import type Database from 'better-sqlite3'; import { type JsonValue, type WorkflowDefinition, type WorkflowId, type WorkflowNodeOutput } from './model.js'; import { type ContinuationAttemptQuery } from './repository-continuation.js'; import { type WorkflowMutexNodeRun } from './repository-mutex.js'; import { WorkflowRepositoryError } from './repository-support.js'; import { type ResolvedEmployeeConfig, type WorkflowApprovalRecord, type WorkflowAttemptRecord, type WorkflowChildRunSummary, type WorkflowError, type WorkflowNodeRunRecord, type WorkflowNodeRunStatus, type WorkflowRunDetail, type WorkflowRunRecord, type WorkflowRunStatus } from './runtime.js'; export { WorkflowRepositoryError }; export interface CreateWorkflowInput { id: string; title: string; description?: string; } export interface DefinitionListQuery { cursor?: string; limit?: number; enabled?: boolean; retired?: boolean; } export interface CursorPage { items: T[]; nextCursor: string | null; } import type { WorkflowDefinitionSummary, WorkflowRunSummary } from './wire.js'; export type { WorkflowDefinitionSummary, WorkflowRunSummary }; export interface CreateRunInput { workflowId: string; input: Record; trigger: { nodeId: string; kind: 'manual' | 'schedule' | 'event' | 'todo-status' | 'workflow-call'; fireId?: string; payload: Record; }; idempotencyKey?: string; invocationSessionId?: string; } export interface RunListQuery { cursor?: string; limit?: number; status?: WorkflowRunStatus; triggerKind?: WorkflowRunRecord['trigger']['kind']; startedFrom?: string; startedTo?: string; text?: string; } export interface WorkflowRunTransaction { setRunStatus(status: WorkflowRunStatus, patch?: { cancelRequestedAt?: string; endedAt?: string; error?: WorkflowError; }): WorkflowRunRecord; setNodeStatus(nodeId: string, status: WorkflowNodeRunStatus, patch?: Partial>): WorkflowNodeRunRecord; createAttempt(input: { nodeId: string; resolvedConfig: ResolvedEmployeeConfig; input: JsonValue; promptText?: string; retryIdempotencyKey?: string; }): WorkflowAttemptRecord; settleAttempt(nodeId: string, attempt: number, patch: { status: 'running'; sessionId: string; } | { status: 'completed'; sessionId?: string; output: WorkflowNodeOutput; endedAt: string; } | { status: 'failed' | 'timed-out' | 'cancelled'; sessionId?: string; error: WorkflowError; endedAt: string; }): WorkflowAttemptRecord; setAttemptReminder(nodeId: string, attempt: number, patch: { remindersSent?: number; stopNudgesSent?: number; nextReminderAt?: string | null; extensions?: number; lastExtensionReason?: string | null; pendingOutputError?: string | null; lastProcessedTurn?: number; }): WorkflowAttemptRecord; putApproval(input: Omit): WorkflowApprovalRecord; } export declare class WorkflowRepository { private readonly db; private readonly now; private mutating; constructor(db: Database.Database, now?: () => string); private transactionStamp; private row; private requireDefinition; private requireMutable; private write; createDefinition(input: CreateWorkflowInput): WorkflowDefinition; getDefinition(id: string): WorkflowDefinition | null; listDefinitions(query: DefinitionListQuery): CursorPage; saveDefinition(definition: WorkflowDefinition, expectedRevision: number): WorkflowDefinition; setEnabled(id: string, enabled: boolean, expectedRevision: number): WorkflowDefinition; setRetired(id: string, retired: boolean, expectedRevision: number, at: string): WorkflowDefinition; duplicateDefinition(id: WorkflowId, input: { id: WorkflowId; title: string; }): WorkflowDefinition; createRun(input: CreateRunInput, frozenDefinition?: WorkflowDefinition): WorkflowRunRecord; getRun(workflowId: string, runId: string): WorkflowRunDetail | null; listRuns(workflowId: string, query: RunListQuery): CursorPage; findRunByIdempotency(workflowId: string, key: string): WorkflowRunRecord | null; findWorkflowCallByIdempotency(input: { workflowId: string; input: Record; caller: { workflowId: string; runId: string; nodeId: string; }; itemIndex?: number; todoId?: string; idempotencyKey: string; }): WorkflowRunRecord | null; mutateRun(runId: string, expectedRevision: number, mutation: (tx: WorkflowRunTransaction) => T): T; getAttempt(runId: string, nodeId: string, attempt: number): WorkflowAttemptRecord | null; listAttempts(runId: string, nodeId: string): WorkflowAttemptRecord[]; listChildRuns(parentRunId: string, nodeId: string): WorkflowChildRunSummary[]; findAttemptBySessionId(sessionId: string): WorkflowAttemptRecord | null; findContinuationAttempt(query: ContinuationAttemptQuery): WorkflowAttemptRecord | null; findAttemptByRetryKey(runId: string, key: string): WorkflowAttemptRecord | null; listRecoverableRuns(): WorkflowRunRecord[]; listMutexNodeRuns(): WorkflowMutexNodeRun[]; listDueWaits(now: string, limit: number): WorkflowNodeRunRecord[]; nextDueWait(): WorkflowNodeRunRecord | null; listDueReminders(now: string, limit: number): WorkflowAttemptRecord[]; nextDueReminder(): { runId: string; nodeId: string; attempt: number; nextReminderAt: string; } | null; nextDueTimeout(): string | null; } //# sourceMappingURL=repository.d.ts.map