@codemation/core 0.13.2 → 0.14.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 (69) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/dist/{CostCatalogContract-Dxq1BTyi.d.cts → CostCatalogContract-B9aYIqJu.d.cts} +2 -2
  3. package/dist/{EngineRuntimeRegistration.types-CqcTWexS.d.cts → EngineRuntimeRegistration.types-BYAmGMdS.d.cts} +3 -3
  4. package/dist/{EngineRuntimeRegistration.types-Cr75cSfL.d.ts → EngineRuntimeRegistration.types-CVLI8DsJ.d.ts} +2 -2
  5. package/dist/{InMemoryRunDataFactory-Csy2evr_.d.cts → InMemoryRunDataFactory-C3rIszrW.d.cts} +4 -2
  6. package/dist/{ItemsInputNormalizer-BbQTSEkZ.cjs → ItemsInputNormalizer-B9SdLG24.cjs} +2 -2
  7. package/dist/{ItemsInputNormalizer-BbQTSEkZ.cjs.map → ItemsInputNormalizer-B9SdLG24.cjs.map} +1 -1
  8. package/dist/{ItemsInputNormalizer-CSZGMgl3.js → ItemsInputNormalizer-CZEODg94.js} +2 -2
  9. package/dist/{ItemsInputNormalizer-CSZGMgl3.js.map → ItemsInputNormalizer-CZEODg94.js.map} +1 -1
  10. package/dist/{ItemsInputNormalizer-BYljnXU0.d.ts → ItemsInputNormalizer-DoOawd9R.d.ts} +2 -2
  11. package/dist/{ItemsInputNormalizer-Bi8m-Ijs.d.cts → ItemsInputNormalizer-UCpn7luX.d.cts} +3 -3
  12. package/dist/{RunIntentService-BitgkKaT.d.cts → RunIntentService-0f3ICjAz.d.cts} +2 -2
  13. package/dist/{RunIntentService-DYpqfu6D.d.ts → RunIntentService-Dx_HHxDX.d.ts} +2 -2
  14. package/dist/{agentMcpTypes-DGIwk6Ue.d.cts → agentMcpTypes-B11B3Hd-.d.cts} +8 -1
  15. package/dist/bootstrap/index.cjs +3 -3
  16. package/dist/bootstrap/index.d.cts +5 -5
  17. package/dist/bootstrap/index.d.ts +5 -5
  18. package/dist/bootstrap/index.js +3 -3
  19. package/dist/{bootstrap-DIv-vloi.cjs → bootstrap-Be0LB0nh.cjs} +3 -3
  20. package/dist/{bootstrap-DIv-vloi.cjs.map → bootstrap-Be0LB0nh.cjs.map} +1 -1
  21. package/dist/{bootstrap-Bkd-Nfbn.js → bootstrap-pSQdsMfa.js} +3 -3
  22. package/dist/{bootstrap-Bkd-Nfbn.js.map → bootstrap-pSQdsMfa.js.map} +1 -1
  23. package/dist/browser.cjs +2 -2
  24. package/dist/browser.d.cts +3 -3
  25. package/dist/browser.d.ts +2 -2
  26. package/dist/browser.js +2 -2
  27. package/dist/contracts.d.cts +4 -4
  28. package/dist/contracts.d.ts +1 -1
  29. package/dist/{di-tom0pM2h.js → di-CEV6wTc4.js} +4 -5
  30. package/dist/di-CEV6wTc4.js.map +1 -0
  31. package/dist/{di-LP2qSHkY.cjs → di-DhwtDRgs.cjs} +4 -5
  32. package/dist/di-DhwtDRgs.cjs.map +1 -0
  33. package/dist/{executionPersistenceContracts-CN9d7AnL.d.cts → executionPersistenceContracts-CX9Ql8N1.d.cts} +2 -2
  34. package/dist/{index-rllWL4r-.d.ts → index-CbJdbIHe.d.ts} +93 -6
  35. package/dist/{index-BSQ2LoIh.d.ts → index-uPnD9EE6.d.ts} +51 -11
  36. package/dist/index.cjs +20 -7
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +135 -16
  39. package/dist/index.d.ts +5 -5
  40. package/dist/index.js +19 -8
  41. package/dist/index.js.map +1 -1
  42. package/dist/{params-DRUr0F5v.d.cts → params-Dwl10Ws9.d.cts} +3 -4
  43. package/dist/{runtime-CWPdvJpC.js → runtime-CSunvf7A.js} +112 -15
  44. package/dist/runtime-CSunvf7A.js.map +1 -0
  45. package/dist/{runtime-_VdHwGkJ.cjs → runtime-n2tqRwaf.cjs} +117 -14
  46. package/dist/runtime-n2tqRwaf.cjs.map +1 -0
  47. package/dist/testing.cjs +3 -3
  48. package/dist/testing.d.cts +3 -3
  49. package/dist/testing.d.ts +3 -3
  50. package/dist/testing.js +3 -3
  51. package/package.json +1 -1
  52. package/src/authoring/defineNode.types.ts +18 -7
  53. package/src/authoring/definePollingTrigger.types.ts +20 -5
  54. package/src/authoring/index.ts +1 -0
  55. package/src/authoring/nodeBaseOptions.types.ts +18 -0
  56. package/src/contracts/itemExpr.ts +15 -11
  57. package/src/contracts/workflowTypes.ts +7 -0
  58. package/src/contracts/workspaceFileTypes.ts +42 -2
  59. package/src/execution/NodeOutputNormalizer.ts +8 -1
  60. package/src/execution/RunnableOutputBehaviorResolver.ts +12 -0
  61. package/src/index.ts +10 -2
  62. package/src/workflow/dsl/ChainCursorResolver.ts +13 -0
  63. package/src/workflow/dsl/WhenBuilder.ts +66 -2
  64. package/src/workflow/dsl/workflowBuilderTypes.ts +29 -0
  65. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +1 -0
  66. package/dist/di-LP2qSHkY.cjs.map +0 -1
  67. package/dist/di-tom0pM2h.js.map +0 -1
  68. package/dist/runtime-CWPdvJpC.js.map +0 -1
  69. package/dist/runtime-_VdHwGkJ.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- const require_di = require('./di-LP2qSHkY.cjs');
1
+ const require_di = require('./di-DhwtDRgs.cjs');
2
2
  let zod = require("zod");
3
3
  zod = require_di.__toESM(zod);
4
4
  let node_stream_web = require("node:stream/web");
@@ -211,9 +211,13 @@ function defineNode(options) {
211
211
  icon = options.icon;
212
212
  inputSchema = options.inputSchema;
213
213
  keepBinaries = options.keepBinaries ?? false;
214
- constructor(name, config, id) {
214
+ id;
215
+ description;
216
+ constructor(name, config, idOrOptions) {
215
217
  this.name = name;
216
- this.id = id;
218
+ const resolved = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
219
+ this.id = resolved?.id;
220
+ this.description = resolved?.description;
217
221
  this.config = config;
218
222
  }
219
223
  config;
@@ -229,8 +233,8 @@ function defineNode(options) {
229
233
  key: options.key,
230
234
  title: options.title,
231
235
  description: options.description,
232
- create(config, name = options.title, id) {
233
- return new DefinedRunnableNodeConfig(name, config, id);
236
+ create(config, name = options.title, idOrOptions) {
237
+ return new DefinedRunnableNodeConfig(name, config, idOrOptions);
234
238
  },
235
239
  register(context) {
236
240
  context.registerNode(DefinedNodeRuntime);
@@ -260,9 +264,13 @@ function defineBatchNode(options) {
260
264
  kind = "node";
261
265
  type = DefinedNodeRuntime;
262
266
  icon = options.icon;
263
- constructor(name, config, id) {
267
+ id;
268
+ description;
269
+ constructor(name, config, idOrOptions) {
264
270
  this.name = name;
265
- this.id = id;
271
+ const resolved = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
272
+ this.id = resolved?.id;
273
+ this.description = resolved?.description;
266
274
  this.config = config;
267
275
  }
268
276
  config;
@@ -278,8 +286,8 @@ function defineBatchNode(options) {
278
286
  key: options.key,
279
287
  title: options.title,
280
288
  description: options.description,
281
- create(config, name = options.title, id) {
282
- return new DefinedRunnableNodeConfig(name, config, id);
289
+ create(config, name = options.title, idOrOptions) {
290
+ return new DefinedRunnableNodeConfig(name, config, idOrOptions);
283
291
  },
284
292
  register(context) {
285
293
  context.registerNode(DefinedNodeRuntime);
@@ -446,10 +454,13 @@ async function handleResume(item, resumeContext, decisionSchema, resolvedPredica
446
454
  //#endregion
447
455
  //#region src/workflow/dsl/WhenBuilder.ts
448
456
  var WhenBuilder = class WhenBuilder {
449
- constructor(wf, from, branchPort) {
457
+ /** Tail endpoint of the arm this builder added (set by addBranch). */
458
+ armEndpoint;
459
+ constructor(wf, from, branchPort, priorEndpoints = []) {
450
460
  this.wf = wf;
451
461
  this.from = from;
452
462
  this.branchPort = branchPort;
463
+ this.priorEndpoints = priorEndpoints;
453
464
  }
454
465
  addBranch(steps) {
455
466
  const created = [];
@@ -470,20 +481,84 @@ var WhenBuilder = class WhenBuilder {
470
481
  return nodeId ? { nodeId } : { nodeId: r };
471
482
  });
472
483
  }
484
+ this.armEndpoint = prev ? {
485
+ node: prev,
486
+ output: "main",
487
+ inputPortHint: this.branchPort
488
+ } : {
489
+ node: this.from,
490
+ output: this.branchPort,
491
+ inputPortHint: this.branchPort
492
+ };
473
493
  return this;
474
494
  }
475
495
  when = (branch, steps, ...more) => {
476
496
  const list = Array.isArray(steps) ? steps : [steps, ...more];
477
497
  const port = branch ? "true" : "false";
478
- const b = new WhenBuilder(this.wf, this.from, port);
498
+ const b = new WhenBuilder(this.wf, this.from, port, this.accumulatedEndpoints);
479
499
  b.addBranch(list);
480
500
  return b;
481
501
  };
502
+ /**
503
+ * Continue the trunk after a boolean `.when(...)` branch chain, auto-merging EVERY branch
504
+ * tail accumulated across the chain into the next node — the same fan-in the object form
505
+ * produces. Typed as `ChainCursor<TCurrentJson>` (the pre-branch item type): boolean arms
506
+ * carry no output guard so the merged item type is underdetermined — use the object form
507
+ * `.when({ true: [...], false: [...] })` when you need a precise merged type inline.
508
+ */
509
+ then(config) {
510
+ return this.toCursor().then(config);
511
+ }
512
+ /**
513
+ * Chainable human-approval step after a boolean `.when(...)` branch chain — merges every
514
+ * branch tail into the approval node. Mirrors `ChainCursor.humanApproval`.
515
+ */
516
+ humanApproval(node$1, config, metadata) {
517
+ return this.toCursor().humanApproval(node$1, config, metadata);
518
+ }
482
519
  build() {
483
520
  return this.wf.build();
484
521
  }
522
+ /** Endpoints of every arm added so far in this chain (prior arms + this one). */
523
+ get accumulatedEndpoints() {
524
+ return this.armEndpoint ? [...this.priorEndpoints, this.armEndpoint] : this.priorEndpoints;
525
+ }
526
+ toCursor() {
527
+ return new ChainCursor(this.wf, this.accumulatedEndpoints);
528
+ }
485
529
  };
486
530
 
531
+ //#endregion
532
+ //#region src/workflow/dsl/workflowBuilderTypes.ts
533
+ /**
534
+ * Flags a node's config so its output is MERGED onto `item.json` (shallow, output-wins) instead of
535
+ * replacing it — the config-level twin of {@link ChainCursor.thenMerge}.
536
+ *
537
+ * Unlike `.thenMerge` (a cursor method that only works on the trunk), `mergeForward` operates on a
538
+ * bare config, so it is usable in ANY position — including inside a `.when({ true: [...] })` branch
539
+ * arm, where the steps are a flat array of configs (not a cursor). Wrap a payload-REPLACING node
540
+ * (e.g. an extractor) in `mergeForward(node.create(...))` so prior fields survive into the next step.
541
+ *
542
+ * The OUTPUT type becomes `TIn & TOut` (the intersection), mirroring `.thenMerge`'s return type at
543
+ * the config level — so the next step in the branch array sees both the prior fields and the node's
544
+ * output. The INPUT type stays `TIn` (the node still receives the pre-merge item).
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * workflow
549
+ * .trigger(...)
550
+ * .when({
551
+ * true: [mergeForward(extractor.create(...))], // output merges onto item.json; { a } survives
552
+ * false: [...],
553
+ * })
554
+ * .build();
555
+ * ```
556
+ */
557
+ function mergeForward(config) {
558
+ config.mergeJson = true;
559
+ return config;
560
+ }
561
+
487
562
  //#endregion
488
563
  //#region src/workflow/dsl/ChainCursorResolver.ts
489
564
  var ChainCursor = class ChainCursor {
@@ -501,6 +576,15 @@ var ChainCursor = class ChainCursor {
501
576
  ...inputPortHint ? { inputPortHint } : {}
502
577
  }]);
503
578
  }
579
+ /**
580
+ * Append a step whose output is MERGED onto `item.json` (shallow, output-wins) instead of
581
+ * replacing it — so earlier fields (e.g. trigger metadata) survive a transform/OCR/extraction
582
+ * node. Use for any node in a pipeline where you need data from before it.
583
+ */
584
+ thenMerge(config) {
585
+ mergeForward(config);
586
+ return this.then(config);
587
+ }
504
588
  thenIntoInputHints(config) {
505
589
  const next = this.wf.add(config);
506
590
  for (const e of this.endpoints) this.wf.connect(e.node, next, e.output, e.inputPortHint ?? "in");
@@ -2090,10 +2174,16 @@ var NodeOutputNormalizer = class {
2090
2174
  isItemLike(value) {
2091
2175
  return typeof value === "object" && value !== null && "json" in value;
2092
2176
  }
2177
+ isPlainJsonObject(value) {
2178
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2179
+ }
2093
2180
  applyOutput(baseItem, next, behavior) {
2094
2181
  const explicitBinary = next.binary;
2095
2182
  return {
2096
- json: next.json,
2183
+ json: behavior.mergeJson && this.isPlainJsonObject(baseItem.json) && this.isPlainJsonObject(next.json) ? {
2184
+ ...baseItem.json,
2185
+ ...next.json
2186
+ } : next.json,
2097
2187
  ...explicitBinary !== void 0 ? { binary: explicitBinary } : behavior.keepBinaries && baseItem.binary ? { binary: baseItem.binary } : {},
2098
2188
  ...next.meta ? { meta: next.meta } : {},
2099
2189
  ...next.paired ? { paired: next.paired } : {}
@@ -2105,11 +2195,17 @@ var NodeOutputNormalizer = class {
2105
2195
  //#region src/execution/RunnableOutputBehaviorResolver.ts
2106
2196
  var RunnableOutputBehaviorResolver = class {
2107
2197
  resolve(config) {
2108
- return { keepBinaries: this.isKeepBinariesEnabled(config) };
2198
+ return {
2199
+ keepBinaries: this.isKeepBinariesEnabled(config),
2200
+ mergeJson: this.isMergeJsonEnabled(config)
2201
+ };
2109
2202
  }
2110
2203
  isKeepBinariesEnabled(config) {
2111
2204
  return config.keepBinaries === true;
2112
2205
  }
2206
+ isMergeJsonEnabled(config) {
2207
+ return config.mergeJson === true;
2208
+ }
2113
2209
  };
2114
2210
 
2115
2211
  //#endregion
@@ -2648,6 +2744,7 @@ var WorkflowSnapshotCodec = class {
2648
2744
  name: config.name,
2649
2745
  id: config.id,
2650
2746
  icon: config.icon,
2747
+ description: config.description,
2651
2748
  execution: config.execution
2652
2749
  };
2653
2750
  this.injectTokenIds(fallback, config);
@@ -7139,6 +7236,12 @@ Object.defineProperty(exports, 'isUnbrandedPortsEmissionShape', {
7139
7236
  return isUnbrandedPortsEmissionShape;
7140
7237
  }
7141
7238
  });
7239
+ Object.defineProperty(exports, 'mergeForward', {
7240
+ enumerable: true,
7241
+ get: function () {
7242
+ return mergeForward;
7243
+ }
7244
+ });
7142
7245
  Object.defineProperty(exports, 'node', {
7143
7246
  enumerable: true,
7144
7247
  get: function () {
@@ -7151,4 +7254,4 @@ Object.defineProperty(exports, 'tool', {
7151
7254
  return tool;
7152
7255
  }
7153
7256
  });
7154
- //# sourceMappingURL=runtime-_VdHwGkJ.cjs.map
7257
+ //# sourceMappingURL=runtime-n2tqRwaf.cjs.map