/** * Schema version for the shared local agent-host endpoint registry under * `/agent-host/local-endpoint/`. Each running agent host owns * one immutable entry file at `entries/.json`; readers additionally * merge any legacy `metadata.json` array left by older builds (read-only). This * schema is shared with the Rust CLI * (`cli/src/tunnels/agent_host_registry.rs`); field renames or removals MUST be * coordinated across both languages. * * Version 1 was the editor-only, socket-path-only schema * (`ILocalAgentHostEndpointMetadata` in `node/localAgentHostMetadata.ts`). * Version 2 generalizes the registry to hold both editor (socket/pipe) and * standalone CLI (TCP) endpoints so every locally running agent host is * discoverable from one place. Changing the on-disk container (one file per * instance vs. the historical single shared array) did not change this * serialized entry shape or `AGENT_HOST_ENDPOINT_REGISTRY_SCHEMA_VERSION`. */ export declare const AGENT_HOST_ENDPOINT_REGISTRY_SCHEMA_VERSION = 2; /** * Kind of process that owns an agent host endpoint. Controls * ownership/default-selection policy on the client; it is not by itself a * measure of trust or of registry identity (see {@link IAgentHostEndpointIdentity}). */ export type AgentHostServerType = "editor" | "standalone"; /** * How to physically connect to an endpoint. Editor endpoints are always a * Unix domain socket or Windows named pipe; the standalone Rust CLI * currently only ever publishes a TCP endpoint. */ export type AgentHostEndpointAddress = { readonly type: "socket"; readonly path: string; } | { readonly type: "tcp"; readonly host: string; readonly port: number; }; /** * One entry of the shared local agent-host endpoint registry. Each live * agent host serializes exactly one of these as its own * `entries/.json` file; a legacy `metadata.json` (and the * `code agent endpoints` SSH inventory) instead carries a JSON array of them. */ export interface IAgentHostEndpointMetadata { readonly schemaVersion: typeof AGENT_HOST_ENDPOINT_REGISTRY_SCHEMA_VERSION; readonly type: AgentHostServerType; readonly pid: number; readonly instanceId: string; readonly protocolVersion: string; readonly connectionToken: string; readonly endpoint: AgentHostEndpointAddress; readonly quality?: string; readonly tunnelName?: string; } /** * The subset of {@link IAgentHostEndpointMetadata} that identifies a unique * registry entry/owner: `(type, pid, instanceId)`. `instanceId` makes * identity safe across PID reuse and rapid process replacement; `pid` alone * is not a safe key because operating systems recycle PIDs. */ export interface IAgentHostEndpointIdentity { readonly type: AgentHostServerType; readonly pid: number; readonly instanceId: string; } /** * Structurally validates one raw registry entry and returns it typed, or * `undefined` if it is malformed or its `schemaVersion` is not the one this * build understands. Every field is treated as untrusted input. */ export declare function parseAgentHostEndpointMetadataEntry(raw: unknown): IAgentHostEndpointMetadata | undefined; /** * Parses an array-shaped registry payload (`AgentHostEndpointMetadata[]`) — * a legacy `metadata.json` file or the `code agent endpoints` SSH inventory. * Every entry is validated independently: malformed entries and entries with * an unsupported `schemaVersion` are dropped rather than failing the entire * read. A non-array top-level value yields an empty registry. */ export declare function parseAgentHostEndpointRegistry(raw: unknown): IAgentHostEndpointMetadata[]; /** Stable string key for `(type, pid, instanceId)`, suitable for use as a Map key. */ export declare function getAgentHostEndpointIdentityKey(identity: IAgentHostEndpointIdentity): string; /** * Canonical UTF-8 input hashed to derive an identity's `.json` entry * file name. The `\0` separators are unambiguous (no field contains NUL) and the * encoding is shared byte-for-byte with the Rust CLI; it MUST NOT change without * a coordinated update on both sides. */ export declare function getAgentHostEndpointIdentityHashInput(identity: IAgentHostEndpointIdentity): string; export declare function isSameAgentHostEndpointIdentity(a: IAgentHostEndpointIdentity, b: IAgentHostEndpointIdentity): boolean; /** * Deduplicates entries by `(type, pid, instanceId)`. If a duplicate identity * appears more than once (for example a legacy `metadata.json` entry and a * newer per-instance entry file both describe the same owner), the entry * encountered later in `entries` wins, since it is presumed to be the most * recently written copy. */ export declare function dedupeAgentHostEndpointMetadata(entries: readonly IAgentHostEndpointMetadata[]): IAgentHostEndpointMetadata[];