@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,12 +1,12 @@
1
- const require_di = require('./di-DhwtDRgs.cjs');
1
+ const require_di = require('./di-C6Ubf9o5.cjs');
2
+ const require_workflowTypes = require('./workflowTypes-BW6Hhee7.cjs');
3
+ const require_contracts = require('./contracts-7L1wJHdk.cjs');
4
+ let node_crypto = require("node:crypto");
5
+ node_crypto = require_di.__toESM(node_crypto);
2
6
  let zod = require("zod");
3
7
  zod = require_di.__toESM(zod);
4
8
  let node_stream_web = require("node:stream/web");
5
9
  node_stream_web = require_di.__toESM(node_stream_web);
6
- let node_crypto = require("node:crypto");
7
- node_crypto = require_di.__toESM(node_crypto);
8
- let tsyringe = require("tsyringe");
9
- tsyringe = require_di.__toESM(tsyringe);
10
10
 
11
11
  //#region src/contracts/humanTaskStoreTypes.ts
12
12
  const HumanTaskStoreToken = Symbol.for("codemation.core.HumanTaskStore");
@@ -15,12 +15,6 @@ const HumanTaskStoreToken = Symbol.for("codemation.core.HumanTaskStore");
15
15
  //#region src/contracts/hitlSeamTypes.ts
16
16
  const HitlResumeTokenSignerToken = Symbol.for("codemation.core.HitlResumeTokenSigner");
17
17
  const HitlTimeoutJobSchedulerToken = Symbol.for("codemation.core.HitlTimeoutJobScheduler");
18
- /**
19
- * Optional workspace ID injected into NodeSuspensionHandler in managed mode (T7 security fix).
20
- * Allows the handler to stamp the workspaceId on each HumanTaskRecord so HitlCallbackHandler
21
- * can assert workspace identity independently of the HMAC middleware.
22
- * Not registered in non-managed mode; NodeSuspensionHandler defaults to null.
23
- */
24
18
  const HitlWorkspaceIdToken = Symbol.for("codemation.core.HitlWorkspaceId");
25
19
 
26
20
  //#endregion
@@ -35,115 +29,6 @@ var DefinedNodeRegistry = class {
35
29
  }
36
30
  };
37
31
 
38
- //#endregion
39
- //#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
40
- /** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
41
- const persistedRuntimeTypeMetadataKey = Symbol.for("codemation.core.persistedRuntimeTypeMetadata");
42
- /** Normalizes decorator options so persistence metadata has stable defaults. */
43
- var PersistedRuntimeTypeDecoratorDefaults = class {
44
- static appPackageName = "app";
45
- static apply(options) {
46
- return {
47
- ...options,
48
- packageName: options.packageName ?? this.appPackageName
49
- };
50
- }
51
- };
52
-
53
- //#endregion
54
- //#region src/runtime-types/PersistedRuntimeTypeNameResolver.ts
55
- /** Resolves the persisted type name from either an explicit override or the class name itself. */
56
- var PersistedRuntimeTypeNameResolver = class {
57
- static resolve(target, override) {
58
- const resolved = override ?? target.name;
59
- if (!resolved) throw new Error("Persisted runtime token metadata requires a named class or an explicit decorator name override.");
60
- return resolved;
61
- }
62
- };
63
-
64
- //#endregion
65
- //#region src/runtime-types/StackTraceCallSitePathResolver.ts
66
- var StackTraceCallSitePathResolver = class {
67
- static resolve(decoratorFileUrl) {
68
- const stack = (/* @__PURE__ */ new Error()).stack ?? "";
69
- for (const line of stack.split("\n")) {
70
- const candidate = this.extractPath(line.trim());
71
- if (!candidate) continue;
72
- if (candidate === decoratorFileUrl || candidate.includes("runtimeTypeDecorators")) continue;
73
- return candidate;
74
- }
75
- }
76
- static extractPath(line) {
77
- const fileUrlMatch = line.match(/file:\/\/[^\s)]+/);
78
- if (fileUrlMatch) return fileUrlMatch[0];
79
- const parenMatch = line.match(/\((\/[^)]+)\)/);
80
- if (parenMatch) return parenMatch[1];
81
- return line.match(/at (\/[^\s]+)/)?.[1];
82
- }
83
- };
84
-
85
- //#endregion
86
- //#region src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts
87
- /**
88
- * Defines and retrieves persisted runtime metadata on decorated classes.
89
- * The metadata is attached as a non-enumerable property so runtime objects stay serializable.
90
- */
91
- var PersistedRuntimeTypeMetadataStore = class {
92
- static define(target, kind, options, decoratorFileUrl) {
93
- const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);
94
- const metadata = {
95
- persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),
96
- kind,
97
- packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,
98
- sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl)
99
- };
100
- Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {
101
- configurable: false,
102
- enumerable: false,
103
- writable: false,
104
- value: metadata
105
- });
106
- }
107
- static get(target) {
108
- if (!target || typeof target !== "function" && typeof target !== "object") return;
109
- return target[persistedRuntimeTypeMetadataKey];
110
- }
111
- };
112
-
113
- //#endregion
114
- //#region src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts
115
- /**
116
- * Applies both tsyringe injectability and persisted runtime metadata in one decorator.
117
- * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.
118
- */
119
- var InjectableRuntimeDecoratorComposer = class {
120
- static compose(kind, options, decoratorFileUrl) {
121
- return (target) => {
122
- (0, tsyringe.injectable)()(target);
123
- PersistedRuntimeTypeMetadataStore.define(target, kind, options, decoratorFileUrl);
124
- };
125
- }
126
- };
127
-
128
- //#endregion
129
- //#region src/runtime-types/runtimeTypeDecorators.types.ts
130
- /** Reads persisted runtime metadata from a decorated class or object. */
131
- function getPersistedRuntimeTypeMetadata(target) {
132
- return PersistedRuntimeTypeMetadataStore.get(target);
133
- }
134
- /** Marks a class as a persisted node runtime type and an injectable tsyringe service. */
135
- function node(options = {}) {
136
- return InjectableRuntimeDecoratorComposer.compose("node", options, require("url").pathToFileURL(__filename).href);
137
- }
138
- /** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */
139
- function tool(options = {}) {
140
- return InjectableRuntimeDecoratorComposer.compose("tool", options, require("url").pathToFileURL(__filename).href);
141
- }
142
- /** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */
143
- function chatModel(options = {}) {
144
- return InjectableRuntimeDecoratorComposer.compose("chatModel", options, require("url").pathToFileURL(__filename).href);
145
- }
146
-
147
32
  //#endregion
148
33
  //#region src/authoring/defineNode.types.ts
149
34
  const definedNodeCredentialRequirementFactory = {
@@ -204,7 +89,7 @@ function defineNode(options) {
204
89
  return await options.execute(payload, context);
205
90
  }
206
91
  };
207
- node({ name: options.key })(DefinedNodeRuntime);
92
+ require_contracts.node({ name: options.key })(DefinedNodeRuntime);
208
93
  const DefinedRunnableNodeConfig = class {
209
94
  kind = "node";
210
95
  type = DefinedNodeRuntime;
@@ -259,7 +144,7 @@ function defineBatchNode(options) {
259
144
  return [...await options.run(args.items.map((item) => item.json), context)];
260
145
  }
261
146
  };
262
- node({ name: options.key })(DefinedNodeRuntime);
147
+ require_contracts.node({ name: options.key })(DefinedNodeRuntime);
263
148
  const DefinedRunnableNodeConfig = class {
264
149
  kind = "node";
265
150
  type = DefinedNodeRuntime;
@@ -299,60 +184,9 @@ function defineBatchNode(options) {
299
184
 
300
185
  //#endregion
301
186
  //#region src/authoring/defineHumanApprovalNode.types.ts
302
- /**
303
- * Returns `true` when `node` was created by {@link defineHumanApprovalNode}.
304
- * Uses the `humanApprovalToolBehavior` typed field as the discriminant.
305
- */
306
187
  function isHumanApprovalNode(node$1) {
307
188
  return typeof node$1 === "object" && node$1 !== null && "humanApprovalToolBehavior" in node$1 && typeof node$1.humanApprovalToolBehavior === "object";
308
189
  }
309
- /**
310
- * Authoring helper that compiles a HITL approval channel down to a regular
311
- * {@link defineNode}-backed node with `SuspensionRequest` semantics.
312
- *
313
- * **Fast-forward decision semantics:**
314
- * - On the first `execute` call (no `ctx.resumeContext`): throws a `SuspensionRequest`
315
- * that calls the author's `deliver`. The engine persists the suspension and continues.
316
- * - On resume (`ctx.resumeContext` set): calls `onDecision`/`onTimeout` as appropriate,
317
- * merges a `decision` key into `item.json`, and returns an item with the original
318
- * `binary` map passed by reference (no copy).
319
- *
320
- * **Output shape per item:**
321
- * ```ts
322
- * // Input: { json: { invoiceId: 42 }, binary?: {...} }
323
- * // Output: { json: { invoiceId: 42, decision: { status: "approved", actor, decidedAt } }, binary: <unchanged> }
324
- * ```
325
- * If `item.json` already has a `decision` key it is **overwritten**. Namespace as
326
- * needed if your schema reserves that key for another purpose.
327
- *
328
- * **Predicate persistence:**
329
- * The `approvedPredicate` function is NOT serialized to the suspension record (except
330
- * as an audit-only string via `toString()`). On resume, the workflow definition is
331
- * reloaded from code at process start and the predicate closure is rebuilt naturally.
332
- * If a deploy ships a changed predicate between suspend and resume, the *new* predicate
333
- * runs — document this in your runbook when the predicate carries business logic that
334
- * may change across deploys.
335
- *
336
- * @example
337
- * ```ts
338
- * export const slackApprovalNode = defineHumanApprovalNode({
339
- * key: "my-plugin.slackApproval",
340
- * title: "Slack Approval",
341
- * channel: "slack",
342
- * configSchema: z.object({ channel: z.string(), message: z.string() }),
343
- * decisionSchema: z.object({ approved: z.boolean(), note: z.string().optional() }),
344
- *
345
- * async deliver({ task, config, item }, ctx) {
346
- * const ts = await postSlackMessage(config.channel, `Approve? <${task.resumeUrl}>`);
347
- * return { channel: config.channel, ts };
348
- * },
349
- *
350
- * async onDecision({ decision, actor, delivery }, ctx) {
351
- * await updateSlackMessage(delivery.channel, delivery.ts, decision.approved ? "✅" : "❌");
352
- * },
353
- * });
354
- * ```
355
- */
356
190
  function defineHumanApprovalNode(opts) {
357
191
  const resolvedPredicate = resolveApprovedPredicate(opts.decisionSchema, opts.approvedPredicate);
358
192
  const timeout = opts.defaultTimeout ?? "24h";
@@ -369,7 +203,7 @@ function defineHumanApprovalNode(opts) {
369
203
  async execute(args, { config, execution: ctx }) {
370
204
  if (!ctx.resumeContext) {
371
205
  const subject = buildSubject(opts.title, args.item, ctx);
372
- throw new require_di.SuspensionRequest({
206
+ throw new require_workflowTypes.SuspensionRequest({
373
207
  decisionSchema: opts.decisionSchema,
374
208
  timeout,
375
209
  onTimeout,
@@ -454,7 +288,6 @@ async function handleResume(item, resumeContext, decisionSchema, resolvedPredica
454
288
  //#endregion
455
289
  //#region src/workflow/dsl/WhenBuilder.ts
456
290
  var WhenBuilder = class WhenBuilder {
457
- /** Tail endpoint of the arm this builder added (set by addBranch). */
458
291
  armEndpoint;
459
292
  constructor(wf, from, branchPort, priorEndpoints = []) {
460
293
  this.wf = wf;
@@ -499,27 +332,15 @@ var WhenBuilder = class WhenBuilder {
499
332
  b.addBranch(list);
500
333
  return b;
501
334
  };
502
- /**
503
- * Continue the trunk after a boolean `.when(...)` branch chain, auto-merging EVERY branch
504
- * tail accumulated across the chain into the next node — the same fan-in the object form
505
- * produces. Typed as `ChainCursor<TCurrentJson>` (the pre-branch item type): boolean arms
506
- * carry no output guard so the merged item type is underdetermined — use the object form
507
- * `.when({ true: [...], false: [...] })` when you need a precise merged type inline.
508
- */
509
335
  then(config) {
510
336
  return this.toCursor().then(config);
511
337
  }
512
- /**
513
- * Chainable human-approval step after a boolean `.when(...)` branch chain — merges every
514
- * branch tail into the approval node. Mirrors `ChainCursor.humanApproval`.
515
- */
516
338
  humanApproval(node$1, config, metadata) {
517
339
  return this.toCursor().humanApproval(node$1, config, metadata);
518
340
  }
519
341
  build() {
520
342
  return this.wf.build();
521
343
  }
522
- /** Endpoints of every arm added so far in this chain (prior arms + this one). */
523
344
  get accumulatedEndpoints() {
524
345
  return this.armEndpoint ? [...this.priorEndpoints, this.armEndpoint] : this.priorEndpoints;
525
346
  }
@@ -530,30 +351,6 @@ var WhenBuilder = class WhenBuilder {
530
351
 
531
352
  //#endregion
532
353
  //#region src/workflow/dsl/workflowBuilderTypes.ts
533
- /**
534
- * Flags a node's config so its output is MERGED onto `item.json` (shallow, output-wins) instead of
535
- * replacing it — the config-level twin of {@link ChainCursor.thenMerge}.
536
- *
537
- * Unlike `.thenMerge` (a cursor method that only works on the trunk), `mergeForward` operates on a
538
- * bare config, so it is usable in ANY position — including inside a `.when({ true: [...] })` branch
539
- * arm, where the steps are a flat array of configs (not a cursor). Wrap a payload-REPLACING node
540
- * (e.g. an extractor) in `mergeForward(node.create(...))` so prior fields survive into the next step.
541
- *
542
- * The OUTPUT type becomes `TIn & TOut` (the intersection), mirroring `.thenMerge`'s return type at
543
- * the config level — so the next step in the branch array sees both the prior fields and the node's
544
- * output. The INPUT type stays `TIn` (the node still receives the pre-merge item).
545
- *
546
- * @example
547
- * ```ts
548
- * workflow
549
- * .trigger(...)
550
- * .when({
551
- * true: [mergeForward(extractor.create(...))], // output merges onto item.json; { a } survives
552
- * false: [...],
553
- * })
554
- * .build();
555
- * ```
556
- */
557
354
  function mergeForward(config) {
558
355
  config.mergeJson = true;
559
356
  return config;
@@ -576,11 +373,6 @@ var ChainCursor = class ChainCursor {
576
373
  ...inputPortHint ? { inputPortHint } : {}
577
374
  }]);
578
375
  }
579
- /**
580
- * Append a step whose output is MERGED onto `item.json` (shallow, output-wins) instead of
581
- * replacing it — so earlier fields (e.g. trigger metadata) survive a transform/OCR/extraction
582
- * node. Use for any node in a pipeline where you need data from before it.
583
- */
584
376
  thenMerge(config) {
585
377
  mergeForward(config);
586
378
  return this.then(config);
@@ -653,21 +445,6 @@ var ChainCursor = class ChainCursor {
653
445
  }
654
446
  return new ChainCursor(this.wf, nextEndpoints);
655
447
  }
656
- /**
657
- * Chainable shorthand for `.then(node.create(config, metadata?.name, metadata?.nodeId))`.
658
- *
659
- * Signals to readers that this step suspends the run and waits for a human decision.
660
- * Throws at workflow-build time if `node` was not created via `defineHumanApprovalNode`.
661
- *
662
- * @example
663
- * ```ts
664
- * workflow
665
- * .trigger(...)
666
- * .humanApproval(inboxApproval, { title: "Approve?", body: "...", priority: "normal" })
667
- * .then(nextStep.create(...))
668
- * .build();
669
- * ```
670
- */
671
448
  humanApproval(node$1, config, metadata) {
672
449
  if (!isHumanApprovalNode(node$1)) throw new Error(`.humanApproval() requires a node created via defineHumanApprovalNode (got '${node$1.key ?? String(node$1)}').`);
673
450
  return this.then(node$1.create(config, metadata?.name, metadata?.nodeId));
@@ -684,15 +461,6 @@ var ChainCursor = class ChainCursor {
684
461
 
685
462
  //#endregion
686
463
  //#region src/workflow/dsl/NodeIdSlugifier.ts
687
- /**
688
- * Converts a human-readable node label into a stable, URL-safe identifier segment.
689
- *
690
- * Rules:
691
- * - Lowercase the entire string.
692
- * - Replace every run of characters outside `[a-z0-9]` with a single `-`.
693
- * - Strip any leading or trailing `-` characters.
694
- * - Return `""` for blank/empty input.
695
- */
696
464
  const NodeIdSlugifier = { slugify(label) {
697
465
  if (!label) return "";
698
466
  return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -700,15 +468,6 @@ const NodeIdSlugifier = { slugify(label) {
700
468
 
701
469
  //#endregion
702
470
  //#region src/workflow/dsl/WorkflowDefinitionError.ts
703
- /**
704
- * Thrown by {@link WorkflowBuilder.build} when the workflow definition is structurally invalid.
705
- *
706
- * Common causes:
707
- * - A node has an empty effective id (label is blank and no explicit `id` was given).
708
- * - Two or more nodes share the same effective id (label slugs collide or explicit ids clash).
709
- *
710
- * Fix: provide an explicit `id:` on the offending node configs.
711
- */
712
471
  var WorkflowDefinitionError = class extends Error {
713
472
  constructor(message) {
714
473
  super(message);
@@ -783,7 +542,7 @@ var WorkflowBuilder = class {
783
542
  tokenName,
784
543
  label: node$1.name ?? ""
785
544
  });
786
- if (require_di.AgentConfigInspector.isAgentNodeConfig(node$1.config)) for (const child of require_di.AgentConnectionNodeCollector.collect(node$1.id, node$1.config)) entries.push({
545
+ if (require_di.AgentConfigInspector.isAgentNodeConfig(node$1.config)) for (const child of require_workflowTypes.AgentConnectionNodeCollector.collect(node$1.id, node$1.config)) entries.push({
787
546
  nodeId: child.nodeId,
788
547
  tokenName: child.typeName,
789
548
  label: child.name
@@ -820,17 +579,10 @@ var WorkflowBuilder = class {
820
579
 
821
580
  //#endregion
822
581
  //#region src/workflow/definition/ConnectionInvocationIdFactory.ts
823
- /**
824
- * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
825
- *
826
- * Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
827
- * paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
828
- */
829
582
  var ConnectionInvocationIdFactory = class {
830
583
  static create() {
831
584
  return `cinv_${globalThis.crypto.randomUUID()}`;
832
585
  }
833
- /** Deterministic id for tests when a stable sequence is needed. */
834
586
  static createForTest(runId, connectionNodeId, sequence) {
835
587
  return `cinv_${runId}_${connectionNodeId}_${sequence}`;
836
588
  }
@@ -838,9 +590,6 @@ var ConnectionInvocationIdFactory = class {
838
590
 
839
591
  //#endregion
840
592
  //#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
841
- /**
842
- * Derives which workflow nodes participate in the main execution graph vs connection-only children.
843
- */
844
593
  var WorkflowExecutableNodeClassifier = class {
845
594
  connectionOwnedIds;
846
595
  constructor(workflow) {
@@ -860,9 +609,6 @@ var WorkflowExecutableNodeClassifier = class {
860
609
  for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
861
610
  return ids;
862
611
  }
863
- /**
864
- * Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
865
- */
866
612
  findDefaultExecutableStartNodeId(workflow) {
867
613
  const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
868
614
  if (firstTrigger) return firstTrigger;
@@ -927,13 +673,6 @@ var DefaultWorkflowGraphFactory = class {
927
673
 
928
674
  //#endregion
929
675
  //#region src/events/ConnectionInvocationEventPublisher.ts
930
- /**
931
- * Publishes per-invocation lifecycle records onto the run {@link RunEventBus}.
932
- *
933
- * Surgical, per-invocation events let the UI update the right-side inspector
934
- * timeline as each LLM round / tool call transitions through `running` → `completed`
935
- * (or `failed`) without depending on a coarse `runSaved` poll.
936
- */
937
676
  var ConnectionInvocationEventPublisher = class {
938
677
  constructor(eventBus, parent) {
939
678
  this.eventBus = eventBus;
@@ -961,7 +700,6 @@ var ConnectionInvocationEventPublisher = class {
961
700
 
962
701
  //#endregion
963
702
  //#region src/events/NodeEventPublisher.ts
964
- /** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
965
703
  var NodeEventPublisher = class {
966
704
  constructor(eventBus) {
967
705
  this.eventBus = eventBus;
@@ -981,20 +719,7 @@ var NodeEventPublisher = class {
981
719
 
982
720
  //#endregion
983
721
  //#region src/binaries/boundedReadBinary.types.ts
984
- /**
985
- * Reads all bytes from an already-opened binary stream into a contiguous `Uint8Array`.
986
- *
987
- * Safety contract:
988
- * - `attachment.size` is checked against `maxBytes` *before* any allocation (no OOM).
989
- * - A single buffer of exactly `attachment.size` is pre-allocated; the stream fills it
990
- * directly — no chunks array, no doubling.
991
- * - A byte-count mismatch between the declared size and actual stream content is an error.
992
- *
993
- * This is the single canonical implementation; `ExecutionBinaryService.getBytes`,
994
- * `getText`, and `getJson` all delegate here. The per-package `readBinaryBody` helpers
995
- * in `core-nodes` and `core-nodes-ocr` have been removed in favour of this function.
996
- */
997
- async function boundedReadBinary(result, attachment, maxBytes = require_di.BINARY_DEFAULT_MAX_BYTES) {
722
+ async function boundedReadBinary(result, attachment, maxBytes = require_workflowTypes.BINARY_DEFAULT_MAX_BYTES) {
998
723
  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.`);
999
724
  const out = new Uint8Array(attachment.size);
1000
725
  const reader = result.body.getReader();
@@ -1010,18 +735,15 @@ async function boundedReadBinary(result, attachment, maxBytes = require_di.BINAR
1010
735
  if (offset !== out.byteLength) throw new Error(`Binary stream produced ${offset} bytes but attachment declared size ${attachment.size}.`);
1011
736
  return out;
1012
737
  }
1013
- /** Shared implementation of `getBytes` used by both binary-service classes. */
1014
738
  async function readBinaryAsBytes(storage, attachment, maxBytes) {
1015
739
  const result = await storage.openReadStream(attachment.storageKey);
1016
740
  if (!result) throw new Error("Binary attachment stream is unavailable.");
1017
741
  return boundedReadBinary(result, attachment, maxBytes);
1018
742
  }
1019
- /** Shared implementation of `getText` used by both binary-service classes. */
1020
743
  async function readBinaryAsText(storage, attachment, maxBytes) {
1021
744
  const bytes = await readBinaryAsBytes(storage, attachment, maxBytes);
1022
745
  return new TextDecoder().decode(bytes);
1023
746
  }
1024
- /** Shared implementation of `getJson` used by both binary-service classes. */
1025
747
  async function readBinaryAsJson(storage, attachment, maxBytes) {
1026
748
  const text = await readBinaryAsText(storage, attachment, maxBytes);
1027
749
  try {
@@ -1365,19 +1087,6 @@ var ActivationEnqueueService = class {
1365
1087
 
1366
1088
  //#endregion
1367
1089
  //#region src/execution/ChildExecutionScopeFactory.ts
1368
- /**
1369
- * Builds a re-rooted child execution context for sub-agent (and other deeply-nested) invocations.
1370
- *
1371
- * At the orchestrator's `agent.tool.call` boundary the inner runtime needs a ctx whose:
1372
- * - `nodeId` is the tool's connection node id (so inner LLM/tool connection ids derive correctly),
1373
- * - `activationId` is fresh (so its connection-invocation rows are uniquely identifiable),
1374
- * - `telemetry` parents children under the tool-call span (not the orchestrator's node span),
1375
- * - `binary` is scoped to the new (nodeId, activationId),
1376
- * - `parentInvocationId` points back to the tool-call invocation for downstream lineage.
1377
- *
1378
- * Registered via factory in {@link EngineRuntimeRegistrar} so constructors stay free of parameter
1379
- * decorators (Next/SWC and coverage tooling cannot parse them on in-repo sources).
1380
- */
1381
1090
  var ChildExecutionScopeFactory = class {
1382
1091
  constructor(activationIdFactory) {
1383
1092
  this.activationIdFactory = activationIdFactory;
@@ -1407,9 +1116,6 @@ var ChildExecutionScopeFactory = class {
1407
1116
 
1408
1117
  //#endregion
1409
1118
  //#region src/contracts/itemMeta.ts
1410
- /**
1411
- * Reads `meta._cm.originIndex` when present (used for fan-in merge-by-origin and Merge routing).
1412
- */
1413
1119
  function getOriginIndexFromItem(item) {
1414
1120
  const v = (item.meta?._cm)?.originIndex;
1415
1121
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
@@ -1417,17 +1123,6 @@ function getOriginIndexFromItem(item) {
1417
1123
 
1418
1124
  //#endregion
1419
1125
  //#region src/execution/FanInMergeByOriginMerger.ts
1420
- /**
1421
- * Default fan-in: combine multi-port {@link NodeInputsByPort} into one {@link Items} batch for per-item nodes.
1422
- *
1423
- * This is used when a single-input per-item node has multiple inbound edges (for example, branch reconverge
1424
- * after an `If` / `Switch`). The default behavior is **append / union** (preserving item payloads) with a
1425
- * deterministic order:
1426
- *
1427
- * - When router origin metadata exists (`meta._cm.originIndex`), items are sorted by origin index so the
1428
- * downstream batch preserves original ordering across branches.
1429
- * - Otherwise, items are appended by port-key order, preserving each port's local order.
1430
- */
1431
1126
  var FanInMergeByOriginMerger = class {
1432
1127
  merge(inputsByPort) {
1433
1128
  const portKeys = Object.keys(inputsByPort).sort();
@@ -1477,11 +1172,6 @@ var NodeInputContractError = class extends Error {
1477
1172
 
1478
1173
  //#endregion
1479
1174
  //#region src/execution/NodeActivationRequestInputPreparer.ts
1480
- /**
1481
- * Validates per-item inputs for {@link RunnableNode} before enqueue persistence (Zod on `item.json`).
1482
- * Does not rewrite `item.json` (wire stays as emitted upstream; engine passes parsed input via `execute` args).
1483
- * Converts multi-input activations into a single-input batch when the node is per-item only (engine fan-in).
1484
- */
1485
1175
  var NodeActivationRequestInputPreparer = class {
1486
1176
  fanInMerger = new FanInMergeByOriginMerger();
1487
1177
  constructor(workflowNodeInstanceFactory) {
@@ -1628,13 +1318,11 @@ var RetryPolicy = class {
1628
1318
  if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);
1629
1319
  if (!Number.isFinite(delayMs) || delayMs < 0) throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);
1630
1320
  }
1631
- /** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */
1632
1321
  static defaultForHttp = {
1633
1322
  kind: "fixed",
1634
1323
  maxAttempts: 3,
1635
1324
  delayMs: 1e3
1636
1325
  };
1637
- /** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */
1638
1326
  static defaultForAiAgent = {
1639
1327
  kind: "fixed",
1640
1328
  maxAttempts: 3,
@@ -1704,12 +1392,6 @@ var NoOpTelemetryArtifactReference = class {
1704
1392
 
1705
1393
  //#endregion
1706
1394
  //#region src/contracts/NoOpTelemetrySpanScope.ts
1707
- /**
1708
- * Standalone no-op {@link NodeExecutionTelemetry} value used as the return for `asNodeTelemetry`.
1709
- *
1710
- * Defined here (instead of in `NoOpNodeExecutionTelemetry.ts`) so that {@link NoOpTelemetrySpanScope}
1711
- * can return it without importing the other module — both no-ops share this leaf.
1712
- */
1713
1395
  const noOpNodeExecutionTelemetry = {
1714
1396
  traceId: "00000000000000000000000000000000",
1715
1397
  spanId: "0000000000000000",
@@ -1744,7 +1426,6 @@ const noOpTelemetrySpanScope = {
1744
1426
  };
1745
1427
  var NoOpTelemetrySpanScope = class {
1746
1428
  static value = noOpTelemetrySpanScope;
1747
- /** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
1748
1429
  static nodeExecutionTelemetryValue = noOpNodeExecutionTelemetry;
1749
1430
  };
1750
1431
 
@@ -1781,7 +1462,6 @@ var NoOpExecutionTelemetryFactory = class {
1781
1462
 
1782
1463
  //#endregion
1783
1464
  //#region src/contracts/workflowActivationPolicy.ts
1784
- /** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
1785
1465
  var AllWorkflowsActiveWorkflowActivationPolicy = class {
1786
1466
  isActive(_workflowId) {
1787
1467
  return true;
@@ -1801,25 +1481,15 @@ var CodemationTelemetryAttributeNames = class {
1801
1481
  static connectionInvocationId = "codemation.connection.invocation_id";
1802
1482
  static toolName = "codemation.tool.name";
1803
1483
  static traceParentRunId = "codemation.parent.run.id";
1804
- /** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
1805
1484
  static iterationId = "codemation.iteration.id";
1806
- /** Item index (0-based) of the iteration. */
1807
1485
  static iterationIndex = "codemation.iteration.index";
1808
- /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
1809
1486
  static parentInvocationId = "codemation.parent.invocation_id";
1810
- /** MCP server id on spans created for callTool invocations. */
1811
1487
  static mcpServerId = "mcp.server_id";
1812
- /** MCP tool name on spans created for callTool invocations. */
1813
1488
  static mcpToolName = "mcp.tool_name";
1814
- /** Terminal node-execution status (e.g. `"hitl-approved"`, `"hitl-rejected"`) on HITL outcome spans. */
1815
1489
  static nodeExecutionStatus = "codemation.node.execution_status";
1816
- /** Populated on run-halted spans; discriminates the halt reason (e.g. `"hitl-rejected"`). */
1817
1490
  static runHaltReason = "codemation.run.halt_reason";
1818
- /** Human task ID on `hitl.task.*` span events. */
1819
1491
  static hitlTaskId = "codemation.hitl.task_id";
1820
- /** HITL channel name (e.g. `"inbox"`, `"control-plane-inbox"`) on `hitl.task.*` span events. */
1821
1492
  static hitlChannel = "codemation.hitl.channel";
1822
- /** Decision outcome (e.g. `"approved"`, `"rejected"`) on `hitl.task.decided` span events. */
1823
1493
  static hitlDecisionStatus = "codemation.hitl.decision_status";
1824
1494
  };
1825
1495
 
@@ -2034,7 +1704,6 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
2034
1704
 
2035
1705
  //#endregion
2036
1706
  //#region src/execution/InProcessRetryRunner.ts
2037
- /** Maximum permitted retry attempts — workflow-declared values above this are clamped. */
2038
1707
  const HARD_MAX_RETRY_ATTEMPTS = 10;
2039
1708
  var InProcessRetryRunner = class InProcessRetryRunner {
2040
1709
  constructor(sleeper) {
@@ -2126,9 +1795,6 @@ var InProcessRetryRunner = class InProcessRetryRunner {
2126
1795
 
2127
1796
  //#endregion
2128
1797
  //#region src/execution/ItemExprResolver.ts
2129
- /**
2130
- * Resolves {@link import("../contracts/itemExpr").ItemExpr} leaves on runnable config before {@link RunnableNode.execute}.
2131
- */
2132
1798
  var ItemExprResolver = class {
2133
1799
  async resolveConfigForItem(ctx, item, itemIndex, items) {
2134
1800
  if (!ctx) throw new Error("ItemExprResolver.resolveConfigForItem: ctx is required");
@@ -2218,9 +1884,6 @@ var InProcessRetryRunnerFactory = class {
2218
1884
 
2219
1885
  //#endregion
2220
1886
  //#region src/execution/NodeActivationRequestComposer.ts
2221
- /**
2222
- * Builds {@link NodeActivationRequest} values shared by workflow starters and continuation.
2223
- */
2224
1887
  var NodeActivationRequestComposer = class {
2225
1888
  constructor(activationIdFactory, credentialResolverFactory) {
2226
1889
  this.activationIdFactory = activationIdFactory;
@@ -2312,16 +1975,6 @@ var NodeActivationRequestComposer = class {
2312
1975
 
2313
1976
  //#endregion
2314
1977
  //#region src/execution/RunSuspendedError.ts
2315
- /**
2316
- * Internal sentinel thrown by {@link NodeSuspensionHandler} after persisting a suspension
2317
- * entry. `NodeExecutionRequestHandlerService` catches this specifically and returns cleanly —
2318
- * no continuation call, preventing `resumeFromNodeResult` / `resumeFromNodeError` from
2319
- * overwriting the `"suspended"` run status.
2320
- *
2321
- * The `Error` suffix satisfies the ESLint `no-manual-di-new` allowlist. This is NOT a
2322
- * user-facing error — it is an engine-internal control-flow primitive and should NOT be
2323
- * exported from the public barrel.
2324
- */
2325
1978
  var RunSuspendedError = class extends Error {
2326
1979
  constructor(runId, taskId) {
2327
1980
  super(`RunSuspendedError: run ${runId} suspended on task ${taskId}`);
@@ -2363,8 +2016,8 @@ var NodeExecutor = class {
2363
2016
  }
2364
2017
  }
2365
2018
  isCredentialError(e) {
2366
- if (e instanceof require_di.CredentialUnboundError) return true;
2367
- return (e instanceof Error ? e.cause : void 0) instanceof require_di.CredentialUnboundError;
2019
+ if (e instanceof require_workflowTypes.CredentialUnboundError) return true;
2020
+ return (e instanceof Error ? e.cause : void 0) instanceof require_workflowTypes.CredentialUnboundError;
2368
2021
  }
2369
2022
  async executeMultiInputActivation(request, node$1) {
2370
2023
  const multiInputNode = node$1;
@@ -2451,7 +2104,7 @@ var NodeExecutor = class {
2451
2104
  const resolvedCtx = await this.itemExprResolver.resolveConfigForItem(runnableCtx, item, i, inputBatch);
2452
2105
  const iterationCtx = {
2453
2106
  ...this.pickExecutionContext(runnableCtx, resolvedCtx),
2454
- iterationId: require_di.NodeIterationIdFactory.create(),
2107
+ iterationId: require_workflowTypes.NodeIterationIdFactory.create(),
2455
2108
  itemIndex: i
2456
2109
  };
2457
2110
  const args = {
@@ -2465,7 +2118,7 @@ var NodeExecutor = class {
2465
2118
  try {
2466
2119
  raw = await Promise.resolve(node$1.execute(args));
2467
2120
  } catch (e) {
2468
- if (e instanceof require_di.SuspensionRequest || e instanceof Error && e.name === "SuspensionRequest" && typeof e.request === "object") {
2121
+ if (e instanceof require_workflowTypes.SuspensionRequest || e instanceof Error && e.name === "SuspensionRequest" && typeof e.request === "object") {
2469
2122
  if (!this.suspensionHandler || !this.loadRunState) throw new Error(`Node ${request.nodeId} threw SuspensionRequest but this NodeExecutor has no suspensionHandler configured.`, { cause: e });
2470
2123
  const state = await this.loadRunState(request.runId);
2471
2124
  if (!state) throw new Error(`NodeExecutor: run state not found for runId ${request.runId} during suspension`, { cause: e });
@@ -2498,7 +2151,6 @@ var NodeExecutor = class {
2498
2151
  if (hasSuspension) throw new RunSuspendedError(request.runId, "unknown");
2499
2152
  return byPort;
2500
2153
  }
2501
- /** Use resolver ctx only when {@link NodeExecutionContext.config} is non-nullish. */
2502
2154
  pickExecutionContext(runnableCtx, resolvedCtx) {
2503
2155
  if (resolvedCtx != null && resolvedCtx.config != null) return resolvedCtx;
2504
2156
  return runnableCtx;
@@ -2599,247 +2251,41 @@ var MissingRuntimeNode = class {
2599
2251
  };
2600
2252
 
2601
2253
  //#endregion
2602
- //#region src/workflowSnapshots/MissingRuntimeTrigger.ts
2603
- var MissingRuntimeTrigger = class {
2604
- kind = "trigger";
2605
- outputPorts = ["main"];
2606
- async setup(_ctx) {}
2607
- async execute(items) {
2608
- return { main: items };
2609
- }
2610
- };
2611
-
2612
- //#endregion
2613
- //#region src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts
2614
- var PersistedRuntimeTypeIdFactory = class {
2615
- static fromMetadata(args) {
2616
- const metadata = getPersistedRuntimeTypeMetadata(args.type);
2617
- if (!metadata) return;
2618
- const packageName = metadata.packageName;
2619
- if (!packageName) return;
2620
- return `${packageName}::${metadata.persistedName}`;
2254
+ //#region src/workflowSnapshots/WorkflowParityMismatchError.ts
2255
+ var WorkflowParityMismatchError = class extends Error {
2256
+ name = "WorkflowParityMismatchError";
2257
+ missingNodes;
2258
+ constructor(missingNodes) {
2259
+ const labels = missingNodes.map((n) => `${n.nodeId} (token: ${n.missingTokenId ?? "unknown"})`).join(", ");
2260
+ super(`Workflow parity mismatch: nodes resolve to MissingRuntime and cannot execute: ${labels}`);
2261
+ this.missingNodes = missingNodes;
2621
2262
  }
2622
2263
  };
2623
2264
 
2624
2265
  //#endregion
2625
- //#region src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts
2626
- var PersistedWorkflowTokenRegistry = class {
2627
- tokensById = /* @__PURE__ */ new Map();
2628
- tokenIdsByToken = /* @__PURE__ */ new Map();
2629
- /**
2630
- * Register a token with its package ID. Token ID is inferred as `packageId::tokenName`.
2631
- */
2632
- register(type, packageId, persistedNameOverride) {
2633
- const tokenId = `${packageId}::${persistedNameOverride ?? this.displayNameForTypeToken(type)}`;
2634
- this.tokensById.set(tokenId, type);
2635
- this.tokenIdsByToken.set(type, tokenId);
2636
- return tokenId;
2637
- }
2638
- /**
2639
- * Register all decorated runtime types discovered in workflows.
2640
- */
2641
- registerFromWorkflows(workflows) {
2642
- for (const workflow of workflows) for (const node$1 of workflow.nodes) {
2643
- this.registerDecoratedType(node$1.type);
2644
- this.registerDecoratedType(node$1.config.type);
2645
- this.registerNestedTypes(node$1.config);
2646
- }
2647
- }
2648
- registerDecoratedType(type) {
2649
- if (this.tokenIdsByToken.has(type)) return;
2650
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });
2651
- if (!tokenId) return;
2652
- this.tokensById.set(tokenId, type);
2653
- this.tokenIdsByToken.set(type, tokenId);
2654
- }
2655
- registerNestedTypes(value) {
2656
- if (Array.isArray(value)) {
2657
- for (const entry of value) this.registerNestedTypes(entry);
2658
- return;
2659
- }
2660
- if (!value || typeof value !== "object") return;
2661
- const record = value;
2662
- const type = this.asTypeToken(record.type);
2663
- if (type) this.registerDecoratedType(type);
2664
- for (const v of Object.values(record)) this.registerNestedTypes(v);
2665
- }
2666
- displayNameForTypeToken(token) {
2667
- if (typeof token === "function" && token.name) return token.name;
2668
- if (typeof token === "string") return token;
2669
- return "";
2670
- }
2671
- asTypeToken(value) {
2672
- if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
2673
- }
2674
- getTokenId(token) {
2675
- const existing = this.tokenIdsByToken.get(token);
2676
- if (existing) return existing;
2677
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });
2678
- if (!tokenId) return;
2679
- this.tokensById.set(tokenId, token);
2680
- this.tokenIdsByToken.set(token, tokenId);
2681
- return tokenId;
2682
- }
2683
- resolve(tokenId) {
2684
- return this.tokensById.get(tokenId);
2266
+ //#region src/workflowSnapshots/MissingRuntimeParityGuard.ts
2267
+ var MissingRuntimeParityGuard = class {
2268
+ constructor(marker) {
2269
+ this.marker = marker;
2270
+ }
2271
+ assertNone(workflow, nodeIds) {
2272
+ const missing = (nodeIds ? workflow.nodes.filter((n) => nodeIds.includes(n.id)) : workflow.nodes).filter((n) => this.marker.isMarked(n.config)).map((n) => ({
2273
+ nodeId: n.id,
2274
+ kind: n.kind,
2275
+ missingTokenId: n.config.missingTokenId
2276
+ }));
2277
+ if (missing.length > 0) throw new WorkflowParityMismatchError(missing);
2685
2278
  }
2686
2279
  };
2687
2280
 
2688
2281
  //#endregion
2689
- //#region src/workflowSnapshots/WorkflowSnapshotCodec.ts
2690
- var WorkflowSnapshotCodec = class {
2691
- constructor(tokenRegistry) {
2692
- this.tokenRegistry = tokenRegistry;
2693
- }
2694
- create(workflow) {
2695
- return {
2696
- id: workflow.id,
2697
- name: workflow.name,
2698
- workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
2699
- ...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
2700
- nodes: workflow.nodes.map((node$1) => {
2701
- const inspectorSummaryRows = this.safeInspectorSummary(node$1.config);
2702
- return {
2703
- id: node$1.id,
2704
- kind: node$1.kind,
2705
- name: node$1.name,
2706
- nodeTokenId: this.resolveTokenId(node$1.type),
2707
- configTokenId: this.resolveTokenId(node$1.config.type),
2708
- tokenName: this.resolveTokenName(node$1.type),
2709
- configTokenName: this.resolveTokenName(node$1.config.type),
2710
- config: this.serializeConfig(node$1.config),
2711
- ...inspectorSummaryRows !== void 0 ? { inspectorSummary: inspectorSummaryRows } : {}
2712
- };
2713
- }),
2714
- edges: workflow.edges.map((edge) => ({
2715
- from: {
2716
- nodeId: edge.from.nodeId,
2717
- output: edge.from.output
2718
- },
2719
- to: {
2720
- nodeId: edge.to.nodeId,
2721
- input: edge.to.input
2722
- }
2723
- }))
2724
- };
2725
- }
2726
- hydrate(snapshotNode, liveConfig) {
2727
- const hydrated = this.mergeValue(liveConfig, snapshotNode.config);
2728
- const configToken = this.tokenRegistry.resolve(snapshotNode.configTokenId);
2729
- Object.assign(hydrated, {
2730
- type: configToken ?? liveConfig.type,
2731
- kind: snapshotNode.kind
2732
- });
2733
- if (snapshotNode.name && !("name" in hydrated && hydrated.name)) Object.assign(hydrated, { name: snapshotNode.name });
2734
- return hydrated;
2735
- }
2736
- serializeConfig(config) {
2737
- try {
2738
- const cloned = JSON.parse(JSON.stringify(config));
2739
- this.injectTokenIds(cloned, config);
2740
- return cloned;
2741
- } catch {
2742
- const fallback = {
2743
- kind: config.kind,
2744
- name: config.name,
2745
- id: config.id,
2746
- icon: config.icon,
2747
- description: config.description,
2748
- execution: config.execution
2749
- };
2750
- this.injectTokenIds(fallback, config);
2751
- return fallback;
2752
- }
2753
- }
2754
- /**
2755
- * Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
2756
- * Returns undefined if the method is absent, throws, or produces no valid rows.
2757
- */
2758
- safeInspectorSummary(config) {
2759
- const fn = config.inspectorSummary;
2760
- if (typeof fn !== "function") return void 0;
2761
- let raw;
2762
- try {
2763
- raw = fn.call(config);
2764
- } catch {
2765
- return;
2766
- }
2767
- if (!Array.isArray(raw)) return void 0;
2768
- const rows = [];
2769
- for (const entry of raw) {
2770
- if (!entry || typeof entry !== "object") continue;
2771
- const { label, value } = entry;
2772
- if (typeof label !== "string" || typeof value !== "string") continue;
2773
- const trimmedLabel = label.trim();
2774
- if (trimmedLabel.length === 0) continue;
2775
- rows.push({
2776
- label: trimmedLabel,
2777
- value
2778
- });
2779
- }
2780
- return rows.length > 0 ? rows : void 0;
2781
- }
2782
- injectTokenIds(target, source) {
2783
- const type = this.asTypeToken(source.type);
2784
- if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
2785
- for (const [key, value] of Object.entries(source)) {
2786
- if (key === "type" || value == null) continue;
2787
- if (Array.isArray(value)) {
2788
- const targetArray = target[key];
2789
- if (Array.isArray(targetArray)) value.forEach((item, index) => {
2790
- if (item && typeof item === "object" && targetArray[index] && typeof targetArray[index] === "object") this.injectTokenIds(targetArray[index], item);
2791
- });
2792
- continue;
2793
- }
2794
- if (typeof value === "object") {
2795
- const targetValue = target[key];
2796
- if (targetValue && typeof targetValue === "object") this.injectTokenIds(targetValue, value);
2797
- }
2798
- }
2799
- }
2800
- mergeValue(liveValue, snapshotValue) {
2801
- const liveRecord = this.asRecord(liveValue);
2802
- const snapshotRecord = this.asRecord(snapshotValue);
2803
- const hydrated = Object.create(liveValue && typeof liveValue === "object" ? Object.getPrototypeOf(liveValue) ?? Object.prototype : Object.prototype);
2804
- for (const [key, value] of Object.entries(snapshotRecord)) hydrated[key] = this.mergeNestedValue(liveRecord[key], value);
2805
- this.restoreNonSerializableProperties(liveRecord, hydrated);
2806
- this.restoreTypeProperty(hydrated);
2807
- return hydrated;
2808
- }
2809
- mergeNestedValue(liveValue, snapshotValue) {
2810
- if (Array.isArray(snapshotValue)) {
2811
- const liveArray = Array.isArray(liveValue) ? liveValue : [];
2812
- return snapshotValue.map((entry, index) => this.mergeNestedValue(liveArray[index], entry));
2813
- }
2814
- if (snapshotValue && typeof snapshotValue === "object") return this.mergeValue(liveValue, snapshotValue);
2815
- return snapshotValue;
2816
- }
2817
- restoreNonSerializableProperties(liveRecord, hydrated) {
2818
- for (const [key, value] of Object.entries(liveRecord)) if (typeof value === "function" || typeof value === "symbol") hydrated[key] = value;
2819
- for (const sym of Object.getOwnPropertySymbols(liveRecord)) hydrated[sym] = liveRecord[sym];
2820
- }
2821
- restoreTypeProperty(record) {
2822
- const tokenId = typeof record.tokenId === "string" ? record.tokenId : void 0;
2823
- if (!tokenId) return;
2824
- const type = this.tokenRegistry.resolve(tokenId);
2825
- if (type) record.type = type;
2826
- }
2827
- resolveTokenId(token) {
2828
- return this.tokenRegistry.getTokenId(token) ?? this.resolveTokenName(token) ?? "unknown";
2829
- }
2830
- resolveTokenName(token) {
2831
- if (typeof token === "function" && token.name) return token.name;
2832
- if (typeof token === "string") return token;
2833
- }
2834
- asTypeToken(value) {
2835
- if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
2836
- }
2837
- asRecord(value) {
2838
- if (!value || typeof value !== "object" || Array.isArray(value)) return {};
2839
- const record = value;
2840
- const out = { ...record };
2841
- for (const sym of Object.getOwnPropertySymbols(value)) out[sym] = record[sym];
2842
- return out;
2282
+ //#region src/workflowSnapshots/MissingRuntimeTrigger.ts
2283
+ var MissingRuntimeTrigger = class {
2284
+ kind = "trigger";
2285
+ outputPorts = ["main"];
2286
+ async setup(_ctx) {}
2287
+ async execute(items) {
2288
+ return { main: items };
2843
2289
  }
2844
2290
  };
2845
2291
 
@@ -3108,9 +2554,6 @@ var NodeRunStateWriterFactory = class {
3108
2554
 
3109
2555
  //#endregion
3110
2556
  //#region src/execution/PersistedRunStateTerminalBuilder.ts
3111
- /**
3112
- * Merges common terminal-run fields onto a loaded {@link PersistedRunState} without repeating object literals.
3113
- */
3114
2557
  var PersistedRunStateTerminalBuilder = class {
3115
2558
  mergeTerminal(args) {
3116
2559
  return {
@@ -3208,9 +2651,6 @@ var RunStateSemantics = class {
3208
2651
 
3209
2652
  //#endregion
3210
2653
  //#region src/execution/WorkflowRunExecutionContextFactory.ts
3211
- /**
3212
- * Shared {@link ExecutionContextFactory#create} wiring for workflow runners (base context before node-specific fields).
3213
- */
3214
2654
  var WorkflowRunExecutionContextFactory = class {
3215
2655
  constructor(executionContextFactory, credentialResolverFactory) {
3216
2656
  this.executionContextFactory = executionContextFactory;
@@ -3329,7 +2769,7 @@ var WorkflowTopology = class WorkflowTopology {
3329
2769
  //#endregion
3330
2770
  //#region src/orchestration/RunContinuationService.ts
3331
2771
  var RunContinuationService = class {
3332
- constructor(activationIdFactory, workflowExecutionRepository, runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy) {
2772
+ constructor(activationIdFactory, workflowExecutionRepository, runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy, parityGuard) {
3333
2773
  this.activationIdFactory = activationIdFactory;
3334
2774
  this.workflowExecutionRepository = workflowExecutionRepository;
3335
2775
  this.runDataFactory = runDataFactory;
@@ -3347,6 +2787,7 @@ var RunContinuationService = class {
3347
2787
  this.policyErrorServices = policyErrorServices;
3348
2788
  this.terminalPersistence = terminalPersistence;
3349
2789
  this.executionLimitsPolicy = executionLimitsPolicy;
2790
+ this.parityGuard = parityGuard;
3350
2791
  }
3351
2792
  async markNodeRunning(args) {
3352
2793
  const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(args.runId), this.workflowExecutionRepository.loadSchedulingState(args.runId)]);
@@ -3589,6 +3030,7 @@ var RunContinuationService = class {
3589
3030
  nodeDefinition: def
3590
3031
  });
3591
3032
  try {
3033
+ this.parityGuard.assertNone(wf, [next.nodeId]);
3592
3034
  const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
3593
3035
  runId: state.runId,
3594
3036
  workflowId: state.workflowId,
@@ -3760,20 +3202,6 @@ var RunContinuationService = class {
3760
3202
  async waitForWebhookResponse(runId) {
3761
3203
  return await this.waiters.waitForWebhookResponse(runId);
3762
3204
  }
3763
- /**
3764
- * Re-activate a previously suspended run item with a human decision.
3765
- *
3766
- * Called by the HITL resume endpoint. This method:
3767
- * 1. Loads `PersistedRunState` and locates the suspension entry by `taskId`.
3768
- * 2. Removes the entry from the `suspension` array; if empty, run stays `"suspended"` until
3769
- * enqueue flips it to `"pending"`.
3770
- * 3. Writes `pendingResume` onto the state so `NodeExecutionRequestHandlerService` can
3771
- * splice `resumeContext` into the node's execution context.
3772
- * 4. Reconstructs the original input from `outputsByNode` of the upstream node and
3773
- * enqueues a new activation via `activationEnqueueService`.
3774
- *
3775
- * @throws if the run is not found, not suspended, or the `taskId` is unknown.
3776
- */
3777
3205
  async resumeRun(args) {
3778
3206
  const state = await this.workflowExecutionRepository.load(args.runId);
3779
3207
  if (!state) throw new Error(`Unknown runId: ${args.runId}`);
@@ -3832,6 +3260,7 @@ var RunContinuationService = class {
3832
3260
  batchId,
3833
3261
  input: resumeInput
3834
3262
  });
3263
+ this.parityGuard.assertNone(wf, [suspensionEntry.nodeId]);
3835
3264
  const { result, queuedSnapshot } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
3836
3265
  runId: state.runId,
3837
3266
  workflowId: state.workflowId,
@@ -4066,6 +3495,7 @@ var RunContinuationService = class {
4066
3495
  nodeDefinition: nextDefinition
4067
3496
  });
4068
3497
  try {
3498
+ this.parityGuard.assertNone(args.workflow, [next.nodeId]);
4069
3499
  const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
4070
3500
  runId: args.state.runId,
4071
3501
  workflowId: args.state.workflowId,
@@ -4180,10 +3610,6 @@ var RunContinuationService = class {
4180
3610
  engineMaxSubworkflowDepth: state.executionOptions?.maxSubworkflowDepth ?? fb.maxSubworkflowDepth
4181
3611
  };
4182
3612
  }
4183
- /**
4184
- * Next activation could not be enqueued (e.g. input contract / mapping failed in the preparer).
4185
- * Marks the target node failed and terminates the run.
4186
- */
4187
3613
  async terminateRunAfterActivationEnqueueRejected(args) {
4188
3614
  const finishedAt = args.completedAt;
4189
3615
  const inputsByPort = NodeInputsByPortFactory.fromRequest(args.request);
@@ -4240,11 +3666,6 @@ var RunContinuationService = class {
4240
3666
  this.waiters.resolveRunCompletion(result);
4241
3667
  return result;
4242
3668
  }
4243
- /**
4244
- * Inspects node outputs for a `decision.status` written by `defineHumanApprovalNode`.
4245
- * Returns the first-class HITL node status and halt classification, or `undefined`
4246
- * when the node is not a HITL approval node.
4247
- */
4248
3669
  resolveHitlStatus(outputs) {
4249
3670
  const firstItem = outputs?.main?.[0];
4250
3671
  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;
@@ -4285,7 +3706,6 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
4285
3706
  constructor(topology) {
4286
3707
  this.topology = topology;
4287
3708
  }
4288
- /** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */
4289
3709
  static createFromTopology(topology) {
4290
3710
  return new CurrentStateFrontierPlanner(topology);
4291
3711
  }
@@ -4540,7 +3960,7 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
4540
3960
  isRuntimeDescendant(nodeId, descendantNodeIds) {
4541
3961
  for (const descendantNodeId of descendantNodeIds) {
4542
3962
  if (nodeId === descendantNodeId) return false;
4543
- if (require_di.ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) return true;
3963
+ if (require_workflowTypes.ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) return true;
4544
3964
  }
4545
3965
  return false;
4546
3966
  }
@@ -5037,12 +4457,6 @@ var DefaultDrivingScheduler = class {
5037
4457
  }
5038
4458
  return await this.prepareInlineDispatch(request);
5039
4459
  }
5040
- /**
5041
- * Scheduler precedence is explicit:
5042
- * 1. run-intent override (`executionOptions.localOnly`)
5043
- * 2. node-level execution hint / queue policy
5044
- * 3. container-default scheduler policy fallback
5045
- */
5046
4460
  async selectScheduler(request) {
5047
4461
  if (request.executionOptions?.localOnly) return {
5048
4462
  mode: "local",
@@ -5108,14 +4522,6 @@ var InlineDrivingScheduler = class {
5108
4522
  setContinuation(continuation) {
5109
4523
  this.continuation = continuation;
5110
4524
  }
5111
- /**
5112
- * Prevents new drain cycles from being scheduled and waits for all currently-running
5113
- * drains to complete. Call before closing the DB connection or rolling back test transactions
5114
- * to ensure no in-flight writes hit a closed/rolled-back connection.
5115
- *
5116
- * Bounded: only the drains already in-flight at call time are awaited. Runs that keep
5117
- * re-scheduling will not schedule new work once stopped is set.
5118
- */
5119
4525
  async stop() {
5120
4526
  this.stopped = true;
5121
4527
  if (this.activeDrainPromises.size > 0) await Promise.allSettled(this.activeDrainPromises);
@@ -5227,24 +4633,16 @@ var LocalOnlyScheduler = class {
5227
4633
 
5228
4634
  //#endregion
5229
4635
  //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
5230
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
5231
4636
  const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
5232
4637
  defaultMaxNodeActivations: 1e5,
5233
4638
  hardMaxNodeActivations: 1e5,
5234
4639
  defaultMaxSubworkflowDepth: 32,
5235
4640
  hardMaxSubworkflowDepth: 32
5236
4641
  };
5237
- /**
5238
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
5239
- */
5240
4642
  var EngineExecutionLimitsPolicy = class {
5241
4643
  constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
5242
4644
  this.config = config;
5243
4645
  }
5244
- /**
5245
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
5246
- * Replaces a separate one-method factory for root-run bootstrap.
5247
- */
5248
4646
  createRootExecutionOptions() {
5249
4647
  return this.mergeExecutionOptionsForNewRun(void 0, void 0);
5250
4648
  }
@@ -5472,10 +4870,6 @@ var InMemoryRunDataFactory = class {
5472
4870
 
5473
4871
  //#endregion
5474
4872
  //#region src/triggers/polling/PollingTriggerDedupWindow.ts
5475
- /**
5476
- * Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
5477
- * Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
5478
- */
5479
4873
  var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
5480
4874
  static defaultCapN = 2e3;
5481
4875
  merge(previous, incoming, capN = PollingTriggerDedupWindow.defaultCapN) {
@@ -5489,11 +4883,6 @@ var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
5489
4883
 
5490
4884
  //#endregion
5491
4885
  //#region src/triggers/polling/PollingTriggerRuntime.ts
5492
- /**
5493
- * Generic polling-trigger runtime. Owns the set-interval loop, overlap guard, and persistence.
5494
- * Constructed by {@link import("../../runtime/EngineFactory").EngineFactory} and exposed to plugin
5495
- * authors via {@link import("../../contracts/runtimeTypes").TriggerSetupContext}.polling.
5496
- */
5497
4886
  var PollingTriggerRuntime = class {
5498
4887
  activeTriggers = /* @__PURE__ */ new Set();
5499
4888
  intervalsByTrigger = /* @__PURE__ */ new Map();
@@ -5595,7 +4984,7 @@ var NoOpPollingTriggerLogger = class {
5595
4984
  //#endregion
5596
4985
  //#region src/orchestration/NodeExecutionRequestHandlerService.ts
5597
4986
  var NodeExecutionRequestHandlerService = class {
5598
- constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy) {
4987
+ constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy, parityGuard) {
5599
4988
  this.workflowExecutionRepository = workflowExecutionRepository;
5600
4989
  this.workflowSnapshotResolver = workflowSnapshotResolver;
5601
4990
  this.runDataFactory = runDataFactory;
@@ -5605,6 +4994,7 @@ var NodeExecutionRequestHandlerService = class {
5605
4994
  this.nodeExecutor = nodeExecutor;
5606
4995
  this.continuation = continuation;
5607
4996
  this.executionLimitsPolicy = executionLimitsPolicy;
4997
+ this.parityGuard = parityGuard;
5608
4998
  }
5609
4999
  async handleNodeExecutionRequest(request) {
5610
5000
  const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(request.runId), this.workflowExecutionRepository.loadSchedulingState(request.runId)]);
@@ -5688,6 +5078,7 @@ var NodeExecutionRequestHandlerService = class {
5688
5078
  });
5689
5079
  let outputs;
5690
5080
  try {
5081
+ this.parityGuard.assertNone(workflow, [request.nodeId]);
5691
5082
  outputs = await this.nodeExecutor.execute(activationRequest);
5692
5083
  } catch (error) {
5693
5084
  if (error instanceof RunSuspendedError) return;
@@ -5862,12 +5253,6 @@ var RunQueuePlanner = class {
5862
5253
  const received = queueEntry.collect.received;
5863
5254
  for (const input of queueEntry.collect.expectedInputs ?? []) if (!(input in received)) received[input] = [];
5864
5255
  }
5865
- /**
5866
- * Matches `CurrentStateFrontierPlanner.buildFrontierQueue`: anything that is not exactly one input
5867
- * port named `in` participates in multi-port collect (Merge after `If` branches, etc.). Routing must
5868
- * not depend solely on `nodeInstances.get(toNodeId)?.executeMulti`, or a Merge can be enqueued as a
5869
- * single-input job and `NodeExecutor` will call `execute` on a multi-input-only implementation.
5870
- */
5871
5256
  usesTopologyCollectMerge(toNodeId) {
5872
5257
  const expectedInputs = this.topology.expectedInputsByNode.get(toNodeId) ?? [];
5873
5258
  if (expectedInputs.length !== 1 || expectedInputs[0] !== "in") return true;
@@ -6267,11 +5652,6 @@ var EngineWaiters = class {
6267
5652
 
6268
5653
  //#endregion
6269
5654
  //#region src/orchestration/Engine.ts
6270
- /**
6271
- * Runtime facade for orchestration, continuation, triggers, and webhook routing.
6272
- * Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
6273
- * The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
6274
- */
6275
5655
  var Engine = class {
6276
5656
  constructor(deps) {
6277
5657
  this.deps = deps;
@@ -6345,10 +5725,6 @@ var Engine = class {
6345
5725
  async waitForWebhookResponse(runId) {
6346
5726
  return await this.deps.runContinuationService.waitForWebhookResponse(runId);
6347
5727
  }
6348
- /**
6349
- * Re-activate a suspended run item with a human decision (HITL).
6350
- * The HTTP resume endpoint calls this; this method exposes the engine primitive.
6351
- */
6352
5728
  async resumeRun(args) {
6353
5729
  return await this.deps.runContinuationService.resumeRun(args);
6354
5730
  }
@@ -6359,11 +5735,6 @@ var Engine = class {
6359
5735
 
6360
5736
  //#endregion
6361
5737
  //#region src/runtime/EngineFactory.ts
6362
- /**
6363
- * Composes the {@link Engine} graph from {@link EngineCompositionDeps}. Production wiring usually goes through
6364
- * {@link import("../bootstrap/runtime/EngineRuntimeRegistrar").EngineRuntimeRegistrar}; this factory remains for tests and custom composition.
6365
- * Exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
6366
- */
6367
5738
  var EngineFactory = class {
6368
5739
  create(deps) {
6369
5740
  const waiters = new EngineWaiters();
@@ -6372,10 +5743,12 @@ var EngineFactory = class {
6372
5743
  const nodeStatePublisherFactory = new NodeRunStateWriterFactory(deps.workflowExecutionRepository, nodeEventPublisher, deps.eventBus);
6373
5744
  const planningFactory = new EngineWorkflowPlanningFactory(deps.workflowNodeInstanceFactory);
6374
5745
  const executionLimitsPolicy = deps.executionLimitsPolicy ?? new EngineExecutionLimitsPolicy();
6375
- const workflowSnapshotCodec = deps.workflowSnapshotCodec ?? new WorkflowSnapshotCodec(deps.tokenRegistry);
5746
+ const workflowSnapshotCodec = deps.workflowSnapshotCodec ?? new require_contracts.WorkflowSnapshotCodec(deps.tokenRegistry);
6376
5747
  const missingRuntimeFallbacks = deps.missingRuntimeFallbacks ?? new MissingRuntimeFallbacks();
6377
5748
  const workflowSnapshotResolver = new WorkflowSnapshotResolver(deps.workflowRepository, deps.tokenRegistry, workflowSnapshotCodec, missingRuntimeFallbacks);
6378
- const semantics = new RunStateSemantics(new MissingRuntimeExecutionMarker());
5749
+ const missingRuntimeExecutionMarker = new MissingRuntimeExecutionMarker();
5750
+ const semantics = new RunStateSemantics(missingRuntimeExecutionMarker);
5751
+ const parityGuard = new MissingRuntimeParityGuard(missingRuntimeExecutionMarker);
6379
5752
  const nodeActivationRequestInputPreparer = new NodeActivationRequestInputPreparer(deps.workflowNodeInstanceFactory);
6380
5753
  const activationEnqueueService = new ActivationEnqueueService(deps.activationScheduler, deps.workflowExecutionRepository, nodeEventPublisher, nodeActivationRequestInputPreparer);
6381
5754
  const runExecutionContextFactory = new WorkflowRunExecutionContextFactory(deps.executionContextFactory, credentialResolverFactory);
@@ -6385,8 +5758,8 @@ var EngineFactory = class {
6385
5758
  const terminalPersistence = new RunTerminalPersistenceCoordinator(deps.workflowExecutionRepository, storagePolicyEvaluator);
6386
5759
  const policyErrorServices = new WorkflowPolicyErrorServices(deps.nodeResolver);
6387
5760
  const runStartService = new RunStartService(deps.runIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, workflowSnapshotCodec, planningFactory, nodeStatePublisherFactory, runExecutionContextFactory, nodeActivationRequestComposer, activationEnqueueService, semantics, waiters, deps.workflowPolicyRuntimeDefaults, executionLimitsPolicy, nodeEventPublisher, persistedRunStateTerminalBuilder);
6388
- const runContinuationService = new RunContinuationService(deps.activationIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy);
6389
- const nodeExecutionRequestHandler = new NodeExecutionRequestHandlerService(deps.workflowExecutionRepository, workflowSnapshotResolver, deps.runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, deps.nodeExecutor, runContinuationService, executionLimitsPolicy);
5761
+ 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);
5762
+ const nodeExecutionRequestHandler = new NodeExecutionRequestHandlerService(deps.workflowExecutionRepository, workflowSnapshotResolver, deps.runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, deps.nodeExecutor, runContinuationService, executionLimitsPolicy, parityGuard);
6390
5763
  const pollingTriggerLogger = deps.pollingTriggerLogger ?? new NoOpPollingTriggerLogger();
6391
5764
  const pollingTriggerDedupWindow = new PollingTriggerDedupWindow();
6392
5765
  const pollingTriggerRuntime = new PollingTriggerRuntime(deps.triggerSetupStateRepository, pollingTriggerLogger);
@@ -6569,10 +5942,6 @@ var RunIntentService = class {
6569
5942
  };
6570
5943
  })]);
6571
5944
  }
6572
- /**
6573
- * Webhook-triggered runs always force inline execution first.
6574
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
6575
- */
6576
5945
  createWebhookExecutionOptions() {
6577
5946
  return {
6578
5947
  localOnly: true,
@@ -6591,10 +5960,6 @@ var RunIntentServiceFactory = class {
6591
5960
 
6592
5961
  //#endregion
6593
5962
  //#region src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts
6594
- /**
6595
- * Resolves webhook HTTP routes from the live workflow repository (no trigger setup / registration).
6596
- * Maintains an in-memory index keyed by user-defined endpoint path for O(1) lookups after reload.
6597
- */
6598
5963
  var WorkflowRepositoryWebhookTriggerMatcher = class {
6599
5964
  routeByPath = /* @__PURE__ */ new Map();
6600
5965
  engineRoutesActive = false;
@@ -6900,12 +6265,6 @@ Object.defineProperty(exports, 'InProcessRetryRunnerFactory', {
6900
6265
  return InProcessRetryRunnerFactory;
6901
6266
  }
6902
6267
  });
6903
- Object.defineProperty(exports, 'InjectableRuntimeDecoratorComposer', {
6904
- enumerable: true,
6905
- get: function () {
6906
- return InjectableRuntimeDecoratorComposer;
6907
- }
6908
- });
6909
6268
  Object.defineProperty(exports, 'InlineDrivingScheduler', {
6910
6269
  enumerable: true,
6911
6270
  get: function () {
@@ -6924,6 +6283,12 @@ Object.defineProperty(exports, 'LocalOnlyScheduler', {
6924
6283
  return LocalOnlyScheduler;
6925
6284
  }
6926
6285
  });
6286
+ Object.defineProperty(exports, 'MissingRuntimeParityGuard', {
6287
+ enumerable: true,
6288
+ get: function () {
6289
+ return MissingRuntimeParityGuard;
6290
+ }
6291
+ });
6927
6292
  Object.defineProperty(exports, 'MissingRuntimeTriggerToken', {
6928
6293
  enumerable: true,
6929
6294
  get: function () {
@@ -7026,24 +6391,6 @@ Object.defineProperty(exports, 'NodeOutputNormalizer', {
7026
6391
  return NodeOutputNormalizer;
7027
6392
  }
7028
6393
  });
7029
- Object.defineProperty(exports, 'PersistedRuntimeTypeMetadataStore', {
7030
- enumerable: true,
7031
- get: function () {
7032
- return PersistedRuntimeTypeMetadataStore;
7033
- }
7034
- });
7035
- Object.defineProperty(exports, 'PersistedRuntimeTypeNameResolver', {
7036
- enumerable: true,
7037
- get: function () {
7038
- return PersistedRuntimeTypeNameResolver;
7039
- }
7040
- });
7041
- Object.defineProperty(exports, 'PersistedWorkflowTokenRegistry', {
7042
- enumerable: true,
7043
- get: function () {
7044
- return PersistedWorkflowTokenRegistry;
7045
- }
7046
- });
7047
6394
  Object.defineProperty(exports, 'PollingTriggerDedupWindow', {
7048
6395
  enumerable: true,
7049
6396
  get: function () {
@@ -7098,12 +6445,6 @@ Object.defineProperty(exports, 'RunnableOutputBehaviorResolver', {
7098
6445
  return RunnableOutputBehaviorResolver;
7099
6446
  }
7100
6447
  });
7101
- Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
7102
- enumerable: true,
7103
- get: function () {
7104
- return StackTraceCallSitePathResolver;
7105
- }
7106
- });
7107
6448
  Object.defineProperty(exports, 'StaticCostCatalog', {
7108
6449
  enumerable: true,
7109
6450
  get: function () {
@@ -7146,6 +6487,12 @@ Object.defineProperty(exports, 'WorkflowExecutableNodeClassifierFactory', {
7146
6487
  return WorkflowExecutableNodeClassifierFactory;
7147
6488
  }
7148
6489
  });
6490
+ Object.defineProperty(exports, 'WorkflowParityMismatchError', {
6491
+ enumerable: true,
6492
+ get: function () {
6493
+ return WorkflowParityMismatchError;
6494
+ }
6495
+ });
7149
6496
  Object.defineProperty(exports, 'WorkflowPolicyErrorServices', {
7150
6497
  enumerable: true,
7151
6498
  get: function () {
@@ -7164,24 +6511,12 @@ Object.defineProperty(exports, 'WorkflowRepositoryWebhookTriggerMatcherFactory',
7164
6511
  return WorkflowRepositoryWebhookTriggerMatcherFactory;
7165
6512
  }
7166
6513
  });
7167
- Object.defineProperty(exports, 'WorkflowSnapshotCodec', {
7168
- enumerable: true,
7169
- get: function () {
7170
- return WorkflowSnapshotCodec;
7171
- }
7172
- });
7173
6514
  Object.defineProperty(exports, 'WorkflowStoragePolicyEvaluator', {
7174
6515
  enumerable: true,
7175
6516
  get: function () {
7176
6517
  return WorkflowStoragePolicyEvaluator;
7177
6518
  }
7178
6519
  });
7179
- Object.defineProperty(exports, 'chatModel', {
7180
- enumerable: true,
7181
- get: function () {
7182
- return chatModel;
7183
- }
7184
- });
7185
6520
  Object.defineProperty(exports, 'defineBatchNode', {
7186
6521
  enumerable: true,
7187
6522
  get: function () {
@@ -7212,12 +6547,6 @@ Object.defineProperty(exports, 'getOriginIndexFromItem', {
7212
6547
  return getOriginIndexFromItem;
7213
6548
  }
7214
6549
  });
7215
- Object.defineProperty(exports, 'getPersistedRuntimeTypeMetadata', {
7216
- enumerable: true,
7217
- get: function () {
7218
- return getPersistedRuntimeTypeMetadata;
7219
- }
7220
- });
7221
6550
  Object.defineProperty(exports, 'isHumanApprovalNode', {
7222
6551
  enumerable: true,
7223
6552
  get: function () {
@@ -7242,16 +6571,4 @@ Object.defineProperty(exports, 'mergeForward', {
7242
6571
  return mergeForward;
7243
6572
  }
7244
6573
  });
7245
- Object.defineProperty(exports, 'node', {
7246
- enumerable: true,
7247
- get: function () {
7248
- return node;
7249
- }
7250
- });
7251
- Object.defineProperty(exports, 'tool', {
7252
- enumerable: true,
7253
- get: function () {
7254
- return tool;
7255
- }
7256
- });
7257
- //# sourceMappingURL=runtime-n2tqRwaf.cjs.map
6574
+ //# sourceMappingURL=runtime-Due-FOZ2.cjs.map