@kernlang/agon 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GLQ5IQ5X.js → chunk-52VTWOLH.js} +3 -3
- package/dist/{chunk-F72VMPTY.js → chunk-H7KZ34VX.js} +3 -3
- package/dist/{chunk-7PMMOQZ7.js → chunk-PFHGKBQT.js} +1063 -397
- package/dist/chunk-PFHGKBQT.js.map +1 -0
- package/dist/{chunk-IA4AR2R4.js → chunk-XOJPAFCJ.js} +46 -19
- package/dist/chunk-XOJPAFCJ.js.map +1 -0
- package/dist/engines/minimax-coding-plan-minimax-m3.json +27 -0
- package/dist/{forge-G274YAH7.js → forge-6NV4WCMB.js} +4 -4
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/{plan-mode-DCE7VGQV.js → plan-mode-OSU42TOI.js} +4 -4
- package/dist/{src-U2AWRNRL.js → src-4VOZ6GIN.js} +24 -2
- package/package.json +2 -2
- package/dist/chunk-7PMMOQZ7.js.map +0 -1
- package/dist/chunk-IA4AR2R4.js.map +0 -1
- /package/dist/{chunk-GLQ5IQ5X.js.map → chunk-52VTWOLH.js.map} +0 -0
- /package/dist/{chunk-F72VMPTY.js.map → chunk-H7KZ34VX.js.map} +0 -0
- /package/dist/{forge-G274YAH7.js.map → forge-6NV4WCMB.js.map} +0 -0
- /package/dist/{plan-mode-DCE7VGQV.js.map → plan-mode-OSU42TOI.js.map} +0 -0
- /package/dist/{src-U2AWRNRL.js.map → src-4VOZ6GIN.js.map} +0 -0
|
@@ -1703,7 +1703,7 @@ async function spawnWithTimeout(opts) {
|
|
|
1703
1703
|
if (opts.signal?.aborted) {
|
|
1704
1704
|
return { exitCode: 130, stdout: "", stderr: "Aborted", durationMs: 0, timedOut: false };
|
|
1705
1705
|
}
|
|
1706
|
-
return new Promise((
|
|
1706
|
+
return new Promise((resolve28) => {
|
|
1707
1707
|
const startTime = Date.now();
|
|
1708
1708
|
let timedOut = false;
|
|
1709
1709
|
let aborted2 = false;
|
|
@@ -1719,7 +1719,7 @@ async function spawnWithTimeout(opts) {
|
|
|
1719
1719
|
if (forceKillTimer) clearTimeout(forceKillTimer);
|
|
1720
1720
|
if (forceFinishTimer) clearTimeout(forceFinishTimer);
|
|
1721
1721
|
if (opts.signal) opts.signal.removeEventListener("abort", onAbort);
|
|
1722
|
-
|
|
1722
|
+
resolve28(result);
|
|
1723
1723
|
}
|
|
1724
1724
|
const child = spawn(opts.command, opts.args, {
|
|
1725
1725
|
cwd: opts.cwd,
|
|
@@ -16551,20 +16551,235 @@ ${result}
|
|
|
16551
16551
|
return result;
|
|
16552
16552
|
}
|
|
16553
16553
|
|
|
16554
|
+
// ../core/src/generated/blocks/codebase-map.ts
|
|
16555
|
+
import { readFileSync as readFileSync9, readdirSync as readdirSync7, statSync as statSync7, lstatSync as lstatSync2, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync7, rmSync as rmSync4 } from "fs";
|
|
16556
|
+
import { join as join10, relative as relative2 } from "path";
|
|
16557
|
+
import { createHash as createHash2 } from "crypto";
|
|
16558
|
+
var MAP_IGNORE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "dist-tsc", ".next", ".cache", ".turbo", "__pycache__", ".venv", "venv", "coverage", ".kern-gaps", ".agon", ".claude", "worktrees", "build", "out", ".idea", ".vscode"]);
|
|
16559
|
+
var MAP_SOURCE_EXT = [".kern", ".ts", ".tsx", ".py", ".js", ".jsx"];
|
|
16560
|
+
var MAP_MAX_FILES_WALKED = 6e3;
|
|
16561
|
+
var MAP_MAX_FILES_READ = 600;
|
|
16562
|
+
var MAP_MAX_FILE_BYTES = 262144;
|
|
16563
|
+
var MAP_MEMO = /* @__PURE__ */ new Map();
|
|
16564
|
+
var MAP_LOCKFILES = ["package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb"];
|
|
16565
|
+
var MAP_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
16566
|
+
function mapSourceExt(path) {
|
|
16567
|
+
const dot = path.lastIndexOf(".");
|
|
16568
|
+
if (dot < 0) return null;
|
|
16569
|
+
const ext = path.slice(dot);
|
|
16570
|
+
return MAP_SOURCE_EXT.includes(ext) ? ext : null;
|
|
16571
|
+
}
|
|
16572
|
+
function collectSourceFiles(root) {
|
|
16573
|
+
const out = [];
|
|
16574
|
+
const stack = [root];
|
|
16575
|
+
while (stack.length > 0 && out.length < MAP_MAX_FILES_WALKED) {
|
|
16576
|
+
const dir = stack.pop();
|
|
16577
|
+
let entries;
|
|
16578
|
+
try {
|
|
16579
|
+
entries = readdirSync7(dir);
|
|
16580
|
+
} catch {
|
|
16581
|
+
continue;
|
|
16582
|
+
}
|
|
16583
|
+
for (const entry of entries) {
|
|
16584
|
+
if (entry.startsWith(".DS_")) continue;
|
|
16585
|
+
const full = join10(dir, entry);
|
|
16586
|
+
let st;
|
|
16587
|
+
try {
|
|
16588
|
+
st = lstatSync2(full);
|
|
16589
|
+
} catch {
|
|
16590
|
+
continue;
|
|
16591
|
+
}
|
|
16592
|
+
if (st.isSymbolicLink()) continue;
|
|
16593
|
+
if (st.isDirectory()) {
|
|
16594
|
+
if (!MAP_IGNORE_DIRS.has(entry)) stack.push(full);
|
|
16595
|
+
continue;
|
|
16596
|
+
}
|
|
16597
|
+
if (mapSourceExt(entry)) out.push(relative2(root, full));
|
|
16598
|
+
if (out.length >= MAP_MAX_FILES_WALKED) break;
|
|
16599
|
+
}
|
|
16600
|
+
}
|
|
16601
|
+
out.sort();
|
|
16602
|
+
return out;
|
|
16603
|
+
}
|
|
16604
|
+
function extractSymbols(relPath, content) {
|
|
16605
|
+
const ext = mapSourceExt(relPath);
|
|
16606
|
+
const names = [];
|
|
16607
|
+
const push = (n) => {
|
|
16608
|
+
if (n && !names.includes(n)) names.push(n);
|
|
16609
|
+
};
|
|
16610
|
+
if (ext === ".kern") {
|
|
16611
|
+
const re = /\b(?:fn|service|union|interface|const|screen|machine|event|type)\s+name=([A-Za-z0-9_$]+)/g;
|
|
16612
|
+
let m;
|
|
16613
|
+
while ((m = re.exec(content)) !== null) push(m[1]);
|
|
16614
|
+
} else if (ext === ".py") {
|
|
16615
|
+
const re = /^\s*(?:async\s+)?(?:def|class)\s+([A-Za-z0-9_]+)/gm;
|
|
16616
|
+
let m;
|
|
16617
|
+
while ((m = re.exec(content)) !== null) push(m[1]);
|
|
16618
|
+
} else {
|
|
16619
|
+
const re = /^\s*export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|var|class|interface|type|enum)\s+([A-Za-z0-9_$]+)/gm;
|
|
16620
|
+
let m;
|
|
16621
|
+
while ((m = re.exec(content)) !== null) push(m[1]);
|
|
16622
|
+
}
|
|
16623
|
+
return names.slice(0, 12);
|
|
16624
|
+
}
|
|
16625
|
+
function topLevelGroup(relPath) {
|
|
16626
|
+
const parts = relPath.split("/");
|
|
16627
|
+
if (parts[0] === "packages" && parts.length > 1) return `packages/${parts[1]}`;
|
|
16628
|
+
if (parts.length > 1) return parts[0];
|
|
16629
|
+
return "(root)";
|
|
16630
|
+
}
|
|
16631
|
+
function mapCacheDir() {
|
|
16632
|
+
return agonPath("cache", "codebase-map");
|
|
16633
|
+
}
|
|
16634
|
+
function mapCacheKey(cwd) {
|
|
16635
|
+
return createHash2("sha1").update(cwd).digest("hex").slice(0, 16);
|
|
16636
|
+
}
|
|
16637
|
+
function mapCacheFile(cwd) {
|
|
16638
|
+
return join10(mapCacheDir(), `${mapCacheKey(cwd)}.json`);
|
|
16639
|
+
}
|
|
16640
|
+
function mapCacheSignature(cwd) {
|
|
16641
|
+
let head = "nogit";
|
|
16642
|
+
try {
|
|
16643
|
+
head = headSha(cwd);
|
|
16644
|
+
} catch {
|
|
16645
|
+
}
|
|
16646
|
+
let lockMtime = "0";
|
|
16647
|
+
for (const lf of MAP_LOCKFILES) {
|
|
16648
|
+
try {
|
|
16649
|
+
lockMtime = String(Math.round(statSync7(join10(cwd, lf)).mtimeMs));
|
|
16650
|
+
break;
|
|
16651
|
+
} catch {
|
|
16652
|
+
}
|
|
16653
|
+
}
|
|
16654
|
+
return `${head}:${lockMtime}`;
|
|
16655
|
+
}
|
|
16656
|
+
function readMapDiskCache(cwd, sig) {
|
|
16657
|
+
try {
|
|
16658
|
+
const path = mapCacheFile(cwd);
|
|
16659
|
+
if (!existsSync7(path)) return null;
|
|
16660
|
+
const raw = JSON.parse(readFileSync9(path, "utf-8"));
|
|
16661
|
+
if (raw.sig !== sig) return null;
|
|
16662
|
+
if (typeof raw.builtAt === "number" && Date.now() - raw.builtAt > MAP_CACHE_TTL_MS) return null;
|
|
16663
|
+
return typeof raw.brief === "string" ? raw.brief : null;
|
|
16664
|
+
} catch {
|
|
16665
|
+
return null;
|
|
16666
|
+
}
|
|
16667
|
+
}
|
|
16668
|
+
function writeMapDiskCache(cwd, sig, brief) {
|
|
16669
|
+
try {
|
|
16670
|
+
mkdirSync7(mapCacheDir(), { recursive: true });
|
|
16671
|
+
writeFileSync7(mapCacheFile(cwd), JSON.stringify({ sig, brief, builtAt: Date.now() }));
|
|
16672
|
+
} catch {
|
|
16673
|
+
}
|
|
16674
|
+
}
|
|
16675
|
+
function composeBrief(cwd, cap) {
|
|
16676
|
+
const files = collectSourceFiles(cwd);
|
|
16677
|
+
if (files.length === 0) return "";
|
|
16678
|
+
const generatedCount = files.filter((f) => f.includes("/generated/")).length;
|
|
16679
|
+
const kernCount = files.filter((f) => f.endsWith(".kern")).length;
|
|
16680
|
+
const groups = /* @__PURE__ */ new Map();
|
|
16681
|
+
for (const f of files) {
|
|
16682
|
+
const g = topLevelGroup(f);
|
|
16683
|
+
const arr = groups.get(g) ?? [];
|
|
16684
|
+
arr.push(f);
|
|
16685
|
+
groups.set(g, arr);
|
|
16686
|
+
}
|
|
16687
|
+
let filesRead = 0;
|
|
16688
|
+
const lines = [];
|
|
16689
|
+
let totalLen = 0;
|
|
16690
|
+
const addLine = (s) => {
|
|
16691
|
+
lines.push(s);
|
|
16692
|
+
totalLen += s.length + 1;
|
|
16693
|
+
};
|
|
16694
|
+
addLine("## CODEBASE BRIEF (where things live \u2014 prefer this over searching)");
|
|
16695
|
+
if (kernCount > 0 && generatedCount > 0) {
|
|
16696
|
+
addLine(`KERN project: ${kernCount} .kern sources compile to generated/ TS mirrors \u2014 EDIT THE .kern, not generated/.`);
|
|
16697
|
+
}
|
|
16698
|
+
const groupNames = Array.from(groups.keys()).sort();
|
|
16699
|
+
const perGroupBudget = Math.min(cap, Math.max(300, Math.floor(cap / Math.max(1, groupNames.length))));
|
|
16700
|
+
for (const g of groupNames) {
|
|
16701
|
+
if (totalLen > cap) break;
|
|
16702
|
+
const groupFiles = (groups.get(g) ?? []).filter((f) => !f.includes("/generated/"));
|
|
16703
|
+
if (groupFiles.length === 0) continue;
|
|
16704
|
+
groupFiles.sort((a, b) => {
|
|
16705
|
+
const ak = a.endsWith(".kern") ? 0 : 1;
|
|
16706
|
+
const bk = b.endsWith(".kern") ? 0 : 1;
|
|
16707
|
+
if (ak !== bk) return ak - bk;
|
|
16708
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
16709
|
+
});
|
|
16710
|
+
const groupStart = totalLen;
|
|
16711
|
+
addLine(`
|
|
16712
|
+
### ${g} (${groupFiles.length} files)`);
|
|
16713
|
+
let shown = 0;
|
|
16714
|
+
for (const f of groupFiles.slice(0, 12)) {
|
|
16715
|
+
if (totalLen > cap) break;
|
|
16716
|
+
if (shown > 0 && totalLen - groupStart > perGroupBudget) break;
|
|
16717
|
+
let syms = [];
|
|
16718
|
+
if (filesRead < MAP_MAX_FILES_READ) {
|
|
16719
|
+
try {
|
|
16720
|
+
const st = statSync7(join10(cwd, f));
|
|
16721
|
+
if (st.size <= MAP_MAX_FILE_BYTES) {
|
|
16722
|
+
syms = extractSymbols(f, readFileSync9(join10(cwd, f), "utf-8"));
|
|
16723
|
+
filesRead++;
|
|
16724
|
+
}
|
|
16725
|
+
} catch {
|
|
16726
|
+
}
|
|
16727
|
+
}
|
|
16728
|
+
addLine(syms.length > 0 ? `- ${f}: ${syms.join(", ")}` : `- ${f}`);
|
|
16729
|
+
shown++;
|
|
16730
|
+
}
|
|
16731
|
+
const extra = groupFiles.length - shown;
|
|
16732
|
+
if (extra > 0) addLine(` (+${extra} more files in ${g})`);
|
|
16733
|
+
}
|
|
16734
|
+
let brief = lines.join("\n");
|
|
16735
|
+
if (brief.length > cap) brief = brief.slice(0, cap) + "\n... (brief truncated)";
|
|
16736
|
+
return brief;
|
|
16737
|
+
}
|
|
16738
|
+
function buildCodebaseMap(cwd, maxChars) {
|
|
16739
|
+
if (maxChars !== void 0) return composeBrief(cwd, Math.max(1, maxChars));
|
|
16740
|
+
const sig = mapCacheSignature(cwd);
|
|
16741
|
+
const cached2 = MAP_MEMO.get(cwd);
|
|
16742
|
+
if (cached2 !== void 0 && cached2.sig === sig) return cached2.brief;
|
|
16743
|
+
const fromDisk = readMapDiskCache(cwd, sig);
|
|
16744
|
+
if (fromDisk !== null) {
|
|
16745
|
+
MAP_MEMO.set(cwd, { sig, brief: fromDisk });
|
|
16746
|
+
return fromDisk;
|
|
16747
|
+
}
|
|
16748
|
+
const brief = composeBrief(cwd, 3500);
|
|
16749
|
+
writeMapDiskCache(cwd, sig, brief);
|
|
16750
|
+
MAP_MEMO.set(cwd, { sig, brief });
|
|
16751
|
+
return brief;
|
|
16752
|
+
}
|
|
16753
|
+
function clearCodebaseMapCache(cwd) {
|
|
16754
|
+
if (cwd) {
|
|
16755
|
+
MAP_MEMO.delete(cwd);
|
|
16756
|
+
try {
|
|
16757
|
+
rmSync4(mapCacheFile(cwd), { force: true });
|
|
16758
|
+
} catch {
|
|
16759
|
+
}
|
|
16760
|
+
} else {
|
|
16761
|
+
MAP_MEMO.clear();
|
|
16762
|
+
try {
|
|
16763
|
+
rmSync4(mapCacheDir(), { recursive: true, force: true });
|
|
16764
|
+
} catch {
|
|
16765
|
+
}
|
|
16766
|
+
}
|
|
16767
|
+
}
|
|
16768
|
+
|
|
16554
16769
|
// ../core/src/generated/blocks/workspace.ts
|
|
16555
|
-
import { readFileSync as
|
|
16556
|
-
import { join as
|
|
16770
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync8, renameSync as renameSync6 } from "fs";
|
|
16771
|
+
import { join as join11, resolve as resolve5, basename as basename2 } from "path";
|
|
16557
16772
|
import { homedir as homedir4 } from "os";
|
|
16558
16773
|
function getWorkspacesPath() {
|
|
16559
16774
|
const override = process.env.AGON_HOME?.trim();
|
|
16560
|
-
const home = override ? resolve5(override) :
|
|
16561
|
-
return
|
|
16775
|
+
const home = override ? resolve5(override) : join11(homedir4(), ".agon");
|
|
16776
|
+
return join11(home, "workspaces.json");
|
|
16562
16777
|
}
|
|
16563
16778
|
function loadState() {
|
|
16564
16779
|
const WORKSPACES_PATH = getWorkspacesPath();
|
|
16565
16780
|
ensureAgonHome();
|
|
16566
16781
|
try {
|
|
16567
|
-
return JSON.parse(
|
|
16782
|
+
return JSON.parse(readFileSync10(WORKSPACES_PATH, "utf-8"));
|
|
16568
16783
|
} catch (err) {
|
|
16569
16784
|
if (err.code !== "ENOENT") {
|
|
16570
16785
|
console.warn(`[agon] workspace state corrupted, resetting to defaults: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -16575,7 +16790,7 @@ function loadState() {
|
|
|
16575
16790
|
function saveState(state) {
|
|
16576
16791
|
const WORKSPACES_PATH = getWorkspacesPath();
|
|
16577
16792
|
const tmpPath = WORKSPACES_PATH + ".tmp";
|
|
16578
|
-
|
|
16793
|
+
writeFileSync8(tmpPath, JSON.stringify(state, null, 2) + "\n");
|
|
16579
16794
|
renameSync6(tmpPath, WORKSPACES_PATH);
|
|
16580
16795
|
}
|
|
16581
16796
|
function addWorkspace(rawPath) {
|
|
@@ -16862,17 +17077,17 @@ function resetStepForRetry(plan, stepId) {
|
|
|
16862
17077
|
}
|
|
16863
17078
|
|
|
16864
17079
|
// ../core/src/generated/signals/plan-store.ts
|
|
16865
|
-
import { readFileSync as
|
|
16866
|
-
import { join as
|
|
17080
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync9, mkdirSync as mkdirSync8, readdirSync as readdirSync8, unlinkSync as unlinkSync3, renameSync as renameSync7 } from "fs";
|
|
17081
|
+
import { join as join12, resolve as resolve6 } from "path";
|
|
16867
17082
|
import { homedir as homedir5 } from "os";
|
|
16868
17083
|
function getPlansDir() {
|
|
16869
17084
|
const override = process.env.AGON_HOME?.trim();
|
|
16870
|
-
const home = override ? resolve6(override) :
|
|
16871
|
-
return
|
|
17085
|
+
const home = override ? resolve6(override) : join12(homedir5(), ".agon");
|
|
17086
|
+
return join12(home, "plans");
|
|
16872
17087
|
}
|
|
16873
17088
|
function ensurePlansDir() {
|
|
16874
17089
|
ensureAgonHome();
|
|
16875
|
-
|
|
17090
|
+
mkdirSync8(getPlansDir(), { recursive: true });
|
|
16876
17091
|
}
|
|
16877
17092
|
function safePlanPath(id) {
|
|
16878
17093
|
const sanitized = id.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
@@ -16887,12 +17102,12 @@ function savePlan(plan) {
|
|
|
16887
17102
|
ensurePlansDir();
|
|
16888
17103
|
const target = safePlanPath(plan.id);
|
|
16889
17104
|
const tmpPath = target + ".tmp";
|
|
16890
|
-
|
|
17105
|
+
writeFileSync9(tmpPath, JSON.stringify(plan, null, 2) + "\n");
|
|
16891
17106
|
renameSync7(tmpPath, target);
|
|
16892
17107
|
}
|
|
16893
17108
|
function loadPlan(id) {
|
|
16894
17109
|
try {
|
|
16895
|
-
return JSON.parse(
|
|
17110
|
+
return JSON.parse(readFileSync11(safePlanPath(id), "utf-8"));
|
|
16896
17111
|
} catch (err) {
|
|
16897
17112
|
if (err.code !== "ENOENT") {
|
|
16898
17113
|
console.warn(`[agon] failed to load plan ${id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -16904,8 +17119,8 @@ function listPlans(limit) {
|
|
|
16904
17119
|
ensurePlansDir();
|
|
16905
17120
|
try {
|
|
16906
17121
|
const plansDir = getPlansDir();
|
|
16907
|
-
const files =
|
|
16908
|
-
return files.map((f) => JSON.parse(
|
|
17122
|
+
const files = readdirSync8(plansDir).filter((f) => f.endsWith(".json"));
|
|
17123
|
+
return files.map((f) => JSON.parse(readFileSync11(join12(plansDir, f), "utf-8"))).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)).slice(0, limit ?? 20);
|
|
16909
17124
|
} catch (err) {
|
|
16910
17125
|
console.warn(`[agon] failed to list plans: ${err instanceof Error ? err.message : String(err)}`);
|
|
16911
17126
|
return [];
|
|
@@ -16947,6 +17162,389 @@ function wordWrap(text, width) {
|
|
|
16947
17162
|
return result;
|
|
16948
17163
|
}
|
|
16949
17164
|
|
|
17165
|
+
// ../core/src/generated/blocks/stack-trace.ts
|
|
17166
|
+
import { existsSync as existsSync9, readFileSync as readFileSync12 } from "fs";
|
|
17167
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute2, normalize, resolve as resolve7 } from "path";
|
|
17168
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
17169
|
+
import { createRequire as createRequire2 } from "module";
|
|
17170
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
17171
|
+
function setBoundedCacheEntry(cache, key, value) {
|
|
17172
|
+
if (!cache || typeof cache.set !== "function") return;
|
|
17173
|
+
const limit = 256;
|
|
17174
|
+
if (cache.has(key)) {
|
|
17175
|
+
cache.delete(key);
|
|
17176
|
+
} else if (cache.size >= limit) {
|
|
17177
|
+
const oldest = cache.keys().next().value;
|
|
17178
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
17179
|
+
}
|
|
17180
|
+
cache.set(key, value);
|
|
17181
|
+
}
|
|
17182
|
+
function normalizeStackFilePath(rawPath) {
|
|
17183
|
+
let filePath = String(rawPath ?? "");
|
|
17184
|
+
if (!filePath) return "";
|
|
17185
|
+
if (filePath.startsWith("file://")) {
|
|
17186
|
+
try {
|
|
17187
|
+
filePath = fileURLToPath2(filePath);
|
|
17188
|
+
} catch {
|
|
17189
|
+
return normalize(filePath);
|
|
17190
|
+
}
|
|
17191
|
+
}
|
|
17192
|
+
return normalize(filePath);
|
|
17193
|
+
}
|
|
17194
|
+
function readTextFileCached(filePath) {
|
|
17195
|
+
const normalized = normalizeStackFilePath(filePath);
|
|
17196
|
+
if (!normalized) return null;
|
|
17197
|
+
const cache = stackTraceMapperState().sourceTextCache;
|
|
17198
|
+
if (cache.has(normalized)) return cache.get(normalized) ?? null;
|
|
17199
|
+
let content = null;
|
|
17200
|
+
try {
|
|
17201
|
+
if (existsSync9(normalized)) content = readFileSync12(normalized, "utf8");
|
|
17202
|
+
} catch {
|
|
17203
|
+
content = null;
|
|
17204
|
+
}
|
|
17205
|
+
if (content !== null) setBoundedCacheEntry(cache, normalized, content);
|
|
17206
|
+
return content;
|
|
17207
|
+
}
|
|
17208
|
+
function nodeModuleApi() {
|
|
17209
|
+
try {
|
|
17210
|
+
return createRequire2(import.meta.url)("node:module");
|
|
17211
|
+
} catch {
|
|
17212
|
+
return {};
|
|
17213
|
+
}
|
|
17214
|
+
}
|
|
17215
|
+
function sourceMappingUrlFromContent(content) {
|
|
17216
|
+
const text = String(content ?? "");
|
|
17217
|
+
const lineMatches = [...text.matchAll(/\/\/\s*[#@]\s*sourceMappingURL\s*=\s*([^\s]+)/g)];
|
|
17218
|
+
const blockMatches = [...text.matchAll(/\/\*\s*[#@]\s*sourceMappingURL\s*=\s*([\s\S]*?)\s*\*\//g)];
|
|
17219
|
+
const matches = [...lineMatches, ...blockMatches].sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
|
17220
|
+
const last = matches[matches.length - 1];
|
|
17221
|
+
return last?.[1]?.trim() || null;
|
|
17222
|
+
}
|
|
17223
|
+
function loadSourceMapForFile(filePath) {
|
|
17224
|
+
const normalized = normalizeStackFilePath(filePath);
|
|
17225
|
+
if (!normalized) return null;
|
|
17226
|
+
const mod = nodeModuleApi();
|
|
17227
|
+
try {
|
|
17228
|
+
if (typeof mod.findSourceMap === "function") {
|
|
17229
|
+
const found = mod.findSourceMap(normalized);
|
|
17230
|
+
if (found) return found;
|
|
17231
|
+
}
|
|
17232
|
+
} catch {
|
|
17233
|
+
}
|
|
17234
|
+
const cache = stackTraceMapperState().sourceMapCache;
|
|
17235
|
+
if (cache.has(normalized)) return cache.get(normalized) ?? null;
|
|
17236
|
+
let loaded = null;
|
|
17237
|
+
try {
|
|
17238
|
+
const content = readTextFileCached(normalized);
|
|
17239
|
+
const mappingUrl = content ? sourceMappingUrlFromContent(content) : null;
|
|
17240
|
+
if (mappingUrl) {
|
|
17241
|
+
let payload = null;
|
|
17242
|
+
if (mappingUrl.startsWith("data:")) {
|
|
17243
|
+
const base643 = mappingUrl.match(/^data:application\/json(?:;charset=[^;,]+)?;base64,(.+)$/i)?.[1];
|
|
17244
|
+
if (base643) payload = JSON.parse(Buffer2.from(base643, "base64").toString("utf8"));
|
|
17245
|
+
} else {
|
|
17246
|
+
const mapPath = resolve7(dirname5(normalized), decodeURIComponent(mappingUrl));
|
|
17247
|
+
if (existsSync9(mapPath)) payload = JSON.parse(readFileSync12(mapPath, "utf8"));
|
|
17248
|
+
}
|
|
17249
|
+
if (payload && typeof mod.SourceMap === "function") {
|
|
17250
|
+
loaded = new mod.SourceMap(payload);
|
|
17251
|
+
}
|
|
17252
|
+
}
|
|
17253
|
+
} catch {
|
|
17254
|
+
loaded = null;
|
|
17255
|
+
}
|
|
17256
|
+
setBoundedCacheEntry(cache, normalized, loaded);
|
|
17257
|
+
return loaded;
|
|
17258
|
+
}
|
|
17259
|
+
function sourceContentForOrigin(sourceMap, originFileName) {
|
|
17260
|
+
const payload = sourceMap?.payload;
|
|
17261
|
+
const sources = Array.isArray(payload?.sources) ? payload.sources : [];
|
|
17262
|
+
const contents = Array.isArray(payload?.sourcesContent) ? payload.sourcesContent : [];
|
|
17263
|
+
let index = sources.indexOf(originFileName);
|
|
17264
|
+
if (index < 0) {
|
|
17265
|
+
const normalizedOrigin = String(originFileName ?? "").replace(/\\/g, "/");
|
|
17266
|
+
index = sources.findIndex((source) => String(source ?? "").replace(/\\/g, "/") === normalizedOrigin);
|
|
17267
|
+
}
|
|
17268
|
+
if (index < 0) return null;
|
|
17269
|
+
const content = contents[index];
|
|
17270
|
+
return typeof content === "string" ? content : null;
|
|
17271
|
+
}
|
|
17272
|
+
function resolveSourceMapSourcePath(mapFilePath, sourceMap, originFileName) {
|
|
17273
|
+
let sourceRef = String(originFileName ?? "");
|
|
17274
|
+
if (!sourceRef) return "";
|
|
17275
|
+
if (sourceRef.startsWith("file://")) {
|
|
17276
|
+
try {
|
|
17277
|
+
return normalize(fileURLToPath2(sourceRef));
|
|
17278
|
+
} catch {
|
|
17279
|
+
return sourceRef;
|
|
17280
|
+
}
|
|
17281
|
+
}
|
|
17282
|
+
if (isAbsolute2(sourceRef)) return normalize(sourceRef);
|
|
17283
|
+
const sourceRoot = String(sourceMap?.payload?.sourceRoot ?? "");
|
|
17284
|
+
if (sourceRoot.startsWith("file://")) {
|
|
17285
|
+
try {
|
|
17286
|
+
return normalize(resolve7(fileURLToPath2(sourceRoot), sourceRef));
|
|
17287
|
+
} catch {
|
|
17288
|
+
return normalize(sourceRef);
|
|
17289
|
+
}
|
|
17290
|
+
}
|
|
17291
|
+
return normalize(resolve7(dirname5(normalizeStackFilePath(mapFilePath)), sourceRoot, sourceRef));
|
|
17292
|
+
}
|
|
17293
|
+
function sourceMapOriginForLocation(sourceMap, lineNumber, columnNumber) {
|
|
17294
|
+
if (!sourceMap) return null;
|
|
17295
|
+
if (typeof sourceMap.findOrigin === "function") {
|
|
17296
|
+
try {
|
|
17297
|
+
const origin = sourceMap.findOrigin(lineNumber, columnNumber);
|
|
17298
|
+
if (origin?.fileName && Number.isFinite(Number(origin.lineNumber))) {
|
|
17299
|
+
return {
|
|
17300
|
+
fileName: String(origin.fileName),
|
|
17301
|
+
lineNumber: Math.max(1, Math.floor(Number(origin.lineNumber) || 1))
|
|
17302
|
+
};
|
|
17303
|
+
}
|
|
17304
|
+
} catch {
|
|
17305
|
+
}
|
|
17306
|
+
}
|
|
17307
|
+
if (typeof sourceMap.findEntry === "function") {
|
|
17308
|
+
try {
|
|
17309
|
+
const entry = sourceMap.findEntry(Math.max(0, lineNumber - 1), Math.max(0, columnNumber - 1));
|
|
17310
|
+
const fileName = entry?.originalSource ?? entry?.sourceURL ?? entry?.fileName;
|
|
17311
|
+
const rawLine = entry?.originalLine ?? entry?.line ?? entry?.lineNumber;
|
|
17312
|
+
if (fileName && Number.isFinite(Number(rawLine))) {
|
|
17313
|
+
return {
|
|
17314
|
+
fileName: String(fileName),
|
|
17315
|
+
lineNumber: Math.max(1, Math.floor(Number(rawLine)) + 1)
|
|
17316
|
+
};
|
|
17317
|
+
}
|
|
17318
|
+
} catch {
|
|
17319
|
+
}
|
|
17320
|
+
}
|
|
17321
|
+
return null;
|
|
17322
|
+
}
|
|
17323
|
+
function generatedSourceTextForLocation(filePath, lineNumber, columnNumber) {
|
|
17324
|
+
const normalized = normalizeStackFilePath(filePath);
|
|
17325
|
+
if (!normalized) return null;
|
|
17326
|
+
const safeLine = Math.max(1, Math.floor(Number(lineNumber) || 1));
|
|
17327
|
+
const rawColumn = Number(columnNumber);
|
|
17328
|
+
const safeColumn = Number.isFinite(rawColumn) ? Math.max(0, Math.floor(rawColumn)) : 1;
|
|
17329
|
+
const sourceMap = loadSourceMapForFile(normalized);
|
|
17330
|
+
if (sourceMap) {
|
|
17331
|
+
try {
|
|
17332
|
+
const origin = sourceMapOriginForLocation(sourceMap, safeLine, safeColumn);
|
|
17333
|
+
if (origin) {
|
|
17334
|
+
const originPath = resolveSourceMapSourcePath(normalized, sourceMap, origin.fileName);
|
|
17335
|
+
const content = readTextFileCached(originPath) ?? sourceContentForOrigin(sourceMap, origin.fileName);
|
|
17336
|
+
if (content) {
|
|
17337
|
+
return {
|
|
17338
|
+
content,
|
|
17339
|
+
filePath: originPath,
|
|
17340
|
+
lineNumber: origin.lineNumber,
|
|
17341
|
+
generatedFile: normalized,
|
|
17342
|
+
generatedLine: safeLine
|
|
17343
|
+
};
|
|
17344
|
+
}
|
|
17345
|
+
}
|
|
17346
|
+
} catch {
|
|
17347
|
+
}
|
|
17348
|
+
}
|
|
17349
|
+
const directContent = readTextFileCached(normalized);
|
|
17350
|
+
if (!directContent) return null;
|
|
17351
|
+
return {
|
|
17352
|
+
content: directContent,
|
|
17353
|
+
filePath: normalized,
|
|
17354
|
+
lineNumber: safeLine,
|
|
17355
|
+
generatedFile: normalized,
|
|
17356
|
+
generatedLine: safeLine
|
|
17357
|
+
};
|
|
17358
|
+
}
|
|
17359
|
+
function findNearestKernTrace(content, lineNumber) {
|
|
17360
|
+
const lines = String(content ?? "").split(/\r?\n/);
|
|
17361
|
+
const start = Math.max(0, Math.min(lines.length - 1, Math.floor(Number(lineNumber) || 1) - 1));
|
|
17362
|
+
for (let index = start; index >= 0; index -= 1) {
|
|
17363
|
+
const match = lines[index].match(/^\s*\/\/ @kern-source: (.+):(\d+)\s*$/);
|
|
17364
|
+
if (!match) continue;
|
|
17365
|
+
return { sourceName: match[1], line: Math.max(1, Math.floor(Number(match[2]) || 1)) };
|
|
17366
|
+
}
|
|
17367
|
+
return null;
|
|
17368
|
+
}
|
|
17369
|
+
function generatedHeaderSource(content) {
|
|
17370
|
+
const match = String(content ?? "").match(/^\/\/\s*@generated\s+by\s+kern\b[\s\S]*?\bSource:\s*(.+?)\s*$/m);
|
|
17371
|
+
return match?.[1]?.trim() || null;
|
|
17372
|
+
}
|
|
17373
|
+
function packageRootForGeneratedPath(generatedFile) {
|
|
17374
|
+
const normalized = normalizeStackFilePath(generatedFile);
|
|
17375
|
+
const slashPath = normalized.replace(/\\/g, "/");
|
|
17376
|
+
const srcMarker = "/src/generated/";
|
|
17377
|
+
const srcIndex = slashPath.indexOf(srcMarker);
|
|
17378
|
+
if (srcIndex >= 0) return normalized.slice(0, srcIndex);
|
|
17379
|
+
const generatedMarker = "/generated/";
|
|
17380
|
+
const generatedIndex = slashPath.indexOf(generatedMarker);
|
|
17381
|
+
if (generatedIndex >= 0) return normalized.slice(0, generatedIndex);
|
|
17382
|
+
return null;
|
|
17383
|
+
}
|
|
17384
|
+
function resolveKernSourceFile(generatedFile, content, sourceName) {
|
|
17385
|
+
const header = generatedHeaderSource(content);
|
|
17386
|
+
const candidates = [];
|
|
17387
|
+
const root = packageRootForGeneratedPath(generatedFile);
|
|
17388
|
+
if (header) {
|
|
17389
|
+
if (isAbsolute2(header)) candidates.push(normalize(header));
|
|
17390
|
+
if (root) candidates.push(normalize(resolve7(root, header)));
|
|
17391
|
+
candidates.push(normalize(resolve7(dirname5(normalizeStackFilePath(generatedFile)), header)));
|
|
17392
|
+
try {
|
|
17393
|
+
candidates.push(normalize(resolve7(process.cwd(), header)));
|
|
17394
|
+
} catch {
|
|
17395
|
+
}
|
|
17396
|
+
}
|
|
17397
|
+
if (root) {
|
|
17398
|
+
candidates.push(normalize(resolve7(root, "src", "kern", `${sourceName}.kern`)));
|
|
17399
|
+
candidates.push(normalize(resolve7(root, "kern", `${sourceName}.kern`)));
|
|
17400
|
+
}
|
|
17401
|
+
const sourceBase = `${sourceName}.kern`;
|
|
17402
|
+
const matchingHeader = candidates.find((candidate) => basename3(candidate) === sourceBase);
|
|
17403
|
+
const matchingHeaderExists = matchingHeader ? (() => {
|
|
17404
|
+
try {
|
|
17405
|
+
return existsSync9(matchingHeader);
|
|
17406
|
+
} catch {
|
|
17407
|
+
return false;
|
|
17408
|
+
}
|
|
17409
|
+
})() : false;
|
|
17410
|
+
const existing = candidates.find((candidate) => {
|
|
17411
|
+
try {
|
|
17412
|
+
return existsSync9(candidate);
|
|
17413
|
+
} catch {
|
|
17414
|
+
return false;
|
|
17415
|
+
}
|
|
17416
|
+
});
|
|
17417
|
+
return (matchingHeaderExists ? matchingHeader : null) ?? matchingHeader ?? existing ?? candidates[0] ?? sourceBase;
|
|
17418
|
+
}
|
|
17419
|
+
function resolveKernSourceLocation(filePath, lineNumber, columnNumber) {
|
|
17420
|
+
const normalized = normalizeStackFilePath(filePath);
|
|
17421
|
+
const cache = stackTraceMapperState().locationCache;
|
|
17422
|
+
const cacheKey = `${normalized || String(filePath ?? "")}:${Number(lineNumber) || 0}:${Number(columnNumber) || 0}`;
|
|
17423
|
+
if (cache.has(cacheKey)) return cache.get(cacheKey) ?? null;
|
|
17424
|
+
const source = generatedSourceTextForLocation(filePath, lineNumber, columnNumber);
|
|
17425
|
+
if (!source?.content) {
|
|
17426
|
+
setBoundedCacheEntry(cache, cacheKey, null);
|
|
17427
|
+
return null;
|
|
17428
|
+
}
|
|
17429
|
+
const trace = findNearestKernTrace(source.content, source.lineNumber);
|
|
17430
|
+
if (!trace) {
|
|
17431
|
+
setBoundedCacheEntry(cache, cacheKey, null);
|
|
17432
|
+
return null;
|
|
17433
|
+
}
|
|
17434
|
+
const kernFile = resolveKernSourceFile(source.filePath, source.content, trace.sourceName);
|
|
17435
|
+
const result = {
|
|
17436
|
+
file: kernFile,
|
|
17437
|
+
line: trace.line,
|
|
17438
|
+
sourceName: trace.sourceName,
|
|
17439
|
+
generatedFile: source.filePath,
|
|
17440
|
+
generatedLine: source.lineNumber
|
|
17441
|
+
};
|
|
17442
|
+
setBoundedCacheEntry(cache, cacheKey, result);
|
|
17443
|
+
return result;
|
|
17444
|
+
}
|
|
17445
|
+
function stackLineLocation(line) {
|
|
17446
|
+
const match = String(line ?? "").match(/((?:file:\/\/\/[A-Za-z]:[\\/].+?|[A-Za-z]:[\\/].+?|file:\/\/\/.+?|\/.+?|\\\\.+?)\.(?:mjs|cjs|js|jsx|ts|tsx|mts|cts|vue|py|json)):(\d+):(\d+)(\)?)(\s*)$/);
|
|
17447
|
+
if (!match || match.index == null) return null;
|
|
17448
|
+
const locationText = `${match[1]}:${match[2]}:${match[3]}`;
|
|
17449
|
+
return {
|
|
17450
|
+
rawFile: match[1],
|
|
17451
|
+
rawLine: match[2],
|
|
17452
|
+
rawColumn: match[3],
|
|
17453
|
+
start: match.index,
|
|
17454
|
+
end: match.index + locationText.length
|
|
17455
|
+
};
|
|
17456
|
+
}
|
|
17457
|
+
function mapKernStackTrace(stack) {
|
|
17458
|
+
const text = String(stack ?? "");
|
|
17459
|
+
if (!text) return text;
|
|
17460
|
+
return text.split("\n").map((line) => {
|
|
17461
|
+
if (line.includes("[kern: ")) return line;
|
|
17462
|
+
const frame = stackLineLocation(line);
|
|
17463
|
+
if (!frame) return line;
|
|
17464
|
+
const loc = resolveKernSourceLocation(frame.rawFile, Number(frame.rawLine), Number(frame.rawColumn));
|
|
17465
|
+
if (!loc) return line;
|
|
17466
|
+
return `${line.slice(0, frame.end)} [kern: ${loc.file}:${loc.line}]${line.slice(frame.end)}`;
|
|
17467
|
+
}).join("\n");
|
|
17468
|
+
}
|
|
17469
|
+
function formatDefaultStackTrace(error48, frames) {
|
|
17470
|
+
const name = error48?.name ? String(error48.name) : "Error";
|
|
17471
|
+
const message = error48?.message ? `${name}: ${String(error48.message)}` : name;
|
|
17472
|
+
const lines = [message];
|
|
17473
|
+
for (const frame of frames ?? []) {
|
|
17474
|
+
lines.push(` at ${String(frame)}`);
|
|
17475
|
+
}
|
|
17476
|
+
return lines.join("\n");
|
|
17477
|
+
}
|
|
17478
|
+
function stackTraceMapperDisabled() {
|
|
17479
|
+
return !!process.env.AGON_NO_STACK_TRACE_MAPPER;
|
|
17480
|
+
}
|
|
17481
|
+
function stackTraceMapperState() {
|
|
17482
|
+
const holder = stackTraceMapperState;
|
|
17483
|
+
if (!holder.state) {
|
|
17484
|
+
holder.state = {
|
|
17485
|
+
installed: false,
|
|
17486
|
+
previous: null,
|
|
17487
|
+
wrapper: null,
|
|
17488
|
+
sourceTextCache: /* @__PURE__ */ new Map(),
|
|
17489
|
+
sourceMapCache: /* @__PURE__ */ new Map(),
|
|
17490
|
+
locationCache: /* @__PURE__ */ new Map()
|
|
17491
|
+
};
|
|
17492
|
+
}
|
|
17493
|
+
return holder.state;
|
|
17494
|
+
}
|
|
17495
|
+
function installKernStackTraceMapper() {
|
|
17496
|
+
if (stackTraceMapperDisabled()) return;
|
|
17497
|
+
const state = stackTraceMapperState();
|
|
17498
|
+
if (state.installed && Error.prepareStackTrace === state.wrapper) return;
|
|
17499
|
+
if (state.installed) {
|
|
17500
|
+
state.installed = false;
|
|
17501
|
+
state.previous = null;
|
|
17502
|
+
state.wrapper = null;
|
|
17503
|
+
}
|
|
17504
|
+
const mod = nodeModuleApi();
|
|
17505
|
+
try {
|
|
17506
|
+
if (typeof mod.setSourceMapsSupport === "function") {
|
|
17507
|
+
mod.setSourceMapsSupport(true, { nodeModules: false, generatedCode: true });
|
|
17508
|
+
}
|
|
17509
|
+
} catch {
|
|
17510
|
+
}
|
|
17511
|
+
const previous = Error.prepareStackTrace;
|
|
17512
|
+
if (state.wrapper && previous === state.wrapper) {
|
|
17513
|
+
state.installed = true;
|
|
17514
|
+
return;
|
|
17515
|
+
}
|
|
17516
|
+
const wrapper = (error48, frames) => {
|
|
17517
|
+
if (typeof previous === "function") {
|
|
17518
|
+
const rendered = previous(error48, frames);
|
|
17519
|
+
return typeof rendered === "string" ? mapKernStackTrace(rendered) : rendered;
|
|
17520
|
+
}
|
|
17521
|
+
return mapKernStackTrace(formatDefaultStackTrace(error48, frames));
|
|
17522
|
+
};
|
|
17523
|
+
try {
|
|
17524
|
+
Error.prepareStackTrace = wrapper;
|
|
17525
|
+
} catch {
|
|
17526
|
+
return;
|
|
17527
|
+
}
|
|
17528
|
+
state.previous = previous;
|
|
17529
|
+
state.wrapper = wrapper;
|
|
17530
|
+
state.installed = true;
|
|
17531
|
+
}
|
|
17532
|
+
function uninstallKernStackTraceMapper() {
|
|
17533
|
+
const state = stackTraceMapperState();
|
|
17534
|
+
if (state.installed && Error.prepareStackTrace === state.wrapper) {
|
|
17535
|
+
try {
|
|
17536
|
+
Error.prepareStackTrace = state.previous;
|
|
17537
|
+
} catch {
|
|
17538
|
+
}
|
|
17539
|
+
}
|
|
17540
|
+
state.installed = false;
|
|
17541
|
+
state.previous = null;
|
|
17542
|
+
state.wrapper = null;
|
|
17543
|
+
state.sourceTextCache?.clear?.();
|
|
17544
|
+
state.sourceMapCache?.clear?.();
|
|
17545
|
+
state.locationCache?.clear?.();
|
|
17546
|
+
}
|
|
17547
|
+
|
|
16950
17548
|
// ../core/src/generated/signals/output-manager.ts
|
|
16951
17549
|
function formatSpinnerFrame(frames, index, text) {
|
|
16952
17550
|
return ` \x1B[38;5;214m${frames[index % frames.length]}\x1B[0m \x1B[2m${text}\x1B[0m`;
|
|
@@ -17114,15 +17712,15 @@ async function discoverEngines(registry2, adapter) {
|
|
|
17114
17712
|
}
|
|
17115
17713
|
|
|
17116
17714
|
// ../core/src/generated/blocks/patch-apply.ts
|
|
17117
|
-
import { readFileSync as
|
|
17118
|
-
import { join as
|
|
17715
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync8 } from "fs";
|
|
17716
|
+
import { join as join14 } from "path";
|
|
17119
17717
|
import { execSync } from "child_process";
|
|
17120
17718
|
|
|
17121
17719
|
// ../core/src/generated/utils/paths.ts
|
|
17122
|
-
import { join as
|
|
17720
|
+
import { join as join13, resolve as resolve8 } from "path";
|
|
17123
17721
|
import { homedir as homedir6 } from "os";
|
|
17124
17722
|
function runtimeAgonPath(...parts) {
|
|
17125
|
-
return
|
|
17723
|
+
return join13(resolve8(process.env.AGON_HOME?.trim() || join13(homedir6(), ".agon")), ...parts);
|
|
17126
17724
|
}
|
|
17127
17725
|
function getCacheDir() {
|
|
17128
17726
|
return runtimeAgonPath("cache");
|
|
@@ -17215,12 +17813,12 @@ function invertPatch(content) {
|
|
|
17215
17813
|
// ../core/src/generated/blocks/patch-apply.ts
|
|
17216
17814
|
function readPatchFromManifest(manifestPath) {
|
|
17217
17815
|
try {
|
|
17218
|
-
const raw =
|
|
17816
|
+
const raw = readFileSync13(manifestPath, "utf-8");
|
|
17219
17817
|
const manifest = JSON.parse(raw);
|
|
17220
17818
|
if (!manifest.winner) return null;
|
|
17221
17819
|
const patchPath = manifest.patches[manifest.winner];
|
|
17222
17820
|
if (!patchPath) return null;
|
|
17223
|
-
const content = normalizePatchContent(
|
|
17821
|
+
const content = normalizePatchContent(readFileSync13(patchPath, "utf-8"));
|
|
17224
17822
|
const lineCount = content.split("\n").filter(
|
|
17225
17823
|
(l) => l.startsWith("+") && !l.startsWith("+++") || l.startsWith("-") && !l.startsWith("---")
|
|
17226
17824
|
).length;
|
|
@@ -17232,7 +17830,7 @@ function readPatchFromManifest(manifestPath) {
|
|
|
17232
17830
|
}
|
|
17233
17831
|
function readPatchFromPath(patchPath) {
|
|
17234
17832
|
try {
|
|
17235
|
-
const content = normalizePatchContent(
|
|
17833
|
+
const content = normalizePatchContent(readFileSync13(patchPath, "utf-8"));
|
|
17236
17834
|
if (!content.trim()) return null;
|
|
17237
17835
|
const lineCount = content.split("\n").filter(
|
|
17238
17836
|
(l) => l.startsWith("+") && !l.startsWith("+++") || l.startsWith("-") && !l.startsWith("---")
|
|
@@ -17292,7 +17890,7 @@ function preflightApply(cwd, patchPath, manifestPath) {
|
|
|
17292
17890
|
}
|
|
17293
17891
|
function applyPatchWithUndo(cwd, patchContent) {
|
|
17294
17892
|
const undoDir = getUndoDir();
|
|
17295
|
-
|
|
17893
|
+
mkdirSync9(undoDir, { recursive: true });
|
|
17296
17894
|
const inverse = invertPatch(patchContent);
|
|
17297
17895
|
const token = `undo-${Date.now()}`;
|
|
17298
17896
|
try {
|
|
@@ -17301,18 +17899,18 @@ function applyPatchWithUndo(cwd, patchContent) {
|
|
|
17301
17899
|
const msg = err instanceof Error ? err.stderr || err.message : String(err);
|
|
17302
17900
|
return { ok: false, error: msg };
|
|
17303
17901
|
}
|
|
17304
|
-
const inversePath =
|
|
17305
|
-
const tmpPath =
|
|
17306
|
-
|
|
17902
|
+
const inversePath = join14(undoDir, `${token}.patch`);
|
|
17903
|
+
const tmpPath = join14(undoDir, `${token}.patch.tmp`);
|
|
17904
|
+
writeFileSync10(tmpPath, inverse);
|
|
17307
17905
|
renameSync8(tmpPath, inversePath);
|
|
17308
17906
|
return { ok: true, undoToken: token };
|
|
17309
17907
|
}
|
|
17310
17908
|
function undoPatch(cwd, undoToken) {
|
|
17311
17909
|
const undoDir = getUndoDir();
|
|
17312
|
-
const inversePath =
|
|
17910
|
+
const inversePath = join14(undoDir, `${undoToken}.patch`);
|
|
17313
17911
|
let inverse;
|
|
17314
17912
|
try {
|
|
17315
|
-
inverse =
|
|
17913
|
+
inverse = readFileSync13(inversePath, "utf-8");
|
|
17316
17914
|
} catch {
|
|
17317
17915
|
return { ok: false, error: `Undo token not found: ${undoToken}` };
|
|
17318
17916
|
}
|
|
@@ -17326,28 +17924,28 @@ function undoPatch(cwd, undoToken) {
|
|
|
17326
17924
|
}
|
|
17327
17925
|
|
|
17328
17926
|
// ../core/src/generated/blocks/file-history.ts
|
|
17329
|
-
import { readFileSync as
|
|
17330
|
-
import { join as
|
|
17927
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, existsSync as existsSync10, readdirSync as readdirSync9, unlinkSync as unlinkSync4 } from "fs";
|
|
17928
|
+
import { join as join15, dirname as dirname6, resolve as resolve9 } from "path";
|
|
17331
17929
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
17332
17930
|
import { homedir as homedir7 } from "os";
|
|
17333
17931
|
function snapshotsDir() {
|
|
17334
17932
|
const override = process.env.AGON_HOME?.trim();
|
|
17335
|
-
const home = override ?
|
|
17336
|
-
return
|
|
17933
|
+
const home = override ? resolve9(override) : join15(homedir7(), ".agon");
|
|
17934
|
+
return join15(home, "snapshots");
|
|
17337
17935
|
}
|
|
17338
17936
|
var MAX_SNAPSHOTS = 50;
|
|
17339
17937
|
function ensureSnapshotsDir() {
|
|
17340
17938
|
ensureAgonHome();
|
|
17341
|
-
|
|
17939
|
+
mkdirSync10(snapshotsDir(), { recursive: true });
|
|
17342
17940
|
}
|
|
17343
17941
|
function takeSnapshot(label, cwd, filePaths) {
|
|
17344
17942
|
ensureSnapshotsDir();
|
|
17345
17943
|
const files = [];
|
|
17346
17944
|
for (const fp of filePaths) {
|
|
17347
|
-
const fullPath =
|
|
17348
|
-
if (
|
|
17945
|
+
const fullPath = resolve9(cwd, fp);
|
|
17946
|
+
if (existsSync10(fullPath)) {
|
|
17349
17947
|
try {
|
|
17350
|
-
const content =
|
|
17948
|
+
const content = readFileSync14(fullPath, "utf-8");
|
|
17351
17949
|
files.push({ path: fp, content, timestamp: Date.now(), existed: true });
|
|
17352
17950
|
} catch (err) {
|
|
17353
17951
|
console.warn(`[agon] snapshot: could not read ${fp}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -17363,36 +17961,36 @@ function takeSnapshot(label, cwd, filePaths) {
|
|
|
17363
17961
|
files,
|
|
17364
17962
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
17365
17963
|
};
|
|
17366
|
-
const entryPath =
|
|
17367
|
-
|
|
17964
|
+
const entryPath = join15(snapshotsDir(), `${entry.id}.json`);
|
|
17965
|
+
writeFileSync11(entryPath, JSON.stringify(entry, null, 2) + "\n");
|
|
17368
17966
|
pruneSnapshots();
|
|
17369
17967
|
return entry;
|
|
17370
17968
|
}
|
|
17371
17969
|
function revertSnapshot(id) {
|
|
17372
17970
|
ensureSnapshotsDir();
|
|
17373
|
-
const entryPath =
|
|
17374
|
-
if (!
|
|
17971
|
+
const entryPath = join15(snapshotsDir(), `${id}.json`);
|
|
17972
|
+
if (!existsSync10(entryPath)) {
|
|
17375
17973
|
return { ok: false, error: `Snapshot ${id} not found`, filesReverted: 0 };
|
|
17376
17974
|
}
|
|
17377
17975
|
let entry;
|
|
17378
17976
|
try {
|
|
17379
|
-
entry = JSON.parse(
|
|
17977
|
+
entry = JSON.parse(readFileSync14(entryPath, "utf-8"));
|
|
17380
17978
|
} catch (err) {
|
|
17381
17979
|
return { ok: false, error: `Corrupt snapshot: ${err instanceof Error ? err.message : String(err)}`, filesReverted: 0 };
|
|
17382
17980
|
}
|
|
17383
17981
|
let reverted = 0;
|
|
17384
17982
|
for (const snap of entry.files) {
|
|
17385
|
-
const fullPath =
|
|
17983
|
+
const fullPath = resolve9(entry.cwd, snap.path);
|
|
17386
17984
|
try {
|
|
17387
17985
|
const existedBefore = typeof snap.existed === "boolean" ? snap.existed : snap.content !== "";
|
|
17388
17986
|
if (!existedBefore) {
|
|
17389
|
-
if (
|
|
17987
|
+
if (existsSync10(fullPath)) {
|
|
17390
17988
|
unlinkSync4(fullPath);
|
|
17391
17989
|
reverted++;
|
|
17392
17990
|
}
|
|
17393
17991
|
} else {
|
|
17394
|
-
|
|
17395
|
-
|
|
17992
|
+
mkdirSync10(dirname6(fullPath), { recursive: true });
|
|
17993
|
+
writeFileSync11(fullPath, snap.content);
|
|
17396
17994
|
reverted++;
|
|
17397
17995
|
}
|
|
17398
17996
|
} catch (err) {
|
|
@@ -17409,10 +18007,10 @@ function revertSnapshot(id) {
|
|
|
17409
18007
|
function listSnapshots() {
|
|
17410
18008
|
ensureSnapshotsDir();
|
|
17411
18009
|
try {
|
|
17412
|
-
const files =
|
|
18010
|
+
const files = readdirSync9(snapshotsDir()).filter((f) => f.endsWith(".json"));
|
|
17413
18011
|
const entries = files.map((f) => {
|
|
17414
18012
|
try {
|
|
17415
|
-
return JSON.parse(
|
|
18013
|
+
return JSON.parse(readFileSync14(join15(snapshotsDir(), f), "utf-8"));
|
|
17416
18014
|
} catch {
|
|
17417
18015
|
return null;
|
|
17418
18016
|
}
|
|
@@ -17429,11 +18027,11 @@ function listSnapshots() {
|
|
|
17429
18027
|
}
|
|
17430
18028
|
function pruneSnapshots() {
|
|
17431
18029
|
try {
|
|
17432
|
-
const files =
|
|
18030
|
+
const files = readdirSync9(snapshotsDir()).filter((f) => f.endsWith(".json"));
|
|
17433
18031
|
if (files.length > MAX_SNAPSHOTS) {
|
|
17434
18032
|
const byAge = files.map((f) => {
|
|
17435
18033
|
try {
|
|
17436
|
-
const entry = JSON.parse(
|
|
18034
|
+
const entry = JSON.parse(readFileSync14(join15(snapshotsDir(), f), "utf-8"));
|
|
17437
18035
|
return { file: f, ts: Date.parse(entry.createdAt ?? "") || 0 };
|
|
17438
18036
|
} catch {
|
|
17439
18037
|
return { file: f, ts: 0 };
|
|
@@ -17442,7 +18040,7 @@ function pruneSnapshots() {
|
|
|
17442
18040
|
const toDelete = byAge.slice(0, files.length - MAX_SNAPSHOTS);
|
|
17443
18041
|
for (const item of toDelete) {
|
|
17444
18042
|
try {
|
|
17445
|
-
unlinkSync4(
|
|
18043
|
+
unlinkSync4(join15(snapshotsDir(), item.file));
|
|
17446
18044
|
} catch {
|
|
17447
18045
|
}
|
|
17448
18046
|
}
|
|
@@ -17533,38 +18131,38 @@ function copyToClipboard(text) {
|
|
|
17533
18131
|
}
|
|
17534
18132
|
|
|
17535
18133
|
// ../core/src/generated/signals/paste-store.ts
|
|
17536
|
-
import { readFileSync as
|
|
17537
|
-
import { join as
|
|
17538
|
-
import { createHash as
|
|
18134
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync12, mkdirSync as mkdirSync11, existsSync as existsSync11, readdirSync as readdirSync10, unlinkSync as unlinkSync5, statSync as statSync9 } from "fs";
|
|
18135
|
+
import { join as join16, resolve as resolve10 } from "path";
|
|
18136
|
+
import { createHash as createHash3 } from "crypto";
|
|
17539
18137
|
import { homedir as homedir8 } from "os";
|
|
17540
18138
|
function getPasteStoreDir() {
|
|
17541
18139
|
const override = process.env.AGON_HOME?.trim();
|
|
17542
|
-
const home = override ?
|
|
17543
|
-
return
|
|
18140
|
+
const home = override ? resolve10(override) : join16(homedir8(), ".agon");
|
|
18141
|
+
return join16(home, "paste-cache");
|
|
17544
18142
|
}
|
|
17545
18143
|
var PASTE_MAX_AGE = 7 * 24 * 60 * 60 * 1e3;
|
|
17546
18144
|
function ensurePasteDir() {
|
|
17547
18145
|
ensureAgonHome();
|
|
17548
|
-
|
|
18146
|
+
mkdirSync11(getPasteStoreDir(), { recursive: true });
|
|
17549
18147
|
}
|
|
17550
18148
|
var PasteStore = class {
|
|
17551
18149
|
store(text) {
|
|
17552
18150
|
ensurePasteDir();
|
|
17553
|
-
const hash2 =
|
|
17554
|
-
const filePath =
|
|
17555
|
-
if (!
|
|
17556
|
-
|
|
18151
|
+
const hash2 = createHash3("sha256").update(text).digest("hex");
|
|
18152
|
+
const filePath = join16(getPasteStoreDir(), `${hash2}.txt`);
|
|
18153
|
+
if (!existsSync11(filePath)) {
|
|
18154
|
+
writeFileSync12(filePath, text);
|
|
17557
18155
|
}
|
|
17558
18156
|
const lines = text.split("\n");
|
|
17559
18157
|
const preview = text.slice(0, 200).replace(/\n/g, " ").trim();
|
|
17560
18158
|
return { hash: hash2, preview, lineCount: lines.length };
|
|
17561
18159
|
}
|
|
17562
18160
|
retrieve(hash2) {
|
|
17563
|
-
const filePath =
|
|
17564
|
-
if (!
|
|
18161
|
+
const filePath = join16(getPasteStoreDir(), `${hash2}.txt`);
|
|
18162
|
+
if (!existsSync11(filePath)) {
|
|
17565
18163
|
return null;
|
|
17566
18164
|
}
|
|
17567
|
-
return
|
|
18165
|
+
return readFileSync15(filePath, "utf-8");
|
|
17568
18166
|
}
|
|
17569
18167
|
cleanup(maxAge) {
|
|
17570
18168
|
const age = maxAge ?? PASTE_MAX_AGE;
|
|
@@ -17573,11 +18171,11 @@ var PasteStore = class {
|
|
|
17573
18171
|
ensurePasteDir();
|
|
17574
18172
|
try {
|
|
17575
18173
|
const pasteStoreDir = getPasteStoreDir();
|
|
17576
|
-
const files =
|
|
18174
|
+
const files = readdirSync10(pasteStoreDir).filter((f) => f.endsWith(".txt"));
|
|
17577
18175
|
for (const f of files) {
|
|
17578
|
-
const fp =
|
|
18176
|
+
const fp = join16(pasteStoreDir, f);
|
|
17579
18177
|
try {
|
|
17580
|
-
const stat =
|
|
18178
|
+
const stat = statSync9(fp);
|
|
17581
18179
|
if (now - stat.mtimeMs > age) {
|
|
17582
18180
|
unlinkSync5(fp);
|
|
17583
18181
|
deleted++;
|
|
@@ -17597,27 +18195,27 @@ var PasteStore = class {
|
|
|
17597
18195
|
var pasteStore = new PasteStore();
|
|
17598
18196
|
|
|
17599
18197
|
// ../core/src/generated/signals/session-store.ts
|
|
17600
|
-
import { writeFileSync as
|
|
17601
|
-
import { join as
|
|
17602
|
-
import { createHash as
|
|
18198
|
+
import { writeFileSync as writeFileSync13, readFileSync as readFileSync16, existsSync as existsSync12, mkdirSync as mkdirSync12, unlinkSync as unlinkSync6, readdirSync as readdirSync11, rmdirSync, renameSync as renameSync9 } from "fs";
|
|
18199
|
+
import { join as join17 } from "path";
|
|
18200
|
+
import { createHash as createHash4 } from "crypto";
|
|
17603
18201
|
var SESSION_SCHEMA_VERSION = 2;
|
|
17604
18202
|
var SESSION_MAX_MESSAGES = 80;
|
|
17605
18203
|
var SESSION_TTL_MS = 36e5;
|
|
17606
18204
|
function sessionStorePath(engineId) {
|
|
17607
|
-
const cwdHash =
|
|
18205
|
+
const cwdHash = createHash4("md5").update(process.cwd()).digest("hex").slice(0, 8);
|
|
17608
18206
|
return runtimeAgonPath("sessions", `${engineId}-${cwdHash}.json`);
|
|
17609
18207
|
}
|
|
17610
18208
|
function sessionCacheDir(engineId) {
|
|
17611
|
-
const cwdHash =
|
|
18209
|
+
const cwdHash = createHash4("md5").update(process.cwd()).digest("hex").slice(0, 8);
|
|
17612
18210
|
return runtimeAgonPath("sessions", `${engineId}-${cwdHash}-cache`);
|
|
17613
18211
|
}
|
|
17614
18212
|
function saveToolResultToDisk(engineId, toolCallId, toolName, content) {
|
|
17615
18213
|
try {
|
|
17616
18214
|
const cacheDir = sessionCacheDir(engineId);
|
|
17617
|
-
|
|
17618
|
-
const filePath =
|
|
18215
|
+
mkdirSync12(cacheDir, { recursive: true });
|
|
18216
|
+
const filePath = join17(cacheDir, `${toolCallId}.txt`);
|
|
17619
18217
|
const tmpFilePath = filePath + ".tmp";
|
|
17620
|
-
|
|
18218
|
+
writeFileSync13(tmpFilePath, content, "utf-8");
|
|
17621
18219
|
renameSync9(tmpFilePath, filePath);
|
|
17622
18220
|
return {
|
|
17623
18221
|
toolCallId,
|
|
@@ -17634,11 +18232,11 @@ function saveToolResultToDisk(engineId, toolCallId, toolName, content) {
|
|
|
17634
18232
|
function loadToolResultFromDisk(engineId, toolCallId) {
|
|
17635
18233
|
try {
|
|
17636
18234
|
const cacheDir = sessionCacheDir(engineId);
|
|
17637
|
-
const filePath =
|
|
17638
|
-
if (!
|
|
18235
|
+
const filePath = join17(cacheDir, `${toolCallId}.txt`);
|
|
18236
|
+
if (!existsSync12(filePath)) {
|
|
17639
18237
|
return null;
|
|
17640
18238
|
}
|
|
17641
|
-
return
|
|
18239
|
+
return readFileSync16(filePath, "utf-8");
|
|
17642
18240
|
} catch (e) {
|
|
17643
18241
|
return null;
|
|
17644
18242
|
}
|
|
@@ -17646,13 +18244,13 @@ function loadToolResultFromDisk(engineId, toolCallId) {
|
|
|
17646
18244
|
function pruneToolCache(engineId, keepIds) {
|
|
17647
18245
|
try {
|
|
17648
18246
|
const cacheDir = sessionCacheDir(engineId);
|
|
17649
|
-
if (!
|
|
17650
|
-
const files =
|
|
18247
|
+
if (!existsSync12(cacheDir)) return;
|
|
18248
|
+
const files = readdirSync11(cacheDir);
|
|
17651
18249
|
for (const f of files) {
|
|
17652
18250
|
const id = f.replace(/\.txt$/, "");
|
|
17653
18251
|
if (!keepIds.has(id)) {
|
|
17654
18252
|
try {
|
|
17655
|
-
unlinkSync6(
|
|
18253
|
+
unlinkSync6(join17(cacheDir, f));
|
|
17656
18254
|
} catch {
|
|
17657
18255
|
}
|
|
17658
18256
|
}
|
|
@@ -17662,21 +18260,21 @@ function pruneToolCache(engineId, keepIds) {
|
|
|
17662
18260
|
}
|
|
17663
18261
|
function saveSessionState(engineId, state) {
|
|
17664
18262
|
const dir = runtimeAgonPath("sessions");
|
|
17665
|
-
|
|
18263
|
+
mkdirSync12(dir, { recursive: true });
|
|
17666
18264
|
const path = sessionStorePath(engineId);
|
|
17667
18265
|
const trimmed = state.messageHistory.slice(-SESSION_MAX_MESSAGES);
|
|
17668
18266
|
const data = { schemaVersion: SESSION_SCHEMA_VERSION, messageHistory: trimmed, compactionSummary: state.compactionSummary ?? null, toolCacheManifest: state.toolCacheManifest ?? [], confidence: state.confidence, savedAt: Date.now() };
|
|
17669
18267
|
const tmpPath = path + ".tmp";
|
|
17670
|
-
|
|
18268
|
+
writeFileSync13(tmpPath, JSON.stringify(data), "utf-8");
|
|
17671
18269
|
renameSync9(tmpPath, path);
|
|
17672
18270
|
}
|
|
17673
18271
|
function loadSessionState(engineId) {
|
|
17674
18272
|
const path = sessionStorePath(engineId);
|
|
17675
|
-
if (!
|
|
18273
|
+
if (!existsSync12(path)) {
|
|
17676
18274
|
return null;
|
|
17677
18275
|
}
|
|
17678
18276
|
try {
|
|
17679
|
-
const raw =
|
|
18277
|
+
const raw = readFileSync16(path, "utf-8");
|
|
17680
18278
|
const data = JSON.parse(raw);
|
|
17681
18279
|
if (data.savedAt && Date.now() - data.savedAt > SESSION_TTL_MS) {
|
|
17682
18280
|
return null;
|
|
@@ -17695,16 +18293,16 @@ function loadSessionState(engineId) {
|
|
|
17695
18293
|
function clearSessionState(engineId) {
|
|
17696
18294
|
const path = sessionStorePath(engineId);
|
|
17697
18295
|
try {
|
|
17698
|
-
if (
|
|
18296
|
+
if (existsSync12(path)) unlinkSync6(path);
|
|
17699
18297
|
} catch {
|
|
17700
18298
|
}
|
|
17701
18299
|
try {
|
|
17702
18300
|
const cacheDir = sessionCacheDir(engineId);
|
|
17703
|
-
if (
|
|
17704
|
-
const files =
|
|
18301
|
+
if (existsSync12(cacheDir)) {
|
|
18302
|
+
const files = readdirSync11(cacheDir);
|
|
17705
18303
|
for (const f of files) {
|
|
17706
18304
|
try {
|
|
17707
|
-
unlinkSync6(
|
|
18305
|
+
unlinkSync6(join17(cacheDir, f));
|
|
17708
18306
|
} catch {
|
|
17709
18307
|
}
|
|
17710
18308
|
}
|
|
@@ -17715,7 +18313,7 @@ function clearSessionState(engineId) {
|
|
|
17715
18313
|
}
|
|
17716
18314
|
var CONVERSATION_SCHEMA_VERSION = 1;
|
|
17717
18315
|
function conversationStorePath() {
|
|
17718
|
-
const cwdHash =
|
|
18316
|
+
const cwdHash = createHash4("md5").update(process.cwd()).digest("hex").slice(0, 8);
|
|
17719
18317
|
return runtimeAgonPath("sessions", `conversation-${cwdHash}.json`);
|
|
17720
18318
|
}
|
|
17721
18319
|
function stripEngineArtifacts(messages) {
|
|
@@ -17764,22 +18362,22 @@ ${marker}` : marker;
|
|
|
17764
18362
|
}
|
|
17765
18363
|
function saveConversation(messages, sourceEngineId) {
|
|
17766
18364
|
const dir = runtimeAgonPath("sessions");
|
|
17767
|
-
|
|
18365
|
+
mkdirSync12(dir, { recursive: true });
|
|
17768
18366
|
const path = conversationStorePath();
|
|
17769
18367
|
const trimmed = messages.slice(-SESSION_MAX_MESSAGES);
|
|
17770
18368
|
const clean = stripEngineArtifacts(trimmed);
|
|
17771
18369
|
const data = { schemaVersion: CONVERSATION_SCHEMA_VERSION, messageHistory: clean, savedAt: Date.now(), sourceEngine: sourceEngineId };
|
|
17772
18370
|
const tmpPath = path + ".tmp";
|
|
17773
|
-
|
|
18371
|
+
writeFileSync13(tmpPath, JSON.stringify(data), "utf-8");
|
|
17774
18372
|
renameSync9(tmpPath, path);
|
|
17775
18373
|
}
|
|
17776
18374
|
function loadConversation() {
|
|
17777
18375
|
const path = conversationStorePath();
|
|
17778
|
-
if (!
|
|
18376
|
+
if (!existsSync12(path)) {
|
|
17779
18377
|
return null;
|
|
17780
18378
|
}
|
|
17781
18379
|
try {
|
|
17782
|
-
const raw =
|
|
18380
|
+
const raw = readFileSync16(path, "utf-8");
|
|
17783
18381
|
const data = JSON.parse(raw);
|
|
17784
18382
|
if (data.savedAt && Date.now() - data.savedAt > SESSION_TTL_MS) {
|
|
17785
18383
|
return null;
|
|
@@ -17795,7 +18393,7 @@ function loadConversation() {
|
|
|
17795
18393
|
function clearConversation() {
|
|
17796
18394
|
const path = conversationStorePath();
|
|
17797
18395
|
try {
|
|
17798
|
-
if (
|
|
18396
|
+
if (existsSync12(path)) unlinkSync6(path);
|
|
17799
18397
|
} catch {
|
|
17800
18398
|
}
|
|
17801
18399
|
}
|
|
@@ -17998,7 +18596,7 @@ var Semaphore = class {
|
|
|
17998
18596
|
this.permits -= 1;
|
|
17999
18597
|
return;
|
|
18000
18598
|
}
|
|
18001
|
-
return new Promise((
|
|
18599
|
+
return new Promise((resolve28, reject) => {
|
|
18002
18600
|
const entry = {
|
|
18003
18601
|
resolve: () => {
|
|
18004
18602
|
if (entry.onAbort && entry.signal) {
|
|
@@ -18007,7 +18605,7 @@ var Semaphore = class {
|
|
|
18007
18605
|
} catch {
|
|
18008
18606
|
}
|
|
18009
18607
|
}
|
|
18010
|
-
|
|
18608
|
+
resolve28();
|
|
18011
18609
|
},
|
|
18012
18610
|
reject: (err) => {
|
|
18013
18611
|
if (entry.onAbort && entry.signal) {
|
|
@@ -18624,8 +19222,8 @@ async function runToolLoop(sendMessage, initialResponse, ctx, registry2, callbac
|
|
|
18624
19222
|
}
|
|
18625
19223
|
|
|
18626
19224
|
// ../core/src/generated/tools/tool-read.ts
|
|
18627
|
-
import { readFileSync as
|
|
18628
|
-
import { resolve as
|
|
19225
|
+
import { readFileSync as readFileSync17, statSync as statSync11, existsSync as existsSync13 } from "fs";
|
|
19226
|
+
import { resolve as resolve11, relative as relative4 } from "path";
|
|
18629
19227
|
function formatWithLineNumbers(text, startLine) {
|
|
18630
19228
|
const lines = text.split("\n");
|
|
18631
19229
|
return lines.map((line, i) => {
|
|
@@ -18663,9 +19261,9 @@ function createReadTool() {
|
|
|
18663
19261
|
return null;
|
|
18664
19262
|
};
|
|
18665
19263
|
const checkPermission = (input, ctx) => {
|
|
18666
|
-
const filePath =
|
|
18667
|
-
const rel =
|
|
18668
|
-
if (rel.startsWith("..") ||
|
|
19264
|
+
const filePath = resolve11(ctx.cwd, input.file_path);
|
|
19265
|
+
const rel = relative4(ctx.cwd, filePath);
|
|
19266
|
+
if (rel.startsWith("..") || resolve11(ctx.cwd, rel) !== filePath) {
|
|
18669
19267
|
return {
|
|
18670
19268
|
behavior: "deny",
|
|
18671
19269
|
message: `Read denied: ${filePath} is outside the working directory`,
|
|
@@ -18675,7 +19273,7 @@ function createReadTool() {
|
|
|
18675
19273
|
return { behavior: "allow" };
|
|
18676
19274
|
};
|
|
18677
19275
|
const execute = async (input, ctx) => {
|
|
18678
|
-
const filePath =
|
|
19276
|
+
const filePath = resolve11(ctx.cwd, input.file_path);
|
|
18679
19277
|
if (ctx.virtualFs) {
|
|
18680
19278
|
const vfsContent = ctx.virtualFs.read(filePath);
|
|
18681
19279
|
if (vfsContent === null) {
|
|
@@ -18687,12 +19285,12 @@ function createReadTool() {
|
|
|
18687
19285
|
const sliced2 = limit2 !== void 0 ? lines2.slice(offset2, offset2 + limit2) : lines2.slice(offset2);
|
|
18688
19286
|
return { ok: true, content: sliced2.join("\n") };
|
|
18689
19287
|
}
|
|
18690
|
-
if (!
|
|
19288
|
+
if (!existsSync13(filePath)) {
|
|
18691
19289
|
return { ok: false, content: "", error: `File not found: ${filePath}` };
|
|
18692
19290
|
}
|
|
18693
19291
|
let mtime;
|
|
18694
19292
|
try {
|
|
18695
|
-
const stat =
|
|
19293
|
+
const stat = statSync11(filePath);
|
|
18696
19294
|
mtime = stat.mtimeMs;
|
|
18697
19295
|
} catch (err) {
|
|
18698
19296
|
return { ok: false, content: "", error: `Cannot stat file: ${err instanceof Error ? err.message : String(err)}` };
|
|
@@ -18708,7 +19306,7 @@ function createReadTool() {
|
|
|
18708
19306
|
}
|
|
18709
19307
|
let fullContent;
|
|
18710
19308
|
try {
|
|
18711
|
-
fullContent =
|
|
19309
|
+
fullContent = readFileSync17(filePath, "utf-8");
|
|
18712
19310
|
} catch (err) {
|
|
18713
19311
|
return { ok: false, content: "", error: `Cannot read file: ${err instanceof Error ? err.message : String(err)}` };
|
|
18714
19312
|
}
|
|
@@ -18739,8 +19337,8 @@ function createReadTool() {
|
|
|
18739
19337
|
}
|
|
18740
19338
|
|
|
18741
19339
|
// ../core/src/generated/tools/tool-edit.ts
|
|
18742
|
-
import { readFileSync as
|
|
18743
|
-
import { resolve as
|
|
19340
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync14, statSync as statSync12, existsSync as existsSync14 } from "fs";
|
|
19341
|
+
import { resolve as resolve12, relative as relative5 } from "path";
|
|
18744
19342
|
function normalizeCurlyQuotes(text) {
|
|
18745
19343
|
return text.replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"');
|
|
18746
19344
|
}
|
|
@@ -18796,9 +19394,9 @@ function createEditTool() {
|
|
|
18796
19394
|
reason: "exploration-mode"
|
|
18797
19395
|
};
|
|
18798
19396
|
}
|
|
18799
|
-
const filePath =
|
|
18800
|
-
const rel =
|
|
18801
|
-
if (rel.startsWith("..") ||
|
|
19397
|
+
const filePath = resolve12(ctx.cwd, input.file_path);
|
|
19398
|
+
const rel = relative5(ctx.cwd, filePath);
|
|
19399
|
+
if (rel.startsWith("..") || resolve12(ctx.cwd, rel) !== filePath) {
|
|
18802
19400
|
return {
|
|
18803
19401
|
behavior: "deny",
|
|
18804
19402
|
message: `Edit denied: ${filePath} is outside the working directory`,
|
|
@@ -18808,7 +19406,7 @@ function createEditTool() {
|
|
|
18808
19406
|
return { behavior: "allow" };
|
|
18809
19407
|
};
|
|
18810
19408
|
const execute = async (input, ctx) => {
|
|
18811
|
-
const filePath =
|
|
19409
|
+
const filePath = resolve12(ctx.cwd, input.file_path);
|
|
18812
19410
|
const oldString = input.old_string;
|
|
18813
19411
|
const newString = input.new_string;
|
|
18814
19412
|
const replaceAll = input.replace_all ?? false;
|
|
@@ -18824,7 +19422,7 @@ function createEditTool() {
|
|
|
18824
19422
|
ctx.virtualFs.write(filePath, updated);
|
|
18825
19423
|
return { ok: true, content: `Edited ${filePath} in VirtualFS` };
|
|
18826
19424
|
}
|
|
18827
|
-
if (!
|
|
19425
|
+
if (!existsSync14(filePath)) {
|
|
18828
19426
|
return { ok: false, content: "", error: `File not found: ${filePath}` };
|
|
18829
19427
|
}
|
|
18830
19428
|
const cache = ctx.readFileState;
|
|
@@ -18837,7 +19435,7 @@ function createEditTool() {
|
|
|
18837
19435
|
}
|
|
18838
19436
|
let mtime;
|
|
18839
19437
|
try {
|
|
18840
|
-
const stat =
|
|
19438
|
+
const stat = statSync12(filePath);
|
|
18841
19439
|
mtime = stat.mtimeMs;
|
|
18842
19440
|
} catch (err) {
|
|
18843
19441
|
return { ok: false, content: "", error: `Cannot stat file: ${err instanceof Error ? err.message : String(err)}` };
|
|
@@ -18852,7 +19450,7 @@ function createEditTool() {
|
|
|
18852
19450
|
}
|
|
18853
19451
|
let content;
|
|
18854
19452
|
try {
|
|
18855
|
-
content =
|
|
19453
|
+
content = readFileSync18(filePath, "utf-8");
|
|
18856
19454
|
} catch (err) {
|
|
18857
19455
|
return { ok: false, content: "", error: `Cannot read file: ${err instanceof Error ? err.message : String(err)}` };
|
|
18858
19456
|
}
|
|
@@ -18885,15 +19483,15 @@ function createEditTool() {
|
|
|
18885
19483
|
};
|
|
18886
19484
|
}
|
|
18887
19485
|
}
|
|
18888
|
-
const relPath =
|
|
19486
|
+
const relPath = relative5(ctx.cwd, filePath);
|
|
18889
19487
|
const snapshot = takeSnapshot(`Edit: ${relPath}`, ctx.cwd, [relPath]);
|
|
18890
19488
|
const newContent = replaceAll ? content.split(searchString).join(newString) : content.replace(searchString, newString);
|
|
18891
19489
|
try {
|
|
18892
|
-
|
|
19490
|
+
writeFileSync14(filePath, newContent, "utf-8");
|
|
18893
19491
|
} catch (err) {
|
|
18894
19492
|
return { ok: false, content: "", error: `Failed to write file: ${err instanceof Error ? err.message : String(err)}` };
|
|
18895
19493
|
}
|
|
18896
|
-
const newMtime =
|
|
19494
|
+
const newMtime = statSync12(filePath).mtimeMs;
|
|
18897
19495
|
cache.set(filePath, {
|
|
18898
19496
|
content: newContent,
|
|
18899
19497
|
timestamp: newMtime,
|
|
@@ -18912,8 +19510,8 @@ function createEditTool() {
|
|
|
18912
19510
|
}
|
|
18913
19511
|
|
|
18914
19512
|
// ../core/src/generated/tools/tool-write.ts
|
|
18915
|
-
import { writeFileSync as
|
|
18916
|
-
import { resolve as
|
|
19513
|
+
import { writeFileSync as writeFileSync15, statSync as statSync13, existsSync as existsSync15, mkdirSync as mkdirSync14 } from "fs";
|
|
19514
|
+
import { resolve as resolve13, dirname as dirname9, relative as relative6 } from "path";
|
|
18917
19515
|
function createWriteTool() {
|
|
18918
19516
|
const definition = {
|
|
18919
19517
|
name: "Write",
|
|
@@ -18947,9 +19545,9 @@ function createWriteTool() {
|
|
|
18947
19545
|
reason: "exploration-mode"
|
|
18948
19546
|
};
|
|
18949
19547
|
}
|
|
18950
|
-
const filePath =
|
|
18951
|
-
const rel =
|
|
18952
|
-
if (rel.startsWith("..") ||
|
|
19548
|
+
const filePath = resolve13(ctx.cwd, input.file_path);
|
|
19549
|
+
const rel = relative6(ctx.cwd, filePath);
|
|
19550
|
+
if (rel.startsWith("..") || resolve13(ctx.cwd, rel) !== filePath) {
|
|
18953
19551
|
return {
|
|
18954
19552
|
behavior: "deny",
|
|
18955
19553
|
message: `Write denied: ${filePath} is outside the working directory`,
|
|
@@ -18959,15 +19557,15 @@ function createWriteTool() {
|
|
|
18959
19557
|
return { behavior: "allow" };
|
|
18960
19558
|
};
|
|
18961
19559
|
const execute = async (input, ctx) => {
|
|
18962
|
-
const filePath =
|
|
19560
|
+
const filePath = resolve13(ctx.cwd, input.file_path);
|
|
18963
19561
|
const content = input.content;
|
|
18964
|
-
const relPath =
|
|
19562
|
+
const relPath = relative6(ctx.cwd, filePath);
|
|
18965
19563
|
const cache = ctx.readFileState;
|
|
18966
19564
|
if (ctx.virtualFs) {
|
|
18967
19565
|
ctx.virtualFs.write(filePath, content);
|
|
18968
19566
|
return { ok: true, content: `Wrote ${filePath} in VirtualFS (${content.split("\n").length} lines)` };
|
|
18969
19567
|
}
|
|
18970
|
-
const fileExists =
|
|
19568
|
+
const fileExists = existsSync15(filePath);
|
|
18971
19569
|
let snapshot = null;
|
|
18972
19570
|
if (fileExists) {
|
|
18973
19571
|
if (!cache.has(filePath)) {
|
|
@@ -18979,7 +19577,7 @@ function createWriteTool() {
|
|
|
18979
19577
|
}
|
|
18980
19578
|
let mtime;
|
|
18981
19579
|
try {
|
|
18982
|
-
const stat =
|
|
19580
|
+
const stat = statSync13(filePath);
|
|
18983
19581
|
mtime = stat.mtimeMs;
|
|
18984
19582
|
} catch (err) {
|
|
18985
19583
|
return { ok: false, content: "", error: `Cannot stat file: ${err instanceof Error ? err.message : String(err)}` };
|
|
@@ -18996,20 +19594,20 @@ function createWriteTool() {
|
|
|
18996
19594
|
} else {
|
|
18997
19595
|
snapshot = takeSnapshot(`Write (new): ${relPath}`, ctx.cwd, [relPath]);
|
|
18998
19596
|
}
|
|
18999
|
-
const parentDir =
|
|
19000
|
-
if (!
|
|
19597
|
+
const parentDir = dirname9(filePath);
|
|
19598
|
+
if (!existsSync15(parentDir)) {
|
|
19001
19599
|
try {
|
|
19002
|
-
|
|
19600
|
+
mkdirSync14(parentDir, { recursive: true });
|
|
19003
19601
|
} catch (err) {
|
|
19004
19602
|
return { ok: false, content: "", error: `Failed to create directory: ${err instanceof Error ? err.message : String(err)}` };
|
|
19005
19603
|
}
|
|
19006
19604
|
}
|
|
19007
19605
|
try {
|
|
19008
|
-
|
|
19606
|
+
writeFileSync15(filePath, content, "utf-8");
|
|
19009
19607
|
} catch (err) {
|
|
19010
19608
|
return { ok: false, content: "", error: `Failed to write file: ${err instanceof Error ? err.message : String(err)}` };
|
|
19011
19609
|
}
|
|
19012
|
-
const newMtime =
|
|
19610
|
+
const newMtime = statSync13(filePath).mtimeMs;
|
|
19013
19611
|
cache.set(filePath, {
|
|
19014
19612
|
content,
|
|
19015
19613
|
timestamp: newMtime,
|
|
@@ -19112,10 +19710,10 @@ function createBashTool() {
|
|
|
19112
19710
|
const readRedirect = tryRedirectToRead(command);
|
|
19113
19711
|
if (readRedirect) {
|
|
19114
19712
|
try {
|
|
19115
|
-
const { readFileSync:
|
|
19116
|
-
const { resolve:
|
|
19117
|
-
const filePath =
|
|
19118
|
-
const content =
|
|
19713
|
+
const { readFileSync: readFileSync33 } = await import("fs");
|
|
19714
|
+
const { resolve: resolve28 } = await import("path");
|
|
19715
|
+
const filePath = resolve28(ctx.cwd, readRedirect.file);
|
|
19716
|
+
const content = readFileSync33(filePath, "utf-8");
|
|
19119
19717
|
const lines = content.split("\n");
|
|
19120
19718
|
const offset = readRedirect.offset ?? 0;
|
|
19121
19719
|
const limit = readRedirect.limit ?? lines.length;
|
|
@@ -19415,7 +20013,7 @@ import { randomUUID as randomUUID3 } from "crypto";
|
|
|
19415
20013
|
|
|
19416
20014
|
// ../core/src/generated/blocks/file-state-cache.ts
|
|
19417
20015
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
19418
|
-
import { resolve as
|
|
20016
|
+
import { resolve as resolve14 } from "path";
|
|
19419
20017
|
var MAX_CACHE_ENTRIES = 100;
|
|
19420
20018
|
var MAX_CACHE_BYTES = 25 * 1024 * 1024;
|
|
19421
20019
|
function createTrackedFileStateMap(owner) {
|
|
@@ -19520,7 +20118,7 @@ var _projectCaches = /* @__PURE__ */ new Map();
|
|
|
19520
20118
|
var _projectFingerprintCache = /* @__PURE__ */ new Map();
|
|
19521
20119
|
var PROJECT_FINGERPRINT_TTL_MS = 1e3;
|
|
19522
20120
|
function projectCacheFingerprint(cwd) {
|
|
19523
|
-
const absCwd =
|
|
20121
|
+
const absCwd = resolve14(cwd || process.cwd());
|
|
19524
20122
|
const now = Date.now();
|
|
19525
20123
|
const cached2 = _projectFingerprintCache.get(absCwd);
|
|
19526
20124
|
if (cached2 && cached2.expires > now) return cached2.value;
|
|
@@ -19895,21 +20493,21 @@ function createTodoWriteTool() {
|
|
|
19895
20493
|
}
|
|
19896
20494
|
|
|
19897
20495
|
// ../core/src/generated/signals/auth-store.ts
|
|
19898
|
-
import { readFileSync as
|
|
19899
|
-
import { join as
|
|
20496
|
+
import { readFileSync as readFileSync19, writeFileSync as writeFileSync16, mkdirSync as mkdirSync15, existsSync as existsSync16, chmodSync } from "fs";
|
|
20497
|
+
import { join as join18, dirname as dirname10, resolve as resolve15 } from "path";
|
|
19900
20498
|
import { homedir as homedir9 } from "os";
|
|
19901
20499
|
function getAuthFile() {
|
|
19902
20500
|
const override = process.env.AGON_HOME?.trim();
|
|
19903
|
-
const home = override ?
|
|
19904
|
-
return
|
|
20501
|
+
const home = override ? resolve15(override) : join18(homedir9(), ".agon");
|
|
20502
|
+
return join18(home, "auth.json");
|
|
19905
20503
|
}
|
|
19906
20504
|
function loadAuthStore() {
|
|
19907
20505
|
const authFile = getAuthFile();
|
|
19908
|
-
if (!
|
|
20506
|
+
if (!existsSync16(authFile)) {
|
|
19909
20507
|
return { entries: {} };
|
|
19910
20508
|
}
|
|
19911
20509
|
try {
|
|
19912
|
-
const data = JSON.parse(
|
|
20510
|
+
const data = JSON.parse(readFileSync19(authFile, "utf-8"));
|
|
19913
20511
|
return { entries: data ?? {} };
|
|
19914
20512
|
} catch (e) {
|
|
19915
20513
|
return { entries: {} };
|
|
@@ -19917,9 +20515,9 @@ function loadAuthStore() {
|
|
|
19917
20515
|
}
|
|
19918
20516
|
function saveAuthStore(store) {
|
|
19919
20517
|
const authFile = getAuthFile();
|
|
19920
|
-
const dir =
|
|
19921
|
-
|
|
19922
|
-
|
|
20518
|
+
const dir = dirname10(authFile);
|
|
20519
|
+
mkdirSync15(dir, { recursive: true });
|
|
20520
|
+
writeFileSync16(authFile, JSON.stringify(store.entries, null, 2) + "\n", { mode: 384 });
|
|
19923
20521
|
try {
|
|
19924
20522
|
chmodSync(authFile, 384);
|
|
19925
20523
|
} catch (_e) {
|
|
@@ -20469,7 +21067,7 @@ function planEngineIsolation(engine, mode, opts) {
|
|
|
20469
21067
|
var fileStateCache = new FileStateCache();
|
|
20470
21068
|
|
|
20471
21069
|
// ../core/src/generated/tools/tool-permissions.ts
|
|
20472
|
-
import { resolve as
|
|
21070
|
+
import { resolve as resolve16, relative as relative7, isAbsolute as isAbsolute3 } from "path";
|
|
20473
21071
|
import { realpathSync as realpathSync3 } from "fs";
|
|
20474
21072
|
import { execSync as execSync3 } from "child_process";
|
|
20475
21073
|
var DANGEROUS_COMMANDS = ["rm -rf /", "rm -rf ~", "rm -rf *", "dd if" + String.fromCharCode(61), "mkfs.", "> /dev/sd", "> /dev/nv", "chmod 777 /", ":(){:|:&}\\x3b:"];
|
|
@@ -20524,7 +21122,7 @@ function checkBashPermission(command, ctx) {
|
|
|
20524
21122
|
return isDangerousCommand(command) ? { behavior: "deny", message: `Dangerous command blocked: ${command.slice(0, 50)}`, reason: "dangerous_pattern" } : ctx.permissionMode === "deny-all" ? { behavior: "deny", message: "All tool execution is denied" } : ctx.toolPermissions?.["Bash"] === "allow" ? { behavior: "allow" } : ctx.toolPermissions?.["Bash"] === "deny" ? { behavior: "deny", message: "Bash denied in settings" } : isReadOnlyCommand(command) ? { behavior: "allow" } : ctx.allowedCommands?.some((ac) => command.startsWith(ac) || command.trim().split(/\s+/)[0] === ac) ? { behavior: "allow" } : ctx.permissionMode === "smart" ? isSessionAllowed(command, ctx) || ctx.source === "orchestrator" ? { behavior: "allow" } : { behavior: "ask", message: `This command requires approval`, reason: "bash_mutating" } : ctx.permissionMode === "auto" ? { behavior: "allow" } : { behavior: "ask", message: `This command requires approval`, reason: "bash_mutating" };
|
|
20525
21123
|
}
|
|
20526
21124
|
function isPathUnderCwd(filePath, cwd) {
|
|
20527
|
-
const resolved =
|
|
21125
|
+
const resolved = isAbsolute3(filePath) ? filePath : resolve16(cwd, filePath);
|
|
20528
21126
|
let realPath;
|
|
20529
21127
|
let realCwd;
|
|
20530
21128
|
try {
|
|
@@ -20537,7 +21135,7 @@ function isPathUnderCwd(filePath, cwd) {
|
|
|
20537
21135
|
} catch {
|
|
20538
21136
|
realCwd = cwd;
|
|
20539
21137
|
}
|
|
20540
|
-
const rel =
|
|
21138
|
+
const rel = relative7(realCwd, realPath);
|
|
20541
21139
|
return !rel.startsWith("..");
|
|
20542
21140
|
}
|
|
20543
21141
|
function checkFileReadPermission(filePath, ctx) {
|
|
@@ -20547,7 +21145,7 @@ function checkFileReadPermission(filePath, ctx) {
|
|
|
20547
21145
|
if (ctx.toolPermissions?.["Read"] === "deny") {
|
|
20548
21146
|
return { behavior: "deny", message: "Read denied in settings" };
|
|
20549
21147
|
}
|
|
20550
|
-
const readResolved =
|
|
21148
|
+
const readResolved = isAbsolute3(filePath) ? filePath : resolve16(ctx.cwd, filePath);
|
|
20551
21149
|
if (isPathUnderCwd(readResolved, ctx.cwd)) {
|
|
20552
21150
|
return { behavior: "allow" };
|
|
20553
21151
|
}
|
|
@@ -20572,11 +21170,11 @@ function checkFileWritePermission(filePath, ctx) {
|
|
|
20572
21170
|
return { behavior: "ask", message: `Edit requires approval: ${filePath}` };
|
|
20573
21171
|
}
|
|
20574
21172
|
}
|
|
20575
|
-
const writeResolved =
|
|
20576
|
-
const
|
|
21173
|
+
const writeResolved = isAbsolute3(filePath) ? filePath : resolve16(ctx.cwd, filePath);
|
|
21174
|
+
const basename7 = writeResolved.split("/").pop() ?? "";
|
|
20577
21175
|
const sensitivePatterns = [".env", "credentials", "secrets", ".pem", ".key", "id_rsa"];
|
|
20578
|
-
if (sensitivePatterns.some((pat) =>
|
|
20579
|
-
return { behavior: "ask", message: `Write to sensitive file: ${
|
|
21176
|
+
if (sensitivePatterns.some((pat) => basename7.includes(pat))) {
|
|
21177
|
+
return { behavior: "ask", message: `Write to sensitive file: ${basename7}` };
|
|
20580
21178
|
}
|
|
20581
21179
|
if (isPathUnderCwd(writeResolved, ctx.cwd)) {
|
|
20582
21180
|
return { behavior: "allow" };
|
|
@@ -20936,6 +21534,39 @@ function createGoalTool() {
|
|
|
20936
21534
|
};
|
|
20937
21535
|
return { definition, validate, checkPermission, execute };
|
|
20938
21536
|
}
|
|
21537
|
+
function createConquerTool() {
|
|
21538
|
+
const definition = {
|
|
21539
|
+
name: "Conquer",
|
|
21540
|
+
description: "Delegate to the supervised-autonomous conquer controller \u2014 Cesar drives an external builder CLI (--builder codex|claude|agy, default codex) as the user, unattended, until an OPEN-ENDED build is done, then STOPS at a human merge gate (changes left in the tree or pushed to a branch; NEVER auto-merged). The gate command IS the done-spec \u2014 make it discriminating. Fire ONLY when the user explicitly asks to conquer / build unattended; it is a long multi-hour run. After calling, STOP and wait \u2014 runs in the background; track with /jobs or /focus.",
|
|
21541
|
+
inputSchema: {
|
|
21542
|
+
type: "object",
|
|
21543
|
+
properties: {
|
|
21544
|
+
task: { type: "string", description: "Open-ended build task to drive to completion (seeds the run + branch)." },
|
|
21545
|
+
gate: { type: "string", description: 'The done-spec: a discriminating test/verify command that proves the build is complete (e.g. "pnpm test"). Required \u2014 frozen at start.' },
|
|
21546
|
+
builder: { type: "string", description: "External builder CLI Cesar drives as the user: codex | claude | agy. Default codex." },
|
|
21547
|
+
engines: { type: "array", items: { type: "string" }, description: "Optional consult roster for fork escalations (nero/tribunal/council). Omit for active roster." },
|
|
21548
|
+
maxTurns: { type: "number", description: "Optional cap on builder turns (0/omit = controller default)." }
|
|
21549
|
+
},
|
|
21550
|
+
required: ["task", "gate"]
|
|
21551
|
+
},
|
|
21552
|
+
maxResultSizeChars: 500,
|
|
21553
|
+
isReadOnly: false,
|
|
21554
|
+
isConcurrencySafe: false
|
|
21555
|
+
};
|
|
21556
|
+
const validate = (input, _ctx) => {
|
|
21557
|
+
if (!input.task || typeof input.task !== "string" || !input.task.trim()) return "Missing required parameter: task";
|
|
21558
|
+
if (!input.gate || typeof input.gate !== "string" || !input.gate.trim()) return "Missing required parameter: gate (the done-spec test/verify command). Ask the user for the command that proves the build is done.";
|
|
21559
|
+
if (input.engines !== void 0 && (!Array.isArray(input.engines) || !input.engines.every((e) => typeof e === "string" && e.trim().length > 0))) return "engines must be an array of non-empty engine ID strings";
|
|
21560
|
+
return null;
|
|
21561
|
+
};
|
|
21562
|
+
const checkPermission = (_input, _ctx) => {
|
|
21563
|
+
return { behavior: "allow" };
|
|
21564
|
+
};
|
|
21565
|
+
const execute = async (_input, _ctx) => {
|
|
21566
|
+
return { ok: true, content: "Delegation accepted. STOP responding now. The orchestrator will handle the rest." };
|
|
21567
|
+
};
|
|
21568
|
+
return { definition, validate, checkPermission, execute };
|
|
21569
|
+
}
|
|
20939
21570
|
function createPipelineTool() {
|
|
20940
21571
|
const definition = {
|
|
20941
21572
|
name: "Pipeline",
|
|
@@ -21094,8 +21725,8 @@ function createExitPlanModeTool() {
|
|
|
21094
21725
|
}
|
|
21095
21726
|
|
|
21096
21727
|
// ../core/src/generated/cesar/plan.ts
|
|
21097
|
-
import { mkdirSync as
|
|
21098
|
-
import { join as
|
|
21728
|
+
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync17, readFileSync as readFileSync20, readdirSync as readdirSync12, renameSync as renameSync10, unlinkSync as unlinkSync7, existsSync as existsSync17 } from "fs";
|
|
21729
|
+
import { join as join19, resolve as resolve17 } from "path";
|
|
21099
21730
|
function getCesarPlansDir() {
|
|
21100
21731
|
return runtimeAgonPath("plans");
|
|
21101
21732
|
}
|
|
@@ -21108,16 +21739,16 @@ function safeCesarPlanId(planId) {
|
|
|
21108
21739
|
}
|
|
21109
21740
|
function cesarPlanJsonPath(planId) {
|
|
21110
21741
|
const plansDir = getCesarPlansDir();
|
|
21111
|
-
const full =
|
|
21112
|
-
if (!full.startsWith(
|
|
21742
|
+
const full = resolve17(plansDir, `${safeCesarPlanId(planId)}.json`);
|
|
21743
|
+
if (!full.startsWith(resolve17(plansDir))) {
|
|
21113
21744
|
throw new Error(`Invalid plan ID: ${planId}`);
|
|
21114
21745
|
}
|
|
21115
21746
|
return full;
|
|
21116
21747
|
}
|
|
21117
21748
|
function cesarPlanMarkdownPath(planId) {
|
|
21118
21749
|
const plansDir = getCesarPlansDir();
|
|
21119
|
-
const full =
|
|
21120
|
-
if (!full.startsWith(
|
|
21750
|
+
const full = resolve17(plansDir, `${safeCesarPlanId(planId)}.md`);
|
|
21751
|
+
if (!full.startsWith(resolve17(plansDir))) {
|
|
21121
21752
|
throw new Error(`Invalid plan ID: ${planId}`);
|
|
21122
21753
|
}
|
|
21123
21754
|
return full;
|
|
@@ -21202,7 +21833,7 @@ function exitCesarPlan(plan, reason) {
|
|
|
21202
21833
|
}
|
|
21203
21834
|
function saveCesarPlan(plan) {
|
|
21204
21835
|
const dir = getCesarPlansDir();
|
|
21205
|
-
|
|
21836
|
+
mkdirSync16(dir, { recursive: true });
|
|
21206
21837
|
const finalPath = cesarPlanJsonPath(plan.id);
|
|
21207
21838
|
const persistedPlan = {
|
|
21208
21839
|
...plan,
|
|
@@ -21210,7 +21841,7 @@ function saveCesarPlan(plan) {
|
|
|
21210
21841
|
};
|
|
21211
21842
|
const tmpPath = `${finalPath}.${process.pid}.${Date.now()}.tmp`;
|
|
21212
21843
|
try {
|
|
21213
|
-
|
|
21844
|
+
writeFileSync17(tmpPath, JSON.stringify(persistedPlan, null, 2));
|
|
21214
21845
|
renameSync10(tmpPath, finalPath);
|
|
21215
21846
|
} catch (err) {
|
|
21216
21847
|
try {
|
|
@@ -21230,9 +21861,9 @@ function loadCesarPlan(planId) {
|
|
|
21230
21861
|
const paths = [{ filePath: cesarPlanJsonPath(safeId), canonical: true }, { filePath: runtimeAgonPath("runs", `${safeId}.json`), canonical: false }];
|
|
21231
21862
|
for (const entry of paths) {
|
|
21232
21863
|
try {
|
|
21233
|
-
const plan = JSON.parse(
|
|
21864
|
+
const plan = JSON.parse(readFileSync20(entry.filePath, "utf-8"));
|
|
21234
21865
|
const fallbackMarkdownPath = cesarPlanMarkdownPath(plan.id);
|
|
21235
|
-
const hasFallback = entry.canonical ||
|
|
21866
|
+
const hasFallback = entry.canonical || existsSync17(fallbackMarkdownPath);
|
|
21236
21867
|
const fallbackPath = hasFallback ? fallbackMarkdownPath : void 0;
|
|
21237
21868
|
const planFilePath = plan.planFilePath ?? fallbackPath;
|
|
21238
21869
|
return planFilePath ? { ...plan, planFilePath } : plan;
|
|
@@ -21246,16 +21877,16 @@ function listCesarPlans() {
|
|
|
21246
21877
|
const readFromDir = (dir, canonical) => {
|
|
21247
21878
|
let files = [];
|
|
21248
21879
|
try {
|
|
21249
|
-
files =
|
|
21880
|
+
files = readdirSync12(dir).filter((f) => f.startsWith("cplan-") && f.endsWith(".json"));
|
|
21250
21881
|
} catch {
|
|
21251
21882
|
return;
|
|
21252
21883
|
}
|
|
21253
21884
|
for (const f of files) {
|
|
21254
21885
|
try {
|
|
21255
|
-
const plan = JSON.parse(
|
|
21886
|
+
const plan = JSON.parse(readFileSync20(join19(dir, f), "utf-8"));
|
|
21256
21887
|
if (!plan?.id || byId.has(plan.id)) continue;
|
|
21257
21888
|
const fallbackMarkdownPath = cesarPlanMarkdownPath(plan.id);
|
|
21258
|
-
const planFilePath = plan.planFilePath ?? (canonical ||
|
|
21889
|
+
const planFilePath = plan.planFilePath ?? (canonical || existsSync17(fallbackMarkdownPath) ? fallbackMarkdownPath : void 0);
|
|
21259
21890
|
byId.set(plan.id, planFilePath ? { ...plan, planFilePath } : plan);
|
|
21260
21891
|
} catch {
|
|
21261
21892
|
}
|
|
@@ -21404,15 +22035,15 @@ function formatCesarPlanMarkdown(plan) {
|
|
|
21404
22035
|
}
|
|
21405
22036
|
|
|
21406
22037
|
// ../core/src/generated/tools/mcp-discovery.ts
|
|
21407
|
-
import { readFileSync as
|
|
21408
|
-
import { join as
|
|
22038
|
+
import { readFileSync as readFileSync21, existsSync as existsSync18, statSync as statSync14 } from "fs";
|
|
22039
|
+
import { join as join20 } from "path";
|
|
21409
22040
|
import { homedir as homedir10 } from "os";
|
|
21410
22041
|
function _readJsonSafe(path) {
|
|
21411
22042
|
try {
|
|
21412
|
-
if (!
|
|
22043
|
+
if (!existsSync18(path)) {
|
|
21413
22044
|
return null;
|
|
21414
22045
|
}
|
|
21415
|
-
return JSON.parse(
|
|
22046
|
+
return JSON.parse(readFileSync21(path, "utf-8"));
|
|
21416
22047
|
} catch (e) {
|
|
21417
22048
|
return null;
|
|
21418
22049
|
}
|
|
@@ -21445,31 +22076,31 @@ function _extractMcpServers(data) {
|
|
|
21445
22076
|
function discoverMcpServers(cwd) {
|
|
21446
22077
|
const home = homedir10();
|
|
21447
22078
|
const servers = /* @__PURE__ */ new Map();
|
|
21448
|
-
const claudeSettings = _readJsonSafe(
|
|
22079
|
+
const claudeSettings = _readJsonSafe(join20(home, ".claude", "settings.json"));
|
|
21449
22080
|
if (claudeSettings) {
|
|
21450
22081
|
for (const s of _extractMcpServers(claudeSettings)) {
|
|
21451
22082
|
servers.set(s.name, s);
|
|
21452
22083
|
}
|
|
21453
22084
|
}
|
|
21454
|
-
const claudeLocal = _readJsonSafe(
|
|
22085
|
+
const claudeLocal = _readJsonSafe(join20(home, ".claude", "settings.local.json"));
|
|
21455
22086
|
if (claudeLocal) {
|
|
21456
22087
|
for (const s of _extractMcpServers(claudeLocal)) {
|
|
21457
22088
|
servers.set(s.name, s);
|
|
21458
22089
|
}
|
|
21459
22090
|
}
|
|
21460
|
-
const vscodeMcp = _readJsonSafe(
|
|
22091
|
+
const vscodeMcp = _readJsonSafe(join20(cwd, ".vscode", "mcp.json"));
|
|
21461
22092
|
if (vscodeMcp) {
|
|
21462
22093
|
for (const s of _extractMcpServers(vscodeMcp)) {
|
|
21463
22094
|
servers.set(s.name, s);
|
|
21464
22095
|
}
|
|
21465
22096
|
}
|
|
21466
|
-
const cursorMcp = _readJsonSafe(
|
|
22097
|
+
const cursorMcp = _readJsonSafe(join20(cwd, ".cursor", "mcp.json"));
|
|
21467
22098
|
if (cursorMcp) {
|
|
21468
22099
|
for (const s of _extractMcpServers(cursorMcp)) {
|
|
21469
22100
|
servers.set(s.name, s);
|
|
21470
22101
|
}
|
|
21471
22102
|
}
|
|
21472
|
-
const agonProject = _readJsonSafe(
|
|
22103
|
+
const agonProject = _readJsonSafe(join20(cwd, ".agon.json"));
|
|
21473
22104
|
if (agonProject) {
|
|
21474
22105
|
for (const s of _extractMcpServers(agonProject)) {
|
|
21475
22106
|
servers.set(s.name, s);
|
|
@@ -21479,12 +22110,12 @@ function discoverMcpServers(cwd) {
|
|
|
21479
22110
|
}
|
|
21480
22111
|
function mcpDiscoveryFingerprint(cwd) {
|
|
21481
22112
|
const home = homedir10();
|
|
21482
|
-
const paths = [
|
|
22113
|
+
const paths = [join20(home, ".claude", "settings.json"), join20(home, ".claude", "settings.local.json"), join20(cwd, ".vscode", "mcp.json"), join20(cwd, ".cursor", "mcp.json"), join20(cwd, ".agon.json")];
|
|
21483
22114
|
const parts = [];
|
|
21484
22115
|
for (const p of paths) {
|
|
21485
22116
|
try {
|
|
21486
|
-
if (
|
|
21487
|
-
parts.push(`${p}:${
|
|
22117
|
+
if (existsSync18(p)) {
|
|
22118
|
+
parts.push(`${p}:${statSync14(p).mtimeMs}`);
|
|
21488
22119
|
}
|
|
21489
22120
|
} catch (e) {
|
|
21490
22121
|
}
|
|
@@ -21502,13 +22133,13 @@ function mcpServersToWireFormat(servers) {
|
|
|
21502
22133
|
}
|
|
21503
22134
|
|
|
21504
22135
|
// ../core/src/generated/signals/chat-store.ts
|
|
21505
|
-
import { mkdirSync as
|
|
21506
|
-
import { join as
|
|
22136
|
+
import { mkdirSync as mkdirSync17, appendFileSync, readFileSync as readFileSync22, readdirSync as readdirSync13, statSync as statSync15, unlinkSync as unlinkSync8 } from "fs";
|
|
22137
|
+
import { join as join21 } from "path";
|
|
21507
22138
|
function chatsDir() {
|
|
21508
22139
|
return runtimeAgonPath("chats");
|
|
21509
22140
|
}
|
|
21510
22141
|
function ensureChatsDir() {
|
|
21511
|
-
|
|
22142
|
+
mkdirSync17(chatsDir(), { recursive: true });
|
|
21512
22143
|
}
|
|
21513
22144
|
var CHAT_RETENTION = 50;
|
|
21514
22145
|
var CHAT_SUMMARY_TAIL_MESSAGES = 12;
|
|
@@ -21517,7 +22148,7 @@ var CHAT_SUMMARY_ENTRY_CHARS = 320;
|
|
|
21517
22148
|
function pruneChats() {
|
|
21518
22149
|
try {
|
|
21519
22150
|
const dir = chatsDir();
|
|
21520
|
-
const files =
|
|
22151
|
+
const files = readdirSync13(dir).filter((f) => f.endsWith(".ndjson")).map((f) => {
|
|
21521
22152
|
const ts = parseInt(f.replace("chat-", "").replace(".ndjson", ""), 10);
|
|
21522
22153
|
return { name: f, ts: isNaN(ts) ? 0 : ts };
|
|
21523
22154
|
}).sort((a, b) => b.ts - a.ts);
|
|
@@ -21525,7 +22156,7 @@ function pruneChats() {
|
|
|
21525
22156
|
const toRemove = files.slice(CHAT_RETENTION);
|
|
21526
22157
|
for (const f of toRemove) {
|
|
21527
22158
|
try {
|
|
21528
|
-
unlinkSync8(
|
|
22159
|
+
unlinkSync8(join21(dir, f.name));
|
|
21529
22160
|
} catch {
|
|
21530
22161
|
}
|
|
21531
22162
|
}
|
|
@@ -21537,7 +22168,7 @@ function startChatSession(opts) {
|
|
|
21537
22168
|
pruneChats();
|
|
21538
22169
|
const id = `chat-${Date.now()}`;
|
|
21539
22170
|
const session = { id, startedAt: (/* @__PURE__ */ new Date()).toISOString(), messages: [], cwd: opts?.cwd, branch: opts?.branch, engineIds: opts?.engineIds };
|
|
21540
|
-
const filePath =
|
|
22171
|
+
const filePath = join21(chatsDir(), `${id}.ndjson`);
|
|
21541
22172
|
const header = { _type: "header", id, startedAt: session.startedAt };
|
|
21542
22173
|
if (opts?.cwd) {
|
|
21543
22174
|
header.cwd = opts.cwd;
|
|
@@ -21553,7 +22184,7 @@ function startChatSession(opts) {
|
|
|
21553
22184
|
}
|
|
21554
22185
|
function appendMessage(session, msg) {
|
|
21555
22186
|
session.messages.push(msg);
|
|
21556
|
-
const filePath =
|
|
22187
|
+
const filePath = join21(chatsDir(), `${session.id}.ndjson`);
|
|
21557
22188
|
appendFileSync(filePath, JSON.stringify(msg) + "\n");
|
|
21558
22189
|
if (updateChatSummary(session)) {
|
|
21559
22190
|
appendSummaryRecord(session);
|
|
@@ -21573,7 +22204,7 @@ function appendUserTurnIfAbsent(session, input) {
|
|
|
21573
22204
|
}
|
|
21574
22205
|
const msg = { role: "user", content: input, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
21575
22206
|
session.messages.push(msg);
|
|
21576
|
-
const filePath =
|
|
22207
|
+
const filePath = join21(chatsDir(), `${session.id}.ndjson`);
|
|
21577
22208
|
appendFileSync(filePath, JSON.stringify(msg) + "\n");
|
|
21578
22209
|
if (updateChatSummary(session)) {
|
|
21579
22210
|
appendSummaryRecord(session);
|
|
@@ -21608,7 +22239,7 @@ function trimChatSummary(summary) {
|
|
|
21608
22239
|
return text.slice(0, head).trimEnd() + marker + text.slice(text.length - tail).trimStart();
|
|
21609
22240
|
}
|
|
21610
22241
|
function appendSummaryRecord(session) {
|
|
21611
|
-
const filePath =
|
|
22242
|
+
const filePath = join21(chatsDir(), `${session.id}.ndjson`);
|
|
21612
22243
|
appendFileSync(filePath, JSON.stringify({ _type: "summary", summary: session.summary ?? "", summarizedMessageCount: session.summarizedMessageCount ?? 0, timestamp: (/* @__PURE__ */ new Date()).toISOString() }) + "\n");
|
|
21613
22244
|
}
|
|
21614
22245
|
function freeSummarizedMessageBodies(messages, from, to) {
|
|
@@ -21719,8 +22350,8 @@ function buildHistoryPrimedPrompt(session, input, maxTurns) {
|
|
|
21719
22350
|
}
|
|
21720
22351
|
function loadChatSession(id) {
|
|
21721
22352
|
try {
|
|
21722
|
-
const filePath =
|
|
21723
|
-
const raw =
|
|
22353
|
+
const filePath = join21(chatsDir(), `${id}.ndjson`);
|
|
22354
|
+
const raw = readFileSync22(filePath, "utf-8");
|
|
21724
22355
|
const lines = raw.trim().split("\n").filter(Boolean);
|
|
21725
22356
|
if (lines.length === 0) return null;
|
|
21726
22357
|
const header = JSON.parse(lines[0]);
|
|
@@ -21761,9 +22392,9 @@ function listChatSessions(limit) {
|
|
|
21761
22392
|
ensureChatsDir();
|
|
21762
22393
|
try {
|
|
21763
22394
|
const dir = chatsDir();
|
|
21764
|
-
const files =
|
|
22395
|
+
const files = readdirSync13(dir).filter((f) => f.endsWith(".ndjson")).map((f) => ({
|
|
21765
22396
|
name: f,
|
|
21766
|
-
mtime:
|
|
22397
|
+
mtime: statSync15(join21(dir, f)).mtimeMs
|
|
21767
22398
|
})).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
|
|
21768
22399
|
return files.map((f) => {
|
|
21769
22400
|
const id = f.name.replace(".ndjson", "");
|
|
@@ -21780,8 +22411,8 @@ function latestChatSession() {
|
|
|
21780
22411
|
}
|
|
21781
22412
|
|
|
21782
22413
|
// ../core/src/generated/blocks/image.ts
|
|
21783
|
-
import { existsSync as
|
|
21784
|
-
import { resolve as
|
|
22414
|
+
import { existsSync as existsSync19 } from "fs";
|
|
22415
|
+
import { resolve as resolve19, basename as basename4, extname as extname2 } from "path";
|
|
21785
22416
|
import { homedir as homedir11 } from "os";
|
|
21786
22417
|
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".bmp"]);
|
|
21787
22418
|
var MIME_MAP = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp", ".svg": "image/svg+xml", ".bmp": "image/bmp" };
|
|
@@ -21798,20 +22429,20 @@ function mimeFromExt(filePath) {
|
|
|
21798
22429
|
function resolveImagePath(rawPath, cwd) {
|
|
21799
22430
|
let resolved;
|
|
21800
22431
|
if (rawPath.startsWith("~/")) {
|
|
21801
|
-
resolved =
|
|
22432
|
+
resolved = resolve19(homedir11(), rawPath.slice(2));
|
|
21802
22433
|
} else if (rawPath.startsWith("/")) {
|
|
21803
|
-
resolved =
|
|
22434
|
+
resolved = resolve19(rawPath);
|
|
21804
22435
|
} else {
|
|
21805
|
-
resolved =
|
|
22436
|
+
resolved = resolve19(cwd, rawPath);
|
|
21806
22437
|
}
|
|
21807
|
-
return
|
|
22438
|
+
return existsSync19(resolved) ? resolved : null;
|
|
21808
22439
|
}
|
|
21809
22440
|
function buildImageAttachment(rawPath, cwd) {
|
|
21810
22441
|
const resolved = resolveImagePath(rawPath.trim(), cwd);
|
|
21811
22442
|
if (!resolved) {
|
|
21812
22443
|
return null;
|
|
21813
22444
|
}
|
|
21814
|
-
return { path: resolved, filename:
|
|
22445
|
+
return { path: resolved, filename: basename4(resolved), mimeType: mimeFromExt(resolved) };
|
|
21815
22446
|
}
|
|
21816
22447
|
function extractImagesFromInput(input, cwd) {
|
|
21817
22448
|
const images = [];
|
|
@@ -21841,31 +22472,31 @@ function extractImagesFromInput(input, cwd) {
|
|
|
21841
22472
|
}
|
|
21842
22473
|
|
|
21843
22474
|
// ../core/src/generated/signals/flow.ts
|
|
21844
|
-
import { readFileSync as
|
|
21845
|
-
import { join as
|
|
22475
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync19, mkdirSync as mkdirSync18, readdirSync as readdirSync14 } from "fs";
|
|
22476
|
+
import { join as join22, resolve as resolve20 } from "path";
|
|
21846
22477
|
import { homedir as homedir12 } from "os";
|
|
21847
22478
|
function getFlowsDir() {
|
|
21848
22479
|
const override = process.env.AGON_HOME?.trim();
|
|
21849
|
-
const home = override ?
|
|
21850
|
-
return
|
|
22480
|
+
const home = override ? resolve20(override) : join22(homedir12(), ".agon");
|
|
22481
|
+
return join22(home, "flows");
|
|
21851
22482
|
}
|
|
21852
22483
|
var FLOWS_DIR = getFlowsDir();
|
|
21853
22484
|
var FRICTION_TAGS = ["slow", "wrong-mode", "engine-error", "unclear-output", "timeout", "context-lost", "other"];
|
|
21854
22485
|
function ensureFlowsDir() {
|
|
21855
|
-
|
|
22486
|
+
mkdirSync18(getFlowsDir(), { recursive: true });
|
|
21856
22487
|
}
|
|
21857
22488
|
function logFlow(record2) {
|
|
21858
22489
|
ensureFlowsDir();
|
|
21859
22490
|
const filename = `flow-${record2.id}.json`;
|
|
21860
|
-
const filepath =
|
|
21861
|
-
|
|
22491
|
+
const filepath = join22(getFlowsDir(), filename);
|
|
22492
|
+
writeFileSync19(filepath, JSON.stringify(record2, null, 2));
|
|
21862
22493
|
return filepath;
|
|
21863
22494
|
}
|
|
21864
22495
|
function readFlows(limit) {
|
|
21865
22496
|
ensureFlowsDir();
|
|
21866
22497
|
let files;
|
|
21867
22498
|
try {
|
|
21868
|
-
files =
|
|
22499
|
+
files = readdirSync14(getFlowsDir()).filter((f) => f.startsWith("flow-") && f.endsWith(".json")).sort().reverse();
|
|
21869
22500
|
} catch (err) {
|
|
21870
22501
|
console.warn(`[agon] failed to read flows directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
21871
22502
|
return [];
|
|
@@ -21874,7 +22505,7 @@ function readFlows(limit) {
|
|
|
21874
22505
|
const records = [];
|
|
21875
22506
|
for (const file2 of files) {
|
|
21876
22507
|
try {
|
|
21877
|
-
const data = JSON.parse(
|
|
22508
|
+
const data = JSON.parse(readFileSync23(join22(getFlowsDir(), file2), "utf-8"));
|
|
21878
22509
|
records.push(data);
|
|
21879
22510
|
} catch (err) {
|
|
21880
22511
|
console.warn(`[agon] skipping malformed flow record ${file2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -21939,13 +22570,13 @@ async function companionDispatch(opts) {
|
|
|
21939
22570
|
const startTime = Date.now();
|
|
21940
22571
|
if (!isAcp && !isStreamJson) {
|
|
21941
22572
|
const checkAvailable = () => {
|
|
21942
|
-
return new Promise((
|
|
22573
|
+
return new Promise((resolve28) => {
|
|
21943
22574
|
const check2 = spawn2(opts.binaryPath, ["app-server", "--help"], {
|
|
21944
22575
|
stdio: "pipe",
|
|
21945
22576
|
timeout: 5e3
|
|
21946
22577
|
});
|
|
21947
|
-
check2.on("close", (code) =>
|
|
21948
|
-
check2.on("error", () =>
|
|
22578
|
+
check2.on("close", (code) => resolve28(code === 0));
|
|
22579
|
+
check2.on("error", () => resolve28(false));
|
|
21949
22580
|
});
|
|
21950
22581
|
};
|
|
21951
22582
|
const available = await checkAvailable();
|
|
@@ -21963,10 +22594,10 @@ async function companionDispatch(opts) {
|
|
|
21963
22594
|
detached: true
|
|
21964
22595
|
});
|
|
21965
22596
|
let procClosed = false;
|
|
21966
|
-
const procClosedPromise = new Promise((
|
|
22597
|
+
const procClosedPromise = new Promise((resolve28) => {
|
|
21967
22598
|
proc.once("close", () => {
|
|
21968
22599
|
procClosed = true;
|
|
21969
|
-
|
|
22600
|
+
resolve28();
|
|
21970
22601
|
});
|
|
21971
22602
|
});
|
|
21972
22603
|
let nextId = 1;
|
|
@@ -21994,7 +22625,7 @@ async function companionDispatch(opts) {
|
|
|
21994
22625
|
return normalized;
|
|
21995
22626
|
}
|
|
21996
22627
|
function writeStdin(line) {
|
|
21997
|
-
return new Promise((
|
|
22628
|
+
return new Promise((resolve28, reject) => {
|
|
21998
22629
|
if (stdinError) {
|
|
21999
22630
|
reject(stdinError);
|
|
22000
22631
|
return;
|
|
@@ -22006,7 +22637,7 @@ async function companionDispatch(opts) {
|
|
|
22006
22637
|
}
|
|
22007
22638
|
stdin.write(line, (err) => {
|
|
22008
22639
|
if (err) reject(setStdinError(err));
|
|
22009
|
-
else
|
|
22640
|
+
else resolve28();
|
|
22010
22641
|
});
|
|
22011
22642
|
});
|
|
22012
22643
|
}
|
|
@@ -22141,12 +22772,12 @@ async function companionDispatch(opts) {
|
|
|
22141
22772
|
function send(method, params) {
|
|
22142
22773
|
const id = nextId++;
|
|
22143
22774
|
const timeoutMs = method === "initialize" ? 8e3 : opts.timeout * 1e3;
|
|
22144
|
-
return new Promise((
|
|
22775
|
+
return new Promise((resolve28, reject) => {
|
|
22145
22776
|
const timer = setTimeout(() => {
|
|
22146
22777
|
pending.delete(id);
|
|
22147
22778
|
reject(new Error(`Timeout waiting for ${method}`));
|
|
22148
22779
|
}, timeoutMs);
|
|
22149
|
-
pending.set(id, { resolve:
|
|
22780
|
+
pending.set(id, { resolve: resolve28, reject, timer });
|
|
22150
22781
|
void writeStdin(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n").catch((err) => {
|
|
22151
22782
|
pending.delete(id);
|
|
22152
22783
|
clearTimeout(timer);
|
|
@@ -22158,7 +22789,7 @@ async function companionDispatch(opts) {
|
|
|
22158
22789
|
fireWriteStdin(JSON.stringify({ jsonrpc: "2.0", method }) + "\n");
|
|
22159
22790
|
}
|
|
22160
22791
|
function sleep(ms) {
|
|
22161
|
-
return new Promise((
|
|
22792
|
+
return new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
22162
22793
|
}
|
|
22163
22794
|
function killProc(signal = "SIGTERM") {
|
|
22164
22795
|
if (procClosed) return;
|
|
@@ -22186,10 +22817,10 @@ async function companionDispatch(opts) {
|
|
|
22186
22817
|
}
|
|
22187
22818
|
function waitForTurnComplete() {
|
|
22188
22819
|
const deadline = Date.now() + opts.timeout * 1e3;
|
|
22189
|
-
return new Promise((
|
|
22820
|
+
return new Promise((resolve28, reject) => {
|
|
22190
22821
|
const check2 = () => {
|
|
22191
22822
|
if (turnCompleted) {
|
|
22192
|
-
|
|
22823
|
+
resolve28();
|
|
22193
22824
|
return;
|
|
22194
22825
|
}
|
|
22195
22826
|
if (turnError) {
|
|
@@ -22303,19 +22934,19 @@ async function companionDispatch(opts) {
|
|
|
22303
22934
|
}
|
|
22304
22935
|
|
|
22305
22936
|
// ../core/src/generated/signals/models-registry.ts
|
|
22306
|
-
import { readFileSync as
|
|
22307
|
-
import { join as
|
|
22937
|
+
import { readFileSync as readFileSync24, writeFileSync as writeFileSync20, mkdirSync as mkdirSync19, existsSync as existsSync20, statSync as statSync16 } from "fs";
|
|
22938
|
+
import { join as join23 } from "path";
|
|
22308
22939
|
var CACHE_TTL_MS = 36e5;
|
|
22309
22940
|
var MODELS_DEV_URL = "https://models.dev/api.json";
|
|
22310
22941
|
async function fetchModelsRegistry() {
|
|
22311
22942
|
const cacheDir = getCacheDir();
|
|
22312
|
-
const cacheFile =
|
|
22313
|
-
if (
|
|
22943
|
+
const cacheFile = join23(cacheDir, "models-dev.json");
|
|
22944
|
+
if (existsSync20(cacheFile)) {
|
|
22314
22945
|
try {
|
|
22315
|
-
const stat =
|
|
22946
|
+
const stat = statSync16(cacheFile);
|
|
22316
22947
|
const age = Date.now() - stat.mtimeMs;
|
|
22317
22948
|
if (age < CACHE_TTL_MS) {
|
|
22318
|
-
return JSON.parse(
|
|
22949
|
+
return JSON.parse(readFileSync24(cacheFile, "utf-8"));
|
|
22319
22950
|
}
|
|
22320
22951
|
} catch (_e) {
|
|
22321
22952
|
console.warn(`[agon] models-registry: cache read failed, refetching: ${_e instanceof Error ? _e.message : String(_e)}`);
|
|
@@ -22323,14 +22954,14 @@ async function fetchModelsRegistry() {
|
|
|
22323
22954
|
}
|
|
22324
22955
|
const response = await fetch(MODELS_DEV_URL);
|
|
22325
22956
|
if (!response.ok) {
|
|
22326
|
-
if (
|
|
22327
|
-
return JSON.parse(
|
|
22957
|
+
if (existsSync20(cacheFile)) {
|
|
22958
|
+
return JSON.parse(readFileSync24(cacheFile, "utf-8"));
|
|
22328
22959
|
}
|
|
22329
22960
|
throw new Error(`Failed to fetch models registry: ${response.status}`);
|
|
22330
22961
|
}
|
|
22331
22962
|
const data = await response.json();
|
|
22332
|
-
|
|
22333
|
-
|
|
22963
|
+
mkdirSync19(cacheDir, { recursive: true });
|
|
22964
|
+
writeFileSync20(cacheFile, JSON.stringify(data));
|
|
22334
22965
|
return data;
|
|
22335
22966
|
}
|
|
22336
22967
|
function resolveModelFormat(providerNpm, model) {
|
|
@@ -22432,7 +23063,8 @@ function searchModels(entries, query) {
|
|
|
22432
23063
|
});
|
|
22433
23064
|
return scored.map((s) => s.entry);
|
|
22434
23065
|
}
|
|
22435
|
-
function normalizeBaseUrl(url2) {
|
|
23066
|
+
function normalizeBaseUrl(url2, format) {
|
|
23067
|
+
if (format === "anthropic") return url2;
|
|
22436
23068
|
try {
|
|
22437
23069
|
const parsed = new URL(url2);
|
|
22438
23070
|
if (parsed.pathname.startsWith("/anthropic/") || parsed.pathname === "/anthropic") {
|
|
@@ -22445,29 +23077,29 @@ function normalizeBaseUrl(url2) {
|
|
|
22445
23077
|
}
|
|
22446
23078
|
}
|
|
22447
23079
|
function modelEntryToEngineDef(entry) {
|
|
22448
|
-
return { schemaVersion: 3, id: `${entry.providerId}-${entry.modelId}`.replace(/[^a-zA-Z0-9._-]/g, "-").toLowerCase(), displayName: `${entry.providerName} \u2014 ${entry.modelName}`, isLocal: false, tier: "user", timeout: 180, exec: { args: [] }, review: { args: [] }, api: { baseUrl: normalizeBaseUrl(entry.baseUrl), apiKeyEnv: entry.apiKeyEnv, model: entry.modelId, maxTokens: Math.min(entry.contextWindow ? Math.floor(entry.contextWindow / 4) : 4096, 16384), format: entry.format ?? "openai" } };
|
|
23080
|
+
return { schemaVersion: 3, id: `${entry.providerId}-${entry.modelId}`.replace(/[^a-zA-Z0-9._-]/g, "-").toLowerCase(), displayName: `${entry.providerName} \u2014 ${entry.modelName}`, isLocal: false, tier: "user", timeout: 180, exec: { args: [] }, review: { args: [] }, api: { baseUrl: normalizeBaseUrl(entry.baseUrl, entry.format ?? "openai"), apiKeyEnv: entry.apiKeyEnv, model: entry.modelId, maxTokens: Math.min(entry.contextWindow ? Math.floor(entry.contextWindow / 4) : 4096, 16384), format: entry.format ?? "openai" } };
|
|
22449
23081
|
}
|
|
22450
23082
|
|
|
22451
23083
|
// ../core/src/generated/signals/cli-models-registry.ts
|
|
22452
23084
|
import { execSync as execSync4 } from "child_process";
|
|
22453
|
-
import { readFileSync as
|
|
22454
|
-
import { join as
|
|
23085
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, existsSync as existsSync21, statSync as statSync17 } from "fs";
|
|
23086
|
+
import { join as join24 } from "path";
|
|
22455
23087
|
import { homedir as homedir13 } from "os";
|
|
22456
|
-
import { createRequire as
|
|
23088
|
+
import { createRequire as createRequire3 } from "module";
|
|
22457
23089
|
var ENGINE_PROVIDER_MAP = { anthropic: { providerId: "anthropic", engineId: "claude", engineBinary: "claude", versionCmd: ["--version"], listCmd: ["__pty:/model"], effortLevels: ["low", "medium", "high", "xhigh", "max"] }, openai: { providerId: "openai", engineId: "codex", engineBinary: "codex", versionCmd: ["--version"], listCmd: ["__pty:/model"], effortLevels: ["low", "medium", "high", "xhigh"] }, google: { providerId: "google", engineId: "agy", engineBinary: "agy", versionCmd: ["--version"], listCmd: ["__pty:/model"] }, opencode: { providerId: "opencode", engineId: "opencode", engineBinary: "opencode", versionCmd: ["--version"], listCmd: ["models"] }, mistral: { providerId: "mistral", engineId: "mistral", engineBinary: "mistral", versionCmd: ["--version"] }, openrouter: { providerId: "openrouter", engineId: "openrouter", engineBinary: "openrouter", versionCmd: [] } };
|
|
22458
23090
|
var ENGINE_DISPLAY_NAMES = { claude: "Claude", codex: "Codex", agy: "Antigravity", opencode: "OpenCode", mistral: "Mistral", openrouter: "OpenRouter" };
|
|
22459
23091
|
var FALLBACK_MODELS = { anthropic: [{ id: "claude-sonnet-4-5-20250929", name: "Claude Sonnet 4.5", contextWindow: 2e5, toolCall: true, reasoning: true }, { id: "claude-haiku-4-5-20251001", name: "Claude Haiku 4.5", contextWindow: 2e5, toolCall: true, reasoning: true }], openai: [{ id: "gpt-4o", name: "GPT-4o", contextWindow: 128e3, toolCall: true, reasoning: false }, { id: "o4-mini", name: "o4-mini", contextWindow: 2e5, toolCall: true, reasoning: true }], google: [{ id: "gemini-3.5-flash", name: "Gemini 3.5 Flash", contextWindow: 1048576, toolCall: true, reasoning: true }, { id: "gemini-3.1-pro", name: "Gemini 3.1 Pro", contextWindow: 1048576, toolCall: true, reasoning: true }, { id: "gemini-3-flash-preview", name: "Gemini 3 Flash", contextWindow: 1048576, toolCall: true, reasoning: true }], mistral: [{ id: "mistral-large-latest", name: "Mistral Large", contextWindow: 128e3, toolCall: true, reasoning: false }, { id: "codestral-latest", name: "Codestral", contextWindow: 256e3, toolCall: true, reasoning: false }], openrouter: [{ id: "auto", name: "Auto (best for task)", toolCall: true, reasoning: false }], opencode: [{ id: "anthropic/claude-sonnet-4", name: "anthropic/claude-sonnet-4", toolCall: true, reasoning: false }, { id: "openai/gpt-5.3-codex", name: "openai/gpt-5.3-codex", toolCall: true, reasoning: false }] };
|
|
22460
23092
|
var PROBE_TTL_MS = 864e5;
|
|
22461
23093
|
function probedModelsCacheFile(engineId) {
|
|
22462
|
-
return
|
|
23094
|
+
return join24(getCacheDir(), `cli-models-${engineId.replace(/[^a-zA-Z0-9_-]/g, "-")}.json`);
|
|
22463
23095
|
}
|
|
22464
23096
|
function readProbedCliModels(engineId, ttlMs) {
|
|
22465
23097
|
try {
|
|
22466
23098
|
const file2 = probedModelsCacheFile(engineId);
|
|
22467
|
-
if (!
|
|
22468
|
-
const age = Date.now() -
|
|
23099
|
+
if (!existsSync21(file2)) return null;
|
|
23100
|
+
const age = Date.now() - statSync17(file2).mtimeMs;
|
|
22469
23101
|
if (age > (ttlMs ?? PROBE_TTL_MS)) return null;
|
|
22470
|
-
const data = JSON.parse(
|
|
23102
|
+
const data = JSON.parse(readFileSync25(file2, "utf-8"));
|
|
22471
23103
|
const raw = Array.isArray(data?.models) ? data.models : [];
|
|
22472
23104
|
const models = raw.map((m) => ({ id: String(m.id ?? ""), name: String(m.name ?? m.id ?? ""), current: !!m.current })).filter((m) => m.name);
|
|
22473
23105
|
return models.length > 0 ? models : null;
|
|
@@ -22477,7 +23109,7 @@ function readProbedCliModels(engineId, ttlMs) {
|
|
|
22477
23109
|
}
|
|
22478
23110
|
function resolveModelProbeScript() {
|
|
22479
23111
|
try {
|
|
22480
|
-
const req =
|
|
23112
|
+
const req = createRequire3(import.meta.url);
|
|
22481
23113
|
const anchor = req.resolve("@kernlang/agon-engines/cli/claude.js");
|
|
22482
23114
|
const candidates = [
|
|
22483
23115
|
// Canonical: the package ships the probe at py/kern_engines/cli/ (see
|
|
@@ -22485,16 +23117,16 @@ function resolveModelProbeScript() {
|
|
|
22485
23117
|
// to the package root, then into py/. This is the path that actually
|
|
22486
23118
|
// exists — the dist/cli & root/cli guesses below never matched, so the
|
|
22487
23119
|
// probe silently never ran and every engine fell back to its static list.
|
|
22488
|
-
|
|
23120
|
+
join24(anchor, "..", "..", "..", "py", "kern_engines", "cli", "model_probe.py"),
|
|
22489
23121
|
// dist/cli → root → py/kern_engines/cli
|
|
22490
|
-
|
|
23122
|
+
join24(anchor, "..", "..", "py", "kern_engines", "cli", "model_probe.py"),
|
|
22491
23123
|
// (alt layout: cli/claude.js → root)
|
|
22492
|
-
|
|
22493
|
-
|
|
22494
|
-
|
|
23124
|
+
join24(anchor, "..", "..", "..", "cli", "model_probe.py"),
|
|
23125
|
+
join24(anchor, "..", "..", "cli", "model_probe.py"),
|
|
23126
|
+
join24(anchor, "..", "model_probe.py")
|
|
22495
23127
|
];
|
|
22496
23128
|
for (const c of candidates) {
|
|
22497
|
-
if (
|
|
23129
|
+
if (existsSync21(c)) return c;
|
|
22498
23130
|
}
|
|
22499
23131
|
return null;
|
|
22500
23132
|
} catch {
|
|
@@ -22564,8 +23196,8 @@ async function refreshProbedCliModels(engineId, binary, listCmd, pythonBin) {
|
|
|
22564
23196
|
return false;
|
|
22565
23197
|
}
|
|
22566
23198
|
const dir = getCacheDir();
|
|
22567
|
-
|
|
22568
|
-
|
|
23199
|
+
mkdirSync20(dir, { recursive: true });
|
|
23200
|
+
writeFileSync21(probedModelsCacheFile(engineId), JSON.stringify({ ts: Date.now(), engineId, models }));
|
|
22569
23201
|
return true;
|
|
22570
23202
|
} catch (e) {
|
|
22571
23203
|
dbg(`probe threw: ${e?.message ?? e}`);
|
|
@@ -22581,10 +23213,10 @@ function findBinary(binary) {
|
|
|
22581
23213
|
} catch (e) {
|
|
22582
23214
|
}
|
|
22583
23215
|
const home = homedir13();
|
|
22584
|
-
const searchPaths = [
|
|
23216
|
+
const searchPaths = [join24(home, ".local", "bin"), join24(home, ".npm-global", "bin"), "/usr/local/bin"];
|
|
22585
23217
|
for (const dir of searchPaths) {
|
|
22586
|
-
const fullPath =
|
|
22587
|
-
if (
|
|
23218
|
+
const fullPath = join24(dir, binary);
|
|
23219
|
+
if (existsSync21(fullPath)) {
|
|
22588
23220
|
return fullPath;
|
|
22589
23221
|
}
|
|
22590
23222
|
}
|
|
@@ -22601,6 +23233,29 @@ function getBinaryVersion(binary, versionCmd) {
|
|
|
22601
23233
|
return null;
|
|
22602
23234
|
}
|
|
22603
23235
|
}
|
|
23236
|
+
var VERSION_CACHE = /* @__PURE__ */ new Map();
|
|
23237
|
+
async function getBinaryVersionAsync(engineId, binary, versionCmd) {
|
|
23238
|
+
if (!versionCmd.length) return null;
|
|
23239
|
+
const cached2 = VERSION_CACHE.get(engineId);
|
|
23240
|
+
if (cached2) return cached2;
|
|
23241
|
+
try {
|
|
23242
|
+
const result = await spawnWithTimeout({ command: binary, args: versionCmd, cwd: process.cwd(), timeout: 5e3 });
|
|
23243
|
+
if (result.timedOut || result.exitCode !== 0) return null;
|
|
23244
|
+
const v = (result.stdout ?? "").trim() || null;
|
|
23245
|
+
if (v) VERSION_CACHE.set(engineId, v);
|
|
23246
|
+
return v;
|
|
23247
|
+
} catch {
|
|
23248
|
+
return null;
|
|
23249
|
+
}
|
|
23250
|
+
}
|
|
23251
|
+
async function refreshCliGroupVersion(engineId) {
|
|
23252
|
+
const entry = Object.entries(ENGINE_PROVIDER_MAP).find(([, e]) => e.engineId === engineId);
|
|
23253
|
+
if (!entry) return null;
|
|
23254
|
+
const [, eng] = entry;
|
|
23255
|
+
const binaryPath = findBinary(eng.engineBinary);
|
|
23256
|
+
if (!binaryPath) return null;
|
|
23257
|
+
return getBinaryVersionAsync(eng.engineId, binaryPath, eng.versionCmd);
|
|
23258
|
+
}
|
|
22604
23259
|
function buildCliModelGroups() {
|
|
22605
23260
|
const groups = [];
|
|
22606
23261
|
for (const [key, eng] of Object.entries(ENGINE_PROVIDER_MAP)) {
|
|
@@ -22626,7 +23281,7 @@ async function buildCliModelGroupsAsync() {
|
|
|
22626
23281
|
for (const [key, eng] of Object.entries(ENGINE_PROVIDER_MAP)) {
|
|
22627
23282
|
const binaryPath = findBinary(eng.engineBinary);
|
|
22628
23283
|
const installed = binaryPath !== null;
|
|
22629
|
-
const version2 = installed ?
|
|
23284
|
+
const version2 = installed ? await getBinaryVersionAsync(eng.engineId, binaryPath, eng.versionCmd) : null;
|
|
22630
23285
|
const displayName = ENGINE_DISPLAY_NAMES[eng.engineId] ?? eng.engineId.charAt(0).toUpperCase() + eng.engineId.slice(1);
|
|
22631
23286
|
const probed = readProbedCliModels(eng.engineId);
|
|
22632
23287
|
const models = probed && probed.length > 0 ? probed.map((m) => Object.assign({}, { id: m.id, name: m.name, providerId: eng.providerId, providerName: displayName, engineId: eng.engineId, engineBinary: eng.engineBinary, toolCall: true, reasoning: true })) : (FALLBACK_MODELS[key] ?? []).map((m) => Object.assign({}, { id: m.id, name: m.name, providerId: eng.providerId, providerName: displayName, engineId: eng.engineId, engineBinary: eng.engineBinary, contextWindow: m.contextWindow, toolCall: m.toolCall, reasoning: m.reasoning }));
|
|
@@ -22639,7 +23294,7 @@ function buildCliGroupsImmediate() {
|
|
|
22639
23294
|
for (const [key, eng] of Object.entries(ENGINE_PROVIDER_MAP)) {
|
|
22640
23295
|
const binaryPath = findBinary(eng.engineBinary);
|
|
22641
23296
|
const installed = binaryPath !== null;
|
|
22642
|
-
const version2 = installed ?
|
|
23297
|
+
const version2 = installed ? VERSION_CACHE.get(eng.engineId) ?? null : null;
|
|
22643
23298
|
const displayName = ENGINE_DISPLAY_NAMES[eng.engineId] ?? eng.engineId.charAt(0).toUpperCase() + eng.engineId.slice(1);
|
|
22644
23299
|
const probed = readProbedCliModels(eng.engineId);
|
|
22645
23300
|
const probeCapable = Array.isArray(eng.listCmd) && eng.listCmd.length > 0;
|
|
@@ -22658,7 +23313,7 @@ async function refreshCliGroup(engineId) {
|
|
|
22658
23313
|
const probeCapable = Array.isArray(eng.listCmd) && eng.listCmd.length > 0;
|
|
22659
23314
|
if (!installed || !probeCapable) return null;
|
|
22660
23315
|
const displayName = ENGINE_DISPLAY_NAMES[eng.engineId] ?? eng.engineId.charAt(0).toUpperCase() + eng.engineId.slice(1);
|
|
22661
|
-
const version2 =
|
|
23316
|
+
const version2 = await getBinaryVersionAsync(eng.engineId, binaryPath, eng.versionCmd);
|
|
22662
23317
|
try {
|
|
22663
23318
|
await refreshProbedCliModels(eng.engineId, binaryPath, eng.listCmd);
|
|
22664
23319
|
} catch {
|
|
@@ -22705,12 +23360,12 @@ function createCompanionSession(config2) {
|
|
|
22705
23360
|
function sendRpc(method, params) {
|
|
22706
23361
|
const id = nextRpcId++;
|
|
22707
23362
|
const timeoutMs = method === "initialize" ? 8e3 : 9e4;
|
|
22708
|
-
return new Promise((
|
|
23363
|
+
return new Promise((resolve28, reject) => {
|
|
22709
23364
|
const timer = setTimeout(() => {
|
|
22710
23365
|
pending.delete(id);
|
|
22711
23366
|
reject(new Error(`Timeout waiting for ${method}`));
|
|
22712
23367
|
}, timeoutMs);
|
|
22713
|
-
pending.set(id, { resolve:
|
|
23368
|
+
pending.set(id, { resolve: resolve28, reject, timer });
|
|
22714
23369
|
proc.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
|
22715
23370
|
});
|
|
22716
23371
|
}
|
|
@@ -23035,12 +23690,12 @@ function createAcpSession(config2) {
|
|
|
23035
23690
|
function sendRpc(method, params) {
|
|
23036
23691
|
const id = nextRpcId++;
|
|
23037
23692
|
const timeoutMs = method === "initialize" ? 8e3 : 9e4;
|
|
23038
|
-
return new Promise((
|
|
23693
|
+
return new Promise((resolve28, reject) => {
|
|
23039
23694
|
const timer = setTimeout(() => {
|
|
23040
23695
|
pending.delete(id);
|
|
23041
23696
|
reject(new Error(`ACP timeout: ${method}`));
|
|
23042
23697
|
}, timeoutMs);
|
|
23043
|
-
pending.set(id, { resolve:
|
|
23698
|
+
pending.set(id, { resolve: resolve28, reject, timer });
|
|
23044
23699
|
proc.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
|
23045
23700
|
});
|
|
23046
23701
|
}
|
|
@@ -23486,16 +24141,16 @@ function createStreamJsonSession(config2) {
|
|
|
23486
24141
|
alive = false;
|
|
23487
24142
|
proc = null;
|
|
23488
24143
|
});
|
|
23489
|
-
const startOk = await new Promise((
|
|
23490
|
-
const timeout = setTimeout(() =>
|
|
24144
|
+
const startOk = await new Promise((resolve28) => {
|
|
24145
|
+
const timeout = setTimeout(() => resolve28(true), 5e3);
|
|
23491
24146
|
rl.once("line", () => {
|
|
23492
24147
|
clearTimeout(timeout);
|
|
23493
|
-
|
|
24148
|
+
resolve28(true);
|
|
23494
24149
|
});
|
|
23495
24150
|
proc.once("close", (code) => {
|
|
23496
24151
|
clearTimeout(timeout);
|
|
23497
24152
|
console.error(`[cesar:claude] process died during start, code=${code}`);
|
|
23498
|
-
|
|
24153
|
+
resolve28(false);
|
|
23499
24154
|
});
|
|
23500
24155
|
});
|
|
23501
24156
|
if (!startOk || !proc) {
|
|
@@ -24656,33 +25311,33 @@ function createStreamBridge(dispatch, opts) {
|
|
|
24656
25311
|
}
|
|
24657
25312
|
|
|
24658
25313
|
// ../core/src/generated/forge/virtual-fs.ts
|
|
24659
|
-
import { readFileSync as
|
|
24660
|
-
import { join as
|
|
24661
|
-
import { createHash as
|
|
25314
|
+
import { readFileSync as readFileSync26, existsSync as existsSync22, readdirSync as readdirSync15, statSync as statSync18 } from "fs";
|
|
25315
|
+
import { join as join25, resolve as resolve21, relative as relative8, dirname as dirname11 } from "path";
|
|
25316
|
+
import { createHash as createHash5 } from "crypto";
|
|
24662
25317
|
function createFileSnapshot(rootDir) {
|
|
24663
|
-
const snapshotId =
|
|
25318
|
+
const snapshotId = createHash5("sha256").update(rootDir + Date.now().toString()).digest("hex").slice(0, 12);
|
|
24664
25319
|
return {
|
|
24665
25320
|
snapshotId,
|
|
24666
|
-
rootDir:
|
|
25321
|
+
rootDir: resolve21(rootDir),
|
|
24667
25322
|
cache: /* @__PURE__ */ new Map()
|
|
24668
25323
|
};
|
|
24669
25324
|
}
|
|
24670
25325
|
function snapshotRead(snap, absPath) {
|
|
24671
|
-
const key =
|
|
25326
|
+
const key = resolve21(absPath);
|
|
24672
25327
|
if (snap.cache.has(key)) {
|
|
24673
25328
|
return snap.cache.get(key) ?? null;
|
|
24674
25329
|
}
|
|
24675
25330
|
try {
|
|
24676
|
-
if (!
|
|
25331
|
+
if (!existsSync22(key)) {
|
|
24677
25332
|
snap.cache.set(key, null);
|
|
24678
25333
|
return null;
|
|
24679
25334
|
}
|
|
24680
|
-
const st =
|
|
25335
|
+
const st = statSync18(key);
|
|
24681
25336
|
if (!st.isFile()) {
|
|
24682
25337
|
snap.cache.set(key, null);
|
|
24683
25338
|
return null;
|
|
24684
25339
|
}
|
|
24685
|
-
const content =
|
|
25340
|
+
const content = readFileSync26(key, "utf-8");
|
|
24686
25341
|
snap.cache.set(key, content);
|
|
24687
25342
|
return content;
|
|
24688
25343
|
} catch (e) {
|
|
@@ -24691,15 +25346,15 @@ function snapshotRead(snap, absPath) {
|
|
|
24691
25346
|
}
|
|
24692
25347
|
}
|
|
24693
25348
|
function snapshotList(snap, absDir) {
|
|
24694
|
-
const dir =
|
|
25349
|
+
const dir = resolve21(absDir);
|
|
24695
25350
|
try {
|
|
24696
|
-
return
|
|
25351
|
+
return readdirSync15(dir).filter((f) => {
|
|
24697
25352
|
try {
|
|
24698
|
-
return
|
|
25353
|
+
return statSync18(join25(dir, f)).isFile();
|
|
24699
25354
|
} catch {
|
|
24700
25355
|
return false;
|
|
24701
25356
|
}
|
|
24702
|
-
}).map((f) =>
|
|
25357
|
+
}).map((f) => join25(dir, f));
|
|
24703
25358
|
} catch {
|
|
24704
25359
|
return [];
|
|
24705
25360
|
}
|
|
@@ -24725,19 +25380,19 @@ var VirtualFS = class {
|
|
|
24725
25380
|
notifyChange(absPath) {
|
|
24726
25381
|
if (!this.onChange) return;
|
|
24727
25382
|
try {
|
|
24728
|
-
this.onChange(
|
|
25383
|
+
this.onChange(resolve21(absPath));
|
|
24729
25384
|
} catch {
|
|
24730
25385
|
}
|
|
24731
25386
|
}
|
|
24732
25387
|
read(absPath) {
|
|
24733
|
-
const key =
|
|
25388
|
+
const key = resolve21(absPath);
|
|
24734
25389
|
if (this.overlay.has(key)) {
|
|
24735
25390
|
return this.overlay.get(key) ?? null;
|
|
24736
25391
|
}
|
|
24737
25392
|
return snapshotRead(this.snapshot, key);
|
|
24738
25393
|
}
|
|
24739
25394
|
write(absPath, content) {
|
|
24740
|
-
const key =
|
|
25395
|
+
const key = resolve21(absPath);
|
|
24741
25396
|
const previous = this.overlay.has(key) ? this.overlay.get(key) ?? null : snapshotRead(this.snapshot, key);
|
|
24742
25397
|
this.overlay.set(key, content);
|
|
24743
25398
|
if (previous !== content) {
|
|
@@ -24745,7 +25400,7 @@ var VirtualFS = class {
|
|
|
24745
25400
|
}
|
|
24746
25401
|
}
|
|
24747
25402
|
delete(absPath) {
|
|
24748
|
-
const key =
|
|
25403
|
+
const key = resolve21(absPath);
|
|
24749
25404
|
const previous = this.overlay.has(key) ? this.overlay.get(key) ?? null : snapshotRead(this.snapshot, key);
|
|
24750
25405
|
this.overlay.set(key, null);
|
|
24751
25406
|
if (previous !== null) {
|
|
@@ -24753,19 +25408,19 @@ var VirtualFS = class {
|
|
|
24753
25408
|
}
|
|
24754
25409
|
}
|
|
24755
25410
|
exists(absPath) {
|
|
24756
|
-
const key =
|
|
25411
|
+
const key = resolve21(absPath);
|
|
24757
25412
|
if (this.overlay.has(key)) {
|
|
24758
25413
|
return this.overlay.get(key) !== null;
|
|
24759
25414
|
}
|
|
24760
25415
|
return snapshotRead(this.snapshot, key) !== null;
|
|
24761
25416
|
}
|
|
24762
25417
|
list(absDir) {
|
|
24763
|
-
const dir =
|
|
25418
|
+
const dir = resolve21(absDir);
|
|
24764
25419
|
const base = snapshotList(this.snapshot, dir);
|
|
24765
25420
|
const overlayWritten = [];
|
|
24766
25421
|
const overlayDeleted = /* @__PURE__ */ new Set();
|
|
24767
25422
|
for (const [path, content] of this.overlay.entries()) {
|
|
24768
|
-
if (
|
|
25423
|
+
if (dirname11(path) === dir) {
|
|
24769
25424
|
if (content === null) {
|
|
24770
25425
|
overlayDeleted.add(path);
|
|
24771
25426
|
} else {
|
|
@@ -24822,9 +25477,9 @@ function applyEffectPackage(pkg, targetDir) {
|
|
|
24822
25477
|
const import_fs = __require("fs");
|
|
24823
25478
|
const modified = [];
|
|
24824
25479
|
for (const effect of pkg.effects) {
|
|
24825
|
-
const absPath =
|
|
25480
|
+
const absPath = resolve21(targetDir, effect.kind === "rename" ? effect.from : effect.path);
|
|
24826
25481
|
if (effect.kind === "write") {
|
|
24827
|
-
const dir =
|
|
25482
|
+
const dir = dirname11(absPath);
|
|
24828
25483
|
import_fs.mkdirSync(dir, { recursive: true });
|
|
24829
25484
|
import_fs.writeFileSync(absPath, effect.content, "utf-8");
|
|
24830
25485
|
modified.push(absPath);
|
|
@@ -24835,8 +25490,8 @@ function applyEffectPackage(pkg, targetDir) {
|
|
|
24835
25490
|
}
|
|
24836
25491
|
modified.push(absPath);
|
|
24837
25492
|
} else if (effect.kind === "rename") {
|
|
24838
|
-
const dest =
|
|
24839
|
-
import_fs.mkdirSync(
|
|
25493
|
+
const dest = resolve21(targetDir, effect.to);
|
|
25494
|
+
import_fs.mkdirSync(dirname11(dest), { recursive: true });
|
|
24840
25495
|
import_fs.renameSync(absPath, dest);
|
|
24841
25496
|
modified.push(absPath);
|
|
24842
25497
|
modified.push(dest);
|
|
@@ -24845,13 +25500,13 @@ function applyEffectPackage(pkg, targetDir) {
|
|
|
24845
25500
|
return modified;
|
|
24846
25501
|
}
|
|
24847
25502
|
function relocateEffectPackage(pkg, fromDir, toDir) {
|
|
24848
|
-
const fromRoot =
|
|
24849
|
-
const toRoot =
|
|
25503
|
+
const fromRoot = resolve21(fromDir);
|
|
25504
|
+
const toRoot = resolve21(toDir);
|
|
24850
25505
|
const relocatePath = (path) => {
|
|
24851
|
-
const abs =
|
|
24852
|
-
const rel =
|
|
24853
|
-
if (rel.startsWith("..") ||
|
|
24854
|
-
return
|
|
25506
|
+
const abs = resolve21(path);
|
|
25507
|
+
const rel = relative8(fromRoot, abs);
|
|
25508
|
+
if (rel.startsWith("..") || resolve21(fromRoot, rel) !== abs) return abs;
|
|
25509
|
+
return resolve21(toRoot, rel);
|
|
24855
25510
|
};
|
|
24856
25511
|
const effects = pkg.effects.map((effect) => {
|
|
24857
25512
|
if (effect.kind === "write") {
|
|
@@ -24914,7 +25569,7 @@ function scoreEffectPackage(pkg, taskKeywords) {
|
|
|
24914
25569
|
|
|
24915
25570
|
// ../core/src/generated/cesar/speculator.ts
|
|
24916
25571
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
24917
|
-
import { resolve as
|
|
25572
|
+
import { resolve as resolve22, join as join26 } from "path";
|
|
24918
25573
|
var Speculator = class {
|
|
24919
25574
|
runId;
|
|
24920
25575
|
snapshot;
|
|
@@ -24923,7 +25578,7 @@ var Speculator = class {
|
|
|
24923
25578
|
this.snapshot = null;
|
|
24924
25579
|
}
|
|
24925
25580
|
async run(opts) {
|
|
24926
|
-
const cwd =
|
|
25581
|
+
const cwd = resolve22(opts.cwd);
|
|
24927
25582
|
const isolate = opts.isolate !== false;
|
|
24928
25583
|
const root = isolate ? repoRoot(cwd) : cwd;
|
|
24929
25584
|
this.snapshot = createFileSnapshot(cwd);
|
|
@@ -24936,7 +25591,7 @@ var Speculator = class {
|
|
|
24936
25591
|
if (isolate) {
|
|
24937
25592
|
const baseSha = stashSnapshot(root);
|
|
24938
25593
|
for (const member of opts.members) {
|
|
24939
|
-
const wtPath =
|
|
25594
|
+
const wtPath = join26(root, `.agon/speculate-worktrees/${this.runId}/${member.engineId}`);
|
|
24940
25595
|
try {
|
|
24941
25596
|
await worktreeCreate(root, wtPath, baseSha);
|
|
24942
25597
|
worktreesByEngine[member.engineId] = wtPath;
|
|
@@ -25109,26 +25764,26 @@ ${sessionLines.join("\n")}`);
|
|
|
25109
25764
|
}
|
|
25110
25765
|
|
|
25111
25766
|
// ../core/src/generated/cesar/context-thread.ts
|
|
25112
|
-
import { readFileSync as
|
|
25113
|
-
import { join as
|
|
25114
|
-
import { randomUUID as randomUUID5, createHash as
|
|
25767
|
+
import { readFileSync as readFileSync27, writeFileSync as writeFileSync22, mkdirSync as mkdirSync21, renameSync as renameSync11, existsSync as existsSync23, readdirSync as readdirSync16, unlinkSync as unlinkSync9, statSync as statSync19, chmodSync as chmodSync2, openSync, fsyncSync, closeSync, appendFileSync as appendFileSync2 } from "fs";
|
|
25768
|
+
import { join as join27, resolve as resolve23, basename as basename6 } from "path";
|
|
25769
|
+
import { randomUUID as randomUUID5, createHash as createHash6 } from "crypto";
|
|
25115
25770
|
import { homedir as homedir14 } from "os";
|
|
25116
25771
|
function threadsDir() {
|
|
25117
25772
|
const override = process.env.AGON_HOME?.trim();
|
|
25118
|
-
const home = override ?
|
|
25119
|
-
return
|
|
25773
|
+
const home = override ? resolve23(override) : join27(homedir14(), ".agon");
|
|
25774
|
+
return join27(home, "threads");
|
|
25120
25775
|
}
|
|
25121
25776
|
function activePointerPath() {
|
|
25122
|
-
return
|
|
25777
|
+
return join27(threadsDir(), "active.json");
|
|
25123
25778
|
}
|
|
25124
25779
|
function projectHash16(projectPath) {
|
|
25125
|
-
return
|
|
25780
|
+
return createHash6("sha256").update(projectPath).digest("hex").slice(0, 16);
|
|
25126
25781
|
}
|
|
25127
25782
|
function projectSha8(projectPath) {
|
|
25128
25783
|
return projectHash16(projectPath);
|
|
25129
25784
|
}
|
|
25130
25785
|
function threadDirFor(projectPath) {
|
|
25131
|
-
return
|
|
25786
|
+
return join27(threadsDir(), projectHash16(projectPath));
|
|
25132
25787
|
}
|
|
25133
25788
|
var THREAD_ID_RE = /^(thread_\d{10,16}_[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;
|
|
25134
25789
|
function threadJournalPath(projectPath, threadId) {
|
|
@@ -25139,9 +25794,9 @@ function threadFilePath(projectPath, threadId) {
|
|
|
25139
25794
|
throw new Error(`Invalid threadId: ${threadId}`);
|
|
25140
25795
|
}
|
|
25141
25796
|
const dir = threadDirFor(projectPath);
|
|
25142
|
-
const full =
|
|
25143
|
-
const resolvedDir =
|
|
25144
|
-
const nativeSep =
|
|
25797
|
+
const full = resolve23(dir, `${threadId}.json`);
|
|
25798
|
+
const resolvedDir = resolve23(dir);
|
|
25799
|
+
const nativeSep = join27("a", "b")[1];
|
|
25145
25800
|
const isContained = full === resolvedDir || full.startsWith(resolvedDir + "/") || full.startsWith(resolvedDir + nativeSep);
|
|
25146
25801
|
if (!isContained) {
|
|
25147
25802
|
throw new Error(`Invalid thread path (traversal attempt): ${threadId}`);
|
|
@@ -25150,7 +25805,7 @@ function threadFilePath(projectPath, threadId) {
|
|
|
25150
25805
|
}
|
|
25151
25806
|
function ensureThreadDir(projectPath) {
|
|
25152
25807
|
ensureAgonHome();
|
|
25153
|
-
|
|
25808
|
+
mkdirSync21(threadDirFor(projectPath), { recursive: true });
|
|
25154
25809
|
}
|
|
25155
25810
|
var LOCK_MAX_RETRIES = 8;
|
|
25156
25811
|
var LOCK_BASE_DELAY_MS = 20;
|
|
@@ -25161,7 +25816,7 @@ async function acquireLock(lockPath) {
|
|
|
25161
25816
|
for (let attempt = 0; attempt < LOCK_MAX_RETRIES; attempt++) {
|
|
25162
25817
|
try {
|
|
25163
25818
|
const fd = openSync(lockPath, "wx", 384);
|
|
25164
|
-
|
|
25819
|
+
writeFileSync22(fd, String(process.pid));
|
|
25165
25820
|
closeSync(fd);
|
|
25166
25821
|
return attempt;
|
|
25167
25822
|
} catch (err) {
|
|
@@ -25210,7 +25865,7 @@ var SECRET_PATTERNS = [
|
|
|
25210
25865
|
var SECRET_PATH_BLOCKLIST = [".env", ".env.local", ".env.production", ".env.staging", ".env.development", "credentials.json", "secrets.json", "auth.json", ".ssh/id_rsa", ".ssh/id_ed25519", ".ssh/id_ecdsa", ".aws/credentials", ".docker/config.json", ".netrc", ".pgpass", ".my.cnf"];
|
|
25211
25866
|
function isSecretPath(path) {
|
|
25212
25867
|
const lower = path.toLowerCase();
|
|
25213
|
-
const name =
|
|
25868
|
+
const name = basename6(lower);
|
|
25214
25869
|
for (const needle of SECRET_PATH_BLOCKLIST) {
|
|
25215
25870
|
if (name === needle || lower.endsWith("/" + needle) || lower.endsWith("\\" + needle)) {
|
|
25216
25871
|
return true;
|
|
@@ -25334,14 +25989,14 @@ var ContextThread = class {
|
|
|
25334
25989
|
const now = Date.now();
|
|
25335
25990
|
if (config2.threadId) {
|
|
25336
25991
|
const candidatePath = threadFilePath(this.projectPath, config2.threadId);
|
|
25337
|
-
if (
|
|
25992
|
+
if (existsSync23(candidatePath)) {
|
|
25338
25993
|
try {
|
|
25339
|
-
const stat =
|
|
25994
|
+
const stat = statSync19(candidatePath);
|
|
25340
25995
|
if (stat.size > MAX_THREAD_FILE_BYTES) {
|
|
25341
25996
|
console.warn(`[agon] context-thread: ${candidatePath} is ${stat.size} bytes (> ${MAX_THREAD_FILE_BYTES}), refusing to load. Run /thread compact or /thread fork.`);
|
|
25342
25997
|
throw new Error("thread file too large");
|
|
25343
25998
|
}
|
|
25344
|
-
const raw =
|
|
25999
|
+
const raw = readFileSync27(candidatePath, "utf-8");
|
|
25345
26000
|
const snap = JSON.parse(raw);
|
|
25346
26001
|
if (snap && typeof snap === "object" && Array.isArray(snap.messages)) {
|
|
25347
26002
|
const filteredMessages = (snap.messages ?? []).filter((m) => m && m.role !== "system");
|
|
@@ -25359,9 +26014,9 @@ var ContextThread = class {
|
|
|
25359
26014
|
this.fileTouches = snap.fileTouches ?? {};
|
|
25360
26015
|
this.hydrated = true;
|
|
25361
26016
|
const jPathOnLoad = threadFilePath(this.projectPath, this.threadId).replace(/\.json$/, ".journal.jsonl");
|
|
25362
|
-
if (
|
|
26017
|
+
if (existsSync23(jPathOnLoad)) {
|
|
25363
26018
|
try {
|
|
25364
|
-
const journalLines =
|
|
26019
|
+
const journalLines = readFileSync27(jPathOnLoad, "utf-8").split("\n").filter(Boolean);
|
|
25365
26020
|
const knownOnLoad = new Set(this.messages.map((m) => m.id));
|
|
25366
26021
|
let merged = false;
|
|
25367
26022
|
for (const line of journalLines) {
|
|
@@ -25631,8 +26286,8 @@ ${msg.content}` };
|
|
|
25631
26286
|
let bytes = 0;
|
|
25632
26287
|
try {
|
|
25633
26288
|
const path = threadFilePath(this.projectPath, this.threadId);
|
|
25634
|
-
if (
|
|
25635
|
-
bytes =
|
|
26289
|
+
if (existsSync23(path)) {
|
|
26290
|
+
bytes = readFileSync27(path, "utf-8").length;
|
|
25636
26291
|
}
|
|
25637
26292
|
} catch {
|
|
25638
26293
|
}
|
|
@@ -25665,7 +26320,7 @@ ${msg.content}` };
|
|
|
25665
26320
|
let fd = -1;
|
|
25666
26321
|
try {
|
|
25667
26322
|
fd = openSync(tmpPath, "w", 384);
|
|
25668
|
-
|
|
26323
|
+
writeFileSync22(fd, body, "utf-8");
|
|
25669
26324
|
fsyncSync(fd);
|
|
25670
26325
|
} finally {
|
|
25671
26326
|
if (fd >= 0) try {
|
|
@@ -25681,7 +26336,7 @@ ${msg.content}` };
|
|
|
25681
26336
|
this.dirty = false;
|
|
25682
26337
|
this.hydrated = true;
|
|
25683
26338
|
const jPath = threadJournalPath(this.projectPath, this.threadId);
|
|
25684
|
-
if (
|
|
26339
|
+
if (existsSync23(jPath)) unlinkSync9(jPath);
|
|
25685
26340
|
this.journaledIds.clear();
|
|
25686
26341
|
} catch {
|
|
25687
26342
|
}
|
|
@@ -25713,9 +26368,9 @@ ${msg.content}` };
|
|
|
25713
26368
|
}
|
|
25714
26369
|
try {
|
|
25715
26370
|
const jPath = threadJournalPath(this.projectPath, this.threadId);
|
|
25716
|
-
if (
|
|
26371
|
+
if (existsSync23(jPath)) {
|
|
25717
26372
|
try {
|
|
25718
|
-
const journalLines =
|
|
26373
|
+
const journalLines = readFileSync27(jPath, "utf-8").split("\n").filter(Boolean);
|
|
25719
26374
|
const known = new Set(this.messages.map((m) => m.id));
|
|
25720
26375
|
for (const line of journalLines) {
|
|
25721
26376
|
try {
|
|
@@ -25734,11 +26389,11 @@ ${msg.content}` };
|
|
|
25734
26389
|
console.warn(`[agon] context-thread: journal merge failed (will overwrite): ${err instanceof Error ? err.message : String(err)}`);
|
|
25735
26390
|
}
|
|
25736
26391
|
}
|
|
25737
|
-
if (
|
|
26392
|
+
if (existsSync23(target)) {
|
|
25738
26393
|
try {
|
|
25739
|
-
const stat =
|
|
26394
|
+
const stat = statSync19(target);
|
|
25740
26395
|
if (stat.size <= MAX_THREAD_FILE_BYTES) {
|
|
25741
|
-
const raw =
|
|
26396
|
+
const raw = readFileSync27(target, "utf-8");
|
|
25742
26397
|
const onDisk = JSON.parse(raw);
|
|
25743
26398
|
if (onDisk && Array.isArray(onDisk.messages)) {
|
|
25744
26399
|
const known = new Set(this.messages.map((m) => m.id));
|
|
@@ -25777,7 +26432,7 @@ ${msg.content}` };
|
|
|
25777
26432
|
let fd = -1;
|
|
25778
26433
|
try {
|
|
25779
26434
|
fd = openSync(tmpPath, "w", 384);
|
|
25780
|
-
|
|
26435
|
+
writeFileSync22(fd, body, "utf-8");
|
|
25781
26436
|
fsyncSync(fd);
|
|
25782
26437
|
} finally {
|
|
25783
26438
|
if (fd >= 0) {
|
|
@@ -25796,7 +26451,7 @@ ${msg.content}` };
|
|
|
25796
26451
|
this.dirty = false;
|
|
25797
26452
|
this.hydrated = true;
|
|
25798
26453
|
try {
|
|
25799
|
-
if (
|
|
26454
|
+
if (existsSync23(jPath)) unlinkSync9(jPath);
|
|
25800
26455
|
this.journaledIds.clear();
|
|
25801
26456
|
} catch {
|
|
25802
26457
|
}
|
|
@@ -25817,8 +26472,8 @@ ${msg.content}` };
|
|
|
25817
26472
|
function loadActivePointer() {
|
|
25818
26473
|
try {
|
|
25819
26474
|
const path = activePointerPath();
|
|
25820
|
-
if (
|
|
25821
|
-
const raw =
|
|
26475
|
+
if (existsSync23(path)) {
|
|
26476
|
+
const raw = readFileSync27(path, "utf-8");
|
|
25822
26477
|
const parsed = JSON.parse(raw);
|
|
25823
26478
|
if (parsed && typeof parsed === "object" && parsed.byProject) {
|
|
25824
26479
|
return parsed;
|
|
@@ -25832,9 +26487,9 @@ function loadActivePointer() {
|
|
|
25832
26487
|
function saveActivePointer(pointer) {
|
|
25833
26488
|
ensureAgonHome();
|
|
25834
26489
|
const path = activePointerPath();
|
|
25835
|
-
|
|
26490
|
+
mkdirSync21(threadsDir(), { recursive: true });
|
|
25836
26491
|
const tmpPath = path + ".tmp";
|
|
25837
|
-
|
|
26492
|
+
writeFileSync22(tmpPath, JSON.stringify(pointer, null, 2) + "\n", "utf-8");
|
|
25838
26493
|
renameSync11(tmpPath, path);
|
|
25839
26494
|
}
|
|
25840
26495
|
var _WeakRefCtor = globalThis.WeakRef;
|
|
@@ -25890,9 +26545,9 @@ async function forkActiveThread(projectPath, systemPrompt) {
|
|
|
25890
26545
|
}
|
|
25891
26546
|
function listThreadsForProject(projectPath) {
|
|
25892
26547
|
const dir = threadDirFor(projectPath);
|
|
25893
|
-
if (!
|
|
26548
|
+
if (!existsSync23(dir)) return [];
|
|
25894
26549
|
try {
|
|
25895
|
-
return
|
|
26550
|
+
return readdirSync16(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5));
|
|
25896
26551
|
} catch (err) {
|
|
25897
26552
|
console.warn(`[agon] context-thread: failed to list threads: ${err instanceof Error ? err.message : String(err)}`);
|
|
25898
26553
|
return [];
|
|
@@ -26432,7 +27087,7 @@ var AgentSession = class {
|
|
|
26432
27087
|
};
|
|
26433
27088
|
|
|
26434
27089
|
// ../core/src/generated/cesar/agent-team.ts
|
|
26435
|
-
import { join as
|
|
27090
|
+
import { join as join28 } from "path";
|
|
26436
27091
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
26437
27092
|
function makeAgentTeamError(message, cause) {
|
|
26438
27093
|
const err = new Error(`AgentTeam: ${message}`);
|
|
@@ -26515,7 +27170,7 @@ var AgentTeam = class {
|
|
|
26515
27170
|
if (!this.config.isolate) {
|
|
26516
27171
|
return { m, wt: null };
|
|
26517
27172
|
}
|
|
26518
|
-
const wt =
|
|
27173
|
+
const wt = join28(this.config.cwd, ".agon", "agent-worktrees", this.runId, m.engineId);
|
|
26519
27174
|
worktreeCreate(root, wt, this.baseSha);
|
|
26520
27175
|
return { m, wt };
|
|
26521
27176
|
});
|
|
@@ -27341,10 +27996,10 @@ function hooksOutput(results) {
|
|
|
27341
27996
|
}
|
|
27342
27997
|
|
|
27343
27998
|
// ../core/src/generated/blocks/skill-loader.ts
|
|
27344
|
-
import { readFileSync as
|
|
27345
|
-
import { join as
|
|
27999
|
+
import { readFileSync as readFileSync28, readdirSync as readdirSync17, existsSync as existsSync24 } from "fs";
|
|
28000
|
+
import { join as join29, dirname as dirname12, resolve as resolve24 } from "path";
|
|
27346
28001
|
import { homedir as homedir15 } from "os";
|
|
27347
|
-
import { fileURLToPath as
|
|
28002
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
27348
28003
|
function parseFrontmatter(content) {
|
|
27349
28004
|
const match = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);
|
|
27350
28005
|
if (!match) {
|
|
@@ -27363,7 +28018,7 @@ function parseFrontmatter(content) {
|
|
|
27363
28018
|
}
|
|
27364
28019
|
function loadSkillFile(filePath) {
|
|
27365
28020
|
try {
|
|
27366
|
-
const content =
|
|
28021
|
+
const content = readFileSync28(filePath, "utf-8");
|
|
27367
28022
|
const { meta: meta3, body } = parseFrontmatter(content);
|
|
27368
28023
|
if (!meta3.name || !meta3.trigger) return null;
|
|
27369
28024
|
return {
|
|
@@ -27381,11 +28036,11 @@ function loadSkillFile(filePath) {
|
|
|
27381
28036
|
}
|
|
27382
28037
|
function loadSkillsFromDir(dir, source) {
|
|
27383
28038
|
const skills = [];
|
|
27384
|
-
if (!
|
|
28039
|
+
if (!existsSync24(dir)) return skills;
|
|
27385
28040
|
try {
|
|
27386
|
-
const files =
|
|
28041
|
+
const files = readdirSync17(dir).filter((f) => f.endsWith(".md"));
|
|
27387
28042
|
for (const file2 of files) {
|
|
27388
|
-
const skill = loadSkillFile(
|
|
28043
|
+
const skill = loadSkillFile(join29(dir, file2));
|
|
27389
28044
|
if (skill) {
|
|
27390
28045
|
skill.source = source;
|
|
27391
28046
|
skills.push(skill);
|
|
@@ -27399,12 +28054,12 @@ function loadSkillsFromDir(dir, source) {
|
|
|
27399
28054
|
function loadSkills(cwd) {
|
|
27400
28055
|
const skills = [];
|
|
27401
28056
|
const override = process.env.AGON_HOME?.trim();
|
|
27402
|
-
const home = override ?
|
|
27403
|
-
const builtinDir =
|
|
28057
|
+
const home = override ? resolve24(override) : join29(homedir15(), ".agon");
|
|
28058
|
+
const builtinDir = join29(dirname12(fileURLToPath3(import.meta.url)), "../../skills");
|
|
27404
28059
|
skills.push(...loadSkillsFromDir(builtinDir, "builtin"));
|
|
27405
|
-
skills.push(...loadSkillsFromDir(
|
|
28060
|
+
skills.push(...loadSkillsFromDir(join29(home, "skills"), "global"));
|
|
27406
28061
|
if (cwd) {
|
|
27407
|
-
skills.push(...loadSkillsFromDir(
|
|
28062
|
+
skills.push(...loadSkillsFromDir(join29(cwd, ".agon", "skills"), "project"));
|
|
27408
28063
|
}
|
|
27409
28064
|
const seen = /* @__PURE__ */ new Map();
|
|
27410
28065
|
for (const skill of skills) {
|
|
@@ -27421,17 +28076,17 @@ function renderSkillPrompt(skill, input) {
|
|
|
27421
28076
|
}
|
|
27422
28077
|
|
|
27423
28078
|
// ../core/src/generated/blocks/engine-memory.ts
|
|
27424
|
-
import { readFileSync as
|
|
27425
|
-
import { join as
|
|
28079
|
+
import { readFileSync as readFileSync29, writeFileSync as writeFileSync23, mkdirSync as mkdirSync22, renameSync as renameSync12 } from "fs";
|
|
28080
|
+
import { join as join30, resolve as resolve25 } from "path";
|
|
27426
28081
|
import { homedir as homedir16 } from "os";
|
|
27427
28082
|
function memoryPath() {
|
|
27428
28083
|
const override = process.env.AGON_HOME?.trim();
|
|
27429
|
-
const home = override ?
|
|
27430
|
-
return
|
|
28084
|
+
const home = override ? resolve25(override) : join30(homedir16(), ".agon");
|
|
28085
|
+
return join30(home, "engine-memory.json");
|
|
27431
28086
|
}
|
|
27432
28087
|
function loadEngineMemory() {
|
|
27433
28088
|
try {
|
|
27434
|
-
return JSON.parse(
|
|
28089
|
+
return JSON.parse(readFileSync29(memoryPath(), "utf-8"));
|
|
27435
28090
|
} catch (err) {
|
|
27436
28091
|
if (err.code !== "ENOENT") {
|
|
27437
28092
|
console.warn(`[agon] failed to load engine memory: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -27441,12 +28096,12 @@ function loadEngineMemory() {
|
|
|
27441
28096
|
}
|
|
27442
28097
|
function saveEngineMemory(record2) {
|
|
27443
28098
|
const override = process.env.AGON_HOME?.trim();
|
|
27444
|
-
const home = override ?
|
|
27445
|
-
|
|
28099
|
+
const home = override ? resolve25(override) : join30(homedir16(), ".agon");
|
|
28100
|
+
mkdirSync22(home, { recursive: true });
|
|
27446
28101
|
record2.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
27447
28102
|
const path = memoryPath();
|
|
27448
28103
|
const tmpPath = path + ".tmp";
|
|
27449
|
-
|
|
28104
|
+
writeFileSync23(tmpPath, JSON.stringify(record2, null, 2) + "\n");
|
|
27450
28105
|
renameSync12(tmpPath, path);
|
|
27451
28106
|
}
|
|
27452
28107
|
function ensureProfile(record2, engineId) {
|
|
@@ -27674,13 +28329,13 @@ function assignForgeRoles(engineIds, taskClass) {
|
|
|
27674
28329
|
}
|
|
27675
28330
|
|
|
27676
28331
|
// ../core/src/generated/blocks/sidechain-logger.ts
|
|
27677
|
-
import { appendFileSync as appendFileSync3, mkdirSync as
|
|
27678
|
-
import { join as
|
|
28332
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync23 } from "fs";
|
|
28333
|
+
import { join as join31 } from "path";
|
|
27679
28334
|
function createSidechainLogger(opts) {
|
|
27680
28335
|
const suffix = opts.parentId ? `_sidechain_${opts.parentId}` : "";
|
|
27681
28336
|
const filename = `${opts.sessionType}_${opts.sessionId}${suffix}.jsonl`;
|
|
27682
|
-
const logPath =
|
|
27683
|
-
|
|
28337
|
+
const logPath = join31(opts.outputDir, filename);
|
|
28338
|
+
mkdirSync23(opts.outputDir, { recursive: true });
|
|
27684
28339
|
function log(type, engineId, data) {
|
|
27685
28340
|
const event = {
|
|
27686
28341
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -27709,12 +28364,12 @@ function createSidechainLogger(opts) {
|
|
|
27709
28364
|
}
|
|
27710
28365
|
|
|
27711
28366
|
// ../core/src/generated/blocks/provenance.ts
|
|
27712
|
-
import { readFileSync as
|
|
27713
|
-
import { join as
|
|
27714
|
-
import { createHash as
|
|
28367
|
+
import { readFileSync as readFileSync30, writeFileSync as writeFileSync24, mkdirSync as mkdirSync24 } from "fs";
|
|
28368
|
+
import { join as join32, resolve as resolve26 } from "path";
|
|
28369
|
+
import { createHash as createHash7 } from "crypto";
|
|
27715
28370
|
function sha256OfFile(path) {
|
|
27716
28371
|
try {
|
|
27717
|
-
return "sha256:" +
|
|
28372
|
+
return "sha256:" + createHash7("sha256").update(readFileSync30(path)).digest("hex");
|
|
27718
28373
|
} catch (e) {
|
|
27719
28374
|
console.warn(`[agon] provenance: could not hash ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
27720
28375
|
return "unavailable";
|
|
@@ -27874,18 +28529,18 @@ function renderProvenanceMarkdown(led) {
|
|
|
27874
28529
|
function writeProvenanceReport(manifest, manifestPath, outDir, format) {
|
|
27875
28530
|
const fmt = format ?? "md";
|
|
27876
28531
|
const ledger = buildForgeProvenance(manifest, manifestPath);
|
|
27877
|
-
|
|
28532
|
+
mkdirSync24(outDir, { recursive: true });
|
|
27878
28533
|
if (fmt === "md" || fmt === "both") {
|
|
27879
|
-
const mdPath =
|
|
27880
|
-
|
|
28534
|
+
const mdPath = resolve26(join32(outDir, "provenance.md"));
|
|
28535
|
+
writeFileSync24(mdPath, renderProvenanceMarkdown(ledger), "utf-8");
|
|
27881
28536
|
if (fmt === "md") return mdPath;
|
|
27882
28537
|
}
|
|
27883
28538
|
if (fmt === "json" || fmt === "both") {
|
|
27884
|
-
const jsonPath =
|
|
27885
|
-
|
|
28539
|
+
const jsonPath = resolve26(join32(outDir, "provenance.json"));
|
|
28540
|
+
writeFileSync24(jsonPath, renderProvenanceJson(ledger), "utf-8");
|
|
27886
28541
|
if (fmt === "json") return jsonPath;
|
|
27887
28542
|
}
|
|
27888
|
-
return
|
|
28543
|
+
return resolve26(join32(outDir, "provenance.md"));
|
|
27889
28544
|
}
|
|
27890
28545
|
|
|
27891
28546
|
// ../core/src/generated/models/extension-manifest.ts
|
|
@@ -27991,8 +28646,8 @@ var CommandRegistry = class {
|
|
|
27991
28646
|
};
|
|
27992
28647
|
|
|
27993
28648
|
// ../core/src/generated/blocks/extension-loader.ts
|
|
27994
|
-
import { join as
|
|
27995
|
-
import { readdirSync as
|
|
28649
|
+
import { join as join33, resolve as resolve27 } from "path";
|
|
28650
|
+
import { readdirSync as readdirSync18, readFileSync as readFileSync31, existsSync as existsSync25 } from "fs";
|
|
27996
28651
|
import { homedir as homedir17 } from "os";
|
|
27997
28652
|
|
|
27998
28653
|
// ../core/src/generated/signals/event-bus.ts
|
|
@@ -28083,31 +28738,31 @@ function bridgeShellHooks(bus, hooks) {
|
|
|
28083
28738
|
function discoverExtensionDirs(cwd) {
|
|
28084
28739
|
const results = [];
|
|
28085
28740
|
const override = process.env.AGON_HOME?.trim();
|
|
28086
|
-
const home = override ?
|
|
28087
|
-
const userDir =
|
|
28088
|
-
if (
|
|
28741
|
+
const home = override ? resolve27(override) : join33(homedir17(), ".agon");
|
|
28742
|
+
const userDir = join33(home, "extensions");
|
|
28743
|
+
if (existsSync25(userDir)) {
|
|
28089
28744
|
try {
|
|
28090
|
-
const entries =
|
|
28745
|
+
const entries = readdirSync18(userDir, { withFileTypes: true });
|
|
28091
28746
|
for (const entry of entries) {
|
|
28092
28747
|
if (entry.isDirectory()) {
|
|
28093
|
-
const manifestPath =
|
|
28094
|
-
if (
|
|
28095
|
-
results.push({ dir:
|
|
28748
|
+
const manifestPath = join33(userDir, entry.name, "manifest.json");
|
|
28749
|
+
if (existsSync25(manifestPath)) {
|
|
28750
|
+
results.push({ dir: join33(userDir, entry.name), source: "user" });
|
|
28096
28751
|
}
|
|
28097
28752
|
}
|
|
28098
28753
|
}
|
|
28099
28754
|
} catch {
|
|
28100
28755
|
}
|
|
28101
28756
|
}
|
|
28102
|
-
const repoDir =
|
|
28103
|
-
if (
|
|
28757
|
+
const repoDir = join33(cwd, ".agon", "extensions");
|
|
28758
|
+
if (existsSync25(repoDir)) {
|
|
28104
28759
|
try {
|
|
28105
|
-
const entries =
|
|
28760
|
+
const entries = readdirSync18(repoDir, { withFileTypes: true });
|
|
28106
28761
|
for (const entry of entries) {
|
|
28107
28762
|
if (entry.isDirectory()) {
|
|
28108
|
-
const manifestPath =
|
|
28109
|
-
if (
|
|
28110
|
-
results.push({ dir:
|
|
28763
|
+
const manifestPath = join33(repoDir, entry.name, "manifest.json");
|
|
28764
|
+
if (existsSync25(manifestPath)) {
|
|
28765
|
+
results.push({ dir: join33(repoDir, entry.name), source: "repo" });
|
|
28111
28766
|
}
|
|
28112
28767
|
}
|
|
28113
28768
|
}
|
|
@@ -28117,9 +28772,9 @@ function discoverExtensionDirs(cwd) {
|
|
|
28117
28772
|
return results;
|
|
28118
28773
|
}
|
|
28119
28774
|
function loadExtensionManifest(dir, source) {
|
|
28120
|
-
const manifestPath =
|
|
28775
|
+
const manifestPath = join33(dir, "manifest.json");
|
|
28121
28776
|
try {
|
|
28122
|
-
const raw = JSON.parse(
|
|
28777
|
+
const raw = JSON.parse(readFileSync31(manifestPath, "utf-8"));
|
|
28123
28778
|
const result = validateManifest(raw, manifestPath);
|
|
28124
28779
|
if (!result.ok || !result.data) {
|
|
28125
28780
|
console.warn(`[agon] skipping extension ${dir}: ${result.error}`);
|
|
@@ -28151,7 +28806,7 @@ async function registerExtensionCommands(ext, commandRegistry) {
|
|
|
28151
28806
|
if (!commands || commands.length === 0) return registered;
|
|
28152
28807
|
for (const cmd of commands) {
|
|
28153
28808
|
try {
|
|
28154
|
-
const handlerPath =
|
|
28809
|
+
const handlerPath = resolve27(ext.dir, cmd.handler);
|
|
28155
28810
|
const mod = await import(handlerPath);
|
|
28156
28811
|
if (typeof mod.execute !== "function") {
|
|
28157
28812
|
console.warn(`[agon] extension '${ext.manifest.id}' command '${cmd.name}': handler missing execute() export`);
|
|
@@ -28187,8 +28842,8 @@ function registerExtensionEngines(ext, engineRegistry) {
|
|
|
28187
28842
|
}
|
|
28188
28843
|
for (const enginePath of enginePaths) {
|
|
28189
28844
|
try {
|
|
28190
|
-
const fullPath =
|
|
28191
|
-
const raw = JSON.parse(
|
|
28845
|
+
const fullPath = resolve27(ext.dir, enginePath);
|
|
28846
|
+
const raw = JSON.parse(readFileSync31(fullPath, "utf-8"));
|
|
28192
28847
|
if (raw.id) {
|
|
28193
28848
|
engineRegistry.register(raw);
|
|
28194
28849
|
registered.push(raw.id);
|
|
@@ -28209,12 +28864,12 @@ function registerExtensionSkills(ext) {
|
|
|
28209
28864
|
trigger: sc.trigger.startsWith("/") ? sc.trigger : "/" + sc.trigger,
|
|
28210
28865
|
description: sc.description || "",
|
|
28211
28866
|
prompt: sc.prompt || "",
|
|
28212
|
-
source:
|
|
28867
|
+
source: resolve27(ext.dir, "manifest.json"),
|
|
28213
28868
|
tools: sc.tools
|
|
28214
28869
|
};
|
|
28215
28870
|
if (sc.handler) {
|
|
28216
28871
|
try {
|
|
28217
|
-
const handlerPath =
|
|
28872
|
+
const handlerPath = resolve27(ext.dir, sc.handler);
|
|
28218
28873
|
skill._handlerPath = handlerPath;
|
|
28219
28874
|
skill.handler = async (args, ctx) => {
|
|
28220
28875
|
const mod = await import(handlerPath);
|
|
@@ -28238,7 +28893,7 @@ async function registerExtensionHooks(ext, eventBus) {
|
|
|
28238
28893
|
if (!hookContribs || hookContribs.length === 0) return registered;
|
|
28239
28894
|
for (const hook of hookContribs) {
|
|
28240
28895
|
try {
|
|
28241
|
-
const handlerPath =
|
|
28896
|
+
const handlerPath = resolve27(ext.dir, hook.handler);
|
|
28242
28897
|
const mod = await import(handlerPath);
|
|
28243
28898
|
if (typeof mod.handler !== "function" && typeof mod.default !== "function") {
|
|
28244
28899
|
console.warn(`[agon] extension '${ext.manifest.id}' hook '${hook.event}': handler missing handler() or default() export`);
|
|
@@ -28601,8 +29256,8 @@ function computeContributionWeights(team, trace) {
|
|
|
28601
29256
|
}
|
|
28602
29257
|
|
|
28603
29258
|
// ../core/src/generated/teams/team-elo.ts
|
|
28604
|
-
import { readFileSync as
|
|
28605
|
-
import { dirname as
|
|
29259
|
+
import { readFileSync as readFileSync32, writeFileSync as writeFileSync25, mkdirSync as mkdirSync25, renameSync as renameSync13 } from "fs";
|
|
29260
|
+
import { dirname as dirname13 } from "path";
|
|
28606
29261
|
function defaultCompositionRating(lineupKey2) {
|
|
28607
29262
|
return { lineupKey: lineupKey2, rating: 1500, wins: 0, losses: 0, draws: 0, matches: 0 };
|
|
28608
29263
|
}
|
|
@@ -28611,7 +29266,7 @@ function defaultRoleRating(engineId, role) {
|
|
|
28611
29266
|
}
|
|
28612
29267
|
function loadTeamElo() {
|
|
28613
29268
|
try {
|
|
28614
|
-
return JSON.parse(
|
|
29269
|
+
return JSON.parse(readFileSync32(TEAM_ELO_PATH, "utf-8"));
|
|
28615
29270
|
} catch (err) {
|
|
28616
29271
|
if (err.code !== "ENOENT") {
|
|
28617
29272
|
console.warn(`[agon] failed to load team ELO: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -28620,10 +29275,10 @@ function loadTeamElo() {
|
|
|
28620
29275
|
}
|
|
28621
29276
|
}
|
|
28622
29277
|
function saveTeamElo(record2) {
|
|
28623
|
-
|
|
29278
|
+
mkdirSync25(dirname13(TEAM_ELO_PATH), { recursive: true });
|
|
28624
29279
|
record2.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
28625
29280
|
const tmpPath = TEAM_ELO_PATH + ".tmp";
|
|
28626
|
-
|
|
29281
|
+
writeFileSync25(tmpPath, JSON.stringify(record2, null, 2) + "\n");
|
|
28627
29282
|
renameSync13(tmpPath, TEAM_ELO_PATH);
|
|
28628
29283
|
}
|
|
28629
29284
|
function expectedScore(rA, rB) {
|
|
@@ -28816,6 +29471,10 @@ export {
|
|
|
28816
29471
|
EngineRegistry,
|
|
28817
29472
|
isKernProject,
|
|
28818
29473
|
scanProjectContext,
|
|
29474
|
+
collectSourceFiles,
|
|
29475
|
+
extractSymbols,
|
|
29476
|
+
buildCodebaseMap,
|
|
29477
|
+
clearCodebaseMapCache,
|
|
28819
29478
|
addWorkspace,
|
|
28820
29479
|
removeWorkspace,
|
|
28821
29480
|
listWorkspaces,
|
|
@@ -28842,6 +29501,10 @@ export {
|
|
|
28842
29501
|
listPlans,
|
|
28843
29502
|
deletePlan,
|
|
28844
29503
|
wordWrap,
|
|
29504
|
+
resolveKernSourceLocation,
|
|
29505
|
+
mapKernStackTrace,
|
|
29506
|
+
installKernStackTraceMapper,
|
|
29507
|
+
uninstallKernStackTraceMapper,
|
|
28845
29508
|
formatSpinnerFrame,
|
|
28846
29509
|
formatEngineBlock,
|
|
28847
29510
|
formatStatusLine,
|
|
@@ -28940,6 +29603,7 @@ export {
|
|
|
28940
29603
|
createAgentTool,
|
|
28941
29604
|
createQuickNeroTool,
|
|
28942
29605
|
createGoalTool,
|
|
29606
|
+
createConquerTool,
|
|
28943
29607
|
createPipelineTool,
|
|
28944
29608
|
createProposePlanTool,
|
|
28945
29609
|
createExitPlanModeTool,
|
|
@@ -28990,6 +29654,8 @@ export {
|
|
|
28990
29654
|
refreshProbedCliModels,
|
|
28991
29655
|
findBinary,
|
|
28992
29656
|
getBinaryVersion,
|
|
29657
|
+
getBinaryVersionAsync,
|
|
29658
|
+
refreshCliGroupVersion,
|
|
28993
29659
|
buildCliModelGroups,
|
|
28994
29660
|
buildCliModelGroupsAsync,
|
|
28995
29661
|
buildCliGroupsImmediate,
|
|
@@ -29106,4 +29772,4 @@ export {
|
|
|
29106
29772
|
predictTeamRating,
|
|
29107
29773
|
updateTeamElo
|
|
29108
29774
|
};
|
|
29109
|
-
//# sourceMappingURL=chunk-
|
|
29775
|
+
//# sourceMappingURL=chunk-PFHGKBQT.js.map
|