import type { CapturedIntent, DecisionGate } from "@decionis/agent-safe-pipeline"; import type { EscalationHandoff } from "../service/EscalationResolver.js"; import type { InterceptedRequest } from "./InterceptedRequest.js"; /** One held request: everything a resume needs to ask the authority again and forward it once. */ export interface HeldEscalation { readonly captured: CapturedIntent; readonly request: InterceptedRequest; readonly decision: DecisionGate; readonly handoff: EscalationHandoff | null; readonly heldAt: string; readonly expiresAt: number; /** SHA-256 of the resume token handed to the caller whose request was held; the token itself is not kept. */ readonly resumeDigest: Buffer; } /** * Where a gateway keeps the requests it holds. A hold is put once, read by * the caller holding its resume token, and taken once: `claim` removes it * and returns it to exactly one caller, so a request is forwarded at most * once by this store; the authority's single-use grant is the backstop. */ export interface HoldStore { /** False when the store is full: the request is held in name only and cannot be resumed. */ put(intentId: string, entry: HeldEscalation): boolean; /** The live hold under an id; an expired one is removed and is absent. */ get(intentId: string): HeldEscalation | undefined; /** Removes the hold and returns it, to one caller only. */ claim(intentId: string): HeldEscalation | undefined; delete(intentId: string): void; /** Removes expired holds; returns how many are live. */ sweep(): number; /** Forgets what this process holds in memory; a durable store keeps its holds for the next process. */ close(): void; } /** The most holds one gateway keeps. */ export declare const MAX_HELD = 1000; /** Holds in this process's memory: lost on restart, and seen only by this replica. */ export declare class MemoryHoldStore implements HoldStore { private readonly clock; private readonly held; constructor(clock: () => number); put(intentId: string, entry: HeldEscalation): boolean; get(intentId: string): HeldEscalation | undefined; claim(intentId: string): HeldEscalation | undefined; delete(intentId: string): void; sweep(): number; close(): void; } /** Why a durable hold store cannot be used: the code, never the key or a path's contents. */ export declare class HoldStoreError extends Error { readonly code: "HOLD_KEY_UNREADABLE" | "HOLD_KEY_INVALID" | "HOLD_DIR_UNUSABLE"; constructor(code: "HOLD_KEY_UNREADABLE" | "HOLD_KEY_INVALID" | "HOLD_DIR_UNUSABLE"); } /** * Holds as files in a directory every replica of a gateway mounts: any * replica can resume a hold, and a restart or a reload loses none. Each file * is sealed with AES-256-GCM under a key read from a mounted file; the * associated data binds it to its scope (the tenant) and its intent id, so a * file copied to another tenant's directory or renamed to another intent does * not open. File names are digests of the intent id, never the id itself. * * A claim renames the file to a name only the claimant knows; the rename * succeeds for one caller and fails for every other, on one host or across * hosts sharing the directory. */ export declare class FileHoldStore implements HoldStore { private readonly dir; private readonly scope; private readonly clock; private readonly key; constructor(dir: string, keyFile: string, scope: string, clock: () => number); /** The key: 32 bytes, written base64 or base64url (whitespace ignored), or hex. */ static readKey(keyFile: string): Buffer; put(intentId: string, entry: HeldEscalation): boolean; get(intentId: string): HeldEscalation | undefined; claim(intentId: string): HeldEscalation | undefined; delete(intentId: string): void; sweep(): number; close(): void; /** A hold's file, opened and checked; expired, unreadable or forged files are removed. */ private open; private unseal; private aad; private path; private static expiresAt; private static olderThan; private static encode; private static decode; } //# sourceMappingURL=HoldStore.d.ts.map