import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation"; import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event"; import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle"; import { IObservable, IReader } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable"; import { ThemeIcon } from "@codingame/monaco-vscode-api/vscode/vs/base/common/themables"; import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri"; import { IAccessibilityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service"; import { IAccessibilitySignalService } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service"; import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service"; import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service"; import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service"; import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service"; import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation"; import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service"; import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service"; import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service"; import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service"; import { ChatRequestToolReferenceEntry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/attachments/chatVariableEntries"; import { IVariableReference } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes"; import { IChatToolInvocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService"; import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService.service"; import { ILanguageModelChatMetadata } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels"; import { ILanguageModelToolsConfirmationService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsConfirmationService.service"; import { CountTokensCallback, IBeginToolCallOptions, IToolAndToolSetEnablementMap, IToolData, IToolImpl, IToolInvocation, IToolInvokedEvent, IToolResult, IToolSet, ToolDataSource, ToolSet } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService"; import { ILanguageModelToolsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService.service"; import { IToolResultCompressor } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/toolResultCompressor.service"; import { IChatWidgetService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service"; export declare enum AutoApproveStorageKeys { GlobalAutoApproveOptIn = "chat.tools.global.autoApprove.optIn" } export declare const globalAutoApproveDescription: import("@codingame/monaco-vscode-api/vscode/vs/nls").ILocalizedString; export declare class LanguageModelToolsService extends Disposable implements ILanguageModelToolsService { private readonly _instantiationService; private readonly _extensionService; private readonly _contextKeyService; private readonly _chatService; private readonly _dialogService; private readonly _telemetryService; private readonly _logService; private readonly _configurationService; private readonly _accessibilityService; private readonly _accessibilitySignalService; private readonly _storageService; private readonly _confirmationService; private readonly _commandService; private readonly _chatWidgetService; private readonly _toolResultCompressor; _serviceBrand: undefined; readonly vscodeToolSet: ToolSet; readonly executeToolSet: ToolSet; readonly readToolSet: ToolSet; readonly agentToolSet: ToolSet; private readonly _onDidChangeTools; readonly onDidChangeTools: Event; private readonly _onDidPrepareToolCallBecomeUnresponsive; readonly onDidPrepareToolCallBecomeUnresponsive: Event<{ sessionResource: URI; toolData: IToolData; }>; private readonly _onDidInvokeTool; readonly onDidInvokeTool: Event; /** Throttle tools updates because it sends all tools and runs on context key updates */ private readonly _onDidChangeToolsScheduler; private readonly _tools; private readonly _toolContextKeys; private readonly _ctxToolsCount; private readonly _callsByRequestId; /** Pending tool calls in the streaming phase, keyed by toolCallId */ private readonly _pendingToolCalls; /** Deduplicates _checkGlobalAutoApprove calls within this window */ private _pendingGlobalAutoApproveCheck; private readonly _isAgentModeEnabled; constructor(_instantiationService: IInstantiationService, _extensionService: IExtensionService, _contextKeyService: IContextKeyService, _chatService: IChatService, _dialogService: IDialogService, _telemetryService: ITelemetryService, _logService: ILogService, _configurationService: IConfigurationService, _accessibilityService: IAccessibilityService, _accessibilitySignalService: IAccessibilitySignalService, _storageService: IStorageService, _confirmationService: ILanguageModelToolsConfirmationService, _commandService: ICommandService, _chatWidgetService: IChatWidgetService, _toolResultCompressor: IToolResultCompressor); private isToolEnabledForModel; /** * Returns if the given tool or toolset is permitted in the current context. * When agent mode is enabled, all tools are permitted (no restriction) * When agent mode is disabled only a subset of read-only tools are permitted in agentic-loop contexts. */ private isPermitted; dispose(): void; registerToolData(toolData: IToolData): IDisposable; flushToolUpdates(): void; private _refreshAllToolContextKeys; registerToolImplementation(id: string, tool: IToolImpl): IDisposable; registerTool(toolData: IToolData, tool: IToolImpl): IDisposable; getTools(model: ILanguageModelChatMetadata | undefined): Iterable; observeTools(model: ILanguageModelChatMetadata | undefined): IObservable; getAllToolsIncludingDisabled(): Iterable; getTool(id: string): IToolData | undefined; getToolByName(name: string): IToolData | undefined; private _handlePreToolUseDenial; /** * Validate updatedInput from a preToolUse hook against the tool's input schema * using the json.validate command from the JSON extension. * @returns An error message string if validation fails, or undefined if valid. */ private _validateUpdatedInput; invokeTool(dto: IToolInvocation, countTokens: CountTokensCallback, token: CancellationToken): Promise; private prepareToolInvocationWithHookResult; private _logToolApprovalTelemetry; /** * Determines the auto-confirm decision based on a preToolUse hook result. * If the hook returned 'allow', auto-approves. If 'ask', forces confirmation * and ensures confirmation messages exist on `preparedInvocation`. Otherwise * falls back to normal auto-confirm logic. * * Returns the possibly-updated preparedInvocation along with the auto-confirm decision, * since when the hook returns 'ask' and preparedInvocation was undefined, we create one. */ private resolveAutoConfirmFromHook; private prepareToolInvocation; beginToolCall(options: IBeginToolCallOptions): IChatToolInvocation | undefined; private _callHandleToolStream; updateToolStream(toolCallId: string, partialInput: unknown, token: CancellationToken): Promise; private playAccessibilitySignal; private ensureToolDetails; private toolResultHasImages; /** * Returns true if the tool result message (or falling back to the tool invocation's * pastTenseMessage from streaming) contains empty markdown links pointing to image * files (the `[](imageUri)` pattern) that will be rendered as file pills by renderFileWidgets. */ private toolResultMessageHasImageFileWidgets; private formatToolInput; private toolResultToIO; /** * Returns true if enterprise policy has explicitly disabled the global auto-approve setting. * When this is the case, Bypass Approvals and Autopilot permission levels should not auto-approve tools. */ private _isAutoApprovePolicyRestricted; /** * Returns true if the session's current (live) permission picker level is auto-approve. * This checks the widget's current state, not what was stamped on the request, * so switching to Autopilot mid-session takes effect immediately. */ private _isSessionLiveAutoApproveLevel; /** * True if the session is in an auto-approve level (Auto-Approve / Autopilot), * via either the last request's stamped level or the live picker level. */ private _isSessionInAutoApproveLevel; private getEligibleForAutoApprovalSpecialCase; private isToolEligibleForAutoApproval; private shouldAutoConfirm; private shouldAutoConfirmPostExecution; private _checkGlobalAutoApprove; private _doCheckGlobalAutoApprove; private cleanupCallDisposables; cancelToolCallsForRequest(requestId: string): void; private static readonly githubMCPServerAliases; private static readonly playwrightMCPServerAliases; private getToolSetAliases; private getToolAliases; /** * Create a map that contains all tools and toolsets with their enablement state. * @param fullReferenceNames A list of tool or toolset by their full reference names that are enabled. * @returns A map of tool or toolset instances to their enablement state. */ toToolAndToolSetEnablementMap(fullReferenceNames: readonly string[], model: ILanguageModelChatMetadata | undefined): IToolAndToolSetEnablementMap; toFullReferenceNames(map: IToolAndToolSetEnablementMap): string[]; toToolReferences(variableReferences: readonly IVariableReference[]): ChatRequestToolReferenceEntry[]; private readonly _toolSets; readonly toolSets: IObservable>; getToolSetsForModel(model: ILanguageModelChatMetadata | undefined, reader?: IReader): Iterable; getToolSet(id: string): ToolSet | undefined; getToolSetByName(name: string): ToolSet | undefined; getSpecedToolSetName(referenceName: string): string; createToolSet(source: ToolDataSource, id: string, referenceName: string, options?: { icon?: ThemeIcon; description?: string; legacyFullNames?: string[]; }): ToolSet & IDisposable; private readonly allToolsIncludingDisableObs; private readonly toolsWithFullReferenceName; getFullReferenceNames(): Iterable; getDeprecatedFullReferenceNames(): Map>; getToolByFullReferenceName(fullReferenceName: string): IToolData | ToolSet | undefined; getFullReferenceName(tool: IToolData | IToolSet, toolSet?: IToolSet): string; }