import { Event } from "../../../../base/common/event.js"; import { Disposable, IDisposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { IOffsetRange } from "../../../../editor/common/core/ranges/offsetRange.js"; import { IConfigurationService } from "../../../../platform/configuration/common/configuration.service.js"; import { IContextKeyService } from "../../../../platform/contextkey/common/contextkey.service.js"; import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.js"; import { ChatModeKind } from "./constants.js"; import { IHandOff } from "./promptSyntax/promptFileParser.js"; import { IAgentSource, ICustomAgent, ICustomAgentVisibility, PromptsStorage } from "./promptSyntax/service/promptsService.js"; import { PromptFileSource, Target } from "./promptSyntax/promptTypes.js"; import { ThemeIcon } from "../../../../base/common/themables.js"; import { IChatModeService } from "./chatModes.service.js"; /** * The set of chat modes available for a particular session type, partitioned * into builtin and custom modes, with helpers for lookup by id or name. */ export interface IChatModes { readonly onDidChange: Event; readonly builtin: readonly IChatMode[]; readonly custom: readonly IChatMode[]; findModeById(id: string): IChatMode | undefined; findModeByName(name: string): IChatMode | undefined; /** * Awaits the most recently scheduled update of custom prompt modes. * After this resolves, {@link custom} reflects the latest data from the * prompts service. */ waitForPendingUpdates(): Promise; } export declare class ChatModeService extends Disposable implements IChatModeService { private readonly instantiationService; private readonly configurationService; readonly _serviceBrand: undefined; private readonly agentModeDisabledByPolicy; private localMode; constructor(instantiationService: IInstantiationService, contextKeyService: IContextKeyService, configurationService: IConfigurationService); createModes(sessionResource: URI): IChatModes & IDisposable; getLocalModes(): Promise; private updateAgentModePolicyContextKey; private isAgentModeDisabledByPolicy; } export interface IChatModeData { readonly id: string; readonly name: string; readonly description?: string; readonly kind: ChatModeKind; readonly customTools?: readonly string[]; readonly model?: readonly string[] | string; readonly argumentHint?: string; readonly modeInstructions?: IChatModeInstructions; readonly body?: string; readonly handOffs?: readonly IHandOff[]; readonly uri?: URI; readonly source?: IChatModeSourceData; readonly target?: Target; readonly visibility?: ICustomAgentVisibility; readonly agents?: readonly string[]; readonly sessionTypes?: readonly string[]; readonly infer?: boolean; } export interface IChatMode { readonly id: string; readonly name: IObservable; readonly label: IObservable; readonly icon: IObservable; readonly description: IObservable; readonly isBuiltin: boolean; readonly kind: ChatModeKind; readonly customTools?: IObservable; readonly handOffs?: IObservable; readonly model?: IObservable; readonly argumentHint?: IObservable; readonly modeInstructions?: IObservable; readonly uri?: IObservable; readonly source?: IAgentSource; readonly target: IObservable; readonly visibility?: IObservable; readonly agents?: IObservable; readonly sessionTypes?: readonly string[]; } /** Shows source information only when another offered mode has the same visible label. */ export declare function getChatModeSourceLabel(mode: IChatMode, modes: readonly IChatMode[]): string | undefined; export interface IVariableReference { readonly name: string; readonly range: IOffsetRange; } export interface IChatModeInstructions { readonly content: string; readonly toolReferences: readonly IVariableReference[]; readonly metadata?: Record; } export declare namespace IChatModeInstructions { function isEquals(a: IChatModeInstructions | undefined, b: IChatModeInstructions | undefined): boolean; } export declare class CustomChatMode implements IChatMode { private readonly _nameObservable; private readonly _descriptionObservable; private readonly _customToolsObservable; private readonly _modeInstructions; private readonly _uriObservable; private readonly _modelObservable; private readonly _argumentHintObservable; private readonly _handoffsObservable; private readonly _targetObservable; private readonly _visibilityObservable; private readonly _agentsObservable; private _source; private _sessionTypes; readonly kind: ChatModeKind; readonly id: string; get name(): IObservable; get description(): IObservable; get icon(): IObservable; get isBuiltin(): boolean; get customTools(): IObservable; get model(): IObservable; get argumentHint(): IObservable; get modeInstructions(): IObservable; get uri(): IObservable; get label(): IObservable; get handOffs(): IObservable; get source(): IAgentSource; get target(): IObservable; get visibility(): IObservable; get agents(): IObservable; get sessionTypes(): readonly string[] | undefined; constructor(customChatMode: ICustomAgent); /** * Updates the underlying data and triggers observable changes */ updateData(newData: ICustomAgent): boolean; toJSON(): IChatModeData; } type IChatModeSourceData = ({ readonly storage: PromptsStorage.extension; readonly extensionId: string; type?: PromptFileSource.ExtensionContribution | PromptFileSource.ExtensionAPI; } | { readonly storage: PromptsStorage.local | PromptsStorage.user | PromptsStorage.builtIn; } | { readonly storage: PromptsStorage.plugin; readonly pluginUri: URI; }) & { readonly label?: string; }; export declare class BuiltinChatMode implements IChatMode { readonly kind: ChatModeKind; readonly name: IObservable; readonly label: IObservable; readonly description: IObservable; readonly icon: IObservable; readonly target: IObservable; constructor(kind: ChatModeKind, label: string, description: string, icon: ThemeIcon); get isBuiltin(): boolean; get id(): string; /** * Getters are not json-stringified */ toJSON(): IChatModeData; } export declare namespace ChatMode { const Ask: BuiltinChatMode; const Edit: BuiltinChatMode; const Agent: BuiltinChatMode; } export declare function isBuiltinChatMode(mode: IChatMode): boolean; /** * Returns a telemetry-safe mode name. User/local mode names are hashed * to avoid leaking PII; builtin and extension mode names are returned as-is. */ export declare function getModeNameForTelemetry(mode: IChatMode): string; /** * Generates a stable identifier for a handoff by combining the target agent * name with a slugified version of the display label. * * Within a single source agent, the combination of `agent` + `label` must be * unique for IDs to be unambiguous. * * @example * ``` * getHandoffId({ agent: 'agent', label: 'Continue', prompt: '...' }) * // => 'agent:continue' * ``` */ export declare function getHandoffId(handoff: IHandOff): string; /** * Describes a single handoff defined in a custom agent's `.agent.md` file. */ export interface IHandoffInfo { /** Stable identifier for programmatic matching (format: `:`). */ readonly id: string; readonly label: string; readonly agent: string; readonly prompt: string; readonly send?: boolean; readonly showContinueOn?: boolean; readonly model?: string; } /** * Describes a custom agent (or built-in mode) and the handoffs it defines. */ export interface ICustomAgentInfo { readonly id: string; readonly name: string; readonly isBuiltin: boolean; readonly visibility: { readonly userInvocable: boolean; readonly agentInvocable: boolean; }; readonly handoffs: IHandoffInfo[]; } /** * Builds an array of {@link ICustomAgentInfo} with handoff metadata for the given agents/modes. * * @param modes - The set of agents/modes to include. Pass all modes to get a * complete picture, or a filtered subset to scope the result. * @returns One entry per agent/mode, each containing the agent's metadata and * its declared handoffs. */ export declare function buildCustomAgentHandoffsInfo(modes: readonly IChatMode[]): ICustomAgentInfo[]; export {};