@e4779/pi-fabric 0.92.41-fork.6 → 0.96.4-fork.10
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/LAWS.bend +502 -0
- package/PROOF.bend +452 -0
- package/README.md +5 -1
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/dist/agents/handoff.d.ts +2 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +2 -0
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents.js +6 -5
- package/dist/agents.js.map +1 -1
- package/dist/chunks/{chunk-3TXOQ5MG.js → chunk-3CJETB4S.js} +828 -204
- package/dist/chunks/chunk-3CJETB4S.js.map +7 -0
- package/dist/chunks/{chunk-IUCVOZRX.js → chunk-3SIXBW6A.js} +2 -2
- package/dist/chunks/chunk-4E63LJDD.js +468 -0
- package/dist/chunks/chunk-4E63LJDD.js.map +7 -0
- package/dist/chunks/{chunk-AAHHYDTO.js → chunk-4NF3S3NM.js} +1 -1
- package/dist/chunks/{chunk-AAHHYDTO.js.map → chunk-4NF3S3NM.js.map} +2 -2
- package/dist/chunks/{chunk-2SWRVIYJ.js → chunk-754HA6KO.js} +2 -2
- package/dist/chunks/{chunk-K6DHXXF5.js → chunk-B2IVWASP.js} +2 -2
- package/dist/chunks/{chunk-ZDNGXLEC.js → chunk-B4HECUJI.js} +2 -2
- package/dist/chunks/{chunk-H6DDV6E2.js → chunk-CSJSHBAT.js} +5 -5
- package/dist/chunks/{chunk-MW5VI7IW.js → chunk-D4B4CCTA.js} +2 -2
- package/dist/chunks/{chunk-EDL4JDW7.js → chunk-EBWMC3OO.js} +2 -2
- package/dist/chunks/{chunk-4NUTVNS2.js → chunk-F72MAIQY.js} +31 -368
- package/dist/chunks/chunk-F72MAIQY.js.map +7 -0
- package/dist/chunks/{chunk-W3FRE4VI.js → chunk-FDIEQEXS.js} +2 -2
- package/dist/chunks/{chunk-7A6NVHB5.js → chunk-FJSHRHOR.js} +7 -4
- package/dist/chunks/chunk-FJSHRHOR.js.map +7 -0
- package/dist/chunks/{chunk-PSNXUZMY.js → chunk-G2F2RDZI.js} +5 -47
- package/dist/chunks/chunk-G2F2RDZI.js.map +7 -0
- package/dist/chunks/{chunk-3WIGAX56.js → chunk-JCV54SSP.js} +2 -2
- package/dist/chunks/chunk-KS44WKJJ.js +51 -0
- package/dist/chunks/chunk-KS44WKJJ.js.map +7 -0
- package/dist/chunks/{chunk-3H7SDWZI.js → chunk-LNLQ2LX3.js} +22 -1
- package/dist/chunks/chunk-LNLQ2LX3.js.map +7 -0
- package/dist/chunks/{chunk-G4LADAYY.js → chunk-OINADFEF.js} +8 -3
- package/dist/chunks/chunk-OINADFEF.js.map +7 -0
- package/dist/chunks/{chunk-UQ4LTUH4.js → chunk-OUAC6O5C.js} +36 -9
- package/dist/chunks/chunk-OUAC6O5C.js.map +7 -0
- package/dist/chunks/{chunk-MQG5QKGI.js → chunk-Q5BMTL6A.js} +217 -95
- package/dist/chunks/chunk-Q5BMTL6A.js.map +7 -0
- package/dist/chunks/{chunk-IK6PPFWG.js → chunk-QFKHAAZA.js} +11 -11
- package/dist/chunks/chunk-QFKHAAZA.js.map +7 -0
- package/dist/chunks/{chunk-RTXZHKMS.js → chunk-QNMQJNXE.js} +7 -3
- package/dist/chunks/chunk-QNMQJNXE.js.map +7 -0
- package/dist/chunks/{chunk-U5FYOMG5.js → chunk-UBPFGMDQ.js} +6 -2
- package/dist/chunks/chunk-UBPFGMDQ.js.map +7 -0
- package/dist/chunks/{chunk-FLKGJPCN.js → chunk-ULQFHZJE.js} +4 -1
- package/dist/chunks/chunk-ULQFHZJE.js.map +7 -0
- package/dist/chunks/{chunk-7VAZ4N43.js → chunk-V3PIO7QL.js} +2 -2
- package/dist/chunks/{chunk-MGDLRV2R.js → chunk-VQGO4P7C.js} +2 -2
- package/dist/chunks/{chunk-XT4346N7.js → chunk-WXSELMFV.js} +9 -3
- package/dist/chunks/chunk-WXSELMFV.js.map +7 -0
- package/dist/chunks/{chunk-D5WKZONW.js → chunk-X3IRR7CV.js} +2 -2
- package/dist/chunks/{chunk-IJL3QK3J.js → chunk-Y57UHPIK.js} +1 -1
- package/dist/chunks/{chunk-IJL3QK3J.js.map → chunk-Y57UHPIK.js.map} +1 -1
- package/dist/chunks/{chunk-RKRVOBVO.js → chunk-YC3QQDZ3.js} +2 -2
- package/dist/chunks/{chunk-Q4XJ4PYL.js → chunk-ZRI433JP.js} +299 -83
- package/dist/chunks/chunk-ZRI433JP.js.map +7 -0
- package/dist/chunks/{chunk-36B4AIRT.js → chunk-ZTXZ6JDO.js} +2 -2
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/bounds.d.ts +4 -0
- package/dist/compaction/bounds.d.ts.map +1 -1
- package/dist/compaction/branch-summary.d.ts.map +1 -1
- package/dist/compaction/dialogue.d.ts +24 -0
- package/dist/compaction/dialogue.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +6 -2
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +6 -5
- package/dist/compaction/instructions.d.ts +1 -0
- package/dist/compaction/instructions.d.ts.map +1 -1
- package/dist/compaction/projections.d.ts +3 -3
- package/dist/compaction/projections.d.ts.map +1 -1
- package/dist/compaction/qa.d.ts.map +1 -1
- package/dist/compaction/render.d.ts +11 -0
- package/dist/compaction/render.d.ts.map +1 -1
- package/dist/components/configuration.js +2 -3
- package/dist/components/effect-policy.d.ts +2 -0
- package/dist/components/effect-policy.d.ts.map +1 -1
- package/dist/components/effect-scope.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +14 -2
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +7 -5
- package/dist/core/provider-bindings.d.ts +8 -2
- package/dist/core/provider-bindings.d.ts.map +1 -1
- package/dist/core/provider-operations.d.ts +28 -0
- package/dist/core/provider-operations.d.ts.map +1 -0
- package/dist/core/provider-operations.js +201 -0
- package/dist/core/provider-operations.js.map +7 -0
- package/dist/core/shell-inbox.d.ts +13 -0
- package/dist/core/shell-inbox.d.ts.map +1 -0
- package/dist/core/shell-jobs.d.ts +51 -7
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/shell-limits.d.ts +3 -0
- package/dist/core/shell-limits.d.ts.map +1 -0
- package/dist/core/shell-monitor.d.ts +51 -0
- package/dist/core/shell-monitor.d.ts.map +1 -0
- package/dist/entropy/index.js +8 -7
- package/dist/entropy/normal-form.d.ts.map +1 -1
- package/dist/execution-service.d.ts +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +1124 -325
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/index.js +155 -44
- package/dist/index.js.map +3 -3
- package/dist/jev/observation.js +5 -3
- package/dist/jev.d.ts +0 -1
- package/dist/jev.d.ts.map +1 -1
- package/dist/jev.js +9 -13
- package/dist/memory/digest.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -1
- package/dist/memory/discovery.js +6 -5
- package/dist/memory/expand-service.d.ts.map +1 -1
- package/dist/memory/file-worker.js +9 -8
- package/dist/memory/file-worker.js.map +1 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/normalize.d.ts.map +1 -1
- package/dist/memory/normalize.js +5 -4
- package/dist/memory/search.js +7 -6
- package/dist/memory/worker-provider.js +10 -9
- package/dist/memory.js +9 -8
- package/dist/memory.js.map +1 -1
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/prewalk/handoff.d.ts +1 -1
- package/dist/prewalk/handoff.d.ts.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/jev-provider.d.ts +1 -1
- package/dist/providers/jev-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +9 -7
- package/dist/providers/memory-provider.js +9 -8
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/tasks-provider.d.ts +12 -0
- package/dist/providers/tasks-provider.d.ts.map +1 -0
- package/dist/residency/host.js +10 -9
- package/dist/residency/pi-entry.js +10 -9
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +1 -2
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/typescript-kernel.js +2 -2
- package/dist/runtime-state-builtins.d.ts +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/schema/controller.d.ts.map +1 -1
- package/dist/state/store.d.ts.map +1 -1
- package/dist/ui/controller.d.ts +1 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-targets.js +2 -2
- package/dist/ui/conversation.js +7 -7
- package/dist/ui/dashboard.js +9 -9
- package/dist/ui/highlight.d.ts.map +1 -1
- package/dist/ui/languages/bend.d.ts +4 -0
- package/dist/ui/languages/bend.d.ts.map +1 -0
- package/dist/ui/languages/bend.js +73 -0
- package/dist/ui/languages/bend.js.map +7 -0
- package/dist/ui/settings.js +1 -2
- package/dist/ui/settings.js.map +1 -1
- package/dist/ui/shell-hang-keys.d.ts.map +1 -1
- package/dist/ui/shell-tasks.d.ts +22 -0
- package/dist/ui/shell-tasks.d.ts.map +1 -0
- package/dist/ui/shell-tasks.js +161 -0
- package/dist/ui/shell-tasks.js.map +7 -0
- package/dist/ui/shiki-catalog.d.ts +2 -1
- package/dist/ui/shiki-catalog.d.ts.map +1 -1
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/types.d.ts +1 -0
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/verified/authority.d.ts +17 -0
- package/dist/verified/authority.d.ts.map +1 -0
- package/dist/verified/generated/authority-kernel.d.ts +10 -0
- package/dist/verified/generated/authority-kernel.js +116 -0
- package/dist/verified/generated/kernel.d.ts +31 -0
- package/dist/verified/generated/kernel.js +351 -0
- package/dist/verified/generated/lifecycle-kernel.d.ts +7 -0
- package/dist/verified/generated/lifecycle-kernel.js +155 -0
- package/dist/verified/generated/manifest.json +54 -0
- package/dist/verified/generated/provider-kernel.d.ts +9 -0
- package/dist/verified/generated/provider-kernel.js +80 -0
- package/dist/verified/generated/storage-kernel.d.ts +11 -0
- package/dist/verified/generated/storage-kernel.js +98 -0
- package/dist/verified/memory.d.ts +11 -0
- package/dist/verified/memory.d.ts.map +1 -0
- package/dist/verified/nat.d.ts +2 -0
- package/dist/verified/nat.d.ts.map +1 -0
- package/dist/verified/policy.d.ts +37 -0
- package/dist/verified/policy.d.ts.map +1 -0
- package/dist/verified/resources.d.ts +14 -0
- package/dist/verified/resources.d.ts.map +1 -0
- package/dist/verified/storage.d.ts +32 -0
- package/dist/verified/storage.d.ts.map +1 -0
- package/dist/worker/event-projection.d.ts +6 -0
- package/dist/worker/event-projection.d.ts.map +1 -0
- package/dist/worker/event-projection.js +99 -0
- package/dist/worker/event-projection.js.map +7 -0
- package/dist/worker/recovery-watchdog.d.ts +12 -0
- package/dist/worker/recovery-watchdog.d.ts.map +1 -0
- package/dist/worker/recovery-watchdog.js +41 -0
- package/dist/worker/recovery-watchdog.js.map +7 -0
- package/dist/worker.js +80 -22
- package/dist/worker.js.map +2 -2
- package/docs/agents.md +26 -14
- package/docs/architecture.md +1 -1
- package/docs/background-tasks.md +140 -0
- package/docs/compaction.md +91 -28
- package/docs/components.md +5 -1
- package/docs/configuration.md +6 -6
- package/docs/foreman.md +4 -4
- package/docs/harnesses.md +95 -0
- package/docs/interface.md +7 -0
- package/docs/jev.md +59 -52
- package/docs/kernels.md +2 -2
- package/docs/licenses/bend-apache-2.0.txt +202 -0
- package/docs/memory-recall.md +1 -1
- package/docs/programmatic-compaction.md +13 -2
- package/docs/provider-capabilities.md +197 -0
- package/docs/shell-middleware.md +3 -3
- package/docs/skills.md +1 -1
- package/docs/verified-kernels.md +278 -0
- package/package.json +14 -4
- package/proofs/abi.json +308 -0
- package/proofs/authority-abi.json +7 -0
- package/proofs/authority-kernel.bend +23 -0
- package/proofs/authority-proof.bend +74 -0
- package/proofs/authority-spec.bend +30 -0
- package/proofs/authority-state.bend +43 -0
- package/proofs/authority-types.d.ts +3 -0
- package/proofs/kernel.bend +139 -0
- package/proofs/lifecycle-abi.json +3 -0
- package/proofs/lifecycle-kernel.bend +11 -0
- package/proofs/lifecycle-proof.bend +249 -0
- package/proofs/lifecycle-spec.bend +261 -0
- package/proofs/lifecycle-types.d.ts +4 -0
- package/proofs/lifecycle.bend +119 -0
- package/proofs/provider-abi.json +4 -0
- package/proofs/provider-kernel.bend +14 -0
- package/proofs/provider-plans.bend +28 -0
- package/proofs/provider-spec.bend +14 -0
- package/proofs/provider-types.d.ts +5 -0
- package/proofs/resource-proof.bend +633 -0
- package/proofs/resource-spec.bend +133 -0
- package/proofs/resources.bend +160 -0
- package/proofs/state-kernel.bend +17 -0
- package/proofs/state-plans.bend +40 -0
- package/proofs/state-proof.bend +42 -0
- package/proofs/state-spec.bend +26 -0
- package/proofs/storage-abi.json +3 -0
- package/proofs/storage-kernel.bend +11 -0
- package/proofs/storage-plans.bend +100 -0
- package/proofs/storage-proof.bend +176 -0
- package/proofs/storage-spec.bend +70 -0
- package/proofs/storage-types.d.ts +8 -0
- package/proofs/types.d.ts +7 -0
- package/scripts/test-verified-kernels.mjs +107 -0
- package/scripts/verified-kernels.mjs +136 -0
- package/skillsets/python/fabric-jev/SKILL.md +13 -9
- package/skillsets/typescript/fabric-exec/SKILL.md +4 -2
- package/skillsets/typescript/fabric-jev/SKILL.md +13 -9
- package/dist/chunks/chunk-3H7SDWZI.js.map +0 -7
- package/dist/chunks/chunk-3TXOQ5MG.js.map +0 -7
- package/dist/chunks/chunk-4NUTVNS2.js.map +0 -7
- package/dist/chunks/chunk-77PDIBK2.js +0 -129
- package/dist/chunks/chunk-77PDIBK2.js.map +0 -7
- package/dist/chunks/chunk-7A6NVHB5.js.map +0 -7
- package/dist/chunks/chunk-FLKGJPCN.js.map +0 -7
- package/dist/chunks/chunk-G4LADAYY.js.map +0 -7
- package/dist/chunks/chunk-IK6PPFWG.js.map +0 -7
- package/dist/chunks/chunk-MQG5QKGI.js.map +0 -7
- package/dist/chunks/chunk-PSNXUZMY.js.map +0 -7
- package/dist/chunks/chunk-Q4XJ4PYL.js.map +0 -7
- package/dist/chunks/chunk-RTXZHKMS.js.map +0 -7
- package/dist/chunks/chunk-U5FYOMG5.js.map +0 -7
- package/dist/chunks/chunk-UQ4LTUH4.js.map +0 -7
- package/dist/chunks/chunk-XT4346N7.js.map +0 -7
- package/dist/jev/browser.d.ts +0 -37
- package/dist/jev/browser.d.ts.map +0 -1
- package/dist/jev/browser.js +0 -13
- package/dist/jev/browser.js.map +0 -7
- /package/dist/chunks/{chunk-IUCVOZRX.js.map → chunk-3SIXBW6A.js.map} +0 -0
- /package/dist/chunks/{chunk-2SWRVIYJ.js.map → chunk-754HA6KO.js.map} +0 -0
- /package/dist/chunks/{chunk-K6DHXXF5.js.map → chunk-B2IVWASP.js.map} +0 -0
- /package/dist/chunks/{chunk-ZDNGXLEC.js.map → chunk-B4HECUJI.js.map} +0 -0
- /package/dist/chunks/{chunk-H6DDV6E2.js.map → chunk-CSJSHBAT.js.map} +0 -0
- /package/dist/chunks/{chunk-MW5VI7IW.js.map → chunk-D4B4CCTA.js.map} +0 -0
- /package/dist/chunks/{chunk-EDL4JDW7.js.map → chunk-EBWMC3OO.js.map} +0 -0
- /package/dist/chunks/{chunk-W3FRE4VI.js.map → chunk-FDIEQEXS.js.map} +0 -0
- /package/dist/chunks/{chunk-3WIGAX56.js.map → chunk-JCV54SSP.js.map} +0 -0
- /package/dist/chunks/{chunk-7VAZ4N43.js.map → chunk-V3PIO7QL.js.map} +0 -0
- /package/dist/chunks/{chunk-MGDLRV2R.js.map → chunk-VQGO4P7C.js.map} +0 -0
- /package/dist/chunks/{chunk-D5WKZONW.js.map → chunk-X3IRR7CV.js.map} +0 -0
- /package/dist/chunks/{chunk-RKRVOBVO.js.map → chunk-YC3QQDZ3.js.map} +0 -0
- /package/dist/chunks/{chunk-36B4AIRT.js.map → chunk-ZTXZ6JDO.js.map} +0 -0
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
peerLabelPrefix
|
|
20
20
|
} from "./chunk-YV2PHCDB.js";
|
|
21
|
+
import {
|
|
22
|
+
ownedStat,
|
|
23
|
+
processAlive
|
|
24
|
+
} from "./chunk-RAO6TQFP.js";
|
|
21
25
|
import {
|
|
22
26
|
resolveAgentDir
|
|
23
27
|
} from "./chunk-PXAICAUT.js";
|
|
@@ -27,17 +31,12 @@ import {
|
|
|
27
31
|
import {
|
|
28
32
|
DEFAULT_FABRIC_CONFIG,
|
|
29
33
|
MAX_AGENT_TIMEOUT_MS,
|
|
30
|
-
MIN_AGENT_TIMEOUT_MS
|
|
31
|
-
|
|
32
|
-
} from "./chunk-4NUTVNS2.js";
|
|
33
|
-
import {
|
|
34
|
-
ownedStat,
|
|
35
|
-
processAlive
|
|
36
|
-
} from "./chunk-RAO6TQFP.js";
|
|
34
|
+
MIN_AGENT_TIMEOUT_MS
|
|
35
|
+
} from "./chunk-F72MAIQY.js";
|
|
37
36
|
import {
|
|
38
37
|
compileFabricSummary,
|
|
39
38
|
rawContextTokens
|
|
40
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-Q5BMTL6A.js";
|
|
41
40
|
import {
|
|
42
41
|
writeFileAtomic,
|
|
43
42
|
writeJsonAtomic
|
|
@@ -66,7 +65,7 @@ import {
|
|
|
66
65
|
import {
|
|
67
66
|
compactionRequestBoundsError,
|
|
68
67
|
encodeCompactionRequest
|
|
69
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-LNLQ2LX3.js";
|
|
70
69
|
|
|
71
70
|
// src/core/model-usage.ts
|
|
72
71
|
import { readFileSync } from "node:fs";
|
|
@@ -93,6 +92,199 @@ var loadModelUsage = (agentDir = resolveAgentDir()) => {
|
|
|
93
92
|
import { randomUUID } from "node:crypto";
|
|
94
93
|
import fs from "node:fs";
|
|
95
94
|
import path2 from "node:path";
|
|
95
|
+
|
|
96
|
+
// src/verified/generated/storage-kernel.js
|
|
97
|
+
function c(n, t) {
|
|
98
|
+
return { $: n < t ? "LT" : n === t ? "EQ" : "GT" };
|
|
99
|
+
}
|
|
100
|
+
function g(n) {
|
|
101
|
+
if (n > 281474976710655n)
|
|
102
|
+
throw "bend: a Nat past the largest immediate 2^48-1";
|
|
103
|
+
return n;
|
|
104
|
+
}
|
|
105
|
+
function u(n, t) {
|
|
106
|
+
return { $: "$JMP", f: n, x: t };
|
|
107
|
+
}
|
|
108
|
+
function $(n) {
|
|
109
|
+
for (; n !== null && typeof n == "object" && n.$ === "$JMP"; )
|
|
110
|
+
n = n.f(...n.x);
|
|
111
|
+
return n;
|
|
112
|
+
}
|
|
113
|
+
function p(n, t) {
|
|
114
|
+
return (...e) => e.length < t ? p((...r) => n(...e, ...r), t - e.length) : $(n(...e));
|
|
115
|
+
}
|
|
116
|
+
function v(n, t) {
|
|
117
|
+
return u(B, [n, t]);
|
|
118
|
+
}
|
|
119
|
+
function B(n, t) {
|
|
120
|
+
let e = n.key, r = n.expected, i = n.change, o = t.present, l = t.version, m = t.highWater;
|
|
121
|
+
return u(T, [$(b(r, l)), e, i, o, l, m]);
|
|
122
|
+
}
|
|
123
|
+
function T(n, t, e, r, i, o) {
|
|
124
|
+
return n ? u(I, [t, e, r, i, o]) : { $: "Conflict" };
|
|
125
|
+
}
|
|
126
|
+
function b(n, t) {
|
|
127
|
+
if (n.$ === "Any")
|
|
128
|
+
return true;
|
|
129
|
+
{
|
|
130
|
+
let e = n.version;
|
|
131
|
+
return u(N, [e, t]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function I(n, t, e, r, i) {
|
|
135
|
+
if (t.$ === "Delete")
|
|
136
|
+
return e ? u(h, [$(d(r, i)), n, { $: "Delete" }, r, i]) : { $: "Unchanged" };
|
|
137
|
+
{
|
|
138
|
+
let o = t.value, l = t.identity;
|
|
139
|
+
return u(h, [$(d($(w(e, r, i)), i)), n, { $: "Put", value: o, identity: l }, $(w(e, r, i)), i]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function N(n, t) {
|
|
143
|
+
let e = n.high, r = n.low, i = t.high, o = t.low;
|
|
144
|
+
return u(a, [$(f(e, i)), $(f(r, o))]);
|
|
145
|
+
}
|
|
146
|
+
function h(n, t, e, r, i) {
|
|
147
|
+
if (n)
|
|
148
|
+
if (e.$ === "Put") {
|
|
149
|
+
let o = e.value, l = e.identity;
|
|
150
|
+
return { $: "PutNext", key: t, value: o, identity: l, version: $(s(r)), highWater: $(s(i)) };
|
|
151
|
+
} else
|
|
152
|
+
return { $: "DeleteNext", key: t, version: $(s(r)), highWater: $(s(i)) };
|
|
153
|
+
else
|
|
154
|
+
return { $: "Exhausted" };
|
|
155
|
+
}
|
|
156
|
+
function d(n, t) {
|
|
157
|
+
return u(a, [$(y(n)), $(y(t))]);
|
|
158
|
+
}
|
|
159
|
+
function w(n, t, e) {
|
|
160
|
+
return n ? t : e;
|
|
161
|
+
}
|
|
162
|
+
function a(n, t) {
|
|
163
|
+
return n ? t : false;
|
|
164
|
+
}
|
|
165
|
+
function f(n, t) {
|
|
166
|
+
return u(P, [c(n, t)]);
|
|
167
|
+
}
|
|
168
|
+
function s(n) {
|
|
169
|
+
let t = n.high, e = n.low;
|
|
170
|
+
return u(E, [$(f(e, BigInt(4294967295))), t, e]);
|
|
171
|
+
}
|
|
172
|
+
function y(n) {
|
|
173
|
+
let t = n.high, e = n.low, r = BigInt(2097151), i = BigInt(4294967295), o = t < r, l = e < i;
|
|
174
|
+
return u(a, [$(a($(x(t, BigInt(2097151))), $(x(e, BigInt(4294967295))))), o || l]);
|
|
175
|
+
}
|
|
176
|
+
function P(n) {
|
|
177
|
+
return n.$ === "LT" ? false : n.$ === "EQ";
|
|
178
|
+
}
|
|
179
|
+
function E(n, t, e) {
|
|
180
|
+
return n ? { $: "Revision", high: g(t + 1n), low: 0n } : { $: "Revision", high: t, low: g(e + 1n) };
|
|
181
|
+
}
|
|
182
|
+
function x(n, t) {
|
|
183
|
+
return u(k, [c(n, t)]);
|
|
184
|
+
}
|
|
185
|
+
function k(n) {
|
|
186
|
+
return n.$ === "LT" ? true : n.$ === "EQ";
|
|
187
|
+
}
|
|
188
|
+
var C = /* @__PURE__ */ p(v, 2);
|
|
189
|
+
|
|
190
|
+
// src/verified/storage.ts
|
|
191
|
+
var RADIX = 4294967296n;
|
|
192
|
+
var encode = (text) => {
|
|
193
|
+
let result = { $: "Nil" };
|
|
194
|
+
for (let index = text.length - 1; index >= 0; index--) {
|
|
195
|
+
result = { $: "Con", head: BigInt(text.charCodeAt(index)), tail: result };
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
};
|
|
199
|
+
var decode = (text) => {
|
|
200
|
+
const units = [];
|
|
201
|
+
for (let node = text; node.$ === "Con"; node = node.tail) {
|
|
202
|
+
if (node.head < 0n || node.head > 65535n) throw new Error("Invalid storage code unit");
|
|
203
|
+
units.push(String.fromCharCode(Number(node.head)));
|
|
204
|
+
}
|
|
205
|
+
return units.join("");
|
|
206
|
+
};
|
|
207
|
+
var storageRevision = (value) => {
|
|
208
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
209
|
+
throw new Error("Invalid Fabric mesh revision: expected a nonnegative safe integer");
|
|
210
|
+
}
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
var encodeRevision = (value) => {
|
|
214
|
+
const exact = BigInt(storageRevision(value));
|
|
215
|
+
return { $: "Revision", high: exact / RADIX, low: exact % RADIX };
|
|
216
|
+
};
|
|
217
|
+
var decodeRevision = (value) => {
|
|
218
|
+
if (value.high < 0n || value.high > 2097151n || value.low < 0n || value.low >= RADIX) {
|
|
219
|
+
throw new Error("Invalid verified storage revision limbs");
|
|
220
|
+
}
|
|
221
|
+
return storageRevision(Number(value.high * RADIX + value.low));
|
|
222
|
+
};
|
|
223
|
+
var serialize = (value) => {
|
|
224
|
+
const json = JSON.stringify(value);
|
|
225
|
+
if (json === void 0) throw new Error("Mesh values must be JSON-serializable");
|
|
226
|
+
return json;
|
|
227
|
+
};
|
|
228
|
+
var capture = (key, ifVersion, payload) => {
|
|
229
|
+
const expected = ifVersion === void 0 ? void 0 : storageRevision(ifVersion);
|
|
230
|
+
const request = {
|
|
231
|
+
$: "Request",
|
|
232
|
+
key: encode(key),
|
|
233
|
+
expected: expected === void 0 ? { $: "Any" } : { $: "At", version: encodeRevision(expected) },
|
|
234
|
+
change: payload === void 0 ? { $: "Delete" } : {
|
|
235
|
+
$: "Put",
|
|
236
|
+
value: encode(payload.value),
|
|
237
|
+
identity: encode(payload.identity)
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
return Object.freeze({
|
|
241
|
+
key,
|
|
242
|
+
transition(present, actualVersion, highWater) {
|
|
243
|
+
const actual = storageRevision(actualVersion);
|
|
244
|
+
const clock = storageRevision(highWater);
|
|
245
|
+
if (clock < actual) throw new Error("Inconsistent Fabric mesh high-water revision");
|
|
246
|
+
const plan = C(
|
|
247
|
+
request,
|
|
248
|
+
{ $: "Slot", present, version: encodeRevision(actual), highWater: encodeRevision(clock) }
|
|
249
|
+
);
|
|
250
|
+
switch (plan.$) {
|
|
251
|
+
case "Conflict":
|
|
252
|
+
throw new Error(`Mesh compare-and-swap failed for ${key}: expected version ${expected}, found ${actual}`);
|
|
253
|
+
case "Exhausted":
|
|
254
|
+
throw new Error(`Fabric mesh revision exhausted for ${key}`);
|
|
255
|
+
case "Unchanged":
|
|
256
|
+
return { kind: "unchanged" };
|
|
257
|
+
case "PutNext":
|
|
258
|
+
return {
|
|
259
|
+
kind: "put",
|
|
260
|
+
key: decode(plan.key),
|
|
261
|
+
value: JSON.parse(decode(plan.value)),
|
|
262
|
+
identity: JSON.parse(decode(plan.identity)),
|
|
263
|
+
version: decodeRevision(plan.version),
|
|
264
|
+
highWater: decodeRevision(plan.highWater)
|
|
265
|
+
};
|
|
266
|
+
case "DeleteNext":
|
|
267
|
+
return { kind: "delete", key: decode(plan.key), version: decodeRevision(plan.version), highWater: decodeRevision(plan.highWater) };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
var captureStoragePut = (input, maxValueBytes = Number.POSITIVE_INFINITY) => {
|
|
273
|
+
const { key, ifVersion, value, identity } = input;
|
|
274
|
+
if (ifVersion !== void 0) storageRevision(ifVersion);
|
|
275
|
+
const identityJson = serialize(identity);
|
|
276
|
+
const valueJson = serialize(value);
|
|
277
|
+
if (Buffer.byteLength(valueJson, "utf8") > maxValueBytes) {
|
|
278
|
+
throw new Error(`Mesh state value exceeds ${maxValueBytes} bytes`);
|
|
279
|
+
}
|
|
280
|
+
return capture(key, ifVersion, { value: valueJson, identity: identityJson });
|
|
281
|
+
};
|
|
282
|
+
var captureStorageDelete = (input) => {
|
|
283
|
+
const { key, ifVersion } = input;
|
|
284
|
+
return capture(key, ifVersion);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// src/mesh/store.ts
|
|
96
288
|
var TOPIC_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;
|
|
97
289
|
var KEY_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/;
|
|
98
290
|
var LOCK_TIMEOUT_MS = 1e4;
|
|
@@ -121,7 +313,7 @@ var jsonClone = (value) => {
|
|
|
121
313
|
return JSON.parse(serialized);
|
|
122
314
|
};
|
|
123
315
|
var isMeshStateFile = (value) => {
|
|
124
|
-
if (typeof value !== "object" || value === null || Array.isArray(value) || value.format
|
|
316
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || ![1, 2].includes(value.format)) {
|
|
125
317
|
return false;
|
|
126
318
|
}
|
|
127
319
|
const entries = value.entries;
|
|
@@ -166,20 +358,20 @@ var recoverConcatenatedState = (serialized) => {
|
|
|
166
358
|
}
|
|
167
359
|
return start < 0 && documents > 1 ? snapshots.at(-1) : void 0;
|
|
168
360
|
};
|
|
169
|
-
var emptyState = () => ({ format: 1, entries: {} });
|
|
170
|
-
var readState = (filePath, maxBytes) => {
|
|
361
|
+
var emptyState = () => ({ format: 1, revisionFormat: 2, entries: {}, highWater: 0 });
|
|
362
|
+
var readState = (filePath, maxBytes, recoverDamage = true) => {
|
|
171
363
|
let serialized;
|
|
172
364
|
try {
|
|
173
365
|
const stat = fs.statSync(filePath);
|
|
174
366
|
if (stat.size > maxBytes) throw new Error(`state exceeds ${maxBytes} bytes`);
|
|
175
|
-
if (stat.size === 0) return emptyState();
|
|
367
|
+
if (stat.size === 0 && recoverDamage) return emptyState();
|
|
176
368
|
serialized = fs.readFileSync(filePath, "utf8");
|
|
177
369
|
} catch (error) {
|
|
178
370
|
if (errorCode(error) === "ENOENT") return emptyState();
|
|
179
371
|
const message = error instanceof Error ? error.message : String(error);
|
|
180
372
|
throw new Error(`Failed to read Fabric mesh state: ${message}`);
|
|
181
373
|
}
|
|
182
|
-
if (!serialized.trim()) return emptyState();
|
|
374
|
+
if (!serialized.trim() && recoverDamage) return emptyState();
|
|
183
375
|
try {
|
|
184
376
|
const parsed = JSON.parse(serialized);
|
|
185
377
|
if (isMeshStateFile(parsed)) return parsed;
|
|
@@ -187,7 +379,7 @@ var readState = (filePath, maxBytes) => {
|
|
|
187
379
|
} catch (error) {
|
|
188
380
|
const recovered = recoverConcatenatedState(serialized);
|
|
189
381
|
if (recovered) return recovered;
|
|
190
|
-
|
|
382
|
+
if (!recoverDamage) throw new Error("Failed to read Fabric mesh state: invalid state format");
|
|
191
383
|
return emptyState();
|
|
192
384
|
}
|
|
193
385
|
};
|
|
@@ -198,24 +390,55 @@ var atomicWrite = (filePath, value, maxBytes = Number.POSITIVE_INFINITY) => {
|
|
|
198
390
|
}
|
|
199
391
|
writeFileAtomic(filePath, serialized);
|
|
200
392
|
};
|
|
393
|
+
var stateSlot = (state, key) => {
|
|
394
|
+
if (state.versions !== void 0 && (typeof state.versions !== "object" || state.versions === null || Array.isArray(state.versions))) {
|
|
395
|
+
throw new Error("Invalid Fabric mesh revision table");
|
|
396
|
+
}
|
|
397
|
+
let retainedMaximum = 0;
|
|
398
|
+
for (const revision of Object.values(state.versions ?? {})) {
|
|
399
|
+
retainedMaximum = Math.max(retainedMaximum, storageRevision(revision));
|
|
400
|
+
}
|
|
401
|
+
for (const [entryKey, entry] of Object.entries(state.entries)) {
|
|
402
|
+
if (typeof entry !== "object" || entry === null || entry.key !== entryKey) {
|
|
403
|
+
throw new Error("Invalid Fabric mesh state entry");
|
|
404
|
+
}
|
|
405
|
+
const version2 = storageRevision(entry.version);
|
|
406
|
+
const retained = state.versions !== void 0 && Object.hasOwn(state.versions, entryKey) ? state.versions[entryKey] : void 0;
|
|
407
|
+
if (version2 === 0 || retained !== void 0 && retained !== version2) {
|
|
408
|
+
throw new Error("Inconsistent Fabric mesh revision");
|
|
409
|
+
}
|
|
410
|
+
retainedMaximum = Math.max(retainedMaximum, version2);
|
|
411
|
+
}
|
|
412
|
+
if (Object.hasOwn(state, "revisionFormat") && state.revisionFormat !== 2) {
|
|
413
|
+
throw new Error("Unsupported Fabric mesh revision protocol");
|
|
414
|
+
}
|
|
415
|
+
if ((state.format === 2 || state.revisionFormat === 2) && !Object.hasOwn(state, "highWater")) {
|
|
416
|
+
throw new Error("Missing Fabric mesh high-water revision");
|
|
417
|
+
}
|
|
418
|
+
const highWater = Object.hasOwn(state, "highWater") ? storageRevision(state.highWater) : retainedMaximum;
|
|
419
|
+
if (highWater < retainedMaximum) throw new Error("Inconsistent Fabric mesh high-water revision");
|
|
420
|
+
const present = Object.hasOwn(state.entries, key);
|
|
421
|
+
const version = present ? state.entries[key].version : state.versions !== void 0 && Object.hasOwn(state.versions, key) ? state.versions[key] : 0;
|
|
422
|
+
return { present, version, highWater };
|
|
423
|
+
};
|
|
201
424
|
var compactStateTombstones = (state, maxTombstones) => {
|
|
202
425
|
state.versions ??= {};
|
|
203
426
|
const orderedKeys = [];
|
|
204
427
|
const seen = /* @__PURE__ */ new Set();
|
|
205
428
|
for (const key of state.tombstoneOrder ?? []) {
|
|
206
|
-
if (state.entries
|
|
429
|
+
if (Object.hasOwn(state.entries, key) || !Object.hasOwn(state.versions, key) || seen.has(key)) continue;
|
|
207
430
|
seen.add(key);
|
|
208
431
|
orderedKeys.push(key);
|
|
209
432
|
}
|
|
210
433
|
for (const key of Object.keys(state.versions)) {
|
|
211
|
-
if (state.entries
|
|
434
|
+
if (Object.hasOwn(state.entries, key) || seen.has(key)) continue;
|
|
212
435
|
seen.add(key);
|
|
213
436
|
orderedKeys.push(key);
|
|
214
437
|
}
|
|
215
438
|
const retainedKeys = orderedKeys.slice(-maxTombstones);
|
|
216
439
|
const retained = new Set(retainedKeys);
|
|
217
440
|
for (const key of Object.keys(state.versions)) {
|
|
218
|
-
if (!state.entries
|
|
441
|
+
if (!Object.hasOwn(state.entries, key) && !retained.has(key)) delete state.versions[key];
|
|
219
442
|
}
|
|
220
443
|
state.tombstoneOrder = retainedKeys;
|
|
221
444
|
};
|
|
@@ -477,8 +700,8 @@ var MeshStore = class {
|
|
|
477
700
|
}
|
|
478
701
|
get(key) {
|
|
479
702
|
this.#validateKey(key);
|
|
480
|
-
const
|
|
481
|
-
return
|
|
703
|
+
const entries = this.#readCachedState().entries;
|
|
704
|
+
return Object.hasOwn(entries, key) ? jsonClone(entries[key]) : void 0;
|
|
482
705
|
}
|
|
483
706
|
list(prefix = "", limit = 100) {
|
|
484
707
|
const boundedLimit = Math.max(1, Math.min(Math.floor(limit), this.maxReadEvents));
|
|
@@ -490,34 +713,28 @@ var MeshStore = class {
|
|
|
490
713
|
return Object.values(this.#readCachedState().entries).filter((entry) => !prefix || entry.key.startsWith(prefix)).sort((left, right) => left.key.localeCompare(right.key)).map((entry) => jsonClone(entry));
|
|
491
714
|
}
|
|
492
715
|
async put(input) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
throw new Error(`Mesh state value exceeds ${this.maxEventBytes} bytes`);
|
|
497
|
-
}
|
|
716
|
+
const { key, value, identity, ifVersion } = input;
|
|
717
|
+
this.#validateKey(key);
|
|
718
|
+
const request = captureStoragePut({ key, value, identity, ifVersion }, this.maxEventBytes);
|
|
498
719
|
return this.#withLock(() => {
|
|
499
|
-
const state = readState(this.#statePath, this.#maxStateBytes);
|
|
500
|
-
const
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
if (input.ifVersion !== void 0) {
|
|
504
|
-
if (actualVersion !== input.ifVersion) {
|
|
505
|
-
throw new Error(
|
|
506
|
-
`Mesh compare-and-swap failed for ${input.key}: expected version ${input.ifVersion}, found ${actualVersion}`
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
720
|
+
const state = readState(this.#statePath, this.#maxStateBytes, false);
|
|
721
|
+
const slot = stateSlot(state, request.key);
|
|
722
|
+
const plan = request.transition(slot.present, slot.version, slot.highWater);
|
|
723
|
+
if (plan.kind !== "put") throw new Error("Invalid verified storage put plan");
|
|
510
724
|
const entry = {
|
|
511
|
-
key:
|
|
512
|
-
value,
|
|
513
|
-
version:
|
|
725
|
+
key: plan.key,
|
|
726
|
+
value: plan.value,
|
|
727
|
+
version: plan.version,
|
|
514
728
|
updatedAt: Date.now(),
|
|
515
|
-
updatedBy:
|
|
729
|
+
updatedBy: plan.identity
|
|
516
730
|
};
|
|
517
|
-
state.entries[
|
|
731
|
+
state.entries[plan.key] = entry;
|
|
518
732
|
state.versions ??= {};
|
|
519
|
-
state.versions[
|
|
520
|
-
state.
|
|
733
|
+
state.versions[plan.key] = plan.version;
|
|
734
|
+
state.format = 1;
|
|
735
|
+
state.revisionFormat = 2;
|
|
736
|
+
state.highWater = plan.highWater;
|
|
737
|
+
state.tombstoneOrder = (state.tombstoneOrder ?? []).filter((key2) => key2 !== plan.key);
|
|
521
738
|
compactStateTombstones(state, this.#maxStateTombstones);
|
|
522
739
|
atomicWrite(this.#statePath, state, this.#maxStateBytes);
|
|
523
740
|
this.#cacheState(state);
|
|
@@ -525,37 +742,32 @@ var MeshStore = class {
|
|
|
525
742
|
});
|
|
526
743
|
}
|
|
527
744
|
async delete(input) {
|
|
528
|
-
|
|
745
|
+
const { key, ifVersion } = input;
|
|
746
|
+
this.#validateKey(key);
|
|
747
|
+
const request = captureStorageDelete({ key, ifVersion });
|
|
529
748
|
return this.#withLock(() => {
|
|
530
|
-
const state = readState(this.#statePath, this.#maxStateBytes);
|
|
531
|
-
const
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
if (!existing) {
|
|
535
|
-
if (input.ifVersion !== void 0 && input.ifVersion !== actualVersion) {
|
|
536
|
-
throw new Error(
|
|
537
|
-
`Mesh compare-and-swap failed for ${input.key}: expected version ${input.ifVersion}, found ${actualVersion}`
|
|
538
|
-
);
|
|
539
|
-
}
|
|
749
|
+
const state = readState(this.#statePath, this.#maxStateBytes, false);
|
|
750
|
+
const slot = stateSlot(state, request.key);
|
|
751
|
+
const plan = request.transition(slot.present, slot.version, slot.highWater);
|
|
752
|
+
if (plan.kind === "unchanged") {
|
|
540
753
|
this.#cacheState(state);
|
|
541
754
|
return { deleted: false };
|
|
542
755
|
}
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
`Mesh compare-and-swap failed for ${input.key}: expected version ${input.ifVersion}, found ${existing.version}`
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
delete state.entries[input.key];
|
|
756
|
+
if (plan.kind !== "delete") throw new Error("Invalid verified storage delete plan");
|
|
757
|
+
delete state.entries[plan.key];
|
|
549
758
|
state.versions ??= {};
|
|
550
|
-
state.versions[
|
|
759
|
+
state.versions[plan.key] = plan.version;
|
|
760
|
+
state.format = 1;
|
|
761
|
+
state.revisionFormat = 2;
|
|
762
|
+
state.highWater = plan.highWater;
|
|
551
763
|
state.tombstoneOrder = [
|
|
552
|
-
...(state.tombstoneOrder ?? []).filter((
|
|
553
|
-
|
|
764
|
+
...(state.tombstoneOrder ?? []).filter((key2) => key2 !== plan.key),
|
|
765
|
+
plan.key
|
|
554
766
|
];
|
|
555
767
|
compactStateTombstones(state, this.#maxStateTombstones);
|
|
556
768
|
atomicWrite(this.#statePath, state, this.#maxStateBytes);
|
|
557
769
|
this.#cacheState(state);
|
|
558
|
-
return { deleted: true, version:
|
|
770
|
+
return { deleted: true, version: plan.version };
|
|
559
771
|
});
|
|
560
772
|
}
|
|
561
773
|
#readCachedState() {
|
|
@@ -1740,7 +1952,7 @@ var synchronizeSourceSettings = (session, seed) => {
|
|
|
1740
1952
|
session.appendThinkingLevelChange(seed.sourceThinkingLevel);
|
|
1741
1953
|
}
|
|
1742
1954
|
};
|
|
1743
|
-
var writeHandoffSession = (seed, cwd, directory, transfer, compaction) => {
|
|
1955
|
+
var writeHandoffSession = (seed, cwd, directory, transfer, compaction, compactionBudget) => {
|
|
1744
1956
|
fs8.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1745
1957
|
const policy = transfer ? thinkingTransferPolicy(transfer) : "preserved";
|
|
1746
1958
|
let session;
|
|
@@ -1757,6 +1969,14 @@ var writeHandoffSession = (seed, cwd, directory, transfer, compaction) => {
|
|
|
1757
1969
|
report = translated.report;
|
|
1758
1970
|
session = materializeBranch({ ...seed, sourceBranch: translated.entries }, cwd, directory);
|
|
1759
1971
|
}
|
|
1972
|
+
synchronizeSourceSettings(session, seed);
|
|
1973
|
+
session.appendMessage(seed.outerToolResult);
|
|
1974
|
+
if (digest) {
|
|
1975
|
+
session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {
|
|
1976
|
+
policy,
|
|
1977
|
+
citedBlocks: digest.citedBlocks
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1760
1980
|
let compactionOutcome;
|
|
1761
1981
|
if (compaction) {
|
|
1762
1982
|
const branchEntries = session.getBranch();
|
|
@@ -1765,9 +1985,15 @@ var writeHandoffSession = (seed, cwd, directory, transfer, compaction) => {
|
|
|
1765
1985
|
preserve: compaction.preserve
|
|
1766
1986
|
}) : compaction.instructions;
|
|
1767
1987
|
const tokensBefore = rawContextTokens(branchEntries);
|
|
1768
|
-
const compiled = compileFabricSummary(
|
|
1988
|
+
const compiled = compileFabricSummary(
|
|
1989
|
+
branchEntries,
|
|
1990
|
+
tokensBefore,
|
|
1991
|
+
void 0,
|
|
1992
|
+
customInstructions,
|
|
1993
|
+
compactionBudget ? { ...compactionBudget, calibrateUsage: false } : void 0
|
|
1994
|
+
);
|
|
1769
1995
|
if ("cancel" in compiled) {
|
|
1770
|
-
|
|
1996
|
+
throw new Error(`Handoff compaction cancelled: ${compiled.reason}`);
|
|
1771
1997
|
} else {
|
|
1772
1998
|
session.appendCompaction(
|
|
1773
1999
|
compiled.compaction.summary,
|
|
@@ -1784,24 +2010,11 @@ var writeHandoffSession = (seed, cwd, directory, transfer, compaction) => {
|
|
|
1784
2010
|
};
|
|
1785
2011
|
}
|
|
1786
2012
|
}
|
|
1787
|
-
synchronizeSourceSettings(session, seed);
|
|
1788
|
-
session.appendMessage(seed.outerToolResult);
|
|
1789
|
-
if (digest) {
|
|
1790
|
-
session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {
|
|
1791
|
-
policy,
|
|
1792
|
-
citedBlocks: digest.citedBlocks
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
2013
|
session.appendCustomEntry("pi-fabric-handoff", {
|
|
1796
2014
|
sourceSessionId: seed.sourceSessionId,
|
|
1797
2015
|
boundary: "fabric_exec_end",
|
|
1798
2016
|
...compactionOutcome ? {
|
|
1799
|
-
compaction: compactionOutcome
|
|
1800
|
-
applied: true,
|
|
1801
|
-
sections: compactionOutcome.sections,
|
|
1802
|
-
tokensBefore: compactionOutcome.tokensBefore,
|
|
1803
|
-
firstKeptEntryId: compactionOutcome.firstKeptEntryId
|
|
1804
|
-
} : { applied: false, reason: compactionOutcome.reason }
|
|
2017
|
+
compaction: compactionOutcome
|
|
1805
2018
|
} : {},
|
|
1806
2019
|
...transfer && report ? {
|
|
1807
2020
|
thinkingTransfer: {
|
|
@@ -2223,6 +2436,7 @@ var AgentManager = class {
|
|
|
2223
2436
|
this.#onResultConsumed = options.onResultConsumed;
|
|
2224
2437
|
this.#onLifecycle = options.onLifecycle;
|
|
2225
2438
|
this.#preparePiModel = options.preparePiModel;
|
|
2439
|
+
this.#resolveHandoffCompactionBudget = options.resolveHandoffCompactionBudget;
|
|
2226
2440
|
this.#resolveParticipantGuidance = options.resolveParticipantGuidance;
|
|
2227
2441
|
this.#resolveInheritedSessionPins = options.resolveInheritedSessionPins;
|
|
2228
2442
|
this.#currentDepth = Math.max(0, Number(process.env.PI_FABRIC_DEPTH ?? "0") || 0);
|
|
@@ -2276,6 +2490,7 @@ var AgentManager = class {
|
|
|
2276
2490
|
#onResultConsumed;
|
|
2277
2491
|
#onLifecycle;
|
|
2278
2492
|
#preparePiModel;
|
|
2493
|
+
#resolveHandoffCompactionBudget;
|
|
2279
2494
|
#resolveParticipantGuidance;
|
|
2280
2495
|
#resolveInheritedSessionPins;
|
|
2281
2496
|
#piModelPreparations = /* @__PURE__ */ new Map();
|
|
@@ -2492,7 +2707,8 @@ var AgentManager = class {
|
|
|
2492
2707
|
agentCwd,
|
|
2493
2708
|
path12.join(runDirectory, "handoff-session"),
|
|
2494
2709
|
request.thinkingTransfer,
|
|
2495
|
-
request.handoffCompact
|
|
2710
|
+
request.handoffCompact,
|
|
2711
|
+
request.handoffCompact ? await this.#resolveHandoffCompactionBudget?.(model, agentCwd) : void 0
|
|
2496
2712
|
) : request.sessionFile;
|
|
2497
2713
|
const adapter = await this.#resolveTransport(request.transport ?? this.config.transport);
|
|
2498
2714
|
const timeoutMs = effectiveAgentTimeoutMs(
|
|
@@ -7323,4 +7539,4 @@ export {
|
|
|
7323
7539
|
agentParticipantRecords,
|
|
7324
7540
|
actorParticipantRecord
|
|
7325
7541
|
};
|
|
7326
|
-
//# sourceMappingURL=chunk-
|
|
7542
|
+
//# sourceMappingURL=chunk-ZRI433JP.js.map
|