@codemation/core 0.10.2 → 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 (66) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/dist/{EngineRuntimeRegistration.types-ClLuY1FG.d.ts → EngineRuntimeRegistration.types-BZ_1XWAJ.d.ts} +2 -2
  3. package/dist/{EngineRuntimeRegistration.types-BryWi2mA.d.cts → EngineRuntimeRegistration.types-MPYWsEM0.d.cts} +7 -2
  4. package/dist/{InMemoryRunDataFactory-DeXNJt1O.d.cts → InMemoryRunDataFactory-hmkh0lzR.d.cts} +8 -3
  5. package/dist/{RunIntentService-CI-F8qQ7.d.ts → RunIntentService-BrEq6Jm6.d.ts} +1536 -1358
  6. package/dist/{RunIntentService-BqNjrksF.d.cts → RunIntentService-MUHJ1bhO.d.cts} +1713 -1603
  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-BfFKGzyj.js → bootstrap-Dgzsjoj7.js} +7 -2
  12. package/dist/bootstrap-Dgzsjoj7.js.map +1 -0
  13. package/dist/{bootstrap-DtjQtuvi.cjs → bootstrap-dVmpU1ju.cjs} +7 -2
  14. package/dist/bootstrap-dVmpU1ju.cjs.map +1 -0
  15. package/dist/{index-CJQtTY_M.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 +168 -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-DbMjpb5d.js → runtime-Duf3ClPw.js} +184 -50
  23. package/dist/runtime-Duf3ClPw.js.map +1 -0
  24. package/dist/{runtime-_ywksLa6.cjs → runtime-vH0EeZzH.cjs} +190 -50
  25. package/dist/runtime-vH0EeZzH.cjs.map +1 -0
  26. package/dist/testing.cjs +2 -2
  27. package/dist/testing.d.cts +3 -3
  28. package/dist/testing.d.ts +2 -2
  29. package/dist/testing.js +2 -2
  30. package/package.json +4 -13
  31. package/src/ai/AgentConnectionNodeCollector.ts +47 -5
  32. package/src/authoring/defineNode.types.ts +21 -1
  33. package/src/authoring/definePollingTrigger.types.ts +20 -0
  34. package/src/binaries/UnavailableBinaryStorage.ts +6 -0
  35. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
  36. package/src/browser.ts +1 -0
  37. package/src/contracts/AgentBindError.ts +11 -0
  38. package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
  39. package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
  40. package/src/contracts/agentMcpTypes.ts +64 -0
  41. package/src/contracts/index.ts +4 -0
  42. package/src/contracts/mcpTypes.ts +29 -0
  43. package/src/contracts/runTypes.ts +8 -0
  44. package/src/contracts/runtimeTypes.ts +4 -0
  45. package/src/contracts/workflowTypes.ts +21 -0
  46. package/src/contracts.ts +3 -0
  47. package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
  48. package/src/di/CoreTokens.ts +7 -0
  49. package/src/execution/InProcessRetryRunner.ts +31 -5
  50. package/src/execution/NodeExecutor.ts +27 -7
  51. package/src/execution/NodeRunStateWriter.ts +2 -0
  52. package/src/index.ts +10 -0
  53. package/src/orchestration/RunContinuationService.ts +6 -2
  54. package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
  55. package/src/scheduler/InlineDrivingScheduler.ts +26 -22
  56. package/src/types/index.ts +1 -0
  57. package/src/validation/WorkflowEdgePortError.types.ts +16 -0
  58. package/src/validation/WorkflowEdgePortValidator.ts +52 -0
  59. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
  60. package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
  61. package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
  62. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
  63. package/dist/bootstrap-BfFKGzyj.js.map +0 -1
  64. package/dist/bootstrap-DtjQtuvi.cjs.map +0 -1
  65. package/dist/runtime-DbMjpb5d.js.map +0 -1
  66. package/dist/runtime-_ywksLa6.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
@@ -1393,6 +1446,20 @@ var DefaultAsyncSleeper = class {
1393
1446
  }
1394
1447
  };
1395
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
+
1396
1463
  //#endregion
1397
1464
  //#region src/contracts/emitPorts.ts
1398
1465
  const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
@@ -1632,6 +1699,10 @@ var CodemationTelemetryAttributeNames = class {
1632
1699
  static iterationIndex = "codemation.iteration.index";
1633
1700
  /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
1634
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";
1635
1706
  };
1636
1707
 
1637
1708
  //#endregion
@@ -1847,18 +1918,21 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
1847
1918
 
1848
1919
  //#endregion
1849
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;
1850
1923
  var InProcessRetryRunner = class InProcessRetryRunner {
1851
1924
  constructor(sleeper) {
1852
1925
  this.sleeper = sleeper;
1853
1926
  }
1854
- async run(policy, work) {
1855
- const spec = InProcessRetryRunner.normalizePolicy(policy);
1927
+ async run(policy, work, shouldRetry, warn) {
1928
+ const spec = InProcessRetryRunner.normalizePolicy(policy, warn);
1856
1929
  let lastError;
1857
1930
  for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
1858
1931
  return await work();
1859
1932
  } catch (error) {
1860
1933
  lastError = error;
1861
1934
  if (attempt >= spec.maxAttempts) break;
1935
+ if (shouldRetry !== void 0 && !shouldRetry(error)) break;
1862
1936
  const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
1863
1937
  await this.sleeper.sleep(delayMs);
1864
1938
  }
@@ -1873,7 +1947,7 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1873
1947
  if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
1874
1948
  return Math.max(0, Math.floor(ms));
1875
1949
  }
1876
- static normalizePolicy(policy) {
1950
+ static normalizePolicy(policy, warn) {
1877
1951
  if (policy === void 0) return {
1878
1952
  kind: "none",
1879
1953
  maxAttempts: 1
@@ -1889,17 +1963,19 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1889
1963
  };
1890
1964
  if (kind === "fixed") {
1891
1965
  const p = policy;
1966
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts");
1892
1967
  return {
1893
1968
  kind: "fixed",
1894
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
1969
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1895
1970
  delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
1896
1971
  };
1897
1972
  }
1898
1973
  if (kind === "exponential") {
1899
1974
  const p = policy;
1975
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts");
1900
1976
  return {
1901
1977
  kind: "exponential",
1902
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
1978
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1903
1979
  initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
1904
1980
  multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
1905
1981
  maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
@@ -1911,6 +1987,13 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1911
1987
  maxAttempts: 1
1912
1988
  };
1913
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
+ }
1914
1997
  static assertPositiveInt(value, label) {
1915
1998
  if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
1916
1999
  return value;
@@ -2113,12 +2196,24 @@ var NodeExecutor = class {
2113
2196
  this.outputBehaviorResolver = outputBehaviorResolver ?? new RunnableOutputBehaviorResolver();
2114
2197
  }
2115
2198
  async execute(request) {
2199
+ await this.assertRequiredCredentialsBound(request);
2116
2200
  const policy = request.ctx.config.retryPolicy;
2117
2201
  return await this.retryRunner.run(policy, async () => {
2118
2202
  const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);
2119
2203
  if (request.kind === "multi") return await this.executeMultiInputActivation(request, nodeInstance);
2120
2204
  return await this.executeSingleInputNode(request, nodeInstance);
2121
- });
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;
2122
2217
  }
2123
2218
  async executeMultiInputActivation(request, node$1) {
2124
2219
  const multiInputNode = node$1;
@@ -2428,16 +2523,20 @@ var WorkflowSnapshotCodec = class {
2428
2523
  name: workflow.name,
2429
2524
  workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
2430
2525
  ...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
2431
- nodes: workflow.nodes.map((node$1) => ({
2432
- id: node$1.id,
2433
- kind: node$1.kind,
2434
- name: node$1.name,
2435
- nodeTokenId: this.resolveTokenId(node$1.type),
2436
- configTokenId: this.resolveTokenId(node$1.config.type),
2437
- tokenName: this.resolveTokenName(node$1.type),
2438
- configTokenName: this.resolveTokenName(node$1.config.type),
2439
- config: this.serializeConfig(node$1.config)
2440
- })),
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
+ }),
2441
2540
  edges: workflow.edges.map((edge) => ({
2442
2541
  from: {
2443
2542
  nodeId: edge.from.nodeId,
@@ -2477,6 +2576,34 @@ var WorkflowSnapshotCodec = class {
2477
2576
  return fallback;
2478
2577
  }
2479
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
+ }
2480
2607
  injectTokenIds(target, source) {
2481
2608
  const type = this.asTypeToken(source.type);
2482
2609
  if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
@@ -2747,6 +2874,8 @@ var NodeRunStateWriter = class {
2747
2874
  status: args.status,
2748
2875
  managedInput: args.managedInput,
2749
2876
  managedOutput: args.managedOutput,
2877
+ statusLabel: args.statusLabel,
2878
+ subjectName: args.subjectName,
2750
2879
  error: args.error,
2751
2880
  queuedAt: args.queuedAt,
2752
2881
  startedAt: args.startedAt,
@@ -3109,7 +3238,7 @@ var RunContinuationService = class {
3109
3238
  });
3110
3239
  const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;
3111
3240
  const engineCounters = { completedNodeActivations: completedActivations };
3112
- const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3241
+ const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3113
3242
  if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {
3114
3243
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3115
3244
  state,
@@ -3433,7 +3562,7 @@ var RunContinuationService = class {
3433
3562
  });
3434
3563
  const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;
3435
3564
  const engineCounters = { completedNodeActivations: completedActivations };
3436
- const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3565
+ const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3437
3566
  if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {
3438
3567
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3439
3568
  state: args.state,
@@ -4662,25 +4791,24 @@ var InlineDrivingScheduler = class {
4662
4791
  this.scheduledRuns.delete(runId);
4663
4792
  try {
4664
4793
  const q = this.queuesByRunId.get(runId) ?? [];
4665
- while (q.length > 0) {
4666
- const { request } = q.shift();
4667
- const cont = this.continuation;
4668
- if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
4669
- await cont.markNodeRunning({
4670
- runId: request.runId,
4671
- activationId: request.activationId,
4672
- nodeId: request.nodeId,
4673
- inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
4674
- });
4675
- let outputs;
4676
- try {
4677
- outputs = await this.nodeExecutor.execute(request);
4678
- } catch (e) {
4679
- await this.resumeAfterExecutionError(cont, request, this.asError(e));
4680
- continue;
4681
- }
4682
- 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;
4683
4810
  }
4811
+ await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
4684
4812
  } finally {
4685
4813
  if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);
4686
4814
  this.drainingRuns.delete(runId);
@@ -4690,10 +4818,10 @@ var InlineDrivingScheduler = class {
4690
4818
  scheduleDrain(runId) {
4691
4819
  if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) return;
4692
4820
  this.scheduledRuns.add(runId);
4693
- setTimeout(() => {
4821
+ setImmediate(() => {
4694
4822
  this.scheduledRuns.delete(runId);
4695
4823
  this.drainRun(runId);
4696
- }, 0);
4824
+ });
4697
4825
  }
4698
4826
  async resumeAfterExecutionResult(continuation, request, outputs) {
4699
4827
  try {
@@ -4943,6 +5071,12 @@ var InMemoryBinaryStorage = class {
4943
5071
  async delete(storageKey) {
4944
5072
  this.values.delete(storageKey);
4945
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
+ }
4946
5080
  };
4947
5081
 
4948
5082
  //#endregion
@@ -6417,6 +6551,12 @@ Object.defineProperty(exports, 'MissingRuntimeTriggerToken', {
6417
6551
  return MissingRuntimeTriggerToken;
6418
6552
  }
6419
6553
  });
6554
+ Object.defineProperty(exports, 'NoOpAgentMcpIntegration', {
6555
+ enumerable: true,
6556
+ get: function () {
6557
+ return NoOpAgentMcpIntegration;
6558
+ }
6559
+ });
6420
6560
  Object.defineProperty(exports, 'NoOpCostTrackingTelemetry', {
6421
6561
  enumerable: true,
6422
6562
  get: function () {
@@ -6765,4 +6905,4 @@ Object.defineProperty(exports, 'tool', {
6765
6905
  return tool;
6766
6906
  }
6767
6907
  });
6768
- //# sourceMappingURL=runtime-_ywksLa6.cjs.map
6908
+ //# sourceMappingURL=runtime-vH0EeZzH.cjs.map