agent-valley 4.14.3 → 4.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/plugin.json +1 -1
- package/dist/index.js +486 -338
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23458,7 +23458,7 @@ var require_dist3 = __commonJS(function(exports) {
|
|
|
23458
23458
|
});
|
|
23459
23459
|
|
|
23460
23460
|
// ../../node_modules/.bun/readdirp@5.1.1/node_modules/readdirp/index.js
|
|
23461
|
-
import { lstat as
|
|
23461
|
+
import { lstat as lstat37, readdir as readdir23, realpath as realpath42, stat as stat9 } from "node:fs/promises";
|
|
23462
23462
|
import { join as pjoin, resolve as presolve, sep as psep } from "node:path";
|
|
23463
23463
|
import { Readable as Readable2 } from "node:stream";
|
|
23464
23464
|
function readdirp(root, options = {}) {
|
|
@@ -23555,7 +23555,7 @@ var init_readdirp = __esm(() => {
|
|
|
23555
23555
|
const type = opts.type ?? defaultOptions4.type;
|
|
23556
23556
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
23557
23557
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
23558
|
-
const statMethod = opts.lstat ?
|
|
23558
|
+
const statMethod = opts.lstat ? lstat37 : stat9;
|
|
23559
23559
|
if (wantBigintFsStats) {
|
|
23560
23560
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
23561
23561
|
} else {
|
|
@@ -23636,7 +23636,7 @@ var init_readdirp = __esm(() => {
|
|
|
23636
23636
|
async _exploreDir(path, depth) {
|
|
23637
23637
|
let files;
|
|
23638
23638
|
try {
|
|
23639
|
-
files = await
|
|
23639
|
+
files = await readdir23(path, this._rdOptions);
|
|
23640
23640
|
} catch (error) {
|
|
23641
23641
|
this._onError(error);
|
|
23642
23642
|
}
|
|
@@ -23681,8 +23681,8 @@ var init_readdirp = __esm(() => {
|
|
|
23681
23681
|
async _getSymlinkEntryType(entry) {
|
|
23682
23682
|
const full = entry.fullPath;
|
|
23683
23683
|
try {
|
|
23684
|
-
const entryRealPath = await
|
|
23685
|
-
const entryRealPathStats = await
|
|
23684
|
+
const entryRealPath = await realpath42(full);
|
|
23685
|
+
const entryRealPathStats = await lstat37(entryRealPath);
|
|
23686
23686
|
if (entryRealPathStats.isFile()) {
|
|
23687
23687
|
return "file";
|
|
23688
23688
|
}
|
|
@@ -23885,7 +23885,7 @@ var init_runtime = __esm(() => {
|
|
|
23885
23885
|
|
|
23886
23886
|
// ../../node_modules/.bun/chokidar@6.0.0/node_modules/chokidar/backend.js
|
|
23887
23887
|
import { watch as fsWatch, realpathSync as realpathSync8 } from "node:fs";
|
|
23888
|
-
import { lstat as
|
|
23888
|
+
import { lstat as lstat38, open as open20, stat as stat10 } from "node:fs/promises";
|
|
23889
23889
|
import * as sp2 from "node:path";
|
|
23890
23890
|
function allocateSharedResourceGeneration() {
|
|
23891
23891
|
return ++nextGeneration;
|
|
@@ -24102,7 +24102,7 @@ async function handleNativeError(path, cont, error) {
|
|
|
24102
24102
|
}
|
|
24103
24103
|
async function retireIfSelfRemoved(cont, nativePath) {
|
|
24104
24104
|
try {
|
|
24105
|
-
await
|
|
24105
|
+
await lstat38(sp2.join(nativePath, sp2.basename(nativePath)));
|
|
24106
24106
|
return;
|
|
24107
24107
|
} catch (error) {
|
|
24108
24108
|
if (!isMissingError(error))
|
|
@@ -24968,7 +24968,7 @@ var init_policy = __esm(() => {
|
|
|
24968
24968
|
});
|
|
24969
24969
|
|
|
24970
24970
|
// ../../node_modules/.bun/chokidar@6.0.0/node_modules/chokidar/reconcile.js
|
|
24971
|
-
import { realpath as fsrealpath, lstat as
|
|
24971
|
+
import { realpath as fsrealpath, lstat as lstat39, readlink as readlink2, stat as stat12 } from "node:fs/promises";
|
|
24972
24972
|
import * as sp5 from "node:path";
|
|
24973
24973
|
function recoveryTrigger(resource) {
|
|
24974
24974
|
return {
|
|
@@ -25191,7 +25191,7 @@ class ObservationEngine {
|
|
|
25191
25191
|
}
|
|
25192
25192
|
async mappedFileSnapshot(path) {
|
|
25193
25193
|
try {
|
|
25194
|
-
return await
|
|
25194
|
+
return await lstat39(path);
|
|
25195
25195
|
} catch (error) {
|
|
25196
25196
|
if (isMissingError(error))
|
|
25197
25197
|
return false;
|
|
@@ -25213,7 +25213,7 @@ class ObservationEngine {
|
|
|
25213
25213
|
timer = undefined;
|
|
25214
25214
|
(async () => {
|
|
25215
25215
|
try {
|
|
25216
|
-
await
|
|
25216
|
+
await lstat39(path);
|
|
25217
25217
|
} catch (error) {
|
|
25218
25218
|
if (!active || !fsw.lifecycle.isActive(generation))
|
|
25219
25219
|
return;
|
|
@@ -25275,7 +25275,7 @@ class ObservationEngine {
|
|
|
25275
25275
|
const listener = async (_path, newStats) => {
|
|
25276
25276
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
25277
25277
|
try {
|
|
25278
|
-
const newStats = prevStats.isSymbolicLink() && !this.fsw.options.followSymlinks ? await
|
|
25278
|
+
const newStats = prevStats.isSymbolicLink() && !this.fsw.options.followSymlinks ? await lstat39(file) : await stat12(file);
|
|
25279
25279
|
if (!isActive())
|
|
25280
25280
|
return;
|
|
25281
25281
|
const at = newStats.atimeMs;
|
|
@@ -25405,7 +25405,7 @@ class ObservationEngine {
|
|
|
25405
25405
|
let disappeared = false;
|
|
25406
25406
|
let becameNonDirectory = false;
|
|
25407
25407
|
try {
|
|
25408
|
-
const currentStats = target ? await
|
|
25408
|
+
const currentStats = target ? await lstat39(affectedPath) : await stat12(affectedPath);
|
|
25409
25409
|
becameNonDirectory = !target && !currentStats.isDirectory();
|
|
25410
25410
|
} catch (stateError) {
|
|
25411
25411
|
if (isMissingError(stateError))
|
|
@@ -25437,7 +25437,7 @@ class ObservationEngine {
|
|
|
25437
25437
|
if (!this.isHelperActive(wh, path))
|
|
25438
25438
|
return;
|
|
25439
25439
|
try {
|
|
25440
|
-
await
|
|
25440
|
+
await lstat39(path);
|
|
25441
25441
|
return;
|
|
25442
25442
|
} catch (error) {
|
|
25443
25443
|
if (!isMissingError(error))
|
|
@@ -25557,7 +25557,7 @@ class ObservationEngine {
|
|
|
25557
25557
|
let ancestor = sp5.dirname(candidate);
|
|
25558
25558
|
while (true) {
|
|
25559
25559
|
try {
|
|
25560
|
-
await
|
|
25560
|
+
await lstat39(ancestor);
|
|
25561
25561
|
return missing;
|
|
25562
25562
|
} catch (error) {
|
|
25563
25563
|
if (!isMissingError(error)) {
|
|
@@ -25593,7 +25593,7 @@ class ObservationEngine {
|
|
|
25593
25593
|
return;
|
|
25594
25594
|
let stats;
|
|
25595
25595
|
try {
|
|
25596
|
-
stats = await
|
|
25596
|
+
stats = await lstat39(candidate);
|
|
25597
25597
|
} catch (error) {
|
|
25598
25598
|
if (!isMissingError(error)) {
|
|
25599
25599
|
this.reportError(error);
|
|
@@ -25754,7 +25754,7 @@ class ObservationEngine {
|
|
|
25754
25754
|
this.reconcileBackendTrigger(dir, false, trigger, async () => {
|
|
25755
25755
|
let rootStats;
|
|
25756
25756
|
try {
|
|
25757
|
-
rootStats = await
|
|
25757
|
+
rootStats = await lstat39(dir);
|
|
25758
25758
|
} catch (error) {
|
|
25759
25759
|
if (isMissingError(error)) {
|
|
25760
25760
|
this.fsw.removePath(parentPath, sp5.basename(dir), true);
|
|
@@ -25810,7 +25810,7 @@ class ObservationEngine {
|
|
|
25810
25810
|
wh.recursiveDisabled = true;
|
|
25811
25811
|
let currentStats;
|
|
25812
25812
|
try {
|
|
25813
|
-
currentStats = await
|
|
25813
|
+
currentStats = await lstat39(dir);
|
|
25814
25814
|
} catch (statError) {
|
|
25815
25815
|
if (isMissingError(statError))
|
|
25816
25816
|
fsw.removePath(sp5.dirname(dir), sp5.basename(dir), true);
|
|
@@ -26004,7 +26004,7 @@ class ObservationEngine {
|
|
|
26004
26004
|
if (trigger.kind === "native") {
|
|
26005
26005
|
let observedStats;
|
|
26006
26006
|
try {
|
|
26007
|
-
const linkStats = await
|
|
26007
|
+
const linkStats = await lstat39(dirPath);
|
|
26008
26008
|
observedStats = linkStats.isSymbolicLink() && this.fsw.options.followSymlinks ? await stat12(dirPath) : linkStats;
|
|
26009
26009
|
} catch (error) {
|
|
26010
26010
|
if (isMissingError(error)) {
|
|
@@ -26136,7 +26136,7 @@ class ObservationEngine {
|
|
|
26136
26136
|
return "complete";
|
|
26137
26137
|
}
|
|
26138
26138
|
try {
|
|
26139
|
-
const linkStats = await
|
|
26139
|
+
const linkStats = await lstat39(wh.watchPath);
|
|
26140
26140
|
if (!this.isHelperActive(wh)) {
|
|
26141
26141
|
return "complete";
|
|
26142
26142
|
}
|
|
@@ -26262,7 +26262,7 @@ var init_reconcile = __esm(() => {
|
|
|
26262
26262
|
// ../../node_modules/.bun/chokidar@6.0.0/node_modules/chokidar/index.js
|
|
26263
26263
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
26264
26264
|
import { realpathSync as realpathSync9 } from "node:fs";
|
|
26265
|
-
import { readdir as
|
|
26265
|
+
import { readdir as readdir24 } from "node:fs/promises";
|
|
26266
26266
|
import * as sp6 from "node:path";
|
|
26267
26267
|
function* ancestorKeys(path) {
|
|
26268
26268
|
let current = sp6.resolve(path);
|
|
@@ -26725,7 +26725,7 @@ var init_chokidar = __esm(() => {
|
|
|
26725
26725
|
const generation = this.lifecycle.generation;
|
|
26726
26726
|
this.lifecycle.track((async () => {
|
|
26727
26727
|
try {
|
|
26728
|
-
await
|
|
26728
|
+
await readdir24(path);
|
|
26729
26729
|
} catch (error) {
|
|
26730
26730
|
if (isMissingError(error) && this.lifecycle.isActive(generation)) {
|
|
26731
26731
|
this.removePath(sp6.dirname(path), sp6.basename(path));
|
|
@@ -27234,7 +27234,7 @@ function canonicalConfig(config) {
|
|
|
27234
27234
|
import { spawn as spawn12 } from "node:child_process";
|
|
27235
27235
|
import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
|
|
27236
27236
|
import { homedir as homedir13, tmpdir as tmpdir5 } from "node:os";
|
|
27237
|
-
import { delimiter as delimiter4, join as
|
|
27237
|
+
import { delimiter as delimiter4, join as join84 } from "node:path";
|
|
27238
27238
|
function runTerminalCommand(request, spawnCommand = spawn12) {
|
|
27239
27239
|
return new Promise((resolve) => {
|
|
27240
27240
|
let child;
|
|
@@ -27283,7 +27283,7 @@ function defaults2() {
|
|
|
27283
27283
|
discover: discoverAgents,
|
|
27284
27284
|
runCommand: runTerminalCommand,
|
|
27285
27285
|
supportsLoginCommand: (agent, path, env) => supportsNativeLoginCommand(agent, path, { env }),
|
|
27286
|
-
makeTempDir: () => mkdtempSync(
|
|
27286
|
+
makeTempDir: () => mkdtempSync(join84(tmpdir5(), "av-agent-install-")),
|
|
27287
27287
|
removeTempDir: (path) => rmSync2(path, { recursive: true, force: true })
|
|
27288
27288
|
};
|
|
27289
27289
|
}
|
|
@@ -27310,7 +27310,7 @@ async function runOfficialInstaller(installerUrl, deps, options = {}) {
|
|
|
27310
27310
|
let directory;
|
|
27311
27311
|
try {
|
|
27312
27312
|
directory = deps.makeTempDir();
|
|
27313
|
-
const scriptPath =
|
|
27313
|
+
const scriptPath = join84(directory, "install.sh");
|
|
27314
27314
|
const request = { env: options.env ?? deps.env, ...options.cwd ? { cwd: options.cwd } : {} };
|
|
27315
27315
|
const download = await deps.runCommand({
|
|
27316
27316
|
command: curl,
|
|
@@ -27383,7 +27383,7 @@ async function installChiefAgent(agent, overrides = {}) {
|
|
|
27383
27383
|
const install = await runOfficialInstaller(plan.installerUrl, deps);
|
|
27384
27384
|
if (!install.success)
|
|
27385
27385
|
return commandFailure(install.stage === "download" ? "Installer download" : "Installation", install, plan.documentation);
|
|
27386
|
-
const localBin =
|
|
27386
|
+
const localBin = join84(deps.home, ".local", "bin");
|
|
27387
27387
|
const pathParts = (deps.env.PATH ?? "").split(delimiter4);
|
|
27388
27388
|
if (!pathParts.includes(localBin))
|
|
27389
27389
|
deps.env.PATH = [localBin, ...pathParts.filter(Boolean)].join(delimiter4);
|
|
@@ -27514,31 +27514,31 @@ var init_agent_provisioning = __esm(() => {
|
|
|
27514
27514
|
|
|
27515
27515
|
// src/oma-provisioning.ts
|
|
27516
27516
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync3 } from "node:fs";
|
|
27517
|
-
import { chmod as chmod5, lstat as
|
|
27517
|
+
import { chmod as chmod5, lstat as lstat40, readdir as readdir25, readFile as readFile25, realpath as realpath43, unlink as unlink7, writeFile as writeFile16 } from "node:fs/promises";
|
|
27518
27518
|
import { homedir as homedir14, tmpdir as tmpdir6 } from "node:os";
|
|
27519
|
-
import { delimiter as delimiter5, isAbsolute as
|
|
27519
|
+
import { delimiter as delimiter5, isAbsolute as isAbsolute31, join as join85, relative as relative25, resolve as resolve49 } from "node:path";
|
|
27520
27520
|
function defaults3() {
|
|
27521
27521
|
const home = homedir14();
|
|
27522
27522
|
return {
|
|
27523
27523
|
platform: process.platform,
|
|
27524
27524
|
home,
|
|
27525
27525
|
env: process.env,
|
|
27526
|
-
resolveBinary: (name) => resolveBinaryPath(name, name === "bun" ? [
|
|
27526
|
+
resolveBinary: (name) => resolveBinaryPath(name, name === "bun" ? [join85(process.env.BUN_INSTALL ?? join85(home, ".bun"), "bin", "bun")] : []),
|
|
27527
27527
|
runCommand: runTerminalCommand,
|
|
27528
|
-
makeTempDir: () => mkdtempSync2(
|
|
27528
|
+
makeTempDir: () => mkdtempSync2(join85(tmpdir6(), "av-oma-install-")),
|
|
27529
27529
|
removeTempDir: (path) => rmSync3(path, { recursive: true, force: true })
|
|
27530
27530
|
};
|
|
27531
27531
|
}
|
|
27532
27532
|
async function directory2(path) {
|
|
27533
27533
|
try {
|
|
27534
|
-
return (await
|
|
27534
|
+
return (await lstat40(path)).isDirectory();
|
|
27535
27535
|
} catch {
|
|
27536
27536
|
return false;
|
|
27537
27537
|
}
|
|
27538
27538
|
}
|
|
27539
27539
|
async function present(path) {
|
|
27540
27540
|
try {
|
|
27541
|
-
await
|
|
27541
|
+
await lstat40(path);
|
|
27542
27542
|
return true;
|
|
27543
27543
|
} catch {
|
|
27544
27544
|
return false;
|
|
@@ -27546,7 +27546,7 @@ async function present(path) {
|
|
|
27546
27546
|
}
|
|
27547
27547
|
async function installedVersion2(skills) {
|
|
27548
27548
|
try {
|
|
27549
|
-
const marker = JSON.parse(await readFile25(
|
|
27549
|
+
const marker = JSON.parse(await readFile25(join85(skills, "_version.json"), "utf8"));
|
|
27550
27550
|
return marker.schemaVersion === 2 && marker.mode === "project" && typeof marker.version === "string" && /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(marker.version) ? marker.version : null;
|
|
27551
27551
|
} catch {
|
|
27552
27552
|
return null;
|
|
@@ -27555,10 +27555,10 @@ async function installedVersion2(skills) {
|
|
|
27555
27555
|
async function snapshotConfig(agents) {
|
|
27556
27556
|
const snapshots = [];
|
|
27557
27557
|
for (const name of CUSTOM_CONFIG_NAMES) {
|
|
27558
|
-
const path =
|
|
27558
|
+
const path = join85(agents, name);
|
|
27559
27559
|
if (!await present(path))
|
|
27560
27560
|
continue;
|
|
27561
|
-
const file = await
|
|
27561
|
+
const file = await lstat40(path);
|
|
27562
27562
|
if (!file.isFile())
|
|
27563
27563
|
throw new Error("Custom configuration must be a project-local regular file.");
|
|
27564
27564
|
snapshots.push({ path, bytes: await readFile25(path), mode: file.mode & 511 });
|
|
@@ -27575,10 +27575,10 @@ async function restoreConfig(agents, snapshots) {
|
|
|
27575
27575
|
["oma-config.yaml", "oma-config.cue"],
|
|
27576
27576
|
["oma-config.local.yaml", "oma-config.local.cue"]
|
|
27577
27577
|
]) {
|
|
27578
|
-
if (!pair.some((name) => original.has(
|
|
27578
|
+
if (!pair.some((name) => original.has(join85(agents, name))))
|
|
27579
27579
|
continue;
|
|
27580
27580
|
for (const name of pair) {
|
|
27581
|
-
const path =
|
|
27581
|
+
const path = join85(agents, name);
|
|
27582
27582
|
if (!original.has(path))
|
|
27583
27583
|
await unlink7(path).catch((error) => {
|
|
27584
27584
|
if (error.code !== "ENOENT")
|
|
@@ -27588,17 +27588,17 @@ async function restoreConfig(agents, snapshots) {
|
|
|
27588
27588
|
}
|
|
27589
27589
|
}
|
|
27590
27590
|
async function workspacePath(input) {
|
|
27591
|
-
if (!input.trim() || !
|
|
27591
|
+
if (!input.trim() || !isAbsolute31(input))
|
|
27592
27592
|
return null;
|
|
27593
27593
|
const root = resolve49(input);
|
|
27594
27594
|
if (!await directory2(root))
|
|
27595
27595
|
return null;
|
|
27596
|
-
for (const path of [
|
|
27596
|
+
for (const path of [join85(root, ".agents"), join85(root, ".agents", "skills")]) {
|
|
27597
27597
|
if (!await present(path))
|
|
27598
27598
|
continue;
|
|
27599
|
-
const actual = await
|
|
27600
|
-
const location2 = relative25(await
|
|
27601
|
-
if (location2 === ".." || location2.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ||
|
|
27599
|
+
const actual = await realpath43(path);
|
|
27600
|
+
const location2 = relative25(await realpath43(root), actual);
|
|
27601
|
+
if (location2 === ".." || location2.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute31(location2))
|
|
27602
27602
|
return null;
|
|
27603
27603
|
}
|
|
27604
27604
|
return root;
|
|
@@ -27608,15 +27608,15 @@ async function inspectOma(workspaceRoot, _overrides = {}) {
|
|
|
27608
27608
|
const root = await workspacePath(workspaceRoot);
|
|
27609
27609
|
if (!root)
|
|
27610
27610
|
return { success: false, message: "Choose an existing absolute workspace with project-local OMA files." };
|
|
27611
|
-
const skills =
|
|
27611
|
+
const skills = join85(root, ".agents", "skills");
|
|
27612
27612
|
const version = await installedVersion2(skills);
|
|
27613
27613
|
if (!version)
|
|
27614
27614
|
throw new Error("Invalid installed metadata");
|
|
27615
|
-
const entries = (await
|
|
27615
|
+
const entries = (await readdir25(skills, { withFileTypes: true })).filter((entry) => /^oma-[a-z0-9-]+$/.test(entry.name));
|
|
27616
27616
|
if (!entries.length)
|
|
27617
27617
|
throw new Error("No installed skills");
|
|
27618
27618
|
for (const entry of entries) {
|
|
27619
|
-
if (!entry.isDirectory() || !(await
|
|
27619
|
+
if (!entry.isDirectory() || !(await lstat40(join85(skills, entry.name, "SKILL.md"))).isFile())
|
|
27620
27620
|
throw new Error("Incomplete installed skill");
|
|
27621
27621
|
}
|
|
27622
27622
|
return {
|
|
@@ -27664,16 +27664,16 @@ async function prepareOma(workspaceRoot, overrides = {}) {
|
|
|
27664
27664
|
delete environment.OMA_YES;
|
|
27665
27665
|
environment.CI = "true";
|
|
27666
27666
|
const paths = [
|
|
27667
|
-
deps.env.BUN_INSTALL_BIN ??
|
|
27668
|
-
|
|
27667
|
+
deps.env.BUN_INSTALL_BIN ?? join85(deps.env.BUN_INSTALL ?? join85(deps.home, ".bun"), "bin"),
|
|
27668
|
+
join85(deps.home, ".local", "bin")
|
|
27669
27669
|
];
|
|
27670
27670
|
environment.PATH = [...new Set([...paths, ...(environment.PATH ?? "").split(delimiter5).filter(Boolean)])].join(delimiter5);
|
|
27671
27671
|
const request = { command: bun, env: environment, cwd: root, timeoutMs: 300000 };
|
|
27672
27672
|
const latest = await deps.runCommand({ ...request, args: ["install", "--global", LATEST_PACKAGE] });
|
|
27673
27673
|
if (!latest.success)
|
|
27674
27674
|
return failure4("OMA CLI update", latest);
|
|
27675
|
-
const agents =
|
|
27676
|
-
const existing = await installedVersion2(
|
|
27675
|
+
const agents = join85(root, ".agents");
|
|
27676
|
+
const existing = await installedVersion2(join85(agents, "skills")) !== null || await directory2(join85(agents, "skills")) && (await present(join85(agents, "oma-config.yaml")) || await present(join85(agents, "mcp.json")) || await directory2(join85(agents, "workflows")));
|
|
27677
27677
|
const custom = await snapshotConfig(agents);
|
|
27678
27678
|
const args = existing ? ["update", "--yes", "--with-new-skills", "--all"] : ["install"];
|
|
27679
27679
|
let installed;
|
|
@@ -29162,9 +29162,9 @@ var init_ui = __esm(() => {
|
|
|
29162
29162
|
|
|
29163
29163
|
// src/setup/workspace-step.ts
|
|
29164
29164
|
import { statSync as statSync6 } from "node:fs";
|
|
29165
|
-
import { isAbsolute as
|
|
29165
|
+
import { isAbsolute as isAbsolute32 } from "node:path";
|
|
29166
29166
|
async function validateOrderWorkspace(path) {
|
|
29167
|
-
if (!
|
|
29167
|
+
if (!isAbsolute32(path))
|
|
29168
29168
|
return "Set workspace.root in av.yaml to an absolute Git repository path.";
|
|
29169
29169
|
try {
|
|
29170
29170
|
if (!statSync6(path).isDirectory())
|
|
@@ -29191,7 +29191,7 @@ async function stepWorkspace(ctx, step, total) {
|
|
|
29191
29191
|
validate: (v) => {
|
|
29192
29192
|
if (!v?.trim())
|
|
29193
29193
|
return "Required";
|
|
29194
|
-
if (!
|
|
29194
|
+
if (!isAbsolute32(v.trim()))
|
|
29195
29195
|
return "Must be an absolute path";
|
|
29196
29196
|
}
|
|
29197
29197
|
});
|
|
@@ -29217,8 +29217,8 @@ var init_workspace_step = __esm(() => {
|
|
|
29217
29217
|
});
|
|
29218
29218
|
|
|
29219
29219
|
// src/setup/noninteractive-config.ts
|
|
29220
|
-
import { lstat as
|
|
29221
|
-
import { isAbsolute as
|
|
29220
|
+
import { lstat as lstat41, realpath as realpath44 } from "node:fs/promises";
|
|
29221
|
+
import { isAbsolute as isAbsolute33, join as join86, parse as parsePath, resolve as resolve50 } from "node:path";
|
|
29222
29222
|
function validateNoninteractiveOptions(options) {
|
|
29223
29223
|
if (!options.yes || options.edit || options.mode !== undefined && options.mode !== "order")
|
|
29224
29224
|
throw new Error("Use av setup --yes only for local order setup; --edit and --mode tracker require interactive setup.");
|
|
@@ -29263,7 +29263,7 @@ function selectChief(options, deps, project, global2, existingProject) {
|
|
|
29263
29263
|
const savedType = projectActor.type ?? (existingProject ? globalActor.type : undefined);
|
|
29264
29264
|
const selected = options.actor ?? runtime?.actorType ?? savedType;
|
|
29265
29265
|
if (!selected)
|
|
29266
|
-
throw new SetupIdentityRequiredError(`actor.type is not selected for ${
|
|
29266
|
+
throw new SetupIdentityRequiredError(`actor.type is not selected for ${join86(deps.projectRoot, "av.yaml")}, and the current agent runtime is unknown. Defaults in ${deps.globalConfigPath} do not identify a new project's initiating agent. Rerun av setup --yes --actor <current-vendor> --model <current-model-or-empty>.`);
|
|
29267
29267
|
const actorType = selected;
|
|
29268
29268
|
const actorSource = options.actor !== undefined ? "explicit" : runtime ? "runtime" : projectActor.type ? "project" : "global";
|
|
29269
29269
|
const previousType = savedType;
|
|
@@ -29301,14 +29301,14 @@ async function prepareNoninteractiveConfig(options, deps) {
|
|
|
29301
29301
|
validateNoninteractiveOptions(options);
|
|
29302
29302
|
let projectRoot;
|
|
29303
29303
|
try {
|
|
29304
|
-
projectRoot = await
|
|
29305
|
-
if (!(await
|
|
29304
|
+
projectRoot = await realpath44(resolve50(deps.projectRoot));
|
|
29305
|
+
if (!(await lstat41(projectRoot)).isDirectory())
|
|
29306
29306
|
throw new Error("not a directory");
|
|
29307
29307
|
} catch {
|
|
29308
29308
|
throw new Error(`AV configuration directory ${deps.projectRoot} does not exist. Run av setup from an existing directory.`);
|
|
29309
29309
|
}
|
|
29310
29310
|
const globalPath = resolve50(deps.globalConfigPath);
|
|
29311
|
-
const projectPath =
|
|
29311
|
+
const projectPath = join86(projectRoot, "av.yaml");
|
|
29312
29312
|
const project = await configFile(projectPath, projectConfigSchema);
|
|
29313
29313
|
const global2 = await configFile(globalPath, globalConfigSchema);
|
|
29314
29314
|
const chief = selectChief(options, { ...deps, projectRoot, globalConfigPath: globalPath }, project.raw, global2.raw, project.file.before !== null);
|
|
@@ -29325,11 +29325,11 @@ async function prepareNoninteractiveConfig(options, deps) {
|
|
|
29325
29325
|
}
|
|
29326
29326
|
const savedWorkspace = project.raw.workspace?.root;
|
|
29327
29327
|
const selectedWorkspace = options.workspace ?? savedWorkspace ?? projectRoot;
|
|
29328
|
-
const workspacePath =
|
|
29328
|
+
const workspacePath = isAbsolute33(selectedWorkspace) ? selectedWorkspace : resolve50(projectRoot, selectedWorkspace);
|
|
29329
29329
|
const workspaceError = await validateOrderWorkspace(workspacePath);
|
|
29330
29330
|
if (workspaceError)
|
|
29331
29331
|
throw new Error(workspaceError);
|
|
29332
|
-
const workspace = await
|
|
29332
|
+
const workspace = await realpath44(workspacePath);
|
|
29333
29333
|
const canonical = (raw) => canonicalConfig({ ...raw, agent: raw.actor ?? raw.agent });
|
|
29334
29334
|
const savedProject = {
|
|
29335
29335
|
...canonical(project.raw),
|
|
@@ -29372,7 +29372,7 @@ var init_noninteractive_config = __esm(() => {
|
|
|
29372
29372
|
});
|
|
29373
29373
|
|
|
29374
29374
|
// src/setup/noninteractive.ts
|
|
29375
|
-
import { join as
|
|
29375
|
+
import { join as join87, parse as parsePath2, resolve as resolve51 } from "node:path";
|
|
29376
29376
|
function rerunCommand(result, options) {
|
|
29377
29377
|
const quote = (value) => `'${value.replace(/'/g, "'\\''")}'`;
|
|
29378
29378
|
return `cd ${quote(result.projectRoot)} && av setup --yes --actor ${result.chief.actorType} --model ${quote(result.chief.model ?? "")} --workspace ${quote(result.workspace ?? result.projectRoot)} --oma ${options.oma ?? "prepare"} --json`;
|
|
@@ -29386,7 +29386,7 @@ async function setupNoninteractive(options, overrides = {}) {
|
|
|
29386
29386
|
projectRoot: resolve51(deps.projectRoot),
|
|
29387
29387
|
workspace: null,
|
|
29388
29388
|
config: {
|
|
29389
|
-
project:
|
|
29389
|
+
project: join87(resolve51(deps.projectRoot), "av.yaml"),
|
|
29390
29390
|
global: resolve51(deps.globalConfigPath),
|
|
29391
29391
|
saved: false
|
|
29392
29392
|
},
|
|
@@ -29890,7 +29890,7 @@ var init_container_step = __esm(() => {
|
|
|
29890
29890
|
});
|
|
29891
29891
|
|
|
29892
29892
|
// src/setup/metric-step.ts
|
|
29893
|
-
import { isAbsolute as
|
|
29893
|
+
import { isAbsolute as isAbsolute34 } from "node:path";
|
|
29894
29894
|
async function text14(message, initialValue, validate) {
|
|
29895
29895
|
const value = await text12({
|
|
29896
29896
|
message: `${message} (:back goes back)`,
|
|
@@ -29974,7 +29974,7 @@ async function stepMetrics(ctx) {
|
|
|
29974
29974
|
draft.token_env = token;
|
|
29975
29975
|
} else {
|
|
29976
29976
|
const file = await text14("Repository-relative JSON file", old?.file ?? "metrics/revenue.json", (value) => {
|
|
29977
|
-
if (!value || value.length > 2000 ||
|
|
29977
|
+
if (!value || value.length > 2000 || isAbsolute34(value) || /^[A-Za-z]:/.test(value) || value.startsWith("\\") || value.split(/[\\/]/).includes(".."))
|
|
29978
29978
|
return "Use a relative file inside the repository, without ..";
|
|
29979
29979
|
});
|
|
29980
29980
|
if (navigated2(file))
|
|
@@ -31878,9 +31878,9 @@ var init_setup = __esm(() => {
|
|
|
31878
31878
|
// ../../packages/core/src/relay/credentials.ts
|
|
31879
31879
|
import { readFileSync as readFileSync14 } from "node:fs";
|
|
31880
31880
|
import { homedir as homedir15 } from "node:os";
|
|
31881
|
-
import { join as
|
|
31881
|
+
import { join as join88 } from "node:path";
|
|
31882
31882
|
function defaultCredentialsPath() {
|
|
31883
|
-
return
|
|
31883
|
+
return join88(homedir15(), ".agent-valley", "credentials.json");
|
|
31884
31884
|
}
|
|
31885
31885
|
function validateRelayCredentials(value, binding, now = Date.now()) {
|
|
31886
31886
|
const result = credentialsSchema.safeParse(value);
|
|
@@ -56713,8 +56713,8 @@ async function startAvMcpHttp(api, options) {
|
|
|
56713
56713
|
|
|
56714
56714
|
// src/mission-api.ts
|
|
56715
56715
|
import { randomUUID as randomUUID25 } from "node:crypto";
|
|
56716
|
-
import { lstat as
|
|
56717
|
-
import { isAbsolute as
|
|
56716
|
+
import { lstat as lstat30, readdir as readdir16, realpath as realpath34 } from "node:fs/promises";
|
|
56717
|
+
import { isAbsolute as isAbsolute22, join as join61 } from "node:path";
|
|
56718
56718
|
|
|
56719
56719
|
// ../../packages/core/src/chief/reports.ts
|
|
56720
56720
|
init_zod();
|
|
@@ -77908,8 +77908,8 @@ async function launchMission(input) {
|
|
|
77908
77908
|
|
|
77909
77909
|
// src/operation-api.ts
|
|
77910
77910
|
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
77911
|
-
import { realpath as
|
|
77912
|
-
import { join as
|
|
77911
|
+
import { realpath as realpath33 } from "node:fs/promises";
|
|
77912
|
+
import { join as join60 } from "node:path";
|
|
77913
77913
|
|
|
77914
77914
|
// ../../packages/core/src/chief/continuous-store.ts
|
|
77915
77915
|
init_atomic_json();
|
|
@@ -78183,10 +78183,10 @@ class ContinuousOperationStore {
|
|
|
78183
78183
|
}
|
|
78184
78184
|
|
|
78185
78185
|
// src/chief-continuous.ts
|
|
78186
|
-
import { execFile as
|
|
78186
|
+
import { execFile as execFile9 } from "node:child_process";
|
|
78187
78187
|
import { randomUUID as randomUUID23 } from "node:crypto";
|
|
78188
|
-
import { realpath as
|
|
78189
|
-
import { join as
|
|
78188
|
+
import { realpath as realpath32 } from "node:fs/promises";
|
|
78189
|
+
import { join as join59, resolve as resolve33 } from "node:path";
|
|
78190
78190
|
import { promisify as promisify5 } from "node:util";
|
|
78191
78191
|
|
|
78192
78192
|
// ../../packages/core/src/chief/container-observation-command.ts
|
|
@@ -80269,7 +80269,7 @@ init_execution();
|
|
|
80269
80269
|
init_runtime_ignore();
|
|
80270
80270
|
|
|
80271
80271
|
// src/chief-continuous-decision.ts
|
|
80272
|
-
import { join as
|
|
80272
|
+
import { join as join56 } from "node:path";
|
|
80273
80273
|
// ../../packages/core/src/chief/coordinator-checkpoint.ts
|
|
80274
80274
|
class CheckpointError extends Error {
|
|
80275
80275
|
}
|
|
@@ -80796,7 +80796,7 @@ init_execution();
|
|
|
80796
80796
|
|
|
80797
80797
|
// ../../packages/core/src/chief/runtime.ts
|
|
80798
80798
|
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
80799
|
-
import { join as
|
|
80799
|
+
import { join as join48, resolve as resolve29 } from "node:path";
|
|
80800
80800
|
|
|
80801
80801
|
// ../../packages/core/src/oma/receipt-adapter.ts
|
|
80802
80802
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
@@ -82371,6 +82371,134 @@ function unattendedVerificationGuidance(stage) {
|
|
|
82371
82371
|
`);
|
|
82372
82372
|
}
|
|
82373
82373
|
|
|
82374
|
+
// ../../packages/core/src/chief/workspace-growth.ts
|
|
82375
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
82376
|
+
var GIB2 = 1024 ** 3;
|
|
82377
|
+
var INTEGRATION_CHECK_GROWTH_ENV = "AV_INTEGRATION_CHECK_GROWTH_GIB";
|
|
82378
|
+
var DEFAULT_INTEGRATION_CHECK_GROWTH_GIB = 1;
|
|
82379
|
+
var STORAGE_NOTE_PREFIX = "Storage:";
|
|
82380
|
+
function growthThresholdBytes(env = process.env) {
|
|
82381
|
+
const raw = env[INTEGRATION_CHECK_GROWTH_ENV]?.trim();
|
|
82382
|
+
if (!raw)
|
|
82383
|
+
return DEFAULT_INTEGRATION_CHECK_GROWTH_GIB * GIB2;
|
|
82384
|
+
const value = Number(raw);
|
|
82385
|
+
if (!Number.isFinite(value) || value < 0)
|
|
82386
|
+
throw new Error(`${INTEGRATION_CHECK_GROWTH_ENV}=${raw} is invalid. Set it to a non-negative number of GiB (for example ${DEFAULT_INTEGRATION_CHECK_GROWTH_GIB}), or 0 to disable the storage report.`);
|
|
82387
|
+
return value * GIB2;
|
|
82388
|
+
}
|
|
82389
|
+
function directorySizes(path, timeoutMs = 60000) {
|
|
82390
|
+
return new Promise((resolve) => {
|
|
82391
|
+
execFile7("du", ["-k", "-d", "3", path], { timeout: timeoutMs, maxBuffer: 64 * 1024 * 1024 }, (error, stdout) => {
|
|
82392
|
+
if (error && !stdout)
|
|
82393
|
+
return resolve(undefined);
|
|
82394
|
+
const sizes = new Map;
|
|
82395
|
+
for (const line of stdout.split(`
|
|
82396
|
+
`)) {
|
|
82397
|
+
const tab = line.indexOf("\t");
|
|
82398
|
+
const kib = Number(line.slice(0, tab));
|
|
82399
|
+
if (tab < 1 || !Number.isFinite(kib))
|
|
82400
|
+
continue;
|
|
82401
|
+
const entry = line.slice(tab + 1);
|
|
82402
|
+
if (entry !== path && !entry.startsWith(`${path}/`))
|
|
82403
|
+
continue;
|
|
82404
|
+
sizes.set(entry.slice(path.length + 1), kib * 1024);
|
|
82405
|
+
}
|
|
82406
|
+
resolve(sizes.has("") ? sizes : undefined);
|
|
82407
|
+
});
|
|
82408
|
+
});
|
|
82409
|
+
}
|
|
82410
|
+
var owned = (entry) => [".git", ".agent-valley"].some((root) => entry === root || entry.startsWith(`${root}/`));
|
|
82411
|
+
function growthReport(before, after, thresholdBytes) {
|
|
82412
|
+
if (!before || !after || thresholdBytes <= 0)
|
|
82413
|
+
return;
|
|
82414
|
+
const delta = (entry) => (after.get(entry) ?? 0) - (before.get(entry) ?? 0);
|
|
82415
|
+
const total = delta("") - [".git", ".agent-valley"].reduce((sum, root) => sum + delta(root), 0);
|
|
82416
|
+
if (total < thresholdBytes)
|
|
82417
|
+
return;
|
|
82418
|
+
const floor = Math.max(total / 10, 64 * 1024 ** 2);
|
|
82419
|
+
const depth = (entry) => entry.split("/").length;
|
|
82420
|
+
const grown = [...after.keys()].filter((entry) => entry && !owned(entry) && delta(entry) >= floor).sort((a, b) => depth(b) - depth(a) || delta(b) - delta(a));
|
|
82421
|
+
const picked = [];
|
|
82422
|
+
for (const entry of grown)
|
|
82423
|
+
if (!picked.some((child) => child.startsWith(`${entry}/`)))
|
|
82424
|
+
picked.push(entry);
|
|
82425
|
+
const gib = (bytes) => `${(bytes / GIB2).toFixed(1)} GiB`;
|
|
82426
|
+
const where = picked.sort((a, b) => delta(b) - delta(a)).slice(0, 3).map((entry) => `${entry} (+${gib(delta(entry))})`);
|
|
82427
|
+
const size = (after.get("") ?? 0) - (after.get(".git") ?? 0) - (after.get(".agent-valley") ?? 0);
|
|
82428
|
+
return `${STORAGE_NOTE_PREFIX} this check left ${gib(total)} of new files in the workspace (${gib(size)} in total)${where.length ? `, mostly under ${where.join(", ")}` : ""}. Nothing removes them, so repeated checks fill the disk; the tests or scripts that create these files have to remove them. Until they do, name the directory in AV_WORKSPACE_SCRATCH and AV clears entries of earlier runs before each check.`;
|
|
82429
|
+
}
|
|
82430
|
+
|
|
82431
|
+
// ../../packages/core/src/chief/workspace-scratch.ts
|
|
82432
|
+
import { execFile as execFile8 } from "node:child_process";
|
|
82433
|
+
import { lstat as lstat26, readdir as readdir14, realpath as realpath27, rm as rm11 } from "node:fs/promises";
|
|
82434
|
+
import { isAbsolute as isAbsolute18, join as join47, normalize, sep as sep18 } from "node:path";
|
|
82435
|
+
var WORKSPACE_SCRATCH_ENV = "AV_WORKSPACE_SCRATCH";
|
|
82436
|
+
var WORKSPACE_SCRATCH_MINUTES_ENV = "AV_WORKSPACE_SCRATCH_MINUTES";
|
|
82437
|
+
var DEFAULT_WORKSPACE_SCRATCH_MINUTES = 30;
|
|
82438
|
+
var ignored = (workspace, directory) => new Promise((resolve) => {
|
|
82439
|
+
execFile8("git", ["-C", workspace, "check-ignore", "-q", "--", directory], { timeout: 20000 }, (error) => resolve(!error));
|
|
82440
|
+
});
|
|
82441
|
+
function scratchDirectories(env = process.env) {
|
|
82442
|
+
return [
|
|
82443
|
+
...new Set((env[WORKSPACE_SCRATCH_ENV] ?? "").split(/[,\n]/).map((entry) => entry.trim()).filter(Boolean))
|
|
82444
|
+
];
|
|
82445
|
+
}
|
|
82446
|
+
function scratchAgeMs(env) {
|
|
82447
|
+
const raw = env[WORKSPACE_SCRATCH_MINUTES_ENV]?.trim();
|
|
82448
|
+
const minutes = raw ? Number(raw) : DEFAULT_WORKSPACE_SCRATCH_MINUTES;
|
|
82449
|
+
return (Number.isFinite(minutes) && minutes >= 0 ? minutes : DEFAULT_WORKSPACE_SCRATCH_MINUTES) * 60000;
|
|
82450
|
+
}
|
|
82451
|
+
async function releaseWorkspaceScratch(workspace, env = process.env, now = Date.now()) {
|
|
82452
|
+
const result = { cleared: [], skipped: [] };
|
|
82453
|
+
const directories = scratchDirectories(env);
|
|
82454
|
+
if (!directories.length)
|
|
82455
|
+
return result;
|
|
82456
|
+
const limit = now - scratchAgeMs(env);
|
|
82457
|
+
const root = await realpath27(workspace);
|
|
82458
|
+
for (const directory of directories) {
|
|
82459
|
+
const skip = (reason) => result.skipped.push({ directory, reason });
|
|
82460
|
+
const relative = normalize(directory);
|
|
82461
|
+
const first = relative.split(sep18)[0];
|
|
82462
|
+
if (isAbsolute18(directory) || relative === "." || first === ".." || first === ".git" || first === ".agent-valley") {
|
|
82463
|
+
skip("it is not a directory inside the workspace's own files; use a workspace-relative path");
|
|
82464
|
+
continue;
|
|
82465
|
+
}
|
|
82466
|
+
const path = join47(root, relative);
|
|
82467
|
+
try {
|
|
82468
|
+
if (!(await lstat26(path)).isDirectory() || await realpath27(path) !== path) {
|
|
82469
|
+
skip("it is not a plain directory (a symbolic link is never followed)");
|
|
82470
|
+
continue;
|
|
82471
|
+
}
|
|
82472
|
+
} catch {
|
|
82473
|
+
continue;
|
|
82474
|
+
}
|
|
82475
|
+
if (!await ignored(root, relative)) {
|
|
82476
|
+
skip("it is not Git-ignored; AV clears only ignored output, never tracked or untracked product files");
|
|
82477
|
+
continue;
|
|
82478
|
+
}
|
|
82479
|
+
let entries = 0;
|
|
82480
|
+
for (const name of await readdir14(path)) {
|
|
82481
|
+
const child = join47(path, name);
|
|
82482
|
+
try {
|
|
82483
|
+
if ((await lstat26(child)).mtimeMs >= limit)
|
|
82484
|
+
continue;
|
|
82485
|
+
await rm11(child, { recursive: true, force: true });
|
|
82486
|
+
entries += 1;
|
|
82487
|
+
} catch {}
|
|
82488
|
+
}
|
|
82489
|
+
if (entries)
|
|
82490
|
+
result.cleared.push({ directory: relative, entries });
|
|
82491
|
+
}
|
|
82492
|
+
return result;
|
|
82493
|
+
}
|
|
82494
|
+
function scratchNote(release) {
|
|
82495
|
+
const parts = [
|
|
82496
|
+
...release.cleared.map((entry) => `AV cleared ${entry.entries} entries of earlier runs from ${entry.directory}.`),
|
|
82497
|
+
...release.skipped.map((entry) => `${WORKSPACE_SCRATCH_ENV} entry ${entry.directory} was not cleared: ${entry.reason}.`)
|
|
82498
|
+
];
|
|
82499
|
+
return parts.length ? `Storage: ${parts.join(" ")}` : undefined;
|
|
82500
|
+
}
|
|
82501
|
+
|
|
82374
82502
|
// ../../packages/core/src/chief/runtime-integration-check.ts
|
|
82375
82503
|
var INTEGRATION_CHECK_ENV = "AV_INTEGRATION_CHECK";
|
|
82376
82504
|
var INTEGRATION_CHECK_COMMAND_ENV = "AV_INTEGRATION_CHECK_COMMAND";
|
|
@@ -82417,6 +82545,18 @@ async function runIntegrationCheck(mission, active, signal, source = process.env
|
|
|
82417
82545
|
if (!command && !mission.verificationContract)
|
|
82418
82546
|
return;
|
|
82419
82547
|
await assertMissionWorkspace(mission);
|
|
82548
|
+
const cleared = scratchNote(await releaseWorkspaceScratch(mission.workspace.path, source));
|
|
82549
|
+
const threshold = growthThresholdBytes(source);
|
|
82550
|
+
const before = threshold > 0 ? await directorySizes(mission.workspace.path) : undefined;
|
|
82551
|
+
const result = await checkIntegratedTree(mission, active, command, signal, source);
|
|
82552
|
+
if (!result)
|
|
82553
|
+
return result;
|
|
82554
|
+
const growth = before ? growthReport(before, await directorySizes(mission.workspace.path), threshold) : undefined;
|
|
82555
|
+
const storage = [cleared, growth].filter((note) => note !== undefined).map((note, index) => index ? note.slice(STORAGE_NOTE_PREFIX.length + 1) : note).join(" ");
|
|
82556
|
+
return storage ? { ok: result.ok, output: `${storage}
|
|
82557
|
+
${result.output}`.slice(0, 8000) } : result;
|
|
82558
|
+
}
|
|
82559
|
+
async function checkIntegratedTree(mission, active, command, signal, source) {
|
|
82420
82560
|
active.begin("verify");
|
|
82421
82561
|
try {
|
|
82422
82562
|
const operator = async () => operatorIntegrationResult(command ?? "", await runVerificationGate(mission.workspace, command ?? "", {
|
|
@@ -82528,7 +82668,7 @@ class ChiefRuntime {
|
|
|
82528
82668
|
const workspace = context?.workspace ?? mission.workspace;
|
|
82529
82669
|
const savedCatalog = workspace === mission.workspace ? mission.availableSkills : mission.availableSkills?.map((skill) => ({
|
|
82530
82670
|
...skill,
|
|
82531
|
-
path:
|
|
82671
|
+
path: join48(workspace.path, ".agents", "skills", skill.name, "SKILL.md")
|
|
82532
82672
|
}));
|
|
82533
82673
|
const catalog = savedCatalog ?? await discoverMissionSkills(workspace.path);
|
|
82534
82674
|
if (!requiresOmaActor({ oma: mission.oma, availableSkills: catalog }))
|
|
@@ -82546,6 +82686,9 @@ class ChiefRuntime {
|
|
|
82546
82686
|
throw new Error("A trusted verification command is required. Set --verify before creating an order.");
|
|
82547
82687
|
if (mission.verificationContract)
|
|
82548
82688
|
await assertMissionWorkspace(mission);
|
|
82689
|
+
await releaseWorkspaceScratch(mission.workspace.path).catch(() => {
|
|
82690
|
+
return;
|
|
82691
|
+
});
|
|
82549
82692
|
const active = this.store.processGuard(mission.id);
|
|
82550
82693
|
active.begin("verify");
|
|
82551
82694
|
try {
|
|
@@ -82589,7 +82732,7 @@ class ChiefRuntime {
|
|
|
82589
82732
|
workspace,
|
|
82590
82733
|
availableSkills: mission.availableSkills?.map((skill) => ({
|
|
82591
82734
|
...skill,
|
|
82592
|
-
path:
|
|
82735
|
+
path: join48(workspace.path, ".agents", "skills", skill.name, "SKILL.md")
|
|
82593
82736
|
}))
|
|
82594
82737
|
};
|
|
82595
82738
|
if (signal?.aborted)
|
|
@@ -83363,15 +83506,15 @@ init_execution();
|
|
|
83363
83506
|
|
|
83364
83507
|
// src/chief-supervisor.ts
|
|
83365
83508
|
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
83366
|
-
import { join as
|
|
83509
|
+
import { join as join52 } from "node:path";
|
|
83367
83510
|
init_execution();
|
|
83368
83511
|
// src/chief-delivery.ts
|
|
83369
83512
|
import { createHash as createHash29 } from "node:crypto";
|
|
83370
83513
|
import { mkdir as mkdir22, writeFile as writeFile15 } from "node:fs/promises";
|
|
83371
|
-
import { join as
|
|
83514
|
+
import { join as join51 } from "node:path";
|
|
83372
83515
|
|
|
83373
83516
|
// ../../packages/core/src/chief/report-delivery.ts
|
|
83374
|
-
import { join as
|
|
83517
|
+
import { join as join50 } from "node:path";
|
|
83375
83518
|
|
|
83376
83519
|
// ../../packages/core/src/chief/report-delivery-adapters.ts
|
|
83377
83520
|
init_report_delivery_contract();
|
|
@@ -83755,8 +83898,8 @@ init_atomic_json();
|
|
|
83755
83898
|
init_report_delivery_contract();
|
|
83756
83899
|
import { createHash as createHash28 } from "node:crypto";
|
|
83757
83900
|
import { constants as constants14 } from "node:fs";
|
|
83758
|
-
import { mkdir as mkdir21, open as open15, readdir as
|
|
83759
|
-
import { isAbsolute as
|
|
83901
|
+
import { mkdir as mkdir21, open as open15, readdir as readdir15, readFile as readFile18, realpath as realpath28 } from "node:fs/promises";
|
|
83902
|
+
import { isAbsolute as isAbsolute19, join as join49, relative as relative15, resolve as resolve30 } from "node:path";
|
|
83760
83903
|
var hash4 = string2().regex(/^[a-f0-9]{64}$/);
|
|
83761
83904
|
var outboxRecordSchema = strictObject({
|
|
83762
83905
|
version: literal(1),
|
|
@@ -83798,12 +83941,12 @@ function receipt(record) {
|
|
|
83798
83941
|
class ReportOutbox {
|
|
83799
83942
|
directory;
|
|
83800
83943
|
constructor(stateDir) {
|
|
83801
|
-
this.directory =
|
|
83944
|
+
this.directory = join49(stateDir, "report-outbox");
|
|
83802
83945
|
}
|
|
83803
83946
|
path(id) {
|
|
83804
83947
|
if (!hash4.safeParse(id).success)
|
|
83805
83948
|
throw new Error("Invalid report receipt ID. Use av reports to find a receipt.");
|
|
83806
|
-
return
|
|
83949
|
+
return join49(this.directory, `${id}.json`);
|
|
83807
83950
|
}
|
|
83808
83951
|
lock(id) {
|
|
83809
83952
|
return new MissionStore(this.directory).lock(id);
|
|
@@ -83832,7 +83975,7 @@ class ReportOutbox {
|
|
|
83832
83975
|
await writeJsonAtomic(this.path(record.id), record);
|
|
83833
83976
|
}
|
|
83834
83977
|
async list() {
|
|
83835
|
-
const names = await
|
|
83978
|
+
const names = await readdir15(this.directory).catch((error) => {
|
|
83836
83979
|
if (error.code === "ENOENT")
|
|
83837
83980
|
return [];
|
|
83838
83981
|
throw new Error("Cannot list report outbox. Restore access to the Chief Director state directory.");
|
|
@@ -83850,10 +83993,10 @@ async function validateReportAttachment(attachment, artifactRoot) {
|
|
|
83850
83993
|
async function verifiedAttachment(attachment, artifactRoot, readBytes) {
|
|
83851
83994
|
const failure = new ReportDeliveryError("Capture file is missing, changed, or outside the artifact directory. Restore the original capture and retry av reports.", true, false);
|
|
83852
83995
|
try {
|
|
83853
|
-
const root = await
|
|
83854
|
-
const path = await
|
|
83996
|
+
const root = await realpath28(artifactRoot);
|
|
83997
|
+
const path = await realpath28(attachment.path);
|
|
83855
83998
|
const local = relative15(root, path);
|
|
83856
|
-
if (!local || local.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || local === ".." ||
|
|
83999
|
+
if (!local || local.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || local === ".." || isAbsolute19(local))
|
|
83857
84000
|
throw failure;
|
|
83858
84001
|
if (resolve30(attachment.path) !== attachment.path)
|
|
83859
84002
|
throw failure;
|
|
@@ -83910,7 +84053,7 @@ function dependencies(stateDir, overrides) {
|
|
|
83910
84053
|
env: overrides.env ?? process.env,
|
|
83911
84054
|
registry: { ...createReportChannelRegistry(fetch2), ...overrides.registry },
|
|
83912
84055
|
attachments: overrides.attachments ?? [],
|
|
83913
|
-
artifactRoot: overrides.artifactRoot ??
|
|
84056
|
+
artifactRoot: overrides.artifactRoot ?? join50(stateDir, "captures"),
|
|
83914
84057
|
now: overrides.now ?? (() => new Date)
|
|
83915
84058
|
};
|
|
83916
84059
|
}
|
|
@@ -84091,8 +84234,8 @@ init_chief_schema();
|
|
|
84091
84234
|
init_yaml_loader();
|
|
84092
84235
|
async function saveAndDeliverMissionReport(mission, root) {
|
|
84093
84236
|
const repository = mission.repositoryRoot ?? root;
|
|
84094
|
-
const directory =
|
|
84095
|
-
const reportPath =
|
|
84237
|
+
const directory = join51(root, ".agent-valley/reports");
|
|
84238
|
+
const reportPath = join51(directory, `${mission.id}.md`);
|
|
84096
84239
|
const report = renderReport(mission);
|
|
84097
84240
|
await mkdir22(directory, { recursive: true, mode: 448 });
|
|
84098
84241
|
await writeFile15(reportPath, report, { mode: 384 });
|
|
@@ -84107,12 +84250,12 @@ ${explanation.eli5}`);
|
|
|
84107
84250
|
try {
|
|
84108
84251
|
const config = mergeChiefConfig(loadGlobalConfig()?.chief, loadProjectConfig(root)?.chief);
|
|
84109
84252
|
const attachments = [...mission.capture?.attachments ?? []];
|
|
84110
|
-
const artifactRoot =
|
|
84253
|
+
const artifactRoot = join51(repository, ".agent-valley/captures");
|
|
84111
84254
|
if (config.reporting?.destinations.length) {
|
|
84112
84255
|
const bytes = Buffer.from(report);
|
|
84113
84256
|
const sha256 = createHash29("sha256").update(bytes).digest("hex");
|
|
84114
|
-
const reportDirectory =
|
|
84115
|
-
const attachmentPath =
|
|
84257
|
+
const reportDirectory = join51(artifactRoot, mission.id);
|
|
84258
|
+
const attachmentPath = join51(reportDirectory, `report-${sha256}.md`);
|
|
84116
84259
|
await mkdir22(reportDirectory, { recursive: true, mode: 448 });
|
|
84117
84260
|
await writeFile15(attachmentPath, bytes, { mode: 384 });
|
|
84118
84261
|
attachments.push({
|
|
@@ -84123,7 +84266,7 @@ ${explanation.eli5}`);
|
|
|
84123
84266
|
sha256
|
|
84124
84267
|
});
|
|
84125
84268
|
}
|
|
84126
|
-
const receipts = await dispatchMissionReport(mission, report, reportPath, config.reporting,
|
|
84269
|
+
const receipts = await dispatchMissionReport(mission, report, reportPath, config.reporting, join51(repository, ".agent-valley"), {
|
|
84127
84270
|
attachments,
|
|
84128
84271
|
artifactRoot
|
|
84129
84272
|
});
|
|
@@ -84388,7 +84531,7 @@ function abortableDelay(ms, signal) {
|
|
|
84388
84531
|
async function superviseOrder(goal, options, root, dependencies = {}) {
|
|
84389
84532
|
assertNotManagedRun();
|
|
84390
84533
|
const id = options.resume ?? options.missionId ?? randomUUID20();
|
|
84391
|
-
const store = new MissionStore(
|
|
84534
|
+
const store = new MissionStore(join52(root, ".agent-valley/missions"));
|
|
84392
84535
|
const controller = new AbortController;
|
|
84393
84536
|
const interrupt = () => controller.abort(dependencies.signal?.reason);
|
|
84394
84537
|
const terminate = () => controller.abort(options.service ? serviceShutdownPause() : undefined);
|
|
@@ -84744,7 +84887,7 @@ init_sandbox_binary();
|
|
|
84744
84887
|
init_agent_discovery();
|
|
84745
84888
|
import { readFileSync as readFileSync10, statSync as statSync4 } from "node:fs";
|
|
84746
84889
|
import { homedir as homedir10 } from "node:os";
|
|
84747
|
-
import { join as
|
|
84890
|
+
import { join as join53 } from "node:path";
|
|
84748
84891
|
import { stripVTControlCharacters as stripVTControlCharacters4 } from "node:util";
|
|
84749
84892
|
var MAX_OUTPUT_BYTES4 = 2097152;
|
|
84750
84893
|
var PROBE_TIMEOUT_MS2 = 15000;
|
|
@@ -84870,8 +85013,8 @@ async function discoverFreeModels(agentType, workspacePath, signal, overrides =
|
|
|
84870
85013
|
};
|
|
84871
85014
|
let state;
|
|
84872
85015
|
try {
|
|
84873
|
-
const home = env.XDG_STATE_HOME ||
|
|
84874
|
-
const content = deps.readState(
|
|
85016
|
+
const home = env.XDG_STATE_HOME || join53(env.HOME || homedir10(), ".local", "state");
|
|
85017
|
+
const content = deps.readState(join53(home, agentType, "model.json"));
|
|
84875
85018
|
state = content && Buffer.byteLength(content) <= MAX_OUTPUT_BYTES4 ? JSON.parse(content) : undefined;
|
|
84876
85019
|
} catch {
|
|
84877
85020
|
state = undefined;
|
|
@@ -84902,8 +85045,8 @@ async function discoverFreeModels(agentType, workspacePath, signal, overrides =
|
|
|
84902
85045
|
// ../../packages/core/src/chief/metric-source-adapters.ts
|
|
84903
85046
|
init_metric_source_policy();
|
|
84904
85047
|
import { constants as constants15 } from "node:fs";
|
|
84905
|
-
import { lstat as
|
|
84906
|
-
import { isAbsolute as
|
|
85048
|
+
import { lstat as lstat27, open as open16, realpath as realpath29 } from "node:fs/promises";
|
|
85049
|
+
import { isAbsolute as isAbsolute20, relative as relative16, resolve as resolve31, sep as sep19 } from "node:path";
|
|
84907
85050
|
var MAX_METRIC_RESPONSE_BYTES = 2000000;
|
|
84908
85051
|
function metricSourceEnvironment(request, name) {
|
|
84909
85052
|
if (!name || !request.env[name]?.trim())
|
|
@@ -84986,24 +85129,24 @@ var httpJsonMetricAdapter = {
|
|
|
84986
85129
|
};
|
|
84987
85130
|
var jsonFileMetricAdapter = {
|
|
84988
85131
|
async collect(request) {
|
|
84989
|
-
const root = await
|
|
85132
|
+
const root = await realpath29(request.repositoryRoot);
|
|
84990
85133
|
const name = request.source.file;
|
|
84991
|
-
if (!name ||
|
|
85134
|
+
if (!name || isAbsolute20(name))
|
|
84992
85135
|
throw new MetricSourceError("Metric file must be relative to the source repository. Set chief.metric_sources.sources[].file in av.yaml.");
|
|
84993
85136
|
const path = resolve31(root, name);
|
|
84994
85137
|
const within = relative16(root, path);
|
|
84995
|
-
if (!within || within.startsWith(`..${
|
|
85138
|
+
if (!within || within.startsWith(`..${sep19}`) || within === ".." || isAbsolute20(within))
|
|
84996
85139
|
throw new MetricSourceError("Metric file escapes the source repository. Choose a repository-relative JSON file.");
|
|
84997
85140
|
let current = root;
|
|
84998
|
-
for (const part of within.split(
|
|
85141
|
+
for (const part of within.split(sep19)) {
|
|
84999
85142
|
current = resolve31(current, part);
|
|
85000
|
-
if ((await
|
|
85143
|
+
if ((await lstat27(current)).isSymbolicLink())
|
|
85001
85144
|
throw new MetricSourceError("Metric file and parent directories must not be symlinks. Choose a regular JSON file inside the source repository.");
|
|
85002
85145
|
}
|
|
85003
85146
|
const file = await open16(path, constants15.O_RDONLY | constants15.O_NOFOLLOW);
|
|
85004
85147
|
try {
|
|
85005
85148
|
const stat = await file.stat();
|
|
85006
|
-
if (!stat.isFile() || stat.size > MAX_METRIC_RESPONSE_BYTES || await
|
|
85149
|
+
if (!stat.isFile() || stat.size > MAX_METRIC_RESPONSE_BYTES || await realpath29(path) !== path)
|
|
85007
85150
|
throw new MetricSourceError("Metric file must be a regular JSON file of at most 2 MB inside the source repository.");
|
|
85008
85151
|
const bytes = await file.readFile();
|
|
85009
85152
|
if (bytes.byteLength > MAX_METRIC_RESPONSE_BYTES)
|
|
@@ -85402,8 +85545,8 @@ function createMissionMetricPorts(repository, mission, dependencies = {}) {
|
|
|
85402
85545
|
// src/chief-tool-config.ts
|
|
85403
85546
|
import { randomUUID as randomUUID22 } from "node:crypto";
|
|
85404
85547
|
import { constants as constants16 } from "node:fs";
|
|
85405
|
-
import { link as link2, lstat as
|
|
85406
|
-
import { join as
|
|
85548
|
+
import { link as link2, lstat as lstat28, mkdir as mkdir23, open as open17, realpath as realpath30, unlink as unlink5 } from "node:fs/promises";
|
|
85549
|
+
import { join as join54 } from "node:path";
|
|
85407
85550
|
init_dist2();
|
|
85408
85551
|
init_client_toml();
|
|
85409
85552
|
var maximumBytes = 1024 * 1024;
|
|
@@ -85422,8 +85565,8 @@ async function assertLocalPath(root, local) {
|
|
|
85422
85565
|
const parts = local.split("/");
|
|
85423
85566
|
let current = root;
|
|
85424
85567
|
for (const [index, part] of parts.entries()) {
|
|
85425
|
-
current =
|
|
85426
|
-
const stats = await
|
|
85568
|
+
current = join54(current, part);
|
|
85569
|
+
const stats = await lstat28(current).catch((error) => {
|
|
85427
85570
|
if (error.code === "ENOENT")
|
|
85428
85571
|
return;
|
|
85429
85572
|
throw error;
|
|
@@ -85479,10 +85622,10 @@ async function privateExclude(original, target, paths) {
|
|
|
85479
85622
|
]);
|
|
85480
85623
|
const common = targetCommon.trim();
|
|
85481
85624
|
const path = exclude.trim();
|
|
85482
|
-
if (common !==
|
|
85625
|
+
if (common !== join54(target, ".git") && common !== originalCommon.trim() || path !== join54(common, "info", "exclude") || await realpath30(common) !== common)
|
|
85483
85626
|
throw new ChiefToolConfigError("Chief MCP configuration requires the workspace's own Git metadata or its original repository's shared worktree metadata.");
|
|
85484
|
-
const info =
|
|
85485
|
-
const infoStats = await
|
|
85627
|
+
const info = join54(common, "info");
|
|
85628
|
+
const infoStats = await lstat28(info).catch((error) => {
|
|
85486
85629
|
if (error.code === "ENOENT")
|
|
85487
85630
|
return;
|
|
85488
85631
|
throw error;
|
|
@@ -85491,7 +85634,7 @@ async function privateExclude(original, target, paths) {
|
|
|
85491
85634
|
throw new ChiefToolConfigError("Git info storage must be a local directory before preparing Chief MCP tools.");
|
|
85492
85635
|
if (!infoStats)
|
|
85493
85636
|
await mkdir23(info, { mode: 448 });
|
|
85494
|
-
if (await
|
|
85637
|
+
if (await realpath30(info) !== info)
|
|
85495
85638
|
throw new ChiefToolConfigError("Git info storage redirects through a symlink. Restore it before preparing Chief MCP tools.");
|
|
85496
85639
|
const exists = await assertLocalPath(common, "info/exclude");
|
|
85497
85640
|
const content = exists ? await readPrivateFile(path) : "";
|
|
@@ -85511,7 +85654,7 @@ async function privateExclude(original, target, paths) {
|
|
|
85511
85654
|
}
|
|
85512
85655
|
}
|
|
85513
85656
|
async function prepareToolConfig(originalRepository, targetWorkspace) {
|
|
85514
|
-
const [original, target] = await Promise.all([
|
|
85657
|
+
const [original, target] = await Promise.all([realpath30(originalRepository), realpath30(targetWorkspace)]);
|
|
85515
85658
|
if (original === target)
|
|
85516
85659
|
throw new ChiefToolConfigError("Prepare Chief MCP tools in a separate mission workspace using its original repository root.");
|
|
85517
85660
|
const selected = [];
|
|
@@ -85520,29 +85663,29 @@ async function prepareToolConfig(originalRepository, targetWorkspace) {
|
|
|
85520
85663
|
continue;
|
|
85521
85664
|
if (!await assertLocalPath(original, config.path))
|
|
85522
85665
|
continue;
|
|
85523
|
-
const content = selectedNamespace(await readPrivateFile(
|
|
85666
|
+
const content = selectedNamespace(await readPrivateFile(join54(original, config.path)), config.namespace, config.toml);
|
|
85524
85667
|
if (content)
|
|
85525
85668
|
selected.push({ path: config.path, content });
|
|
85526
85669
|
}
|
|
85527
85670
|
if (!selected.length)
|
|
85528
85671
|
return;
|
|
85529
85672
|
for (const root of [original, target]) {
|
|
85530
|
-
const stats = await
|
|
85531
|
-
if (stats.isSymbolicLink() || !stats.isFile() && !stats.isDirectory() || await
|
|
85673
|
+
const stats = await lstat28(join54(root, ".git"));
|
|
85674
|
+
if (stats.isSymbolicLink() || !stats.isFile() && !stats.isDirectory() || await realpath30((await parallelGit(root, ["rev-parse", "--show-toplevel"])).trim()) !== root)
|
|
85532
85675
|
throw new ChiefToolConfigError("Chief MCP tools require original local Git repository metadata. Restore the workspace before starting Chief.");
|
|
85533
85676
|
}
|
|
85534
85677
|
await privateExclude(original, target, selected.map((config) => config.path));
|
|
85535
85678
|
for (const config of selected) {
|
|
85536
85679
|
const parts = config.path.split("/");
|
|
85537
85680
|
if (parts.length > 1) {
|
|
85538
|
-
const parent =
|
|
85681
|
+
const parent = join54(target, ...parts.slice(0, -1));
|
|
85539
85682
|
await mkdir23(parent, { recursive: true, mode: 448 });
|
|
85540
|
-
if (await
|
|
85683
|
+
if (await realpath30(parent) !== parent)
|
|
85541
85684
|
throw new ChiefToolConfigError("Chief MCP configuration parent redirects through a symlink. Restore its local directory.");
|
|
85542
85685
|
}
|
|
85543
85686
|
if (await assertLocalPath(target, config.path))
|
|
85544
85687
|
continue;
|
|
85545
|
-
const path =
|
|
85688
|
+
const path = join54(target, config.path);
|
|
85546
85689
|
const temporary = `${path}.av-mcp-${randomUUID22()}.tmp`;
|
|
85547
85690
|
const file = await open17(temporary, "wx", 384);
|
|
85548
85691
|
try {
|
|
@@ -85574,9 +85717,9 @@ async function prepareChiefToolConfig(originalRepository, targetWorkspace) {
|
|
|
85574
85717
|
// src/tool-discovery.ts
|
|
85575
85718
|
init_client_toml();
|
|
85576
85719
|
import { constants as constants17 } from "node:fs";
|
|
85577
|
-
import { access as access2, lstat as
|
|
85720
|
+
import { access as access2, lstat as lstat29, readFile as readFile19, realpath as realpath31 } from "node:fs/promises";
|
|
85578
85721
|
import { homedir as homedir11 } from "node:os";
|
|
85579
|
-
import { delimiter as delimiter3, isAbsolute as
|
|
85722
|
+
import { delimiter as delimiter3, isAbsolute as isAbsolute21, join as join55, resolve as resolve32 } from "node:path";
|
|
85580
85723
|
var binaries = [
|
|
85581
85724
|
"docker",
|
|
85582
85725
|
"orb",
|
|
@@ -85592,11 +85735,11 @@ var binaries = [
|
|
|
85592
85735
|
var MAX_CONFIG_BYTES = 1048576;
|
|
85593
85736
|
var record7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
85594
85737
|
async function executable2(name, env) {
|
|
85595
|
-
for (const directory of (env.PATH ?? "").split(delimiter3).filter(
|
|
85738
|
+
for (const directory of (env.PATH ?? "").split(delimiter3).filter(isAbsolute21)) {
|
|
85596
85739
|
try {
|
|
85597
|
-
const path =
|
|
85740
|
+
const path = join55(directory, name);
|
|
85598
85741
|
await access2(path, constants17.X_OK);
|
|
85599
|
-
if ((await
|
|
85742
|
+
if ((await lstat29(await realpath31(path))).isFile())
|
|
85600
85743
|
return true;
|
|
85601
85744
|
} catch {}
|
|
85602
85745
|
}
|
|
@@ -85605,7 +85748,7 @@ async function executable2(name, env) {
|
|
|
85605
85748
|
async function mcpNames(path, scope, project, requestedRoot) {
|
|
85606
85749
|
const base = { kind: "mcp", scope, authentication: "unknown", source: path };
|
|
85607
85750
|
try {
|
|
85608
|
-
const info = await
|
|
85751
|
+
const info = await lstat29(path);
|
|
85609
85752
|
if (!info.isFile() || info.isSymbolicLink() || info.size > MAX_CONFIG_BYTES)
|
|
85610
85753
|
throw new Error("Invalid config");
|
|
85611
85754
|
const source = await readFile19(path, "utf8");
|
|
@@ -85649,7 +85792,7 @@ async function mcpNames(path, scope, project, requestedRoot) {
|
|
|
85649
85792
|
async function discoverTools(root, dependencies = {}) {
|
|
85650
85793
|
const env = dependencies.env ?? process.env;
|
|
85651
85794
|
const home = dependencies.home ?? homedir11();
|
|
85652
|
-
const project = await
|
|
85795
|
+
const project = await realpath31(root);
|
|
85653
85796
|
const projectFiles = [
|
|
85654
85797
|
".mcp.json",
|
|
85655
85798
|
".cursor/mcp.json",
|
|
@@ -85659,11 +85802,11 @@ async function discoverTools(root, dependencies = {}) {
|
|
|
85659
85802
|
".codex/config.toml"
|
|
85660
85803
|
];
|
|
85661
85804
|
const userFiles = [".claude.json", ".cursor/mcp.json", ".qwen/settings.json", ".gemini/settings.json"];
|
|
85662
|
-
const codexHome = env.CODEX_HOME &&
|
|
85805
|
+
const codexHome = env.CODEX_HOME && isAbsolute21(env.CODEX_HOME) ? env.CODEX_HOME : join55(home, ".codex");
|
|
85663
85806
|
const configs = [
|
|
85664
|
-
...projectFiles.map((path) => ({ path:
|
|
85807
|
+
...projectFiles.map((path) => ({ path: join55(project, path), scope: "project" })),
|
|
85665
85808
|
...userFiles.map((path) => ({ path: resolve32(home, path), scope: "user" })),
|
|
85666
|
-
{ path:
|
|
85809
|
+
{ path: join55(codexHome, "config.toml"), scope: "user" }
|
|
85667
85810
|
];
|
|
85668
85811
|
const [cli, mcp] = await Promise.all([
|
|
85669
85812
|
Promise.all(binaries.map(async (name) => ({
|
|
@@ -85719,7 +85862,7 @@ function seededExhaustion(operation, now) {
|
|
|
85719
85862
|
async function decideContinuousGoal(operation, decisionId, root, dependencies = {}) {
|
|
85720
85863
|
if (!operation.baseline)
|
|
85721
85864
|
throw new Error("An accepted operation baseline is required before selecting a goal.");
|
|
85722
|
-
const store = new MissionStore(
|
|
85865
|
+
const store = new MissionStore(join56(root, ".agent-valley", "operation-decisions", operation.id));
|
|
85723
85866
|
const unlock = await store.lock(decisionId);
|
|
85724
85867
|
const runtime = (dependencies.runtime ?? ((storage, signal) => new ChiefRuntime(storage, signal, undefined, undefined, undefined, discoverReadyAgents, discoverFreeModels)))(store, dependencies.signal);
|
|
85725
85868
|
let mission;
|
|
@@ -85833,7 +85976,7 @@ async function decideContinuousGoal(operation, decisionId, root, dependencies =
|
|
|
85833
85976
|
const previousId = operation.history.at(-1)?.missionId;
|
|
85834
85977
|
let previousReport;
|
|
85835
85978
|
if (previousId) {
|
|
85836
|
-
const previous = await new MissionStore(
|
|
85979
|
+
const previous = await new MissionStore(join56(root, ".agent-valley", "missions")).load(previousId);
|
|
85837
85980
|
if (previous.repositoryRoot !== operation.repositoryRoot || previous.status !== "completed")
|
|
85838
85981
|
throw new Error("The previous accepted child's evidence no longer matches this operation. Restore its saved checkpoint before selecting another goal.");
|
|
85839
85982
|
previousReport = renderReport(previous).slice(0, 16000);
|
|
@@ -85872,7 +86015,7 @@ async function decideContinuousGoal(operation, decisionId, root, dependencies =
|
|
|
85872
86015
|
|
|
85873
86016
|
// src/chief-continuous-report.ts
|
|
85874
86017
|
import { mkdir as mkdir24 } from "node:fs/promises";
|
|
85875
|
-
import { join as
|
|
86018
|
+
import { join as join57 } from "node:path";
|
|
85876
86019
|
init_atomic_json();
|
|
85877
86020
|
function operationDeliveryLines(operation, delivery, unavailable = false) {
|
|
85878
86021
|
const integration = operation.sourceIntegration;
|
|
@@ -85933,17 +86076,17 @@ function renderOperationReport(operation, delivery, unavailable = false) {
|
|
|
85933
86076
|
`);
|
|
85934
86077
|
}
|
|
85935
86078
|
async function saveOperationReport(root, operation) {
|
|
85936
|
-
const directory =
|
|
86079
|
+
const directory = join57(root, ".agent-valley", "operation-reports");
|
|
85937
86080
|
await mkdir24(directory, { recursive: true, mode: 448 });
|
|
85938
86081
|
const evidence = await deliveryFor(root, operation);
|
|
85939
|
-
await writeTextAtomic(
|
|
86082
|
+
await writeTextAtomic(join57(directory, `${operation.id}.md`), renderOperationReport(operation, evidence.delivery, evidence.unavailable));
|
|
85940
86083
|
}
|
|
85941
86084
|
async function deliveryFor(root, operation) {
|
|
85942
86085
|
const id = operation.currentMissionId ?? operation.history.at(-1)?.missionId;
|
|
85943
86086
|
if (!id)
|
|
85944
86087
|
return {};
|
|
85945
86088
|
try {
|
|
85946
|
-
const mission = await new MissionStore(
|
|
86089
|
+
const mission = await new MissionStore(join57(root, ".agent-valley", "missions")).load(id);
|
|
85947
86090
|
return mission.repositoryRoot === operation.repositoryRoot ? { delivery: mission.codeDelivery } : { unavailable: true };
|
|
85948
86091
|
} catch {
|
|
85949
86092
|
return { unavailable: true };
|
|
@@ -85976,7 +86119,7 @@ function createOperationProgressReporter(root, write = console.log) {
|
|
|
85976
86119
|
};
|
|
85977
86120
|
}
|
|
85978
86121
|
// src/chief-source-integration.ts
|
|
85979
|
-
import { join as
|
|
86122
|
+
import { join as join58 } from "node:path";
|
|
85980
86123
|
init_execution();
|
|
85981
86124
|
function sourceIntegrationCheckpoint(operation) {
|
|
85982
86125
|
const accepted = operation.baseline;
|
|
@@ -85999,7 +86142,7 @@ async function initialSourceIntegration(repositoryRoot, id, mode, remoteDelivery
|
|
|
85999
86142
|
async function assertChildSettled(operation, storageRoot) {
|
|
86000
86143
|
if (!operation.currentMissionId)
|
|
86001
86144
|
return;
|
|
86002
|
-
const missions = new MissionStore(
|
|
86145
|
+
const missions = new MissionStore(join58(storageRoot, ".agent-valley", "missions"));
|
|
86003
86146
|
if (await missions.isLocked(operation.currentMissionId))
|
|
86004
86147
|
throw new Error("The current child is still owned by another coordinator. Resume source integration after its checkpoint is settled.");
|
|
86005
86148
|
const child = await missions.load(operation.currentMissionId).catch((error) => {
|
|
@@ -86050,7 +86193,7 @@ async function resumeSourceIntegration(operation, mode, storageRoot, signal, sav
|
|
|
86050
86193
|
if (selected !== "snapshot-only")
|
|
86051
86194
|
throw new Error("This operation already uses explicit commit and push delivery. Keep its saved delivery policy instead of adding worktree application.");
|
|
86052
86195
|
}
|
|
86053
|
-
const persist = save ?? ((current) => new ContinuousOperationStore(
|
|
86196
|
+
const persist = save ?? ((current) => new ContinuousOperationStore(join58(storageRoot, ".agent-valley", "operations")).save(current));
|
|
86054
86197
|
const { accepted, applied, caughtUp, pendingIds } = sourceIntegrationCheckpoint(operation);
|
|
86055
86198
|
const activation = selected === "worktree" && operation.sourceIntegrationPolicy?.mode !== "worktree";
|
|
86056
86199
|
if (activation) {
|
|
@@ -86091,7 +86234,7 @@ async function resumeSourceIntegration(operation, mode, storageRoot, signal, sav
|
|
|
86091
86234
|
if (policy?.mode === "worktree" && accepted?.missionId && (applied?.missionId !== accepted.missionId || applied.nextTree !== accepted.baselineTree)) {
|
|
86092
86235
|
if (applied?.missionId === accepted.missionId)
|
|
86093
86236
|
throw new Error("The saved source application summary differs from its accepted snapshot. Restore the original verified receipt before resuming.");
|
|
86094
|
-
const previous = await validateContinuousBaseline(operation.repositoryRoot, operation.id,
|
|
86237
|
+
const previous = await validateContinuousBaseline(operation.repositoryRoot, operation.id, join58(operation.repositoryRoot, ".agent-valley", "operations", operation.id, "baselines", applied?.missionId ?? "initial", "workspace"));
|
|
86095
86238
|
if (applied && previous.baselineTree !== applied.nextTree)
|
|
86096
86239
|
throw new Error("The last applied source snapshot no longer matches its saved summary. Restore its original baseline before resuming.");
|
|
86097
86240
|
operation.sourceIntegration = await integrateContinuousSource(operation, previous, accepted, signal);
|
|
@@ -86120,7 +86263,7 @@ async function resumeSourceIntegration(operation, mode, storageRoot, signal, sav
|
|
|
86120
86263
|
}
|
|
86121
86264
|
|
|
86122
86265
|
// src/chief-continuous.ts
|
|
86123
|
-
var execute3 = promisify5(
|
|
86266
|
+
var execute3 = promisify5(execFile9);
|
|
86124
86267
|
var orderKeys = [
|
|
86125
86268
|
"workspace",
|
|
86126
86269
|
"verify",
|
|
@@ -86159,7 +86302,7 @@ function integerOption(value, name, maximum) {
|
|
|
86159
86302
|
return number;
|
|
86160
86303
|
}
|
|
86161
86304
|
function operationStore(root) {
|
|
86162
|
-
return new ContinuousOperationStore(
|
|
86305
|
+
return new ContinuousOperationStore(join59(resolve33(root), ".agent-valley", "operations"));
|
|
86163
86306
|
}
|
|
86164
86307
|
async function restoreOperationOrigin(repository, workspace) {
|
|
86165
86308
|
const env = { ...process.env, ...clearedGitEnvironment };
|
|
@@ -86200,7 +86343,7 @@ async function newOperation(charter, options, root, id) {
|
|
|
86200
86343
|
if (value !== undefined)
|
|
86201
86344
|
settings[key] = value;
|
|
86202
86345
|
}
|
|
86203
|
-
const repositoryRoot = await
|
|
86346
|
+
const repositoryRoot = await realpath32(config.workspace);
|
|
86204
86347
|
const sourceIntegrationPolicy = await initialSourceIntegration(repositoryRoot, id, options.sourceIntegration, options.deliver);
|
|
86205
86348
|
Object.assign(settings, {
|
|
86206
86349
|
workspace: repositoryRoot,
|
|
@@ -86238,7 +86381,7 @@ async function newOperation(charter, options, root, id) {
|
|
|
86238
86381
|
}
|
|
86239
86382
|
async function runOperation(charter, options, root = process.cwd(), dependencies = {}) {
|
|
86240
86383
|
assertNotManagedRun();
|
|
86241
|
-
root = await
|
|
86384
|
+
root = await realpath32(root);
|
|
86242
86385
|
await ensureRuntimeGitignore(root);
|
|
86243
86386
|
const id = options.resume ?? options.operationId ?? randomUUID23();
|
|
86244
86387
|
const storage = operationStore(root);
|
|
@@ -86276,7 +86419,7 @@ async function runOperation(charter, options, root = process.cwd(), dependencies
|
|
|
86276
86419
|
if (options.retry || decisionBudgetKeys.some((key) => options[key] !== undefined)) {
|
|
86277
86420
|
if (operation.currentMissionId || !operation.decisionId)
|
|
86278
86421
|
throw new Error("Operation resume budget reconciliation applies only to an active decision checkpoint. Adjust the current child's budget with av order --resume <child-id>.");
|
|
86279
|
-
const decisions = new MissionStore(
|
|
86422
|
+
const decisions = new MissionStore(join59(root, ".agent-valley", "operation-decisions", operation.id));
|
|
86280
86423
|
const unlockDecision = await decisions.lock(operation.decisionId);
|
|
86281
86424
|
try {
|
|
86282
86425
|
const decision = await decisions.load(operation.decisionId);
|
|
@@ -86321,7 +86464,7 @@ async function runOperation(charter, options, root = process.cwd(), dependencies
|
|
|
86321
86464
|
const interval = integerOption(options.interval, "--interval", 86400);
|
|
86322
86465
|
if (interval !== undefined)
|
|
86323
86466
|
operation.waitIntervalSec = interval;
|
|
86324
|
-
if (operation.repositoryRoot !== await
|
|
86467
|
+
if (operation.repositoryRoot !== await realpath32(String(operation.settings.workspace)))
|
|
86325
86468
|
throw new Error("Operation repository identity changed. Restore its original repository before resuming.");
|
|
86326
86469
|
if (hasDeliveryResumeOptions(options)) {
|
|
86327
86470
|
await assertSettledSourceIntegrations(operation.repositoryRoot, operation.id, sourceIntegrationCheckpoint(operation).pendingIds);
|
|
@@ -86348,7 +86491,7 @@ async function runOperation(charter, options, root = process.cwd(), dependencies
|
|
|
86348
86491
|
console.log(`Operation ${id}
|
|
86349
86492
|
Charter: ${operation.charter}
|
|
86350
86493
|
Resume: av order --resume ${id}`);
|
|
86351
|
-
const missions = new MissionStore(
|
|
86494
|
+
const missions = new MissionStore(join59(root, ".agent-valley", "missions"));
|
|
86352
86495
|
return await runContinuousOperation(operation, {
|
|
86353
86496
|
signal: controller.signal,
|
|
86354
86497
|
...options.retry ? { retryDecision: true } : {},
|
|
@@ -86452,7 +86595,7 @@ class OperationApi {
|
|
|
86452
86595
|
this.root = root;
|
|
86453
86596
|
this.workspace = workspace;
|
|
86454
86597
|
this.dependencies = dependencies;
|
|
86455
|
-
this.store = new ContinuousOperationStore(
|
|
86598
|
+
this.store = new ContinuousOperationStore(join60(root, ".agent-valley/operations"));
|
|
86456
86599
|
this.jobs = new MissionJobs(root, "operation-jobs");
|
|
86457
86600
|
}
|
|
86458
86601
|
order(raw) {
|
|
@@ -86620,7 +86763,7 @@ class OperationApi {
|
|
|
86620
86763
|
await ensureAvDirectory(this.root, ["operations"]);
|
|
86621
86764
|
try {
|
|
86622
86765
|
const operation = await this.store.load(id);
|
|
86623
|
-
if (await
|
|
86766
|
+
if (await realpath33(operation.repositoryRoot) !== this.workspace)
|
|
86624
86767
|
throw new Error("Saved operation belongs to another repository. Connect to its workspace.");
|
|
86625
86768
|
return operation;
|
|
86626
86769
|
} catch (error) {
|
|
@@ -86707,19 +86850,19 @@ class MissionApi {
|
|
|
86707
86850
|
this.projectRoot = projectRoot;
|
|
86708
86851
|
this.workspace = workspace;
|
|
86709
86852
|
this.dependencies = dependencies;
|
|
86710
|
-
this.store = new MissionStore(
|
|
86853
|
+
this.store = new MissionStore(join61(projectRoot, ".agent-valley/missions"));
|
|
86711
86854
|
this.jobs = new MissionJobs(projectRoot);
|
|
86712
86855
|
this.operationApi = new OperationApi(projectRoot, workspace, dependencies);
|
|
86713
86856
|
this.operationJobs = new MissionJobs(projectRoot, "operation-jobs");
|
|
86714
86857
|
}
|
|
86715
86858
|
static async create(workspace, dependencies = {}) {
|
|
86716
|
-
if (!
|
|
86859
|
+
if (!isAbsolute22(workspace))
|
|
86717
86860
|
throw new Error("Set an absolute Git repository path in av mcp --workspace <path>.");
|
|
86718
|
-
const projectRoot = await
|
|
86861
|
+
const projectRoot = await realpath34(workspace);
|
|
86719
86862
|
const target = loadProjectConfig(projectRoot)?.workspace?.root ?? projectRoot;
|
|
86720
|
-
if (!
|
|
86863
|
+
if (!isAbsolute22(target))
|
|
86721
86864
|
throw new Error("Set workspace.root in av.yaml to an absolute Git repository path.");
|
|
86722
|
-
return new MissionApi(projectRoot, await
|
|
86865
|
+
return new MissionApi(projectRoot, await realpath34(target), dependencies);
|
|
86723
86866
|
}
|
|
86724
86867
|
get targetWorkspace() {
|
|
86725
86868
|
return this.workspace;
|
|
@@ -86746,7 +86889,7 @@ class MissionApi {
|
|
|
86746
86889
|
async order(raw) {
|
|
86747
86890
|
assertNotManagedRun(this.dependencies.env);
|
|
86748
86891
|
const input = mcpOrderSchema.parse(raw);
|
|
86749
|
-
if (input.workspace && (!
|
|
86892
|
+
if (input.workspace && (!isAbsolute22(input.workspace) || await realpath34(input.workspace) !== this.workspace))
|
|
86750
86893
|
throw new Error("This AV server is bound to another workspace. Start av mcp --workspace for the target repository.");
|
|
86751
86894
|
return this.serializeOrder(async () => {
|
|
86752
86895
|
if (input.requestId) {
|
|
@@ -86769,7 +86912,7 @@ class MissionApi {
|
|
|
86769
86912
|
async list() {
|
|
86770
86913
|
this.assertOpen();
|
|
86771
86914
|
await ensureAvDirectory(this.projectRoot, ["missions"]);
|
|
86772
|
-
const ids = new Set((await
|
|
86915
|
+
const ids = new Set((await readdir16(join61(this.projectRoot, ".agent-valley/missions"))).filter((name) => name.endsWith(".json")).map((name) => missionIdSchema.parse(name.slice(0, -5))));
|
|
86773
86916
|
for (const job of await this.jobs.list())
|
|
86774
86917
|
ids.add(job.missionId);
|
|
86775
86918
|
return {
|
|
@@ -86865,7 +87008,7 @@ class MissionApi {
|
|
|
86865
87008
|
throw new Error("This mission is already completed. Create a new order for additional work.");
|
|
86866
87009
|
validateResumeOptions(undefined, options);
|
|
86867
87010
|
applyResumeOptions(structuredClone(mission), undefined, options);
|
|
86868
|
-
if (mission.repositoryRoot && await
|
|
87011
|
+
if (mission.repositoryRoot && await realpath34(mission.repositoryRoot) !== this.workspace)
|
|
86869
87012
|
throw new Error("The saved mission belongs to another repository. Connect to its workspace before resuming.");
|
|
86870
87013
|
const unlock = await this.store.lock(id);
|
|
86871
87014
|
await unlock();
|
|
@@ -86923,8 +87066,8 @@ class MissionApi {
|
|
|
86923
87066
|
async load(id) {
|
|
86924
87067
|
await ensureAvDirectory(this.projectRoot, ["missions"]);
|
|
86925
87068
|
try {
|
|
86926
|
-
const path =
|
|
86927
|
-
const stat = await
|
|
87069
|
+
const path = join61(this.projectRoot, ".agent-valley/missions", `${missionIdSchema.parse(id)}.json`);
|
|
87070
|
+
const stat = await lstat30(path);
|
|
86928
87071
|
if (!stat.isFile() || stat.isSymbolicLink())
|
|
86929
87072
|
throw new Error(`Mission record must be a regular file: ${path}. Remove the symlink before retrying.`);
|
|
86930
87073
|
return await this.store.observe(id);
|
|
@@ -86948,8 +87091,8 @@ class MissionApi {
|
|
|
86948
87091
|
// src/plugin-export.ts
|
|
86949
87092
|
init_client_integrations_assets();
|
|
86950
87093
|
init_client_integrations_files();
|
|
86951
|
-
import { lstat as
|
|
86952
|
-
import { dirname as dirname14, join as
|
|
87094
|
+
import { lstat as lstat31, readdir as readdir17, realpath as realpath35 } from "node:fs/promises";
|
|
87095
|
+
import { dirname as dirname14, join as join62, relative as relative17, resolve as resolve34 } from "node:path";
|
|
86953
87096
|
|
|
86954
87097
|
// src/plugin-assets.ts
|
|
86955
87098
|
import { copyFile as copyFile2, mkdir as mkdir25, readFile as readFile20 } from "node:fs/promises";
|
|
@@ -87116,8 +87259,8 @@ async function projectDirectory(workspace) {
|
|
|
87116
87259
|
if (typeof workspace !== "string" || !workspace.trim())
|
|
87117
87260
|
throw new Error("Pass --workspace /absolute/AV-project to bind every exported MCP server to its AV configuration.");
|
|
87118
87261
|
try {
|
|
87119
|
-
const project = await
|
|
87120
|
-
if (!(await
|
|
87262
|
+
const project = await realpath35(resolve34(workspace));
|
|
87263
|
+
if (!(await lstat31(project)).isDirectory())
|
|
87121
87264
|
throw new Error("not a directory");
|
|
87122
87265
|
return project;
|
|
87123
87266
|
} catch {
|
|
@@ -87143,12 +87286,12 @@ async function outputDirectory(output) {
|
|
|
87143
87286
|
let ancestor = target;
|
|
87144
87287
|
for (;; ) {
|
|
87145
87288
|
try {
|
|
87146
|
-
const info = await
|
|
87289
|
+
const info = await lstat31(ancestor);
|
|
87147
87290
|
if (info.isSymbolicLink())
|
|
87148
87291
|
throw exportConflict(ancestor, "symbolic link exports are not modified");
|
|
87149
87292
|
if (!info.isDirectory())
|
|
87150
87293
|
throw exportConflict(ancestor, "expected an output directory");
|
|
87151
|
-
return
|
|
87294
|
+
return join62(await realpath35(ancestor), relative17(ancestor, target));
|
|
87152
87295
|
} catch (error) {
|
|
87153
87296
|
if (error.code !== "ENOENT")
|
|
87154
87297
|
throw error;
|
|
@@ -87159,7 +87302,7 @@ async function outputDirectory(output) {
|
|
|
87159
87302
|
async function outputFiles(root, directory = root) {
|
|
87160
87303
|
let entries;
|
|
87161
87304
|
try {
|
|
87162
|
-
entries = await
|
|
87305
|
+
entries = await readdir17(directory, { withFileTypes: true });
|
|
87163
87306
|
} catch (error) {
|
|
87164
87307
|
if (error.code === "ENOENT")
|
|
87165
87308
|
return [];
|
|
@@ -87167,7 +87310,7 @@ async function outputFiles(root, directory = root) {
|
|
|
87167
87310
|
}
|
|
87168
87311
|
const files = [];
|
|
87169
87312
|
for (const entry of entries) {
|
|
87170
|
-
const path =
|
|
87313
|
+
const path = join62(directory, entry.name);
|
|
87171
87314
|
if (entry.isSymbolicLink())
|
|
87172
87315
|
throw exportConflict(path, "symbolic links are not modified");
|
|
87173
87316
|
if (entry.isDirectory())
|
|
@@ -87204,21 +87347,21 @@ async function exportPluginPackages(options) {
|
|
|
87204
87347
|
if (output === workspace)
|
|
87205
87348
|
throw exportConflict(output, "the output directory must be separate from the AV project root");
|
|
87206
87349
|
const { manifest } = await loadPluginManifestAsset(options.sourceManifest ? [options.sourceManifest] : undefined);
|
|
87207
|
-
const { content: skill } = await loadClientSkillAsset(options.sourceSkillRoot ? [
|
|
87350
|
+
const { content: skill } = await loadClientSkillAsset(options.sourceSkillRoot ? [join62(options.sourceSkillRoot, "SKILL.md")] : clientSkillAssetCandidates());
|
|
87208
87351
|
const { content: license } = await loadPluginLicenseAsset(options.sourceLicense ? [options.sourceLicense] : undefined);
|
|
87209
87352
|
const packageFiles = pluginPackageFiles(manifest, skill, license, { workspace, remoteUrl });
|
|
87210
|
-
const receipt = await integrationFile(output,
|
|
87353
|
+
const receipt = await integrationFile(output, join62(output, receiptName2), "", 384);
|
|
87211
87354
|
const hashes = ownedFileHashes(receipt.before, receipt.path);
|
|
87212
87355
|
const existing = await outputFiles(output);
|
|
87213
87356
|
for (const path of existing) {
|
|
87214
87357
|
if (path === receiptName2)
|
|
87215
87358
|
continue;
|
|
87216
87359
|
if (!packageFiles.has(path) || hashes[path] === undefined)
|
|
87217
|
-
throw exportConflict(
|
|
87360
|
+
throw exportConflict(join62(output, path), "unowned files are retained");
|
|
87218
87361
|
}
|
|
87219
87362
|
const files = [];
|
|
87220
87363
|
for (const [path, content] of packageFiles) {
|
|
87221
|
-
const file = await integrationFile(output,
|
|
87364
|
+
const file = await integrationFile(output, join62(output, path), content, 420);
|
|
87222
87365
|
if (hashes[path] !== undefined && (file.before === null || contentHash(file.before) !== hashes[path]))
|
|
87223
87366
|
throw exportConflict(file.path, "the exported file was changed or removed locally");
|
|
87224
87367
|
if (hashes[path] === undefined && file.before !== null)
|
|
@@ -87237,11 +87380,11 @@ async function exportPluginPackages(options) {
|
|
|
87237
87380
|
transport: remoteUrl ? "streamable-http" : "stdio",
|
|
87238
87381
|
files: await applyIntegrationFiles(output, [...files, receipt]),
|
|
87239
87382
|
packages: {
|
|
87240
|
-
portable:
|
|
87241
|
-
claude:
|
|
87242
|
-
cursor:
|
|
87243
|
-
qwen:
|
|
87244
|
-
antigravity:
|
|
87383
|
+
portable: join62(output, "portable/av"),
|
|
87384
|
+
claude: join62(output, "claude/plugins/av"),
|
|
87385
|
+
cursor: join62(output, "cursor/plugins/av"),
|
|
87386
|
+
qwen: join62(output, "qwen/av"),
|
|
87387
|
+
antigravity: join62(output, "antigravity/av")
|
|
87245
87388
|
}
|
|
87246
87389
|
};
|
|
87247
87390
|
}
|
|
@@ -87303,8 +87446,8 @@ function registerAgentClientCommands(program) {
|
|
|
87303
87446
|
|
|
87304
87447
|
// src/chief.ts
|
|
87305
87448
|
import { randomUUID as randomUUID28 } from "node:crypto";
|
|
87306
|
-
import { realpath as
|
|
87307
|
-
import { join as
|
|
87449
|
+
import { realpath as realpath38 } from "node:fs/promises";
|
|
87450
|
+
import { join as join68 } from "node:path";
|
|
87308
87451
|
|
|
87309
87452
|
// ../../node_modules/.bun/@langchain+core@1.3.5+84de184876195c42/node_modules/@langchain/core/dist/_virtual/_rolldown/runtime.js
|
|
87310
87453
|
var __defProp4 = Object.defineProperty;
|
|
@@ -92992,7 +93135,7 @@ async function writeFileAtomic(filePath, content) {
|
|
|
92992
93135
|
await nodeFsPromises.rm(tempPath, { force: true });
|
|
92993
93136
|
}
|
|
92994
93137
|
}
|
|
92995
|
-
async function
|
|
93138
|
+
async function readdir19(dir) {
|
|
92996
93139
|
return nodeFsPromises.readdir(dir);
|
|
92997
93140
|
}
|
|
92998
93141
|
async function stat6(filePath) {
|
|
@@ -95597,7 +95740,7 @@ class Client2 {
|
|
|
95597
95740
|
}
|
|
95598
95741
|
if (maxBytes !== undefined && maxBytes > 0) {
|
|
95599
95742
|
try {
|
|
95600
|
-
const entries = await
|
|
95743
|
+
const entries = await readdir19(directory);
|
|
95601
95744
|
const traceFiles = entries.filter((f) => f.startsWith("trace_") && f.endsWith(".json"));
|
|
95602
95745
|
let total = 0;
|
|
95603
95746
|
for (const name of traceFiles) {
|
|
@@ -127081,7 +127224,7 @@ var math_exports = /* @__PURE__ */ __exportAll3({
|
|
|
127081
127224
|
innerProduct: () => innerProduct2,
|
|
127082
127225
|
matrixFunc: () => matrixFunc,
|
|
127083
127226
|
maximalMarginalRelevance: () => maximalMarginalRelevance,
|
|
127084
|
-
normalize: () =>
|
|
127227
|
+
normalize: () => normalize2
|
|
127085
127228
|
});
|
|
127086
127229
|
function matrixFunc(X, Y, func) {
|
|
127087
127230
|
if (X.length === 0 || X[0].length === 0 || Y.length === 0 || Y[0].length === 0)
|
|
@@ -127090,7 +127233,7 @@ function matrixFunc(X, Y, func) {
|
|
|
127090
127233
|
throw new Error(`Number of columns in X and Y must be the same. X has shape ${[X.length, X[0].length]} and Y has shape ${[Y.length, Y[0].length]}.`);
|
|
127091
127234
|
return X.map((xVector) => Y.map((yVector) => func(xVector, yVector)).map((similarity) => Number.isNaN(similarity) ? 0 : similarity));
|
|
127092
127235
|
}
|
|
127093
|
-
function
|
|
127236
|
+
function normalize2(M, similarity = false) {
|
|
127094
127237
|
const max = matrixMaxVal(M);
|
|
127095
127238
|
return M.map((row) => row.map((val) => similarity ? 1 - val / max : val / max));
|
|
127096
127239
|
}
|
|
@@ -138996,6 +139139,11 @@ async function planMission(context) {
|
|
|
138996
139139
|
|
|
138997
139140
|
// ../../packages/core/src/chief/coordinator-integration.ts
|
|
138998
139141
|
init_execution();
|
|
139142
|
+
var storageNote = (output) => {
|
|
139143
|
+
const first = output.split(`
|
|
139144
|
+
`, 1)[0] ?? "";
|
|
139145
|
+
return first.startsWith(STORAGE_NOTE_PREFIX) ? ` ${first}` : "";
|
|
139146
|
+
};
|
|
138999
139147
|
async function recordIntegrationCheck(mission, ports, states, save) {
|
|
139000
139148
|
if (!ports.integrationCheck)
|
|
139001
139149
|
return;
|
|
@@ -139022,7 +139170,7 @@ async function recordIntegrationCheck(mission, ports, states, save) {
|
|
|
139022
139170
|
const observed = { at: new Date().toISOString(), ok: result.ok, output: result.output.slice(0, 8000) };
|
|
139023
139171
|
for (const state of targets)
|
|
139024
139172
|
state.integrationCheck = observed;
|
|
139025
|
-
await save("integration-check", `${result.ok ? "Contract command checks pass" : "Contract command checks fail"} on the integrated tree before review of ${targets.map((state) => state.id).join(", ")}.${result.ok ?
|
|
139173
|
+
await save("integration-check", `${result.ok ? "Contract command checks pass" : "Contract command checks fail"} on the integrated tree before review of ${targets.map((state) => state.id).join(", ")}.${result.ok ? storageNote(result.output) : ` ${result.output.slice(0, 1500)}`}`, first.id);
|
|
139026
139174
|
}
|
|
139027
139175
|
|
|
139028
139176
|
// ../../packages/core/src/chief/coordinator-parallel.ts
|
|
@@ -139677,9 +139825,9 @@ import { lstatSync as lstatSync4 } from "node:fs";
|
|
|
139677
139825
|
// ../../packages/core/src/workspace/isolated-branch-import.ts
|
|
139678
139826
|
init_worktree_lifecycle();
|
|
139679
139827
|
import { randomUUID as randomUUID27 } from "node:crypto";
|
|
139680
|
-
import { mkdtemp as mkdtemp2, rm as
|
|
139828
|
+
import { mkdtemp as mkdtemp2, rm as rm13 } from "node:fs/promises";
|
|
139681
139829
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
139682
|
-
import { join as
|
|
139830
|
+
import { join as join64 } from "node:path";
|
|
139683
139831
|
async function importIsolatedBranch(workspace, root) {
|
|
139684
139832
|
if (!isIsolatedGitWorkspace(workspace))
|
|
139685
139833
|
return null;
|
|
@@ -139726,7 +139874,7 @@ async function importIsolatedBranch(workspace, root) {
|
|
|
139726
139874
|
`).filter(Boolean);
|
|
139727
139875
|
if (commits.length === 0)
|
|
139728
139876
|
return null;
|
|
139729
|
-
temporaryWorktree = await mkdtemp2(
|
|
139877
|
+
temporaryWorktree = await mkdtemp2(join64(tmpdir4(), "av-branch-import-"));
|
|
139730
139878
|
const added = await runCommand("git", ["worktree", "add", "--detach", temporaryWorktree, currentHead], {
|
|
139731
139879
|
cwd: root
|
|
139732
139880
|
});
|
|
@@ -139757,7 +139905,7 @@ async function importIsolatedBranch(workspace, root) {
|
|
|
139757
139905
|
if (temporaryWorktree) {
|
|
139758
139906
|
if (worktreeAdded)
|
|
139759
139907
|
await runCommand("git", ["worktree", "remove", "--force", temporaryWorktree], { cwd: root });
|
|
139760
|
-
await
|
|
139908
|
+
await rm13(temporaryWorktree, { recursive: true, force: true });
|
|
139761
139909
|
}
|
|
139762
139910
|
await runCommand("git", ["update-ref", "-d", importedRef], { cwd: root });
|
|
139763
139911
|
}
|
|
@@ -139766,8 +139914,8 @@ async function importIsolatedBranch(workspace, root) {
|
|
|
139766
139914
|
// ../../packages/core/src/workspace/safety-net.ts
|
|
139767
139915
|
init_logger();
|
|
139768
139916
|
init_worktree_lifecycle();
|
|
139769
|
-
import { lstat as
|
|
139770
|
-
import { isAbsolute as
|
|
139917
|
+
import { lstat as lstat32, readFile as readFile21, realpath as realpath36 } from "node:fs/promises";
|
|
139918
|
+
import { isAbsolute as isAbsolute23, join as join65, relative as relative18, resolve as resolve37, sep as sep20 } from "node:path";
|
|
139771
139919
|
var CONFLICT_MARKER_PATTERN = /^(<<<<<<<|=======|>>>>>>>)( .*)?$/m;
|
|
139772
139920
|
var REGENERATABLE_LOCKFILE_PATTERNS = [
|
|
139773
139921
|
/(^|\/)package-lock\.json$/,
|
|
@@ -139869,7 +140017,7 @@ async function findConflictMarkerFiles(root, files) {
|
|
|
139869
140017
|
}
|
|
139870
140018
|
function isInside(parent, child) {
|
|
139871
140019
|
const rel = relative18(parent, child);
|
|
139872
|
-
return rel === "" || rel !== ".." && !rel.startsWith(`..${
|
|
140020
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep20}`) && !isAbsolute23(rel);
|
|
139873
140021
|
}
|
|
139874
140022
|
function untrustedGitError(detail) {
|
|
139875
140023
|
return {
|
|
@@ -139879,8 +140027,8 @@ function untrustedGitError(detail) {
|
|
|
139879
140027
|
};
|
|
139880
140028
|
}
|
|
139881
140029
|
async function validateTrustedWorktree(cwd, repoRoot) {
|
|
139882
|
-
const dotGit =
|
|
139883
|
-
const entry = await
|
|
140030
|
+
const dotGit = join65(cwd, ".git");
|
|
140031
|
+
const entry = await lstat32(dotGit).catch(() => null);
|
|
139884
140032
|
if (!entry)
|
|
139885
140033
|
return untrustedGitError(`missing ${dotGit}`);
|
|
139886
140034
|
if (entry.isSymbolicLink())
|
|
@@ -139891,18 +140039,18 @@ async function validateTrustedWorktree(cwd, repoRoot) {
|
|
|
139891
140039
|
if (!match?.[1])
|
|
139892
140040
|
return untrustedGitError(`${dotGit} has no gitdir pointer`);
|
|
139893
140041
|
const gitDir = resolve37(cwd, match[1].trim());
|
|
139894
|
-
if (!gitDir.split(
|
|
140042
|
+
if (!gitDir.split(sep20).includes("worktrees"))
|
|
139895
140043
|
return untrustedGitError(`${dotGit} does not point into a worktrees directory`);
|
|
139896
140044
|
if (isInside(cwd, gitDir))
|
|
139897
140045
|
return untrustedGitError(`${dotGit} points inside the agent-writable workspace`);
|
|
139898
|
-
const gitDirStat = await
|
|
140046
|
+
const gitDirStat = await lstat32(gitDir).catch(() => null);
|
|
139899
140047
|
if (!gitDirStat?.isDirectory())
|
|
139900
140048
|
return untrustedGitError(`${dotGit} points at a missing directory`);
|
|
139901
140049
|
if (repoRoot) {
|
|
139902
140050
|
const commonDir = resolve37(gitDir, "..", "..");
|
|
139903
140051
|
const [actualCommon, expectedCommon] = await Promise.all([
|
|
139904
|
-
|
|
139905
|
-
|
|
140052
|
+
realpath36(commonDir).catch(() => null),
|
|
140053
|
+
realpath36(join65(repoRoot, ".git")).catch(() => null)
|
|
139906
140054
|
]);
|
|
139907
140055
|
if (!expectedCommon || actualCommon !== expectedCommon) {
|
|
139908
140056
|
return untrustedGitError(`${dotGit} points outside the configured repository`);
|
|
@@ -139915,8 +140063,8 @@ async function validateTrustedWorktree(cwd, repoRoot) {
|
|
|
139915
140063
|
if (top.exitCode !== 0)
|
|
139916
140064
|
return untrustedGitError(top.stderr.trim() || "git rev-parse failed");
|
|
139917
140065
|
const [actualTop, expectedTop] = await Promise.all([
|
|
139918
|
-
|
|
139919
|
-
|
|
140066
|
+
realpath36(top.stdout.trim()).catch(() => null),
|
|
140067
|
+
realpath36(cwd).catch(() => null)
|
|
139920
140068
|
]);
|
|
139921
140069
|
if (!actualTop || !expectedTop || actualTop !== expectedTop) {
|
|
139922
140070
|
return untrustedGitError("git reports a different worktree root");
|
|
@@ -140352,11 +140500,11 @@ function createMissionContainerPorts(dependencies = {}) {
|
|
|
140352
140500
|
}
|
|
140353
140501
|
|
|
140354
140502
|
// src/chief-parent-resume.ts
|
|
140355
|
-
import { join as
|
|
140503
|
+
import { join as join66 } from "node:path";
|
|
140356
140504
|
async function resumeParentForChild(root, child, resume) {
|
|
140357
140505
|
if (child.status !== "completed" || !verifiedMissionEvidence(child))
|
|
140358
140506
|
return child;
|
|
140359
|
-
const directory =
|
|
140507
|
+
const directory = join66(root, ".agent-valley", "operations");
|
|
140360
140508
|
const owners = (await new ContinuousOperationStore(directory).list()).filter((operation) => operation.currentMissionId === child.id);
|
|
140361
140509
|
if (owners.length > 1)
|
|
140362
140510
|
throw new Error("Multiple orders claim this child. Restore a single owning operation before resuming its accepted result.");
|
|
@@ -140380,16 +140528,16 @@ async function resumeParentForChild(root, child, resume) {
|
|
|
140380
140528
|
}
|
|
140381
140529
|
|
|
140382
140530
|
// src/chief-workspace-dependencies.ts
|
|
140383
|
-
import { lstat as
|
|
140384
|
-
import { join as
|
|
140531
|
+
import { lstat as lstat33, mkdir as mkdir28, readdir as readdir20, readFile as readFile22, realpath as realpath37, stat as stat7, symlink } from "node:fs/promises";
|
|
140532
|
+
import { join as join67, relative as relative19, resolve as resolve38, sep as sep21 } from "node:path";
|
|
140385
140533
|
var caches = new Set([".cache", ".vite", ".vite-temp"]);
|
|
140386
|
-
var inside3 = (root, path) => path === root || path.startsWith(`${root}${
|
|
140534
|
+
var inside3 = (root, path) => path === root || path.startsWith(`${root}${sep21}`);
|
|
140387
140535
|
async function prepareMissionDependencies(repository, workspace) {
|
|
140388
|
-
const source = await
|
|
140389
|
-
const target = await
|
|
140536
|
+
const source = await realpath37(repository);
|
|
140537
|
+
const target = await realpath37(workspace);
|
|
140390
140538
|
if (source === target)
|
|
140391
140539
|
throw new Error("Dependency preparation requires a separate mission workspace.");
|
|
140392
|
-
const packagePath =
|
|
140540
|
+
const packagePath = join67(source, "package.json");
|
|
140393
140541
|
const metadata = await readFile22(packagePath, "utf8").catch((error) => {
|
|
140394
140542
|
if (error.code === "ENOENT")
|
|
140395
140543
|
return null;
|
|
@@ -140410,7 +140558,7 @@ async function prepareMissionDependencies(repository, workspace) {
|
|
|
140410
140558
|
if (++visited > 1000)
|
|
140411
140559
|
throw new Error("Workspace dependency discovery exceeds 1,000 directories.");
|
|
140412
140560
|
if (!segments.length) {
|
|
140413
|
-
const path = await
|
|
140561
|
+
const path = await realpath37(directory).catch(() => {
|
|
140414
140562
|
return;
|
|
140415
140563
|
});
|
|
140416
140564
|
if (path && inside3(source, path))
|
|
@@ -140419,12 +140567,12 @@ async function prepareMissionDependencies(repository, workspace) {
|
|
|
140419
140567
|
}
|
|
140420
140568
|
const [segment, ...rest] = segments;
|
|
140421
140569
|
if (segment === "*") {
|
|
140422
|
-
for (const entry of await
|
|
140570
|
+
for (const entry of await readdir20(directory, { withFileTypes: true }).catch(() => [])) {
|
|
140423
140571
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules")
|
|
140424
|
-
await expand(
|
|
140572
|
+
await expand(join67(directory, entry.name), rest);
|
|
140425
140573
|
}
|
|
140426
140574
|
} else if (segment)
|
|
140427
|
-
await expand(
|
|
140575
|
+
await expand(join67(directory, segment), rest);
|
|
140428
140576
|
}
|
|
140429
140577
|
for (const pattern of patterns) {
|
|
140430
140578
|
if (typeof pattern !== "string" || pattern.length > 1024 || pattern.startsWith("/") || pattern.split("/").some((part) => !part || part === "." || part === ".." || part.startsWith(".") || part === "node_modules" || part !== "*" && /[*?\\:]/.test(part)) || pattern.split("/").length > 8)
|
|
@@ -140435,61 +140583,61 @@ async function prepareMissionDependencies(repository, workspace) {
|
|
|
140435
140583
|
async function link(from, to) {
|
|
140436
140584
|
if (++entries > 5000)
|
|
140437
140585
|
throw new Error("Installed dependencies exceed 5,000 links; prepare a smaller workspace.");
|
|
140438
|
-
let installed = await
|
|
140586
|
+
let installed = await realpath37(from);
|
|
140439
140587
|
if (!inside3(source, installed))
|
|
140440
140588
|
throw new Error("An installed dependency escapes the selected repository. Prepare repository-local dependencies.");
|
|
140441
|
-
if (!relative19(source, installed).split(
|
|
140589
|
+
if (!relative19(source, installed).split(sep21).includes("node_modules")) {
|
|
140442
140590
|
installed = resolve38(target, relative19(source, installed));
|
|
140443
|
-
const destination = await
|
|
140591
|
+
const destination = await realpath37(installed).catch(() => {
|
|
140444
140592
|
return;
|
|
140445
140593
|
});
|
|
140446
140594
|
if (!destination || !inside3(target, destination))
|
|
140447
140595
|
throw new Error("A workspace dependency is missing or escapes the mission workspace. Restore that package.");
|
|
140448
140596
|
installed = destination;
|
|
140449
140597
|
}
|
|
140450
|
-
const existing = await
|
|
140598
|
+
const existing = await lstat33(to).catch((error) => {
|
|
140451
140599
|
if (error.code === "ENOENT")
|
|
140452
140600
|
return;
|
|
140453
140601
|
throw error;
|
|
140454
140602
|
});
|
|
140455
140603
|
if (existing) {
|
|
140456
|
-
if (!existing.isSymbolicLink() || await
|
|
140604
|
+
if (!existing.isSymbolicLink() || await realpath37(to) !== installed)
|
|
140457
140605
|
throw new Error("An existing mission dependency differs from the installed package. Preserve it and repair setup.");
|
|
140458
140606
|
return;
|
|
140459
140607
|
}
|
|
140460
140608
|
await symlink(installed, to, (await stat7(installed)).isDirectory() ? "dir" : "file");
|
|
140461
140609
|
}
|
|
140462
140610
|
for (const root of roots) {
|
|
140463
|
-
const modules =
|
|
140611
|
+
const modules = join67(root, "node_modules");
|
|
140464
140612
|
const installed = await stat7(modules).catch(() => {
|
|
140465
140613
|
return;
|
|
140466
140614
|
});
|
|
140467
140615
|
if (!installed?.isDirectory())
|
|
140468
140616
|
continue;
|
|
140469
|
-
const destinationRoot = await
|
|
140617
|
+
const destinationRoot = await realpath37(resolve38(target, relative19(source, root)));
|
|
140470
140618
|
if (!inside3(target, destinationRoot))
|
|
140471
140619
|
throw new Error("A mission package directory escapes its workspace.");
|
|
140472
|
-
const destination =
|
|
140473
|
-
const existing = await
|
|
140620
|
+
const destination = join67(destinationRoot, "node_modules");
|
|
140621
|
+
const existing = await lstat33(destination).catch(() => {
|
|
140474
140622
|
return;
|
|
140475
140623
|
});
|
|
140476
140624
|
if (existing && !existing.isDirectory())
|
|
140477
140625
|
throw new Error("Mission node_modules must be a local directory.");
|
|
140478
140626
|
await mkdir28(destination, { recursive: true });
|
|
140479
|
-
for (const entry of await
|
|
140627
|
+
for (const entry of await readdir20(modules, { withFileTypes: true })) {
|
|
140480
140628
|
if (caches.has(entry.name))
|
|
140481
140629
|
continue;
|
|
140482
|
-
const from =
|
|
140483
|
-
const to =
|
|
140630
|
+
const from = join67(modules, entry.name);
|
|
140631
|
+
const to = join67(destination, entry.name);
|
|
140484
140632
|
if (entry.name.startsWith("@") && entry.isDirectory()) {
|
|
140485
|
-
const scope = await
|
|
140633
|
+
const scope = await lstat33(to).catch(() => {
|
|
140486
140634
|
return;
|
|
140487
140635
|
});
|
|
140488
140636
|
if (scope && !scope.isDirectory())
|
|
140489
140637
|
throw new Error("A dependency scope must be a local directory.");
|
|
140490
140638
|
await mkdir28(to, { recursive: true });
|
|
140491
|
-
for (const member of await
|
|
140492
|
-
await link(
|
|
140639
|
+
for (const member of await readdir20(from))
|
|
140640
|
+
await link(join67(from, member), join67(to, member));
|
|
140493
140641
|
} else
|
|
140494
140642
|
await link(from, to);
|
|
140495
140643
|
}
|
|
@@ -140512,7 +140660,7 @@ async function runOrder(goal, options, root = process.cwd()) {
|
|
|
140512
140660
|
if (!options.resume && [options.retry, options.resolveEffect, options.effectResult, options.accountRun, options.accountCost].some((value) => value !== undefined && value !== false))
|
|
140513
140661
|
throw new Error("Use --resume <id> for retry, external-effect resolution or cost reconciliation.");
|
|
140514
140662
|
await ensureRuntimeGitignore(root);
|
|
140515
|
-
const store = new MissionStore(
|
|
140663
|
+
const store = new MissionStore(join68(root, ".agent-valley/missions"));
|
|
140516
140664
|
const id = options.resume ?? options.missionId ?? randomUUID28();
|
|
140517
140665
|
const unlock = await store.lock(id);
|
|
140518
140666
|
const abortController = new AbortController;
|
|
@@ -140556,12 +140704,12 @@ async function runOrder(goal, options, root = process.cwd()) {
|
|
|
140556
140704
|
...options,
|
|
140557
140705
|
deliveryPaths: deliveryPaths(options.deliveryPaths)
|
|
140558
140706
|
});
|
|
140559
|
-
const operation = options.operationId ? await operationStore(await
|
|
140560
|
-
if (operation && (operation.repositoryRoot !== await
|
|
140707
|
+
const operation = options.operationId ? await operationStore(await realpath38(root)).load(options.operationId) : undefined;
|
|
140708
|
+
if (operation && (operation.repositoryRoot !== await realpath38(config.workspace) || operation.currentMissionId !== id || operation.decision?.action !== "execute" || operation.decision.goal !== goal || operation.baseline?.path !== options.baselineWorkspace))
|
|
140561
140709
|
throw new Error("Internal child launch does not match its saved operation, goal and accepted baseline. Restore the original operation checkpoint.");
|
|
140562
140710
|
if (Boolean(options.baselineWorkspace) !== Boolean(options.operationId))
|
|
140563
140711
|
throw new Error("An internal operation snapshot requires both its operation identity and accepted baseline.");
|
|
140564
|
-
const workspace = options.baselineWorkspace && options.operationId ? await createContinuousMissionWorkspace(config.workspace, options.operationId, options.baselineWorkspace, id, goal) : await new WorkspaceManager(config.workspace).create(missionIssue(id, goal), undefined, codeDelivery ?
|
|
140712
|
+
const workspace = options.baselineWorkspace && options.operationId ? await createContinuousMissionWorkspace(config.workspace, options.operationId, options.baselineWorkspace, id, goal) : await new WorkspaceManager(config.workspace).create(missionIssue(id, goal), undefined, codeDelivery ? join68(config.workspace, ".agent-valley", "workspaces") : undefined);
|
|
140565
140713
|
if (options.operationId) {
|
|
140566
140714
|
await restoreOperationOrigin(config.workspace, workspace.path);
|
|
140567
140715
|
const store = await operationCacheStore(workspace.path);
|
|
@@ -140635,7 +140783,7 @@ Resume: bun av order --resume ${id}`);
|
|
|
140635
140783
|
await store.save(mission);
|
|
140636
140784
|
}
|
|
140637
140785
|
if (mission.status !== "completed")
|
|
140638
|
-
await prepareChiefToolConfig(await
|
|
140786
|
+
await prepareChiefToolConfig(await realpath38(repository), await realpath38(mission.workspace.path));
|
|
140639
140787
|
if (mission.executionPolicy) {
|
|
140640
140788
|
const started = Date.parse(executionState(mission).startedAt);
|
|
140641
140789
|
const remaining = started + mission.executionPolicy.maxDurationSec * 1000 - Date.now();
|
|
@@ -140670,7 +140818,7 @@ Resume: bun av order --resume ${id}`);
|
|
|
140670
140818
|
...parallel,
|
|
140671
140819
|
prepare: async (current, taskId, attempt) => {
|
|
140672
140820
|
const record = await parallel.prepare(current, taskId, attempt);
|
|
140673
|
-
await prepareChiefToolConfig(await
|
|
140821
|
+
await prepareChiefToolConfig(await realpath38(repository), await realpath38(record.path));
|
|
140674
140822
|
return record;
|
|
140675
140823
|
}
|
|
140676
140824
|
}
|
|
@@ -140731,7 +140879,7 @@ Resume: bun av order --resume ${id}`);
|
|
|
140731
140879
|
}
|
|
140732
140880
|
async function dispatchOrder(goal, options, root = process.cwd(), dependencies = {}) {
|
|
140733
140881
|
assertNotManagedRun();
|
|
140734
|
-
root = await
|
|
140882
|
+
root = await realpath38(root);
|
|
140735
140883
|
let single = Boolean(options.once || options.worker || options.missionId || options.baselineWorkspace);
|
|
140736
140884
|
if (options.resume && !single) {
|
|
140737
140885
|
const missing = (error) => {
|
|
@@ -140741,7 +140889,7 @@ async function dispatchOrder(goal, options, root = process.cwd(), dependencies =
|
|
|
140741
140889
|
};
|
|
140742
140890
|
const [operation, mission] = await Promise.all([
|
|
140743
140891
|
operationStore(root).load(options.resume).catch(missing),
|
|
140744
|
-
new MissionStore(
|
|
140892
|
+
new MissionStore(join68(root, ".agent-valley", "missions")).load(options.resume).catch(missing)
|
|
140745
140893
|
]);
|
|
140746
140894
|
if (operation && mission)
|
|
140747
140895
|
throw new Error(`Saved ID ${options.resume} names both an operation and a mission. Use --once to resume the mission; inspect av operations before resuming the operation.`);
|
|
@@ -140787,14 +140935,14 @@ async function dispatchOrder(goal, options, root = process.cwd(), dependencies =
|
|
|
140787
140935
|
}
|
|
140788
140936
|
|
|
140789
140937
|
// src/operations-prune.ts
|
|
140790
|
-
import { realpath as
|
|
140938
|
+
import { realpath as realpath40 } from "node:fs/promises";
|
|
140791
140939
|
|
|
140792
140940
|
// ../../packages/core/src/chief/continuous-retention.ts
|
|
140793
140941
|
init_zod();
|
|
140794
140942
|
import { createHash as createHash30 } from "node:crypto";
|
|
140795
140943
|
import { constants as constants18 } from "node:fs";
|
|
140796
|
-
import { lstat as
|
|
140797
|
-
import { dirname as dirname15, join as
|
|
140944
|
+
import { lstat as lstat34, open as open19, readdir as readdir21, realpath as realpath39, rename as rename6, rm as rm14 } from "node:fs/promises";
|
|
140945
|
+
import { dirname as dirname15, join as join69, resolve as resolve39, sep as sep22 } from "node:path";
|
|
140798
140946
|
var digest7 = (content) => createHash30("sha256").update(content).digest("hex");
|
|
140799
140947
|
var sha2 = string2().regex(/^[a-f0-9]{40,64}$/);
|
|
140800
140948
|
var preparedSchema = strictObject({
|
|
@@ -140818,7 +140966,7 @@ var completedSchema = strictObject({
|
|
|
140818
140966
|
});
|
|
140819
140967
|
async function exists(path) {
|
|
140820
140968
|
try {
|
|
140821
|
-
await
|
|
140969
|
+
await lstat34(path);
|
|
140822
140970
|
return true;
|
|
140823
140971
|
} catch (error) {
|
|
140824
140972
|
if (error.code === "ENOENT")
|
|
@@ -140827,7 +140975,7 @@ async function exists(path) {
|
|
|
140827
140975
|
}
|
|
140828
140976
|
}
|
|
140829
140977
|
async function localDirectory3(path) {
|
|
140830
|
-
if (!(await
|
|
140978
|
+
if (!(await lstat34(path)).isDirectory() || await realpath39(path) !== resolve39(path))
|
|
140831
140979
|
throw new Error("Pruning requires canonical local directories. Preserve redirected artifacts and restore their original paths.");
|
|
140832
140980
|
}
|
|
140833
140981
|
async function readLocal(path) {
|
|
@@ -140865,7 +141013,7 @@ async function independentGitMetadata(path) {
|
|
|
140865
141013
|
const directory = pending.pop();
|
|
140866
141014
|
if (!directory)
|
|
140867
141015
|
break;
|
|
140868
|
-
for (const entry of await
|
|
141016
|
+
for (const entry of await readdir21(directory, { withFileTypes: true })) {
|
|
140869
141017
|
if (++entries > 1e5)
|
|
140870
141018
|
throw new Error("Git metadata inspection exceeded its bound; retain this clone.");
|
|
140871
141019
|
if (entry.name.endsWith(".lock"))
|
|
@@ -140873,29 +141021,29 @@ async function independentGitMetadata(path) {
|
|
|
140873
141021
|
if (entry.isSymbolicLink())
|
|
140874
141022
|
throw new Error("Git metadata redirects through a symbolic link.");
|
|
140875
141023
|
if (entry.isDirectory())
|
|
140876
|
-
pending.push(
|
|
141024
|
+
pending.push(join69(directory, entry.name));
|
|
140877
141025
|
else if (!entry.isFile())
|
|
140878
141026
|
throw new Error("Git metadata contains an unsupported file type; preserve this clone.");
|
|
140879
141027
|
}
|
|
140880
141028
|
}
|
|
140881
141029
|
}
|
|
140882
141030
|
async function emptyScratch(path, depth = 0) {
|
|
140883
|
-
if (depth > 8 || !(await
|
|
141031
|
+
if (depth > 8 || !(await lstat34(path)).isDirectory() || await realpath39(path) !== path)
|
|
140884
141032
|
return false;
|
|
140885
|
-
const entries = await
|
|
141033
|
+
const entries = await readdir21(path);
|
|
140886
141034
|
if (entries.length > 100)
|
|
140887
141035
|
return false;
|
|
140888
141036
|
for (const name of entries)
|
|
140889
|
-
if (!await emptyScratch(
|
|
141037
|
+
if (!await emptyScratch(join69(path, name), depth + 1))
|
|
140890
141038
|
return false;
|
|
140891
141039
|
return true;
|
|
140892
141040
|
}
|
|
140893
141041
|
async function inspectClone(path, baseline) {
|
|
140894
141042
|
await localDirectory3(path);
|
|
140895
|
-
await localDirectory3(
|
|
140896
|
-
await independentGitMetadata(
|
|
141043
|
+
await localDirectory3(join69(path, ".git"));
|
|
141044
|
+
await independentGitMetadata(join69(path, ".git"));
|
|
140897
141045
|
for (const key of ["commondir", "objects/info/alternates", "objects/info/http-alternates", "info/grafts", "shallow"])
|
|
140898
|
-
if (await exists(
|
|
141046
|
+
if (await exists(join69(path, ".git", key)))
|
|
140899
141047
|
throw new Error("Git metadata depends on another repository.");
|
|
140900
141048
|
const [top, branch, head, refs, status, worktrees, remotes] = await Promise.all([
|
|
140901
141049
|
git2(path, ["rev-parse", "--show-toplevel"]),
|
|
@@ -140920,7 +141068,7 @@ async function inspectClone(path, baseline) {
|
|
|
140920
141068
|
`) !== `worktree ${resolve39(path)}`)
|
|
140921
141069
|
throw new Error("Frozen baseline has linked worktrees.");
|
|
140922
141070
|
for (const entry of status.split("\x00").filter(Boolean)) {
|
|
140923
|
-
if (entry === "!! .agent-valley/" && await emptyScratch(
|
|
141071
|
+
if (entry === "!! .agent-valley/" && await emptyScratch(join69(path, ".agent-valley")))
|
|
140924
141072
|
continue;
|
|
140925
141073
|
throw new Error("Frozen baseline has tracked, untracked or ignored changes.");
|
|
140926
141074
|
}
|
|
@@ -140953,62 +141101,62 @@ async function recoverable(current, baseline) {
|
|
|
140953
141101
|
throw new Error("The current baseline is missing recovery objects.");
|
|
140954
141102
|
}
|
|
140955
141103
|
async function processEvidence(storePath, missionId) {
|
|
140956
|
-
if (await exists(
|
|
141104
|
+
if (await exists(join69(storePath, `${missionId}.json.lock`)))
|
|
140957
141105
|
return true;
|
|
140958
|
-
if (await exists(
|
|
141106
|
+
if (await exists(join69(storePath, `${missionId}.json.lock.reclaim`)))
|
|
140959
141107
|
return true;
|
|
140960
|
-
return (await
|
|
141108
|
+
return (await readdir21(storePath)).some((name) => name === `${missionId}.active` || name.startsWith(`${missionId}.run-`) && name.endsWith(".active"));
|
|
140961
141109
|
}
|
|
140962
141110
|
async function protectMissionBaseline(mission, protectedPaths) {
|
|
140963
141111
|
if (!mission.repositoryRoot)
|
|
140964
141112
|
throw new Error("An unresolved mission has no repository identity; preserve all baselines.");
|
|
140965
141113
|
protectedPaths.add(mission.workspace.path);
|
|
140966
141114
|
const workspace = mission.workspace.path;
|
|
140967
|
-
const prefix =
|
|
140968
|
-
if (!workspace.startsWith(`${prefix}${
|
|
141115
|
+
const prefix = join69(mission.repositoryRoot, ".agent-valley", "operations");
|
|
141116
|
+
if (!workspace.startsWith(`${prefix}${sep22}`))
|
|
140969
141117
|
return;
|
|
140970
141118
|
await localDirectory3(dirname15(workspace));
|
|
140971
|
-
const raw = await readLocal(
|
|
141119
|
+
const raw = await readLocal(join69(dirname15(workspace), "workspace.json"));
|
|
140972
141120
|
if (!raw)
|
|
140973
141121
|
throw new Error("An unresolved mission is missing its workspace receipt; preserve all baselines.");
|
|
140974
141122
|
const value = JSON.parse(raw);
|
|
140975
141123
|
if (value.missionId !== mission.id || value.repositoryRoot !== mission.repositoryRoot || value.path !== workspace || typeof value.baselinePath !== "string")
|
|
140976
141124
|
throw new Error("An unresolved mission has an ambiguous workspace receipt; preserve all baselines.");
|
|
140977
|
-
protectedPaths.add(await
|
|
141125
|
+
protectedPaths.add(await realpath39(value.baselinePath));
|
|
140978
141126
|
}
|
|
140979
141127
|
async function referencedBaselines(storageRoot, operations) {
|
|
140980
141128
|
const protectedPaths = new Set;
|
|
140981
|
-
const missionDirectories = [
|
|
141129
|
+
const missionDirectories = [join69(storageRoot, ".agent-valley", "missions")];
|
|
140982
141130
|
for (const operation of operations) {
|
|
140983
141131
|
if (operation.baseline)
|
|
140984
141132
|
protectedPaths.add(operation.baseline.path);
|
|
140985
141133
|
if (operation.sourceIntegration)
|
|
140986
|
-
protectedPaths.add(
|
|
141134
|
+
protectedPaths.add(join69(operation.repositoryRoot, ".agent-valley", "operations", operation.id, "baselines", operation.sourceIntegration.missionId, "workspace"));
|
|
140987
141135
|
for (const id of [operation.currentMissionId, operation.decisionId]) {
|
|
140988
141136
|
if (!id)
|
|
140989
141137
|
continue;
|
|
140990
|
-
const container =
|
|
141138
|
+
const container = join69(operation.repositoryRoot, ".agent-valley", "operations", operation.id, "workspaces", id);
|
|
140991
141139
|
await localDirectory3(container);
|
|
140992
|
-
const raw = await readLocal(
|
|
141140
|
+
const raw = await readLocal(join69(container, "workspace.json"));
|
|
140993
141141
|
if (!raw)
|
|
140994
141142
|
throw new Error("An active child or decision has no workspace receipt; preserve all baselines.");
|
|
140995
141143
|
const value = JSON.parse(raw);
|
|
140996
141144
|
if (value.operationId !== operation.id || value.missionId !== id || typeof value.baselinePath !== "string")
|
|
140997
141145
|
throw new Error("An active workspace has an ambiguous baseline reference.");
|
|
140998
|
-
protectedPaths.add(await
|
|
140999
|
-
protectedPaths.add(
|
|
141146
|
+
protectedPaths.add(await realpath39(value.baselinePath));
|
|
141147
|
+
protectedPaths.add(join69(operation.repositoryRoot, ".agent-valley", "operations", operation.id, "baselines", id, "workspace"));
|
|
141000
141148
|
}
|
|
141001
|
-
missionDirectories.push(
|
|
141149
|
+
missionDirectories.push(join69(storageRoot, ".agent-valley", "operation-decisions", operation.id));
|
|
141002
141150
|
}
|
|
141003
141151
|
for (const directory of missionDirectories) {
|
|
141004
141152
|
if (!await exists(directory))
|
|
141005
141153
|
continue;
|
|
141006
141154
|
await localDirectory3(directory);
|
|
141007
141155
|
const store = new MissionStore(directory);
|
|
141008
|
-
for (const name of await
|
|
141156
|
+
for (const name of await readdir21(directory)) {
|
|
141009
141157
|
if (!name.endsWith(".json"))
|
|
141010
141158
|
continue;
|
|
141011
|
-
await readLocal(
|
|
141159
|
+
await readLocal(join69(directory, name));
|
|
141012
141160
|
const mission = await store.load(name.slice(0, -5));
|
|
141013
141161
|
if (mission.status !== "completed" || mission.tasks.some((task) => task.effectState === "unknown") || mission.operations?.runs.some((run) => run.executionState && run.executionState !== "settled") || await processEvidence(directory, mission.id))
|
|
141014
141162
|
await protectMissionBaseline(mission, protectedPaths);
|
|
@@ -141018,9 +141166,9 @@ async function referencedBaselines(storageRoot, operations) {
|
|
|
141018
141166
|
}
|
|
141019
141167
|
async function pruneContinuousBaselines(storageRoot, operationId, options = {}) {
|
|
141020
141168
|
operationIdSchema.parse(operationId);
|
|
141021
|
-
if (await
|
|
141169
|
+
if (await realpath39(storageRoot) !== resolve39(storageRoot))
|
|
141022
141170
|
throw new Error("Use the original canonical operation storage root.");
|
|
141023
|
-
const directory =
|
|
141171
|
+
const directory = join69(storageRoot, ".agent-valley", "operations");
|
|
141024
141172
|
await localDirectory3(directory);
|
|
141025
141173
|
const store = new ContinuousOperationStore(directory);
|
|
141026
141174
|
const unlock = await store.lock(operationId);
|
|
@@ -141030,26 +141178,26 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141030
141178
|
await localDirectory3(root);
|
|
141031
141179
|
if (resolve39((await git2(root, ["rev-parse", "--show-toplevel"])).trim()) !== resolve39(root))
|
|
141032
141180
|
throw new Error("Restore the original Git repository before pruning.");
|
|
141033
|
-
const artifacts =
|
|
141034
|
-
const baselines =
|
|
141181
|
+
const artifacts = join69(root, ".agent-valley", "operations", operationId);
|
|
141182
|
+
const baselines = join69(artifacts, "baselines");
|
|
141035
141183
|
await localDirectory3(artifacts);
|
|
141036
141184
|
await localDirectory3(baselines);
|
|
141037
141185
|
const current = operation.baseline;
|
|
141038
141186
|
if (!current)
|
|
141039
141187
|
throw new Error("No accepted baseline exists. Preserve the operation artifacts.");
|
|
141040
141188
|
const protectedPaths = await referencedBaselines(storageRoot, await store.list());
|
|
141041
|
-
protectedPaths.add(
|
|
141189
|
+
protectedPaths.add(join69(baselines, "initial", "workspace"));
|
|
141042
141190
|
for (const entry of operation.history.slice(-2))
|
|
141043
141191
|
protectedPaths.add(entry.baselinePath);
|
|
141044
|
-
const currentReceipt = continuousBaselineSchema.parse(JSON.parse(await readLocal(
|
|
141192
|
+
const currentReceipt = continuousBaselineSchema.parse(JSON.parse(await readLocal(join69(dirname15(current.path), "baseline.json")) ?? "null"));
|
|
141045
141193
|
if (JSON.stringify(currentReceipt) !== JSON.stringify(current))
|
|
141046
141194
|
throw new Error("The accepted baseline receipt changed.");
|
|
141047
141195
|
await inspectClone(current.path, current);
|
|
141048
|
-
const missionsPath =
|
|
141196
|
+
const missionsPath = join69(storageRoot, ".agent-valley", "missions");
|
|
141049
141197
|
const missions = new MissionStore(missionsPath);
|
|
141050
141198
|
const candidates = [];
|
|
141051
|
-
for (const key of (await
|
|
141052
|
-
const path =
|
|
141199
|
+
for (const key of (await readdir21(baselines)).sort()) {
|
|
141200
|
+
const path = join69(baselines, key, "workspace");
|
|
141053
141201
|
let release;
|
|
141054
141202
|
let result = { key, path, status: "kept", reason: "Retained for inspection." };
|
|
141055
141203
|
try {
|
|
@@ -141057,16 +141205,16 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141057
141205
|
await localDirectory3(dirname15(path));
|
|
141058
141206
|
if (protectedPaths.has(path))
|
|
141059
141207
|
throw new Error("Initial, current, previous or referenced baseline is protected.");
|
|
141060
|
-
const raw = await readLocal(
|
|
141208
|
+
const raw = await readLocal(join69(dirname15(path), "baseline.json"));
|
|
141061
141209
|
const snapshot = continuousBaselineSchema.parse(JSON.parse(raw ?? "null"));
|
|
141062
|
-
const transaction = continuousBaselineSchema.parse(JSON.parse(await readLocal(
|
|
141210
|
+
const transaction = continuousBaselineSchema.parse(JSON.parse(await readLocal(join69(dirname15(path), "snapshot.json")) ?? "null"));
|
|
141063
141211
|
if (JSON.stringify(transaction) !== JSON.stringify(snapshot))
|
|
141064
141212
|
throw new Error("Original snapshot transaction and baseline receipts differ.");
|
|
141065
141213
|
if (snapshot.operationId !== operationId || snapshot.repositoryRoot !== root || snapshot.path !== path || snapshot.missionId !== key || snapshot.branch !== `av-operation/${operationId}/baseline-${key}`)
|
|
141066
141214
|
throw new Error("Baseline identity does not match its private directory.");
|
|
141067
|
-
const preparedPath =
|
|
141068
|
-
const completedPath =
|
|
141069
|
-
const quarantine =
|
|
141215
|
+
const preparedPath = join69(dirname15(path), "pruning.json");
|
|
141216
|
+
const completedPath = join69(dirname15(path), "pruned.json");
|
|
141217
|
+
const quarantine = join69(dirname15(path), "workspace.pruning");
|
|
141070
141218
|
const preparedRaw = await readLocal(preparedPath);
|
|
141071
141219
|
const prepared = preparedRaw ? preparedSchema.parse(JSON.parse(preparedRaw)) : undefined;
|
|
141072
141220
|
if (prepared && (prepared.operationId !== operationId || prepared.missionId !== key || prepared.path !== path || prepared.quarantine !== quarantine || prepared.commit !== snapshot.commit || prepared.tree !== snapshot.baselineTree || prepared.baselineDigest !== digest7(raw)))
|
|
@@ -141081,7 +141229,7 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141081
141229
|
continue;
|
|
141082
141230
|
}
|
|
141083
141231
|
const accepted = operation.history.some((entry) => entry.missionId === key && entry.baselinePath === path);
|
|
141084
|
-
const journalRaw = await readLocal(
|
|
141232
|
+
const journalRaw = await readLocal(join69(dirname15(path), "acceptance.json"));
|
|
141085
141233
|
const journal = journalRaw ? continuousAcceptanceSchema.parse(JSON.parse(journalRaw)) : undefined;
|
|
141086
141234
|
if (journal && (journal.operationId !== operationId || journal.repositoryRoot !== root || journal.missionId !== key || journal.baselinePath !== path || journal.commit !== snapshot.commit || journal.tree !== snapshot.baselineTree || journal.cycle > operation.completedCycles))
|
|
141087
141235
|
throw new Error("Acceptance journal does not match this frozen baseline.");
|
|
@@ -141117,7 +141265,7 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141117
141265
|
if (hasQuarantine && !prepared)
|
|
141118
141266
|
throw new Error("Unrecorded pruning quarantine is protected.");
|
|
141119
141267
|
await inspectClone(physicalPath, snapshot);
|
|
141120
|
-
const identity = await
|
|
141268
|
+
const identity = await lstat34(physicalPath);
|
|
141121
141269
|
if (prepared && (identity.dev !== prepared.device || identity.ino !== prepared.inode))
|
|
141122
141270
|
throw new Error("Workspace identity changed after pruning was prepared.");
|
|
141123
141271
|
result = {
|
|
@@ -141141,16 +141289,16 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141141
141289
|
at: (options.now?.() ?? new Date).toISOString()
|
|
141142
141290
|
});
|
|
141143
141291
|
await inspectClone(physicalPath, snapshot);
|
|
141144
|
-
const checked = await
|
|
141292
|
+
const checked = await lstat34(physicalPath);
|
|
141145
141293
|
if (checked.dev !== identity.dev || checked.ino !== identity.ino)
|
|
141146
141294
|
throw new Error("Workspace identity changed before pruning.");
|
|
141147
141295
|
if (!hasQuarantine)
|
|
141148
141296
|
await rename6(path, quarantine);
|
|
141149
141297
|
await localDirectory3(quarantine);
|
|
141150
|
-
const moved = await
|
|
141298
|
+
const moved = await lstat34(quarantine);
|
|
141151
141299
|
if (moved.dev !== identity.dev || moved.ino !== identity.ino)
|
|
141152
141300
|
throw new Error("Pruning quarantine identity changed.");
|
|
141153
|
-
await
|
|
141301
|
+
await rm14(quarantine, { recursive: true });
|
|
141154
141302
|
await immutable(completedPath, {
|
|
141155
141303
|
version: 1,
|
|
141156
141304
|
preparedDigest: digest7(receipt),
|
|
@@ -141183,7 +141331,7 @@ async function pruneContinuousBaselines(storageRoot, operationId, options = {})
|
|
|
141183
141331
|
// src/operations-prune.ts
|
|
141184
141332
|
async function pruneOperationArtifacts(id, options = {}, root = process.cwd()) {
|
|
141185
141333
|
assertNotManagedRun();
|
|
141186
|
-
const result = await pruneContinuousBaselines(await
|
|
141334
|
+
const result = await pruneContinuousBaselines(await realpath40(root), id, options);
|
|
141187
141335
|
console.log(`Operation ${id} baseline pruning: ${result.applied ? "apply" : "dry run"}.`);
|
|
141188
141336
|
for (const entry of result.candidates)
|
|
141189
141337
|
console.log(`${entry.status} ${entry.path}
|
|
@@ -141229,16 +141377,16 @@ function registerContinuousCommands(program) {
|
|
|
141229
141377
|
}
|
|
141230
141378
|
|
|
141231
141379
|
// src/chief-missions.ts
|
|
141232
|
-
import { join as
|
|
141380
|
+
import { join as join74 } from "node:path";
|
|
141233
141381
|
|
|
141234
141382
|
// ../../packages/core/src/chief/storage-gc.ts
|
|
141235
|
-
import { lstat as
|
|
141236
|
-
import { join as
|
|
141383
|
+
import { lstat as lstat36, readdir as readdir22, realpath as realpath41 } from "node:fs/promises";
|
|
141384
|
+
import { join as join71 } from "node:path";
|
|
141237
141385
|
|
|
141238
141386
|
// ../../packages/core/src/chief/continuous-archive.ts
|
|
141239
141387
|
init_zod();
|
|
141240
|
-
import { lstat as
|
|
141241
|
-
import { dirname as dirname16, join as
|
|
141388
|
+
import { lstat as lstat35, mkdir as mkdir29, readFile as readFile23, rename as rename7, rm as rm15 } from "node:fs/promises";
|
|
141389
|
+
import { dirname as dirname16, join as join70 } from "node:path";
|
|
141242
141390
|
var sha3 = string2().regex(/^[a-f0-9]{40,64}$/);
|
|
141243
141391
|
var archiveSchema = strictObject({
|
|
141244
141392
|
version: literal(1),
|
|
@@ -141262,16 +141410,16 @@ var snapshotIdentity = {
|
|
|
141262
141410
|
GIT_AUTHOR_DATE: "2000-01-01T00:00:00Z",
|
|
141263
141411
|
GIT_COMMITTER_DATE: "2000-01-01T00:00:00Z"
|
|
141264
141412
|
};
|
|
141265
|
-
var exists2 = (path) =>
|
|
141413
|
+
var exists2 = (path) => lstat35(path).then(() => true, (error) => {
|
|
141266
141414
|
if (error.code === "ENOENT")
|
|
141267
141415
|
return false;
|
|
141268
141416
|
throw error;
|
|
141269
141417
|
});
|
|
141270
141418
|
function operationArchiveRepository(container) {
|
|
141271
|
-
return
|
|
141419
|
+
return join70(dirname16(dirname16(container)), "archive.git");
|
|
141272
141420
|
}
|
|
141273
141421
|
async function readContinuousChildArchive(container) {
|
|
141274
|
-
const raw = await readFile23(
|
|
141422
|
+
const raw = await readFile23(join70(container, "archive", "archive.json"), "utf8").catch(() => {
|
|
141275
141423
|
return;
|
|
141276
141424
|
});
|
|
141277
141425
|
return raw === undefined ? undefined : archiveSchema.parse(JSON.parse(raw));
|
|
@@ -141281,11 +141429,11 @@ async function archiveContinuousChild(container, options = {}) {
|
|
|
141281
141429
|
if (!record)
|
|
141282
141430
|
throw new Error(`${container} has no matching AV operation child receipt (workspace.json). Preserve it and inspect it manually.`);
|
|
141283
141431
|
const repository = operationArchiveRepository(container);
|
|
141284
|
-
const archiveDirectory =
|
|
141432
|
+
const archiveDirectory = join70(container, "archive");
|
|
141285
141433
|
const existing = await readContinuousChildArchive(container);
|
|
141286
141434
|
if (existing) {
|
|
141287
141435
|
if (options.apply !== false)
|
|
141288
|
-
await
|
|
141436
|
+
await rm15(record.path, { recursive: true, force: true });
|
|
141289
141437
|
return { status: "already-archived", repository };
|
|
141290
141438
|
}
|
|
141291
141439
|
if (!await exists2(record.path))
|
|
@@ -141321,10 +141469,10 @@ async function archiveContinuousChild(container, options = {}) {
|
|
|
141321
141469
|
await mkdir29(archiveDirectory, { recursive: true, mode: 448 });
|
|
141322
141470
|
const receipts = [];
|
|
141323
141471
|
for (const name of [".agent-valley", ".agents"]) {
|
|
141324
|
-
const source =
|
|
141472
|
+
const source = join70(record.path, name);
|
|
141325
141473
|
if (!await exists2(source))
|
|
141326
141474
|
continue;
|
|
141327
|
-
let target =
|
|
141475
|
+
let target = join70(archiveDirectory, name.slice(1));
|
|
141328
141476
|
if (await exists2(target))
|
|
141329
141477
|
target = `${target}-${Date.now()}`;
|
|
141330
141478
|
await rename7(source, target);
|
|
@@ -141344,25 +141492,25 @@ async function archiveContinuousChild(container, options = {}) {
|
|
|
141344
141492
|
archivedAt: (options.now ?? (() => new Date))().toISOString(),
|
|
141345
141493
|
restore: `git clone ${repository} <dir> && git -C <dir> checkout ${productCommit}`
|
|
141346
141494
|
};
|
|
141347
|
-
await writeParallelJson(
|
|
141348
|
-
await
|
|
141495
|
+
await writeParallelJson(join70(archiveDirectory, "archive.json"), archive);
|
|
141496
|
+
await rm15(record.path, { recursive: true, force: true });
|
|
141349
141497
|
return { status: "archived", repository };
|
|
141350
141498
|
}
|
|
141351
141499
|
|
|
141352
141500
|
// ../../packages/core/src/chief/storage-gc.ts
|
|
141353
141501
|
var DEFAULT_STORAGE_STALE_DAYS = 7;
|
|
141354
141502
|
var DAY_MS = 86400000;
|
|
141355
|
-
var exists3 = (path) =>
|
|
141503
|
+
var exists3 = (path) => lstat36(path).then(() => true, () => false);
|
|
141356
141504
|
var message2 = (error) => error instanceof Error ? error.message : String(error);
|
|
141357
141505
|
async function savedMissions(root, operationIds) {
|
|
141358
141506
|
const directories = [
|
|
141359
|
-
|
|
141360
|
-
...operationIds.map((id) =>
|
|
141507
|
+
join71(root, ".agent-valley", "missions"),
|
|
141508
|
+
...operationIds.map((id) => join71(root, ".agent-valley", "operation-decisions", id))
|
|
141361
141509
|
];
|
|
141362
141510
|
const saved = new Map;
|
|
141363
141511
|
for (const directory of directories) {
|
|
141364
141512
|
const store = new MissionStore(directory);
|
|
141365
|
-
for (const name of (await
|
|
141513
|
+
for (const name of (await readdir22(directory).catch(() => [])).sort()) {
|
|
141366
141514
|
if (!name.endsWith(".json"))
|
|
141367
141515
|
continue;
|
|
141368
141516
|
const id = name.slice(0, -5);
|
|
@@ -141375,7 +141523,7 @@ async function savedMissions(root, operationIds) {
|
|
|
141375
141523
|
return saved;
|
|
141376
141524
|
}
|
|
141377
141525
|
async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
141378
|
-
const root = await
|
|
141526
|
+
const root = await realpath41(repositoryRoot);
|
|
141379
141527
|
const apply = options.apply === true;
|
|
141380
141528
|
const staleDays = options.staleDays ?? DEFAULT_STORAGE_STALE_DAYS;
|
|
141381
141529
|
if (!Number.isFinite(staleDays) || staleDays < 0)
|
|
@@ -141384,7 +141532,7 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141384
141532
|
const idleDays = (mission) => (now - Date.parse(mission.updatedAt)) / DAY_MS;
|
|
141385
141533
|
const outcome = apply ? "released" : "eligible";
|
|
141386
141534
|
const entries = [];
|
|
141387
|
-
const operations = await new ContinuousOperationStore(
|
|
141535
|
+
const operations = await new ContinuousOperationStore(join71(root, ".agent-valley", "operations")).list().catch(() => []);
|
|
141388
141536
|
const missions = await savedMissions(root, operations.map((operation) => operation.id));
|
|
141389
141537
|
for (const [missionId, { mission, active }] of missions) {
|
|
141390
141538
|
const completed = mission.status === "completed";
|
|
@@ -141419,7 +141567,7 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141419
141567
|
entries.push({
|
|
141420
141568
|
kind: "build-output",
|
|
141421
141569
|
missionId,
|
|
141422
|
-
path:
|
|
141570
|
+
path: join71(mission.workspace.path, relative),
|
|
141423
141571
|
outcome,
|
|
141424
141572
|
reason: `Ignored build output in the AV-owned workspace of a ${why}.`
|
|
141425
141573
|
});
|
|
@@ -141440,9 +141588,9 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141440
141588
|
operation.sourceIntegration?.missionId,
|
|
141441
141589
|
...operation.history.slice(-2).map((entry) => entry.missionId)
|
|
141442
141590
|
].filter((id) => Boolean(id)));
|
|
141443
|
-
const workspaces =
|
|
141444
|
-
for (const missionId of (await
|
|
141445
|
-
const container =
|
|
141591
|
+
const workspaces = join71(root, ".agent-valley", "operations", operation.id, "workspaces");
|
|
141592
|
+
for (const missionId of (await readdir22(workspaces).catch(() => [])).sort()) {
|
|
141593
|
+
const container = join71(workspaces, missionId);
|
|
141446
141594
|
const record = await readContinuousMissionWorkspace(container);
|
|
141447
141595
|
if (!record || !await exists3(record.path) || protectedIds.has(missionId))
|
|
141448
141596
|
continue;
|
|
@@ -141459,7 +141607,7 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141459
141607
|
missionId,
|
|
141460
141608
|
path: record.path,
|
|
141461
141609
|
outcome,
|
|
141462
|
-
reason: `${saved.mission.status} child idle for ${Math.floor(idleDays(saved.mission))} days; branches, evidence refs and product commit go to ${result.repository}, receipts to ${
|
|
141610
|
+
reason: `${saved.mission.status} child idle for ${Math.floor(idleDays(saved.mission))} days; branches, evidence refs and product commit go to ${result.repository}, receipts to ${join71(container, "archive")}.`
|
|
141463
141611
|
});
|
|
141464
141612
|
} catch (error) {
|
|
141465
141613
|
entries.push({
|
|
@@ -141491,7 +141639,7 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141491
141639
|
entries.push({
|
|
141492
141640
|
kind: "baseline",
|
|
141493
141641
|
operationId: operation.id,
|
|
141494
|
-
path:
|
|
141642
|
+
path: join71(root, ".agent-valley", "operations", operation.id, "baselines"),
|
|
141495
141643
|
outcome: "kept",
|
|
141496
141644
|
reason: message2(error)
|
|
141497
141645
|
});
|
|
@@ -141502,14 +141650,14 @@ async function collectStorageGarbage(repositoryRoot, options = {}) {
|
|
|
141502
141650
|
|
|
141503
141651
|
// src/chief-reconcile.ts
|
|
141504
141652
|
init_execution();
|
|
141505
|
-
import { join as
|
|
141653
|
+
import { join as join72 } from "node:path";
|
|
141506
141654
|
async function reconcileMissionExecution(missionId, options, root = process.cwd()) {
|
|
141507
141655
|
assertNotManagedRun();
|
|
141508
141656
|
const runId = options.run?.trim();
|
|
141509
141657
|
const evidence = options.evidence?.trim();
|
|
141510
141658
|
if (!runId || runId.length > 2000 || !evidence || evidence.length > 2000)
|
|
141511
141659
|
throw new Error("Set --run to the uncertain execution ID and --evidence to 1–2,000 characters describing how you confirmed it stopped.");
|
|
141512
|
-
const store = new MissionStore(
|
|
141660
|
+
const store = new MissionStore(join72(root, ".agent-valley", "missions"));
|
|
141513
141661
|
const unlock = await store.lock(missionId);
|
|
141514
141662
|
try {
|
|
141515
141663
|
const mission = await store.load(missionId);
|
|
@@ -141538,7 +141686,7 @@ function registerMissionReconciliation(missions, root = process.cwd()) {
|
|
|
141538
141686
|
}
|
|
141539
141687
|
|
|
141540
141688
|
// src/chief-watch.ts
|
|
141541
|
-
import { join as
|
|
141689
|
+
import { join as join73 } from "node:path";
|
|
141542
141690
|
var STORAGE_GC_INTERVAL_MS = 60 * 60 * 1000;
|
|
141543
141691
|
async function watchOrders(root = process.cwd(), dependencies = {}) {
|
|
141544
141692
|
assertNotManagedRun();
|
|
@@ -141552,7 +141700,7 @@ async function watchOrders(root = process.cwd(), dependencies = {}) {
|
|
|
141552
141700
|
process.once("SIGINT", stop);
|
|
141553
141701
|
process.once("SIGTERM", terminate);
|
|
141554
141702
|
}
|
|
141555
|
-
const missions = new MissionStore(
|
|
141703
|
+
const missions = new MissionStore(join73(root, ".agent-valley", "missions"));
|
|
141556
141704
|
const now = dependencies.now ?? Date.now;
|
|
141557
141705
|
let lastStorageGc = Number.NEGATIVE_INFINITY;
|
|
141558
141706
|
try {
|
|
@@ -141654,7 +141802,7 @@ function registerMissionCommands(program) {
|
|
|
141654
141802
|
await watchOrders(process.cwd(), { service: options.service, storageGc: collectStorageGarbage });
|
|
141655
141803
|
return;
|
|
141656
141804
|
}
|
|
141657
|
-
const missions = await new MissionStore(
|
|
141805
|
+
const missions = await new MissionStore(join74(process.cwd(), ".agent-valley/missions")).list();
|
|
141658
141806
|
if (options.json) {
|
|
141659
141807
|
console.log(JSON.stringify(missions.map((mission) => ({
|
|
141660
141808
|
id: mission.id,
|
|
@@ -141702,12 +141850,12 @@ function registerChiefCommands(program) {
|
|
|
141702
141850
|
|
|
141703
141851
|
// src/chief-organization.ts
|
|
141704
141852
|
import { readFile as readFile24, stat as stat8 } from "node:fs/promises";
|
|
141705
|
-
import { isAbsolute as
|
|
141853
|
+
import { isAbsolute as isAbsolute24, join as join75, resolve as resolve40 } from "node:path";
|
|
141706
141854
|
init_chief_schema();
|
|
141707
141855
|
init_yaml_loader();
|
|
141708
141856
|
function organizationRepository(root, workspace) {
|
|
141709
141857
|
const repository = workspace ?? loadProjectConfig(root)?.workspace?.root ?? root;
|
|
141710
|
-
if (!
|
|
141858
|
+
if (!isAbsolute24(repository))
|
|
141711
141859
|
throw new Error("Set workspace.root in av.yaml or --workspace to an absolute source repository path.");
|
|
141712
141860
|
return repository;
|
|
141713
141861
|
}
|
|
@@ -141756,13 +141904,13 @@ function registerOrganizationCommands(program) {
|
|
|
141756
141904
|
});
|
|
141757
141905
|
const reports = program.command("reports").description("Inspect and retry third-party report attachments");
|
|
141758
141906
|
reports.command("list").option("--workspace <path>", "Source repository").action(async (opts) => {
|
|
141759
|
-
console.log(JSON.stringify(await listReportDeliveries(
|
|
141907
|
+
console.log(JSON.stringify(await listReportDeliveries(join75(organizationRepository(process.cwd(), opts.workspace), ".agent-valley")), null, 2));
|
|
141760
141908
|
});
|
|
141761
141909
|
reports.command("retry").option("--workspace <path>", "Source repository").action(async (opts) => {
|
|
141762
141910
|
const config = mergeChiefConfig(loadGlobalConfig()?.chief, loadProjectConfig()?.chief);
|
|
141763
141911
|
if (!config.reporting)
|
|
141764
141912
|
throw new Error("Set chief.reporting.destinations in av.yaml before retrying reports.");
|
|
141765
|
-
console.log(JSON.stringify(await retryPendingReports(config.reporting,
|
|
141913
|
+
console.log(JSON.stringify(await retryPendingReports(config.reporting, join75(organizationRepository(process.cwd(), opts.workspace), ".agent-valley")), null, 2));
|
|
141766
141914
|
});
|
|
141767
141915
|
}
|
|
141768
141916
|
|
|
@@ -141787,10 +141935,10 @@ var import_picocolors = __toESM(require_picocolors(), 1);
|
|
|
141787
141935
|
init_project_config_path();
|
|
141788
141936
|
init_yaml_loader();
|
|
141789
141937
|
init_doctor_checks();
|
|
141790
|
-
import { join as
|
|
141938
|
+
import { join as join83 } from "node:path";
|
|
141791
141939
|
|
|
141792
141940
|
// src/doctor-oma-checks.ts
|
|
141793
|
-
import { join as
|
|
141941
|
+
import { join as join82 } from "node:path";
|
|
141794
141942
|
function checkOma(project, deps) {
|
|
141795
141943
|
const strict = project?.oma?.mode === "strict";
|
|
141796
141944
|
const order = !!project && !project.tracker && !project.linear && !project.github;
|
|
@@ -141878,7 +142026,7 @@ function checkOma(project, deps) {
|
|
|
141878
142026
|
fix: "Set verify.command to a deterministic non-build check in av.yaml before using oma.mode: strict.",
|
|
141879
142027
|
critical: true
|
|
141880
142028
|
});
|
|
141881
|
-
const triggerPath =
|
|
142029
|
+
const triggerPath = join82(deps.cwd, ".agents", "hooks", "core", "triggers.json");
|
|
141882
142030
|
let table = null;
|
|
141883
142031
|
try {
|
|
141884
142032
|
table = parseTriggerTable(deps.readFileSync(triggerPath));
|
|
@@ -141895,7 +142043,7 @@ function checkOma(project, deps) {
|
|
|
141895
142043
|
return results;
|
|
141896
142044
|
}
|
|
141897
142045
|
results.push({ id: "oma.triggers", name: "OMA trigger table", status: "pass", message: triggerPath, critical: false });
|
|
141898
|
-
const missing = Object.entries(table.workflows).filter(([name, workflow]) => !workflow.persistent && !table.excludedWorkflows.includes(name)).map(([name]) =>
|
|
142046
|
+
const missing = Object.entries(table.workflows).filter(([name, workflow]) => !workflow.persistent && !table.excludedWorkflows.includes(name)).map(([name]) => join82(deps.cwd, ".agents", "workflows", `${name}.md`)).filter((path) => !deps.existsSync(path));
|
|
141899
142047
|
results.push(missing.length === 0 ? {
|
|
141900
142048
|
id: "oma.workflows",
|
|
141901
142049
|
name: "OMA workflow files",
|
|
@@ -141970,7 +142118,7 @@ function checkTunnel(project, deps) {
|
|
|
141970
142118
|
}
|
|
141971
142119
|
const mode = project?.tunnel?.cloudflare?.mode ?? "quick";
|
|
141972
142120
|
if (mode === "named") {
|
|
141973
|
-
const certPath =
|
|
142121
|
+
const certPath = join83(deps.home, ".cloudflared", "cert.pem");
|
|
141974
142122
|
if (!deps.existsSync(certPath)) {
|
|
141975
142123
|
return {
|
|
141976
142124
|
id: "tunnel",
|
|
@@ -142010,7 +142158,7 @@ function checkTunnel(project, deps) {
|
|
|
142010
142158
|
critical: false
|
|
142011
142159
|
};
|
|
142012
142160
|
}
|
|
142013
|
-
const ngrokConfigPath = deps.platform === "darwin" ?
|
|
142161
|
+
const ngrokConfigPath = deps.platform === "darwin" ? join83(deps.home, "Library", "Application Support", "ngrok", "ngrok.yml") : join83(deps.home, ".config", "ngrok", "ngrok.yml");
|
|
142014
142162
|
if (!deps.existsSync(ngrokConfigPath)) {
|
|
142015
142163
|
return {
|
|
142016
142164
|
id: "tunnel",
|
|
@@ -142081,7 +142229,7 @@ function checkConfig(deps) {
|
|
|
142081
142229
|
critical: true
|
|
142082
142230
|
});
|
|
142083
142231
|
}
|
|
142084
|
-
const projectPath =
|
|
142232
|
+
const projectPath = join83(deps.cwd, PROJECT_CONFIG_FILENAME);
|
|
142085
142233
|
try {
|
|
142086
142234
|
project = deps.loadProjectConfig(deps.cwd);
|
|
142087
142235
|
results.push(project ? {
|
|
@@ -142472,12 +142620,12 @@ async function readStatus(port) {
|
|
|
142472
142620
|
}
|
|
142473
142621
|
|
|
142474
142622
|
// src/storage-gc-command.ts
|
|
142475
|
-
import { execFile as
|
|
142623
|
+
import { execFile as execFile10 } from "node:child_process";
|
|
142476
142624
|
import { promisify as promisify6 } from "node:util";
|
|
142477
142625
|
init_disk_budget();
|
|
142478
|
-
var exec5 = promisify6(
|
|
142479
|
-
var
|
|
142480
|
-
var gib = (bytes) => `${(bytes /
|
|
142626
|
+
var exec5 = promisify6(execFile10);
|
|
142627
|
+
var GIB3 = 1024 ** 3;
|
|
142628
|
+
var gib = (bytes) => `${(bytes / GIB3).toFixed(1)} GiB`;
|
|
142481
142629
|
async function diskUsage(path) {
|
|
142482
142630
|
try {
|
|
142483
142631
|
const { stdout } = await exec5("du", ["-sk", path]);
|
|
@@ -146694,8 +146842,8 @@ init_team_relay_error();
|
|
|
146694
146842
|
|
|
146695
146843
|
// ../../packages/core/src/relay/turso-migration-assets.ts
|
|
146696
146844
|
init_zod();
|
|
146697
|
-
import { copyFile as copyFile3, lstat as
|
|
146698
|
-
import { dirname as dirname20, join as
|
|
146845
|
+
import { copyFile as copyFile3, lstat as lstat42, mkdir as mkdir30, readFile as readFile26 } from "node:fs/promises";
|
|
146846
|
+
import { dirname as dirname20, join as join89 } from "node:path";
|
|
146699
146847
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
146700
146848
|
var TURSO_MIGRATION_ASSET_PATH = "assets/turso/migrations";
|
|
146701
146849
|
var journalSchema = object({
|
|
@@ -146716,7 +146864,7 @@ function tursoMigrationAssetCandidates(moduleUrl = import.meta.url) {
|
|
|
146716
146864
|
];
|
|
146717
146865
|
}
|
|
146718
146866
|
async function regularFile2(path) {
|
|
146719
|
-
const info = await
|
|
146867
|
+
const info = await lstat42(path);
|
|
146720
146868
|
if (!info.isFile() || info.isSymbolicLink())
|
|
146721
146869
|
throw new Error(`Turso migration asset ${path} must be a regular file. Restore the checkout or reinstall the CLI package.`);
|
|
146722
146870
|
}
|
|
@@ -146724,7 +146872,7 @@ async function loadTursoMigrationAssets(candidates = tursoMigrationAssetCandidat
|
|
|
146724
146872
|
for (const directory of candidates) {
|
|
146725
146873
|
let info;
|
|
146726
146874
|
try {
|
|
146727
|
-
info = await
|
|
146875
|
+
info = await lstat42(directory);
|
|
146728
146876
|
} catch (error) {
|
|
146729
146877
|
if (error.code === "ENOENT")
|
|
146730
146878
|
continue;
|
|
@@ -146733,10 +146881,10 @@ async function loadTursoMigrationAssets(candidates = tursoMigrationAssetCandidat
|
|
|
146733
146881
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
146734
146882
|
throw new Error(`Turso migration directory ${directory} must be a regular directory. Restore the checkout or reinstall the CLI package.`);
|
|
146735
146883
|
try {
|
|
146736
|
-
const meta = await
|
|
146884
|
+
const meta = await lstat42(join89(directory, "meta"));
|
|
146737
146885
|
if (!meta.isDirectory() || meta.isSymbolicLink())
|
|
146738
146886
|
throw new Error("Invalid migration metadata directory");
|
|
146739
|
-
const journalPath =
|
|
146887
|
+
const journalPath = join89(directory, "meta/_journal.json");
|
|
146740
146888
|
await regularFile2(journalPath);
|
|
146741
146889
|
const journal = journalSchema.parse(JSON.parse(await readFile26(journalPath, "utf8")));
|
|
146742
146890
|
const tags = journal.entries.map((entry) => entry.tag);
|
|
@@ -146744,8 +146892,8 @@ async function loadTursoMigrationAssets(candidates = tursoMigrationAssetCandidat
|
|
|
146744
146892
|
throw new Error("Duplicate migration tags");
|
|
146745
146893
|
const files = ["meta/_journal.json", ...tags.map((tag) => `${tag}.sql`)];
|
|
146746
146894
|
for (const file of files.slice(1)) {
|
|
146747
|
-
await regularFile2(
|
|
146748
|
-
if (!(await readFile26(
|
|
146895
|
+
await regularFile2(join89(directory, file));
|
|
146896
|
+
if (!(await readFile26(join89(directory, file), "utf8")).trim())
|
|
146749
146897
|
throw new Error("Empty migration SQL");
|
|
146750
146898
|
}
|
|
146751
146899
|
return { directory, files };
|