pi-better-harness 0.63.2 → 0.63.3
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/CHANGELOG.md +6 -0
- package/node_modules/pi-better-background-tasks/package.json +2 -2
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
- package/node_modules/pi-better-subagents/managed-failure-worker.mjs +12 -4
- package/node_modules/pi-better-subagents/managed-launch-host.ts +43 -27
- package/node_modules/pi-better-subagents/package.json +2 -2
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-better-background-tasks",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.12",
|
|
4
4
|
"description": "Pi extension for durable background shell tasks, watchers, logs, and status inspection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"vitest": "^3.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"pi-better-server": "0.11.
|
|
71
|
+
"pi-better-server": "0.11.3",
|
|
72
72
|
"proper-lockfile": "^4.1.2"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"darwin-arm64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"2f924d7cd4e1ad5d794bec95a137106a8f6b5f2bd04369c58d2aec5a901500ec"},"sha256":"78daba2279b9bfb5226c8fd52abe24c208edca13da755e7ed80fda3e6ef968f9"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"darwin-x64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"07abb16092f12eb644915b9ff5d83db6f31ab12d47157e4761d736baedec8c24"},"sha256":"f0c562aaa9eecc049cfca30c65e9d48ea6910afcf960ee6b5b32a871c4ec1229"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"linux-arm64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"b92440ca99f4ba61421b7c9abe31e2592ade59769d645576b0b1e5126b31ff8e"},"sha256":"4953e9134db701131d66d461f2c2854a5263b0c3f0a40c611f44b2ef0d272da9"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"linux-x64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"36b7199bf4ffcc7f153fa098e8e0e52405b55e34cc23e878b4263d401a4cb1c1"},"sha256":"22489d051dad976692873e71cd5b8e48791c440131bd9e60e609cd7ee616698d"}
|
|
@@ -3,10 +3,18 @@ import { parentPort, workerData } from "node:worker_threads";
|
|
|
3
3
|
import { collectRunFailures } from "./failures.ts";
|
|
4
4
|
import { readMeta } from "./registry.ts";
|
|
5
5
|
const revoked = new Int32Array(workerData.revocation);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
parentPort.on("message", ({ ids, cancelled }) => {
|
|
7
|
+
let nextProgress = performance.now() + workerData.progressIntervalMs;
|
|
8
|
+
const assertCurrent = () => {
|
|
9
|
+
if (!Number.isSafeInteger(workerData.epoch) || Atomics.load(revoked, 0)) throw new Error("failure-fold-owner-revoked");
|
|
10
|
+
if (Atomics.load(cancelled, 0)) throw new Error("failure-fold-batch-cancelled");
|
|
11
|
+
// Called while advancing through IDs and log chunks. A blocked read cannot renew the deadline.
|
|
12
|
+
const now = performance.now();
|
|
13
|
+
if (now >= nextProgress) {
|
|
14
|
+
nextProgress = now + workerData.progressIntervalMs;
|
|
15
|
+
parentPort.postMessage({ progress: true });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
10
18
|
try {
|
|
11
19
|
assertCurrent();
|
|
12
20
|
if (!Array.isArray(ids) || ids.length > 128) throw new Error("failure-fold-batch-overflow");
|
|
@@ -26,8 +26,8 @@ const failureFoldRevocations = new Map<string, Int32Array>();
|
|
|
26
26
|
export class ManagedSubagentHost {
|
|
27
27
|
private foldRevocation = new Int32Array(new SharedArrayBuffer(4));
|
|
28
28
|
private failureWorker?: Worker;
|
|
29
|
-
private
|
|
30
|
-
private failureResponse?: { resolve(): void; reject(error: Error): void };
|
|
29
|
+
private failureWorkerExit?: Promise<number>;
|
|
30
|
+
private failureResponse?: { resolve(): void; reject(error: Error): void; progress(): void };
|
|
31
31
|
private current: any;
|
|
32
32
|
private api!: ExtensionAPI;
|
|
33
33
|
private session: any;
|
|
@@ -153,7 +153,7 @@ export class ManagedSubagentHost {
|
|
|
153
153
|
listActiveMetasForParent(pid).filter(meta => meta.spawnPidStartTime === start && effectiveStatus(meta) === "running").length
|
|
154
154
|
+ this.journal.unresolvedAttempts().filter((attempt: any) => attempt.capacityOwner?.pid === pid && attempt.capacityOwner?.start === start && !readMeta(attempt.id)).length);
|
|
155
155
|
get cleaningRegistry() { return this.registryCleanup !== undefined; }
|
|
156
|
-
get busy() { return this.pending > 0 || Boolean(this.failureResponse) || this.cleaningRegistry; }
|
|
156
|
+
get busy() { return this.pending > 0 || Boolean(this.failureResponse || this.failureWorkerExit) || this.cleaningRegistry; }
|
|
157
157
|
status() {
|
|
158
158
|
return { owner: "server", instanceId: this.instance, runtimeEpoch: this.epoch,
|
|
159
159
|
lifecycle: { ...this.lifecycleMetrics, activeDeadlines: this.healthDue.size },
|
|
@@ -460,48 +460,64 @@ export class ManagedSubagentHost {
|
|
|
460
460
|
let release: (() => void) | undefined;
|
|
461
461
|
let physicalExit: Promise<number> | undefined;
|
|
462
462
|
const result = this.tail.catch(() => undefined).then(async () => {
|
|
463
|
+
if (this.failureWorkerExit) await this.failureWorkerExit;
|
|
463
464
|
release = this.enterControl?.();
|
|
464
465
|
if (this.enterControl && !release) throw new Error("runtime-overloaded: failure fold source capacity");
|
|
465
466
|
this.journal.current(this.epoch);
|
|
466
467
|
if (Atomics.load(this.foldRevocation, 0)) throw new Error("failure-fold-owner-revoked");
|
|
467
|
-
if (this.failureWorkerError) throw this.failureWorkerError;
|
|
468
468
|
if (ids.length > 128) throw new Error("failure-fold-batch-overflow");
|
|
469
469
|
if (!this.failureWorker) {
|
|
470
470
|
const worker = this.failureWorker = new Worker(new URL("./managed-failure-worker.mjs", import.meta.url), {
|
|
471
|
-
execArgv: [], workerData: { root: this.root, epoch: this.epoch, revocation: this.foldRevocation.buffer
|
|
471
|
+
execArgv: [], workerData: { root: this.root, epoch: this.epoch, revocation: this.foldRevocation.buffer,
|
|
472
|
+
progressIntervalMs: Math.max(1, Math.floor(this.verificationMs / 4)) },
|
|
473
|
+
});
|
|
474
|
+
let failure: Error | undefined;
|
|
475
|
+
worker.on("error", error => { failure = error; });
|
|
476
|
+
worker.on("exit", code => {
|
|
477
|
+
if (this.failureWorker !== worker) return;
|
|
478
|
+
this.failureWorker = undefined;
|
|
479
|
+
this.failureResponse?.reject(failure ?? new Error(`failure-fold-worker-exited: ${code}`));
|
|
472
480
|
});
|
|
473
|
-
const fail = (error: Error) => {
|
|
474
|
-
this.failureWorkerError = error;
|
|
475
|
-
this.failureResponse?.reject(error); this.failureResponse = undefined;
|
|
476
|
-
};
|
|
477
481
|
worker.on("message", message => {
|
|
478
|
-
|
|
479
|
-
if (message.error)
|
|
482
|
+
if (message.progress) this.failureResponse?.progress();
|
|
483
|
+
else if (message.error) this.failureResponse?.reject(new Error(message.error));
|
|
484
|
+
else if (message.complete) this.failureResponse?.resolve();
|
|
480
485
|
});
|
|
481
|
-
worker.on("error", fail);
|
|
482
|
-
worker.on("exit", code => fail(new Error(`failure-fold-worker-exited: ${code}`)));
|
|
483
486
|
worker.unref();
|
|
484
487
|
}
|
|
488
|
+
const worker = this.failureWorker;
|
|
489
|
+
const cancelled = new Int32Array(new SharedArrayBuffer(4));
|
|
490
|
+
const now = Date.now();
|
|
491
|
+
const record = this.foldRecord = { kind: 'failure-fold', ids: [...ids], lastProgressAt: now, nextDeadline: now + this.verificationMs,
|
|
492
|
+
recovery: 'revoke-unacknowledged-fold-generation-at-existing-verification-deadline' };
|
|
485
493
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
486
494
|
try {
|
|
487
495
|
await new Promise<void>((resolve, reject) => {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const error = new Error("failure-fold-verification-deadline: source worker did not acknowledge");
|
|
493
|
-
Atomics.store(this.foldRevocation, 0, 1);
|
|
494
|
-
this.failureWorkerError = error;
|
|
496
|
+
const onStall = () => {
|
|
497
|
+
// This batch lost its worker. The journal owner can retry after it exits.
|
|
498
|
+
Atomics.store(cancelled, 0, 1);
|
|
499
|
+
physicalExit = this.failureWorkerExit = worker.terminate();
|
|
495
500
|
this.failureResponse = undefined;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
this.
|
|
501
|
+
reject(new Error("failure-fold-verification-deadline: source worker did not acknowledge"));
|
|
502
|
+
};
|
|
503
|
+
timer = setTimeout(onStall, this.verificationMs);
|
|
504
|
+
this.failureResponse = { resolve, reject, progress: () => {
|
|
505
|
+
record.lastProgressAt = Date.now();
|
|
506
|
+
record.nextDeadline = record.lastProgressAt + this.verificationMs;
|
|
507
|
+
clearTimeout(timer);
|
|
508
|
+
timer = setTimeout(onStall, this.verificationMs);
|
|
509
|
+
} };
|
|
510
|
+
worker.postMessage({ ids, cancelled });
|
|
500
511
|
});
|
|
501
|
-
} finally {
|
|
512
|
+
} finally {
|
|
513
|
+
this.failureResponse = undefined;
|
|
514
|
+
this.foldRecord = undefined;
|
|
515
|
+
if (timer) clearTimeout(timer);
|
|
516
|
+
}
|
|
502
517
|
}).finally(() => {
|
|
503
|
-
if (physicalExit)
|
|
504
|
-
|
|
518
|
+
if (physicalExit) {
|
|
519
|
+
void physicalExit.then(() => { this.failureWorkerExit = undefined; release?.(); }, () => undefined);
|
|
520
|
+
} else release?.();
|
|
505
521
|
});
|
|
506
522
|
this.tail = result;
|
|
507
523
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-better-subagents",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.5",
|
|
4
4
|
"description": "Pi extension for detached, sandboxed subagent runs that keep the foreground session free.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@earendil-works/pi-tui": "*"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"pi-better-server": "0.11.
|
|
84
|
+
"pi-better-server": "0.11.3",
|
|
85
85
|
"proper-lockfile": "^4.1.2",
|
|
86
86
|
"shell-quote": "1.12.0",
|
|
87
87
|
"smol-toml": "1.9.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"darwin-arm64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"2f924d7cd4e1ad5d794bec95a137106a8f6b5f2bd04369c58d2aec5a901500ec"},"sha256":"78daba2279b9bfb5226c8fd52abe24c208edca13da755e7ed80fda3e6ef968f9"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"darwin-x64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"07abb16092f12eb644915b9ff5d83db6f31ab12d47157e4761d736baedec8c24"},"sha256":"f0c562aaa9eecc049cfca30c65e9d48ea6910afcf960ee6b5b32a871c4ec1229"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"linux-arm64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"b92440ca99f4ba61421b7c9abe31e2592ade59769d645576b0b1e5126b31ff8e"},"sha256":"4953e9134db701131d66d461f2c2854a5263b0c3f0a40c611f44b2ef0d272da9"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"7a4cc7258e17ff17a3c55e3628e6b1da2fda1e8691cb756239ee7fcaaf346c2b","piSdkVersion":"1.7.0","nodeVersion":"24.14.1","platform":"linux-x64","dependencyLockDigest":"97fbfa01a6e5a49f4f29f5c2048549391417c545cbdd52ec799629aa867d8653","protocolVersion":1,"serverVersion":"0.11.3","contentId":"36b7199bf4ffcc7f153fa098e8e0e52405b55e34cc23e878b4263d401a4cb1c1"},"sha256":"22489d051dad976692873e71cd5b8e48791c440131bd9e60e609cd7ee616698d"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-better-harness",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.3",
|
|
4
4
|
"description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, Goals, and Todo lists.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"@xterm/xterm": "6.0.0",
|
|
75
75
|
"marked": "18.0.5",
|
|
76
76
|
"openai": "6.26.0",
|
|
77
|
-
"pi-better-background-tasks": "0.21.
|
|
77
|
+
"pi-better-background-tasks": "0.21.12",
|
|
78
78
|
"pi-better-goal": "0.18.4",
|
|
79
79
|
"pi-better-sandbox": "0.15.2",
|
|
80
|
-
"pi-better-server": "0.11.
|
|
80
|
+
"pi-better-server": "0.11.3",
|
|
81
81
|
"pi-better-ssh": "0.1.7",
|
|
82
|
-
"pi-better-subagents": "0.41.
|
|
82
|
+
"pi-better-subagents": "0.41.5",
|
|
83
83
|
"proper-lockfile": "^4.1.2",
|
|
84
84
|
"shell-quote": "1.12.0",
|
|
85
85
|
"smol-toml": "1.9.0",
|