@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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Generated by Bend 2.0.26; do not edit. See LAWS.bend and PROOF.bend.
|
|
2
|
+
// Includes adapted Bend runtime/Base code, Copyright 2026 HigherOrderCO, Apache-2.0.
|
|
3
|
+
// CLI removed and exports added by Pi Fabric; see THIRD_PARTY_NOTICES.md.
|
|
4
|
+
function c(n, t) {
|
|
5
|
+
return { $: n < t ? "LT" : n === t ? "EQ" : "GT" };
|
|
6
|
+
}
|
|
7
|
+
function g(n) {
|
|
8
|
+
if (n > 281474976710655n)
|
|
9
|
+
throw "bend: a Nat past the largest immediate 2^48-1";
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function u(n, t) {
|
|
13
|
+
return { $: "$JMP", f: n, x: t };
|
|
14
|
+
}
|
|
15
|
+
function $(n) {
|
|
16
|
+
for (; n !== null && typeof n == "object" && n.$ === "$JMP"; )
|
|
17
|
+
n = n.f(...n.x);
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
function p(n, t) {
|
|
21
|
+
return (...e) => e.length < t ? p((...r) => n(...e, ...r), t - e.length) : $(n(...e));
|
|
22
|
+
}
|
|
23
|
+
function v(n, t) {
|
|
24
|
+
return u(B, [n, t]);
|
|
25
|
+
}
|
|
26
|
+
function B(n, t) {
|
|
27
|
+
let e = n.key, r = n.expected, i = n.change, o = t.present, l = t.version, m = t.highWater;
|
|
28
|
+
return u(T, [$(b(r, l)), e, i, o, l, m]);
|
|
29
|
+
}
|
|
30
|
+
function T(n, t, e, r, i, o) {
|
|
31
|
+
return n ? u(I, [t, e, r, i, o]) : { $: "Conflict" };
|
|
32
|
+
}
|
|
33
|
+
function b(n, t) {
|
|
34
|
+
if (n.$ === "Any")
|
|
35
|
+
return !0;
|
|
36
|
+
{
|
|
37
|
+
let e = n.version;
|
|
38
|
+
return u(N, [e, t]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function I(n, t, e, r, i) {
|
|
42
|
+
if (t.$ === "Delete")
|
|
43
|
+
return e ? u(h, [$(d(r, i)), n, { $: "Delete" }, r, i]) : { $: "Unchanged" };
|
|
44
|
+
{
|
|
45
|
+
let o = t.value, l = t.identity;
|
|
46
|
+
return u(h, [$(d($(w(e, r, i)), i)), n, { $: "Put", value: o, identity: l }, $(w(e, r, i)), i]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function N(n, t) {
|
|
50
|
+
let e = n.high, r = n.low, i = t.high, o = t.low;
|
|
51
|
+
return u(a, [$(f(e, i)), $(f(r, o))]);
|
|
52
|
+
}
|
|
53
|
+
function h(n, t, e, r, i) {
|
|
54
|
+
if (n)
|
|
55
|
+
if (e.$ === "Put") {
|
|
56
|
+
let o = e.value, l = e.identity;
|
|
57
|
+
return { $: "PutNext", key: t, value: o, identity: l, version: $(s(r)), highWater: $(s(i)) };
|
|
58
|
+
} else
|
|
59
|
+
return { $: "DeleteNext", key: t, version: $(s(r)), highWater: $(s(i)) };
|
|
60
|
+
else
|
|
61
|
+
return { $: "Exhausted" };
|
|
62
|
+
}
|
|
63
|
+
function d(n, t) {
|
|
64
|
+
return u(a, [$(y(n)), $(y(t))]);
|
|
65
|
+
}
|
|
66
|
+
function w(n, t, e) {
|
|
67
|
+
return n ? t : e;
|
|
68
|
+
}
|
|
69
|
+
function a(n, t) {
|
|
70
|
+
return n ? t : !1;
|
|
71
|
+
}
|
|
72
|
+
function f(n, t) {
|
|
73
|
+
return u(P, [c(n, t)]);
|
|
74
|
+
}
|
|
75
|
+
function s(n) {
|
|
76
|
+
let t = n.high, e = n.low;
|
|
77
|
+
return u(E, [$(f(e, BigInt(4294967295))), t, e]);
|
|
78
|
+
}
|
|
79
|
+
function y(n) {
|
|
80
|
+
let t = n.high, e = n.low, r = BigInt(2097151), i = BigInt(4294967295), o = t < r, l = e < i;
|
|
81
|
+
return u(a, [$(a($(x(t, BigInt(2097151))), $(x(e, BigInt(4294967295))))), o || l]);
|
|
82
|
+
}
|
|
83
|
+
function P(n) {
|
|
84
|
+
return n.$ === "LT" ? !1 : n.$ === "EQ";
|
|
85
|
+
}
|
|
86
|
+
function E(n, t, e) {
|
|
87
|
+
return n ? { $: "Revision", high: g(t + 1n), low: 0n } : { $: "Revision", high: t, low: g(e + 1n) };
|
|
88
|
+
}
|
|
89
|
+
function x(n, t) {
|
|
90
|
+
return u(k, [c(n, t)]);
|
|
91
|
+
}
|
|
92
|
+
function k(n) {
|
|
93
|
+
return n.$ === "LT" ? !0 : n.$ === "EQ";
|
|
94
|
+
}
|
|
95
|
+
var C = /* @__PURE__ */ p(v, 2);
|
|
96
|
+
export {
|
|
97
|
+
C as storageTransition
|
|
98
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Check the actual outgoing page against the selected normalized source, after
|
|
2
|
+
* all envelope trimming. Source observation/hashing and lineage selection remain
|
|
3
|
+
* host responsibilities; ranges are checked by the compiled Bend kernel. */
|
|
4
|
+
export declare const acceptsExpansionPage: (records: readonly Record<string, unknown>[], source: readonly {
|
|
5
|
+
index: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}[], entryOffset: number, textOffset: number, cursor: {
|
|
8
|
+
position: number;
|
|
9
|
+
textOffset: number;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/verified/memory.ts"],"names":[],"mappings":"AAEA;;4EAE4E;AAC5E,eAAO,MAAM,oBAAoB,GAC/B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC3C,QAAQ,SAAS;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAClD,aAAa,MAAM,EACnB,YAAY,MAAM,EAClB,QAAQ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,KAC/C,OAmBF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nat.d.ts","sourceRoot":"","sources":["../../src/verified/nat.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,QAAc,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type BendList } from "./generated/kernel.js";
|
|
2
|
+
export { unknownConflict, knownConflict, transitionCurrent, canClose, cleanupState, pointerCurrent, coverageComplete, useNormalized, headReadable, consume, lineageSelected, } from "./generated/kernel.js";
|
|
3
|
+
export declare const bendList: <T>(values: readonly T[]) => BendList<T>;
|
|
4
|
+
export { boundedEffectResources } from "./resources.js";
|
|
5
|
+
export declare const acceptSummaryBounds: (bytes: number, byteLimit: number, projected: number, target: number) => boolean;
|
|
6
|
+
export declare const acceptSampleAccounting: (total: number, retained: number, omitted: number, limit: number) => boolean;
|
|
7
|
+
export interface CutSpan {
|
|
8
|
+
first: number;
|
|
9
|
+
last: number;
|
|
10
|
+
hasCall: boolean;
|
|
11
|
+
hasResult: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CutCandidate {
|
|
14
|
+
eligible: boolean;
|
|
15
|
+
afterPrevious: boolean;
|
|
16
|
+
retained: number;
|
|
17
|
+
budget: number;
|
|
18
|
+
boundary: number;
|
|
19
|
+
}
|
|
20
|
+
/** The producer may reject cheaply, but cannot publish a cut without this check.
|
|
21
|
+
* Batches bound backend non-tail list construction; every source span is checked. */
|
|
22
|
+
export declare const acceptCompactionCut: (candidate: CutCandidate, spans: Iterable<CutSpan>) => boolean;
|
|
23
|
+
export interface TextRange {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
total: number;
|
|
27
|
+
complete: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const acceptMemoryChunk: (range: TextRange, length: number, expectedStart: number, expectedTotal: number) => boolean;
|
|
30
|
+
/** A fixed ordered tuple prevents a missing check from becoming an empty,
|
|
31
|
+
* vacuously accepted certificate. Messages are diagnostics, never authority. */
|
|
32
|
+
export declare const assertCertificateFacts: (facts: readonly [CertificateFact, CertificateFact, CertificateFact, CertificateFact, CertificateFact, CertificateFact, CertificateFact, CertificateFact]) => void;
|
|
33
|
+
interface CertificateFact {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
error: string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/verified/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EACzF,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GACxE,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,QAAQ,SAAS,CAAC,EAAE,KAAG,QAAQ,CAAC,CAAC,CAM5D,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,WAAW,MAAM,EAAE,WAAW,MAAM,EAAE,QAAQ,MAAM,KAAG,OAEtB,CAAC;AAErF,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,OAE1B,CAAC;AAEhF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;qFACqF;AACrF,eAAO,MAAM,mBAAmB,GAAI,WAAW,YAAY,EAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAG,OAmBvF,CAAC;AAEF,MAAM,WAAW,SAAS;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAC3F,eAAO,MAAM,iBAAiB,GAC5B,OAAO,SAAS,EAAE,QAAQ,MAAM,EAAE,eAAe,MAAM,EAAE,eAAe,MAAM,KAC7E,OAQF,CAAC;AAEF;gFACgF;AAChF,eAAO,MAAM,sBAAsB,GACjC,OAAO,SAAS,CAAC,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,CAAC,KACvJ,IAOF,CAAC;AACF,UAAU,eAAe;IAAG,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resourceGroups, type BendList, type ResourceName, type ResourceScope, type ResourceEffect } from "./generated/kernel.js";
|
|
2
|
+
export { resourceGroups };
|
|
3
|
+
/** Lossless wire encoding, including NULs and lone surrogates. Never truncate,
|
|
4
|
+
* hash, normalize Unicode, or assign independently interned numeric IDs here. */
|
|
5
|
+
export declare const encodeResourceNames: (values: readonly unknown[] | undefined) => BendList<ResourceName>;
|
|
6
|
+
/** ABI decoding only. Normalization policy lives in the compiled checker. */
|
|
7
|
+
export declare const decodeResourceScope: (scope: ResourceScope) => string[];
|
|
8
|
+
export declare const boundedEffectResources: (resources: readonly string[] | undefined) => string[];
|
|
9
|
+
export declare const encodeResourceEffects: (effects: readonly {
|
|
10
|
+
kind: string;
|
|
11
|
+
ordering: string;
|
|
12
|
+
resources: readonly string[];
|
|
13
|
+
}[]) => BendList<ResourceEffect>;
|
|
14
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/verified/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAC8B,cAAc,EACjD,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAC1E,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B;iFACiF;AACjF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,OAAO,EAAE,GAAG,SAAS,KAAG,QAAQ,CAAC,YAAY,CAoBjG,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,GAAI,OAAO,aAAa,KAAG,MAAM,EAYhE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,WAAW,SAAS,MAAM,EAAE,GAAG,SAAS,KAAG,MAAM,EAUvF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,SAAS,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,KACnF,QAAQ,CAAC,cAAc,CAWzB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MeshIdentity } from "../mesh/store.js";
|
|
2
|
+
export declare const storageRevision: (value: unknown) => number;
|
|
3
|
+
export type StorageTransition = {
|
|
4
|
+
kind: "put";
|
|
5
|
+
key: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
identity: MeshIdentity;
|
|
8
|
+
version: number;
|
|
9
|
+
highWater: number;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "delete";
|
|
12
|
+
key: string;
|
|
13
|
+
version: number;
|
|
14
|
+
highWater: number;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "unchanged";
|
|
17
|
+
};
|
|
18
|
+
export interface CapturedStorageRequest {
|
|
19
|
+
readonly key: string;
|
|
20
|
+
readonly transition: (present: boolean, actualVersion: number, highWater: number) => StorageTransition;
|
|
21
|
+
}
|
|
22
|
+
export declare const captureStoragePut: (input: {
|
|
23
|
+
key: string;
|
|
24
|
+
ifVersion?: number | undefined;
|
|
25
|
+
value: unknown;
|
|
26
|
+
identity: MeshIdentity;
|
|
27
|
+
}, maxValueBytes?: number) => CapturedStorageRequest;
|
|
28
|
+
export declare const captureStorageDelete: (input: {
|
|
29
|
+
key: string;
|
|
30
|
+
ifVersion?: number | undefined;
|
|
31
|
+
}) => CapturedStorageRequest;
|
|
32
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/verified/storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAuBrD,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,MAKhD,CAAC;AAsBF,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,iBAAiB,CAAC;CACxG;AA+CD,eAAO,MAAM,iBAAiB,GAAI,OAAO;IACvC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;CACrF,EAAE,sBAAwC,KAAG,sBAU7C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO;IAC1C,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,KAAG,sBAGH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-projection.d.ts","sourceRoot":"","sources":["../../src/worker/event-projection.ts"],"names":[],"mappings":"AAOA,qBAAa,iBAAiB;;IAW5B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAuE3B,GAAG,IAAI,MAAM;CAiBd"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// src/worker/event-projection.ts
|
|
2
|
+
var PiEventProjection = class {
|
|
3
|
+
#depth = 0;
|
|
4
|
+
#inString = false;
|
|
5
|
+
#escaped = false;
|
|
6
|
+
#expectKey = false;
|
|
7
|
+
#readingKey = false;
|
|
8
|
+
#keyToken = "";
|
|
9
|
+
#key = "";
|
|
10
|
+
#awaitingValue = false;
|
|
11
|
+
#skipping = false;
|
|
12
|
+
write(text) {
|
|
13
|
+
const parts = [];
|
|
14
|
+
let start = 0;
|
|
15
|
+
for (let i = 0; i < text.length; i++) {
|
|
16
|
+
const char = text[i];
|
|
17
|
+
if (char === "\n") {
|
|
18
|
+
if (this.#skipping) {
|
|
19
|
+
parts.push("!\n");
|
|
20
|
+
start = i + 1;
|
|
21
|
+
}
|
|
22
|
+
this.#reset();
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (this.#inString) {
|
|
26
|
+
if (this.#readingKey && this.#keyToken.length < 256) this.#keyToken += char;
|
|
27
|
+
if (this.#escaped) {
|
|
28
|
+
this.#escaped = false;
|
|
29
|
+
} else if (char === "\\") {
|
|
30
|
+
this.#escaped = true;
|
|
31
|
+
} else if (char === '"') {
|
|
32
|
+
this.#inString = false;
|
|
33
|
+
if (this.#readingKey) {
|
|
34
|
+
try {
|
|
35
|
+
this.#key = JSON.parse(this.#keyToken);
|
|
36
|
+
} catch {
|
|
37
|
+
this.#key = "";
|
|
38
|
+
}
|
|
39
|
+
this.#readingKey = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (this.#depth === 1 && this.#awaitingValue && !/[ \t\r]/.test(char)) {
|
|
45
|
+
this.#awaitingValue = false;
|
|
46
|
+
if (char === "[" && (this.#key === "messages" || this.#key === "toolResults")) {
|
|
47
|
+
parts.push(text.slice(start, i), "[]");
|
|
48
|
+
this.#skipping = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (char === '"') {
|
|
52
|
+
this.#inString = true;
|
|
53
|
+
this.#readingKey = this.#depth === 1 && this.#expectKey;
|
|
54
|
+
if (this.#readingKey) {
|
|
55
|
+
this.#keyToken = '"';
|
|
56
|
+
this.#expectKey = false;
|
|
57
|
+
}
|
|
58
|
+
} else if (char === "{" || char === "[") {
|
|
59
|
+
this.#depth++;
|
|
60
|
+
if (this.#depth === 1 && char === "{") this.#expectKey = true;
|
|
61
|
+
} else if (char === "}" || char === "]") {
|
|
62
|
+
this.#depth--;
|
|
63
|
+
if (this.#skipping && this.#depth === 1 && char === "]") {
|
|
64
|
+
this.#skipping = false;
|
|
65
|
+
start = i + 1;
|
|
66
|
+
}
|
|
67
|
+
} else if (this.#depth === 1 && char === ":") {
|
|
68
|
+
this.#awaitingValue = true;
|
|
69
|
+
} else if (this.#depth === 1 && char === ",") {
|
|
70
|
+
this.#expectKey = true;
|
|
71
|
+
this.#key = "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!this.#skipping) parts.push(text.slice(start));
|
|
75
|
+
return parts.join("");
|
|
76
|
+
}
|
|
77
|
+
// A child may exit without LF. Do not let a truncated discarded array look
|
|
78
|
+
// complete to the worker's final JSON.parse.
|
|
79
|
+
end() {
|
|
80
|
+
const incomplete = this.#skipping ? "!" : "";
|
|
81
|
+
this.#reset();
|
|
82
|
+
return incomplete;
|
|
83
|
+
}
|
|
84
|
+
#reset() {
|
|
85
|
+
this.#depth = 0;
|
|
86
|
+
this.#inString = false;
|
|
87
|
+
this.#escaped = false;
|
|
88
|
+
this.#expectKey = false;
|
|
89
|
+
this.#readingKey = false;
|
|
90
|
+
this.#keyToken = "";
|
|
91
|
+
this.#key = "";
|
|
92
|
+
this.#awaitingValue = false;
|
|
93
|
+
this.#skipping = false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
PiEventProjection
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=event-projection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/worker/event-projection.ts"],
|
|
4
|
+
"sourcesContent": ["// Pi repeats the entire history in agent_end.messages and the current tool\n// results in turn_end.toolResults. These top-level fields are not consumed by\n// the worker or transcript reader; authoritative messages arrive separately.\n// Elide them *before* buffering a JSONL record, not after JSON.parse. This keeps\n// image-heavy sessions bounded without dropping lifecycle flags after history.\n// This is a lexical projection, not a JSON validator. Retained JSON is parsed\n// by the worker. Discarded values are never accumulated; key tokens are bounded.\nexport class PiEventProjection {\n #depth = 0;\n #inString = false;\n #escaped = false;\n #expectKey = false;\n #readingKey = false;\n #keyToken = \"\";\n #key = \"\";\n #awaitingValue = false;\n #skipping = false;\n\n write(text: string): string {\n const parts: string[] = [];\n let start = 0;\n for (let i = 0; i < text.length; i++) {\n const char = text[i]!;\n // Only LF frames records. CR is retained for the worker's CRLF handling;\n // U+2028/U+2029 and escaped newlines are ordinary JSON string contents.\n if (char === \"\\n\") {\n if (this.#skipping) {\n // An incomplete discarded value must not manufacture a valid event.\n parts.push(\"!\\n\");\n start = i + 1;\n }\n this.#reset();\n continue;\n }\n if (this.#inString) {\n if (this.#readingKey && this.#keyToken.length < 256) this.#keyToken += char;\n if (this.#escaped) {\n this.#escaped = false;\n } else if (char === \"\\\\\") {\n this.#escaped = true;\n } else if (char === '\"') {\n this.#inString = false;\n if (this.#readingKey) {\n try {\n this.#key = JSON.parse(this.#keyToken) as string;\n } catch {\n this.#key = \"\";\n }\n this.#readingKey = false;\n }\n }\n continue;\n }\n if (this.#depth === 1 && this.#awaitingValue && !/[ \\t\\r]/.test(char)) {\n this.#awaitingValue = false;\n if (char === \"[\" && (this.#key === \"messages\" || this.#key === \"toolResults\")) {\n parts.push(text.slice(start, i), \"[]\");\n this.#skipping = true;\n }\n }\n if (char === '\"') {\n this.#inString = true;\n this.#readingKey = this.#depth === 1 && this.#expectKey;\n if (this.#readingKey) {\n this.#keyToken = '\"';\n this.#expectKey = false;\n }\n } else if (char === \"{\" || char === \"[\") {\n this.#depth++;\n if (this.#depth === 1 && char === \"{\") this.#expectKey = true;\n } else if (char === \"}\" || char === \"]\") {\n this.#depth--;\n if (this.#skipping && this.#depth === 1 && char === \"]\") {\n this.#skipping = false;\n start = i + 1;\n }\n } else if (this.#depth === 1 && char === \":\") {\n this.#awaitingValue = true;\n } else if (this.#depth === 1 && char === \",\") {\n this.#expectKey = true;\n this.#key = \"\";\n }\n }\n if (!this.#skipping) parts.push(text.slice(start));\n return parts.join(\"\");\n }\n\n // A child may exit without LF. Do not let a truncated discarded array look\n // complete to the worker's final JSON.parse.\n end(): string {\n const incomplete = this.#skipping ? \"!\" : \"\";\n this.#reset();\n return incomplete;\n }\n\n #reset(): void {\n this.#depth = 0;\n this.#inString = false;\n this.#escaped = false;\n this.#expectKey = false;\n this.#readingKey = false;\n this.#keyToken = \"\";\n this.#key = \"\";\n this.#awaitingValue = false;\n this.#skipping = false;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,YAAY;AAAA,EAEZ,MAAM,MAAsB;AAC1B,UAAM,QAAkB,CAAC;AACzB,QAAI,QAAQ;AACZ,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,OAAO,KAAK,CAAC;AAGnB,UAAI,SAAS,MAAM;AACjB,YAAI,KAAK,WAAW;AAElB,gBAAM,KAAK,KAAK;AAChB,kBAAQ,IAAI;AAAA,QACd;AACA,aAAK,OAAO;AACZ;AAAA,MACF;AACA,UAAI,KAAK,WAAW;AAClB,YAAI,KAAK,eAAe,KAAK,UAAU,SAAS,IAAK,MAAK,aAAa;AACvE,YAAI,KAAK,UAAU;AACjB,eAAK,WAAW;AAAA,QAClB,WAAW,SAAS,MAAM;AACxB,eAAK,WAAW;AAAA,QAClB,WAAW,SAAS,KAAK;AACvB,eAAK,YAAY;AACjB,cAAI,KAAK,aAAa;AACpB,gBAAI;AACF,mBAAK,OAAO,KAAK,MAAM,KAAK,SAAS;AAAA,YACvC,QAAQ;AACN,mBAAK,OAAO;AAAA,YACd;AACA,iBAAK,cAAc;AAAA,UACrB;AAAA,QACF;AACA;AAAA,MACF;AACA,UAAI,KAAK,WAAW,KAAK,KAAK,kBAAkB,CAAC,UAAU,KAAK,IAAI,GAAG;AACrE,aAAK,iBAAiB;AACtB,YAAI,SAAS,QAAQ,KAAK,SAAS,cAAc,KAAK,SAAS,gBAAgB;AAC7E,gBAAM,KAAK,KAAK,MAAM,OAAO,CAAC,GAAG,IAAI;AACrC,eAAK,YAAY;AAAA,QACnB;AAAA,MACF;AACA,UAAI,SAAS,KAAK;AAChB,aAAK,YAAY;AACjB,aAAK,cAAc,KAAK,WAAW,KAAK,KAAK;AAC7C,YAAI,KAAK,aAAa;AACpB,eAAK,YAAY;AACjB,eAAK,aAAa;AAAA,QACpB;AAAA,MACF,WAAW,SAAS,OAAO,SAAS,KAAK;AACvC,aAAK;AACL,YAAI,KAAK,WAAW,KAAK,SAAS,IAAK,MAAK,aAAa;AAAA,MAC3D,WAAW,SAAS,OAAO,SAAS,KAAK;AACvC,aAAK;AACL,YAAI,KAAK,aAAa,KAAK,WAAW,KAAK,SAAS,KAAK;AACvD,eAAK,YAAY;AACjB,kBAAQ,IAAI;AAAA,QACd;AAAA,MACF,WAAW,KAAK,WAAW,KAAK,SAAS,KAAK;AAC5C,aAAK,iBAAiB;AAAA,MACxB,WAAW,KAAK,WAAW,KAAK,SAAS,KAAK;AAC5C,aAAK,aAAa;AAClB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AACA,QAAI,CAAC,KAAK,UAAW,OAAM,KAAK,KAAK,MAAM,KAAK,CAAC;AACjD,WAAO,MAAM,KAAK,EAAE;AAAA,EACtB;AAAA;AAAA;AAAA,EAIA,MAAc;AACZ,UAAM,aAAa,KAAK,YAAY,MAAM;AAC1C,SAAK,OAAO;AACZ,WAAO;AAAA,EACT;AAAA,EAEA,SAAe;AACb,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,cAAc;AACnB,SAAK,YAAY;AACjB,SAAK,OAAO;AACZ,SAAK,iBAAiB;AACtB,SAAK,YAAY;AAAA,EACnB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PI_RECOVERY_TIMEOUT_MS = 60000;
|
|
2
|
+
/** Bounds stalled Pi error recovery, not healthy inference or tool execution. */
|
|
3
|
+
export declare class PiRecoveryWatchdog {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly fail;
|
|
6
|
+
constructor(fail: (error: string) => void);
|
|
7
|
+
arm(reason: string): void;
|
|
8
|
+
progress(): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=recovery-watchdog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-watchdog.d.ts","sourceRoot":"","sources":["../../src/worker/recovery-watchdog.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,iFAAiF;AACjF,qBAAa,kBAAkB;;IAKjB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAE1D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAazB,QAAQ,IAAI,IAAI;IAOhB,KAAK,IAAI,IAAI;IAMb,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/worker/recovery-watchdog.ts
|
|
2
|
+
var PI_RECOVERY_TIMEOUT_MS = 6e4;
|
|
3
|
+
var PiRecoveryWatchdog = class {
|
|
4
|
+
constructor(fail) {
|
|
5
|
+
this.fail = fail;
|
|
6
|
+
}
|
|
7
|
+
#timer;
|
|
8
|
+
#reason;
|
|
9
|
+
#disposed = false;
|
|
10
|
+
arm(reason) {
|
|
11
|
+
if (this.#disposed) return;
|
|
12
|
+
this.#reason = reason;
|
|
13
|
+
if (this.#timer) return;
|
|
14
|
+
this.#timer = setTimeout(() => {
|
|
15
|
+
const error = this.#reason;
|
|
16
|
+
this.dispose();
|
|
17
|
+
this.fail(`${error}; Pi made no recovery progress for ${PI_RECOVERY_TIMEOUT_MS}ms; terminating child`);
|
|
18
|
+
}, PI_RECOVERY_TIMEOUT_MS);
|
|
19
|
+
this.#timer.unref?.();
|
|
20
|
+
}
|
|
21
|
+
progress() {
|
|
22
|
+
if (!this.#reason || this.#disposed) return;
|
|
23
|
+
const reason = this.#reason;
|
|
24
|
+
this.clear();
|
|
25
|
+
this.arm(reason);
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
if (this.#timer) clearTimeout(this.#timer);
|
|
29
|
+
this.#timer = void 0;
|
|
30
|
+
this.#reason = void 0;
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.clear();
|
|
34
|
+
this.#disposed = true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
PI_RECOVERY_TIMEOUT_MS,
|
|
39
|
+
PiRecoveryWatchdog
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=recovery-watchdog.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/worker/recovery-watchdog.ts"],
|
|
4
|
+
"sourcesContent": ["export const PI_RECOVERY_TIMEOUT_MS = 60_000;\n\n/** Bounds stalled Pi error recovery, not healthy inference or tool execution. */\nexport class PiRecoveryWatchdog {\n #timer: ReturnType<typeof setTimeout> | undefined;\n #reason: string | undefined;\n #disposed = false;\n\n constructor(private readonly fail: (error: string) => void) {}\n\n arm(reason: string): void {\n if (this.#disposed) return;\n this.#reason = reason;\n // Repeated errors, retry announcements and lifecycle chatter are not progress.\n if (this.#timer) return;\n this.#timer = setTimeout(() => {\n const error = this.#reason;\n this.dispose();\n this.fail(`${error}; Pi made no recovery progress for ${PI_RECOVERY_TIMEOUT_MS}ms; terminating child`);\n }, PI_RECOVERY_TIMEOUT_MS);\n this.#timer.unref?.();\n }\n\n progress(): void {\n if (!this.#reason || this.#disposed) return;\n const reason = this.#reason;\n this.clear();\n this.arm(reason);\n }\n\n clear(): void {\n if (this.#timer) clearTimeout(this.#timer);\n this.#timer = undefined;\n this.#reason = undefined;\n }\n\n dispose(): void {\n this.clear();\n this.#disposed = true;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,yBAAyB;AAG/B,IAAM,qBAAN,MAAyB;AAAA,EAK9B,YAA6B,MAA+B;AAA/B;AAAA,EAAgC;AAAA,EAJ7D;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EAIZ,IAAI,QAAsB;AACxB,QAAI,KAAK,UAAW;AACpB,SAAK,UAAU;AAEf,QAAI,KAAK,OAAQ;AACjB,SAAK,SAAS,WAAW,MAAM;AAC7B,YAAM,QAAQ,KAAK;AACnB,WAAK,QAAQ;AACb,WAAK,KAAK,GAAG,KAAK,sCAAsC,sBAAsB,uBAAuB;AAAA,IACvG,GAAG,sBAAsB;AACzB,SAAK,OAAO,QAAQ;AAAA,EACtB;AAAA,EAEA,WAAiB;AACf,QAAI,CAAC,KAAK,WAAW,KAAK,UAAW;AACrC,UAAM,SAAS,KAAK;AACpB,SAAK,MAAM;AACX,SAAK,IAAI,MAAM;AAAA,EACjB;AAAA,EAEA,QAAc;AACZ,QAAI,KAAK,OAAQ,cAAa,KAAK,MAAM;AACzC,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,UAAgB;AACd,SAAK,MAAM;AACX,SAAK,YAAY;AAAA,EACnB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/worker.js
CHANGED
|
@@ -7,11 +7,21 @@ import crossSpawn from "cross-spawn";
|
|
|
7
7
|
import { StringDecoder } from "node:string_decoder";
|
|
8
8
|
var NODE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".cjs", ".mjs", ".ts", ".cts", ".mts"]);
|
|
9
9
|
var spawnCli = (command, args, options) => NODE_SCRIPT_EXTENSIONS.has(path.extname(command).toLowerCase()) ? crossSpawn(process.execPath, [command, ...args], options) : crossSpawn(command, [...args], options);
|
|
10
|
+
var loadWorkerEventProjection = async () => {
|
|
11
|
+
if (!import.meta.url.endsWith(".ts")) return import("./worker/event-projection.js");
|
|
12
|
+
const sourceModulePath = "./worker/event-projection.ts";
|
|
13
|
+
return import(sourceModulePath);
|
|
14
|
+
};
|
|
10
15
|
var loadWorkerModelControl = async () => {
|
|
11
16
|
if (!import.meta.url.endsWith(".ts")) return import("./worker/model-control.js");
|
|
12
17
|
const sourceModulePath = "./worker/model-control.ts";
|
|
13
18
|
return import(sourceModulePath);
|
|
14
19
|
};
|
|
20
|
+
var loadWorkerRecovery = async () => {
|
|
21
|
+
if (!import.meta.url.endsWith(".ts")) return import("./worker/recovery-watchdog.js");
|
|
22
|
+
const sourceModulePath = "./worker/recovery-watchdog.ts";
|
|
23
|
+
return import(sourceModulePath);
|
|
24
|
+
};
|
|
15
25
|
var loadAgentResult = async () => {
|
|
16
26
|
if (!import.meta.url.endsWith(".ts")) return import("./agents/result.js");
|
|
17
27
|
const sourceModulePath = "./agents/result.ts";
|
|
@@ -133,12 +143,14 @@ process.on("unhandledRejection", (error) => {
|
|
|
133
143
|
process.exit(1);
|
|
134
144
|
});
|
|
135
145
|
var main = async () => {
|
|
136
|
-
const [optionHelpers, loadedRunRecordHelpers, sessionExportHelpers, { parseStructuredValue, validateAgentResult }, { PiModelControl }] = await Promise.all([
|
|
146
|
+
const [optionHelpers, loadedRunRecordHelpers, sessionExportHelpers, { parseStructuredValue, validateAgentResult }, { PiModelControl }, { PiEventProjection }, { PiRecoveryWatchdog }] = await Promise.all([
|
|
137
147
|
loadWorkerOptions(),
|
|
138
148
|
loadWorkerRunRecord(),
|
|
139
149
|
loadWorkerSessionExport(),
|
|
140
150
|
loadAgentResult(),
|
|
141
|
-
loadWorkerModelControl()
|
|
151
|
+
loadWorkerModelControl(),
|
|
152
|
+
loadWorkerEventProjection(),
|
|
153
|
+
loadWorkerRecovery()
|
|
142
154
|
]);
|
|
143
155
|
runRecordHelpers = loadedRunRecordHelpers;
|
|
144
156
|
const {
|
|
@@ -270,6 +282,7 @@ ${schema}`
|
|
|
270
282
|
let outputBuffer = "";
|
|
271
283
|
let vedaOutput = "";
|
|
272
284
|
let vedaParsed;
|
|
285
|
+
const eventProjection = options.runner === "pi" ? new PiEventProjection() : void 0;
|
|
273
286
|
const outputDecoder = new StringDecoder("utf8");
|
|
274
287
|
const stderrDecoder = new StringDecoder("utf8");
|
|
275
288
|
let terminalStatus;
|
|
@@ -277,6 +290,36 @@ ${schema}`
|
|
|
277
290
|
let sawAgentError = false;
|
|
278
291
|
let retryPending = false;
|
|
279
292
|
const update = () => updateRunRecord(options.statusFile, record);
|
|
293
|
+
let killTimer;
|
|
294
|
+
let closeTimer;
|
|
295
|
+
const recoveryWatchdog = new PiRecoveryWatchdog((error) => failStalledChild(error));
|
|
296
|
+
const killChild = () => {
|
|
297
|
+
recoveryWatchdog.dispose();
|
|
298
|
+
if (closeTimer) clearTimeout(closeTimer);
|
|
299
|
+
terminateChild(child, "SIGTERM");
|
|
300
|
+
killTimer ??= setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS);
|
|
301
|
+
killTimer.unref();
|
|
302
|
+
child.stdin?.end();
|
|
303
|
+
};
|
|
304
|
+
const failStalledChild = (error) => {
|
|
305
|
+
if (terminalStatus) return;
|
|
306
|
+
terminalStatus = "failed";
|
|
307
|
+
terminalError = error;
|
|
308
|
+
record.error = error;
|
|
309
|
+
update();
|
|
310
|
+
appendLog(`${JSON.stringify({ type: "fabric_recovery_error", error })}
|
|
311
|
+
`);
|
|
312
|
+
killChild();
|
|
313
|
+
};
|
|
314
|
+
const closeChild = () => {
|
|
315
|
+
child.stdin?.end();
|
|
316
|
+
recoveryWatchdog.clear();
|
|
317
|
+
if (closeTimer || killTimer) return;
|
|
318
|
+
closeTimer = setTimeout(() => failStalledChild(
|
|
319
|
+
`${terminalError ?? "Child Pi settled"}; child did not exit after stdin closed for ${KILL_GRACE_MS}ms`
|
|
320
|
+
), KILL_GRACE_MS);
|
|
321
|
+
closeTimer.unref();
|
|
322
|
+
};
|
|
280
323
|
const modelControl = new PiModelControl(options.id, options.model, thinking, {
|
|
281
324
|
send(frame) {
|
|
282
325
|
if (terminalStatus) return;
|
|
@@ -306,9 +349,7 @@ ${schema}`
|
|
|
306
349
|
update();
|
|
307
350
|
appendLog(`${JSON.stringify({ type: "fabric_model_error", requestedModel: options.model, model: record.model, error })}
|
|
308
351
|
`);
|
|
309
|
-
|
|
310
|
-
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
311
|
-
child.stdin?.end();
|
|
352
|
+
killChild();
|
|
312
353
|
}
|
|
313
354
|
});
|
|
314
355
|
const lastEmittedUsage = emptyUsage();
|
|
@@ -357,9 +398,7 @@ ${schema}`
|
|
|
357
398
|
child.stdin.write(`${JSON.stringify(frame)}
|
|
358
399
|
`);
|
|
359
400
|
},
|
|
360
|
-
close
|
|
361
|
-
child.stdin?.end();
|
|
362
|
-
},
|
|
401
|
+
close: closeChild,
|
|
363
402
|
update(status) {
|
|
364
403
|
record.compaction = status;
|
|
365
404
|
update();
|
|
@@ -371,9 +410,7 @@ ${schema}`
|
|
|
371
410
|
if (total <= options.maxTokens) return;
|
|
372
411
|
terminalStatus = "timed_out";
|
|
373
412
|
terminalError = `Fabric token limit reached: ${total} tokens (limit ${options.maxTokens} set by agents.maxTokensPerChild); terminating child. The count is cumulative across the run and includes cache reads/writes, so it grows every turn; raise or disable agents.maxTokensPerChild in /fabric settings (0 disables), or split the task into smaller agent runs.`;
|
|
374
|
-
|
|
375
|
-
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
376
|
-
child.stdin?.end();
|
|
413
|
+
killChild();
|
|
377
414
|
};
|
|
378
415
|
const claudeTools = /* @__PURE__ */ new Map();
|
|
379
416
|
const claudeCompletedUsage = emptyUsage();
|
|
@@ -632,17 +669,33 @@ ${text}
|
|
|
632
669
|
modelControl.observeAssistant(message);
|
|
633
670
|
}
|
|
634
671
|
}
|
|
672
|
+
if (event.type === "message_update" && !terminalStatus) {
|
|
673
|
+
const delta = event.assistantMessageEvent;
|
|
674
|
+
if (delta && ["text_delta", "thinking_delta", "toolcall_delta"].includes(String(delta.type)) && typeof delta.delta === "string" && delta.delta.length > 0) recoveryWatchdog.progress();
|
|
675
|
+
}
|
|
635
676
|
if (event.type === "agent_start") {
|
|
636
677
|
emitLifecycle("pi.agent_start");
|
|
637
678
|
retryPending = false;
|
|
638
|
-
|
|
639
|
-
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (event.type === "auto_retry_start" && !terminalStatus) {
|
|
682
|
+
retryPending = true;
|
|
683
|
+
recoveryWatchdog.arm(terminalError ?? stringField(event.errorMessage) ?? "Pi retry stalled");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (event.type === "auto_retry_end" && !terminalStatus) {
|
|
687
|
+
retryPending = false;
|
|
688
|
+
if (event.success === false) {
|
|
689
|
+
sawAgentError = true;
|
|
690
|
+
terminalError = stringField(event.finalError) ?? terminalError ?? "Pi retries exhausted";
|
|
691
|
+
recoveryWatchdog.arm(terminalError);
|
|
692
|
+
}
|
|
640
693
|
return;
|
|
641
694
|
}
|
|
642
695
|
if (event.type === "response" && event.command === "prompt" && event.success === false) {
|
|
643
696
|
sawAgentError = true;
|
|
644
697
|
if (!terminalStatus) terminalError = typeof event.error === "string" ? event.error : "Pi rejected the prompt";
|
|
645
|
-
|
|
698
|
+
closeChild();
|
|
646
699
|
return;
|
|
647
700
|
}
|
|
648
701
|
if (event.type === "extension_ui_request") {
|
|
@@ -711,10 +764,12 @@ ${text}
|
|
|
711
764
|
});
|
|
712
765
|
modelControl.observeAssistant(messageRecord);
|
|
713
766
|
enforceTokenLimit();
|
|
714
|
-
if (messageRecord.stopReason === "error" && !terminalStatus) {
|
|
767
|
+
if ((messageRecord.stopReason === "error" || messageRecord.stopReason === "aborted") && !terminalStatus) {
|
|
715
768
|
sawAgentError = true;
|
|
716
769
|
terminalError = assistantError(messageRecord);
|
|
770
|
+
recoveryWatchdog.arm(terminalError);
|
|
717
771
|
} else {
|
|
772
|
+
recoveryWatchdog.clear();
|
|
718
773
|
sawAgentError = false;
|
|
719
774
|
if (!terminalStatus) terminalError = void 0;
|
|
720
775
|
}
|
|
@@ -724,6 +779,7 @@ ${text}
|
|
|
724
779
|
if (event.type === "agent_end") {
|
|
725
780
|
emitLifecycle("pi.agent_end", { willRetry: event.willRetry === true });
|
|
726
781
|
retryPending = event.willRetry === true;
|
|
782
|
+
if (retryPending && !terminalStatus) recoveryWatchdog.arm(terminalError ?? "Pi announced a retry but did not resume");
|
|
727
783
|
return;
|
|
728
784
|
}
|
|
729
785
|
if (event.type === "agent_settled") {
|
|
@@ -882,7 +938,7 @@ ${schema}`
|
|
|
882
938
|
terminalStatus = "failed";
|
|
883
939
|
terminalError = artifactPath ? `Agent emitted an oversized event line; first ${prefix.length} characters saved to: ${artifactPath}` : "Agent emitted an oversized event line";
|
|
884
940
|
outputBuffer = "";
|
|
885
|
-
|
|
941
|
+
killChild();
|
|
886
942
|
};
|
|
887
943
|
child.stdout?.on("data", (chunk) => {
|
|
888
944
|
const decoded = outputDecoder.write(chunk);
|
|
@@ -890,7 +946,7 @@ ${schema}`
|
|
|
890
946
|
vedaOutput += decoded;
|
|
891
947
|
return;
|
|
892
948
|
}
|
|
893
|
-
outputBuffer += decoded;
|
|
949
|
+
outputBuffer += eventProjection ? eventProjection.write(decoded) : decoded;
|
|
894
950
|
while (true) {
|
|
895
951
|
const newline = outputBuffer.indexOf("\n");
|
|
896
952
|
if (newline < 0) {
|
|
@@ -925,16 +981,14 @@ ${schema}`
|
|
|
925
981
|
if (options.runner === "pi" && !modelControl.ready) {
|
|
926
982
|
terminalError += "; Pi model admission did not complete; task was not sent";
|
|
927
983
|
}
|
|
928
|
-
|
|
929
|
-
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
984
|
+
killChild();
|
|
930
985
|
}, options.timeoutMs);
|
|
931
986
|
timeout.unref();
|
|
932
987
|
const stop = () => {
|
|
933
988
|
if (terminalStatus) return;
|
|
934
989
|
terminalStatus = "stopped";
|
|
935
990
|
terminalError = "Agent stopped";
|
|
936
|
-
|
|
937
|
-
setTimeout(() => terminateChild(child, "SIGKILL"), KILL_GRACE_MS).unref();
|
|
991
|
+
killChild();
|
|
938
992
|
};
|
|
939
993
|
process.once("SIGTERM", stop);
|
|
940
994
|
process.once("SIGINT", stop);
|
|
@@ -950,6 +1004,9 @@ ${schema}`
|
|
|
950
1004
|
if (steerTimer) clearInterval(steerTimer);
|
|
951
1005
|
if (claudeCloseTimer) clearTimeout(claudeCloseTimer);
|
|
952
1006
|
clearTimeout(timeout);
|
|
1007
|
+
if (killTimer) clearTimeout(killTimer);
|
|
1008
|
+
if (closeTimer) clearTimeout(closeTimer);
|
|
1009
|
+
recoveryWatchdog.dispose();
|
|
953
1010
|
if (options.runner === "pi" && !modelControl.ready && !terminalStatus) {
|
|
954
1011
|
terminalStatus = "failed";
|
|
955
1012
|
terminalError = `Child Pi exited before requested model admission completed; task was not sent${stderr.trim() ? `: ${stderr.trim()}` : ""}`;
|
|
@@ -958,7 +1015,8 @@ ${schema}`
|
|
|
958
1015
|
if (options.runner === "veda") {
|
|
959
1016
|
vedaOutput += outputDecoder.end();
|
|
960
1017
|
} else {
|
|
961
|
-
|
|
1018
|
+
const tail = outputDecoder.end();
|
|
1019
|
+
outputBuffer += eventProjection ? eventProjection.write(tail) + eventProjection.end() : tail;
|
|
962
1020
|
}
|
|
963
1021
|
recordStderr(stderrDecoder.end());
|
|
964
1022
|
if (options.runner === "veda") {
|