@madarco/agentbox 0.23.4 → 0.24.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.
Files changed (193) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -2
  4. package/dist/{_cloud-attach-BQRWX3J2.js → _cloud-attach-T6GPR6LJ.js} +5 -5
  5. package/dist/{chunk-GGRZ3GZO.js → chunk-5KHEH47T.js} +91 -79
  6. package/dist/chunk-5KHEH47T.js.map +1 -0
  7. package/dist/{chunk-I6ZRWTPR.js → chunk-6U2S6QWD.js} +219 -18
  8. package/dist/chunk-6U2S6QWD.js.map +1 -0
  9. package/dist/{chunk-LK2JT2OO.js → chunk-DEDTPG2D.js} +880 -146
  10. package/dist/chunk-DEDTPG2D.js.map +1 -0
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-LA4JMS27.js → chunk-I654PBHA.js} +290 -330
  13. package/dist/chunk-I654PBHA.js.map +1 -0
  14. package/dist/{chunk-W3FQPFP7.js → chunk-K2EDQGZP.js} +18 -4
  15. package/dist/chunk-K2EDQGZP.js.map +1 -0
  16. package/dist/{chunk-LSQXT5WZ.js → chunk-LC4E2EIZ.js} +3 -3
  17. package/dist/{chunk-LSQXT5WZ.js.map → chunk-LC4E2EIZ.js.map} +1 -1
  18. package/dist/{chunk-SFA57TGX.js → chunk-NACA6AM7.js} +183 -49
  19. package/dist/chunk-NACA6AM7.js.map +1 -0
  20. package/dist/{chunk-QEQFZLYR.js → chunk-RYQLFKCP.js} +20 -10
  21. package/dist/chunk-RYQLFKCP.js.map +1 -0
  22. package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
  23. package/dist/chunk-UIRBYL4G.js.map +1 -0
  24. package/dist/chunk-WJFZJZIM.js +0 -0
  25. package/dist/chunk-WLHJZPFJ.js +845 -0
  26. package/dist/chunk-WLHJZPFJ.js.map +1 -0
  27. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  28. package/dist/dist-3KIJ2KQ2.js +1437 -0
  29. package/dist/dist-3KIJ2KQ2.js.map +1 -0
  30. package/dist/{dist-V235KVEX.js → dist-7OUOHQPA.js} +196 -151
  31. package/dist/dist-7OUOHQPA.js.map +1 -0
  32. package/dist/{dist-Z2NEVV55.js → dist-B7TNWGVG.js} +8 -4
  33. package/dist/{dist-CUKBKS3N.js → dist-KYV3LEHG.js} +10 -6
  34. package/dist/{dist-FXQFTT75.js → dist-PHYCFYKH.js} +37 -17
  35. package/dist/dist-PHYCFYKH.js.map +1 -0
  36. package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
  37. package/dist/{dist-QO4CTLAX.js → dist-Z7KEPQC7.js} +6 -6
  38. package/dist/index.js +2560 -1108
  39. package/dist/index.js.map +1 -1
  40. package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
  41. package/package.json +28 -28
  42. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/_shared/agentbox-codex-hooks.json +1 -1
  44. package/runtime/_shared/agentbox-dockerd-start +0 -0
  45. package/runtime/_shared/agentbox-open +0 -0
  46. package/runtime/_shared/agentbox-portless-trust +0 -0
  47. package/runtime/_shared/agentbox-vnc-start +0 -0
  48. package/runtime/_shared/ctl.cjs +468 -97
  49. package/runtime/_shared/gh-shim +0 -0
  50. package/runtime/_shared/git-shim +53 -3
  51. package/runtime/_shared/linear-shim +0 -0
  52. package/runtime/_shared/ntn-shim +0 -0
  53. package/runtime/daytona/custom-system-CLAUDE.md +1 -1
  54. package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
  55. package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
  56. package/runtime/digitalocean/agentbox-dockerd-start +145 -0
  57. package/runtime/digitalocean/agentbox-open +28 -0
  58. package/runtime/digitalocean/agentbox-portless-trust +82 -0
  59. package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
  60. package/runtime/digitalocean/agentbox-vnc-start +102 -0
  61. package/runtime/digitalocean/claude-managed-settings.json +116 -0
  62. package/runtime/digitalocean/ctl.cjs +27852 -0
  63. package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
  64. package/runtime/digitalocean/gh-shim +344 -0
  65. package/runtime/digitalocean/git-shim +181 -0
  66. package/runtime/digitalocean/linear-shim +181 -0
  67. package/runtime/digitalocean/ntn-shim +95 -0
  68. package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
  69. package/runtime/digitalocean/scripts/install-box.sh +462 -0
  70. package/runtime/docker/Dockerfile.box +5 -0
  71. package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
  72. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  73. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
  74. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  75. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  76. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  77. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  78. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  79. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  80. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
  81. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  82. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
  83. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  84. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  85. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  86. package/runtime/e2b/agentbox-codex-hooks.json +1 -1
  87. package/runtime/e2b/agentbox-dockerd-start +0 -0
  88. package/runtime/e2b/agentbox-open +0 -0
  89. package/runtime/e2b/agentbox-vnc-start +0 -0
  90. package/runtime/e2b/ctl.cjs +468 -97
  91. package/runtime/e2b/custom-system-CLAUDE.md +6 -3
  92. package/runtime/e2b/gh-shim +0 -0
  93. package/runtime/e2b/git-shim +53 -3
  94. package/runtime/e2b/linear-shim +0 -0
  95. package/runtime/e2b/ntn-shim +0 -0
  96. package/runtime/e2b/scripts/build-template.sh +16 -0
  97. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  98. package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
  99. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  100. package/runtime/hetzner/agentbox-open +0 -0
  101. package/runtime/hetzner/agentbox-portless-trust +0 -0
  102. package/runtime/hetzner/agentbox-vnc-start +0 -0
  103. package/runtime/hetzner/ctl.cjs +468 -97
  104. package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
  105. package/runtime/hetzner/gh-shim +0 -0
  106. package/runtime/hetzner/git-shim +53 -3
  107. package/runtime/hetzner/linear-shim +0 -0
  108. package/runtime/hetzner/ntn-shim +0 -0
  109. package/runtime/hetzner/scripts/install-box.sh +5 -0
  110. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  111. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  117. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  120. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  121. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  122. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
  124. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  125. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
  128. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
  129. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
  130. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  131. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
  132. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
  133. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  134. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  135. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  136. package/runtime/hub/apps/hub/.next/static/chunks/1c5w3kqosumog.js +1 -0
  137. package/runtime/hub/apps/hub/.next/static/chunks/1o3ot_9-8jgzc.js +1 -0
  138. package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
  139. package/runtime/hub/apps/hub/.next/static/chunks/3uq9hf-roasav.js +1 -0
  140. package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
  141. package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
  142. package/runtime/hub/apps/hub/{chunk-H22XP3NY.js → chunk-3VE7AYVK.js} +600 -145
  143. package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
  144. package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
  145. package/runtime/hub/apps/hub/{chunk-2Z74R6ZT.js → chunk-FGBXEXUV.js} +351 -292
  146. package/runtime/hub/apps/hub/{chunk-AR7CEZ2G.js → chunk-YVELHPNY.js} +218 -17
  147. package/runtime/hub/apps/hub/{dist-LZNRLUYY.js → dist-33ZNVTC6.js} +183 -49
  148. package/runtime/hub/apps/hub/{dist-Q6G66Z57.js → dist-4SXAJBOC.js} +195 -150
  149. package/runtime/hub/apps/hub/{dist-SD4G36EP.js → dist-EPJFN2J3.js} +116 -86
  150. package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
  151. package/runtime/hub/apps/hub/{dist-LNHEG5P4.js → dist-UJVIROA4.js} +19 -5
  152. package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
  153. package/runtime/hub/apps/hub/{dist-VV6Z2CQX.js → dist-YM5J25H6.js} +7 -3
  154. package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
  155. package/runtime/hub/apps/hub/package.json +1 -0
  156. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-CAXQS5Y3.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
  157. package/runtime/hub/apps/hub/server.js +38 -19
  158. package/runtime/relay/bin.cjs +275 -59
  159. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  160. package/runtime/vercel/agentbox-codex-hooks.json +1 -1
  161. package/runtime/vercel/agentbox-dockerd-start +0 -0
  162. package/runtime/vercel/agentbox-open +0 -0
  163. package/runtime/vercel/agentbox-vnc-start +0 -0
  164. package/runtime/vercel/ctl.cjs +468 -97
  165. package/runtime/vercel/custom-system-CLAUDE.md +3 -2
  166. package/runtime/vercel/gh-shim +0 -0
  167. package/runtime/vercel/git-shim +53 -3
  168. package/runtime/vercel/linear-shim +0 -0
  169. package/runtime/vercel/ntn-shim +0 -0
  170. package/runtime/vercel/scripts/provision.sh +16 -0
  171. package/dist/chunk-GGRZ3GZO.js.map +0 -1
  172. package/dist/chunk-I6ZRWTPR.js.map +0 -1
  173. package/dist/chunk-LA4JMS27.js.map +0 -1
  174. package/dist/chunk-LK2JT2OO.js.map +0 -1
  175. package/dist/chunk-QEQFZLYR.js.map +0 -1
  176. package/dist/chunk-QT3SHMLY.js.map +0 -1
  177. package/dist/chunk-SFA57TGX.js.map +0 -1
  178. package/dist/chunk-W3FQPFP7.js.map +0 -1
  179. package/dist/dist-FXQFTT75.js.map +0 -1
  180. package/dist/dist-V235KVEX.js.map +0 -1
  181. package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
  182. package/runtime/hub/apps/hub/.next/static/chunks/20hq7-0depjid.js +0 -1
  183. package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +0 -1
  184. package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +0 -1
  185. /package/dist/{_cloud-attach-BQRWX3J2.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
  186. /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
  187. /package/dist/{dist-CUKBKS3N.js.map → dist-KYV3LEHG.js.map} +0 -0
  188. /package/dist/{dist-QO4CTLAX.js.map → dist-T5MXBZGP.js.map} +0 -0
  189. /package/dist/{dist-Z2NEVV55.js.map → dist-Z7KEPQC7.js.map} +0 -0
  190. /package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
  191. /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
  192. /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
  193. /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/sandbox-e2b/src/index.ts","../../../packages/sandbox-e2b/src/backend.ts","../../../packages/sandbox-e2b/src/retry.ts","../../../packages/sandbox-e2b/src/prepare.ts","../../../packages/sandbox-e2b/src/build-attach.ts","../../../packages/sandbox-e2b/src/provider-module.ts"],"sourcesContent":["/**\n * The E2B sandbox provider. A thin `CloudBackend` over the `e2b` v2 SDK,\n * composed via `@agentbox/sandbox-cloud`'s `createCloudProvider` for\n * everything provider-agnostic (workspace seeding, ctl launch, state, relay\n * polling).\n *\n * Three capabilities are overridden on top of the cloud scaffold:\n * - `prepare` — bake the custom base template via Template.build\n * (`agentbox prepare --provider e2b`).\n * - `buildAttach` — SDK-streaming PTY bridge (E2B has no SSH).\n * - `checkpoint` — store the E2B snapshot id (template id) in the manifest\n * so restore boots from it (`Sandbox.createSnapshot` produces an\n * id-addressed reusable snapshot, same shape as Vercel).\n *\n * `launchDockerd: true` — E2B microVMs DO support nested containers (full root\n * + cap_sys_admin + working namespaces, verified 2026-06-23), so the base\n * template bakes the docker engine and the cloud scaffold auto-starts dockerd\n * on every create/resume (same as the vercel/hetzner/daytona providers).\n */\n\nimport type { BoxRecord, Provider, ProviderCheckpoint } from '@agentbox/core';\nimport {\n createCloudProvider,\n currentCloudBaseFingerprint,\n listCloudCheckpoints,\n removeCloudCheckpointDir,\n resolveCloudCheckpoint,\n writeCloudCheckpointManifest,\n} from '@agentbox/sandbox-cloud';\nimport { readCliStamp, recordBox, type ProviderModule } from '@agentbox/sandbox-core';\nimport { e2bBackend, DEFAULT_BOX_IMAGE_REF } from './backend.js';\nimport { Sandbox, resolveApiKey } from './sdk.js';\nimport { withE2bRetry } from './retry.js';\nimport { prepareE2bProvider } from './prepare.js';\nimport { buildE2bAttach } from './build-attach.js';\nimport { currentE2bBaseFingerprintLive } from './prepared-state.js';\nimport { ensureE2bCredentials, setE2bCredentials } from './credentials.js';\nimport { doctorChecks, readCredStatusSummary } from './provider-module.js';\n\nconst BACKEND_NAME = 'e2b';\n\nconst cloudProvider = createCloudProvider(e2bBackend, {\n // E2B applies resources at the template level (Template.build({ cpuCount,\n // memoryMB }) — `prepare` sets these). The numbers below are advisory\n // metadata for BoxRecord stats / the dashboard pane; per-create overrides\n // aren't honored by the SDK.\n defaultResources: { cpu: 2, memory: 4, disk: 8 },\n launchDockerd: true,\n});\n\n/**\n * Create a reusable, named E2B snapshot from a running sandbox.\n * `Sandbox.createSnapshot` pauses the source while capturing, then returns a\n * persistent `snapshotId` (template id form: `name:tag` or `template-id:tag`)\n * usable with `Sandbox.create({ template })` — see SDK docs.\n */\nasync function createE2bSnapshot(sandboxId: string, name: string): Promise<string> {\n const apiKey = resolveApiKey();\n return withE2bRetry(\n { method: 'createSnapshot', retryOnAmbiguous: false, attemptTimeoutMs: 900_000, backoffMs: [] },\n async () => {\n const info = await Sandbox.createSnapshot(sandboxId, { apiKey, name });\n return info.snapshotId;\n },\n );\n}\n\n/** Delete a snapshot by id. Idempotent — a missing snapshot is success. */\nasync function deleteE2bSnapshot(snapshotId: string): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry({ method: 'deleteSnapshot', retryOnAmbiguous: true }, async () => {\n try {\n await Sandbox.deleteSnapshot(snapshotId, { apiKey });\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n if (/not.?found|404/i.test(msg)) return; // idempotent\n throw err;\n }\n });\n}\n\n/**\n * Build a safe, unique E2B snapshot name. E2B names are global within a team\n * (`createSnapshot({ name })` reuses an existing name if it exists, growing\n * the build set). We stamp a per-create timestamp so each checkpoint gets its\n * own name → its own template id, never overwriting an earlier checkpoint.\n */\nfunction snapshotName(boxName: string, checkpointName: string): string {\n // E2B template names accept lower-case alnum + dashes/dots; coerce.\n const sanitize = (s: string): string =>\n s.toLowerCase().replace(/[^a-z0-9.-]+/g, '-').replace(/^-+|-+$/g, '');\n const ts = new Date().toISOString().replace(/[:.]/g, '-').replace('T', '_').replace('Z', '');\n return `agentbox-${sanitize(boxName)}-${sanitize(checkpointName)}-${sanitize(ts)}`;\n}\n\n/**\n * E2B-specific checkpoint capability. Unlike the scaffold's default (which\n * stores a caller-chosen snapshot *name*), we capture the SDK-returned\n * opaque snapshot id and store THAT in the manifest's `snapshotName` field —\n * the cloud create flow passes `manifest.snapshotName` straight to\n * `provision({ snapshot })`, and the E2B backend boots from it as a template\n * id. (Same id-addressed shape as Vercel's checkpoint capability.)\n */\nconst e2bCheckpoint: ProviderCheckpoint = {\n async create(box: BoxRecord, name: string) {\n if (!box.projectRoot) {\n throw new Error(\n 'cloud checkpoint requires the box to have a project root (run `agentbox checkpoint` from inside the project)',\n );\n }\n if (!box.cloud?.sandboxId) {\n throw new Error(`e2b box ${box.name} has no sandboxId — record is malformed`);\n }\n // NOTE: createSnapshot pauses the source sandbox; agentbox-ctl-checkpoint\n // resumes it lazily on the next op (Sandbox.connect auto-resumes).\n const e2bSnapName = snapshotName(box.name, name);\n const snapshotId = await createE2bSnapshot(box.cloud.sandboxId, e2bSnapName);\n // The box is now paused — persist it so the fast `agentbox list` path\n // doesn't show a stale `running` after a checkpoint. Best-effort.\n try {\n await recordBox({ ...box, cloud: { ...box.cloud, lastState: 'paused' } });\n } catch {\n // not worth failing the checkpoint over a state-record write\n }\n const info = await writeCloudCheckpointManifest(box.projectRoot, BACKEND_NAME, name, {\n snapshotName: snapshotId,\n sourceBoxId: box.id,\n sourceBoxName: box.name,\n baseProvider: BACKEND_NAME,\n baseFingerprint: currentCloudBaseFingerprint(BACKEND_NAME),\n cliVersion: readCliStamp().cliVersion,\n });\n return { ref: info.name };\n },\n async list(projectRoot: string) {\n const entries = await listCloudCheckpoints(projectRoot, BACKEND_NAME);\n return entries.map((e) => ({ ref: e.name, createdAt: e.manifest.createdAt }));\n },\n async remove(projectRoot: string, ref: string) {\n const entry = await resolveCloudCheckpoint(projectRoot, BACKEND_NAME, ref);\n if (!entry) return;\n try {\n await deleteE2bSnapshot(entry.manifest.snapshotName);\n } catch {\n // best-effort: drop the local manifest even if the remote delete failed\n // (network/perms/already-gone) so the user isn't left with a dead pointer.\n }\n await removeCloudCheckpointDir(projectRoot, BACKEND_NAME, ref);\n },\n};\n\nexport const e2bProvider: Provider = {\n ...cloudProvider,\n prepare: prepareE2bProvider,\n buildAttach: buildE2bAttach,\n checkpoint: e2bCheckpoint,\n baseFingerprint: () => currentE2bBaseFingerprintLive(),\n};\n\n/** Uniform surface the CLI provider loader resolves this package through. */\nexport const providerModule: ProviderModule = {\n provider: e2bProvider,\n backend: e2bBackend,\n ensureCredentials: ensureE2bCredentials,\n readCredStatus: readCredStatusSummary,\n setCredentials: (fields) => Promise.resolve(setE2bCredentials(fields)),\n currentBaseFingerprintLive: (claudeInstall) => currentE2bBaseFingerprintLive(claudeInstall),\n doctorChecks,\n};\n\nexport { e2bBackend, DEFAULT_BOX_IMAGE_REF };\nexport { ensureE2bEnvLoaded, reloadE2bEnv } from './env-loader.js';\nexport {\n ensureE2bCredentials,\n setE2bCredentials,\n readE2bCredStatus,\n secretsPath,\n maskKey,\n type EnsureE2bCredentialsOptions,\n type E2bCredStatus,\n} from './credentials.js';\nexport {\n RUNTIME_ASSETS,\n candidatesFor,\n resolveRuntimeAssets,\n findStagedCliRuntimeRoot,\n type RuntimeAsset,\n type ResolvedAsset,\n} from './runtime-assets.js';\nexport {\n prepareE2b,\n prepareE2bProvider,\n type PrepareE2bOptions,\n type PrepareE2bResult,\n} from './prepare.js';\nexport {\n currentE2bBaseFingerprintLive,\n ensureE2bBaseTemplate,\n preparedStatePath,\n readPreparedState,\n writePreparedState,\n updatePreparedState,\n type PreparedE2bState,\n type PreparedE2bBase,\n} from './prepared-state.js';\nexport { buildE2bAttach } from './build-attach.js';\n","/**\n * E2B `CloudBackend` — maps the provider-neutral cloud primitives onto the\n * `e2b` v2 SDK (Firecracker microVMs + pause/resume persistence). Composed\n * into a full `Provider` by `@agentbox/sandbox-cloud`'s `createCloudProvider`.\n *\n * Platform shape this backend is built around:\n * - Boxes boot from the prepared base template baked by `agentbox prepare\n * --provider e2b` (Template.build → custom Debian image with agentbox-ctl,\n * the vscode user, /workspace, claude/codex/opencode, tmux, Chromium).\n * `backend.provision` gates on `ensureE2bBaseTemplate()` (mirrors the\n * hetzner/vercel pattern: `prepare` itself sidesteps the gate so a cold\n * install can bootstrap). A snapshot ref (cloud checkpoint) wins over\n * the prepared base.\n * - No nested containers (Firecracker microVM); the provider sets\n * `launchDockerd: false`.\n * - Preview URLs (`{port}-{sandboxId}.{E2B_DOMAIN}`) are public HTTPS by\n * default (allowPublicTraffic=true); no header token needed. We construct\n * the URL string locally so `previewUrl` doesn't have to `Sandbox.connect`\n * (which would auto-resume a paused box).\n * - `Sandbox.getInfo` is a NON-resuming static API; `state()`/`get()` use it\n * to check existence cheaply without waking a paused sandbox. Auto-resume\n * happens only inside `Sandbox.connect` (used by ops that need a live\n * handle: exec, file ops, pause, destroy).\n * - `Sandbox.pause` is the canonical pause API (`betaPause` is deprecated).\n * - `Sandbox.createSnapshot` is the reusable-snapshot primitive; the\n * provider overrides the whole `checkpoint` capability in index.ts to\n * store the resulting snapshot id (matching vercel's id-addressed shape).\n * - No SSH — the provider overrides `buildAttach` with an SDK-streaming\n * PTY bridge (`buildE2bAttach`); the legacy `attachArgv` slot stays\n * unset.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport type {\n CloudBackend,\n CloudExecOptions,\n CloudExecResult,\n CloudFileEntry,\n CloudHandle,\n CloudPreviewUrl,\n CloudProvisionRequest,\n CloudSandboxSummary,\n CloudState,\n} from '@agentbox/core';\nimport type { SandboxInfo, SandboxState } from './sdk.js';\nimport { Sandbox, Template, resolveApiKey } from './sdk.js';\nimport { withE2bRetry } from './retry.js';\nimport { ensureE2bBaseTemplate, readPreparedState } from './prepared-state.js';\n\n/**\n * Sentinel image ref the cloud-provider hands us when no --image was passed.\n * Mirrors docker's convention; the actual template id is read from the\n * prepared-state file by `provision`.\n */\nexport const DEFAULT_BOX_IMAGE_REF = 'agentbox/box:dev';\n\n/** Box user agentbox standardizes on (matches docker/vercel — created by build-template.sh). */\nconst BOX_USER = 'vscode';\nconst BOX_OWNER = 'vscode:vscode';\n\n/** Default E2B preview hostname. Override via the SDK's `E2B_DOMAIN` env. */\nconst DEFAULT_E2B_DOMAIN = 'e2b.app';\n\n/**\n * Per-box session timeout the SDK enforces at create. Past it, E2B\n * auto-terminates the sandbox. The host keepalive loop renews it while the\n * agent is active via `renewTimeout` (static `Sandbox.setTimeout`), so a\n * long-running session isn't killed mid-work. 45 min default mirrors vercel.\n */\nconst DEFAULT_TIMEOUT_MS = 45 * 60_000;\n\nconst E2B_WEB_PORT = 8080;\n\n/** Single-quote a string for safe embedding inside a `bash -lc '<…>'`. */\nfunction shq(s: string): string {\n return \"'\" + s.replace(/'/g, \"'\\\\''\") + \"'\";\n}\n\n/**\n * Convert a Node `Buffer` to a plain `ArrayBuffer` because E2B's `files.write`\n * `data:` field is `string | ArrayBuffer | Blob | ReadableStream` — Buffer is a\n * `Uint8Array` subclass and doesn't satisfy that union at the type level (even\n * though it works at runtime). Copy rather than slice the underlying buffer:\n * Buffers may share an underlying ArrayBuffer with a pooled allocator, so\n * `data.buffer` of a small Buffer can be a megabyte-long shared region.\n */\nfunction bufferToArrayBuffer(b: Buffer): ArrayBuffer {\n const ab = new ArrayBuffer(b.byteLength);\n new Uint8Array(ab).set(b);\n return ab;\n}\n\n/**\n * Map the SDK's nullable string state onto our 4-value `CloudState`.\n * E2B reports 'running' | 'paused' (per SDK types). Anything else (or absent)\n * → 'missing' so callers ping-pong the lifecycle into a clean state.\n */\nfunction mapState(s: SandboxState | undefined): CloudState {\n switch (s) {\n case 'running':\n return 'running';\n case 'paused':\n return 'paused';\n default:\n return 'missing';\n }\n}\n\n/** True when the error means \"sandbox doesn't exist\" (404). */\nfunction isNotFound(err: unknown): boolean {\n if (!err || typeof err !== 'object') return false;\n const name = err instanceof Error ? err.name : '';\n if (name === 'SandboxNotFoundError' || name === 'NotFoundError') return true;\n const status = (err as { statusCode?: unknown; status?: unknown }).statusCode ?? (err as { status?: unknown }).status;\n return status === 404;\n}\n\n/**\n * Sanitize a box name for use as the `metadata.name` value. E2B accepts\n * arbitrary strings (probed) but we strip control chars defensively so a name\n * with embedded newlines can't break log parsing or response shapes.\n */\nfunction safeMetadataName(name: string): string {\n return name.replace(/[\\u0000-\\u001f]/g, '').slice(0, 200);\n}\n\nexport const e2bBackend: CloudBackend = {\n name: 'e2b',\n\n // The cloud scaffold's WebProxy binds whatever port we expose here, and\n // `agentbox url --kind=web` resolves via `getHost(port)`. 8080 matches the\n // non-privileged convention vercel uses — `getHost` accepts any port, but\n // staying on 8080 keeps the in-box ctl flag (AGENTBOX_WEB_PROXY_PORT)\n // identical across cloud providers.\n webProxyPort: E2B_WEB_PORT,\n\n async provision(req: CloudProvisionRequest): Promise<CloudHandle> {\n const apiKey = resolveApiKey();\n const log = req.onLog ?? (() => {});\n // Resolve the template to boot from: an explicit cloud-checkpoint snapshot\n // (req.snapshot) wins, else the prepared base template id. We don't fall\n // back to E2B's stock `base` template — every box must have the agentbox\n // runtime baked in. The gate throws an actionable \"run `agentbox prepare`\"\n // error when no template is recorded yet (mirrors the hetzner/vercel\n // pattern: `prepare` itself sidesteps the gate by calling `prepareE2b`\n // directly, never `provision`).\n if (req.snapshot === undefined) {\n ensureE2bBaseTemplate();\n }\n const template = req.snapshot ?? readPreparedState().base?.templateId;\n if (!template) {\n throw new Error(\n 'e2b provision: no template available — `agentbox prepare --provider e2b` must run first',\n );\n }\n\n // No-retry: Sandbox.create is billable and non-idempotent — a timeout\n // after the request reached the origin could leave a duplicate sandbox we\n // can't reference for cleanup.\n const sb = await withE2bRetry(\n { method: 'provision', retryOnAmbiguous: false, attemptTimeoutMs: 300_000, backoffMs: [] },\n async () =>\n Sandbox.create({\n apiKey,\n template,\n // Friendly name (so prune can see it) + the 'agentbox' marker so\n // `list()` can filter out sandboxes provisioned by other tooling.\n metadata: { agentbox: 'true', 'agentbox.name': safeMetadataName(req.name), name: safeMetadataName(req.name) },\n envs: req.env,\n timeoutMs: req.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n }),\n );\n log(`e2b: created sandbox ${sb.sandboxId} (template ${template})`);\n return { sandboxId: sb.sandboxId };\n },\n\n async get(sandboxId: string): Promise<CloudHandle | null> {\n const apiKey = resolveApiKey();\n return withE2bRetry({ method: 'get', retryOnAmbiguous: true }, async () => {\n try {\n // Static, NON-resuming — won't wake a paused sandbox just to confirm\n // it exists (per orchestrator review #1: connect would auto-resume).\n await Sandbox.getInfo(sandboxId, { apiKey });\n return { sandboxId };\n } catch (err) {\n if (isNotFound(err)) return null;\n throw err;\n }\n });\n },\n\n async list(): Promise<CloudSandboxSummary[]> {\n const apiKey = resolveApiKey();\n return withE2bRetry({ method: 'list', retryOnAmbiguous: true }, async () => {\n const summaries: CloudSandboxSummary[] = [];\n // Default query returns both running and paused sandboxes. We filter\n // client-side to the ones we created (metadata.agentbox === 'true').\n for (const state of ['running', 'paused'] as const) {\n const paginator = Sandbox.list({ apiKey, query: { state: [state] } });\n while (paginator.hasNext) {\n const page = await paginator.nextItems();\n for (const info of page) {\n if (info.metadata?.['agentbox'] !== 'true') continue;\n const friendly =\n info.metadata?.['agentbox.name'] ?? info.metadata?.['name'];\n const summary: CloudSandboxSummary = { sandboxId: info.sandboxId, state };\n if (friendly) summary.name = friendly;\n const startedAt = info.startedAt;\n if (startedAt instanceof Date) summary.createdAt = startedAt.toISOString();\n summaries.push(summary);\n }\n }\n }\n return summaries;\n });\n },\n\n // E2B has no separate stop primitive — sandboxes are either running or\n // paused. start is therefore a connect-and-resume (auto-resume inside\n // Sandbox.connect handles a paused box transparently).\n async start(h: CloudHandle): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry(\n { method: 'start', retryOnAmbiguous: true, attemptTimeoutMs: 120_000 },\n async () => {\n await Sandbox.connect(h.sandboxId, { apiKey });\n },\n );\n },\n\n // stop ≡ pause on E2B (the pause IS the cold-storage state).\n async stop(h: CloudHandle): Promise<void> {\n await this.pause(h);\n },\n\n async pause(h: CloudHandle): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry(\n { method: 'pause', retryOnAmbiguous: true, attemptTimeoutMs: 120_000 },\n async () => {\n await Sandbox.pause(h.sandboxId, { apiKey });\n },\n );\n },\n\n async resume(h: CloudHandle): Promise<void> {\n await this.start(h);\n },\n\n // E2B `setTimeout` SETS the TTL to N ms from now (absolute-from-now), so we\n // ignore the host's tracked deadline and use `target - now`. The static\n // `Sandbox.setTimeout` hits the API without `connect` (no resume of a paused\n // box). The host only calls when target > current, so this never shortens.\n async renewTimeout(h: CloudHandle, targetDeadlineEpochMs: number): Promise<void> {\n const ttlMs = Math.max(0, targetDeadlineEpochMs - Date.now());\n if (ttlMs === 0) return;\n const apiKey = resolveApiKey();\n await withE2bRetry({ method: 'renewTimeout', retryOnAmbiguous: true }, async () => {\n await Sandbox.setTimeout(h.sandboxId, ttlMs, { apiKey });\n });\n },\n\n async destroy(h: CloudHandle): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry(\n { method: 'destroy', retryOnAmbiguous: true, attemptTimeoutMs: 120_000 },\n async () => {\n try {\n await Sandbox.kill(h.sandboxId, { apiKey });\n } catch (err) {\n if (isNotFound(err)) return; // idempotent\n throw err;\n }\n },\n );\n },\n\n async state(h: CloudHandle): Promise<CloudState> {\n const apiKey = resolveApiKey();\n return withE2bRetry({ method: 'state', retryOnAmbiguous: true }, async () => {\n try {\n const info: SandboxInfo = await Sandbox.getInfo(h.sandboxId, { apiKey });\n return mapState(info.state);\n } catch (err) {\n if (isNotFound(err)) return 'missing';\n throw err;\n }\n });\n },\n\n async exec(h: CloudHandle, cmd: string, opts?: CloudExecOptions): Promise<CloudExecResult> {\n const apiKey = resolveApiKey();\n // Default per-attempt cap is 5 min — covers the cloud scaffold's\n // workspace-seed/carry extracts (tar of thousands of files, chown -R).\n // Callers can shorten with opts.attemptTimeoutMs for snappier probes.\n const timeoutMs = opts?.attemptTimeoutMs ?? 300_000;\n return withE2bRetry(\n {\n method: 'exec',\n retryOnAmbiguous: opts?.noRetry ? false : true,\n attemptTimeoutMs: timeoutMs,\n backoffMs: opts?.noRetry ? [] : undefined,\n },\n async () => {\n // Connect for the live handle — auto-resumes a paused box, which is\n // the correct semantics for exec (caller wants the command to run).\n const sb = await Sandbox.connect(h.sandboxId, { apiKey });\n // E2B's `commands.run` accepts only 'root' | 'user' | 'vscode'…; any\n // unix username we create in the fixup is valid. Pass through.\n const user = (opts?.user ?? BOX_USER) as 'root' | 'user';\n try {\n const r = await sb.commands.run(cmd, {\n ...(opts?.cwd !== undefined ? { cwd: opts.cwd } : {}),\n ...(opts?.env !== undefined ? { envs: opts.env } : {}),\n user,\n timeoutMs,\n });\n return { exitCode: r.exitCode, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };\n } catch (err) {\n // commands.run throws on non-zero exit; the CommandResult fields\n // (exitCode/stdout/stderr) hang off the error. Map back into our\n // CloudExecResult so callers see exit=1, not a thrown exception\n // (vercel/daytona/hetzner exec contract returns the result).\n if (err instanceof Error && err.name === 'CommandExitError') {\n const ce = err as unknown as {\n exitCode: number;\n stdout: string;\n stderr: string;\n };\n return { exitCode: ce.exitCode, stdout: ce.stdout ?? '', stderr: ce.stderr ?? '' };\n }\n throw err;\n }\n },\n );\n },\n\n async uploadFile(h: CloudHandle, localPath: string, remotePath: string): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry(\n { method: 'uploadFile', retryOnAmbiguous: true, attemptTimeoutMs: 300_000 },\n async () => {\n const data = await readFile(localPath);\n const sb = await Sandbox.connect(h.sandboxId, { apiKey });\n await sb.files.write([{ path: remotePath, data: bufferToArrayBuffer(data) }]);\n // files.write writes as the default user; chown to vscode so reads\n // from the scaffold's `sudo -u vscode …` exec calls succeed. Best-\n // effort — a chown failure on a world-readable file is harmless.\n try {\n await sb.commands.run(`sudo -n chown ${BOX_OWNER} ${shq(remotePath)}`, {\n user: 'root',\n timeoutMs: 10_000,\n });\n } catch {\n // ignore — file is at least present and readable\n }\n },\n );\n },\n\n async downloadFile(h: CloudHandle, remotePath: string, localPath: string): Promise<void> {\n const apiKey = resolveApiKey();\n await withE2bRetry(\n { method: 'downloadFile', retryOnAmbiguous: true, attemptTimeoutMs: 300_000 },\n async () => {\n const sb = await Sandbox.connect(h.sandboxId, { apiKey });\n const bytes = await sb.files.read(remotePath, { format: 'bytes' });\n const { writeFile } = await import('node:fs/promises');\n await writeFile(localPath, Buffer.from(bytes));\n },\n );\n },\n\n async listFiles(h: CloudHandle, remoteDir: string): Promise<CloudFileEntry[]> {\n const apiKey = resolveApiKey();\n return withE2bRetry({ method: 'listFiles', retryOnAmbiguous: true }, async () => {\n const sb = await Sandbox.connect(h.sandboxId, { apiKey });\n const entries = await sb.files.list(remoteDir);\n return entries.map((e) => ({ name: e.name, isDir: e.type === 'dir' }));\n });\n },\n\n async previewUrl(h: CloudHandle, port: number): Promise<CloudPreviewUrl> {\n // E2B's `sandbox.getHost(port)` is just string interpolation of\n // `${port}-${sandboxId}.${sandboxDomain}` — calling it via Sandbox.connect\n // would auto-resume a paused box (the SDK's documented behavior). The\n // domain defaults to `e2b.app` with `E2B_DOMAIN` as the override (matches\n // the SDK's `ConnectionConfig` default), so we construct the URL locally\n // and never wake the box for a UI/dashboard URL fetch.\n const domain = process.env.E2B_DOMAIN ?? DEFAULT_E2B_DOMAIN;\n return { url: `https://${String(port)}-${h.sandboxId}.${domain}`, token: undefined };\n },\n\n // Fewer params than the interface's (h, port, expiresInSeconds) is fine —\n // E2B preview URLs are already public + browser-usable; no per-URL TTL.\n async signedPreviewUrl(h: CloudHandle, port: number): Promise<CloudPreviewUrl> {\n return this.previewUrl(h, port);\n },\n\n /**\n * Probe whether a snapshot (i.e. a template id) is still bootable. E2B's\n * snapshot ids look like `template-id:tag` or `team-slug/name:tag` — both\n * accepted by `Template.exists(name)`. Returns false on any lookup failure\n * (treated by the cloud-provider as \"gone\" so it falls back to a from-base\n * boot rather than 410ing the user).\n */\n async snapshotExists(snapshotName: string): Promise<boolean> {\n const apiKey = resolveApiKey();\n return withE2bRetry({ method: 'snapshotExists', retryOnAmbiguous: true }, async () => {\n try {\n return await Template.exists(snapshotName, { apiKey });\n } catch {\n return false;\n }\n });\n },\n};\n","/**\n * Bounded retry wrapper for E2B SDK calls — mirrors `withVercelRetry` /\n * `withHetznerRetry` in shape and intent. The E2B API rate-limits (429) and\n * can return transient 5xx during incidents; without bounded retries those\n * propagate as wedges in the calling lifecycle code.\n *\n * Non-idempotent ops (`provision`/`Sandbox.create`) pass `retryOnAmbiguous:\n * false` so a timeout after the request reached the origin doesn't create a\n * duplicate billable sandbox.\n */\n\nexport interface WithRetryOptions {\n method: string;\n /** Per-attempt timeout (ms). Default 30_000. */\n attemptTimeoutMs?: number;\n /** Backoff before attempts 2, 3, … (ms). Default [1000, 2000, 4000]. */\n backoffMs?: readonly number[];\n /**\n * Retry on errors where we can't be sure the server applied the request\n * (connection failures, per-attempt timeouts, 5xx). Set false for\n * non-idempotent operations where a retry could create a duplicate resource.\n */\n retryOnAmbiguous: boolean;\n /** Override the default stderr retry sink (used by tests). */\n onRetry?: (line: string) => void;\n}\n\nconst DEFAULT_BACKOFF: readonly number[] = [1000, 2000, 4000];\nconst DEFAULT_ATTEMPT_TIMEOUT_MS = 30_000;\n\nclass AttemptTimeoutError extends Error {\n constructor(method: string, ms: number) {\n super(`e2b ${method}: per-attempt timeout after ${String(ms)}ms`);\n this.name = 'AttemptTimeoutError';\n }\n}\n\nexport function isAttemptTimeout(err: unknown): err is AttemptTimeoutError {\n return err instanceof AttemptTimeoutError;\n}\n\n/** HTTP status code dug out of whatever error shape the SDK throws. */\nfunction statusCodeOf(err: unknown): number | undefined {\n if (!err || typeof err !== 'object') return undefined;\n for (const key of ['statusCode', 'status', 'code'] as const) {\n const v = (err as Record<string, unknown>)[key];\n if (typeof v === 'number') return v;\n }\n const resp = (err as { response?: { status?: unknown } }).response;\n if (resp && typeof resp.status === 'number') return resp.status;\n return undefined;\n}\n\nexport function isRetriable(err: unknown, allowAmbiguous: boolean): boolean {\n if (err instanceof AttemptTimeoutError) return allowAmbiguous;\n\n // The SDK exposes a dedicated `SandboxNotFoundError` and `RateLimitError`.\n // Match by error name to avoid an import cycle (sdk.ts → retry → sdk).\n const name = err instanceof Error ? err.name : undefined;\n if (name === 'RateLimitError') return true;\n if (name === 'SandboxNotFoundError') return false;\n\n const status = statusCodeOf(err);\n if (status !== undefined) {\n if (status === 429) return true;\n if (status >= 500 && status <= 599) return allowAmbiguous;\n return false;\n }\n\n // Raw fetch / undici errors. Node wraps low-level errors in `{ cause }`.\n if (err && typeof err === 'object') {\n const candidates: unknown[] = [err, (err as { cause?: unknown }).cause];\n for (const c of candidates) {\n if (!c || typeof c !== 'object') continue;\n const code = (c as { code?: unknown }).code;\n if (\n code === 'ECONNRESET' ||\n code === 'ETIMEDOUT' ||\n code === 'ECONNABORTED' ||\n code === 'EAI_AGAIN' ||\n code === 'ECONNREFUSED' ||\n code === 'ENOTFOUND' ||\n code === 'UND_ERR_SOCKET' ||\n code === 'UND_ERR_CONNECT_TIMEOUT'\n ) {\n return allowAmbiguous;\n }\n }\n }\n return false;\n}\n\nexport async function withE2bRetry<T>(opts: WithRetryOptions, fn: () => Promise<T>): Promise<T> {\n const backoff = opts.backoffMs ?? DEFAULT_BACKOFF;\n const maxAttempts = backoff.length + 1;\n const timeoutMs = opts.attemptTimeoutMs ?? DEFAULT_ATTEMPT_TIMEOUT_MS;\n const log = opts.onRetry ?? defaultRetryLog;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await raceTimeout(fn(), timeoutMs, opts.method);\n } catch (err) {\n const last = attempt === maxAttempts;\n if (last || !isRetriable(err, opts.retryOnAmbiguous)) throw err;\n const delay = backoff[attempt - 1] ?? backoff[backoff.length - 1] ?? 4000;\n log(\n `e2b ${opts.method}: attempt ${String(attempt)} failed (${errorSummary(err)}); retrying in ${String(delay)}ms`,\n );\n await sleep(delay);\n }\n }\n throw new Error(`withE2bRetry: exhausted attempts for ${opts.method}`);\n}\n\nfunction defaultRetryLog(line: string): void {\n process.stderr.write(`\\n[e2b-retry] ${line}\\n`);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nasync function raceTimeout<T>(p: Promise<T>, ms: number, method: string): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n p,\n new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new AttemptTimeoutError(method, ms)), ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\nfunction errorSummary(err: unknown): string {\n if (err instanceof Error) {\n const status = statusCodeOf(err);\n return status !== undefined\n ? `${err.name}(${String(status)}): ${truncate(err.message)}`\n : `${err.name}: ${truncate(err.message)}`;\n }\n return truncate(String(err));\n}\n\nfunction truncate(s: string, max = 160): string {\n return s.length > max ? `${s.slice(0, max)}…` : s;\n}\n","/**\n * `agentbox prepare --provider e2b` — bake the E2B base template.\n *\n * Unlike Vercel/Hetzner, E2B can build templates from a build DSL (the SDK's\n * `Template` + `Template.build`). We mirror Vercel's `prepare` shape but drive\n * the build through the SDK builder API instead of booting a sandbox + running\n * `provision.sh`:\n *\n * 1. Resolve runtime assets + fingerprint the build context. Skip-fast when\n * an up-to-date template id is already recorded.\n * 2. Stage every resolved asset under a temp `fileContextPath` directory\n * with predictable relative names (E2B's `template.copy(src, dest)`\n * requires sources to be RELATIVE paths inside the context dir).\n * 3. `Template({ fileContextPath })` → `.fromBaseImage()` (E2B's default\n * Debian 12 + node 20 + git + sudo). `.copy(rel, dest)` for each asset,\n * `.runCmd('bash /tmp/agentbox-build-template.sh', { user: 'root' })`,\n * `.setReadyCmd('test -x /usr/local/bin/agentbox-ctl')`.\n * 4. `Template.build(t, 'agentbox-base:<tag>', { cpuCount, memoryMB,\n * onBuildLogs })` streams logs into the spinner; returns the BuildInfo\n * with the template id.\n * 5. Persist `{ schema:1, base: { templateId, contextSha256, cliVersion,\n * cliCommit, createdAt } }` to ~/.agentbox/e2b-prepared.json.\n *\n * Templates on E2B are reusable named resources addressed by id+tag. Re-running\n * with the same name reuses the existing template id (E2B's documented\n * behavior). Unlike Vercel snapshots there's no per-box eviction concern; one\n * template is reused for every create.\n *\n * vCPU / RAM are template-level on E2B — set them here so per-box `create`\n * doesn't try to override them (which E2B rejects).\n */\n\nimport { copyFile, mkdir, mkdtemp, rm } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport type { Provider } from '@agentbox/core';\nimport {\n claudeInstallFingerprint,\n computeContextSha256,\n readCliStamp,\n stageAllAgentStatic,\n type AgentStaticStage,\n} from '@agentbox/sandbox-core';\nimport { ensureE2bCredentials } from './credentials.js';\nimport { resolveApiKey, Template } from './sdk.js';\nimport {\n preparedStatePath,\n readPreparedState,\n writePreparedState,\n} from './prepared-state.js';\nimport {\n findStagedCliRuntimeRoot,\n resolveRuntimeAssets,\n type ResolvedAsset,\n} from './runtime-assets.js';\n\nexport interface PrepareE2bOptions {\n name?: string;\n hostWorkspace?: string;\n /** Force re-bake even when an up-to-date template id is recorded. */\n force?: boolean;\n /** vCPUs for the baked template (default 2). E2B applies this per-sandbox at boot. */\n cpuCount?: number;\n /** Memory in MiB for the baked template (default 4096). */\n memoryMB?: number;\n /** CLI runtime tree (set by the CLI to its dist neighbor). */\n cliRuntimeRoot?: string;\n /** Repo root for the dev fallback (defaults to a cwd-walk). */\n repoRoot?: string;\n /** How build-template.sh installs Claude Code (`native` default | `npm`). */\n claudeInstall?: 'native' | 'npm';\n onLog?: (line: string) => void;\n}\n\nexport interface PrepareE2bResult {\n snapshotName?: string;\n}\n\n/** Template name agentbox bakes under. E2B treats `name:tag` as a single addressable build. */\nconst TEMPLATE_NAME = 'agentbox-base:latest';\nconst DEFAULT_TAG = 'latest';\n\nconst DEFAULT_CPU = 2;\nconst DEFAULT_MEMORY_MB = 4096;\n\nexport async function prepareE2b(\n opts: PrepareE2bOptions = {},\n): Promise<PrepareE2bResult> {\n await ensureE2bCredentials();\n const apiKey = resolveApiKey();\n const log = opts.onLog ?? (() => {});\n const progress = (s: string) => log(`prepare-e2b: ${s}`);\n\n const assets = resolveRuntimeAssets({\n cliRuntimeRoot: opts.cliRuntimeRoot ?? findStagedCliRuntimeRoot(),\n repoRoot: opts.repoRoot,\n });\n const claudeInstall = opts.claudeInstall ?? 'native';\n const contextSha = claudeInstallFingerprint(\n await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),\n claudeInstall,\n );\n\n // Skip-fast: existing template + matching fingerprint.\n //\n // Probe the persisted templateId itself, not TEMPLATE_NAME. If someone\n // (or another bake) rebuilt the alias under a different id, the name still\n // resolves but the stored id is stale and `Sandbox.create({ template: <stale id> })`\n // 404s. `Template.exists` accepts both `name:tag` and `template-id:tag`\n // forms, so we pass the exact id we'd later hand to `provision`.\n const existing = readPreparedState();\n if (!opts.force && existing.base) {\n if (existing.base.contextSha256 === contextSha) {\n const stillThere = await templateExists(existing.base.templateId, apiKey);\n if (stillThere) {\n progress(\n `template ${existing.base.templateId} already exists (fingerprint ${contextSha.slice(0, 12)} matches); skipping (pass --force to rebuild)`,\n );\n return { snapshotName: existing.base.templateId };\n }\n progress(`recorded template ${existing.base.templateId} is gone on E2B; rebuilding`);\n } else {\n progress(\n `build context changed (was ${existing.base.contextSha256?.slice(0, 12) ?? '<none>'}, now ${contextSha.slice(0, 12)}); rebuilding`,\n );\n }\n }\n\n // E2B's `template.copy(src, dest)` requires `src` to be a RELATIVE path\n // inside the Template's `fileContextPath`. Stage every resolved asset into\n // a temp dir under its logical name (asset.name) so the copy chain reads\n // from a single context root.\n const contextDir = await mkdtemp(join(tmpdir(), 'agentbox-e2b-build-'));\n let agentStages: AgentStaticStage[] = [];\n try {\n progress(`staging build context at ${contextDir}`);\n await stageAssetsInto(contextDir, assets);\n\n // Stage the host's per-tool static config (shared sync-layer producer) and\n // copy each tarball into the build context (E2B copy sources must be\n // relative to fileContextPath).\n agentStages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });\n for (const s of agentStages) for (const w of s.staged.warnings) log(w);\n const usableStages = agentStages.filter((s) => s.staged.tarballPath !== null);\n for (const s of usableStages) {\n await copyFile(s.staged.tarballPath as string, resolve(contextDir, e2bStagePaths(s.kind).contextRel));\n }\n\n // Build the Template via the SDK builder. fromBaseImage() starts from E2B's\n // own `e2bdev/base` (Debian 12 + node 20 + git + sudo), which halves the\n // install time vs starting from a vanilla Debian image.\n progress('assembling template build (fromBaseImage + asset copy + runCmd)');\n const template = Template({ fileContextPath: contextDir }).fromBaseImage();\n for (const a of assets) {\n progress(` copy ${a.name} -> ${a.remotePath}`);\n template.copy(a.name, a.remotePath, {\n forceUpload: true,\n mode: a.remoteMode,\n user: 'root',\n });\n }\n template.runCmd(`AGENTBOX_CLAUDE_INSTALL=${claudeInstall} bash /tmp/agentbox-build-template.sh 2>&1`, {\n user: 'root',\n });\n\n // Seed the host's static agent config ON TOP of the built box (the vscode\n // user + home dirs exist only after build-template.sh). Copy each staged\n // tarball into the build, then one root pass extracts + chowns them —\n // mirrors Vercel/Hetzner/Daytona's host-static bake.\n for (const s of usableStages) {\n const { contextRel, remoteTar } = e2bStagePaths(s.kind);\n progress(` seed ${s.kind} static -> ${s.extractDir}`);\n template.copy(contextRel, remoteTar, { forceUpload: true, mode: 0o644, user: 'root' });\n }\n if (usableStages.length > 0) {\n const extract =\n usableStages\n .map((s) => `mkdir -p ${s.extractDir} && tar -xzf ${e2bStagePaths(s.kind).remoteTar} -C ${s.extractDir} --no-same-permissions --no-same-owner -m`)\n .join(' && ') +\n ' && chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local' +\n ' && ([ -d /home/vscode/.agents ] && chown -R vscode:vscode /home/vscode/.agents || true)' +\n ' && rm -f /tmp/agentbox-seed-*.tar.gz';\n template.runCmd(extract, { user: 'root' });\n }\n // setReadyCmd flips the builder into TemplateFinal — required for build().\n // The check passes once the script's last `install` step lands the ctl bundle.\n const finalTemplate = template.setReadyCmd(\n 'test -x /usr/local/bin/agentbox-ctl',\n );\n\n const cpuCount = opts.cpuCount ?? DEFAULT_CPU;\n const memoryMB = opts.memoryMB ?? DEFAULT_MEMORY_MB;\n progress(\n `running Template.build('${TEMPLATE_NAME}', { cpuCount: ${String(cpuCount)}, memoryMB: ${String(memoryMB)} })`,\n );\n const info = await Template.build(finalTemplate, TEMPLATE_NAME, {\n apiKey,\n cpuCount,\n memoryMB,\n onBuildLogs: (entry: LogEntryLike) => {\n // LogEntry exposes timestamp / level / message; stream the human form.\n log(`[build] ${formatBuildLog(entry)}`);\n },\n });\n progress(`template built: id=${info.templateId} build=${info.buildId} name=${info.name}`);\n\n // Persist. `Sandbox.create({ template })` auto-appends `:default` when no\n // tag is given (and 404s if that tag wasn't built), so we MUST store the\n // tagged form. `info.templateId` is just the raw id with no tag; use the\n // first tag we built with (`latest`) or fall back to `info.tags[0]`.\n const tag = info.tags?.[0] ?? DEFAULT_TAG;\n const cliStamp = readCliStamp();\n const taggedId = `${info.templateId}:${tag}`;\n writePreparedState({\n schema: 1,\n base: {\n templateId: taggedId,\n // info.name is the full `name:tag` pair Template.build() was called\n // with (e.g. `agentbox-base:latest`). Earlier code re-appended `:${tag}`\n // and produced `agentbox-base:latest:latest` in the status display.\n templateName: info.name,\n contextSha256: contextSha,\n cliVersion: cliStamp.cliVersion,\n cliCommit: cliStamp.cliCommit,\n createdAt: new Date().toISOString(),\n },\n });\n progress(`wrote ${preparedStatePath()}`);\n\n progress(`prepare complete — base template ${taggedId}`);\n return { snapshotName: taggedId };\n } finally {\n await Promise.all(agentStages.map((s) => s.staged.cleanup())).catch(() => {\n // best-effort: staged-tarball cleanup failures are noise.\n });\n await rm(contextDir, { recursive: true, force: true }).catch(() => {\n // best-effort: temp dir cleanup failures are noise, not errors.\n });\n }\n}\n\n/**\n * Copy every asset into `contextDir` under its logical `name`. Preserves the\n * source mode on the copy (E2B's `template.copy` also accepts a `mode`\n * override, but the on-disk mode keeps the local stage representative).\n */\nasync function stageAssetsInto(\n contextDir: string,\n assets: ResolvedAsset[],\n): Promise<void> {\n for (const a of assets) {\n const dest = resolve(contextDir, a.name);\n await mkdir(dirname(dest), { recursive: true });\n await copyFile(a.localPath, dest);\n }\n}\n\n/** E2B build paths for a staged tool (derived from its kind). E2B copy sources\n * must be RELATIVE to the Template `fileContextPath`, so the tarball is staged\n * into the context dir under `contextRel` then copied to `remoteTar`. */\nfunction e2bStagePaths(kind: AgentStaticStage['kind']): { contextRel: string; remoteTar: string } {\n return {\n contextRel: `agentbox-seed-${kind}.tar.gz`,\n remoteTar: `/tmp/agentbox-seed-${kind}.tar.gz`,\n };\n}\n\n/**\n * Check if a named template is bootable on E2B. Returns true on a 'ready'\n * build, false on anything else (deleted, errored, never built). Used by the\n * skip-fast path to detect a template that was deleted out-of-band.\n */\nasync function templateExists(name: string, apiKey: string): Promise<boolean> {\n try {\n return await Template.exists(name, { apiKey });\n } catch {\n return false;\n }\n}\n\n/**\n * E2B's `LogEntry` shape (timestamp, level, message). We treat the SDK's\n * type loosely here so the line-stream doesn't bind us to internal class\n * shapes — only the `.toString()` plus `.message` are documented.\n */\ninterface LogEntryLike {\n message?: string;\n level?: string;\n timestamp?: Date;\n toString(): string;\n}\n\nfunction formatBuildLog(entry: LogEntryLike): string {\n // The SDK's LogEntry.toString() emits a `[level] timestamp message` form.\n // For the spinner we only want the message — and clip overly long lines.\n const raw = typeof entry.message === 'string' ? entry.message : entry.toString();\n const cleaned = raw.replace(/\\r?\\n+$/, '');\n return cleaned.length > 200 ? cleaned.slice(0, 200) + '…' : cleaned;\n}\n\n/** Provider-level binding used by the CLI's `prepare` command. */\nexport const prepareE2bProvider: NonNullable<Provider['prepare']> = (req) =>\n prepareE2b({\n name: req.name,\n hostWorkspace: req.hostWorkspace ?? process.cwd(),\n force: req.force,\n claudeInstall: req.claudeInstall,\n onLog: req.onLog,\n });\n","/**\n * `buildE2bAttach` — the E2B provider's override of `Provider.buildAttach`.\n *\n * E2B has no SSH and no public PTY CLI like Vercel's `sbx exec -i`. We ship\n * our own attach helper (`attach-helper.cjs`) that connects to the sandbox via\n * the SDK and bridges the host PTY to an in-box `sandbox.pty.create()`.\n *\n * Argv shape:\n * node <attach-helper.cjs> --sandbox-id <id> --user vscode\n *\n * The inner bash command (`renderInnerCommand` output: tmux ensure + attach)\n * is passed through the environment as `AGENTBOX_E2B_INNER_CMD` so quoting\n * stays sane and it doesn't leak through `ps`. `E2B_API_KEY` is passed through\n * the env for the same reason. `node-pty` (the host PTY wrapper) is what\n * spawns this argv, so stdin/stdout/SIGWINCH all reach the helper unchanged.\n */\n\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n type AttachKind,\n type AttachSpec,\n type BoxRecord,\n type BuildAttachOptions,\n} from '@agentbox/core';\nimport { hostTermForCloud, renderInnerCommand } from '@agentbox/sandbox-cloud';\nimport { resolveApiKey } from './sdk.js';\n\nconst SELF = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Resolve the absolute path to `attach-helper.cjs`. In the published CLI it\n * lives at `runtime/e2b/attach-helper.cjs` (next to the staged provider\n * runtime tree); in dev it lives next to the package's `dist/`.\n */\nexport function resolveAttachHelperPath(): string {\n const candidates = [\n // dev: dist/index.js sibling\n resolve(SELF, 'attach-helper.cjs'),\n // dev: src compiled to dist/, while index.ts is in src/\n resolve(SELF, '..', 'dist', 'attach-helper.cjs'),\n // staged CLI: apps/cli/runtime/e2b/attach-helper.cjs\n resolve(SELF, '..', 'runtime', 'e2b', 'attach-helper.cjs'),\n resolve(SELF, '..', '..', 'runtime', 'e2b', 'attach-helper.cjs'),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n // Last-resort: still return the first candidate so the error message points\n // somewhere informative.\n return candidates[0]!;\n}\n\nexport async function buildE2bAttach(\n box: BoxRecord,\n kind: AttachKind,\n opts?: BuildAttachOptions,\n): Promise<AttachSpec> {\n const sandboxId = box.cloud?.sandboxId;\n if (!sandboxId) {\n throw new Error(`e2b box ${box.name} has no sandboxId — record is malformed`);\n }\n\n const helper = resolveAttachHelperPath();\n if (!existsSync(helper)) {\n throw new Error(\n `e2b attach helper not found at ${helper} — rebuild the CLI (\\`pnpm -w build\\`) ` +\n 'so packages/sandbox-e2b/dist/attach-helper.cjs is generated.',\n );\n }\n\n const apiKey = resolveApiKey();\n const inner = renderInnerCommand(kind, opts);\n // Forward the host's TERM (the helper has no host env once node-pty spawns\n // it, so pass it explicitly). The helper sets it on the in-box PTY; the\n // renderInnerCommand TERM guard downgrades to xterm-256color when the box's\n // terminfo doesn't carry it (e.g. xterm-ghostty), matching the docker path.\n const hostTerm = hostTermForCloud();\n\n const argv = [\n process.execPath,\n helper,\n '--sandbox-id',\n sandboxId,\n '--user',\n 'vscode',\n ];\n // Detached pre-start (new-tab attach / `-i` queue worker): the inner command\n // only creates the tmux session (no `exec tmux attach`). The helper must run\n // it once and EXIT rather than open a persistent interactive PTY that idles\n // forever — otherwise the host's `runDetached` await never resolves and\n // `agentbox <agent>` hangs after \"box ready\". See attach-helper.ts header.\n if (opts?.detached) argv.push('--detached');\n\n return {\n argv,\n env: {\n E2B_API_KEY: apiKey,\n AGENTBOX_E2B_INNER_CMD: inner,\n AGENTBOX_HOST_TERM: hostTerm,\n },\n };\n}\n","/**\n * Doctor probes + normalized credential status for the e2b provider,\n * assembled into `providerModule` in `index.ts`. Moved out of apps/cli so the\n * CLI dispatches to it generically (see `@agentbox/sandbox-core`'s `ProviderModule`).\n */\n\nimport { errSummary, type CheckResult, type CredStatusSummary } from '@agentbox/sandbox-core';\nimport { readE2bCredStatus } from './credentials.js';\nimport { readPreparedState } from './prepared-state.js';\n\nexport function readCredStatusSummary(): CredStatusSummary {\n const cred = readE2bCredStatus();\n return { configured: cred.auth !== 'none', label: cred.auth };\n}\n\nexport async function doctorChecks(): Promise<CheckResult[]> {\n try {\n const cred = readE2bCredStatus();\n const credRes: CheckResult =\n cred.auth === 'none'\n ? {\n label: 'credentials',\n status: 'warn',\n detail: 'not configured',\n hint: '`agentbox e2b login`',\n }\n : { label: 'credentials', status: 'ok', detail: `${cred.auth} (${cred.source})` };\n\n const prepared = readPreparedState();\n const tmplRes: CheckResult = prepared.base?.templateId\n ? {\n label: 'base template',\n status: 'ok',\n detail: `${prepared.base.templateName ?? prepared.base.templateId} (${prepared.base.cliVersion ?? '—'})`,\n }\n : {\n label: 'base template',\n status: 'warn',\n detail: 'not baked',\n hint: '`agentbox prepare --provider e2b`',\n };\n return [credRes, tmplRes];\n } catch (err) {\n return [{ label: 'credentials', status: 'warn', detail: errSummary(err) }];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgCA,SAAS,gBAAgB;AEAzB,SAAS,UAAU,OAAO,SAAS,UAAU;AAC7C,SAAS,cAAc;AACvB,SAAS,SAAS,MAAM,eAAe;ACjBvC,SAAS,kBAAkB;AAC3B,SAAS,WAAAA,UAAS,WAAAC,gBAAe;AACjC,SAAS,qBAAqB;AFQ9B,IAAM,kBAAqC,CAAC,KAAM,KAAM,GAAI;AAC5D,IAAM,6BAA6B;AAEnC,IAAM,sBAAN,cAAkC,MAAM;EACtC,YAAY,QAAgB,IAAY;AACtC,UAAM,OAAO,MAAM,+BAA+B,OAAO,EAAE,CAAC,IAAI;AAChE,SAAK,OAAO;EACd;AACF;AAOA,SAAS,aAAa,KAA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,QAAI;AACF,YAAM,UAAU,EAAE,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,OAAO,WAAW,SAAS,EAAE,CAAC;IAC1E,QAAQ;IAER;AACA,UAAM,OAAO,MAAM,6BAA6B,IAAI,aAAa,cAAc,MAAM;MACnF,cAAc;MACd,aAAa,IAAI;MACjB,eAAe,IAAI;MACnB,cAAc;MACd,iBAAiB,4BAA4B,YAAY;MACzD,YAAYC,aAAa,EAAE;IAC7B,CAAC;AACD,WAAO,EAAE,KAAK,KAAK,KAAK;EAC1B;EACA,MAAM,KAAK,aAAqB;AAC9B,UAAM,UAAU,MAAM,qBAAqB,aAAa,YAAY;AACpE,WAAO,QAAQ,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,EAAE,SAAS,UAAU,EAAE;EAC9E;EACA,MAAM,OAAO,aAAqB,KAAa;AAC7C,UAAM,QAAQ,MAAM,uBAAuB,aAAa,cAAc,GAAG;AACzE,QAAI,CAAC,MAAO;AACZ,QAAI;AACF,YAAM,kBAAkB,MAAM,SAAS,YAAY;IACrD,QAAQ;IAGR;AACA,UAAM,yBAAyB,aAAa,cAAc,GAAG;EAC/D;AACF;AAEO,IAAM,cAAwB;EACnC,GAAG;EACH,SAAS;EACT,aAAa;EACb,YAAY;EACZ,iBAAiB,MAAM,8BAA8B;AACvD;AAGO,IAAM,iBAAiC;EAC5C,UAAU;EACV,SAAS;EACT,mBAAmB;EACnB,gBAAgB;EAChB,gBAAgB,CAAC,WAAW,QAAQ,QAAQ,kBAAkB,MAAM,CAAC;EACrE,4BAA4B,CAAC,kBAAkB,8BAA8B,aAAa;EAC1F;AACF;","names":["dirname","resolve","snapshotName","dirname","resolve","readCliStamp"]}
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,33789,1485,e=>{"use strict";var t=e.i(1262),s=e.i(54129);e.s(["Ago",0,function({ms:e}){let[a,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>r(!0),[]),(0,t.jsx)("span",{suppressHydrationWarning:!0,children:a?function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return t+"s ago";let s=Math.floor(t/60);if(s<60)return s+"m ago";let a=Math.floor(s/60);return a<24?a+"h ago":Math.floor(a/24)+"d ago"}(e):new Date(e).toLocaleDateString()})}],33789),e.s(["SectionLabel",0,function({children:e,right:s}){return(0,t.jsxs)("div",{className:"mb-3 mt-8 flex items-center gap-2.5 font-mono text-[11px] uppercase tracking-[.1em] text-[#a4a9b0]",children:[e,(0,t.jsx)("span",{className:"h-px flex-1 bg-border"}),s??null]})}],1485)},8536,e=>{"use strict";var t=e.i(1262),s=e.i(65232);e.s(["Card",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,s.cn)("rounded-xl border border-border bg-card text-card-foreground",e),...a})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,s.cn)("p-5 pt-0",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,s.cn)("text-[12.5px] text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,s.cn)("flex flex-col space-y-1 p-5",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,s.cn)("text-[15px] font-semibold leading-none tracking-tight",e),...a})}])},3060,e=>{"use strict";var t=e.i(1262),s=e.i(65232);e.s(["Input",0,function({className:e,...a}){return(0,t.jsx)("input",{className:(0,s.cn)("flex h-10 w-full rounded-lg border border-input bg-card px-3 py-1 text-sm shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...a})}])},86184,e=>{"use strict";var t=e.i(1262),s=e.i(54129),a=e.i(69377),r=e.i(3060);function n({jobId:e,login:l}){let[i,o]=(0,s.useState)(""),[d,c]=(0,s.useState)(!1),[x,u]=(0,s.useState)(null),p="exchanging"===l.phase,m=async()=>{let t=i.trim();if(t&&!d){c(!0),u(null);try{let s=await fetch(`/api/v1/jobs/${encodeURIComponent(e)}/login-code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})});if(!s.ok){let e=await s.json().catch(()=>null);u(e?.error?.message??`request failed (${s.status})`);return}o("")}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-amber-200",children:"Claude login required"}),(0,t.jsx)("p",{className:"text-xs text-amber-100/80",children:"Your saved Claude login is expired. Open the sign-in page, approve access, then paste the code Claude shows you."}),l.url?(0,t.jsx)("a",{href:l.url,target:"_blank",rel:"noreferrer",className:"w-fit rounded-md bg-amber-500/20 px-2.5 py-1 text-xs font-medium text-amber-100 underline decoration-amber-400/50 underline-offset-2 hover:bg-amber-500/30",children:"Open Claude sign-in ↗"}):(0,t.jsx)("span",{className:"text-xs text-amber-100/60",children:"waiting for the sign-in link…"}),(0,t.jsxs)("div",{className:"mt-1 flex gap-2",children:[(0,t.jsx)(r.Input,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&m()},placeholder:"Paste approval code",disabled:p,className:"flex-1 font-mono text-xs"}),(0,t.jsx)(a.Button,{type:"button",onClick:()=>void m(),disabled:!i.trim()||d||p,children:p?"Verifying…":d?"Submitting…":"Submit"})]}),l.lastError?(0,t.jsx)("p",{className:"text-xs text-amber-300",children:l.lastError}):null,"error"===l.phase&&l.error?(0,t.jsx)("p",{className:"text-xs text-red-400",children:l.error}):null,x?(0,t.jsx)("p",{className:"text-xs text-red-400",children:x}):null]})}e.s(["JobLogStream",0,function({jobId:e,endpoint:a,onDone:r,onStatus:l,onLogin:i}){let[o,d]=(0,s.useState)([]),[c,x]=(0,s.useState)(null),u=(0,s.useRef)(null),p=(0,s.useRef)(r);p.current=r;let m=(0,s.useRef)(l);m.current=l;let f=(0,s.useRef)(i);return f.current=i,(0,s.useEffect)(()=>{m.current?.("streaming");let t=new EventSource(a??`/api/jobs/${encodeURIComponent(e)}/logs`);return t.addEventListener("log",e=>{let t=JSON.parse(e.data);d(e=>[...e,t])}),t.addEventListener("login",e=>{let t=JSON.parse(e.data);x(t),f.current?.(t)}),t.addEventListener("end",e=>{let s=JSON.parse(e.data);m.current?.(s.status),p.current?.(s.status),t.close()}),()=>t.close()},[e,a]),(0,s.useEffect)(()=>{let e=u.current;e&&(e.scrollTop=e.scrollHeight)},[o]),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[c&&"done"!==c.phase?(0,t.jsx)(n,{jobId:e,login:c}):null,(0,t.jsx)("pre",{ref:u,className:"max-h-[440px] min-h-[220px] overflow-auto whitespace-pre rounded-lg bg-[#16181c] p-3 font-mono text-[11.5px] leading-relaxed text-[#d6d9de]",children:0===o.length?"starting…":o.join("\n")})]})}])},50557,e=>{"use strict";var t=e.i(1262),s=e.i(54129),a=e.i(33789),r=e.i(44344),n=e.i(64595),l=e.i(8536),i=e.i(65232);function o({className:e,...s}){return(0,t.jsx)("div",{className:(0,i.cn)("h-px w-full shrink-0 bg-border",e),...s})}var d=e.i(96621),c=e.i(1485),x=e.i(45971),u=e.i(69377),p=e.i(3060),m=e.i(86184);let f={docker:[],e2b:[{key:"apiKey",label:"API key",placeholder:"e2b_…"}],daytona:[{key:"apiKey",label:"API key",placeholder:"dtn_…"}],hetzner:[{key:"token",label:"API token",placeholder:"project read+write token"}],vercel:[{key:"token",label:"Access token",placeholder:"vercel token"},{key:"teamId",label:"Team ID",placeholder:"team_… (optional)",optional:!0},{key:"projectId",label:"Project ID",placeholder:"prj_… (optional)",optional:!0}]};function h(){let{state:e}=(0,d.useStore)(),[a,r]=(0,s.useState)({});return(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/v1/providers?freshness=1",{credentials:"same-origin"});if(!t.ok)return;let s=await t.json();if(e)return;let a={};for(let e of s.providers??[])a[e.id]={baseStatus:e.baseStatus,baseStaleReason:e.baseStaleReason};r(a)}catch{}})(),()=>{e=!0}},[e.providers]),(0,t.jsx)(l.Card,{className:"divide-y divide-border/60 overflow-hidden",children:e.providers.map(e=>(0,t.jsx)(g,{provider:{...e,...a[e.id]}},e.id))})}function g({provider:e}){var a;let l=(0,x.useRouter)(),o=f[e.id]??[],d=new Set(o.filter(e=>!e.optional).map(e=>e.key)),[c,h]=(0,s.useState)({}),[b,j]=(0,s.useState)(()=>e.hasCredentials?Object.fromEntries(o.filter(e=>!e.optional).map(e=>[e.key,!0])):{}),[v,N]=(0,s.useState)(!1),[y,k]=(0,s.useState)(null),[S,w]=(0,s.useState)(!e.hasCredentials&&o.length>0),[C,I]=(0,s.useState)(e.jobId??null),[B,E]=(0,s.useState)(!1),[R,A]=(0,s.useState)(null),O=async()=>{N(!0),k(null);try{let t={};for(let e of o){if(b[e.key])continue;let s=(c[e.key]??"").trim();s&&(t[e.key]=s)}let s=await fetch(`/api/v1/providers/${encodeURIComponent(e.id)}/credentials`,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)});if(!s.ok){let e=await s.json().catch(()=>null);k(e?.error?.message??`request failed (${s.status})`);return}h({}),j(Object.fromEntries([...d].map(e=>[e,!0]))),w(!1),l.refresh()}catch(e){k(e instanceof Error?e.message:String(e))}finally{N(!1)}},z=async()=>{E(!0),A(null);try{let t=await fetch(`/api/v1/providers/${encodeURIComponent(e.id)}/prepare`,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(e.configured?{force:!0}:{})}),s=await t.json().catch(()=>null);if(!t.ok||!s?.jobId)return void A(s?.error?.message??`request failed (${t.status})`);I(s.jobId)}catch(e){A(e instanceof Error?e.message:String(e))}finally{E(!1)}},P="docker"===e.id||e.hasCredentials,L=o.length>0;return(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-4 px-5",children:[(0,t.jsxs)("div",{className:(0,i.cn)("flex items-center gap-3",L&&"cursor-pointer"),onClick:L?()=>w(e=>!e):void 0,children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[14px] font-semibold",children:[e.label,(a=e).configured?"stale"===a.baseStatus?(0,t.jsx)(n.Badge,{className:"badge-warn gap-1.5 normal-case",title:a.baseStaleReason,children:"stale — re-bake"}):"unprepared"===a.baseStatus?(0,t.jsx)(n.Badge,{className:"gap-1.5 normal-case",children:"needs bake"}):(0,t.jsxs)(n.Badge,{className:"badge-run gap-1.5 normal-case",children:[(0,t.jsx)("span",{className:"badge-dot"}),"ready"]}):a.hasCredentials?(0,t.jsx)(n.Badge,{className:"gap-1.5 normal-case",children:"needs bake"}):(0,t.jsx)(n.Badge,{className:"gap-1.5 normal-case",children:"needs credentials"})]}),e.reason?(0,t.jsx)("div",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:e.reason}):null]}),(0,t.jsx)("div",{className:"flex flex-none items-center gap-2",onClick:e=>e.stopPropagation(),children:(0,t.jsxs)(u.Button,{type:"button",size:"sm",variant:e.configured?"outline":"default",disabled:!P||B||!!C,onClick:()=>void z(),title:P?void 0:"Add credentials first",children:[(0,t.jsx)(r.Icons.refresh,{className:"size-3.5"}),C?"Baking…":B?"Starting…":e.configured?"Re-bake":"Bake image"]})}),L?(0,t.jsx)(r.Icons.chevR,{className:(0,i.cn)("size-4 flex-none text-muted-foreground transition-transform",S&&"rotate-90")}):(0,t.jsx)("span",{className:"size-4 flex-none","aria-hidden":!0})]}),S&&o.length>0?(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-border/70 bg-card/50 p-3",children:[o.map(e=>(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("label",{className:"text-[11.5px] font-medium text-muted-foreground",children:[e.label,e.optional?" (optional)":""]}),(0,t.jsx)(p.Input,{type:"password",autoComplete:"off",value:b[e.key]?"••••••••••••":c[e.key]??"",placeholder:e.placeholder,onFocus:()=>{b[e.key]&&(j(t=>({...t,[e.key]:!1})),h(t=>({...t,[e.key]:""})))},onBlur:()=>{d.has(e.key)&&!(c[e.key]??"").trim()&&j(t=>({...t,[e.key]:!0}))},onChange:t=>h(s=>({...s,[e.key]:t.target.value})),className:"font-mono text-xs"})]},e.key)),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsx)(u.Button,{type:"button",size:"sm",disabled:v,onClick:()=>void O(),children:v?"Saving…":"Save credentials"}),y?(0,t.jsx)("span",{className:"text-xs text-red-400",children:y}):null]})]}):null,R?(0,t.jsx)("div",{className:"text-xs text-red-400",children:R}):null,C?(0,t.jsx)(m.JobLogStream,{jobId:C,endpoint:`/api/v1/jobs/${encodeURIComponent(C)}/logs`,onDone:()=>{I(null),l.refresh()}}):null]})}e.s(["default",0,function(){let{state:e}=(0,d.useStore)(),x=e.github,[u,p]=(0,s.useState)(null);return(0,s.useEffect)(()=>{let e=!0;return fetch("/api/v1/health",{credentials:"same-origin"}).then(e=>e.ok?e.json():null).then(t=>{e&&t?.version&&p(t.version)}).catch(()=>{}),()=>{e=!1}},[]),(0,t.jsxs)("div",{className:"mx-auto w-full max-w-[1080px] px-8 pb-16 pt-8 max-sm:px-4",children:[(0,t.jsx)("h1",{className:"text-[25px] font-semibold leading-tight tracking-[-0.025em]",children:"Settings"}),(0,t.jsx)("div",{className:"mt-1.5 text-sm text-muted-foreground",children:"Providers, GitHub access & hub configuration."}),(0,t.jsx)(c.SectionLabel,{right:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-normal text-[#a4a9b0]",children:"credentials & base images"}),children:"Sandbox providers"}),(0,t.jsx)(h,{}),(0,t.jsx)(c.SectionLabel,{children:"GitHub App"}),x.available?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Card,{className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"flex items-center gap-4 p-5",children:[(0,t.jsx)("span",{className:"grid h-11 w-11 flex-none place-items-center rounded-xl bg-foreground text-background",children:(0,t.jsx)(r.Icons.github,{className:"size-6"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[14.5px] font-semibold",children:[x.appName,x.installed?(0,t.jsxs)(n.Badge,{className:"badge-run gap-1.5 normal-case",children:[(0,t.jsx)("span",{className:"badge-dot"}),"installed"]}):null]}),(0,t.jsx)("div",{className:"mt-0.5 font-mono text-[12.5px] text-muted-foreground",children:x.installed?`@${x.account}`:"Not installed"})]})]})}),(0,t.jsx)(c.SectionLabel,{right:(0,t.jsxs)("span",{className:"font-mono text-[11px] tracking-normal text-[#a4a9b0]",children:[x.repos.length," repos"]}),children:"Authorized repositories"}),(0,t.jsx)(l.Card,{className:"divide-y divide-border/60 overflow-hidden",children:x.repos.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)("span",{className:"grid h-[30px] w-[30px] flex-none place-items-center rounded-md border border-border bg-background text-secondary-foreground",children:(0,t.jsx)(r.Icons.repo,{className:"size-[15px]"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block font-mono text-[13px] font-medium",children:e.full}),(0,t.jsxs)("span",{className:"mt-0.5 flex items-center gap-3 font-mono text-[11.5px] text-muted-foreground",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsx)(r.LangDot,{lang:e.lang}),e.lang]}),(0,t.jsxs)("span",{children:["updated ",(0,t.jsx)(a.Ago,{ms:e.pushedAt})]}),(0,t.jsx)(n.Badge,{className:(0,i.cn)("px-1.5 py-0 text-[10px] uppercase tracking-[.03em]",e.private?"":"border-[var(--green-line)] text-primary"),children:e.private?"private":"public"})]})]})]},e.id))})]}):(0,t.jsxs)(l.Card,{className:"overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-4 p-5",children:[(0,t.jsx)("span",{className:"grid h-11 w-11 flex-none place-items-center rounded-xl bg-secondary text-muted-foreground",children:(0,t.jsx)(r.Icons.github,{className:"size-6"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[14.5px] font-semibold",children:["GitHub App",(0,t.jsx)(n.Badge,{className:"gap-1.5 normal-case",children:"not available"})]}),(0,t.jsx)("div",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:"The GitHub App leases repo-scoped tokens to cloud boxes from the hosted hub. On a local machine boxes use your own git credentials directly, so there is nothing to configure here."})]})]}),(0,t.jsx)(o,{}),(0,t.jsxs)("div",{className:"flex items-start gap-3 p-4 px-5 text-[12.5px] text-muted-foreground",children:[(0,t.jsx)(r.Icons.shield,{className:"mt-0.5 size-[15px] flex-none text-primary"}),(0,t.jsx)("span",{children:"Available when the hub runs in a hosted profile (hetzner or vercel)."})]})]}),(0,t.jsxs)("div",{className:"mt-10 text-center font-mono text-[11px] text-muted-foreground",children:["AgentBox ",u??"…"]})]})}],50557)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,33789,1485,e=>{"use strict";var r=e.i(1262),t=e.i(54129);e.s(["Ago",0,function({ms:e}){let[n,a]=(0,t.useState)(!1);return(0,t.useEffect)(()=>a(!0),[]),(0,r.jsx)("span",{suppressHydrationWarning:!0,children:n?function(e){let r=Math.floor((Date.now()-e)/1e3);if(r<60)return r+"s ago";let t=Math.floor(r/60);if(t<60)return t+"m ago";let n=Math.floor(t/60);return n<24?n+"h ago":Math.floor(n/24)+"d ago"}(e):new Date(e).toLocaleDateString()})}],33789),e.s(["SectionLabel",0,function({children:e,right:t}){return(0,r.jsxs)("div",{className:"mb-3 mt-8 flex items-center gap-2.5 font-mono text-[11px] uppercase tracking-[.1em] text-[#a4a9b0]",children:[e,(0,r.jsx)("span",{className:"h-px flex-1 bg-border"}),t??null]})}],1485)},9383,(e,r,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={callServer:function(){return s.callServer},createServerReference:function(){return i.createServerReference},findSourceMapURL:function(){return o.findSourceMapURL}};for(var a in n)Object.defineProperty(t,a,{enumerable:!0,get:n[a]});let s=e.r(57855),o=e.r(61414),i=e.r(97615)},31758,e=>{"use strict";var r=e.i(1262),t=e.i(44344);e.s(["EmptyBox",0,function({children:e}){return(0,r.jsxs)("div",{className:"rounded-xl border border-dashed border-border bg-card px-5 py-9 text-center text-[13.5px] text-muted-foreground",children:[(0,r.jsx)("div",{className:"mx-auto mb-3 grid h-10 w-10 place-items-center rounded-lg border border-border text-[#a4a9b0]",children:(0,r.jsx)(t.Icons.box,{className:"size-5"})}),e]})}])},88451,e=>{"use strict";var r=e.i(1262),t=e.i(45971),n=e.i(54129),a=e.i(44344),s=e.i(69377),o=e.i(9383);let i=(0,o.createServerReference)("60ff5520393ac26282f15f58e0b073a0c45b3ba7e5",o.callServer,void 0,o.findSourceMapURL,"answerApprovalAction");e.s(["ApprovalActions",0,function({id:e}){let o=(0,t.useRouter)(),[c,l]=(0,n.useTransition)(),d=r=>{l(async()=>{let t=await i(e,r);t.ok||window.alert(`Failed: ${t.error}`),o.refresh()})};return(0,r.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,r.jsxs)(s.Button,{variant:"outline",size:"sm",disabled:c,className:"hover:border-[var(--red-line)] hover:bg-[var(--red-soft)] hover:text-[var(--red)]",onClick:()=>d("n"),children:[(0,r.jsx)(a.Icons.x,{}),"Deny"]}),(0,r.jsxs)(s.Button,{size:"sm",disabled:c,onClick:()=>d("y"),children:[(0,r.jsx)(a.Icons.check,{}),"Approve"]})]})}],88451)},16200,e=>{"use strict";var r=e.i(1262),t=e.i(65232);e.s(["Label",0,function({className:e,...n}){return(0,r.jsx)("label",{className:(0,t.cn)("mb-2 block text-[13px] font-medium leading-none",e),...n})}])},8536,e=>{"use strict";var r=e.i(1262),t=e.i(65232);e.s(["Card",0,function({className:e,...n}){return(0,r.jsx)("div",{className:(0,t.cn)("rounded-xl border border-border bg-card text-card-foreground",e),...n})},"CardContent",0,function({className:e,...n}){return(0,r.jsx)("div",{className:(0,t.cn)("p-5 pt-0",e),...n})},"CardDescription",0,function({className:e,...n}){return(0,r.jsx)("div",{className:(0,t.cn)("text-[12.5px] text-muted-foreground",e),...n})},"CardHeader",0,function({className:e,...n}){return(0,r.jsx)("div",{className:(0,t.cn)("flex flex-col space-y-1 p-5",e),...n})},"CardTitle",0,function({className:e,...n}){return(0,r.jsx)("div",{className:(0,t.cn)("text-[15px] font-semibold leading-none tracking-tight",e),...n})}])},3060,e=>{"use strict";var r=e.i(1262),t=e.i(65232);e.s(["Input",0,function({className:e,...n}){return(0,r.jsx)("input",{className:(0,t.cn)("flex h-10 w-full rounded-lg border border-input bg-card px-3 py-1 text-sm shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...n})}])},86892,30544,e=>{"use strict";var r=e.i(1262),t=e.i(64595);let n={running:{label:"running",badgeClass:"badge-run"},paused:{label:"paused",badgeClass:"badge-pause"},stopped:{label:"stopped",badgeClass:"badge-stop"},creating:{label:"creating",badgeClass:"badge-create"},error:{label:"error",badgeClass:"badge-err"}};e.s(["StatusBadge",0,function({status:e}){let a=n[e]??n.stopped;return(0,r.jsxs)(t.Badge,{className:a.badgeClass,children:[(0,r.jsx)("span",{className:"badge-dot"}),a.label]})}],86892);var a=e.i(45971),s=e.i(54129),o=e.i(65232),i=e.i(69377),c=e.i(44344),l=e.i(9383);let d=(0,l.createServerReference)("40f10bede8a5e7505d5875574f7e6fc4a06e8e2cb7",l.callServer,void 0,l.findSourceMapURL,"destroyBoxAction"),u=(0,l.createServerReference)("40ea16199b5abb2d3c1d4cecdd25aac1e3c41f074c",l.callServer,void 0,l.findSourceMapURL,"pauseBoxAction"),x=(0,l.createServerReference)("6096bb2a65e369cd77e8b1dc6cd900a5f1e67287bb",l.callServer,void 0,l.findSourceMapURL,"renameBoxAction"),b=(0,l.createServerReference)("4071308a0e1675de302803bb969800c52d79f11e13",l.callServer,void 0,l.findSourceMapURL,"resumeBoxAction"),p=(0,l.createServerReference)("40e545c7dd69b4a1d410deb9c94101099961d3af7a",l.callServer,void 0,l.findSourceMapURL,"stopBoxAction");e.s(["BoxActions",0,function({box:e,size:t}){let n=(0,a.useRouter)(),[l,f]=(0,s.useTransition)(),m="running"===e.status,v="paused"===e.status,g="stopped"===e.status,h="lg"===t,j=h?"sm":"icon-sm",y=(r,t,a)=>{r.stopPropagation(),(!a||window.confirm(a))&&f(async()=>{let r=await t(e.id);r.ok||window.alert(`Action failed: ${r.error}`),n.refresh()})};return(0,r.jsxs)("div",{className:(0,o.cn)("flex gap-1.5",h?"":"justify-end"),children:[v?(0,r.jsxs)(i.Button,{variant:h?"default":"outline",size:j,title:"Resume",disabled:l,className:h?"":"hover:border-[var(--green)] hover:bg-accent hover:text-[var(--green-ink)]",onClick:e=>y(e,b),children:[(0,r.jsx)(c.Icons.play,{}),h?"Resume":null]}):(0,r.jsxs)(i.Button,{variant:"outline",size:j,disabled:l||!m,title:"Pause",className:h?"":"hover:border-[var(--amber)] hover:bg-[var(--amber-soft)] hover:text-[var(--amber)]",onClick:e=>y(e,u),children:[(0,r.jsx)(c.Icons.pause,{}),h?"Pause":null]}),(0,r.jsxs)(i.Button,{variant:"outline",size:j,disabled:l||g,title:"Stop",onClick:e=>y(e,p),children:[(0,r.jsx)(c.Icons.stop,{}),h?"Stop":null]}),(0,r.jsxs)(i.Button,{variant:"outline",size:j,disabled:l,title:"Rename",onClick:r=>{r.stopPropagation();let t=window.prompt("Rename box (label only — leave blank to reset)",e.displayName??e.task);null!==t&&f(async()=>{let r=await x(e.id,t.trim());r.ok||window.alert(`Rename failed: ${r.error}`),n.refresh()})},children:[(0,r.jsx)(c.Icons.pencil,{}),h?"Rename":null]}),(0,r.jsxs)(i.Button,{variant:"destructive",size:j,title:"Destroy",disabled:l,onClick:r=>y(r,d,`Destroy box ${e.id}? Its workspace volume is discarded. This cannot be undone.`),children:[(0,r.jsx)(c.Icons.trash,{}),h?"Destroy":null]})]})}],30544)},95141,e=>{"use strict";var r=e.i(1262),t=e.i(54129),n=e.i(65232),a=e.i(44344);e.s(["Dialog",0,function({onClose:e,className:s,children:o}){return(0,t.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),(0,r.jsx)("div",{className:"anim-fade fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-[rgba(20,24,30,.42)] p-6 backdrop-blur-[2px]",onClick:e,children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",className:(0,n.cn)("anim-pop relative m-auto w-full max-w-[500px] rounded-2xl border border-border bg-card shadow-[0_40px_80px_-30px_rgba(20,24,30,.5)]",s),onClick:e=>e.stopPropagation(),children:[o,(0,r.jsx)("button",{className:"absolute right-4 top-4 grid h-7 w-7 cursor-pointer place-items-center rounded-md border-0 bg-transparent text-[#a4a9b0] transition-colors hover:bg-secondary hover:text-foreground",onClick:e,"aria-label":"Close",children:(0,r.jsx)(a.Icons.x,{style:{width:15,height:15}})})]})})},"DialogBody",0,function({className:e,...t}){return(0,r.jsx)("div",{className:(0,n.cn)("px-5 py-4",e),...t})},"DialogDescription",0,function({className:e,...t}){return(0,r.jsx)("div",{className:(0,n.cn)("mt-1 font-mono text-xs text-muted-foreground",e),...t})},"DialogFooter",0,function({className:e,...t}){return(0,r.jsx)("div",{className:(0,n.cn)("flex justify-end gap-2.5 rounded-b-2xl border-t border-border/70 bg-background px-5 py-3.5",e),...t})},"DialogHeader",0,function({className:e,...t}){return(0,r.jsx)("div",{className:(0,n.cn)("flex items-start gap-3 border-b border-border/70 px-5 pb-4 pt-5",e),...t})},"DialogIcon",0,function({children:e}){return(0,r.jsx)("span",{className:"grid h-9 w-9 flex-none place-items-center rounded-lg border border-[var(--green-line)] bg-accent text-primary [&_svg]:size-[17px]",children:e})},"DialogTitle",0,function({className:e,...t}){return(0,r.jsx)("div",{className:(0,n.cn)("text-base font-semibold leading-tight tracking-tight",e),...t})}])},49604,e=>{"use strict";var r=e.i(1262),t=e.i(65232);e.s(["Select",0,function({wrapperClassName:e,className:n,children:a,...s}){return(0,r.jsxs)("span",{className:(0,t.cn)("relative inline-flex",e),children:[(0,r.jsx)("select",{className:(0,t.cn)("h-9 w-full cursor-pointer appearance-none rounded-lg border border-input bg-card py-1 pl-3 pr-9 text-[13px] shadow-sm focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",n),...s,children:a}),(0,r.jsx)("svg",{className:"pointer-events-none absolute right-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}])},80922,35594,e=>{"use strict";var r=e.i(1262),t=e.i(51096),n=e.i(44344);e.s(["BackLink",0,function({to:e,children:a}){return(0,r.jsxs)(t.default,{className:"mb-3.5 inline-flex cursor-pointer items-center gap-1.5 border-0 bg-transparent p-0 font-mono text-xs text-muted-foreground hover:text-primary",href:e,children:[(0,r.jsx)(n.Icons.arrowL,{className:"size-[13px]"}),a]})}],80922);var a=e.i(65232),s=e.i(8536);e.s(["Stat",0,function({k:e,v:t,mono:n,icon:s}){return(0,r.jsxs)("div",{className:"px-4.5 p-4",children:[(0,r.jsx)("div",{className:"mb-1.5 font-mono text-[10.5px] uppercase tracking-[.06em] text-[#a4a9b0]",children:e}),(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-2 font-semibold tracking-[-0.01em]",n?"font-mono text-sm font-medium":"text-base"),children:[s?(0,r.jsx)(s,{className:"size-[15px] text-muted-foreground"}):null,t]})]})},"StatGrid",0,function({children:e}){return(0,r.jsx)(s.Card,{className:"grid grid-cols-[repeat(auto-fit,minmax(140px,1fr))] divide-x divide-border/60 overflow-hidden",children:e})}],35594)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,88451,e=>{"use strict";var t=e.i(1262),r=e.i(45971),s=e.i(54129),n=e.i(44344),a=e.i(69377),o=e.i(9383);let l=(0,o.createServerReference)("60ff5520393ac26282f15f58e0b073a0c45b3ba7e5",o.callServer,void 0,o.findSourceMapURL,"answerApprovalAction");e.s(["ApprovalActions",0,function({id:e}){let o=(0,r.useRouter)(),[i,c]=(0,s.useTransition)(),d=t=>{c(async()=>{let r=await l(e,t);r.ok||window.alert(`Failed: ${r.error}`),o.refresh()})};return(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,t.jsxs)(a.Button,{variant:"outline",size:"sm",disabled:i,className:"hover:border-[var(--red-line)] hover:bg-[var(--red-soft)] hover:text-[var(--red)]",onClick:()=>d("n"),children:[(0,t.jsx)(n.Icons.x,{}),"Deny"]}),(0,t.jsxs)(a.Button,{size:"sm",disabled:i,onClick:()=>d("y"),children:[(0,t.jsx)(n.Icons.check,{}),"Approve"]})]})}],88451)},95141,e=>{"use strict";var t=e.i(1262),r=e.i(54129),s=e.i(65232),n=e.i(44344);e.s(["Dialog",0,function({onClose:e,className:a,children:o}){return(0,r.useEffect)(()=>{let t=t=>{"Escape"===t.key&&e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),(0,t.jsx)("div",{className:"anim-fade fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-[rgba(20,24,30,.42)] p-6 backdrop-blur-[2px]",onClick:e,children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true",className:(0,s.cn)("anim-pop relative m-auto w-full max-w-[500px] rounded-2xl border border-border bg-card shadow-[0_40px_80px_-30px_rgba(20,24,30,.5)]",a),onClick:e=>e.stopPropagation(),children:[o,(0,t.jsx)("button",{className:"absolute right-4 top-4 grid h-7 w-7 cursor-pointer place-items-center rounded-md border-0 bg-transparent text-[#a4a9b0] transition-colors hover:bg-secondary hover:text-foreground",onClick:e,"aria-label":"Close",children:(0,t.jsx)(n.Icons.x,{style:{width:15,height:15}})})]})})},"DialogBody",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,s.cn)("px-5 py-4",e),...r})},"DialogDescription",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,s.cn)("mt-1 font-mono text-xs text-muted-foreground",e),...r})},"DialogFooter",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,s.cn)("flex justify-end gap-2.5 rounded-b-2xl border-t border-border/70 bg-background px-5 py-3.5",e),...r})},"DialogHeader",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,s.cn)("flex items-start gap-3 border-b border-border/70 px-5 pb-4 pt-5",e),...r})},"DialogIcon",0,function({children:e}){return(0,t.jsx)("span",{className:"grid h-9 w-9 flex-none place-items-center rounded-lg border border-[var(--green-line)] bg-accent text-primary [&_svg]:size-[17px]",children:e})},"DialogTitle",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,s.cn)("text-base font-semibold leading-tight tracking-tight",e),...r})}])},86892,30544,e=>{"use strict";var t=e.i(1262),r=e.i(64595);let s={running:{label:"running",badgeClass:"badge-run"},paused:{label:"paused",badgeClass:"badge-pause"},stopped:{label:"stopped",badgeClass:"badge-stop"},creating:{label:"creating",badgeClass:"badge-create"},error:{label:"error",badgeClass:"badge-err"}};e.s(["StatusBadge",0,function({status:e}){let n=s[e]??s.stopped;return(0,t.jsxs)(r.Badge,{className:n.badgeClass,children:[(0,t.jsx)("span",{className:"badge-dot"}),n.label]})}],86892);var n=e.i(45971),a=e.i(54129),o=e.i(65232),l=e.i(69377),i=e.i(44344),c=e.i(9383);let d=(0,c.createServerReference)("40f10bede8a5e7505d5875574f7e6fc4a06e8e2cb7",c.callServer,void 0,c.findSourceMapURL,"destroyBoxAction"),u=(0,c.createServerReference)("40ea16199b5abb2d3c1d4cecdd25aac1e3c41f074c",c.callServer,void 0,c.findSourceMapURL,"pauseBoxAction"),x=(0,c.createServerReference)("6096bb2a65e369cd77e8b1dc6cd900a5f1e67287bb",c.callServer,void 0,c.findSourceMapURL,"renameBoxAction"),m=(0,c.createServerReference)("4071308a0e1675de302803bb969800c52d79f11e13",c.callServer,void 0,c.findSourceMapURL,"resumeBoxAction"),p=(0,c.createServerReference)("40e545c7dd69b4a1d410deb9c94101099961d3af7a",c.callServer,void 0,c.findSourceMapURL,"stopBoxAction");e.s(["BoxActions",0,function({box:e,size:r}){let s=(0,n.useRouter)(),[c,b]=(0,a.useTransition)(),h="running"===e.status,f="paused"===e.status,g="stopped"===e.status,j="lg"===r,v=j?"sm":"icon-sm",N=(t,r,n)=>{t.stopPropagation(),(!n||window.confirm(n))&&b(async()=>{let t=await r(e.id);t.ok||window.alert(`Action failed: ${t.error}`),s.refresh()})};return(0,t.jsxs)("div",{className:(0,o.cn)("flex gap-1.5",j?"":"justify-end"),children:[f?(0,t.jsxs)(l.Button,{variant:j?"default":"outline",size:v,title:"Resume",disabled:c,className:j?"":"hover:border-[var(--green)] hover:bg-accent hover:text-[var(--green-ink)]",onClick:e=>N(e,m),children:[(0,t.jsx)(i.Icons.play,{}),j?"Resume":null]}):(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c||!h,title:"Pause",className:j?"":"hover:border-[var(--amber)] hover:bg-[var(--amber-soft)] hover:text-[var(--amber)]",onClick:e=>N(e,u),children:[(0,t.jsx)(i.Icons.pause,{}),j?"Pause":null]}),(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c||g,title:"Stop",onClick:e=>N(e,p),children:[(0,t.jsx)(i.Icons.stop,{}),j?"Stop":null]}),(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c,title:"Rename",onClick:t=>{t.stopPropagation();let r=window.prompt("Rename box (label only — leave blank to reset)",e.displayName??e.task);null!==r&&b(async()=>{let t=await x(e.id,r.trim());t.ok||window.alert(`Rename failed: ${t.error}`),s.refresh()})},children:[(0,t.jsx)(i.Icons.pencil,{}),j?"Rename":null]}),(0,t.jsxs)(l.Button,{variant:"destructive",size:v,title:"Destroy",disabled:c,onClick:t=>N(t,d,`Destroy box ${e.id}? Its workspace volume is discarded. This cannot be undone.`),children:[(0,t.jsx)(i.Icons.trash,{}),j?"Destroy":null]})]})}],30544)},49604,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Select",0,function({wrapperClassName:e,className:s,children:n,...a}){return(0,t.jsxs)("span",{className:(0,r.cn)("relative inline-flex",e),children:[(0,t.jsx)("select",{className:(0,r.cn)("h-9 w-full cursor-pointer appearance-none rounded-lg border border-input bg-card py-1 pl-3 pr-9 text-[13px] shadow-sm focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",s),...a,children:n}),(0,t.jsx)("svg",{className:"pointer-events-none absolute right-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:(0,t.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}])},8536,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Card",0,function({className:e,...s}){return(0,t.jsx)("div",{className:(0,r.cn)("rounded-xl border border-border bg-card text-card-foreground",e),...s})},"CardContent",0,function({className:e,...s}){return(0,t.jsx)("div",{className:(0,r.cn)("p-5 pt-0",e),...s})},"CardDescription",0,function({className:e,...s}){return(0,t.jsx)("div",{className:(0,r.cn)("text-[12.5px] text-muted-foreground",e),...s})},"CardHeader",0,function({className:e,...s}){return(0,t.jsx)("div",{className:(0,r.cn)("flex flex-col space-y-1 p-5",e),...s})},"CardTitle",0,function({className:e,...s}){return(0,t.jsx)("div",{className:(0,r.cn)("text-[15px] font-semibold leading-none tracking-tight",e),...s})}])},3060,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Input",0,function({className:e,...s}){return(0,t.jsx)("input",{className:(0,r.cn)("flex h-10 w-full rounded-lg border border-input bg-card px-3 py-1 text-sm shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...s})}])},86184,e=>{"use strict";var t=e.i(1262),r=e.i(54129),s=e.i(69377),n=e.i(3060);function a({jobId:e,login:o}){let[l,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(!1),[u,x]=(0,r.useState)(null),m="exchanging"===o.phase,p=async()=>{let t=l.trim();if(t&&!c){d(!0),x(null);try{let r=await fetch(`/api/v1/jobs/${encodeURIComponent(e)}/login-code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})});if(!r.ok){let e=await r.json().catch(()=>null);x(e?.error?.message??`request failed (${r.status})`);return}i("")}catch(e){x(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-amber-200",children:"Claude login required"}),(0,t.jsx)("p",{className:"text-xs text-amber-100/80",children:"Your saved Claude login is expired. Open the sign-in page, approve access, then paste the code Claude shows you."}),o.url?(0,t.jsx)("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"w-fit rounded-md bg-amber-500/20 px-2.5 py-1 text-xs font-medium text-amber-100 underline decoration-amber-400/50 underline-offset-2 hover:bg-amber-500/30",children:"Open Claude sign-in ↗"}):(0,t.jsx)("span",{className:"text-xs text-amber-100/60",children:"waiting for the sign-in link…"}),(0,t.jsxs)("div",{className:"mt-1 flex gap-2",children:[(0,t.jsx)(n.Input,{value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p()},placeholder:"Paste approval code",disabled:m,className:"flex-1 font-mono text-xs"}),(0,t.jsx)(s.Button,{type:"button",onClick:()=>void p(),disabled:!l.trim()||c||m,children:m?"Verifying…":c?"Submitting…":"Submit"})]}),o.lastError?(0,t.jsx)("p",{className:"text-xs text-amber-300",children:o.lastError}):null,"error"===o.phase&&o.error?(0,t.jsx)("p",{className:"text-xs text-red-400",children:o.error}):null,u?(0,t.jsx)("p",{className:"text-xs text-red-400",children:u}):null]})}e.s(["JobLogStream",0,function({jobId:e,endpoint:s,onDone:n,onStatus:o,onLogin:l}){let[i,c]=(0,r.useState)([]),[d,u]=(0,r.useState)(null),x=(0,r.useRef)(null),m=(0,r.useRef)(n);m.current=n;let p=(0,r.useRef)(o);p.current=o;let b=(0,r.useRef)(l);return b.current=l,(0,r.useEffect)(()=>{p.current?.("streaming");let t=new EventSource(s??`/api/jobs/${encodeURIComponent(e)}/logs`);return t.addEventListener("log",e=>{let t=JSON.parse(e.data);c(e=>[...e,t])}),t.addEventListener("login",e=>{let t=JSON.parse(e.data);u(t),b.current?.(t)}),t.addEventListener("end",e=>{let r=JSON.parse(e.data);p.current?.(r.status),m.current?.(r.status),t.close()}),()=>t.close()},[e,s]),(0,r.useEffect)(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[i]),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[d&&"done"!==d.phase?(0,t.jsx)(a,{jobId:e,login:d}):null,(0,t.jsx)("pre",{ref:x,className:"max-h-[440px] min-h-[220px] overflow-auto whitespace-pre rounded-lg bg-[#16181c] p-3 font-mono text-[11.5px] leading-relaxed text-[#d6d9de]",children:0===i.length?"starting…":i.join("\n")})]})}])},33789,1485,e=>{"use strict";var t=e.i(1262),r=e.i(54129);e.s(["Ago",0,function({ms:e}){let[s,n]=(0,r.useState)(!1);return(0,r.useEffect)(()=>n(!0),[]),(0,t.jsx)("span",{suppressHydrationWarning:!0,children:s?function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return t+"s ago";let r=Math.floor(t/60);if(r<60)return r+"m ago";let s=Math.floor(r/60);return s<24?s+"h ago":Math.floor(s/24)+"d ago"}(e):new Date(e).toLocaleDateString()})}],33789),e.s(["SectionLabel",0,function({children:e,right:r}){return(0,t.jsxs)("div",{className:"mb-3 mt-8 flex items-center gap-2.5 font-mono text-[11px] uppercase tracking-[.1em] text-[#a4a9b0]",children:[e,(0,t.jsx)("span",{className:"h-px flex-1 bg-border"}),r??null]})}],1485)},9383,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var s={callServer:function(){return a.callServer},createServerReference:function(){return l.createServerReference},findSourceMapURL:function(){return o.findSourceMapURL}};for(var n in s)Object.defineProperty(r,n,{enumerable:!0,get:s[n]});let a=e.r(57855),o=e.r(61414),l=e.r(97615)},31758,e=>{"use strict";var t=e.i(1262),r=e.i(44344);e.s(["EmptyBox",0,function({children:e}){return(0,t.jsxs)("div",{className:"rounded-xl border border-dashed border-border bg-card px-5 py-9 text-center text-[13.5px] text-muted-foreground",children:[(0,t.jsx)("div",{className:"mx-auto mb-3 grid h-10 w-10 place-items-center rounded-lg border border-border text-[#a4a9b0]",children:(0,t.jsx)(r.Icons.box,{className:"size-5"})}),e]})}])},23878,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Table",0,function({className:e,...s}){return(0,t.jsx)("table",{className:(0,r.cn)("w-full caption-bottom text-sm",e),...s})},"TableBody",0,function({className:e,...s}){return(0,t.jsx)("tbody",{className:(0,r.cn)("[&_tr:last-child]:border-0",e),...s})},"TableCell",0,function({className:e,...s}){return(0,t.jsx)("td",{className:(0,r.cn)("px-4 py-3 align-middle",e),...s})},"TableHead",0,function({className:e,...s}){return(0,t.jsx)("th",{className:(0,r.cn)("h-9 px-4 text-left align-middle font-mono text-[10.5px] font-normal uppercase tracking-[.08em] text-muted-foreground/90",e),...s})},"TableHeader",0,function({className:e,...s}){return(0,t.jsx)("thead",{className:(0,r.cn)("bg-background [&_tr]:border-b [&_tr]:border-border",e),...s})},"TableRow",0,function({className:e,...s}){return(0,t.jsx)("tr",{className:(0,r.cn)("border-b border-border/60 transition-colors hover:bg-[#fcfcfb] data-[state=selected]:bg-accent",e),...s})}])},22983,93268,66818,e=>{"use strict";var t=e.i(1262),r=e.i(45971),s=e.i(33789),n=e.i(44344),a=e.i(86892),o=e.i(8536),l=e.i(23878),i=e.i(30544);e.s(["BoxTable",0,function({boxes:e}){let c=(0,r.useRouter)();return(0,t.jsx)(o.Card,{className:"overflow-hidden",children:(0,t.jsxs)(l.Table,{children:[(0,t.jsx)(l.TableHeader,{children:(0,t.jsxs)(l.TableRow,{className:"hover:bg-transparent",children:[(0,t.jsx)(l.TableHead,{className:"w-[38%]",children:"Task"}),(0,t.jsx)(l.TableHead,{className:"w-[27%] max-md:hidden",children:"Branch"}),(0,t.jsx)(l.TableHead,{className:"max-md:hidden",children:"Status"}),(0,t.jsx)(l.TableHead,{className:"text-right",children:"Actions"})]})}),(0,t.jsx)(l.TableBody,{children:e.map(e=>(0,t.jsxs)(l.TableRow,{className:"cursor-pointer",onClick:()=>c.push("/boxes/"+e.id),children:[(0,t.jsxs)(l.TableCell,{children:[(0,t.jsx)("div",{className:"truncate text-[13.5px] font-medium",children:e.task}),(0,t.jsxs)("div",{className:"mt-0.5 font-mono text-[11px] text-[#a4a9b0]",children:[e.id," · ",e.host]})]}),(0,t.jsxs)(l.TableCell,{className:"max-md:hidden",children:[(0,t.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1.5 font-mono text-xs text-secondary-foreground",children:[(0,t.jsx)(n.Icons.branch,{className:"size-3 flex-none text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.branch})]}),(0,t.jsxs)("div",{className:"mt-0.5 font-mono text-[11px] text-[#a4a9b0]",children:[e.agent," · ",(0,t.jsx)(s.Ago,{ms:e.lastActivity})]})]}),(0,t.jsx)(l.TableCell,{className:"max-md:hidden",children:(0,t.jsx)(a.StatusBadge,{status:e.status})}),(0,t.jsx)(l.TableCell,{className:"text-right",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(i.BoxActions,{box:e})})]},e.id))})]})})}],22983);var c=e.i(54129),d=e.i(64595),u=e.i(69377),x=e.i(95141),m=e.i(3060),p=e.i(49604),b=e.i(65232);function h({className:e,...r}){return(0,t.jsx)("textarea",{className:(0,b.cn)("flex min-h-[76px] w-full resize-y rounded-lg border border-input bg-card px-3 py-2 text-sm leading-normal shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...r})}var f=e.i(9383);let g=(0,f.createServerReference)("4070192706087364b8c7d220576a6f3e4d3e5c532b",f.callServer,void 0,f.findSourceMapURL,"createBoxAction"),j=(0,f.createServerReference)("40386bdce4d894a318a969412fa1299d2704ccdfb3",f.callServer,void 0,f.findSourceMapURL,"listBranchesAction");var v=e.i(96621),N=e.i(86184);let S=[{id:"docker",label:"Docker (local)",configured:!0}];function y({project:e,projects:s,onClose:a}){let o=(0,r.useRouter)(),{state:l}=(0,v.useStore)(),i=l.providers.length?l.providers:S,[d,f]=(0,c.useTransition)(),[C,B]=(0,c.useState)(e?.id??s[0]?.id??""),[R,I]=(0,c.useState)("claude"),[T,D]=(0,c.useState)("docker"),[A,L]=(0,c.useState)(""),[P,z]=(0,c.useState)(""),[E,U]=(0,c.useState)(""),[M,H]=(0,c.useState)(null),[O,F]=(0,c.useState)(!1),[$,_]=(0,c.useState)(!1),[J,K]=(0,c.useState)(null),[q,W]=(0,c.useState)(null),[V,Y]=(0,c.useState)("streaming"),[G,Q]=(0,c.useState)(null),[X,Z]=(0,c.useState)(null),[ee,et]=(0,c.useState)(!1),[er,es]=(0,c.useState)(null);(0,c.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/v1/providers?freshness=1",{credentials:"same-origin"});if(!t.ok)return;let r=await t.json();if(e)return;let s={};for(let e of r.providers??[])s[e.id]={baseStatus:e.baseStatus,baseStaleReason:e.baseStaleReason,jobId:e.jobId};es(s)}catch{}})(),()=>{e=!0}},[]);let en=s.find(e=>e.id===C)??e,ea=T??"docker",eo=i.find(e=>e.id===ea),el=er?.[ea],ei=!!el&&(!!el.jobId||"unprepared"===el.baseStatus||"stale"===el.baseStatus);(0,c.useEffect)(()=>{if(!C||q)return;F(en?.needsSetup??!1),D("docker");let e=!1;return H(null),U(en?.currentBranch??""),j(C).then(t=>{if(e||!t.ok){e||t.ok||H([]);return}H(t.branches),t.current&&t.branches.includes(t.current)&&U(t.current)}),()=>{e=!0}},[C,q]);let ec=()=>{K(null);let e=el?.jobId;e?Z(e):f(async()=>{try{let e=await fetch(`/api/v1/providers/${encodeURIComponent(ea)}/prepare`,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t?.jobId)return void K(t?.error?.message??`base image build request failed (${e.status})`);Z(t.jobId)}catch(e){K(e instanceof Error?e.message:String(e))}})},ed=()=>{K(null),f(async()=>{let e=await g({projectId:C,agent:R,provider:T,name:A.trim()||void 0,prompt:"none"===R?void 0:P.trim()||void 0,fromBranch:E.trim()&&E.trim()!==en?.currentBranch?E.trim():void 0,setupWizard:"none"!==R&&O});e.ok?(W(e.jobId),o.refresh()):K(e.error)})};return(0,t.jsxs)(x.Dialog,{onClose:a,className:q||X?"max-w-[900px]":"max-w-[560px]",children:[(0,t.jsxs)(x.DialogHeader,{children:[(0,t.jsx)(x.DialogIcon,{children:(0,t.jsx)(n.Icons.box,{})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(x.DialogTitle,{children:!q&&X?"Building base image":"Create box"}),(0,t.jsx)(x.DialogDescription,{children:en?en.name:"Start a box in a project"})]}),q||X?(0,t.jsx)("div",{className:"ml-auto mr-8 flex-none pt-0.5",children:(0,t.jsx)(w,{status:V,loginPhase:G})}):null]}),(0,t.jsx)(x.DialogBody,{className:"flex flex-col gap-4",children:q?(0,t.jsx)(N.JobLogStream,{jobId:q,onStatus:Y,onDone:()=>o.refresh(),onLogin:e=>Q(e?.phase??null)}):X?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:["Building the ",eo?.label??ea," base image — one-time, can take several minutes. The box is created automatically when it finishes."]}),(0,t.jsx)(N.JobLogStream,{jobId:X,onStatus:Y,onDone:e=>{"done"===e?ed():K(`base image build ${e}`)}}),J?(0,t.jsx)("div",{className:"font-mono text-xs text-destructive",children:J}):null]}):(0,t.jsxs)(t.Fragment,{children:[e?null:(0,t.jsx)(k,{label:"Project",children:(0,t.jsxs)(p.Select,{value:C,onChange:e=>B(e.target.value),children:[0===s.length?(0,t.jsx)("option",{value:"",children:"No projects — add one first"}):null,s.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,t.jsx)(k,{label:"Provider",children:(0,t.jsx)(p.Select,{value:T,onChange:e=>D(e.target.value),children:i.map(e=>(0,t.jsxs)("option",{value:e.id,disabled:!e.configured,title:e.reason,children:[e.label,e.configured?"":" — not configured"]},e.id))})}),ei?(0,t.jsx)("p",{className:"-mt-2 font-mono text-xs text-amber-600 dark:text-amber-400",title:el?.baseStaleReason,children:el?.jobId?"A base-image build is already running — the box will be created when it finishes.":el?.baseStatus==="unprepared"?"First use of this provider: the base image will be downloaded or built first (can take 5–10 minutes).":"The base image is out of date and will be rebuilt first (can take 5–10 minutes)."}):null,(0,t.jsx)(k,{label:"Agent",children:(0,t.jsxs)(p.Select,{value:R,onChange:e=>I(e.target.value),children:[(0,t.jsx)("option",{value:"claude",children:"Claude"}),(0,t.jsx)("option",{value:"codex",children:"Codex"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"}),(0,t.jsx)("option",{value:"none",children:"Empty — just create the box"})]})}),(0,t.jsx)(k,{label:"Name (optional)",children:(0,t.jsx)(m.Input,{value:A,onChange:e=>L(e.target.value),placeholder:"auto"})}),en?.needsSetup&&"none"!==R?(0,t.jsxs)("label",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("input",{type:"checkbox",checked:O,onChange:e=>F(e.target.checked),className:"mt-0.5 h-4 w-4 flex-none accent-primary"}),(0,t.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-secondary-foreground",children:"Run setup wizard"}),(0,t.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:"This project has no agentbox.yaml — the agent explores the repo and proposes one on its first turn."})]})]}):null,"none"===R?(0,t.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:["The box is created and left running with no agent — attach later from a terminal or SSH (",(0,t.jsx)("span",{className:"text-secondary-foreground",children:"agentbox shell"}),")."]}):null,(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>_(e=>!e),className:"flex cursor-pointer items-center gap-1.5 self-start text-xs font-medium text-secondary-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(n.Icons.chevR,{className:(0,b.cn)("size-3.5 transition-transform",$&&"rotate-90")}),"Advanced"]}),$?(0,t.jsxs)(t.Fragment,{children:[null===M?(0,t.jsx)(k,{label:"Base branch",children:(0,t.jsx)(p.Select,{value:"",disabled:!0,children:(0,t.jsx)("option",{value:"",children:"Loading branches…"})})}):M.length>0?(0,t.jsx)(k,{label:"Base branch",children:(0,t.jsxs)(p.Select,{value:E,onChange:e=>U(e.target.value),children:[en?.currentBranch&&!M.includes(en.currentBranch)?(0,t.jsxs)("option",{value:"",children:[en.currentBranch," (current)"]}):null,M.map(e=>(0,t.jsxs)("option",{value:e,children:[e,e===en?.currentBranch?" (current)":""]},e))]})}):null,"none"!==R?(0,t.jsx)(k,{label:"Initial prompt (optional)",children:(0,t.jsx)(h,{value:P,onChange:e=>z(e.target.value),rows:3,placeholder:"Leave empty to just start the agent — attach later from a terminal or SSH."})}):null]}):null]}),J?(0,t.jsx)("div",{className:"font-mono text-xs text-destructive",children:J}):null]})}),(0,t.jsx)(x.DialogFooter,{children:q||X?(0,t.jsxs)(t.Fragment,{children:["streaming"===V?(0,t.jsx)("span",{className:"mr-auto self-center font-mono text-xs text-muted-foreground",children:q?"The box + agent start in the background — you can close this.":"Keep this open — the box is created when the build finishes."}):null,(0,t.jsx)(u.Button,{onClick:a,children:"Close"})]}):ee?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"mr-auto self-center font-mono text-xs text-muted-foreground",title:el?.baseStaleReason,children:["The ",eo?.label??ea," base image is out of date."]}),(0,t.jsx)(u.Button,{variant:"outline",onClick:()=>et(!1),disabled:d,children:"Cancel"}),(0,t.jsx)(u.Button,{variant:"outline",onClick:()=>{et(!1),ed()},disabled:d,children:"Use existing image"}),(0,t.jsx)(u.Button,{onClick:()=>{et(!1),ec()},disabled:d,children:"Rebuild & create"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Button,{variant:"outline",onClick:a,disabled:d,children:"Cancel"}),(0,t.jsx)(u.Button,{onClick:()=>{(K(null),C)?ei?"docker"===ea||el?.baseStatus!=="stale"||el.jobId?ec():et(!0):ed():K("pick a project")},disabled:d||!C,children:d?"Starting…":"Create box"})]})})]})}function w({status:e,loginPhase:r}){return"done"===e?(0,t.jsxs)(d.Badge,{className:"badge-run",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Done"]}):"failed"===e||"error"===e||"cancelled"===e?(0,t.jsxs)(d.Badge,{className:"badge-err",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Failed"]}):"error"===r?(0,t.jsxs)(d.Badge,{className:"badge-err",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Login failed"]}):"awaiting-code"===r||"starting"===r||"exchanging"===r?(0,t.jsxs)(d.Badge,{className:"badge-create",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Login required"]}):(0,t.jsxs)(d.Badge,{className:"badge-create",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Working…"]})}function k({label:e,children:r}){return(0,t.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-secondary-foreground",children:e}),r]})}e.s(["CreateBoxButton",0,function({project:e,projects:r,variant:s,size:a,className:o}){let[l,i]=(0,c.useState)(!1);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(u.Button,{variant:s,size:a,className:o,onClick:()=>i(!0),children:[(0,t.jsx)(n.Icons.plus,{}),"Create box"]}),l?(0,t.jsx)(y,{project:e,projects:r??(e?[e]:[]),onClose:()=>i(!1)}):null]})}],93268);let C=(0,f.createServerReference)("40c7856bd78dddab224344045df78d51620e411335",f.callServer,void 0,f.findSourceMapURL,"removeProjectAction");e.s(["DeleteProjectButton",0,function({project:e,size:s,className:a,redirectHome:o}){let l=(0,r.useRouter)(),[i,d]=(0,c.useTransition)();return(0,t.jsxs)(u.Button,{variant:"destructive",size:s,className:a,title:"Delete project",disabled:i,onClick:t=>{t.stopPropagation(),t.preventDefault(),window.confirm(`Remove project "${e.name}" from the hub? Its folder and files are NOT deleted — this only unregisters it (and any hub-set project settings). This cannot be undone.`)&&d(async()=>{let t=await C(e.id);t.ok?o?l.push("/"):l.refresh():window.alert(`Delete failed: ${t.error}`)})},children:[(0,t.jsx)(n.Icons.trash,{}),"Delete"]})}],66818)},87340,e=>{"use strict";var t=e.i(1262),r=e.i(51096),s=e.i(44344),n=e.i(96621),a=e.i(88451);function o(){let{state:e,box:o}=(0,n.useStore)();if(0===e.approvals.length)return null;let l=[...e.approvals].sort((e,t)=>e.createdAt-t.createdAt),i=l[0],c=o(i.boxId);return(0,t.jsxs)("div",{className:"mb-6 flex items-start gap-3 rounded-xl border border-[var(--amber-line)] bg-[var(--amber-soft)] p-4",children:[(0,t.jsx)(s.Icons.shield,{className:"mt-0.5 size-4 flex-none text-[var(--amber)]"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[c?(0,t.jsx)(r.default,{className:"text-[13.5px] font-semibold hover:text-[var(--green-ink)]",href:"/boxes/"+c.id,children:c.task}):(0,t.jsx)("span",{className:"text-[13.5px] font-semibold",children:i.boxId}),(0,t.jsx)("span",{className:"truncate font-mono text-[12.5px] text-secondary-foreground",children:i.command??i.message})]}),i.detail?(0,t.jsx)("div",{className:"mt-0.5 truncate text-[11.5px] text-muted-foreground",children:i.detail}):null,i.cwd?(0,t.jsx)("div",{className:"mt-0.5 truncate font-mono text-[11px] text-[#a4a9b0]",children:i.cwd}):null]}),(0,t.jsxs)("div",{className:"flex flex-none items-center gap-3",children:[l.length>1?(0,t.jsxs)("div",{className:"hidden items-center gap-2 sm:flex",children:[(0,t.jsxs)("span",{className:"font-mono text-[11.5px] text-[var(--amber)]",children:[l.length," pending"]}),(0,t.jsx)(r.default,{className:"font-mono text-[11.5px] text-muted-foreground hover:text-[var(--green-ink)]",href:"/approvals",children:"View all"})]}):null,(0,t.jsx)(a.ApprovalActions,{id:i.id})]})]})}var l=e.i(45971),i=e.i(54129),c=e.i(69377),d=e.i(95141),u=e.i(3060),x=e.i(9383);let m=(0,x.createServerReference)("4087bb6da1f4834ca146bcc8cb7c69295dbeda0bdc",x.callServer,void 0,x.findSourceMapURL,"addProjectAction"),p=(0,x.createServerReference)("40942714d29a270a6816a39cd419b4f09f50fc19b1",x.callServer,void 0,x.findSourceMapURL,"browseDirAction");function b(){let[e,r]=(0,i.useState)(!1);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(c.Button,{onClick:()=>r(!0),children:[(0,t.jsx)(s.Icons.plus,{}),"New project"]}),e?(0,t.jsx)(h,{onClose:()=>r(!1)}):null]})}function h({onClose:e}){let r=(0,l.useRouter)(),[n,a]=(0,i.useTransition)(),[o,x]=(0,i.useState)(""),[b,f]=(0,i.useState)(null),[g,j]=(0,i.useState)([]),[v,N]=(0,i.useState)(!0),[S,y]=(0,i.useState)(null),w=(0,i.useCallback)(async e=>{N(!0),y(null);let t=await p(e);if(!t.ok){y(t.error),N(!1);return}x(t.path),f(t.parent),j(t.entries),N(!1)},[]);return(0,i.useEffect)(()=>{w()},[w]),(0,t.jsxs)(d.Dialog,{onClose:e,children:[(0,t.jsxs)(d.DialogHeader,{children:[(0,t.jsx)(d.DialogIcon,{children:(0,t.jsx)(s.Icons.folder,{})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.DialogTitle,{children:"Add project"}),(0,t.jsx)(d.DialogDescription,{children:"Pick a folder on this machine"})]})]}),(0,t.jsxs)(d.DialogBody,{className:"flex flex-col gap-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.Button,{variant:"outline",className:"flex-none px-2.5",onClick:()=>void w(b??void 0),disabled:!b||v,title:"Up one level","aria-label":"Up one level",children:(0,t.jsx)(s.Icons.arrowUp,{})}),(0,t.jsx)(u.Input,{value:o,onChange:e=>x(e.target.value),placeholder:"/Users/you/Projects/my-app",className:"font-mono text-xs",onKeyDown:e=>{"Enter"===e.key&&w(o)}})]}),(0,t.jsx)("div",{className:"h-56 overflow-y-auto rounded-lg border border-border bg-background",children:v?(0,t.jsx)("div",{className:"px-3 py-2.5 font-mono text-xs text-muted-foreground",children:"Loading…"}):0===g.length?(0,t.jsx)("div",{className:"px-3 py-2.5 font-mono text-xs text-muted-foreground",children:"No subfolders here"}):g.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>void w(e.path),className:"flex w-full cursor-pointer items-center gap-2 border-0 border-b border-border/60 bg-transparent px-3 py-2 text-left text-[13px] transition-colors last:border-b-0 hover:bg-secondary",children:[(0,t.jsx)(s.Icons.folder,{className:"size-4 flex-none text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.name}),e.isProject?(0,t.jsx)("span",{className:"ml-auto flex-none rounded border border-[var(--green-line)] bg-accent px-1.5 py-px font-mono text-[10px] uppercase tracking-wide text-primary",children:"project"}):(0,t.jsx)(s.Icons.chevR,{className:"ml-auto size-3.5 flex-none text-[#a4a9b0]"})]},e.path))}),S?(0,t.jsx)("div",{className:"font-mono text-xs text-destructive",children:S}):null]}),(0,t.jsxs)(d.DialogFooter,{children:[(0,t.jsx)(c.Button,{variant:"outline",onClick:e,disabled:n,children:"Cancel"}),(0,t.jsx)(c.Button,{onClick:()=>{y(null);let t=o.trim();t?a(async()=>{let s=await m(t);s.ok?(r.refresh(),e()):y(s.error)}):y("choose a folder")},disabled:n||v,children:n?"Adding…":"Add this folder"})]})]})}var f=e.i(22983),g=e.i(93268),j=e.i(66818),v=e.i(31758),N=e.i(1485);e.s(["default",0,function(){let{state:e,boxesFor:a}=(0,n.useStore)(),l=e.projects.map(e=>({p:e,boxes:a(e.id)})).sort((e,t)=>(e.boxes.length>0?0:1)-(t.boxes.length>0?0:1)),i=e.boxes.filter(e=>"running"===e.status).length;return(0,t.jsxs)("div",{className:"mx-auto w-full max-w-[1080px] px-8 pb-16 pt-8 max-sm:px-4",children:[(0,t.jsx)(o,{}),(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h1",{className:"text-[25px] font-semibold leading-tight tracking-[-0.025em]",children:"Boxes"}),(0,t.jsxs)("div",{className:"mt-1.5 text-sm text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-mono text-secondary-foreground",children:i})," running across"," ",(0,t.jsx)("span",{className:"font-mono text-secondary-foreground",children:e.projects.length})," ","project",1===e.projects.length?"":"s"," on this machine."]})]}),(0,t.jsx)("div",{className:"ml-auto flex flex-none gap-2",children:(0,t.jsx)(b,{})})]}),(0,t.jsx)(N.SectionLabel,{children:"Projects"}),0===l.length?(0,t.jsxs)(v.EmptyBox,{children:[(0,t.jsx)("div",{children:"No projects on this machine yet."}),(0,t.jsx)("div",{className:"mt-1.5 font-mono text-xs text-muted-foreground",children:"Add one with “New project”, or run `agentbox create` in a folder."})]}):null,l.map(({p:e,boxes:n})=>(0,t.jsxs)("div",{className:"mb-7",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-1 pb-3",children:[(0,t.jsxs)(r.default,{className:"flex cursor-pointer items-center gap-2 border-0 bg-transparent p-0 text-[15px] font-semibold tracking-[-0.01em] text-foreground hover:text-[var(--green-ink)]",href:"/projects/"+e.id,children:[(0,t.jsx)("span",{className:"grid h-[22px] w-[22px] flex-none place-items-center rounded-md border border-[var(--green-line)] bg-accent text-primary",children:(0,t.jsx)(s.Icons.folder,{className:"size-[13px]"})}),e.name]}),(0,t.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:e.repo}),(0,t.jsx)("span",{className:"flex-1"}),(0,t.jsxs)("span",{className:"font-mono text-[11.5px] text-[#a4a9b0]",children:[n.length," box",1===n.length?"":"es"]}),(0,t.jsx)(g.CreateBoxButton,{project:e,variant:"outline",size:"sm",className:"font-mono text-xs"}),0===n.length?(0,t.jsx)(j.DeleteProjectButton,{project:e,size:"sm",className:"font-mono text-xs"}):null]}),n.length?(0,t.jsx)(f.BoxTable,{boxes:n}):(0,t.jsx)(v.EmptyBox,{children:(0,t.jsxs)("div",{children:["No boxes in ",(0,t.jsx)("b",{className:"font-semibold text-secondary-foreground",children:e.name})," yet."]})})]},e.id))]})}],87340)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,86892,30544,e=>{"use strict";var t=e.i(1262),r=e.i(64595);let a={running:{label:"running",badgeClass:"badge-run"},paused:{label:"paused",badgeClass:"badge-pause"},stopped:{label:"stopped",badgeClass:"badge-stop"},creating:{label:"creating",badgeClass:"badge-create"},error:{label:"error",badgeClass:"badge-err"}};e.s(["StatusBadge",0,function({status:e}){let n=a[e]??a.stopped;return(0,t.jsxs)(r.Badge,{className:n.badgeClass,children:[(0,t.jsx)("span",{className:"badge-dot"}),n.label]})}],86892);var n=e.i(45971),s=e.i(54129),o=e.i(65232),l=e.i(69377),i=e.i(44344),c=e.i(9383);let d=(0,c.createServerReference)("40f10bede8a5e7505d5875574f7e6fc4a06e8e2cb7",c.callServer,void 0,c.findSourceMapURL,"destroyBoxAction"),u=(0,c.createServerReference)("40ea16199b5abb2d3c1d4cecdd25aac1e3c41f074c",c.callServer,void 0,c.findSourceMapURL,"pauseBoxAction"),x=(0,c.createServerReference)("6096bb2a65e369cd77e8b1dc6cd900a5f1e67287bb",c.callServer,void 0,c.findSourceMapURL,"renameBoxAction"),m=(0,c.createServerReference)("4071308a0e1675de302803bb969800c52d79f11e13",c.callServer,void 0,c.findSourceMapURL,"resumeBoxAction"),p=(0,c.createServerReference)("40e545c7dd69b4a1d410deb9c94101099961d3af7a",c.callServer,void 0,c.findSourceMapURL,"stopBoxAction");e.s(["BoxActions",0,function({box:e,size:r}){let a=(0,n.useRouter)(),[c,b]=(0,s.useTransition)(),h="running"===e.status,f="paused"===e.status,g="stopped"===e.status,j="lg"===r,v=j?"sm":"icon-sm",N=(t,r,n)=>{t.stopPropagation(),(!n||window.confirm(n))&&b(async()=>{let t=await r(e.id);t.ok||window.alert(`Action failed: ${t.error}`),a.refresh()})};return(0,t.jsxs)("div",{className:(0,o.cn)("flex gap-1.5",j?"":"justify-end"),children:[f?(0,t.jsxs)(l.Button,{variant:j?"default":"outline",size:v,title:"Resume",disabled:c,className:j?"":"hover:border-[var(--green)] hover:bg-accent hover:text-[var(--green-ink)]",onClick:e=>N(e,m),children:[(0,t.jsx)(i.Icons.play,{}),j?"Resume":null]}):(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c||!h,title:"Pause",className:j?"":"hover:border-[var(--amber)] hover:bg-[var(--amber-soft)] hover:text-[var(--amber)]",onClick:e=>N(e,u),children:[(0,t.jsx)(i.Icons.pause,{}),j?"Pause":null]}),(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c||g,title:"Stop",onClick:e=>N(e,p),children:[(0,t.jsx)(i.Icons.stop,{}),j?"Stop":null]}),(0,t.jsxs)(l.Button,{variant:"outline",size:v,disabled:c,title:"Rename",onClick:t=>{t.stopPropagation();let r=window.prompt("Rename box (label only — leave blank to reset)",e.displayName??e.task);null!==r&&b(async()=>{let t=await x(e.id,r.trim());t.ok||window.alert(`Rename failed: ${t.error}`),a.refresh()})},children:[(0,t.jsx)(i.Icons.pencil,{}),j?"Rename":null]}),(0,t.jsxs)(l.Button,{variant:"destructive",size:v,title:"Destroy",disabled:c,onClick:t=>N(t,d,`Destroy box ${e.id}? Its workspace volume is discarded. This cannot be undone.`),children:[(0,t.jsx)(i.Icons.trash,{}),j?"Destroy":null]})]})}],30544)},95141,e=>{"use strict";var t=e.i(1262),r=e.i(54129),a=e.i(65232),n=e.i(44344);e.s(["Dialog",0,function({onClose:e,className:s,children:o}){return(0,r.useEffect)(()=>{let t=t=>{"Escape"===t.key&&e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),(0,t.jsx)("div",{className:"anim-fade fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-[rgba(20,24,30,.42)] p-6 backdrop-blur-[2px]",onClick:e,children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true",className:(0,a.cn)("anim-pop relative m-auto w-full max-w-[500px] rounded-2xl border border-border bg-card shadow-[0_40px_80px_-30px_rgba(20,24,30,.5)]",s),onClick:e=>e.stopPropagation(),children:[o,(0,t.jsx)("button",{className:"absolute right-4 top-4 grid h-7 w-7 cursor-pointer place-items-center rounded-md border-0 bg-transparent text-[#a4a9b0] transition-colors hover:bg-secondary hover:text-foreground",onClick:e,"aria-label":"Close",children:(0,t.jsx)(n.Icons.x,{style:{width:15,height:15}})})]})})},"DialogBody",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,a.cn)("px-5 py-4",e),...r})},"DialogDescription",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,a.cn)("mt-1 font-mono text-xs text-muted-foreground",e),...r})},"DialogFooter",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,a.cn)("flex justify-end gap-2.5 rounded-b-2xl border-t border-border/70 bg-background px-5 py-3.5",e),...r})},"DialogHeader",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,a.cn)("flex items-start gap-3 border-b border-border/70 px-5 pb-4 pt-5",e),...r})},"DialogIcon",0,function({children:e}){return(0,t.jsx)("span",{className:"grid h-9 w-9 flex-none place-items-center rounded-lg border border-[var(--green-line)] bg-accent text-primary [&_svg]:size-[17px]",children:e})},"DialogTitle",0,function({className:e,...r}){return(0,t.jsx)("div",{className:(0,a.cn)("text-base font-semibold leading-tight tracking-tight",e),...r})}])},49604,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Select",0,function({wrapperClassName:e,className:a,children:n,...s}){return(0,t.jsxs)("span",{className:(0,r.cn)("relative inline-flex",e),children:[(0,t.jsx)("select",{className:(0,r.cn)("h-9 w-full cursor-pointer appearance-none rounded-lg border border-input bg-card py-1 pl-3 pr-9 text-[13px] shadow-sm focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",a),...s,children:n}),(0,t.jsx)("svg",{className:"pointer-events-none absolute right-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:(0,t.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}])},80922,35594,e=>{"use strict";var t=e.i(1262),r=e.i(51096),a=e.i(44344);e.s(["BackLink",0,function({to:e,children:n}){return(0,t.jsxs)(r.default,{className:"mb-3.5 inline-flex cursor-pointer items-center gap-1.5 border-0 bg-transparent p-0 font-mono text-xs text-muted-foreground hover:text-primary",href:e,children:[(0,t.jsx)(a.Icons.arrowL,{className:"size-[13px]"}),n]})}],80922);var n=e.i(65232),s=e.i(8536);e.s(["Stat",0,function({k:e,v:r,mono:a,icon:s}){return(0,t.jsxs)("div",{className:"px-4.5 p-4",children:[(0,t.jsx)("div",{className:"mb-1.5 font-mono text-[10.5px] uppercase tracking-[.06em] text-[#a4a9b0]",children:e}),(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-2 font-semibold tracking-[-0.01em]",a?"font-mono text-sm font-medium":"text-base"),children:[s?(0,t.jsx)(s,{className:"size-[15px] text-muted-foreground"}):null,r]})]})},"StatGrid",0,function({children:e}){return(0,t.jsx)(s.Card,{className:"grid grid-cols-[repeat(auto-fit,minmax(140px,1fr))] divide-x divide-border/60 overflow-hidden",children:e})}],35594)},8536,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Card",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,r.cn)("rounded-xl border border-border bg-card text-card-foreground",e),...a})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,r.cn)("p-5 pt-0",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,r.cn)("text-[12.5px] text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,r.cn)("flex flex-col space-y-1 p-5",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{className:(0,r.cn)("text-[15px] font-semibold leading-none tracking-tight",e),...a})}])},3060,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Input",0,function({className:e,...a}){return(0,t.jsx)("input",{className:(0,r.cn)("flex h-10 w-full rounded-lg border border-input bg-card px-3 py-1 text-sm shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...a})}])},86184,e=>{"use strict";var t=e.i(1262),r=e.i(54129),a=e.i(69377),n=e.i(3060);function s({jobId:e,login:o}){let[l,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(!1),[u,x]=(0,r.useState)(null),m="exchanging"===o.phase,p=async()=>{let t=l.trim();if(t&&!c){d(!0),x(null);try{let r=await fetch(`/api/v1/jobs/${encodeURIComponent(e)}/login-code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})});if(!r.ok){let e=await r.json().catch(()=>null);x(e?.error?.message??`request failed (${r.status})`);return}i("")}catch(e){x(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-amber-200",children:"Claude login required"}),(0,t.jsx)("p",{className:"text-xs text-amber-100/80",children:"Your saved Claude login is expired. Open the sign-in page, approve access, then paste the code Claude shows you."}),o.url?(0,t.jsx)("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"w-fit rounded-md bg-amber-500/20 px-2.5 py-1 text-xs font-medium text-amber-100 underline decoration-amber-400/50 underline-offset-2 hover:bg-amber-500/30",children:"Open Claude sign-in ↗"}):(0,t.jsx)("span",{className:"text-xs text-amber-100/60",children:"waiting for the sign-in link…"}),(0,t.jsxs)("div",{className:"mt-1 flex gap-2",children:[(0,t.jsx)(n.Input,{value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p()},placeholder:"Paste approval code",disabled:m,className:"flex-1 font-mono text-xs"}),(0,t.jsx)(a.Button,{type:"button",onClick:()=>void p(),disabled:!l.trim()||c||m,children:m?"Verifying…":c?"Submitting…":"Submit"})]}),o.lastError?(0,t.jsx)("p",{className:"text-xs text-amber-300",children:o.lastError}):null,"error"===o.phase&&o.error?(0,t.jsx)("p",{className:"text-xs text-red-400",children:o.error}):null,u?(0,t.jsx)("p",{className:"text-xs text-red-400",children:u}):null]})}e.s(["JobLogStream",0,function({jobId:e,endpoint:a,onDone:n,onStatus:o,onLogin:l}){let[i,c]=(0,r.useState)([]),[d,u]=(0,r.useState)(null),x=(0,r.useRef)(null),m=(0,r.useRef)(n);m.current=n;let p=(0,r.useRef)(o);p.current=o;let b=(0,r.useRef)(l);return b.current=l,(0,r.useEffect)(()=>{p.current?.("streaming");let t=new EventSource(a??`/api/jobs/${encodeURIComponent(e)}/logs`);return t.addEventListener("log",e=>{let t=JSON.parse(e.data);c(e=>[...e,t])}),t.addEventListener("login",e=>{let t=JSON.parse(e.data);u(t),b.current?.(t)}),t.addEventListener("end",e=>{let r=JSON.parse(e.data);p.current?.(r.status),m.current?.(r.status),t.close()}),()=>t.close()},[e,a]),(0,r.useEffect)(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[i]),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[d&&"done"!==d.phase?(0,t.jsx)(s,{jobId:e,login:d}):null,(0,t.jsx)("pre",{ref:x,className:"max-h-[440px] min-h-[220px] overflow-auto whitespace-pre rounded-lg bg-[#16181c] p-3 font-mono text-[11.5px] leading-relaxed text-[#d6d9de]",children:0===i.length?"starting…":i.join("\n")})]})}])},33789,1485,e=>{"use strict";var t=e.i(1262),r=e.i(54129);e.s(["Ago",0,function({ms:e}){let[a,n]=(0,r.useState)(!1);return(0,r.useEffect)(()=>n(!0),[]),(0,t.jsx)("span",{suppressHydrationWarning:!0,children:a?function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return t+"s ago";let r=Math.floor(t/60);if(r<60)return r+"m ago";let a=Math.floor(r/60);return a<24?a+"h ago":Math.floor(a/24)+"d ago"}(e):new Date(e).toLocaleDateString()})}],33789),e.s(["SectionLabel",0,function({children:e,right:r}){return(0,t.jsxs)("div",{className:"mb-3 mt-8 flex items-center gap-2.5 font-mono text-[11px] uppercase tracking-[.1em] text-[#a4a9b0]",children:[e,(0,t.jsx)("span",{className:"h-px flex-1 bg-border"}),r??null]})}],1485)},9383,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var a={callServer:function(){return s.callServer},createServerReference:function(){return l.createServerReference},findSourceMapURL:function(){return o.findSourceMapURL}};for(var n in a)Object.defineProperty(r,n,{enumerable:!0,get:a[n]});let s=e.r(57855),o=e.r(61414),l=e.r(97615)},31758,e=>{"use strict";var t=e.i(1262),r=e.i(44344);e.s(["EmptyBox",0,function({children:e}){return(0,t.jsxs)("div",{className:"rounded-xl border border-dashed border-border bg-card px-5 py-9 text-center text-[13.5px] text-muted-foreground",children:[(0,t.jsx)("div",{className:"mx-auto mb-3 grid h-10 w-10 place-items-center rounded-lg border border-border text-[#a4a9b0]",children:(0,t.jsx)(r.Icons.box,{className:"size-5"})}),e]})}])},23878,e=>{"use strict";var t=e.i(1262),r=e.i(65232);e.s(["Table",0,function({className:e,...a}){return(0,t.jsx)("table",{className:(0,r.cn)("w-full caption-bottom text-sm",e),...a})},"TableBody",0,function({className:e,...a}){return(0,t.jsx)("tbody",{className:(0,r.cn)("[&_tr:last-child]:border-0",e),...a})},"TableCell",0,function({className:e,...a}){return(0,t.jsx)("td",{className:(0,r.cn)("px-4 py-3 align-middle",e),...a})},"TableHead",0,function({className:e,...a}){return(0,t.jsx)("th",{className:(0,r.cn)("h-9 px-4 text-left align-middle font-mono text-[10.5px] font-normal uppercase tracking-[.08em] text-muted-foreground/90",e),...a})},"TableHeader",0,function({className:e,...a}){return(0,t.jsx)("thead",{className:(0,r.cn)("bg-background [&_tr]:border-b [&_tr]:border-border",e),...a})},"TableRow",0,function({className:e,...a}){return(0,t.jsx)("tr",{className:(0,r.cn)("border-b border-border/60 transition-colors hover:bg-[#fcfcfb] data-[state=selected]:bg-accent",e),...a})}])},22983,93268,66818,e=>{"use strict";var t=e.i(1262),r=e.i(45971),a=e.i(33789),n=e.i(44344),s=e.i(86892),o=e.i(8536),l=e.i(23878),i=e.i(30544);e.s(["BoxTable",0,function({boxes:e}){let c=(0,r.useRouter)();return(0,t.jsx)(o.Card,{className:"overflow-hidden",children:(0,t.jsxs)(l.Table,{children:[(0,t.jsx)(l.TableHeader,{children:(0,t.jsxs)(l.TableRow,{className:"hover:bg-transparent",children:[(0,t.jsx)(l.TableHead,{className:"w-[38%]",children:"Task"}),(0,t.jsx)(l.TableHead,{className:"w-[27%] max-md:hidden",children:"Branch"}),(0,t.jsx)(l.TableHead,{className:"max-md:hidden",children:"Status"}),(0,t.jsx)(l.TableHead,{className:"text-right",children:"Actions"})]})}),(0,t.jsx)(l.TableBody,{children:e.map(e=>(0,t.jsxs)(l.TableRow,{className:"cursor-pointer",onClick:()=>c.push("/boxes/"+e.id),children:[(0,t.jsxs)(l.TableCell,{children:[(0,t.jsx)("div",{className:"truncate text-[13.5px] font-medium",children:e.task}),(0,t.jsxs)("div",{className:"mt-0.5 font-mono text-[11px] text-[#a4a9b0]",children:[e.id," · ",e.host]})]}),(0,t.jsxs)(l.TableCell,{className:"max-md:hidden",children:[(0,t.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1.5 font-mono text-xs text-secondary-foreground",children:[(0,t.jsx)(n.Icons.branch,{className:"size-3 flex-none text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.branch})]}),(0,t.jsxs)("div",{className:"mt-0.5 font-mono text-[11px] text-[#a4a9b0]",children:[e.agent," · ",(0,t.jsx)(a.Ago,{ms:e.lastActivity})]})]}),(0,t.jsx)(l.TableCell,{className:"max-md:hidden",children:(0,t.jsx)(s.StatusBadge,{status:e.status})}),(0,t.jsx)(l.TableCell,{className:"text-right",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(i.BoxActions,{box:e})})]},e.id))})]})})}],22983);var c=e.i(54129),d=e.i(64595),u=e.i(69377),x=e.i(95141),m=e.i(3060),p=e.i(49604),b=e.i(65232);function h({className:e,...r}){return(0,t.jsx)("textarea",{className:(0,b.cn)("flex min-h-[76px] w-full resize-y rounded-lg border border-input bg-card px-3 py-2 text-sm leading-normal shadow-sm transition-[border-color,box-shadow] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/15",e),...r})}var f=e.i(9383);let g=(0,f.createServerReference)("4070192706087364b8c7d220576a6f3e4d3e5c532b",f.callServer,void 0,f.findSourceMapURL,"createBoxAction"),j=(0,f.createServerReference)("40386bdce4d894a318a969412fa1299d2704ccdfb3",f.callServer,void 0,f.findSourceMapURL,"listBranchesAction");var v=e.i(96621),N=e.i(86184);let S=[{id:"docker",label:"Docker (local)",configured:!0}];function y({project:e,projects:a,onClose:s}){let o=(0,r.useRouter)(),{state:l}=(0,v.useStore)(),i=l.providers.length?l.providers:S,[d,f]=(0,c.useTransition)(),[C,B]=(0,c.useState)(e?.id??a[0]?.id??""),[R,T]=(0,c.useState)("claude"),[I,D]=(0,c.useState)("docker"),[L,A]=(0,c.useState)(""),[P,E]=(0,c.useState)(""),[z,U]=(0,c.useState)(""),[H,M]=(0,c.useState)(null),[O,F]=(0,c.useState)(!1),[$,_]=(0,c.useState)(!1),[J,q]=(0,c.useState)(null),[K,W]=(0,c.useState)(null),[G,V]=(0,c.useState)("streaming"),[Y,Q]=(0,c.useState)(null),[X,Z]=(0,c.useState)(null),[ee,et]=(0,c.useState)(!1),[er,ea]=(0,c.useState)(null);(0,c.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/v1/providers?freshness=1",{credentials:"same-origin"});if(!t.ok)return;let r=await t.json();if(e)return;let a={};for(let e of r.providers??[])a[e.id]={baseStatus:e.baseStatus,baseStaleReason:e.baseStaleReason,jobId:e.jobId};ea(a)}catch{}})(),()=>{e=!0}},[]);let en=a.find(e=>e.id===C)??e,es=I??"docker",eo=i.find(e=>e.id===es),el=er?.[es],ei=!!el&&(!!el.jobId||"unprepared"===el.baseStatus||"stale"===el.baseStatus);(0,c.useEffect)(()=>{if(!C||K)return;F(en?.needsSetup??!1),D("docker");let e=!1;return M(null),U(en?.currentBranch??""),j(C).then(t=>{if(e||!t.ok){e||t.ok||M([]);return}M(t.branches),t.current&&t.branches.includes(t.current)&&U(t.current)}),()=>{e=!0}},[C,K]);let ec=()=>{q(null);let e=el?.jobId;e?Z(e):f(async()=>{try{let e=await fetch(`/api/v1/providers/${encodeURIComponent(es)}/prepare`,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t?.jobId)return void q(t?.error?.message??`base image build request failed (${e.status})`);Z(t.jobId)}catch(e){q(e instanceof Error?e.message:String(e))}})},ed=()=>{q(null),f(async()=>{let e=await g({projectId:C,agent:R,provider:I,name:L.trim()||void 0,prompt:"none"===R?void 0:P.trim()||void 0,fromBranch:z.trim()&&z.trim()!==en?.currentBranch?z.trim():void 0,setupWizard:"none"!==R&&O});e.ok?(W(e.jobId),o.refresh()):q(e.error)})};return(0,t.jsxs)(x.Dialog,{onClose:s,className:K||X?"max-w-[900px]":"max-w-[560px]",children:[(0,t.jsxs)(x.DialogHeader,{children:[(0,t.jsx)(x.DialogIcon,{children:(0,t.jsx)(n.Icons.box,{})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(x.DialogTitle,{children:!K&&X?"Building base image":"Create box"}),(0,t.jsx)(x.DialogDescription,{children:en?en.name:"Start a box in a project"})]}),K||X?(0,t.jsx)("div",{className:"ml-auto mr-8 flex-none pt-0.5",children:(0,t.jsx)(w,{status:G,loginPhase:Y})}):null]}),(0,t.jsx)(x.DialogBody,{className:"flex flex-col gap-4",children:K?(0,t.jsx)(N.JobLogStream,{jobId:K,onStatus:V,onDone:()=>o.refresh(),onLogin:e=>Q(e?.phase??null)}):X?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:["Building the ",eo?.label??es," base image — one-time, can take several minutes. The box is created automatically when it finishes."]}),(0,t.jsx)(N.JobLogStream,{jobId:X,onStatus:V,onDone:e=>{"done"===e?ed():q(`base image build ${e}`)}}),J?(0,t.jsx)("div",{className:"font-mono text-xs text-destructive",children:J}):null]}):(0,t.jsxs)(t.Fragment,{children:[e?null:(0,t.jsx)(k,{label:"Project",children:(0,t.jsxs)(p.Select,{value:C,onChange:e=>B(e.target.value),children:[0===a.length?(0,t.jsx)("option",{value:"",children:"No projects — add one first"}):null,a.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,t.jsx)(k,{label:"Provider",children:(0,t.jsx)(p.Select,{value:I,onChange:e=>D(e.target.value),children:i.map(e=>(0,t.jsxs)("option",{value:e.id,disabled:!e.configured,title:e.reason,children:[e.label,e.configured?"":" — not configured"]},e.id))})}),ei?(0,t.jsx)("p",{className:"-mt-2 font-mono text-xs text-amber-600 dark:text-amber-400",title:el?.baseStaleReason,children:el?.jobId?"A base-image build is already running — the box will be created when it finishes.":el?.baseStatus==="unprepared"?"First use of this provider: the base image will be downloaded or built first (can take 5–10 minutes).":"The base image is out of date and will be rebuilt first (can take 5–10 minutes)."}):null,(0,t.jsx)(k,{label:"Agent",children:(0,t.jsxs)(p.Select,{value:R,onChange:e=>T(e.target.value),children:[(0,t.jsx)("option",{value:"claude",children:"Claude"}),(0,t.jsx)("option",{value:"codex",children:"Codex"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"}),(0,t.jsx)("option",{value:"none",children:"Empty — just create the box"})]})}),(0,t.jsx)(k,{label:"Name (optional)",children:(0,t.jsx)(m.Input,{value:L,onChange:e=>A(e.target.value),placeholder:"auto"})}),en?.needsSetup&&"none"!==R?(0,t.jsxs)("label",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("input",{type:"checkbox",checked:O,onChange:e=>F(e.target.checked),className:"mt-0.5 h-4 w-4 flex-none accent-primary"}),(0,t.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-secondary-foreground",children:"Run setup wizard"}),(0,t.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:"This project has no agentbox.yaml — the agent explores the repo and proposes one on its first turn."})]})]}):null,"none"===R?(0,t.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:["The box is created and left running with no agent — attach later from a terminal or SSH (",(0,t.jsx)("span",{className:"text-secondary-foreground",children:"agentbox shell"}),")."]}):null,(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>_(e=>!e),className:"flex cursor-pointer items-center gap-1.5 self-start text-xs font-medium text-secondary-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(n.Icons.chevR,{className:(0,b.cn)("size-3.5 transition-transform",$&&"rotate-90")}),"Advanced"]}),$?(0,t.jsxs)(t.Fragment,{children:[null===H?(0,t.jsx)(k,{label:"Base branch",children:(0,t.jsx)(p.Select,{value:"",disabled:!0,children:(0,t.jsx)("option",{value:"",children:"Loading branches…"})})}):H.length>0?(0,t.jsx)(k,{label:"Base branch",children:(0,t.jsxs)(p.Select,{value:z,onChange:e=>U(e.target.value),children:[en?.currentBranch&&!H.includes(en.currentBranch)?(0,t.jsxs)("option",{value:"",children:[en.currentBranch," (current)"]}):null,H.map(e=>(0,t.jsxs)("option",{value:e,children:[e,e===en?.currentBranch?" (current)":""]},e))]})}):null,"none"!==R?(0,t.jsx)(k,{label:"Initial prompt (optional)",children:(0,t.jsx)(h,{value:P,onChange:e=>E(e.target.value),rows:3,placeholder:"Leave empty to just start the agent — attach later from a terminal or SSH."})}):null]}):null]}),J?(0,t.jsx)("div",{className:"font-mono text-xs text-destructive",children:J}):null]})}),(0,t.jsx)(x.DialogFooter,{children:K||X?(0,t.jsxs)(t.Fragment,{children:["streaming"===G?(0,t.jsx)("span",{className:"mr-auto self-center font-mono text-xs text-muted-foreground",children:K?"The box + agent start in the background — you can close this.":"Keep this open — the box is created when the build finishes."}):null,(0,t.jsx)(u.Button,{onClick:s,children:"Close"})]}):ee?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"mr-auto self-center font-mono text-xs text-muted-foreground",title:el?.baseStaleReason,children:["The ",eo?.label??es," base image is out of date."]}),(0,t.jsx)(u.Button,{variant:"outline",onClick:()=>et(!1),disabled:d,children:"Cancel"}),(0,t.jsx)(u.Button,{variant:"outline",onClick:()=>{et(!1),ed()},disabled:d,children:"Use existing image"}),(0,t.jsx)(u.Button,{onClick:()=>{et(!1),ec()},disabled:d,children:"Rebuild & create"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Button,{variant:"outline",onClick:s,disabled:d,children:"Cancel"}),(0,t.jsx)(u.Button,{onClick:()=>{(q(null),C)?ei?"docker"===es||el?.baseStatus!=="stale"||el.jobId?ec():et(!0):ed():q("pick a project")},disabled:d||!C,children:d?"Starting…":"Create box"})]})})]})}function w({status:e,loginPhase:r}){return"done"===e?(0,t.jsxs)(d.Badge,{className:"badge-run",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Done"]}):"failed"===e||"error"===e||"cancelled"===e?(0,t.jsxs)(d.Badge,{className:"badge-err",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Failed"]}):"error"===r?(0,t.jsxs)(d.Badge,{className:"badge-err",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Login failed"]}):"awaiting-code"===r||"starting"===r||"exchanging"===r?(0,t.jsxs)(d.Badge,{className:"badge-create",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Login required"]}):(0,t.jsxs)(d.Badge,{className:"badge-create",children:[(0,t.jsx)("span",{className:"badge-dot"}),"Working…"]})}function k({label:e,children:r}){return(0,t.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-secondary-foreground",children:e}),r]})}e.s(["CreateBoxButton",0,function({project:e,projects:r,variant:a,size:s,className:o}){let[l,i]=(0,c.useState)(!1);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(u.Button,{variant:a,size:s,className:o,onClick:()=>i(!0),children:[(0,t.jsx)(n.Icons.plus,{}),"Create box"]}),l?(0,t.jsx)(y,{project:e,projects:r??(e?[e]:[]),onClose:()=>i(!1)}):null]})}],93268);let C=(0,f.createServerReference)("40c7856bd78dddab224344045df78d51620e411335",f.callServer,void 0,f.findSourceMapURL,"removeProjectAction");e.s(["DeleteProjectButton",0,function({project:e,size:a,className:s,redirectHome:o}){let l=(0,r.useRouter)(),[i,d]=(0,c.useTransition)();return(0,t.jsxs)(u.Button,{variant:"destructive",size:a,className:s,title:"Delete project",disabled:i,onClick:t=>{t.stopPropagation(),t.preventDefault(),window.confirm(`Remove project "${e.name}" from the hub? Its folder and files are NOT deleted — this only unregisters it (and any hub-set project settings). This cannot be undone.`)&&d(async()=>{let t=await C(e.id);t.ok?o?l.push("/"):l.refresh():window.alert(`Delete failed: ${t.error}`)})},children:[(0,t.jsx)(n.Icons.trash,{}),"Delete"]})}],66818)},86691,e=>{"use strict";var t=e.i(1262),r=e.i(45971),a=e.i(33789),n=e.i(44344),s=e.i(96621),o=e.i(80922),l=e.i(22983),i=e.i(93268),c=e.i(66818),d=e.i(31758),u=e.i(1485),x=e.i(35594);e.s(["default",0,function(){let{id:e}=(0,r.useParams)(),{project:m,boxesFor:p}=(0,s.useStore)(),b=m(e);if(!b)return(0,t.jsxs)("div",{className:"mx-auto w-full max-w-[1080px] px-8 pb-16 pt-8",children:[(0,t.jsx)(o.BackLink,{to:"/",children:"Dashboard"}),(0,t.jsx)(d.EmptyBox,{children:"Project not found."})]});let h=p(e),f=h.filter(e=>"running"===e.status).length;return(0,t.jsxs)("div",{className:"mx-auto w-full max-w-[1080px] px-8 pb-16 pt-8 max-sm:px-4",children:[(0,t.jsx)(o.BackLink,{to:"/",children:"All projects"}),(0,t.jsxs)("div",{className:"flex items-start gap-4 max-md:flex-col",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h1",{className:"flex items-center gap-3 text-[25px] font-semibold leading-tight tracking-[-0.025em]",children:[(0,t.jsx)("span",{className:"grid h-[26px] w-[26px] flex-none place-items-center rounded-md border border-[var(--green-line)] bg-accent text-primary",children:(0,t.jsx)(n.Icons.folder,{className:"size-[15px]"})}),b.name]}),(0,t.jsxs)("div",{className:"mt-1.5 text-sm text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-mono text-secondary-foreground",children:b.repo})," · ",b.provider]})]}),(0,t.jsxs)("div",{className:"ml-auto flex flex-none gap-2 max-md:ml-0",children:[(0,t.jsx)(i.CreateBoxButton,{project:b}),0===h.length?(0,t.jsx)(c.DeleteProjectButton,{project:b,redirectHome:!0}):null]})]}),(0,t.jsx)("div",{className:"mt-5",children:(0,t.jsxs)(x.StatGrid,{children:[(0,t.jsx)(x.Stat,{k:"Boxes",v:h.length,icon:n.Icons.box}),(0,t.jsx)(x.Stat,{k:"Running",v:f,icon:n.Icons.activity}),(0,t.jsx)(x.Stat,{k:"Provider",v:b.provider,mono:!0}),(0,t.jsx)(x.Stat,{k:"Created",v:(0,t.jsx)(a.Ago,{ms:b.createdAt}),mono:!0})]})}),(0,t.jsx)(u.SectionLabel,{children:"Boxes"}),h.length?(0,t.jsx)(l.BoxTable,{boxes:h}):(0,t.jsx)(d.EmptyBox,{children:(0,t.jsx)("div",{children:"No boxes yet."})})]})}])}]);