@madarco/agentbox 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/dist/{_cloud-attach-MH7NKIZY.js → _cloud-attach-U3QJO7IF.js} +4 -4
- package/dist/{chunk-52LKNUY7.js → chunk-6JJIKCMY.js} +2 -2
- package/dist/{chunk-P6UT5XGE.js → chunk-DBMLOY3T.js} +11 -3
- package/dist/{chunk-P6UT5XGE.js.map → chunk-DBMLOY3T.js.map} +1 -1
- package/dist/{chunk-NXX3KQZ6.js → chunk-IXQTUXWV.js} +2 -2
- package/dist/{chunk-MODNW54N.js → chunk-KTEDFUKM.js} +2 -2
- package/dist/{chunk-4ATVA3RM.js → chunk-PX7G4PSI.js} +78 -23
- package/dist/chunk-PX7G4PSI.js.map +1 -0
- package/dist/{chunk-3465NDRZ.js → chunk-QKL7PCXQ.js} +127 -11
- package/dist/chunk-QKL7PCXQ.js.map +1 -0
- package/dist/{chunk-7K2A3NLE.js → chunk-X2DWS4KS.js} +14 -6
- package/dist/chunk-X2DWS4KS.js.map +1 -0
- package/dist/{chunk-5N7GA2X7.js → chunk-YZVFGFYQ.js} +263 -881
- package/dist/chunk-YZVFGFYQ.js.map +1 -0
- package/dist/{dist-G5PDFWKH.js → dist-FMA5Y25B.js} +5 -5
- package/dist/{dist-T3JIYHCA.js → dist-NWKOEWUJ.js} +120 -26
- package/dist/dist-NWKOEWUJ.js.map +1 -0
- package/dist/{dist-AJWL4WLW.js → dist-SAS4PIHA.js} +13 -3
- package/dist/{dist-CTTTHG6U.js → dist-U76JL6HI.js} +5 -5
- package/dist/{dist-LUEH7MER.js → dist-UVQJ2BZJ.js} +5 -5
- package/dist/index.js +1236 -561
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js → prepared-state-MQHD3M5F-YYVVMTNJ.js} +2 -2
- package/package.json +6 -5
- package/runtime/daytona/custom-system-CLAUDE.md +13 -3
- package/runtime/docker/Dockerfile.box +44 -10
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +6 -5
- package/runtime/docker/packages/ctl/dist/bin.cjs +324 -109
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +82 -0
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +12 -3
- package/runtime/e2b/agentbox-setup-skill.md +6 -5
- package/runtime/e2b/ctl.cjs +324 -109
- package/runtime/e2b/custom-system-CLAUDE.md +12 -3
- package/runtime/e2b/scripts/build-template.sh +44 -2
- package/runtime/hetzner/agentbox-portless-trust +82 -0
- package/runtime/hetzner/agentbox-setup-skill.md +6 -5
- package/runtime/hetzner/ctl.cjs +324 -109
- package/runtime/hetzner/custom-system-CLAUDE.md +12 -3
- package/runtime/hetzner/scripts/install-box.sh +51 -7
- package/runtime/relay/bin.cjs +187 -43
- package/runtime/vercel/agentbox-setup-skill.md +6 -5
- package/runtime/vercel/ctl.cjs +324 -109
- package/runtime/vercel/custom-system-CLAUDE.md +12 -3
- package/runtime/vercel/scripts/provision.sh +44 -2
- package/share/agentbox-setup/SKILL.md +6 -5
- package/share/host-skills/agentbox/SKILL.md +14 -0
- package/share/host-skills/agentbox-info/SKILL.md +30 -1
- package/dist/chunk-3465NDRZ.js.map +0 -1
- package/dist/chunk-4ATVA3RM.js.map +0 -1
- package/dist/chunk-5N7GA2X7.js.map +0 -1
- package/dist/chunk-7K2A3NLE.js.map +0 -1
- package/dist/dist-T3JIYHCA.js.map +0 -1
- /package/dist/{_cloud-attach-MH7NKIZY.js.map → _cloud-attach-U3QJO7IF.js.map} +0 -0
- /package/dist/{chunk-52LKNUY7.js.map → chunk-6JJIKCMY.js.map} +0 -0
- /package/dist/{chunk-NXX3KQZ6.js.map → chunk-IXQTUXWV.js.map} +0 -0
- /package/dist/{chunk-MODNW54N.js.map → chunk-KTEDFUKM.js.map} +0 -0
- /package/dist/{dist-G5PDFWKH.js.map → dist-FMA5Y25B.js.map} +0 -0
- /package/dist/{dist-AJWL4WLW.js.map → dist-SAS4PIHA.js.map} +0 -0
- /package/dist/{dist-CTTTHG6U.js.map → dist-U76JL6HI.js.map} +0 -0
- /package/dist/{dist-LUEH7MER.js.map → dist-UVQJ2BZJ.js.map} +0 -0
- /package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js.map → prepared-state-MQHD3M5F-YYVVMTNJ.js.map} +0 -0
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
removeBoxRecord,
|
|
27
27
|
renderCarryEntries,
|
|
28
28
|
reserveProjectIndex
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-X2DWS4KS.js";
|
|
30
30
|
|
|
31
31
|
// ../../packages/sandbox-docker/dist/index.js
|
|
32
32
|
import { mkdir as mkdir7, stat as stat9 } from "fs/promises";
|
|
@@ -2077,829 +2077,7 @@ import { chmod, mkdir as mkdir22, readFile as readFile23 } from "fs/promises";
|
|
|
2077
2077
|
import { basename as basename32, join as join22 } from "path";
|
|
2078
2078
|
import { execa as execa4 } from "execa";
|
|
2079
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
|
|
2080
|
+
import { parse, stringify } from "smol-toml";
|
|
2903
2081
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
2904
2082
|
import { readFile as readFile52, stat as stat42 } from "fs/promises";
|
|
2905
2083
|
import { homedir as homedir5 } from "os";
|
|
@@ -3852,6 +3030,7 @@ async function listAgentboxVolumes() {
|
|
|
3852
3030
|
if (result.exitCode !== 0) return [];
|
|
3853
3031
|
return (result.stdout ?? "").split("\n").map((s) => s.trim()).filter((s) => s.startsWith(AGENTBOX_PREFIX));
|
|
3854
3032
|
}
|
|
3033
|
+
var BOX_HOME = "/home/vscode";
|
|
3855
3034
|
function posixDirname(p) {
|
|
3856
3035
|
return posix.dirname(p) || "/";
|
|
3857
3036
|
}
|
|
@@ -3880,7 +3059,7 @@ async function streamTarPipe(producerFile, producerArgs, consumerFile, consumerA
|
|
|
3880
3059
|
{ exitCode: c.exitCode, stderr: c.stderr }
|
|
3881
3060
|
];
|
|
3882
3061
|
}
|
|
3883
|
-
async function
|
|
3062
|
+
async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
3884
3063
|
const srcAbs = resolve2(hostSrc);
|
|
3885
3064
|
if (!existsSync(srcAbs)) throw new Error(`source not found: ${hostSrc}`);
|
|
3886
3065
|
const srcBasename = basename3(srcAbs);
|
|
@@ -3950,9 +3129,33 @@ async function uploadToBox(box, hostSrc, boxDst, exclude) {
|
|
|
3950
3129
|
warn: `chown ${finalPath} to vscode (uid 1000) failed; ownership inside the box may be root.`
|
|
3951
3130
|
};
|
|
3952
3131
|
}
|
|
3132
|
+
if (finalPath.startsWith(BOX_HOME + "/")) {
|
|
3133
|
+
const walk = await execa22(
|
|
3134
|
+
"docker",
|
|
3135
|
+
[
|
|
3136
|
+
"exec",
|
|
3137
|
+
"--user",
|
|
3138
|
+
"root",
|
|
3139
|
+
box.container,
|
|
3140
|
+
"sh",
|
|
3141
|
+
"-c",
|
|
3142
|
+
`parent=$(dirname "$1"); while [ "$parent" != "$2" ] && [ "$parent" != "/" ]; do chown 1000:1000 "$parent" || true; parent=$(dirname "$parent"); done`,
|
|
3143
|
+
"sh",
|
|
3144
|
+
finalPath,
|
|
3145
|
+
BOX_HOME
|
|
3146
|
+
],
|
|
3147
|
+
{ reject: false }
|
|
3148
|
+
);
|
|
3149
|
+
if (walk.exitCode !== 0) {
|
|
3150
|
+
return {
|
|
3151
|
+
finalPath,
|
|
3152
|
+
warn: `chown of parent dirs under ${BOX_HOME} failed; some may remain root-owned.`
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3953
3156
|
return { finalPath };
|
|
3954
3157
|
}
|
|
3955
|
-
async function
|
|
3158
|
+
async function downloadOneFromBox(box, boxSrc, hostDst, exclude) {
|
|
3956
3159
|
const srcBasename = posix.basename(boxSrc);
|
|
3957
3160
|
const srcParent = posixDirname(boxSrc);
|
|
3958
3161
|
const dstAbs = resolve2(hostDst);
|
|
@@ -3985,6 +3188,119 @@ async function downloadFromBox(box, boxSrc, hostDst, exclude) {
|
|
|
3985
3188
|
}
|
|
3986
3189
|
return { finalPath };
|
|
3987
3190
|
}
|
|
3191
|
+
async function boxIsDir(container, p) {
|
|
3192
|
+
const r = await execa22("docker", ["exec", container, "test", "-d", p], { reject: false });
|
|
3193
|
+
return r.exitCode === 0;
|
|
3194
|
+
}
|
|
3195
|
+
async function resolveBoxDestDir(box, boxDst) {
|
|
3196
|
+
if (boxDst.endsWith("/")) return boxDst.replace(/\/+$/, "") || "/";
|
|
3197
|
+
if (await boxIsDir(box.container, boxDst)) return boxDst.replace(/\/+$/, "") || "/";
|
|
3198
|
+
throw new Error(
|
|
3199
|
+
`cannot copy multiple sources to '${boxDst}': destination is not a directory (add a trailing slash, e.g. ${boxDst}/)`
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
function groupByParent(paths, dir, base) {
|
|
3203
|
+
const groups = /* @__PURE__ */ new Map();
|
|
3204
|
+
for (const p of paths) {
|
|
3205
|
+
const parent = dir(p);
|
|
3206
|
+
const arr = groups.get(parent);
|
|
3207
|
+
if (arr) arr.push(base(p));
|
|
3208
|
+
else groups.set(parent, [base(p)]);
|
|
3209
|
+
}
|
|
3210
|
+
return groups;
|
|
3211
|
+
}
|
|
3212
|
+
async function uploadToBox(box, hostSrcs, boxDst, exclude) {
|
|
3213
|
+
if (hostSrcs.length === 1) return uploadOneToBox(box, hostSrcs[0], boxDst, exclude);
|
|
3214
|
+
const absSrcs = hostSrcs.map((s) => {
|
|
3215
|
+
const a = resolve2(s);
|
|
3216
|
+
if (!existsSync(a)) throw new Error(`source not found: ${s}`);
|
|
3217
|
+
return a;
|
|
3218
|
+
});
|
|
3219
|
+
const boxDir = await resolveBoxDestDir(box, boxDst);
|
|
3220
|
+
const mk = await execa22(
|
|
3221
|
+
"docker",
|
|
3222
|
+
["exec", "--user", "root", box.container, "mkdir", "-p", boxDir],
|
|
3223
|
+
{ reject: false }
|
|
3224
|
+
);
|
|
3225
|
+
if (mk.exitCode !== 0) {
|
|
3226
|
+
throw new Error(`mkdir -p ${boxDir} in box failed: ${asText(mk.stderr).slice(0, 300)}`);
|
|
3227
|
+
}
|
|
3228
|
+
for (const [parent, basenames] of groupByParent(absSrcs, dirname3, basename3)) {
|
|
3229
|
+
const [packed, extracted] = await streamTarPipe(
|
|
3230
|
+
"tar",
|
|
3231
|
+
["-C", parent, "-cf", "-", ...tarExcludeArgs(exclude), ...basenames],
|
|
3232
|
+
"docker",
|
|
3233
|
+
["exec", "-i", "--user", "root", box.container, "tar", "-xf", "-", "-C", boxDir],
|
|
3234
|
+
{ ...process.env, COPYFILE_DISABLE: "1" }
|
|
3235
|
+
);
|
|
3236
|
+
if (packed.exitCode !== 0) {
|
|
3237
|
+
throw new Error(`tar pack failed for ${parent}: ${asText(packed.stderr).slice(0, 300)}`);
|
|
3238
|
+
}
|
|
3239
|
+
if (extracted.exitCode !== 0) {
|
|
3240
|
+
throw new Error(`tar extract in box failed: ${asText(extracted.stderr).slice(0, 300)}`);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
let warn;
|
|
3244
|
+
for (const a of absSrcs) {
|
|
3245
|
+
const landed = boxDir === "/" ? `/${basename3(a)}` : `${boxDir}/${basename3(a)}`;
|
|
3246
|
+
const chown = await execa22(
|
|
3247
|
+
"docker",
|
|
3248
|
+
["exec", "--user", "root", box.container, "chown", "-R", "1000:1000", landed],
|
|
3249
|
+
{ reject: false }
|
|
3250
|
+
);
|
|
3251
|
+
if (chown.exitCode !== 0) {
|
|
3252
|
+
warn = `chown under ${boxDir} to vscode (uid 1000) failed; ownership inside the box may be root.`;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
if (boxDir.startsWith(BOX_HOME + "/")) {
|
|
3256
|
+
const walk = await execa22(
|
|
3257
|
+
"docker",
|
|
3258
|
+
[
|
|
3259
|
+
"exec",
|
|
3260
|
+
"--user",
|
|
3261
|
+
"root",
|
|
3262
|
+
box.container,
|
|
3263
|
+
"sh",
|
|
3264
|
+
"-c",
|
|
3265
|
+
`parent="$1"; while [ "$parent" != "$2" ] && [ "$parent" != "/" ]; do chown 1000:1000 "$parent" || true; parent=$(dirname "$parent"); done`,
|
|
3266
|
+
"sh",
|
|
3267
|
+
boxDir,
|
|
3268
|
+
BOX_HOME
|
|
3269
|
+
],
|
|
3270
|
+
{ reject: false }
|
|
3271
|
+
);
|
|
3272
|
+
if (walk.exitCode !== 0) {
|
|
3273
|
+
warn = warn ?? `chown of parent dirs under ${BOX_HOME} failed; some may remain root-owned.`;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
return warn ? { finalPath: `${boxDir}/`, warn } : { finalPath: `${boxDir}/` };
|
|
3277
|
+
}
|
|
3278
|
+
async function downloadFromBox(box, boxSrcs, hostDst, exclude) {
|
|
3279
|
+
if (boxSrcs.length === 1) return downloadOneFromBox(box, boxSrcs[0], hostDst, exclude);
|
|
3280
|
+
const dstAbs = resolve2(hostDst);
|
|
3281
|
+
const dstExists = existsSync(dstAbs);
|
|
3282
|
+
if (!hostDst.endsWith("/") && !(dstExists && statSync(dstAbs).isDirectory())) {
|
|
3283
|
+
throw new Error(
|
|
3284
|
+
`cannot copy multiple sources to '${hostDst}': destination is not a directory (add a trailing slash, e.g. ${hostDst}/)`
|
|
3285
|
+
);
|
|
3286
|
+
}
|
|
3287
|
+
mkdirSync(dstAbs, { recursive: true });
|
|
3288
|
+
for (const [parent, basenames] of groupByParent(boxSrcs, posixDirname, posix.basename)) {
|
|
3289
|
+
const [packed, extracted] = await streamTarPipe(
|
|
3290
|
+
"docker",
|
|
3291
|
+
["exec", box.container, "tar", "-C", parent, "-cf", "-", ...tarExcludeArgs(exclude), ...basenames],
|
|
3292
|
+
"tar",
|
|
3293
|
+
["-xf", "-", "-C", dstAbs]
|
|
3294
|
+
);
|
|
3295
|
+
if (packed.exitCode !== 0) {
|
|
3296
|
+
throw new Error(`tar pack in box failed for ${parent}: ${asText(packed.stderr).slice(0, 300)}`);
|
|
3297
|
+
}
|
|
3298
|
+
if (extracted.exitCode !== 0) {
|
|
3299
|
+
throw new Error(`tar extract on host failed: ${asText(extracted.stderr).slice(0, 300)}`);
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
return { finalPath: dstAbs };
|
|
3303
|
+
}
|
|
3988
3304
|
var CONTAINER_EXPORT_MERGED = "/host-export";
|
|
3989
3305
|
var cachedEngine = null;
|
|
3990
3306
|
async function detectEngine() {
|
|
@@ -4428,10 +3744,10 @@ async function copyCarryPathsToBox(opts) {
|
|
|
4428
3744
|
}
|
|
4429
3745
|
return { copied, errors, applied };
|
|
4430
3746
|
}
|
|
4431
|
-
var
|
|
3747
|
+
var BOX_HOME2 = "/home/vscode";
|
|
4432
3748
|
async function copyOneEntry(container, entry) {
|
|
4433
3749
|
if (entry.kind === "missing") return;
|
|
4434
|
-
const boxDest = entry.absDest.startsWith("~/") ? `${
|
|
3750
|
+
const boxDest = entry.absDest.startsWith("~/") ? `${BOX_HOME2}/${entry.absDest.slice(2)}` : entry.absDest;
|
|
4435
3751
|
const boxDestParent = boxDest.endsWith("/") ? boxDest.slice(0, -1) : boxDest;
|
|
4436
3752
|
const parentDir = entry.kind === "dir" ? boxDestParent : dirnameUnix(boxDestParent);
|
|
4437
3753
|
const mkdir9 = await execa3(
|
|
@@ -4531,9 +3847,9 @@ async function copyOneEntry(container, entry) {
|
|
|
4531
3847
|
if (chown.exitCode !== 0) {
|
|
4532
3848
|
throw new Error(`chown failed: ${String(chown.stderr).slice(0, 300)}`);
|
|
4533
3849
|
}
|
|
4534
|
-
if (boxDest.startsWith(
|
|
3850
|
+
if (boxDest.startsWith(BOX_HOME2 + "/") && dirnameUnix(boxDest) !== BOX_HOME2) {
|
|
4535
3851
|
const safeDest = boxDest.replace(/'/g, `'\\''`);
|
|
4536
|
-
const script = `set -e; parent="$(dirname '${safeDest}')"; while [ "$parent" != "${
|
|
3852
|
+
const script = `set -e; parent="$(dirname '${safeDest}')"; while [ "$parent" != "${BOX_HOME2}" ] && [ "$parent" != "/" ]; do chown ${String(uid)}:${String(uid)} "$parent"; parent="$(dirname "$parent")"; done`;
|
|
4537
3853
|
const chownParents = await execa3(
|
|
4538
3854
|
"docker",
|
|
4539
3855
|
["exec", "--user", "0:0", container, "bash", "-c", script],
|
|
@@ -5046,7 +4362,21 @@ var CODEX_RSYNC_EXCLUDES = [
|
|
|
5046
4362
|
"--exclude=session_index.jsonl",
|
|
5047
4363
|
"--exclude=models_cache.json",
|
|
5048
4364
|
"--exclude=installation_id",
|
|
5049
|
-
"--exclude=version.json"
|
|
4365
|
+
"--exclude=version.json",
|
|
4366
|
+
// Heavy host-only artifacts that are useless inside a Linux box and balloon
|
|
4367
|
+
// the staged tarball (~800 MB on a real host) — without these the codex
|
|
4368
|
+
// static scp/extract during prepare crawls. `packages/standalone` is the
|
|
4369
|
+
// macOS aarch64 standalone release binaries (the in-box codex is npm-installed
|
|
4370
|
+
// anyway); `plugins/.plugin-appserver` is the platform-specific plugin
|
|
4371
|
+
// app-server runtime; `computer-use` is the macOS `Codex Computer Use.app`
|
|
4372
|
+
// bundle. `archived_sessions` is host session history, not config (mirrors the
|
|
4373
|
+
// `sessions` exclude). (`plugins/cache`, the marketplace download cache, is
|
|
4374
|
+
// already dropped by the generic `--exclude=cache` above.) This shrinks the
|
|
4375
|
+
// staged codex tarball from ~800 MB to ~0.5 MB.
|
|
4376
|
+
"--exclude=packages",
|
|
4377
|
+
"--exclude=plugins/.plugin-appserver",
|
|
4378
|
+
"--exclude=computer-use",
|
|
4379
|
+
"--exclude=archived_sessions"
|
|
5050
4380
|
];
|
|
5051
4381
|
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
4382
|
async function sanitizeStagedCodexConfig(configPath, hostHome) {
|
|
@@ -6142,6 +5472,40 @@ var SHARED_CODEX_VOLUME = "agentbox-codex-config";
|
|
|
6142
5472
|
var DEFAULT_CODEX_SESSION = "codex";
|
|
6143
5473
|
var CONTAINER_CODEX_DIR = "/home/vscode/.codex";
|
|
6144
5474
|
var IN_BOX_CODEX_HOOKS_PATH = "/usr/local/share/agentbox/codex-hooks.json";
|
|
5475
|
+
var BOX_SYSTEM_PROMPT_PATH = "/etc/claude-code/CLAUDE.md";
|
|
5476
|
+
var CODEX_OVERRIDE_SENTINEL = "<!-- agentbox:box-facts (generated; edit AGENTS.md instead) -->";
|
|
5477
|
+
var CODEX_OVERRIDE_WROTE_MARKER = "agentbox:codex-override-written";
|
|
5478
|
+
function buildCodexAgentsOverrideScript(codexHome) {
|
|
5479
|
+
return [
|
|
5480
|
+
"set -e",
|
|
5481
|
+
`BOX=${BOX_SYSTEM_PROMPT_PATH}`,
|
|
5482
|
+
'[ -f "$BOX" ] || exit 0',
|
|
5483
|
+
`DIR=${codexHome}`,
|
|
5484
|
+
'OVR="$DIR/AGENTS.override.md"',
|
|
5485
|
+
'AGT="$DIR/AGENTS.md"',
|
|
5486
|
+
`SENTINEL='${CODEX_OVERRIDE_SENTINEL}'`,
|
|
5487
|
+
'UC=""',
|
|
5488
|
+
'if [ -f "$OVR" ] && ! head -n1 "$OVR" | grep -qF "$SENTINEL"; then',
|
|
5489
|
+
' UC=$(cat "$OVR")',
|
|
5490
|
+
'elif [ -f "$AGT" ]; then',
|
|
5491
|
+
' UC=$(cat "$AGT")',
|
|
5492
|
+
"fi",
|
|
5493
|
+
'mkdir -p "$DIR"',
|
|
5494
|
+
'TMP="$OVR.agentbox.tmp"',
|
|
5495
|
+
"{",
|
|
5496
|
+
` printf '%s\\n' "$SENTINEL"`,
|
|
5497
|
+
' cat "$BOX"',
|
|
5498
|
+
' if [ -n "$UC" ]; then',
|
|
5499
|
+
" printf '\\n\\n'",
|
|
5500
|
+
` printf '%s\\n' "$UC"`,
|
|
5501
|
+
" fi",
|
|
5502
|
+
'} > "$TMP"',
|
|
5503
|
+
'mv "$TMP" "$OVR"',
|
|
5504
|
+
// Printed only on a real write; the early `exit 0` (box facts absent) skips
|
|
5505
|
+
// it, so callers can distinguish "wrote" from "no-op" on a 0 exit.
|
|
5506
|
+
`printf '%s\\n' '${CODEX_OVERRIDE_WROTE_MARKER}'`
|
|
5507
|
+
].join("\n");
|
|
5508
|
+
}
|
|
6145
5509
|
function resolveCodexVolume(opts) {
|
|
6146
5510
|
if (opts.isolate) {
|
|
6147
5511
|
return { volume: `${SHARED_CODEX_VOLUME}-${opts.boxId}` };
|
|
@@ -6189,12 +5553,20 @@ async function ensureCodexVolume(spec, opts) {
|
|
|
6189
5553
|
// resumes at /workspace (Codex reads the cwd from state_*.sqlite's threads
|
|
6190
5554
|
// index, which it backfills from the box's rollouts) and the host's
|
|
6191
5555
|
// cross-project Codex history doesn't leak into the box.
|
|
6192
|
-
// The trailing `rm -rf` purges
|
|
5556
|
+
// The trailing `rm -rf` purges anything a PREVIOUS sync (before these
|
|
6193
5557
|
// excludes) already copied into the shared volume — rsync without
|
|
6194
5558
|
// --delete only adds/updates. The globs are no-ops with `-f` when absent,
|
|
6195
5559
|
// and never touch box-owned `sessions/` (the teleported rollouts) or
|
|
6196
5560
|
// `hooks.json`.
|
|
6197
|
-
|
|
5561
|
+
// Heavy host-only artifacts are also excluded (mirrors CODEX_RSYNC_EXCLUDES
|
|
5562
|
+
// in host-stage.ts): `packages` (macOS standalone release binaries — the
|
|
5563
|
+
// in-box codex is npm-installed), `plugins/.plugin-appserver` (the
|
|
5564
|
+
// platform-specific plugin app-server runtime), `computer-use` (the macOS
|
|
5565
|
+
// `Codex Computer Use.app` bundle), `archived_sessions` (host history), and
|
|
5566
|
+
// the regenerable caches (`.tmp`, `tmp`, `cache`, `vendor_imports`,
|
|
5567
|
+
// `sqlite`, `models_cache.json`). Without these the shared volume balloons
|
|
5568
|
+
// to ~1.5 GB and every create's rsync crawls.
|
|
5569
|
+
"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 --exclude=packages --exclude=plugins/.plugin-appserver --exclude=computer-use --exclude=archived_sessions --exclude=.tmp --exclude=tmp --exclude=cache --exclude=vendor_imports --exclude=sqlite --exclude=models_cache.json /src/ /dst/ && rm -rf /dst/state_*.sqlite* /dst/logs_*.sqlite* /dst/session_index.jsonl /dst/external_agent_session_imports.json /dst/shell_snapshots /dst/packages /dst/plugins/.plugin-appserver /dst/computer-use /dst/archived_sessions /dst/.tmp /dst/tmp /dst/cache /dst/vendor_imports /dst/sqlite /dst/models_cache.json" + skillsPurge + " && chown -R 1000:1000 /dst"
|
|
6198
5570
|
]);
|
|
6199
5571
|
await sanitizeVolumeCodexConfig(spec.volume, opts.image);
|
|
6200
5572
|
return { created, synced: true };
|
|
@@ -6239,6 +5611,25 @@ async function seedCodexHooks(volume, image) {
|
|
|
6239
5611
|
return { seeded: false };
|
|
6240
5612
|
}
|
|
6241
5613
|
}
|
|
5614
|
+
async function seedCodexAgentsOverride(volume, image) {
|
|
5615
|
+
try {
|
|
5616
|
+
const { stdout } = await execa7("docker", [
|
|
5617
|
+
"run",
|
|
5618
|
+
"--rm",
|
|
5619
|
+
"--user",
|
|
5620
|
+
"0",
|
|
5621
|
+
"-v",
|
|
5622
|
+
`${volume}:/dst`,
|
|
5623
|
+
image,
|
|
5624
|
+
"sh",
|
|
5625
|
+
"-c",
|
|
5626
|
+
buildCodexAgentsOverrideScript("/dst") + '\nchown 1000:1000 "$OVR" 2>/dev/null || true'
|
|
5627
|
+
]);
|
|
5628
|
+
return { seeded: stdout.includes(CODEX_OVERRIDE_WROTE_MARKER) };
|
|
5629
|
+
} catch {
|
|
5630
|
+
return { seeded: false };
|
|
5631
|
+
}
|
|
5632
|
+
}
|
|
6242
5633
|
async function sanitizeVolumeCodexConfig(volume, image) {
|
|
6243
5634
|
try {
|
|
6244
5635
|
const hostConfig = join52(homedir5(), ".codex", "config.toml");
|
|
@@ -7974,7 +7365,8 @@ var CheckpointError = class extends Error {
|
|
|
7974
7365
|
};
|
|
7975
7366
|
var CTL_DAEMON_LOG = "/var/log/agentbox/ctl-daemon.log";
|
|
7976
7367
|
async function launchCtlDaemon(container, hostSocketPath, timeoutMs = 3e3) {
|
|
7977
|
-
const
|
|
7368
|
+
const logDir = CTL_DAEMON_LOG.replace(/\/[^/]*$/, "");
|
|
7369
|
+
const wrapped = `mkdir -p ${logDir} && { pgrep -f 'agentbox-ctl daemon$' >/dev/null 2>&1 && exit 0; }; exec agentbox-ctl daemon >>${CTL_DAEMON_LOG} 2>&1`;
|
|
7978
7370
|
const result = await execInBox(container, ["sh", "-c", wrapped], {
|
|
7979
7371
|
user: "vscode",
|
|
7980
7372
|
detach: true
|
|
@@ -8733,6 +8125,16 @@ async function pathExists7(p) {
|
|
|
8733
8125
|
return false;
|
|
8734
8126
|
}
|
|
8735
8127
|
}
|
|
8128
|
+
async function trustInBoxPortlessCa(container, log) {
|
|
8129
|
+
const script = "agentbox-portless-trust /home/vscode/.portless/ca.pem >/dev/null 2>&1 || true; echo 'export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/agentbox-portless-ca.crt' > /etc/profile.d/agentbox-portless-ca.sh 2>/dev/null || true";
|
|
8130
|
+
const r = await execa16(
|
|
8131
|
+
"docker",
|
|
8132
|
+
["exec", "--user", "root", container, "bash", "-lc", script],
|
|
8133
|
+
{ reject: false }
|
|
8134
|
+
);
|
|
8135
|
+
if (r.exitCode === 0) log("portless: trusted host CA in box (system store + NSS)");
|
|
8136
|
+
else log("portless: in-box CA trust failed (best-effort) \u2014 in-box https may warn");
|
|
8137
|
+
}
|
|
8736
8138
|
async function buildIdentityMounts() {
|
|
8737
8139
|
const home = homedir12();
|
|
8738
8140
|
const candidates = [
|
|
@@ -8986,6 +8388,8 @@ async function createBox(opts) {
|
|
|
8986
8388
|
else log(`reusing volume ${codexSpec.volume}`);
|
|
8987
8389
|
const codexHooks = await seedCodexHooks(codexSpec.volume, ensureRef);
|
|
8988
8390
|
if (codexHooks.seeded) log(`seeded Codex activity hooks into ${codexSpec.volume}`);
|
|
8391
|
+
const codexOverride = await seedCodexAgentsOverride(codexSpec.volume, ensureRef);
|
|
8392
|
+
if (codexOverride.seeded) log(`seeded Codex AGENTS.override.md into ${codexSpec.volume}`);
|
|
8989
8393
|
codexMounts = buildCodexMounts(codexSpec, process.env);
|
|
8990
8394
|
codexConfigVolume = codexSpec.volume;
|
|
8991
8395
|
}
|
|
@@ -9354,6 +8758,9 @@ async function createBox(opts) {
|
|
|
9354
8758
|
portlessAliasName = name;
|
|
9355
8759
|
portlessUrl = await portlessGetUrl(name);
|
|
9356
8760
|
log(`portless alias ${portlessUrl} -> 127.0.0.1:${String(webHostPort)}`);
|
|
8761
|
+
if (portlessUrl.startsWith("https://")) {
|
|
8762
|
+
await trustInBoxPortlessCa(containerName, log);
|
|
8763
|
+
}
|
|
9357
8764
|
} else {
|
|
9358
8765
|
log("portless alias failed (best-effort) \u2014 box still reachable on the loopback URL");
|
|
9359
8766
|
}
|
|
@@ -10350,6 +9757,18 @@ var dockerProvider = {
|
|
|
10350
9757
|
const { record } = await startBox(box.id);
|
|
10351
9758
|
return { ...record, provider: "docker" };
|
|
10352
9759
|
},
|
|
9760
|
+
async reconnect(box) {
|
|
9761
|
+
const insp = await inspectBox(box.id);
|
|
9762
|
+
if (insp.state === "missing" || insp.state === "destroyed") {
|
|
9763
|
+
throw new Error(`box ${box.name} has no container; was it destroyed?`);
|
|
9764
|
+
}
|
|
9765
|
+
if (insp.state === "paused") {
|
|
9766
|
+
const record2 = await unpauseBox(box.id);
|
|
9767
|
+
return { ...record2, provider: "docker" };
|
|
9768
|
+
}
|
|
9769
|
+
const { record } = await startBox(box.id);
|
|
9770
|
+
return { ...record, provider: "docker" };
|
|
9771
|
+
},
|
|
10353
9772
|
async pause(box) {
|
|
10354
9773
|
await pauseBox(box.id);
|
|
10355
9774
|
},
|
|
@@ -10383,12 +9802,12 @@ var dockerProvider = {
|
|
|
10383
9802
|
const r = await execInBox(box.container, argv, opts?.user ? { user: opts.user } : {});
|
|
10384
9803
|
return { exitCode: r.exitCode, stdout: r.stdout, stderr: r.stderr };
|
|
10385
9804
|
},
|
|
10386
|
-
async uploadPath(box,
|
|
10387
|
-
const r = await uploadToBox(box,
|
|
9805
|
+
async uploadPath(box, hostSrcs, boxDst, exclude) {
|
|
9806
|
+
const r = await uploadToBox(box, hostSrcs, boxDst, exclude);
|
|
10388
9807
|
return { finalPath: r.finalPath };
|
|
10389
9808
|
},
|
|
10390
|
-
async downloadPath(box,
|
|
10391
|
-
const r = await downloadFromBox(box,
|
|
9809
|
+
async downloadPath(box, boxSrcs, hostDst, exclude) {
|
|
9810
|
+
const r = await downloadFromBox(box, boxSrcs, hostDst, exclude);
|
|
10392
9811
|
return { finalPath: r.finalPath };
|
|
10393
9812
|
},
|
|
10394
9813
|
async resolveUrl(box, opts) {
|
|
@@ -10405,9 +9824,7 @@ var dockerProvider = {
|
|
|
10405
9824
|
return box.portlessUrl ?? await portlessGetUrl(box.portlessAlias);
|
|
10406
9825
|
}
|
|
10407
9826
|
if (box.webHostPort === void 0) {
|
|
10408
|
-
throw new Error(
|
|
10409
|
-
`web port not resolved for box ${box.name}; is the container running?`
|
|
10410
|
-
);
|
|
9827
|
+
throw new Error(`web port not resolved for box ${box.name}; is the container running?`);
|
|
10411
9828
|
}
|
|
10412
9829
|
return `http://127.0.0.1:${String(box.webHostPort)}`;
|
|
10413
9830
|
},
|
|
@@ -10709,9 +10126,13 @@ export {
|
|
|
10709
10126
|
pullClaudeExtras,
|
|
10710
10127
|
SHARED_CODEX_VOLUME,
|
|
10711
10128
|
DEFAULT_CODEX_SESSION,
|
|
10129
|
+
BOX_SYSTEM_PROMPT_PATH,
|
|
10130
|
+
CODEX_OVERRIDE_WROTE_MARKER,
|
|
10131
|
+
buildCodexAgentsOverrideScript,
|
|
10712
10132
|
resolveCodexVolume,
|
|
10713
10133
|
ensureCodexVolume,
|
|
10714
10134
|
seedCodexHooks,
|
|
10135
|
+
seedCodexAgentsOverride,
|
|
10715
10136
|
CODEX_FORWARDED_ENV_KEYS,
|
|
10716
10137
|
buildCodexMounts,
|
|
10717
10138
|
CodexSessionError,
|
|
@@ -10852,43 +10273,4 @@ export {
|
|
|
10852
10273
|
browserSessionActive,
|
|
10853
10274
|
ensureBoxBrowser
|
|
10854
10275
|
};
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
smol-toml/dist/date.js:
|
|
10858
|
-
smol-toml/dist/error.js:
|
|
10859
|
-
smol-toml/dist/primitive.js:
|
|
10860
|
-
smol-toml/dist/util.js:
|
|
10861
|
-
smol-toml/dist/extract.js:
|
|
10862
|
-
smol-toml/dist/struct.js:
|
|
10863
|
-
smol-toml/dist/parse.js:
|
|
10864
|
-
smol-toml/dist/stringify.js:
|
|
10865
|
-
smol-toml/dist/index.js:
|
|
10866
|
-
(*!
|
|
10867
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
10868
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
10869
|
-
*
|
|
10870
|
-
* Redistribution and use in source and binary forms, with or without
|
|
10871
|
-
* modification, are permitted provided that the following conditions are met:
|
|
10872
|
-
*
|
|
10873
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
10874
|
-
* list of conditions and the following disclaimer.
|
|
10875
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10876
|
-
* this list of conditions and the following disclaimer in the
|
|
10877
|
-
* documentation and/or other materials provided with the distribution.
|
|
10878
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
10879
|
-
* may be used to endorse or promote products derived from this software without
|
|
10880
|
-
* specific prior written permission.
|
|
10881
|
-
*
|
|
10882
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
10883
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
10884
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
10885
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
10886
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
10887
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
10888
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
10889
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
10890
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
10891
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10892
|
-
*)
|
|
10893
|
-
*/
|
|
10894
|
-
//# sourceMappingURL=chunk-5N7GA2X7.js.map
|
|
10276
|
+
//# sourceMappingURL=chunk-YZVFGFYQ.js.map
|