@noetic-tools/core 0.0.1 → 0.1.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 (202) hide show
  1. package/dist/adapters/in-memory-fs-adapter.js +1 -1
  2. package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +8 -0
  3. package/dist/adapters/in-memory-subprocess/manifest-persistence.js +56 -0
  4. package/dist/adapters/in-memory-subprocess/metadata.d.ts +12 -0
  5. package/dist/adapters/in-memory-subprocess/metadata.js +58 -0
  6. package/dist/adapters/in-memory-subprocess/step-completion.d.ts +3 -0
  7. package/dist/adapters/in-memory-subprocess/step-completion.js +86 -0
  8. package/dist/adapters/in-memory-subprocess/types.d.ts +88 -0
  9. package/dist/adapters/in-memory-subprocess/types.js +2 -0
  10. package/dist/adapters/in-memory-subprocess-adapter.d.ts +12 -4
  11. package/dist/adapters/in-memory-subprocess-adapter.js +164 -55
  12. package/dist/adapters/openrouter.d.ts +11 -2
  13. package/dist/adapters/openrouter.js +66 -5
  14. package/dist/builders/control-flow-builders.js +8 -3
  15. package/dist/builders/every.js +4 -1
  16. package/dist/builders/layer-provides-builders.d.ts +1 -32
  17. package/dist/builders/layer-provides-builders.js +1 -33
  18. package/dist/builders/loop-builder.js +4 -1
  19. package/dist/builders/memory-builder.js +1 -1
  20. package/dist/builders/provide-builder.js +4 -1
  21. package/dist/builders/spawn-builder.d.ts +20 -7
  22. package/dist/builders/spawn-builder.js +16 -2
  23. package/dist/builders/step-builders.d.ts +49 -28
  24. package/dist/builders/step-builders.js +30 -11
  25. package/dist/builders/tool-builder.d.ts +5 -1
  26. package/dist/builders/tool-builder.js +2 -0
  27. package/dist/builders/workflow-hydrator.d.ts +38 -0
  28. package/dist/builders/workflow-hydrator.js +336 -0
  29. package/dist/conditions/conditions.js +1 -1
  30. package/dist/errors/noetic-error.js +2 -0
  31. package/dist/{runtime → harness}/agent-harness.d.ts +65 -45
  32. package/dist/harness/agent-harness.js +576 -0
  33. package/dist/harness/deps/adapters.d.ts +4 -0
  34. package/dist/harness/deps/adapters.js +4 -0
  35. package/dist/harness/deps/interpreter.d.ts +5 -0
  36. package/dist/harness/deps/interpreter.js +4 -0
  37. package/dist/harness/deps/memory.d.ts +5 -0
  38. package/dist/harness/deps/memory.js +4 -0
  39. package/dist/harness/deps/runtime.d.ts +10 -0
  40. package/dist/harness/deps/runtime.js +7 -0
  41. package/dist/harness/deps/types.d.ts +17 -0
  42. package/dist/harness/deps/types.js +1 -0
  43. package/dist/harness/model-call.d.ts +50 -0
  44. package/dist/harness/model-call.js +694 -0
  45. package/dist/harness/model-schema.d.ts +19 -0
  46. package/dist/harness/model-schema.js +46 -0
  47. package/dist/harness/step-bootstrap.d.ts +25 -0
  48. package/dist/harness/step-bootstrap.js +170 -0
  49. package/dist/index.d.ts +48 -12
  50. package/dist/index.js +29 -7
  51. package/dist/interpreter/action-deps.d.ts +12 -0
  52. package/dist/interpreter/action-deps.js +10 -0
  53. package/dist/interpreter/action-types.d.ts +8 -0
  54. package/dist/interpreter/action-types.js +1 -0
  55. package/dist/interpreter/collect-tools.d.ts +1 -1
  56. package/dist/interpreter/collect-tools.js +6 -2
  57. package/dist/interpreter/execute-action.d.ts +22 -0
  58. package/dist/interpreter/execute-action.js +527 -0
  59. package/dist/interpreter/{execute-every.d.ts → execute-control.d.ts} +7 -1
  60. package/dist/interpreter/execute-control.js +530 -0
  61. package/dist/interpreter/execute.d.ts +13 -0
  62. package/dist/interpreter/execute.js +151 -48
  63. package/dist/interpreter/message-helpers.d.ts +1 -9
  64. package/dist/interpreter/message-helpers.js +1 -42
  65. package/dist/interpreter/step-dispatcher.d.ts +61 -0
  66. package/dist/interpreter/step-dispatcher.js +67 -0
  67. package/dist/interpreter/typeguards.d.ts +3 -10
  68. package/dist/interpreter/typeguards.js +3 -20
  69. package/dist/{runtime → memory}/exec-context-factory.js +1 -1
  70. package/dist/memory/flow-schema.d.ts +52 -0
  71. package/dist/memory/flow-schema.js +102 -0
  72. package/dist/memory/function-call-utils.js +4 -2
  73. package/dist/memory/layer-api.d.ts +1 -1
  74. package/dist/memory/layer-api.js +2 -2
  75. package/dist/memory/layer-lifecycle.d.ts +1 -1
  76. package/dist/memory/layer-lifecycle.js +2 -2
  77. package/dist/memory/layer-provides.d.ts +32 -0
  78. package/dist/memory/layer-provides.js +33 -0
  79. package/dist/memory/layer-usage.d.ts +3 -2
  80. package/dist/memory/layer-usage.js +9 -3
  81. package/dist/memory/layers/durable-task-state.js +1 -1
  82. package/dist/memory/layers/file-reference.js +302 -246
  83. package/dist/memory/layers/history-window.js +1 -1
  84. package/dist/memory/layers/observational-memory.js +1 -2
  85. package/dist/memory/layers/plan.d.ts +1 -1
  86. package/dist/memory/layers/plan.js +13 -8
  87. package/dist/memory/layers/steering.js +1 -1
  88. package/dist/memory/layers/tool-memory-layer.d.ts +1 -1
  89. package/dist/memory/layers/working-memory.js +2 -2
  90. package/dist/patterns/dynamic-workflow.d.ts +55 -0
  91. package/dist/patterns/dynamic-workflow.js +194 -0
  92. package/dist/patterns/flow.d.ts +2 -52
  93. package/dist/patterns/flow.js +1 -103
  94. package/dist/patterns/interview.js +1 -1
  95. package/dist/patterns/plans.d.ts +3 -3
  96. package/dist/patterns/plans.js +3 -3
  97. package/dist/patterns/ralph-wiggum.d.ts +1 -1
  98. package/dist/patterns/react.d.ts +1 -1
  99. package/dist/portable/adapters.d.ts +6 -0
  100. package/dist/portable/adapters.js +6 -0
  101. package/dist/portable/ask-user.d.ts +4 -0
  102. package/dist/portable/ask-user.js +2 -0
  103. package/dist/portable/builders.d.ts +12 -0
  104. package/dist/portable/builders.js +12 -0
  105. package/dist/portable/memory-layers.d.ts +12 -0
  106. package/dist/portable/memory-layers.js +12 -0
  107. package/dist/portable/runtime.d.ts +4 -0
  108. package/dist/portable/runtime.js +4 -0
  109. package/dist/portable/until.d.ts +4 -0
  110. package/dist/portable/until.js +4 -0
  111. package/dist/portable.d.ts +8 -26
  112. package/dist/portable.js +8 -34
  113. package/dist/runtime/broadcaster-utils.d.ts +5 -1
  114. package/dist/runtime/broadcaster-utils.js +11 -6
  115. package/dist/runtime/channel-store.js +1 -1
  116. package/dist/runtime/context-deps.d.ts +4 -0
  117. package/dist/runtime/context-deps.js +2 -0
  118. package/dist/runtime/context-impl.d.ts +42 -12
  119. package/dist/runtime/context-impl.js +51 -4
  120. package/dist/runtime/context-type-deps.d.ts +14 -0
  121. package/dist/runtime/context-type-deps.js +1 -0
  122. package/dist/runtime/detached-handle.d.ts +50 -2
  123. package/dist/runtime/detached-handle.js +216 -12
  124. package/dist/runtime/durable/checkpoint-store.d.ts +38 -0
  125. package/dist/runtime/durable/checkpoint-store.js +101 -0
  126. package/dist/runtime/durable/detached-signal.d.ts +37 -0
  127. package/dist/runtime/durable/detached-signal.js +52 -0
  128. package/dist/runtime/durable/harness-checkpoints.d.ts +51 -0
  129. package/dist/runtime/durable/harness-checkpoints.js +104 -0
  130. package/dist/runtime/durable/index.d.ts +10 -0
  131. package/dist/runtime/durable/index.js +5 -0
  132. package/dist/runtime/durable/runnable-loop.d.ts +100 -0
  133. package/dist/runtime/durable/runnable-loop.js +90 -0
  134. package/dist/runtime/durable/session-seed.d.ts +28 -0
  135. package/dist/runtime/durable/session-seed.js +27 -0
  136. package/dist/runtime/durable/stall-nudge.d.ts +82 -0
  137. package/dist/runtime/durable/stall-nudge.js +87 -0
  138. package/dist/runtime/in-memory-storage.js +1 -1
  139. package/dist/runtime/item-log-impl.d.ts +1 -1
  140. package/dist/runtime/step-registry.d.ts +42 -0
  141. package/dist/runtime/step-registry.js +77 -0
  142. package/dist/schemas/workflow.d.ts +139 -0
  143. package/dist/schemas/workflow.js +232 -0
  144. package/dist/types/ask-user-types.d.ts +57 -0
  145. package/dist/types/ask-user-types.js +74 -0
  146. package/dist/types/checkpoint.d.ts +98 -0
  147. package/dist/types/checkpoint.js +81 -0
  148. package/dist/types/common.d.ts +1 -50
  149. package/dist/types/context-parts/item-log.d.ts +6 -0
  150. package/dist/types/context-parts/item-log.js +1 -0
  151. package/dist/types/context-parts/layer-usage.d.ts +18 -0
  152. package/dist/types/context-parts/layer-usage.js +1 -0
  153. package/dist/types/context.d.ts +135 -26
  154. package/dist/types/error.d.ts +15 -0
  155. package/dist/types/harness-result.d.ts +1 -1
  156. package/dist/types/items.d.ts +18 -2
  157. package/dist/types/memory-context.d.ts +39 -0
  158. package/dist/types/memory-context.js +1 -0
  159. package/dist/types/memory.d.ts +35 -65
  160. package/dist/types/runtime.d.ts +2 -1
  161. package/dist/types/steering.d.ts +1 -1
  162. package/dist/types/step-registrar.d.ts +46 -0
  163. package/dist/types/step-registrar.js +56 -0
  164. package/dist/types/step.d.ts +30 -5
  165. package/dist/types/subprocess-adapter.d.ts +119 -3
  166. package/dist/types/subprocess-adapter.js +2 -0
  167. package/dist/types/tool.d.ts +64 -0
  168. package/dist/types/tool.js +1 -0
  169. package/dist/unstable.d.ts +2 -2
  170. package/dist/unstable.js +2 -2
  171. package/dist/until/predicates.d.ts +9 -0
  172. package/dist/until/predicates.js +14 -0
  173. package/dist/util/message-helpers.d.ts +17 -0
  174. package/dist/util/message-helpers.js +64 -0
  175. package/package.json +1 -1
  176. package/dist/adapters/local-fs-adapter.d.ts +0 -3
  177. package/dist/adapters/local-fs-adapter.js +0 -43
  178. package/dist/adapters/local-shell-adapter.d.ts +0 -51
  179. package/dist/adapters/local-shell-adapter.js +0 -167
  180. package/dist/adapters/local-subprocess-adapter.d.ts +0 -16
  181. package/dist/adapters/local-subprocess-adapter.js +0 -187
  182. package/dist/interpreter/execute-branch.d.ts +0 -3
  183. package/dist/interpreter/execute-branch.js +0 -10
  184. package/dist/interpreter/execute-every.js +0 -143
  185. package/dist/interpreter/execute-fork.d.ts +0 -3
  186. package/dist/interpreter/execute-fork.js +0 -215
  187. package/dist/interpreter/execute-llm.d.ts +0 -4
  188. package/dist/interpreter/execute-llm.js +0 -217
  189. package/dist/interpreter/execute-loop.d.ts +0 -3
  190. package/dist/interpreter/execute-loop.js +0 -171
  191. package/dist/interpreter/execute-provide.d.ts +0 -10
  192. package/dist/interpreter/execute-provide.js +0 -64
  193. package/dist/interpreter/execute-run.d.ts +0 -3
  194. package/dist/interpreter/execute-run.js +0 -39
  195. package/dist/interpreter/execute-spawn.d.ts +0 -11
  196. package/dist/interpreter/execute-spawn.js +0 -113
  197. package/dist/interpreter/execute-tool.d.ts +0 -5
  198. package/dist/interpreter/execute-tool.js +0 -81
  199. package/dist/runtime/agent-harness.js +0 -1170
  200. /package/dist/{runtime → memory}/exec-context-factory.d.ts +0 -0
  201. /package/dist/{interpreter → util}/framework-cast.d.ts +0 -0
  202. /package/dist/{interpreter → util}/framework-cast.js +0 -0
@@ -0,0 +1,46 @@
1
+ import { mergeExtensions } from '../schemas/item';
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';
26
+ import { AgentHarness } from './agent-harness';
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
@@ -5,12 +5,6 @@ export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter';
5
5
  /** @public */
6
6
  export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter';
7
7
  /** @public */
8
- export { createLocalFsAdapter } from './adapters/local-fs-adapter';
9
- /** @public */
10
- export { type CreateLocalShellAdapterOptions, createLocalShellAdapter, type LocalShellAdapter, } from './adapters/local-shell-adapter';
11
- /** @public */
12
- export { type CreateLocalSubprocessAdapterOptions, createLocalSubprocessAdapter, defaultProcessSignaller, type ProcessSignaller, type SubprocessSignal, } from './adapters/local-subprocess-adapter';
13
- /** @public */
14
8
  export { createOpenRouterEmbed } from './adapters/openrouter';
15
9
  /** @public */
16
10
  export { channel } from './builders/channel-builder';
@@ -37,6 +31,10 @@ export { step } from './builders/step-builders';
37
31
  /** @public */
38
32
  export { tool, toolWithGenerator } from './builders/tool-builder';
39
33
  /** @public */
34
+ export type { HydrationContext } from './builders/workflow-hydrator';
35
+ /** @public */
36
+ export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator';
37
+ /** @public */
40
38
  export type { Condition, OtherwiseClause, WhenClause } from './conditions';
41
39
  /** @public */
42
40
  export { aiCondition, allCondition, anyCondition, cosineSimilarity, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions';
@@ -45,8 +43,14 @@ export { isNoeticConfigError, NoeticConfigError } from './errors/noetic-config-e
45
43
  /** @public */
46
44
  export { isNoeticError, NoeticErrorImpl } from './errors/noetic-error';
47
45
  /** @public */
46
+ export type { AskUserAnnotation, AskUserInput, AskUserOption, AskUserOutput, AskUserQuestion, } from './types/ask-user-types';
47
+ /** @public */
48
+ export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from './types/ask-user-types';
49
+ /** @public */
48
50
  export { execute } from './interpreter/execute';
49
51
  /** @public */
52
+ export { findFunctionCall } from './memory/function-call-utils';
53
+ /** @public */
50
54
  export type { DurableTaskState, DurableTaskStateConfig } from './memory/layers/durable-task-state';
51
55
  /** @public */
52
56
  export { durableTaskState } from './memory/layers/durable-task-state';
@@ -77,10 +81,18 @@ export { workingMemory } from './memory/layers/working-memory';
77
81
  /** @public */
78
82
  export { stripUnresolvedToolCalls } from './memory/strip-unresolved';
79
83
  /** @public */
84
+ export { createMessage, estimateTokens } from './util/message-helpers';
85
+ /** @public */
86
+ export { GenAI, ToolAttr } from './observability/genai-attributes';
87
+ /** @public */
80
88
  export { InMemoryExporter, NoopExporter } from './observability/trace-exporter';
81
89
  /** @public */
82
90
  export { createInMemoryStorage } from './runtime/in-memory-storage';
83
91
  /** @public */
92
+ export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './patterns/dynamic-workflow';
93
+ /** @public */
94
+ export { dynamicWorkflow, parseAndRunWorkflow } from './patterns/dynamic-workflow';
95
+ /** @public */
84
96
  export type { FlowNode, ForkFlowNode, LlmFlowNode, SequenceFlowNode, SpawnFlowNode, SubagentFlowNode, } from './patterns/flow';
85
97
  /** @public */
86
98
  export { FlowSchema, flowDepth, validateFlow, walkFlow } from './patterns/flow';
@@ -97,17 +109,33 @@ export { ralphWiggum } from './patterns/ralph-wiggum';
97
109
  /** @public */
98
110
  export { react } from './patterns/react';
99
111
  /** @public */
100
- export { AgentHarness } from './runtime/agent-harness';
112
+ export { AgentHarness } from './harness/agent-harness';
113
+ /** @public */
114
+ export type { AfterFirstTurnContext, CheckpointStore, CreateCheckpointStoreOptions, CreateNudgeMessageOpts, DetachedSignal, RunnableLoopHarness, RunnableLoopOpts, SessionSeedHarness, StallNudgeOpts, } from './runtime/durable';
115
+ /** @public */
116
+ export { CheckpointKeys, createCheckpointStore, createDetachedSignal, createNudgeMessage, createStallNudgeHook, DEFAULT_NUDGE_MESSAGE_TEXT, runnableLoop, seedFromItems, } from './runtime/durable';
117
+ /** @public */
118
+ export { getRegistry, lookupStep, registerStep } from './runtime/step-registry';
101
119
  /** @public */
102
120
  export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from './schemas/item';
103
121
  /** @public */
122
+ export type { BranchRoute, BranchWorkflowNode, EveryWorkflowNode, ForkWorkflowNode, LlmWorkflowNode, LoopWorkflowNode, MergeStrategy, ProvideWorkflowNode, SequenceWorkflowNode, SpawnWorkflowNode, ToolWorkflowNode, UntilPredicate, WorkflowDocument, WorkflowNode, } from './schemas/workflow';
123
+ /** @public */
124
+ export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow';
125
+ /** @public */
104
126
  export type { Channel, ChannelHandle, ExternalChannel } from './types/channel';
105
127
  /** @public */
106
- export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, StepMeta, TokenUsage, Tool, ToolMemoryDeclaration, } from './types/common';
128
+ export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, StepMeta, TokenUsage, } from './types/common';
129
+ /** @public */
130
+ export type { Tool, ToolMemoryDeclaration } from './types/tool';
107
131
  /** @public */
108
132
  export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers';
109
133
  /** @public */
110
- export type { Context, CwdState, ItemLog, LastLayerUsage, LayerUsageEntry, } from './types/context';
134
+ export type { Context, ContextHarness, CwdState, } from './types/context';
135
+ /** @public */
136
+ export type { ItemLog } from './types/context-parts/item-log';
137
+ /** @public */
138
+ export type { LastLayerUsage, LayerUsageEntry } from './types/context-parts/layer-usage';
111
139
  /** @public */
112
140
  export type { DetachedHandle } from './types/detached';
113
141
  /** @public */
@@ -115,14 +143,20 @@ export { DetachedStatus } from './types/detached';
115
143
  /** @public */
116
144
  export type { EmbedFn } from './types/embed';
117
145
  /** @public */
146
+ export type { CheckpointSnapshot, CwdSnapshot, FrontierFrame, ItemLogSnapshot, PendingAskUserSnapshot, } from './types/checkpoint';
147
+ /** @public */
148
+ export { CheckpointSchemaVersion, CheckpointSnapshotSchema, CwdSnapshotSchema, FrontierFrameSchema, ItemLogSnapshotSchema, PendingAskUserSnapshotSchema, } from './types/checkpoint';
149
+ /** @public */
118
150
  export type { NoeticError } from './types/error';
119
151
  /** @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';
152
+ 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';
121
153
  /** @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';
154
+ 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';
123
155
  /** @public */
124
156
  export { Slot } from './types/memory';
125
157
  /** @public */
158
+ export type { ExecutionContext, ExecutionOutcome, MemoryCallModelRequest, MemoryScope, } from './types/memory-context';
159
+ /** @public */
126
160
  export type { MemoryTraceSpan, Span, TraceExporter } from './types/observability';
127
161
  /** @public */
128
162
  export type { FrameworkStreamEvent, HarnessResponse, SdkStreamEvent, StreamEvent, StreamingItem, } from './types/harness-result';
@@ -136,12 +170,14 @@ export { LedgerEntryKind, SteeringAction } from './types/steering';
136
170
  export type { ExecuteStepFn, SettleResult, Snapshot, Step, StepBranch, StepFork, StepForkAll, StepForkRace, StepForkSettle, StepLLM, StepLoop, StepProvide, StepRun, StepSpawn, StepTool, Until, Verdict, } from './types/step';
137
171
  /** @public */
138
172
  export type { FsAdapter, FsStats } from './types/fs-adapter';
173
+ /** @public Reusable error-serialiser used by custom SubprocessAdapter implementations. */
174
+ export { serializeError } from './adapters/in-memory-subprocess/metadata';
139
175
  /** @public */
140
176
  export type { ShellAdapter, ShellExecOptions, ShellExecResult } from './types/shell-adapter';
141
177
  /** @public */
142
178
  export { TIMEOUT_ERROR_PREFIX } from './types/shell-adapter';
143
179
  /** @public */
144
- export type { SubprocessAdapter, SubprocessControlResult, SubprocessHandle, SubprocessRequest, SubprocessStatus, SubprocessStopResult, } from './types/subprocess-adapter';
180
+ export type { ProcessSubprocessRequest, SerializedError, StepSubprocessOverrides, StepSubprocessRequest, SubprocessAdapter, SubprocessControlResult, SubprocessHandle, SubprocessHandleMetadata, SubprocessRequest, SubprocessStatus, SubprocessStopResult, } from './types/subprocess-adapter';
145
181
  /** @public */
146
182
  export type { ToolExecutionContext, ToolMemory } from './types/tool-context';
147
183
  /** @public */
package/dist/index.js CHANGED
@@ -6,12 +6,6 @@ export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter';
6
6
  /** @public */
7
7
  export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter';
8
8
  /** @public */
9
- export { createLocalFsAdapter } from './adapters/local-fs-adapter';
10
- /** @public */
11
- export { createLocalShellAdapter, } from './adapters/local-shell-adapter';
12
- /** @public */
13
- export { createLocalSubprocessAdapter, defaultProcessSignaller, } from './adapters/local-subprocess-adapter';
14
- /** @public */
15
9
  export { createOpenRouterEmbed } from './adapters/openrouter';
16
10
  //#endregion
17
11
  //#region Builders
@@ -36,6 +30,8 @@ export { step } from './builders/step-builders';
36
30
  /** @public */
37
31
  export { tool, toolWithGenerator } from './builders/tool-builder';
38
32
  /** @public */
33
+ export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator';
34
+ /** @public */
39
35
  export { aiCondition, allCondition, anyCondition, cosineSimilarity, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions';
40
36
  //#endregion
41
37
  //#region Errors
@@ -43,10 +39,16 @@ export { aiCondition, allCondition, anyCondition, cosineSimilarity, embeddingMat
43
39
  export { isNoeticConfigError, NoeticConfigError } from './errors/noetic-config-error';
44
40
  /** @public */
45
41
  export { isNoeticError, NoeticErrorImpl } from './errors/noetic-error';
42
+ /** @public */
43
+ export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from './types/ask-user-types';
46
44
  //#endregion
47
45
  //#region Execution
48
46
  /** @public */
49
47
  export { execute } from './interpreter/execute';
48
+ //#endregion
49
+ //#region Memory Layers
50
+ /** @public */
51
+ export { findFunctionCall } from './memory/function-call-utils';
50
52
  /** @public */
51
53
  export { durableTaskState } from './memory/layers/durable-task-state';
52
54
  /** @public */
@@ -68,12 +70,20 @@ export { workingMemory } from './memory/layers/working-memory';
68
70
  /** @public */
69
71
  export { stripUnresolvedToolCalls } from './memory/strip-unresolved';
70
72
  //#endregion
73
+ //#region Message Utilities
74
+ /** @public */
75
+ export { createMessage, estimateTokens } from './util/message-helpers';
76
+ //#endregion
71
77
  //#region Observability
72
78
  /** @public */
79
+ export { GenAI, ToolAttr } from './observability/genai-attributes';
80
+ /** @public */
73
81
  export { InMemoryExporter, NoopExporter } from './observability/trace-exporter';
74
82
  /** @public */
75
83
  export { createInMemoryStorage } from './runtime/in-memory-storage';
76
84
  /** @public */
85
+ export { dynamicWorkflow, parseAndRunWorkflow } from './patterns/dynamic-workflow';
86
+ /** @public */
77
87
  export { FlowSchema, flowDepth, validateFlow, walkFlow } from './patterns/flow';
78
88
  /** @public */
79
89
  export { interview } from './patterns/interview';
@@ -86,11 +96,17 @@ export { react } from './patterns/react';
86
96
  //#endregion
87
97
  //#region Runtime
88
98
  /** @public */
89
- export { AgentHarness } from './runtime/agent-harness';
99
+ export { AgentHarness } from './harness/agent-harness';
100
+ /** @public */
101
+ export { CheckpointKeys, createCheckpointStore, createDetachedSignal, createNudgeMessage, createStallNudgeHook, DEFAULT_NUDGE_MESSAGE_TEXT, runnableLoop, seedFromItems, } from './runtime/durable';
102
+ /** @public */
103
+ export { getRegistry, lookupStep, registerStep } from './runtime/step-registry';
90
104
  //#endregion
91
105
  //#region Schemas
92
106
  /** @public */
93
107
  export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from './schemas/item';
108
+ /** @public */
109
+ export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow';
94
110
  //#endregion
95
111
  //#region Types — Context
96
112
  /** @public */
@@ -98,9 +114,15 @@ export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers'
98
114
  /** @public */
99
115
  export { DetachedStatus } from './types/detached';
100
116
  /** @public */
117
+ export { CheckpointSchemaVersion, CheckpointSnapshotSchema, CwdSnapshotSchema, FrontierFrameSchema, ItemLogSnapshotSchema, PendingAskUserSnapshotSchema, } from './types/checkpoint';
118
+ /** @public */
101
119
  export { Slot } from './types/memory';
102
120
  /** @public */
103
121
  export { LedgerEntryKind, SteeringAction } from './types/steering';
122
+ //#endregion
123
+ //#region Types — Shell
124
+ /** @public Reusable error-serialiser used by custom SubprocessAdapter implementations. */
125
+ export { serializeError } from './adapters/in-memory-subprocess/metadata';
104
126
  /** @public */
105
127
  export { TIMEOUT_ERROR_PREFIX } from './types/shell-adapter';
106
128
  //#endregion
@@ -0,0 +1,12 @@
1
+ export { contextToExecCtx } from '../memory/exec-context-factory';
2
+ export { resolveLayerTools } from '../memory/layer-api';
3
+ export type { LayerStateStore } from '../memory/layer-lifecycle';
4
+ export { returnLayers, spawnLayers } from '../memory/layer-lifecycle';
5
+ export { commitLayerUsage, computeLayerUsage } from '../memory/layer-usage';
6
+ export { assembleView } from '../memory/projector';
7
+ export { emitFrameworkEvent, getBroadcaster } from '../runtime/broadcaster-utils';
8
+ export { ContextImpl } from '../runtime/context-impl';
9
+ export { snapshotCwdState } from '../runtime/cwd-helpers';
10
+ export { buildToolExecutionContext } from '../runtime/tool-memory';
11
+ export type { ItemSchemaRegistry } from '../schemas/item';
12
+ export { defaultItemSchemaRegistry } from '../schemas/item';
@@ -0,0 +1,10 @@
1
+ export { contextToExecCtx } from '../memory/exec-context-factory';
2
+ export { resolveLayerTools } from '../memory/layer-api';
3
+ export { returnLayers, spawnLayers } from '../memory/layer-lifecycle';
4
+ export { commitLayerUsage, computeLayerUsage } from '../memory/layer-usage';
5
+ export { assembleView } from '../memory/projector';
6
+ export { emitFrameworkEvent, getBroadcaster } from '../runtime/broadcaster-utils';
7
+ export { ContextImpl } from '../runtime/context-impl';
8
+ export { snapshotCwdState } from '../runtime/cwd-helpers';
9
+ export { buildToolExecutionContext } from '../runtime/tool-memory';
10
+ export { defaultItemSchemaRegistry } from '../schemas/item';
@@ -0,0 +1,8 @@
1
+ export type { RetryPolicy, StepMeta } from '../types/common';
2
+ export type { Context } from '../types/context';
3
+ export type { FunctionCallItem, Item } from '../types/items';
4
+ export type { ContextMemory, ExecutionContext, MemoryConfig, MemoryLayer } from '../types/memory';
5
+ export type { AgentHarnessContract, RecallLayerOutput } from '../types/runtime';
6
+ export { SteeringAction } from '../types/steering';
7
+ export type { ExecuteStepFn, StepLLM, StepProvide, StepRun, StepSpawn, StepTool, } from '../types/step';
8
+ export type { Tool } from '../types/tool';
@@ -0,0 +1 @@
1
+ export { SteeringAction } from '../types/steering';
@@ -1,5 +1,5 @@
1
- import type { Tool } from '../types/common';
2
1
  import type { Step } from '../types/step';
2
+ import type { Tool } from '../types/tool';
3
3
  /**
4
4
  * Recursively walks a step tree and collects all Tool instances
5
5
  * declared on LLM steps. Used to build the unified tool set
@@ -1,4 +1,4 @@
1
- import { frameworkCast } from './framework-cast';
1
+ import { frameworkCast } from '../util/framework-cast';
2
2
  /**
3
3
  * Recursively walks a step tree and collects all Tool instances
4
4
  * declared on LLM steps. Used to build the unified tool set
@@ -28,7 +28,11 @@ export function deduplicateTools(tools) {
28
28
  function walkStep(step, out) {
29
29
  switch (step.kind) {
30
30
  case 'llm':
31
- if (step.tools) {
31
+ // Skip function-form tools: they're resolved per execution from `ctx`
32
+ // and cannot contribute to the pre-computed unified set. Consumers that
33
+ // need those tools in the pool should register them via
34
+ // `AgentHarness.tools` instead.
35
+ if (Array.isArray(step.tools)) {
32
36
  out.push(...step.tools);
33
37
  }
34
38
  return;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Action step handlers: run, llm, spawn, provide, tool.
3
+ */
4
+ import type { ItemSchemaRegistry, LayerStateStore } from './action-deps';
5
+ import type { AgentHarnessContract, Context, ExecuteStepFn, MemoryLayer, StepLLM, StepProvide, StepRun, StepSpawn, StepTool } from './action-types';
6
+ export declare function executeRun<TMemory, I, O>(step: StepRun<TMemory, I, O>, input: I, ctx: Context<TMemory>): Promise<O>;
7
+ export declare function executeLLM<TMemory, I, O>(step: StepLLM<TMemory, I, O>, input: I, ctx: Context<TMemory>, layers?: MemoryLayer[]): Promise<O>;
8
+ export interface ExecuteSpawnOpts {
9
+ layerStore?: LayerStateStore;
10
+ parentLayers?: MemoryLayer[];
11
+ itemSchemas?: ItemSchemaRegistry;
12
+ }
13
+ export declare function executeSpawn<TMemory, I, O>(step: StepSpawn<TMemory, I, O>, input: I, ctx: Context<TMemory>, executeStep: ExecuteStepFn, opts?: ExecuteSpawnOpts): Promise<O>;
14
+ /**
15
+ * Executes a provide step by attaching memory layers to the current context
16
+ * without creating an isolated child context.
17
+ *
18
+ * Unlike spawn, provide does not create a new itemLog or clone state.
19
+ * Events flow through to the parent in real-time.
20
+ */
21
+ export declare function executeProvide<TMemory, I, O>(step: StepProvide<TMemory, I, O>, input: I, ctx: Context<TMemory>, executeStep: ExecuteStepFn): Promise<O>;
22
+ export declare function executeTool<TMemory, I, O>(step: StepTool<TMemory, I, O>, input: I, ctx: Context<TMemory>, harness: AgentHarnessContract, layers?: MemoryLayer[]): Promise<O>;