import type { NextStepDirective, PauseUntilSignalDirective, AgentManifest } from '@sapiom/agent'; import type { ExecutionState, StepRow } from './execution-state.js'; export interface StartExecutionArgs { readonly workflowName: string; readonly organizationId: string | null; readonly tenantId: string | null; readonly input: unknown; readonly entryStep: string; readonly entryStepInput: unknown; readonly idempotencyKey?: string; readonly manifest: AgentManifest; readonly definitionId?: string | null; readonly buildRunId?: string | null; readonly scopedApiKeyId?: string | null; } export interface ExecutionStore { startExecution(args: StartExecutionArgs): Promise; loadExecution(executionId: string): Promise; prepareResume(args: { executionId: string; fromStepName: string; fromStepInput: unknown; }): Promise; nextStepOrder(executionId: string): Promise; startStep(args: { executionId: string; stepName: string; stepOrder: number; attempt: number; input: unknown; status: 'dispatched' | 'running'; }): Promise; findStepRow(executionId: string, stepOrder: number, attempt: number): Promise; findStepRowById(stepRowId: string): Promise; completeStep(args: { stepRowId: string; output: unknown; nextDirective: NextStepDirective; sharedStateAfter: Record; logs?: unknown; }): Promise; failStep(args: { stepRowId: string; error: unknown; sharedStateAfter: Record; logs?: unknown; }): Promise; failActiveDispatchedStep?(args: { executionId: string; expectedVersion: number; stepRowId: string; error: unknown; sharedState: Record; logs?: unknown; }): Promise; markStepDispatched(args: { executionId: string; expectedVersion: number; stepRowId: string; deadlineAt: Date; }): Promise; transitionToStep(args: { executionId: string; expectedVersion: number; nextStep: string; nextStepInput: unknown; sharedState: Record; }): Promise; retainStepForRetry(args: { executionId: string; expectedVersion: number; sharedState: Record; }): Promise; pauseExecution(args: { executionId: string; expectedVersion: number; directive: PauseUntilSignalDirective; sharedState: Record; }): Promise; completeExecution(args: { executionId: string; expectedVersion: number; output: unknown; sharedState: Record; }): Promise; failExecution(args: { executionId: string; expectedVersion: number; error: unknown; output?: unknown; sharedState: Record; }): Promise; } export interface SpanSpec { readonly name: string; readonly attributes?: Record; } export interface RuntimeObserver { withSpan(span: SpanSpec, fn: () => Promise): Promise; count(metric: { name: string; attributes?: Record; }): void; onTerminal?(executionId: string, kind: 'completed' | 'failed'): Promise; openRun?(args: { executionId: string; workflowName: string; tenantId: string; }): Promise; openStep?(args: { executionId: string; stepName: string; stepRowId: string; tenantId: string; }): Promise; completeStep?(args: { stepRowId: string; outcome: 'success' | 'error'; }): Promise; completeRun?(args: { executionId: string; outcome: 'success' | 'error'; }): Promise; } export declare const NOOP_OBSERVER: RuntimeObserver; export interface RuntimeAnalytics { track(eventType: string, data?: Record): void; }