@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
@@ -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
@@ -1366,6 +1419,20 @@ var DefaultAsyncSleeper = class {
1366
1419
  }
1367
1420
  };
1368
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
+
1369
1436
  //#endregion
1370
1437
  //#region src/contracts/emitPorts.ts
1371
1438
  const EMIT_PORTS_BRAND = Symbol.for("codemation.emitPorts");
@@ -1605,6 +1672,10 @@ var CodemationTelemetryAttributeNames = class {
1605
1672
  static iterationIndex = "codemation.iteration.index";
1606
1673
  /** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
1607
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";
1608
1679
  };
1609
1680
 
1610
1681
  //#endregion
@@ -1820,18 +1891,21 @@ var CatalogBackedCostTrackingTelemetryFactory = class {
1820
1891
 
1821
1892
  //#endregion
1822
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;
1823
1896
  var InProcessRetryRunner = class InProcessRetryRunner {
1824
1897
  constructor(sleeper) {
1825
1898
  this.sleeper = sleeper;
1826
1899
  }
1827
- async run(policy, work) {
1828
- const spec = InProcessRetryRunner.normalizePolicy(policy);
1900
+ async run(policy, work, shouldRetry, warn) {
1901
+ const spec = InProcessRetryRunner.normalizePolicy(policy, warn);
1829
1902
  let lastError;
1830
1903
  for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
1831
1904
  return await work();
1832
1905
  } catch (error) {
1833
1906
  lastError = error;
1834
1907
  if (attempt >= spec.maxAttempts) break;
1908
+ if (shouldRetry !== void 0 && !shouldRetry(error)) break;
1835
1909
  const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
1836
1910
  await this.sleeper.sleep(delayMs);
1837
1911
  }
@@ -1846,7 +1920,7 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1846
1920
  if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
1847
1921
  return Math.max(0, Math.floor(ms));
1848
1922
  }
1849
- static normalizePolicy(policy) {
1923
+ static normalizePolicy(policy, warn) {
1850
1924
  if (policy === void 0) return {
1851
1925
  kind: "none",
1852
1926
  maxAttempts: 1
@@ -1862,17 +1936,19 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1862
1936
  };
1863
1937
  if (kind === "fixed") {
1864
1938
  const p = policy;
1939
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts");
1865
1940
  return {
1866
1941
  kind: "fixed",
1867
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
1942
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1868
1943
  delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
1869
1944
  };
1870
1945
  }
1871
1946
  if (kind === "exponential") {
1872
1947
  const p = policy;
1948
+ const raw = InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts");
1873
1949
  return {
1874
1950
  kind: "exponential",
1875
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
1951
+ maxAttempts: InProcessRetryRunner.clampMaxAttempts(raw, warn),
1876
1952
  initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
1877
1953
  multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
1878
1954
  maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
@@ -1884,6 +1960,13 @@ var InProcessRetryRunner = class InProcessRetryRunner {
1884
1960
  maxAttempts: 1
1885
1961
  };
1886
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
+ }
1887
1970
  static assertPositiveInt(value, label) {
1888
1971
  if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
1889
1972
  return value;
@@ -2086,12 +2169,24 @@ var NodeExecutor = class {
2086
2169
  this.outputBehaviorResolver = outputBehaviorResolver ?? new RunnableOutputBehaviorResolver();
2087
2170
  }
2088
2171
  async execute(request) {
2172
+ await this.assertRequiredCredentialsBound(request);
2089
2173
  const policy = request.ctx.config.retryPolicy;
2090
2174
  return await this.retryRunner.run(policy, async () => {
2091
2175
  const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);
2092
2176
  if (request.kind === "multi") return await this.executeMultiInputActivation(request, nodeInstance);
2093
2177
  return await this.executeSingleInputNode(request, nodeInstance);
2094
- });
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;
2095
2190
  }
2096
2191
  async executeMultiInputActivation(request, node$1) {
2097
2192
  const multiInputNode = node$1;
@@ -2401,16 +2496,20 @@ var WorkflowSnapshotCodec = class {
2401
2496
  name: workflow.name,
2402
2497
  workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== void 0,
2403
2498
  ...workflow.connections !== void 0 && workflow.connections.length > 0 ? { connections: workflow.connections } : {},
2404
- nodes: workflow.nodes.map((node$1) => ({
2405
- id: node$1.id,
2406
- kind: node$1.kind,
2407
- name: node$1.name,
2408
- nodeTokenId: this.resolveTokenId(node$1.type),
2409
- configTokenId: this.resolveTokenId(node$1.config.type),
2410
- tokenName: this.resolveTokenName(node$1.type),
2411
- configTokenName: this.resolveTokenName(node$1.config.type),
2412
- config: this.serializeConfig(node$1.config)
2413
- })),
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
+ }),
2414
2513
  edges: workflow.edges.map((edge) => ({
2415
2514
  from: {
2416
2515
  nodeId: edge.from.nodeId,
@@ -2450,6 +2549,34 @@ var WorkflowSnapshotCodec = class {
2450
2549
  return fallback;
2451
2550
  }
2452
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
+ }
2453
2580
  injectTokenIds(target, source) {
2454
2581
  const type = this.asTypeToken(source.type);
2455
2582
  if (type) target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
@@ -2720,6 +2847,8 @@ var NodeRunStateWriter = class {
2720
2847
  status: args.status,
2721
2848
  managedInput: args.managedInput,
2722
2849
  managedOutput: args.managedOutput,
2850
+ statusLabel: args.statusLabel,
2851
+ subjectName: args.subjectName,
2723
2852
  error: args.error,
2724
2853
  queuedAt: args.queuedAt,
2725
2854
  startedAt: args.startedAt,
@@ -3082,7 +3211,7 @@ var RunContinuationService = class {
3082
3211
  });
3083
3212
  const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;
3084
3213
  const engineCounters = { completedNodeActivations: completedActivations };
3085
- const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3214
+ const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3086
3215
  if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {
3087
3216
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3088
3217
  state,
@@ -3406,7 +3535,7 @@ var RunContinuationService = class {
3406
3535
  });
3407
3536
  const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;
3408
3537
  const engineCounters = { completedNodeActivations: completedActivations };
3409
- const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
3538
+ const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? this.executionLimitsPolicy.createRootExecutionOptions().maxNodeActivations;
3410
3539
  if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {
3411
3540
  const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
3412
3541
  state: args.state,
@@ -4635,25 +4764,24 @@ var InlineDrivingScheduler = class {
4635
4764
  this.scheduledRuns.delete(runId);
4636
4765
  try {
4637
4766
  const q = this.queuesByRunId.get(runId) ?? [];
4638
- while (q.length > 0) {
4639
- const { request } = q.shift();
4640
- const cont = this.continuation;
4641
- if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
4642
- await cont.markNodeRunning({
4643
- runId: request.runId,
4644
- activationId: request.activationId,
4645
- nodeId: request.nodeId,
4646
- inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
4647
- });
4648
- let outputs;
4649
- try {
4650
- outputs = await this.nodeExecutor.execute(request);
4651
- } catch (e) {
4652
- await this.resumeAfterExecutionError(cont, request, this.asError(e));
4653
- continue;
4654
- }
4655
- 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;
4656
4783
  }
4784
+ await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
4657
4785
  } finally {
4658
4786
  if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);
4659
4787
  this.drainingRuns.delete(runId);
@@ -4663,10 +4791,10 @@ var InlineDrivingScheduler = class {
4663
4791
  scheduleDrain(runId) {
4664
4792
  if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) return;
4665
4793
  this.scheduledRuns.add(runId);
4666
- setTimeout(() => {
4794
+ setImmediate(() => {
4667
4795
  this.scheduledRuns.delete(runId);
4668
4796
  this.drainRun(runId);
4669
- }, 0);
4797
+ });
4670
4798
  }
4671
4799
  async resumeAfterExecutionResult(continuation, request, outputs) {
4672
4800
  try {
@@ -4916,6 +5044,12 @@ var InMemoryBinaryStorage = class {
4916
5044
  async delete(storageKey) {
4917
5045
  this.values.delete(storageKey);
4918
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
+ }
4919
5053
  };
4920
5054
 
4921
5055
  //#endregion
@@ -6144,5 +6278,5 @@ var WorkflowRepositoryWebhookTriggerMatcherFactory = class {
6144
6278
  };
6145
6279
 
6146
6280
  //#endregion
6147
- export { NoOpCostTrackingTelemetryFactory as $, singleton as $t, PersistedWorkflowTokenRegistry as A, AgentConfigInspector as At, DefaultExecutionContextFactory as B, InjectableRuntimeDecoratorComposer as Bt, DefaultDrivingScheduler as C, WorkflowBuilder as Ct, NodeInstanceFactoryFactory as D, WhenBuilder as Dt, StaticCostCatalog as E, ChainCursor as Et, RunnableOutputBehaviorResolver as F, NodeBackedToolConfig as Ft, CodemationTelemetryAttributeNames as G, delay as Gt, nodeRef as H, StackTraceCallSitePathResolver as Ht, NodeOutputNormalizer as I, chatModel as It, NoOpExecutionTelemetryFactory as J, injectable as Jt, AllWorkflowsActiveWorkflowActivationPolicy as K, inject as Kt, ItemExprResolver as L, getPersistedRuntimeTypeMetadata as Lt, NodeExecutorFactory as M, itemExpr as Mt, NodeExecutor as N, resolveItemExprsForExecution as Nt, NodeInstanceFactory as O, AgentConnectionNodeCollector as Ot, InProcessRetryRunnerFactory as P, resolveItemExprsInUnknown as Pt, NoOpTelemetryArtifactReference as Q, registry as Qt, InProcessRetryRunner as R, node as Rt, HintOnlyOffloadPolicy as S, ConnectionInvocationIdFactory as St, RunPolicySnapshotFactory as T, NodeIdSlugifier as Tt, CodemationTelemetryMetricNames as U, PersistedRuntimeTypeNameResolver as Ut, branchRef as V, PersistedRuntimeTypeMetadataStore as Vt, GenAiTelemetryAttributeNames as W, container$1 as Wt, NoOpNodeExecutionTelemetry as X, instancePerContainerCachingFactory as Xt, NoOpExecutionTelemetry as Y, instanceCachingFactory as Yt, NoOpTelemetrySpanScope as Z, predicateAwareClassFactory as Zt, RunTerminalPersistenceCoordinator as _, ConnectionInvocationEventPublisher as _t, InMemoryLiveWorkflowRepository as a, RetryPolicy as at, LocalOnlyScheduler as b, WorkflowExecutableNodeClassifier as bt, EngineFactory as c, isPortsEmission as ct, PollingTriggerRuntime as d, CredentialResolverFactory as dt, CoreTokens as en, NoOpCostTrackingTelemetry as et, PollingTriggerDedupWindow as f, getOriginIndexFromItem as ft, WorkflowPolicyErrorServices as g, NodeEventPublisher as gt, WorkflowStoragePolicyEvaluator as h, UnavailableBinaryStorage as ht, RunIntentService as i, ExpRetryPolicy as it, MissingRuntimeTriggerToken as j, isItemExpr as jt, WorkflowSnapshotCodec as k, ConnectionNodeIdFactory as kt, Engine as l, isUnbrandedPortsEmissionShape as lt, InMemoryBinaryStorage as m, DefaultExecutionBinaryService as mt, WorkflowRepositoryWebhookTriggerMatcher as n, CostTrackingTelemetryMetricNames as nt, EngineWorkflowRunnerServiceFactory as o, NoRetryPolicy as ot, InMemoryRunDataFactory as p, ChildExecutionScopeFactory as pt, RunFinishedAtFactory as q, injectAll as qt, RunIntentServiceFactory as r, CredentialUnboundError as rt, EngineWorkflowRunnerService as s, emitPorts as st, WorkflowRepositoryWebhookTriggerMatcherFactory as t, CostTrackingTelemetryAttributeNames as tt, NoOpPollingTriggerLogger as u, DefaultAsyncSleeper as ut, ENGINE_EXECUTION_LIMITS_DEFAULTS as v, DefaultWorkflowGraphFactory as vt, ConfigDrivenOffloadPolicy as w, WorkflowDefinitionError as wt, InlineDrivingScheduler as x, NodeIterationIdFactory as xt, EngineExecutionLimitsPolicy as y, WorkflowExecutableNodeClassifierFactory as yt, CatalogBackedCostTrackingTelemetryFactory as z, tool as zt };
6148
- //# sourceMappingURL=runtime-DbMjpb5d.js.map
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