@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,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Literal schema version stamped on every `CheckpointSnapshot`. Bumped when a
|
|
5
|
+
* backward-incompatible change lands. `restore()` refuses to load snapshots
|
|
6
|
+
* whose version is not recognised and surfaces a typed `NoeticConfigError`
|
|
7
|
+
* (`code === 'CHECKPOINT_SCHEMA_MISMATCH'`) so hosts can discard cleanly.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CheckpointSchemaVersion = 1;
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* One entry in the execution frontier — a pointer to a step currently in
|
|
13
|
+
* flight on the parent's stack, plus the input/state snapshot required to
|
|
14
|
+
* resume it.
|
|
15
|
+
*
|
|
16
|
+
* The frontier is intentionally lenient: frame `state` is treated as an
|
|
17
|
+
* opaque JSON value because step `state` is user-defined. Parse/validate at
|
|
18
|
+
* the call site when specific shape guarantees are needed.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FrontierFrameSchema: z.ZodObject<{
|
|
21
|
+
stepId: z.ZodString;
|
|
22
|
+
input: z.ZodUnknown;
|
|
23
|
+
state: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
/** @public Shape of a single frontier frame serialised inside a snapshot. */
|
|
26
|
+
export type FrontierFrame = z.infer<typeof FrontierFrameSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
* Working-directory snapshot captured at checkpoint time. `current` is the
|
|
30
|
+
* active cwd; `previous` records the last value for parity with
|
|
31
|
+
* `CwdState.previousCwd` which tools use for `cd -`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CwdSnapshotSchema: z.ZodObject<{
|
|
34
|
+
current: z.ZodNullable<z.ZodString>;
|
|
35
|
+
previous: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
/** @public Cwd portion of a checkpoint snapshot. */
|
|
38
|
+
export type CwdSnapshot = z.infer<typeof CwdSnapshotSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* Shape of an ask-user record that was pending at snapshot time. The actual
|
|
42
|
+
* schema is owned by the code-agent `AskUserService`; we only need the outer
|
|
43
|
+
* envelope here so the host can replay the queue into a restarted TUI modal.
|
|
44
|
+
*/
|
|
45
|
+
export declare const PendingAskUserSnapshotSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
input: z.ZodUnknown;
|
|
48
|
+
createdAt: z.ZodNumber;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
/** @public Pending ask-user record captured in a snapshot. */
|
|
51
|
+
export type PendingAskUserSnapshot = z.infer<typeof PendingAskUserSnapshotSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* @public
|
|
54
|
+
* Item log state captured in a snapshot. We store the ordered list of items
|
|
55
|
+
* directly — the `ItemLogImpl` is append-only so the list is its own cursor.
|
|
56
|
+
*
|
|
57
|
+
* Items are carried as `unknown` here and re-parsed on restore via the
|
|
58
|
+
* harness's `ItemSchemaRegistry`, which is the same gate production traffic
|
|
59
|
+
* passes through.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ItemLogSnapshotSchema: z.ZodObject<{
|
|
62
|
+
items: z.ZodArray<z.ZodUnknown>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
/** @public Item log portion of a snapshot. */
|
|
65
|
+
export type ItemLogSnapshot = z.infer<typeof ItemLogSnapshotSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
* Top-level checkpoint payload persisted through a `CheckpointStore`. Carries
|
|
69
|
+
* a schema version so forward-incompatible changes can be rejected cleanly
|
|
70
|
+
* instead of producing a silently corrupt restored context.
|
|
71
|
+
*/
|
|
72
|
+
export declare const CheckpointSnapshotSchema: z.ZodObject<{
|
|
73
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
74
|
+
executionId: z.ZodString;
|
|
75
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
resourceId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
frontier: z.ZodArray<z.ZodObject<{
|
|
78
|
+
stepId: z.ZodString;
|
|
79
|
+
input: z.ZodUnknown;
|
|
80
|
+
state: z.ZodOptional<z.ZodUnknown>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
layers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
83
|
+
cwd: z.ZodNullable<z.ZodObject<{
|
|
84
|
+
current: z.ZodNullable<z.ZodString>;
|
|
85
|
+
previous: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
askUser: z.ZodArray<z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
input: z.ZodUnknown;
|
|
90
|
+
createdAt: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
itemLog: z.ZodObject<{
|
|
93
|
+
items: z.ZodArray<z.ZodUnknown>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
capturedAt: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
/** @public Snapshot of an execution suitable for `CheckpointStore.save()`. */
|
|
98
|
+
export type CheckpointSnapshot = z.infer<typeof CheckpointSnapshotSchema>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
//#region Schema
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* Literal schema version stamped on every `CheckpointSnapshot`. Bumped when a
|
|
6
|
+
* backward-incompatible change lands. `restore()` refuses to load snapshots
|
|
7
|
+
* whose version is not recognised and surfaces a typed `NoeticConfigError`
|
|
8
|
+
* (`code === 'CHECKPOINT_SCHEMA_MISMATCH'`) so hosts can discard cleanly.
|
|
9
|
+
*/
|
|
10
|
+
export const CheckpointSchemaVersion = 1;
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
* One entry in the execution frontier — a pointer to a step currently in
|
|
14
|
+
* flight on the parent's stack, plus the input/state snapshot required to
|
|
15
|
+
* resume it.
|
|
16
|
+
*
|
|
17
|
+
* The frontier is intentionally lenient: frame `state` is treated as an
|
|
18
|
+
* opaque JSON value because step `state` is user-defined. Parse/validate at
|
|
19
|
+
* the call site when specific shape guarantees are needed.
|
|
20
|
+
*/
|
|
21
|
+
export const FrontierFrameSchema = z.object({
|
|
22
|
+
/** Stable id of the step this frame represents. */
|
|
23
|
+
stepId: z.string(),
|
|
24
|
+
/** Serialisable input delivered to the step when it started. */
|
|
25
|
+
input: z.unknown(),
|
|
26
|
+
/** Optional per-frame state snapshot. */
|
|
27
|
+
state: z.unknown().optional(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
* Working-directory snapshot captured at checkpoint time. `current` is the
|
|
32
|
+
* active cwd; `previous` records the last value for parity with
|
|
33
|
+
* `CwdState.previousCwd` which tools use for `cd -`.
|
|
34
|
+
*/
|
|
35
|
+
export const CwdSnapshotSchema = z.object({
|
|
36
|
+
current: z.string().nullable(),
|
|
37
|
+
previous: z.string().nullish(),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* Shape of an ask-user record that was pending at snapshot time. The actual
|
|
42
|
+
* schema is owned by the code-agent `AskUserService`; we only need the outer
|
|
43
|
+
* envelope here so the host can replay the queue into a restarted TUI modal.
|
|
44
|
+
*/
|
|
45
|
+
export const PendingAskUserSnapshotSchema = z.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
input: z.unknown(),
|
|
48
|
+
createdAt: z.number(),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
* Item log state captured in a snapshot. We store the ordered list of items
|
|
53
|
+
* directly — the `ItemLogImpl` is append-only so the list is its own cursor.
|
|
54
|
+
*
|
|
55
|
+
* Items are carried as `unknown` here and re-parsed on restore via the
|
|
56
|
+
* harness's `ItemSchemaRegistry`, which is the same gate production traffic
|
|
57
|
+
* passes through.
|
|
58
|
+
*/
|
|
59
|
+
export const ItemLogSnapshotSchema = z.object({
|
|
60
|
+
items: z.array(z.unknown()),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
* Top-level checkpoint payload persisted through a `CheckpointStore`. Carries
|
|
65
|
+
* a schema version so forward-incompatible changes can be rejected cleanly
|
|
66
|
+
* instead of producing a silently corrupt restored context.
|
|
67
|
+
*/
|
|
68
|
+
export const CheckpointSnapshotSchema = z.object({
|
|
69
|
+
schemaVersion: z.literal(CheckpointSchemaVersion),
|
|
70
|
+
executionId: z.string(),
|
|
71
|
+
threadId: z.string().optional(),
|
|
72
|
+
resourceId: z.string().optional(),
|
|
73
|
+
frontier: z.array(FrontierFrameSchema),
|
|
74
|
+
layers: z.record(z.string(), z.unknown()),
|
|
75
|
+
cwd: CwdSnapshotSchema.nullable(),
|
|
76
|
+
askUser: z.array(PendingAskUserSnapshotSchema),
|
|
77
|
+
itemLog: ItemLogSnapshotSchema,
|
|
78
|
+
/** ISO-8601 timestamp of when the snapshot was taken. */
|
|
79
|
+
capturedAt: z.string(),
|
|
80
|
+
});
|
|
81
|
+
//#endregion
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { FunctionCallItem, FunctionCallOutputItem, Item, ItemSchemaExtensions, ToolResultExtensionItem } from './items';
|
|
3
|
-
import type { ToolExecutionContext } from './tool-context';
|
|
4
|
-
type ToolExecutionResult<O extends ZodTypeAny> = Promise<z.infer<O>> | AsyncGenerator<unknown, z.infer<O>>;
|
|
1
|
+
import type { FunctionCallItem, Item } from './items.js';
|
|
5
2
|
/**
|
|
6
3
|
* Policy controlling automatic retry behavior on step failure.
|
|
7
4
|
* @public
|
|
@@ -30,51 +27,6 @@ export interface ModelParams {
|
|
|
30
27
|
/** Sequences that cause the model to stop generating. */
|
|
31
28
|
stopSequences?: string[];
|
|
32
29
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Declares tool-owned memory that the runtime materializes into a MemoryLayer.
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export interface ToolMemoryDeclaration<TState = unknown> {
|
|
38
|
-
/** Shared id — tools with the same id share state. Defaults to `tool.name`. */
|
|
39
|
-
id?: string;
|
|
40
|
-
/** Factory for the initial state. */
|
|
41
|
-
init: () => TState;
|
|
42
|
-
/** Project state into the LLM context. Return null to omit. */
|
|
43
|
-
recall: (state: TState) => string | null;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A tool definition that an LLM can invoke during execution.
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
export interface Tool<I extends ZodTypeAny = ZodTypeAny, O extends ZodTypeAny = ZodTypeAny> {
|
|
50
|
-
/** Unique tool name used by the LLM for selection. */
|
|
51
|
-
name: string;
|
|
52
|
-
/** Human-readable description shown to the LLM. */
|
|
53
|
-
description: string;
|
|
54
|
-
/** Zod schema validating tool input arguments. */
|
|
55
|
-
input: I;
|
|
56
|
-
/** Zod schema validating tool return value. */
|
|
57
|
-
output: O;
|
|
58
|
-
/** Optional Zod schema validating streaming events yielded during execution. */
|
|
59
|
-
event?: ZodTypeAny;
|
|
60
|
-
/** Optional item schemas contributed by this tool for tool call/result extensions. */
|
|
61
|
-
itemSchemas?: Pick<ItemSchemaExtensions, 'toolCalls' | 'toolResults' | 'items'>;
|
|
62
|
-
/** Decorate the harness-created tool result item before it is appended/emitted. */
|
|
63
|
-
decorateResultItem?(params: {
|
|
64
|
-
baseItem: FunctionCallOutputItem;
|
|
65
|
-
callItem: FunctionCallItem;
|
|
66
|
-
args: z.infer<I>;
|
|
67
|
-
result: z.infer<O> | undefined;
|
|
68
|
-
output: string;
|
|
69
|
-
error?: boolean;
|
|
70
|
-
}): Item | ToolResultExtensionItem;
|
|
71
|
-
/** Async function that performs the tool's work. */
|
|
72
|
-
execute(args: z.infer<I>, toolCtx: ToolExecutionContext): ToolExecutionResult<O>;
|
|
73
|
-
/** When true, execution pauses for human approval before running. */
|
|
74
|
-
needsApproval?: boolean;
|
|
75
|
-
/** Optional memory declaration — the runtime generates a MemoryLayer from this. */
|
|
76
|
-
memory?: ToolMemoryDeclaration;
|
|
77
|
-
}
|
|
78
30
|
/** @public Aggregate token counts for an execution (input, output, total, cached). */
|
|
79
31
|
export interface TokenUsage {
|
|
80
32
|
input: number;
|
|
@@ -108,4 +60,3 @@ export interface LlmProviderConfig {
|
|
|
108
60
|
provider: 'openrouter';
|
|
109
61
|
apiKey?: string;
|
|
110
62
|
}
|
|
111
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Item } from '../items.js';
|
|
2
|
+
/** @public Per-layer contribution to the context window on the most recent LLM call. */
|
|
3
|
+
export interface LayerUsageEntry {
|
|
4
|
+
readonly layerId: string;
|
|
5
|
+
readonly tokenCount: number;
|
|
6
|
+
/** Items this layer contributed to the context view for the last LLM call. */
|
|
7
|
+
readonly items: ReadonlyArray<Item>;
|
|
8
|
+
}
|
|
9
|
+
/** @public Breakdown of the context window as of the most recent LLM call in an execution. */
|
|
10
|
+
export interface LastLayerUsage {
|
|
11
|
+
readonly executionId: string;
|
|
12
|
+
readonly modelId: string;
|
|
13
|
+
readonly layers: ReadonlyArray<LayerUsageEntry>;
|
|
14
|
+
readonly systemPromptTokens: number;
|
|
15
|
+
readonly toolsTokens: number;
|
|
16
|
+
readonly historyTokens: number;
|
|
17
|
+
readonly totalUsedTokens: number;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
import type { ItemSchemaRegistry } from '../schemas/item.js';
|
|
3
|
+
import type { Channel, ChannelHandle, ExternalChannel } from './channel.js';
|
|
4
|
+
import type { LLMResponse, ModelParams, StepMeta, TokenUsage } from './common.js';
|
|
5
|
+
import type { ItemLog } from './context-parts/item-log.js';
|
|
6
|
+
import type { LastLayerUsage } from './context-parts/layer-usage.js';
|
|
7
|
+
import type { DetachedHandle } from './detached.js';
|
|
8
|
+
import type { FsAdapter } from './fs-adapter.js';
|
|
9
|
+
import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
|
|
10
|
+
import type { ExecuteInput } from './items.js';
|
|
11
|
+
import type { ContextMemory, MemoryLayer, StorageAdapter } from './memory.js';
|
|
12
|
+
import type { Span } from './observability.js';
|
|
13
|
+
import type { ShellAdapter } from './shell-adapter.js';
|
|
14
|
+
import type { SteeringDecision } from './steering.js';
|
|
15
|
+
import type { SubprocessAdapter } from './subprocess-adapter.js';
|
|
16
|
+
import type { Tool } from './tool.js';
|
|
16
17
|
/**
|
|
17
18
|
* @public Mutable working-directory state shared among the tools attached to a
|
|
18
19
|
* single Context. The reference is fixed for the Context's lifetime; mutate
|
|
@@ -24,22 +25,129 @@ export interface CwdState {
|
|
|
24
25
|
cwd: string;
|
|
25
26
|
previousCwd?: string;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly
|
|
31
|
-
|
|
32
|
-
readonly
|
|
28
|
+
export type ContextHarnessStatus = {
|
|
29
|
+
readonly kind: 'idle';
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: 'generating';
|
|
32
|
+
readonly startedAt: number;
|
|
33
|
+
readonly turnId: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'aborting';
|
|
36
|
+
readonly turnId: string;
|
|
37
|
+
};
|
|
38
|
+
interface ContextCallModelRequestBase {
|
|
39
|
+
model: string;
|
|
40
|
+
items: ReadonlyArray<import('./items.js').Item>;
|
|
41
|
+
instructions?: string;
|
|
42
|
+
params?: ModelParams;
|
|
43
|
+
outputSchema?: ZodType;
|
|
44
|
+
emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}
|
|
47
|
+
interface ContextCallModelRequestWithTools extends ContextCallModelRequestBase {
|
|
48
|
+
tools: Tool[];
|
|
49
|
+
ctx: Context;
|
|
50
|
+
layers?: MemoryLayer[];
|
|
51
|
+
allowedToolNames?: string[];
|
|
52
|
+
}
|
|
53
|
+
interface ContextCallModelRequestWithoutTools extends ContextCallModelRequestBase {
|
|
54
|
+
tools?: undefined;
|
|
55
|
+
ctx?: undefined;
|
|
56
|
+
layers?: undefined;
|
|
57
|
+
}
|
|
58
|
+
export type ContextCallModelRequest = ContextCallModelRequestWithTools | ContextCallModelRequestWithoutTools;
|
|
59
|
+
export interface ContextDetachedSpawnOverrides {
|
|
60
|
+
threadId?: string;
|
|
61
|
+
resourceId?: string;
|
|
62
|
+
cwdInit?: string;
|
|
33
63
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly
|
|
42
|
-
readonly
|
|
64
|
+
export interface ContextRerenderRequest {
|
|
65
|
+
layerId: string;
|
|
66
|
+
slot: number;
|
|
67
|
+
timing: 'immediate' | 'batched';
|
|
68
|
+
scope: 'self' | 'slot-after' | 'all';
|
|
69
|
+
}
|
|
70
|
+
export interface ContextAppendPipelineResult {
|
|
71
|
+
readonly items: import('./items.js').Item[];
|
|
72
|
+
readonly rerenderRequests: ContextRerenderRequest[];
|
|
73
|
+
}
|
|
74
|
+
export interface ContextRecallLayerOutput {
|
|
75
|
+
layerId: string;
|
|
76
|
+
items: import('./items.js').Item[];
|
|
77
|
+
tokenCount: number;
|
|
78
|
+
}
|
|
79
|
+
export type ContextStep<TMemory = ContextMemory, I = unknown, O = unknown> = {
|
|
80
|
+
readonly kind: 'run';
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly execute: (input: I, ctx: Context<TMemory>) => Promise<O>;
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: 'llm';
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly output?: ZodType<O>;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: 'loop';
|
|
89
|
+
readonly id: string;
|
|
90
|
+
readonly steps: ReadonlyArray<ContextStep<TMemory, I, O>>;
|
|
91
|
+
readonly prepareNext?: (output: O, verdict: unknown, ctx: Context<TMemory>) => I;
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: string;
|
|
94
|
+
readonly id: string;
|
|
95
|
+
};
|
|
96
|
+
/** @public Runtime surface exposed on Context without coupling Context's definition to the runtime type module. */
|
|
97
|
+
export interface ContextHarness {
|
|
98
|
+
readonly config: {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly params: Record<string, unknown>;
|
|
101
|
+
};
|
|
102
|
+
readonly fs: FsAdapter;
|
|
103
|
+
readonly shell: ShellAdapter;
|
|
104
|
+
readonly subprocess: SubprocessAdapter;
|
|
105
|
+
readonly rootCwdState: CwdState;
|
|
106
|
+
callModel(request: ContextCallModelRequest): Promise<LLMResponse>;
|
|
107
|
+
execute(input: ExecuteInput, options?: unknown): Promise<void>;
|
|
108
|
+
getAgentResponse(scope?: unknown): Promise<HarnessResponse>;
|
|
109
|
+
getItemStream(scope?: unknown): AsyncIterable<StreamingItem>;
|
|
110
|
+
getTextStream(scope?: unknown): AsyncIterable<string>;
|
|
111
|
+
getReasoningStream(scope?: unknown): AsyncIterable<string>;
|
|
112
|
+
getFullStream(scope?: unknown): AsyncIterable<StreamEvent>;
|
|
113
|
+
run<I, O>(step: ContextStep<ContextMemory, I, O>, input: I, ctx: Context): Promise<O>;
|
|
114
|
+
detachedSpawn<I, O>(step: unknown, input: I, parentCtx: Context, overrides?: ContextDetachedSpawnOverrides): DetachedHandle<O>;
|
|
115
|
+
createContext(opts?: {
|
|
116
|
+
parent?: Context;
|
|
117
|
+
items?: import('./items.js').Item[];
|
|
118
|
+
state?: unknown;
|
|
119
|
+
threadId?: string;
|
|
120
|
+
resourceId?: string;
|
|
121
|
+
memory?: MemoryLayer[];
|
|
122
|
+
cwdInit?: string;
|
|
123
|
+
}): Context;
|
|
124
|
+
setRootCwd(nextCwd: string): void;
|
|
125
|
+
getLayerState<T>(executionId: string, layerId: string): T | undefined;
|
|
126
|
+
setLayerState<T>(executionId: string, layerId: string, state: T): void;
|
|
127
|
+
beforeToolCall(layers: MemoryLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
|
|
128
|
+
afterModelCall(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
|
|
129
|
+
runAppendPipeline(layers: MemoryLayer[], items: import('./items.js').Item[], ctx: Context): Promise<ContextAppendPipelineResult>;
|
|
130
|
+
recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<ContextRecallLayerOutput[]>;
|
|
131
|
+
projectHistory(layers: MemoryLayer[], items: ReadonlyArray<import('./items.js').Item>, ctx: Context): Promise<ReadonlyArray<import('./items.js').Item>>;
|
|
132
|
+
storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
|
|
133
|
+
previewRequestItems(scope?: unknown): Promise<ReadonlyArray<import('./items.js').Item>>;
|
|
134
|
+
send<T>(channel: Channel<T>, value: T, ctx: Context): void;
|
|
135
|
+
recv<T>(channel: Channel<T>, ctx: Context, opts?: {
|
|
136
|
+
timeout?: number;
|
|
137
|
+
}): Promise<T>;
|
|
138
|
+
tryRecv<T>(channel: Channel<T>, ctx: Context): T | null;
|
|
139
|
+
getChannelHandle<T>(channel: ExternalChannel<T>, executionId: string): ChannelHandle<T>;
|
|
140
|
+
initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
|
|
141
|
+
disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
|
|
142
|
+
checkpoint(ctx: Context): Promise<void>;
|
|
143
|
+
restore(executionId: string): Promise<Context | null>;
|
|
144
|
+
cancel(ctx: Context, reason?: string): Promise<void>;
|
|
145
|
+
createSpan(name: string, parent: Span | null): Span;
|
|
146
|
+
abort(scope?: unknown): Promise<void>;
|
|
147
|
+
getStatus(scope?: unknown): ContextHarnessStatus;
|
|
148
|
+
getQueueSize(scope?: unknown): number;
|
|
149
|
+
seedSessionHistory(threadId: string, items: ReadonlyArray<import('./items.js').Item>): void;
|
|
150
|
+
executeRerender(requests: ContextRerenderRequest[], layers: MemoryLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<ContextRecallLayerOutput[]>;
|
|
43
151
|
}
|
|
44
152
|
/** @public Execution context threaded through every step, carrying state, metrics, and channels. */
|
|
45
153
|
export interface Context<TMemory = ContextMemory, TState = unknown> {
|
|
@@ -58,7 +166,7 @@ export interface Context<TMemory = ContextMemory, TState = unknown> {
|
|
|
58
166
|
readonly lastStepMeta: StepMeta | null;
|
|
59
167
|
/** Per-layer breakdown of the context window as of the most recent callModel. Undefined until the first LLM call completes. */
|
|
60
168
|
readonly lastLayerUsage?: LastLayerUsage;
|
|
61
|
-
readonly harness:
|
|
169
|
+
readonly harness: ContextHarness;
|
|
62
170
|
/** Filesystem adapter for virtual or real filesystem access. */
|
|
63
171
|
readonly fs: FsAdapter;
|
|
64
172
|
/** Shell adapter for virtual or real shell command execution. */
|
|
@@ -91,3 +199,4 @@ export interface Context<TMemory = ContextMemory, TState = unknown> {
|
|
|
91
199
|
readonly abortReason?: string;
|
|
92
200
|
abort(reason?: string): void;
|
|
93
201
|
}
|
|
202
|
+
export {};
|
package/dist/types/error.d.ts
CHANGED
|
@@ -48,4 +48,19 @@ export type NoeticError = {
|
|
|
48
48
|
} | {
|
|
49
49
|
kind: 'steering_denied';
|
|
50
50
|
guidance?: string;
|
|
51
|
+
} | {
|
|
52
|
+
/**
|
|
53
|
+
* Raised by `DetachedHandle.await()` when the adapter persistently
|
|
54
|
+
* returns `null` for a handle that was previously spawned — the
|
|
55
|
+
* handle has been evicted from the adapter's registry, either by
|
|
56
|
+
* a restart-after-stop-without-restore flow or by a storage
|
|
57
|
+
* inconsistency. This guards against an otherwise-infinite poll
|
|
58
|
+
* loop that would hold the promise open forever. A short grace
|
|
59
|
+
* period tolerates transient nulls (e.g. the in-memory adapter
|
|
60
|
+
* briefly returning null between spawn and first microtask yield).
|
|
61
|
+
*/
|
|
62
|
+
kind: 'handle_evicted';
|
|
63
|
+
handleId: string;
|
|
64
|
+
stepId: string;
|
|
65
|
+
gracePeriodMs: number;
|
|
51
66
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LastLayerUsage } from './context';
|
|
2
|
-
import type { Item } from './items';
|
|
1
|
+
import type { LastLayerUsage } from './context-parts/layer-usage.js';
|
|
2
|
+
import type { Item } from './items.js';
|
|
3
3
|
/** @public SDK-originated event from the OpenResponses streaming API. */
|
|
4
4
|
export interface SdkStreamEvent {
|
|
5
5
|
readonly source: 'sdk';
|
package/dist/types/items.d.ts
CHANGED
|
@@ -29,12 +29,28 @@ export interface InputTextPart {
|
|
|
29
29
|
readonly type: 'input_text';
|
|
30
30
|
readonly text: string;
|
|
31
31
|
}
|
|
32
|
+
/** @public User image input content. */
|
|
33
|
+
export interface InputImagePart {
|
|
34
|
+
readonly type: 'input_image';
|
|
35
|
+
readonly imageUrl: string;
|
|
36
|
+
readonly detail?: 'auto' | 'low' | 'high';
|
|
37
|
+
}
|
|
38
|
+
/** @public User file input content. */
|
|
39
|
+
export interface InputFilePart {
|
|
40
|
+
readonly type: 'input_file';
|
|
41
|
+
readonly fileData?: string;
|
|
42
|
+
readonly fileId?: string | null;
|
|
43
|
+
readonly fileUrl?: string;
|
|
44
|
+
readonly filename?: string;
|
|
45
|
+
}
|
|
32
46
|
/** @public Reasoning trace content. */
|
|
33
47
|
export type ReasoningTextPart = ReasoningTextContent;
|
|
34
48
|
/** @public Reasoning summary content. */
|
|
35
49
|
export type SummaryTextPart = ReasoningSummaryText;
|
|
50
|
+
/** @public User/developer input content variants. */
|
|
51
|
+
export type InputContentPart = InputTextPart | InputImagePart | InputFilePart;
|
|
36
52
|
/** @public Content part variants for message items. */
|
|
37
|
-
export type ContentPart = OutputTextPart | RefusalPart |
|
|
53
|
+
export type ContentPart = OutputTextPart | RefusalPart | InputContentPart;
|
|
38
54
|
/** @public Assistant message output item. */
|
|
39
55
|
export type MessageItem = ResponsesOutputMessage;
|
|
40
56
|
/** @public Function call requested by the model. */
|
|
@@ -68,7 +84,7 @@ export interface InputMessageItem {
|
|
|
68
84
|
readonly type: 'message';
|
|
69
85
|
readonly role: 'user' | 'system' | 'developer';
|
|
70
86
|
readonly status: 'in_progress' | 'completed' | 'incomplete' | 'failed';
|
|
71
|
-
readonly content:
|
|
87
|
+
readonly content: InputContentPart[];
|
|
72
88
|
}
|
|
73
89
|
/**
|
|
74
90
|
* @public Tool execution output created by the harness during the tool loop.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { LLMResponse } from './common.js';
|
|
2
|
+
import type { FsAdapter } from './fs-adapter.js';
|
|
3
|
+
import type { Item } from './items.js';
|
|
4
|
+
import type { ShellAdapter } from './shell-adapter.js';
|
|
5
|
+
/** @public Isolation scope controlling how a memory layer's state is keyed and shared. */
|
|
6
|
+
export type MemoryScope = 'thread' | 'resource' | 'global' | 'execution';
|
|
7
|
+
/** @public Terminal outcome of an execution run, reported to memory layers on completion. */
|
|
8
|
+
export type ExecutionOutcome = 'success' | 'failure' | 'aborted';
|
|
9
|
+
/** @public Minimal model-call surface exposed to memory-layer hooks. */
|
|
10
|
+
export interface MemoryCallModelRequest {
|
|
11
|
+
model: string;
|
|
12
|
+
items: ReadonlyArray<Item>;
|
|
13
|
+
instructions?: string;
|
|
14
|
+
}
|
|
15
|
+
/** @public Runtime metadata available to memory layer hooks during each lifecycle phase. */
|
|
16
|
+
export interface ExecutionContext {
|
|
17
|
+
executionId: string;
|
|
18
|
+
threadId: string;
|
|
19
|
+
resourceId?: string;
|
|
20
|
+
depth: number;
|
|
21
|
+
stepNumber: number;
|
|
22
|
+
tokenUsage: {
|
|
23
|
+
input: number;
|
|
24
|
+
output: number;
|
|
25
|
+
};
|
|
26
|
+
cost: number;
|
|
27
|
+
/** Filesystem adapter for virtual or real filesystem access. */
|
|
28
|
+
fs: FsAdapter;
|
|
29
|
+
/** Shell adapter for virtual or real shell command execution. */
|
|
30
|
+
shell: ShellAdapter;
|
|
31
|
+
callModel?: (request: MemoryCallModelRequest) => Promise<LLMResponse>;
|
|
32
|
+
tokenize(text: string): number;
|
|
33
|
+
trace: {
|
|
34
|
+
setAttribute(key: string, value: string | number | boolean): void;
|
|
35
|
+
addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
36
|
+
};
|
|
37
|
+
/** Snapshot a sibling memory layer's state by its `layer.id`. */
|
|
38
|
+
readLayerState<T>(layerId: string): T | undefined;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|