chatToolInvocation.ts ×8

Frontier kind: Code frontier

unlabeled · c_b4a5be9d2d99

9 tests · 44288 LOC · 194 files · introduces 0 tests · 74 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges74 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4025 ranges44288 lines · 194 files · Browse complete extent
All tests (intent)
9 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.

3 files ranked by introduced lines: 74 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatModel.ts 35 introduced LOC · 4 ranges

Open complete file

961 this._contentChanged(quiet);
962 } else if (progress.kind === 'externalToolInvocationUpdate') {
963 > this._handleExternalToolInvocationUpdate(progress); chatModel.ts
964 > this._contentChanged(quiet);
965 } else {
966 this._responseParts.push(progress);
1028
1029 private _handleExternalToolInvocationUpdate(progress: IChatExternalToolInvocationUpdate): void {
1030 > // Look for existing invocation in the response parts chatModel.ts
1031 > const existingInvocation = this._responseParts.findLast(
1032 > (part): part is ChatToolInvocation => part.kind === 'toolInvocation' && part.toolCallId === progress.toolCallId
1033 > );
1034 >
1035 > if (existingInvocation) {
1036 if (progress.toolSpecificData !== undefined) {
1037 existingInvocation.toolSpecificData = progress.toolSpecificData;
1047 return;
1048 }
1049 > chatModel.ts
1050 > // Create a new external tool invocation
1051 > const toolData: IToolData = {
1052 > id: progress.toolName,
1053 > source: ToolDataSource.External,
1054 > displayName: progress.toolName,
1055 > modelDescription: progress.toolName,
1056 > };
1057 >
1058 > const invocation = new ChatToolInvocation(
1059 > {
1060 > invocationMessage: progress.invocationMessage,
1061 > pastTenseMessage: progress.pastTenseMessage,
1062 > toolSpecificData: progress.toolSpecificData,
1063 > },
1064 > toolData,
1065 > progress.toolCallId,
1066 > progress.subagentInvocationId,
1067 > undefined, // parameters
1068 > {},
1069 > undefined // chatRequestId
1070 > );
1071 >
1072 > if (progress.isComplete) {
1073 // Already completed on first push
1074 if (progress.toolSpecificData !== undefined) {
1082 });
1083 }
1084 > chatModel.ts
1085 > this._responseParts.push(invocation);
1086 > }
1087
1088 protected override computeRepr(): string {
src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.ts 31 introduced LOC · 8 ranges

Open complete file

124 });
125 } else if (!this.confirmationMessages?.title) {
126 > this._state = observableValue(this, { chatToolInvocation.ts
127 > type: IChatToolInvocation.StateKind.Executing,
128 > confirmed: { type: ToolConfirmKind.ConfirmationNotNeeded, reason: this.confirmationMessages?.confirmationNotNeededReason },
129 > progress: this._progress,
130 > parameters: this.parameters,
131 > confirmationMessages: this.confirmationMessages,
132 > });
133 > } else {
134 this._state = observableValue(this, {
135 type: IChatToolInvocation.StateKind.WaitingForConfirmation,
310
311 private _setCompleted(result: IToolResult | undefined, postConfirmed?: ConfirmedReason | undefined) {
312 > if (postConfirmed && (postConfirmed.type === ToolConfirmKind.Denied || postConfirmed.type === ToolConfirmKind.Skipped)) { chatToolInvocation.ts
313 this._state.set({
314 type: IChatToolInvocation.StateKind.Cancelled,
319 return;
320 }
322 > this._state.set({
323 > type: IChatToolInvocation.StateKind.Completed,
324 > confirmed: IChatToolInvocation.executionConfirmedOrDenied(this) || { type: ToolConfirmKind.ConfirmationNotNeeded },
325 > resultDetails: result?.toolResultDetails,
326 > postConfirmed,
327 > contentForModel: result?.content || [],
328 > parameters: this.parameters,
329 > confirmationMessages: this.confirmationMessages,
330 > }, undefined);
331 > }
332
333 public async didExecuteTool(result: IToolResult | undefined, final?: boolean, checkIfResultAutoApproved?: () => Promise<ConfirmedReason | undefined>): Promise<IChatToolInvocation.State> {
334 > if (result?.toolSpecificData) { chatToolInvocation.ts
335 this.toolSpecificData = result.toolSpecificData;
336 }
337 > if (result?.toolResultMessage) { chatToolInvocation.ts
338 this.pastTenseMessage = result.toolResultMessage;
339 > } else if (this._progress.get().message) { chatToolInvocation.ts
340 this.pastTenseMessage = this._progress.get().message;
341 }
343 > if (this.confirmationMessages?.confirmResults && !result?.toolResultError && result?.confirmResults !== false && !final) {
344 const autoApproved = await checkIfResultAutoApproved?.();
345 if (autoApproved) {
356 }, undefined);
357 }
358 > } else { chatToolInvocation.ts
359 > this._setCompleted(result);
360 > }
361 >
362 > return this._state.get();
363 > }
364
365 public setAuthenticationRequired(server: IChatMcpAuthenticationRequiredServer, cancel: () => void = () => { }): void {
src/vs/workbench/contrib/chat/common/chatService/chatService.ts 8 introduced LOC · 4 ranges

Open complete file

866
867 export function executionConfirmedOrDenied(invocation: IChatToolInvocation | IChatToolInvocationSerialized, reader?: IReader): ConfirmedReason | undefined {
868 > if (invocation.kind === 'toolInvocationSerialized') { chatService.ts
869 if (invocation.isConfirmed === undefined || typeof invocation.isConfirmed === 'boolean') {
870 return { type: invocation.isConfirmed ? ToolConfirmKind.UserAction : ToolConfirmKind.Denied };
872 return invocation.isConfirmed;
873 }
875 > const state = invocation.state.read(reader);
876 > if (state.type === StateKind.Streaming || state.type === StateKind.WaitingForConfirmation) {
877 return undefined; // don't know yet
878 }
879 > if (state.type === StateKind.Cancelled) { chatService.ts
880 return { type: state.reason };
881 }
883 > return state.confirmed;
884 > }
885
886 export function awaitConfirmation(invocation: IChatToolInvocation, token?: CancellationToken): Promise<ConfirmedReason> {