export interface BridgeRuntime { port: number; pid: number; startedAt: string; /** * Shared secret for the daemon's localhost probe server (2026-10). * * Every non-public endpoint now requires it, so a web page the user visits * can no longer take workspace locks, forge session events, or read `/status`. * It lives here - next to the port the callers already read - rather than in * its own file, so no caller needs new plumbing. * * This is deliberately NOT a defence against another local process running * as the same user: those can read this file. It exists to stop BROWSERS, * which can reach `http://127.0.0.1:` but can never read a local file. */ probeToken?: string; } export declare function runtimeFile(): string; /** Runtime file written by the daemon on start (stale entries are fine). */ export declare function writeRuntimeFile(entry: BridgeRuntime): void; export declare function readRuntimeFile(): BridgeRuntime | null; /** * The probe token the running daemon expects, or null when there is none * (no daemon, or a daemon older than 2026-10). Callers send it as * `X-TeamShare-Probe-Token`; a tokenless (older) daemon ignores it. */ export declare function readProbeToken(): string | null; /** * POST to the running daemon's probe server WITH the probe token attached. * * Since 2026-10 every route except `GET /ping` and `GET /usage` requires that * token - they were open to any web page the user visited, which could take * workspace locks on their repos, forge session events into the live console * and release agents. All in-repo callers go through here so the header can * never be forgotten; a caller that hand-rolls its own fetch must add it too. * * Returns null when there is no daemon (callers must fail open) and never * throws - a dead daemon must not block whatever the caller was doing. */ export declare function daemonPost(path: string, body?: unknown, timeoutMs?: number): Promise; /** * GET a route on the running daemon's probe server, with the probe token. * * Same contract as `daemonPost`: returns null when no daemon answers and never * throws. Used by the harness's ACTIVITY PROBE (2026-10-27) - the run asks the * daemon whether its MCP relay has served a request recently, which is the only * way a client/server harness can see a long tool call it is not printing. */ export declare function daemonGet(path: string, timeoutMs?: number): Promise; /** * Best arbiter base URL: explicit env override > runtime file > probe the * candidate ports once. Returns null when no daemon answers - callers must * fail open. */ export declare function discoverArbiter(): Promise; export type WsEventType = 'lock.waiting' | 'lock.granted' | 'lock.released' | 'build.start' | 'build.finish' | 'peer.ping' | 'presence.here' | 'worktree.created' | 'worktree.removed'; export interface WsEvent { type: WsEventType; /** ISO timestamp (filled automatically). */ ts?: string; dir?: string; agentId?: string; kind?: string; taskId?: string; note?: string; } /** Log always; relay to the daemon's SSE hub when reachable. Never throws. */ export declare function publishEvent(event: WsEvent): void; /** Convenience: did `file` appear recently (used by tests). */ export declare function arbitrationLogExists(): boolean;