@earendil-works/pi-agent-core 0.84.3 → 0.85.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.
- package/README.md +4 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +32 -25
- package/dist/agent-loop.js.map +1 -1
- package/dist/harness/agent-harness.d.ts +639 -384
- package/dist/harness/agent-harness.d.ts.map +1 -1
- package/dist/harness/agent-harness.js +5 -251
- package/dist/harness/agent-harness.js.map +1 -1
- package/dist/harness/compaction/branch-summarization.d.ts +12 -6
- package/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/harness/compaction/branch-summarization.js +33 -26
- package/dist/harness/compaction/branch-summarization.js.map +1 -1
- package/dist/harness/compaction/compaction.d.ts +30 -8
- package/dist/harness/compaction/compaction.d.ts.map +1 -1
- package/dist/harness/compaction/compaction.js +53 -63
- package/dist/harness/compaction/compaction.js.map +1 -1
- package/dist/harness/config.d.ts +9 -0
- package/dist/harness/config.d.ts.map +1 -0
- package/dist/harness/config.js +27 -0
- package/dist/harness/config.js.map +1 -0
- package/dist/harness/context.d.ts +9 -0
- package/dist/harness/context.d.ts.map +1 -0
- package/dist/harness/context.js +13 -0
- package/dist/harness/context.js.map +1 -0
- package/dist/harness/env/nodejs.d.ts +24 -28
- package/dist/harness/env/nodejs.d.ts.map +1 -1
- package/dist/harness/env/nodejs.js +242 -87
- package/dist/harness/env/nodejs.js.map +1 -1
- package/dist/harness/events.d.ts +20 -38
- package/dist/harness/events.d.ts.map +1 -1
- package/dist/harness/events.js +240 -55
- package/dist/harness/events.js.map +1 -1
- package/dist/harness/execution/assistant.d.ts +42 -0
- package/dist/harness/execution/assistant.d.ts.map +1 -0
- package/dist/harness/execution/assistant.js +82 -0
- package/dist/harness/execution/assistant.js.map +1 -0
- package/dist/harness/execution/effect-gate.d.ts +22 -0
- package/dist/harness/execution/effect-gate.d.ts.map +1 -0
- package/dist/harness/execution/effect-gate.js +49 -0
- package/dist/harness/execution/effect-gate.js.map +1 -0
- package/dist/harness/execution/tools.d.ts +67 -0
- package/dist/harness/execution/tools.d.ts.map +1 -0
- package/dist/harness/execution/tools.js +121 -0
- package/dist/harness/execution/tools.js.map +1 -0
- package/dist/harness/hooks.d.ts +38 -0
- package/dist/harness/hooks.d.ts.map +1 -0
- package/dist/harness/hooks.js +406 -0
- package/dist/harness/hooks.js.map +1 -0
- package/dist/harness/messages.d.ts +2 -2
- package/dist/harness/messages.d.ts.map +1 -1
- package/dist/harness/messages.js.map +1 -1
- package/dist/harness/prompt-templates.d.ts +3 -2
- package/dist/harness/prompt-templates.d.ts.map +1 -1
- package/dist/harness/prompt-templates.js +17 -17
- package/dist/harness/prompt-templates.js.map +1 -1
- package/dist/harness/result.d.ts +93 -0
- package/dist/harness/result.d.ts.map +1 -1
- package/dist/harness/result.js +40 -0
- package/dist/harness/result.js.map +1 -1
- package/dist/harness/runtime/drive/boundary.d.ts +28 -0
- package/dist/harness/runtime/drive/boundary.d.ts.map +1 -0
- package/dist/harness/runtime/drive/boundary.js +170 -0
- package/dist/harness/runtime/drive/boundary.js.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts +8 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.js +133 -0
- package/dist/harness/runtime/drive/checkpoint.js.map +1 -0
- package/dist/harness/runtime/drive/deferred.d.ts +15 -0
- package/dist/harness/runtime/drive/deferred.d.ts.map +1 -0
- package/dist/harness/runtime/drive/deferred.js +179 -0
- package/dist/harness/runtime/drive/deferred.js.map +1 -0
- package/dist/harness/runtime/drive/generation.d.ts +8 -0
- package/dist/harness/runtime/drive/generation.d.ts.map +1 -0
- package/dist/harness/runtime/drive/generation.js +205 -0
- package/dist/harness/runtime/drive/generation.js.map +1 -0
- package/dist/harness/runtime/drive/reconcile.d.ts +5 -0
- package/dist/harness/runtime/drive/reconcile.d.ts.map +1 -0
- package/dist/harness/runtime/drive/reconcile.js +140 -0
- package/dist/harness/runtime/drive/reconcile.js.map +1 -0
- package/dist/harness/runtime/drive/recovery.d.ts +8 -0
- package/dist/harness/runtime/drive/recovery.d.ts.map +1 -0
- package/dist/harness/runtime/drive/recovery.js +85 -0
- package/dist/harness/runtime/drive/recovery.js.map +1 -0
- package/dist/harness/runtime/drive/response.d.ts +23 -0
- package/dist/harness/runtime/drive/response.d.ts.map +1 -0
- package/dist/harness/runtime/drive/response.js +394 -0
- package/dist/harness/runtime/drive/response.js.map +1 -0
- package/dist/harness/runtime/drive/retry.d.ts +4 -0
- package/dist/harness/runtime/drive/retry.d.ts.map +1 -0
- package/dist/harness/runtime/drive/retry.js +37 -0
- package/dist/harness/runtime/drive/retry.js.map +1 -0
- package/dist/harness/runtime/drive/structural.d.ts +32 -0
- package/dist/harness/runtime/drive/structural.d.ts.map +1 -0
- package/dist/harness/runtime/drive/structural.js +929 -0
- package/dist/harness/runtime/drive/structural.js.map +1 -0
- package/dist/harness/runtime/drive/terminal.d.ts +7 -0
- package/dist/harness/runtime/drive/terminal.d.ts.map +1 -0
- package/dist/harness/runtime/drive/terminal.js +49 -0
- package/dist/harness/runtime/drive/terminal.js.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts +14 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.js +244 -0
- package/dist/harness/runtime/drive/tool-placement.js.map +1 -0
- package/dist/harness/runtime/drive/tools.d.ts +6 -0
- package/dist/harness/runtime/drive/tools.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tools.js +449 -0
- package/dist/harness/runtime/drive/tools.js.map +1 -0
- package/dist/harness/runtime/drive.d.ts +6 -0
- package/dist/harness/runtime/drive.d.ts.map +1 -0
- package/dist/harness/runtime/drive.js +93 -0
- package/dist/harness/runtime/drive.js.map +1 -0
- package/dist/harness/runtime/harness.d.ts +59 -0
- package/dist/harness/runtime/harness.d.ts.map +1 -0
- package/dist/harness/runtime/harness.js +311 -0
- package/dist/harness/runtime/harness.js.map +1 -0
- package/dist/harness/runtime/index.d.ts +2 -0
- package/dist/harness/runtime/index.d.ts.map +1 -0
- package/dist/harness/runtime/index.js +2 -0
- package/dist/harness/runtime/index.js.map +1 -0
- package/dist/harness/runtime/lane.d.ts +101 -0
- package/dist/harness/runtime/lane.d.ts.map +1 -0
- package/dist/harness/runtime/lane.js +1575 -0
- package/dist/harness/runtime/lane.js.map +1 -0
- package/dist/harness/runtime/progress.d.ts +15 -0
- package/dist/harness/runtime/progress.d.ts.map +1 -0
- package/dist/harness/runtime/progress.js +66 -0
- package/dist/harness/runtime/progress.js.map +1 -0
- package/dist/harness/runtime/reducer.d.ts +5 -0
- package/dist/harness/runtime/reducer.d.ts.map +1 -0
- package/dist/harness/runtime/reducer.js +240 -0
- package/dist/harness/runtime/reducer.js.map +1 -0
- package/dist/harness/runtime/restore.d.ts +24 -0
- package/dist/harness/runtime/restore.d.ts.map +1 -0
- package/dist/harness/runtime/restore.js +117 -0
- package/dist/harness/runtime/restore.js.map +1 -0
- package/dist/harness/runtime/transcript.d.ts +21 -0
- package/dist/harness/runtime/transcript.d.ts.map +1 -0
- package/dist/harness/runtime/transcript.js +72 -0
- package/dist/harness/runtime/transcript.js.map +1 -0
- package/dist/harness/runtime/types.d.ts +105 -0
- package/dist/harness/runtime/types.d.ts.map +1 -0
- package/dist/harness/runtime/types.js +61 -0
- package/dist/harness/runtime/types.js.map +1 -0
- package/dist/harness/session/commit.d.ts +53 -0
- package/dist/harness/session/commit.d.ts.map +1 -0
- package/dist/harness/session/commit.js +57 -0
- package/dist/harness/session/commit.js.map +1 -0
- package/dist/harness/session/context.d.ts +6 -18
- package/dist/harness/session/context.d.ts.map +1 -1
- package/dist/harness/session/context.js +31 -49
- package/dist/harness/session/context.js.map +1 -1
- package/dist/harness/session/fork-policy.d.ts +13 -0
- package/dist/harness/session/fork-policy.d.ts.map +1 -0
- package/dist/harness/session/fork-policy.js +22 -0
- package/dist/harness/session/fork-policy.js.map +1 -0
- package/dist/harness/session/fork.d.ts +18 -0
- package/dist/harness/session/fork.d.ts.map +1 -0
- package/dist/harness/session/fork.js +127 -0
- package/dist/harness/session/fork.js.map +1 -0
- package/dist/harness/session/in-memory-storage-state.d.ts +39 -0
- package/dist/harness/session/in-memory-storage-state.d.ts.map +1 -0
- package/dist/harness/session/in-memory-storage-state.js +216 -0
- package/dist/harness/session/in-memory-storage-state.js.map +1 -0
- package/dist/harness/session/index.d.ts +9 -5
- package/dist/harness/session/index.d.ts.map +1 -1
- package/dist/harness/session/index.js +7 -4
- package/dist/harness/session/index.js.map +1 -1
- package/dist/harness/session/jsonl/codec.d.ts +19 -8
- package/dist/harness/session/jsonl/codec.d.ts.map +1 -1
- package/dist/harness/session/jsonl/codec.js +34 -218
- package/dist/harness/session/jsonl/codec.js.map +1 -1
- package/dist/harness/session/jsonl/index.d.ts +4 -0
- package/dist/harness/session/jsonl/index.d.ts.map +1 -0
- package/dist/harness/session/jsonl/index.js +4 -0
- package/dist/harness/session/jsonl/index.js.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts +18 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.js +383 -0
- package/dist/harness/session/jsonl/legacy-v3.js.map +1 -0
- package/dist/harness/session/jsonl/repo.d.ts +26 -19
- package/dist/harness/session/jsonl/repo.d.ts.map +1 -1
- package/dist/harness/session/jsonl/repo.js +266 -156
- package/dist/harness/session/jsonl/repo.js.map +1 -1
- package/dist/harness/session/jsonl/storage.d.ts +39 -41
- package/dist/harness/session/jsonl/storage.d.ts.map +1 -1
- package/dist/harness/session/jsonl/storage.js +238 -181
- package/dist/harness/session/jsonl/storage.js.map +1 -1
- package/dist/harness/session/jsonl/types.d.ts +23 -22
- package/dist/harness/session/jsonl/types.d.ts.map +1 -1
- package/dist/harness/session/jsonl/types.js +2 -1
- package/dist/harness/session/jsonl/types.js.map +1 -1
- package/dist/harness/session/memory.d.ts +46 -40
- package/dist/harness/session/memory.d.ts.map +1 -1
- package/dist/harness/session/memory.js +346 -113
- package/dist/harness/session/memory.js.map +1 -1
- package/dist/harness/session/mutation-line.d.ts +8 -0
- package/dist/harness/session/mutation-line.d.ts.map +1 -0
- package/dist/harness/session/mutation-line.js +21 -0
- package/dist/harness/session/mutation-line.js.map +1 -0
- package/dist/harness/session/session.d.ts +78 -46
- package/dist/harness/session/session.d.ts.map +1 -1
- package/dist/harness/session/session.js +343 -209
- package/dist/harness/session/session.js.map +1 -1
- package/dist/harness/session/testing/benchmark/datasets.d.ts +12 -0
- package/dist/harness/session/testing/benchmark/datasets.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/datasets.js +24 -0
- package/dist/harness/session/testing/benchmark/datasets.js.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts +42 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.js +127 -0
- package/dist/harness/session/testing/benchmark/session-repo.js.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts +25 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.js +114 -0
- package/dist/harness/session/testing/benchmark/storage.js.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts +21 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.js +590 -0
- package/dist/harness/session/testing/conformance/session-repo.js.map +1 -0
- package/dist/harness/session/testing/conformance/storage.d.ts +4 -0
- package/dist/harness/session/testing/conformance/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/storage.js +600 -0
- package/dist/harness/session/testing/conformance/storage.js.map +1 -0
- package/dist/harness/session/testing/gating-storage.d.ts +26 -0
- package/dist/harness/session/testing/gating-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/gating-storage.js +100 -0
- package/dist/harness/session/testing/gating-storage.js.map +1 -0
- package/dist/harness/session/testing/index.d.ts +9 -2
- package/dist/harness/session/testing/index.d.ts.map +1 -1
- package/dist/harness/session/testing/index.js +8 -1
- package/dist/harness/session/testing/index.js.map +1 -1
- package/dist/harness/session/testing/instrumented-storage.d.ts +11 -0
- package/dist/harness/session/testing/instrumented-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/instrumented-storage.js +16 -0
- package/dist/harness/session/testing/instrumented-storage.js.map +1 -0
- package/dist/harness/session/testing/storage-decorator.d.ts +20 -0
- package/dist/harness/session/testing/storage-decorator.d.ts.map +1 -0
- package/dist/harness/session/testing/storage-decorator.js +41 -0
- package/dist/harness/session/testing/storage-decorator.js.map +1 -0
- package/dist/harness/session/testing/types.d.ts +5 -7
- package/dist/harness/session/testing/types.d.ts.map +1 -1
- package/dist/harness/session/testing/types.js.map +1 -1
- package/dist/harness/session/types.d.ts +424 -259
- package/dist/harness/session/types.d.ts.map +1 -1
- package/dist/harness/session/types.js +7 -8
- package/dist/harness/session/types.js.map +1 -1
- package/dist/harness/session/values.d.ts +95 -0
- package/dist/harness/session/values.d.ts.map +1 -0
- package/dist/harness/session/values.js +81 -0
- package/dist/harness/session/values.js.map +1 -0
- package/dist/harness/skills.d.ts +3 -2
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +29 -26
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/telemetry.d.ts +64 -43
- package/dist/harness/telemetry.d.ts.map +1 -1
- package/dist/harness/telemetry.js +45 -26
- package/dist/harness/telemetry.js.map +1 -1
- package/dist/harness/tools/bash.d.ts +4 -4
- package/dist/harness/tools/bash.d.ts.map +1 -1
- package/dist/harness/tools/bash.js +66 -93
- package/dist/harness/tools/bash.js.map +1 -1
- package/dist/harness/tools/edit.d.ts.map +1 -1
- package/dist/harness/tools/edit.js +10 -10
- package/dist/harness/tools/edit.js.map +1 -1
- package/dist/harness/tools/file-mutation-queue.d.ts +2 -1
- package/dist/harness/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/harness/tools/file-mutation-queue.js +5 -5
- package/dist/harness/tools/file-mutation-queue.js.map +1 -1
- package/dist/harness/tools/path-utils.d.ts +3 -2
- package/dist/harness/tools/path-utils.d.ts.map +1 -1
- package/dist/harness/tools/path-utils.js +5 -5
- package/dist/harness/tools/path-utils.js.map +1 -1
- package/dist/harness/tools/read.d.ts +2 -1
- package/dist/harness/tools/read.d.ts.map +1 -1
- package/dist/harness/tools/read.js +4 -6
- package/dist/harness/tools/read.js.map +1 -1
- package/dist/harness/tools/write.d.ts.map +1 -1
- package/dist/harness/tools/write.js +7 -7
- package/dist/harness/tools/write.js.map +1 -1
- package/dist/harness/types.d.ts +108 -45
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/utils/adaptive-publisher.d.ts +24 -0
- package/dist/harness/utils/adaptive-publisher.d.ts.map +1 -0
- package/dist/harness/utils/adaptive-publisher.js +79 -0
- package/dist/harness/utils/adaptive-publisher.js.map +1 -0
- package/dist/harness/utils/output-capture.d.ts +31 -0
- package/dist/harness/utils/output-capture.d.ts.map +1 -0
- package/dist/harness/utils/output-capture.js +217 -0
- package/dist/harness/utils/output-capture.js.map +1 -0
- package/dist/harness/utils/shell-output.d.ts +12 -5
- package/dist/harness/utils/shell-output.d.ts.map +1 -1
- package/dist/harness/utils/shell-output.js +64 -174
- package/dist/harness/utils/shell-output.js.map +1 -1
- package/dist/harness/utils/truncate.d.ts +1 -0
- package/dist/harness/utils/truncate.d.ts.map +1 -1
- package/dist/harness/utils/truncate.js +1 -1
- package/dist/harness/utils/truncate.js.map +1 -1
- package/dist/harness/utils/usage.d.ts +4 -0
- package/dist/harness/utils/usage.d.ts.map +1 -0
- package/dist/harness/utils/usage.js +33 -0
- package/dist/harness/utils/usage.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/proxy.d.ts +2 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +40 -10
- package/dist/proxy.js.map +1 -1
- package/dist/search/index.d.ts +24 -16
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/index.js.map +1 -1
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +25 -4
- package/dist/harness/reducer.d.ts +0 -100
- package/dist/harness/reducer.d.ts.map +0 -1
- package/dist/harness/reducer.js +0 -415
- package/dist/harness/reducer.js.map +0 -1
- package/dist/harness/session/jsonl/errors.d.ts +0 -9
- package/dist/harness/session/jsonl/errors.d.ts.map +0 -1
- package/dist/harness/session/jsonl/errors.js +0 -19
- package/dist/harness/session/jsonl/errors.js.map +0 -1
- package/dist/harness/session/jsonl.d.ts +0 -3
- package/dist/harness/session/jsonl.d.ts.map +0 -1
- package/dist/harness/session/jsonl.js +0 -2
- package/dist/harness/session/jsonl.js.map +0 -1
- package/dist/harness/session/state.d.ts +0 -65
- package/dist/harness/session/state.d.ts.map +0 -1
- package/dist/harness/session/state.js +0 -319
- package/dist/harness/session/state.js.map +0 -1
- package/dist/harness/session/testing/conformance.d.ts +0 -4
- package/dist/harness/session/testing/conformance.d.ts.map +0 -1
- package/dist/harness/session/testing/conformance.js +0 -762
- package/dist/harness/session/testing/conformance.js.map +0 -1
- package/dist/search/scanning.d.ts +0 -29
- package/dist/search/scanning.d.ts.map +0 -1
- package/dist/search/scanning.js +0 -103
- package/dist/search/scanning.js.map +0 -1
|
@@ -1,346 +1,511 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import "
|
|
3
|
-
import type { AgentMessage } from "../../types.ts";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { AssistantMessage, StopReason, Usage } from "@earendil-works/pi-ai";
|
|
3
|
+
import type { AgentMessage, QueueMode, ThinkingLevel } from "../../types.ts";
|
|
4
|
+
import type { BranchPreparation } from "../compaction/branch-summarization.ts";
|
|
5
|
+
import type { CompactionPreparation, CompactionSettings } from "../compaction/compaction.ts";
|
|
6
|
+
import type { Context } from "../context.ts";
|
|
7
|
+
import type { AgentHarnessStreamOptions } from "../types.ts";
|
|
8
|
+
import type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from "./values.ts";
|
|
9
|
+
export type { JsonValue } from "@earendil-works/chord";
|
|
10
|
+
export type SettledAssistantMessage = AssistantMessage & {
|
|
11
|
+
stopReason: Exclude<StopReason, "pending">;
|
|
7
12
|
};
|
|
8
|
-
export type
|
|
9
|
-
export interface IdGenerator {
|
|
10
|
-
next(): string;
|
|
11
|
-
}
|
|
13
|
+
export type EntryType = "message" | "compaction" | "branch_summary" | "custom";
|
|
12
14
|
export interface EntryBase {
|
|
13
|
-
type: string;
|
|
14
15
|
id: string;
|
|
15
|
-
seq: number;
|
|
16
16
|
parentId: string | null;
|
|
17
|
+
seq: number;
|
|
17
18
|
timestamp: number;
|
|
19
|
+
type: EntryType;
|
|
20
|
+
customType?: string;
|
|
18
21
|
}
|
|
19
22
|
export interface MessageEntry extends EntryBase {
|
|
20
23
|
type: "message";
|
|
21
24
|
message: AgentMessage;
|
|
22
25
|
terminate?: true;
|
|
23
26
|
}
|
|
24
|
-
export interface ModelChangeEntry extends EntryBase {
|
|
25
|
-
type: "model_change";
|
|
26
|
-
provider: string;
|
|
27
|
-
modelId: string;
|
|
28
|
-
}
|
|
29
|
-
export interface ThinkingLevelEntry extends EntryBase {
|
|
30
|
-
type: "thinking_level_change";
|
|
31
|
-
thinkingLevel: string;
|
|
32
|
-
}
|
|
33
|
-
export interface ActiveToolsEntry extends EntryBase {
|
|
34
|
-
type: "active_tools_change";
|
|
35
|
-
activeToolNames: string[];
|
|
36
|
-
}
|
|
37
27
|
export interface CompactionEntry extends EntryBase {
|
|
38
28
|
type: "compaction";
|
|
39
29
|
summary: string;
|
|
40
30
|
retainedTail: AgentMessage[];
|
|
41
31
|
tokensBefore: number;
|
|
42
|
-
details?:
|
|
32
|
+
details?: JsonValue;
|
|
43
33
|
usage?: Usage;
|
|
34
|
+
fromHook: boolean;
|
|
44
35
|
}
|
|
45
36
|
export interface BranchSummaryEntry extends EntryBase {
|
|
46
37
|
type: "branch_summary";
|
|
47
|
-
fromId: string;
|
|
38
|
+
fromId: string | null;
|
|
48
39
|
summary: string;
|
|
49
|
-
details?:
|
|
40
|
+
details?: JsonValue;
|
|
50
41
|
usage?: Usage;
|
|
42
|
+
fromHook: boolean;
|
|
51
43
|
}
|
|
52
44
|
export interface CustomEntry extends EntryBase {
|
|
53
45
|
type: "custom";
|
|
54
46
|
customType: string;
|
|
55
|
-
data?:
|
|
47
|
+
data?: JsonValue;
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
export type
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
/** Convert an application-defined custom entry into model context. */
|
|
50
|
+
export type EntryProjector = (entry: CustomEntry, context: Context) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;
|
|
51
|
+
export type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;
|
|
52
|
+
/** Entry supplied to a transaction before storage assigns sequence and timestamp. */
|
|
53
|
+
export type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, "seq" | "timestamp"> : never;
|
|
54
|
+
export interface LaneConfiguration {
|
|
55
|
+
model: {
|
|
56
|
+
provider: string;
|
|
57
|
+
modelId: string;
|
|
58
|
+
};
|
|
59
|
+
thinkingLevel: ThinkingLevel;
|
|
60
|
+
activeToolNames: string[];
|
|
64
61
|
}
|
|
65
|
-
export interface
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
export interface OperationMeta {
|
|
63
|
+
operationId: string;
|
|
64
|
+
lane: string;
|
|
65
|
+
sourceTipId: string | null;
|
|
66
|
+
startedAt: number;
|
|
68
67
|
intent: {
|
|
69
68
|
kind: "run";
|
|
70
|
-
|
|
71
|
-
originalPrompt: AgentMessage[];
|
|
72
|
-
/** Captured nextRun items, then the prompt, then before_run injections. */
|
|
73
|
-
initialMessages: ProvisionedEntry[];
|
|
74
|
-
systemPromptOverride?: string;
|
|
75
|
-
resumeData?: {
|
|
76
|
-
[extensionId: string]: JsonValue;
|
|
77
|
-
};
|
|
69
|
+
promptEntryIds: string[];
|
|
78
70
|
} | {
|
|
79
71
|
kind: "compaction";
|
|
80
72
|
customInstructions?: string;
|
|
81
|
-
resultEntryId: string;
|
|
82
73
|
} | {
|
|
83
74
|
kind: "navigation";
|
|
84
75
|
targetId: string | null;
|
|
85
76
|
summarize: boolean;
|
|
86
|
-
customInstructions?: string;
|
|
87
77
|
label?: string;
|
|
88
|
-
|
|
78
|
+
customInstructions?: string;
|
|
89
79
|
};
|
|
90
80
|
}
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
message: string;
|
|
102
|
-
};
|
|
81
|
+
export type Control = {
|
|
82
|
+
status: "running";
|
|
83
|
+
} | {
|
|
84
|
+
status: "cancel_requested";
|
|
85
|
+
requestedAt: number;
|
|
86
|
+
};
|
|
87
|
+
export interface OperationError {
|
|
88
|
+
code: string;
|
|
89
|
+
message: string;
|
|
90
|
+
details?: JsonValue;
|
|
103
91
|
}
|
|
104
|
-
export type
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
export type TerminalStatus = "completed" | "declined" | "aborted" | "failed";
|
|
93
|
+
/** Immutable lane-lived observation record written by one terminal transaction. */
|
|
94
|
+
export interface OperationResultRecord {
|
|
95
|
+
operationId: string;
|
|
96
|
+
kind: OperationMeta["intent"]["kind"];
|
|
97
|
+
status: TerminalStatus;
|
|
98
|
+
error?: OperationError;
|
|
99
|
+
fromTipId: string | null;
|
|
100
|
+
tipId: string | null;
|
|
101
|
+
startedAt: number;
|
|
102
|
+
endedAt: number;
|
|
103
|
+
}
|
|
104
|
+
export type Continuation = {
|
|
105
|
+
kind: "need_assistant";
|
|
106
|
+
overflowRecoveryUsed: boolean;
|
|
112
107
|
} | {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
kind: "may_finish";
|
|
109
|
+
includeFinalAssistant: boolean;
|
|
110
|
+
};
|
|
111
|
+
/** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */
|
|
112
|
+
export interface CheckpointData {
|
|
113
|
+
continuation: Continuation;
|
|
114
|
+
triggerEntryId: string;
|
|
115
|
+
}
|
|
116
|
+
export type InboxItemKind = "steer" | "followUp" | "nextRun" | "write";
|
|
117
|
+
export interface InboxItem {
|
|
118
|
+
entryId: string;
|
|
119
|
+
kind: InboxItemKind;
|
|
120
|
+
}
|
|
121
|
+
export interface NormalizedRetryPolicy {
|
|
122
|
+
maxAttempts: number;
|
|
123
|
+
baseDelayMs: number;
|
|
124
|
+
}
|
|
125
|
+
export interface GenerationContext {
|
|
126
|
+
stepId: string;
|
|
127
|
+
triggerEntryId: string;
|
|
128
|
+
configuration: LaneConfiguration;
|
|
129
|
+
streamOptions: AgentHarnessStreamOptions;
|
|
130
|
+
retryPolicy: NormalizedRetryPolicy;
|
|
131
|
+
overflowRecoveryUsed: boolean;
|
|
132
|
+
}
|
|
133
|
+
interface ToolCallSource {
|
|
134
|
+
/** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */
|
|
135
|
+
sourceIndex: number;
|
|
117
136
|
resultEntryId: string;
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
}
|
|
138
|
+
export type ToolCall = ToolCallSource & ({
|
|
139
|
+
status: "planned";
|
|
140
|
+
} | {
|
|
141
|
+
status: "effect_pending";
|
|
142
|
+
replay: "never" | "safe";
|
|
143
|
+
} | {
|
|
144
|
+
status: "outcome_ready";
|
|
145
|
+
terminate: boolean;
|
|
146
|
+
} | {
|
|
147
|
+
status: "completed";
|
|
148
|
+
terminate: boolean;
|
|
120
149
|
});
|
|
121
|
-
export interface
|
|
122
|
-
type: "tool_started";
|
|
123
|
-
runId: string;
|
|
150
|
+
export interface ToolBatch {
|
|
124
151
|
assistantEntryId: string;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
152
|
+
configuration: LaneConfiguration;
|
|
153
|
+
turnId: string;
|
|
154
|
+
calls: ToolCall[];
|
|
155
|
+
}
|
|
156
|
+
export interface SummaryContext {
|
|
131
157
|
resultEntryId: string;
|
|
132
|
-
|
|
158
|
+
configuration: LaneConfiguration;
|
|
159
|
+
streamOptions: AgentHarnessStreamOptions;
|
|
160
|
+
retryPolicy: NormalizedRetryPolicy;
|
|
161
|
+
}
|
|
162
|
+
export interface Cancellable {
|
|
163
|
+
control: Control;
|
|
164
|
+
}
|
|
165
|
+
export interface RunSettings {
|
|
166
|
+
compaction: CompactionSettings;
|
|
167
|
+
steeringMode: QueueMode;
|
|
168
|
+
followUpMode: QueueMode;
|
|
169
|
+
toolExecution: "sequential" | "parallel";
|
|
133
170
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
171
|
+
/** Uniform scope carried by every operation leaf. */
|
|
172
|
+
export interface OperationScope extends Cancellable {
|
|
173
|
+
settings: RunSettings;
|
|
174
|
+
latestAssistantEntryId: string | null;
|
|
175
|
+
}
|
|
176
|
+
/** Shared backoff data for every retry-wait leaf. */
|
|
177
|
+
export interface RetryWait {
|
|
178
|
+
nextAttempt: number;
|
|
179
|
+
notBefore: number;
|
|
180
|
+
errorMessage: string;
|
|
181
|
+
}
|
|
182
|
+
export interface AssistantGenerationScope {
|
|
183
|
+
generationContext: GenerationContext;
|
|
184
|
+
}
|
|
185
|
+
export type ResultBoundary = {
|
|
186
|
+
kind: "resume_checkpoint";
|
|
187
|
+
resumeAfter: CheckpointData;
|
|
139
188
|
} | {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
189
|
+
kind: "finish";
|
|
190
|
+
} | {
|
|
191
|
+
kind: "commit_navigation";
|
|
192
|
+
targetId: string;
|
|
193
|
+
label?: string;
|
|
194
|
+
};
|
|
195
|
+
export interface SummaryTask {
|
|
196
|
+
taskId: string;
|
|
197
|
+
reason?: "manual" | "threshold" | "overflow";
|
|
198
|
+
customInstructions?: string;
|
|
199
|
+
boundary: ResultBoundary;
|
|
149
200
|
}
|
|
150
|
-
export interface
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
target: ProvisionedEntry;
|
|
201
|
+
export interface SummaryGenerationScope {
|
|
202
|
+
task: SummaryTask;
|
|
203
|
+
summaryContext: SummaryContext;
|
|
154
204
|
}
|
|
155
|
-
export
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
cause: "assistant" | "compaction" | "branch_summary" | "deferred_fetch";
|
|
160
|
-
runId: string;
|
|
161
|
-
entryId: string;
|
|
205
|
+
export interface SummaryGenerationReady extends SummaryGenerationScope {
|
|
206
|
+
nextAttempt: number;
|
|
207
|
+
}
|
|
208
|
+
export interface SummaryGenerationEffectPending extends SummaryGenerationScope {
|
|
162
209
|
attempt: number;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
210
|
+
request?: {
|
|
211
|
+
index: number;
|
|
212
|
+
usageId: string;
|
|
213
|
+
};
|
|
214
|
+
usageIds: string[];
|
|
215
|
+
}
|
|
216
|
+
export interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {
|
|
217
|
+
}
|
|
218
|
+
export interface DeferredScope extends OperationScope {
|
|
219
|
+
stepId: string;
|
|
220
|
+
sourceEntryId: string;
|
|
221
|
+
poll: number;
|
|
222
|
+
configuration: LaneConfiguration;
|
|
223
|
+
streamOptions: AgentHarnessStreamOptions;
|
|
224
|
+
}
|
|
225
|
+
export interface StartingOperation extends OperationScope {
|
|
226
|
+
at: "starting";
|
|
227
|
+
}
|
|
228
|
+
export interface CheckpointOperation extends OperationScope, CheckpointData {
|
|
229
|
+
at: "checkpoint";
|
|
230
|
+
}
|
|
231
|
+
export interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {
|
|
232
|
+
at: "assistant.ready";
|
|
233
|
+
nextAttempt: number;
|
|
234
|
+
}
|
|
235
|
+
export interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {
|
|
236
|
+
at: "assistant.effect_pending";
|
|
237
|
+
attempt: number;
|
|
238
|
+
responseEntryId: string;
|
|
239
|
+
usageId: string;
|
|
240
|
+
intendedOutputLimit: number;
|
|
241
|
+
contextWindow: number;
|
|
242
|
+
}
|
|
243
|
+
export interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {
|
|
244
|
+
at: "assistant.retry_wait";
|
|
245
|
+
}
|
|
246
|
+
export interface ToolsOperation extends OperationScope {
|
|
247
|
+
at: "tools";
|
|
248
|
+
batch: ToolBatch;
|
|
249
|
+
}
|
|
250
|
+
export interface DeferredSuspendedOperation extends DeferredScope {
|
|
251
|
+
at: "deferred.suspended";
|
|
252
|
+
}
|
|
253
|
+
export interface DeferredEffectPendingOperation extends DeferredScope {
|
|
254
|
+
at: "deferred.effect_pending";
|
|
255
|
+
responseEntryId: string;
|
|
256
|
+
usageId: string;
|
|
257
|
+
}
|
|
258
|
+
export interface SummaryDecidingOperation extends OperationScope {
|
|
259
|
+
at: "summary.deciding";
|
|
260
|
+
task: SummaryTask;
|
|
261
|
+
}
|
|
262
|
+
export interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {
|
|
263
|
+
at: "summary.ready";
|
|
264
|
+
}
|
|
265
|
+
export interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {
|
|
266
|
+
at: "summary.effect_pending";
|
|
267
|
+
}
|
|
268
|
+
export interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {
|
|
269
|
+
at: "summary.retry_wait";
|
|
270
|
+
}
|
|
271
|
+
export interface NavigationReadyToCommitOperation extends OperationScope {
|
|
272
|
+
at: "navigation.ready_to_commit";
|
|
273
|
+
/** Unsummarized navigation may target the branch root (null). */
|
|
274
|
+
targetId: string | null;
|
|
275
|
+
label?: string;
|
|
276
|
+
}
|
|
277
|
+
/** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */
|
|
278
|
+
export type OperationState = StartingOperation | CheckpointOperation | AssistantReadyOperation | AssistantEffectPendingOperation | AssistantRetryWaitOperation | ToolsOperation | DeferredSuspendedOperation | DeferredEffectPendingOperation | SummaryDecidingOperation | SummaryReadyOperation | SummaryEffectPendingOperation | SummaryRetryWaitOperation | NavigationReadyToCommitOperation;
|
|
279
|
+
export type OperationAt = OperationState["at"];
|
|
280
|
+
/** Copy only the uniform operation scope when constructing a successor leaf. */
|
|
281
|
+
export declare function operationScopeOf(state: OperationState): OperationScope;
|
|
282
|
+
export type Operation = {
|
|
283
|
+
meta: OperationMeta;
|
|
284
|
+
state: OperationState;
|
|
285
|
+
};
|
|
286
|
+
export interface LaneState {
|
|
287
|
+
currentOperationId: string | null;
|
|
288
|
+
lastOperationId: string | null;
|
|
289
|
+
inbox: InboxItem[];
|
|
290
|
+
}
|
|
291
|
+
export type PendingEntry = {
|
|
292
|
+
type: "message";
|
|
293
|
+
payload: AgentMessage;
|
|
169
294
|
} | {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
295
|
+
type: "custom";
|
|
296
|
+
customType: string;
|
|
297
|
+
payload?: JsonValue;
|
|
298
|
+
};
|
|
299
|
+
export interface DurableFileOperations {
|
|
300
|
+
read: string[];
|
|
301
|
+
written: string[];
|
|
302
|
+
edited: string[];
|
|
303
|
+
}
|
|
304
|
+
export type DurableStructuralPreparation = {
|
|
305
|
+
kind: "compaction";
|
|
306
|
+
messagesToSummarize: CompactionPreparation["messagesToSummarize"];
|
|
307
|
+
turnPrefixMessages: CompactionPreparation["turnPrefixMessages"];
|
|
308
|
+
retainedTail: CompactionPreparation["retainedTail"];
|
|
309
|
+
isSplitTurn: boolean;
|
|
310
|
+
tokensBefore: number;
|
|
311
|
+
previousSummary?: string;
|
|
312
|
+
fileOps: DurableFileOperations;
|
|
313
|
+
settings: CompactionSettings;
|
|
173
314
|
} | {
|
|
174
|
-
|
|
175
|
-
|
|
315
|
+
kind: "branch_summary";
|
|
316
|
+
messages: BranchPreparation["messages"];
|
|
317
|
+
fileOps: DurableFileOperations;
|
|
318
|
+
totalTokens: number;
|
|
319
|
+
};
|
|
320
|
+
export interface UsageRow {
|
|
321
|
+
id: string;
|
|
322
|
+
seq: number;
|
|
323
|
+
usage: Usage;
|
|
176
324
|
entryId?: string;
|
|
325
|
+
adjustment: boolean;
|
|
177
326
|
details?: JsonValue;
|
|
178
|
-
}
|
|
179
|
-
export
|
|
180
|
-
|
|
181
|
-
|
|
327
|
+
}
|
|
328
|
+
export interface EntryWrite {
|
|
329
|
+
kind: "entry";
|
|
330
|
+
entry: NewEntry;
|
|
331
|
+
}
|
|
332
|
+
export interface UsageWrite {
|
|
333
|
+
kind: "usage";
|
|
334
|
+
row: Omit<UsageRow, "seq">;
|
|
335
|
+
}
|
|
336
|
+
export type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;
|
|
337
|
+
export interface CommitResult {
|
|
338
|
+
firstSeq: number;
|
|
339
|
+
seqs: number[];
|
|
340
|
+
timestamp: number;
|
|
341
|
+
/** Session totals immediately after this commit was applied. */
|
|
342
|
+
stats: SessionStats;
|
|
343
|
+
}
|
|
344
|
+
export interface EntryStructure {
|
|
345
|
+
id: string;
|
|
346
|
+
parentId: string | null;
|
|
347
|
+
seq: number;
|
|
348
|
+
timestamp: number;
|
|
349
|
+
type: EntryType;
|
|
350
|
+
customType?: string;
|
|
351
|
+
}
|
|
182
352
|
export interface EntryCursor {
|
|
183
|
-
|
|
353
|
+
seq: number;
|
|
184
354
|
}
|
|
185
|
-
export interface
|
|
186
|
-
|
|
355
|
+
export interface BranchScan {
|
|
356
|
+
start?: string;
|
|
357
|
+
stopAtType?: EntryType;
|
|
358
|
+
stopAtId?: string;
|
|
359
|
+
type?: EntryType;
|
|
187
360
|
customType?: string;
|
|
188
|
-
order?:
|
|
361
|
+
order?: "newestFirst" | "oldestFirst";
|
|
189
362
|
limit?: number;
|
|
190
363
|
cursor?: EntryCursor;
|
|
191
364
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
365
|
+
export type StorageBranchScan = BranchScan & {
|
|
366
|
+
start: string;
|
|
367
|
+
};
|
|
368
|
+
export interface EntryScan {
|
|
369
|
+
type?: EntryType;
|
|
370
|
+
customType?: string;
|
|
371
|
+
fromSeq?: number;
|
|
372
|
+
toSeq?: number;
|
|
373
|
+
order?: "asc" | "desc";
|
|
374
|
+
limit?: number;
|
|
197
375
|
}
|
|
198
|
-
export interface
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
type?: LaneRecord["type"];
|
|
203
|
-
/**
|
|
204
|
-
* Operation identity. Matches OperationStartedRecord.id and the runId
|
|
205
|
-
* property of operation-owned records. Records without an operation
|
|
206
|
-
* identity do not match.
|
|
207
|
-
*/
|
|
208
|
-
runId?: string;
|
|
209
|
-
/** Exact operation intent kind. Valid only with type "operation_started". */
|
|
210
|
-
operationKind?: OperationStartedRecord["intent"]["kind"];
|
|
211
|
-
/** Exclusive chronological lower bound: seq > afterSeq, regardless of order. */
|
|
212
|
-
afterSeq?: number;
|
|
213
|
-
/** Sequence order. Default: "newestFirst". */
|
|
214
|
-
order?: EntryOrder;
|
|
215
|
-
/** Positive maximum number of matching records. */
|
|
376
|
+
export interface UsageScan {
|
|
377
|
+
fromSeq?: number;
|
|
378
|
+
toSeq?: number;
|
|
379
|
+
order?: "asc" | "desc";
|
|
216
380
|
limit?: number;
|
|
217
381
|
}
|
|
382
|
+
export interface SessionStats {
|
|
383
|
+
messageCount: number;
|
|
384
|
+
usage: Usage;
|
|
385
|
+
}
|
|
386
|
+
export interface Storage {
|
|
387
|
+
commit(writes: Write[], context: Context): Promise<CommitResult>;
|
|
388
|
+
getEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;
|
|
389
|
+
getValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;
|
|
390
|
+
scanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;
|
|
391
|
+
readList<T>(address: ValueList<T>, options: ListReadOptions | undefined, context: Context): Promise<ListElement<T>[]>;
|
|
392
|
+
scanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;
|
|
393
|
+
scanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;
|
|
394
|
+
scanEntries(query: EntryScan, context: Context): Promise<Entry[]>;
|
|
395
|
+
scanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;
|
|
396
|
+
getStats(context: Context): Promise<SessionStats>;
|
|
397
|
+
close(context: Context): Promise<void>;
|
|
398
|
+
}
|
|
218
399
|
export interface SessionMetadata {
|
|
219
400
|
id: string;
|
|
220
401
|
createdAt: number;
|
|
402
|
+
storageVersion: number;
|
|
403
|
+
cwd?: string;
|
|
221
404
|
parentSessionId?: string;
|
|
405
|
+
legacyParentSessionPath?: string;
|
|
222
406
|
}
|
|
223
|
-
export interface
|
|
224
|
-
|
|
225
|
-
cachedTokens: number;
|
|
226
|
-
uncachedTokens: number;
|
|
227
|
-
totalTokens: number;
|
|
228
|
-
costTotal: number;
|
|
229
|
-
}
|
|
230
|
-
export interface LanePointer {
|
|
231
|
-
lane: string;
|
|
232
|
-
leafId: string | null;
|
|
407
|
+
export interface IdGenerator {
|
|
408
|
+
next(timestampMs?: number): string;
|
|
233
409
|
}
|
|
234
|
-
export
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} | {
|
|
239
|
-
kind: "record";
|
|
240
|
-
seq: number;
|
|
241
|
-
record: LaneRecord;
|
|
242
|
-
} | {
|
|
243
|
-
kind: "lane";
|
|
244
|
-
seq: number;
|
|
245
|
-
lane: string;
|
|
246
|
-
leafId: string | null;
|
|
247
|
-
} | {
|
|
248
|
-
kind: "fact";
|
|
249
|
-
seq: number;
|
|
250
|
-
fact: "name";
|
|
251
|
-
name: string | undefined;
|
|
252
|
-
} | {
|
|
253
|
-
kind: "fact";
|
|
254
|
-
seq: number;
|
|
255
|
-
fact: "label";
|
|
256
|
-
targetId: string;
|
|
257
|
-
label: string | undefined;
|
|
258
|
-
};
|
|
259
|
-
export interface LogOptions {
|
|
260
|
-
afterSeq?: number;
|
|
410
|
+
export interface EntryQuery {
|
|
411
|
+
type?: EntryType;
|
|
412
|
+
customType?: string;
|
|
413
|
+
order?: "asc" | "desc";
|
|
261
414
|
limit?: number;
|
|
415
|
+
cursor?: EntryCursor;
|
|
416
|
+
}
|
|
417
|
+
export interface SessionReader {
|
|
418
|
+
getEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;
|
|
419
|
+
getStats(context: Context): Promise<SessionStats>;
|
|
420
|
+
getValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;
|
|
421
|
+
scanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;
|
|
422
|
+
readList<T>(address: ValueList<T>, options: ListReadOptions | undefined, context: Context): Promise<ListElement<T>[]>;
|
|
423
|
+
/** Scan a branch from an explicit entry while this reader capability remains valid. */
|
|
424
|
+
scanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;
|
|
425
|
+
}
|
|
426
|
+
/** Exclusive keyless mutation barrier for one Session. */
|
|
427
|
+
export interface SessionMutation extends SessionReader {
|
|
428
|
+
/** Exactly zero or one commit attempt. A second attempt rejects. */
|
|
429
|
+
commit(writes: Write[], context: Context): Promise<CommitResult>;
|
|
430
|
+
/** Wait for any commit attempt, invalidate the capability, and release the barrier. */
|
|
431
|
+
end(context: Context): Promise<void>;
|
|
262
432
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
433
|
+
/** Callback-scoped mutation capability without authority to release its Session barrier. */
|
|
434
|
+
export type SessionMutator = Omit<SessionMutation, "end">;
|
|
435
|
+
export type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;
|
|
436
|
+
export interface Branch {
|
|
437
|
+
readonly name: string;
|
|
438
|
+
getTipId(context: Context): Promise<string | null>;
|
|
439
|
+
findEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;
|
|
440
|
+
findEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;
|
|
441
|
+
appendMessage(message: AgentMessage, context: Context): Promise<string>;
|
|
442
|
+
appendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;
|
|
443
|
+
}
|
|
444
|
+
export interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {
|
|
445
|
+
readonly metadata: TMetadata;
|
|
446
|
+
readonly idGenerator: IdGenerator;
|
|
447
|
+
getEntry(id: string, context: Context): Promise<Entry | undefined>;
|
|
448
|
+
getStats(context: Context): Promise<SessionStats>;
|
|
449
|
+
getName(context: Context): Promise<string | undefined>;
|
|
450
|
+
getLabel(targetId: string, context: Context): Promise<string | undefined>;
|
|
451
|
+
findEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;
|
|
452
|
+
findEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;
|
|
453
|
+
branch(name: string, context: Context): Promise<Branch | undefined>;
|
|
454
|
+
createBranch(name: string, at: string | null, context: Context): Promise<Branch>;
|
|
455
|
+
beginMutation(context: Context): Promise<SessionMutation>;
|
|
285
456
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* results provide no additional recovery state.
|
|
457
|
+
* Trusted exclusive callback over the Session mutation line. Calling a public Session writer from
|
|
458
|
+
* this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.
|
|
459
|
+
* Use the supplied mutator for the callback's sole commit.
|
|
290
460
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
setName(name: string | undefined): Promise<void>;
|
|
300
|
-
getLabel(id: string): Promise<string | undefined>;
|
|
301
|
-
setLabel(id: string, label: string | undefined): Promise<void>;
|
|
302
|
-
getStats(): Promise<SessionStats>;
|
|
303
|
-
}
|
|
304
|
-
export interface SessionTree {
|
|
305
|
-
getLeafId(): Promise<string | null>;
|
|
306
|
-
getEntry(id: string): Promise<Entry | undefined>;
|
|
307
|
-
getStats(): Promise<SessionStats>;
|
|
308
|
-
getName(): Promise<string | undefined>;
|
|
309
|
-
setName(name: string | undefined): Promise<void>;
|
|
310
|
-
getLabel(targetId: string): Promise<string | undefined>;
|
|
311
|
-
setLabel(targetId: string, label: string | undefined): Promise<void>;
|
|
312
|
-
/** Session-wide, all branches, sequence order. */
|
|
313
|
-
findEntries(query?: EntryQuery): Promise<Entry[]>;
|
|
314
|
-
findEntry(query?: EntryQuery): Promise<Entry | undefined>;
|
|
315
|
-
/** Branch-scoped: the path from start toward root. */
|
|
316
|
-
findEntriesOnBranch(query?: EntryQuery & BranchBounds): Promise<Entry[]>;
|
|
317
|
-
findEntryOnBranch(query?: EntryQuery & BranchBounds): Promise<Entry | undefined>;
|
|
318
|
-
appendMessage(message: AgentMessage): Promise<string>;
|
|
319
|
-
appendCustomEntry(customType: string, data?: unknown): Promise<string>;
|
|
461
|
+
mutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;
|
|
462
|
+
setValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;
|
|
463
|
+
deleteValue<T>(address: Value<T>, context: Context): Promise<void>;
|
|
464
|
+
appendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;
|
|
465
|
+
deleteList<T>(address: ValueList<T>, context: Context): Promise<void>;
|
|
466
|
+
setName(name: string | undefined, context: Context): Promise<void>;
|
|
467
|
+
setLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;
|
|
468
|
+
close(context: Context): Promise<void>;
|
|
320
469
|
}
|
|
321
470
|
export interface SessionCreateOptions {
|
|
322
471
|
id?: string;
|
|
323
472
|
parentSessionId?: string;
|
|
324
473
|
}
|
|
325
474
|
export type ForkOptions = {
|
|
326
|
-
|
|
475
|
+
/**
|
|
476
|
+
* Copy one path from a complete configured source AgentLane under the same
|
|
477
|
+
* Branch name, with copied configuration and fresh idle lane state.
|
|
478
|
+
*/
|
|
479
|
+
scope: "branch";
|
|
480
|
+
/** Source Branch to copy. */
|
|
481
|
+
branch: string;
|
|
482
|
+
/** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */
|
|
327
483
|
entryId?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Whether the fork includes the selected entry or stops at its parent.
|
|
486
|
+
* Defaults to including the selected entry.
|
|
487
|
+
*/
|
|
328
488
|
position?: "before" | "at";
|
|
489
|
+
/** Optional destination session id. */
|
|
490
|
+
id?: string;
|
|
329
491
|
} | {
|
|
492
|
+
/**
|
|
493
|
+
* Copy the whole conversation tree and every Branch tip. Each configured
|
|
494
|
+
* AgentLane copies configuration plus fresh idle state; data-only Branches
|
|
495
|
+
* remain data-only. Operation/pending/result/usage state is excluded.
|
|
496
|
+
*/
|
|
330
497
|
scope: "tree";
|
|
498
|
+
/** Optional destination session id. */
|
|
499
|
+
id?: string;
|
|
331
500
|
};
|
|
332
|
-
export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
export type SessionErrorCode = "not_found" | "already_exists" | "invalid_entry" | "invalid_payload" | "invalid_lane" | "invalid_query" | "invalid_fork_target" | "storage";
|
|
342
|
-
export declare class SessionError extends Error {
|
|
343
|
-
readonly code: SessionErrorCode;
|
|
344
|
-
constructor(code: SessionErrorCode, message: string, cause?: Error);
|
|
501
|
+
export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends {
|
|
502
|
+
id?: string;
|
|
503
|
+
parentSessionId?: string;
|
|
504
|
+
} = SessionCreateOptions, TListOptions = void> {
|
|
505
|
+
create(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;
|
|
506
|
+
open(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;
|
|
507
|
+
list(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;
|
|
508
|
+
delete(metadata: TMetadata, context: Context): Promise<void>;
|
|
509
|
+
fork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;
|
|
345
510
|
}
|
|
346
511
|
//# sourceMappingURL=types.d.ts.map
|