import { CancellationToken } from "../../../../../base/common/cancellation.js"; import { Event } from "../../../../../base/common/event.js"; import { IDisposable } from "../../../../../base/common/lifecycle.js"; import { IObservable, IReader } from "../../../../../base/common/observable.js"; import { ThemeIcon } from "../../../../../base/common/themables.js"; import { URI } from "../../../../../base/common/uri.js"; import { ChatRequestToolReferenceEntry } from "../attachments/chatVariableEntries.js"; import { IVariableReference } from "../chatModes.js"; import { IChatToolInvocation } from "../chatService/chatService.js"; import { ILanguageModelChatMetadata } from "../languageModels.js"; import { ToolSet, IToolData, IToolInvokedEvent, IToolImpl, IBeginToolCallOptions, IToolInvocation, CountTokensCallback, IToolResult, IToolSet, ToolDataSource, IToolAndToolSetEnablementMap } from "./languageModelToolsService.js"; export declare const ILanguageModelToolsService: import("../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier; export interface ILanguageModelToolsService { _serviceBrand: undefined; readonly vscodeToolSet: ToolSet; readonly executeToolSet: ToolSet; readonly readToolSet: ToolSet; readonly agentToolSet: ToolSet; readonly onDidChangeTools: Event; readonly onDidPrepareToolCallBecomeUnresponsive: Event<{ readonly sessionResource: URI; readonly toolData: IToolData; }>; readonly onDidInvokeTool: Event; registerToolData(toolData: IToolData): IDisposable; registerToolImplementation(id: string, tool: IToolImpl): IDisposable; registerTool(toolData: IToolData, tool: IToolImpl): IDisposable; /** * Get all tools currently enabled (matching `when` clauses and model). * @param model The language model metadata to filter tools by. If undefined, model-specific filtering is skipped. */ getTools(model: ILanguageModelChatMetadata | undefined): Iterable; /** * Creats an observable of enabled tools in the context. Note the observable * should be created and reused, not created per reader, for example: * * ``` * const toolsObs = toolsService.observeTools(model); * autorun(reader => { * const tools = toolsObs.read(reader); * ... * }); * ``` * @param model The language model metadata to filter tools by. If undefined, model-specific filtering is skipped. */ observeTools(model: ILanguageModelChatMetadata | undefined): IObservable; /** * Get all registered tools regardless of enablement state. * Use this for configuration UIs, completions, etc. where all tools should be visible. */ getAllToolsIncludingDisabled(): Iterable; /** * Get a tool by its ID. Does not check when clauses. */ getTool(id: string): IToolData | undefined; /** * Get a tool by its reference name. Does not check when clauses. */ getToolByName(name: string): IToolData | undefined; /** * Begin a tool call in the streaming phase. * Creates a ChatToolInvocation in the Streaming state and appends it to the chat. * Returns the invocation so it can be looked up later when invokeTool is called. */ beginToolCall(options: IBeginToolCallOptions): IChatToolInvocation | undefined; /** * Update the streaming state of a pending tool call. * Calls the tool's handleToolStream method to get a custom invocation message. */ updateToolStream(toolCallId: string, partialInput: unknown, token: CancellationToken): Promise; invokeTool(invocation: IToolInvocation, countTokens: CountTokensCallback, token: CancellationToken): Promise; cancelToolCallsForRequest(requestId: string): void; /** Flush any pending tool updates to the extension hosts. */ flushToolUpdates(): void; readonly toolSets: IObservable>; getToolSetsForModel(model: ILanguageModelChatMetadata | undefined, reader?: IReader): Iterable; getToolSet(id: string): IToolSet | undefined; getToolSetByName(name: string): IToolSet | undefined; createToolSet(source: ToolDataSource, id: string, referenceName: string, options?: { icon?: ThemeIcon; description?: string; legacyFullNames?: string[]; }): ToolSet & IDisposable; getFullReferenceNames(): Iterable; getFullReferenceName(tool: IToolData, toolSet?: IToolSet): string; getToolByFullReferenceName(fullReferenceName: string): IToolData | IToolSet | undefined; getDeprecatedFullReferenceNames(): Map>; /** * Gets the enablement maps based on the given set of references. * @param fullReferenceNames The full reference names of the tools and tool sets to enable. * @param model Optional language model metadata to filter tools by. * If undefined is passed, all tools will be returned, even if normally disabled. */ toToolAndToolSetEnablementMap(fullReferenceNames: readonly string[], model: ILanguageModelChatMetadata | undefined): IToolAndToolSetEnablementMap; toFullReferenceNames(map: IToolAndToolSetEnablementMap): string[]; toToolReferences(variableReferences: readonly IVariableReference[]): ChatRequestToolReferenceEntry[]; }