@wrongstack/core 0.24.0 → 0.31.1
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/coordination/index.d.ts +3 -3
- package/dist/coordination/index.js +414 -71
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +2 -2
- package/dist/defaults/index.js +388 -57
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +47 -5
- package/dist/execution/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +635 -242
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.js +2 -1
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/{multi-agent-coordinator-Dcsc5t4-.d.ts → multi-agent-coordinator-DOXSgtom.d.ts} +4 -0
- package/dist/{null-fleet-bus-Cq4YKOiW.d.ts → null-fleet-bus-CAQDGsKc.d.ts} +58 -2
- package/dist/sdd/index.js +40 -3
- package/dist/sdd/index.js.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +76 -1
- package/dist/utils/index.js +171 -5
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as crypto2 from 'crypto';
|
|
2
2
|
import { randomBytes, createCipheriv, createDecipheriv, randomUUID, createHash } from 'crypto';
|
|
3
|
-
import * as
|
|
3
|
+
import * as fsp3 from 'fs/promises';
|
|
4
4
|
import { readFile, readdir, stat, mkdir } from 'fs/promises';
|
|
5
5
|
import * as path6 from 'path';
|
|
6
|
-
import { join, extname, relative, resolve, sep } from 'path';
|
|
6
|
+
import { join, extname, relative, isAbsolute, resolve, sep } from 'path';
|
|
7
7
|
import * as fs2 from 'fs';
|
|
8
8
|
import * as os5 from 'os';
|
|
9
9
|
import { execFile, spawn } from 'child_process';
|
|
@@ -37,16 +37,16 @@ __export(atomic_write_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
39
39
|
const dir = path6.dirname(targetPath);
|
|
40
|
-
await
|
|
40
|
+
await fsp3.mkdir(dir, { recursive: true });
|
|
41
41
|
const tmp = path6.join(dir, `.${path6.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
42
42
|
try {
|
|
43
43
|
if (typeof content === "string") {
|
|
44
|
-
await
|
|
44
|
+
await fsp3.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
|
|
45
45
|
} else {
|
|
46
|
-
await
|
|
46
|
+
await fsp3.writeFile(tmp, content, { flag: "wx" });
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
const fh = await
|
|
49
|
+
const fh = await fsp3.open(tmp, "r+");
|
|
50
50
|
try {
|
|
51
51
|
await fh.sync();
|
|
52
52
|
} finally {
|
|
@@ -56,36 +56,36 @@ async function atomicWrite(targetPath, content, opts = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
let mode;
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
60
|
-
mode =
|
|
59
|
+
const stat10 = await fsp3.stat(targetPath);
|
|
60
|
+
mode = stat10.mode & 511;
|
|
61
61
|
} catch {
|
|
62
62
|
mode = opts.mode;
|
|
63
63
|
}
|
|
64
64
|
if (mode !== void 0) {
|
|
65
|
-
await
|
|
65
|
+
await fsp3.chmod(tmp, mode);
|
|
66
66
|
}
|
|
67
67
|
await renameWithRetry(tmp, targetPath);
|
|
68
68
|
} catch (err) {
|
|
69
69
|
try {
|
|
70
|
-
await
|
|
70
|
+
await fsp3.unlink(tmp);
|
|
71
71
|
} catch {
|
|
72
72
|
}
|
|
73
73
|
throw err;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
async function ensureDir(dir) {
|
|
77
|
-
await
|
|
77
|
+
await fsp3.mkdir(dir, { recursive: true });
|
|
78
78
|
}
|
|
79
79
|
async function renameWithRetry(from, to) {
|
|
80
80
|
if (process.platform !== "win32") {
|
|
81
|
-
await
|
|
81
|
+
await fsp3.rename(from, to);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
const delays = [10, 25, 60, 120, 250];
|
|
85
85
|
let lastErr;
|
|
86
86
|
for (let i = 0; i <= delays.length; i++) {
|
|
87
87
|
try {
|
|
88
|
-
await
|
|
88
|
+
await fsp3.rename(from, to);
|
|
89
89
|
return;
|
|
90
90
|
} catch (err) {
|
|
91
91
|
lastErr = err;
|
|
@@ -93,7 +93,7 @@ async function renameWithRetry(from, to) {
|
|
|
93
93
|
if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
|
|
94
94
|
throw err;
|
|
95
95
|
}
|
|
96
|
-
await new Promise((
|
|
96
|
+
await new Promise((resolve10) => setTimeout(resolve10, delays[i]));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
throw lastErr;
|
|
@@ -1206,20 +1206,20 @@ function isSecretField(name) {
|
|
|
1206
1206
|
async function rewriteConfigEncrypted(configPath, vault, patch) {
|
|
1207
1207
|
let current = {};
|
|
1208
1208
|
try {
|
|
1209
|
-
const raw = await
|
|
1209
|
+
const raw = await fsp3.readFile(configPath, "utf8");
|
|
1210
1210
|
current = JSON.parse(raw);
|
|
1211
1211
|
} catch {
|
|
1212
1212
|
}
|
|
1213
1213
|
const merged = deepMerge(current, patch ?? {});
|
|
1214
1214
|
const encrypted = encryptConfigSecrets(merged, vault);
|
|
1215
|
-
await
|
|
1215
|
+
await fsp3.mkdir(path6.dirname(configPath), { recursive: true });
|
|
1216
1216
|
await atomicWrite(configPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
1217
1217
|
await restrictFilePermissions(configPath);
|
|
1218
1218
|
}
|
|
1219
1219
|
async function migratePlaintextSecrets(configPath, vault) {
|
|
1220
1220
|
let raw;
|
|
1221
1221
|
try {
|
|
1222
|
-
raw = await
|
|
1222
|
+
raw = await fsp3.readFile(configPath, "utf8");
|
|
1223
1223
|
} catch {
|
|
1224
1224
|
return { migrated: 0, file: configPath };
|
|
1225
1225
|
}
|
|
@@ -1248,7 +1248,7 @@ async function restrictFilePermissions(filePath) {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
} else {
|
|
1250
1250
|
try {
|
|
1251
|
-
await
|
|
1251
|
+
await fsp3.chmod(filePath, 384);
|
|
1252
1252
|
} catch {
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
@@ -1550,6 +1550,17 @@ function round4(n) {
|
|
|
1550
1550
|
|
|
1551
1551
|
// src/utils/token-estimate.ts
|
|
1552
1552
|
var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
|
|
1553
|
+
var _cal = {
|
|
1554
|
+
ratio: 1,
|
|
1555
|
+
// current calibration multiplier (actual / estimated)
|
|
1556
|
+
count: 0,
|
|
1557
|
+
// number of samples recorded
|
|
1558
|
+
prevEst: 0,
|
|
1559
|
+
// estimated tokens from the most recent estimateRequestTokens call
|
|
1560
|
+
/** EWM α — higher = faster adaptation, more volatile */
|
|
1561
|
+
alpha: 0.3
|
|
1562
|
+
};
|
|
1563
|
+
var MIN_SAMPLES_FOR_CALIBRATION = 3;
|
|
1553
1564
|
var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
|
|
1554
1565
|
var ESTIMATE_CACHE_MAX_SIZE = 1e4;
|
|
1555
1566
|
function getCachedEstimate(key, compute) {
|
|
@@ -1622,13 +1633,53 @@ function estimateRequestTokens(messages, systemPrompt, tools) {
|
|
|
1622
1633
|
for (const t2 of tools) {
|
|
1623
1634
|
toolsTokens += estimateToolDefTokens(t2);
|
|
1624
1635
|
}
|
|
1636
|
+
const total = messagesTokens + systemTokens + toolsTokens;
|
|
1637
|
+
_cal.prevEst = total;
|
|
1625
1638
|
return {
|
|
1626
1639
|
messages: messagesTokens,
|
|
1627
1640
|
systemPrompt: systemTokens,
|
|
1628
1641
|
tools: toolsTokens,
|
|
1629
|
-
total
|
|
1642
|
+
total
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
function recordActualUsage(actualInputTokens, estimatedInputTokens) {
|
|
1646
|
+
if (actualInputTokens <= 0) return;
|
|
1647
|
+
const est = estimatedInputTokens ?? _cal.prevEst;
|
|
1648
|
+
if (est <= 0) return;
|
|
1649
|
+
const sampleRatio = actualInputTokens / est;
|
|
1650
|
+
if (_cal.count === 0) {
|
|
1651
|
+
_cal.ratio = sampleRatio;
|
|
1652
|
+
} else {
|
|
1653
|
+
_cal.ratio = _cal.alpha * sampleRatio + (1 - _cal.alpha) * _cal.ratio;
|
|
1654
|
+
}
|
|
1655
|
+
_cal.ratio = Math.min(1.5, Math.max(0.5, _cal.ratio));
|
|
1656
|
+
_cal.count++;
|
|
1657
|
+
}
|
|
1658
|
+
function getCalibrationState() {
|
|
1659
|
+
return {
|
|
1660
|
+
ratio: _cal.ratio,
|
|
1661
|
+
count: _cal.count,
|
|
1662
|
+
calibrated: _cal.count >= MIN_SAMPLES_FOR_CALIBRATION
|
|
1630
1663
|
};
|
|
1631
1664
|
}
|
|
1665
|
+
function estimateRequestTokensCalibrated(messages, systemPrompt, tools) {
|
|
1666
|
+
const result = estimateRequestTokens(messages, systemPrompt, tools);
|
|
1667
|
+
if (_cal.count >= MIN_SAMPLES_FOR_CALIBRATION) {
|
|
1668
|
+
const safeRatio = Math.min(1.5, Math.max(0.5, _cal.ratio));
|
|
1669
|
+
return {
|
|
1670
|
+
messages: Math.round(result.messages * safeRatio),
|
|
1671
|
+
systemPrompt: Math.round(result.systemPrompt * safeRatio),
|
|
1672
|
+
tools: Math.round(result.tools * safeRatio),
|
|
1673
|
+
total: Math.round(result.total * safeRatio)
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
return result;
|
|
1677
|
+
}
|
|
1678
|
+
function resetCalibration() {
|
|
1679
|
+
_cal.ratio = 1;
|
|
1680
|
+
_cal.count = 0;
|
|
1681
|
+
_cal.prevEst = 0;
|
|
1682
|
+
}
|
|
1632
1683
|
|
|
1633
1684
|
// src/utils/message-invariants.ts
|
|
1634
1685
|
function repairToolUseAdjacency(messages) {
|
|
@@ -2431,7 +2482,7 @@ var DefaultModelsRegistry = class {
|
|
|
2431
2482
|
async readOverlayFile() {
|
|
2432
2483
|
if (!this.overlayFile) return void 0;
|
|
2433
2484
|
try {
|
|
2434
|
-
const raw = await
|
|
2485
|
+
const raw = await fsp3.readFile(this.overlayFile, "utf8");
|
|
2435
2486
|
return JSON.parse(raw);
|
|
2436
2487
|
} catch {
|
|
2437
2488
|
return void 0;
|
|
@@ -2509,7 +2560,7 @@ var DefaultModelsRegistry = class {
|
|
|
2509
2560
|
}
|
|
2510
2561
|
async readCacheAt(file) {
|
|
2511
2562
|
try {
|
|
2512
|
-
const raw = await
|
|
2563
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
2513
2564
|
return JSON.parse(raw);
|
|
2514
2565
|
} catch {
|
|
2515
2566
|
return void 0;
|
|
@@ -2927,7 +2978,7 @@ var InMemoryAgentBridge = class {
|
|
|
2927
2978
|
);
|
|
2928
2979
|
}
|
|
2929
2980
|
this.inflightGuards.add(correlationId);
|
|
2930
|
-
return new Promise((
|
|
2981
|
+
return new Promise((resolve10, reject) => {
|
|
2931
2982
|
const timer = setTimeout(() => {
|
|
2932
2983
|
this.inflightGuards.delete(correlationId);
|
|
2933
2984
|
this.pendingRequests.delete(correlationId);
|
|
@@ -2939,7 +2990,7 @@ var InMemoryAgentBridge = class {
|
|
|
2939
2990
|
return;
|
|
2940
2991
|
}
|
|
2941
2992
|
this.pendingRequests.set(correlationId, {
|
|
2942
|
-
resolve:
|
|
2993
|
+
resolve: resolve10,
|
|
2943
2994
|
reject,
|
|
2944
2995
|
timer
|
|
2945
2996
|
});
|
|
@@ -4441,6 +4492,120 @@ function buildChildEnv(optsOrSessionId) {
|
|
|
4441
4492
|
if (opts.sessionId) out["WRONGSTACK_SESSION_ID"] = opts.sessionId;
|
|
4442
4493
|
return out;
|
|
4443
4494
|
}
|
|
4495
|
+
var GLOB_CHARS = /* @__PURE__ */ new Set(["*", "?", "["]);
|
|
4496
|
+
var IS_WINDOWS = process.platform === "win32";
|
|
4497
|
+
var SEP = IS_WINDOWS ? "\\" : "/";
|
|
4498
|
+
function isGlob(p) {
|
|
4499
|
+
for (const c of p) {
|
|
4500
|
+
if (GLOB_CHARS.has(c)) return true;
|
|
4501
|
+
}
|
|
4502
|
+
return false;
|
|
4503
|
+
}
|
|
4504
|
+
function globToRegex(pat) {
|
|
4505
|
+
let i = 0, re = "^";
|
|
4506
|
+
while (i < pat.length) {
|
|
4507
|
+
const c = pat[i];
|
|
4508
|
+
if (c === "*") {
|
|
4509
|
+
if (pat[i + 1] === "*") {
|
|
4510
|
+
re += ".*";
|
|
4511
|
+
i += 2;
|
|
4512
|
+
if (pat[i] === "/") i++;
|
|
4513
|
+
} else {
|
|
4514
|
+
re += "[^/\\\\]*";
|
|
4515
|
+
i++;
|
|
4516
|
+
}
|
|
4517
|
+
} else if (c === "?") {
|
|
4518
|
+
re += "[^/\\\\]";
|
|
4519
|
+
i++;
|
|
4520
|
+
} else if (c === "[") {
|
|
4521
|
+
let cls = "[";
|
|
4522
|
+
i++;
|
|
4523
|
+
if (pat[i] === "!" || pat[i] === "^") {
|
|
4524
|
+
cls += "^";
|
|
4525
|
+
i++;
|
|
4526
|
+
}
|
|
4527
|
+
while (i < pat.length && pat[i] !== "]") {
|
|
4528
|
+
const ch = pat[i] ?? "";
|
|
4529
|
+
if (ch === "\\") cls += "\\\\";
|
|
4530
|
+
else if (ch === "]" || ch === "^") cls += `\\${ch}`;
|
|
4531
|
+
else cls += ch;
|
|
4532
|
+
i++;
|
|
4533
|
+
}
|
|
4534
|
+
cls += "]";
|
|
4535
|
+
re += cls;
|
|
4536
|
+
i++;
|
|
4537
|
+
} else {
|
|
4538
|
+
re += c.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
4539
|
+
i++;
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
return new RegExp(re + "$");
|
|
4543
|
+
}
|
|
4544
|
+
function baseDir(pat) {
|
|
4545
|
+
let i = pat.length - 1;
|
|
4546
|
+
while (i >= 0 && !GLOB_CHARS.has(pat[i]) && pat[i] !== SEP && pat[i] !== "/") i--;
|
|
4547
|
+
const cut = i >= 0 ? pat.lastIndexOf(SEP, i) : pat.lastIndexOf("/", i);
|
|
4548
|
+
return cut < 0 ? "." : pat.slice(0, cut);
|
|
4549
|
+
}
|
|
4550
|
+
async function expandGlob(pattern) {
|
|
4551
|
+
if (!isGlob(pattern)) return [pattern];
|
|
4552
|
+
const results = /* @__PURE__ */ new Set();
|
|
4553
|
+
const abs = isAbsolute(pattern);
|
|
4554
|
+
const base = abs ? baseDir(pattern) : baseDir(pattern);
|
|
4555
|
+
const relPat = base === "." ? pattern : pattern.slice(base.length + 1);
|
|
4556
|
+
async function walk4(dir, pat) {
|
|
4557
|
+
let entries;
|
|
4558
|
+
try {
|
|
4559
|
+
entries = await fsp3.readdir(dir);
|
|
4560
|
+
} catch {
|
|
4561
|
+
return;
|
|
4562
|
+
}
|
|
4563
|
+
const firstGlob = pat.search(/[*?[\[]/);
|
|
4564
|
+
if (firstGlob < 0) {
|
|
4565
|
+
const re = globToRegex(pat);
|
|
4566
|
+
for (const e of entries) {
|
|
4567
|
+
if (re.test(e)) {
|
|
4568
|
+
const full = `${dir}${SEP}${e}`;
|
|
4569
|
+
results.add(abs ? resolve(full) : full);
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
return;
|
|
4573
|
+
}
|
|
4574
|
+
const before = pat.slice(0, firstGlob);
|
|
4575
|
+
const rest = pat.slice(firstGlob);
|
|
4576
|
+
if (before.endsWith("**")) {
|
|
4577
|
+
await walk4(dir, rest);
|
|
4578
|
+
for (const e of entries) {
|
|
4579
|
+
const full = `${dir}${SEP}${e}`;
|
|
4580
|
+
try {
|
|
4581
|
+
const stat10 = await fsp3.stat(full);
|
|
4582
|
+
if (stat10.isDirectory()) await walk4(full, rest);
|
|
4583
|
+
} catch {
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
} else if (before === "") {
|
|
4587
|
+
const re = globToRegex(rest);
|
|
4588
|
+
for (const e of entries) {
|
|
4589
|
+
if (re.test(e)) {
|
|
4590
|
+
const full = `${dir}${SEP}${e}`;
|
|
4591
|
+
results.add(abs ? resolve(full) : full);
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
} else {
|
|
4595
|
+
const seg = before.replace(/[*?[\]]/g, "").replace(/\/$/, "");
|
|
4596
|
+
if (entries.includes(seg)) {
|
|
4597
|
+
const full = `${dir}${SEP}${seg}`;
|
|
4598
|
+
try {
|
|
4599
|
+
const stat10 = await fsp3.stat(full);
|
|
4600
|
+
if (stat10.isDirectory()) await walk4(full, rest);
|
|
4601
|
+
} catch {
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
await walk4(base === "." ? "." : base, relPat);
|
|
4607
|
+
return [...results];
|
|
4608
|
+
}
|
|
4444
4609
|
|
|
4445
4610
|
// src/utils/json-repair.ts
|
|
4446
4611
|
function completePartialObject(s) {
|
|
@@ -4557,7 +4722,7 @@ var DefaultSessionStore = class {
|
|
|
4557
4722
|
const file = path6.join(shardDir, `${id}.jsonl`);
|
|
4558
4723
|
let handle;
|
|
4559
4724
|
try {
|
|
4560
|
-
handle = await
|
|
4725
|
+
handle = await fsp3.open(file, "a", 384);
|
|
4561
4726
|
} catch (err) {
|
|
4562
4727
|
throw new Error(
|
|
4563
4728
|
`Failed to open session file: ${err instanceof Error ? err.message : String(err)}`,
|
|
@@ -4581,7 +4746,7 @@ var DefaultSessionStore = class {
|
|
|
4581
4746
|
const data = await this.load(id);
|
|
4582
4747
|
let handle;
|
|
4583
4748
|
try {
|
|
4584
|
-
handle = await
|
|
4749
|
+
handle = await fsp3.open(file, "a", 384);
|
|
4585
4750
|
} catch (err) {
|
|
4586
4751
|
throw new Error(
|
|
4587
4752
|
`Failed to open session "${id}" for append: ${err instanceof Error ? err.message : String(err)}`,
|
|
@@ -4610,7 +4775,7 @@ var DefaultSessionStore = class {
|
|
|
4610
4775
|
}
|
|
4611
4776
|
async load(id) {
|
|
4612
4777
|
const file = this.sessionPath(id, ".jsonl");
|
|
4613
|
-
const raw = await
|
|
4778
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
4614
4779
|
const lines = raw.split("\n").filter((l) => l.trim());
|
|
4615
4780
|
const events = [];
|
|
4616
4781
|
for (const line of lines) {
|
|
@@ -4645,7 +4810,7 @@ var DefaultSessionStore = class {
|
|
|
4645
4810
|
/** Recursively collect all session IDs from shard subdirectories. */
|
|
4646
4811
|
async collectSessionIds(dir) {
|
|
4647
4812
|
const ids = [];
|
|
4648
|
-
const entries = await
|
|
4813
|
+
const entries = await fsp3.readdir(dir, { withFileTypes: true });
|
|
4649
4814
|
for (const entry of entries) {
|
|
4650
4815
|
const full = path6.join(dir, entry.name);
|
|
4651
4816
|
if (entry.isDirectory()) {
|
|
@@ -4659,12 +4824,12 @@ var DefaultSessionStore = class {
|
|
|
4659
4824
|
async summaryFor(id) {
|
|
4660
4825
|
const manifest = this.sessionPath(id, ".summary.json");
|
|
4661
4826
|
try {
|
|
4662
|
-
const raw = await
|
|
4827
|
+
const raw = await fsp3.readFile(manifest, "utf8");
|
|
4663
4828
|
return JSON.parse(raw);
|
|
4664
4829
|
} catch {
|
|
4665
4830
|
const full = this.sessionPath(id, ".jsonl");
|
|
4666
|
-
const
|
|
4667
|
-
const summary = await this.summarize(id,
|
|
4831
|
+
const stat10 = await fsp3.stat(full);
|
|
4832
|
+
const summary = await this.summarize(id, stat10.mtime.toISOString());
|
|
4668
4833
|
await atomicWrite(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
|
|
4669
4834
|
console.warn(
|
|
4670
4835
|
`[session-store] Failed to write manifest for "${id}":`,
|
|
@@ -4675,8 +4840,8 @@ var DefaultSessionStore = class {
|
|
|
4675
4840
|
}
|
|
4676
4841
|
}
|
|
4677
4842
|
async delete(id) {
|
|
4678
|
-
await
|
|
4679
|
-
await
|
|
4843
|
+
await fsp3.unlink(this.sessionPath(id, ".jsonl"));
|
|
4844
|
+
await fsp3.unlink(this.sessionPath(id, ".summary.json")).catch(() => void 0);
|
|
4680
4845
|
}
|
|
4681
4846
|
async clearHistory(id) {
|
|
4682
4847
|
await this.ensureShardDir(id);
|
|
@@ -4690,8 +4855,8 @@ var DefaultSessionStore = class {
|
|
|
4690
4855
|
provider: "unknown"
|
|
4691
4856
|
})}
|
|
4692
4857
|
`;
|
|
4693
|
-
await
|
|
4694
|
-
await
|
|
4858
|
+
await fsp3.writeFile(file, record, "utf8");
|
|
4859
|
+
await fsp3.unlink(meta).catch(() => void 0);
|
|
4695
4860
|
}
|
|
4696
4861
|
async summarize(id, mtime) {
|
|
4697
4862
|
try {
|
|
@@ -4877,7 +5042,7 @@ var FileSessionWriter = class {
|
|
|
4877
5042
|
`;
|
|
4878
5043
|
try {
|
|
4879
5044
|
if (this.filePath) {
|
|
4880
|
-
await
|
|
5045
|
+
await fsp3.writeFile(this.filePath, record, { flag: "a", mode: 384 });
|
|
4881
5046
|
}
|
|
4882
5047
|
} catch {
|
|
4883
5048
|
}
|
|
@@ -4970,7 +5135,7 @@ var FileSessionWriter = class {
|
|
|
4970
5135
|
}
|
|
4971
5136
|
async truncateToCheckpoint(targetPromptIndex) {
|
|
4972
5137
|
if (!this.filePath) return 0;
|
|
4973
|
-
const raw = await
|
|
5138
|
+
const raw = await fsp3.readFile(this.filePath, "utf8");
|
|
4974
5139
|
const lines = raw.split("\n");
|
|
4975
5140
|
const kept = [];
|
|
4976
5141
|
let removedCount = 0;
|
|
@@ -5008,13 +5173,13 @@ var FileSessionWriter = class {
|
|
|
5008
5173
|
}
|
|
5009
5174
|
const truncated = kept.join("\n");
|
|
5010
5175
|
const tmpPath = `${this.filePath}.rewind.tmp`;
|
|
5011
|
-
await
|
|
5176
|
+
await fsp3.writeFile(tmpPath, truncated + "\n", "utf8");
|
|
5012
5177
|
try {
|
|
5013
5178
|
await this.handle.close();
|
|
5014
|
-
await
|
|
5015
|
-
this.handle = await
|
|
5179
|
+
await fsp3.rename(tmpPath, this.filePath);
|
|
5180
|
+
this.handle = await fsp3.open(this.filePath, "a", 384);
|
|
5016
5181
|
} catch (err) {
|
|
5017
|
-
await
|
|
5182
|
+
await fsp3.unlink(tmpPath).catch(() => void 0);
|
|
5018
5183
|
throw err;
|
|
5019
5184
|
}
|
|
5020
5185
|
await this.append({
|
|
@@ -5040,7 +5205,7 @@ var FileSessionWriter = class {
|
|
|
5040
5205
|
provider: this.meta.provider ?? "unknown"
|
|
5041
5206
|
})}
|
|
5042
5207
|
`;
|
|
5043
|
-
await
|
|
5208
|
+
await fsp3.writeFile(this.filePath, record, "utf8");
|
|
5044
5209
|
}
|
|
5045
5210
|
/**
|
|
5046
5211
|
* Idea #1 — write an in-flight marker. The agent loop should call
|
|
@@ -5097,7 +5262,7 @@ var QueueStore = class {
|
|
|
5097
5262
|
async read() {
|
|
5098
5263
|
let raw;
|
|
5099
5264
|
try {
|
|
5100
|
-
raw = await
|
|
5265
|
+
raw = await fsp3.readFile(this.file, "utf8");
|
|
5101
5266
|
} catch (err) {
|
|
5102
5267
|
const code = err.code;
|
|
5103
5268
|
if (code === "ENOENT") return [];
|
|
@@ -5119,7 +5284,7 @@ var QueueStore = class {
|
|
|
5119
5284
|
}
|
|
5120
5285
|
async clear() {
|
|
5121
5286
|
try {
|
|
5122
|
-
await
|
|
5287
|
+
await fsp3.unlink(this.file);
|
|
5123
5288
|
} catch (err) {
|
|
5124
5289
|
const code = err.code;
|
|
5125
5290
|
if (code === "ENOENT") return;
|
|
@@ -5154,7 +5319,7 @@ var DefaultAttachmentStore = class {
|
|
|
5154
5319
|
let spooledPath;
|
|
5155
5320
|
let data = input.data;
|
|
5156
5321
|
if (this.spoolDir && bytes >= this.spoolThreshold) {
|
|
5157
|
-
await
|
|
5322
|
+
await fsp3.mkdir(this.spoolDir, { recursive: true });
|
|
5158
5323
|
spooledPath = path6.join(this.spoolDir, `${id}.bin`);
|
|
5159
5324
|
await atomicWrite(spooledPath, input.data, {
|
|
5160
5325
|
encoding: input.kind === "image" ? "base64" : "utf8"
|
|
@@ -5217,7 +5382,7 @@ var DefaultAttachmentStore = class {
|
|
|
5217
5382
|
for (const att of this.items.values()) {
|
|
5218
5383
|
if (att.path) toDelete.push(att.path);
|
|
5219
5384
|
}
|
|
5220
|
-
await Promise.all(toDelete.map((p) =>
|
|
5385
|
+
await Promise.all(toDelete.map((p) => fsp3.unlink(p).catch(() => void 0)));
|
|
5221
5386
|
}
|
|
5222
5387
|
this.items.clear();
|
|
5223
5388
|
this.refs.length = 0;
|
|
@@ -5225,7 +5390,7 @@ var DefaultAttachmentStore = class {
|
|
|
5225
5390
|
}
|
|
5226
5391
|
async toBlock(att) {
|
|
5227
5392
|
if (att.kind === "image") {
|
|
5228
|
-
const data = att.data ?? (att.path ? await
|
|
5393
|
+
const data = att.data ?? (att.path ? await fsp3.readFile(att.path, { encoding: "base64" }) : "");
|
|
5229
5394
|
return {
|
|
5230
5395
|
type: "image",
|
|
5231
5396
|
source: {
|
|
@@ -5235,7 +5400,7 @@ var DefaultAttachmentStore = class {
|
|
|
5235
5400
|
}
|
|
5236
5401
|
};
|
|
5237
5402
|
}
|
|
5238
|
-
const raw = att.data ?? (att.path ? await
|
|
5403
|
+
const raw = att.data ?? (att.path ? await fsp3.readFile(att.path, "utf8") : "");
|
|
5239
5404
|
const label = att.meta.filename ? `<file path="${att.meta.filename}">` : "<pasted>";
|
|
5240
5405
|
const close = att.meta.filename ? "</file>" : "</pasted>";
|
|
5241
5406
|
return { type: "text", text: `${label}
|
|
@@ -5335,7 +5500,7 @@ ${body.trim()}`);
|
|
|
5335
5500
|
}
|
|
5336
5501
|
async read(scope) {
|
|
5337
5502
|
try {
|
|
5338
|
-
return await
|
|
5503
|
+
return await fsp3.readFile(this.files[scope], "utf8");
|
|
5339
5504
|
} catch {
|
|
5340
5505
|
return "";
|
|
5341
5506
|
}
|
|
@@ -5346,7 +5511,7 @@ ${body.trim()}`);
|
|
|
5346
5511
|
await ensureDir(path6.dirname(file));
|
|
5347
5512
|
let existing = "";
|
|
5348
5513
|
try {
|
|
5349
|
-
existing = await
|
|
5514
|
+
existing = await fsp3.readFile(file, "utf8");
|
|
5350
5515
|
} catch {
|
|
5351
5516
|
}
|
|
5352
5517
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5370,7 +5535,7 @@ ${entry}`;
|
|
|
5370
5535
|
const file = this.files[scope];
|
|
5371
5536
|
let existing;
|
|
5372
5537
|
try {
|
|
5373
|
-
existing = await
|
|
5538
|
+
existing = await fsp3.readFile(file, "utf8");
|
|
5374
5539
|
} catch {
|
|
5375
5540
|
return 0;
|
|
5376
5541
|
}
|
|
@@ -5409,7 +5574,7 @@ ${entry}`;
|
|
|
5409
5574
|
const file = this.files[scope];
|
|
5410
5575
|
let existing;
|
|
5411
5576
|
try {
|
|
5412
|
-
existing = await
|
|
5577
|
+
existing = await fsp3.readFile(file, "utf8");
|
|
5413
5578
|
} catch {
|
|
5414
5579
|
return;
|
|
5415
5580
|
}
|
|
@@ -5425,7 +5590,7 @@ ${entry}`;
|
|
|
5425
5590
|
const next = lines.join("\n");
|
|
5426
5591
|
const backup = `${file}.bak.${Date.now()}`;
|
|
5427
5592
|
try {
|
|
5428
|
-
await
|
|
5593
|
+
await fsp3.copyFile(file, backup);
|
|
5429
5594
|
} catch {
|
|
5430
5595
|
}
|
|
5431
5596
|
try {
|
|
@@ -5742,7 +5907,7 @@ var DefaultConfigLoader = class {
|
|
|
5742
5907
|
*/
|
|
5743
5908
|
async loadSyncConfig() {
|
|
5744
5909
|
try {
|
|
5745
|
-
const raw = await
|
|
5910
|
+
const raw = await fsp3.readFile(this.paths.syncConfig, "utf8");
|
|
5746
5911
|
const parsed = safeParse(raw);
|
|
5747
5912
|
if (!parsed.ok || !parsed.value) return null;
|
|
5748
5913
|
if (this.vault) {
|
|
@@ -5759,7 +5924,7 @@ var DefaultConfigLoader = class {
|
|
|
5759
5924
|
async readJson(file) {
|
|
5760
5925
|
let raw;
|
|
5761
5926
|
try {
|
|
5762
|
-
raw = await
|
|
5927
|
+
raw = await fsp3.readFile(file, "utf8");
|
|
5763
5928
|
} catch (err) {
|
|
5764
5929
|
if (err.code !== "ENOENT") {
|
|
5765
5930
|
console.warn(`[config] Failed to read "${file}":`, err);
|
|
@@ -5941,7 +6106,7 @@ var RecoveryLock = class {
|
|
|
5941
6106
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5942
6107
|
};
|
|
5943
6108
|
try {
|
|
5944
|
-
await
|
|
6109
|
+
await fsp3.writeFile(this.file, JSON.stringify(lock), { flag: "wx", mode: 384 });
|
|
5945
6110
|
} catch (err) {
|
|
5946
6111
|
const code = err.code;
|
|
5947
6112
|
if (code === "EEXIST") {
|
|
@@ -5957,7 +6122,7 @@ var RecoveryLock = class {
|
|
|
5957
6122
|
*/
|
|
5958
6123
|
async clear() {
|
|
5959
6124
|
try {
|
|
5960
|
-
await
|
|
6125
|
+
await fsp3.unlink(this.file);
|
|
5961
6126
|
} catch (err) {
|
|
5962
6127
|
const code = err.code;
|
|
5963
6128
|
if (code === "ENOENT") return;
|
|
@@ -5967,7 +6132,7 @@ var RecoveryLock = class {
|
|
|
5967
6132
|
async readLock() {
|
|
5968
6133
|
let raw;
|
|
5969
6134
|
try {
|
|
5970
|
-
raw = await
|
|
6135
|
+
raw = await fsp3.readFile(this.file, "utf8");
|
|
5971
6136
|
} catch (err) {
|
|
5972
6137
|
const code = err.code;
|
|
5973
6138
|
if (code === "ENOENT") return null;
|
|
@@ -6196,7 +6361,7 @@ init_atomic_write();
|
|
|
6196
6361
|
async function loadTodosCheckpoint(filePath) {
|
|
6197
6362
|
let raw;
|
|
6198
6363
|
try {
|
|
6199
|
-
raw = await
|
|
6364
|
+
raw = await fsp3.readFile(filePath, "utf8");
|
|
6200
6365
|
} catch {
|
|
6201
6366
|
return null;
|
|
6202
6367
|
}
|
|
@@ -6267,7 +6432,7 @@ init_atomic_write();
|
|
|
6267
6432
|
async function loadPlan(filePath) {
|
|
6268
6433
|
let raw;
|
|
6269
6434
|
try {
|
|
6270
|
-
raw = await
|
|
6435
|
+
raw = await fsp3.readFile(filePath, "utf8");
|
|
6271
6436
|
} catch {
|
|
6272
6437
|
return null;
|
|
6273
6438
|
}
|
|
@@ -6504,7 +6669,7 @@ init_atomic_write();
|
|
|
6504
6669
|
async function loadDirectorState(filePath) {
|
|
6505
6670
|
let raw;
|
|
6506
6671
|
try {
|
|
6507
|
-
raw = await
|
|
6672
|
+
raw = await fsp3.readFile(filePath, "utf8");
|
|
6508
6673
|
} catch {
|
|
6509
6674
|
return null;
|
|
6510
6675
|
}
|
|
@@ -6519,7 +6684,7 @@ async function loadDirectorState(filePath) {
|
|
|
6519
6684
|
async function acquireDirectorStateLock(lockPath, processId = process.pid) {
|
|
6520
6685
|
let existing;
|
|
6521
6686
|
try {
|
|
6522
|
-
existing = await
|
|
6687
|
+
existing = await fsp3.readFile(lockPath, "utf8");
|
|
6523
6688
|
} catch {
|
|
6524
6689
|
}
|
|
6525
6690
|
if (existing) {
|
|
@@ -6543,7 +6708,7 @@ async function acquireDirectorStateLock(lockPath, processId = process.pid) {
|
|
|
6543
6708
|
}
|
|
6544
6709
|
async function releaseDirectorStateLock(lockPath) {
|
|
6545
6710
|
try {
|
|
6546
|
-
await
|
|
6711
|
+
await fsp3.unlink(lockPath);
|
|
6547
6712
|
} catch {
|
|
6548
6713
|
}
|
|
6549
6714
|
}
|
|
@@ -6748,7 +6913,7 @@ var DefaultPermissionPolicy = class {
|
|
|
6748
6913
|
}
|
|
6749
6914
|
async reload() {
|
|
6750
6915
|
try {
|
|
6751
|
-
const raw = await
|
|
6916
|
+
const raw = await fsp3.readFile(this.trustFile, "utf8");
|
|
6752
6917
|
const parsed = safeParse(raw);
|
|
6753
6918
|
if (parsed.ok && parsed.value) this.policy = parsed.value;
|
|
6754
6919
|
} catch {
|
|
@@ -6987,12 +7152,12 @@ var DefaultSkillLoader = class {
|
|
|
6987
7152
|
const seen = /* @__PURE__ */ new Set();
|
|
6988
7153
|
for (const { dir, source } of this.dirs) {
|
|
6989
7154
|
try {
|
|
6990
|
-
const entries = await
|
|
7155
|
+
const entries = await fsp3.readdir(dir, { withFileTypes: true });
|
|
6991
7156
|
for (const e of entries) {
|
|
6992
7157
|
if (!e.isDirectory()) continue;
|
|
6993
7158
|
const skillFile = path6.join(dir, e.name, "SKILL.md");
|
|
6994
7159
|
try {
|
|
6995
|
-
const raw = await
|
|
7160
|
+
const raw = await fsp3.readFile(skillFile, "utf8");
|
|
6996
7161
|
const meta = parseFrontmatter(raw);
|
|
6997
7162
|
if (!meta.name || !meta.description) continue;
|
|
6998
7163
|
if (seen.has(meta.name)) continue;
|
|
@@ -7034,7 +7199,7 @@ var DefaultSkillLoader = class {
|
|
|
7034
7199
|
const entries = [];
|
|
7035
7200
|
for (const s of skills) {
|
|
7036
7201
|
try {
|
|
7037
|
-
const raw = await
|
|
7202
|
+
const raw = await fsp3.readFile(s.path, "utf8");
|
|
7038
7203
|
const { trigger, scope } = parseDescription(raw);
|
|
7039
7204
|
entries.push({ name: s.name, trigger, scope, source: s.source, path: s.path });
|
|
7040
7205
|
} catch {
|
|
@@ -7048,7 +7213,7 @@ var DefaultSkillLoader = class {
|
|
|
7048
7213
|
async readBody(name) {
|
|
7049
7214
|
const m = await this.find(name);
|
|
7050
7215
|
if (!m) throw new Error(`Skill "${name}" not found`);
|
|
7051
|
-
return
|
|
7216
|
+
return fsp3.readFile(m.path, "utf8");
|
|
7052
7217
|
}
|
|
7053
7218
|
};
|
|
7054
7219
|
function parseFrontmatter(raw) {
|
|
@@ -7313,8 +7478,8 @@ async function streamProviderToResponse(provider, req, signal, ctx, events) {
|
|
|
7313
7478
|
try {
|
|
7314
7479
|
await Promise.race([
|
|
7315
7480
|
Promise.resolve(iter.return?.()),
|
|
7316
|
-
new Promise((
|
|
7317
|
-
drainTimer = setTimeout(
|
|
7481
|
+
new Promise((resolve10) => {
|
|
7482
|
+
drainTimer = setTimeout(resolve10, 500);
|
|
7318
7483
|
})
|
|
7319
7484
|
]);
|
|
7320
7485
|
} finally {
|
|
@@ -7375,7 +7540,7 @@ async function runProviderWithRetry(opts) {
|
|
|
7375
7540
|
description
|
|
7376
7541
|
});
|
|
7377
7542
|
}
|
|
7378
|
-
await new Promise((
|
|
7543
|
+
await new Promise((resolve10, reject) => {
|
|
7379
7544
|
let settled = false;
|
|
7380
7545
|
const onAbort = () => {
|
|
7381
7546
|
if (settled) return;
|
|
@@ -7388,7 +7553,7 @@ async function runProviderWithRetry(opts) {
|
|
|
7388
7553
|
settled = true;
|
|
7389
7554
|
clearTimeout(t2);
|
|
7390
7555
|
signal.removeEventListener("abort", onAbort);
|
|
7391
|
-
|
|
7556
|
+
resolve10();
|
|
7392
7557
|
}, delay);
|
|
7393
7558
|
if (signal.aborted) {
|
|
7394
7559
|
onAbort();
|
|
@@ -8131,7 +8296,7 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
8131
8296
|
}
|
|
8132
8297
|
handler() {
|
|
8133
8298
|
return async (ctx, next) => {
|
|
8134
|
-
const tokens = this._estimator ? this._estimator(ctx) :
|
|
8299
|
+
const tokens = this._estimator ? this._estimator(ctx) : estimateRequestTokensCalibrated(ctx.messages, ctx.systemPrompt, ctx.tools ?? []).total;
|
|
8135
8300
|
const load = tokens / this._maxContext;
|
|
8136
8301
|
const policy = this.policyProvider?.(ctx);
|
|
8137
8302
|
const thresholds = policy?.thresholds ?? {
|
|
@@ -8400,7 +8565,7 @@ function goalFilePath(projectRoot) {
|
|
|
8400
8565
|
async function loadGoal(filePath) {
|
|
8401
8566
|
let raw;
|
|
8402
8567
|
try {
|
|
8403
|
-
raw = await
|
|
8568
|
+
raw = await fsp3.readFile(filePath, "utf8");
|
|
8404
8569
|
} catch {
|
|
8405
8570
|
return null;
|
|
8406
8571
|
}
|
|
@@ -9067,7 +9232,7 @@ ${recentJournal}` : "No prior iterations.",
|
|
|
9067
9232
|
}
|
|
9068
9233
|
};
|
|
9069
9234
|
function sleep(ms) {
|
|
9070
|
-
return new Promise((
|
|
9235
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
9071
9236
|
}
|
|
9072
9237
|
|
|
9073
9238
|
// src/coordination/subagent-budget.ts
|
|
@@ -9283,12 +9448,12 @@ var SubagentBudget = class _SubagentBudget {
|
|
|
9283
9448
|
if (!bus || !bus.hasListenerFor("budget.threshold_reached")) {
|
|
9284
9449
|
return Promise.resolve("stop");
|
|
9285
9450
|
}
|
|
9286
|
-
return new Promise((
|
|
9451
|
+
return new Promise((resolve10) => {
|
|
9287
9452
|
let resolved = false;
|
|
9288
9453
|
const respond = (d) => {
|
|
9289
9454
|
if (resolved) return;
|
|
9290
9455
|
resolved = true;
|
|
9291
|
-
|
|
9456
|
+
resolve10(d);
|
|
9292
9457
|
};
|
|
9293
9458
|
const fallback = setTimeout(
|
|
9294
9459
|
() => respond("stop"),
|
|
@@ -12225,6 +12390,10 @@ var NICKNAME_POOL = {
|
|
|
12225
12390
|
"pasteur": { name: "Pasteur", domain: "biology" },
|
|
12226
12391
|
"hawking": { name: "Hawking", domain: "cosmology" },
|
|
12227
12392
|
"sagan": { name: "Sagan", domain: "cosmology" },
|
|
12393
|
+
// Exploration & navigation
|
|
12394
|
+
"columbus": { name: "Columbus", domain: "exploration" },
|
|
12395
|
+
"polo": { name: "Polo", domain: "exploration" },
|
|
12396
|
+
"magellan": { name: "Magellan", domain: "exploration" },
|
|
12228
12397
|
// Chemistry / materials
|
|
12229
12398
|
"lavoisier": { name: "Lavoisier", domain: "chemistry" },
|
|
12230
12399
|
"mendeleev": { name: "Mendeleev", domain: "chemistry" }
|
|
@@ -12279,7 +12448,7 @@ function formatRole(role) {
|
|
|
12279
12448
|
}
|
|
12280
12449
|
|
|
12281
12450
|
// src/coordination/multi-agent-coordinator.ts
|
|
12282
|
-
var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
12451
|
+
var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends EventEmitter {
|
|
12283
12452
|
coordinatorId;
|
|
12284
12453
|
config;
|
|
12285
12454
|
runner;
|
|
@@ -12294,8 +12463,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12294
12463
|
* names) to memorable ones here — that's what surfaces in the fleet monitor.
|
|
12295
12464
|
*/
|
|
12296
12465
|
usedNicknames = /* @__PURE__ */ new Set();
|
|
12466
|
+
/** Maps subagentId → nickname key (e.g. 'einstein'). Used to free the slot on remove(). */
|
|
12467
|
+
subagentNicknames = /* @__PURE__ */ new Map();
|
|
12297
12468
|
pendingTasks = [];
|
|
12298
12469
|
completedResults = [];
|
|
12470
|
+
/** Prevents completedResults from growing unbounded in long-running coordinators. */
|
|
12471
|
+
static MAX_COMPLETED_RESULTS = 1e4;
|
|
12299
12472
|
totalIterations = 0;
|
|
12300
12473
|
inFlight = 0;
|
|
12301
12474
|
/**
|
|
@@ -12350,7 +12523,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12350
12523
|
* Explicit, human-chosen names — including nicknames already assigned by
|
|
12351
12524
|
* `Director.spawn()` — are left untouched, so this never double-assigns.
|
|
12352
12525
|
*/
|
|
12353
|
-
withNickname(subagent) {
|
|
12526
|
+
withNickname(subagent, subagentId) {
|
|
12354
12527
|
const role = subagent.role ?? "subagent";
|
|
12355
12528
|
const name = subagent.name?.trim() ?? "";
|
|
12356
12529
|
const isPlaceholder = name === "" || name.toLowerCase() === role.toLowerCase() || name === "subagent" || name === "adhoc" || name === "generic" || /^slot-/.test(name);
|
|
@@ -12358,11 +12531,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12358
12531
|
const nickname = assignNickname(role, this.usedNicknames);
|
|
12359
12532
|
const baseKey = nickname.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
12360
12533
|
this.usedNicknames.add(baseKey);
|
|
12534
|
+
this.subagentNicknames.set(subagentId, baseKey);
|
|
12361
12535
|
return { ...subagent, name: nickname };
|
|
12362
12536
|
}
|
|
12363
12537
|
async spawn(subagent) {
|
|
12364
|
-
subagent = this.withNickname(subagent);
|
|
12365
12538
|
const id = subagent.id || randomUUID();
|
|
12539
|
+
subagent = this.withNickname(subagent, id);
|
|
12366
12540
|
if (this.subagents.has(id)) {
|
|
12367
12541
|
throw new Error(`Subagent id "${id}" already exists \u2014 refusing to overwrite`);
|
|
12368
12542
|
}
|
|
@@ -12506,7 +12680,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12506
12680
|
taskIds.map((id) => {
|
|
12507
12681
|
const cached = this.completedResults.find((r) => r.taskId === id);
|
|
12508
12682
|
if (cached) return cached;
|
|
12509
|
-
return new Promise((
|
|
12683
|
+
return new Promise((resolve10, reject) => {
|
|
12510
12684
|
const timeout = setTimeout(() => {
|
|
12511
12685
|
this.off("task.completed", handler);
|
|
12512
12686
|
reject(new Error(`awaitTasks timed out waiting for task "${id}"`));
|
|
@@ -12515,7 +12689,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12515
12689
|
if (result.taskId === id) {
|
|
12516
12690
|
clearTimeout(timeout);
|
|
12517
12691
|
this.off("task.completed", handler);
|
|
12518
|
-
|
|
12692
|
+
resolve10(result);
|
|
12519
12693
|
}
|
|
12520
12694
|
};
|
|
12521
12695
|
this.on("task.completed", handler);
|
|
@@ -12804,6 +12978,12 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12804
12978
|
}
|
|
12805
12979
|
recordCompletion(result) {
|
|
12806
12980
|
this.completedResults.push(result);
|
|
12981
|
+
if (this.completedResults.length > _DefaultMultiAgentCoordinator.MAX_COMPLETED_RESULTS) {
|
|
12982
|
+
this.completedResults.splice(
|
|
12983
|
+
0,
|
|
12984
|
+
this.completedResults.length - _DefaultMultiAgentCoordinator.MAX_COMPLETED_RESULTS
|
|
12985
|
+
);
|
|
12986
|
+
}
|
|
12807
12987
|
this.totalIterations += result.iterations;
|
|
12808
12988
|
if (this.inFlight > 0) {
|
|
12809
12989
|
this.inFlight--;
|
|
@@ -12873,7 +13053,29 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
|
|
|
12873
13053
|
}
|
|
12874
13054
|
this.subagents.delete(subagentId);
|
|
12875
13055
|
this.terminating.delete(subagentId);
|
|
13056
|
+
const nicknameKey = this.subagentNicknames.get(subagentId);
|
|
13057
|
+
if (nicknameKey) {
|
|
13058
|
+
this.usedNicknames.delete(nicknameKey);
|
|
13059
|
+
this.subagentNicknames.delete(subagentId);
|
|
13060
|
+
}
|
|
13061
|
+
const orphaned = this.pendingTasks.filter((t2) => t2.subagentId === subagentId);
|
|
12876
13062
|
this.pendingTasks = this.pendingTasks.filter((t2) => t2.subagentId !== subagentId);
|
|
13063
|
+
for (const t2 of orphaned) {
|
|
13064
|
+
const synthetic = {
|
|
13065
|
+
subagentId,
|
|
13066
|
+
taskId: t2.id,
|
|
13067
|
+
status: "stopped",
|
|
13068
|
+
error: {
|
|
13069
|
+
kind: "aborted_by_parent",
|
|
13070
|
+
message: `Subagent "${subagentId}" was removed while task "${t2.id}" was pending`,
|
|
13071
|
+
retryable: false
|
|
13072
|
+
},
|
|
13073
|
+
iterations: 0,
|
|
13074
|
+
toolCalls: 0,
|
|
13075
|
+
durationMs: 0
|
|
13076
|
+
};
|
|
13077
|
+
this.recordCompletion(synthetic);
|
|
13078
|
+
}
|
|
12877
13079
|
this.fleetBus?.emit({
|
|
12878
13080
|
subagentId,
|
|
12879
13081
|
ts: Date.now(),
|
|
@@ -12990,7 +13192,7 @@ function providerErrorToSubagentError(err, message, cause) {
|
|
|
12990
13192
|
|
|
12991
13193
|
// src/execution/parallel-eternal-engine.ts
|
|
12992
13194
|
function sleep2(ms) {
|
|
12993
|
-
return new Promise((
|
|
13195
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
12994
13196
|
}
|
|
12995
13197
|
var GOAL_COMPLETE_MARKER2 = /^\s*\[goal[_\s-]?complete\]\s*$/im;
|
|
12996
13198
|
var ParallelEternalEngine = class {
|
|
@@ -13488,6 +13690,80 @@ function buildGoalPreamble(goal) {
|
|
|
13488
13690
|
// src/coordination/director.ts
|
|
13489
13691
|
init_atomic_write();
|
|
13490
13692
|
|
|
13693
|
+
// src/coordination/large-answer-store.ts
|
|
13694
|
+
var LargeAnswerStore = class {
|
|
13695
|
+
/**
|
|
13696
|
+
* Responses above this size (in characters) are stored out-of-context.
|
|
13697
|
+
* Below this, the full answer is returned inline (no overhead).
|
|
13698
|
+
* Default: 2000 chars ≈ 400-600 tokens.
|
|
13699
|
+
*/
|
|
13700
|
+
sizeThreshold;
|
|
13701
|
+
store = /* @__PURE__ */ new Map();
|
|
13702
|
+
constructor(sizeThreshold = 2e3) {
|
|
13703
|
+
this.sizeThreshold = sizeThreshold;
|
|
13704
|
+
}
|
|
13705
|
+
/**
|
|
13706
|
+
* Store a value, returning a summary + key for inline use.
|
|
13707
|
+
* If the value is below sizeThreshold, returns it as-is (no store entry).
|
|
13708
|
+
*/
|
|
13709
|
+
storeAnswer(value) {
|
|
13710
|
+
if (value === void 0 || value === null) {
|
|
13711
|
+
return { summary: String(value), inline: true };
|
|
13712
|
+
}
|
|
13713
|
+
const serialized = typeof value === "string" ? value : JSON.stringify(value);
|
|
13714
|
+
const size = serialized.length;
|
|
13715
|
+
if (size <= this.sizeThreshold) {
|
|
13716
|
+
return { summary: serialized.slice(0, 500), inline: true };
|
|
13717
|
+
}
|
|
13718
|
+
const key = `a-${hashStr(serialized)}`;
|
|
13719
|
+
this.store.set(key, {
|
|
13720
|
+
key,
|
|
13721
|
+
value,
|
|
13722
|
+
size,
|
|
13723
|
+
storedAt: Date.now()
|
|
13724
|
+
});
|
|
13725
|
+
return {
|
|
13726
|
+
key,
|
|
13727
|
+
summary: `[stored: ${size} chars \u2014 use roll_up or ask_result tool to retrieve, key=${key}]`,
|
|
13728
|
+
inline: false
|
|
13729
|
+
};
|
|
13730
|
+
}
|
|
13731
|
+
/**
|
|
13732
|
+
* Retrieve a previously stored answer by its key.
|
|
13733
|
+
* Returns undefined if the key is unknown or the store was cleared.
|
|
13734
|
+
*/
|
|
13735
|
+
retrieveAnswer(key) {
|
|
13736
|
+
return this.store.get(key)?.value;
|
|
13737
|
+
}
|
|
13738
|
+
/**
|
|
13739
|
+
* Check if a key exists in the store.
|
|
13740
|
+
*/
|
|
13741
|
+
hasAnswer(key) {
|
|
13742
|
+
return this.store.has(key);
|
|
13743
|
+
}
|
|
13744
|
+
/** Number of stored entries. */
|
|
13745
|
+
get size() {
|
|
13746
|
+
return this.store.size;
|
|
13747
|
+
}
|
|
13748
|
+
/** Total characters stored. */
|
|
13749
|
+
get totalChars() {
|
|
13750
|
+
let total = 0;
|
|
13751
|
+
for (const e of this.store.values()) total += e.size;
|
|
13752
|
+
return total;
|
|
13753
|
+
}
|
|
13754
|
+
/** Clear all stored entries. Call at the end of a director run. */
|
|
13755
|
+
clear() {
|
|
13756
|
+
this.store.clear();
|
|
13757
|
+
}
|
|
13758
|
+
};
|
|
13759
|
+
function hashStr(s) {
|
|
13760
|
+
let h = 5381;
|
|
13761
|
+
for (let i = 0; i < s.length; i++) {
|
|
13762
|
+
h = h * 33 ^ s.charCodeAt(i);
|
|
13763
|
+
}
|
|
13764
|
+
return (h >>> 0).toString(36);
|
|
13765
|
+
}
|
|
13766
|
+
|
|
13491
13767
|
// src/coordination/director-prompts.ts
|
|
13492
13768
|
var DEFAULT_DIRECTOR_PREAMBLE = `You are the Director of a multi-agent fleet. You orchestrate worker
|
|
13493
13769
|
subagents by spawning them, assigning tasks, awaiting completions, and
|
|
@@ -13771,9 +14047,12 @@ function makeSpawnTool(director, roster) {
|
|
|
13771
14047
|
provider: { type: "string", description: 'Provider id (e.g. "anthropic", "openai"). Defaults to the leader provider when omitted.' },
|
|
13772
14048
|
model: { type: "string", description: "Model id within the provider. Defaults to the leader model when omitted." },
|
|
13773
14049
|
systemPromptOverride: { type: "string", description: "Extra prompt text appended after the role-base prompt." },
|
|
13774
|
-
maxIterations: { type: "number" },
|
|
13775
|
-
maxToolCalls: { type: "number" },
|
|
13776
|
-
maxCostUsd: { type: "number" }
|
|
14050
|
+
maxIterations: { type: "number", minimum: 1 },
|
|
14051
|
+
maxToolCalls: { type: "number", minimum: 1 },
|
|
14052
|
+
maxCostUsd: { type: "number", minimum: 0 },
|
|
14053
|
+
timeoutMs: { type: "number", minimum: 1, description: "Hard wall-clock cap in milliseconds. Defaults to none (idle timeout is the default reaper)." },
|
|
14054
|
+
idleTimeoutMs: { type: "number", minimum: 1, description: "Idle timeout in ms: reap the subagent after this long with no activity. Resets on every iteration/tool call. Default is role/coordinator-specific." },
|
|
14055
|
+
maxTokens: { type: "number", minimum: 1, description: "Maximum total tokens (input + output) the subagent may use." }
|
|
13777
14056
|
},
|
|
13778
14057
|
required: []
|
|
13779
14058
|
};
|
|
@@ -13819,6 +14098,9 @@ function makeSpawnTool(director, roster) {
|
|
|
13819
14098
|
if (typeof i.maxIterations === "number") cfg.maxIterations = i.maxIterations;
|
|
13820
14099
|
if (typeof i.maxToolCalls === "number") cfg.maxToolCalls = i.maxToolCalls;
|
|
13821
14100
|
if (typeof i.maxCostUsd === "number") cfg.maxCostUsd = i.maxCostUsd;
|
|
14101
|
+
if (typeof i.timeoutMs === "number") cfg.timeoutMs = i.timeoutMs;
|
|
14102
|
+
if (typeof i.idleTimeoutMs === "number") cfg.idleTimeoutMs = i.idleTimeoutMs;
|
|
14103
|
+
if (typeof i.maxTokens === "number") cfg.maxTokens = i.maxTokens;
|
|
13822
14104
|
try {
|
|
13823
14105
|
const subagentId = await director.spawn(cfg);
|
|
13824
14106
|
return { subagentId, provider: cfg.provider, model: cfg.model, name: cfg.name, role: cfg.role };
|
|
@@ -13846,10 +14128,10 @@ function makeAssignTool(director) {
|
|
|
13846
14128
|
const inputSchema = {
|
|
13847
14129
|
type: "object",
|
|
13848
14130
|
properties: {
|
|
13849
|
-
subagentId: { type: "string", description: "Target subagent id. Required." },
|
|
13850
|
-
description: { type: "string", description: "The task in natural language \u2014 what you want this subagent to do." },
|
|
13851
|
-
maxToolCalls: { type: "number", description: "Optional per-task tool-call budget override." },
|
|
13852
|
-
timeoutMs: { type: "number", description: "Optional per-task timeout in ms." }
|
|
14131
|
+
subagentId: { type: "string", minLength: 1, description: "Target subagent id. Required." },
|
|
14132
|
+
description: { type: "string", minLength: 1, description: "The task in natural language \u2014 what you want this subagent to do." },
|
|
14133
|
+
maxToolCalls: { type: "number", minimum: 1, description: "Optional per-task tool-call budget override." },
|
|
14134
|
+
timeoutMs: { type: "number", minimum: 1, description: "Optional per-task timeout in ms." }
|
|
13853
14135
|
},
|
|
13854
14136
|
required: ["subagentId", "description"]
|
|
13855
14137
|
};
|
|
@@ -13890,9 +14172,9 @@ function makeAskTool(director) {
|
|
|
13890
14172
|
inputSchema: {
|
|
13891
14173
|
type: "object",
|
|
13892
14174
|
properties: {
|
|
13893
|
-
subagentId: { type: "string", description: "Subagent to ask. Must be a previously spawned id." },
|
|
13894
|
-
question: { type: "string", description: "The question or instruction." },
|
|
13895
|
-
timeoutMs: { type: "number", description: "Optional timeout in ms (default 30s)." }
|
|
14175
|
+
subagentId: { type: "string", minLength: 1, description: "Subagent to ask. Must be a previously spawned id." },
|
|
14176
|
+
question: { type: "string", minLength: 1, description: "The question or instruction." },
|
|
14177
|
+
timeoutMs: { type: "number", minimum: 1, description: "Optional timeout in ms (default 30s)." }
|
|
13896
14178
|
},
|
|
13897
14179
|
required: ["subagentId", "question"]
|
|
13898
14180
|
},
|
|
@@ -13900,13 +14182,49 @@ function makeAskTool(director) {
|
|
|
13900
14182
|
const i = input;
|
|
13901
14183
|
try {
|
|
13902
14184
|
const answer = await director.ask(i.subagentId, { question: i.question }, i.timeoutMs);
|
|
13903
|
-
|
|
14185
|
+
const stored = director.largeAnswerStore.storeAnswer(answer);
|
|
14186
|
+
if (stored.inline) {
|
|
14187
|
+
return { ok: true, answer: stored.summary };
|
|
14188
|
+
}
|
|
14189
|
+
return {
|
|
14190
|
+
ok: true,
|
|
14191
|
+
answer: stored.summary,
|
|
14192
|
+
_answerKey: stored.key,
|
|
14193
|
+
_hint: "Response was large and stored. Use ask_result with the key to retrieve it."
|
|
14194
|
+
};
|
|
13904
14195
|
} catch (err) {
|
|
13905
14196
|
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
13906
14197
|
}
|
|
13907
14198
|
}
|
|
13908
14199
|
};
|
|
13909
14200
|
}
|
|
14201
|
+
function makeAskResultTool(director) {
|
|
14202
|
+
return {
|
|
14203
|
+
name: "ask_result",
|
|
14204
|
+
description: "Retrieve a large `ask_subagent` response that was stored out-of-context (>2K chars). Returns the full stored value.",
|
|
14205
|
+
permission: "auto",
|
|
14206
|
+
mutating: false,
|
|
14207
|
+
inputSchema: {
|
|
14208
|
+
type: "object",
|
|
14209
|
+
properties: {
|
|
14210
|
+
key: {
|
|
14211
|
+
type: "string",
|
|
14212
|
+
minLength: 1,
|
|
14213
|
+
description: "The `_answerKey` returned by `ask_subagent` for a large response."
|
|
14214
|
+
}
|
|
14215
|
+
},
|
|
14216
|
+
required: ["key"]
|
|
14217
|
+
},
|
|
14218
|
+
async execute(input) {
|
|
14219
|
+
const i = input;
|
|
14220
|
+
const value = director.largeAnswerStore.retrieveAnswer(i.key);
|
|
14221
|
+
if (value === void 0) {
|
|
14222
|
+
return { ok: false, error: `No stored answer found for key "${i.key}" \u2014 it may have been cleared or the key is invalid.` };
|
|
14223
|
+
}
|
|
14224
|
+
return { ok: true, value };
|
|
14225
|
+
}
|
|
14226
|
+
};
|
|
14227
|
+
}
|
|
13910
14228
|
function makeRollUpTool(director) {
|
|
13911
14229
|
return {
|
|
13912
14230
|
name: "roll_up",
|
|
@@ -14060,6 +14378,7 @@ function makeCollabDebugTool(director) {
|
|
|
14060
14378
|
},
|
|
14061
14379
|
timeoutMs: {
|
|
14062
14380
|
type: "number",
|
|
14381
|
+
minimum: 1,
|
|
14063
14382
|
description: "Timeout in ms. Default: 600000 (10 minutes)."
|
|
14064
14383
|
}
|
|
14065
14384
|
},
|
|
@@ -14197,9 +14516,9 @@ var CollabSession = class extends EventEmitter {
|
|
|
14197
14516
|
}
|
|
14198
14517
|
async buildSnapshot() {
|
|
14199
14518
|
if (this.snapshot.files.length > 0) return this.snapshot;
|
|
14200
|
-
for (const filePath of this.options.targetPaths) {
|
|
14519
|
+
for (const filePath of (await Promise.all(this.options.targetPaths.map((p) => expandGlob(p)))).flat()) {
|
|
14201
14520
|
try {
|
|
14202
|
-
const content = await
|
|
14521
|
+
const content = await fsp3.readFile(filePath, "utf8");
|
|
14203
14522
|
const ext = filePath.split(".").pop() ?? "";
|
|
14204
14523
|
const language = ext === "ts" || ext === "tsx" ? "typescript" : ext === "js" || ext === "jsx" ? "javascript" : ext === "md" ? "markdown" : ext === "json" ? "json" : void 0;
|
|
14205
14524
|
this.snapshot.files.push({ path: filePath, content, language });
|
|
@@ -14253,7 +14572,7 @@ var CollabSession = class extends EventEmitter {
|
|
|
14253
14572
|
reject(new Error(`CollabSession timed out after ${this.timeoutMs}ms`));
|
|
14254
14573
|
}, this.timeoutMs);
|
|
14255
14574
|
});
|
|
14256
|
-
let results;
|
|
14575
|
+
let results = null;
|
|
14257
14576
|
try {
|
|
14258
14577
|
results = await Promise.race([
|
|
14259
14578
|
Promise.all([
|
|
@@ -14684,7 +15003,7 @@ var FleetContextOverflowError = class extends Error {
|
|
|
14684
15003
|
this.observed = observed;
|
|
14685
15004
|
}
|
|
14686
15005
|
};
|
|
14687
|
-
var Director = class {
|
|
15006
|
+
var Director = class _Director {
|
|
14688
15007
|
/** Alias for the ICoordinator contract. `id` is retained for backward compatibility. */
|
|
14689
15008
|
get coordinatorId() {
|
|
14690
15009
|
return this.id;
|
|
@@ -14742,6 +15061,8 @@ var Director = class {
|
|
|
14742
15061
|
* coordinator already fired the event — `awaitTasks(['t-1'])` after
|
|
14743
15062
|
* t-1 finished should resolve immediately, not hang. */
|
|
14744
15063
|
completed = /* @__PURE__ */ new Map();
|
|
15064
|
+
/** Prevents the completed Map from growing unbounded in long-running directors. */
|
|
15065
|
+
static MAX_COMPLETED = 1e4;
|
|
14745
15066
|
/** Per-subagent provider/model metadata, captured at spawn time so the
|
|
14746
15067
|
* FleetUsageAggregator's metaLookup can surface readable rows. */
|
|
14747
15068
|
subagentMeta = /* @__PURE__ */ new Map();
|
|
@@ -14821,6 +15142,8 @@ var Director = class {
|
|
|
14821
15142
|
_leaderBtwNotes = [];
|
|
14822
15143
|
/** Active collab sessions tracked by sessionId (see spawnCollab). */
|
|
14823
15144
|
_activeCollabSessions = /* @__PURE__ */ new Map();
|
|
15145
|
+
/** Prevents large `ask_subagent` answers from bloating the leader's context window. */
|
|
15146
|
+
largeAnswerStore;
|
|
14824
15147
|
constructor(opts) {
|
|
14825
15148
|
this.id = opts.config.coordinatorId || randomUUID();
|
|
14826
15149
|
this.manifestPath = opts.manifestPath;
|
|
@@ -14849,7 +15172,7 @@ var Director = class {
|
|
|
14849
15172
|
}, opts.checkpointDebounceMs ?? 250) : null;
|
|
14850
15173
|
this.fleetManager = opts.fleetManager;
|
|
14851
15174
|
if (this.sharedScratchpadPath) {
|
|
14852
|
-
void
|
|
15175
|
+
void fsp3.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(
|
|
14853
15176
|
(err) => this.logShutdownError("shared_scratchpad_mkdir", err)
|
|
14854
15177
|
);
|
|
14855
15178
|
}
|
|
@@ -14881,6 +15204,11 @@ var Director = class {
|
|
|
14881
15204
|
this.taskCompletedListener = (payload) => {
|
|
14882
15205
|
const r = payload.result;
|
|
14883
15206
|
this.completed.set(r.taskId, r);
|
|
15207
|
+
if (this.completed.size > _Director.MAX_COMPLETED) {
|
|
15208
|
+
const toDelete = this.completed.size - _Director.MAX_COMPLETED;
|
|
15209
|
+
const keys = [...this.completed.keys()].slice(0, toDelete);
|
|
15210
|
+
for (const k of keys) this.completed.delete(k);
|
|
15211
|
+
}
|
|
14884
15212
|
const waiter = this.taskWaiters.get(r.taskId);
|
|
14885
15213
|
if (waiter) {
|
|
14886
15214
|
waiter.resolve(r);
|
|
@@ -14987,6 +15315,7 @@ var Director = class {
|
|
|
14987
15315
|
payload.extend(extra);
|
|
14988
15316
|
});
|
|
14989
15317
|
});
|
|
15318
|
+
this.largeAnswerStore = new LargeAnswerStore(2e3);
|
|
14990
15319
|
}
|
|
14991
15320
|
/**
|
|
14992
15321
|
* Record a granted budget extension and broadcast it on the FleetBus so
|
|
@@ -15352,7 +15681,7 @@ var Director = class {
|
|
|
15352
15681
|
})),
|
|
15353
15682
|
usage: this.usage.snapshot()
|
|
15354
15683
|
};
|
|
15355
|
-
await
|
|
15684
|
+
await fsp3.mkdir(path6.dirname(this.manifestPath), { recursive: true });
|
|
15356
15685
|
await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
|
|
15357
15686
|
return this.manifestPath;
|
|
15358
15687
|
}
|
|
@@ -15467,11 +15796,11 @@ var Director = class {
|
|
|
15467
15796
|
if (cached) return cached;
|
|
15468
15797
|
const existing = this.taskWaiters.get(id);
|
|
15469
15798
|
if (existing) return existing.promise;
|
|
15470
|
-
let
|
|
15799
|
+
let resolve10;
|
|
15471
15800
|
const promise = new Promise((res) => {
|
|
15472
|
-
|
|
15801
|
+
resolve10 = res;
|
|
15473
15802
|
});
|
|
15474
|
-
this.taskWaiters.set(id, { promise, resolve:
|
|
15803
|
+
this.taskWaiters.set(id, { promise, resolve: resolve10 });
|
|
15475
15804
|
return promise;
|
|
15476
15805
|
})
|
|
15477
15806
|
);
|
|
@@ -15484,7 +15813,24 @@ var Director = class {
|
|
|
15484
15813
|
}
|
|
15485
15814
|
async remove(subagentId) {
|
|
15486
15815
|
await this.coordinator.remove(subagentId);
|
|
15816
|
+
const bridge = this.subagentBridges.get(subagentId);
|
|
15817
|
+
if (bridge) {
|
|
15818
|
+
await bridge.stop();
|
|
15819
|
+
this.subagentBridges.delete(subagentId);
|
|
15820
|
+
}
|
|
15487
15821
|
this.usage.removeSubagent(subagentId);
|
|
15822
|
+
if (this.fleetManager) {
|
|
15823
|
+
this.fleetManager.removeSubagent(subagentId);
|
|
15824
|
+
} else {
|
|
15825
|
+
const entry = this.manifestEntries.get(subagentId);
|
|
15826
|
+
if (entry?.name) {
|
|
15827
|
+
const nicknameKey = entry.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
15828
|
+
this._usedNicknames.delete(nicknameKey);
|
|
15829
|
+
}
|
|
15830
|
+
}
|
|
15831
|
+
this.manifestEntries.delete(subagentId);
|
|
15832
|
+
this.taskOwners.delete(subagentId);
|
|
15833
|
+
this.taskDescriptions.delete(subagentId);
|
|
15488
15834
|
}
|
|
15489
15835
|
status() {
|
|
15490
15836
|
const base = this.coordinator.getStatus();
|
|
@@ -15540,7 +15886,7 @@ var Director = class {
|
|
|
15540
15886
|
const filePath = path6.join(this.sessionsRoot, this.directorRunId, `${subagentId}.jsonl`);
|
|
15541
15887
|
let raw;
|
|
15542
15888
|
try {
|
|
15543
|
-
raw = await
|
|
15889
|
+
raw = await fsp3.readFile(filePath, "utf8");
|
|
15544
15890
|
} catch {
|
|
15545
15891
|
return null;
|
|
15546
15892
|
}
|
|
@@ -15646,6 +15992,7 @@ var Director = class {
|
|
|
15646
15992
|
makeAssignTool(this),
|
|
15647
15993
|
makeAwaitTasksTool(this),
|
|
15648
15994
|
makeAskTool(this),
|
|
15995
|
+
makeAskResultTool(this),
|
|
15649
15996
|
makeRollUpTool(this),
|
|
15650
15997
|
makeTerminateTool(this),
|
|
15651
15998
|
makeTerminateAllTool(this),
|
|
@@ -15728,15 +16075,33 @@ function createDelegateTool(opts) {
|
|
|
15728
16075
|
},
|
|
15729
16076
|
timeoutMs: {
|
|
15730
16077
|
type: "number",
|
|
16078
|
+
minimum: 1,
|
|
15731
16079
|
description: `Wall-clock budget for this delegate in milliseconds. No hard cap \u2014 set as high as the task realistically needs (a monorepo audit can take hours, a single-file lint takes seconds). Default ${Math.round(defaultTimeoutMs / 1e3 / 60)} minutes.`
|
|
15732
16080
|
},
|
|
15733
16081
|
maxIterations: {
|
|
15734
16082
|
type: "number",
|
|
16083
|
+
minimum: 1,
|
|
15735
16084
|
description: "Maximum LLM iterations the subagent may take. Unset = use the role/coordinator default. Raise this for tasks with many tool-think-tool cycles (deep code analysis, multi-file refactors)."
|
|
15736
16085
|
},
|
|
15737
16086
|
maxToolCalls: {
|
|
15738
16087
|
type: "number",
|
|
16088
|
+
minimum: 1,
|
|
15739
16089
|
description: "Maximum number of tool invocations the subagent may make. Unset = use the role/coordinator default. Raise this for tasks that touch many files (large grep + read + report)."
|
|
16090
|
+
},
|
|
16091
|
+
idleTimeoutMs: {
|
|
16092
|
+
type: "number",
|
|
16093
|
+
minimum: 1,
|
|
16094
|
+
description: "Idle timeout in ms: reap the subagent after this long with no activity. Resets on every iteration/tool call. Unset = use the role/coordinator default."
|
|
16095
|
+
},
|
|
16096
|
+
maxTokens: {
|
|
16097
|
+
type: "number",
|
|
16098
|
+
minimum: 1,
|
|
16099
|
+
description: "Maximum total tokens (input + output) the subagent may use. Unset = use the role/coordinator default."
|
|
16100
|
+
},
|
|
16101
|
+
maxCostUsd: {
|
|
16102
|
+
type: "number",
|
|
16103
|
+
minimum: 0,
|
|
16104
|
+
description: "Maximum estimated USD cost the subagent may incur. Unset = use the role/coordinator default."
|
|
15740
16105
|
}
|
|
15741
16106
|
},
|
|
15742
16107
|
required: ["task"]
|
|
@@ -15794,12 +16159,21 @@ function createDelegateTool(opts) {
|
|
|
15794
16159
|
};
|
|
15795
16160
|
cfg = applyRosterBudget({ ...cfg, name: i.name });
|
|
15796
16161
|
}
|
|
15797
|
-
if (typeof i.maxIterations === "number"
|
|
16162
|
+
if (typeof i.maxIterations === "number") {
|
|
15798
16163
|
cfg.maxIterations = i.maxIterations;
|
|
15799
16164
|
}
|
|
15800
|
-
if (typeof i.maxToolCalls === "number"
|
|
16165
|
+
if (typeof i.maxToolCalls === "number") {
|
|
15801
16166
|
cfg.maxToolCalls = i.maxToolCalls;
|
|
15802
16167
|
}
|
|
16168
|
+
if (typeof i.idleTimeoutMs === "number") {
|
|
16169
|
+
cfg.idleTimeoutMs = i.idleTimeoutMs;
|
|
16170
|
+
}
|
|
16171
|
+
if (typeof i.maxTokens === "number") {
|
|
16172
|
+
cfg.maxTokens = i.maxTokens;
|
|
16173
|
+
}
|
|
16174
|
+
if (typeof i.maxCostUsd === "number") {
|
|
16175
|
+
cfg.maxCostUsd = i.maxCostUsd;
|
|
16176
|
+
}
|
|
15803
16177
|
const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 6e4;
|
|
15804
16178
|
if (!cfg.timeoutMs) {
|
|
15805
16179
|
cfg.timeoutMs = Math.max(3e4, timeoutMs - SUBAGENT_TIMEOUT_BUFFER_MS);
|
|
@@ -15811,7 +16185,7 @@ function createDelegateTool(opts) {
|
|
|
15811
16185
|
subagentId
|
|
15812
16186
|
});
|
|
15813
16187
|
const dir = director;
|
|
15814
|
-
const result = await new Promise((
|
|
16188
|
+
const result = await new Promise((resolve10) => {
|
|
15815
16189
|
let settled = false;
|
|
15816
16190
|
let timer;
|
|
15817
16191
|
const finish = (value) => {
|
|
@@ -15821,7 +16195,7 @@ function createDelegateTool(opts) {
|
|
|
15821
16195
|
offTool();
|
|
15822
16196
|
offIter();
|
|
15823
16197
|
offProgress();
|
|
15824
|
-
|
|
16198
|
+
resolve10(value);
|
|
15825
16199
|
};
|
|
15826
16200
|
const arm = () => {
|
|
15827
16201
|
if (timer) clearTimeout(timer);
|
|
@@ -15968,7 +16342,7 @@ async function readSubagentPartial(opts, subagentId) {
|
|
|
15968
16342
|
candidates.push(path6.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
|
|
15969
16343
|
} else {
|
|
15970
16344
|
try {
|
|
15971
|
-
const entries = await
|
|
16345
|
+
const entries = await fsp3.readdir(opts.sessionsRoot, { withFileTypes: true });
|
|
15972
16346
|
for (const entry of entries) {
|
|
15973
16347
|
if (entry.isDirectory()) {
|
|
15974
16348
|
candidates.push(path6.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
|
|
@@ -15981,7 +16355,7 @@ async function readSubagentPartial(opts, subagentId) {
|
|
|
15981
16355
|
for (const file of candidates) {
|
|
15982
16356
|
let raw;
|
|
15983
16357
|
try {
|
|
15984
|
-
raw = await
|
|
16358
|
+
raw = await fsp3.readFile(file, "utf8");
|
|
15985
16359
|
} catch {
|
|
15986
16360
|
continue;
|
|
15987
16361
|
}
|
|
@@ -16150,7 +16524,7 @@ var DefaultModeStore = class {
|
|
|
16150
16524
|
async loadActiveMode() {
|
|
16151
16525
|
try {
|
|
16152
16526
|
const configPath = path6.join(this.configDir, "mode.json");
|
|
16153
|
-
const content = await
|
|
16527
|
+
const content = await fsp3.readFile(configPath, "utf8");
|
|
16154
16528
|
const data = JSON.parse(content);
|
|
16155
16529
|
this.activeModeId = data.activeMode ?? null;
|
|
16156
16530
|
} catch {
|
|
@@ -16159,7 +16533,7 @@ var DefaultModeStore = class {
|
|
|
16159
16533
|
}
|
|
16160
16534
|
async saveActiveMode() {
|
|
16161
16535
|
try {
|
|
16162
|
-
await
|
|
16536
|
+
await fsp3.mkdir(this.configDir, { recursive: true });
|
|
16163
16537
|
const configPath = path6.join(this.configDir, "mode.json");
|
|
16164
16538
|
await atomicWrite(
|
|
16165
16539
|
configPath,
|
|
@@ -16172,13 +16546,13 @@ var DefaultModeStore = class {
|
|
|
16172
16546
|
async function loadProjectModes(modesDir) {
|
|
16173
16547
|
const modes = [];
|
|
16174
16548
|
try {
|
|
16175
|
-
const entries = await
|
|
16549
|
+
const entries = await fsp3.readdir(modesDir);
|
|
16176
16550
|
for (const entry of entries) {
|
|
16177
16551
|
if (!entry.endsWith(".md") && !entry.endsWith(".txt")) continue;
|
|
16178
16552
|
const filePath = path6.join(modesDir, entry);
|
|
16179
|
-
const
|
|
16180
|
-
if (!
|
|
16181
|
-
const content = await
|
|
16553
|
+
const stat10 = await fsp3.stat(filePath);
|
|
16554
|
+
if (!stat10.isFile()) continue;
|
|
16555
|
+
const content = await fsp3.readFile(filePath, "utf8");
|
|
16182
16556
|
const id = path6.basename(entry, path6.extname(entry));
|
|
16183
16557
|
modes.push({
|
|
16184
16558
|
id,
|
|
@@ -16196,7 +16570,7 @@ async function loadUserModes(modesDir) {
|
|
|
16196
16570
|
const modes = [];
|
|
16197
16571
|
try {
|
|
16198
16572
|
const manifestPath = path6.join(modesDir, "modes.json");
|
|
16199
|
-
const content = await
|
|
16573
|
+
const content = await fsp3.readFile(manifestPath, "utf8");
|
|
16200
16574
|
const manifest = JSON.parse(content);
|
|
16201
16575
|
for (const mode of manifest.modes) {
|
|
16202
16576
|
modes.push(mode);
|
|
@@ -17052,7 +17426,7 @@ var SpecStore = class {
|
|
|
17052
17426
|
}
|
|
17053
17427
|
async load(id) {
|
|
17054
17428
|
try {
|
|
17055
|
-
const raw = await
|
|
17429
|
+
const raw = await fsp3.readFile(this.filePath(id), "utf8");
|
|
17056
17430
|
return JSON.parse(raw);
|
|
17057
17431
|
} catch {
|
|
17058
17432
|
return null;
|
|
@@ -17064,7 +17438,7 @@ var SpecStore = class {
|
|
|
17064
17438
|
}
|
|
17065
17439
|
async delete(id) {
|
|
17066
17440
|
try {
|
|
17067
|
-
await
|
|
17441
|
+
await fsp3.unlink(this.filePath(id));
|
|
17068
17442
|
await this.removeFromIndex(id);
|
|
17069
17443
|
return true;
|
|
17070
17444
|
} catch {
|
|
@@ -17073,7 +17447,7 @@ var SpecStore = class {
|
|
|
17073
17447
|
}
|
|
17074
17448
|
async exists(id) {
|
|
17075
17449
|
try {
|
|
17076
|
-
await
|
|
17450
|
+
await fsp3.access(this.filePath(id));
|
|
17077
17451
|
return true;
|
|
17078
17452
|
} catch {
|
|
17079
17453
|
return false;
|
|
@@ -17115,7 +17489,7 @@ var SpecStore = class {
|
|
|
17115
17489
|
}
|
|
17116
17490
|
async readIndex() {
|
|
17117
17491
|
try {
|
|
17118
|
-
const raw = await
|
|
17492
|
+
const raw = await fsp3.readFile(this.indexPath, "utf8");
|
|
17119
17493
|
const parsed = JSON.parse(raw);
|
|
17120
17494
|
if (parsed?.version === 1) return parsed;
|
|
17121
17495
|
} catch {
|
|
@@ -17178,7 +17552,7 @@ var TaskGraphStore = class {
|
|
|
17178
17552
|
}
|
|
17179
17553
|
async load(id) {
|
|
17180
17554
|
try {
|
|
17181
|
-
const raw = await
|
|
17555
|
+
const raw = await fsp3.readFile(this.filePath(id), "utf8");
|
|
17182
17556
|
return graphFromJSON(raw);
|
|
17183
17557
|
} catch {
|
|
17184
17558
|
return null;
|
|
@@ -17190,7 +17564,7 @@ var TaskGraphStore = class {
|
|
|
17190
17564
|
}
|
|
17191
17565
|
async delete(id) {
|
|
17192
17566
|
try {
|
|
17193
|
-
await
|
|
17567
|
+
await fsp3.unlink(this.filePath(id));
|
|
17194
17568
|
await this.removeFromIndex(id);
|
|
17195
17569
|
return true;
|
|
17196
17570
|
} catch {
|
|
@@ -17199,7 +17573,7 @@ var TaskGraphStore = class {
|
|
|
17199
17573
|
}
|
|
17200
17574
|
async exists(id) {
|
|
17201
17575
|
try {
|
|
17202
|
-
await
|
|
17576
|
+
await fsp3.access(this.filePath(id));
|
|
17203
17577
|
return true;
|
|
17204
17578
|
} catch {
|
|
17205
17579
|
return false;
|
|
@@ -17210,7 +17584,7 @@ var TaskGraphStore = class {
|
|
|
17210
17584
|
}
|
|
17211
17585
|
async readIndex() {
|
|
17212
17586
|
try {
|
|
17213
|
-
const raw = await
|
|
17587
|
+
const raw = await fsp3.readFile(this.indexPath, "utf8");
|
|
17214
17588
|
const parsed = JSON.parse(raw);
|
|
17215
17589
|
if (parsed?.version === 1) return parsed;
|
|
17216
17590
|
} catch {
|
|
@@ -17450,10 +17824,10 @@ var AISpecBuilder = class {
|
|
|
17450
17824
|
async saveSession() {
|
|
17451
17825
|
if (!this.sessionPath) return;
|
|
17452
17826
|
try {
|
|
17453
|
-
const
|
|
17827
|
+
const fsp20 = await import('fs/promises');
|
|
17454
17828
|
const path35 = await import('path');
|
|
17455
17829
|
const { atomicWrite: atomicWrite2 } = await Promise.resolve().then(() => (init_atomic_write(), atomic_write_exports));
|
|
17456
|
-
await
|
|
17830
|
+
await fsp20.mkdir(path35.dirname(this.sessionPath), { recursive: true });
|
|
17457
17831
|
await atomicWrite2(this.sessionPath, JSON.stringify(this.session, null, 2));
|
|
17458
17832
|
} catch {
|
|
17459
17833
|
}
|
|
@@ -17462,8 +17836,8 @@ var AISpecBuilder = class {
|
|
|
17462
17836
|
async loadSession() {
|
|
17463
17837
|
if (!this.sessionPath) return false;
|
|
17464
17838
|
try {
|
|
17465
|
-
const
|
|
17466
|
-
const raw = await
|
|
17839
|
+
const fsp20 = await import('fs/promises');
|
|
17840
|
+
const raw = await fsp20.readFile(this.sessionPath, "utf8");
|
|
17467
17841
|
const loaded = JSON.parse(raw);
|
|
17468
17842
|
if (loaded?.id && loaded?.phase && loaded?.title) {
|
|
17469
17843
|
this.session = loaded;
|
|
@@ -17477,8 +17851,8 @@ var AISpecBuilder = class {
|
|
|
17477
17851
|
async deleteSession() {
|
|
17478
17852
|
if (!this.sessionPath) return;
|
|
17479
17853
|
try {
|
|
17480
|
-
const
|
|
17481
|
-
await
|
|
17854
|
+
const fsp20 = await import('fs/promises');
|
|
17855
|
+
await fsp20.unlink(this.sessionPath);
|
|
17482
17856
|
} catch {
|
|
17483
17857
|
}
|
|
17484
17858
|
}
|
|
@@ -18964,9 +19338,9 @@ var DefaultHealthRegistry = class {
|
|
|
18964
19338
|
}
|
|
18965
19339
|
async runOne(check) {
|
|
18966
19340
|
let timer = null;
|
|
18967
|
-
const timeout = new Promise((
|
|
19341
|
+
const timeout = new Promise((resolve10) => {
|
|
18968
19342
|
timer = setTimeout(
|
|
18969
|
-
() =>
|
|
19343
|
+
() => resolve10({ status: "unhealthy", detail: `timeout after ${this.timeoutMs}ms` }),
|
|
18970
19344
|
this.timeoutMs
|
|
18971
19345
|
);
|
|
18972
19346
|
});
|
|
@@ -19205,14 +19579,14 @@ async function startMetricsServer(opts) {
|
|
|
19205
19579
|
const { createServer } = await import('http');
|
|
19206
19580
|
server = createServer(listener);
|
|
19207
19581
|
}
|
|
19208
|
-
await new Promise((
|
|
19582
|
+
await new Promise((resolve10, reject) => {
|
|
19209
19583
|
const onError = (err) => {
|
|
19210
19584
|
server.off("listening", onListening);
|
|
19211
19585
|
reject(err);
|
|
19212
19586
|
};
|
|
19213
19587
|
const onListening = () => {
|
|
19214
19588
|
server.off("error", onError);
|
|
19215
|
-
|
|
19589
|
+
resolve10();
|
|
19216
19590
|
};
|
|
19217
19591
|
server.once("error", onError);
|
|
19218
19592
|
server.once("listening", onListening);
|
|
@@ -19224,8 +19598,8 @@ async function startMetricsServer(opts) {
|
|
|
19224
19598
|
return {
|
|
19225
19599
|
port: boundPort,
|
|
19226
19600
|
url: `${protocol}://${host}:${boundPort}${path35}`,
|
|
19227
|
-
close: () => new Promise((
|
|
19228
|
-
server.close((err) => err ? reject(err) :
|
|
19601
|
+
close: () => new Promise((resolve10, reject) => {
|
|
19602
|
+
server.close((err) => err ? reject(err) : resolve10());
|
|
19229
19603
|
})
|
|
19230
19604
|
};
|
|
19231
19605
|
}
|
|
@@ -19925,7 +20299,7 @@ async function downloadGitHubTarball(parsed) {
|
|
|
19925
20299
|
`Tarball too large (${(Number.parseInt(contentLength, 10) / 1024 / 1024).toFixed(1)}MB). Max: ${MAX_TARBALL_SIZE / 1024 / 1024}MB`
|
|
19926
20300
|
);
|
|
19927
20301
|
}
|
|
19928
|
-
const tempDir = await
|
|
20302
|
+
const tempDir = await fsp3.mkdtemp(path6.join(os5.tmpdir(), "wskill-"));
|
|
19929
20303
|
try {
|
|
19930
20304
|
if (!response.body) {
|
|
19931
20305
|
throw new Error("Empty response body from GitHub API");
|
|
@@ -19942,7 +20316,7 @@ async function downloadGitHubTarball(parsed) {
|
|
|
19942
20316
|
await extractTar(tarBuf, tempDir);
|
|
19943
20317
|
return { tempDir };
|
|
19944
20318
|
} catch (err) {
|
|
19945
|
-
await
|
|
20319
|
+
await fsp3.rm(tempDir, { recursive: true, force: true }).catch(() => {
|
|
19946
20320
|
});
|
|
19947
20321
|
throw err;
|
|
19948
20322
|
}
|
|
@@ -19968,16 +20342,16 @@ async function extractTar(buf, destDir) {
|
|
|
19968
20342
|
}
|
|
19969
20343
|
if (typeflag === 53 || typeflag === 0) {
|
|
19970
20344
|
if (relPath.endsWith("/") || typeflag === 53) {
|
|
19971
|
-
await
|
|
20345
|
+
await fsp3.mkdir(destPath, { recursive: true });
|
|
19972
20346
|
}
|
|
19973
20347
|
}
|
|
19974
20348
|
if ((typeflag === 48 || typeflag === 0 || typeflag === 0) && size > 0) {
|
|
19975
20349
|
const dir = path6.dirname(destPath);
|
|
19976
|
-
await
|
|
20350
|
+
await fsp3.mkdir(dir, { recursive: true });
|
|
19977
20351
|
const dataStart = offset + 512;
|
|
19978
20352
|
const dataEnd = dataStart + size;
|
|
19979
20353
|
if (dataEnd > buf.length) break;
|
|
19980
|
-
await
|
|
20354
|
+
await fsp3.writeFile(destPath, buf.subarray(dataStart, dataEnd));
|
|
19981
20355
|
}
|
|
19982
20356
|
}
|
|
19983
20357
|
offset += 512 + Math.ceil(size / 512) * 512;
|
|
@@ -20007,7 +20381,7 @@ var SkillManifestStore = class {
|
|
|
20007
20381
|
async read() {
|
|
20008
20382
|
if (this.cache) return this.cache;
|
|
20009
20383
|
try {
|
|
20010
|
-
const raw = await
|
|
20384
|
+
const raw = await fsp3.readFile(this.manifestPath, "utf8");
|
|
20011
20385
|
const data = JSON.parse(raw);
|
|
20012
20386
|
if (!Array.isArray(data.skills)) {
|
|
20013
20387
|
this.cache = { skills: [] };
|
|
@@ -20021,7 +20395,7 @@ var SkillManifestStore = class {
|
|
|
20021
20395
|
}
|
|
20022
20396
|
async write(data) {
|
|
20023
20397
|
const dir = path6.dirname(this.manifestPath);
|
|
20024
|
-
await
|
|
20398
|
+
await fsp3.mkdir(dir, { recursive: true });
|
|
20025
20399
|
await atomicWrite(this.manifestPath, JSON.stringify(data, null, 2) + "\n");
|
|
20026
20400
|
this.cache = data;
|
|
20027
20401
|
}
|
|
@@ -20097,7 +20471,7 @@ var SkillInstaller = class {
|
|
|
20097
20471
|
await this.removeSkillFiles(skill.name, scope);
|
|
20098
20472
|
}
|
|
20099
20473
|
const destDir = path6.join(targetDir, skill.name);
|
|
20100
|
-
await
|
|
20474
|
+
await fsp3.mkdir(destDir, { recursive: true });
|
|
20101
20475
|
const copiedFiles = [];
|
|
20102
20476
|
for (const file of skill.files) {
|
|
20103
20477
|
const srcPath = path6.join(skill.baseDir, file);
|
|
@@ -20106,14 +20480,14 @@ var SkillInstaller = class {
|
|
|
20106
20480
|
if (!resolved.startsWith(path6.resolve(destDir))) {
|
|
20107
20481
|
throw new Error(`Path traversal detected in skill file: ${file}`);
|
|
20108
20482
|
}
|
|
20109
|
-
const
|
|
20110
|
-
if (
|
|
20483
|
+
const stat10 = await fsp3.stat(srcPath);
|
|
20484
|
+
if (stat10.size > MAX_SKILL_FILE_SIZE) {
|
|
20111
20485
|
throw new Error(
|
|
20112
|
-
`Skill file "${file}" is too large (${(
|
|
20486
|
+
`Skill file "${file}" is too large (${(stat10.size / 1024).toFixed(1)}KB). Max: ${MAX_SKILL_FILE_SIZE / 1024}KB`
|
|
20113
20487
|
);
|
|
20114
20488
|
}
|
|
20115
|
-
await
|
|
20116
|
-
await
|
|
20489
|
+
await fsp3.mkdir(path6.dirname(destPath), { recursive: true });
|
|
20490
|
+
await fsp3.copyFile(srcPath, destPath);
|
|
20117
20491
|
copiedFiles.push(file);
|
|
20118
20492
|
}
|
|
20119
20493
|
const entry = {
|
|
@@ -20138,7 +20512,7 @@ var SkillInstaller = class {
|
|
|
20138
20512
|
this.invalidateLoaderCache();
|
|
20139
20513
|
return results;
|
|
20140
20514
|
} finally {
|
|
20141
|
-
await
|
|
20515
|
+
await fsp3.rm(tempDir, { recursive: true, force: true }).catch(() => {
|
|
20142
20516
|
});
|
|
20143
20517
|
}
|
|
20144
20518
|
}
|
|
@@ -20242,31 +20616,31 @@ var SkillInstaller = class {
|
|
|
20242
20616
|
* Detect skills in an extracted repository.
|
|
20243
20617
|
* Returns an array of detected skills with their files.
|
|
20244
20618
|
*/
|
|
20245
|
-
async detectSkills(
|
|
20619
|
+
async detectSkills(baseDir2) {
|
|
20246
20620
|
const results = [];
|
|
20247
|
-
const rootSkillMd = path6.join(
|
|
20621
|
+
const rootSkillMd = path6.join(baseDir2, "SKILL.md");
|
|
20248
20622
|
try {
|
|
20249
|
-
await
|
|
20250
|
-
const content = await
|
|
20623
|
+
await fsp3.access(rootSkillMd);
|
|
20624
|
+
const content = await fsp3.readFile(rootSkillMd, "utf8");
|
|
20251
20625
|
const meta = parseFrontmatter2(content);
|
|
20252
20626
|
if (meta.name && meta.description) {
|
|
20253
20627
|
results.push({
|
|
20254
20628
|
name: meta.name,
|
|
20255
|
-
baseDir,
|
|
20629
|
+
baseDir: baseDir2,
|
|
20256
20630
|
files: ["SKILL.md"]
|
|
20257
20631
|
});
|
|
20258
20632
|
return results;
|
|
20259
20633
|
}
|
|
20260
20634
|
} catch {
|
|
20261
20635
|
}
|
|
20262
|
-
const skillsDir = path6.join(
|
|
20636
|
+
const skillsDir = path6.join(baseDir2, "skills");
|
|
20263
20637
|
try {
|
|
20264
|
-
const entries = await
|
|
20638
|
+
const entries = await fsp3.readdir(skillsDir, { withFileTypes: true });
|
|
20265
20639
|
for (const entry of entries) {
|
|
20266
20640
|
if (!entry.isDirectory()) continue;
|
|
20267
20641
|
const skillFile = path6.join(skillsDir, entry.name, "SKILL.md");
|
|
20268
20642
|
try {
|
|
20269
|
-
const content = await
|
|
20643
|
+
const content = await fsp3.readFile(skillFile, "utf8");
|
|
20270
20644
|
const meta = parseFrontmatter2(content);
|
|
20271
20645
|
if (meta.name && meta.description) {
|
|
20272
20646
|
const skillDir = path6.join(skillsDir, entry.name);
|
|
@@ -20290,7 +20664,7 @@ var SkillInstaller = class {
|
|
|
20290
20664
|
async removeSkillFiles(name, scope) {
|
|
20291
20665
|
const targetDir = scope === "project" ? this.opts.projectSkillsDir : this.opts.globalSkillsDir;
|
|
20292
20666
|
const skillDir = path6.join(targetDir, name);
|
|
20293
|
-
await
|
|
20667
|
+
await fsp3.rm(skillDir, { recursive: true, force: true });
|
|
20294
20668
|
}
|
|
20295
20669
|
/**
|
|
20296
20670
|
* Invalidate the skill loader's cache so newly installed skills appear.
|
|
@@ -20338,15 +20712,15 @@ function parseFrontmatter2(raw) {
|
|
|
20338
20712
|
flush();
|
|
20339
20713
|
return out;
|
|
20340
20714
|
}
|
|
20341
|
-
async function collectFiles(dir,
|
|
20715
|
+
async function collectFiles(dir, baseDir2) {
|
|
20342
20716
|
const results = [];
|
|
20343
|
-
const entries = await
|
|
20717
|
+
const entries = await fsp3.readdir(dir, { withFileTypes: true });
|
|
20344
20718
|
for (const entry of entries) {
|
|
20345
20719
|
const fullPath = path6.join(dir, entry.name);
|
|
20346
|
-
const relPath = path6.relative(
|
|
20720
|
+
const relPath = path6.relative(baseDir2, fullPath);
|
|
20347
20721
|
if (entry.isDirectory()) {
|
|
20348
20722
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
20349
|
-
results.push(...await collectFiles(fullPath,
|
|
20723
|
+
results.push(...await collectFiles(fullPath, baseDir2));
|
|
20350
20724
|
} else {
|
|
20351
20725
|
results.push(relPath);
|
|
20352
20726
|
}
|
|
@@ -20468,7 +20842,7 @@ var AnnotationsStore = class {
|
|
|
20468
20842
|
async readFile(sessionId) {
|
|
20469
20843
|
const fp = this.filePath(sessionId);
|
|
20470
20844
|
try {
|
|
20471
|
-
const raw = await
|
|
20845
|
+
const raw = await fsp3.readFile(fp, "utf8");
|
|
20472
20846
|
const parsed = JSON.parse(raw);
|
|
20473
20847
|
if (parsed.version !== FILE_VERSION) {
|
|
20474
20848
|
return { version: FILE_VERSION, annotations: [] };
|
|
@@ -20568,7 +20942,7 @@ var ReplayLogStore = class {
|
|
|
20568
20942
|
if (count > this.maxEntries) {
|
|
20569
20943
|
await this.compact(input.sessionId, cache);
|
|
20570
20944
|
} else {
|
|
20571
|
-
await
|
|
20945
|
+
await fsp3.appendFile(this.filePath(input.sessionId), JSON.stringify(entry) + "\n", "utf8");
|
|
20572
20946
|
this.diskCount.set(input.sessionId, count);
|
|
20573
20947
|
}
|
|
20574
20948
|
});
|
|
@@ -20610,7 +20984,7 @@ var ReplayLogStore = class {
|
|
|
20610
20984
|
async list() {
|
|
20611
20985
|
let entries;
|
|
20612
20986
|
try {
|
|
20613
|
-
entries = await
|
|
20987
|
+
entries = await fsp3.readdir(this.dir);
|
|
20614
20988
|
} catch (err) {
|
|
20615
20989
|
if (err.code === "ENOENT") return [];
|
|
20616
20990
|
return [];
|
|
@@ -20638,7 +21012,7 @@ var ReplayLogStore = class {
|
|
|
20638
21012
|
async readAll(sessionId) {
|
|
20639
21013
|
const fp = this.filePath(sessionId);
|
|
20640
21014
|
try {
|
|
20641
|
-
const raw = await
|
|
21015
|
+
const raw = await fsp3.readFile(fp, "utf8");
|
|
20642
21016
|
const out = [];
|
|
20643
21017
|
for (const line of raw.split("\n")) {
|
|
20644
21018
|
if (!line.trim()) continue;
|
|
@@ -20701,19 +21075,19 @@ var SessionRecovery = class {
|
|
|
20701
21075
|
async detectStale(sessionId) {
|
|
20702
21076
|
const fp = this.filePath(sessionId);
|
|
20703
21077
|
const TAIL_SIZE = 8192;
|
|
20704
|
-
let
|
|
21078
|
+
let stat10;
|
|
20705
21079
|
try {
|
|
20706
|
-
|
|
21080
|
+
stat10 = await fsp3.stat(fp);
|
|
20707
21081
|
} catch (err) {
|
|
20708
21082
|
if (err.code === "ENOENT") return null;
|
|
20709
21083
|
return null;
|
|
20710
21084
|
}
|
|
20711
|
-
if (
|
|
20712
|
-
const position = Math.max(0,
|
|
21085
|
+
if (stat10.size === 0) return null;
|
|
21086
|
+
const position = Math.max(0, stat10.size - TAIL_SIZE);
|
|
20713
21087
|
const buf = Buffer.alloc(TAIL_SIZE);
|
|
20714
21088
|
let fh;
|
|
20715
21089
|
try {
|
|
20716
|
-
fh = await
|
|
21090
|
+
fh = await fsp3.open(fp, "r");
|
|
20717
21091
|
const { bytesRead } = await fh.read(buf, 0, TAIL_SIZE, position);
|
|
20718
21092
|
let eventCount = 0;
|
|
20719
21093
|
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
@@ -20759,7 +21133,7 @@ var SessionRecovery = class {
|
|
|
20759
21133
|
const fp = this.filePath(sessionId);
|
|
20760
21134
|
let raw;
|
|
20761
21135
|
try {
|
|
20762
|
-
raw = await
|
|
21136
|
+
raw = await fsp3.readFile(fp, "utf8");
|
|
20763
21137
|
} catch (err) {
|
|
20764
21138
|
if (err.code === "ENOENT") return null;
|
|
20765
21139
|
return null;
|
|
@@ -20802,7 +21176,7 @@ var SessionRecovery = class {
|
|
|
20802
21176
|
async listResumable() {
|
|
20803
21177
|
let entries;
|
|
20804
21178
|
try {
|
|
20805
|
-
entries = await
|
|
21179
|
+
entries = await fsp3.readdir(this.dir);
|
|
20806
21180
|
} catch (err) {
|
|
20807
21181
|
if (err.code === "ENOENT") return [];
|
|
20808
21182
|
return [];
|
|
@@ -20945,7 +21319,7 @@ var ToolAuditLog = class {
|
|
|
20945
21319
|
async readAll(sessionId) {
|
|
20946
21320
|
const fp = this.filePath(sessionId);
|
|
20947
21321
|
try {
|
|
20948
|
-
const raw = await
|
|
21322
|
+
const raw = await fsp3.readFile(fp, "utf8");
|
|
20949
21323
|
const out = [];
|
|
20950
21324
|
for (const line of raw.split("\n")) {
|
|
20951
21325
|
if (!line.trim()) continue;
|
|
@@ -20963,7 +21337,7 @@ var ToolAuditLog = class {
|
|
|
20963
21337
|
async appendLine(sessionId, entry) {
|
|
20964
21338
|
const fp = this.filePath(sessionId);
|
|
20965
21339
|
const line = JSON.stringify(entry) + "\n";
|
|
20966
|
-
await
|
|
21340
|
+
await fsp3.appendFile(fp, line, "utf8");
|
|
20967
21341
|
const count = (this.unSyncedWrites.get(sessionId) ?? 0) + 1;
|
|
20968
21342
|
this.unSyncedWrites.set(sessionId, count);
|
|
20969
21343
|
if (this.fsyncEvery !== Infinity && count % this.fsyncEvery === 0) {
|
|
@@ -20980,7 +21354,7 @@ var ToolAuditLog = class {
|
|
|
20980
21354
|
}
|
|
20981
21355
|
async sync(sessionId, fp) {
|
|
20982
21356
|
try {
|
|
20983
|
-
const fh = await
|
|
21357
|
+
const fh = await fsp3.open(fp, "r+");
|
|
20984
21358
|
try {
|
|
20985
21359
|
await fh.sync();
|
|
20986
21360
|
} finally {
|
|
@@ -21028,7 +21402,7 @@ var DefaultSessionRewinder = class {
|
|
|
21028
21402
|
projectRoot;
|
|
21029
21403
|
async listCheckpoints(sessionId) {
|
|
21030
21404
|
const file = path6.join(this.sessionsDir, `${sessionId}.jsonl`);
|
|
21031
|
-
const raw = await
|
|
21405
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
21032
21406
|
const events = parseEvents(raw);
|
|
21033
21407
|
const fileCountMap = /* @__PURE__ */ new Map();
|
|
21034
21408
|
for (const event of events) {
|
|
@@ -21053,7 +21427,7 @@ var DefaultSessionRewinder = class {
|
|
|
21053
21427
|
}
|
|
21054
21428
|
async rewindToCheckpoint(sessionId, checkpointIndex) {
|
|
21055
21429
|
const file = path6.join(this.sessionsDir, `${sessionId}.jsonl`);
|
|
21056
|
-
const raw = await
|
|
21430
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
21057
21431
|
const events = parseEvents(raw);
|
|
21058
21432
|
let targetIdx = -1;
|
|
21059
21433
|
for (let i = 0; i < events.length; i++) {
|
|
@@ -21088,7 +21462,7 @@ var DefaultSessionRewinder = class {
|
|
|
21088
21462
|
}
|
|
21089
21463
|
async rewindLastN(sessionId, n) {
|
|
21090
21464
|
const file = path6.join(this.sessionsDir, `${sessionId}.jsonl`);
|
|
21091
|
-
const raw = await
|
|
21465
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
21092
21466
|
const events = parseEvents(raw);
|
|
21093
21467
|
const checkpoints = [];
|
|
21094
21468
|
for (const event of events) {
|
|
@@ -21117,7 +21491,7 @@ var DefaultSessionRewinder = class {
|
|
|
21117
21491
|
}
|
|
21118
21492
|
async rewindToStart(sessionId) {
|
|
21119
21493
|
const file = path6.join(this.sessionsDir, `${sessionId}.jsonl`);
|
|
21120
|
-
const raw = await
|
|
21494
|
+
const raw = await fsp3.readFile(file, "utf8");
|
|
21121
21495
|
const events = parseEvents(raw);
|
|
21122
21496
|
const allSnapshots = [];
|
|
21123
21497
|
for (const event of events) {
|
|
@@ -21165,7 +21539,7 @@ async function revertSnapshots(snapshots, projectRoot) {
|
|
|
21165
21539
|
revertedFiles.push(file.path);
|
|
21166
21540
|
}
|
|
21167
21541
|
} else if (file.action === "created") {
|
|
21168
|
-
await
|
|
21542
|
+
await fsp3.unlink(file.path);
|
|
21169
21543
|
revertedFiles.push(file.path);
|
|
21170
21544
|
} else if (file.action === "modified") {
|
|
21171
21545
|
if (file.before !== null) {
|
|
@@ -21192,12 +21566,12 @@ var DefaultPromptStore = class {
|
|
|
21192
21566
|
await ensureDir(this.dir);
|
|
21193
21567
|
const entries = [];
|
|
21194
21568
|
try {
|
|
21195
|
-
const files = await
|
|
21569
|
+
const files = await fsp3.readdir(this.dir);
|
|
21196
21570
|
for (const file of files) {
|
|
21197
21571
|
if (!file.endsWith(".json")) continue;
|
|
21198
21572
|
try {
|
|
21199
21573
|
const raw = JSON.parse(
|
|
21200
|
-
await
|
|
21574
|
+
await fsp3.readFile(path6.join(this.dir, file), "utf8")
|
|
21201
21575
|
);
|
|
21202
21576
|
entries.push(raw.entry);
|
|
21203
21577
|
} catch {
|
|
@@ -21212,7 +21586,7 @@ var DefaultPromptStore = class {
|
|
|
21212
21586
|
async get(id) {
|
|
21213
21587
|
const file = path6.join(this.dir, `${id}.json`);
|
|
21214
21588
|
try {
|
|
21215
|
-
const raw = JSON.parse(await
|
|
21589
|
+
const raw = JSON.parse(await fsp3.readFile(file, "utf8"));
|
|
21216
21590
|
return raw.entry;
|
|
21217
21591
|
} catch {
|
|
21218
21592
|
return null;
|
|
@@ -21227,7 +21601,7 @@ var DefaultPromptStore = class {
|
|
|
21227
21601
|
async delete(id) {
|
|
21228
21602
|
const file = path6.join(this.dir, `${id}.json`);
|
|
21229
21603
|
try {
|
|
21230
|
-
await
|
|
21604
|
+
await fsp3.unlink(file);
|
|
21231
21605
|
return true;
|
|
21232
21606
|
} catch {
|
|
21233
21607
|
return false;
|
|
@@ -21334,7 +21708,7 @@ var CloudSync = class {
|
|
|
21334
21708
|
lastSyncedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21335
21709
|
localRev: rev
|
|
21336
21710
|
};
|
|
21337
|
-
await
|
|
21711
|
+
await fsp3.writeFile(this.statePath, JSON.stringify(syncState, null, 2), "utf8");
|
|
21338
21712
|
this.state = syncState;
|
|
21339
21713
|
return {
|
|
21340
21714
|
ok: true,
|
|
@@ -21366,8 +21740,8 @@ var CloudSync = class {
|
|
|
21366
21740
|
const rel = segments.slice(2).join("/");
|
|
21367
21741
|
const destPath = rel ? path6.join(localPath, rel) : localPath;
|
|
21368
21742
|
const blobData = await this.getBlob(token, owner, repoName, entry.sha);
|
|
21369
|
-
await
|
|
21370
|
-
await
|
|
21743
|
+
await fsp3.mkdir(path6.dirname(destPath), { recursive: true });
|
|
21744
|
+
await fsp3.writeFile(destPath, Buffer.from(blobData, "base64"));
|
|
21371
21745
|
}
|
|
21372
21746
|
const localRev = await this.hashLocalCategories(cfg.categories);
|
|
21373
21747
|
const syncState = {
|
|
@@ -21376,7 +21750,7 @@ var CloudSync = class {
|
|
|
21376
21750
|
lastSyncedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21377
21751
|
localRev
|
|
21378
21752
|
};
|
|
21379
|
-
await
|
|
21753
|
+
await fsp3.writeFile(this.statePath, JSON.stringify(syncState, null, 2), "utf8");
|
|
21380
21754
|
this.state = syncState;
|
|
21381
21755
|
return {
|
|
21382
21756
|
ok: true,
|
|
@@ -21395,7 +21769,7 @@ var CloudSync = class {
|
|
|
21395
21769
|
}
|
|
21396
21770
|
async loadState() {
|
|
21397
21771
|
try {
|
|
21398
|
-
const raw = await
|
|
21772
|
+
const raw = await fsp3.readFile(this.statePath, "utf8");
|
|
21399
21773
|
this.state = JSON.parse(raw);
|
|
21400
21774
|
} catch {
|
|
21401
21775
|
this.state = null;
|
|
@@ -21466,17 +21840,17 @@ var CloudSync = class {
|
|
|
21466
21840
|
const localPath = this.categoryToPath(cat);
|
|
21467
21841
|
if (!localPath) continue;
|
|
21468
21842
|
try {
|
|
21469
|
-
const
|
|
21470
|
-
if (
|
|
21843
|
+
const stat10 = await fsp3.stat(localPath);
|
|
21844
|
+
if (stat10.isDirectory()) {
|
|
21471
21845
|
const files = await this.walkDir(localPath, localPath);
|
|
21472
21846
|
for (const file of files) {
|
|
21473
|
-
const content = await
|
|
21847
|
+
const content = await fsp3.readFile(file, "utf8");
|
|
21474
21848
|
const rel = path6.relative(localPath, file).replace(/\\/g, "/");
|
|
21475
21849
|
entries.push({ path: `data/${cat}/${rel}`, content, mode: "100644" });
|
|
21476
21850
|
hashes.push(content);
|
|
21477
21851
|
}
|
|
21478
21852
|
} else {
|
|
21479
|
-
const content = await
|
|
21853
|
+
const content = await fsp3.readFile(localPath, "utf8");
|
|
21480
21854
|
entries.push({ path: `data/${cat}`, content, mode: "100644" });
|
|
21481
21855
|
hashes.push(content);
|
|
21482
21856
|
}
|
|
@@ -21492,15 +21866,15 @@ var CloudSync = class {
|
|
|
21492
21866
|
const localPath = this.categoryToPath(cat);
|
|
21493
21867
|
if (!localPath) continue;
|
|
21494
21868
|
try {
|
|
21495
|
-
const
|
|
21496
|
-
if (
|
|
21869
|
+
const stat10 = await fsp3.stat(localPath);
|
|
21870
|
+
if (stat10.isDirectory()) {
|
|
21497
21871
|
const files = await this.walkDir(localPath, localPath);
|
|
21498
21872
|
for (const file of files) {
|
|
21499
|
-
const content = await
|
|
21873
|
+
const content = await fsp3.readFile(file);
|
|
21500
21874
|
hashes.push(content.toString("base64") + file);
|
|
21501
21875
|
}
|
|
21502
21876
|
} else {
|
|
21503
|
-
const content = await
|
|
21877
|
+
const content = await fsp3.readFile(localPath);
|
|
21504
21878
|
hashes.push(content.toString("base64") + localPath);
|
|
21505
21879
|
}
|
|
21506
21880
|
} catch {
|
|
@@ -21526,7 +21900,7 @@ var CloudSync = class {
|
|
|
21526
21900
|
}
|
|
21527
21901
|
async walkDir(dir, base) {
|
|
21528
21902
|
const results = [];
|
|
21529
|
-
const entries = await
|
|
21903
|
+
const entries = await fsp3.readdir(dir, { withFileTypes: true });
|
|
21530
21904
|
for (const entry of entries) {
|
|
21531
21905
|
const full = path6.join(dir, entry.name);
|
|
21532
21906
|
if (entry.isDirectory()) {
|
|
@@ -22701,7 +23075,7 @@ var SecurityScannerOrchestrator = class {
|
|
|
22701
23075
|
const delay = Math.round(policy.delayMs(attempt));
|
|
22702
23076
|
const status = isProviderErr ? err.status : 0;
|
|
22703
23077
|
console.warn(`[SecurityScanner] retry ${attempt + 1} after ${delay}ms (status=${status}) \u2014 ${errAsErr.message}`);
|
|
22704
|
-
await new Promise((
|
|
23078
|
+
await new Promise((resolve10) => setTimeout(resolve10, delay));
|
|
22705
23079
|
return this.completeWithRetry(provider, request, abortController, attempt + 1);
|
|
22706
23080
|
}
|
|
22707
23081
|
}
|
|
@@ -23626,7 +24000,7 @@ var FleetManager = class {
|
|
|
23626
24000
|
})),
|
|
23627
24001
|
usage: this.usage.snapshot()
|
|
23628
24002
|
};
|
|
23629
|
-
await
|
|
24003
|
+
await fsp3.mkdir(path6.dirname(this.manifestPath), { recursive: true });
|
|
23630
24004
|
await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
|
|
23631
24005
|
return this.manifestPath;
|
|
23632
24006
|
}
|
|
@@ -23736,6 +24110,23 @@ var FleetManager = class {
|
|
|
23736
24110
|
}));
|
|
23737
24111
|
return { pending, live: [] };
|
|
23738
24112
|
}
|
|
24113
|
+
/**
|
|
24114
|
+
* Clean up all fleet-manager state associated with a removed subagent:
|
|
24115
|
+
* - Frees the nickname slot so the same name can be reused
|
|
24116
|
+
* - Removes any pending tasks for this subagent
|
|
24117
|
+
*/
|
|
24118
|
+
removeSubagent(subagentId) {
|
|
24119
|
+
const entry = this.manifestEntries.get(subagentId);
|
|
24120
|
+
if (entry?.name) {
|
|
24121
|
+
const nicknameKey = entry.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
24122
|
+
this._usedNicknames.delete(nicknameKey);
|
|
24123
|
+
}
|
|
24124
|
+
for (const [taskId, task] of this.pendingTasks) {
|
|
24125
|
+
if (task.subagentId === subagentId) {
|
|
24126
|
+
this.pendingTasks.delete(taskId);
|
|
24127
|
+
}
|
|
24128
|
+
}
|
|
24129
|
+
}
|
|
23739
24130
|
/** Release all resources: clear the manifest debounce timer and dispose the usage aggregator. */
|
|
23740
24131
|
dispose() {
|
|
23741
24132
|
if (this.manifestTimer) {
|
|
@@ -23923,7 +24314,7 @@ async function runRestart(name, deps) {
|
|
|
23923
24314
|
}
|
|
23924
24315
|
async function readConfig(p) {
|
|
23925
24316
|
try {
|
|
23926
|
-
return JSON.parse(await
|
|
24317
|
+
return JSON.parse(await fsp3.readFile(p, "utf8"));
|
|
23927
24318
|
} catch {
|
|
23928
24319
|
return {};
|
|
23929
24320
|
}
|
|
@@ -23931,8 +24322,8 @@ async function readConfig(p) {
|
|
|
23931
24322
|
async function writeConfig(p, cfg) {
|
|
23932
24323
|
const raw = JSON.stringify(cfg, null, 2);
|
|
23933
24324
|
const tmp = p + ".tmp";
|
|
23934
|
-
await
|
|
23935
|
-
await
|
|
24325
|
+
await fsp3.writeFile(tmp, raw, "utf8");
|
|
24326
|
+
await fsp3.rename(tmp, p);
|
|
23936
24327
|
}
|
|
23937
24328
|
function bold(s) {
|
|
23938
24329
|
return `\x1B[1m${s}\x1B[0m`;
|
|
@@ -24255,12 +24646,12 @@ function makeContinueToNextIterationTool() {
|
|
|
24255
24646
|
// src/core/iteration-limit.ts
|
|
24256
24647
|
function requestLimitExtension(opts) {
|
|
24257
24648
|
const { events, currentIterations, currentLimit, autoExtend, timeoutMs = 3e4 } = opts;
|
|
24258
|
-
return new Promise((
|
|
24649
|
+
return new Promise((resolve10) => {
|
|
24259
24650
|
let resolved = false;
|
|
24260
24651
|
const timerFired = () => {
|
|
24261
24652
|
if (!resolved) {
|
|
24262
24653
|
resolved = true;
|
|
24263
|
-
|
|
24654
|
+
resolve10(0);
|
|
24264
24655
|
}
|
|
24265
24656
|
};
|
|
24266
24657
|
const timer = setTimeout(timerFired, timeoutMs);
|
|
@@ -24269,14 +24660,14 @@ function requestLimitExtension(opts) {
|
|
|
24269
24660
|
if (!resolved) {
|
|
24270
24661
|
resolved = true;
|
|
24271
24662
|
clearTimeout(timer);
|
|
24272
|
-
|
|
24663
|
+
resolve10(0);
|
|
24273
24664
|
}
|
|
24274
24665
|
};
|
|
24275
24666
|
const grant = (extra) => {
|
|
24276
24667
|
if (!resolved) {
|
|
24277
24668
|
resolved = true;
|
|
24278
24669
|
clearTimeout(timer);
|
|
24279
|
-
|
|
24670
|
+
resolve10(Math.max(0, extra));
|
|
24280
24671
|
}
|
|
24281
24672
|
};
|
|
24282
24673
|
events.emit("iteration.limit_reached", {
|
|
@@ -24290,7 +24681,7 @@ function requestLimitExtension(opts) {
|
|
|
24290
24681
|
if (!resolved) {
|
|
24291
24682
|
resolved = true;
|
|
24292
24683
|
clearTimeout(timer);
|
|
24293
|
-
|
|
24684
|
+
resolve10(100);
|
|
24294
24685
|
}
|
|
24295
24686
|
});
|
|
24296
24687
|
}
|
|
@@ -24526,6 +24917,8 @@ var Agent = class {
|
|
|
24526
24917
|
let res;
|
|
24527
24918
|
try {
|
|
24528
24919
|
res = await customRunner(this.ctx, req);
|
|
24920
|
+
const calibratedEstimate = estimateRequestTokensCalibrated(req.messages, req.system, req.tools ?? []).total;
|
|
24921
|
+
recordActualUsage(res.usage.input, calibratedEstimate);
|
|
24529
24922
|
recoveryRetries = 0;
|
|
24530
24923
|
} catch (err) {
|
|
24531
24924
|
if (controller.signal.aborted) {
|
|
@@ -24880,13 +25273,13 @@ var Agent = class {
|
|
|
24880
25273
|
}
|
|
24881
25274
|
}
|
|
24882
25275
|
waitForConfirm(info) {
|
|
24883
|
-
return new Promise((
|
|
25276
|
+
return new Promise((resolve10) => {
|
|
24884
25277
|
this.events.emit("tool.confirm_needed", {
|
|
24885
25278
|
tool: info.tool,
|
|
24886
25279
|
input: info.input,
|
|
24887
25280
|
toolUseId: info.toolUseId,
|
|
24888
25281
|
suggestedPattern: info.suggestedPattern,
|
|
24889
|
-
resolve:
|
|
25282
|
+
resolve: resolve10
|
|
24890
25283
|
});
|
|
24891
25284
|
});
|
|
24892
25285
|
}
|
|
@@ -25425,7 +25818,7 @@ var DefaultSystemPromptBuilder = class {
|
|
|
25425
25818
|
if (!planPath) return "";
|
|
25426
25819
|
let raw;
|
|
25427
25820
|
try {
|
|
25428
|
-
raw = await
|
|
25821
|
+
raw = await fsp3.readFile(planPath, "utf8");
|
|
25429
25822
|
} catch {
|
|
25430
25823
|
return "";
|
|
25431
25824
|
}
|
|
@@ -25653,19 +26046,19 @@ ${mem}`);
|
|
|
25653
26046
|
}
|
|
25654
26047
|
async dirExists(p) {
|
|
25655
26048
|
try {
|
|
25656
|
-
const
|
|
25657
|
-
return
|
|
26049
|
+
const stat10 = await fsp3.stat(p);
|
|
26050
|
+
return stat10.isDirectory();
|
|
25658
26051
|
} catch {
|
|
25659
26052
|
return false;
|
|
25660
26053
|
}
|
|
25661
26054
|
}
|
|
25662
26055
|
async gitStatus(root) {
|
|
25663
|
-
return new Promise((
|
|
26056
|
+
return new Promise((resolve10) => {
|
|
25664
26057
|
let settled = false;
|
|
25665
26058
|
const finish = (s) => {
|
|
25666
26059
|
if (settled) return;
|
|
25667
26060
|
settled = true;
|
|
25668
|
-
|
|
26061
|
+
resolve10(s);
|
|
25669
26062
|
};
|
|
25670
26063
|
let proc;
|
|
25671
26064
|
const timer = setTimeout(() => {
|
|
@@ -25720,7 +26113,7 @@ ${mem}`);
|
|
|
25720
26113
|
const hits = await Promise.all(
|
|
25721
26114
|
checks.map(async ([marker, lang]) => {
|
|
25722
26115
|
try {
|
|
25723
|
-
await
|
|
26116
|
+
await fsp3.access(path6.join(root, marker));
|
|
25724
26117
|
return lang;
|
|
25725
26118
|
} catch {
|
|
25726
26119
|
return null;
|
|
@@ -27069,7 +27462,7 @@ var PhaseOrchestrator = class {
|
|
|
27069
27462
|
};
|
|
27070
27463
|
}
|
|
27071
27464
|
delay(ms) {
|
|
27072
|
-
return new Promise((
|
|
27465
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
27073
27466
|
}
|
|
27074
27467
|
};
|
|
27075
27468
|
|
|
@@ -27388,14 +27781,14 @@ var PhaseStore = class {
|
|
|
27388
27781
|
}
|
|
27389
27782
|
async save(graph) {
|
|
27390
27783
|
const filePath = this.getFilePath(graph.id);
|
|
27391
|
-
await
|
|
27784
|
+
await fsp3.mkdir(path6.dirname(filePath), { recursive: true });
|
|
27392
27785
|
const serialized = this.serializeGraph(graph);
|
|
27393
|
-
await
|
|
27786
|
+
await fsp3.writeFile(filePath, JSON.stringify(serialized, null, 2), "utf8");
|
|
27394
27787
|
}
|
|
27395
27788
|
async load(graphId) {
|
|
27396
27789
|
const filePath = this.getFilePath(graphId);
|
|
27397
27790
|
try {
|
|
27398
|
-
const raw = await
|
|
27791
|
+
const raw = await fsp3.readFile(filePath, "utf8");
|
|
27399
27792
|
const serialized = JSON.parse(raw);
|
|
27400
27793
|
return this.deserializeGraph(serialized);
|
|
27401
27794
|
} catch {
|
|
@@ -27405,18 +27798,18 @@ var PhaseStore = class {
|
|
|
27405
27798
|
async delete(graphId) {
|
|
27406
27799
|
const filePath = this.getFilePath(graphId);
|
|
27407
27800
|
try {
|
|
27408
|
-
await
|
|
27801
|
+
await fsp3.unlink(filePath);
|
|
27409
27802
|
} catch {
|
|
27410
27803
|
}
|
|
27411
27804
|
}
|
|
27412
27805
|
async list() {
|
|
27413
27806
|
try {
|
|
27414
|
-
const entries = await
|
|
27807
|
+
const entries = await fsp3.readdir(this.baseDir, { withFileTypes: true });
|
|
27415
27808
|
const graphs = [];
|
|
27416
27809
|
for (const entry of entries) {
|
|
27417
27810
|
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
27418
27811
|
try {
|
|
27419
|
-
const raw = await
|
|
27812
|
+
const raw = await fsp3.readFile(path6.join(this.baseDir, entry.name), "utf8");
|
|
27420
27813
|
const serialized = JSON.parse(raw);
|
|
27421
27814
|
const done = serialized.completedPhaseIds.length;
|
|
27422
27815
|
const total = serialized.phases.length;
|
|
@@ -27562,7 +27955,7 @@ var CheckpointManager = class {
|
|
|
27562
27955
|
this.baseDir = opts.baseDir ?? path6.join(opts.store.baseDir, ".checkpoints");
|
|
27563
27956
|
}
|
|
27564
27957
|
async initialize() {
|
|
27565
|
-
await
|
|
27958
|
+
await fsp3.mkdir(this.baseDir, { recursive: true });
|
|
27566
27959
|
await this.loadFromDisk();
|
|
27567
27960
|
}
|
|
27568
27961
|
async saveCheckpoint(graph, label) {
|
|
@@ -27625,14 +28018,14 @@ var CheckpointManager = class {
|
|
|
27625
28018
|
return true;
|
|
27626
28019
|
}
|
|
27627
28020
|
async saveToDisk(checkpoint) {
|
|
27628
|
-
await
|
|
28021
|
+
await fsp3.mkdir(this.baseDir, { recursive: true });
|
|
27629
28022
|
const filePath = path6.join(this.baseDir, `${checkpoint.graphId}.json`);
|
|
27630
28023
|
const serialized = {
|
|
27631
28024
|
...checkpoint
|
|
27632
28025
|
};
|
|
27633
28026
|
let existing = [];
|
|
27634
28027
|
try {
|
|
27635
|
-
const raw = await
|
|
28028
|
+
const raw = await fsp3.readFile(filePath, "utf8");
|
|
27636
28029
|
const parsed = JSON.parse(raw);
|
|
27637
28030
|
if (Array.isArray(parsed)) {
|
|
27638
28031
|
existing = parsed;
|
|
@@ -27640,12 +28033,12 @@ var CheckpointManager = class {
|
|
|
27640
28033
|
} catch {
|
|
27641
28034
|
}
|
|
27642
28035
|
existing.push(serialized);
|
|
27643
|
-
await
|
|
28036
|
+
await fsp3.writeFile(filePath, JSON.stringify(existing, null, 2), "utf8");
|
|
27644
28037
|
}
|
|
27645
28038
|
async deleteFromDisk(checkpointId) {
|
|
27646
28039
|
let entries;
|
|
27647
28040
|
try {
|
|
27648
|
-
entries = await
|
|
28041
|
+
entries = await fsp3.readdir(this.baseDir);
|
|
27649
28042
|
} catch {
|
|
27650
28043
|
return;
|
|
27651
28044
|
}
|
|
@@ -27653,16 +28046,16 @@ var CheckpointManager = class {
|
|
|
27653
28046
|
if (!filename.endsWith(".json")) continue;
|
|
27654
28047
|
const filePath = path6.join(this.baseDir, filename);
|
|
27655
28048
|
try {
|
|
27656
|
-
const raw = await
|
|
28049
|
+
const raw = await fsp3.readFile(filePath, "utf8");
|
|
27657
28050
|
const parsed = JSON.parse(raw);
|
|
27658
28051
|
if (!Array.isArray(parsed)) continue;
|
|
27659
28052
|
const existing = parsed;
|
|
27660
28053
|
const filtered = existing.filter((c) => c.id !== checkpointId);
|
|
27661
28054
|
if (filtered.length !== existing.length) {
|
|
27662
28055
|
if (filtered.length === 0) {
|
|
27663
|
-
await
|
|
28056
|
+
await fsp3.unlink(filePath);
|
|
27664
28057
|
} else {
|
|
27665
|
-
await
|
|
28058
|
+
await fsp3.writeFile(filePath, JSON.stringify(filtered, null, 2), "utf8");
|
|
27666
28059
|
}
|
|
27667
28060
|
}
|
|
27668
28061
|
} catch {
|
|
@@ -27672,7 +28065,7 @@ var CheckpointManager = class {
|
|
|
27672
28065
|
async loadFromDisk() {
|
|
27673
28066
|
let entries;
|
|
27674
28067
|
try {
|
|
27675
|
-
entries = await
|
|
28068
|
+
entries = await fsp3.readdir(this.baseDir);
|
|
27676
28069
|
} catch {
|
|
27677
28070
|
return;
|
|
27678
28071
|
}
|
|
@@ -27680,7 +28073,7 @@ var CheckpointManager = class {
|
|
|
27680
28073
|
if (!filename.endsWith(".json")) continue;
|
|
27681
28074
|
const filePath = path6.join(this.baseDir, filename);
|
|
27682
28075
|
try {
|
|
27683
|
-
const raw = await
|
|
28076
|
+
const raw = await fsp3.readFile(filePath, "utf8");
|
|
27684
28077
|
const parsed = JSON.parse(raw);
|
|
27685
28078
|
if (!Array.isArray(parsed)) continue;
|
|
27686
28079
|
const checkpoints = parsed;
|
|
@@ -28029,8 +28422,8 @@ var CollaborationBus = class {
|
|
|
28029
28422
|
if (this.isPaused()) return false;
|
|
28030
28423
|
this.pausedAtMs = Date.now();
|
|
28031
28424
|
this.pausedBy = byParticipant;
|
|
28032
|
-
this.pausePromise = new Promise((
|
|
28033
|
-
this.pauseResolve =
|
|
28425
|
+
this.pausePromise = new Promise((resolve10) => {
|
|
28426
|
+
this.pauseResolve = resolve10;
|
|
28034
28427
|
});
|
|
28035
28428
|
return true;
|
|
28036
28429
|
}
|
|
@@ -28066,8 +28459,8 @@ var CollaborationBus = class {
|
|
|
28066
28459
|
return true;
|
|
28067
28460
|
}
|
|
28068
28461
|
let timer;
|
|
28069
|
-
const timeoutPromise = new Promise((
|
|
28070
|
-
timer = setTimeout(() =>
|
|
28462
|
+
const timeoutPromise = new Promise((resolve10) => {
|
|
28463
|
+
timer = setTimeout(() => resolve10("timeout"), timeoutMs);
|
|
28071
28464
|
});
|
|
28072
28465
|
const resumedPromise = this.pausePromise.then(() => "resumed");
|
|
28073
28466
|
const winner = await Promise.race([resumedPromise, timeoutPromise]);
|
|
@@ -28558,7 +28951,7 @@ function createGitPlugin() {
|
|
|
28558
28951
|
}
|
|
28559
28952
|
async function runGit(args, cwd) {
|
|
28560
28953
|
try {
|
|
28561
|
-
return await new Promise((
|
|
28954
|
+
return await new Promise((resolve10, reject) => {
|
|
28562
28955
|
const child = spawn("git", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
28563
28956
|
let stdout = "";
|
|
28564
28957
|
let stderr = "";
|
|
@@ -28579,7 +28972,7 @@ async function runGit(args, cwd) {
|
|
|
28579
28972
|
})
|
|
28580
28973
|
);
|
|
28581
28974
|
});
|
|
28582
|
-
child.on("close", (code) =>
|
|
28975
|
+
child.on("close", (code) => resolve10({ stdout, stderr, code: code ?? 0 }));
|
|
28583
28976
|
});
|
|
28584
28977
|
} catch (err) {
|
|
28585
28978
|
if (err instanceof WrongStackError) throw err;
|
|
@@ -29255,6 +29648,6 @@ ${formatPlan(updated)}`
|
|
|
29255
29648
|
};
|
|
29256
29649
|
}
|
|
29257
29650
|
|
|
29258
|
-
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, AISpecBuilder, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, ALL_SYNC_CATEGORIES, AUDIT_LOG_AGENT, Agent, AgentError, AnnotationsStore, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutoPhasePlanner, AutoPhaseRunner, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, CORE_RECONSTRUCT_EVENTS, CheckpointManager, CloudSync, CollaborationBus, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DEFAULT_TOOLS_CONFIG, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultPromptStore, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, ERROR_CODES, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, FsError, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, PhaseGraphBuilder, PhaseOrchestrator, PhaseStore, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReplayLogStore, ReplayProviderRunner, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, STANDARD_AUDIT_EVENTS, ScopedEventBus, SddParallelRun, SddTaskDecomposer, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SessionRecovery, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolAuditLog, ToolError, ToolExecutor, ToolRegistry, WorktreeManager, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, assertSafePath, atomicWrite, attachAutoExtend, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildBtwBlock, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, collabInjectMiddleware, collabPauseMiddleware, color, compileGlob, compileUserRegex, completePartialObject, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, consumeBtwNotes, context7Server, contextManagerTool, createAutoExecutor, createAutoPhaseFromTaskGraph, createContextManagerTool, createDefaultPipelines, createDelegateTool, createGitPlugin, createMcpControlTool, createMessage, createObservabilityPlugin, createPlanPlugin, createPromptsPlugin, createSecurityPlugin, createSecuritySlashCommand, createSessionEventBridge, createSkillsPlugin, createSyncPlugin, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, dispatchAgent, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatGoal, formatPlan, formatPlanTemplates, formatTodosList, getAgentDefinition, getContextWindowMode, getPlanTemplate, getTemplate, githubServer, goalFilePath, googleMapsServer, hashRequest, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAskTool, makeAssignTool, makeAutonomyPromptContributor, makeAwaitTasksTool, makeCollabDebugTool, makeContinueToNextIterationTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, matchAny, matchGlob, mergeModelsPayload, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, parseContinueDirective, parseSkillRef, pendingBtwCount, projectHash, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resolveAuditLevel, resolveContextWindowPolicy, resolveSessionLoggingConfig, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, runProviderWithRetry, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, scoreAgents, securitySlashCommand, sentinelServer, setBtwNote, setPlanItemStatus, slackServer, stableStringify, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
|
|
29651
|
+
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, AISpecBuilder, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, ALL_SYNC_CATEGORIES, AUDIT_LOG_AGENT, Agent, AgentError, AnnotationsStore, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutoPhasePlanner, AutoPhaseRunner, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, CORE_RECONSTRUCT_EVENTS, CheckpointManager, CloudSync, CollaborationBus, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DEFAULT_TOOLS_CONFIG, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultPromptStore, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, ERROR_CODES, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, FsError, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, PhaseGraphBuilder, PhaseOrchestrator, PhaseStore, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReplayLogStore, ReplayProviderRunner, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, STANDARD_AUDIT_EVENTS, ScopedEventBus, SddParallelRun, SddTaskDecomposer, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SessionRecovery, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolAuditLog, ToolError, ToolExecutor, ToolRegistry, WorktreeManager, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, assertSafePath, atomicWrite, attachAutoExtend, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildBtwBlock, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, collabInjectMiddleware, collabPauseMiddleware, color, compileGlob, compileUserRegex, completePartialObject, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, consumeBtwNotes, context7Server, contextManagerTool, createAutoExecutor, createAutoPhaseFromTaskGraph, createContextManagerTool, createDefaultPipelines, createDelegateTool, createGitPlugin, createMcpControlTool, createMessage, createObservabilityPlugin, createPlanPlugin, createPromptsPlugin, createSecurityPlugin, createSecuritySlashCommand, createSessionEventBridge, createSkillsPlugin, createSyncPlugin, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, dispatchAgent, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, expandGlob, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatGoal, formatPlan, formatPlanTemplates, formatTodosList, getAgentDefinition, getCalibrationState, getContextWindowMode, getPlanTemplate, getTemplate, githubServer, goalFilePath, googleMapsServer, hashRequest, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAskTool, makeAssignTool, makeAutonomyPromptContributor, makeAwaitTasksTool, makeCollabDebugTool, makeContinueToNextIterationTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, matchAny, matchGlob, mergeModelsPayload, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, parseContinueDirective, parseSkillRef, pendingBtwCount, projectHash, recordActualUsage, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resetCalibration, resolveAuditLevel, resolveContextWindowPolicy, resolveSessionLoggingConfig, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, runProviderWithRetry, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, scoreAgents, securitySlashCommand, sentinelServer, setBtwNote, setPlanItemStatus, slackServer, stableStringify, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
|
|
29259
29652
|
//# sourceMappingURL=index.js.map
|
|
29260
29653
|
//# sourceMappingURL=index.js.map
|