@mycompbox/compbox-cli 1.21.19 → 1.21.20
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/.tsbuildinfo +1 -1
- package/agents/internal/feature-worker.md +311 -0
- package/agents/orchestrator.md +1203 -0
- package/agents/planner.md +694 -0
- package/agents/request-formulator.md +450 -0
- package/commands/run.d.ts.map +1 -1
- package/commands/run.js +14 -2
- package/commands/run.js.map +1 -1
- package/commands/workspace.d.ts.map +1 -1
- package/commands/workspace.js +7 -2
- package/commands/workspace.js.map +1 -1
- package/index.js +559 -250
- package/package.json +1 -1
- package/utils/agent-invoker.d.ts +83 -0
- package/utils/agent-invoker.d.ts.map +1 -1
- package/utils/agent-invoker.js +252 -11
- package/utils/agent-invoker.js.map +1 -1
- package/utils/agent-store.d.ts +26 -4
- package/utils/agent-store.d.ts.map +1 -1
- package/utils/agent-store.js +79 -7
- package/utils/agent-store.js.map +1 -1
- package/utils/bundled-agents.d.ts +29 -0
- package/utils/bundled-agents.d.ts.map +1 -0
- package/utils/bundled-agents.js +73 -0
- package/utils/bundled-agents.js.map +1 -0
package/index.js
CHANGED
|
@@ -261,11 +261,11 @@ var FileManager = class {
|
|
|
261
261
|
await this.ensureDirectories();
|
|
262
262
|
const tar = await import("tar");
|
|
263
263
|
const fs4 = await import("fs/promises");
|
|
264
|
-
const
|
|
264
|
+
const path5 = await import("path");
|
|
265
265
|
const os2 = await import("os");
|
|
266
|
-
const tmpDir = await fs4.mkdtemp(
|
|
266
|
+
const tmpDir = await fs4.mkdtemp(path5.join(os2.tmpdir(), "compbox-extract-"));
|
|
267
267
|
try {
|
|
268
|
-
const tarPath =
|
|
268
|
+
const tarPath = path5.join(tmpDir, "pack.tar.gz");
|
|
269
269
|
await fs4.writeFile(tarPath, filesBuffer);
|
|
270
270
|
await tar.extract({
|
|
271
271
|
file: tarPath,
|
|
@@ -276,9 +276,9 @@ var FileManager = class {
|
|
|
276
276
|
for (const file of extractedFiles) {
|
|
277
277
|
if (file === "pack.tar.gz") continue;
|
|
278
278
|
const normalizedFile = file.startsWith(".github/") || file.startsWith(".github\\") ? file.slice(".github/".length) : file;
|
|
279
|
-
const sourcePath =
|
|
280
|
-
const targetPath =
|
|
281
|
-
const targetFileDir =
|
|
279
|
+
const sourcePath = path5.join(tmpDir, file);
|
|
280
|
+
const targetPath = path5.join(this.githubDir, normalizedFile);
|
|
281
|
+
const targetFileDir = path5.dirname(targetPath);
|
|
282
282
|
await fs4.mkdir(targetFileDir, { recursive: true });
|
|
283
283
|
await fs4.copyFile(sourcePath, targetPath);
|
|
284
284
|
installedFiles.push(normalizedFile);
|
|
@@ -298,17 +298,17 @@ var FileManager = class {
|
|
|
298
298
|
*/
|
|
299
299
|
async getAllFiles(dir, baseDir) {
|
|
300
300
|
const fs4 = await import("fs/promises");
|
|
301
|
-
const
|
|
301
|
+
const path5 = await import("path");
|
|
302
302
|
const base = baseDir ?? dir;
|
|
303
303
|
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
304
304
|
const files = [];
|
|
305
305
|
for (const entry of entries) {
|
|
306
|
-
const fullPath =
|
|
306
|
+
const fullPath = path5.join(dir, entry.name);
|
|
307
307
|
if (entry.isDirectory()) {
|
|
308
308
|
const nestedFiles = await this.getAllFiles(fullPath, base);
|
|
309
309
|
files.push(...nestedFiles);
|
|
310
310
|
} else if (entry.isFile()) {
|
|
311
|
-
const relativePath =
|
|
311
|
+
const relativePath = path5.relative(base, fullPath);
|
|
312
312
|
files.push(relativePath);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
@@ -769,12 +769,12 @@ function installAutostart() {
|
|
|
769
769
|
const home = homedir2();
|
|
770
770
|
const script = scriptInstallPath(home);
|
|
771
771
|
const node = process.execPath;
|
|
772
|
-
const
|
|
772
|
+
const path5 = process.env.PATH ?? "/usr/bin:/bin";
|
|
773
773
|
if (process.platform === "darwin") {
|
|
774
774
|
const plistPath = join3(home, "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
775
775
|
const logFile = join3(home, ".compbox", "agent-runner.log");
|
|
776
776
|
mkdirSync(dirname2(plistPath), { recursive: true });
|
|
777
|
-
writeFileSync(plistPath, launchdPlist({ node, script, path:
|
|
777
|
+
writeFileSync(plistPath, launchdPlist({ node, script, path: path5, logFile }));
|
|
778
778
|
const domain = `gui/${String(process.getuid?.() ?? 0)}`;
|
|
779
779
|
try {
|
|
780
780
|
execFileSync2("launchctl", ["bootout", domain, plistPath], { stdio: "ignore" });
|
|
@@ -786,7 +786,7 @@ function installAutostart() {
|
|
|
786
786
|
if (process.platform === "linux") {
|
|
787
787
|
const unitPath = join3(home, ".config", "systemd", "user", SYSTEMD_UNIT);
|
|
788
788
|
mkdirSync(dirname2(unitPath), { recursive: true });
|
|
789
|
-
writeFileSync(unitPath, systemdUnit({ node, script, path:
|
|
789
|
+
writeFileSync(unitPath, systemdUnit({ node, script, path: path5 }));
|
|
790
790
|
execFileSync2("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
791
791
|
execFileSync2("systemctl", ["--user", "enable", "--now", SYSTEMD_UNIT], { stdio: "pipe" });
|
|
792
792
|
return `it starts at every login (stop it with \`systemctl --user disable --now ${SYSTEMD_UNIT}\`)`;
|
|
@@ -813,11 +813,11 @@ async function defaultLatestVersion() {
|
|
|
813
813
|
}
|
|
814
814
|
var execFileAsync = promisify(execFile);
|
|
815
815
|
function defaultRun(file, args) {
|
|
816
|
-
return new Promise((
|
|
816
|
+
return new Promise((resolve7, reject) => {
|
|
817
817
|
const child = spawn(file, args, { stdio: "inherit", shell: process.platform === "win32" && file.endsWith(".cmd") });
|
|
818
818
|
child.on("error", reject);
|
|
819
819
|
child.on("exit", (code, signal) => {
|
|
820
|
-
if (code === 0)
|
|
820
|
+
if (code === 0) resolve7();
|
|
821
821
|
else reject(new Error(`${file} ${args.join(" ")} exited with ${signal ?? String(code)}`));
|
|
822
822
|
});
|
|
823
823
|
});
|
|
@@ -829,9 +829,9 @@ async function defaultDownload(url) {
|
|
|
829
829
|
}
|
|
830
830
|
function defaultWriteTemp(name, content) {
|
|
831
831
|
const dir = mkdtempSync(join4(tmpdir(), "compbox-update-"));
|
|
832
|
-
const
|
|
833
|
-
writeFileSync2(
|
|
834
|
-
return { path:
|
|
832
|
+
const path5 = join4(dir, name);
|
|
833
|
+
writeFileSync2(path5, content, { mode: 448 });
|
|
834
|
+
return { path: path5, cleanup: () => {
|
|
835
835
|
rmSync(dir, { recursive: true, force: true });
|
|
836
836
|
} };
|
|
837
837
|
}
|
|
@@ -867,9 +867,9 @@ function safeRealpath(d, p) {
|
|
|
867
867
|
function norm(p) {
|
|
868
868
|
return p.replace(/\\/g, "/");
|
|
869
869
|
}
|
|
870
|
-
function isUnder(
|
|
870
|
+
function isUnder(path5, dir) {
|
|
871
871
|
const base = norm(dir).replace(/\/+$/, "");
|
|
872
|
-
return norm(
|
|
872
|
+
return norm(path5).startsWith(`${base}/`);
|
|
873
873
|
}
|
|
874
874
|
function windowsScriptPath(d) {
|
|
875
875
|
return d.localAppData ? join4(d.localAppData, "CompBox", "compbox.cjs") : null;
|
|
@@ -1295,13 +1295,13 @@ async function refreshPacksAfterUpdate(options, nonInteractive) {
|
|
|
1295
1295
|
const entry = process.argv[1];
|
|
1296
1296
|
if (!entry) return;
|
|
1297
1297
|
console.log(chalk3.gray("\nChecking Skill Packs for updates..."));
|
|
1298
|
-
const code = await new Promise((
|
|
1298
|
+
const code = await new Promise((resolve7) => {
|
|
1299
1299
|
const child = spawn2(process.execPath, [entry, ...packRefreshArgs(options, nonInteractive)], { stdio: "inherit" });
|
|
1300
1300
|
child.on("error", () => {
|
|
1301
|
-
|
|
1301
|
+
resolve7(null);
|
|
1302
1302
|
});
|
|
1303
1303
|
child.on("close", (c) => {
|
|
1304
|
-
|
|
1304
|
+
resolve7(c);
|
|
1305
1305
|
});
|
|
1306
1306
|
});
|
|
1307
1307
|
if (code !== 0) {
|
|
@@ -1862,7 +1862,7 @@ function normalizeGitRemote(raw) {
|
|
|
1862
1862
|
if (input === "")
|
|
1863
1863
|
return "";
|
|
1864
1864
|
let host = "";
|
|
1865
|
-
let
|
|
1865
|
+
let path5 = "";
|
|
1866
1866
|
const hasScheme = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(input);
|
|
1867
1867
|
if (hasScheme) {
|
|
1868
1868
|
let url;
|
|
@@ -1872,7 +1872,7 @@ function normalizeGitRemote(raw) {
|
|
|
1872
1872
|
return input;
|
|
1873
1873
|
}
|
|
1874
1874
|
host = url.hostname.toLowerCase();
|
|
1875
|
-
|
|
1875
|
+
path5 = url.pathname;
|
|
1876
1876
|
} else {
|
|
1877
1877
|
const scp = /^(?:[^@]+@)?([^:]+):(.*)$/.exec(input);
|
|
1878
1878
|
const scpHost = scp?.[1];
|
|
@@ -1881,10 +1881,10 @@ function normalizeGitRemote(raw) {
|
|
|
1881
1881
|
return input.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1882
1882
|
}
|
|
1883
1883
|
host = scpHost.toLowerCase();
|
|
1884
|
-
|
|
1884
|
+
path5 = scpPath;
|
|
1885
1885
|
}
|
|
1886
|
-
|
|
1887
|
-
return `https://${host}/${
|
|
1886
|
+
path5 = path5.replace(/^\/+/, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1887
|
+
return `https://${host}/${path5}`;
|
|
1888
1888
|
}
|
|
1889
1889
|
|
|
1890
1890
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
@@ -2365,8 +2365,8 @@ function getErrorMap() {
|
|
|
2365
2365
|
|
|
2366
2366
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
2367
2367
|
var makeIssue = (params) => {
|
|
2368
|
-
const { data, path:
|
|
2369
|
-
const fullPath = [...
|
|
2368
|
+
const { data, path: path5, errorMaps, issueData } = params;
|
|
2369
|
+
const fullPath = [...path5, ...issueData.path || []];
|
|
2370
2370
|
const fullIssue = {
|
|
2371
2371
|
...issueData,
|
|
2372
2372
|
path: fullPath
|
|
@@ -2482,11 +2482,11 @@ var errorUtil;
|
|
|
2482
2482
|
|
|
2483
2483
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
2484
2484
|
var ParseInputLazyPath = class {
|
|
2485
|
-
constructor(parent, value,
|
|
2485
|
+
constructor(parent, value, path5, key) {
|
|
2486
2486
|
this._cachedPath = [];
|
|
2487
2487
|
this.parent = parent;
|
|
2488
2488
|
this.data = value;
|
|
2489
|
-
this._path =
|
|
2489
|
+
this._path = path5;
|
|
2490
2490
|
this._key = key;
|
|
2491
2491
|
}
|
|
2492
2492
|
get path() {
|
|
@@ -7263,6 +7263,18 @@ var AGENT_TYPICAL_MINUTES = {
|
|
|
7263
7263
|
[BELT_AGENT_KEYS.planReviewer]: 5
|
|
7264
7264
|
};
|
|
7265
7265
|
|
|
7266
|
+
// ../shared/dist/brief-files.js
|
|
7267
|
+
var BRIEF_DIR = ".compbox/brief";
|
|
7268
|
+
var BRIEF_FILES = {
|
|
7269
|
+
summary: `${BRIEF_DIR}/summary.md`,
|
|
7270
|
+
architecture: `${BRIEF_DIR}/architecture.md`,
|
|
7271
|
+
productDesign: `${BRIEF_DIR}/product.md`,
|
|
7272
|
+
businessPlan: `${BRIEF_DIR}/business.md`,
|
|
7273
|
+
rules: `${BRIEF_DIR}/rules.md`,
|
|
7274
|
+
pathMap: `${BRIEF_DIR}/path-map.md`
|
|
7275
|
+
};
|
|
7276
|
+
var BRIEF_DIAGRAMS_DIR = `${BRIEF_DIR}/diagrams`;
|
|
7277
|
+
|
|
7266
7278
|
// src/utils/config-store.ts
|
|
7267
7279
|
var DEFAULT_BUILD_STALL_MINUTES = 30;
|
|
7268
7280
|
var DEFAULT_BUILD_MAX_HOURS = 12;
|
|
@@ -7302,11 +7314,11 @@ function getConfigPath() {
|
|
|
7302
7314
|
}
|
|
7303
7315
|
function readConfig() {
|
|
7304
7316
|
try {
|
|
7305
|
-
const
|
|
7306
|
-
if (!existsSync6(
|
|
7317
|
+
const path5 = getConfigPath();
|
|
7318
|
+
if (!existsSync6(path5)) {
|
|
7307
7319
|
return {};
|
|
7308
7320
|
}
|
|
7309
|
-
const parsed = JSON.parse(readFileSync2(
|
|
7321
|
+
const parsed = JSON.parse(readFileSync2(path5, "utf-8"));
|
|
7310
7322
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
7311
7323
|
return parsed;
|
|
7312
7324
|
}
|
|
@@ -7318,14 +7330,14 @@ function readConfig() {
|
|
|
7318
7330
|
function writeConfig(config) {
|
|
7319
7331
|
const dir = getConfigDir();
|
|
7320
7332
|
mkdirSync2(dir, { recursive: true });
|
|
7321
|
-
const
|
|
7322
|
-
writeFileSync3(
|
|
7333
|
+
const path5 = getConfigPath();
|
|
7334
|
+
writeFileSync3(path5, `${JSON.stringify(config, null, 2)}
|
|
7323
7335
|
`, {
|
|
7324
7336
|
encoding: "utf-8",
|
|
7325
7337
|
mode: 384
|
|
7326
7338
|
});
|
|
7327
7339
|
try {
|
|
7328
|
-
chmodSync(
|
|
7340
|
+
chmodSync(path5, 384);
|
|
7329
7341
|
} catch {
|
|
7330
7342
|
}
|
|
7331
7343
|
}
|
|
@@ -7381,8 +7393,8 @@ function readOriginRemote(repoPath) {
|
|
|
7381
7393
|
function listProjectDirs() {
|
|
7382
7394
|
return readConfig().projectDirs ?? [];
|
|
7383
7395
|
}
|
|
7384
|
-
function addProjectDir(
|
|
7385
|
-
const target =
|
|
7396
|
+
function addProjectDir(path5, readOrigin = readOriginRemote) {
|
|
7397
|
+
const target = path5.trim();
|
|
7386
7398
|
if (target.length === 0) {
|
|
7387
7399
|
throw new Error("A project directory path is required.");
|
|
7388
7400
|
}
|
|
@@ -7425,8 +7437,8 @@ async function promptText(question, options = {}) {
|
|
|
7425
7437
|
const rendered = defaultValue !== void 0 ? `${question} [${defaultValue}]: ` : question;
|
|
7426
7438
|
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
7427
7439
|
try {
|
|
7428
|
-
const answer = await new Promise((
|
|
7429
|
-
rl.question(rendered,
|
|
7440
|
+
const answer = await new Promise((resolve7) => {
|
|
7441
|
+
rl.question(rendered, resolve7);
|
|
7430
7442
|
});
|
|
7431
7443
|
const trimmed = answer.trim();
|
|
7432
7444
|
if (trimmed.length === 0 && defaultValue !== void 0) {
|
|
@@ -7438,7 +7450,7 @@ async function promptText(question, options = {}) {
|
|
|
7438
7450
|
}
|
|
7439
7451
|
}
|
|
7440
7452
|
function promptSecret(question) {
|
|
7441
|
-
return new Promise((
|
|
7453
|
+
return new Promise((resolve7) => {
|
|
7442
7454
|
const rl = readline.createInterface({
|
|
7443
7455
|
input: stdin,
|
|
7444
7456
|
output: stdout,
|
|
@@ -7450,7 +7462,7 @@ function promptSecret(question) {
|
|
|
7450
7462
|
rl.question("", (answer) => {
|
|
7451
7463
|
rl.close();
|
|
7452
7464
|
stdout.write("\n");
|
|
7453
|
-
|
|
7465
|
+
resolve7(answer.trim());
|
|
7454
7466
|
});
|
|
7455
7467
|
});
|
|
7456
7468
|
}
|
|
@@ -7672,11 +7684,11 @@ function secretsPath() {
|
|
|
7672
7684
|
}
|
|
7673
7685
|
function readSecretsFile() {
|
|
7674
7686
|
try {
|
|
7675
|
-
const
|
|
7676
|
-
if (!existsSync7(
|
|
7687
|
+
const path5 = secretsPath();
|
|
7688
|
+
if (!existsSync7(path5)) {
|
|
7677
7689
|
return {};
|
|
7678
7690
|
}
|
|
7679
|
-
const parsed = JSON.parse(readFileSync3(
|
|
7691
|
+
const parsed = JSON.parse(readFileSync3(path5, "utf-8"));
|
|
7680
7692
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
7681
7693
|
return parsed;
|
|
7682
7694
|
}
|
|
@@ -7688,14 +7700,14 @@ function readSecretsFile() {
|
|
|
7688
7700
|
function writeSecretsFile(secrets) {
|
|
7689
7701
|
const dir = getConfigDir();
|
|
7690
7702
|
mkdirSync3(dir, { recursive: true });
|
|
7691
|
-
const
|
|
7692
|
-
writeFileSync4(
|
|
7703
|
+
const path5 = secretsPath();
|
|
7704
|
+
writeFileSync4(path5, `${JSON.stringify(secrets, null, 2)}
|
|
7693
7705
|
`, {
|
|
7694
7706
|
encoding: "utf-8",
|
|
7695
7707
|
mode: 384
|
|
7696
7708
|
});
|
|
7697
7709
|
try {
|
|
7698
|
-
chmodSync2(
|
|
7710
|
+
chmodSync2(path5, 384);
|
|
7699
7711
|
} catch {
|
|
7700
7712
|
}
|
|
7701
7713
|
}
|
|
@@ -7741,7 +7753,7 @@ var cached;
|
|
|
7741
7753
|
function resolveCliVersion() {
|
|
7742
7754
|
if (cached !== void 0) return cached;
|
|
7743
7755
|
if (true) {
|
|
7744
|
-
cached = "1.21.
|
|
7756
|
+
cached = "1.21.20";
|
|
7745
7757
|
return cached;
|
|
7746
7758
|
}
|
|
7747
7759
|
const require2 = createRequire(import.meta.url);
|
|
@@ -8303,11 +8315,11 @@ var MailboxClient = class {
|
|
|
8303
8315
|
);
|
|
8304
8316
|
return res.data;
|
|
8305
8317
|
}
|
|
8306
|
-
async send(method,
|
|
8318
|
+
async send(method, path5, machineToken, body, what) {
|
|
8307
8319
|
const config = { headers: { Authorization: `Bearer ${machineToken}` } };
|
|
8308
8320
|
let res;
|
|
8309
8321
|
try {
|
|
8310
|
-
res = method === "get" ? await this.http.get(
|
|
8322
|
+
res = method === "get" ? await this.http.get(path5, config) : await this.http[method](path5, body, config);
|
|
8311
8323
|
} catch (error) {
|
|
8312
8324
|
throw toMailboxError(error, `${what} request failed`);
|
|
8313
8325
|
}
|
|
@@ -8797,10 +8809,10 @@ function buildWellKnownDirs(options = {}) {
|
|
|
8797
8809
|
if (platform === "win32") {
|
|
8798
8810
|
return buildWin32WellKnownDirs(env, options.home);
|
|
8799
8811
|
}
|
|
8800
|
-
const
|
|
8812
|
+
const join26 = (...parts) => posixPath.join(...parts);
|
|
8801
8813
|
const home = options.home ?? homedir5();
|
|
8802
8814
|
const dirs = [
|
|
8803
|
-
|
|
8815
|
+
join26(home, ".local", "bin"),
|
|
8804
8816
|
// default Claude Code install location
|
|
8805
8817
|
"/opt/homebrew/bin",
|
|
8806
8818
|
// Homebrew on Apple Silicon
|
|
@@ -8808,29 +8820,29 @@ function buildWellKnownDirs(options = {}) {
|
|
|
8808
8820
|
// Homebrew on Intel / common Unix prefix
|
|
8809
8821
|
];
|
|
8810
8822
|
if (env.npm_config_prefix) {
|
|
8811
|
-
dirs.push(
|
|
8823
|
+
dirs.push(join26(env.npm_config_prefix, "bin"));
|
|
8812
8824
|
}
|
|
8813
|
-
dirs.push(
|
|
8825
|
+
dirs.push(join26(home, ".npm-global", "bin"));
|
|
8814
8826
|
if (env.PNPM_HOME) {
|
|
8815
8827
|
dirs.push(env.PNPM_HOME);
|
|
8816
8828
|
}
|
|
8817
|
-
dirs.push(
|
|
8818
|
-
dirs.push(
|
|
8829
|
+
dirs.push(join26(home, "Library", "pnpm"));
|
|
8830
|
+
dirs.push(join26(home, ".local", "share", "pnpm"));
|
|
8819
8831
|
return dirs;
|
|
8820
8832
|
}
|
|
8821
8833
|
function buildWin32WellKnownDirs(env, homeOverride) {
|
|
8822
|
-
const
|
|
8834
|
+
const join26 = (...parts) => win32Path.join(...parts);
|
|
8823
8835
|
const dirs = [];
|
|
8824
8836
|
const userProfile = env.USERPROFILE ?? homeOverride;
|
|
8825
8837
|
if (userProfile) {
|
|
8826
|
-
dirs.push(
|
|
8838
|
+
dirs.push(join26(userProfile, ".local", "bin"));
|
|
8827
8839
|
}
|
|
8828
8840
|
if (env.APPDATA) {
|
|
8829
|
-
dirs.push(
|
|
8841
|
+
dirs.push(join26(env.APPDATA, "npm"));
|
|
8830
8842
|
}
|
|
8831
8843
|
if (env.LOCALAPPDATA) {
|
|
8832
|
-
dirs.push(
|
|
8833
|
-
dirs.push(
|
|
8844
|
+
dirs.push(join26(env.LOCALAPPDATA, "Programs", "claude"));
|
|
8845
|
+
dirs.push(join26(env.LOCALAPPDATA, "pnpm"));
|
|
8834
8846
|
}
|
|
8835
8847
|
if (env.npm_config_prefix) {
|
|
8836
8848
|
dirs.push(env.npm_config_prefix);
|
|
@@ -8974,7 +8986,7 @@ function probeAgentRuntime(deps = {}) {
|
|
|
8974
8986
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8975
8987
|
});
|
|
8976
8988
|
}
|
|
8977
|
-
return new Promise((
|
|
8989
|
+
return new Promise((resolve7) => {
|
|
8978
8990
|
let settled = false;
|
|
8979
8991
|
let child;
|
|
8980
8992
|
let stdout2 = "";
|
|
@@ -8989,7 +9001,7 @@ function probeAgentRuntime(deps = {}) {
|
|
|
8989
9001
|
child.kill("SIGKILL");
|
|
8990
9002
|
} catch {
|
|
8991
9003
|
}
|
|
8992
|
-
|
|
9004
|
+
resolve7({ ...result, checkedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
8993
9005
|
};
|
|
8994
9006
|
const timer = setTimeout(() => {
|
|
8995
9007
|
settle({
|
|
@@ -9001,7 +9013,7 @@ function probeAgentRuntime(deps = {}) {
|
|
|
9001
9013
|
child = spawnFn(abs, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
9002
9014
|
} catch (error) {
|
|
9003
9015
|
clearTimeout(timer);
|
|
9004
|
-
|
|
9016
|
+
resolve7({
|
|
9005
9017
|
status: "error",
|
|
9006
9018
|
detail: error instanceof Error ? error.message : "failed to spawn claude",
|
|
9007
9019
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -9048,7 +9060,7 @@ var defaultExec = async (file, args) => {
|
|
|
9048
9060
|
const r = await execFileAsync2(file, args, { windowsHide: true });
|
|
9049
9061
|
return { stdout: r.stdout, stderr: r.stderr };
|
|
9050
9062
|
};
|
|
9051
|
-
var defaultSleep = (ms) => new Promise((
|
|
9063
|
+
var defaultSleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
9052
9064
|
function describeExecError(err) {
|
|
9053
9065
|
const e = err ?? {};
|
|
9054
9066
|
const code = typeof e.code === "number" || typeof e.code === "string" ? e.code : void 0;
|
|
@@ -9164,10 +9176,10 @@ function encodeTaskXml(xml) {
|
|
|
9164
9176
|
}
|
|
9165
9177
|
function writeTaskXmlFile(xml) {
|
|
9166
9178
|
const dir = mkdtempSync2(join9(tmpdir2(), "compbox-task-"));
|
|
9167
|
-
const
|
|
9168
|
-
writeFileSync6(
|
|
9179
|
+
const path5 = join9(dir, "runner-task.xml");
|
|
9180
|
+
writeFileSync6(path5, encodeTaskXml(xml));
|
|
9169
9181
|
return {
|
|
9170
|
-
path:
|
|
9182
|
+
path: path5,
|
|
9171
9183
|
cleanup: () => {
|
|
9172
9184
|
rmSync3(dir, { recursive: true, force: true });
|
|
9173
9185
|
}
|
|
@@ -9427,7 +9439,7 @@ function countFailures(results) {
|
|
|
9427
9439
|
}
|
|
9428
9440
|
var LAUNCH_PROBE_TIMEOUT_MS = 5e3;
|
|
9429
9441
|
function probeLaunchTarget(command, args, timeoutMs = LAUNCH_PROBE_TIMEOUT_MS) {
|
|
9430
|
-
return new Promise((
|
|
9442
|
+
return new Promise((resolve7) => {
|
|
9431
9443
|
let settled = false;
|
|
9432
9444
|
const child = spawn4(command, args, {
|
|
9433
9445
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -9449,7 +9461,7 @@ function probeLaunchTarget(command, args, timeoutMs = LAUNCH_PROBE_TIMEOUT_MS) {
|
|
|
9449
9461
|
child.kill("SIGKILL");
|
|
9450
9462
|
} catch {
|
|
9451
9463
|
}
|
|
9452
|
-
|
|
9464
|
+
resolve7(result);
|
|
9453
9465
|
};
|
|
9454
9466
|
const timer = setTimeout(() => {
|
|
9455
9467
|
settle({ status: "timeout" });
|
|
@@ -9950,16 +9962,16 @@ async function spendLimitCheck(read) {
|
|
|
9950
9962
|
var CLOUD_PREFLIGHT_BUDGET_MS = 6e4;
|
|
9951
9963
|
var GCLOUD_INSTALL_COMMAND = "brew install --cask google-cloud-sdk && gcloud auth login";
|
|
9952
9964
|
var SKIPPED_TIMEOUT = "skipped: could not verify (gcloud took too long)";
|
|
9953
|
-
var defaultPreflightExecFile = (file, args, opts) => new Promise((
|
|
9965
|
+
var defaultPreflightExecFile = (file, args, opts) => new Promise((resolve7) => {
|
|
9954
9966
|
nodeExecFile(file, args, { timeout: Math.max(1, opts.timeoutMs), maxBuffer: 8 * 1024 * 1024, ...opts.env && { env: opts.env } }, (error, stdout2, stderr) => {
|
|
9955
9967
|
if (!error) {
|
|
9956
|
-
|
|
9968
|
+
resolve7({ ok: true, stdout: stdout2 });
|
|
9957
9969
|
return;
|
|
9958
9970
|
}
|
|
9959
9971
|
const err = error;
|
|
9960
|
-
if (err.code === "ENOENT")
|
|
9961
|
-
else if (err.killed || err.signal === "SIGTERM")
|
|
9962
|
-
else
|
|
9972
|
+
if (err.code === "ENOENT") resolve7({ ok: false, reason: "missing", stderr: "" });
|
|
9973
|
+
else if (err.killed || err.signal === "SIGTERM") resolve7({ ok: false, reason: "timeout", stderr });
|
|
9974
|
+
else resolve7({ ok: false, reason: "error", stderr: stderr || err.message });
|
|
9963
9975
|
});
|
|
9964
9976
|
});
|
|
9965
9977
|
function isStringArray2(v) {
|
|
@@ -10303,7 +10315,7 @@ async function finishMergeApproval(approval, merge) {
|
|
|
10303
10315
|
|
|
10304
10316
|
// src/commands/run.ts
|
|
10305
10317
|
import { Command as Command8 } from "commander";
|
|
10306
|
-
import { delimiter } from "node:path";
|
|
10318
|
+
import { delimiter, join as join23 } from "node:path";
|
|
10307
10319
|
import chalk9 from "chalk";
|
|
10308
10320
|
|
|
10309
10321
|
// src/utils/agent-invoker.ts
|
|
@@ -10461,8 +10473,8 @@ function killProcessTree(child, deps = {}) {
|
|
|
10461
10473
|
}
|
|
10462
10474
|
|
|
10463
10475
|
// src/utils/agent-invoker.ts
|
|
10464
|
-
import { randomUUID } from "node:crypto";
|
|
10465
|
-
import { copyFileSync as copyFileSync3, existsSync as existsSync16, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4 } from "node:fs";
|
|
10476
|
+
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
10477
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync16, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, readdirSync as readdirSync4, readFileSync as readFileSync10, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
10466
10478
|
import { mkdir as mkdir2, mkdtemp, realpath, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
10467
10479
|
import { homedir as homedir9, tmpdir as tmpdir4 } from "node:os";
|
|
10468
10480
|
import { join as join18 } from "node:path";
|
|
@@ -10643,12 +10655,12 @@ function sameDir(a, b, platform) {
|
|
|
10643
10655
|
const norm2 = (d) => d.replace(/[\\/]+$/, "").replace(/\//g, "\\").toLowerCase();
|
|
10644
10656
|
return norm2(a) === norm2(b);
|
|
10645
10657
|
}
|
|
10646
|
-
function pathWithout(
|
|
10658
|
+
function pathWithout(path5, exclude, platform = process.platform) {
|
|
10647
10659
|
const delim = delimiterFor(platform);
|
|
10648
|
-
return
|
|
10660
|
+
return path5.split(delim).filter((d) => d && !sameDir(d, exclude, platform)).join(delim);
|
|
10649
10661
|
}
|
|
10650
|
-
function isOnPath(command,
|
|
10651
|
-
for (const dir of
|
|
10662
|
+
function isOnPath(command, path5, platform = process.platform, env = process.env) {
|
|
10663
|
+
for (const dir of path5.split(delimiterFor(platform))) {
|
|
10652
10664
|
if (!dir) continue;
|
|
10653
10665
|
if (platform === "win32") {
|
|
10654
10666
|
if (findWin32Executable(command, dir, env)) return true;
|
|
@@ -10701,8 +10713,8 @@ function ensurePackageManagerShims(opts = {}) {
|
|
|
10701
10713
|
const env = opts.env ?? process.env;
|
|
10702
10714
|
const dir = join11(opts.home ?? homedir8(), ".compbox", "shims");
|
|
10703
10715
|
const searchPath = opts.searchPath ?? ((p) => claudeChildEnvPath(p, { platform, env }));
|
|
10704
|
-
const
|
|
10705
|
-
const missing = Object.keys(STAND_INS).filter((tool) => !isOnPath(tool,
|
|
10716
|
+
const path5 = pathWithout(searchPath(opts.path ?? process.env.PATH), dir, platform);
|
|
10717
|
+
const missing = Object.keys(STAND_INS).filter((tool) => !isOnPath(tool, path5, platform, env));
|
|
10706
10718
|
if (missing.length === 0) return null;
|
|
10707
10719
|
const nodeBinDir = opts.nodeBinDir ?? dirname4(process.execPath);
|
|
10708
10720
|
const win322 = platform === "win32";
|
|
@@ -10864,9 +10876,9 @@ function writeAtomic(file, content, mode) {
|
|
|
10864
10876
|
chmodSync4(tmp, mode);
|
|
10865
10877
|
renameSync(tmp, file);
|
|
10866
10878
|
}
|
|
10867
|
-
function resolveRealGh(
|
|
10879
|
+
function resolveRealGh(path5, platform = process.platform) {
|
|
10868
10880
|
const names = platform === "win32" ? ["gh.exe", "gh.cmd", "gh"] : ["gh"];
|
|
10869
|
-
for (const dir of (
|
|
10881
|
+
for (const dir of (path5 ?? "").split(platform === "win32" ? ";" : ":")) {
|
|
10870
10882
|
if (!dir) continue;
|
|
10871
10883
|
for (const name of names) {
|
|
10872
10884
|
if (isOnPath(name, dir)) return join12(dir, name);
|
|
@@ -10887,16 +10899,16 @@ function ensureMergeGuardShims(binDir, realGhPath, platform = process.platform,
|
|
|
10887
10899
|
return null;
|
|
10888
10900
|
}
|
|
10889
10901
|
}
|
|
10890
|
-
function withMergeGuardPath(
|
|
10891
|
-
if (!binDir) return
|
|
10892
|
-
const realGh = resolveRealGh(
|
|
10893
|
-
if (!realGh) return
|
|
10902
|
+
function withMergeGuardPath(path5, binDir, platform = process.platform, ghDeny = []) {
|
|
10903
|
+
if (!binDir) return path5;
|
|
10904
|
+
const realGh = resolveRealGh(path5, platform);
|
|
10905
|
+
if (!realGh) return path5;
|
|
10894
10906
|
const rules = [...new Set(ghDeny.map((d) => d.trim()))].sort();
|
|
10895
10907
|
const shimDir = rules.length > 0 ? join12(binDir, `declared-${createHash("sha256").update(rules.join("\n")).digest("hex").slice(0, 12)}`) : binDir;
|
|
10896
10908
|
const dir = ensureMergeGuardShims(shimDir, realGh, platform, rules);
|
|
10897
|
-
if (!dir) return
|
|
10909
|
+
if (!dir) return path5;
|
|
10898
10910
|
const sep2 = platform === "win32" ? ";" : ":";
|
|
10899
|
-
return
|
|
10911
|
+
return path5 ? `${dir}${sep2}${path5}` : dir;
|
|
10900
10912
|
}
|
|
10901
10913
|
function prePushHookScript(baseBranch, origHooksDir, extraProtected = []) {
|
|
10902
10914
|
const extra = extraProtected.filter((b) => /^[A-Za-z0-9._/-]+$/.test(b) && !b.includes(".."));
|
|
@@ -11548,8 +11560,8 @@ var LOCKFILES = [
|
|
|
11548
11560
|
];
|
|
11549
11561
|
function detectLockfile(dir, exists) {
|
|
11550
11562
|
for (const [file, pm] of LOCKFILES) {
|
|
11551
|
-
const
|
|
11552
|
-
if (exists(
|
|
11563
|
+
const path5 = join14(dir, file);
|
|
11564
|
+
if (exists(path5)) return { lockfile: path5, pm };
|
|
11553
11565
|
}
|
|
11554
11566
|
return null;
|
|
11555
11567
|
}
|
|
@@ -11668,7 +11680,7 @@ function orphanMarkers(entries) {
|
|
|
11668
11680
|
var RUN_PUSH_ENV = "COMPBOX_RUN_PUSH";
|
|
11669
11681
|
var INSTALL_TIMEOUT_MS = 20 * 60 * 1e3;
|
|
11670
11682
|
var GIT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
11671
|
-
var defaultCommandRunner = (command, args, cwd) => new Promise((
|
|
11683
|
+
var defaultCommandRunner = (command, args, cwd) => new Promise((resolve7) => {
|
|
11672
11684
|
let stdout2 = "";
|
|
11673
11685
|
let stderr = "";
|
|
11674
11686
|
let settled = false;
|
|
@@ -11676,7 +11688,7 @@ var defaultCommandRunner = (command, args, cwd) => new Promise((resolve6) => {
|
|
|
11676
11688
|
if (settled) return;
|
|
11677
11689
|
settled = true;
|
|
11678
11690
|
clearTimeout(timer);
|
|
11679
|
-
|
|
11691
|
+
resolve7(result);
|
|
11680
11692
|
};
|
|
11681
11693
|
const child = spawn5(command, args, {
|
|
11682
11694
|
cwd,
|
|
@@ -11711,10 +11723,10 @@ function withIsolatedGcloud(env, dir) {
|
|
|
11711
11723
|
return { ...env, CLOUDSDK_CONFIG: gcloudConfigDir(dir) };
|
|
11712
11724
|
}
|
|
11713
11725
|
function createGcloudConfigDir(dir) {
|
|
11714
|
-
const
|
|
11715
|
-
mkdirSync8(
|
|
11716
|
-
writeFileSync10(join15(
|
|
11717
|
-
return
|
|
11726
|
+
const path5 = gcloudConfigDir(dir);
|
|
11727
|
+
mkdirSync8(path5, { recursive: true, mode: 448 });
|
|
11728
|
+
writeFileSync10(join15(path5, ".gitignore"), "*\n");
|
|
11729
|
+
return path5;
|
|
11718
11730
|
}
|
|
11719
11731
|
function removeGcloudConfigDir(dir) {
|
|
11720
11732
|
try {
|
|
@@ -11739,10 +11751,10 @@ function waitingPrBodyBlock(request) {
|
|
|
11739
11751
|
fence
|
|
11740
11752
|
].join("\n");
|
|
11741
11753
|
}
|
|
11742
|
-
function isLocalConfigFile(
|
|
11743
|
-
if (
|
|
11744
|
-
const name = basename3(
|
|
11745
|
-
return name === ".mcp.json" || name === "CLAUDE.local.md" ||
|
|
11754
|
+
function isLocalConfigFile(path5) {
|
|
11755
|
+
if (path5.split("/").includes("node_modules")) return false;
|
|
11756
|
+
const name = basename3(path5);
|
|
11757
|
+
return name === ".mcp.json" || name === "CLAUDE.local.md" || path5 === ".claude/settings.local.json";
|
|
11746
11758
|
}
|
|
11747
11759
|
function slugForBranch(value) {
|
|
11748
11760
|
return value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "run";
|
|
@@ -11751,11 +11763,11 @@ function stamp(now) {
|
|
|
11751
11763
|
const pad = (n) => String(n).padStart(2, "0");
|
|
11752
11764
|
return `${String(now.getFullYear())}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
11753
11765
|
}
|
|
11754
|
-
function realpathOr(
|
|
11766
|
+
function realpathOr(path5) {
|
|
11755
11767
|
try {
|
|
11756
|
-
return realpathSync3(
|
|
11768
|
+
return realpathSync3(path5);
|
|
11757
11769
|
} catch {
|
|
11758
|
-
return
|
|
11770
|
+
return path5;
|
|
11759
11771
|
}
|
|
11760
11772
|
}
|
|
11761
11773
|
function keptForReplyNote(ws) {
|
|
@@ -11820,18 +11832,18 @@ var RunWorkspaceManager = class {
|
|
|
11820
11832
|
this.storesRoot = deps.storesRoot ?? join15(dirname5(this.runsRoot), "stores");
|
|
11821
11833
|
this.retentionMs = deps.retentionMs;
|
|
11822
11834
|
this.activeRunDirs = deps.activeRunDirs;
|
|
11823
|
-
this.mtimeMs = deps.mtimeMs ?? ((
|
|
11835
|
+
this.mtimeMs = deps.mtimeMs ?? ((path5) => {
|
|
11824
11836
|
try {
|
|
11825
|
-
return statSync4(
|
|
11837
|
+
return statSync4(path5).mtimeMs;
|
|
11826
11838
|
} catch {
|
|
11827
11839
|
return null;
|
|
11828
11840
|
}
|
|
11829
11841
|
});
|
|
11830
11842
|
this.isPidAlive = deps.isPidAlive ?? pidAlive;
|
|
11831
11843
|
this.pid = deps.pid ?? process.pid;
|
|
11832
|
-
this.readFile = deps.readFile ?? ((
|
|
11844
|
+
this.readFile = deps.readFile ?? ((path5) => {
|
|
11833
11845
|
try {
|
|
11834
|
-
return readFileSync7(
|
|
11846
|
+
return readFileSync7(path5);
|
|
11835
11847
|
} catch {
|
|
11836
11848
|
return null;
|
|
11837
11849
|
}
|
|
@@ -11864,15 +11876,15 @@ var RunWorkspaceManager = class {
|
|
|
11864
11876
|
}
|
|
11865
11877
|
/** Whether a `.active` marker still protects this folder from pruning. */
|
|
11866
11878
|
activeByMarker(dir) {
|
|
11867
|
-
const
|
|
11879
|
+
const path5 = activeMarkerPath(dir);
|
|
11868
11880
|
let text = null;
|
|
11869
11881
|
try {
|
|
11870
|
-
text = readFileSync7(
|
|
11882
|
+
text = readFileSync7(path5, "utf-8");
|
|
11871
11883
|
} catch {
|
|
11872
11884
|
text = null;
|
|
11873
11885
|
}
|
|
11874
|
-
const exists = text !== null || this.exists(
|
|
11875
|
-
const touched = Math.max(this.mtimeMs(
|
|
11886
|
+
const exists = text !== null || this.exists(path5);
|
|
11887
|
+
const touched = Math.max(this.mtimeMs(path5) ?? 0, this.mtimeMs(dir) ?? 0);
|
|
11876
11888
|
return activeMarkerProtects({
|
|
11877
11889
|
exists,
|
|
11878
11890
|
marker: parseActiveMarker(text),
|
|
@@ -12284,12 +12296,12 @@ var RunWorkspaceManager = class {
|
|
|
12284
12296
|
`${ignored.stdout}
|
|
12285
12297
|
${untracked.stdout}`.split("\n").map((p) => p.trim()).filter((p) => p && !p.endsWith("/"))
|
|
12286
12298
|
);
|
|
12287
|
-
for (const
|
|
12288
|
-
if (!isLocalConfigFile(
|
|
12299
|
+
for (const path5 of candidates) {
|
|
12300
|
+
if (!isLocalConfigFile(path5)) continue;
|
|
12289
12301
|
try {
|
|
12290
|
-
this.copyFile(join15(projectDir,
|
|
12302
|
+
this.copyFile(join15(projectDir, path5), join15(dir, path5));
|
|
12291
12303
|
} catch {
|
|
12292
|
-
notes.push(`Couldn't copy ${
|
|
12304
|
+
notes.push(`Couldn't copy ${path5} into the run workspace.`);
|
|
12293
12305
|
}
|
|
12294
12306
|
}
|
|
12295
12307
|
return {
|
|
@@ -12309,10 +12321,10 @@ ${untracked.stdout}`.split("\n").map((p) => p.trim()).filter((p) => p && !p.ends
|
|
|
12309
12321
|
const list = await this.git(["worktree", "list", "--porcelain"], projectDir);
|
|
12310
12322
|
if (list.status !== 0) return true;
|
|
12311
12323
|
const holders = [];
|
|
12312
|
-
let
|
|
12324
|
+
let path5 = null;
|
|
12313
12325
|
for (const line of list.stdout.split("\n")) {
|
|
12314
|
-
if (line.startsWith("worktree "))
|
|
12315
|
-
else if (line.trim() === `branch refs/heads/${branch}` &&
|
|
12326
|
+
if (line.startsWith("worktree ")) path5 = line.slice("worktree ".length).trim();
|
|
12327
|
+
else if (line.trim() === `branch refs/heads/${branch}` && path5) holders.push(path5);
|
|
12316
12328
|
}
|
|
12317
12329
|
const roots = [this.runsRoot, realpathOr(this.runsRoot)];
|
|
12318
12330
|
const kept = holders.filter((dir) => roots.some((root) => dir.startsWith(`${root}/`)));
|
|
@@ -12799,8 +12811,8 @@ var CHECKS_CONFIG_FILE = join16(".compbox", "checks.json");
|
|
|
12799
12811
|
var DEFAULT_CHECK_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
12800
12812
|
var OUTPUT_TAIL_LINES = 40;
|
|
12801
12813
|
var OUTPUT_TAIL_CHARS = 4e3;
|
|
12802
|
-
function readJson(
|
|
12803
|
-
return JSON.parse(readFileSync8(
|
|
12814
|
+
function readJson(path5) {
|
|
12815
|
+
return JSON.parse(readFileSync8(path5, "utf-8"));
|
|
12804
12816
|
}
|
|
12805
12817
|
function isRecord2(value) {
|
|
12806
12818
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12947,14 +12959,14 @@ function outputTail(output, lines = OUTPUT_TAIL_LINES) {
|
|
|
12947
12959
|
function createCheckRunner(deps = {}) {
|
|
12948
12960
|
const platform = deps.platform ?? process.platform;
|
|
12949
12961
|
const killDeps = { ...deps.processGroup, platform };
|
|
12950
|
-
return (command, args, cwd, timeoutMs) => new Promise((
|
|
12962
|
+
return (command, args, cwd, timeoutMs) => new Promise((resolve7) => {
|
|
12951
12963
|
let output = "";
|
|
12952
12964
|
let settled = false;
|
|
12953
12965
|
const done = (result) => {
|
|
12954
12966
|
if (settled) return;
|
|
12955
12967
|
settled = true;
|
|
12956
12968
|
clearTimeout(timer);
|
|
12957
|
-
|
|
12969
|
+
resolve7(result);
|
|
12958
12970
|
};
|
|
12959
12971
|
const child = spawnCrossPlatform(
|
|
12960
12972
|
command,
|
|
@@ -13031,9 +13043,9 @@ function checkGroup(check) {
|
|
|
13031
13043
|
function parseNameStatus(output) {
|
|
13032
13044
|
const files = [];
|
|
13033
13045
|
for (const line of output.split("\n")) {
|
|
13034
|
-
const [status,
|
|
13035
|
-
if (!status || !
|
|
13036
|
-
files.push({ status: status.trim(), path:
|
|
13046
|
+
const [status, path5] = line.split(" ");
|
|
13047
|
+
if (!status || !path5) continue;
|
|
13048
|
+
files.push({ status: status.trim(), path: path5.trim() });
|
|
13037
13049
|
}
|
|
13038
13050
|
return files;
|
|
13039
13051
|
}
|
|
@@ -13066,8 +13078,8 @@ async function compareWithBase(input, deps) {
|
|
|
13066
13078
|
const now = deps.now ?? Date.now;
|
|
13067
13079
|
const budgetMs = deps.budgetMs ?? BASE_COMPARE_BUDGET_MS;
|
|
13068
13080
|
const exists = deps.exists ?? existsSync15;
|
|
13069
|
-
const removeDir = deps.removeDir ?? ((
|
|
13070
|
-
rmSync5(
|
|
13081
|
+
const removeDir = deps.removeDir ?? ((path5) => {
|
|
13082
|
+
rmSync5(path5, { recursive: true, force: true });
|
|
13071
13083
|
});
|
|
13072
13084
|
const copyFile = deps.copyFile ?? ((from, to) => {
|
|
13073
13085
|
mkdirSync9(dirname6(to), { recursive: true });
|
|
@@ -13107,9 +13119,9 @@ async function compareWithBase(input, deps) {
|
|
|
13107
13119
|
`${ignored.status === 0 ? ignored.stdout : ""}
|
|
13108
13120
|
${untracked.status === 0 ? untracked.stdout : ""}`.split("\n").map((p) => p.trim()).filter((p) => p && !p.endsWith("/") && isLocalConfigFile(p))
|
|
13109
13121
|
);
|
|
13110
|
-
for (const
|
|
13122
|
+
for (const path5 of candidates) {
|
|
13111
13123
|
try {
|
|
13112
|
-
copyFile(join17(input.dir,
|
|
13124
|
+
copyFile(join17(input.dir, path5), join17(baseDir, path5));
|
|
13113
13125
|
} catch {
|
|
13114
13126
|
}
|
|
13115
13127
|
}
|
|
@@ -13302,7 +13314,7 @@ function createWrapUp(deps) {
|
|
|
13302
13314
|
const runChecks = deps.runChecks ?? defaultRunChecks;
|
|
13303
13315
|
const retryChecks = deps.retryChecks ?? (deps.runChecks ? void 0 : defaultRetryChecks);
|
|
13304
13316
|
const compare = deps.compareWithBase ?? (deps.runChecks ? void 0 : (i) => compareWithBase(i, { run: deps.run }));
|
|
13305
|
-
const readFile4 = deps.readFile ?? ((
|
|
13317
|
+
const readFile4 = deps.readFile ?? ((path5) => readFileSync9(path5, "utf-8"));
|
|
13306
13318
|
const wrapUp = async (input) => {
|
|
13307
13319
|
const reasons = [];
|
|
13308
13320
|
const failures = [];
|
|
@@ -13778,13 +13790,13 @@ async function materializeAttachments(dir, attachments, fetchImpl = fetch, warn
|
|
|
13778
13790
|
if (fetched.length > 0) await mkdir2(dir, { recursive: true });
|
|
13779
13791
|
for (const f of fetched) {
|
|
13780
13792
|
const mimeType = baseMime(f.attachment.mimeType);
|
|
13781
|
-
const
|
|
13793
|
+
const path5 = join18(
|
|
13782
13794
|
dir,
|
|
13783
13795
|
`attachment-${String(files.length + 1)}.${EXTENSION_BY_MIME[mimeType] ?? "bin"}`
|
|
13784
13796
|
);
|
|
13785
13797
|
try {
|
|
13786
|
-
await writeFile2(
|
|
13787
|
-
files.push({ path:
|
|
13798
|
+
await writeFile2(path5, f.bytes);
|
|
13799
|
+
files.push({ path: path5, mimeType });
|
|
13788
13800
|
} catch (error) {
|
|
13789
13801
|
const message = error instanceof Error ? error.message : "unknown error";
|
|
13790
13802
|
warn(`Skipping attachment ${f.attachment.id}: could not save it (${message}).`);
|
|
@@ -13870,7 +13882,7 @@ function rejectsPartialMessagesFlag(stderr) {
|
|
|
13870
13882
|
return stderr.includes("--include-partial-messages") && /unknown|unrecognized|invalid|unexpected|not supported/i.test(stderr);
|
|
13871
13883
|
}
|
|
13872
13884
|
function runClaudeCliTurn(prompt, opts) {
|
|
13873
|
-
return new Promise((
|
|
13885
|
+
return new Promise((resolve7, reject) => {
|
|
13874
13886
|
const model = opts.model === void 0 ? ANTHROPIC_MODEL : opts.model;
|
|
13875
13887
|
const onText = opts.onText;
|
|
13876
13888
|
const streaming = typeof onText === "function";
|
|
@@ -13979,7 +13991,7 @@ function runClaudeCliTurn(prompt, opts) {
|
|
|
13979
13991
|
);
|
|
13980
13992
|
return;
|
|
13981
13993
|
}
|
|
13982
|
-
|
|
13994
|
+
resolve7({ text: result.text, sessionId: result.sessionId });
|
|
13983
13995
|
return;
|
|
13984
13996
|
}
|
|
13985
13997
|
settled = true;
|
|
@@ -14008,7 +14020,7 @@ function runClaudeCliTurn(prompt, opts) {
|
|
|
14008
14020
|
);
|
|
14009
14021
|
return;
|
|
14010
14022
|
}
|
|
14011
|
-
|
|
14023
|
+
resolve7({ text: shaped.result, sessionId: shaped.session_id });
|
|
14012
14024
|
});
|
|
14013
14025
|
};
|
|
14014
14026
|
attempt(streaming);
|
|
@@ -14264,6 +14276,128 @@ function parsePlanningStage(value) {
|
|
|
14264
14276
|
function parseUuid(value) {
|
|
14265
14277
|
return typeof value === "string" && UUID_RE.test(value) ? value : void 0;
|
|
14266
14278
|
}
|
|
14279
|
+
function parseAgentFile(content) {
|
|
14280
|
+
const text = content.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
|
|
14281
|
+
const fields = {};
|
|
14282
|
+
if (!text.startsWith("---\n")) return { fields, body: text.trim() };
|
|
14283
|
+
const end = text.indexOf("\n---", 4);
|
|
14284
|
+
if (end === -1) return { fields, body: text.trim() };
|
|
14285
|
+
const afterFence = text.indexOf("\n", end + 4);
|
|
14286
|
+
const body = afterFence === -1 ? "" : text.slice(afterFence + 1);
|
|
14287
|
+
let key = null;
|
|
14288
|
+
for (const line of text.slice(4, end).split("\n")) {
|
|
14289
|
+
const m = /^([A-Za-z_][\w-]*):\s*(.*)$/.exec(line);
|
|
14290
|
+
if (m && !/^\s/.test(line)) {
|
|
14291
|
+
key = m[1] ?? null;
|
|
14292
|
+
if (key) fields[key] = (m[2] ?? "").trim();
|
|
14293
|
+
} else if (key && line.trim() !== "") {
|
|
14294
|
+
fields[key] = `${fields[key] ?? ""} ${line.trim()}`.trim();
|
|
14295
|
+
}
|
|
14296
|
+
}
|
|
14297
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
14298
|
+
const q = /^"(.*)"$/s.exec(v) ?? /^'(.*)'$/s.exec(v);
|
|
14299
|
+
fields[k] = q?.[1] ?? v;
|
|
14300
|
+
}
|
|
14301
|
+
return { fields, body: body.trim() };
|
|
14302
|
+
}
|
|
14303
|
+
function parseToolsField(value) {
|
|
14304
|
+
if (!value) return void 0;
|
|
14305
|
+
const tools = value.replace(/^\[|\]$/g, "").split(/[,\s]+/).map((t) => t.replace(/^["']|["']$/g, "").trim()).filter(Boolean);
|
|
14306
|
+
return tools.length > 0 ? tools : void 0;
|
|
14307
|
+
}
|
|
14308
|
+
function buildAgentDefinitionArgs(agentDir, mainAgent, existingSystemPrompt, opts = {}) {
|
|
14309
|
+
const mainPath = join18(agentDir, `${mainAgent}.md`);
|
|
14310
|
+
if (!existsSync16(mainPath)) {
|
|
14311
|
+
throw new Error(`The ${mainAgent} agent file is missing from the agent set (${mainPath}).`);
|
|
14312
|
+
}
|
|
14313
|
+
const main = parseAgentFile(readFileSync10(mainPath, "utf8"));
|
|
14314
|
+
const systemPrompt = [main.body, existingSystemPrompt?.trim()].filter((s) => Boolean(s)).join("\n\n");
|
|
14315
|
+
const agents = {};
|
|
14316
|
+
const addFrom = (dir) => {
|
|
14317
|
+
if (!existsSync16(dir)) return;
|
|
14318
|
+
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
14319
|
+
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
14320
|
+
const name = entry.name.slice(0, -".md".length);
|
|
14321
|
+
if (dir === agentDir && name === mainAgent) continue;
|
|
14322
|
+
const parsed = parseAgentFile(readFileSync10(join18(dir, entry.name), "utf8"));
|
|
14323
|
+
if (!parsed.body) continue;
|
|
14324
|
+
const tools = parseToolsField(parsed.fields.tools);
|
|
14325
|
+
agents[name] = {
|
|
14326
|
+
description: [parsed.fields.description, parsed.fields.name].find(Boolean) ?? name,
|
|
14327
|
+
prompt: parsed.body,
|
|
14328
|
+
...tools && { tools },
|
|
14329
|
+
...parsed.fields.model && { model: parsed.fields.model }
|
|
14330
|
+
};
|
|
14331
|
+
}
|
|
14332
|
+
};
|
|
14333
|
+
addFrom(agentDir);
|
|
14334
|
+
addFrom(join18(agentDir, "internal"));
|
|
14335
|
+
const spill = opts.spillDir ?? join18(tmpdir4(), "compbox-agent-args");
|
|
14336
|
+
const max = opts.maxInlineChars ?? AGENT_ARG_MAX_INLINE_CHARS;
|
|
14337
|
+
const out = [];
|
|
14338
|
+
if (systemPrompt) {
|
|
14339
|
+
out.push(
|
|
14340
|
+
...systemPrompt.length > max ? ["--append-system-prompt-file", spillAgentArg(spill, systemPrompt, "md")] : ["--append-system-prompt", systemPrompt]
|
|
14341
|
+
);
|
|
14342
|
+
}
|
|
14343
|
+
if (Object.keys(agents).length > 0) {
|
|
14344
|
+
const json = JSON.stringify(agents);
|
|
14345
|
+
out.push("--agents", json.length > max ? spillAgentArg(spill, json, "json") : json);
|
|
14346
|
+
}
|
|
14347
|
+
return out;
|
|
14348
|
+
}
|
|
14349
|
+
var AGENT_ARG_MAX_INLINE_CHARS = 24e3;
|
|
14350
|
+
function spillAgentArg(dir, content, ext) {
|
|
14351
|
+
mkdirSync10(dir, { recursive: true, mode: 448 });
|
|
14352
|
+
const hash = createHash3("sha256").update(content).digest("hex").slice(0, 32);
|
|
14353
|
+
const file = join18(dir, `${hash}.${ext}`);
|
|
14354
|
+
if (!existsSync16(file)) {
|
|
14355
|
+
const tmp = `${file}.${String(process.pid)}.${randomUUID()}.tmp`;
|
|
14356
|
+
writeFileSync11(tmp, content, { mode: 384 });
|
|
14357
|
+
renameSync2(tmp, file);
|
|
14358
|
+
}
|
|
14359
|
+
return file;
|
|
14360
|
+
}
|
|
14361
|
+
function withAgentDefinitions(args, agentDir, mainAgent, opts = {}) {
|
|
14362
|
+
if (!agentDir) return args;
|
|
14363
|
+
const kept = [];
|
|
14364
|
+
const existing = [];
|
|
14365
|
+
let takeNext = false;
|
|
14366
|
+
for (const [i, a] of args.entries()) {
|
|
14367
|
+
if (takeNext) {
|
|
14368
|
+
existing.push(a);
|
|
14369
|
+
takeNext = false;
|
|
14370
|
+
} else if (a === "--append-system-prompt" && i + 1 < args.length) {
|
|
14371
|
+
takeNext = true;
|
|
14372
|
+
} else {
|
|
14373
|
+
kept.push(a);
|
|
14374
|
+
}
|
|
14375
|
+
}
|
|
14376
|
+
return [
|
|
14377
|
+
...kept,
|
|
14378
|
+
...buildAgentDefinitionArgs(agentDir, mainAgent, existing.join("\n\n") || void 0, opts)
|
|
14379
|
+
];
|
|
14380
|
+
}
|
|
14381
|
+
function missingAgentDefinitionMessage(agentDir, mainAgent, source) {
|
|
14382
|
+
if (!agentDir) return null;
|
|
14383
|
+
const rel = `${mainAgent}.md`;
|
|
14384
|
+
const where = source ? ` (agent set source: ${source})` : "";
|
|
14385
|
+
const fix = "Reinstall the CompBox CLI, or reconnect so the agent set can be downloaded again.";
|
|
14386
|
+
const mainPath = join18(agentDir, rel);
|
|
14387
|
+
if (!existsSync16(mainPath)) {
|
|
14388
|
+
return `Built-in agent definition missing: ${rel}${where}. Expected it at ${mainPath}. ${fix}`;
|
|
14389
|
+
}
|
|
14390
|
+
let body;
|
|
14391
|
+
try {
|
|
14392
|
+
body = parseAgentFile(readFileSync10(mainPath, "utf8")).body;
|
|
14393
|
+
} catch (error) {
|
|
14394
|
+
return `Built-in agent definition unreadable: ${rel}${where}: ${error instanceof Error ? error.message : String(error)}. ${fix}`;
|
|
14395
|
+
}
|
|
14396
|
+
if (!body.trim()) {
|
|
14397
|
+
return `Built-in agent definition is empty: ${rel}${where}. ${fix}`;
|
|
14398
|
+
}
|
|
14399
|
+
return null;
|
|
14400
|
+
}
|
|
14267
14401
|
function buildPlannerArgs(epicRequestId, resume = {}) {
|
|
14268
14402
|
const stage = parsePlanningStage(resume.resumeFromStage);
|
|
14269
14403
|
const epicId = parseUuid(resume.epicId);
|
|
@@ -14456,6 +14590,31 @@ function plannerOutputTail(text, max = 300) {
|
|
|
14456
14590
|
if (!trimmed) return "";
|
|
14457
14591
|
return trimmed.length > max ? `\u2026${trimmed.slice(-max)}` : trimmed;
|
|
14458
14592
|
}
|
|
14593
|
+
var PLANNER_STDERR_TAIL_MAX = 4096;
|
|
14594
|
+
function appendBoundedTail(buf, chunk, max = PLANNER_STDERR_TAIL_MAX) {
|
|
14595
|
+
const next = buf + chunk;
|
|
14596
|
+
return next.length > max ? next.slice(-max) : next;
|
|
14597
|
+
}
|
|
14598
|
+
function describePlannerNoEpic(opts) {
|
|
14599
|
+
const exit = opts.signal ? `stopped by ${opts.signal}` : `exit code ${String(opts.code ?? "null")}`;
|
|
14600
|
+
const secs = Math.max(0, Math.round(opts.elapsedMs / 1e3));
|
|
14601
|
+
const parts = [
|
|
14602
|
+
`The planner finished but no epic was produced (${exit}, after ${String(secs)}s).`
|
|
14603
|
+
];
|
|
14604
|
+
if (!opts.reportedStage) {
|
|
14605
|
+
parts.push(
|
|
14606
|
+
"The planner never reported a planning stage \u2014 Claude probably did not load the planner agent."
|
|
14607
|
+
);
|
|
14608
|
+
} else {
|
|
14609
|
+
parts.push(`Last reported stage: ${opts.reportedStage}.`);
|
|
14610
|
+
}
|
|
14611
|
+
const err = plannerOutputTail(opts.stderr);
|
|
14612
|
+
if (err) parts.push(`stderr: ${err}`);
|
|
14613
|
+
const head = opts.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean).slice(0, 20).join(" | ");
|
|
14614
|
+
if (head) parts.push(`stdout: ${head.length > 300 ? `${head.slice(0, 300)}\u2026` : head}`);
|
|
14615
|
+
parts.push("It may need human review.");
|
|
14616
|
+
return parts.join(" ");
|
|
14617
|
+
}
|
|
14459
14618
|
function summarizeComplianceScore(raw) {
|
|
14460
14619
|
let score = raw;
|
|
14461
14620
|
if (typeof score === "string") {
|
|
@@ -14527,11 +14686,20 @@ async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
14527
14686
|
if (!isGitRepo(ctx.projectDir)) {
|
|
14528
14687
|
return { status: "failed", result: { error: projectDirNotGitRepoMessage(ctx.projectDir) } };
|
|
14529
14688
|
}
|
|
14689
|
+
const missingPlanner = missingAgentDefinitionMessage(deps.agentDir, "planner", deps.agentSource);
|
|
14690
|
+
if (missingPlanner) {
|
|
14691
|
+
return { status: "failed", result: { error: missingPlanner } };
|
|
14692
|
+
}
|
|
14530
14693
|
const routing = await resolveRoutingImpl();
|
|
14531
14694
|
const keyRunStartedAtMs = Date.now();
|
|
14532
14695
|
const command = resolveClaudeBinary() ?? "claude";
|
|
14696
|
+
const plannerArgs = withAgentDefinitions(
|
|
14697
|
+
buildPlannerArgs(ctx.epicRequestId, ctx),
|
|
14698
|
+
deps.agentDir,
|
|
14699
|
+
"planner"
|
|
14700
|
+
);
|
|
14533
14701
|
const args = applyAgentPermissions(
|
|
14534
|
-
ctx.keyRun ? keyRunArgs(
|
|
14702
|
+
ctx.keyRun ? keyRunArgs(plannerArgs) : plannerArgs,
|
|
14535
14703
|
permissionsFor(deps.agentPermissions, "planner")
|
|
14536
14704
|
);
|
|
14537
14705
|
const routedEnv = claudeSpawnEnv(process.env, routing);
|
|
@@ -14553,7 +14721,7 @@ async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
14553
14721
|
} catch {
|
|
14554
14722
|
}
|
|
14555
14723
|
let planningFailure = null;
|
|
14556
|
-
const outcome = await new Promise((
|
|
14724
|
+
const outcome = await new Promise((resolve7) => {
|
|
14557
14725
|
let stdout2 = "";
|
|
14558
14726
|
let stderr = "";
|
|
14559
14727
|
let settled = false;
|
|
@@ -14595,7 +14763,7 @@ async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
14595
14763
|
if (heartbeatTimer) clearInterval(heartbeatTimer);
|
|
14596
14764
|
clearTimeout(timer);
|
|
14597
14765
|
disposeAbort();
|
|
14598
|
-
|
|
14766
|
+
resolve7(result);
|
|
14599
14767
|
};
|
|
14600
14768
|
const timer = setTimeout(() => {
|
|
14601
14769
|
killProcessGroupNow(child, deps.processGroup);
|
|
@@ -14615,7 +14783,7 @@ async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
14615
14783
|
stdout2 += chunk.toString("utf-8");
|
|
14616
14784
|
});
|
|
14617
14785
|
child.stderr.on("data", (chunk) => {
|
|
14618
|
-
stderr
|
|
14786
|
+
stderr = appendBoundedTail(stderr, chunk.toString("utf-8"));
|
|
14619
14787
|
});
|
|
14620
14788
|
child.on("error", (error) => {
|
|
14621
14789
|
if (cancelled) {
|
|
@@ -14683,9 +14851,17 @@ ${stderr}`;
|
|
|
14683
14851
|
ctx.epicRequestId,
|
|
14684
14852
|
fetchImpl
|
|
14685
14853
|
);
|
|
14854
|
+
const noEpicReason = describePlannerNoEpic({
|
|
14855
|
+
code,
|
|
14856
|
+
signal: exitSignal ?? null,
|
|
14857
|
+
elapsedMs: Date.now() - keyRunStartedAtMs,
|
|
14858
|
+
stdout: stdout2,
|
|
14859
|
+
stderr,
|
|
14860
|
+
reportedStage: lastStage
|
|
14861
|
+
});
|
|
14686
14862
|
if (!settled && lastStage !== "VERIFY") {
|
|
14687
14863
|
planningFailure = {
|
|
14688
|
-
reason:
|
|
14864
|
+
reason: noEpicReason,
|
|
14689
14865
|
stage: lastStage ?? "ANALYZE"
|
|
14690
14866
|
};
|
|
14691
14867
|
}
|
|
@@ -14694,7 +14870,7 @@ ${stderr}`;
|
|
|
14694
14870
|
result: {
|
|
14695
14871
|
needsHumanReview: true,
|
|
14696
14872
|
stage: "VERIFY",
|
|
14697
|
-
error:
|
|
14873
|
+
error: noEpicReason
|
|
14698
14874
|
}
|
|
14699
14875
|
});
|
|
14700
14876
|
return;
|
|
@@ -14791,11 +14967,16 @@ async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
14791
14967
|
if (!isGitRepo(ctx.projectDir)) {
|
|
14792
14968
|
return { status: "failed", result: { error: projectDirNotGitRepoMessage(ctx.projectDir) } };
|
|
14793
14969
|
}
|
|
14970
|
+
const missingPlanner = missingAgentDefinitionMessage(deps.agentDir, "planner", deps.agentSource);
|
|
14971
|
+
if (missingPlanner) {
|
|
14972
|
+
return { status: "failed", result: { error: missingPlanner } };
|
|
14973
|
+
}
|
|
14794
14974
|
const routing = await resolveRoutingImpl();
|
|
14795
14975
|
const keyRunStartedAtMs = Date.now();
|
|
14796
14976
|
const command = resolveClaudeBinary() ?? "claude";
|
|
14977
|
+
const refineArgs = withAgentDefinitions(buildRefineArgs(ctx.epicId), deps.agentDir, "planner");
|
|
14797
14978
|
const args = applyAgentPermissions(
|
|
14798
|
-
ctx.keyRun ? keyRunArgs(
|
|
14979
|
+
ctx.keyRun ? keyRunArgs(refineArgs) : refineArgs,
|
|
14799
14980
|
permissionsFor(deps.agentPermissions, "planner")
|
|
14800
14981
|
);
|
|
14801
14982
|
const baseEnv = buildRefineEnv(claudeSpawnEnv(process.env, routing), ctx.notes);
|
|
@@ -14808,7 +14989,7 @@ async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
14808
14989
|
);
|
|
14809
14990
|
} catch {
|
|
14810
14991
|
}
|
|
14811
|
-
const outcome = await new Promise((
|
|
14992
|
+
const outcome = await new Promise((resolve7) => {
|
|
14812
14993
|
let stdout2 = "";
|
|
14813
14994
|
let stderr = "";
|
|
14814
14995
|
let settled = false;
|
|
@@ -14850,7 +15031,7 @@ async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
14850
15031
|
if (heartbeatTimer) clearInterval(heartbeatTimer);
|
|
14851
15032
|
clearTimeout(timer);
|
|
14852
15033
|
disposeAbort();
|
|
14853
|
-
|
|
15034
|
+
resolve7(result);
|
|
14854
15035
|
};
|
|
14855
15036
|
const timer = setTimeout(() => {
|
|
14856
15037
|
killProcessGroupNow(child, deps.processGroup);
|
|
@@ -14865,7 +15046,7 @@ async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
14865
15046
|
stdout2 += chunk.toString("utf-8");
|
|
14866
15047
|
});
|
|
14867
15048
|
child.stderr.on("data", (chunk) => {
|
|
14868
|
-
stderr
|
|
15049
|
+
stderr = appendBoundedTail(stderr, chunk.toString("utf-8"));
|
|
14869
15050
|
});
|
|
14870
15051
|
child.on("error", (error) => {
|
|
14871
15052
|
if (cancelled) {
|
|
@@ -14943,10 +15124,10 @@ ${stderr}`;
|
|
|
14943
15124
|
return outcome;
|
|
14944
15125
|
}
|
|
14945
15126
|
function gitHead(dir) {
|
|
14946
|
-
return new Promise((
|
|
15127
|
+
return new Promise((resolve7, reject) => {
|
|
14947
15128
|
execFile3("git", ["rev-parse", "HEAD"], { cwd: dir, timeout: 15e3 }, (error, stdout2) => {
|
|
14948
15129
|
if (error) reject(new Error(`git rev-parse HEAD failed: ${error.message}`));
|
|
14949
|
-
else
|
|
15130
|
+
else resolve7(stdout2.trim());
|
|
14950
15131
|
});
|
|
14951
15132
|
});
|
|
14952
15133
|
}
|
|
@@ -15013,7 +15194,7 @@ function buildConflictResolveArgs(files, baseBranch) {
|
|
|
15013
15194
|
function createClaudeConflictResolver(opts) {
|
|
15014
15195
|
const spawnImpl = opts.spawnImpl ?? spawn6;
|
|
15015
15196
|
const timeoutMs = opts.timeoutMs ?? CONFLICT_RESOLVE_TIMEOUT_MS;
|
|
15016
|
-
return ({ dir, files, baseBranch, signal }) => new Promise((
|
|
15197
|
+
return ({ dir, files, baseBranch, signal }) => new Promise((resolve7) => {
|
|
15017
15198
|
let settled = false;
|
|
15018
15199
|
const child = spawnPiped(
|
|
15019
15200
|
spawnImpl,
|
|
@@ -15036,7 +15217,7 @@ function createClaudeConflictResolver(opts) {
|
|
|
15036
15217
|
settled = true;
|
|
15037
15218
|
clearTimeout(timer);
|
|
15038
15219
|
disposeAbort();
|
|
15039
|
-
|
|
15220
|
+
resolve7(result);
|
|
15040
15221
|
};
|
|
15041
15222
|
const timer = setTimeout(() => {
|
|
15042
15223
|
killProcessGroupNow(child, opts.processGroup);
|
|
@@ -15410,6 +15591,14 @@ async function prepareOrchestrateRun(ctx, deps = {}) {
|
|
|
15410
15591
|
if (!toolchainPresent(projectDir)) {
|
|
15411
15592
|
return { ok: false, result: { status: "failed", result: { error: toolchainMissingMessage(projectDir) } } };
|
|
15412
15593
|
}
|
|
15594
|
+
const missingOrchestrator = missingAgentDefinitionMessage(
|
|
15595
|
+
deps.agentDir,
|
|
15596
|
+
"orchestrator",
|
|
15597
|
+
deps.agentSource
|
|
15598
|
+
);
|
|
15599
|
+
if (missingOrchestrator) {
|
|
15600
|
+
return { ok: false, result: { status: "failed", result: { error: missingOrchestrator } } };
|
|
15601
|
+
}
|
|
15413
15602
|
if (!ctx.fix && ctx.cloud && !ctx.resume) {
|
|
15414
15603
|
const spendTeamId = ctx.teamId;
|
|
15415
15604
|
const preflight = deps.cloudPreflight ?? ((facts, repo) => runCloudPreflight(facts, repo, {
|
|
@@ -15455,7 +15644,10 @@ async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
15455
15644
|
let resumeFallbackWhy = null;
|
|
15456
15645
|
const orchestratorPerms = permissionsFor(deps.agentPermissions, "orchestrator");
|
|
15457
15646
|
const protectedBranches = orchestratorPerms?.protectedBranches ?? [];
|
|
15458
|
-
const agentArgs = (a) =>
|
|
15647
|
+
const agentArgs = (a) => {
|
|
15648
|
+
const withDefs = withAgentDefinitions(a, deps.agentDir, "orchestrator");
|
|
15649
|
+
return applyAgentPermissions(ctx.keyRun ? keyRunArgs(withDefs) : withDefs, orchestratorPerms);
|
|
15650
|
+
};
|
|
15459
15651
|
if (resume) {
|
|
15460
15652
|
if (!resume.sessionId || !resume.runDir) {
|
|
15461
15653
|
resumeFallbackWhy = "the paused run didn't keep a session to resume";
|
|
@@ -15598,7 +15790,7 @@ async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
15598
15790
|
error: reason === "ceiling" ? `The orchestrator run reached the ${String(Math.round(maxMs / 36e5))}-hour limit (buildMaxHours) and was stopped.` : `The orchestrator run made no progress for ${String(Math.round(stallMs / 6e4))} minutes (no new commit, finished feature or output) and was stopped.`
|
|
15599
15791
|
}
|
|
15600
15792
|
});
|
|
15601
|
-
const runOnce = (runArgsNow, budgetMs) => new Promise((
|
|
15793
|
+
const runOnce = (runArgsNow, budgetMs) => new Promise((resolve7) => {
|
|
15602
15794
|
let stdout2 = "";
|
|
15603
15795
|
let stderr = "";
|
|
15604
15796
|
let outputBytes = 0;
|
|
@@ -15658,7 +15850,7 @@ async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
15658
15850
|
watcher.stop();
|
|
15659
15851
|
if (watcher.madeProgress) madeProgress = true;
|
|
15660
15852
|
disposeAbort();
|
|
15661
|
-
|
|
15853
|
+
resolve7(result);
|
|
15662
15854
|
};
|
|
15663
15855
|
const watcher = startProgressWatcher({
|
|
15664
15856
|
getHead,
|
|
@@ -16128,7 +16320,7 @@ async function updatePersonalEpicRequest(apiBaseUrl, userApiToken, epicRequestId
|
|
|
16128
16320
|
|
|
16129
16321
|
// src/utils/repo-setup.ts
|
|
16130
16322
|
import { spawn as spawn7 } from "node:child_process";
|
|
16131
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync11, readdirSync as
|
|
16323
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync11, readdirSync as readdirSync5 } from "node:fs";
|
|
16132
16324
|
import { homedir as homedir10 } from "node:os";
|
|
16133
16325
|
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join19, resolve as resolve3 } from "node:path";
|
|
16134
16326
|
var CLONE_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
@@ -16190,9 +16382,9 @@ async function invokeConnectRepo(payload, deps = {}) {
|
|
|
16190
16382
|
const clone = deps.clone ?? defaultGitCloner;
|
|
16191
16383
|
const home = deps.home ?? homedir10();
|
|
16192
16384
|
const exists = deps.exists ?? existsSync17;
|
|
16193
|
-
const isEmptyDir = deps.isEmptyDir ?? ((
|
|
16385
|
+
const isEmptyDir = deps.isEmptyDir ?? ((path5) => {
|
|
16194
16386
|
try {
|
|
16195
|
-
return
|
|
16387
|
+
return readdirSync5(path5).length === 0;
|
|
16196
16388
|
} catch {
|
|
16197
16389
|
return false;
|
|
16198
16390
|
}
|
|
@@ -16200,8 +16392,8 @@ async function invokeConnectRepo(payload, deps = {}) {
|
|
|
16200
16392
|
const isGitRepo = deps.isGitRepo ?? isGitRepoDir;
|
|
16201
16393
|
const readOrigin = deps.readOrigin ?? readOriginRemote;
|
|
16202
16394
|
const listDirs = deps.listDirs ?? listProjectDirs;
|
|
16203
|
-
const addDir = deps.addDir ?? ((
|
|
16204
|
-
const mkdir4 = deps.mkdir ?? ((
|
|
16395
|
+
const addDir = deps.addDir ?? ((path5) => addProjectDir(path5));
|
|
16396
|
+
const mkdir4 = deps.mkdir ?? ((path5) => void mkdirSync11(path5, { recursive: true }));
|
|
16205
16397
|
const p = parsePayload(payload);
|
|
16206
16398
|
if (!p) {
|
|
16207
16399
|
return { status: "failed", result: { error: "The job was missing the project repository. Try again from the project page." } };
|
|
@@ -16558,7 +16750,7 @@ function formatBlockedAction(action) {
|
|
|
16558
16750
|
const detail = action.detail.replace(/[\r\n]+/g, " ").slice(0, 300);
|
|
16559
16751
|
return `[custom-agent] blocked by ${by}: ${action.tool}${detail ? ` (${detail})` : ""}`;
|
|
16560
16752
|
}
|
|
16561
|
-
var defaultProcessRunner = (command, args, opts) => new Promise((
|
|
16753
|
+
var defaultProcessRunner = (command, args, opts) => new Promise((resolve7) => {
|
|
16562
16754
|
const child = spawn8(command, args, {
|
|
16563
16755
|
cwd: opts.cwd,
|
|
16564
16756
|
env: opts.env,
|
|
@@ -16570,10 +16762,10 @@ var defaultProcessRunner = (command, args, opts) => new Promise((resolve6) => {
|
|
|
16570
16762
|
child.stdout.on("data", (c) => stdout2 += c.toString("utf-8"));
|
|
16571
16763
|
child.stderr.on("data", (c) => stderr += c.toString("utf-8"));
|
|
16572
16764
|
child.on("error", (error) => {
|
|
16573
|
-
|
|
16765
|
+
resolve7({ code: null, stdout: stdout2, stderr: stderr + error.message });
|
|
16574
16766
|
});
|
|
16575
16767
|
child.on("close", (code) => {
|
|
16576
|
-
|
|
16768
|
+
resolve7({ code, stdout: stdout2, stderr });
|
|
16577
16769
|
});
|
|
16578
16770
|
});
|
|
16579
16771
|
async function runCustomAgent(spec, opts) {
|
|
@@ -16648,17 +16840,17 @@ function isSafeRefName(ref) {
|
|
|
16648
16840
|
function trialRef(trialId) {
|
|
16649
16841
|
return `refs/compbox/trials/${trialId.replace(/[^A-Za-z0-9-]/g, "")}`;
|
|
16650
16842
|
}
|
|
16651
|
-
var defaultGitRunner = (args, cwd) => new Promise((
|
|
16843
|
+
var defaultGitRunner = (args, cwd) => new Promise((resolve7) => {
|
|
16652
16844
|
let stdout2 = "";
|
|
16653
16845
|
let stderr = "";
|
|
16654
16846
|
const child = spawn9("git", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
16655
16847
|
child.stdout.on("data", (c) => stdout2 += c.toString("utf-8"));
|
|
16656
16848
|
child.stderr.on("data", (c) => stderr += c.toString("utf-8"));
|
|
16657
16849
|
child.on("error", (error) => {
|
|
16658
|
-
|
|
16850
|
+
resolve7({ status: null, stdout: stdout2, stderr: stderr + error.message });
|
|
16659
16851
|
});
|
|
16660
16852
|
child.on("close", (status) => {
|
|
16661
|
-
|
|
16853
|
+
resolve7({ status, stdout: stdout2, stderr });
|
|
16662
16854
|
});
|
|
16663
16855
|
});
|
|
16664
16856
|
function failed(error) {
|
|
@@ -16770,11 +16962,57 @@ function startKeepAwake(opts) {
|
|
|
16770
16962
|
}
|
|
16771
16963
|
|
|
16772
16964
|
// src/utils/agent-store.ts
|
|
16773
|
-
import { createHash as
|
|
16774
|
-
import { existsSync as
|
|
16965
|
+
import { createHash as createHash4, randomBytes } from "node:crypto";
|
|
16966
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
16775
16967
|
import * as fs3 from "node:fs/promises";
|
|
16776
16968
|
import * as os from "node:os";
|
|
16969
|
+
import * as path4 from "node:path";
|
|
16970
|
+
|
|
16971
|
+
// src/utils/bundled-agents.ts
|
|
16972
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
16777
16973
|
import * as path3 from "node:path";
|
|
16974
|
+
import { fileURLToPath } from "node:url";
|
|
16975
|
+
var MARKER_FILE2 = "orchestrator.md";
|
|
16976
|
+
var BundledAgentsMissingError = class extends Error {
|
|
16977
|
+
constructor(searched) {
|
|
16978
|
+
super(
|
|
16979
|
+
"CompBox could not find its built-in agents (planner, orchestrator). This CLI install looks incomplete \u2014 reinstall it with `npm install -g @mycompbox/compbox-cli` or `brew reinstall compbox`.\nLooked in:\n" + searched.map((p) => ` - ${p}`).join("\n")
|
|
16980
|
+
);
|
|
16981
|
+
this.searched = searched;
|
|
16982
|
+
this.name = "BundledAgentsMissingError";
|
|
16983
|
+
}
|
|
16984
|
+
};
|
|
16985
|
+
function moduleDir() {
|
|
16986
|
+
if (typeof __dirname === "string" && __dirname !== "") return __dirname;
|
|
16987
|
+
return path3.dirname(fileURLToPath(import.meta.url));
|
|
16988
|
+
}
|
|
16989
|
+
function isAgentsDir(dir) {
|
|
16990
|
+
return existsSync18(path3.join(dir, MARKER_FILE2));
|
|
16991
|
+
}
|
|
16992
|
+
function bundledAgentsCandidates(startDir) {
|
|
16993
|
+
const candidates = [
|
|
16994
|
+
path3.join(startDir, "agents"),
|
|
16995
|
+
// bundles: dist/index.js, <libexec>/compbox.cjs
|
|
16996
|
+
path3.join(startDir, "..", "agents")
|
|
16997
|
+
// tsc build: dist/utils/
|
|
16998
|
+
];
|
|
16999
|
+
let dir = startDir;
|
|
17000
|
+
for (; ; ) {
|
|
17001
|
+
candidates.push(path3.join(dir, ".github", "agents", "claude"));
|
|
17002
|
+
const parent = path3.dirname(dir);
|
|
17003
|
+
if (parent === dir) break;
|
|
17004
|
+
dir = parent;
|
|
17005
|
+
}
|
|
17006
|
+
return candidates.map((c) => path3.resolve(c));
|
|
17007
|
+
}
|
|
17008
|
+
function getBundledAgentsDir(startDir = moduleDir()) {
|
|
17009
|
+
const candidates = bundledAgentsCandidates(startDir);
|
|
17010
|
+
const found = candidates.find(isAgentsDir);
|
|
17011
|
+
if (!found) throw new BundledAgentsMissingError(candidates);
|
|
17012
|
+
return found;
|
|
17013
|
+
}
|
|
17014
|
+
|
|
17015
|
+
// src/utils/agent-store.ts
|
|
16778
17016
|
var AgentSetIntegrityError = class extends Error {
|
|
16779
17017
|
constructor(message) {
|
|
16780
17018
|
super(message);
|
|
@@ -16789,11 +17027,25 @@ var AgentSetUnavailableError = class extends Error {
|
|
|
16789
17027
|
};
|
|
16790
17028
|
var SHA256_RE = /^[0-9a-f]{64}$/;
|
|
16791
17029
|
var LAST_SET_FILE = "last-set.json";
|
|
17030
|
+
var BUNDLED_PREFIX = "agents/claude";
|
|
17031
|
+
async function readTree(dir, rel = "") {
|
|
17032
|
+
const out = /* @__PURE__ */ new Map();
|
|
17033
|
+
const entries = await fs3.readdir(path4.join(dir, rel), { withFileTypes: true });
|
|
17034
|
+
for (const entry of entries) {
|
|
17035
|
+
const childRel = rel === "" ? entry.name : `${rel}/${entry.name}`;
|
|
17036
|
+
if (entry.isDirectory()) {
|
|
17037
|
+
for (const [k, v] of await readTree(dir, childRel)) out.set(k, v);
|
|
17038
|
+
} else if (entry.isFile()) {
|
|
17039
|
+
out.set(childRel, await fs3.readFile(path4.join(dir, childRel)));
|
|
17040
|
+
}
|
|
17041
|
+
}
|
|
17042
|
+
return out;
|
|
17043
|
+
}
|
|
16792
17044
|
function defaultAgentStoreRoot() {
|
|
16793
|
-
return
|
|
17045
|
+
return path4.join(os.homedir(), ".compbox", "agent-store");
|
|
16794
17046
|
}
|
|
16795
17047
|
function sha256Hex(content) {
|
|
16796
|
-
return
|
|
17048
|
+
return createHash4("sha256").update(content).digest("hex");
|
|
16797
17049
|
}
|
|
16798
17050
|
function layoutPath(filePath) {
|
|
16799
17051
|
const posix2 = filePath.replace(/\\/g, "/");
|
|
@@ -16871,11 +17123,11 @@ function describeError(error) {
|
|
|
16871
17123
|
return typeof e?.message === "string" ? e.message : String(error);
|
|
16872
17124
|
}
|
|
16873
17125
|
function isInside(child, parent) {
|
|
16874
|
-
const rel =
|
|
16875
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
17126
|
+
const rel = path4.relative(path4.resolve(parent), path4.resolve(child));
|
|
17127
|
+
return rel === "" || !rel.startsWith("..") && !path4.isAbsolute(rel);
|
|
16876
17128
|
}
|
|
16877
17129
|
async function writeAtomic2(target, content) {
|
|
16878
|
-
await fs3.mkdir(
|
|
17130
|
+
await fs3.mkdir(path4.dirname(target), { recursive: true, mode: 448 });
|
|
16879
17131
|
const tmp = `${target}.${String(process.pid)}.${randomBytes(4).toString("hex")}.tmp`;
|
|
16880
17132
|
await fs3.writeFile(tmp, content, { mode: 384 });
|
|
16881
17133
|
await fs3.rename(tmp, target);
|
|
@@ -16883,17 +17135,43 @@ async function writeAtomic2(target, content) {
|
|
|
16883
17135
|
var AgentStore = class {
|
|
16884
17136
|
root;
|
|
16885
17137
|
log;
|
|
17138
|
+
bundledAgentsDir;
|
|
17139
|
+
bundledCache;
|
|
16886
17140
|
constructor(options = {}) {
|
|
16887
|
-
this.root =
|
|
17141
|
+
this.root = path4.resolve(options.root ?? defaultAgentStoreRoot());
|
|
16888
17142
|
this.log = options.log ?? (() => void 0);
|
|
17143
|
+
this.bundledAgentsDir = options.bundledAgentsDir;
|
|
16889
17144
|
if (options.projectDir && isInside(this.root, options.projectDir)) {
|
|
16890
17145
|
throw new AgentSetUnavailableError(
|
|
16891
17146
|
`The agent store (${this.root}) must not live inside the project folder (${options.projectDir}); agent files are never written into the customer repo.`
|
|
16892
17147
|
);
|
|
16893
17148
|
}
|
|
16894
17149
|
}
|
|
17150
|
+
/** Built-in agent files keyed by their layout path (`agents/claude/...`). */
|
|
17151
|
+
async bundledFiles() {
|
|
17152
|
+
if (this.bundledCache) return this.bundledCache;
|
|
17153
|
+
let dir;
|
|
17154
|
+
try {
|
|
17155
|
+
dir = this.bundledAgentsDir ?? getBundledAgentsDir();
|
|
17156
|
+
} catch (error) {
|
|
17157
|
+
throw new AgentSetUnavailableError(error instanceof Error ? error.message : String(error));
|
|
17158
|
+
}
|
|
17159
|
+
const files = /* @__PURE__ */ new Map();
|
|
17160
|
+
for (const [rel, content] of await readTree(dir)) {
|
|
17161
|
+
const target = `${BUNDLED_PREFIX}/${rel}`;
|
|
17162
|
+
assertSafeRelativePath(target, "the built-in agents");
|
|
17163
|
+
files.set(target, content);
|
|
17164
|
+
}
|
|
17165
|
+
if (files.size === 0) {
|
|
17166
|
+
throw new AgentSetUnavailableError(
|
|
17167
|
+
`CompBox's built-in agents folder (${dir}) is empty. Reinstall the CLI.`
|
|
17168
|
+
);
|
|
17169
|
+
}
|
|
17170
|
+
this.bundledCache = files;
|
|
17171
|
+
return files;
|
|
17172
|
+
}
|
|
16895
17173
|
blobPath(sha256) {
|
|
16896
|
-
return
|
|
17174
|
+
return path4.join(this.root, "blobs", sha256.slice(0, 2), sha256);
|
|
16897
17175
|
}
|
|
16898
17176
|
/** Cached blob content if present AND it still hashes to `sha256`; otherwise undefined. */
|
|
16899
17177
|
async readVerifiedBlob(sha256) {
|
|
@@ -16931,7 +17209,7 @@ var AgentStore = class {
|
|
|
16931
17209
|
downloaded.push(`${pack.name}@${pack.version}`);
|
|
16932
17210
|
}
|
|
16933
17211
|
const resolved = await this.layout(set, "online", downloaded);
|
|
16934
|
-
await writeAtomic2(
|
|
17212
|
+
await writeAtomic2(path4.join(this.root, LAST_SET_FILE), JSON.stringify(set, null, 2));
|
|
16935
17213
|
return resolved;
|
|
16936
17214
|
}
|
|
16937
17215
|
/**
|
|
@@ -16941,7 +17219,7 @@ var AgentStore = class {
|
|
|
16941
17219
|
*/
|
|
16942
17220
|
async installedAgentVersions() {
|
|
16943
17221
|
try {
|
|
16944
|
-
const raw = await fs3.readFile(
|
|
17222
|
+
const raw = await fs3.readFile(path4.join(this.root, LAST_SET_FILE), "utf8");
|
|
16945
17223
|
return agentVersionsOf(validateAgentSet(JSON.parse(raw)).packs);
|
|
16946
17224
|
} catch {
|
|
16947
17225
|
return void 0;
|
|
@@ -16950,11 +17228,12 @@ var AgentStore = class {
|
|
|
16950
17228
|
async resolveOffline(reason) {
|
|
16951
17229
|
let raw;
|
|
16952
17230
|
try {
|
|
16953
|
-
raw = await fs3.readFile(
|
|
17231
|
+
raw = await fs3.readFile(path4.join(this.root, LAST_SET_FILE), "utf8");
|
|
16954
17232
|
} catch {
|
|
16955
|
-
|
|
16956
|
-
`
|
|
17233
|
+
this.log(
|
|
17234
|
+
`Offline (${reason}) and no cached agent set yet: using CompBox's built-in agents only.`
|
|
16957
17235
|
);
|
|
17236
|
+
return this.layout({ organizationId: "", packs: [] }, "bundled", []);
|
|
16958
17237
|
}
|
|
16959
17238
|
let set;
|
|
16960
17239
|
try {
|
|
@@ -16989,10 +17268,10 @@ var AgentStore = class {
|
|
|
16989
17268
|
const where = `${pack.name}@${pack.version}`;
|
|
16990
17269
|
const tarball = await deps.downloadPack(pack.skillPackId, pack.version);
|
|
16991
17270
|
const tar = await import("tar");
|
|
16992
|
-
const tmpDir = await fs3.mkdtemp(
|
|
17271
|
+
const tmpDir = await fs3.mkdtemp(path4.join(os.tmpdir(), "compbox-agent-set-"));
|
|
16993
17272
|
try {
|
|
16994
|
-
const tarPath =
|
|
16995
|
-
const outDir =
|
|
17273
|
+
const tarPath = path4.join(tmpDir, "pack.tar.gz");
|
|
17274
|
+
const outDir = path4.join(tmpDir, "out");
|
|
16996
17275
|
await fs3.mkdir(outDir);
|
|
16997
17276
|
await fs3.writeFile(tarPath, tarball);
|
|
16998
17277
|
try {
|
|
@@ -17013,7 +17292,7 @@ var AgentStore = class {
|
|
|
17013
17292
|
for (const file of pack.files) {
|
|
17014
17293
|
let content;
|
|
17015
17294
|
try {
|
|
17016
|
-
content = await fs3.readFile(
|
|
17295
|
+
content = await fs3.readFile(path4.join(outDir, file.path));
|
|
17017
17296
|
} catch {
|
|
17018
17297
|
throw new AgentSetIntegrityError(
|
|
17019
17298
|
`Agent file "${file.path}" is missing from the download of ${where}. Run blocked.`
|
|
@@ -17037,23 +17316,38 @@ var AgentStore = class {
|
|
|
17037
17316
|
}
|
|
17038
17317
|
/**
|
|
17039
17318
|
* Lay the verified set out in `<root>/sets/<digest>/`, reusing an existing
|
|
17040
|
-
* layout only if every file in it still verifies.
|
|
17041
|
-
*
|
|
17319
|
+
* layout only if every file in it still verifies. The built-in agents go
|
|
17320
|
+
* down first; packs are applied on top in name order, so a pack overrides a
|
|
17321
|
+
* built-in file at the same path and on a pack clash the later name wins.
|
|
17042
17322
|
*/
|
|
17043
17323
|
async layout(set, source, downloaded) {
|
|
17044
|
-
const
|
|
17045
|
-
const setsDir = path3.join(this.root, "sets");
|
|
17046
|
-
const dir = path3.join(setsDir, digest);
|
|
17324
|
+
const bundled = await this.bundledFiles();
|
|
17047
17325
|
const placed = /* @__PURE__ */ new Map();
|
|
17326
|
+
const bundledContent = /* @__PURE__ */ new Map();
|
|
17327
|
+
for (const [rel, content] of bundled) {
|
|
17328
|
+
const sha256 = sha256Hex(content);
|
|
17329
|
+
placed.set(rel, sha256);
|
|
17330
|
+
bundledContent.set(sha256, content);
|
|
17331
|
+
}
|
|
17332
|
+
const baseDigest = sha256Hex(
|
|
17333
|
+
[...placed].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([p, h]) => `${p}\0${h}`).join("\n")
|
|
17334
|
+
);
|
|
17335
|
+
const digest = sha256Hex(`${agentSetDigest(set)}
|
|
17336
|
+
${baseDigest}`);
|
|
17337
|
+
const setsDir = path4.join(this.root, "sets");
|
|
17338
|
+
const dir = path4.join(setsDir, digest);
|
|
17339
|
+
const bundledCount = placed.size;
|
|
17340
|
+
const fromPack = /* @__PURE__ */ new Set();
|
|
17048
17341
|
const ordered = [...set.packs].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
17049
17342
|
for (const pack of ordered) {
|
|
17050
17343
|
for (const file of pack.files) {
|
|
17051
17344
|
const rel = layoutPath(file.path);
|
|
17052
17345
|
const prior = placed.get(rel);
|
|
17053
|
-
if (prior !== void 0 && prior !== file.sha256) {
|
|
17346
|
+
if (prior !== void 0 && prior !== file.sha256 && fromPack.has(rel)) {
|
|
17054
17347
|
this.log(`Agent file "${rel}" is provided by more than one pack; using ${pack.name}'s.`);
|
|
17055
17348
|
}
|
|
17056
17349
|
placed.set(rel, file.sha256);
|
|
17350
|
+
fromPack.add(rel);
|
|
17057
17351
|
}
|
|
17058
17352
|
}
|
|
17059
17353
|
if (await this.layoutIntact(dir, placed)) {
|
|
@@ -17063,24 +17357,25 @@ var AgentStore = class {
|
|
|
17063
17357
|
dir,
|
|
17064
17358
|
digest,
|
|
17065
17359
|
source,
|
|
17360
|
+
bundledFiles: bundledCount,
|
|
17066
17361
|
downloaded
|
|
17067
17362
|
};
|
|
17068
17363
|
}
|
|
17069
17364
|
await fs3.mkdir(setsDir, { recursive: true, mode: 448 });
|
|
17070
|
-
const staging =
|
|
17365
|
+
const staging = path4.join(
|
|
17071
17366
|
setsDir,
|
|
17072
17367
|
`.${digest}.${String(process.pid)}.${randomBytes(4).toString("hex")}`
|
|
17073
17368
|
);
|
|
17074
17369
|
try {
|
|
17075
17370
|
for (const [rel, sha256] of placed) {
|
|
17076
|
-
const content = await this.readVerifiedBlob(sha256);
|
|
17371
|
+
const content = fromPack.has(rel) ? await this.readVerifiedBlob(sha256) : bundledContent.get(sha256);
|
|
17077
17372
|
if (!content) {
|
|
17078
17373
|
throw new AgentSetIntegrityError(
|
|
17079
17374
|
`Cached agent file "${rel}" changed while preparing the run. Run blocked.`
|
|
17080
17375
|
);
|
|
17081
17376
|
}
|
|
17082
|
-
const target =
|
|
17083
|
-
await fs3.mkdir(
|
|
17377
|
+
const target = path4.join(staging, rel);
|
|
17378
|
+
await fs3.mkdir(path4.dirname(target), { recursive: true, mode: 448 });
|
|
17084
17379
|
await fs3.writeFile(target, content, { mode: 384 });
|
|
17085
17380
|
}
|
|
17086
17381
|
await fs3.mkdir(staging, { recursive: true, mode: 448 });
|
|
@@ -17096,14 +17391,15 @@ var AgentStore = class {
|
|
|
17096
17391
|
dir,
|
|
17097
17392
|
digest,
|
|
17098
17393
|
source,
|
|
17394
|
+
bundledFiles: bundledCount,
|
|
17099
17395
|
downloaded
|
|
17100
17396
|
};
|
|
17101
17397
|
}
|
|
17102
17398
|
async layoutIntact(dir, placed) {
|
|
17103
|
-
if (!
|
|
17399
|
+
if (!existsSync19(dir)) return false;
|
|
17104
17400
|
for (const [rel, sha256] of placed) {
|
|
17105
17401
|
try {
|
|
17106
|
-
if (sha256Hex(await fs3.readFile(
|
|
17402
|
+
if (sha256Hex(await fs3.readFile(path4.join(dir, rel))) !== sha256) return false;
|
|
17107
17403
|
} catch {
|
|
17108
17404
|
return false;
|
|
17109
17405
|
}
|
|
@@ -17182,7 +17478,7 @@ function formatOutdatedNotice(error, currentVersion) {
|
|
|
17182
17478
|
].join("\n");
|
|
17183
17479
|
}
|
|
17184
17480
|
function sleep(ms) {
|
|
17185
|
-
return new Promise((
|
|
17481
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
17186
17482
|
}
|
|
17187
17483
|
function backoffDelay(consecutiveErrors) {
|
|
17188
17484
|
return Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** (consecutiveErrors - 1));
|
|
@@ -17405,6 +17701,8 @@ async function handleStartExecution(ctx, job) {
|
|
|
17405
17701
|
}
|
|
17406
17702
|
const jobProjectDir = routed.path;
|
|
17407
17703
|
let agentPermissions = null;
|
|
17704
|
+
let agentDir;
|
|
17705
|
+
let agentSource;
|
|
17408
17706
|
let agentVersions;
|
|
17409
17707
|
if (ctx.userApiToken) {
|
|
17410
17708
|
try {
|
|
@@ -17419,10 +17717,12 @@ async function handleStartExecution(ctx, job) {
|
|
|
17419
17717
|
);
|
|
17420
17718
|
console.log(
|
|
17421
17719
|
chalk9.gray(
|
|
17422
|
-
` Agent set verified (${String(agentSet.packs.length)} pack(s), ${agentSet.source === "cache" ? "from cache, offline" : "online"}).`
|
|
17720
|
+
` Agent set verified (built-in agents + ${String(agentSet.packs.length)} pack(s), ${agentSet.source === "cache" ? "from cache, offline" : agentSet.source === "bundled" ? "offline, built-in agents only" : "online"}).`
|
|
17423
17721
|
)
|
|
17424
17722
|
);
|
|
17425
17723
|
agentVersions = agentVersionsOf(agentSet.packs);
|
|
17724
|
+
agentDir = join23(agentSet.dir, "agents", "claude");
|
|
17725
|
+
agentSource = agentSet.source;
|
|
17426
17726
|
agentPermissions = loadAgentPermissions(agentSet.dir, (m) => {
|
|
17427
17727
|
console.log(chalk9.gray(` ${m}`));
|
|
17428
17728
|
});
|
|
@@ -17481,7 +17781,9 @@ async function handleStartExecution(ctx, job) {
|
|
|
17481
17781
|
// H4: keep this machine online during the long planner run — the poll
|
|
17482
17782
|
// loop (its own heartbeat) is blocked for the whole job.
|
|
17483
17783
|
heartbeat: () => jobHeartbeat(ctx),
|
|
17484
|
-
...agentPermissions && { agentPermissions }
|
|
17784
|
+
...agentPermissions && { agentPermissions },
|
|
17785
|
+
...agentDir && { agentDir },
|
|
17786
|
+
...agentSource && { agentSource }
|
|
17485
17787
|
}
|
|
17486
17788
|
)
|
|
17487
17789
|
);
|
|
@@ -17517,7 +17819,9 @@ async function handleStartExecution(ctx, job) {
|
|
|
17517
17819
|
},
|
|
17518
17820
|
{
|
|
17519
17821
|
heartbeat: () => jobHeartbeat(ctx),
|
|
17520
|
-
...agentPermissions && { agentPermissions }
|
|
17822
|
+
...agentPermissions && { agentPermissions },
|
|
17823
|
+
...agentDir && { agentDir },
|
|
17824
|
+
...agentSource && { agentSource }
|
|
17521
17825
|
}
|
|
17522
17826
|
)
|
|
17523
17827
|
);
|
|
@@ -17591,6 +17895,8 @@ async function handleStartExecution(ctx, job) {
|
|
|
17591
17895
|
// ENG-349: this machine's in-flight run folders are never pruned.
|
|
17592
17896
|
activeRunDirs: ACTIVE_RUN_DIRS,
|
|
17593
17897
|
...agentPermissions && { agentPermissions },
|
|
17898
|
+
...agentDir && { agentDir },
|
|
17899
|
+
...agentSource && { agentSource },
|
|
17594
17900
|
workspace: new RunWorkspaceManager({
|
|
17595
17901
|
openPullRequest: (input) => ctx.client.openPullRequest(ctx.machineToken, job.id, input)
|
|
17596
17902
|
})
|
|
@@ -18161,8 +18467,8 @@ machinesDirsCommand.command("list").description("List the registered remote \u21
|
|
|
18161
18467
|
}
|
|
18162
18468
|
console.log(table.toString());
|
|
18163
18469
|
});
|
|
18164
|
-
machinesDirsCommand.command("add [path]").description("Register a git checkout (default: current directory) by its origin remote").action((
|
|
18165
|
-
const target =
|
|
18470
|
+
machinesDirsCommand.command("add [path]").description("Register a git checkout (default: current directory) by its origin remote").action((path5) => {
|
|
18471
|
+
const target = path5 && path5.trim().length > 0 ? path5.trim() : process.cwd();
|
|
18166
18472
|
try {
|
|
18167
18473
|
const entry = addProjectDir(target);
|
|
18168
18474
|
console.log(chalk11.green(`\u2714 Registered ${entry.remote} \u2192 ${entry.path}`));
|
|
@@ -18394,13 +18700,13 @@ Setting up ${match.name} (${match.gitRemote})...`));
|
|
|
18394
18700
|
import { Command as Command13 } from "commander";
|
|
18395
18701
|
import chalk14 from "chalk";
|
|
18396
18702
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
18397
|
-
import { cpSync, existsSync as
|
|
18703
|
+
import { cpSync, existsSync as existsSync21, mkdirSync as mkdirSync13, readdirSync as readdirSync6, readFileSync as readFileSync12, rmSync as rmSync6, statSync as statSync6, writeFileSync as writeFileSync13 } from "node:fs";
|
|
18398
18704
|
import { homedir as homedir12 } from "node:os";
|
|
18399
|
-
import { dirname as
|
|
18705
|
+
import { dirname as dirname10, join as join25, posix, relative as relative4, resolve as resolve6, isAbsolute as isAbsolute5 } from "node:path";
|
|
18400
18706
|
|
|
18401
18707
|
// src/utils/custom-agent-sync.ts
|
|
18402
|
-
import { existsSync as
|
|
18403
|
-
import { join as
|
|
18708
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync11, writeFileSync as writeFileSync12 } from "node:fs";
|
|
18709
|
+
import { join as join24 } from "node:path";
|
|
18404
18710
|
var REQUEST_TIMEOUT_MS = 15e3;
|
|
18405
18711
|
var MAX_REPORTS = 500;
|
|
18406
18712
|
function isRecord3(value) {
|
|
@@ -18489,8 +18795,8 @@ function writeInstalledCustomAgents(agentsDir, agents, log = () => void 0) {
|
|
|
18489
18795
|
report("failed");
|
|
18490
18796
|
continue;
|
|
18491
18797
|
}
|
|
18492
|
-
const target =
|
|
18493
|
-
if (written.includes(slug2) ||
|
|
18798
|
+
const target = join24(agentsDir, `${slug2}.md`);
|
|
18799
|
+
if (written.includes(slug2) || existsSync20(target)) {
|
|
18494
18800
|
log(`Custom agent "${agent.name}" would replace the agent @${slug2}; skipped.`);
|
|
18495
18801
|
report("failed");
|
|
18496
18802
|
continue;
|
|
@@ -18498,8 +18804,8 @@ function writeInstalledCustomAgents(agentsDir, agents, log = () => void 0) {
|
|
|
18498
18804
|
try {
|
|
18499
18805
|
const content = customAgentFile(agent);
|
|
18500
18806
|
mkdirSync12(agentsDir, { recursive: true });
|
|
18501
|
-
|
|
18502
|
-
if (sha256Hex(
|
|
18807
|
+
writeFileSync12(target, content);
|
|
18808
|
+
if (sha256Hex(readFileSync11(target)) !== sha256Hex(content)) throw new Error("the file on disk does not match");
|
|
18503
18809
|
written.push(slug2);
|
|
18504
18810
|
report("installed");
|
|
18505
18811
|
log(`Custom agent @${slug2} (version ${String(agent.version)}) installed.`);
|
|
@@ -18548,15 +18854,15 @@ function readWorkspaceEnv(env = process.env) {
|
|
|
18548
18854
|
if (!apiUrl || !jobId || !token) return null;
|
|
18549
18855
|
return { apiUrl: apiUrl.replace(/\/+$/, ""), jobId, token };
|
|
18550
18856
|
}
|
|
18551
|
-
async function workspaceApi(env,
|
|
18552
|
-
const res = await fetchFn(`${env.apiUrl}/api/v1/cloud-runs/workspace/${
|
|
18857
|
+
async function workspaceApi(env, path5, method, fetchFn, body = {}) {
|
|
18858
|
+
const res = await fetchFn(`${env.apiUrl}/api/v1/cloud-runs/workspace/${path5}`, {
|
|
18553
18859
|
method,
|
|
18554
18860
|
headers: { Authorization: `Bearer ${env.token}`, ...method === "POST" && { "Content-Type": "application/json" } },
|
|
18555
18861
|
...method === "POST" && { body: JSON.stringify(body) }
|
|
18556
18862
|
});
|
|
18557
18863
|
if (!res.ok) {
|
|
18558
18864
|
const body2 = await res.json().catch(() => null);
|
|
18559
|
-
throw new Error(body2?.error?.message ?? `CompBox returned ${String(res.status)} for ${
|
|
18865
|
+
throw new Error(body2?.error?.message ?? `CompBox returned ${String(res.status)} for ${path5}`);
|
|
18560
18866
|
}
|
|
18561
18867
|
return (await res.json()).data;
|
|
18562
18868
|
}
|
|
@@ -18576,7 +18882,7 @@ CompBox's own files live outside the project: any path an agent file mentions un
|
|
|
18576
18882
|
Never push to the default branch: work on the run's own branch.
|
|
18577
18883
|
`;
|
|
18578
18884
|
}
|
|
18579
|
-
var AGENTS_SUBDIR =
|
|
18885
|
+
var AGENTS_SUBDIR = join25(".github", "agents", "claude");
|
|
18580
18886
|
function safeSourcePath(sourcePath) {
|
|
18581
18887
|
if (typeof sourcePath !== "string" || !sourcePath || isAbsolute5(sourcePath) || sourcePath.includes("\\")) return null;
|
|
18582
18888
|
const normal = posix.normalize(sourcePath);
|
|
@@ -18586,7 +18892,7 @@ function safeSourcePath(sourcePath) {
|
|
|
18586
18892
|
}
|
|
18587
18893
|
async function prepareRunAgents(opts) {
|
|
18588
18894
|
const { builtInRoot, runRoot } = opts;
|
|
18589
|
-
const builtIn = { agentsDir:
|
|
18895
|
+
const builtIn = { agentsDir: join25(builtInRoot, AGENTS_SUBDIR), compboxRoot: builtInRoot, edited: [] };
|
|
18590
18896
|
try {
|
|
18591
18897
|
const agents = await fetchResolvedAgents(opts.apiUrl, opts.token, opts.fetchFn);
|
|
18592
18898
|
const versions = agents.map((a) => ({ name: a.key, version: String(a.version), sha256: sha256Hex(a.content) })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
@@ -18594,32 +18900,32 @@ async function prepareRunAgents(opts) {
|
|
|
18594
18900
|
const edited = [];
|
|
18595
18901
|
for (const agent of agents) {
|
|
18596
18902
|
if (agent.source !== "edited") continue;
|
|
18597
|
-
const
|
|
18598
|
-
if (!
|
|
18903
|
+
const path5 = safeSourcePath(agent.sourcePath);
|
|
18904
|
+
if (!path5) {
|
|
18599
18905
|
console.warn(chalk14.yellow(`Skipping the company's copy of ${agent.key}: its path can't be used.`));
|
|
18600
18906
|
continue;
|
|
18601
18907
|
}
|
|
18602
|
-
edited.push({ path:
|
|
18908
|
+
edited.push({ path: path5, content: agent.content });
|
|
18603
18909
|
}
|
|
18604
18910
|
if (edited.length === 0) return builtIn;
|
|
18605
18911
|
delete builtIn.versions;
|
|
18606
|
-
const root =
|
|
18912
|
+
const root = resolve6(runRoot);
|
|
18607
18913
|
rmSync6(root, { recursive: true, force: true });
|
|
18608
18914
|
mkdirSync13(root, { recursive: true });
|
|
18609
|
-
const builtInGithub =
|
|
18610
|
-
if (
|
|
18915
|
+
const builtInGithub = join25(builtInRoot, ".github");
|
|
18916
|
+
if (existsSync21(builtInGithub)) cpSync(builtInGithub, join25(root, ".github"), { recursive: true });
|
|
18611
18917
|
for (const file of edited) {
|
|
18612
|
-
const target =
|
|
18918
|
+
const target = resolve6(root, file.path);
|
|
18613
18919
|
const rel = relative4(root, target);
|
|
18614
18920
|
if (rel.startsWith("..") || isAbsolute5(rel)) throw new Error(`unsafe agent path ${file.path}`);
|
|
18615
|
-
mkdirSync13(
|
|
18616
|
-
|
|
18617
|
-
if (sha256Hex(
|
|
18921
|
+
mkdirSync13(dirname10(target), { recursive: true });
|
|
18922
|
+
writeFileSync13(target, file.content);
|
|
18923
|
+
if (sha256Hex(readFileSync12(target)) !== sha256Hex(file.content)) {
|
|
18618
18924
|
throw new Error(`hash mismatch for ${file.path}`);
|
|
18619
18925
|
}
|
|
18620
18926
|
}
|
|
18621
18927
|
console.log(`Using the company's copy of ${String(edited.length)} agent file(s).`);
|
|
18622
|
-
return { agentsDir:
|
|
18928
|
+
return { agentsDir: join25(root, AGENTS_SUBDIR), compboxRoot: root, edited: edited.map((f) => f.path), versions };
|
|
18623
18929
|
} catch (error) {
|
|
18624
18930
|
console.warn(
|
|
18625
18931
|
chalk14.yellow(
|
|
@@ -18630,12 +18936,12 @@ async function prepareRunAgents(opts) {
|
|
|
18630
18936
|
}
|
|
18631
18937
|
}
|
|
18632
18938
|
function copyBuiltInAgents(agents, builtInRoot, runRoot) {
|
|
18633
|
-
const root =
|
|
18939
|
+
const root = resolve6(runRoot);
|
|
18634
18940
|
rmSync6(root, { recursive: true, force: true });
|
|
18635
18941
|
mkdirSync13(root, { recursive: true });
|
|
18636
|
-
const builtInGithub =
|
|
18637
|
-
if (
|
|
18638
|
-
return { ...agents, agentsDir:
|
|
18942
|
+
const builtInGithub = join25(builtInRoot, ".github");
|
|
18943
|
+
if (existsSync21(builtInGithub)) cpSync(builtInGithub, join25(root, ".github"), { recursive: true });
|
|
18944
|
+
return { ...agents, agentsDir: join25(root, AGENTS_SUBDIR), compboxRoot: root };
|
|
18639
18945
|
}
|
|
18640
18946
|
async function runWorkspace(deps = {}) {
|
|
18641
18947
|
const env = readWorkspaceEnv(deps.env);
|
|
@@ -18648,7 +18954,7 @@ async function runWorkspace(deps = {}) {
|
|
|
18648
18954
|
const home = deps.home ?? homedir12();
|
|
18649
18955
|
const workDir = deps.workDir ?? "/workspace";
|
|
18650
18956
|
const compboxRoot = deps.compboxRoot ?? "/opt/compbox";
|
|
18651
|
-
const runAgentsRoot = deps.runAgentsRoot ??
|
|
18957
|
+
const runAgentsRoot = deps.runAgentsRoot ?? join25(workDir, "compbox-agents");
|
|
18652
18958
|
const client = deps.client ?? new MailboxClient(env.apiUrl);
|
|
18653
18959
|
const job = await client.nextJob(env.token, 0);
|
|
18654
18960
|
if (job?.id !== env.jobId) {
|
|
@@ -18665,11 +18971,12 @@ async function runWorkspace(deps = {}) {
|
|
|
18665
18971
|
if (payload.fix !== void 0 && !fix) {
|
|
18666
18972
|
return fail("This fix job's pull request details couldn't be read, so nothing was run.");
|
|
18667
18973
|
}
|
|
18668
|
-
const repoDir =
|
|
18974
|
+
const repoDir = join25(workDir, "repo");
|
|
18669
18975
|
let userApiToken;
|
|
18670
18976
|
let keyRun;
|
|
18671
18977
|
let agentPermissions = null;
|
|
18672
18978
|
let agentVersions;
|
|
18979
|
+
let agentDir;
|
|
18673
18980
|
try {
|
|
18674
18981
|
const git = await workspaceApi(env, "git-credentials", "GET", fetchFn);
|
|
18675
18982
|
userApiToken = (await workspaceApi(env, "session", "POST", fetchFn)).userApiToken;
|
|
@@ -18693,7 +19000,7 @@ async function runWorkspace(deps = {}) {
|
|
|
18693
19000
|
"--",
|
|
18694
19001
|
"compbox-mcp"
|
|
18695
19002
|
]);
|
|
18696
|
-
mkdirSync13(
|
|
19003
|
+
mkdirSync13(join25(home, ".claude"), { recursive: true });
|
|
18697
19004
|
let agents = await prepareRunAgents({
|
|
18698
19005
|
apiUrl: env.apiUrl,
|
|
18699
19006
|
token: userApiToken,
|
|
@@ -18714,9 +19021,10 @@ async function runWorkspace(deps = {}) {
|
|
|
18714
19021
|
console.log(chalk14.gray(` ${m}`));
|
|
18715
19022
|
}
|
|
18716
19023
|
});
|
|
18717
|
-
|
|
19024
|
+
writeFileSync13(join25(home, ".claude", "CLAUDE.md"), agentRoutingInstructions(agents.agentsDir, agents.compboxRoot));
|
|
18718
19025
|
agentVersions = agents.versions;
|
|
18719
|
-
|
|
19026
|
+
agentDir = agents.agentsDir;
|
|
19027
|
+
agentPermissions = loadAgentPermissions(join25(agents.compboxRoot, ".github"), (m) => {
|
|
18720
19028
|
console.log(chalk14.gray(` ${m}`));
|
|
18721
19029
|
});
|
|
18722
19030
|
for (const agent of ["planner", "orchestrator"]) {
|
|
@@ -18760,7 +19068,7 @@ async function runWorkspace(deps = {}) {
|
|
|
18760
19068
|
keyRun,
|
|
18761
19069
|
signal
|
|
18762
19070
|
},
|
|
18763
|
-
{ heartbeat, ...agentPermissions && { agentPermissions } }
|
|
19071
|
+
{ heartbeat, ...agentPermissions && { agentPermissions }, ...agentDir && { agentDir } }
|
|
18764
19072
|
);
|
|
18765
19073
|
} else if (payload.kind === "orchestrate" && payload.epicId) {
|
|
18766
19074
|
outcome = await (deps.orchestrate ?? invokeStartExecutionOrchestrate)(
|
|
@@ -18782,6 +19090,7 @@ async function runWorkspace(deps = {}) {
|
|
|
18782
19090
|
{
|
|
18783
19091
|
heartbeat,
|
|
18784
19092
|
...agentPermissions && { agentPermissions },
|
|
19093
|
+
...agentDir && { agentDir },
|
|
18785
19094
|
workspace: new RunWorkspaceManager({
|
|
18786
19095
|
openPullRequest: (input) => client.openPullRequest(env.token, job.id, input)
|
|
18787
19096
|
})
|
|
@@ -18801,7 +19110,7 @@ async function runWorkspace(deps = {}) {
|
|
|
18801
19110
|
keyRun,
|
|
18802
19111
|
signal
|
|
18803
19112
|
},
|
|
18804
|
-
{ heartbeat, ...agentPermissions && { agentPermissions } }
|
|
19113
|
+
{ heartbeat, ...agentPermissions && { agentPermissions }, ...agentDir && { agentDir } }
|
|
18805
19114
|
);
|
|
18806
19115
|
} else {
|
|
18807
19116
|
return fail("The job is missing what to plan or build.");
|
|
@@ -18817,28 +19126,28 @@ async function runWorkspace(deps = {}) {
|
|
|
18817
19126
|
}
|
|
18818
19127
|
var MAX_TRANSCRIPT_BYTES = 5 * 1024 * 1024;
|
|
18819
19128
|
function findSessionTranscript(home) {
|
|
18820
|
-
const root =
|
|
19129
|
+
const root = join25(home, ".claude", "projects");
|
|
18821
19130
|
let newest = null;
|
|
18822
19131
|
let folders;
|
|
18823
19132
|
try {
|
|
18824
|
-
folders =
|
|
19133
|
+
folders = readdirSync6(root);
|
|
18825
19134
|
} catch {
|
|
18826
19135
|
return null;
|
|
18827
19136
|
}
|
|
18828
19137
|
for (const folder of folders) {
|
|
18829
19138
|
let files;
|
|
18830
19139
|
try {
|
|
18831
|
-
files =
|
|
19140
|
+
files = readdirSync6(join25(root, folder));
|
|
18832
19141
|
} catch {
|
|
18833
19142
|
continue;
|
|
18834
19143
|
}
|
|
18835
19144
|
for (const file of files) {
|
|
18836
19145
|
if (!file.endsWith(".jsonl")) continue;
|
|
18837
|
-
const
|
|
18838
|
-
const stat = statSync6(
|
|
19146
|
+
const path5 = join25(root, folder, file);
|
|
19147
|
+
const stat = statSync6(path5, { throwIfNoEntry: false });
|
|
18839
19148
|
if (!stat?.isFile()) continue;
|
|
18840
19149
|
if (!newest || stat.mtimeMs > newest.mtime) {
|
|
18841
|
-
newest = { path:
|
|
19150
|
+
newest = { path: path5, folder, sessionId: file.slice(0, -".jsonl".length), mtime: stat.mtimeMs, bytes: stat.size };
|
|
18842
19151
|
}
|
|
18843
19152
|
}
|
|
18844
19153
|
}
|
|
@@ -18846,7 +19155,7 @@ function findSessionTranscript(home) {
|
|
|
18846
19155
|
return {
|
|
18847
19156
|
sessionId: newest.sessionId,
|
|
18848
19157
|
projectFolder: newest.folder,
|
|
18849
|
-
transcript: newest.bytes > MAX_TRANSCRIPT_BYTES ? "" :
|
|
19158
|
+
transcript: newest.bytes > MAX_TRANSCRIPT_BYTES ? "" : readFileSync12(newest.path, "utf-8"),
|
|
18850
19159
|
bytes: newest.bytes
|
|
18851
19160
|
};
|
|
18852
19161
|
}
|
|
@@ -18920,8 +19229,8 @@ import { Command as Command14 } from "commander";
|
|
|
18920
19229
|
import chalk15 from "chalk";
|
|
18921
19230
|
var SLACK_MS = 6e4;
|
|
18922
19231
|
var WAIT_LIMIT_MS = 30 * 6e4;
|
|
18923
|
-
async function call(deps,
|
|
18924
|
-
const res = await (deps.fetchFn ?? fetch)(`${deps.apiBaseUrl.replace(/\/+$/, "")}/api/v1${
|
|
19232
|
+
async function call(deps, path5, init = {}) {
|
|
19233
|
+
const res = await (deps.fetchFn ?? fetch)(`${deps.apiBaseUrl.replace(/\/+$/, "")}/api/v1${path5}`, {
|
|
18925
19234
|
method: init.method ?? "GET",
|
|
18926
19235
|
headers: {
|
|
18927
19236
|
Authorization: `Bearer ${deps.apiToken}`,
|