import type { DatabaseSync } from 'node:sqlite'; /** Local dispatch only. These IDs must be resolved by the authenticated host, not by message text. */ export interface CodexDispatchScope { ownerId: number; teamRef: string; sourceId: string; } export interface CodexDispatchTarget extends CodexDispatchScope { taskId: string; threadId: string; } export type CodexDispatchState = 'pending' | 'preparing' | 'waiting' | 'submitting' | 'queued_confirmed' | 'accepted_confirmed' | 'unknown' | 'cancelled' | 'expired'; export type CodexDispatchWaitReason = 'permission_required' | 'locked' | 'codex_unavailable' | 'draft_present' | 'user_active' | 'target_unavailable' | 'executor_restarted'; export interface CodexDispatchRequest extends CodexDispatchTarget { requestId: string; text: string; delivery: 'queue'; generation: string; state: CodexDispatchState; reason: string; createdAt: number; updatedAt: number; expiresAt: number; evidence: CodexDispatchEvidence | null; } /** Only an adapter correlating NEW native evidence to this attempt may construct this receipt. */ export interface CodexDispatchEvidence { requestId: string; threadId: string; kind: 'queue' | 'turn'; nativeId: string; } export interface CodexDispatchLease { request: CodexDispatchRequest; token: string; executorId: string; } /** * A private, durable LOCAL outbox, deliberately separate from activity upload and Codex's queue DB. * Not an authentication boundary: only a trusted host/companion may call these methods. * Use one private database per physical input executor. Multiple preview processes must share it * or hold an additional OS-level singleton lock before enabling a real adapter. */ export declare class CodexDispatchJournal { private readonly db; private readonly now; constructor(db: DatabaseSync, now?: () => number); private transaction; private control; private row; private update; private release; private checked; /** Must be reached through an explicit, local user control, never by enabling uploads. */ enable(scope: CodexDispatchScope): void; /** Revocation fences unstarted requests permanently, even if the user subsequently re-enables. */ revoke(scope: CodexDispatchScope): void; create(target: CodexDispatchTarget, requestId: string, text: string): CodexDispatchRequest; list(scope: CodexDispatchScope, taskId: string): CodexDispatchRequest[]; claim(scope: CodexDispatchScope, executorId: string): CodexDispatchLease | undefined; private authorizationFailure; wait(lease: CodexDispatchLease, reason: CodexDispatchWaitReason): void; /** The returned canonical request is the ONLY payload the adapter may submit. */ beginInput(lease: CodexDispatchLease): CodexDispatchRequest | undefined; /** Last-moment fence for the adapter, including between staging text and pressing send. */ canSubmit(lease: CodexDispatchLease): boolean; finish(lease: CodexDispatchLease, evidence: CodexDispatchEvidence | null): CodexDispatchRequest; /** * Caller MUST prove the named executor has stopped while holding the OS singleton lock. * No timeouts/lease expiry automatically reclaim an executor that could still press send. */ recoverStoppedExecutor(executorId: string): void; } //# sourceMappingURL=team-codex-dispatch-journal.d.ts.map