import { j as AICallLogger, k as CreateAICallInput, l as AIHelperStats, m as AICallRecord, J as JobQueue, E as EnqueueJobInput, D as DequeueResult, n as JobRecord, o as JobStatus, 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, h as CreateOutboxEventInput, O as OutboxRecord, s as SaveArtifactInput, t as WorkflowArtifactRecord, f as CreateAnnotationInput, A as AnnotationFilters, g as WorkflowAnnotationRecord, u as WorkflowLogRecord } from '../interface-DMzwv0lD.js'; /** * In-Memory AI Call Logger * * A complete in-memory implementation of AICallLogger for testing. * Tracks all AI calls with full cost/token tracking and topic-based aggregation. * * @example * ```typescript * import { InMemoryAICallLogger } from '@bratsos/workflow-engine/testing'; * * const aiLogger = new InMemoryAICallLogger(); * // Use in tests... * aiLogger.clear(); // Reset between tests * ``` */ declare class InMemoryAICallLogger implements AICallLogger { private calls; private recordedBatches; /** * Log a single AI call (fire and forget) */ 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; /** * Clear all data - useful between tests */ clear(): void; /** * Get all calls for inspection */ getAllCalls(): AICallRecord[]; /** * Get calls by topic for inspection */ getCallsByTopic(topic: string): AICallRecord[]; /** * Get calls by topic prefix for inspection */ getCallsByTopicPrefix(prefix: string): AICallRecord[]; /** * Get calls by model for inspection */ getCallsByModel(modelKey: string): AICallRecord[]; /** * Get calls by call type for inspection */ getCallsByType(callType: string): AICallRecord[]; /** * Get total cost across all calls */ getTotalCost(): number; /** * Get total tokens across all calls */ getTotalTokens(): { input: number; output: number; }; /** * Get call count */ getCallCount(): number; /** * Get all recorded batch IDs */ getRecordedBatchIds(): string[]; /** * Get the last call made (useful for assertions) */ getLastCall(): AICallRecord | null; /** * Assert a call was made with specific properties */ hasCallMatching(predicate: (call: AICallRecord) => boolean): boolean; } /** * In-Memory Job Queue * * A complete in-memory implementation of JobQueue for testing. * Supports priority ordering, locking, and stale job recovery. * * @example * ```typescript * import { InMemoryJobQueue } from '@bratsos/workflow-engine/testing'; * * const jobQueue = new InMemoryJobQueue(); * // Use in tests... * jobQueue.clear(); // Reset between tests * ``` */ declare class InMemoryJobQueue implements JobQueue { private jobs; private workerId; private defaultMaxAttempts; constructor(workerId?: string); enqueue(options: EnqueueJobInput): Promise; enqueueParallel(jobs: EnqueueJobInput[]): Promise; dequeue(): Promise; complete(jobId: string): Promise; suspend(jobId: string, nextPollAt: Date): Promise; fail(jobId: string, error: string, shouldRetry?: boolean): Promise; getSuspendedJobsReadyToPoll(): Promise>; releaseStaleJobs(staleThresholdMs?: number): Promise; cancelByRun(workflowRunId: string): Promise; /** * Clear all jobs - useful between tests */ clear(): void; /** * Get all jobs for inspection */ getAllJobs(): JobRecord[]; /** * Get jobs by status for inspection */ getJobsByStatus(status: JobStatus): JobRecord[]; /** * Get a specific job by ID */ getJob(jobId: string): JobRecord | null; /** * Get the worker ID for this queue instance */ getWorkerId(): string; /** * Set max attempts for new jobs */ setDefaultMaxAttempts(maxAttempts: number): void; /** * Simulate a worker crash by releasing a job's lock without completing it */ simulateCrash(jobId: string): void; /** * Move a suspended job back to pending (for manual resume testing) */ resumeJob(jobId: string): void; /** * Set lockedAt for testing stale job scenarios */ setJobLockedAt(jobId: string, lockedAt: Date): void; /** * Set nextPollAt for testing suspended job polling */ setJobNextPollAt(jobId: string, nextPollAt: Date | null): void; } /** * In-Memory Workflow Persistence * * A complete in-memory implementation of WorkflowPersistence for testing. * All data is stored in Maps and lost when the instance is garbage collected. * * @example * ```typescript * import { InMemoryWorkflowPersistence } from '@bratsos/workflow-engine/testing'; * * const persistence = new InMemoryWorkflowPersistence(); * // Use in tests... * persistence.clear(); // Reset between tests * ``` */ declare class InMemoryWorkflowPersistence implements WorkflowPersistence { private runs; private stages; private logs; private artifacts; private annotations; private outbox; private idempotencyKeys; private idempotencyInProgress; private outboxSequences; private stageKey; private artifactKey; private idempotencyCompositeKey; 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; createStage(data: CreateStageInput): Promise; upsertStage(data: UpsertStageInput): Promise; updateStage(id: string, data: UpdateStageInput): Promise; updateStageByRunAndStageId(workflowRunId: string, stageId: string, data: UpdateStageInput): Promise; 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; 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; 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; saveStageOutput(runId: string, workflowType: string, stageId: string, output: unknown): Promise; /** * Clear all data - useful between tests */ clear(): void; /** * Get all runs for inspection */ getAllRuns(): WorkflowRunRecord[]; /** * Get all stages for inspection */ getAllStages(): WorkflowStageRecord[]; /** * Get all logs for inspection */ getAllLogs(): WorkflowLogRecord[]; /** * Get all artifacts for inspection */ getAllArtifacts(): WorkflowArtifactRecord[]; /** * Get all annotations for inspection */ getAllAnnotations(): WorkflowAnnotationRecord[]; } export { InMemoryAICallLogger, InMemoryJobQueue, InMemoryWorkflowPersistence };