@codemation/core 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/{CostCatalogContract-B9aYIqJu.d.cts → CostCatalogContract-Dwo-ZamG.d.cts} +2 -2
  3. package/dist/EngineRuntimeRegistration.types-BiNasx3G.d.cts +54 -0
  4. package/dist/EngineRuntimeRegistration.types-Dq4ucrdo.d.ts +21 -0
  5. package/dist/{InMemoryRunDataFactory-C3rIszrW.d.cts → InMemoryRunDataFactory-D2U9azmZ.d.cts} +2 -20
  6. package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs} +1 -1
  7. package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs.map} +1 -1
  8. package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js → InMemoryRunEventBusRegistry-Layt2xgm.js} +1 -1
  9. package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js.map → InMemoryRunEventBusRegistry-Layt2xgm.js.map} +1 -1
  10. package/dist/{ItemsInputNormalizer-UCpn7luX.d.cts → ItemsInputNormalizer-A5txcOWX.d.cts} +3 -98
  11. package/dist/{ItemsInputNormalizer-B9SdLG24.cjs → ItemsInputNormalizer-C1fv3sMW.cjs} +2 -2
  12. package/dist/ItemsInputNormalizer-C1fv3sMW.cjs.map +1 -0
  13. package/dist/{ItemsInputNormalizer-DoOawd9R.d.ts → ItemsInputNormalizer-D2vrMrX1.d.ts} +2 -62
  14. package/dist/{ItemsInputNormalizer-CZEODg94.js → ItemsInputNormalizer-fUYo4GLV.js} +2 -2
  15. package/dist/ItemsInputNormalizer-fUYo4GLV.js.map +1 -0
  16. package/dist/{RunIntentService-0f3ICjAz.d.cts → RunIntentService-DKxuHTUz.d.cts} +2 -15
  17. package/dist/{RunIntentService-Dx_HHxDX.d.ts → RunIntentService-DrpKli2k.d.ts} +2 -22
  18. package/dist/{agentMcpTypes-B11B3Hd-.d.cts → agentMcpTypes-BHX4RQCC.d.cts} +24 -524
  19. package/dist/bootstrap/index.cjs +9 -5
  20. package/dist/bootstrap/index.d.cts +32 -106
  21. package/dist/bootstrap/index.d.ts +18 -17
  22. package/dist/bootstrap/index.js +6 -5
  23. package/dist/{bootstrap-Be0LB0nh.cjs → bootstrap-CTB53rEF.cjs} +9 -60
  24. package/dist/bootstrap-CTB53rEF.cjs.map +1 -0
  25. package/dist/{bootstrap-pSQdsMfa.js → bootstrap-DmqKheCI.js} +6 -57
  26. package/dist/bootstrap-DmqKheCI.js.map +1 -0
  27. package/dist/browser.cjs +12 -11
  28. package/dist/browser.d.cts +4 -4
  29. package/dist/browser.d.ts +3 -3
  30. package/dist/browser.js +3 -2
  31. package/dist/contracts-7L1wJHdk.cjs +569 -0
  32. package/dist/contracts-7L1wJHdk.cjs.map +1 -0
  33. package/dist/contracts-CjJ5CZ7N.js +447 -0
  34. package/dist/contracts-CjJ5CZ7N.js.map +1 -0
  35. package/dist/contracts.cjs +9 -2
  36. package/dist/contracts.d.cts +5 -5
  37. package/dist/contracts.d.ts +2 -2
  38. package/dist/contracts.js +3 -2
  39. package/dist/{executionPersistenceContracts-CX9Ql8N1.d.cts → deploymentManifestTypes-B8CDmZZK.d.cts} +65 -81
  40. package/dist/di-C6Ubf9o5.cjs +179 -0
  41. package/dist/di-C6Ubf9o5.cjs.map +1 -0
  42. package/dist/di-Cjiil7U-.js +114 -0
  43. package/dist/di-Cjiil7U-.js.map +1 -0
  44. package/dist/{index-CbJdbIHe.d.ts → index-CRv3_pY3.d.ts} +87 -870
  45. package/dist/{index-uPnD9EE6.d.ts → index-mnLS0iQl.d.ts} +27 -400
  46. package/dist/index.cjs +44 -115
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +17 -524
  49. package/dist/index.d.ts +5 -5
  50. package/dist/index.js +21 -98
  51. package/dist/index.js.map +1 -1
  52. package/dist/{params-Dwl10Ws9.d.cts → params-CrK4iuG1.d.cts} +2 -11
  53. package/dist/{runtime-CSunvf7A.js → runtime-CBFDpmiz.js} +46 -679
  54. package/dist/runtime-CBFDpmiz.js.map +1 -0
  55. package/dist/{runtime-n2tqRwaf.cjs → runtime-Due-FOZ2.cjs} +69 -752
  56. package/dist/runtime-Due-FOZ2.cjs.map +1 -0
  57. package/dist/testing.cjs +8 -40
  58. package/dist/testing.cjs.map +1 -1
  59. package/dist/testing.d.cts +3 -32
  60. package/dist/testing.d.ts +3 -32
  61. package/dist/testing.js +6 -38
  62. package/dist/testing.js.map +1 -1
  63. package/dist/{di-DhwtDRgs.cjs → workflowTypes-BW6Hhee7.cjs} +4 -229
  64. package/dist/workflowTypes-BW6Hhee7.cjs.map +1 -0
  65. package/dist/{di-CEV6wTc4.js → workflowTypes-DZtBTmKf.js} +3 -162
  66. package/dist/workflowTypes-DZtBTmKf.js.map +1 -0
  67. package/package.json +1 -1
  68. package/src/ai/AgentConnectionNodeCollector.ts +0 -4
  69. package/src/ai/AgentMessageConfigNormalizerFactory.ts +0 -4
  70. package/src/ai/AiHost.ts +0 -38
  71. package/src/ai/CallableToolConfig.ts +0 -9
  72. package/src/ai/CallableToolKindToken.ts +0 -4
  73. package/src/authoring/callableTool.types.ts +0 -3
  74. package/src/authoring/defineCollection.types.ts +0 -11
  75. package/src/authoring/defineHumanApprovalNode.types.ts +0 -116
  76. package/src/authoring/defineNode.types.ts +0 -25
  77. package/src/authoring/definePollingTrigger.types.ts +18 -152
  78. package/src/authoring/definePollingTriggerInternals.ts +0 -4
  79. package/src/authoring/nodeBaseOptions.types.ts +0 -14
  80. package/src/binaries/boundedReadBinary.types.ts +0 -16
  81. package/src/bootstrap/index.ts +8 -2
  82. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +0 -5
  83. package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +0 -23
  84. package/src/browser.ts +0 -3
  85. package/src/contracts/AgentBindError.ts +0 -5
  86. package/src/contracts/Clock.ts +0 -1
  87. package/src/contracts/CodemationTelemetryAttributeNames.ts +0 -10
  88. package/src/contracts/NoOpAgentMcpIntegration.ts +0 -6
  89. package/src/contracts/NoOpTelemetrySpanScope.ts +0 -7
  90. package/src/contracts/RetryPolicy.ts +0 -2
  91. package/src/contracts/agentMcpTypes.ts +0 -34
  92. package/src/contracts/assertionTypes.ts +0 -33
  93. package/src/contracts/baseTypes.ts +0 -6
  94. package/src/contracts/collectionTypes.ts +0 -25
  95. package/src/contracts/credentialTypes.ts +13 -60
  96. package/src/contracts/deploymentManifestTypes.ts +158 -0
  97. package/src/contracts/dispatchTypes.ts +29 -0
  98. package/src/contracts/executionPersistenceContracts.ts +0 -33
  99. package/src/contracts/hitlSeamTypes.ts +0 -14
  100. package/src/contracts/humanTaskStoreTypes.ts +0 -2
  101. package/src/contracts/inboxChannelTypes.ts +0 -9
  102. package/src/contracts/index.ts +3 -0
  103. package/src/contracts/itemExpr.ts +0 -18
  104. package/src/contracts/itemMeta.ts +0 -3
  105. package/src/contracts/mcpTypes.ts +0 -16
  106. package/src/contracts/retryPolicySpec.types.ts +0 -10
  107. package/src/contracts/runFinishedAtFactory.ts +0 -1
  108. package/src/contracts/runTypes.ts +0 -74
  109. package/src/contracts/runtimeTypes.ts +4 -131
  110. package/src/contracts/telemetryTypes.ts +0 -7
  111. package/src/contracts/testTriggerTypes.ts +0 -43
  112. package/src/contracts/triggerInvokerTypes.ts +6 -0
  113. package/src/contracts/webhookTypes.ts +0 -8
  114. package/src/contracts/workflowActivationPolicy.ts +0 -5
  115. package/src/contracts/workflowTypes.ts +4 -86
  116. package/src/contracts/workspaceFileTypes.ts +0 -72
  117. package/src/contracts.ts +18 -10
  118. package/src/credentials/CredentialMaterialProvider.types.ts +0 -28
  119. package/src/credentials/ManagedCredentialMaterialWriteError.ts +0 -6
  120. package/src/credentials/ManagedMaterialFetchError.ts +0 -6
  121. package/src/credentials/OAuthFlowExecutor.types.ts +0 -15
  122. package/src/di/CoreTokens.ts +2 -6
  123. package/src/events/ConnectionInvocationEventPublisher.ts +0 -7
  124. package/src/events/NodeEventPublisher.ts +0 -1
  125. package/src/events/runEvents.ts +0 -8
  126. package/src/execution/ActivationEnqueueService.ts +0 -10
  127. package/src/execution/ChildExecutionScopeFactory.ts +0 -13
  128. package/src/execution/FanInMergeByOriginMerger.ts +0 -11
  129. package/src/execution/InProcessRetryRunner.ts +0 -1
  130. package/src/execution/ItemExprResolver.ts +0 -3
  131. package/src/execution/NodeActivationRequestComposer.ts +0 -3
  132. package/src/execution/NodeActivationRequestInputPreparer.ts +0 -5
  133. package/src/execution/NodeExecutionSnapshotFactory.ts +0 -1
  134. package/src/execution/NodeExecutor.ts +1 -17
  135. package/src/execution/NodeSuspensionHandler.ts +1 -39
  136. package/src/execution/PersistedRunStateTerminalBuilder.ts +0 -5
  137. package/src/execution/RunSuspendedError.ts +0 -10
  138. package/src/execution/WorkflowRunExecutionContextFactory.ts +0 -3
  139. package/src/orchestration/AbortControllerFactory.ts +0 -4
  140. package/src/orchestration/Engine.ts +0 -9
  141. package/src/orchestration/NodeExecutionRequestHandlerService.ts +3 -4
  142. package/src/orchestration/RunContinuationService.ts +7 -39
  143. package/src/orchestration/RunStartService.ts +0 -7
  144. package/src/orchestration/TestSuiteOrchestrator.ts +0 -18
  145. package/src/orchestration/TestSuiteRunIdFactory.ts +0 -4
  146. package/src/orchestration/TriggerRuntimeService.ts +3 -2
  147. package/src/planning/CurrentStateFrontierPlanner.ts +0 -1
  148. package/src/planning/RunQueuePlanner.ts +0 -6
  149. package/src/policies/executionLimits/EngineExecutionLimitsPolicy.ts +0 -8
  150. package/src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.ts +0 -3
  151. package/src/runStorage/RunSummaryMapper.ts +0 -1
  152. package/src/runtime/EngineFactory.ts +6 -11
  153. package/src/runtime/RunIntentService.ts +0 -4
  154. package/src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts +0 -4
  155. package/src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts +0 -4
  156. package/src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts +0 -4
  157. package/src/runtime-types/PersistedRuntimeTypeNameResolver.ts +0 -1
  158. package/src/runtime-types/persistedRuntimeTypeModelRegistry.ts +0 -4
  159. package/src/runtime-types/runtimeTypeDecorators.types.ts +0 -12
  160. package/src/scheduler/ConfigDrivenOffloadPolicy.ts +0 -1
  161. package/src/scheduler/DefaultDrivingScheduler.ts +0 -6
  162. package/src/scheduler/InlineDrivingScheduler.ts +0 -13
  163. package/src/serialization/ItemsInputNormalizer.ts +0 -5
  164. package/src/testing/CapturingScheduler.ts +0 -3
  165. package/src/testing/EngineTestKitRunIdFactory.ts +0 -3
  166. package/src/testing/ItemHarnessNode.ts +0 -3
  167. package/src/testing/ItemHarnessNodeConfig.ts +0 -4
  168. package/src/testing/PrefixedSequentialIdGenerator.ts +0 -3
  169. package/src/testing/RegistrarEngineTestKit.types.ts +0 -2
  170. package/src/testing/RejectingCredentialSessionService.ts +0 -4
  171. package/src/testing/SubWorkflowRunnerTestNode.ts +0 -3
  172. package/src/testing/WorkflowTestHarnessManualTrigger.ts +0 -3
  173. package/src/testing/WorkflowTestKitBuilder.ts +0 -4
  174. package/src/testing/WorkflowTestKitRunNodeWorkflowFactory.ts +0 -3
  175. package/src/testing.ts +0 -3
  176. package/src/triggers/polling/PollingTriggerDedupWindow.ts +0 -4
  177. package/src/triggers/polling/PollingTriggerLogger.ts +0 -5
  178. package/src/triggers/polling/PollingTriggerRuntime.ts +0 -5
  179. package/src/types/index.ts +0 -6
  180. package/src/validation/WorkflowEdgePortValidator.ts +0 -5
  181. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +0 -7
  182. package/src/workflow/definition/ConnectionNodeIdFactory.ts +0 -6
  183. package/src/workflow/definition/NodeIterationIdFactory.ts +0 -13
  184. package/src/workflow/definition/WorkflowExecutableNodeClassifier.ts +0 -6
  185. package/src/workflow/dsl/ChainCursorResolver.ts +0 -20
  186. package/src/workflow/dsl/NodeIdSlugifier.ts +0 -9
  187. package/src/workflow/dsl/WhenBuilder.ts +0 -17
  188. package/src/workflow/dsl/WorkflowDefinitionError.ts +0 -9
  189. package/src/workflow/dsl/workflowBuilderTypes.ts +0 -24
  190. package/src/workflowSnapshots/MissingRuntimeParityGuard.ts +24 -0
  191. package/src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts +0 -6
  192. package/src/workflowSnapshots/WorkflowParityMismatchError.ts +18 -0
  193. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +0 -5
  194. package/src/workflowSnapshots/index.ts +3 -0
  195. package/dist/EngineRuntimeRegistration.types-BYAmGMdS.d.cts +0 -81
  196. package/dist/EngineRuntimeRegistration.types-CVLI8DsJ.d.ts +0 -44
  197. package/dist/ItemsInputNormalizer-B9SdLG24.cjs.map +0 -1
  198. package/dist/ItemsInputNormalizer-CZEODg94.js.map +0 -1
  199. package/dist/bootstrap-Be0LB0nh.cjs.map +0 -1
  200. package/dist/bootstrap-pSQdsMfa.js.map +0 -1
  201. package/dist/contracts-CK0x6w_G.cjs +0 -74
  202. package/dist/contracts-CK0x6w_G.cjs.map +0 -1
  203. package/dist/contracts-DXdfTdpW.js +0 -50
  204. package/dist/contracts-DXdfTdpW.js.map +0 -1
  205. package/dist/di-CEV6wTc4.js.map +0 -1
  206. package/dist/di-DhwtDRgs.cjs.map +0 -1
  207. package/dist/runtime-CSunvf7A.js.map +0 -1
  208. package/dist/runtime-n2tqRwaf.cjs.map +0 -1
@@ -1,7 +1,9 @@
1
- import { E as ConnectionNodeIdFactory, _ as CredentialUnboundError, a as injectable, g as SuspensionRequest, h as BINARY_DEFAULT_MAX_BYTES, v as NodeIterationIdFactory, w as resolveItemExprsForExecution, x as AgentConfigInspector, y as AgentConnectionNodeCollector } from "./di-CEV6wTc4.js";
1
+ import { a as SuspensionRequest, c as AgentConnectionNodeCollector, i as BINARY_DEFAULT_MAX_BYTES, o as CredentialUnboundError, s as NodeIterationIdFactory, u as ConnectionNodeIdFactory } from "./workflowTypes-DZtBTmKf.js";
2
+ import { f as AgentConfigInspector, h as resolveItemExprsForExecution } from "./di-Cjiil7U-.js";
3
+ import { a as WorkflowSnapshotCodec, l as node } from "./contracts-CjJ5CZ7N.js";
4
+ import { createHash } from "node:crypto";
2
5
  import { ZodError, z } from "zod";
3
6
  import { ReadableStream } from "node:stream/web";
4
- import { createHash } from "node:crypto";
5
7
 
6
8
  //#region src/contracts/humanTaskStoreTypes.ts
7
9
  const HumanTaskStoreToken = Symbol.for("codemation.core.HumanTaskStore");
@@ -10,12 +12,6 @@ const HumanTaskStoreToken = Symbol.for("codemation.core.HumanTaskStore");
10
12
  //#region src/contracts/hitlSeamTypes.ts
11
13
  const HitlResumeTokenSignerToken = Symbol.for("codemation.core.HitlResumeTokenSigner");
12
14
  const HitlTimeoutJobSchedulerToken = Symbol.for("codemation.core.HitlTimeoutJobScheduler");
13
- /**
14
- * Optional workspace ID injected into NodeSuspensionHandler in managed mode (T7 security fix).
15
- * Allows the handler to stamp the workspaceId on each HumanTaskRecord so HitlCallbackHandler
16
- * can assert workspace identity independently of the HMAC middleware.
17
- * Not registered in non-managed mode; NodeSuspensionHandler defaults to null.
18
- */
19
15
  const HitlWorkspaceIdToken = Symbol.for("codemation.core.HitlWorkspaceId");
20
16
 
21
17
  //#endregion
@@ -30,115 +26,6 @@ var DefinedNodeRegistry = class {
30
26
  }
31
27
  };
32
28
 
33
- //#endregion
34
- //#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
35
- /** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
36
- const persistedRuntimeTypeMetadataKey = Symbol.for("codemation.core.persistedRuntimeTypeMetadata");
37
- /** Normalizes decorator options so persistence metadata has stable defaults. */
38
- var PersistedRuntimeTypeDecoratorDefaults = class {
39
- static appPackageName = "app";
40
- static apply(options) {
41
- return {
42
- ...options,
43
- packageName: options.packageName ?? this.appPackageName
44
- };
45
- }
46
- };
47
-
48
- //#endregion
49
- //#region src/runtime-types/PersistedRuntimeTypeNameResolver.ts
50
- /** Resolves the persisted type name from either an explicit override or the class name itself. */
51
- var PersistedRuntimeTypeNameResolver = class {
52
- static resolve(target, override) {
53
- const resolved = override ?? target.name;
54
- if (!resolved) throw new Error("Persisted runtime token metadata requires a named class or an explicit decorator name override.");
55
- return resolved;
56
- }
57
- };
58
-
59
- //#endregion
60
- //#region src/runtime-types/StackTraceCallSitePathResolver.ts
61
- var StackTraceCallSitePathResolver = class {
62
- static resolve(decoratorFileUrl) {
63
- const stack = (/* @__PURE__ */ new Error()).stack ?? "";
64
- for (const line of stack.split("\n")) {
65
- const candidate = this.extractPath(line.trim());
66
- if (!candidate) continue;
67
- if (candidate === decoratorFileUrl || candidate.includes("runtimeTypeDecorators")) continue;
68
- return candidate;
69
- }
70
- }
71
- static extractPath(line) {
72
- const fileUrlMatch = line.match(/file:\/\/[^\s)]+/);
73
- if (fileUrlMatch) return fileUrlMatch[0];
74
- const parenMatch = line.match(/\((\/[^)]+)\)/);
75
- if (parenMatch) return parenMatch[1];
76
- return line.match(/at (\/[^\s]+)/)?.[1];
77
- }
78
- };
79
-
80
- //#endregion
81
- //#region src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts
82
- /**
83
- * Defines and retrieves persisted runtime metadata on decorated classes.
84
- * The metadata is attached as a non-enumerable property so runtime objects stay serializable.
85
- */
86
- var PersistedRuntimeTypeMetadataStore = class {
87
- static define(target, kind, options, decoratorFileUrl) {
88
- const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);
89
- const metadata = {
90
- persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),
91
- kind,
92
- packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,
93
- sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl)
94
- };
95
- Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {
96
- configurable: false,
97
- enumerable: false,
98
- writable: false,
99
- value: metadata
100
- });
101
- }
102
- static get(target) {
103
- if (!target || typeof target !== "function" && typeof target !== "object") return;
104
- return target[persistedRuntimeTypeMetadataKey];
105
- }
106
- };
107
-
108
- //#endregion
109
- //#region src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts
110
- /**
111
- * Applies both tsyringe injectability and persisted runtime metadata in one decorator.
112
- * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.
113
- */
114
- var InjectableRuntimeDecoratorComposer = class {
115
- static compose(kind, options, decoratorFileUrl) {
116
- return (target) => {
117
- injectable()(target);
118
- PersistedRuntimeTypeMetadataStore.define(target, kind, options, decoratorFileUrl);
119
- };
120
- }
121
- };
122
-
123
- //#endregion
124
- //#region src/runtime-types/runtimeTypeDecorators.types.ts
125
- /** Reads persisted runtime metadata from a decorated class or object. */
126
- function getPersistedRuntimeTypeMetadata(target) {
127
- return PersistedRuntimeTypeMetadataStore.get(target);
128
- }
129
- /** Marks a class as a persisted node runtime type and an injectable tsyringe service. */
130
- function node(options = {}) {
131
- return InjectableRuntimeDecoratorComposer.compose("node", options, import.meta.url);
132
- }
133
- /** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */
134
- function tool(options = {}) {
135
- return InjectableRuntimeDecoratorComposer.compose("tool", options, import.meta.url);
136
- }
137
- /** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */
138
- function chatModel(options = {}) {
139
- return InjectableRuntimeDecoratorComposer.compose("chatModel", options, import.meta.url);
140
- }
141
-
142
29
  //#endregion
143
30
  //#region src/authoring/defineNode.types.ts
144
31
  const definedNodeCredentialRequirementFactory = {
@@ -294,60 +181,9 @@ function defineBatchNode(options) {
294
181
 
295
182
  //#endregion
296
183
  //#region src/authoring/defineHumanApprovalNode.types.ts
297
- /**
298
- * Returns `true` when `node` was created by {@link defineHumanApprovalNode}.
299
- * Uses the `humanApprovalToolBehavior` typed field as the discriminant.
300
- */
301
184
  function isHumanApprovalNode(node$1) {
302
185
  return typeof node$1 === "object" && node$1 !== null && "humanApprovalToolBehavior" in node$1 && typeof node$1.humanApprovalToolBehavior === "object";
303
186
  }
304
- /**
305
- * Authoring helper that compiles a HITL approval channel down to a regular
306
- * {@link defineNode}-backed node with `SuspensionRequest` semantics.
307
- *
308
- * **Fast-forward decision semantics:**
309
- * - On the first `execute` call (no `ctx.resumeContext`): throws a `SuspensionRequest`
310
- * that calls the author's `deliver`. The engine persists the suspension and continues.
311
- * - On resume (`ctx.resumeContext` set): calls `onDecision`/`onTimeout` as appropriate,
312
- * merges a `decision` key into `item.json`, and returns an item with the original
313
- * `binary` map passed by reference (no copy).
314
- *
315
- * **Output shape per item:**
316
- * ```ts
317
- * // Input: { json: { invoiceId: 42 }, binary?: {...} }
318
- * // Output: { json: { invoiceId: 42, decision: { status: "approved", actor, decidedAt } }, binary: <unchanged> }
319
- * ```
320
- * If `item.json` already has a `decision` key it is **overwritten**. Namespace as
321
- * needed if your schema reserves that key for another purpose.
322
- *
323
- * **Predicate persistence:**
324
- * The `approvedPredicate` function is NOT serialized to the suspension record (except
325
- * as an audit-only string via `toString()`). On resume, the workflow definition is
326
- * reloaded from code at process start and the predicate closure is rebuilt naturally.
327
- * If a deploy ships a changed predicate between suspend and resume, the *new* predicate
328
- * runs — document this in your runbook when the predicate carries business logic that
329
- * may change across deploys.
330
- *
331
- * @example
332
- * ```ts
333
- * export const slackApprovalNode = defineHumanApprovalNode({
334
- * key: "my-plugin.slackApproval",
335
- * title: "Slack Approval",
336
- * channel: "slack",
337
- * configSchema: z.object({ channel: z.string(), message: z.string() }),
338
- * decisionSchema: z.object({ approved: z.boolean(), note: z.string().optional() }),
339
- *
340
- * async deliver({ task, config, item }, ctx) {
341
- * const ts = await postSlackMessage(config.channel, `Approve? <${task.resumeUrl}>`);
342
- * return { channel: config.channel, ts };
343
- * },
344
- *
345
- * async onDecision({ decision, actor, delivery }, ctx) {
346
- * await updateSlackMessage(delivery.channel, delivery.ts, decision.approved ? "✅" : "❌");
347
- * },
348
- * });
349
- * ```
350
- */
351
187
  function defineHumanApprovalNode(opts) {
352
188
  const resolvedPredicate = resolveApprovedPredicate(opts.decisionSchema, opts.approvedPredicate);
353
189
  const timeout = opts.defaultTimeout ?? "24h";
@@ -449,7 +285,6 @@ async function handleResume(item, resumeContext, decisionSchema, resolvedPredica
449
285
  //#endregion
450
286
  //#region src/workflow/dsl/WhenBuilder.ts
451
287
  var WhenBuilder = class WhenBuilder {
452
- /** Tail endpoint of the arm this builder added (set by addBranch). */
453
288
  armEndpoint;
454
289
  constructor(wf, from, branchPort, priorEndpoints = []) {
455
290
  this.wf = wf;
@@ -494,27 +329,15 @@ var WhenBuilder = class WhenBuilder {
494
329
  b.addBranch(list);
495
330
  return b;
496
331
  };
497
- /**
498
- * Continue the trunk after a boolean `.when(...)` branch chain, auto-merging EVERY branch
499
- * tail accumulated across the chain into the next node — the same fan-in the object form
500
- * produces. Typed as `ChainCursor<TCurrentJson>` (the pre-branch item type): boolean arms
501
- * carry no output guard so the merged item type is underdetermined — use the object form
502
- * `.when({ true: [...], false: [...] })` when you need a precise merged type inline.
503
- */
504
332
  then(config) {
505
333
  return this.toCursor().then(config);
506
334
  }
507
- /**
508
- * Chainable human-approval step after a boolean `.when(...)` branch chain — merges every
509
- * branch tail into the approval node. Mirrors `ChainCursor.humanApproval`.
510
- */
511
335
  humanApproval(node$1, config, metadata) {
512
336
  return this.toCursor().humanApproval(node$1, config, metadata);
513
337
  }
514
338
  build() {
515
339
  return this.wf.build();
516
340
  }
517
- /** Endpoints of every arm added so far in this chain (prior arms + this one). */
518
341
  get accumulatedEndpoints() {
519
342
  return this.armEndpoint ? [...this.priorEndpoints, this.armEndpoint] : this.priorEndpoints;
520
343
  }
@@ -525,30 +348,6 @@ var WhenBuilder = class WhenBuilder {
525
348
 
526
349
  //#endregion
527
350
  //#region src/workflow/dsl/workflowBuilderTypes.ts
528
- /**
529
- * Flags a node's config so its output is MERGED onto `item.json` (shallow, output-wins) instead of
530
- * replacing it — the config-level twin of {@link ChainCursor.thenMerge}.
531
- *
532
- * Unlike `.thenMerge` (a cursor method that only works on the trunk), `mergeForward` operates on a
533
- * bare config, so it is usable in ANY position — including inside a `.when({ true: [...] })` branch
534
- * arm, where the steps are a flat array of configs (not a cursor). Wrap a payload-REPLACING node
535
- * (e.g. an extractor) in `mergeForward(node.create(...))` so prior fields survive into the next step.
536
- *
537
- * The OUTPUT type becomes `TIn & TOut` (the intersection), mirroring `.thenMerge`'s return type at
538
- * the config level — so the next step in the branch array sees both the prior fields and the node's
539
- * output. The INPUT type stays `TIn` (the node still receives the pre-merge item).
540
- *
541
- * @example
542
- * ```ts
543
- * workflow
544
- * .trigger(...)
545
- * .when({
546
- * true: [mergeForward(extractor.create(...))], // output merges onto item.json; { a } survives
547
- * false: [...],
548
- * })
549
- * .build();
550
- * ```
551
- */
552
351
  function mergeForward(config) {
553
352
  config.mergeJson = true;
554
353
  return config;
@@ -571,11 +370,6 @@ var ChainCursor = class ChainCursor {
571
370
  ...inputPortHint ? { inputPortHint } : {}
572
371
  }]);
573
372
  }
574
- /**
575
- * Append a step whose output is MERGED onto `item.json` (shallow, output-wins) instead of
576
- * replacing it — so earlier fields (e.g. trigger metadata) survive a transform/OCR/extraction
577
- * node. Use for any node in a pipeline where you need data from before it.
578
- */
579
373
  thenMerge(config) {
580
374
  mergeForward(config);
581
375
  return this.then(config);
@@ -648,21 +442,6 @@ var ChainCursor = class ChainCursor {
648
442
  }
649
443
  return new ChainCursor(this.wf, nextEndpoints);
650
444
  }
651
- /**
652
- * Chainable shorthand for `.then(node.create(config, metadata?.name, metadata?.nodeId))`.
653
- *
654
- * Signals to readers that this step suspends the run and waits for a human decision.
655
- * Throws at workflow-build time if `node` was not created via `defineHumanApprovalNode`.
656
- *
657
- * @example
658
- * ```ts
659
- * workflow
660
- * .trigger(...)
661
- * .humanApproval(inboxApproval, { title: "Approve?", body: "...", priority: "normal" })
662
- * .then(nextStep.create(...))
663
- * .build();
664
- * ```
665
- */
666
445
  humanApproval(node$1, config, metadata) {
667
446
  if (!isHumanApprovalNode(node$1)) throw new Error(`.humanApproval() requires a node created via defineHumanApprovalNode (got '${node$1.key ?? String(node$1)}').`);
668
447
  return this.then(node$1.create(config, metadata?.name, metadata?.nodeId));
@@ -679,15 +458,6 @@ var ChainCursor = class ChainCursor {
679
458
 
680
459
  //#endregion
681
460
  //#region src/workflow/dsl/NodeIdSlugifier.ts
682
- /**
683
- * Converts a human-readable node label into a stable, URL-safe identifier segment.
684
- *
685
- * Rules:
686
- * - Lowercase the entire string.
687
- * - Replace every run of characters outside `[a-z0-9]` with a single `-`.
688
- * - Strip any leading or trailing `-` characters.
689
- * - Return `""` for blank/empty input.
690
- */
691
461
  const NodeIdSlugifier = { slugify(label) {
692
462
  if (!label) return "";
693
463
  return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -695,15 +465,6 @@ const NodeIdSlugifier = { slugify(label) {
695
465
 
696
466
  //#endregion
697
467
  //#region src/workflow/dsl/WorkflowDefinitionError.ts
698
- /**
699
- * Thrown by {@link WorkflowBuilder.build} when the workflow definition is structurally invalid.
700
- *
701
- * Common causes:
702
- * - A node has an empty effective id (label is blank and no explicit `id` was given).
703
- * - Two or more nodes share the same effective id (label slugs collide or explicit ids clash).
704
- *
705
- * Fix: provide an explicit `id:` on the offending node configs.
706
- */
707
468
  var WorkflowDefinitionError = class extends Error {
708
469
  constructor(message) {
709
470
  super(message);
@@ -815,17 +576,10 @@ var WorkflowBuilder = class {
815
576
 
816
577
  //#endregion
817
578
  //#region src/workflow/definition/ConnectionInvocationIdFactory.ts
818
- /**
819
- * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
820
- *
821
- * Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
822
- * paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
823
- */
824
579
  var ConnectionInvocationIdFactory = class {
825
580
  static create() {
826
581
  return `cinv_${globalThis.crypto.randomUUID()}`;
827
582
  }
828
- /** Deterministic id for tests when a stable sequence is needed. */
829
583
  static createForTest(runId, connectionNodeId, sequence) {
830
584
  return `cinv_${runId}_${connectionNodeId}_${sequence}`;
831
585
  }
@@ -833,9 +587,6 @@ var ConnectionInvocationIdFactory = class {
833
587
 
834
588
  //#endregion
835
589
  //#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
836
- /**
837
- * Derives which workflow nodes participate in the main execution graph vs connection-only children.
838
- */
839
590
  var WorkflowExecutableNodeClassifier = class {
840
591
  connectionOwnedIds;
841
592
  constructor(workflow) {
@@ -855,9 +606,6 @@ var WorkflowExecutableNodeClassifier = class {
855
606
  for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
856
607
  return ids;
857
608
  }
858
- /**
859
- * Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
860
- */
861
609
  findDefaultExecutableStartNodeId(workflow) {
862
610
  const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
863
611
  if (firstTrigger) return firstTrigger;
@@ -922,13 +670,6 @@ var DefaultWorkflowGraphFactory = class {
922
670
 
923
671
  //#endregion
924
672
  //#region src/events/ConnectionInvocationEventPublisher.ts
925
- /**
926
- * Publishes per-invocation lifecycle records onto the run {@link RunEventBus}.
927
- *
928
- * Surgical, per-invocation events let the UI update the right-side inspector
929
- * timeline as each LLM round / tool call transitions through `running` → `completed`
930
- * (or `failed`) without depending on a coarse `runSaved` poll.
931
- */
932
673
  var ConnectionInvocationEventPublisher = class {
933
674
  constructor(eventBus, parent) {
934
675
  this.eventBus = eventBus;
@@ -956,7 +697,6 @@ var ConnectionInvocationEventPublisher = class {
956
697
 
957
698
  //#endregion
958
699
  //#region src/events/NodeEventPublisher.ts
959
- /** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
960
700
  var NodeEventPublisher = class {
961
701
  constructor(eventBus) {
962
702
  this.eventBus = eventBus;
@@ -976,19 +716,6 @@ var NodeEventPublisher = class {
976
716
 
977
717
  //#endregion
978
718
  //#region src/binaries/boundedReadBinary.types.ts
979
- /**
980
- * Reads all bytes from an already-opened binary stream into a contiguous `Uint8Array`.
981
- *
982
- * Safety contract:
983
- * - `attachment.size` is checked against `maxBytes` *before* any allocation (no OOM).
984
- * - A single buffer of exactly `attachment.size` is pre-allocated; the stream fills it
985
- * directly — no chunks array, no doubling.
986
- * - A byte-count mismatch between the declared size and actual stream content is an error.
987
- *
988
- * This is the single canonical implementation; `ExecutionBinaryService.getBytes`,
989
- * `getText`, and `getJson` all delegate here. The per-package `readBinaryBody` helpers
990
- * in `core-nodes` and `core-nodes-ocr` have been removed in favour of this function.
991
- */
992
719
  async function boundedReadBinary(result, attachment, maxBytes = BINARY_DEFAULT_MAX_BYTES) {
993
720
  if (attachment.size > maxBytes) throw new Error(`Binary attachment size ${attachment.size} bytes exceeds maxBytes ${maxBytes}. Raise the node's maxBytes setting if this document is expected to be larger.`);
994
721
  const out = new Uint8Array(attachment.size);
@@ -1005,18 +732,15 @@ async function boundedReadBinary(result, attachment, maxBytes = BINARY_DEFAULT_M
1005
732
  if (offset !== out.byteLength) throw new Error(`Binary stream produced ${offset} bytes but attachment declared size ${attachment.size}.`);
1006
733
  return out;
1007
734
  }
1008
- /** Shared implementation of `getBytes` used by both binary-service classes. */
1009
735
  async function readBinaryAsBytes(storage, attachment, maxBytes) {
1010
736
  const result = await storage.openReadStream(attachment.storageKey);
1011
737
  if (!result) throw new Error("Binary attachment stream is unavailable.");
1012
738
  return boundedReadBinary(result, attachment, maxBytes);
1013
739
  }
1014
- /** Shared implementation of `getText` used by both binary-service classes. */
1015
740
  async function readBinaryAsText(storage, attachment, maxBytes) {
1016
741
  const bytes = await readBinaryAsBytes(storage, attachment, maxBytes);
1017
742
  return new TextDecoder().decode(bytes);
1018
743
  }
1019
- /** Shared implementation of `getJson` used by both binary-service classes. */
1020
744
  async function readBinaryAsJson(storage, attachment, maxBytes) {
1021
745
  const text = await readBinaryAsText(storage, attachment, maxBytes);
1022
746
  try {
@@ -1360,19 +1084,6 @@ var ActivationEnqueueService = class {
1360
1084
 
1361
1085
  //#endregion
1362
1086
  //#region src/execution/ChildExecutionScopeFactory.ts
1363
- /**
1364
- * Builds a re-rooted child execution context for sub-agent (and other deeply-nested) invocations.
1365
- *
1366
- * At the orchestrator's `agent.tool.call` boundary the inner runtime needs a ctx whose:
1367
- * - `nodeId` is the tool's connection node id (so inner LLM/tool connection ids derive correctly),
1368
- * - `activationId` is fresh (so its connection-invocation rows are uniquely identifiable),
1369
- * - `telemetry` parents children under the tool-call span (not the orchestrator's node span),
1370
- * - `binary` is scoped to the new (nodeId, activationId),
1371
- * - `parentInvocationId` points back to the tool-call invocation for downstream lineage.
1372
- *
1373
- * Registered via factory in {@link EngineRuntimeRegistrar} so constructors stay free of parameter
1374
- * decorators (Next/SWC and coverage tooling cannot parse them on in-repo sources).
1375
- */
1376
1087
  var ChildExecutionScopeFactory = class {
1377
1088
  constructor(activationIdFactory) {
1378
1089
  this.activationIdFactory = activationIdFactory;
@@ -1402,9 +1113,6 @@ var ChildExecutionScopeFactory = class {
1402
1113
 
1403
1114
  //#endregion
1404
1115
  //#region src/contracts/itemMeta.ts
1405
- /**
1406
- * Reads `meta._cm.originIndex` when present (used for fan-in merge-by-origin and Merge routing).
1407
- */
1408
1116
  function getOriginIndexFromItem(item) {
1409
1117
  const v = (item.meta?._cm)?.originIndex;
1410
1118
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
@@ -1412,17 +1120,6 @@ function getOriginIndexFromItem(item) {
1412
1120
 
1413
1121
  //#endregion
1414
1122
  //#region src/execution/FanInMergeByOriginMerger.ts
1415
- /**
1416
- * Default fan-in: combine multi-port {@link NodeInputsByPort} into one {@link Items} batch for per-item nodes.
1417
- *
1418
- * This is used when a single-input per-item node has multiple inbound edges (for example, branch reconverge
1419
- * after an `If` / `Switch`). The default behavior is **append / union** (preserving item payloads) with a
1420
- * deterministic order:
1421
- *
1422
- * - When router origin metadata exists (`meta._cm.originIndex`), items are sorted by origin index so the
1423
- * downstream batch preserves original ordering across branches.
1424
- * - Otherwise, items are appended by port-key order, preserving each port's local order.
1425
- */
1426
1123
  var FanInMergeByOriginMerger = class {
1427
1124
  merge(inputsByPort) {
1428
1125
  const portKeys = Object.keys(inputsByPort).sort();
@@ -1472,11 +1169,6 @@ var NodeInputContractError = class extends Error {
1472
1169
 
1473
1170
  //#endregion
1474
1171
  //#region src/execution/NodeActivationRequestInputPreparer.ts
1475
- /**
1476
- * Validates per-item inputs for {@link RunnableNode} before enqueue persistence (Zod on `item.json`).
1477
- * Does not rewrite `item.json` (wire stays as emitted upstream; engine passes parsed input via `execute` args).
1478
- * Converts multi-input activations into a single-input batch when the node is per-item only (engine fan-in).
1479
- */
1480
1172
  var NodeActivationRequestInputPreparer = class {
1481
1173
  fanInMerger = new FanInMergeByOriginMerger();
1482
1174
  constructor(workflowNodeInstanceFactory) {
@@ -1623,13 +1315,11 @@ var RetryPolicy = class {
1623
1315
  if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);
1624
1316
  if (!Number.isFinite(delayMs) || delayMs < 0) throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);
1625
1317
  }
1626
- /** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */
1627
1318
  static defaultForHttp = {
1628
1319
  kind: "fixed",
1629
1320
  maxAttempts: 3,
1630
1321
  delayMs: 1e3
1631
1322
  };
1632
- /** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */
1633
1323
  static defaultForAiAgent = {
1634
1324
  kind: "fixed",
1635
1325
  maxAttempts: 3,
@@ -1699,12 +1389,6 @@ var NoOpTelemetryArtifactReference = class {
1699
1389
 
1700
1390
  //#endregion
1701
1391
  //#region src/contracts/NoOpTelemetrySpanScope.ts
1702
- /**
1703
- * Standalone no-op {@link NodeExecutionTelemetry} value used as the return for `asNodeTelemetry`.
1704
- *
1705
- * Defined here (instead of in `NoOpNodeExecutionTelemetry.ts`) so that {@link NoOpTelemetrySpanScope}
1706
- * can return it without importing the other module — both no-ops share this leaf.
1707
- */
1708
1392
  const noOpNodeExecutionTelemetry = {
1709
1393
  traceId: "00000000000000000000000000000000",
1710
1394
  spanId: "0000000000000000",
@@ -1739,7 +1423,6 @@ const noOpTelemetrySpanScope = {
1739
1423
  };
1740
1424
  var NoOpTelemetrySpanScope = class {
1741
1425
  static value = noOpTelemetrySpanScope;
1742
- /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
1743
1426
  static nodeExecutionTelemetryValue = noOpNodeExecutionTelemetry;
1744
1427
  };
1745
1428
 
@@ -1776,7 +1459,6 @@ var NoOpExecutionTelemetryFactory = class {
1776
1459
 
1777
1460
  //#endregion
1778
1461
  //#region src/contracts/workflowActivationPolicy.ts
1779
- /** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
1780
1462
  var AllWorkflowsActiveWorkflowActivationPolicy = class {
1781
1463
  isActive(_workflowId) {
1782
1464
  return true;
@@ -1796,25 +1478,15 @@ var CodemationTelemetryAttributeNames = class {
1796
1478
  static connectionInvocationId = "codemation.connection.invocation_id";
1797
1479
  static toolName = "codemation.tool.name";
1798
1480
  static traceParentRunId = "codemation.parent.run.id";
1799
- /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
1800
1481
  static iterationId = "codemation.iteration.id";
1801
- /** Item index (0-based) of the iteration. */
1802
1482
  static iterationIndex = "codemation.iteration.index";
1803
- /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
1804
1483
  static parentInvocationId = "codemation.parent.invocation_id";
1805
- /** MCP server id on spans created for callTool invocations. */
1806
1484
  static mcpServerId = "mcp.server_id";
1807
- /** MCP tool name on spans created for callTool invocations. */
1808
1485
  static mcpToolName = "mcp.tool_name";
1809
- /** Terminal node-execution status (e.g. `"hitl-approved"`, `"hitl-rejected"`) on HITL outcome spans. */
1810
1486
  static nodeExecutionStatus = "codemation.node.execution_status";
1811
- /** Populated on run-halted spans; discriminates the halt reason (e.g. `"hitl-rejected"`). */
1812
1487
  static runHaltReason = "codemation.run.halt_reason";
1813
- /** Human task ID on `hitl.task.*` span events. */
1814
1488
  static hitlTaskId = "codemation.hitl.task_id";
1815
- /** HITL channel name (e.g. `"inbox"`, `"control-plane-inbox"`) on `hitl.task.*` span events. */
1816
1489
  static hitlChannel = "codemation.hitl.channel";
1817
- /** Decision outcome (e.g. `"approved"`, `"rejected"`) on `hitl.task.decided` span events. */
1818
1490
  static hitlDecisionStatus = "codemation.hitl.decision_status";
1819
1491
  };
1820
1492
 
@@ -2029,7 +1701,6 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
2029
1701
 
2030
1702
  //#endregion
2031
1703
  //#region src/execution/InProcessRetryRunner.ts
2032
- /** Maximum permitted retry attempts — workflow-declared values above this are clamped. */
2033
1704
  const HARD_MAX_RETRY_ATTEMPTS = 10;
2034
1705
  var InProcessRetryRunner = class InProcessRetryRunner {
2035
1706
  constructor(sleeper) {
@@ -2121,9 +1792,6 @@ var InProcessRetryRunner = class InProcessRetryRunner {
2121
1792
 
2122
1793
  //#endregion
2123
1794
  //#region src/execution/ItemExprResolver.ts
2124
- /**
2125
- * Resolves {@link import("../contracts/itemExpr").ItemExpr} leaves on runnable config before {@link RunnableNode.execute}.
2126
- */
2127
1795
  var ItemExprResolver = class {
2128
1796
  async resolveConfigForItem(ctx, item, itemIndex, items) {
2129
1797
  if (!ctx) throw new Error("ItemExprResolver.resolveConfigForItem: ctx is required");
@@ -2213,9 +1881,6 @@ var InProcessRetryRunnerFactory = class {
2213
1881
 
2214
1882
  //#endregion
2215
1883
  //#region src/execution/NodeActivationRequestComposer.ts
2216
- /**
2217
- * Builds {@link NodeActivationRequest} values shared by workflow starters and continuation.
2218
- */
2219
1884
  var NodeActivationRequestComposer = class {
2220
1885
  constructor(activationIdFactory, credentialResolverFactory) {
2221
1886
  this.activationIdFactory = activationIdFactory;
@@ -2307,16 +1972,6 @@ var NodeActivationRequestComposer = class {
2307
1972
 
2308
1973
  //#endregion
2309
1974
  //#region src/execution/RunSuspendedError.ts
2310
- /**
2311
- * Internal sentinel thrown by {@link NodeSuspensionHandler} after persisting a suspension
2312
- * entry. `NodeExecutionRequestHandlerService` catches this specifically and returns cleanly —
2313
- * no continuation call, preventing `resumeFromNodeResult` / `resumeFromNodeError` from
2314
- * overwriting the `"suspended"` run status.
2315
- *
2316
- * The `Error` suffix satisfies the ESLint `no-manual-di-new` allowlist. This is NOT a
2317
- * user-facing error — it is an engine-internal control-flow primitive and should NOT be
2318
- * exported from the public barrel.
2319
- */
2320
1975
  var RunSuspendedError = class extends Error {
2321
1976
  constructor(runId, taskId) {
2322
1977
  super(`RunSuspendedError: run ${runId} suspended on task ${taskId}`);
@@ -2493,7 +2148,6 @@ var NodeExecutor = class {
2493
2148
  if (hasSuspension) throw new RunSuspendedError(request.runId, "unknown");
2494
2149
  return byPort;
2495
2150
  }
2496
- /** Use resolver ctx only when {@link NodeExecutionContext.config} is non-nullish. */
2497
2151
  pickExecutionContext(runnableCtx, resolvedCtx) {
2498
2152
  if (resolvedCtx != null && resolvedCtx.config != null) return resolvedCtx;
2499
2153
  return runnableCtx;
@@ -2594,247 +2248,41 @@ var MissingRuntimeNode = class {
2594
2248
  };
2595
2249
 
2596
2250
  //#endregion
2597
- //#region src/workflowSnapshots/MissingRuntimeTrigger.ts
2598
- var MissingRuntimeTrigger = class {
2599
- kind = "trigger";
2600
- outputPorts = ["main"];
2601
- async setup(_ctx) {}
2602
- async execute(items) {
2603
- return { main: items };
2604
- }
2605
- };
2606
-
2607
- //#endregion
2608
- //#region src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts
2609
- var PersistedRuntimeTypeIdFactory = class {
2610
- static fromMetadata(args) {
2611
- const metadata = getPersistedRuntimeTypeMetadata(args.type);
2612
- if (!metadata) return;
2613
- const packageName = metadata.packageName;
2614
- if (!packageName) return;
2615
- return `${packageName}::${metadata.persistedName}`;
2251
+ //#region src/workflowSnapshots/WorkflowParityMismatchError.ts
2252
+ var WorkflowParityMismatchError = class extends Error {
2253
+ name = "WorkflowParityMismatchError";
2254
+ missingNodes;
2255
+ constructor(missingNodes) {
2256
+ const labels = missingNodes.map((n) => `${n.nodeId} (token: ${n.missingTokenId ?? "unknown"})`).join(", ");
2257
+ super(`Workflow parity mismatch: nodes resolve to MissingRuntime and cannot execute: ${labels}`);
2258
+ this.missingNodes = missingNodes;
2616
2259
  }
2617
2260
  };
2618
2261
 
2619
2262
  //#endregion
2620
- //#region src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts
2621
- var PersistedWorkflowTokenRegistry = class {
2622
- tokensById = /* @__PURE__ */ new Map();
2623
- tokenIdsByToken = /* @__PURE__ */ new Map();
2624
- /**
2625
- * Register a token with its package ID. Token ID is inferred as `packageId::tokenName`.
2626
- */
2627
- register(type, packageId, persistedNameOverride) {
2628
- const tokenId = `${packageId}::${persistedNameOverride ?? this.displayNameForTypeToken(type)}`;
2629
- this.tokensById.set(tokenId, type);
2630
- this.tokenIdsByToken.set(type, tokenId);
2631
- return tokenId;
2632
- }
2633
- /**
2634
- * Register all decorated runtime types discovered in workflows.
2635
- */
2636
- registerFromWorkflows(workflows) {
2637
- for (const workflow of workflows) for (const node$1 of workflow.nodes) {
2638
- this.registerDecoratedType(node$1.type);
2639
- this.registerDecoratedType(node$1.config.type);
2640
- this.registerNestedTypes(node$1.config);
2641
- }
2642
- }
2643
- registerDecoratedType(type) {
2644
- if (this.tokenIdsByToken.has(type)) return;
2645
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });
2646
- if (!tokenId) return;
2647
- this.tokensById.set(tokenId, type);
2648
- this.tokenIdsByToken.set(type, tokenId);
2649
- }
2650
- registerNestedTypes(value) {
2651
- if (Array.isArray(value)) {
2652
- for (const entry of value) this.registerNestedTypes(entry);
2653
- return;
2654
- }
2655
- if (!value || typeof value !== "object") return;
2656
- const record = value;
2657
- const type = this.asTypeToken(record.type);
2658
- if (type) this.registerDecoratedType(type);
2659
- for (const v of Object.values(record)) this.registerNestedTypes(v);
2660
- }
2661
- displayNameForTypeToken(token) {
2662
- if (typeof token === "function" && token.name) return token.name;
2663
- if (typeof token === "string") return token;
2664
- return "";
2665
- }
2666
- asTypeToken(value) {
2667
- if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
2668
- }
2669
- getTokenId(token) {
2670
- const existing = this.tokenIdsByToken.get(token);
2671
- if (existing) return existing;
2672
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });
2673
- if (!tokenId) return;
2674
- this.tokensById.set(tokenId, token);
2675
- this.tokenIdsByToken.set(token, tokenId);
2676
- return tokenId;
2677
- }
2678
- resolve(tokenId) {
2679
- return this.tokensById.get(tokenId);
2263
+ //#region src/workflowSnapshots/MissingRuntimeParityGuard.ts
2264
+ var MissingRuntimeParityGuard = class {
2265
+ constructor(marker) {
2266
+ this.marker = marker;
2267
+ }
2268
+ assertNone(workflow, nodeIds) {
2269
+ const missing = (nodeIds ? workflow.nodes.filter((n) => nodeIds.includes(n.id)) : workflow.nodes).filter((n) => this.marker.isMarked(n.config)).map((n) => ({
2270
+ nodeId: n.id,
2271
+ kind: n.kind,
2272
+ missingTokenId: n.config.missingTokenId
2273
+ }));
2274
+ if (missing.length > 0) throw new WorkflowParityMismatchError(missing);
2680
2275
  }
2681
2276
  };
2682
2277
 
2683
2278
  //#endregion
2684
- //#region src/workflowSnapshots/WorkflowSnapshotCodec.ts
2685
- var WorkflowSnapshotCodec = class {
2686
- constructor(tokenRegistry) {
2687
- this.tokenRegistry = tokenRegistry;
2688
- }
2689
- create(workflow) {
2690
- return {
2691
- id: workflow.id,
2692
- name: workflow.name,
2693
- workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
2694
- ...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
2695
- nodes: workflow.nodes.map((node$1) => {
2696
- const inspectorSummaryRows = this.safeInspectorSummary(node$1.config);
2697
- return {
2698
- id: node$1.id,
2699
- kind: node$1.kind,
2700
- name: node$1.name,
2701
- nodeTokenId: this.resolveTokenId(node$1.type),
2702
- configTokenId: this.resolveTokenId(node$1.config.type),
2703
- tokenName: this.resolveTokenName(node$1.type),
2704
- configTokenName: this.resolveTokenName(node$1.config.type),
2705
- config: this.serializeConfig(node$1.config),
2706
- ...inspectorSummaryRows !== void 0 ? { inspectorSummary: inspectorSummaryRows } : {}
2707
- };
2708
- }),
2709
- edges: workflow.edges.map((edge) => ({
2710
- from: {
2711
- nodeId: edge.from.nodeId,
2712
- output: edge.from.output
2713
- },
2714
- to: {
2715
- nodeId: edge.to.nodeId,
2716
- input: edge.to.input
2717
- }
2718
- }))
2719
- };
2720
- }
2721
- hydrate(snapshotNode, liveConfig) {
2722
- const hydrated = this.mergeValue(liveConfig, snapshotNode.config);
2723
- const configToken = this.tokenRegistry.resolve(snapshotNode.configTokenId);
2724
- Object.assign(hydrated, {
2725
- type: configToken ?? liveConfig.type,
2726
- kind: snapshotNode.kind
2727
- });
2728
- if (snapshotNode.name && !("name" in hydrated && hydrated.name)) Object.assign(hydrated, { name: snapshotNode.name });
2729
- return hydrated;
2730
- }
2731
- serializeConfig(config) {
2732
- try {
2733
- const cloned = JSON.parse(JSON.stringify(config));
2734
- this.injectTokenIds(cloned, config);
2735
- return cloned;
2736
- } catch {
2737
- const fallback = {
2738
- kind: config.kind,
2739
- name: config.name,
2740
- id: config.id,
2741
- icon: config.icon,
2742
- description: config.description,
2743
- execution: config.execution
2744
- };
2745
- this.injectTokenIds(fallback, config);
2746
- return fallback;
2747
- }
2748
- }
2749
- /**
2750
- * Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
2751
- * Returns undefined if the method is absent, throws, or produces no valid rows.
2752
- */
2753
- safeInspectorSummary(config) {
2754
- const fn = config.inspectorSummary;
2755
- if (typeof fn !== "function") return void 0;
2756
- let raw;
2757
- try {
2758
- raw = fn.call(config);
2759
- } catch {
2760
- return;
2761
- }
2762
- if (!Array.isArray(raw)) return void 0;
2763
- const rows = [];
2764
- for (const entry of raw) {
2765
- if (!entry || typeof entry !== "object") continue;
2766
- const { label, value } = entry;
2767
- if (typeof label !== "string" || typeof value !== "string") continue;
2768
- const trimmedLabel = label.trim();
2769
- if (trimmedLabel.length === 0) continue;
2770
- rows.push({
2771
- label: trimmedLabel,
2772
- value
2773
- });
2774
- }
2775
- return rows.length > 0 ? rows : void 0;
2776
- }
2777
- injectTokenIds(target, source) {
2778
- const type = this.asTypeToken(source.type);
2779
- if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
2780
- for (const [key, value] of Object.entries(source)) {
2781
- if (key === "type" || value == null) continue;
2782
- if (Array.isArray(value)) {
2783
- const targetArray = target[key];
2784
- if (Array.isArray(targetArray)) value.forEach((item, index) => {
2785
- if (item && typeof item === "object" && targetArray[index] && typeof targetArray[index] === "object") this.injectTokenIds(targetArray[index], item);
2786
- });
2787
- continue;
2788
- }
2789
- if (typeof value === "object") {
2790
- const targetValue = target[key];
2791
- if (targetValue && typeof targetValue === "object") this.injectTokenIds(targetValue, value);
2792
- }
2793
- }
2794
- }
2795
- mergeValue(liveValue, snapshotValue) {
2796
- const liveRecord = this.asRecord(liveValue);
2797
- const snapshotRecord = this.asRecord(snapshotValue);
2798
- const hydrated = Object.create(liveValue && typeof liveValue === "object" ? Object.getPrototypeOf(liveValue) ?? Object.prototype : Object.prototype);
2799
- for (const [key, value] of Object.entries(snapshotRecord)) hydrated[key] = this.mergeNestedValue(liveRecord[key], value);
2800
- this.restoreNonSerializableProperties(liveRecord, hydrated);
2801
- this.restoreTypeProperty(hydrated);
2802
- return hydrated;
2803
- }
2804
- mergeNestedValue(liveValue, snapshotValue) {
2805
- if (Array.isArray(snapshotValue)) {
2806
- const liveArray = Array.isArray(liveValue) ? liveValue : [];
2807
- return snapshotValue.map((entry, index) => this.mergeNestedValue(liveArray[index], entry));
2808
- }
2809
- if (snapshotValue && typeof snapshotValue === "object") return this.mergeValue(liveValue, snapshotValue);
2810
- return snapshotValue;
2811
- }
2812
- restoreNonSerializableProperties(liveRecord, hydrated) {
2813
- for (const [key, value] of Object.entries(liveRecord)) if (typeof value === "function" || typeof value === "symbol") hydrated[key] = value;
2814
- for (const sym of Object.getOwnPropertySymbols(liveRecord)) hydrated[sym] = liveRecord[sym];
2815
- }
2816
- restoreTypeProperty(record) {
2817
- const tokenId = typeof record.tokenId === "string" ? record.tokenId : void 0;
2818
- if (!tokenId) return;
2819
- const type = this.tokenRegistry.resolve(tokenId);
2820
- if (type) record.type = type;
2821
- }
2822
- resolveTokenId(token) {
2823
- return this.tokenRegistry.getTokenId(token) ?? this.resolveTokenName(token) ?? "unknown";
2824
- }
2825
- resolveTokenName(token) {
2826
- if (typeof token === "function" && token.name) return token.name;
2827
- if (typeof token === "string") return token;
2828
- }
2829
- asTypeToken(value) {
2830
- if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
2831
- }
2832
- asRecord(value) {
2833
- if (!value || typeof value !== "object" || Array.isArray(value)) return {};
2834
- const record = value;
2835
- const out = { ...record };
2836
- for (const sym of Object.getOwnPropertySymbols(value)) out[sym] = record[sym];
2837
- return out;
2279
+ //#region src/workflowSnapshots/MissingRuntimeTrigger.ts
2280
+ var MissingRuntimeTrigger = class {
2281
+ kind = "trigger";
2282
+ outputPorts = ["main"];
2283
+ async setup(_ctx) {}
2284
+ async execute(items) {
2285
+ return { main: items };
2838
2286
  }
2839
2287
  };
2840
2288
 
@@ -3103,9 +2551,6 @@ var NodeRunStateWriterFactory = class {
3103
2551
 
3104
2552
  //#endregion
3105
2553
  //#region src/execution/PersistedRunStateTerminalBuilder.ts
3106
- /**
3107
- * Merges common terminal-run fields onto a loaded {@link PersistedRunState} without repeating object literals.
3108
- */
3109
2554
  var PersistedRunStateTerminalBuilder = class {
3110
2555
  mergeTerminal(args) {
3111
2556
  return {
@@ -3203,9 +2648,6 @@ var RunStateSemantics = class {
3203
2648
 
3204
2649
  //#endregion
3205
2650
  //#region src/execution/WorkflowRunExecutionContextFactory.ts
3206
- /**
3207
- * Shared {@link ExecutionContextFactory#create} wiring for workflow runners (base context before node-specific fields).
3208
- */
3209
2651
  var WorkflowRunExecutionContextFactory = class {
3210
2652
  constructor(executionContextFactory, credentialResolverFactory) {
3211
2653
  this.executionContextFactory = executionContextFactory;
@@ -3324,7 +2766,7 @@ var WorkflowTopology = class WorkflowTopology {
3324
2766
  //#endregion
3325
2767
  //#region src/orchestration/RunContinuationService.ts
3326
2768
  var RunContinuationService = class {
3327
- constructor(activationIdFactory, workflowExecutionRepository, runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy) {
2769
+ constructor(activationIdFactory, workflowExecutionRepository, runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy, parityGuard) {
3328
2770
  this.activationIdFactory = activationIdFactory;
3329
2771
  this.workflowExecutionRepository = workflowExecutionRepository;
3330
2772
  this.runDataFactory = runDataFactory;
@@ -3342,6 +2784,7 @@ var RunContinuationService = class {
3342
2784
  this.policyErrorServices = policyErrorServices;
3343
2785
  this.terminalPersistence = terminalPersistence;
3344
2786
  this.executionLimitsPolicy = executionLimitsPolicy;
2787
+ this.parityGuard = parityGuard;
3345
2788
  }
3346
2789
  async markNodeRunning(args) {
3347
2790
  const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(args.runId), this.workflowExecutionRepository.loadSchedulingState(args.runId)]);
@@ -3584,6 +3027,7 @@ var RunContinuationService = class {
3584
3027
  nodeDefinition: def
3585
3028
  });
3586
3029
  try {
3030
+ this.parityGuard.assertNone(wf, [next.nodeId]);
3587
3031
  const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
3588
3032
  runId: state.runId,
3589
3033
  workflowId: state.workflowId,
@@ -3755,20 +3199,6 @@ var RunContinuationService = class {
3755
3199
  async waitForWebhookResponse(runId) {
3756
3200
  return await this.waiters.waitForWebhookResponse(runId);
3757
3201
  }
3758
- /**
3759
- * Re-activate a previously suspended run item with a human decision.
3760
- *
3761
- * Called by the HITL resume endpoint. This method:
3762
- * 1. Loads `PersistedRunState` and locates the suspension entry by `taskId`.
3763
- * 2. Removes the entry from the `suspension` array; if empty, run stays `"suspended"` until
3764
- * enqueue flips it to `"pending"`.
3765
- * 3. Writes `pendingResume` onto the state so `NodeExecutionRequestHandlerService` can
3766
- * splice `resumeContext` into the node's execution context.
3767
- * 4. Reconstructs the original input from `outputsByNode` of the upstream node and
3768
- * enqueues a new activation via `activationEnqueueService`.
3769
- *
3770
- * @throws if the run is not found, not suspended, or the `taskId` is unknown.
3771
- */
3772
3202
  async resumeRun(args) {
3773
3203
  const state = await this.workflowExecutionRepository.load(args.runId);
3774
3204
  if (!state) throw new Error(`Unknown runId: ${args.runId}`);
@@ -3827,6 +3257,7 @@ var RunContinuationService = class {
3827
3257
  batchId,
3828
3258
  input: resumeInput
3829
3259
  });
3260
+ this.parityGuard.assertNone(wf, [suspensionEntry.nodeId]);
3830
3261
  const { result, queuedSnapshot } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
3831
3262
  runId: state.runId,
3832
3263
  workflowId: state.workflowId,
@@ -4061,6 +3492,7 @@ var RunContinuationService = class {
4061
3492
  nodeDefinition: nextDefinition
4062
3493
  });
4063
3494
  try {
3495
+ this.parityGuard.assertNone(args.workflow, [next.nodeId]);
4064
3496
  const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
4065
3497
  runId: args.state.runId,
4066
3498
  workflowId: args.state.workflowId,
@@ -4175,10 +3607,6 @@ var RunContinuationService = class {
4175
3607
  engineMaxSubworkflowDepth: state.executionOptions?.maxSubworkflowDepth ?? fb.maxSubworkflowDepth
4176
3608
  };
4177
3609
  }
4178
- /**
4179
- * Next activation could not be enqueued (e.g. input contract / mapping failed in the preparer).
4180
- * Marks the target node failed and terminates the run.
4181
- */
4182
3610
  async terminateRunAfterActivationEnqueueRejected(args) {
4183
3611
  const finishedAt = args.completedAt;
4184
3612
  const inputsByPort = NodeInputsByPortFactory.fromRequest(args.request);
@@ -4235,11 +3663,6 @@ var RunContinuationService = class {
4235
3663
  this.waiters.resolveRunCompletion(result);
4236
3664
  return result;
4237
3665
  }
4238
- /**
4239
- * Inspects node outputs for a `decision.status` written by `defineHumanApprovalNode`.
4240
- * Returns the first-class HITL node status and halt classification, or `undefined`
4241
- * when the node is not a HITL approval node.
4242
- */
4243
3666
  resolveHitlStatus(outputs) {
4244
3667
  const firstItem = outputs?.main?.[0];
4245
3668
  const decisionStatus = firstItem && typeof firstItem === "object" && "json" in firstItem && firstItem.json && typeof firstItem.json === "object" && "decision" in firstItem.json && firstItem.json.decision && typeof firstItem.json.decision === "object" && "status" in firstItem.json.decision ? firstItem.json.decision.status : void 0;
@@ -4280,7 +3703,6 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
4280
3703
  constructor(topology) {
4281
3704
  this.topology = topology;
4282
3705
  }
4283
- /** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */
4284
3706
  static createFromTopology(topology) {
4285
3707
  return new CurrentStateFrontierPlanner(topology);
4286
3708
  }
@@ -5032,12 +4454,6 @@ var DefaultDrivingScheduler = class {
5032
4454
  }
5033
4455
  return await this.prepareInlineDispatch(request);
5034
4456
  }
5035
- /**
5036
- * Scheduler precedence is explicit:
5037
- * 1. run-intent override (`executionOptions.localOnly`)
5038
- * 2. node-level execution hint / queue policy
5039
- * 3. container-default scheduler policy fallback
5040
- */
5041
4457
  async selectScheduler(request) {
5042
4458
  if (request.executionOptions?.localOnly) return {
5043
4459
  mode: "local",
@@ -5103,14 +4519,6 @@ var InlineDrivingScheduler = class {
5103
4519
  setContinuation(continuation) {
5104
4520
  this.continuation = continuation;
5105
4521
  }
5106
- /**
5107
- * Prevents new drain cycles from being scheduled and waits for all currently-running
5108
- * drains to complete. Call before closing the DB connection or rolling back test transactions
5109
- * to ensure no in-flight writes hit a closed/rolled-back connection.
5110
- *
5111
- * Bounded: only the drains already in-flight at call time are awaited. Runs that keep
5112
- * re-scheduling will not schedule new work once stopped is set.
5113
- */
5114
4522
  async stop() {
5115
4523
  this.stopped = true;
5116
4524
  if (this.activeDrainPromises.size > 0) await Promise.allSettled(this.activeDrainPromises);
@@ -5222,24 +4630,16 @@ var LocalOnlyScheduler = class {
5222
4630
 
5223
4631
  //#endregion
5224
4632
  //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
5225
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
5226
4633
  const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
5227
4634
  defaultMaxNodeActivations: 1e5,
5228
4635
  hardMaxNodeActivations: 1e5,
5229
4636
  defaultMaxSubworkflowDepth: 32,
5230
4637
  hardMaxSubworkflowDepth: 32
5231
4638
  };
5232
- /**
5233
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
5234
- */
5235
4639
  var EngineExecutionLimitsPolicy = class {
5236
4640
  constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
5237
4641
  this.config = config;
5238
4642
  }
5239
- /**
5240
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
5241
- * Replaces a separate one-method factory for root-run bootstrap.
5242
- */
5243
4643
  createRootExecutionOptions() {
5244
4644
  return this.mergeExecutionOptionsForNewRun(void 0, void 0);
5245
4645
  }
@@ -5467,10 +4867,6 @@ var InMemoryRunDataFactory = class {
5467
4867
 
5468
4868
  //#endregion
5469
4869
  //#region src/triggers/polling/PollingTriggerDedupWindow.ts
5470
- /**
5471
- * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
5472
- * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
5473
- */
5474
4870
  var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
5475
4871
  static defaultCapN = 2e3;
5476
4872
  merge(previous, incoming, capN = PollingTriggerDedupWindow.defaultCapN) {
@@ -5484,11 +4880,6 @@ var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
5484
4880
 
5485
4881
  //#endregion
5486
4882
  //#region src/triggers/polling/PollingTriggerRuntime.ts
5487
- /**
5488
- * Generic polling-trigger runtime. Owns the set-interval loop, overlap guard, and persistence.
5489
- * Constructed by {@link import("../../runtime/EngineFactory").EngineFactory} and exposed to plugin
5490
- * authors via {@link import("../../contracts/runtimeTypes").TriggerSetupContext}.polling.
5491
- */
5492
4883
  var PollingTriggerRuntime = class {
5493
4884
  activeTriggers = /* @__PURE__ */ new Set();
5494
4885
  intervalsByTrigger = /* @__PURE__ */ new Map();
@@ -5590,7 +4981,7 @@ var NoOpPollingTriggerLogger = class {
5590
4981
  //#endregion
5591
4982
  //#region src/orchestration/NodeExecutionRequestHandlerService.ts
5592
4983
  var NodeExecutionRequestHandlerService = class {
5593
- constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy) {
4984
+ constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy, parityGuard) {
5594
4985
  this.workflowExecutionRepository = workflowExecutionRepository;
5595
4986
  this.workflowSnapshotResolver = workflowSnapshotResolver;
5596
4987
  this.runDataFactory = runDataFactory;
@@ -5600,6 +4991,7 @@ var NodeExecutionRequestHandlerService = class {
5600
4991
  this.nodeExecutor = nodeExecutor;
5601
4992
  this.continuation = continuation;
5602
4993
  this.executionLimitsPolicy = executionLimitsPolicy;
4994
+ this.parityGuard = parityGuard;
5603
4995
  }
5604
4996
  async handleNodeExecutionRequest(request) {
5605
4997
  const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(request.runId), this.workflowExecutionRepository.loadSchedulingState(request.runId)]);
@@ -5683,6 +5075,7 @@ var NodeExecutionRequestHandlerService = class {
5683
5075
  });
5684
5076
  let outputs;
5685
5077
  try {
5078
+ this.parityGuard.assertNone(workflow, [request.nodeId]);
5686
5079
  outputs = await this.nodeExecutor.execute(activationRequest);
5687
5080
  } catch (error) {
5688
5081
  if (error instanceof RunSuspendedError) return;
@@ -5857,12 +5250,6 @@ var RunQueuePlanner = class {
5857
5250
  const received = queueEntry.collect.received;
5858
5251
  for (const input$1 of queueEntry.collect.expectedInputs ?? []) if (!(input$1 in received)) received[input$1] = [];
5859
5252
  }
5860
- /**
5861
- * Matches `CurrentStateFrontierPlanner.buildFrontierQueue`: anything that is not exactly one input
5862
- * port named `in` participates in multi-port collect (Merge after `If` branches, etc.). Routing must
5863
- * not depend solely on `nodeInstances.get(toNodeId)?.executeMulti`, or a Merge can be enqueued as a
5864
- * single-input job and `NodeExecutor` will call `execute` on a multi-input-only implementation.
5865
- */
5866
5253
  usesTopologyCollectMerge(toNodeId) {
5867
5254
  const expectedInputs = this.topology.expectedInputsByNode.get(toNodeId) ?? [];
5868
5255
  if (expectedInputs.length !== 1 || expectedInputs[0] !== "in") return true;
@@ -6262,11 +5649,6 @@ var EngineWaiters = class {
6262
5649
 
6263
5650
  //#endregion
6264
5651
  //#region src/orchestration/Engine.ts
6265
- /**
6266
- * Runtime facade for orchestration, continuation, triggers, and webhook routing.
6267
- * Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
6268
- * The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
6269
- */
6270
5652
  var Engine = class {
6271
5653
  constructor(deps) {
6272
5654
  this.deps = deps;
@@ -6340,10 +5722,6 @@ var Engine = class {
6340
5722
  async waitForWebhookResponse(runId) {
6341
5723
  return await this.deps.runContinuationService.waitForWebhookResponse(runId);
6342
5724
  }
6343
- /**
6344
- * Re-activate a suspended run item with a human decision (HITL).
6345
- * The HTTP resume endpoint calls this; this method exposes the engine primitive.
6346
- */
6347
5725
  async resumeRun(args) {
6348
5726
  return await this.deps.runContinuationService.resumeRun(args);
6349
5727
  }
@@ -6354,11 +5732,6 @@ var Engine = class {
6354
5732
 
6355
5733
  //#endregion
6356
5734
  //#region src/runtime/EngineFactory.ts
6357
- /**
6358
- * Composes the {@link Engine} graph from {@link EngineCompositionDeps}. Production wiring usually goes through
6359
- * {@link import("../bootstrap/runtime/EngineRuntimeRegistrar").EngineRuntimeRegistrar}; this factory remains for tests and custom composition.
6360
- * Exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
6361
- */
6362
5735
  var EngineFactory = class {
6363
5736
  create(deps) {
6364
5737
  const waiters = new EngineWaiters();
@@ -6370,7 +5743,9 @@ var EngineFactory = class {
6370
5743
  const workflowSnapshotCodec = deps.workflowSnapshotCodec ?? new WorkflowSnapshotCodec(deps.tokenRegistry);
6371
5744
  const missingRuntimeFallbacks = deps.missingRuntimeFallbacks ?? new MissingRuntimeFallbacks();
6372
5745
  const workflowSnapshotResolver = new WorkflowSnapshotResolver(deps.workflowRepository, deps.tokenRegistry, workflowSnapshotCodec, missingRuntimeFallbacks);
6373
- const semantics = new RunStateSemantics(new MissingRuntimeExecutionMarker());
5746
+ const missingRuntimeExecutionMarker = new MissingRuntimeExecutionMarker();
5747
+ const semantics = new RunStateSemantics(missingRuntimeExecutionMarker);
5748
+ const parityGuard = new MissingRuntimeParityGuard(missingRuntimeExecutionMarker);
6374
5749
  const nodeActivationRequestInputPreparer = new NodeActivationRequestInputPreparer(deps.workflowNodeInstanceFactory);
6375
5750
  const activationEnqueueService = new ActivationEnqueueService(deps.activationScheduler, deps.workflowExecutionRepository, nodeEventPublisher, nodeActivationRequestInputPreparer);
6376
5751
  const runExecutionContextFactory = new WorkflowRunExecutionContextFactory(deps.executionContextFactory, credentialResolverFactory);
@@ -6380,8 +5755,8 @@ var EngineFactory = class {
6380
5755
  const terminalPersistence = new RunTerminalPersistenceCoordinator(deps.workflowExecutionRepository, storagePolicyEvaluator);
6381
5756
  const policyErrorServices = new WorkflowPolicyErrorServices(deps.nodeResolver);
6382
5757
  const runStartService = new RunStartService(deps.runIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, workflowSnapshotCodec, planningFactory, nodeStatePublisherFactory, runExecutionContextFactory, nodeActivationRequestComposer, activationEnqueueService, semantics, waiters, deps.workflowPolicyRuntimeDefaults, executionLimitsPolicy, nodeEventPublisher, persistedRunStateTerminalBuilder);
6383
- const runContinuationService = new RunContinuationService(deps.activationIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy);
6384
- const nodeExecutionRequestHandler = new NodeExecutionRequestHandlerService(deps.workflowExecutionRepository, workflowSnapshotResolver, deps.runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, deps.nodeExecutor, runContinuationService, executionLimitsPolicy);
5758
+ const runContinuationService = new RunContinuationService(deps.activationIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy, parityGuard);
5759
+ const nodeExecutionRequestHandler = new NodeExecutionRequestHandlerService(deps.workflowExecutionRepository, workflowSnapshotResolver, deps.runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, deps.nodeExecutor, runContinuationService, executionLimitsPolicy, parityGuard);
6385
5760
  const pollingTriggerLogger = deps.pollingTriggerLogger ?? new NoOpPollingTriggerLogger();
6386
5761
  const pollingTriggerDedupWindow = new PollingTriggerDedupWindow();
6387
5762
  const pollingTriggerRuntime = new PollingTriggerRuntime(deps.triggerSetupStateRepository, pollingTriggerLogger);
@@ -6564,10 +5939,6 @@ var RunIntentService = class {
6564
5939
  };
6565
5940
  })]);
6566
5941
  }
6567
- /**
6568
- * Webhook-triggered runs always force inline execution first.
6569
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
6570
- */
6571
5942
  createWebhookExecutionOptions() {
6572
5943
  return {
6573
5944
  localOnly: true,
@@ -6586,10 +5957,6 @@ var RunIntentServiceFactory = class {
6586
5957
 
6587
5958
  //#endregion
6588
5959
  //#region src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts
6589
- /**
6590
- * Resolves webhook HTTP routes from the live workflow repository (no trigger setup / registration).
6591
- * Maintains an in-memory index keyed by user-defined endpoint path for O(1) lookups after reload.
6592
- */
6593
5960
  var WorkflowRepositoryWebhookTriggerMatcher = class {
6594
5961
  routeByPath = /* @__PURE__ */ new Map();
6595
5962
  engineRoutesActive = false;
@@ -6679,5 +6046,5 @@ var WorkflowRepositoryWebhookTriggerMatcherFactory = class {
6679
6046
  };
6680
6047
 
6681
6048
  //#endregion
6682
- export { CostTrackingTelemetryAttributeNames as $, PersistedWorkflowTokenRegistry as A, getPersistedRuntimeTypeMetadata as At, CatalogBackedCostTrackingTelemetryFactory as B, HitlWorkspaceIdToken as Bt, DefaultDrivingScheduler as C, mergeForward as Ct, NodeInstanceFactoryFactory as D, defineBatchNode as Dt, StaticCostCatalog as E, isHumanApprovalNode as Et, InProcessRetryRunnerFactory as F, StackTraceCallSitePathResolver as Ft, AllWorkflowsActiveWorkflowActivationPolicy as G, CodemationTelemetryMetricNames as H, RunnableOutputBehaviorResolver as I, PersistedRuntimeTypeNameResolver as It, NoOpNodeExecutionTelemetry as J, NoOpExecutionTelemetryFactory as K, NodeOutputNormalizer as L, DefinedNodeRegistry as Lt, NodeExecutorFactory as M, tool as Mt, NodeExecutor as N, InjectableRuntimeDecoratorComposer as Nt, NodeInstanceFactory as O, defineNode as Ot, RunSuspendedError as P, PersistedRuntimeTypeMetadataStore as Pt, NoOpCostTrackingTelemetry as Q, ItemExprResolver as R, HitlResumeTokenSignerToken as Rt, HintOnlyOffloadPolicy as S, ChainCursor as St, RunPolicySnapshotFactory as T, defineHumanApprovalNode as Tt, GenAiTelemetryAttributeNames as U, DefaultExecutionContextFactory as V, HumanTaskStoreToken as Vt, CodemationTelemetryAttributeNames as W, NoOpTelemetryArtifactReference as X, NoOpTelemetrySpanScope as Y, NoOpCostTrackingTelemetryFactory as Z, RunTerminalPersistenceCoordinator as _, WorkflowExecutableNodeClassifier as _t, InMemoryLiveWorkflowRepository as a, isPortsEmission as at, LocalOnlyScheduler as b, WorkflowDefinitionError as bt, EngineFactory as c, CredentialResolverFactory as ct, PollingTriggerRuntime as d, DefaultExecutionBinaryService as dt, CostTrackingTelemetryMetricNames as et, PollingTriggerDedupWindow as f, UnavailableBinaryStorage as ft, WorkflowPolicyErrorServices as g, WorkflowExecutableNodeClassifierFactory as gt, WorkflowStoragePolicyEvaluator as h, DefaultWorkflowGraphFactory as ht, RunIntentService as i, emitPorts as it, MissingRuntimeTriggerToken as j, node as jt, WorkflowSnapshotCodec as k, chatModel as kt, Engine as l, getOriginIndexFromItem as lt, InMemoryBinaryStorage as m, ConnectionInvocationEventPublisher as mt, WorkflowRepositoryWebhookTriggerMatcher as n, RetryPolicy as nt, EngineWorkflowRunnerServiceFactory as o, isUnbrandedPortsEmissionShape as ot, InMemoryRunDataFactory as p, NodeEventPublisher as pt, NoOpExecutionTelemetry as q, RunIntentServiceFactory as r, NoRetryPolicy as rt, EngineWorkflowRunnerService as s, DefaultAsyncSleeper as st, WorkflowRepositoryWebhookTriggerMatcherFactory as t, ExpRetryPolicy as tt, NoOpPollingTriggerLogger as u, ChildExecutionScopeFactory as ut, ENGINE_EXECUTION_LIMITS_DEFAULTS as v, ConnectionInvocationIdFactory as vt, ConfigDrivenOffloadPolicy as w, WhenBuilder as wt, InlineDrivingScheduler as x, NodeIdSlugifier as xt, EngineExecutionLimitsPolicy as y, WorkflowBuilder as yt, InProcessRetryRunner as z, HitlTimeoutJobSchedulerToken as zt };
6683
- //# sourceMappingURL=runtime-CSunvf7A.js.map
6049
+ export { CostTrackingTelemetryAttributeNames as $, WorkflowParityMismatchError as A, HitlResumeTokenSignerToken as At, CatalogBackedCostTrackingTelemetryFactory as B, DefaultDrivingScheduler as C, mergeForward as Ct, NodeInstanceFactoryFactory as D, defineBatchNode as Dt, StaticCostCatalog as E, isHumanApprovalNode as Et, InProcessRetryRunnerFactory as F, AllWorkflowsActiveWorkflowActivationPolicy as G, CodemationTelemetryMetricNames as H, RunnableOutputBehaviorResolver as I, NoOpNodeExecutionTelemetry as J, NoOpExecutionTelemetryFactory as K, NodeOutputNormalizer as L, NodeExecutorFactory as M, HitlWorkspaceIdToken as Mt, NodeExecutor as N, HumanTaskStoreToken as Nt, NodeInstanceFactory as O, defineNode as Ot, RunSuspendedError as P, NoOpCostTrackingTelemetry as Q, ItemExprResolver as R, HintOnlyOffloadPolicy as S, ChainCursor as St, RunPolicySnapshotFactory as T, defineHumanApprovalNode as Tt, GenAiTelemetryAttributeNames as U, DefaultExecutionContextFactory as V, CodemationTelemetryAttributeNames as W, NoOpTelemetryArtifactReference as X, NoOpTelemetrySpanScope as Y, NoOpCostTrackingTelemetryFactory as Z, RunTerminalPersistenceCoordinator as _, WorkflowExecutableNodeClassifier as _t, InMemoryLiveWorkflowRepository as a, isPortsEmission as at, LocalOnlyScheduler as b, WorkflowDefinitionError as bt, EngineFactory as c, CredentialResolverFactory as ct, PollingTriggerRuntime as d, DefaultExecutionBinaryService as dt, CostTrackingTelemetryMetricNames as et, PollingTriggerDedupWindow as f, UnavailableBinaryStorage as ft, WorkflowPolicyErrorServices as g, WorkflowExecutableNodeClassifierFactory as gt, WorkflowStoragePolicyEvaluator as h, DefaultWorkflowGraphFactory as ht, RunIntentService as i, emitPorts as it, MissingRuntimeTriggerToken as j, HitlTimeoutJobSchedulerToken as jt, MissingRuntimeParityGuard as k, DefinedNodeRegistry as kt, Engine as l, getOriginIndexFromItem as lt, InMemoryBinaryStorage as m, ConnectionInvocationEventPublisher as mt, WorkflowRepositoryWebhookTriggerMatcher as n, RetryPolicy as nt, EngineWorkflowRunnerServiceFactory as o, isUnbrandedPortsEmissionShape as ot, InMemoryRunDataFactory as p, NodeEventPublisher as pt, NoOpExecutionTelemetry as q, RunIntentServiceFactory as r, NoRetryPolicy as rt, EngineWorkflowRunnerService as s, DefaultAsyncSleeper as st, WorkflowRepositoryWebhookTriggerMatcherFactory as t, ExpRetryPolicy as tt, NoOpPollingTriggerLogger as u, ChildExecutionScopeFactory as ut, ENGINE_EXECUTION_LIMITS_DEFAULTS as v, ConnectionInvocationIdFactory as vt, ConfigDrivenOffloadPolicy as w, WhenBuilder as wt, InlineDrivingScheduler as x, NodeIdSlugifier as xt, EngineExecutionLimitsPolicy as y, WorkflowBuilder as yt, InProcessRetryRunner as z };
6050
+ //# sourceMappingURL=runtime-CBFDpmiz.js.map