copilotAgentSession.ts ×12

Frontier kind: Code frontier

unlabeled · c_9e4abb24ad3d

36 tests · 43543 LOC · 242 files · introduces 0 tests · 47 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges47 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3968 ranges43543 lines · 242 files · Browse complete extent
All tests (intent)
36 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: 47 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts 47 introduced LOC · 12 ranges

Open complete file

2137 */
2138 private async _handlePermissionRequest(
2139 > request: ITypedPermissionRequest, copilotAgentSession.ts
2140 > ): Promise<PermissionRequestResult> {
2141 > try {
2142 > const toolCallId = request.toolCallId;
2143 > if (!toolCallId) {
2144 // TODO: handle permission requests without a toolCallId by creating a synthetic tool call
2145 this._logService.warn(`[Copilot:${this.sessionId}] Permission request without toolCallId, auto-denying: kind=${request.kind}`);
2150 ? await this._takeAutoApproval(toolCallId)
2151 : undefined;
2152 > const recommendation = autoApproval?.recommendation; copilotAgentSession.ts
2153 > if (recommendation === 'approve' && !request.requestSandboxBypass) {
2154 if (request.kind === 'custom-tool'
2155 && typeof request.toolName === 'string'
2209 if (request.kind === 'read' && typeof request.path === 'string'
2210 && this._isSessionAttachmentPath(request.path)
2212 this._logService.info(`[Copilot:${this.sessionId}] Auto-approving session attachment ${request.path}`);
2213 return { kind: 'approve-once' };
2218 // `os.tmpdir()/copilot-tool-output-…txt` and then asks the model
2219 // to read them back in a follow-up turn — no need to confirm.
2220 > if (request.kind === 'read' && typeof request.path === 'string') { copilotAgentSession.ts
2221 if (isCopilotSdkToolOutputTempFile(request.path, this._environmentService.tmpDir.fsPath)) {
2222 this._logService.info(`[Copilot:${this.sessionId}] Auto-approving Copilot SDK tool-output temp file ${request.path}`);
2233 && this._serverToolHost?.toolNames.includes(request.toolName)
2234 && !this._serverToolHost.requiresConfirmation(request.toolName)
2236 this._logService.info(`[Copilot:${this.sessionId}] Auto-approving server tool ${request.toolName}`);
2237 return { kind: 'approve-once' };
2240 const isShellRequest = request.kind === 'shell'
2241 || (request.kind === 'custom-tool' && typeof request.toolName === 'string' && isShellTool(request.toolName));
2243 > if (request.kind === 'custom-tool'
2244 && typeof request.toolName === 'string'
2245 && this._clientToolNames.has(this._clientToolName(request.toolName))
2246 && this._pendingClientToolCalls.hasBufferedResult(toolCallId)
2248 this._logService.info(`[Copilot:${this.sessionId}] Auto-approving client tool ${request.toolName} because its result arrived before the permission request`);
2249 return { kind: 'approve-once' };
2261 // `sandbox.allowBypass` would let the model escape the sandbox with no
2262 // prompt at all.
2263 > if (isShellRequest && !request.requestSandboxBypass && await this._isShellSandboxedByDefault()) { copilotAgentSession.ts
2264 // Session may have been disposed while we awaited the engine
2265 // check; if so the deferred has already been settled and
2288 }
2289
2290 > const isNewFile = edits?.items.some(edit => !edit.before && !!edit.after); copilotAgentSession.ts
2291 > const { confirmationTitle, invocationMessage, toolInput, permissionKind, permissionPath } = getPermissionDisplay(request, this._workingDirectory, isNewFile);
2292 >
2293 > // Fire a pending_confirmation signal to transition the tool to PendingConfirmation
2294 > const toolName = request.toolName ?? request.kind;
2295 > // Forward the tool's parentToolCallId (if any) so the host can
2296 > // route the resulting ChatToolCallReady to the correct
2297 > // subagent session — without it the action would land on the
2298 > // parent session, which has no matching ChatToolCallStart.
2299 > const parentToolCallId = this._activeToolCalls.get(toolCallId)?.parentToolCallId;
2300 > this._onDidSessionProgress.fire({
2301 > kind: 'pending_confirmation',
2302 > chat: this._chatChannelUri,
2303 > state: {
2304 > status: ToolCallStatus.PendingConfirmation,
2305 > toolCallId,
2306 > toolName,
2307 > displayName: getToolDisplayName(toolName),
2308 > invocationMessage,
2309 > toolInput,
2310 > confirmationTitle,
2311 > riskAssessment: autoApproval?.reason
2312 ? {
2313 kind: ToolCallRiskAssessmentKind.Judge,
2317 }
2318 : undefined,
2319 > edits, copilotAgentSession.ts
2320 > },
2321 > permissionKind,
2322 > permissionPath,
2323 > requestSandboxBypass: request.requestSandboxBypass,
2324 > parentToolCallId,
2325 > });
2326 >
2327 > const result = await deferred.p;
2328 this._logService.info(`[Copilot:${this.sessionId}] Permission response: toolCallId=${toolCallId}, result=${result.kind}`);
2329 > if (result.kind === 'approve-once' && (request.kind === 'write' || request.kind === 'read')) { copilotAgentSession.ts
2330 this._approvedDuplicablePermissionSignatures.set(toolCallId, safeStringify(request));
2331 }
2335 throw error;
2336 }
2338
2339 private _getInternalSessionResourcePath(request: ITypedPermissionRequest): string | undefined {