@madarco/agentbox 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_cloud-attach-ZXBCNWJX.js +13 -0
- package/dist/{chunk-NW5NYTQM.js → chunk-BXQMIEHC.js} +459 -110
- package/dist/chunk-BXQMIEHC.js.map +1 -0
- package/dist/{chunk-UK72UQ5U.js → chunk-G3H2L3O2.js} +55 -4
- package/dist/chunk-G3H2L3O2.js.map +1 -0
- package/dist/{chunk-7KOEFGN2.js → chunk-GU5LW4B5.js} +385 -31
- package/dist/chunk-GU5LW4B5.js.map +1 -0
- package/dist/chunk-KL36BRN4.js +455 -0
- package/dist/chunk-KL36BRN4.js.map +1 -0
- package/dist/{chunk-V5KZGB5V.js → chunk-LEV3KICD.js} +18 -2
- package/dist/chunk-LEV3KICD.js.map +1 -0
- package/dist/chunk-MTVI44DW.js +662 -0
- package/dist/chunk-MTVI44DW.js.map +1 -0
- package/dist/{chunk-NAVL4R34.js → chunk-NCJP5MTN.js} +1281 -556
- package/dist/chunk-NCJP5MTN.js.map +1 -0
- package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js → cloud-poller-SUNA6ZQC-2RG5WPRN.js} +2 -2
- package/dist/{dist-ETCFRVPA.js → dist-32EZBYG4.js} +50 -20
- package/dist/{dist-R67WMLCF.js → dist-CX5CGVEB.js} +120 -10
- package/dist/dist-CX5CGVEB.js.map +1 -0
- package/dist/{dist-QZGJIBT5.js → dist-GDHP34ZK.js} +141 -75
- package/dist/dist-GDHP34ZK.js.map +1 -0
- package/dist/dist-XML54CNB.js +849 -0
- package/dist/dist-XML54CNB.js.map +1 -0
- package/dist/index.js +3881 -867
- package/dist/index.js.map +1 -1
- package/dist/prepared-state-CL4CWXQA-H5THETIM.js +18 -0
- package/dist/prepared-state-CL4CWXQA-H5THETIM.js.map +1 -0
- package/package.json +7 -5
- package/runtime/daytona/custom-system-CLAUDE.md +39 -0
- package/runtime/docker/Dockerfile.box +22 -0
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
- package/runtime/docker/packages/ctl/dist/bin.cjs +1214 -98
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +66 -35
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +15 -1
- package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +62 -1
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +15 -4
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +263 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +131 -0
- package/runtime/docker/packages/sandbox-docker/scripts/opencode-agentbox-plugin.js +76 -0
- package/runtime/hetzner/agentbox-codex-hooks.json +66 -35
- package/runtime/hetzner/agentbox-setup-skill.md +1 -1
- package/runtime/hetzner/agentbox-vnc-start +15 -1
- package/runtime/hetzner/claude-managed-settings.json +62 -1
- package/runtime/hetzner/ctl.cjs +1214 -98
- package/runtime/hetzner/custom-system-CLAUDE.md +26 -14
- package/runtime/hetzner/gh-shim +263 -0
- package/runtime/hetzner/git-shim +131 -0
- package/runtime/hetzner/opencode-agentbox-plugin.js +76 -0
- package/runtime/hetzner/scripts/install-box.sh +11 -2
- package/runtime/relay/bin.cjs +1146 -63
- package/runtime/vercel/agentbox-checkpoint-cleanup +52 -0
- package/runtime/vercel/agentbox-codex-hooks.json +68 -0
- package/runtime/vercel/agentbox-open +28 -0
- package/runtime/vercel/agentbox-setup-skill.md +196 -0
- package/runtime/vercel/agentbox-vnc-start +91 -0
- package/runtime/vercel/claude-managed-settings.json +115 -0
- package/runtime/vercel/ctl.cjs +23466 -0
- package/runtime/vercel/custom-system-CLAUDE.md +50 -0
- package/runtime/vercel/gh-shim +263 -0
- package/runtime/vercel/git-shim +131 -0
- package/runtime/vercel/scripts/provision.sh +274 -0
- package/share/agentbox-setup/SKILL.md +1 -1
- package/share/host-skills/agentbox/SKILL.md +29 -0
- package/share/host-skills/agentbox-info/SKILL.md +211 -0
- package/share/host-skills/codex/agentbox.md +35 -0
- package/share/host-skills/opencode/agentbox.md +26 -0
- package/dist/_cloud-attach-DMVH6GWO.js +0 -12
- package/dist/chunk-7KOEFGN2.js.map +0 -1
- package/dist/chunk-NAVL4R34.js.map +0 -1
- package/dist/chunk-NW5NYTQM.js.map +0 -1
- package/dist/chunk-UK72UQ5U.js.map +0 -1
- package/dist/chunk-V5KZGB5V.js.map +0 -1
- package/dist/dist-QZGJIBT5.js.map +0 -1
- package/dist/dist-R67WMLCF.js.map +0 -1
- /package/dist/{_cloud-attach-DMVH6GWO.js.map → _cloud-attach-ZXBCNWJX.js.map} +0 -0
- /package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js.map → cloud-poller-SUNA6ZQC-2RG5WPRN.js.map} +0 -0
- /package/dist/{dist-ETCFRVPA.js.map → dist-32EZBYG4.js.map} +0 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CloudBoxPoller,
|
|
4
4
|
CloudBoxPollers
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-G3H2L3O2.js";
|
|
6
6
|
export {
|
|
7
7
|
CloudBoxPoller,
|
|
8
8
|
CloudBoxPollers
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=cloud-poller-
|
|
10
|
+
//# sourceMappingURL=cloud-poller-SUNA6ZQC-2RG5WPRN.js.map
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CHECKPOINTS_ROOT,
|
|
7
7
|
CHECKPOINT_IMAGE_PREFIX,
|
|
8
8
|
CLAUDE_FORWARDED_ENV_KEYS,
|
|
9
|
+
CODEX_CREDENTIALS_BACKUP_FILE,
|
|
9
10
|
CODEX_FORWARDED_ENV_KEYS,
|
|
10
11
|
CONTAINER_EXPORT_MERGED,
|
|
11
12
|
CONTAINER_USER,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
CheckpointError,
|
|
14
15
|
ClaudeSessionError,
|
|
15
16
|
CodexSessionError,
|
|
16
|
-
DEFAULT_BOX_IMAGE,
|
|
17
17
|
DEFAULT_CLAUDE_SESSION,
|
|
18
18
|
DEFAULT_CODEX_SESSION,
|
|
19
19
|
DEFAULT_ENV_PATTERNS,
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
DEFAULT_SHELL_SESSION,
|
|
23
23
|
EXCLUDE_DIRS,
|
|
24
24
|
ExportError,
|
|
25
|
-
GitWorktreeError,
|
|
26
25
|
IDE_FLAVORS,
|
|
26
|
+
OPENCODE_CREDENTIALS_BACKUP_FILE,
|
|
27
27
|
OPENCODE_FORWARDED_ENV_KEYS,
|
|
28
28
|
OpencodeSessionError,
|
|
29
29
|
PORTLESS_PROXY_PORT,
|
|
@@ -38,17 +38,13 @@ import {
|
|
|
38
38
|
SHARED_VSCODE_EXTENSIONS_VOLUME,
|
|
39
39
|
SHELL_SESSION_PREFIX,
|
|
40
40
|
SNAPSHOTS_ROOT,
|
|
41
|
-
STATE_DIR,
|
|
42
|
-
STATE_FILE,
|
|
43
41
|
VNC_CONTAINER_PORT,
|
|
44
42
|
WORKTREE_ROOT,
|
|
45
43
|
agentboxHomeBytes,
|
|
46
44
|
allCheckpointImagesBytes,
|
|
47
|
-
allocateProjectIndex,
|
|
48
45
|
allocateShellSessionName,
|
|
49
46
|
attachClaudeSession,
|
|
50
47
|
attachedContainerUri,
|
|
51
|
-
autoPickProjectBox,
|
|
52
48
|
bindWorktrees,
|
|
53
49
|
boxResourceStats,
|
|
54
50
|
boxRunDirFor,
|
|
@@ -69,6 +65,7 @@ import {
|
|
|
69
65
|
buildOpencodeMounts,
|
|
70
66
|
buildShellArgv,
|
|
71
67
|
buildShellSessionAttachArgv,
|
|
68
|
+
buildTmuxConfigShellSnippet,
|
|
72
69
|
buildTmuxSessionArgs,
|
|
73
70
|
buildVncUrls,
|
|
74
71
|
buildVscodeMounts,
|
|
@@ -85,23 +82,21 @@ import {
|
|
|
85
82
|
cursorServerVolumeName,
|
|
86
83
|
destroyBox,
|
|
87
84
|
detectEngine,
|
|
88
|
-
detectGitRepos,
|
|
89
85
|
detectPortless,
|
|
90
86
|
dockerProvider,
|
|
91
87
|
dockerVolumeName,
|
|
88
|
+
downloadFromBox,
|
|
92
89
|
ensureAgentboxTasksFile,
|
|
93
90
|
ensureBoxBrowser,
|
|
94
91
|
ensureClaudeVolume,
|
|
95
92
|
ensureCodexInstalled,
|
|
96
93
|
ensureCodexVolume,
|
|
97
94
|
ensureIdeVolumes,
|
|
98
|
-
ensureImage,
|
|
99
95
|
ensureOpencodeInstalled,
|
|
100
96
|
ensureOpencodeVolume,
|
|
101
97
|
ensureRelay,
|
|
102
98
|
ensureVscodeVolumes,
|
|
103
99
|
execInBox,
|
|
104
|
-
findBox,
|
|
105
100
|
forgetBoxFromRelay,
|
|
106
101
|
formatDetachNotice,
|
|
107
102
|
generateRelayToken,
|
|
@@ -115,10 +110,9 @@ import {
|
|
|
115
110
|
hostBackupHasCredentials,
|
|
116
111
|
ideProfile,
|
|
117
112
|
ideServerVolumeName,
|
|
118
|
-
imageExists,
|
|
119
|
-
imageInfo,
|
|
120
113
|
inspectBox,
|
|
121
114
|
installPortless,
|
|
115
|
+
isRealAgentCredential,
|
|
122
116
|
isShellSessionName,
|
|
123
117
|
killShellSession,
|
|
124
118
|
launchDockerdDaemon,
|
|
@@ -127,6 +121,7 @@ import {
|
|
|
127
121
|
listBoxes,
|
|
128
122
|
listCheckpoints,
|
|
129
123
|
listShellSessions,
|
|
124
|
+
mintHostInitiatedToken,
|
|
130
125
|
openBoxInFinder,
|
|
131
126
|
openInFinder,
|
|
132
127
|
opencodeSessionInfo,
|
|
@@ -135,7 +130,6 @@ import {
|
|
|
135
130
|
parseShellSessionList,
|
|
136
131
|
parseSyncResult,
|
|
137
132
|
pauseBox,
|
|
138
|
-
pickFreshBranch,
|
|
139
133
|
portlessAlias,
|
|
140
134
|
portlessBrowserEnv,
|
|
141
135
|
portlessGetUrl,
|
|
@@ -150,20 +144,16 @@ import {
|
|
|
150
144
|
pullOpencodeConfig,
|
|
151
145
|
pullToHost,
|
|
152
146
|
readBoxStatus,
|
|
153
|
-
readState,
|
|
154
147
|
rebuildPluginNativeDeps,
|
|
155
|
-
recordBox,
|
|
156
148
|
refreshExport,
|
|
157
149
|
registerBoxWithRelay,
|
|
158
150
|
rehydrateRelayRegistry,
|
|
159
|
-
removeBoxRecord,
|
|
160
151
|
removeCheckpoint,
|
|
161
152
|
removeImage,
|
|
162
153
|
removeInBoxWorktree,
|
|
163
154
|
repairIdeOwnership,
|
|
164
155
|
repairVscodeServerOwnership,
|
|
165
156
|
resetPortlessCache,
|
|
166
|
-
resolveBoxRef,
|
|
167
157
|
resolveCheckpoint,
|
|
168
158
|
resolveClaudeVolume,
|
|
169
159
|
resolveCodexVolume,
|
|
@@ -175,6 +165,7 @@ import {
|
|
|
175
165
|
scanHostEnvFiles,
|
|
176
166
|
scanPluginCacheForRebuild,
|
|
177
167
|
seedCodexHooks,
|
|
168
|
+
seedOpencodePlugin,
|
|
178
169
|
seedSetupSkillIntoVolume,
|
|
179
170
|
seedWorkspace,
|
|
180
171
|
seedWorkspaceFromDir,
|
|
@@ -190,6 +181,7 @@ import {
|
|
|
190
181
|
stageCodexCredentialsForUpload,
|
|
191
182
|
stageCodexStaticForUpload,
|
|
192
183
|
stageOpencodeCredentialsForUpload,
|
|
184
|
+
stageOpencodeStateForUpload,
|
|
193
185
|
stageOpencodeStaticForUpload,
|
|
194
186
|
startBox,
|
|
195
187
|
startClaudeSession,
|
|
@@ -201,6 +193,7 @@ import {
|
|
|
201
193
|
stopRelay,
|
|
202
194
|
syncClaudeCredentials,
|
|
203
195
|
unpauseBox,
|
|
196
|
+
uploadToBox,
|
|
204
197
|
volumeExists,
|
|
205
198
|
volumeHasCodexAuth,
|
|
206
199
|
volumeHasOpencodeAuth,
|
|
@@ -208,8 +201,31 @@ import {
|
|
|
208
201
|
vscodeServerVolumeName,
|
|
209
202
|
waitForTmuxPaneContent,
|
|
210
203
|
warmUpClaudeCredentials
|
|
211
|
-
} from "./chunk-
|
|
212
|
-
import
|
|
204
|
+
} from "./chunk-NCJP5MTN.js";
|
|
205
|
+
import {
|
|
206
|
+
DEFAULT_BOX_IMAGE,
|
|
207
|
+
GitWorktreeError,
|
|
208
|
+
STATE_DIR,
|
|
209
|
+
STATE_FILE,
|
|
210
|
+
allocateProjectIndex,
|
|
211
|
+
autoPickProjectBox,
|
|
212
|
+
computeDockerContextFingerprint,
|
|
213
|
+
detectGitRepos,
|
|
214
|
+
ensureImage,
|
|
215
|
+
findBox,
|
|
216
|
+
imageExists,
|
|
217
|
+
imageInfo,
|
|
218
|
+
pickFreshBranch,
|
|
219
|
+
preparedMatches,
|
|
220
|
+
readPreparedDockerState,
|
|
221
|
+
readState,
|
|
222
|
+
recordBox,
|
|
223
|
+
removeBoxRecord,
|
|
224
|
+
resolveBoxRef,
|
|
225
|
+
resolveContextFiles,
|
|
226
|
+
writePreparedDockerState
|
|
227
|
+
} from "./chunk-KL36BRN4.js";
|
|
228
|
+
import "./chunk-G3H2L3O2.js";
|
|
213
229
|
export {
|
|
214
230
|
AmbiguousBoxError,
|
|
215
231
|
BOXES_ROOT,
|
|
@@ -217,6 +233,7 @@ export {
|
|
|
217
233
|
CHECKPOINTS_ROOT,
|
|
218
234
|
CHECKPOINT_IMAGE_PREFIX,
|
|
219
235
|
CLAUDE_FORWARDED_ENV_KEYS,
|
|
236
|
+
CODEX_CREDENTIALS_BACKUP_FILE,
|
|
220
237
|
CODEX_FORWARDED_ENV_KEYS,
|
|
221
238
|
CONTAINER_EXPORT_MERGED,
|
|
222
239
|
CONTAINER_USER,
|
|
@@ -235,6 +252,7 @@ export {
|
|
|
235
252
|
ExportError,
|
|
236
253
|
GitWorktreeError,
|
|
237
254
|
IDE_FLAVORS,
|
|
255
|
+
OPENCODE_CREDENTIALS_BACKUP_FILE,
|
|
238
256
|
OPENCODE_FORWARDED_ENV_KEYS,
|
|
239
257
|
OpencodeSessionError,
|
|
240
258
|
PORTLESS_PROXY_PORT,
|
|
@@ -280,6 +298,7 @@ export {
|
|
|
280
298
|
buildOpencodeMounts,
|
|
281
299
|
buildShellArgv,
|
|
282
300
|
buildShellSessionAttachArgv,
|
|
301
|
+
buildTmuxConfigShellSnippet,
|
|
283
302
|
buildTmuxSessionArgs,
|
|
284
303
|
buildVncUrls,
|
|
285
304
|
buildVscodeMounts,
|
|
@@ -288,6 +307,7 @@ export {
|
|
|
288
307
|
clearRelayNotice,
|
|
289
308
|
codexSessionInfo,
|
|
290
309
|
collectRepoCarryOver,
|
|
310
|
+
computeDockerContextFingerprint,
|
|
291
311
|
computeNextCheckpointName,
|
|
292
312
|
copyHostEnvFilesToBox,
|
|
293
313
|
copyHostFilesToBox,
|
|
@@ -300,6 +320,7 @@ export {
|
|
|
300
320
|
detectPortless,
|
|
301
321
|
dockerProvider,
|
|
302
322
|
dockerVolumeName,
|
|
323
|
+
downloadFromBox,
|
|
303
324
|
ensureAgentboxTasksFile,
|
|
304
325
|
ensureBoxBrowser,
|
|
305
326
|
ensureClaudeVolume,
|
|
@@ -330,6 +351,7 @@ export {
|
|
|
330
351
|
imageInfo,
|
|
331
352
|
inspectBox,
|
|
332
353
|
installPortless,
|
|
354
|
+
isRealAgentCredential,
|
|
333
355
|
isShellSessionName,
|
|
334
356
|
killShellSession,
|
|
335
357
|
launchDockerdDaemon,
|
|
@@ -338,6 +360,7 @@ export {
|
|
|
338
360
|
listBoxes,
|
|
339
361
|
listCheckpoints,
|
|
340
362
|
listShellSessions,
|
|
363
|
+
mintHostInitiatedToken,
|
|
341
364
|
openBoxInFinder,
|
|
342
365
|
openInFinder,
|
|
343
366
|
opencodeSessionInfo,
|
|
@@ -353,6 +376,7 @@ export {
|
|
|
353
376
|
portlessInstallHint,
|
|
354
377
|
portlessStartHint,
|
|
355
378
|
portlessUnalias,
|
|
379
|
+
preparedMatches,
|
|
356
380
|
projectCheckpointImageBytes,
|
|
357
381
|
projectCheckpointsDir,
|
|
358
382
|
pruneBoxes,
|
|
@@ -361,6 +385,7 @@ export {
|
|
|
361
385
|
pullOpencodeConfig,
|
|
362
386
|
pullToHost,
|
|
363
387
|
readBoxStatus,
|
|
388
|
+
readPreparedDockerState,
|
|
364
389
|
readState,
|
|
365
390
|
rebuildPluginNativeDeps,
|
|
366
391
|
recordBox,
|
|
@@ -378,6 +403,7 @@ export {
|
|
|
378
403
|
resolveCheckpoint,
|
|
379
404
|
resolveClaudeVolume,
|
|
380
405
|
resolveCodexVolume,
|
|
406
|
+
resolveContextFiles,
|
|
381
407
|
resolveOpencodeVolume,
|
|
382
408
|
resolvePortlessHostStateDir,
|
|
383
409
|
runInteractiveClaudeLogin,
|
|
@@ -386,6 +412,7 @@ export {
|
|
|
386
412
|
scanHostEnvFiles,
|
|
387
413
|
scanPluginCacheForRebuild,
|
|
388
414
|
seedCodexHooks,
|
|
415
|
+
seedOpencodePlugin,
|
|
389
416
|
seedSetupSkillIntoVolume,
|
|
390
417
|
seedWorkspace,
|
|
391
418
|
seedWorkspaceFromDir,
|
|
@@ -401,6 +428,7 @@ export {
|
|
|
401
428
|
stageCodexCredentialsForUpload,
|
|
402
429
|
stageCodexStaticForUpload,
|
|
403
430
|
stageOpencodeCredentialsForUpload,
|
|
431
|
+
stageOpencodeStateForUpload,
|
|
404
432
|
stageOpencodeStaticForUpload,
|
|
405
433
|
startBox,
|
|
406
434
|
startClaudeSession,
|
|
@@ -412,12 +440,14 @@ export {
|
|
|
412
440
|
stopRelay,
|
|
413
441
|
syncClaudeCredentials,
|
|
414
442
|
unpauseBox,
|
|
443
|
+
uploadToBox,
|
|
415
444
|
volumeExists,
|
|
416
445
|
volumeHasCodexAuth,
|
|
417
446
|
volumeHasOpencodeAuth,
|
|
418
447
|
volumeSizeBytes,
|
|
419
448
|
vscodeServerVolumeName,
|
|
420
449
|
waitForTmuxPaneContent,
|
|
421
|
-
warmUpClaudeCredentials
|
|
450
|
+
warmUpClaudeCredentials,
|
|
451
|
+
writePreparedDockerState
|
|
422
452
|
};
|
|
423
|
-
//# sourceMappingURL=dist-
|
|
453
|
+
//# sourceMappingURL=dist-32EZBYG4.js.map
|
|
@@ -5,21 +5,86 @@ import {
|
|
|
5
5
|
ensureDaytonaCredentials,
|
|
6
6
|
ensureDaytonaEnvLoaded,
|
|
7
7
|
getClient,
|
|
8
|
+
resolveDaytonaCustomClaudeMd,
|
|
8
9
|
resolveDockerfileContext
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LEV3KICD.js";
|
|
10
11
|
import {
|
|
11
12
|
createCloudProvider
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BXQMIEHC.js";
|
|
13
14
|
import {
|
|
14
15
|
stageClaudeStaticForUpload,
|
|
15
16
|
stageCodexStaticForUpload,
|
|
16
17
|
stageOpencodeStaticForUpload
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import
|
|
18
|
+
} from "./chunk-NCJP5MTN.js";
|
|
19
|
+
import {
|
|
20
|
+
DOCKER_CONTEXT_FILE_MAP,
|
|
21
|
+
computeContextSha256,
|
|
22
|
+
readCliStamp,
|
|
23
|
+
readPreparedStateRaw,
|
|
24
|
+
resolveContextFilesFrom,
|
|
25
|
+
writePreparedStateRaw
|
|
26
|
+
} from "./chunk-KL36BRN4.js";
|
|
27
|
+
import "./chunk-G3H2L3O2.js";
|
|
19
28
|
|
|
20
29
|
// ../../packages/sandbox-daytona/dist/index.js
|
|
21
30
|
import { Image } from "@daytonaio/sdk";
|
|
22
|
-
|
|
31
|
+
import { existsSync } from "fs";
|
|
32
|
+
import { dirname, resolve } from "path";
|
|
33
|
+
import { fileURLToPath } from "url";
|
|
34
|
+
var SCHEMA = 1;
|
|
35
|
+
function resolveDaytonaContextFiles() {
|
|
36
|
+
const ctx = resolveDockerfileContext();
|
|
37
|
+
if (!ctx) return null;
|
|
38
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
39
|
+
const packageRoot = resolve(here, "..");
|
|
40
|
+
const monorepoRoot = resolve(here, "..", "..", "..");
|
|
41
|
+
const dockerPackageRoot = resolve(monorepoRoot, "packages", "sandbox-docker");
|
|
42
|
+
const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
43
|
+
contextDir: ctx.context,
|
|
44
|
+
devRoot: existsSync(dockerPackageRoot) ? dockerPackageRoot : packageRoot
|
|
45
|
+
});
|
|
46
|
+
if (!docker) return null;
|
|
47
|
+
const overlay = resolveDaytonaCustomClaudeMd();
|
|
48
|
+
if (!overlay) return null;
|
|
49
|
+
return [
|
|
50
|
+
...docker,
|
|
51
|
+
// Daytona-specific overlay: separate logical name so a docker/daytona
|
|
52
|
+
// CLAUDE.md drift produces different fingerprints (the daytona snapshot
|
|
53
|
+
// contains both files in distinct locations).
|
|
54
|
+
{ rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
async function computeDaytonaContextFingerprint() {
|
|
58
|
+
const files = resolveDaytonaContextFiles();
|
|
59
|
+
if (!files) return null;
|
|
60
|
+
return { contextSha256: await computeContextSha256(files), files };
|
|
61
|
+
}
|
|
62
|
+
function readPreparedDaytonaState() {
|
|
63
|
+
const raw = readPreparedStateRaw("daytona");
|
|
64
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
65
|
+
const parsed = raw;
|
|
66
|
+
if (parsed.schema !== SCHEMA) return null;
|
|
67
|
+
return { schema: SCHEMA, base: parsed.base };
|
|
68
|
+
}
|
|
69
|
+
function writePreparedDaytonaState(opts) {
|
|
70
|
+
const stamp = readCliStamp();
|
|
71
|
+
const state = {
|
|
72
|
+
schema: SCHEMA,
|
|
73
|
+
base: {
|
|
74
|
+
imageRef: opts.snapshotName,
|
|
75
|
+
contextSha256: opts.contextSha256,
|
|
76
|
+
cliVersion: stamp.cliVersion,
|
|
77
|
+
cliCommit: stamp.cliCommit,
|
|
78
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
writePreparedStateRaw("daytona", state);
|
|
82
|
+
}
|
|
83
|
+
function preparedMatches(state, current) {
|
|
84
|
+
return state?.base?.contextSha256 === current;
|
|
85
|
+
}
|
|
86
|
+
function defaultSnapshotName(fingerprint) {
|
|
87
|
+
if (fingerprint) return `agentbox-base-${fingerprint.slice(0, 12)}`;
|
|
23
88
|
return `agentbox-base-${Math.floor(Date.now() / 1e3).toString()}`;
|
|
24
89
|
}
|
|
25
90
|
async function stageAllAgentStatic(opts) {
|
|
@@ -53,33 +118,69 @@ async function prepareDaytona(opts) {
|
|
|
53
118
|
ensureDaytonaEnvLoaded();
|
|
54
119
|
const log = opts.onLog ?? (() => {
|
|
55
120
|
});
|
|
56
|
-
const
|
|
121
|
+
const fingerprint = await computeDaytonaContextFingerprint();
|
|
122
|
+
const snapshotName = opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null);
|
|
123
|
+
const prepared = readPreparedDaytonaState();
|
|
124
|
+
if (!opts.force && fingerprint && preparedMatches(prepared, fingerprint.contextSha256)) {
|
|
125
|
+
try {
|
|
126
|
+
const existing = await getClient().snapshot.get(
|
|
127
|
+
prepared?.base?.imageRef ?? snapshotName
|
|
128
|
+
);
|
|
129
|
+
if (existing?.name) {
|
|
130
|
+
log(
|
|
131
|
+
`daytona snapshot '${existing.name}' up to date (fingerprint ${fingerprint.contextSha256.slice(0, 12)}) \u2014 skipping rebuild (pass --force to override)`
|
|
132
|
+
);
|
|
133
|
+
return { snapshotName: existing.name };
|
|
134
|
+
}
|
|
135
|
+
log(
|
|
136
|
+
`recorded snapshot '${prepared?.base?.imageRef ?? snapshotName}' not found on Daytona; rebuilding`
|
|
137
|
+
);
|
|
138
|
+
} catch {
|
|
139
|
+
log(
|
|
140
|
+
`recorded snapshot lookup failed; rebuilding (pass --force to silence)`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
} else if (!opts.force && fingerprint && prepared?.base?.contextSha256) {
|
|
144
|
+
log(
|
|
145
|
+
`daytona build context changed (was ${prepared.base.contextSha256.slice(0, 12)}, now ${fingerprint.contextSha256.slice(0, 12)}); rebuilding snapshot`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
57
148
|
const ctx = resolveDockerfileContext();
|
|
58
149
|
if (!ctx) {
|
|
59
150
|
throw new Error(
|
|
60
151
|
"could not locate AgentBox Dockerfile.box build context for the Daytona snapshot. Set AGENTBOX_DOCKER_CONTEXT to the directory containing Dockerfile.box."
|
|
61
152
|
);
|
|
62
153
|
}
|
|
154
|
+
const daytonaClaudeMd = resolveDaytonaCustomClaudeMd();
|
|
155
|
+
if (!daytonaClaudeMd) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
"could not locate packages/sandbox-daytona/scripts/custom-system-CLAUDE.md (or its staged runtime/daytona/ copy). Ensure `pnpm -w build` ran so the CLI staging populated runtime/daytona/."
|
|
158
|
+
);
|
|
159
|
+
}
|
|
63
160
|
const stages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });
|
|
64
161
|
for (const s of stages) {
|
|
65
162
|
for (const w of s.staged.warnings) log(w);
|
|
66
163
|
}
|
|
67
164
|
try {
|
|
68
165
|
let image = Image.fromDockerfile(ctx.dockerfile);
|
|
69
|
-
|
|
166
|
+
image = image.addLocalFile(daytonaClaudeMd, "/tmp/agentbox-custom-CLAUDE.md");
|
|
167
|
+
const extractCmds = [
|
|
168
|
+
"install -m 0644 /tmp/agentbox-custom-CLAUDE.md /etc/claude-code/CLAUDE.md",
|
|
169
|
+
"rm -f /tmp/agentbox-custom-CLAUDE.md"
|
|
170
|
+
];
|
|
70
171
|
const usable = stages.filter((s) => s.staged.tarballPath !== null);
|
|
71
172
|
for (const s of usable) {
|
|
72
173
|
image = image.addLocalFile(s.staged.tarballPath, s.remoteTar);
|
|
73
174
|
extractCmds.push(`mkdir -p ${s.extractDir}`);
|
|
74
175
|
extractCmds.push(`tar -xzf ${s.remoteTar} -C ${s.extractDir}`);
|
|
75
176
|
}
|
|
76
|
-
if (
|
|
177
|
+
if (usable.length > 0) {
|
|
77
178
|
extractCmds.push(
|
|
78
179
|
"chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local"
|
|
79
180
|
);
|
|
80
181
|
extractCmds.push("rm -f /tmp/agentbox-seed-*.tar.gz");
|
|
81
|
-
image = image.dockerfileCommands(["USER root"]).runCommands(...extractCmds).dockerfileCommands(["USER vscode"]);
|
|
82
182
|
}
|
|
183
|
+
image = image.dockerfileCommands(["USER root"]).runCommands(...extractCmds).dockerfileCommands(["USER vscode"]);
|
|
83
184
|
const client = getClient();
|
|
84
185
|
log(`creating Daytona snapshot '${snapshotName}'\u2026`);
|
|
85
186
|
const snapshot = await client.snapshot.create(
|
|
@@ -89,6 +190,15 @@ async function prepareDaytona(opts) {
|
|
|
89
190
|
}
|
|
90
191
|
);
|
|
91
192
|
log(`snapshot '${snapshot.name}' is ${snapshot.state ?? "created"}`);
|
|
193
|
+
if (fingerprint) {
|
|
194
|
+
writePreparedDaytonaState({
|
|
195
|
+
snapshotName: snapshot.name ?? snapshotName,
|
|
196
|
+
contextSha256: fingerprint.contextSha256
|
|
197
|
+
});
|
|
198
|
+
log(
|
|
199
|
+
`recorded daytona-prepared.json (fingerprint ${fingerprint.contextSha256.slice(0, 12)})`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
92
202
|
return { snapshotName: snapshot.name ?? snapshotName };
|
|
93
203
|
} finally {
|
|
94
204
|
await Promise.all(stages.map((s) => s.staged.cleanup()));
|
|
@@ -180,4 +290,4 @@ export {
|
|
|
180
290
|
getDaytonaStatus,
|
|
181
291
|
resolveDockerfileContext
|
|
182
292
|
};
|
|
183
|
-
//# sourceMappingURL=dist-
|
|
293
|
+
//# sourceMappingURL=dist-CX5CGVEB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../packages/sandbox-daytona/src/index.ts","../../../packages/sandbox-daytona/src/prepare.ts","../../../packages/sandbox-daytona/src/prepared-state.ts","../../../packages/sandbox-daytona/src/status.ts"],"sourcesContent":["/**\n * The Daytona Cloud sandbox provider. A thin `CloudBackend` over\n * `@daytonaio/sdk`, composed via `@agentbox/sandbox-cloud`'s `createCloudProvider`\n * for everything provider-agnostic (workspace seeding, ctl launch, state).\n */\n\nimport type { Provider } from '@agentbox/core';\nimport { createCloudProvider } from '@agentbox/sandbox-cloud';\nimport { daytonaBackend, DEFAULT_BOX_IMAGE_REF } from './backend.js';\nimport { prepareDaytona } from './prepare.js';\n\nconst cloudProvider = createCloudProvider(daytonaBackend, {\n defaultResources: { cpu: 2, memory: 4, disk: 8 },\n});\n\nexport const daytonaProvider: Provider = {\n ...cloudProvider,\n prepare: prepareDaytona,\n};\n\nexport { daytonaBackend, DEFAULT_BOX_IMAGE_REF };\nexport { resolveDockerfileContext, type DockerfileContext } from './dockerfile-context.js';\nexport { ensureDaytonaEnvLoaded } from './env-loader.js';\n// Called by the CLI provider registry to gate first-run interactive setup.\n// Plain async function — no commander surface — so adding it here doesn't\n// pull commander/clack into consumers' type graphs. The full CLI command\n// lives at the `./cli` subpath export.\nexport { ensureDaytonaCredentials } from './credentials.js';\nexport type { EnsureDaytonaCredentialsOptions } from './credentials.js';\nexport {\n getDaytonaStatus,\n type DaytonaStatus,\n type DaytonaSnapshotSummary,\n type DaytonaVolumeSummary,\n} from './status.js';\n","/**\n * Daytona-side implementation of the `Provider.prepare` hook (`agentbox\n * prepare --provider daytona`). One-time, user-triggered:\n *\n * 1. Stage filtered tarballs of the host's `~/.claude`, `~/.codex`, and\n * `~/.local/share/opencode` static config (no auth tokens — those go on\n * the per-org `agentbox-credentials` volume at create time).\n * 2. Build a layered Daytona `Image`: start from `Dockerfile.box`, then\n * `.addLocalFile()` each staged tarball + `.runCommands()` to extract\n * them into the right paths inside the image.\n * 3. Call `daytona.snapshot.create({ name, image }, { onLogs })` — Daytona\n * runs the build server-side, registers the result as an org-scoped\n * named snapshot, and returns when it's `active`.\n *\n * Replaces the old `agentbox daytona publish-snapshot` flow that\n * provisioned a sandbox + ran an in-sandbox bake + called the broken\n * `_experimental_createSnapshot`. The new path never provisions a sandbox.\n *\n * Source of truth for the public API:\n * https://www.daytona.io/docs/en/snapshots/\n */\n\nimport { Image } from '@daytonaio/sdk';\nimport type { PrepareOptions, PrepareResult } from '@agentbox/core';\nimport {\n stageClaudeStaticForUpload,\n stageCodexStaticForUpload,\n stageOpencodeStaticForUpload,\n type StageResult,\n} from '@agentbox/sandbox-cloud';\nimport { getClient } from './backend.js';\nimport { resolveDaytonaCustomClaudeMd, resolveDockerfileContext } from './dockerfile-context.js';\nimport { ensureDaytonaEnvLoaded } from './env-loader.js';\nimport {\n computeDaytonaContextFingerprint,\n preparedMatches,\n readPreparedDaytonaState,\n writePreparedDaytonaState,\n} from './prepared-state.js';\n\n/**\n * Default snapshot name. Keyed on the first 12 chars of the build-context\n * fingerprint so identical content produces the same snapshot name across\n * machines / CLI runs (idempotent): if the named snapshot already exists\n * on Daytona, prepare can short-circuit without uploading the build\n * context again. Falls back to a timestamp when fingerprinting fails\n * (partial dev rebuild).\n */\nfunction defaultSnapshotName(fingerprint: string | null): string {\n if (fingerprint) return `agentbox-base-${fingerprint.slice(0, 12)}`;\n return `agentbox-base-${Math.floor(Date.now() / 1000).toString()}`;\n}\n\ninterface AgentStage {\n kind: 'claude' | 'codex' | 'opencode';\n /** Path inside the image build that the tarball is uploaded to. */\n remoteTar: string;\n /** Path the image build extracts the tarball into. */\n extractDir: string;\n staged: StageResult;\n}\n\n/**\n * Stage the three agents' static tarballs in parallel. Each `StageResult`'s\n * `cleanup()` must be called by the caller, after the image build picks the\n * file up.\n */\nasync function stageAllAgentStatic(opts: { hostWorkspace?: string }): Promise<AgentStage[]> {\n const [claudeStaged, codexStaged, opencodeStaged] = await Promise.all([\n stageClaudeStaticForUpload({ hostWorkspace: opts.hostWorkspace }),\n stageCodexStaticForUpload(),\n stageOpencodeStaticForUpload(),\n ]);\n return [\n {\n kind: 'claude',\n remoteTar: '/tmp/agentbox-seed-claude.tar.gz',\n extractDir: '/home/vscode/.claude',\n staged: claudeStaged,\n },\n {\n kind: 'codex',\n remoteTar: '/tmp/agentbox-seed-codex.tar.gz',\n extractDir: '/home/vscode/.codex',\n staged: codexStaged,\n },\n {\n kind: 'opencode',\n remoteTar: '/tmp/agentbox-seed-opencode.tar.gz',\n extractDir: '/home/vscode/.local/share/opencode',\n staged: opencodeStaged,\n },\n ];\n}\n\n/**\n * Run `agentbox prepare --provider daytona`. Returns `{ snapshotName }` on\n * success so the CLI can pin it into the project config.\n */\nexport async function prepareDaytona(opts: PrepareOptions): Promise<PrepareResult> {\n ensureDaytonaEnvLoaded();\n const log = opts.onLog ?? (() => {});\n\n // Fingerprint the build context first so we can (a) name the snapshot\n // deterministically and (b) detect cache hits against the recorded\n // prepared state. Computed before staging so an early `null` (partial\n // dev rebuild) doesn't waste a tar staging cycle.\n const fingerprint = await computeDaytonaContextFingerprint();\n const snapshotName =\n opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null);\n\n const prepared = readPreparedDaytonaState();\n if (\n !opts.force &&\n fingerprint &&\n preparedMatches(prepared, fingerprint.contextSha256)\n ) {\n // Confirm the snapshot still exists on Daytona before short-circuiting.\n // A \"yes locally, no on the server\" mismatch must rebuild.\n try {\n const existing = await getClient().snapshot.get(\n prepared?.base?.imageRef ?? snapshotName,\n );\n if (existing?.name) {\n log(\n `daytona snapshot '${existing.name}' up to date ` +\n `(fingerprint ${fingerprint.contextSha256.slice(0, 12)}) — skipping rebuild ` +\n `(pass --force to override)`,\n );\n return { snapshotName: existing.name };\n }\n log(\n `recorded snapshot '${prepared?.base?.imageRef ?? snapshotName}' not found on Daytona; rebuilding`,\n );\n } catch {\n log(\n `recorded snapshot lookup failed; rebuilding (pass --force to silence)`,\n );\n }\n } else if (!opts.force && fingerprint && prepared?.base?.contextSha256) {\n log(\n `daytona build context changed (was ${prepared.base.contextSha256.slice(0, 12)}, ` +\n `now ${fingerprint.contextSha256.slice(0, 12)}); rebuilding snapshot`,\n );\n }\n\n const ctx = resolveDockerfileContext();\n if (!ctx) {\n throw new Error(\n 'could not locate AgentBox Dockerfile.box build context for the Daytona snapshot. ' +\n 'Set AGENTBOX_DOCKER_CONTEXT to the directory containing Dockerfile.box.',\n );\n }\n\n const daytonaClaudeMd = resolveDaytonaCustomClaudeMd();\n if (!daytonaClaudeMd) {\n throw new Error(\n 'could not locate packages/sandbox-daytona/scripts/custom-system-CLAUDE.md ' +\n '(or its staged runtime/daytona/ copy). Ensure `pnpm -w build` ran so the ' +\n 'CLI staging populated runtime/daytona/.',\n );\n }\n\n const stages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });\n // Surface staging warnings (codex Keychain landmine, etc.) before the\n // longer build kicks off.\n for (const s of stages) {\n for (const w of s.staged.warnings) log(w);\n }\n\n try {\n let image: Image = Image.fromDockerfile(ctx.dockerfile);\n\n // Overlay the daytona-specific /etc/claude-code/CLAUDE.md on top of the\n // docker-shaped one baked by Dockerfile.box. Daytona boxes have no host\n // .git/ bind-mount, so the in-box hint needs daytona-specific git wording.\n image = image.addLocalFile(daytonaClaudeMd, '/tmp/agentbox-custom-CLAUDE.md');\n const extractCmds: string[] = [\n 'install -m 0644 /tmp/agentbox-custom-CLAUDE.md /etc/claude-code/CLAUDE.md',\n 'rm -f /tmp/agentbox-custom-CLAUDE.md',\n ];\n\n // For each agent whose stage produced a tarball, add the file to the\n // image build context and append a single tar-extract + chown.\n const usable = stages.filter((s) => s.staged.tarballPath !== null);\n for (const s of usable) {\n image = image.addLocalFile(s.staged.tarballPath as string, s.remoteTar);\n extractCmds.push(`mkdir -p ${s.extractDir}`);\n extractCmds.push(`tar -xzf ${s.remoteTar} -C ${s.extractDir}`);\n }\n if (usable.length > 0) {\n // One final pass: own the extracted trees as the box user, then drop the\n // staging tarballs (no point shipping them twice in the image layer).\n extractCmds.push(\n 'chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local',\n );\n extractCmds.push('rm -f /tmp/agentbox-seed-*.tar.gz');\n }\n // Dockerfile.box ends with `USER vscode`. Switch to root for the\n // install/tar/chown/rm pass — COPYed files are root-owned in /tmp (sticky\n // bit), chown -R on /home/vscode/.* only works as root, and\n // /etc/claude-code is root-owned. Switch back to vscode so the image\n // keeps its default-user invariant.\n image = image\n .dockerfileCommands(['USER root'])\n .runCommands(...extractCmds)\n .dockerfileCommands(['USER vscode']);\n\n const client = getClient();\n log(`creating Daytona snapshot '${snapshotName}'…`);\n const snapshot = await client.snapshot.create(\n { name: snapshotName, image },\n {\n onLogs: (chunk: string) => log(String(chunk).split('\\n').filter(Boolean).join(' ')),\n },\n );\n log(`snapshot '${snapshot.name}' is ${snapshot.state ?? 'created'}`);\n if (fingerprint) {\n writePreparedDaytonaState({\n snapshotName: snapshot.name ?? snapshotName,\n contextSha256: fingerprint.contextSha256,\n });\n log(\n `recorded daytona-prepared.json (fingerprint ${fingerprint.contextSha256.slice(0, 12)})`,\n );\n }\n return { snapshotName: snapshot.name ?? snapshotName };\n } finally {\n await Promise.all(stages.map((s) => s.staged.cleanup()));\n }\n}\n","/**\n * Daytona provider's `~/.agentbox/daytona-prepared.json` reader/writer +\n * build-context fingerprinting for the org-scoped base snapshot.\n *\n * The daytona prepare bakes the docker `Dockerfile.box` plus a daytona-\n * specific `custom-system-CLAUDE.md` overlay. The fingerprint covers both\n * — same canonical file map as the docker provider for the dockerfile\n * inputs, plus one extra entry for the daytona overlay.\n */\n\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n computeContextSha256,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { resolveDaytonaCustomClaudeMd, resolveDockerfileContext } from './dockerfile-context.js';\n\nconst SCHEMA = 1 as const;\n\nexport type PreparedDaytonaState = PreparedBaseSnapshot<string, never>;\n\n/**\n * Resolve every file that influences the daytona base snapshot: the docker\n * build context (shared map from sandbox-core) plus the daytona-specific\n * CLAUDE.md overlay added by `Image.addLocalFile` in `prepare.ts`.\n *\n * Returns `null` if any file is missing — callers degrade to \"always\n * rebuild\" rather than stamp a misleading fingerprint.\n */\nexport function resolveDaytonaContextFiles(): ContextFile[] | null {\n const ctx = resolveDockerfileContext();\n if (!ctx) return null;\n // sandbox-daytona's package root = parent of src/ or parent of dist/.\n // Mirrors the `resolve(here, '..', '..', '..')` walk in dockerfile-context.ts.\n const here = dirname(fileURLToPath(import.meta.url));\n const packageRoot = resolve(here, '..');\n const monorepoRoot = resolve(here, '..', '..', '..');\n // Docker's dev fallback is anchored at sandbox-docker's root, not\n // sandbox-daytona's, so we pass the monorepo root and prefix the dev\n // paths to walk into packages/sandbox-docker/.\n //\n // Simpler: just point devRoot at sandbox-docker's package root when it\n // exists (legacy monorepo layout).\n const dockerPackageRoot = resolve(monorepoRoot, 'packages', 'sandbox-docker');\n const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx.context,\n devRoot: existsSync(dockerPackageRoot) ? dockerPackageRoot : packageRoot,\n });\n if (!docker) return null;\n const overlay = resolveDaytonaCustomClaudeMd();\n if (!overlay) return null;\n return [\n ...docker,\n // Daytona-specific overlay: separate logical name so a docker/daytona\n // CLAUDE.md drift produces different fingerprints (the daytona snapshot\n // contains both files in distinct locations).\n { rel: 'daytona/custom-system-CLAUDE.md', abs: overlay },\n ];\n}\n\nexport interface DaytonaFingerprint {\n contextSha256: string;\n files: ContextFile[];\n}\n\nexport async function computeDaytonaContextFingerprint(): Promise<DaytonaFingerprint | null> {\n const files = resolveDaytonaContextFiles();\n if (!files) return null;\n return { contextSha256: await computeContextSha256(files), files };\n}\n\nexport function readPreparedDaytonaState(): PreparedDaytonaState | null {\n const raw = readPreparedStateRaw('daytona');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDaytonaState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedDaytonaState(opts: {\n snapshotName: string;\n contextSha256: string;\n}): void {\n const stamp = readCliStamp();\n const state: PreparedDaytonaState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.snapshotName,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n },\n };\n writePreparedStateRaw('daytona', state);\n}\n\nexport function preparedMatches(\n state: PreparedDaytonaState | null,\n current: string,\n): boolean {\n return state?.base?.contextSha256 === current;\n}\n","/**\n * Read-only status helpers for `agentbox prepare` (no-args mode). Surfaces\n * the user-facing inventory of agentbox-owned base images / snapshots /\n * volumes on the configured Daytona org so the user can see at a glance\n * what's already prepared and what isn't.\n *\n * Daytona-side state lives in two places:\n * - **Snapshots** — built by `agentbox prepare --provider daytona`. Listed\n * filtered to `agentbox*` so we don't surface unrelated org snapshots.\n * - **Volumes** — the per-org `agentbox-credentials` volume created lazily\n * by `ensureAgentVolumesForCloud` on first `agentbox create --provider\n * daytona`.\n *\n * All calls swallow auth/network errors and return an empty section — the\n * status command must work for users who don't have Daytona configured.\n */\n\nimport { ensureDaytonaEnvLoaded } from './env-loader.js';\nimport { getClient } from './backend.js';\n\nexport interface DaytonaSnapshotSummary {\n name: string;\n state?: string;\n /** Snapshot size in GB, as reported by Daytona (may be undefined for non-`active` states). */\n sizeGb?: number;\n createdAt?: string;\n errorReason?: string;\n}\n\nexport interface DaytonaVolumeSummary {\n name: string;\n id: string;\n state?: string;\n createdAt?: string;\n lastUsedAt?: string;\n}\n\nexport interface DaytonaStatus {\n /** True when Daytona credentials are present + the SDK could connect. */\n configured: boolean;\n /** Snapshots whose name starts with `agentbox` (case-insensitive). */\n snapshots: DaytonaSnapshotSummary[];\n /** Volumes whose name starts with `agentbox` (case-insensitive). */\n volumes: DaytonaVolumeSummary[];\n /** Non-fatal explanation when `configured` is false. */\n reason?: string;\n}\n\nfunction isAgentboxName(name: unknown): boolean {\n return typeof name === 'string' && name.toLowerCase().startsWith('agentbox');\n}\n\n/**\n * Collect a read-only summary of agentbox-owned snapshots + volumes on the\n * Daytona org. Never throws — failure paths return `configured: false` with\n * a one-line reason.\n */\nexport async function getDaytonaStatus(): Promise<DaytonaStatus> {\n try {\n ensureDaytonaEnvLoaded();\n } catch (err) {\n return {\n configured: false,\n snapshots: [],\n volumes: [],\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n let client;\n try {\n client = getClient();\n } catch (err) {\n return {\n configured: false,\n snapshots: [],\n volumes: [],\n reason: err instanceof Error ? err.message.split('\\n')[0] : String(err),\n };\n }\n\n const snapshots: DaytonaSnapshotSummary[] = [];\n const volumes: DaytonaVolumeSummary[] = [];\n let reason: string | undefined;\n\n try {\n const list = await client.snapshot.list();\n const items = (list as { items?: unknown[] }).items ?? (Array.isArray(list) ? list : []);\n for (const s of items) {\n const dto = s as { name?: unknown; state?: unknown; size?: unknown; createdAt?: unknown; errorReason?: unknown };\n if (!isAgentboxName(dto.name)) continue;\n snapshots.push({\n name: dto.name as string,\n state: typeof dto.state === 'string' ? dto.state : undefined,\n sizeGb: typeof dto.size === 'number' ? dto.size : undefined,\n createdAt: typeof dto.createdAt === 'string' ? dto.createdAt : undefined,\n errorReason: typeof dto.errorReason === 'string' ? dto.errorReason : undefined,\n });\n }\n } catch (err) {\n reason = `snapshot list failed: ${err instanceof Error ? err.message.split('\\n')[0] : String(err)}`;\n }\n\n try {\n const list = await client.volume.list();\n const items: unknown[] = Array.isArray(list)\n ? list\n : ((list as { items?: unknown[] }).items ?? []);\n for (const v of items) {\n const dto = v as { name?: unknown; id?: unknown; state?: unknown; createdAt?: unknown; lastUsedAt?: unknown };\n if (!isAgentboxName(dto.name)) continue;\n volumes.push({\n name: dto.name as string,\n id: typeof dto.id === 'string' ? dto.id : '',\n state: typeof dto.state === 'string' ? dto.state : undefined,\n createdAt: typeof dto.createdAt === 'string' ? dto.createdAt : undefined,\n lastUsedAt: typeof dto.lastUsedAt === 'string' ? dto.lastUsedAt : undefined,\n });\n }\n } catch (err) {\n const msg = `volume list failed: ${err instanceof Error ? err.message.split('\\n')[0] : String(err)}`;\n reason = reason ? `${reason}; ${msg}` : msg;\n }\n\n return {\n configured: true,\n snapshots: snapshots.sort((a, b) => (b.createdAt ?? '').localeCompare(a.createdAt ?? '')),\n volumes: volumes.sort((a, b) => a.name.localeCompare(b.name)),\n reason,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsBA,SAAS,aAAa;ACZtB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AAa9B,IAAM,SAAS;AAYR,SAAS,6BAAmD;AACjE,QAAM,MAAM,yBAAyB;AACrC,MAAI,CAAC,IAAK,QAAO;AAGjB,QAAM,OAAO,QAAQ,cAAc,YAAY,GAAG,CAAC;AACnD,QAAM,cAAc,QAAQ,MAAM,IAAI;AACtC,QAAM,eAAe,QAAQ,MAAM,MAAM,MAAM,IAAI;AAOnD,QAAM,oBAAoB,QAAQ,cAAc,YAAY,gBAAgB;AAC5E,QAAM,SAAS,wBAAwB,yBAAyB;IAC9D,YAAY,IAAI;IAChB,SAAS,WAAW,iBAAiB,IAAI,oBAAoB;EAC/D,CAAC;AACD,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,UAAU,6BAA6B;AAC7C,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO;IACL,GAAG;;;;IAIH,EAAE,KAAK,mCAAmC,KAAK,QAAQ;EACzD;AACF;AAOA,eAAsB,mCAAuE;AAC3F,QAAM,QAAQ,2BAA2B;AACzC,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,EAAE,eAAe,MAAM,qBAAqB,KAAK,GAAG,MAAM;AACnE;AAEO,SAAS,2BAAwD;AACtE,QAAM,MAAM,qBAAqB,SAAS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