@prompd/core 0.5.0-beta.18 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1531,7 +1531,17 @@ interface ParallelNodeData extends BaseNodeData {
1531
1531
  /** Custom labels for fork branches (indexed by branch number) */
1532
1532
  forkLabels?: string[];
1533
1533
  branches: ParallelBranch[];
1534
- waitFor: 'all' | 'any' | 'race';
1534
+ /**
1535
+ * all: every branch settles (fails only if all fail). race: first to settle wins.
1536
+ * any: first success wins. quorum: quorumCount successes win. Losers are cancelled.
1537
+ */
1538
+ waitFor: 'all' | 'any' | 'race' | 'quorum';
1539
+ /** Successes required when waitFor is 'quorum' (default 1). */
1540
+ quorumCount?: number;
1541
+ /** Branches running at once (default 4). */
1542
+ maxConcurrency?: number;
1543
+ /** Per-branch timeout in ms; unset or 0 = none. A timeout counts as a failure. */
1544
+ branchTimeoutMs?: number;
1535
1545
  mergeStrategy: 'object' | 'array' | 'first';
1536
1546
  /** Whether the container is collapsed (hides child nodes) */
1537
1547
  collapsed?: boolean;
@@ -3055,4 +3065,75 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
3055
3065
  */
3056
3066
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
3057
3067
 
3058
- export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolDeployHook, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
3068
+ /**
3069
+ * Parallel branch execution shared by every Prompd workflow engine (CLI + browser).
3070
+ *
3071
+ * runBranches schedules N branches under a wait policy and a concurrency limit,
3072
+ * aborts the branches that lose, and reports each branch's outcome in BRANCH
3073
+ * order. It knows nothing about nodes: the caller supplies how one branch runs.
3074
+ * traceForkBranches/forkJoinId derive fork-mode branches from a workflow's edges.
3075
+ */
3076
+
3077
+ type BranchWaitFor = 'all' | 'any' | 'race' | 'quorum';
3078
+ type BranchMergeStrategy = 'object' | 'array' | 'first';
3079
+ type BranchStatus = 'ok' | 'error' | 'cancelled' | 'timeout';
3080
+ interface BranchSpec {
3081
+ /** Stable key used by the `object` merge strategy. */
3082
+ key: string;
3083
+ label: string;
3084
+ /** Node ids in execution order. Empty for a branch that passes input straight to the join. */
3085
+ nodeIds: string[];
3086
+ }
3087
+ interface BranchResult<T = unknown> {
3088
+ key: string;
3089
+ label: string;
3090
+ status: BranchStatus;
3091
+ output?: T;
3092
+ error?: string;
3093
+ ms: number;
3094
+ }
3095
+ interface RunBranchesOptions {
3096
+ waitFor: BranchWaitFor;
3097
+ /** Successes required for `quorum` (clamped to 1..branches.length). */
3098
+ quorumCount?: number;
3099
+ /** Branches running at once (default DEFAULT_MAX_CONCURRENCY, minimum 1). */
3100
+ maxConcurrency?: number;
3101
+ /** Per-branch timeout in ms; unset or <= 0 means none. */
3102
+ timeoutMs?: number;
3103
+ /** Aborting it cancels every unfinished branch and resolves with ok: false. */
3104
+ signal?: AbortSignal;
3105
+ now?: () => number;
3106
+ }
3107
+ interface RunBranchesOutcome<T = unknown> {
3108
+ ok: boolean;
3109
+ /** One entry per branch, in branch order. */
3110
+ results: BranchResult<T>[];
3111
+ /** The results the wait policy chose (see runBranches). */
3112
+ selected: BranchResult<T>[];
3113
+ error?: string;
3114
+ }
3115
+ type BranchRunner<T> = (branch: BranchSpec, signal: AbortSignal) => Promise<T>;
3116
+ declare const DEFAULT_MAX_CONCURRENCY = 4;
3117
+ /**
3118
+ * Run branches concurrently and settle by `waitFor`:
3119
+ * - all: every branch settles; ok unless all failed; selected = all results.
3120
+ * - race: the first branch to settle (ok or not) decides; selected = [it].
3121
+ * - any: the first success decides; fails once all failed; selected = [it] | [].
3122
+ * - quorum: quorumCount successes decide; fails once unreachable; selected = those, branch order.
3123
+ * Resolves as soon as the decision is made: losers are aborted, never awaited,
3124
+ * and anything they return later is ignored.
3125
+ */
3126
+ declare function runBranches<T>(branches: BranchSpec[], run: BranchRunner<T>, opts: RunBranchesOptions): Promise<RunBranchesOutcome<T>>;
3127
+ /** Combine the selected results. Shapes match the CLI engine's historical output. */
3128
+ declare function mergeBranchResults<T>(outcome: RunBranchesOutcome<T>, strategy: BranchMergeStrategy): unknown;
3129
+ /**
3130
+ * Fork-mode branches of a parallel node, derived from edges: each `fork-<i>`
3131
+ * out-edge starts branch i, which follows execution edges forward until a
3132
+ * `merge` node or an edge into an `input-<i>` join handle. Labels come from
3133
+ * data.forkLabels (default "Branch N"); duplicates are suffixed so every key is unique.
3134
+ */
3135
+ declare function traceForkBranches(file: WorkflowFile, parallelId: string): BranchSpec[];
3136
+ /** The node a fork-mode parallel's branches rejoin at (target of an `input-*` edge). */
3137
+ declare function forkJoinId(file: WorkflowFile, parallelId: string): string | undefined;
3138
+
3139
+ export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, type BranchMergeStrategy, type BranchResult, type BranchRunner, type BranchSpec, type BranchStatus, type BranchWaitFor, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_MAX_CONCURRENCY, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type RunBranchesOptions, type RunBranchesOutcome, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolDeployHook, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, forkJoinId, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, mergeBranchResults, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, runBranches, serializeWorkflow, stripFilePath, traceForkBranches, uninstallPackage, validateWorkflow, validateWorkflowQuick };
package/dist/index.d.ts CHANGED
@@ -1531,7 +1531,17 @@ interface ParallelNodeData extends BaseNodeData {
1531
1531
  /** Custom labels for fork branches (indexed by branch number) */
1532
1532
  forkLabels?: string[];
1533
1533
  branches: ParallelBranch[];
1534
- waitFor: 'all' | 'any' | 'race';
1534
+ /**
1535
+ * all: every branch settles (fails only if all fail). race: first to settle wins.
1536
+ * any: first success wins. quorum: quorumCount successes win. Losers are cancelled.
1537
+ */
1538
+ waitFor: 'all' | 'any' | 'race' | 'quorum';
1539
+ /** Successes required when waitFor is 'quorum' (default 1). */
1540
+ quorumCount?: number;
1541
+ /** Branches running at once (default 4). */
1542
+ maxConcurrency?: number;
1543
+ /** Per-branch timeout in ms; unset or 0 = none. A timeout counts as a failure. */
1544
+ branchTimeoutMs?: number;
1535
1545
  mergeStrategy: 'object' | 'array' | 'first';
1536
1546
  /** Whether the container is collapsed (hides child nodes) */
1537
1547
  collapsed?: boolean;
@@ -3055,4 +3065,75 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
3055
3065
  */
3056
3066
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
3057
3067
 
3058
- export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolDeployHook, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
3068
+ /**
3069
+ * Parallel branch execution shared by every Prompd workflow engine (CLI + browser).
3070
+ *
3071
+ * runBranches schedules N branches under a wait policy and a concurrency limit,
3072
+ * aborts the branches that lose, and reports each branch's outcome in BRANCH
3073
+ * order. It knows nothing about nodes: the caller supplies how one branch runs.
3074
+ * traceForkBranches/forkJoinId derive fork-mode branches from a workflow's edges.
3075
+ */
3076
+
3077
+ type BranchWaitFor = 'all' | 'any' | 'race' | 'quorum';
3078
+ type BranchMergeStrategy = 'object' | 'array' | 'first';
3079
+ type BranchStatus = 'ok' | 'error' | 'cancelled' | 'timeout';
3080
+ interface BranchSpec {
3081
+ /** Stable key used by the `object` merge strategy. */
3082
+ key: string;
3083
+ label: string;
3084
+ /** Node ids in execution order. Empty for a branch that passes input straight to the join. */
3085
+ nodeIds: string[];
3086
+ }
3087
+ interface BranchResult<T = unknown> {
3088
+ key: string;
3089
+ label: string;
3090
+ status: BranchStatus;
3091
+ output?: T;
3092
+ error?: string;
3093
+ ms: number;
3094
+ }
3095
+ interface RunBranchesOptions {
3096
+ waitFor: BranchWaitFor;
3097
+ /** Successes required for `quorum` (clamped to 1..branches.length). */
3098
+ quorumCount?: number;
3099
+ /** Branches running at once (default DEFAULT_MAX_CONCURRENCY, minimum 1). */
3100
+ maxConcurrency?: number;
3101
+ /** Per-branch timeout in ms; unset or <= 0 means none. */
3102
+ timeoutMs?: number;
3103
+ /** Aborting it cancels every unfinished branch and resolves with ok: false. */
3104
+ signal?: AbortSignal;
3105
+ now?: () => number;
3106
+ }
3107
+ interface RunBranchesOutcome<T = unknown> {
3108
+ ok: boolean;
3109
+ /** One entry per branch, in branch order. */
3110
+ results: BranchResult<T>[];
3111
+ /** The results the wait policy chose (see runBranches). */
3112
+ selected: BranchResult<T>[];
3113
+ error?: string;
3114
+ }
3115
+ type BranchRunner<T> = (branch: BranchSpec, signal: AbortSignal) => Promise<T>;
3116
+ declare const DEFAULT_MAX_CONCURRENCY = 4;
3117
+ /**
3118
+ * Run branches concurrently and settle by `waitFor`:
3119
+ * - all: every branch settles; ok unless all failed; selected = all results.
3120
+ * - race: the first branch to settle (ok or not) decides; selected = [it].
3121
+ * - any: the first success decides; fails once all failed; selected = [it] | [].
3122
+ * - quorum: quorumCount successes decide; fails once unreachable; selected = those, branch order.
3123
+ * Resolves as soon as the decision is made: losers are aborted, never awaited,
3124
+ * and anything they return later is ignored.
3125
+ */
3126
+ declare function runBranches<T>(branches: BranchSpec[], run: BranchRunner<T>, opts: RunBranchesOptions): Promise<RunBranchesOutcome<T>>;
3127
+ /** Combine the selected results. Shapes match the CLI engine's historical output. */
3128
+ declare function mergeBranchResults<T>(outcome: RunBranchesOutcome<T>, strategy: BranchMergeStrategy): unknown;
3129
+ /**
3130
+ * Fork-mode branches of a parallel node, derived from edges: each `fork-<i>`
3131
+ * out-edge starts branch i, which follows execution edges forward until a
3132
+ * `merge` node or an edge into an `input-<i>` join handle. Labels come from
3133
+ * data.forkLabels (default "Branch N"); duplicates are suffixed so every key is unique.
3134
+ */
3135
+ declare function traceForkBranches(file: WorkflowFile, parallelId: string): BranchSpec[];
3136
+ /** The node a fork-mode parallel's branches rejoin at (target of an `input-*` edge). */
3137
+ declare function forkJoinId(file: WorkflowFile, parallelId: string): string | undefined;
3138
+
3139
+ export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, type BranchMergeStrategy, type BranchResult, type BranchRunner, type BranchSpec, type BranchStatus, type BranchWaitFor, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_MAX_CONCURRENCY, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type RunBranchesOptions, type RunBranchesOutcome, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolDeployHook, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, forkJoinId, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, mergeBranchResults, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, runBranches, serializeWorkflow, stripFilePath, traceForkBranches, uninstallPackage, validateWorkflow, validateWorkflowQuick };
package/dist/index.js CHANGED
@@ -3699,8 +3699,9 @@ function validateNode(node, workflow) {
3699
3699
  break;
3700
3700
  }
3701
3701
  if (["loop", "parallel", "tool-call-router", "chat-agent"].includes(node.type)) {
3702
+ const isForkParallel = node.type === "parallel" && node.data.mode === "fork";
3702
3703
  const children = workflow.nodes.filter((n) => n.parentId === node.id);
3703
- if (children.length === 0 && node.type !== "chat-agent") {
3704
+ if (children.length === 0 && node.type !== "chat-agent" && !isForkParallel) {
3704
3705
  const containerTypeHelp = {
3705
3706
  "loop": "Drag nodes inside this loop container to define the loop body.",
3706
3707
  "parallel": "Drag nodes inside this parallel container to run them concurrently.",
@@ -4549,16 +4550,19 @@ function validateNodeData(node, errors, warnings) {
4549
4550
  return;
4550
4551
  }
4551
4552
  switch (node.type) {
4552
- case "prompt":
4553
- if (!("source" in node.data)) {
4553
+ case "prompt": {
4554
+ const d = node.data;
4555
+ const inline = (v) => typeof v === "string" && v.trim() !== "";
4556
+ if (!("source" in node.data) && !inline(d.rawPrompt) && !inline(d.content)) {
4554
4557
  errors.push({
4555
4558
  nodeId: node.id,
4556
4559
  field: "source",
4557
- message: "Prompt node missing source",
4560
+ message: "Prompt node has no source: attach a .prmd file (source) or enter inline prompt text (rawPrompt)",
4558
4561
  code: "MISSING_PROMPT_SOURCE"
4559
4562
  });
4560
4563
  }
4561
4564
  break;
4565
+ }
4562
4566
  case "condition":
4563
4567
  if (!("conditions" in node.data) || !Array.isArray(node.data.conditions)) {
4564
4568
  errors.push({
@@ -4893,6 +4897,166 @@ function getExecutionOrder(workflow) {
4893
4897
  return order;
4894
4898
  }
4895
4899
 
4896
- export { AnthropicFormatter, BUILTIN_COMMAND_EXECUTABLES, CODE_EXTENSIONS, CONTENT_TYPES, CodeGenerationStage, CompilationContext, CompilationError, CompilationStage, CompilerPipeline, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, HybridFileSystem, LexicalAnalysisStage, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, MemoryFileSystem, MemoryPackageResolver, OpenAIFormatter, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, ParseError, PrompdCompiler, PrompdError, PrompdLoader, PrompdParser, SectionOverrideProcessor, SecurityError, SemanticAnalysisStage, TOOL_DEPLOY_DIRS, TemplateProcessingStage, VALID_PACKAGE_TYPES, ValidationError, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
4900
+ // src/lib/parallel.ts
4901
+ var DEFAULT_MAX_CONCURRENCY = 4;
4902
+ var errMsg = (e) => e instanceof Error ? e.message : String(e);
4903
+ function runBranches(branches, run, opts) {
4904
+ const n = branches.length;
4905
+ if (n === 0) return Promise.resolve({ ok: true, results: [], selected: [] });
4906
+ const now = opts.now ?? (() => Date.now());
4907
+ const need = opts.waitFor === "quorum" ? Math.max(1, Math.min(n, Math.floor(opts.quorumCount ?? 1))) : opts.waitFor === "all" ? n : 1;
4908
+ const limit = Math.max(1, Math.floor(opts.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY));
4909
+ const timeoutMs = opts.timeoutMs && opts.timeoutMs > 0 ? opts.timeoutMs : 0;
4910
+ const results = new Array(n);
4911
+ const controllers = new Array(n);
4912
+ const timers = new Array(n);
4913
+ const startedAt = new Array(n).fill(0);
4914
+ const order = [];
4915
+ return new Promise((resolve) => {
4916
+ let nextIdx = 0;
4917
+ let running = 0;
4918
+ let okCount = 0;
4919
+ let failCount = 0;
4920
+ let done = false;
4921
+ const finish = (ok, error) => {
4922
+ if (done) return;
4923
+ done = true;
4924
+ opts.signal?.removeEventListener("abort", onParentAbort);
4925
+ const t = now();
4926
+ for (let i = 0; i < n; i++) {
4927
+ if (timers[i]) clearTimeout(timers[i]);
4928
+ if (results[i]) continue;
4929
+ controllers[i]?.abort();
4930
+ results[i] = { key: branches[i].key, label: branches[i].label, status: "cancelled", ms: controllers[i] ? t - startedAt[i] : 0 };
4931
+ }
4932
+ const all = results;
4933
+ let selected;
4934
+ if (opts.waitFor === "all") selected = all;
4935
+ else if (opts.waitFor === "race") selected = order.length ? [all[order[0]]] : [];
4936
+ else if (opts.waitFor === "any") {
4937
+ const i = order.find((k) => all[k].status === "ok");
4938
+ selected = i === void 0 ? [] : [all[i]];
4939
+ } else selected = ok ? all.filter((r) => r.status === "ok") : [];
4940
+ resolve({ ok, results: all, selected, ...error ? { error } : {} });
4941
+ };
4942
+ const onParentAbort = () => finish(false, "Aborted");
4943
+ const decide = () => {
4944
+ if (opts.waitFor === "race") {
4945
+ const w = results[order[0]];
4946
+ finish(w.status === "ok", w.status === "ok" ? void 0 : `First branch to finish (${w.label}) ended with ${w.status}${w.error ? `: ${w.error}` : ""}`);
4947
+ return;
4948
+ }
4949
+ if (opts.waitFor === "all") {
4950
+ if (order.length === n) finish(okCount > 0, okCount > 0 ? void 0 : "All branches failed");
4951
+ return;
4952
+ }
4953
+ if (okCount >= need) finish(true);
4954
+ else if (failCount > n - need) {
4955
+ finish(false, opts.waitFor === "any" ? "All branches failed" : `Quorum not reached: ${okCount} of ${need} required branches succeeded`);
4956
+ }
4957
+ };
4958
+ const settle = (i, part) => {
4959
+ if (done || results[i]) return;
4960
+ if (timers[i]) clearTimeout(timers[i]);
4961
+ results[i] = { key: branches[i].key, label: branches[i].label, ...part, ms: now() - startedAt[i] };
4962
+ running--;
4963
+ order.push(i);
4964
+ if (part.status === "ok") okCount++;
4965
+ else failCount++;
4966
+ decide();
4967
+ pump();
4968
+ };
4969
+ const start = (i) => {
4970
+ const ac = new AbortController();
4971
+ controllers[i] = ac;
4972
+ startedAt[i] = now();
4973
+ running++;
4974
+ if (timeoutMs) {
4975
+ timers[i] = setTimeout(() => {
4976
+ ac.abort();
4977
+ settle(i, { status: "timeout", error: `timed out after ${timeoutMs}ms` });
4978
+ }, timeoutMs);
4979
+ }
4980
+ let p;
4981
+ try {
4982
+ p = run(branches[i], ac.signal);
4983
+ } catch (e) {
4984
+ p = Promise.reject(e);
4985
+ }
4986
+ p.then(
4987
+ (output) => settle(i, { status: "ok", output }),
4988
+ (e) => settle(i, { status: "error", error: errMsg(e) })
4989
+ );
4990
+ };
4991
+ function pump() {
4992
+ while (!done && running < limit && nextIdx < n) start(nextIdx++);
4993
+ }
4994
+ if (opts.signal?.aborted) {
4995
+ finish(false, "Aborted");
4996
+ return;
4997
+ }
4998
+ opts.signal?.addEventListener("abort", onParentAbort, { once: true });
4999
+ pump();
5000
+ });
5001
+ }
5002
+ function mergeBranchResults(outcome, strategy) {
5003
+ const sel = outcome.selected;
5004
+ if (strategy === "object") {
5005
+ const merged = {};
5006
+ for (const r of sel) merged[r.key] = r.status === "ok" ? r.output : null;
5007
+ return merged;
5008
+ }
5009
+ if (strategy === "first") {
5010
+ const first = sel.find((r) => r.status === "ok");
5011
+ return first ? { result: first.output } : { error: "All branches failed" };
5012
+ }
5013
+ return sel.map((r) => r.status === "ok" ? r.output : null);
5014
+ }
5015
+ var EVENT_HANDLES = ["onError", "onCheckpoint", "onProgress", "toolResult"];
5016
+ var forkIndex = (handle) => {
5017
+ const k = parseInt((handle ?? "").replace("fork-", ""), 10);
5018
+ return Number.isFinite(k) ? k : 0;
5019
+ };
5020
+ function traceForkBranches(file, parallelId) {
5021
+ const node = file.nodes.find((n) => n.id === parallelId);
5022
+ if (!node || node.type !== "parallel") return [];
5023
+ const data = node.data;
5024
+ const mergeIds = new Set(file.nodes.filter((n) => n.type === "merge").map((n) => n.id));
5025
+ const forkEdges = file.edges.filter((e) => e.source === parallelId && e.sourceHandle?.startsWith("fork-")).sort((a, b) => forkIndex(a.sourceHandle) - forkIndex(b.sourceHandle));
5026
+ const labelUses = /* @__PURE__ */ new Map();
5027
+ return forkEdges.map((fe) => {
5028
+ const idx = forkIndex(fe.sourceHandle);
5029
+ const nodeIds = [];
5030
+ if (!fe.targetHandle?.startsWith("input-")) {
5031
+ const visited = /* @__PURE__ */ new Set();
5032
+ const queue = [fe.target];
5033
+ while (queue.length > 0) {
5034
+ const id = queue.shift();
5035
+ if (visited.has(id) || mergeIds.has(id)) continue;
5036
+ visited.add(id);
5037
+ nodeIds.push(id);
5038
+ for (const e of file.edges) {
5039
+ if (e.source !== id) continue;
5040
+ if (e.sourceHandle === "loop-end" || e.sourceHandle === "parallel-end") continue;
5041
+ if (e.targetHandle?.startsWith("fork-")) continue;
5042
+ if (e.sourceHandle && EVENT_HANDLES.includes(e.sourceHandle)) continue;
5043
+ if (e.targetHandle?.startsWith("input-")) continue;
5044
+ if (!visited.has(e.target) && !mergeIds.has(e.target)) queue.push(e.target);
5045
+ }
5046
+ }
5047
+ }
5048
+ const base = data.forkLabels?.[idx]?.trim() || `Branch ${idx + 1}`;
5049
+ const uses = labelUses.get(base) ?? 0;
5050
+ labelUses.set(base, uses + 1);
5051
+ const label = uses === 0 ? base : `${base} (${uses + 1})`;
5052
+ return { key: label, label, nodeIds };
5053
+ });
5054
+ }
5055
+ function forkJoinId(file, parallelId) {
5056
+ const members = /* @__PURE__ */ new Set([parallelId, ...traceForkBranches(file, parallelId).flatMap((b) => b.nodeIds)]);
5057
+ return file.edges.find((e) => members.has(e.source) && e.targetHandle?.startsWith("input-"))?.target;
5058
+ }
5059
+
5060
+ export { AnthropicFormatter, BUILTIN_COMMAND_EXECUTABLES, CODE_EXTENSIONS, CONTENT_TYPES, CodeGenerationStage, CompilationContext, CompilationError, CompilationStage, CompilerPipeline, DEFAULT_MAX_CONCURRENCY, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, HybridFileSystem, LexicalAnalysisStage, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, MemoryFileSystem, MemoryPackageResolver, OpenAIFormatter, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, ParseError, PrompdCompiler, PrompdError, PrompdLoader, PrompdParser, SectionOverrideProcessor, SecurityError, SemanticAnalysisStage, TOOL_DEPLOY_DIRS, TemplateProcessingStage, VALID_PACKAGE_TYPES, ValidationError, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, forkJoinId, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, mergeBranchResults, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, runBranches, serializeWorkflow, stripFilePath, traceForkBranches, uninstallPackage, validateWorkflow, validateWorkflowQuick };
4897
5061
  //# sourceMappingURL=index.js.map
4898
5062
  //# sourceMappingURL=index.js.map