claudeCanUseTool.ts ×6

Frontier kind: Code frontier

unlabeled · c_8256da55d856

13 tests · 56514 LOC · 346 files · introduces 0 tests · 53 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges53 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5605 ranges56514 lines · 346 files · Browse complete extent
All tests (intent)
13 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: 53 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeCanUseTool.ts 53 introduced LOC · 6 ranges

Open complete file

89 return { behavior: 'deny', message: 'SDK aborted the tool request' };
90 }
91 > const abortHandler = () => { claudeCanUseTool.ts
92 session.respondToPermissionRequest(options.toolUseID, false);
93 session.respondToUserInputRequest(options.toolUseID, ChatInputResponseKind.Cancel);
94 };
95 > options.signal.addEventListener('abort', abortHandler); claudeCanUseTool.ts
96 > try {
97 > return await dispatchCanUseTool(deps, session, toolName, input, options);
98 > } finally {
99 > options.signal.removeEventListener('abort', abortHandler);
100 > }
101 }
102
103 > async function dispatchCanUseTool( claudeCanUseTool.ts
104 > deps: IClaudeCanUseToolDeps,
105 > session: ClaudeAgentSession,
106 > toolName: string,
107 > input: Record<string, unknown>,
108 > options: IClaudeCanUseToolOptions,
109 > ): Promise<PermissionResult> {
110 > // Interactive tools (`AskUserQuestion`, `ExitPlanMode`) are
111 > // exempt from SDK `permissionMode` auto-approval, so they reach
112 > // `canUseTool` even under `bypassPermissions`. Routing then
113 > // splits by tool semantics rather than by the
114 > // `INTERACTIVE_CLAUDE_TOOLS` flag itself: `ExitPlanMode` is a
115 > // permission gate (Approve/Deny on whether to leave plan mode)
116 > // so it uses the standard `pending_confirmation` channel with
117 > // custom button labels; `AskUserQuestion` is structured user
118 > // input (a question carousel) so it routes through
119 > // `requestUserInput` / `ChatInputRequested`.
120 > if (INTERACTIVE_CLAUDE_TOOLS.has(toolName)) {
121 return handleInteractiveTool(deps, session, toolName, input, options);
122 }
125 const displayName = getClaudeToolDisplayName(toolName);
126 const permissionPath = options.blockedPath ?? getClaudeToolPath(toolName, input);
127 > const toolInputString = getClaudeToolInputString(toolName, input); claudeCanUseTool.ts
128 > const meta = buildClaudeToolMeta(toolName);
129 > const state: ToolCallPendingConfirmationState = {
130 > status: ToolCallStatus.PendingConfirmation,
131 > toolCallId: options.toolUseID,
132 > toolName,
133 > displayName,
134 > invocationMessage: getClaudeInvocationMessage(toolName, displayName, input),
135 > toolInput: toolInputString,
136 > confirmationTitle: getClaudeConfirmationTitle(toolName),
137 > ...(meta ? { _meta: meta } : {}),
138 > };
139 >
140 > const parentToolCallId = resolveSubagentParent(session, options);
141 >
142 > const approved = await session.requestPermission({
143 > toolUseID: options.toolUseID,
144 > state,
145 > permissionKind,
146 > ...(permissionPath !== undefined ? { permissionPath } : {}),
147 > ...(parentToolCallId !== undefined ? { parentToolCallId } : {}),
148 > });
149 return approved
150 ? { behavior: 'allow', updatedInput: input }
151 : { behavior: 'deny', message: CLAUDE_USER_DECLINED_MESSAGE };
153
154 /**
164 * tool call (no subagent context).
165 */
166 > function resolveSubagentParent( claudeCanUseTool.ts
167 > session: ClaudeAgentSession,
168 > options: IClaudeCanUseToolOptions,
169 > ): string | undefined {
170 > if (!options.agentID) {
171 return undefined;
172 }