import { IDisposable } from "../../../base/common/lifecycle.js"; import { Event, URI } from "../../../sessions/sessions.web.main.internal.js"; import { IAgentHostConnectionInfo, IAgentHostSessionResolutionPolicy, IAgentHostSessionIdentity, IAgentHostSessionResolution } from "./agentHostConnectionsService.js"; import { IAgentConnection } from "./agentService.js"; export declare const IAgentHostConnectionsService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * A facade over the window's ambient agent host * (`IAgentHostService`) and the registry of remote agent hosts * (`IRemoteAgentHostService`), so consumers can enumerate and resolve * {@link IAgentConnection}s without branching on local-vs-remote or * fanning out over "1 ambient + N remote" themselves. Session providers may * register declarative scheme/default-changeset policy so every consumer * resolves provider-specific session resources consistently. * * This service deliberately does NOT expose connection lifecycle operations: * ambient-process concerns (restart, inspect, auth-pending) stay on * `IAgentHostService`, and remote-registry mutations (add/remove/reconnect/ * upgrade) stay on `IRemoteAgentHostService`. */ export interface IAgentHostConnectionsService { readonly _serviceBrand: undefined; /** Fires when the set of connections changes (ambient lifecycle or remotes added/removed). */ readonly onDidChangeConnections: Event; /** Fires when connection or provider policy changes can alter session-resource resolution. */ readonly onDidChangeSessionResolution: Event; /** * All known connections as `[ambient, ...remotes]`. The ambient entry is * always present with a live `connection`; only remote entries may have * `connection: undefined` (e.g. while connecting/disconnected). Remote * entries reflect the current `IRemoteAgentHostService` registry. */ readonly connections: readonly IAgentHostConnectionInfo[]; /** The window's ambient/primary connection (local, or the window-remote bridge). */ readonly ambientConnection: IAgentConnection; /** * Resolves a live connection by sanitized authority, including * {@link AMBIENT_AGENT_HOST_AUTHORITY} for the ambient host. Returns * `undefined` when no connected host matches. */ getConnectionByAuthority(authority: string): IAgentConnection | undefined; /** * Resolves a live remote connection by raw address. The ambient host has no * address and is never returned here — use {@link ambientConnection} or * {@link getConnectionByAuthority} with {@link AMBIENT_AGENT_HOST_AUTHORITY}. */ getConnectionByAddress(address: string): IAgentConnection | undefined; /** * Registers provider-owned session resolution policy for a connection. * At most one policy may be registered for an authority. */ registerSessionResolutionPolicy(authority: string, policy: IAgentHostSessionResolutionPolicy): IDisposable; /** * Runs `fn`, coalescing every {@link onDidChangeSessionResolution} it would fire into a single * event emitted after the outermost batch completes. Reads inside the batch see the new state. */ batchSessionResolutionChanges(fn: () => T): T; /** Records an exact backend identity and adapts only its frontend provider scheme. */ registerSessionResource(backendSession: URI, authority?: string, provider?: string): URI; /** Looks up a frontend resource using its advertised backend identity on one connection. */ findSessionResource(backendSession: URI, authority?: string): URI | undefined; /** * Maps a backend session through provider policy only when the resource * resolves back to that exact session. Unsupported identities return undefined. */ getSessionResource(backendSession: URI, authority?: string): URI | undefined; /** * Resolves an agent-host chat-session resource to its connection authority * and backend session URI without requiring the host to be connected. */ resolveSessionResourceIdentity(sessionResource: URI): IAgentHostSessionIdentity | undefined; /** * Resolves an agent-host chat-session resource to its owning connection and * backend session URI. Handles both local schemes * (`agent-host-`) — backed by the ambient connection — and remote * schemes (`remote--`) — resolved against the live * remote registry. Returns `undefined` when the resource is not an * agent-host session, or when the matching remote host is not connected. * * NOTE: provisional/untitled sessions are a workbench concern and are NOT * handled here — callers that support them should resolve those first. */ resolveSessionResource(sessionResource: URI): IAgentHostSessionResolution | undefined; }