@madarco/agentbox 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +8 -7
- package/dist/{_cloud-attach-W2CFNXKO.js → _cloud-attach-7WRQH6XZ.js} +5 -5
- package/dist/{chunk-7PRLM3PH.js → chunk-7ZZAZPYX.js} +3 -3
- package/dist/{chunk-LU3WAHTU.js → chunk-BA2VLJVU.js} +3 -3
- package/dist/{chunk-GHFIKSBJ.js → chunk-DJQMK4RN.js} +12 -4
- package/dist/chunk-DJQMK4RN.js.map +1 -0
- package/dist/{chunk-4UNSBU5R.js → chunk-DQHMDDAT.js} +2 -2
- package/dist/{chunk-LCZOQTIX.js → chunk-I2OAJS3L.js} +40 -377
- package/dist/{chunk-LCZOQTIX.js.map → chunk-I2OAJS3L.js.map} +1 -1
- package/dist/{chunk-5F5SOSDY.js → chunk-JGZSA5ZI.js} +72 -23
- package/dist/chunk-JGZSA5ZI.js.map +1 -0
- package/dist/{chunk-7C5MOA4Z.js → chunk-K5KOLYIL.js} +3 -3
- package/dist/{chunk-Y3OPQWAQ.js → chunk-PK2QF4IR.js} +576 -198
- package/dist/chunk-PK2QF4IR.js.map +1 -0
- package/dist/{chunk-VZC5J44U.js → chunk-UIFL7F2G.js} +55 -38
- package/dist/chunk-UIFL7F2G.js.map +1 -0
- package/dist/{chunk-NH3W6HUZ.js → chunk-ZY7M7MXH.js} +41 -16
- package/dist/chunk-ZY7M7MXH.js.map +1 -0
- package/dist/chunk-ZYKNSHOH.js +259 -0
- package/dist/chunk-ZYKNSHOH.js.map +1 -0
- package/dist/{dist-IGQNVIV3.js → dist-5IICYSR6.js} +42 -374
- package/dist/{dist-IGQNVIV3.js.map → dist-5IICYSR6.js.map} +1 -1
- package/dist/{dist-KL73Z37T.js → dist-AR5CHRSV.js} +86 -45
- package/dist/{dist-KL73Z37T.js.map → dist-AR5CHRSV.js.map} +1 -1
- package/dist/{dist-3V5SLNK4.js → dist-DTNYMBQ5.js} +12 -12
- package/dist/{dist-UB3PYSCG.js → dist-K4LNH3EC.js} +6 -6
- package/dist/{dist-BIDAC4H4.js → dist-POVRY7HO.js} +8 -4
- package/dist/{dist-SBDYDH7H.js → dist-U2SVLJUQ.js} +4 -2
- package/dist/{dist-I5OBPLP2.js → dist-XYY6SIKG.js} +6 -6
- package/dist/dist-YA7EXBGG.js +809 -0
- package/dist/dist-YA7EXBGG.js.map +1 -0
- package/dist/index.js +962 -583
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-OBM2F7CU-DY7TZV4R.js → prepared-state-75DIZ55S-W6NU3S3B.js} +2 -2
- package/package.json +8 -7
- package/runtime/_shared/ctl.cjs +83 -36
- package/runtime/digitalocean/ctl.cjs +83 -36
- package/runtime/docker/packages/ctl/dist/bin.cjs +83 -36
- package/runtime/e2b/ctl.cjs +83 -36
- package/runtime/hetzner/ctl.cjs +83 -36
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +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/chunks/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
- 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]__1-9g0ae._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__19pc87s._.js → [root-of-the-server]__1k8g143._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +4 -4
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
- 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/{auth-MVL4NCQC.js → auth-DC44GQZY.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-GRIXACTV.js → auth-config-LALRDYDO.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-JLG5JJXD.js → chunk-3FJNKSNZ.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-LNHPLR3L.js → chunk-4QY2VZCF.js} +509 -135
- package/runtime/hub/apps/hub/{chunk-QBJOF5D3.js → chunk-BARD2DI6.js} +11 -3
- package/runtime/hub/apps/hub/{chunk-V3OMPMI3.js → chunk-QSMPSV5Z.js} +70 -21
- package/runtime/hub/apps/hub/{chunk-MA73PTOR.js → chunk-XZZXPEVV.js} +58 -37
- package/runtime/hub/apps/hub/{dist-7LB4D4ZQ.js → dist-3ENKQN5G.js} +35 -365
- package/runtime/hub/apps/hub/{dist-SIQJD72C.js → dist-6VGJOQYK.js} +84 -43
- package/runtime/hub/apps/hub/{dist-ERQDDSOY.js → dist-AE6IV4FV.js} +4 -4
- package/runtime/hub/apps/hub/{dist-IZ2JCN5R.js → dist-EQV4L7KP.js} +3 -1
- package/runtime/hub/apps/hub/dist-NNBELNA7.js +1017 -0
- package/runtime/hub/apps/hub/{dist-ZVY2FWG6.js → dist-RJJ2SDYO.js} +4 -4
- package/runtime/hub/apps/hub/{dist-26KVXHXV.js → dist-TU7D6UTB.js} +37 -366
- package/runtime/hub/apps/hub/{dist-YZJA4WRV.js → dist-WAZKGVYL.js} +7 -3
- package/runtime/hub/apps/hub/{hub-token-BJG6Q5II.js → hub-token-COBZGSLS.js} +2 -2
- package/runtime/hub/apps/hub/package.json +1 -0
- package/runtime/hub/apps/hub/{prepared-state-OBM2F7CU-ZEYFNYFI.js → prepared-state-75DIZ55S-NYEDSU2U.js} +1 -1
- package/runtime/hub/apps/hub/server.js +20 -16
- package/runtime/relay/bin.cjs +57 -20
- package/runtime/vercel/ctl.cjs +83 -36
- package/dist/chunk-5F5SOSDY.js.map +0 -1
- package/dist/chunk-GHFIKSBJ.js.map +0 -1
- package/dist/chunk-NH3W6HUZ.js.map +0 -1
- package/dist/chunk-VZC5J44U.js.map +0 -1
- package/dist/chunk-Y3OPQWAQ.js.map +0 -1
- package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
- /package/dist/{_cloud-attach-W2CFNXKO.js.map → _cloud-attach-7WRQH6XZ.js.map} +0 -0
- /package/dist/{chunk-7PRLM3PH.js.map → chunk-7ZZAZPYX.js.map} +0 -0
- /package/dist/{chunk-LU3WAHTU.js.map → chunk-BA2VLJVU.js.map} +0 -0
- /package/dist/{chunk-4UNSBU5R.js.map → chunk-DQHMDDAT.js.map} +0 -0
- /package/dist/{chunk-7C5MOA4Z.js.map → chunk-K5KOLYIL.js.map} +0 -0
- /package/dist/{dist-3V5SLNK4.js.map → dist-DTNYMBQ5.js.map} +0 -0
- /package/dist/{dist-UB3PYSCG.js.map → dist-K4LNH3EC.js.map} +0 -0
- /package/dist/{dist-BIDAC4H4.js.map → dist-POVRY7HO.js.map} +0 -0
- /package/dist/{dist-I5OBPLP2.js.map → dist-U2SVLJUQ.js.map} +0 -0
- /package/dist/{dist-SBDYDH7H.js.map → dist-XYY6SIKG.js.map} +0 -0
- /package/dist/{prepared-state-OBM2F7CU-DY7TZV4R.js.map → prepared-state-75DIZ55S-W6NU3S3B.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_ssgManifest.js +0 -0
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
readE2bCredStatus,
|
|
6
6
|
readPreparedState as readPreparedState3,
|
|
7
7
|
secretsPath as secretsPath4
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DQHMDDAT.js";
|
|
9
9
|
import {
|
|
10
10
|
detectEgressIp as detectEgressIp2,
|
|
11
11
|
ensureDigitalOceanCredentials,
|
|
@@ -17,7 +17,11 @@ import {
|
|
|
17
17
|
readPreparedState as readPreparedState4,
|
|
18
18
|
secretsPath as secretsPath5,
|
|
19
19
|
syncFirewallSource as syncFirewallSource2
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-7ZZAZPYX.js";
|
|
21
|
+
import {
|
|
22
|
+
probeRemoteEngine,
|
|
23
|
+
readPreparedState as readPreparedState5
|
|
24
|
+
} from "./chunk-ZYKNSHOH.js";
|
|
21
25
|
import {
|
|
22
26
|
ADVANCED_HINT_GROUPS,
|
|
23
27
|
ALERT_BAND_ROWS,
|
|
@@ -43,6 +47,7 @@ import {
|
|
|
43
47
|
loadProviderModule,
|
|
44
48
|
loadPtyBackend,
|
|
45
49
|
menuLines,
|
|
50
|
+
parseProviderSpec,
|
|
46
51
|
pasteHostClipboardImage,
|
|
47
52
|
popTerminalTitle,
|
|
48
53
|
postAnswer,
|
|
@@ -61,7 +66,7 @@ import {
|
|
|
61
66
|
subscribePrompts,
|
|
62
67
|
uploadImageFileToBox,
|
|
63
68
|
withFirewallRepair
|
|
64
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-ZY7M7MXH.js";
|
|
65
70
|
import {
|
|
66
71
|
daytonaBackend,
|
|
67
72
|
ensureDaytonaCredentials,
|
|
@@ -69,7 +74,7 @@ import {
|
|
|
69
74
|
readDaytonaCredStatus,
|
|
70
75
|
readPreparedDaytonaState,
|
|
71
76
|
secretsPath
|
|
72
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-K5KOLYIL.js";
|
|
73
78
|
import {
|
|
74
79
|
deployControlPlaneToHetzner,
|
|
75
80
|
detectEgressIp,
|
|
@@ -81,7 +86,7 @@ import {
|
|
|
81
86
|
readPreparedState,
|
|
82
87
|
secretsPath as secretsPath2,
|
|
83
88
|
syncFirewallSource
|
|
84
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-I2OAJS3L.js";
|
|
85
90
|
import {
|
|
86
91
|
createGitDeployment,
|
|
87
92
|
createGitProject,
|
|
@@ -100,7 +105,7 @@ import {
|
|
|
100
105
|
resolveVercelApiAuth,
|
|
101
106
|
secretsPath as secretsPath3,
|
|
102
107
|
upsertProjectEnv
|
|
103
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-BA2VLJVU.js";
|
|
104
109
|
import {
|
|
105
110
|
agentSpecsForCloud,
|
|
106
111
|
baseFreshnessFromFingerprints,
|
|
@@ -113,7 +118,7 @@ import {
|
|
|
113
118
|
probeCloudCheckpoint,
|
|
114
119
|
resolveCloudCheckpoint,
|
|
115
120
|
seedAgentVolumesIfFresh
|
|
116
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-DJQMK4RN.js";
|
|
117
122
|
import {
|
|
118
123
|
ALL_CONNECTORS,
|
|
119
124
|
BOX_STATUS_EVENT,
|
|
@@ -263,7 +268,7 @@ import {
|
|
|
263
268
|
waitForTmuxPaneContent,
|
|
264
269
|
warmUpClaudeCredentials,
|
|
265
270
|
writeJob
|
|
266
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-UIFL7F2G.js";
|
|
267
272
|
import {
|
|
268
273
|
BUILT_IN_DEFAULTS,
|
|
269
274
|
CLOUD_PROVIDER_NAMES,
|
|
@@ -289,8 +294,9 @@ import {
|
|
|
289
294
|
resolveDaytonaClass,
|
|
290
295
|
resolveDefaultCheckpoint,
|
|
291
296
|
setConfigValue,
|
|
297
|
+
setConfigWarningSink,
|
|
292
298
|
unsetConfigValue
|
|
293
|
-
} from "./chunk-
|
|
299
|
+
} from "./chunk-JGZSA5ZI.js";
|
|
294
300
|
import {
|
|
295
301
|
AmbiguousBoxError,
|
|
296
302
|
BoxNotFoundError,
|
|
@@ -369,7 +375,7 @@ import {
|
|
|
369
375
|
toSyncKind,
|
|
370
376
|
transportSettingsTarget,
|
|
371
377
|
upsertClaudeSshConfig
|
|
372
|
-
} from "./chunk-
|
|
378
|
+
} from "./chunk-PK2QF4IR.js";
|
|
373
379
|
import "./chunk-G3H2L3O2.js";
|
|
374
380
|
import {
|
|
375
381
|
__export,
|
|
@@ -377,14 +383,14 @@ import {
|
|
|
377
383
|
} from "./chunk-WJFZJZIM.js";
|
|
378
384
|
|
|
379
385
|
// src/version.ts
|
|
380
|
-
var AGENTBOX_VERSION = true ? "0.
|
|
381
|
-
var AGENTBOX_COMMIT = true ? "
|
|
386
|
+
var AGENTBOX_VERSION = true ? "0.26.0" : "0.0.0-dev";
|
|
387
|
+
var AGENTBOX_COMMIT = true ? "d326ab3b" : "dev";
|
|
382
388
|
|
|
383
389
|
// src/index.ts
|
|
384
390
|
import { existsSync as _existsSync } from "fs";
|
|
385
391
|
import { dirname as _dirname, resolve as _resolve } from "path";
|
|
386
392
|
import { fileURLToPath as _fileURLToPath } from "url";
|
|
387
|
-
import { Command as
|
|
393
|
+
import { Command as Command67 } from "commander";
|
|
388
394
|
|
|
389
395
|
// src/engine-override.ts
|
|
390
396
|
async function applyEngineOverrideAtStartup() {
|
|
@@ -399,18 +405,39 @@ async function applyEngineOverrideAtStartup() {
|
|
|
399
405
|
|
|
400
406
|
// src/help.ts
|
|
401
407
|
var HELP_GROUPS = [
|
|
402
|
-
{
|
|
408
|
+
{
|
|
409
|
+
title: "Create & run",
|
|
410
|
+
commands: ["create", "attach", "fork", "claude", "codex", "opencode"]
|
|
411
|
+
},
|
|
403
412
|
{
|
|
404
413
|
title: "Access",
|
|
405
|
-
commands: ["dashboard", "
|
|
414
|
+
commands: ["dashboard", "url", "screen", "code", "shell", "open", "logs", "drive"]
|
|
406
415
|
},
|
|
407
|
-
{ title: "Inspect", commands: ["list", "status", "top", "agent"] },
|
|
408
|
-
{ title: "Lifecycle", commands: ["start", "stop", "destroy", "pause", "unpause"] },
|
|
409
|
-
{ title: "Sync & state", commands: ["download", "cp", "checkpoint", "queue"] },
|
|
416
|
+
{ title: "Inspect", commands: ["list", "status", "services", "top", "agent"] },
|
|
417
|
+
{ title: "Lifecycle", commands: ["start", "stop", "destroy", "pause", "unpause", "recover"] },
|
|
410
418
|
{
|
|
411
|
-
title: "
|
|
419
|
+
title: "Git & sync",
|
|
420
|
+
commands: ["git", "git push", "git pull", "git pr", "download", "cp", "checkpoint", "queue"]
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
title: "Providers",
|
|
412
424
|
commands: [
|
|
413
425
|
"prepare",
|
|
426
|
+
"docker",
|
|
427
|
+
"daytona",
|
|
428
|
+
"hetzner",
|
|
429
|
+
"vercel",
|
|
430
|
+
"e2b",
|
|
431
|
+
"digitalocean",
|
|
432
|
+
"remote-docker",
|
|
433
|
+
"plugin",
|
|
434
|
+
"inbound",
|
|
435
|
+
"connect"
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
title: "Advanced",
|
|
440
|
+
commands: [
|
|
414
441
|
"wait",
|
|
415
442
|
"prune",
|
|
416
443
|
"doctor",
|
|
@@ -418,16 +445,55 @@ var HELP_GROUPS = [
|
|
|
418
445
|
"install",
|
|
419
446
|
"app",
|
|
420
447
|
"config",
|
|
421
|
-
"git",
|
|
422
448
|
"relay",
|
|
423
|
-
"
|
|
424
|
-
"daytona",
|
|
425
|
-
"hetzner",
|
|
426
|
-
"vercel",
|
|
427
|
-
"e2b"
|
|
449
|
+
"hub"
|
|
428
450
|
]
|
|
429
451
|
}
|
|
430
452
|
];
|
|
453
|
+
var SHORT_DESCRIPTIONS = {
|
|
454
|
+
create: "Create and start a new agent box (no agent launched)",
|
|
455
|
+
claude: "Create a box and launch Claude Code (detachable tmux session)",
|
|
456
|
+
codex: "Create a box and launch OpenAI Codex (detachable tmux session)",
|
|
457
|
+
opencode: "Create a box and launch OpenCode (detachable tmux session)",
|
|
458
|
+
fork: "Fork the current host agent session into a new box and resume it there",
|
|
459
|
+
attach: "Attach to the running agent tmux session in a box",
|
|
460
|
+
url: "Open a box's web app URL in the browser",
|
|
461
|
+
shell: "Open an interactive shell in a box (detachable tmux session)",
|
|
462
|
+
open: "Mount a box /workspace in Finder (sshfs), or open it in a host app",
|
|
463
|
+
drive: "Drive a box tmux session: snapshot screen, send keys, wait for output",
|
|
464
|
+
top: "Live resource monitor (cpu/mem/disk) for a box, project, or all boxes",
|
|
465
|
+
agent: "Query and wait on the in-box coding agent's state",
|
|
466
|
+
start: "Start a stopped box",
|
|
467
|
+
stop: "Stop a box (disk preserved)",
|
|
468
|
+
destroy: "Destroy a box and discard its writable layer",
|
|
469
|
+
pause: "Pause a box (docker cgroup freeze / cloud archive)",
|
|
470
|
+
unpause: "Resume a paused box",
|
|
471
|
+
recover: "Reconnect to an already-running box without power-cycling it",
|
|
472
|
+
download: "Download a box's /workspace back to the host (gitignore-aware)",
|
|
473
|
+
cp: "Copy files between host and box (like `docker cp`)",
|
|
474
|
+
checkpoint: "List and manage project checkpoints (warm state new boxes start from)",
|
|
475
|
+
"git pull": "Fetch via the relay then merge in /workspace (or switch branch first)",
|
|
476
|
+
prepare: "Build provider base images / snapshots, or show what's prepared",
|
|
477
|
+
docker: "Local Docker provider (the default) \u2014 sugar for `--provider docker`",
|
|
478
|
+
daytona: "Daytona cloud provider \u2014 credentials + `--provider daytona` sugar",
|
|
479
|
+
hetzner: "Hetzner Cloud VPS provider \u2014 credentials, firewall + provider sugar",
|
|
480
|
+
vercel: "Vercel Sandbox provider \u2014 credentials + `--provider vercel` sugar",
|
|
481
|
+
e2b: "E2B sandbox provider \u2014 credentials + `--provider e2b` sugar",
|
|
482
|
+
digitalocean: "DigitalOcean Droplet provider \u2014 credentials, firewall + provider sugar",
|
|
483
|
+
"remote-docker": "Docker on a machine you own, over SSH \u2014 provider sugar",
|
|
484
|
+
inbound: "Set a VPS box's inbound-access policy (per-box firewall)",
|
|
485
|
+
connect: "Print a VPS box's SSH details to drive it from another device",
|
|
486
|
+
prune: "Clean up orphan state records (--all: orphan docker resources)",
|
|
487
|
+
doctor: "Diagnose system compatibility and provider readiness",
|
|
488
|
+
"self-update": "Update agentbox, host skills, box image, relay/hub, and the tray app",
|
|
489
|
+
install: "Interactive setup wizard: pick a provider, log in, prepare its image",
|
|
490
|
+
app: "Control the AgentBox menu-bar app",
|
|
491
|
+
config: "Read / write layered config (global, project, workspace)",
|
|
492
|
+
hub: "Run the AgentBox hub \u2014 relay + Web UI on http://127.0.0.1:8787"
|
|
493
|
+
};
|
|
494
|
+
var TERM_OVERRIDES = {
|
|
495
|
+
"git pr": "pr create -f"
|
|
496
|
+
};
|
|
431
497
|
function term(cmd) {
|
|
432
498
|
const aliases = cmd.aliases();
|
|
433
499
|
return aliases.length ? `${cmd.name()}|${aliases.join("|")}` : cmd.name();
|
|
@@ -438,31 +504,131 @@ function isHiddenCommand(cmd) {
|
|
|
438
504
|
function buildGroupedHelp(program2) {
|
|
439
505
|
const visible = program2.commands.filter((c) => !isHiddenCommand(c));
|
|
440
506
|
const byName = new Map(visible.map((c) => [c.name(), c]));
|
|
441
|
-
const grouped = new Set(HELP_GROUPS.flatMap((g) => g.commands));
|
|
507
|
+
const grouped = new Set(HELP_GROUPS.flatMap((g) => g.commands.map((n) => n.split(" ")[0])));
|
|
442
508
|
const orphans = visible.map((c) => c.name()).filter((n) => !grouped.has(n));
|
|
443
509
|
const groups = [...HELP_GROUPS];
|
|
444
510
|
if (orphans.length) groups.push({ title: "Other", commands: orphans });
|
|
445
|
-
const
|
|
511
|
+
const resolve7 = (name) => {
|
|
512
|
+
const parts = name.split(" ");
|
|
513
|
+
let cmd = byName.get(parts[0]);
|
|
514
|
+
for (const part of parts.slice(1)) {
|
|
515
|
+
cmd = cmd?.commands.find((c) => c.name() === part || c.aliases().includes(part));
|
|
516
|
+
}
|
|
517
|
+
return cmd ? { cmd, depth: parts.length - 1 } : void 0;
|
|
518
|
+
};
|
|
519
|
+
const rowTerm = (name, cmd) => TERM_OVERRIDES[name] ?? term(cmd);
|
|
520
|
+
const termWidths = [];
|
|
446
521
|
for (const g of groups) {
|
|
447
522
|
for (const name of g.commands) {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
523
|
+
const row2 = resolve7(name);
|
|
524
|
+
if (row2) termWidths.push(rowTerm(name, row2.cmd).length + row2.depth * 2);
|
|
450
525
|
}
|
|
451
526
|
}
|
|
452
|
-
const pad5 = Math.max(0, ...
|
|
527
|
+
const pad5 = Math.max(0, ...termWidths) + 2;
|
|
528
|
+
const descBudget = MAX_HELP_LINE - 4 - pad5;
|
|
453
529
|
const lines = ["Commands:"];
|
|
454
530
|
for (const g of groups) {
|
|
455
531
|
const title = g.hint ? `${g.title} (${g.hint})` : g.title;
|
|
456
532
|
lines.push("", ` ${title}`);
|
|
457
533
|
for (const name of g.commands) {
|
|
458
|
-
const
|
|
459
|
-
if (!
|
|
460
|
-
|
|
534
|
+
const row2 = resolve7(name);
|
|
535
|
+
if (!row2) continue;
|
|
536
|
+
const description = SHORT_DESCRIPTIONS[name] ?? row2.cmd.description();
|
|
537
|
+
const indent = " " + " ".repeat(row2.depth);
|
|
538
|
+
lines.push(
|
|
539
|
+
`${indent}${rowTerm(name, row2.cmd).padEnd(pad5 - row2.depth * 2)}${clip(description, descBudget)}`
|
|
540
|
+
);
|
|
461
541
|
}
|
|
462
542
|
}
|
|
463
543
|
lines.push("", "Run `agentbox <command> --help` for command-specific options.");
|
|
464
544
|
return lines.join("\n");
|
|
465
545
|
}
|
|
546
|
+
var MAX_HELP_LINE = 100;
|
|
547
|
+
function clip(text4, budget) {
|
|
548
|
+
if (text4.length <= budget) return text4;
|
|
549
|
+
const cut = text4.lastIndexOf(" ", budget - 1);
|
|
550
|
+
return `${text4.slice(0, cut > budget / 2 ? cut : budget - 1).trimEnd()}\u2026`;
|
|
551
|
+
}
|
|
552
|
+
var COMPACT_HELP = [
|
|
553
|
+
{
|
|
554
|
+
title: "Run an agent",
|
|
555
|
+
rows: [
|
|
556
|
+
{
|
|
557
|
+
commands: ["claude", "codex", "opencode"],
|
|
558
|
+
description: "Start the agent in a new isolated box"
|
|
559
|
+
}
|
|
560
|
+
]
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
title: "Work with boxes",
|
|
564
|
+
rows: [
|
|
565
|
+
{ commands: ["attach"], description: "Re-attach to a box's agent session" },
|
|
566
|
+
{ commands: ["list"], description: "List agent boxes (-g for all projects)" },
|
|
567
|
+
{
|
|
568
|
+
commands: ["url", "screen", "open", "code"],
|
|
569
|
+
description: "Open a box's web app, VNC, files, or editor"
|
|
570
|
+
},
|
|
571
|
+
{ commands: ["destroy"], description: "Destroy a box" }
|
|
572
|
+
]
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
title: "Git",
|
|
576
|
+
rows: [
|
|
577
|
+
{
|
|
578
|
+
commands: ["git"],
|
|
579
|
+
term: "git push|pull|pr",
|
|
580
|
+
description: "Push box commits to the remote, pull host changes into the box, open PRs"
|
|
581
|
+
}
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
];
|
|
585
|
+
var COMPACT_EXAMPLE = [
|
|
586
|
+
"Example:",
|
|
587
|
+
" agentbox claude # launch Claude, one box per task/branch",
|
|
588
|
+
" agentbox hetzner|e2b|\u2026 codex # launch with other agents or providers",
|
|
589
|
+
" ! agentbox fork hetzner|e2b|\u2026 # teleport the current session from the chat",
|
|
590
|
+
"",
|
|
591
|
+
" agentbox attach 1 # detach with Ctrl+a d, then re-attach",
|
|
592
|
+
"",
|
|
593
|
+
" # Then ask your agent to push/pr or do it from your pc:",
|
|
594
|
+
" agentbox git push 1 # push to remote",
|
|
595
|
+
" agentbox git push 1 --host-only # move back the branch to your pc",
|
|
596
|
+
" agentbox git pr create 1 -f # create a PR from the box",
|
|
597
|
+
" agentbox destroy # remove the box",
|
|
598
|
+
"",
|
|
599
|
+
" # Or ask your host agent (via the /agentbox-info skill) to spin up",
|
|
600
|
+
" # boxes for subtasks and orchestrate them for you"
|
|
601
|
+
];
|
|
602
|
+
var COMPACT_MORE = [
|
|
603
|
+
" More in `agentbox help`",
|
|
604
|
+
" dashboard, pause|stop|checkpoint, claude|codex|opencode,",
|
|
605
|
+
" connect|download|services|inbound, drive|queue, config, \u2026"
|
|
606
|
+
];
|
|
607
|
+
var COMPACT_FOOTER = ["Run `agentbox <command> --help` for command options."];
|
|
608
|
+
function buildCompactHelp(program2) {
|
|
609
|
+
const byName = new Map(program2.commands.map((c) => [c.name(), c]));
|
|
610
|
+
const rowTerm = (row2) => {
|
|
611
|
+
if (row2.term) return row2.term;
|
|
612
|
+
if (row2.commands.length === 1) {
|
|
613
|
+
const cmd = byName.get(row2.commands[0]);
|
|
614
|
+
if (cmd) return term(cmd);
|
|
615
|
+
}
|
|
616
|
+
return row2.commands.join("|");
|
|
617
|
+
};
|
|
618
|
+
const allTerms = COMPACT_HELP.flatMap((g) => g.rows.map(rowTerm));
|
|
619
|
+
const pad5 = Math.max(0, ...allTerms.map((t) => t.length)) + 3;
|
|
620
|
+
const lines = ["Commands:"];
|
|
621
|
+
for (const g of COMPACT_HELP) {
|
|
622
|
+
lines.push("", ` ${g.title}`);
|
|
623
|
+
for (const row2 of g.rows) {
|
|
624
|
+
const cmd = byName.get(row2.commands[0]);
|
|
625
|
+
const description = row2.description ?? cmd?.description() ?? "";
|
|
626
|
+
lines.push(` ${rowTerm(row2).padEnd(pad5)}${description}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
lines.push("", ...COMPACT_MORE, "", ...COMPACT_EXAMPLE, "", ...COMPACT_FOOTER);
|
|
630
|
+
return lines.join("\n");
|
|
631
|
+
}
|
|
466
632
|
|
|
467
633
|
// src/commands/agent.ts
|
|
468
634
|
import { log as log3 } from "@clack/prompts";
|
|
@@ -1343,7 +1509,7 @@ function decideTrayUpdate(input) {
|
|
|
1343
1509
|
function isReleaseVersion(v) {
|
|
1344
1510
|
const core = v.split("-", 1)[0] ?? v;
|
|
1345
1511
|
const parts = core.split(".");
|
|
1346
|
-
return parts.length === 3 && parts.every((
|
|
1512
|
+
return parts.length === 3 && parts.every((p2) => /^\d+$/.test(p2)) && core !== "0.0.0";
|
|
1347
1513
|
}
|
|
1348
1514
|
async function readInstalledTrayVersion() {
|
|
1349
1515
|
if (!trayInstalled()) return void 0;
|
|
@@ -1903,6 +2069,15 @@ function cloudSizingProviderOptions(providerName, cfg, flags = {}) {
|
|
|
1903
2069
|
if (providerName === "e2b") {
|
|
1904
2070
|
out.timeoutMs = cfg.box.e2bTimeoutMs;
|
|
1905
2071
|
}
|
|
2072
|
+
if (providerName === "remote-docker") {
|
|
2073
|
+
const host = (flags.remoteHost?.trim() || cfg.box.remoteDockerHost || "").trim();
|
|
2074
|
+
if (host.length === 0) {
|
|
2075
|
+
throw new Error(
|
|
2076
|
+
"remote-docker needs an SSH destination: use `agentbox docker:<host> \u2026`, pass `--remote-host <host>`, or set a default with `agentbox config set box.remoteDockerHost <user@host>`"
|
|
2077
|
+
);
|
|
2078
|
+
}
|
|
2079
|
+
out.remoteHost = host;
|
|
2080
|
+
}
|
|
1906
2081
|
if (providerName === "daytona") {
|
|
1907
2082
|
out.timeoutMs = cfg.box.daytonaTimeoutMs;
|
|
1908
2083
|
out.sandboxClass = resolveDaytonaClass(cfg);
|
|
@@ -1916,9 +2091,9 @@ function cloudSizingProviderOptions(providerName, cfg, flags = {}) {
|
|
|
1916
2091
|
import { stat } from "fs/promises";
|
|
1917
2092
|
import { homedir as homedir4 } from "os";
|
|
1918
2093
|
import { join as join6 } from "path";
|
|
1919
|
-
async function fileExists(
|
|
2094
|
+
async function fileExists(p2) {
|
|
1920
2095
|
try {
|
|
1921
|
-
await stat(
|
|
2096
|
+
await stat(p2);
|
|
1922
2097
|
return true;
|
|
1923
2098
|
} catch {
|
|
1924
2099
|
return false;
|
|
@@ -2017,11 +2192,11 @@ function toTarExcludes(tokens) {
|
|
|
2017
2192
|
return out;
|
|
2018
2193
|
}
|
|
2019
2194
|
function effectiveExcludes(userTokens, useDefaults) {
|
|
2020
|
-
const
|
|
2195
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
2021
2196
|
const out = [];
|
|
2022
2197
|
const add = (t) => {
|
|
2023
|
-
if (t && !
|
|
2024
|
-
|
|
2198
|
+
if (t && !seen2.has(t)) {
|
|
2199
|
+
seen2.add(t);
|
|
2025
2200
|
out.push(t);
|
|
2026
2201
|
}
|
|
2027
2202
|
};
|
|
@@ -2044,7 +2219,7 @@ function isPathExcluded(relPath, tokens) {
|
|
|
2044
2219
|
}
|
|
2045
2220
|
return false;
|
|
2046
2221
|
}
|
|
2047
|
-
async function buildNode(abs, rel, tokens,
|
|
2222
|
+
async function buildNode(abs, rel, tokens, seen2) {
|
|
2048
2223
|
let bytes = 0;
|
|
2049
2224
|
const children = [];
|
|
2050
2225
|
let entries;
|
|
@@ -2064,10 +2239,10 @@ async function buildNode(abs, rel, tokens, seen) {
|
|
|
2064
2239
|
continue;
|
|
2065
2240
|
}
|
|
2066
2241
|
const key = `${String(st.dev)}:${String(st.ino)}`;
|
|
2067
|
-
if (
|
|
2068
|
-
|
|
2242
|
+
if (seen2.has(key)) continue;
|
|
2243
|
+
seen2.add(key);
|
|
2069
2244
|
if (st.isDirectory()) {
|
|
2070
|
-
const child = await buildNode(full, childRel, tokens,
|
|
2245
|
+
const child = await buildNode(full, childRel, tokens, seen2);
|
|
2071
2246
|
bytes += child.bytes;
|
|
2072
2247
|
children.push(child);
|
|
2073
2248
|
} else if (st.isFile()) {
|
|
@@ -2246,8 +2421,8 @@ function expandHostPath(src, ctx) {
|
|
|
2246
2421
|
if (isAbsolute(src)) return resolve(src);
|
|
2247
2422
|
throw new Error(`${ctx.where}: src "${src}" must start with /, ~/, or ./`);
|
|
2248
2423
|
}
|
|
2249
|
-
function containsDotDot(
|
|
2250
|
-
const segs = normalize(
|
|
2424
|
+
function containsDotDot(p2) {
|
|
2425
|
+
const segs = normalize(p2).split("/");
|
|
2251
2426
|
return segs.some((s) => s === "..");
|
|
2252
2427
|
}
|
|
2253
2428
|
function validateBoxDest(dest, ctx) {
|
|
@@ -2264,15 +2439,15 @@ function validateBoxDest(dest, ctx) {
|
|
|
2264
2439
|
if (DENYLIST_DEST_EXACT.has(dest)) {
|
|
2265
2440
|
throw new Error(`${ctx.where}.dest "${dest}" is on the denylist`);
|
|
2266
2441
|
}
|
|
2267
|
-
for (const
|
|
2268
|
-
if (dest ===
|
|
2269
|
-
throw new Error(`${ctx.where}.dest "${dest}" is on the denylist (prefix ${
|
|
2442
|
+
for (const p2 of DENYLIST_DEST_PREFIXES) {
|
|
2443
|
+
if (dest === p2 || dest.startsWith(`${p2}/`)) {
|
|
2444
|
+
throw new Error(`${ctx.where}.dest "${dest}" is on the denylist (prefix ${p2})`);
|
|
2270
2445
|
}
|
|
2271
2446
|
}
|
|
2272
2447
|
}
|
|
2273
2448
|
async function dirSizeCapped(dir, cap, exclude = []) {
|
|
2274
2449
|
let total = 0;
|
|
2275
|
-
const
|
|
2450
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
2276
2451
|
async function walk(d) {
|
|
2277
2452
|
if (total > cap) return;
|
|
2278
2453
|
const { readdir: readdir4 } = await import("fs/promises");
|
|
@@ -2294,8 +2469,8 @@ async function dirSizeCapped(dir, cap, exclude = []) {
|
|
|
2294
2469
|
continue;
|
|
2295
2470
|
}
|
|
2296
2471
|
const key = `${String(st.dev)}:${String(st.ino)}`;
|
|
2297
|
-
if (
|
|
2298
|
-
|
|
2472
|
+
if (seen2.has(key)) continue;
|
|
2473
|
+
seen2.add(key);
|
|
2299
2474
|
if (st.isDirectory()) {
|
|
2300
2475
|
await walk(full);
|
|
2301
2476
|
} else if (st.isFile()) {
|
|
@@ -2310,7 +2485,7 @@ async function dirSizeCapped(dir, cap, exclude = []) {
|
|
|
2310
2485
|
|
|
2311
2486
|
// src/lib/carry-resync.ts
|
|
2312
2487
|
async function resyncCarryFiles(args) {
|
|
2313
|
-
const
|
|
2488
|
+
const log69 = args.onLog ?? (() => {
|
|
2314
2489
|
});
|
|
2315
2490
|
const prior = args.box.carry?.entries ?? [];
|
|
2316
2491
|
if (prior.length === 0) return { recopied: 0, skippedNew: 0 };
|
|
@@ -2322,7 +2497,7 @@ async function resyncCarryFiles(args) {
|
|
|
2322
2497
|
maxBytes: cfg.effective.box.cpMaxBytes
|
|
2323
2498
|
});
|
|
2324
2499
|
if (resolved.errors.length > 0) {
|
|
2325
|
-
|
|
2500
|
+
log69(`carry: resync skipped (resolve errors: ${resolved.errors.length})`);
|
|
2326
2501
|
return { recopied: 0, skippedNew: 0 };
|
|
2327
2502
|
}
|
|
2328
2503
|
const priorByDest = new Map(prior.map((e) => [e.dest, e]));
|
|
@@ -2339,7 +2514,7 @@ async function resyncCarryFiles(args) {
|
|
|
2339
2514
|
if (hash === void 0 || hash !== existing.hash) changed.push(entry);
|
|
2340
2515
|
}
|
|
2341
2516
|
if (skippedNew > 0) {
|
|
2342
|
-
|
|
2517
|
+
log69(
|
|
2343
2518
|
`carry: ${String(skippedNew)} new entry/entries not applied on resync \u2014 recreate the box to approve`
|
|
2344
2519
|
);
|
|
2345
2520
|
}
|
|
@@ -2347,9 +2522,9 @@ async function resyncCarryFiles(args) {
|
|
|
2347
2522
|
const result = await copyCarryPathsToBox({
|
|
2348
2523
|
container: args.box.container,
|
|
2349
2524
|
entries: changed,
|
|
2350
|
-
onLog:
|
|
2525
|
+
onLog: log69
|
|
2351
2526
|
});
|
|
2352
|
-
for (const err of result.errors)
|
|
2527
|
+
for (const err of result.errors) log69(`carry: ${err}`);
|
|
2353
2528
|
const updatedByDest = new Map(result.applied.map((e) => [e.dest, e]));
|
|
2354
2529
|
const mergedEntries = prior.map((e) => updatedByDest.get(e.dest) ?? e);
|
|
2355
2530
|
await recordBox({
|
|
@@ -2357,7 +2532,7 @@ async function resyncCarryFiles(args) {
|
|
|
2357
2532
|
carry: { count: mergedEntries.length, entries: mergedEntries }
|
|
2358
2533
|
});
|
|
2359
2534
|
if (result.applied.length > 0) {
|
|
2360
|
-
|
|
2535
|
+
log69(`carry: re-copied ${String(result.applied.length)} changed file(s)`);
|
|
2361
2536
|
}
|
|
2362
2537
|
return { recopied: result.applied.length, skippedNew };
|
|
2363
2538
|
}
|
|
@@ -2691,9 +2866,9 @@ async function resolveBranchSelection(opts) {
|
|
|
2691
2866
|
}
|
|
2692
2867
|
|
|
2693
2868
|
// src/lib/launch-recap.ts
|
|
2694
|
-
function homeShorten(
|
|
2869
|
+
function homeShorten(p2) {
|
|
2695
2870
|
const home = homedir6();
|
|
2696
|
-
return
|
|
2871
|
+
return p2 === home || p2.startsWith(home + "/") ? "~" + p2.slice(home.length) : p2;
|
|
2697
2872
|
}
|
|
2698
2873
|
function whiten(text4) {
|
|
2699
2874
|
if (process.env.NO_COLOR) return text4;
|
|
@@ -3013,21 +3188,21 @@ async function resolveSshIdentity(host) {
|
|
|
3013
3188
|
for (const line of (r.stdout ?? "").split("\n")) {
|
|
3014
3189
|
const m = /^identityfile\s+(.+)$/i.exec(line.trim());
|
|
3015
3190
|
if (!m) continue;
|
|
3016
|
-
const
|
|
3017
|
-
if (await fileExists2(
|
|
3191
|
+
const p2 = m[1].replace(/^~(?=\/)/, home);
|
|
3192
|
+
if (await fileExists2(p2)) return p2;
|
|
3018
3193
|
}
|
|
3019
3194
|
}
|
|
3020
3195
|
} catch {
|
|
3021
3196
|
}
|
|
3022
3197
|
for (const name of ["id_ed25519", "id_rsa", "id_ecdsa"]) {
|
|
3023
|
-
const
|
|
3024
|
-
if (await fileExists2(
|
|
3198
|
+
const p2 = join11(home, ".ssh", name);
|
|
3199
|
+
if (await fileExists2(p2)) return p2;
|
|
3025
3200
|
}
|
|
3026
3201
|
return null;
|
|
3027
3202
|
}
|
|
3028
|
-
async function fileExists2(
|
|
3203
|
+
async function fileExists2(p2) {
|
|
3029
3204
|
try {
|
|
3030
|
-
return (await stat4(
|
|
3205
|
+
return (await stat4(p2)).isFile();
|
|
3031
3206
|
} catch {
|
|
3032
3207
|
return false;
|
|
3033
3208
|
}
|
|
@@ -3393,13 +3568,13 @@ async function resolveCodexTeleport(opts) {
|
|
|
3393
3568
|
forwardArgs: ["resume", picked.uuid]
|
|
3394
3569
|
};
|
|
3395
3570
|
}
|
|
3396
|
-
function posixBasename(
|
|
3397
|
-
const i =
|
|
3398
|
-
return i === -1 ?
|
|
3571
|
+
function posixBasename(p2) {
|
|
3572
|
+
const i = p2.lastIndexOf("/");
|
|
3573
|
+
return i === -1 ? p2 : p2.slice(i + 1);
|
|
3399
3574
|
}
|
|
3400
|
-
function posixDirname(
|
|
3401
|
-
const i =
|
|
3402
|
-
return i === -1 ? "." :
|
|
3575
|
+
function posixDirname(p2) {
|
|
3576
|
+
const i = p2.lastIndexOf("/");
|
|
3577
|
+
return i === -1 ? "." : p2.slice(0, i);
|
|
3403
3578
|
}
|
|
3404
3579
|
async function listCodexSessions(sessionsRoot) {
|
|
3405
3580
|
const out = [];
|
|
@@ -3561,10 +3736,10 @@ import { existsSync as existsSync7 } from "fs";
|
|
|
3561
3736
|
import { homedir as homedir10, tmpdir as tmpdir5 } from "os";
|
|
3562
3737
|
import { basename as basename2, isAbsolute as isAbsolute2, join as join14, resolve as resolve2 } from "path";
|
|
3563
3738
|
var BOX_CLAUDE_PLANS_DIR = "/home/vscode/.claude/plans";
|
|
3564
|
-
function expandHome(
|
|
3565
|
-
if (
|
|
3566
|
-
if (
|
|
3567
|
-
return isAbsolute2(
|
|
3739
|
+
function expandHome(p2, hostHome) {
|
|
3740
|
+
if (p2 === "~") return hostHome;
|
|
3741
|
+
if (p2.startsWith("~/")) return join14(hostHome, p2.slice(2));
|
|
3742
|
+
return isAbsolute2(p2) ? p2 : resolve2(p2);
|
|
3568
3743
|
}
|
|
3569
3744
|
async function resolvePlanTeleport(opts) {
|
|
3570
3745
|
const hostHome = opts.hostHome ?? homedir10();
|
|
@@ -3887,7 +4062,7 @@ async function evaluateCheckpoint(provider, projectRoot, ref) {
|
|
|
3887
4062
|
}
|
|
3888
4063
|
async function evaluateBaseFreshness(provider, claudeInstall) {
|
|
3889
4064
|
if (provider === "docker") {
|
|
3890
|
-
const { evaluateDockerBaseFreshness: evaluateDockerBaseFreshness2 } = await import("./dist-
|
|
4065
|
+
const { evaluateDockerBaseFreshness: evaluateDockerBaseFreshness2 } = await import("./dist-POVRY7HO.js");
|
|
3891
4066
|
return await evaluateDockerBaseFreshness2({ claudeInstall });
|
|
3892
4067
|
}
|
|
3893
4068
|
const stored = currentCloudBaseFingerprint(provider);
|
|
@@ -3908,7 +4083,7 @@ function buildSetupInitialPrompt(workspace, hasAgentboxYaml = false) {
|
|
|
3908
4083
|
var WIZARD_AUTOLAUNCH_ENV = "AGENTBOX_WIZARD_AUTOLAUNCH";
|
|
3909
4084
|
var WIZARD_ENV_FILES_ENV = "AGENTBOX_WIZARD_ENV_FILES";
|
|
3910
4085
|
var WIZARD_RECREATE_ENV = "AGENTBOX_WIZARD_RECREATE";
|
|
3911
|
-
var WIZARD_ENV_SCAN_PATTERNS = DEFAULT_ENV_PATTERNS.filter((
|
|
4086
|
+
var WIZARD_ENV_SCAN_PATTERNS = DEFAULT_ENV_PATTERNS.filter((p2) => p2 !== "agentbox.yaml");
|
|
3912
4087
|
async function maybeRunSetupWizard(args) {
|
|
3913
4088
|
if (process.env[WIZARD_AUTOLAUNCH_ENV] === "1") {
|
|
3914
4089
|
if (args.command !== "claude") return { action: "proceed" };
|
|
@@ -3984,7 +4159,7 @@ async function maybeRunSetupWizard(args) {
|
|
|
3984
4159
|
if (found.length > 0) {
|
|
3985
4160
|
const picked = await multiselect({
|
|
3986
4161
|
message: "Import host env/secret files into the box? (space to toggle, enter to confirm)",
|
|
3987
|
-
options: found.map((
|
|
4162
|
+
options: found.map((p2) => ({ value: p2, label: p2 })),
|
|
3988
4163
|
initialValues: found,
|
|
3989
4164
|
required: false
|
|
3990
4165
|
});
|
|
@@ -4065,7 +4240,7 @@ function serializeEnvFilesForEnv(files) {
|
|
|
4065
4240
|
}
|
|
4066
4241
|
function parseEnvFilesFromEnv(raw) {
|
|
4067
4242
|
if (!raw) return void 0;
|
|
4068
|
-
const out = raw.split("\0").filter((
|
|
4243
|
+
const out = raw.split("\0").filter((p2) => p2.length > 0);
|
|
4069
4244
|
return out.length > 0 ? out : void 0;
|
|
4070
4245
|
}
|
|
4071
4246
|
function passthroughFlags(opts) {
|
|
@@ -4148,7 +4323,7 @@ async function renderDocker(status) {
|
|
|
4148
4323
|
}
|
|
4149
4324
|
async function daytonaStatus() {
|
|
4150
4325
|
try {
|
|
4151
|
-
const mod = await import("./dist-
|
|
4326
|
+
const mod = await import("./dist-AR5CHRSV.js");
|
|
4152
4327
|
return await mod.getDaytonaStatus();
|
|
4153
4328
|
} catch (err) {
|
|
4154
4329
|
return {
|
|
@@ -4159,7 +4334,7 @@ async function daytonaStatus() {
|
|
|
4159
4334
|
}
|
|
4160
4335
|
async function e2bStatus() {
|
|
4161
4336
|
try {
|
|
4162
|
-
const mod = await import("./dist-
|
|
4337
|
+
const mod = await import("./dist-K4LNH3EC.js");
|
|
4163
4338
|
const cred = mod.readE2bCredStatus();
|
|
4164
4339
|
if (cred.auth === "none") {
|
|
4165
4340
|
return { configured: false, reason: "not configured \u2014 run `agentbox e2b login`" };
|
|
@@ -4261,14 +4436,15 @@ function resolvePrepareLocation(providerName, cliLocation, effective) {
|
|
|
4261
4436
|
const configured = providerName === "hetzner" ? effective?.box.hetznerLocation : providerName === "digitalocean" ? effective?.box.digitaloceanRegion : providerName === "daytona" ? effective?.box.daytonaRegion : void 0;
|
|
4262
4437
|
return cliLocation?.trim() || configured || void 0;
|
|
4263
4438
|
}
|
|
4264
|
-
async function runPrepare(
|
|
4265
|
-
if (!isKnownProvider(
|
|
4439
|
+
async function runPrepare(providerSpec, opts = {}) {
|
|
4440
|
+
if (!isKnownProvider(providerSpec)) {
|
|
4266
4441
|
process.stderr.write(
|
|
4267
4442
|
`error: --provider must be one of: ${getRuntimeProviderNames().join(", ")}
|
|
4268
4443
|
`
|
|
4269
4444
|
);
|
|
4270
4445
|
process.exit(1);
|
|
4271
4446
|
}
|
|
4447
|
+
const { name: providerName, remoteHost } = parseProviderSpec(providerSpec);
|
|
4272
4448
|
if (providerName === "daytona" && !opts.yes && process.stdin.isTTY) {
|
|
4273
4449
|
process.stdout.write(
|
|
4274
4450
|
"This will trigger a Daytona image build (~7 min cold, ~seconds with cache) and register a named snapshot in your org.\nRe-run with --yes to skip this notice.\n"
|
|
@@ -4287,6 +4463,7 @@ async function runPrepare(providerName, opts = {}) {
|
|
|
4287
4463
|
const vmBaseImage = providerName === "daytona" ? cfg?.effective.box.daytonaVmBaseImage || void 0 : void 0;
|
|
4288
4464
|
const location = resolvePrepareLocation(providerName, opts.location, cfg?.effective);
|
|
4289
4465
|
const size = opts.size?.trim() || (cfg ? resolveBoxSize(cfg.effective, providerName) : "") || void 0;
|
|
4466
|
+
const host = providerName === "remote-docker" ? remoteHost || cfg?.effective.box.remoteDockerHost || void 0 : void 0;
|
|
4290
4467
|
const sp = spinner4();
|
|
4291
4468
|
sp.start(`preparing ${providerName}\u2026`);
|
|
4292
4469
|
try {
|
|
@@ -4299,6 +4476,7 @@ async function runPrepare(providerName, opts = {}) {
|
|
|
4299
4476
|
claudeInstall,
|
|
4300
4477
|
location,
|
|
4301
4478
|
size,
|
|
4479
|
+
host,
|
|
4302
4480
|
sandboxClass,
|
|
4303
4481
|
vmBaseImage,
|
|
4304
4482
|
onLog: (line) => sp.message(line.slice(0, 80))
|
|
@@ -4962,7 +5140,7 @@ async function attachClaudeWrapped(box, sessionName, reattach, onError, openIn)
|
|
|
4962
5140
|
onError,
|
|
4963
5141
|
openIn,
|
|
4964
5142
|
onPasteImage: canPaste ? () => pasteHostClipboardImage(provider, box) : void 0,
|
|
4965
|
-
onPasteImageFile: canPaste ? (
|
|
5143
|
+
onPasteImageFile: canPaste ? (p2) => uploadImageFileToBox(provider, box, p2) : void 0
|
|
4966
5144
|
});
|
|
4967
5145
|
process.exit(code);
|
|
4968
5146
|
}
|
|
@@ -5203,7 +5381,9 @@ var claudeCommand = new Command5("claude").description("Create a sandboxed box a
|
|
|
5203
5381
|
cliOverrides: buildClaudeCliOverrides(opts)
|
|
5204
5382
|
});
|
|
5205
5383
|
const projectRoot = (await findProjectRoot(opts.workspace)).root;
|
|
5206
|
-
const
|
|
5384
|
+
const { name: providerName, remoteHost } = parseProviderSpec(
|
|
5385
|
+
opts.provider ?? cfg.effective.box.provider ?? "docker"
|
|
5386
|
+
);
|
|
5207
5387
|
const isCloud = providerName !== "docker";
|
|
5208
5388
|
if (cfg.effective.git.pushMode === "direct" && !isCloud) {
|
|
5209
5389
|
prompt_exports.log.error(
|
|
@@ -5420,7 +5600,9 @@ var claudeCommand = new Command5("claude").description("Create a sandboxed box a
|
|
|
5420
5600
|
gitPushMode: cfg.effective.git.pushMode,
|
|
5421
5601
|
// Per-provider session-lifetime (e2b/vercel timeout) so the keepalive
|
|
5422
5602
|
// seeds correctly; mirrors `agentbox create`.
|
|
5423
|
-
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective
|
|
5603
|
+
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective, {
|
|
5604
|
+
remoteHost
|
|
5605
|
+
})
|
|
5424
5606
|
},
|
|
5425
5607
|
binary: "claude",
|
|
5426
5608
|
hasSeedPrompt: Boolean(planPrepared) || wiz.action === "launch-with-prompt" && Boolean(wiz.initialPrompt) || Boolean(resumePrepared),
|
|
@@ -6189,9 +6371,9 @@ async function maybeRunCodexLogin(args) {
|
|
|
6189
6371
|
}
|
|
6190
6372
|
async function cloudCodexCredAvailable(env = process.env) {
|
|
6191
6373
|
if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
|
|
6192
|
-
for (const
|
|
6374
|
+
for (const p2 of [CODEX_CREDENTIALS_BACKUP_FILE, join18(homedir14(), ".codex", "auth.json")]) {
|
|
6193
6375
|
try {
|
|
6194
|
-
await access(
|
|
6376
|
+
await access(p2);
|
|
6195
6377
|
return true;
|
|
6196
6378
|
} catch {
|
|
6197
6379
|
}
|
|
@@ -6332,7 +6514,9 @@ var codexCommand = new Command6("codex").description("Create a sandboxed box and
|
|
|
6332
6514
|
cliOverrides: buildCodexCliOverrides(opts)
|
|
6333
6515
|
});
|
|
6334
6516
|
const projectRoot = (await findProjectRoot(opts.workspace)).root;
|
|
6335
|
-
const
|
|
6517
|
+
const { name: providerName, remoteHost } = parseProviderSpec(
|
|
6518
|
+
opts.provider ?? cfg.effective.box.provider ?? "docker"
|
|
6519
|
+
);
|
|
6336
6520
|
const isCloud = providerName !== "docker";
|
|
6337
6521
|
if (cfg.effective.git.pushMode === "direct" && !isCloud) {
|
|
6338
6522
|
prompt_exports.log.error(
|
|
@@ -6467,7 +6651,9 @@ var codexCommand = new Command6("codex").description("Create a sandboxed box and
|
|
|
6467
6651
|
controlPlaneUrl: cfg.effective.relay.controlPlaneUrl,
|
|
6468
6652
|
gitPushMode: cfg.effective.git.pushMode,
|
|
6469
6653
|
// Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
|
|
6470
|
-
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective
|
|
6654
|
+
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective, {
|
|
6655
|
+
remoteHost
|
|
6656
|
+
})
|
|
6471
6657
|
},
|
|
6472
6658
|
binary: "codex",
|
|
6473
6659
|
sessionName: cfg.effective.codex.sessionName,
|
|
@@ -7050,9 +7236,9 @@ async function cloudOpencodeCredAvailable(env = process.env) {
|
|
|
7050
7236
|
for (const k of OPENCODE_FORWARDED_ENV_KEYS) {
|
|
7051
7237
|
if ((env[k] ?? "").length > 0) return true;
|
|
7052
7238
|
}
|
|
7053
|
-
for (const
|
|
7239
|
+
for (const p2 of [OPENCODE_CREDENTIALS_BACKUP_FILE, join19(homedir15(), ".local", "share", "opencode", "auth.json")]) {
|
|
7054
7240
|
try {
|
|
7055
|
-
await access2(
|
|
7241
|
+
await access2(p2);
|
|
7056
7242
|
return true;
|
|
7057
7243
|
} catch {
|
|
7058
7244
|
}
|
|
@@ -7169,7 +7355,9 @@ var opencodeCommand = new Command7("opencode").description("Create a sandboxed b
|
|
|
7169
7355
|
cliOverrides: buildOpencodeCliOverrides(opts)
|
|
7170
7356
|
});
|
|
7171
7357
|
const projectRoot = (await findProjectRoot(opts.workspace)).root;
|
|
7172
|
-
const
|
|
7358
|
+
const { name: providerName, remoteHost } = parseProviderSpec(
|
|
7359
|
+
opts.provider ?? cfg.effective.box.provider ?? "docker"
|
|
7360
|
+
);
|
|
7173
7361
|
const isCloud = providerName !== "docker";
|
|
7174
7362
|
if (cfg.effective.git.pushMode === "direct" && !isCloud) {
|
|
7175
7363
|
prompt_exports.log.error(
|
|
@@ -7304,7 +7492,9 @@ var opencodeCommand = new Command7("opencode").description("Create a sandboxed b
|
|
|
7304
7492
|
controlPlaneUrl: cfg.effective.relay.controlPlaneUrl,
|
|
7305
7493
|
gitPushMode: cfg.effective.git.pushMode,
|
|
7306
7494
|
// Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
|
|
7307
|
-
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective
|
|
7495
|
+
providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective, {
|
|
7496
|
+
remoteHost
|
|
7497
|
+
})
|
|
7308
7498
|
},
|
|
7309
7499
|
binary: "opencode",
|
|
7310
7500
|
sessionName: cfg.effective.opencode.sessionName,
|
|
@@ -7894,7 +8084,7 @@ function cloudRow(c, backend, def) {
|
|
|
7894
8084
|
}
|
|
7895
8085
|
async function listAllProjects() {
|
|
7896
8086
|
const projects = await listProjectsConfigured();
|
|
7897
|
-
const rootByHash = new Map(projects.map((
|
|
8087
|
+
const rootByHash = new Map(projects.map((p2) => [p2.hash, p2.originalPath]));
|
|
7898
8088
|
const dockerGroups = await listAllCheckpoints();
|
|
7899
8089
|
const cloudGroups = await Promise.all(
|
|
7900
8090
|
(await allCloudBackends()).map(async (backend) => ({
|
|
@@ -8275,9 +8465,22 @@ var OPEN_IN_APPS = [
|
|
|
8275
8465
|
"iterm2",
|
|
8276
8466
|
"finder"
|
|
8277
8467
|
];
|
|
8278
|
-
var PERSISTENT_SSH_PROVIDERS = [
|
|
8279
|
-
|
|
8280
|
-
|
|
8468
|
+
var PERSISTENT_SSH_PROVIDERS = [
|
|
8469
|
+
"docker",
|
|
8470
|
+
"hetzner",
|
|
8471
|
+
// remote-docker qualifies for the same reason docker does: a per-box key that
|
|
8472
|
+
// outlives the CLI call. Its box sshd is reached by `ProxyJump`ing through the
|
|
8473
|
+
// engine (ssh's own transport — no AgentBox-held tunnel to keep alive), and
|
|
8474
|
+
// start/open re-resolve the published port into `~/.ssh/config`.
|
|
8475
|
+
"remote-docker"
|
|
8476
|
+
];
|
|
8477
|
+
var IDE_PROVIDERS = ["docker", "hetzner", "daytona", "remote-docker"];
|
|
8478
|
+
var SSH_MOUNT_PROVIDERS = [
|
|
8479
|
+
"docker",
|
|
8480
|
+
"hetzner",
|
|
8481
|
+
"daytona",
|
|
8482
|
+
"remote-docker"
|
|
8483
|
+
];
|
|
8281
8484
|
function realSeams() {
|
|
8282
8485
|
return {
|
|
8283
8486
|
env: process.env,
|
|
@@ -8299,8 +8502,8 @@ function macAppInstalled(appName, seams) {
|
|
|
8299
8502
|
return seams.existsSync(join20("/Applications", appName)) || seams.existsSync(join20(seams.homedir(), "Applications", appName));
|
|
8300
8503
|
}
|
|
8301
8504
|
function defaultHerdrSocketPath(seams = realSeams()) {
|
|
8302
|
-
const
|
|
8303
|
-
return seams.existsSync(
|
|
8505
|
+
const p2 = join20(seams.homedir(), ".config", "herdr", "herdr.sock");
|
|
8506
|
+
return seams.existsSync(p2) ? p2 : void 0;
|
|
8304
8507
|
}
|
|
8305
8508
|
var CMUX_APP_CLI_SUFFIX = "cmux.app/Contents/Resources/bin/cmux";
|
|
8306
8509
|
var VSCODE_APPS = [
|
|
@@ -8323,8 +8526,8 @@ function resolveVscodeCli(cli, seams = realSeams()) {
|
|
|
8323
8526
|
const app = VSCODE_APPS.find((a) => a.cli === cli);
|
|
8324
8527
|
if (!app) return void 0;
|
|
8325
8528
|
for (const root of ["/Applications", join20(seams.homedir(), "Applications")]) {
|
|
8326
|
-
const
|
|
8327
|
-
if (seams.existsSync(
|
|
8529
|
+
const p2 = join20(root, app.appName, app.bundleCliSuffix);
|
|
8530
|
+
if (seams.existsSync(p2)) return p2;
|
|
8328
8531
|
}
|
|
8329
8532
|
return void 0;
|
|
8330
8533
|
}
|
|
@@ -8504,20 +8707,20 @@ async function prepareDockerAttach(box, opts) {
|
|
|
8504
8707
|
return attachedContainerUri(box.container, { dockerContext });
|
|
8505
8708
|
}
|
|
8506
8709
|
async function prepareCloudAttach(box, opts) {
|
|
8507
|
-
const
|
|
8508
|
-
const state = await
|
|
8710
|
+
const p2 = await providerForBox(box);
|
|
8711
|
+
const state = await p2.probeState(box);
|
|
8509
8712
|
if (state === "paused") {
|
|
8510
8713
|
log20.info("box is paused; resuming");
|
|
8511
|
-
await
|
|
8714
|
+
await p2.resume(box);
|
|
8512
8715
|
} else if (state === "stopped") {
|
|
8513
8716
|
log20.info("box is stopped; starting");
|
|
8514
|
-
await
|
|
8717
|
+
await p2.start(box);
|
|
8515
8718
|
} else if (state === "missing") {
|
|
8516
8719
|
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
8517
8720
|
}
|
|
8518
8721
|
if (opts.wait) {
|
|
8519
8722
|
try {
|
|
8520
|
-
const r = await
|
|
8723
|
+
const r = await p2.exec(box, ["agentbox-ctl", "wait-ready", "--json", "--timeout", opts.timeoutMs]);
|
|
8521
8724
|
const reply = JSON.parse(r.stdout);
|
|
8522
8725
|
if (!reply.ready) {
|
|
8523
8726
|
const lines = [];
|
|
@@ -8531,7 +8734,7 @@ async function prepareCloudAttach(box, opts) {
|
|
|
8531
8734
|
log20.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
|
|
8532
8735
|
}
|
|
8533
8736
|
}
|
|
8534
|
-
const { alias } = await ensureCloudSshAlias(box,
|
|
8737
|
+
const { alias } = await ensureCloudSshAlias(box, p2, { bringOnline: false });
|
|
8535
8738
|
log20.info(`updated ~/.ssh/config alias ${alias}`);
|
|
8536
8739
|
return `vscode-remote://ssh-remote+${alias}/workspace`;
|
|
8537
8740
|
}
|
|
@@ -8854,9 +9057,9 @@ var listProjectsCommand = new Command12("list-projects").description("List direc
|
|
|
8854
9057
|
process.stdout.write("(no per-project config recorded)\n");
|
|
8855
9058
|
return;
|
|
8856
9059
|
}
|
|
8857
|
-
for (const
|
|
9060
|
+
for (const p2 of projects) {
|
|
8858
9061
|
process.stdout.write(
|
|
8859
|
-
`${
|
|
9062
|
+
`${p2.hash} ${p2.originalPath}${p2.hasConfigFile ? "" : " (meta only \u2014 no config.yaml)"}
|
|
8860
9063
|
`
|
|
8861
9064
|
);
|
|
8862
9065
|
}
|
|
@@ -8931,9 +9134,9 @@ function parseBoxArg(arg) {
|
|
|
8931
9134
|
const prefix = arg.slice(0, idx);
|
|
8932
9135
|
if (prefix.includes("/")) return null;
|
|
8933
9136
|
if (prefix.length === 0) return null;
|
|
8934
|
-
const
|
|
8935
|
-
if (
|
|
8936
|
-
return { boxRef: prefix, path:
|
|
9137
|
+
const p2 = arg.slice(idx + 1);
|
|
9138
|
+
if (p2.length === 0) return null;
|
|
9139
|
+
return { boxRef: prefix, path: p2 };
|
|
8937
9140
|
}
|
|
8938
9141
|
function parseArgs(paths) {
|
|
8939
9142
|
if (paths.length === 0) {
|
|
@@ -9116,7 +9319,13 @@ async function attachShell(record) {
|
|
|
9116
9319
|
}
|
|
9117
9320
|
var createCommand = new Command14("create").description(
|
|
9118
9321
|
"Create and start a new agent box (Docker container with /workspace seeded via in-container git worktree)"
|
|
9119
|
-
).option("-w, --workspace <path>", "host workspace to mount", process.cwd()).option("-n, --name <name>", "friendly box name (default: <workspace-basename>-<id>)").option(
|
|
9322
|
+
).option("-w, --workspace <path>", "host workspace to mount", process.cwd()).option("-n, --name <name>", "friendly box name (default: <workspace-basename>-<id>)").option(
|
|
9323
|
+
"--provider <name>",
|
|
9324
|
+
"sandbox backend: docker (default), daytona, hetzner, digitalocean, vercel, e2b, remote-docker. `docker:<host>` runs the box on that machine's docker engine over SSH."
|
|
9325
|
+
).option(
|
|
9326
|
+
"--remote-host <dest>",
|
|
9327
|
+
"SSH destination whose docker engine runs the box \u2014 an ~/.ssh/config alias or [user@]host[:port]. Overrides box.remoteDockerHost. Same as `--provider docker:<dest>`. remote-docker-only."
|
|
9328
|
+
).option(
|
|
9120
9329
|
"--host-snapshot",
|
|
9121
9330
|
"APFS-clone the host workspace into a per-box scratch dir before seeding /workspace (stabilizes the tar-pipe source)"
|
|
9122
9331
|
).option("--no-host-snapshot", "bind the live workspace directly (host edits leak into reads)").option(
|
|
@@ -9191,7 +9400,10 @@ var createCommand = new Command14("create").description(
|
|
|
9191
9400
|
await registerProject(projectRoot);
|
|
9192
9401
|
} catch {
|
|
9193
9402
|
}
|
|
9194
|
-
const providerName
|
|
9403
|
+
const { name: providerName, remoteHost: specRemoteHost } = parseProviderSpec(
|
|
9404
|
+
opts.provider ?? cfg.effective.box.provider ?? "docker"
|
|
9405
|
+
);
|
|
9406
|
+
const remoteHost = opts.remoteHost ?? specRemoteHost;
|
|
9195
9407
|
if (cfg.effective.git.pushMode === "direct" && providerName === "docker") {
|
|
9196
9408
|
log22.error(
|
|
9197
9409
|
"git.pushMode=direct / --dangerously-with-credentials is not applicable to docker boxes (they run on your host and bind-mount the host .git). Use a cloud provider (e.g. --provider hetzner|e2b|vercel|daytona)."
|
|
@@ -9212,6 +9424,9 @@ var createCommand = new Command14("create").description(
|
|
|
9212
9424
|
if (opts.inbound && providerName !== "hetzner" && providerName !== "digitalocean") {
|
|
9213
9425
|
log22.warn(`--inbound applies to hetzner/digitalocean only; ignored for provider ${providerName}`);
|
|
9214
9426
|
}
|
|
9427
|
+
if (opts.remoteHost && providerName !== "remote-docker") {
|
|
9428
|
+
log22.warn(`--remote-host applies to remote-docker only; ignored for provider ${providerName}`);
|
|
9429
|
+
}
|
|
9215
9430
|
const imageDefault = resolveBoxImage(
|
|
9216
9431
|
cfg.effective,
|
|
9217
9432
|
providerName
|
|
@@ -9368,7 +9583,8 @@ var createCommand = new Command14("create").description(
|
|
|
9368
9583
|
...cloudSizingProviderOptions(provider.name, cfg.effective, {
|
|
9369
9584
|
size: opts.size,
|
|
9370
9585
|
location: opts.location,
|
|
9371
|
-
inbound: opts.inbound
|
|
9586
|
+
inbound: opts.inbound,
|
|
9587
|
+
remoteHost
|
|
9372
9588
|
})
|
|
9373
9589
|
}
|
|
9374
9590
|
});
|
|
@@ -9421,7 +9637,7 @@ var createCommand = new Command14("create").description(
|
|
|
9421
9637
|
const n = await bumpProjectGcCounter();
|
|
9422
9638
|
if (n % m.pruneProjectConfigsEvery === 0) {
|
|
9423
9639
|
const boxes = await listBoxes();
|
|
9424
|
-
const protectedPaths = boxes.map((b) => b.projectRoot).filter((
|
|
9640
|
+
const protectedPaths = boxes.map((b) => b.projectRoot).filter((p2) => typeof p2 === "string");
|
|
9425
9641
|
const res = await pruneOrphanProjectConfigs({ protectedPaths });
|
|
9426
9642
|
if (res.removed.length > 0) {
|
|
9427
9643
|
log22.info(
|
|
@@ -9434,7 +9650,7 @@ var createCommand = new Command14("create").description(
|
|
|
9434
9650
|
}
|
|
9435
9651
|
outro7("done");
|
|
9436
9652
|
if (attachClaudeAfter) {
|
|
9437
|
-
const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-
|
|
9653
|
+
const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-7WRQH6XZ.js");
|
|
9438
9654
|
await cloudAgentAttach2({
|
|
9439
9655
|
box: result.record,
|
|
9440
9656
|
binary: "claude",
|
|
@@ -12012,9 +12228,73 @@ var digitaloceanCommand = new Command21("digitalocean").description(
|
|
|
12012
12228
|
"DigitalOcean Droplet provider \u2014 credentials, firewall, plus sugar for `--provider digitalocean` (e.g. `agentbox digitalocean create|claude|codex|opencode`)"
|
|
12013
12229
|
).addCommand(loginSub5, { isDefault: true }).addCommand(firewallSub2);
|
|
12014
12230
|
|
|
12231
|
+
// ../../packages/sandbox-remote-docker/dist/cli.js
|
|
12232
|
+
import { Command as Command22 } from "commander";
|
|
12233
|
+
import * as p from "@clack/prompts";
|
|
12234
|
+
var remoteDockerCommand = new Command22("remote-docker").description("Remote Docker provider \u2014 run boxes on your own machine over SSH").addCommand(
|
|
12235
|
+
new Command22("check").description("Verify an SSH destination can host boxes (ssh reachable + docker present)").argument("[host]", "SSH destination (default: box.remoteDockerHost)").action(async (host) => {
|
|
12236
|
+
const target = (host ?? await configuredHost()).trim();
|
|
12237
|
+
if (!target) {
|
|
12238
|
+
p.log.error(
|
|
12239
|
+
"no SSH destination \u2014 pass one (`agentbox remote-docker check user@host`) or set `box.remoteDockerHost`"
|
|
12240
|
+
);
|
|
12241
|
+
process.exitCode = 1;
|
|
12242
|
+
return;
|
|
12243
|
+
}
|
|
12244
|
+
const s = p.spinner();
|
|
12245
|
+
s.start(`probing ${target}`);
|
|
12246
|
+
const res = await probeRemoteEngine(target);
|
|
12247
|
+
if (!res.ok) {
|
|
12248
|
+
s.stop(`${target}: unusable`);
|
|
12249
|
+
p.log.error(res.error);
|
|
12250
|
+
process.exitCode = 1;
|
|
12251
|
+
return;
|
|
12252
|
+
}
|
|
12253
|
+
s.stop(`${target}: docker ${res.version} (${res.os}/${res.arch})`);
|
|
12254
|
+
const baked = readPreparedState5()?.hosts[target];
|
|
12255
|
+
p.log.info(
|
|
12256
|
+
baked ? `box image baked: ${baked.imageRef}` : `box image not baked yet \u2014 the first create will do it, or run \`agentbox prepare --provider docker:${target}\``
|
|
12257
|
+
);
|
|
12258
|
+
})
|
|
12259
|
+
).addCommand(
|
|
12260
|
+
new Command22("use").description("Set the default SSH destination for `--provider remote-docker`").argument("<host>", "SSH destination (~/.ssh/config alias or [user@]host[:port])").option("-g, --global", "write to the global config instead of this project").action(async (host, opts) => {
|
|
12261
|
+
const res = await probeRemoteEngine(host);
|
|
12262
|
+
if (!res.ok) {
|
|
12263
|
+
p.log.error(res.error);
|
|
12264
|
+
process.exitCode = 1;
|
|
12265
|
+
return;
|
|
12266
|
+
}
|
|
12267
|
+
await setConfigValue(
|
|
12268
|
+
opts.global ? "global" : "project",
|
|
12269
|
+
"box.remoteDockerHost",
|
|
12270
|
+
host,
|
|
12271
|
+
process.cwd()
|
|
12272
|
+
);
|
|
12273
|
+
p.log.success(
|
|
12274
|
+
`box.remoteDockerHost = ${host} (${opts.global ? "global" : "project"}) \u2014 docker ${res.version}`
|
|
12275
|
+
);
|
|
12276
|
+
})
|
|
12277
|
+
).addCommand(
|
|
12278
|
+
new Command22("hosts").description("List the remote engines this machine has baked a box image on").action(() => {
|
|
12279
|
+
const state = readPreparedState5();
|
|
12280
|
+
const hosts = Object.entries(state?.hosts ?? {});
|
|
12281
|
+
if (hosts.length === 0) {
|
|
12282
|
+
p.log.info("no remote engines prepared yet");
|
|
12283
|
+
return;
|
|
12284
|
+
}
|
|
12285
|
+
for (const [host, info] of hosts) {
|
|
12286
|
+
p.log.info(`${host} ${info.imageRef} (${info.cliVersion ?? "\u2014"}, ${info.createdAt})`);
|
|
12287
|
+
}
|
|
12288
|
+
})
|
|
12289
|
+
);
|
|
12290
|
+
async function configuredHost() {
|
|
12291
|
+
const cfg = await loadEffectiveConfig(process.cwd());
|
|
12292
|
+
return cfg.effective.box.remoteDockerHost || "";
|
|
12293
|
+
}
|
|
12294
|
+
|
|
12015
12295
|
// src/commands/destroy.ts
|
|
12016
12296
|
import { execa as execa7 } from "execa";
|
|
12017
|
-
import { Command as
|
|
12297
|
+
import { Command as Command23 } from "commander";
|
|
12018
12298
|
async function destroyOrphanContainer(ref) {
|
|
12019
12299
|
const candidates = ref.startsWith("agentbox-") ? [ref] : [`agentbox-${ref}`, ref];
|
|
12020
12300
|
for (const name of candidates) {
|
|
@@ -12037,7 +12317,7 @@ async function destroyOrphanContainer(ref) {
|
|
|
12037
12317
|
}
|
|
12038
12318
|
return null;
|
|
12039
12319
|
}
|
|
12040
|
-
var destroyCommand = new
|
|
12320
|
+
var destroyCommand = new Command23("destroy").alias("rm").description("Destroy a box and discard its container writable layer (where /workspace lived)").argument(
|
|
12041
12321
|
"[box]",
|
|
12042
12322
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
12043
12323
|
).option("-y, --yes", "skip the confirmation prompt").option("--keep-snapshot", "don't delete the snapshot dir under ~/.agentbox/snapshots/").action(async (idOrName, opts) => {
|
|
@@ -12103,10 +12383,10 @@ var destroyCommand = new Command22("destroy").alias("rm").description("Destroy a
|
|
|
12103
12383
|
});
|
|
12104
12384
|
|
|
12105
12385
|
// src/commands/download.ts
|
|
12106
|
-
import { Command as
|
|
12386
|
+
import { Command as Command29 } from "commander";
|
|
12107
12387
|
|
|
12108
12388
|
// src/commands/download-claude.ts
|
|
12109
|
-
import { Command as
|
|
12389
|
+
import { Command as Command24 } from "commander";
|
|
12110
12390
|
|
|
12111
12391
|
// src/commands/_agent-pull.ts
|
|
12112
12392
|
async function cloudTransportForPull(box) {
|
|
@@ -12243,7 +12523,7 @@ function tag(item) {
|
|
|
12243
12523
|
const noun = item.category === "plugins" ? "plugin" : item.category.replace(/s$/, "");
|
|
12244
12524
|
return ` ${item.category}/${item.name} (new ${noun})`;
|
|
12245
12525
|
}
|
|
12246
|
-
var downloadClaudeCommand = new
|
|
12526
|
+
var downloadClaudeCommand = new Command24("claude").description(
|
|
12247
12527
|
"Download box-installed Claude skills/plugins/agents/commands back to host ~/.claude (additive), optionally propagating them to other boxes"
|
|
12248
12528
|
).argument(
|
|
12249
12529
|
"[box]",
|
|
@@ -12322,8 +12602,8 @@ var downloadClaudeCommand = new Command23("claude").description(
|
|
|
12322
12602
|
});
|
|
12323
12603
|
|
|
12324
12604
|
// src/commands/download-codex.ts
|
|
12325
|
-
import { Command as
|
|
12326
|
-
var downloadCodexCommand = new
|
|
12605
|
+
import { Command as Command25 } from "commander";
|
|
12606
|
+
var downloadCodexCommand = new Command25("codex").description(
|
|
12327
12607
|
"Download box-side Codex config/auth (config.toml, auth.json, prompts) back to host ~/.codex (additive), optionally propagating them to other boxes"
|
|
12328
12608
|
).argument(
|
|
12329
12609
|
"[box]",
|
|
@@ -12395,8 +12675,8 @@ var downloadCodexCommand = new Command24("codex").description(
|
|
|
12395
12675
|
});
|
|
12396
12676
|
|
|
12397
12677
|
// src/commands/download-opencode.ts
|
|
12398
|
-
import { Command as
|
|
12399
|
-
var downloadOpencodeCommand = new
|
|
12678
|
+
import { Command as Command26 } from "commander";
|
|
12679
|
+
var downloadOpencodeCommand = new Command26("opencode").description(
|
|
12400
12680
|
"Download box-side OpenCode config/auth (auth.json, opencode.json, agents, commands, themes) back to host ~/.config + ~/.local/share opencode (additive), optionally propagating them to other boxes"
|
|
12401
12681
|
).argument(
|
|
12402
12682
|
"[box]",
|
|
@@ -12468,7 +12748,7 @@ var downloadOpencodeCommand = new Command25("opencode").description(
|
|
|
12468
12748
|
});
|
|
12469
12749
|
|
|
12470
12750
|
// src/commands/download-config.ts
|
|
12471
|
-
import { Command as
|
|
12751
|
+
import { Command as Command27 } from "commander";
|
|
12472
12752
|
function tagChange(line) {
|
|
12473
12753
|
const sp = line.indexOf(" ");
|
|
12474
12754
|
const code = sp === -1 ? line : line.slice(0, sp);
|
|
@@ -12477,7 +12757,7 @@ function tagChange(line) {
|
|
|
12477
12757
|
return ` ${path} ${isNew ? "(new)" : "(overwrites host)"}`;
|
|
12478
12758
|
}
|
|
12479
12759
|
var CONFIG_PATTERNS = ["agentbox.yaml"];
|
|
12480
|
-
var downloadConfigCommand = new
|
|
12760
|
+
var downloadConfigCommand = new Command27("config").description("Download agentbox.yaml box -> host").argument(
|
|
12481
12761
|
"[box]",
|
|
12482
12762
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
12483
12763
|
).option("-y, --yes", "skip the confirmation prompt").option("--dry-run", "list matched files and exit; don't write").option("--no-refresh", "skip the box->scratch-dir rsync step").action(async (idOrName, opts) => {
|
|
@@ -12543,7 +12823,7 @@ var downloadConfigCommand = new Command26("config").description("Download agentb
|
|
|
12543
12823
|
});
|
|
12544
12824
|
|
|
12545
12825
|
// src/commands/download-env.ts
|
|
12546
|
-
import { Command as
|
|
12826
|
+
import { Command as Command28 } from "commander";
|
|
12547
12827
|
function tagChange2(line) {
|
|
12548
12828
|
const sp = line.indexOf(" ");
|
|
12549
12829
|
const code = sp === -1 ? line : line.slice(0, sp);
|
|
@@ -12551,7 +12831,7 @@ function tagChange2(line) {
|
|
|
12551
12831
|
const isNew = /^>f\++$/.test(code);
|
|
12552
12832
|
return ` ${path} ${isNew ? "(new)" : "(overwrites host)"}`;
|
|
12553
12833
|
}
|
|
12554
|
-
var downloadEnvCommand = new
|
|
12834
|
+
var downloadEnvCommand = new Command28("env").description(
|
|
12555
12835
|
"Download gitignored env/config files (.env*, .envrc, secrets.toml, agentbox.yaml, ...) box -> host"
|
|
12556
12836
|
).argument(
|
|
12557
12837
|
"[box]",
|
|
@@ -12627,7 +12907,7 @@ var downloadEnvCommand = new Command27("env").description(
|
|
|
12627
12907
|
});
|
|
12628
12908
|
|
|
12629
12909
|
// src/commands/download.ts
|
|
12630
|
-
var downloadCommand = new
|
|
12910
|
+
var downloadCommand = new Command29("download").enablePositionalOptions().description("Download a box's /workspace back into your host workspace dir (gitignore-aware)").argument(
|
|
12631
12911
|
"[box]",
|
|
12632
12912
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
12633
12913
|
).option("-y, --yes", "skip the confirmation prompt").option("--dry-run", "print the change list and exit; don't write").option(
|
|
@@ -12756,8 +13036,8 @@ downloadCommand.addCommand(downloadOpencodeCommand);
|
|
|
12756
13036
|
downloadCommand.addCommand(downloadConfigCommand);
|
|
12757
13037
|
|
|
12758
13038
|
// src/commands/drive.ts
|
|
12759
|
-
import { log as
|
|
12760
|
-
import { Command as
|
|
13039
|
+
import { log as log39 } from "@clack/prompts";
|
|
13040
|
+
import { Command as Command30 } from "commander";
|
|
12761
13041
|
|
|
12762
13042
|
// src/lib/drive/keys.ts
|
|
12763
13043
|
var NAMED = {
|
|
@@ -12836,11 +13116,11 @@ function resolveToken(raw) {
|
|
|
12836
13116
|
// src/commands/drive.ts
|
|
12837
13117
|
var PROMPT_ENTER_DELAY_MS = 200;
|
|
12838
13118
|
var POLL_INTERVAL_MS2 = 250;
|
|
12839
|
-
var driveCommand = new
|
|
13119
|
+
var driveCommand = new Command30("drive").description(
|
|
12840
13120
|
"Drive a running tmux session inside a box: snapshot the screen, send keystrokes, type text, or wait for output. Targets the agent session by default (claude \u2192 codex \u2192 opencode)."
|
|
12841
13121
|
);
|
|
12842
13122
|
var sessionOption = ["--session <name>", "tmux session to target (default: first running agent session)"];
|
|
12843
|
-
var driveSnapshotCommand = new
|
|
13123
|
+
var driveSnapshotCommand = new Command30("snapshot").description("Print the rendered terminal contents of the box's active tmux session.").argument(
|
|
12844
13124
|
"[box]",
|
|
12845
13125
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
12846
13126
|
).option(sessionOption[0], sessionOption[1]).option("--ansi", "preserve ANSI color/style escape sequences (default: plain text)").option("--with-cursor", "include cursor coordinates and pane size (implies --json)").option("--rows <range>", 'inclusive row range "FROM:TO" (negative numbers walk into scrollback)').option("--json", "emit a JSON envelope { session, cols, rows, cursor?, screen }").action(async (boxRef, opts) => {
|
|
@@ -12869,7 +13149,7 @@ var driveSnapshotCommand = new Command29("snapshot").description("Print the rend
|
|
|
12869
13149
|
handleDriveError(err);
|
|
12870
13150
|
}
|
|
12871
13151
|
});
|
|
12872
|
-
var driveKeypressCommand = new
|
|
13152
|
+
var driveKeypressCommand = new Command30("keypress").description('Send keystrokes parsed via the DSL (e.g. "<C-a>q", "ls<Enter>"). Each arg is concatenated with no spaces.').argument(
|
|
12873
13153
|
"<box>",
|
|
12874
13154
|
"box ref: project index, id, id prefix, name, or container"
|
|
12875
13155
|
).argument("<keys...>", "one or more DSL tokens / literal text; `<<` escapes a literal `<`").option(sessionOption[0], sessionOption[1]).action(async (boxRef, keys, opts) => {
|
|
@@ -12883,7 +13163,7 @@ var driveKeypressCommand = new Command29("keypress").description('Send keystroke
|
|
|
12883
13163
|
handleDriveError(err);
|
|
12884
13164
|
}
|
|
12885
13165
|
});
|
|
12886
|
-
var driveSendTextCommand = new
|
|
13166
|
+
var driveSendTextCommand = new Command30("send-text").description("Type literal text into the session (no DSL parsing, no trailing Enter).").argument("<box>", "box ref").argument("<text>", "literal text to type").option(sessionOption[0], sessionOption[1]).action(async (boxRef, text4, opts) => {
|
|
12887
13167
|
try {
|
|
12888
13168
|
const box = await resolveBoxOrExit(boxRef);
|
|
12889
13169
|
const provider = await providerForBox(box);
|
|
@@ -12893,7 +13173,7 @@ var driveSendTextCommand = new Command29("send-text").description("Type literal
|
|
|
12893
13173
|
handleDriveError(err);
|
|
12894
13174
|
}
|
|
12895
13175
|
});
|
|
12896
|
-
var drivePromptCommand = new
|
|
13176
|
+
var drivePromptCommand = new Command30("prompt").description('Type text into the agent session and press Enter \u2014 convenience for "send a message to the running agent".').argument("<box>", "box ref").argument("<text>", "prompt text to send (literal; no DSL parsing)").option(sessionOption[0], sessionOption[1]).option("--delay <ms>", `milliseconds to wait between text and Enter (default: ${String(PROMPT_ENTER_DELAY_MS)})`).action(async (boxRef, text4, opts) => {
|
|
12897
13177
|
try {
|
|
12898
13178
|
const box = await resolveBoxOrExit(boxRef);
|
|
12899
13179
|
const provider = await providerForBox(box);
|
|
@@ -12906,7 +13186,7 @@ var drivePromptCommand = new Command29("prompt").description('Type text into the
|
|
|
12906
13186
|
handleDriveError(err);
|
|
12907
13187
|
}
|
|
12908
13188
|
});
|
|
12909
|
-
var driveWaitCommand = new
|
|
13189
|
+
var driveWaitCommand = new Command30("wait").description("Block until --text appears in the session's rendered screen, or exit non-zero on timeout.").argument("<box>", "box ref").requiredOption("--text <str>", "substring to wait for").option("--timeout <ms>", "wall-clock cap in milliseconds (default: 5000)").option(sessionOption[0], sessionOption[1]).option("--json", "emit a JSON envelope { matched, elapsedMs, session, screen? }").action(async (boxRef, opts) => {
|
|
12910
13190
|
try {
|
|
12911
13191
|
const box = await resolveBoxOrExit(boxRef);
|
|
12912
13192
|
const provider = await providerForBox(box);
|
|
@@ -12939,14 +13219,14 @@ var driveWaitCommand = new Command29("wait").description("Block until --text app
|
|
|
12939
13219
|
}) + "\n"
|
|
12940
13220
|
);
|
|
12941
13221
|
} else {
|
|
12942
|
-
|
|
13222
|
+
log39.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
|
|
12943
13223
|
}
|
|
12944
13224
|
process.exit(1);
|
|
12945
13225
|
} catch (err) {
|
|
12946
13226
|
handleDriveError(err);
|
|
12947
13227
|
}
|
|
12948
13228
|
});
|
|
12949
|
-
var driveResizeCommand = new
|
|
13229
|
+
var driveResizeCommand = new Command30("resize").description("Resize the tmux window to <cols> x <rows>.").argument("<box>", "box ref").argument("<cols>", "columns (positive int)").argument("<rows>", "rows (positive int)").option(sessionOption[0], sessionOption[1]).action(async (boxRef, colsStr, rowsStr, opts) => {
|
|
12950
13230
|
try {
|
|
12951
13231
|
const box = await resolveBoxOrExit(boxRef);
|
|
12952
13232
|
const provider = await providerForBox(box);
|
|
@@ -12966,8 +13246,8 @@ driveCommand.addCommand(driveWaitCommand);
|
|
|
12966
13246
|
driveCommand.addCommand(driveResizeCommand);
|
|
12967
13247
|
function handleDriveError(err) {
|
|
12968
13248
|
if (err instanceof SessionNotFoundError) {
|
|
12969
|
-
|
|
12970
|
-
|
|
13249
|
+
log39.error(err.message);
|
|
13250
|
+
log39.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
|
|
12971
13251
|
process.exit(2);
|
|
12972
13252
|
}
|
|
12973
13253
|
handleLifecycleError(err);
|
|
@@ -12991,8 +13271,8 @@ function sleep4(ms) {
|
|
|
12991
13271
|
}
|
|
12992
13272
|
|
|
12993
13273
|
// src/commands/fork.ts
|
|
12994
|
-
import { log as
|
|
12995
|
-
import { Command as
|
|
13274
|
+
import { log as log40 } from "@clack/prompts";
|
|
13275
|
+
import { Command as Command31 } from "commander";
|
|
12996
13276
|
import { existsSync as existsSync10, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
|
|
12997
13277
|
import { homedir as homedir16 } from "os";
|
|
12998
13278
|
import { join as join21 } from "path";
|
|
@@ -13064,7 +13344,7 @@ function resolveAttachArgs(attachIn) {
|
|
|
13064
13344
|
if (attachIn === "same") return ["--attach-in", "same"];
|
|
13065
13345
|
return detectHostTerminal() === "unknown" ? ["--no-attach"] : ["--attach-in", attachIn];
|
|
13066
13346
|
}
|
|
13067
|
-
var forkCommand = new
|
|
13347
|
+
var forkCommand = new Command31("fork").description(
|
|
13068
13348
|
"Fork the current host agent session into a new box and resume it there. Autodetects the agent (Claude / Codex) and the current session from the launching agent's env, so a bare `agentbox fork` forks whatever you ran it from. Opens the box in a new terminal tab under iTerm/tmux; otherwise starts it in the background."
|
|
13069
13349
|
).argument(
|
|
13070
13350
|
"[provider]",
|
|
@@ -13090,36 +13370,36 @@ var forkCommand = new Command30("fork").description(
|
|
|
13090
13370
|
'copy a Claude Code plan file (e.g. ~/.claude/plans/<slug>.md) into the box, start claude in plan mode, and seed a "resume the plan" prompt. Claude only.'
|
|
13091
13371
|
).action(async (providerArg, opts) => {
|
|
13092
13372
|
if ((process.env.AGENTBOX_RELAY_URL ?? "").trim().length > 0) {
|
|
13093
|
-
|
|
13373
|
+
log40.error(
|
|
13094
13374
|
"agentbox fork runs on the host only: it teleports a host agent session into a new box. You appear to be inside a box (AGENTBOX_RELAY_URL is set) \u2014 box\u2192box fork is not supported yet."
|
|
13095
13375
|
);
|
|
13096
13376
|
process.exit(2);
|
|
13097
13377
|
}
|
|
13098
13378
|
const agent = opts.agent?.trim() || detectAgentFromEnv() || "claude";
|
|
13099
13379
|
if (!FORK_AGENTS.includes(agent)) {
|
|
13100
|
-
|
|
13380
|
+
log40.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
|
|
13101
13381
|
process.exit(2);
|
|
13102
13382
|
}
|
|
13103
13383
|
const attachIn = opts.attachIn ?? "tab";
|
|
13104
13384
|
if (!FORK_ATTACH_VALUES.includes(attachIn)) {
|
|
13105
|
-
|
|
13385
|
+
log40.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
|
|
13106
13386
|
process.exit(2);
|
|
13107
13387
|
}
|
|
13108
13388
|
const plan = opts.plan?.trim();
|
|
13109
13389
|
if (plan && agent !== "claude") {
|
|
13110
|
-
|
|
13390
|
+
log40.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
|
|
13111
13391
|
process.exit(2);
|
|
13112
13392
|
}
|
|
13113
13393
|
const carryMode = opts.carry ?? "send";
|
|
13114
13394
|
if (carryMode !== "send" && carryMode !== "skip") {
|
|
13115
|
-
|
|
13395
|
+
log40.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
|
|
13116
13396
|
process.exit(2);
|
|
13117
13397
|
}
|
|
13118
13398
|
let provider;
|
|
13119
13399
|
try {
|
|
13120
13400
|
provider = resolveForkProvider(providerArg, opts.provider);
|
|
13121
13401
|
} catch (err) {
|
|
13122
|
-
|
|
13402
|
+
log40.error(err instanceof Error ? err.message : String(err));
|
|
13123
13403
|
process.exit(2);
|
|
13124
13404
|
}
|
|
13125
13405
|
if (!opts.session?.trim()) {
|
|
@@ -13143,7 +13423,7 @@ var forkCommand = new Command30("fork").description(
|
|
|
13143
13423
|
try {
|
|
13144
13424
|
sessionArgs = resolveSessionArgs(agent, opts);
|
|
13145
13425
|
} catch (err) {
|
|
13146
|
-
|
|
13426
|
+
log40.error(err instanceof Error ? err.message : String(err));
|
|
13147
13427
|
process.exit(2);
|
|
13148
13428
|
}
|
|
13149
13429
|
const subArgv = [
|
|
@@ -13165,7 +13445,7 @@ var forkCommand = new Command30("fork").description(
|
|
|
13165
13445
|
});
|
|
13166
13446
|
|
|
13167
13447
|
// src/commands/install.ts
|
|
13168
|
-
import { Command as
|
|
13448
|
+
import { Command as Command35 } from "commander";
|
|
13169
13449
|
import { execa as execa9 } from "execa";
|
|
13170
13450
|
import {
|
|
13171
13451
|
existsSync as existsSync18,
|
|
@@ -13290,8 +13570,8 @@ async function checkSsh() {
|
|
|
13290
13570
|
async function onPath(bin) {
|
|
13291
13571
|
const r = await execa8("which", [bin], { reject: false });
|
|
13292
13572
|
if (r.exitCode !== 0) return null;
|
|
13293
|
-
const
|
|
13294
|
-
return
|
|
13573
|
+
const p2 = (r.stdout ?? "").trim();
|
|
13574
|
+
return p2.length > 0 ? p2 : null;
|
|
13295
13575
|
}
|
|
13296
13576
|
async function checkSshfs() {
|
|
13297
13577
|
const path = await onPath("sshfs");
|
|
@@ -13309,11 +13589,32 @@ function checkMacfuse() {
|
|
|
13309
13589
|
};
|
|
13310
13590
|
}
|
|
13311
13591
|
async function runSystemChecks() {
|
|
13312
|
-
const [git2, ssh, sshfs] = await Promise.all([
|
|
13592
|
+
const [git2, ssh, sshfs, config] = await Promise.all([
|
|
13593
|
+
checkGit(),
|
|
13594
|
+
checkSsh(),
|
|
13595
|
+
checkSshfs(),
|
|
13596
|
+
checkConfig()
|
|
13597
|
+
]);
|
|
13313
13598
|
const results = [checkNode(), checkPlatform(), checkAgentboxHome(), git2, ssh, sshfs];
|
|
13314
13599
|
if (process.platform === "darwin") results.push(checkMacfuse());
|
|
13600
|
+
results.push(...config);
|
|
13315
13601
|
return results;
|
|
13316
13602
|
}
|
|
13603
|
+
async function checkConfig() {
|
|
13604
|
+
let loaded;
|
|
13605
|
+
try {
|
|
13606
|
+
loaded = await loadEffectiveConfig(process.cwd());
|
|
13607
|
+
} catch (err) {
|
|
13608
|
+
return [{ label: "config", status: "warn", detail: errSummary(err) }];
|
|
13609
|
+
}
|
|
13610
|
+
if (loaded.warnings.length === 0) return [];
|
|
13611
|
+
return loaded.warnings.map((detail) => ({
|
|
13612
|
+
label: "config",
|
|
13613
|
+
status: "warn",
|
|
13614
|
+
detail,
|
|
13615
|
+
hint: "fix the key, or ignore this if it was set by a newer agentbox"
|
|
13616
|
+
}));
|
|
13617
|
+
}
|
|
13317
13618
|
var INTEGRATION_PROBE_TIMEOUT_MS = 1e4;
|
|
13318
13619
|
async function probeIntegrationBin(bin, args) {
|
|
13319
13620
|
try {
|
|
@@ -13436,8 +13737,7 @@ async function baseFreshnessRow(name) {
|
|
|
13436
13737
|
async function runProviderChecks(name) {
|
|
13437
13738
|
try {
|
|
13438
13739
|
const mod = await loadProviderModule(name);
|
|
13439
|
-
const results = await mod.doctorChecks();
|
|
13440
|
-
const fresh = await baseFreshnessRow(name);
|
|
13740
|
+
const [results, fresh] = await Promise.all([mod.doctorChecks(), baseFreshnessRow(name)]);
|
|
13441
13741
|
return { title: name, results: fresh ? [...results, fresh] : results };
|
|
13442
13742
|
} catch (err) {
|
|
13443
13743
|
return {
|
|
@@ -13447,12 +13747,16 @@ async function runProviderChecks(name) {
|
|
|
13447
13747
|
}
|
|
13448
13748
|
}
|
|
13449
13749
|
async function runAllChecks() {
|
|
13450
|
-
const
|
|
13451
|
-
|
|
13452
|
-
getRuntimeProviderNames().map((n) => runProviderChecks(n))
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
return [
|
|
13750
|
+
const [sysResults, providerGroups, integrationResults] = await Promise.all([
|
|
13751
|
+
runSystemChecks(),
|
|
13752
|
+
Promise.all(getRuntimeProviderNames().map((n) => runProviderChecks(n))),
|
|
13753
|
+
integrationsChecks()
|
|
13754
|
+
]);
|
|
13755
|
+
return [
|
|
13756
|
+
{ title: "system", results: sysResults },
|
|
13757
|
+
...providerGroups,
|
|
13758
|
+
{ title: "integrations", results: integrationResults }
|
|
13759
|
+
];
|
|
13456
13760
|
}
|
|
13457
13761
|
function worstInResults(results) {
|
|
13458
13762
|
let worst = "ok";
|
|
@@ -13642,8 +13946,8 @@ async function maybePromptStar(opts) {
|
|
|
13642
13946
|
}
|
|
13643
13947
|
|
|
13644
13948
|
// src/commands/install-cmux.ts
|
|
13645
|
-
import { intro as intro9, log as
|
|
13646
|
-
import { Command as
|
|
13949
|
+
import { intro as intro9, log as log42, note as note3, outro as outro8 } from "@clack/prompts";
|
|
13950
|
+
import { Command as Command32 } from "commander";
|
|
13647
13951
|
import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
13648
13952
|
import { homedir as homedir20 } from "os";
|
|
13649
13953
|
import { dirname as dirname5, join as join26 } from "path";
|
|
@@ -13670,7 +13974,7 @@ function parseHeight(raw) {
|
|
|
13670
13974
|
if (!Number.isFinite(n) || n <= 0) return 320;
|
|
13671
13975
|
return Math.round(n);
|
|
13672
13976
|
}
|
|
13673
|
-
var installCmuxCommand = new
|
|
13977
|
+
var installCmuxCommand = new Command32("cmux").description(
|
|
13674
13978
|
"Add an AgentBox panel to the cmux sidebar dock (~/.config/cmux/dock.json) showing the live list of all your boxes."
|
|
13675
13979
|
).option("--height <points>", "panel height in points", "320").option("--title <text>", "panel title shown in the dock header", "AgentBox").option("--dry-run", "print the resulting dock.json without writing it").option("--force", "reset a dock.json that fails to parse (backed up to dock.json.bak)").action((opts) => {
|
|
13676
13980
|
const dockPath = cmuxDockPath();
|
|
@@ -13688,7 +13992,7 @@ var installCmuxCommand = new Command31("cmux").description(
|
|
|
13688
13992
|
if (parsed && typeof parsed === "object") doc = parsed;
|
|
13689
13993
|
} catch {
|
|
13690
13994
|
if (!opts.force) {
|
|
13691
|
-
|
|
13995
|
+
log42.error(
|
|
13692
13996
|
`existing dock config is not valid JSON: ${dockPath}
|
|
13693
13997
|
fix it by hand, or pass --force to back it up and write a fresh one`
|
|
13694
13998
|
);
|
|
@@ -13696,7 +14000,7 @@ fix it by hand, or pass --force to back it up and write a fresh one`
|
|
|
13696
14000
|
}
|
|
13697
14001
|
if (!opts.dryRun) {
|
|
13698
14002
|
renameSync3(dockPath, dockPath + ".bak");
|
|
13699
|
-
|
|
14003
|
+
log42.warn(`backed up unparseable dock config to ${dockPath}.bak`);
|
|
13700
14004
|
}
|
|
13701
14005
|
doc = { controls: [] };
|
|
13702
14006
|
}
|
|
@@ -13725,8 +14029,8 @@ To see it:
|
|
|
13725
14029
|
});
|
|
13726
14030
|
|
|
13727
14031
|
// src/commands/install-herdr.ts
|
|
13728
|
-
import { intro as intro10, log as
|
|
13729
|
-
import { Command as
|
|
14032
|
+
import { intro as intro10, log as log43, note as note4, outro as outro9 } from "@clack/prompts";
|
|
14033
|
+
import { Command as Command33, Option } from "commander";
|
|
13730
14034
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
13731
14035
|
import { chmodSync, existsSync as existsSync16, mkdirSync as mkdirSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync10 } from "fs";
|
|
13732
14036
|
import { homedir as homedir21 } from "os";
|
|
@@ -13857,9 +14161,9 @@ function escapeRe(s) {
|
|
|
13857
14161
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13858
14162
|
}
|
|
13859
14163
|
function writeShim(dir) {
|
|
13860
|
-
const
|
|
13861
|
-
writeFileSync10(
|
|
13862
|
-
chmodSync(
|
|
14164
|
+
const p2 = join27(dir, "agentbox-shim.sh");
|
|
14165
|
+
writeFileSync10(p2, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
|
|
14166
|
+
chmodSync(p2, 493);
|
|
13863
14167
|
}
|
|
13864
14168
|
function applyKeybindings() {
|
|
13865
14169
|
const cfg = herdrConfigPath();
|
|
@@ -13869,7 +14173,7 @@ function applyKeybindings() {
|
|
|
13869
14173
|
spawnSync4(herdrBinary(), ["server", "reload-config"], { stdio: "ignore" });
|
|
13870
14174
|
return cfg;
|
|
13871
14175
|
}
|
|
13872
|
-
var installHerdrCommand = new
|
|
14176
|
+
var installHerdrCommand = new Command33("herdr").description(
|
|
13873
14177
|
"Install a Herdr plugin: a boxes-list overlay, keyboard shortcuts, and Ctrl+click to open a box web app."
|
|
13874
14178
|
).option("--dry-run", "print the generated files without writing or linking anything").addOption(new Option("--plugin-keys", "finish setup for a herdr-installed plugin").hideHelp()).action((opts) => {
|
|
13875
14179
|
if (opts.pluginKeys) {
|
|
@@ -13920,7 +14224,7 @@ ${herdrKeybindingsBlock()}
|
|
|
13920
14224
|
if (linked.status === 0) {
|
|
13921
14225
|
spawnSync4(bin, ["server", "reload-config"], { stdio: "ignore" });
|
|
13922
14226
|
} else {
|
|
13923
|
-
|
|
14227
|
+
log43.warn(
|
|
13924
14228
|
`could not run \`${bin} plugin link\` (is Herdr installed / running?).
|
|
13925
14229
|
Run it yourself: herdr plugin link ${dir} && herdr server reload-config`
|
|
13926
14230
|
);
|
|
@@ -13936,7 +14240,7 @@ Added shortcuts to ${cfg}
|
|
|
13936
14240
|
});
|
|
13937
14241
|
|
|
13938
14242
|
// src/commands/install-codex.ts
|
|
13939
|
-
import { Command as
|
|
14243
|
+
import { Command as Command34 } from "commander";
|
|
13940
14244
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
13941
14245
|
import {
|
|
13942
14246
|
existsSync as existsSync17,
|
|
@@ -14031,7 +14335,7 @@ function codexPluginInstalled(bin) {
|
|
|
14031
14335
|
const r = spawnSync5(bin, ["plugin", "list", "--json"], { encoding: "utf8" });
|
|
14032
14336
|
if (r.status !== 0 || !r.stdout) return false;
|
|
14033
14337
|
const parsed = JSON.parse(r.stdout);
|
|
14034
|
-
return (parsed.installed ?? []).some((
|
|
14338
|
+
return (parsed.installed ?? []).some((p2) => p2.pluginId === PLUGIN_ID);
|
|
14035
14339
|
} catch {
|
|
14036
14340
|
return false;
|
|
14037
14341
|
}
|
|
@@ -14156,7 +14460,7 @@ ${codexPluginEnableTable()}
|
|
|
14156
14460
|
}
|
|
14157
14461
|
return result;
|
|
14158
14462
|
}
|
|
14159
|
-
var installCodexCommand = new
|
|
14463
|
+
var installCodexCommand = new Command34("codex").description(
|
|
14160
14464
|
"Install + enable the AgentBox Codex plugin (marketplace add, plugin add, and enable it by default in ~/.codex/config.toml)."
|
|
14161
14465
|
).option("--dry-run", "print the commands and config block without changing anything").option("--force", "re-install and re-enable even if the plugin was disabled").option("--no-dev", "use the published GitHub marketplace even inside a source checkout").action(async (opts) => {
|
|
14162
14466
|
(0, prompt_exports.intro)("AgentBox Codex plugin");
|
|
@@ -14224,8 +14528,8 @@ function paintLine(line, center) {
|
|
|
14224
14528
|
}
|
|
14225
14529
|
return out + "\x1B[0m";
|
|
14226
14530
|
}
|
|
14227
|
-
async function animateBanner() {
|
|
14228
|
-
if (process.env.NO_COLOR || process.env.CI || process.env.AGENTBOX_NO_ANIM || !process.stdout.isTTY) {
|
|
14531
|
+
async function animateBanner(animate) {
|
|
14532
|
+
if (!animate || process.env.NO_COLOR || process.env.CI || process.env.AGENTBOX_NO_ANIM || !process.stdout.isTTY) {
|
|
14229
14533
|
process.stdout.write(BANNER);
|
|
14230
14534
|
return;
|
|
14231
14535
|
}
|
|
@@ -14300,6 +14604,13 @@ function writableReason(target, force) {
|
|
|
14300
14604
|
}
|
|
14301
14605
|
return force ? "forced" : "skip";
|
|
14302
14606
|
}
|
|
14607
|
+
function sameContent(src, dest) {
|
|
14608
|
+
try {
|
|
14609
|
+
return readFileSync10(dest, "utf8") === readFileSync10(src, "utf8");
|
|
14610
|
+
} catch {
|
|
14611
|
+
return false;
|
|
14612
|
+
}
|
|
14613
|
+
}
|
|
14303
14614
|
function installHostSkills(opts = {}) {
|
|
14304
14615
|
const force = opts.force === true;
|
|
14305
14616
|
const dryRun = opts.dryRun === true;
|
|
@@ -14369,6 +14680,10 @@ async function installForkSkill(opts = {}) {
|
|
|
14369
14680
|
symlinkSync3(src, dest);
|
|
14370
14681
|
return { written: [dest], skipped: 0, blocked: [], method: "symlink" };
|
|
14371
14682
|
}
|
|
14683
|
+
if (!force && sameContent(src, dest)) {
|
|
14684
|
+
if (!quiet) prompt_exports.log.info(`host /agentbox skill already up to date (${dest})`);
|
|
14685
|
+
return { written: [], skipped: 1, blocked: [], method: "skip" };
|
|
14686
|
+
}
|
|
14372
14687
|
try {
|
|
14373
14688
|
await execa9(
|
|
14374
14689
|
"npx",
|
|
@@ -14420,8 +14735,33 @@ async function runProviderLogin(name) {
|
|
|
14420
14735
|
await mod.ensureCredentials();
|
|
14421
14736
|
return true;
|
|
14422
14737
|
}
|
|
14423
|
-
function
|
|
14424
|
-
const
|
|
14738
|
+
async function maybeSetDefaultProvider(name, autoYes) {
|
|
14739
|
+
const cfg = await loadEffectiveConfig(process.cwd());
|
|
14740
|
+
if (cfg.effective.box.provider === name) return true;
|
|
14741
|
+
const label = providerMeta(name).label;
|
|
14742
|
+
const wantDefault = autoYes ? true : await confirm({
|
|
14743
|
+
message: `Make ${label} the default for new boxes? (plain \`agentbox claude\` will use it)`,
|
|
14744
|
+
initialValue: true
|
|
14745
|
+
});
|
|
14746
|
+
if (!wantDefault) {
|
|
14747
|
+
prompt_exports.log.info(
|
|
14748
|
+
`left the default as ${cfg.effective.box.provider} \u2014 start a ${name} box with \`agentbox ${name} claude\`, or set it later with \`agentbox config set box.provider ${name} --global\``
|
|
14749
|
+
);
|
|
14750
|
+
return false;
|
|
14751
|
+
}
|
|
14752
|
+
try {
|
|
14753
|
+
const r = await setConfigValue("global", "box.provider", name, process.cwd(), { raw: true });
|
|
14754
|
+
prompt_exports.log.info(`box.provider = ${name} (wrote ${r.path})`);
|
|
14755
|
+
return true;
|
|
14756
|
+
} catch (err) {
|
|
14757
|
+
prompt_exports.log.warn(
|
|
14758
|
+
`could not write box.provider: ${err instanceof Error ? err.message : String(err)} \u2014 set it with \`agentbox config set box.provider ${name} --global\``
|
|
14759
|
+
);
|
|
14760
|
+
return false;
|
|
14761
|
+
}
|
|
14762
|
+
}
|
|
14763
|
+
function tutorialBody(provider, isDefault) {
|
|
14764
|
+
const startCmd = isDefault ? "agentbox claude " : `agentbox ${provider} claude`;
|
|
14425
14765
|
return `Get started:
|
|
14426
14766
|
${startCmd} # for claude, codex, opencode
|
|
14427
14767
|
-> Setup wizard? -> Yes # install dependencies and setup agentbox.yaml
|
|
@@ -14435,9 +14775,10 @@ function isProviderName(s) {
|
|
|
14435
14775
|
}
|
|
14436
14776
|
async function runInstallWizard(opts = {}) {
|
|
14437
14777
|
if (!ensureTty()) return false;
|
|
14438
|
-
|
|
14778
|
+
const sysPromise = runSystemChecks();
|
|
14779
|
+
await animateBanner(isFirstRun());
|
|
14439
14780
|
(0, prompt_exports.intro)("Check system compatibility");
|
|
14440
|
-
const sysResults = await
|
|
14781
|
+
const sysResults = await sysPromise;
|
|
14441
14782
|
const sysGroup = { title: "system", results: sysResults };
|
|
14442
14783
|
process.stdout.write(" " + formatCompact([sysGroup]) + "\n");
|
|
14443
14784
|
const hardFail = sysResults.find((r) => r.status === "fail");
|
|
@@ -14462,10 +14803,10 @@ async function runInstallWizard(opts = {}) {
|
|
|
14462
14803
|
const picked = await select({
|
|
14463
14804
|
message: "Which provider do you want to set up?",
|
|
14464
14805
|
initialValue: "docker",
|
|
14465
|
-
options: KNOWN_PROVIDERS.map((
|
|
14466
|
-
value:
|
|
14467
|
-
label: providerMeta(
|
|
14468
|
-
hint: providerMeta(
|
|
14806
|
+
options: KNOWN_PROVIDERS.map((p2) => ({
|
|
14807
|
+
value: p2,
|
|
14808
|
+
label: providerMeta(p2).label,
|
|
14809
|
+
hint: providerMeta(p2).loginHint
|
|
14469
14810
|
}))
|
|
14470
14811
|
});
|
|
14471
14812
|
providerName = picked;
|
|
@@ -14496,6 +14837,7 @@ async function runInstallWizard(opts = {}) {
|
|
|
14496
14837
|
`skipped \u2014 the ${providerName} base will build lazily on first \`agentbox ${providerName === "docker" ? "" : providerName + " "}create\``
|
|
14497
14838
|
);
|
|
14498
14839
|
}
|
|
14840
|
+
const isDefaultProvider = await maybeSetDefaultProvider(providerName, opts.yes ?? false);
|
|
14499
14841
|
const sp = (0, prompt_exports.spinner)();
|
|
14500
14842
|
sp.start("installing host /agentbox skill\u2026");
|
|
14501
14843
|
try {
|
|
@@ -14567,22 +14909,22 @@ pass \`agentbox install --skills-only --force\` to overwrite`
|
|
|
14567
14909
|
}
|
|
14568
14910
|
}
|
|
14569
14911
|
}
|
|
14570
|
-
(0, prompt_exports.note)(tutorialBody(providerName), "Next steps");
|
|
14912
|
+
(0, prompt_exports.note)(tutorialBody(providerName, isDefaultProvider), "Next steps");
|
|
14571
14913
|
(0, prompt_exports.outro)(
|
|
14572
14914
|
opts.fromAutoTrigger ? "\u2728 Setup complete \u2014 continuing with your command\u2026" : "\u2728 Setup complete"
|
|
14573
14915
|
);
|
|
14574
14916
|
await maybePromptStar({ trigger: "install" });
|
|
14575
14917
|
return true;
|
|
14576
14918
|
}
|
|
14577
|
-
var installCommand = new
|
|
14919
|
+
var installCommand = new Command35("install").description(
|
|
14578
14920
|
"Interactive setup wizard: system check, pick a provider, log in, prepare its base image/snapshot, and install the host /agentbox skill. `--skills-only` runs just the skill install."
|
|
14579
14921
|
).option(
|
|
14580
14922
|
"--skills-only",
|
|
14581
14923
|
"only install the host /agentbox skill files (no wizard, no login, no prepare)"
|
|
14582
14924
|
).option("--force", "overwrite existing skill files even if not AgentBox-managed").option("--dry-run", "print what would be written without changing anything").option(
|
|
14583
14925
|
"-p, --provider <name>",
|
|
14584
|
-
|
|
14585
|
-
).option("-y, --yes", "auto-confirm the prepare step").action(async (opts, cmd) => {
|
|
14926
|
+
`pre-select the provider to set up (${PROVIDER_NAMES.join(" | ")})`
|
|
14927
|
+
).option("-y, --yes", "auto-confirm the prepare step and the default-provider prompt").action(async (opts, cmd) => {
|
|
14586
14928
|
const stray = cmd.args[0];
|
|
14587
14929
|
if (stray !== void 0) {
|
|
14588
14930
|
const targets = cmd.commands.map((c) => c.name()).join(", ");
|
|
@@ -14638,7 +14980,7 @@ import { existsSync as existsSync19, readFileSync as readFileSync11, statSync as
|
|
|
14638
14980
|
import { createRequire } from "module";
|
|
14639
14981
|
import { dirname as dirname9, isAbsolute as isAbsolute3, resolve as resolve6 } from "path";
|
|
14640
14982
|
import { pathToFileURL } from "url";
|
|
14641
|
-
import { Command as
|
|
14983
|
+
import { Command as Command36 } from "commander";
|
|
14642
14984
|
function resolutionPaths() {
|
|
14643
14985
|
const paths = /* @__PURE__ */ new Set();
|
|
14644
14986
|
paths.add(process.cwd());
|
|
@@ -14647,7 +14989,7 @@ function resolutionPaths() {
|
|
|
14647
14989
|
if (g) paths.add(g);
|
|
14648
14990
|
} catch {
|
|
14649
14991
|
}
|
|
14650
|
-
for (const
|
|
14992
|
+
for (const p2 of (process.env.NODE_PATH ?? "").split(":")) if (p2) paths.add(p2);
|
|
14651
14993
|
return [...paths];
|
|
14652
14994
|
}
|
|
14653
14995
|
function resolvePackage(arg) {
|
|
@@ -14724,7 +15066,7 @@ async function loadAndValidate(pkg) {
|
|
|
14724
15066
|
}
|
|
14725
15067
|
return { providers, apiVersion };
|
|
14726
15068
|
}
|
|
14727
|
-
var pluginCommand = new
|
|
15069
|
+
var pluginCommand = new Command36("plugin").description(
|
|
14728
15070
|
"Manage externally-installed provider packages (community providers)"
|
|
14729
15071
|
);
|
|
14730
15072
|
pluginCommand.command("add").argument("<package>", "installed package name or a path to its directory").option("-y, --yes", "skip the trust confirmation prompt").description("register an installed provider package so `--provider <name>` can use it").action(async (packageArg, opts) => {
|
|
@@ -14739,19 +15081,19 @@ pluginCommand.command("add").argument("<package>", "installed package name or a
|
|
|
14739
15081
|
return;
|
|
14740
15082
|
}
|
|
14741
15083
|
const existing = readPluginRegistrySync().plugins;
|
|
14742
|
-
for (const
|
|
15084
|
+
for (const p2 of validated.providers) {
|
|
14743
15085
|
const clash = existing.find(
|
|
14744
|
-
(r) => r.packageName !== pkg.packageName && r.providers.includes(
|
|
15086
|
+
(r) => r.packageName !== pkg.packageName && r.providers.includes(p2.name)
|
|
14745
15087
|
);
|
|
14746
15088
|
if (clash) {
|
|
14747
15089
|
prompt_exports.log.error(
|
|
14748
|
-
`provider "${
|
|
15090
|
+
`provider "${p2.name}" is already provided by "${clash.packageName}" \u2014 remove it first (\`agentbox plugin remove ${p2.name}\`)`
|
|
14749
15091
|
);
|
|
14750
15092
|
process.exitCode = 1;
|
|
14751
15093
|
return;
|
|
14752
15094
|
}
|
|
14753
15095
|
}
|
|
14754
|
-
const provNames = validated.providers.map((
|
|
15096
|
+
const provNames = validated.providers.map((p2) => p2.name).join(", ");
|
|
14755
15097
|
prompt_exports.log.info(
|
|
14756
15098
|
`${pkg.packageName}@${pkg.version} \u2014 provider(s): ${provNames} (SDK v${String(validated.apiVersion)})`
|
|
14757
15099
|
);
|
|
@@ -14769,7 +15111,7 @@ pluginCommand.command("add").argument("<package>", "installed package name or a
|
|
|
14769
15111
|
packageName: pkg.packageName,
|
|
14770
15112
|
resolvedEntry: pkg.entryPath,
|
|
14771
15113
|
version: pkg.version,
|
|
14772
|
-
providers: validated.providers.map((
|
|
15114
|
+
providers: validated.providers.map((p2) => p2.name),
|
|
14773
15115
|
apiVersion: validated.apiVersion,
|
|
14774
15116
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
14775
15117
|
});
|
|
@@ -14781,16 +15123,16 @@ pluginCommand.command("list").description("list registered provider plugins").ac
|
|
|
14781
15123
|
process.stdout.write("no provider plugins registered\n");
|
|
14782
15124
|
return;
|
|
14783
15125
|
}
|
|
14784
|
-
for (const
|
|
15126
|
+
for (const p2 of plugins) {
|
|
14785
15127
|
process.stdout.write(
|
|
14786
|
-
`${
|
|
15128
|
+
`${p2.providers.join(", ").padEnd(20)} ${p2.packageName}@${p2.version} (SDK v${String(p2.apiVersion)})
|
|
14787
15129
|
`
|
|
14788
15130
|
);
|
|
14789
15131
|
}
|
|
14790
15132
|
});
|
|
14791
15133
|
pluginCommand.command("info").argument("<name>", "provider name or package name").description("show a registered plugin").action((name) => {
|
|
14792
15134
|
const { plugins } = readPluginRegistrySync();
|
|
14793
|
-
const hit = plugins.find((
|
|
15135
|
+
const hit = plugins.find((p2) => p2.packageName === name || p2.providers.includes(name));
|
|
14794
15136
|
if (!hit) {
|
|
14795
15137
|
process.stderr.write(`no registered plugin matches "${name}"
|
|
14796
15138
|
`);
|
|
@@ -14811,8 +15153,8 @@ pluginCommand.command("remove").alias("rm").argument("<name>", "provider name or
|
|
|
14811
15153
|
});
|
|
14812
15154
|
|
|
14813
15155
|
// src/commands/doctor.ts
|
|
14814
|
-
import { Command as
|
|
14815
|
-
var doctorCommand = new
|
|
15156
|
+
import { Command as Command37 } from "commander";
|
|
15157
|
+
var doctorCommand = new Command37("doctor").description(
|
|
14816
15158
|
"Diagnose system compatibility and provider readiness (Node, git, ssh, Docker daemon, provider credentials, prepared snapshots)."
|
|
14817
15159
|
).option(
|
|
14818
15160
|
"-p, --provider <name>",
|
|
@@ -14878,7 +15220,7 @@ function formatUnknown(err) {
|
|
|
14878
15220
|
}
|
|
14879
15221
|
|
|
14880
15222
|
// src/commands/git.ts
|
|
14881
|
-
import { Command as
|
|
15223
|
+
import { Command as Command38 } from "commander";
|
|
14882
15224
|
var WORKSPACE = "/workspace";
|
|
14883
15225
|
var TOKEN_TTL_MS = 12e4;
|
|
14884
15226
|
async function runInBox(box, argv2) {
|
|
@@ -14961,7 +15303,7 @@ function buildPredictedGhPrParams(ghArgs) {
|
|
|
14961
15303
|
async function exitWith(code) {
|
|
14962
15304
|
process.exit(code);
|
|
14963
15305
|
}
|
|
14964
|
-
var pushCommand = new
|
|
15306
|
+
var pushCommand = new Command38("push").description("Push the box's branch via the host relay (host creds, no prompt)").argument("<box>", "box ref: project index, id, id prefix, name, or container").argument("[args...]", "extra flags forwarded to `agentbox-ctl git push` (e.g. --force-with-lease, --tags)").option("--remote <name>", "remote name (default: origin)").option("--host-only", "land the branch in the host's local repo only; do NOT push to the remote (nothing is published online)").option("--as <branch>", "with --host-only: destination branch name in the host repo (default: the box's branch name)").option("--force", "with --host-only: allow a non-fast-forward overwrite of the destination branch").allowExcessArguments(true).allowUnknownOption(true).action(
|
|
14965
15307
|
async (boxRef, args, opts) => {
|
|
14966
15308
|
try {
|
|
14967
15309
|
if (opts.hostOnly && opts.remote) {
|
|
@@ -14982,7 +15324,7 @@ var pushCommand = new Command37("push").description("Push the box's branch via t
|
|
|
14982
15324
|
}
|
|
14983
15325
|
}
|
|
14984
15326
|
);
|
|
14985
|
-
var fetchCommand = new
|
|
15327
|
+
var fetchCommand = new Command38("fetch").description("Fetch via the host relay (refs land in the shared .git)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `agentbox-ctl git fetch` (e.g. --prune)").option("--remote <name>", "remote name (default: origin)").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args, opts) => {
|
|
14986
15328
|
try {
|
|
14987
15329
|
const box = await resolveBoxOrExit(boxRef);
|
|
14988
15330
|
const predicted = buildPredictedGitParams(opts.remote, args);
|
|
@@ -14995,7 +15337,7 @@ var fetchCommand = new Command37("fetch").description("Fetch via the host relay
|
|
|
14995
15337
|
handleLifecycleError(err);
|
|
14996
15338
|
}
|
|
14997
15339
|
});
|
|
14998
|
-
var pullCommand = new
|
|
15340
|
+
var pullCommand = new Command38("pull").description(
|
|
14999
15341
|
"Fetch via the relay then merge in /workspace. With <branch>: first `git checkout <branch>` so the box switches base branch and pulls latest \u2014 useful for reusing a box on a new task."
|
|
15000
15342
|
).argument("<box>", "box ref").argument("[branch]", "optional branch to switch to before pulling (e.g. main)").argument("[args...]", "extra flags forwarded to `agentbox-ctl git pull`").option("--remote <name>", "remote name (default: origin)").option("--ff-only", "pass --ff-only to the in-box merge").allowExcessArguments(true).allowUnknownOption(true).action(
|
|
15001
15343
|
async (boxRef, branch, args, opts) => {
|
|
@@ -15017,7 +15359,7 @@ var pullCommand = new Command37("pull").description(
|
|
|
15017
15359
|
}
|
|
15018
15360
|
}
|
|
15019
15361
|
);
|
|
15020
|
-
var checkoutCommand = new
|
|
15362
|
+
var checkoutCommand = new Command38("checkout").description("Change the box's working branch (runs `git checkout <branch>` in /workspace)").argument("<box>", "box ref").argument("<branch>", "branch to check out inside the box").argument("[args...]", "extra flags forwarded to `git checkout`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, branch, args) => {
|
|
15021
15363
|
try {
|
|
15022
15364
|
const box = await resolveBoxOrExit(boxRef);
|
|
15023
15365
|
const provider = await providerForBox(box);
|
|
@@ -15028,7 +15370,7 @@ var checkoutCommand = new Command37("checkout").description("Change the box's wo
|
|
|
15028
15370
|
handleLifecycleError(err);
|
|
15029
15371
|
}
|
|
15030
15372
|
});
|
|
15031
|
-
var branchCommand = new
|
|
15373
|
+
var branchCommand = new Command38("branch").description("Create a new agentbox/* branch from HEAD (or a given base) and switch the box onto it").argument("<box>", "box ref").argument("<name>", "new branch name (an 'agentbox/' prefix is added when missing)").option("--from <ref>", "base ref to fork from (default: the box's current HEAD)").action(async (boxRef, name, opts) => {
|
|
15032
15374
|
try {
|
|
15033
15375
|
const box = await resolveBoxOrExit(boxRef);
|
|
15034
15376
|
const provider = await providerForBox(box);
|
|
@@ -15039,7 +15381,7 @@ var branchCommand = new Command37("branch").description("Create a new agentbox/*
|
|
|
15039
15381
|
handleLifecycleError(err);
|
|
15040
15382
|
}
|
|
15041
15383
|
});
|
|
15042
|
-
var statusCommand = new
|
|
15384
|
+
var statusCommand = new Command38("status").description("Run `git status` in the box's /workspace (read-only, no relay)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `git status`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args) => {
|
|
15043
15385
|
try {
|
|
15044
15386
|
const box = await resolveBoxOrExit(boxRef);
|
|
15045
15387
|
await exitWith(await runAndStream(box, ["git", "status", ...args]));
|
|
@@ -15065,7 +15407,7 @@ function injectPrCreateHead2(op, box, args) {
|
|
|
15065
15407
|
return injectPrCreateHead(op, rootWt?.branch, args);
|
|
15066
15408
|
}
|
|
15067
15409
|
function buildPrSubcommand(op) {
|
|
15068
|
-
return new
|
|
15410
|
+
return new Command38(op).description(PR_OP_DESCRIPTIONS[op]).argument("<box>", "box ref").argument(
|
|
15069
15411
|
"[args...]",
|
|
15070
15412
|
"extra flags forwarded to `gh pr <op>` (e.g. --title, --body, --label, --draft, --json)"
|
|
15071
15413
|
).allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args) => {
|
|
@@ -15081,18 +15423,18 @@ function buildPrSubcommand(op) {
|
|
|
15081
15423
|
}
|
|
15082
15424
|
});
|
|
15083
15425
|
}
|
|
15084
|
-
var prCommand = new
|
|
15426
|
+
var prCommand = new Command38("pr").description(
|
|
15085
15427
|
"PR operations against a box's branch via the host `gh` CLI"
|
|
15086
15428
|
);
|
|
15087
15429
|
for (const op of GH_PR_OPS) {
|
|
15088
15430
|
const sub = buildPrSubcommand(op);
|
|
15089
15431
|
prCommand.addCommand(sub, op === "create" ? { isDefault: true } : void 0);
|
|
15090
15432
|
}
|
|
15091
|
-
var gitCommand = new
|
|
15433
|
+
var gitCommand = new Command38("git").description("Run git / gh pr operations against a box from the host").addCommand(pushCommand).addCommand(fetchCommand).addCommand(pullCommand).addCommand(checkoutCommand).addCommand(branchCommand).addCommand(statusCommand).addCommand(prCommand);
|
|
15092
15434
|
|
|
15093
15435
|
// src/commands/list.ts
|
|
15094
|
-
import { log as
|
|
15095
|
-
import { Command as
|
|
15436
|
+
import { log as log47 } from "@clack/prompts";
|
|
15437
|
+
import { Command as Command39 } from "commander";
|
|
15096
15438
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
15097
15439
|
|
|
15098
15440
|
// src/box-label.ts
|
|
@@ -15126,11 +15468,11 @@ async function applyLiveCloudStates(boxes) {
|
|
|
15126
15468
|
})
|
|
15127
15469
|
);
|
|
15128
15470
|
}
|
|
15129
|
-
function withTimeout(
|
|
15471
|
+
function withTimeout(p2, ms) {
|
|
15130
15472
|
return new Promise((resolve7) => {
|
|
15131
15473
|
const t = setTimeout(() => resolve7(null), ms);
|
|
15132
15474
|
if (typeof t.unref === "function") t.unref();
|
|
15133
|
-
|
|
15475
|
+
p2.then(
|
|
15134
15476
|
(v) => {
|
|
15135
15477
|
clearTimeout(t);
|
|
15136
15478
|
resolve7(v);
|
|
@@ -15263,8 +15605,8 @@ function urlCell(box, stream) {
|
|
|
15263
15605
|
}
|
|
15264
15606
|
const sep2 = " ";
|
|
15265
15607
|
return {
|
|
15266
|
-
text: parts.map((
|
|
15267
|
-
width: parts.reduce((a,
|
|
15608
|
+
text: parts.map((p2) => p2.text).join(sep2),
|
|
15609
|
+
width: parts.reduce((a, p2) => a + p2.width, 0) + sep2.length * (parts.length - 1)
|
|
15268
15610
|
};
|
|
15269
15611
|
}
|
|
15270
15612
|
function workspaceCell(path, target, stream) {
|
|
@@ -15456,7 +15798,7 @@ async function buildListText(all, live) {
|
|
|
15456
15798
|
${table}`;
|
|
15457
15799
|
}
|
|
15458
15800
|
var listCommand2 = withWatchOptions(
|
|
15459
|
-
new
|
|
15801
|
+
new Command39("list").alias("ls").description("List agent boxes in the current project (-g for all)").option("-j, --json", "machine-readable JSON output").option("-g, --global", "include boxes from all projects").option(
|
|
15460
15802
|
"--live",
|
|
15461
15803
|
"probe live cloud state via the provider SDK (slower; default: last host-known state)"
|
|
15462
15804
|
).option("--cmux", "compact output for the cmux dock sidebar (narrow, 2 lines per box)").option(
|
|
@@ -15465,7 +15807,7 @@ var listCommand2 = withWatchOptions(
|
|
|
15465
15807
|
)
|
|
15466
15808
|
).action(async (opts) => {
|
|
15467
15809
|
if (opts.json && opts.watch) {
|
|
15468
|
-
|
|
15810
|
+
log47.error("cannot combine --json with --watch");
|
|
15469
15811
|
process.exit(2);
|
|
15470
15812
|
}
|
|
15471
15813
|
const all = opts.global ?? false;
|
|
@@ -15510,11 +15852,11 @@ var listCommand2 = withWatchOptions(
|
|
|
15510
15852
|
});
|
|
15511
15853
|
|
|
15512
15854
|
// src/commands/logs.ts
|
|
15513
|
-
import { log as
|
|
15514
|
-
import { Command as
|
|
15855
|
+
import { log as log48 } from "@clack/prompts";
|
|
15856
|
+
import { Command as Command40 } from "commander";
|
|
15515
15857
|
import { spawn as spawn6 } from "child_process";
|
|
15516
15858
|
var DAEMON_LOG_PATH = "/var/log/agentbox/ctl-daemon.log";
|
|
15517
|
-
var logsCommand = new
|
|
15859
|
+
var logsCommand = new Command40("logs").description("Print recent log lines from a box service; -f to stream").argument(
|
|
15518
15860
|
"[box]",
|
|
15519
15861
|
"box ref (optional when cwd has exactly 1 box): project index, id, id prefix, name, or container"
|
|
15520
15862
|
).argument("[service]", "service name from agentbox.yaml").option("-n, --tail <n>", "how many recent lines to print first", "200").option("-f, --follow", "keep the connection open and stream new lines").option(
|
|
@@ -15532,9 +15874,9 @@ var logsCommand = new Command39("logs").description("Print recent log lines from
|
|
|
15532
15874
|
service = boxArg;
|
|
15533
15875
|
}
|
|
15534
15876
|
if (!service && !opts.daemon) {
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15877
|
+
log48.error("missing <service> argument");
|
|
15878
|
+
log48.info("usage: agentbox logs [box] <service> [-n N] [-f]");
|
|
15879
|
+
log48.info(" agentbox logs [box] --daemon [-n N] [-f]");
|
|
15538
15880
|
process.exit(2);
|
|
15539
15881
|
}
|
|
15540
15882
|
const box = await resolveBoxOrExit(idOrName);
|
|
@@ -15545,7 +15887,7 @@ var logsCommand = new Command39("logs").description("Print recent log lines from
|
|
|
15545
15887
|
if (!opts.follow) {
|
|
15546
15888
|
const proc = await provider.exec(box, args, { user: "vscode" });
|
|
15547
15889
|
if (proc.exitCode !== 0) {
|
|
15548
|
-
|
|
15890
|
+
log48.error(
|
|
15549
15891
|
`${opts.daemon ? "daemon log" : "agentbox-ctl logs"} failed: ${proc.stderr || proc.stdout}`
|
|
15550
15892
|
);
|
|
15551
15893
|
process.exit(1);
|
|
@@ -15601,12 +15943,12 @@ var logsCommand = new Command39("logs").description("Print recent log lines from
|
|
|
15601
15943
|
});
|
|
15602
15944
|
|
|
15603
15945
|
// src/commands/open.ts
|
|
15604
|
-
import { log as
|
|
15946
|
+
import { log as log49 } from "@clack/prompts";
|
|
15605
15947
|
import { execa as execa10 } from "execa";
|
|
15606
15948
|
import { existsSync as existsSync20, mkdirSync as mkdirSync13 } from "fs";
|
|
15607
15949
|
import { homedir as homedir24 } from "os";
|
|
15608
15950
|
import { join as join30 } from "path";
|
|
15609
|
-
import { Command as
|
|
15951
|
+
import { Command as Command41, InvalidArgumentError as InvalidArgumentError3 } from "commander";
|
|
15610
15952
|
|
|
15611
15953
|
// src/commands/path.ts
|
|
15612
15954
|
async function runPath(box, opts) {
|
|
@@ -15636,7 +15978,7 @@ function parseOpenTarget(value) {
|
|
|
15636
15978
|
`expected one of: claude, codex, herdr, cmux, vscode, iterm2, finder (got "${value}")`
|
|
15637
15979
|
);
|
|
15638
15980
|
}
|
|
15639
|
-
var openCommand = new
|
|
15981
|
+
var openCommand = new Command41("open").description(
|
|
15640
15982
|
"Mount a box /workspace via sshfs and reveal in Finder (default), or open it in a host app via --in"
|
|
15641
15983
|
).argument(
|
|
15642
15984
|
"[box]",
|
|
@@ -15754,11 +16096,11 @@ async function ensurePersistentSshAlias(box, appLabel) {
|
|
|
15754
16096
|
}
|
|
15755
16097
|
async function openInCodex(box) {
|
|
15756
16098
|
const alias = await ensurePersistentSshAlias(box, "Codex");
|
|
15757
|
-
|
|
16099
|
+
log49.info(`ssh alias '${alias}' written (Include'd from ~/.ssh/config)`);
|
|
15758
16100
|
const url = codexAddUrl(alias);
|
|
15759
16101
|
const opened = await execa10(hostOpenCommand(), [url], { reject: false });
|
|
15760
16102
|
if (opened.exitCode !== 0) {
|
|
15761
|
-
|
|
16103
|
+
log49.warn(
|
|
15762
16104
|
`could not auto-open the Codex link (is Codex.app installed?): ${opened.stderr || `exit ${String(opened.exitCode)}`}`
|
|
15763
16105
|
);
|
|
15764
16106
|
const link = hyperlink(`Add ${alias} to Codex SSH`, url, process.stdout);
|
|
@@ -15768,18 +16110,18 @@ ${url}
|
|
|
15768
16110
|
process.exitCode = 1;
|
|
15769
16111
|
return;
|
|
15770
16112
|
}
|
|
15771
|
-
|
|
16113
|
+
log49.success(`opening Codex \u2014 the SSH connection form is pre-filled with '${alias}'`);
|
|
15772
16114
|
process.stdout.write(url + "\n");
|
|
15773
16115
|
}
|
|
15774
16116
|
async function openInClaude(box) {
|
|
15775
16117
|
const alias = await ensurePersistentSshAlias(box, "Claude");
|
|
15776
|
-
|
|
16118
|
+
log49.info(`ssh alias '${alias}' written (Include'd from ~/.ssh/config)`);
|
|
15777
16119
|
const entry = claudeSshEntryFor(alias, box.name);
|
|
15778
16120
|
upsertClaudeSshConfig(entry);
|
|
15779
|
-
|
|
16121
|
+
log49.info(`added '${entry.name}' to Claude desktop's SSH connections (${claudeSettingsPath()})`);
|
|
15780
16122
|
const opened = await execa10(hostOpenCommand(), ["-a", "Claude"], { reject: false });
|
|
15781
16123
|
if (opened.exitCode !== 0) {
|
|
15782
|
-
|
|
16124
|
+
log49.warn(
|
|
15783
16125
|
`could not launch Claude (is Claude.app installed?): ${opened.stderr || `exit ${String(opened.exitCode)}`}`
|
|
15784
16126
|
);
|
|
15785
16127
|
process.stdout.write(
|
|
@@ -15789,29 +16131,29 @@ async function openInClaude(box) {
|
|
|
15789
16131
|
process.exitCode = 1;
|
|
15790
16132
|
return;
|
|
15791
16133
|
}
|
|
15792
|
-
|
|
16134
|
+
log49.success(`opening Claude \u2014 pick '${entry.name}' from the Environment dropdown`);
|
|
15793
16135
|
}
|
|
15794
16136
|
async function openInTerminalApp(box, host) {
|
|
15795
16137
|
if ((box.provider ?? "docker") === "docker") {
|
|
15796
16138
|
const insp = await inspectBox(box.id);
|
|
15797
16139
|
if (insp.state === "paused") {
|
|
15798
|
-
|
|
16140
|
+
log49.info("box is paused; unpausing");
|
|
15799
16141
|
await unpauseBox(box.id);
|
|
15800
16142
|
} else if (insp.state === "stopped") {
|
|
15801
|
-
|
|
16143
|
+
log49.info("box is stopped; starting");
|
|
15802
16144
|
await startBox(box.id);
|
|
15803
16145
|
} else if (insp.state === "missing") {
|
|
15804
16146
|
throw new Error(`box ${box.name} has no container; was it destroyed?`);
|
|
15805
16147
|
}
|
|
15806
16148
|
} else {
|
|
15807
|
-
const
|
|
15808
|
-
const state = await
|
|
16149
|
+
const p2 = await providerForBox(box);
|
|
16150
|
+
const state = await p2.probeState(box);
|
|
15809
16151
|
if (state === "paused") {
|
|
15810
|
-
|
|
15811
|
-
await
|
|
16152
|
+
log49.info("box is paused; resuming");
|
|
16153
|
+
await p2.resume(box);
|
|
15812
16154
|
} else if (state === "stopped") {
|
|
15813
|
-
|
|
15814
|
-
await
|
|
16155
|
+
log49.info("box is stopped; starting");
|
|
16156
|
+
await p2.start(box);
|
|
15815
16157
|
} else if (state === "missing") {
|
|
15816
16158
|
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
15817
16159
|
}
|
|
@@ -15857,15 +16199,15 @@ ${r.error ?? ""}`
|
|
|
15857
16199
|
const hint = host === "herdr" ? " Is Herdr running? (`herdr status server`)" : host === "cmux" ? " Is cmux running?" : " Is iTerm2 installed?";
|
|
15858
16200
|
throw new Error(`could not open in ${host}: ${r.error ?? "unknown error"}.${hint}`);
|
|
15859
16201
|
}
|
|
15860
|
-
|
|
16202
|
+
log49.success(`opened ${box.name} in a new ${host} ${host === "iterm2" ? "window" : "workspace"} (agentbox attach)`);
|
|
15861
16203
|
}
|
|
15862
16204
|
async function bringDockerBoxOnline(box) {
|
|
15863
16205
|
const insp = await inspectBox(box.id);
|
|
15864
16206
|
if (insp.state === "paused") {
|
|
15865
|
-
|
|
16207
|
+
log49.info("box is paused; unpausing");
|
|
15866
16208
|
await unpauseBox(box.id);
|
|
15867
16209
|
} else if (insp.state === "stopped") {
|
|
15868
|
-
|
|
16210
|
+
log49.info("box is stopped; starting");
|
|
15869
16211
|
const started = await startBox(box.id);
|
|
15870
16212
|
return started.record;
|
|
15871
16213
|
} else if (insp.state === "missing") {
|
|
@@ -15904,10 +16246,10 @@ async function runSshfsMount(box, opts) {
|
|
|
15904
16246
|
if (!existsSync20(mountRoot)) {
|
|
15905
16247
|
mkdirSync13(mountRoot, { recursive: true, mode: 493 });
|
|
15906
16248
|
} else if (await isMounted(mountRoot)) {
|
|
15907
|
-
|
|
16249
|
+
log49.info(`re-mounting (stale mount detected at ${mountRoot})`);
|
|
15908
16250
|
await tryUnmount(mountRoot);
|
|
15909
16251
|
}
|
|
15910
|
-
|
|
16252
|
+
log49.info(`mounting ${alias}:/workspace at ${mountRoot}`);
|
|
15911
16253
|
const mount = await execa10(
|
|
15912
16254
|
sshfsBin,
|
|
15913
16255
|
[
|
|
@@ -15956,8 +16298,8 @@ async function tryUnmount(path) {
|
|
|
15956
16298
|
}
|
|
15957
16299
|
|
|
15958
16300
|
// src/commands/pause.ts
|
|
15959
|
-
import { Command as
|
|
15960
|
-
var pauseCommand = new
|
|
16301
|
+
import { Command as Command42 } from "commander";
|
|
16302
|
+
var pauseCommand = new Command42("pause").description(
|
|
15961
16303
|
"Pause a box. Docker: `docker pause` (cgroup freeze \u2014 sub-second resume). Cloud: backend.pause (Daytona archive \u2014 cold storage; resume is slower but uses no quota while archived)."
|
|
15962
16304
|
).argument(
|
|
15963
16305
|
"[box]",
|
|
@@ -15984,9 +16326,9 @@ var pauseCommand = new Command41("pause").description(
|
|
|
15984
16326
|
});
|
|
15985
16327
|
|
|
15986
16328
|
// src/commands/inbound.ts
|
|
15987
|
-
import { confirm as confirm3, isCancel as isCancel5, log as
|
|
15988
|
-
import { Command as
|
|
15989
|
-
var inboundCommand = new
|
|
16329
|
+
import { confirm as confirm3, isCancel as isCancel5, log as log50 } from "@clack/prompts";
|
|
16330
|
+
import { Command as Command43 } from "commander";
|
|
16331
|
+
var inboundCommand = new Command43("inbound").description(
|
|
15990
16332
|
"Set a VPS box's inbound-access policy (hetzner / digitalocean per-box firewall). `open` = SSH reachable from anywhere (0.0.0.0/0, key-only \u2014 reach the box from a phone with the laptop off); `lock` = host egress IP only; a CIDR list = host egress plus those. `--show` prints the current policy."
|
|
15991
16333
|
).argument(
|
|
15992
16334
|
"[box]",
|
|
@@ -16011,7 +16353,7 @@ var inboundCommand = new Command42("inbound").description(
|
|
|
16011
16353
|
return;
|
|
16012
16354
|
}
|
|
16013
16355
|
if (!provider.setInbound) {
|
|
16014
|
-
|
|
16356
|
+
log50.error(
|
|
16015
16357
|
`inbound access control isn't supported for provider '${box.provider ?? "docker"}' \u2014 only hetzner / digitalocean boxes have a per-box firewall.`
|
|
16016
16358
|
);
|
|
16017
16359
|
process.exit(2);
|
|
@@ -16019,16 +16361,16 @@ var inboundCommand = new Command42("inbound").description(
|
|
|
16019
16361
|
const raw = spec.join(" ");
|
|
16020
16362
|
const policy = parseInboundSpec(raw);
|
|
16021
16363
|
if (policy.mode === "open" && !opts.yes) {
|
|
16022
|
-
|
|
16364
|
+
log50.warn(
|
|
16023
16365
|
`This opens SSH (port 22) on box '${box.name}' to the entire internet (0.0.0.0/0). Access stays key-only (password auth is disabled), but the port becomes publicly reachable.`
|
|
16024
16366
|
);
|
|
16025
16367
|
const ok = await confirm3({ message: "Open the firewall to the world?", initialValue: false });
|
|
16026
16368
|
if (isCancel5(ok) || !ok) {
|
|
16027
|
-
|
|
16369
|
+
log50.info("cancelled");
|
|
16028
16370
|
return;
|
|
16029
16371
|
}
|
|
16030
16372
|
}
|
|
16031
|
-
const applied = await provider.setInbound(box, raw, (line) =>
|
|
16373
|
+
const applied = await provider.setInbound(box, raw, (line) => log50.step(line));
|
|
16032
16374
|
process.stdout.write(`inbound set for ${box.name}: ${describeInbound(applied)}
|
|
16033
16375
|
`);
|
|
16034
16376
|
} catch (err) {
|
|
@@ -16038,15 +16380,15 @@ var inboundCommand = new Command42("inbound").description(
|
|
|
16038
16380
|
|
|
16039
16381
|
// src/commands/connect.ts
|
|
16040
16382
|
import { readFile as readFile6 } from "fs/promises";
|
|
16041
|
-
import { confirm as confirm4, isCancel as isCancel6, log as
|
|
16042
|
-
import { Command as
|
|
16383
|
+
import { confirm as confirm4, isCancel as isCancel6, log as log51 } from "@clack/prompts";
|
|
16384
|
+
import { Command as Command44 } from "commander";
|
|
16043
16385
|
function looksLikePublicKey(s) {
|
|
16044
16386
|
return /^(ssh-(ed25519|rsa|dss)|ecdsa-sha2-\S+|sk-ssh-\S+|sk-ecdsa-\S+)\s+\S+/.test(s.trim());
|
|
16045
16387
|
}
|
|
16046
16388
|
function shellSingleQuote(s) {
|
|
16047
16389
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
16048
16390
|
}
|
|
16049
|
-
var connectCommand = new
|
|
16391
|
+
var connectCommand = new Command44("connect").description(
|
|
16050
16392
|
"Print a VPS box's SSH connection details (to drive it from a phone / other SSH client with the laptop off), add another device's key, export the box key, or copy git credentials into the box so it pushes on its own (--dangerously-git-credentials). Pair with `agentbox inbound <box> open` so the box is reachable off-network. Hetzner / DigitalOcean only."
|
|
16051
16393
|
).argument(
|
|
16052
16394
|
"[box]",
|
|
@@ -16066,36 +16408,36 @@ var connectCommand = new Command43("connect").description(
|
|
|
16066
16408
|
const provider = await providerForBox(box);
|
|
16067
16409
|
if (opts.dangerouslyGitCredentials) {
|
|
16068
16410
|
if (opts.addKey || opts.exportKey) {
|
|
16069
|
-
|
|
16411
|
+
log51.error("--dangerously-git-credentials cannot be combined with --add-key / --export-key.");
|
|
16070
16412
|
process.exit(2);
|
|
16071
16413
|
}
|
|
16072
16414
|
if (!provider.enableDirectGit || !provider.buildAttach) {
|
|
16073
|
-
|
|
16415
|
+
log51.error(
|
|
16074
16416
|
`\`connect --dangerously-git-credentials\` needs an SSH cloud box (hetzner / digitalocean) \u2014 provider '${box.provider ?? "docker"}' isn't supported here` + (provider.enableDirectGit ? "" : " (docker boxes bind-mount the host .git, so git direct mode is N/A)") + "."
|
|
16075
16417
|
);
|
|
16076
16418
|
process.exit(2);
|
|
16077
16419
|
}
|
|
16078
16420
|
const projectRoot = box.projectRoot ?? box.workspacePath ?? process.cwd();
|
|
16079
|
-
const gate = await runGitCredsGate({ projectRoot, onLog: (l) =>
|
|
16421
|
+
const gate = await runGitCredsGate({ projectRoot, onLog: (l) => log51.step(l) });
|
|
16080
16422
|
if (gate.decision === "cancel") {
|
|
16081
|
-
|
|
16423
|
+
log51.info("cancelled");
|
|
16082
16424
|
return;
|
|
16083
16425
|
}
|
|
16084
16426
|
if (gate.decision === "skip" || gate.entries.length === 0) {
|
|
16085
|
-
|
|
16427
|
+
log51.warn(
|
|
16086
16428
|
"no git credential could be resolved for this repo (no token / ssh key found); nothing was applied."
|
|
16087
16429
|
);
|
|
16088
16430
|
return;
|
|
16089
16431
|
}
|
|
16090
16432
|
await resolveCloudSshTarget(box, provider, {
|
|
16091
16433
|
bringOnline: true,
|
|
16092
|
-
logInfo: (l) =>
|
|
16434
|
+
logInfo: (l) => log51.step(l)
|
|
16093
16435
|
});
|
|
16094
16436
|
await provider.enableDirectGit(box, gate.entries, {
|
|
16095
16437
|
hostRepo: projectRoot,
|
|
16096
|
-
onLog: (l) =>
|
|
16438
|
+
onLog: (l) => log51.step(l)
|
|
16097
16439
|
});
|
|
16098
|
-
|
|
16440
|
+
log51.success(
|
|
16099
16441
|
`git direct mode enabled for ${box.name} \u2014 it can now \`git push\` / \`pull\` on its own with your laptop off.`
|
|
16100
16442
|
);
|
|
16101
16443
|
const lastAgent = box.lastAgent;
|
|
@@ -16108,9 +16450,9 @@ var connectCommand = new Command43("connect").description(
|
|
|
16108
16450
|
await restoreAgentSessions(box, provider, {
|
|
16109
16451
|
restoreOnly: lastAgent,
|
|
16110
16452
|
force: true,
|
|
16111
|
-
onLog: (l) =>
|
|
16453
|
+
onLog: (l) => log51.step(l)
|
|
16112
16454
|
});
|
|
16113
|
-
|
|
16455
|
+
log51.success(`${lastAgent} restarted in the background \u2014 it now pushes direct.`);
|
|
16114
16456
|
return;
|
|
16115
16457
|
}
|
|
16116
16458
|
}
|
|
@@ -16122,23 +16464,23 @@ var connectCommand = new Command43("connect").description(
|
|
|
16122
16464
|
return;
|
|
16123
16465
|
}
|
|
16124
16466
|
if (!provider.buildAttach) {
|
|
16125
|
-
|
|
16467
|
+
log51.error(
|
|
16126
16468
|
`\`connect\` needs an SSH box \u2014 provider '${box.provider ?? "docker"}' isn't reachable over SSH (only hetzner / digitalocean boxes are).`
|
|
16127
16469
|
);
|
|
16128
16470
|
process.exit(2);
|
|
16129
16471
|
}
|
|
16130
16472
|
const conn = await resolveCloudSshTarget(box, provider, {
|
|
16131
16473
|
bringOnline: Boolean(opts.addKey),
|
|
16132
|
-
logInfo: (l) =>
|
|
16474
|
+
logInfo: (l) => log51.step(l)
|
|
16133
16475
|
});
|
|
16134
16476
|
if (!conn.identityFile) {
|
|
16135
|
-
|
|
16477
|
+
log51.error(`box '${box.name}' has no persistent SSH key \u2014 only hetzner / digitalocean boxes are supported.`);
|
|
16136
16478
|
process.exit(2);
|
|
16137
16479
|
}
|
|
16138
16480
|
if (opts.addKey) {
|
|
16139
16481
|
const raw = opts.addKey.startsWith("@") ? (await readFile6(opts.addKey.slice(1), "utf8")).trim() : opts.addKey.trim();
|
|
16140
16482
|
if (!looksLikePublicKey(raw)) {
|
|
16141
|
-
|
|
16483
|
+
log51.error(
|
|
16142
16484
|
"that does not look like an SSH public key (expected e.g. `ssh-ed25519 AAAA\u2026 comment`). Pass the public key string or @path-to-key.pub."
|
|
16143
16485
|
);
|
|
16144
16486
|
process.exit(2);
|
|
@@ -16147,7 +16489,7 @@ var connectCommand = new Command43("connect").description(
|
|
|
16147
16489
|
const script = `set -e; mkdir -p ~/.ssh && chmod 700 ~/.ssh; touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys; if grep -qxF ${q} ~/.ssh/authorized_keys; then echo already-present; else echo ${q} >> ~/.ssh/authorized_keys && echo added; fi`;
|
|
16148
16490
|
const res = await provider.exec(box, ["bash", "-lc", script]);
|
|
16149
16491
|
if (res.exitCode !== 0) {
|
|
16150
|
-
|
|
16492
|
+
log51.error(`failed to add key: ${res.stderr || res.stdout || `exit ${String(res.exitCode)}`}`);
|
|
16151
16493
|
process.exit(1);
|
|
16152
16494
|
}
|
|
16153
16495
|
const already = res.stdout.includes("already-present");
|
|
@@ -16160,12 +16502,12 @@ var connectCommand = new Command43("connect").description(
|
|
|
16160
16502
|
}
|
|
16161
16503
|
if (opts.exportKey) {
|
|
16162
16504
|
if (!opts.yes) {
|
|
16163
|
-
|
|
16505
|
+
log51.warn(
|
|
16164
16506
|
`This prints box '${box.name}''s PRIVATE key. Anyone with it can SSH in as ${conn.user}. Prefer \`--add-key <your-device.pub>\` (the box key then never leaves this host).`
|
|
16165
16507
|
);
|
|
16166
16508
|
const ok = await confirm4({ message: "Export the private key?", initialValue: false });
|
|
16167
16509
|
if (isCancel6(ok) || !ok) {
|
|
16168
|
-
|
|
16510
|
+
log51.info("cancelled");
|
|
16169
16511
|
return;
|
|
16170
16512
|
}
|
|
16171
16513
|
}
|
|
@@ -16210,7 +16552,7 @@ var connectCommand = new Command43("connect").description(
|
|
|
16210
16552
|
});
|
|
16211
16553
|
|
|
16212
16554
|
// src/commands/prune.ts
|
|
16213
|
-
import { Command as
|
|
16555
|
+
import { Command as Command45 } from "commander";
|
|
16214
16556
|
function totalRemovals(r, projectConfigs) {
|
|
16215
16557
|
return r.removedRecords.length + r.removedContainers.length + r.removedVolumes.length + r.removedSnapshotDirs.length + r.removedBoxDirs.length + projectConfigs.length;
|
|
16216
16558
|
}
|
|
@@ -16251,12 +16593,12 @@ function summary(r, projectConfigs) {
|
|
|
16251
16593
|
async function liveProjectRoots() {
|
|
16252
16594
|
try {
|
|
16253
16595
|
const boxes = await listBoxes();
|
|
16254
|
-
return boxes.map((b) => b.projectRoot).filter((
|
|
16596
|
+
return boxes.map((b) => b.projectRoot).filter((p2) => typeof p2 === "string");
|
|
16255
16597
|
} catch {
|
|
16256
16598
|
return [];
|
|
16257
16599
|
}
|
|
16258
16600
|
}
|
|
16259
|
-
var pruneCommand = new
|
|
16601
|
+
var pruneCommand = new Command45("prune").description("Clean up orphan state.json records (and with --all, orphan docker resources)").option("--dry-run", "show what would be removed, don't change anything").option(
|
|
16260
16602
|
"--all",
|
|
16261
16603
|
"also remove orphan agentbox-* containers, volumes, snapshot dirs, and orphan per-project config dirs"
|
|
16262
16604
|
).option("-y, --yes", "skip the confirmation prompt").option(
|
|
@@ -16301,7 +16643,14 @@ ${summary(result, removedProjects)}
|
|
|
16301
16643
|
handleLifecycleError(err);
|
|
16302
16644
|
}
|
|
16303
16645
|
});
|
|
16304
|
-
var CLOUD_PRUNE_PROVIDERS = [
|
|
16646
|
+
var CLOUD_PRUNE_PROVIDERS = [
|
|
16647
|
+
"daytona",
|
|
16648
|
+
"hetzner",
|
|
16649
|
+
"vercel",
|
|
16650
|
+
"e2b",
|
|
16651
|
+
"digitalocean",
|
|
16652
|
+
"remote-docker"
|
|
16653
|
+
];
|
|
16305
16654
|
function isCloudPruneProvider(name) {
|
|
16306
16655
|
return CLOUD_PRUNE_PROVIDERS.includes(name);
|
|
16307
16656
|
}
|
|
@@ -16370,17 +16719,17 @@ async function pruneCloud(provider, opts) {
|
|
|
16370
16719
|
|
|
16371
16720
|
// src/commands/queue.ts
|
|
16372
16721
|
import { readFile as readFile7, stat as stat7 } from "fs/promises";
|
|
16373
|
-
import { intro as intro13, log as
|
|
16374
|
-
import { Command as
|
|
16722
|
+
import { intro as intro13, log as log53, outro as outro12 } from "@clack/prompts";
|
|
16723
|
+
import { Command as Command46 } from "commander";
|
|
16375
16724
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
|
|
16376
|
-
var queueCommand = new
|
|
16377
|
-
var queueListCommand = new
|
|
16725
|
+
var queueCommand = new Command46("queue").description("Inspect and manage background `agentbox claude|codex|opencode -i` jobs");
|
|
16726
|
+
var queueListCommand = new Command46("list").description("List queued, running, and (with --all) terminal background jobs").option("--all", "include done/failed/cancelled jobs (default: hide terminal)").action(async (opts) => {
|
|
16378
16727
|
const jobs = await loadQueue();
|
|
16379
16728
|
const cfg = await loadQueueConfig();
|
|
16380
16729
|
const visible = opts.all === true ? jobs : jobs.filter((j) => !TERMINAL_STATUSES.has(j.status));
|
|
16381
16730
|
if (visible.length === 0) {
|
|
16382
|
-
|
|
16383
|
-
|
|
16731
|
+
log53.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
|
|
16732
|
+
log53.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
|
|
16384
16733
|
return;
|
|
16385
16734
|
}
|
|
16386
16735
|
const rows = visible.map((j) => ({
|
|
@@ -16405,12 +16754,12 @@ var queueListCommand = new Command45("list").description("List queued, running,
|
|
|
16405
16754
|
headers.map((h, i) => pad5(String(r[h]), widths[i])).join(" ") + "\n"
|
|
16406
16755
|
);
|
|
16407
16756
|
}
|
|
16408
|
-
|
|
16757
|
+
log53.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
|
|
16409
16758
|
});
|
|
16410
|
-
var queueShowCommand = new
|
|
16759
|
+
var queueShowCommand = new Command46("show").description("Dump a job manifest and tail its log").argument("<id>", "queue job id (from `agentbox queue list`)").option("--tail <n>", "lines of log to print (default: 50)", "50").action(async (id, opts) => {
|
|
16411
16760
|
const job = await readJob(id);
|
|
16412
16761
|
if (!job) {
|
|
16413
|
-
|
|
16762
|
+
log53.error(`no job with id ${id}`);
|
|
16414
16763
|
process.exit(1);
|
|
16415
16764
|
}
|
|
16416
16765
|
process.stdout.write(JSON.stringify(job, null, 2) + "\n");
|
|
@@ -16426,18 +16775,18 @@ var queueShowCommand = new Command45("show").description("Dump a job manifest an
|
|
|
16426
16775
|
process.stdout.write(slice.join("\n"));
|
|
16427
16776
|
if (!slice.join("\n").endsWith("\n")) process.stdout.write("\n");
|
|
16428
16777
|
} catch {
|
|
16429
|
-
|
|
16778
|
+
log53.info(`(no log at ${job.logPath} yet)`);
|
|
16430
16779
|
}
|
|
16431
16780
|
});
|
|
16432
|
-
var queueCancelCommand = new
|
|
16781
|
+
var queueCancelCommand = new Command46("cancel").description("Cancel a queued job; running jobs are NOT killed \u2014 use `agentbox destroy` instead").argument("<id>", "queue job id (from `agentbox queue list`)").action(async (id) => {
|
|
16433
16782
|
intro13(`Cancelling queue job ${id}...`);
|
|
16434
16783
|
const job = await readJob(id);
|
|
16435
16784
|
if (!job) {
|
|
16436
|
-
|
|
16785
|
+
log53.error(`no job with id ${id}`);
|
|
16437
16786
|
process.exit(1);
|
|
16438
16787
|
}
|
|
16439
16788
|
if (job.status !== "queued") {
|
|
16440
|
-
|
|
16789
|
+
log53.error(
|
|
16441
16790
|
`job ${id} is ${job.status}; cancel only flips 'queued' \u2192 'cancelled'.` + (job.status === "running" ? ` Use 'agentbox destroy ${job.boxName || id}' to stop the box.` : "")
|
|
16442
16791
|
);
|
|
16443
16792
|
process.exit(1);
|
|
@@ -16451,13 +16800,13 @@ var queueCancelCommand = new Command45("cancel").description("Cancel a queued jo
|
|
|
16451
16800
|
await writeJob(cancelled);
|
|
16452
16801
|
outro12(`job ${id} cancelled`);
|
|
16453
16802
|
});
|
|
16454
|
-
var queueClearCommand = new
|
|
16803
|
+
var queueClearCommand = new Command46("clear").description("Sweep terminal-state manifests from ~/.agentbox/queue/").option("--done", "remove done jobs").option("--failed", "remove failed jobs").option("--cancelled", "remove cancelled jobs").option("--all", "remove every terminal-state job (done + failed + cancelled)").action(async (opts) => {
|
|
16455
16804
|
const targets = /* @__PURE__ */ new Set();
|
|
16456
16805
|
if (opts.all === true || opts.done === true) targets.add("done");
|
|
16457
16806
|
if (opts.all === true || opts.failed === true) targets.add("failed");
|
|
16458
16807
|
if (opts.all === true || opts.cancelled === true) targets.add("cancelled");
|
|
16459
16808
|
if (targets.size === 0) {
|
|
16460
|
-
|
|
16809
|
+
log53.error("pick at least one of: --done, --failed, --cancelled, --all");
|
|
16461
16810
|
process.exit(2);
|
|
16462
16811
|
}
|
|
16463
16812
|
const jobs = await loadQueue();
|
|
@@ -16467,7 +16816,7 @@ var queueClearCommand = new Command45("clear").description("Sweep terminal-state
|
|
|
16467
16816
|
await deleteJob(j.id);
|
|
16468
16817
|
removed += 1;
|
|
16469
16818
|
}
|
|
16470
|
-
|
|
16819
|
+
log53.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
|
|
16471
16820
|
});
|
|
16472
16821
|
var QUEUE_WAIT_EVENTS = [
|
|
16473
16822
|
"new-box",
|
|
@@ -16480,11 +16829,11 @@ var QUEUE_WAIT_EVENTS = [
|
|
|
16480
16829
|
var ACTIVE_JOB_STATUSES = /* @__PURE__ */ new Set(["queued", "running"]);
|
|
16481
16830
|
var DEFAULT_QUEUE_WAIT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
16482
16831
|
var QUEUE_POLL_INTERVAL_MS = 500;
|
|
16483
|
-
var queueWaitForCommand = new
|
|
16832
|
+
var queueWaitForCommand = new Command46("wait-for").description(
|
|
16484
16833
|
`Block until a queue / box event fires. <event> one of: ${QUEUE_WAIT_EVENTS.join(" | ")}.`
|
|
16485
16834
|
).argument("<event>", `target event: ${QUEUE_WAIT_EVENTS.join(" | ")}`).option("--box <ref>", "box ref (required for box-paused / box-running / box-stopped)").option("--job <id>", "queue job id (required for job-done)").option("--timeout <ms>", `wall-clock cap (default: ${String(DEFAULT_QUEUE_WAIT_TIMEOUT_MS)})`).option("--json", "emit a JSON envelope { matched, elapsedMs, ... }").action(async (eventRaw, opts) => {
|
|
16486
16835
|
if (!QUEUE_WAIT_EVENTS.includes(eventRaw)) {
|
|
16487
|
-
|
|
16836
|
+
log53.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
|
|
16488
16837
|
process.exit(2);
|
|
16489
16838
|
}
|
|
16490
16839
|
const event = eventRaw;
|
|
@@ -16504,11 +16853,11 @@ var queueWaitForCommand = new Command45("wait-for").description(
|
|
|
16504
16853
|
if (opts.json === true) {
|
|
16505
16854
|
process.stdout.write(JSON.stringify({ matched: false, event, elapsedMs }) + "\n");
|
|
16506
16855
|
} else {
|
|
16507
|
-
|
|
16856
|
+
log53.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
|
|
16508
16857
|
}
|
|
16509
16858
|
process.exit(1);
|
|
16510
16859
|
}
|
|
16511
|
-
|
|
16860
|
+
log53.error(err instanceof Error ? err.message : String(err));
|
|
16512
16861
|
process.exit(1);
|
|
16513
16862
|
}
|
|
16514
16863
|
});
|
|
@@ -16605,8 +16954,8 @@ function truncate(s, max) {
|
|
|
16605
16954
|
}
|
|
16606
16955
|
|
|
16607
16956
|
// src/commands/relay.ts
|
|
16608
|
-
import { log as
|
|
16609
|
-
import { Command as
|
|
16957
|
+
import { log as log54, spinner as spinner12 } from "@clack/prompts";
|
|
16958
|
+
import { Command as Command47 } from "commander";
|
|
16610
16959
|
async function rehydrateFromState() {
|
|
16611
16960
|
const state = await readState();
|
|
16612
16961
|
await rehydrateRelayRegistry(
|
|
@@ -16650,7 +16999,7 @@ function renderStatus(s) {
|
|
|
16650
16999
|
}
|
|
16651
17000
|
return ["relay: not running", ` log: ${s.logFile}`].join("\n");
|
|
16652
17001
|
}
|
|
16653
|
-
var statusSub2 = new
|
|
17002
|
+
var statusSub2 = new Command47("status").description("Show whether the host relay is running, with pid / port / box count").option("--json", "emit RelayStatus as JSON").action(async (opts) => {
|
|
16654
17003
|
try {
|
|
16655
17004
|
const s = await getRelayStatus();
|
|
16656
17005
|
if (opts.json) {
|
|
@@ -16662,9 +17011,9 @@ var statusSub2 = new Command46("status").description("Show whether the host rela
|
|
|
16662
17011
|
handleLifecycleError(err);
|
|
16663
17012
|
}
|
|
16664
17013
|
});
|
|
16665
|
-
var stopSub2 = new
|
|
17014
|
+
var stopSub2 = new Command47("stop").description("Stop the host relay process (idempotent)").action(async () => {
|
|
16666
17015
|
try {
|
|
16667
|
-
const s =
|
|
17016
|
+
const s = spinner12();
|
|
16668
17017
|
s.start("stopping relay");
|
|
16669
17018
|
const result = await stopRelay();
|
|
16670
17019
|
s.stop(
|
|
@@ -16674,9 +17023,9 @@ var stopSub2 = new Command46("stop").description("Stop the host relay process (i
|
|
|
16674
17023
|
handleLifecycleError(err);
|
|
16675
17024
|
}
|
|
16676
17025
|
});
|
|
16677
|
-
var startSub2 = new
|
|
17026
|
+
var startSub2 = new Command47("start").description("Start the host relay if not already running (idempotent)").action(async () => {
|
|
16678
17027
|
try {
|
|
16679
|
-
const s =
|
|
17028
|
+
const s = spinner12();
|
|
16680
17029
|
s.start("starting relay");
|
|
16681
17030
|
const ep = await ensureRelay();
|
|
16682
17031
|
await rehydrateFromState();
|
|
@@ -16685,15 +17034,15 @@ var startSub2 = new Command46("start").description("Start the host relay if not
|
|
|
16685
17034
|
handleLifecycleError(err);
|
|
16686
17035
|
}
|
|
16687
17036
|
});
|
|
16688
|
-
var restartSub2 = new
|
|
17037
|
+
var restartSub2 = new Command47("restart").description("Stop then start the host relay").action(async () => {
|
|
16689
17038
|
try {
|
|
16690
|
-
const s =
|
|
17039
|
+
const s = spinner12();
|
|
16691
17040
|
s.start("stopping relay");
|
|
16692
17041
|
const stopped = await stopRelay();
|
|
16693
17042
|
s.stop(
|
|
16694
17043
|
stopped.stopped ? `stopped relay (pid ${String(stopped.pid)})` : "relay was not running"
|
|
16695
17044
|
);
|
|
16696
|
-
const s2 =
|
|
17045
|
+
const s2 = spinner12();
|
|
16697
17046
|
s2.start("starting relay");
|
|
16698
17047
|
try {
|
|
16699
17048
|
const ep = await ensureRelay();
|
|
@@ -16701,19 +17050,19 @@ var restartSub2 = new Command46("restart").description("Stop then start the host
|
|
|
16701
17050
|
s2.stop(`relay running on ${ep.hostUrl}`);
|
|
16702
17051
|
} catch (err) {
|
|
16703
17052
|
s2.stop("relay start failed");
|
|
16704
|
-
|
|
17053
|
+
log54.warn(err instanceof Error ? err.message : String(err));
|
|
16705
17054
|
throw err;
|
|
16706
17055
|
}
|
|
16707
17056
|
} catch (err) {
|
|
16708
17057
|
handleLifecycleError(err);
|
|
16709
17058
|
}
|
|
16710
17059
|
});
|
|
16711
|
-
var relayCommand = new
|
|
17060
|
+
var relayCommand = new Command47("relay").description("Manage the host relay process (status / stop / start / restart)").addCommand(statusSub2, { isDefault: true }).addCommand(stopSub2).addCommand(startSub2).addCommand(restartSub2);
|
|
16712
17061
|
|
|
16713
17062
|
// src/commands/hub.ts
|
|
16714
17063
|
import { spawn as spawn7 } from "child_process";
|
|
16715
|
-
import { log as
|
|
16716
|
-
import { Command as
|
|
17064
|
+
import { log as log55, spinner as spinner13 } from "@clack/prompts";
|
|
17065
|
+
import { Command as Command48 } from "commander";
|
|
16717
17066
|
async function resolvePortlessEnabled() {
|
|
16718
17067
|
try {
|
|
16719
17068
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
@@ -16744,7 +17093,7 @@ function renderStatus2(s) {
|
|
|
16744
17093
|
}
|
|
16745
17094
|
return ["hub: not running", ` log: ${s.logFile}`].join("\n");
|
|
16746
17095
|
}
|
|
16747
|
-
var statusSub3 = new
|
|
17096
|
+
var statusSub3 = new Command48("status").description("Show whether the hub (relay + Web UI) is running, with its URL").option("--json", "emit HubStatus as JSON").action(async (opts) => {
|
|
16748
17097
|
try {
|
|
16749
17098
|
const s = await getHubStatus();
|
|
16750
17099
|
if (opts.json) {
|
|
@@ -16756,9 +17105,9 @@ var statusSub3 = new Command47("status").description("Show whether the hub (rela
|
|
|
16756
17105
|
handleLifecycleError(err);
|
|
16757
17106
|
}
|
|
16758
17107
|
});
|
|
16759
|
-
var startSub3 = new
|
|
17108
|
+
var startSub3 = new Command48("start").description("Start the hub (relay + Web UI on port 8787) and open it").option("--no-open", "don't open the browser, just print the URL").action(async (opts) => {
|
|
16760
17109
|
try {
|
|
16761
|
-
const s =
|
|
17110
|
+
const s = spinner13();
|
|
16762
17111
|
s.start("starting hub");
|
|
16763
17112
|
const ep = await ensureHub({
|
|
16764
17113
|
onLog: (line) => s.message(line),
|
|
@@ -16775,9 +17124,9 @@ var startSub3 = new Command47("start").description("Start the hub (relay + Web U
|
|
|
16775
17124
|
handleLifecycleError(err);
|
|
16776
17125
|
}
|
|
16777
17126
|
});
|
|
16778
|
-
var stopSub3 = new
|
|
17127
|
+
var stopSub3 = new Command48("stop").description("Stop the hub process (idempotent)").action(async () => {
|
|
16779
17128
|
try {
|
|
16780
|
-
const s =
|
|
17129
|
+
const s = spinner13();
|
|
16781
17130
|
s.start("stopping hub");
|
|
16782
17131
|
const result = await stopHub();
|
|
16783
17132
|
s.stop(result.stopped ? `stopped hub (pid ${String(result.pid)})` : "hub was not running");
|
|
@@ -16785,13 +17134,13 @@ var stopSub3 = new Command47("stop").description("Stop the hub process (idempote
|
|
|
16785
17134
|
handleLifecycleError(err);
|
|
16786
17135
|
}
|
|
16787
17136
|
});
|
|
16788
|
-
var restartSub3 = new
|
|
17137
|
+
var restartSub3 = new Command48("restart").description("Stop then start the hub").option("--no-open", "don't open the browser, just print the URL").action(async (opts) => {
|
|
16789
17138
|
try {
|
|
16790
|
-
const s =
|
|
17139
|
+
const s = spinner13();
|
|
16791
17140
|
s.start("stopping hub");
|
|
16792
17141
|
const stopped = await stopHub();
|
|
16793
17142
|
s.stop(stopped.stopped ? `stopped hub (pid ${String(stopped.pid)})` : "hub was not running");
|
|
16794
|
-
const s2 =
|
|
17143
|
+
const s2 = spinner13();
|
|
16795
17144
|
s2.start("starting hub");
|
|
16796
17145
|
try {
|
|
16797
17146
|
const ep = await ensureHub({
|
|
@@ -16807,20 +17156,20 @@ var restartSub3 = new Command47("restart").description("Stop then start the hub"
|
|
|
16807
17156
|
if (opts.open !== false) openInBrowser2(ep.openUrl);
|
|
16808
17157
|
} catch (err) {
|
|
16809
17158
|
s2.stop("hub start failed");
|
|
16810
|
-
|
|
17159
|
+
log55.warn(err instanceof Error ? err.message : String(err));
|
|
16811
17160
|
throw err;
|
|
16812
17161
|
}
|
|
16813
17162
|
} catch (err) {
|
|
16814
17163
|
handleLifecycleError(err);
|
|
16815
17164
|
}
|
|
16816
17165
|
});
|
|
16817
|
-
var hubCommand = new
|
|
17166
|
+
var hubCommand = new Command48("hub").description(
|
|
16818
17167
|
"Run the AgentBox hub \u2014 the relay + Web UI on http://127.0.0.1:8787 (also https://agentbox.localhost when Portless is installed)"
|
|
16819
17168
|
).addCommand(startSub3, { isDefault: true }).addCommand(statusSub3).addCommand(stopSub3).addCommand(restartSub3);
|
|
16820
17169
|
|
|
16821
17170
|
// src/commands/control-plane.ts
|
|
16822
|
-
import { isCancel as isCancel8, log as
|
|
16823
|
-
import { Command as
|
|
17171
|
+
import { isCancel as isCancel8, log as log56, note as note7, select as select3, spinner as spinner14 } from "@clack/prompts";
|
|
17172
|
+
import { Command as Command49 } from "commander";
|
|
16824
17173
|
import { spawn as spawn10 } from "child_process";
|
|
16825
17174
|
import { existsSync as existsSync21, readFileSync as readFileSync12 } from "fs";
|
|
16826
17175
|
import { chmod as chmod2, mkdir as mkdir2, rm, writeFile as writeFile6 } from "fs/promises";
|
|
@@ -16832,22 +17181,22 @@ import { randomBytes as randomBytes3 } from "crypto";
|
|
|
16832
17181
|
// src/control-plane/create-box.ts
|
|
16833
17182
|
function makeControlPlaneCreateBox(deps) {
|
|
16834
17183
|
return async (request, jobId) => {
|
|
16835
|
-
const
|
|
17184
|
+
const log69 = deps.log ?? (() => {
|
|
16836
17185
|
});
|
|
16837
17186
|
const dir = deps.tmpDir(jobId);
|
|
16838
17187
|
try {
|
|
16839
|
-
|
|
17188
|
+
log69(`leasing a push token for ${request.repoUrl}`);
|
|
16840
17189
|
const authedUrl = await deps.leaseRemoteUrl(request.repoUrl);
|
|
16841
|
-
|
|
17190
|
+
log69(`cloning ${request.repoUrl}${request.branch ? `@${request.branch}` : ""} into ${dir}`);
|
|
16842
17191
|
await deps.cloneRepo(authedUrl, request.repoUrl, dir, request.branch);
|
|
16843
|
-
|
|
17192
|
+
log69(`provisioning ${request.provider} box from the clone`);
|
|
16844
17193
|
const box = await deps.createBox({
|
|
16845
17194
|
workspacePath: dir,
|
|
16846
17195
|
name: request.name,
|
|
16847
17196
|
provider: request.provider,
|
|
16848
17197
|
onLog: deps.log
|
|
16849
17198
|
});
|
|
16850
|
-
|
|
17199
|
+
log69(`created box ${box.id}`);
|
|
16851
17200
|
return { boxId: box.id };
|
|
16852
17201
|
} finally {
|
|
16853
17202
|
await deps.cleanup(dir);
|
|
@@ -16865,7 +17214,7 @@ async function runGitHubAppManifestFlow(opts) {
|
|
|
16865
17214
|
const githubUrl = (opts.githubUrl ?? "https://github.com").replace(/\/$/, "");
|
|
16866
17215
|
const apiBaseUrl = (opts.apiBaseUrl ?? "https://api.github.com").replace(/\/$/, "");
|
|
16867
17216
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
16868
|
-
const
|
|
17217
|
+
const log69 = opts.log ?? (() => {
|
|
16869
17218
|
});
|
|
16870
17219
|
const state = randomBytes(16).toString("hex");
|
|
16871
17220
|
return new Promise((resolve7, reject) => {
|
|
@@ -16967,10 +17316,10 @@ async function runGitHubAppManifestFlow(opts) {
|
|
|
16967
17316
|
server.listen(0, "127.0.0.1", () => {
|
|
16968
17317
|
listenPort = server.address().port;
|
|
16969
17318
|
const startUrl = `http://127.0.0.1:${String(listenPort)}/`;
|
|
16970
|
-
|
|
17319
|
+
log69(`opening ${startUrl} to create the GitHub App\u2026`);
|
|
16971
17320
|
void Promise.resolve(opts.openBrowser(startUrl)).catch((err) => {
|
|
16972
|
-
|
|
16973
|
-
|
|
17321
|
+
log69(`could not open the browser automatically: ${err instanceof Error ? err.message : String(err)}`);
|
|
17322
|
+
log69(`open this URL manually: ${startUrl}`);
|
|
16974
17323
|
});
|
|
16975
17324
|
});
|
|
16976
17325
|
});
|
|
@@ -17015,9 +17364,9 @@ async function ghLogin() {
|
|
|
17015
17364
|
const login = r.stdout.trim();
|
|
17016
17365
|
return r.code === 0 && login.length > 0 ? login : null;
|
|
17017
17366
|
}
|
|
17018
|
-
async function ensureFork(repo, login,
|
|
17367
|
+
async function ensureFork(repo, login, log69) {
|
|
17019
17368
|
const fork = `${login}/${nameOf(repo)}`;
|
|
17020
|
-
|
|
17369
|
+
log69(`forking ${repo} -> ${fork}\u2026`);
|
|
17021
17370
|
const f = await gh(["repo", "fork", repo, "--clone=false"]);
|
|
17022
17371
|
if (f.code !== 0 && !/already exists/i.test(`${f.stderr}${f.stdout}`)) {
|
|
17023
17372
|
throw new Error(`gh repo fork ${repo} failed: ${(f.stderr || f.stdout).trim()}`);
|
|
@@ -17036,13 +17385,13 @@ var PROJECT_DEFAULT = "agentbox-control-plane";
|
|
|
17036
17385
|
var ROOT_DIRECTORY = "apps/hub";
|
|
17037
17386
|
var GitConnectError = class extends Error {
|
|
17038
17387
|
};
|
|
17039
|
-
function connectedTo(
|
|
17040
|
-
return !!
|
|
17388
|
+
function connectedTo(p2, repo) {
|
|
17389
|
+
return !!p2?.link && p2.link.type === "github" && `${p2.link.org ?? ""}/${p2.link.repo ?? ""}`.toLowerCase() === repo.toLowerCase();
|
|
17041
17390
|
}
|
|
17042
17391
|
function isConnectError(msg) {
|
|
17043
17392
|
return /install the GitHub integration|integration first|github integration/i.test(msg);
|
|
17044
17393
|
}
|
|
17045
|
-
function provisionNeon(teamId, projectId,
|
|
17394
|
+
function provisionNeon(teamId, projectId, log69) {
|
|
17046
17395
|
return new Promise((resolve7) => {
|
|
17047
17396
|
const work = mkdtempSync2(join31(tmpdir6(), "agentbox-neon-"));
|
|
17048
17397
|
const env = { ...process.env, VERCEL_PROJECT_ID: projectId, ...teamId ? { VERCEL_ORG_ID: teamId } : {} };
|
|
@@ -17052,7 +17401,7 @@ function provisionNeon(teamId, projectId, log67) {
|
|
|
17052
17401
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17053
17402
|
});
|
|
17054
17403
|
const onData = (c) => {
|
|
17055
|
-
for (const l of c.toString("utf8").split(/\r?\n/)) if (l.trim())
|
|
17404
|
+
for (const l of c.toString("utf8").split(/\r?\n/)) if (l.trim()) log69(`neon: ${l.trim()}`);
|
|
17056
17405
|
};
|
|
17057
17406
|
child.stdout.on("data", onData);
|
|
17058
17407
|
child.stderr.on("data", onData);
|
|
@@ -17064,22 +17413,22 @@ function provisionNeon(teamId, projectId, log67) {
|
|
|
17064
17413
|
resolve7();
|
|
17065
17414
|
};
|
|
17066
17415
|
child.on("error", (e) => {
|
|
17067
|
-
|
|
17416
|
+
log69(`neon: could not run \`vercel integration add neon\` (${e.message}) \u2014 continuing`);
|
|
17068
17417
|
done();
|
|
17069
17418
|
});
|
|
17070
17419
|
child.on("close", (code) => {
|
|
17071
|
-
if (code !== 0)
|
|
17420
|
+
if (code !== 0) log69(`neon: integration add exited ${String(code)} \u2014 continuing (it may already be attached)`);
|
|
17072
17421
|
done();
|
|
17073
17422
|
});
|
|
17074
17423
|
});
|
|
17075
17424
|
}
|
|
17076
|
-
async function pollDeployment(token, teamId, id,
|
|
17425
|
+
async function pollDeployment(token, teamId, id, log69) {
|
|
17077
17426
|
const stop = Date.now() + 20 * 6e4;
|
|
17078
17427
|
let last = "";
|
|
17079
17428
|
while (Date.now() < stop) {
|
|
17080
17429
|
const d = await getDeployment(token, teamId, id);
|
|
17081
17430
|
if (d.readyState !== last) {
|
|
17082
|
-
|
|
17431
|
+
log69(`build: ${d.readyState.toLowerCase()}`);
|
|
17083
17432
|
last = d.readyState;
|
|
17084
17433
|
}
|
|
17085
17434
|
if (d.readyState === "READY") return;
|
|
@@ -17144,14 +17493,14 @@ async function apiDeploy(a) {
|
|
|
17144
17493
|
return { url: alias.startsWith("http") ? alias : `https://${alias}` };
|
|
17145
17494
|
}
|
|
17146
17495
|
function deployButtonUrl(repo, projectName) {
|
|
17147
|
-
const
|
|
17496
|
+
const p2 = new URLSearchParams({
|
|
17148
17497
|
"repository-url": `https://github.com/${repo}`,
|
|
17149
17498
|
"root-directory": ROOT_DIRECTORY,
|
|
17150
17499
|
stores: '[{"type":"postgres"}]',
|
|
17151
17500
|
"project-name": projectName,
|
|
17152
17501
|
"repository-name": projectName
|
|
17153
17502
|
});
|
|
17154
|
-
return `https://vercel.com/new/clone?${
|
|
17503
|
+
return `https://vercel.com/new/clone?${p2.toString()}`;
|
|
17155
17504
|
}
|
|
17156
17505
|
async function buttonDeploy(a) {
|
|
17157
17506
|
const url = deployButtonUrl(a.repo, a.projectName);
|
|
@@ -17292,7 +17641,7 @@ async function waitForHealthz(url, deadlineMs) {
|
|
|
17292
17641
|
}
|
|
17293
17642
|
return false;
|
|
17294
17643
|
}
|
|
17295
|
-
var setupSub = new
|
|
17644
|
+
var setupSub = new Command49("setup").description(
|
|
17296
17645
|
"Create the GitHub App the control plane leases push tokens with, and write its deploy config (env + admin token)"
|
|
17297
17646
|
).option("--name <name>", "GitHub App name (default: autogenerated agentbox-<rand>, must be globally unique)").option("--org <org>", "create the App under an organization instead of your user account").option("--deploy <target>", "deploy the plane after creating the App: vercel | hetzner | none").option("--repo <owner/name>", "GitHub repo to deploy the plane from (default madarco/agentbox; fork + pass this if you don't own it)").option("--ref <ref>", "git ref of the repo to deploy (branch/tag/sha; default main) \u2014 used by Vercel + Hetzner").action(async (opts) => {
|
|
17298
17647
|
try {
|
|
@@ -17301,7 +17650,7 @@ var setupSub = new Command48("setup").description(
|
|
|
17301
17650
|
'Your browser will open to GitHub to create the App. Review the\npermissions (Contents + Pull requests: write) and click "Create".',
|
|
17302
17651
|
"GitHub App"
|
|
17303
17652
|
);
|
|
17304
|
-
const s =
|
|
17653
|
+
const s = spinner14();
|
|
17305
17654
|
s.start("waiting for the GitHub App to be created in your browser");
|
|
17306
17655
|
const app = await runGitHubAppManifestFlow({
|
|
17307
17656
|
appName: String(name),
|
|
@@ -17331,7 +17680,7 @@ AGENTBOX_RELAY_ADMIN_TOKEN=${adminToken}
|
|
|
17331
17680
|
JSON.stringify({ appId: app.appId, slug: app.slug, htmlUrl: app.htmlUrl, installUrl: app.installUrl }, null, 2) + "\n",
|
|
17332
17681
|
{ mode: 384 }
|
|
17333
17682
|
);
|
|
17334
|
-
|
|
17683
|
+
log56.success(`GitHub App ready. Deploy config written to ${ENV_PATH2} (0600).`);
|
|
17335
17684
|
const target = await resolveDeployTarget(opts.deploy);
|
|
17336
17685
|
let deployedUrl = null;
|
|
17337
17686
|
if (target !== "none") {
|
|
@@ -17347,7 +17696,7 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
|
|
|
17347
17696
|
await chmod2(ENV_PATH2, 384);
|
|
17348
17697
|
}
|
|
17349
17698
|
try {
|
|
17350
|
-
const ds =
|
|
17699
|
+
const ds = spinner14();
|
|
17351
17700
|
ds.start(`deploying the control plane to ${target}`);
|
|
17352
17701
|
const onLog = (line) => ds.message(line);
|
|
17353
17702
|
const repo = opts.repo ?? DEFAULT_DEPLOY_REPO;
|
|
@@ -17365,7 +17714,7 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
|
|
|
17365
17714
|
}
|
|
17366
17715
|
ds.stop(`deployed: ${deployedUrl}`);
|
|
17367
17716
|
} catch (e) {
|
|
17368
|
-
|
|
17717
|
+
log56.warn(`deploy to ${target} failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
17369
17718
|
printManualDeploy();
|
|
17370
17719
|
}
|
|
17371
17720
|
} else {
|
|
@@ -17373,13 +17722,13 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
|
|
|
17373
17722
|
}
|
|
17374
17723
|
if (deployedUrl) {
|
|
17375
17724
|
const url = await applyControlPlaneUrl(deployedUrl);
|
|
17376
|
-
|
|
17725
|
+
log56.success(`Pointed the CLI at ${url} (relay.controlPlaneUrl).`);
|
|
17377
17726
|
const ok = await waitForHealthz(url, 6e4);
|
|
17378
|
-
|
|
17727
|
+
log56[ok ? "success" : "warn"](
|
|
17379
17728
|
ok ? `Control plane is healthy (${url}/healthz).` : `Could not confirm ${url}/healthz yet \u2014 check the deployment.`
|
|
17380
17729
|
);
|
|
17381
17730
|
}
|
|
17382
|
-
|
|
17731
|
+
log56.info(`Install the App on your repos: ${app.installUrl}`);
|
|
17383
17732
|
openInBrowser(app.installUrl);
|
|
17384
17733
|
} catch (err) {
|
|
17385
17734
|
handleLifecycleError(err);
|
|
@@ -17388,7 +17737,7 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
|
|
|
17388
17737
|
async function resolveDeployTarget(flag) {
|
|
17389
17738
|
if (flag === "vercel" || flag === "hetzner" || flag === "none") return flag;
|
|
17390
17739
|
if (flag) {
|
|
17391
|
-
|
|
17740
|
+
log56.warn(`unknown --deploy "${flag}"; choose interactively`);
|
|
17392
17741
|
}
|
|
17393
17742
|
const choice = await select3({
|
|
17394
17743
|
message: "Deploy the control plane now?",
|
|
@@ -17403,7 +17752,7 @@ async function resolveDeployTarget(flag) {
|
|
|
17403
17752
|
return choice;
|
|
17404
17753
|
}
|
|
17405
17754
|
function printManualDeploy() {
|
|
17406
|
-
|
|
17755
|
+
log56.info(
|
|
17407
17756
|
[
|
|
17408
17757
|
"Deploy later with the written env:",
|
|
17409
17758
|
` Self-host: cd apps/hub && docker compose --env-file ${ENV_PATH2} up --build`,
|
|
@@ -17412,45 +17761,45 @@ function printManualDeploy() {
|
|
|
17412
17761
|
].join("\n")
|
|
17413
17762
|
);
|
|
17414
17763
|
}
|
|
17415
|
-
var setUrlSub = new
|
|
17764
|
+
var setUrlSub = new Command49("set-url").description("Point boxes + the CLI at a deployed control plane (sets relay.controlPlaneUrl)").argument("<url>", "base URL of the deployed control plane, e.g. https://plane.example.com").action(async (url) => {
|
|
17416
17765
|
try {
|
|
17417
17766
|
const trimmed = await applyControlPlaneUrl(url);
|
|
17418
|
-
|
|
17767
|
+
log56.success(`Set relay.controlPlaneUrl = ${trimmed}`);
|
|
17419
17768
|
} catch (err) {
|
|
17420
17769
|
handleLifecycleError(err);
|
|
17421
17770
|
}
|
|
17422
17771
|
});
|
|
17423
|
-
var unsetUrlSub = new
|
|
17772
|
+
var unsetUrlSub = new Command49("unset-url").description("Stop using a control plane on this machine (removes relay.controlPlaneUrl)").option("--purge", "also delete this machine's local App metadata + admin token (~/.agentbox/control-plane)").action(async (opts) => {
|
|
17424
17773
|
try {
|
|
17425
17774
|
const g = await unsetConfigValue("global", "relay.controlPlaneUrl", process.cwd());
|
|
17426
|
-
const
|
|
17427
|
-
if (!g.existed && !
|
|
17428
|
-
|
|
17775
|
+
const p2 = await unsetConfigValue("project", "relay.controlPlaneUrl", process.cwd());
|
|
17776
|
+
if (!g.existed && !p2.existed) {
|
|
17777
|
+
log56.info("No control plane was configured (relay.controlPlaneUrl not set).");
|
|
17429
17778
|
} else {
|
|
17430
|
-
const where = [g.existed ? "global" : null,
|
|
17431
|
-
|
|
17779
|
+
const where = [g.existed ? "global" : null, p2.existed ? "project" : null].filter(Boolean).join(" + ");
|
|
17780
|
+
log56.success(
|
|
17432
17781
|
`Removed relay.controlPlaneUrl (${where}). New cloud boxes now push through the host relay (your laptop must be on), and the GitHub-App repo-authorization prompt no longer fires.`
|
|
17433
17782
|
);
|
|
17434
17783
|
}
|
|
17435
17784
|
if (existsSync21(CP_DIR2)) {
|
|
17436
17785
|
if (opts.purge) {
|
|
17437
17786
|
await rm(CP_DIR2, { recursive: true, force: true });
|
|
17438
|
-
|
|
17787
|
+
log56.success(`Purged this machine's control-plane credentials (${CP_DIR2}).`);
|
|
17439
17788
|
} else {
|
|
17440
|
-
|
|
17789
|
+
log56.info(`This machine's App metadata + admin token remain in ${CP_DIR2} (use --purge to delete).`);
|
|
17441
17790
|
}
|
|
17442
17791
|
}
|
|
17443
17792
|
} catch (err) {
|
|
17444
17793
|
handleLifecycleError(err);
|
|
17445
17794
|
}
|
|
17446
17795
|
});
|
|
17447
|
-
var statusSub4 = new
|
|
17796
|
+
var statusSub4 = new Command49("status").description("Check whether the configured control plane is reachable").option("--url <url>", "override the control-plane URL (default: relay.controlPlaneUrl)").option("--json", "emit JSON").action(async (opts) => {
|
|
17448
17797
|
try {
|
|
17449
|
-
const { loadEffectiveConfig: loadEffectiveConfig2 } = await import("./dist-
|
|
17798
|
+
const { loadEffectiveConfig: loadEffectiveConfig2 } = await import("./dist-U2SVLJUQ.js");
|
|
17450
17799
|
const cfg = await loadEffectiveConfig2(process.cwd());
|
|
17451
17800
|
const url = (opts.url ?? cfg.effective.relay.controlPlaneUrl ?? "").replace(/\/$/, "");
|
|
17452
17801
|
if (!url) {
|
|
17453
|
-
|
|
17802
|
+
log56.error("No control plane configured. Run `agentbox control-plane set-url <url>` (or pass --url).");
|
|
17454
17803
|
process.exitCode = 1;
|
|
17455
17804
|
return;
|
|
17456
17805
|
}
|
|
@@ -17475,36 +17824,36 @@ var statusSub4 = new Command48("status").description("Check whether the configur
|
|
|
17475
17824
|
handleLifecycleError(err);
|
|
17476
17825
|
}
|
|
17477
17826
|
});
|
|
17478
|
-
var addSub = new
|
|
17827
|
+
var addSub = new Command49("add").description("Authorize the current project's git repo on the control plane's GitHub App").action(async () => {
|
|
17479
17828
|
try {
|
|
17480
17829
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
17481
17830
|
const controlPlaneUrl = cfg.effective.relay.controlPlaneUrl;
|
|
17482
17831
|
if (!controlPlaneUrl) {
|
|
17483
|
-
|
|
17832
|
+
log56.error("No control plane configured. Run `agentbox control-plane set-url <url>` first.");
|
|
17484
17833
|
process.exitCode = 1;
|
|
17485
17834
|
return;
|
|
17486
17835
|
}
|
|
17487
17836
|
const ownerRepo = await resolveOwnerRepo(process.cwd());
|
|
17488
17837
|
if (!ownerRepo) {
|
|
17489
|
-
|
|
17838
|
+
log56.error("No git origin found here \u2014 `cd` into a project with a GitHub remote.");
|
|
17490
17839
|
process.exitCode = 1;
|
|
17491
17840
|
return;
|
|
17492
17841
|
}
|
|
17493
17842
|
const { owner, repo } = ownerRepo;
|
|
17494
17843
|
const installed = await checkRepoInstalled(owner, repo, controlPlaneUrl);
|
|
17495
17844
|
if (installed === true) {
|
|
17496
|
-
|
|
17845
|
+
log56.success(`${owner}/${repo} is already authorized on the GitHub App.`);
|
|
17497
17846
|
return;
|
|
17498
17847
|
}
|
|
17499
17848
|
const url = addRepoUrl(loadControlPlaneMeta());
|
|
17500
17849
|
if (!url) {
|
|
17501
|
-
|
|
17850
|
+
log56.error(
|
|
17502
17851
|
"No GitHub App metadata found locally. Run this from a machine that ran `control-plane setup`,\nor open your App settings on GitHub and add the repo manually."
|
|
17503
17852
|
);
|
|
17504
17853
|
process.exitCode = 1;
|
|
17505
17854
|
return;
|
|
17506
17855
|
}
|
|
17507
|
-
|
|
17856
|
+
log56.info(`Opening ${url} \u2014 select ${owner}/${repo}, then approve.`);
|
|
17508
17857
|
openInBrowser(url);
|
|
17509
17858
|
} catch (err) {
|
|
17510
17859
|
handleLifecycleError(err);
|
|
@@ -17530,14 +17879,14 @@ function runGit(args) {
|
|
|
17530
17879
|
);
|
|
17531
17880
|
});
|
|
17532
17881
|
}
|
|
17533
|
-
var workerSub = new
|
|
17882
|
+
var workerSub = new Command49("worker").description(
|
|
17534
17883
|
"Drain the control plane box-creation queue and provision real boxes (long-running; needs provider creds + the App key)"
|
|
17535
17884
|
).requiredOption("--store <url>", "Postgres URL of the control plane (same store the plane uses)").option("--once", "drain the queue once and exit (default: loop)").option("--poll-interval <ms>", "poll interval when looping", "5000").action(async (opts) => {
|
|
17536
17885
|
try {
|
|
17537
17886
|
loadControlPlaneEnv();
|
|
17538
17887
|
const appCfg = loadGitHubAppConfig();
|
|
17539
17888
|
if (!appCfg) {
|
|
17540
|
-
|
|
17889
|
+
log56.error("No GitHub App configured. Run `agentbox control-plane setup` first.");
|
|
17541
17890
|
process.exitCode = 1;
|
|
17542
17891
|
return;
|
|
17543
17892
|
}
|
|
@@ -17558,8 +17907,8 @@ var workerSub = new Command48("worker").description(
|
|
|
17558
17907
|
await runGit(["-C", dest, "remote", "set-url", "origin", repoUrl]);
|
|
17559
17908
|
},
|
|
17560
17909
|
createBox: async ({ workspacePath, name, provider, onLog }) => {
|
|
17561
|
-
const
|
|
17562
|
-
const created = await
|
|
17910
|
+
const p2 = await providerForCreate({ flag: provider, config: cfg.effective });
|
|
17911
|
+
const created = await p2.create({ workspacePath, name, projectRoot: workspacePath, onLog });
|
|
17563
17912
|
return { id: created.record.id };
|
|
17564
17913
|
},
|
|
17565
17914
|
tmpDir: (jobId) => join33(tmpdir7(), `agentbox-cp-worker-${jobId}`),
|
|
@@ -17589,10 +17938,10 @@ var workerSub = new Command48("worker").description(
|
|
|
17589
17938
|
handleLifecycleError(err);
|
|
17590
17939
|
}
|
|
17591
17940
|
});
|
|
17592
|
-
var controlPlaneCommand = new
|
|
17941
|
+
var controlPlaneCommand = new Command49("control-plane").description("EXPERIMENTAL - Set up + manage the hosted control plane (GitHub App, deploy config, reachability)").addCommand(statusSub4, { isDefault: true }).addCommand(setupSub).addCommand(setUrlSub).addCommand(unsetUrlSub).addCommand(addSub).addCommand(workerSub);
|
|
17593
17942
|
|
|
17594
17943
|
// src/commands/_run-queued-job.ts
|
|
17595
|
-
import { Command as
|
|
17944
|
+
import { Command as Command50 } from "commander";
|
|
17596
17945
|
import { stat as stat8 } from "fs/promises";
|
|
17597
17946
|
import { join as join34 } from "path";
|
|
17598
17947
|
|
|
@@ -17656,14 +18005,14 @@ async function needsClaudeLogin(image, isCloud) {
|
|
|
17656
18005
|
return !await hostBackupHasCredentials();
|
|
17657
18006
|
}
|
|
17658
18007
|
async function ensureClaudeLoginFresh(args) {
|
|
17659
|
-
const { id, log:
|
|
18008
|
+
const { id, log: log69, image, isCloud } = args;
|
|
17660
18009
|
if (!await needsClaudeLogin(image, isCloud)) return;
|
|
17661
|
-
|
|
18010
|
+
log69.write("claude login is expired or missing \u2014 starting browser re-login");
|
|
17662
18011
|
await patchJobLogin(id, { required: true, phase: "starting" });
|
|
17663
|
-
await ensureImage(image, { onProgress: (line) =>
|
|
18012
|
+
await ensureImage(image, { onProgress: (line) => log69.write(line) });
|
|
17664
18013
|
let chain = Promise.resolve();
|
|
17665
18014
|
const enqueue = (patch) => {
|
|
17666
|
-
chain = chain.then(() => patchJobLogin(id, patch)).catch((err) =>
|
|
18015
|
+
chain = chain.then(() => patchJobLogin(id, patch)).catch((err) => log69.write(`login manifest write failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
17667
18016
|
};
|
|
17668
18017
|
let pendingCode = null;
|
|
17669
18018
|
const codeWatcher = setInterval(() => {
|
|
@@ -17679,8 +18028,8 @@ async function ensureClaudeLoginFresh(args) {
|
|
|
17679
18028
|
const result = await runClaudeLogin({
|
|
17680
18029
|
image,
|
|
17681
18030
|
signal: abort.signal,
|
|
17682
|
-
writeRaw: (chunk) =>
|
|
17683
|
-
writeLog: (line) =>
|
|
18031
|
+
writeRaw: (chunk) => log69.raw(chunk),
|
|
18032
|
+
writeLog: (line) => log69.write(line),
|
|
17684
18033
|
onPhase: (phase, u) => {
|
|
17685
18034
|
const patch = { phase };
|
|
17686
18035
|
if (u?.url) patch.url = u.url;
|
|
@@ -17696,30 +18045,30 @@ async function ensureClaudeLoginFresh(args) {
|
|
|
17696
18045
|
});
|
|
17697
18046
|
await chain;
|
|
17698
18047
|
if (!result.ok) throw new Error(result.error ?? "claude login failed");
|
|
17699
|
-
|
|
18048
|
+
log69.write("claude login refreshed");
|
|
17700
18049
|
} finally {
|
|
17701
18050
|
clearInterval(codeWatcher);
|
|
17702
18051
|
for (const sig of ["SIGTERM", "SIGINT"]) process.removeListener(sig, onSignal);
|
|
17703
18052
|
}
|
|
17704
18053
|
}
|
|
17705
|
-
var runQueuedJobCommand = new
|
|
17706
|
-
const
|
|
17707
|
-
|
|
18054
|
+
var runQueuedJobCommand = new Command50("_run-queued-job").description("internal: run a queued background agent job (do not invoke directly)").argument("<id>", "queue job id (from ~/.agentbox/queue/<id>.json)").action(async (id) => {
|
|
18055
|
+
const log69 = openCommandLog(`queue-${id}`);
|
|
18056
|
+
log69.write(`worker pid=${String(process.pid)} starting for job ${id}`);
|
|
17708
18057
|
let job = null;
|
|
17709
18058
|
try {
|
|
17710
18059
|
job = await readJob(id);
|
|
17711
18060
|
if (!job) {
|
|
17712
|
-
|
|
17713
|
-
|
|
18061
|
+
log69.write(`FATAL: no manifest at id=${id}`);
|
|
18062
|
+
log69.close();
|
|
17714
18063
|
process.exit(64);
|
|
17715
18064
|
}
|
|
17716
18065
|
const onBoxCreated = (boxId) => {
|
|
17717
18066
|
if (job) job = { ...job, boxId };
|
|
17718
18067
|
};
|
|
17719
18068
|
if ((job.providerName || "docker") === "docker") {
|
|
17720
|
-
await runDockerJob(job,
|
|
18069
|
+
await runDockerJob(job, log69, onBoxCreated);
|
|
17721
18070
|
} else {
|
|
17722
|
-
await runCloudJob(job,
|
|
18071
|
+
await runCloudJob(job, log69, onBoxCreated);
|
|
17723
18072
|
}
|
|
17724
18073
|
const persisted = await readJob(id);
|
|
17725
18074
|
const done = {
|
|
@@ -17730,12 +18079,12 @@ var runQueuedJobCommand = new Command49("_run-queued-job").description("internal
|
|
|
17730
18079
|
login: persisted?.login
|
|
17731
18080
|
};
|
|
17732
18081
|
await writeJob(done);
|
|
17733
|
-
|
|
17734
|
-
|
|
18082
|
+
log69.write(`done`);
|
|
18083
|
+
log69.close();
|
|
17735
18084
|
process.exit(0);
|
|
17736
18085
|
} catch (err) {
|
|
17737
18086
|
const msg = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
17738
|
-
|
|
18087
|
+
log69.write(`FAIL: ${msg}`);
|
|
17739
18088
|
if (job) {
|
|
17740
18089
|
try {
|
|
17741
18090
|
const persisted = await readJob(id);
|
|
@@ -17751,31 +18100,33 @@ var runQueuedJobCommand = new Command49("_run-queued-job").description("internal
|
|
|
17751
18100
|
} catch {
|
|
17752
18101
|
}
|
|
17753
18102
|
}
|
|
17754
|
-
|
|
18103
|
+
log69.close();
|
|
17755
18104
|
process.exit(1);
|
|
17756
18105
|
}
|
|
17757
18106
|
});
|
|
17758
|
-
async function runDockerJob(job,
|
|
18107
|
+
async function runDockerJob(job, log69, onBoxCreated) {
|
|
17759
18108
|
const opts = job.createOpts;
|
|
17760
18109
|
const cfg = await loadEffectiveConfig(opts.workspace, {
|
|
17761
18110
|
cliOverrides: buildOverridesFromJob(job)
|
|
17762
18111
|
});
|
|
17763
18112
|
const projectRoot = (await findProjectRoot(opts.workspace)).root;
|
|
17764
|
-
const
|
|
18113
|
+
const { name: providerName } = parseProviderSpec(
|
|
18114
|
+
job.providerName || cfg.effective.box.provider || "docker"
|
|
18115
|
+
);
|
|
17765
18116
|
const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
|
|
17766
18117
|
const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
|
|
17767
18118
|
const useSnapshot = opts.hostSnapshot === false ? false : opts.hostSnapshot === true ? true : cfg.effective.box.hostSnapshot ?? false;
|
|
17768
18119
|
const resolved = !job.noAgent && job.agent === "claude-code" ? await resolveClaudeAuth(process.env) : null;
|
|
17769
18120
|
const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
|
|
17770
18121
|
if (!job.noAgent && job.agent === "claude-code") {
|
|
17771
|
-
await ensureClaudeLoginFresh({ id: job.id, log:
|
|
18122
|
+
await ensureClaudeLoginFresh({ id: job.id, log: log69, image: cfg.effective.box.image, isCloud: false });
|
|
17772
18123
|
}
|
|
17773
18124
|
const portlessEnabled = opts.portless ?? await resolvePortlessNonInteractive({
|
|
17774
18125
|
engine: await detectEngine(),
|
|
17775
18126
|
enabled: cfg.effective.portless.enabled,
|
|
17776
18127
|
cwd: opts.workspace
|
|
17777
18128
|
});
|
|
17778
|
-
|
|
18129
|
+
log69.write(`creating box for agent=${job.noAgent ? "none" : job.agent}`);
|
|
17779
18130
|
const result = await createBox({
|
|
17780
18131
|
workspacePath: opts.workspace,
|
|
17781
18132
|
name: opts.name && opts.name.length > 0 ? opts.name : void 0,
|
|
@@ -17800,30 +18151,30 @@ async function runDockerJob(job, log67, onBoxCreated) {
|
|
|
17800
18151
|
// at box-create time (the worker runs on the host, so it can read the files).
|
|
17801
18152
|
carry: opts.carry,
|
|
17802
18153
|
projectRoot,
|
|
17803
|
-
onLog: (line) =>
|
|
18154
|
+
onLog: (line) => log69.write(line)
|
|
17804
18155
|
});
|
|
17805
|
-
|
|
18156
|
+
log69.write(`box created: ${result.record.container}`);
|
|
17806
18157
|
onBoxCreated(result.record.id);
|
|
17807
18158
|
if (!job.noAgent) await recordLastAgent(result.record.id, toSyncKind(job.agent)).catch(() => {
|
|
17808
18159
|
});
|
|
17809
18160
|
const persisted = await readJob(job.id);
|
|
17810
18161
|
await writeJob({ ...job, boxId: result.record.id, login: persisted?.login });
|
|
17811
18162
|
if (job.noAgent) {
|
|
17812
|
-
|
|
18163
|
+
log69.write("no-agent box created; skipping agent session");
|
|
17813
18164
|
return;
|
|
17814
18165
|
}
|
|
17815
18166
|
const resyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
|
|
17816
|
-
if (resyncWarning)
|
|
18167
|
+
if (resyncWarning) log69.write(resyncWarning);
|
|
17817
18168
|
const seeded = await applySetupWizardPrompt(job, opts.workspace, job.prompt);
|
|
17818
18169
|
const prompt = prependResyncWarning(resyncWarning, seeded);
|
|
17819
18170
|
const promptedArgs = buildPromptArgs(job.agent, prompt, job.agentArgs);
|
|
17820
18171
|
if (job.agent === "claude-code") {
|
|
17821
|
-
|
|
18172
|
+
log69.write(`checking plugin native deps`);
|
|
17822
18173
|
await rebuildPluginNativeDeps(result.record.container, {
|
|
17823
18174
|
volume: result.record.claudeConfigVolume ?? SHARED_CLAUDE_VOLUME,
|
|
17824
|
-
onProgress: (line) =>
|
|
18175
|
+
onProgress: (line) => log69.write(line)
|
|
17825
18176
|
});
|
|
17826
|
-
|
|
18177
|
+
log69.write(`starting claude session`);
|
|
17827
18178
|
await startClaudeSession({
|
|
17828
18179
|
container: result.record.container,
|
|
17829
18180
|
claudeArgs: applyClaudeSkipPermissions(promptedArgs, cfg.effective),
|
|
@@ -17831,22 +18182,22 @@ async function runDockerJob(job, log67, onBoxCreated) {
|
|
|
17831
18182
|
boxName: result.record.name
|
|
17832
18183
|
});
|
|
17833
18184
|
} else if (job.agent === "codex") {
|
|
17834
|
-
|
|
18185
|
+
log69.write(`checking codex`);
|
|
17835
18186
|
await ensureCodexInstalled(result.record.container, {
|
|
17836
|
-
onProgress: (line) =>
|
|
18187
|
+
onProgress: (line) => log69.write(line)
|
|
17837
18188
|
});
|
|
17838
|
-
|
|
18189
|
+
log69.write(`starting codex session`);
|
|
17839
18190
|
await startCodexSession({
|
|
17840
18191
|
container: result.record.container,
|
|
17841
18192
|
codexArgs: applyCodexSkipPermissions(promptedArgs, cfg.effective),
|
|
17842
18193
|
sessionName: cfg.effective.codex.sessionName
|
|
17843
18194
|
});
|
|
17844
18195
|
} else if (job.agent === "opencode") {
|
|
17845
|
-
|
|
18196
|
+
log69.write(`checking opencode`);
|
|
17846
18197
|
await ensureOpencodeInstalled(result.record.container, {
|
|
17847
|
-
onProgress: (line) =>
|
|
18198
|
+
onProgress: (line) => log69.write(line)
|
|
17848
18199
|
});
|
|
17849
|
-
|
|
18200
|
+
log69.write(`starting opencode session`);
|
|
17850
18201
|
await startOpencodeSession({
|
|
17851
18202
|
container: result.record.container,
|
|
17852
18203
|
opencodeArgs: promptedArgs,
|
|
@@ -17855,14 +18206,14 @@ async function runDockerJob(job, log67, onBoxCreated) {
|
|
|
17855
18206
|
} else {
|
|
17856
18207
|
throw new Error(`unknown agent kind: ${String(job.agent)}`);
|
|
17857
18208
|
}
|
|
17858
|
-
await maybeOpenQueuedTerminal(job, result.record.name,
|
|
18209
|
+
await maybeOpenQueuedTerminal(job, result.record.name, log69);
|
|
17859
18210
|
}
|
|
17860
|
-
async function maybeOpenQueuedTerminal(job, boxName,
|
|
18211
|
+
async function maybeOpenQueuedTerminal(job, boxName, log69) {
|
|
17861
18212
|
const ctx = job.openTerminal;
|
|
17862
18213
|
if (!ctx) return;
|
|
17863
18214
|
const cliEntry = process.env["AGENTBOX_CLI_ENTRY"];
|
|
17864
18215
|
if (!cliEntry) {
|
|
17865
|
-
|
|
18216
|
+
log69.write("queue.openIn: AGENTBOX_CLI_ENTRY unset; cannot open terminal");
|
|
17866
18217
|
return;
|
|
17867
18218
|
}
|
|
17868
18219
|
const argv2 = [
|
|
@@ -17876,28 +18227,29 @@ async function maybeOpenQueuedTerminal(job, boxName, log67) {
|
|
|
17876
18227
|
];
|
|
17877
18228
|
try {
|
|
17878
18229
|
const r = await spawnQueuedOpenTerminal(ctx, argv2, boxName);
|
|
17879
|
-
|
|
18230
|
+
log69.write(
|
|
17880
18231
|
r.launched ? `queue.openIn: ${r.note}` : `queue.openIn: open failed: ${r.error ?? ""}`
|
|
17881
18232
|
);
|
|
17882
18233
|
} catch (err) {
|
|
17883
|
-
|
|
18234
|
+
log69.write(`queue.openIn: open threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
17884
18235
|
}
|
|
17885
18236
|
}
|
|
17886
|
-
async function runCloudJob(job,
|
|
18237
|
+
async function runCloudJob(job, log69, onBoxCreated) {
|
|
17887
18238
|
const opts = job.createOpts;
|
|
17888
18239
|
const cfg = await loadEffectiveConfig(opts.workspace, {
|
|
17889
18240
|
cliOverrides: buildOverridesFromJob(job)
|
|
17890
18241
|
});
|
|
17891
18242
|
const projectRoot = (await findProjectRoot(opts.workspace)).root;
|
|
17892
|
-
const
|
|
17893
|
-
const
|
|
18243
|
+
const providerSpec = job.providerName || cfg.effective.box.provider || "docker";
|
|
18244
|
+
const { name: providerName, remoteHost } = parseProviderSpec(providerSpec);
|
|
18245
|
+
const provider = await providerForCreate({ flag: providerSpec, config: cfg.effective });
|
|
17894
18246
|
const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
|
|
17895
18247
|
const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
|
|
17896
18248
|
const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
|
|
17897
18249
|
if (!job.noAgent && job.agent === "claude-code") {
|
|
17898
|
-
await ensureClaudeLoginFresh({ id: job.id, log:
|
|
18250
|
+
await ensureClaudeLoginFresh({ id: job.id, log: log69, image: DEFAULT_BOX_IMAGE, isCloud: true });
|
|
17899
18251
|
}
|
|
17900
|
-
|
|
18252
|
+
log69.write(`creating cloud box (${providerName}) for agent=${job.noAgent ? "none" : job.agent}`);
|
|
17901
18253
|
const result = await provider.create({
|
|
17902
18254
|
workspacePath: opts.workspace,
|
|
17903
18255
|
name: opts.name && opts.name.length > 0 ? opts.name : void 0,
|
|
@@ -17914,12 +18266,12 @@ async function runCloudJob(job, log67, onBoxCreated) {
|
|
|
17914
18266
|
// worker runs on the host too, so it reads the files and uploads them.
|
|
17915
18267
|
carry: opts.carry,
|
|
17916
18268
|
projectRoot,
|
|
17917
|
-
onLog: (line) =>
|
|
18269
|
+
onLog: (line) => log69.write(line),
|
|
17918
18270
|
// Same size / location / session-lifetime resolution the foreground
|
|
17919
18271
|
// `agentbox create` does, so a queued box isn't sized differently.
|
|
17920
|
-
providerOptions: cloudSizingProviderOptions(providerName, cfg.effective)
|
|
18272
|
+
providerOptions: cloudSizingProviderOptions(providerName, cfg.effective, { remoteHost })
|
|
17921
18273
|
});
|
|
17922
|
-
|
|
18274
|
+
log69.write(`box created: ${result.record.id}`);
|
|
17923
18275
|
onBoxCreated(result.record.id);
|
|
17924
18276
|
if (!job.noAgent) await recordLastAgent(result.record.id, toSyncKind(job.agent)).catch(() => {
|
|
17925
18277
|
});
|
|
@@ -17929,10 +18281,10 @@ async function runCloudJob(job, log67, onBoxCreated) {
|
|
|
17929
18281
|
result.record,
|
|
17930
18282
|
provider,
|
|
17931
18283
|
cfg.effective.ssh.autoConfig,
|
|
17932
|
-
(m) =>
|
|
18284
|
+
(m) => log69.write(m)
|
|
17933
18285
|
);
|
|
17934
18286
|
if (job.noAgent) {
|
|
17935
|
-
|
|
18287
|
+
log69.write("no-agent box created; skipping agent session");
|
|
17936
18288
|
return;
|
|
17937
18289
|
}
|
|
17938
18290
|
const seeded = await applySetupWizardPrompt(job, opts.workspace, job.prompt);
|
|
@@ -17955,14 +18307,14 @@ async function runCloudJob(job, log67, onBoxCreated) {
|
|
|
17955
18307
|
} else {
|
|
17956
18308
|
throw new Error(`unknown agent kind: ${String(job.agent)}`);
|
|
17957
18309
|
}
|
|
17958
|
-
|
|
18310
|
+
log69.write(`starting detached ${job.agent} session`);
|
|
17959
18311
|
await cloudAgentStartDetached({
|
|
17960
18312
|
box: result.record,
|
|
17961
18313
|
binary,
|
|
17962
18314
|
sessionName,
|
|
17963
18315
|
extraArgs
|
|
17964
18316
|
});
|
|
17965
|
-
await maybeOpenQueuedTerminal(job, result.record.name,
|
|
18317
|
+
await maybeOpenQueuedTerminal(job, result.record.name, log69);
|
|
17966
18318
|
}
|
|
17967
18319
|
function buildOverridesFromJob(job) {
|
|
17968
18320
|
const opts = job.createOpts;
|
|
@@ -17992,19 +18344,19 @@ function buildOverridesFromJob(job) {
|
|
|
17992
18344
|
}
|
|
17993
18345
|
|
|
17994
18346
|
// src/commands/_run-queued-prepare.ts
|
|
17995
|
-
import { Command as
|
|
17996
|
-
var runQueuedPrepareCommand = new
|
|
17997
|
-
const
|
|
17998
|
-
|
|
18347
|
+
import { Command as Command51 } from "commander";
|
|
18348
|
+
var runQueuedPrepareCommand = new Command51("_run-queued-prepare").description("internal: run a queued provider image-bake job (do not invoke directly)").argument("<id>", "queue job id (from ~/.agentbox/queue/<id>.json)").action(async (id) => {
|
|
18349
|
+
const log69 = openCommandLog(`queue-${id}`);
|
|
18350
|
+
log69.write(`prepare worker pid=${String(process.pid)} starting for job ${id}`);
|
|
17999
18351
|
let job = null;
|
|
18000
18352
|
try {
|
|
18001
18353
|
job = await readJob(id);
|
|
18002
18354
|
if (!job) {
|
|
18003
|
-
|
|
18004
|
-
|
|
18355
|
+
log69.write(`FATAL: no manifest at id=${id}`);
|
|
18356
|
+
log69.close();
|
|
18005
18357
|
process.exit(64);
|
|
18006
18358
|
}
|
|
18007
|
-
await runPrepareJob(job,
|
|
18359
|
+
await runPrepareJob(job, log69);
|
|
18008
18360
|
const done = {
|
|
18009
18361
|
...job,
|
|
18010
18362
|
status: "done",
|
|
@@ -18012,12 +18364,12 @@ var runQueuedPrepareCommand = new Command50("_run-queued-prepare").description("
|
|
|
18012
18364
|
exitCode: 0
|
|
18013
18365
|
};
|
|
18014
18366
|
await writeJob(done);
|
|
18015
|
-
|
|
18016
|
-
|
|
18367
|
+
log69.write("done");
|
|
18368
|
+
log69.close();
|
|
18017
18369
|
process.exit(0);
|
|
18018
18370
|
} catch (err) {
|
|
18019
18371
|
const msg = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
18020
|
-
|
|
18372
|
+
log69.write(`FAIL: ${msg}`);
|
|
18021
18373
|
if (job) {
|
|
18022
18374
|
try {
|
|
18023
18375
|
const failed = {
|
|
@@ -18031,11 +18383,11 @@ var runQueuedPrepareCommand = new Command50("_run-queued-prepare").description("
|
|
|
18031
18383
|
} catch {
|
|
18032
18384
|
}
|
|
18033
18385
|
}
|
|
18034
|
-
|
|
18386
|
+
log69.close();
|
|
18035
18387
|
process.exit(1);
|
|
18036
18388
|
}
|
|
18037
18389
|
});
|
|
18038
|
-
async function runPrepareJob(job,
|
|
18390
|
+
async function runPrepareJob(job, log69) {
|
|
18039
18391
|
const providerName = job.providerName;
|
|
18040
18392
|
if (!isKnownProvider(providerName)) {
|
|
18041
18393
|
throw new Error(`unknown provider '${providerName}'`);
|
|
@@ -18048,24 +18400,24 @@ async function runPrepareJob(job, log67) {
|
|
|
18048
18400
|
if (typeof provider.prepare !== "function") {
|
|
18049
18401
|
throw new Error(`provider '${providerName}' does not implement prepare`);
|
|
18050
18402
|
}
|
|
18051
|
-
|
|
18403
|
+
log69.write(`baking ${providerName} (force=${String(job.prepare?.force ?? false)})`);
|
|
18052
18404
|
const result = await provider.prepare({
|
|
18053
18405
|
hostWorkspace: cwd,
|
|
18054
18406
|
force: job.prepare?.force,
|
|
18055
18407
|
registry,
|
|
18056
18408
|
claudeInstall,
|
|
18057
|
-
onLog: (line) =>
|
|
18409
|
+
onLog: (line) => log69.write(line)
|
|
18058
18410
|
});
|
|
18059
|
-
|
|
18411
|
+
log69.write(
|
|
18060
18412
|
result.snapshotName !== void 0 ? `prepared ${providerName}: ${result.snapshotName}` : `prepared ${providerName}`
|
|
18061
18413
|
);
|
|
18062
18414
|
if (result.snapshotName !== void 0 && isProviderKind(providerName)) {
|
|
18063
18415
|
const key = boxImageConfigKey(providerName);
|
|
18064
18416
|
try {
|
|
18065
18417
|
await setConfigValue("global", key, result.snapshotName, cwd);
|
|
18066
|
-
|
|
18418
|
+
log69.write(`pinned ${key}=${result.snapshotName} (global)`);
|
|
18067
18419
|
} catch (err) {
|
|
18068
|
-
|
|
18420
|
+
log69.write(
|
|
18069
18421
|
`warning: baked ${result.snapshotName} but failed to pin ${key}: ${err instanceof Error ? err.message : String(err)}`
|
|
18070
18422
|
);
|
|
18071
18423
|
}
|
|
@@ -18073,10 +18425,10 @@ async function runPrepareJob(job, log67) {
|
|
|
18073
18425
|
}
|
|
18074
18426
|
|
|
18075
18427
|
// src/commands/_claude-login-worker.ts
|
|
18076
|
-
import { Command as
|
|
18077
|
-
var claudeLoginWorkerCommand = new
|
|
18078
|
-
const
|
|
18079
|
-
|
|
18428
|
+
import { Command as Command52 } from "commander";
|
|
18429
|
+
var claudeLoginWorkerCommand = new Command52("_claude-login-worker").description("internal: drive `claude auth login` under a pty for headless login (do not invoke directly)").argument("<id>", "login session id (~/.agentbox/claude-login/<id>/)").action(async (id) => {
|
|
18430
|
+
const log69 = openCommandLog(`claude-login-${id}`);
|
|
18431
|
+
log69.write(`worker pid=${String(process.pid)} starting for session ${id}`);
|
|
18080
18432
|
const base = { pid: process.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18081
18433
|
let cur = { ...base, phase: "starting" };
|
|
18082
18434
|
const setState = (patch) => {
|
|
@@ -18086,15 +18438,15 @@ var claudeLoginWorkerCommand = new Command51("_claude-login-worker").description
|
|
|
18086
18438
|
setState({ phase: "starting" });
|
|
18087
18439
|
const req = readLoginRequest(id);
|
|
18088
18440
|
if (!req) {
|
|
18089
|
-
|
|
18441
|
+
log69.write(`FATAL: no request.json for session ${id}`);
|
|
18090
18442
|
setState({ phase: "error", error: "internal: missing login request" });
|
|
18091
|
-
|
|
18443
|
+
log69.close();
|
|
18092
18444
|
process.exit(64);
|
|
18093
18445
|
}
|
|
18094
18446
|
const abort = new AbortController();
|
|
18095
18447
|
for (const sig of ["SIGTERM", "SIGINT"]) {
|
|
18096
18448
|
process.on(sig, () => {
|
|
18097
|
-
|
|
18449
|
+
log69.write(`received ${sig}; aborting`);
|
|
18098
18450
|
abort.abort();
|
|
18099
18451
|
});
|
|
18100
18452
|
}
|
|
@@ -18103,18 +18455,18 @@ var claudeLoginWorkerCommand = new Command51("_claude-login-worker").description
|
|
|
18103
18455
|
// No method flags → the subscription paste-code flow (prints a URL, reads a
|
|
18104
18456
|
// code). Respect an explicit method the user forwarded (e.g. --console).
|
|
18105
18457
|
extraArgs: req.extraArgs,
|
|
18106
|
-
writeRaw: (chunk) =>
|
|
18107
|
-
writeLog: (line) =>
|
|
18458
|
+
writeRaw: (chunk) => log69.raw(chunk),
|
|
18459
|
+
writeLog: (line) => log69.write(line),
|
|
18108
18460
|
onPhase: (phase, update) => setState({ phase, ...update }),
|
|
18109
18461
|
getCode: () => takeLoginCode(id),
|
|
18110
18462
|
signal: abort.signal
|
|
18111
18463
|
});
|
|
18112
|
-
|
|
18464
|
+
log69.close();
|
|
18113
18465
|
process.exit(result.ok ? 0 : 1);
|
|
18114
18466
|
});
|
|
18115
18467
|
|
|
18116
18468
|
// src/commands/_post-update-refresh.ts
|
|
18117
|
-
import { Command as
|
|
18469
|
+
import { Command as Command53 } from "commander";
|
|
18118
18470
|
|
|
18119
18471
|
// src/lib/post-update-refresh.ts
|
|
18120
18472
|
async function maybeUpdateTray(say) {
|
|
@@ -18194,7 +18546,7 @@ async function runPostUpdateRefresh(opts = {}) {
|
|
|
18194
18546
|
}
|
|
18195
18547
|
|
|
18196
18548
|
// src/commands/_post-update-refresh.ts
|
|
18197
|
-
var postUpdateRefreshCommand = new
|
|
18549
|
+
var postUpdateRefreshCommand = new Command53("_post-update-refresh").description("internal: refresh skills, box image, relay, and tray after a package update").option("--skip-skills", "skip refreshing the host skill files").action(async (opts) => {
|
|
18198
18550
|
try {
|
|
18199
18551
|
await runPostUpdateRefresh({ skipSkills: opts.skipSkills });
|
|
18200
18552
|
} catch (err) {
|
|
@@ -18318,7 +18670,7 @@ function nudgeMessage(state, method, version = AGENTBOX_VERSION) {
|
|
|
18318
18670
|
|
|
18319
18671
|
// src/commands/herdr.ts
|
|
18320
18672
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
18321
|
-
import { Command as
|
|
18673
|
+
import { Command as Command54 } from "commander";
|
|
18322
18674
|
function parseHerdrLink(uri) {
|
|
18323
18675
|
if (!uri) return null;
|
|
18324
18676
|
const m = uri.match(/^agentbox:\/\/([^/]+)\/(.+)$/);
|
|
@@ -18344,7 +18696,7 @@ function herdrContextCwd(env = process.env) {
|
|
|
18344
18696
|
}
|
|
18345
18697
|
return process.cwd();
|
|
18346
18698
|
}
|
|
18347
|
-
var newCommand = new
|
|
18699
|
+
var newCommand = new Command54("new").description("Open a new box session in a fresh Herdr tab (used by the plugin shortcut)").option("--agent <agent>", "agent to launch (claude|codex|opencode)", "claude").action(async (opts) => {
|
|
18348
18700
|
const agent = opts.agent ?? "claude";
|
|
18349
18701
|
const cwd = herdrContextCwd();
|
|
18350
18702
|
const r = await spawnInNewTerminal({
|
|
@@ -18357,7 +18709,7 @@ var newCommand = new Command53("new").description("Open a new box session in a f
|
|
|
18357
18709
|
if (r.launched) process.stdout.write(r.note + "\n");
|
|
18358
18710
|
else if (r.error) process.stderr.write(r.error + "\n");
|
|
18359
18711
|
});
|
|
18360
|
-
var linkCommand = new
|
|
18712
|
+
var linkCommand = new Command54("link").description("Handle a Ctrl+click on an agentbox:// link (used by the plugin link handler)").argument("[uri]", "the clicked URI; defaults to $HERDR_PLUGIN_CLICKED_URL").action(async (uriArg) => {
|
|
18361
18713
|
const link = parseHerdrLink(uriArg ?? process.env["HERDR_PLUGIN_CLICKED_URL"]);
|
|
18362
18714
|
if (!link) return;
|
|
18363
18715
|
if (link.verb !== "web") return;
|
|
@@ -18390,14 +18742,14 @@ var linkCommand = new Command53("link").description("Handle a Ctrl+click on an a
|
|
|
18390
18742
|
sound: "request"
|
|
18391
18743
|
});
|
|
18392
18744
|
});
|
|
18393
|
-
var herdrCommand = new
|
|
18745
|
+
var herdrCommand = new Command54("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
|
|
18394
18746
|
|
|
18395
18747
|
// src/commands/recover.ts
|
|
18396
18748
|
import { homedir as homedir27 } from "os";
|
|
18397
18749
|
import { join as join35 } from "path";
|
|
18398
18750
|
import { access as access3 } from "fs/promises";
|
|
18399
|
-
import { isCancel as isCancel9, log as
|
|
18400
|
-
import { Command as
|
|
18751
|
+
import { isCancel as isCancel9, log as log58, select as select4 } from "@clack/prompts";
|
|
18752
|
+
import { Command as Command55 } from "commander";
|
|
18401
18753
|
function hetznerKeyPath(sandboxId) {
|
|
18402
18754
|
return join35(homedir27(), ".agentbox", "boxes", sandboxId, "ssh", "id_ed25519");
|
|
18403
18755
|
}
|
|
@@ -18429,7 +18781,7 @@ async function readBoxBranch(box) {
|
|
|
18429
18781
|
}
|
|
18430
18782
|
async function recoverKnownBox(box, opts) {
|
|
18431
18783
|
if (await hetznerKeyMissing(box)) {
|
|
18432
|
-
|
|
18784
|
+
log58.warn(
|
|
18433
18785
|
`${box.name}: per-box SSH key not found at ${hetznerKeyPath(box.cloud?.sandboxId ?? box.id)} \u2014 this box was created on another host and can't be controlled from here. Skipping.`
|
|
18434
18786
|
);
|
|
18435
18787
|
return false;
|
|
@@ -18438,19 +18790,19 @@ async function recoverKnownBox(box, opts) {
|
|
|
18438
18790
|
const record = await withFirewallRepair(
|
|
18439
18791
|
provider,
|
|
18440
18792
|
box,
|
|
18441
|
-
{ enabled: opts.firewallSync, onLog: (line) =>
|
|
18793
|
+
{ enabled: opts.firewallSync, onLog: (line) => log58.success(line) },
|
|
18442
18794
|
() => provider.reconnect(box)
|
|
18443
18795
|
);
|
|
18444
|
-
|
|
18796
|
+
log58.success(`reconnected ${record.name}`);
|
|
18445
18797
|
const lastAgent = normalizeLastAgent(record.lastAgent);
|
|
18446
18798
|
await restoreAgentSessions(record, provider, {
|
|
18447
18799
|
restoreOnly: lastAgent,
|
|
18448
|
-
onLog: (line) =>
|
|
18800
|
+
onLog: (line) => log58.info(line)
|
|
18449
18801
|
});
|
|
18450
18802
|
if (opts.attach) {
|
|
18451
18803
|
const result = await attachToRunningAgent(record, {});
|
|
18452
18804
|
if (result === "none") {
|
|
18453
|
-
|
|
18805
|
+
log58.warn(
|
|
18454
18806
|
`${record.name} reconnected but no agent session came up${lastAgent ? ` (last agent: ${lastAgent})` : ""}. Start one with: agentbox ${lastAgent ?? "claude"} ${record.name}`
|
|
18455
18807
|
);
|
|
18456
18808
|
}
|
|
@@ -18460,11 +18812,11 @@ async function recoverKnownBox(box, opts) {
|
|
|
18460
18812
|
async function adoptUnknownBox(provider, ref) {
|
|
18461
18813
|
const backend = await cloudBackendForProvider(provider);
|
|
18462
18814
|
if (!backend) {
|
|
18463
|
-
|
|
18815
|
+
log58.error(`--adopt is cloud-only; '${provider}' has no remote sandbox list`);
|
|
18464
18816
|
process.exit(2);
|
|
18465
18817
|
}
|
|
18466
18818
|
if (!backend.list) {
|
|
18467
|
-
|
|
18819
|
+
log58.error(`${provider} backend doesn't expose list(); cannot enumerate sandboxes to adopt`);
|
|
18468
18820
|
process.exit(2);
|
|
18469
18821
|
}
|
|
18470
18822
|
const [remote, state] = await Promise.all([backend.list(), readState()]);
|
|
@@ -18477,14 +18829,14 @@ async function adoptUnknownBox(provider, ref) {
|
|
|
18477
18829
|
(sb2) => !knownIds.has(sb2.sandboxId) && (sb2.name ?? "").length > 0
|
|
18478
18830
|
);
|
|
18479
18831
|
if (candidates.length === 0) {
|
|
18480
|
-
|
|
18832
|
+
log58.info(`no un-tracked ${provider} sandboxes to adopt`);
|
|
18481
18833
|
return null;
|
|
18482
18834
|
}
|
|
18483
18835
|
let chosen;
|
|
18484
18836
|
if (ref) {
|
|
18485
18837
|
chosen = candidates.find((sb2) => sb2.sandboxId === ref || sb2.name === ref);
|
|
18486
18838
|
if (!chosen) {
|
|
18487
|
-
|
|
18839
|
+
log58.error(`no adoptable ${provider} sandbox matches '${ref}'`);
|
|
18488
18840
|
process.exit(1);
|
|
18489
18841
|
}
|
|
18490
18842
|
} else if (candidates.length === 1) {
|
|
@@ -18499,7 +18851,7 @@ async function adoptUnknownBox(provider, ref) {
|
|
|
18499
18851
|
}))
|
|
18500
18852
|
});
|
|
18501
18853
|
if (isCancel9(picked)) {
|
|
18502
|
-
|
|
18854
|
+
log58.info("cancelled");
|
|
18503
18855
|
return null;
|
|
18504
18856
|
}
|
|
18505
18857
|
chosen = picked;
|
|
@@ -18523,7 +18875,7 @@ async function adoptUnknownBox(provider, ref) {
|
|
|
18523
18875
|
}
|
|
18524
18876
|
};
|
|
18525
18877
|
if (await hetznerKeyMissing(record)) {
|
|
18526
|
-
|
|
18878
|
+
log58.error(
|
|
18527
18879
|
`cannot adopt ${record.name}: per-box SSH key not found at ${hetznerKeyPath(sb.sandboxId)} \u2014 Hetzner boxes can only be controlled from the host that created them (the private key never leaves that host).`
|
|
18528
18880
|
);
|
|
18529
18881
|
process.exit(1);
|
|
@@ -18542,13 +18894,13 @@ async function adoptUnknownBox(provider, ref) {
|
|
|
18542
18894
|
];
|
|
18543
18895
|
}
|
|
18544
18896
|
await recordBox(record);
|
|
18545
|
-
|
|
18546
|
-
|
|
18897
|
+
log58.success(`adopted ${record.name} (${provider} sandbox ${sb.sandboxId})`);
|
|
18898
|
+
log58.warn(
|
|
18547
18899
|
"host-side project linkage (project index, git worktree host paths) could not be reconstructed from the box."
|
|
18548
18900
|
);
|
|
18549
18901
|
return record;
|
|
18550
18902
|
}
|
|
18551
|
-
var recoverCommand = new
|
|
18903
|
+
var recoverCommand = new Command55("recover").description(
|
|
18552
18904
|
"Reconnect to an already-running box without power-cycling it: ensure the relay is up, re-open the host transport (Hetzner SSH tunnel) + portless aliases, re-register with the relay, relaunch the agent it was running, and attach. With --all, recover every box in state. With --provider <p> --adopt [ref], first rebuild local state for a box created elsewhere."
|
|
18553
18905
|
).argument(
|
|
18554
18906
|
"[box]",
|
|
@@ -18564,7 +18916,7 @@ var recoverCommand = new Command54("recover").description(
|
|
|
18564
18916
|
if (opts.adopt) {
|
|
18565
18917
|
const provider = opts.provider;
|
|
18566
18918
|
if (!provider || !isKnownProvider(provider) || provider === "docker") {
|
|
18567
|
-
|
|
18919
|
+
log58.error("--adopt requires --provider <daytona|hetzner|vercel|e2b>");
|
|
18568
18920
|
process.exit(2);
|
|
18569
18921
|
}
|
|
18570
18922
|
const adopted = await adoptUnknownBox(provider, idOrName);
|
|
@@ -18578,7 +18930,7 @@ var recoverCommand = new Command54("recover").description(
|
|
|
18578
18930
|
if (opts.all) {
|
|
18579
18931
|
const state = await readState();
|
|
18580
18932
|
if (state.boxes.length === 0) {
|
|
18581
|
-
|
|
18933
|
+
log58.info("no boxes in local state to recover");
|
|
18582
18934
|
return;
|
|
18583
18935
|
}
|
|
18584
18936
|
let ok = 0;
|
|
@@ -18590,12 +18942,12 @@ var recoverCommand = new Command54("recover").description(
|
|
|
18590
18942
|
}))
|
|
18591
18943
|
ok++;
|
|
18592
18944
|
} catch (err) {
|
|
18593
|
-
|
|
18945
|
+
log58.warn(
|
|
18594
18946
|
`${box2.name}: recover failed: ${err instanceof Error ? err.message : String(err)}`
|
|
18595
18947
|
);
|
|
18596
18948
|
}
|
|
18597
18949
|
}
|
|
18598
|
-
|
|
18950
|
+
log58.success(`recovered ${String(ok)}/${String(state.boxes.length)} box(es)`);
|
|
18599
18951
|
return;
|
|
18600
18952
|
}
|
|
18601
18953
|
const box = await resolveBoxOrExit(idOrName);
|
|
@@ -18610,8 +18962,8 @@ var recoverCommand = new Command54("recover").description(
|
|
|
18610
18962
|
|
|
18611
18963
|
// src/commands/screen.ts
|
|
18612
18964
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
18613
|
-
import { log as
|
|
18614
|
-
import { Command as
|
|
18965
|
+
import { log as log59 } from "@clack/prompts";
|
|
18966
|
+
import { Command as Command56 } from "commander";
|
|
18615
18967
|
var SIGNED_URL_TTL_MIN = 1;
|
|
18616
18968
|
var SIGNED_URL_TTL_MAX = 86400;
|
|
18617
18969
|
function parseTtlOrExit(raw) {
|
|
@@ -18624,7 +18976,7 @@ function parseTtlOrExit(raw) {
|
|
|
18624
18976
|
}
|
|
18625
18977
|
return n;
|
|
18626
18978
|
}
|
|
18627
|
-
var screenCommand = new
|
|
18979
|
+
var screenCommand = new Command56("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
|
|
18628
18980
|
"[box]",
|
|
18629
18981
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
18630
18982
|
).option("--print", "print the URL to stdout instead of launching the browser").option("--loopback", "docker only: use the 127.0.0.1 URL instead of the OrbStack .orb.local URL").option(
|
|
@@ -18641,23 +18993,23 @@ var screenCommand = new Command55("screen").description("Open a box's VNC (noVNC
|
|
|
18641
18993
|
if (provider === "docker") {
|
|
18642
18994
|
const insp = await inspectBox(box.id);
|
|
18643
18995
|
if (insp.state === "paused") {
|
|
18644
|
-
|
|
18996
|
+
log59.info("box is paused; unpausing");
|
|
18645
18997
|
await unpauseBox(box.id);
|
|
18646
18998
|
} else if (insp.state === "stopped") {
|
|
18647
|
-
|
|
18999
|
+
log59.info("box is stopped; starting");
|
|
18648
19000
|
await startBox(box.id);
|
|
18649
19001
|
} else if (insp.state === "missing") {
|
|
18650
19002
|
throw new Error(`box ${box.name} has no container; was it destroyed?`);
|
|
18651
19003
|
}
|
|
18652
19004
|
const br = await ensureBoxBrowserShowingApp(box);
|
|
18653
19005
|
if (br.up && !br.alreadyRunning) {
|
|
18654
|
-
|
|
19006
|
+
log59.info(
|
|
18655
19007
|
br.target !== "about:blank" ? `opened ${br.target} in the in-box browser (visible in the VNC view)` : "started in-box browser"
|
|
18656
19008
|
);
|
|
18657
19009
|
} else if (br.alreadyRunning) {
|
|
18658
|
-
|
|
19010
|
+
log59.info("in-box browser already running; left it untouched");
|
|
18659
19011
|
} else {
|
|
18660
|
-
|
|
19012
|
+
log59.warn(`could not start in-box browser: ${br.reason ?? "unknown"}`);
|
|
18661
19013
|
}
|
|
18662
19014
|
const engine = await detectEngine();
|
|
18663
19015
|
const urls = buildVncUrls(box, engine);
|
|
@@ -18675,24 +19027,24 @@ var screenCommand = new Command55("screen").description("Open a box's VNC (noVNC
|
|
|
18675
19027
|
);
|
|
18676
19028
|
}
|
|
18677
19029
|
const ttl = parseTtlOrExit(opts.ttl);
|
|
18678
|
-
const
|
|
18679
|
-
const state = await
|
|
19030
|
+
const p2 = await providerForBox(box);
|
|
19031
|
+
const state = await p2.probeState(box);
|
|
18680
19032
|
if (state === "paused") {
|
|
18681
|
-
|
|
18682
|
-
await
|
|
19033
|
+
log59.info("box is paused; resuming");
|
|
19034
|
+
await p2.resume(box);
|
|
18683
19035
|
} else if (state === "stopped") {
|
|
18684
|
-
|
|
18685
|
-
await
|
|
19036
|
+
log59.info("box is stopped; starting");
|
|
19037
|
+
await p2.start(box);
|
|
18686
19038
|
} else if (state === "missing") {
|
|
18687
19039
|
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
18688
19040
|
}
|
|
18689
|
-
const br = await openWebAppOnVncScreen(box,
|
|
19041
|
+
const br = await openWebAppOnVncScreen(box, p2);
|
|
18690
19042
|
if (br.opened) {
|
|
18691
|
-
|
|
19043
|
+
log59.info(`opened ${br.target ?? ""} in the in-box browser (visible in the VNC view)`);
|
|
18692
19044
|
} else if (br.reason && br.reason !== "no web service") {
|
|
18693
|
-
|
|
19045
|
+
log59.warn(`could not open in-box browser (continuing): ${br.reason}`);
|
|
18694
19046
|
}
|
|
18695
|
-
const base = await
|
|
19047
|
+
const base = await p2.resolveUrl(box, { kind: "vnc", ttl });
|
|
18696
19048
|
url = `${base.replace(/\/$/, "")}/vnc.html?autoconnect=1&password=${encodeURIComponent(box.vncPassword)}`;
|
|
18697
19049
|
}
|
|
18698
19050
|
if (opts.print) {
|
|
@@ -18712,8 +19064,8 @@ var screenCommand = new Command55("screen").description("Open a box's VNC (noVNC
|
|
|
18712
19064
|
});
|
|
18713
19065
|
|
|
18714
19066
|
// src/commands/services.ts
|
|
18715
|
-
import { log as
|
|
18716
|
-
import { Command as
|
|
19067
|
+
import { log as log60 } from "@clack/prompts";
|
|
19068
|
+
import { Command as Command57 } from "commander";
|
|
18717
19069
|
async function liveStatus(provider, box) {
|
|
18718
19070
|
const r = await boxServicesStatusRaw(provider, box).catch(() => null);
|
|
18719
19071
|
if (!r || r.exitCode !== 0) return null;
|
|
@@ -18723,7 +19075,7 @@ async function liveStatus(provider, box) {
|
|
|
18723
19075
|
return null;
|
|
18724
19076
|
}
|
|
18725
19077
|
}
|
|
18726
|
-
var listCommand3 = new
|
|
19078
|
+
var listCommand3 = new Command57("list").description("List the box's services with their live state (running / ready / crashed / \u2026)").argument("[box]", "box ref (default: the only box in this project)").option("--json", "print the raw live status (services, tasks, ports) as JSON").action(async (idOrName, opts) => {
|
|
18727
19079
|
try {
|
|
18728
19080
|
const box = await resolveBoxOrExit(idOrName);
|
|
18729
19081
|
const provider = await providerForBox(box);
|
|
@@ -18733,7 +19085,7 @@ var listCommand3 = new Command56("list").description("List the box's services wi
|
|
|
18733
19085
|
process.stdout.write(JSON.stringify({ services: [], tasks: [], ports: [] }) + "\n");
|
|
18734
19086
|
return;
|
|
18735
19087
|
}
|
|
18736
|
-
|
|
19088
|
+
log60.error("could not reach the box supervisor (is the box running?). Try `agentbox status` for the persisted snapshot.");
|
|
18737
19089
|
process.exit(1);
|
|
18738
19090
|
}
|
|
18739
19091
|
if (opts.json) {
|
|
@@ -18749,7 +19101,7 @@ var listCommand3 = new Command56("list").description("List the box's services wi
|
|
|
18749
19101
|
handleLifecycleError(err);
|
|
18750
19102
|
}
|
|
18751
19103
|
});
|
|
18752
|
-
var restartCommand = new
|
|
19104
|
+
var restartCommand = new Command57("restart").description("Restart one service, or every service when no name is given").argument("[box]", "box ref (default: the only box in this project)").argument("[name]", "service to restart (omit to restart all)").action(async (idOrName, name) => {
|
|
18753
19105
|
try {
|
|
18754
19106
|
const { box, shifted } = await resolveBoxOrShift(idOrName);
|
|
18755
19107
|
const serviceName = shifted ? idOrName : name;
|
|
@@ -18762,7 +19114,7 @@ var restartCommand = new Command56("restart").description("Restart one service,
|
|
|
18762
19114
|
}
|
|
18763
19115
|
const live = await liveStatus(provider, box);
|
|
18764
19116
|
if (!live) {
|
|
18765
|
-
|
|
19117
|
+
log60.error("could not reach the box supervisor (is the box running?)");
|
|
18766
19118
|
process.exit(1);
|
|
18767
19119
|
}
|
|
18768
19120
|
const names = live.services.map((s) => s.name);
|
|
@@ -18786,22 +19138,22 @@ var restartCommand = new Command56("restart").description("Restart one service,
|
|
|
18786
19138
|
handleLifecycleError(err);
|
|
18787
19139
|
}
|
|
18788
19140
|
});
|
|
18789
|
-
var servicesCommand = new
|
|
19141
|
+
var servicesCommand = new Command57("services").description("List and restart a box's agentbox.yaml services").addCommand(listCommand3, { isDefault: true }).addCommand(restartCommand);
|
|
18790
19142
|
|
|
18791
19143
|
// src/commands/shell.ts
|
|
18792
19144
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
18793
|
-
import { log as
|
|
18794
|
-
import { Command as
|
|
19145
|
+
import { log as log62, spinner as spinner15 } from "@clack/prompts";
|
|
19146
|
+
import { Command as Command58 } from "commander";
|
|
18795
19147
|
|
|
18796
19148
|
// src/commands/_provider-guard.ts
|
|
18797
|
-
import { log as
|
|
19149
|
+
import { log as log61 } from "@clack/prompts";
|
|
18798
19150
|
function requireDockerProvider(box, commandName) {
|
|
18799
19151
|
const provider = box.provider ?? "docker";
|
|
18800
19152
|
if (provider === "docker") return;
|
|
18801
|
-
|
|
19153
|
+
log61.error(
|
|
18802
19154
|
`\`agentbox ${commandName}\` doesn't yet support cloud boxes (this box's provider is '${provider}').`
|
|
18803
19155
|
);
|
|
18804
|
-
|
|
19156
|
+
log61.info(
|
|
18805
19157
|
"Cloud-provider routing for this command is on the Phase 3 backlog. For now: use `agentbox url` for web access, `agentbox-ctl git push` from inside the sandbox via SSH/web terminal, or fall back to the cloud provider's own console."
|
|
18806
19158
|
);
|
|
18807
19159
|
process.exit(2);
|
|
@@ -18843,10 +19195,10 @@ function fmtAgo2(iso) {
|
|
|
18843
19195
|
async function ensureBoxRunning(box) {
|
|
18844
19196
|
const insp = await inspectBox(box.id);
|
|
18845
19197
|
if (insp.state === "paused") {
|
|
18846
|
-
|
|
19198
|
+
log62.info("box is paused; unpausing");
|
|
18847
19199
|
await unpauseBox(box.id);
|
|
18848
19200
|
} else if (insp.state === "stopped") {
|
|
18849
|
-
|
|
19201
|
+
log62.info("box is stopped; starting");
|
|
18850
19202
|
await startBox(box.id);
|
|
18851
19203
|
} else if (insp.state === "missing") {
|
|
18852
19204
|
throw new Error(`box ${box.name} has no container; was it destroyed?`);
|
|
@@ -18885,7 +19237,7 @@ async function startOrAttachShell(box, cfg) {
|
|
|
18885
19237
|
const label = shellLabel(cfg.sessionName);
|
|
18886
19238
|
const info = await shellSessionInfo(box.container, cfg.sessionName, cfg.user);
|
|
18887
19239
|
if (info.running) {
|
|
18888
|
-
|
|
19240
|
+
log62.info(`reattaching to shell "${label}" \u2014 Control+a d to detach`);
|
|
18889
19241
|
} else {
|
|
18890
19242
|
await startShellSession({
|
|
18891
19243
|
container: box.container,
|
|
@@ -18893,7 +19245,7 @@ async function startOrAttachShell(box, cfg) {
|
|
|
18893
19245
|
user: cfg.user,
|
|
18894
19246
|
login: cfg.login
|
|
18895
19247
|
});
|
|
18896
|
-
|
|
19248
|
+
log62.info(`shell "${label}" \u2014 Control+a d to detach, leaves it running`);
|
|
18897
19249
|
}
|
|
18898
19250
|
const code = await runWrappedAttach({
|
|
18899
19251
|
container: box.container,
|
|
@@ -18917,7 +19269,7 @@ async function runSshConfig(box, opts) {
|
|
|
18917
19269
|
);
|
|
18918
19270
|
}
|
|
18919
19271
|
if (await hasUnmanagedHostConflict(conn.alias)) {
|
|
18920
|
-
|
|
19272
|
+
log62.warn(
|
|
18921
19273
|
`~/.ssh/config already has a non-agentbox \`Host ${conn.alias}\` entry. agentbox's Include is prepended, so SSH applies agentbox's HostName/IdentityFile first and your entry is ignored \u2014 rename the box (or remove your entry) if you meant yours to win.`
|
|
18922
19274
|
);
|
|
18923
19275
|
}
|
|
@@ -18962,7 +19314,7 @@ async function runSshConfig(box, opts) {
|
|
|
18962
19314
|
];
|
|
18963
19315
|
process.stdout.write(lines.join("\n") + "\n");
|
|
18964
19316
|
}
|
|
18965
|
-
var shellCommand = new
|
|
19317
|
+
var shellCommand = new Command58("shell").description(
|
|
18966
19318
|
"Open an interactive shell in a box, in a detachable tmux session (auto-unpause/start)"
|
|
18967
19319
|
).argument(
|
|
18968
19320
|
"[box]",
|
|
@@ -18995,7 +19347,7 @@ var shellCommand = new Command57("shell").description(
|
|
|
18995
19347
|
throw new Error(`cloud sandbox for ${box.name} is missing; was it destroyed?`);
|
|
18996
19348
|
}
|
|
18997
19349
|
if (state !== "running") {
|
|
18998
|
-
const s =
|
|
19350
|
+
const s = spinner15();
|
|
18999
19351
|
s.start(state === "paused" ? "resuming box" : "starting box");
|
|
19000
19352
|
box = await provider.start(box);
|
|
19001
19353
|
s.stop("box running");
|
|
@@ -19075,7 +19427,7 @@ var shellCommand = new Command57("shell").description(
|
|
|
19075
19427
|
handleLifecycleError(err);
|
|
19076
19428
|
}
|
|
19077
19429
|
});
|
|
19078
|
-
var shellAttachCommand = new
|
|
19430
|
+
var shellAttachCommand = new Command58("attach").description(
|
|
19079
19431
|
"Attach to a shell tmux session in a box, starting one if none is running (auto-unpause/start)"
|
|
19080
19432
|
).argument(
|
|
19081
19433
|
"[box]",
|
|
@@ -19113,7 +19465,7 @@ function renderShellTable(sessions) {
|
|
|
19113
19465
|
for (const r of rows) process.stdout.write(`${fmt(r)}
|
|
19114
19466
|
`);
|
|
19115
19467
|
}
|
|
19116
|
-
var shellLsCommand = new
|
|
19468
|
+
var shellLsCommand = new Command58("ls").description("List the shell tmux sessions running in a box").argument(
|
|
19117
19469
|
"[box]",
|
|
19118
19470
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
19119
19471
|
).action(async (idOrName) => {
|
|
@@ -19122,11 +19474,11 @@ var shellLsCommand = new Command57("ls").description("List the shell tmux sessio
|
|
|
19122
19474
|
requireDockerProvider(box, "shell");
|
|
19123
19475
|
const insp = await inspectBox(box.id);
|
|
19124
19476
|
if (insp.state !== "running") {
|
|
19125
|
-
|
|
19477
|
+
log62.info(`box ${box.name} is ${insp.state} \u2014 no live shell sessions`);
|
|
19126
19478
|
return;
|
|
19127
19479
|
}
|
|
19128
19480
|
if (insp.shellSessions.length === 0) {
|
|
19129
|
-
|
|
19481
|
+
log62.info(
|
|
19130
19482
|
`no shell sessions in ${box.name} \u2014 start one with: agentbox shell ${reattachRef2(box)}`
|
|
19131
19483
|
);
|
|
19132
19484
|
return;
|
|
@@ -19136,7 +19488,7 @@ var shellLsCommand = new Command57("ls").description("List the shell tmux sessio
|
|
|
19136
19488
|
handleLifecycleError(err);
|
|
19137
19489
|
}
|
|
19138
19490
|
});
|
|
19139
|
-
var shellKillCommand = new
|
|
19491
|
+
var shellKillCommand = new Command58("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
|
|
19140
19492
|
"[box]",
|
|
19141
19493
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
19142
19494
|
).option("-n, --name <label>", "shell label to kill (default: the box default shell)").option("--all", "kill every shell session in the box").action(async function(idOrName) {
|
|
@@ -19146,25 +19498,25 @@ var shellKillCommand = new Command57("kill").description("Kill a shell tmux sess
|
|
|
19146
19498
|
requireDockerProvider(box, "shell");
|
|
19147
19499
|
const insp = await inspectBox(box.id);
|
|
19148
19500
|
if (insp.state !== "running") {
|
|
19149
|
-
|
|
19501
|
+
log62.info(`box ${box.name} is ${insp.state} \u2014 no shell sessions to kill`);
|
|
19150
19502
|
return;
|
|
19151
19503
|
}
|
|
19152
19504
|
if (opts.all) {
|
|
19153
19505
|
if (insp.shellSessions.length === 0) {
|
|
19154
|
-
|
|
19506
|
+
log62.info(`no shell sessions in ${box.name}`);
|
|
19155
19507
|
return;
|
|
19156
19508
|
}
|
|
19157
19509
|
let killed = 0;
|
|
19158
19510
|
for (const s of insp.shellSessions) {
|
|
19159
19511
|
if (await killShellSession(box.container, s.sessionName)) killed++;
|
|
19160
19512
|
}
|
|
19161
|
-
|
|
19513
|
+
log62.success(`killed ${String(killed)} shell session${killed === 1 ? "" : "s"} in ${box.name}`);
|
|
19162
19514
|
return;
|
|
19163
19515
|
}
|
|
19164
19516
|
const target = shellSessionName(opts.name);
|
|
19165
19517
|
const ok = await killShellSession(box.container, target);
|
|
19166
|
-
if (ok)
|
|
19167
|
-
else
|
|
19518
|
+
if (ok) log62.success(`killed shell "${shellLabel(target)}" in ${box.name}`);
|
|
19519
|
+
else log62.warn(`no shell "${shellLabel(target)}" in ${box.name} (already gone?)`);
|
|
19168
19520
|
} catch (err) {
|
|
19169
19521
|
handleLifecycleError(err);
|
|
19170
19522
|
}
|
|
@@ -19174,8 +19526,8 @@ shellCommand.addCommand(shellLsCommand);
|
|
|
19174
19526
|
shellCommand.addCommand(shellKillCommand);
|
|
19175
19527
|
|
|
19176
19528
|
// src/commands/start.ts
|
|
19177
|
-
import { Command as
|
|
19178
|
-
var startCommand = new
|
|
19529
|
+
import { Command as Command59 } from "commander";
|
|
19530
|
+
var startCommand = new Command59("start").description(
|
|
19179
19531
|
"Start a stopped box. Docker: docker start + relaunch ctl/dockerd/vnc daemons. Cloud: backend.start, then re-resolve preview URLs/tokens, re-launch in-sandbox ctl/dockerd daemons, and re-register with the host relay (so the CloudBoxPoller resumes)."
|
|
19180
19532
|
).argument(
|
|
19181
19533
|
"[box]",
|
|
@@ -19215,8 +19567,8 @@ var startCommand = new Command58("start").description(
|
|
|
19215
19567
|
});
|
|
19216
19568
|
|
|
19217
19569
|
// src/commands/status.ts
|
|
19218
|
-
import { log as
|
|
19219
|
-
import { Command as
|
|
19570
|
+
import { log as log64 } from "@clack/prompts";
|
|
19571
|
+
import { Command as Command60 } from "commander";
|
|
19220
19572
|
|
|
19221
19573
|
// src/endpoints-render.ts
|
|
19222
19574
|
function renderEndpointLines(endpoints, stream) {
|
|
@@ -19289,9 +19641,9 @@ function renderPersistedSections(s) {
|
|
|
19289
19641
|
if (s.ports.length === 0) {
|
|
19290
19642
|
out.push(" (none listening)");
|
|
19291
19643
|
} else {
|
|
19292
|
-
const other = s.ports.filter((
|
|
19644
|
+
const other = s.ports.filter((p2) => !p2.service).map((p2) => p2.port).sort((a, b) => a - b);
|
|
19293
19645
|
out.push(
|
|
19294
|
-
...s.ports.filter((
|
|
19646
|
+
...s.ports.filter((p2) => p2.service).map((p2) => ` :${String(p2.port)} (${p2.service})`)
|
|
19295
19647
|
);
|
|
19296
19648
|
if (other.length > 0) out.push(` other (${other.length}): ${other.join(", ")}`);
|
|
19297
19649
|
}
|
|
@@ -19299,7 +19651,7 @@ function renderPersistedSections(s) {
|
|
|
19299
19651
|
}
|
|
19300
19652
|
|
|
19301
19653
|
// src/commands/inspect.ts
|
|
19302
|
-
import { log as
|
|
19654
|
+
import { log as log63 } from "@clack/prompts";
|
|
19303
19655
|
function fmtLimit(n, unit) {
|
|
19304
19656
|
return n && n > 0 ? `${String(n)}${unit}` : "unlimited";
|
|
19305
19657
|
}
|
|
@@ -19458,7 +19810,7 @@ function renderCodexActivityCloud(persisted) {
|
|
|
19458
19810
|
async function runInspect(box, opts) {
|
|
19459
19811
|
try {
|
|
19460
19812
|
if (opts.json && opts.watch) {
|
|
19461
|
-
|
|
19813
|
+
log63.error("cannot combine --json with --watch");
|
|
19462
19814
|
process.exit(2);
|
|
19463
19815
|
}
|
|
19464
19816
|
const isCloud = (box.provider ?? "docker") !== "docker";
|
|
@@ -19496,7 +19848,7 @@ async function runInspect(box, opts) {
|
|
|
19496
19848
|
// src/commands/status.ts
|
|
19497
19849
|
var MAX_DISPLAY_NAME = 60;
|
|
19498
19850
|
var statusCommand2 = withWatchOptions(
|
|
19499
|
-
new
|
|
19851
|
+
new Command60("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
|
|
19500
19852
|
"[box]",
|
|
19501
19853
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
19502
19854
|
).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status").option(
|
|
@@ -19506,17 +19858,17 @@ var statusCommand2 = withWatchOptions(
|
|
|
19506
19858
|
).action(async (idOrName, opts) => {
|
|
19507
19859
|
try {
|
|
19508
19860
|
if (opts.json && opts.watch) {
|
|
19509
|
-
|
|
19861
|
+
log64.error("cannot combine --json with --watch");
|
|
19510
19862
|
process.exit(2);
|
|
19511
19863
|
}
|
|
19512
19864
|
if (opts.setName !== void 0 && opts.clearName) {
|
|
19513
|
-
|
|
19865
|
+
log64.error("cannot combine --set-name with --clear-name");
|
|
19514
19866
|
process.exit(2);
|
|
19515
19867
|
}
|
|
19516
19868
|
const box = await resolveBoxOrExit(idOrName);
|
|
19517
19869
|
if (opts.setName !== void 0 || opts.clearName) {
|
|
19518
19870
|
if (opts.json || opts.watch) {
|
|
19519
|
-
|
|
19871
|
+
log64.error("cannot combine --set-name/--clear-name with --json or --watch");
|
|
19520
19872
|
process.exit(2);
|
|
19521
19873
|
}
|
|
19522
19874
|
const before = boxLabel(box);
|
|
@@ -19526,11 +19878,11 @@ var statusCommand2 = withWatchOptions(
|
|
|
19526
19878
|
} else {
|
|
19527
19879
|
next = [...opts.setName].filter((c) => c >= " " && c.charCodeAt(0) !== 127).join("").trim();
|
|
19528
19880
|
if (!next) {
|
|
19529
|
-
|
|
19881
|
+
log64.error("--set-name requires a non-empty name (use --clear-name to reset)");
|
|
19530
19882
|
process.exit(2);
|
|
19531
19883
|
}
|
|
19532
19884
|
if (next.length > MAX_DISPLAY_NAME) {
|
|
19533
|
-
|
|
19885
|
+
log64.error(`name too long (max ${String(MAX_DISPLAY_NAME)} chars)`);
|
|
19534
19886
|
process.exit(2);
|
|
19535
19887
|
}
|
|
19536
19888
|
}
|
|
@@ -19664,8 +20016,8 @@ function renderPersisted2(s, state) {
|
|
|
19664
20016
|
}
|
|
19665
20017
|
|
|
19666
20018
|
// src/commands/stop.ts
|
|
19667
|
-
import { Command as
|
|
19668
|
-
var stopCommand = new
|
|
20019
|
+
import { Command as Command61 } from "commander";
|
|
20020
|
+
var stopCommand = new Command61("stop").description(
|
|
19669
20021
|
"Stop a box (Docker: docker stop; preserves upper + node_modules volumes. Cloud: backend.stop \u2014 sandbox stays in your account, disk preserved)."
|
|
19670
20022
|
).argument(
|
|
19671
20023
|
"[box]",
|
|
@@ -19694,7 +20046,7 @@ restart with: agentbox start ${box.name}
|
|
|
19694
20046
|
});
|
|
19695
20047
|
|
|
19696
20048
|
// src/commands/top.ts
|
|
19697
|
-
import { Command as
|
|
20049
|
+
import { Command as Command62 } from "commander";
|
|
19698
20050
|
var COLS = ["BOX", "STATE", "CPU%", "MEM USAGE / LIMIT", "MEM%", "PIDS", "DISK", "NET I/O"];
|
|
19699
20051
|
function row(name, state, s) {
|
|
19700
20052
|
const mem = `${fmtBytes2(s.memUsedBytes)} / ${fmtBytes2(s.memLimitBytes)}`;
|
|
@@ -19768,7 +20120,7 @@ async function renderProjectFooters() {
|
|
|
19768
20120
|
|
|
19769
20121
|
SYSTEM: ${parts.join(" - ")}` : "";
|
|
19770
20122
|
}
|
|
19771
|
-
var topCommand = new
|
|
20123
|
+
var topCommand = new Command62("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
|
|
19772
20124
|
"[box]",
|
|
19773
20125
|
"box ref (default: every box on the host; --project narrows to the cwd's project)"
|
|
19774
20126
|
).option("-p, --project", "show only boxes in the cwd's project").option("--once", "print a single snapshot instead of watching").option("-j, --json", "machine-readable JSON (implies --once)").option("--interval <seconds>", "refresh interval", "2").option("--live", "probe live cloud state via the provider SDK (slower; default: last host-known)").action(async (idOrName, opts) => {
|
|
@@ -19801,8 +20153,8 @@ var topCommand = new Command61("top").description("Live resource monitor (cpu/me
|
|
|
19801
20153
|
});
|
|
19802
20154
|
|
|
19803
20155
|
// src/commands/unpause.ts
|
|
19804
|
-
import { Command as
|
|
19805
|
-
var unpauseCommand = new
|
|
20156
|
+
import { Command as Command63 } from "commander";
|
|
20157
|
+
var unpauseCommand = new Command63("unpause").description(
|
|
19806
20158
|
"Resume a paused box. Docker: `docker unpause` (sub-second). Cloud: backend.resume (re-hydrates from archive \u2014 slower first time)."
|
|
19807
20159
|
).argument(
|
|
19808
20160
|
"[box]",
|
|
@@ -19839,7 +20191,7 @@ var unpauseCommand = new Command62("unpause").description(
|
|
|
19839
20191
|
|
|
19840
20192
|
// src/commands/update.ts
|
|
19841
20193
|
import { spawn as spawn11 } from "child_process";
|
|
19842
|
-
import { Command as
|
|
20194
|
+
import { Command as Command64 } from "commander";
|
|
19843
20195
|
var PKG2 = "@madarco/agentbox";
|
|
19844
20196
|
function selfUpdateCommand(method) {
|
|
19845
20197
|
if (method === "npm") return { cmd: "npm", args: ["install", "-g", `${PKG2}@latest`] };
|
|
@@ -19880,7 +20232,7 @@ async function reportLatest() {
|
|
|
19880
20232
|
} catch {
|
|
19881
20233
|
}
|
|
19882
20234
|
}
|
|
19883
|
-
var updateCommand = new
|
|
20235
|
+
var updateCommand = new Command64("self-update").description(
|
|
19884
20236
|
"Update agentbox: self-update via npm/pnpm (unless run via npx), refresh the host skills, re-check the box image (rebuilt on the next create only if its build context changed), reload the relay/hub, and update the menu-bar app"
|
|
19885
20237
|
).option("-y, --yes", "skip the confirmation prompt").option("--dry-run", "show what would happen, don't change anything").option("--skip-self", "skip the package self-update; only refresh the skills + image + relay + app").option("--skip-skills", "skip refreshing the host skill files in ~/.claude, ~/.codex, ~/.config/opencode").action(async (opts) => {
|
|
19886
20238
|
try {
|
|
@@ -19950,8 +20302,8 @@ var updateCommand = new Command63("self-update").description(
|
|
|
19950
20302
|
|
|
19951
20303
|
// src/commands/url.ts
|
|
19952
20304
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
19953
|
-
import { log as
|
|
19954
|
-
import { Command as
|
|
20305
|
+
import { log as log66 } from "@clack/prompts";
|
|
20306
|
+
import { Command as Command65 } from "commander";
|
|
19955
20307
|
var SIGNED_URL_TTL_MIN2 = 1;
|
|
19956
20308
|
var SIGNED_URL_TTL_MAX2 = 86400;
|
|
19957
20309
|
function parseTtlOrExit2(raw) {
|
|
@@ -19964,7 +20316,7 @@ function parseTtlOrExit2(raw) {
|
|
|
19964
20316
|
}
|
|
19965
20317
|
return n;
|
|
19966
20318
|
}
|
|
19967
|
-
var urlCommand = new
|
|
20319
|
+
var urlCommand = new Command65("url").description(
|
|
19968
20320
|
"Open a box's web app URL in the browser, even when no service declares `expose:` (auto-unpause/start)"
|
|
19969
20321
|
).argument(
|
|
19970
20322
|
"[box]",
|
|
@@ -19983,10 +20335,10 @@ var urlCommand = new Command64("url").description(
|
|
|
19983
20335
|
if (provider === "docker") {
|
|
19984
20336
|
const insp = await inspectBox(box.id);
|
|
19985
20337
|
if (insp.state === "paused") {
|
|
19986
|
-
|
|
20338
|
+
log66.info("box is paused; unpausing");
|
|
19987
20339
|
await unpauseBox(box.id);
|
|
19988
20340
|
} else if (insp.state === "stopped") {
|
|
19989
|
-
|
|
20341
|
+
log66.info("box is stopped; starting");
|
|
19990
20342
|
await startBox(box.id);
|
|
19991
20343
|
} else if (insp.state === "missing") {
|
|
19992
20344
|
throw new Error(`box ${box.name} has no container; was it destroyed?`);
|
|
@@ -20012,18 +20364,18 @@ var urlCommand = new Command64("url").description(
|
|
|
20012
20364
|
}
|
|
20013
20365
|
} else {
|
|
20014
20366
|
const ttl = parseTtlOrExit2(opts.ttl);
|
|
20015
|
-
const
|
|
20016
|
-
const state = await
|
|
20367
|
+
const p2 = await providerForBox(box);
|
|
20368
|
+
const state = await p2.probeState(box);
|
|
20017
20369
|
if (state === "paused") {
|
|
20018
|
-
|
|
20019
|
-
await
|
|
20370
|
+
log66.info("box is paused; resuming");
|
|
20371
|
+
await p2.resume(box);
|
|
20020
20372
|
} else if (state === "stopped") {
|
|
20021
|
-
|
|
20022
|
-
await
|
|
20373
|
+
log66.info("box is stopped; starting");
|
|
20374
|
+
await p2.start(box);
|
|
20023
20375
|
} else if (state === "missing") {
|
|
20024
20376
|
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
20025
20377
|
}
|
|
20026
|
-
url = await
|
|
20378
|
+
url = await p2.resolveUrl(box, { kind: "web", ttl });
|
|
20027
20379
|
}
|
|
20028
20380
|
if (opts.print) {
|
|
20029
20381
|
process.stdout.write(`${url}
|
|
@@ -20042,9 +20394,9 @@ var urlCommand = new Command64("url").description(
|
|
|
20042
20394
|
});
|
|
20043
20395
|
|
|
20044
20396
|
// src/commands/wait.ts
|
|
20045
|
-
import { log as
|
|
20046
|
-
import { Command as
|
|
20047
|
-
var waitCommand = new
|
|
20397
|
+
import { log as log67 } from "@clack/prompts";
|
|
20398
|
+
import { Command as Command66 } from "commander";
|
|
20399
|
+
var waitCommand = new Command66("wait").description("Block until the box reports all autostart units ready").argument(
|
|
20048
20400
|
"[box]",
|
|
20049
20401
|
"box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
|
|
20050
20402
|
).option("--timeout <ms>", "overall timeout in milliseconds", "120000").option("--units <names...>", "restrict to the named units").option("-j, --json", "machine-readable JSON output").action(async (idOrName, opts) => {
|
|
@@ -20060,7 +20412,7 @@ var waitCommand = new Command65("wait").description("Block until the box reports
|
|
|
20060
20412
|
try {
|
|
20061
20413
|
parsed = JSON.parse(proc.stdout);
|
|
20062
20414
|
} catch {
|
|
20063
|
-
|
|
20415
|
+
log67.error(`agentbox-ctl wait-ready failed: ${proc.stderr || proc.stdout}`);
|
|
20064
20416
|
process.exit(1);
|
|
20065
20417
|
}
|
|
20066
20418
|
if (opts.json) {
|
|
@@ -20095,6 +20447,17 @@ function rewriteProviderPrefix(argv2) {
|
|
|
20095
20447
|
return [...head, subcmd, "--provider", provider, ...rest];
|
|
20096
20448
|
}
|
|
20097
20449
|
|
|
20450
|
+
// src/lib/config-warnings.ts
|
|
20451
|
+
import { log as log68 } from "@clack/prompts";
|
|
20452
|
+
var seen = /* @__PURE__ */ new Set();
|
|
20453
|
+
function installConfigWarningSink() {
|
|
20454
|
+
setConfigWarningSink((message) => {
|
|
20455
|
+
if (seen.has(message)) return;
|
|
20456
|
+
seen.add(message);
|
|
20457
|
+
log68.warn(message);
|
|
20458
|
+
});
|
|
20459
|
+
}
|
|
20460
|
+
|
|
20098
20461
|
// src/index.ts
|
|
20099
20462
|
process.env.DOCKER_CLI_HINTS ??= "false";
|
|
20100
20463
|
process.env.AGENTBOX_CLI_VERSION = AGENTBOX_VERSION;
|
|
@@ -20111,7 +20474,8 @@ process.env.AGENTBOX_CLI_COMMIT = AGENTBOX_COMMIT;
|
|
|
20111
20474
|
}
|
|
20112
20475
|
}
|
|
20113
20476
|
}
|
|
20114
|
-
|
|
20477
|
+
installConfigWarningSink();
|
|
20478
|
+
var program = new Command67();
|
|
20115
20479
|
program.name("agentbox").description("Launch coding agents in isolated sandboxes").version(AGENTBOX_VERSION);
|
|
20116
20480
|
program.enablePositionalOptions();
|
|
20117
20481
|
program.addCommand(createCommand);
|
|
@@ -20164,6 +20528,7 @@ program.addCommand(hetznerCommand);
|
|
|
20164
20528
|
program.addCommand(vercelCommand);
|
|
20165
20529
|
program.addCommand(e2bCommand);
|
|
20166
20530
|
program.addCommand(digitaloceanCommand);
|
|
20531
|
+
program.addCommand(remoteDockerCommand);
|
|
20167
20532
|
program.addCommand(dockerCommand);
|
|
20168
20533
|
program.addCommand(updateCommand);
|
|
20169
20534
|
program.addCommand(installCommand);
|
|
@@ -20171,7 +20536,21 @@ program.addCommand(appCommand);
|
|
|
20171
20536
|
program.addCommand(pluginCommand);
|
|
20172
20537
|
program.addCommand(doctorCommand);
|
|
20173
20538
|
program.configureHelp({ visibleCommands: () => [] });
|
|
20174
|
-
program.addHelpText("after", () => "\n" +
|
|
20539
|
+
program.addHelpText("after", () => "\n" + buildCompactHelp(program));
|
|
20540
|
+
program.helpCommand(false);
|
|
20541
|
+
program.addCommand(
|
|
20542
|
+
new Command67("help").description("List every command, grouped; `help <command>` for one command").argument("[command]", "command to show help for").action((name) => {
|
|
20543
|
+
if (name) {
|
|
20544
|
+
const sub = program.commands.find(
|
|
20545
|
+
(c) => c.name() === name || c.aliases().includes(name)
|
|
20546
|
+
);
|
|
20547
|
+
if (!sub) program.error(`unknown command '${name}'`);
|
|
20548
|
+
sub.help();
|
|
20549
|
+
}
|
|
20550
|
+
process.stdout.write(program.helpInformation() + "\n" + buildGroupedHelp(program) + "\n");
|
|
20551
|
+
}),
|
|
20552
|
+
{ hidden: true }
|
|
20553
|
+
);
|
|
20175
20554
|
await applyEngineOverrideAtStartup();
|
|
20176
20555
|
var argv = rewriteProviderPrefix(process.argv);
|
|
20177
20556
|
var FIRST_RUN_EXEMPT = /* @__PURE__ */ new Set([
|