import { OperatingSystem } from "../../../base/common/platform.js"; import { URI } from "../../../base/common/uri.js"; import type { ResourceLabelFormatter } from "../../label/common/label.js"; /** * The URI scheme for accessing files on a remote agent host. * * The original file path is kept verbatim as the URI path so resource * labels, language detection, and path comparisons see a real path. The * original scheme, authority, query, and content path (when different) are carried in a single * url-safe-base64 `_ah` query parameter so any remote resource can be * represented without assuming `file://`: * * ``` * vscode-agent-host://[connectionAuthority][originalPath]?_ah=[meta]#[originalFragment] * ``` * * where `meta` is {@link IAgentHostUriMeta} as url-safe-base64-encoded * JSON. Encoding the metadata as a single opaque parameter (rather than * raw JSON) keeps the query a well-formed parameter list, so unrelated * query parameters such as `vscodeLinkType` can coexist on the wrapped * URI without corrupting the metadata. For example, * `file:///home/user/foo.ts` on remote `my-server` becomes: * ``` * vscode-agent-host://my-server/home/user/foo.ts?_ah=eyJzY2hlbWUiOiJmaWxlIn0 * ``` */ export declare const AGENT_HOST_SCHEME = "vscode-agent-host"; /** * Maps resource URIs between the Agent Host and its client. */ export interface IAgentHostResourceUriMapper { fromAgentHost(resource: URI): URI; toAgentHost(resource: URI): URI; } export declare const identityAgentHostResourceUriMapper: IAgentHostResourceUriMapper; /** * Wraps a remote URI into a {@link AGENT_HOST_SCHEME} URI that can be * resolved through the agent host filesystem provider. * * @param originalUri The URI on the remote (e.g. `file:///path` or * `agenthost-content:///sessionId/...`) * @param connectionAuthority The sanitized connection identifier used as * the URI authority (from {@link agentHostAuthority}). */ export declare function toAgentHostUri(originalUri: URI, connectionAuthority: string): URI; /** * Wraps a `ContentRef` for `resourceRead`, optionally displaying its file's path * while preserving the original content URI. Directly resolvable local filesystem URIs stay unchanged. */ export declare function toAgentHostContentUri(originalUri: URI, connectionAuthority: string, fileUri?: URI): URI; /** * Maps a host-side URI into client space. * * Content references use {@link toAgentHostContentUri}, with `fileUri` providing * the file identity for labels and comparisons when available. */ export type AgentHostUriMapper = (uri: URI, options?: { readonly contentRef?: boolean; readonly fileUri?: URI; }) => URI; /** * Whether the URI wraps a protocol `ContentRef` — content read with * `resourceRead`, never resolved with `resourceResolve`. * * See {@link toAgentHostContentUri}. */ export declare function isAgentHostContentRefUri(agentHostUri: URI): boolean; /** * Extracts the original URI from a {@link AGENT_HOST_SCHEME} URI. * * The inverse of {@link toAgentHostUri}. */ export declare function fromAgentHostUri(agentHostUri: URI): URI; export declare function createAgentHostResourceUriMapper(connectionAuthority: string): IAgentHostResourceUriMapper; /** * Maps the editor's remote filesystem to host-local files while retaining the window's workspace identities. */ export declare function createEditorRemoteAgentHostResourceUriMapper(remoteAuthority: string, connectionAuthority: string): IAgentHostResourceUriMapper; /** * Strips the redundant `ws://` scheme from an address. The transport layer * already defaults to `ws://`, so only `wss://` needs to be preserved. */ export declare function normalizeRemoteAgentHostAddress(address: string): string; /** * Encode a remote address into an identifier that is safe for use in * both URI schemes and case-insensitive URI authorities without collisions. * * The reserved `local` name becomes `remote_local`; lowercase alphanumeric * addresses pass through; lowercase host-like addresses replace `:` with `__`; * all other values use lowercase hex with a reserved `hex-` prefix. */ export declare function agentHostAuthority(address: string): string; /** * Authority of the in-process agent host. It always runs on the same * machine — and therefore the same operating system — as the client. */ export declare const LOCAL_AGENT_HOST_AUTHORITY = "local"; /** * Fallback label formatter for {@link AGENT_HOST_SCHEME} URIs of hosts * whose operating system is unknown. The URI path is already the original * resource path, so the label is the path verbatim. * * Deliberately lossless: without knowing the host's operating system, * neither `\` separators nor drive letter normalization can be applied * safely, since `/c:/repo/a.ts` is a valid POSIX path too and rendering it * as `C:/repo/a.ts` would name a different resource. Hosts whose operating * system is known get {@link agentHostLabelFormatter} instead. */ export declare const AGENT_HOST_LABEL_FORMATTER: ResourceLabelFormatter; /** * Label formatter for {@link AGENT_HOST_SCHEME} URIs of an agent host whose * operating system is known, so its paths render the way they do natively * on that host (`C:\a\b` instead of `/c:/a/b`). This matters because such * URIs are shown side by side with plain `file:` URIs — for example as the * original side of a diff — which are always rendered natively. * * Registered per authority since the operating system cannot be derived * from the client: a Windows client may be connected to a POSIX host. */ export declare function agentHostLabelFormatter(authority: string, os: OperatingSystem): ResourceLabelFormatter;