@madarco/agentbox 0.18.0 → 0.20.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 (71) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/README.md +4 -3
  3. package/dist/_cloud-attach-THTN4CFZ.js +18 -0
  4. package/dist/{chunk-U7IZS2ZP.js → chunk-3VFY3N4A.js} +1388 -234
  5. package/dist/chunk-3VFY3N4A.js.map +1 -0
  6. package/dist/{chunk-XWBFWUY2.js → chunk-52LKNUY7.js} +6 -3
  7. package/dist/chunk-52LKNUY7.js.map +1 -0
  8. package/dist/{chunk-6QFPYU4Z.js → chunk-7K2A3NLE.js} +8 -5
  9. package/dist/chunk-7K2A3NLE.js.map +1 -0
  10. package/dist/{chunk-5BO6SGMI.js → chunk-7RWFYLF3.js} +194 -34
  11. package/dist/chunk-7RWFYLF3.js.map +1 -0
  12. package/dist/{chunk-IA6YHH52.js → chunk-MODNW54N.js} +6 -3
  13. package/dist/{chunk-IA6YHH52.js.map → chunk-MODNW54N.js.map} +1 -1
  14. package/dist/{chunk-46NXCJ6Z.js → chunk-NXX3KQZ6.js} +2 -2
  15. package/dist/{chunk-3JXSW6PN.js → chunk-P6UT5XGE.js} +2 -2
  16. package/dist/{chunk-OG4KMYOJ.js → chunk-ZX6DTA4X.js} +276 -56
  17. package/dist/chunk-ZX6DTA4X.js.map +1 -0
  18. package/dist/{dist-CFSKUAS5.js → dist-3PLT2EK2.js} +17 -3
  19. package/dist/{dist-T7ESSBCZ.js → dist-3WFNXXPE.js} +20 -6
  20. package/dist/dist-3WFNXXPE.js.map +1 -0
  21. package/dist/{dist-3UYQZOAO.js → dist-7ELDXBAG.js} +19 -6
  22. package/dist/dist-7ELDXBAG.js.map +1 -0
  23. package/dist/{dist-4BHW7DCO.js → dist-C3YRC3PP.js} +10 -5
  24. package/dist/dist-C3YRC3PP.js.map +1 -0
  25. package/dist/{dist-7BS2JS27.js → dist-CZ6CRADC.js} +18 -7
  26. package/dist/dist-CZ6CRADC.js.map +1 -0
  27. package/dist/index.js +1218 -560
  28. package/dist/index.js.map +1 -1
  29. package/dist/{prepared-state-MQHD3M5F-OVABNV66.js → prepared-state-MQHD3M5F-5ZMCNY43.js} +2 -2
  30. package/package.json +4 -4
  31. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
  32. package/runtime/docker/packages/ctl/dist/bin.cjs +255 -169
  33. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +13 -0
  34. package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +4 -4
  35. package/runtime/e2b/agentbox-dockerd-start +145 -0
  36. package/runtime/e2b/agentbox-setup-skill.md +1 -1
  37. package/runtime/e2b/attach-helper.cjs +23 -2
  38. package/runtime/e2b/claude-managed-settings.json +4 -4
  39. package/runtime/e2b/ctl.cjs +255 -169
  40. package/runtime/e2b/scripts/build-template.sh +22 -5
  41. package/runtime/hetzner/agentbox-dockerd-start +13 -0
  42. package/runtime/hetzner/agentbox-setup-skill.md +1 -1
  43. package/runtime/hetzner/claude-managed-settings.json +4 -4
  44. package/runtime/hetzner/ctl.cjs +255 -169
  45. package/runtime/relay/bin.cjs +267 -63
  46. package/runtime/vercel/agentbox-dockerd-start +145 -0
  47. package/runtime/vercel/agentbox-setup-skill.md +1 -1
  48. package/runtime/vercel/claude-managed-settings.json +4 -4
  49. package/runtime/vercel/ctl.cjs +255 -169
  50. package/runtime/vercel/custom-system-CLAUDE.md +5 -4
  51. package/runtime/vercel/scripts/provision.sh +20 -5
  52. package/share/agentbox-setup/SKILL.md +1 -1
  53. package/share/host-skills/agentbox/SKILL.md +4 -4
  54. package/share/host-skills/agentbox-info/SKILL.md +6 -6
  55. package/share/host-skills/codex/agentbox.md +12 -4
  56. package/share/host-skills/opencode/agentbox.md +2 -2
  57. package/dist/_cloud-attach-3UC3IL62.js +0 -16
  58. package/dist/chunk-5BO6SGMI.js.map +0 -1
  59. package/dist/chunk-6QFPYU4Z.js.map +0 -1
  60. package/dist/chunk-OG4KMYOJ.js.map +0 -1
  61. package/dist/chunk-U7IZS2ZP.js.map +0 -1
  62. package/dist/chunk-XWBFWUY2.js.map +0 -1
  63. package/dist/dist-3UYQZOAO.js.map +0 -1
  64. package/dist/dist-4BHW7DCO.js.map +0 -1
  65. package/dist/dist-7BS2JS27.js.map +0 -1
  66. package/dist/dist-T7ESSBCZ.js.map +0 -1
  67. /package/dist/{_cloud-attach-3UC3IL62.js.map → _cloud-attach-THTN4CFZ.js.map} +0 -0
  68. /package/dist/{chunk-46NXCJ6Z.js.map → chunk-NXX3KQZ6.js.map} +0 -0
  69. /package/dist/{chunk-3JXSW6PN.js.map → chunk-P6UT5XGE.js.map} +0 -0
  70. /package/dist/{dist-CFSKUAS5.js.map → dist-3PLT2EK2.js.map} +0 -0
  71. /package/dist/{prepared-state-MQHD3M5F-OVABNV66.js.map → prepared-state-MQHD3M5F-5ZMCNY43.js.map} +0 -0
@@ -26,13 +26,13 @@ import {
26
26
  removeBoxRecord,
27
27
  renderCarryEntries,
28
28
  reserveProjectIndex
29
- } from "./chunk-6QFPYU4Z.js";
29
+ } from "./chunk-7K2A3NLE.js";
30
30
 
31
31
  // ../../packages/sandbox-docker/dist/index.js
32
- import { mkdir as mkdir7, stat as stat8 } from "fs/promises";
33
- import { homedir as homedir10 } from "os";
34
- import { basename as basename6, join as join12, resolve as resolve4 } from "path";
35
- import { execa as execa15 } from "execa";
32
+ import { mkdir as mkdir7, stat as stat9 } from "fs/promises";
33
+ import { homedir as homedir12 } from "os";
34
+ import { basename as basename6, join as join13, resolve as resolve4 } from "path";
35
+ import { execa as execa16 } from "execa";
36
36
 
37
37
  // ../../packages/ctl/dist/index.js
38
38
  import { readFile as readFile2 } from "fs/promises";
@@ -968,6 +968,7 @@ var BUILT_IN_DEFAULTS = {
968
968
  vercelVcpus: 2,
969
969
  vercelTimeoutMs: 27e5,
970
970
  vercelNetworkPolicy: "",
971
+ e2bTimeoutMs: 27e5,
971
972
  cpMaxBytes: 100 * 1024 * 1024
972
973
  },
973
974
  checkpoint: {
@@ -1251,6 +1252,11 @@ var KEY_REGISTRY = [
1251
1252
  type: "int",
1252
1253
  description: "Max session length (ms) for new --provider vercel boxes before the VM auto-snapshots; persistent mode auto-resumes on the next call. Default 2700000 (45 min, the Hobby ceiling). Vercel-only."
1253
1254
  },
1255
+ {
1256
+ key: "box.e2bTimeoutMs",
1257
+ type: "int",
1258
+ description: "Session timeout (ms) a new --provider e2b box is created with, before E2B auto-pauses it on inactivity. The host keepalive loop pushes this forward while the agent is working. Default 2700000 (45 min); the Hobby tier caps total session at ~1 h regardless. E2B-only."
1259
+ },
1254
1260
  {
1255
1261
  key: "box.cpMaxBytes",
1256
1262
  type: "int",
@@ -2050,7 +2056,7 @@ async function touchProjectMeta(absPath) {
2050
2056
  // ../../packages/sandbox-docker/dist/index.js
2051
2057
  import { spawnSync } from "child_process";
2052
2058
  import { mkdir as mkdir3, mkdtemp as mkdtemp2, readdir as readdir3, readFile as readFile42, realpath as realpath2, rm as rm2, stat as stat3, writeFile as writeFile22 } from "fs/promises";
2053
- import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
2059
+ import { homedir as homedir4, tmpdir as tmpdir2 } from "os";
2054
2060
  import { isAbsolute as isAbsolute2, join as join4, relative as relative2 } from "path";
2055
2061
  import { setTimeout as delay } from "timers/promises";
2056
2062
  import { execa as execa6 } from "execa";
@@ -2064,51 +2070,879 @@ import { existsSync, mkdirSync, renameSync, statSync } from "fs";
2064
2070
  import { basename as basename3, dirname as dirname3, posix, resolve as resolve2 } from "path";
2065
2071
  import { execa as execa22 } from "execa";
2066
2072
  import { copyFile, mkdtemp, readdir as readdir22, readFile as readFile32, rm as rm3, stat as stat22, writeFile as writeFile3 } from "fs/promises";
2067
- import { homedir as homedir22, tmpdir } from "os";
2073
+ import { homedir as homedir3, tmpdir } from "os";
2068
2074
  import { basename as basename4, join as join32, relative } from "path";
2069
2075
  import { execa as execa5 } from "execa";
2070
2076
  import { chmod, mkdir as mkdir22, readFile as readFile23 } from "fs/promises";
2071
2077
  import { basename as basename32, join as join22 } from "path";
2072
2078
  import { execa as execa4 } from "execa";
2079
+ import { homedir as homedir22 } from "os";
2080
+
2081
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
2082
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
2083
+ var TomlDate = class _TomlDate extends Date {
2084
+ #hasDate = false;
2085
+ #hasTime = false;
2086
+ #offset = null;
2087
+ constructor(date) {
2088
+ let hasDate = true;
2089
+ let hasTime = true;
2090
+ let offset = "Z";
2091
+ if (typeof date === "string") {
2092
+ let match = date.match(DATE_TIME_RE);
2093
+ if (match) {
2094
+ if (!match[1]) {
2095
+ hasDate = false;
2096
+ date = `0000-01-01T${date}`;
2097
+ }
2098
+ hasTime = !!match[2];
2099
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
2100
+ if (match[2] && +match[2] > 23) {
2101
+ date = "";
2102
+ } else {
2103
+ offset = match[3] || null;
2104
+ date = date.toUpperCase();
2105
+ if (!offset && hasTime)
2106
+ date += "Z";
2107
+ }
2108
+ } else {
2109
+ date = "";
2110
+ }
2111
+ }
2112
+ super(date);
2113
+ if (!isNaN(this.getTime())) {
2114
+ this.#hasDate = hasDate;
2115
+ this.#hasTime = hasTime;
2116
+ this.#offset = offset;
2117
+ }
2118
+ }
2119
+ isDateTime() {
2120
+ return this.#hasDate && this.#hasTime;
2121
+ }
2122
+ isLocal() {
2123
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
2124
+ }
2125
+ isDate() {
2126
+ return this.#hasDate && !this.#hasTime;
2127
+ }
2128
+ isTime() {
2129
+ return this.#hasTime && !this.#hasDate;
2130
+ }
2131
+ isValid() {
2132
+ return this.#hasDate || this.#hasTime;
2133
+ }
2134
+ toISOString() {
2135
+ let iso = super.toISOString();
2136
+ if (this.isDate())
2137
+ return iso.slice(0, 10);
2138
+ if (this.isTime())
2139
+ return iso.slice(11, 23);
2140
+ if (this.#offset === null)
2141
+ return iso.slice(0, -1);
2142
+ if (this.#offset === "Z")
2143
+ return iso;
2144
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
2145
+ offset = this.#offset[0] === "-" ? offset : -offset;
2146
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
2147
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
2148
+ }
2149
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
2150
+ let date = new _TomlDate(jsDate);
2151
+ date.#offset = offset;
2152
+ return date;
2153
+ }
2154
+ static wrapAsLocalDateTime(jsDate) {
2155
+ let date = new _TomlDate(jsDate);
2156
+ date.#offset = null;
2157
+ return date;
2158
+ }
2159
+ static wrapAsLocalDate(jsDate) {
2160
+ let date = new _TomlDate(jsDate);
2161
+ date.#hasTime = false;
2162
+ date.#offset = null;
2163
+ return date;
2164
+ }
2165
+ static wrapAsLocalTime(jsDate) {
2166
+ let date = new _TomlDate(jsDate);
2167
+ date.#hasDate = false;
2168
+ date.#offset = null;
2169
+ return date;
2170
+ }
2171
+ };
2172
+
2173
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/error.js
2174
+ function getLineColFromPtr(string, ptr) {
2175
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
2176
+ return [lines.length, lines.pop().length + 1];
2177
+ }
2178
+ function makeCodeBlock(string, line, column) {
2179
+ let lines = string.split(/\r\n|\n|\r/g);
2180
+ let codeblock = "";
2181
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
2182
+ for (let i = line - 1; i <= line + 1; i++) {
2183
+ let l = lines[i - 1];
2184
+ if (!l)
2185
+ continue;
2186
+ codeblock += i.toString().padEnd(numberLen, " ");
2187
+ codeblock += ": ";
2188
+ codeblock += l;
2189
+ codeblock += "\n";
2190
+ if (i === line) {
2191
+ codeblock += " ".repeat(numberLen + column + 2);
2192
+ codeblock += "^\n";
2193
+ }
2194
+ }
2195
+ return codeblock;
2196
+ }
2197
+ var TomlError = class extends Error {
2198
+ line;
2199
+ column;
2200
+ codeblock;
2201
+ constructor(message, options) {
2202
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
2203
+ const codeblock = makeCodeBlock(options.toml, line, column);
2204
+ super(`Invalid TOML document: ${message}
2205
+
2206
+ ${codeblock}`, options);
2207
+ this.line = line;
2208
+ this.column = column;
2209
+ this.codeblock = codeblock;
2210
+ }
2211
+ };
2212
+
2213
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/primitive.js
2214
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
2215
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
2216
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
2217
+ function parseString(str, ptr) {
2218
+ let c = str[ptr++];
2219
+ let first = c;
2220
+ let isLiteral = c === "'";
2221
+ let isMultiline = c === str[ptr] && c === str[ptr + 1];
2222
+ if (isMultiline) {
2223
+ if (str[ptr += 2] === "\n")
2224
+ ptr++;
2225
+ else if (str[ptr] === "\r" && str[ptr + 1] === "\n")
2226
+ ptr += 2;
2227
+ }
2228
+ let parsed = "";
2229
+ let sliceStart = ptr;
2230
+ let state = 0;
2231
+ for (let i = ptr; i < str.length; i++) {
2232
+ c = str[i];
2233
+ if (isMultiline && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
2234
+ state = state && 3;
2235
+ } else if (c < " " && c !== " " || c === "\x7F") {
2236
+ throw new TomlError("control characters are not allowed in strings", {
2237
+ toml: str,
2238
+ ptr: i
2239
+ });
2240
+ } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
2241
+ if (isMultiline) {
2242
+ if (str[i + 3] === first)
2243
+ i++;
2244
+ if (str[i + 3] === first)
2245
+ i++;
2246
+ }
2247
+ return [
2248
+ // If we're in a newline escape still, then there's nothing to add.
2249
+ // Also try to avoid concat if there's nothing to add to parsed, or nothing has been added to parsed.
2250
+ state ? parsed : parsed + str.slice(sliceStart, i),
2251
+ i + (isMultiline ? 3 : 1)
2252
+ ];
2253
+ } else if (!state) {
2254
+ if (!isLiteral && c === "\\") {
2255
+ parsed += str.slice(sliceStart, sliceStart = i);
2256
+ state = 1;
2257
+ }
2258
+ } else if (state === 1) {
2259
+ if (c === "x" || c === "u" || c === "U") {
2260
+ let value = 0;
2261
+ let len = c === "x" ? 2 : c === "u" ? 4 : 8;
2262
+ for (let j = 0; j < len; j++, i++) {
2263
+ let hex = str.charCodeAt(i + 1);
2264
+ let digit = (
2265
+ /* 0-9 */
2266
+ hex >= 48 && hex <= 57 ? hex - 48 : (
2267
+ /* A-F */
2268
+ hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
2269
+ /* a-f */
2270
+ hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
2271
+ )
2272
+ )
2273
+ );
2274
+ if (digit < 0)
2275
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
2276
+ value = value << 4 | digit;
2277
+ }
2278
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
2279
+ throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
2280
+ }
2281
+ parsed += String.fromCodePoint(value);
2282
+ sliceStart = i + 1;
2283
+ state = 0;
2284
+ } else if (c === " " || c === " ") {
2285
+ state = 2;
2286
+ } else {
2287
+ if (c === "b")
2288
+ parsed += "\b";
2289
+ else if (c === "t")
2290
+ parsed += " ";
2291
+ else if (c === "n")
2292
+ parsed += "\n";
2293
+ else if (c === "f")
2294
+ parsed += "\f";
2295
+ else if (c === "r")
2296
+ parsed += "\r";
2297
+ else if (c === "e")
2298
+ parsed += "\x1B";
2299
+ else if (c === '"')
2300
+ parsed += '"';
2301
+ else if (c === "\\")
2302
+ parsed += "\\";
2303
+ else
2304
+ throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
2305
+ sliceStart = i + 1;
2306
+ state = 0;
2307
+ }
2308
+ } else if (c !== " " && c !== " ") {
2309
+ if (state === 2) {
2310
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
2311
+ toml: str,
2312
+ ptr: sliceStart
2313
+ });
2314
+ }
2315
+ state = !isLiteral && c === "\\" ? 1 : 0;
2316
+ sliceStart = i;
2317
+ }
2318
+ }
2319
+ throw new TomlError("unfinished string", { toml: str, ptr });
2320
+ }
2321
+ function parseValue(value, toml, ptr, integersAsBigInt) {
2322
+ if (value === "true")
2323
+ return true;
2324
+ if (value === "false")
2325
+ return false;
2326
+ if (value === "-inf")
2327
+ return -Infinity;
2328
+ if (value === "inf" || value === "+inf")
2329
+ return Infinity;
2330
+ if (value === "nan" || value === "+nan" || value === "-nan")
2331
+ return NaN;
2332
+ if (value === "-0")
2333
+ return integersAsBigInt ? 0n : 0;
2334
+ let isInt = INT_REGEX.test(value);
2335
+ if (isInt || FLOAT_REGEX.test(value)) {
2336
+ if (LEADING_ZERO.test(value)) {
2337
+ throw new TomlError("leading zeroes are not allowed", {
2338
+ toml,
2339
+ ptr
2340
+ });
2341
+ }
2342
+ value = value.replace(/_/g, "");
2343
+ let numeric = +value;
2344
+ if (isNaN(numeric)) {
2345
+ throw new TomlError("invalid number", {
2346
+ toml,
2347
+ ptr
2348
+ });
2349
+ }
2350
+ if (isInt) {
2351
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
2352
+ throw new TomlError("integer value cannot be represented losslessly", {
2353
+ toml,
2354
+ ptr
2355
+ });
2356
+ }
2357
+ if (isInt || integersAsBigInt === true)
2358
+ numeric = BigInt(value);
2359
+ }
2360
+ return numeric;
2361
+ }
2362
+ const date = new TomlDate(value);
2363
+ if (!date.isValid()) {
2364
+ throw new TomlError("invalid value", {
2365
+ toml,
2366
+ ptr
2367
+ });
2368
+ }
2369
+ return date;
2370
+ }
2371
+
2372
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/util.js
2373
+ function indexOfNewline(str, start = 0, end = str.length) {
2374
+ let idx = str.indexOf("\n", start);
2375
+ if (str[idx - 1] === "\r")
2376
+ idx--;
2377
+ return idx <= end ? idx : -1;
2378
+ }
2379
+ function skipComment(str, ptr) {
2380
+ for (let i = ptr; i < str.length; i++) {
2381
+ let c = str[i];
2382
+ if (c === "\n")
2383
+ return i;
2384
+ if (c === "\r" && str[i + 1] === "\n")
2385
+ return i + 1;
2386
+ if (c < " " && c !== " " || c === "\x7F") {
2387
+ throw new TomlError("control characters are not allowed in comments", {
2388
+ toml: str,
2389
+ ptr
2390
+ });
2391
+ }
2392
+ }
2393
+ return str.length;
2394
+ }
2395
+ function skipVoid(str, ptr, banNewLines, banComments) {
2396
+ let c;
2397
+ while (1) {
2398
+ while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
2399
+ ptr++;
2400
+ if (banComments || c !== "#")
2401
+ break;
2402
+ ptr = skipComment(str, ptr);
2403
+ }
2404
+ return ptr;
2405
+ }
2406
+ function skipUntil(str, ptr, sep2, end, banNewLines = false) {
2407
+ if (!end) {
2408
+ ptr = indexOfNewline(str, ptr);
2409
+ return ptr < 0 ? str.length : ptr;
2410
+ }
2411
+ for (let i = ptr; i < str.length; i++) {
2412
+ let c = str[i];
2413
+ if (c === "#") {
2414
+ i = indexOfNewline(str, i);
2415
+ } else if (c === sep2) {
2416
+ return i + 1;
2417
+ } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
2418
+ return i;
2419
+ }
2420
+ }
2421
+ throw new TomlError("cannot find end of structure", {
2422
+ toml: str,
2423
+ ptr
2424
+ });
2425
+ }
2426
+
2427
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/extract.js
2428
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
2429
+ let value = str.slice(startPtr, endPtr);
2430
+ let commentIdx = value.indexOf("#");
2431
+ if (commentIdx > -1) {
2432
+ skipComment(str, commentIdx);
2433
+ value = value.slice(0, commentIdx);
2434
+ }
2435
+ return [value.trimEnd(), commentIdx];
2436
+ }
2437
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
2438
+ if (depth === 0) {
2439
+ throw new TomlError("document contains excessively nested structures. aborting.", {
2440
+ toml: str,
2441
+ ptr
2442
+ });
2443
+ }
2444
+ let c = str[ptr];
2445
+ if (c === "[" || c === "{") {
2446
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
2447
+ if (end) {
2448
+ endPtr2 = skipVoid(str, endPtr2);
2449
+ if (str[endPtr2] === ",")
2450
+ endPtr2++;
2451
+ else if (str[endPtr2] !== end) {
2452
+ throw new TomlError("expected comma or end of structure", {
2453
+ toml: str,
2454
+ ptr: endPtr2
2455
+ });
2456
+ }
2457
+ }
2458
+ return [value, endPtr2];
2459
+ }
2460
+ if (c === '"' || c === "'") {
2461
+ let [parsed, endPtr2] = parseString(str, ptr);
2462
+ if (end) {
2463
+ endPtr2 = skipVoid(str, endPtr2);
2464
+ if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
2465
+ throw new TomlError("unexpected character encountered", {
2466
+ toml: str,
2467
+ ptr: endPtr2
2468
+ });
2469
+ }
2470
+ if (str[endPtr2] === ",")
2471
+ endPtr2++;
2472
+ }
2473
+ return [parsed, endPtr2];
2474
+ }
2475
+ let endPtr = skipUntil(str, ptr, ",", end);
2476
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
2477
+ if (!slice[0]) {
2478
+ throw new TomlError("incomplete key-value declaration: no value specified", {
2479
+ toml: str,
2480
+ ptr
2481
+ });
2482
+ }
2483
+ if (end && slice[1] > -1) {
2484
+ endPtr = skipVoid(str, ptr + slice[1]);
2485
+ if (str[endPtr] === ",")
2486
+ endPtr++;
2487
+ }
2488
+ return [
2489
+ parseValue(slice[0], str, ptr, integersAsBigInt),
2490
+ endPtr
2491
+ ];
2492
+ }
2493
+
2494
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/struct.js
2495
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
2496
+ function parseKey(str, ptr, end = "=") {
2497
+ let dot = ptr - 1;
2498
+ let parsed = [];
2499
+ let endPtr = str.indexOf(end, ptr);
2500
+ if (endPtr < 0) {
2501
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2502
+ toml: str,
2503
+ ptr
2504
+ });
2505
+ }
2506
+ do {
2507
+ let c = str[ptr = ++dot];
2508
+ if (c !== " " && c !== " ") {
2509
+ if (c === '"' || c === "'") {
2510
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
2511
+ throw new TomlError("multiline strings are not allowed in keys", {
2512
+ toml: str,
2513
+ ptr
2514
+ });
2515
+ }
2516
+ let [part, eos] = parseString(str, ptr);
2517
+ dot = str.indexOf(".", eos);
2518
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
2519
+ let newLine = indexOfNewline(strEnd);
2520
+ if (newLine > -1) {
2521
+ throw new TomlError("newlines are not allowed in keys", {
2522
+ toml: str,
2523
+ ptr: ptr + dot + newLine
2524
+ });
2525
+ }
2526
+ if (strEnd.trimStart()) {
2527
+ throw new TomlError("found extra tokens after the string part", {
2528
+ toml: str,
2529
+ ptr: eos
2530
+ });
2531
+ }
2532
+ if (endPtr < eos) {
2533
+ endPtr = str.indexOf(end, eos);
2534
+ if (endPtr < 0) {
2535
+ throw new TomlError("incomplete key-value: cannot find end of key", {
2536
+ toml: str,
2537
+ ptr
2538
+ });
2539
+ }
2540
+ }
2541
+ parsed.push(part);
2542
+ } else {
2543
+ dot = str.indexOf(".", ptr);
2544
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
2545
+ if (!KEY_PART_RE.test(part)) {
2546
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
2547
+ toml: str,
2548
+ ptr
2549
+ });
2550
+ }
2551
+ parsed.push(part.trimEnd());
2552
+ }
2553
+ }
2554
+ } while (dot + 1 && dot < endPtr);
2555
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
2556
+ }
2557
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
2558
+ let res = {};
2559
+ let seen = /* @__PURE__ */ new Set();
2560
+ let c;
2561
+ ptr++;
2562
+ while ((c = str[ptr++]) !== "}" && c) {
2563
+ if (c === ",") {
2564
+ throw new TomlError("expected value, found comma", {
2565
+ toml: str,
2566
+ ptr: ptr - 1
2567
+ });
2568
+ } else if (c === "#")
2569
+ ptr = skipComment(str, ptr);
2570
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2571
+ let k;
2572
+ let t = res;
2573
+ let hasOwn = false;
2574
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
2575
+ for (let i = 0; i < key.length; i++) {
2576
+ if (i)
2577
+ t = hasOwn ? t[k] : t[k] = {};
2578
+ k = key[i];
2579
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
2580
+ throw new TomlError("trying to redefine an already defined value", {
2581
+ toml: str,
2582
+ ptr
2583
+ });
2584
+ }
2585
+ if (!hasOwn && k === "__proto__") {
2586
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2587
+ }
2588
+ }
2589
+ if (hasOwn) {
2590
+ throw new TomlError("trying to redefine an already defined value", {
2591
+ toml: str,
2592
+ ptr
2593
+ });
2594
+ }
2595
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
2596
+ seen.add(value);
2597
+ t[k] = value;
2598
+ ptr = valueEndPtr;
2599
+ }
2600
+ }
2601
+ if (!c) {
2602
+ throw new TomlError("unfinished table encountered", {
2603
+ toml: str,
2604
+ ptr
2605
+ });
2606
+ }
2607
+ return [res, ptr];
2608
+ }
2609
+ function parseArray(str, ptr, depth, integersAsBigInt) {
2610
+ let res = [];
2611
+ let c;
2612
+ ptr++;
2613
+ while ((c = str[ptr++]) !== "]" && c) {
2614
+ if (c === ",") {
2615
+ throw new TomlError("expected value, found comma", {
2616
+ toml: str,
2617
+ ptr: ptr - 1
2618
+ });
2619
+ } else if (c === "#")
2620
+ ptr = skipComment(str, ptr);
2621
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
2622
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
2623
+ res.push(e[0]);
2624
+ ptr = e[1];
2625
+ }
2626
+ }
2627
+ if (!c) {
2628
+ throw new TomlError("unfinished array encountered", {
2629
+ toml: str,
2630
+ ptr
2631
+ });
2632
+ }
2633
+ return [res, ptr];
2634
+ }
2635
+
2636
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/parse.js
2637
+ function peekTable(key, table, meta, type) {
2638
+ let t = table;
2639
+ let m = meta;
2640
+ let k;
2641
+ let hasOwn = false;
2642
+ let state;
2643
+ for (let i = 0; i < key.length; i++) {
2644
+ if (i) {
2645
+ t = hasOwn ? t[k] : t[k] = {};
2646
+ m = (state = m[k]).c;
2647
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
2648
+ return null;
2649
+ }
2650
+ if (state.t === 2) {
2651
+ let l = t.length - 1;
2652
+ t = t[l];
2653
+ m = m[l].c;
2654
+ }
2655
+ }
2656
+ k = key[i];
2657
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
2658
+ return null;
2659
+ }
2660
+ if (!hasOwn) {
2661
+ if (k === "__proto__") {
2662
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
2663
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
2664
+ }
2665
+ m[k] = {
2666
+ t: i < key.length - 1 && type === 2 ? 3 : type,
2667
+ d: false,
2668
+ i: 0,
2669
+ c: {}
2670
+ };
2671
+ }
2672
+ }
2673
+ state = m[k];
2674
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
2675
+ return null;
2676
+ }
2677
+ if (type === 2) {
2678
+ if (!state.d) {
2679
+ state.d = true;
2680
+ t[k] = [];
2681
+ }
2682
+ t[k].push(t = {});
2683
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
2684
+ }
2685
+ if (state.d) {
2686
+ return null;
2687
+ }
2688
+ state.d = true;
2689
+ if (type === 1) {
2690
+ t = hasOwn ? t[k] : t[k] = {};
2691
+ } else if (type === 0 && hasOwn) {
2692
+ return null;
2693
+ }
2694
+ return [k, t, state.c];
2695
+ }
2696
+ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
2697
+ let res = {};
2698
+ let meta = {};
2699
+ let tbl = res;
2700
+ let m = meta;
2701
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
2702
+ if (toml[ptr] === "[") {
2703
+ let isTableArray = toml[++ptr] === "[";
2704
+ let k = parseKey(toml, ptr += +isTableArray, "]");
2705
+ if (isTableArray) {
2706
+ if (toml[k[1] - 1] !== "]") {
2707
+ throw new TomlError("expected end of table declaration", {
2708
+ toml,
2709
+ ptr: k[1] - 1
2710
+ });
2711
+ }
2712
+ k[1]++;
2713
+ }
2714
+ let p = peekTable(
2715
+ k[0],
2716
+ res,
2717
+ meta,
2718
+ isTableArray ? 2 : 1
2719
+ /* Type.EXPLICIT */
2720
+ );
2721
+ if (!p) {
2722
+ throw new TomlError("trying to redefine an already defined table or value", {
2723
+ toml,
2724
+ ptr
2725
+ });
2726
+ }
2727
+ m = p[2];
2728
+ tbl = p[1];
2729
+ ptr = k[1];
2730
+ } else {
2731
+ let k = parseKey(toml, ptr);
2732
+ let p = peekTable(
2733
+ k[0],
2734
+ tbl,
2735
+ m,
2736
+ 0
2737
+ /* Type.DOTTED */
2738
+ );
2739
+ if (!p) {
2740
+ throw new TomlError("trying to redefine an already defined table or value", {
2741
+ toml,
2742
+ ptr
2743
+ });
2744
+ }
2745
+ let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
2746
+ p[1][p[0]] = v[0];
2747
+ ptr = v[1];
2748
+ }
2749
+ ptr = skipVoid(toml, ptr, true);
2750
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
2751
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
2752
+ toml,
2753
+ ptr
2754
+ });
2755
+ }
2756
+ ptr = skipVoid(toml, ptr);
2757
+ }
2758
+ return res;
2759
+ }
2760
+
2761
+ // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/stringify.js
2762
+ var BARE_KEY = /^[a-z0-9-_]+$/i;
2763
+ function extendedTypeOf(obj) {
2764
+ let type = typeof obj;
2765
+ if (type === "object") {
2766
+ if (Array.isArray(obj))
2767
+ return "array";
2768
+ if (obj instanceof Date)
2769
+ return "date";
2770
+ }
2771
+ return type;
2772
+ }
2773
+ function isArrayOfTables(obj) {
2774
+ for (let i = 0; i < obj.length; i++) {
2775
+ if (extendedTypeOf(obj[i]) !== "object")
2776
+ return false;
2777
+ }
2778
+ return obj.length != 0;
2779
+ }
2780
+ function formatString(s) {
2781
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
2782
+ }
2783
+ function stringifyValue(val, type, depth, numberAsFloat) {
2784
+ if (depth === 0) {
2785
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2786
+ }
2787
+ if (type === "number") {
2788
+ if (isNaN(val))
2789
+ return "nan";
2790
+ if (val === Infinity)
2791
+ return "inf";
2792
+ if (val === -Infinity)
2793
+ return "-inf";
2794
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
2795
+ return val.toFixed(1);
2796
+ return val.toString();
2797
+ }
2798
+ if (type === "bigint" || type === "boolean") {
2799
+ return val.toString();
2800
+ }
2801
+ if (type === "string") {
2802
+ return formatString(val);
2803
+ }
2804
+ if (type === "date") {
2805
+ if (isNaN(val.getTime())) {
2806
+ throw new TypeError("cannot serialize invalid date");
2807
+ }
2808
+ return val.toISOString();
2809
+ }
2810
+ if (type === "object") {
2811
+ return stringifyInlineTable(val, depth, numberAsFloat);
2812
+ }
2813
+ if (type === "array") {
2814
+ return stringifyArray(val, depth, numberAsFloat);
2815
+ }
2816
+ }
2817
+ function stringifyInlineTable(obj, depth, numberAsFloat) {
2818
+ let keys = Object.keys(obj);
2819
+ if (keys.length === 0)
2820
+ return "{}";
2821
+ let res = "{ ";
2822
+ for (let i = 0; i < keys.length; i++) {
2823
+ let k = keys[i];
2824
+ if (i)
2825
+ res += ", ";
2826
+ res += BARE_KEY.test(k) ? k : formatString(k);
2827
+ res += " = ";
2828
+ res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
2829
+ }
2830
+ return res + " }";
2831
+ }
2832
+ function stringifyArray(array, depth, numberAsFloat) {
2833
+ if (array.length === 0)
2834
+ return "[]";
2835
+ let res = "[ ";
2836
+ for (let i = 0; i < array.length; i++) {
2837
+ if (i)
2838
+ res += ", ";
2839
+ if (array[i] === null || array[i] === void 0) {
2840
+ throw new TypeError("arrays cannot contain null or undefined values");
2841
+ }
2842
+ res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
2843
+ }
2844
+ return res + " ]";
2845
+ }
2846
+ function stringifyArrayTable(array, key, depth, numberAsFloat) {
2847
+ if (depth === 0) {
2848
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2849
+ }
2850
+ let res = "";
2851
+ for (let i = 0; i < array.length; i++) {
2852
+ res += `${res && "\n"}[[${key}]]
2853
+ `;
2854
+ res += stringifyTable(0, array[i], key, depth, numberAsFloat);
2855
+ }
2856
+ return res;
2857
+ }
2858
+ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
2859
+ if (depth === 0) {
2860
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
2861
+ }
2862
+ let preamble = "";
2863
+ let tables = "";
2864
+ let keys = Object.keys(obj);
2865
+ for (let i = 0; i < keys.length; i++) {
2866
+ let k = keys[i];
2867
+ if (obj[k] !== null && obj[k] !== void 0) {
2868
+ let type = extendedTypeOf(obj[k]);
2869
+ if (type === "symbol" || type === "function") {
2870
+ throw new TypeError(`cannot serialize values of type '${type}'`);
2871
+ }
2872
+ let key = BARE_KEY.test(k) ? k : formatString(k);
2873
+ if (type === "array" && isArrayOfTables(obj[k])) {
2874
+ tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
2875
+ } else if (type === "object") {
2876
+ let tblKey = prefix ? `${prefix}.${key}` : key;
2877
+ tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
2878
+ } else {
2879
+ preamble += key;
2880
+ preamble += " = ";
2881
+ preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
2882
+ preamble += "\n";
2883
+ }
2884
+ }
2885
+ }
2886
+ if (tableKey && (preamble || !tables))
2887
+ preamble = preamble ? `[${tableKey}]
2888
+ ${preamble}` : `[${tableKey}]`;
2889
+ return preamble && tables ? `${preamble}
2890
+ ${tables}` : preamble || tables;
2891
+ }
2892
+ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
2893
+ if (extendedTypeOf(obj) !== "object") {
2894
+ throw new TypeError("stringify can only be called with an object");
2895
+ }
2896
+ let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
2897
+ if (str[str.length - 1] !== "\n")
2898
+ return str + "\n";
2899
+ return str;
2900
+ }
2901
+
2902
+ // ../../packages/sandbox-docker/dist/index.js
2073
2903
  import { spawnSync as spawnSync2 } from "child_process";
2074
- import { stat as stat42 } from "fs/promises";
2075
- import { homedir as homedir4 } from "os";
2904
+ import { readFile as readFile52, stat as stat42 } from "fs/promises";
2905
+ import { homedir as homedir5 } from "os";
2076
2906
  import { join as join52 } from "path";
2077
2907
  import { execa as execa7 } from "execa";
2078
- import { spawnSync as spawnSync3 } from "child_process";
2079
2908
  import { stat as stat5 } from "fs/promises";
2080
- import { homedir as homedir5 } from "os";
2909
+ import { homedir as homedir6 } from "os";
2081
2910
  import { join as join6 } from "path";
2082
2911
  import { execa as execa8 } from "execa";
2083
- import { randomBytes as randomBytes2 } from "crypto";
2084
- import { createHash as createHash22 } from "crypto";
2085
- import { readFile as readFile52 } from "fs/promises";
2912
+ import { spawnSync as spawnSync3 } from "child_process";
2913
+ import { stat as stat6 } from "fs/promises";
2914
+ import { homedir as homedir7 } from "os";
2086
2915
  import { join as join7 } from "path";
2087
2916
  import { execa as execa9 } from "execa";
2088
- import { existsSync as existsSync2 } from "fs";
2917
+ import { randomBytes as randomBytes2 } from "crypto";
2918
+ import { createHash as createHash22 } from "crypto";
2089
2919
  import { readFile as readFile6 } from "fs/promises";
2090
- import { homedir as homedir6 } from "os";
2091
2920
  import { join as join8 } from "path";
2092
2921
  import { execa as execa10 } from "execa";
2922
+ import { existsSync as existsSync2 } from "fs";
2923
+ import { readFile as readFile7 } from "fs/promises";
2924
+ import { homedir as homedir8 } from "os";
2925
+ import { join as join9 } from "path";
2093
2926
  import { execa as execa11 } from "execa";
2094
- import { mkdir as mkdir42, readdir as readdir42, rm as rm32, stat as stat6 } from "fs/promises";
2095
- import { homedir as homedir7, platform } from "os";
2096
- import { join as join9, resolve as resolve22 } from "path";
2097
- import { mkdir as mkdir5, mkdtemp as mkdtemp3, readFile as readFile7, readdir as readdir5, rm as rm4, writeFile as writeFile32 } from "fs/promises";
2098
- import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
2099
- import { basename as basename5, join as join10 } from "path";
2100
2927
  import { execa as execa12 } from "execa";
2101
- import { stat as stat7 } from "fs/promises";
2928
+ import { mkdir as mkdir42, readdir as readdir42, rm as rm32, stat as stat7 } from "fs/promises";
2929
+ import { homedir as homedir9, platform } from "os";
2930
+ import { join as join10, resolve as resolve22 } from "path";
2931
+ import { mkdir as mkdir5, mkdtemp as mkdtemp3, readFile as readFile8, readdir as readdir5, rm as rm4, writeFile as writeFile32 } from "fs/promises";
2932
+ import { homedir as homedir10, tmpdir as tmpdir3 } from "os";
2933
+ import { basename as basename5, join as join11 } from "path";
2102
2934
  import { execa as execa13 } from "execa";
2935
+ import { stat as stat8 } from "fs/promises";
2103
2936
  import { execa as execa14 } from "execa";
2937
+ import { execa as execa15 } from "execa";
2104
2938
  import { spawn } from "child_process";
2105
2939
  import { randomBytes as randomBytes22 } from "crypto";
2106
2940
  import { existsSync as existsSync3, openSync } from "fs";
2107
- import { cp, mkdir as mkdir6, readFile as readFile8, readdir as readdir6, rename as rename3, rm as rm5, unlink as unlink2, writeFile as writeFile4 } from "fs/promises";
2941
+ import { cp, mkdir as mkdir6, readFile as readFile9, readdir as readdir6, rename as rename3, rm as rm5, unlink as unlink2, writeFile as writeFile4 } from "fs/promises";
2108
2942
  import { request as httpRequest } from "http";
2109
2943
  import { createRequire } from "module";
2110
- import { homedir as homedir9 } from "os";
2111
- import { dirname as dirname32, join as join11, resolve as resolve3, sep } from "path";
2944
+ import { homedir as homedir11 } from "os";
2945
+ import { dirname as dirname32, join as join12, resolve as resolve3, sep } from "path";
2112
2946
  import { setTimeout as delay2 } from "timers/promises";
2113
2947
  import { fileURLToPath } from "url";
2114
2948
 
@@ -2608,21 +3442,22 @@ var QUEUE_LOGS_DIR = join3(STATE_DIR, "logs");
2608
3442
  function queueLogPath(id) {
2609
3443
  return join3(QUEUE_LOGS_DIR, `queue-${id}.log`);
2610
3444
  }
3445
+ var FAILURE_BACKOFF_MS = 5 * 6e4;
2611
3446
 
2612
3447
  // ../../packages/sandbox-docker/dist/index.js
3448
+ import { execa as execa18 } from "execa";
3449
+ import { readdir as readdir7, rm as rm6, stat as stat10 } from "fs/promises";
3450
+ import { join as join15 } from "path";
2613
3451
  import { execa as execa17 } from "execa";
2614
- import { readdir as readdir7, rm as rm6, stat as stat9 } from "fs/promises";
2615
3452
  import { join as join14 } from "path";
2616
- import { execa as execa16 } from "execa";
2617
- import { join as join13 } from "path";
2618
- import { homedir as homedir11 } from "os";
2619
- import { join as join15 } from "path";
2620
- import { execa as execa18 } from "execa";
2621
- import { createHash as createHash32 } from "crypto";
2622
- import { copyFile as copyFile2, mkdir as mkdir8, mkdtemp as mkdtemp4, readdir as readdir8, readFile as readFile9, rm as rm7, stat as stat10 } from "fs/promises";
2623
- import { homedir as homedir12, tmpdir as tmpdir4 } from "os";
2624
- import { basename as basename7, dirname as dirname4, join as join16 } from "path";
3453
+ import { homedir as homedir13 } from "os";
3454
+ import { join as join16 } from "path";
2625
3455
  import { execa as execa19 } from "execa";
3456
+ import { createHash as createHash32 } from "crypto";
3457
+ import { copyFile as copyFile2, mkdir as mkdir8, mkdtemp as mkdtemp4, readdir as readdir8, readFile as readFile10, rm as rm7, stat as stat11 } from "fs/promises";
3458
+ import { homedir as homedir14, tmpdir as tmpdir4 } from "os";
3459
+ import { basename as basename7, dirname as dirname4, join as join17 } from "path";
3460
+ import { execa as execa20 } from "execa";
2626
3461
  function isHostPathHookCommand(command, hostHome) {
2627
3462
  if (typeof command !== "string" || command.length === 0) return false;
2628
3463
  if (hostHome.length === 0) return false;
@@ -3788,6 +4623,41 @@ async function hostBackupHasCredentials(path = CREDENTIALS_BACKUP_FILE) {
3788
4623
  return false;
3789
4624
  }
3790
4625
  }
4626
+ function parseVolumeClaudeCredentials(stdout) {
4627
+ return {
4628
+ present: /\bPRESENT=yes\b/.test(stdout),
4629
+ hasRefreshToken: /\bREFRESH=yes\b/.test(stdout)
4630
+ };
4631
+ }
4632
+ var VOLUME_CRED_PROBE_SCRIPT = `
4633
+ PRESENT=no
4634
+ REFRESH=no
4635
+ VOL=/dst/.credentials.json
4636
+ if [ -f "$VOL" ]; then
4637
+ PRESENT=yes
4638
+ if jq -e '(.claudeAiOauth.refreshToken // "") | length > 0' "$VOL" >/dev/null 2>&1; then REFRESH=yes; fi
4639
+ fi
4640
+ echo "PRESENT=$PRESENT REFRESH=$REFRESH"
4641
+ `;
4642
+ async function volumeClaudeCredentials(volume, image) {
4643
+ try {
4644
+ const { stdout } = await execa4("docker", [
4645
+ "run",
4646
+ "--rm",
4647
+ "--user",
4648
+ "0",
4649
+ "-v",
4650
+ `${volume}:/dst`,
4651
+ image,
4652
+ "sh",
4653
+ "-c",
4654
+ VOLUME_CRED_PROBE_SCRIPT
4655
+ ]);
4656
+ return parseVolumeClaudeCredentials(stdout);
4657
+ } catch {
4658
+ return { present: false, hasRefreshToken: false };
4659
+ }
4660
+ }
3791
4661
  function parseSyncResult(stdout) {
3792
4662
  const volumeHasCredentials = /\bVOLREAL=yes\b/.test(stdout);
3793
4663
  if (/\bEXTRACTED=yes\b/.test(stdout)) return { direction: "extracted", volumeHasCredentials };
@@ -3837,6 +4707,75 @@ async function syncClaudeCredentials(spec, opts) {
3837
4707
  return { direction: "noop", volumeHasCredentials: false };
3838
4708
  }
3839
4709
  }
4710
+ function isHostOnlyPath(cmd, hostHome) {
4711
+ if (typeof cmd !== "string" || cmd.length === 0) return false;
4712
+ if (!cmd.startsWith("/")) return false;
4713
+ const hostOnlyRoots = [
4714
+ hostHome.endsWith("/") ? hostHome : `${hostHome}/`,
4715
+ "/Applications/",
4716
+ "/opt/homebrew/",
4717
+ "/Library/",
4718
+ "/System/",
4719
+ "/private/",
4720
+ "/Users/"
4721
+ ];
4722
+ return hostOnlyRoots.some((root) => cmd.startsWith(root));
4723
+ }
4724
+ function isRecord(v) {
4725
+ return typeof v === "object" && v !== null && !Array.isArray(v);
4726
+ }
4727
+ var BOX_WORKSPACE = "/workspace";
4728
+ var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE}"]
4729
+ trust_level = "trusted"
4730
+ `;
4731
+ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir22()) {
4732
+ const cfg = parse(tomlText);
4733
+ let changed = false;
4734
+ if (isRecord(cfg["mcp_servers"])) {
4735
+ const servers = cfg["mcp_servers"];
4736
+ for (const [name, def] of Object.entries(servers)) {
4737
+ if (isRecord(def) && isHostOnlyPath(def["command"], hostHome)) {
4738
+ delete servers[name];
4739
+ changed = true;
4740
+ }
4741
+ }
4742
+ }
4743
+ const notify = cfg["notify"];
4744
+ if (Array.isArray(notify) && isHostOnlyPath(notify[0], hostHome)) {
4745
+ delete cfg["notify"];
4746
+ changed = true;
4747
+ }
4748
+ const droppedMarkets = /* @__PURE__ */ new Set();
4749
+ if (isRecord(cfg["marketplaces"])) {
4750
+ const markets = cfg["marketplaces"];
4751
+ for (const [name, def] of Object.entries(markets)) {
4752
+ if (isRecord(def) && def["source_type"] === "local" && isHostOnlyPath(def["source"], hostHome)) {
4753
+ delete markets[name];
4754
+ droppedMarkets.add(name);
4755
+ changed = true;
4756
+ }
4757
+ }
4758
+ }
4759
+ if (droppedMarkets.size > 0 && isRecord(cfg["plugins"])) {
4760
+ const plugins = cfg["plugins"];
4761
+ for (const key of Object.keys(plugins)) {
4762
+ const marketplace = key.split("@")[1];
4763
+ if (marketplace !== void 0 && droppedMarkets.has(marketplace)) {
4764
+ delete plugins[key];
4765
+ changed = true;
4766
+ }
4767
+ }
4768
+ }
4769
+ if (!isRecord(cfg["projects"])) cfg["projects"] = {};
4770
+ const projects = cfg["projects"];
4771
+ const wsEntry = isRecord(projects[BOX_WORKSPACE]) ? projects[BOX_WORKSPACE] : {};
4772
+ if (wsEntry["trust_level"] !== "trusted") {
4773
+ wsEntry["trust_level"] = "trusted";
4774
+ projects[BOX_WORKSPACE] = wsEntry;
4775
+ changed = true;
4776
+ }
4777
+ return { text: changed ? stringify(cfg) : tomlText, changed };
4778
+ }
3840
4779
  var CLOUD_WORKSPACE = "/workspace";
3841
4780
  async function pathExists(p) {
3842
4781
  try {
@@ -3935,7 +4874,7 @@ function encodeClaudeProjectsKey(absPath) {
3935
4874
  return absPath.replace(/[^a-zA-Z0-9]/g, "-");
3936
4875
  }
3937
4876
  var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
3938
- async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir22()) {
4877
+ async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir3()) {
3939
4878
  if (hostWorkspace.length === 0) return null;
3940
4879
  const memDir = join32(
3941
4880
  hostHome,
@@ -3990,7 +4929,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
3990
4929
  return working;
3991
4930
  }
3992
4931
  async function stageClaudeJsonOnlyForUpload(opts = {}) {
3993
- const hostHome = opts.hostHome ?? homedir22();
4932
+ const hostHome = opts.hostHome ?? homedir3();
3994
4933
  const stageDir = await mkStageDir("claude-json-only");
3995
4934
  let tarballPath = null;
3996
4935
  try {
@@ -4012,7 +4951,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
4012
4951
  }
4013
4952
  }
4014
4953
  async function stageClaudeStaticForUpload(opts = {}) {
4015
- const hostHome = opts.hostHome ?? homedir22();
4954
+ const hostHome = opts.hostHome ?? homedir3();
4016
4955
  const hostClaude = join32(hostHome, ".claude");
4017
4956
  if (!await pathExists(hostClaude)) return emptyResult();
4018
4957
  const stageDir = await mkStageDir("claude-static");
@@ -4083,12 +5022,16 @@ var CODEX_RSYNC_EXCLUDES = [
4083
5022
  "--exclude=log",
4084
5023
  "--exclude=history.jsonl",
4085
5024
  "--exclude=hooks.json",
4086
- "--exclude=logs_2.sqlite",
4087
- "--exclude=logs_2.sqlite-shm",
4088
- "--exclude=logs_2.sqlite-wal",
4089
- "--exclude=state_5.sqlite",
4090
- "--exclude=state_5.sqlite-shm",
4091
- "--exclude=state_5.sqlite-wal",
5025
+ // Codex's session-state DBs / indexes — the `state_*.sqlite` `threads` index
5026
+ // is where Codex reads the resume cwd, so seeding the host copy makes a
5027
+ // teleported session resume at its host cwd (the "Choose working directory"
5028
+ // prompt). Globbed on the version suffix (state_5 -> state_6 across schema
5029
+ // bumps) so it keeps matching. Codex rebuilds the index from the box's
5030
+ // rollouts (see `backfill_state`). Also stops the host's cross-project Codex
5031
+ // history from leaking into the box.
5032
+ "--exclude=state_*.sqlite*",
5033
+ "--exclude=logs_*.sqlite*",
5034
+ "--exclude=external_agent_session_imports.json",
4092
5035
  "--exclude=sqlite",
4093
5036
  "--exclude=cache",
4094
5037
  "--exclude=vendor_imports",
@@ -4106,8 +5049,16 @@ var CODEX_RSYNC_EXCLUDES = [
4106
5049
  "--exclude=version.json"
4107
5050
  ];
4108
5051
  var CODEX_KEYCHAIN_WARNING = 'codex: ~/.codex/auth.json missing. On macOS the codex CLI defaults to storing the OAuth token in the system Keychain, which isn\'t reachable from a remote sandbox. To share creds with cloud boxes either:\n - add `cli_auth_credentials_store = "file"` to ~/.codex/config.toml then re-run `codex login`, or\n - set OPENAI_API_KEY in your environment, or\n - run `codex login --with-api-key` for a file-backed login.\nSkipping codex seed; in-box codex will prompt for sign-in.';
5052
+ async function sanitizeStagedCodexConfig(configPath, hostHome) {
5053
+ try {
5054
+ if (!await pathExists(configPath)) return;
5055
+ const { text, changed } = sanitizeCodexConfigForBox(await readFile32(configPath, "utf8"), hostHome);
5056
+ if (changed) await writeFile3(configPath, text);
5057
+ } catch {
5058
+ }
5059
+ }
4109
5060
  async function stageCodexStaticForUpload(opts = {}) {
4110
- const hostHome = opts.hostHome ?? homedir22();
5061
+ const hostHome = opts.hostHome ?? homedir3();
4111
5062
  const hostCodex = join32(hostHome, ".codex");
4112
5063
  if (!await pathExists(hostCodex)) return emptyResult();
4113
5064
  const stageDir = await mkStageDir("codex-static");
@@ -4123,6 +5074,7 @@ async function stageCodexStaticForUpload(opts = {}) {
4123
5074
  `${hostCodex}/`,
4124
5075
  `${stageDir}/`
4125
5076
  ]);
5077
+ await sanitizeStagedCodexConfig(join32(stageDir, "config.toml"), hostHome);
4126
5078
  tarballPath = await tarballFromDir(stageDir, "codex-static");
4127
5079
  return {
4128
5080
  tarballPath,
@@ -4135,8 +5087,35 @@ async function stageCodexStaticForUpload(opts = {}) {
4135
5087
  throw err;
4136
5088
  }
4137
5089
  }
5090
+ async function stageAgentsStaticForUpload(opts = {}) {
5091
+ const hostHome = opts.hostHome ?? homedir3();
5092
+ const hostAgents = join32(hostHome, ".agents");
5093
+ if (!await pathExists(hostAgents)) return emptyResult();
5094
+ const stageDir = await mkStageDir("agents-static");
5095
+ let tarballPath = null;
5096
+ try {
5097
+ const broken = await findBrokenSymlinks(hostAgents);
5098
+ await execa5("rsync", [
5099
+ "-a",
5100
+ "-L",
5101
+ ...broken.map((r) => `--exclude=/${r}`),
5102
+ `${hostAgents}/`,
5103
+ `${stageDir}/`
5104
+ ]);
5105
+ tarballPath = await tarballFromDir(stageDir, "agents-static");
5106
+ return {
5107
+ tarballPath,
5108
+ cleanup: makeCleanup([stageDir, tarballPath]),
5109
+ warnings: []
5110
+ };
5111
+ } catch (err) {
5112
+ await rm3(stageDir, { recursive: true, force: true });
5113
+ if (tarballPath) await rm3(tarballPath, { force: true });
5114
+ throw err;
5115
+ }
5116
+ }
4138
5117
  async function stageCodexCredentialsForUpload(opts = {}) {
4139
- const hostHome = opts.hostHome ?? homedir22();
5118
+ const hostHome = opts.hostHome ?? homedir3();
4140
5119
  const cloudBackup = join32(hostHome, ".agentbox", "codex-credentials.json");
4141
5120
  if (await pathExists(cloudBackup)) {
4142
5121
  return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
@@ -4159,7 +5138,7 @@ var OPENCODE_DATA_EXCLUDES = [
4159
5138
  "--exclude=opencode.db-wal"
4160
5139
  ];
4161
5140
  async function stageOpencodeStaticForUpload(opts = {}) {
4162
- const hostHome = opts.hostHome ?? homedir22();
5141
+ const hostHome = opts.hostHome ?? homedir3();
4163
5142
  const hostData = join32(hostHome, ".local", "share", "opencode");
4164
5143
  const hostConfig = join32(hostHome, ".config", "opencode");
4165
5144
  const hasData = await pathExists(hostData);
@@ -4204,7 +5183,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
4204
5183
  }
4205
5184
  }
4206
5185
  async function stageOpencodeCredentialsForUpload(opts = {}) {
4207
- const hostHome = opts.hostHome ?? homedir22();
5186
+ const hostHome = opts.hostHome ?? homedir3();
4208
5187
  const cloudBackup = join32(hostHome, ".agentbox", "opencode-credentials.json");
4209
5188
  if (await pathExists(cloudBackup)) {
4210
5189
  return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
@@ -4214,7 +5193,7 @@ async function stageOpencodeCredentialsForUpload(opts = {}) {
4214
5193
  return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
4215
5194
  }
4216
5195
  async function stageOpencodeStateForUpload(opts = {}) {
4217
- const hostHome = opts.hostHome ?? homedir22();
5196
+ const hostHome = opts.hostHome ?? homedir3();
4218
5197
  const hostModel = join32(hostHome, ".local", "state", "opencode", "model.json");
4219
5198
  if (!await pathExists(hostModel)) return emptyResult();
4220
5199
  return stageSingleFileTarball("opencode-state", hostModel, "model.json");
@@ -4263,32 +5242,43 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
4263
5242
  })
4264
5243
  );
4265
5244
  const unsyncable = [];
4266
- async function walk(dir) {
4267
- let entries;
5245
+ const onPath = /* @__PURE__ */ new Set();
5246
+ async function walk(realDir, virtualDir) {
5247
+ if (onPath.has(realDir)) return;
5248
+ onPath.add(realDir);
4268
5249
  try {
4269
- entries = await readdir3(dir, { withFileTypes: true });
4270
- } catch {
4271
- return;
4272
- }
4273
- for (const ent of entries) {
4274
- const full = join4(dir, ent.name);
4275
- if (ent.isSymbolicLink()) {
4276
- let real;
4277
- try {
4278
- real = await realpath2(full);
4279
- } catch {
4280
- unsyncable.push(relative2(root, full));
4281
- continue;
4282
- }
4283
- if (!reachable.some((r) => isUnder(r, real))) {
4284
- unsyncable.push(relative2(root, full));
5250
+ let entries;
5251
+ try {
5252
+ entries = await readdir3(realDir, { withFileTypes: true });
5253
+ } catch {
5254
+ return;
5255
+ }
5256
+ for (const ent of entries) {
5257
+ const realFull = join4(realDir, ent.name);
5258
+ const virtualFull = virtualDir ? join4(virtualDir, ent.name) : ent.name;
5259
+ if (ent.isSymbolicLink()) {
5260
+ let real;
5261
+ try {
5262
+ real = await realpath2(realFull);
5263
+ } catch {
5264
+ unsyncable.push(virtualFull);
5265
+ continue;
5266
+ }
5267
+ if (!reachable.some((r) => isUnder(r, real))) {
5268
+ unsyncable.push(virtualFull);
5269
+ continue;
5270
+ }
5271
+ const st = await stat3(real).catch(() => null);
5272
+ if (st?.isDirectory()) await walk(real, virtualFull);
5273
+ } else if (ent.isDirectory()) {
5274
+ await walk(realFull, virtualFull);
4285
5275
  }
4286
- } else if (ent.isDirectory()) {
4287
- await walk(full);
4288
5276
  }
5277
+ } finally {
5278
+ onPath.delete(realDir);
4289
5279
  }
4290
5280
  }
4291
- await walk(root);
5281
+ await walk(root, "");
4292
5282
  return unsyncable;
4293
5283
  }
4294
5284
  async function ensureClaudeVolume(spec, opts) {
@@ -4296,13 +5286,13 @@ async function ensureClaudeVolume(spec, opts) {
4296
5286
  await ensureVolume(spec.volume);
4297
5287
  const created = !existed;
4298
5288
  if (!opts.syncFromHost) return { created, synced: false };
4299
- const hostClaude = join4(homedir3(), ".claude");
5289
+ const hostClaude = join4(homedir4(), ".claude");
4300
5290
  if (!await pathExists2(hostClaude)) return { created, synced: false };
4301
- const hostClaudeJson = join4(homedir3(), ".claude.json");
5291
+ const hostClaudeJson = join4(homedir4(), ".claude.json");
4302
5292
  const hasJson = await pathExists2(hostClaudeJson);
4303
5293
  const seedClaudeJson = !await volumeHasClaudeJson(spec.volume, opts.image);
4304
- const hostHome = homedir3();
4305
- const hostAgents = join4(homedir3(), ".agents");
5294
+ const hostHome = homedir4();
5295
+ const hostAgents = join4(homedir4(), ".agents");
4306
5296
  const hasAgents = await pathExists2(hostAgents);
4307
5297
  const args = [
4308
5298
  "run",
@@ -5019,7 +6009,7 @@ async function readJsonFile(path) {
5019
6009
  }
5020
6010
  }
5021
6011
  async function pullClaudeExtras(spec, opts) {
5022
- const hostHome = homedir3();
6012
+ const hostHome = homedir4();
5023
6013
  const hostClaude = join4(hostHome, ".claude");
5024
6014
  const inventoryScript = [
5025
6015
  "for cat in skills agents commands; do",
@@ -5188,9 +6178,12 @@ async function ensureCodexVolume(spec, opts) {
5188
6178
  const existed = await volumeExists(spec.volume);
5189
6179
  await ensureVolume(spec.volume);
5190
6180
  const created = !existed;
5191
- const hostCodex = join52(homedir4(), ".codex");
6181
+ const hostCodex = join52(homedir5(), ".codex");
5192
6182
  const willSync = opts.syncFromHost && await pathExists3(hostCodex);
5193
6183
  if (willSync) {
6184
+ const hasAgents = await pathExists3(join52(homedir5(), ".agents"));
6185
+ const skillsExclude = hasAgents ? " --exclude=skills" : "";
6186
+ const skillsPurge = hasAgents ? " && { [ -d /dst/skills ] && find /dst/skills -mindepth 1 -maxdepth 1 ! -name .system -exec rm -rf {} + || true; }" : "";
5194
6187
  await execa7("docker", [
5195
6188
  "run",
5196
6189
  "--rm",
@@ -5205,8 +6198,18 @@ async function ensureCodexVolume(spec, opts) {
5205
6198
  "-c",
5206
6199
  // --exclude=hooks.json: the AgentBox activity hooks file is box-owned
5207
6200
  // (seeded by seedCodexHooks); never let the host copy clobber it.
5208
- "rsync -a --exclude=sessions --exclude=log --exclude=history.jsonl --exclude=hooks.json /src/ /dst/ && chown -R 1000:1000 /dst"
6201
+ // The session-state DBs / indexes are excluded so a teleported session
6202
+ // resumes at /workspace (Codex reads the cwd from state_*.sqlite's threads
6203
+ // index, which it backfills from the box's rollouts) and the host's
6204
+ // cross-project Codex history doesn't leak into the box.
6205
+ // The trailing `rm -rf` purges any state DBs a PREVIOUS sync (before these
6206
+ // excludes) already copied into the shared volume — rsync without
6207
+ // --delete only adds/updates. The globs are no-ops with `-f` when absent,
6208
+ // and never touch box-owned `sessions/` (the teleported rollouts) or
6209
+ // `hooks.json`.
6210
+ "rsync -a --exclude=sessions --exclude=log --exclude=history.jsonl --exclude=hooks.json" + skillsExclude + " --exclude=state_*.sqlite* --exclude=logs_*.sqlite* --exclude=session_index.jsonl --exclude=external_agent_session_imports.json --exclude=shell_snapshots /src/ /dst/ && rm -rf /dst/state_*.sqlite* /dst/logs_*.sqlite* /dst/session_index.jsonl /dst/external_agent_session_imports.json /dst/shell_snapshots" + skillsPurge + " && chown -R 1000:1000 /dst"
5209
6211
  ]);
6212
+ await sanitizeVolumeCodexConfig(spec.volume, opts.image);
5210
6213
  return { created, synced: true };
5211
6214
  }
5212
6215
  await execa7(
@@ -5225,6 +6228,9 @@ async function ensureCodexVolume(spec, opts) {
5225
6228
  ],
5226
6229
  { reject: false }
5227
6230
  );
6231
+ if (!await pathExists3(join52(hostCodex, "config.toml"))) {
6232
+ await sanitizeVolumeCodexConfig(spec.volume, opts.image);
6233
+ }
5228
6234
  return { created, synced: false };
5229
6235
  }
5230
6236
  async function seedCodexHooks(volume, image) {
@@ -5246,6 +6252,39 @@ async function seedCodexHooks(volume, image) {
5246
6252
  return { seeded: false };
5247
6253
  }
5248
6254
  }
6255
+ async function sanitizeVolumeCodexConfig(volume, image) {
6256
+ try {
6257
+ const hostConfig = join52(homedir5(), ".codex", "config.toml");
6258
+ let text;
6259
+ if (!await pathExists3(hostConfig)) {
6260
+ text = MINIMAL_TRUSTED_CODEX_CONFIG;
6261
+ } else {
6262
+ const sanitized = sanitizeCodexConfigForBox(await readFile52(hostConfig, "utf8"));
6263
+ if (!sanitized.changed || sanitized.text.length === 0) return { sanitized: false };
6264
+ text = sanitized.text;
6265
+ }
6266
+ await execa7(
6267
+ "docker",
6268
+ [
6269
+ "run",
6270
+ "--rm",
6271
+ "-i",
6272
+ "--user",
6273
+ "0",
6274
+ "-v",
6275
+ `${volume}:/dst`,
6276
+ image,
6277
+ "sh",
6278
+ "-c",
6279
+ "cat > /dst/config.toml.tmp && chown 1000:1000 /dst/config.toml.tmp && mv /dst/config.toml.tmp /dst/config.toml"
6280
+ ],
6281
+ { input: text }
6282
+ );
6283
+ return { sanitized: true };
6284
+ } catch {
6285
+ return { sanitized: false };
6286
+ }
6287
+ }
5249
6288
  var CODEX_FORWARDED_ENV_KEYS = ["OPENAI_API_KEY"];
5250
6289
  function buildCodexMounts(spec, hostEnv) {
5251
6290
  const env = {};
@@ -5420,7 +6459,7 @@ async function codexSessionInfo(container, sessionName) {
5420
6459
  }
5421
6460
  var CODEX_PULL_ITEMS = ["config.toml", "auth.json", "prompts"];
5422
6461
  async function pullCodexConfig(spec, opts) {
5423
- const hostCodex = join52(homedir4(), ".codex");
6462
+ const hostCodex = join52(homedir5(), ".codex");
5424
6463
  const inv = await execa7(
5425
6464
  "docker",
5426
6465
  [
@@ -5480,6 +6519,57 @@ async function pullCodexConfig(spec, opts) {
5480
6519
  }
5481
6520
  return { newItems };
5482
6521
  }
6522
+ var SHARED_AGENTS_VOLUME = "agentbox-agents-config";
6523
+ var CONTAINER_AGENTS_DIR = "/home/vscode/.agents";
6524
+ function resolveAgentsVolume() {
6525
+ return { volume: SHARED_AGENTS_VOLUME };
6526
+ }
6527
+ async function pathExists4(p) {
6528
+ try {
6529
+ await stat5(p);
6530
+ return true;
6531
+ } catch {
6532
+ return false;
6533
+ }
6534
+ }
6535
+ async function ensureAgentsVolume(spec, opts) {
6536
+ const existed = await volumeExists(spec.volume);
6537
+ await ensureVolume(spec.volume);
6538
+ const created = !existed;
6539
+ const hostAgents = join6(homedir6(), ".agents");
6540
+ const willSync = opts.syncFromHost && await pathExists4(hostAgents);
6541
+ if (willSync) {
6542
+ const unsyncable = await findUnsyncableSymlinks(hostAgents, [hostAgents]);
6543
+ const symlinkExcludes = unsyncable.map((rel) => ` --exclude=/${rel}`).join("");
6544
+ await execa8("docker", [
6545
+ "run",
6546
+ "--rm",
6547
+ "--user",
6548
+ "0",
6549
+ "-v",
6550
+ `${spec.volume}:/dst`,
6551
+ "-v",
6552
+ `${hostAgents}:/src:ro`,
6553
+ opts.image,
6554
+ "sh",
6555
+ "-c",
6556
+ "rsync -a --copy-unsafe-links" + symlinkExcludes + " /src/ /dst/ && chown -R 1000:1000 /dst"
6557
+ ]);
6558
+ return { created, synced: true };
6559
+ }
6560
+ await execa8(
6561
+ "docker",
6562
+ ["run", "--rm", "--user", "0", "-v", `${spec.volume}:/dst`, opts.image, "sh", "-c", "chown 1000:1000 /dst"],
6563
+ { reject: false }
6564
+ );
6565
+ return { created, synced: false };
6566
+ }
6567
+ function buildAgentsMounts(spec) {
6568
+ return {
6569
+ extraVolumes: [`${spec.volume}:${CONTAINER_AGENTS_DIR}`],
6570
+ volumeName: spec.volume
6571
+ };
6572
+ }
5483
6573
  var SHARED_OPENCODE_VOLUME = "agentbox-opencode-config";
5484
6574
  var DEFAULT_OPENCODE_SESSION = "opencode";
5485
6575
  var CONTAINER_OPENCODE_DIR = "/home/vscode/.local/share/opencode";
@@ -5492,9 +6582,9 @@ function resolveOpencodeVolume(opts) {
5492
6582
  }
5493
6583
  return { volume: SHARED_OPENCODE_VOLUME };
5494
6584
  }
5495
- async function pathExists4(p) {
6585
+ async function pathExists5(p) {
5496
6586
  try {
5497
- await stat5(p);
6587
+ await stat6(p);
5498
6588
  return true;
5499
6589
  } catch {
5500
6590
  return false;
@@ -5509,12 +6599,12 @@ async function ensureOpencodeVolume(spec, opts) {
5509
6599
  const existed = await volumeExists(spec.volume);
5510
6600
  await ensureVolume(spec.volume);
5511
6601
  const created = !existed;
5512
- const hostData = join6(homedir5(), ".local", "share", "opencode");
5513
- const hostConfig = join6(homedir5(), ".config", "opencode");
5514
- const hostState = join6(homedir5(), ".local", "state", "opencode");
5515
- const hasData = await pathExists4(hostData);
5516
- const hasConfig = await pathExists4(hostConfig);
5517
- const hasState = await pathExists4(hostState);
6602
+ const hostData = join7(homedir7(), ".local", "share", "opencode");
6603
+ const hostConfig = join7(homedir7(), ".config", "opencode");
6604
+ const hostState = join7(homedir7(), ".local", "state", "opencode");
6605
+ const hasData = await pathExists5(hostData);
6606
+ const hasConfig = await pathExists5(hostConfig);
6607
+ const hasState = await pathExists5(hostState);
5518
6608
  const willSync = opts.syncFromHost && (hasData || hasConfig || hasState);
5519
6609
  if (willSync) {
5520
6610
  const args = ["run", "--rm", "--user", "0", "-v", `${spec.volume}:/dst`];
@@ -5537,10 +6627,10 @@ async function ensureOpencodeVolume(spec, opts) {
5537
6627
  }
5538
6628
  steps.push("chown -R 1000:1000 /dst");
5539
6629
  args.push(opts.image, "sh", "-c", steps.join(" && "));
5540
- await execa8("docker", args);
6630
+ await execa9("docker", args);
5541
6631
  return { created, synced: true };
5542
6632
  }
5543
- await execa8(
6633
+ await execa9(
5544
6634
  "docker",
5545
6635
  [
5546
6636
  "run",
@@ -5560,7 +6650,7 @@ async function ensureOpencodeVolume(spec, opts) {
5560
6650
  }
5561
6651
  async function seedOpencodePlugin(volume, image) {
5562
6652
  try {
5563
- const { stdout } = await execa8("docker", [
6653
+ const { stdout } = await execa9("docker", [
5564
6654
  "run",
5565
6655
  "--rm",
5566
6656
  "--user",
@@ -5608,14 +6698,14 @@ var OpencodeSessionError = class extends Error {
5608
6698
  }
5609
6699
  };
5610
6700
  async function ensureOpencodeInstalled(container, opts = {}) {
5611
- const probe = await execa8(
6701
+ const probe = await execa9(
5612
6702
  "docker",
5613
6703
  ["exec", "--user", CONTAINER_USER, container, "sh", "-c", "command -v opencode"],
5614
6704
  { reject: false }
5615
6705
  );
5616
6706
  if (probe.exitCode === 0) return { installed: false };
5617
6707
  opts.onProgress?.("installing opencode (absent from this box image)");
5618
- const install = await execa8(
6708
+ const install = await execa9(
5619
6709
  "docker",
5620
6710
  ["exec", "--user", "root", container, "bash", "-lc", "npm install -g opencode-ai 2>&1"],
5621
6711
  { reject: false }
@@ -5637,7 +6727,7 @@ async function startOpencodeSession(opts) {
5637
6727
  const v = process.env[k];
5638
6728
  if (typeof v === "string" && v.length > 0) envFlags.push("-e", `${k}=${v}`);
5639
6729
  }
5640
- const result = await execa8(
6730
+ const result = await execa9(
5641
6731
  "docker",
5642
6732
  [
5643
6733
  "exec",
@@ -5723,7 +6813,7 @@ function runInteractiveOpencodeLogin(dockerArgv) {
5723
6813
  return { exitCode: child.status ?? 1 };
5724
6814
  }
5725
6815
  async function volumeHasOpencodeAuth(volume, image) {
5726
- const res = await execa8(
6816
+ const res = await execa9(
5727
6817
  "docker",
5728
6818
  ["run", "--rm", "-v", `${volume}:/dst`, image, "sh", "-c", "test -e /dst/auth.json"],
5729
6819
  { reject: false }
@@ -5732,7 +6822,7 @@ async function volumeHasOpencodeAuth(volume, image) {
5732
6822
  }
5733
6823
  async function opencodeSessionInfo(container, sessionName) {
5734
6824
  const name = sessionName ?? DEFAULT_OPENCODE_SESSION;
5735
- const has = await execa8(
6825
+ const has = await execa9(
5736
6826
  "docker",
5737
6827
  ["exec", "--user", CONTAINER_USER, container, "tmux", "has-session", "-t", name],
5738
6828
  { reject: false }
@@ -5740,7 +6830,7 @@ async function opencodeSessionInfo(container, sessionName) {
5740
6830
  if (has.exitCode !== 0) {
5741
6831
  return { running: false, sessionName: name, startedAt: null };
5742
6832
  }
5743
- const ts = await execa8(
6833
+ const ts = await execa9(
5744
6834
  "docker",
5745
6835
  [
5746
6836
  "exec",
@@ -5776,9 +6866,9 @@ var OPENCODE_PULL_CONFIG_ITEMS = [
5776
6866
  "themes"
5777
6867
  ];
5778
6868
  async function pullOpencodeConfig(spec, opts) {
5779
- const hostData = join6(homedir5(), ".local", "share", "opencode");
5780
- const hostConfig = join6(homedir5(), ".config", "opencode");
5781
- const inv = await execa8(
6869
+ const hostData = join7(homedir7(), ".local", "share", "opencode");
6870
+ const hostConfig = join7(homedir7(), ".config", "opencode");
6871
+ const inv = await execa9(
5782
6872
  "docker",
5783
6873
  [
5784
6874
  "run",
@@ -5804,7 +6894,7 @@ async function pullOpencodeConfig(spec, opts) {
5804
6894
  const [group, name] = line.trim().split(/\s+/, 2);
5805
6895
  if (!name || group !== "data" && group !== "config") continue;
5806
6896
  const hostBase = group === "data" ? hostData : hostConfig;
5807
- if (await pathExists4(join6(hostBase, name))) continue;
6897
+ if (await pathExists5(join7(hostBase, name))) continue;
5808
6898
  newItems.push({
5809
6899
  label: group === "data" ? name : `config/${name}`,
5810
6900
  src: group === "data" ? `/src/${name}` : `/src/config/${name}`,
@@ -5820,7 +6910,7 @@ async function pullOpencodeConfig(spec, opts) {
5820
6910
  const cmds = newItems.map(
5821
6911
  (i) => `cp -a '${i.src}' '${i.hostDst === "data" ? "/dst-data" : "/dst-config"}/${i.name}'`
5822
6912
  );
5823
- const apply = await execa8(
6913
+ const apply = await execa9(
5824
6914
  "docker",
5825
6915
  [
5826
6916
  "run",
@@ -5931,9 +7021,9 @@ function gitWorktreePathFor(branch) {
5931
7021
  return `${WORKTREE_ROOT}/${fsSafeBranch(branch)}`;
5932
7022
  }
5933
7023
  async function collectRepoCarryOver(repo, branch, containerPath, gitWorktreePath) {
5934
- const stash = await execa9("git", ["-C", repo.hostMainRepo, "stash", "create"], { reject: false });
7024
+ const stash = await execa10("git", ["-C", repo.hostMainRepo, "stash", "create"], { reject: false });
5935
7025
  const stashSha = stash.exitCode === 0 ? stash.stdout.trim() || null : null;
5936
- const untracked = await execa9(
7026
+ const untracked = await execa10(
5937
7027
  "git",
5938
7028
  ["-C", repo.hostMainRepo, "ls-files", "--others", "--exclude-standard", "-z"],
5939
7029
  { reject: false }
@@ -5950,7 +7040,7 @@ async function collectRepoCarryOver(repo, branch, containerPath, gitWorktreePath
5950
7040
  };
5951
7041
  }
5952
7042
  async function dexec(container, argv, user = "vscode", cwd = "/") {
5953
- const r = await execa9(
7043
+ const r = await execa10(
5954
7044
  "docker",
5955
7045
  ["exec", "-w", cwd, "--user", user, container, ...argv],
5956
7046
  { reject: false }
@@ -5982,7 +7072,7 @@ async function bindWorktrees(container, binds, onLog) {
5982
7072
  (a, b) => a.kind === "root" && b.kind !== "root" ? -1 : a.kind !== "root" && b.kind === "root" ? 1 : 0
5983
7073
  );
5984
7074
  for (const b of ordered) {
5985
- await execa9(
7075
+ await execa10(
5986
7076
  "docker",
5987
7077
  ["exec", "-w", "/", "--user", "root", container, "sh", "-c", `mountpoint -q ${b.containerPath} && umount ${b.containerPath} || true`],
5988
7078
  { reject: false }
@@ -6004,7 +7094,7 @@ async function seedWorkspace(opts) {
6004
7094
  const wt = r.gitWorktreePath;
6005
7095
  const baseRef = r.repo.kind === "root" ? opts.fromBranch ?? "HEAD" : "HEAD";
6006
7096
  const addArgs = r.reuseBranch ? ["worktree", "add", wt, r.branch] : ["worktree", "add", "-b", r.branch, wt, baseRef];
6007
- const add = await execa9(
7097
+ const add = await execa10(
6008
7098
  "docker",
6009
7099
  ["exec", "--user", "vscode", opts.container, "git", "-C", main, ...addArgs],
6010
7100
  { reject: false }
@@ -6015,7 +7105,7 @@ async function seedWorkspace(opts) {
6015
7105
  );
6016
7106
  }
6017
7107
  log(`worktree ${wt} on branch ${r.branch} (host main ${main})`);
6018
- await execa9(
7108
+ await execa10(
6019
7109
  "docker",
6020
7110
  [
6021
7111
  "exec",
@@ -6031,7 +7121,7 @@ async function seedWorkspace(opts) {
6031
7121
  ],
6032
7122
  { reject: false }
6033
7123
  );
6034
- await execa9(
7124
+ await execa10(
6035
7125
  "docker",
6036
7126
  [
6037
7127
  "exec",
@@ -6061,7 +7151,7 @@ async function seedWorkspace(opts) {
6061
7151
  for (const r of opts.repos) {
6062
7152
  const ct = r.containerPath;
6063
7153
  if (r.stashSha) {
6064
- const withIndex = await execa9(
7154
+ const withIndex = await execa10(
6065
7155
  "docker",
6066
7156
  [
6067
7157
  "exec",
@@ -6079,7 +7169,7 @@ async function seedWorkspace(opts) {
6079
7169
  { reject: false }
6080
7170
  );
6081
7171
  if (withIndex.exitCode !== 0) {
6082
- const noIndex = await execa9(
7172
+ const noIndex = await execa10(
6083
7173
  "docker",
6084
7174
  [
6085
7175
  "exec",
@@ -6107,7 +7197,7 @@ async function seedWorkspace(opts) {
6107
7197
  }
6108
7198
  }
6109
7199
  if (r.untrackedNul.length > 0) {
6110
- const tarOut = await execa9("tar", ["-C", r.hostSource, "--null", "-T", "-", "-cf", "-"], {
7200
+ const tarOut = await execa10("tar", ["-C", r.hostSource, "--null", "-T", "-", "-cf", "-"], {
6111
7201
  input: r.untrackedNul.replace(/\0$/, ""),
6112
7202
  encoding: "buffer",
6113
7203
  reject: false
@@ -6116,7 +7206,7 @@ async function seedWorkspace(opts) {
6116
7206
  log(`warning: tar of untracked files for ${r.repo.hostMainRepo} failed: ${tarOut.stderr}`);
6117
7207
  continue;
6118
7208
  }
6119
- const tarIn = await execa9(
7209
+ const tarIn = await execa10(
6120
7210
  "docker",
6121
7211
  ["exec", "-i", "--user", "vscode", opts.container, "tar", "-C", ct, "-xf", "-"],
6122
7212
  { input: tarOut.stdout, reject: false }
@@ -6169,7 +7259,7 @@ async function regenerateRestoredWorktrees(opts) {
6169
7259
  for (const p of opts.plans) {
6170
7260
  const baseRef = p.kind === "root" ? opts.fromBranch ?? "HEAD" : "HEAD";
6171
7261
  const metaDir = `${p.hostMainRepo}/.git/worktrees/${fsSafeBranch(p.freshBranch)}`;
6172
- const r = await execa9(
7262
+ const r = await execa10(
6173
7263
  "docker",
6174
7264
  [
6175
7265
  "exec",
@@ -6202,14 +7292,14 @@ async function regenerateRestoredWorktrees(opts) {
6202
7292
  async function seedWorkspaceFromDir(opts) {
6203
7293
  const log = opts.onLog ?? (() => {
6204
7294
  });
6205
- const tarOut = await execa9("tar", ["-C", opts.hostSource, "-cf", "-", "."], {
7295
+ const tarOut = await execa10("tar", ["-C", opts.hostSource, "-cf", "-", "."], {
6206
7296
  encoding: "buffer",
6207
7297
  reject: false
6208
7298
  });
6209
7299
  if (tarOut.exitCode !== 0) {
6210
7300
  throw new GitWorktreeError(`tar of ${opts.hostSource} failed: ${tarOut.stderr}`);
6211
7301
  }
6212
- const tarIn = await execa9(
7302
+ const tarIn = await execa10(
6213
7303
  "docker",
6214
7304
  ["exec", "-i", "--user", "1000:1000", opts.container, "tar", "-C", "/workspace", "-xf", "-"],
6215
7305
  { input: tarOut.stdout, reject: false }
@@ -6220,13 +7310,13 @@ async function seedWorkspaceFromDir(opts) {
6220
7310
  log(`seeded /workspace from ${opts.hostSource}`);
6221
7311
  }
6222
7312
  async function removeInBoxWorktree(args) {
6223
- const remove = await execa9(
7313
+ const remove = await execa10(
6224
7314
  "git",
6225
7315
  ["-C", args.hostMainRepo, "worktree", "remove", "--force", args.gitWorktreePath],
6226
7316
  { reject: false }
6227
7317
  );
6228
7318
  if (remove.exitCode === 0) return;
6229
- await execa9("git", ["-C", args.hostMainRepo, "worktree", "prune"], { reject: false });
7319
+ await execa10("git", ["-C", args.hostMainRepo, "worktree", "prune"], { reject: false });
6230
7320
  }
6231
7321
  function ctParent(p) {
6232
7322
  const i = p.lastIndexOf("/");
@@ -6257,20 +7347,20 @@ async function resyncWorkspaceFromHost(opts) {
6257
7347
  const hostMain = w.hostMainRepo;
6258
7348
  const boxBranch = w.branch;
6259
7349
  const res = { containerPath: ct, mergeConflicts: [], overlaySkipped: [] };
6260
- const hostBranchProbe = await execa9(
7350
+ const hostBranchProbe = await execa10(
6261
7351
  "git",
6262
7352
  ["-C", hostMain, "symbolic-ref", "--short", "-q", "HEAD"],
6263
7353
  { reject: false }
6264
7354
  );
6265
- const hostRef = hostBranchProbe.exitCode === 0 && hostBranchProbe.stdout.trim() ? hostBranchProbe.stdout.trim() : (await execa9("git", ["-C", hostMain, "rev-parse", "HEAD"], { reject: false })).stdout.trim();
7355
+ const hostRef = hostBranchProbe.exitCode === 0 && hostBranchProbe.stdout.trim() ? hostBranchProbe.stdout.trim() : (await execa10("git", ["-C", hostMain, "rev-parse", "HEAD"], { reject: false })).stdout.trim();
6266
7356
  if (!hostRef) {
6267
7357
  log(`resync: ${ct}: could not resolve host ref; skipping`);
6268
7358
  results.push(res);
6269
7359
  continue;
6270
7360
  }
6271
- const stash = await execa9("git", ["-C", hostMain, "stash", "create"], { reject: false });
7361
+ const stash = await execa10("git", ["-C", hostMain, "stash", "create"], { reject: false });
6272
7362
  const hostStashSha = stash.exitCode === 0 ? stash.stdout.trim() || null : null;
6273
- const untracked = await execa9(
7363
+ const untracked = await execa10(
6274
7364
  "git",
6275
7365
  ["-C", hostMain, "ls-files", "--others", "--exclude-standard", "-z"],
6276
7366
  { reject: false }
@@ -6340,7 +7430,7 @@ async function resyncWorkspaceFromHost(opts) {
6340
7430
  }
6341
7431
  }
6342
7432
  if (hostUntracked.length > 0) {
6343
- const probe = await execa9(
7433
+ const probe = await execa10(
6344
7434
  "docker",
6345
7435
  [
6346
7436
  "exec",
@@ -6372,7 +7462,7 @@ async function resyncWorkspaceFromHost(opts) {
6372
7462
  let hostHash = "";
6373
7463
  if (boxToken !== void 0 && boxToken !== NON_REGULAR_TOKEN) {
6374
7464
  try {
6375
- hostHash = createHash22("sha256").update(await readFile52(join7(hostMain, p))).digest("hex");
7465
+ hostHash = createHash22("sha256").update(await readFile6(join8(hostMain, p))).digest("hex");
6376
7466
  } catch {
6377
7467
  identical++;
6378
7468
  continue;
@@ -6387,13 +7477,13 @@ async function resyncWorkspaceFromHost(opts) {
6387
7477
  log(`resync: ${ct}: ${String(identical)} untracked host file(s) already identical in box (no-op)`);
6388
7478
  }
6389
7479
  if (toCopy.length > 0) {
6390
- const tarOut = await execa9("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
7480
+ const tarOut = await execa10("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
6391
7481
  input: toCopy.join("\0"),
6392
7482
  encoding: "buffer",
6393
7483
  reject: false
6394
7484
  });
6395
7485
  if (tarOut.exitCode === 0) {
6396
- await execa9(
7486
+ await execa10(
6397
7487
  "docker",
6398
7488
  ["exec", "-i", "--user", "vscode", opts.container, "tar", "-C", ct, "-xf", "-"],
6399
7489
  { input: tarOut.stdout, reject: false }
@@ -6416,7 +7506,7 @@ var cached = null;
6416
7506
  async function detectPortless() {
6417
7507
  if (cached !== null) return cached;
6418
7508
  try {
6419
- const ver = await execa10(PORTLESS_BIN, SUB_VERSION, { reject: false });
7509
+ const ver = await execa11(PORTLESS_BIN, SUB_VERSION, { reject: false });
6420
7510
  if (ver.exitCode !== 0) {
6421
7511
  cached = { installed: false, proxyRunning: false };
6422
7512
  return cached;
@@ -6436,7 +7526,7 @@ function resetPortlessCache() {
6436
7526
  }
6437
7527
  async function portlessAlias(name, port) {
6438
7528
  try {
6439
- const r = await execa10(PORTLESS_BIN, [SUB_ALIAS, name, String(port)], { reject: false });
7529
+ const r = await execa11(PORTLESS_BIN, [SUB_ALIAS, name, String(port)], { reject: false });
6440
7530
  return r.exitCode === 0;
6441
7531
  } catch {
6442
7532
  return false;
@@ -6444,7 +7534,7 @@ async function portlessAlias(name, port) {
6444
7534
  }
6445
7535
  async function portlessUnalias(name) {
6446
7536
  try {
6447
- const r = await execa10(PORTLESS_BIN, [SUB_ALIAS, SUB_ALIAS_REMOVE, name], { reject: false });
7537
+ const r = await execa11(PORTLESS_BIN, [SUB_ALIAS, SUB_ALIAS_REMOVE, name], { reject: false });
6448
7538
  return r.exitCode === 0;
6449
7539
  } catch {
6450
7540
  return false;
@@ -6453,7 +7543,7 @@ async function portlessUnalias(name) {
6453
7543
  async function portlessGetUrl(name) {
6454
7544
  const fallback = `https://${name}.localhost`;
6455
7545
  try {
6456
- const r = await execa10(PORTLESS_BIN, [SUB_GET, name], { reject: false });
7546
+ const r = await execa11(PORTLESS_BIN, [SUB_GET, name], { reject: false });
6457
7547
  const out = (r.stdout ?? "").trim();
6458
7548
  if (r.exitCode === 0 && /^https?:\/\//.test(out)) return out;
6459
7549
  } catch {
@@ -6474,7 +7564,7 @@ function portlessBrowserEnv(boxName, opts) {
6474
7564
  }
6475
7565
  async function installPortless() {
6476
7566
  try {
6477
- const r = await execa10("npm", ["install", "-g", "portless"], { reject: false });
7567
+ const r = await execa11("npm", ["install", "-g", "portless"], { reject: false });
6478
7568
  return r.exitCode === 0;
6479
7569
  } catch {
6480
7570
  return false;
@@ -6482,7 +7572,7 @@ async function installPortless() {
6482
7572
  }
6483
7573
  async function startPortlessProxy() {
6484
7574
  try {
6485
- const r = await execa10(
7575
+ const r = await execa11(
6486
7576
  PORTLESS_BIN,
6487
7577
  ["proxy", "start", "--no-tls", "-p", String(PORTLESS_PROXY_PORT)],
6488
7578
  { reject: false }
@@ -6495,7 +7585,7 @@ async function startPortlessProxy() {
6495
7585
  function portlessStateDirCandidates() {
6496
7586
  const env = process.env["PORTLESS_STATE_DIR"];
6497
7587
  if (env && env.trim().length > 0) return [env.trim()];
6498
- return ["/tmp/portless", join8(homedir6(), ".portless")];
7588
+ return ["/tmp/portless", join9(homedir8(), ".portless")];
6499
7589
  }
6500
7590
  function pidAlive(pid) {
6501
7591
  if (!Number.isFinite(pid) || pid <= 0) return false;
@@ -6508,7 +7598,7 @@ function pidAlive(pid) {
6508
7598
  }
6509
7599
  async function readProxyPid(dir) {
6510
7600
  try {
6511
- const raw = await readFile6(join8(dir, "proxy.pid"), "utf8");
7601
+ const raw = await readFile7(join9(dir, "proxy.pid"), "utf8");
6512
7602
  const pid = Number.parseInt(raw.trim(), 10);
6513
7603
  return Number.isFinite(pid) && pid > 0 ? pid : null;
6514
7604
  } catch {
@@ -6528,7 +7618,7 @@ async function resolvePortlessHostStateDir(override) {
6528
7618
  if (env && env.trim().length > 0) return env.trim();
6529
7619
  const live = await findLivePortlessStateDir();
6530
7620
  if (live) return live;
6531
- const home = join8(homedir6(), ".portless");
7621
+ const home = join9(homedir8(), ".portless");
6532
7622
  if (existsSync2(home)) return home;
6533
7623
  if (existsSync2("/tmp/portless")) return "/tmp/portless";
6534
7624
  return home;
@@ -6536,7 +7626,7 @@ async function resolvePortlessHostStateDir(override) {
6536
7626
  async function isProxyRunning() {
6537
7627
  if (await findLivePortlessStateDir() !== null) return true;
6538
7628
  try {
6539
- const r = await execa10("pgrep", ["-f", "portless proxy"], { reject: false });
7629
+ const r = await execa11("pgrep", ["-f", "portless proxy"], { reject: false });
6540
7630
  return r.exitCode === 0 && (r.stdout ?? "").trim().length > 0;
6541
7631
  } catch {
6542
7632
  return false;
@@ -6557,12 +7647,12 @@ var EXCLUDE_DIRS = /* @__PURE__ */ new Set([
6557
7647
  ".cache",
6558
7648
  ".parcel-cache"
6559
7649
  ]);
6560
- var SNAPSHOTS_ROOT = join9(homedir7(), ".agentbox", "snapshots");
7650
+ var SNAPSHOTS_ROOT = join10(homedir9(), ".agentbox", "snapshots");
6561
7651
  function snapshotPathFor(box) {
6562
7652
  const mnemonic = sanitizeMnemonic(box.name);
6563
7653
  const n = box.projectIndex;
6564
7654
  const segment = typeof n === "number" && Number.isFinite(n) && n > 0 ? `${box.id}-${String(n)}-${mnemonic}` : `${box.id}-${mnemonic}`;
6565
- return join9(SNAPSHOTS_ROOT, segment);
7655
+ return join10(SNAPSHOTS_ROOT, segment);
6566
7656
  }
6567
7657
  async function findExcludedDirs(root, excluded = EXCLUDE_DIRS) {
6568
7658
  const matches = [];
@@ -6575,7 +7665,7 @@ async function findExcludedDirs(root, excluded = EXCLUDE_DIRS) {
6575
7665
  }
6576
7666
  for (const entry of entries) {
6577
7667
  if (!entry.isDirectory()) continue;
6578
- const abs = join9(dir, entry.name);
7668
+ const abs = join10(dir, entry.name);
6579
7669
  if (excluded.has(entry.name)) {
6580
7670
  matches.push(abs);
6581
7671
  continue;
@@ -6592,26 +7682,26 @@ async function createSnapshot(opts) {
6592
7682
  const excluded = opts.excluded ?? EXCLUDE_DIRS;
6593
7683
  await mkdir42(SNAPSHOTS_ROOT, { recursive: true });
6594
7684
  const cpArgs = platform() === "darwin" ? ["-cR"] : ["-R"];
6595
- await execa11("cp", [...cpArgs, `${source}/`, destination]);
7685
+ await execa12("cp", [...cpArgs, `${source}/`, destination]);
6596
7686
  const toPrune = await findExcludedDirs(destination, excluded);
6597
7687
  await Promise.all(toPrune.map((p) => rm32(p, { recursive: true, force: true })));
6598
7688
  return { destination, prunedPaths: toPrune };
6599
7689
  }
6600
- var CHECKPOINTS_ROOT = join10(homedir8(), ".agentbox", "checkpoints");
7690
+ var CHECKPOINTS_ROOT = join11(homedir10(), ".agentbox", "checkpoints");
6601
7691
  var CHECKPOINT_IMAGE_PREFIX = "agentbox-ckpt-";
6602
7692
  function checkpointImageTag(projectRoot, name) {
6603
7693
  const mnemonic = sanitizeMnemonic(basename5(projectRoot));
6604
7694
  return `${CHECKPOINT_IMAGE_PREFIX}${hashProjectPath(projectRoot)}_${mnemonic}:${name}`;
6605
7695
  }
6606
7696
  function projectCheckpointsDir(projectRoot) {
6607
- return join10(CHECKPOINTS_ROOT, projectDirSegment(projectRoot));
7697
+ return join11(CHECKPOINTS_ROOT, projectDirSegment(projectRoot));
6608
7698
  }
6609
7699
  function checkpointDir(projectRoot, name) {
6610
- return join10(projectCheckpointsDir(projectRoot), name);
7700
+ return join11(projectCheckpointsDir(projectRoot), name);
6611
7701
  }
6612
7702
  async function readManifest(dir) {
6613
7703
  try {
6614
- const raw = await readFile7(join10(dir, "manifest.json"), "utf8");
7704
+ const raw = await readFile8(join11(dir, "manifest.json"), "utf8");
6615
7705
  const m = JSON.parse(raw);
6616
7706
  if (m.schema !== 2 && m.schema !== 3) return null;
6617
7707
  return m;
@@ -6628,7 +7718,7 @@ async function listCheckpointsInDir(root) {
6628
7718
  }
6629
7719
  const out = [];
6630
7720
  for (const name of entries) {
6631
- const dir = join10(root, name);
7721
+ const dir = join11(root, name);
6632
7722
  const manifest = await readManifest(dir);
6633
7723
  if (manifest) out.push({ name, dir, manifest });
6634
7724
  }
@@ -6647,7 +7737,7 @@ async function listAllCheckpoints() {
6647
7737
  }
6648
7738
  const out = [];
6649
7739
  for (const segment of segments) {
6650
- const items = await listCheckpointsInDir(join10(CHECKPOINTS_ROOT, segment));
7740
+ const items = await listCheckpointsInDir(join11(CHECKPOINTS_ROOT, segment));
6651
7741
  if (items.length > 0) out.push({ segment, items });
6652
7742
  }
6653
7743
  return out;
@@ -6667,7 +7757,7 @@ async function listAllCheckpointImages() {
6667
7757
  }
6668
7758
  const out = /* @__PURE__ */ new Set();
6669
7759
  for (const proj of projectDirs) {
6670
- const projPath = join10(CHECKPOINTS_ROOT, proj);
7760
+ const projPath = join11(CHECKPOINTS_ROOT, proj);
6671
7761
  let names;
6672
7762
  try {
6673
7763
  names = (await readdir5(projPath, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
@@ -6675,7 +7765,7 @@ async function listAllCheckpointImages() {
6675
7765
  continue;
6676
7766
  }
6677
7767
  for (const name of names) {
6678
- const manifest = await readManifest(join10(projPath, name));
7768
+ const manifest = await readManifest(join11(projPath, name));
6679
7769
  if (manifest) out.add(manifest.image);
6680
7770
  }
6681
7771
  }
@@ -6717,7 +7807,7 @@ async function runCleanup(container, log) {
6717
7807
  }
6718
7808
  }
6719
7809
  async function inspectImageConfig(imageRef) {
6720
- const r = await execa12("docker", ["image", "inspect", imageRef], { reject: false });
7810
+ const r = await execa13("docker", ["image", "inspect", imageRef], { reject: false });
6721
7811
  if (r.exitCode !== 0) {
6722
7812
  throw new CheckpointError(`docker image inspect ${imageRef} failed`, r.stdout, r.stderr);
6723
7813
  }
@@ -6793,14 +7883,14 @@ async function createCheckpoint(opts) {
6793
7883
  await runCleanup(box.container, log);
6794
7884
  if (type === "layered") {
6795
7885
  log(`docker commit ${box.container} -> ${tag} (layered)`);
6796
- const r = await execa12("docker", ["commit", box.container, tag], { reject: false });
7886
+ const r = await execa13("docker", ["commit", box.container, tag], { reject: false });
6797
7887
  if (r.exitCode !== 0) {
6798
7888
  throw new CheckpointError(`docker commit failed for ${box.container}`, r.stdout, r.stderr);
6799
7889
  }
6800
7890
  } else {
6801
7891
  log(`docker commit ${box.container} -> <intermediate> (flattened path)`);
6802
7892
  const intermediate = `${tag}-intermediate`;
6803
- const commit = await execa12("docker", ["commit", box.container, intermediate], {
7893
+ const commit = await execa13("docker", ["commit", box.container, intermediate], {
6804
7894
  reject: false
6805
7895
  });
6806
7896
  if (commit.exitCode !== 0) {
@@ -6836,7 +7926,7 @@ async function createCheckpoint(opts) {
6836
7926
  cliVersion: stamp.cliVersion,
6837
7927
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
6838
7928
  };
6839
- await writeFile32(join10(dir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n", "utf8");
7929
+ await writeFile32(join11(dir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n", "utf8");
6840
7930
  if (opts.setDefault) {
6841
7931
  await setConfigValue("project", "box.defaultCheckpointDocker", name, opts.projectRoot);
6842
7932
  log(`set project default checkpoint (box.defaultCheckpointDocker) -> ${name}`);
@@ -6845,7 +7935,7 @@ async function createCheckpoint(opts) {
6845
7935
  }
6846
7936
  async function flattenImage(sourceTag, destTag, log) {
6847
7937
  const tmpName = `agentbox-flatten-${Date.now().toString(36)}`;
6848
- const create = await execa12(
7938
+ const create = await execa13(
6849
7939
  "docker",
6850
7940
  ["create", "--name", tmpName, sourceTag, "sleep", "0"],
6851
7941
  { reject: false }
@@ -6853,11 +7943,11 @@ async function flattenImage(sourceTag, destTag, log) {
6853
7943
  if (create.exitCode !== 0) {
6854
7944
  throw new CheckpointError(`docker create for flatten failed`, create.stdout, create.stderr);
6855
7945
  }
6856
- const scratch = await mkdtemp3(join10(tmpdir3(), "agentbox-flatten-"));
7946
+ const scratch = await mkdtemp3(join11(tmpdir3(), "agentbox-flatten-"));
6857
7947
  try {
6858
- const rootfsPath = join10(scratch, "rootfs.tar");
7948
+ const rootfsPath = join11(scratch, "rootfs.tar");
6859
7949
  log(`exporting rootfs of ${sourceTag} to ${rootfsPath}`);
6860
- const exp = await execa12("docker", ["export", "-o", rootfsPath, tmpName], { reject: false });
7950
+ const exp = await execa13("docker", ["export", "-o", rootfsPath, tmpName], { reject: false });
6861
7951
  if (exp.exitCode !== 0) {
6862
7952
  throw new CheckpointError(`docker export failed`, exp.stdout, exp.stderr);
6863
7953
  }
@@ -6868,18 +7958,18 @@ async function flattenImage(sourceTag, destTag, log) {
6868
7958
  "ADD rootfs.tar /",
6869
7959
  ...renderConfigDirectives(cfg)
6870
7960
  ];
6871
- await writeFile32(join10(scratch, "Dockerfile"), lines.join("\n") + "\n", "utf8");
7961
+ await writeFile32(join11(scratch, "Dockerfile"), lines.join("\n") + "\n", "utf8");
6872
7962
  log(`building flattened ${destTag} from rootfs.tar (FROM scratch)`);
6873
- const build = await execa12(
7963
+ const build = await execa13(
6874
7964
  "docker",
6875
- ["build", "-t", destTag, "-f", join10(scratch, "Dockerfile"), scratch],
7965
+ ["build", "-t", destTag, "-f", join11(scratch, "Dockerfile"), scratch],
6876
7966
  { reject: false }
6877
7967
  );
6878
7968
  if (build.exitCode !== 0) {
6879
7969
  throw new CheckpointError(`flatten docker build failed`, build.stdout, build.stderr);
6880
7970
  }
6881
7971
  } finally {
6882
- await execa12("docker", ["rm", "-f", tmpName], { reject: false });
7972
+ await execa13("docker", ["rm", "-f", tmpName], { reject: false });
6883
7973
  await rm4(scratch, { recursive: true, force: true });
6884
7974
  }
6885
7975
  }
@@ -6905,7 +7995,7 @@ async function launchCtlDaemon(container, hostSocketPath, timeoutMs = 3e3) {
6905
7995
  }
6906
7996
  const deadline = Date.now() + timeoutMs;
6907
7997
  while (Date.now() < deadline) {
6908
- if (await pathExists5(hostSocketPath)) return { up: true };
7998
+ if (await pathExists6(hostSocketPath)) return { up: true };
6909
7999
  await new Promise((r) => setTimeout(r, 100));
6910
8000
  }
6911
8001
  return {
@@ -6913,9 +8003,9 @@ async function launchCtlDaemon(container, hostSocketPath, timeoutMs = 3e3) {
6913
8003
  reason: `socket ${hostSocketPath} did not appear within ${String(timeoutMs)}ms`
6914
8004
  };
6915
8005
  }
6916
- async function pathExists5(p) {
8006
+ async function pathExists6(p) {
6917
8007
  try {
6918
- await stat7(p);
8008
+ await stat8(p);
6919
8009
  return true;
6920
8010
  } catch {
6921
8011
  return false;
@@ -6923,7 +8013,7 @@ async function pathExists5(p) {
6923
8013
  }
6924
8014
  async function writeBoxEnvFile(container, env) {
6925
8015
  const body = formatBoxEnvBody(env);
6926
- const result = await execa13(
8016
+ const result = await execa14(
6927
8017
  "docker",
6928
8018
  ["exec", "--user", "root", "-i", container, "sh", "-c", "umask 022 && cat > /etc/agentbox/box.env"],
6929
8019
  { input: body, reject: false }
@@ -6947,7 +8037,7 @@ function shellSingleQuote(s) {
6947
8037
  return `'${s.replace(/'/g, `'\\''`)}'`;
6948
8038
  }
6949
8039
  async function ensureHomeOwnedByVscode(container) {
6950
- await execa14(
8040
+ await execa15(
6951
8041
  "docker",
6952
8042
  [
6953
8043
  "exec",
@@ -6963,10 +8053,10 @@ async function ensureHomeOwnedByVscode(container) {
6963
8053
  { reject: false }
6964
8054
  );
6965
8055
  }
6966
- var STATE_DIR22 = join11(homedir9(), ".agentbox");
6967
- var PID_FILE = join11(STATE_DIR22, "relay.pid");
6968
- var LOG_FILE = join11(STATE_DIR22, "relay.log");
6969
- var RELAY_HOME_DIR = join11(STATE_DIR22, "relay");
8056
+ var STATE_DIR22 = join12(homedir11(), ".agentbox");
8057
+ var PID_FILE = join12(STATE_DIR22, "relay.pid");
8058
+ var LOG_FILE = join12(STATE_DIR22, "relay.log");
8059
+ var RELAY_HOME_DIR = join12(STATE_DIR22, "relay");
6970
8060
  var PORT = DEFAULT_RELAY_PORT;
6971
8061
  var ENDPOINT = {
6972
8062
  // host.docker.internal is the Docker Desktop / OrbStack-supplied alias for
@@ -7133,13 +8223,13 @@ async function stageRelayHome(version, log) {
7133
8223
  if (process.env.AGENTBOX_RELAY_BIN || process.env.AGENTBOX_CLI_ENTRY) return null;
7134
8224
  const cliRoot = findCliRoot(dirname32(fileURLToPath(import.meta.url)));
7135
8225
  if (cliRoot === null) return null;
7136
- const homeDir = join11(RELAY_HOME_DIR, version);
7137
- const stagedEntry = join11(homeDir, "dist", "index.js");
7138
- const stagedBin = join11(homeDir, "runtime", "relay", "bin.cjs");
8226
+ const homeDir = join12(RELAY_HOME_DIR, version);
8227
+ const stagedEntry = join12(homeDir, "dist", "index.js");
8228
+ const stagedBin = join12(homeDir, "runtime", "relay", "bin.cjs");
7139
8229
  if (existsSync3(stagedEntry) && existsSync3(stagedBin)) {
7140
8230
  return { relayBin: stagedBin, cliEntry: stagedEntry };
7141
8231
  }
7142
- const nodeModules = resolveDepRoot(join11(cliRoot, "dist", "index.js"));
8232
+ const nodeModules = resolveDepRoot(join12(cliRoot, "dist", "index.js"));
7143
8233
  if (nodeModules === null) return null;
7144
8234
  const tmpDir = `${homeDir}.tmp-${String(process.pid)}`;
7145
8235
  try {
@@ -7147,10 +8237,10 @@ async function stageRelayHome(version, log) {
7147
8237
  await rm5(tmpDir, { recursive: true, force: true });
7148
8238
  await mkdir6(tmpDir, { recursive: true });
7149
8239
  for (const sub of ["dist", "runtime", "share"]) {
7150
- const src = join11(cliRoot, sub);
7151
- if (existsSync3(src)) await cp(src, join11(tmpDir, sub), { recursive: true });
8240
+ const src = join12(cliRoot, sub);
8241
+ if (existsSync3(src)) await cp(src, join12(tmpDir, sub), { recursive: true });
7152
8242
  }
7153
- await cp(nodeModules, join11(tmpDir, "node_modules"), { recursive: true, dereference: true });
8243
+ await cp(nodeModules, join12(tmpDir, "node_modules"), { recursive: true, dereference: true });
7154
8244
  await rm5(homeDir, { recursive: true, force: true });
7155
8245
  await rename3(tmpDir, homeDir);
7156
8246
  } catch (err) {
@@ -7169,7 +8259,7 @@ async function stageRelayHome(version, log) {
7169
8259
  }
7170
8260
  function findCliRoot(moduleDir) {
7171
8261
  for (const root of [resolve3(moduleDir, ".."), resolve3(moduleDir, "..", "..")]) {
7172
- if (existsSync3(join11(root, "dist", "index.js")) && existsSync3(join11(root, "runtime", "relay", "bin.cjs"))) {
8262
+ if (existsSync3(join12(root, "dist", "index.js")) && existsSync3(join12(root, "runtime", "relay", "bin.cjs"))) {
7173
8263
  return root;
7174
8264
  }
7175
8265
  }
@@ -7184,7 +8274,7 @@ function resolveDepRoot(fromFile) {
7184
8274
  const idx = main.lastIndexOf(marker);
7185
8275
  if (idx === -1) return null;
7186
8276
  const nm = main.slice(0, idx + marker.length - 1);
7187
- return existsSync3(join11(nm, "commander")) ? nm : null;
8277
+ return existsSync3(join12(nm, "commander")) ? nm : null;
7188
8278
  } catch {
7189
8279
  return null;
7190
8280
  }
@@ -7198,7 +8288,7 @@ async function gcOldRelayHomes(keepVersion) {
7198
8288
  }
7199
8289
  for (const name of entries) {
7200
8290
  if (name === keepVersion) continue;
7201
- await rm5(join11(RELAY_HOME_DIR, name), { recursive: true, force: true }).catch(() => {
8291
+ await rm5(join12(RELAY_HOME_DIR, name), { recursive: true, force: true }).catch(() => {
7202
8292
  });
7203
8293
  }
7204
8294
  }
@@ -7309,7 +8399,7 @@ function fetchHealthz(timeoutMs) {
7309
8399
  }
7310
8400
  async function readPidFile() {
7311
8401
  try {
7312
- const text = await readFile8(PID_FILE, "utf8");
8402
+ const text = await readFile9(PID_FILE, "utf8");
7313
8403
  const pid = Number.parseInt(text.trim(), 10);
7314
8404
  return Number.isFinite(pid) && pid > 0 ? pid : null;
7315
8405
  } catch {
@@ -7614,8 +8704,8 @@ async function ensureAgentboxTasksFile(container, services, opts = {}) {
7614
8704
  return { status: "wrote" };
7615
8705
  }
7616
8706
  async function writeFileInBox(container, path, content) {
7617
- const { execa: execa20 } = await import("execa");
7618
- const result = await execa20(
8707
+ const { execa: execa21 } = await import("execa");
8708
+ const result = await execa21(
7619
8709
  "docker",
7620
8710
  ["exec", "-i", "--user", "vscode", container, "sh", "-c", `cat > ${shellQuote(path)}`],
7621
8711
  { input: content, reject: false }
@@ -7646,22 +8736,22 @@ function defaultBoxName(workspacePath, id) {
7646
8736
  const base = sanitizeBasename(workspacePath);
7647
8737
  return base.length > 0 ? `${base}-${id}` : id;
7648
8738
  }
7649
- async function pathExists6(p) {
8739
+ async function pathExists7(p) {
7650
8740
  try {
7651
- await stat8(p);
8741
+ await stat9(p);
7652
8742
  return true;
7653
8743
  } catch {
7654
8744
  return false;
7655
8745
  }
7656
8746
  }
7657
8747
  async function buildIdentityMounts() {
7658
- const home = homedir10();
8748
+ const home = homedir12();
7659
8749
  const candidates = [
7660
- { src: join12(home, ".gitconfig"), dst: "/home/vscode/.gitconfig", readOnly: true }
8750
+ { src: join13(home, ".gitconfig"), dst: "/home/vscode/.gitconfig", readOnly: true }
7661
8751
  ];
7662
8752
  const out = [];
7663
8753
  for (const c of candidates) {
7664
- if (await pathExists6(c.src)) {
8754
+ if (await pathExists7(c.src)) {
7665
8755
  out.push(`${c.src}:${c.dst}${c.readOnly ? ":ro" : ""}`);
7666
8756
  }
7667
8757
  }
@@ -7671,11 +8761,11 @@ async function createBox(opts) {
7671
8761
  const log = opts.onLog ?? (() => {
7672
8762
  });
7673
8763
  const workspace = resolve4(opts.workspacePath);
7674
- if (!await pathExists6(workspace)) {
8764
+ if (!await pathExists7(workspace)) {
7675
8765
  throw new Error(`workspace does not exist: ${workspace}`);
7676
8766
  }
7677
- const cfgPath = join12(workspace, "agentbox.yaml");
7678
- if (await pathExists6(cfgPath)) {
8767
+ const cfgPath = join13(workspace, "agentbox.yaml");
8768
+ if (await pathExists7(cfgPath)) {
7679
8769
  try {
7680
8770
  const cfg = await loadConfig(cfgPath);
7681
8771
  log(`agentbox.yaml validated (${String(cfg.services.length)} service(s))`);
@@ -7890,7 +8980,7 @@ async function createBox(opts) {
7890
8980
  log(`seeded claude credentials into ${claudeSpec.volume} from host backup`);
7891
8981
  }
7892
8982
  const claudeMounts = buildClaudeMounts(claudeSpec, process.env);
7893
- const wantCodex = opts.codexConfig !== void 0 || await pathExists6(join12(homedir10(), ".codex"));
8983
+ const wantCodex = opts.codexConfig !== void 0 || await pathExists7(join13(homedir12(), ".codex"));
7894
8984
  let codexMounts;
7895
8985
  let codexConfigVolume;
7896
8986
  if (wantCodex) {
@@ -7910,7 +9000,21 @@ async function createBox(opts) {
7910
9000
  codexMounts = buildCodexMounts(codexSpec, process.env);
7911
9001
  codexConfigVolume = codexSpec.volume;
7912
9002
  }
7913
- const wantOpencode = opts.opencodeConfig !== void 0 || await pathExists6(join12(homedir10(), ".config", "opencode")) || await pathExists6(join12(homedir10(), ".local", "share", "opencode"));
9003
+ let agentsMounts;
9004
+ let agentsConfigVolume;
9005
+ if (await pathExists7(join13(homedir12(), ".agents"))) {
9006
+ const agentsSpec = resolveAgentsVolume();
9007
+ const agentsEnsured = await ensureAgentsVolume(agentsSpec, {
9008
+ syncFromHost: true,
9009
+ image: ensureRef
9010
+ });
9011
+ if (agentsEnsured.synced) log(`synced ${agentsSpec.volume} from ~/.agents`);
9012
+ else if (agentsEnsured.created) log(`created empty volume ${agentsSpec.volume}`);
9013
+ else log(`reusing volume ${agentsSpec.volume}`);
9014
+ agentsMounts = buildAgentsMounts(agentsSpec);
9015
+ agentsConfigVolume = agentsSpec.volume;
9016
+ }
9017
+ const wantOpencode = opts.opencodeConfig !== void 0 || await pathExists7(join13(homedir12(), ".config", "opencode")) || await pathExists7(join13(homedir12(), ".local", "share", "opencode"));
7914
9018
  let opencodeMounts;
7915
9019
  let opencodeConfigVolume;
7916
9020
  if (wantOpencode) {
@@ -7931,14 +9035,15 @@ async function createBox(opts) {
7931
9035
  opencodeConfigVolume = opencodeSpec.volume;
7932
9036
  }
7933
9037
  const boxDir = boxRunDirFor({ id, name, projectIndex });
7934
- const socketDir = join12(boxDir, "run");
7935
- const socketPath = join12(socketDir, "ctl.sock");
7936
- const mergedExportDir = join12(boxDir, "workspace");
9038
+ const socketDir = join13(boxDir, "run");
9039
+ const socketPath = join13(socketDir, "ctl.sock");
9040
+ const mergedExportDir = join13(boxDir, "workspace");
7937
9041
  await mkdir7(socketDir, { recursive: true });
7938
9042
  await mkdir7(mergedExportDir, { recursive: true });
7939
9043
  const extraVolumes = await buildIdentityMounts();
7940
9044
  extraVolumes.push(...claudeMounts.extraVolumes);
7941
9045
  if (codexMounts) extraVolumes.push(...codexMounts.extraVolumes);
9046
+ if (agentsMounts) extraVolumes.push(...agentsMounts.extraVolumes);
7942
9047
  if (opencodeMounts) extraVolumes.push(...opencodeMounts.extraVolumes);
7943
9048
  extraVolumes.push(...ide.extraVolumes);
7944
9049
  extraVolumes.push(`${socketDir}:/run/agentbox`);
@@ -8034,6 +9139,7 @@ async function createBox(opts) {
8034
9139
  socketPath,
8035
9140
  claudeConfigVolume: claudeSpec.volume,
8036
9141
  codexConfigVolume,
9142
+ agentsConfigVolume,
8037
9143
  opencodeConfigVolume,
8038
9144
  vscodeServerVolume: vscodeServerVolumeName(id),
8039
9145
  cursorServerVolume: cursorServerVolumeName(id),
@@ -8099,7 +9205,7 @@ async function createBox(opts) {
8099
9205
  } catch (err) {
8100
9206
  if (opts.useBranch !== void 0) {
8101
9207
  log(`seedWorkspace failed for --use-branch ${opts.useBranch}; cleaning up the box`);
8102
- await execa15("docker", ["rm", "-f", containerName], { reject: false });
9208
+ await execa16("docker", ["rm", "-f", containerName], { reject: false });
8103
9209
  await removeBoxRecord(id);
8104
9210
  for (const w of gitWorktreeRecords) {
8105
9211
  await removeInBoxWorktree({
@@ -8162,7 +9268,7 @@ async function createBox(opts) {
8162
9268
  else log(`agentbox-ctl daemon did not become reachable: ${ctl.reason}`);
8163
9269
  if (opts.withPlaywright) {
8164
9270
  log("installing @playwright/cli@latest (--with-playwright)");
8165
- const result = await execa15(
9271
+ const result = await execa16(
8166
9272
  "docker",
8167
9273
  [
8168
9274
  "exec",
@@ -8341,7 +9447,7 @@ function parseShellSessionList(stdout) {
8341
9447
  return out;
8342
9448
  }
8343
9449
  async function listShellSessions(container, user) {
8344
- const res = await execa16(
9450
+ const res = await execa17(
8345
9451
  "docker",
8346
9452
  [
8347
9453
  "exec",
@@ -8365,7 +9471,7 @@ async function startShellSession(opts) {
8365
9471
  const login = opts.login !== false;
8366
9472
  const term = process.env["TERM"] ?? "xterm-256color";
8367
9473
  const cmd = login ? "bash -l" : "bash";
8368
- const result = await execa16(
9474
+ const result = await execa17(
8369
9475
  "docker",
8370
9476
  [
8371
9477
  "exec",
@@ -8414,7 +9520,7 @@ function buildShellSessionAttachArgv(container, sessionName, user) {
8414
9520
  }
8415
9521
  async function shellSessionInfo(container, sessionName, user) {
8416
9522
  const name = sessionName ?? DEFAULT_SHELL_SESSION;
8417
- const has = await execa16(
9523
+ const has = await execa17(
8418
9524
  "docker",
8419
9525
  ["exec", "--user", user ?? CONTAINER_USER, container, "tmux", "has-session", "-t", name],
8420
9526
  { reject: false }
@@ -8422,7 +9528,7 @@ async function shellSessionInfo(container, sessionName, user) {
8422
9528
  return { running: has.exitCode === 0, sessionName: name };
8423
9529
  }
8424
9530
  async function killShellSession(container, sessionName, user) {
8425
- const res = await execa16(
9531
+ const res = await execa17(
8426
9532
  "docker",
8427
9533
  [
8428
9534
  "exec",
@@ -8476,7 +9582,7 @@ async function getBoxEndpoints(record, engine, persisted) {
8476
9582
  for (const svc of persistedServices) pushService(svc.name, svc.port);
8477
9583
  } else {
8478
9584
  try {
8479
- const cfg = await loadConfig(join13(record.workspacePath, "agentbox.yaml"));
9585
+ const cfg = await loadConfig(join14(record.workspacePath, "agentbox.yaml"));
8480
9586
  if (!webServiceName) {
8481
9587
  webServiceName = cfg.services.find((s) => s.expose)?.name ?? null;
8482
9588
  }
@@ -8581,9 +9687,9 @@ function safeHost(url) {
8581
9687
  return "";
8582
9688
  }
8583
9689
  }
8584
- async function pathExists7(p) {
9690
+ async function pathExists8(p) {
8585
9691
  try {
8586
- await stat9(p);
9692
+ await stat10(p);
8587
9693
  return true;
8588
9694
  } catch {
8589
9695
  return false;
@@ -8627,9 +9733,9 @@ async function resyncBox(idOrName, onLog) {
8627
9733
  async function startBox(idOrName) {
8628
9734
  const box = await resolveBox(idOrName);
8629
9735
  for (const w of box.gitWorktrees ?? []) {
8630
- if (!await pathExists7(join14(w.hostMainRepo, ".git"))) {
9736
+ if (!await pathExists8(join15(w.hostMainRepo, ".git"))) {
8631
9737
  throw new Error(
8632
- `main repo for box worktree missing: ${join14(w.hostMainRepo, ".git")} (recreate the box)`
9738
+ `main repo for box worktree missing: ${join15(w.hostMainRepo, ".git")} (recreate the box)`
8633
9739
  );
8634
9740
  }
8635
9741
  }
@@ -8725,7 +9831,7 @@ async function getBoxHostPaths(idOrName) {
8725
9831
  }
8726
9832
  async function dirSizeBytes(path) {
8727
9833
  try {
8728
- const result = await execa17("du", ["-sk", path], { reject: false });
9834
+ const result = await execa18("du", ["-sk", path], { reject: false });
8729
9835
  if (result.exitCode !== 0) return null;
8730
9836
  const sizeKb = Number.parseInt((result.stdout ?? "").split(/\s+/)[0] ?? "", 10);
8731
9837
  if (Number.isNaN(sizeKb)) return null;
@@ -8856,7 +9962,7 @@ async function destroyBox(idOrName, opts = {}) {
8856
9962
  async function listSnapshotDirs() {
8857
9963
  try {
8858
9964
  const entries = await readdir7(SNAPSHOTS_ROOT, { withFileTypes: true });
8859
- return entries.filter((e) => e.isDirectory()).map((e) => join14(SNAPSHOTS_ROOT, e.name));
9965
+ return entries.filter((e) => e.isDirectory()).map((e) => join15(SNAPSHOTS_ROOT, e.name));
8860
9966
  } catch {
8861
9967
  return [];
8862
9968
  }
@@ -8864,13 +9970,13 @@ async function listSnapshotDirs() {
8864
9970
  async function listBoxDirs() {
8865
9971
  try {
8866
9972
  const entries = await readdir7(BOXES_ROOT, { withFileTypes: true });
8867
- return entries.filter((e) => e.isDirectory()).map((e) => join14(BOXES_ROOT, e.name));
9973
+ return entries.filter((e) => e.isDirectory()).map((e) => join15(BOXES_ROOT, e.name));
8868
9974
  } catch {
8869
9975
  return [];
8870
9976
  }
8871
9977
  }
8872
9978
  async function listCheckpointImageTags() {
8873
- const r = await execa17(
9979
+ const r = await execa18(
8874
9980
  "docker",
8875
9981
  ["image", "ls", "--format", "{{.Repository}}:{{.Tag}}", `${CHECKPOINT_IMAGE_PREFIX}*`],
8876
9982
  { reject: false }
@@ -8916,6 +10022,8 @@ async function pruneBoxes(opts = {}) {
8916
10022
  SHARED_CLAUDE_VOLUME,
8917
10023
  // The shared codex-config volume — same reasoning (holds Codex auth).
8918
10024
  SHARED_CODEX_VOLUME,
10025
+ // The shared agents-config volume — holds the cross-agent ~/.agents skills.
10026
+ SHARED_AGENTS_VOLUME,
8919
10027
  // The shared opencode-config volume — same reasoning (holds OpenCode auth).
8920
10028
  SHARED_OPENCODE_VOLUME,
8921
10029
  // Shared across boxes: downloaded IDE extensions. Same reasoning.
@@ -8978,7 +10086,7 @@ async function pruneBoxes(opts = {}) {
8978
10086
  } catch {
8979
10087
  }
8980
10088
  try {
8981
- await execa17("docker", ["image", "rm", RELAY_IMAGE_REF], { reject: false });
10089
+ await execa18("docker", ["image", "rm", RELAY_IMAGE_REF], { reject: false });
8982
10090
  } catch {
8983
10091
  }
8984
10092
  try {
@@ -8999,7 +10107,7 @@ async function pruneBoxes(opts = {}) {
8999
10107
  async function snapshotPresent(path) {
9000
10108
  if (!path) return false;
9001
10109
  try {
9002
- const s = await stat9(path);
10110
+ const s = await stat10(path);
9003
10111
  return s.isDirectory();
9004
10112
  } catch {
9005
10113
  return false;
@@ -9040,7 +10148,7 @@ function splitPair(raw) {
9040
10148
  return [parts[0].trim(), parts[1].trim()];
9041
10149
  }
9042
10150
  async function duBytes(path) {
9043
- const result = await execa18("du", ["-sk", path], { reject: false });
10151
+ const result = await execa19("du", ["-sk", path], { reject: false });
9044
10152
  if (result.exitCode !== 0) return null;
9045
10153
  const kb = Number.parseInt((result.stdout ?? "").split(/\s+/)[0] ?? "", 10);
9046
10154
  return Number.isNaN(kb) ? null : kb * 1024;
@@ -9049,11 +10157,11 @@ async function volumeSizeBytes(name) {
9049
10157
  if (!name) return null;
9050
10158
  const engine = await detectEngine();
9051
10159
  if (engine === "orbstack") {
9052
- const live = join15(homedir11(), "OrbStack", "docker", "volumes", name);
10160
+ const live = join16(homedir13(), "OrbStack", "docker", "volumes", name);
9053
10161
  const sz = await duBytes(live);
9054
10162
  if (sz !== null) return sz;
9055
10163
  }
9056
- const df = await execa18(
10164
+ const df = await execa19(
9057
10165
  "docker",
9058
10166
  ["system", "df", "-v", "--format", "{{json .Volumes}}"],
9059
10167
  { reject: false }
@@ -9074,7 +10182,7 @@ async function volumeSizeBytes(name) {
9074
10182
  return null;
9075
10183
  }
9076
10184
  async function imageBytes(tag) {
9077
- const r = await execa18("docker", ["image", "inspect", tag, "--format", "{{.Size}}"], {
10185
+ const r = await execa19("docker", ["image", "inspect", tag, "--format", "{{.Size}}"], {
9078
10186
  reject: false
9079
10187
  });
9080
10188
  if (r.exitCode !== 0) return null;
@@ -9085,7 +10193,7 @@ async function projectCheckpointImageBytes(projectRoot, name) {
9085
10193
  return imageBytes(checkpointImageTag(projectRoot, name));
9086
10194
  }
9087
10195
  async function allCheckpointImagesBytes() {
9088
- const r = await execa18(
10196
+ const r = await execa19(
9089
10197
  "docker",
9090
10198
  [
9091
10199
  "image",
@@ -9112,7 +10220,7 @@ async function allCheckpointImagesBytes() {
9112
10220
  return any ? total : null;
9113
10221
  }
9114
10222
  async function agentboxHomeBytes() {
9115
- return duBytes(join15(homedir11(), ".agentbox"));
10223
+ return duBytes(join16(homedir13(), ".agentbox"));
9116
10224
  }
9117
10225
  function limitsFromRecord(record) {
9118
10226
  const r = record.resourceLimits;
@@ -9137,7 +10245,7 @@ function reconcileLimits(persisted, dockerJson) {
9137
10245
  };
9138
10246
  }
9139
10247
  async function containerWritableBytes(container) {
9140
- const r = await execa18(
10248
+ const r = await execa19(
9141
10249
  "docker",
9142
10250
  ["ps", "-a", "--filter", `name=^${container}$`, "--format", "{{.Size}}", "--size"],
9143
10251
  { reject: false }
@@ -9184,7 +10292,7 @@ async function boxResourceStats(record) {
9184
10292
  if (await inspectContainerStatus(record.container) !== "running") {
9185
10293
  return base;
9186
10294
  }
9187
- const proc = await execa18(
10295
+ const proc = await execa19(
9188
10296
  "docker",
9189
10297
  ["stats", "--no-stream", "--format", "{{json .}}", record.container],
9190
10298
  { reject: false }
@@ -9361,9 +10469,9 @@ var dockerProvider = {
9361
10469
  var BOX_WORKFLOWS_DIR = "/home/vscode/.claude/workflows";
9362
10470
  var BOX_DYNAMIC_SYNC_MANIFEST = "/home/vscode/.agentbox/dynamic-sync.json";
9363
10471
  var BOX_MEMORY_DIR = `${BOX_CLAUDE_PROJECT_DIR}/memory`;
9364
- async function pathExists8(p) {
10472
+ async function pathExists9(p) {
9365
10473
  try {
9366
- await stat10(p);
10474
+ await stat11(p);
9367
10475
  return true;
9368
10476
  } catch {
9369
10477
  return false;
@@ -9379,14 +10487,14 @@ async function walkFiles(root, prefix = "") {
9379
10487
  const out = [];
9380
10488
  for (const ent of entries) {
9381
10489
  const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
9382
- const full = join16(root, ent.name);
10490
+ const full = join17(root, ent.name);
9383
10491
  if (ent.isDirectory()) {
9384
10492
  out.push(...await walkFiles(full, rel));
9385
10493
  } else if (ent.isFile()) {
9386
10494
  out.push(rel);
9387
10495
  } else if (ent.isSymbolicLink()) {
9388
10496
  try {
9389
- const s = await stat10(full);
10497
+ const s = await stat11(full);
9390
10498
  if (s.isFile()) out.push(rel);
9391
10499
  } catch {
9392
10500
  }
@@ -9395,7 +10503,7 @@ async function walkFiles(root, prefix = "") {
9395
10503
  return out;
9396
10504
  }
9397
10505
  async function hashFile(absPath) {
9398
- const buf = await readFile9(absPath);
10506
+ const buf = await readFile10(absPath);
9399
10507
  return createHash32("sha256").update(buf).digest("hex");
9400
10508
  }
9401
10509
  async function buildHostSet(name, hostDir, boxDst) {
@@ -9403,13 +10511,13 @@ async function buildHostSet(name, hostDir, boxDst) {
9403
10511
  const rels = await walkFiles(hostDir);
9404
10512
  const files = {};
9405
10513
  for (const rel of rels) {
9406
- files[rel] = await hashFile(join16(hostDir, rel));
10514
+ files[rel] = await hashFile(join17(hostDir, rel));
9407
10515
  }
9408
10516
  return { dst: boxDst, files, hostDir };
9409
10517
  }
9410
- async function buildHostSyncManifest(workspacePath, hostHome = homedir12()) {
9411
- const workflowsDir = join16(hostHome, ".claude", "workflows");
9412
- const workflowsHost = await pathExists8(workflowsDir) ? workflowsDir : null;
10518
+ async function buildHostSyncManifest(workspacePath, hostHome = homedir14()) {
10519
+ const workflowsDir = join17(hostHome, ".claude", "workflows");
10520
+ const workflowsHost = await pathExists9(workflowsDir) ? workflowsDir : null;
9413
10521
  const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
9414
10522
  const [workflows, memory] = await Promise.all([
9415
10523
  buildHostSet("workflows", workflowsHost, BOX_WORKFLOWS_DIR),
@@ -9430,7 +10538,7 @@ function computeSyncDelta(host, box) {
9430
10538
  uploads.push({
9431
10539
  set: name,
9432
10540
  rel,
9433
- absSrc: join16(hostSet.hostDir, rel),
10541
+ absSrc: join17(hostSet.hostDir, rel),
9434
10542
  dst: `${hostSet.dst}/${rel}`
9435
10543
  });
9436
10544
  }
@@ -9449,16 +10557,16 @@ async function stageDynamicSyncTarball(uploads) {
9449
10557
  return { tarballPath: null, cleanup: async () => {
9450
10558
  } };
9451
10559
  }
9452
- const stageDir = await mkdtemp4(join16(tmpdir4(), "agentbox-dynsync-stage-"));
10560
+ const stageDir = await mkdtemp4(join17(tmpdir4(), "agentbox-dynsync-stage-"));
9453
10561
  let tarballPath = null;
9454
10562
  try {
9455
10563
  for (const up of uploads) {
9456
- const target = join16(stageDir, up.set, up.rel);
10564
+ const target = join17(stageDir, up.set, up.rel);
9457
10565
  await mkdir8(dirname4(target), { recursive: true });
9458
10566
  await copyFile2(up.absSrc, target);
9459
10567
  }
9460
- tarballPath = join16(tmpdir4(), `agentbox-dynsync-${basename7(stageDir)}.tar.gz`);
9461
- await execa19("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
10568
+ tarballPath = join17(tmpdir4(), `agentbox-dynsync-${basename7(stageDir)}.tar.gz`);
10569
+ await execa20("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
9462
10570
  env: { ...process.env, COPYFILE_DISABLE: "1" }
9463
10571
  });
9464
10572
  const tp = tarballPath;
@@ -9576,6 +10684,8 @@ export {
9576
10684
  extractCodexCredentials,
9577
10685
  extractOpencodeCredentials,
9578
10686
  hostBackupHasCredentials,
10687
+ parseVolumeClaudeCredentials,
10688
+ volumeClaudeCredentials,
9579
10689
  parseSyncResult,
9580
10690
  syncClaudeCredentials,
9581
10691
  encodeClaudeProjectsKey,
@@ -9585,6 +10695,7 @@ export {
9585
10695
  stageClaudeStaticForUpload,
9586
10696
  stageClaudeCredentialsForUpload,
9587
10697
  stageCodexStaticForUpload,
10698
+ stageAgentsStaticForUpload,
9588
10699
  stageCodexCredentialsForUpload,
9589
10700
  stageOpencodeStaticForUpload,
9590
10701
  stageOpencodeCredentialsForUpload,
@@ -9630,6 +10741,10 @@ export {
9630
10741
  volumeHasCodexAuth,
9631
10742
  codexSessionInfo,
9632
10743
  pullCodexConfig,
10744
+ SHARED_AGENTS_VOLUME,
10745
+ resolveAgentsVolume,
10746
+ ensureAgentsVolume,
10747
+ buildAgentsMounts,
9633
10748
  SHARED_OPENCODE_VOLUME,
9634
10749
  DEFAULT_OPENCODE_SESSION,
9635
10750
  resolveOpencodeVolume,
@@ -9755,4 +10870,43 @@ export {
9755
10870
  browserSessionActive,
9756
10871
  ensureBoxBrowser
9757
10872
  };
9758
- //# sourceMappingURL=chunk-U7IZS2ZP.js.map
10873
+ /*! Bundled license information:
10874
+
10875
+ smol-toml/dist/date.js:
10876
+ smol-toml/dist/error.js:
10877
+ smol-toml/dist/primitive.js:
10878
+ smol-toml/dist/util.js:
10879
+ smol-toml/dist/extract.js:
10880
+ smol-toml/dist/struct.js:
10881
+ smol-toml/dist/parse.js:
10882
+ smol-toml/dist/stringify.js:
10883
+ smol-toml/dist/index.js:
10884
+ (*!
10885
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
10886
+ * SPDX-License-Identifier: BSD-3-Clause
10887
+ *
10888
+ * Redistribution and use in source and binary forms, with or without
10889
+ * modification, are permitted provided that the following conditions are met:
10890
+ *
10891
+ * 1. Redistributions of source code must retain the above copyright notice, this
10892
+ * list of conditions and the following disclaimer.
10893
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
10894
+ * this list of conditions and the following disclaimer in the
10895
+ * documentation and/or other materials provided with the distribution.
10896
+ * 3. Neither the name of the copyright holder nor the names of its contributors
10897
+ * may be used to endorse or promote products derived from this software without
10898
+ * specific prior written permission.
10899
+ *
10900
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
10901
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10902
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10903
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
10904
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10905
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
10906
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
10907
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
10908
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
10909
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10910
+ *)
10911
+ */
10912
+ //# sourceMappingURL=chunk-3VFY3N4A.js.map