@codemation/core 0.10.1 → 0.11.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 +195 -0
- package/dist/{EngineRuntimeRegistration.types-D1fyApMI.d.ts → EngineRuntimeRegistration.types-BZ_1XWAJ.d.ts} +2 -2
- package/dist/{EngineRuntimeRegistration.types-pB3FnzqR.d.cts → EngineRuntimeRegistration.types-MPYWsEM0.d.cts} +7 -2
- package/dist/{InMemoryRunDataFactory-Xw7v4-sj.d.cts → InMemoryRunDataFactory-hmkh0lzR.d.cts} +8 -3
- package/dist/{RunIntentService-BE9CAkbf.d.ts → RunIntentService-BrEq6Jm6.d.ts} +1802 -1605
- package/dist/{RunIntentService-siBSjaaY.d.cts → RunIntentService-MUHJ1bhO.d.cts} +1722 -1598
- package/dist/bootstrap/index.cjs +2 -2
- package/dist/bootstrap/index.d.cts +6 -3
- package/dist/bootstrap/index.d.ts +4 -3
- package/dist/bootstrap/index.js +2 -2
- package/dist/{bootstrap-D3r505ko.js → bootstrap-Dgzsjoj7.js} +7 -2
- package/dist/bootstrap-Dgzsjoj7.js.map +1 -0
- package/dist/{bootstrap-Cm5ruQxx.cjs → bootstrap-dVmpU1ju.cjs} +7 -2
- package/dist/bootstrap-dVmpU1ju.cjs.map +1 -0
- package/dist/{index-DeLl1Tne.d.ts → index-Bes88mxT.d.ts} +113 -6
- package/dist/index.cjs +71 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +69 -4
- package/dist/index.js.map +1 -1
- package/dist/{runtime-BGNbRnqs.js → runtime-Duf3ClPw.js} +202 -53
- package/dist/runtime-Duf3ClPw.js.map +1 -0
- package/dist/{runtime-DKXJwTNv.cjs → runtime-vH0EeZzH.cjs} +208 -53
- package/dist/runtime-vH0EeZzH.cjs.map +1 -0
- package/dist/testing.cjs +6 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +6 -2
- package/dist/testing.js.map +1 -1
- package/package.json +4 -13
- package/src/ai/AgentConnectionNodeCollector.ts +47 -5
- package/src/authoring/defineNode.types.ts +21 -1
- package/src/authoring/definePollingTrigger.types.ts +20 -0
- package/src/binaries/UnavailableBinaryStorage.ts +6 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
- package/src/browser.ts +1 -0
- package/src/contracts/AgentBindError.ts +11 -0
- package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
- package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
- package/src/contracts/agentMcpTypes.ts +64 -0
- package/src/contracts/executionPersistenceContracts.ts +5 -0
- package/src/contracts/index.ts +4 -0
- package/src/contracts/mcpTypes.ts +29 -0
- package/src/contracts/runTypes.ts +13 -0
- package/src/contracts/runtimeTypes.ts +10 -0
- package/src/contracts/workflowTypes.ts +21 -0
- package/src/contracts.ts +3 -0
- package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
- package/src/di/CoreTokens.ts +7 -0
- package/src/execution/InProcessRetryRunner.ts +31 -5
- package/src/execution/NodeExecutionSnapshotFactory.ts +3 -0
- package/src/execution/NodeExecutor.ts +27 -7
- package/src/execution/NodeRunStateWriter.ts +14 -0
- package/src/index.ts +10 -0
- package/src/orchestration/RunContinuationService.ts +6 -2
- package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
- package/src/scheduler/InlineDrivingScheduler.ts +26 -22
- package/src/testing/SubWorkflowRunnerTestNode.ts +1 -0
- package/src/types/index.ts +1 -0
- package/src/validation/WorkflowEdgePortError.types.ts +16 -0
- package/src/validation/WorkflowEdgePortValidator.ts +52 -0
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
- package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
- package/dist/bootstrap-Cm5ruQxx.cjs.map +0 -1
- package/dist/bootstrap-D3r505ko.js.map +0 -1
- package/dist/runtime-BGNbRnqs.js.map +0 -1
- package/dist/runtime-DKXJwTNv.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { container as container$1, delay, inject, injectAll, injectable, instanceCachingFactory, instancePerContainerCachingFactory, predicateAwareClassFactory, registry, singleton } from "tsyringe";
|
|
3
3
|
import { ZodError, z } from "zod";
|
|
4
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
5
4
|
import { ReadableStream } from "node:stream/web";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
6
|
|
|
7
7
|
//#region src/di/CoreTokens.ts
|
|
8
8
|
const CoreTokens = {
|
|
@@ -25,7 +25,8 @@ const CoreTokens = {
|
|
|
25
25
|
BinaryStorage: Symbol.for("codemation.core.BinaryStorage"),
|
|
26
26
|
WebhookBasePath: Symbol.for("codemation.core.WebhookBasePath"),
|
|
27
27
|
EngineExecutionLimitsPolicy: Symbol.for("codemation.core.EngineExecutionLimitsPolicy"),
|
|
28
|
-
WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
|
|
28
|
+
WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy"),
|
|
29
|
+
AgentMcpIntegration: Symbol.for("codemation.core.AgentMcpIntegration")
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
//#endregion
|
|
@@ -291,6 +292,25 @@ var ConnectionNodeIdFactory = class {
|
|
|
291
292
|
const normalized = this.normalizeToolName(toolName);
|
|
292
293
|
return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;
|
|
293
294
|
}
|
|
295
|
+
static mcpConnectionNodeId(parentNodeId, serverId) {
|
|
296
|
+
return `${parentNodeId}${this.connectionSegment}mcp${this.connectionSegment}${serverId}`;
|
|
297
|
+
}
|
|
298
|
+
static isMcpConnectionNodeId(nodeId) {
|
|
299
|
+
return nodeId.includes(`${this.connectionSegment}mcp${this.connectionSegment}`);
|
|
300
|
+
}
|
|
301
|
+
static parseMcpConnectionNodeId(nodeId) {
|
|
302
|
+
if (!this.isMcpConnectionNodeId(nodeId)) return;
|
|
303
|
+
const marker = `${this.connectionSegment}mcp${this.connectionSegment}`;
|
|
304
|
+
const idx = nodeId.lastIndexOf(marker);
|
|
305
|
+
if (idx < 0) return;
|
|
306
|
+
const parentNodeId = nodeId.slice(0, idx);
|
|
307
|
+
const serverId = nodeId.slice(idx + marker.length);
|
|
308
|
+
if (!parentNodeId || !serverId) return;
|
|
309
|
+
return {
|
|
310
|
+
parentNodeId,
|
|
311
|
+
serverId
|
|
312
|
+
};
|
|
313
|
+
}
|
|
294
314
|
static isLanguageModelConnectionNodeId(nodeId) {
|
|
295
315
|
return nodeId.endsWith(`${this.connectionSegment}llm`);
|
|
296
316
|
}
|
|
@@ -329,12 +349,12 @@ var ConnectionNodeIdFactory = class {
|
|
|
329
349
|
//#endregion
|
|
330
350
|
//#region src/ai/AgentConnectionNodeCollector.ts
|
|
331
351
|
const AgentConnectionNodeCollector = new class {
|
|
332
|
-
collect(parentNodeId, agentConfig) {
|
|
352
|
+
collect(parentNodeId, agentConfig, mcpServerResolver) {
|
|
333
353
|
const collected = [];
|
|
334
|
-
this.collectInto(parentNodeId, agentConfig, collected);
|
|
354
|
+
this.collectInto(parentNodeId, agentConfig, collected, mcpServerResolver);
|
|
335
355
|
return collected;
|
|
336
356
|
}
|
|
337
|
-
collectInto(parentNodeId, agentConfig, collected) {
|
|
357
|
+
collectInto(parentNodeId, agentConfig, collected, mcpServerResolver) {
|
|
338
358
|
collected.push({
|
|
339
359
|
nodeId: ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
|
|
340
360
|
parentNodeId,
|
|
@@ -358,13 +378,35 @@ const AgentConnectionNodeCollector = new class {
|
|
|
358
378
|
icon: tool$1.presentation?.icon,
|
|
359
379
|
credentialSource: tool$1
|
|
360
380
|
});
|
|
361
|
-
this.collectNestedAgentTools(toolNodeId, tool$1, collected);
|
|
381
|
+
this.collectNestedAgentTools(toolNodeId, tool$1, collected, mcpServerResolver);
|
|
382
|
+
}
|
|
383
|
+
if (mcpServerResolver) {
|
|
384
|
+
const mcpServers = agentConfig.mcpServers;
|
|
385
|
+
for (const serverId of mcpServers ?? []) {
|
|
386
|
+
const decl = mcpServerResolver(serverId);
|
|
387
|
+
if (!decl) continue;
|
|
388
|
+
const acceptedTypes = decl.acceptedCredentialTypes ?? [];
|
|
389
|
+
collected.push({
|
|
390
|
+
nodeId: ConnectionNodeIdFactory.mcpConnectionNodeId(parentNodeId, serverId),
|
|
391
|
+
parentNodeId,
|
|
392
|
+
connectionName: "tools",
|
|
393
|
+
role: "tool",
|
|
394
|
+
name: decl.displayName,
|
|
395
|
+
typeName: serverId,
|
|
396
|
+
icon: "lucide:plug",
|
|
397
|
+
credentialSource: { getCredentialRequirements: () => [{
|
|
398
|
+
slotKey: "credential",
|
|
399
|
+
label: decl.displayName,
|
|
400
|
+
acceptedTypes
|
|
401
|
+
}] }
|
|
402
|
+
});
|
|
403
|
+
}
|
|
362
404
|
}
|
|
363
405
|
}
|
|
364
|
-
collectNestedAgentTools(toolNodeId, tool$1, collected) {
|
|
406
|
+
collectNestedAgentTools(toolNodeId, tool$1, collected, mcpServerResolver) {
|
|
365
407
|
if (!this.isNodeBackedAgentTool(tool$1)) return;
|
|
366
408
|
const innerAgent = tool$1 instanceof NodeBackedToolConfig ? tool$1.node : tool$1.node;
|
|
367
|
-
this.collectInto(toolNodeId, innerAgent, collected);
|
|
409
|
+
this.collectInto(toolNodeId, innerAgent, collected, mcpServerResolver);
|
|
368
410
|
}
|
|
369
411
|
/**
|
|
370
412
|
* After JSON round-trip (persisted snapshots), tools are plain objects — `instanceof NodeBackedToolConfig` fails.
|
|
@@ -655,10 +697,13 @@ var WorkflowBuilder = class {
|
|
|
655
697
|
//#region src/workflow/definition/ConnectionInvocationIdFactory.ts
|
|
656
698
|
/**
|
|
657
699
|
* Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
|
|
700
|
+
*
|
|
701
|
+
* Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
|
|
702
|
+
* paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
|
|
658
703
|
*/
|
|
659
704
|
var ConnectionInvocationIdFactory = class {
|
|
660
705
|
static create() {
|
|
661
|
-
return `cinv_${randomUUID()}`;
|
|
706
|
+
return `cinv_${globalThis.crypto.randomUUID()}`;
|
|
662
707
|
}
|
|
663
708
|
/** Deterministic id for tests when a stable sequence is needed. */
|
|
664
709
|
static createForTest(runId, connectionNodeId, sequence) {
|
|
@@ -674,10 +719,14 @@ var ConnectionInvocationIdFactory = class {
|
|
|
674
719
|
* Activations are per-batch (one scheduled execution of a node, possibly with N items).
|
|
675
720
|
* Iterations refine that to one identifier per item-index inside the batch loop, so per-item
|
|
676
721
|
* connection invocations and telemetry can be grouped without time-window heuristics.
|
|
722
|
+
*
|
|
723
|
+
* Uses Web Crypto's `randomUUID` (Node 19+ and all modern browsers) so this module is safe
|
|
724
|
+
* to include in the browser entry. Importing `node:crypto` here previously leaked into the
|
|
725
|
+
* canvas client bundle through `browser.ts` and OOM'd consumers' Turbopack builds.
|
|
677
726
|
*/
|
|
678
727
|
var NodeIterationIdFactory = class {
|
|
679
728
|
static create() {
|
|
680
|
-
return `iter_${randomUUID()}`;
|
|
729
|
+
return `iter_${globalThis.crypto.randomUUID()}`;
|
|
681
730
|
}
|
|
682
731
|
/** Deterministic id for tests when a stable sequence is needed. */
|
|
683
732
|
static createForTest(seed, sequence) {
|
|
@@ -927,6 +976,10 @@ var UnavailableBinaryStorage = class {
|
|
|
927
976
|
return { exists: false };
|
|
928
977
|
}
|
|
929
978
|
async delete() {}
|
|
979
|
+
async deleteMany() {}
|
|
980
|
+
async listByPrefix() {
|
|
981
|
+
return [];
|
|
982
|
+
}
|
|
930
983
|
};
|
|
931
984
|
|
|
932
985
|
//#endregion
|
|
@@ -995,7 +1048,8 @@ var NodeExecutionSnapshotFactory = class {
|
|
|
995
1048
|
inputsByPort: args.inputsByPort,
|
|
996
1049
|
outputs: args.outputs,
|
|
997
1050
|
usedPinnedOutput: fromPinnedOutput,
|
|
998
|
-
error: void 0
|
|
1051
|
+
error: void 0,
|
|
1052
|
+
...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
|
|
999
1053
|
};
|
|
1000
1054
|
}
|
|
1001
1055
|
static skipped(args) {
|
|
@@ -1012,7 +1066,8 @@ var NodeExecutionSnapshotFactory = class {
|
|
|
1012
1066
|
updatedAt: args.finishedAt,
|
|
1013
1067
|
inputsByPort: args.inputsByPort,
|
|
1014
1068
|
outputs: args.outputs,
|
|
1015
|
-
error: void 0
|
|
1069
|
+
error: void 0,
|
|
1070
|
+
...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
|
|
1016
1071
|
};
|
|
1017
1072
|
}
|
|
1018
1073
|
static failed(args) {
|
|
@@ -1034,7 +1089,8 @@ var NodeExecutionSnapshotFactory = class {
|
|
|
1034
1089
|
name: args.error.name,
|
|
1035
1090
|
stack: args.error.stack,
|
|
1036
1091
|
details: args.error.details
|
|
1037
|
-
}
|
|
1092
|
+
},
|
|
1093
|
+
...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
|
|
1038
1094
|
};
|
|
1039
1095
|
}
|
|
1040
1096
|
};
|
|
@@ -1363,6 +1419,20 @@ var DefaultAsyncSleeper = class {
|
|
|
1363
1419
|
}
|
|
1364
1420
|
};
|
|
1365
1421
|
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region src/contracts/NoOpAgentMcpIntegration.ts
|
|
1424
|
+
/**
|
|
1425
|
+
* No-op implementation of AgentMcpIntegration.
|
|
1426
|
+
* Registered by the core engine runtime as a fallback when the host does not
|
|
1427
|
+
* supply a real implementation (e.g. in unit tests or headless engine setups).
|
|
1428
|
+
* Always returns an empty tool map so the agent runs with node-backed tools only.
|
|
1429
|
+
*/
|
|
1430
|
+
var NoOpAgentMcpIntegration = class {
|
|
1431
|
+
async prepareMcpTools() {
|
|
1432
|
+
return /* @__PURE__ */ new Map();
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1366
1436
|
//#endregion
|
|
1367
1437
|
//#region src/contracts/emitPorts.ts
|
|
1368
1438
|
const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
|
|
@@ -1602,6 +1672,10 @@ var CodemationTelemetryAttributeNames = class {
|
|
|
1602
1672
|
static iterationIndex = "codemation.iteration.index";
|
|
1603
1673
|
/** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
|
|
1604
1674
|
static parentInvocationId = "codemation.parent.invocation_id";
|
|
1675
|
+
/** MCP server id on spans created for callTool invocations. */
|
|
1676
|
+
static mcpServerId = "mcp.server_id";
|
|
1677
|
+
/** MCP tool name on spans created for callTool invocations. */
|
|
1678
|
+
static mcpToolName = "mcp.tool_name";
|
|
1605
1679
|
};
|
|
1606
1680
|
|
|
1607
1681
|
//#endregion
|
|
@@ -1817,18 +1891,21 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
|
|
|
1817
1891
|
|
|
1818
1892
|
//#endregion
|
|
1819
1893
|
//#region src/execution/InProcessRetryRunner.ts
|
|
1894
|
+
/** Maximum permitted retry attempts — workflow-declared values above this are clamped. */
|
|
1895
|
+
const HARD_MAX_RETRY_ATTEMPTS = 10;
|
|
1820
1896
|
var InProcessRetryRunner = class InProcessRetryRunner {
|
|
1821
1897
|
constructor(sleeper) {
|
|
1822
1898
|
this.sleeper = sleeper;
|
|
1823
1899
|
}
|
|
1824
|
-
async run(policy, work) {
|
|
1825
|
-
const spec = InProcessRetryRunner.normalizePolicy(policy);
|
|
1900
|
+
async run(policy, work, shouldRetry, warn) {
|
|
1901
|
+
const spec = InProcessRetryRunner.normalizePolicy(policy, warn);
|
|
1826
1902
|
let lastError;
|
|
1827
1903
|
for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
|
|
1828
1904
|
return await work();
|
|
1829
1905
|
} catch (error) {
|
|
1830
1906
|
lastError = error;
|
|
1831
1907
|
if (attempt >= spec.maxAttempts) break;
|
|
1908
|
+
if (shouldRetry !== void 0 && !shouldRetry(error)) break;
|
|
1832
1909
|
const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
|
|
1833
1910
|
await this.sleeper.sleep(delayMs);
|
|
1834
1911
|
}
|
|
@@ -1843,7 +1920,7 @@ var InProcessRetryRunner = class InProcessRetryRunner {
|
|
|
1843
1920
|
if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
|
|
1844
1921
|
return Math.max(0, Math.floor(ms));
|
|
1845
1922
|
}
|
|
1846
|
-
static normalizePolicy(policy) {
|
|
1923
|
+
static normalizePolicy(policy, warn) {
|
|
1847
1924
|
if (policy === void 0) return {
|
|
1848
1925
|
kind: "none",
|
|
1849
1926
|
maxAttempts: 1
|
|
@@ -1859,17 +1936,19 @@ var InProcessRetryRunner = class InProcessRetryRunner {
|
|
|
1859
1936
|
};
|
|
1860
1937
|
if (kind === "fixed") {
|
|
1861
1938
|
const p = policy;
|
|
1939
|
+
const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts");
|
|
1862
1940
|
return {
|
|
1863
1941
|
kind: "fixed",
|
|
1864
|
-
maxAttempts: InProcessRetryRunner.
|
|
1942
|
+
maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
|
|
1865
1943
|
delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
|
|
1866
1944
|
};
|
|
1867
1945
|
}
|
|
1868
1946
|
if (kind === "exponential") {
|
|
1869
1947
|
const p = policy;
|
|
1948
|
+
const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts");
|
|
1870
1949
|
return {
|
|
1871
1950
|
kind: "exponential",
|
|
1872
|
-
maxAttempts: InProcessRetryRunner.
|
|
1951
|
+
maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
|
|
1873
1952
|
initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
|
|
1874
1953
|
multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
|
|
1875
1954
|
maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
|
|
@@ -1881,6 +1960,13 @@ var InProcessRetryRunner = class InProcessRetryRunner {
|
|
|
1881
1960
|
maxAttempts: 1
|
|
1882
1961
|
};
|
|
1883
1962
|
}
|
|
1963
|
+
static clampMaxAttempts(requested, warn) {
|
|
1964
|
+
if (requested > HARD_MAX_RETRY_ATTEMPTS) {
|
|
1965
|
+
warn?.(`Retry policy maxAttempts (${requested}) exceeds hard ceiling (${HARD_MAX_RETRY_ATTEMPTS}); clamping to ${HARD_MAX_RETRY_ATTEMPTS}.`);
|
|
1966
|
+
return HARD_MAX_RETRY_ATTEMPTS;
|
|
1967
|
+
}
|
|
1968
|
+
return requested;
|
|
1969
|
+
}
|
|
1884
1970
|
static assertPositiveInt(value, label) {
|
|
1885
1971
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
|
|
1886
1972
|
return value;
|
|
@@ -2083,12 +2169,24 @@ var NodeExecutor = class {
|
|
|
2083
2169
|
this.outputBehaviorResolver = outputBehaviorResolver ?? new RunnableOutputBehaviorResolver();
|
|
2084
2170
|
}
|
|
2085
2171
|
async execute(request) {
|
|
2172
|
+
await this.assertRequiredCredentialsBound(request);
|
|
2086
2173
|
const policy = request.ctx.config.retryPolicy;
|
|
2087
2174
|
return await this.retryRunner.run(policy, async () => {
|
|
2088
2175
|
const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);
|
|
2089
2176
|
if (request.kind === "multi") return await this.executeMultiInputActivation(request, nodeInstance);
|
|
2090
2177
|
return await this.executeSingleInputNode(request, nodeInstance);
|
|
2091
|
-
});
|
|
2178
|
+
}, (error) => !this.isCredentialError(error));
|
|
2179
|
+
}
|
|
2180
|
+
async assertRequiredCredentialsBound(request) {
|
|
2181
|
+
if (!request.ctx.getCredential) return;
|
|
2182
|
+
for (const req of request.ctx.config.getCredentialRequirements?.() ?? []) {
|
|
2183
|
+
if (req.optional) continue;
|
|
2184
|
+
await request.ctx.getCredential(req.slotKey);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
isCredentialError(e) {
|
|
2188
|
+
if (e instanceof CredentialUnboundError) return true;
|
|
2189
|
+
return (e instanceof Error ? e.cause : void 0) instanceof CredentialUnboundError;
|
|
2092
2190
|
}
|
|
2093
2191
|
async executeMultiInputActivation(request, node$1) {
|
|
2094
2192
|
const multiInputNode = node$1;
|
|
@@ -2398,16 +2496,20 @@ var WorkflowSnapshotCodec = class {
|
|
|
2398
2496
|
name: workflow.name,
|
|
2399
2497
|
workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
|
|
2400
2498
|
...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
|
|
2401
|
-
nodes: workflow.nodes.map((node$1) =>
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2499
|
+
nodes: workflow.nodes.map((node$1) => {
|
|
2500
|
+
const inspectorSummaryRows = this.safeInspectorSummary(node$1.config);
|
|
2501
|
+
return {
|
|
2502
|
+
id: node$1.id,
|
|
2503
|
+
kind: node$1.kind,
|
|
2504
|
+
name: node$1.name,
|
|
2505
|
+
nodeTokenId: this.resolveTokenId(node$1.type),
|
|
2506
|
+
configTokenId: this.resolveTokenId(node$1.config.type),
|
|
2507
|
+
tokenName: this.resolveTokenName(node$1.type),
|
|
2508
|
+
configTokenName: this.resolveTokenName(node$1.config.type),
|
|
2509
|
+
config: this.serializeConfig(node$1.config),
|
|
2510
|
+
...inspectorSummaryRows !== void 0 ? { inspectorSummary: inspectorSummaryRows } : {}
|
|
2511
|
+
};
|
|
2512
|
+
}),
|
|
2411
2513
|
edges: workflow.edges.map((edge) => ({
|
|
2412
2514
|
from: {
|
|
2413
2515
|
nodeId: edge.from.nodeId,
|
|
@@ -2447,6 +2549,34 @@ var WorkflowSnapshotCodec = class {
|
|
|
2447
2549
|
return fallback;
|
|
2448
2550
|
}
|
|
2449
2551
|
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
|
|
2554
|
+
* Returns undefined if the method is absent, throws, or produces no valid rows.
|
|
2555
|
+
*/
|
|
2556
|
+
safeInspectorSummary(config) {
|
|
2557
|
+
const fn = config.inspectorSummary;
|
|
2558
|
+
if (typeof fn !== "function") return void 0;
|
|
2559
|
+
let raw;
|
|
2560
|
+
try {
|
|
2561
|
+
raw = fn.call(config);
|
|
2562
|
+
} catch {
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
2565
|
+
if (!Array.isArray(raw)) return void 0;
|
|
2566
|
+
const rows = [];
|
|
2567
|
+
for (const entry of raw) {
|
|
2568
|
+
if (!entry || typeof entry !== "object") continue;
|
|
2569
|
+
const { label, value } = entry;
|
|
2570
|
+
if (typeof label !== "string" || typeof value !== "string") continue;
|
|
2571
|
+
const trimmedLabel = label.trim();
|
|
2572
|
+
if (trimmedLabel.length === 0) continue;
|
|
2573
|
+
rows.push({
|
|
2574
|
+
label: trimmedLabel,
|
|
2575
|
+
value
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
return rows.length > 0 ? rows : void 0;
|
|
2579
|
+
}
|
|
2450
2580
|
injectTokenIds(target, source) {
|
|
2451
2581
|
const type = this.asTypeToken(source.type);
|
|
2452
2582
|
if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
|
|
@@ -2691,6 +2821,18 @@ var NodeRunStateWriter = class {
|
|
|
2691
2821
|
await this.publishNodeEvent("nodeFailed", snapshot);
|
|
2692
2822
|
});
|
|
2693
2823
|
}
|
|
2824
|
+
setChildRunId(args) {
|
|
2825
|
+
return this.enqueue(async () => {
|
|
2826
|
+
const state = await this.loadState();
|
|
2827
|
+
const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
|
|
2828
|
+
if (!previous) return;
|
|
2829
|
+
const updated = {
|
|
2830
|
+
...previous,
|
|
2831
|
+
childRunId: args.childRunId
|
|
2832
|
+
};
|
|
2833
|
+
await this.saveSnapshot(state, updated);
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2694
2836
|
appendConnectionInvocation(args) {
|
|
2695
2837
|
return this.enqueue(async () => {
|
|
2696
2838
|
const state = await this.loadState();
|
|
@@ -2705,6 +2847,8 @@ var NodeRunStateWriter = class {
|
|
|
2705
2847
|
status: args.status,
|
|
2706
2848
|
managedInput: args.managedInput,
|
|
2707
2849
|
managedOutput: args.managedOutput,
|
|
2850
|
+
statusLabel: args.statusLabel,
|
|
2851
|
+
subjectName: args.subjectName,
|
|
2708
2852
|
error: args.error,
|
|
2709
2853
|
queuedAt: args.queuedAt,
|
|
2710
2854
|
startedAt: args.startedAt,
|
|
@@ -3067,7 +3211,7 @@ var RunContinuationService = class {
|
|
|
3067
3211
|
});
|
|
3068
3212
|
const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;
|
|
3069
3213
|
const engineCounters = { completedNodeActivations: completedActivations };
|
|
3070
|
-
const maxNodeActivations = state.executionOptions?.maxNodeActivations ??
|
|
3214
|
+
const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
|
|
3071
3215
|
if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {
|
|
3072
3216
|
const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
|
|
3073
3217
|
state,
|
|
@@ -3391,7 +3535,7 @@ var RunContinuationService = class {
|
|
|
3391
3535
|
});
|
|
3392
3536
|
const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;
|
|
3393
3537
|
const engineCounters = { completedNodeActivations: completedActivations };
|
|
3394
|
-
const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ??
|
|
3538
|
+
const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
|
|
3395
3539
|
if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {
|
|
3396
3540
|
const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
|
|
3397
3541
|
state: args.state,
|
|
@@ -4620,25 +4764,24 @@ var InlineDrivingScheduler = class {
|
|
|
4620
4764
|
this.scheduledRuns.delete(runId);
|
|
4621
4765
|
try {
|
|
4622
4766
|
const q = this.queuesByRunId.get(runId) ?? [];
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
}
|
|
4640
|
-
await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
|
|
4767
|
+
if (q.length === 0) return;
|
|
4768
|
+
const { request } = q.shift();
|
|
4769
|
+
const cont = this.continuation;
|
|
4770
|
+
if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
|
|
4771
|
+
await cont.markNodeRunning({
|
|
4772
|
+
runId: request.runId,
|
|
4773
|
+
activationId: request.activationId,
|
|
4774
|
+
nodeId: request.nodeId,
|
|
4775
|
+
inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
|
|
4776
|
+
});
|
|
4777
|
+
let outputs;
|
|
4778
|
+
try {
|
|
4779
|
+
outputs = await this.nodeExecutor.execute(request);
|
|
4780
|
+
} catch (e) {
|
|
4781
|
+
await this.resumeAfterExecutionError(cont, request, this.asError(e));
|
|
4782
|
+
return;
|
|
4641
4783
|
}
|
|
4784
|
+
await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
|
|
4642
4785
|
} finally {
|
|
4643
4786
|
if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);
|
|
4644
4787
|
this.drainingRuns.delete(runId);
|
|
@@ -4648,10 +4791,10 @@ var InlineDrivingScheduler = class {
|
|
|
4648
4791
|
scheduleDrain(runId) {
|
|
4649
4792
|
if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) return;
|
|
4650
4793
|
this.scheduledRuns.add(runId);
|
|
4651
|
-
|
|
4794
|
+
setImmediate(() => {
|
|
4652
4795
|
this.scheduledRuns.delete(runId);
|
|
4653
4796
|
this.drainRun(runId);
|
|
4654
|
-
}
|
|
4797
|
+
});
|
|
4655
4798
|
}
|
|
4656
4799
|
async resumeAfterExecutionResult(continuation, request, outputs) {
|
|
4657
4800
|
try {
|
|
@@ -4901,6 +5044,12 @@ var InMemoryBinaryStorage = class {
|
|
|
4901
5044
|
async delete(storageKey) {
|
|
4902
5045
|
this.values.delete(storageKey);
|
|
4903
5046
|
}
|
|
5047
|
+
async deleteMany(storageKeys) {
|
|
5048
|
+
for (const key of storageKeys) this.values.delete(key);
|
|
5049
|
+
}
|
|
5050
|
+
async listByPrefix(prefix) {
|
|
5051
|
+
return Array.from(this.values.keys()).filter((key) => key.startsWith(prefix));
|
|
5052
|
+
}
|
|
4904
5053
|
};
|
|
4905
5054
|
|
|
4906
5055
|
//#endregion
|
|
@@ -6129,5 +6278,5 @@ var WorkflowRepositoryWebhookTriggerMatcherFactory = class {
|
|
|
6129
6278
|
};
|
|
6130
6279
|
|
|
6131
6280
|
//#endregion
|
|
6132
|
-
export { NoOpCostTrackingTelemetryFactory as $,
|
|
6133
|
-
//# sourceMappingURL=runtime-
|
|
6281
|
+
export { NoOpCostTrackingTelemetryFactory as $, registry as $t, PersistedWorkflowTokenRegistry as A, ConnectionNodeIdFactory as At, DefaultExecutionContextFactory as B, tool as Bt, DefaultDrivingScheduler as C, ConnectionInvocationIdFactory as Ct, NodeInstanceFactoryFactory as D, ChainCursor as Dt, StaticCostCatalog as E, NodeIdSlugifier as Et, RunnableOutputBehaviorResolver as F, resolveItemExprsInUnknown as Ft, CodemationTelemetryAttributeNames as G, container$1 as Gt, nodeRef as H, PersistedRuntimeTypeMetadataStore as Ht, NodeOutputNormalizer as I, NodeBackedToolConfig as It, NoOpExecutionTelemetryFactory as J, injectAll as Jt, AllWorkflowsActiveWorkflowActivationPolicy as K, delay as Kt, ItemExprResolver as L, chatModel as Lt, NodeExecutorFactory as M, isItemExpr as Mt, NodeExecutor as N, itemExpr as Nt, NodeInstanceFactory as O, WhenBuilder as Ot, InProcessRetryRunnerFactory as P, resolveItemExprsForExecution as Pt, NoOpTelemetryArtifactReference as Q, predicateAwareClassFactory as Qt, InProcessRetryRunner as R, getPersistedRuntimeTypeMetadata as Rt, HintOnlyOffloadPolicy as S, NodeIterationIdFactory as St, RunPolicySnapshotFactory as T, WorkflowDefinitionError as Tt, CodemationTelemetryMetricNames as U, StackTraceCallSitePathResolver as Ut, branchRef as V, InjectableRuntimeDecoratorComposer as Vt, GenAiTelemetryAttributeNames as W, PersistedRuntimeTypeNameResolver as Wt, NoOpNodeExecutionTelemetry as X, instanceCachingFactory as Xt, NoOpExecutionTelemetry as Y, injectable as Yt, NoOpTelemetrySpanScope as Z, instancePerContainerCachingFactory as Zt, RunTerminalPersistenceCoordinator as _, NodeEventPublisher as _t, InMemoryLiveWorkflowRepository as a, RetryPolicy as at, LocalOnlyScheduler as b, WorkflowExecutableNodeClassifierFactory as bt, EngineFactory as c, isPortsEmission as ct, PollingTriggerRuntime as d, DefaultAsyncSleeper as dt, singleton as en, NoOpCostTrackingTelemetry as et, PollingTriggerDedupWindow as f, CredentialResolverFactory as ft, WorkflowPolicyErrorServices as g, UnavailableBinaryStorage as gt, WorkflowStoragePolicyEvaluator as h, DefaultExecutionBinaryService as ht, RunIntentService as i, ExpRetryPolicy as it, MissingRuntimeTriggerToken as j, AgentConfigInspector as jt, WorkflowSnapshotCodec as k, AgentConnectionNodeCollector as kt, Engine as l, isUnbrandedPortsEmissionShape as lt, InMemoryBinaryStorage as m, ChildExecutionScopeFactory as mt, WorkflowRepositoryWebhookTriggerMatcher as n, CostTrackingTelemetryMetricNames as nt, EngineWorkflowRunnerServiceFactory as o, NoRetryPolicy as ot, InMemoryRunDataFactory as p, getOriginIndexFromItem as pt, RunFinishedAtFactory as q, inject as qt, RunIntentServiceFactory as r, CredentialUnboundError as rt, EngineWorkflowRunnerService as s, emitPorts as st, WorkflowRepositoryWebhookTriggerMatcherFactory as t, CoreTokens as tn, CostTrackingTelemetryAttributeNames as tt, NoOpPollingTriggerLogger as u, NoOpAgentMcpIntegration as ut, ENGINE_EXECUTION_LIMITS_DEFAULTS as v, ConnectionInvocationEventPublisher as vt, ConfigDrivenOffloadPolicy as w, WorkflowBuilder as wt, InlineDrivingScheduler as x, WorkflowExecutableNodeClassifier as xt, EngineExecutionLimitsPolicy as y, DefaultWorkflowGraphFactory as yt, CatalogBackedCostTrackingTelemetryFactory as z, node as zt };
|
|
6282
|
+
//# sourceMappingURL=runtime-Duf3ClPw.js.map
|