@codemation/core 0.0.16 → 0.0.19

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"RunIntentService-CYnn140t.js","names":["eventBus: RunEventBus | undefined","metadata: PersistedRuntimeTypeMetadata","storage: BinaryStorage","workflowId: WorkflowId","runId: RunId","nodeId: NodeId","activationId: NodeActivationId","now: () => Date","storage: BinaryStorage","workflowId: WorkflowId","runId: RunId","now: () => Date","activationScheduler: ActivationSchedulerPort","workflowExecutionRepository: WorkflowExecutionRepository","nodeEventPublisher: NodeEventPublisher","pending: PendingNodeExecution","credentialSessions: CredentialSessionService","binaryStorage: BinaryStorage","currentDate: () => Date","sleeper: AsyncSleeper","lastError: unknown","activationIdFactory: ActivationIdFactory","credentialResolverFactory: CredentialResolverFactory","nodeInstanceFactory: WorkflowNodeInstanceFactory","retryRunner: InProcessRetryRunner","node","name: string","missingTokenId?: string","name: string","missingTokenId?: string","node","workflowRepository: WorkflowRepository","tokenRegistry: PersistedWorkflowTokenRegistryLike","codec: WorkflowSnapshotCodec","missingRuntimeFallbacks: MissingRuntimeFallbacks","node","nodeResolver: NodeResolver","workflowExecutionRepository: WorkflowExecutionRepository","runId: RunId","workflowId: WorkflowId","parent: ParentExecutionRef | undefined","publishNodeEvent: (\n kind: \"nodeQueued\" | \"nodeStarted\" | \"nodeCompleted\" | \"nodeFailed\",\n snapshot: NodeExecutionSnapshot,\n ) => Promise<void>","record: ConnectionInvocationRecord","workflowExecutionRepository: WorkflowExecutionRepository","nodeEventPublisher: NodeEventPublisher","missingRuntimeExecutionMarker: MissingRuntimeExecutionMarker","node","executionContextFactory: ExecutionContextFactory","credentialResolverFactory: CredentialResolverFactory","defsById: ReadonlyMap<NodeId, NodeDef>","outgoingByNode: ReadonlyMap<\n NodeId,\n ReadonlyArray<Readonly<{ output: OutputPortKey; to: Readonly<{ nodeId: NodeId; input: InputPortKey }> }>>\n >","incomingByNode: ReadonlyMap<\n NodeId,\n ReadonlyArray<Readonly<{ from: Readonly<{ nodeId: NodeId; output: OutputPortKey }>; input: InputPortKey }>>\n >","expectedInputsByNode: ReadonlyMap<NodeId, ReadonlyArray<InputPortKey>>","rootNodeIds: ReadonlyArray<NodeId>","order: InputPortKey[]","node","activationIdFactory: ActivationIdFactory","workflowExecutionRepository: WorkflowExecutionRepository","runDataFactory: RunDataFactory","runExecutionContextFactory: WorkflowRunExecutionContextFactory","workflowSnapshotResolver: WorkflowSnapshotResolver","planningFactory: EngineWorkflowPlanningFactory","nodeStatePublisherFactory: NodeRunStateWriterFactory","credentialResolverFactory: CredentialResolverFactory","nodeActivationRequestComposer: NodeActivationRequestComposer","persistedRunStateTerminalBuilder: PersistedRunStateTerminalBuilder","activationEnqueueService: ActivationEnqueueService","nodeEventPublisher: NodeEventPublisher","semantics: RunStateSemantics","waiters: EngineWaiters","policyErrorServices: WorkflowPolicyErrorServices","terminalPersistence: RunTerminalPersistenceCoordinator","executionLimitsPolicy: EngineExecutionLimitsPolicy","result: RunResult","result","queue: RunQueueEntry[]","next: ReturnType<(typeof planner)[\"nextActivation\"]>","triggerOutputs: NodeOutputs","topology: WorkflowTopology","queue: RunQueueEntry[]","outputsByNode: Record<NodeId, NodeOutputs>","clearedNodeIds: NodeId[]","preservedPinnedNodeIds: NodeId[]","satisfiedNodeIds: NodeId[]","frontierNodeIds: NodeId[]","received: Record<InputPortKey, Items>","input","pendingNodeIds: NodeId[]","runIdFactory: RunIdFactory","workflowExecutionRepository: WorkflowExecutionRepository","runDataFactory: RunDataFactory","workflowSnapshotFactory: WorkflowSnapshotFactory","planningFactory: EngineWorkflowPlanningFactory","nodeStatePublisherFactory: NodeRunStateWriterFactory","runExecutionContextFactory: WorkflowRunExecutionContextFactory","nodeActivationRequestComposer: NodeActivationRequestComposer","activationEnqueueService: ActivationEnqueueService","semantics: RunStateSemantics","waiters: EngineWaiters","workflowPolicyRuntimeDefaults: WorkflowPolicyRuntimeDefaults | undefined","executionLimitsPolicy: EngineExecutionLimitsPolicy","initialNodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>","queue: RunQueueEntry[]","result: RunResult","offloadPolicy: NodeOffloadPolicy","workerScheduler: NodeExecutionScheduler","inline: InlineDrivingScheduler","workerRequest: NodeExecutionRequest","nodeExecutor: NodeExecutor","receipt: NodeActivationReceipt","ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig","config: EngineExecutionLimitsPolicyConfig","chunks: Uint8Array[]","bytes: Uint8Array","out: Record<NodeId, NodeOutputs>","max: string | undefined","engine: Engine","workflowRepository: WorkflowRepository"],"sources":["../src/workflow/definition/ConnectionNodeIdFactory.ts","../src/workflow/definition/WorkflowExecutableNodeClassifier.ts","../src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts","../src/di/CoreTokens.ts","../src/events/NodeEventPublisher.ts","../src/runtime-types/persistedRuntimeTypeModelRegistry.ts","../src/runtime-types/PersistedRuntimeTypeNameResolver.ts","../src/runtime-types/StackTraceCallSitePathResolver.ts","../src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts","../src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts","../src/runtime-types/runtimeTypeDecorators.types.ts","../src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts","../src/binaries/UnavailableBinaryStorage.ts","../src/binaries/DefaultExecutionBinaryServiceFactory.ts","../src/execution/NodeExecutionSnapshotFactory.ts","../src/execution/NodeInputsByPortFactory.ts","../src/execution/ActivationEnqueueService.ts","../src/execution/CredentialResolverFactory.ts","../src/execution/DefaultAsyncSleeper.ts","../src/execution/DefaultExecutionContextFactory.ts","../src/execution/InProcessRetryRunner.ts","../src/execution/InProcessRetryRunnerFactory.ts","../src/execution/NodeActivationRequestComposer.ts","../src/execution/NodeExecutor.ts","../src/execution/NodeExecutorFactory.ts","../src/workflowSnapshots/MissingRuntimeExecutionMarker.ts","../src/workflowSnapshots/MissingRuntimeNodeToken.ts","../src/workflowSnapshots/MissingRuntimeNodeConfig.ts","../src/workflowSnapshots/MissingRuntimeTriggerToken.ts","../src/workflowSnapshots/MissingRuntimeTriggerConfig.ts","../src/workflowSnapshots/MissingRuntimeFallbacksFactory.ts","../src/workflowSnapshots/MissingRuntimeNode.ts","../src/workflowSnapshots/MissingRuntimeTrigger.ts","../src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts","../src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts","../src/workflowSnapshots/WorkflowSnapshotResolver.ts","../src/execution/NodeInstanceFactory.ts","../src/execution/NodeInstanceFactoryFactory.ts","../src/execution/NodeRunStateWriter.ts","../src/execution/NodeRunStateWriterFactory.ts","../src/execution/PersistedRunStateTerminalBuilder.ts","../src/execution/RunStateSemantics.ts","../src/execution/WorkflowRunExecutionContextFactory.ts","../src/planning/WorkflowTopologyPlanner.ts","../src/orchestration/RunContinuationService.ts","../src/planning/CurrentStateFrontierPlanner.ts","../src/policies/storage/RunPolicySnapshotFactory.ts","../src/orchestration/RunStartService.ts","../src/scheduler/ConfigDrivenOffloadPolicy.ts","../src/scheduler/DefaultDrivingScheduler.ts","../src/scheduler/HintOnlyOffloadPolicy.ts","../src/scheduler/InlineDrivingScheduler.ts","../src/scheduler/LocalOnlyScheduler.ts","../src/policies/executionLimits/EngineExecutionLimitsPolicy.ts","../src/runStorage/BinaryBodyBufferReader.ts","../src/runStorage/BinaryBodyReadableStreamFactory.ts","../src/runStorage/InMemoryBinaryStorageRegistry.ts","../src/runStorage/InMemoryRunData.ts","../src/runStorage/InMemoryRunDataFactory.ts","../src/contracts/runFinishedAtFactory.ts","../src/runtime/RunIntentService.ts"],"sourcesContent":["import type { NodeId } from \"../../types\";\n\n/**\n * Deterministic ids for workflow connection-owned child nodes (LLM slot, tools, etc.).\n * These are stable across loads.\n */\nexport class ConnectionNodeIdFactory {\n static readonly connectionSegment = \"__conn__\" as const;\n\n static languageModelConnectionNodeId(parentNodeId: NodeId): NodeId {\n return `${parentNodeId}${this.connectionSegment}llm`;\n }\n\n static toolConnectionNodeId(parentNodeId: NodeId, toolName: string): NodeId {\n const normalized = this.normalizeToolName(toolName);\n return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;\n }\n\n static isLanguageModelConnectionNodeId(nodeId: NodeId): boolean {\n return nodeId.endsWith(`${this.connectionSegment}llm`);\n }\n\n static isToolConnectionNodeId(nodeId: NodeId): boolean {\n return nodeId.includes(`${this.connectionSegment}tool${this.connectionSegment}`);\n }\n\n /** True when `nodeId` is a connection-owned child of `parentNodeId` (LLM or tool slot). */\n static isConnectionOwnedDescendantOf(parentNodeId: NodeId, nodeId: NodeId): boolean {\n return nodeId.startsWith(`${parentNodeId}${this.connectionSegment}`);\n }\n\n /** Normalizes a tool display name to a stable id segment. */\n static normalizeToolName(toolName: string): string {\n return (\n toolName\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\") || \"tool\"\n );\n }\n}\n","import type { NodeDefinition, NodeId, WorkflowDefinition } from \"../../types\";\n\n/**\n * Derives which workflow nodes participate in the main execution graph vs connection-only children.\n */\nexport class WorkflowExecutableNodeClassifier {\n private readonly connectionOwnedIds: ReadonlySet<NodeId>;\n\n constructor(workflow: WorkflowDefinition) {\n this.connectionOwnedIds = this.collectConnectionOwnedIds(workflow);\n }\n\n isConnectionOwnedNodeId(nodeId: NodeId): boolean {\n return this.connectionOwnedIds.has(nodeId);\n }\n\n isExecutableNodeId(nodeId: NodeId): boolean {\n return !this.connectionOwnedIds.has(nodeId);\n }\n\n filterExecutableNodeDefinitions(nodes: ReadonlyArray<NodeDefinition>): ReadonlyArray<NodeDefinition> {\n return nodes.filter((n) => this.isExecutableNodeId(n.id));\n }\n\n private collectConnectionOwnedIds(workflow: WorkflowDefinition): ReadonlySet<NodeId> {\n const ids = new Set<NodeId>();\n for (const connection of workflow.connections ?? []) {\n for (const childId of connection.childNodeIds) {\n ids.add(childId);\n }\n }\n return ids;\n }\n\n /**\n * Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.\n */\n findDefaultExecutableStartNodeId(workflow: WorkflowDefinition): NodeId {\n const firstTrigger = workflow.nodes.find((n) => n.kind === \"trigger\" && this.isExecutableNodeId(n.id))?.id;\n if (firstTrigger) return firstTrigger;\n\n const incoming = new Map<NodeId, number>();\n for (const n of workflow.nodes) {\n if (this.isExecutableNodeId(n.id)) incoming.set(n.id, 0);\n }\n for (const e of workflow.edges) {\n if (!this.isExecutableNodeId(e.from.nodeId) || !this.isExecutableNodeId(e.to.nodeId)) continue;\n incoming.set(e.to.nodeId, (incoming.get(e.to.nodeId) ?? 0) + 1);\n }\n const start = workflow.nodes.find((n) => this.isExecutableNodeId(n.id) && (incoming.get(n.id) ?? 0) === 0)?.id;\n return (\n start ??\n workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id ??\n (() => {\n throw new Error(`Workflow ${workflow.id} has no executable nodes`);\n })()\n );\n }\n\n firstExecutableNodeIdInDefinitionOrder(workflow: WorkflowDefinition): NodeId | undefined {\n return workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id;\n }\n\n lastExecutableNodeIdInDefinitionOrder(workflow: WorkflowDefinition): NodeId {\n for (let i = workflow.nodes.length - 1; i >= 0; i--) {\n const n = workflow.nodes[i]!;\n if (this.isExecutableNodeId(n.id)) return n.id;\n }\n throw new Error(`Workflow ${workflow.id} has no executable nodes`);\n }\n}\n","import type { WorkflowDefinition } from \"../../types\";\n\nimport { WorkflowExecutableNodeClassifier } from \"./WorkflowExecutableNodeClassifier\";\n\nexport class WorkflowExecutableNodeClassifierFactory {\n static create(workflow: WorkflowDefinition): WorkflowExecutableNodeClassifier {\n return new WorkflowExecutableNodeClassifier(workflow);\n }\n}\n","import type { TypeToken } from \"./index\";\nimport type { RunEventBus } from \"../events/runEvents\";\nimport type { EngineExecutionLimitsPolicy } from \"../policies/executionLimits/EngineExecutionLimitsPolicy\";\nimport type {\n ActivationIdFactory,\n BinaryStorage,\n CredentialSessionService,\n CredentialTypeRegistry,\n ExecutionContextFactory,\n LiveWorkflowRepository,\n NodeActivationScheduler,\n NodeResolver,\n PersistedWorkflowTokenRegistryLike,\n RunDataFactory,\n RunIdFactory,\n TriggerSetupStateRepository,\n WorkflowExecutionRepository,\n WorkflowNodeInstanceFactory,\n WorkflowActivationPolicy,\n WorkflowRepository,\n WorkflowRunnerService,\n} from \"../types\";\n\nexport const CoreTokens = {\n PersistedWorkflowTokenRegistry: Symbol.for(\n \"codemation.core.PersistedWorkflowTokenRegistry\",\n ) as TypeToken<PersistedWorkflowTokenRegistryLike>,\n CredentialSessionService: Symbol.for(\n \"codemation.core.CredentialSessionService\",\n ) as TypeToken<CredentialSessionService>,\n CredentialTypeRegistry: Symbol.for(\"codemation.core.CredentialTypeRegistry\") as TypeToken<CredentialTypeRegistry>,\n WorkflowRunnerService: Symbol.for(\"codemation.core.WorkflowRunnerService\") as TypeToken<WorkflowRunnerService>,\n LiveWorkflowRepository: Symbol.for(\"codemation.core.LiveWorkflowRepository\") as TypeToken<LiveWorkflowRepository>,\n WorkflowRepository: Symbol.for(\"codemation.core.WorkflowRepository\") as TypeToken<WorkflowRepository>,\n NodeResolver: Symbol.for(\"codemation.core.NodeResolver\") as TypeToken<NodeResolver>,\n WorkflowNodeInstanceFactory: Symbol.for(\n \"codemation.core.WorkflowNodeInstanceFactory\",\n ) as TypeToken<WorkflowNodeInstanceFactory>,\n RunIdFactory: Symbol.for(\"codemation.core.RunIdFactory\") as TypeToken<RunIdFactory>,\n ActivationIdFactory: Symbol.for(\"codemation.core.ActivationIdFactory\") as TypeToken<ActivationIdFactory>,\n WorkflowExecutionRepository: Symbol.for(\n \"codemation.core.WorkflowExecutionRepository\",\n ) as TypeToken<WorkflowExecutionRepository>,\n TriggerSetupStateRepository: Symbol.for(\n \"codemation.core.TriggerSetupStateRepository\",\n ) as TypeToken<TriggerSetupStateRepository>,\n NodeActivationScheduler: Symbol.for(\"codemation.core.NodeActivationScheduler\") as TypeToken<NodeActivationScheduler>,\n RunDataFactory: Symbol.for(\"codemation.core.RunDataFactory\") as TypeToken<RunDataFactory>,\n ExecutionContextFactory: Symbol.for(\"codemation.core.ExecutionContextFactory\") as TypeToken<ExecutionContextFactory>,\n RunEventBus: Symbol.for(\"codemation.core.RunEventBus\") as TypeToken<RunEventBus>,\n BinaryStorage: Symbol.for(\"codemation.core.BinaryStorage\") as TypeToken<BinaryStorage>,\n WebhookBasePath: Symbol.for(\"codemation.core.WebhookBasePath\") as TypeToken<string>,\n /** Engine execution limits (defaults + optional host overrides). Consumers may bind a custom instance to override. */\n EngineExecutionLimitsPolicy: Symbol.for(\n \"codemation.core.EngineExecutionLimitsPolicy\",\n ) as TypeToken<EngineExecutionLimitsPolicy>,\n WorkflowActivationPolicy: Symbol.for(\n \"codemation.core.WorkflowActivationPolicy\",\n ) as TypeToken<WorkflowActivationPolicy>,\n} as const;\n","import type { RunEventBus } from \"./runEvents\";\nimport type { NodeExecutionSnapshot } from \"../types\";\n\n/** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */\nexport class NodeEventPublisher {\n constructor(private readonly eventBus: RunEventBus | undefined) {}\n\n async publish(\n kind: \"nodeQueued\" | \"nodeStarted\" | \"nodeCompleted\" | \"nodeFailed\",\n snapshot: NodeExecutionSnapshot,\n ): Promise<void> {\n if (!this.eventBus) return;\n await this.eventBus.publish({\n kind,\n runId: snapshot.runId,\n workflowId: snapshot.workflowId,\n parent: snapshot.parent,\n at: snapshot.updatedAt,\n snapshot,\n });\n }\n}\n","/** Shared metadata key used to attach persisted runtime-type information to decorated classes. */\nexport const persistedRuntimeTypeMetadataKey = Symbol.for(\"codemation.core.persistedRuntimeTypeMetadata\");\n\nexport type DecoratedRuntimeType = Readonly<{ name?: string }> & object;\n\n/** Categories of runtime classes that can be discovered and rehydrated from persisted snapshots. */\nexport type PersistedRuntimeTypeKind = \"node\" | \"tool\" | \"chatModel\";\n\nexport interface PersistedRuntimeTypeDecoratorOptions {\n readonly name?: string;\n readonly packageName?: string;\n readonly moduleUrl?: string;\n}\n\n/** Serialized metadata attached to a decorated runtime type. */\nexport interface PersistedRuntimeTypeMetadata {\n readonly persistedName: string;\n readonly kind: PersistedRuntimeTypeKind;\n readonly packageName: string;\n readonly sourceHint?: string;\n}\n\n/** Normalizes decorator options so persistence metadata has stable defaults. */\nexport class PersistedRuntimeTypeDecoratorDefaults {\n static readonly appPackageName = \"app\";\n\n static apply(options: PersistedRuntimeTypeDecoratorOptions): PersistedRuntimeTypeDecoratorOptions {\n return {\n ...options,\n packageName: options.packageName ?? this.appPackageName,\n };\n }\n}\n","import type { DecoratedRuntimeType } from \"./persistedRuntimeTypeModelRegistry\";\n\n/** Resolves the persisted type name from either an explicit override or the class name itself. */\nexport class PersistedRuntimeTypeNameResolver {\n static resolve(target: DecoratedRuntimeType, override: string | undefined): string {\n const resolved = override ?? target.name;\n if (!resolved) {\n throw new Error(\n \"Persisted runtime token metadata requires a named class or an explicit decorator name override.\",\n );\n }\n return resolved;\n }\n}\n","export class StackTraceCallSitePathResolver {\n static resolve(decoratorFileUrl: string): string | undefined {\n const stack = new Error().stack ?? \"\";\n for (const line of stack.split(\"\\n\")) {\n const candidate = this.extractPath(line.trim());\n if (!candidate) {\n continue;\n }\n if (candidate === decoratorFileUrl || candidate.includes(\"runtimeTypeDecorators\")) {\n continue;\n }\n return candidate;\n }\n return undefined;\n }\n\n private static extractPath(line: string): string | undefined {\n const fileUrlMatch = line.match(/file:\\/\\/[^\\s)]+/);\n if (fileUrlMatch) return fileUrlMatch[0];\n const parenMatch = line.match(/\\((\\/[^)]+)\\)/);\n if (parenMatch) return parenMatch[1];\n const bareMatch = line.match(/at (\\/[^\\s]+)/);\n return bareMatch?.[1];\n }\n}\n","import {\n PersistedRuntimeTypeDecoratorDefaults,\n persistedRuntimeTypeMetadataKey,\n type DecoratedRuntimeType,\n type PersistedRuntimeTypeDecoratorOptions,\n type PersistedRuntimeTypeKind,\n type PersistedRuntimeTypeMetadata,\n} from \"./persistedRuntimeTypeModelRegistry\";\nimport { PersistedRuntimeTypeNameResolver } from \"./PersistedRuntimeTypeNameResolver\";\nimport { StackTraceCallSitePathResolver } from \"./StackTraceCallSitePathResolver\";\n\n/**\n * Defines and retrieves persisted runtime metadata on decorated classes.\n * The metadata is attached as a non-enumerable property so runtime objects stay serializable.\n */\nexport class PersistedRuntimeTypeMetadataStore {\n static define(\n target: DecoratedRuntimeType,\n kind: PersistedRuntimeTypeKind,\n options: PersistedRuntimeTypeDecoratorOptions,\n decoratorFileUrl: string,\n ): void {\n const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);\n const metadata: PersistedRuntimeTypeMetadata = {\n persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),\n kind,\n packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,\n sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl),\n };\n Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {\n configurable: false,\n enumerable: false,\n writable: false,\n value: metadata,\n });\n }\n\n static get(target: unknown): PersistedRuntimeTypeMetadata | undefined {\n if (!target || (typeof target !== \"function\" && typeof target !== \"object\")) {\n return undefined;\n }\n return (target as Record<PropertyKey, unknown>)[persistedRuntimeTypeMetadataKey] as\n | PersistedRuntimeTypeMetadata\n | undefined;\n }\n}\n","import { injectable } from \"../di\";\n\nimport { PersistedRuntimeTypeMetadataStore } from \"./PersistedRuntimeTypeMetadataStoreRegistry\";\nimport type {\n DecoratedRuntimeType,\n PersistedRuntimeTypeDecoratorOptions,\n PersistedRuntimeTypeKind,\n} from \"./persistedRuntimeTypeModelRegistry\";\n\n/**\n * Applies both tsyringe injectability and persisted runtime metadata in one decorator.\n * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.\n */\nexport class InjectableRuntimeDecoratorComposer {\n static compose(\n kind: PersistedRuntimeTypeKind,\n options: PersistedRuntimeTypeDecoratorOptions,\n decoratorFileUrl: string,\n ): ClassDecorator {\n return (target) => {\n injectable()(target as never);\n PersistedRuntimeTypeMetadataStore.define(target as DecoratedRuntimeType, kind, options, decoratorFileUrl);\n };\n }\n}\n","import type {\n PersistedRuntimeTypeDecoratorOptions,\n PersistedRuntimeTypeMetadata,\n} from \"./persistedRuntimeTypeModelRegistry\";\n\nimport { InjectableRuntimeDecoratorComposer } from \"./InjectableRuntimeDecoratorComposerRegistry\";\nimport { PersistedRuntimeTypeMetadataStore } from \"./PersistedRuntimeTypeMetadataStoreRegistry\";\n\n/**\n * Public decorator entry points for runtime-discoverable classes.\n *\n * These exports intentionally stay as plain decorator factory functions because TypeScript's\n * `@decorator()` syntax expects callable values rather than instance methods. The helpers below\n * attach DI metadata and persisted-name metadata in one step so hosts can discover nodes, tools,\n * and chat models without duplicating registration boilerplate.\n */\nexport type {\n PersistedRuntimeTypeDecoratorOptions,\n PersistedRuntimeTypeKind,\n PersistedRuntimeTypeMetadata,\n} from \"./persistedRuntimeTypeModelRegistry\";\n\n/** Reads persisted runtime metadata from a decorated class or object. */\nexport function getPersistedRuntimeTypeMetadata(target: unknown): PersistedRuntimeTypeMetadata | undefined {\n return PersistedRuntimeTypeMetadataStore.get(target);\n}\n\n/** Marks a class as a persisted node runtime type and an injectable tsyringe service. */\nexport function node(options: PersistedRuntimeTypeDecoratorOptions = {}): ClassDecorator {\n return InjectableRuntimeDecoratorComposer.compose(\"node\", options, import.meta.url);\n}\n\n/** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */\nexport function tool(options: PersistedRuntimeTypeDecoratorOptions = {}): ClassDecorator {\n return InjectableRuntimeDecoratorComposer.compose(\"tool\", options, import.meta.url);\n}\n\n/** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */\nexport function chatModel(options: PersistedRuntimeTypeDecoratorOptions = {}): ClassDecorator {\n return InjectableRuntimeDecoratorComposer.compose(\"chatModel\", options, import.meta.url);\n}\n\nexport { InjectableRuntimeDecoratorComposer } from \"./InjectableRuntimeDecoratorComposerRegistry\";\nexport { PersistedRuntimeTypeMetadataStore } from \"./PersistedRuntimeTypeMetadataStoreRegistry\";\nexport { PersistedRuntimeTypeNameResolver } from \"./PersistedRuntimeTypeNameResolver\";\nexport { StackTraceCallSitePathResolver } from \"./StackTraceCallSitePathResolver\";\n","import type { BinaryAttachment, BinaryPreviewKind, Item, NodeActivationId, NodeId, RunId, WorkflowId } from \"../types\";\n\nimport type {\n BinaryAttachmentCreateRequest,\n BinaryStorage,\n BinaryStorageReadResult,\n NodeBinaryAttachmentService,\n} from \"../types\";\n\nexport class DefaultNodeBinaryAttachmentService implements NodeBinaryAttachmentService {\n constructor(\n private readonly storage: BinaryStorage,\n private readonly workflowId: WorkflowId,\n private readonly runId: RunId,\n private readonly nodeId: NodeId,\n private readonly activationId: NodeActivationId,\n private readonly now: () => Date,\n ) {}\n\n async attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment> {\n const attachmentId = this.createAttachmentId();\n const createdAt = this.now().toISOString();\n const storageKey = this.createStorageKey(args, attachmentId);\n const stored = await this.storage.write({\n storageKey,\n body: args.body,\n });\n return {\n id: attachmentId,\n storageKey: stored.storageKey,\n mimeType: args.mimeType,\n size: stored.size,\n storageDriver: this.storage.driverName,\n previewKind: args.previewKind ?? this.resolvePreviewKind(args.mimeType),\n createdAt,\n runId: this.runId,\n workflowId: this.workflowId,\n nodeId: this.nodeId,\n activationId: this.activationId,\n filename: args.filename,\n sha256: stored.sha256,\n };\n }\n\n withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson> {\n return {\n ...item,\n binary: {\n ...(item.binary ?? {}),\n [name]: attachment,\n },\n };\n }\n\n forNode(args: { nodeId: NodeId; activationId: NodeActivationId }): NodeBinaryAttachmentService {\n return new DefaultNodeBinaryAttachmentService(\n this.storage,\n this.workflowId,\n this.runId,\n args.nodeId,\n args.activationId,\n this.now,\n );\n }\n\n async openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined> {\n return await this.storage.openReadStream(attachment.storageKey);\n }\n\n private createAttachmentId(): string {\n return DefaultNodeBinaryAttachmentService.createAttachmentIdValue(`${this.activationId}-${this.now().getTime()}`);\n }\n\n private static createAttachmentIdValue(fallbackValue: string): string {\n const cryptoObject = globalThis.crypto;\n if (cryptoObject && typeof cryptoObject.randomUUID === \"function\") {\n return cryptoObject.randomUUID();\n }\n return fallbackValue;\n }\n\n private createStorageKey(args: BinaryAttachmentCreateRequest, attachmentId: string): string {\n const safeName = this.sanitizeSegment(args.name);\n const safeFilename = this.sanitizeFilename(args.filename);\n const filenameSuffix = safeFilename ? `-${safeFilename}` : \"\";\n return `${this.sanitizeSegment(this.workflowId)}/${this.sanitizeSegment(this.runId)}/${this.sanitizeSegment(this.nodeId)}/${this.sanitizeSegment(this.activationId)}/${attachmentId}-${safeName}${filenameSuffix}`;\n }\n\n private sanitizeSegment(value: string): string {\n const normalized = value.trim();\n if (!normalized) {\n return \"item\";\n }\n return normalized.replace(/[^a-zA-Z0-9._-]+/g, \"_\");\n }\n\n private sanitizeFilename(value: string | undefined): string | undefined {\n if (!value) {\n return undefined;\n }\n const normalized = value.trim().split(\"/\").at(-1)?.split(\"\\\\\").at(-1) ?? value.trim();\n if (!normalized) {\n return undefined;\n }\n return normalized.replace(/[^a-zA-Z0-9._-]+/g, \"_\");\n }\n\n private resolvePreviewKind(mimeType: string): BinaryPreviewKind {\n if (mimeType.startsWith(\"image/\")) {\n return \"image\";\n }\n if (mimeType.startsWith(\"audio/\")) {\n return \"audio\";\n }\n if (mimeType.startsWith(\"video/\")) {\n return \"video\";\n }\n return \"download\";\n }\n}\n","import type { BinaryStorage } from \"../types\";\n\nexport class UnavailableBinaryStorage implements BinaryStorage {\n readonly driverName = \"unavailable\";\n\n async write(): Promise<never> {\n throw new Error(\"Binary storage is not configured for this runtime.\");\n }\n\n async openReadStream(): Promise<undefined> {\n return undefined;\n }\n\n async stat(): Promise<{ exists: false }> {\n return { exists: false };\n }\n\n async delete(): Promise<void> {}\n}\n","import type { BinaryAttachment, NodeActivationId, NodeId, RunId, WorkflowId } from \"../types\";\n\nimport type {\n BinaryStorage,\n BinaryStorageReadResult,\n ExecutionBinaryService,\n NodeBinaryAttachmentService,\n} from \"../types\";\n\nimport { DefaultNodeBinaryAttachmentService } from \"./DefaultNodeBinaryAttachmentServiceFactory\";\n\nexport class DefaultExecutionBinaryService implements ExecutionBinaryService {\n constructor(\n private readonly storage: BinaryStorage,\n private readonly workflowId: WorkflowId,\n private readonly runId: RunId,\n private readonly now: () => Date,\n ) {}\n\n forNode(args: { nodeId: NodeId; activationId: NodeActivationId }): NodeBinaryAttachmentService {\n return new DefaultNodeBinaryAttachmentService(\n this.storage,\n this.workflowId,\n this.runId,\n args.nodeId,\n args.activationId,\n this.now,\n );\n }\n\n async openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined> {\n return await this.storage.openReadStream(attachment.storageKey);\n }\n}\n\nexport { DefaultNodeBinaryAttachmentService } from \"./DefaultNodeBinaryAttachmentServiceFactory\";\nexport { UnavailableBinaryStorage } from \"./UnavailableBinaryStorage\";\n","import type {\n NodeActivationId,\n NodeExecutionSnapshot,\n NodeId,\n NodeInputsByPort,\n NodeOutputs,\n ParentExecutionRef,\n RunId,\n WorkflowId,\n} from \"../types\";\n\nexport class NodeExecutionSnapshotFactory {\n static queued(args: {\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n queuedAt: string;\n inputsByPort: NodeInputsByPort;\n }): NodeExecutionSnapshot {\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: args.parent,\n status: \"queued\",\n queuedAt: args.queuedAt,\n updatedAt: args.queuedAt,\n inputsByPort: args.inputsByPort,\n };\n }\n\n static running(args: {\n previous?: NodeExecutionSnapshot;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n startedAt: string;\n inputsByPort: NodeInputsByPort;\n }): NodeExecutionSnapshot {\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: args.parent,\n status: \"running\",\n queuedAt: args.previous?.queuedAt,\n startedAt: args.startedAt,\n updatedAt: args.startedAt,\n inputsByPort: args.inputsByPort,\n outputs: args.previous?.outputs,\n error: undefined,\n };\n }\n\n static completed(args: {\n previous?: NodeExecutionSnapshot;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n finishedAt: string;\n inputsByPort: NodeInputsByPort;\n outputs: NodeOutputs;\n fromPinnedOutput?: boolean;\n }): NodeExecutionSnapshot {\n const fromPinnedOutput = args.fromPinnedOutput ?? false;\n const startedAt = fromPinnedOutput ? (args.previous?.startedAt ?? args.finishedAt) : args.previous?.startedAt;\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: args.parent,\n status: \"completed\",\n queuedAt: args.previous?.queuedAt,\n startedAt,\n finishedAt: args.finishedAt,\n updatedAt: args.finishedAt,\n inputsByPort: args.inputsByPort,\n outputs: args.outputs,\n usedPinnedOutput: fromPinnedOutput,\n error: undefined,\n };\n }\n\n static skipped(args: {\n previous?: NodeExecutionSnapshot;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n finishedAt: string;\n inputsByPort: NodeInputsByPort;\n outputs: NodeOutputs;\n }): NodeExecutionSnapshot {\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: args.parent,\n status: \"skipped\",\n queuedAt: args.previous?.queuedAt,\n startedAt: args.previous?.startedAt,\n finishedAt: args.finishedAt,\n updatedAt: args.finishedAt,\n inputsByPort: args.inputsByPort,\n outputs: args.outputs,\n error: undefined,\n };\n }\n\n static failed(args: {\n previous?: NodeExecutionSnapshot;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n finishedAt: string;\n inputsByPort: NodeInputsByPort;\n error: Error;\n }): NodeExecutionSnapshot {\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: args.parent,\n status: \"failed\",\n queuedAt: args.previous?.queuedAt,\n startedAt: args.previous?.startedAt,\n finishedAt: args.finishedAt,\n updatedAt: args.finishedAt,\n inputsByPort: args.inputsByPort,\n outputs: undefined,\n error: {\n message: args.error.message,\n name: args.error.name,\n stack: args.error.stack,\n },\n };\n }\n}\n","import type { NodeActivationRequest, NodeInputsByPort } from \"../types\";\n\nexport class NodeInputsByPortFactory {\n static empty(): NodeInputsByPort {\n return {};\n }\n\n static fromRequest(request: NodeActivationRequest): NodeInputsByPort {\n if (request.kind === \"multi\") {\n return request.inputsByPort;\n }\n return { in: request.input };\n }\n}\n","import type {\n ConnectionInvocationRecord,\n EngineRunCounters,\n NodeActivationRequest,\n NodeActivationScheduler,\n NodeExecutionSnapshot,\n NodeId,\n ParentExecutionRef,\n PendingNodeExecution,\n PersistedRunControlState,\n RunDataFactory,\n RunExecutionOptions,\n RunId,\n RunQueueEntry,\n RunResult,\n WorkflowExecutionRepository,\n WorkflowId,\n} from \"../types\";\n\nimport { RunQueuePlanner } from \"../planning/RunQueuePlanner\";\n\nimport { NodeEventPublisher } from \"../events/NodeEventPublisher\";\nimport { NodeExecutionSnapshotFactory } from \"./NodeExecutionSnapshotFactory\";\nimport { NodeInputsByPortFactory } from \"./NodeInputsByPortFactory\";\n\ntype PersistedRunStateRecord = NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>;\n\ntype ActivationSchedulerPort = Pick<NodeActivationScheduler, \"enqueue\"> &\n Pick<Partial<NodeActivationScheduler>, \"notifyPendingStatePersisted\">;\n\nexport type ActivationEnqueueRequest = {\n runId: RunId;\n workflowId: WorkflowId;\n startedAt: string;\n parent?: ParentExecutionRef;\n executionOptions?: RunExecutionOptions;\n control: PersistedRunControlState | undefined;\n workflowSnapshot: PersistedRunStateRecord[\"workflowSnapshot\"];\n mutableState: PersistedRunStateRecord[\"mutableState\"];\n policySnapshot: PersistedRunStateRecord[\"policySnapshot\"];\n pendingQueue: RunQueueEntry[];\n request: NodeActivationRequest;\n previousNodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;\n planner: RunQueuePlanner;\n engineCounters?: EngineRunCounters;\n connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;\n};\n\nexport class ActivationEnqueueService {\n constructor(\n private readonly activationScheduler: ActivationSchedulerPort,\n private readonly workflowExecutionRepository: WorkflowExecutionRepository,\n private readonly nodeEventPublisher: NodeEventPublisher,\n ) {}\n\n async enqueueActivation(args: ActivationEnqueueRequest): Promise<RunResult> {\n const { result, queuedSnapshot } = await this.enqueueActivationWithSnapshot(args);\n await this.nodeEventPublisher.publish(\"nodeQueued\", queuedSnapshot);\n return result;\n }\n\n async enqueueActivationWithSnapshot(\n args: ActivationEnqueueRequest,\n ): Promise<{ result: RunResult; queuedSnapshot: NodeExecutionSnapshot }> {\n const receipt = await this.activationScheduler.enqueue(args.request);\n const inputsByPort = NodeInputsByPortFactory.fromRequest(args.request);\n const itemsIn =\n args.request.kind === \"multi\"\n ? args.planner.sumItemsByPort(args.request.inputsByPort)\n : args.request.input.length;\n const enqueuedAt = new Date().toISOString();\n const pending: PendingNodeExecution = {\n runId: args.runId,\n activationId: args.request.activationId,\n workflowId: args.workflowId,\n nodeId: args.request.nodeId,\n itemsIn,\n inputsByPort,\n receiptId: receipt.receiptId,\n queue: receipt.queue,\n batchId: args.request.batchId,\n enqueuedAt,\n };\n const queuedSnapshot = NodeExecutionSnapshotFactory.queued({\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: args.request.nodeId,\n activationId: args.request.activationId,\n parent: args.parent,\n queuedAt: enqueuedAt,\n inputsByPort,\n });\n\n await this.workflowExecutionRepository.save({\n runId: args.runId,\n workflowId: args.workflowId,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n engineCounters: args.engineCounters,\n connectionInvocations: args.connectionInvocations ? [...args.connectionInvocations] : [],\n status: \"pending\",\n pending,\n queue: args.pendingQueue.map((entry) => ({ ...entry })),\n outputsByNode: (args.request.ctx.data as ReturnType<RunDataFactory[\"create\"]>).dump(),\n nodeSnapshotsByNodeId: {\n ...args.previousNodeSnapshotsByNodeId,\n [args.request.nodeId]: queuedSnapshot,\n },\n });\n this.notifyPendingStatePersisted(args.runId);\n return {\n result: { runId: args.runId, workflowId: args.workflowId, startedAt: args.startedAt, status: \"pending\", pending },\n queuedSnapshot,\n };\n }\n\n private notifyPendingStatePersisted(runId: RunId): void {\n this.activationScheduler.notifyPendingStatePersisted?.(runId);\n }\n}\n","import type { CredentialSessionService, NodeExecutionContext, NodeId, WorkflowId } from \"../types\";\n\nexport class CredentialResolverFactory {\n constructor(private readonly credentialSessions: CredentialSessionService) {}\n\n create(\n workflowId: WorkflowId,\n nodeId: NodeId,\n config?: NodeExecutionContext[\"config\"],\n ): NodeExecutionContext[\"getCredential\"] {\n const acceptedTypesBySlot = new Map<string, ReadonlyArray<string>>();\n for (const requirement of config?.getCredentialRequirements?.() ?? []) {\n acceptedTypesBySlot.set(requirement.slotKey, requirement.acceptedTypes);\n }\n\n return async <TSession = unknown>(slotKey: string): Promise<TSession> => {\n try {\n return await this.credentialSessions.getSession<TSession>({\n workflowId,\n nodeId,\n slotKey,\n });\n } catch (error) {\n const acceptedTypes = acceptedTypesBySlot.get(slotKey) ?? [];\n const message = error instanceof Error ? error.message : String(error);\n const alreadyListsAcceptedTypes =\n message.includes(\"Accepted types:\") ||\n message.includes(\"Accepted credential types:\") ||\n message.includes(\"binding points at an unknown type\");\n const acceptedTypesSuffix =\n acceptedTypes.length > 0 && !alreadyListsAcceptedTypes ? ` Accepted types: ${acceptedTypes.join(\", \")}.` : \"\";\n throw new Error(\n `Failed to resolve credential for workflow ${workflowId} node ${nodeId} slot \"${slotKey}\". ${message}${acceptedTypesSuffix}`,\n { cause: error },\n );\n }\n };\n }\n}\n","import type { AsyncSleeper } from \"./asyncSleeper.types\";\n\nexport class DefaultAsyncSleeper implements AsyncSleeper {\n sleep(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n }\n}\n","import type {\n BinaryStorage,\n ExecutionContext,\n ExecutionContextFactory,\n NodeExecutionStatePublisher,\n ParentExecutionRef,\n RunDataSnapshot,\n RunId,\n WorkflowId,\n} from \"../types\";\n\nimport {\n DefaultExecutionBinaryService,\n UnavailableBinaryStorage,\n} from \"../binaries/DefaultExecutionBinaryServiceFactory\";\n\nexport class DefaultExecutionContextFactory implements ExecutionContextFactory {\n constructor(\n private readonly binaryStorage: BinaryStorage = new UnavailableBinaryStorage(),\n private readonly currentDate: () => Date = () => new Date(),\n ) {}\n\n create(args: {\n runId: RunId;\n workflowId: WorkflowId;\n parent?: ParentExecutionRef;\n subworkflowDepth: number;\n engineMaxNodeActivations: number;\n engineMaxSubworkflowDepth: number;\n data: RunDataSnapshot;\n nodeState?: NodeExecutionStatePublisher;\n getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;\n }): ExecutionContext {\n return {\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n subworkflowDepth: args.subworkflowDepth,\n engineMaxNodeActivations: args.engineMaxNodeActivations,\n engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,\n now: this.currentDate,\n data: args.data,\n nodeState: args.nodeState,\n binary: new DefaultExecutionBinaryService(this.binaryStorage, args.workflowId, args.runId, this.currentDate),\n getCredential: args.getCredential,\n };\n }\n}\n","import type {\n ExponentialRetryPolicySpec,\n FixedRetryPolicySpec,\n RetryPolicySpec,\n} from \"../contracts/retryPolicySpec.types\";\nimport type { AsyncSleeper } from \"./asyncSleeper.types\";\n\nexport type { AsyncSleeper } from \"./asyncSleeper.types\";\n\ntype NormalizedPolicy =\n | { readonly kind: \"none\"; readonly maxAttempts: 1 }\n | { readonly kind: \"fixed\"; readonly maxAttempts: number; readonly delayMs: number }\n | {\n readonly kind: \"exponential\";\n readonly maxAttempts: number;\n readonly initialDelayMs: number;\n readonly multiplier: number;\n readonly maxDelayMs?: number;\n readonly jitter?: boolean;\n };\n\nexport class InProcessRetryRunner {\n constructor(private readonly sleeper: AsyncSleeper) {}\n\n async run<T>(policy: RetryPolicySpec | undefined, work: () => Promise<T>): Promise<T> {\n const spec = InProcessRetryRunner.normalizePolicy(policy);\n let lastError: unknown;\n for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) {\n try {\n return await work();\n } catch (error) {\n lastError = error;\n if (attempt >= spec.maxAttempts) {\n break;\n }\n const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);\n await this.sleeper.sleep(delayMs);\n }\n }\n throw lastError instanceof Error ? lastError : new Error(String(lastError));\n }\n\n private static delayAfterFailureMs(spec: NormalizedPolicy, failedAttempt: number): number {\n if (spec.kind === \"none\") {\n return 0;\n }\n if (spec.kind === \"fixed\") {\n return spec.delayMs;\n }\n const exponent = failedAttempt - 1;\n let ms = spec.initialDelayMs * Math.pow(spec.multiplier, exponent);\n if (spec.jitter === true) {\n ms *= 1 + Math.random() * 0.2;\n }\n if (spec.maxDelayMs !== undefined && ms > spec.maxDelayMs) {\n ms = spec.maxDelayMs;\n }\n return Math.max(0, Math.floor(ms));\n }\n\n private static normalizePolicy(policy: RetryPolicySpec | undefined): NormalizedPolicy {\n if (policy === undefined) {\n return { kind: \"none\", maxAttempts: 1 };\n }\n if (typeof policy !== \"object\" || policy === null) {\n return { kind: \"none\", maxAttempts: 1 };\n }\n const kind = (policy as { kind?: unknown }).kind;\n if (kind === \"none\") {\n return { kind: \"none\", maxAttempts: 1 };\n }\n if (kind === \"fixed\") {\n const p = policy as FixedRetryPolicySpec;\n const maxAttempts = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, \"fixed.maxAttempts\");\n const delayMs = InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, \"fixed.delayMs\");\n return { kind: \"fixed\", maxAttempts, delayMs };\n }\n if (kind === \"exponential\") {\n const p = policy as ExponentialRetryPolicySpec;\n return {\n kind: \"exponential\",\n maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, \"exponential.maxAttempts\"),\n initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, \"exponential.initialDelayMs\"),\n multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),\n maxDelayMs:\n p.maxDelayMs === undefined\n ? undefined\n : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, \"exponential.maxDelayMs\"),\n jitter: p.jitter === true,\n };\n }\n return { kind: \"none\", maxAttempts: 1 };\n }\n\n private static assertPositiveInt(value: unknown, label: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) {\n throw new Error(`Retry policy ${label} must be a positive integer`);\n }\n return value;\n }\n\n private static assertNonNegativeFinite(value: unknown, label: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n throw new Error(`Retry policy ${label} must be a non-negative finite number`);\n }\n return value;\n }\n\n private static assertMultiplier(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 1) {\n throw new Error(`Retry policy exponential.multiplier must be >= 1`);\n }\n return value;\n }\n}\n","import { DefaultAsyncSleeper } from \"./DefaultAsyncSleeper\";\nimport { InProcessRetryRunner } from \"./InProcessRetryRunner\";\n\nexport class InProcessRetryRunnerFactory {\n create(defaultAsyncSleeper: DefaultAsyncSleeper): InProcessRetryRunner {\n return new InProcessRetryRunner(defaultAsyncSleeper);\n }\n}\n","import type {\n ActivationIdFactory,\n ExecutionContextFactory,\n Items,\n NodeActivationId,\n NodeActivationRequest,\n NodeExecutionContext,\n NodeId,\n ParentExecutionRef,\n RunDataFactory,\n RunExecutionOptions,\n RunId,\n WorkflowId,\n} from \"../types\";\n\nimport type { PlannedActivation } from \"../planning/RunQueuePlanner\";\n\nimport { CredentialResolverFactory } from \"./CredentialResolverFactory\";\n\ntype NodeExecutionDefinition = Readonly<{ id: NodeId; config: NodeExecutionContext[\"config\"] }>;\n\ntype NodeActivationContextArgs = {\n runId: RunId;\n workflowId: WorkflowId;\n parent?: ParentExecutionRef;\n executionOptions?: RunExecutionOptions;\n base: ReturnType<ExecutionContextFactory[\"create\"]>;\n data: ReturnType<RunDataFactory[\"create\"]>;\n};\n\nexport type SingleDefinitionActivationRequest = NodeActivationContextArgs & {\n definition: NodeExecutionDefinition;\n batchId: string;\n input: Items;\n};\n\nexport type PlannedNodeActivationRequest = NodeActivationContextArgs & {\n next: PlannedActivation;\n nodeDefinition: NodeExecutionDefinition;\n};\n\n/**\n * Builds {@link NodeActivationRequest} values shared by workflow starters and continuation.\n */\nexport class NodeActivationRequestComposer {\n constructor(\n private readonly activationIdFactory: ActivationIdFactory,\n private readonly credentialResolverFactory: CredentialResolverFactory,\n ) {}\n\n createSingleFromDefinition(\n args: SingleDefinitionActivationRequest,\n ): Extract<NodeActivationRequest, { kind: \"single\" }> {\n return this.createSingleFromDefinitionWithActivation({\n ...args,\n activationId: this.activationIdFactory.makeActivationId(),\n });\n }\n\n createSingleFromDefinitionWithActivation(\n args: SingleDefinitionActivationRequest & Readonly<{ activationId: NodeActivationId }>,\n ): Extract<NodeActivationRequest, { kind: \"single\" }> {\n const ctx = this.createNodeExecutionContext(args, args.definition, args.activationId);\n return {\n kind: \"single\",\n runId: args.runId,\n activationId: args.activationId,\n workflowId: args.workflowId,\n nodeId: args.definition.id,\n parent: args.parent,\n executionOptions: args.executionOptions,\n batchId: args.batchId,\n input: args.input,\n ctx,\n };\n }\n\n createFromPlannedActivation(args: PlannedNodeActivationRequest): NodeActivationRequest {\n const activationId = this.activationIdFactory.makeActivationId();\n const ctx = this.createNodeExecutionContext(args, args.nodeDefinition, activationId);\n if (args.next.kind === \"multi\") {\n return {\n kind: \"multi\",\n runId: args.runId,\n activationId,\n workflowId: args.workflowId,\n nodeId: args.nodeDefinition.id,\n parent: args.parent,\n executionOptions: args.executionOptions,\n batchId: args.next.batchId,\n inputsByPort: args.next.inputsByPort,\n ctx,\n };\n }\n return {\n kind: \"single\",\n runId: args.runId,\n activationId,\n workflowId: args.workflowId,\n nodeId: args.nodeDefinition.id,\n parent: args.parent,\n executionOptions: args.executionOptions,\n batchId: args.next.batchId,\n input: args.next.input,\n ctx,\n };\n }\n\n private createNodeExecutionContext(\n args: NodeActivationContextArgs,\n definition: NodeExecutionDefinition,\n activationId: string,\n ): NodeExecutionContext {\n return {\n ...args.base,\n data: args.data,\n nodeId: definition.id,\n activationId,\n config: definition.config,\n binary: args.base.binary.forNode({ nodeId: definition.id, activationId }),\n getCredential: this.credentialResolverFactory.create(args.workflowId, definition.id, definition.config),\n };\n }\n}\n","import type { MultiInputNode, Node, NodeActivationRequest, NodeOutputs, WorkflowNodeInstanceFactory } from \"../types\";\n\nimport { InProcessRetryRunner } from \"./InProcessRetryRunner\";\n\nexport class NodeExecutor {\n constructor(\n private readonly nodeInstanceFactory: WorkflowNodeInstanceFactory,\n private readonly retryRunner: InProcessRetryRunner,\n ) {}\n\n async execute(request: NodeActivationRequest): Promise<NodeOutputs> {\n const policy = request.ctx.config.retryPolicy;\n return await this.retryRunner.run(policy, async () => {\n const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);\n if (request.kind === \"multi\") {\n return await this.executeMultiInputNode(request, nodeInstance);\n }\n return await this.executeSingleInputNode(request, nodeInstance);\n });\n }\n\n private async executeMultiInputNode(\n request: Extract<NodeActivationRequest, { kind: \"multi\" }>,\n node: unknown,\n ): Promise<NodeOutputs> {\n const multiInputNode = node as MultiInputNode;\n if (typeof (multiInputNode as { executeMulti?: unknown }).executeMulti !== \"function\") {\n throw new Error(`Node ${request.nodeId} does not support executeMulti but received multi-input activation`);\n }\n return await multiInputNode.executeMulti(request.inputsByPort, request.ctx as any);\n }\n\n private async executeSingleInputNode(\n request: Extract<NodeActivationRequest, { kind: \"single\" }>,\n node: unknown,\n ): Promise<NodeOutputs> {\n const singleInputNode = node as Node;\n if (typeof (singleInputNode as { execute?: unknown }).execute !== \"function\") {\n throw new Error(`Node ${request.nodeId} does not support execute but received single-input activation`);\n }\n return await singleInputNode.execute(request.input, request.ctx as any);\n }\n}\n","import type { WorkflowNodeInstanceFactory } from \"../types\";\n\nimport { InProcessRetryRunner } from \"./InProcessRetryRunner\";\nimport { NodeExecutor } from \"./NodeExecutor\";\n\nexport class NodeExecutorFactory {\n create(workflowNodeInstanceFactory: WorkflowNodeInstanceFactory, retryRunner: InProcessRetryRunner): NodeExecutor {\n return new NodeExecutor(workflowNodeInstanceFactory, retryRunner);\n }\n}\n","export class MissingRuntimeExecutionMarker {\n isMarked(config: unknown): boolean {\n return Boolean((config as Partial<{ missingRuntime: boolean }> | undefined)?.missingRuntime);\n }\n}\n","export class MissingRuntimeNodeToken {}\n","import type { NodeConfigBase } from \"../types\";\n\nimport { MissingRuntimeNodeToken } from \"./MissingRuntimeNodeToken\";\n\nexport class MissingRuntimeNodeConfig implements NodeConfigBase {\n readonly kind = \"node\" as const;\n readonly type = MissingRuntimeNodeToken;\n\n constructor(\n public readonly name: string,\n public readonly missingTokenId?: string,\n public readonly missingRuntime = true,\n ) {}\n}\n","export class MissingRuntimeTriggerToken {}\n","import type { NodeConfigBase } from \"../types\";\n\nimport { MissingRuntimeTriggerToken } from \"./MissingRuntimeTriggerToken\";\n\nexport class MissingRuntimeTriggerConfig implements NodeConfigBase {\n readonly kind = \"trigger\" as const;\n readonly type = MissingRuntimeTriggerToken;\n\n constructor(\n public readonly name: string,\n public readonly missingTokenId?: string,\n public readonly missingRuntime = true,\n ) {}\n}\n","import type { NodeDefinition, PersistedWorkflowSnapshotNode } from \"../types\";\n\nimport { MissingRuntimeNodeConfig } from \"./MissingRuntimeNodeConfig\";\nimport { MissingRuntimeNodeToken } from \"./MissingRuntimeNodeToken\";\nimport { MissingRuntimeTriggerConfig } from \"./MissingRuntimeTriggerConfig\";\nimport { MissingRuntimeTriggerToken } from \"./MissingRuntimeTriggerToken\";\n\nexport class MissingRuntimeFallbacks {\n createDefinition(snapshotNode: PersistedWorkflowSnapshotNode): NodeDefinition {\n if (snapshotNode.kind === \"trigger\") {\n return {\n id: snapshotNode.id,\n kind: \"trigger\",\n name: snapshotNode.name,\n type: MissingRuntimeTriggerToken,\n config: new MissingRuntimeTriggerConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId),\n };\n }\n return {\n id: snapshotNode.id,\n kind: \"node\",\n name: snapshotNode.name,\n type: MissingRuntimeNodeToken,\n config: new MissingRuntimeNodeConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId),\n };\n }\n}\n","import type { Items, Node, NodeOutputs } from \"../types\";\n\nimport { MissingRuntimeNodeConfig } from \"./MissingRuntimeNodeConfig\";\n\nexport class MissingRuntimeNode implements Node<MissingRuntimeNodeConfig> {\n readonly kind = \"node\" as const;\n readonly outputPorts = [\"main\"] as const;\n\n async execute(items: Items): Promise<NodeOutputs> {\n return { main: items };\n }\n}\n","import type { ExecutableTriggerNode, Items, NodeOutputs, TriggerSetupContext } from \"../types\";\n\nimport { MissingRuntimeTriggerConfig } from \"./MissingRuntimeTriggerConfig\";\n\nexport class MissingRuntimeTrigger implements ExecutableTriggerNode<MissingRuntimeTriggerConfig> {\n readonly kind = \"trigger\" as const;\n readonly outputPorts = [\"main\"] as const;\n\n async setup(_ctx: TriggerSetupContext<MissingRuntimeTriggerConfig>): Promise<undefined> {\n return undefined;\n }\n\n async execute(items: Items): Promise<NodeOutputs> {\n return { main: items };\n }\n}\n","import type { TypeToken } from \"../di\";\n\nimport { getPersistedRuntimeTypeMetadata } from \"../runtime-types/runtimeTypeDecorators.types\";\n\nimport type { PersistedTokenId } from \"../types\";\n\nexport class PersistedRuntimeTypeIdFactory {\n static fromMetadata(args: Readonly<{ type: TypeToken<unknown> }>): PersistedTokenId | undefined {\n const metadata = getPersistedRuntimeTypeMetadata(args.type);\n if (!metadata) {\n return undefined;\n }\n const packageName = metadata.packageName;\n if (!packageName) {\n return undefined;\n }\n return `${packageName}::${metadata.persistedName}` as PersistedTokenId;\n }\n}\n","import type { TypeToken } from \"../di\";\n\nimport type { PersistedTokenId, WorkflowDefinition } from \"../types\";\n\nimport { PersistedRuntimeTypeIdFactory } from \"./PersistedRuntimeTypeIdFactory\";\n\nexport class PersistedWorkflowTokenRegistry {\n private readonly tokensById = new Map<PersistedTokenId, TypeToken<unknown>>();\n private readonly tokenIdsByToken = new Map<TypeToken<unknown>, PersistedTokenId>();\n\n /**\n * Register a token with its package ID. Token ID is inferred as `packageId::tokenName`.\n */\n register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): PersistedTokenId {\n const tokenName = persistedNameOverride ?? this.displayNameForTypeToken(type);\n const tokenId = `${packageId}::${tokenName}` as PersistedTokenId;\n this.tokensById.set(tokenId, type);\n this.tokenIdsByToken.set(type, tokenId);\n return tokenId;\n }\n\n /**\n * Register all decorated runtime types discovered in workflows.\n */\n registerFromWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void {\n for (const workflow of workflows) {\n for (const node of workflow.nodes) {\n this.registerDecoratedType(node.type);\n this.registerDecoratedType(node.config.type);\n this.registerNestedTypes(node.config);\n }\n }\n }\n\n private registerDecoratedType(type: TypeToken<unknown>): void {\n if (this.tokenIdsByToken.has(type)) {\n return;\n }\n const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });\n if (!tokenId) {\n return;\n }\n this.tokensById.set(tokenId, type);\n this.tokenIdsByToken.set(type, tokenId);\n }\n\n private registerNestedTypes(value: unknown): void {\n if (Array.isArray(value)) {\n for (const entry of value) this.registerNestedTypes(entry);\n return;\n }\n if (!value || typeof value !== \"object\") return;\n const record = value as Record<string, unknown>;\n const type = this.asTypeToken(record.type);\n if (type) this.registerDecoratedType(type);\n for (const v of Object.values(record)) this.registerNestedTypes(v);\n }\n\n private displayNameForTypeToken(token: TypeToken<unknown>): string {\n if (typeof token === \"function\" && token.name) return token.name;\n if (typeof token === \"string\") return token;\n return \"\";\n }\n\n private asTypeToken(value: unknown): TypeToken<unknown> | undefined {\n if (typeof value === \"function\" || typeof value === \"string\" || typeof value === \"symbol\") {\n return value as TypeToken<unknown>;\n }\n return undefined;\n }\n\n getTokenId(token: TypeToken<unknown>): PersistedTokenId | undefined {\n const existing = this.tokenIdsByToken.get(token);\n if (existing) {\n return existing;\n }\n const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });\n if (!tokenId) {\n return undefined;\n }\n this.tokensById.set(tokenId, token);\n this.tokenIdsByToken.set(token, tokenId);\n return tokenId;\n }\n\n resolve(tokenId: PersistedTokenId): TypeToken<unknown> | undefined {\n return this.tokensById.get(tokenId);\n }\n}\n","import type { TypeToken } from \"../di\";\nimport type {\n NodeDefinition,\n PersistedWorkflowSnapshot,\n PersistedWorkflowTokenRegistryLike,\n WorkflowDefinition,\n WorkflowId,\n WorkflowRepository,\n} from \"../types\";\n\nimport { MissingRuntimeFallbacks } from \"./MissingRuntimeFallbacksFactory\";\nimport { WorkflowSnapshotCodec } from \"./WorkflowSnapshotCodec\";\n\nexport class WorkflowSnapshotResolver {\n constructor(\n private readonly workflowRepository: WorkflowRepository,\n private readonly tokenRegistry: PersistedWorkflowTokenRegistryLike,\n private readonly codec: WorkflowSnapshotCodec,\n private readonly missingRuntimeFallbacks: MissingRuntimeFallbacks,\n ) {}\n\n resolve(args: {\n workflowId: WorkflowId;\n workflowSnapshot?: PersistedWorkflowSnapshot;\n }): WorkflowDefinition | undefined {\n const liveWorkflow = this.workflowRepository.get(args.workflowId);\n if (!args.workflowSnapshot) {\n return liveWorkflow;\n }\n if (!liveWorkflow) {\n return this.rebuildWorkflow(args.workflowSnapshot, undefined);\n }\n return this.rebuildWorkflow(args.workflowSnapshot, liveWorkflow);\n }\n\n private rebuildWorkflow(\n snapshot: PersistedWorkflowSnapshot,\n liveWorkflow: WorkflowDefinition | undefined,\n ): WorkflowDefinition {\n const liveNodesById = new Map((liveWorkflow?.nodes ?? []).map((node) => [node.id, node] as const));\n const nodes = snapshot.nodes.map((snapshotNode) => {\n const liveNode = liveNodesById.get(snapshotNode.id);\n if (!this.isCompatibleLiveNode(liveNode, snapshotNode)) {\n return this.missingRuntimeFallbacks.createDefinition(snapshotNode);\n }\n return {\n id: snapshotNode.id,\n kind: snapshotNode.kind,\n name: snapshotNode.name ?? liveNode.name,\n type: liveNode.type,\n config: this.codec.hydrate(snapshotNode, liveNode.config),\n } satisfies NodeDefinition;\n });\n const nodeIds = new Set(nodes.map((node) => node.id));\n const connectionsFromSnapshot =\n snapshot.connections\n ?.map((connection) => ({\n ...connection,\n childNodeIds: connection.childNodeIds.filter((childId) => nodeIds.has(childId)),\n }))\n .filter((connection) => connection.childNodeIds.length > 0) ?? [];\n return {\n id: snapshot.id,\n name: snapshot.name,\n nodes,\n edges: snapshot.edges.filter((edge) => nodeIds.has(edge.from.nodeId) && nodeIds.has(edge.to.nodeId)),\n ...(connectionsFromSnapshot.length > 0 ? { connections: connectionsFromSnapshot } : {}),\n ...(liveWorkflow?.discoveryPathSegments !== undefined\n ? { discoveryPathSegments: liveWorkflow.discoveryPathSegments }\n : {}),\n };\n }\n\n private isCompatibleLiveNode(\n liveNode: WorkflowDefinition[\"nodes\"][number] | undefined,\n snapshotNode: PersistedWorkflowSnapshot[\"nodes\"][number],\n ): liveNode is WorkflowDefinition[\"nodes\"][number] {\n if (!liveNode || liveNode.kind !== snapshotNode.kind) {\n return false;\n }\n if (!snapshotNode.nodeTokenId || !snapshotNode.configTokenId) {\n throw new Error(`Persisted workflow snapshot node \"${snapshotNode.id}\" is missing stable token ids.`);\n }\n const liveNodeTokenId = this.resolveLiveTokenId(liveNode.type);\n const liveConfigTokenId = this.resolveLiveTokenId(liveNode.config.type);\n return liveNodeTokenId === snapshotNode.nodeTokenId && liveConfigTokenId === snapshotNode.configTokenId;\n }\n\n private resolveLiveTokenId(type: TypeToken<unknown>): string | undefined {\n const registeredTokenId = this.tokenRegistry.getTokenId(type);\n if (registeredTokenId) {\n return registeredTokenId;\n }\n if (typeof type === \"function\" && type.name) {\n return type.name;\n }\n if (typeof type === \"string\") {\n return type;\n }\n return undefined;\n }\n}\n","import type { TypeToken } from \"../di\";\nimport type { NodeId, NodeResolver, WorkflowDefinition, WorkflowNodeInstanceFactory } from \"../types\";\n\nimport { MissingRuntimeNode, MissingRuntimeTrigger } from \"../workflowSnapshots\";\nimport { MissingRuntimeNodeToken } from \"../workflowSnapshots/MissingRuntimeNodeToken\";\nimport { MissingRuntimeTriggerToken } from \"../workflowSnapshots/MissingRuntimeTriggerToken\";\n\nexport class NodeInstanceFactory implements WorkflowNodeInstanceFactory {\n constructor(private readonly nodeResolver: NodeResolver) {}\n\n createNodes(workflow: WorkflowDefinition): Map<NodeId, unknown> {\n const nodeInstances = new Map<NodeId, unknown>();\n for (const definition of workflow.nodes) {\n nodeInstances.set(definition.id, this.createNode(definition));\n }\n return nodeInstances;\n }\n\n createNode(definition: WorkflowDefinition[\"nodes\"][number]): unknown {\n return this.createByType(definition.type);\n }\n\n createByType(type: TypeToken<unknown>): unknown {\n if (type === MissingRuntimeNodeToken) {\n return new MissingRuntimeNode();\n }\n if (type === MissingRuntimeTriggerToken) {\n return new MissingRuntimeTrigger();\n }\n return this.nodeResolver.resolve(type);\n }\n}\n","import type { NodeResolver } from \"../types\";\n\nimport { NodeInstanceFactory } from \"./NodeInstanceFactory\";\n\nexport class NodeInstanceFactoryFactory {\n create(nodeResolver: NodeResolver): NodeInstanceFactory {\n return new NodeInstanceFactory(nodeResolver);\n }\n}\n","import type {\n ConnectionInvocationAppendArgs,\n ConnectionInvocationRecord,\n NodeActivationId,\n NodeExecutionSnapshot,\n NodeExecutionStatePublisher,\n NodeId,\n NodeInputsByPort,\n NodeOutputs,\n ParentExecutionRef,\n RunId,\n WorkflowExecutionRepository,\n WorkflowId,\n} from \"../types\";\n\nimport { NodeInputsByPortFactory } from \"./NodeInputsByPortFactory\";\nimport { NodeExecutionSnapshotFactory } from \"./NodeExecutionSnapshotFactory\";\n\nexport class NodeRunStateWriter implements NodeExecutionStatePublisher {\n private chain: Promise<void> = Promise.resolve();\n\n constructor(\n private readonly workflowExecutionRepository: WorkflowExecutionRepository,\n private readonly runId: RunId,\n private readonly workflowId: WorkflowId,\n private readonly parent: ParentExecutionRef | undefined,\n private readonly publishNodeEvent: (\n kind: \"nodeQueued\" | \"nodeStarted\" | \"nodeCompleted\" | \"nodeFailed\",\n snapshot: NodeExecutionSnapshot,\n ) => Promise<void>,\n ) {}\n\n markQueued(args: {\n nodeId: NodeId;\n activationId?: NodeActivationId;\n inputsByPort?: NodeInputsByPort;\n }): Promise<void> {\n return this.enqueue(async () => {\n const state = await this.loadState();\n const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];\n const queuedAt = new Date().toISOString();\n const snapshot = NodeExecutionSnapshotFactory.queued({\n runId: this.runId,\n workflowId: this.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,\n parent: this.parent,\n queuedAt,\n inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n });\n await this.saveSnapshot(state, snapshot);\n await this.publishNodeEvent(\"nodeQueued\", snapshot);\n });\n }\n\n markRunning(args: {\n nodeId: NodeId;\n activationId?: NodeActivationId;\n inputsByPort?: NodeInputsByPort;\n }): Promise<void> {\n return this.enqueue(async () => {\n const state = await this.loadState();\n const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];\n const startedAt = new Date().toISOString();\n const snapshot = NodeExecutionSnapshotFactory.running({\n previous,\n runId: this.runId,\n workflowId: this.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,\n parent: this.parent,\n startedAt,\n inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n });\n await this.saveSnapshot(state, snapshot);\n await this.publishNodeEvent(\"nodeStarted\", snapshot);\n });\n }\n\n markCompleted(args: {\n nodeId: NodeId;\n activationId?: NodeActivationId;\n inputsByPort?: NodeInputsByPort;\n outputs?: NodeOutputs;\n }): Promise<void> {\n return this.enqueue(async () => {\n const state = await this.loadState();\n const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];\n const finishedAt = new Date().toISOString();\n const snapshot = NodeExecutionSnapshotFactory.completed({\n previous,\n runId: this.runId,\n workflowId: this.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,\n parent: this.parent,\n finishedAt,\n inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n outputs: args.outputs ?? previous?.outputs ?? {},\n });\n await this.saveSnapshot(state, snapshot);\n await this.publishNodeEvent(\"nodeCompleted\", snapshot);\n });\n }\n\n markFailed(args: {\n nodeId: NodeId;\n activationId?: NodeActivationId;\n inputsByPort?: NodeInputsByPort;\n error: Error;\n }): Promise<void> {\n return this.enqueue(async () => {\n const state = await this.loadState();\n const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];\n const finishedAt = new Date().toISOString();\n const snapshot = NodeExecutionSnapshotFactory.failed({\n previous,\n runId: this.runId,\n workflowId: this.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,\n parent: this.parent,\n finishedAt,\n inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n error: args.error,\n });\n await this.saveSnapshot(state, snapshot);\n await this.publishNodeEvent(\"nodeFailed\", snapshot);\n });\n }\n\n appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void> {\n return this.enqueue(async () => {\n const state = await this.loadState();\n const updatedAt = new Date().toISOString();\n const record: ConnectionInvocationRecord = {\n invocationId: args.invocationId,\n runId: this.runId,\n workflowId: this.workflowId,\n connectionNodeId: args.connectionNodeId,\n parentAgentNodeId: args.parentAgentNodeId,\n parentAgentActivationId: args.parentAgentActivationId,\n status: args.status,\n managedInput: args.managedInput,\n managedOutput: args.managedOutput,\n error: args.error,\n queuedAt: args.queuedAt,\n startedAt: args.startedAt,\n finishedAt: args.finishedAt,\n updatedAt,\n };\n await this.workflowExecutionRepository.save({\n ...state,\n connectionInvocations: [...(state.connectionInvocations ?? []), record],\n });\n });\n }\n\n private enqueue(work: () => Promise<void>): Promise<void> {\n const next = this.chain.then(work);\n this.chain = next.catch(() => undefined);\n return next;\n }\n\n private async loadState(): Promise<NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>> {\n const state = await this.workflowExecutionRepository.load(this.runId);\n if (!state) {\n throw new Error(`Unknown runId: ${this.runId}`);\n }\n return state;\n }\n\n private async saveSnapshot(\n state: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>,\n snapshot: NodeExecutionSnapshot,\n ): Promise<void> {\n await this.workflowExecutionRepository.save({\n ...state,\n nodeSnapshotsByNodeId: {\n ...(state.nodeSnapshotsByNodeId ?? {}),\n [snapshot.nodeId]: snapshot,\n },\n });\n }\n}\n","import type {\n NodeExecutionStatePublisher,\n ParentExecutionRef,\n RunId,\n WorkflowExecutionRepository,\n WorkflowId,\n} from \"../types\";\n\nimport { NodeEventPublisher } from \"../events/NodeEventPublisher\";\nimport { NodeRunStateWriter } from \"./NodeRunStateWriter\";\n\nexport class NodeRunStateWriterFactory {\n constructor(\n private readonly workflowExecutionRepository: WorkflowExecutionRepository,\n private readonly nodeEventPublisher: NodeEventPublisher,\n ) {}\n\n create(runId: RunId, workflowId: WorkflowId, parent: ParentExecutionRef | undefined): NodeExecutionStatePublisher {\n return new NodeRunStateWriter(\n this.workflowExecutionRepository,\n runId,\n workflowId,\n parent,\n async (kind, snapshot) => {\n await this.nodeEventPublisher.publish(kind, snapshot);\n },\n );\n }\n}\n","import type { EngineRunCounters, PersistedRunState, RunQueueEntry } from \"../types\";\n\n/**\n * Merges common terminal-run fields onto a loaded {@link PersistedRunState} without repeating object literals.\n */\nexport class PersistedRunStateTerminalBuilder {\n mergeTerminal(args: {\n state: PersistedRunState;\n engineCounters: EngineRunCounters;\n status: \"completed\" | \"failed\";\n queue: RunQueueEntry[];\n outputsByNode: PersistedRunState[\"outputsByNode\"];\n nodeSnapshotsByNodeId: NonNullable<PersistedRunState[\"nodeSnapshotsByNodeId\"]>;\n }): PersistedRunState {\n return {\n ...args.state,\n engineCounters: args.engineCounters,\n status: args.status,\n pending: undefined,\n queue: args.queue,\n outputsByNode: args.outputsByNode,\n nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,\n };\n }\n}\n","import type {\n Items,\n NodeActivationId,\n NodeExecutionSnapshot,\n NodeId,\n NodeInputsByPort,\n NodeOutputs,\n ParentExecutionRef,\n PersistedRunControlState,\n RunCurrentState,\n RunDataFactory,\n RunId,\n RunQueueEntry,\n WorkflowExecutionRepository,\n WorkflowDefinition,\n WorkflowId,\n} from \"../types\";\n\nimport { WorkflowExecutableNodeClassifierFactory } from \"../workflow/definition/WorkflowExecutableNodeClassifierFactory\";\nimport { RunQueuePlanner } from \"../planning/RunQueuePlanner\";\n\nimport { MissingRuntimeExecutionMarker } from \"../workflowSnapshots/MissingRuntimeExecutionMarker\";\nimport { NodeExecutionSnapshotFactory } from \"./NodeExecutionSnapshotFactory\";\nimport { NodeInputsByPortFactory } from \"./NodeInputsByPortFactory\";\n\nexport class RunStateSemantics {\n constructor(private readonly missingRuntimeExecutionMarker: MissingRuntimeExecutionMarker) {}\n\n isStopConditionSatisfied(stopCondition: PersistedRunControlState[\"stopCondition\"], nodeId: NodeId): boolean {\n if (!stopCondition || stopCondition.kind === \"workflowCompleted\") {\n return false;\n }\n return stopCondition.nodeId === nodeId;\n }\n\n resolveResultOutputs(\n workflow: WorkflowDefinition,\n stopCondition: PersistedRunControlState[\"stopCondition\"],\n outputsByNode: Record<NodeId, NodeOutputs>,\n ): Items {\n if (stopCondition?.kind === \"nodeCompleted\") {\n return outputsByNode[stopCondition.nodeId]?.main ?? [];\n }\n const lastNodeId =\n WorkflowExecutableNodeClassifierFactory.create(workflow).lastExecutableNodeIdInDefinitionOrder(workflow);\n return outputsByNode[lastNodeId]?.main ?? [];\n }\n\n applySkippedSnapshots(args: {\n runId: RunId;\n workflowId: WorkflowId;\n parent?: ParentExecutionRef;\n currentState: RunCurrentState;\n skippedNodeIds: ReadonlyArray<NodeId>;\n preservedPinnedNodeIds: ReadonlyArray<NodeId>;\n finishedAt: string;\n }): Record<NodeId, NodeExecutionSnapshot> {\n const snapshots = { ...args.currentState.nodeSnapshotsByNodeId };\n const skippedPinnedNodeIds = new Set<NodeId>(\n args.preservedPinnedNodeIds.filter((nodeId) => args.skippedNodeIds.includes(nodeId)),\n );\n for (const nodeId of args.skippedNodeIds) {\n if (args.currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort) {\n skippedPinnedNodeIds.add(nodeId);\n }\n }\n for (const nodeId of skippedPinnedNodeIds) {\n const previous = snapshots[nodeId];\n snapshots[nodeId] = NodeExecutionSnapshotFactory.completed({\n previous,\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId,\n activationId: previous?.activationId ?? `synthetic_${nodeId}`,\n parent: args.parent,\n finishedAt: args.finishedAt,\n inputsByPort: previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n outputs: args.currentState.outputsByNode[nodeId] ?? {},\n fromPinnedOutput: true,\n });\n }\n return snapshots;\n }\n\n applyPinnedQueueSkips(args: {\n runId: RunId;\n workflowId: WorkflowId;\n parent?: ParentExecutionRef;\n mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"];\n planner: RunQueuePlanner;\n queue: RunQueueEntry[];\n data: ReturnType<RunDataFactory[\"create\"]>;\n nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;\n finishedAt: string;\n }): void {\n let changed = true;\n while (changed) {\n changed = false;\n for (let index = 0; index < args.queue.length; index += 1) {\n const queueEntry = args.queue[index]!;\n const pinnedOutputs = args.mutableState?.nodesById?.[queueEntry.nodeId]?.pinnedOutputsByPort;\n if (!pinnedOutputs) {\n continue;\n }\n args.queue.splice(index, 1);\n const previous = args.nodeSnapshotsByNodeId[queueEntry.nodeId];\n args.nodeSnapshotsByNodeId[queueEntry.nodeId] = NodeExecutionSnapshotFactory.completed({\n previous,\n runId: args.runId,\n workflowId: args.workflowId,\n nodeId: queueEntry.nodeId,\n activationId: previous?.activationId ?? `synthetic_${queueEntry.nodeId}`,\n parent: args.parent,\n finishedAt: args.finishedAt,\n inputsByPort: this.resolveQueueEntryInputsByPort(queueEntry),\n outputs: pinnedOutputs,\n fromPinnedOutput: true,\n });\n args.data.setOutputs(queueEntry.nodeId, pinnedOutputs);\n args.planner.applyOutputs(args.queue, {\n fromNodeId: queueEntry.nodeId,\n outputs: pinnedOutputs as any,\n batchId: queueEntry.batchId ?? \"batch_1\",\n });\n changed = true;\n break;\n }\n }\n }\n\n createFinishedSnapshot(args: {\n workflow: WorkflowDefinition;\n previous?: NodeExecutionSnapshot;\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n activationId: NodeActivationId;\n parent?: ParentExecutionRef;\n finishedAt: string;\n inputsByPort: NodeInputsByPort;\n outputs: NodeOutputs;\n }): NodeExecutionSnapshot {\n const definition = args.workflow.nodes.find((node) => node.id === args.nodeId);\n if (this.missingRuntimeExecutionMarker.isMarked(definition?.config)) {\n return NodeExecutionSnapshotFactory.skipped(args);\n }\n return NodeExecutionSnapshotFactory.completed(args);\n }\n\n private resolveQueueEntryInputsByPort(queueEntry: RunQueueEntry): NodeInputsByPort {\n if (queueEntry.collect) {\n return queueEntry.collect.received;\n }\n return {\n [queueEntry.toInput ?? \"in\"]: queueEntry.input,\n };\n }\n}\n","import type {\n ExecutionContextFactory,\n NodeExecutionStatePublisher,\n NodeId,\n ParentExecutionRef,\n RunDataFactory,\n RunId,\n WorkflowId,\n} from \"../types\";\n\nimport { CredentialResolverFactory } from \"./CredentialResolverFactory\";\n\n/**\n * Shared {@link ExecutionContextFactory#create} wiring for workflow runners (base context before node-specific fields).\n */\nexport class WorkflowRunExecutionContextFactory {\n constructor(\n private readonly executionContextFactory: ExecutionContextFactory,\n private readonly credentialResolverFactory: CredentialResolverFactory,\n ) {}\n\n create(args: {\n runId: RunId;\n workflowId: WorkflowId;\n nodeId: NodeId;\n parent?: ParentExecutionRef;\n subworkflowDepth: number;\n engineMaxNodeActivations: number;\n engineMaxSubworkflowDepth: number;\n data: ReturnType<RunDataFactory[\"create\"]>;\n nodeState?: NodeExecutionStatePublisher;\n }) {\n return this.executionContextFactory.create({\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n subworkflowDepth: args.subworkflowDepth,\n engineMaxNodeActivations: args.engineMaxNodeActivations,\n engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,\n data: args.data,\n nodeState: args.nodeState,\n getCredential: this.credentialResolverFactory.create(args.workflowId, args.nodeId),\n });\n }\n}\n","import type { InputPortKey, NodeId, OutputPortKey, WorkflowDefinition } from \"../types\";\nimport { WorkflowExecutableNodeClassifierFactory } from \"../workflow/definition/WorkflowExecutableNodeClassifierFactory\";\n\ntype NodeDef = WorkflowDefinition[\"nodes\"][number];\n\nexport class WorkflowTopology {\n private constructor(\n public readonly defsById: ReadonlyMap<NodeId, NodeDef>,\n public readonly outgoingByNode: ReadonlyMap<\n NodeId,\n ReadonlyArray<Readonly<{ output: OutputPortKey; to: Readonly<{ nodeId: NodeId; input: InputPortKey }> }>>\n >,\n public readonly incomingByNode: ReadonlyMap<\n NodeId,\n ReadonlyArray<Readonly<{ from: Readonly<{ nodeId: NodeId; output: OutputPortKey }>; input: InputPortKey }>>\n >,\n public readonly expectedInputsByNode: ReadonlyMap<NodeId, ReadonlyArray<InputPortKey>>,\n public readonly rootNodeIds: ReadonlyArray<NodeId>,\n ) {}\n\n static fromWorkflow(wf: WorkflowDefinition): WorkflowTopology {\n const classifier = WorkflowExecutableNodeClassifierFactory.create(wf);\n const defs = new Map<NodeId, NodeDef>();\n for (const n of wf.nodes) {\n if (classifier.isExecutableNodeId(n.id)) defs.set(n.id, n);\n }\n\n const outgoing = new Map<\n NodeId,\n Array<Readonly<{ output: OutputPortKey; to: Readonly<{ nodeId: NodeId; input: InputPortKey }> }>>\n >();\n for (const e of wf.edges) {\n if (!classifier.isExecutableNodeId(e.from.nodeId) || !classifier.isExecutableNodeId(e.to.nodeId)) {\n continue;\n }\n const list = outgoing.get(e.from.nodeId) ?? [];\n list.push({ output: e.from.output, to: { nodeId: e.to.nodeId, input: e.to.input } });\n outgoing.set(e.from.nodeId, list);\n }\n\n const incomingByNode = new Map<\n NodeId,\n Array<Readonly<{ from: Readonly<{ nodeId: NodeId; output: OutputPortKey }>; input: InputPortKey }>>\n >();\n for (const e of wf.edges) {\n if (!classifier.isExecutableNodeId(e.from.nodeId) || !classifier.isExecutableNodeId(e.to.nodeId)) {\n continue;\n }\n const list = incomingByNode.get(e.to.nodeId) ?? [];\n list.push({ from: { nodeId: e.from.nodeId, output: e.from.output }, input: e.to.input });\n incomingByNode.set(e.to.nodeId, list);\n }\n\n const expected = new Map<NodeId, InputPortKey[]>();\n for (const [toNodeId, inputs] of incomingByNode.entries()) {\n const counts = new Map<InputPortKey, number>();\n for (const edge of inputs) counts.set(edge.input, (counts.get(edge.input) ?? 0) + 1);\n for (const [k, n] of counts.entries()) {\n if (n > 1) throw new Error(`Node ${toNodeId} has multiple edges into input '${k}'. Use a Merge node upstream.`);\n }\n\n const order: InputPortKey[] = [];\n const seen = new Set<InputPortKey>();\n for (const edge of inputs) {\n if (seen.has(edge.input)) continue;\n seen.add(edge.input);\n order.push(edge.input);\n }\n expected.set(toNodeId, order);\n }\n\n const rootNodeIds = wf.nodes\n .filter((node) => classifier.isExecutableNodeId(node.id) && !incomingByNode.has(node.id))\n .map((node) => node.id);\n return new WorkflowTopology(defs, outgoing, incomingByNode, expected, rootNodeIds);\n }\n}\n","import type {\n ActivationIdFactory,\n NodeActivationId,\n NodeExecutionContext,\n NodeId,\n NodeInputsByPort,\n NodeOutputs,\n PersistedRunState,\n RunDataFactory,\n RunId,\n RunQueueEntry,\n RunResult,\n WorkflowExecutionRepository,\n WebhookControlSignal,\n WebhookRunResult,\n WorkflowDefinition,\n WorkflowId,\n WorkflowSnapshotResolver,\n} from \"../types\";\n\nimport { WorkflowTopology } from \"../planning/WorkflowTopologyPlanner\";\nimport { WorkflowExecutableNodeClassifierFactory } from \"../workflow/definition/WorkflowExecutableNodeClassifierFactory\";\n\nimport { CredentialResolverFactory } from \"../execution/CredentialResolverFactory\";\nimport type { EngineExecutionLimitsPolicy } from \"../policies/executionLimits/EngineExecutionLimitsPolicy\";\nimport { RunTerminalPersistenceCoordinator } from \"../policies/storage/RunTerminalPersistenceCoordinator\";\nimport { WorkflowPolicyErrorServices } from \"../policies/WorkflowPolicyErrorServices\";\nimport { EngineWorkflowPlanningFactory } from \"../planning/EngineWorkflowPlanningFactory\";\nimport type { EngineWaiters } from \"../orchestration/EngineWaiters\";\nimport { NodeEventPublisher } from \"../events/NodeEventPublisher\";\n\nimport { ActivationEnqueueService } from \"../execution/ActivationEnqueueService\";\nimport { NodeExecutionSnapshotFactory } from \"../execution/NodeExecutionSnapshotFactory\";\nimport { NodeInputsByPortFactory } from \"../execution/NodeInputsByPortFactory\";\nimport { NodeRunStateWriterFactory } from \"../execution/NodeRunStateWriterFactory\";\nimport { NodeActivationRequestComposer } from \"../execution/NodeActivationRequestComposer\";\nimport { PersistedRunStateTerminalBuilder } from \"../execution/PersistedRunStateTerminalBuilder\";\nimport { RunStateSemantics } from \"../execution/RunStateSemantics\";\nimport { WorkflowRunExecutionContextFactory } from \"../execution/WorkflowRunExecutionContextFactory\";\n\nexport class RunContinuationService {\n constructor(\n private readonly activationIdFactory: ActivationIdFactory,\n private readonly workflowExecutionRepository: WorkflowExecutionRepository,\n private readonly runDataFactory: RunDataFactory,\n private readonly runExecutionContextFactory: WorkflowRunExecutionContextFactory,\n private readonly workflowSnapshotResolver: WorkflowSnapshotResolver,\n private readonly planningFactory: EngineWorkflowPlanningFactory,\n private readonly nodeStatePublisherFactory: NodeRunStateWriterFactory,\n private readonly credentialResolverFactory: CredentialResolverFactory,\n private readonly nodeActivationRequestComposer: NodeActivationRequestComposer,\n private readonly persistedRunStateTerminalBuilder: PersistedRunStateTerminalBuilder,\n private readonly activationEnqueueService: ActivationEnqueueService,\n private readonly nodeEventPublisher: NodeEventPublisher,\n private readonly semantics: RunStateSemantics,\n private readonly waiters: EngineWaiters,\n private readonly policyErrorServices: WorkflowPolicyErrorServices,\n private readonly terminalPersistence: RunTerminalPersistenceCoordinator,\n private readonly executionLimitsPolicy: EngineExecutionLimitsPolicy,\n ) {}\n\n async markNodeRunning(args: {\n runId: RunId;\n activationId: NodeActivationId;\n nodeId: NodeId;\n inputsByPort: NodeInputsByPort;\n }): Promise<void> {\n const state = await this.workflowExecutionRepository.load(args.runId);\n if (!state?.pending) return;\n if (state.pending.activationId !== args.activationId || state.pending.nodeId !== args.nodeId) return;\n\n const startedAt = new Date().toISOString();\n const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];\n const snapshot = NodeExecutionSnapshotFactory.running({\n previous,\n runId: state.runId,\n workflowId: state.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: state.parent,\n startedAt,\n inputsByPort: args.inputsByPort,\n });\n\n await this.workflowExecutionRepository.save({\n ...state,\n nodeSnapshotsByNodeId: {\n ...(state.nodeSnapshotsByNodeId ?? {}),\n [args.nodeId]: snapshot,\n },\n });\n await this.nodeEventPublisher.publish(\"nodeStarted\", snapshot);\n }\n\n async resumeFromNodeResult(args: {\n runId: RunId;\n activationId: NodeActivationId;\n nodeId: NodeId;\n outputs: NodeOutputs;\n }): Promise<RunResult> {\n const state = await this.workflowExecutionRepository.load(args.runId);\n if (!state) throw new Error(`Unknown runId: ${args.runId}`);\n if (state.status !== \"pending\" || !state.pending) throw new Error(`Run ${args.runId} is not pending`);\n if (state.pending.activationId !== args.activationId)\n throw new Error(`activationId mismatch for run ${args.runId}`);\n if (state.pending.nodeId !== args.nodeId) throw new Error(`nodeId mismatch for run ${args.runId}`);\n\n const wf = this.resolvePersistedWorkflow(state);\n if (!wf) throw new Error(`Unknown workflowId: ${state.workflowId}`);\n\n const { topology, planner } = this.planningFactory.create(wf);\n\n const data = this.runDataFactory.create(state.outputsByNode);\n const limits = this.resolveEngineLimitsFromState(state);\n const base = this.runExecutionContextFactory.create({\n runId: state.runId,\n workflowId: state.workflowId,\n nodeId: args.nodeId,\n parent: state.parent,\n subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,\n engineMaxNodeActivations: limits.engineMaxNodeActivations,\n engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,\n data,\n nodeState: this.nodeStatePublisherFactory.create(state.runId, state.workflowId, state.parent),\n });\n\n data.setOutputs(args.nodeId, args.outputs);\n const completedAt = new Date().toISOString();\n const completedSnapshot = this.semantics.createFinishedSnapshot({\n workflow: wf,\n previous: state.nodeSnapshotsByNodeId?.[args.nodeId],\n runId: state.runId,\n workflowId: state.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: state.parent,\n finishedAt: completedAt,\n inputsByPort: state.pending.inputsByPort,\n outputs: args.outputs,\n });\n\n const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;\n const engineCounters = { completedNodeActivations: completedActivations };\n const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;\n\n if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {\n const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state,\n engineCounters,\n status: \"completed\",\n queue: [],\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: {\n ...(state.nodeSnapshotsByNodeId ?? {}),\n [args.nodeId]: completedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(completedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: wf,\n state: completedState,\n finalStatus: \"completed\",\n finishedAt: completedAt,\n });\n const result: RunResult = {\n runId: state.runId,\n workflowId: state.workflowId,\n startedAt: state.startedAt,\n status: \"completed\",\n outputs: this.semantics.resolveResultOutputs(wf, state.control?.stopCondition, data.dump()),\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n const batchId = state.pending.batchId ?? \"batch_1\";\n const queue: RunQueueEntry[] = (state.queue ?? []).map((q) => ({ ...q, batchId: q.batchId ?? batchId }));\n const nextNodeSnapshotsByNodeId = {\n ...(state.nodeSnapshotsByNodeId ?? {}),\n [args.nodeId]: completedSnapshot,\n };\n\n planner.applyOutputs(queue, { fromNodeId: args.nodeId, outputs: args.outputs as any, batchId });\n this.semantics.applyPinnedQueueSkips({\n runId: state.runId,\n workflowId: state.workflowId,\n parent: state.parent,\n mutableState: state.mutableState,\n planner,\n queue,\n data,\n nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,\n finishedAt: completedAt,\n });\n\n let next: ReturnType<(typeof planner)[\"nextActivation\"]>;\n try {\n next = planner.nextActivation(queue);\n } catch (cause) {\n const completedDefinition = topology.defsById.get(args.nodeId);\n const completedNodeLabel = this.formatNodeLabel({\n definition: completedDefinition,\n nodeId: args.nodeId,\n });\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new Error(\n `After completing ${completedNodeLabel}, the engine could not plan the next activation. ${reason} Outputs: ${this.formatOutputCounts(args.outputs)}.`,\n { cause },\n );\n }\n if (!next) {\n const lastNodeId = WorkflowExecutableNodeClassifierFactory.create(wf).lastExecutableNodeIdInDefinitionOrder(wf);\n const outputs = data.getOutputItems(lastNodeId, \"main\");\n\n const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state,\n engineCounters,\n status: \"completed\",\n queue: [],\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,\n });\n await this.workflowExecutionRepository.save(completedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: wf,\n state: completedState,\n finalStatus: \"completed\",\n finishedAt: completedAt,\n });\n\n const result: RunResult = {\n runId: state.runId,\n workflowId: state.workflowId,\n startedAt: state.startedAt,\n status: \"completed\",\n outputs,\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n if (completedActivations >= maxNodeActivations) {\n const message = `Run exceeded maxNodeActivations (${maxNodeActivations}) after ${completedActivations} completed node activations (next would be ${next.nodeId}).`;\n const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state,\n engineCounters,\n status: \"failed\",\n queue: queue.map((q) => ({ ...q })),\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,\n });\n await this.workflowExecutionRepository.save(failedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: wf,\n state: failedState,\n finalStatus: \"failed\",\n finishedAt: completedAt,\n });\n const result: RunResult = {\n runId: state.runId,\n workflowId: state.workflowId,\n startedAt: state.startedAt,\n status: \"failed\",\n error: { message },\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n const def = topology.defsById.get(next.nodeId);\n if (!def || def.kind !== \"node\") throw new Error(`Node ${next.nodeId} is not a runnable node`);\n\n const request = this.nodeActivationRequestComposer.createFromPlannedActivation({\n next,\n base,\n data,\n runId: state.runId,\n workflowId: state.workflowId,\n parent: state.parent,\n executionOptions: state.executionOptions,\n nodeDefinition: def,\n });\n\n const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({\n runId: state.runId,\n workflowId: state.workflowId,\n startedAt: state.startedAt,\n parent: state.parent,\n executionOptions: state.executionOptions,\n control: state.control,\n workflowSnapshot: state.workflowSnapshot,\n mutableState: state.mutableState,\n policySnapshot: state.policySnapshot,\n pendingQueue: queue,\n request,\n previousNodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,\n planner,\n engineCounters,\n connectionInvocations: state.connectionInvocations ?? [],\n });\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.nodeEventPublisher.publish(\"nodeQueued\", queuedSnapshot);\n return result;\n }\n\n async resumeFromNodeError(args: {\n runId: RunId;\n activationId: NodeActivationId;\n nodeId: NodeId;\n error: Error;\n }): Promise<RunResult> {\n const state = await this.workflowExecutionRepository.load(args.runId);\n if (!state) throw new Error(`Unknown runId: ${args.runId}`);\n if (state.status !== \"pending\" || !state.pending) throw new Error(`Run ${args.runId} is not pending`);\n if (state.pending.activationId !== args.activationId)\n throw new Error(`activationId mismatch for run ${args.runId}`);\n if (state.pending.nodeId !== args.nodeId) throw new Error(`nodeId mismatch for run ${args.runId}`);\n\n const wf = this.resolvePersistedWorkflow(state);\n if (!wf) throw new Error(`Unknown workflowId: ${state.workflowId}`);\n const failedDefinition = WorkflowTopology.fromWorkflow(wf).defsById.get(args.nodeId);\n const webhookControlSignal =\n state.executionOptions?.webhook && failedDefinition?.kind === \"trigger\"\n ? this.asWebhookControlSignal(args.error)\n : undefined;\n if (webhookControlSignal) {\n return await this.resumeFromWebhookControl({ state, workflow: wf, args, signal: webhookControlSignal });\n }\n\n if (failedDefinition && failedDefinition.kind === \"node\") {\n const nodeHandler = this.policyErrorServices.resolveNodeErrorHandler(failedDefinition.config.nodeErrorHandler);\n if (nodeHandler) {\n try {\n const ctx = this.buildNodeExecutionContextForPending(state, wf, failedDefinition, args.nodeId);\n const inputsByPort = state.pending.inputsByPort;\n const portKeys = Object.keys(inputsByPort);\n const kind = portKeys.length === 1 && portKeys[0] === \"in\" ? (\"single\" as const) : (\"multi\" as const);\n const items = inputsByPort.in ?? [];\n const recovered = await nodeHandler.handle({\n kind,\n items,\n inputsByPort: kind === \"multi\" ? inputsByPort : undefined,\n ctx,\n error: args.error,\n });\n return await this.resumeFromNodeResult({\n runId: args.runId,\n activationId: args.activationId,\n nodeId: args.nodeId,\n outputs: recovered,\n });\n } catch {\n // fall through to workflow-level failure\n }\n }\n }\n\n const finishedAt = new Date().toISOString();\n const message = args.error?.message ?? String(args.error);\n const failedSnapshot = NodeExecutionSnapshotFactory.failed({\n previous: state.nodeSnapshotsByNodeId?.[args.nodeId],\n runId: state.runId,\n workflowId: state.workflowId,\n nodeId: args.nodeId,\n activationId: args.activationId,\n parent: state.parent,\n finishedAt,\n inputsByPort: state.pending.inputsByPort,\n error: args.error,\n });\n const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state,\n engineCounters: state.engineCounters ?? { completedNodeActivations: 0 },\n status: \"failed\",\n queue: (state.queue ?? []).map((q) => ({ ...q })),\n outputsByNode: state.outputsByNode,\n nodeSnapshotsByNodeId: {\n ...(state.nodeSnapshotsByNodeId ?? {}),\n [args.nodeId]: failedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(failedState);\n await this.nodeEventPublisher.publish(\"nodeFailed\", failedSnapshot);\n\n const wfErr = this.policyErrorServices.resolveWorkflowErrorHandler(wf.workflowErrorHandler);\n if (wfErr) {\n await Promise.resolve(\n wfErr.onError({\n runId: state.runId,\n workflowId: state.workflowId,\n workflow: wf,\n failedNodeId: args.nodeId,\n error: args.error,\n startedAt: state.startedAt,\n finishedAt,\n }),\n );\n }\n\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: wf,\n state: failedState,\n finalStatus: \"failed\",\n finishedAt,\n });\n\n const result: RunResult = {\n runId: state.runId,\n workflowId: state.workflowId,\n startedAt: state.startedAt,\n status: \"failed\",\n error: { message },\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n async resumeFromStepResult(args: {\n runId: RunId;\n activationId: NodeActivationId;\n nodeId: NodeId;\n outputs: NodeOutputs;\n }): Promise<RunResult> {\n return await this.resumeFromNodeResult(args);\n }\n\n async resumeFromStepError(args: {\n runId: RunId;\n activationId: NodeActivationId;\n nodeId: NodeId;\n error: Error;\n }): Promise<RunResult> {\n return await this.resumeFromNodeError(args);\n }\n\n async waitForCompletion(runId: RunId): Promise<Extract<RunResult, { status: \"completed\" | \"failed\" }>> {\n const existing = await this.workflowExecutionRepository.load(runId);\n if (existing?.status === \"completed\") {\n const wf = this.resolvePersistedWorkflow(existing);\n const outputs = wf\n ? this.semantics.resolveResultOutputs(wf, existing.control?.stopCondition, existing.outputsByNode)\n : [];\n return {\n runId: existing.runId,\n workflowId: existing.workflowId,\n startedAt: existing.startedAt,\n status: \"completed\",\n outputs,\n };\n }\n if (existing?.status === \"failed\") {\n return {\n runId: existing.runId,\n workflowId: existing.workflowId,\n startedAt: existing.startedAt,\n status: \"failed\",\n error: { message: \"Run failed\" },\n };\n }\n\n const result = await this.waiters.waitForCompletion(runId);\n if (result.status !== \"completed\" && result.status !== \"failed\") {\n throw new Error(`Unexpected run completion status: ${result.status}`);\n }\n return result;\n }\n\n async waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult> {\n return await this.waiters.waitForWebhookResponse(runId);\n }\n\n private async resumeFromWebhookControl(args: {\n state: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>;\n workflow: WorkflowDefinition;\n args: { runId: RunId; activationId: NodeActivationId; nodeId: NodeId; error: Error };\n signal: WebhookControlSignal;\n }): Promise<RunResult> {\n const data = this.runDataFactory.create(args.state.outputsByNode);\n const { topology, planner } = this.planningFactory.create(args.workflow);\n\n const continuedItems =\n args.signal.kind === \"respondNowAndContinue\" ? (args.signal.continueItems ?? []) : args.signal.responseItems;\n const triggerOutputs: NodeOutputs = { main: continuedItems };\n data.setOutputs(args.args.nodeId, triggerOutputs);\n\n const completedSnapshot = this.semantics.createFinishedSnapshot({\n workflow: args.workflow,\n previous: args.state.nodeSnapshotsByNodeId?.[args.args.nodeId],\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n nodeId: args.args.nodeId,\n activationId: args.args.activationId,\n parent: args.state.parent,\n finishedAt: new Date().toISOString(),\n inputsByPort: args.state.pending?.inputsByPort ?? NodeInputsByPortFactory.empty(),\n outputs: triggerOutputs,\n });\n\n const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;\n const engineCounters = { completedNodeActivations: completedActivations };\n const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;\n\n if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {\n const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state: args.state,\n engineCounters,\n status: \"completed\",\n queue: [],\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: {\n ...(args.state.nodeSnapshotsByNodeId ?? {}),\n [args.args.nodeId]: completedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(completedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: args.workflow,\n state: completedState,\n finalStatus: \"completed\",\n finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt,\n });\n this.waiters.resolveWebhookResponse({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n runStatus: \"completed\",\n response: args.signal.responseItems,\n });\n const result: RunResult = {\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n status: \"completed\",\n outputs: this.semantics.resolveResultOutputs(args.workflow, args.state.control?.stopCondition, data.dump()),\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n if (args.signal.kind === \"respondNow\") {\n const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state: args.state,\n engineCounters,\n status: \"completed\",\n queue: [],\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: {\n ...(args.state.nodeSnapshotsByNodeId ?? {}),\n [args.args.nodeId]: completedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(completedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: args.workflow,\n state: completedState,\n finalStatus: \"completed\",\n finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt,\n });\n\n const result: RunResult = {\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n status: \"completed\",\n outputs: args.signal.responseItems,\n };\n this.waiters.resolveWebhookResponse({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n runStatus: \"completed\",\n response: args.signal.responseItems,\n });\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n const batchId = args.state.pending?.batchId ?? \"batch_1\";\n const queue: RunQueueEntry[] = (args.state.queue ?? []).map((entry) => ({\n ...entry,\n batchId: entry.batchId ?? batchId,\n }));\n planner.applyOutputs(queue, { fromNodeId: args.args.nodeId, outputs: triggerOutputs as any, batchId });\n const next = planner.nextActivation(queue);\n\n if (!next) {\n const lastNodeId = WorkflowExecutableNodeClassifierFactory.create(\n args.workflow,\n ).lastExecutableNodeIdInDefinitionOrder(args.workflow);\n const outputs = data.getOutputItems(lastNodeId, \"main\");\n const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state: args.state,\n engineCounters,\n status: \"completed\",\n queue: [],\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: {\n ...(args.state.nodeSnapshotsByNodeId ?? {}),\n [args.args.nodeId]: completedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(completedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: args.workflow,\n state: completedState,\n finalStatus: \"completed\",\n finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt,\n });\n\n const result: RunResult = {\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n status: \"completed\",\n outputs,\n };\n this.waiters.resolveWebhookResponse({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n runStatus: \"completed\",\n response: args.signal.responseItems,\n });\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n if (completedActivations >= maxNodeActivations) {\n const message = `Run exceeded maxNodeActivations (${maxNodeActivations}) after ${completedActivations} completed node activations (next would be ${next.nodeId}).`;\n const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({\n state: args.state,\n engineCounters,\n status: \"failed\",\n queue: queue.map((q) => ({ ...q })),\n outputsByNode: data.dump(),\n nodeSnapshotsByNodeId: {\n ...(args.state.nodeSnapshotsByNodeId ?? {}),\n [args.args.nodeId]: completedSnapshot,\n },\n });\n await this.workflowExecutionRepository.save(failedState);\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.terminalPersistence.maybeDeleteAfterTerminalState({\n workflow: args.workflow,\n state: failedState,\n finalStatus: \"failed\",\n finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt,\n });\n const result: RunResult = {\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n status: \"failed\",\n error: { message },\n };\n this.waiters.resolveWebhookResponse({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n runStatus: \"pending\",\n response: args.signal.responseItems,\n });\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n\n const nextDefinition = topology.defsById.get(next.nodeId);\n if (!nextDefinition || nextDefinition.kind !== \"node\") {\n throw new Error(`Node ${next.nodeId} is not a runnable node`);\n }\n\n const webhookLimits = this.resolveEngineLimitsFromState(args.state);\n const base = this.runExecutionContextFactory.create({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n nodeId: nextDefinition.id,\n parent: args.state.parent,\n subworkflowDepth: args.state.executionOptions?.subworkflowDepth ?? 0,\n engineMaxNodeActivations: webhookLimits.engineMaxNodeActivations,\n engineMaxSubworkflowDepth: webhookLimits.engineMaxSubworkflowDepth,\n data,\n nodeState: this.nodeStatePublisherFactory.create(args.state.runId, args.state.workflowId, args.state.parent),\n });\n const request = this.nodeActivationRequestComposer.createFromPlannedActivation({\n next,\n base,\n data,\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n parent: args.state.parent,\n executionOptions: args.state.executionOptions,\n nodeDefinition: nextDefinition,\n });\n\n const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n parent: args.state.parent,\n executionOptions: args.state.executionOptions,\n control: args.state.control,\n workflowSnapshot: args.state.workflowSnapshot,\n mutableState: args.state.mutableState,\n policySnapshot: args.state.policySnapshot,\n pendingQueue: queue,\n request,\n previousNodeSnapshotsByNodeId: {\n ...(args.state.nodeSnapshotsByNodeId ?? {}),\n [args.args.nodeId]: completedSnapshot,\n },\n planner,\n engineCounters,\n connectionInvocations: args.state.connectionInvocations ?? [],\n });\n await this.nodeEventPublisher.publish(\"nodeCompleted\", completedSnapshot);\n await this.nodeEventPublisher.publish(\"nodeQueued\", queuedSnapshot);\n this.waiters.resolveWebhookResponse({\n runId: args.state.runId,\n workflowId: args.state.workflowId,\n startedAt: args.state.startedAt,\n runStatus: \"pending\",\n response: args.signal.responseItems,\n });\n return result;\n }\n\n private asWebhookControlSignal(error: Error): WebhookControlSignal | undefined {\n const candidate = error as Partial<WebhookControlSignal> | undefined;\n if (!candidate || candidate.__webhookControl !== true) return undefined;\n if (candidate.kind !== \"respondNow\" && candidate.kind !== \"respondNowAndContinue\") return undefined;\n if (!Array.isArray(candidate.responseItems)) return undefined;\n return candidate as WebhookControlSignal;\n }\n\n private resolvePersistedWorkflow(state: {\n workflowId: WorkflowId;\n workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"workflowSnapshot\"];\n }): WorkflowDefinition | undefined {\n return this.workflowSnapshotResolver.resolve({\n workflowId: state.workflowId,\n workflowSnapshot: state.workflowSnapshot,\n });\n }\n\n private buildNodeExecutionContextForPending(\n state: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>,\n wf: WorkflowDefinition,\n def: Readonly<{ id: NodeId; config: NodeExecutionContext[\"config\"] }>,\n nodeId: NodeId,\n ): NodeExecutionContext {\n const data = this.runDataFactory.create(state.outputsByNode);\n const limits = this.resolveEngineLimitsFromState(state);\n const base = this.runExecutionContextFactory.create({\n runId: state.runId,\n workflowId: state.workflowId,\n nodeId,\n parent: state.parent,\n subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,\n engineMaxNodeActivations: limits.engineMaxNodeActivations,\n engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,\n data,\n nodeState: this.nodeStatePublisherFactory.create(state.runId, state.workflowId, state.parent),\n });\n const activationId = state.pending!.activationId;\n return {\n ...base,\n data,\n nodeId,\n activationId,\n config: def.config,\n binary: base.binary.forNode({ nodeId, activationId }),\n getCredential: this.credentialResolverFactory.create(wf.id, nodeId, def.config),\n };\n }\n\n private resolveEngineLimitsFromState(state: PersistedRunState): {\n engineMaxNodeActivations: number;\n engineMaxSubworkflowDepth: number;\n } {\n const fb = this.executionLimitsPolicy.createRootExecutionOptions();\n return {\n engineMaxNodeActivations: state.executionOptions?.maxNodeActivations ?? fb.maxNodeActivations!,\n engineMaxSubworkflowDepth: state.executionOptions?.maxSubworkflowDepth ?? fb.maxSubworkflowDepth!,\n };\n }\n\n private formatNodeLabel(args: {\n definition?: Readonly<{ id: NodeId; name?: string; type: unknown }>;\n nodeId: NodeId;\n }): string {\n const tokenName = typeof args.definition?.type === \"function\" ? args.definition.type.name : \"Node\";\n return args.definition?.name\n ? `\"${args.definition.name}\" (${tokenName}:${args.nodeId})`\n : `${tokenName}:${args.nodeId}`;\n }\n\n private formatOutputCounts(outputs: NodeOutputs): string {\n const entries = Object.entries(outputs ?? {});\n if (entries.length === 0) {\n return \"no outputs\";\n }\n return entries.map(([port, items]) => `${port}=${items?.length ?? 0}`).join(\", \");\n }\n}\n","import type {\n ExecutionFrontierPlan,\n InputPortKey,\n Items,\n NodeId,\n NodeOutputs,\n OutputPortKey,\n RunCurrentState,\n PersistedMutableNodeState,\n RunQueueEntry,\n RunStateResetRequest,\n RunStopCondition,\n ConnectionInvocationRecord,\n} from \"../types\";\n\nimport { ConnectionNodeIdFactory } from \"../workflow/definition/ConnectionNodeIdFactory\";\nimport { WorkflowTopology } from \"./WorkflowTopologyPlanner\";\n\nexport class CurrentStateFrontierPlanner {\n constructor(private readonly topology: WorkflowTopology) {}\n\n /** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */\n static createFromTopology(topology: WorkflowTopology): CurrentStateFrontierPlanner {\n return new CurrentStateFrontierPlanner(topology);\n }\n\n plan(args: {\n currentState?: RunCurrentState;\n stopCondition?: RunStopCondition;\n reset?: RunStateResetRequest;\n items?: Items;\n }): ExecutionFrontierPlan {\n const stopCondition = args.stopCondition ?? { kind: \"workflowCompleted\" as const };\n const baseState = this.cloneCurrentState(args.currentState);\n const normalizedState = this.overlayPinnedOutputs(baseState);\n const resetResult = this.applyReset({ currentState: normalizedState, reset: args.reset });\n const requiredNodeIds = this.collectRequiredNodeIds(stopCondition, resetResult.currentState);\n const satisfiedNodeIds = this.collectSatisfiedNodeIds(resetResult.currentState);\n const skippedNodeIds = [\n ...new Set([\n ...[...requiredNodeIds].filter((nodeId) => this.isNodeSatisfied(resetResult.currentState, nodeId)),\n ...resetResult.preservedPinnedNodeIds.filter((nodeId) => requiredNodeIds.has(nodeId)),\n ]),\n ];\n const frontierNodeIds = this.collectFrontierNodeIds(requiredNodeIds, resetResult.currentState);\n const rootNodeIds = frontierNodeIds.filter(\n (nodeId) => (this.topology.incomingByNode.get(nodeId) ?? []).length === 0,\n );\n\n if (rootNodeIds.length > 1) {\n throw new Error(`Ambiguous execution frontier. Multiple root nodes require input: ${rootNodeIds.join(\", \")}`);\n }\n\n if (frontierNodeIds.length === 0) {\n return {\n queue: [],\n currentState: resetResult.currentState,\n stopCondition,\n satisfiedNodeIds,\n skippedNodeIds,\n clearedNodeIds: resetResult.clearedNodeIds,\n preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,\n };\n }\n\n if (rootNodeIds.length === 1) {\n const rootNodeId = rootNodeIds[0]!;\n const definition = this.topology.defsById.get(rootNodeId);\n if (!definition) {\n throw new Error(`Unknown frontier nodeId: ${rootNodeId}`);\n }\n return {\n rootNodeId,\n rootNodeInput: this.resolveRootNodeInput({ nodeKind: definition.kind, items: args.items }),\n queue: [],\n currentState: resetResult.currentState,\n stopCondition,\n satisfiedNodeIds,\n skippedNodeIds,\n clearedNodeIds: resetResult.clearedNodeIds,\n preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,\n };\n }\n\n const queue: RunQueueEntry[] = [];\n for (const nodeId of frontierNodeIds) {\n queue.push(...this.buildFrontierQueue(nodeId, resetResult.currentState));\n }\n\n return {\n queue,\n currentState: resetResult.currentState,\n stopCondition,\n satisfiedNodeIds,\n skippedNodeIds,\n clearedNodeIds: resetResult.clearedNodeIds,\n preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,\n };\n }\n\n private cloneCurrentState(currentState: RunCurrentState | undefined): RunCurrentState {\n if (!currentState) {\n return {\n outputsByNode: {},\n nodeSnapshotsByNodeId: {},\n connectionInvocations: [],\n mutableState: undefined,\n };\n }\n return {\n outputsByNode: { ...currentState.outputsByNode },\n nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },\n connectionInvocations: currentState.connectionInvocations ? [...currentState.connectionInvocations] : undefined,\n mutableState: currentState.mutableState,\n };\n }\n\n private overlayPinnedOutputs(currentState: RunCurrentState): RunCurrentState {\n const outputsByNode: Record<NodeId, NodeOutputs> = { ...currentState.outputsByNode };\n for (const [nodeId, nodeState] of Object.entries(currentState.mutableState?.nodesById ?? {}) as Array<\n [NodeId, PersistedMutableNodeState]\n >) {\n const pinnedOutputs = nodeState.pinnedOutputsByPort;\n if (!pinnedOutputs) {\n continue;\n }\n outputsByNode[nodeId] = pinnedOutputs;\n }\n return {\n outputsByNode,\n nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },\n connectionInvocations: currentState.connectionInvocations,\n mutableState: currentState.mutableState,\n };\n }\n\n private applyReset(args: { currentState: RunCurrentState; reset?: RunStateResetRequest }): Readonly<{\n currentState: RunCurrentState;\n clearedNodeIds: ReadonlyArray<NodeId>;\n preservedPinnedNodeIds: ReadonlyArray<NodeId>;\n }> {\n if (!args.reset) {\n return {\n currentState: args.currentState,\n clearedNodeIds: [],\n preservedPinnedNodeIds: [],\n };\n }\n\n const outputsByNode: Record<NodeId, NodeOutputs> = { ...args.currentState.outputsByNode };\n const nodeSnapshotsByNodeId = { ...args.currentState.nodeSnapshotsByNodeId };\n const clearedNodeIds: NodeId[] = [];\n const preservedPinnedNodeIds: NodeId[] = [];\n const descendants = this.collectDescendants(args.reset.clearFromNodeId);\n const runtimeDescendants = this.collectRuntimeDescendants(args.currentState, descendants);\n const clearedIdSet = new Set<NodeId>([...descendants, ...runtimeDescendants]);\n\n for (const nodeId of [...descendants, ...runtimeDescendants]) {\n const pinnedOutputs = this.getPinnedOutputs(args.currentState, nodeId);\n if (pinnedOutputs) {\n outputsByNode[nodeId] = pinnedOutputs;\n delete nodeSnapshotsByNodeId[nodeId];\n preservedPinnedNodeIds.push(nodeId);\n continue;\n }\n delete outputsByNode[nodeId];\n delete nodeSnapshotsByNodeId[nodeId];\n clearedNodeIds.push(nodeId);\n }\n\n return {\n currentState: {\n outputsByNode,\n nodeSnapshotsByNodeId,\n connectionInvocations: this.filterConnectionInvocations(args.currentState.connectionInvocations, clearedIdSet),\n mutableState: args.currentState.mutableState,\n },\n clearedNodeIds,\n preservedPinnedNodeIds,\n };\n }\n\n private collectSatisfiedNodeIds(currentState: RunCurrentState): ReadonlyArray<NodeId> {\n const satisfiedNodeIds: NodeId[] = [];\n for (const nodeId of this.topology.defsById.keys()) {\n if (this.isNodeSatisfied(currentState, nodeId)) {\n satisfiedNodeIds.push(nodeId);\n }\n }\n return satisfiedNodeIds;\n }\n\n private collectFrontierNodeIds(\n requiredNodeIds: ReadonlySet<NodeId>,\n currentState: RunCurrentState,\n ): ReadonlyArray<NodeId> {\n const frontierNodeIds: NodeId[] = [];\n for (const nodeId of this.topology.defsById.keys()) {\n if (!requiredNodeIds.has(nodeId) || this.isNodeSatisfied(currentState, nodeId)) {\n continue;\n }\n const incomingEdges = this.topology.incomingByNode.get(nodeId) ?? [];\n const isFrontier = incomingEdges.every((edge) => this.isEdgeSatisfied(currentState, nodeId, edge.input));\n if (isFrontier) {\n frontierNodeIds.push(nodeId);\n }\n }\n return frontierNodeIds;\n }\n\n private collectRequiredNodeIds(stopCondition: RunStopCondition, currentState: RunCurrentState): ReadonlySet<NodeId> {\n const requiredNodeIds = new Set<NodeId>();\n if (stopCondition.kind === \"workflowCompleted\") {\n for (const nodeId of this.topology.defsById.keys()) {\n if (!this.isNodeSatisfied(currentState, nodeId)) {\n this.collectRequiredNode(requiredNodeIds, currentState, nodeId);\n }\n }\n return requiredNodeIds;\n }\n if (!this.topology.defsById.has(stopCondition.nodeId)) {\n throw new Error(`Unknown stop nodeId: ${stopCondition.nodeId}`);\n }\n this.collectRequiredNode(requiredNodeIds, currentState, stopCondition.nodeId);\n return requiredNodeIds;\n }\n\n private collectRequiredNode(requiredNodeIds: Set<NodeId>, currentState: RunCurrentState, nodeId: NodeId): void {\n if (requiredNodeIds.has(nodeId)) {\n return;\n }\n if (this.isNodeSatisfied(currentState, nodeId) && !this.isNodeSatisfiedByOutputsOnly(currentState, nodeId)) {\n return;\n }\n requiredNodeIds.add(nodeId);\n for (const edge of this.topology.incomingByNode.get(nodeId) ?? []) {\n if (\n !this.isEdgeSatisfied(currentState, nodeId, edge.input) ||\n this.isNodeSatisfiedByOutputsOnly(currentState, edge.from.nodeId)\n ) {\n this.collectRequiredNode(requiredNodeIds, currentState, edge.from.nodeId);\n }\n }\n }\n\n private buildFrontierQueue(nodeId: NodeId, currentState: RunCurrentState): ReadonlyArray<RunQueueEntry> {\n const incomingEdges = this.topology.incomingByNode.get(nodeId) ?? [];\n if (incomingEdges.length === 0) {\n return [];\n }\n const expectedInputs = this.topology.expectedInputsByNode.get(nodeId) ?? [];\n const usesCollect = expectedInputs.length !== 1 || expectedInputs[0] !== \"in\";\n if (usesCollect) {\n const received: Record<InputPortKey, Items> = {};\n for (const input of expectedInputs) {\n received[input] = this.resolveInput(currentState, nodeId, input);\n }\n return [\n {\n nodeId,\n input: [],\n batchId: \"batch_1\",\n collect: {\n expectedInputs,\n received,\n },\n },\n ];\n }\n const input = expectedInputs[0] ?? \"in\";\n const incomingEdge = incomingEdges.find((edge) => edge.input === input);\n return [\n {\n nodeId,\n input: this.resolveInput(currentState, nodeId, input),\n toInput: input,\n batchId: \"batch_1\",\n from: incomingEdge?.from,\n },\n ];\n }\n\n private resolveRootNodeInput(args: { nodeKind: \"node\" | \"trigger\"; items?: Items }): Items {\n if (args.items) {\n return args.items;\n }\n if (args.nodeKind === \"trigger\") {\n return [];\n }\n return [{ json: {} }];\n }\n\n private isNodeSatisfied(currentState: RunCurrentState, nodeId: NodeId): boolean {\n return this.hasOutputs(currentState, nodeId) || this.hasCompletedSnapshot(currentState, nodeId);\n }\n\n private isNodeSatisfiedByOutputsOnly(currentState: RunCurrentState, nodeId: NodeId): boolean {\n return this.hasOutputs(currentState, nodeId) && !this.hasCompletedSnapshot(currentState, nodeId);\n }\n\n private isEdgeSatisfied(currentState: RunCurrentState, nodeId: NodeId, input: InputPortKey): boolean {\n const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);\n if (!incomingEdge) {\n return false;\n }\n return this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);\n }\n\n private resolveInput(currentState: RunCurrentState, nodeId: NodeId, input: InputPortKey): Items {\n const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);\n if (!incomingEdge) {\n return [];\n }\n return this.resolveOutputItems(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);\n }\n\n private hasOutputs(currentState: RunCurrentState, nodeId: NodeId): boolean {\n return Object.prototype.hasOwnProperty.call(currentState.outputsByNode, nodeId);\n }\n\n private hasCompletedSnapshot(currentState: RunCurrentState, nodeId: NodeId): boolean {\n const snapshot = currentState.nodeSnapshotsByNodeId[nodeId];\n return snapshot?.status === \"completed\" || snapshot?.status === \"skipped\";\n }\n\n private hasOutputPort(currentState: RunCurrentState, nodeId: NodeId, output: OutputPortKey): boolean {\n const outputs = currentState.outputsByNode[nodeId];\n if (!outputs) {\n return false;\n }\n return Object.prototype.hasOwnProperty.call(outputs, output);\n }\n\n private resolveOutputItems(currentState: RunCurrentState, nodeId: NodeId, output: OutputPortKey): Items {\n return currentState.outputsByNode[nodeId]?.[output] ?? [];\n }\n\n private getPinnedOutputs(currentState: RunCurrentState, nodeId: NodeId): NodeOutputs | undefined {\n return currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort;\n }\n\n private filterConnectionInvocations(\n invocations: ReadonlyArray<ConnectionInvocationRecord> | undefined,\n clearedIdSet: ReadonlySet<NodeId>,\n ): ReadonlyArray<ConnectionInvocationRecord> | undefined {\n if (!invocations || invocations.length === 0) {\n return invocations;\n }\n const kept = invocations.filter(\n (invocation) => !clearedIdSet.has(invocation.parentAgentNodeId) && !clearedIdSet.has(invocation.connectionNodeId),\n );\n return kept.length === invocations.length ? invocations : kept;\n }\n\n private collectDescendants(startNodeId: NodeId): ReadonlyArray<NodeId> {\n const pendingNodeIds: NodeId[] = [startNodeId];\n const descendants = new Set<NodeId>();\n while (pendingNodeIds.length > 0) {\n const nodeId = pendingNodeIds.pop();\n if (!nodeId || descendants.has(nodeId)) {\n continue;\n }\n descendants.add(nodeId);\n for (const edge of this.topology.outgoingByNode.get(nodeId) ?? []) {\n pendingNodeIds.push(edge.to.nodeId);\n }\n }\n return [...descendants];\n }\n\n private collectRuntimeDescendants(\n currentState: RunCurrentState,\n descendantNodeIds: ReadonlyArray<NodeId>,\n ): ReadonlyArray<NodeId> {\n const descendantSet = new Set(descendantNodeIds);\n const runtimeNodeIds = new Set<NodeId>();\n for (const nodeId of [\n ...Object.keys(currentState.outputsByNode),\n ...Object.keys(currentState.nodeSnapshotsByNodeId),\n ...Object.keys(currentState.mutableState?.nodesById ?? {}),\n ] as NodeId[]) {\n if (this.isRuntimeDescendant(nodeId, descendantSet)) {\n runtimeNodeIds.add(nodeId);\n }\n }\n return [...runtimeNodeIds];\n }\n\n private isRuntimeDescendant(nodeId: NodeId, descendantNodeIds: ReadonlySet<NodeId>): boolean {\n for (const descendantNodeId of descendantNodeIds) {\n if (nodeId === descendantNodeId) {\n return false;\n }\n if (ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) {\n return true;\n }\n }\n return false;\n }\n}\n","import type {\n PersistedRunPolicySnapshot,\n WorkflowDefinition,\n WorkflowPolicyRuntimeDefaults,\n WorkflowStoragePolicyMode,\n} from \"../../types\";\n\nexport class RunPolicySnapshotFactory {\n static create(workflow: WorkflowDefinition, defaults?: WorkflowPolicyRuntimeDefaults): PersistedRunPolicySnapshot {\n const prune = workflow.prunePolicy;\n const retentionSeconds = prune?.runDataRetentionSeconds ?? defaults?.retentionSeconds;\n const binaryRetentionSeconds = prune?.binaryRetentionSeconds ?? defaults?.binaryRetentionSeconds;\n const storagePolicy: WorkflowStoragePolicyMode =\n typeof workflow.storagePolicy === \"string\"\n ? (workflow.storagePolicy as WorkflowStoragePolicyMode)\n : (defaults?.storagePolicy ?? \"ALL\");\n return {\n retentionSeconds,\n binaryRetentionSeconds,\n storagePolicy,\n };\n }\n}\n","import type {\n CurrentStateExecutionRequest,\n ExecutionContextFactory,\n ExecutionFrontierPlan,\n Items,\n NodeExecutionSnapshot,\n NodeId,\n NodeOutputs,\n ParentExecutionRef,\n PersistedRunControlState,\n RunCurrentState,\n RunDataFactory,\n RunExecutionOptions,\n RunId,\n RunIdFactory,\n RunQueueEntry,\n RunResult,\n WorkflowExecutionRepository,\n WorkflowDefinition,\n WorkflowId,\n WorkflowPolicyRuntimeDefaults,\n WorkflowSnapshotFactory,\n} from \"../types\";\n\nimport { WorkflowExecutableNodeClassifierFactory } from \"../workflow/definition/WorkflowExecutableNodeClassifierFactory\";\nimport { CurrentStateFrontierPlanner } from \"../planning/CurrentStateFrontierPlanner\";\nimport { RunQueuePlanner } from \"../planning/RunQueuePlanner\";\nimport { WorkflowTopology } from \"../planning/WorkflowTopologyPlanner\";\nimport { EngineExecutionLimitsPolicy } from \"../policies/executionLimits/EngineExecutionLimitsPolicy\";\nimport { EngineWorkflowPlanningFactory } from \"../planning/EngineWorkflowPlanningFactory\";\nimport type { EngineWaiters } from \"../orchestration/EngineWaiters\";\nimport { RunPolicySnapshotFactory } from \"../policies/storage/RunPolicySnapshotFactory\";\n\nimport { ActivationEnqueueService } from \"../execution/ActivationEnqueueService\";\nimport { NodeRunStateWriterFactory } from \"../execution/NodeRunStateWriterFactory\";\nimport { NodeActivationRequestComposer } from \"../execution/NodeActivationRequestComposer\";\nimport { RunStateSemantics } from \"../execution/RunStateSemantics\";\nimport { WorkflowRunExecutionContextFactory } from \"../execution/WorkflowRunExecutionContextFactory\";\n\nexport class RunStartService {\n constructor(\n private readonly runIdFactory: RunIdFactory,\n private readonly workflowExecutionRepository: WorkflowExecutionRepository,\n private readonly runDataFactory: RunDataFactory,\n private readonly workflowSnapshotFactory: WorkflowSnapshotFactory,\n private readonly planningFactory: EngineWorkflowPlanningFactory,\n private readonly nodeStatePublisherFactory: NodeRunStateWriterFactory,\n private readonly runExecutionContextFactory: WorkflowRunExecutionContextFactory,\n private readonly nodeActivationRequestComposer: NodeActivationRequestComposer,\n private readonly activationEnqueueService: ActivationEnqueueService,\n private readonly semantics: RunStateSemantics,\n private readonly waiters: EngineWaiters,\n private readonly workflowPolicyRuntimeDefaults: WorkflowPolicyRuntimeDefaults | undefined,\n private readonly executionLimitsPolicy: EngineExecutionLimitsPolicy,\n ) {}\n\n async runWorkflow(\n workflow: WorkflowDefinition,\n startAt: NodeId,\n items: Items,\n parent?: ParentExecutionRef,\n executionOptions?: RunExecutionOptions,\n persistedStateOverrides?: Readonly<{\n workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"workflowSnapshot\"];\n mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"];\n }>,\n ): Promise<RunResult> {\n const runId = this.runIdFactory.makeRunId();\n const startedAt = new Date().toISOString();\n const workflowSnapshot = persistedStateOverrides?.workflowSnapshot ?? this.workflowSnapshotFactory.create(workflow);\n const mutableState = persistedStateOverrides?.mutableState;\n const policySnapshot = RunPolicySnapshotFactory.create(workflow, this.workflowPolicyRuntimeDefaults);\n const mergedExecutionOptions = this.executionLimitsPolicy.mergeExecutionOptionsForNewRun(parent, executionOptions);\n\n await this.workflowExecutionRepository.createRun({\n runId,\n workflowId: workflow.id,\n startedAt,\n parent,\n executionOptions: mergedExecutionOptions,\n workflowSnapshot,\n mutableState,\n policySnapshot,\n engineCounters: { completedNodeActivations: 0 },\n });\n\n const data = this.runDataFactory.create();\n const base = this.runExecutionContextFactory.create({\n runId,\n workflowId: workflow.id,\n nodeId: startAt,\n parent,\n subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,\n engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations!,\n engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth!,\n data,\n nodeState: this.nodeStatePublisherFactory.create(runId, workflow.id, parent),\n });\n const { topology, planner } = this.planningFactory.create(workflow);\n const startDefinition = topology.defsById.get(startAt);\n if (!startDefinition) {\n throw new Error(`Unknown start nodeId: ${startAt}`);\n }\n\n const initialNodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot> = {};\n if (startDefinition.kind === \"trigger\") {\n const request = this.nodeActivationRequestComposer.createSingleFromDefinition({\n runId,\n workflowId: workflow.id,\n definition: startDefinition,\n parent,\n executionOptions: mergedExecutionOptions,\n batchId: \"batch_1\",\n input: items,\n base,\n data,\n });\n return await this.activationEnqueueService.enqueueActivation({\n runId,\n workflowId: workflow.id,\n startedAt,\n parent,\n executionOptions: mergedExecutionOptions,\n workflowSnapshot,\n mutableState,\n policySnapshot,\n control: undefined,\n pendingQueue: [],\n request,\n previousNodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,\n planner,\n engineCounters: { completedNodeActivations: 0 },\n connectionInvocations: [],\n });\n }\n\n const queue: RunQueueEntry[] = [{ nodeId: startAt, input: items, toInput: \"in\", batchId: \"batch_1\" }];\n return await this.scheduleQueuedPlan({\n runId,\n workflowId: workflow.id,\n startedAt,\n parent,\n executionOptions: mergedExecutionOptions,\n control: undefined,\n workflowSnapshot,\n mutableState,\n policySnapshot,\n workflow,\n planner,\n queue,\n base,\n data,\n nodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,\n connectionInvocations: [],\n });\n }\n\n async runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult> {\n const runId = this.runIdFactory.makeRunId();\n const startedAt = new Date().toISOString();\n const workflowSnapshot = request.workflowSnapshot ?? this.workflowSnapshotFactory.create(request.workflow);\n const mutableState = request.mutableState ?? request.currentState?.mutableState;\n const policySnapshot = RunPolicySnapshotFactory.create(request.workflow, this.workflowPolicyRuntimeDefaults);\n const control = {\n stopCondition: request.stopCondition ?? { kind: \"workflowCompleted\" as const },\n };\n const mergedExecutionOptions = this.executionLimitsPolicy.mergeExecutionOptionsForNewRun(\n request.parent,\n request.executionOptions,\n );\n\n await this.workflowExecutionRepository.createRun({\n runId,\n workflowId: request.workflow.id,\n startedAt,\n parent: request.parent,\n executionOptions: mergedExecutionOptions,\n control,\n workflowSnapshot,\n mutableState,\n policySnapshot,\n engineCounters: { completedNodeActivations: 0 },\n });\n\n const { topology, planner } = this.planningFactory.create(request.workflow);\n const plan = CurrentStateFrontierPlanner.createFromTopology(topology).plan({\n currentState: this.createRunCurrentState(request.currentState, mutableState),\n stopCondition: control.stopCondition,\n reset: request.reset,\n items: request.items,\n });\n\n const data = this.runDataFactory.create(plan.currentState.outputsByNode);\n const base = this.runExecutionContextFactory.create({\n runId,\n workflowId: request.workflow.id,\n nodeId:\n WorkflowExecutableNodeClassifierFactory.create(request.workflow).firstExecutableNodeIdInDefinitionOrder(\n request.workflow,\n ) ?? \"unknown_node\",\n parent: request.parent,\n subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,\n engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations!,\n engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth!,\n data,\n nodeState: this.nodeStatePublisherFactory.create(runId, request.workflow.id, request.parent),\n });\n\n return await this.scheduleInitialPlan({\n runId,\n startedAt,\n workflow: request.workflow,\n workflowSnapshot,\n mutableState,\n policySnapshot,\n executionOptions: mergedExecutionOptions,\n control,\n parent: request.parent,\n planner,\n plan,\n base,\n data,\n });\n }\n\n private createRunCurrentState(\n currentState: RunCurrentState | undefined,\n mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"],\n ): RunCurrentState {\n return {\n outputsByNode: { ...(currentState?.outputsByNode ?? {}) },\n nodeSnapshotsByNodeId: { ...(currentState?.nodeSnapshotsByNodeId ?? {}) },\n connectionInvocations: currentState?.connectionInvocations ? [...currentState.connectionInvocations] : undefined,\n mutableState: mutableState ?? currentState?.mutableState,\n };\n }\n\n private async scheduleInitialPlan(args: {\n runId: RunId;\n startedAt: string;\n workflow: WorkflowDefinition;\n workflowSnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"workflowSnapshot\"];\n mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"];\n policySnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"policySnapshot\"];\n executionOptions?: RunExecutionOptions;\n control: PersistedRunControlState | undefined;\n parent?: ParentExecutionRef;\n planner: RunQueuePlanner;\n plan: ExecutionFrontierPlan;\n base: ReturnType<ExecutionContextFactory[\"create\"]>;\n data: ReturnType<RunDataFactory[\"create\"]>;\n }): Promise<RunResult> {\n const initialNodeSnapshotsByNodeId = this.semantics.applySkippedSnapshots({\n runId: args.runId,\n workflowId: args.workflow.id,\n parent: args.parent,\n currentState: args.plan.currentState,\n skippedNodeIds: args.plan.skippedNodeIds,\n preservedPinnedNodeIds: args.plan.preservedPinnedNodeIds,\n finishedAt: args.startedAt,\n });\n\n if (args.plan.rootNodeId) {\n const startDef = WorkflowTopology.fromWorkflow(args.workflow).defsById.get(args.plan.rootNodeId);\n if (!startDef) {\n throw new Error(`Unknown frontier nodeId: ${args.plan.rootNodeId}`);\n }\n const startItems = args.plan.rootNodeInput ?? [];\n const request = this.nodeActivationRequestComposer.createSingleFromDefinition({\n runId: args.runId,\n workflowId: args.workflow.id,\n definition: startDef,\n parent: args.parent,\n executionOptions: args.executionOptions,\n batchId: \"batch_1\",\n input: startItems,\n base: args.base,\n data: args.data,\n });\n return await this.activationEnqueueService.enqueueActivation({\n runId: args.runId,\n workflowId: args.workflow.id,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n pendingQueue: [],\n request,\n previousNodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,\n planner: args.planner,\n engineCounters: { completedNodeActivations: 0 },\n connectionInvocations: args.plan.currentState.connectionInvocations ?? [],\n });\n }\n\n return await this.scheduleQueuedPlan({\n runId: args.runId,\n workflowId: args.workflow.id,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n workflow: args.workflow,\n planner: args.planner,\n queue: [...args.plan.queue],\n base: args.base,\n data: args.data,\n nodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,\n connectionInvocations: args.plan.currentState.connectionInvocations ?? [],\n });\n }\n\n private async scheduleQueuedPlan(args: {\n runId: RunId;\n workflowId: WorkflowId;\n startedAt: string;\n parent?: ParentExecutionRef;\n executionOptions?: RunExecutionOptions;\n control: PersistedRunControlState | undefined;\n workflowSnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"workflowSnapshot\"];\n mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"];\n policySnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"policySnapshot\"];\n workflow: WorkflowDefinition;\n planner: RunQueuePlanner;\n queue: RunQueueEntry[];\n base: ReturnType<ExecutionContextFactory[\"create\"]>;\n data: ReturnType<RunDataFactory[\"create\"]>;\n nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;\n connectionInvocations: RunCurrentState[\"connectionInvocations\"];\n }): Promise<RunResult> {\n this.semantics.applyPinnedQueueSkips({\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n mutableState: args.mutableState,\n planner: args.planner,\n queue: args.queue,\n data: args.data,\n nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,\n finishedAt: args.startedAt,\n });\n const next = args.planner.nextActivation(args.queue);\n if (!next) {\n return await this.completeRun({\n runId: args.runId,\n workflowId: args.workflowId,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n workflow: args.workflow,\n data: args.data,\n nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,\n connectionInvocations: args.connectionInvocations,\n });\n }\n\n const definition = WorkflowTopology.fromWorkflow(args.workflow).defsById.get(next.nodeId);\n if (!definition || definition.kind !== \"node\") {\n throw new Error(`Node ${next.nodeId} is not a runnable node`);\n }\n\n const request = this.nodeActivationRequestComposer.createFromPlannedActivation({\n next,\n base: args.base,\n data: args.data,\n runId: args.runId,\n workflowId: args.workflowId,\n parent: args.parent,\n executionOptions: args.executionOptions,\n nodeDefinition: definition,\n });\n\n return await this.activationEnqueueService.enqueueActivation({\n runId: args.runId,\n workflowId: args.workflowId,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n pendingQueue: args.queue,\n request,\n previousNodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,\n planner: args.planner,\n engineCounters: { completedNodeActivations: 0 },\n connectionInvocations: args.connectionInvocations ?? [],\n });\n }\n\n private async completeRun(args: {\n runId: RunId;\n workflowId: WorkflowId;\n startedAt: string;\n parent?: ParentExecutionRef;\n executionOptions?: RunExecutionOptions;\n control: PersistedRunControlState | undefined;\n workflowSnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"workflowSnapshot\"];\n mutableState: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"mutableState\"];\n policySnapshot: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository[\"load\"]>>>[\"policySnapshot\"];\n workflow: WorkflowDefinition;\n data: ReturnType<RunDataFactory[\"create\"]>;\n nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;\n connectionInvocations: RunCurrentState[\"connectionInvocations\"];\n }): Promise<RunResult> {\n await this.workflowExecutionRepository.save({\n runId: args.runId,\n workflowId: args.workflowId,\n startedAt: args.startedAt,\n parent: args.parent,\n executionOptions: args.executionOptions,\n control: args.control,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n policySnapshot: args.policySnapshot,\n engineCounters: { completedNodeActivations: 0 },\n connectionInvocations: args.connectionInvocations ? [...args.connectionInvocations] : [],\n status: \"completed\",\n pending: undefined,\n queue: [],\n outputsByNode: args.data.dump(),\n nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,\n });\n const result: RunResult = {\n runId: args.runId,\n workflowId: args.workflowId,\n startedAt: args.startedAt,\n status: \"completed\",\n outputs: this.semantics.resolveResultOutputs(\n args.workflow,\n args.control?.stopCondition,\n args.data.dump() as Record<NodeId, NodeOutputs>,\n ),\n };\n this.waiters.resolveRunCompletion(result);\n return result;\n }\n}\n","import type {\n ExecutionMode,\n NodeConfigBase,\n NodeId,\n NodeOffloadPolicy,\n NodeSchedulerDecision,\n WorkflowId,\n} from \"../types\";\nexport class ConfigDrivenOffloadPolicy implements NodeOffloadPolicy {\n private readonly defaultMode: ExecutionMode;\n\n constructor(defaultMode: ExecutionMode = \"worker\") {\n this.defaultMode = defaultMode;\n }\n\n decide(args: { workflowId: WorkflowId; nodeId: NodeId; config: NodeConfigBase }): NodeSchedulerDecision {\n const hint = args.config.execution?.hint;\n const queue = args.config.execution?.queue;\n\n if (hint === \"local\") return { mode: \"local\" };\n if (hint === \"worker\") return { mode: \"worker\", queue };\n\n // If a queue is specified, treat it as an implicit worker hint.\n if (queue) return { mode: \"worker\", queue };\n\n return { mode: this.defaultMode };\n }\n}\n","import type {\n NodeActivationContinuation,\n NodeActivationReceipt,\n NodeActivationRequest,\n NodeActivationScheduler,\n NodeExecutionRequest,\n NodeExecutionScheduler,\n NodeOffloadPolicy,\n} from \"../types\";\nimport { InlineDrivingScheduler } from \"./InlineDrivingScheduler\";\n\ntype SchedulerSelection = Readonly<{\n mode: NodeActivationReceipt[\"mode\"];\n queue?: string;\n decision: \"runIntentOverride\" | \"nodePolicy\" | \"containerDefault\";\n}>;\n\nexport class DefaultDrivingScheduler implements NodeActivationScheduler {\n constructor(\n private readonly offloadPolicy: NodeOffloadPolicy,\n private readonly workerScheduler: NodeExecutionScheduler,\n private readonly inline: InlineDrivingScheduler,\n ) {}\n\n setContinuation(continuation: NodeActivationContinuation): void {\n this.inline.setContinuation(continuation);\n }\n\n async enqueue(request: NodeActivationRequest): Promise<NodeActivationReceipt> {\n const selection = await this.selectScheduler(request);\n if (selection.mode === \"worker\") {\n if (request.kind === \"multi\") {\n throw new Error(`Multi-input node ${request.nodeId} cannot be scheduled to worker (insert local placement)`);\n }\n\n const workerRequest: NodeExecutionRequest = {\n runId: request.runId,\n activationId: request.activationId,\n workflowId: request.workflowId,\n nodeId: request.nodeId,\n input: request.input,\n parent: request.parent,\n queue: selection.queue,\n executionOptions: request.executionOptions,\n };\n\n const receipt = await this.workerScheduler.enqueue(workerRequest);\n return { receiptId: receipt.receiptId, mode: \"worker\", queue: selection.queue };\n }\n\n return await this.enqueueInline(request);\n }\n\n notifyPendingStatePersisted(runId: string): void {\n this.inline.notifyPendingStatePersisted(runId);\n }\n\n /**\n * Scheduler precedence is explicit:\n * 1. run-intent override (`executionOptions.localOnly`)\n * 2. node-level execution hint / queue policy\n * 3. container-default scheduler policy fallback\n */\n private async selectScheduler(request: NodeActivationRequest): Promise<SchedulerSelection> {\n if (request.executionOptions?.localOnly) {\n return {\n mode: \"local\",\n decision: \"runIntentOverride\",\n };\n }\n\n const decision = this.offloadPolicy.decide({\n workflowId: request.workflowId,\n nodeId: request.nodeId,\n config: request.ctx.config,\n });\n if (this.hasNodeSchedulingPreference(request)) {\n return {\n mode: decision.mode,\n queue: decision.queue,\n decision: \"nodePolicy\",\n };\n }\n\n return {\n mode: decision.mode,\n queue: decision.queue,\n decision: \"containerDefault\",\n };\n }\n\n private hasNodeSchedulingPreference(request: NodeActivationRequest): boolean {\n return request.ctx.config.execution?.hint !== undefined || request.ctx.config.execution?.queue !== undefined;\n }\n\n private async enqueueInline(request: NodeActivationRequest): Promise<NodeActivationReceipt> {\n const receipt = await this.inline.enqueue(request);\n return { ...receipt, mode: \"local\" };\n }\n}\n","import type { NodeConfigBase, NodeId, NodeOffloadPolicy, NodeSchedulerDecision, WorkflowId } from \"../types\";\n\nexport class HintOnlyOffloadPolicy implements NodeOffloadPolicy {\n decide(args: { workflowId: WorkflowId; nodeId: NodeId; config: NodeConfigBase }): NodeSchedulerDecision {\n const hint = args.config.execution?.hint;\n if (hint === \"worker\") return { mode: \"worker\", queue: args.config.execution?.queue };\n return { mode: \"local\" };\n }\n}\n","import type {\n NodeActivationContinuation,\n NodeActivationReceipt,\n NodeActivationRequest,\n NodeActivationScheduler,\n RunId,\n} from \"../types\";\nimport { NodeExecutor } from \"../execution/NodeExecutor\";\n\nexport class InlineDrivingScheduler implements NodeActivationScheduler {\n private continuation: NodeActivationContinuation | undefined;\n private readonly drainingRuns = new Set<RunId>();\n private readonly queuesByRunId = new Map<\n RunId,\n Array<Readonly<{ request: NodeActivationRequest; receipt: NodeActivationReceipt }>>\n >();\n private readonly scheduledRuns = new Set<RunId>();\n private seq = 0;\n\n constructor(private readonly nodeExecutor: NodeExecutor) {}\n\n setContinuation(continuation: NodeActivationContinuation): void {\n this.continuation = continuation;\n }\n\n async enqueue(request: NodeActivationRequest): Promise<NodeActivationReceipt> {\n const receipt: NodeActivationReceipt = { receiptId: `inline_${++this.seq}`, mode: \"local\" };\n const q = this.queuesByRunId.get(request.runId) ?? [];\n q.push({ request, receipt });\n this.queuesByRunId.set(request.runId, q);\n\n return receipt;\n }\n\n notifyPendingStatePersisted(runId: RunId): void {\n if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) {\n return;\n }\n this.scheduleDrain(runId);\n }\n\n private async drainRun(runId: RunId): Promise<void> {\n if (this.drainingRuns.has(runId)) return;\n this.drainingRuns.add(runId);\n this.scheduledRuns.delete(runId);\n try {\n const q = this.queuesByRunId.get(runId) ?? [];\n while (q.length > 0) {\n const next = q.shift()!;\n const { request } = next;\n\n const cont = this.continuation;\n if (!cont) throw new Error(\"InlineDrivingScheduler is missing a continuation (setContinuation was not called)\");\n\n await cont.markNodeRunning({\n runId: request.runId,\n activationId: request.activationId,\n nodeId: request.nodeId,\n inputsByPort: request.kind === \"multi\" ? request.inputsByPort : { in: request.input },\n });\n\n let outputs;\n try {\n outputs = await this.nodeExecutor.execute(request);\n } catch (e) {\n await this.resumeAfterExecutionError(cont, request, this.asError(e));\n continue;\n }\n\n await this.resumeAfterExecutionResult(cont, request, outputs ?? {});\n }\n } finally {\n if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);\n this.drainingRuns.delete(runId);\n if ((this.queuesByRunId.get(runId)?.length ?? 0) > 0) {\n this.scheduleDrain(runId);\n }\n }\n }\n\n private scheduleDrain(runId: RunId): void {\n if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) {\n return;\n }\n this.scheduledRuns.add(runId);\n setTimeout(() => {\n this.scheduledRuns.delete(runId);\n void this.drainRun(runId);\n }, 0);\n }\n\n private async resumeAfterExecutionResult(\n continuation: NodeActivationContinuation,\n request: NodeActivationRequest,\n outputs: unknown,\n ): Promise<void> {\n try {\n await continuation.resumeFromNodeResult({\n runId: request.runId,\n activationId: request.activationId,\n nodeId: request.nodeId,\n outputs: outputs as any,\n });\n } catch (e) {\n this.rethrowUnlessIgnorableContinuationError(e);\n }\n }\n\n private async resumeAfterExecutionError(\n continuation: NodeActivationContinuation,\n request: NodeActivationRequest,\n error: Error,\n ): Promise<void> {\n try {\n await continuation.resumeFromNodeError({\n runId: request.runId,\n activationId: request.activationId,\n nodeId: request.nodeId,\n error,\n });\n } catch (e) {\n this.rethrowUnlessIgnorableContinuationError(e);\n }\n }\n\n private asError(e: unknown): Error {\n return e instanceof Error ? e : new Error(String(e));\n }\n\n private rethrowUnlessIgnorableContinuationError(e: unknown): void {\n if (this.isIgnorableContinuationError(e)) {\n return;\n }\n throw this.asError(e);\n }\n\n private isIgnorableContinuationError(e: unknown): boolean {\n const message = this.asError(e).message;\n return (\n message.includes(\" is not pending\") ||\n message.includes(\"activationId mismatch\") ||\n message.includes(\"nodeId mismatch\")\n );\n }\n}\n","import type { NodeExecutionRequest, NodeExecutionScheduler } from \"../types\";\n\nexport class LocalOnlyScheduler implements NodeExecutionScheduler {\n async enqueue(_request: NodeExecutionRequest): Promise<{ receiptId: string }> {\n throw new Error(\"No worker scheduler configured\");\n }\n}\n","import type { ParentExecutionRef, RunExecutionOptions } from \"../../types\";\n\nexport interface EngineExecutionLimitsPolicyConfig {\n readonly defaultMaxNodeActivations: number;\n readonly hardMaxNodeActivations: number;\n readonly defaultMaxSubworkflowDepth: number;\n readonly hardMaxSubworkflowDepth: number;\n}\n\n/** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */\nexport const ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig = {\n defaultMaxNodeActivations: 100_000,\n hardMaxNodeActivations: 100_000,\n defaultMaxSubworkflowDepth: 32,\n hardMaxSubworkflowDepth: 32,\n};\n\n/**\n * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.\n */\nexport class EngineExecutionLimitsPolicy {\n constructor(private readonly config: EngineExecutionLimitsPolicyConfig = ENGINE_EXECUTION_LIMITS_DEFAULTS) {}\n\n /**\n * Effective options for a new root run (depth 0): defaults merged with engine ceilings.\n * Replaces a separate one-method factory for root-run bootstrap.\n */\n createRootExecutionOptions(): RunExecutionOptions {\n return this.mergeExecutionOptionsForNewRun(undefined, undefined);\n }\n\n mergeExecutionOptionsForNewRun(\n parent: ParentExecutionRef | undefined,\n user: RunExecutionOptions | undefined,\n ): RunExecutionOptions {\n const subworkflowDepth = parent === undefined ? 0 : (parent.subworkflowDepth ?? 0) + 1;\n const inheritedMaxNode = parent?.engineMaxNodeActivations;\n const inheritedMaxSub = parent?.engineMaxSubworkflowDepth;\n const maxNodeActivations = this.capNumber(\n user?.maxNodeActivations ?? inheritedMaxNode,\n this.config.defaultMaxNodeActivations,\n this.config.hardMaxNodeActivations,\n );\n const maxSubworkflowDepth = this.capNumber(\n user?.maxSubworkflowDepth ?? inheritedMaxSub,\n this.config.defaultMaxSubworkflowDepth,\n this.config.hardMaxSubworkflowDepth,\n );\n if (subworkflowDepth > maxSubworkflowDepth) {\n throw new Error(\n `Subworkflow nesting depth ${subworkflowDepth} exceeds maxSubworkflowDepth ${maxSubworkflowDepth} (run would be a child of parent run).`,\n );\n }\n return {\n ...user,\n subworkflowDepth,\n maxNodeActivations,\n maxSubworkflowDepth,\n };\n }\n\n private capNumber(requested: number | undefined, defaultValue: number, hardCeiling: number): number {\n const base = requested === undefined ? defaultValue : requested;\n return Math.min(base, hardCeiling);\n }\n}\n","import { ReadableStream } from \"node:stream/web\";\n\nimport type { BinaryBody } from \"../types\";\n\nexport class BinaryBodyBufferReader {\n async read(body: BinaryBody): Promise<Uint8Array> {\n if (body instanceof Uint8Array) {\n return body;\n }\n if (body instanceof ArrayBuffer) {\n return new Uint8Array(body);\n }\n if (body instanceof ReadableStream) {\n return await this.readReadableStream(body);\n }\n return await this.readAsyncIterable(body);\n }\n\n private async readReadableStream(body: ReadableStream<Uint8Array>): Promise<Uint8Array> {\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n let totalSize = 0;\n try {\n while (true) {\n const result = await reader.read();\n if (result.done) {\n break;\n }\n chunks.push(result.value);\n totalSize += result.value.byteLength;\n }\n } finally {\n reader.releaseLock();\n }\n return this.joinChunks(chunks, totalSize);\n }\n\n private async readAsyncIterable(body: AsyncIterable<Uint8Array>): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n let totalSize = 0;\n for await (const chunk of body) {\n chunks.push(chunk);\n totalSize += chunk.byteLength;\n }\n return this.joinChunks(chunks, totalSize);\n }\n\n private joinChunks(chunks: ReadonlyArray<Uint8Array>, totalSize: number): Uint8Array {\n const bytes = new Uint8Array(totalSize);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n }\n}\n","import { ReadableStream } from \"node:stream/web\";\n\nexport class BinaryBodyReadableStreamFactory {\n constructor(private readonly bytes: Uint8Array) {}\n\n create(): ReadableStream<Uint8Array> {\n const value = this.bytes;\n let consumed = false;\n return new ReadableStream<Uint8Array>({\n pull(controller) {\n if (consumed) {\n controller.close();\n return;\n }\n consumed = true;\n controller.enqueue(value);\n controller.close();\n },\n });\n }\n}\n","import { createHash } from \"node:crypto\";\n\nimport type {\n BinaryBody,\n BinaryStorage,\n BinaryStorageReadResult,\n BinaryStorageStatResult,\n BinaryStorageWriteResult,\n} from \"../types\";\n\nimport { BinaryBodyBufferReader } from \"./BinaryBodyBufferReader\";\nimport { BinaryBodyReadableStreamFactory } from \"./BinaryBodyReadableStreamFactory\";\n\nexport class InMemoryBinaryStorage implements BinaryStorage {\n readonly driverName = \"memory\";\n private readonly values = new Map<string, Uint8Array>();\n\n async write(args: { storageKey: string; body: BinaryBody }): Promise<BinaryStorageWriteResult> {\n const bytes = await new BinaryBodyBufferReader().read(args.body);\n this.values.set(args.storageKey, bytes);\n return {\n storageKey: args.storageKey,\n size: bytes.byteLength,\n sha256: createHash(\"sha256\").update(bytes).digest(\"hex\"),\n };\n }\n\n async openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined> {\n const bytes = this.values.get(storageKey);\n if (!bytes) {\n return undefined;\n }\n return {\n body: new BinaryBodyReadableStreamFactory(bytes).create(),\n size: bytes.byteLength,\n };\n }\n\n async stat(storageKey: string): Promise<BinaryStorageStatResult> {\n const bytes = this.values.get(storageKey);\n if (!bytes) {\n return { exists: false };\n }\n return { exists: true, size: bytes.byteLength };\n }\n\n async delete(storageKey: string): Promise<void> {\n this.values.delete(storageKey);\n }\n}\n\nexport { BinaryBodyBufferReader } from \"./BinaryBodyBufferReader\";\nexport { BinaryBodyReadableStreamFactory } from \"./BinaryBodyReadableStreamFactory\";\n","import type { Items, MutableRunData, NodeId, NodeOutputs, OutputPortKey } from \"../types\";\n\nexport class InMemoryRunData implements MutableRunData {\n private readonly byNode = new Map<NodeId, NodeOutputs>();\n\n constructor(initial?: Record<NodeId, NodeOutputs>) {\n if (initial) {\n for (const [nodeId, outputs] of Object.entries(initial)) this.byNode.set(nodeId, outputs);\n }\n }\n\n setOutputs(nodeId: NodeId, outputs: NodeOutputs): void {\n this.byNode.set(nodeId, outputs);\n }\n\n getOutputs(nodeId: NodeId): NodeOutputs | undefined {\n return this.byNode.get(nodeId);\n }\n\n getOutputItems(nodeId: NodeId, output: OutputPortKey = \"main\"): Items {\n return this.byNode.get(nodeId)?.[output] ?? [];\n }\n\n getOutputItem(nodeId: NodeId, itemIndex: number, output: OutputPortKey = \"main\") {\n return this.getOutputItems(nodeId, output)[itemIndex];\n }\n\n dump(): Record<NodeId, NodeOutputs> {\n const out: Record<NodeId, NodeOutputs> = {};\n for (const [nodeId, outputs] of this.byNode.entries()) out[nodeId] = outputs;\n return out;\n }\n}\n","import type { MutableRunData, NodeId, NodeOutputs, RunDataFactory } from \"../types\";\nimport { InMemoryRunData } from \"./InMemoryRunData\";\n\nexport class InMemoryRunDataFactory implements RunDataFactory {\n create(initial?: Record<NodeId, NodeOutputs>): MutableRunData {\n return new InMemoryRunData(initial);\n }\n}\n","import type { PersistedRunState } from \"./runTypes\";\n\ntype RunFinishedAtSource = Pick<PersistedRunState, \"status\" | \"nodeSnapshotsByNodeId\">;\n\n/** Derives workflow end time from node snapshots for run listings. */\nexport class RunFinishedAtFactory {\n static resolveIso(state: RunFinishedAtSource): string | undefined {\n if (state.status === \"running\" || state.status === \"pending\") {\n return undefined;\n }\n let max: string | undefined;\n for (const snap of Object.values(state.nodeSnapshotsByNodeId)) {\n if (snap?.finishedAt && (!max || snap.finishedAt > max)) {\n max = snap.finishedAt;\n }\n }\n return max;\n }\n}\n","import type {\n CurrentStateExecutionRequest,\n HttpMethod,\n Items,\n NodeId,\n RunCurrentState,\n RunExecutionOptions,\n RunResult,\n RunStopCondition,\n WebhookInvocationMatch,\n WebhookRunResult,\n WebhookTriggerResolution,\n WorkflowDefinition,\n WorkflowRepository,\n} from \"../types\";\n\nimport { Engine } from \"../orchestration/Engine\";\n\nexport type StartWorkflowIntent = {\n workflow: WorkflowDefinition;\n startAt?: string;\n items: Items;\n parent?: CurrentStateExecutionRequest[\"parent\"];\n executionOptions?: RunExecutionOptions;\n workflowSnapshot?: CurrentStateExecutionRequest[\"workflowSnapshot\"];\n mutableState?: CurrentStateExecutionRequest[\"mutableState\"];\n currentState?: RunCurrentState;\n stopCondition?: RunStopCondition;\n reset?: CurrentStateExecutionRequest[\"reset\"];\n};\n\nexport type RerunFromNodeIntent = {\n workflow: WorkflowDefinition;\n nodeId: NodeId;\n currentState: RunCurrentState;\n items?: Items;\n parent?: CurrentStateExecutionRequest[\"parent\"];\n executionOptions?: RunExecutionOptions;\n workflowSnapshot?: CurrentStateExecutionRequest[\"workflowSnapshot\"];\n mutableState?: CurrentStateExecutionRequest[\"mutableState\"];\n};\n\nexport type MatchedWebhookRunIntent = {\n endpointPath: string;\n method: HttpMethod;\n requestItem: Items[number];\n};\n\nexport type WebhookMatchRunIntent = {\n match: WebhookInvocationMatch;\n requestItem: Items[number];\n};\n\nexport class RunIntentService {\n constructor(\n private readonly engine: Engine,\n private readonly workflowRepository: WorkflowRepository,\n ) {}\n\n async startWorkflow(args: StartWorkflowIntent): Promise<RunResult> {\n if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) {\n return await this.engine.runWorkflow(\n args.workflow,\n args.startAt,\n args.items,\n args.parent,\n args.executionOptions,\n {\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n },\n );\n }\n return await this.engine.runWorkflowFromState({\n workflow: args.workflow,\n items: args.items,\n parent: args.parent,\n executionOptions: args.executionOptions,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n currentState: args.currentState,\n stopCondition: args.stopCondition ?? { kind: \"workflowCompleted\" },\n reset: args.reset,\n });\n }\n\n async rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult> {\n if (args.items) {\n return await this.engine.runWorkflow(args.workflow, args.nodeId, args.items, args.parent, args.executionOptions, {\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n });\n }\n return await this.engine.runWorkflowFromState({\n workflow: args.workflow,\n parent: args.parent,\n executionOptions: args.executionOptions,\n workflowSnapshot: args.workflowSnapshot,\n mutableState: args.mutableState,\n currentState: args.currentState,\n stopCondition: { kind: \"workflowCompleted\" },\n reset: { clearFromNodeId: args.nodeId },\n });\n }\n\n resolveWebhookTrigger(args: { endpointPath: string; method: HttpMethod }): WebhookTriggerResolution {\n return this.engine.resolveWebhookTrigger(args);\n }\n\n async runMatchedWebhook(args: MatchedWebhookRunIntent): Promise<WebhookRunResult> {\n const resolution = this.resolveWebhookTrigger(args);\n if (resolution.status === \"notFound\") {\n throw new Error(\"Unknown webhook endpoint\");\n }\n if (resolution.status === \"methodNotAllowed\") {\n throw new Error(\"Method not allowed\");\n }\n return await this.runWebhookMatch({\n match: resolution.match,\n requestItem: args.requestItem,\n });\n }\n\n async runWebhookMatch(args: WebhookMatchRunIntent): Promise<WebhookRunResult> {\n const workflow = this.workflowRepository.get(args.match.workflowId);\n if (!workflow) {\n throw new Error(`Unknown workflowId: ${args.match.workflowId}`);\n }\n const scheduled = await this.engine.runWorkflow(\n workflow,\n args.match.nodeId,\n [args.requestItem],\n undefined,\n this.createWebhookExecutionOptions(),\n );\n if (scheduled.status === \"failed\") {\n throw new Error(scheduled.error.message);\n }\n if (scheduled.status === \"completed\") {\n return {\n runId: scheduled.runId,\n workflowId: scheduled.workflowId,\n startedAt: scheduled.startedAt,\n runStatus: \"completed\",\n response: scheduled.outputs,\n };\n }\n return await Promise.race([\n this.engine.waitForWebhookResponse(scheduled.runId),\n this.engine.waitForCompletion(scheduled.runId).then((completed) => {\n if (completed.status === \"failed\") {\n throw new Error(completed.error.message);\n }\n return {\n runId: completed.runId,\n workflowId: completed.workflowId,\n startedAt: completed.startedAt,\n runStatus: \"completed\" as const,\n response: completed.outputs,\n } satisfies WebhookRunResult;\n }),\n ]);\n }\n\n /**\n * Webhook-triggered runs always force inline execution first.\n * This is the highest-precedence scheduler override: it wins over node hints and container defaults.\n */\n private createWebhookExecutionOptions(): RunExecutionOptions {\n return {\n localOnly: true,\n webhook: true,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAa,0BAAb,MAAqC;CACnC,OAAgB,oBAAoB;CAEpC,OAAO,8BAA8B,cAA8B;AACjE,SAAO,GAAG,eAAe,KAAK,kBAAkB;;CAGlD,OAAO,qBAAqB,cAAsB,UAA0B;EAC1E,MAAM,aAAa,KAAK,kBAAkB,SAAS;AACnD,SAAO,GAAG,eAAe,KAAK,kBAAkB,MAAM,KAAK,oBAAoB;;CAGjF,OAAO,gCAAgC,QAAyB;AAC9D,SAAO,OAAO,SAAS,GAAG,KAAK,kBAAkB,KAAK;;CAGxD,OAAO,uBAAuB,QAAyB;AACrD,SAAO,OAAO,SAAS,GAAG,KAAK,kBAAkB,MAAM,KAAK,oBAAoB;;;CAIlF,OAAO,8BAA8B,cAAsB,QAAyB;AAClF,SAAO,OAAO,WAAW,GAAG,eAAe,KAAK,oBAAoB;;;CAItE,OAAO,kBAAkB,UAA0B;AACjD,SACE,SACG,MAAM,CACN,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG,IAAI;;;;;;;;;ACjCpC,IAAa,mCAAb,MAA8C;CAC5C,AAAiB;CAEjB,YAAY,UAA8B;AACxC,OAAK,qBAAqB,KAAK,0BAA0B,SAAS;;CAGpE,wBAAwB,QAAyB;AAC/C,SAAO,KAAK,mBAAmB,IAAI,OAAO;;CAG5C,mBAAmB,QAAyB;AAC1C,SAAO,CAAC,KAAK,mBAAmB,IAAI,OAAO;;CAG7C,gCAAgC,OAAqE;AACnG,SAAO,MAAM,QAAQ,MAAM,KAAK,mBAAmB,EAAE,GAAG,CAAC;;CAG3D,AAAQ,0BAA0B,UAAmD;EACnF,MAAM,sBAAM,IAAI,KAAa;AAC7B,OAAK,MAAM,cAAc,S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