@noetic-tools/core 0.2.1 → 1.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 (207) hide show
  1. package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
  2. package/dist/adapters/in-memory-fs-adapter.js +1 -1
  3. package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
  4. package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +2 -2
  5. package/dist/adapters/in-memory-subprocess/metadata.d.ts +1 -1
  6. package/dist/adapters/in-memory-subprocess/types.d.ts +2 -2
  7. package/dist/adapters/in-memory-subprocess-adapter.d.ts +1 -1
  8. package/dist/adapters/openrouter.d.ts +2 -6
  9. package/dist/adapters/openrouter.js +1 -4
  10. package/dist/builders/channel-builder.d.ts +1 -1
  11. package/dist/builders/control-flow-builders.d.ts +2 -3
  12. package/dist/builders/control-flow-builders.js +1 -2
  13. package/dist/builders/every.d.ts +2 -3
  14. package/dist/builders/every.js +1 -1
  15. package/dist/builders/layer-provides-builders.d.ts +1 -1
  16. package/dist/builders/layer-provides-builders.js +1 -1
  17. package/dist/builders/loop-builder.d.ts +2 -2
  18. package/dist/builders/loop-builder.js +1 -1
  19. package/dist/builders/memory-builder.d.ts +1 -1
  20. package/dist/builders/memory-builder.js +1 -1
  21. package/dist/builders/provide-builder.d.ts +2 -2
  22. package/dist/builders/provide-builder.js +1 -1
  23. package/dist/builders/spawn-builder.d.ts +2 -3
  24. package/dist/builders/spawn-builder.js +1 -1
  25. package/dist/builders/step-builders.d.ts +2 -6
  26. package/dist/builders/step-builders.js +1 -1
  27. package/dist/builders/tool-builder.d.ts +1 -3
  28. package/dist/builders/tool-builder.js +1 -1
  29. package/dist/builders/workflow-hydrator.d.ts +2 -3
  30. package/dist/builders/workflow-hydrator.js +1 -2
  31. package/dist/conditions/conditions.d.ts +2 -3
  32. package/dist/conditions/conditions.js +1 -1
  33. package/dist/harness/agent-harness.d.ts +15 -5
  34. package/dist/harness/agent-harness.js +65 -10
  35. package/dist/harness/deps/memory.d.ts +2 -5
  36. package/dist/harness/deps/memory.js +1 -4
  37. package/dist/harness/deps/types.d.ts +3 -16
  38. package/dist/harness/deps/types.js +1 -1
  39. package/dist/harness/model-call.d.ts +1 -3
  40. package/dist/harness/model-call.js +10 -10
  41. package/dist/harness/model-schema.d.ts +10 -4
  42. package/dist/harness/model-schema.js +9 -1
  43. package/dist/index.d.ts +28 -49
  44. package/dist/index.js +9 -27
  45. package/dist/interpreter/action-deps.d.ts +4 -8
  46. package/dist/interpreter/action-deps.js +2 -6
  47. package/dist/interpreter/action-types.d.ts +3 -8
  48. package/dist/interpreter/action-types.js +1 -1
  49. package/dist/interpreter/collect-tools.d.ts +1 -2
  50. package/dist/interpreter/collect-tools.js +1 -1
  51. package/dist/interpreter/execute-action.js +122 -27
  52. package/dist/interpreter/execute-control.d.ts +1 -2
  53. package/dist/interpreter/execute-control.js +60 -7
  54. package/dist/interpreter/execute.d.ts +2 -3
  55. package/dist/interpreter/execute.js +1 -2
  56. package/dist/interpreter/message-helpers.d.ts +1 -1
  57. package/dist/interpreter/message-helpers.js +1 -1
  58. package/dist/interpreter/step-dispatcher.d.ts +2 -5
  59. package/dist/interpreter/typeguards.d.ts +3 -4
  60. package/dist/interpreter/typeguards.js +1 -1
  61. package/dist/observability/span-impl.d.ts +1 -1
  62. package/dist/observability/trace-exporter.d.ts +1 -1
  63. package/dist/patterns/dynamic-workflow.d.ts +2 -5
  64. package/dist/patterns/dynamic-workflow.js +1 -2
  65. package/dist/patterns/flow.d.ts +2 -2
  66. package/dist/patterns/flow.js +1 -1
  67. package/dist/patterns/interview.d.ts +2 -2
  68. package/dist/patterns/interview.js +1 -1
  69. package/dist/patterns/plans.d.ts +2 -3
  70. package/dist/patterns/plans.js +1 -1
  71. package/dist/patterns/ralph-wiggum.d.ts +2 -3
  72. package/dist/patterns/react.d.ts +2 -3
  73. package/dist/portable/memory-layers.d.ts +1 -7
  74. package/dist/portable/memory-layers.js +1 -7
  75. package/dist/portable.d.ts +2 -2
  76. package/dist/portable.js +2 -2
  77. package/dist/runtime/broadcaster-utils.d.ts +1 -1
  78. package/dist/runtime/channel-store.d.ts +43 -3
  79. package/dist/runtime/channel-store.js +233 -37
  80. package/dist/runtime/context-deps.d.ts +3 -3
  81. package/dist/runtime/context-deps.js +2 -2
  82. package/dist/runtime/context-impl.d.ts +17 -1
  83. package/dist/runtime/context-impl.js +30 -3
  84. package/dist/runtime/context-type-deps.d.ts +2 -11
  85. package/dist/runtime/cwd-helpers.d.ts +1 -1
  86. package/dist/runtime/detached-handle.d.ts +2 -3
  87. package/dist/runtime/detached-handle.js +1 -3
  88. package/dist/runtime/durable/checkpoint-store.d.ts +1 -1
  89. package/dist/runtime/durable/checkpoint-store.js +1 -1
  90. package/dist/runtime/durable/harness-checkpoints.d.ts +2 -5
  91. package/dist/runtime/durable/runnable-loop.d.ts +1 -3
  92. package/dist/runtime/durable/session-seed.d.ts +1 -1
  93. package/dist/runtime/durable/stall-nudge.d.ts +17 -10
  94. package/dist/runtime/durable/stall-nudge.js +29 -10
  95. package/dist/runtime/event-broadcaster.d.ts +10 -2
  96. package/dist/runtime/event-broadcaster.js +43 -19
  97. package/dist/runtime/in-memory-storage.d.ts +1 -1
  98. package/dist/runtime/in-memory-storage.js +1 -1
  99. package/dist/runtime/item-log-impl.d.ts +1 -3
  100. package/dist/runtime/item-log-impl.js +1 -1
  101. package/dist/runtime/message-queue.d.ts +1 -2
  102. package/dist/runtime/session-runner.d.ts +1 -4
  103. package/dist/runtime/session-streams.d.ts +1 -2
  104. package/dist/runtime/session-streams.js +1 -1
  105. package/dist/runtime/step-registry.d.ts +2 -2
  106. package/dist/runtime/step-registry.js +1 -2
  107. package/dist/runtime/tool-memory.d.ts +1 -3
  108. package/dist/types/mutable-context.d.ts +2 -3
  109. package/dist/types/step-registrar.d.ts +1 -1
  110. package/dist/unstable.d.ts +5 -9
  111. package/dist/unstable.js +3 -6
  112. package/dist/until/combinators.d.ts +1 -1
  113. package/dist/until/never.d.ts +1 -1
  114. package/dist/until/predicates.d.ts +2 -2
  115. package/package.json +4 -2
  116. package/dist/errors/noetic-config-error.d.ts +0 -41
  117. package/dist/errors/noetic-config-error.js +0 -44
  118. package/dist/errors/noetic-error.d.ts +0 -18
  119. package/dist/errors/noetic-error.js +0 -54
  120. package/dist/memory/budget.d.ts +0 -23
  121. package/dist/memory/budget.js +0 -117
  122. package/dist/memory/exec-context-factory.d.ts +0 -25
  123. package/dist/memory/exec-context-factory.js +0 -30
  124. package/dist/memory/flow-schema.d.ts +0 -52
  125. package/dist/memory/flow-schema.js +0 -102
  126. package/dist/memory/function-call-utils.d.ts +0 -6
  127. package/dist/memory/function-call-utils.js +0 -27
  128. package/dist/memory/layer-api.d.ts +0 -14
  129. package/dist/memory/layer-api.js +0 -91
  130. package/dist/memory/layer-lifecycle.d.ts +0 -160
  131. package/dist/memory/layer-lifecycle.js +0 -552
  132. package/dist/memory/layer-provides.d.ts +0 -32
  133. package/dist/memory/layer-provides.js +0 -33
  134. package/dist/memory/layer-usage.d.ts +0 -16
  135. package/dist/memory/layer-usage.js +0 -54
  136. package/dist/memory/layers/durable-task-state.d.ts +0 -79
  137. package/dist/memory/layers/durable-task-state.js +0 -118
  138. package/dist/memory/layers/file-reference.d.ts +0 -55
  139. package/dist/memory/layers/file-reference.js +0 -594
  140. package/dist/memory/layers/history-window.d.ts +0 -29
  141. package/dist/memory/layers/history-window.js +0 -114
  142. package/dist/memory/layers/observational-memory.d.ts +0 -53
  143. package/dist/memory/layers/observational-memory.js +0 -109
  144. package/dist/memory/layers/plan.d.ts +0 -55
  145. package/dist/memory/layers/plan.js +0 -374
  146. package/dist/memory/layers/static-content.d.ts +0 -27
  147. package/dist/memory/layers/static-content.js +0 -35
  148. package/dist/memory/layers/steering.d.ts +0 -51
  149. package/dist/memory/layers/steering.js +0 -258
  150. package/dist/memory/layers/temporal.d.ts +0 -91
  151. package/dist/memory/layers/temporal.js +0 -245
  152. package/dist/memory/layers/tool-memory-layer.d.ts +0 -16
  153. package/dist/memory/layers/tool-memory-layer.js +0 -43
  154. package/dist/memory/layers/working-memory.d.ts +0 -44
  155. package/dist/memory/layers/working-memory.js +0 -92
  156. package/dist/memory/projector.d.ts +0 -10
  157. package/dist/memory/projector.js +0 -19
  158. package/dist/memory/scope.d.ts +0 -3
  159. package/dist/memory/scope.js +0 -31
  160. package/dist/memory/strip-unresolved.d.ts +0 -13
  161. package/dist/memory/strip-unresolved.js +0 -35
  162. package/dist/schemas/item.d.ts +0 -35
  163. package/dist/schemas/item.js +0 -155
  164. package/dist/types/channel.d.ts +0 -29
  165. package/dist/types/channel.js +0 -1
  166. package/dist/types/common.d.ts +0 -68
  167. package/dist/types/common.js +0 -1
  168. package/dist/types/context-parts/item-log.d.ts +0 -6
  169. package/dist/types/context-parts/item-log.js +0 -1
  170. package/dist/types/context-parts/layer-usage.d.ts +0 -18
  171. package/dist/types/context-parts/layer-usage.js +0 -1
  172. package/dist/types/context.d.ts +0 -202
  173. package/dist/types/context.js +0 -1
  174. package/dist/types/detached.d.ts +0 -17
  175. package/dist/types/detached.js +0 -7
  176. package/dist/types/error.d.ts +0 -66
  177. package/dist/types/error.js +0 -1
  178. package/dist/types/fs-adapter.d.ts +0 -51
  179. package/dist/types/fs-adapter.js +0 -3
  180. package/dist/types/harness-result.d.ts +0 -43
  181. package/dist/types/harness-result.js +0 -2
  182. package/dist/types/items.d.ts +0 -131
  183. package/dist/types/items.js +0 -2
  184. package/dist/types/memory-context.d.ts +0 -39
  185. package/dist/types/memory-context.js +0 -1
  186. package/dist/types/memory.d.ts +0 -306
  187. package/dist/types/memory.js +0 -13
  188. package/dist/types/observability.d.ts +0 -30
  189. package/dist/types/observability.js +0 -1
  190. package/dist/types/runtime.d.ts +0 -256
  191. package/dist/types/runtime.js +0 -1
  192. package/dist/types/shell-adapter.d.ts +0 -34
  193. package/dist/types/shell-adapter.js +0 -10
  194. package/dist/types/steering.d.ts +0 -89
  195. package/dist/types/steering.js +0 -14
  196. package/dist/types/step.d.ts +0 -231
  197. package/dist/types/step.js +0 -1
  198. package/dist/types/subprocess-adapter.d.ts +0 -157
  199. package/dist/types/subprocess-adapter.js +0 -3
  200. package/dist/types/tool-context.d.ts +0 -34
  201. package/dist/types/tool-context.js +0 -1
  202. package/dist/types/tool.d.ts +0 -64
  203. package/dist/types/tool.js +0 -1
  204. package/dist/util/framework-cast.d.ts +0 -10
  205. package/dist/util/framework-cast.js +0 -16
  206. package/dist/util/message-helpers.d.ts +0 -17
  207. package/dist/util/message-helpers.js +0 -64
@@ -5,11 +5,14 @@
5
5
  * and without the agent asking for external input — i.e. the agent
6
6
  * stopped without calling either a terminal tool or an ask-user-style
7
7
  * tool. That's a soft failure: rather than wait forever, we nudge the
8
- * agent once to remind it of its options. If the second turn also
9
- * ends in the same stalled shape we escalate: the caller-supplied
10
- * `onStall` callback records the escalation (task pause, metrics,
11
- * whatever the domain demands) and we settle the signal ourselves with
12
- * a canonical "stalled" outcome so the parent unwinds cleanly.
8
+ * agent once to remind it of its options and wait for the nudged turn
9
+ * to actually complete (`harness.execute` is enqueue-only, so the hook
10
+ * awaits `getAgentResponse` — raced against the signal — before
11
+ * re-checking). If the second turn also ends in the same stalled shape
12
+ * we escalate: the caller-supplied `onStall` callback records the
13
+ * escalation (task pause, metrics, whatever the domain demands) and we
14
+ * settle the signal ourselves with a canonical "stalled" outcome so
15
+ * the parent unwinds cleanly.
13
16
  *
14
17
  * The helper factors the state machine out of the loop so callers can
15
18
  * opt in per-runner. Task-specific concerns (how "pending external
@@ -55,10 +58,14 @@ export function createNudgeMessage(opts) {
55
58
  * - the caller reports pending external input (`hasPendingExternal`
56
59
  * returns true — e.g. an outstanding ask-user request).
57
60
  *
58
- * Otherwise it sends the nudge message via `harness.execute`, waits
59
- * for microtasks to flush, and re-checks the same two conditions. If
60
- * the agent still hasn't progressed, the hook fires `onStall` and
61
- * resolves the signal with `buildStalledOutcome()`.
61
+ * Otherwise it sends the nudge message via `harness.execute` and waits
62
+ * for the nudged turn to actually complete. `execute()` only enqueues
63
+ * the message — the turn runs asynchronously through the session
64
+ * runner — so the hook awaits `harness.getAgentResponse(threadId)`
65
+ * (raced against `signal.done` so a terminal tool that settles the
66
+ * signal mid-turn short-circuits the wait) before re-checking the same
67
+ * two conditions. If the agent still hasn't progressed, the hook fires
68
+ * `onStall` and resolves the signal with `buildStalledOutcome()`.
62
69
  */
63
70
  export function createStallNudgeHook(opts) {
64
71
  return async (ctx) => {
@@ -72,7 +79,19 @@ export function createStallNudgeHook(opts) {
72
79
  await opts.harness.execute(opts.nudgeMessage, {
73
80
  threadId: opts.threadId,
74
81
  });
75
- await Promise.resolve();
82
+ // Wait for the nudged turn to genuinely finish. A one-microtask wait
83
+ // would escalate before the agent's LLM round trip even starts —
84
+ // `execute()` resolves as soon as the message is enqueued. Errors from
85
+ // `getAgentResponse` are swallowed: a failed response fetch must not
86
+ // crash the hook, it just means we proceed to the stall re-check.
87
+ await Promise.race([
88
+ opts.harness
89
+ .getAgentResponse({
90
+ threadId: opts.threadId,
91
+ })
92
+ .catch(() => undefined),
93
+ opts.signal.done.then(() => undefined, () => undefined),
94
+ ]);
76
95
  if (ctx.signalSettled()) {
77
96
  return;
78
97
  }
@@ -1,4 +1,4 @@
1
- import type { StreamEvent } from '../types/harness-result.js';
1
+ import type { StreamEvent } from '@noetic-tools/types';
2
2
  interface EventBroadcasterOpts {
3
3
  maxBufferSize?: number;
4
4
  }
@@ -45,7 +45,13 @@ export declare class EventBroadcaster {
45
45
  }
46
46
  declare class BroadcastIterator implements AsyncIterator<StreamEvent> {
47
47
  private cursor;
48
- private waiter?;
48
+ /**
49
+ * Parked `next()` calls, FIFO. The AsyncIterator protocol allows pipelined
50
+ * `next()` calls (calling again before the previous promise settles), so a
51
+ * single waiter slot would orphan all but the latest call — the overwritten
52
+ * promises would never settle. `notify()` drains in arrival order.
53
+ */
54
+ private readonly waiters;
49
55
  private returned;
50
56
  private readonly broadcaster;
51
57
  constructor(broadcaster: EventBroadcaster);
@@ -54,6 +60,8 @@ declare class BroadcastIterator implements AsyncIterator<StreamEvent> {
54
60
  /** Called by the broadcaster when new data or completion is available. */
55
61
  notify(): void;
56
62
  next(): Promise<IteratorResult<StreamEvent>>;
63
+ /** Settle every parked waiter with `{ done: true }` — used on early exit. */
64
+ private settleWaiters;
57
65
  throw(err: Error): Promise<IteratorResult<StreamEvent>>;
58
66
  return(): Promise<IteratorResult<StreamEvent>>;
59
67
  private tryRead;
@@ -101,7 +101,13 @@ export class EventBroadcaster {
101
101
  //#region BroadcastIterator
102
102
  class BroadcastIterator {
103
103
  cursor = 0;
104
- waiter;
104
+ /**
105
+ * Parked `next()` calls, FIFO. The AsyncIterator protocol allows pipelined
106
+ * `next()` calls (calling again before the previous promise settles), so a
107
+ * single waiter slot would orphan all but the latest call — the overwritten
108
+ * promises would never settle. `notify()` drains in arrival order.
109
+ */
110
+ waiters = [];
105
111
  returned = false;
106
112
  broadcaster;
107
113
  constructor(broadcaster) {
@@ -113,20 +119,22 @@ class BroadcastIterator {
113
119
  }
114
120
  /** Called by the broadcaster when new data or completion is available. */
115
121
  notify() {
116
- if (!this.waiter) {
117
- return;
118
- }
119
- const w = this.waiter;
120
- this.waiter = undefined;
121
- try {
122
- const result = this.tryRead();
123
- if (result) {
124
- w.resolve(result);
122
+ while (this.waiters.length > 0) {
123
+ let result;
124
+ try {
125
+ result = this.tryRead();
125
126
  }
126
- }
127
- catch (err) {
128
- // Reject the waiter's promise so the error propagates through the async iterator
129
- w.reject(err);
127
+ catch (err) {
128
+ // Reject so the error propagates through the async iterator. The
129
+ // broadcaster stays finished-with-error, so the loop drains every
130
+ // remaining waiter with the same rejection.
131
+ this.waiters.shift().reject(err);
132
+ continue;
133
+ }
134
+ if (!result) {
135
+ return;
136
+ }
137
+ this.waiters.shift().resolve(result);
130
138
  }
131
139
  }
132
140
  async next() {
@@ -136,25 +144,41 @@ class BroadcastIterator {
136
144
  value: undefined,
137
145
  };
138
146
  }
139
- const result = this.tryRead();
140
- if (result) {
141
- return result;
147
+ // Only read ahead when no one is parked — a pipelined next() must queue
148
+ // BEHIND earlier calls so events are handed out in FIFO order.
149
+ if (this.waiters.length === 0) {
150
+ const result = this.tryRead();
151
+ if (result) {
152
+ return result;
153
+ }
142
154
  }
143
155
  return new Promise((resolve, reject) => {
144
- this.waiter = {
156
+ this.waiters.push({
145
157
  resolve,
146
158
  reject,
147
- };
159
+ });
148
160
  });
149
161
  }
162
+ /** Settle every parked waiter with `{ done: true }` — used on early exit. */
163
+ settleWaiters() {
164
+ const drained = this.waiters.splice(0, this.waiters.length);
165
+ for (const waiter of drained) {
166
+ waiter.resolve({
167
+ done: true,
168
+ value: undefined,
169
+ });
170
+ }
171
+ }
150
172
  async throw(err) {
151
173
  this.returned = true;
152
174
  this.broadcaster.removeIterator(this);
175
+ this.settleWaiters();
153
176
  throw err;
154
177
  }
155
178
  async return() {
156
179
  this.returned = true;
157
180
  this.broadcaster.removeIterator(this);
181
+ this.settleWaiters();
158
182
  return {
159
183
  done: true,
160
184
  value: undefined,
@@ -1,4 +1,4 @@
1
- import type { StorageAdapter } from '../types/memory.js';
1
+ import type { StorageAdapter } from '@noetic-tools/memory';
2
2
  /**
3
3
  * @public Process-local, Map-backed StorageAdapter.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { frameworkCast } from '../util/framework-cast.js';
1
+ import { frameworkCast } from '@noetic-tools/types';
2
2
  //#region Public API
3
3
  /**
4
4
  * @public Process-local, Map-backed StorageAdapter.
@@ -1,6 +1,4 @@
1
- import type { ItemSchemaRegistry } from '../schemas/item.js';
2
- import type { ItemLog } from '../types/context-parts/item-log.js';
3
- import type { Item } from '../types/items.js';
1
+ import type { Item, ItemLog, ItemSchemaRegistry } from '@noetic-tools/types';
4
2
  export declare class ItemLogImpl implements ItemLog {
5
3
  private readonly itemSchemas;
6
4
  private readonly _items;
@@ -1,4 +1,4 @@
1
- import { defaultItemSchemaRegistry } from '../schemas/item.js';
1
+ import { defaultItemSchemaRegistry } from '@noetic-tools/types';
2
2
  export class ItemLogImpl {
3
3
  itemSchemas;
4
4
  _items = [];
@@ -1,5 +1,4 @@
1
- import type { ExecuteInput } from '../types/items.js';
2
- import type { DeliveryMode, ExecuteOptions } from '../types/runtime.js';
1
+ import type { DeliveryMode, ExecuteInput, ExecuteOptions } from '@noetic-tools/types';
3
2
  /** @internal A message accepted by `AgentHarness.execute()` and held until the
4
3
  * session runner processes it. The effective `DeliveryMode` is resolved at
5
4
  * enqueue time so the runner never has to look at harness defaults again. */
@@ -1,7 +1,4 @@
1
- import type { Context } from '../types/context.js';
2
- import type { HarnessResponse } from '../types/harness-result.js';
3
- import type { Item } from '../types/items.js';
4
- import type { HarnessStatus } from '../types/runtime.js';
1
+ import type { Context, HarnessResponse, HarnessStatus, Item } from '@noetic-tools/types';
5
2
  import { EventBroadcaster } from './event-broadcaster.js';
6
3
  import type { QueuedMessage } from './message-queue.js';
7
4
  import { MessageQueue } from './message-queue.js';
@@ -1,5 +1,4 @@
1
- import type { ItemSchemaRegistry } from '../schemas/item.js';
2
- import type { StreamingItem } from '../types/harness-result.js';
1
+ import type { ItemSchemaRegistry, StreamingItem } from '@noetic-tools/types';
3
2
  import type { EventBroadcaster } from './event-broadcaster.js';
4
3
  /** @internal Yield text deltas from the session broadcaster. */
5
4
  export declare function filterTextStream(broadcaster: EventBroadcaster): AsyncIterable<string>;
@@ -1,4 +1,4 @@
1
- import { defaultItemSchemaRegistry } from '../schemas/item.js';
1
+ import { defaultItemSchemaRegistry } from '@noetic-tools/types';
2
2
  //#endregion
3
3
  //#region Helpers
4
4
  function isItemRecord(value) {
@@ -1,5 +1,5 @@
1
- import type { ContextMemory } from '../types/memory.js';
2
- import type { Step } from '../types/step.js';
1
+ import type { ContextMemory } from '@noetic-tools/memory';
2
+ import type { Step } from '@noetic-tools/types';
3
3
  /** Registry-wide step type — stored at the widest generic parameters so
4
4
  * callers can register steps with narrower input/output types without
5
5
  * fighting variance. The public `Step` default already uses `unknown` for
@@ -1,6 +1,5 @@
1
- import { NoeticConfigError } from '../errors/noetic-config-error.js';
1
+ import { frameworkCast, NoeticConfigError } from '@noetic-tools/types';
2
2
  import { setDefaultRegistrar } from '../types/step-registrar.js';
3
- import { frameworkCast } from '../util/framework-cast.js';
4
3
  //#endregion
5
4
  //#region Module state
6
5
  const registry = new Map();
@@ -1,6 +1,4 @@
1
+ import type { AgentHarnessContract, Context, ToolExecutionContext, ToolMemory } from '@noetic-tools/types';
1
2
  import type { TurnContext } from '@openrouter/agent';
2
- import type { Context } from '../types/context.js';
3
- import type { AgentHarnessContract } from '../types/runtime.js';
4
- import type { ToolExecutionContext, ToolMemory } from '../types/tool-context.js';
5
3
  export declare function buildToolMemory(harness: AgentHarnessContract, ctx: Context): ToolMemory;
6
4
  export declare function buildToolExecutionContext(ctx: Context, harness: AgentHarnessContract, turnContext?: TurnContext): ToolExecutionContext;
@@ -1,6 +1,5 @@
1
- import type { StepMeta, TokenUsage } from './common.js';
2
- import type { Context } from './context.js';
3
- import type { ContextMemory } from './memory.js';
1
+ import type { ContextMemory } from '@noetic-tools/memory';
2
+ import type { Context, StepMeta, TokenUsage } from '@noetic-tools/types';
4
3
  /**
5
4
  * Internal-only interface for interpreter code that needs to mutate Context fields.
6
5
  * NOT exported from the package public API.
@@ -13,7 +13,7 @@
13
13
  * when an out-of-process child needs to look up a step by id. In-process
14
14
  * execution walks the step tree directly and never touches either side.
15
15
  */
16
- import type { Step } from './step.js';
16
+ import type { Step } from '@noetic-tools/types';
17
17
  /**
18
18
  * @public
19
19
  * Registers a step under its `id` so the subprocess adapter can later
@@ -7,22 +7,18 @@
7
7
  * and other framework extensions. Do not depend on them in application code.
8
8
  */
9
9
  /** @unstable Budget allocation algorithm for memory layer token budgets. */
10
- export type { BudgetAllocation, BudgetLimits } from './memory/budget.js';
11
- /** @unstable Budget allocation and checking utilities. */
12
- export { allocateBudgets, checkBudget } from './memory/budget.js';
13
10
  /** @unstable Layer state store type for managing per-layer state during execution. */
14
- export type { LayerStateStore } from './memory/layer-lifecycle.js';
11
+ export type { BudgetAllocation, BudgetLimits, LayerStateStore } from '@noetic-tools/memory';
12
+ /** @unstable Budget allocation and checking utilities. */
15
13
  /** @unstable Factory for creating layer state stores. */
16
- export { createLayerStateStore } from './memory/layer-lifecycle.js';
17
14
  /** @unstable View assembly algorithm that converges memory layer outputs into the LLM context. */
18
- export { assembleView } from './memory/projector.js';
19
15
  /** @unstable Factory for creating scoped storage wrappers around a StorageAdapter. */
20
- export { createScopedStorage } from './memory/scope.js';
16
+ export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/memory';
17
+ /** @unstable Unsafe cast utility for bridging internal type boundaries. */
18
+ export { frameworkCast } from '@noetic-tools/types';
21
19
  /**
22
20
  * @unstable Internal helper used by sync agent-spawn paths (worktree isolation)
23
21
  * to seed a child's cwd snapshot without touching `previousCwd`. Not part of
24
22
  * the public surface — call sites must hold exclusive use of the parent ctx.
25
23
  */
26
24
  export { retargetCwdForSpawn } from './runtime/cwd-helpers.js';
27
- /** @unstable Unsafe cast utility for bridging internal type boundaries. */
28
- export { frameworkCast } from './util/framework-cast.js';
package/dist/unstable.js CHANGED
@@ -7,18 +7,15 @@
7
7
  * and other framework extensions. Do not depend on them in application code.
8
8
  */
9
9
  /** @unstable Budget allocation and checking utilities. */
10
- export { allocateBudgets, checkBudget } from './memory/budget.js';
11
10
  /** @unstable Factory for creating layer state stores. */
12
- export { createLayerStateStore } from './memory/layer-lifecycle.js';
13
11
  /** @unstable View assembly algorithm that converges memory layer outputs into the LLM context. */
14
- export { assembleView } from './memory/projector.js';
15
12
  /** @unstable Factory for creating scoped storage wrappers around a StorageAdapter. */
16
- export { createScopedStorage } from './memory/scope.js';
13
+ export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/memory';
14
+ /** @unstable Unsafe cast utility for bridging internal type boundaries. */
15
+ export { frameworkCast } from '@noetic-tools/types';
17
16
  /**
18
17
  * @unstable Internal helper used by sync agent-spawn paths (worktree isolation)
19
18
  * to seed a child's cwd snapshot without touching `previousCwd`. Not part of
20
19
  * the public surface — call sites must hold exclusive use of the parent ctx.
21
20
  */
22
21
  export { retargetCwdForSpawn } from './runtime/cwd-helpers.js';
23
- /** @unstable Unsafe cast utility for bridging internal type boundaries. */
24
- export { frameworkCast } from './util/framework-cast.js';
@@ -1,4 +1,4 @@
1
- import type { Until } from '../types/step.js';
1
+ import type { Until } from '@noetic-tools/types';
2
2
  /**
3
3
  * Combines predicates with OR semantics; stops the loop when any predicate says stop.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { Until } from '../types/step.js';
1
+ import type { Until } from '@noetic-tools/types';
2
2
  /**
3
3
  * Termination predicate that never stops the loop. Use with `every`-like
4
4
  * forever-loops or with explicit cancellation paths.
@@ -1,6 +1,6 @@
1
+ import type { StorageAdapter } from '@noetic-tools/memory';
2
+ import type { Until } from '@noetic-tools/types';
1
3
  import type { EmbedFn } from '../types/embed.js';
2
- import type { StorageAdapter } from '../types/memory.js';
3
- import type { Until } from '../types/step.js';
4
4
  import { never } from './never.js';
5
5
  /** @public Async verification function that checks loop output and optionally returns feedback. */
6
6
  export type VerifyFn = (output: unknown) => Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/core",
3
- "version": "0.2.1",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Step primitives, interpreter, runtime, and memory layer contract for Noetic agents.",
6
6
  "license": "Apache-2.0",
@@ -64,13 +64,15 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
+ "@noetic-tools/memory": "^1.0.1",
68
+ "@noetic-tools/types": "^1.0.0",
67
69
  "@openrouter/agent": "^0.6.0",
68
70
  "zod": "^4.0.0"
69
71
  },
70
72
  "scripts": {
71
73
  "build": "bunx tsc -p tsconfig.build.json && bun scripts/add-js-extensions.ts",
72
74
  "verify:esm": "bun scripts/verify-node-esm.ts",
73
- "prepublishOnly": "rm -rf dist && bun run build && bun run verify:esm",
75
+ "prepublishOnly": "rm -rf dist && bun run build && bun run verify:esm && bun scripts/pin-workspace-deps.ts && bun scripts/strip-dev-conditions.ts",
74
76
  "test": "bun test",
75
77
  "test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
76
78
  "test:ci": "bun test --coverage --coverage-reporter=lcov",
@@ -1,41 +0,0 @@
1
- /**
2
- * @public
3
- * Configuration-time error thrown during construction and setup.
4
- *
5
- * `NoeticConfigError` is separate from `NoeticError`. The two are never interchangeable:
6
- * - `NoeticError` — thrown during execution (LLM failures, fork failures, budget exceeded).
7
- * - `NoeticConfigError` — thrown during construction (invalid step config, missing env vars, runtime misconfiguration).
8
- *
9
- * @example
10
- * ```ts
11
- * try {
12
- * loop({ id: '', steps: [], until: until.maxSteps(10) });
13
- * } catch (e) {
14
- * if (isNoeticConfigError(e)) {
15
- * console.error(e.code, e.hint);
16
- * }
17
- * }
18
- * ```
19
- */
20
- export declare class NoeticConfigError extends Error {
21
- /** SCREAMING_SNAKE_CASE code uniquely identifying this error condition. */
22
- readonly code: string;
23
- /** Complete sentence describing what the user should do next. */
24
- readonly hint: string;
25
- /** Link to the relevant docs page, if available. */
26
- readonly docsUrl?: string;
27
- constructor(opts: {
28
- code: string;
29
- message: string;
30
- hint: string;
31
- docsUrl?: string;
32
- });
33
- }
34
- /**
35
- * @public
36
- * Type guard for `NoeticConfigError`.
37
- *
38
- * @param e - Value to check.
39
- * @returns `true` if `e` is a `NoeticConfigError`.
40
- */
41
- export declare function isNoeticConfigError(e: unknown): e is NoeticConfigError;
@@ -1,44 +0,0 @@
1
- /**
2
- * @public
3
- * Configuration-time error thrown during construction and setup.
4
- *
5
- * `NoeticConfigError` is separate from `NoeticError`. The two are never interchangeable:
6
- * - `NoeticError` — thrown during execution (LLM failures, fork failures, budget exceeded).
7
- * - `NoeticConfigError` — thrown during construction (invalid step config, missing env vars, runtime misconfiguration).
8
- *
9
- * @example
10
- * ```ts
11
- * try {
12
- * loop({ id: '', steps: [], until: until.maxSteps(10) });
13
- * } catch (e) {
14
- * if (isNoeticConfigError(e)) {
15
- * console.error(e.code, e.hint);
16
- * }
17
- * }
18
- * ```
19
- */
20
- export class NoeticConfigError extends Error {
21
- /** SCREAMING_SNAKE_CASE code uniquely identifying this error condition. */
22
- code;
23
- /** Complete sentence describing what the user should do next. */
24
- hint;
25
- /** Link to the relevant docs page, if available. */
26
- docsUrl;
27
- constructor(opts) {
28
- super(opts.message);
29
- this.name = 'NoeticConfigError';
30
- this.code = opts.code;
31
- this.hint = opts.hint;
32
- this.docsUrl = opts.docsUrl;
33
- }
34
- }
35
- /**
36
- * @public
37
- * Type guard for `NoeticConfigError`.
38
- *
39
- * @param e - Value to check.
40
- * @returns `true` if `e` is a `NoeticConfigError`.
41
- */
42
- export function isNoeticConfigError(e) {
43
- return e instanceof NoeticConfigError;
44
- }
@@ -1,18 +0,0 @@
1
- import type { NoeticError } from '../types/error.js';
2
- /**
3
- * Runtime error thrown during step execution (LLM failures, fork failures, budget exceeded, etc.).
4
- *
5
- * @public
6
- */
7
- export declare class NoeticErrorImpl extends Error {
8
- readonly noeticError: NoeticError;
9
- constructor(error: NoeticError);
10
- }
11
- /**
12
- * Type guard for `NoeticErrorImpl`.
13
- *
14
- * @public
15
- * @param e - Value to check.
16
- * @returns `true` if `e` is a `NoeticErrorImpl`.
17
- */
18
- export declare function isNoeticError(e: unknown): e is NoeticErrorImpl;
@@ -1,54 +0,0 @@
1
- /**
2
- * Runtime error thrown during step execution (LLM failures, fork failures, budget exceeded, etc.).
3
- *
4
- * @public
5
- */
6
- export class NoeticErrorImpl extends Error {
7
- noeticError;
8
- constructor(error) {
9
- super(formatMessage(error));
10
- this.name = 'NoeticError';
11
- this.noeticError = error;
12
- }
13
- }
14
- /**
15
- * Type guard for `NoeticErrorImpl`.
16
- *
17
- * @public
18
- * @param e - Value to check.
19
- * @returns `true` if `e` is a `NoeticErrorImpl`.
20
- */
21
- export function isNoeticError(e) {
22
- return e instanceof NoeticErrorImpl;
23
- }
24
- function formatMessage(error) {
25
- switch (error.kind) {
26
- case 'step_failed':
27
- return `Step '${error.stepId}' failed: ${error.cause.message}`;
28
- case 'llm_refused':
29
- return `LLM refused at step '${error.stepId}': ${error.refusal}`;
30
- case 'llm_parse_error':
31
- return `LLM parse error at step '${error.stepId}': failed to parse output`;
32
- case 'llm_rate_limit':
33
- return `LLM rate limited at step '${error.stepId}'${error.retryAfter ? ` (retry after ${error.retryAfter}ms)` : ''}`;
34
- case 'fork_partial':
35
- return `Fork '${error.stepId}' partial failure: ${error.succeeded.length} succeeded, ${error.failed.length} failed`;
36
- case 'channel_timeout':
37
- return `Channel '${error.channelName}' timed out after ${error.timeout}ms`;
38
- case 'channel_closed':
39
- return `Channel '${error.channelName}' is closed`;
40
- case 'cancelled':
41
- return `Cancelled${error.reason ? `: ${error.reason}` : ''}`;
42
- case 'budget_exceeded':
43
- return `Budget exceeded: ${error.field} limit ${error.limit}, actual ${error.actual}`;
44
- case 'steering_denied':
45
- return `Steering denied${error.guidance ? `: ${error.guidance}` : ''}`;
46
- case 'handle_evicted':
47
- return `Subprocess handle '${error.handleId}' evicted (step '${error.stepId}'): adapter returned null for ${error.gracePeriodMs}ms`;
48
- default: {
49
- const _exhaustive = error;
50
- void _exhaustive;
51
- return 'NoeticError: unknown kind';
52
- }
53
- }
54
- }
@@ -1,23 +0,0 @@
1
- import type { Context } from '../types/context.js';
2
- import type { MemoryLayer } from '../types/memory.js';
3
- export interface BudgetAllocation {
4
- layerId: string;
5
- allocated: number;
6
- }
7
- interface AllocateBudgetsOpts {
8
- layers: MemoryLayer[];
9
- totalBudget: number;
10
- systemPromptTokens: number;
11
- responseReserve: number;
12
- }
13
- export declare function allocateBudgets({ layers, totalBudget, systemPromptTokens, responseReserve, }: AllocateBudgetsOpts): {
14
- allocations: BudgetAllocation[];
15
- historyBudget: number;
16
- };
17
- export interface BudgetLimits {
18
- maxCost?: number;
19
- maxSteps?: number;
20
- maxDuration?: number;
21
- }
22
- export declare function checkBudget(ctx: Context, limits: BudgetLimits): void;
23
- export {};