import { type EngineerEnvelope } from './contract.js'; /** * The answer inbox (T7) — the inbound mirror of the outbox spool. * * The relay long-poll delivers EVERY approved outbound envelope to the daemon, * answers included; the daemon writes `answer` envelopes here so a separate * process (`engineer ask`, and the wizard's child agent driving it via Bash) * can block on the reply. Plain files keep the T4 invariant intact: the asking * process needs no ek_ token and no network — the daemon owns both. * * Files are named `.json` so re-delivery is an idempotent * overwrite. Answers are never consumed on read (a timed-out ask can * `--resume` later); `pruneInbox` bounds growth instead. */ /** How the returned answer was matched to the question. */ export type AnswerCorrelation = 'in_reply_to' | 'heuristic'; export interface AnswerMatch { envelope: Extract; correlation: AnswerCorrelation; } /** Validate + atomically drop an answer envelope into the inbox. Returns the path. */ export declare function writeAnswerEnvelope(dir: string, envelope: unknown): string; /** Every well-formed answer, oldest-first by file mtime. Malformed files are skipped. */ export declare function readAnswerEnvelopes(dir: string): AnswerMatch['envelope'][]; /** * Find the answer to a question. Exact `in_reply_to` match wins. Fallback: the * support agent is PROMPTED to set in_reply_to but its tool schema leaves it * optional (flagged T2 follow-up), so an uncorrelated answer created after * `askedAfterTs` is offered too — labeled `heuristic` so the caller can treat * it with suspicion (concurrent questions could cross wires). */ export declare function findAnswerFor(dir: string, questionId: string, askedAfterTs?: string): AnswerMatch | null; export interface AwaitAnswerOptions { timeoutMs: number; /** Poll interval (test seam; default 500ms). */ pollMs?: number; /** Heuristic-fallback window start (ISO ts). Omit to require exact correlation. */ askedAfterTs?: string; sleep?: (ms: number) => Promise; } /** * Block until the question's answer lands in the inbox, or the deadline * passes. A plain poll (no fs.watch): waits are minutes-long and the interval * is sub-second, so watcher plumbing buys nothing but edge cases. */ export declare function awaitAnswer(dir: string, questionId: string, opts: AwaitAnswerOptions): Promise; /** Bound inbox growth: drop files older than 7 days, then oldest beyond 100. */ export declare function pruneInbox(dir: string, now?: number): void; //# sourceMappingURL=inbox.d.ts.map