import { j as AICallLogger, k as CreateAICallInput, l as AIHelperStats, p as WorkflowPersistence, C as CreateRunInput, W as WorkflowRunRecord, U as UpdateRunInput, q as WorkflowStatus, a as CreateStageInput, b as WorkflowStageRecord, c as UpsertStageInput, d as UpdateStageInput, r as WorkflowStageStatus, e as CreateLogInput, s as SaveArtifactInput, t as WorkflowArtifactRecord, f as CreateAnnotationInput, A as AnnotationFilters, g as WorkflowAnnotationRecord, h as CreateOutboxEventInput, O as OutboxRecord, J as JobQueue, E as EnqueueJobInput, D as DequeueResult } from './interface-DMzwv0lD.js'; /** * PrismaAICallLogger - Prisma implementation of AICallLogger * * Handles AI call logging to the database. Uses fire-and-forget pattern * for non-blocking logging during AI operations. */ type PrismaClient$2 = any; declare class PrismaAICallLogger implements AICallLogger { private readonly prisma; constructor(prisma: PrismaClient$2); /** * Log a single AI call (fire and forget) * Does not await - logs asynchronously to avoid blocking AI operations */ logCall(call: CreateAICallInput): void; /** * Log batch results (for recording batch API results) */ logBatchResults(batchId: string, results: CreateAICallInput[]): Promise; /** * Get aggregated stats for a topic prefix */ getStats(topicPrefix: string): Promise; /** * Check if batch results are already recorded */ isRecorded(batchId: string): Promise; } declare function createPrismaAICallLogger(prisma: PrismaClient$2): AICallLogger; /** * PrismaWorkflowPersistence - Prisma implementation of WorkflowPersistence * * This is the default persistence implementation used by the workflow engine. * It wraps Prisma client operations to match the WorkflowPersistence interface. */ type PrismaClient$1 = any; type DatabaseType = "postgresql" | "sqlite"; interface PrismaWorkflowPersistenceOptions { /** * Database type. Defaults to "postgresql". * Set to "sqlite" when using SQLite (uses optimistic locking instead of FOR UPDATE SKIP LOCKED). */ databaseType?: DatabaseType; /** * Skip interactive transactions. Defaults to false. * Set to true in single-process environments where transactions are not needed. */ skipInteractiveTransactions?: boolean; } declare class PrismaWorkflowPersistence implements WorkflowPersistence { private readonly prisma; private enums; private databaseType; private skipTransactions; constructor(prisma: PrismaClient$1, options?: PrismaWorkflowPersistenceOptions); withTransaction(fn: (tx: WorkflowPersistence) => Promise): Promise; createRun(data: CreateRunInput): Promise; updateRun(id: string, data: UpdateRunInput): Promise; getRun(id: string): Promise; getRunStatus(id: string): Promise; getRunsByStatus(status: WorkflowStatus): Promise; getStuckRuns(stuckSince: Date): Promise; claimPendingRun(id: string): Promise; claimNextPendingRun(): Promise; /** * PostgreSQL implementation using FOR UPDATE SKIP LOCKED for zero-contention claiming. * This atomically: * 1. Finds the highest priority PENDING run (FIFO within same priority) * 2. Locks it exclusively (other workers skip locked rows) * 3. Updates it to RUNNING * 4. Returns the claimed run */ private claimNextPendingRunPostgres; /** * SQLite implementation using optimistic locking. * SQLite doesn't support FOR UPDATE SKIP LOCKED, so we use a two-step approach: * 1. Find a PENDING run * 2. Atomically update it (only succeeds if still PENDING) * 3. If another worker claimed it, retry */ private claimNextPendingRunSqlite; createStage(data: CreateStageInput): Promise; upsertStage(data: UpsertStageInput): Promise; updateStage(id: string, data: UpdateStageInput): Promise; updateStageByRunAndStageId(workflowRunId: string, stageId: string, data: UpdateStageInput): Promise; private buildRunUpdateData; private buildStageUpdateData; getStage(runId: string, stageId: string): Promise; getStageById(id: string): Promise; getStagesByRun(runId: string, options?: { status?: WorkflowStageStatus; orderBy?: "asc" | "desc"; }): Promise; getSuspendedStages(beforeDate: Date): Promise; getFirstSuspendedStageReadyToResume(runId: string): Promise; getFirstFailedStage(runId: string): Promise; getLastCompletedStage(runId: string): Promise; getLastCompletedStageBefore(runId: string, executionGroup: number): Promise; deleteStage(id: string): Promise; createLog(data: CreateLogInput): Promise; saveArtifact(data: SaveArtifactInput): Promise; loadArtifact(runId: string, key: string): Promise; hasArtifact(runId: string, key: string): Promise; deleteArtifact(runId: string, key: string): Promise; listArtifacts(runId: string): Promise; getStageIdForArtifact(runId: string, stageId: string): Promise; appendAnnotations(inputs: CreateAnnotationInput[]): Promise; listAnnotations(workflowRunId: string, filters?: AnnotationFilters): Promise; private mapWorkflowAnnotation; saveStageOutput(runId: string, workflowType: string, stageId: string, output: unknown): Promise; appendOutboxEvents(events: CreateOutboxEventInput[]): Promise; getUnpublishedOutboxEvents(limit?: number): Promise; markOutboxEventsPublished(ids: string[]): Promise; incrementOutboxRetryCount(id: string): Promise; moveOutboxEventToDLQ(id: string): Promise; replayDLQEvents(maxEvents: number): Promise; acquireIdempotencyKey(key: string, commandType: string): Promise<{ status: "acquired"; } | { status: "replay"; result: unknown; } | { status: "in_progress"; }>; completeIdempotencyKey(key: string, commandType: string, result: unknown): Promise; releaseIdempotencyKey(key: string, commandType: string): Promise; private mapWorkflowRun; private mapWorkflowStage; private mapOutboxEvent; private mapWorkflowArtifact; } /** * Factory function to create PrismaWorkflowPersistence */ declare function createPrismaWorkflowPersistence(prisma: PrismaClient$1, options?: PrismaWorkflowPersistenceOptions): PrismaWorkflowPersistence; /** * PrismaJobQueue - Prisma implementation of JobQueue * * Provides atomic job queue operations using PostgreSQL * with FOR UPDATE SKIP LOCKED for safe concurrent access. * * This is migrated from the original services/job-queue.server.ts */ type PrismaClient = any; interface PrismaJobQueueOptions { /** * Unique worker identifier. Defaults to auto-generated ID. */ workerId?: string; /** * Database type. Defaults to "postgresql". * Set to "sqlite" when using SQLite (uses optimistic locking instead of FOR UPDATE SKIP LOCKED). */ databaseType?: DatabaseType; } declare class PrismaJobQueue implements JobQueue { private workerId; private prisma; private enums; private databaseType; constructor(prisma: PrismaClient, options?: PrismaJobQueueOptions); /** * Add a new job to the queue */ enqueue(options: EnqueueJobInput): Promise; /** * Enqueue multiple stages in parallel (same execution group) */ enqueueParallel(jobs: EnqueueJobInput[]): Promise; /** * Atomically dequeue the next available job * Uses FOR UPDATE SKIP LOCKED (PostgreSQL) or optimistic locking (SQLite) */ dequeue(): Promise; /** * PostgreSQL implementation using FOR UPDATE SKIP LOCKED for safe concurrency */ private dequeuePostgres; /** * SQLite implementation using optimistic locking. * SQLite doesn't support FOR UPDATE SKIP LOCKED, so we use a two-step approach: * 1. Find a PENDING job * 2. Atomically update it (only succeeds if still PENDING) * 3. If another worker claimed it, retry */ private dequeueSqlite; /** * Mark job as completed */ complete(jobId: string): Promise; /** * Mark job as suspended (for async-batch) */ suspend(jobId: string, nextPollAt: Date): Promise; /** * Mark job as failed */ fail(jobId: string, error: string, shouldRetry?: boolean): Promise; /** * Get suspended jobs that are ready to be checked */ getSuspendedJobsReadyToPoll(): Promise>; /** * Cancel all pending/suspended jobs for a workflow run. */ cancelByRun(workflowRunId: string): Promise; /** * Release stale locks (for crashed workers) */ releaseStaleJobs(staleThresholdMs?: number): Promise; } /** * Factory function to create PrismaJobQueue with prisma client * * @param prisma - Prisma client instance * @param optionsOrWorkerId - Options object or workerId string (for backwards compatibility) */ declare function createPrismaJobQueue(prisma: PrismaClient, optionsOrWorkerId?: PrismaJobQueueOptions | string): JobQueue; export { type DatabaseType as D, PrismaAICallLogger as P, PrismaJobQueue as a, type PrismaJobQueueOptions as b, PrismaWorkflowPersistence as c, type PrismaWorkflowPersistenceOptions as d, createPrismaAICallLogger as e, createPrismaJobQueue as f, createPrismaWorkflowPersistence as g };