import { type Database } from "./database.js"; /** * A scheduled run whose own turn (`session_turns.scheduled_task_run_id`) is * waiting on a person: a pending tool approval or structured human-input * request. Projected at read time from durable turn/event facts; nothing is * stored, so the run row stays `dispatched` exactly as its lifecycle requires. * * `since` is when the current unanswered wait began: the first * `session.requiresAction` of this turn after the latest response that was not * the scheduler's own timeout rejection. A person's decision therefore restarts * the clock, while the scheduler rejecting several queued approvals one by one * does not (each would otherwise get a fresh full timeout). * * `expiresAt` is `since` plus the task's frozen `agentConfig.approvalTimeoutSeconds` * from the run's accepted execution; null when the task sets no timeout. */ export type ScheduledRunHumanWait = { runId: string; turnId: string; sessionId: string; since: string; expiresAt: string | null; timeoutSeconds: number | null; }; /** Client event id prefix of the scheduler's own timeout decisions. */ export declare const SCHEDULED_HUMAN_WAIT_TIMEOUT_CLIENT_EVENT_PREFIX = "system:scheduled-approval-timeout:"; /** * Human waits of scheduled runs, selected either by run ids or by one exact * turn. Runs must be scheduled-task runs of this workspace. Caller supplies * the RLS-scoped handle. */ export declare function scheduledRunHumanWaitsInRlsContext(scopedDb: Database, workspaceId: string, filter: { runIds: readonly string[]; } | { turnId: string; }): Promise; /** Read-time projection for run listings: run id -> its current human wait. */ export declare function listScheduledRunHumanWaits(db: Database, workspaceId: string, runIds: readonly string[]): Promise>; export type ScheduledTaskHumanWaitAttentionRow = ScheduledRunHumanWait & { taskId: string; taskName: string; taskExecutionDigest: string; firedAt: string; }; /** * Active agent schedules (owned by `subjectId`, or ownerless when allowed) * whose latest run with a turn is waiting on a person right now. */ export declare function listScheduledTaskHumanWaitAttention(db: Database, workspaceId: string, input: { subjectId: string; includeOwnerless: boolean; taskLimit: number; }): Promise;