import { type CompactStatuslineState } from '../compact-statusline/compact-statusline-service.js'; export type StatusLineStdin = { workspace?: { current_dir?: string; project_dir?: string; }; cwd?: string; session_id?: string; caller_id?: string; /** * The harness's own context numbers. Declared here because this type IS the * documented shape of the payload the harness pipes in; omitting a documented * field would make the type lie by omission, and a consumer that reached for * it would have to cast. Read (never written) by * `harness-context-witness.ts` — see that module for why * `context_window_size` is NOT a denominator. */ context_window?: { context_window_size?: unknown; used_percentage?: unknown; remaining_percentage?: unknown; current_usage?: Record | undefined; } | undefined; }; export type StatusLineState = 'active' | 'idle' | 'stale' | 'invalid-presence'; export type StatusLinePresence = { skill: string; mode?: string; gate?: string; setAt?: string; claudeSessionId?: string; }; export type StatusLineActiveLeaf = { role: string; pendingCount: number; }; export type StatusLineModel = { state: StatusLineState; projectRoot: string | null; presence: StatusLinePresence | null; ageMs: number | null; compact: CompactStatuslineState; activeLeaf: StatusLineActiveLeaf | null; /** * id resolved for the project root (`getSessionIdCanonical`), or * `null` when no project root is bound or no `.peaks/_runtime//` * session is on disk. The renderer reads this to append ` [shortSid]` * to the project name cell for idle / stale states (G1); invalid- * presence still suppresses the suffix (G2). * * Carry-forward for AC1/AC2/AC3: the value is `null` whenever * `projectRoot === null` — the renderer relies on this to skip the * suffix without re-running `getSessionIdCanonical` against a non- * existent root. */ sessionId: string | null; /** * overlay snapshot read from `.peaks/_runtime//24h-state.json`, * or `null` when no file exists / file is corrupt / file has wrong * shape. The renderer reads this to append `[24h-]` after * the existing `` token in the ACTIVE state only. * * Always present (never undefined). `null` means "no overlay" — * the renderer skips the suffix without re-reading disk. */ twentyFourHourState: TwentyFourHourOverlay | null; }; /** * type returned by `read24hOverlay`. The renderer only consumes * `state` (to format `[24h-]`). The canonical * schema at `src/services/24h-mode/state.ts:55-66` carries additional * fields (`attempts: Record`, `enteredAt`, * `checkpoints`, etc.) but the overlay is deliberately MINIMAL — * it tolerates forward compatibility with new states the writer * graceful null on any invalid input). */ export type TwentyFourHourOverlay = { state: string; }; /** * the canonical `read24hState` in `src/services/24h-mode/store.ts:108`. * The canonical reader calls `coerceSnapshot` (which throws on * malformed shapes via `24H_STATE_INVALID`); this overlay reader * throw across the statusline boundary). * * Returns null when: * - `projectRoot` or `sessionId` is empty * - the file does not exist (ENOENT) * - JSON.parse fails (corrupt file) * - root is not a non-array object * - `state` is missing, non-string, or empty string */ export declare function read24hOverlay(projectRoot: string, sessionId: string): TwentyFourHourOverlay | null; export declare function resolveCwdFromStdin(stdin: StatusLineStdin | null): string; export declare function parseStatusLineStdin(raw: string): StatusLineStdin | null; /** * Resolve the callerId for the read-side isolation. Order of resolution: * 1. `stdin?.caller_id` (when the harness / IDE adapter forwards it) * 2. `process.env.CLAUDE_CODE_SESSION_ID` (Claude Code's ambient session id; * used as a coarse callerId surrogate when stdin omits caller_id) * 3. `null` (no callerId — caller falls back to the project-level * single-file read for back-compat) */ export declare function resolveCallerId(stdin: StatusLineStdin | null): string | null; /** * Read the active-dispatch index for the canonical session, filter to * in-flight entries (status NOT IN { done, failed, cancelled, no-execution, * never-started, unreadable, stale }), and return the most-recent leaf role * plus the total in-flight count. Returns `{ role: null, pendingCount: 0 }` * when no session id resolves, the index is empty, or every entry is terminal. * * READ-ONLY: only reads `.peaks/_sub_agents//active-dispatches.json`. * Never mutates the on-disk record. */ export declare function readActiveLeaf(projectRoot: string, sessionId: string | null): StatusLineActiveLeaf | null; /** * Read-only compact state resolver. Resolves the canonical session id for the * detected project root, then delegates to {@link decideCompactStatusline}. * Returns `{ kind: 'none', filledCells: 0 }` when no project root is bound — * the renderer falls back to the C1 normal line in that case. */ export declare function readCompactState(projectRoot: string | null, nowMs: number): CompactStatuslineState;