@cydm/pie 4.12.1 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/ask-user/index.js +1 -1
- package/dist/builtin/extensions/cron/index.js +177 -28
- package/dist/builtin/extensions/im-forward/index.js +472 -53
- package/dist/builtin/extensions/memory/index.js +8 -8
- package/dist/builtin/extensions/pie-proc/index.js +7 -7
- package/dist/builtin/extensions/plan-mode/index.js +1 -1
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +15 -6
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +163 -14
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-D2OVVTF6.js +1603 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-K7ESY3XD.js → cli-DJ36OIQ4.js} +98 -109
- package/dist/builtin/skills/computer-use-axi/SKILL.md +11 -7
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +43 -17
- package/dist/chunks/{chunk-QSXBPTOA.js → chunk-3CJLYX5J.js} +4 -4
- package/dist/chunks/{chunk-W37NAT3N.js → chunk-5MCIBDAM.js} +5 -5
- package/dist/chunks/{chunk-WTBLV6F5.js → chunk-5PCLBIOO.js} +23 -9
- package/dist/chunks/{chunk-KW46ND3S.js → chunk-AKC7NMP4.js} +126 -15
- package/dist/chunks/{chunk-26ILLZKQ.js → chunk-NOSNHMA2.js} +1 -1
- package/dist/chunks/{host-image-fallback-NXY36VO2.js → host-image-fallback-MZK633DK.js} +1 -1
- package/dist/chunks/{memory-git-C3S276QJ.js → memory-git-Q3UBYOJ4.js} +2 -2
- package/dist/chunks/{read-file-understanding-ZCBNCQHG.js → read-file-understanding-KCJMSOS7.js} +3 -3
- package/dist/chunks/{src-7CU7OTQS.js → src-QI47K3W3.js} +1 -1
- package/dist/cli.js +48 -48
- package/package.json +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +0 -795
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createAskUserCapability
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
5
5
|
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
6
6
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
7
7
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
@@ -590,6 +590,63 @@ var Store = class {
|
|
|
590
590
|
return "updated";
|
|
591
591
|
});
|
|
592
592
|
}
|
|
593
|
+
/** Auto-recover an enabled, repeating managed process job left in `blocked`
|
|
594
|
+
* (e.g. after upgrading past a broken release or fixing a stale binary).
|
|
595
|
+
* Preserves paused (`enabled=false`), running, one-shot (`at`), and
|
|
596
|
+
* count-exhausted jobs. Optionally refreshes `command` atomically in the
|
|
597
|
+
* same transaction. */
|
|
598
|
+
recoverBlockedProcess(managedBy, opts) {
|
|
599
|
+
this.disabledMarker(managedBy);
|
|
600
|
+
if (opts?.command !== void 0) {
|
|
601
|
+
const command = opts.command;
|
|
602
|
+
if (!Array.isArray(command) || command.length === 0 || !command.every((c) => typeof c === "string" && c.length > 0))
|
|
603
|
+
throw new Error("process command must be a non-empty string array");
|
|
604
|
+
if (command.some((part) => part.includes("\0")))
|
|
605
|
+
throw new Error("process command arguments must not contain NUL bytes");
|
|
606
|
+
const probePrompt = JSON.stringify({ command, managedBy });
|
|
607
|
+
if (probePrompt.length > 16e3)
|
|
608
|
+
throw new Error("process command exceeds the 16000-character job budget");
|
|
609
|
+
if (!parseProcessCommand({ id: "probe", sessionId: PROCESS_SESSION_ID, cwd: this.dir, prompt: probePrompt, schedule: { every: 60 }, enabled: true, next: 1, state: "ready" }))
|
|
610
|
+
throw new Error("invalid process command (1..32 args, each 1..4096 chars, no NUL bytes)");
|
|
611
|
+
}
|
|
612
|
+
const now = opts?.now ?? Date.now();
|
|
613
|
+
let auditInfo;
|
|
614
|
+
const result = this.transaction((s) => {
|
|
615
|
+
const existing = s.jobs.find((j) => j.sessionId === PROCESS_SESSION_ID && parseProcessCommand(j)?.managedBy === managedBy);
|
|
616
|
+
if (!existing || !existing.enabled || existing.state !== "blocked") return { recovered: false };
|
|
617
|
+
if ("at" in existing.schedule) return { recovered: false };
|
|
618
|
+
if (existing.remaining !== void 0 && existing.remaining <= 0) return { recovered: false };
|
|
619
|
+
if (existing.occurrence !== void 0 && !Number.isSafeInteger(existing.occurrence)) return { recovered: false };
|
|
620
|
+
const next = nextTime(existing.schedule, Math.max(now, existing.occurrence ?? now));
|
|
621
|
+
if (next === null) return { recovered: false };
|
|
622
|
+
const previousError = existing.error;
|
|
623
|
+
let commandUpdated = false;
|
|
624
|
+
if (opts?.command) {
|
|
625
|
+
const current = parseProcessCommand(existing)?.command ?? [];
|
|
626
|
+
if (current.length !== opts.command.length || current.some((v, i) => v !== opts.command[i])) {
|
|
627
|
+
existing.prompt = JSON.stringify({ command: opts.command, managedBy });
|
|
628
|
+
commandUpdated = true;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
existing.state = "ready";
|
|
632
|
+
existing.next = next;
|
|
633
|
+
delete existing.target;
|
|
634
|
+
delete existing.deliveryStarted;
|
|
635
|
+
delete existing.error;
|
|
636
|
+
delete existing.consecutiveFailures;
|
|
637
|
+
delete existing.noticedError;
|
|
638
|
+
auditInfo = {
|
|
639
|
+
jobId: existing.id,
|
|
640
|
+
cwd: existing.cwd,
|
|
641
|
+
detail: `startup auto-recovery of blocked managed ${managedBy} job${previousError ? ` (was: ${previousError.slice(0, 200)})` : ""}${commandUpdated ? "; command refreshed" : ""}`
|
|
642
|
+
};
|
|
643
|
+
return { recovered: true, jobId: existing.id, previousError, next, commandUpdated };
|
|
644
|
+
});
|
|
645
|
+
if (auditInfo) {
|
|
646
|
+
this.audit({ kind: "auto-retry", jobId: auditInfo.jobId, sessionId: PROCESS_SESSION_ID, cwd: auditInfo.cwd, detail: auditInfo.detail });
|
|
647
|
+
}
|
|
648
|
+
return result;
|
|
649
|
+
}
|
|
593
650
|
/** Opt-out and removal share the state writer mutex with on/default registration. */
|
|
594
651
|
disableProcess(managedBy) {
|
|
595
652
|
this.disabledMarker(managedBy);
|
|
@@ -982,7 +1039,34 @@ function runWorker(job, signal, cli = process.argv[1], configDir) {
|
|
|
982
1039
|
});
|
|
983
1040
|
}
|
|
984
1041
|
function processJobEnv(configDir) {
|
|
985
|
-
const allow = [
|
|
1042
|
+
const allow = [
|
|
1043
|
+
"PATH",
|
|
1044
|
+
"PATHEXT",
|
|
1045
|
+
"SYSTEMROOT",
|
|
1046
|
+
"SYSTEMDRIVE",
|
|
1047
|
+
"COMSPEC",
|
|
1048
|
+
"LANG",
|
|
1049
|
+
"LC_ALL",
|
|
1050
|
+
"TZ",
|
|
1051
|
+
"TERM",
|
|
1052
|
+
"TMPDIR",
|
|
1053
|
+
"TEMP",
|
|
1054
|
+
"TMP",
|
|
1055
|
+
"HOME",
|
|
1056
|
+
"USERPROFILE",
|
|
1057
|
+
"XDG_CONFIG_HOME",
|
|
1058
|
+
"XDG_CACHE_HOME",
|
|
1059
|
+
"HTTP_PROXY",
|
|
1060
|
+
"HTTPS_PROXY",
|
|
1061
|
+
"ALL_PROXY",
|
|
1062
|
+
"NO_PROXY",
|
|
1063
|
+
"http_proxy",
|
|
1064
|
+
"https_proxy",
|
|
1065
|
+
"all_proxy",
|
|
1066
|
+
"no_proxy",
|
|
1067
|
+
"NODE_EXTRA_CA_CERTS",
|
|
1068
|
+
"SSL_CERT_FILE"
|
|
1069
|
+
];
|
|
986
1070
|
const env = {};
|
|
987
1071
|
for (const key of allow) {
|
|
988
1072
|
const value = process.env[key];
|
|
@@ -992,6 +1076,29 @@ function processJobEnv(configDir) {
|
|
|
992
1076
|
if (configDir) env.PIE_CODING_AGENT_DIR = configDir;
|
|
993
1077
|
return env;
|
|
994
1078
|
}
|
|
1079
|
+
function readProcessErrorExcerpt(logFile, startOffset) {
|
|
1080
|
+
try {
|
|
1081
|
+
const stat = fs3.statSync(logFile);
|
|
1082
|
+
if (!stat.isFile() || stat.size <= startOffset) return void 0;
|
|
1083
|
+
const maxRead = 4096;
|
|
1084
|
+
const readStart = Math.max(startOffset, stat.size - maxRead);
|
|
1085
|
+
const length = stat.size - readStart;
|
|
1086
|
+
if (length <= 0) return void 0;
|
|
1087
|
+
const buf = Buffer.alloc(length);
|
|
1088
|
+
const fd = fs3.openSync(logFile, "r");
|
|
1089
|
+
try {
|
|
1090
|
+
fs3.readSync(fd, buf, 0, length, readStart);
|
|
1091
|
+
} finally {
|
|
1092
|
+
fs3.closeSync(fd);
|
|
1093
|
+
}
|
|
1094
|
+
const lines = buf.toString("utf8").replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "").split(/\r?\n/).map((line) => line.replace(/[\x00-\x1f\x7f]/g, " ").replace(/\s+/g, " ").trim()).filter((line) => line.length > 0 && !/^at\s+/.test(line) && !/^[{}[\],]+$/.test(line) && !/^(?:code|path|requestPath|requireStack):/.test(line) && !/^-\s+/.test(line));
|
|
1095
|
+
if (lines.length === 0) return void 0;
|
|
1096
|
+
const preferred = lines.find((line) => /Fatal error:|Error:|failed\b|Cannot find module/i.test(line)) ?? lines[lines.length - 1];
|
|
1097
|
+
return preferred.length > 200 ? `${preferred.slice(0, 197)}...` : preferred;
|
|
1098
|
+
} catch {
|
|
1099
|
+
return void 0;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
995
1102
|
var PROCESS_WORKER_RETRYABLE_EXIT_CODE = 75;
|
|
996
1103
|
var ProcessWorkerCancelled = class extends Error {
|
|
997
1104
|
aborted = true;
|
|
@@ -1022,6 +1129,13 @@ function runProcessWorker(job, command, cwd, deadlineMs = 30 * 60 * 1e3, logDir,
|
|
|
1022
1129
|
fs3.appendFileSync(logFile, header);
|
|
1023
1130
|
} catch {
|
|
1024
1131
|
}
|
|
1132
|
+
const logStartOffset = (() => {
|
|
1133
|
+
try {
|
|
1134
|
+
return fs3.statSync(logFile).size;
|
|
1135
|
+
} catch {
|
|
1136
|
+
return 0;
|
|
1137
|
+
}
|
|
1138
|
+
})();
|
|
1025
1139
|
let out;
|
|
1026
1140
|
try {
|
|
1027
1141
|
out = fs3.openSync(logFile, "a");
|
|
@@ -1136,6 +1250,7 @@ function runProcessWorker(job, command, cwd, deadlineMs = 30 * 60 * 1e3, logDir,
|
|
|
1136
1250
|
await termination;
|
|
1137
1251
|
settled = true;
|
|
1138
1252
|
if (cleanupFailure) failure = `process cleanup failed: ${String(cleanupFailure)}`;
|
|
1253
|
+
const excerpt = !failure && !cleanupFailure && code !== 0 ? readProcessErrorExcerpt(logFile, logStartOffset) : void 0;
|
|
1139
1254
|
try {
|
|
1140
1255
|
fs3.appendFileSync(logFile, `[${(/* @__PURE__ */ new Date()).toISOString()}] job=${job.id} exit=${code}${failure ? ` error=${failure}` : ""}
|
|
1141
1256
|
`);
|
|
@@ -1146,10 +1261,10 @@ function runProcessWorker(job, command, cwd, deadlineMs = 30 * 60 * 1e3, logDir,
|
|
|
1146
1261
|
return;
|
|
1147
1262
|
}
|
|
1148
1263
|
if (!failure && !cleanupFailure && command.managedBy === "memory" && code === PROCESS_WORKER_RETRYABLE_EXIT_CODE) {
|
|
1149
|
-
reject(new ProcessWorkerRetryable(`transient memory distillation failure (exit ${code})`));
|
|
1264
|
+
reject(new ProcessWorkerRetryable(`transient memory distillation failure (exit ${code})${excerpt ? `: ${excerpt}` : ""}`));
|
|
1150
1265
|
return;
|
|
1151
1266
|
}
|
|
1152
|
-
if (failure || code !== 0) reject(new Error(failure ?? `process exited ${code}`));
|
|
1267
|
+
if (failure || code !== 0) reject(new Error(failure ?? `process exited ${code}${excerpt ? `: ${excerpt}` : ""}`));
|
|
1153
1268
|
else resolve3();
|
|
1154
1269
|
});
|
|
1155
1270
|
});
|
|
@@ -1241,35 +1356,69 @@ var Runtime = class {
|
|
|
1241
1356
|
void this.ensureMemoryDistillationDefault();
|
|
1242
1357
|
}
|
|
1243
1358
|
/** Default daily distillation at 03:00 local. Idempotent: an existing
|
|
1244
|
-
* managed job
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1359
|
+
* managed job keeps user pause/running reservations, while:
|
|
1360
|
+
* - enabled repeating `blocked` jobs auto-recover on startup (and refresh
|
|
1361
|
+
* stale/upgraded CLI commands) so a fixed release or config heals
|
|
1362
|
+
* itself without manual intervention on every machine;
|
|
1363
|
+
* - enabled `ready` jobs migrate their command in-place when
|
|
1364
|
+
* `PIE_SESSIONS_DIR` mismatches or the persisted node/CLI binary path
|
|
1365
|
+
* no longer exists on disk (e.g. Homebrew node upgrade). */
|
|
1247
1366
|
async ensureMemoryDistillationDefault() {
|
|
1248
1367
|
try {
|
|
1249
1368
|
const existing = this.store.findProcess("memory");
|
|
1250
1369
|
if (existing) {
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1370
|
+
const currentCmd = (() => {
|
|
1371
|
+
try {
|
|
1372
|
+
return JSON.parse(existing.prompt).command ?? [];
|
|
1373
|
+
} catch {
|
|
1374
|
+
return [];
|
|
1375
|
+
}
|
|
1376
|
+
})();
|
|
1377
|
+
const desiredCmd = managedMemoryCommand();
|
|
1378
|
+
const isManagedDistillCmd = currentCmd.includes("memory") && currentCmd.includes("distill");
|
|
1379
|
+
const hasMissingBinaryOrEntry = (() => {
|
|
1380
|
+
if (!isManagedDistillCmd) return false;
|
|
1381
|
+
const bin = currentCmd[0];
|
|
1382
|
+
if (bin && path4.isAbsolute(bin) && !fs4.existsSync(bin)) return true;
|
|
1383
|
+
const memIdx = currentCmd.indexOf("memory");
|
|
1384
|
+
const entry = memIdx >= 2 ? currentCmd[memIdx - 1] : void 0;
|
|
1385
|
+
if (entry && path4.isAbsolute(entry) && !fs4.existsSync(entry)) return true;
|
|
1386
|
+
return false;
|
|
1387
|
+
})();
|
|
1388
|
+
const isBundledCli = (() => {
|
|
1389
|
+
const hasLoader = desiredCmd.some((arg) => /^--(?:import|loader|experimental-loader)(?:=|$)/.test(arg));
|
|
1390
|
+
if (hasLoader) return false;
|
|
1391
|
+
const memIdx = desiredCmd.indexOf("memory");
|
|
1392
|
+
const entry = memIdx >= 2 ? desiredCmd[memIdx - 1] : void 0;
|
|
1393
|
+
return Boolean(entry && /(?:^|[\\/])cli\.js$/i.test(entry) && fs4.existsSync(entry));
|
|
1394
|
+
})();
|
|
1395
|
+
const sessionsDirMismatch = (() => {
|
|
1396
|
+
if (!process.env.PIE_SESSIONS_DIR || !desiredCmd.includes("--sessions-dir")) return false;
|
|
1397
|
+
const curIdx = currentCmd.indexOf("--sessions-dir");
|
|
1398
|
+
const wantIdx = desiredCmd.indexOf("--sessions-dir");
|
|
1399
|
+
const curDir = curIdx >= 0 ? currentCmd[curIdx + 1] : void 0;
|
|
1400
|
+
const wantDir = wantIdx >= 0 ? desiredCmd[wantIdx + 1] : void 0;
|
|
1401
|
+
return curDir !== wantDir ? wantDir : false;
|
|
1402
|
+
})();
|
|
1403
|
+
if (existing.enabled && existing.state === "blocked") {
|
|
1404
|
+
const shouldRefreshCmd = isManagedDistillCmd && (hasMissingBinaryOrEntry || Boolean(sessionsDirMismatch) || isBundledCli && (currentCmd.length !== desiredCmd.length || currentCmd.some((v, i) => v !== desiredCmd[i])));
|
|
1405
|
+
const rec = this.store.recoverBlockedProcess("memory", {
|
|
1406
|
+
...shouldRefreshCmd ? { command: desiredCmd } : {}
|
|
1407
|
+
});
|
|
1408
|
+
if (rec.recovered) {
|
|
1409
|
+
this.ctx.log(
|
|
1410
|
+
`cron: auto-recovered blocked managed memory distillation job (was: ${rec.previousError ?? "unknown"}; next ${rec.next !== void 0 ? new Date(rec.next).toISOString() : "none"}${rec.commandUpdated ? "; refreshed command" : ""})`
|
|
1411
|
+
);
|
|
1412
|
+
}
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (sessionsDirMismatch || hasMissingBinaryOrEntry) {
|
|
1416
|
+
const outcome = this.store.syncProcessCommand("memory", desiredCmd);
|
|
1417
|
+
if (outcome === "updated") {
|
|
1418
|
+
const reason = sessionsDirMismatch ? `pin --sessions-dir ${sessionsDirMismatch}` : "repair missing node/CLI executable path";
|
|
1419
|
+
this.ctx.log(`cron: migrated managed memory distillation command to ${reason}`);
|
|
1420
|
+
} else if (outcome === "deferred" && sessionsDirMismatch) {
|
|
1421
|
+
this.ctx.log(`cron: managed memory distillation job needs repair to pin --sessions-dir ${sessionsDirMismatch} (currently ${existing.state === "running" ? "running" : !existing.enabled ? "paused" : existing.state}; run 'pie memory schedule on' when ready)`);
|
|
1273
1422
|
}
|
|
1274
1423
|
}
|
|
1275
1424
|
return;
|