src/vs/platform/agentHost/node/codex/codexElicitationMapper.ts

177 LOC · 164 covered · 13 uncovered · 25 ranges · 32 concepts · 7 introducers · 17 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filecodexAgent.ts ×13 · 83 introduced LOCcodexAgent.ts ×13codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1 · 0 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1 · 0 introduced LOCcodexSessionConfigKeys.t…codexAgent.ts ×1 · 27 introduced LOCcodexAgent.ts ×1codexAgent.ts ×24 · 89 introduced LOCcodexAgent.ts ×24codexSessionConfigKeys.ts ×1 · 7 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×7 · 49 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 11 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 4 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×3 · 18 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×3 · 19 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 3 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×6 · 23 introduced LOCcodexSessionConfigKeys.t…codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×3 · 7 introduced LOCcodexAgent.ts ×3codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 10 introduced LOCcodexAgent.ts ×1codexAgent.ts ×8 · 19 introduced LOCcodexAgent.ts ×8codexAgent.ts ×158 · 1640 introduced LOCcodexAgent.ts ×158codexElicitationMapper.ts ×5 · 62 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×5 · 32 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×1 · 3 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×1 · 6 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×3 · 7 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×3 · 5 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.ts ×7 · 49 introduced LOCcodexElicitationMapper.t…codexElicitationMapper.test|title=codexElicitationMapper buildElicitationRequest (form) projects every primitive field kind|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexElicitationMapper.test|title=codexElicitationMapper buildElicitationRequest (form) projects every primitive field kind|occurrence=1codexElicitationMapper.t…codexElicitationMapper.test|title=codexElicitationMapper buildElicitationRequest (url) surfaces the url with no questions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexElicitationMapper.test|title=codexElicitationMapper buildElicitationRequest (url) surfaces the url with no questions|occurrence=1codexElicitationMapper.t…codexElicitationMapper.test|title=codexElicitationMapper elicitationResponseFromAnswers (url accept) carries no content|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexElicitationMapper.test|title=codexElicitationMapper elicitationResponseFromAnswers (url accept) carries no content|occurrence=1codexElicitationMapper.t…accept|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexElicitationMapper.test|title=codexElicitationMapper elicitationResponseFromAnswers maps decline/cancel/accept|occurrence=1accept|occurrence=1codexModelRefresh.test|title=CodexAgent model refresh keeps the last known-good models when a periodic refresh fails|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexModelRefresh.test|title=CodexAgent model refresh keeps the last known-good models when a periodic refresh fails|occurrence=1codexModelRefresh.test|t…codexPackagePaths.test|title=codex package paths codexBinaryTriple every suffix produced by codexPackageSuffix maps to a rust target triple|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexBinaryTriple every suffix produced by codexPackageSuffix maps to a rust target triple|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexBinaryTriple returns undefined for unknown suffixes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexBinaryTriple returns undefined for unknown suffixes|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix every supported (platform, arch) returns the npm optionalDependencies suffix|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix every supported (platform, arch) returns the npm optionalDependencies suffix|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix never returns a -musl suffix on Linux (Codex is statically musl-linked)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix never returns a -musl suffix on Linux (Codex is statically musl-linked)|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix returns undefined for unsupported platforms and architectures|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix returns undefined for unsupported platforms and architectures|occurrence=1codexPackagePaths.test|t…codex resolves|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns the directory containing node_modules when @openai/codex resolves|occurrence=1codex resolves|occurrenc…codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns undefined when resolution throws (e.g. built product without the devDependency)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns undefined when resolution throws (e.g. built product without the devDependency)|occurrence=1codexPackagePaths.test|t…codexSessionConfigKeys.test|title=codexSessionConfigKeys expands permissions presets and falls back to legacy axes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys expands permissions presets and falls back to legacy axes|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys inverts presets and migrates legacy axes without escalating|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys inverts presets and migrates legacy axes without escalating|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys narrows valid values and rejects invalid values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys narrows valid values and rejects invalid values|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1codexSessionConfigKeys.t…Focused file · src/vs/platform/agentHost/node/codex/codexElicitationMapper.ts · 177 LOCcodex/codexElicitationMa…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- codexElicitationMapper.ts ×7
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { hasKey } from '../../../../base/common/types.js';
7 > import { ChatInputAnswerState, ChatInputAnswerValueKind, ChatInputQuestionKind, ChatInputResponseKind, type ChatInputAnswer, type ChatInputOption, type ChatInputQuestion, type ChatInputRequest } from '../../common/state/sessionState.js';
8 > import type { JsonValue } from './protocol/generated/serde_json/JsonValue.js';
9 > import type { McpElicitationPrimitiveSchema } from './protocol/generated/v2/McpElicitationPrimitiveSchema.js';
10 > import type { McpServerElicitationRequestParams } from './protocol/generated/v2/McpServerElicitationRequestParams.js';
11 > import type { McpServerElicitationRequestResponse } from './protocol/generated/v2/McpServerElicitationRequestResponse.js';
12 >
13 > /**
14 > * Translate a codex `mcpServer/elicitation/request` into an agent-host
15 > * {@link ChatInputRequest}. Three modes are supported, mirroring the MCP
16 > * elicitation spec:
17 > *
18 > * - `form` — projects each field of the requested JSON schema into a
19 > * {@link ChatInputQuestion} (text / number / boolean / single- or
20 > * multi-select), reusing the same chat-input surface as the model's
21 > * `ask_user` tool.
22 > * - `openai/form` — carries an opaque, OpenAI-specific form schema we
23 > * cannot project into typed questions; surfaces the message only so the
24 > * user can still accept or decline.
25 > * - `url` — surfaces the URL the server wants the user to open via
26 > * {@link ChatInputRequest.url} with no questions.
27 > *
28 > * MCP field names are used directly as the stable question id (the key
29 > * the answer map is later read back by).
30 > */
31 > export function buildElicitationRequest(requestId: string, params: McpServerElicitationRequestParams): ChatInputRequest {
32 > if (params.mode === 'url') { codexElicitationMapper.ts ×3
33 > const request: ChatInputRequest = { id: requestId, message: params.message }; codexElicitationMapper.ts ×1
34 > if (params.url) {
35 > request.url = params.url;
36 > }
37 > return request;
38 > }
39 > if (params.mode !== 'form') { codexElicitationMapper.ts ×5
40 // `openai/form` carries an opaque, OpenAI-specific schema we cannot
41 // project into typed questions; surface the message only so the user
42 // can still accept or decline.
43 return { id: requestId, message: params.message };
44 }
45 > const required = new Set(params.requestedSchema.required ?? []); codexElicitationMapper.ts ×3
46 > const questions: ChatInputQuestion[] = [];
47 > for (const [name, field] of Object.entries(params.requestedSchema.properties)) {
48 > if (field) { codexElicitationMapper.ts ×5
49 > questions.push(elicitationFieldToQuestion(name, field, required.has(name)));
50 > }
51 > }
52 > return questions.length > 0
53 > ? { id: requestId, message: params.message, questions }
54 : { id: requestId, message: params.message };
57 > /**
58 > * Build the codex elicitation response from the client's answers. A
59 > * declined request maps to `decline`, a cancelled/closed request to
60 > * `cancel`, and an accepted request to `accept` with a `content` object
61 > * keyed by field name (omitting skipped/missing answers). `url`-mode
62 > * acceptances carry no content.
63 > */
64 > export function elicitationResponseFromAnswers(
65 > params: McpServerElicitationRequestParams, codexElicitationMapper.ts ×3
66 > response: ChatInputResponseKind,
67 > answers: Record<string, ChatInputAnswer> | undefined,
68 > ): McpServerElicitationRequestResponse {
69 > if (response === ChatInputResponseKind.Decline) {
70 > return { action: 'decline', content: null, _meta: null }; codexElicitationMapper.ts ×5
71 > }
72 > if (response !== ChatInputResponseKind.Accept) { codexElicitationMapper.ts ×3
73 > return { action: 'cancel', content: null, _meta: null }; codexElicitationMapper.ts ×5
74 > }
75 > if (params.mode !== 'form') { codexElicitationMapper.ts ×3
76 > // `url` and `openai/form` acceptances carry no projected content. codexElicitationMapper.ts ×1
77 > return { action: 'accept', content: null, _meta: null };
78 > }
79 > const content: { [key: string]: JsonValue } = {}; codexElicitationMapper.ts ×5
80 > for (const [name, field] of Object.entries(params.requestedSchema.properties)) {
81 > if (!field) {
82 continue;
83 }
84 > const value = elicitationAnswerToValue(answers?.[name]); codexElicitationMapper.ts ×5
85 > if (value !== undefined) {
86 > content[name] = value;
87 > }
88 > }
89 > return { action: 'accept', content, _meta: null };
90 > }
92 > /** Decline response used when there is no session to route the elicitation to. */
93 > export function declinedElicitationResponse(): McpServerElicitationRequestResponse {
94 return { action: 'decline', content: null, _meta: null };
95 }
97 > /** Cancel response used when the session is torn down mid-elicitation. */
98 > export function cancelledElicitationResponse(): McpServerElicitationRequestResponse {
99 return { action: 'cancel', content: null, _meta: null };
100 }
102 > function elicitationFieldToQuestion(id: string, field: McpElicitationPrimitiveSchema, required: boolean): ChatInputQuestion { codexElicitationMapper.ts ×5
103 > const base = { id, title: field.title, message: field.description ?? field.title ?? id, required };
104 >
105 > switch (field.type) {
106 > case 'boolean':
107 > return { ...base, kind: ChatInputQuestionKind.Boolean, defaultValue: field.default };
108 > case 'number':
109 > case 'integer':
110 > return {
111 > ...base,
112 > kind: field.type === 'integer' ? ChatInputQuestionKind.Integer : ChatInputQuestionKind.Number,
113 > min: field.minimum,
114 > max: field.maximum,
115 > defaultValue: field.default,
116 > };
117 > case 'array':
118 > return {
119 > ...base,
120 > kind: ChatInputQuestionKind.MultiSelect,
121 > options: hasKey(field.items, { anyOf: true })
122 ? field.items.anyOf.map((o): ChatInputOption => ({ id: o.const, label: o.title || o.const }))
123 > : field.items.enum.map((v): ChatInputOption => ({ id: v, label: v })), codexElicitationMapper.ts ×5
124 > min: bigintToNumber(field.minItems),
125 > max: bigintToNumber(field.maxItems),
126 > };
127 > case 'string':
128 > // Titled single-select (`oneOf`), enum/legacy single-select (`enum`,
129 > // optionally `enumNames`), or a plain text field.
130 > if (hasKey(field, { oneOf: true })) {
131 > return {
132 > ...base,
133 > kind: ChatInputQuestionKind.SingleSelect,
134 > options: field.oneOf.map((o): ChatInputOption => ({ id: o.const, label: o.title || o.const })),
135 > };
136 > }
137 > if (hasKey(field, { enum: true })) {
138 > const names: readonly string[] | undefined = (field as { enumNames?: readonly string[] }).enumNames;
139 > return {
140 > ...base,
141 > kind: ChatInputQuestionKind.SingleSelect,
142 > options: field.enum.map((v, i): ChatInputOption => ({ id: v, label: names?.[i] || v })),
143 > };
144 > }
145 > return {
146 > ...base,
147 > kind: ChatInputQuestionKind.Text,
148 > format: field.format,
149 > min: field.minLength,
150 > max: field.maxLength,
151 > defaultValue: field.default,
152 > };
153 > }
154 > }
156 > function elicitationAnswerToValue(answer: ChatInputAnswer | undefined): JsonValue | undefined { codexElicitationMapper.ts ×5
157 > if (!answer || answer.state === ChatInputAnswerState.Skipped) {
158 > return undefined;
159 > }
160 > const { value } = answer;
161 > switch (value.kind) {
162 > case ChatInputAnswerValueKind.Text:
163 > return value.value;
164 > case ChatInputAnswerValueKind.Number:
165 > return value.value;
166 > case ChatInputAnswerValueKind.Boolean:
167 > return value.value;
168 > case ChatInputAnswerValueKind.Selected:
169 > return value.value;
170 > case ChatInputAnswerValueKind.SelectedMany:
171 > return value.value;
172 > }
173 > }
175 > function bigintToNumber(value: bigint | null | undefined): number | undefined { codexElicitationMapper.ts ×5
176 > return value === null || value === undefined ? undefined : Number(value);
177 > }