claudeInteractiveTools.ts ×6

Frontier kind: Code frontier

unlabeled · c_219f7a93c6c4

211 tests · 17850 LOC · 66 files · introduces 0 tests · 86 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges86 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1174 ranges17850 lines · 66 files · Browse complete extent
All tests (intent)
211 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 86 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeInteractiveTools.ts 86 introduced LOC · 6 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- claudeInteractiveTools.ts
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 { localize } from '../../../../nls.js';
7 > import { ConfirmationOptionKind, ChatInputAnswerState, ChatInputAnswerValueKind, ChatInputQuestionKind, ToolCallStatus, type ChatInputOption, type ChatInputQuestion, type ToolCallPendingConfirmationState } from '../../common/state/protocol/state.js';
8 > import type { ChatInputAnswer } from '../../common/state/sessionState.js';
9 > import { getClaudeToolDisplayName } from './claudeToolDisplay.js';
10 >
11 > /**
12 > * Pure projections between the Claude SDK's interactive built-in tool
13 > * inputs/outputs and the agentHost workbench protocol.
14 > *
15 > * Phase 7 S3.5. The two interactive tools (`ExitPlanMode`,
16 > * `AskUserQuestion`) are exempt from the SDK's `permissionMode` auto-
17 > * approval and always reach `canUseTool`. The agent's job for each is
18 > * to render a workbench prompt and translate the user's answer back
19 > * into the SDK's `PermissionResult` shape — this module owns those
20 > * projections so they can be tested without standing up an agent.
21 > */
22 >
23 > // #region ExitPlanMode
24 >
25 > /**
26 > * Build the {@link ToolCallPendingConfirmationState} card body for the
27 > * `ExitPlanMode` confirmation. Custom Approve / Deny buttons (no "Allow
28 > * in this Session") so the approval is never remembered — each plan
29 > * must be approved on its own merit. Mirrors the production extension's
30 > * `exitPlanModeHandler.ts`.
31 > */
32 > export function buildExitPlanModeConfirmationState(input: Record<string, unknown>, toolUseID: string): ToolCallPendingConfirmationState {
33 const plan = typeof input.plan === 'string' ? input.plan : '';
34 return {
46 };
47 }
49 > // #endregion
50 >
51 > // #region AskUserQuestion
52 >
53 > /**
54 > * Narrowed view of the `AskUserQuestion` SDK input. The SDK delivers
55 > * questions as `Record<string, unknown>`; we cast (no schema validation
56 > * — the SDK is the upstream authority) and surface the subset we use.
57 > */
58 > export interface ParsedAskUserQuestionInput {
59 > readonly questions: ReadonlyArray<{
60 > readonly question: string;
61 > readonly header: string;
62 > readonly options: ReadonlyArray<{ label: string; description?: string }>;
63 > readonly multiSelect?: boolean;
64 > readonly allowFreeformInput?: boolean;
65 > }>;
66 > }
67 >
68 > /**
69 > * Cast the `AskUserQuestion` SDK input into the typed shape. Returns
70 > * `undefined` when there are no questions — the agent translates that
71 > * to a `deny` `PermissionResult`.
72 > */
73 > export function parseAskUserQuestionInput(input: Record<string, unknown>): ParsedAskUserQuestionInput | undefined {
74 const askInput = input as Partial<ParsedAskUserQuestionInput>;
75 if (!askInput.questions?.length) {
78 return { questions: askInput.questions };
79 }
81 > /**
82 > * Derive the workbench question id for the `idx`-th SDK question.
83 > * Both {@link buildAskUserSessionInputQuestions} and
84 > * {@link flattenAskUserAnswers} key into the answers map by this id, so
85 > * keep the two callers in sync via this helper. Empty-header questions
86 > * fall back to a positional id so they round-trip; they would
87 > * otherwise collide on `''`.
88 > */
89 function askUserQuestionId(header: string, idx: number): string {
90 return header || `q-${idx}`;
91 }
93 > /**
94 > * Project the parsed SDK questions into the workbench's
95 > * {@link ChatInputQuestion} shape. `multiSelect` flips the question
96 > * kind; the rest of the fields map 1:1.
97 > */
98 > export function buildAskUserSessionInputQuestions(askInput: ParsedAskUserQuestionInput): ChatInputQuestion[] {
99 return askInput.questions.map((q, idx) => {
100 const opts: ChatInputOption[] = q.options.map(opt => ({
123 });
124 }
126 > /**
127 > * Re-key the workbench answers from `{questionHeader → ChatInputAnswer}`
128 > * into the production extension's `Record<questionText, valueString>`
129 > * contract. Skipped questions and empty answers are dropped; the result
130 > * is `{}` when nothing was answered. Single-select / multi-select /
131 > * text answer shapes flatten to a comma-joined string (matching the
132 > * production extension's wire format).
133 > */
134 > export function flattenAskUserAnswers(askInput: ParsedAskUserQuestionInput, answers: Record<string, ChatInputAnswer>): Record<string, string> {
135 const result: Record<string, string> = {};
136 for (let idx = 0; idx < askInput.questions.length; idx++) {