mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Merge pull request #257296 from microsoft/tyriar/256552
Remove IChatTerminalToolInvocationData
This commit is contained in:
@@ -1871,7 +1871,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||||||
LanguageModelToolExtensionSource: extHostTypes.LanguageModelToolExtensionSource,
|
LanguageModelToolExtensionSource: extHostTypes.LanguageModelToolExtensionSource,
|
||||||
LanguageModelToolMCPSource: extHostTypes.LanguageModelToolMCPSource,
|
LanguageModelToolMCPSource: extHostTypes.LanguageModelToolMCPSource,
|
||||||
ExtendedLanguageModelToolResult: extHostTypes.ExtendedLanguageModelToolResult,
|
ExtendedLanguageModelToolResult: extHostTypes.ExtendedLanguageModelToolResult,
|
||||||
PreparedTerminalToolInvocation: extHostTypes.PreparedTerminalToolInvocation,
|
|
||||||
LanguageModelChatToolMode: extHostTypes.LanguageModelChatToolMode,
|
LanguageModelChatToolMode: extHostTypes.LanguageModelChatToolMode,
|
||||||
LanguageModelPromptTsxPart: extHostTypes.LanguageModelPromptTsxPart,
|
LanguageModelPromptTsxPart: extHostTypes.LanguageModelPromptTsxPart,
|
||||||
NewSymbolName: extHostTypes.NewSymbolName,
|
NewSymbolName: extHostTypes.NewSymbolName,
|
||||||
|
|||||||
@@ -184,10 +184,6 @@ export class ExtHostLanguageModelTools implements ExtHostLanguageModelToolsShape
|
|||||||
options.chatRequestId = dto.chatRequestId;
|
options.chatRequestId = dto.chatRequestId;
|
||||||
options.chatInteractionId = dto.chatInteractionId;
|
options.chatInteractionId = dto.chatInteractionId;
|
||||||
options.chatSessionId = dto.context?.sessionId;
|
options.chatSessionId = dto.context?.sessionId;
|
||||||
|
|
||||||
if (dto.toolSpecificData?.kind === 'terminal') {
|
|
||||||
options.terminalCommand = dto.toolSpecificData.command;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProposedApiEnabled(item.extension, 'chatParticipantAdditions') && dto.modelId) {
|
if (isProposedApiEnabled(item.extension, 'chatParticipantAdditions') && dto.modelId) {
|
||||||
@@ -251,25 +247,7 @@ export class ExtHostLanguageModelTools implements ExtHostLanguageModelToolsShape
|
|||||||
chatSessionId: context.chatSessionId,
|
chatSessionId: context.chatSessionId,
|
||||||
chatInteractionId: context.chatInteractionId
|
chatInteractionId: context.chatInteractionId
|
||||||
};
|
};
|
||||||
if (isProposedApiEnabled(item.extension, 'chatParticipantPrivate') && item.tool.prepareInvocation2) {
|
if (item.tool.prepareInvocation) {
|
||||||
const result = await item.tool.prepareInvocation2(options, token);
|
|
||||||
if (!result) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
confirmationMessages: result.confirmationMessages ? {
|
|
||||||
title: typeof result.confirmationMessages.title === 'string' ? result.confirmationMessages.title : typeConvert.MarkdownString.from(result.confirmationMessages.title),
|
|
||||||
message: typeof result.confirmationMessages.message === 'string' ? result.confirmationMessages.message : typeConvert.MarkdownString.from(result.confirmationMessages.message),
|
|
||||||
} : undefined,
|
|
||||||
toolSpecificData: {
|
|
||||||
kind: 'terminal',
|
|
||||||
language: result.language,
|
|
||||||
command: result.command,
|
|
||||||
},
|
|
||||||
presentation: result.presentation
|
|
||||||
};
|
|
||||||
} else if (item.tool.prepareInvocation) {
|
|
||||||
const result = await item.tool.prepareInvocation(options, token);
|
const result = await item.tool.prepareInvocation(options, token);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -4839,15 +4839,6 @@ export class LanguageModelToolResultPart2 implements vscode.LanguageModelToolRes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PreparedTerminalToolInvocation {
|
|
||||||
constructor(
|
|
||||||
public readonly command: string,
|
|
||||||
public readonly language: string,
|
|
||||||
public readonly confirmationMessages?: vscode.LanguageModelToolConfirmationMessages,
|
|
||||||
public readonly presentation?: 'hidden'
|
|
||||||
) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ChatErrorLevel {
|
export enum ChatErrorLevel {
|
||||||
Info = 0,
|
Info = 0,
|
||||||
Warning = 1,
|
Warning = 1,
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ export const getToolConfirmationAlert = (accessor: ServicesAccessor, toolInvocat
|
|||||||
let input = '';
|
let input = '';
|
||||||
if (v.toolSpecificData) {
|
if (v.toolSpecificData) {
|
||||||
if (v.toolSpecificData.kind === 'terminal') {
|
if (v.toolSpecificData.kind === 'terminal') {
|
||||||
input = v.toolSpecificData.command;
|
|
||||||
} else if (v.toolSpecificData.kind === 'terminal2') {
|
|
||||||
input = v.toolSpecificData.commandLine.toolEdited ?? v.toolSpecificData.commandLine.original;
|
input = v.toolSpecificData.commandLine.toolEdited ?? v.toolSpecificData.commandLine.original;
|
||||||
} else if (v.toolSpecificData.kind === 'extensions') {
|
} else if (v.toolSpecificData.kind === 'extensions') {
|
||||||
input = JSON.stringify(v.toolSpecificData.extensions);
|
input = JSON.stringify(v.toolSpecificData.extensions);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
|
|||||||
import { ThemeIcon } from '../../../../../../base/common/themables.js';
|
import { ThemeIcon } from '../../../../../../base/common/themables.js';
|
||||||
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
|
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
|
||||||
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
|
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
|
||||||
import { IChatMarkdownContent, IChatTerminalToolInvocationData, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData2 } from '../../../common/chatService.js';
|
import { IChatMarkdownContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData } from '../../../common/chatService.js';
|
||||||
import { CodeBlockModelCollection } from '../../../common/codeBlockModelCollection.js';
|
import { CodeBlockModelCollection } from '../../../common/codeBlockModelCollection.js';
|
||||||
import { IChatCodeBlockInfo } from '../../chat.js';
|
import { IChatCodeBlockInfo } from '../../chat.js';
|
||||||
import { ICodeBlockRenderOptions } from '../../codeBlockPart.js';
|
import { ICodeBlockRenderOptions } from '../../codeBlockPart.js';
|
||||||
@@ -27,7 +27,7 @@ export class ChatTerminalMarkdownProgressPart extends BaseChatToolInvocationSubP
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
|
toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
|
||||||
terminalData: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2,
|
terminalData: IChatTerminalToolInvocationData,
|
||||||
context: IChatContentPartRenderContext,
|
context: IChatContentPartRenderContext,
|
||||||
renderer: MarkdownRenderer,
|
renderer: MarkdownRenderer,
|
||||||
editorPool: EditorPool,
|
editorPool: EditorPool,
|
||||||
@@ -38,9 +38,7 @@ export class ChatTerminalMarkdownProgressPart extends BaseChatToolInvocationSubP
|
|||||||
) {
|
) {
|
||||||
super(toolInvocation);
|
super(toolInvocation);
|
||||||
|
|
||||||
const command = terminalData.kind === 'terminal'
|
const command = terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original;
|
||||||
? terminalData.command
|
|
||||||
: terminalData.commandLine.userEdited ?? terminalData.commandLine.toolEdited ?? terminalData.commandLine.original;
|
|
||||||
|
|
||||||
const content = new MarkdownString(`\`\`\`${terminalData.language}\n${command}\n\`\`\``);
|
const content = new MarkdownString(`\`\`\`${terminalData.language}\n${command}\n\`\`\``);
|
||||||
const chatMarkdownContent: IChatMarkdownContent = {
|
const chatMarkdownContent: IChatMarkdownContent = {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { IContextKeyService } from '../../../../../../platform/contextkey/common
|
|||||||
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
|
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
|
||||||
import { IKeybindingService } from '../../../../../../platform/keybinding/common/keybinding.js';
|
import { IKeybindingService } from '../../../../../../platform/keybinding/common/keybinding.js';
|
||||||
import { ChatContextKeys } from '../../../common/chatContextKeys.js';
|
import { ChatContextKeys } from '../../../common/chatContextKeys.js';
|
||||||
import { IChatTerminalToolInvocationData, IChatToolInvocation, type IChatTerminalToolInvocationData2 } from '../../../common/chatService.js';
|
import { IChatToolInvocation, type IChatTerminalToolInvocationData } from '../../../common/chatService.js';
|
||||||
import { CancelChatActionId } from '../../actions/chatExecuteActions.js';
|
import { CancelChatActionId } from '../../actions/chatExecuteActions.js';
|
||||||
import { AcceptToolConfirmationActionId } from '../../actions/chatToolActions.js';
|
import { AcceptToolConfirmationActionId } from '../../actions/chatToolActions.js';
|
||||||
import { IChatCodeBlockInfo, IChatWidgetService } from '../../chat.js';
|
import { IChatCodeBlockInfo, IChatWidgetService } from '../../chat.js';
|
||||||
@@ -33,7 +33,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
toolInvocation: IChatToolInvocation,
|
toolInvocation: IChatToolInvocation,
|
||||||
terminalData: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2,
|
terminalData: IChatTerminalToolInvocationData,
|
||||||
private readonly context: IChatContentPartRenderContext,
|
private readonly context: IChatContentPartRenderContext,
|
||||||
private readonly renderer: MarkdownRenderer,
|
private readonly renderer: MarkdownRenderer,
|
||||||
private readonly editorPool: EditorPool,
|
private readonly editorPool: EditorPool,
|
||||||
@@ -90,7 +90,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
|
|||||||
};
|
};
|
||||||
const langId = this.languageService.getLanguageIdByLanguageName(terminalData.language ?? 'sh') ?? 'shellscript';
|
const langId = this.languageService.getLanguageIdByLanguageName(terminalData.language ?? 'sh') ?? 'shellscript';
|
||||||
const model = this.modelService.createModel(
|
const model = this.modelService.createModel(
|
||||||
terminalData.kind === 'terminal' ? terminalData.command : terminalData.commandLine.toolEdited ?? terminalData.commandLine.original,
|
terminalData.commandLine.toolEdited ?? terminalData.commandLine.original,
|
||||||
this.languageService.createById(langId),
|
this.languageService.createById(langId),
|
||||||
this._getUniqueCodeBlockUri(),
|
this._getUniqueCodeBlockUri(),
|
||||||
true
|
true
|
||||||
@@ -122,11 +122,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
|
|||||||
this._onDidChangeHeight.fire();
|
this._onDidChangeHeight.fire();
|
||||||
}));
|
}));
|
||||||
this._register(model.onDidChangeContent(e => {
|
this._register(model.onDidChangeContent(e => {
|
||||||
if (terminalData.kind === 'terminal') {
|
terminalData.commandLine.userEdited = model.getValue();
|
||||||
terminalData.command = model.getValue();
|
|
||||||
} else {
|
|
||||||
terminalData.commandLine.userEdited = model.getValue();
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
const element = dom.$('');
|
const element = dom.$('');
|
||||||
dom.append(element, editor.object.element);
|
dom.append(element, editor.object.element);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class ChatToolInvocationPart extends Disposable implements IChatContentPa
|
|||||||
return this.instantiationService.createInstance(ChatTaskListSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData);
|
return this.instantiationService.createInstance(ChatTaskListSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData);
|
||||||
}
|
}
|
||||||
if (this.toolInvocation.confirmationMessages) {
|
if (this.toolInvocation.confirmationMessages) {
|
||||||
if (this.toolInvocation.toolSpecificData?.kind === 'terminal' || this.toolInvocation.toolSpecificData?.kind === 'terminal2') {
|
if (this.toolInvocation.toolSpecificData?.kind === 'terminal') {
|
||||||
return this.instantiationService.createInstance(TerminalConfirmationWidgetSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex);
|
return this.instantiationService.createInstance(TerminalConfirmationWidgetSubPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex);
|
||||||
} else {
|
} else {
|
||||||
return this.instantiationService.createInstance(ToolConfirmationSubPart, this.toolInvocation, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockModelCollection, this.codeBlockStartIndex);
|
return this.instantiationService.createInstance(ToolConfirmationSubPart, this.toolInvocation, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockModelCollection, this.codeBlockStartIndex);
|
||||||
@@ -97,7 +97,7 @@ export class ChatToolInvocationPart extends Disposable implements IChatContentPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.toolInvocation.toolSpecificData?.kind === 'terminal' || this.toolInvocation.toolSpecificData?.kind === 'terminal2') {
|
if (this.toolInvocation.toolSpecificData?.kind === 'terminal') {
|
||||||
return this.instantiationService.createInstance(ChatTerminalMarkdownProgressPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex, this.codeBlockModelCollection);
|
return this.instantiationService.createInstance(ChatTerminalMarkdownProgressPart, this.toolInvocation, this.toolInvocation.toolSpecificData, this.context, this.renderer, this.editorPool, this.currentWidthDelegate, this.codeBlockStartIndex, this.codeBlockModelCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,14 +75,12 @@ class ChatResponseAccessibleProvider extends Disposable implements IAccessibleVi
|
|||||||
let input = '';
|
let input = '';
|
||||||
if (toolInvocation.toolSpecificData) {
|
if (toolInvocation.toolSpecificData) {
|
||||||
input = toolInvocation.toolSpecificData?.kind === 'terminal'
|
input = toolInvocation.toolSpecificData?.kind === 'terminal'
|
||||||
? toolInvocation.toolSpecificData.command
|
? toolInvocation.toolSpecificData.commandLine.userEdited ?? toolInvocation.toolSpecificData.commandLine.toolEdited ?? toolInvocation.toolSpecificData.commandLine.original
|
||||||
: toolInvocation.toolSpecificData?.kind === 'terminal2'
|
: toolInvocation.toolSpecificData?.kind === 'extensions'
|
||||||
? toolInvocation.toolSpecificData.commandLine.userEdited ?? toolInvocation.toolSpecificData.commandLine.toolEdited ?? toolInvocation.toolSpecificData.commandLine.original
|
? JSON.stringify(toolInvocation.toolSpecificData.extensions)
|
||||||
: toolInvocation.toolSpecificData?.kind === 'extensions'
|
: toolInvocation.toolSpecificData?.kind === 'tasks'
|
||||||
? JSON.stringify(toolInvocation.toolSpecificData.extensions)
|
? JSON.stringify(toolInvocation.toolSpecificData.tasks)
|
||||||
: toolInvocation.toolSpecificData?.kind === 'tasks'
|
: JSON.stringify(toolInvocation.toolSpecificData.rawInput);
|
||||||
? JSON.stringify(toolInvocation.toolSpecificData.tasks)
|
|
||||||
: JSON.stringify(toolInvocation.toolSpecificData.rawInput);
|
|
||||||
}
|
}
|
||||||
responseContent += `${title}`;
|
responseContent += `${title}`;
|
||||||
if (input) {
|
if (input) {
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
if (prepared?.confirmationMessages) {
|
if (prepared?.confirmationMessages) {
|
||||||
if (prepared.toolSpecificData?.kind !== 'terminal' && prepared.toolSpecificData?.kind !== 'terminal2' && typeof prepared.confirmationMessages.allowAutoConfirm !== 'boolean') {
|
if (prepared.toolSpecificData?.kind !== 'terminal' && typeof prepared.confirmationMessages.allowAutoConfirm !== 'boolean') {
|
||||||
prepared.confirmationMessages.allowAutoConfirm = true;
|
prepared.confirmationMessages.allowAutoConfirm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { encodeBase64 } from '../../../../../base/common/buffer.js';
|
|||||||
import { IMarkdownString } from '../../../../../base/common/htmlContent.js';
|
import { IMarkdownString } from '../../../../../base/common/htmlContent.js';
|
||||||
import { observableValue } from '../../../../../base/common/observable.js';
|
import { observableValue } from '../../../../../base/common/observable.js';
|
||||||
import { localize } from '../../../../../nls.js';
|
import { localize } from '../../../../../nls.js';
|
||||||
import { IChatExtensionsContent, IChatTerminalToolInvocationData, IChatToolInputInvocationData, IChatTasksContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData2 } from '../chatService.js';
|
import { IChatExtensionsContent, IChatToolInputInvocationData, IChatTasksContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData } from '../chatService.js';
|
||||||
import { IPreparedToolInvocation, isToolResultOutputDetails, IToolConfirmationMessages, IToolData, IToolProgressStep, IToolResult } from '../languageModelToolsService.js';
|
import { IPreparedToolInvocation, isToolResultOutputDetails, IToolConfirmationMessages, IToolData, IToolProgressStep, IToolResult } from '../languageModelToolsService.js';
|
||||||
|
|
||||||
export class ChatToolInvocation implements IChatToolInvocation {
|
export class ChatToolInvocation implements IChatToolInvocation {
|
||||||
@@ -46,7 +46,7 @@ export class ChatToolInvocation implements IChatToolInvocation {
|
|||||||
public readonly presentation: IPreparedToolInvocation['presentation'];
|
public readonly presentation: IPreparedToolInvocation['presentation'];
|
||||||
public readonly toolId: string;
|
public readonly toolId: string;
|
||||||
|
|
||||||
public readonly toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
public readonly toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
||||||
|
|
||||||
public readonly progress = observableValue<{ message?: string | IMarkdownString; progress: number }>(this, { progress: 0 });
|
public readonly progress = observableValue<{ message?: string | IMarkdownString; progress: number }>(this, { progress: 0 });
|
||||||
|
|
||||||
|
|||||||
@@ -242,12 +242,6 @@ export interface IChatElicitationRequest {
|
|||||||
|
|
||||||
export interface IChatTerminalToolInvocationData {
|
export interface IChatTerminalToolInvocationData {
|
||||||
kind: 'terminal';
|
kind: 'terminal';
|
||||||
command: string;
|
|
||||||
language: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IChatTerminalToolInvocationData2 {
|
|
||||||
kind: 'terminal2';
|
|
||||||
commandLine: {
|
commandLine: {
|
||||||
original: string;
|
original: string;
|
||||||
userEdited?: string;
|
userEdited?: string;
|
||||||
@@ -263,7 +257,7 @@ export interface IChatToolInputInvocationData {
|
|||||||
|
|
||||||
export interface IChatToolInvocation {
|
export interface IChatToolInvocation {
|
||||||
presentation: IPreparedToolInvocation['presentation'];
|
presentation: IPreparedToolInvocation['presentation'];
|
||||||
toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
||||||
/** Presence of this property says that confirmation is required */
|
/** Presence of this property says that confirmation is required */
|
||||||
confirmationMessages?: IToolConfirmationMessages;
|
confirmationMessages?: IToolConfirmationMessages;
|
||||||
confirmed: DeferredPromise<boolean>;
|
confirmed: DeferredPromise<boolean>;
|
||||||
@@ -296,7 +290,7 @@ export interface IToolResultOutputDetailsSerialized {
|
|||||||
*/
|
*/
|
||||||
export interface IChatToolInvocationSerialized {
|
export interface IChatToolInvocationSerialized {
|
||||||
presentation: IPreparedToolInvocation['presentation'];
|
presentation: IPreparedToolInvocation['presentation'];
|
||||||
toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
||||||
invocationMessage: string | IMarkdownString;
|
invocationMessage: string | IMarkdownString;
|
||||||
originMessage: string | IMarkdownString | undefined;
|
originMessage: string | IMarkdownString | undefined;
|
||||||
pastTenseMessage: string | IMarkdownString | undefined;
|
pastTenseMessage: string | IMarkdownString | undefined;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { ContextKeyExpression } from '../../../../platform/contextkey/common/con
|
|||||||
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
|
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
|
||||||
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
||||||
import { IProgress } from '../../../../platform/progress/common/progress.js';
|
import { IProgress } from '../../../../platform/progress/common/progress.js';
|
||||||
import { IChatExtensionsContent, IChatTerminalToolInvocationData, IChatToolInputInvocationData, IChatTasksContent, type IChatTerminalToolInvocationData2 } from './chatService.js';
|
import { IChatExtensionsContent, IChatToolInputInvocationData, IChatTasksContent, type IChatTerminalToolInvocationData } from './chatService.js';
|
||||||
import { PromptElementJSON, stringifyPromptElementJSON } from './tools/promptTsxTypes.js';
|
import { PromptElementJSON, stringifyPromptElementJSON } from './tools/promptTsxTypes.js';
|
||||||
import { VSBuffer } from '../../../../base/common/buffer.js';
|
import { VSBuffer } from '../../../../base/common/buffer.js';
|
||||||
import { derived, IObservable, IReader, ITransaction, ObservableSet } from '../../../../base/common/observable.js';
|
import { derived, IObservable, IReader, ITransaction, ObservableSet } from '../../../../base/common/observable.js';
|
||||||
@@ -113,7 +113,7 @@ export interface IToolInvocation {
|
|||||||
context: IToolInvocationContext | undefined;
|
context: IToolInvocationContext | undefined;
|
||||||
chatRequestId?: string;
|
chatRequestId?: string;
|
||||||
chatInteractionId?: string;
|
chatInteractionId?: string;
|
||||||
toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
||||||
modelId?: string;
|
modelId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ export interface IPreparedToolInvocation {
|
|||||||
originMessage?: string | IMarkdownString;
|
originMessage?: string | IMarkdownString;
|
||||||
confirmationMessages?: IToolConfirmationMessages;
|
confirmationMessages?: IToolConfirmationMessages;
|
||||||
presentation?: 'hidden' | undefined;
|
presentation?: 'hidden' | undefined;
|
||||||
toolSpecificData?: IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
toolSpecificData?: IChatTerminalToolInvocationData | IChatToolInputInvocationData | IChatExtensionsContent | IChatTasksContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IToolImpl {
|
export interface IToolImpl {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { TerminalCapability } from '../../../../../platform/terminal/common/capa
|
|||||||
import { ITerminalLogService } from '../../../../../platform/terminal/common/terminal.js';
|
import { ITerminalLogService } from '../../../../../platform/terminal/common/terminal.js';
|
||||||
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
|
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
|
||||||
import { IRemoteAgentService } from '../../../../services/remote/common/remoteAgentService.js';
|
import { IRemoteAgentService } from '../../../../services/remote/common/remoteAgentService.js';
|
||||||
import { IChatService, type IChatTerminalToolInvocationData, type IChatTerminalToolInvocationData2 } from '../../../chat/common/chatService.js';
|
import { IChatService, type IChatTerminalToolInvocationData } from '../../../chat/common/chatService.js';
|
||||||
import { CountTokensCallback, ILanguageModelToolsService, IPreparedToolInvocation, IToolData, IToolImpl, IToolInvocation, IToolInvocationPreparationContext, IToolResult, ToolDataSource, ToolProgress, type IToolConfirmationMessages } from '../../../chat/common/languageModelToolsService.js';
|
import { CountTokensCallback, ILanguageModelToolsService, IPreparedToolInvocation, IToolData, IToolImpl, IToolInvocation, IToolInvocationPreparationContext, IToolResult, ToolDataSource, ToolProgress, type IToolConfirmationMessages } from '../../../chat/common/languageModelToolsService.js';
|
||||||
import { ITerminalService, type ITerminalInstance } from '../../../terminal/browser/terminal.js';
|
import { ITerminalService, type ITerminalInstance } from '../../../terminal/browser/terminal.js';
|
||||||
import type { XtermTerminal } from '../../../terminal/browser/xterm/xtermTerminal.js';
|
import type { XtermTerminal } from '../../../terminal/browser/xterm/xtermTerminal.js';
|
||||||
@@ -122,7 +122,6 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
|
|||||||
// HACK: Per-tool call state, saved globally
|
// HACK: Per-tool call state, saved globally
|
||||||
// TODO: These should not be part of the state as different sessions could get confused https://github.com/microsoft/vscode/issues/255889
|
// TODO: These should not be part of the state as different sessions could get confused https://github.com/microsoft/vscode/issues/255889
|
||||||
private _alternativeRecommendation?: IToolResult;
|
private _alternativeRecommendation?: IToolResult;
|
||||||
private _rewrittenCommand?: string;
|
|
||||||
|
|
||||||
private static readonly _backgroundExecutions = new Map<string, BackgroundTerminalExecution>();
|
private static readonly _backgroundExecutions = new Map<string, BackgroundTerminalExecution>();
|
||||||
public static getBackgroundOutput(id: string): string {
|
public static getBackgroundOutput(id: string): string {
|
||||||
@@ -222,7 +221,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
|
|||||||
confirmationMessages,
|
confirmationMessages,
|
||||||
presentation,
|
presentation,
|
||||||
toolSpecificData: {
|
toolSpecificData: {
|
||||||
kind: 'terminal2',
|
kind: 'terminal',
|
||||||
commandLine: {
|
commandLine: {
|
||||||
original: args.command,
|
original: args.command,
|
||||||
toolEdited: toolEditedCommand
|
toolEdited: toolEditedCommand
|
||||||
@@ -241,7 +240,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
|
|||||||
|
|
||||||
this._logService.debug(`RunInTerminalTool: Invoking with options ${JSON.stringify(args)}`);
|
this._logService.debug(`RunInTerminalTool: Invoking with options ${JSON.stringify(args)}`);
|
||||||
|
|
||||||
const toolSpecificData = invocation.toolSpecificData as IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | undefined;
|
const toolSpecificData = invocation.toolSpecificData as IChatTerminalToolInvocationData | undefined;
|
||||||
if (!toolSpecificData) {
|
if (!toolSpecificData) {
|
||||||
throw new Error('toolSpecificData must be provided for this tool');
|
throw new Error('toolSpecificData must be provided for this tool');
|
||||||
}
|
}
|
||||||
@@ -251,25 +250,16 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
|
|||||||
throw new Error('A chat session ID is required for this tool');
|
throw new Error('A chat session ID is required for this tool');
|
||||||
}
|
}
|
||||||
|
|
||||||
let command: string | undefined;
|
const command = toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original;
|
||||||
let didUserEditCommand: boolean;
|
const didUserEditCommand = (
|
||||||
let didToolEditCommand: boolean;
|
toolSpecificData.commandLine.userEdited !== undefined &&
|
||||||
if (toolSpecificData.kind === 'terminal') {
|
toolSpecificData.commandLine.userEdited !== toolSpecificData.commandLine.original
|
||||||
command = toolSpecificData.command ?? this._rewrittenCommand ?? args.command;
|
);
|
||||||
didUserEditCommand = typeof toolSpecificData?.command === 'string' && toolSpecificData.command !== args.command;
|
const didToolEditCommand = (
|
||||||
didToolEditCommand = !didUserEditCommand && this._rewrittenCommand !== undefined;
|
!didUserEditCommand &&
|
||||||
} else {
|
toolSpecificData.commandLine.toolEdited !== undefined &&
|
||||||
command = toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original;
|
toolSpecificData.commandLine.toolEdited !== toolSpecificData.commandLine.original
|
||||||
didUserEditCommand = (
|
);
|
||||||
toolSpecificData.commandLine.userEdited !== undefined &&
|
|
||||||
toolSpecificData.commandLine.userEdited !== toolSpecificData.commandLine.original
|
|
||||||
);
|
|
||||||
didToolEditCommand = (
|
|
||||||
!didUserEditCommand &&
|
|
||||||
toolSpecificData.commandLine.toolEdited !== undefined &&
|
|
||||||
toolSpecificData.commandLine.toolEdited !== toolSpecificData.commandLine.original
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.isCancellationRequested) {
|
if (token.isCancellationRequested) {
|
||||||
throw new CancellationError();
|
throw new CancellationError();
|
||||||
|
|||||||
@@ -205,24 +205,6 @@ declare module 'vscode' {
|
|||||||
presentation?: 'hidden' | undefined;
|
presentation?: 'hidden' | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LanguageModelTool<T> {
|
|
||||||
prepareInvocation2?(options: LanguageModelToolInvocationPrepareOptions<T>, token: CancellationToken): ProviderResult<PreparedTerminalToolInvocation>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PreparedTerminalToolInvocation {
|
|
||||||
readonly command: string;
|
|
||||||
readonly language: string;
|
|
||||||
readonly confirmationMessages?: LanguageModelToolConfirmationMessages;
|
|
||||||
readonly presentation?: 'hidden' | undefined;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
command: string,
|
|
||||||
language: string,
|
|
||||||
confirmationMessages?: LanguageModelToolConfirmationMessages,
|
|
||||||
presentation?: 'hidden'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
|
export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
|
||||||
toolResultMessage?: string | MarkdownString;
|
toolResultMessage?: string | MarkdownString;
|
||||||
toolResultDetails?: Array<Uri | Location>;
|
toolResultDetails?: Array<Uri | Location>;
|
||||||
|
|||||||
Reference in New Issue
Block a user