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

87 LOC · 87 covered · 0 uncovered · 17 ranges · 33 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 ×158codexUserInputMapper.ts ×2 · 2 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.test|title=codexUserInputMapper userInputResponseFromAnswers flattens answers per question id|occurrence=1 · 0 introduced LOCcodexUserInputMapper.tes…codexUserInputMapper.ts ×2 · 8 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.ts ×2 · 5 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.ts ×1 · 10 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.ts ×5 · 7 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.ts ×1 · 24 introduced LOCcodexUserInputMapper.ts …codexUserInputMapper.ts ×4 · 31 introduced LOCcodexUserInputMapper.ts …codexModelRefresh.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…codexUserInputMapper.test|title=codexUserInputMapper answerStrings handles every value kind and freeform|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexUserInputMapper.test|title=codexUserInputMapper answerStrings handles every value kind and freeform|occurrence=1codexUserInputMapper.tes…codexUserInputMapper.test|title=codexUserInputMapper buildUserInputRequest maps select and text questions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexUserInputMapper.test|title=codexUserInputMapper buildUserInputRequest maps select and text questions|occurrence=1codexUserInputMapper.tes…missing answers yield empty arrays|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexUserInputMapper.test|title=codexUserInputMapper declined/skipped/missing answers yield empty arrays|occurrence=1missing answers yield em…codexUserInputMapper.test|title=codexUserInputMapper userInputResponseFromAnswers flattens answers per question id|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexUserInputMapper.test|title=codexUserInputMapper userInputResponseFromAnswers flattens answers per question id|occurrence=1codexUserInputMapper.tes…Focused file · src/vs/platform/agentHost/node/codex/codexUserInputMapper.ts · 87 LOCcodex/codexUserInputMapp…

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 > /*--------------------------------------------------------------------------------------------- codexUserInputMapper.ts ×4
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 { ChatInputAnswerState, ChatInputAnswerValueKind, ChatInputQuestionKind, ChatInputResponseKind, type ChatInputAnswer, type ChatInputQuestion, type ChatInputRequest } from '../../common/state/sessionState.js';
7 > import type { ToolRequestUserInputAnswer } from './protocol/generated/v2/ToolRequestUserInputAnswer.js';
8 > import type { ToolRequestUserInputQuestion } from './protocol/generated/v2/ToolRequestUserInputQuestion.js';
9 > import type { ToolRequestUserInputResponse } from './protocol/generated/v2/ToolRequestUserInputResponse.js';
10 >
11 > /**
12 > * Translate codex `request_user_input` (the model's `ask_user`) questions into
13 > * an agent-host {@link ChatInputRequest}. Questions with options become a
14 > * single-select (with freeform allowed when codex marks `isOther`); option-less
15 > * questions become a free text question. Codex options have no stable id, so
16 > * the option label doubles as the id.
17 > */
18 > export function buildUserInputRequest(requestId: string, questions: readonly ToolRequestUserInputQuestion[]): ChatInputRequest {
20 > id: requestId,
21 > questions: questions.map((q): ChatInputQuestion => {
22 > if (q.options && q.options.length > 0) {
23 > return {
24 > kind: ChatInputQuestionKind.SingleSelect,
25 > id: q.id,
26 > title: q.header,
27 > message: q.question,
28 > required: true,
29 > options: q.options.map(o => ({ id: o.label, label: o.label, description: o.description || undefined })),
30 > allowFreeformInput: q.isOther,
31 > };
32 > }
33 > return {
34 > kind: ChatInputQuestionKind.Text,
35 > id: q.id,
36 > title: q.header,
37 > message: q.question,
38 > required: true,
39 > };
40 > }),
41 > };
42 > }
44 > /**
45 > * Build the codex `request_user_input` response from the client's answers.
46 > * Codex expects an answer (a string array) per question id; a declined/cancelled
47 > * request or a skipped/missing answer yields an empty array for that question.
48 > */
49 > export function userInputResponseFromAnswers(
50 > questions: readonly ToolRequestUserInputQuestion[], codexUserInputMapper.ts ×1
51 > response: ChatInputResponseKind,
52 > answers: Record<string, ChatInputAnswer> | undefined,
53 > ): ToolRequestUserInputResponse {
54 > const out: Record<string, ToolRequestUserInputAnswer> = {};
55 > for (const q of questions) {
56 > out[q.id] = { answers: answerStrings(answers?.[q.id], response) };
57 > }
58 > return { answers: out };
59 > }
61 > /** Response with empty answers for every question (used when there is no session to ask). */
62 > export function emptyUserInputResponse(questions: readonly ToolRequestUserInputQuestion[]): ToolRequestUserInputResponse {
63 > const out: Record<string, ToolRequestUserInputAnswer> = {}; codexUserInputMapper.ts ×2
64 > for (const q of questions) {
65 > out[q.id] = { answers: [] };
66 > }
67 > return { answers: out };
68 > }
70 > /** Flatten a single chat input answer into the string array codex expects. */
71 > export function answerStrings(answer: ChatInputAnswer | undefined, response: ChatInputResponseKind): string[] {
72 > if (response !== ChatInputResponseKind.Accept || !answer || answer.state === ChatInputAnswerState.Skipped) { codexUserInputMapper.ts ×5
73 > return []; codexUserInputMapper.ts ×2
74 > }
75 > const { value } = answer; codexUserInputMapper.ts ×2
76 > switch (value.kind) {
77 > case ChatInputAnswerValueKind.Text:
78 > return [value.value];
79 > case ChatInputAnswerValueKind.Number: codexUserInputMapper.ts ×5
80 > case ChatInputAnswerValueKind.Boolean:
81 > return [String(value.value)]; codexUserInputMapper.ts ×2
82 > case ChatInputAnswerValueKind.Selected: codexUserInputMapper.ts ×5
83 > return [value.value, ...(value.freeformValues ?? [])]; codexUserInputMapper.ts ×2
84 > case ChatInputAnswerValueKind.SelectedMany: codexUserInputMapper.ts ×5
85 > return [...value.value, ...(value.freeformValues ?? [])]; codexUserInputMapper.ts ×2
87 > }