@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
|
@@ -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,9 @@ 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.imBinding === "string" && record.imBinding.length <= 512 && !hasControlChars(record.imBinding)) file.imBinding = record.imBinding;
|
|
772
780
|
if (Array.isArray(record.allowPeers) && record.allowPeers.length <= 1e3 && record.allowPeers.every((id) => typeof id === "string" && (id === "*" || isValidInstanceId(id)))) file.allowPeers = record.allowPeers;
|
|
773
781
|
if (typeof record.secret === "string" && /^[a-f0-9]{64}$/.test(record.secret)) file.secret = record.secret;
|
|
774
782
|
if (typeof record.sessionName === "string" && !hasControlChars(record.sessionName) && record.sessionName.length <= MAX_DISPLAY_NAME_CHARS) file.sessionName = record.sessionName;
|
|
@@ -1132,7 +1140,6 @@ var IpcTransport = class {
|
|
|
1132
1140
|
};
|
|
1133
1141
|
|
|
1134
1142
|
// builtin/extensions/im-forward/event-hub.ts
|
|
1135
|
-
import * as fs3 from "node:fs";
|
|
1136
1143
|
import * as path3 from "node:path";
|
|
1137
1144
|
|
|
1138
1145
|
// builtin/extensions/im-forward/address-book.ts
|
|
@@ -1223,8 +1230,10 @@ function resolveAddress(text, ownLiveName, book) {
|
|
|
1223
1230
|
return { kind: "none" };
|
|
1224
1231
|
}
|
|
1225
1232
|
const body = text.trimStart().slice(name.length + 1).trim();
|
|
1233
|
+
if (!resolvedBook.complete) return { kind: "ambiguous", name, reason: "address book unreadable" };
|
|
1226
1234
|
const foreignOwners = resolvedBook.names.get(name);
|
|
1227
1235
|
if (foreignOwners && foreignOwners.size > 0) {
|
|
1236
|
+
if (foreignOwners.size > 1) return { kind: "ambiguous", name, reason: "duplicate live session name" };
|
|
1228
1237
|
if (resolvedBook.selfPublished === name || live === name) return { kind: "ambiguous", name, reason: "duplicate live session name" };
|
|
1229
1238
|
return { kind: "other", name };
|
|
1230
1239
|
}
|
|
@@ -1238,6 +1247,36 @@ function resolveAddress(text, ownLiveName, book) {
|
|
|
1238
1247
|
// builtin/extensions/im-forward/event-hub.ts
|
|
1239
1248
|
var DISPATCH_PREFIX = "[im-forward-dispatch]";
|
|
1240
1249
|
var dispatchReceiver;
|
|
1250
|
+
var imBinding;
|
|
1251
|
+
var bindingListeners = /* @__PURE__ */ new Set();
|
|
1252
|
+
function bindingChanged() {
|
|
1253
|
+
for (const fn of bindingListeners) {
|
|
1254
|
+
try {
|
|
1255
|
+
fn();
|
|
1256
|
+
} catch {
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function onImBindingChanged(fn) {
|
|
1261
|
+
bindingListeners.add(fn);
|
|
1262
|
+
return () => {
|
|
1263
|
+
bindingListeners.delete(fn);
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
function registerImBinding(value) {
|
|
1267
|
+
const token = Symbol(value);
|
|
1268
|
+
imBinding = { value, token };
|
|
1269
|
+
bindingChanged();
|
|
1270
|
+
return () => {
|
|
1271
|
+
if (imBinding?.token === token) {
|
|
1272
|
+
imBinding = void 0;
|
|
1273
|
+
bindingChanged();
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
function currentImBinding() {
|
|
1278
|
+
return imBinding?.value;
|
|
1279
|
+
}
|
|
1241
1280
|
var turnImDriverOracle;
|
|
1242
1281
|
function registerTurnImDriver(oracle) {
|
|
1243
1282
|
turnImDriverOracle = oracle;
|
|
@@ -1260,7 +1299,6 @@ function takeDispatchFrame(text) {
|
|
|
1260
1299
|
return true;
|
|
1261
1300
|
}
|
|
1262
1301
|
}
|
|
1263
|
-
var LOCK_STALE_MS = 2e4;
|
|
1264
1302
|
function hubDir() {
|
|
1265
1303
|
return path3.join(addressBookRoot(), "im-forward");
|
|
1266
1304
|
}
|
|
@@ -1268,116 +1306,64 @@ function lockPath(binding) {
|
|
|
1268
1306
|
const safe = binding.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
1269
1307
|
return path3.join(hubDir(), `consumer-${safe}.lock`);
|
|
1270
1308
|
}
|
|
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
1309
|
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
|
-
}
|
|
1310
|
+
return readOwnership(lockPath(binding), (v) => v.binding === binding);
|
|
1295
1311
|
}
|
|
1296
|
-
function lockAlive(info,
|
|
1297
|
-
|
|
1298
|
-
return pidAlive2(info.pid) && now - info.heartbeatAt < LOCK_STALE_MS;
|
|
1312
|
+
function lockAlive(info, _now = Date.now()) {
|
|
1313
|
+
return !!info && !pidDefinitelyDead(info.pid);
|
|
1299
1314
|
}
|
|
1300
1315
|
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: () => {
|
|
1316
|
+
try {
|
|
1317
|
+
const result = claimOwnership(
|
|
1318
|
+
lockPath(binding),
|
|
1319
|
+
{ pid: process.pid, holder, heartbeatAt: Date.now(), binding },
|
|
1320
|
+
(v) => v.binding === binding
|
|
1321
|
+
);
|
|
1322
|
+
if ("holder" in result) return void 0;
|
|
1323
|
+
let stopped = false;
|
|
1324
|
+
let retiring = false;
|
|
1325
|
+
const release = () => {
|
|
1326
|
+
if (retiring) return;
|
|
1327
|
+
stopped = true;
|
|
1328
|
+
clearInterval(timer);
|
|
1360
1329
|
try {
|
|
1361
|
-
|
|
1362
|
-
`);
|
|
1330
|
+
result.handle.release();
|
|
1363
1331
|
} catch {
|
|
1364
1332
|
}
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
clearInterval(
|
|
1333
|
+
};
|
|
1334
|
+
const retire = () => {
|
|
1335
|
+
stopped = true;
|
|
1336
|
+
retiring = true;
|
|
1337
|
+
clearInterval(timer);
|
|
1338
|
+
if (!onLost) return;
|
|
1339
|
+
void Promise.resolve().then(onLost).then(() => {
|
|
1340
|
+
retiring = false;
|
|
1341
|
+
release();
|
|
1342
|
+
}).catch(() => {
|
|
1343
|
+
});
|
|
1344
|
+
};
|
|
1345
|
+
const heartbeat = () => {
|
|
1346
|
+
if (stopped) return;
|
|
1370
1347
|
try {
|
|
1371
|
-
|
|
1372
|
-
if (current && current.pid === process.pid) fs3.rmSync(target, { force: true });
|
|
1348
|
+
if (shouldYield?.() === true || !result.handle.heartbeat()) retire();
|
|
1373
1349
|
} catch {
|
|
1350
|
+
retire();
|
|
1374
1351
|
}
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1352
|
+
};
|
|
1353
|
+
const timer = setInterval(heartbeat, 5e3);
|
|
1354
|
+
timer.unref();
|
|
1355
|
+
return { heartbeat, release };
|
|
1356
|
+
} catch {
|
|
1357
|
+
return void 0;
|
|
1358
|
+
}
|
|
1377
1359
|
}
|
|
1378
1360
|
function currentConsumer(binding) {
|
|
1379
|
-
|
|
1380
|
-
|
|
1361
|
+
try {
|
|
1362
|
+
const info = readLock(binding);
|
|
1363
|
+
return { info, alive: lockAlive(info) };
|
|
1364
|
+
} catch {
|
|
1365
|
+
return { info: void 0, alive: true };
|
|
1366
|
+
}
|
|
1381
1367
|
}
|
|
1382
1368
|
|
|
1383
1369
|
export {
|
|
@@ -1426,6 +1412,9 @@ export {
|
|
|
1426
1412
|
signEnvelope,
|
|
1427
1413
|
IpcTransport,
|
|
1428
1414
|
DISPATCH_PREFIX,
|
|
1415
|
+
onImBindingChanged,
|
|
1416
|
+
registerImBinding,
|
|
1417
|
+
currentImBinding,
|
|
1429
1418
|
registerTurnImDriver,
|
|
1430
1419
|
isTurnUserImDriven,
|
|
1431
1420
|
registerDispatchReceiver,
|
|
@@ -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) {
|
|
@@ -2,17 +2,17 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
createAgentOperationError,
|
|
4
4
|
getAgentFailureMetadata
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5KI4Y4LA.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSystemGateway,
|
|
8
8
|
detectPlatform,
|
|
9
9
|
getFileSystemGateway,
|
|
10
10
|
getPlatformConfig,
|
|
11
11
|
streamSimple
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3W3SXVPB.js";
|
|
13
13
|
import {
|
|
14
14
|
Type
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XXGYUYXI.js";
|
|
16
16
|
|
|
17
17
|
// ../../packages/agent-framework/src/skills/parser.ts
|
|
18
18
|
function parseFrontmatter(yaml) {
|
|
@@ -147,7 +147,7 @@ function pathContains(parent, child) {
|
|
|
147
147
|
}
|
|
148
148
|
async function readExcludeCwds() {
|
|
149
149
|
try {
|
|
150
|
-
const { getSettingsPath } = await import("./config-
|
|
150
|
+
const { getSettingsPath } = await import("./config-4EOI5NOU.js");
|
|
151
151
|
const raw = JSON.parse(fs.readFileSync(getSettingsPath(), "utf8"));
|
|
152
152
|
const list = raw?.extensions?.memory?.excludeCwds;
|
|
153
153
|
if (!Array.isArray(list)) return [];
|
|
@@ -171,11 +171,11 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
171
171
|
let result;
|
|
172
172
|
let ledger;
|
|
173
173
|
try {
|
|
174
|
-
const { ModelRegistry } = await import("./model-registry-
|
|
175
|
-
const { AuthStorage } = await import("./auth-storage-
|
|
176
|
-
const { getSessionsDir } = await import("./config-
|
|
177
|
-
const { FileSessionStore } = await import("./src-
|
|
178
|
-
const { MemoryStore, runDistillation } = await import("./src-
|
|
174
|
+
const { ModelRegistry } = await import("./model-registry-3XAHXXTA.js");
|
|
175
|
+
const { AuthStorage } = await import("./auth-storage-C3FZMT7J.js");
|
|
176
|
+
const { getSessionsDir } = await import("./config-4EOI5NOU.js");
|
|
177
|
+
const { FileSessionStore } = await import("./src-EGXFJ3WA.js");
|
|
178
|
+
const { MemoryStore, runDistillation } = await import("./src-CLE5ILN4.js");
|
|
179
179
|
const store = new MemoryStore(memoryRoot);
|
|
180
180
|
ledger = store;
|
|
181
181
|
const registry = new ModelRegistry(AuthStorage.create());
|
|
@@ -190,7 +190,7 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
190
190
|
if (!resolved.model || !resolved.apiKey) {
|
|
191
191
|
throw new Error(`no complete model/key pair for class ${modelClass}${resolved.fallbackReason ? `: ${resolved.fallbackReason}` : ""}`);
|
|
192
192
|
}
|
|
193
|
-
const { completeSimple } = await import("./src-
|
|
193
|
+
const { completeSimple } = await import("./src-Q7LU27C2.js");
|
|
194
194
|
const message = await withModelTimeout(
|
|
195
195
|
completeSimple(
|
|
196
196
|
resolved.model,
|
|
@@ -255,7 +255,7 @@ async function runDistillAuto(memoryRoot, days = 7, runner) {
|
|
|
255
255
|
} catch {
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
|
-
const { MemoryStore, todayKey } = await import("./src-
|
|
258
|
+
const { MemoryStore, todayKey } = await import("./src-CLE5ILN4.js");
|
|
259
259
|
const store = new MemoryStore(memoryRoot);
|
|
260
260
|
const today = todayKey(Date.now());
|
|
261
261
|
const dates = [];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/core/node-ownership-lock.ts
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
function pidDefinitelyDead(pid) {
|
|
8
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
9
|
+
try {
|
|
10
|
+
process.kill(pid, 0);
|
|
11
|
+
return false;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return error.code === "ESRCH";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function withOwnershipMutex(lock, fn) {
|
|
17
|
+
fs.mkdirSync(path.dirname(lock), { recursive: true, mode: 448 });
|
|
18
|
+
const token = randomUUID();
|
|
19
|
+
const candidate = `${lock}.acquire.${token}`;
|
|
20
|
+
fs.mkdirSync(candidate, { mode: 448 });
|
|
21
|
+
try {
|
|
22
|
+
fs.writeFileSync(path.join(candidate, `held.${token}`), JSON.stringify({ version: 1, pid: process.pid }), { flag: "wx", mode: 384 });
|
|
23
|
+
const deadline = process.hrtime.bigint() + 2000000000n;
|
|
24
|
+
for (; ; ) {
|
|
25
|
+
try {
|
|
26
|
+
fs.renameSync(candidate, lock);
|
|
27
|
+
break;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (!["EEXIST", "ENOTEMPTY", "EPERM", "ENOTDIR"].includes(error.code ?? "")) throw error;
|
|
30
|
+
if (process.hrtime.bigint() >= deadline) throw new Error(`Ownership mutex contention: ${lock}`);
|
|
31
|
+
try {
|
|
32
|
+
const entries = fs.readdirSync(lock);
|
|
33
|
+
if (entries.every((name) => {
|
|
34
|
+
if (!/^held\.[a-f0-9-]+$/.test(name)) return false;
|
|
35
|
+
const value = JSON.parse(fs.readFileSync(path.join(lock, name), "utf8"));
|
|
36
|
+
return value?.version === 1 && pidDefinitelyDead(value.pid);
|
|
37
|
+
})) {
|
|
38
|
+
for (const name of entries) {
|
|
39
|
+
try {
|
|
40
|
+
fs.unlinkSync(path.join(lock, name));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
if (e.code !== "ENOENT") throw e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
fs.rmdirSync(lock);
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return fn();
|
|
54
|
+
} finally {
|
|
55
|
+
try {
|
|
56
|
+
fs.unlinkSync(path.join(lock, `held.${token}`));
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
fs.rmdirSync(lock);
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} finally {
|
|
65
|
+
fs.rmSync(candidate, { recursive: true, force: true });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function readOwnership(target, valid) {
|
|
69
|
+
let raw;
|
|
70
|
+
try {
|
|
71
|
+
raw = fs.readFileSync(target, "utf8");
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (error.code === "ENOENT") return void 0;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
const value = JSON.parse(raw);
|
|
77
|
+
if (!value || !Number.isInteger(value.pid) || value.pid <= 0 || typeof value.holder !== "string" || !Number.isFinite(value.heartbeatAt) || value.generation !== void 0 && typeof value.generation !== "string" || !valid(value)) {
|
|
78
|
+
throw new Error(`Invalid ownership record: ${target}`);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
function claimOwnership(target, mine, valid) {
|
|
83
|
+
const mutex = `${target}.mutex`;
|
|
84
|
+
const generation = randomUUID();
|
|
85
|
+
const publish = () => {
|
|
86
|
+
const tmp = `${target}.${randomUUID()}.tmp`;
|
|
87
|
+
try {
|
|
88
|
+
fs.writeFileSync(tmp, `${JSON.stringify({ ...mine, generation, heartbeatAt: Date.now() })}
|
|
89
|
+
`, { flag: "wx", mode: 384 });
|
|
90
|
+
fs.renameSync(tmp, target);
|
|
91
|
+
} finally {
|
|
92
|
+
fs.rmSync(tmp, { force: true });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const holder = withOwnershipMutex(mutex, () => {
|
|
96
|
+
const current = readOwnership(target, valid);
|
|
97
|
+
if (current && !pidDefinitelyDead(current.pid)) return current;
|
|
98
|
+
publish();
|
|
99
|
+
return void 0;
|
|
100
|
+
});
|
|
101
|
+
if (holder) return { holder };
|
|
102
|
+
let released = false;
|
|
103
|
+
return { handle: {
|
|
104
|
+
heartbeat: () => {
|
|
105
|
+
if (released) return false;
|
|
106
|
+
return withOwnershipMutex(mutex, () => {
|
|
107
|
+
if (readOwnership(target, valid)?.generation !== generation) return false;
|
|
108
|
+
publish();
|
|
109
|
+
return true;
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
release: () => {
|
|
113
|
+
if (released) return;
|
|
114
|
+
released = true;
|
|
115
|
+
withOwnershipMutex(mutex, () => {
|
|
116
|
+
if (readOwnership(target, valid)?.generation === generation) fs.unlinkSync(target);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
} };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
pidDefinitelyDead,
|
|
124
|
+
readOwnership,
|
|
125
|
+
claimOwnership
|
|
126
|
+
};
|
|
@@ -18,13 +18,11 @@ import {
|
|
|
18
18
|
getSessionsDir,
|
|
19
19
|
getSettingsPath,
|
|
20
20
|
getThemesDir,
|
|
21
|
-
init_config,
|
|
22
21
|
isBunRuntime,
|
|
23
22
|
migrateConfigFromAgentDir,
|
|
24
23
|
resolveSessionsDirOverride
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
init_config();
|
|
24
|
+
} from "./chunk-CBDQJMUI.js";
|
|
25
|
+
import "./chunk-LZQXQOPJ.js";
|
|
28
26
|
export {
|
|
29
27
|
APP_NAME,
|
|
30
28
|
CONFIG_DIR_NAME,
|
|
@@ -3,10 +3,9 @@ import {
|
|
|
3
3
|
readProcessCommandLine
|
|
4
4
|
} from "./chunk-X6LBWHK3.js";
|
|
5
5
|
import {
|
|
6
|
-
getConfigDir
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import "./chunk-RZGYXAJU.js";
|
|
6
|
+
getConfigDir
|
|
7
|
+
} from "./chunk-CBDQJMUI.js";
|
|
8
|
+
import "./chunk-LZQXQOPJ.js";
|
|
10
9
|
|
|
11
10
|
// src/commands/manager-cli.ts
|
|
12
11
|
import { spawn, execFileSync } from "node:child_process";
|
|
@@ -14,7 +13,6 @@ import { createRequire } from "node:module";
|
|
|
14
13
|
import * as fs from "node:fs";
|
|
15
14
|
import * as os from "node:os";
|
|
16
15
|
import * as path from "node:path";
|
|
17
|
-
init_config();
|
|
18
16
|
var require_ = createRequire(import.meta.url);
|
|
19
17
|
var CRON_SECTION_MARKER = "## \u5B9A\u65F6\u4EFB\u52A1";
|
|
20
18
|
var CRON_SECTION = `
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
assertNoSecretSubstrings,
|
|
5
5
|
configuredRemoteCredentialValues,
|
|
6
6
|
loadResolvedModelsConfig
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-NHV2CALB.js";
|
|
8
|
+
import "./chunk-CBDQJMUI.js";
|
|
9
|
+
import "./chunk-3W3SXVPB.js";
|
|
10
|
+
import "./chunk-XXGYUYXI.js";
|
|
11
|
+
import "./chunk-LZQXQOPJ.js";
|
|
12
12
|
export {
|
|
13
13
|
ModelRegistry,
|
|
14
14
|
assertNoSecretSubstrings,
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
createToolCallerIdentity,
|
|
9
9
|
getAgentFailureMetadata,
|
|
10
10
|
getToolCallerIdentity
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-5KI4Y4LA.js";
|
|
12
|
+
import "./chunk-3W3SXVPB.js";
|
|
13
|
+
import "./chunk-XXGYUYXI.js";
|
|
14
|
+
import "./chunk-LZQXQOPJ.js";
|
|
15
15
|
export {
|
|
16
16
|
Agent,
|
|
17
17
|
agentLoop,
|