@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
|
@@ -304,39 +304,42 @@ import { dirname as dirname2, join as join2 } from "path";
|
|
|
304
304
|
import { setTimeout as delay } from "timers/promises";
|
|
305
305
|
import { readdir, stat as stat2 } from "fs/promises";
|
|
306
306
|
import { join as join22 } from "path";
|
|
307
|
-
import {
|
|
307
|
+
import { promises as fs } from "fs";
|
|
308
308
|
import { homedir as homedir22 } from "os";
|
|
309
|
-
import { dirname as dirname22,
|
|
310
|
-
import { existsSync
|
|
309
|
+
import { dirname as dirname22, join as join3 } from "path";
|
|
310
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
311
311
|
import { homedir as homedir3 } from "os";
|
|
312
|
-
import { dirname as dirname3,
|
|
312
|
+
import { dirname as dirname3, resolve as resolve3 } from "path";
|
|
313
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
314
|
+
import { homedir as homedir4 } from "os";
|
|
315
|
+
import { dirname as dirname4, join as join4 } from "path";
|
|
313
316
|
import { mkdtemp, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
314
317
|
import { tmpdir } from "os";
|
|
315
|
-
import { basename as basename2, join as
|
|
316
|
-
import { join as join5 } from "path";
|
|
317
|
-
import { homedir as homedir4 } from "os";
|
|
318
|
-
import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
|
|
319
|
-
import { tmpdir as tmpdir2 } from "os";
|
|
318
|
+
import { basename as basename2, join as join5 } from "path";
|
|
320
319
|
import { join as join6 } from "path";
|
|
321
|
-
import { readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
322
320
|
import { homedir as homedir5 } from "os";
|
|
321
|
+
import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
|
|
322
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
323
323
|
import { join as join7 } from "path";
|
|
324
|
+
import { readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
325
|
+
import { homedir as homedir6 } from "os";
|
|
326
|
+
import { join as join8 } from "path";
|
|
324
327
|
import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
|
|
325
|
-
import { isAbsolute as isAbsolute3, join as
|
|
328
|
+
import { isAbsolute as isAbsolute3, join as join9, relative } from "path";
|
|
326
329
|
import { stat as stat6 } from "fs/promises";
|
|
327
330
|
import { chmod, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
328
|
-
import { dirname as
|
|
331
|
+
import { dirname as dirname5 } from "path";
|
|
329
332
|
import { createHash } from "crypto";
|
|
330
333
|
import { readFile as readFile5 } from "fs/promises";
|
|
331
|
-
import { join as
|
|
334
|
+
import { join as join10 } from "path";
|
|
332
335
|
import { createHash as createHash2 } from "crypto";
|
|
333
336
|
import { copyFile, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat7 } from "fs/promises";
|
|
334
|
-
import { homedir as
|
|
335
|
-
import { basename as basename22, dirname as
|
|
337
|
+
import { homedir as homedir7, tmpdir as tmpdir3 } from "os";
|
|
338
|
+
import { basename as basename22, dirname as dirname6, join as join11 } from "path";
|
|
336
339
|
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";
|
|
337
|
-
import { homedir as
|
|
338
|
-
import { basename as basename3, join as
|
|
339
|
-
import { homedir as
|
|
340
|
+
import { homedir as homedir9, tmpdir as tmpdir4 } from "os";
|
|
341
|
+
import { basename as basename3, join as join12, relative as relative2 } from "path";
|
|
342
|
+
import { homedir as homedir8 } from "os";
|
|
340
343
|
|
|
341
344
|
// ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
|
|
342
345
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
@@ -1163,8 +1166,8 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
1163
1166
|
import { createHash as createHash3 } from "crypto";
|
|
1164
1167
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
1165
1168
|
import { readFile as readFile8 } from "fs/promises";
|
|
1166
|
-
import { homedir as
|
|
1167
|
-
import { dirname as
|
|
1169
|
+
import { homedir as homedir10 } from "os";
|
|
1170
|
+
import { dirname as dirname7, resolve as pathResolve } from "path";
|
|
1168
1171
|
var STATE_DIR = join2(homedir2(), ".agentbox");
|
|
1169
1172
|
var STATE_FILE = join2(STATE_DIR, "state.json");
|
|
1170
1173
|
var EMPTY = { version: 1, boxes: [] };
|
|
@@ -1257,6 +1260,34 @@ async function recordLastAgent(boxId, kind, path = STATE_FILE) {
|
|
|
1257
1260
|
path
|
|
1258
1261
|
);
|
|
1259
1262
|
}
|
|
1263
|
+
async function setBoxDisplayName(boxId, displayName, path = STATE_FILE) {
|
|
1264
|
+
const trimmed = displayName?.trim();
|
|
1265
|
+
const next = trimmed ? trimmed : void 0;
|
|
1266
|
+
await mutateState(
|
|
1267
|
+
(state) => ({
|
|
1268
|
+
version: 1,
|
|
1269
|
+
boxes: state.boxes.map((b) => {
|
|
1270
|
+
if (b.id !== boxId) return b;
|
|
1271
|
+
if (next) return { ...b, displayName: next };
|
|
1272
|
+
const rest = { ...b };
|
|
1273
|
+
delete rest.displayName;
|
|
1274
|
+
return rest;
|
|
1275
|
+
})
|
|
1276
|
+
}),
|
|
1277
|
+
path
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
|
|
1281
|
+
await mutateState(
|
|
1282
|
+
(state) => ({
|
|
1283
|
+
version: 1,
|
|
1284
|
+
boxes: state.boxes.map(
|
|
1285
|
+
(b) => b.id === boxId && b.cloud ? { ...b, cloud: { ...b.cloud, ssh } } : b
|
|
1286
|
+
)
|
|
1287
|
+
}),
|
|
1288
|
+
path
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1260
1291
|
async function reserveProjectIndex(record, projectRoot, path = STATE_FILE) {
|
|
1261
1292
|
let index = 1;
|
|
1262
1293
|
await mutateState((state) => {
|
|
@@ -1310,6 +1341,8 @@ function findBox(idOrName, state) {
|
|
|
1310
1341
|
if (prefixMatches.length > 1) return { kind: "ambiguous", matches: prefixMatches };
|
|
1311
1342
|
const byName = state.boxes.find((b) => b.name === q);
|
|
1312
1343
|
if (byName) return { kind: "ok", box: byName };
|
|
1344
|
+
const byDisplayName = state.boxes.find((b) => b.displayName === q);
|
|
1345
|
+
if (byDisplayName) return { kind: "ok", box: byDisplayName };
|
|
1313
1346
|
const byContainer = state.boxes.find((b) => b.container === q);
|
|
1314
1347
|
if (byContainer) return { kind: "ok", box: byContainer };
|
|
1315
1348
|
return { kind: "none" };
|
|
@@ -1397,6 +1430,160 @@ var GitWorktreeError = class extends Error {
|
|
|
1397
1430
|
function hostOpenCommand() {
|
|
1398
1431
|
return process.platform === "linux" ? "xdg-open" : "open";
|
|
1399
1432
|
}
|
|
1433
|
+
function sshConfigPath() {
|
|
1434
|
+
return join3(homedir22(), ".ssh", "config");
|
|
1435
|
+
}
|
|
1436
|
+
function agentboxSshConfigPath() {
|
|
1437
|
+
return join3(homedir22(), ".agentbox", "ssh", "config");
|
|
1438
|
+
}
|
|
1439
|
+
function stateFilePath() {
|
|
1440
|
+
return join3(homedir22(), ".agentbox", "state.json");
|
|
1441
|
+
}
|
|
1442
|
+
var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
|
|
1443
|
+
var INCLUDE_END = "# END agentbox ssh include";
|
|
1444
|
+
function beginMarker(alias) {
|
|
1445
|
+
return `# BEGIN agentbox cloud box ${alias}`;
|
|
1446
|
+
}
|
|
1447
|
+
function endMarker(alias) {
|
|
1448
|
+
return `# END agentbox cloud box ${alias}`;
|
|
1449
|
+
}
|
|
1450
|
+
function agentboxAliasFor(boxName) {
|
|
1451
|
+
return boxName;
|
|
1452
|
+
}
|
|
1453
|
+
async function readFileOrEmpty(path) {
|
|
1454
|
+
try {
|
|
1455
|
+
return await fs.readFile(path, "utf8");
|
|
1456
|
+
} catch (err) {
|
|
1457
|
+
if (err.code === "ENOENT") return "";
|
|
1458
|
+
throw err;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
function buildBlock(opts) {
|
|
1462
|
+
const lines = [
|
|
1463
|
+
beginMarker(opts.alias),
|
|
1464
|
+
`Host ${opts.alias}`,
|
|
1465
|
+
` HostName ${opts.hostname}`,
|
|
1466
|
+
` User ${opts.user}`
|
|
1467
|
+
];
|
|
1468
|
+
if (opts.identityFile) {
|
|
1469
|
+
lines.push(` IdentityFile ${opts.identityFile}`);
|
|
1470
|
+
lines.push(` IdentitiesOnly yes`);
|
|
1471
|
+
}
|
|
1472
|
+
lines.push(
|
|
1473
|
+
` StrictHostKeyChecking accept-new`,
|
|
1474
|
+
` UserKnownHostsFile /dev/null`,
|
|
1475
|
+
` LogLevel ERROR`,
|
|
1476
|
+
endMarker(opts.alias),
|
|
1477
|
+
""
|
|
1478
|
+
);
|
|
1479
|
+
return lines.join("\n");
|
|
1480
|
+
}
|
|
1481
|
+
function stripLegacyInlineBlocks(contents) {
|
|
1482
|
+
const pattern = /^# BEGIN agentbox cloud box .*\n[\s\S]*?^# END agentbox cloud box .*\n?/gm;
|
|
1483
|
+
return contents.replace(pattern, "");
|
|
1484
|
+
}
|
|
1485
|
+
function hasIncludeBlock(contents) {
|
|
1486
|
+
return contents.includes(INCLUDE_BEGIN) || contents.includes(`Include ${agentboxSshConfigPath()}`);
|
|
1487
|
+
}
|
|
1488
|
+
async function ensureSshInclude() {
|
|
1489
|
+
const path = sshConfigPath();
|
|
1490
|
+
await fs.mkdir(join3(homedir22(), ".ssh"), { recursive: true, mode: 448 });
|
|
1491
|
+
const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
|
|
1492
|
+
let next = existing;
|
|
1493
|
+
if (!hasIncludeBlock(existing)) {
|
|
1494
|
+
const block = `${INCLUDE_BEGIN}
|
|
1495
|
+
Include ${agentboxSshConfigPath()}
|
|
1496
|
+
${INCLUDE_END}
|
|
1497
|
+
`;
|
|
1498
|
+
next = existing.length === 0 ? block : `${block}
|
|
1499
|
+
${existing}`;
|
|
1500
|
+
}
|
|
1501
|
+
await fs.writeFile(path, next, { mode: 384 });
|
|
1502
|
+
await fs.chmod(path, 384);
|
|
1503
|
+
}
|
|
1504
|
+
async function syncAgentboxSshConfig(statePath = stateFilePath()) {
|
|
1505
|
+
const state = await readState(statePath);
|
|
1506
|
+
const blocks = [];
|
|
1507
|
+
for (const box of state.boxes) {
|
|
1508
|
+
const ssh = box.cloud?.ssh;
|
|
1509
|
+
if (!ssh) continue;
|
|
1510
|
+
blocks.push(
|
|
1511
|
+
buildBlock({
|
|
1512
|
+
alias: agentboxAliasFor(box.name),
|
|
1513
|
+
hostname: ssh.host,
|
|
1514
|
+
user: ssh.user,
|
|
1515
|
+
identityFile: ssh.identityFile
|
|
1516
|
+
})
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
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";
|
|
1520
|
+
const path = agentboxSshConfigPath();
|
|
1521
|
+
await fs.mkdir(dirname22(path), { recursive: true, mode: 448 });
|
|
1522
|
+
await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
|
|
1523
|
+
await fs.chmod(path, 384);
|
|
1524
|
+
await ensureSshInclude();
|
|
1525
|
+
}
|
|
1526
|
+
function parseSshTarget(argv) {
|
|
1527
|
+
let target;
|
|
1528
|
+
for (let i = argv.length - 1; i >= 0; i--) {
|
|
1529
|
+
const v = argv[i];
|
|
1530
|
+
if (!v || v.startsWith("-")) continue;
|
|
1531
|
+
const at = v.indexOf("@");
|
|
1532
|
+
if (at <= 0) continue;
|
|
1533
|
+
target = { user: v.slice(0, at), host: v.slice(at + 1) };
|
|
1534
|
+
break;
|
|
1535
|
+
}
|
|
1536
|
+
if (!target) return void 0;
|
|
1537
|
+
let identityFile;
|
|
1538
|
+
for (let i = 0; i < argv.length - 1; i++) {
|
|
1539
|
+
if (argv[i] === "-i") {
|
|
1540
|
+
identityFile = argv[i + 1];
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
return { ...target, identityFile };
|
|
1545
|
+
}
|
|
1546
|
+
async function resolveCloudSshTarget(box, provider, opts = {}) {
|
|
1547
|
+
if (!provider.buildAttach) {
|
|
1548
|
+
throw new Error(`cloud provider '${provider.name}' does not support SSH attach`);
|
|
1549
|
+
}
|
|
1550
|
+
if (opts.bringOnline ?? true) {
|
|
1551
|
+
const state = await provider.probeState(box);
|
|
1552
|
+
if (state === "paused") {
|
|
1553
|
+
opts.logInfo?.("box is paused; resuming");
|
|
1554
|
+
await provider.resume(box);
|
|
1555
|
+
} else if (state === "stopped") {
|
|
1556
|
+
opts.logInfo?.("box is stopped; starting");
|
|
1557
|
+
await provider.start(box);
|
|
1558
|
+
} else if (state === "missing") {
|
|
1559
|
+
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
const spec = await provider.buildAttach(box, "shell", { noTmux: true });
|
|
1563
|
+
const target = parseSshTarget(spec.argv);
|
|
1564
|
+
if (!target) {
|
|
1565
|
+
throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
|
|
1566
|
+
}
|
|
1567
|
+
const alias = agentboxAliasFor(box.name);
|
|
1568
|
+
return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
|
|
1569
|
+
}
|
|
1570
|
+
async function autoWriteSshConfig(box, provider, enabled, logWarn) {
|
|
1571
|
+
if (!enabled) return;
|
|
1572
|
+
try {
|
|
1573
|
+
const conn = await resolveCloudSshTarget(box, provider, { bringOnline: false });
|
|
1574
|
+
if (!conn.identityFile) return;
|
|
1575
|
+
await recordBoxSsh(box.id, {
|
|
1576
|
+
host: conn.host,
|
|
1577
|
+
user: conn.user,
|
|
1578
|
+
identityFile: conn.identityFile
|
|
1579
|
+
});
|
|
1580
|
+
await syncAgentboxSshConfig();
|
|
1581
|
+
} catch (err) {
|
|
1582
|
+
logWarn?.(
|
|
1583
|
+
`ssh-config auto-write for ${box.name} failed: ${err instanceof Error ? err.message : String(err)}`
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1400
1587
|
var BOX_WORKSPACE = "/workspace";
|
|
1401
1588
|
function run(provider, box, argv) {
|
|
1402
1589
|
return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
|
|
@@ -1472,13 +1659,13 @@ function errSummary(err) {
|
|
|
1472
1659
|
return err instanceof Error ? firstLine(err.message) : String(err);
|
|
1473
1660
|
}
|
|
1474
1661
|
function secretsEnvPath() {
|
|
1475
|
-
return resolve3(
|
|
1662
|
+
return resolve3(homedir3(), ".agentbox", "secrets.env");
|
|
1476
1663
|
}
|
|
1477
1664
|
function writeManagedSecrets(managedKeys, record) {
|
|
1478
1665
|
for (const k of managedKeys) delete process.env[k];
|
|
1479
1666
|
for (const [k, v] of Object.entries(record)) process.env[k] = v;
|
|
1480
1667
|
const path = secretsEnvPath();
|
|
1481
|
-
mkdirSync(
|
|
1668
|
+
mkdirSync(dirname3(path), { recursive: true });
|
|
1482
1669
|
let existing = "";
|
|
1483
1670
|
if (existsSync(path)) {
|
|
1484
1671
|
try {
|
|
@@ -1509,7 +1696,7 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
1509
1696
|
} catch {
|
|
1510
1697
|
}
|
|
1511
1698
|
}
|
|
1512
|
-
var PLUGINS_FILE =
|
|
1699
|
+
var PLUGINS_FILE = join4(homedir4(), ".agentbox", "plugins.json");
|
|
1513
1700
|
var SUPPORTED_SDK_API_VERSIONS = [1];
|
|
1514
1701
|
function isSupportedApiVersion(v) {
|
|
1515
1702
|
return SUPPORTED_SDK_API_VERSIONS.includes(v);
|
|
@@ -1548,7 +1735,7 @@ function wantsRender(e) {
|
|
|
1548
1735
|
async function renderCarryEntries(entries, ctx, onLog) {
|
|
1549
1736
|
if (!entries.some(wantsRender)) return entries;
|
|
1550
1737
|
const context = carryPlaceholderContext(ctx);
|
|
1551
|
-
const stage = await mkdtemp(
|
|
1738
|
+
const stage = await mkdtemp(join5(tmpdir(), "agentbox-carry-render-"));
|
|
1552
1739
|
const out = [];
|
|
1553
1740
|
for (const [i, entry] of entries.entries()) {
|
|
1554
1741
|
if (!wantsRender(entry)) {
|
|
@@ -1562,7 +1749,7 @@ async function renderCarryEntries(entries, ctx, onLog) {
|
|
|
1562
1749
|
context,
|
|
1563
1750
|
onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
|
|
1564
1751
|
});
|
|
1565
|
-
const tmp =
|
|
1752
|
+
const tmp = join5(stage, `${String(i)}-${basename2(entry.absSrc)}`);
|
|
1566
1753
|
await writeFile3(tmp, rendered, "utf8");
|
|
1567
1754
|
out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
|
|
1568
1755
|
const what = [
|
|
@@ -1618,7 +1805,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1618
1805
|
credential: {
|
|
1619
1806
|
boxRelPath: ".credentials.json",
|
|
1620
1807
|
boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
|
|
1621
|
-
hostBackup:
|
|
1808
|
+
hostBackup: join6(STATE_DIR, "claude-credentials.json"),
|
|
1622
1809
|
cloudMountPath: "/home/vscode/.agentbox-creds/claude",
|
|
1623
1810
|
cloudSubpath: "claude/",
|
|
1624
1811
|
realShape: "claude-oauth"
|
|
@@ -1678,7 +1865,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1678
1865
|
credential: {
|
|
1679
1866
|
boxRelPath: "auth.json",
|
|
1680
1867
|
boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
|
|
1681
|
-
hostBackup:
|
|
1868
|
+
hostBackup: join6(STATE_DIR, "codex-credentials.json"),
|
|
1682
1869
|
cloudMountPath: "/home/vscode/.agentbox-creds/codex",
|
|
1683
1870
|
cloudSubpath: "codex/",
|
|
1684
1871
|
realShape: "nonempty-json"
|
|
@@ -1729,7 +1916,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1729
1916
|
credential: {
|
|
1730
1917
|
boxRelPath: "auth.json",
|
|
1731
1918
|
boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
|
|
1732
|
-
hostBackup:
|
|
1919
|
+
hostBackup: join6(STATE_DIR, "opencode-credentials.json"),
|
|
1733
1920
|
cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
|
|
1734
1921
|
cloudSubpath: "opencode/",
|
|
1735
1922
|
realShape: "nonempty-json"
|
|
@@ -1763,7 +1950,7 @@ function makeSyncContext(init) {
|
|
|
1763
1950
|
hostWorkspace: init.hostWorkspace,
|
|
1764
1951
|
projectRoot: init.projectRoot ?? init.hostWorkspace,
|
|
1765
1952
|
boxWorkspace: init.boxWorkspace ?? "/workspace",
|
|
1766
|
-
hostHome: init.hostHome ??
|
|
1953
|
+
hostHome: init.hostHome ?? homedir5(),
|
|
1767
1954
|
onLog: init.onLog ?? (() => {
|
|
1768
1955
|
})
|
|
1769
1956
|
};
|
|
@@ -1835,8 +2022,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
|
|
|
1835
2022
|
async function pushEnvFiles(ctx, transport, patterns) {
|
|
1836
2023
|
const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
|
|
1837
2024
|
if (list.length === 0) return { copied: 0 };
|
|
1838
|
-
const stage = await mkdtemp2(
|
|
1839
|
-
const localTar =
|
|
2025
|
+
const stage = await mkdtemp2(join7(tmpdir2(), "agentbox-envfiles-"));
|
|
2026
|
+
const localTar = join7(stage, "envfiles.tar");
|
|
1840
2027
|
try {
|
|
1841
2028
|
const packed = await execa(
|
|
1842
2029
|
"tar",
|
|
@@ -1908,9 +2095,9 @@ function encodeClaudeProjectsKey(absPath) {
|
|
|
1908
2095
|
return absPath.replace(/[^a-zA-Z0-9]/g, "-");
|
|
1909
2096
|
}
|
|
1910
2097
|
var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
|
|
1911
|
-
async function resolveClaudeMemoryDir(hostWorkspace, hostHome =
|
|
2098
|
+
async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir6()) {
|
|
1912
2099
|
if (hostWorkspace.length === 0) return null;
|
|
1913
|
-
const memDir =
|
|
2100
|
+
const memDir = join8(
|
|
1914
2101
|
hostHome,
|
|
1915
2102
|
".claude",
|
|
1916
2103
|
"projects",
|
|
@@ -1953,8 +2140,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
|
|
|
1953
2140
|
return;
|
|
1954
2141
|
}
|
|
1955
2142
|
for (const ent of entries) {
|
|
1956
|
-
const realFull =
|
|
1957
|
-
const virtualFull = virtualDir ?
|
|
2143
|
+
const realFull = join9(realDir, ent.name);
|
|
2144
|
+
const virtualFull = virtualDir ? join9(virtualDir, ent.name) : ent.name;
|
|
1958
2145
|
if (ent.isSymbolicLink()) {
|
|
1959
2146
|
let real;
|
|
1960
2147
|
try {
|
|
@@ -2057,7 +2244,7 @@ async function extractCredentials(transport, opts = {}) {
|
|
|
2057
2244
|
try {
|
|
2058
2245
|
const text = await transport.readText(spec.credential.boxAbsPath);
|
|
2059
2246
|
if (!text || !isRealAgentCredential(spec.id, text)) continue;
|
|
2060
|
-
await mkdir3(
|
|
2247
|
+
await mkdir3(dirname5(hostBackup), { recursive: true });
|
|
2061
2248
|
await writeFile4(hostBackup, text, { mode: 384 });
|
|
2062
2249
|
await chmod(hostBackup, 384).catch(() => {
|
|
2063
2250
|
});
|
|
@@ -2219,7 +2406,7 @@ function makeHostGitPorts() {
|
|
|
2219
2406
|
return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
|
|
2220
2407
|
},
|
|
2221
2408
|
async hashHostFile(hostMain, relPath) {
|
|
2222
|
-
return createHash("sha256").update(await readFile5(
|
|
2409
|
+
return createHash("sha256").update(await readFile5(join10(hostMain, relPath))).digest("hex");
|
|
2223
2410
|
},
|
|
2224
2411
|
async packHostFiles(hostMain, relPaths) {
|
|
2225
2412
|
const tarOut = await execa("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
|
|
@@ -2252,7 +2439,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
2252
2439
|
const out = [];
|
|
2253
2440
|
for (const ent of entries) {
|
|
2254
2441
|
const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
|
|
2255
|
-
const full =
|
|
2442
|
+
const full = join11(root, ent.name);
|
|
2256
2443
|
if (ent.isDirectory()) {
|
|
2257
2444
|
out.push(...await walkFiles(full, rel));
|
|
2258
2445
|
} else if (ent.isFile()) {
|
|
@@ -2276,12 +2463,12 @@ async function buildHostSet(name, hostDir, boxDst) {
|
|
|
2276
2463
|
const rels = await walkFiles(hostDir);
|
|
2277
2464
|
const files = {};
|
|
2278
2465
|
for (const rel of rels) {
|
|
2279
|
-
files[rel] = await hashFile(
|
|
2466
|
+
files[rel] = await hashFile(join11(hostDir, rel));
|
|
2280
2467
|
}
|
|
2281
2468
|
return { dst: boxDst, files, hostDir };
|
|
2282
2469
|
}
|
|
2283
|
-
async function buildHostSyncManifest(workspacePath, hostHome =
|
|
2284
|
-
const workflowsDir =
|
|
2470
|
+
async function buildHostSyncManifest(workspacePath, hostHome = homedir7()) {
|
|
2471
|
+
const workflowsDir = join11(hostHome, ".claude", "workflows");
|
|
2285
2472
|
const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
|
|
2286
2473
|
const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
|
|
2287
2474
|
const [workflows, memory] = await Promise.all([
|
|
@@ -2303,7 +2490,7 @@ function computeSyncDelta(host, box) {
|
|
|
2303
2490
|
uploads.push({
|
|
2304
2491
|
set: name,
|
|
2305
2492
|
rel,
|
|
2306
|
-
absSrc:
|
|
2493
|
+
absSrc: join11(hostSet.hostDir, rel),
|
|
2307
2494
|
dst: `${hostSet.dst}/${rel}`
|
|
2308
2495
|
});
|
|
2309
2496
|
}
|
|
@@ -2322,15 +2509,15 @@ async function stageDynamicSyncTarball(uploads) {
|
|
|
2322
2509
|
return { tarballPath: null, cleanup: async () => {
|
|
2323
2510
|
} };
|
|
2324
2511
|
}
|
|
2325
|
-
const stageDir = await mkdtemp3(
|
|
2512
|
+
const stageDir = await mkdtemp3(join11(tmpdir3(), "agentbox-dynsync-stage-"));
|
|
2326
2513
|
let tarballPath = null;
|
|
2327
2514
|
try {
|
|
2328
2515
|
for (const up of uploads) {
|
|
2329
|
-
const target =
|
|
2330
|
-
await mkdir4(
|
|
2516
|
+
const target = join11(stageDir, up.set, up.rel);
|
|
2517
|
+
await mkdir4(dirname6(target), { recursive: true });
|
|
2331
2518
|
await copyFile(up.absSrc, target);
|
|
2332
2519
|
}
|
|
2333
|
-
tarballPath =
|
|
2520
|
+
tarballPath = join11(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
|
|
2334
2521
|
await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
2335
2522
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
2336
2523
|
});
|
|
@@ -2464,7 +2651,7 @@ var BOX_WORKSPACE2 = "/workspace";
|
|
|
2464
2651
|
var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
|
|
2465
2652
|
trust_level = "trusted"
|
|
2466
2653
|
`;
|
|
2467
|
-
function sanitizeCodexConfigForBox(tomlText, hostHome =
|
|
2654
|
+
function sanitizeCodexConfigForBox(tomlText, hostHome = homedir8()) {
|
|
2468
2655
|
const cfg = parse(tomlText);
|
|
2469
2656
|
let changed = false;
|
|
2470
2657
|
if (isRecord(cfg["mcp_servers"])) {
|
|
@@ -2532,7 +2719,7 @@ async function findBrokenSymlinks(root) {
|
|
|
2532
2719
|
return;
|
|
2533
2720
|
}
|
|
2534
2721
|
for (const ent of entries) {
|
|
2535
|
-
const full =
|
|
2722
|
+
const full = join12(dir, ent.name);
|
|
2536
2723
|
if (ent.isSymbolicLink()) {
|
|
2537
2724
|
try {
|
|
2538
2725
|
await stat8(full);
|
|
@@ -2548,14 +2735,14 @@ async function findBrokenSymlinks(root) {
|
|
|
2548
2735
|
return broken;
|
|
2549
2736
|
}
|
|
2550
2737
|
async function mkStageDir(prefix) {
|
|
2551
|
-
return mkdtemp4(
|
|
2738
|
+
return mkdtemp4(join12(tmpdir4(), `agentbox-${prefix}-stage-`));
|
|
2552
2739
|
}
|
|
2553
2740
|
function emptyResult(warnings = []) {
|
|
2554
2741
|
return { tarballPath: null, cleanup: async () => {
|
|
2555
2742
|
}, warnings };
|
|
2556
2743
|
}
|
|
2557
2744
|
async function tarballFromDir(stageDir, agent) {
|
|
2558
|
-
const tarballPath =
|
|
2745
|
+
const tarballPath = join12(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
|
|
2559
2746
|
await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
2560
2747
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
2561
2748
|
});
|
|
@@ -2572,7 +2759,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
2572
2759
|
const stageDir = await mkStageDir(agent);
|
|
2573
2760
|
let tarballPath = null;
|
|
2574
2761
|
try {
|
|
2575
|
-
await copyFile2(sourcePath,
|
|
2762
|
+
await copyFile2(sourcePath, join12(stageDir, tarballEntryName));
|
|
2576
2763
|
tarballPath = await tarballFromDir(stageDir, agent);
|
|
2577
2764
|
return {
|
|
2578
2765
|
tarballPath,
|
|
@@ -2588,7 +2775,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
2588
2775
|
var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
|
|
2589
2776
|
async function buildBoxClaudeJsonFromHost(opts) {
|
|
2590
2777
|
const { hostHome, hostWorkspace } = opts;
|
|
2591
|
-
const hostClaudeJson =
|
|
2778
|
+
const hostClaudeJson = join12(hostHome, ".claude.json");
|
|
2592
2779
|
let working;
|
|
2593
2780
|
if (await pathExists4(hostClaudeJson)) {
|
|
2594
2781
|
try {
|
|
@@ -2623,7 +2810,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
|
|
|
2623
2810
|
return working;
|
|
2624
2811
|
}
|
|
2625
2812
|
async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
2626
|
-
const hostHome = opts.hostHome ??
|
|
2813
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2627
2814
|
const stageDir = await mkStageDir("claude-json-only");
|
|
2628
2815
|
let tarballPath = null;
|
|
2629
2816
|
try {
|
|
@@ -2631,7 +2818,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
2631
2818
|
hostHome,
|
|
2632
2819
|
hostWorkspace: opts.hostWorkspace
|
|
2633
2820
|
});
|
|
2634
|
-
await writeFile5(
|
|
2821
|
+
await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2635
2822
|
tarballPath = await tarballFromDir(stageDir, "claude-json-only");
|
|
2636
2823
|
return {
|
|
2637
2824
|
tarballPath,
|
|
@@ -2645,8 +2832,8 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
2645
2832
|
}
|
|
2646
2833
|
}
|
|
2647
2834
|
async function stageClaudeStaticForUpload(opts = {}) {
|
|
2648
|
-
const hostHome = opts.hostHome ??
|
|
2649
|
-
const hostClaude =
|
|
2835
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2836
|
+
const hostClaude = join12(hostHome, ".claude");
|
|
2650
2837
|
if (!await pathExists4(hostClaude)) return emptyResult();
|
|
2651
2838
|
const stageDir = await mkStageDir("claude-static");
|
|
2652
2839
|
let tarballPath = null;
|
|
@@ -2663,7 +2850,7 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
2663
2850
|
`${hostClaude}/`,
|
|
2664
2851
|
`${stageDir}/`
|
|
2665
2852
|
]);
|
|
2666
|
-
const settingsPath =
|
|
2853
|
+
const settingsPath = join12(stageDir, "settings.json");
|
|
2667
2854
|
if (await pathExists4(settingsPath)) {
|
|
2668
2855
|
try {
|
|
2669
2856
|
const parsed = JSON.parse(await readFile7(settingsPath, "utf8"));
|
|
@@ -2678,14 +2865,14 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
2678
2865
|
hostHome,
|
|
2679
2866
|
hostWorkspace: opts.hostWorkspace
|
|
2680
2867
|
});
|
|
2681
|
-
await writeFile5(
|
|
2682
|
-
const pluginsDir =
|
|
2868
|
+
await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2869
|
+
const pluginsDir = join12(stageDir, "plugins");
|
|
2683
2870
|
if (await pathExists4(pluginsDir)) {
|
|
2684
2871
|
try {
|
|
2685
2872
|
const entries = await readdir5(pluginsDir, { withFileTypes: true });
|
|
2686
2873
|
for (const ent of entries) {
|
|
2687
2874
|
if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
|
|
2688
|
-
const file =
|
|
2875
|
+
const file = join12(pluginsDir, ent.name);
|
|
2689
2876
|
const raw = await readFile7(file, "utf8");
|
|
2690
2877
|
const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
|
|
2691
2878
|
if (replaced !== raw) await writeFile5(file, replaced);
|
|
@@ -2720,8 +2907,8 @@ async function sanitizeStagedCodexConfig(configPath, hostHome) {
|
|
|
2720
2907
|
}
|
|
2721
2908
|
}
|
|
2722
2909
|
async function stageCodexStaticForUpload(opts = {}) {
|
|
2723
|
-
const hostHome = opts.hostHome ??
|
|
2724
|
-
const hostCodex =
|
|
2910
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2911
|
+
const hostCodex = join12(hostHome, ".codex");
|
|
2725
2912
|
if (!await pathExists4(hostCodex)) return emptyResult();
|
|
2726
2913
|
const stageDir = await mkStageDir("codex-static");
|
|
2727
2914
|
let tarballPath = null;
|
|
@@ -2735,7 +2922,7 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2735
2922
|
`${hostCodex}/`,
|
|
2736
2923
|
`${stageDir}/`
|
|
2737
2924
|
]);
|
|
2738
|
-
await sanitizeStagedCodexConfig(
|
|
2925
|
+
await sanitizeStagedCodexConfig(join12(stageDir, "config.toml"), hostHome);
|
|
2739
2926
|
tarballPath = await tarballFromDir(stageDir, "codex-static");
|
|
2740
2927
|
return {
|
|
2741
2928
|
tarballPath,
|
|
@@ -2749,8 +2936,8 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2749
2936
|
}
|
|
2750
2937
|
}
|
|
2751
2938
|
async function stageAgentsStaticForUpload(opts = {}) {
|
|
2752
|
-
const hostHome = opts.hostHome ??
|
|
2753
|
-
const hostAgents =
|
|
2939
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2940
|
+
const hostAgents = join12(hostHome, ".agents");
|
|
2754
2941
|
if (!await pathExists4(hostAgents)) return emptyResult();
|
|
2755
2942
|
const stageDir = await mkStageDir("agents-static");
|
|
2756
2943
|
let tarballPath = null;
|
|
@@ -2776,20 +2963,20 @@ async function stageAgentsStaticForUpload(opts = {}) {
|
|
|
2776
2963
|
}
|
|
2777
2964
|
}
|
|
2778
2965
|
async function stageCodexCredentialsForUpload(opts = {}) {
|
|
2779
|
-
const hostHome = opts.hostHome ??
|
|
2780
|
-
const cloudBackup =
|
|
2966
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2967
|
+
const cloudBackup = join12(hostHome, ".agentbox", "codex-credentials.json");
|
|
2781
2968
|
if (await pathExists4(cloudBackup)) {
|
|
2782
2969
|
return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
|
|
2783
2970
|
}
|
|
2784
|
-
const hostAuth =
|
|
2971
|
+
const hostAuth = join12(hostHome, ".codex", "auth.json");
|
|
2785
2972
|
if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
|
|
2786
2973
|
return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
|
|
2787
2974
|
}
|
|
2788
2975
|
var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
|
|
2789
2976
|
async function stageOpencodeStaticForUpload(opts = {}) {
|
|
2790
|
-
const hostHome = opts.hostHome ??
|
|
2791
|
-
const hostData =
|
|
2792
|
-
const hostConfig =
|
|
2977
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
2978
|
+
const hostData = join12(hostHome, ".local", "share", "opencode");
|
|
2979
|
+
const hostConfig = join12(hostHome, ".config", "opencode");
|
|
2793
2980
|
const hasData = await pathExists4(hostData);
|
|
2794
2981
|
const hasConfig = await pathExists4(hostConfig);
|
|
2795
2982
|
if (!hasData && !hasConfig) return emptyResult();
|
|
@@ -2808,7 +2995,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2808
2995
|
]);
|
|
2809
2996
|
}
|
|
2810
2997
|
if (hasConfig) {
|
|
2811
|
-
const configStage =
|
|
2998
|
+
const configStage = join12(stageDir, "config");
|
|
2812
2999
|
const cfgBroken = await findBrokenSymlinks(hostConfig);
|
|
2813
3000
|
await execa("rsync", [
|
|
2814
3001
|
"-a",
|
|
@@ -2831,18 +3018,18 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2831
3018
|
}
|
|
2832
3019
|
}
|
|
2833
3020
|
async function stageOpencodeCredentialsForUpload(opts = {}) {
|
|
2834
|
-
const hostHome = opts.hostHome ??
|
|
2835
|
-
const cloudBackup =
|
|
3021
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
3022
|
+
const cloudBackup = join12(hostHome, ".agentbox", "opencode-credentials.json");
|
|
2836
3023
|
if (await pathExists4(cloudBackup)) {
|
|
2837
3024
|
return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
|
|
2838
3025
|
}
|
|
2839
|
-
const hostAuth =
|
|
3026
|
+
const hostAuth = join12(hostHome, ".local", "share", "opencode", "auth.json");
|
|
2840
3027
|
if (!await pathExists4(hostAuth)) return emptyResult();
|
|
2841
3028
|
return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
|
|
2842
3029
|
}
|
|
2843
3030
|
async function stageOpencodeStateForUpload(opts = {}) {
|
|
2844
|
-
const hostHome = opts.hostHome ??
|
|
2845
|
-
const hostModel =
|
|
3031
|
+
const hostHome = opts.hostHome ?? homedir9();
|
|
3032
|
+
const hostModel = join12(hostHome, ".local", "state", "opencode", "model.json");
|
|
2846
3033
|
if (!await pathExists4(hostModel)) return emptyResult();
|
|
2847
3034
|
return stageSingleFileTarball("opencode-state", hostModel, "model.json");
|
|
2848
3035
|
}
|
|
@@ -2868,7 +3055,7 @@ function preparedStatePathFor(provider) {
|
|
|
2868
3055
|
if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
|
|
2869
3056
|
throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
|
|
2870
3057
|
}
|
|
2871
|
-
return pathResolve(
|
|
3058
|
+
return pathResolve(homedir10(), ".agentbox", `${provider}-prepared.json`);
|
|
2872
3059
|
}
|
|
2873
3060
|
function readPreparedStateRaw(provider) {
|
|
2874
3061
|
const path = preparedStatePathFor(provider);
|
|
@@ -2881,7 +3068,7 @@ function readPreparedStateRaw(provider) {
|
|
|
2881
3068
|
}
|
|
2882
3069
|
function writePreparedStateRaw(provider, state) {
|
|
2883
3070
|
const path = preparedStatePathFor(provider);
|
|
2884
|
-
mkdirSync2(
|
|
3071
|
+
mkdirSync2(dirname7(path), { recursive: true });
|
|
2885
3072
|
const body = JSON.stringify(state, null, 2) + "\n";
|
|
2886
3073
|
const tmp = `${path}.tmp`;
|
|
2887
3074
|
writeFileSync2(tmp, body, { mode: 384 });
|
|
@@ -2969,11 +3156,11 @@ import { dirname as dirname23, resolve as resolve22 } from "path";
|
|
|
2969
3156
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2970
3157
|
import { existsSync as existsSync4 } from "fs";
|
|
2971
3158
|
import { fileURLToPath } from "url";
|
|
2972
|
-
import { dirname as
|
|
3159
|
+
import { dirname as dirname8, resolve as resolve4 } from "path";
|
|
2973
3160
|
var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
|
|
2974
3161
|
async function resolveClaudeInstallMode() {
|
|
2975
3162
|
try {
|
|
2976
|
-
const { loadEffectiveConfig } = await import("./dist-
|
|
3163
|
+
const { loadEffectiveConfig } = await import("./dist-STQK5XM6.js");
|
|
2977
3164
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
2978
3165
|
return cfg.effective.box.claudeInstall;
|
|
2979
3166
|
} catch {
|
|
@@ -2984,7 +3171,7 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
|
|
|
2984
3171
|
function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
|
|
2985
3172
|
return `${registry}:sha-${sha.slice(0, 16)}`;
|
|
2986
3173
|
}
|
|
2987
|
-
var here =
|
|
3174
|
+
var here = dirname8(fileURLToPath(import.meta.url));
|
|
2988
3175
|
function resolveDockerBuild() {
|
|
2989
3176
|
const override = process.env.AGENTBOX_DOCKER_CONTEXT;
|
|
2990
3177
|
if (override && existsSync4(resolve4(override, "Dockerfile.box"))) {
|
|
@@ -3075,7 +3262,7 @@ async function buildImage(opts = {}) {
|
|
|
3075
3262
|
return ref;
|
|
3076
3263
|
}
|
|
3077
3264
|
async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
3078
|
-
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-
|
|
3265
|
+
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-D2HJEY2L.js");
|
|
3079
3266
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
3080
3267
|
const allowPull = opts.allowPull !== false;
|
|
3081
3268
|
if (allowPull && registry && fingerprint) {
|
|
@@ -3102,7 +3289,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
|
3102
3289
|
return { source: "built" };
|
|
3103
3290
|
}
|
|
3104
3291
|
async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
3105
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-
|
|
3292
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-D2HJEY2L.js");
|
|
3106
3293
|
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
3107
3294
|
const rawFingerprint = await computeDockerContextFingerprint2({
|
|
3108
3295
|
contextDir: opts.contextDir
|
|
@@ -3208,6 +3395,7 @@ export {
|
|
|
3208
3395
|
readState,
|
|
3209
3396
|
recordBox,
|
|
3210
3397
|
recordLastAgent,
|
|
3398
|
+
setBoxDisplayName,
|
|
3211
3399
|
reserveProjectIndex,
|
|
3212
3400
|
removeBoxRecord,
|
|
3213
3401
|
findBox,
|
|
@@ -3218,6 +3406,8 @@ export {
|
|
|
3218
3406
|
pickFreshBranch,
|
|
3219
3407
|
GitWorktreeError,
|
|
3220
3408
|
hostOpenCommand,
|
|
3409
|
+
syncAgentboxSshConfig,
|
|
3410
|
+
autoWriteSshConfig,
|
|
3221
3411
|
BOX_WORKSPACE,
|
|
3222
3412
|
boxGitCheckout,
|
|
3223
3413
|
boxGitNewBranch,
|