import type { TaskRecord, TaskState, TaskOrigin, TaskTemplateRef, TaskOutcome, TaskMemberRole, TaskTerminalIntent, TaskDeletionActor, TaskDeletionMemberPhase } from './types.js'; export declare const tasksDir: () => string; export declare class TaskStateError extends Error { } /** * Accepted deletion is the per-task epoch guard: once pending, every lifecycle * mutation, terminal settlement, and room publication must fail boundedly. */ export declare function assertNoPendingDeletion(task: TaskRecord): void; export interface CreateTaskInput { title: string; brief?: string; brief_file?: string; template?: TaskTemplateRef; execution_plan?: TaskRecord['execution_plan']; origin: TaskOrigin; idempotency_key?: string; start?: boolean; no_room?: boolean; room_id?: string; listId?: string; } export declare function createTask(input: CreateTaskInput): TaskRecord; export declare function getTask(id: string): TaskRecord; export declare function updateTaskExecutionPlan(id: string, executionPlan: NonNullable): TaskRecord; export declare function listTasks(filter?: { state?: TaskState | TaskState[]; listId?: string; includeDeleting?: boolean; }): TaskRecord[]; export declare function moveTaskToList(id: string, listId: string): TaskRecord; export declare function findByIdempotencyKey(key: string): TaskRecord | undefined; export declare function startTask(id: string): TaskRecord; export declare function activateTask(id: string): TaskRecord; export declare function blockTask(id: string, reason: string): TaskRecord; export declare function unblockTask(id: string): TaskRecord; export declare function reviewTask(id: string): TaskRecord; export declare function completeTask(id: string, outcome?: TaskOutcome): TaskRecord; export declare function cancelTask(id: string): TaskRecord; /** Persist the first terminal request. Callers serialize this with the task-operation lock. */ export declare function beginTaskTerminalIntent(id: string, input: { kind: TaskTerminalIntent['kind']; roomId?: string; outcome?: TaskOutcome; }): TaskRecord; /** Record an actionable failure without claiming the requested terminal state. */ export declare function setTaskTerminalIntentError(id: string, error: string, recoveryHint: string): TaskRecord; /** Atomically publish the task terminal state and settled audit cursor. */ export declare function finishTaskTerminalIntent(id: string): TaskRecord; export declare function failTask(id: string, error: string): TaskRecord; export declare function updateTaskRoom(id: string, roomId: string, roomIdentityCid: string): TaskRecord; export declare function updateTaskTemplate(id: string, template: TaskTemplateRef): TaskRecord; export declare function updateTaskMembers(id: string, members: TaskMemberRole[]): TaskRecord; /** * Lenient read for deletion settlement and status surfaces: a broken list * reference must never make a task unreadable or undeletable. Missing records * throw the canonical task-not-found error; other read failures propagate. */ export declare function getDeletingTask(id: string): TaskRecord; /** Cheap durable deletion-epoch probe for room/member publication guards. */ export declare function taskDeletionState(id: string): 'none' | 'pending' | 'absent'; /** * Durable, surface-independent audit evidence for a permanent deletion. The * receipt outlives the task record: written with the acceptance intent, and * completed before settlement is reported. Metadata only — never brief or * room content. */ export interface TaskDeletionReceipt { schema_version: 1; task_id: string; title: string; accepted_at: string; actor: TaskDeletionActor; original_state: TaskState; room_id?: string; member_count: number; settled_at?: string; result?: 'deleted'; } export declare const deletionReceiptsDir: () => string; export declare function readTaskDeletionReceipt(id: string): TaskDeletionReceipt | undefined; /** * Ensure the acceptance receipt exists before any cleanup side effect, * backfilling it from the durable intent (heals a crash between the intent * write and the receipt write). Fails closed: a receipt write error aborts * settlement rather than deleting resources without audit evidence. */ export declare function ensureTaskDeletionReceipt(id: string): void; /** Record settlement on the receipt; idempotent, tolerant of legacy absence. */ export declare function completeTaskDeletionReceipt(id: string): void; export type TaskDeletionAcceptance = { status: 'accepted' | 'pending'; task: TaskRecord; } | { status: 'already_absent'; }; /** * Persist the first-wins durable deletion intent. Accepts every lifecycle * state, takes precedence over a pending terminal intent, and never touches * remote resources. Repeat requests while pending re-arm settlement; a request * for a missing record reports the idempotent already-absent outcome. * * Low-level record mutation only. Callers serialize acceptance with settlement * through deletion.ts, which holds the common task-operation lock. */ export declare function beginTaskDeletionIntent(id: string, actor: TaskDeletionActor): TaskDeletionAcceptance; /** Record an actionable settlement failure; the task stays hidden and recoverable. */ export declare function setTaskDeletionError(id: string, error: string, recoveryHint: string): TaskRecord; /** Marker proving a member never launched, mirroring close.ts's short path. */ export declare const DELETION_MEMBER_NEVER_LAUNCHED = "never-launched"; /** Marker proving absence verified against temp state AND the CID-wide identity scan. */ export declare const DELETION_MEMBER_ABSENT_VERIFIED = "absent-verified"; /** * Advance a member retirement cursor carried by the deletion intent. Only * adjacent forward transitions are legal — plus the explicit * pending → identity_absent short path proved by the 'never-launched' marker — * so no managed agent can be claimed retired without the full evidence chain. * launch_id and archive_path are immutable once recorded; same-phase retries * are idempotent but must not change evidence. */ export declare function advanceTaskDeletionMember(id: string, name: string, phase: TaskDeletionMemberPhase, launchId?: string, archivePath?: string): TaskRecord; interface SeatEvidence { role_name: string; identity_cid?: string; retirement?: { phase: TaskDeletionMemberPhase; launch_id: string; archive_path?: string; }; } /** * Durably register cursors for late-provisioned members before retirement * begins: provisioning publishes room seats before updateTaskMembers, so the * acceptance snapshot can be empty while live seats exist. Seats without a * recorded identity CID are not registered here — until a CID is recorded * there is no managed identity to orphan, and the room record still carries * those seats through the close saga that follows. */ export declare function upsertTaskDeletionMembersFromSeats(id: string, seats: ReadonlyArray): TaskRecord; /** * The pre-room-delete checkpoint: import completed retirement evidence from * room seats into the deletion cursors, so a crash between room-record * deletion and task unlink retries from durable cursors instead of * reconstructing consumed evidence. Call ONLY after closeManagedRoom has * completed retirement and BEFORE cowork.deleteRoom/deleteRoomRecord. * * The room saga is trusted for phase jumps, but partial or corrupt retained * records must not become false success: every seat must be identity_absent; * a real launch requires archive evidence; an identity-less seat is accepted * only via the never-launched proof. */ export declare function importTaskDeletionRetirementEvidence(id: string, seats: ReadonlyArray): TaskRecord; /** * Physically remove a deletion-pending task record. Settlement-only: callers * must have completed member retirement and room cleanup first. Missing * records are the idempotent already-settled outcome. */ export declare function unlinkDeletedTask(id: string): boolean; export {};