@noetic-tools/core 5.9.0 → 5.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 (42) hide show
  1. package/dist/adapters/in-memory-subprocess/manifest-persistence.js +5 -1
  2. package/dist/adapters/in-memory-subprocess/metadata.js +1 -0
  3. package/dist/adapters/in-memory-subprocess/types.d.ts +4 -0
  4. package/dist/adapters/in-memory-subprocess-adapter.js +2 -0
  5. package/dist/adapters/openrouter.d.ts +13 -3
  6. package/dist/adapters/openrouter.js +43 -12
  7. package/dist/builders/dynamic-workflow.js +2 -1
  8. package/dist/builders/provide-builder.d.ts +6 -5
  9. package/dist/builders/spawn-builder.d.ts +6 -2
  10. package/dist/builders/step-builders.d.ts +9 -2
  11. package/dist/builders/step-builders.js +30 -2
  12. package/dist/builders/workflow-hydrator.js +1 -0
  13. package/dist/harness/agent-harness.d.ts +7 -1
  14. package/dist/harness/agent-harness.js +1 -0
  15. package/dist/harness/deps/context.d.ts +1 -1
  16. package/dist/harness/deps/context.js +1 -1
  17. package/dist/harness/deps/types.d.ts +1 -1
  18. package/dist/harness/model-call.js +114 -18
  19. package/dist/index.d.ts +9 -5
  20. package/dist/index.js +1 -1
  21. package/dist/interpreter/action-deps.d.ts +1 -1
  22. package/dist/interpreter/action-deps.js +1 -1
  23. package/dist/interpreter/action-types.d.ts +1 -1
  24. package/dist/interpreter/child-span.d.ts +5 -4
  25. package/dist/interpreter/child-span.js +7 -5
  26. package/dist/interpreter/context-assembly.d.ts +5 -4
  27. package/dist/interpreter/context-assembly.js +18 -14
  28. package/dist/interpreter/execute-action.d.ts +25 -5
  29. package/dist/interpreter/execute-action.js +100 -18
  30. package/dist/interpreter/execute-control.js +7 -0
  31. package/dist/interpreter/execute-decide.js +2 -2
  32. package/dist/interpreter/execute.js +22 -8
  33. package/dist/interpreter/step-dispatcher.js +1 -0
  34. package/dist/observability/genai-attributes.d.ts +33 -3
  35. package/dist/observability/genai-attributes.js +34 -4
  36. package/dist/runtime/tool-approval.d.ts +25 -0
  37. package/dist/runtime/tool-approval.js +67 -0
  38. package/dist/unstable.d.ts +1 -1
  39. package/dist/util/detached-handle.d.ts +4 -10
  40. package/dist/util/detached-handle.js +14 -23
  41. package/package.json +3 -3
  42. package/schema/noetic-workflow.schema.json +25 -0
@@ -92,7 +92,9 @@ function extractError(metadata) {
92
92
  * @public
93
93
  * Thin wrapper over a `SubprocessHandle` that implements the `DetachedHandle`
94
94
  * contract. Polls the adapter until the handle reaches a terminal status,
95
- * then reads the result (or error) off `handle.metadata`.
95
+ * then reads the result (or error) off `handle.metadata`. Polling starts in
96
+ * the constructor, so `status`, `result`, and `error` settle whether or not
97
+ * the caller ever invokes `.await()`.
96
98
  *
97
99
  * The polling cadence starts at 10ms and ramps to 100ms after the first
98
100
  * second — responsive for short-lived in-memory steps without burning cycles
@@ -107,19 +109,22 @@ export class DetachedHandleImpl {
107
109
  _status = DetachedStatus.Running;
108
110
  _result;
109
111
  _error;
110
- _settlementPromise;
112
+ _settlement;
111
113
  constructor(opts) {
112
114
  this.id = opts.id;
113
115
  this._stepId = opts.stepId;
114
116
  this._adapter = opts.adapter;
115
117
  this._spawnPromise = opts.spawnPromise;
116
118
  this._startTime = Date.now();
117
- // Observe spawn failure eagerly so `.error` is populated even if the
118
- // caller never invokes `.await()`. We intentionally swallow the
119
- // rejection here — `.await()` surfaces it to the caller.
120
- this._spawnPromise.catch((err) => {
121
- this._status = DetachedStatus.Failed;
122
- this._error = err instanceof Error ? err.message : String(err);
119
+ // One shared poll for the handle's life, so repeated `.await()` calls
120
+ // don't start parallel loops. The rejection is swallowed here only to
121
+ // record it; `.await()` surfaces it to the caller.
122
+ this._settlement = this.pollUntilSettled();
123
+ this._settlement.catch((err) => {
124
+ if (this._status === DetachedStatus.Running) {
125
+ this._status = DetachedStatus.Failed;
126
+ this._error = err instanceof Error ? err.message : String(err);
127
+ }
123
128
  });
124
129
  }
125
130
  get status() {
@@ -138,7 +143,7 @@ export class DetachedHandleImpl {
138
143
  * observes the final value.
139
144
  */
140
145
  async await(timeout) {
141
- const settlement = this.getOrStartSettlement();
146
+ const settlement = this._settlement;
142
147
  if (timeout === undefined || timeout <= 0) {
143
148
  return settlement;
144
149
  }
@@ -165,20 +170,6 @@ export class DetachedHandleImpl {
165
170
  }
166
171
  }
167
172
  }
168
- /**
169
- * Start (or return the cached) polling promise that resolves on the first
170
- * terminal status the adapter reports for this handle.
171
- *
172
- * A single settlement promise is shared across all `.await()` callers so
173
- * repeated calls don't spawn parallel polling loops.
174
- */
175
- getOrStartSettlement() {
176
- if (this._settlementPromise) {
177
- return this._settlementPromise;
178
- }
179
- this._settlementPromise = this.pollUntilSettled();
180
- return this._settlementPromise;
181
- }
182
173
  async pollUntilSettled() {
183
174
  // Wait for the spawn itself to succeed before we start polling —
184
175
  // otherwise we'd be polling with an undefined handle id.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/core",
3
- "version": "5.9.0",
3
+ "version": "5.11.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.6.0",
72
- "@noetic-tools/types": "^3.7.0",
71
+ "@noetic-tools/context": "^1.8.0",
72
+ "@noetic-tools/types": "^3.9.0",
73
73
  "@openrouter/agent": "^0.11.0",
74
74
  "@openrouter/sdk": "1.4.25",
75
75
  "zod": "^4.0.0"
@@ -89,6 +89,31 @@
89
89
  "additionalProperties": false
90
90
  }
91
91
  },
92
+ "toolChoice": {
93
+ "anyOf": [
94
+ {
95
+ "type": "string",
96
+ "enum": [
97
+ "auto",
98
+ "required",
99
+ "none"
100
+ ]
101
+ },
102
+ {
103
+ "type": "object",
104
+ "properties": {
105
+ "tool": {
106
+ "type": "string",
107
+ "minLength": 1
108
+ }
109
+ },
110
+ "required": [
111
+ "tool"
112
+ ],
113
+ "additionalProperties": false
114
+ }
115
+ ]
116
+ },
92
117
  "params": {
93
118
  "type": "object",
94
119
  "properties": {