import { CancellationToken } from "../../../base/common/cancellation.js"; import { IObservable } from "../../../base/common/observable.js"; import { URI, Event } from "../../../sessions/sessions.web.main.internal.js"; import { IArtifactIntegrationAccess } from "../../artifactIntegrations/common/artifactIntegration.js"; import { IMcpServerConfiguration } from "../../mcp/common/mcpPlatformTypes.js"; import { AuthenticateParams, AuthenticateResult, IAgentModelInfo, IAgentSessionMetadata, AgentProvider, IAgentPluginInstallation, IAgentPluginUninstallRequest, IAgentExtensionInventory, AgentCanvasDefinitionSnapshot, IAgentCanvasOpenRequest, IAgentCanvasCloseRequest, IAgentPluginInstallRequest, IAgentManagedPluginRetryEntry, IAgentPluginMarketplace, IAgentPluginMarketplaceItem, IAgentPluginMarketplaceRemoveResult, IAgentPluginMarketplaceRefreshResult, IAgentCustomizationMarketplaceSearchRequest, IAgentCustomizationMarketplaceSearchResult, IAgentCustomizationInstallation, IAgentCustomizationInstallationRequest, IAgentCustomizationInstallationReview, IAgentCustomizationInstallationApplyResult, IAgentCreateChatRequestOptions, IAgentCreateChatWorkspace, IAgentResolveSessionConfigParams, IAgentSessionConfigCompletionsParams, IMcpNotification } from "./agent.js"; import { AgentChatMoveDestination } from "./agentHostChatMove.js"; import { AgentHostClientType } from "./agentHostClientInfo.js"; import { IAgentHostAuthenticationScope, IAgentHostCredentialSource } from "./agentHostCredentials.js"; import { IAgentHostSavedChat, IAgentHostSavedChatContinuation, IAgentHostSavedChatContinuationResult } from "./agentHostSavedChat.js"; import { IAgentHostSessionSubscribeTelemetryContext, IAgentHostClientTelemetryContext } from "./agentHostTelemetry.js"; import { IAgentHostWorktreeCleanupStatus, IAgentHostManagedWorktree } from "./agentHostWorktreeCleanup.js"; import { IAgentServiceCreateSessionConfig, IAgentCreateChatInitialMessageContext, IAgentHostNetworkDiagnosticsInfo, IAgentHostManagedSettingsDiagnostics, IAgentHostNetworkFetchResult, AgentHostDebugLogsArtifactKind, IAgentHostDebugLogsArtifact, IAgentHostDebugLogsChunk, type IAgentConnection, type IAgentHostInspectInfo, type IAgentHostSocketInfo, type IMissionControlCredentialSealingRequest, type IMissionControlOptions } from "./agentService.js"; import { IClientArtifactIntegrationRegistry } from "./clientArtifactIntegrations.js"; import { ResolveSessionConfigResult, SessionConfigCompletionsResult, CompletionsParams, CompletionsResult, CreateTerminalParams, InvokeChangesetOperationParams, InvokeChangesetOperationResult, AutomationCapabilities, ListAutomationTriggerDefinitionsParams, ListAutomationTriggerDefinitionsResult, RunAutomationParams, RunAutomationResult, FetchAutomationRunsParams, FetchAutomationRunsResult } from "./state/protocol/commands.js"; import { ActionEnvelope, INotification, SessionAction, ChatAction, TerminalAction, ClientChangesetAction, ClientAnnotationsAction, IRootConfigChangedAction, ClientAutomationAction, ClientAutomationRunAction } from "./state/sessionActions.js"; import { IStateSnapshot, ResourceListResult, ContentEncoding, ResourceReadResult, ResourceWriteParams, ResourceWriteResult, ResourceCopyParams, ResourceCopyResult, ResourceDeleteParams, ResourceDeleteResult, ResourceMoveParams, ResourceMoveResult, ResourceResolveParams, ResourceResolveResult, ResourceMkdirParams, ResourceMkdirResult, CreateResourceWatchParams, CreateResourceWatchResult, ResourceWatchState } from "./state/sessionProtocol.js"; export declare const IAgentService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; export interface IAgentService { readonly artifactIntegrations?: IArtifactIntegrationAccess; /** Receives integrations that connected clients coordinate, so agents can use them alongside host integrations. */ readonly artifactIntegrationClients?: IClientArtifactIntegrationRegistry; readonly _serviceBrand: undefined; /** * Authenticate for a protected resource on the server. * The {@link AuthenticateParams.resource} must match a resource from * the agent's protectedResources in root state. Analogous to RFC 6750 * bearer token delivery. */ authenticate(params: AuthenticateParams, scope?: IAgentHostAuthenticationScope): Promise; /** Resolves a provider's connection-scoped model catalog without authenticating the shared provider. */ getModelsForCredentials(provider: string, credentials: IAgentHostCredentialSource, token?: CancellationToken): Promise; /** List all available sessions from the Copilot CLI. */ listSessions(): Promise; /** Counts durable registry identities without provider metadata reads or presentation filtering. */ getSessionCount(): Promise; createSession(config: IAgentServiceCreateSessionConfig | undefined): Promise; /** Reads persisted exact-chat history without restoring its executable provider. */ readSavedChat?(session: URI, chat?: URI): Promise; /** Records a verified Copilot continuation and archives only safely covered saved chats. */ completeSavedChatContinuation?(request: IAgentHostSavedChatContinuation): Promise; /** Removes an Automation and returns exact backend session URIs deleted by this request. */ deleteAutomation?(resource: string, deleteHistory: boolean, legacySessions?: readonly URI[], requestId?: string): Promise; acknowledgeAutomationDeletion?(requestId: string): Promise; /** Permanently adopts an external session without sending a message. */ importSession?(session: URI): Promise; /** Removes a recorded artifact or reference, awaiting host metadata persistence. */ removeSessionArtifact?(session: URI, artifactId: string): Promise; /** Stops a chat's background work entry. Resolves false when it had already finished or is not tracked. */ stopBackgroundWork?(chat: URI, id: string): Promise; installSandboxCertificate?(chat: string, scopeId: string): Promise; rotateSandboxCertificate?(chat: string, scopeId: string): Promise; removeSandboxCertificate?(chat: string, scopeId: string): Promise; createDetachedWorktree?(session: URI, prompt: string): Promise<{ handle: string; worktree: URI; }>; claimDetachedWorktree?(handle: string): Promise; setDetachedWorktreeArchived?(handle: string, archived: boolean): Promise; deleteDetachedWorktree?(handle: string): Promise; reconcileDetachedWorktrees?(scope: string, activeHandles: readonly string[]): Promise; refreshCopilotConnectorSessions?(forceConnectorName?: string): Promise; listPluginInstallations?(provider: AgentProvider, session?: URI, chat?: URI): Promise; uninstallPlugin?(provider: AgentProvider, request: IAgentPluginUninstallRequest, session?: URI, chat?: URI): Promise; setPluginEnabled?(provider: AgentProvider, plugin: string, enabled: boolean): Promise; listAgentExtensions?(session?: URI, chat?: URI): Promise; setAgentExtensionEnabled?(extensionId: string, enabled: boolean, session?: URI, chat?: URI): Promise; /** Returns `undefined` while the provider registry is unsettled; the provider must publish a canvas change after it settles. */ listSessionCanvases?(session: URI, chat: URI): Promise; openSessionCanvas?(session: URI, request: IAgentCanvasOpenRequest, chat: URI): Promise; closeSessionCanvas?(session: URI, request: IAgentCanvasCloseRequest, chat: URI): Promise; installPlugin?(provider: AgentProvider, request: IAgentPluginInstallRequest, session?: URI, chat?: URI): Promise; retryManagedPlugins?(provider: AgentProvider, session: URI, chat?: URI): Promise; listPluginMarketplaces?(provider: AgentProvider, session: URI, chat?: URI): Promise; addPluginMarketplace?(provider: AgentProvider, session: URI, source: string, chat?: URI): Promise; browsePluginMarketplace?(provider: AgentProvider, session: URI, name: string, chat?: URI): Promise; removePluginMarketplace?(provider: AgentProvider, session: URI, name: string, force?: boolean, chat?: URI): Promise; refreshPluginMarketplaces?(provider: AgentProvider, session: URI, name?: string, chat?: URI): Promise; searchCustomizationMarketplace?(provider: AgentProvider, session: URI, request: IAgentCustomizationMarketplaceSearchRequest): Promise; listCustomizationInstallations?(provider: AgentProvider, session: URI): Promise; prepareCustomizationInstallation?(provider: AgentProvider, session: URI, request: IAgentCustomizationInstallationRequest | { readonly installationId: string; }): Promise; applyCustomizationInstallation?(provider: AgentProvider, operationId: string): Promise; recoverCustomizationInstallations?(provider: AgentProvider, session: URI): Promise; addMcpServerConfiguration?(provider: AgentProvider, name: string, config: IMcpServerConfiguration): Promise; /** * Create an additional chat within an existing session. Spins up the * backing chat in the harness (sharing the session's session) and * registers the chat in the session's catalog so subscribers observe a * `session/chatAdded` action. The `chat` URI is the client-chosen channel. */ createChat(session: URI, chat: URI, options?: IAgentCreateChatRequestOptions, credentials?: IAgentHostCredentialSource, initialMessageContext?: IAgentCreateChatInitialMessageContext): Promise; /** * Applies `workspace` to `chat`, a peer chat that `session` owns and that has not started a turn: prepares the * folder, worktree or scratch folder as {@link createChat} does for a requested workspace, then rebinds the chat's * backing to it. Throws, leaving the chat unchanged, for the default chat, a forked, side or spawned chat, a chat * with a turn or pending message, or a provider that can't give a chat its own working directory. */ setChatWorkspace(session: URI, chat: URI, workspace: IAgentCreateChatWorkspace, credentials?: IAgentHostCredentialSource): Promise; /** Dispose an additional chat created via {@link createChat}. */ disposeChat(session: URI, chat: URI): Promise; /** * Moves a chat that `session` owns (AHP `moveChat`): within `session`, into another existing session with its * descendants, or into a new session. Resolves to the chat's owner afterwards. Throws * `AgentChatMoveRefusedError` without changing anything when the move is refused. */ moveChat(session: URI, chat: URI, destination: AgentChatMoveDestination): Promise; /** * Moves a session whose only chat is its default chat (with that chat's descendants) under `destination`, placed * after `after` (`undefined`: first), VS Code-internal (Block 4). The chat becomes a peer of `destination` and * `session` ends. Resolves to `destination`. Throws `AgentChatMoveRefusedError` without changing anything when the * move is refused. */ moveSession(session: URI, destination: URI, after: URI | undefined): Promise; /** Resolve the dynamic configuration schema for creating a session. */ resolveSessionConfig(params: IAgentResolveSessionConfigParams): Promise; /** Return dynamic completions for a session configuration property. */ sessionConfigCompletions(params: IAgentSessionConfigCompletionsParams): Promise; /** * Return completion items for a partially-typed input (e.g. an `@`-mention * inside a user message the user is composing). Delegates to a pluggable * set of {@link IAgentHostCompletionItemProvider}s registered with the * agent host. * * Note: this method does not accept a {@link CancellationToken} because * `CancellationToken`s do not round-trip through the IPC boundary today * (the deserialised value lacks the prototype methods used by * subscribers). Callers that need cancellation should race the returned * promise on their own side. */ completions(params: CompletionsParams): Promise; /** * Returns the set of characters that, when typed in a {@link UserMessage} * input, SHOULD cause the client to issue a `completions` request. * Aggregated from every registered {@link IAgentHostCompletionItemProvider}. */ getCompletionTriggerCharacters(): Promise; /** Dispose a session in the agent host, freeing SDK resources. */ disposeSession(session: URI): Promise; /** * Create a terminal requested by a protocol client. Terminals created by * VS Code clients (per `clientType`) receive VS Code's terminal identity * (`TERM_PROGRAM`). */ createTerminal(params: CreateTerminalParams, clientType?: AgentHostClientType): Promise; /** Dispose a terminal and kill its process if still running. */ disposeTerminal(terminal: URI): Promise; invokeChangesetOperation(params: InvokeChangesetOperationParams, credentials?: IAgentHostCredentialSource): Promise; /** * Routes a request received on an `mcp://` AHP side channel to the * MCP server implementation owned by the appropriate agent. The * channel URI shape is `mcp:////` * (the latter two segments URL-encoded), where `chatUri` is the concrete * `ahp-chat://` URI, matching the * {@link McpServerCustomization.channel | channel} the agent host * advertises while the server is in * {@link McpServerStatus.Ready | `Ready`}. * * `method` is the raw MCP JSON-RPC method (e.g. `tools/list`, * `tools/call`, `resources/read`); `params` are the JSON-RPC params * (still carrying the routing envelope's `channel` field, which the * agent may ignore). Rejects with an `Error` whose message begins * with `Method not found` when the channel is unknown or the agent * doesn't recognise the method — the protocol server translates that * into a JSON-RPC `-32601`. */ handleMcpRequest(channel: string, method: string, params: Record | undefined): Promise; /** * Aggregated stream of MCP notifications across every agent. The * protocol server subscribes once and broadcasts each notification as * a JSON-RPC notification to all connected clients (the routing * envelope's `channel` field is sufficient for client-side dispatch, * so no per-subscription fanout is required). */ readonly onMcpNotification: Event; /** Gracefully shut down all sessions and the underlying client. */ shutdown(): Promise; /** * Host-level network context for diagnostics — agent host version, OS/arch, * account, proxy settings/env, and the endpoints worth probing (which * callers probe via {@link diagnosticsFetch}, plus any additional URLs). */ getNetworkDiagnosticsInfo(): Promise; /** Resolve managed settings through each provider's native SDK/runtime implementation. */ getManagedSettingsDiagnostics(): Promise; /** * Probe connectivity from the agent host process to a single `url`, * resolving the proxy and timing DNS + reachability. Used by the "Network * Diagnostics" developer command. */ diagnosticsFetch(url: string): Promise; getSessionStateFile?(session: URI, chat?: URI): Promise; /** Resolve the owning provider's exact plan artifact without granting access to its directory. */ getSessionPlanFile?(session: URI, chat: URI): URI | undefined; collectDebugLogs?(session: URI | undefined, kind: AgentHostDebugLogsArtifactKind, chat?: URI, progressToken?: string): Promise; cancelDebugLogs?(progressToken: string): Promise; readDebugLogsChunk?(resource: URI, position: number): Promise; /** * Subscribe to state at the given URI. Returns a snapshot of the current * state and the serverSeq at snapshot time. Subsequent actions for this * resource arrive via {@link onDidAction}. Registers `clientId` against * the resource so the server-side refcount knows who is watching, so the * caller does not need to invoke {@link addSubscriber} separately. Pair * with {@link unsubscribe} when the subscription is released. When * provided, `isActive` is checked before registering the subscriber so a * request cancelled during asynchronous resolution cannot pin the resource. * Callers must distinguish lost subscription ownership from a missing resource. */ subscribe(resource: URI, clientId: string, isActive?: () => boolean, credentials?: IAgentHostCredentialSource, telemetryContext?: IAgentHostSessionSubscribeTelemetryContext): Promise; /** * Counterpart to {@link subscribe}. Drops `clientId` from the refcount * for `resource`; when the last subscriber is removed, idle session state * for `resource` may be evicted from the server. */ unsubscribe(resource: URI, clientId: string): void; /** * Register `clientId` against `resource` without going through * {@link subscribe}. Only needed by callers that hand out snapshots * synchronously (e.g. the JSON-RPC handshake serving `initialSubscriptions` * out of the in-memory state cache); regular subscribers should call * {@link subscribe} instead. Counterpart cleanup is {@link unsubscribe}. */ addSubscriber(resource: URI, clientId: string): void; /** * Fires when the server applies an action to subscribable state. * Clients use this alongside {@link subscribe} to keep their local * state in sync. */ readonly onDidAction: Event; /** * Fires when the server broadcasts an ephemeral notification * (e.g. sessionAdded, sessionRemoved). */ readonly onDidNotification: Event; readonly automationCapabilities: AutomationCapabilities | undefined; /** Whether chats of one session may use different agents (the `multipleChatProviders.enabled` host setting). */ readonly multipleChatProvidersEnabled?: boolean; listAutomationTriggerDefinitions(params: ListAutomationTriggerDefinitionsParams): Promise; runAutomation(params: RunAutomationParams): Promise; fetchAutomationRuns(params: FetchAutomationRunsParams): Promise; /** * Dispatch a client-originated action to the server. The server applies * it to state, triggers side effects, and echoes it back via * {@link onDidAction} with the client's origin for reconciliation. * * `channel` is the protocol URI string identifying the channel the action * targets (a session URI for session actions, terminal URI for terminal * actions, or {@link ROOT_STATE_URI} for root actions). Strings are used * rather than {@link URI} objects so that authority-less scheme URIs * like `ahp-root://` survive the wire format without normalization. * Queued dispatches return a promise that settles after application or rejection. */ dispatchAction(channel: string, action: SessionAction | ChatAction | TerminalAction | ClientChangesetAction | ClientAnnotationsAction | IRootConfigChangedAction | ClientAutomationAction | ClientAutomationRunAction, clientId: string, clientSeq: number, clientContext?: IAgentHostClientTelemetryContext, credentials?: IAgentHostCredentialSource): void | Promise; /** * List the contents of a directory on the agent host's filesystem. * Used by the client to drive a remote folder picker before session creation. */ resourceList(uri: URI): Promise; /** Estimates reclaimable allocation using the host-wide scan budget; an idle session enables persistent caching. */ measureWorktreeDiskUsage(root: URI, token: CancellationToken, session?: URI): Promise; /** Reports background removal state, optionally retrying cleanup of an archived session. */ sessionWorktreeCleanup?(session: URI, retry: boolean, force?: boolean): Promise; listManagedWorktrees?(repositories: readonly URI[]): Promise; cleanupManagedWorktree?(repository: URI, worktree: URI, branch: string, force?: boolean): Promise; /** * Read stored content by URI from the agent host (e.g. file edit snapshots, * or reading files from the remote filesystem). */ resourceRead(uri: URI, encoding?: ContentEncoding): Promise; /** * Write content to a file on the agent host's filesystem. * Used for undo/redo operations on file edits. */ resourceWrite(params: ResourceWriteParams): Promise; resourceCopy(params: ResourceCopyParams): Promise; resourceDelete(params: ResourceDeleteParams): Promise; resourceMove(params: ResourceMoveParams): Promise; /** Resolve a resource (stat + realpath). */ resourceResolve(params: ResourceResolveParams): Promise; /** Create a directory (`mkdir -p` semantics). */ resourceMkdir(params: ResourceMkdirParams): Promise; /** * Create a resource watcher on the agent host's filesystem. Returns the * `ahp-resource-watch:/` channel URI the caller subscribes to in * order to receive `resourceWatch/changed` events. The watcher is * tied to the subscriber refcount on that channel — the implementation * MUST hold the underlying file-system watcher for a short grace * period after the last unsubscribe so reconnects don't drop events. */ createResourceWatch(params: CreateResourceWatchParams): Promise; /** * Notify the agent service that a client subscribed to the given * `ahp-resource-watch:` channel so the per-watch refcount is bumped * (and the underlying {@link IFileService} watcher attached on the * first subscriber). Returns the decoded watch descriptor when the * channel parses successfully and the watcher is live; returns * `undefined` for unknown channels so the caller can surface a * not-found error. */ onResourceWatchSubscribed(channel: string): ResourceWatchState | undefined; /** * Counterpart to {@link onResourceWatchSubscribed}. Decrements the * per-watch refcount; on the last drop the watcher is held for a * short grace period before disposal. */ onResourceWatchUnsubscribed(channel: string): boolean; } export declare const IAgentHostService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * The ambient Agent Host connection used by workbench surfaces. */ export interface IAgentHostService extends IAgentConnection { readonly _serviceBrand: undefined; /** Available only through the local native Agent Host management connection. */ configureMissionControl?(options: IMissionControlOptions | undefined, withdrawingAccountId?: string): Promise; sealMissionControlCredential?(request: IMissionControlCredentialSealingRequest): Promise; getMissionControlEnvironmentId?(): Promise; getMissionControlEnvironmentName?(): Promise; /** * Whether {@link createSession} can seed `importConversation` history * (supported by the local management connection and by AHP connections that * advertise `vscode.createSessionImport`). */ readonly supportsConversationImport?: boolean; readonly onAgentHostExit: Event; readonly onAgentHostStart: Event; /** * `true` while we are in the middle of authenticating against the local * agent host (resolving tokens for any advertised `protectedResources` and * pushing them via {@link authenticate}). Defaults to `true` at startup so * that the period before the first auth pass is also covered. * * Producers (the workbench `AgentHostContribution`) flip this around their * auth pass; consumers (e.g. the local sessions provider) read it to mark * sessions as still loading. */ readonly authenticationPending: IObservable; /** Update {@link authenticationPending}. Internal — only the auth driver should call this. */ setAuthenticationPending(pending: boolean): void; /** Refresh live local Copilot sessions after Connector membership or authorization changes. */ refreshCopilotConnectorSessions?(forceConnectorName?: string): Promise; /** Uninstall a plugin through its local Agent Host provider. */ listPluginInstallations?(provider: AgentProvider, session?: URI, chat?: URI): Promise; uninstallPlugin?(provider: AgentProvider, request: IAgentPluginUninstallRequest, session?: URI, chat?: URI): Promise; setPluginEnabled?(provider: AgentProvider, plugin: string, enabled: boolean): Promise; /** Install a plugin through its local Agent Host provider. */ installPlugin?(provider: AgentProvider, request: IAgentPluginInstallRequest, session?: URI, chat?: URI): Promise; /** Retry the plugins a live chat's managed settings require through its local Agent Host provider. */ retryManagedPlugins?(provider: AgentProvider, session: URI, chat?: URI): Promise; listPluginMarketplaces?(provider: AgentProvider, session: URI, chat?: URI): Promise; addPluginMarketplace?(provider: AgentProvider, session: URI, source: string, chat?: URI): Promise; browsePluginMarketplace?(provider: AgentProvider, session: URI, name: string, chat?: URI): Promise; removePluginMarketplace?(provider: AgentProvider, session: URI, name: string, force?: boolean, chat?: URI): Promise; refreshPluginMarketplaces?(provider: AgentProvider, session: URI, name?: string, chat?: URI): Promise; searchCustomizationMarketplace?(provider: AgentProvider, session: URI, request: IAgentCustomizationMarketplaceSearchRequest): Promise; listCustomizationInstallations?(provider: AgentProvider, session: URI): Promise; prepareCustomizationInstallation?(provider: AgentProvider, session: URI, request: IAgentCustomizationInstallationRequest | { readonly installationId: string; }): Promise; applyCustomizationInstallation?(provider: AgentProvider, operationId: string): Promise; recoverCustomizationInstallations?(provider: AgentProvider, session: URI): Promise; /** * Provisional bridge for provider-global raw MCP configuration. * @see https://github.com/github/copilot-agent-runtime/issues/26495 */ addMcpServerConfiguration?(provider: AgentProvider, name: string, config: IMcpServerConfiguration): Promise; /** Start connecting to the agent host if it has not already started. */ startAgentHost(): void; /** Restart the agent host process, if this connection owns its lifecycle. */ restartAgentHost(): Promise; startWebSocketServer(): Promise; /** * Get inspector listener info for the agent host process. If the inspector * is not currently active and `tryEnable` is true, opens the inspector on * a random local port. Returns `undefined` if the inspector cannot be * enabled. */ getInspectInfo(tryEnable: boolean): Promise; }