@noetic-tools/core 5.7.0 → 5.8.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 (44) hide show
  1. package/dist/builders/channel-builder.d.ts +18 -0
  2. package/dist/builders/control-flow-builders.d.ts +17 -30
  3. package/dist/builders/decide-builders.d.ts +5 -5
  4. package/dist/builders/decide-builders.js +4 -0
  5. package/dist/builders/every.d.ts +2 -2
  6. package/dist/builders/every.js +2 -0
  7. package/dist/builders/loop-builder.d.ts +1 -1
  8. package/dist/builders/loop-builder.js +1 -1
  9. package/dist/builders/provide-builder.d.ts +2 -2
  10. package/dist/builders/provide-builder.js +2 -0
  11. package/dist/builders/spawn-builder.d.ts +2 -2
  12. package/dist/builders/spawn-builder.js +2 -0
  13. package/dist/builders/step-builders.d.ts +8 -8
  14. package/dist/builders/workflow-hydrator.js +6 -1
  15. package/dist/harness/agent-harness.d.ts +18 -5
  16. package/dist/harness/agent-harness.js +49 -14
  17. package/dist/harness/deps/runtime.d.ts +3 -2
  18. package/dist/harness/deps/runtime.js +2 -2
  19. package/dist/harness/model-call.js +10 -0
  20. package/dist/index.d.ts +7 -5
  21. package/dist/index.js +3 -3
  22. package/dist/interpreter/child-span.d.ts +17 -0
  23. package/dist/interpreter/child-span.js +51 -0
  24. package/dist/interpreter/execute-action.js +21 -16
  25. package/dist/interpreter/execute-control.js +64 -8
  26. package/dist/interpreter/execute.d.ts +10 -0
  27. package/dist/interpreter/execute.js +41 -12
  28. package/dist/observability/genai-attributes.d.ts +45 -29
  29. package/dist/observability/genai-attributes.js +19 -1
  30. package/dist/runtime/channel-store.d.ts +73 -1
  31. package/dist/runtime/channel-store.js +179 -63
  32. package/dist/runtime/context-impl.d.ts +7 -1
  33. package/dist/runtime/context-impl.js +15 -0
  34. package/dist/runtime/durable/harness-checkpoints.d.ts +5 -1
  35. package/dist/runtime/durable/harness-checkpoints.js +8 -2
  36. package/dist/runtime/durable/step-ledger.d.ts +14 -4
  37. package/dist/runtime/durable/step-ledger.js +22 -5
  38. package/dist/types/checkpoint.d.ts +31 -0
  39. package/dist/types/checkpoint.js +29 -0
  40. package/dist/until/combinators.d.ts +10 -0
  41. package/dist/until/combinators.js +37 -13
  42. package/dist/until/predicates.js +4 -2
  43. package/package.json +3 -3
  44. package/schema/noetic-workflow.schema.json +57 -0
@@ -1,26 +1,36 @@
1
1
  /**
2
2
  * Combines predicates with OR semantics; stops the loop when any predicate says stop.
3
3
  *
4
+ * Predicates run in order and the first stop verdict short-circuits, so it is
5
+ * returned as is. When none stops, the combined verdict carries every
6
+ * predicate's `reason` (joined with `'; '`) and `feedback` (joined with `'\n'`),
7
+ * so a failing `until.verified()` still hands its feedback to `prepareNext`.
8
+ *
4
9
  * @public
5
10
  * @param predicates - Until predicates to evaluate.
6
11
  * @returns A combined `Until` that short-circuits on the first stop verdict.
7
12
  */
8
13
  export function any(...predicates) {
9
14
  return async (snapshot) => {
15
+ const verdicts = [];
10
16
  for (const pred of predicates) {
11
17
  const verdict = await pred(snapshot);
12
18
  if (verdict.stop) {
13
19
  return verdict;
14
20
  }
21
+ verdicts.push(verdict);
15
22
  }
16
- return {
17
- stop: false,
18
- };
23
+ return merge(false, verdicts);
19
24
  };
20
25
  }
21
26
  /**
22
27
  * Combines predicates with AND semantics; stops the loop only when all predicates say stop.
23
28
  *
29
+ * Predicates run in order and the first continue verdict short-circuits, so it
30
+ * is returned as is. When all stop, the combined verdict carries every
31
+ * predicate's `reason` (joined with `'; '`, default `'All predicates
32
+ * satisfied'`) and `feedback` (joined with `'\n'`).
33
+ *
24
34
  * @public
25
35
  * @param predicates - Until predicates to evaluate.
26
36
  * @returns A combined `Until` that requires all predicates to be satisfied.
@@ -30,20 +40,34 @@ export function all(...predicates) {
30
40
  const verdicts = [];
31
41
  for (const pred of predicates) {
32
42
  const verdict = await pred(snapshot);
33
- verdicts.push(verdict);
34
43
  if (!verdict.stop) {
35
- return {
36
- stop: false,
37
- };
44
+ return verdict;
38
45
  }
46
+ verdicts.push(verdict);
39
47
  }
40
- const reasons = verdicts
41
- .map((v) => v.reason)
42
- .filter(Boolean)
43
- .join('; ');
48
+ const merged = merge(true, verdicts);
44
49
  return {
45
- stop: true,
46
- reason: reasons || 'All predicates satisfied',
50
+ ...merged,
51
+ reason: merged.reason ?? 'All predicates satisfied',
47
52
  };
48
53
  };
49
54
  }
55
+ /** Folds the verdicts that decided a combinator into one, leaving out empty fields. */
56
+ function merge(stop, verdicts) {
57
+ const verdict = {
58
+ stop,
59
+ };
60
+ const reason = join(verdicts.map((v) => v.reason), '; ');
61
+ if (reason !== undefined) {
62
+ verdict.reason = reason;
63
+ }
64
+ const feedback = join(verdicts.map((v) => v.feedback), '\n');
65
+ if (feedback !== undefined) {
66
+ verdict.feedback = feedback;
67
+ }
68
+ return verdict;
69
+ }
70
+ function join(parts, separator) {
71
+ const present = parts.filter((p) => p !== undefined && p !== '');
72
+ return present.length === 0 ? undefined : present.join(separator);
73
+ }
@@ -18,7 +18,9 @@ export const until = {
18
18
  maxCost(usd) {
19
19
  return (snap) => ({
20
20
  stop: snap.cost >= usd,
21
- reason: snap.cost >= usd ? `Reached max cost ($${usd})` : undefined,
21
+ reason: snap.cost >= usd
22
+ ? `Cost $${snap.cost.toFixed(2)} exceeded budget $${usd.toFixed(2)}`
23
+ : undefined,
22
24
  });
23
25
  },
24
26
  /** Stops the loop when elapsed time reaches `ms` milliseconds. @public */
@@ -52,7 +54,7 @@ export const until = {
52
54
  const result = await fn(snap.lastOutput);
53
55
  return {
54
56
  stop: result.pass,
55
- reason: result.pass ? 'Verification passed' : undefined,
57
+ reason: result.pass ? 'Verification passed' : 'Verification failed',
56
58
  feedback: result.feedback,
57
59
  };
58
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/core",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "type": "module",
5
5
  "description": "Step primitives, interpreter, runtime, and context layer contract for Noetic agents.",
6
6
  "license": "Apache-2.0",
@@ -68,8 +68,8 @@
68
68
  }
69
69
  },
70
70
  "dependencies": {
71
- "@noetic-tools/context": "^1.4.0",
72
- "@noetic-tools/types": "^3.5.0",
71
+ "@noetic-tools/context": "^1.5.0",
72
+ "@noetic-tools/types": "^3.6.0",
73
73
  "@openrouter/agent": "^0.11.0",
74
74
  "@openrouter/sdk": "1.4.25",
75
75
  "zod": "^4.0.0"
@@ -32,6 +32,9 @@
32
32
  "type": "string",
33
33
  "minLength": 1
34
34
  },
35
+ "durable": {
36
+ "type": "boolean"
37
+ },
35
38
  "model": {
36
39
  "type": "string"
37
40
  },
@@ -83,6 +86,18 @@
83
86
  "items": {
84
87
  "type": "string"
85
88
  }
89
+ },
90
+ "serviceTier": {
91
+ "type": "string",
92
+ "enum": [
93
+ "auto",
94
+ "default",
95
+ "fast",
96
+ "flex",
97
+ "priority",
98
+ "scale",
99
+ "ultrafast"
100
+ ]
86
101
  }
87
102
  },
88
103
  "additionalProperties": false
@@ -124,6 +139,9 @@
124
139
  "type": "string",
125
140
  "minLength": 1
126
141
  },
142
+ "durable": {
143
+ "type": "boolean"
144
+ },
127
145
  "toolName": {
128
146
  "type": "string",
129
147
  "minLength": 1
@@ -154,6 +172,9 @@
154
172
  "type": "string",
155
173
  "minLength": 1
156
174
  },
175
+ "durable": {
176
+ "type": "boolean"
177
+ },
157
178
  "execute": {
158
179
  "type": "string",
159
180
  "minLength": 1
@@ -213,6 +234,9 @@
213
234
  "type": "string",
214
235
  "minLength": 1
215
236
  },
237
+ "durable": {
238
+ "type": "boolean"
239
+ },
216
240
  "routes": {
217
241
  "minItems": 1,
218
242
  "type": "array",
@@ -256,6 +280,9 @@
256
280
  "type": "string",
257
281
  "minLength": 1
258
282
  },
283
+ "durable": {
284
+ "type": "boolean"
285
+ },
259
286
  "model": {
260
287
  "type": "string",
261
288
  "minLength": 1
@@ -432,6 +459,9 @@
432
459
  "type": "string",
433
460
  "minLength": 1
434
461
  },
462
+ "durable": {
463
+ "type": "boolean"
464
+ },
435
465
  "decide": {
436
466
  "type": "object",
437
467
  "properties": {
@@ -443,6 +473,9 @@
443
473
  "type": "string",
444
474
  "minLength": 1
445
475
  },
476
+ "durable": {
477
+ "type": "boolean"
478
+ },
446
479
  "model": {
447
480
  "type": "string",
448
481
  "minLength": 1
@@ -652,6 +685,9 @@
652
685
  "type": "string",
653
686
  "minLength": 1
654
687
  },
688
+ "durable": {
689
+ "type": "boolean"
690
+ },
655
691
  "mode": {
656
692
  "type": "string",
657
693
  "enum": [
@@ -706,6 +742,9 @@
706
742
  "type": "string",
707
743
  "minLength": 1
708
744
  },
745
+ "durable": {
746
+ "type": "boolean"
747
+ },
709
748
  "child": {
710
749
  "$ref": "#/$defs/WorkflowNode"
711
750
  },
@@ -740,6 +779,9 @@
740
779
  "type": "string",
741
780
  "minLength": 1
742
781
  },
782
+ "durable": {
783
+ "type": "boolean"
784
+ },
743
785
  "child": {
744
786
  "$ref": "#/$defs/WorkflowNode"
745
787
  },
@@ -771,6 +813,9 @@
771
813
  "type": "string",
772
814
  "minLength": 1
773
815
  },
816
+ "durable": {
817
+ "type": "boolean"
818
+ },
774
819
  "body": {
775
820
  "$ref": "#/$defs/WorkflowNode"
776
821
  },
@@ -802,6 +847,9 @@
802
847
  "type": "string",
803
848
  "minLength": 1
804
849
  },
850
+ "durable": {
851
+ "type": "boolean"
852
+ },
805
853
  "steps": {
806
854
  "minItems": 1,
807
855
  "type": "array",
@@ -828,6 +876,9 @@
828
876
  "type": "string",
829
877
  "minLength": 1
830
878
  },
879
+ "durable": {
880
+ "type": "boolean"
881
+ },
831
882
  "step": {
832
883
  "$ref": "#/$defs/WorkflowNode"
833
884
  },
@@ -862,6 +913,9 @@
862
913
  "type": "string",
863
914
  "minLength": 1
864
915
  },
916
+ "durable": {
917
+ "type": "boolean"
918
+ },
865
919
  "document": {
866
920
  "$ref": "#"
867
921
  },
@@ -890,6 +944,9 @@
890
944
  "type": "string",
891
945
  "minLength": 1
892
946
  },
947
+ "durable": {
948
+ "type": "boolean"
949
+ },
893
950
  "agent": {
894
951
  "type": "string",
895
952
  "minLength": 1