@codemation/core 1.0.1 → 2.0.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 (86) hide show
  1. package/CHANGELOG.md +293 -0
  2. package/dist/{EngineRuntimeRegistration.types-kxQA5NLt.d.ts → EngineRuntimeRegistration.types-D1fyApMI.d.ts} +2 -2
  3. package/dist/{EngineWorkflowRunnerService-Ba2AvBnL.d.cts → EngineRuntimeRegistration.types-pB3FnzqR.d.cts} +17 -17
  4. package/dist/{InMemoryRunDataFactory-Ou4tQUOS.d.cts → InMemoryRunDataFactory-Xw7v4-sj.d.cts} +31 -29
  5. package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs +47 -0
  6. package/dist/InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map +1 -0
  7. package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js +41 -0
  8. package/dist/InMemoryRunEventBusRegistry-sM4z4n_i.js.map +1 -0
  9. package/dist/{RunIntentService-dteLjNiT.d.ts → RunIntentService-BE9CAkbf.d.ts} +602 -213
  10. package/dist/{RunIntentService-Dyh_dH0k.d.cts → RunIntentService-siBSjaaY.d.cts} +430 -125
  11. package/dist/bootstrap/index.cjs +5 -2
  12. package/dist/bootstrap/index.d.cts +212 -135
  13. package/dist/bootstrap/index.d.ts +4 -4
  14. package/dist/bootstrap/index.js +3 -3
  15. package/dist/{bootstrap-Cko6udwL.cjs → bootstrap-Cm5ruQxx.cjs} +253 -3
  16. package/dist/bootstrap-Cm5ruQxx.cjs.map +1 -0
  17. package/dist/{bootstrap-CL68rqWg.js → bootstrap-D3r505ko.js} +236 -4
  18. package/dist/bootstrap-D3r505ko.js.map +1 -0
  19. package/dist/{index-CyfGTfU1.d.ts → index-DeLl1Tne.d.ts} +574 -242
  20. package/dist/index.cjs +328 -180
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +441 -103
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +305 -163
  25. package/dist/index.js.map +1 -1
  26. package/dist/{runtime-284ok0cm.js → runtime-BGNbRnqs.js} +764 -75
  27. package/dist/runtime-BGNbRnqs.js.map +1 -0
  28. package/dist/{runtime-B3Og-_St.cjs → runtime-DKXJwTNv.cjs} +841 -80
  29. package/dist/runtime-DKXJwTNv.cjs.map +1 -0
  30. package/dist/testing.cjs +4 -4
  31. package/dist/testing.cjs.map +1 -1
  32. package/dist/testing.d.cts +2 -2
  33. package/dist/testing.d.ts +2 -2
  34. package/dist/testing.js +3 -3
  35. package/package.json +7 -2
  36. package/src/authoring/DefinedCollectionRegistry.ts +17 -0
  37. package/src/authoring/defineCollection.types.ts +181 -0
  38. package/src/authoring/definePollingTrigger.types.ts +396 -0
  39. package/src/authoring/definePollingTriggerInternals.ts +74 -0
  40. package/src/authoring/index.ts +19 -0
  41. package/src/bootstrap/index.ts +9 -0
  42. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +5 -1
  43. package/src/contracts/assertionTypes.ts +63 -0
  44. package/src/contracts/baseTypes.ts +12 -0
  45. package/src/contracts/collectionTypes.ts +44 -0
  46. package/src/contracts/credentialTypes.ts +23 -1
  47. package/src/contracts/index.ts +4 -0
  48. package/src/contracts/runTypes.ts +27 -1
  49. package/src/contracts/runtimeTypes.ts +34 -0
  50. package/src/contracts/testTriggerTypes.ts +66 -0
  51. package/src/contracts/workflowTypes.ts +30 -7
  52. package/src/contracts.ts +59 -0
  53. package/src/events/runEvents.ts +49 -0
  54. package/src/execution/ChildExecutionScopeFactory.ts +4 -7
  55. package/src/execution/DefaultExecutionContextFactory.ts +6 -0
  56. package/src/execution/NodeInstanceFactory.ts +13 -1
  57. package/src/execution/NodeInstantiationError.ts +16 -0
  58. package/src/execution/WorkflowRunExecutionContextFactory.ts +3 -0
  59. package/src/execution/index.ts +1 -0
  60. package/src/index.ts +7 -0
  61. package/src/orchestration/AbortControllerFactory.ts +9 -0
  62. package/src/orchestration/NodeExecutionRequestHandlerService.ts +1 -0
  63. package/src/orchestration/RunContinuationService.ts +3 -0
  64. package/src/orchestration/RunStartService.ts +114 -2
  65. package/src/orchestration/TestSuiteOrchestrator.ts +350 -0
  66. package/src/orchestration/TestSuiteRunIdFactory.ts +11 -0
  67. package/src/orchestration/TriggerRuntimeService.ts +34 -7
  68. package/src/orchestration/index.ts +9 -0
  69. package/src/runtime/EngineFactory.ts +11 -0
  70. package/src/triggers/polling/PollingTriggerDedupWindow.ts +23 -0
  71. package/src/triggers/polling/PollingTriggerLogger.ts +18 -0
  72. package/src/triggers/polling/PollingTriggerRuntime.ts +122 -0
  73. package/src/triggers/polling/index.ts +5 -0
  74. package/src/types/index.ts +12 -9
  75. package/src/workflow/dsl/NodeIdSlugifier.ts +18 -0
  76. package/src/workflow/dsl/WorkflowBuilder.ts +71 -3
  77. package/src/workflow/dsl/WorkflowDefinitionError.ts +15 -0
  78. package/src/workflow/index.ts +2 -0
  79. package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs +0 -262
  80. package/dist/InMemoryRunEventBusRegistry-B0_C4OnP.cjs.map +0 -1
  81. package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js +0 -238
  82. package/dist/InMemoryRunEventBusRegistry-C2U83Hmv.js.map +0 -1
  83. package/dist/bootstrap-CL68rqWg.js.map +0 -1
  84. package/dist/bootstrap-Cko6udwL.cjs.map +0 -1
  85. package/dist/runtime-284ok0cm.js.map +0 -1
  86. package/dist/runtime-B3Og-_St.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
- const require_runtime = require('./runtime-B3Og-_St.cjs');
2
- const require_InMemoryRunEventBusRegistry = require('./InMemoryRunEventBusRegistry-B0_C4OnP.cjs');
1
+ const require_runtime = require('./runtime-DKXJwTNv.cjs');
2
+ const require_InMemoryRunEventBusRegistry = require('./InMemoryRunEventBusRegistry-VM3OWnHo.cjs');
3
3
  let zod = require("zod");
4
4
  zod = require_runtime.__toESM(zod);
5
- let node_crypto = require("node:crypto");
6
- node_crypto = require_runtime.__toESM(node_crypto);
7
5
  let tsyringe = require("tsyringe");
8
6
  tsyringe = require_runtime.__toESM(tsyringe);
9
7
 
@@ -28,7 +26,7 @@ var DefinedNodeRegistry = class {
28
26
 
29
27
  //#endregion
30
28
  //#region src/authoring/defineNode.types.ts
31
- const definedNodeCredentialRequirementFactory = {
29
+ const definedNodeCredentialRequirementFactory$1 = {
32
30
  create(bindings) {
33
31
  if (!bindings) return [];
34
32
  return Object.entries(bindings).map(([slotKey, binding]) => {
@@ -58,13 +56,13 @@ const definedNodeCredentialRequirementFactory = {
58
56
  return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (character) => character.toUpperCase());
59
57
  }
60
58
  };
61
- const definedNodeCredentialAccessorFactory = { create(bindings, ctx) {
59
+ const definedNodeCredentialAccessorFactory$1 = { create(bindings, ctx) {
62
60
  if (!bindings) return {};
63
61
  const entries = Object.keys(bindings).map((slotKey) => [slotKey, () => ctx.getCredential(slotKey)]);
64
62
  return Object.fromEntries(entries);
65
63
  } };
66
64
  function defineNode(options) {
67
- const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
65
+ const credentialRequirements = definedNodeCredentialRequirementFactory$1.create(options.credentials);
68
66
  const DefinedNodeRuntime = class {
69
67
  kind = "node";
70
68
  outputPorts = ["main"];
@@ -73,7 +71,7 @@ function defineNode(options) {
73
71
  const ctx = args.ctx;
74
72
  const context = {
75
73
  config: ctx.config.config,
76
- credentials: definedNodeCredentialAccessorFactory.create(options.credentials, ctx),
74
+ credentials: definedNodeCredentialAccessorFactory$1.create(options.credentials, ctx),
77
75
  execution: ctx
78
76
  };
79
77
  const payload = {
@@ -119,7 +117,7 @@ function defineNode(options) {
119
117
  return definition;
120
118
  }
121
119
  function defineBatchNode(options) {
122
- const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
120
+ const credentialRequirements = definedNodeCredentialRequirementFactory$1.create(options.credentials);
123
121
  const DefinedNodeRuntime = class {
124
122
  kind = "node";
125
123
  outputPorts = ["main"];
@@ -128,7 +126,7 @@ function defineBatchNode(options) {
128
126
  const ctx = args.ctx;
129
127
  const context = {
130
128
  config: ctx.config.config,
131
- credentials: definedNodeCredentialAccessorFactory.create(options.credentials, ctx),
129
+ credentials: definedNodeCredentialAccessorFactory$1.create(options.credentials, ctx),
132
130
  execution: ctx
133
131
  };
134
132
  return [...await options.run(args.items.map((item) => item.json), context)];
@@ -336,84 +334,295 @@ function callableTool(options) {
336
334
  }
337
335
 
338
336
  //#endregion
339
- //#region src/ai/NodeBackedToolConfig.ts
340
- var NodeBackedToolConfig = class {
341
- type;
342
- toolKind = "nodeBacked";
343
- description;
344
- presentation;
345
- inputSchemaValue;
346
- outputSchemaValue;
347
- mapInputValue;
348
- mapOutputValue;
349
- constructor(name, node$1, options) {
350
- this.name = name;
351
- this.node = node$1;
352
- this.type = node$1.type;
353
- this.description = options.description;
354
- this.presentation = options.presentation;
355
- this.inputSchemaValue = options.inputSchema;
356
- this.outputSchemaValue = options.outputSchema;
357
- this.mapInputValue = options.mapInput;
358
- this.mapOutputValue = options.mapOutput;
337
+ //#region src/authoring/DefinedCollectionRegistry.ts
338
+ var DefinedCollectionRegistry = class {
339
+ static definitions = /* @__PURE__ */ new Map();
340
+ static register(definition) {
341
+ this.definitions.set(definition.name, definition);
359
342
  }
360
- getCredentialRequirements() {
361
- return this.node.getCredentialRequirements?.() ?? [];
343
+ static resolve(name) {
344
+ return this.definitions.get(name);
362
345
  }
363
- getInputSchema() {
364
- return this.inputSchemaValue;
346
+ static list() {
347
+ return Array.from(this.definitions.values());
365
348
  }
366
- getOutputSchema() {
367
- return this.outputSchemaValue;
349
+ };
350
+
351
+ //#endregion
352
+ //#region src/authoring/defineCollection.types.ts
353
+ var CollectionColumnBuilderImpl = class {
354
+ _nullable;
355
+ _default;
356
+ constructor(_type) {
357
+ this._type = _type;
358
+ this._nullable = true;
359
+ }
360
+ notNull() {
361
+ this._nullable = false;
362
+ return this;
363
+ }
364
+ default(value) {
365
+ this._default = value;
366
+ this._nullable = false;
367
+ return this;
368
368
  }
369
- toNodeItem(args) {
370
- const mapped = this.mapInputValue?.(args) ?? args.input;
371
- if (this.isItem(mapped)) return mapped;
372
- return { json: mapped };
369
+ };
370
+ const c = {
371
+ text() {
372
+ return new CollectionColumnBuilderImpl("text");
373
+ },
374
+ int() {
375
+ return new CollectionColumnBuilderImpl("int");
376
+ },
377
+ bigint() {
378
+ return new CollectionColumnBuilderImpl("bigint");
379
+ },
380
+ double() {
381
+ return new CollectionColumnBuilderImpl("double");
382
+ },
383
+ bool() {
384
+ return new CollectionColumnBuilderImpl("bool");
385
+ },
386
+ timestamptz() {
387
+ return new CollectionColumnBuilderImpl("timestamptz");
388
+ },
389
+ jsonb() {
390
+ return new CollectionColumnBuilderImpl("jsonb");
391
+ },
392
+ uuid() {
393
+ return new CollectionColumnBuilderImpl("uuid");
373
394
  }
374
- toToolOutput(args) {
375
- const raw = this.mapOutputValue?.(args) ?? this.readDefaultToolOutput(args.outputs);
376
- return this.outputSchemaValue.parse(raw);
395
+ };
396
+ /**
397
+ * Validates that a name follows the required pattern: lowercase + underscores, starts with letter.
398
+ */
399
+ function validateCollectionName(name) {
400
+ if (!/^[a-z][a-z0-9_]*$/.test(name)) throw new Error(`Collection name "${name}" must start with a lowercase letter and contain only lowercase letters, digits, and underscores.`);
401
+ }
402
+ /**
403
+ * Validates that all field names follow the required pattern.
404
+ */
405
+ function validateFieldNames(fields) {
406
+ const pattern = /^[a-z][a-z0-9_]*$/;
407
+ const reserved = [
408
+ "id",
409
+ "created_at",
410
+ "updated_at"
411
+ ];
412
+ for (const fieldName of Object.keys(fields)) {
413
+ if (reserved.includes(fieldName)) throw new Error(`Field name "${fieldName}" is reserved for internal use.`);
414
+ if (!pattern.test(fieldName)) throw new Error(`Field name "${fieldName}" must start with a lowercase letter and contain only lowercase letters, digits, and underscores.`);
377
415
  }
378
- readDefaultToolOutput(outputs) {
379
- const firstMainItem = outputs.main?.[0];
380
- if (!firstMainItem) throw new Error(`Node-backed tool "${this.name}" did not produce a main output item.`);
381
- return firstMainItem.json;
416
+ }
417
+ /**
418
+ * Validates that all indexed fields exist in the declared fields.
419
+ */
420
+ function validateIndexes(indexes, fieldNames) {
421
+ for (const index of indexes) for (const fieldName of index.on) if (!fieldNames.has(fieldName)) throw new Error(`Index references non-existent field "${fieldName}".`);
422
+ }
423
+ function defineCollection(options) {
424
+ validateCollectionName(options.name);
425
+ const fields = {};
426
+ for (const [fieldName, builder] of Object.entries(options.fields)) {
427
+ const columnBuilder = builder;
428
+ fields[fieldName] = {
429
+ type: columnBuilder._type,
430
+ nullable: columnBuilder._nullable,
431
+ default: columnBuilder._default
432
+ };
382
433
  }
383
- isItem(value) {
384
- return typeof value === "object" && value !== null && "json" in value;
434
+ validateFieldNames(fields);
435
+ const fieldNames = new Set(Object.keys(fields));
436
+ const indexes = options.indexes ?? [];
437
+ validateIndexes(indexes, fieldNames);
438
+ const definition = {
439
+ name: options.name,
440
+ fields,
441
+ indexes
442
+ };
443
+ DefinedCollectionRegistry.register(definition);
444
+ return {
445
+ kind: "defined-collection",
446
+ definition,
447
+ register(context) {
448
+ context.registerCollection(definition);
449
+ }
450
+ };
451
+ }
452
+
453
+ //#endregion
454
+ //#region src/authoring/definePollingTriggerInternals.ts
455
+ const definedNodeCredentialRequirementFactory = {
456
+ create(bindings) {
457
+ if (!bindings) return [];
458
+ return Object.entries(bindings).map(([slotKey, binding]) => {
459
+ if (typeof binding === "string" || this.isCredentialType(binding)) return {
460
+ slotKey,
461
+ label: this.humanize(slotKey),
462
+ acceptedTypes: [this.resolveTypeId(binding)]
463
+ };
464
+ const types = Array.isArray(binding.type) ? binding.type : [binding.type];
465
+ return {
466
+ slotKey,
467
+ label: binding.label ?? this.humanize(slotKey),
468
+ acceptedTypes: types.map((entry) => this.resolveTypeId(entry)),
469
+ optional: binding.optional,
470
+ helpText: binding.helpText,
471
+ helpUrl: binding.helpUrl
472
+ };
473
+ });
474
+ },
475
+ isCredentialType(value) {
476
+ return Boolean(value) && typeof value === "object" && "definition" in value && typeof value.definition?.typeId === "string";
477
+ },
478
+ resolveTypeId(type) {
479
+ return typeof type === "string" ? type : type.definition.typeId;
480
+ },
481
+ humanize(key) {
482
+ return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (character) => character.toUpperCase());
385
483
  }
386
484
  };
485
+ const definedNodeCredentialAccessorFactory = { create(bindings, ctx) {
486
+ if (!bindings) return {};
487
+ const entries = Object.keys(bindings).map((slotKey) => [slotKey, () => ctx.getCredential(slotKey)]);
488
+ return Object.fromEntries(entries);
489
+ } };
387
490
 
388
491
  //#endregion
389
- //#region src/ai/AgentConfigInspectorFactory.ts
390
- var AgentConfigInspector = class {
391
- static isAgentNodeConfig(config) {
392
- if (!config) return false;
393
- const candidate = config;
394
- return !!candidate.chatModel && this.hasCompatibleMessageConfiguration(candidate);
395
- }
396
- static hasCompatibleMessageConfiguration(candidate) {
397
- const messages = candidate.messages;
398
- if (messages === void 0 || messages === null) return false;
399
- if (Array.isArray(messages)) return messages.length > 0;
400
- if (typeof messages === "object") {
401
- if (require_runtime.isItemExpr(messages)) return true;
402
- const o = messages;
403
- return Array.isArray(o.prompt) && o.prompt.length > 0 || typeof o.buildMessages === "function";
404
- }
405
- return false;
492
+ //#region src/authoring/definePollingTrigger.types.ts
493
+ /**
494
+ * TriggerNodeConfig produced by `DefinedPollingTrigger.create(...)`.
495
+ * Holds user configuration and credential requirements for the engine.
496
+ * The setup state type is opaque `JsonValue | undefined` — the runtime
497
+ * uses an internal wrapped shape that plugin authors never see.
498
+ */
499
+ var DefinedPollingTriggerConfig = class {
500
+ kind = "trigger";
501
+ type;
502
+ icon;
503
+ constructor(name, cfg, typeToken, icon, credentialRequirements, id) {
504
+ this.name = name;
505
+ this.cfg = cfg;
506
+ this.credentialRequirements = credentialRequirements;
507
+ this.id = id;
508
+ this.type = typeToken;
509
+ this.icon = icon;
510
+ }
511
+ getCredentialRequirements() {
512
+ return this.credentialRequirements;
406
513
  }
407
514
  };
515
+ function isWrappedState(value) {
516
+ return value !== null && typeof value === "object" && "seenKeys" in value && Array.isArray(value.seenKeys);
517
+ }
518
+ /**
519
+ * Declarative helper for authoring polling triggers.
520
+ *
521
+ * ```ts
522
+ * export const onNewMail = definePollingTrigger({
523
+ * key: "my-plugin.on-new-mail",
524
+ * title: "On new mail",
525
+ * configSchema: z.object({ folder: z.string() }),
526
+ * credentials: { auth: myOAuthCredentialType },
527
+ * initialState: () => ({ lastSeenId: undefined }),
528
+ * pollIntervalMs: 60_000,
529
+ * async poll({ config, state, credentials }) {
530
+ * const session = await credentials.auth();
531
+ * const messages = await fetchMessages(session, config.folder, state.lastSeenId);
532
+ * return {
533
+ * items: messages.map(m => ({ json: m, dedupKey: m.id })),
534
+ * nextState: { lastSeenId: messages[0]?.id ?? state.lastSeenId },
535
+ * };
536
+ * },
537
+ * });
538
+ * ```
539
+ */
540
+ function definePollingTrigger(options) {
541
+ const credentialRequirements = definedNodeCredentialRequirementFactory.create(options.credentials);
542
+ const DEFAULT_INTERVAL_MS = 6e4;
543
+ const DefinedPollingTriggerRuntime = class {
544
+ kind = "trigger";
545
+ outputPorts = ["main"];
546
+ async setup(ctx) {
547
+ const cfg = ctx.config.cfg;
548
+ const intervalMs = cfg.pollIntervalMs ?? options.pollIntervalMs ?? DEFAULT_INTERVAL_MS;
549
+ const persisted = ctx.previousState;
550
+ const seedWrapped = (isWrappedState(persisted) ? persisted : void 0) ?? {
551
+ userState: options.initialState ? options.initialState() : void 0,
552
+ seenKeys: []
553
+ };
554
+ return await ctx.polling.start({
555
+ intervalMs,
556
+ seedState: seedWrapped,
557
+ runCycle: async ({ previousState }) => {
558
+ const wrapped = previousState ?? seedWrapped;
559
+ const seenSet = new Set(wrapped.seenKeys);
560
+ const credentialAccessors = definedNodeCredentialAccessorFactory.create(options.credentials, ctx);
561
+ const pollResult = await options.poll({
562
+ config: cfg,
563
+ state: wrapped.userState,
564
+ credentials: credentialAccessors
565
+ });
566
+ const newItems = [];
567
+ const newKeys = [];
568
+ for (const item of pollResult.items) {
569
+ if (item.dedupKey !== void 0) {
570
+ if (seenSet.has(item.dedupKey)) continue;
571
+ newKeys.push(item.dedupKey);
572
+ }
573
+ newItems.push({ json: item.json });
574
+ }
575
+ const allKeys = [...wrapped.seenKeys, ...newKeys];
576
+ const cappedKeys = allKeys.length > 2e3 ? allKeys.slice(allKeys.length - 2e3) : allKeys;
577
+ return {
578
+ items: newItems,
579
+ nextState: {
580
+ userState: pollResult.nextState,
581
+ seenKeys: cappedKeys
582
+ }
583
+ };
584
+ }
585
+ });
586
+ }
587
+ async execute(items, ctx) {
588
+ if (options.execute) return await options.execute(items, ctx);
589
+ return { main: items };
590
+ }
591
+ async getTestItems(ctx) {
592
+ if (options.testItems) return await options.testItems(ctx);
593
+ return [];
594
+ }
595
+ };
596
+ require_runtime.node({ name: options.key })(DefinedPollingTriggerRuntime);
597
+ return {
598
+ kind: "defined-polling-trigger",
599
+ key: options.key,
600
+ title: options.title,
601
+ description: options.description,
602
+ create(cfg, name = options.title, id) {
603
+ return new DefinedPollingTriggerConfig(name, cfg, DefinedPollingTriggerRuntime, options.icon, credentialRequirements, id);
604
+ },
605
+ poll(pollCtx) {
606
+ return options.poll({
607
+ config: pollCtx.config,
608
+ state: pollCtx.state,
609
+ credentials: pollCtx.credentials ?? {}
610
+ });
611
+ },
612
+ register(context) {
613
+ context.registerNode(DefinedPollingTriggerRuntime);
614
+ }
615
+ };
616
+ }
408
617
 
409
618
  //#endregion
410
619
  //#region src/ai/AgentToolFactory.ts
411
620
  var AgentToolFactoryImpl = class {
412
621
  asTool(node$1, options) {
413
- return new NodeBackedToolConfig(options.name ?? node$1.name ?? "tool", node$1, this.withDefaultAgentInputMapper(node$1, options));
622
+ return new require_runtime.NodeBackedToolConfig(options.name ?? node$1.name ?? "tool", node$1, this.withDefaultAgentInputMapper(node$1, options));
414
623
  }
415
624
  withDefaultAgentInputMapper(node$1, options) {
416
- if (options.mapInput || !AgentConfigInspector.isAgentNodeConfig(node$1)) return options;
625
+ if (options.mapInput || !require_runtime.AgentConfigInspector.isAgentNodeConfig(node$1)) return options;
417
626
  return {
418
627
  ...options,
419
628
  mapInput: ({ input, item }) => this.mergeAgentToolInputWithCurrentItem(input, item)
@@ -493,103 +702,6 @@ const AgentGuardrailDefaults = {
493
702
  onTurnLimitReached: "error"
494
703
  };
495
704
 
496
- //#endregion
497
- //#region src/ai/AgentConnectionNodeCollector.ts
498
- const AgentConnectionNodeCollector = new class {
499
- collect(parentNodeId, agentConfig) {
500
- const collected = [];
501
- this.collectInto(parentNodeId, agentConfig, collected);
502
- return collected;
503
- }
504
- collectInto(parentNodeId, agentConfig, collected) {
505
- collected.push({
506
- nodeId: require_runtime.ConnectionNodeIdFactory.languageModelConnectionNodeId(parentNodeId),
507
- parentNodeId,
508
- connectionName: "llm",
509
- role: "languageModel",
510
- name: agentConfig.chatModel.presentation?.label ?? agentConfig.chatModel.name,
511
- typeName: agentConfig.chatModel.name,
512
- icon: agentConfig.chatModel.presentation?.icon,
513
- credentialSource: agentConfig.chatModel
514
- });
515
- for (const tool$1 of agentConfig.tools ?? []) {
516
- const toolNodeId = require_runtime.ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, tool$1.name);
517
- const isNestedAgent = this.isNodeBackedAgentTool(tool$1);
518
- collected.push({
519
- nodeId: toolNodeId,
520
- parentNodeId,
521
- connectionName: "tools",
522
- role: isNestedAgent ? "nestedAgent" : "tool",
523
- name: tool$1.presentation?.label ?? tool$1.name,
524
- typeName: tool$1.name,
525
- icon: tool$1.presentation?.icon,
526
- credentialSource: tool$1
527
- });
528
- this.collectNestedAgentTools(toolNodeId, tool$1, collected);
529
- }
530
- }
531
- collectNestedAgentTools(toolNodeId, tool$1, collected) {
532
- if (!this.isNodeBackedAgentTool(tool$1)) return;
533
- const innerAgent = tool$1 instanceof NodeBackedToolConfig ? tool$1.node : tool$1.node;
534
- this.collectInto(toolNodeId, innerAgent, collected);
535
- }
536
- /**
537
- * After JSON round-trip (persisted snapshots), tools are plain objects — `instanceof NodeBackedToolConfig` fails.
538
- * Detect node-backed tools structurally via {@link NodeBackedToolConfig#toolKind}.
539
- */
540
- isNodeBackedAgentTool(tool$1) {
541
- if (tool$1 instanceof NodeBackedToolConfig) return AgentConfigInspector.isAgentNodeConfig(tool$1.node);
542
- if (!tool$1 || typeof tool$1 !== "object") return false;
543
- const t = tool$1;
544
- if (t.toolKind !== "nodeBacked") return false;
545
- return AgentConfigInspector.isAgentNodeConfig(t.node);
546
- }
547
- }();
548
-
549
- //#endregion
550
- //#region src/workflow/definition/ConnectionInvocationIdFactory.ts
551
- /**
552
- * Unique ids for persisted connection invocation history rows (LLM/tool calls under an owning node).
553
- */
554
- var ConnectionInvocationIdFactory = class {
555
- static create() {
556
- return `cinv_${(0, node_crypto.randomUUID)()}`;
557
- }
558
- /** Deterministic id for tests when a stable sequence is needed. */
559
- static createForTest(runId, connectionNodeId, sequence) {
560
- return `cinv_${runId}_${connectionNodeId}_${sequence}`;
561
- }
562
- };
563
-
564
- //#endregion
565
- //#region src/workflow/graph/ExecutableGraph.ts
566
- var ExecutableGraph = class {
567
- outgoingByNodeAndPort = /* @__PURE__ */ new Map();
568
- constructor(def) {
569
- for (const e of def.edges) {
570
- const byPort = this.outgoingByNodeAndPort.get(e.from.nodeId) ?? /* @__PURE__ */ new Map();
571
- const next = byPort.get(e.from.output) ?? [];
572
- next.push({
573
- nodeId: e.to.nodeId,
574
- input: e.to.input
575
- });
576
- byPort.set(e.from.output, next);
577
- this.outgoingByNodeAndPort.set(e.from.nodeId, byPort);
578
- }
579
- }
580
- next(nodeId, output) {
581
- return this.outgoingByNodeAndPort.get(nodeId)?.get(output) ?? [];
582
- }
583
- };
584
-
585
- //#endregion
586
- //#region src/workflow/graph/DefaultWorkflowGraphFactory.ts
587
- var DefaultWorkflowGraphFactory = class {
588
- create(def) {
589
- return new ExecutableGraph(def);
590
- }
591
- };
592
-
593
705
  //#endregion
594
706
  //#region src/events/EventPublishingWorkflowExecutionRepository.ts
595
707
  var EventPublishingWorkflowExecutionRepository = class {
@@ -641,6 +753,15 @@ var EventPublishingWorkflowExecutionRepository = class {
641
753
  }
642
754
  };
643
755
 
756
+ //#endregion
757
+ //#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
758
+ function __decorate(decorators, target, key, desc) {
759
+ var c$1 = arguments.length, r = c$1 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
760
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
761
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c$1 < 3 ? d(r) : c$1 > 3 ? d(target, key, r) : d(target, key)) || r;
762
+ return c$1 > 3 && r && Object.defineProperty(target, key, r), r;
763
+ }
764
+
644
765
  //#endregion
645
766
  //#region src/serialization/ItemsInputNormalizer.ts
646
767
  let ItemsInputNormalizer = class ItemsInputNormalizer$1 {
@@ -662,11 +783,31 @@ let ItemsInputNormalizer = class ItemsInputNormalizer$1 {
662
783
  return typeof raw === "object" && raw !== null && Object.prototype.hasOwnProperty.call(raw, "json");
663
784
  }
664
785
  };
665
- ItemsInputNormalizer = require_runtime.__decorate([(0, tsyringe.injectable)()], ItemsInputNormalizer);
786
+ ItemsInputNormalizer = __decorate([(0, tsyringe.injectable)()], ItemsInputNormalizer);
666
787
 
667
788
  //#endregion
668
- exports.AgentConfigInspector = AgentConfigInspector;
669
- exports.AgentConnectionNodeCollector = AgentConnectionNodeCollector;
789
+ //#region src/contracts/assertionTypes.ts
790
+ /**
791
+ * Default {@link AssertionResult.passThreshold} when authors omit it. Boolean-style assertions
792
+ * (assertEqual / contains / etc.) emit `score: 1` or `score: 0` so this default works for them;
793
+ * AI-judge assertions are expected to set their own threshold.
794
+ */
795
+ const DEFAULT_ASSERTION_PASS_THRESHOLD = .5;
796
+ /**
797
+ * Derive whether an assertion result is considered "passing" using the score-based contract:
798
+ * `errored` always fails, otherwise `score >= (passThreshold ?? 0.5)`. This is the canonical
799
+ * derivation — UI and rollup code should call it rather than inlining the comparison so future
800
+ * tweaks (e.g. NaN handling) land in one place.
801
+ */
802
+ function deriveAssertionPassed(result) {
803
+ if (result.errored === true) return false;
804
+ const threshold = result.passThreshold ?? DEFAULT_ASSERTION_PASS_THRESHOLD;
805
+ return result.score >= threshold;
806
+ }
807
+
808
+ //#endregion
809
+ exports.AgentConfigInspector = require_runtime.AgentConfigInspector;
810
+ exports.AgentConnectionNodeCollector = require_runtime.AgentConnectionNodeCollector;
670
811
  exports.AgentGuardrailDefaults = AgentGuardrailDefaults;
671
812
  exports.AgentMessageConfigNormalizer = AgentMessageConfigNormalizer;
672
813
  exports.AgentToolFactory = AgentToolFactory;
@@ -674,28 +815,26 @@ exports.AllWorkflowsActiveWorkflowActivationPolicy = require_runtime.AllWorkflow
674
815
  exports.CallableToolConfig = CallableToolConfig;
675
816
  exports.CallableToolFactory = CallableToolFactory;
676
817
  exports.CallableToolKindToken = CallableToolKindToken;
677
- exports.ChainCursor = require_InMemoryRunEventBusRegistry.ChainCursor;
678
- Object.defineProperty(exports, 'ChildExecutionScopeFactory', {
679
- enumerable: true,
680
- get: function () {
681
- return require_runtime.ChildExecutionScopeFactory;
682
- }
683
- });
818
+ exports.ChainCursor = require_runtime.ChainCursor;
819
+ exports.ChildExecutionScopeFactory = require_runtime.ChildExecutionScopeFactory;
684
820
  exports.CodemationTelemetryAttributeNames = require_runtime.CodemationTelemetryAttributeNames;
685
821
  exports.CodemationTelemetryMetricNames = require_runtime.CodemationTelemetryMetricNames;
686
822
  exports.ConnectionInvocationEventPublisher = require_runtime.ConnectionInvocationEventPublisher;
687
- exports.ConnectionInvocationIdFactory = ConnectionInvocationIdFactory;
823
+ exports.ConnectionInvocationIdFactory = require_runtime.ConnectionInvocationIdFactory;
688
824
  exports.ConnectionNodeIdFactory = require_runtime.ConnectionNodeIdFactory;
689
825
  exports.CoreTokens = require_runtime.CoreTokens;
690
826
  exports.CostTrackingTelemetryAttributeNames = require_runtime.CostTrackingTelemetryAttributeNames;
691
827
  exports.CostTrackingTelemetryMetricNames = require_runtime.CostTrackingTelemetryMetricNames;
692
828
  exports.CredentialResolverFactory = require_runtime.CredentialResolverFactory;
693
829
  exports.CredentialUnboundError = require_runtime.CredentialUnboundError;
830
+ exports.DEFAULT_ASSERTION_PASS_THRESHOLD = DEFAULT_ASSERTION_PASS_THRESHOLD;
694
831
  exports.DefaultAsyncSleeper = require_runtime.DefaultAsyncSleeper;
695
832
  exports.DefaultExecutionBinaryService = require_runtime.DefaultExecutionBinaryService;
696
833
  exports.DefaultExecutionContextFactory = require_runtime.DefaultExecutionContextFactory;
697
- exports.DefaultWorkflowGraphFactory = DefaultWorkflowGraphFactory;
834
+ exports.DefaultWorkflowGraphFactory = require_runtime.DefaultWorkflowGraphFactory;
835
+ exports.DefinedCollectionRegistry = DefinedCollectionRegistry;
698
836
  exports.DefinedNodeRegistry = DefinedNodeRegistry;
837
+ exports.DefinedPollingTriggerConfig = DefinedPollingTriggerConfig;
699
838
  exports.EngineExecutionLimitsPolicy = require_runtime.EngineExecutionLimitsPolicy;
700
839
  exports.EventPublishingWorkflowExecutionRepository = EventPublishingWorkflowExecutionRepository;
701
840
  exports.ExpRetryPolicy = require_runtime.ExpRetryPolicy;
@@ -718,15 +857,19 @@ exports.NoOpCostTrackingTelemetryFactory = require_runtime.NoOpCostTrackingTelem
718
857
  exports.NoOpExecutionTelemetry = require_runtime.NoOpExecutionTelemetry;
719
858
  exports.NoOpExecutionTelemetryFactory = require_runtime.NoOpExecutionTelemetryFactory;
720
859
  exports.NoOpNodeExecutionTelemetry = require_runtime.NoOpNodeExecutionTelemetry;
860
+ exports.NoOpPollingTriggerLogger = require_runtime.NoOpPollingTriggerLogger;
721
861
  exports.NoOpTelemetryArtifactReference = require_runtime.NoOpTelemetryArtifactReference;
722
862
  exports.NoOpTelemetrySpanScope = require_runtime.NoOpTelemetrySpanScope;
723
863
  exports.NoRetryPolicy = require_runtime.NoRetryPolicy;
724
- exports.NodeBackedToolConfig = NodeBackedToolConfig;
864
+ exports.NodeBackedToolConfig = require_runtime.NodeBackedToolConfig;
725
865
  exports.NodeEventPublisher = require_runtime.NodeEventPublisher;
866
+ exports.NodeIdSlugifier = require_runtime.NodeIdSlugifier;
726
867
  exports.NodeIterationIdFactory = require_runtime.NodeIterationIdFactory;
727
868
  exports.NodeOutputNormalizer = require_runtime.NodeOutputNormalizer;
728
869
  exports.PersistedRuntimeTypeMetadataStore = require_runtime.PersistedRuntimeTypeMetadataStore;
729
870
  exports.PersistedRuntimeTypeNameResolver = require_runtime.PersistedRuntimeTypeNameResolver;
871
+ exports.PollingTriggerDedupWindow = require_runtime.PollingTriggerDedupWindow;
872
+ exports.PollingTriggerRuntime = require_runtime.PollingTriggerRuntime;
730
873
  exports.RetryPolicy = require_runtime.RetryPolicy;
731
874
  exports.RunFinishedAtFactory = require_runtime.RunFinishedAtFactory;
732
875
  exports.RunIntentService = require_runtime.RunIntentService;
@@ -734,11 +877,13 @@ exports.RunnableOutputBehaviorResolver = require_runtime.RunnableOutputBehaviorR
734
877
  exports.StackTraceCallSitePathResolver = require_runtime.StackTraceCallSitePathResolver;
735
878
  exports.SystemClock = SystemClock;
736
879
  exports.UnavailableBinaryStorage = require_runtime.UnavailableBinaryStorage;
737
- exports.WhenBuilder = require_InMemoryRunEventBusRegistry.WhenBuilder;
738
- exports.WorkflowBuilder = require_InMemoryRunEventBusRegistry.WorkflowBuilder;
880
+ exports.WhenBuilder = require_runtime.WhenBuilder;
881
+ exports.WorkflowBuilder = require_runtime.WorkflowBuilder;
882
+ exports.WorkflowDefinitionError = require_runtime.WorkflowDefinitionError;
739
883
  exports.WorkflowExecutableNodeClassifier = require_runtime.WorkflowExecutableNodeClassifier;
740
884
  exports.WorkflowExecutableNodeClassifierFactory = require_runtime.WorkflowExecutableNodeClassifierFactory;
741
885
  exports.branchRef = require_runtime.branchRef;
886
+ exports.c = c;
742
887
  exports.callableTool = callableTool;
743
888
  exports.chatModel = require_runtime.chatModel;
744
889
  Object.defineProperty(exports, 'container', {
@@ -748,14 +893,17 @@ Object.defineProperty(exports, 'container', {
748
893
  }
749
894
  });
750
895
  exports.defineBatchNode = defineBatchNode;
896
+ exports.defineCollection = defineCollection;
751
897
  exports.defineCredential = defineCredential;
752
898
  exports.defineNode = defineNode;
899
+ exports.definePollingTrigger = definePollingTrigger;
753
900
  Object.defineProperty(exports, 'delay', {
754
901
  enumerable: true,
755
902
  get: function () {
756
903
  return tsyringe.delay;
757
904
  }
758
905
  });
906
+ exports.deriveAssertionPassed = deriveAssertionPassed;
759
907
  exports.emitPorts = require_runtime.emitPorts;
760
908
  exports.getOriginIndexFromItem = require_runtime.getOriginIndexFromItem;
761
909
  exports.getPersistedRuntimeTypeMetadata = require_runtime.getPersistedRuntimeTypeMetadata;