@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/dist/{EngineRuntimeRegistration.types-D1fyApMI.d.ts → EngineRuntimeRegistration.types-BZ_1XWAJ.d.ts} +2 -2
  3. package/dist/{EngineRuntimeRegistration.types-pB3FnzqR.d.cts → EngineRuntimeRegistration.types-MPYWsEM0.d.cts} +7 -2
  4. package/dist/{InMemoryRunDataFactory-Xw7v4-sj.d.cts → InMemoryRunDataFactory-hmkh0lzR.d.cts} +8 -3
  5. package/dist/{RunIntentService-BE9CAkbf.d.ts → RunIntentService-BrEq6Jm6.d.ts} +1802 -1605
  6. package/dist/{RunIntentService-siBSjaaY.d.cts → RunIntentService-MUHJ1bhO.d.cts} +1722 -1598
  7. package/dist/bootstrap/index.cjs +2 -2
  8. package/dist/bootstrap/index.d.cts +6 -3
  9. package/dist/bootstrap/index.d.ts +4 -3
  10. package/dist/bootstrap/index.js +2 -2
  11. package/dist/{bootstrap-D3r505ko.js → bootstrap-Dgzsjoj7.js} +7 -2
  12. package/dist/bootstrap-Dgzsjoj7.js.map +1 -0
  13. package/dist/{bootstrap-Cm5ruQxx.cjs → bootstrap-dVmpU1ju.cjs} +7 -2
  14. package/dist/bootstrap-dVmpU1ju.cjs.map +1 -0
  15. package/dist/{index-DeLl1Tne.d.ts → index-Bes88mxT.d.ts} +113 -6
  16. package/dist/index.cjs +71 -3
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +173 -6
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +69 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/{runtime-BGNbRnqs.js → runtime-Duf3ClPw.js} +202 -53
  23. package/dist/runtime-Duf3ClPw.js.map +1 -0
  24. package/dist/{runtime-DKXJwTNv.cjs → runtime-vH0EeZzH.cjs} +208 -53
  25. package/dist/runtime-vH0EeZzH.cjs.map +1 -0
  26. package/dist/testing.cjs +6 -2
  27. package/dist/testing.cjs.map +1 -1
  28. package/dist/testing.d.cts +3 -3
  29. package/dist/testing.d.ts +2 -2
  30. package/dist/testing.js +6 -2
  31. package/dist/testing.js.map +1 -1
  32. package/package.json +4 -13
  33. package/src/ai/AgentConnectionNodeCollector.ts +47 -5
  34. package/src/authoring/defineNode.types.ts +21 -1
  35. package/src/authoring/definePollingTrigger.types.ts +20 -0
  36. package/src/binaries/UnavailableBinaryStorage.ts +6 -0
  37. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
  38. package/src/browser.ts +1 -0
  39. package/src/contracts/AgentBindError.ts +11 -0
  40. package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
  41. package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
  42. package/src/contracts/agentMcpTypes.ts +64 -0
  43. package/src/contracts/executionPersistenceContracts.ts +5 -0
  44. package/src/contracts/index.ts +4 -0
  45. package/src/contracts/mcpTypes.ts +29 -0
  46. package/src/contracts/runTypes.ts +13 -0
  47. package/src/contracts/runtimeTypes.ts +10 -0
  48. package/src/contracts/workflowTypes.ts +21 -0
  49. package/src/contracts.ts +3 -0
  50. package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
  51. package/src/di/CoreTokens.ts +7 -0
  52. package/src/execution/InProcessRetryRunner.ts +31 -5
  53. package/src/execution/NodeExecutionSnapshotFactory.ts +3 -0
  54. package/src/execution/NodeExecutor.ts +27 -7
  55. package/src/execution/NodeRunStateWriter.ts +14 -0
  56. package/src/index.ts +10 -0
  57. package/src/orchestration/RunContinuationService.ts +6 -2
  58. package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
  59. package/src/scheduler/InlineDrivingScheduler.ts +26 -22
  60. package/src/testing/SubWorkflowRunnerTestNode.ts +1 -0
  61. package/src/types/index.ts +1 -0
  62. package/src/validation/WorkflowEdgePortError.types.ts +16 -0
  63. package/src/validation/WorkflowEdgePortValidator.ts +52 -0
  64. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
  65. package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
  66. package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
  67. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
  68. package/dist/bootstrap-Cm5ruQxx.cjs.map +0 -1
  69. package/dist/bootstrap-D3r505ko.js.map +0 -1
  70. package/dist/runtime-BGNbRnqs.js.map +0 -1
  71. package/dist/runtime-DKXJwTNv.cjs.map +0 -1
@@ -26,10 +26,10 @@ let tsyringe = require("tsyringe");
26
26
  tsyringe = __toESM(tsyringe);
27
27
  let zod = require("zod");
28
28
  zod = __toESM(zod);
29
- let node_crypto = require("node:crypto");
30
- node_crypto = __toESM(node_crypto);
31
29
  let node_stream_web = require("node:stream/web");
32
30
  node_stream_web = __toESM(node_stream_web);
31
+ let node_crypto = require("node:crypto");
32
+ node_crypto = __toESM(node_crypto);
33
33
 
34
34
  //#region src/di/CoreTokens.ts
35
35
  const CoreTokens = {
@@ -52,7 +52,8 @@ const CoreTokens = {
52
52
  BinaryStorage: Symbol.for("codemation.core.BinaryStorage"),
53
53
  WebhookBasePath: Symbol.for("codemation.core.WebhookBasePath"),
54
54
  EngineExecutionLimitsPolicy: Symbol.for("codemation.core.EngineExecutionLimitsPolicy"),
55
- WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
55
+ WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy"),
56
+ AgentMcpIntegration: Symbol.for("codemation.core.AgentMcpIntegration")
56
57
  };
57
58
 
58
59
  //#endregion
@@ -318,6 +319,25 @@ var ConnectionNodeIdFactory = class {
318
319
  const normalized = this.normalizeToolName(toolName);
319
320
  return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;
320
321
  }
322
+ static mcpConnectionNodeId(parentNodeId, serverId) {
323
+ return `${parentNodeId}${this.connectionSegment}mcp${this.connectionSegment}${serverId}`;
324
+ }
325
+ static isMcpConnectionNodeId(nodeId) {
326
+ return nodeId.includes(`${this.connectionSegment}mcp${this.connectionSegment}`);
327
+ }
328
+ static parseMcpConnectionNodeId(nodeId) {
329
+ if (!this.isMcpConnectionNodeId(nodeId)) return;
330
+ const marker = `${this.connectionSegment}mcp${this.connectionSegment}`;
331
+ const idx = nodeId.lastIndexOf(marker);
332
+ if (idx < 0) return;
333
+ const parentNodeId = nodeId.slice(0, idx);
334
+ const serverId = nodeId.slice(idx + marker.length);
335
+ if (!parentNodeId || !serverId) return;
336
+ return {
337
+ parentNodeId,
338
+ serverId
339
+ };
340
+ }
321
341
  static isLanguageModelConnectionNodeId(nodeId) {
322
342
  return nodeId.endsWith(`${this.connectionSegment}llm`);
323
343
  }
@@ -356,12 +376,12 @@ var ConnectionNodeIdFactory = class {
356
376
  //#endregion
357
377
  //#region src/ai/AgentConnectionNodeCollector.ts
358
378
  const AgentConnectionNodeCollector = new class {
359
- collect(parentNodeId, agentConfig) {
379
+ collect(parentNodeId, agentConfig, mcpServerResolver) {
360
380
  const collected = [];
361
- this.collectInto(parentNodeId, agentConfig, collected);
381
+ this.collectInto(parentNodeId, agentConfig, collected, mcpServerResolver);
362
382
  return collected;
363
383
  }
364
- collectInto(parentNodeId, agentConfig, collected) {
384
+ collectInto(parentNodeId, agentConfig, collected, mcpServerResolver) {
365
385
  collected.push({
366
386
  nodeId: ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
367
387
  parentNodeId,
@@ -385,13 +405,35 @@ const AgentConnectionNodeCollector = new class {
385
405
  icon: tool$1.presentation?.icon,
386
406
  credentialSource: tool$1
387
407
  });
388
- this.collectNestedAgentTools(toolNodeId, tool$1, collected);
408
+ this.collectNestedAgentTools(toolNodeId, tool$1, collected, mcpServerResolver);
409
+ }
410
+ if (mcpServerResolver) {
411
+ const mcpServers = agentConfig.mcpServers;
412
+ for (const serverId of mcpServers ?? []) {
413
+ const decl = mcpServerResolver(serverId);
414
+ if (!decl) continue;
415
+ const acceptedTypes = decl.acceptedCredentialTypes ?? [];
416
+ collected.push({
417
+ nodeId: ConnectionNodeIdFactory.mcpConnectionNodeId(parentNodeId, serverId),
418
+ parentNodeId,
419
+ connectionName: "tools",
420
+ role: "tool",
421
+ name: decl.displayName,
422
+ typeName: serverId,
423
+ icon: "lucide:plug",
424
+ credentialSource: { getCredentialRequirements: () => [{
425
+ slotKey: "credential",
426
+ label: decl.displayName,
427
+ acceptedTypes
428
+ }] }
429
+ });
430
+ }
389
431
  }
390
432
  }
391
- collectNestedAgentTools(toolNodeId, tool$1, collected) {
433
+ collectNestedAgentTools(toolNodeId, tool$1, collected, mcpServerResolver) {
392
434
  if (!this.isNodeBackedAgentTool(tool$1)) return;
393
435
  const innerAgent = tool$1 instanceof NodeBackedToolConfig ? tool$1.node : tool$1.node;
394
- this.collectInto(toolNodeId, innerAgent, collected);
436
+ this.collectInto(toolNodeId, innerAgent, collected, mcpServerResolver);
395
437
  }
396
438
  /**
397
439
  * After JSON round-trip (persisted snapshots), tools are plain objects — `instanceof NodeBackedToolConfig` fails.
@@ -682,10 +724,13 @@ var WorkflowBuilder = class {
682
724
  //#region src/workflow/definition/ConnectionInvocationIdFactory.ts
683
725
  /**
684
726
  * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
727
+ *
728
+ * Uses Web Crypto's `randomUUID` so this module is safe in browser-bundle contexts —
729
+ * paired with `NodeIterationIdFactory` which had the same `node:crypto` regression.
685
730
  */
686
731
  var ConnectionInvocationIdFactory = class {
687
732
  static create() {
688
- return `cinv_${(0, node_crypto.randomUUID)()}`;
733
+ return `cinv_${globalThis.crypto.randomUUID()}`;
689
734
  }
690
735
  /** Deterministic id for tests when a stable sequence is needed. */
691
736
  static createForTest(runId, connectionNodeId, sequence) {
@@ -701,10 +746,14 @@ var ConnectionInvocationIdFactory = class {
701
746
  * Activations are per-batch (one scheduled execution of a node, possibly with N items).
702
747
  * Iterations refine that to one identifier per item-index inside the batch loop, so per-item
703
748
  * connection invocations and telemetry can be grouped without time-window heuristics.
749
+ *
750
+ * Uses Web Crypto's `randomUUID` (Node 19+ and all modern browsers) so this module is safe
751
+ * to include in the browser entry. Importing `node:crypto` here previously leaked into the
752
+ * canvas client bundle through `browser.ts` and OOM'd consumers' Turbopack builds.
704
753
  */
705
754
  var NodeIterationIdFactory = class {
706
755
  static create() {
707
- return `iter_${(0, node_crypto.randomUUID)()}`;
756
+ return `iter_${globalThis.crypto.randomUUID()}`;
708
757
  }
709
758
  /** Deterministic id for tests when a stable sequence is needed. */
710
759
  static createForTest(seed, sequence) {
@@ -954,6 +1003,10 @@ var UnavailableBinaryStorage = class {
954
1003
  return { exists: false };
955
1004
  }
956
1005
  async delete() {}
1006
+ async deleteMany() {}
1007
+ async listByPrefix() {
1008
+ return [];
1009
+ }
957
1010
  };
958
1011
 
959
1012
  //#endregion
@@ -1022,7 +1075,8 @@ var NodeExecutionSnapshotFactory = class {
1022
1075
  inputsByPort: args.inputsByPort,
1023
1076
  outputs: args.outputs,
1024
1077
  usedPinnedOutput: fromPinnedOutput,
1025
- error: void 0
1078
+ error: void 0,
1079
+ ...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
1026
1080
  };
1027
1081
  }
1028
1082
  static skipped(args) {
@@ -1039,7 +1093,8 @@ var NodeExecutionSnapshotFactory = class {
1039
1093
  updatedAt: args.finishedAt,
1040
1094
  inputsByPort: args.inputsByPort,
1041
1095
  outputs: args.outputs,
1042
- error: void 0
1096
+ error: void 0,
1097
+ ...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
1043
1098
  };
1044
1099
  }
1045
1100
  static failed(args) {
@@ -1061,7 +1116,8 @@ var NodeExecutionSnapshotFactory = class {
1061
1116
  name: args.error.name,
1062
1117
  stack: args.error.stack,
1063
1118
  details: args.error.details
1064
- }
1119
+ },
1120
+ ...args.previous?.childRunId !== void 0 ? { childRunId: args.previous.childRunId } : {}
1065
1121
  };
1066
1122
  }
1067
1123
  };
@@ -1390,6 +1446,20 @@ var DefaultAsyncSleeper = class {
1390
1446
  }
1391
1447
  };
1392
1448
 
1449
+ //#endregion
1450
+ //#region src/contracts/NoOpAgentMcpIntegration.ts
1451
+ /**
1452
+ * No-op implementation of AgentMcpIntegration.
1453
+ * Registered by the core engine runtime as a fallback when the host does not
1454
+ * supply a real implementation (e.g. in unit tests or headless engine setups).
1455
+ * Always returns an empty tool map so the agent runs with node-backed tools only.
1456
+ */
1457
+ var NoOpAgentMcpIntegration = class {
1458
+ async prepareMcpTools() {
1459
+ return /* @__PURE__ */ new Map();
1460
+ }
1461
+ };
1462
+
1393
1463
  //#endregion
1394
1464
  //#region src/contracts/emitPorts.ts
1395
1465
  const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
@@ -1629,6 +1699,10 @@ var CodemationTelemetryAttributeNames = class {
1629
1699
  static iterationIndex = "codemation.iteration.index";
1630
1700
  /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
1631
1701
  static parentInvocationId = "codemation.parent.invocation_id";
1702
+ /** MCP server id on spans created for callTool invocations. */
1703
+ static mcpServerId = "mcp.server_id";
1704
+ /** MCP tool name on spans created for callTool invocations. */
1705
+ static mcpToolName = "mcp.tool_name";
1632
1706
  };
1633
1707
 
1634
1708
  //#endregion
@@ -1844,18 +1918,21 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
1844
1918
 
1845
1919
  //#endregion
1846
1920
  //#region src/execution/InProcessRetryRunner.ts
1921
+ /** Maximum permitted retry attempts — workflow-declared values above this are clamped. */
1922
+ const HARD_MAX_RETRY_ATTEMPTS = 10;
1847
1923
  var InProcessRetryRunner = class InProcessRetryRunner {
1848
1924
  constructor(sleeper) {
1849
1925
  this.sleeper = sleeper;
1850
1926
  }
1851
- async run(policy, work) {
1852
- const spec = InProcessRetryRunner.normalizePolicy(policy);
1927
+ async run(policy, work, shouldRetry, warn) {
1928
+ const spec = InProcessRetryRunner.normalizePolicy(policy, warn);
1853
1929
  let lastError;
1854
1930
  for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
1855
1931
  return await work();
1856
1932
  } catch (error) {
1857
1933
  lastError = error;
1858
1934
  if (attempt >= spec.maxAttempts) break;
1935
+ if (shouldRetry !== void 0 && !shouldRetry(error)) break;
1859
1936
  const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
1860
1937
  await this.sleeper.sleep(delayMs);
1861
1938
  }
@@ -1870,7 +1947,7 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1870
1947
  if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
1871
1948
  return Math.max(0, Math.floor(ms));
1872
1949
  }
1873
- static normalizePolicy(policy) {
1950
+ static normalizePolicy(policy, warn) {
1874
1951
  if (policy === void 0) return {
1875
1952
  kind: "none",
1876
1953
  maxAttempts: 1
@@ -1886,17 +1963,19 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1886
1963
  };
1887
1964
  if (kind === "fixed") {
1888
1965
  const p = policy;
1966
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts");
1889
1967
  return {
1890
1968
  kind: "fixed",
1891
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
1969
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1892
1970
  delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
1893
1971
  };
1894
1972
  }
1895
1973
  if (kind === "exponential") {
1896
1974
  const p = policy;
1975
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts");
1897
1976
  return {
1898
1977
  kind: "exponential",
1899
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
1978
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1900
1979
  initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
1901
1980
  multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
1902
1981
  maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
@@ -1908,6 +1987,13 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1908
1987
  maxAttempts: 1
1909
1988
  };
1910
1989
  }
1990
+ static clampMaxAttempts(requested, warn) {
1991
+ if (requested > HARD_MAX_RETRY_ATTEMPTS) {
1992
+ warn?.(`Retry policy maxAttempts (${requested}) exceeds hard ceiling (${HARD_MAX_RETRY_ATTEMPTS}); clamping to ${HARD_MAX_RETRY_ATTEMPTS}.`);
1993
+ return HARD_MAX_RETRY_ATTEMPTS;
1994
+ }
1995
+ return requested;
1996
+ }
1911
1997
  static assertPositiveInt(value, label) {
1912
1998
  if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
1913
1999
  return value;
@@ -2110,12 +2196,24 @@ var NodeExecutor = class {
2110
2196
  this.outputBehaviorResolver = outputBehaviorResolver ?? new RunnableOutputBehaviorResolver();
2111
2197
  }
2112
2198
  async execute(request) {
2199
+ await this.assertRequiredCredentialsBound(request);
2113
2200
  const policy = request.ctx.config.retryPolicy;
2114
2201
  return await this.retryRunner.run(policy, async () => {
2115
2202
  const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);
2116
2203
  if (request.kind === "multi") return await this.executeMultiInputActivation(request, nodeInstance);
2117
2204
  return await this.executeSingleInputNode(request, nodeInstance);
2118
- });
2205
+ }, (error) => !this.isCredentialError(error));
2206
+ }
2207
+ async assertRequiredCredentialsBound(request) {
2208
+ if (!request.ctx.getCredential) return;
2209
+ for (const req of request.ctx.config.getCredentialRequirements?.() ?? []) {
2210
+ if (req.optional) continue;
2211
+ await request.ctx.getCredential(req.slotKey);
2212
+ }
2213
+ }
2214
+ isCredentialError(e) {
2215
+ if (e instanceof CredentialUnboundError) return true;
2216
+ return (e instanceof Error ? e.cause : void 0) instanceof CredentialUnboundError;
2119
2217
  }
2120
2218
  async executeMultiInputActivation(request, node$1) {
2121
2219
  const multiInputNode = node$1;
@@ -2425,16 +2523,20 @@ var WorkflowSnapshotCodec = class {
2425
2523
  name: workflow.name,
2426
2524
  workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
2427
2525
  ...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
2428
- nodes: workflow.nodes.map((node$1) => ({
2429
- id: node$1.id,
2430
- kind: node$1.kind,
2431
- name: node$1.name,
2432
- nodeTokenId: this.resolveTokenId(node$1.type),
2433
- configTokenId: this.resolveTokenId(node$1.config.type),
2434
- tokenName: this.resolveTokenName(node$1.type),
2435
- configTokenName: this.resolveTokenName(node$1.config.type),
2436
- config: this.serializeConfig(node$1.config)
2437
- })),
2526
+ nodes: workflow.nodes.map((node$1) => {
2527
+ const inspectorSummaryRows = this.safeInspectorSummary(node$1.config);
2528
+ return {
2529
+ id: node$1.id,
2530
+ kind: node$1.kind,
2531
+ name: node$1.name,
2532
+ nodeTokenId: this.resolveTokenId(node$1.type),
2533
+ configTokenId: this.resolveTokenId(node$1.config.type),
2534
+ tokenName: this.resolveTokenName(node$1.type),
2535
+ configTokenName: this.resolveTokenName(node$1.config.type),
2536
+ config: this.serializeConfig(node$1.config),
2537
+ ...inspectorSummaryRows !== void 0 ? { inspectorSummary: inspectorSummaryRows } : {}
2538
+ };
2539
+ }),
2438
2540
  edges: workflow.edges.map((edge) => ({
2439
2541
  from: {
2440
2542
  nodeId: edge.from.nodeId,
@@ -2474,6 +2576,34 @@ var WorkflowSnapshotCodec = class {
2474
2576
  return fallback;
2475
2577
  }
2476
2578
  }
2579
+ /**
2580
+ * Safely call `config.inspectorSummary()` and return a plain JSON-safe array, or undefined.
2581
+ * Returns undefined if the method is absent, throws, or produces no valid rows.
2582
+ */
2583
+ safeInspectorSummary(config) {
2584
+ const fn = config.inspectorSummary;
2585
+ if (typeof fn !== "function") return void 0;
2586
+ let raw;
2587
+ try {
2588
+ raw = fn.call(config);
2589
+ } catch {
2590
+ return;
2591
+ }
2592
+ if (!Array.isArray(raw)) return void 0;
2593
+ const rows = [];
2594
+ for (const entry of raw) {
2595
+ if (!entry || typeof entry !== "object") continue;
2596
+ const { label, value } = entry;
2597
+ if (typeof label !== "string" || typeof value !== "string") continue;
2598
+ const trimmedLabel = label.trim();
2599
+ if (trimmedLabel.length === 0) continue;
2600
+ rows.push({
2601
+ label: trimmedLabel,
2602
+ value
2603
+ });
2604
+ }
2605
+ return rows.length > 0 ? rows : void 0;
2606
+ }
2477
2607
  injectTokenIds(target, source) {
2478
2608
  const type = this.asTypeToken(source.type);
2479
2609
  if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
@@ -2718,6 +2848,18 @@ var NodeRunStateWriter = class {
2718
2848
  await this.publishNodeEvent("nodeFailed", snapshot);
2719
2849
  });
2720
2850
  }
2851
+ setChildRunId(args) {
2852
+ return this.enqueue(async () => {
2853
+ const state = await this.loadState();
2854
+ const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
2855
+ if (!previous) return;
2856
+ const updated = {
2857
+ ...previous,
2858
+ childRunId: args.childRunId
2859
+ };
2860
+ await this.saveSnapshot(state, updated);
2861
+ });
2862
+ }
2721
2863
  appendConnectionInvocation(args) {
2722
2864
  return this.enqueue(async () => {
2723
2865
  const state = await this.loadState();
@@ -2732,6 +2874,8 @@ var NodeRunStateWriter = class {
2732
2874
  status: args.status,
2733
2875
  managedInput: args.managedInput,
2734
2876
  managedOutput: args.managedOutput,
2877
+ statusLabel: args.statusLabel,
2878
+ subjectName: args.subjectName,
2735
2879
  error: args.error,
2736
2880
  queuedAt: args.queuedAt,
2737
2881
  startedAt: args.startedAt,
@@ -3094,7 +3238,7 @@ var RunContinuationService = class {
3094
3238
  });
3095
3239
  const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;
3096
3240
  const engineCounters = { completedNodeActivations: completedActivations };
3097
- const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3241
+ const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3098
3242
  if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {
3099
3243
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3100
3244
  state,
@@ -3418,7 +3562,7 @@ var RunContinuationService = class {
3418
3562
  });
3419
3563
  const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;
3420
3564
  const engineCounters = { completedNodeActivations: completedActivations };
3421
- const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3565
+ const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3422
3566
  if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {
3423
3567
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3424
3568
  state: args.state,
@@ -4647,25 +4791,24 @@ var InlineDrivingScheduler = class {
4647
4791
  this.scheduledRuns.delete(runId);
4648
4792
  try {
4649
4793
  const q = this.queuesByRunId.get(runId) ?? [];
4650
- while (q.length > 0) {
4651
- const { request } = q.shift();
4652
- const cont = this.continuation;
4653
- if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
4654
- await cont.markNodeRunning({
4655
- runId: request.runId,
4656
- activationId: request.activationId,
4657
- nodeId: request.nodeId,
4658
- inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
4659
- });
4660
- let outputs;
4661
- try {
4662
- outputs = await this.nodeExecutor.execute(request);
4663
- } catch (e) {
4664
- await this.resumeAfterExecutionError(cont, request, this.asError(e));
4665
- continue;
4666
- }
4667
- await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
4794
+ if (q.length === 0) return;
4795
+ const { request } = q.shift();
4796
+ const cont = this.continuation;
4797
+ if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
4798
+ await cont.markNodeRunning({
4799
+ runId: request.runId,
4800
+ activationId: request.activationId,
4801
+ nodeId: request.nodeId,
4802
+ inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
4803
+ });
4804
+ let outputs;
4805
+ try {
4806
+ outputs = await this.nodeExecutor.execute(request);
4807
+ } catch (e) {
4808
+ await this.resumeAfterExecutionError(cont, request, this.asError(e));
4809
+ return;
4668
4810
  }
4811
+ await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
4669
4812
  } finally {
4670
4813
  if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);
4671
4814
  this.drainingRuns.delete(runId);
@@ -4675,10 +4818,10 @@ var InlineDrivingScheduler = class {
4675
4818
  scheduleDrain(runId) {
4676
4819
  if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) return;
4677
4820
  this.scheduledRuns.add(runId);
4678
- setTimeout(() => {
4821
+ setImmediate(() => {
4679
4822
  this.scheduledRuns.delete(runId);
4680
4823
  this.drainRun(runId);
4681
- }, 0);
4824
+ });
4682
4825
  }
4683
4826
  async resumeAfterExecutionResult(continuation, request, outputs) {
4684
4827
  try {
@@ -4928,6 +5071,12 @@ var InMemoryBinaryStorage = class {
4928
5071
  async delete(storageKey) {
4929
5072
  this.values.delete(storageKey);
4930
5073
  }
5074
+ async deleteMany(storageKeys) {
5075
+ for (const key of storageKeys) this.values.delete(key);
5076
+ }
5077
+ async listByPrefix(prefix) {
5078
+ return Array.from(this.values.keys()).filter((key) => key.startsWith(prefix));
5079
+ }
4931
5080
  };
4932
5081
 
4933
5082
  //#endregion
@@ -6402,6 +6551,12 @@ Object.defineProperty(exports, 'MissingRuntimeTriggerToken', {
6402
6551
  return MissingRuntimeTriggerToken;
6403
6552
  }
6404
6553
  });
6554
+ Object.defineProperty(exports, 'NoOpAgentMcpIntegration', {
6555
+ enumerable: true,
6556
+ get: function () {
6557
+ return NoOpAgentMcpIntegration;
6558
+ }
6559
+ });
6405
6560
  Object.defineProperty(exports, 'NoOpCostTrackingTelemetry', {
6406
6561
  enumerable: true,
6407
6562
  get: function () {
@@ -6750,4 +6905,4 @@ Object.defineProperty(exports, 'tool', {
6750
6905
  return tool;
6751
6906
  }
6752
6907
  });
6753
- //# sourceMappingURL=runtime-DKXJwTNv.cjs.map
6908
+ //# sourceMappingURL=runtime-vH0EeZzH.cjs.map