@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
@@ -0,0 +1,845 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ claudeInstallFingerprint,
4
+ computeContextSha256,
5
+ hostOpenCommand,
6
+ preparedStatePathFor,
7
+ readPreparedStateRaw,
8
+ writePreparedStateRaw
9
+ } from "./chunk-DEDTPG2D.js";
10
+
11
+ // ../../packages/sandbox-digitalocean/dist/chunk-NIR5EL3O.js
12
+ import { existsSync, readFileSync } from "fs";
13
+ import { homedir } from "os";
14
+ import { resolve } from "path";
15
+ import { spawnSync } from "child_process";
16
+ import {
17
+ chmodSync,
18
+ existsSync as existsSync2,
19
+ mkdirSync,
20
+ readFileSync as readFileSync2,
21
+ renameSync,
22
+ writeFileSync
23
+ } from "fs";
24
+ import { homedir as homedir2 } from "os";
25
+ import { dirname, resolve as resolve2 } from "path";
26
+ import {
27
+ cancel,
28
+ confirm,
29
+ isCancel,
30
+ intro,
31
+ log,
32
+ note,
33
+ outro,
34
+ password,
35
+ spinner
36
+ } from "@clack/prompts";
37
+ import { existsSync as existsSync3 } from "fs";
38
+ import { dirname as dirname2, resolve as resolve3 } from "path";
39
+ import { fileURLToPath } from "url";
40
+ var DIGITALOCEAN_KEYS = ["DIGITALOCEAN_TOKEN", "DIGITALOCEAN_API_URL"];
41
+ var loaded = false;
42
+ function ensureDigitalOceanEnvLoaded() {
43
+ if (loaded) return;
44
+ loaded = true;
45
+ importDigitalOceanFromFile(resolve(homedir(), ".agentbox", "secrets.env"));
46
+ }
47
+ function importDigitalOceanFromFile(path) {
48
+ if (!existsSync(path)) return;
49
+ let body;
50
+ try {
51
+ body = readFileSync(path, "utf8");
52
+ } catch {
53
+ return;
54
+ }
55
+ const parsed = parseEnvFile(body);
56
+ for (const key of DIGITALOCEAN_KEYS) {
57
+ if (process.env[key] !== void 0) continue;
58
+ const value = parsed[key];
59
+ if (typeof value === "string") {
60
+ process.env[key] = value;
61
+ }
62
+ }
63
+ }
64
+ function parseEnvFile(body) {
65
+ const out = {};
66
+ for (const rawLine of body.split(/\r?\n/)) {
67
+ const line = rawLine.trim();
68
+ if (line.length === 0 || line.startsWith("#")) continue;
69
+ const stripped = line.startsWith("export ") ? line.slice("export ".length) : line;
70
+ const eq = stripped.indexOf("=");
71
+ if (eq <= 0) continue;
72
+ const key = stripped.slice(0, eq).trim();
73
+ let value = stripped.slice(eq + 1).trim();
74
+ if (value.length >= 2 && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'"))) {
75
+ value = value.slice(1, -1);
76
+ }
77
+ out[key] = value;
78
+ }
79
+ return out;
80
+ }
81
+ var DEFAULT_DO_ENDPOINT = "https://api.digitalocean.com/v2";
82
+ var DigitalOceanApiError = class extends Error {
83
+ statusCode;
84
+ code;
85
+ requestId;
86
+ constructor(statusCode, code, message, requestId) {
87
+ super(`digitalocean ${String(statusCode)} ${code}: ${message}`);
88
+ this.name = "DigitalOceanApiError";
89
+ this.statusCode = statusCode;
90
+ this.code = code;
91
+ this.requestId = requestId;
92
+ }
93
+ };
94
+ function makeDigitalOceanClient(opts = {}) {
95
+ ensureDigitalOceanEnvLoaded();
96
+ const rawToken = opts.token ?? process.env.DIGITALOCEAN_TOKEN;
97
+ if (!rawToken || rawToken.trim().length === 0) {
98
+ throw new Error(
99
+ "DigitalOcean credentials not configured: DIGITALOCEAN_TOKEN is empty.\nRun `agentbox digitalocean login` interactively, or set DIGITALOCEAN_TOKEN in the environment."
100
+ );
101
+ }
102
+ const token = rawToken.trim();
103
+ const endpoint = (opts.endpoint ?? process.env.DIGITALOCEAN_API_URL ?? DEFAULT_DO_ENDPOINT).replace(/\/$/, "");
104
+ const fetchImpl = opts.fetchImpl ?? fetch;
105
+ async function req(method, path, body) {
106
+ const url = path.startsWith("http") ? path : `${endpoint}${path}`;
107
+ const init = {
108
+ method,
109
+ headers: {
110
+ Authorization: `Bearer ${token}`,
111
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {}
112
+ },
113
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
114
+ };
115
+ const res = await fetchImpl(url, init);
116
+ if (res.status === 204) return null;
117
+ if (res.status === 404) return null;
118
+ if (!res.ok) {
119
+ let parsed = {};
120
+ try {
121
+ parsed = await res.json();
122
+ } catch {
123
+ }
124
+ const code = parsed.id ?? `http_${String(res.status)}`;
125
+ const msg = parsed.message ?? res.statusText ?? "unknown error";
126
+ throw new DigitalOceanApiError(res.status, code, msg, parsed.request_id);
127
+ }
128
+ const text = await res.text();
129
+ if (text.length === 0) return null;
130
+ return JSON.parse(text);
131
+ }
132
+ async function reqExpect(method, path, body) {
133
+ const out = await req(method, path, body);
134
+ if (out === null) {
135
+ throw new DigitalOceanApiError(0, "empty_response", `expected a body from ${method} ${path}`);
136
+ }
137
+ return out;
138
+ }
139
+ async function paginate(firstPath, key) {
140
+ const all = [];
141
+ let next = firstPath;
142
+ while (next) {
143
+ const r = await reqExpect("GET", next);
144
+ const page = r[key] ?? [];
145
+ all.push(...page);
146
+ const links = r.links;
147
+ next = links?.pages?.next;
148
+ }
149
+ return all;
150
+ }
151
+ function withPerPage(path) {
152
+ return path.includes("?") ? `${path}&per_page=200` : `${path}?per_page=200`;
153
+ }
154
+ async function dropletAction(id, payload) {
155
+ const r = await reqExpect(
156
+ "POST",
157
+ `/droplets/${String(id)}/actions`,
158
+ payload
159
+ );
160
+ return r.action;
161
+ }
162
+ return {
163
+ async getAccount() {
164
+ const r = await reqExpect("GET", "/account");
165
+ return r.account;
166
+ },
167
+ async getDroplet(id) {
168
+ const r = await req("GET", `/droplets/${String(id)}`);
169
+ return r?.droplet ?? null;
170
+ },
171
+ async createDroplet(reqBody) {
172
+ const r = await reqExpect("POST", "/droplets", reqBody);
173
+ const createAction = r.links?.actions?.find((a) => a.rel === "create") ?? r.links?.actions?.[0];
174
+ return { droplet: r.droplet, actionId: createAction?.id ?? null };
175
+ },
176
+ async listDroplets(opts2) {
177
+ const base = opts2?.tag_name ? `/droplets?tag_name=${encodeURIComponent(opts2.tag_name)}` : "/droplets";
178
+ return paginate(withPerPage(base), "droplets");
179
+ },
180
+ async deleteDroplet(id) {
181
+ await req("DELETE", `/droplets/${String(id)}`);
182
+ },
183
+ async powerOn(id) {
184
+ return dropletAction(id, { type: "power_on" });
185
+ },
186
+ async powerOff(id) {
187
+ return dropletAction(id, { type: "power_off" });
188
+ },
189
+ async shutdown(id) {
190
+ return dropletAction(id, { type: "shutdown" });
191
+ },
192
+ async snapshotDroplet(id, name) {
193
+ return dropletAction(id, { type: "snapshot", name });
194
+ },
195
+ async getAction(id) {
196
+ const r = await req("GET", `/actions/${String(id)}`);
197
+ return r?.action ?? null;
198
+ },
199
+ async listSnapshots() {
200
+ return paginate(
201
+ withPerPage("/snapshots?resource_type=droplet"),
202
+ "snapshots"
203
+ );
204
+ },
205
+ async getSnapshot(id) {
206
+ const r = await req("GET", `/snapshots/${encodeURIComponent(id)}`);
207
+ return r?.snapshot ?? null;
208
+ },
209
+ async deleteSnapshot(id) {
210
+ await req("DELETE", `/snapshots/${encodeURIComponent(id)}`);
211
+ },
212
+ async listSizes() {
213
+ return paginate(withPerPage("/sizes"), "sizes");
214
+ },
215
+ async createFirewall(reqBody) {
216
+ const r = await reqExpect("POST", "/firewalls", reqBody);
217
+ return r.firewall;
218
+ },
219
+ async getFirewall(id) {
220
+ const r = await req("GET", `/firewalls/${encodeURIComponent(id)}`);
221
+ return r?.firewall ?? null;
222
+ },
223
+ async listFirewalls() {
224
+ return paginate(withPerPage("/firewalls"), "firewalls");
225
+ },
226
+ async updateFirewall(id, reqBody) {
227
+ const r = await reqExpect(
228
+ "PUT",
229
+ `/firewalls/${encodeURIComponent(id)}`,
230
+ reqBody
231
+ );
232
+ return r.firewall;
233
+ },
234
+ async deleteFirewall(id) {
235
+ await req("DELETE", `/firewalls/${encodeURIComponent(id)}`);
236
+ },
237
+ async createTag(name) {
238
+ try {
239
+ await req("POST", "/tags", { name });
240
+ } catch (err) {
241
+ if (err instanceof DigitalOceanApiError && err.statusCode === 422) return;
242
+ throw err;
243
+ }
244
+ },
245
+ async deleteTag(name) {
246
+ await req("DELETE", `/tags/${encodeURIComponent(name)}`);
247
+ }
248
+ };
249
+ }
250
+ function exitOnCancel(v) {
251
+ if (isCancel(v)) {
252
+ cancel("Cancelled.");
253
+ process.exit(130);
254
+ }
255
+ return v;
256
+ }
257
+ var DASHBOARD_KEYS_URL = "https://cloud.digitalocean.com/account/api/tokens";
258
+ var MANAGED_KEYS = ["DIGITALOCEAN_TOKEN", "DIGITALOCEAN_API_URL"];
259
+ async function ensureDigitalOceanCredentials(opts = {}) {
260
+ ensureDigitalOceanEnvLoaded();
261
+ if (!opts.force && hasUsableCredentials()) return;
262
+ if (!process.stdin.isTTY) return;
263
+ intro("DigitalOcean setup");
264
+ note(
265
+ `AgentBox needs a DigitalOcean Personal Access Token to provision Droplets.
266
+
267
+ 1. Open ${DASHBOARD_KEYS_URL}
268
+ 2. Click "Generate New Token".
269
+ 3. Give it Read + Write scopes, then copy the token.`,
270
+ "API token required"
271
+ );
272
+ const open = exitOnCancel(
273
+ await confirm({
274
+ message: `Open ${DASHBOARD_KEYS_URL} in your browser?`,
275
+ initialValue: true
276
+ })
277
+ );
278
+ if (open) openDashboard();
279
+ for (let attempt = 0; attempt < 2; attempt++) {
280
+ const creds = await promptForCredentials();
281
+ const result = await validateCredentials(creds);
282
+ if (result.ok) {
283
+ persistCredentials(creds);
284
+ log.success(`DigitalOcean credentials saved to ${secretsPath()}`);
285
+ outro("Setup complete.");
286
+ return;
287
+ }
288
+ if (result.kind === "auth" && attempt === 0) {
289
+ log.error(`That token was rejected by DigitalOcean: ${result.message}`);
290
+ log.info("Try again, or press Ctrl-C to cancel.");
291
+ continue;
292
+ }
293
+ if (result.kind === "network") {
294
+ log.warn(`Could not reach DigitalOcean to validate (${result.message}) \u2014 saving anyway.`);
295
+ persistCredentials(creds);
296
+ log.success(`DigitalOcean credentials saved to ${secretsPath()}`);
297
+ outro("Setup complete (unvalidated).");
298
+ return;
299
+ }
300
+ throw new Error(`DigitalOcean credentials rejected: ${result.message}`);
301
+ }
302
+ }
303
+ function hasUsableCredentials() {
304
+ return typeof process.env.DIGITALOCEAN_TOKEN === "string" && process.env.DIGITALOCEAN_TOKEN.length > 0;
305
+ }
306
+ async function promptForCredentials() {
307
+ const token = exitOnCancel(
308
+ await password({
309
+ message: "Paste your DigitalOcean Cloud API token",
310
+ validate(v) {
311
+ if (!v || v.trim().length === 0) return "Cannot be empty";
312
+ return void 0;
313
+ }
314
+ })
315
+ );
316
+ return { token: token.trim() };
317
+ }
318
+ async function validateCredentials(creds) {
319
+ const s = spinner();
320
+ s.start("Validating credentials with DigitalOcean");
321
+ try {
322
+ const client = makeDigitalOceanClient({ token: creds.token, endpoint: creds.endpoint });
323
+ await client.getAccount();
324
+ s.stop("DigitalOcean credentials accepted");
325
+ return { ok: true };
326
+ } catch (err) {
327
+ const message = err instanceof Error ? err.message : String(err);
328
+ s.stop("DigitalOcean credentials check failed");
329
+ if (/401|403|unauthor|forbidden|invalid|token/i.test(message)) {
330
+ return { ok: false, kind: "auth", message };
331
+ }
332
+ return { ok: false, kind: "network", message };
333
+ }
334
+ }
335
+ function persistCredentials(creds) {
336
+ process.env.DIGITALOCEAN_TOKEN = creds.token;
337
+ if (creds.endpoint) process.env.DIGITALOCEAN_API_URL = creds.endpoint;
338
+ const path = secretsPath();
339
+ mkdirSync(dirname(path), { recursive: true });
340
+ let existing = "";
341
+ if (existsSync2(path)) {
342
+ try {
343
+ existing = readFileSync2(path, "utf8");
344
+ } catch {
345
+ existing = "";
346
+ }
347
+ }
348
+ const kept = existing.split(/\r?\n/).filter((line) => {
349
+ const stripped = line.startsWith("export ") ? line.slice("export ".length) : line;
350
+ const eq = stripped.indexOf("=");
351
+ if (eq <= 0) return true;
352
+ const key = stripped.slice(0, eq).trim();
353
+ return !MANAGED_KEYS.includes(key);
354
+ }).join("\n").replace(/\s+$/u, "");
355
+ const lines = [`DIGITALOCEAN_TOKEN=${creds.token}`];
356
+ if (creds.endpoint) lines.push(`DIGITALOCEAN_API_URL=${creds.endpoint}`);
357
+ const body = (kept ? `${kept}
358
+ ` : "") + lines.join("\n") + "\n";
359
+ const tmp = `${path}.tmp`;
360
+ writeFileSync(tmp, body, { mode: 384 });
361
+ try {
362
+ chmodSync(tmp, 384);
363
+ } catch {
364
+ }
365
+ renameSync(tmp, path);
366
+ try {
367
+ chmodSync(path, 384);
368
+ } catch {
369
+ }
370
+ }
371
+ async function setDigitalOceanCredentials(fields) {
372
+ const token = (fields.token ?? "").trim();
373
+ const endpoint = (fields.endpoint ?? "").trim() || void 0;
374
+ if (!token) {
375
+ return { ok: false, error: "token is required", status: { configured: false } };
376
+ }
377
+ const creds = { token, endpoint };
378
+ const result = await validateCredentials(creds);
379
+ if (!result.ok && result.kind === "auth") {
380
+ return {
381
+ ok: false,
382
+ error: `token rejected by DigitalOcean: ${result.message}`,
383
+ status: { configured: false }
384
+ };
385
+ }
386
+ persistCredentials(creds);
387
+ const label = result.ok ? "token" : "token (unvalidated)";
388
+ return { ok: true, status: { configured: true, label } };
389
+ }
390
+ function openDashboard() {
391
+ try {
392
+ const r = spawnSync(hostOpenCommand(), [DASHBOARD_KEYS_URL], { stdio: "ignore" });
393
+ if (r.status !== 0) {
394
+ log.warn(`Could not auto-open the browser \u2014 visit ${DASHBOARD_KEYS_URL} manually.`);
395
+ }
396
+ } catch {
397
+ log.warn(`Could not auto-open the browser \u2014 visit ${DASHBOARD_KEYS_URL} manually.`);
398
+ }
399
+ }
400
+ function secretsPath() {
401
+ return resolve2(homedir2(), ".agentbox", "secrets.env");
402
+ }
403
+ function readDigitalOceanCredStatus() {
404
+ const shellHadToken = !!process.env.DIGITALOCEAN_TOKEN;
405
+ ensureDigitalOceanEnvLoaded();
406
+ const token = process.env.DIGITALOCEAN_TOKEN;
407
+ const endpoint = process.env.DIGITALOCEAN_API_URL;
408
+ if (!token) return { source: "none" };
409
+ return {
410
+ token,
411
+ endpoint,
412
+ source: shellHadToken ? "env" : "secrets.env"
413
+ };
414
+ }
415
+ function maskKey(value) {
416
+ if (value.length <= 8) return "*".repeat(value.length);
417
+ return `${value.slice(0, 4)}\u2026${"*".repeat(8)}${value.slice(-4)}`;
418
+ }
419
+ var PROBES = [
420
+ "https://api.ipify.org",
421
+ "https://ifconfig.io/ip",
422
+ "https://icanhazip.com"
423
+ ];
424
+ var TIMEOUT_MS = 3e3;
425
+ var IPV4_RE = /^(?:\d{1,3}\.){3}\d{1,3}$/;
426
+ var IPV6_RE = /^[0-9a-fA-F:]+$/;
427
+ async function detectEgressIp(opts = {}) {
428
+ const probes = opts.probes ?? PROBES;
429
+ const timeout = opts.timeoutMs ?? TIMEOUT_MS;
430
+ const fetchImpl = opts.fetchImpl ?? fetch;
431
+ const errors = [];
432
+ for (const url of probes) {
433
+ try {
434
+ const ip = await raceTimeout(probe(url, fetchImpl), timeout);
435
+ if (ip) {
436
+ opts.onLog?.(`egress-ip: detected ${ip} via ${url}`);
437
+ return ip;
438
+ }
439
+ errors.push(`${url}: empty/invalid response`);
440
+ } catch (err) {
441
+ errors.push(`${url}: ${err instanceof Error ? err.message : String(err)}`);
442
+ }
443
+ }
444
+ throw new Error(
445
+ `could not auto-detect the host's egress IP \u2014 all ${String(probes.length)} probes failed:
446
+ ` + errors.map((e) => ` - ${e}`).join("\n") + `
447
+ Override with --firewall-source <cidr> (e.g. --firewall-source 0.0.0.0/0 for the explicit-open opt-in).`
448
+ );
449
+ }
450
+ async function probe(url, fetchImpl) {
451
+ const res = await fetchImpl(url, { method: "GET" });
452
+ if (!res.ok) return null;
453
+ const body = (await res.text()).trim();
454
+ if (IPV4_RE.test(body)) {
455
+ const parts = body.split(".").map((p) => Number.parseInt(p, 10));
456
+ if (parts.every((p) => p >= 0 && p <= 255)) return body;
457
+ return null;
458
+ }
459
+ if (IPV6_RE.test(body) && body.includes(":")) return body;
460
+ return null;
461
+ }
462
+ async function raceTimeout(p, ms) {
463
+ let timer;
464
+ try {
465
+ return await Promise.race([
466
+ p,
467
+ new Promise((_resolve, reject) => {
468
+ timer = setTimeout(() => reject(new Error(`probe timed out after ${String(ms)}ms`)), ms);
469
+ })
470
+ ]);
471
+ } finally {
472
+ if (timer !== void 0) clearTimeout(timer);
473
+ }
474
+ }
475
+ var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
476
+ var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
477
+ var AttemptTimeoutError = class extends Error {
478
+ constructor(method, ms) {
479
+ super(`digitalocean ${method}: per-attempt timeout after ${String(ms)}ms`);
480
+ this.name = "AttemptTimeoutError";
481
+ }
482
+ };
483
+ function isAttemptTimeout(err) {
484
+ return err instanceof AttemptTimeoutError;
485
+ }
486
+ function isRetriable(err, allowAmbiguous) {
487
+ if (err instanceof DigitalOceanApiError) {
488
+ if (err.statusCode === 429 || err.code === "rate_limit_exceeded") return true;
489
+ if (err.statusCode >= 500 && err.statusCode <= 599) return allowAmbiguous;
490
+ if (err.code === "locked" || err.code === "conflict") return true;
491
+ return false;
492
+ }
493
+ if (err instanceof AttemptTimeoutError) return allowAmbiguous;
494
+ if (err && typeof err === "object") {
495
+ const candidates = [err, err.cause];
496
+ for (const c of candidates) {
497
+ if (!c || typeof c !== "object") continue;
498
+ const code = c.code;
499
+ if (code === "ECONNRESET" || code === "ETIMEDOUT" || code === "ECONNABORTED" || code === "EAI_AGAIN" || code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "UND_ERR_SOCKET" || code === "UND_ERR_CONNECT_TIMEOUT") {
500
+ return allowAmbiguous;
501
+ }
502
+ }
503
+ }
504
+ return false;
505
+ }
506
+ async function withDigitalOceanRetry(opts, fn) {
507
+ const backoff = opts.backoffMs ?? DEFAULT_BACKOFF;
508
+ const maxAttempts = backoff.length + 1;
509
+ const timeoutMs = opts.attemptTimeoutMs ?? DEFAULT_ATTEMPT_TIMEOUT_MS;
510
+ const log2 = opts.onRetry ?? defaultRetryLog;
511
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
512
+ try {
513
+ return await raceTimeout2(fn(), timeoutMs, opts.method);
514
+ } catch (err) {
515
+ const last = attempt === maxAttempts;
516
+ if (last || !isRetriable(err, opts.retryOnAmbiguous)) throw err;
517
+ const delay = backoff[attempt - 1] ?? backoff[backoff.length - 1] ?? 4e3;
518
+ log2(
519
+ `digitalocean ${opts.method}: attempt ${String(attempt)} failed (${errorSummary(err)}); retrying in ${String(delay)}ms`
520
+ );
521
+ await sleep(delay);
522
+ }
523
+ }
524
+ throw new Error(`withDigitalOceanRetry: exhausted attempts for ${opts.method}`);
525
+ }
526
+ function defaultRetryLog(line) {
527
+ process.stderr.write(`
528
+ [digitalocean-retry] ${line}
529
+ `);
530
+ }
531
+ function sleep(ms) {
532
+ return new Promise((resolve4) => setTimeout(resolve4, ms));
533
+ }
534
+ async function raceTimeout2(p, ms, method) {
535
+ let timer;
536
+ try {
537
+ return await Promise.race([
538
+ p,
539
+ new Promise((_resolve, reject) => {
540
+ timer = setTimeout(() => reject(new AttemptTimeoutError(method, ms)), ms);
541
+ })
542
+ ]);
543
+ } finally {
544
+ if (timer !== void 0) clearTimeout(timer);
545
+ }
546
+ }
547
+ function errorSummary(err) {
548
+ if (err instanceof DigitalOceanApiError) {
549
+ return `DigitalOceanApiError ${String(err.statusCode)} ${err.code}: ${truncate(err.message)}`;
550
+ }
551
+ if (err instanceof Error) {
552
+ const code = err.code;
553
+ return code !== void 0 ? `${err.name}(${String(code)}): ${truncate(err.message)}` : `${err.name}: ${truncate(err.message)}`;
554
+ }
555
+ return truncate(String(err));
556
+ }
557
+ function truncate(s, max = 160) {
558
+ return s.length > max ? `${s.slice(0, max)}\u2026` : s;
559
+ }
560
+ function sshInboundRules(sources) {
561
+ const addresses = Array.isArray(sources) ? sources : [sources];
562
+ return [
563
+ {
564
+ protocol: "tcp",
565
+ ports: "22",
566
+ sources: { addresses }
567
+ }
568
+ ];
569
+ }
570
+ function allowAllOutboundRules() {
571
+ const everywhere = { addresses: ["0.0.0.0/0", "::/0"] };
572
+ return [
573
+ { protocol: "tcp", ports: "1-65535", destinations: everywhere },
574
+ { protocol: "udp", ports: "1-65535", destinations: everywhere },
575
+ // icmp takes no ports in DigitalOcean's API.
576
+ { protocol: "icmp", destinations: everywhere }
577
+ ];
578
+ }
579
+ async function createPerBoxFirewall(client, opts) {
580
+ await withDigitalOceanRetry(
581
+ { method: "createTag", retryOnAmbiguous: true, attemptTimeoutMs: 6e4 },
582
+ () => client.createTag(opts.tag)
583
+ );
584
+ const body = {
585
+ name: opts.name,
586
+ inbound_rules: sshInboundRules(opts.sources),
587
+ outbound_rules: allowAllOutboundRules(),
588
+ tags: [opts.tag]
589
+ };
590
+ return withDigitalOceanRetry(
591
+ { method: "createFirewall", retryOnAmbiguous: false, attemptTimeoutMs: 6e4 },
592
+ () => client.createFirewall(body)
593
+ );
594
+ }
595
+ async function syncFirewallSource(client, firewall, sources) {
596
+ const body = {
597
+ name: firewall.name,
598
+ inbound_rules: sshInboundRules(sources),
599
+ outbound_rules: allowAllOutboundRules(),
600
+ droplet_ids: firewall.droplet_ids,
601
+ tags: firewall.tags
602
+ };
603
+ await withDigitalOceanRetry(
604
+ { method: "updateFirewall", retryOnAmbiguous: true, attemptTimeoutMs: 6e4 },
605
+ () => client.updateFirewall(firewall.id, body)
606
+ );
607
+ }
608
+ async function findFirewallForDroplet(client, dropletId, dropletTags) {
609
+ const tagSet = new Set(dropletTags);
610
+ const all = await client.listFirewalls();
611
+ return all.find(
612
+ (fw) => fw.droplet_ids.includes(dropletId) || fw.tags.some((t) => tagSet.has(t))
613
+ ) ?? null;
614
+ }
615
+ async function deletePerBoxFirewall(client, firewallId, opts = {}) {
616
+ const deadline = Date.now() + (opts.detachWaitMs ?? 6e4);
617
+ let interval = 1e3;
618
+ const cleanupTags = async () => {
619
+ for (const t of opts.tags ?? []) {
620
+ try {
621
+ await client.deleteTag(t);
622
+ } catch {
623
+ }
624
+ }
625
+ };
626
+ while (true) {
627
+ try {
628
+ await withDigitalOceanRetry(
629
+ { method: "deleteFirewall", retryOnAmbiguous: true, attemptTimeoutMs: 3e4 },
630
+ () => client.deleteFirewall(firewallId)
631
+ );
632
+ await cleanupTags();
633
+ return;
634
+ } catch (err) {
635
+ if (err instanceof DigitalOceanApiError && (err.statusCode === 404 || err.code === "not_found")) {
636
+ await cleanupTags();
637
+ return;
638
+ }
639
+ const stillAttached = err instanceof DigitalOceanApiError && (err.statusCode === 409 || err.code === "conflict" || err.code === "resource_in_use");
640
+ if (stillAttached && Date.now() < deadline) {
641
+ await new Promise((r) => setTimeout(r, interval));
642
+ interval = Math.min(interval * 2, 8e3);
643
+ continue;
644
+ }
645
+ throw err;
646
+ }
647
+ }
648
+ }
649
+ function normalizeSourceCidr(raw) {
650
+ const trimmed = raw.trim();
651
+ if (trimmed.includes("/")) return trimmed;
652
+ if (trimmed.includes(":")) return `${trimmed}/128`;
653
+ return `${trimmed}/32`;
654
+ }
655
+ var SELF = dirname2(fileURLToPath(import.meta.url));
656
+ function findStagedCliRuntimeRoot() {
657
+ const candidates = [
658
+ resolve3(SELF, "..", "runtime"),
659
+ // <cliRoot>/dist/.. → <cliRoot> then /runtime
660
+ resolve3(SELF, "..", "..", "runtime")
661
+ // chunk-NNNN.js at <cliRoot>/dist/<sub>/.. → <cliRoot>/runtime
662
+ ];
663
+ for (const c of candidates) {
664
+ if (existsSync3(resolve3(c, "digitalocean", "scripts", "install-box.sh"))) return c;
665
+ }
666
+ return void 0;
667
+ }
668
+ var RUNTIME_ASSETS = [
669
+ { name: "install-box.sh", remoteBasename: "agentbox-install.sh", remoteMode: 493 },
670
+ { name: "agentbox-ctl", remoteBasename: "agentbox-ctl", remoteMode: 493 },
671
+ { name: "agentbox-vnc-start", remoteBasename: "agentbox-vnc-start", remoteMode: 493 },
672
+ { name: "agentbox-dockerd-start", remoteBasename: "agentbox-dockerd-start", remoteMode: 493 },
673
+ { name: "agentbox-portless-trust", remoteBasename: "agentbox-portless-trust", remoteMode: 493 },
674
+ { name: "agentbox-checkpoint-cleanup", remoteBasename: "agentbox-checkpoint-cleanup", remoteMode: 493 },
675
+ { name: "agentbox-open", remoteBasename: "agentbox-open", remoteMode: 493 },
676
+ { name: "gh-shim", remoteBasename: "agentbox-gh-shim", remoteMode: 493 },
677
+ { name: "git-shim", remoteBasename: "agentbox-git-shim", remoteMode: 493 },
678
+ { name: "ntn-shim", remoteBasename: "agentbox-ntn-shim", remoteMode: 493 },
679
+ { name: "linear-shim", remoteBasename: "agentbox-linear-shim", remoteMode: 493 },
680
+ { name: "custom-system-CLAUDE.md", remoteBasename: "agentbox-custom-CLAUDE.md", remoteMode: 420 },
681
+ { name: "claude-managed-settings.json", remoteBasename: "agentbox-managed-settings.json", remoteMode: 420 },
682
+ { name: "agentbox-codex-hooks.json", remoteBasename: "agentbox-codex-hooks.json", remoteMode: 420 },
683
+ { name: "agentbox-setup-skill.md", remoteBasename: "agentbox-setup-skill.md", remoteMode: 420 }
684
+ ];
685
+ function candidatesFor(name, opts = {}) {
686
+ const cliRoot = opts.cliRuntimeRoot;
687
+ const monorepo = opts.repoRoot ?? guessRepoRoot();
688
+ const monorepoRelative = {
689
+ "install-box.sh": ["packages/sandbox-digitalocean/scripts/install-box.sh"],
690
+ "agentbox-ctl": ["packages/ctl/dist/bin.cjs"],
691
+ "agentbox-vnc-start": ["packages/sandbox-docker/scripts/agentbox-vnc-start"],
692
+ "agentbox-dockerd-start": ["packages/sandbox-docker/scripts/agentbox-dockerd-start"],
693
+ "agentbox-portless-trust": ["packages/sandbox-docker/scripts/agentbox-portless-trust"],
694
+ "agentbox-checkpoint-cleanup": ["packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup"],
695
+ "agentbox-open": ["packages/sandbox-docker/scripts/agentbox-open"],
696
+ "gh-shim": ["packages/sandbox-docker/scripts/gh-shim"],
697
+ "git-shim": ["packages/sandbox-docker/scripts/git-shim"],
698
+ "ntn-shim": ["packages/sandbox-docker/scripts/ntn-shim"],
699
+ "linear-shim": ["packages/sandbox-docker/scripts/linear-shim"],
700
+ "custom-system-CLAUDE.md": ["packages/sandbox-digitalocean/scripts/custom-system-CLAUDE.md"],
701
+ "claude-managed-settings.json": ["packages/sandbox-docker/scripts/claude-managed-settings.json"],
702
+ "agentbox-codex-hooks.json": ["packages/sandbox-docker/scripts/agentbox-codex-hooks.json"],
703
+ "agentbox-setup-skill.md": ["apps/cli/share/agentbox-setup/SKILL.md"]
704
+ };
705
+ const cliRelative = {
706
+ "install-box.sh": ["digitalocean/scripts/install-box.sh"],
707
+ "agentbox-ctl": ["digitalocean/ctl.cjs"],
708
+ "agentbox-vnc-start": ["digitalocean/agentbox-vnc-start", "docker/packages/sandbox-docker/scripts/agentbox-vnc-start"],
709
+ "agentbox-dockerd-start": ["digitalocean/agentbox-dockerd-start", "docker/packages/sandbox-docker/scripts/agentbox-dockerd-start"],
710
+ "agentbox-portless-trust": ["digitalocean/agentbox-portless-trust", "docker/packages/sandbox-docker/scripts/agentbox-portless-trust"],
711
+ "agentbox-checkpoint-cleanup": ["digitalocean/agentbox-checkpoint-cleanup", "docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup"],
712
+ "agentbox-open": ["digitalocean/agentbox-open", "docker/packages/sandbox-docker/scripts/agentbox-open"],
713
+ "gh-shim": ["digitalocean/gh-shim", "docker/packages/sandbox-docker/scripts/gh-shim"],
714
+ "git-shim": ["digitalocean/git-shim", "docker/packages/sandbox-docker/scripts/git-shim"],
715
+ "ntn-shim": ["digitalocean/ntn-shim", "docker/packages/sandbox-docker/scripts/ntn-shim"],
716
+ "linear-shim": ["digitalocean/linear-shim", "docker/packages/sandbox-docker/scripts/linear-shim"],
717
+ "custom-system-CLAUDE.md": ["digitalocean/custom-system-CLAUDE.md"],
718
+ "claude-managed-settings.json": ["digitalocean/claude-managed-settings.json", "docker/packages/sandbox-docker/scripts/claude-managed-settings.json"],
719
+ "agentbox-codex-hooks.json": ["digitalocean/agentbox-codex-hooks.json", "docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json"],
720
+ "agentbox-setup-skill.md": ["digitalocean/agentbox-setup-skill.md", "docker/apps/cli/share/agentbox-setup/SKILL.md"]
721
+ };
722
+ const out = [];
723
+ if (cliRoot) {
724
+ for (const rel of cliRelative[name] ?? []) out.push(resolve3(cliRoot, rel));
725
+ }
726
+ for (const rel of monorepoRelative[name] ?? []) out.push(resolve3(monorepo, rel));
727
+ return out;
728
+ }
729
+ function resolveRuntimeAssets(opts = {}) {
730
+ const out = [];
731
+ const missing = [];
732
+ for (const asset of RUNTIME_ASSETS) {
733
+ const cands = candidatesFor(asset.name, opts);
734
+ const hit = cands.find((p) => existsSync3(p));
735
+ if (!hit) {
736
+ missing.push({ name: asset.name, tried: cands });
737
+ continue;
738
+ }
739
+ out.push({ ...asset, localPath: hit });
740
+ }
741
+ if (missing.length > 0) {
742
+ const lines = missing.flatMap((m) => [` - ${m.name}: tried`, ...m.tried.map((p) => ` ${p}`)]);
743
+ throw new Error(
744
+ `digitalocean: could not resolve runtime assets \u2014 these files are needed to install on the prepare VPS:
745
+ ` + lines.join("\n") + `
746
+
747
+ If you are running from the monorepo, ensure \`pnpm -w build\` has run so packages/ctl/dist/bin.cjs exists. If you are running from a published CLI bundle, the runtime/digitalocean tree should be staged automatically.`
748
+ );
749
+ }
750
+ return out;
751
+ }
752
+ function guessRepoRoot() {
753
+ let cur = SELF;
754
+ for (let i = 0; i < 8; i++) {
755
+ if (existsSync3(resolve3(cur, "pnpm-workspace.yaml"))) return cur;
756
+ const parent = dirname2(cur);
757
+ if (parent === cur) break;
758
+ cur = parent;
759
+ }
760
+ return SELF;
761
+ }
762
+ var SCHEMA = 2;
763
+ function preparedStatePath() {
764
+ return preparedStatePathFor("digitalocean");
765
+ }
766
+ function readPreparedState() {
767
+ const raw = readPreparedStateRaw("digitalocean");
768
+ if (raw === null || typeof raw !== "object") return { schema: SCHEMA };
769
+ const parsed = raw;
770
+ if (parsed.schema === 1) {
771
+ const v1 = parsed;
772
+ return migrateFromV1(v1);
773
+ }
774
+ if (parsed.schema !== SCHEMA) {
775
+ return { schema: SCHEMA };
776
+ }
777
+ return {
778
+ schema: SCHEMA,
779
+ base: parsed.base
780
+ };
781
+ }
782
+ function migrateFromV1(v1) {
783
+ const base = v1.base ? {
784
+ imageId: v1.base.imageId,
785
+ description: v1.base.description,
786
+ createdAt: v1.base.createdAt,
787
+ contextSha256: v1.base.installScriptSha256
788
+ } : void 0;
789
+ return {
790
+ schema: SCHEMA,
791
+ base
792
+ };
793
+ }
794
+ function writePreparedState(state) {
795
+ writePreparedStateRaw("digitalocean", state);
796
+ }
797
+ function updatePreparedState(mutate) {
798
+ const s = readPreparedState();
799
+ mutate(s);
800
+ writePreparedState(s);
801
+ }
802
+ async function currentDigitalOceanBaseFingerprintLive(claudeInstall = "native") {
803
+ try {
804
+ const assets = resolveRuntimeAssets({ cliRuntimeRoot: findStagedCliRuntimeRoot() });
805
+ return claudeInstallFingerprint(
806
+ await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),
807
+ claudeInstall
808
+ );
809
+ } catch {
810
+ return void 0;
811
+ }
812
+ }
813
+
814
+ export {
815
+ ensureDigitalOceanEnvLoaded,
816
+ DEFAULT_DO_ENDPOINT,
817
+ DigitalOceanApiError,
818
+ makeDigitalOceanClient,
819
+ ensureDigitalOceanCredentials,
820
+ setDigitalOceanCredentials,
821
+ secretsPath,
822
+ readDigitalOceanCredStatus,
823
+ maskKey,
824
+ detectEgressIp,
825
+ isAttemptTimeout,
826
+ isRetriable,
827
+ withDigitalOceanRetry,
828
+ sshInboundRules,
829
+ allowAllOutboundRules,
830
+ createPerBoxFirewall,
831
+ syncFirewallSource,
832
+ findFirewallForDroplet,
833
+ deletePerBoxFirewall,
834
+ normalizeSourceCidr,
835
+ findStagedCliRuntimeRoot,
836
+ RUNTIME_ASSETS,
837
+ candidatesFor,
838
+ resolveRuntimeAssets,
839
+ preparedStatePath,
840
+ readPreparedState,
841
+ writePreparedState,
842
+ updatePreparedState,
843
+ currentDigitalOceanBaseFingerprintLive
844
+ };
845
+ //# sourceMappingURL=chunk-WLHJZPFJ.js.map