/** * The `peaks web` daemon contract — on-disk (`daemon.json`) and on-the-wire * * `parseDaemonInfo` validates both shape and `PROTOCOL_VERSION`, so a daemon * left over from an older protocol is rejected (and therefore killed and * respawned) rather than mis-called. */ /** Bumped whenever `WebOpRequest` / `WebOpResponse` / `WebDaemonInfo` change shape. */ export declare const PROTOCOL_VERSION = 1; /** * The full `peaks web` verb surface. S1 implements the first six. * * `whoami` is the CLI's ownership proof: it answers with the daemon's OWN * identity, behind the bearer check, so `peaks web stop` can tell "the daemon * this record describes" from "some local listener that happens to answer 2xx". */ export type WebOp = 'open' | 'text' | 'snap' | 'click' | 'shot' | 'metrics' | 'login' | 'install' | 'status' | 'stop' | 'whoami'; /** Contents of `web/daemon/daemon.json` — the only way to reach a live daemon. */ export interface WebDaemonInfo { readonly protocolVersion: number; readonly pid: number; readonly port: number; /** 32 random bytes, hex. Sent as `Authorization: Bearer `. */ readonly token: string; /** `peaks-loop` version that wrote the file. */ readonly version: string; readonly projectRoot: string; readonly sessionId: string; readonly startedAt: string; } /** Body of `POST /op`. */ export interface WebOpRequest { readonly op: WebOp; readonly args: Readonly>; } /** Response of `POST /op`. */ export interface WebOpResponse { readonly ok: boolean; readonly data: T | null; readonly code: string | null; readonly message: string | null; readonly warnings: readonly string[]; readonly nextActions: readonly string[]; } /** * Parse and validate a `daemon.json` body. Returns `null` for malformed JSON, * a wrong `protocolVersion`, or any missing/mistyped/out-of-range field — never * throws. * * Every field is checked against how the caller will USE it, not just its type: * `port` is bounded to the TCP range because it is interpolated into a URL, and * `pid` is a positive integer because it is passed to `process.kill`. Ownership * (`projectRoot` / `sessionId` vs the caller's) is deliberately NOT checked here * — this function has no caller to compare against; `daemon-registry.readDaemonInfo` * is where that comparison belongs. */ export declare function parseDaemonInfo(raw: string): WebDaemonInfo | null;