@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
@@ -22,14 +22,15 @@ import {
22
22
  readBoxStatus,
23
23
  registerBoxWithRelay,
24
24
  syncClaudeCredentials
25
- } from "./chunk-LA4JMS27.js";
25
+ } from "./chunk-I654PBHA.js";
26
26
  import {
27
27
  hashProjectPath,
28
28
  loadEffectiveConfig,
29
29
  projectDirSegment,
30
30
  sanitizeMnemonic
31
- } from "./chunk-QT3SHMLY.js";
31
+ } from "./chunk-UIRBYL4G.js";
32
32
  import {
33
+ AGENT_SYNC_SPECS,
33
34
  BOX_DYNAMIC_SYNC_MANIFEST,
34
35
  BOX_HOME,
35
36
  BOX_MEMORY_DIR,
@@ -37,20 +38,26 @@ import {
37
38
  DEFAULT_BOX_IMAGE,
38
39
  SEED_MARKER,
39
40
  SYNC_DRYRUN_ENV,
41
+ UserFacingError,
40
42
  allocateProjectIndex,
41
43
  buildHostSyncManifest,
42
44
  computeSyncDelta,
45
+ describeInbound,
43
46
  detectGitRepos,
44
47
  dirnameUnix,
45
48
  dryRunProviderSync,
46
49
  extractCredentials,
47
50
  generateBoxId,
48
51
  hostClaudeBackupExpired,
52
+ isRealAgentCredential,
49
53
  makeHostGitPorts,
50
54
  makeSyncContext,
55
+ parseInboundSpec,
51
56
  planCarryEntry,
57
+ pushCredentialToBox,
52
58
  pushEnvFiles,
53
59
  readCliStamp,
60
+ readCredentialBackup,
54
61
  readPreparedStateRaw,
55
62
  readState,
56
63
  recordBox,
@@ -58,6 +65,7 @@ import {
58
65
  renderCarryEntries,
59
66
  resolveSyncTopology,
60
67
  resyncWorkspace,
68
+ shouldAcceptCredentialUpdate,
61
69
  stageClaudeCredentialsForUpload,
62
70
  stageClaudeJsonOnlyForUpload,
63
71
  stageClaudeStaticForUpload,
@@ -66,8 +74,9 @@ import {
66
74
  stageDynamicSyncTarball,
67
75
  stageOpencodeCredentialsForUpload,
68
76
  stageOpencodeStateForUpload,
69
- stageOpencodeStaticForUpload
70
- } from "./chunk-LK2JT2OO.js";
77
+ stageOpencodeStaticForUpload,
78
+ writeCredentialBackup
79
+ } from "./chunk-DEDTPG2D.js";
71
80
 
72
81
  // ../../packages/sandbox-cloud/dist/index.js
73
82
  import { basename as basename2, resolve } from "path";
@@ -613,6 +622,44 @@ async function extractCloudAgentCredentials(backend, handle, opts = {}) {
613
622
  const transport = createCloudSyncTransport({ backend, handle });
614
623
  return extractCredentials(transport, { onLog: opts.onLog, backups: opts.backups });
615
624
  }
625
+ async function reconcileAgentCredentials(backend, handle, opts = {}) {
626
+ return reconcileAgentCredentialsViaTransport(
627
+ createCloudSyncTransport({ backend, handle }),
628
+ opts
629
+ );
630
+ }
631
+ async function reconcileAgentCredentialsViaTransport(transport, opts = {}) {
632
+ const log = opts.onLog ?? (() => {
633
+ });
634
+ for (const spec of AGENT_SYNC_SPECS) {
635
+ const backupPath = opts.backups?.[spec.id];
636
+ try {
637
+ const hostText = await readCredentialBackup(spec.id, { backupPath });
638
+ const boxText = await transport.readText(spec.credential.boxAbsPath);
639
+ const hostReal = hostText !== null && isRealAgentCredential(spec.id, hostText);
640
+ const boxReal = boxText !== null && boxText.length > 0 && isRealAgentCredential(spec.id, boxText);
641
+ if (!hostReal && !boxReal) continue;
642
+ if (!hostReal && boxReal) {
643
+ await writeCredentialBackup(spec.id, boxText, { backupPath });
644
+ log(`captured ${spec.id} credential from box (no host backup)`);
645
+ continue;
646
+ }
647
+ if (boxReal && spec.credential.realShape === "claude-oauth" && shouldAcceptCredentialUpdate(spec.id, boxText, hostText).accept) {
648
+ await writeCredentialBackup(spec.id, boxText, { backupPath });
649
+ log(`captured newer ${spec.id} credential from box`);
650
+ continue;
651
+ }
652
+ if (!boxReal || shouldAcceptCredentialUpdate(spec.id, hostText, boxText).accept) {
653
+ await pushCredentialToBox(transport, spec.id, hostText);
654
+ log(`refreshed ${spec.id} credential in box from host backup`);
655
+ }
656
+ } catch (err) {
657
+ log(
658
+ `WARN: ${spec.id} credential reconcile failed (${err instanceof Error ? err.message : String(err)}) \u2014 skipping`
659
+ );
660
+ }
661
+ }
662
+ }
616
663
  function sq(p) {
617
664
  return `'${p.replace(/'/g, `'\\''`)}'`;
618
665
  }
@@ -752,6 +799,73 @@ async function seedGitIdentity(backend, handle, opts = {}) {
752
799
  }
753
800
  log(`git: configured committer identity ${name} <${email}>`);
754
801
  }
802
+ async function seedGitCredentials(backend, handle, opts = {}) {
803
+ const log = opts.onLog ?? (() => {
804
+ });
805
+ const host = await readHostOriginHost(opts.hostRepo);
806
+ const qHost = quoteShellArg(host);
807
+ const httpsKey = quoteShellArg(`url.https://${host}/.insteadOf`);
808
+ const sshKey = quoteShellArg(`url.git@${host}:.insteadOf`);
809
+ const tokenCfg = [
810
+ `git config --global credential.helper store`,
811
+ `git config --global --unset-all ${httpsKey} 2>/dev/null || true`,
812
+ `git config --global --add ${httpsKey} ${quoteShellArg(`git@${host}:`)}`,
813
+ `git config --global --add ${httpsKey} ${quoteShellArg(`ssh://git@${host}/`)}`
814
+ ].join(" && ");
815
+ const sshCfg = [
816
+ `git config --global --replace-all ${sshKey} ${quoteShellArg(`https://${host}/`)}`,
817
+ `AGB_KEY=$(ls "$HOME"/.ssh/id_ed25519 "$HOME"/.ssh/id_rsa "$HOME"/.ssh/id_ecdsa 2>/dev/null | head -1)`,
818
+ `if [ -z "$AGB_KEY" ]; then AGB_KEY=$(find "$HOME/.ssh" -maxdepth 1 -type f ! -name '*.pub' ! -name 'config' ! -name 'known_hosts*' ! -name 'authorized_keys' 2>/dev/null | head -1); fi`,
819
+ `git config --global core.sshCommand "ssh\${AGB_KEY:+ -i $AGB_KEY} -o StrictHostKeyChecking=accept-new"`,
820
+ await buildSigningSnippet(opts.hostRepo)
821
+ ].filter(Boolean).join("; ");
822
+ const script = [
823
+ // carry chowns to a fixed uid (1000); the box user is 1001/1002 elsewhere.
824
+ // Re-own so the box can read its own 0600 creds. Provider-agnostic.
825
+ `sudo -n chown -R "$(id -u):$(id -g)" "$HOME/.git-credentials" "$HOME/.ssh" 2>/dev/null || true`,
826
+ `chmod 600 "$HOME/.git-credentials" 2>/dev/null || true`,
827
+ `chmod 700 "$HOME/.ssh" 2>/dev/null || true`,
828
+ // Any copied key (default OR custom basename) must be 0600 for ssh.
829
+ `find "$HOME/.ssh" -maxdepth 1 -type f -exec chmod 600 {} + 2>/dev/null || true`,
830
+ `HOST=${qHost}`,
831
+ // Mode comes from the explicit marker the gate wrote (so a stray `carry:`
832
+ // ~/.git-credentials can't flip an SSH-mode box to HTTPS); fall back to file
833
+ // presence for boxes created before the marker existed. SSH mode accepts ANY
834
+ // private key (default OR a custom basename from an `IdentityFile`). Whatever
835
+ // the mode, the matching credential must actually be present — if not, the
836
+ // carry dropped it, so exit non-zero and fail the create rather than stamp a
837
+ // broken direct box.
838
+ `AGB_HAS_KEY() { find "$HOME/.ssh" -maxdepth 1 -type f ! -name '*.pub' ! -name 'config' ! -name 'known_hosts*' ! -name 'authorized_keys' 2>/dev/null | grep -q .; }`,
839
+ `MODE=$(cat "$HOME/.config/agentbox/git-direct-mode" 2>/dev/null)`,
840
+ `if [ -z "$MODE" ]; then if [ -f "$HOME/.git-credentials" ]; then MODE=token; elif AGB_HAS_KEY; then MODE=ssh; fi; fi`,
841
+ `if [ "$MODE" = token ] && [ -f "$HOME/.git-credentials" ]; then ${tokenCfg}; elif [ "$MODE" = ssh ] && AGB_HAS_KEY; then ${sshCfg}; else echo "agentbox: git.pushMode=direct but the chosen credential ($MODE) did not land in the box (carry upload failed?)" >&2; exit 3; fi`
842
+ ].join("\n");
843
+ const r = await backend.exec(handle, bashScript(script));
844
+ if (r.exitCode !== 0) {
845
+ throw new Error(
846
+ `git.pushMode=direct: configuring box-held credentials failed (exit ${String(r.exitCode)}): ${(r.stderr || r.stdout).trim()}`
847
+ );
848
+ }
849
+ log("git: configured box-held credentials (direct push mode)");
850
+ }
851
+ async function buildSigningSnippet(hostRepo) {
852
+ const gpgsign = (await readHostGitConfig("commit.gpgsign", hostRepo))?.toLowerCase();
853
+ const format = (await readHostGitConfig("gpg.format", hostRepo))?.toLowerCase();
854
+ const signingKey = await readHostGitConfig("user.signingkey", hostRepo);
855
+ if (gpgsign !== "true" || !signingKey || format !== "ssh") return "";
856
+ const looksLikePath = signingKey.includes("/") && !signingKey.startsWith("key::");
857
+ const boxKey = looksLikePath ? `/home/vscode/.ssh/${signingKey.split("/").pop() ?? ""}` : signingKey;
858
+ const priv = looksLikePath ? `/home/vscode/.ssh/${(signingKey.split("/").pop() ?? "").replace(/\.pub$/, "")}` : boxKey;
859
+ return `git config --global gpg.format ssh && git config --global user.signingkey ${quoteShellArg(boxKey)} && if ssh-keygen -y -P '' -f ${quoteShellArg(priv)} >/dev/null 2>&1; then git config --global commit.gpgsign true; else git config --global --unset commit.gpgsign 2>/dev/null || true; echo "agentbox: signing key needs a passphrase \u2014 leaving commit signing OFF so in-box commits do not fail" >&2; fi`;
860
+ }
861
+ async function readHostOriginHost(hostRepo) {
862
+ const args = hostRepo ? ["-C", hostRepo, "remote", "get-url", "origin"] : ["remote", "get-url", "origin"];
863
+ const r = await execa3("git", args, { reject: false });
864
+ const url = r.exitCode === 0 ? (r.stdout ?? "").trim() : "";
865
+ const m = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?([^/:]+)/i.exec(url) ?? /^(?:[^@/]+@)?([^/:]+):/i.exec(url);
866
+ const host = m?.[1];
867
+ return host && host.length > 0 ? host : "github.com";
868
+ }
755
869
  async function readHostGitConfig(key, hostRepo) {
756
870
  const args = hostRepo ? ["-C", hostRepo, "config", key] : ["config", key];
757
871
  const r = await execa3("git", args, { reject: false });
@@ -818,7 +932,10 @@ async function uploadOneEntry(args) {
818
932
  const localTar = join4(args.stageDir, `carry-${String(args.index)}.tar`);
819
933
  const excludeArgs = isDir ? exclude.map((p) => `--exclude=${p}`) : [];
820
934
  const tarArgs = isDir ? ["-C", entry.absSrc, "-cf", localTar, ...excludeArgs, "."] : ["-C", dirnameUnix(entry.absSrc), "-cf", localTar, fileBase];
821
- const packed = await execa4("tar", tarArgs, { reject: false });
935
+ const packed = await execa4("tar", tarArgs, {
936
+ reject: false,
937
+ env: { ...process.env, COPYFILE_DISABLE: "1" }
938
+ });
822
939
  if (packed.exitCode !== 0) {
823
940
  throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
824
941
  }
@@ -1287,6 +1404,9 @@ function buildBootstrapEnv(args) {
1287
1404
  if (lease) {
1288
1405
  boxEnvFile.push(`AGENTBOX_GIT_LEASE=1`);
1289
1406
  }
1407
+ if (pushMode === "direct") {
1408
+ boxEnvFile.push(`AGENTBOX_GIT_DIRECT=1`);
1409
+ }
1290
1410
  return { env, boxEnvFile };
1291
1411
  }
1292
1412
  async function kickCloudBootstrap(args) {
@@ -1444,7 +1564,7 @@ function buildCarryOverSteps(opts) {
1444
1564
  }
1445
1565
  if (opts.hasUntracked) {
1446
1566
  steps.push(
1447
- opts.detectConflicts ? `if [ -f ${untracked} ]; then tar -tzf ${untracked} | while IFS= read -r p; do case "$p" in ''|*/) continue ;; esac; if [ -e ${wd}/"$p" ]; then echo "${OVERLAY_SKIP_MARKER}$p"; fi; done || true ; tar -C ${wd} --skip-old-files -xzf ${untracked} || true ; rm -f ${untracked} ; fi` : `if [ -f ${untracked} ]; then tar -C ${wd} -xzf ${untracked} && rm -f ${untracked} ; fi`
1567
+ opts.detectConflicts ? `if [ -f ${untracked} ]; then tar -tzf ${untracked} | while IFS= read -r p; do case "$p" in ''|*/) continue ;; esac; if [ -e ${wd}/"$p" ]; then echo "${OVERLAY_SKIP_MARKER}$p"; fi; done || true ; tar -C ${wd} --skip-old-files --no-same-owner -xzf ${untracked} || true ; rm -f ${untracked} ; fi` : `if [ -f ${untracked} ]; then tar -C ${wd} --no-same-owner -xzf ${untracked} && rm -f ${untracked} ; fi`
1448
1568
  );
1449
1569
  }
1450
1570
  return steps;
@@ -1527,8 +1647,7 @@ async function seedFromGitClone(args) {
1527
1647
  });
1528
1648
  const gitDir = `${args.workspaceDir}/.git`;
1529
1649
  const prepSteps = args.overlay ? [`$SUDO rm -rf ${quoteShellArgv([gitDir])}`] : [
1530
- `$SUDO rm -rf ${quoteShellArgv([args.workspaceDir])}`,
1531
- `$SUDO mkdir -p ${quoteShellArgv([args.workspaceDir])}`,
1650
+ ...wipeDirSteps(args.workspaceDir),
1532
1651
  `$SUDO chown "$(id -un):$(id -gn)" ${quoteShellArgv([args.workspaceDir])}`
1533
1652
  ];
1534
1653
  const checkoutSteps = args.overlay ? [
@@ -1553,7 +1672,12 @@ async function seedFromGitClone(args) {
1553
1672
  // `/workspace/<rel>`, so the root clone is preserved). Overlay: rm only
1554
1673
  // `<dir>/.git`, preserving the warm working tree.
1555
1674
  ...prepSteps,
1556
- `tar -C ${quoteShellArgv([args.workspaceDir])} -xzf ${quoteShellArgv([remoteTar])}`,
1675
+ // --no-same-owner (here and on every extraction in this file): clouds
1676
+ // whose exec user is root would otherwise preserve the HOST's numeric
1677
+ // uids from the tarball, and git then fails with "dubious ownership"
1678
+ // on /workspace/.git. Non-root extraction already behaves this way
1679
+ // (tar defaults to --no-same-owner unless root).
1680
+ `tar -C ${quoteShellArgv([args.workspaceDir])} --no-same-owner -xzf ${quoteShellArgv([remoteTar])}`,
1557
1681
  setOrigin,
1558
1682
  ...checkoutSteps,
1559
1683
  ...carryOverSteps,
@@ -1674,7 +1798,7 @@ async function tryReseedRepoDelta(args) {
1674
1798
  hasUntracked: untrackedSize > 0,
1675
1799
  detectConflicts: true
1676
1800
  });
1677
- const lfsStep = deltaLfsSize > 0 ? `tar -C ${quoteShellArgv([`${args.workspaceDir}/.git`])} -xzf ${quoteShellArgv([REMOTE_DELTA_LFS])}` : ": # no delta lfs objects";
1801
+ const lfsStep = deltaLfsSize > 0 ? `tar -C ${quoteShellArgv([`${args.workspaceDir}/.git`])} --no-same-owner -xzf ${quoteShellArgv([REMOTE_DELTA_LFS])}` : ": # no delta lfs objects";
1678
1802
  const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
1679
1803
  const script = [
1680
1804
  `set -euo pipefail`,
@@ -1835,6 +1959,10 @@ async function readOriginUrl(hostRepo) {
1835
1959
  const out = (r.stdout ?? "").trim();
1836
1960
  return out.length > 0 ? out : null;
1837
1961
  }
1962
+ function wipeDirSteps(dir) {
1963
+ const q = quoteShellArgv([dir]);
1964
+ return [`$SUDO mkdir -p ${q}`, `$SUDO find ${q} -mindepth 1 -maxdepth 1 -exec rm -rf {} +`];
1965
+ }
1838
1966
  async function seedFromTar(args) {
1839
1967
  const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-tar-"));
1840
1968
  const tarPath = join7(stage, "workspace.tar.gz");
@@ -1852,10 +1980,9 @@ async function seedFromTar(args) {
1852
1980
  // (index-pack) fails with "Unable to read current working directory".
1853
1981
  `cd /tmp`,
1854
1982
  SUDO,
1855
- `$SUDO rm -rf ${quoteShellArgv([args.workspaceDir])}`,
1856
- `$SUDO mkdir -p ${quoteShellArgv([args.workspaceDir])}`,
1983
+ ...wipeDirSteps(args.workspaceDir),
1857
1984
  `$SUDO chown "$(id -un):$(id -gn)" ${quoteShellArgv([args.workspaceDir])}`,
1858
- `tar -C ${quoteShellArgv([args.workspaceDir])} -xzf ${quoteShellArgv([remoteTar])}`,
1985
+ `tar -C ${quoteShellArgv([args.workspaceDir])} --no-same-owner -xzf ${quoteShellArgv([remoteTar])}`,
1859
1986
  `rm -f ${quoteShellArgv([remoteTar])}`
1860
1987
  ].join("\n");
1861
1988
  const r = await args.backend.exec(args.handle, bashScript(script));
@@ -1952,7 +2079,7 @@ function createCloudProvider(backend, opts = {}) {
1952
2079
  if (!sandboxId) {
1953
2080
  throw new Error(`cloud box ${box.name} has no sandboxId \u2014 record is malformed`);
1954
2081
  }
1955
- return { sandboxId };
2082
+ return { sandboxId, inbound: box.cloud?.inbound };
1956
2083
  }
1957
2084
  function mintBox(req) {
1958
2085
  const id = generateBoxId();
@@ -2124,6 +2251,14 @@ function createCloudProvider(backend, opts = {}) {
2124
2251
  } catch {
2125
2252
  }
2126
2253
  }
2254
+ try {
2255
+ const credentialSync = (await loadEffectiveConfig(box.workspacePath)).effective.box.credentialSync;
2256
+ if (credentialSync) {
2257
+ await reconcileAgentCredentials(backend, h, { onLog: () => {
2258
+ } });
2259
+ }
2260
+ } catch {
2261
+ }
2127
2262
  return next;
2128
2263
  }
2129
2264
  return {
@@ -2134,15 +2269,17 @@ function createCloudProvider(backend, opts = {}) {
2134
2269
  });
2135
2270
  const { id, name, branch } = mintBox(req);
2136
2271
  const image = opts.provisionImage ? await opts.provisionImage(req) : req.image ?? FALLBACK_IMAGE;
2137
- const baseResources = opts.defaultResources ?? { cpu: 2, memory: 4, disk: 8 };
2138
- const vcpuOverride = req.providerOptions?.["vcpus"];
2139
- const resources = typeof vcpuOverride === "number" && vcpuOverride > 0 ? { ...baseResources, cpu: vcpuOverride } : baseResources;
2272
+ const resources = opts.defaultResources ?? { cpu: 2, memory: 4, disk: 8 };
2140
2273
  const timeoutOverride = req.providerOptions?.["timeoutMs"];
2141
2274
  const timeoutMs = typeof timeoutOverride === "number" && timeoutOverride > 0 ? timeoutOverride : void 0;
2142
2275
  const networkPolicyOpt = req.providerOptions?.["networkPolicy"];
2143
2276
  const networkPolicy = typeof networkPolicyOpt === "string" && networkPolicyOpt.trim() !== "" ? networkPolicyOpt.trim() : void 0;
2144
2277
  const sizeOpt = req.providerOptions?.["size"];
2145
2278
  const size = typeof sizeOpt === "string" && sizeOpt.trim() !== "" ? sizeOpt.trim() : void 0;
2279
+ const locationOpt = req.providerOptions?.["location"];
2280
+ const location = typeof locationOpt === "string" && locationOpt.trim() !== "" ? locationOpt.trim() : void 0;
2281
+ const inboundOpt = req.providerOptions?.["inbound"];
2282
+ const inbound = typeof inboundOpt === "string" && inboundOpt.trim() !== "" ? inboundOpt.trim() : void 0;
2146
2283
  const relayToken = generateRelayToken();
2147
2284
  const bridgeToken = generateRelayToken();
2148
2285
  try {
@@ -2172,10 +2309,13 @@ function createCloudProvider(backend, opts = {}) {
2172
2309
  }
2173
2310
  const agentVolumes = await ensureAgentVolumesForCloud(backend, { onLog: log });
2174
2311
  const exposeServicePorts = await readExposedServicePorts(req.workspacePath);
2312
+ const credentialSyncOff = (req.credentialSync ?? (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective.box.credentialSync) === false;
2175
2313
  const provisionEnv = {
2176
2314
  AGENTBOX_BOX_ID: id,
2177
2315
  AGENTBOX_BOX_NAME: name,
2178
2316
  AGENTBOX_BOX_KIND: "cloud",
2317
+ // Absent = enabled; the ctl credential watcher only checks for '0'.
2318
+ ...credentialSyncOff ? { AGENTBOX_CREDENTIAL_SYNC: "0" } : {},
2179
2319
  // In-sandbox relay is on the box's loopback at the in-box port.
2180
2320
  // 8788 is distinct from the host relay's 8787 so a nested agentbox
2181
2321
  // run inside the box can claim :8787 without colliding.
@@ -2194,6 +2334,8 @@ function createCloudProvider(backend, opts = {}) {
2194
2334
  snapshot,
2195
2335
  resources,
2196
2336
  size,
2337
+ location,
2338
+ inbound,
2197
2339
  timeoutMs,
2198
2340
  exposePorts: exposeServicePorts,
2199
2341
  networkPolicy,
@@ -2223,6 +2365,14 @@ function createCloudProvider(backend, opts = {}) {
2223
2365
  throw err;
2224
2366
  }
2225
2367
  }
2368
+ if (handle.resources) {
2369
+ const r = handle.resources;
2370
+ const parts = [];
2371
+ if (typeof r.cpu === "number") parts.push(`${String(r.cpu)} vCPU`);
2372
+ if (typeof r.memory === "number") parts.push(`${String(r.memory)} GB RAM`);
2373
+ if (typeof r.disk === "number") parts.push(`${String(r.disk)} GB disk`);
2374
+ if (parts.length > 0) log(`provisioned ${parts.join(" / ")}`);
2375
+ }
2226
2376
  const inBoxClone = req.inBoxClone ? {
2227
2377
  authedUrl: req.inBoxClone.authedUrl,
2228
2378
  originUrl: req.inBoxClone.originUrl,
@@ -2279,6 +2429,12 @@ function createCloudProvider(backend, opts = {}) {
2279
2429
  carrySummary = { count: result.applied.length, entries: result.applied };
2280
2430
  }
2281
2431
  }
2432
+ if (req.gitPushMode === "direct") {
2433
+ await seedGitCredentials(backend, handle, {
2434
+ hostRepo: req.workspacePath,
2435
+ onLog: log
2436
+ });
2437
+ }
2282
2438
  const vncEnabled = req.vnc?.enabled !== false;
2283
2439
  const vncPassword = vncEnabled ? generateVncPassword() : void 0;
2284
2440
  const wp = backend.webProxyPort ?? CLOUD_WEB_PROXY_PORT;
@@ -2472,6 +2628,12 @@ function createCloudProvider(backend, opts = {}) {
2472
2628
  snapshotRef: resolvedCheckpointRef,
2473
2629
  lastState: "running",
2474
2630
  sessionTimeoutMs: timeoutMs,
2631
+ // Real resources the backend reported (Hetzner: the plan's actual
2632
+ // cores/memory/disk). Absent → readers fall back to defaultResources.
2633
+ resources: handle.resources,
2634
+ // Inbound-access policy the backend applied to the per-box firewall
2635
+ // (VPS providers). Persisted so drift re-syncs preserve the whitelist.
2636
+ inbound: handle.inbound,
2475
2637
  // Only host-seeded boxes share a fork base with the host, so only
2476
2638
  // they can be resynced back to the host tip on session start (7.5).
2477
2639
  // inBoxClone / plane boxes clone from a leased URL — left unset.
@@ -2517,6 +2679,42 @@ function createCloudProvider(backend, opts = {}) {
2517
2679
  async repairReachability(box) {
2518
2680
  return await backend.repairReachability?.(handleFor(box)) ?? { changed: false };
2519
2681
  },
2682
+ async setInbound(box, spec, onLog) {
2683
+ if (!backend.setInbound) {
2684
+ throw new UserFacingError(
2685
+ `inbound access control isn't supported for provider '${providerName}' \u2014 it has no per-box firewall (only hetzner / digitalocean do).`
2686
+ );
2687
+ }
2688
+ const policy = parseInboundSpec(spec);
2689
+ const { sources } = await backend.setInbound(handleFor(box), policy);
2690
+ onLog?.(`${describeInbound(policy)} -> ${sources.join(", ")}`);
2691
+ const cloud = box.cloud;
2692
+ if (cloud) await recordBox({ ...box, cloud: { ...cloud, inbound: policy } });
2693
+ return policy;
2694
+ },
2695
+ async enableDirectGit(box, entries, opts2) {
2696
+ const onLog = opts2?.onLog;
2697
+ const handle = handleFor(box);
2698
+ const ctx = makeSyncContext({
2699
+ boxName: box.name,
2700
+ boxId: box.id,
2701
+ provider: "cloud",
2702
+ hostWorkspace: box.workspacePath,
2703
+ boxWorkspace: CLOUD_WORKSPACE_DIR,
2704
+ onLog
2705
+ });
2706
+ await makeCloudSync(backend, handle).applyCarry(ctx, entries);
2707
+ await seedGitCredentials(backend, handle, { hostRepo: opts2?.hostRepo, onLog });
2708
+ const flip = 'if ! sudo -n grep -q "^AGENTBOX_GIT_DIRECT=" /etc/agentbox/box.env 2>/dev/null; then echo AGENTBOX_GIT_DIRECT=1 | sudo -n tee -a /etc/agentbox/box.env >/dev/null; fi';
2709
+ const r = await backend.exec(handle, bashScript(flip));
2710
+ if (r.exitCode !== 0) {
2711
+ throw new Error(
2712
+ `enableDirectGit: failed to set AGENTBOX_GIT_DIRECT in box env: ${r.stderr || r.stdout || `exit ${String(r.exitCode)}`}`
2713
+ );
2714
+ }
2715
+ const cloud = box.cloud;
2716
+ if (cloud) await recordBox({ ...box, cloud: { ...cloud, gitPushMode: "direct" } });
2717
+ },
2520
2718
  async pause(box) {
2521
2719
  await backend.pause(handleFor(box));
2522
2720
  await persistLastState(box, "paused");
@@ -2670,6 +2868,9 @@ function createCloudProvider(backend, opts = {}) {
2670
2868
  sync(box) {
2671
2869
  return makeCloudSync(backend, handleFor(box));
2672
2870
  },
2871
+ syncTransport(box) {
2872
+ return createCloudSyncTransport({ backend, handle: handleFor(box) });
2873
+ },
2673
2874
  // Session-start live-box resync (Phase 7.5): merge the host's current state
2674
2875
  // back into the box, box-wins on conflict. Gated on `hostSeeded` so
2675
2876
  // inBoxClone / plane boxes (no host fork base) are left untouched. The box
@@ -2871,4 +3072,4 @@ export {
2871
3072
  renderInnerCommand,
2872
3073
  openWebAppOnVncScreen
2873
3074
  };
2874
- //# sourceMappingURL=chunk-I6ZRWTPR.js.map
3075
+ //# sourceMappingURL=chunk-6U2S6QWD.js.map