/** * Shared editor-session registry format: entry shape, guards, path, * liveness-filtered reads, served-project parsing and pending launches. * The server’s session-registry module owns writes to this format. * * The registry is also the CREDENTIAL FILE for the owner's own processes: each entry carries its session's * connection token, and `sessionFetch` is how a process on this machine reaches a session with it, as a Code-OSS * client reads its server's `--connection-token-file` (`src/vs/server/node/serverConnectionToken.ts:62-79` in the * `volter-ai/code-oss` fork). The file is the user's alone (0600, written by the session). */ /** One registry entry, exactly as the server's write half records it. */ export interface EditorSessionEntry { /** Canonical project root currently open, or null when none. */ project: string | null; port: number; /** PID of the dev-server process. */ pid: number; /** ISO timestamp of server start. */ startedAt: string; sessionId: string | null; /** The session's connection token, which every request to it carries (`sessionFetch`). Never returned by a * session route; it is in this user-private file and in the page's cookie. */ connectionToken?: string | null; repositoryId: string | null; worktreeId: string | null; worktreeRoot: string | null; projectRelativePath: string | null; branch: string | null; headCommit: string | null; baseCommit: string | null; } export declare const EDITOR_SESSIONS_REGISTRY_FILE: string; export declare function isEditorSessionEntry(v: unknown): v is EditorSessionEntry; export declare function normalizeEditorSessionEntry(session: EditorSessionEntry): EditorSessionEntry; /** Whether pid exists. Signal 0's EPERM means it exists but this caller cannot signal it. */ export declare function pidAlive(pid: number): boolean; /** The registry's live entries — shape-validated and PID-liveness-filtered. */ export declare function readLiveRegisteredSessions(): EditorSessionEntry[]; /** * The cookie the session reads its connection token from: Code-OSS's own (`connectionTokenCookieName`, * `src/vs/base/common/network.ts:187`). The page's Code-OSS server sets it on the page's host from the address's * `?tkn=` (`src/vs/server/node/webClientServer.ts:313-336`), and the session's routes share that host through its * proxy and the token through the project's token file, so one cookie carries both. */ export declare const CONNECTION_TOKEN_COOKIE = "vscode-tkn"; /** The connection token of the live session listening on `port` of this machine, from its entry; null when no live * session there registered one. */ export declare function registeredConnectionToken(port: number): string | null; /** `init` with the connection token of the session `url` names, as the cookie the session reads. Only a loopback * address gets one, and only a registered session's: the token never leaves this machine. */ export declare function withSessionToken(url: string | URL, init?: RequestInit): RequestInit; /** * Say why a session on this machine refused (403) a request this process could send it no token with: its registry * entry, the one place the owner's processes read the token from, is missing or carries none. Throws that; returns * when the refusal is something else (a token was sent, or the address is not a local session's). */ export declare function refuseWithoutRegisteredToken(url: string | URL, status: number): void; /** `fetch` to a session on this machine, carrying its connection token (`withSessionToken`). Every request a process * of the owner's makes to a session goes through here or through `EditorClient`, which does the same, and a refusal * for want of the token says so (`refuseWithoutRegisteredToken`). */ export declare function sessionFetch(url: string | URL, init?: RequestInit): Promise; /** Announce a launch before the server can register. Each launcher owns its file. */ export declare function announceEditorLaunch(project: string): () => void; /** Wait only for an observed live launcher, never for a missing editor. */ export declare function waitForPendingEditorLaunch(project: string): Promise; /** Read the project identity reported by /__editor/project. A serving path * identifies an open project even when its manifest cannot be parsed or * validated; project: null alone denotes no described project. */ export declare function servedProjectAnswer(body: unknown): { path: string | null; manifestError: string | null; };