/** * Binding status service — v2.18.2 read-only introspection helper. * * Surfaces the on-disk binding-store contents to the * `peaks binding status` CLI command (follow-up issue #2, deferred * from the v2.18.0 PRD §3.4 nice-to-have list). * * The service is intentionally read-only: it never calls * `registerInstance`, `heartbeat`, `dropInstance`, or any other * mutator. The only writes it performs are to stdout/stderr (the * rendering layer). This is the v2.18.2 "no side effects on status" * contract — a user running `peaks binding status` must not see their * own binding change underneath them. * * Format modes: * - `table` (default for non-TTY): ASCII table with columns * `sid | callerId | pid | roles | lastHeartbeat`. Designed to be * greppable and pipeable; no ANSI colour, no padding tricks. * - `json` (default when `--json` is set): raw binding dump matching * the zod `BindingSchema` shape. */ import { type Binding, type InstanceRecord } from './binding-store.js'; export type BindingStatusFormat = 'table' | 'json'; export type BindingStatusView = { /** The raw binding that was read (or `null` when no binding exists). */ binding: Binding | null; /** The on-disk source of the binding (informational; the CLI uses this for the header). */ source: 'canonical' | 'legacy' | 'none'; /** The project root the binding was read from. */ projectRoot: string; /** True when the binding's callerIds do not match the current outer-session-id env signal. */ stale: boolean; /** The current outer-session-id resolved from PEAKS_OUTER_SESSION_ID / CLAUDE_CODE_SESSION_ID / 'unknown'. */ outerSessionId: string; }; /** * Read the binding from disk and assemble the read-only view. Pure * helper that does no filesystem writes; safe to call from any test. */ export declare function loadBindingStatus(projectRoot: string): BindingStatusView; export declare function readOuterSessionId(): string; /** * Resolve the outer (harness / IDE) session id for the auto-compact * context-percent probe. Order: env signal first (PEAKS_OUTER_SESSION_ID / * CLAUDE_CODE_SESSION_ID), then the bound peaks session's recorded * `outerSessionId` (`session.json` meta). Returns `undefined` when neither is * available — the caller passes `undefined` through and the adapter's fallback * returns null → conservative-fallback. Vendor-neutral: this helper has no * IDE-specific naming; the env-var read lives alongside the binding layer. */ export declare function resolveOuterSessionId(projectRoot: string, sessionId: string, env?: NodeJS.ProcessEnv): string | undefined; /** * Render the binding as a pipeable ASCII table. The columns are fixed * (no truncation, no wrapping) so a downstream `awk` / `cut` pipeline * can be built against it. Returns the empty string (NOT a header * row) when the binding has no instances, so callers can detect "no * data" via the row count. */ export declare function formatTable(view: BindingStatusView): string; /** * Render the binding as a JSON envelope. The shape mirrors * `BindingSchema` (camelCase keys kept for back-compat with the * existing v2.18.0 callers; instance fields are nested under * `instances[]`). */ export declare function formatJson(view: BindingStatusView): Record; export declare function isInstanceRecord(value: unknown): value is InstanceRecord;