/** * Subset of AgentLink's runtime state file that we care about. The full * schema (RuntimeState) lives in AgentLink's `agent/src/config.ts`; it * carries `pid`, `sessionId`, `server`, etc., but the only field we need to * build a deep link is `sessionUrl`. */ export interface AgentlinkRuntimeState { /** * Full web-portal URL for the running AgentLink session, e.g. * `https://msclaude.ai/s/#/?k=` (or * `/ms/` in Entra mode). The `#/` portion is the hash * router root and `?k=...` carries the E2E key that AgentLink's browser * uses to decrypt traffic. We treat the URL as an opaque template. */ sessionUrl: string; } /** * Read AgentLink's runtime state. Returns null when AgentLink isn't running * (file missing), the file is unreadable, or it lacks a usable `sessionUrl`. * Never throws — callers fall back to omitting the link silently. */ export declare function loadAgentlinkRuntimeState(): AgentlinkRuntimeState | null; /** * Build a deep link into AgentLink's web portal that opens a specific Claude * session inside the running AgentLink agent. AgentLink's hash router * recognises `#/chat_v2/_` and resumes the * session for that working directory from the same `~/.claude/projects/` * files that `#list-sessions` reads, so the web UI lands on the exact same * conversation in the right workspace. * * The route segment is `encodeURIComponent(cwd) + '_' + claudeSessionId`. * AgentLink decodeURIComponent's the whole segment and then splits on the * LAST underscore, so the cwd may itself contain underscores while the * trailing session id (a UUID) stays intact. This mirrors the web UI's own * `router.push('/chat_v2/' + encodeURIComponent(dir) + '_' + id)`. * * Returns null when AgentLink runtime state isn't available or the session * id or cwd is empty so callers can omit the link without branching on errors. * * Examples (input sessionUrl + cwd → returned link): * `https://msclaude.ai/s/abc#/?k=K` + `Q:\repo` * → `https://msclaude.ai/s/abc#/chat_v2/Q%3A%5Crepo_?k=K` * `https://msclaude.ai/ms/xyz#/?k=K` (entra) + `/home/u/p` * → `https://msclaude.ai/ms/xyz#/chat_v2/%2Fhome%2Fu%2Fp_?k=K` * `https://msclaude.ai/s/abc` + `Q:\repo` * → `https://msclaude.ai/s/abc#/chat_v2/Q%3A%5Crepo_` */ export declare function buildSessionWebLink(claudeSessionId: string, cwd: string, state: AgentlinkRuntimeState | null): string | null;