import { atomicSaveJsonFile } from "./durable-json-file.js"; import { type ExecutorKind } from "./executors.js"; export declare const TERMINAL_DELEGATE_SEND_BINDING_SCHEMA = "agent-knock-knock/terminal-delegate-send-binding"; export declare const TERMINAL_DELEGATE_SEND_BINDING_VERSION = 1; export declare const TERMINAL_DELEGATE_SEND_BINDINGS_DIRECTORY = "terminal-delegate-send-bindings"; export declare class TerminalDelegateSendBindingConflictError extends Error { constructor(message: string); } export declare class TerminalDelegateSendBindingUncertainError extends Error { readonly possibleExistingBinding: boolean; constructor(message: string, options?: { cause?: unknown; possibleExistingBinding?: boolean; }); } /** Immutable caller scope for one omitted-target delegate request. */ export interface TerminalDelegateSendRequestBoundary { readonly messageId: string; readonly requestHash: string; readonly requestedWorkspace?: string; readonly requestedAgent?: ExecutorKind; readonly openclawSession?: string; } /** Exact physical target selected while the global message lock is held. */ export interface TerminalDelegateSendTargetBoundary { readonly terminalId: string; readonly workspace: string; readonly terminalRuntimeKey: string; readonly physicalToken: string; } /** Private immutable binding returned to delegate routing. */ export interface TerminalDelegateSendBinding extends TerminalDelegateSendRequestBoundary, TerminalDelegateSendTargetBoundary { readonly reservedAt: string; } export type TerminalDelegateSendBindResult = { outcome: "reserved" | "replay"; binding: TerminalDelegateSendBinding; }; export interface TerminalDelegateSendBindingRepository { pathFor(input: Pick): string; /** Hold the global same-message lock across load, discovery, and bind. */ acquire(messageId: string): () => void; load(boundary: TerminalDelegateSendRequestBoundary): TerminalDelegateSendBinding | undefined; /** Caller must hold acquire(boundary.messageId) until this returns. */ bind(boundary: TerminalDelegateSendRequestBoundary, target: TerminalDelegateSendTargetBoundary): TerminalDelegateSendBindResult; } interface TerminalDelegateSendBindingRepositoryOptions { runtimeDir: string | (() => string); now?: () => Date; ensureDirectory?: (directoryPath: string) => void; acquireLock?: (lockPath: string) => () => void; saveJson?: typeof atomicSaveJsonFile; } /** * Store-independent immutable routing for omitted-target Send. * * The message lock spans discovery because no terminal lock exists until a * target is chosen. The request body is never persisted. Once bound, retries * must return to the same physical/runtime boundary; the per-terminal Send * intent remains responsible for delivery replay versus uncertainty. */ export declare function createTerminalDelegateSendBindingRepository(options: TerminalDelegateSendBindingRepositoryOptions): TerminalDelegateSendBindingRepository; export {};