import { type BackendRecoveryFields, type BackendRetryFields } from "./backend-task-recovery.js"; import { type CallbackAttemptOutcome, type CallbackEnvelopeV1, type CallbackRouteV1 } from "./callback-transport.js"; import type { DesktopAsyncInteraction, DesktopInteraction, DesktopThreadIdentity } from "./desktop-types.js"; export declare const DESKTOP_TASKS_DIRECTORY = "desktop-tasks"; export type DesktopTaskStatus = "awaiting_acceptance" | "watching" | "completed" | "failed" | "interrupted" | "timed_out" | "cancelled"; export interface DesktopSendIntent { message_id: string; client_user_message_id: string; text: string; owner_client_id: string; baseline_turn_ids: string[]; state: "reserved" | "uncertain" | "accepted" | "not_sent"; dispatched_at: string; receipt_turn_id?: string; error_code?: string; } export interface DesktopNotification extends BackendRetryFields { id: string; envelope: CallbackEnvelopeV1; status: "ready" | "leased" | "retry_wait" | "accepted" | "failed" | "uncertain"; attempts: number; attempt_id?: string; lease_expires_at?: string; retry_at?: string; outcome?: CallbackAttemptOutcome; } export interface DesktopTaskRecord extends BackendRecoveryFields { schema: "agent-knock-knock/desktop-task"; version: 1; revision: number; id: string; watch_id: string; desktop_id: string; target: DesktopThreadIdentity; controller_session: string; kind: "send" | "watch"; status: DesktopTaskStatus; created_at: string; updated_at: string; deadline_at: string; native_turn_id?: string; send_intent?: DesktopSendIntent; callback_route?: CallbackRouteV1; observed_at?: string; observation_error?: string; pending_manual_count: number; pending_manual_fingerprint?: string; /** Older v1 records omit this field; absence means no observed async questions. */ pending_async_interactions?: DesktopAsyncInteraction[]; /** All executable interactions; old async-only records remain readable. */ pending_interactions?: DesktopInteraction[]; final_text?: string; notifications: DesktopNotification[]; } export interface DesktopStateScan { tasks: DesktopTaskRecord[]; errors: { id: string; error_code: "desktop_record_invalid"; }[]; } export interface DesktopStateRepository { load(id: string): DesktopTaskRecord | undefined; list(): DesktopTaskRecord[]; scanForReconciliation(): DesktopStateScan; save(record: DesktopTaskRecord, expectedRevision: number | null): DesktopTaskRecord; withLock(id: string, operation: () => T): T; } export declare function assertDesktopTaskRecord(value: unknown): asserts value is DesktopTaskRecord; export declare function createDesktopStateStore(storeDir: string, locks: { acquire(lockPath: string): () => void; }): DesktopStateRepository;