@cydm/pie 4.4.2 → 4.5.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 +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 +364 -118
- 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 +70 -19
- package/dist/builtin/extensions/pie-proc/index.js +27 -13
- 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-OFLKAWI4.js → chunk-2CJIENLY.js} +90 -100
- 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-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-2ATPC47M.js} +35 -5
- package/dist/chunks/manager-upgrade-5CPKTRJ7.js +562 -0
- 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 +173 -136
- package/package.json +3 -3
- package/dist/chunks/chunk-7KLWHWZD.js +0 -164
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
claimOwnership,
|
|
4
|
+
pidDefinitelyDead,
|
|
5
|
+
readOwnership
|
|
6
|
+
} from "./chunk-ZPJ3BNQB.js";
|
|
2
7
|
|
|
3
8
|
// builtin/extensions/im-forward/helpers.ts
|
|
4
9
|
import * as nodeCrypto from "node:crypto";
|
|
@@ -769,6 +774,10 @@ function parseStatusFile(raw) {
|
|
|
769
774
|
updatedAt: record.updatedAt,
|
|
770
775
|
state: record.state
|
|
771
776
|
};
|
|
777
|
+
if (typeof record.unattended === "boolean") file.unattended = record.unattended;
|
|
778
|
+
if (typeof record.isManager === "boolean") file.isManager = record.isManager;
|
|
779
|
+
if (typeof record.version === "string" && record.version.length <= 64 && !hasControlChars(record.version)) file.version = record.version;
|
|
780
|
+
if (typeof record.imBinding === "string" && record.imBinding.length <= 512 && !hasControlChars(record.imBinding)) file.imBinding = record.imBinding;
|
|
772
781
|
if (Array.isArray(record.allowPeers) && record.allowPeers.length <= 1e3 && record.allowPeers.every((id) => typeof id === "string" && (id === "*" || isValidInstanceId(id)))) file.allowPeers = record.allowPeers;
|
|
773
782
|
if (typeof record.secret === "string" && /^[a-f0-9]{64}$/.test(record.secret)) file.secret = record.secret;
|
|
774
783
|
if (typeof record.sessionName === "string" && !hasControlChars(record.sessionName) && record.sessionName.length <= MAX_DISPLAY_NAME_CHARS) file.sessionName = record.sessionName;
|
|
@@ -1132,7 +1141,6 @@ var IpcTransport = class {
|
|
|
1132
1141
|
};
|
|
1133
1142
|
|
|
1134
1143
|
// builtin/extensions/im-forward/event-hub.ts
|
|
1135
|
-
import * as fs3 from "node:fs";
|
|
1136
1144
|
import * as path3 from "node:path";
|
|
1137
1145
|
|
|
1138
1146
|
// builtin/extensions/im-forward/address-book.ts
|
|
@@ -1223,8 +1231,10 @@ function resolveAddress(text, ownLiveName, book) {
|
|
|
1223
1231
|
return { kind: "none" };
|
|
1224
1232
|
}
|
|
1225
1233
|
const body = text.trimStart().slice(name.length + 1).trim();
|
|
1234
|
+
if (!resolvedBook.complete) return { kind: "ambiguous", name, reason: "address book unreadable" };
|
|
1226
1235
|
const foreignOwners = resolvedBook.names.get(name);
|
|
1227
1236
|
if (foreignOwners && foreignOwners.size > 0) {
|
|
1237
|
+
if (foreignOwners.size > 1) return { kind: "ambiguous", name, reason: "duplicate live session name" };
|
|
1228
1238
|
if (resolvedBook.selfPublished === name || live === name) return { kind: "ambiguous", name, reason: "duplicate live session name" };
|
|
1229
1239
|
return { kind: "other", name };
|
|
1230
1240
|
}
|
|
@@ -1238,6 +1248,36 @@ function resolveAddress(text, ownLiveName, book) {
|
|
|
1238
1248
|
// builtin/extensions/im-forward/event-hub.ts
|
|
1239
1249
|
var DISPATCH_PREFIX = "[im-forward-dispatch]";
|
|
1240
1250
|
var dispatchReceiver;
|
|
1251
|
+
var imBinding;
|
|
1252
|
+
var bindingListeners = /* @__PURE__ */ new Set();
|
|
1253
|
+
function bindingChanged() {
|
|
1254
|
+
for (const fn of bindingListeners) {
|
|
1255
|
+
try {
|
|
1256
|
+
fn();
|
|
1257
|
+
} catch {
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
function onImBindingChanged(fn) {
|
|
1262
|
+
bindingListeners.add(fn);
|
|
1263
|
+
return () => {
|
|
1264
|
+
bindingListeners.delete(fn);
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
function registerImBinding(value) {
|
|
1268
|
+
const token = Symbol(value);
|
|
1269
|
+
imBinding = { value, token };
|
|
1270
|
+
bindingChanged();
|
|
1271
|
+
return () => {
|
|
1272
|
+
if (imBinding?.token === token) {
|
|
1273
|
+
imBinding = void 0;
|
|
1274
|
+
bindingChanged();
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
function currentImBinding() {
|
|
1279
|
+
return imBinding?.value;
|
|
1280
|
+
}
|
|
1241
1281
|
var turnImDriverOracle;
|
|
1242
1282
|
function registerTurnImDriver(oracle) {
|
|
1243
1283
|
turnImDriverOracle = oracle;
|
|
@@ -1260,7 +1300,6 @@ function takeDispatchFrame(text) {
|
|
|
1260
1300
|
return true;
|
|
1261
1301
|
}
|
|
1262
1302
|
}
|
|
1263
|
-
var LOCK_STALE_MS = 2e4;
|
|
1264
1303
|
function hubDir() {
|
|
1265
1304
|
return path3.join(addressBookRoot(), "im-forward");
|
|
1266
1305
|
}
|
|
@@ -1268,116 +1307,64 @@ function lockPath(binding) {
|
|
|
1268
1307
|
const safe = binding.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
1269
1308
|
return path3.join(hubDir(), `consumer-${safe}.lock`);
|
|
1270
1309
|
}
|
|
1271
|
-
function pidAlive2(pid) {
|
|
1272
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
1273
|
-
try {
|
|
1274
|
-
process.kill(pid, 0);
|
|
1275
|
-
return true;
|
|
1276
|
-
} catch (error) {
|
|
1277
|
-
return error.code === "EPERM";
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
1310
|
function readLock(binding) {
|
|
1281
|
-
|
|
1282
|
-
const parsed = JSON.parse(fs3.readFileSync(lockPath(binding), "utf8"));
|
|
1283
|
-
if (typeof parsed.pid === "number" && typeof parsed.holder === "string" && typeof parsed.heartbeatAt === "number" && typeof parsed.binding === "string") {
|
|
1284
|
-
return {
|
|
1285
|
-
pid: parsed.pid,
|
|
1286
|
-
holder: parsed.holder,
|
|
1287
|
-
heartbeatAt: parsed.heartbeatAt,
|
|
1288
|
-
binding: parsed.binding
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
return void 0;
|
|
1292
|
-
} catch {
|
|
1293
|
-
return void 0;
|
|
1294
|
-
}
|
|
1311
|
+
return readOwnership(lockPath(binding), (v) => v.binding === binding);
|
|
1295
1312
|
}
|
|
1296
|
-
function lockAlive(info,
|
|
1297
|
-
|
|
1298
|
-
return pidAlive2(info.pid) && now - info.heartbeatAt < LOCK_STALE_MS;
|
|
1313
|
+
function lockAlive(info, _now = Date.now()) {
|
|
1314
|
+
return !!info && !pidDefinitelyDead(info.pid);
|
|
1299
1315
|
}
|
|
1300
1316
|
function tryClaimConsumer(binding, holder, onLost, shouldYield) {
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
fs3.rmSync(tmp, { force: true });
|
|
1315
|
-
if (error.code !== "EEXIST") throw error;
|
|
1316
|
-
return false;
|
|
1317
|
-
}
|
|
1318
|
-
} catch {
|
|
1319
|
-
return false;
|
|
1320
|
-
}
|
|
1321
|
-
};
|
|
1322
|
-
const existing = readLock(binding);
|
|
1323
|
-
if (existing && lockAlive(existing)) return void 0;
|
|
1324
|
-
if (existing) {
|
|
1325
|
-
try {
|
|
1326
|
-
fs3.rmSync(target, { force: true });
|
|
1327
|
-
} catch {
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
if (!takeOver()) return void 0;
|
|
1331
|
-
let released = false;
|
|
1332
|
-
const heartbeatTimer = setInterval(() => {
|
|
1333
|
-
if (released) return;
|
|
1334
|
-
try {
|
|
1335
|
-
const current = readLock(binding);
|
|
1336
|
-
if (current && current.pid !== process.pid) {
|
|
1337
|
-
released = true;
|
|
1338
|
-
clearInterval(heartbeatTimer);
|
|
1339
|
-
onLost?.();
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
if (shouldYield?.() === true) {
|
|
1343
|
-
released = true;
|
|
1344
|
-
clearInterval(heartbeatTimer);
|
|
1345
|
-
try {
|
|
1346
|
-
if (readLock(binding)?.pid === process.pid) fs3.rmSync(target, { force: true });
|
|
1347
|
-
} catch {
|
|
1348
|
-
}
|
|
1349
|
-
onLost?.();
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
fs3.writeFileSync(target, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), binding })}
|
|
1353
|
-
`);
|
|
1354
|
-
} catch {
|
|
1355
|
-
}
|
|
1356
|
-
}, 5e3);
|
|
1357
|
-
heartbeatTimer.unref();
|
|
1358
|
-
return {
|
|
1359
|
-
heartbeat: () => {
|
|
1317
|
+
try {
|
|
1318
|
+
const result = claimOwnership(
|
|
1319
|
+
lockPath(binding),
|
|
1320
|
+
{ pid: process.pid, holder, heartbeatAt: Date.now(), binding },
|
|
1321
|
+
(v) => v.binding === binding
|
|
1322
|
+
);
|
|
1323
|
+
if ("holder" in result) return void 0;
|
|
1324
|
+
let stopped = false;
|
|
1325
|
+
let retiring = false;
|
|
1326
|
+
const release = () => {
|
|
1327
|
+
if (retiring) return;
|
|
1328
|
+
stopped = true;
|
|
1329
|
+
clearInterval(timer);
|
|
1360
1330
|
try {
|
|
1361
|
-
|
|
1362
|
-
`);
|
|
1331
|
+
result.handle.release();
|
|
1363
1332
|
} catch {
|
|
1364
1333
|
}
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
clearInterval(
|
|
1334
|
+
};
|
|
1335
|
+
const retire = () => {
|
|
1336
|
+
stopped = true;
|
|
1337
|
+
retiring = true;
|
|
1338
|
+
clearInterval(timer);
|
|
1339
|
+
if (!onLost) return;
|
|
1340
|
+
void Promise.resolve().then(onLost).then(() => {
|
|
1341
|
+
retiring = false;
|
|
1342
|
+
release();
|
|
1343
|
+
}).catch(() => {
|
|
1344
|
+
});
|
|
1345
|
+
};
|
|
1346
|
+
const heartbeat = () => {
|
|
1347
|
+
if (stopped) return;
|
|
1370
1348
|
try {
|
|
1371
|
-
|
|
1372
|
-
if (current && current.pid === process.pid) fs3.rmSync(target, { force: true });
|
|
1349
|
+
if (shouldYield?.() === true || !result.handle.heartbeat()) retire();
|
|
1373
1350
|
} catch {
|
|
1351
|
+
retire();
|
|
1374
1352
|
}
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1353
|
+
};
|
|
1354
|
+
const timer = setInterval(heartbeat, 5e3);
|
|
1355
|
+
timer.unref();
|
|
1356
|
+
return { heartbeat, release };
|
|
1357
|
+
} catch {
|
|
1358
|
+
return void 0;
|
|
1359
|
+
}
|
|
1377
1360
|
}
|
|
1378
1361
|
function currentConsumer(binding) {
|
|
1379
|
-
|
|
1380
|
-
|
|
1362
|
+
try {
|
|
1363
|
+
const info = readLock(binding);
|
|
1364
|
+
return { info, alive: lockAlive(info) };
|
|
1365
|
+
} catch {
|
|
1366
|
+
return { info: void 0, alive: true };
|
|
1367
|
+
}
|
|
1381
1368
|
}
|
|
1382
1369
|
|
|
1383
1370
|
export {
|
|
@@ -1426,6 +1413,9 @@ export {
|
|
|
1426
1413
|
signEnvelope,
|
|
1427
1414
|
IpcTransport,
|
|
1428
1415
|
DISPATCH_PREFIX,
|
|
1416
|
+
onImBindingChanged,
|
|
1417
|
+
registerImBinding,
|
|
1418
|
+
currentImBinding,
|
|
1429
1419
|
registerTurnImDriver,
|
|
1430
1420
|
isTurnUserImDriven,
|
|
1431
1421
|
registerDispatchReceiver,
|
|
@@ -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
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getBuiltinDir,
|
|
4
|
-
getConfigDir
|
|
5
|
-
|
|
6
|
-
} from "./chunk-UCKOXAME.js";
|
|
4
|
+
getConfigDir
|
|
5
|
+
} from "./chunk-CBDQJMUI.js";
|
|
7
6
|
import {
|
|
8
7
|
classifyShellCommand,
|
|
9
8
|
createSharedWebFetchTool,
|
|
@@ -11,18 +10,18 @@ import {
|
|
|
11
10
|
createSharedWebSearchTool,
|
|
12
11
|
defaultShellKindForPlatform,
|
|
13
12
|
interpretShellExit
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BLDI2GRF.js";
|
|
15
14
|
import {
|
|
16
15
|
requestInteraction
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-Y3I2UV5Y.js";
|
|
18
17
|
import {
|
|
19
18
|
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
20
19
|
OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
|
|
21
20
|
getLogger
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3W3SXVPB.js";
|
|
23
22
|
import {
|
|
24
23
|
Type
|
|
25
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-XXGYUYXI.js";
|
|
26
25
|
|
|
27
26
|
// src/runtime/retry-policy.ts
|
|
28
27
|
var TRANSIENT_NETWORK_ERROR_PATTERN = /sse stream aborted|sse stream closed before end|sse stream ended before response completed|responses stream ended without a terminal event|(?:read\s+)?ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|(?:read\s+|write\s+)?EPIPE|socket hang up|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|client network socket disconnected before secure TLS connection was established|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated/i;
|
|
@@ -1412,7 +1411,6 @@ ${commandNonzeroHint}`;
|
|
|
1412
1411
|
}
|
|
1413
1412
|
|
|
1414
1413
|
// src/capabilities/rendered-page-reader.ts
|
|
1415
|
-
init_config();
|
|
1416
1414
|
import { spawn as spawn2 } from "node:child_process";
|
|
1417
1415
|
import { createRequire } from "node:module";
|
|
1418
1416
|
import * as fs from "node:fs";
|
|
@@ -1426,7 +1424,9 @@ function resolveAxiCli() {
|
|
|
1426
1424
|
}
|
|
1427
1425
|
function resolveMcpScript() {
|
|
1428
1426
|
const packageJson = require2.resolve("chrome-devtools-mcp/package.json");
|
|
1429
|
-
|
|
1427
|
+
const pkg = JSON.parse(fs.readFileSync(packageJson, "utf8"));
|
|
1428
|
+
const rel = pkg.bin?.["chrome-devtools-mcp"] ?? "build/src/bin/chrome-devtools-mcp.js";
|
|
1429
|
+
return path.join(path.dirname(packageJson), rel);
|
|
1430
1430
|
}
|
|
1431
1431
|
function runAxi(args, options = {}) {
|
|
1432
1432
|
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
@@ -1529,6 +1529,12 @@ function createCliRenderedPageReader() {
|
|
|
1529
1529
|
const session = `pie-web-research-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1530
1530
|
const env = { ...process.env, CHROME_DEVTOOLS_AXI_SESSION: session };
|
|
1531
1531
|
delete env.CHROME_DEVTOOLS_AXI_PORT;
|
|
1532
|
+
env.CHROME_DEVTOOLS_AXI_FRESH = "1";
|
|
1533
|
+
delete env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT;
|
|
1534
|
+
delete env.CHROME_DEVTOOLS_AXI_BROWSER_URL;
|
|
1535
|
+
delete env.CHROME_DEVTOOLS_AXI_USER_DATA_DIR;
|
|
1536
|
+
delete env.CHROME_DEVTOOLS_AXI_WS_HEADERS;
|
|
1537
|
+
delete env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL;
|
|
1532
1538
|
if (!env.CHROME_DEVTOOLS_AXI_MCP_PATH?.trim()) env.CHROME_DEVTOOLS_AXI_MCP_PATH = resolveMcpScript();
|
|
1533
1539
|
if (!env.CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS) env.CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS = "1";
|
|
1534
1540
|
cleanStaleScreenshotDirs();
|
|
@@ -1617,7 +1623,6 @@ function createCliWebResearchHealthStore(configDir) {
|
|
|
1617
1623
|
}
|
|
1618
1624
|
|
|
1619
1625
|
// src/capabilities/index.ts
|
|
1620
|
-
init_config();
|
|
1621
1626
|
function createCliHostCapabilities(cwd, options = {}) {
|
|
1622
1627
|
const bashTool = createBashTool(cwd, options.getBashEnv ? { getEnv: options.getBashEnv } : void 0);
|
|
1623
1628
|
const healthStore = createCliWebResearchHealthStore(options.configDir ?? getConfigDir());
|
|
@@ -11,14 +11,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
11
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
13
|
});
|
|
14
|
-
var __esm = (fn, res, err) => function __init() {
|
|
15
|
-
if (err) throw err[0];
|
|
16
|
-
try {
|
|
17
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
throw err = [e], e;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
14
|
var __commonJS = (cb, mod) => function __require2() {
|
|
23
15
|
try {
|
|
24
16
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -46,13 +38,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
46
38
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
47
39
|
mod
|
|
48
40
|
));
|
|
49
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
41
|
|
|
51
42
|
export {
|
|
52
43
|
__require,
|
|
53
|
-
__esm,
|
|
54
44
|
__commonJS,
|
|
55
45
|
__export,
|
|
56
|
-
__toESM
|
|
57
|
-
__toCommonJS
|
|
46
|
+
__toESM
|
|
58
47
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
getConfigDir
|
|
4
|
-
|
|
5
|
-
} from "./chunk-UCKOXAME.js";
|
|
3
|
+
getConfigDir
|
|
4
|
+
} from "./chunk-CBDQJMUI.js";
|
|
6
5
|
import {
|
|
7
6
|
MODEL_CLASS_FALLBACK_ORDER,
|
|
8
7
|
modelSupportsToolPurpose,
|
|
9
8
|
requiredCapabilityForToolPurpose,
|
|
10
9
|
sortToolModelCandidatesByCapability
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3W3SXVPB.js";
|
|
12
11
|
|
|
13
12
|
// src/core/model-registry.ts
|
|
14
|
-
init_config();
|
|
15
13
|
import * as fs from "fs";
|
|
16
14
|
import * as path from "path";
|
|
17
15
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
getConfigDir
|
|
4
|
-
|
|
5
|
-
} from "./chunk-UCKOXAME.js";
|
|
3
|
+
getConfigDir
|
|
4
|
+
} from "./chunk-CBDQJMUI.js";
|
|
6
5
|
|
|
7
6
|
// src/core/auth-storage.ts
|
|
8
|
-
init_config();
|
|
9
7
|
import * as fs from "fs";
|
|
10
8
|
import * as path from "path";
|
|
11
9
|
var AUTH_LOCK_WRITE_GRACE_MS = 1e3;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
__export
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LZQXQOPJ.js";
|
|
5
5
|
|
|
6
6
|
// ../../node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
|
|
7
7
|
function IsAsyncIterator(value) {
|