import { type A2AApprovalStatus } from "./task-lifecycle.js"; import type { Task, Message, TaskState, Artifact } from "./types.js"; export declare const MAX_A2A_IDEMPOTENCY_KEY_CHARS = 128; export declare const A2A_PERSONAL_OWNER_SCOPE = "__personal__"; export declare const A2A_ORG_ID_OWNER_SCOPE_PREFIX = "__a2a_org_id__:"; export declare function a2aTaskLeaseThreadId(taskId: string): string; export declare const A2A_TASK_CLAIM_LOST_ERROR_CODE = "a2a_task_claim_lost"; /** * An `updateTask` write that tasks/cancel beat. The stored task stays * canceled; `task` is that row, so the caller can answer with it. */ export declare class A2ATaskCanceledError extends Error { readonly code = "a2a_task_canceled"; readonly task: Task; constructor(task: Task); } export interface A2ATaskListCursor { createdAt: number; id: string; } export declare const a2aTasksStore: import("../db/store-registry.js").Store; export declare function ensureTable(): Promise; export interface A2AApprovalRecord { id: string; taskId: string; ownerEmail: string; orgId: string | null; tool: string; input: unknown; approvalKey: string; callId: string; status: A2AApprovalStatus; result: string | null; expiresAt: number; } export declare function createA2AApproval(input: { taskId: string; ownerEmail: string; orgId?: string | null; tool: string; toolInput: unknown; approvalKey: string; callId: string; ttlMs?: number; }): Promise; export declare function getA2AApprovalForOwner(id: string, ownerEmail: string, orgId?: string | null): Promise; export declare function claimA2AApproval(id: string, ownerEmail: string, orgId?: string | null): Promise; export declare function settleA2AApproval(id: string, status: "completed" | "failed", resultText: string): Promise; export declare function pauseProcessingA2ATask(id: string, message: Message): Promise; export declare function createTask(message: Message, contextId?: string, metadata?: Record, ownerEmail?: string | null, ownerScope?: string | null): Promise; export declare function createOrReuseTask(message: Message, contextId: string | undefined, metadata: Record | undefined, ownerEmail: string | null, ownerScope: string | null, idempotencyKey: string | undefined): Promise<{ task: Task; reused: boolean; }>; export interface A2ATaskOwnership { ownerEmail: string | null; ownerScope: string | null; } export interface A2ATaskAccessScope { ownerEmail: string; ownerScope: string | null; } export declare function getTaskOwner(id: string): Promise; export declare function getTaskOwnership(id: string): Promise; export declare function claimA2ATaskForProcessing(id: string): Promise; export declare function getA2ATaskDispatchState(id: string): Promise<{ id: string; statusState: string; metadata: Record | undefined; updatedAt: number; createdAt: number; } | null>; export declare function touchQueuedA2ATaskDispatch(id: string): Promise; export declare function touchProcessingA2ATask(id: string): Promise; export declare function resetStuckA2ATaskForRetry(id: string, processingCutoff: number): Promise; export declare function failStuckA2ATask(id: string, processingCutoff: number, reason: string, createdAtCutoff?: number): Promise; export declare function failStuckQueuedA2ATask(id: string, createdAtCutoff: number, reason: string): Promise; /** Fail an abandoned task and revoke any worker lease in the same transaction. */ export declare function failStaleA2ATask(id: string, staleBefore: number, reason: string, errorCode: string): Promise; export declare function getTask(id: string, accessScope?: A2ATaskAccessScope): Promise; export declare function updateTask(id: string, update: { state?: TaskState; message?: Message; artifacts?: Artifact[]; }, accessScope?: A2ATaskAccessScope): Promise; /** * `not_found` covers both a missing task and one the access scope does not * reach, so callers cannot tell them apart. */ export type A2ATaskCancelResult = { status: "not_found"; } | { status: "not_cancelable"; state: TaskState; } | { status: "canceled"; task: Task; }; /** Cancel a task and revoke its worker generation in the same transaction. */ export declare function cancelA2ATask(id: string, accessScope?: A2ATaskAccessScope): Promise; /** * Persist the terminal result produced by the async processor, but only while * that processor still owns a task in `processing`. A tasks/get request may * fail an over-lifetime processor while its handler is still running; the * handler cannot be canceled reliably, so this compare-and-set is what keeps * its eventual completion (or error) from overwriting the timeout result. */ export declare function settleProcessingA2ATask(id: string, update: { state: "completed" | "failed"; message?: Message; artifacts?: Artifact[]; }): Promise; export declare function updateTaskStatusMessage(id: string, message: Message): Promise; export declare function listTasksPage(contextId?: string, options?: { limit?: number; before?: A2ATaskListCursor; }): Promise<{ tasks: Task[]; nextCursor: A2ATaskListCursor | null; }>; export declare function listTasks(contextId?: string): Promise;