@cydm/pie 4.13.1 → 4.14.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 +2 -2
- package/dist/builtin/extensions/im-forward/index.js +8092 -8098
- package/dist/builtin/extensions/mcp-adapter/index.js +86 -81
- package/dist/builtin/extensions/memory/index.js +28 -5
- package/dist/builtin/extensions/pie-ipc/index.js +13 -18
- package/dist/builtin/extensions/pie-proc/index.js +61 -55
- package/dist/builtin/extensions/plan-mode/index.js +2 -2
- package/dist/builtin/extensions/subagent/index.js +3 -3
- package/dist/builtin/extensions/todo/index.js +2 -2
- package/dist/chunks/{chunk-6Z54UHXM.js → chunk-BOQIGMGQ.js} +20 -15
- package/dist/chunks/{chunk-XPJHZRTN.js → chunk-EZZTMDWZ.js} +712 -378
- package/dist/chunks/{chunk-HSMO2BEA.js → chunk-FD3KBPDR.js} +23 -18
- package/dist/chunks/{chunk-3F2CSVNH.js → chunk-IK2FR2YF.js} +2 -1
- package/dist/chunks/{chunk-CCPNHS6B.js → chunk-JJH77AUU.js} +1578 -1566
- package/dist/chunks/{chunk-DT22BBZL.js → chunk-JKO42HZW.js} +1 -1
- package/dist/chunks/{chunk-UCVPNLCO.js → chunk-KGWKRO7Z.js} +1 -1
- package/dist/chunks/{chunk-NHWWRE3T.js → chunk-UYDS75SI.js} +725 -718
- package/dist/chunks/{host-image-fallback-LGWYQMLA.js → host-image-fallback-LPHB5CTL.js} +1 -1
- package/dist/chunks/{manager-cli-OTIMAWO6.js → manager-cli-ZV36YNPJ.js} +187 -173
- package/dist/chunks/{memory-git-7SRO5KLB.js → memory-git-ZJN6SPIU.js} +3 -3
- package/dist/chunks/{model-registry-IWOOAMLZ.js → model-registry-GLBIUOJR.js} +1 -1
- package/dist/chunks/{read-file-understanding-3TYWVOLX.js → read-file-understanding-DFJPTTSB.js} +3 -3
- package/dist/chunks/{src-WA2O2O2V.js → src-KZ7YID3I.js} +1 -1
- package/dist/chunks/{src-D2ICRXWW.js → src-LEXKDSFV.js} +22 -4
- package/dist/cli.js +2859 -2741
- package/package.json +1 -1
- package/dist/chunks/{chunk-3GG342QY.js → chunk-TYCKSYUF.js} +19 -19
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
takeDispatchFrame,
|
|
26
26
|
wrapInboundText,
|
|
27
27
|
wrappedMessageMarker
|
|
28
|
-
} from "../../../chunks/chunk-
|
|
28
|
+
} from "../../../chunks/chunk-TYCKSYUF.js";
|
|
29
29
|
import {
|
|
30
30
|
Type
|
|
31
31
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -35,7 +35,6 @@ import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
|
35
35
|
import * as fs3 from "node:fs";
|
|
36
36
|
import * as os from "node:os";
|
|
37
37
|
import * as path4 from "node:path";
|
|
38
|
-
import { randomUUID } from "node:crypto";
|
|
39
38
|
|
|
40
39
|
// builtin/extensions/pie-ipc/discovery.ts
|
|
41
40
|
import * as fs2 from "node:fs";
|
|
@@ -1081,11 +1080,11 @@ function fitPeekSnapshotToFrame(snapshot, frameBytes, maxBytes = 8e3) {
|
|
|
1081
1080
|
return text;
|
|
1082
1081
|
}
|
|
1083
1082
|
|
|
1084
|
-
// builtin/extensions/pie-ipc/
|
|
1083
|
+
// builtin/extensions/pie-ipc/runtime-base.ts
|
|
1085
1084
|
var DEFAULT_NOTIFY_FALLBACK_MS = 6e5;
|
|
1086
1085
|
var FALLBACK_RENEWAL_CAP = 4;
|
|
1087
1086
|
var PROBE_CACHE_MS = 2e3;
|
|
1088
|
-
var
|
|
1087
|
+
var RuntimeBase = class {
|
|
1089
1088
|
constructor(ctx, config, discoveryDir) {
|
|
1090
1089
|
this.ctx = ctx;
|
|
1091
1090
|
this.config = config;
|
|
@@ -1289,7 +1288,8 @@ var Runtime = class {
|
|
|
1289
1288
|
const status = this.currentStatus();
|
|
1290
1289
|
let queueGate;
|
|
1291
1290
|
try {
|
|
1292
|
-
|
|
1291
|
+
const diagnosticContext = this.ctx;
|
|
1292
|
+
queueGate = diagnosticContext.getQueueGateDiagnostics?.();
|
|
1293
1293
|
} catch {
|
|
1294
1294
|
}
|
|
1295
1295
|
reply("state", JSON.stringify({
|
|
@@ -1772,13 +1772,12 @@ ${outcome.text}`
|
|
|
1772
1772
|
} catch {
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
* outcome — every host kind surfaces the completion exactly once. */
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
// builtin/extensions/pie-ipc/runtime.ts
|
|
1778
|
+
import { randomUUID } from "node:crypto";
|
|
1779
|
+
var Runtime = class extends RuntimeBase {
|
|
1780
|
+
/** Surface an inbox-only completion exactly once instead of silently cancelling its fallback. */
|
|
1782
1781
|
completeNotify(requestId, userAssigned = false) {
|
|
1783
1782
|
const willInject = this.delivery?.willInjectNow() ?? this.ctx.capabilities.editorInjection;
|
|
1784
1783
|
if (willInject) {
|
|
@@ -1796,12 +1795,6 @@ ${outcome.text}`
|
|
|
1796
1795
|
} catch {
|
|
1797
1796
|
}
|
|
1798
1797
|
}
|
|
1799
|
-
/** A completion notification (or its inbox delivery) landed for our send:
|
|
1800
|
-
* destroy the fallback OPERATION so the model is woken exactly once —
|
|
1801
|
-
* including a query-in-flight fallback (review r4-P1): finishOp cancels
|
|
1802
|
-
* the in-flight continuation, which then exits without renewing or
|
|
1803
|
-
* waking. Also records completion for sends whose push arrived BEFORE
|
|
1804
|
-
* the ack did — armNotifyFallback then arms nothing. */
|
|
1805
1798
|
clearNotifyFallback(requestId) {
|
|
1806
1799
|
if (this.completedNotifies.size > 200) this.completedNotifies.clear();
|
|
1807
1800
|
this.completedNotifies.add(requestId);
|
|
@@ -2154,6 +2147,8 @@ ${message.text}`).join("\n---\n");
|
|
|
2154
2147
|
await this.transport?.closeAndFlush();
|
|
2155
2148
|
}
|
|
2156
2149
|
};
|
|
2150
|
+
|
|
2151
|
+
// builtin/extensions/pie-ipc/index.ts
|
|
2157
2152
|
function loadConfig(ctx, configDir) {
|
|
2158
2153
|
try {
|
|
2159
2154
|
const layers = [
|
|
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
registerWorkerLifecycleBridge,
|
|
4
4
|
syncInheritedWorkerModels
|
|
5
|
-
} from "../../../chunks/chunk-
|
|
5
|
+
} from "../../../chunks/chunk-JKO42HZW.js";
|
|
6
6
|
import {
|
|
7
7
|
readProcessCommandLine
|
|
8
8
|
} from "../../../chunks/chunk-7RJXKN7N.js";
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
import "../../../chunks/chunk-Q4NJEPIZ.js";
|
|
13
13
|
import {
|
|
14
14
|
loadResolvedModelsConfig
|
|
15
|
-
} from "../../../chunks/chunk-
|
|
15
|
+
} from "../../../chunks/chunk-UYDS75SI.js";
|
|
16
16
|
import "../../../chunks/chunk-CBDQJMUI.js";
|
|
17
17
|
import {
|
|
18
18
|
redactText
|
|
19
|
-
} from "../../../chunks/chunk-
|
|
19
|
+
} from "../../../chunks/chunk-EZZTMDWZ.js";
|
|
20
20
|
import {
|
|
21
21
|
isCompactSummaryMessage
|
|
22
|
-
} from "../../../chunks/chunk-
|
|
22
|
+
} from "../../../chunks/chunk-JJH77AUU.js";
|
|
23
23
|
import "../../../chunks/chunk-26KRUYZH.js";
|
|
24
24
|
import "../../../chunks/chunk-MCR4JYI6.js";
|
|
25
25
|
import {
|
|
@@ -28,12 +28,12 @@ import {
|
|
|
28
28
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
29
29
|
|
|
30
30
|
// builtin/extensions/pie-proc/index.ts
|
|
31
|
-
import { execFileSync, spawn } from "node:child_process";
|
|
31
|
+
import { execFileSync as execFileSync2, spawn } from "node:child_process";
|
|
32
32
|
import { createRequire } from "node:module";
|
|
33
33
|
import { fileURLToPath } from "node:url";
|
|
34
|
-
import * as
|
|
35
|
-
import * as
|
|
36
|
-
import * as
|
|
34
|
+
import * as fs5 from "node:fs";
|
|
35
|
+
import * as os4 from "node:os";
|
|
36
|
+
import * as path5 from "node:path";
|
|
37
37
|
|
|
38
38
|
// builtin/extensions/pie-proc/panel-bridge.ts
|
|
39
39
|
import * as fs from "node:fs";
|
|
@@ -860,7 +860,7 @@ async function waitForWorkerIpcReady(opts) {
|
|
|
860
860
|
if (!isPidAlive(opts.pid)) return { exitedEarly: true };
|
|
861
861
|
const remaining = deadline - Date.now();
|
|
862
862
|
if (remaining <= 0) break;
|
|
863
|
-
await new Promise((
|
|
863
|
+
await new Promise((resolve6) => setTimeout(resolve6, Math.min(pollMs, remaining)));
|
|
864
864
|
}
|
|
865
865
|
return { peer: readLiveWorkerPeer(opts.ipcRoot, opts.sessionId, opts.pid), exitedEarly: !isPidAlive(opts.pid) };
|
|
866
866
|
}
|
|
@@ -913,22 +913,11 @@ function liveWorkerModelLabel(ipcRoot, sessionId, pid) {
|
|
|
913
913
|
return lvl ? `${peer.model} (${lvl})` : peer.model;
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
// builtin/extensions/pie-proc/
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
return getSessionsDir();
|
|
922
|
-
} catch {
|
|
923
|
-
const override = process.env.PIE_SESSIONS_DIR;
|
|
924
|
-
if (override !== void 0 && override !== "") {
|
|
925
|
-
if (override === "~") return path4.join(os3.homedir(), ".pie", "sessions");
|
|
926
|
-
if (override.startsWith("~/")) return path4.join(os3.homedir(), override.slice(2));
|
|
927
|
-
if (path4.isAbsolute(override)) return override;
|
|
928
|
-
}
|
|
929
|
-
return path4.join(os3.homedir(), ".pie", "sessions");
|
|
930
|
-
}
|
|
931
|
-
}
|
|
916
|
+
// builtin/extensions/pie-proc/proc-runtime.ts
|
|
917
|
+
import { execFileSync } from "node:child_process";
|
|
918
|
+
import * as fs4 from "node:fs";
|
|
919
|
+
import * as os3 from "node:os";
|
|
920
|
+
import * as path4 from "node:path";
|
|
932
921
|
var IM_FORWARD_CONTROL_KEYS = /* @__PURE__ */ new Set(["enabled", "provider", "retryBackoffMs"]);
|
|
933
922
|
var IM_FORWARD_FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["providers", "__proto__", "constructor", "prototype", "toString", "valueOf"]);
|
|
934
923
|
var SAFE_PROVIDER_ID = /^[a-z][a-z0-9_-]{0,31}$/i;
|
|
@@ -1297,13 +1286,30 @@ function readUserImForwardIdentity() {
|
|
|
1297
1286
|
}
|
|
1298
1287
|
return void 0;
|
|
1299
1288
|
}
|
|
1289
|
+
|
|
1290
|
+
// builtin/extensions/pie-proc/index.ts
|
|
1291
|
+
var require_ = createRequire(import.meta.url);
|
|
1292
|
+
function resolveOperatorSessionsDir() {
|
|
1293
|
+
try {
|
|
1294
|
+
const { getSessionsDir } = require_("../../../src/config.js");
|
|
1295
|
+
return getSessionsDir();
|
|
1296
|
+
} catch {
|
|
1297
|
+
const override = process.env.PIE_SESSIONS_DIR;
|
|
1298
|
+
if (override !== void 0 && override !== "") {
|
|
1299
|
+
if (override === "~") return path5.join(os4.homedir(), ".pie", "sessions");
|
|
1300
|
+
if (override.startsWith("~/")) return path5.join(os4.homedir(), override.slice(2));
|
|
1301
|
+
if (path5.isAbsolute(override)) return override;
|
|
1302
|
+
}
|
|
1303
|
+
return path5.join(os4.homedir(), ".pie", "sessions");
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1300
1306
|
function cliEntry() {
|
|
1301
|
-
const moduleDir =
|
|
1307
|
+
const moduleDir = path5.dirname(fileURLToPath(import.meta.url));
|
|
1302
1308
|
for (const rel of ["../../../src/cli.ts", "../../../cli.js"]) {
|
|
1303
|
-
const candidate =
|
|
1309
|
+
const candidate = path5.resolve(moduleDir, rel);
|
|
1304
1310
|
try {
|
|
1305
|
-
const real =
|
|
1306
|
-
if (
|
|
1311
|
+
const real = fs5.realpathSync(candidate);
|
|
1312
|
+
if (fs5.statSync(real).isFile()) return real;
|
|
1307
1313
|
} catch {
|
|
1308
1314
|
}
|
|
1309
1315
|
}
|
|
@@ -1313,10 +1319,10 @@ function loaderArgs() {
|
|
|
1313
1319
|
for (let i = 0; i < process.execArgv.length - 1; i += 1) {
|
|
1314
1320
|
if (process.execArgv[i] === "--import") {
|
|
1315
1321
|
const target = process.execArgv[i + 1];
|
|
1316
|
-
if (target && !
|
|
1322
|
+
if (target && !path5.isAbsolute(target) && !target.startsWith("file:")) {
|
|
1317
1323
|
try {
|
|
1318
|
-
const pkgRoot =
|
|
1319
|
-
return ["--import",
|
|
1324
|
+
const pkgRoot = path5.dirname(require_.resolve(`${target}/package.json`, { paths: [path5.dirname(cliEntry())] }));
|
|
1325
|
+
return ["--import", path5.join(pkgRoot, "dist", "loader.mjs")];
|
|
1320
1326
|
} catch {
|
|
1321
1327
|
return [];
|
|
1322
1328
|
}
|
|
@@ -1327,7 +1333,7 @@ function loaderArgs() {
|
|
|
1327
1333
|
return [];
|
|
1328
1334
|
}
|
|
1329
1335
|
function logDir() {
|
|
1330
|
-
return
|
|
1336
|
+
return path5.join(pieProcDir(), "logs");
|
|
1331
1337
|
}
|
|
1332
1338
|
var toolText = (text, isError = false) => ({ content: [{ type: "text", text }], details: {}, ...isError ? { isError: true } : {} });
|
|
1333
1339
|
function pieProc(ctx) {
|
|
@@ -1339,18 +1345,18 @@ function pieProc(ctx) {
|
|
|
1339
1345
|
const observeActivity = (record) => {
|
|
1340
1346
|
const logTime = (() => {
|
|
1341
1347
|
try {
|
|
1342
|
-
return
|
|
1348
|
+
return fs5.statSync(path5.join(logDir(), `${record.name}.jsonl`)).mtimeMs;
|
|
1343
1349
|
} catch {
|
|
1344
1350
|
return record.lastActiveAt;
|
|
1345
1351
|
}
|
|
1346
1352
|
})();
|
|
1347
1353
|
if (record.pid === 0) return logTime;
|
|
1348
|
-
const statusRoot =
|
|
1354
|
+
const statusRoot = path5.join(path5.resolve(expandTilde(process.env.PIE_IPC_CONFIG_DIR ?? configDirRoot())), "run", "ipc");
|
|
1349
1355
|
try {
|
|
1350
|
-
for (const file of
|
|
1356
|
+
for (const file of fs5.readdirSync(statusRoot)) {
|
|
1351
1357
|
if (!file.endsWith(".json")) continue;
|
|
1352
1358
|
try {
|
|
1353
|
-
const status = JSON.parse(
|
|
1359
|
+
const status = JSON.parse(fs5.readFileSync(path5.join(statusRoot, file), "utf8"));
|
|
1354
1360
|
if (status.sessionId === record.sessionId && status.state === "working") return Date.now();
|
|
1355
1361
|
} catch {
|
|
1356
1362
|
}
|
|
@@ -1383,7 +1389,7 @@ function pieProc(ctx) {
|
|
|
1383
1389
|
if (!Number.isSafeInteger(pid) || pid <= 1) return;
|
|
1384
1390
|
if (process.platform === "win32") {
|
|
1385
1391
|
try {
|
|
1386
|
-
|
|
1392
|
+
execFileSync2("taskkill.exe", ["/F", "/T", "/PID", String(pid)], {
|
|
1387
1393
|
windowsHide: true,
|
|
1388
1394
|
stdio: "ignore",
|
|
1389
1395
|
timeout: 5e3
|
|
@@ -1516,17 +1522,17 @@ function pieProc(ctx) {
|
|
|
1516
1522
|
const canonicalCwd = cwdAllowedOrThrow(params.cwd, readConfigDetailed());
|
|
1517
1523
|
const entry = cliEntry();
|
|
1518
1524
|
if (!entry) throw new Error("cannot resolve a trusted pie entry point (refusing to spawn)");
|
|
1519
|
-
const validatedModel = validateSpawnModelParams({ model: params.model, thinkingLevel: params.thinkingLevel, pieDir:
|
|
1525
|
+
const validatedModel = validateSpawnModelParams({ model: params.model, thinkingLevel: params.thinkingLevel, pieDir: path5.join(pieProcDir(), "agents", params.name), parentConfigDir: configDirRoot() });
|
|
1520
1526
|
let resumeSessionId;
|
|
1521
1527
|
let resumeSessionsDir;
|
|
1522
1528
|
if (params.resumeSessionId) {
|
|
1523
1529
|
if (!/^[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(params.resumeSessionId)) throw new Error(`invalid resumeSessionId "${params.resumeSessionId}"`);
|
|
1524
1530
|
const operatorSessionsDir = resolveOperatorSessionsDir();
|
|
1525
|
-
const workerSessionsDir =
|
|
1531
|
+
const workerSessionsDir = path5.join(pieProcDir(), "agents", params.name, "sessions");
|
|
1526
1532
|
let recordedCwd;
|
|
1527
1533
|
for (const dir of [workerSessionsDir, operatorSessionsDir]) {
|
|
1528
1534
|
try {
|
|
1529
|
-
const head = JSON.parse(
|
|
1535
|
+
const head = JSON.parse(fs5.readFileSync(path5.join(dir, params.resumeSessionId, "head.json"), "utf8"));
|
|
1530
1536
|
recordedCwd = head.metadata?.cwd;
|
|
1531
1537
|
resumeSessionsDir = dir;
|
|
1532
1538
|
break;
|
|
@@ -1537,7 +1543,7 @@ function pieProc(ctx) {
|
|
|
1537
1543
|
if (typeof recordedCwd !== "string" || !recordedCwd) throw new Error(`session "${params.resumeSessionId}" has no recorded cwd; resume requires one`);
|
|
1538
1544
|
let canonicalRecorded = recordedCwd;
|
|
1539
1545
|
try {
|
|
1540
|
-
canonicalRecorded =
|
|
1546
|
+
canonicalRecorded = fs5.realpathSync(recordedCwd);
|
|
1541
1547
|
} catch {
|
|
1542
1548
|
}
|
|
1543
1549
|
if (canonicalRecorded !== canonicalCwd) throw new Error(`resume cwd mismatch: session recorded "${recordedCwd}" but spawn cwd is "${params.cwd}" \u2014 resume in the session's own directory`);
|
|
@@ -1614,12 +1620,12 @@ function pieProc(ctx) {
|
|
|
1614
1620
|
});
|
|
1615
1621
|
let child;
|
|
1616
1622
|
try {
|
|
1617
|
-
const pieDir =
|
|
1618
|
-
|
|
1623
|
+
const pieDir = path5.join(pieProcDir(), "agents", params.name);
|
|
1624
|
+
fs5.mkdirSync(pieDir, { recursive: true });
|
|
1619
1625
|
inheritWorkerConfigFiles(pieDir, configDirRoot());
|
|
1620
1626
|
if (imForward) {
|
|
1621
|
-
const imFile =
|
|
1622
|
-
if (!
|
|
1627
|
+
const imFile = path5.join(pieDir, "im-forward.json");
|
|
1628
|
+
if (!fs5.existsSync(imFile)) {
|
|
1623
1629
|
const provider = typeof imForward.provider === "string" ? imForward.provider.trim() : "";
|
|
1624
1630
|
if (provider && SAFE_PROVIDER_ID.test(provider)) {
|
|
1625
1631
|
const providerSettings = {};
|
|
@@ -1637,16 +1643,16 @@ function pieProc(ctx) {
|
|
|
1637
1643
|
if (typeof imForward.retryBackoffMs === "number" && Number.isFinite(imForward.retryBackoffMs)) {
|
|
1638
1644
|
doc.retryBackoffMs = imForward.retryBackoffMs;
|
|
1639
1645
|
}
|
|
1640
|
-
|
|
1646
|
+
fs5.writeFileSync(imFile, JSON.stringify(doc, null, " "));
|
|
1641
1647
|
}
|
|
1642
1648
|
}
|
|
1643
1649
|
}
|
|
1644
|
-
|
|
1645
|
-
const logFile =
|
|
1650
|
+
fs5.mkdirSync(logDir(), { recursive: true });
|
|
1651
|
+
const logFile = fs5.openSync(path5.join(logDir(), `${params.name}.jsonl`), "a");
|
|
1646
1652
|
const modelArgs = [...validatedModel.model ? ["--model", validatedModel.model] : [], ...validatedModel.thinkingLevel ? ["--thinking", validatedModel.thinkingLevel] : []];
|
|
1647
1653
|
const args = params.kind === "resident" ? [...loaderArgs(), entry, "--json-events", "--idle", "--session-id", sessionId, ...resumeSessionId ? ["--resume-required", "--worker-token", launchToken] : [], ...modelArgs] : [...loaderArgs(), entry, "--session-id", sessionId, ...modelArgs];
|
|
1648
|
-
const inheritedIpcRoot =
|
|
1649
|
-
const inheritedRegistryRoot =
|
|
1654
|
+
const inheritedIpcRoot = path5.resolve(expandTilde(process.env.PIE_IPC_CONFIG_DIR ?? configDirRoot()));
|
|
1655
|
+
const inheritedRegistryRoot = path5.resolve(expandTilde(process.env.PIE_PROC_REGISTRY_ROOT ?? pieProcDir()));
|
|
1650
1656
|
const { PIE_DEFAULT_PROVIDER: _p, PIE_DEFAULT_MODEL: _m, PIE_MANAGER_BOOTSTRAP: _b, PIE_PROC_CURATED_NAME: _c, ...inheritedEnv } = process.env;
|
|
1651
1657
|
const childEnv = {
|
|
1652
1658
|
...inheritedEnv,
|
|
@@ -1680,12 +1686,12 @@ function pieProc(ctx) {
|
|
|
1680
1686
|
});
|
|
1681
1687
|
} finally {
|
|
1682
1688
|
try {
|
|
1683
|
-
|
|
1689
|
+
fs5.closeSync(logFile);
|
|
1684
1690
|
} catch {
|
|
1685
1691
|
}
|
|
1686
1692
|
}
|
|
1687
1693
|
if (typeof child.pid !== "number") {
|
|
1688
|
-
throw new Error(`worker spawn failed (no pid) \u2014 see ${
|
|
1694
|
+
throw new Error(`worker spawn failed (no pid) \u2014 see ${path5.join(logDir(), `${params.name}.jsonl`)}`);
|
|
1689
1695
|
}
|
|
1690
1696
|
child.unref();
|
|
1691
1697
|
const record = {
|
|
@@ -1733,7 +1739,7 @@ function pieProc(ctx) {
|
|
|
1733
1739
|
cwd: record.cwd,
|
|
1734
1740
|
pieDir,
|
|
1735
1741
|
ipcRoot: inheritedIpcRoot,
|
|
1736
|
-
logPath:
|
|
1742
|
+
logPath: path5.join(logDir(), `${params.name}.jsonl`),
|
|
1737
1743
|
ttlMs: params.ttlMs,
|
|
1738
1744
|
explicitModel: validatedModel.model,
|
|
1739
1745
|
explicitThinking: validatedModel.thinkingLevel,
|
|
@@ -1861,7 +1867,7 @@ function pieProc(ctx) {
|
|
|
1861
1867
|
const action = args.action;
|
|
1862
1868
|
if (action === "list") {
|
|
1863
1869
|
const snap = readRegistryUncached();
|
|
1864
|
-
const ipcRoot =
|
|
1870
|
+
const ipcRoot = path5.resolve(expandTilde(process.env.PIE_IPC_CONFIG_DIR ?? configDirRoot()));
|
|
1865
1871
|
const rows = snap.workers.map((w) => {
|
|
1866
1872
|
const model = liveWorkerModelLabel(ipcRoot, w.sessionId, w.pid);
|
|
1867
1873
|
return { name: w.name, pid: w.pid, session: w.sessionId, cwd: w.cwd, kind: w.kind, ...model ? { model } : {}, status: w.pid === 0 ? `pending (reserver ${w.reserverPid ?? "?"})` : workerLiveness(w), idleSeconds: Math.round((Date.now() - Math.max(w.lastActiveAt, observeActivity(w))) / 1e3), ttlMs: w.kind === "resident" ? w.ttlMs ?? currentConfig().defaultTtlMs : 0, im: Boolean(w.imForward) };
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
createPlanCapability,
|
|
7
7
|
markCompletedPlanSteps,
|
|
8
8
|
restoreExecutionState
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
10
|
-
import "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-EZZTMDWZ.js";
|
|
10
|
+
import "../../../chunks/chunk-JJH77AUU.js";
|
|
11
11
|
import "../../../chunks/chunk-26KRUYZH.js";
|
|
12
12
|
import "../../../chunks/chunk-MCR4JYI6.js";
|
|
13
13
|
import {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createCliRetryPolicy,
|
|
6
6
|
formatTransportLifecycle,
|
|
7
7
|
logTransportLifecycle
|
|
8
|
-
} from "../../../chunks/chunk-
|
|
8
|
+
} from "../../../chunks/chunk-BOQIGMGQ.js";
|
|
9
9
|
import {
|
|
10
10
|
getConfigDir
|
|
11
11
|
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
createPolicyEnforcedTools,
|
|
15
15
|
createSharedFileSystemTools,
|
|
16
16
|
createSubagentCapability
|
|
17
|
-
} from "../../../chunks/chunk-
|
|
18
|
-
import "../../../chunks/chunk-
|
|
17
|
+
} from "../../../chunks/chunk-EZZTMDWZ.js";
|
|
18
|
+
import "../../../chunks/chunk-JJH77AUU.js";
|
|
19
19
|
import "../../../chunks/chunk-26KRUYZH.js";
|
|
20
20
|
import "../../../chunks/chunk-MCR4JYI6.js";
|
|
21
21
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
executeManageTodoList,
|
|
9
9
|
executionStateToTodos,
|
|
10
10
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
11
|
+
} from "../../../chunks/chunk-EZZTMDWZ.js";
|
|
12
|
+
import "../../../chunks/chunk-JJH77AUU.js";
|
|
13
13
|
import "../../../chunks/chunk-26KRUYZH.js";
|
|
14
14
|
import "../../../chunks/chunk-MCR4JYI6.js";
|
|
15
15
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
createSharedWebSearchTool,
|
|
11
11
|
defaultShellKindForPlatform,
|
|
12
12
|
interpretShellExit
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-EZZTMDWZ.js";
|
|
14
14
|
import {
|
|
15
15
|
classifyDefaultFailure,
|
|
16
16
|
isDefaultContextOverflowError,
|
|
17
17
|
requestInteraction
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-JJH77AUU.js";
|
|
19
19
|
import {
|
|
20
20
|
getLogger
|
|
21
21
|
} from "./chunk-MCR4JYI6.js";
|
|
@@ -172,11 +172,9 @@ function createTraceTransportSink(noteRuntimeEvent) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/capabilities/bash/index.ts
|
|
175
|
-
import { spawn
|
|
176
|
-
import { closeSync
|
|
177
|
-
import {
|
|
178
|
-
import { join, resolve } from "path";
|
|
179
|
-
import { createHash, randomBytes } from "crypto";
|
|
175
|
+
import { spawn as spawn2 } from "child_process";
|
|
176
|
+
import { closeSync as closeSync2, openSync as openSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
177
|
+
import { createHash as createHash2 } from "crypto";
|
|
180
178
|
|
|
181
179
|
// src/capabilities/bash/truncate.ts
|
|
182
180
|
var DEFAULT_MAX_LINES = 400;
|
|
@@ -535,7 +533,12 @@ var PowerShellDisplay = class {
|
|
|
535
533
|
}
|
|
536
534
|
};
|
|
537
535
|
|
|
538
|
-
// src/capabilities/bash/
|
|
536
|
+
// src/capabilities/bash/runtime.ts
|
|
537
|
+
import { spawn, spawnSync } from "child_process";
|
|
538
|
+
import { closeSync, createWriteStream, existsSync, openSync, statSync, unlinkSync } from "fs";
|
|
539
|
+
import { tmpdir } from "os";
|
|
540
|
+
import { join, resolve } from "path";
|
|
541
|
+
import { randomBytes } from "crypto";
|
|
539
542
|
function buildBashSchema(commandDescription) {
|
|
540
543
|
return Type.Object({
|
|
541
544
|
command: Type.String({ description: commandDescription }),
|
|
@@ -899,6 +902,8 @@ function killProcessTree(pid, leaderExited) {
|
|
|
899
902
|
}
|
|
900
903
|
}
|
|
901
904
|
}
|
|
905
|
+
|
|
906
|
+
// src/capabilities/bash/index.ts
|
|
902
907
|
function createBashTool(defaultCwd, options) {
|
|
903
908
|
const contract = buildShellToolContract(options?.platform);
|
|
904
909
|
const recentCommands = /* @__PURE__ */ new Map();
|
|
@@ -1051,7 +1056,7 @@ function createBashTool(defaultCwd, options) {
|
|
|
1051
1056
|
let shellExitAt = 0;
|
|
1052
1057
|
let lastPipeActivityAt = 0;
|
|
1053
1058
|
const spawnCommand = buildSpawnCommand(resolvedShell, effectiveCommand);
|
|
1054
|
-
const child = (options?.spawnProcess ??
|
|
1059
|
+
const child = (options?.spawnProcess ?? spawn2)(spawnCommand.file, spawnCommand.args, {
|
|
1055
1060
|
shell: spawnCommand.shell,
|
|
1056
1061
|
cwd: workingDir,
|
|
1057
1062
|
env: (() => {
|
|
@@ -1231,13 +1236,13 @@ ${fullOutput}`;
|
|
|
1231
1236
|
let outputText = truncation.content || "(no output)";
|
|
1232
1237
|
if (truncation.truncated && !tempFilePath) {
|
|
1233
1238
|
const path3 = getTempFilePath();
|
|
1234
|
-
const fd =
|
|
1239
|
+
const fd = openSync2(path3, "wx", 384);
|
|
1235
1240
|
tempFilePath = path3;
|
|
1236
1241
|
retainedOutputArtifacts.add(path3);
|
|
1237
1242
|
try {
|
|
1238
|
-
|
|
1243
|
+
writeFileSync2(fd, fullBuffer);
|
|
1239
1244
|
} finally {
|
|
1240
|
-
|
|
1245
|
+
closeSync2(fd);
|
|
1241
1246
|
}
|
|
1242
1247
|
}
|
|
1243
1248
|
await finishTempFileStream(tempFileStream);
|
|
@@ -1319,7 +1324,7 @@ ${commandNonzeroHint}`;
|
|
|
1319
1324
|
}
|
|
1320
1325
|
const repeatedCommand = rememberCommandResult(
|
|
1321
1326
|
`${resolvedShell}\0${workingDir}\0${effectiveCommand}`,
|
|
1322
|
-
|
|
1327
|
+
createHash2("sha256").update(JSON.stringify({ code, sig, timedOut, outputText })).digest("hex")
|
|
1323
1328
|
);
|
|
1324
1329
|
details.repeatedCommand = repeatedCommand;
|
|
1325
1330
|
if (repeatedCommand.count > 1 && repeatedCommand.sameResult) {
|
|
@@ -1353,7 +1358,7 @@ ${commandNonzeroHint}`;
|
|
|
1353
1358
|
}
|
|
1354
1359
|
|
|
1355
1360
|
// src/capabilities/rendered-page-reader.ts
|
|
1356
|
-
import { spawn as
|
|
1361
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
1357
1362
|
import { createRequire } from "node:module";
|
|
1358
1363
|
import * as fs from "node:fs";
|
|
1359
1364
|
import * as os from "node:os";
|
|
@@ -1373,7 +1378,7 @@ function resolveMcpScript() {
|
|
|
1373
1378
|
function runAxi(args, options = {}) {
|
|
1374
1379
|
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
1375
1380
|
return new Promise((resolve2, reject) => {
|
|
1376
|
-
const child =
|
|
1381
|
+
const child = spawn3(process.execPath, [resolveAxiCli(), ...args], {
|
|
1377
1382
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1378
1383
|
shell: false,
|
|
1379
1384
|
env: options.env,
|