export type WorkflowCategory = 'portrait' | 'video-social' | 'makeover' | 'cinematic' | 'music' | 'analysis' | 'custom' | 'other'; export type WorkflowStability = 'production' | 'beta' | 'experimental'; export type WorkflowVisibility = 'private' | 'public'; export interface WorkflowAuthor { userId: string; displayName: string; } export type WorkflowInputType = 'image' | 'audio' | 'video' | 'text' | 'number' | 'select' | 'boolean'; export interface WorkflowInput { name: string; type: WorkflowInputType; required: boolean; description: string; default?: unknown; options?: Array<{ value: string; label: string; }>; multiple?: { min: number; max: number; }; internal?: boolean; jsonSchema?: Record; } export interface WorkflowPreviewArtifact { stageId: string; label: string; mediaType: 'image' | 'video'; url: string; posterUrl?: string; } export interface WorkflowGraphLayout { nodes: Array<{ stageId: string; x: number; y: number; collapsed?: boolean; }>; edges?: Array<{ from: string; to: string; label?: string; }>; viewport?: { x: number; y: number; zoom: number; }; } export interface WorkflowTemplate { id: string; version: string; name: string; description: string; brief?: string; category: WorkflowCategory; stability: WorkflowStability; author: 'system' | WorkflowAuthor; visibility: WorkflowVisibility; inputs: WorkflowInput[]; stages: WorkflowStage[]; reviewFocus?: string[]; estimatedCredits?: { min: number; max: number; }; estimatedCapacityUnits?: { min: number; max: number; }; exposeToLLM: boolean; llmPriority?: number; graph?: WorkflowGraphLayout; thumbnailUrl?: string; previewArtifacts?: WorkflowPreviewArtifact[]; tags?: string[]; metadata?: Record; openMontageImport?: { sourceSchema: string; importedAt: number; unmappedStages?: string[]; unmappedTools?: string[]; }; createdAt: number | string; updatedAt: number | string; } export type WorkflowStage = FixedStage | InteractiveStage | BatchStage; export interface StageBase { id: string; label?: string; produces?: string[]; requiredArtifactsIn?: string[]; optionalArtifactsIn?: string[]; reviewFocus?: string[]; successCriteria?: string[]; checkpointRequired?: boolean; humanApprovalDefault?: boolean; condition?: StageCondition; onError?: 'stop' | 'continue' | 'skip' | 'retry_once'; subStages?: WorkflowStage[]; } export interface FixedStage extends StageBase { type: 'fixed'; tool: string; args: Record; } export interface InteractiveStage extends StageBase { type: 'interactive'; systemPrompt: string; allowedTools: string[]; userMessage?: string; skillRef?: string; } export interface BatchStage extends StageBase { type: 'batch'; overBinding: string; itemName: string; itemStage: FixedStage | InteractiveStage; concurrency?: number; partialExecutionEnabled: boolean; itemLabelTemplate?: string; maxAttemptsPerItem?: number; } export interface StageCondition { type: 'always' | 'if_success_of' | 'if_error_in' | 'if_artifact_exists' | 'expr'; stageId?: string; artifactName?: string; expression?: string; } export type ArtifactKind = 'image' | 'video' | 'audio' | 'model' | 'text' | 'structured'; export interface Artifact { name: string; kind: ArtifactKind; items: ArtifactItem[]; } export interface ArtifactItem { id: string; label?: string; versions: ArtifactVersion[]; selectedVersionId: string; locked?: boolean; metadata?: Record; status?: 'pending' | 'running' | 'ready' | 'failed'; progress?: number; workerName?: string; error?: string; } export interface ArtifactVersion { id: string; createdAt: number; url?: string; content?: string; generatedBy: { stageId: string; tool: string; args: Record; }; cost?: { spark?: number; sogni?: number; }; thumbnailUrl?: string; } export type RunState = 'draft' | 'running' | 'awaiting_input' | 'awaiting_checkpoint' | 'paused' | 'completed' | 'failed' | 'canceled'; export interface Run { id: string; workflowId: string; workflowSnapshot: WorkflowTemplate; state: RunState; inputs: Record; currentStageIndex: number; stages: StageExecution[]; artifacts: Record; chatSessionId?: string; createdAt: number; updatedAt: number; totalCostCredits?: number; staleStageIds: string[]; } export type StageExecutionState = 'pending' | 'running' | 'awaiting_checkpoint' | 'completed' | 'failed' | 'stale' | 'skipped'; export interface StageItemState { state: 'pending' | 'running' | 'ready' | 'failed'; artifactItemId: string; error?: string; } export interface StageExecution { stageId: string; state: StageExecutionState; startedAt?: number; completedAt?: number; error?: string; itemStates?: Record; } export type ToolExecutionProgress = Record; export type ExecutorEvent = { type: 'run_started'; run: Run; } | { type: 'stage_started'; stageIndex: number; stage: WorkflowStage; } | { type: 'stage_item_started'; stageIndex: number; itemId: string; index: number; } | { type: 'stage_item_progress'; stageIndex: number; itemId: string; progress: number; workerName?: string; toolProgress?: ToolExecutionProgress; } | { type: 'stage_item_completed'; stageIndex: number; itemId: string; version: ArtifactVersion; } | { type: 'stage_item_failed'; stageIndex: number; itemId: string; error: string; } | { type: 'stage_completed'; stageIndex: number; } | { type: 'stage_awaiting_checkpoint'; stageIndex: number; reviewFocus?: string[]; } | { type: 'stage_awaiting_interactive'; stageIndex: number; stage: InteractiveStage; } | { type: 'run_completed'; run: Run; } | { type: 'run_failed'; error: Error; run: Run; } | { type: 'run_paused'; run: Run; }; export type ResumeInput = { type: 'approve_checkpoint'; } | { type: 'redo_item'; artifactName: string; itemId: string; overrideArgs?: Record; } | { type: 'redo_stage'; stageId: string; overrideArgs?: Record; } | { type: 'lock_item'; artifactName: string; itemId: string; locked: boolean; } | { type: 'select_version'; artifactName: string; itemId: string; versionId: string; } | { type: 'jump_to_stage'; stageId: string; } | { type: 'interactive_complete'; stageId: string; result: string; producedArtifacts?: Record; } | { type: 'cancel'; }; export type SlotEventPhase = 'started' | 'progress' | 'completed' | 'failed' | 'retrying'; export interface SlotEvent> { phase: SlotEventPhase; stageId: string; stageIndex: number; itemId: string; index: number; attempt: number; toolProgress?: Progress; version?: ArtifactVersion; error?: string; } export type SlotEventReporter> = (event: SlotEvent) => void; export interface ValidationIssue { severity: 'error' | 'warning'; code: string; message: string; path?: string; } export interface ValidationResult { valid: boolean; issues: ValidationIssue[]; } export interface BindingContext { inputs: Record; artifacts: Record; item?: Record & { index: number; }; runtime?: { uploadedFiles?: Array>; }; run?: { id: string; state: RunState; }; } //# sourceMappingURL=types.d.ts.map