@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
@@ -0,0 +1,46 @@
1
+ import { mergeExtensions } from '../schemas/item.js';
2
+ function mergeItemSchemaExtensions(extensions) {
3
+ let result = {
4
+ items: [],
5
+ developerMessages: [],
6
+ toolCalls: [],
7
+ toolResults: [],
8
+ };
9
+ for (const ext of extensions) {
10
+ if (ext) {
11
+ result = mergeExtensions(result, ext);
12
+ }
13
+ }
14
+ return result;
15
+ }
16
+ function collectLayerItemSchemaExtensions(layers) {
17
+ return mergeItemSchemaExtensions(layers?.map((layer) => layer.itemSchemas) ?? []);
18
+ }
19
+ function collectToolItemSchemaExtensions(tools) {
20
+ return mergeItemSchemaExtensions(tools?.map((tool) => tool.itemSchemas) ?? []);
21
+ }
22
+ export function buildItemSchemaRegistry({ base, layers, tools, }) {
23
+ return base
24
+ .extend(collectLayerItemSchemaExtensions(layers))
25
+ .extend(collectToolItemSchemaExtensions(tools));
26
+ }
27
+ export function createToolResultItem({ output, callId, roundItemSchemas, tool, callItem, args, result, error, }) {
28
+ const baseItem = {
29
+ id: crypto.randomUUID(),
30
+ status: 'completed',
31
+ type: 'function_call_output',
32
+ callId,
33
+ output,
34
+ };
35
+ const decorated = tool?.decorateResultItem && callItem?.type === 'function_call'
36
+ ? tool.decorateResultItem({
37
+ baseItem,
38
+ callItem,
39
+ args,
40
+ result,
41
+ output,
42
+ error,
43
+ })
44
+ : baseItem;
45
+ return roundItemSchemas.parseWithCategory(decorated, 'toolResults');
46
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Step-bootstrap child entrypoint for the local subprocess adapter.
3
+ *
4
+ * The parent adapter spawns this module with `bun run <step-bootstrap.ts>`.
5
+ * It:
6
+ *
7
+ * 1. Reads a single JSON envelope from stdin (one frame, newline-terminated).
8
+ * 2. Dynamically imports the registry entry module so its module-level
9
+ * `registerStep` side effects populate the registry in this process.
10
+ * 3. Looks up the requested step by id.
11
+ * 4. Constructs a minimal harness (in-memory adapters, no nested
12
+ * subprocess) and runs the step.
13
+ * 5. Serialises the result (or error) as a JSON envelope on stdout.
14
+ *
15
+ * Protocol: the parent reads **exactly one JSON line** from stdout on child
16
+ * exit:
17
+ *
18
+ * - Success: `{"kind":"ok","result":<value>}`
19
+ * - Failure: `{"kind":"error","error":{"message":"...","name":"...","stack":"...","noeticError":...}}`
20
+ *
21
+ * On failure the process exits with code 1; on success, code 0. Uncaught
22
+ * errors are caught and reported through the same envelope so the parent
23
+ * never sees a silent crash.
24
+ */
25
+ export {};
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Step-bootstrap child entrypoint for the local subprocess adapter.
3
+ *
4
+ * The parent adapter spawns this module with `bun run <step-bootstrap.ts>`.
5
+ * It:
6
+ *
7
+ * 1. Reads a single JSON envelope from stdin (one frame, newline-terminated).
8
+ * 2. Dynamically imports the registry entry module so its module-level
9
+ * `registerStep` side effects populate the registry in this process.
10
+ * 3. Looks up the requested step by id.
11
+ * 4. Constructs a minimal harness (in-memory adapters, no nested
12
+ * subprocess) and runs the step.
13
+ * 5. Serialises the result (or error) as a JSON envelope on stdout.
14
+ *
15
+ * Protocol: the parent reads **exactly one JSON line** from stdout on child
16
+ * exit:
17
+ *
18
+ * - Success: `{"kind":"ok","result":<value>}`
19
+ * - Failure: `{"kind":"error","error":{"message":"...","name":"...","stack":"...","noeticError":...}}`
20
+ *
21
+ * On failure the process exits with code 1; on success, code 0. Uncaught
22
+ * errors are caught and reported through the same envelope so the parent
23
+ * never sees a silent crash.
24
+ */
25
+ import { lookupStep } from '../runtime/step-registry.js';
26
+ import { AgentHarness } from './agent-harness.js';
27
+ //#endregion
28
+ //#region Helpers
29
+ function isRecord(value) {
30
+ return typeof value === 'object' && value !== null;
31
+ }
32
+ function isEnvelope(value) {
33
+ if (!isRecord(value)) {
34
+ return false;
35
+ }
36
+ if (typeof value.stepId !== 'string' || typeof value.executionId !== 'string') {
37
+ return false;
38
+ }
39
+ if (typeof value.registryEntry !== 'string') {
40
+ return false;
41
+ }
42
+ if (!isRecord(value.overrides)) {
43
+ return false;
44
+ }
45
+ return true;
46
+ }
47
+ function readStdinFrame() {
48
+ return new Promise((resolve, reject) => {
49
+ let buf = '';
50
+ process.stdin.setEncoding('utf8');
51
+ process.stdin.on('data', (chunk) => {
52
+ buf += chunk;
53
+ const nl = buf.indexOf('\n');
54
+ if (nl === -1) {
55
+ return;
56
+ }
57
+ process.stdin.pause();
58
+ resolve(buf.slice(0, nl));
59
+ });
60
+ process.stdin.on('end', () => {
61
+ if (buf.length > 0) {
62
+ resolve(buf);
63
+ return;
64
+ }
65
+ reject(new Error('step-bootstrap: stdin closed before an envelope was received'));
66
+ });
67
+ process.stdin.on('error', reject);
68
+ });
69
+ }
70
+ function serializeErrorFor(err) {
71
+ if (err instanceof Error) {
72
+ const payload = {
73
+ message: err.message,
74
+ name: err.name,
75
+ stack: err.stack,
76
+ };
77
+ if (isRecord(err) && 'noeticError' in err) {
78
+ payload.noeticError = err.noeticError;
79
+ }
80
+ return payload;
81
+ }
82
+ return {
83
+ message: typeof err === 'string' ? err : String(err),
84
+ };
85
+ }
86
+ function writeEnvelope(payload) {
87
+ // A single newline-terminated JSON line — matches the parent parser's
88
+ // contract in `local-subprocess-adapter.ts`.
89
+ process.stdout.write(`${JSON.stringify(payload)}\n`);
90
+ }
91
+ //#endregion
92
+ //#region Main
93
+ async function main() {
94
+ const raw = await readStdinFrame();
95
+ let parsed;
96
+ try {
97
+ parsed = JSON.parse(raw);
98
+ }
99
+ catch (err) {
100
+ writeEnvelope({
101
+ kind: 'error',
102
+ error: serializeErrorFor(err),
103
+ });
104
+ return 1;
105
+ }
106
+ if (!isEnvelope(parsed)) {
107
+ writeEnvelope({
108
+ kind: 'error',
109
+ error: {
110
+ message: 'step-bootstrap: stdin envelope failed structural validation',
111
+ },
112
+ });
113
+ return 1;
114
+ }
115
+ // Import the registry entry so module-level `registerStep` side effects
116
+ // populate our registry before lookup. The parent guarantees the path is
117
+ // absolute (see `local-subprocess-adapter.ts:spawnStepHandle`).
118
+ await import(parsed.registryEntry);
119
+ const step = lookupStep(parsed.stepId);
120
+ if (!step) {
121
+ writeEnvelope({
122
+ kind: 'error',
123
+ error: {
124
+ message: `step-bootstrap: step "${parsed.stepId}" is not registered in the child runtime`,
125
+ },
126
+ });
127
+ return 1;
128
+ }
129
+ const harness = new AgentHarness({
130
+ name: `step-bootstrap-${parsed.stepId}`,
131
+ params: {},
132
+ });
133
+ const ctx = harness.createContext({
134
+ threadId: parsed.overrides.threadId,
135
+ resourceId: parsed.overrides.resourceId,
136
+ cwdInit: parsed.overrides.cwdInit,
137
+ });
138
+ try {
139
+ const result = await harness.run(step, parsed.serializedInput, ctx);
140
+ writeEnvelope({
141
+ kind: 'ok',
142
+ result,
143
+ });
144
+ return 0;
145
+ }
146
+ catch (err) {
147
+ writeEnvelope({
148
+ kind: 'error',
149
+ error: serializeErrorFor(err),
150
+ });
151
+ return 1;
152
+ }
153
+ }
154
+ void main()
155
+ .then((code) => {
156
+ // Flush before exit — `process.stdout.write` is async on some platforms
157
+ // (block devices, sockets) and an immediate `process.exit` can truncate.
158
+ process.stdout.once('drain', () => process.exit(code));
159
+ if (process.stdout.writableLength === 0) {
160
+ process.exit(code);
161
+ }
162
+ })
163
+ .catch((err) => {
164
+ writeEnvelope({
165
+ kind: 'error',
166
+ error: serializeErrorFor(err),
167
+ });
168
+ process.exit(1);
169
+ });
170
+ //#endregion
package/dist/index.d.ts CHANGED
@@ -1,152 +1,190 @@
1
1
  /** @public */
2
- export { createInMemoryFsAdapter } from './adapters/in-memory-fs-adapter';
2
+ export { createInMemoryFsAdapter } from './adapters/in-memory-fs-adapter.js';
3
3
  /** @public */
4
- export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter';
4
+ export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter.js';
5
5
  /** @public */
6
- export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter';
6
+ export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter.js';
7
7
  /** @public */
8
- export { createLocalFsAdapter } from './adapters/local-fs-adapter';
8
+ export { createOpenRouterEmbed } from './adapters/openrouter.js';
9
9
  /** @public */
10
- export { type CreateLocalShellAdapterOptions, createLocalShellAdapter, type LocalShellAdapter, } from './adapters/local-shell-adapter';
10
+ export { channel } from './builders/channel-builder.js';
11
11
  /** @public */
12
- export { type CreateLocalSubprocessAdapterOptions, createLocalSubprocessAdapter, defaultProcessSignaller, type ProcessSignaller, type SubprocessSignal, } from './adapters/local-subprocess-adapter';
12
+ export { branch, fork } from './builders/control-flow-builders.js';
13
13
  /** @public */
14
- export { createOpenRouterEmbed } from './adapters/openrouter';
14
+ export type { EveryOptions } from './builders/every.js';
15
15
  /** @public */
16
- export { channel } from './builders/channel-builder';
16
+ export { every } from './builders/every.js';
17
17
  /** @public */
18
- export { branch, fork } from './builders/control-flow-builders';
18
+ export { layerData, layerFn } from './builders/layer-provides-builders.js';
19
19
  /** @public */
20
- export type { EveryOptions } from './builders/every';
20
+ export type { LoopConfig } from './builders/loop-builder.js';
21
21
  /** @public */
22
- export { every } from './builders/every';
22
+ export { loop } from './builders/loop-builder.js';
23
23
  /** @public */
24
- export { layerData, layerFn } from './builders/layer-provides-builders';
24
+ export { memory } from './builders/memory-builder.js';
25
25
  /** @public */
26
- export type { LoopConfig } from './builders/loop-builder';
26
+ export { provide } from './builders/provide-builder.js';
27
27
  /** @public */
28
- export { loop } from './builders/loop-builder';
28
+ export { spawn } from './builders/spawn-builder.js';
29
29
  /** @public */
30
- export { memory } from './builders/memory-builder';
30
+ export { step } from './builders/step-builders.js';
31
31
  /** @public */
32
- export { provide } from './builders/provide-builder';
32
+ export { tool, toolWithGenerator } from './builders/tool-builder.js';
33
33
  /** @public */
34
- export { spawn } from './builders/spawn-builder';
34
+ export type { HydrationContext } from './builders/workflow-hydrator.js';
35
35
  /** @public */
36
- export { step } from './builders/step-builders';
36
+ export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
37
37
  /** @public */
38
- export { tool, toolWithGenerator } from './builders/tool-builder';
38
+ export type { Condition, OtherwiseClause, WhenClause } from './conditions/conditions.js';
39
39
  /** @public */
40
- export type { Condition, OtherwiseClause, WhenClause } from './conditions';
40
+ export { aiCondition, allCondition, anyCondition, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions/conditions.js';
41
41
  /** @public */
42
- export { aiCondition, allCondition, anyCondition, cosineSimilarity, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions';
42
+ export { cosineSimilarity } from './conditions/cosine-similarity.js';
43
43
  /** @public */
44
- export { isNoeticConfigError, NoeticConfigError } from './errors/noetic-config-error';
44
+ export { isNoeticConfigError, NoeticConfigError } from './errors/noetic-config-error.js';
45
45
  /** @public */
46
- export { isNoeticError, NoeticErrorImpl } from './errors/noetic-error';
46
+ export { isNoeticError, NoeticErrorImpl } from './errors/noetic-error.js';
47
47
  /** @public */
48
- export { execute } from './interpreter/execute';
48
+ export type { AskUserAnnotation, AskUserInput, AskUserOption, AskUserOutput, AskUserQuestion, } from './types/ask-user-types.js';
49
49
  /** @public */
50
- export type { DurableTaskState, DurableTaskStateConfig } from './memory/layers/durable-task-state';
50
+ export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from './types/ask-user-types.js';
51
51
  /** @public */
52
- export { durableTaskState } from './memory/layers/durable-task-state';
52
+ export { execute } from './interpreter/execute.js';
53
53
  /** @public */
54
- export { fileReference } from './memory/layers/file-reference';
54
+ export { findFunctionCall } from './memory/function-call-utils.js';
55
55
  /** @public */
56
- export type { HistoryWindowConfig } from './memory/layers/history-window';
56
+ export type { DurableTaskState, DurableTaskStateConfig } from './memory/layers/durable-task-state.js';
57
57
  /** @public */
58
- export { historyWindow } from './memory/layers/history-window';
58
+ export { durableTaskState } from './memory/layers/durable-task-state.js';
59
59
  /** @public */
60
- export type { ObservationalMemoryConfig, ObservationalState, } from './memory/layers/observational-memory';
60
+ export { fileReference } from './memory/layers/file-reference.js';
61
61
  /** @public */
62
- export { observationalMemory } from './memory/layers/observational-memory';
62
+ export type { HistoryWindowConfig } from './memory/layers/history-window.js';
63
63
  /** @public */
64
- export type { PlanEnterSessionCallback, PlanExecutionEntry, PlanExitCallback, PlanMemoryConfig, PlanState, } from './memory/layers/plan';
64
+ export { historyWindow } from './memory/layers/history-window.js';
65
65
  /** @public */
66
- export { PlanPhase, planMemory } from './memory/layers/plan';
66
+ export type { ObservationalMemoryConfig, ObservationalState, } from './memory/layers/observational-memory.js';
67
67
  /** @public */
68
- export { staticContent } from './memory/layers/static-content';
68
+ export { observationalMemory } from './memory/layers/observational-memory.js';
69
69
  /** @public */
70
- export { steering } from './memory/layers/steering';
70
+ export type { PlanEnterSessionCallback, PlanExecutionEntry, PlanExitCallback, PlanMemoryConfig, PlanState, } from './memory/layers/plan.js';
71
71
  /** @public */
72
- export { toolMemoryLayer } from './memory/layers/tool-memory-layer';
72
+ export { PlanPhase, planMemory } from './memory/layers/plan.js';
73
73
  /** @public */
74
- export type { WorkingMemoryConfig, WorkingMemoryState } from './memory/layers/working-memory';
74
+ export { staticContent } from './memory/layers/static-content.js';
75
75
  /** @public */
76
- export { workingMemory } from './memory/layers/working-memory';
76
+ export { steering } from './memory/layers/steering.js';
77
77
  /** @public */
78
- export { stripUnresolvedToolCalls } from './memory/strip-unresolved';
78
+ export { toolMemoryLayer } from './memory/layers/tool-memory-layer.js';
79
79
  /** @public */
80
- export { InMemoryExporter, NoopExporter } from './observability/trace-exporter';
80
+ export type { WorkingMemoryConfig, WorkingMemoryState } from './memory/layers/working-memory.js';
81
81
  /** @public */
82
- export { createInMemoryStorage } from './runtime/in-memory-storage';
82
+ export { workingMemory } from './memory/layers/working-memory.js';
83
83
  /** @public */
84
- export type { FlowNode, ForkFlowNode, LlmFlowNode, SequenceFlowNode, SpawnFlowNode, SubagentFlowNode, } from './patterns/flow';
84
+ export { stripUnresolvedToolCalls } from './memory/strip-unresolved.js';
85
85
  /** @public */
86
- export { FlowSchema, flowDepth, validateFlow, walkFlow } from './patterns/flow';
86
+ export { createMessage, estimateTokens } from './util/message-helpers.js';
87
87
  /** @public */
88
- export type { InterviewOpts, InterviewQuestionAnswer, InterviewResult } from './patterns/interview';
88
+ export { GenAI, ToolAttr } from './observability/genai-attributes.js';
89
89
  /** @public */
90
- export { interview } from './patterns/interview';
90
+ export { InMemoryExporter, NoopExporter } from './observability/trace-exporter.js';
91
91
  /** @public */
92
- export type { PlanConstraints, PlanNode } from './patterns/plans';
92
+ export { createInMemoryStorage } from './runtime/in-memory-storage.js';
93
93
  /** @public */
94
- export { adaptivePlan, compilePlan, PlanNodeSchema } from './patterns/plans';
94
+ export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './patterns/dynamic-workflow.js';
95
95
  /** @public */
96
- export { ralphWiggum } from './patterns/ralph-wiggum';
96
+ export { dynamicWorkflow, parseAndRunWorkflow } from './patterns/dynamic-workflow.js';
97
97
  /** @public */
98
- export { react } from './patterns/react';
98
+ export type { FlowNode, ForkFlowNode, LlmFlowNode, SequenceFlowNode, SpawnFlowNode, SubagentFlowNode, } from './patterns/flow.js';
99
99
  /** @public */
100
- export { AgentHarness } from './runtime/agent-harness';
100
+ export { FlowSchema, flowDepth, validateFlow, walkFlow } from './patterns/flow.js';
101
101
  /** @public */
102
- export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from './schemas/item';
102
+ export type { InterviewOpts, InterviewQuestionAnswer, InterviewResult } from './patterns/interview.js';
103
103
  /** @public */
104
- export type { Channel, ChannelHandle, ExternalChannel } from './types/channel';
104
+ export { interview } from './patterns/interview.js';
105
105
  /** @public */
106
- export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, StepMeta, TokenUsage, Tool, ToolMemoryDeclaration, } from './types/common';
106
+ export type { PlanConstraints, PlanNode } from './patterns/plans.js';
107
107
  /** @public */
108
- export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers';
108
+ export { adaptivePlan, compilePlan, PlanNodeSchema } from './patterns/plans.js';
109
109
  /** @public */
110
- export type { Context, CwdState, ItemLog, LastLayerUsage, LayerUsageEntry, } from './types/context';
110
+ export { ralphWiggum } from './patterns/ralph-wiggum.js';
111
111
  /** @public */
112
- export type { DetachedHandle } from './types/detached';
112
+ export { react } from './patterns/react.js';
113
113
  /** @public */
114
- export { DetachedStatus } from './types/detached';
114
+ export { AgentHarness } from './harness/agent-harness.js';
115
115
  /** @public */
116
- export type { EmbedFn } from './types/embed';
116
+ export type { AfterFirstTurnContext, CheckpointStore, CreateCheckpointStoreOptions, CreateNudgeMessageOpts, DetachedSignal, RunnableLoopHarness, RunnableLoopOpts, SessionSeedHarness, StallNudgeOpts, } from './runtime/durable/index.js';
117
117
  /** @public */
118
- export type { NoeticError } from './types/error';
118
+ export { CheckpointKeys, createCheckpointStore, createDetachedSignal, createNudgeMessage, createStallNudgeHook, DEFAULT_NUDGE_MESSAGE_TEXT, runnableLoop, seedFromItems, } from './runtime/durable/index.js';
119
119
  /** @public */
120
- export type { ContentPart, DeveloperMessageExtensionItem, ExecuteInput, ExtendedItem, ExtensionItem, FileSearchItem, FunctionCallItem, FunctionCallOutputItem, ImageGenerationItem, InferExtendedItem, InputMessageItem, InputTextPart, Item, ItemBase, ItemSchemaExtensions, MessageItem, OutputItem, OutputTextPart, ReasoningItem, ReasoningTextPart, RefusalPart, ServerToolItem, SummaryTextPart, WebSearchItem, } from './types/items';
120
+ export { getRegistry, lookupStep, registerStep } from './runtime/step-registry.js';
121
121
  /** @public */
122
- export type { BudgetConfig, CompleteParams, ContextMemory, DisposeParams, ExecutionContext, ExecutionOutcome, InferMemory, InferMemoryShape, InitParams, InitResult, LayerDataDecl, LayerFunctionDecl, LayerProvides, LayerTimeouts, MemoryConfig, MemoryHooks, MemoryLayer, MemoryScope, ProjectionPolicy, RecallParams, RecallResult, ReturnParams, ReturnResult, ScopedStorage, SpawnParams, SpawnResult, StorageAdapter, StoreParams, StoreResult, } from './types/memory';
122
+ export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from './schemas/item.js';
123
123
  /** @public */
124
- export { Slot } from './types/memory';
124
+ export type { BranchRoute, BranchWorkflowNode, EveryWorkflowNode, ForkWorkflowNode, LlmWorkflowNode, LoopWorkflowNode, MergeStrategy, ProvideWorkflowNode, SequenceWorkflowNode, SpawnWorkflowNode, ToolWorkflowNode, UntilPredicate, WorkflowDocument, WorkflowNode, } from './schemas/workflow.js';
125
125
  /** @public */
126
- export type { MemoryTraceSpan, Span, TraceExporter } from './types/observability';
126
+ export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow.js';
127
127
  /** @public */
128
- export type { FrameworkStreamEvent, HarnessResponse, SdkStreamEvent, StreamEvent, StreamingItem, } from './types/harness-result';
128
+ export type { Channel, ChannelHandle, ExternalChannel } from './types/channel.js';
129
129
  /** @public */
130
- export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, DeliveryMode, ExecuteOptions, HarnessStatus, RecallLayerOutput, SessionScope, } from './types/runtime';
130
+ export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, StepMeta, TokenUsage, } from './types/common.js';
131
131
  /** @public */
132
- export type { AfterModelCallParams, AfterModelCallResult, BeforeToolCallParams, BeforeToolCallResult, LedgerEntry, SteeringConfig, SteeringDecision, SteeringRule, SteeringState, } from './types/steering';
132
+ export type { Tool, ToolMemoryDeclaration } from './types/tool.js';
133
133
  /** @public */
134
- export { LedgerEntryKind, SteeringAction } from './types/steering';
134
+ export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers.js';
135
135
  /** @public */
136
- export type { ExecuteStepFn, SettleResult, Snapshot, Step, StepBranch, StepFork, StepForkAll, StepForkRace, StepForkSettle, StepLLM, StepLoop, StepProvide, StepRun, StepSpawn, StepTool, Until, Verdict, } from './types/step';
136
+ export type { Context, ContextHarness, CwdState, } from './types/context.js';
137
137
  /** @public */
138
- export type { FsAdapter, FsStats } from './types/fs-adapter';
138
+ export type { ItemLog } from './types/context-parts/item-log.js';
139
139
  /** @public */
140
- export type { ShellAdapter, ShellExecOptions, ShellExecResult } from './types/shell-adapter';
140
+ export type { LastLayerUsage, LayerUsageEntry } from './types/context-parts/layer-usage.js';
141
141
  /** @public */
142
- export { TIMEOUT_ERROR_PREFIX } from './types/shell-adapter';
142
+ export type { DetachedHandle } from './types/detached.js';
143
143
  /** @public */
144
- export type { SubprocessAdapter, SubprocessControlResult, SubprocessHandle, SubprocessRequest, SubprocessStatus, SubprocessStopResult, } from './types/subprocess-adapter';
144
+ export { DetachedStatus } from './types/detached.js';
145
145
  /** @public */
146
- export type { ToolExecutionContext, ToolMemory } from './types/tool-context';
146
+ export type { EmbedFn } from './types/embed.js';
147
147
  /** @public */
148
- export { all, any } from './until/combinators';
148
+ export type { CheckpointSnapshot, CwdSnapshot, FrontierFrame, ItemLogSnapshot, PendingAskUserSnapshot, } from './types/checkpoint.js';
149
149
  /** @public */
150
- export type { ConvergeConfig, VerifyFn } from './until/predicates';
150
+ export { CheckpointSchemaVersion, CheckpointSnapshotSchema, CwdSnapshotSchema, FrontierFrameSchema, ItemLogSnapshotSchema, PendingAskUserSnapshotSchema, } from './types/checkpoint.js';
151
151
  /** @public */
152
- export { until } from './until/predicates';
152
+ export type { NoeticError } from './types/error.js';
153
+ /** @public */
154
+ export type { ContentPart, DeveloperMessageExtensionItem, ExecuteInput, ExtendedItem, ExtensionItem, FileSearchItem, FunctionCallItem, FunctionCallOutputItem, ImageGenerationItem, InferExtendedItem, InputContentPart, InputFilePart, InputImagePart, InputMessageItem, InputTextPart, Item, ItemBase, ItemSchemaExtensions, MessageItem, OutputItem, OutputTextPart, ReasoningItem, ReasoningTextPart, RefusalPart, ServerToolItem, SummaryTextPart, WebSearchItem, } from './types/items.js';
155
+ /** @public */
156
+ export type { BudgetConfig, CompleteParams, ContextMemory, DisposeParams, InferMemory, InferMemoryShape, InitParams, InitResult, LayerDataDecl, LayerFunctionDecl, LayerProvides, LayerTimeouts, MemoryConfig, MemoryHooks, MemoryLayer, ProjectionPolicy, RecallParams, RecallResult, ReturnParams, ReturnResult, ScopedStorage, SpawnParams, SpawnResult, StorageAdapter, StoreParams, StoreResult, } from './types/memory.js';
157
+ /** @public */
158
+ export { Slot } from './types/memory.js';
159
+ /** @public */
160
+ export type { ExecutionContext, ExecutionOutcome, MemoryCallModelRequest, MemoryScope, } from './types/memory-context.js';
161
+ /** @public */
162
+ export type { MemoryTraceSpan, Span, TraceExporter } from './types/observability.js';
163
+ /** @public */
164
+ export type { FrameworkStreamEvent, HarnessResponse, SdkStreamEvent, StreamEvent, StreamingItem, } from './types/harness-result.js';
165
+ /** @public */
166
+ export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, DeliveryMode, ExecuteOptions, HarnessStatus, RecallLayerOutput, SessionScope, } from './types/runtime.js';
167
+ /** @public */
168
+ export type { AfterModelCallParams, AfterModelCallResult, BeforeToolCallParams, BeforeToolCallResult, LedgerEntry, SteeringConfig, SteeringDecision, SteeringRule, SteeringState, } from './types/steering.js';
169
+ /** @public */
170
+ export { LedgerEntryKind, SteeringAction } from './types/steering.js';
171
+ /** @public */
172
+ export type { ExecuteStepFn, SettleResult, Snapshot, Step, StepBranch, StepFork, StepForkAll, StepForkRace, StepForkSettle, StepLLM, StepLoop, StepProvide, StepRun, StepSpawn, StepTool, Until, Verdict, } from './types/step.js';
173
+ /** @public */
174
+ export type { FsAdapter, FsStats } from './types/fs-adapter.js';
175
+ /** @public Reusable error-serialiser used by custom SubprocessAdapter implementations. */
176
+ export { serializeError } from './adapters/in-memory-subprocess/metadata.js';
177
+ /** @public */
178
+ export type { ShellAdapter, ShellExecOptions, ShellExecResult } from './types/shell-adapter.js';
179
+ /** @public */
180
+ export { TIMEOUT_ERROR_PREFIX } from './types/shell-adapter.js';
181
+ /** @public */
182
+ export type { ProcessSubprocessRequest, SerializedError, StepSubprocessOverrides, StepSubprocessRequest, SubprocessAdapter, SubprocessControlResult, SubprocessHandle, SubprocessHandleMetadata, SubprocessRequest, SubprocessStatus, SubprocessStopResult, } from './types/subprocess-adapter.js';
183
+ /** @public */
184
+ export type { ToolExecutionContext, ToolMemory } from './types/tool-context.js';
185
+ /** @public */
186
+ export { all, any } from './until/combinators.js';
187
+ /** @public */
188
+ export type { ConvergeConfig, VerifyFn } from './until/predicates.js';
189
+ /** @public */
190
+ export { until } from './until/predicates.js';