import { URI } from "../../../../base/common/uri.js"; import { IRemoteAgentHostConnectionInfo } from "../../../../platform/agentHost/common/remoteAgentHostService.js"; export declare const COPILOT_CLI_LOCAL_AH_SCHEME = "agent-host-copilotcli"; export declare const COPILOT_CLI_EH_SCHEME = "copilotcli"; /** Agent-host provider id for Copilot CLI, used to build backend (AHP channel) session URIs. */ export declare const COPILOT_CLI_AGENT_PROVIDER = "copilotcli"; /** * Builds the local `events.jsonl` URI under `/session-state//`. * * Used for both the local Agent Host Copilot CLI provider and the * extension-host Copilot CLI provider, which share the same on-disk layout * and the same chat session URI shape (`copilotcli:/`). */ export declare function buildLocalEventsUri(copilotHome: URI, rawSessionId: string): URI; /** * Builds the local `/logs` directory URI. */ export declare function buildLocalCopilotLogsUri(copilotHome: URI): URI; /** * Builds the local `/session-state` directory URI. */ export declare function buildLocalSessionStateUri(copilotHome: URI): URI; /** * Builds a `vscode-agent-host://` URI for the `events.jsonl` file inside * the host's user home directory, using the connection's reported * `defaultDirectory` (set from `os.homedir()` on the host during the * AHP handshake). * * The path is joined at the URI-path level using forward slashes, which * works for both POSIX hosts (`/home/me`) and Windows hosts whose * `URI.file(os.homedir()).path` is also forward-slash-rooted (e.g. * `/c:/Users/me`). Returns `undefined` if the host did not report a * usable `defaultDirectory`. */ export declare function buildRemoteEventsUri(connection: IRemoteAgentHostConnectionInfo, rawSessionId: string): URI | undefined; /** * Builds a `vscode-agent-host://` URI for the host's `~/.copilot/logs` * directory, using the connection's reported home directory. */ export declare function buildRemoteCopilotLogsUri(connection: IRemoteAgentHostConnectionInfo): URI | undefined; /** * Parses the connection authority out of a remote AH chat session scheme * of the form `remote--copilotcli`. Returns `undefined` for * any other scheme, including the local `copilotcli` scheme. */ export declare function parseRemoteAuthorityFromScheme(scheme: string): string | undefined; /** * Extracts the raw Copilot CLI session id from a chat session resource. */ export declare function getCopilotCliSessionRawId(sessionResource: URI | undefined): string | undefined; /** * Lists each Copilot CLI session that has both a legacy extension-host row and a * local agent-host row once. * * The agent-host row wins once the session has been adopted. While it is still * un-opened (`isUnopenedTwin`), the legacy row wins instead: the extension host * still owns the conversation, so its row tracks a run in progress and its * archive state, and opening it probes adoption with a fallback to the legacy * session. With no legacy row (its provider retired), the agent-host row stays. * * Only `copilotcli:` rows are ever matched against `agent-host-copilotcli:` rows. * A remote agent-host session (`remote--copilotcli:`) shares the * Copilot CLI session type and can carry the same raw id as a local one, but is * a different session and must never be deduped against it. */ export declare function dedupeMigratedCopilotCliSessions(items: readonly T[], resourceOf: (item: T) => URI, isUnopenedTwin?: (item: T) => boolean): T[]; /** * The local agent-host resource a legacy extension-host Copilot CLI session * would migrate to, or `undefined` when `resource` is not such a session. * Synchronous by design: open paths must not pay a round-trip for the * overwhelmingly common case of a session that is not legacy. */ export declare function migratedCopilotCliResource(resource: URI | undefined): URI | undefined; /** * The legacy extension-host resource a local agent-host Copilot CLI session * was migrated from, or `undefined` when `resource` is not such a session. * The inverse of {@link migratedCopilotCliResource}; never maps a remote * agent-host session, which is a different session, or a peer chat (a URI * fragment), which never existed in the legacy session. */ export declare function legacyCopilotCliResource(resource: URI | undefined): URI | undefined; export type ResolveEventsUriResult = { readonly kind: "ok"; readonly resource: URI; } | { readonly kind: "no-session"; } | { readonly kind: "unsupported-scheme"; readonly scheme: string; } | { readonly kind: "remote-not-connected"; readonly authority: string; } | { readonly kind: "remote-no-home"; readonly authority: string; }; /** * Pure resolver for tests. Translates a chat session resource into the * `events.jsonl` URI for the corresponding Copilot CLI session, or * returns a structured error. */ export declare function resolveEventsUri(sessionResource: URI | undefined, copilotHome: URI, getConnectionByAuthority: (authority: string) => IRemoteAgentHostConnectionInfo | undefined): ResolveEventsUriResult; /** * Resolves the host-local filesystem path string of a Copilot CLI session's * `events.jsonl`, suitable for tooling that runs **on the host** (e.g. the * agent's terminal), as opposed to a workbench {@link URI} consumed by the * file service. * * Reuses {@link resolveEventsUri} so it stays in lockstep with the resolution * used by the chat debug panel and the "Open Copilot CLI State File" command, * then unwraps the result into a plain path: * - a local `file://` URI becomes its `fsPath` (same machine as the host). * - a remote `vscode-agent-host://` URI is unwrapped to the underlying file * URI whose `path` is the real path on the remote host the agent runs on. * * Returns `undefined` when the session is not a Copilot CLI session or the * path cannot be resolved (e.g. a remote host that reported no home directory). */ export declare function buildHostLocalEventsPath(sessionResource: URI | undefined, copilotHome: URI, getConnectionByAuthority: (authority: string) => IRemoteAgentHostConnectionInfo | undefined): string | undefined;