@madarco/agentbox 0.22.1 → 0.22.2
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/CHANGELOG.md +37 -0
- package/dist/{_cloud-attach-YH2SU75S.js → _cloud-attach-Y5WZ7F53.js} +5 -5
- package/dist/{chunk-KBVD2UUQ.js → chunk-3KAWXDQ4.js} +3 -3
- package/dist/{chunk-YZXXBHWG.js → chunk-5DZTXHLQ.js} +3 -3
- package/dist/{chunk-O2NDZQHN.js → chunk-7HAGPF4X.js} +2 -2
- package/dist/{chunk-O67ZESNL.js → chunk-AYNGC4Z5.js} +4 -4
- package/dist/{chunk-GGWVTWJM.js → chunk-BMCT3LBE.js} +16 -13
- package/dist/chunk-BMCT3LBE.js.map +1 -0
- package/dist/{chunk-ALEYDWAO.js → chunk-ES2DDCAC.js} +303 -87
- package/dist/chunk-ES2DDCAC.js.map +1 -0
- package/dist/{chunk-VBSRJG53.js → chunk-QT3SHMLY.js} +9 -1
- package/dist/chunk-QT3SHMLY.js.map +1 -0
- package/dist/{chunk-CDEJ2GQK.js → chunk-S4OWE3UD.js} +4 -4
- package/dist/{chunk-W2FLHB54.js → chunk-V2NCCC2B.js} +2 -2
- package/dist/{dist-QBXEP4VY.js → dist-2BTJQUJS.js} +2 -2
- package/dist/{dist-LJHS4PTC.js → dist-AN5NUXA5.js} +6 -6
- package/dist/{dist-EJXUKIR7.js → dist-FNAGMTUI.js} +4 -4
- package/dist/{dist-YECTRVGD.js → dist-K5GASNBV.js} +6 -6
- package/dist/{dist-UR2DB2HT.js → dist-SJRMFVRV.js} +6 -6
- package/dist/{dist-QNV4H6NN.js → dist-VOVN64Y2.js} +6 -6
- package/dist/index.js +1108 -727
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js → prepared-state-5FIGV4BE-WPHOEDA6.js} +2 -2
- package/package.json +5 -5
- package/runtime/_shared/ctl.cjs +10 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +10 -0
- package/runtime/e2b/ctl.cjs +10 -0
- package/runtime/hetzner/ctl.cjs +10 -0
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +1 -0
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/routes-manifest.json +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/server-reference-manifest.json +12 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/server-reference-manifest.json +12 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/server-reference-manifest.json +12 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +1 -0
- package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_095p8vu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_rename_route_actions_0mf3a9p.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +14 -14
- package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +1 -0
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +24 -0
- package/runtime/hub/apps/hub/.next/static/chunks/2xc1sm79a6tsb.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/332lo0ac7l2wv.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3gdqmzzl34ilu.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/44exu5uemf-ev.js +1 -0
- package/runtime/hub/apps/hub/{auth-YBXDRLHG.js → auth-675P3LQS.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-LJGI76HI.js → auth-config-AOBEKRZQ.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-OBKLTPIR.js → chunk-56YQBVN2.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-LJG4CEGS.js → chunk-5XQ3T3W2.js} +274 -84
- package/runtime/hub/apps/hub/{chunk-JDA7BPPN.js → chunk-673QOHSR.js} +3 -3
- package/runtime/hub/apps/hub/{chunk-V5KGFHCF.js → chunk-7J6ZFTT4.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-AKLBSCSZ.js → chunk-EXQCBM5Q.js} +8 -0
- package/runtime/hub/apps/hub/{dist-GGM4BUKM.js → dist-EI54M5DP.js} +4 -4
- package/runtime/hub/apps/hub/{dist-ELOY2IUE.js → dist-GCALYJN7.js} +3 -3
- package/runtime/hub/apps/hub/{dist-FDBOJ74K.js → dist-K7WHNDZB.js} +4 -4
- package/runtime/hub/apps/hub/{dist-CM4YAQLI.js → dist-LYTWBTUL.js} +4 -4
- package/runtime/hub/apps/hub/{dist-BF54UNHK.js → dist-MOCUH2OC.js} +4 -4
- package/runtime/hub/apps/hub/{dist-IENF7YOD.js → dist-STQK5XM6.js} +1 -1
- package/runtime/hub/apps/hub/{hub-token-EW32VDIU.js → hub-token-2BZFBBW3.js} +2 -2
- package/runtime/hub/apps/hub/{prepared-state-5FIGV4BE-FIXKBF5A.js → prepared-state-5FIGV4BE-D2HJEY2L.js} +1 -1
- package/runtime/hub/apps/hub/server.js +57 -16
- package/runtime/relay/bin.cjs +10 -0
- package/runtime/vercel/ctl.cjs +10 -0
- package/dist/chunk-ALEYDWAO.js.map +0 -1
- package/dist/chunk-GGWVTWJM.js.map +0 -1
- package/dist/chunk-VBSRJG53.js.map +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0lq354ziiwxxl.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/11vmjdy3390ik.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1svigjdfotduh.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/2d5e6t-5j4etp.js +0 -1
- /package/dist/{_cloud-attach-YH2SU75S.js.map → _cloud-attach-Y5WZ7F53.js.map} +0 -0
- /package/dist/{chunk-KBVD2UUQ.js.map → chunk-3KAWXDQ4.js.map} +0 -0
- /package/dist/{chunk-YZXXBHWG.js.map → chunk-5DZTXHLQ.js.map} +0 -0
- /package/dist/{chunk-O2NDZQHN.js.map → chunk-7HAGPF4X.js.map} +0 -0
- /package/dist/{chunk-O67ZESNL.js.map → chunk-AYNGC4Z5.js.map} +0 -0
- /package/dist/{chunk-CDEJ2GQK.js.map → chunk-S4OWE3UD.js.map} +0 -0
- /package/dist/{chunk-W2FLHB54.js.map → chunk-V2NCCC2B.js.map} +0 -0
- /package/dist/{dist-EJXUKIR7.js.map → dist-2BTJQUJS.js.map} +0 -0
- /package/dist/{dist-LJHS4PTC.js.map → dist-AN5NUXA5.js.map} +0 -0
- /package/dist/{dist-QBXEP4VY.js.map → dist-FNAGMTUI.js.map} +0 -0
- /package/dist/{dist-QNV4H6NN.js.map → dist-K5GASNBV.js.map} +0 -0
- /package/dist/{dist-UR2DB2HT.js.map → dist-SJRMFVRV.js.map} +0 -0
- /package/dist/{dist-YECTRVGD.js.map → dist-VOVN64Y2.js.map} +0 -0
- /package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js.map → prepared-state-5FIGV4BE-WPHOEDA6.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_ssgManifest.js +0 -0
|
@@ -274,51 +274,54 @@ import { setTimeout as delay } from "timers/promises";
|
|
|
274
274
|
import { execa } from "execa";
|
|
275
275
|
import { readdir, stat as stat2 } from "fs/promises";
|
|
276
276
|
import { join as join2 } from "path";
|
|
277
|
-
import {
|
|
277
|
+
import { promises as fs } from "fs";
|
|
278
278
|
import { homedir as homedir2 } from "os";
|
|
279
|
-
import { dirname as dirname22,
|
|
279
|
+
import { dirname as dirname22, join as join3 } from "path";
|
|
280
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
281
|
+
import { homedir as homedir3 } from "os";
|
|
282
|
+
import { dirname as dirname3, resolve } from "path";
|
|
280
283
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
281
284
|
import { mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename2, rm as rm2, stat as stat3, writeFile as writeFile2 } from "fs/promises";
|
|
282
|
-
import { homedir as
|
|
283
|
-
import { dirname as
|
|
285
|
+
import { homedir as homedir4 } from "os";
|
|
286
|
+
import { dirname as dirname4, join as join4 } from "path";
|
|
284
287
|
import { setTimeout as delay2 } from "timers/promises";
|
|
285
288
|
import { mkdtemp, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
286
289
|
import { tmpdir } from "os";
|
|
287
|
-
import { basename as basename2, join as
|
|
288
|
-
import { join as
|
|
289
|
-
import { homedir as
|
|
290
|
+
import { basename as basename2, join as join5 } from "path";
|
|
291
|
+
import { join as join6 } from "path";
|
|
292
|
+
import { homedir as homedir5 } from "os";
|
|
290
293
|
import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
|
|
291
294
|
import { tmpdir as tmpdir2 } from "os";
|
|
292
|
-
import { join as
|
|
295
|
+
import { join as join7 } from "path";
|
|
293
296
|
import { execa as execa2 } from "execa";
|
|
294
297
|
import { readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
295
|
-
import { homedir as
|
|
296
|
-
import { join as
|
|
298
|
+
import { homedir as homedir6 } from "os";
|
|
299
|
+
import { join as join8 } from "path";
|
|
297
300
|
import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
|
|
298
|
-
import { isAbsolute, join as
|
|
301
|
+
import { isAbsolute, join as join9, relative } from "path";
|
|
299
302
|
import { stat as stat6 } from "fs/promises";
|
|
300
303
|
import { chmod, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
301
|
-
import { dirname as
|
|
304
|
+
import { dirname as dirname5 } from "path";
|
|
302
305
|
import { createHash } from "crypto";
|
|
303
306
|
import { readFile as readFile5 } from "fs/promises";
|
|
304
|
-
import { join as
|
|
307
|
+
import { join as join10 } from "path";
|
|
305
308
|
import { execa as execa3 } from "execa";
|
|
306
309
|
import { createHash as createHash2 } from "crypto";
|
|
307
310
|
import { copyFile, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat7 } from "fs/promises";
|
|
308
|
-
import { homedir as
|
|
309
|
-
import { basename as basename22, dirname as
|
|
311
|
+
import { homedir as homedir7, tmpdir as tmpdir3 } from "os";
|
|
312
|
+
import { basename as basename22, dirname as dirname6, join as join11 } from "path";
|
|
310
313
|
import { execa as execa4 } from "execa";
|
|
311
314
|
import { copyFile as copyFile2, mkdtemp as mkdtemp4, readdir as readdir5, readFile as readFile7, rm as rm5, stat as stat8, writeFile as writeFile5 } from "fs/promises";
|
|
312
|
-
import { homedir as
|
|
313
|
-
import { basename as basename3, join as
|
|
315
|
+
import { homedir as homedir9, tmpdir as tmpdir4 } from "os";
|
|
316
|
+
import { basename as basename3, join as join12, relative as relative2 } from "path";
|
|
314
317
|
import { execa as execa5 } from "execa";
|
|
315
|
-
import { homedir as
|
|
318
|
+
import { homedir as homedir8 } from "os";
|
|
316
319
|
import { parse, stringify } from "smol-toml";
|
|
317
320
|
import { createHash as createHash3 } from "crypto";
|
|
318
321
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
319
322
|
import { readFile as readFile8 } from "fs/promises";
|
|
320
|
-
import { homedir as
|
|
321
|
-
import { dirname as
|
|
323
|
+
import { homedir as homedir10 } from "os";
|
|
324
|
+
import { dirname as dirname7, resolve as pathResolve } from "path";
|
|
322
325
|
var STATE_DIR = join(homedir(), ".agentbox");
|
|
323
326
|
var STATE_FILE = join(STATE_DIR, "state.json");
|
|
324
327
|
var EMPTY = { version: 1, boxes: [] };
|
|
@@ -411,6 +414,23 @@ async function recordLastAgent(boxId, kind, path = STATE_FILE) {
|
|
|
411
414
|
path
|
|
412
415
|
);
|
|
413
416
|
}
|
|
417
|
+
async function setBoxDisplayName(boxId, displayName, path = STATE_FILE) {
|
|
418
|
+
const trimmed = displayName?.trim();
|
|
419
|
+
const next = trimmed ? trimmed : void 0;
|
|
420
|
+
await mutateState(
|
|
421
|
+
(state) => ({
|
|
422
|
+
version: 1,
|
|
423
|
+
boxes: state.boxes.map((b) => {
|
|
424
|
+
if (b.id !== boxId) return b;
|
|
425
|
+
if (next) return { ...b, displayName: next };
|
|
426
|
+
const rest = { ...b };
|
|
427
|
+
delete rest.displayName;
|
|
428
|
+
return rest;
|
|
429
|
+
})
|
|
430
|
+
}),
|
|
431
|
+
path
|
|
432
|
+
);
|
|
433
|
+
}
|
|
414
434
|
async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
|
|
415
435
|
await mutateState(
|
|
416
436
|
(state) => ({
|
|
@@ -475,6 +495,8 @@ function findBox(idOrName, state) {
|
|
|
475
495
|
if (prefixMatches.length > 1) return { kind: "ambiguous", matches: prefixMatches };
|
|
476
496
|
const byName = state.boxes.find((b) => b.name === q);
|
|
477
497
|
if (byName) return { kind: "ok", box: byName };
|
|
498
|
+
const byDisplayName = state.boxes.find((b) => b.displayName === q);
|
|
499
|
+
if (byDisplayName) return { kind: "ok", box: byDisplayName };
|
|
478
500
|
const byContainer = state.boxes.find((b) => b.container === q);
|
|
479
501
|
if (byContainer) return { kind: "ok", box: byContainer };
|
|
480
502
|
return { kind: "none" };
|
|
@@ -562,6 +584,191 @@ var GitWorktreeError = class extends Error {
|
|
|
562
584
|
function hostOpenCommand() {
|
|
563
585
|
return process.platform === "linux" ? "xdg-open" : "open";
|
|
564
586
|
}
|
|
587
|
+
function sshConfigPath() {
|
|
588
|
+
return join3(homedir2(), ".ssh", "config");
|
|
589
|
+
}
|
|
590
|
+
function agentboxSshConfigPath() {
|
|
591
|
+
return join3(homedir2(), ".agentbox", "ssh", "config");
|
|
592
|
+
}
|
|
593
|
+
function stateFilePath() {
|
|
594
|
+
return join3(homedir2(), ".agentbox", "state.json");
|
|
595
|
+
}
|
|
596
|
+
var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
|
|
597
|
+
var INCLUDE_END = "# END agentbox ssh include";
|
|
598
|
+
function beginMarker(alias) {
|
|
599
|
+
return `# BEGIN agentbox cloud box ${alias}`;
|
|
600
|
+
}
|
|
601
|
+
function endMarker(alias) {
|
|
602
|
+
return `# END agentbox cloud box ${alias}`;
|
|
603
|
+
}
|
|
604
|
+
function agentboxAliasFor(boxName) {
|
|
605
|
+
return boxName;
|
|
606
|
+
}
|
|
607
|
+
async function readFileOrEmpty(path) {
|
|
608
|
+
try {
|
|
609
|
+
return await fs.readFile(path, "utf8");
|
|
610
|
+
} catch (err) {
|
|
611
|
+
if (err.code === "ENOENT") return "";
|
|
612
|
+
throw err;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function buildBlock(opts) {
|
|
616
|
+
const lines = [
|
|
617
|
+
beginMarker(opts.alias),
|
|
618
|
+
`Host ${opts.alias}`,
|
|
619
|
+
` HostName ${opts.hostname}`,
|
|
620
|
+
` User ${opts.user}`
|
|
621
|
+
];
|
|
622
|
+
if (opts.identityFile) {
|
|
623
|
+
lines.push(` IdentityFile ${opts.identityFile}`);
|
|
624
|
+
lines.push(` IdentitiesOnly yes`);
|
|
625
|
+
}
|
|
626
|
+
lines.push(
|
|
627
|
+
` StrictHostKeyChecking accept-new`,
|
|
628
|
+
` UserKnownHostsFile /dev/null`,
|
|
629
|
+
` LogLevel ERROR`,
|
|
630
|
+
endMarker(opts.alias),
|
|
631
|
+
""
|
|
632
|
+
);
|
|
633
|
+
return lines.join("\n");
|
|
634
|
+
}
|
|
635
|
+
function stripLegacyInlineBlocks(contents) {
|
|
636
|
+
const pattern = /^# BEGIN agentbox cloud box .*\n[\s\S]*?^# END agentbox cloud box .*\n?/gm;
|
|
637
|
+
return contents.replace(pattern, "");
|
|
638
|
+
}
|
|
639
|
+
function hasIncludeBlock(contents) {
|
|
640
|
+
return contents.includes(INCLUDE_BEGIN) || contents.includes(`Include ${agentboxSshConfigPath()}`);
|
|
641
|
+
}
|
|
642
|
+
async function ensureSshInclude() {
|
|
643
|
+
const path = sshConfigPath();
|
|
644
|
+
await fs.mkdir(join3(homedir2(), ".ssh"), { recursive: true, mode: 448 });
|
|
645
|
+
const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
|
|
646
|
+
let next = existing;
|
|
647
|
+
if (!hasIncludeBlock(existing)) {
|
|
648
|
+
const block = `${INCLUDE_BEGIN}
|
|
649
|
+
Include ${agentboxSshConfigPath()}
|
|
650
|
+
${INCLUDE_END}
|
|
651
|
+
`;
|
|
652
|
+
next = existing.length === 0 ? block : `${block}
|
|
653
|
+
${existing}`;
|
|
654
|
+
}
|
|
655
|
+
await fs.writeFile(path, next, { mode: 384 });
|
|
656
|
+
await fs.chmod(path, 384);
|
|
657
|
+
}
|
|
658
|
+
async function syncAgentboxSshConfig(statePath = stateFilePath()) {
|
|
659
|
+
const state = await readState(statePath);
|
|
660
|
+
const blocks = [];
|
|
661
|
+
for (const box of state.boxes) {
|
|
662
|
+
const ssh = box.cloud?.ssh;
|
|
663
|
+
if (!ssh) continue;
|
|
664
|
+
blocks.push(
|
|
665
|
+
buildBlock({
|
|
666
|
+
alias: agentboxAliasFor(box.name),
|
|
667
|
+
hostname: ssh.host,
|
|
668
|
+
user: ssh.user,
|
|
669
|
+
identityFile: ssh.identityFile
|
|
670
|
+
})
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
const header = "# Managed by agentbox \u2014 regenerated on box create/start/destroy.\n# Do not edit; changes are overwritten. Disable with `agentbox config set ssh.autoConfig false`.\n\n";
|
|
674
|
+
const path = agentboxSshConfigPath();
|
|
675
|
+
await fs.mkdir(dirname22(path), { recursive: true, mode: 448 });
|
|
676
|
+
await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
|
|
677
|
+
await fs.chmod(path, 384);
|
|
678
|
+
await ensureSshInclude();
|
|
679
|
+
}
|
|
680
|
+
async function hasUnmanagedHostConflict(alias) {
|
|
681
|
+
const contents = stripLegacyInlineBlocks(await readFileOrEmpty(sshConfigPath()));
|
|
682
|
+
if (contents === "") return false;
|
|
683
|
+
return contents.split("\n").some((line) => {
|
|
684
|
+
const m = /^\s*Host\s+(.+?)\s*$/.exec(line);
|
|
685
|
+
if (!m) return false;
|
|
686
|
+
return m[1].split(/\s+/).includes(alias);
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
function parseSshTarget(argv) {
|
|
690
|
+
let target;
|
|
691
|
+
for (let i = argv.length - 1; i >= 0; i--) {
|
|
692
|
+
const v = argv[i];
|
|
693
|
+
if (!v || v.startsWith("-")) continue;
|
|
694
|
+
const at = v.indexOf("@");
|
|
695
|
+
if (at <= 0) continue;
|
|
696
|
+
target = { user: v.slice(0, at), host: v.slice(at + 1) };
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
699
|
+
if (!target) return void 0;
|
|
700
|
+
let identityFile;
|
|
701
|
+
for (let i = 0; i < argv.length - 1; i++) {
|
|
702
|
+
if (argv[i] === "-i") {
|
|
703
|
+
identityFile = argv[i + 1];
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return { ...target, identityFile };
|
|
708
|
+
}
|
|
709
|
+
async function readAgentboxSshAlias(alias) {
|
|
710
|
+
const contents = await readFileOrEmpty(agentboxSshConfigPath());
|
|
711
|
+
if (contents === "") return void 0;
|
|
712
|
+
const begin = beginMarker(alias);
|
|
713
|
+
const end = endMarker(alias);
|
|
714
|
+
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
715
|
+
const match = new RegExp(`^${escape(begin)}\\n([\\s\\S]*?)${escape(end)}`, "m").exec(contents);
|
|
716
|
+
if (!match) return void 0;
|
|
717
|
+
const body = match[1] ?? "";
|
|
718
|
+
const field = (name) => new RegExp(`^\\s*${name}\\s+(.+)$`, "m").exec(body)?.[1]?.trim();
|
|
719
|
+
return { hostName: field("HostName"), identityFile: field("IdentityFile") };
|
|
720
|
+
}
|
|
721
|
+
async function resolveCloudSshTarget(box, provider, opts = {}) {
|
|
722
|
+
if (!provider.buildAttach) {
|
|
723
|
+
throw new Error(`cloud provider '${provider.name}' does not support SSH attach`);
|
|
724
|
+
}
|
|
725
|
+
if (opts.bringOnline ?? true) {
|
|
726
|
+
const state = await provider.probeState(box);
|
|
727
|
+
if (state === "paused") {
|
|
728
|
+
opts.logInfo?.("box is paused; resuming");
|
|
729
|
+
await provider.resume(box);
|
|
730
|
+
} else if (state === "stopped") {
|
|
731
|
+
opts.logInfo?.("box is stopped; starting");
|
|
732
|
+
await provider.start(box);
|
|
733
|
+
} else if (state === "missing") {
|
|
734
|
+
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
const spec = await provider.buildAttach(box, "shell", { noTmux: true });
|
|
738
|
+
const target = parseSshTarget(spec.argv);
|
|
739
|
+
if (!target) {
|
|
740
|
+
throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
|
|
741
|
+
}
|
|
742
|
+
const alias = agentboxAliasFor(box.name);
|
|
743
|
+
return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
|
|
744
|
+
}
|
|
745
|
+
async function ensureCloudSshAlias(box, provider, opts = {}) {
|
|
746
|
+
const conn = await resolveCloudSshTarget(box, provider, opts);
|
|
747
|
+
await recordBoxSsh(box.id, {
|
|
748
|
+
host: conn.host,
|
|
749
|
+
user: conn.user,
|
|
750
|
+
identityFile: conn.identityFile
|
|
751
|
+
});
|
|
752
|
+
await syncAgentboxSshConfig();
|
|
753
|
+
return conn;
|
|
754
|
+
}
|
|
755
|
+
async function autoWriteSshConfig(box, provider, enabled, logWarn) {
|
|
756
|
+
if (!enabled) return;
|
|
757
|
+
try {
|
|
758
|
+
const conn = await resolveCloudSshTarget(box, provider, { bringOnline: false });
|
|
759
|
+
if (!conn.identityFile) return;
|
|
760
|
+
await recordBoxSsh(box.id, {
|
|
761
|
+
host: conn.host,
|
|
762
|
+
user: conn.user,
|
|
763
|
+
identityFile: conn.identityFile
|
|
764
|
+
});
|
|
765
|
+
await syncAgentboxSshConfig();
|
|
766
|
+
} catch (err) {
|
|
767
|
+
logWarn?.(
|
|
768
|
+
`ssh-config auto-write for ${box.name} failed: ${err instanceof Error ? err.message : String(err)}`
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
565
772
|
var BOX_WORKSPACE = "/workspace";
|
|
566
773
|
function run(provider, box, argv) {
|
|
567
774
|
return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
|
|
@@ -637,13 +844,13 @@ function errSummary(err) {
|
|
|
637
844
|
return err instanceof Error ? firstLine(err.message) : String(err);
|
|
638
845
|
}
|
|
639
846
|
function secretsEnvPath() {
|
|
640
|
-
return resolve(
|
|
847
|
+
return resolve(homedir3(), ".agentbox", "secrets.env");
|
|
641
848
|
}
|
|
642
849
|
function writeManagedSecrets(managedKeys, record) {
|
|
643
850
|
for (const k of managedKeys) delete process.env[k];
|
|
644
851
|
for (const [k, v] of Object.entries(record)) process.env[k] = v;
|
|
645
852
|
const path = secretsEnvPath();
|
|
646
|
-
mkdirSync(
|
|
853
|
+
mkdirSync(dirname3(path), { recursive: true });
|
|
647
854
|
let existing = "";
|
|
648
855
|
if (existsSync(path)) {
|
|
649
856
|
try {
|
|
@@ -674,7 +881,7 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
674
881
|
} catch {
|
|
675
882
|
}
|
|
676
883
|
}
|
|
677
|
-
var PLUGINS_FILE =
|
|
884
|
+
var PLUGINS_FILE = join4(homedir4(), ".agentbox", "plugins.json");
|
|
678
885
|
var SUPPORTED_SDK_API_VERSIONS = [1];
|
|
679
886
|
function isSupportedApiVersion(v) {
|
|
680
887
|
return SUPPORTED_SDK_API_VERSIONS.includes(v);
|
|
@@ -685,7 +892,7 @@ var LOCK_ACQUIRE_TIMEOUT_MS2 = 2e4;
|
|
|
685
892
|
var LOCK_RETRY_MS2 = 25;
|
|
686
893
|
async function withFileLock(path, fn) {
|
|
687
894
|
const lockPath = `${path}.lock`;
|
|
688
|
-
await mkdir2(
|
|
895
|
+
await mkdir2(dirname4(path), { recursive: true });
|
|
689
896
|
const deadline = Date.now() + LOCK_ACQUIRE_TIMEOUT_MS2;
|
|
690
897
|
let held = false;
|
|
691
898
|
while (!held) {
|
|
@@ -757,7 +964,7 @@ async function readForWrite(path) {
|
|
|
757
964
|
return p;
|
|
758
965
|
}
|
|
759
966
|
async function writeRegistry(file, path = PLUGINS_FILE) {
|
|
760
|
-
await mkdir2(
|
|
967
|
+
await mkdir2(dirname4(path), { recursive: true });
|
|
761
968
|
const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
|
|
762
969
|
await writeFile2(tmp, JSON.stringify(file, null, 2) + "\n", "utf8");
|
|
763
970
|
await rename2(tmp, path);
|
|
@@ -804,7 +1011,7 @@ function wantsRender(e) {
|
|
|
804
1011
|
async function renderCarryEntries(entries, ctx, onLog) {
|
|
805
1012
|
if (!entries.some(wantsRender)) return entries;
|
|
806
1013
|
const context = carryPlaceholderContext(ctx);
|
|
807
|
-
const stage = await mkdtemp(
|
|
1014
|
+
const stage = await mkdtemp(join5(tmpdir(), "agentbox-carry-render-"));
|
|
808
1015
|
const out = [];
|
|
809
1016
|
for (const [i, entry] of entries.entries()) {
|
|
810
1017
|
if (!wantsRender(entry)) {
|
|
@@ -818,7 +1025,7 @@ async function renderCarryEntries(entries, ctx, onLog) {
|
|
|
818
1025
|
context,
|
|
819
1026
|
onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
|
|
820
1027
|
});
|
|
821
|
-
const tmp =
|
|
1028
|
+
const tmp = join5(stage, `${String(i)}-${basename2(entry.absSrc)}`);
|
|
822
1029
|
await writeFile3(tmp, rendered, "utf8");
|
|
823
1030
|
out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
|
|
824
1031
|
const what = [
|
|
@@ -874,7 +1081,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
874
1081
|
credential: {
|
|
875
1082
|
boxRelPath: ".credentials.json",
|
|
876
1083
|
boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
|
|
877
|
-
hostBackup:
|
|
1084
|
+
hostBackup: join6(STATE_DIR, "claude-credentials.json"),
|
|
878
1085
|
cloudMountPath: "/home/vscode/.agentbox-creds/claude",
|
|
879
1086
|
cloudSubpath: "claude/",
|
|
880
1087
|
realShape: "claude-oauth"
|
|
@@ -934,7 +1141,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
934
1141
|
credential: {
|
|
935
1142
|
boxRelPath: "auth.json",
|
|
936
1143
|
boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
|
|
937
|
-
hostBackup:
|
|
1144
|
+
hostBackup: join6(STATE_DIR, "codex-credentials.json"),
|
|
938
1145
|
cloudMountPath: "/home/vscode/.agentbox-creds/codex",
|
|
939
1146
|
cloudSubpath: "codex/",
|
|
940
1147
|
realShape: "nonempty-json"
|
|
@@ -985,7 +1192,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
985
1192
|
credential: {
|
|
986
1193
|
boxRelPath: "auth.json",
|
|
987
1194
|
boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
|
|
988
|
-
hostBackup:
|
|
1195
|
+
hostBackup: join6(STATE_DIR, "opencode-credentials.json"),
|
|
989
1196
|
cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
|
|
990
1197
|
cloudSubpath: "opencode/",
|
|
991
1198
|
realShape: "nonempty-json"
|
|
@@ -1019,7 +1226,7 @@ function makeSyncContext(init) {
|
|
|
1019
1226
|
hostWorkspace: init.hostWorkspace,
|
|
1020
1227
|
projectRoot: init.projectRoot ?? init.hostWorkspace,
|
|
1021
1228
|
boxWorkspace: init.boxWorkspace ?? "/workspace",
|
|
1022
|
-
hostHome: init.hostHome ??
|
|
1229
|
+
hostHome: init.hostHome ?? homedir5(),
|
|
1023
1230
|
onLog: init.onLog ?? (() => {
|
|
1024
1231
|
})
|
|
1025
1232
|
};
|
|
@@ -1091,8 +1298,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
|
|
|
1091
1298
|
async function pushEnvFiles(ctx, transport, patterns) {
|
|
1092
1299
|
const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
|
|
1093
1300
|
if (list.length === 0) return { copied: 0 };
|
|
1094
|
-
const stage = await mkdtemp2(
|
|
1095
|
-
const localTar =
|
|
1301
|
+
const stage = await mkdtemp2(join7(tmpdir2(), "agentbox-envfiles-"));
|
|
1302
|
+
const localTar = join7(stage, "envfiles.tar");
|
|
1096
1303
|
try {
|
|
1097
1304
|
const packed = await execa2(
|
|
1098
1305
|
"tar",
|
|
@@ -1164,9 +1371,9 @@ function encodeClaudeProjectsKey(absPath) {
|
|
|
1164
1371
|
return absPath.replace(/[^a-zA-Z0-9]/g, "-");
|
|
1165
1372
|
}
|
|
1166
1373
|
var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
|
|
1167
|
-
async function resolveClaudeMemoryDir(hostWorkspace, hostHome =
|
|
1374
|
+
async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir6()) {
|
|
1168
1375
|
if (hostWorkspace.length === 0) return null;
|
|
1169
|
-
const memDir =
|
|
1376
|
+
const memDir = join8(
|
|
1170
1377
|
hostHome,
|
|
1171
1378
|
".claude",
|
|
1172
1379
|
"projects",
|
|
@@ -1209,8 +1416,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
|
|
|
1209
1416
|
return;
|
|
1210
1417
|
}
|
|
1211
1418
|
for (const ent of entries) {
|
|
1212
|
-
const realFull =
|
|
1213
|
-
const virtualFull = virtualDir ?
|
|
1419
|
+
const realFull = join9(realDir, ent.name);
|
|
1420
|
+
const virtualFull = virtualDir ? join9(virtualDir, ent.name) : ent.name;
|
|
1214
1421
|
if (ent.isSymbolicLink()) {
|
|
1215
1422
|
let real;
|
|
1216
1423
|
try {
|
|
@@ -1313,7 +1520,7 @@ async function extractCredentials(transport, opts = {}) {
|
|
|
1313
1520
|
try {
|
|
1314
1521
|
const text = await transport.readText(spec.credential.boxAbsPath);
|
|
1315
1522
|
if (!text || !isRealAgentCredential(spec.id, text)) continue;
|
|
1316
|
-
await mkdir3(
|
|
1523
|
+
await mkdir3(dirname5(hostBackup), { recursive: true });
|
|
1317
1524
|
await writeFile4(hostBackup, text, { mode: 384 });
|
|
1318
1525
|
await chmod(hostBackup, 384).catch(() => {
|
|
1319
1526
|
});
|
|
@@ -1475,7 +1682,7 @@ function makeHostGitPorts() {
|
|
|
1475
1682
|
return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
|
|
1476
1683
|
},
|
|
1477
1684
|
async hashHostFile(hostMain, relPath) {
|
|
1478
|
-
return createHash("sha256").update(await readFile5(
|
|
1685
|
+
return createHash("sha256").update(await readFile5(join10(hostMain, relPath))).digest("hex");
|
|
1479
1686
|
},
|
|
1480
1687
|
async packHostFiles(hostMain, relPaths) {
|
|
1481
1688
|
const tarOut = await execa3("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
|
|
@@ -1508,7 +1715,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
1508
1715
|
const out = [];
|
|
1509
1716
|
for (const ent of entries) {
|
|
1510
1717
|
const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
|
|
1511
|
-
const full =
|
|
1718
|
+
const full = join11(root, ent.name);
|
|
1512
1719
|
if (ent.isDirectory()) {
|
|
1513
1720
|
out.push(...await walkFiles(full, rel));
|
|
1514
1721
|
} else if (ent.isFile()) {
|
|
@@ -1532,12 +1739,12 @@ async function buildHostSet(name, hostDir, boxDst) {
|
|
|
1532
1739
|
const rels = await walkFiles(hostDir);
|
|
1533
1740
|
const files = {};
|
|
1534
1741
|
for (const rel of rels) {
|
|
1535
|
-
files[rel] = await hashFile(
|
|
1742
|
+
files[rel] = await hashFile(join11(hostDir, rel));
|
|
1536
1743
|
}
|
|
1537
1744
|
return { dst: boxDst, files, hostDir };
|
|
1538
1745
|
}
|
|
1539
|
-
async function buildHostSyncManifest(workspacePath, hostHome =
|
|
1540
|
-
const workflowsDir =
|
|
1746
|
+
async function buildHostSyncManifest(workspacePath, hostHome = homedir7()) {
|
|
1747
|
+
const workflowsDir = join11(hostHome, ".claude", "workflows");
|
|
1541
1748
|
const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
|
|
1542
1749
|
const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
|
|
1543
1750
|
const [workflows, memory] = await Promise.all([
|
|
@@ -1559,7 +1766,7 @@ function computeSyncDelta(host, box) {
|
|
|
1559
1766
|
uploads.push({
|
|
1560
1767
|
set: name,
|
|
1561
1768
|
rel,
|
|
1562
|
-
absSrc:
|
|
1769
|
+
absSrc: join11(hostSet.hostDir, rel),
|
|
1563
1770
|
dst: `${hostSet.dst}/${rel}`
|
|
1564
1771
|
});
|
|
1565
1772
|
}
|
|
@@ -1578,15 +1785,15 @@ async function stageDynamicSyncTarball(uploads) {
|
|
|
1578
1785
|
return { tarballPath: null, cleanup: async () => {
|
|
1579
1786
|
} };
|
|
1580
1787
|
}
|
|
1581
|
-
const stageDir = await mkdtemp3(
|
|
1788
|
+
const stageDir = await mkdtemp3(join11(tmpdir3(), "agentbox-dynsync-stage-"));
|
|
1582
1789
|
let tarballPath = null;
|
|
1583
1790
|
try {
|
|
1584
1791
|
for (const up of uploads) {
|
|
1585
|
-
const target =
|
|
1586
|
-
await mkdir4(
|
|
1792
|
+
const target = join11(stageDir, up.set, up.rel);
|
|
1793
|
+
await mkdir4(dirname6(target), { recursive: true });
|
|
1587
1794
|
await copyFile(up.absSrc, target);
|
|
1588
1795
|
}
|
|
1589
|
-
tarballPath =
|
|
1796
|
+
tarballPath = join11(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
|
|
1590
1797
|
await execa4("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
1591
1798
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1592
1799
|
});
|
|
@@ -1720,7 +1927,7 @@ var BOX_WORKSPACE2 = "/workspace";
|
|
|
1720
1927
|
var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
|
|
1721
1928
|
trust_level = "trusted"
|
|
1722
1929
|
`;
|
|
1723
|
-
function sanitizeCodexConfigForBox(tomlText, hostHome =
|
|
1930
|
+
function sanitizeCodexConfigForBox(tomlText, hostHome = homedir8()) {
|
|
1724
1931
|
const cfg = parse(tomlText);
|
|
1725
1932
|
let changed = false;
|
|
1726
1933
|
if (isRecord(cfg["mcp_servers"])) {
|
|
@@ -1788,7 +1995,7 @@ async function findBrokenSymlinks(root) {
|
|
|
1788
1995
|
return;
|
|
1789
1996
|
}
|
|
1790
1997
|
for (const ent of entries) {
|
|
1791
|
-
const full =
|
|
1998
|
+
const full = join12(dir, ent.name);
|
|
1792
1999
|
if (ent.isSymbolicLink()) {
|
|
1793
2000
|
try {
|
|
1794
2001
|
await stat8(full);
|
|
@@ -1804,14 +2011,14 @@ async function findBrokenSymlinks(root) {
|
|
|
1804
2011
|
return broken;
|
|
1805
2012
|
}
|
|
1806
2013
|
async function mkStageDir(prefix) {
|
|
1807
|
-
return mkdtemp4(
|
|
2014
|
+
return mkdtemp4(join12(tmpdir4(), `agentbox-${prefix}-stage-`));
|
|
1808
2015
|
}
|
|
1809
2016
|
function emptyResult(warnings = []) {
|
|
1810
2017
|
return { tarballPath: null, cleanup: async () => {
|
|
1811
2018
|
}, warnings };
|
|
1812
2019
|
}
|
|
1813
2020
|
async function tarballFromDir(stageDir, agent) {
|
|
1814
|
-
const tarballPath =
|
|
2021
|
+
const tarballPath = join12(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
|
|
1815
2022
|
await execa5("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
1816
2023
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1817
2024
|
});
|
|
@@ -1828,7 +2035,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
1828
2035
|
const stageDir = await mkStageDir(agent);
|
|
1829
2036
|
let tarballPath = null;
|
|
1830
2037
|
try {
|
|
1831
|
-
await copyFile2(sourcePath,
|
|
2038
|
+
await copyFile2(sourcePath, join12(stageDir, tarballEntryName));
|
|
1832
2039
|
tarballPath = await tarballFromDir(stageDir, agent);
|
|
1833
2040
|
return {
|
|
1834
2041
|
tarballPath,
|
|
@@ -1844,7 +2051,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
1844
2051
|
var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
|
|
1845
2052
|
async function buildBoxClaudeJsonFromHost(opts) {
|
|
1846
2053
|
const { hostHome, hostWorkspace } = opts;
|
|
1847
|
-
const hostClaudeJson =
|
|
2054
|
+
const hostClaudeJson = join12(hostHome, ".claude.json");
|
|
1848
2055
|
let working;
|
|
1849
2056
|
if (await pathExists4(hostClaudeJson)) {
|
|
1850
2057
|
try {
|
|
@@ -1879,7 +2086,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
|
|
|
1879
2086
|
return working;
|
|
1880
2087
|
}
|
|
1881
2088
|
async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
1882
|
-
const hostHome = opts.hostHome ??
|
|
2089
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
1883
2090
|
const stageDir = await mkStageDir("claude-json-only");
|
|
1884
2091
|
let tarballPath = null;
|
|
1885
2092
|
try {
|
|
@@ -1887,7 +2094,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
1887
2094
|
hostHome,
|
|
1888
2095
|
hostWorkspace: opts.hostWorkspace
|
|
1889
2096
|
});
|
|
1890
|
-
await writeFile5(
|
|
2097
|
+
await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
1891
2098
|
tarballPath = await tarballFromDir(stageDir, "claude-json-only");
|
|
1892
2099
|
return {
|
|
1893
2100
|
tarballPath,
|
|
@@ -1901,8 +2108,8 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
1901
2108
|
}
|
|
1902
2109
|
}
|
|
1903
2110
|
async function stageClaudeStaticForUpload(opts = {}) {
|
|
1904
|
-
const hostHome = opts.hostHome ??
|
|
1905
|
-
const hostClaude =
|
|
2111
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2112
|
+
const hostClaude = join12(hostHome, ".claude");
|
|
1906
2113
|
if (!await pathExists4(hostClaude)) return emptyResult();
|
|
1907
2114
|
const stageDir = await mkStageDir("claude-static");
|
|
1908
2115
|
let tarballPath = null;
|
|
@@ -1919,7 +2126,7 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
1919
2126
|
`${hostClaude}/`,
|
|
1920
2127
|
`${stageDir}/`
|
|
1921
2128
|
]);
|
|
1922
|
-
const settingsPath =
|
|
2129
|
+
const settingsPath = join12(stageDir, "settings.json");
|
|
1923
2130
|
if (await pathExists4(settingsPath)) {
|
|
1924
2131
|
try {
|
|
1925
2132
|
const parsed = JSON.parse(await readFile7(settingsPath, "utf8"));
|
|
@@ -1934,14 +2141,14 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
1934
2141
|
hostHome,
|
|
1935
2142
|
hostWorkspace: opts.hostWorkspace
|
|
1936
2143
|
});
|
|
1937
|
-
await writeFile5(
|
|
1938
|
-
const pluginsDir =
|
|
2144
|
+
await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2145
|
+
const pluginsDir = join12(stageDir, "plugins");
|
|
1939
2146
|
if (await pathExists4(pluginsDir)) {
|
|
1940
2147
|
try {
|
|
1941
2148
|
const entries = await readdir5(pluginsDir, { withFileTypes: true });
|
|
1942
2149
|
for (const ent of entries) {
|
|
1943
2150
|
if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
|
|
1944
|
-
const file =
|
|
2151
|
+
const file = join12(pluginsDir, ent.name);
|
|
1945
2152
|
const raw = await readFile7(file, "utf8");
|
|
1946
2153
|
const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
|
|
1947
2154
|
if (replaced !== raw) await writeFile5(file, replaced);
|
|
@@ -1976,8 +2183,8 @@ async function sanitizeStagedCodexConfig(configPath, hostHome) {
|
|
|
1976
2183
|
}
|
|
1977
2184
|
}
|
|
1978
2185
|
async function stageCodexStaticForUpload(opts = {}) {
|
|
1979
|
-
const hostHome = opts.hostHome ??
|
|
1980
|
-
const hostCodex =
|
|
2186
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2187
|
+
const hostCodex = join12(hostHome, ".codex");
|
|
1981
2188
|
if (!await pathExists4(hostCodex)) return emptyResult();
|
|
1982
2189
|
const stageDir = await mkStageDir("codex-static");
|
|
1983
2190
|
let tarballPath = null;
|
|
@@ -1991,7 +2198,7 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
1991
2198
|
`${hostCodex}/`,
|
|
1992
2199
|
`${stageDir}/`
|
|
1993
2200
|
]);
|
|
1994
|
-
await sanitizeStagedCodexConfig(
|
|
2201
|
+
await sanitizeStagedCodexConfig(join12(stageDir, "config.toml"), hostHome);
|
|
1995
2202
|
tarballPath = await tarballFromDir(stageDir, "codex-static");
|
|
1996
2203
|
return {
|
|
1997
2204
|
tarballPath,
|
|
@@ -2005,8 +2212,8 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2005
2212
|
}
|
|
2006
2213
|
}
|
|
2007
2214
|
async function stageAgentsStaticForUpload(opts = {}) {
|
|
2008
|
-
const hostHome = opts.hostHome ??
|
|
2009
|
-
const hostAgents =
|
|
2215
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2216
|
+
const hostAgents = join12(hostHome, ".agents");
|
|
2010
2217
|
if (!await pathExists4(hostAgents)) return emptyResult();
|
|
2011
2218
|
const stageDir = await mkStageDir("agents-static");
|
|
2012
2219
|
let tarballPath = null;
|
|
@@ -2032,20 +2239,20 @@ async function stageAgentsStaticForUpload(opts = {}) {
|
|
|
2032
2239
|
}
|
|
2033
2240
|
}
|
|
2034
2241
|
async function stageCodexCredentialsForUpload(opts = {}) {
|
|
2035
|
-
const hostHome = opts.hostHome ??
|
|
2036
|
-
const cloudBackup =
|
|
2242
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2243
|
+
const cloudBackup = join12(hostHome, ".agentbox", "codex-credentials.json");
|
|
2037
2244
|
if (await pathExists4(cloudBackup)) {
|
|
2038
2245
|
return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
|
|
2039
2246
|
}
|
|
2040
|
-
const hostAuth =
|
|
2247
|
+
const hostAuth = join12(hostHome, ".codex", "auth.json");
|
|
2041
2248
|
if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
|
|
2042
2249
|
return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
|
|
2043
2250
|
}
|
|
2044
2251
|
var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
|
|
2045
2252
|
async function stageOpencodeStaticForUpload(opts = {}) {
|
|
2046
|
-
const hostHome = opts.hostHome ??
|
|
2047
|
-
const hostData =
|
|
2048
|
-
const hostConfig =
|
|
2253
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2254
|
+
const hostData = join12(hostHome, ".local", "share", "opencode");
|
|
2255
|
+
const hostConfig = join12(hostHome, ".config", "opencode");
|
|
2049
2256
|
const hasData = await pathExists4(hostData);
|
|
2050
2257
|
const hasConfig = await pathExists4(hostConfig);
|
|
2051
2258
|
if (!hasData && !hasConfig) return emptyResult();
|
|
@@ -2064,7 +2271,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2064
2271
|
]);
|
|
2065
2272
|
}
|
|
2066
2273
|
if (hasConfig) {
|
|
2067
|
-
const configStage =
|
|
2274
|
+
const configStage = join12(stageDir, "config");
|
|
2068
2275
|
const cfgBroken = await findBrokenSymlinks(hostConfig);
|
|
2069
2276
|
await execa5("rsync", [
|
|
2070
2277
|
"-a",
|
|
@@ -2087,18 +2294,18 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2087
2294
|
}
|
|
2088
2295
|
}
|
|
2089
2296
|
async function stageOpencodeCredentialsForUpload(opts = {}) {
|
|
2090
|
-
const hostHome = opts.hostHome ??
|
|
2091
|
-
const cloudBackup =
|
|
2297
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2298
|
+
const cloudBackup = join12(hostHome, ".agentbox", "opencode-credentials.json");
|
|
2092
2299
|
if (await pathExists4(cloudBackup)) {
|
|
2093
2300
|
return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
|
|
2094
2301
|
}
|
|
2095
|
-
const hostAuth =
|
|
2302
|
+
const hostAuth = join12(hostHome, ".local", "share", "opencode", "auth.json");
|
|
2096
2303
|
if (!await pathExists4(hostAuth)) return emptyResult();
|
|
2097
2304
|
return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
|
|
2098
2305
|
}
|
|
2099
2306
|
async function stageOpencodeStateForUpload(opts = {}) {
|
|
2100
|
-
const hostHome = opts.hostHome ??
|
|
2101
|
-
const hostModel =
|
|
2307
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2308
|
+
const hostModel = join12(hostHome, ".local", "state", "opencode", "model.json");
|
|
2102
2309
|
if (!await pathExists4(hostModel)) return emptyResult();
|
|
2103
2310
|
return stageSingleFileTarball("opencode-state", hostModel, "model.json");
|
|
2104
2311
|
}
|
|
@@ -2124,7 +2331,7 @@ function preparedStatePathFor(provider) {
|
|
|
2124
2331
|
if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
|
|
2125
2332
|
throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
|
|
2126
2333
|
}
|
|
2127
|
-
return pathResolve(
|
|
2334
|
+
return pathResolve(homedir10(), ".agentbox", `${provider}-prepared.json`);
|
|
2128
2335
|
}
|
|
2129
2336
|
function readPreparedStateRaw(provider) {
|
|
2130
2337
|
const path = preparedStatePathFor(provider);
|
|
@@ -2137,7 +2344,7 @@ function readPreparedStateRaw(provider) {
|
|
|
2137
2344
|
}
|
|
2138
2345
|
function writePreparedStateRaw(provider, state) {
|
|
2139
2346
|
const path = preparedStatePathFor(provider);
|
|
2140
|
-
mkdirSync2(
|
|
2347
|
+
mkdirSync2(dirname7(path), { recursive: true });
|
|
2141
2348
|
const body = JSON.stringify(state, null, 2) + "\n";
|
|
2142
2349
|
const tmp = `${path}.tmp`;
|
|
2143
2350
|
writeFileSync2(tmp, body, { mode: 384 });
|
|
@@ -2226,11 +2433,11 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
2226
2433
|
import { execa as execa6 } from "execa";
|
|
2227
2434
|
import { existsSync as existsSync4 } from "fs";
|
|
2228
2435
|
import { fileURLToPath } from "url";
|
|
2229
|
-
import { dirname as
|
|
2436
|
+
import { dirname as dirname8, resolve as resolve3 } from "path";
|
|
2230
2437
|
var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
|
|
2231
2438
|
async function resolveClaudeInstallMode() {
|
|
2232
2439
|
try {
|
|
2233
|
-
const { loadEffectiveConfig } = await import("./dist-
|
|
2440
|
+
const { loadEffectiveConfig } = await import("./dist-2BTJQUJS.js");
|
|
2234
2441
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
2235
2442
|
return cfg.effective.box.claudeInstall;
|
|
2236
2443
|
} catch {
|
|
@@ -2241,7 +2448,7 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
|
|
|
2241
2448
|
function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
|
|
2242
2449
|
return `${registry}:sha-${sha.slice(0, 16)}`;
|
|
2243
2450
|
}
|
|
2244
|
-
var here =
|
|
2451
|
+
var here = dirname8(fileURLToPath(import.meta.url));
|
|
2245
2452
|
function resolveDockerBuild() {
|
|
2246
2453
|
const override = process.env.AGENTBOX_DOCKER_CONTEXT;
|
|
2247
2454
|
if (override && existsSync4(resolve3(override, "Dockerfile.box"))) {
|
|
@@ -2332,7 +2539,7 @@ async function buildImage(opts = {}) {
|
|
|
2332
2539
|
return ref;
|
|
2333
2540
|
}
|
|
2334
2541
|
async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
2335
|
-
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-
|
|
2542
|
+
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-WPHOEDA6.js");
|
|
2336
2543
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
2337
2544
|
const allowPull = opts.allowPull !== false;
|
|
2338
2545
|
if (allowPull && registry && fingerprint) {
|
|
@@ -2359,7 +2566,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
|
2359
2566
|
return { source: "built" };
|
|
2360
2567
|
}
|
|
2361
2568
|
async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
2362
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-
|
|
2569
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-WPHOEDA6.js");
|
|
2363
2570
|
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
2364
2571
|
const rawFingerprint = await computeDockerContextFingerprint2({
|
|
2365
2572
|
contextDir: opts.contextDir
|
|
@@ -2460,6 +2667,7 @@ export {
|
|
|
2460
2667
|
readState,
|
|
2461
2668
|
recordBox,
|
|
2462
2669
|
recordLastAgent,
|
|
2670
|
+
setBoxDisplayName,
|
|
2463
2671
|
recordBoxSsh,
|
|
2464
2672
|
reserveProjectIndex,
|
|
2465
2673
|
removeBoxRecord,
|
|
@@ -2471,6 +2679,14 @@ export {
|
|
|
2471
2679
|
pickFreshBranch,
|
|
2472
2680
|
GitWorktreeError,
|
|
2473
2681
|
hostOpenCommand,
|
|
2682
|
+
agentboxSshConfigPath,
|
|
2683
|
+
agentboxAliasFor,
|
|
2684
|
+
syncAgentboxSshConfig,
|
|
2685
|
+
hasUnmanagedHostConflict,
|
|
2686
|
+
readAgentboxSshAlias,
|
|
2687
|
+
resolveCloudSshTarget,
|
|
2688
|
+
ensureCloudSshAlias,
|
|
2689
|
+
autoWriteSshConfig,
|
|
2474
2690
|
scratchBranchName,
|
|
2475
2691
|
boxGitCheckout,
|
|
2476
2692
|
boxGitNewBranch,
|
|
@@ -2558,4 +2774,4 @@ export {
|
|
|
2558
2774
|
writePreparedDockerState,
|
|
2559
2775
|
preparedMatches
|
|
2560
2776
|
};
|
|
2561
|
-
//# sourceMappingURL=chunk-
|
|
2777
|
+
//# sourceMappingURL=chunk-ES2DDCAC.js.map
|