@cydm/pie 4.4.2 → 4.4.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/dist/builtin/extensions/ask-user/index.js +6 -6
- package/dist/builtin/extensions/changelog/index.js +1 -1
- package/dist/builtin/extensions/cron/index.js +55 -7
- package/dist/builtin/extensions/document-attachments/index.js +1 -1
- package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
- package/dist/builtin/extensions/im-forward/README.md +3 -1
- package/dist/builtin/extensions/im-forward/index.js +98 -41
- package/dist/builtin/extensions/init/index.js +1 -1
- package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
- package/dist/builtin/extensions/memory/index.js +9 -11
- package/dist/builtin/extensions/pie-ipc/index.js +45 -18
- package/dist/builtin/extensions/pie-proc/index.js +18 -12
- package/dist/builtin/extensions/plan-mode/index.js +6 -6
- package/dist/builtin/extensions/subagent/index.js +9 -11
- package/dist/builtin/extensions/todo/index.js +6 -6
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +24 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +86 -21
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +6 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/{cli-CHC7XYFU.js → cli-NLPMVDGG.js} +32 -4
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +220 -22
- package/dist/chunks/{auth-storage-RABPRJ6T.js → auth-storage-C3FZMT7J.js} +3 -3
- package/dist/chunks/{chunk-R7VO46EK.js → chunk-3W3SXVPB.js} +5 -4
- package/dist/chunks/{chunk-IPLMGAML.js → chunk-5KI4Y4LA.js} +1 -1
- package/dist/chunks/{chunk-YNTIOWCD.js → chunk-BLDI2GRF.js} +5 -5
- package/dist/chunks/{chunk-UCKOXAME.js → chunk-CBDQJMUI.js} +9 -44
- package/dist/chunks/chunk-CGSFBWOM.js +100 -0
- package/dist/chunks/{chunk-OFLKAWI4.js → chunk-JMKLTTZQ.js} +89 -100
- package/dist/chunks/{chunk-7LTQLJJF.js → chunk-LAJXWOKS.js} +15 -10
- package/dist/chunks/{chunk-RZGYXAJU.js → chunk-LZQXQOPJ.js} +1 -12
- package/dist/chunks/{chunk-EQOI6RZV.js → chunk-NHV2CALB.js} +3 -5
- package/dist/chunks/{chunk-OV7SLSHR.js → chunk-SW2E33UL.js} +2 -4
- package/dist/chunks/{chunk-BPSCGGVF.js → chunk-XXGYUYXI.js} +1 -1
- package/dist/chunks/{chunk-XO3NM7BB.js → chunk-Y3I2UV5Y.js} +3 -3
- package/dist/chunks/{chunk-IZDNZW3S.js → chunk-Z2FKA2ZH.js} +8 -8
- package/dist/chunks/chunk-ZPJ3BNQB.js +126 -0
- package/dist/chunks/{config-HF2PDLN5.js → config-4EOI5NOU.js} +2 -4
- package/dist/chunks/{manager-cli-BYCF4RKN.js → manager-cli-WEHNUV5T.js} +3 -5
- package/dist/chunks/{model-registry-7FNIUYPF.js → model-registry-3XAHXXTA.js} +5 -5
- package/dist/chunks/{src-OVWRBWKU.js → src-B44QWSGM.js} +4 -4
- package/dist/chunks/{src-A5YI46OD.js → src-CLE5ILN4.js} +6 -6
- package/dist/chunks/{src-OA3TP6DS.js → src-EGXFJ3WA.js} +5 -5
- package/dist/chunks/{src-TF2RAGRU.js → src-Q7LU27C2.js} +3 -3
- package/dist/chunks/{test-stream-7YZDGBPO.js → test-stream-OR3EJBNF.js} +3 -3
- package/dist/cli.js +128 -132
- package/package.json +3 -3
- package/dist/chunks/chunk-7KLWHWZD.js +0 -164
|
@@ -4344,7 +4344,7 @@ var init_permissions2 = __esm({
|
|
|
4344
4344
|
// vendor/computer-use-axi/src/broker-server.ts
|
|
4345
4345
|
init_test_backend_guard();
|
|
4346
4346
|
import { createHash as createHash4, randomUUID as randomUUID8 } from "node:crypto";
|
|
4347
|
-
import { chmodSync as chmodSync2, lstatSync as lstatSync4, readFileSync as
|
|
4347
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync4, readFileSync as readFileSync5, unlinkSync as unlinkSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
4348
4348
|
import net3 from "node:net";
|
|
4349
4349
|
import path14 from "node:path";
|
|
4350
4350
|
|
|
@@ -5368,9 +5368,9 @@ function artifactsRoot(env = process.env) {
|
|
|
5368
5368
|
|
|
5369
5369
|
// vendor/computer-use-axi/src/bridge.ts
|
|
5370
5370
|
init_test_backend_guard();
|
|
5371
|
-
import { spawn as spawn4 } from "node:child_process";
|
|
5371
|
+
import { execFileSync, spawn as spawn4 } from "node:child_process";
|
|
5372
5372
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
5373
|
-
import { constants as fsConstants5, mkdtempSync } from "node:fs";
|
|
5373
|
+
import { constants as fsConstants5, mkdirSync as mkdirSync6, mkdtempSync, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5374
5374
|
import { access as access4 } from "node:fs/promises";
|
|
5375
5375
|
import net2 from "node:net";
|
|
5376
5376
|
import os4 from "node:os";
|
|
@@ -8195,29 +8195,113 @@ async function waitForExit(child, timeoutMs) {
|
|
|
8195
8195
|
child.once("exit", finish);
|
|
8196
8196
|
});
|
|
8197
8197
|
}
|
|
8198
|
+
function escapeEre(value) {
|
|
8199
|
+
return value.replace(/[\\^$.|?*+()[{]/g, (ch) => `\\${ch}`);
|
|
8200
|
+
}
|
|
8201
|
+
async function scanProfileHolders(profile) {
|
|
8202
|
+
if (process.platform === "win32") return { kind: "ok", pids: [] };
|
|
8203
|
+
const pattern = `user-data-dir=${escapeEre(profile)}([^a-zA-Z0-9_-]|$)`;
|
|
8204
|
+
return await new Promise((resolve2) => {
|
|
8205
|
+
execFile("pgrep", ["-f", pattern], { timeout: 1500 }, (error, stdout) => {
|
|
8206
|
+
if (!error) {
|
|
8207
|
+
const pids = String(stdout ?? "").split(/\s+/).map(Number).filter((n) => Number.isInteger(n) && n > 0 && n !== process.pid);
|
|
8208
|
+
resolve2({ kind: "ok", pids });
|
|
8209
|
+
return;
|
|
8210
|
+
}
|
|
8211
|
+
const code = error.code;
|
|
8212
|
+
if (code === 1) {
|
|
8213
|
+
resolve2({ kind: "none" });
|
|
8214
|
+
return;
|
|
8215
|
+
}
|
|
8216
|
+
resolve2({ kind: "unknown" });
|
|
8217
|
+
});
|
|
8218
|
+
});
|
|
8219
|
+
}
|
|
8220
|
+
async function verifyProfileHolder(pid, profile) {
|
|
8221
|
+
if (process.platform === "darwin") {
|
|
8222
|
+
return await new Promise((resolve2) => {
|
|
8223
|
+
execFile("ps", ["-o", "command=", "-p", String(pid)], { timeout: 1500 }, (error, stdout) => {
|
|
8224
|
+
if (error) {
|
|
8225
|
+
resolve2(false);
|
|
8226
|
+
return;
|
|
8227
|
+
}
|
|
8228
|
+
const command = String(stdout ?? "").trim();
|
|
8229
|
+
if (!command) {
|
|
8230
|
+
resolve2(false);
|
|
8231
|
+
return;
|
|
8232
|
+
}
|
|
8233
|
+
resolve2(commandIncludesExactUserDataDir(command, profile));
|
|
8234
|
+
});
|
|
8235
|
+
});
|
|
8236
|
+
}
|
|
8237
|
+
return await new Promise((resolve2) => {
|
|
8238
|
+
execFile("cat", [`/proc/${pid}/cmdline`], { timeout: 1500 }, (error, stdout) => {
|
|
8239
|
+
if (error) {
|
|
8240
|
+
resolve2(false);
|
|
8241
|
+
return;
|
|
8242
|
+
}
|
|
8243
|
+
const argv = String(stdout ?? "").split("\0").filter(Boolean);
|
|
8244
|
+
resolve2(argv.some((arg, i) => arg === `--user-data-dir=${profile}` || arg === "--user-data-dir" && argv[i + 1] === profile));
|
|
8245
|
+
});
|
|
8246
|
+
});
|
|
8247
|
+
}
|
|
8248
|
+
function commandIncludesExactUserDataDir(command, profile) {
|
|
8249
|
+
const marker = "--user-data-dir=";
|
|
8250
|
+
let index = command.indexOf(marker);
|
|
8251
|
+
while (index !== -1) {
|
|
8252
|
+
const start = index + marker.length;
|
|
8253
|
+
if (command.startsWith(profile, start)) {
|
|
8254
|
+
const after = start + profile.length;
|
|
8255
|
+
if (after === command.length || /[^a-zA-Z0-9_-]/.test(command[after])) return true;
|
|
8256
|
+
}
|
|
8257
|
+
index = command.indexOf(marker, index + 1);
|
|
8258
|
+
}
|
|
8259
|
+
return false;
|
|
8260
|
+
}
|
|
8261
|
+
async function signalTreeOfProfile(profile, signal) {
|
|
8262
|
+
const scan = await scanProfileHolders(profile);
|
|
8263
|
+
if (scan.kind !== "ok") return scan.kind === "none" ? 0 : -1;
|
|
8264
|
+
let signalled = 0;
|
|
8265
|
+
for (const pid of scan.pids) {
|
|
8266
|
+
if (!await verifyProfileHolder(pid, profile)) continue;
|
|
8267
|
+
try {
|
|
8268
|
+
process.kill(pid, signal);
|
|
8269
|
+
signalled++;
|
|
8270
|
+
} catch {
|
|
8271
|
+
}
|
|
8272
|
+
}
|
|
8273
|
+
if (signalled > 0) await new Promise((resolve2) => setTimeout(resolve2, 150));
|
|
8274
|
+
return signalled;
|
|
8275
|
+
}
|
|
8276
|
+
async function countProfileHolders(profile) {
|
|
8277
|
+
const scan = await scanProfileHolders(profile);
|
|
8278
|
+
if (scan.kind === "none") return 0;
|
|
8279
|
+
if (scan.kind === "unknown") return -1;
|
|
8280
|
+
let count = 0;
|
|
8281
|
+
for (const pid of scan.pids) {
|
|
8282
|
+
if (await verifyProfileHolder(pid, profile)) count++;
|
|
8283
|
+
}
|
|
8284
|
+
return count;
|
|
8285
|
+
}
|
|
8198
8286
|
async function releaseOwnedBrowser(child, port, profile) {
|
|
8199
|
-
|
|
8287
|
+
const mainAlive = () => Boolean(child && child.exitCode === null && child.signalCode === null);
|
|
8288
|
+
if (mainAlive()) {
|
|
8200
8289
|
if (port) await requestBrowserClose(port).catch(() => void 0);
|
|
8201
8290
|
if (!await waitForExit(child, 700)) {
|
|
8202
8291
|
if (process.platform === "win32" && child.pid) {
|
|
8203
8292
|
const pid = child.pid;
|
|
8204
8293
|
await new Promise((resolve2) => {
|
|
8205
|
-
execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], {
|
|
8206
|
-
windowsHide: true,
|
|
8207
|
-
timeout: 2e3
|
|
8208
|
-
}, () => resolve2());
|
|
8294
|
+
execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 2e3 }, () => resolve2());
|
|
8209
8295
|
});
|
|
8210
8296
|
if (!await waitForExit(child, 1500)) {
|
|
8211
8297
|
try {
|
|
8212
8298
|
process.kill(pid);
|
|
8213
8299
|
} catch {
|
|
8214
8300
|
}
|
|
8215
|
-
if (!await waitForExit(child, 2e3)) {
|
|
8216
|
-
throw new Error(`Owned browser process ${pid} survived taskkill escalation.`);
|
|
8217
|
-
}
|
|
8301
|
+
if (!await waitForExit(child, 2e3)) throw new Error(`Owned browser process ${pid} survived taskkill escalation.`);
|
|
8218
8302
|
}
|
|
8219
|
-
} else
|
|
8220
|
-
|
|
8303
|
+
} else {
|
|
8304
|
+
child.kill("SIGTERM");
|
|
8221
8305
|
if (!await waitForExit(child, 2e3)) {
|
|
8222
8306
|
child.kill("SIGKILL");
|
|
8223
8307
|
if (!await waitForExit(child, 2e3)) throw new Error("Owned browser did not exit.");
|
|
@@ -8225,6 +8309,20 @@ async function releaseOwnedBrowser(child, port, profile) {
|
|
|
8225
8309
|
}
|
|
8226
8310
|
}
|
|
8227
8311
|
}
|
|
8312
|
+
if (profile && process.platform !== "win32") {
|
|
8313
|
+
await signalTreeOfProfile(profile, "SIGTERM");
|
|
8314
|
+
let holders = await countProfileHolders(profile);
|
|
8315
|
+
if (holders > 0) {
|
|
8316
|
+
await signalTreeOfProfile(profile, "SIGKILL");
|
|
8317
|
+
holders = await countProfileHolders(profile);
|
|
8318
|
+
}
|
|
8319
|
+
if (holders > 0) {
|
|
8320
|
+
throw new Error(`Owned browser helpers survived SIGKILL (${holders} pids hold ${profile}); refusing to remove the profile while processes may still write it.`);
|
|
8321
|
+
}
|
|
8322
|
+
if (holders < 0) {
|
|
8323
|
+
throw new Error(`Cannot verify that no process holds ${profile} (process scan unavailable); refusing to remove the profile.`);
|
|
8324
|
+
}
|
|
8325
|
+
}
|
|
8228
8326
|
if (profile) {
|
|
8229
8327
|
const resolved = path12.resolve(profile);
|
|
8230
8328
|
if (path12.dirname(resolved) !== path12.resolve(os3.tmpdir()) || !/^pie-(chrome|helium)-cdp-/.test(path12.basename(resolved))) {
|
|
@@ -8237,6 +8335,7 @@ async function releaseOwnedBrowserState(owner) {
|
|
|
8237
8335
|
await releaseOwnedBrowser(owner.managedBrowser, owner.managedBrowserCdpPort, owner.managedBrowserProfileDir);
|
|
8238
8336
|
owner.managedBrowser = void 0;
|
|
8239
8337
|
owner.managedBrowserProfileDir = void 0;
|
|
8338
|
+
owner.managedBrowserPid = void 0;
|
|
8240
8339
|
}
|
|
8241
8340
|
|
|
8242
8341
|
// vendor/computer-use-axi/src/root-selection.ts
|
|
@@ -8543,6 +8642,102 @@ function expireStateForArtifactEviction(stateId2) {
|
|
|
8543
8642
|
}
|
|
8544
8643
|
function persistRuntimeBridgeState() {
|
|
8545
8644
|
}
|
|
8645
|
+
function managedBrowserManifestPath() {
|
|
8646
|
+
return path13.join(stateRootDir(process.env), "managed-browser.json");
|
|
8647
|
+
}
|
|
8648
|
+
function writeManagedBrowserManifest(entry) {
|
|
8649
|
+
try {
|
|
8650
|
+
if (!entry) {
|
|
8651
|
+
rmSync(managedBrowserManifestPath(), { force: true });
|
|
8652
|
+
return;
|
|
8653
|
+
}
|
|
8654
|
+
mkdirSync6(stateRootDir(process.env), { recursive: true });
|
|
8655
|
+
writeFileSync3(managedBrowserManifestPath(), JSON.stringify({ ...entry, startedAt: Date.now() }), { encoding: "utf8" });
|
|
8656
|
+
} catch {
|
|
8657
|
+
}
|
|
8658
|
+
}
|
|
8659
|
+
function clearManagedBrowserManifest() {
|
|
8660
|
+
writeManagedBrowserManifest(void 0);
|
|
8661
|
+
}
|
|
8662
|
+
function killManagedBrowserFast() {
|
|
8663
|
+
try {
|
|
8664
|
+
const pid = runtimeState.managedBrowserPid;
|
|
8665
|
+
if (pid !== void 0) {
|
|
8666
|
+
try {
|
|
8667
|
+
process.kill(pid, "SIGKILL");
|
|
8668
|
+
} catch {
|
|
8669
|
+
}
|
|
8670
|
+
}
|
|
8671
|
+
const profile = runtimeState.managedBrowserProfileDir;
|
|
8672
|
+
if (profile) {
|
|
8673
|
+
try {
|
|
8674
|
+
const out = execFileSync("pgrep", ["-f", `user-data-dir=${escapeEre(profile)}([^a-zA-Z0-9_-]|$)`], { timeout: 1500, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"] });
|
|
8675
|
+
for (const pidText of String(out).split(/\s+/)) {
|
|
8676
|
+
const pid2 = Number(pidText);
|
|
8677
|
+
if (Number.isInteger(pid2) && pid2 > 0 && pid2 !== process.pid) {
|
|
8678
|
+
try {
|
|
8679
|
+
process.kill(pid2, "SIGKILL");
|
|
8680
|
+
} catch {
|
|
8681
|
+
}
|
|
8682
|
+
}
|
|
8683
|
+
}
|
|
8684
|
+
} catch {
|
|
8685
|
+
}
|
|
8686
|
+
}
|
|
8687
|
+
} catch {
|
|
8688
|
+
}
|
|
8689
|
+
}
|
|
8690
|
+
function processAlive(pid) {
|
|
8691
|
+
try {
|
|
8692
|
+
process.kill(pid, 0);
|
|
8693
|
+
return true;
|
|
8694
|
+
} catch (error) {
|
|
8695
|
+
return error.code === "EPERM";
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
async function manifestPidIsOurBrowser(pid, profileDir) {
|
|
8699
|
+
if (pid === void 0 || !processAlive(pid)) return false;
|
|
8700
|
+
return await verifyProfileHolder(pid, profileDir);
|
|
8701
|
+
}
|
|
8702
|
+
async function sweepOrphanedManagedBrowser() {
|
|
8703
|
+
let manifest;
|
|
8704
|
+
try {
|
|
8705
|
+
manifest = JSON.parse(readFileSync4(managedBrowserManifestPath(), "utf8"));
|
|
8706
|
+
} catch {
|
|
8707
|
+
clearManagedBrowserManifest();
|
|
8708
|
+
return;
|
|
8709
|
+
}
|
|
8710
|
+
const profileDir = typeof manifest.profileDir === "string" ? manifest.profileDir : void 0;
|
|
8711
|
+
const port = typeof manifest.port === "string" ? manifest.port : void 0;
|
|
8712
|
+
const pid = typeof manifest.pid === "number" ? manifest.pid : void 0;
|
|
8713
|
+
if (!profileDir) {
|
|
8714
|
+
clearManagedBrowserManifest();
|
|
8715
|
+
return;
|
|
8716
|
+
}
|
|
8717
|
+
const resolved = path13.resolve(profileDir);
|
|
8718
|
+
const tmp = path13.resolve(os4.tmpdir());
|
|
8719
|
+
if (path13.dirname(resolved) !== tmp || !/^pie-(chrome|helium)-cdp-/.test(path13.basename(resolved))) {
|
|
8720
|
+
clearManagedBrowserManifest();
|
|
8721
|
+
return;
|
|
8722
|
+
}
|
|
8723
|
+
if (port) await requestBrowserClose(port).catch(() => void 0);
|
|
8724
|
+
if (pid !== void 0 && await manifestPidIsOurBrowser(pid, resolved)) {
|
|
8725
|
+
try {
|
|
8726
|
+
process.kill(pid, "SIGTERM");
|
|
8727
|
+
} catch {
|
|
8728
|
+
}
|
|
8729
|
+
await new Promise((resolve2) => setTimeout(resolve2, 400));
|
|
8730
|
+
if (processAlive(pid)) {
|
|
8731
|
+
try {
|
|
8732
|
+
process.kill(pid, "SIGKILL");
|
|
8733
|
+
} catch {
|
|
8734
|
+
}
|
|
8735
|
+
await new Promise((resolve2) => setTimeout(resolve2, 300));
|
|
8736
|
+
}
|
|
8737
|
+
}
|
|
8738
|
+
await releaseOwnedBrowser(void 0, void 0, resolved);
|
|
8739
|
+
clearManagedBrowserManifest();
|
|
8740
|
+
}
|
|
8546
8741
|
function operationState() {
|
|
8547
8742
|
return savedStates.current();
|
|
8548
8743
|
}
|
|
@@ -8579,6 +8774,8 @@ async function releaseComputerUseSession() {
|
|
|
8579
8774
|
runtimeState.previousCdpPort = void 0;
|
|
8580
8775
|
if (runtimeState.managedBrowser === void 0) {
|
|
8581
8776
|
runtimeState.managedBrowserCdpPort = void 0;
|
|
8777
|
+
runtimeState.managedBrowserPid = void 0;
|
|
8778
|
+
clearManagedBrowserManifest();
|
|
8582
8779
|
}
|
|
8583
8780
|
savedStates.clear();
|
|
8584
8781
|
clearStoredOutputs();
|
|
@@ -10259,17 +10456,11 @@ async function performLaunchBrowser(params, signal) {
|
|
|
10259
10456
|
];
|
|
10260
10457
|
const managedBrowser = spawn4(executable, args, { stdio: "ignore", detached: true });
|
|
10261
10458
|
managedBrowser.unref();
|
|
10262
|
-
const stalePid = runtimeState.managedBrowserPid;
|
|
10263
|
-
if (stalePid !== void 0 && stalePid !== managedBrowser.pid) {
|
|
10264
|
-
try {
|
|
10265
|
-
process.kill(stalePid, "SIGTERM");
|
|
10266
|
-
} catch {
|
|
10267
|
-
}
|
|
10268
|
-
}
|
|
10269
10459
|
runtimeState.managedBrowser = managedBrowser;
|
|
10270
10460
|
runtimeState.managedBrowserCdpPort = String(port);
|
|
10271
10461
|
runtimeState.managedBrowserPid = managedBrowser.pid;
|
|
10272
10462
|
runtimeState.managedBrowserProfileDir = profileDir;
|
|
10463
|
+
writeManagedBrowserManifest({ pid: managedBrowser.pid, port: String(port), profileDir });
|
|
10273
10464
|
persistRuntimeBridgeState();
|
|
10274
10465
|
setManagedCdpPort(String(port));
|
|
10275
10466
|
try {
|
|
@@ -10280,6 +10471,7 @@ async function performLaunchBrowser(params, signal) {
|
|
|
10280
10471
|
setManagedCdpPort(void 0);
|
|
10281
10472
|
runtimeState.managedBrowserCdpPort = void 0;
|
|
10282
10473
|
runtimeState.previousCdpPort = void 0;
|
|
10474
|
+
clearManagedBrowserManifest();
|
|
10283
10475
|
}
|
|
10284
10476
|
throw error;
|
|
10285
10477
|
}
|
|
@@ -10314,6 +10506,7 @@ async function performEvaluateBrowser(params) {
|
|
|
10314
10506
|
const result = await cdpEvaluateForContext(contextId, expression);
|
|
10315
10507
|
if (!result) throw new Error(`Browser context '${contextId}' is no longer available. Observe it again.`);
|
|
10316
10508
|
const successor = await refreshBrowserSnapshot(contextId, "evaluate_browser", { stateId: baseSnapshot.snapshotId, outline: baseSnapshot.outline });
|
|
10509
|
+
if (!successor.details) throw new Error("Browser refresh produced no observation details.");
|
|
10317
10510
|
const details = {
|
|
10318
10511
|
tool: "evaluate_browser",
|
|
10319
10512
|
baseStateId: baseSnapshot.snapshotId,
|
|
@@ -10432,7 +10625,7 @@ function acquireBootstrapLock(directory) {
|
|
|
10432
10625
|
const lockPath = path14.join(directory, "broker.lock");
|
|
10433
10626
|
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
10434
10627
|
try {
|
|
10435
|
-
|
|
10628
|
+
writeFileSync4(lockPath, String(process.pid), { flag: "wx", mode: 384 });
|
|
10436
10629
|
return () => {
|
|
10437
10630
|
try {
|
|
10438
10631
|
unlinkSync4(lockPath);
|
|
@@ -10443,7 +10636,7 @@ function acquireBootstrapLock(directory) {
|
|
|
10443
10636
|
if (error.code !== "EEXIST") throw error;
|
|
10444
10637
|
let ownerPid = 0;
|
|
10445
10638
|
try {
|
|
10446
|
-
ownerPid = Number.parseInt(
|
|
10639
|
+
ownerPid = Number.parseInt(readFileSync5(lockPath, "utf8").trim(), 10);
|
|
10447
10640
|
} catch {
|
|
10448
10641
|
}
|
|
10449
10642
|
if (Number.isInteger(ownerPid) && ownerPid > 0 && isAlive(ownerPid)) {
|
|
@@ -10997,6 +11190,10 @@ async function startBroker(options = {}) {
|
|
|
10997
11190
|
artifacts.cleanupOtherGenerations(generation);
|
|
10998
11191
|
} catch {
|
|
10999
11192
|
}
|
|
11193
|
+
try {
|
|
11194
|
+
await sweepOrphanedManagedBrowser();
|
|
11195
|
+
} catch {
|
|
11196
|
+
}
|
|
11000
11197
|
configureEngineRuntime({
|
|
11001
11198
|
generation,
|
|
11002
11199
|
helperGeneration: helperGeneration2,
|
|
@@ -11152,6 +11349,7 @@ async function main() {
|
|
|
11152
11349
|
process.on("uncaughtException", (error) => {
|
|
11153
11350
|
process.stderr.write(`computer-use-axi broker fatal: ${error instanceof Error ? error.stack ?? error.message : String(error)}
|
|
11154
11351
|
`);
|
|
11352
|
+
killManagedBrowserFast();
|
|
11155
11353
|
process.exit(1);
|
|
11156
11354
|
});
|
|
11157
11355
|
process.on("unhandledRejection", (reason) => {
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
AuthStorage,
|
|
4
4
|
FileAuthStorageBackend,
|
|
5
5
|
InMemoryAuthStorageBackend
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-SW2E33UL.js";
|
|
7
|
+
import "./chunk-CBDQJMUI.js";
|
|
8
|
+
import "./chunk-LZQXQOPJ.js";
|
|
9
9
|
export {
|
|
10
10
|
AuthStorage,
|
|
11
11
|
FileAuthStorageBackend,
|
|
@@ -41,13 +41,13 @@ import {
|
|
|
41
41
|
TypeSystemPolicy,
|
|
42
42
|
Union,
|
|
43
43
|
Unknown
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-XXGYUYXI.js";
|
|
45
45
|
import {
|
|
46
46
|
__commonJS,
|
|
47
47
|
__export,
|
|
48
48
|
__require,
|
|
49
49
|
__toESM
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-LZQXQOPJ.js";
|
|
51
51
|
|
|
52
52
|
// ../../node_modules/partial-json/dist/options.js
|
|
53
53
|
var require_options = __commonJS({
|
|
@@ -5171,6 +5171,7 @@ var CAPTURE_ENABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"])
|
|
|
5171
5171
|
var MAX_CAPTURE_BYTES = 4 * 1024 * 1024;
|
|
5172
5172
|
var DUMP_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
5173
5173
|
var MAX_DUMP_FILES = 400;
|
|
5174
|
+
var DUMP_FILE_NAME = /^pie-sse-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z__[A-Za-z0-9._-]+__[A-Za-z0-9._-]+\.ndjson$/;
|
|
5174
5175
|
var MAX_PRUNE_STAT = 200;
|
|
5175
5176
|
var MAX_PRUNE_UNLINK = 50;
|
|
5176
5177
|
function isSseDumpEnabled(env = readEnv()) {
|
|
@@ -5246,7 +5247,7 @@ var BoundedSseDumpSink = class {
|
|
|
5246
5247
|
async pruneOld() {
|
|
5247
5248
|
try {
|
|
5248
5249
|
const names = await this.fs.readdir(this.directory);
|
|
5249
|
-
const eligible = names.filter((name) =>
|
|
5250
|
+
const eligible = names.filter((name) => DUMP_FILE_NAME.test(name));
|
|
5250
5251
|
if (eligible.length <= MAX_DUMP_FILES && eligible.length === 0) return;
|
|
5251
5252
|
const sample = eligible.slice(0, MAX_PRUNE_STAT);
|
|
5252
5253
|
const dated = [];
|
|
@@ -5287,7 +5288,7 @@ function openSseDumpSink(requestId, modelLabel) {
|
|
|
5287
5288
|
const dir = sseDumpDirectory();
|
|
5288
5289
|
if (!dir) return NULL_SSE_DUMP_SINK;
|
|
5289
5290
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
5290
|
-
return new BoundedSseDumpSink(dir,
|
|
5291
|
+
return new BoundedSseDumpSink(dir, `pie-sse-${stamp}__${sanitize(modelLabel)}__${sanitize(requestId)}.ndjson`, fs);
|
|
5291
5292
|
} catch {
|
|
5292
5293
|
return NULL_SSE_DUMP_SINK;
|
|
5293
5294
|
}
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
parseEntryIdSeq,
|
|
14
14
|
readAncestryPage,
|
|
15
15
|
requestInteraction
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-Y3I2UV5Y.js";
|
|
17
17
|
import {
|
|
18
18
|
Agent,
|
|
19
19
|
getToolCallerIdentity
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5KI4Y4LA.js";
|
|
21
21
|
import {
|
|
22
22
|
AssistantMessageEventStream,
|
|
23
23
|
completeSimple,
|
|
@@ -25,14 +25,14 @@ import {
|
|
|
25
25
|
getFileSystem,
|
|
26
26
|
hashText,
|
|
27
27
|
streamSimple
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-3W3SXVPB.js";
|
|
29
29
|
import {
|
|
30
30
|
Type
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-XXGYUYXI.js";
|
|
32
32
|
import {
|
|
33
33
|
__commonJS,
|
|
34
34
|
__toESM
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-LZQXQOPJ.js";
|
|
36
36
|
|
|
37
37
|
// ../../node_modules/shell-quote/quote.js
|
|
38
38
|
var require_quote = __commonJS({
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
__esm,
|
|
4
|
-
__export
|
|
5
|
-
} from "./chunk-RZGYXAJU.js";
|
|
6
2
|
|
|
7
3
|
// src/config.ts
|
|
8
|
-
var config_exports = {};
|
|
9
|
-
__export(config_exports, {
|
|
10
|
-
APP_NAME: () => APP_NAME,
|
|
11
|
-
CONFIG_DIR_NAME: () => CONFIG_DIR_NAME,
|
|
12
|
-
ENV_AGENT_DIR: () => ENV_AGENT_DIR,
|
|
13
|
-
VERSION: () => VERSION,
|
|
14
|
-
getAgentDir: () => getAgentDir,
|
|
15
|
-
getBuiltinDir: () => getBuiltinDir,
|
|
16
|
-
getConfigDir: () => getConfigDir,
|
|
17
|
-
getCustomThemesDir: () => getCustomThemesDir,
|
|
18
|
-
getDebugLogPath: () => getDebugLogPath,
|
|
19
|
-
getKeybindingsPath: () => getKeybindingsPath,
|
|
20
|
-
getLogsDir: () => getLogsDir,
|
|
21
|
-
getPackageDir: () => getPackageDir,
|
|
22
|
-
getPackageJsonPath: () => getPackageJsonPath,
|
|
23
|
-
getProjectSettingsPath: () => getProjectSettingsPath,
|
|
24
|
-
getRuntimeLogPath: () => getRuntimeLogPath,
|
|
25
|
-
getSessionsDir: () => getSessionsDir,
|
|
26
|
-
getSettingsPath: () => getSettingsPath,
|
|
27
|
-
getThemesDir: () => getThemesDir,
|
|
28
|
-
isBunRuntime: () => isBunRuntime,
|
|
29
|
-
migrateConfigFromAgentDir: () => migrateConfigFromAgentDir,
|
|
30
|
-
resolveSessionsDirOverride: () => resolveSessionsDirOverride
|
|
31
|
-
});
|
|
32
4
|
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|
|
33
5
|
import { homedir } from "os";
|
|
34
6
|
import { dirname, isAbsolute, join } from "path";
|
|
35
7
|
import { fileURLToPath } from "url";
|
|
8
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
var __dirname = dirname(__filename);
|
|
10
|
+
var isBunRuntime = !!process.versions.bun;
|
|
36
11
|
function getPackageDir() {
|
|
37
12
|
const envDir = process.env.PIE_PACKAGE_DIR;
|
|
38
13
|
if (envDir) {
|
|
@@ -65,6 +40,11 @@ function getBuiltinDir() {
|
|
|
65
40
|
function getPackageJsonPath() {
|
|
66
41
|
return join(getPackageDir(), "package.json");
|
|
67
42
|
}
|
|
43
|
+
var pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
44
|
+
var APP_NAME = "pie";
|
|
45
|
+
var CONFIG_DIR_NAME = ".pie";
|
|
46
|
+
var VERSION = pkg.version;
|
|
47
|
+
var ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
|
|
68
48
|
function getConfigDir() {
|
|
69
49
|
const envDir = process.env[ENV_AGENT_DIR];
|
|
70
50
|
if (envDir !== void 0 && envDir !== "") {
|
|
@@ -158,19 +138,6 @@ function migrateConfigFromAgentDir() {
|
|
|
158
138
|
}
|
|
159
139
|
}
|
|
160
140
|
}
|
|
161
|
-
var __filename, __dirname, isBunRuntime, pkg, APP_NAME, CONFIG_DIR_NAME, VERSION, ENV_AGENT_DIR;
|
|
162
|
-
var init_config = __esm({
|
|
163
|
-
"src/config.ts"() {
|
|
164
|
-
__filename = fileURLToPath(import.meta.url);
|
|
165
|
-
__dirname = dirname(__filename);
|
|
166
|
-
isBunRuntime = !!process.versions.bun;
|
|
167
|
-
pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
168
|
-
APP_NAME = "pie";
|
|
169
|
-
CONFIG_DIR_NAME = ".pie";
|
|
170
|
-
VERSION = pkg.version;
|
|
171
|
-
ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
141
|
|
|
175
142
|
export {
|
|
176
143
|
isBunRuntime,
|
|
@@ -193,7 +160,5 @@ export {
|
|
|
193
160
|
getLogsDir,
|
|
194
161
|
getRuntimeLogPath,
|
|
195
162
|
getDebugLogPath,
|
|
196
|
-
migrateConfigFromAgentDir
|
|
197
|
-
config_exports,
|
|
198
|
-
init_config
|
|
163
|
+
migrateConfigFromAgentDir
|
|
199
164
|
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getSessionsDir
|
|
4
|
+
} from "./chunk-CBDQJMUI.js";
|
|
5
|
+
import {
|
|
6
|
+
claimOwnership,
|
|
7
|
+
pidDefinitelyDead,
|
|
8
|
+
readOwnership
|
|
9
|
+
} from "./chunk-ZPJ3BNQB.js";
|
|
10
|
+
|
|
11
|
+
// src/app/session-ownership.ts
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
function sessionOwnersRoot() {
|
|
15
|
+
const sessions = getSessionsDir();
|
|
16
|
+
fs.mkdirSync(sessions, { recursive: true, mode: 448 });
|
|
17
|
+
return path.join(path.dirname(fs.realpathSync(sessions)), "session-owners");
|
|
18
|
+
}
|
|
19
|
+
function lockPath(sessionId) {
|
|
20
|
+
return path.join(sessionOwnersRoot(), `${sessionId.replace(/[^a-zA-Z0-9._-]/g, "_")}.lock`);
|
|
21
|
+
}
|
|
22
|
+
function unavailable(sessionId) {
|
|
23
|
+
return { pid: -1, holder: "(unreadable or contended lock)", heartbeatAt: Date.now(), sessionId };
|
|
24
|
+
}
|
|
25
|
+
function sessionOwnerAlive(sessionId, _now = Date.now()) {
|
|
26
|
+
try {
|
|
27
|
+
const info = readOwnership(lockPath(sessionId), (v) => v.sessionId === sessionId);
|
|
28
|
+
return info && !pidDefinitelyDead(info.pid) ? info : void 0;
|
|
29
|
+
} catch {
|
|
30
|
+
return unavailable(sessionId);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function claimSessionOwnership(sessionId, holder, onLost) {
|
|
34
|
+
try {
|
|
35
|
+
const result = claimOwnership(
|
|
36
|
+
lockPath(sessionId),
|
|
37
|
+
{ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId },
|
|
38
|
+
(v) => v.sessionId === sessionId
|
|
39
|
+
);
|
|
40
|
+
if ("holder" in result) return result;
|
|
41
|
+
let stopped = false;
|
|
42
|
+
const heartbeat = () => {
|
|
43
|
+
if (stopped) return;
|
|
44
|
+
try {
|
|
45
|
+
if (result.handle.heartbeat()) return;
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
stopped = true;
|
|
49
|
+
clearInterval(timer);
|
|
50
|
+
try {
|
|
51
|
+
onLost?.("takeover");
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const timer = setInterval(heartbeat, 5e3);
|
|
56
|
+
timer.unref();
|
|
57
|
+
return { handle: { heartbeat, release: () => {
|
|
58
|
+
stopped = true;
|
|
59
|
+
clearInterval(timer);
|
|
60
|
+
try {
|
|
61
|
+
result.handle.release();
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
} } };
|
|
65
|
+
} catch {
|
|
66
|
+
return { holder: unavailable(sessionId) };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var SessionOwnershipLifecycle = class {
|
|
70
|
+
handle;
|
|
71
|
+
adoptedRelease;
|
|
72
|
+
adopt(release) {
|
|
73
|
+
this.adoptedRelease = release;
|
|
74
|
+
}
|
|
75
|
+
set(handle) {
|
|
76
|
+
this.adoptedRelease?.();
|
|
77
|
+
this.adoptedRelease = void 0;
|
|
78
|
+
this.handle = handle;
|
|
79
|
+
}
|
|
80
|
+
release() {
|
|
81
|
+
this.adoptedRelease?.();
|
|
82
|
+
this.adoptedRelease = void 0;
|
|
83
|
+
this.handle?.release();
|
|
84
|
+
this.handle = void 0;
|
|
85
|
+
}
|
|
86
|
+
claim(sessionId) {
|
|
87
|
+
if (!sessionId) return;
|
|
88
|
+
const claim = claimSessionOwnership(sessionId, process.env.PIE_IPC_DISPLAY_NAME || `tui-pid-${process.pid}`);
|
|
89
|
+
if ("handle" in claim) this.handle = claim.handle;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function liveSessionHolder(sessionId) {
|
|
93
|
+
return sessionOwnerAlive(sessionId);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
claimSessionOwnership,
|
|
98
|
+
SessionOwnershipLifecycle,
|
|
99
|
+
liveSessionHolder
|
|
100
|
+
};
|