pi-fabric 0.92.23 → 0.92.25
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/agents/budget-ledger.d.ts.map +1 -1
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/chunks/{chunk-5Y2TKOQV.js → chunk-2GS5HMHE.js} +203 -111
- package/dist/chunks/chunk-2GS5HMHE.js.map +7 -0
- package/dist/chunks/{chunk-ZHOMIIUF.js → chunk-4BXUSX5F.js} +3 -3
- package/dist/chunks/{chunk-YQFAHWGE.js → chunk-5KOVDJHF.js} +144 -54
- package/dist/chunks/chunk-5KOVDJHF.js.map +7 -0
- package/dist/chunks/{chunk-VYXFSUWU.js → chunk-77PDIBK2.js} +12 -1
- package/dist/chunks/{chunk-VYXFSUWU.js.map → chunk-77PDIBK2.js.map} +2 -2
- package/dist/chunks/{chunk-WVH324VF.js → chunk-FAMBJFFF.js} +1 -1
- package/dist/chunks/{chunk-WVH324VF.js.map → chunk-FAMBJFFF.js.map} +1 -1
- package/dist/chunks/{chunk-MSCHYMYR.js → chunk-IEX4V6PV.js} +48 -2
- package/dist/chunks/{chunk-MSCHYMYR.js.map → chunk-IEX4V6PV.js.map} +2 -2
- package/dist/chunks/{chunk-ARLYAW2A.js → chunk-IR3PIHJM.js} +2 -1
- package/dist/chunks/chunk-IR3PIHJM.js.map +7 -0
- package/dist/chunks/{chunk-XFSRHUZH.js → chunk-LY6EE72A.js} +2 -2
- package/dist/chunks/{chunk-B74OWVAN.js → chunk-NPHCGLGH.js} +10 -7
- package/dist/chunks/chunk-NPHCGLGH.js.map +7 -0
- package/dist/chunks/{chunk-RETQZJ4K.js → chunk-PPHYL6LY.js} +2 -2
- package/dist/chunks/chunk-RAO6TQFP.js +187 -0
- package/dist/chunks/chunk-RAO6TQFP.js.map +7 -0
- package/dist/chunks/{chunk-UTR3I23Z.js → chunk-W63E3WEO.js} +2 -2
- package/dist/chunks/{chunk-NSTQH46Z.js → chunk-WLDAN6IZ.js} +7 -3
- package/dist/chunks/chunk-WLDAN6IZ.js.map +7 -0
- package/dist/chunks/{chunk-AFALENHK.js → chunk-WRKNLJSD.js} +2 -2
- package/dist/chunks/{chunk-SH6PXPNJ.js → chunk-X3OD47CL.js} +10 -2
- package/dist/chunks/{chunk-SH6PXPNJ.js.map → chunk-X3OD47CL.js.map} +3 -3
- package/dist/chunks/{chunk-VIBQBYJ6.js → chunk-XDSD4RLK.js} +3 -2
- package/dist/chunks/chunk-XDSD4RLK.js.map +7 -0
- package/dist/chunks/chunk-YP7I4BQD.js +134 -0
- package/dist/chunks/chunk-YP7I4BQD.js.map +7 -0
- package/dist/components/configuration.d.ts +42 -0
- package/dist/components/configuration.d.ts.map +1 -0
- package/dist/components/configuration.js +17 -0
- package/dist/components/configuration.js.map +7 -0
- package/dist/components/control.d.ts +76 -0
- package/dist/components/control.d.ts.map +1 -0
- package/dist/components/loader.d.ts +12 -0
- package/dist/components/loader.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/components/types.d.ts +2 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/components/validation.d.ts +6 -0
- package/dist/components/validation.d.ts.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +1 -0
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +2 -2
- package/dist/core/auto-approval-classifier.d.ts.map +1 -1
- package/dist/core/shell-jobs.d.ts +7 -1
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +361 -26
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.js +43 -19
- package/dist/index.js.map +3 -3
- package/dist/jev/browser.d.ts.map +1 -1
- package/dist/jev/browser.js +1 -1
- package/dist/jev/model-key.d.ts +6 -0
- package/dist/jev/model-key.d.ts.map +1 -0
- package/dist/jev.js +4 -4
- package/dist/output-budget.d.ts.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/components-provider.d.ts +5 -3
- package/dist/providers/components-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +3 -3
- package/dist/residency/host.js +5 -4
- package/dist/residency/pi-entry.js +5 -4
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +3 -2
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/typescript-kernel.js +5 -5
- package/dist/schema/policy.d.ts.map +1 -1
- package/dist/storage/retention.d.ts +3 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/storage/scratch.d.ts +33 -0
- package/dist/storage/scratch.d.ts.map +1 -0
- package/dist/ui/code-preview-shell.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +2 -2
- package/dist/ui/conversation-native-reader.js +4 -2
- package/dist/ui/conversation-native-reader.js.map +2 -2
- package/dist/ui/conversation.js +2 -2
- package/dist/ui/dashboard-presentation.d.ts.map +1 -1
- package/dist/ui/dashboard.js +11 -7
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/format.d.ts +1 -0
- package/dist/ui/format.d.ts.map +1 -1
- package/dist/ui/settings-sections-execution.d.ts.map +1 -1
- package/dist/ui/settings.js +12 -5
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/tool-call-timing.d.ts.map +1 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/docs/components.md +30 -1
- package/docs/configuration.md +16 -6
- package/docs/jev.md +1 -1
- package/package.json +1 -1
- package/skillsets/python/fabric-jev/SKILL.md +1 -1
- package/skillsets/typescript/fabric-exec/SKILL.md +5 -1
- package/skillsets/typescript/fabric-jev/SKILL.md +1 -1
- package/dist/chunks/chunk-5Y2TKOQV.js.map +0 -7
- package/dist/chunks/chunk-ARLYAW2A.js.map +0 -7
- package/dist/chunks/chunk-B74OWVAN.js.map +0 -7
- package/dist/chunks/chunk-NSTQH46Z.js.map +0 -7
- package/dist/chunks/chunk-VIBQBYJ6.js.map +0 -7
- package/dist/chunks/chunk-YQFAHWGE.js.map +0 -7
- /package/dist/chunks/{chunk-ZHOMIIUF.js.map → chunk-4BXUSX5F.js.map} +0 -0
- /package/dist/chunks/{chunk-XFSRHUZH.js.map → chunk-LY6EE72A.js.map} +0 -0
- /package/dist/chunks/{chunk-RETQZJ4K.js.map → chunk-PPHYL6LY.js.map} +0 -0
- /package/dist/chunks/{chunk-UTR3I23Z.js.map → chunk-W63E3WEO.js.map} +0 -0
- /package/dist/chunks/{chunk-AFALENHK.js.map → chunk-WRKNLJSD.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-ledger.d.ts","sourceRoot":"","sources":["../../src/agents/budget-ledger.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AA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AAE,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,cAAc;IAkBnF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,gBAAgB;IAKpE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,gBAAgB;IAgBvE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,gBAAgB;IAIvE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,gBAAgB;IAUvE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB;IA4B5D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA8qBvB"}
|
|
@@ -30,7 +30,11 @@ import {
|
|
|
30
30
|
MAX_AGENT_TIMEOUT_MS,
|
|
31
31
|
MIN_AGENT_TIMEOUT_MS,
|
|
32
32
|
quarantineDamagedFile
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-5KOVDJHF.js";
|
|
34
|
+
import {
|
|
35
|
+
ownedStat,
|
|
36
|
+
processAlive
|
|
37
|
+
} from "./chunk-RAO6TQFP.js";
|
|
34
38
|
import {
|
|
35
39
|
writeFileAtomic,
|
|
36
40
|
writeJsonAtomic
|
|
@@ -95,7 +99,7 @@ var EVENT_READ_CHUNK_BYTES = 64 * 1024;
|
|
|
95
99
|
var CURSOR_OFFSET_BASE = 2 ** 32;
|
|
96
100
|
var delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
97
101
|
var errorCode = (error) => error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
98
|
-
var
|
|
102
|
+
var processAlive2 = (pid) => {
|
|
99
103
|
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
100
104
|
try {
|
|
101
105
|
process.kill(pid, 0);
|
|
@@ -636,7 +640,7 @@ ${Date.now()}
|
|
|
636
640
|
const [, pidText, createdText] = owner.trim().split("\n");
|
|
637
641
|
const createdAt = Number(createdText);
|
|
638
642
|
if (Number.isFinite(createdAt) && Date.now() - createdAt <= this.#staleLockMs) return false;
|
|
639
|
-
if (
|
|
643
|
+
if (processAlive2(Number(pidText))) return false;
|
|
640
644
|
try {
|
|
641
645
|
if (fs.readFileSync(ownerPath2, "utf8") !== owner) return false;
|
|
642
646
|
fs.rmSync(this.#lockPath, { recursive: true, force: true });
|
|
@@ -893,7 +897,15 @@ function activeBudgetState() {
|
|
|
893
897
|
function initBudgetLedger(budget) {
|
|
894
898
|
const directory = fs2.mkdtempSync(path4.join(os.tmpdir(), "pi-fabric-budget-"));
|
|
895
899
|
const file = path4.join(directory, "cost.jsonl");
|
|
896
|
-
|
|
900
|
+
try {
|
|
901
|
+
fs2.writeFileSync(file, "", { mode: 384 });
|
|
902
|
+
} catch (error) {
|
|
903
|
+
try {
|
|
904
|
+
fs2.rmSync(directory, { recursive: true, force: true });
|
|
905
|
+
} catch {
|
|
906
|
+
}
|
|
907
|
+
throw error;
|
|
908
|
+
}
|
|
897
909
|
const id = randomUUID2().replaceAll("-", "").slice(0, 16);
|
|
898
910
|
process.env[ENV_BUDGET] = String(budget);
|
|
899
911
|
process.env[ENV_BUDGET_FILE] = file;
|
|
@@ -1469,51 +1481,93 @@ var WorktreeManager = class {
|
|
|
1469
1481
|
// src/storage/retention.ts
|
|
1470
1482
|
import fs8 from "node:fs";
|
|
1471
1483
|
import path9 from "node:path";
|
|
1472
|
-
var FABRIC_RUN_ROOT_PREFIX = "pi-fabric-runs-";
|
|
1473
1484
|
var RUN_ROOT_OWNER_FILE = ".fabric-owner.json";
|
|
1474
1485
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "stopped", "timed_out"]);
|
|
1475
1486
|
var ownerPath = (root) => path9.join(root, RUN_ROOT_OWNER_FILE);
|
|
1476
|
-
var readJson = (
|
|
1487
|
+
var readJson = (file) => {
|
|
1477
1488
|
try {
|
|
1478
|
-
|
|
1489
|
+
const stat = ownedStat(file);
|
|
1490
|
+
if (!stat?.isFile() || stat.size > 1024 * 1024) return;
|
|
1491
|
+
return JSON.parse(fs8.readFileSync(file, "utf8"));
|
|
1479
1492
|
} catch {
|
|
1480
|
-
return
|
|
1481
|
-
}
|
|
1482
|
-
};
|
|
1483
|
-
var processAlive2 = (pid) => {
|
|
1484
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
1485
|
-
try {
|
|
1486
|
-
process.kill(pid, 0);
|
|
1487
|
-
return true;
|
|
1488
|
-
} catch (error) {
|
|
1489
|
-
return !(error instanceof Error && "code" in error && error.code === "ESRCH");
|
|
1493
|
+
return;
|
|
1490
1494
|
}
|
|
1491
1495
|
};
|
|
1496
|
+
var time = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
1497
|
+
var validOwner = (owner) => !!owner && Number.isSafeInteger(owner.pid) && owner.pid > 0 && time(owner.startedAt) && time(owner.heartbeatAt) && (owner.closedAt === void 0 || time(owner.closedAt)) && (owner.orphanedAt === void 0 || time(owner.orphanedAt)) && (owner.childrenStopped === void 0 || typeof owner.childrenStopped === "boolean");
|
|
1492
1498
|
var writeOwner = (root, owner) => {
|
|
1493
|
-
|
|
1499
|
+
if (fs8.existsSync(root) && !ownedStat(root)?.isDirectory()) throw new Error("Unsafe Fabric run root");
|
|
1500
|
+
const file = ownerPath(root);
|
|
1501
|
+
if (fs8.existsSync(file)) {
|
|
1502
|
+
const existing = readJson(file);
|
|
1503
|
+
if (!validOwner(existing) || existing.pid !== owner.pid) throw new Error("Unsafe Fabric run owner marker");
|
|
1504
|
+
}
|
|
1505
|
+
writeJsonAtomic(file, owner);
|
|
1494
1506
|
};
|
|
1495
1507
|
var markRunRootActive = (root, now = Date.now()) => {
|
|
1496
1508
|
const existing = readJson(ownerPath(root));
|
|
1497
|
-
writeOwner(root, {
|
|
1498
|
-
pid: process.pid,
|
|
1499
|
-
startedAt: existing?.startedAt ?? now,
|
|
1500
|
-
heartbeatAt: now
|
|
1501
|
-
});
|
|
1502
|
-
};
|
|
1503
|
-
var heartbeatRunRoot = (root, now = Date.now()) => {
|
|
1504
|
-
markRunRootActive(root, now);
|
|
1509
|
+
writeOwner(root, { pid: process.pid, startedAt: validOwner(existing) ? existing.startedAt : now, heartbeatAt: now });
|
|
1505
1510
|
};
|
|
1506
|
-
var
|
|
1511
|
+
var heartbeatRunRoot = markRunRootActive;
|
|
1512
|
+
var markRunRootClosed = (root, now = Date.now(), childrenStopped = false) => {
|
|
1507
1513
|
const existing = readJson(ownerPath(root));
|
|
1508
|
-
writeOwner(root, {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
+
writeOwner(root, { pid: process.pid, startedAt: validOwner(existing) ? existing.startedAt : now, heartbeatAt: now, closedAt: now, childrenStopped });
|
|
1515
|
+
};
|
|
1516
|
+
var recordAgeReference = (record, fallback) => time(record.finishedAt) ? record.finishedAt : time(record.updatedAt) ? record.updatedAt : fallback;
|
|
1517
|
+
var runFiles = /* @__PURE__ */ new Set(["task.txt", "status.json", "events.jsonl", "lifecycle.jsonl", "steer.jsonl", "schema.json", "images.json"]);
|
|
1518
|
+
var safeRunTree = (root, childrenStopped, depth = 0) => {
|
|
1519
|
+
if (depth > 32 || !ownedStat(root)?.isDirectory()) return false;
|
|
1520
|
+
const record = readJson(path9.join(root, "status.json"));
|
|
1521
|
+
const pid = record?.transport === "process" && typeof record.sessionId === "string" && /^\d+$/.test(record.sessionId) ? Number(record.sessionId) : void 0;
|
|
1522
|
+
if (pid !== void 0 && processAlive(pid)) return false;
|
|
1523
|
+
if (!record?.status || !TERMINAL_STATUSES.has(record.status)) {
|
|
1524
|
+
if (!childrenStopped && pid === void 0) return false;
|
|
1525
|
+
if (!ownedStat(path9.join(root, "task.txt"))?.isFile()) return false;
|
|
1526
|
+
}
|
|
1527
|
+
try {
|
|
1528
|
+
for (const name of fs8.readdirSync(root)) {
|
|
1529
|
+
const file = path9.join(root, name);
|
|
1530
|
+
const stat = ownedStat(file);
|
|
1531
|
+
if (!stat) return false;
|
|
1532
|
+
if (stat.isFile() && runFiles.has(name)) continue;
|
|
1533
|
+
if (stat.isDirectory() && name === "handoff-session") {
|
|
1534
|
+
if (fs8.readdirSync(file).some((child) => !child.endsWith(".jsonl") || !ownedStat(path9.join(file, child))?.isFile())) return false;
|
|
1535
|
+
continue;
|
|
1536
|
+
}
|
|
1537
|
+
if (stat.isDirectory() && name === "nested") {
|
|
1538
|
+
for (const child of fs8.readdirSync(file)) if (!safeRunTree(path9.join(file, child), false, depth + 1)) return false;
|
|
1539
|
+
continue;
|
|
1540
|
+
}
|
|
1541
|
+
return false;
|
|
1542
|
+
}
|
|
1543
|
+
return true;
|
|
1544
|
+
} catch {
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
var safeRootContents = (root, childrenStopped) => {
|
|
1549
|
+
try {
|
|
1550
|
+
return fs8.readdirSync(root).every((name) => name === RUN_ROOT_OWNER_FILE || safeRunTree(path9.join(root, name), childrenStopped));
|
|
1551
|
+
} catch {
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
var canRemoveManagedRunRoot = (root) => {
|
|
1556
|
+
if (!ownedStat(root)?.isDirectory()) return false;
|
|
1557
|
+
const owner = readJson(ownerPath(root));
|
|
1558
|
+
return validOwner(owner) && owner.pid === process.pid && safeRootContents(root, true);
|
|
1559
|
+
};
|
|
1560
|
+
var removeEmptyRunRoot = (root) => {
|
|
1561
|
+
try {
|
|
1562
|
+
if (!ownedStat(root)?.isDirectory() || !validOwner(readJson(ownerPath(root)))) return false;
|
|
1563
|
+
if (fs8.readdirSync(root).some((name) => name !== RUN_ROOT_OWNER_FILE)) return false;
|
|
1564
|
+
fs8.rmSync(root, { recursive: true, force: true });
|
|
1565
|
+
return true;
|
|
1566
|
+
} catch {
|
|
1567
|
+
return false;
|
|
1568
|
+
}
|
|
1514
1569
|
};
|
|
1515
|
-
var
|
|
1516
|
-
var pruneClosedRunRoot = (root, orphanedTempRunRetentionMs, oneShotRunRetentionMs, now) => {
|
|
1570
|
+
var pruneClosedRunRoot = (root, owner, orphanMs, oneShotMs, now) => {
|
|
1517
1571
|
const removed = [];
|
|
1518
1572
|
let entries;
|
|
1519
1573
|
try {
|
|
@@ -1523,31 +1577,21 @@ var pruneClosedRunRoot = (root, orphanedTempRunRetentionMs, oneShotRunRetentionM
|
|
|
1523
1577
|
}
|
|
1524
1578
|
for (const entry of entries) {
|
|
1525
1579
|
if (!entry.isDirectory()) continue;
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1580
|
+
const directory = path9.join(root, entry.name);
|
|
1581
|
+
if (!safeRunTree(directory, owner.childrenStopped === true)) continue;
|
|
1582
|
+
const record = readJson(path9.join(directory, "status.json"));
|
|
1583
|
+
const terminal = !!record?.status && TERMINAL_STATUSES.has(record.status);
|
|
1584
|
+
const reference = terminal ? recordAgeReference(record, ownedStat(directory)?.mtimeMs ?? now) : owner.closedAt;
|
|
1585
|
+
const retention = terminal && !record?.actorId ? oneShotMs : orphanMs;
|
|
1586
|
+
if (now - reference < retention) continue;
|
|
1530
1587
|
try {
|
|
1531
|
-
|
|
1588
|
+
fs8.rmSync(directory, { recursive: true, force: true });
|
|
1589
|
+
removed.push(directory);
|
|
1532
1590
|
} catch {
|
|
1533
1591
|
}
|
|
1534
|
-
const retentionMs = record.actorId ? orphanedTempRunRetentionMs : oneShotRunRetentionMs;
|
|
1535
|
-
if (now - recordAgeReference(record, fallback) < retentionMs) continue;
|
|
1536
|
-
fs8.rmSync(runDirectory, { recursive: true, force: true });
|
|
1537
|
-
removed.push(runDirectory);
|
|
1538
1592
|
}
|
|
1539
1593
|
return removed;
|
|
1540
1594
|
};
|
|
1541
|
-
var removeIfEmpty = (root) => {
|
|
1542
|
-
try {
|
|
1543
|
-
const remaining = fs8.readdirSync(root).filter((name) => name !== RUN_ROOT_OWNER_FILE);
|
|
1544
|
-
if (remaining.length > 0) return false;
|
|
1545
|
-
fs8.rmSync(root, { recursive: true, force: true });
|
|
1546
|
-
return true;
|
|
1547
|
-
} catch {
|
|
1548
|
-
return false;
|
|
1549
|
-
}
|
|
1550
|
-
};
|
|
1551
1595
|
var sweepTempRunRoots = (options) => {
|
|
1552
1596
|
const now = options.now ?? Date.now();
|
|
1553
1597
|
const result = { removedRoots: [], removedRuns: [] };
|
|
@@ -1558,46 +1602,38 @@ var sweepTempRunRoots = (options) => {
|
|
|
1558
1602
|
return result;
|
|
1559
1603
|
}
|
|
1560
1604
|
for (const entry of entries) {
|
|
1561
|
-
if (!entry.isDirectory() ||
|
|
1605
|
+
if (!entry.isDirectory() || !/^pi-fabric-runs-[A-Za-z0-9_-]+$/.test(entry.name)) continue;
|
|
1562
1606
|
const root = path9.join(options.tempRoot, entry.name);
|
|
1563
1607
|
if (options.currentRoot && path9.resolve(root) === path9.resolve(options.currentRoot)) continue;
|
|
1608
|
+
if (!ownedStat(root)?.isDirectory()) continue;
|
|
1564
1609
|
const owner = readJson(ownerPath(root));
|
|
1565
|
-
if (!owner)
|
|
1610
|
+
if (!validOwner(owner)) continue;
|
|
1611
|
+
if (owner.closedAt !== void 0) {
|
|
1612
|
+
result.removedRuns.push(...pruneClosedRunRoot(root, owner, options.orphanedTempRunRetentionMs, options.oneShotRunRetentionMs, now));
|
|
1613
|
+
if (removeEmptyRunRoot(root)) result.removedRoots.push(root);
|
|
1614
|
+
continue;
|
|
1615
|
+
}
|
|
1616
|
+
if (processAlive(owner.pid)) continue;
|
|
1617
|
+
if (owner.orphanedAt === void 0) {
|
|
1566
1618
|
try {
|
|
1567
|
-
|
|
1568
|
-
fs8.rmSync(root, { recursive: true, force: true });
|
|
1569
|
-
result.removedRoots.push(root);
|
|
1570
|
-
}
|
|
1619
|
+
writeOwner(root, { ...owner, orphanedAt: now });
|
|
1571
1620
|
} catch {
|
|
1572
1621
|
}
|
|
1573
1622
|
continue;
|
|
1574
1623
|
}
|
|
1575
|
-
if (
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
options.oneShotRunRetentionMs,
|
|
1581
|
-
now
|
|
1582
|
-
)
|
|
1583
|
-
);
|
|
1584
|
-
if (removeIfEmpty(root)) result.removedRoots.push(root);
|
|
1585
|
-
continue;
|
|
1586
|
-
}
|
|
1587
|
-
if (processAlive2(owner.pid)) continue;
|
|
1588
|
-
if (typeof owner.orphanedAt !== "number") {
|
|
1589
|
-
writeOwner(root, { ...owner, orphanedAt: now });
|
|
1590
|
-
continue;
|
|
1624
|
+
if (now - owner.orphanedAt < options.orphanedTempRunRetentionMs || !safeRootContents(root, false)) continue;
|
|
1625
|
+
try {
|
|
1626
|
+
fs8.rmSync(root, { recursive: true, force: true });
|
|
1627
|
+
result.removedRoots.push(root);
|
|
1628
|
+
} catch {
|
|
1591
1629
|
}
|
|
1592
|
-
if (now - owner.orphanedAt < options.orphanedTempRunRetentionMs) continue;
|
|
1593
|
-
fs8.rmSync(root, { recursive: true, force: true });
|
|
1594
|
-
result.removedRoots.push(root);
|
|
1595
1630
|
}
|
|
1596
1631
|
return result;
|
|
1597
1632
|
};
|
|
1598
1633
|
var pruneActorRunArchives = (options) => {
|
|
1599
1634
|
const now = options.now ?? Date.now();
|
|
1600
1635
|
const removed = [];
|
|
1636
|
+
if (!ownedStat(options.runsDirectory)?.isDirectory()) return removed;
|
|
1601
1637
|
let entries;
|
|
1602
1638
|
try {
|
|
1603
1639
|
entries = fs8.readdirSync(options.runsDirectory, { withFileTypes: true });
|
|
@@ -1606,17 +1642,15 @@ var pruneActorRunArchives = (options) => {
|
|
|
1606
1642
|
}
|
|
1607
1643
|
for (const entry of entries) {
|
|
1608
1644
|
if (!entry.isDirectory() || entry.name === options.latestRunId) continue;
|
|
1609
|
-
const
|
|
1610
|
-
const record = readJson(path9.join(
|
|
1611
|
-
if (!record?.status || !TERMINAL_STATUSES.has(record.status)) continue;
|
|
1612
|
-
|
|
1645
|
+
const directory = path9.join(options.runsDirectory, entry.name);
|
|
1646
|
+
const record = readJson(path9.join(directory, "status.json"));
|
|
1647
|
+
if (!record?.status || !TERMINAL_STATUSES.has(record.status) || !safeRunTree(directory, false)) continue;
|
|
1648
|
+
if (now - recordAgeReference(record, ownedStat(directory)?.mtimeMs ?? now) < options.retentionMs) continue;
|
|
1613
1649
|
try {
|
|
1614
|
-
|
|
1650
|
+
fs8.rmSync(directory, { recursive: true, force: true });
|
|
1651
|
+
removed.push(directory);
|
|
1615
1652
|
} catch {
|
|
1616
1653
|
}
|
|
1617
|
-
if (now - recordAgeReference(record, fallback) < options.retentionMs) continue;
|
|
1618
|
-
fs8.rmSync(runDirectory, { recursive: true, force: true });
|
|
1619
|
-
removed.push(runDirectory);
|
|
1620
1654
|
}
|
|
1621
1655
|
return removed;
|
|
1622
1656
|
};
|
|
@@ -1873,14 +1907,6 @@ var AgentManager = class {
|
|
|
1873
1907
|
this.#transports = new Map(adapters.map((adapter) => [adapter.kind, adapter]));
|
|
1874
1908
|
if (this.#managedTempRoot) {
|
|
1875
1909
|
markRunRootActive(this.#runRoot);
|
|
1876
|
-
sweepTempRunRoots({
|
|
1877
|
-
tempRoot: os3.tmpdir(),
|
|
1878
|
-
currentRoot: this.#runRoot,
|
|
1879
|
-
orphanedTempRunRetentionMs: this.#retention.orphanedTempRunMs,
|
|
1880
|
-
oneShotRunRetentionMs: this.#retention.oneShotRunMs
|
|
1881
|
-
});
|
|
1882
|
-
this.#retentionTimer = setInterval(() => this.#scheduleRetentionSweep(), RETENTION_SWEEP_INTERVAL_MS);
|
|
1883
|
-
this.#retentionTimer.unref();
|
|
1884
1910
|
}
|
|
1885
1911
|
}
|
|
1886
1912
|
#runs = /* @__PURE__ */ new Map();
|
|
@@ -1921,6 +1947,11 @@ var AgentManager = class {
|
|
|
1921
1947
|
#uiListRevision = 0;
|
|
1922
1948
|
#uiListCache;
|
|
1923
1949
|
#closing = false;
|
|
1950
|
+
#closePromise;
|
|
1951
|
+
#closeAbort = new AbortController();
|
|
1952
|
+
#spawns = /* @__PURE__ */ new Set();
|
|
1953
|
+
#unregisteredTransports = /* @__PURE__ */ new Set();
|
|
1954
|
+
#launches = /* @__PURE__ */ new Set();
|
|
1924
1955
|
async #prepareModel(model) {
|
|
1925
1956
|
if (!this.#preparePiModel) return model;
|
|
1926
1957
|
const key = model?.trim() || "<session-default>";
|
|
@@ -1987,7 +2018,26 @@ var AgentManager = class {
|
|
|
1987
2018
|
}
|
|
1988
2019
|
return runtime2;
|
|
1989
2020
|
}
|
|
1990
|
-
|
|
2021
|
+
spawn(request, signal) {
|
|
2022
|
+
if (this.#closing) return Promise.reject(new Error("Fabric agent manager is closing"));
|
|
2023
|
+
const pending = this.#spawn(request, signal);
|
|
2024
|
+
this.#spawns.add(pending);
|
|
2025
|
+
void pending.then(() => this.#spawns.delete(pending), () => this.#spawns.delete(pending));
|
|
2026
|
+
return pending;
|
|
2027
|
+
}
|
|
2028
|
+
async #launchTransport(adapter, request) {
|
|
2029
|
+
if (this.#closing) throw new Error("Fabric agent manager is closing");
|
|
2030
|
+
const pending = adapter.launch(request);
|
|
2031
|
+
this.#launches.add(pending);
|
|
2032
|
+
try {
|
|
2033
|
+
const transport = await pending;
|
|
2034
|
+
this.#unregisteredTransports.add(transport);
|
|
2035
|
+
return transport;
|
|
2036
|
+
} finally {
|
|
2037
|
+
this.#launches.delete(pending);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
async #spawn(request, signal) {
|
|
1991
2041
|
if (!this.config.enabled) throw new Error("Agents are disabled in Fabric configuration");
|
|
1992
2042
|
if (this.#currentDepth >= this.config.maxDepth) {
|
|
1993
2043
|
throw new Error(`Fabric agent depth limit reached (${this.config.maxDepth})`);
|
|
@@ -2041,9 +2091,11 @@ var AgentManager = class {
|
|
|
2041
2091
|
);
|
|
2042
2092
|
}
|
|
2043
2093
|
}
|
|
2044
|
-
const
|
|
2094
|
+
const admissionSignal = signal ? AbortSignal.any([signal, this.#closeAbort.signal]) : this.#closeAbort.signal;
|
|
2095
|
+
const release = await this.#semaphore.acquire("native", admissionSignal);
|
|
2045
2096
|
try {
|
|
2046
2097
|
if (runner === "pi") model = await this.#prepareModel(model);
|
|
2098
|
+
if (this.#closing) throw new Error("Fabric agent manager is closing");
|
|
2047
2099
|
this.#semaphore.admit(this.#currentDepth + 1);
|
|
2048
2100
|
} catch (error) {
|
|
2049
2101
|
release();
|
|
@@ -2053,6 +2105,11 @@ var AgentManager = class {
|
|
|
2053
2105
|
const name = safeName(request.name ?? request.task.split("\n", 1)[0] ?? "Fabric agent");
|
|
2054
2106
|
const runDirectory = path11.join(this.#runRoot, id);
|
|
2055
2107
|
fs9.mkdirSync(runDirectory, { recursive: true });
|
|
2108
|
+
if (this.#managedTempRoot && !this.#retentionTimer) {
|
|
2109
|
+
this.#retentionTimer = setInterval(() => this.#scheduleRetentionSweep(), RETENTION_SWEEP_INTERVAL_MS);
|
|
2110
|
+
this.#retentionTimer.unref();
|
|
2111
|
+
this.#scheduleRetentionSweep();
|
|
2112
|
+
}
|
|
2056
2113
|
const taskFile = path11.join(runDirectory, "task.txt");
|
|
2057
2114
|
const statusFile = path11.join(runDirectory, "status.json");
|
|
2058
2115
|
const lifecycleFile = path11.join(runDirectory, "lifecycle.jsonl");
|
|
@@ -2188,10 +2245,12 @@ var AgentManager = class {
|
|
|
2188
2245
|
workerPath: this.#workerPath,
|
|
2189
2246
|
workerArguments
|
|
2190
2247
|
};
|
|
2191
|
-
|
|
2248
|
+
if (this.#closing) throw new Error("Fabric agent manager is closing");
|
|
2249
|
+
const transport = await this.#launchTransport(adapter, launch);
|
|
2192
2250
|
const lifecycle = createAgentLifecycle(release);
|
|
2193
|
-
if (signal?.aborted) {
|
|
2251
|
+
if (signal?.aborted || this.#closing) {
|
|
2194
2252
|
await transport.stop();
|
|
2253
|
+
if (!await transport.isAlive().catch(() => true)) this.#unregisteredTransports.delete(transport);
|
|
2195
2254
|
throw new Error("Agent launch aborted");
|
|
2196
2255
|
}
|
|
2197
2256
|
const managed = {
|
|
@@ -2241,6 +2300,7 @@ var AgentManager = class {
|
|
|
2241
2300
|
signal.addEventListener("abort", managed.abortHandler, { once: true });
|
|
2242
2301
|
}
|
|
2243
2302
|
this.#runs.set(id, managed);
|
|
2303
|
+
this.#unregisteredTransports.delete(transport);
|
|
2244
2304
|
this.#invalidateUiList();
|
|
2245
2305
|
void this.#monitor(managed, timeoutMs);
|
|
2246
2306
|
return this.#handleInfo(managed, "running");
|
|
@@ -2482,28 +2542,59 @@ var AgentManager = class {
|
|
|
2482
2542
|
fs9.appendFileSync(steerFile, line, { encoding: "utf8", mode: 384 });
|
|
2483
2543
|
return { queued: true, messageId };
|
|
2484
2544
|
}
|
|
2485
|
-
|
|
2545
|
+
close() {
|
|
2486
2546
|
this.#closing = true;
|
|
2547
|
+
this.#closeAbort.abort(new Error("Fabric agent manager is closing"));
|
|
2548
|
+
return this.#closePromise ??= this.#close();
|
|
2549
|
+
}
|
|
2550
|
+
async #close() {
|
|
2487
2551
|
this.#uiListeners.clear();
|
|
2488
2552
|
if (this.#retentionTimer) clearInterval(this.#retentionTimer);
|
|
2489
2553
|
this.#retentionTimer = void 0;
|
|
2490
2554
|
await this.#retentionSweep?.catch(() => void 0);
|
|
2491
2555
|
const running = [...this.#runs.values()].filter((managed) => !managed.settled);
|
|
2492
2556
|
await Promise.allSettled(running.map((managed) => this.stop(managed.id)));
|
|
2493
|
-
await Promise.allSettled(
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2557
|
+
await Promise.allSettled([...this.#spawns]);
|
|
2558
|
+
await Promise.allSettled([...this.#launches]);
|
|
2559
|
+
const all = [...this.#runs.values()];
|
|
2560
|
+
await Promise.allSettled(all.map((managed) => this.#waitForTransportExit(managed)));
|
|
2561
|
+
const transports2 = [...all.map((managed) => managed.transport), ...this.#unregisteredTransports];
|
|
2562
|
+
const alive = await Promise.all(transports2.map((transport) => transport.isAlive().catch(() => true)));
|
|
2563
|
+
if (!alive.some(Boolean)) {
|
|
2564
|
+
this.#unregisteredTransports.clear();
|
|
2565
|
+
const storageSafe = !this.#managedTempRoot || canRemoveManagedRunRoot(this.#runRoot);
|
|
2566
|
+
if (!this.config.retainRuns) {
|
|
2567
|
+
if (storageSafe) {
|
|
2568
|
+
await removeTree(this.#runRoot).catch(() => void 0);
|
|
2569
|
+
}
|
|
2570
|
+
} else if (this.#managedTempRoot) {
|
|
2571
|
+
try {
|
|
2572
|
+
markRunRootClosed(this.#runRoot, Date.now(), true);
|
|
2573
|
+
} catch {
|
|
2574
|
+
}
|
|
2575
|
+
removeEmptyRunRoot(this.#runRoot);
|
|
2576
|
+
}
|
|
2577
|
+
if (storageSafe && this.#budgetOwned && this.#budget) {
|
|
2578
|
+
await removeTree(path11.dirname(this.#budget.file)).catch(() => void 0);
|
|
2579
|
+
}
|
|
2498
2580
|
}
|
|
2499
|
-
if (this.#budgetOwned
|
|
2500
|
-
|
|
2501
|
-
|
|
2581
|
+
if (this.#budgetOwned) clearOwnedBudgetEnv();
|
|
2582
|
+
if (this.#managedTempRoot) {
|
|
2583
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2584
|
+
try {
|
|
2585
|
+
sweepTempRunRoots({
|
|
2586
|
+
tempRoot: os3.tmpdir(),
|
|
2587
|
+
currentRoot: this.#runRoot,
|
|
2588
|
+
orphanedTempRunRetentionMs: this.#retention.orphanedTempRunMs,
|
|
2589
|
+
oneShotRunRetentionMs: this.#retention.oneShotRunMs
|
|
2590
|
+
});
|
|
2591
|
+
} catch {
|
|
2592
|
+
}
|
|
2502
2593
|
}
|
|
2503
2594
|
}
|
|
2504
2595
|
#scheduleRetentionSweep() {
|
|
2505
2596
|
if (this.#closing || this.#retentionSweep) return;
|
|
2506
|
-
this.#retentionSweep = this.#runRetentionSweep().finally(() => {
|
|
2597
|
+
this.#retentionSweep = new Promise((resolve) => setImmediate(resolve)).then(() => this.#closing ? void 0 : this.#runRetentionSweep()).catch(() => void 0).finally(() => {
|
|
2507
2598
|
this.#retentionSweep = void 0;
|
|
2508
2599
|
});
|
|
2509
2600
|
}
|
|
@@ -2610,7 +2701,8 @@ var AgentManager = class {
|
|
|
2610
2701
|
this.#drainLifecycle(managed);
|
|
2611
2702
|
fs9.rmSync(managed.statusFile, { force: true });
|
|
2612
2703
|
if (managed.settled || this.#closing || managed.stopRequested) return false;
|
|
2613
|
-
managed.transport = await managed.adapter
|
|
2704
|
+
managed.transport = await this.#launchTransport(managed.adapter, managed.launch);
|
|
2705
|
+
this.#unregisteredTransports.delete(managed.transport);
|
|
2614
2706
|
if (managed.settled || this.#closing || managed.stopRequested) {
|
|
2615
2707
|
await managed.transport.stop().catch(() => void 0);
|
|
2616
2708
|
return false;
|
|
@@ -6870,4 +6962,4 @@ export {
|
|
|
6870
6962
|
agentParticipantRecords,
|
|
6871
6963
|
actorParticipantRecord
|
|
6872
6964
|
};
|
|
6873
|
-
//# sourceMappingURL=chunk-
|
|
6965
|
+
//# sourceMappingURL=chunk-2GS5HMHE.js.map
|