@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.
- package/README.md +31 -11
- package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
- package/dist/adapters/in-memory-fs-adapter.js +1 -1
- package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
- package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +8 -0
- package/dist/adapters/in-memory-subprocess/manifest-persistence.js +56 -0
- package/dist/adapters/in-memory-subprocess/metadata.d.ts +12 -0
- package/dist/adapters/in-memory-subprocess/metadata.js +58 -0
- package/dist/adapters/in-memory-subprocess/step-completion.d.ts +3 -0
- package/dist/adapters/in-memory-subprocess/step-completion.js +86 -0
- package/dist/adapters/in-memory-subprocess/types.d.ts +88 -0
- package/dist/adapters/in-memory-subprocess/types.js +2 -0
- package/dist/adapters/in-memory-subprocess-adapter.d.ts +12 -4
- package/dist/adapters/in-memory-subprocess-adapter.js +164 -55
- package/dist/adapters/openrouter.d.ts +16 -7
- package/dist/adapters/openrouter.js +68 -7
- package/dist/builders/channel-builder.d.ts +1 -1
- package/dist/builders/control-flow-builders.d.ts +3 -3
- package/dist/builders/control-flow-builders.js +9 -4
- package/dist/builders/every.d.ts +3 -3
- package/dist/builders/every.js +5 -2
- package/dist/builders/layer-provides-builders.d.ts +1 -32
- package/dist/builders/layer-provides-builders.js +1 -33
- package/dist/builders/loop-builder.d.ts +2 -2
- package/dist/builders/loop-builder.js +5 -2
- package/dist/builders/memory-builder.d.ts +1 -1
- package/dist/builders/memory-builder.js +1 -1
- package/dist/builders/provide-builder.d.ts +2 -2
- package/dist/builders/provide-builder.js +5 -2
- package/dist/builders/spawn-builder.d.ts +22 -9
- package/dist/builders/spawn-builder.js +17 -3
- package/dist/builders/step-builders.d.ts +51 -30
- package/dist/builders/step-builders.js +31 -12
- package/dist/builders/tool-builder.d.ts +7 -3
- package/dist/builders/tool-builder.js +3 -1
- package/dist/builders/workflow-hydrator.d.ts +38 -0
- package/dist/builders/workflow-hydrator.js +336 -0
- package/dist/conditions/conditions.d.ts +4 -4
- package/dist/conditions/conditions.js +2 -2
- package/dist/errors/noetic-error.d.ts +1 -1
- package/dist/errors/noetic-error.js +2 -0
- package/dist/{runtime → harness}/agent-harness.d.ts +65 -45
- package/dist/harness/agent-harness.js +576 -0
- package/dist/harness/deps/adapters.d.ts +4 -0
- package/dist/harness/deps/adapters.js +4 -0
- package/dist/harness/deps/interpreter.d.ts +5 -0
- package/dist/harness/deps/interpreter.js +4 -0
- package/dist/harness/deps/memory.d.ts +5 -0
- package/dist/harness/deps/memory.js +4 -0
- package/dist/harness/deps/runtime.d.ts +10 -0
- package/dist/harness/deps/runtime.js +7 -0
- package/dist/harness/deps/types.d.ts +17 -0
- package/dist/harness/deps/types.js +1 -0
- package/dist/harness/model-call.d.ts +50 -0
- package/dist/harness/model-call.js +694 -0
- package/dist/harness/model-schema.d.ts +19 -0
- package/dist/harness/model-schema.js +46 -0
- package/dist/harness/step-bootstrap.d.ts +25 -0
- package/dist/harness/step-bootstrap.js +170 -0
- package/dist/index.d.ts +114 -76
- package/dist/index.js +74 -50
- package/dist/internal-test.d.ts +4 -4
- package/dist/internal-test.js +4 -4
- package/dist/interpreter/action-deps.d.ts +12 -0
- package/dist/interpreter/action-deps.js +10 -0
- package/dist/interpreter/action-types.d.ts +8 -0
- package/dist/interpreter/action-types.js +1 -0
- package/dist/interpreter/collect-tools.d.ts +2 -2
- package/dist/interpreter/collect-tools.js +6 -2
- package/dist/interpreter/execute-action.d.ts +22 -0
- package/dist/interpreter/execute-action.js +527 -0
- package/dist/interpreter/{execute-every.d.ts → execute-control.d.ts} +8 -2
- package/dist/interpreter/execute-control.js +530 -0
- package/dist/interpreter/execute.d.ts +16 -3
- package/dist/interpreter/execute.js +154 -51
- package/dist/interpreter/message-helpers.d.ts +1 -9
- package/dist/interpreter/message-helpers.js +1 -42
- package/dist/interpreter/step-dispatcher.d.ts +61 -0
- package/dist/interpreter/step-dispatcher.js +67 -0
- package/dist/interpreter/typeguards.d.ts +8 -15
- package/dist/interpreter/typeguards.js +4 -21
- package/dist/memory/budget.d.ts +2 -2
- package/dist/memory/budget.js +1 -1
- package/dist/{runtime → memory}/exec-context-factory.d.ts +2 -2
- package/dist/{runtime → memory}/exec-context-factory.js +1 -1
- package/dist/memory/flow-schema.d.ts +52 -0
- package/dist/memory/flow-schema.js +102 -0
- package/dist/memory/function-call-utils.d.ts +1 -1
- package/dist/memory/function-call-utils.js +4 -2
- package/dist/memory/layer-api.d.ts +4 -4
- package/dist/memory/layer-api.js +2 -2
- package/dist/memory/layer-lifecycle.d.ts +6 -6
- package/dist/memory/layer-lifecycle.js +6 -6
- package/dist/memory/layer-provides.d.ts +32 -0
- package/dist/memory/layer-provides.js +33 -0
- package/dist/memory/layer-usage.d.ts +4 -3
- package/dist/memory/layer-usage.js +9 -3
- package/dist/memory/layers/durable-task-state.d.ts +8 -8
- package/dist/memory/layers/durable-task-state.js +2 -2
- package/dist/memory/layers/file-reference.d.ts +1 -1
- package/dist/memory/layers/file-reference.js +303 -247
- package/dist/memory/layers/history-window.d.ts +1 -1
- package/dist/memory/layers/history-window.js +4 -4
- package/dist/memory/layers/observational-memory.d.ts +5 -5
- package/dist/memory/layers/observational-memory.js +2 -3
- package/dist/memory/layers/plan.d.ts +2 -2
- package/dist/memory/layers/plan.js +15 -10
- package/dist/memory/layers/static-content.d.ts +2 -2
- package/dist/memory/layers/static-content.js +1 -1
- package/dist/memory/layers/steering.d.ts +7 -7
- package/dist/memory/layers/steering.js +5 -5
- package/dist/memory/layers/tool-memory-layer.d.ts +2 -2
- package/dist/memory/layers/tool-memory-layer.js +1 -1
- package/dist/memory/layers/working-memory.d.ts +7 -7
- package/dist/memory/layers/working-memory.js +4 -4
- package/dist/memory/projector.d.ts +2 -2
- package/dist/memory/scope.d.ts +1 -1
- package/dist/memory/strip-unresolved.d.ts +1 -1
- package/dist/observability/span-impl.d.ts +1 -1
- package/dist/observability/trace-exporter.d.ts +2 -2
- package/dist/observability/trace-exporter.js +1 -1
- package/dist/patterns/dynamic-workflow.d.ts +55 -0
- package/dist/patterns/dynamic-workflow.js +194 -0
- package/dist/patterns/flow.d.ts +2 -52
- package/dist/patterns/flow.js +1 -103
- package/dist/patterns/interview.d.ts +2 -2
- package/dist/patterns/interview.js +5 -5
- package/dist/patterns/plans.d.ts +6 -6
- package/dist/patterns/plans.js +4 -4
- package/dist/patterns/ralph-wiggum.d.ts +4 -4
- package/dist/patterns/ralph-wiggum.js +5 -5
- package/dist/patterns/react.d.ts +3 -3
- package/dist/patterns/react.js +5 -5
- package/dist/portable/adapters.d.ts +6 -0
- package/dist/portable/adapters.js +6 -0
- package/dist/portable/ask-user.d.ts +4 -0
- package/dist/portable/ask-user.js +2 -0
- package/dist/portable/builders.d.ts +12 -0
- package/dist/portable/builders.js +12 -0
- package/dist/portable/memory-layers.d.ts +12 -0
- package/dist/portable/memory-layers.js +12 -0
- package/dist/portable/runtime.d.ts +4 -0
- package/dist/portable/runtime.js +4 -0
- package/dist/portable/until.d.ts +4 -0
- package/dist/portable/until.js +4 -0
- package/dist/portable.d.ts +8 -26
- package/dist/portable.js +8 -34
- package/dist/runtime/broadcaster-utils.d.ts +7 -3
- package/dist/runtime/broadcaster-utils.js +11 -6
- package/dist/runtime/channel-store.d.ts +1 -1
- package/dist/runtime/channel-store.js +2 -2
- package/dist/runtime/context-deps.d.ts +4 -0
- package/dist/runtime/context-deps.js +2 -0
- package/dist/runtime/context-impl.d.ts +42 -12
- package/dist/runtime/context-impl.js +52 -5
- package/dist/runtime/context-type-deps.d.ts +14 -0
- package/dist/runtime/context-type-deps.js +1 -0
- package/dist/runtime/cwd-helpers.d.ts +1 -1
- package/dist/runtime/detached-handle.d.ts +52 -4
- package/dist/runtime/detached-handle.js +218 -14
- package/dist/runtime/durable/checkpoint-store.d.ts +38 -0
- package/dist/runtime/durable/checkpoint-store.js +101 -0
- package/dist/runtime/durable/detached-signal.d.ts +37 -0
- package/dist/runtime/durable/detached-signal.js +52 -0
- package/dist/runtime/durable/harness-checkpoints.d.ts +51 -0
- package/dist/runtime/durable/harness-checkpoints.js +104 -0
- package/dist/runtime/durable/index.d.ts +10 -0
- package/dist/runtime/durable/index.js +5 -0
- package/dist/runtime/durable/runnable-loop.d.ts +100 -0
- package/dist/runtime/durable/runnable-loop.js +90 -0
- package/dist/runtime/durable/session-seed.d.ts +28 -0
- package/dist/runtime/durable/session-seed.js +27 -0
- package/dist/runtime/durable/stall-nudge.d.ts +82 -0
- package/dist/runtime/durable/stall-nudge.js +87 -0
- package/dist/runtime/event-broadcaster.d.ts +1 -1
- package/dist/runtime/in-memory-storage.d.ts +1 -1
- package/dist/runtime/in-memory-storage.js +1 -1
- package/dist/runtime/item-log-impl.d.ts +3 -3
- package/dist/runtime/item-log-impl.js +1 -1
- package/dist/runtime/message-queue.d.ts +2 -2
- package/dist/runtime/session-runner.d.ts +7 -7
- package/dist/runtime/session-runner.js +3 -3
- package/dist/runtime/session-streams.d.ts +3 -3
- package/dist/runtime/session-streams.js +1 -1
- package/dist/runtime/step-registry.d.ts +42 -0
- package/dist/runtime/step-registry.js +77 -0
- package/dist/runtime/tool-memory.d.ts +3 -3
- package/dist/schemas/item.d.ts +1 -1
- package/dist/schemas/workflow.d.ts +139 -0
- package/dist/schemas/workflow.js +232 -0
- package/dist/types/ask-user-types.d.ts +57 -0
- package/dist/types/ask-user-types.js +74 -0
- package/dist/types/checkpoint.d.ts +98 -0
- package/dist/types/checkpoint.js +81 -0
- package/dist/types/common.d.ts +1 -50
- package/dist/types/context-parts/item-log.d.ts +6 -0
- package/dist/types/context-parts/item-log.js +1 -0
- package/dist/types/context-parts/layer-usage.d.ts +18 -0
- package/dist/types/context-parts/layer-usage.js +1 -0
- package/dist/types/context.d.ts +140 -31
- package/dist/types/error.d.ts +15 -0
- package/dist/types/harness-result.d.ts +2 -2
- package/dist/types/items.d.ts +18 -2
- package/dist/types/memory-context.d.ts +39 -0
- package/dist/types/memory-context.js +1 -0
- package/dist/types/memory.d.ts +38 -68
- package/dist/types/mutable-context.d.ts +3 -3
- package/dist/types/runtime.d.ts +14 -13
- package/dist/types/steering.d.ts +2 -2
- package/dist/types/step-registrar.d.ts +46 -0
- package/dist/types/step-registrar.js +56 -0
- package/dist/types/step.d.ts +34 -9
- package/dist/types/subprocess-adapter.d.ts +119 -3
- package/dist/types/subprocess-adapter.js +2 -0
- package/dist/types/tool-context.d.ts +6 -6
- package/dist/types/tool.d.ts +64 -0
- package/dist/types/tool.js +1 -0
- package/dist/unstable.d.ts +9 -9
- package/dist/unstable.js +7 -7
- package/dist/until/combinators.d.ts +1 -1
- package/dist/until/never.d.ts +1 -1
- package/dist/until/predicates.d.ts +13 -4
- package/dist/until/predicates.js +16 -2
- package/dist/util/message-helpers.d.ts +17 -0
- package/dist/util/message-helpers.js +64 -0
- package/package.json +6 -4
- package/dist/adapters/local-fs-adapter.d.ts +0 -3
- package/dist/adapters/local-fs-adapter.js +0 -43
- package/dist/adapters/local-shell-adapter.d.ts +0 -51
- package/dist/adapters/local-shell-adapter.js +0 -167
- package/dist/adapters/local-subprocess-adapter.d.ts +0 -16
- package/dist/adapters/local-subprocess-adapter.js +0 -187
- package/dist/conditions/index.d.ts +0 -3
- package/dist/conditions/index.js +0 -2
- package/dist/interpreter/execute-branch.d.ts +0 -3
- package/dist/interpreter/execute-branch.js +0 -10
- package/dist/interpreter/execute-every.js +0 -143
- package/dist/interpreter/execute-fork.d.ts +0 -3
- package/dist/interpreter/execute-fork.js +0 -215
- package/dist/interpreter/execute-llm.d.ts +0 -4
- package/dist/interpreter/execute-llm.js +0 -217
- package/dist/interpreter/execute-loop.d.ts +0 -3
- package/dist/interpreter/execute-loop.js +0 -171
- package/dist/interpreter/execute-provide.d.ts +0 -10
- package/dist/interpreter/execute-provide.js +0 -64
- package/dist/interpreter/execute-run.d.ts +0 -3
- package/dist/interpreter/execute-run.js +0 -39
- package/dist/interpreter/execute-spawn.d.ts +0 -11
- package/dist/interpreter/execute-spawn.js +0 -113
- package/dist/interpreter/execute-tool.d.ts +0 -5
- package/dist/interpreter/execute-tool.js +0 -81
- package/dist/runtime/agent-harness.js +0 -1170
- /package/dist/{interpreter → util}/framework-cast.d.ts +0 -0
- /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 {
|
|
8
|
+
export { createOpenRouterEmbed } from './adapters/openrouter.js';
|
|
9
9
|
/** @public */
|
|
10
|
-
export {
|
|
10
|
+
export { channel } from './builders/channel-builder.js';
|
|
11
11
|
/** @public */
|
|
12
|
-
export {
|
|
12
|
+
export { branch, fork } from './builders/control-flow-builders.js';
|
|
13
13
|
/** @public */
|
|
14
|
-
export {
|
|
14
|
+
export type { EveryOptions } from './builders/every.js';
|
|
15
15
|
/** @public */
|
|
16
|
-
export {
|
|
16
|
+
export { every } from './builders/every.js';
|
|
17
17
|
/** @public */
|
|
18
|
-
export {
|
|
18
|
+
export { layerData, layerFn } from './builders/layer-provides-builders.js';
|
|
19
19
|
/** @public */
|
|
20
|
-
export type {
|
|
20
|
+
export type { LoopConfig } from './builders/loop-builder.js';
|
|
21
21
|
/** @public */
|
|
22
|
-
export {
|
|
22
|
+
export { loop } from './builders/loop-builder.js';
|
|
23
23
|
/** @public */
|
|
24
|
-
export {
|
|
24
|
+
export { memory } from './builders/memory-builder.js';
|
|
25
25
|
/** @public */
|
|
26
|
-
export
|
|
26
|
+
export { provide } from './builders/provide-builder.js';
|
|
27
27
|
/** @public */
|
|
28
|
-
export {
|
|
28
|
+
export { spawn } from './builders/spawn-builder.js';
|
|
29
29
|
/** @public */
|
|
30
|
-
export {
|
|
30
|
+
export { step } from './builders/step-builders.js';
|
|
31
31
|
/** @public */
|
|
32
|
-
export {
|
|
32
|
+
export { tool, toolWithGenerator } from './builders/tool-builder.js';
|
|
33
33
|
/** @public */
|
|
34
|
-
export {
|
|
34
|
+
export type { HydrationContext } from './builders/workflow-hydrator.js';
|
|
35
35
|
/** @public */
|
|
36
|
-
export {
|
|
36
|
+
export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
|
|
37
37
|
/** @public */
|
|
38
|
-
export {
|
|
38
|
+
export type { Condition, OtherwiseClause, WhenClause } from './conditions/conditions.js';
|
|
39
39
|
/** @public */
|
|
40
|
-
export
|
|
40
|
+
export { aiCondition, allCondition, anyCondition, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions/conditions.js';
|
|
41
41
|
/** @public */
|
|
42
|
-
export {
|
|
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 {
|
|
48
|
+
export type { AskUserAnnotation, AskUserInput, AskUserOption, AskUserOutput, AskUserQuestion, } from './types/ask-user-types.js';
|
|
49
49
|
/** @public */
|
|
50
|
-
export
|
|
50
|
+
export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from './types/ask-user-types.js';
|
|
51
51
|
/** @public */
|
|
52
|
-
export {
|
|
52
|
+
export { execute } from './interpreter/execute.js';
|
|
53
53
|
/** @public */
|
|
54
|
-
export {
|
|
54
|
+
export { findFunctionCall } from './memory/function-call-utils.js';
|
|
55
55
|
/** @public */
|
|
56
|
-
export type {
|
|
56
|
+
export type { DurableTaskState, DurableTaskStateConfig } from './memory/layers/durable-task-state.js';
|
|
57
57
|
/** @public */
|
|
58
|
-
export {
|
|
58
|
+
export { durableTaskState } from './memory/layers/durable-task-state.js';
|
|
59
59
|
/** @public */
|
|
60
|
-
export
|
|
60
|
+
export { fileReference } from './memory/layers/file-reference.js';
|
|
61
61
|
/** @public */
|
|
62
|
-
export {
|
|
62
|
+
export type { HistoryWindowConfig } from './memory/layers/history-window.js';
|
|
63
63
|
/** @public */
|
|
64
|
-
export
|
|
64
|
+
export { historyWindow } from './memory/layers/history-window.js';
|
|
65
65
|
/** @public */
|
|
66
|
-
export {
|
|
66
|
+
export type { ObservationalMemoryConfig, ObservationalState, } from './memory/layers/observational-memory.js';
|
|
67
67
|
/** @public */
|
|
68
|
-
export {
|
|
68
|
+
export { observationalMemory } from './memory/layers/observational-memory.js';
|
|
69
69
|
/** @public */
|
|
70
|
-
export {
|
|
70
|
+
export type { PlanEnterSessionCallback, PlanExecutionEntry, PlanExitCallback, PlanMemoryConfig, PlanState, } from './memory/layers/plan.js';
|
|
71
71
|
/** @public */
|
|
72
|
-
export {
|
|
72
|
+
export { PlanPhase, planMemory } from './memory/layers/plan.js';
|
|
73
73
|
/** @public */
|
|
74
|
-
export
|
|
74
|
+
export { staticContent } from './memory/layers/static-content.js';
|
|
75
75
|
/** @public */
|
|
76
|
-
export {
|
|
76
|
+
export { steering } from './memory/layers/steering.js';
|
|
77
77
|
/** @public */
|
|
78
|
-
export {
|
|
78
|
+
export { toolMemoryLayer } from './memory/layers/tool-memory-layer.js';
|
|
79
79
|
/** @public */
|
|
80
|
-
export {
|
|
80
|
+
export type { WorkingMemoryConfig, WorkingMemoryState } from './memory/layers/working-memory.js';
|
|
81
81
|
/** @public */
|
|
82
|
-
export {
|
|
82
|
+
export { workingMemory } from './memory/layers/working-memory.js';
|
|
83
83
|
/** @public */
|
|
84
|
-
export
|
|
84
|
+
export { stripUnresolvedToolCalls } from './memory/strip-unresolved.js';
|
|
85
85
|
/** @public */
|
|
86
|
-
export {
|
|
86
|
+
export { createMessage, estimateTokens } from './util/message-helpers.js';
|
|
87
87
|
/** @public */
|
|
88
|
-
export
|
|
88
|
+
export { GenAI, ToolAttr } from './observability/genai-attributes.js';
|
|
89
89
|
/** @public */
|
|
90
|
-
export {
|
|
90
|
+
export { InMemoryExporter, NoopExporter } from './observability/trace-exporter.js';
|
|
91
91
|
/** @public */
|
|
92
|
-
export
|
|
92
|
+
export { createInMemoryStorage } from './runtime/in-memory-storage.js';
|
|
93
93
|
/** @public */
|
|
94
|
-
export {
|
|
94
|
+
export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './patterns/dynamic-workflow.js';
|
|
95
95
|
/** @public */
|
|
96
|
-
export {
|
|
96
|
+
export { dynamicWorkflow, parseAndRunWorkflow } from './patterns/dynamic-workflow.js';
|
|
97
97
|
/** @public */
|
|
98
|
-
export {
|
|
98
|
+
export type { FlowNode, ForkFlowNode, LlmFlowNode, SequenceFlowNode, SpawnFlowNode, SubagentFlowNode, } from './patterns/flow.js';
|
|
99
99
|
/** @public */
|
|
100
|
-
export {
|
|
100
|
+
export { FlowSchema, flowDepth, validateFlow, walkFlow } from './patterns/flow.js';
|
|
101
101
|
/** @public */
|
|
102
|
-
export {
|
|
102
|
+
export type { InterviewOpts, InterviewQuestionAnswer, InterviewResult } from './patterns/interview.js';
|
|
103
103
|
/** @public */
|
|
104
|
-
export
|
|
104
|
+
export { interview } from './patterns/interview.js';
|
|
105
105
|
/** @public */
|
|
106
|
-
export type {
|
|
106
|
+
export type { PlanConstraints, PlanNode } from './patterns/plans.js';
|
|
107
107
|
/** @public */
|
|
108
|
-
export {
|
|
108
|
+
export { adaptivePlan, compilePlan, PlanNodeSchema } from './patterns/plans.js';
|
|
109
109
|
/** @public */
|
|
110
|
-
export
|
|
110
|
+
export { ralphWiggum } from './patterns/ralph-wiggum.js';
|
|
111
111
|
/** @public */
|
|
112
|
-
export
|
|
112
|
+
export { react } from './patterns/react.js';
|
|
113
113
|
/** @public */
|
|
114
|
-
export {
|
|
114
|
+
export { AgentHarness } from './harness/agent-harness.js';
|
|
115
115
|
/** @public */
|
|
116
|
-
export type {
|
|
116
|
+
export type { AfterFirstTurnContext, CheckpointStore, CreateCheckpointStoreOptions, CreateNudgeMessageOpts, DetachedSignal, RunnableLoopHarness, RunnableLoopOpts, SessionSeedHarness, StallNudgeOpts, } from './runtime/durable/index.js';
|
|
117
117
|
/** @public */
|
|
118
|
-
export
|
|
118
|
+
export { CheckpointKeys, createCheckpointStore, createDetachedSignal, createNudgeMessage, createStallNudgeHook, DEFAULT_NUDGE_MESSAGE_TEXT, runnableLoop, seedFromItems, } from './runtime/durable/index.js';
|
|
119
119
|
/** @public */
|
|
120
|
-
export
|
|
120
|
+
export { getRegistry, lookupStep, registerStep } from './runtime/step-registry.js';
|
|
121
121
|
/** @public */
|
|
122
|
-
export
|
|
122
|
+
export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from './schemas/item.js';
|
|
123
123
|
/** @public */
|
|
124
|
-
export {
|
|
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
|
|
126
|
+
export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow.js';
|
|
127
127
|
/** @public */
|
|
128
|
-
export type {
|
|
128
|
+
export type { Channel, ChannelHandle, ExternalChannel } from './types/channel.js';
|
|
129
129
|
/** @public */
|
|
130
|
-
export type {
|
|
130
|
+
export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, StepMeta, TokenUsage, } from './types/common.js';
|
|
131
131
|
/** @public */
|
|
132
|
-
export type {
|
|
132
|
+
export type { Tool, ToolMemoryDeclaration } from './types/tool.js';
|
|
133
133
|
/** @public */
|
|
134
|
-
export {
|
|
134
|
+
export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers.js';
|
|
135
135
|
/** @public */
|
|
136
|
-
export type {
|
|
136
|
+
export type { Context, ContextHarness, CwdState, } from './types/context.js';
|
|
137
137
|
/** @public */
|
|
138
|
-
export type {
|
|
138
|
+
export type { ItemLog } from './types/context-parts/item-log.js';
|
|
139
139
|
/** @public */
|
|
140
|
-
export type {
|
|
140
|
+
export type { LastLayerUsage, LayerUsageEntry } from './types/context-parts/layer-usage.js';
|
|
141
141
|
/** @public */
|
|
142
|
-
export {
|
|
142
|
+
export type { DetachedHandle } from './types/detached.js';
|
|
143
143
|
/** @public */
|
|
144
|
-
export
|
|
144
|
+
export { DetachedStatus } from './types/detached.js';
|
|
145
145
|
/** @public */
|
|
146
|
-
export type {
|
|
146
|
+
export type { EmbedFn } from './types/embed.js';
|
|
147
147
|
/** @public */
|
|
148
|
-
export {
|
|
148
|
+
export type { CheckpointSnapshot, CwdSnapshot, FrontierFrame, ItemLogSnapshot, PendingAskUserSnapshot, } from './types/checkpoint.js';
|
|
149
149
|
/** @public */
|
|
150
|
-
export
|
|
150
|
+
export { CheckpointSchemaVersion, CheckpointSnapshotSchema, CwdSnapshotSchema, FrontierFrameSchema, ItemLogSnapshotSchema, PendingAskUserSnapshotSchema, } from './types/checkpoint.js';
|
|
151
151
|
/** @public */
|
|
152
|
-
export {
|
|
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';
|