@noetic-tools/core 0.0.1 → 0.1.1

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 (254) hide show
  1. package/README.md +31 -11
  2. package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
  3. package/dist/adapters/in-memory-fs-adapter.js +1 -1
  4. package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
  5. package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +8 -0
  6. package/dist/adapters/in-memory-subprocess/manifest-persistence.js +56 -0
  7. package/dist/adapters/in-memory-subprocess/metadata.d.ts +12 -0
  8. package/dist/adapters/in-memory-subprocess/metadata.js +58 -0
  9. package/dist/adapters/in-memory-subprocess/step-completion.d.ts +3 -0
  10. package/dist/adapters/in-memory-subprocess/step-completion.js +86 -0
  11. package/dist/adapters/in-memory-subprocess/types.d.ts +88 -0
  12. package/dist/adapters/in-memory-subprocess/types.js +2 -0
  13. package/dist/adapters/in-memory-subprocess-adapter.d.ts +12 -4
  14. package/dist/adapters/in-memory-subprocess-adapter.js +164 -55
  15. package/dist/adapters/openrouter.d.ts +16 -7
  16. package/dist/adapters/openrouter.js +68 -7
  17. package/dist/builders/channel-builder.d.ts +1 -1
  18. package/dist/builders/control-flow-builders.d.ts +3 -3
  19. package/dist/builders/control-flow-builders.js +9 -4
  20. package/dist/builders/every.d.ts +3 -3
  21. package/dist/builders/every.js +5 -2
  22. package/dist/builders/layer-provides-builders.d.ts +1 -32
  23. package/dist/builders/layer-provides-builders.js +1 -33
  24. package/dist/builders/loop-builder.d.ts +2 -2
  25. package/dist/builders/loop-builder.js +5 -2
  26. package/dist/builders/memory-builder.d.ts +1 -1
  27. package/dist/builders/memory-builder.js +1 -1
  28. package/dist/builders/provide-builder.d.ts +2 -2
  29. package/dist/builders/provide-builder.js +5 -2
  30. package/dist/builders/spawn-builder.d.ts +22 -9
  31. package/dist/builders/spawn-builder.js +17 -3
  32. package/dist/builders/step-builders.d.ts +51 -30
  33. package/dist/builders/step-builders.js +31 -12
  34. package/dist/builders/tool-builder.d.ts +7 -3
  35. package/dist/builders/tool-builder.js +3 -1
  36. package/dist/builders/workflow-hydrator.d.ts +38 -0
  37. package/dist/builders/workflow-hydrator.js +336 -0
  38. package/dist/conditions/conditions.d.ts +4 -4
  39. package/dist/conditions/conditions.js +2 -2
  40. package/dist/errors/noetic-error.d.ts +1 -1
  41. package/dist/errors/noetic-error.js +2 -0
  42. package/dist/{runtime → harness}/agent-harness.d.ts +65 -45
  43. package/dist/harness/agent-harness.js +576 -0
  44. package/dist/harness/deps/adapters.d.ts +4 -0
  45. package/dist/harness/deps/adapters.js +4 -0
  46. package/dist/harness/deps/interpreter.d.ts +5 -0
  47. package/dist/harness/deps/interpreter.js +4 -0
  48. package/dist/harness/deps/memory.d.ts +5 -0
  49. package/dist/harness/deps/memory.js +4 -0
  50. package/dist/harness/deps/runtime.d.ts +10 -0
  51. package/dist/harness/deps/runtime.js +7 -0
  52. package/dist/harness/deps/types.d.ts +17 -0
  53. package/dist/harness/deps/types.js +1 -0
  54. package/dist/harness/model-call.d.ts +50 -0
  55. package/dist/harness/model-call.js +694 -0
  56. package/dist/harness/model-schema.d.ts +19 -0
  57. package/dist/harness/model-schema.js +46 -0
  58. package/dist/harness/step-bootstrap.d.ts +25 -0
  59. package/dist/harness/step-bootstrap.js +170 -0
  60. package/dist/index.d.ts +114 -76
  61. package/dist/index.js +74 -50
  62. package/dist/internal-test.d.ts +4 -4
  63. package/dist/internal-test.js +4 -4
  64. package/dist/interpreter/action-deps.d.ts +12 -0
  65. package/dist/interpreter/action-deps.js +10 -0
  66. package/dist/interpreter/action-types.d.ts +8 -0
  67. package/dist/interpreter/action-types.js +1 -0
  68. package/dist/interpreter/collect-tools.d.ts +2 -2
  69. package/dist/interpreter/collect-tools.js +6 -2
  70. package/dist/interpreter/execute-action.d.ts +22 -0
  71. package/dist/interpreter/execute-action.js +527 -0
  72. package/dist/interpreter/{execute-every.d.ts → execute-control.d.ts} +8 -2
  73. package/dist/interpreter/execute-control.js +530 -0
  74. package/dist/interpreter/execute.d.ts +16 -3
  75. package/dist/interpreter/execute.js +154 -51
  76. package/dist/interpreter/message-helpers.d.ts +1 -9
  77. package/dist/interpreter/message-helpers.js +1 -42
  78. package/dist/interpreter/step-dispatcher.d.ts +61 -0
  79. package/dist/interpreter/step-dispatcher.js +67 -0
  80. package/dist/interpreter/typeguards.d.ts +8 -15
  81. package/dist/interpreter/typeguards.js +4 -21
  82. package/dist/memory/budget.d.ts +2 -2
  83. package/dist/memory/budget.js +1 -1
  84. package/dist/{runtime → memory}/exec-context-factory.d.ts +2 -2
  85. package/dist/{runtime → memory}/exec-context-factory.js +1 -1
  86. package/dist/memory/flow-schema.d.ts +52 -0
  87. package/dist/memory/flow-schema.js +102 -0
  88. package/dist/memory/function-call-utils.d.ts +1 -1
  89. package/dist/memory/function-call-utils.js +4 -2
  90. package/dist/memory/layer-api.d.ts +4 -4
  91. package/dist/memory/layer-api.js +2 -2
  92. package/dist/memory/layer-lifecycle.d.ts +6 -6
  93. package/dist/memory/layer-lifecycle.js +6 -6
  94. package/dist/memory/layer-provides.d.ts +32 -0
  95. package/dist/memory/layer-provides.js +33 -0
  96. package/dist/memory/layer-usage.d.ts +4 -3
  97. package/dist/memory/layer-usage.js +9 -3
  98. package/dist/memory/layers/durable-task-state.d.ts +8 -8
  99. package/dist/memory/layers/durable-task-state.js +2 -2
  100. package/dist/memory/layers/file-reference.d.ts +1 -1
  101. package/dist/memory/layers/file-reference.js +303 -247
  102. package/dist/memory/layers/history-window.d.ts +1 -1
  103. package/dist/memory/layers/history-window.js +4 -4
  104. package/dist/memory/layers/observational-memory.d.ts +5 -5
  105. package/dist/memory/layers/observational-memory.js +2 -3
  106. package/dist/memory/layers/plan.d.ts +2 -2
  107. package/dist/memory/layers/plan.js +15 -10
  108. package/dist/memory/layers/static-content.d.ts +2 -2
  109. package/dist/memory/layers/static-content.js +1 -1
  110. package/dist/memory/layers/steering.d.ts +7 -7
  111. package/dist/memory/layers/steering.js +5 -5
  112. package/dist/memory/layers/tool-memory-layer.d.ts +2 -2
  113. package/dist/memory/layers/tool-memory-layer.js +1 -1
  114. package/dist/memory/layers/working-memory.d.ts +7 -7
  115. package/dist/memory/layers/working-memory.js +4 -4
  116. package/dist/memory/projector.d.ts +2 -2
  117. package/dist/memory/scope.d.ts +1 -1
  118. package/dist/memory/strip-unresolved.d.ts +1 -1
  119. package/dist/observability/span-impl.d.ts +1 -1
  120. package/dist/observability/trace-exporter.d.ts +2 -2
  121. package/dist/observability/trace-exporter.js +1 -1
  122. package/dist/patterns/dynamic-workflow.d.ts +55 -0
  123. package/dist/patterns/dynamic-workflow.js +194 -0
  124. package/dist/patterns/flow.d.ts +2 -52
  125. package/dist/patterns/flow.js +1 -103
  126. package/dist/patterns/interview.d.ts +2 -2
  127. package/dist/patterns/interview.js +5 -5
  128. package/dist/patterns/plans.d.ts +6 -6
  129. package/dist/patterns/plans.js +4 -4
  130. package/dist/patterns/ralph-wiggum.d.ts +4 -4
  131. package/dist/patterns/ralph-wiggum.js +5 -5
  132. package/dist/patterns/react.d.ts +3 -3
  133. package/dist/patterns/react.js +5 -5
  134. package/dist/portable/adapters.d.ts +6 -0
  135. package/dist/portable/adapters.js +6 -0
  136. package/dist/portable/ask-user.d.ts +4 -0
  137. package/dist/portable/ask-user.js +2 -0
  138. package/dist/portable/builders.d.ts +12 -0
  139. package/dist/portable/builders.js +12 -0
  140. package/dist/portable/memory-layers.d.ts +12 -0
  141. package/dist/portable/memory-layers.js +12 -0
  142. package/dist/portable/runtime.d.ts +4 -0
  143. package/dist/portable/runtime.js +4 -0
  144. package/dist/portable/until.d.ts +4 -0
  145. package/dist/portable/until.js +4 -0
  146. package/dist/portable.d.ts +8 -26
  147. package/dist/portable.js +8 -34
  148. package/dist/runtime/broadcaster-utils.d.ts +7 -3
  149. package/dist/runtime/broadcaster-utils.js +11 -6
  150. package/dist/runtime/channel-store.d.ts +1 -1
  151. package/dist/runtime/channel-store.js +2 -2
  152. package/dist/runtime/context-deps.d.ts +4 -0
  153. package/dist/runtime/context-deps.js +2 -0
  154. package/dist/runtime/context-impl.d.ts +42 -12
  155. package/dist/runtime/context-impl.js +52 -5
  156. package/dist/runtime/context-type-deps.d.ts +14 -0
  157. package/dist/runtime/context-type-deps.js +1 -0
  158. package/dist/runtime/cwd-helpers.d.ts +1 -1
  159. package/dist/runtime/detached-handle.d.ts +52 -4
  160. package/dist/runtime/detached-handle.js +218 -14
  161. package/dist/runtime/durable/checkpoint-store.d.ts +38 -0
  162. package/dist/runtime/durable/checkpoint-store.js +101 -0
  163. package/dist/runtime/durable/detached-signal.d.ts +37 -0
  164. package/dist/runtime/durable/detached-signal.js +52 -0
  165. package/dist/runtime/durable/harness-checkpoints.d.ts +51 -0
  166. package/dist/runtime/durable/harness-checkpoints.js +104 -0
  167. package/dist/runtime/durable/index.d.ts +10 -0
  168. package/dist/runtime/durable/index.js +5 -0
  169. package/dist/runtime/durable/runnable-loop.d.ts +100 -0
  170. package/dist/runtime/durable/runnable-loop.js +90 -0
  171. package/dist/runtime/durable/session-seed.d.ts +28 -0
  172. package/dist/runtime/durable/session-seed.js +27 -0
  173. package/dist/runtime/durable/stall-nudge.d.ts +82 -0
  174. package/dist/runtime/durable/stall-nudge.js +87 -0
  175. package/dist/runtime/event-broadcaster.d.ts +1 -1
  176. package/dist/runtime/in-memory-storage.d.ts +1 -1
  177. package/dist/runtime/in-memory-storage.js +1 -1
  178. package/dist/runtime/item-log-impl.d.ts +3 -3
  179. package/dist/runtime/item-log-impl.js +1 -1
  180. package/dist/runtime/message-queue.d.ts +2 -2
  181. package/dist/runtime/session-runner.d.ts +7 -7
  182. package/dist/runtime/session-runner.js +3 -3
  183. package/dist/runtime/session-streams.d.ts +3 -3
  184. package/dist/runtime/session-streams.js +1 -1
  185. package/dist/runtime/step-registry.d.ts +42 -0
  186. package/dist/runtime/step-registry.js +77 -0
  187. package/dist/runtime/tool-memory.d.ts +3 -3
  188. package/dist/schemas/item.d.ts +1 -1
  189. package/dist/schemas/workflow.d.ts +139 -0
  190. package/dist/schemas/workflow.js +232 -0
  191. package/dist/types/ask-user-types.d.ts +57 -0
  192. package/dist/types/ask-user-types.js +74 -0
  193. package/dist/types/checkpoint.d.ts +98 -0
  194. package/dist/types/checkpoint.js +81 -0
  195. package/dist/types/common.d.ts +1 -50
  196. package/dist/types/context-parts/item-log.d.ts +6 -0
  197. package/dist/types/context-parts/item-log.js +1 -0
  198. package/dist/types/context-parts/layer-usage.d.ts +18 -0
  199. package/dist/types/context-parts/layer-usage.js +1 -0
  200. package/dist/types/context.d.ts +140 -31
  201. package/dist/types/error.d.ts +15 -0
  202. package/dist/types/harness-result.d.ts +2 -2
  203. package/dist/types/items.d.ts +18 -2
  204. package/dist/types/memory-context.d.ts +39 -0
  205. package/dist/types/memory-context.js +1 -0
  206. package/dist/types/memory.d.ts +38 -68
  207. package/dist/types/mutable-context.d.ts +3 -3
  208. package/dist/types/runtime.d.ts +14 -13
  209. package/dist/types/steering.d.ts +2 -2
  210. package/dist/types/step-registrar.d.ts +46 -0
  211. package/dist/types/step-registrar.js +56 -0
  212. package/dist/types/step.d.ts +34 -9
  213. package/dist/types/subprocess-adapter.d.ts +119 -3
  214. package/dist/types/subprocess-adapter.js +2 -0
  215. package/dist/types/tool-context.d.ts +6 -6
  216. package/dist/types/tool.d.ts +64 -0
  217. package/dist/types/tool.js +1 -0
  218. package/dist/unstable.d.ts +9 -9
  219. package/dist/unstable.js +7 -7
  220. package/dist/until/combinators.d.ts +1 -1
  221. package/dist/until/never.d.ts +1 -1
  222. package/dist/until/predicates.d.ts +13 -4
  223. package/dist/until/predicates.js +16 -2
  224. package/dist/util/message-helpers.d.ts +17 -0
  225. package/dist/util/message-helpers.js +64 -0
  226. package/package.json +6 -4
  227. package/dist/adapters/local-fs-adapter.d.ts +0 -3
  228. package/dist/adapters/local-fs-adapter.js +0 -43
  229. package/dist/adapters/local-shell-adapter.d.ts +0 -51
  230. package/dist/adapters/local-shell-adapter.js +0 -167
  231. package/dist/adapters/local-subprocess-adapter.d.ts +0 -16
  232. package/dist/adapters/local-subprocess-adapter.js +0 -187
  233. package/dist/conditions/index.d.ts +0 -3
  234. package/dist/conditions/index.js +0 -2
  235. package/dist/interpreter/execute-branch.d.ts +0 -3
  236. package/dist/interpreter/execute-branch.js +0 -10
  237. package/dist/interpreter/execute-every.js +0 -143
  238. package/dist/interpreter/execute-fork.d.ts +0 -3
  239. package/dist/interpreter/execute-fork.js +0 -215
  240. package/dist/interpreter/execute-llm.d.ts +0 -4
  241. package/dist/interpreter/execute-llm.js +0 -217
  242. package/dist/interpreter/execute-loop.d.ts +0 -3
  243. package/dist/interpreter/execute-loop.js +0 -171
  244. package/dist/interpreter/execute-provide.d.ts +0 -10
  245. package/dist/interpreter/execute-provide.js +0 -64
  246. package/dist/interpreter/execute-run.d.ts +0 -3
  247. package/dist/interpreter/execute-run.js +0 -39
  248. package/dist/interpreter/execute-spawn.d.ts +0 -11
  249. package/dist/interpreter/execute-spawn.js +0 -113
  250. package/dist/interpreter/execute-tool.d.ts +0 -5
  251. package/dist/interpreter/execute-tool.js +0 -81
  252. package/dist/runtime/agent-harness.js +0 -1170
  253. /package/dist/{interpreter → util}/framework-cast.d.ts +0 -0
  254. /package/dist/{interpreter → util}/framework-cast.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { ZodType } from 'zod';
2
- import type { ContextMemory } from '../types/memory';
3
- import type { Step } from '../types/step';
2
+ import type { ContextMemory } from '../types/memory.js';
3
+ import type { Step } from '../types/step.js';
4
4
  /** @public Answer captured by the host for a single interview question. */
5
5
  export interface InterviewQuestionAnswer {
6
6
  questionId: string;
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { loop } from '../builders/loop-builder';
3
- import { step } from '../builders/step-builders';
4
- import { frameworkCast } from '../interpreter/framework-cast';
5
- import { any } from '../until/combinators';
6
- import { until } from '../until/predicates';
2
+ import { loop } from '../builders/loop-builder.js';
3
+ import { step } from '../builders/step-builders.js';
4
+ import { any } from '../until/combinators.js';
5
+ import { until } from '../until/predicates.js';
6
+ import { frameworkCast } from '../util/framework-cast.js';
7
7
  //#endregion
8
8
  //#region Helpers
9
9
  const DEFAULT_MAX_QUESTIONS = 8;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import type { Context } from '../types/context';
3
- import type { ContextMemory } from '../types/memory';
4
- import type { ExecuteStepFn, Step } from '../types/step';
2
+ import type { Context } from '../types/context.js';
3
+ import type { ContextMemory } from '../types/memory.js';
4
+ import type { ExecuteStepFn, Step } from '../types/step.js';
5
5
  export interface PlanNode {
6
6
  id: string;
7
7
  description: string;
@@ -27,7 +27,7 @@ export interface PlanConstraints {
27
27
  * @param executeStep - Optional step executor for non-run step kinds.
28
28
  * @returns A compiled `Step` ready for execution.
29
29
  */
30
- export declare function compilePlan<O>(plan: PlanNode, agents: Record<string, (prompt: string) => Step<ContextMemory, string, unknown>>, constraints?: PlanConstraints, executeStep?: ExecuteStepFn): Step<ContextMemory, string, O>;
30
+ export declare function compilePlan<O, A = unknown>(plan: PlanNode, agents: Record<string, (prompt: string) => Step<ContextMemory, string, A>>, constraints?: PlanConstraints, executeStep?: ExecuteStepFn): Step<ContextMemory, string, O>;
31
31
  /**
32
32
  * Creates a step that dynamically generates a plan via a planner step and executes it,
33
33
  * retrying with error feedback up to `maxRevisions` times on failure.
@@ -36,9 +36,9 @@ export declare function compilePlan<O>(plan: PlanNode, agents: Record<string, (p
36
36
  * @param opts - Planner step, agent factories, optional constraints, max revision count, and step executor.
37
37
  * @returns A `Step` that adaptively plans and executes.
38
38
  */
39
- export declare function adaptivePlan<O>(opts: {
39
+ export declare function adaptivePlan<O, A = unknown>(opts: {
40
40
  planner: Step<ContextMemory, string, PlanNode>;
41
- agents: Record<string, (prompt: string) => Step<ContextMemory, string, unknown>>;
41
+ agents: Record<string, (prompt: string) => Step<ContextMemory, string, A>>;
42
42
  constraints?: PlanConstraints;
43
43
  maxRevisions: number;
44
44
  executeStep?: ExecuteStepFn;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { fork } from '../builders/control-flow-builders';
3
- import { frameworkCast } from '../interpreter/framework-cast';
2
+ import { fork } from '../builders/control-flow-builders.js';
3
+ import { frameworkCast } from '../util/framework-cast.js';
4
4
  // PlanNode schema — the variable annotation provides the recursive type;
5
5
  // z.lazy() returns a compatible type that TypeScript checks against it.
6
6
  /** @public Zod schema for recursive `PlanNode` validation. */
@@ -47,7 +47,7 @@ function compileNode(node, opts) {
47
47
  id: `plan-fork-${node.id}`,
48
48
  mode: 'all',
49
49
  paths: () => childSteps,
50
- merge: (results) => results[results.length - 1],
50
+ merge: (results) => frameworkCast(results[results.length - 1]),
51
51
  });
52
52
  }
53
53
  // Sequential - chain steps via a run step that uses executeStep
@@ -68,7 +68,7 @@ function compileNode(node, opts) {
68
68
  throw new Error(`No executeStep provided and child step kind '${child.kind}' cannot be executed directly`);
69
69
  }
70
70
  }
71
- return currentOutput;
71
+ return frameworkCast(currentOutput);
72
72
  },
73
73
  };
74
74
  }
@@ -1,7 +1,7 @@
1
- import type { Tool } from '../types/common';
2
- import type { ContextMemory } from '../types/memory';
3
- import type { StepLoop } from '../types/step';
4
- import type { VerifyFn } from '../until/predicates';
1
+ import type { ContextMemory } from '../types/memory.js';
2
+ import type { StepLoop } from '../types/step.js';
3
+ import type { Tool } from '../types/tool.js';
4
+ import type { VerifyFn } from '../until/predicates.js';
5
5
  /**
6
6
  * Creates a retry-with-feedback loop wrapping a ReAct agent. Each iteration spawns an inner agent
7
7
  * and retries with verification feedback until the verifier passes or max iterations is reached.
@@ -1,8 +1,8 @@
1
- import { loop } from '../builders/loop-builder';
2
- import { spawn } from '../builders/spawn-builder';
3
- import { any } from '../until/combinators';
4
- import { until } from '../until/predicates';
5
- import { react } from './react';
1
+ import { loop } from '../builders/loop-builder.js';
2
+ import { spawn } from '../builders/spawn-builder.js';
3
+ import { any } from '../until/combinators.js';
4
+ import { until } from '../until/predicates.js';
5
+ import { react } from './react.js';
6
6
  /**
7
7
  * Creates a retry-with-feedback loop wrapping a ReAct agent. Each iteration spawns an inner agent
8
8
  * and retries with verification feedback until the verifier passes or max iterations is reached.
@@ -1,6 +1,6 @@
1
- import type { Tool } from '../types/common';
2
- import type { ContextMemory, MemoryConfig, MemoryLayer } from '../types/memory';
3
- import type { StepLoop, StepSpawn } from '../types/step';
1
+ import type { ContextMemory, MemoryConfig, MemoryLayer } from '../types/memory.js';
2
+ import type { StepLoop, StepSpawn } from '../types/step.js';
3
+ import type { Tool } from '../types/tool.js';
4
4
  /**
5
5
  * Creates a ReAct (Reason + Act) agent loop: an LLM step with tools iterated until no tool calls or limits are hit.
6
6
  *
@@ -1,8 +1,8 @@
1
- import { loop } from '../builders/loop-builder';
2
- import { spawn } from '../builders/spawn-builder';
3
- import { step } from '../builders/step-builders';
4
- import { any } from '../until/combinators';
5
- import { until } from '../until/predicates';
1
+ import { loop } from '../builders/loop-builder.js';
2
+ import { spawn } from '../builders/spawn-builder.js';
3
+ import { step } from '../builders/step-builders.js';
4
+ import { any } from '../until/combinators.js';
5
+ import { until } from '../until/predicates.js';
6
6
  /**
7
7
  * Creates a ReAct (Reason + Act) agent loop: an LLM step with tools iterated until no tool calls or limits are hit.
8
8
  *
@@ -0,0 +1,6 @@
1
+ /** @public */
2
+ export { createInMemoryFsAdapter } from '../adapters/in-memory-fs-adapter.js';
3
+ /** @public */
4
+ export { createInMemoryShellAdapter } from '../adapters/in-memory-shell-adapter.js';
5
+ /** @public */
6
+ export { createInMemorySubprocessAdapter } from '../adapters/in-memory-subprocess-adapter.js';
@@ -0,0 +1,6 @@
1
+ /** @public */
2
+ export { createInMemoryFsAdapter } from '../adapters/in-memory-fs-adapter.js';
3
+ /** @public */
4
+ export { createInMemoryShellAdapter } from '../adapters/in-memory-shell-adapter.js';
5
+ /** @public */
6
+ export { createInMemorySubprocessAdapter } from '../adapters/in-memory-subprocess-adapter.js';
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export type { AskUserAnnotation, AskUserInput, AskUserOption, AskUserOutput, AskUserQuestion, } from '../types/ask-user-types.js';
3
+ /** @public */
4
+ export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from '../types/ask-user-types.js';
@@ -0,0 +1,2 @@
1
+ /** @public */
2
+ export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from '../types/ask-user-types.js';
@@ -0,0 +1,12 @@
1
+ /** @public */
2
+ export { branch, fork } from '../builders/control-flow-builders.js';
3
+ /** @public */
4
+ export { layerData, layerFn } from '../builders/layer-provides-builders.js';
5
+ /** @public */
6
+ export { loop } from '../builders/loop-builder.js';
7
+ /** @public */
8
+ export { spawn } from '../builders/spawn-builder.js';
9
+ /** @public */
10
+ export { step } from '../builders/step-builders.js';
11
+ /** @public */
12
+ export { tool, toolWithGenerator } from '../builders/tool-builder.js';
@@ -0,0 +1,12 @@
1
+ /** @public */
2
+ export { branch, fork } from '../builders/control-flow-builders.js';
3
+ /** @public */
4
+ export { layerData, layerFn } from '../builders/layer-provides-builders.js';
5
+ /** @public */
6
+ export { loop } from '../builders/loop-builder.js';
7
+ /** @public */
8
+ export { spawn } from '../builders/spawn-builder.js';
9
+ /** @public */
10
+ export { step } from '../builders/step-builders.js';
11
+ /** @public */
12
+ export { tool, toolWithGenerator } from '../builders/tool-builder.js';
@@ -0,0 +1,12 @@
1
+ /** @public */
2
+ export { durableTaskState } from '../memory/layers/durable-task-state.js';
3
+ /** @public */
4
+ export { historyWindow } from '../memory/layers/history-window.js';
5
+ /** @public */
6
+ export { observationalMemory } from '../memory/layers/observational-memory.js';
7
+ /** @public */
8
+ export { planMemory } from '../memory/layers/plan.js';
9
+ /** @public */
10
+ export { toolMemoryLayer } from '../memory/layers/tool-memory-layer.js';
11
+ /** @public */
12
+ export { workingMemory } from '../memory/layers/working-memory.js';
@@ -0,0 +1,12 @@
1
+ /** @public */
2
+ export { durableTaskState } from '../memory/layers/durable-task-state.js';
3
+ /** @public */
4
+ export { historyWindow } from '../memory/layers/history-window.js';
5
+ /** @public */
6
+ export { observationalMemory } from '../memory/layers/observational-memory.js';
7
+ /** @public */
8
+ export { planMemory } from '../memory/layers/plan.js';
9
+ /** @public */
10
+ export { toolMemoryLayer } from '../memory/layers/tool-memory-layer.js';
11
+ /** @public */
12
+ export { workingMemory } from '../memory/layers/working-memory.js';
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export { AgentHarness } from '../harness/agent-harness.js';
3
+ /** @public */
4
+ export { createInMemoryStorage } from '../runtime/in-memory-storage.js';
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export { AgentHarness } from '../harness/agent-harness.js';
3
+ /** @public */
4
+ export { createInMemoryStorage } from '../runtime/in-memory-storage.js';
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export { all, any } from '../until/combinators.js';
3
+ /** @public */
4
+ export { until } from '../until/predicates.js';
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export { all, any } from '../until/combinators.js';
3
+ /** @public */
4
+ export { until } from '../until/predicates.js';
@@ -1,26 +1,8 @@
1
- /** @public */
2
- export { createInMemoryFsAdapter } from './adapters/in-memory-fs-adapter';
3
- /** @public */
4
- export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter';
5
- /** @public */
6
- export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter';
7
- /** @public */
8
- export { step } from './builders/step-builders';
9
- /** @public */
10
- export { tool, toolWithGenerator } from './builders/tool-builder';
11
- /** @public */
12
- export { durableTaskState } from './memory/layers/durable-task-state';
13
- /** @public */
14
- export { historyWindow } from './memory/layers/history-window';
15
- /** @public */
16
- export { observationalMemory } from './memory/layers/observational-memory';
17
- /** @public */
18
- export { planMemory } from './memory/layers/plan';
19
- /** @public */
20
- export { toolMemoryLayer } from './memory/layers/tool-memory-layer';
21
- /** @public */
22
- export { workingMemory } from './memory/layers/working-memory';
23
- /** @public */
24
- export { AgentHarness } from './runtime/agent-harness';
25
- /** @public */
26
- export { createInMemoryStorage } from './runtime/in-memory-storage';
1
+ export * from './portable/adapters.js';
2
+ export * from './portable/ask-user.js';
3
+ export * from './portable/builders.js';
4
+ export * from './portable/memory-layers.js';
5
+ export * from './portable/runtime.js';
6
+ export * from './portable/until.js';
7
+ /** @public */
8
+ export { Slot } from './types/memory.js';
package/dist/portable.js CHANGED
@@ -1,34 +1,8 @@
1
- //#region Portable Adapters
2
- /** @public */
3
- export { createInMemoryFsAdapter } from './adapters/in-memory-fs-adapter';
4
- /** @public */
5
- export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter';
6
- /** @public */
7
- export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter';
8
- //#endregion
9
- //#region Builders
10
- /** @public */
11
- export { step } from './builders/step-builders';
12
- /** @public */
13
- export { tool, toolWithGenerator } from './builders/tool-builder';
14
- //#endregion
15
- //#region Memory Layers
16
- /** @public */
17
- export { durableTaskState } from './memory/layers/durable-task-state';
18
- /** @public */
19
- export { historyWindow } from './memory/layers/history-window';
20
- /** @public */
21
- export { observationalMemory } from './memory/layers/observational-memory';
22
- /** @public */
23
- export { planMemory } from './memory/layers/plan';
24
- /** @public */
25
- export { toolMemoryLayer } from './memory/layers/tool-memory-layer';
26
- /** @public */
27
- export { workingMemory } from './memory/layers/working-memory';
28
- //#endregion
29
- //#region Runtime
30
- /** @public */
31
- export { AgentHarness } from './runtime/agent-harness';
32
- /** @public */
33
- export { createInMemoryStorage } from './runtime/in-memory-storage';
34
- //#endregion
1
+ export * from './portable/adapters.js';
2
+ export * from './portable/ask-user.js';
3
+ export * from './portable/builders.js';
4
+ export * from './portable/memory-layers.js';
5
+ export * from './portable/runtime.js';
6
+ export * from './portable/until.js';
7
+ /** @public */
8
+ export { Slot } from './types/memory.js';
@@ -1,5 +1,5 @@
1
- import type { Context } from '../types/context';
2
- import type { EventBroadcaster } from './event-broadcaster';
1
+ import type { Context } from '../types/context.js';
2
+ import type { EventBroadcaster } from './event-broadcaster.js';
3
3
  /** @internal Option controlling framework event emission on a step or callModel request. */
4
4
  export type EmitOption = boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
5
5
  /**
@@ -13,7 +13,11 @@ export type EmitOption = boolean | ((eventType: string, data: Record<string, unk
13
13
  */
14
14
  export declare function shouldEmit(emit: EmitOption | undefined, eventType: string, data: Record<string, unknown>): boolean;
15
15
  /**
16
- * Get the EventBroadcaster from a context if available.
16
+ * Get the EventBroadcaster from a context if available. Walks up the parent
17
+ * chain so spawned child contexts inherit the session-level broadcaster — the
18
+ * interpreter never re-installs `_broadcaster` on spawn children, so without
19
+ * this traversal every LLM call inside a `spawn()` step would be invisible to
20
+ * the UI stream.
17
21
  * Uses property check rather than instanceof to support mock contexts in tests.
18
22
  * @internal
19
23
  */
@@ -26,16 +26,21 @@ function hasBroadcaster(ctx) {
26
26
  return typeof ctx._broadcaster === 'object' && ctx._broadcaster !== null;
27
27
  }
28
28
  /**
29
- * Get the EventBroadcaster from a context if available.
29
+ * Get the EventBroadcaster from a context if available. Walks up the parent
30
+ * chain so spawned child contexts inherit the session-level broadcaster — the
31
+ * interpreter never re-installs `_broadcaster` on spawn children, so without
32
+ * this traversal every LLM call inside a `spawn()` step would be invisible to
33
+ * the UI stream.
30
34
  * Uses property check rather than instanceof to support mock contexts in tests.
31
35
  * @internal
32
36
  */
33
37
  export function getBroadcaster(ctx) {
34
- if (!ctx) {
35
- return undefined;
36
- }
37
- if (hasBroadcaster(ctx)) {
38
- return ctx._broadcaster;
38
+ let current = ctx;
39
+ while (current) {
40
+ if (hasBroadcaster(current)) {
41
+ return current._broadcaster;
42
+ }
43
+ current = current.parent ?? null;
39
44
  }
40
45
  return undefined;
41
46
  }
@@ -1,4 +1,4 @@
1
- import type { Channel, ChannelHandle, ExternalChannel } from '../types/channel';
1
+ import type { Channel, ChannelHandle, ExternalChannel } from '../types/channel.js';
2
2
  export declare class ChannelStore {
3
3
  private channels;
4
4
  private closedExecutions;
@@ -1,5 +1,5 @@
1
- import { NoeticErrorImpl } from '../errors/noetic-error';
2
- import { frameworkCast } from '../interpreter/framework-cast';
1
+ import { NoeticErrorImpl } from '../errors/noetic-error.js';
2
+ import { frameworkCast } from '../util/framework-cast.js';
3
3
  function isExternalChannel(ch) {
4
4
  return 'external' in ch && ch.external === true;
5
5
  }
@@ -0,0 +1,4 @@
1
+ export { buildContextMemory } from '../memory/layer-api.js';
2
+ export type { ItemSchemaRegistry } from '../schemas/item.js';
3
+ export { defaultItemSchemaRegistry } from '../schemas/item.js';
4
+ export type { AgentHarnessContract, Channel, ChannelStore, Context, ContextMemory, CwdState, EventBroadcaster, FrontierFrame, FsAdapter, Item, ItemLog, LastLayerUsage, MemoryLayer, Span, StepMeta, TokenUsage, Tool, } from './context-type-deps.js';
@@ -0,0 +1,2 @@
1
+ export { buildContextMemory } from '../memory/layer-api.js';
2
+ export { defaultItemSchemaRegistry } from '../schemas/item.js';
@@ -1,14 +1,4 @@
1
- import type { ItemSchemaRegistry } from '../schemas/item';
2
- import type { Channel } from '../types/channel';
3
- import type { StepMeta, TokenUsage, Tool } from '../types/common';
4
- import type { Context, CwdState, ItemLog, LastLayerUsage } from '../types/context';
5
- import type { FsAdapter } from '../types/fs-adapter';
6
- import type { Item } from '../types/items';
7
- import type { ContextMemory, MemoryLayer } from '../types/memory';
8
- import type { Span } from '../types/observability';
9
- import type { AgentHarnessContract } from '../types/runtime';
10
- import type { ChannelStore } from './channel-store';
11
- import type { EventBroadcaster } from './event-broadcaster';
1
+ import type { AgentHarnessContract, Channel, ChannelStore, Context, ContextMemory, CwdState, EventBroadcaster, FrontierFrame, FsAdapter, Item, ItemLog, ItemSchemaRegistry, LastLayerUsage, MemoryLayer, Span, StepMeta, TokenUsage, Tool } from './context-deps.js';
12
2
  export declare class ContextImpl implements Context<ContextMemory> {
13
3
  readonly id: string;
14
4
  stepCount: number;
@@ -34,7 +24,8 @@ export declare class ContextImpl implements Context<ContextMemory> {
34
24
  /**
35
25
  * Shared channel store for cross-context communication. Inherited by
36
26
  * `fork` / `spawn` children so channels published by a sibling are visible
37
- * to peers — see `interpreter/execute-fork.ts` and `interpreter/execute-spawn.ts`.
27
+ * to peers — see `executeFork` and `executeSpawn` in `interpreter/execute-action.ts`
28
+ * and `interpreter/execute-control.ts`.
38
29
  * @internal
39
30
  */
40
31
  readonly channelStore?: ChannelStore;
@@ -44,6 +35,15 @@ export declare class ContextImpl implements Context<ContextMemory> {
44
35
  private _aborted;
45
36
  private _abortReason?;
46
37
  private _memory?;
38
+ /**
39
+ * Stack of steps currently in flight on this context, most-recent last.
40
+ * Pushed by `enterStep` at the top of `execute()` and popped by
41
+ * `leaveStep` when the step resolves (success or failure). The harness'
42
+ * checkpoint writer serialises this stack as the execution frontier so
43
+ * a restart can identify which step the context was paused inside.
44
+ * @internal
45
+ */
46
+ private readonly _frontier;
47
47
  constructor(opts: {
48
48
  harness: AgentHarnessContract;
49
49
  parent?: Context;
@@ -59,6 +59,14 @@ export declare class ContextImpl implements Context<ContextMemory> {
59
59
  itemSchemas?: ItemSchemaRegistry;
60
60
  cwdState?: CwdState;
61
61
  _broadcaster?: EventBroadcaster;
62
+ /**
63
+ * Pre-chosen context id. When set, the ContextImpl adopts this id instead
64
+ * of generating a fresh UUID. Used by `executeSpawn` so the child's
65
+ * `ctx.id` matches the `executionId` keyed into the layer-state store —
66
+ * otherwise writes via `ctx.memory[layerId].state` land on one id while
67
+ * spawn's `onReturn` reads from another, silently losing the update.
68
+ */
69
+ id?: string;
62
70
  });
63
71
  get elapsed(): number;
64
72
  get aborted(): boolean;
@@ -77,4 +85,26 @@ export declare class ContextImpl implements Context<ContextMemory> {
77
85
  get completionValue(): unknown;
78
86
  get abortReason(): string | undefined;
79
87
  abort(reason?: string): void;
88
+ /**
89
+ * @internal
90
+ * Push a frame onto the execution frontier. Called by `execute()` at the
91
+ * top of every step dispatch so that the frontier reflects exactly the
92
+ * stack of steps currently in-flight on this context.
93
+ */
94
+ enterStep(frame: FrontierFrame): void;
95
+ /**
96
+ * @internal
97
+ * Pop the top frame. Called when a step resolves (success or failure)
98
+ * so that the frontier unwinds cleanly. The value of `expectedStepId`
99
+ * is used as a consistency check — if it does not match the top frame
100
+ * the pop is still performed, but a best-effort warning is surfaced to
101
+ * stderr rather than swallowed silently.
102
+ */
103
+ leaveStep(expectedStepId: string): void;
104
+ /**
105
+ * @internal
106
+ * Return a defensive copy of the current frontier. Consumed by the
107
+ * checkpoint writer — see `AgentHarness.checkpoint`.
108
+ */
109
+ serialiseFrontier(): FrontierFrame[];
80
110
  }
@@ -1,6 +1,5 @@
1
- import { buildContextMemory } from '../memory/layer-api';
2
- import { defaultItemSchemaRegistry } from '../schemas/item';
3
- import { ItemLogImpl } from './item-log-impl';
1
+ import { buildContextMemory, defaultItemSchemaRegistry } from './context-deps.js';
2
+ import { ItemLogImpl } from './item-log-impl.js';
4
3
  const EMPTY_MEMORY = Object.freeze({});
5
4
  class NoopSpan {
6
5
  traceId = crypto.randomUUID();
@@ -39,7 +38,8 @@ export class ContextImpl {
39
38
  /**
40
39
  * Shared channel store for cross-context communication. Inherited by
41
40
  * `fork` / `spawn` children so channels published by a sibling are visible
42
- * to peers — see `interpreter/execute-fork.ts` and `interpreter/execute-spawn.ts`.
41
+ * to peers — see `executeFork` and `executeSpawn` in `interpreter/execute-action.ts`
42
+ * and `interpreter/execute-control.ts`.
43
43
  * @internal
44
44
  */
45
45
  channelStore;
@@ -49,8 +49,17 @@ export class ContextImpl {
49
49
  _aborted = false;
50
50
  _abortReason;
51
51
  _memory;
52
+ /**
53
+ * Stack of steps currently in flight on this context, most-recent last.
54
+ * Pushed by `enterStep` at the top of `execute()` and popped by
55
+ * `leaveStep` when the step resolves (success or failure). The harness'
56
+ * checkpoint writer serialises this stack as the execution frontier so
57
+ * a restart can identify which step the context was paused inside.
58
+ * @internal
59
+ */
60
+ _frontier = [];
52
61
  constructor(opts) {
53
- this.id = crypto.randomUUID();
62
+ this.id = opts.id ?? crypto.randomUUID();
54
63
  this._createdAt = Date.now();
55
64
  this.harness = opts.harness;
56
65
  this.state = opts.state ?? {};
@@ -137,4 +146,42 @@ export class ContextImpl {
137
146
  this._aborted = true;
138
147
  this._abortReason = reason;
139
148
  }
149
+ /**
150
+ * @internal
151
+ * Push a frame onto the execution frontier. Called by `execute()` at the
152
+ * top of every step dispatch so that the frontier reflects exactly the
153
+ * stack of steps currently in-flight on this context.
154
+ */
155
+ enterStep(frame) {
156
+ this._frontier.push(frame);
157
+ }
158
+ /**
159
+ * @internal
160
+ * Pop the top frame. Called when a step resolves (success or failure)
161
+ * so that the frontier unwinds cleanly. The value of `expectedStepId`
162
+ * is used as a consistency check — if it does not match the top frame
163
+ * the pop is still performed, but a best-effort warning is surfaced to
164
+ * stderr rather than swallowed silently.
165
+ */
166
+ leaveStep(expectedStepId) {
167
+ const top = this._frontier[this._frontier.length - 1];
168
+ if (top && top.stepId !== expectedStepId) {
169
+ // A mismatch indicates bookkeeping drift. We unwind best-effort and
170
+ // let the caller observe via `serialiseFrontier()` if needed.
171
+ console.warn(`ContextImpl.leaveStep: expected "${expectedStepId}" on top of frontier but saw "${top.stepId}".`);
172
+ }
173
+ this._frontier.pop();
174
+ }
175
+ /**
176
+ * @internal
177
+ * Return a defensive copy of the current frontier. Consumed by the
178
+ * checkpoint writer — see `AgentHarness.checkpoint`.
179
+ */
180
+ serialiseFrontier() {
181
+ return this._frontier.map((frame) => ({
182
+ stepId: frame.stepId,
183
+ input: frame.input,
184
+ state: frame.state,
185
+ }));
186
+ }
140
187
  }
@@ -0,0 +1,14 @@
1
+ export type { Channel } from '../types/channel.js';
2
+ export type { FrontierFrame } from '../types/checkpoint.js';
3
+ export type { StepMeta, TokenUsage } from '../types/common.js';
4
+ export type { Context, CwdState } from '../types/context.js';
5
+ export type { ItemLog } from '../types/context-parts/item-log.js';
6
+ export type { LastLayerUsage } from '../types/context-parts/layer-usage.js';
7
+ export type { FsAdapter } from '../types/fs-adapter.js';
8
+ export type { Item } from '../types/items.js';
9
+ export type { ContextMemory, MemoryLayer } from '../types/memory.js';
10
+ export type { Span } from '../types/observability.js';
11
+ export type { AgentHarnessContract } from '../types/runtime.js';
12
+ export type { Tool } from '../types/tool.js';
13
+ export type { ChannelStore } from './channel-store.js';
14
+ export type { EventBroadcaster } from './event-broadcaster.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { Context, CwdState } from '../types/context';
1
+ import type { Context, CwdState } from '../types/context.js';
2
2
  /**
3
3
  * @public Resolve the live cwd for a tool execution. Falls back to the
4
4
  * tool's factory-time cwd (then `process.cwd()`) so partial test contexts