@codemation/core 0.13.2 → 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.
- package/CHANGELOG.md +167 -0
- package/dist/{CostCatalogContract-Dxq1BTyi.d.cts → CostCatalogContract-Dwo-ZamG.d.cts} +2 -2
- package/dist/EngineRuntimeRegistration.types-BiNasx3G.d.cts +54 -0
- package/dist/EngineRuntimeRegistration.types-Dq4ucrdo.d.ts +21 -0
- package/dist/{InMemoryRunDataFactory-Csy2evr_.d.cts → InMemoryRunDataFactory-D2U9azmZ.d.cts} +4 -20
- package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs.map} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js → InMemoryRunEventBusRegistry-Layt2xgm.js} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js.map → InMemoryRunEventBusRegistry-Layt2xgm.js.map} +1 -1
- package/dist/{ItemsInputNormalizer-Bi8m-Ijs.d.cts → ItemsInputNormalizer-A5txcOWX.d.cts} +3 -98
- package/dist/{ItemsInputNormalizer-BbQTSEkZ.cjs → ItemsInputNormalizer-C1fv3sMW.cjs} +2 -2
- package/dist/ItemsInputNormalizer-C1fv3sMW.cjs.map +1 -0
- package/dist/{ItemsInputNormalizer-BYljnXU0.d.ts → ItemsInputNormalizer-D2vrMrX1.d.ts} +2 -62
- package/dist/{ItemsInputNormalizer-CSZGMgl3.js → ItemsInputNormalizer-fUYo4GLV.js} +2 -2
- package/dist/ItemsInputNormalizer-fUYo4GLV.js.map +1 -0
- package/dist/{RunIntentService-BitgkKaT.d.cts → RunIntentService-DKxuHTUz.d.cts} +2 -15
- package/dist/{RunIntentService-DYpqfu6D.d.ts → RunIntentService-DrpKli2k.d.ts} +2 -22
- package/dist/{agentMcpTypes-DGIwk6Ue.d.cts → agentMcpTypes-BHX4RQCC.d.cts} +25 -518
- package/dist/bootstrap/index.cjs +9 -5
- package/dist/bootstrap/index.d.cts +32 -106
- package/dist/bootstrap/index.d.ts +18 -17
- package/dist/bootstrap/index.js +6 -5
- package/dist/{bootstrap-DIv-vloi.cjs → bootstrap-CTB53rEF.cjs} +9 -60
- package/dist/bootstrap-CTB53rEF.cjs.map +1 -0
- package/dist/{bootstrap-Bkd-Nfbn.js → bootstrap-DmqKheCI.js} +6 -57
- package/dist/bootstrap-DmqKheCI.js.map +1 -0
- package/dist/browser.cjs +12 -11
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +3 -2
- package/dist/contracts-7L1wJHdk.cjs +569 -0
- package/dist/contracts-7L1wJHdk.cjs.map +1 -0
- package/dist/contracts-CjJ5CZ7N.js +447 -0
- package/dist/contracts-CjJ5CZ7N.js.map +1 -0
- package/dist/contracts.cjs +9 -2
- package/dist/contracts.d.cts +5 -5
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.js +3 -2
- package/dist/{executionPersistenceContracts-CN9d7AnL.d.cts → deploymentManifestTypes-B8CDmZZK.d.cts} +65 -81
- package/dist/di-C6Ubf9o5.cjs +179 -0
- package/dist/di-C6Ubf9o5.cjs.map +1 -0
- package/dist/di-Cjiil7U-.js +114 -0
- package/dist/di-Cjiil7U-.js.map +1 -0
- package/dist/{index-rllWL4r-.d.ts → index-CRv3_pY3.d.ts} +112 -808
- package/dist/{index-BSQ2LoIh.d.ts → index-mnLS0iQl.d.ts} +39 -372
- package/dist/index.cjs +53 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -438
- package/dist/index.d.ts +5 -5
- package/dist/index.js +28 -94
- package/dist/index.js.map +1 -1
- package/dist/{params-DRUr0F5v.d.cts → params-CrK4iuG1.d.cts} +3 -13
- package/dist/{runtime-CWPdvJpC.js → runtime-CBFDpmiz.js} +112 -648
- package/dist/runtime-CBFDpmiz.js.map +1 -0
- package/dist/{runtime-_VdHwGkJ.cjs → runtime-Due-FOZ2.cjs} +137 -717
- package/dist/runtime-Due-FOZ2.cjs.map +1 -0
- package/dist/testing.cjs +8 -40
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +3 -32
- package/dist/testing.d.ts +3 -32
- package/dist/testing.js +6 -38
- package/dist/testing.js.map +1 -1
- package/dist/{di-LP2qSHkY.cjs → workflowTypes-BW6Hhee7.cjs} +4 -230
- package/dist/workflowTypes-BW6Hhee7.cjs.map +1 -0
- package/dist/{di-tom0pM2h.js → workflowTypes-DZtBTmKf.js} +3 -163
- package/dist/workflowTypes-DZtBTmKf.js.map +1 -0
- package/package.json +1 -1
- package/src/ai/AgentConnectionNodeCollector.ts +0 -4
- package/src/ai/AgentMessageConfigNormalizerFactory.ts +0 -4
- package/src/ai/AiHost.ts +0 -38
- package/src/ai/CallableToolConfig.ts +0 -9
- package/src/ai/CallableToolKindToken.ts +0 -4
- package/src/authoring/callableTool.types.ts +0 -3
- package/src/authoring/defineCollection.types.ts +0 -11
- package/src/authoring/defineHumanApprovalNode.types.ts +0 -116
- package/src/authoring/defineNode.types.ts +18 -32
- package/src/authoring/definePollingTrigger.types.ts +36 -155
- package/src/authoring/definePollingTriggerInternals.ts +0 -4
- package/src/authoring/index.ts +1 -0
- package/src/authoring/nodeBaseOptions.types.ts +4 -0
- package/src/binaries/boundedReadBinary.types.ts +0 -16
- package/src/bootstrap/index.ts +8 -2
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +0 -5
- package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +0 -23
- package/src/browser.ts +0 -3
- package/src/contracts/AgentBindError.ts +0 -5
- package/src/contracts/Clock.ts +0 -1
- package/src/contracts/CodemationTelemetryAttributeNames.ts +0 -10
- package/src/contracts/NoOpAgentMcpIntegration.ts +0 -6
- package/src/contracts/NoOpTelemetrySpanScope.ts +0 -7
- package/src/contracts/RetryPolicy.ts +0 -2
- package/src/contracts/agentMcpTypes.ts +0 -34
- package/src/contracts/assertionTypes.ts +0 -33
- package/src/contracts/baseTypes.ts +0 -6
- package/src/contracts/collectionTypes.ts +0 -25
- package/src/contracts/credentialTypes.ts +13 -60
- package/src/contracts/deploymentManifestTypes.ts +158 -0
- package/src/contracts/dispatchTypes.ts +29 -0
- package/src/contracts/executionPersistenceContracts.ts +0 -33
- package/src/contracts/hitlSeamTypes.ts +0 -14
- package/src/contracts/humanTaskStoreTypes.ts +0 -2
- package/src/contracts/inboxChannelTypes.ts +0 -9
- package/src/contracts/index.ts +3 -0
- package/src/contracts/itemExpr.ts +7 -21
- package/src/contracts/itemMeta.ts +0 -3
- package/src/contracts/mcpTypes.ts +0 -16
- package/src/contracts/retryPolicySpec.types.ts +0 -10
- package/src/contracts/runFinishedAtFactory.ts +0 -1
- package/src/contracts/runTypes.ts +0 -74
- package/src/contracts/runtimeTypes.ts +4 -131
- package/src/contracts/telemetryTypes.ts +0 -7
- package/src/contracts/testTriggerTypes.ts +0 -43
- package/src/contracts/triggerInvokerTypes.ts +6 -0
- package/src/contracts/webhookTypes.ts +0 -8
- package/src/contracts/workflowActivationPolicy.ts +0 -5
- package/src/contracts/workflowTypes.ts +5 -80
- package/src/contracts/workspaceFileTypes.ts +10 -42
- package/src/contracts.ts +18 -10
- package/src/credentials/CredentialMaterialProvider.types.ts +0 -28
- package/src/credentials/ManagedCredentialMaterialWriteError.ts +0 -6
- package/src/credentials/ManagedMaterialFetchError.ts +0 -6
- package/src/credentials/OAuthFlowExecutor.types.ts +0 -15
- package/src/di/CoreTokens.ts +2 -6
- package/src/events/ConnectionInvocationEventPublisher.ts +0 -7
- package/src/events/NodeEventPublisher.ts +0 -1
- package/src/events/runEvents.ts +0 -8
- package/src/execution/ActivationEnqueueService.ts +0 -10
- package/src/execution/ChildExecutionScopeFactory.ts +0 -13
- package/src/execution/FanInMergeByOriginMerger.ts +0 -11
- package/src/execution/InProcessRetryRunner.ts +0 -1
- package/src/execution/ItemExprResolver.ts +0 -3
- package/src/execution/NodeActivationRequestComposer.ts +0 -3
- package/src/execution/NodeActivationRequestInputPreparer.ts +0 -5
- package/src/execution/NodeExecutionSnapshotFactory.ts +0 -1
- package/src/execution/NodeExecutor.ts +1 -17
- package/src/execution/NodeOutputNormalizer.ts +8 -1
- package/src/execution/NodeSuspensionHandler.ts +1 -39
- package/src/execution/PersistedRunStateTerminalBuilder.ts +0 -5
- package/src/execution/RunSuspendedError.ts +0 -10
- package/src/execution/RunnableOutputBehaviorResolver.ts +12 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +0 -3
- package/src/index.ts +10 -2
- package/src/orchestration/AbortControllerFactory.ts +0 -4
- package/src/orchestration/Engine.ts +0 -9
- package/src/orchestration/NodeExecutionRequestHandlerService.ts +3 -4
- package/src/orchestration/RunContinuationService.ts +7 -39
- package/src/orchestration/RunStartService.ts +0 -7
- package/src/orchestration/TestSuiteOrchestrator.ts +0 -18
- package/src/orchestration/TestSuiteRunIdFactory.ts +0 -4
- package/src/orchestration/TriggerRuntimeService.ts +3 -2
- package/src/planning/CurrentStateFrontierPlanner.ts +0 -1
- package/src/planning/RunQueuePlanner.ts +0 -6
- package/src/policies/executionLimits/EngineExecutionLimitsPolicy.ts +0 -8
- package/src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.ts +0 -3
- package/src/runStorage/RunSummaryMapper.ts +0 -1
- package/src/runtime/EngineFactory.ts +6 -11
- package/src/runtime/RunIntentService.ts +0 -4
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts +0 -4
- package/src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts +0 -4
- package/src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts +0 -4
- package/src/runtime-types/PersistedRuntimeTypeNameResolver.ts +0 -1
- package/src/runtime-types/persistedRuntimeTypeModelRegistry.ts +0 -4
- package/src/runtime-types/runtimeTypeDecorators.types.ts +0 -12
- package/src/scheduler/ConfigDrivenOffloadPolicy.ts +0 -1
- package/src/scheduler/DefaultDrivingScheduler.ts +0 -6
- package/src/scheduler/InlineDrivingScheduler.ts +0 -13
- package/src/serialization/ItemsInputNormalizer.ts +0 -5
- package/src/testing/CapturingScheduler.ts +0 -3
- package/src/testing/EngineTestKitRunIdFactory.ts +0 -3
- package/src/testing/ItemHarnessNode.ts +0 -3
- package/src/testing/ItemHarnessNodeConfig.ts +0 -4
- package/src/testing/PrefixedSequentialIdGenerator.ts +0 -3
- package/src/testing/RegistrarEngineTestKit.types.ts +0 -2
- package/src/testing/RejectingCredentialSessionService.ts +0 -4
- package/src/testing/SubWorkflowRunnerTestNode.ts +0 -3
- package/src/testing/WorkflowTestHarnessManualTrigger.ts +0 -3
- package/src/testing/WorkflowTestKitBuilder.ts +0 -4
- package/src/testing/WorkflowTestKitRunNodeWorkflowFactory.ts +0 -3
- package/src/testing.ts +0 -3
- package/src/triggers/polling/PollingTriggerDedupWindow.ts +0 -4
- package/src/triggers/polling/PollingTriggerLogger.ts +0 -5
- package/src/triggers/polling/PollingTriggerRuntime.ts +0 -5
- package/src/types/index.ts +0 -6
- package/src/validation/WorkflowEdgePortValidator.ts +0 -5
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +0 -7
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +0 -6
- package/src/workflow/definition/NodeIterationIdFactory.ts +0 -13
- package/src/workflow/definition/WorkflowExecutableNodeClassifier.ts +0 -6
- package/src/workflow/dsl/ChainCursorResolver.ts +8 -15
- package/src/workflow/dsl/NodeIdSlugifier.ts +0 -9
- package/src/workflow/dsl/WhenBuilder.ts +49 -2
- package/src/workflow/dsl/WorkflowDefinitionError.ts +0 -9
- package/src/workflow/dsl/workflowBuilderTypes.ts +5 -0
- package/src/workflowSnapshots/MissingRuntimeParityGuard.ts +24 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts +0 -6
- package/src/workflowSnapshots/WorkflowParityMismatchError.ts +18 -0
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +1 -5
- package/src/workflowSnapshots/index.ts +3 -0
- package/dist/EngineRuntimeRegistration.types-CqcTWexS.d.cts +0 -81
- package/dist/EngineRuntimeRegistration.types-Cr75cSfL.d.ts +0 -44
- package/dist/ItemsInputNormalizer-BbQTSEkZ.cjs.map +0 -1
- package/dist/ItemsInputNormalizer-CSZGMgl3.js.map +0 -1
- package/dist/bootstrap-Bkd-Nfbn.js.map +0 -1
- package/dist/bootstrap-DIv-vloi.cjs.map +0 -1
- package/dist/contracts-CK0x6w_G.cjs +0 -74
- package/dist/contracts-CK0x6w_G.cjs.map +0 -1
- package/dist/contracts-DXdfTdpW.js +0 -50
- package/dist/contracts-DXdfTdpW.js.map +0 -1
- package/dist/di-LP2qSHkY.cjs.map +0 -1
- package/dist/di-tom0pM2h.js.map +0 -1
- package/dist/runtime-CWPdvJpC.js.map +0 -1
- package/dist/runtime-_VdHwGkJ.cjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const require_di = require('./di-
|
|
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,16 +89,20 @@ 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;
|
|
211
96
|
icon = options.icon;
|
|
212
97
|
inputSchema = options.inputSchema;
|
|
213
98
|
keepBinaries = options.keepBinaries ?? false;
|
|
214
|
-
|
|
99
|
+
id;
|
|
100
|
+
description;
|
|
101
|
+
constructor(name, config, idOrOptions) {
|
|
215
102
|
this.name = name;
|
|
216
|
-
|
|
103
|
+
const resolved = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
|
|
104
|
+
this.id = resolved?.id;
|
|
105
|
+
this.description = resolved?.description;
|
|
217
106
|
this.config = config;
|
|
218
107
|
}
|
|
219
108
|
config;
|
|
@@ -229,8 +118,8 @@ function defineNode(options) {
|
|
|
229
118
|
key: options.key,
|
|
230
119
|
title: options.title,
|
|
231
120
|
description: options.description,
|
|
232
|
-
create(config, name = options.title,
|
|
233
|
-
return new DefinedRunnableNodeConfig(name, config,
|
|
121
|
+
create(config, name = options.title, idOrOptions) {
|
|
122
|
+
return new DefinedRunnableNodeConfig(name, config, idOrOptions);
|
|
234
123
|
},
|
|
235
124
|
register(context) {
|
|
236
125
|
context.registerNode(DefinedNodeRuntime);
|
|
@@ -255,14 +144,18 @@ function defineBatchNode(options) {
|
|
|
255
144
|
return [...await options.run(args.items.map((item) => item.json), context)];
|
|
256
145
|
}
|
|
257
146
|
};
|
|
258
|
-
node({ name: options.key })(DefinedNodeRuntime);
|
|
147
|
+
require_contracts.node({ name: options.key })(DefinedNodeRuntime);
|
|
259
148
|
const DefinedRunnableNodeConfig = class {
|
|
260
149
|
kind = "node";
|
|
261
150
|
type = DefinedNodeRuntime;
|
|
262
151
|
icon = options.icon;
|
|
263
|
-
|
|
152
|
+
id;
|
|
153
|
+
description;
|
|
154
|
+
constructor(name, config, idOrOptions) {
|
|
264
155
|
this.name = name;
|
|
265
|
-
|
|
156
|
+
const resolved = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
|
|
157
|
+
this.id = resolved?.id;
|
|
158
|
+
this.description = resolved?.description;
|
|
266
159
|
this.config = config;
|
|
267
160
|
}
|
|
268
161
|
config;
|
|
@@ -278,8 +171,8 @@ function defineBatchNode(options) {
|
|
|
278
171
|
key: options.key,
|
|
279
172
|
title: options.title,
|
|
280
173
|
description: options.description,
|
|
281
|
-
create(config, name = options.title,
|
|
282
|
-
return new DefinedRunnableNodeConfig(name, config,
|
|
174
|
+
create(config, name = options.title, idOrOptions) {
|
|
175
|
+
return new DefinedRunnableNodeConfig(name, config, idOrOptions);
|
|
283
176
|
},
|
|
284
177
|
register(context) {
|
|
285
178
|
context.registerNode(DefinedNodeRuntime);
|
|
@@ -291,60 +184,9 @@ function defineBatchNode(options) {
|
|
|
291
184
|
|
|
292
185
|
//#endregion
|
|
293
186
|
//#region src/authoring/defineHumanApprovalNode.types.ts
|
|
294
|
-
/**
|
|
295
|
-
* Returns `true` when `node` was created by {@link defineHumanApprovalNode}.
|
|
296
|
-
* Uses the `humanApprovalToolBehavior` typed field as the discriminant.
|
|
297
|
-
*/
|
|
298
187
|
function isHumanApprovalNode(node$1) {
|
|
299
188
|
return typeof node$1 === "object" && node$1 !== null && "humanApprovalToolBehavior" in node$1 && typeof node$1.humanApprovalToolBehavior === "object";
|
|
300
189
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Authoring helper that compiles a HITL approval channel down to a regular
|
|
303
|
-
* {@link defineNode}-backed node with `SuspensionRequest` semantics.
|
|
304
|
-
*
|
|
305
|
-
* **Fast-forward decision semantics:**
|
|
306
|
-
* - On the first `execute` call (no `ctx.resumeContext`): throws a `SuspensionRequest`
|
|
307
|
-
* that calls the author's `deliver`. The engine persists the suspension and continues.
|
|
308
|
-
* - On resume (`ctx.resumeContext` set): calls `onDecision`/`onTimeout` as appropriate,
|
|
309
|
-
* merges a `decision` key into `item.json`, and returns an item with the original
|
|
310
|
-
* `binary` map passed by reference (no copy).
|
|
311
|
-
*
|
|
312
|
-
* **Output shape per item:**
|
|
313
|
-
* ```ts
|
|
314
|
-
* // Input: { json: { invoiceId: 42 }, binary?: {...} }
|
|
315
|
-
* // Output: { json: { invoiceId: 42, decision: { status: "approved", actor, decidedAt } }, binary: <unchanged> }
|
|
316
|
-
* ```
|
|
317
|
-
* If `item.json` already has a `decision` key it is **overwritten**. Namespace as
|
|
318
|
-
* needed if your schema reserves that key for another purpose.
|
|
319
|
-
*
|
|
320
|
-
* **Predicate persistence:**
|
|
321
|
-
* The `approvedPredicate` function is NOT serialized to the suspension record (except
|
|
322
|
-
* as an audit-only string via `toString()`). On resume, the workflow definition is
|
|
323
|
-
* reloaded from code at process start and the predicate closure is rebuilt naturally.
|
|
324
|
-
* If a deploy ships a changed predicate between suspend and resume, the *new* predicate
|
|
325
|
-
* runs — document this in your runbook when the predicate carries business logic that
|
|
326
|
-
* may change across deploys.
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* ```ts
|
|
330
|
-
* export const slackApprovalNode = defineHumanApprovalNode({
|
|
331
|
-
* key: "my-plugin.slackApproval",
|
|
332
|
-
* title: "Slack Approval",
|
|
333
|
-
* channel: "slack",
|
|
334
|
-
* configSchema: z.object({ channel: z.string(), message: z.string() }),
|
|
335
|
-
* decisionSchema: z.object({ approved: z.boolean(), note: z.string().optional() }),
|
|
336
|
-
*
|
|
337
|
-
* async deliver({ task, config, item }, ctx) {
|
|
338
|
-
* const ts = await postSlackMessage(config.channel, `Approve? <${task.resumeUrl}>`);
|
|
339
|
-
* return { channel: config.channel, ts };
|
|
340
|
-
* },
|
|
341
|
-
*
|
|
342
|
-
* async onDecision({ decision, actor, delivery }, ctx) {
|
|
343
|
-
* await updateSlackMessage(delivery.channel, delivery.ts, decision.approved ? "✅" : "❌");
|
|
344
|
-
* },
|
|
345
|
-
* });
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
190
|
function defineHumanApprovalNode(opts) {
|
|
349
191
|
const resolvedPredicate = resolveApprovedPredicate(opts.decisionSchema, opts.approvedPredicate);
|
|
350
192
|
const timeout = opts.defaultTimeout ?? "24h";
|
|
@@ -361,7 +203,7 @@ function defineHumanApprovalNode(opts) {
|
|
|
361
203
|
async execute(args, { config, execution: ctx }) {
|
|
362
204
|
if (!ctx.resumeContext) {
|
|
363
205
|
const subject = buildSubject(opts.title, args.item, ctx);
|
|
364
|
-
throw new
|
|
206
|
+
throw new require_workflowTypes.SuspensionRequest({
|
|
365
207
|
decisionSchema: opts.decisionSchema,
|
|
366
208
|
timeout,
|
|
367
209
|
onTimeout,
|
|
@@ -446,10 +288,12 @@ async function handleResume(item, resumeContext, decisionSchema, resolvedPredica
|
|
|
446
288
|
//#endregion
|
|
447
289
|
//#region src/workflow/dsl/WhenBuilder.ts
|
|
448
290
|
var WhenBuilder = class WhenBuilder {
|
|
449
|
-
|
|
291
|
+
armEndpoint;
|
|
292
|
+
constructor(wf, from, branchPort, priorEndpoints = []) {
|
|
450
293
|
this.wf = wf;
|
|
451
294
|
this.from = from;
|
|
452
295
|
this.branchPort = branchPort;
|
|
296
|
+
this.priorEndpoints = priorEndpoints;
|
|
453
297
|
}
|
|
454
298
|
addBranch(steps) {
|
|
455
299
|
const created = [];
|
|
@@ -470,20 +314,48 @@ var WhenBuilder = class WhenBuilder {
|
|
|
470
314
|
return nodeId ? { nodeId } : { nodeId: r };
|
|
471
315
|
});
|
|
472
316
|
}
|
|
317
|
+
this.armEndpoint = prev ? {
|
|
318
|
+
node: prev,
|
|
319
|
+
output: "main",
|
|
320
|
+
inputPortHint: this.branchPort
|
|
321
|
+
} : {
|
|
322
|
+
node: this.from,
|
|
323
|
+
output: this.branchPort,
|
|
324
|
+
inputPortHint: this.branchPort
|
|
325
|
+
};
|
|
473
326
|
return this;
|
|
474
327
|
}
|
|
475
328
|
when = (branch, steps, ...more) => {
|
|
476
329
|
const list = Array.isArray(steps) ? steps : [steps, ...more];
|
|
477
330
|
const port = branch ? "true" : "false";
|
|
478
|
-
const b = new WhenBuilder(this.wf, this.from, port);
|
|
331
|
+
const b = new WhenBuilder(this.wf, this.from, port, this.accumulatedEndpoints);
|
|
479
332
|
b.addBranch(list);
|
|
480
333
|
return b;
|
|
481
334
|
};
|
|
335
|
+
then(config) {
|
|
336
|
+
return this.toCursor().then(config);
|
|
337
|
+
}
|
|
338
|
+
humanApproval(node$1, config, metadata) {
|
|
339
|
+
return this.toCursor().humanApproval(node$1, config, metadata);
|
|
340
|
+
}
|
|
482
341
|
build() {
|
|
483
342
|
return this.wf.build();
|
|
484
343
|
}
|
|
344
|
+
get accumulatedEndpoints() {
|
|
345
|
+
return this.armEndpoint ? [...this.priorEndpoints, this.armEndpoint] : this.priorEndpoints;
|
|
346
|
+
}
|
|
347
|
+
toCursor() {
|
|
348
|
+
return new ChainCursor(this.wf, this.accumulatedEndpoints);
|
|
349
|
+
}
|
|
485
350
|
};
|
|
486
351
|
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/workflow/dsl/workflowBuilderTypes.ts
|
|
354
|
+
function mergeForward(config) {
|
|
355
|
+
config.mergeJson = true;
|
|
356
|
+
return config;
|
|
357
|
+
}
|
|
358
|
+
|
|
487
359
|
//#endregion
|
|
488
360
|
//#region src/workflow/dsl/ChainCursorResolver.ts
|
|
489
361
|
var ChainCursor = class ChainCursor {
|
|
@@ -501,6 +373,10 @@ var ChainCursor = class ChainCursor {
|
|
|
501
373
|
...inputPortHint ? { inputPortHint } : {}
|
|
502
374
|
}]);
|
|
503
375
|
}
|
|
376
|
+
thenMerge(config) {
|
|
377
|
+
mergeForward(config);
|
|
378
|
+
return this.then(config);
|
|
379
|
+
}
|
|
504
380
|
thenIntoInputHints(config) {
|
|
505
381
|
const next = this.wf.add(config);
|
|
506
382
|
for (const e of this.endpoints) this.wf.connect(e.node, next, e.output, e.inputPortHint ?? "in");
|
|
@@ -569,21 +445,6 @@ var ChainCursor = class ChainCursor {
|
|
|
569
445
|
}
|
|
570
446
|
return new ChainCursor(this.wf, nextEndpoints);
|
|
571
447
|
}
|
|
572
|
-
/**
|
|
573
|
-
* Chainable shorthand for `.then(node.create(config, metadata?.name, metadata?.nodeId))`.
|
|
574
|
-
*
|
|
575
|
-
* Signals to readers that this step suspends the run and waits for a human decision.
|
|
576
|
-
* Throws at workflow-build time if `node` was not created via `defineHumanApprovalNode`.
|
|
577
|
-
*
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* workflow
|
|
581
|
-
* .trigger(...)
|
|
582
|
-
* .humanApproval(inboxApproval, { title: "Approve?", body: "...", priority: "normal" })
|
|
583
|
-
* .then(nextStep.create(...))
|
|
584
|
-
* .build();
|
|
585
|
-
* ```
|
|
586
|
-
*/
|
|
587
448
|
humanApproval(node$1, config, metadata) {
|
|
588
449
|
if (!isHumanApprovalNode(node$1)) throw new Error(`.humanApproval() requires a node created via defineHumanApprovalNode (got '${node$1.key ?? String(node$1)}').`);
|
|
589
450
|
return this.then(node$1.create(config, metadata?.name, metadata?.nodeId));
|
|
@@ -600,15 +461,6 @@ var ChainCursor = class ChainCursor {
|
|
|
600
461
|
|
|
601
462
|
//#endregion
|
|
602
463
|
//#region src/workflow/dsl/NodeIdSlugifier.ts
|
|
603
|
-
/**
|
|
604
|
-
* Converts a human-readable node label into a stable, URL-safe identifier segment.
|
|
605
|
-
*
|
|
606
|
-
* Rules:
|
|
607
|
-
* - Lowercase the entire string.
|
|
608
|
-
* - Replace every run of characters outside `[a-z0-9]` with a single `-`.
|
|
609
|
-
* - Strip any leading or trailing `-` characters.
|
|
610
|
-
* - Return `""` for blank/empty input.
|
|
611
|
-
*/
|
|
612
464
|
const NodeIdSlugifier = { slugify(label) {
|
|
613
465
|
if (!label) return "";
|
|
614
466
|
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -616,15 +468,6 @@ const NodeIdSlugifier = { slugify(label) {
|
|
|
616
468
|
|
|
617
469
|
//#endregion
|
|
618
470
|
//#region src/workflow/dsl/WorkflowDefinitionError.ts
|
|
619
|
-
/**
|
|
620
|
-
* Thrown by {@link WorkflowBuilder.build} when the workflow definition is structurally invalid.
|
|
621
|
-
*
|
|
622
|
-
* Common causes:
|
|
623
|
-
* - A node has an empty effective id (label is blank and no explicit `id` was given).
|
|
624
|
-
* - Two or more nodes share the same effective id (label slugs collide or explicit ids clash).
|
|
625
|
-
*
|
|
626
|
-
* Fix: provide an explicit `id:` on the offending node configs.
|
|
627
|
-
*/
|
|
628
471
|
var WorkflowDefinitionError = class extends Error {
|
|
629
472
|
constructor(message) {
|
|
630
473
|
super(message);
|
|
@@ -699,7 +542,7 @@ var WorkflowBuilder = class {
|
|
|
699
542
|
tokenName,
|
|
700
543
|
label: node$1.name ?? ""
|
|
701
544
|
});
|
|
702
|
-
if (require_di.AgentConfigInspector.isAgentNodeConfig(node$1.config)) for (const child of
|
|
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({
|
|
703
546
|
nodeId: child.nodeId,
|
|
704
547
|
tokenName: child.typeName,
|
|
705
548
|
label: child.name
|
|
@@ -736,17 +579,10 @@ var WorkflowBuilder = class {
|
|
|
736
579
|
|
|
737
580
|
//#endregion
|
|
738
581
|
//#region src/workflow/definition/ConnectionInvocationIdFactory.ts
|
|
739
|
-
/**
|
|
740
|
-
* Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
|
|
741
|
-
*
|
|
742
|
-
* Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
|
|
743
|
-
* paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
|
|
744
|
-
*/
|
|
745
582
|
var ConnectionInvocationIdFactory = class {
|
|
746
583
|
static create() {
|
|
747
584
|
return `cinv_${globalThis.crypto.randomUUID()}`;
|
|
748
585
|
}
|
|
749
|
-
/** Deterministic id for tests when a stable sequence is needed. */
|
|
750
586
|
static createForTest(runId, connectionNodeId, sequence) {
|
|
751
587
|
return `cinv_${runId}_${connectionNodeId}_${sequence}`;
|
|
752
588
|
}
|
|
@@ -754,9 +590,6 @@ var ConnectionInvocationIdFactory = class {
|
|
|
754
590
|
|
|
755
591
|
//#endregion
|
|
756
592
|
//#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
|
|
757
|
-
/**
|
|
758
|
-
* Derives which workflow nodes participate in the main execution graph vs connection-only children.
|
|
759
|
-
*/
|
|
760
593
|
var WorkflowExecutableNodeClassifier = class {
|
|
761
594
|
connectionOwnedIds;
|
|
762
595
|
constructor(workflow) {
|
|
@@ -776,9 +609,6 @@ var WorkflowExecutableNodeClassifier = class {
|
|
|
776
609
|
for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
|
|
777
610
|
return ids;
|
|
778
611
|
}
|
|
779
|
-
/**
|
|
780
|
-
* Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
|
|
781
|
-
*/
|
|
782
612
|
findDefaultExecutableStartNodeId(workflow) {
|
|
783
613
|
const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
|
|
784
614
|
if (firstTrigger) return firstTrigger;
|
|
@@ -843,13 +673,6 @@ var DefaultWorkflowGraphFactory = class {
|
|
|
843
673
|
|
|
844
674
|
//#endregion
|
|
845
675
|
//#region src/events/ConnectionInvocationEventPublisher.ts
|
|
846
|
-
/**
|
|
847
|
-
* Publishes per-invocation lifecycle records onto the run {@link RunEventBus}.
|
|
848
|
-
*
|
|
849
|
-
* Surgical, per-invocation events let the UI update the right-side inspector
|
|
850
|
-
* timeline as each LLM round / tool call transitions through `running` → `completed`
|
|
851
|
-
* (or `failed`) without depending on a coarse `runSaved` poll.
|
|
852
|
-
*/
|
|
853
676
|
var ConnectionInvocationEventPublisher = class {
|
|
854
677
|
constructor(eventBus, parent) {
|
|
855
678
|
this.eventBus = eventBus;
|
|
@@ -877,7 +700,6 @@ var ConnectionInvocationEventPublisher = class {
|
|
|
877
700
|
|
|
878
701
|
//#endregion
|
|
879
702
|
//#region src/events/NodeEventPublisher.ts
|
|
880
|
-
/** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
|
|
881
703
|
var NodeEventPublisher = class {
|
|
882
704
|
constructor(eventBus) {
|
|
883
705
|
this.eventBus = eventBus;
|
|
@@ -897,20 +719,7 @@ var NodeEventPublisher = class {
|
|
|
897
719
|
|
|
898
720
|
//#endregion
|
|
899
721
|
//#region src/binaries/boundedReadBinary.types.ts
|
|
900
|
-
|
|
901
|
-
* Reads all bytes from an already-opened binary stream into a contiguous `Uint8Array`.
|
|
902
|
-
*
|
|
903
|
-
* Safety contract:
|
|
904
|
-
* - `attachment.size` is checked against `maxBytes` *before* any allocation (no OOM).
|
|
905
|
-
* - A single buffer of exactly `attachment.size` is pre-allocated; the stream fills it
|
|
906
|
-
* directly — no chunks array, no doubling.
|
|
907
|
-
* - A byte-count mismatch between the declared size and actual stream content is an error.
|
|
908
|
-
*
|
|
909
|
-
* This is the single canonical implementation; `ExecutionBinaryService.getBytes`,
|
|
910
|
-
* `getText`, and `getJson` all delegate here. The per-package `readBinaryBody` helpers
|
|
911
|
-
* in `core-nodes` and `core-nodes-ocr` have been removed in favour of this function.
|
|
912
|
-
*/
|
|
913
|
-
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) {
|
|
914
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.`);
|
|
915
724
|
const out = new Uint8Array(attachment.size);
|
|
916
725
|
const reader = result.body.getReader();
|
|
@@ -926,18 +735,15 @@ async function boundedReadBinary(result, attachment, maxBytes = require_di.BINAR
|
|
|
926
735
|
if (offset !== out.byteLength) throw new Error(`Binary stream produced ${offset} bytes but attachment declared size ${attachment.size}.`);
|
|
927
736
|
return out;
|
|
928
737
|
}
|
|
929
|
-
/** Shared implementation of `getBytes` used by both binary-service classes. */
|
|
930
738
|
async function readBinaryAsBytes(storage, attachment, maxBytes) {
|
|
931
739
|
const result = await storage.openReadStream(attachment.storageKey);
|
|
932
740
|
if (!result) throw new Error("Binary attachment stream is unavailable.");
|
|
933
741
|
return boundedReadBinary(result, attachment, maxBytes);
|
|
934
742
|
}
|
|
935
|
-
/** Shared implementation of `getText` used by both binary-service classes. */
|
|
936
743
|
async function readBinaryAsText(storage, attachment, maxBytes) {
|
|
937
744
|
const bytes = await readBinaryAsBytes(storage, attachment, maxBytes);
|
|
938
745
|
return new TextDecoder().decode(bytes);
|
|
939
746
|
}
|
|
940
|
-
/** Shared implementation of `getJson` used by both binary-service classes. */
|
|
941
747
|
async function readBinaryAsJson(storage, attachment, maxBytes) {
|
|
942
748
|
const text = await readBinaryAsText(storage, attachment, maxBytes);
|
|
943
749
|
try {
|
|
@@ -1281,19 +1087,6 @@ var ActivationEnqueueService = class {
|
|
|
1281
1087
|
|
|
1282
1088
|
//#endregion
|
|
1283
1089
|
//#region src/execution/ChildExecutionScopeFactory.ts
|
|
1284
|
-
/**
|
|
1285
|
-
* Builds a re-rooted child execution context for sub-agent (and other deeply-nested) invocations.
|
|
1286
|
-
*
|
|
1287
|
-
* At the orchestrator's `agent.tool.call` boundary the inner runtime needs a ctx whose:
|
|
1288
|
-
* - `nodeId` is the tool's connection node id (so inner LLM/tool connection ids derive correctly),
|
|
1289
|
-
* - `activationId` is fresh (so its connection-invocation rows are uniquely identifiable),
|
|
1290
|
-
* - `telemetry` parents children under the tool-call span (not the orchestrator's node span),
|
|
1291
|
-
* - `binary` is scoped to the new (nodeId, activationId),
|
|
1292
|
-
* - `parentInvocationId` points back to the tool-call invocation for downstream lineage.
|
|
1293
|
-
*
|
|
1294
|
-
* Registered via factory in {@link EngineRuntimeRegistrar} so constructors stay free of parameter
|
|
1295
|
-
* decorators (Next/SWC and coverage tooling cannot parse them on in-repo sources).
|
|
1296
|
-
*/
|
|
1297
1090
|
var ChildExecutionScopeFactory = class {
|
|
1298
1091
|
constructor(activationIdFactory) {
|
|
1299
1092
|
this.activationIdFactory = activationIdFactory;
|
|
@@ -1323,9 +1116,6 @@ var ChildExecutionScopeFactory = class {
|
|
|
1323
1116
|
|
|
1324
1117
|
//#endregion
|
|
1325
1118
|
//#region src/contracts/itemMeta.ts
|
|
1326
|
-
/**
|
|
1327
|
-
* Reads `meta._cm.originIndex` when present (used for fan-in merge-by-origin and Merge routing).
|
|
1328
|
-
*/
|
|
1329
1119
|
function getOriginIndexFromItem(item) {
|
|
1330
1120
|
const v = (item.meta?._cm)?.originIndex;
|
|
1331
1121
|
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
@@ -1333,17 +1123,6 @@ function getOriginIndexFromItem(item) {
|
|
|
1333
1123
|
|
|
1334
1124
|
//#endregion
|
|
1335
1125
|
//#region src/execution/FanInMergeByOriginMerger.ts
|
|
1336
|
-
/**
|
|
1337
|
-
* Default fan-in: combine multi-port {@link NodeInputsByPort} into one {@link Items} batch for per-item nodes.
|
|
1338
|
-
*
|
|
1339
|
-
* This is used when a single-input per-item node has multiple inbound edges (for example, branch reconverge
|
|
1340
|
-
* after an `If` / `Switch`). The default behavior is **append / union** (preserving item payloads) with a
|
|
1341
|
-
* deterministic order:
|
|
1342
|
-
*
|
|
1343
|
-
* - When router origin metadata exists (`meta._cm.originIndex`), items are sorted by origin index so the
|
|
1344
|
-
* downstream batch preserves original ordering across branches.
|
|
1345
|
-
* - Otherwise, items are appended by port-key order, preserving each port's local order.
|
|
1346
|
-
*/
|
|
1347
1126
|
var FanInMergeByOriginMerger = class {
|
|
1348
1127
|
merge(inputsByPort) {
|
|
1349
1128
|
const portKeys = Object.keys(inputsByPort).sort();
|
|
@@ -1393,11 +1172,6 @@ var NodeInputContractError = class extends Error {
|
|
|
1393
1172
|
|
|
1394
1173
|
//#endregion
|
|
1395
1174
|
//#region src/execution/NodeActivationRequestInputPreparer.ts
|
|
1396
|
-
/**
|
|
1397
|
-
* Validates per-item inputs for {@link RunnableNode} before enqueue persistence (Zod on `item.json`).
|
|
1398
|
-
* Does not rewrite `item.json` (wire stays as emitted upstream; engine passes parsed input via `execute` args).
|
|
1399
|
-
* Converts multi-input activations into a single-input batch when the node is per-item only (engine fan-in).
|
|
1400
|
-
*/
|
|
1401
1175
|
var NodeActivationRequestInputPreparer = class {
|
|
1402
1176
|
fanInMerger = new FanInMergeByOriginMerger();
|
|
1403
1177
|
constructor(workflowNodeInstanceFactory) {
|
|
@@ -1544,13 +1318,11 @@ var RetryPolicy = class {
|
|
|
1544
1318
|
if (!Number.isFinite(maxAttempts) || maxAttempts < 1 || !Number.isInteger(maxAttempts)) throw new Error(`RetryPolicy.maxAttempts must be a positive integer, got ${maxAttempts}`);
|
|
1545
1319
|
if (!Number.isFinite(delayMs) || delayMs < 0) throw new Error(`RetryPolicy.delayMs must be a non-negative finite number, got ${delayMs}`);
|
|
1546
1320
|
}
|
|
1547
|
-
/** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */
|
|
1548
1321
|
static defaultForHttp = {
|
|
1549
1322
|
kind: "fixed",
|
|
1550
1323
|
maxAttempts: 3,
|
|
1551
1324
|
delayMs: 1e3
|
|
1552
1325
|
};
|
|
1553
|
-
/** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */
|
|
1554
1326
|
static defaultForAiAgent = {
|
|
1555
1327
|
kind: "fixed",
|
|
1556
1328
|
maxAttempts: 3,
|
|
@@ -1620,12 +1392,6 @@ var NoOpTelemetryArtifactReference = class {
|
|
|
1620
1392
|
|
|
1621
1393
|
//#endregion
|
|
1622
1394
|
//#region src/contracts/NoOpTelemetrySpanScope.ts
|
|
1623
|
-
/**
|
|
1624
|
-
* Standalone no-op {@link NodeExecutionTelemetry} value used as the return for `asNodeTelemetry`.
|
|
1625
|
-
*
|
|
1626
|
-
* Defined here (instead of in `NoOpNodeExecutionTelemetry.ts`) so that {@link NoOpTelemetrySpanScope}
|
|
1627
|
-
* can return it without importing the other module — both no-ops share this leaf.
|
|
1628
|
-
*/
|
|
1629
1395
|
const noOpNodeExecutionTelemetry = {
|
|
1630
1396
|
traceId: "00000000000000000000000000000000",
|
|
1631
1397
|
spanId: "0000000000000000",
|
|
@@ -1660,7 +1426,6 @@ const noOpTelemetrySpanScope = {
|
|
|
1660
1426
|
};
|
|
1661
1427
|
var NoOpTelemetrySpanScope = class {
|
|
1662
1428
|
static value = noOpTelemetrySpanScope;
|
|
1663
|
-
/** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
|
|
1664
1429
|
static nodeExecutionTelemetryValue = noOpNodeExecutionTelemetry;
|
|
1665
1430
|
};
|
|
1666
1431
|
|
|
@@ -1697,7 +1462,6 @@ var NoOpExecutionTelemetryFactory = class {
|
|
|
1697
1462
|
|
|
1698
1463
|
//#endregion
|
|
1699
1464
|
//#region src/contracts/workflowActivationPolicy.ts
|
|
1700
|
-
/** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
|
|
1701
1465
|
var AllWorkflowsActiveWorkflowActivationPolicy = class {
|
|
1702
1466
|
isActive(_workflowId) {
|
|
1703
1467
|
return true;
|
|
@@ -1717,25 +1481,15 @@ var CodemationTelemetryAttributeNames = class {
|
|
|
1717
1481
|
static connectionInvocationId = "codemation.connection.invocation_id";
|
|
1718
1482
|
static toolName = "codemation.tool.name";
|
|
1719
1483
|
static traceParentRunId = "codemation.parent.run.id";
|
|
1720
|
-
/** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
|
|
1721
1484
|
static iterationId = "codemation.iteration.id";
|
|
1722
|
-
/** Item index (0-based) of the iteration. */
|
|
1723
1485
|
static iterationIndex = "codemation.iteration.index";
|
|
1724
|
-
/** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
|
|
1725
1486
|
static parentInvocationId = "codemation.parent.invocation_id";
|
|
1726
|
-
/** MCP server id on spans created for callTool invocations. */
|
|
1727
1487
|
static mcpServerId = "mcp.server_id";
|
|
1728
|
-
/** MCP tool name on spans created for callTool invocations. */
|
|
1729
1488
|
static mcpToolName = "mcp.tool_name";
|
|
1730
|
-
/** Terminal node-execution status (e.g. `"hitl-approved"`, `"hitl-rejected"`) on HITL outcome spans. */
|
|
1731
1489
|
static nodeExecutionStatus = "codemation.node.execution_status";
|
|
1732
|
-
/** Populated on run-halted spans; discriminates the halt reason (e.g. `"hitl-rejected"`). */
|
|
1733
1490
|
static runHaltReason = "codemation.run.halt_reason";
|
|
1734
|
-
/** Human task ID on `hitl.task.*` span events. */
|
|
1735
1491
|
static hitlTaskId = "codemation.hitl.task_id";
|
|
1736
|
-
/** HITL channel name (e.g. `"inbox"`, `"control-plane-inbox"`) on `hitl.task.*` span events. */
|
|
1737
1492
|
static hitlChannel = "codemation.hitl.channel";
|
|
1738
|
-
/** Decision outcome (e.g. `"approved"`, `"rejected"`) on `hitl.task.decided` span events. */
|
|
1739
1493
|
static hitlDecisionStatus = "codemation.hitl.decision_status";
|
|
1740
1494
|
};
|
|
1741
1495
|
|
|
@@ -1950,7 +1704,6 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
|
|
|
1950
1704
|
|
|
1951
1705
|
//#endregion
|
|
1952
1706
|
//#region src/execution/InProcessRetryRunner.ts
|
|
1953
|
-
/** Maximum permitted retry attempts — workflow-declared values above this are clamped. */
|
|
1954
1707
|
const HARD_MAX_RETRY_ATTEMPTS = 10;
|
|
1955
1708
|
var InProcessRetryRunner = class InProcessRetryRunner {
|
|
1956
1709
|
constructor(sleeper) {
|
|
@@ -2042,9 +1795,6 @@ var InProcessRetryRunner = class InProcessRetryRunner {
|
|
|
2042
1795
|
|
|
2043
1796
|
//#endregion
|
|
2044
1797
|
//#region src/execution/ItemExprResolver.ts
|
|
2045
|
-
/**
|
|
2046
|
-
* Resolves {@link import("../contracts/itemExpr").ItemExpr} leaves on runnable config before {@link RunnableNode.execute}.
|
|
2047
|
-
*/
|
|
2048
1798
|
var ItemExprResolver = class {
|
|
2049
1799
|
async resolveConfigForItem(ctx, item, itemIndex, items) {
|
|
2050
1800
|
if (!ctx) throw new Error("ItemExprResolver.resolveConfigForItem: ctx is required");
|
|
@@ -2090,10 +1840,16 @@ var NodeOutputNormalizer = class {
|
|
|
2090
1840
|
isItemLike(value) {
|
|
2091
1841
|
return typeof value === "object" && value !== null && "json" in value;
|
|
2092
1842
|
}
|
|
1843
|
+
isPlainJsonObject(value) {
|
|
1844
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1845
|
+
}
|
|
2093
1846
|
applyOutput(baseItem, next, behavior) {
|
|
2094
1847
|
const explicitBinary = next.binary;
|
|
2095
1848
|
return {
|
|
2096
|
-
json: next.json
|
|
1849
|
+
json: behavior.mergeJson && this.isPlainJsonObject(baseItem.json) && this.isPlainJsonObject(next.json) ? {
|
|
1850
|
+
...baseItem.json,
|
|
1851
|
+
...next.json
|
|
1852
|
+
} : next.json,
|
|
2097
1853
|
...explicitBinary !== void 0 ? { binary: explicitBinary } : behavior.keepBinaries && baseItem.binary ? { binary: baseItem.binary } : {},
|
|
2098
1854
|
...next.meta ? { meta: next.meta } : {},
|
|
2099
1855
|
...next.paired ? { paired: next.paired } : {}
|
|
@@ -2105,11 +1861,17 @@ var NodeOutputNormalizer = class {
|
|
|
2105
1861
|
//#region src/execution/RunnableOutputBehaviorResolver.ts
|
|
2106
1862
|
var RunnableOutputBehaviorResolver = class {
|
|
2107
1863
|
resolve(config) {
|
|
2108
|
-
return {
|
|
1864
|
+
return {
|
|
1865
|
+
keepBinaries: this.isKeepBinariesEnabled(config),
|
|
1866
|
+
mergeJson: this.isMergeJsonEnabled(config)
|
|
1867
|
+
};
|
|
2109
1868
|
}
|
|
2110
1869
|
isKeepBinariesEnabled(config) {
|
|
2111
1870
|
return config.keepBinaries === true;
|
|
2112
1871
|
}
|
|
1872
|
+
isMergeJsonEnabled(config) {
|
|
1873
|
+
return config.mergeJson === true;
|
|
1874
|
+
}
|
|
2113
1875
|
};
|
|
2114
1876
|
|
|
2115
1877
|
//#endregion
|
|
@@ -2122,9 +1884,6 @@ var InProcessRetryRunnerFactory = class {
|
|
|
2122
1884
|
|
|
2123
1885
|
//#endregion
|
|
2124
1886
|
//#region src/execution/NodeActivationRequestComposer.ts
|
|
2125
|
-
/**
|
|
2126
|
-
* Builds {@link NodeActivationRequest} values shared by workflow starters and continuation.
|
|
2127
|
-
*/
|
|
2128
1887
|
var NodeActivationRequestComposer = class {
|
|
2129
1888
|
constructor(activationIdFactory, credentialResolverFactory) {
|
|
2130
1889
|
this.activationIdFactory = activationIdFactory;
|
|
@@ -2216,16 +1975,6 @@ var NodeActivationRequestComposer = class {
|
|
|
2216
1975
|
|
|
2217
1976
|
//#endregion
|
|
2218
1977
|
//#region src/execution/RunSuspendedError.ts
|
|
2219
|
-
/**
|
|
2220
|
-
* Internal sentinel thrown by {@link NodeSuspensionHandler} after persisting a suspension
|
|
2221
|
-
* entry. `NodeExecutionRequestHandlerService` catches this specifically and returns cleanly —
|
|
2222
|
-
* no continuation call, preventing `resumeFromNodeResult` / `resumeFromNodeError` from
|
|
2223
|
-
* overwriting the `"suspended"` run status.
|
|
2224
|
-
*
|
|
2225
|
-
* The `Error` suffix satisfies the ESLint `no-manual-di-new` allowlist. This is NOT a
|
|
2226
|
-
* user-facing error — it is an engine-internal control-flow primitive and should NOT be
|
|
2227
|
-
* exported from the public barrel.
|
|
2228
|
-
*/
|
|
2229
1978
|
var RunSuspendedError = class extends Error {
|
|
2230
1979
|
constructor(runId, taskId) {
|
|
2231
1980
|
super(`RunSuspendedError: run ${runId} suspended on task ${taskId}`);
|
|
@@ -2267,8 +2016,8 @@ var NodeExecutor = class {
|
|
|
2267
2016
|
}
|
|
2268
2017
|
}
|
|
2269
2018
|
isCredentialError(e) {
|
|
2270
|
-
if (e instanceof
|
|
2271
|
-
return (e instanceof Error ? e.cause : void 0) instanceof
|
|
2019
|
+
if (e instanceof require_workflowTypes.CredentialUnboundError) return true;
|
|
2020
|
+
return (e instanceof Error ? e.cause : void 0) instanceof require_workflowTypes.CredentialUnboundError;
|
|
2272
2021
|
}
|
|
2273
2022
|
async executeMultiInputActivation(request, node$1) {
|
|
2274
2023
|
const multiInputNode = node$1;
|
|
@@ -2355,7 +2104,7 @@ var NodeExecutor = class {
|
|
|
2355
2104
|
const resolvedCtx = await this.itemExprResolver.resolveConfigForItem(runnableCtx, item, i, inputBatch);
|
|
2356
2105
|
const iterationCtx = {
|
|
2357
2106
|
...this.pickExecutionContext(runnableCtx, resolvedCtx),
|
|
2358
|
-
iterationId:
|
|
2107
|
+
iterationId: require_workflowTypes.NodeIterationIdFactory.create(),
|
|
2359
2108
|
itemIndex: i
|
|
2360
2109
|
};
|
|
2361
2110
|
const args = {
|
|
@@ -2369,7 +2118,7 @@ var NodeExecutor = class {
|
|
|
2369
2118
|
try {
|
|
2370
2119
|
raw = await Promise.resolve(node$1.execute(args));
|
|
2371
2120
|
} catch (e) {
|
|
2372
|
-
if (e instanceof
|
|
2121
|
+
if (e instanceof require_workflowTypes.SuspensionRequest || e instanceof Error && e.name === "SuspensionRequest" && typeof e.request === "object") {
|
|
2373
2122
|
if (!this.suspensionHandler || !this.loadRunState) throw new Error(`Node ${request.nodeId} threw SuspensionRequest but this NodeExecutor has no suspensionHandler configured.`, { cause: e });
|
|
2374
2123
|
const state = await this.loadRunState(request.runId);
|
|
2375
2124
|
if (!state) throw new Error(`NodeExecutor: run state not found for runId ${request.runId} during suspension`, { cause: e });
|
|
@@ -2402,7 +2151,6 @@ var NodeExecutor = class {
|
|
|
2402
2151
|
if (hasSuspension) throw new RunSuspendedError(request.runId, "unknown");
|
|
2403
2152
|
return byPort;
|
|
2404
2153
|
}
|
|
2405
|
-
/** Use resolver ctx only when {@link NodeExecutionContext.config} is non-nullish. */
|
|
2406
2154
|
pickExecutionContext(runnableCtx, resolvedCtx) {
|
|
2407
2155
|
if (resolvedCtx != null && resolvedCtx.config != null) return resolvedCtx;
|
|
2408
2156
|
return runnableCtx;
|
|
@@ -2503,246 +2251,41 @@ var MissingRuntimeNode = class {
|
|
|
2503
2251
|
};
|
|
2504
2252
|
|
|
2505
2253
|
//#endregion
|
|
2506
|
-
//#region src/workflowSnapshots/
|
|
2507
|
-
var
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
};
|
|
2515
|
-
|
|
2516
|
-
//#endregion
|
|
2517
|
-
//#region src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts
|
|
2518
|
-
var PersistedRuntimeTypeIdFactory = class {
|
|
2519
|
-
static fromMetadata(args) {
|
|
2520
|
-
const metadata = getPersistedRuntimeTypeMetadata(args.type);
|
|
2521
|
-
if (!metadata) return;
|
|
2522
|
-
const packageName = metadata.packageName;
|
|
2523
|
-
if (!packageName) return;
|
|
2524
|
-
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;
|
|
2525
2262
|
}
|
|
2526
2263
|
};
|
|
2527
2264
|
|
|
2528
2265
|
//#endregion
|
|
2529
|
-
//#region src/workflowSnapshots/
|
|
2530
|
-
var
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
}
|
|
2542
|
-
/**
|
|
2543
|
-
* Register all decorated runtime types discovered in workflows.
|
|
2544
|
-
*/
|
|
2545
|
-
registerFromWorkflows(workflows) {
|
|
2546
|
-
for (const workflow of workflows) for (const node$1 of workflow.nodes) {
|
|
2547
|
-
this.registerDecoratedType(node$1.type);
|
|
2548
|
-
this.registerDecoratedType(node$1.config.type);
|
|
2549
|
-
this.registerNestedTypes(node$1.config);
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
registerDecoratedType(type) {
|
|
2553
|
-
if (this.tokenIdsByToken.has(type)) return;
|
|
2554
|
-
const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });
|
|
2555
|
-
if (!tokenId) return;
|
|
2556
|
-
this.tokensById.set(tokenId, type);
|
|
2557
|
-
this.tokenIdsByToken.set(type, tokenId);
|
|
2558
|
-
}
|
|
2559
|
-
registerNestedTypes(value) {
|
|
2560
|
-
if (Array.isArray(value)) {
|
|
2561
|
-
for (const entry of value) this.registerNestedTypes(entry);
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
|
-
if (!value || typeof value !== "object") return;
|
|
2565
|
-
const record = value;
|
|
2566
|
-
const type = this.asTypeToken(record.type);
|
|
2567
|
-
if (type) this.registerDecoratedType(type);
|
|
2568
|
-
for (const v of Object.values(record)) this.registerNestedTypes(v);
|
|
2569
|
-
}
|
|
2570
|
-
displayNameForTypeToken(token) {
|
|
2571
|
-
if (typeof token === "function" && token.name) return token.name;
|
|
2572
|
-
if (typeof token === "string") return token;
|
|
2573
|
-
return "";
|
|
2574
|
-
}
|
|
2575
|
-
asTypeToken(value) {
|
|
2576
|
-
if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
|
|
2577
|
-
}
|
|
2578
|
-
getTokenId(token) {
|
|
2579
|
-
const existing = this.tokenIdsByToken.get(token);
|
|
2580
|
-
if (existing) return existing;
|
|
2581
|
-
const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });
|
|
2582
|
-
if (!tokenId) return;
|
|
2583
|
-
this.tokensById.set(tokenId, token);
|
|
2584
|
-
this.tokenIdsByToken.set(token, tokenId);
|
|
2585
|
-
return tokenId;
|
|
2586
|
-
}
|
|
2587
|
-
resolve(tokenId) {
|
|
2588
|
-
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);
|
|
2589
2278
|
}
|
|
2590
2279
|
};
|
|
2591
2280
|
|
|
2592
2281
|
//#endregion
|
|
2593
|
-
//#region src/workflowSnapshots/
|
|
2594
|
-
var
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
return {
|
|
2600
|
-
id: workflow.id,
|
|
2601
|
-
name: workflow.name,
|
|
2602
|
-
workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
|
|
2603
|
-
...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
|
|
2604
|
-
nodes: workflow.nodes.map((node$1) => {
|
|
2605
|
-
const inspectorSummaryRows = this.safeInspectorSummary(node$1.config);
|
|
2606
|
-
return {
|
|
2607
|
-
id: node$1.id,
|
|
2608
|
-
kind: node$1.kind,
|
|
2609
|
-
name: node$1.name,
|
|
2610
|
-
nodeTokenId: this.resolveTokenId(node$1.type),
|
|
2611
|
-
configTokenId: this.resolveTokenId(node$1.config.type),
|
|
2612
|
-
tokenName: this.resolveTokenName(node$1.type),
|
|
2613
|
-
configTokenName: this.resolveTokenName(node$1.config.type),
|
|
2614
|
-
config: this.serializeConfig(node$1.config),
|
|
2615
|
-
...inspectorSummaryRows !== void 0 ? { inspectorSummary: inspectorSummaryRows } : {}
|
|
2616
|
-
};
|
|
2617
|
-
}),
|
|
2618
|
-
edges: workflow.edges.map((edge) => ({
|
|
2619
|
-
from: {
|
|
2620
|
-
nodeId: edge.from.nodeId,
|
|
2621
|
-
output: edge.from.output
|
|
2622
|
-
},
|
|
2623
|
-
to: {
|
|
2624
|
-
nodeId: edge.to.nodeId,
|
|
2625
|
-
input: edge.to.input
|
|
2626
|
-
}
|
|
2627
|
-
}))
|
|
2628
|
-
};
|
|
2629
|
-
}
|
|
2630
|
-
hydrate(snapshotNode, liveConfig) {
|
|
2631
|
-
const hydrated = this.mergeValue(liveConfig, snapshotNode.config);
|
|
2632
|
-
const configToken = this.tokenRegistry.resolve(snapshotNode.configTokenId);
|
|
2633
|
-
Object.assign(hydrated, {
|
|
2634
|
-
type: configToken ?? liveConfig.type,
|
|
2635
|
-
kind: snapshotNode.kind
|
|
2636
|
-
});
|
|
2637
|
-
if (snapshotNode.name && !("name" in hydrated && hydrated.name)) Object.assign(hydrated, { name: snapshotNode.name });
|
|
2638
|
-
return hydrated;
|
|
2639
|
-
}
|
|
2640
|
-
serializeConfig(config) {
|
|
2641
|
-
try {
|
|
2642
|
-
const cloned = JSON.parse(JSON.stringify(config));
|
|
2643
|
-
this.injectTokenIds(cloned, config);
|
|
2644
|
-
return cloned;
|
|
2645
|
-
} catch {
|
|
2646
|
-
const fallback = {
|
|
2647
|
-
kind: config.kind,
|
|
2648
|
-
name: config.name,
|
|
2649
|
-
id: config.id,
|
|
2650
|
-
icon: config.icon,
|
|
2651
|
-
execution: config.execution
|
|
2652
|
-
};
|
|
2653
|
-
this.injectTokenIds(fallback, config);
|
|
2654
|
-
return fallback;
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
/**
|
|
2658
|
-
* Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
|
|
2659
|
-
* Returns undefined if the method is absent, throws, or produces no valid rows.
|
|
2660
|
-
*/
|
|
2661
|
-
safeInspectorSummary(config) {
|
|
2662
|
-
const fn = config.inspectorSummary;
|
|
2663
|
-
if (typeof fn !== "function") return void 0;
|
|
2664
|
-
let raw;
|
|
2665
|
-
try {
|
|
2666
|
-
raw = fn.call(config);
|
|
2667
|
-
} catch {
|
|
2668
|
-
return;
|
|
2669
|
-
}
|
|
2670
|
-
if (!Array.isArray(raw)) return void 0;
|
|
2671
|
-
const rows = [];
|
|
2672
|
-
for (const entry of raw) {
|
|
2673
|
-
if (!entry || typeof entry !== "object") continue;
|
|
2674
|
-
const { label, value } = entry;
|
|
2675
|
-
if (typeof label !== "string" || typeof value !== "string") continue;
|
|
2676
|
-
const trimmedLabel = label.trim();
|
|
2677
|
-
if (trimmedLabel.length === 0) continue;
|
|
2678
|
-
rows.push({
|
|
2679
|
-
label: trimmedLabel,
|
|
2680
|
-
value
|
|
2681
|
-
});
|
|
2682
|
-
}
|
|
2683
|
-
return rows.length > 0 ? rows : void 0;
|
|
2684
|
-
}
|
|
2685
|
-
injectTokenIds(target, source) {
|
|
2686
|
-
const type = this.asTypeToken(source.type);
|
|
2687
|
-
if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
|
|
2688
|
-
for (const [key, value] of Object.entries(source)) {
|
|
2689
|
-
if (key === "type" || value == null) continue;
|
|
2690
|
-
if (Array.isArray(value)) {
|
|
2691
|
-
const targetArray = target[key];
|
|
2692
|
-
if (Array.isArray(targetArray)) value.forEach((item, index) => {
|
|
2693
|
-
if (item && typeof item === "object" && targetArray[index] && typeof targetArray[index] === "object") this.injectTokenIds(targetArray[index], item);
|
|
2694
|
-
});
|
|
2695
|
-
continue;
|
|
2696
|
-
}
|
|
2697
|
-
if (typeof value === "object") {
|
|
2698
|
-
const targetValue = target[key];
|
|
2699
|
-
if (targetValue && typeof targetValue === "object") this.injectTokenIds(targetValue, value);
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
mergeValue(liveValue, snapshotValue) {
|
|
2704
|
-
const liveRecord = this.asRecord(liveValue);
|
|
2705
|
-
const snapshotRecord = this.asRecord(snapshotValue);
|
|
2706
|
-
const hydrated = Object.create(liveValue && typeof liveValue === "object" ? Object.getPrototypeOf(liveValue) ?? Object.prototype : Object.prototype);
|
|
2707
|
-
for (const [key, value] of Object.entries(snapshotRecord)) hydrated[key] = this.mergeNestedValue(liveRecord[key], value);
|
|
2708
|
-
this.restoreNonSerializableProperties(liveRecord, hydrated);
|
|
2709
|
-
this.restoreTypeProperty(hydrated);
|
|
2710
|
-
return hydrated;
|
|
2711
|
-
}
|
|
2712
|
-
mergeNestedValue(liveValue, snapshotValue) {
|
|
2713
|
-
if (Array.isArray(snapshotValue)) {
|
|
2714
|
-
const liveArray = Array.isArray(liveValue) ? liveValue : [];
|
|
2715
|
-
return snapshotValue.map((entry, index) => this.mergeNestedValue(liveArray[index], entry));
|
|
2716
|
-
}
|
|
2717
|
-
if (snapshotValue && typeof snapshotValue === "object") return this.mergeValue(liveValue, snapshotValue);
|
|
2718
|
-
return snapshotValue;
|
|
2719
|
-
}
|
|
2720
|
-
restoreNonSerializableProperties(liveRecord, hydrated) {
|
|
2721
|
-
for (const [key, value] of Object.entries(liveRecord)) if (typeof value === "function" || typeof value === "symbol") hydrated[key] = value;
|
|
2722
|
-
for (const sym of Object.getOwnPropertySymbols(liveRecord)) hydrated[sym] = liveRecord[sym];
|
|
2723
|
-
}
|
|
2724
|
-
restoreTypeProperty(record) {
|
|
2725
|
-
const tokenId = typeof record.tokenId === "string" ? record.tokenId : void 0;
|
|
2726
|
-
if (!tokenId) return;
|
|
2727
|
-
const type = this.tokenRegistry.resolve(tokenId);
|
|
2728
|
-
if (type) record.type = type;
|
|
2729
|
-
}
|
|
2730
|
-
resolveTokenId(token) {
|
|
2731
|
-
return this.tokenRegistry.getTokenId(token) ?? this.resolveTokenName(token) ?? "unknown";
|
|
2732
|
-
}
|
|
2733
|
-
resolveTokenName(token) {
|
|
2734
|
-
if (typeof token === "function" && token.name) return token.name;
|
|
2735
|
-
if (typeof token === "string") return token;
|
|
2736
|
-
}
|
|
2737
|
-
asTypeToken(value) {
|
|
2738
|
-
if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
|
|
2739
|
-
}
|
|
2740
|
-
asRecord(value) {
|
|
2741
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
2742
|
-
const record = value;
|
|
2743
|
-
const out = { ...record };
|
|
2744
|
-
for (const sym of Object.getOwnPropertySymbols(value)) out[sym] = record[sym];
|
|
2745
|
-
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 };
|
|
2746
2289
|
}
|
|
2747
2290
|
};
|
|
2748
2291
|
|
|
@@ -3011,9 +2554,6 @@ var NodeRunStateWriterFactory = class {
|
|
|
3011
2554
|
|
|
3012
2555
|
//#endregion
|
|
3013
2556
|
//#region src/execution/PersistedRunStateTerminalBuilder.ts
|
|
3014
|
-
/**
|
|
3015
|
-
* Merges common terminal-run fields onto a loaded {@link PersistedRunState} without repeating object literals.
|
|
3016
|
-
*/
|
|
3017
2557
|
var PersistedRunStateTerminalBuilder = class {
|
|
3018
2558
|
mergeTerminal(args) {
|
|
3019
2559
|
return {
|
|
@@ -3111,9 +2651,6 @@ var RunStateSemantics = class {
|
|
|
3111
2651
|
|
|
3112
2652
|
//#endregion
|
|
3113
2653
|
//#region src/execution/WorkflowRunExecutionContextFactory.ts
|
|
3114
|
-
/**
|
|
3115
|
-
* Shared {@link ExecutionContextFactory#create} wiring for workflow runners (base context before node-specific fields).
|
|
3116
|
-
*/
|
|
3117
2654
|
var WorkflowRunExecutionContextFactory = class {
|
|
3118
2655
|
constructor(executionContextFactory, credentialResolverFactory) {
|
|
3119
2656
|
this.executionContextFactory = executionContextFactory;
|
|
@@ -3232,7 +2769,7 @@ var WorkflowTopology = class WorkflowTopology {
|
|
|
3232
2769
|
//#endregion
|
|
3233
2770
|
//#region src/orchestration/RunContinuationService.ts
|
|
3234
2771
|
var RunContinuationService = class {
|
|
3235
|
-
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) {
|
|
3236
2773
|
this.activationIdFactory = activationIdFactory;
|
|
3237
2774
|
this.workflowExecutionRepository = workflowExecutionRepository;
|
|
3238
2775
|
this.runDataFactory = runDataFactory;
|
|
@@ -3250,6 +2787,7 @@ var RunContinuationService = class {
|
|
|
3250
2787
|
this.policyErrorServices = policyErrorServices;
|
|
3251
2788
|
this.terminalPersistence = terminalPersistence;
|
|
3252
2789
|
this.executionLimitsPolicy = executionLimitsPolicy;
|
|
2790
|
+
this.parityGuard = parityGuard;
|
|
3253
2791
|
}
|
|
3254
2792
|
async markNodeRunning(args) {
|
|
3255
2793
|
const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(args.runId), this.workflowExecutionRepository.loadSchedulingState(args.runId)]);
|
|
@@ -3492,6 +3030,7 @@ var RunContinuationService = class {
|
|
|
3492
3030
|
nodeDefinition: def
|
|
3493
3031
|
});
|
|
3494
3032
|
try {
|
|
3033
|
+
this.parityGuard.assertNone(wf, [next.nodeId]);
|
|
3495
3034
|
const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
|
|
3496
3035
|
runId: state.runId,
|
|
3497
3036
|
workflowId: state.workflowId,
|
|
@@ -3663,20 +3202,6 @@ var RunContinuationService = class {
|
|
|
3663
3202
|
async waitForWebhookResponse(runId) {
|
|
3664
3203
|
return await this.waiters.waitForWebhookResponse(runId);
|
|
3665
3204
|
}
|
|
3666
|
-
/**
|
|
3667
|
-
* Re-activate a previously suspended run item with a human decision.
|
|
3668
|
-
*
|
|
3669
|
-
* Called by the HITL resume endpoint. This method:
|
|
3670
|
-
* 1. Loads `PersistedRunState` and locates the suspension entry by `taskId`.
|
|
3671
|
-
* 2. Removes the entry from the `suspension` array; if empty, run stays `"suspended"` until
|
|
3672
|
-
* enqueue flips it to `"pending"`.
|
|
3673
|
-
* 3. Writes `pendingResume` onto the state so `NodeExecutionRequestHandlerService` can
|
|
3674
|
-
* splice `resumeContext` into the node's execution context.
|
|
3675
|
-
* 4. Reconstructs the original input from `outputsByNode` of the upstream node and
|
|
3676
|
-
* enqueues a new activation via `activationEnqueueService`.
|
|
3677
|
-
*
|
|
3678
|
-
* @throws if the run is not found, not suspended, or the `taskId` is unknown.
|
|
3679
|
-
*/
|
|
3680
3205
|
async resumeRun(args) {
|
|
3681
3206
|
const state = await this.workflowExecutionRepository.load(args.runId);
|
|
3682
3207
|
if (!state) throw new Error(`Unknown runId: ${args.runId}`);
|
|
@@ -3735,6 +3260,7 @@ var RunContinuationService = class {
|
|
|
3735
3260
|
batchId,
|
|
3736
3261
|
input: resumeInput
|
|
3737
3262
|
});
|
|
3263
|
+
this.parityGuard.assertNone(wf, [suspensionEntry.nodeId]);
|
|
3738
3264
|
const { result, queuedSnapshot } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
|
|
3739
3265
|
runId: state.runId,
|
|
3740
3266
|
workflowId: state.workflowId,
|
|
@@ -3969,6 +3495,7 @@ var RunContinuationService = class {
|
|
|
3969
3495
|
nodeDefinition: nextDefinition
|
|
3970
3496
|
});
|
|
3971
3497
|
try {
|
|
3498
|
+
this.parityGuard.assertNone(args.workflow, [next.nodeId]);
|
|
3972
3499
|
const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
|
|
3973
3500
|
runId: args.state.runId,
|
|
3974
3501
|
workflowId: args.state.workflowId,
|
|
@@ -4083,10 +3610,6 @@ var RunContinuationService = class {
|
|
|
4083
3610
|
engineMaxSubworkflowDepth: state.executionOptions?.maxSubworkflowDepth ?? fb.maxSubworkflowDepth
|
|
4084
3611
|
};
|
|
4085
3612
|
}
|
|
4086
|
-
/**
|
|
4087
|
-
* Next activation could not be enqueued (e.g. input contract / mapping failed in the preparer).
|
|
4088
|
-
* Marks the target node failed and terminates the run.
|
|
4089
|
-
*/
|
|
4090
3613
|
async terminateRunAfterActivationEnqueueRejected(args) {
|
|
4091
3614
|
const finishedAt = args.completedAt;
|
|
4092
3615
|
const inputsByPort = NodeInputsByPortFactory.fromRequest(args.request);
|
|
@@ -4143,11 +3666,6 @@ var RunContinuationService = class {
|
|
|
4143
3666
|
this.waiters.resolveRunCompletion(result);
|
|
4144
3667
|
return result;
|
|
4145
3668
|
}
|
|
4146
|
-
/**
|
|
4147
|
-
* Inspects node outputs for a `decision.status` written by `defineHumanApprovalNode`.
|
|
4148
|
-
* Returns the first-class HITL node status and halt classification, or `undefined`
|
|
4149
|
-
* when the node is not a HITL approval node.
|
|
4150
|
-
*/
|
|
4151
3669
|
resolveHitlStatus(outputs) {
|
|
4152
3670
|
const firstItem = outputs?.main?.[0];
|
|
4153
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;
|
|
@@ -4188,7 +3706,6 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
|
|
|
4188
3706
|
constructor(topology) {
|
|
4189
3707
|
this.topology = topology;
|
|
4190
3708
|
}
|
|
4191
|
-
/** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */
|
|
4192
3709
|
static createFromTopology(topology) {
|
|
4193
3710
|
return new CurrentStateFrontierPlanner(topology);
|
|
4194
3711
|
}
|
|
@@ -4443,7 +3960,7 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
|
|
|
4443
3960
|
isRuntimeDescendant(nodeId, descendantNodeIds) {
|
|
4444
3961
|
for (const descendantNodeId of descendantNodeIds) {
|
|
4445
3962
|
if (nodeId === descendantNodeId) return false;
|
|
4446
|
-
if (
|
|
3963
|
+
if (require_workflowTypes.ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) return true;
|
|
4447
3964
|
}
|
|
4448
3965
|
return false;
|
|
4449
3966
|
}
|
|
@@ -4940,12 +4457,6 @@ var DefaultDrivingScheduler = class {
|
|
|
4940
4457
|
}
|
|
4941
4458
|
return await this.prepareInlineDispatch(request);
|
|
4942
4459
|
}
|
|
4943
|
-
/**
|
|
4944
|
-
* Scheduler precedence is explicit:
|
|
4945
|
-
* 1. run-intent override (`executionOptions.localOnly`)
|
|
4946
|
-
* 2. node-level execution hint / queue policy
|
|
4947
|
-
* 3. container-default scheduler policy fallback
|
|
4948
|
-
*/
|
|
4949
4460
|
async selectScheduler(request) {
|
|
4950
4461
|
if (request.executionOptions?.localOnly) return {
|
|
4951
4462
|
mode: "local",
|
|
@@ -5011,14 +4522,6 @@ var InlineDrivingScheduler = class {
|
|
|
5011
4522
|
setContinuation(continuation) {
|
|
5012
4523
|
this.continuation = continuation;
|
|
5013
4524
|
}
|
|
5014
|
-
/**
|
|
5015
|
-
* Prevents new drain cycles from being scheduled and waits for all currently-running
|
|
5016
|
-
* drains to complete. Call before closing the DB connection or rolling back test transactions
|
|
5017
|
-
* to ensure no in-flight writes hit a closed/rolled-back connection.
|
|
5018
|
-
*
|
|
5019
|
-
* Bounded: only the drains already in-flight at call time are awaited. Runs that keep
|
|
5020
|
-
* re-scheduling will not schedule new work once stopped is set.
|
|
5021
|
-
*/
|
|
5022
4525
|
async stop() {
|
|
5023
4526
|
this.stopped = true;
|
|
5024
4527
|
if (this.activeDrainPromises.size > 0) await Promise.allSettled(this.activeDrainPromises);
|
|
@@ -5130,24 +4633,16 @@ var LocalOnlyScheduler = class {
|
|
|
5130
4633
|
|
|
5131
4634
|
//#endregion
|
|
5132
4635
|
//#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
|
|
5133
|
-
/** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
|
|
5134
4636
|
const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
|
|
5135
4637
|
defaultMaxNodeActivations: 1e5,
|
|
5136
4638
|
hardMaxNodeActivations: 1e5,
|
|
5137
4639
|
defaultMaxSubworkflowDepth: 32,
|
|
5138
4640
|
hardMaxSubworkflowDepth: 32
|
|
5139
4641
|
};
|
|
5140
|
-
/**
|
|
5141
|
-
* Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
|
|
5142
|
-
*/
|
|
5143
4642
|
var EngineExecutionLimitsPolicy = class {
|
|
5144
4643
|
constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
|
|
5145
4644
|
this.config = config;
|
|
5146
4645
|
}
|
|
5147
|
-
/**
|
|
5148
|
-
* Effective options for a new root run (depth 0): defaults merged with engine ceilings.
|
|
5149
|
-
* Replaces a separate one-method factory for root-run bootstrap.
|
|
5150
|
-
*/
|
|
5151
4646
|
createRootExecutionOptions() {
|
|
5152
4647
|
return this.mergeExecutionOptionsForNewRun(void 0, void 0);
|
|
5153
4648
|
}
|
|
@@ -5375,10 +4870,6 @@ var InMemoryRunDataFactory = class {
|
|
|
5375
4870
|
|
|
5376
4871
|
//#endregion
|
|
5377
4872
|
//#region src/triggers/polling/PollingTriggerDedupWindow.ts
|
|
5378
|
-
/**
|
|
5379
|
-
* Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
|
|
5380
|
-
* Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
|
|
5381
|
-
*/
|
|
5382
4873
|
var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
|
|
5383
4874
|
static defaultCapN = 2e3;
|
|
5384
4875
|
merge(previous, incoming, capN = PollingTriggerDedupWindow.defaultCapN) {
|
|
@@ -5392,11 +4883,6 @@ var PollingTriggerDedupWindow = class PollingTriggerDedupWindow {
|
|
|
5392
4883
|
|
|
5393
4884
|
//#endregion
|
|
5394
4885
|
//#region src/triggers/polling/PollingTriggerRuntime.ts
|
|
5395
|
-
/**
|
|
5396
|
-
* Generic polling-trigger runtime. Owns the set-interval loop, overlap guard, and persistence.
|
|
5397
|
-
* Constructed by {@link import("../../runtime/EngineFactory").EngineFactory} and exposed to plugin
|
|
5398
|
-
* authors via {@link import("../../contracts/runtimeTypes").TriggerSetupContext}.polling.
|
|
5399
|
-
*/
|
|
5400
4886
|
var PollingTriggerRuntime = class {
|
|
5401
4887
|
activeTriggers = /* @__PURE__ */ new Set();
|
|
5402
4888
|
intervalsByTrigger = /* @__PURE__ */ new Map();
|
|
@@ -5498,7 +4984,7 @@ var NoOpPollingTriggerLogger = class {
|
|
|
5498
4984
|
//#endregion
|
|
5499
4985
|
//#region src/orchestration/NodeExecutionRequestHandlerService.ts
|
|
5500
4986
|
var NodeExecutionRequestHandlerService = class {
|
|
5501
|
-
constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy) {
|
|
4987
|
+
constructor(workflowExecutionRepository, workflowSnapshotResolver, runDataFactory, runExecutionContextFactory, nodeStatePublisherFactory, nodeActivationRequestComposer, nodeExecutor, continuation, executionLimitsPolicy, parityGuard) {
|
|
5502
4988
|
this.workflowExecutionRepository = workflowExecutionRepository;
|
|
5503
4989
|
this.workflowSnapshotResolver = workflowSnapshotResolver;
|
|
5504
4990
|
this.runDataFactory = runDataFactory;
|
|
@@ -5508,6 +4994,7 @@ var NodeExecutionRequestHandlerService = class {
|
|
|
5508
4994
|
this.nodeExecutor = nodeExecutor;
|
|
5509
4995
|
this.continuation = continuation;
|
|
5510
4996
|
this.executionLimitsPolicy = executionLimitsPolicy;
|
|
4997
|
+
this.parityGuard = parityGuard;
|
|
5511
4998
|
}
|
|
5512
4999
|
async handleNodeExecutionRequest(request) {
|
|
5513
5000
|
const [state, schedulingState] = await Promise.all([this.workflowExecutionRepository.load(request.runId), this.workflowExecutionRepository.loadSchedulingState(request.runId)]);
|
|
@@ -5591,6 +5078,7 @@ var NodeExecutionRequestHandlerService = class {
|
|
|
5591
5078
|
});
|
|
5592
5079
|
let outputs;
|
|
5593
5080
|
try {
|
|
5081
|
+
this.parityGuard.assertNone(workflow, [request.nodeId]);
|
|
5594
5082
|
outputs = await this.nodeExecutor.execute(activationRequest);
|
|
5595
5083
|
} catch (error) {
|
|
5596
5084
|
if (error instanceof RunSuspendedError) return;
|
|
@@ -5765,12 +5253,6 @@ var RunQueuePlanner = class {
|
|
|
5765
5253
|
const received = queueEntry.collect.received;
|
|
5766
5254
|
for (const input of queueEntry.collect.expectedInputs ?? []) if (!(input in received)) received[input] = [];
|
|
5767
5255
|
}
|
|
5768
|
-
/**
|
|
5769
|
-
* Matches `CurrentStateFrontierPlanner.buildFrontierQueue`: anything that is not exactly one input
|
|
5770
|
-
* port named `in` participates in multi-port collect (Merge after `If` branches, etc.). Routing must
|
|
5771
|
-
* not depend solely on `nodeInstances.get(toNodeId)?.executeMulti`, or a Merge can be enqueued as a
|
|
5772
|
-
* single-input job and `NodeExecutor` will call `execute` on a multi-input-only implementation.
|
|
5773
|
-
*/
|
|
5774
5256
|
usesTopologyCollectMerge(toNodeId) {
|
|
5775
5257
|
const expectedInputs = this.topology.expectedInputsByNode.get(toNodeId) ?? [];
|
|
5776
5258
|
if (expectedInputs.length !== 1 || expectedInputs[0] !== "in") return true;
|
|
@@ -6170,11 +5652,6 @@ var EngineWaiters = class {
|
|
|
6170
5652
|
|
|
6171
5653
|
//#endregion
|
|
6172
5654
|
//#region src/orchestration/Engine.ts
|
|
6173
|
-
/**
|
|
6174
|
-
* Runtime facade for orchestration, continuation, triggers, and webhook routing.
|
|
6175
|
-
* Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
|
|
6176
|
-
* The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
|
|
6177
|
-
*/
|
|
6178
5655
|
var Engine = class {
|
|
6179
5656
|
constructor(deps) {
|
|
6180
5657
|
this.deps = deps;
|
|
@@ -6248,10 +5725,6 @@ var Engine = class {
|
|
|
6248
5725
|
async waitForWebhookResponse(runId) {
|
|
6249
5726
|
return await this.deps.runContinuationService.waitForWebhookResponse(runId);
|
|
6250
5727
|
}
|
|
6251
|
-
/**
|
|
6252
|
-
* Re-activate a suspended run item with a human decision (HITL).
|
|
6253
|
-
* The HTTP resume endpoint calls this; this method exposes the engine primitive.
|
|
6254
|
-
*/
|
|
6255
5728
|
async resumeRun(args) {
|
|
6256
5729
|
return await this.deps.runContinuationService.resumeRun(args);
|
|
6257
5730
|
}
|
|
@@ -6262,11 +5735,6 @@ var Engine = class {
|
|
|
6262
5735
|
|
|
6263
5736
|
//#endregion
|
|
6264
5737
|
//#region src/runtime/EngineFactory.ts
|
|
6265
|
-
/**
|
|
6266
|
-
* Composes the {@link Engine} graph from {@link EngineCompositionDeps}. Production wiring usually goes through
|
|
6267
|
-
* {@link import("../bootstrap/runtime/EngineRuntimeRegistrar").EngineRuntimeRegistrar}; this factory remains for tests and custom composition.
|
|
6268
|
-
* Exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
|
|
6269
|
-
*/
|
|
6270
5738
|
var EngineFactory = class {
|
|
6271
5739
|
create(deps) {
|
|
6272
5740
|
const waiters = new EngineWaiters();
|
|
@@ -6275,10 +5743,12 @@ var EngineFactory = class {
|
|
|
6275
5743
|
const nodeStatePublisherFactory = new NodeRunStateWriterFactory(deps.workflowExecutionRepository, nodeEventPublisher, deps.eventBus);
|
|
6276
5744
|
const planningFactory = new EngineWorkflowPlanningFactory(deps.workflowNodeInstanceFactory);
|
|
6277
5745
|
const executionLimitsPolicy = deps.executionLimitsPolicy ?? new EngineExecutionLimitsPolicy();
|
|
6278
|
-
const workflowSnapshotCodec = deps.workflowSnapshotCodec ?? new WorkflowSnapshotCodec(deps.tokenRegistry);
|
|
5746
|
+
const workflowSnapshotCodec = deps.workflowSnapshotCodec ?? new require_contracts.WorkflowSnapshotCodec(deps.tokenRegistry);
|
|
6279
5747
|
const missingRuntimeFallbacks = deps.missingRuntimeFallbacks ?? new MissingRuntimeFallbacks();
|
|
6280
5748
|
const workflowSnapshotResolver = new WorkflowSnapshotResolver(deps.workflowRepository, deps.tokenRegistry, workflowSnapshotCodec, missingRuntimeFallbacks);
|
|
6281
|
-
const
|
|
5749
|
+
const missingRuntimeExecutionMarker = new MissingRuntimeExecutionMarker();
|
|
5750
|
+
const semantics = new RunStateSemantics(missingRuntimeExecutionMarker);
|
|
5751
|
+
const parityGuard = new MissingRuntimeParityGuard(missingRuntimeExecutionMarker);
|
|
6282
5752
|
const nodeActivationRequestInputPreparer = new NodeActivationRequestInputPreparer(deps.workflowNodeInstanceFactory);
|
|
6283
5753
|
const activationEnqueueService = new ActivationEnqueueService(deps.activationScheduler, deps.workflowExecutionRepository, nodeEventPublisher, nodeActivationRequestInputPreparer);
|
|
6284
5754
|
const runExecutionContextFactory = new WorkflowRunExecutionContextFactory(deps.executionContextFactory, credentialResolverFactory);
|
|
@@ -6288,8 +5758,8 @@ var EngineFactory = class {
|
|
|
6288
5758
|
const terminalPersistence = new RunTerminalPersistenceCoordinator(deps.workflowExecutionRepository, storagePolicyEvaluator);
|
|
6289
5759
|
const policyErrorServices = new WorkflowPolicyErrorServices(deps.nodeResolver);
|
|
6290
5760
|
const runStartService = new RunStartService(deps.runIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, workflowSnapshotCodec, planningFactory, nodeStatePublisherFactory, runExecutionContextFactory, nodeActivationRequestComposer, activationEnqueueService, semantics, waiters, deps.workflowPolicyRuntimeDefaults, executionLimitsPolicy, nodeEventPublisher, persistedRunStateTerminalBuilder);
|
|
6291
|
-
const runContinuationService = new RunContinuationService(deps.activationIdFactory, deps.workflowExecutionRepository, deps.runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy);
|
|
6292
|
-
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);
|
|
6293
5763
|
const pollingTriggerLogger = deps.pollingTriggerLogger ?? new NoOpPollingTriggerLogger();
|
|
6294
5764
|
const pollingTriggerDedupWindow = new PollingTriggerDedupWindow();
|
|
6295
5765
|
const pollingTriggerRuntime = new PollingTriggerRuntime(deps.triggerSetupStateRepository, pollingTriggerLogger);
|
|
@@ -6472,10 +5942,6 @@ var RunIntentService = class {
|
|
|
6472
5942
|
};
|
|
6473
5943
|
})]);
|
|
6474
5944
|
}
|
|
6475
|
-
/**
|
|
6476
|
-
* Webhook-triggered runs always force inline execution first.
|
|
6477
|
-
* This is the highest-precedence scheduler override: it wins over node hints and container defaults.
|
|
6478
|
-
*/
|
|
6479
5945
|
createWebhookExecutionOptions() {
|
|
6480
5946
|
return {
|
|
6481
5947
|
localOnly: true,
|
|
@@ -6494,10 +5960,6 @@ var RunIntentServiceFactory = class {
|
|
|
6494
5960
|
|
|
6495
5961
|
//#endregion
|
|
6496
5962
|
//#region src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts
|
|
6497
|
-
/**
|
|
6498
|
-
* Resolves webhook HTTP routes from the live workflow repository (no trigger setup / registration).
|
|
6499
|
-
* Maintains an in-memory index keyed by user-defined endpoint path for O(1) lookups after reload.
|
|
6500
|
-
*/
|
|
6501
5963
|
var WorkflowRepositoryWebhookTriggerMatcher = class {
|
|
6502
5964
|
routeByPath = /* @__PURE__ */ new Map();
|
|
6503
5965
|
engineRoutesActive = false;
|
|
@@ -6803,12 +6265,6 @@ Object.defineProperty(exports, 'InProcessRetryRunnerFactory', {
|
|
|
6803
6265
|
return InProcessRetryRunnerFactory;
|
|
6804
6266
|
}
|
|
6805
6267
|
});
|
|
6806
|
-
Object.defineProperty(exports, 'InjectableRuntimeDecoratorComposer', {
|
|
6807
|
-
enumerable: true,
|
|
6808
|
-
get: function () {
|
|
6809
|
-
return InjectableRuntimeDecoratorComposer;
|
|
6810
|
-
}
|
|
6811
|
-
});
|
|
6812
6268
|
Object.defineProperty(exports, 'InlineDrivingScheduler', {
|
|
6813
6269
|
enumerable: true,
|
|
6814
6270
|
get: function () {
|
|
@@ -6827,6 +6283,12 @@ Object.defineProperty(exports, 'LocalOnlyScheduler', {
|
|
|
6827
6283
|
return LocalOnlyScheduler;
|
|
6828
6284
|
}
|
|
6829
6285
|
});
|
|
6286
|
+
Object.defineProperty(exports, 'MissingRuntimeParityGuard', {
|
|
6287
|
+
enumerable: true,
|
|
6288
|
+
get: function () {
|
|
6289
|
+
return MissingRuntimeParityGuard;
|
|
6290
|
+
}
|
|
6291
|
+
});
|
|
6830
6292
|
Object.defineProperty(exports, 'MissingRuntimeTriggerToken', {
|
|
6831
6293
|
enumerable: true,
|
|
6832
6294
|
get: function () {
|
|
@@ -6929,24 +6391,6 @@ Object.defineProperty(exports, 'NodeOutputNormalizer', {
|
|
|
6929
6391
|
return NodeOutputNormalizer;
|
|
6930
6392
|
}
|
|
6931
6393
|
});
|
|
6932
|
-
Object.defineProperty(exports, 'PersistedRuntimeTypeMetadataStore', {
|
|
6933
|
-
enumerable: true,
|
|
6934
|
-
get: function () {
|
|
6935
|
-
return PersistedRuntimeTypeMetadataStore;
|
|
6936
|
-
}
|
|
6937
|
-
});
|
|
6938
|
-
Object.defineProperty(exports, 'PersistedRuntimeTypeNameResolver', {
|
|
6939
|
-
enumerable: true,
|
|
6940
|
-
get: function () {
|
|
6941
|
-
return PersistedRuntimeTypeNameResolver;
|
|
6942
|
-
}
|
|
6943
|
-
});
|
|
6944
|
-
Object.defineProperty(exports, 'PersistedWorkflowTokenRegistry', {
|
|
6945
|
-
enumerable: true,
|
|
6946
|
-
get: function () {
|
|
6947
|
-
return PersistedWorkflowTokenRegistry;
|
|
6948
|
-
}
|
|
6949
|
-
});
|
|
6950
6394
|
Object.defineProperty(exports, 'PollingTriggerDedupWindow', {
|
|
6951
6395
|
enumerable: true,
|
|
6952
6396
|
get: function () {
|
|
@@ -7001,12 +6445,6 @@ Object.defineProperty(exports, 'RunnableOutputBehaviorResolver', {
|
|
|
7001
6445
|
return RunnableOutputBehaviorResolver;
|
|
7002
6446
|
}
|
|
7003
6447
|
});
|
|
7004
|
-
Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
|
|
7005
|
-
enumerable: true,
|
|
7006
|
-
get: function () {
|
|
7007
|
-
return StackTraceCallSitePathResolver;
|
|
7008
|
-
}
|
|
7009
|
-
});
|
|
7010
6448
|
Object.defineProperty(exports, 'StaticCostCatalog', {
|
|
7011
6449
|
enumerable: true,
|
|
7012
6450
|
get: function () {
|
|
@@ -7049,6 +6487,12 @@ Object.defineProperty(exports, 'WorkflowExecutableNodeClassifierFactory', {
|
|
|
7049
6487
|
return WorkflowExecutableNodeClassifierFactory;
|
|
7050
6488
|
}
|
|
7051
6489
|
});
|
|
6490
|
+
Object.defineProperty(exports, 'WorkflowParityMismatchError', {
|
|
6491
|
+
enumerable: true,
|
|
6492
|
+
get: function () {
|
|
6493
|
+
return WorkflowParityMismatchError;
|
|
6494
|
+
}
|
|
6495
|
+
});
|
|
7052
6496
|
Object.defineProperty(exports, 'WorkflowPolicyErrorServices', {
|
|
7053
6497
|
enumerable: true,
|
|
7054
6498
|
get: function () {
|
|
@@ -7067,24 +6511,12 @@ Object.defineProperty(exports, 'WorkflowRepositoryWebhookTriggerMatcherFactory',
|
|
|
7067
6511
|
return WorkflowRepositoryWebhookTriggerMatcherFactory;
|
|
7068
6512
|
}
|
|
7069
6513
|
});
|
|
7070
|
-
Object.defineProperty(exports, 'WorkflowSnapshotCodec', {
|
|
7071
|
-
enumerable: true,
|
|
7072
|
-
get: function () {
|
|
7073
|
-
return WorkflowSnapshotCodec;
|
|
7074
|
-
}
|
|
7075
|
-
});
|
|
7076
6514
|
Object.defineProperty(exports, 'WorkflowStoragePolicyEvaluator', {
|
|
7077
6515
|
enumerable: true,
|
|
7078
6516
|
get: function () {
|
|
7079
6517
|
return WorkflowStoragePolicyEvaluator;
|
|
7080
6518
|
}
|
|
7081
6519
|
});
|
|
7082
|
-
Object.defineProperty(exports, 'chatModel', {
|
|
7083
|
-
enumerable: true,
|
|
7084
|
-
get: function () {
|
|
7085
|
-
return chatModel;
|
|
7086
|
-
}
|
|
7087
|
-
});
|
|
7088
6520
|
Object.defineProperty(exports, 'defineBatchNode', {
|
|
7089
6521
|
enumerable: true,
|
|
7090
6522
|
get: function () {
|
|
@@ -7115,12 +6547,6 @@ Object.defineProperty(exports, 'getOriginIndexFromItem', {
|
|
|
7115
6547
|
return getOriginIndexFromItem;
|
|
7116
6548
|
}
|
|
7117
6549
|
});
|
|
7118
|
-
Object.defineProperty(exports, 'getPersistedRuntimeTypeMetadata', {
|
|
7119
|
-
enumerable: true,
|
|
7120
|
-
get: function () {
|
|
7121
|
-
return getPersistedRuntimeTypeMetadata;
|
|
7122
|
-
}
|
|
7123
|
-
});
|
|
7124
6550
|
Object.defineProperty(exports, 'isHumanApprovalNode', {
|
|
7125
6551
|
enumerable: true,
|
|
7126
6552
|
get: function () {
|
|
@@ -7139,16 +6565,10 @@ Object.defineProperty(exports, 'isUnbrandedPortsEmissionShape', {
|
|
|
7139
6565
|
return isUnbrandedPortsEmissionShape;
|
|
7140
6566
|
}
|
|
7141
6567
|
});
|
|
7142
|
-
Object.defineProperty(exports, '
|
|
7143
|
-
enumerable: true,
|
|
7144
|
-
get: function () {
|
|
7145
|
-
return node;
|
|
7146
|
-
}
|
|
7147
|
-
});
|
|
7148
|
-
Object.defineProperty(exports, 'tool', {
|
|
6568
|
+
Object.defineProperty(exports, 'mergeForward', {
|
|
7149
6569
|
enumerable: true,
|
|
7150
6570
|
get: function () {
|
|
7151
|
-
return
|
|
6571
|
+
return mergeForward;
|
|
7152
6572
|
}
|
|
7153
6573
|
});
|
|
7154
|
-
//# sourceMappingURL=runtime-
|
|
6574
|
+
//# sourceMappingURL=runtime-Due-FOZ2.cjs.map
|