sandboxedjs 0.1.71 → 0.1.73

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/dist/index.cjs CHANGED
@@ -4077,6 +4077,214 @@ var init_builtins = __esm({
4077
4077
  }
4078
4078
  });
4079
4079
 
4080
+ // src/util/binary.ts
4081
+ async function nodeBuiltin(name) {
4082
+ const specifier = `node:${name}`;
4083
+ return await import(
4084
+ /* @vite-ignore */
4085
+ /* webpackIgnore: true */
4086
+ specifier
4087
+ );
4088
+ }
4089
+ async function nodeOnlyModule(specifier) {
4090
+ const parts = specifier.split("/");
4091
+ const runtimeSpecifier = parts.join("/");
4092
+ return await import(
4093
+ /* @vite-ignore */
4094
+ /* webpackIgnore: true */
4095
+ runtimeSpecifier
4096
+ );
4097
+ }
4098
+ function nodeZlib() {
4099
+ zlibPromise ??= nodeBuiltin("zlib");
4100
+ return zlibPromise;
4101
+ }
4102
+ async function throughStream(data, stream) {
4103
+ const source = new Blob([data]).stream();
4104
+ const piped = source.pipeThrough(stream);
4105
+ return new Uint8Array(await new Response(piped).arrayBuffer());
4106
+ }
4107
+ async function gzip(data) {
4108
+ if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
4109
+ return throughStream(data, new CompressionStream("gzip"));
4110
+ }
4111
+ async function gunzip(data) {
4112
+ if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
4113
+ return throughStream(data, new DecompressionStream("gzip"));
4114
+ }
4115
+ async function deflate(data) {
4116
+ if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
4117
+ return throughStream(data, new CompressionStream("deflate"));
4118
+ }
4119
+ async function inflate(data) {
4120
+ if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
4121
+ return throughStream(data, new DecompressionStream("deflate"));
4122
+ }
4123
+ function nodeCrypto() {
4124
+ cryptoPromise ??= nodeBuiltin("crypto");
4125
+ return cryptoPromise;
4126
+ }
4127
+ async function digestHex(algorithm, data) {
4128
+ if (isNode) {
4129
+ const { createHash } = await nodeCrypto();
4130
+ return createHash(algorithm).update(data).digest("hex");
4131
+ }
4132
+ if (algorithm === "md5") return md5Hex(data);
4133
+ const name = SUBTLE_NAMES[algorithm];
4134
+ if (!name) throw new UnsupportedAlgorithmError(algorithm);
4135
+ const buffer = await crypto.subtle.digest(name, data);
4136
+ return toHex(new Uint8Array(buffer));
4137
+ }
4138
+ async function randomUuid() {
4139
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
4140
+ const { randomUUID } = await nodeCrypto();
4141
+ return randomUUID();
4142
+ }
4143
+ function toHex(bytes2) {
4144
+ let out = "";
4145
+ for (const byte of bytes2) out += byte.toString(16).padStart(2, "0");
4146
+ return out;
4147
+ }
4148
+ function md5Hex(input) {
4149
+ const S = [
4150
+ 7,
4151
+ 12,
4152
+ 17,
4153
+ 22,
4154
+ 7,
4155
+ 12,
4156
+ 17,
4157
+ 22,
4158
+ 7,
4159
+ 12,
4160
+ 17,
4161
+ 22,
4162
+ 7,
4163
+ 12,
4164
+ 17,
4165
+ 22,
4166
+ 5,
4167
+ 9,
4168
+ 14,
4169
+ 20,
4170
+ 5,
4171
+ 9,
4172
+ 14,
4173
+ 20,
4174
+ 5,
4175
+ 9,
4176
+ 14,
4177
+ 20,
4178
+ 5,
4179
+ 9,
4180
+ 14,
4181
+ 20,
4182
+ 4,
4183
+ 11,
4184
+ 16,
4185
+ 23,
4186
+ 4,
4187
+ 11,
4188
+ 16,
4189
+ 23,
4190
+ 4,
4191
+ 11,
4192
+ 16,
4193
+ 23,
4194
+ 4,
4195
+ 11,
4196
+ 16,
4197
+ 23,
4198
+ 6,
4199
+ 10,
4200
+ 15,
4201
+ 21,
4202
+ 6,
4203
+ 10,
4204
+ 15,
4205
+ 21,
4206
+ 6,
4207
+ 10,
4208
+ 15,
4209
+ 21,
4210
+ 6,
4211
+ 10,
4212
+ 15,
4213
+ 21
4214
+ ];
4215
+ const K = new Uint32Array(64);
4216
+ for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
4217
+ const bitLength = input.length * 8;
4218
+ const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
4219
+ padded.set(input);
4220
+ padded[input.length] = 128;
4221
+ const view = new DataView(padded.buffer);
4222
+ view.setUint32(padded.length - 8, bitLength >>> 0, true);
4223
+ view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
4224
+ let a0 = 1732584193;
4225
+ let b0 = 4023233417;
4226
+ let c0 = 2562383102;
4227
+ let d0 = 271733878;
4228
+ for (let chunk = 0; chunk < padded.length; chunk += 64) {
4229
+ const M = new Uint32Array(16);
4230
+ for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
4231
+ let [a, b, c, d] = [a0, b0, c0, d0];
4232
+ for (let i = 0; i < 64; i++) {
4233
+ let f;
4234
+ let g;
4235
+ if (i < 16) {
4236
+ f = b & c | ~b & d;
4237
+ g = i;
4238
+ } else if (i < 32) {
4239
+ f = d & b | ~d & c;
4240
+ g = (5 * i + 1) % 16;
4241
+ } else if (i < 48) {
4242
+ f = b ^ c ^ d;
4243
+ g = (3 * i + 5) % 16;
4244
+ } else {
4245
+ f = c ^ (b | ~d);
4246
+ g = 7 * i % 16;
4247
+ }
4248
+ const tmp = d;
4249
+ d = c;
4250
+ c = b;
4251
+ const sum = a + f + K[i] + M[g] >>> 0;
4252
+ b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
4253
+ a = tmp;
4254
+ }
4255
+ a0 = a0 + a >>> 0;
4256
+ b0 = b0 + b >>> 0;
4257
+ c0 = c0 + c >>> 0;
4258
+ d0 = d0 + d >>> 0;
4259
+ }
4260
+ const out = new Uint8Array(16);
4261
+ new DataView(out.buffer).setUint32(0, a0, true);
4262
+ new DataView(out.buffer).setUint32(4, b0, true);
4263
+ new DataView(out.buffer).setUint32(8, c0, true);
4264
+ new DataView(out.buffer).setUint32(12, d0, true);
4265
+ return toHex(out);
4266
+ }
4267
+ var isNode, zlibPromise, cryptoPromise, SUBTLE_NAMES, UnsupportedAlgorithmError;
4268
+ var init_binary = __esm({
4269
+ "src/util/binary.ts"() {
4270
+ isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
4271
+ zlibPromise = null;
4272
+ cryptoPromise = null;
4273
+ SUBTLE_NAMES = {
4274
+ sha1: "SHA-1",
4275
+ sha256: "SHA-256",
4276
+ sha384: "SHA-384",
4277
+ sha512: "SHA-512"
4278
+ };
4279
+ UnsupportedAlgorithmError = class extends Error {
4280
+ constructor(algorithm) {
4281
+ super(`${algorithm} is not available in this environment`);
4282
+ this.name = "UnsupportedAlgorithmError";
4283
+ }
4284
+ };
4285
+ }
4286
+ });
4287
+
4080
4288
  // src/pkg/zip.ts
4081
4289
  var zip_exports = {};
4082
4290
  __export(zip_exports, {
@@ -4165,6 +4373,122 @@ var init_zip = __esm({
4165
4373
  }
4166
4374
  });
4167
4375
 
4376
+ // src/python/local-builder.ts
4377
+ var local_builder_exports = {};
4378
+ __export(local_builder_exports, {
4379
+ buildFromSource: () => buildFromSource
4380
+ });
4381
+ async function pipelineRoot() {
4382
+ const [{ existsSync }, { fileURLToPath: fileURLToPath2 }, { dirname: dirname3, resolve: resolve3 }] = await Promise.all([
4383
+ nodeBuiltin("fs"),
4384
+ nodeBuiltin("url"),
4385
+ nodeBuiltin("path")
4386
+ ]);
4387
+ const here = dirname3(fileURLToPath2((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
4388
+ for (const candidate of [
4389
+ resolve3(here, "../python-runtime"),
4390
+ resolve3(here, "../../python-runtime"),
4391
+ resolve3(here, "../../../python-runtime")
4392
+ ]) {
4393
+ if (existsSync(resolve3(candidate, "scripts/build_extension.py"))) return candidate;
4394
+ }
4395
+ return null;
4396
+ }
4397
+ async function run(command, args, cwd) {
4398
+ const { spawn } = await nodeBuiltin("child_process");
4399
+ return await new Promise((resolveRun) => {
4400
+ const child = spawn(command, args, { cwd });
4401
+ let stdout = "";
4402
+ let stderr = "";
4403
+ child.stdout.on("data", (chunk) => {
4404
+ stdout += String(chunk);
4405
+ });
4406
+ child.stderr.on("data", (chunk) => {
4407
+ stderr += String(chunk);
4408
+ });
4409
+ child.on("error", (error) => resolveRun({ code: -1, stdout, stderr: String(error) }));
4410
+ child.on("close", (code) => resolveRun({ code: code ?? -1, stdout, stderr }));
4411
+ });
4412
+ }
4413
+ async function readIndex(root) {
4414
+ const [{ readFileSync, existsSync }, { pathToFileURL: pathToFileURL2 }, { resolve: resolve3 }] = await Promise.all([
4415
+ nodeBuiltin("fs"),
4416
+ nodeBuiltin("url"),
4417
+ nodeBuiltin("path")
4418
+ ]);
4419
+ const directory2 = resolve3(root, "out/wheels");
4420
+ const file3 = resolve3(directory2, "index.json");
4421
+ if (!existsSync(file3)) return null;
4422
+ const parsed = JSON.parse(readFileSync(file3, "utf8"));
4423
+ return {
4424
+ ...parsed,
4425
+ baseUrl: pathToFileURL2(directory2).href
4426
+ };
4427
+ }
4428
+ async function buildFromSource(requirement, log = () => {
4429
+ }) {
4430
+ const root = await pipelineRoot();
4431
+ if (root === null) {
4432
+ return {
4433
+ built: false,
4434
+ index: null,
4435
+ classification: "blocked-toolchain",
4436
+ reason: "the build pipeline is not present; wheels can only be built from a checkout"
4437
+ };
4438
+ }
4439
+ log(`Building ${requirement} from source (no wheel for this runtime yet)`);
4440
+ const recipe = await run("python3", ["scripts/auto_recipe.py", requirement], root);
4441
+ if (recipe.code !== 0) {
4442
+ try {
4443
+ const reported = JSON.parse(recipe.stdout.trim().split("\n").at(-1) ?? "{}");
4444
+ if (reported.reason) {
4445
+ return {
4446
+ built: false,
4447
+ index: null,
4448
+ classification: reported.classification ?? "blocked-toolchain",
4449
+ reason: reported.reason
4450
+ };
4451
+ }
4452
+ } catch {
4453
+ }
4454
+ return {
4455
+ built: false,
4456
+ index: null,
4457
+ classification: "blocked-toolchain",
4458
+ reason: `could not describe ${requirement}: ${recipe.stderr.trim().slice(-400)}`
4459
+ };
4460
+ }
4461
+ const recipePath = recipe.stdout.trim().split("\n").at(-1);
4462
+ const build = await run("python3", ["scripts/build_extension.py", recipePath], root);
4463
+ if (build.code !== 0) {
4464
+ const tail2 = `${build.stdout}
4465
+ ${build.stderr}`.trim().split("\n").slice(-12).join("\n");
4466
+ return {
4467
+ built: false,
4468
+ index: null,
4469
+ classification: "blocked-toolchain",
4470
+ reason: `building ${requirement} failed:
4471
+ ${tail2}`
4472
+ };
4473
+ }
4474
+ const indexed = await run("python3", ["scripts/build_index.py"], root);
4475
+ if (indexed.code !== 0) {
4476
+ return {
4477
+ built: false,
4478
+ index: null,
4479
+ classification: "blocked-toolchain",
4480
+ reason: `built ${requirement} but could not index it: ${indexed.stderr.trim().slice(-300)}`
4481
+ };
4482
+ }
4483
+ log(`Built ${requirement}`);
4484
+ return { built: true, index: await readIndex(root) };
4485
+ }
4486
+ var init_local_builder = __esm({
4487
+ "src/python/local-builder.ts"() {
4488
+ init_binary();
4489
+ }
4490
+ });
4491
+
4168
4492
  // src/fs/vfs.ts
4169
4493
  init_errno();
4170
4494
  init_path();
@@ -15427,211 +15751,7 @@ var commands5 = [grep, find, xargs, diff, cmp];
15427
15751
  // src/bin/archive.ts
15428
15752
  init_mode();
15429
15753
  init_path();
15430
-
15431
- // src/util/binary.ts
15432
- var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
15433
- async function nodeBuiltin(name) {
15434
- const specifier = `node:${name}`;
15435
- return await import(
15436
- /* @vite-ignore */
15437
- /* webpackIgnore: true */
15438
- specifier
15439
- );
15440
- }
15441
- async function nodeOnlyModule(specifier) {
15442
- const parts = specifier.split("/");
15443
- const runtimeSpecifier = parts.join("/");
15444
- return await import(
15445
- /* @vite-ignore */
15446
- /* webpackIgnore: true */
15447
- runtimeSpecifier
15448
- );
15449
- }
15450
- var zlibPromise = null;
15451
- function nodeZlib() {
15452
- zlibPromise ??= nodeBuiltin("zlib");
15453
- return zlibPromise;
15454
- }
15455
- async function throughStream(data, stream) {
15456
- const source = new Blob([data]).stream();
15457
- const piped = source.pipeThrough(stream);
15458
- return new Uint8Array(await new Response(piped).arrayBuffer());
15459
- }
15460
- async function gzip(data) {
15461
- if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
15462
- return throughStream(data, new CompressionStream("gzip"));
15463
- }
15464
- async function gunzip(data) {
15465
- if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
15466
- return throughStream(data, new DecompressionStream("gzip"));
15467
- }
15468
- async function deflate(data) {
15469
- if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
15470
- return throughStream(data, new CompressionStream("deflate"));
15471
- }
15472
- async function inflate(data) {
15473
- if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
15474
- return throughStream(data, new DecompressionStream("deflate"));
15475
- }
15476
- var cryptoPromise = null;
15477
- function nodeCrypto() {
15478
- cryptoPromise ??= nodeBuiltin("crypto");
15479
- return cryptoPromise;
15480
- }
15481
- var SUBTLE_NAMES = {
15482
- sha1: "SHA-1",
15483
- sha256: "SHA-256",
15484
- sha384: "SHA-384",
15485
- sha512: "SHA-512"
15486
- };
15487
- var UnsupportedAlgorithmError = class extends Error {
15488
- constructor(algorithm) {
15489
- super(`${algorithm} is not available in this environment`);
15490
- this.name = "UnsupportedAlgorithmError";
15491
- }
15492
- };
15493
- async function digestHex(algorithm, data) {
15494
- if (isNode) {
15495
- const { createHash } = await nodeCrypto();
15496
- return createHash(algorithm).update(data).digest("hex");
15497
- }
15498
- if (algorithm === "md5") return md5Hex(data);
15499
- const name = SUBTLE_NAMES[algorithm];
15500
- if (!name) throw new UnsupportedAlgorithmError(algorithm);
15501
- const buffer = await crypto.subtle.digest(name, data);
15502
- return toHex(new Uint8Array(buffer));
15503
- }
15504
- async function randomUuid() {
15505
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
15506
- const { randomUUID } = await nodeCrypto();
15507
- return randomUUID();
15508
- }
15509
- function toHex(bytes2) {
15510
- let out = "";
15511
- for (const byte of bytes2) out += byte.toString(16).padStart(2, "0");
15512
- return out;
15513
- }
15514
- function md5Hex(input) {
15515
- const S = [
15516
- 7,
15517
- 12,
15518
- 17,
15519
- 22,
15520
- 7,
15521
- 12,
15522
- 17,
15523
- 22,
15524
- 7,
15525
- 12,
15526
- 17,
15527
- 22,
15528
- 7,
15529
- 12,
15530
- 17,
15531
- 22,
15532
- 5,
15533
- 9,
15534
- 14,
15535
- 20,
15536
- 5,
15537
- 9,
15538
- 14,
15539
- 20,
15540
- 5,
15541
- 9,
15542
- 14,
15543
- 20,
15544
- 5,
15545
- 9,
15546
- 14,
15547
- 20,
15548
- 4,
15549
- 11,
15550
- 16,
15551
- 23,
15552
- 4,
15553
- 11,
15554
- 16,
15555
- 23,
15556
- 4,
15557
- 11,
15558
- 16,
15559
- 23,
15560
- 4,
15561
- 11,
15562
- 16,
15563
- 23,
15564
- 6,
15565
- 10,
15566
- 15,
15567
- 21,
15568
- 6,
15569
- 10,
15570
- 15,
15571
- 21,
15572
- 6,
15573
- 10,
15574
- 15,
15575
- 21,
15576
- 6,
15577
- 10,
15578
- 15,
15579
- 21
15580
- ];
15581
- const K = new Uint32Array(64);
15582
- for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
15583
- const bitLength = input.length * 8;
15584
- const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
15585
- padded.set(input);
15586
- padded[input.length] = 128;
15587
- const view = new DataView(padded.buffer);
15588
- view.setUint32(padded.length - 8, bitLength >>> 0, true);
15589
- view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
15590
- let a0 = 1732584193;
15591
- let b0 = 4023233417;
15592
- let c0 = 2562383102;
15593
- let d0 = 271733878;
15594
- for (let chunk = 0; chunk < padded.length; chunk += 64) {
15595
- const M = new Uint32Array(16);
15596
- for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
15597
- let [a, b, c, d] = [a0, b0, c0, d0];
15598
- for (let i = 0; i < 64; i++) {
15599
- let f;
15600
- let g;
15601
- if (i < 16) {
15602
- f = b & c | ~b & d;
15603
- g = i;
15604
- } else if (i < 32) {
15605
- f = d & b | ~d & c;
15606
- g = (5 * i + 1) % 16;
15607
- } else if (i < 48) {
15608
- f = b ^ c ^ d;
15609
- g = (3 * i + 5) % 16;
15610
- } else {
15611
- f = c ^ (b | ~d);
15612
- g = 7 * i % 16;
15613
- }
15614
- const tmp = d;
15615
- d = c;
15616
- c = b;
15617
- const sum = a + f + K[i] + M[g] >>> 0;
15618
- b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
15619
- a = tmp;
15620
- }
15621
- a0 = a0 + a >>> 0;
15622
- b0 = b0 + b >>> 0;
15623
- c0 = c0 + c >>> 0;
15624
- d0 = d0 + d >>> 0;
15625
- }
15626
- const out = new Uint8Array(16);
15627
- new DataView(out.buffer).setUint32(0, a0, true);
15628
- new DataView(out.buffer).setUint32(4, b0, true);
15629
- new DataView(out.buffer).setUint32(8, c0, true);
15630
- new DataView(out.buffer).setUint32(12, d0, true);
15631
- return toHex(out);
15632
- }
15633
-
15634
- // src/bin/archive.ts
15754
+ init_binary();
15635
15755
  var BLOCK = 512;
15636
15756
  var encoder4 = new TextEncoder();
15637
15757
  var decoder6 = new TextDecoder();
@@ -15944,6 +16064,7 @@ var zlibCompress = defineCommand({
15944
16064
  var commands6 = [tar, gzip2, gunzip2, zcat, zlibCompress];
15945
16065
 
15946
16066
  // src/bin/hash.ts
16067
+ init_binary();
15947
16068
  function makeSum(name, algorithm, path) {
15948
16069
  return defineCommand({
15949
16070
  name,
@@ -17372,7 +17493,7 @@ var wlPaste = defineCommand({
17372
17493
  });
17373
17494
  var commands11 = [xsel, xclip, pbcopy, pbpaste, wlCopy, wlPaste];
17374
17495
 
17375
- // src/runtime/node.ts
17496
+ // src/node/node.ts
17376
17497
  init_path();
17377
17498
  var NODE_VERSION = "v22.12.0";
17378
17499
  new TextEncoder();
@@ -17769,10 +17890,10 @@ function nodeCommands() {
17769
17890
  return [node, nodeVersionFile];
17770
17891
  }
17771
17892
 
17772
- // src/runtime/python.ts
17893
+ // src/python/python.ts
17773
17894
  init_path();
17774
17895
 
17775
- // src/runtime/python/host-abi.ts
17896
+ // src/python/host-abi.ts
17776
17897
  var SBX_HOST_ABI_VERSION = 1;
17777
17898
  var SBX_REQUEST_HEADER_BYTES = 16;
17778
17899
  var SBX_RESPONSE_HEADER_BYTES = 20;
@@ -17885,7 +18006,7 @@ Object.fromEntries(
17885
18006
  Object.entries(Errno).map(([name, code]) => [code, name])
17886
18007
  );
17887
18008
 
17888
- // src/runtime/python/manifest.ts
18009
+ // src/python/manifest.ts
17889
18010
  var MANIFEST_FORMAT = "sandboxedjs-python-runtime";
17890
18011
  var MANIFEST_SCHEMA_VERSION = 1;
17891
18012
  var ManifestError = class extends Error {
@@ -17984,6 +18105,27 @@ var wheels_default = {
17984
18105
  patches: []
17985
18106
  }
17986
18107
  },
18108
+ {
18109
+ name: "numpy",
18110
+ version: "2.2.6",
18111
+ filename: "numpy-2.2.6-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18112
+ sha256: "93ae7230479566b45f715733e92caaeadb1e6fd7b6bfe244e907c2c4eea910bf",
18113
+ abiId: "sbxabi1-c2637d04695ad927",
18114
+ requires: [],
18115
+ provenance: {
18116
+ sourceTreeDigest: "71c23901e3de9adcf52c9e9965279e73f98f45ed7ab9847d7f5f9f1433d4452e",
18117
+ recipeSha256: "b5cde263ce9932472b1c17ee74d80ac194f938ca8e4c3415faedd0abe69c3e09",
18118
+ buildTools: [
18119
+ "setuptools==84.0.0",
18120
+ "meson-python==0.21.0",
18121
+ "meson==1.12.0",
18122
+ "ninja==1.13.2",
18123
+ "Cython==3.1.4"
18124
+ ],
18125
+ nativeDependencies: [],
18126
+ patches: []
18127
+ }
18128
+ },
17987
18129
  {
17988
18130
  name: "pydantic-core",
17989
18131
  version: "2.23.2",
@@ -18061,7 +18203,7 @@ var wheels_default = {
18061
18203
  name: "sbx-meson-probe",
18062
18204
  version: "1.0.0",
18063
18205
  filename: "sbx_meson_probe-1.0.0-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18064
- sha256: "f3efc427caa9ab45c85af554b19c06f0d227852682972894484f9b024a6cb586",
18206
+ sha256: "3ad378e05668ec190f76605e312a47a12009879a13cc083574b03c8cdbbf5ed5",
18065
18207
  abiId: "sbxabi1-c2637d04695ad927",
18066
18208
  requires: [
18067
18209
  "typing-extensions>=4.0"
@@ -18197,7 +18339,7 @@ var wheels_default = {
18197
18339
  name: "siphash24",
18198
18340
  version: "1.9",
18199
18341
  filename: "siphash24-1.9-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18200
- sha256: "cf672c37b0f8e4cd198e5fdd4c6c84036d1d4da36f889564385c1eacfb7c3295",
18342
+ sha256: "41e76fde2f7ed45f801e73c7ed65b7f0ea0465966915e5415c96e782f8cbfc48",
18201
18343
  abiId: "sbxabi1-c2637d04695ad927",
18202
18344
  requires: [],
18203
18345
  provenance: {
@@ -18221,9 +18363,17 @@ var wheels_default = {
18221
18363
 
18222
18364
  // package.json
18223
18365
  var package_default = {
18224
- version: "0.1.71"};
18366
+ version: "0.1.73"};
18225
18367
 
18226
- // src/runtime/python/config.ts
18368
+ // src/python/config.ts
18369
+ function runtimeModuleUrl() {
18370
+ const url = new URL(
18371
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)).includes("/src/python/") ? "../../dist/python/python.js" : "./python/python.js",
18372
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))
18373
+ );
18374
+ if (url.protocol !== "file:") url.searchParams.set("sbx-runtime", package_default.version);
18375
+ return url;
18376
+ }
18227
18377
  var bundledManifest = {
18228
18378
  format: "sandboxedjs-python-runtime",
18229
18379
  schemaVersion: 1,
@@ -18232,16 +18382,7 @@ var bundledManifest = {
18232
18382
  pythonVersion: "3.13.5",
18233
18383
  profile: "dynamic",
18234
18384
  hostAbi: { name: "sbx_host_v1", version: 1 },
18235
- artifacts: {
18236
- moduleUrl: (() => {
18237
- const url = new URL(
18238
- (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)).includes("/src/runtime/python/") ? "../../../dist/python/python.js" : "./python/python.js",
18239
- (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))
18240
- );
18241
- if (url.protocol !== "file:") url.searchParams.set("sbx-runtime", package_default.version);
18242
- return url.href;
18243
- })()
18244
- },
18385
+ artifacts: { moduleUrl: runtimeModuleUrl().href },
18245
18386
  capabilities: {
18246
18387
  threads: true,
18247
18388
  nativeExtensions: "dynamic",
@@ -18250,24 +18391,31 @@ var bundledManifest = {
18250
18391
  persistence: "memory"
18251
18392
  }
18252
18393
  };
18253
- var bundledWheelNames = {
18394
+ var embeddedWheels = {
18254
18395
  "pydantic_core-2.23.2-cp313-cp313-emscripten_5_0_6_wasm32.whl": pydantic_core_2_23_2_cp313_cp313_emscripten_5_0_6_wasm32_default,
18255
18396
  "pydantic_core-2.46.5-cp313-cp313-emscripten_5_0_6_wasm32.whl": pydantic_core_2_46_5_cp313_cp313_emscripten_5_0_6_wasm32_default
18256
18397
  };
18257
18398
  var bundledWheelIndex = {
18258
- baseUrl: "sbx-wheel:",
18259
- wheels: wheels_default.wheels.filter(
18260
- (wheel) => wheel.filename in bundledWheelNames
18261
- ),
18262
- files: bundledWheelNames
18399
+ baseUrl: new URL("./wheels", runtimeModuleUrl()).href,
18400
+ wheels: wheels_default.wheels,
18401
+ files: embeddedWheels
18263
18402
  };
18264
18403
  var config = {
18265
18404
  backend: "sbx-cpython-wasm",
18266
18405
  manifest: bundledManifest,
18267
- wheelIndex: bundledWheelIndex
18406
+ wheelIndex: bundledWheelIndex,
18407
+ /* On by default only where it can possibly work: a Node process, running
18408
+ * from a checkout that has the build pipeline. A browser has no compiler and
18409
+ * never will, and a published package has no pipeline -- in both, building
18410
+ * would replace a clear "no wheel for this package" with a hang or a
18411
+ * confusing failure, so both keep reporting instead. `local-builder` checks
18412
+ * for the pipeline again before it runs, so this is a cheap hint rather than
18413
+ * a promise. */
18414
+ buildFromSource: typeof process !== "undefined" && Boolean(process.versions?.node) && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)).startsWith("file:")
18268
18415
  };
18269
18416
  function setPythonBackend(options) {
18270
18417
  if (options.wheelIndex !== void 0) config.wheelIndex = options.wheelIndex;
18418
+ if (options.buildFromSource !== void 0) config.buildFromSource = options.buildFromSource;
18271
18419
  if (options.manifest !== void 0) config.manifest = validateManifest(options.manifest);
18272
18420
  if (options.workerUrl !== void 0) config.workerUrl = options.workerUrl;
18273
18421
  if (options.backend !== void 0) {
@@ -18941,10 +19089,11 @@ var FileService = class {
18941
19089
  }
18942
19090
  };
18943
19091
 
18944
- // src/runtime/python/backend.ts
19092
+ // src/python/backend.ts
18945
19093
  init_signals();
19094
+ init_binary();
18946
19095
 
18947
- // src/runtime/python/protocol.ts
19096
+ // src/python/protocol.ts
18948
19097
  var ProtocolError = class extends Error {
18949
19098
  code = "ERR_SBX_ABI_PROTOCOL";
18950
19099
  };
@@ -19421,7 +19570,7 @@ var VirtualTcpNetwork = class {
19421
19570
  }
19422
19571
  };
19423
19572
 
19424
- // src/runtime/python/syscall-server.ts
19573
+ // src/python/syscall-server.ts
19425
19574
  var MAX_TRANSFER = 8 * 1024 * 1024;
19426
19575
  var POLLIN = 1;
19427
19576
  var POLLOUT = 4;
@@ -19870,7 +20019,7 @@ function encodeStat(st) {
19870
20019
  return new Writer().u64(st.ino).u32(st.mode).u64(st.size).u32(st.uid).u32(st.gid).u32(st.nlink).i64(Math.round(st.atimeMs * 1e6)).i64(Math.round(st.mtimeMs * 1e6)).i64(Math.round(st.ctimeMs * 1e6)).finish();
19871
20020
  }
19872
20021
 
19873
- // src/runtime/python/sync-transport.ts
20022
+ // src/python/sync-transport.ts
19874
20023
  var STATE = 0;
19875
20024
  var LENGTH = 1;
19876
20025
  var MORE = 2;
@@ -19973,7 +20122,7 @@ function concat3(parts) {
19973
20122
  return joined;
19974
20123
  }
19975
20124
 
19976
- // src/runtime/worker-host.ts
20125
+ // src/worker/worker-host.ts
19977
20126
  function defaultWorkerUrl() {
19978
20127
  return new URL("./worker-entry.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
19979
20128
  }
@@ -20044,7 +20193,7 @@ async function startNodeWorker(url, workerData) {
20044
20193
  };
20045
20194
  }
20046
20195
 
20047
- // src/runtime/python/supervisor.ts
20196
+ // src/python/supervisor.ts
20048
20197
  var nextGeneration = 1;
20049
20198
  async function startPythonProcess(options) {
20050
20199
  const unavailable2 = syncTransportUnavailableReason();
@@ -20159,10 +20308,10 @@ async function startPythonProcess(options) {
20159
20308
  };
20160
20309
  }
20161
20310
 
20162
- // src/runtime/python/install.ts
20311
+ // src/python/install.ts
20163
20312
  init_zip();
20164
20313
 
20165
- // src/runtime/python/pypi.ts
20314
+ // src/python/pypi.ts
20166
20315
  function parseRequirement(text2) {
20167
20316
  const cleaned = text2.replace(/#.*$/, "").trim();
20168
20317
  if (!cleaned) return null;
@@ -20241,7 +20390,7 @@ function splitOnce(text2, separator) {
20241
20390
  return at < 0 ? [text2] : [text2.slice(0, at), text2.slice(at + 1)];
20242
20391
  }
20243
20392
 
20244
- // src/runtime/python/extension-abi.ts
20393
+ // src/python/extension-abi.ts
20245
20394
  var EXTENSION_ABI = {
20246
20395
  "abiId": "sbxabi1-c2637d04695ad927",
20247
20396
  "wheelTag": "cp313-cp313-emscripten_5_0_6_wasm32",
@@ -20255,7 +20404,7 @@ var EXTENSION_ABI = {
20255
20404
  var WHEEL_TAG = EXTENSION_ABI.wheelTag;
20256
20405
  var PURE_PYTHON_TAGS = EXTENSION_ABI.wheel.acceptedPurePythonTags;
20257
20406
 
20258
- // src/runtime/python/resolver.ts
20407
+ // src/python/resolver.ts
20259
20408
  var WHEEL_INDEX_SCHEMA_VERSION = 1;
20260
20409
  function assertIndexUsable(index) {
20261
20410
  const declared = index.schemaVersion;
@@ -20565,7 +20714,7 @@ function requiresFromMetadata(text2) {
20565
20714
  return result;
20566
20715
  }
20567
20716
 
20568
- // src/runtime/python/install.ts
20717
+ // src/python/install.ts
20569
20718
  var SITE_PACKAGES = "/usr/lib/python3.13/site-packages";
20570
20719
  var SCRIPTS = "/usr/local/bin";
20571
20720
  function markerEnvironment(pythonVersion) {
@@ -20692,7 +20841,7 @@ if __name__ == '__main__':
20692
20841
  `;
20693
20842
  }
20694
20843
 
20695
- // src/runtime/python/backend.ts
20844
+ // src/python/backend.ts
20696
20845
  var PENDING_INHERITANCE = /* @__PURE__ */ new Map();
20697
20846
  var INHERIT_TOKEN = "SBX_PYTHON_INHERIT";
20698
20847
  var WNOHANG = 1;
@@ -20845,7 +20994,7 @@ async function resolveWorkerUrl(explicit) {
20845
20994
  nodeBuiltin("url")
20846
20995
  ]);
20847
20996
  if (existsSync(fileURLToPath2(beside))) return beside;
20848
- const built = new URL("../../../dist/python-worker.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
20997
+ const built = new URL("../../dist/python-worker.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
20849
20998
  if (existsSync(fileURLToPath2(built))) return pathToFileURL2(fileURLToPath2(built));
20850
20999
  throw new Error(
20851
21000
  "the SandboxedJs Python process worker has not been built; run `npm run build` in the package, or pass configurePython({ workerUrl })."
@@ -20930,7 +21079,76 @@ function containerMounts(ctx) {
20930
21079
  return mounts;
20931
21080
  }
20932
21081
 
20933
- // src/runtime/python/pip-command.ts
21082
+ // src/python/pip-command.ts
21083
+ init_binary();
21084
+ async function requestRemoteBuild(service, requirement, line) {
21085
+ line(`Asking ${new URL(service).host} to build ${requirement}`);
21086
+ try {
21087
+ const deadline = Date.now() + 20 * 6e4;
21088
+ let verdict = {};
21089
+ for (; ; ) {
21090
+ const response = await fetch(service, {
21091
+ method: "POST",
21092
+ headers: { "content-type": "application/json" },
21093
+ body: JSON.stringify({ requirement })
21094
+ });
21095
+ if (!response.ok) {
21096
+ return {
21097
+ built: false,
21098
+ index: null,
21099
+ classification: "blocked-toolchain",
21100
+ reason: `${service} answered ${response.status}`
21101
+ };
21102
+ }
21103
+ verdict = await response.json();
21104
+ if (verdict.state !== "building-wheel" && verdict.state !== "queued") break;
21105
+ if (Date.now() > deadline) {
21106
+ return {
21107
+ built: false,
21108
+ index: null,
21109
+ classification: "blocked-toolchain",
21110
+ reason: `${service} is still building ${requirement} after 20 minutes`
21111
+ };
21112
+ }
21113
+ await new Promise((wait) => setTimeout(wait, 3e3));
21114
+ }
21115
+ if (!verdict.built) {
21116
+ return {
21117
+ built: false,
21118
+ index: null,
21119
+ classification: verdict.classification ?? "blocked-toolchain",
21120
+ reason: verdict.reason ?? "the build service reported no wheel"
21121
+ };
21122
+ }
21123
+ const base2 = (verdict.indexUrl ?? service.replace(/\/build\/?$/, "")).replace(/\/$/, "");
21124
+ const fresh = await fetch(`${base2}/index.json`, { cache: "no-store" });
21125
+ if (!fresh.ok) {
21126
+ return {
21127
+ built: false,
21128
+ index: null,
21129
+ classification: "blocked-toolchain",
21130
+ reason: `${base2}/index.json answered ${fresh.status} after the build`
21131
+ };
21132
+ }
21133
+ const loaded = await fresh.json();
21134
+ line(`Built ${requirement}`);
21135
+ return {
21136
+ built: true,
21137
+ index: {
21138
+ baseUrl: base2,
21139
+ wheels: loaded.wheels ?? [],
21140
+ ...loaded.schemaVersion === void 0 ? {} : { schemaVersion: loaded.schemaVersion }
21141
+ }
21142
+ };
21143
+ } catch (error) {
21144
+ return {
21145
+ built: false,
21146
+ index: null,
21147
+ classification: "blocked-toolchain",
21148
+ reason: `could not reach the build service at ${service}: ${error.message}`
21149
+ };
21150
+ }
21151
+ }
20934
21152
  var pipCommand = defineCommand({
20935
21153
  name: "pip",
20936
21154
  path: "/usr/bin/pip",
@@ -20983,15 +21201,19 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
20983
21201
  const cache = /* @__PURE__ */ new Map();
20984
21202
  let embeddedFiles = {};
20985
21203
  const request = async (url, timeoutMs, read) => {
20986
- if (url.startsWith("sbx-wheel:")) {
20987
- const filename = decodeURIComponent(url.slice("sbx-wheel:".length).replace(/^\/+/, ""));
20988
- const encoded = embeddedFiles[filename];
20989
- if (!encoded) throw new Error(`bundled wheel ${filename} is missing`);
20990
- const binary = atob(encoded);
21204
+ const embedded = embeddedFiles[decodeURIComponent(
21205
+ url.replace(/[?#].*$/, "").split("/").pop() ?? ""
21206
+ )];
21207
+ if (embedded) {
21208
+ const binary = atob(embedded);
20991
21209
  const bytes2 = new Uint8Array(binary.length);
20992
21210
  for (let i = 0; i < binary.length; i += 1) bytes2[i] = binary.charCodeAt(i);
20993
21211
  return await read(new Response(bytes2));
20994
21212
  }
21213
+ if (url.startsWith("sbx-wheel:")) {
21214
+ const filename = decodeURIComponent(url.slice("sbx-wheel:".length).replace(/^\/+/, ""));
21215
+ throw new Error(`bundled wheel ${filename} is missing`);
21216
+ }
20995
21217
  if (url.startsWith("file:")) {
20996
21218
  try {
20997
21219
  const [{ readFile }, { fileURLToPath: fileURLToPath2 }] = await Promise.all([
@@ -21052,29 +21274,48 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
21052
21274
  index = configured;
21053
21275
  embeddedFiles = configured.files ?? {};
21054
21276
  }
21055
- try {
21056
- const report = await installRequirements({
21057
- index,
21058
- client,
21059
- vfs: ctx.vfs,
21060
- cred: ctx.cred,
21061
- requirements,
21062
- pythonVersion: pythonBackend().manifest?.pythonVersion ?? "3.13.5",
21063
- progress: {
21064
- collecting: (name) => ctx.line(`Collecting ${name}`),
21065
- downloading: () => {
21277
+ let attemptsLeft = 12;
21278
+ for (; ; ) {
21279
+ try {
21280
+ const report = await installRequirements({
21281
+ index,
21282
+ client,
21283
+ vfs: ctx.vfs,
21284
+ cred: ctx.cred,
21285
+ requirements,
21286
+ pythonVersion: pythonBackend().manifest?.pythonVersion ?? "3.13.5",
21287
+ progress: {
21288
+ collecting: (name) => ctx.line(`Collecting ${name}`),
21289
+ downloading: () => {
21290
+ }
21066
21291
  }
21292
+ });
21293
+ for (const skipped of report.skipped) {
21294
+ ctx.line(` Skipping ${skipped.name} (marker: ${skipped.marker})`);
21067
21295
  }
21068
- });
21069
- for (const skipped of report.skipped) {
21070
- ctx.line(` Skipping ${skipped.name} (marker: ${skipped.marker})`);
21296
+ ctx.line(
21297
+ `Successfully installed ${report.installed.map((p) => `${p.name}-${p.version}`).join(" ")}`
21298
+ );
21299
+ return 0;
21300
+ } catch (error) {
21301
+ const failure2 = error.failure;
21302
+ const buildable = failure2?.reason === "no-compatible-distribution" && Boolean(failure2.package) && failure2.sourceAvailable === true;
21303
+ if (!buildable || !pythonBackend().buildFromSource || attemptsLeft <= 0) {
21304
+ return ctx.fail(error.message ?? String(error));
21305
+ }
21306
+ attemptsLeft -= 1;
21307
+ const builder = pythonBackend().buildFromSource;
21308
+ const outcome = typeof builder === "string" ? await requestRemoteBuild(builder, failure2.package, (l) => ctx.line(l)) : await (await Promise.resolve().then(() => (init_local_builder(), local_builder_exports))).buildFromSource(failure2.package, (line) => ctx.line(line));
21309
+ if (!outcome.built) {
21310
+ return ctx.fail(
21311
+ `${error.message}
21312
+ ${outcome.classification}: ${outcome.reason}`
21313
+ );
21314
+ }
21315
+ if (outcome.index) index = outcome.index;
21316
+ embeddedFiles = { ...embeddedFiles, ...outcome.index?.files ?? {} };
21317
+ cache.clear();
21071
21318
  }
21072
- ctx.line(
21073
- `Successfully installed ${report.installed.map((p) => `${p.name}-${p.version}`).join(" ")}`
21074
- );
21075
- return 0;
21076
- } catch (error) {
21077
- return ctx.fail(error.message ?? String(error));
21078
21319
  }
21079
21320
  }
21080
21321
  });
@@ -21092,7 +21333,7 @@ function listInstalled(ctx) {
21092
21333
  return 0;
21093
21334
  }
21094
21335
 
21095
- // src/runtime/emscripten-fs.ts
21336
+ // src/fs/emscripten-fs.ts
21096
21337
  init_errno();
21097
21338
  init_path();
21098
21339
  var EM_ERRNO = {
@@ -21347,7 +21588,10 @@ function mountContainerFs(FS, opts) {
21347
21588
  }
21348
21589
  }
21349
21590
 
21350
- // src/runtime/python-syscalls.ts
21591
+ // src/python/cpython.ts
21592
+ init_binary();
21593
+
21594
+ // src/python/python-syscalls.ts
21351
21595
  var EMPTY = new Uint8Array(0);
21352
21596
  function createStdinHost(ctx) {
21353
21597
  let pending = EMPTY;
@@ -22084,7 +22328,7 @@ function bindProgram(py, binding) {
22084
22328
  });
22085
22329
  }
22086
22330
 
22087
- // src/runtime/cpython.ts
22331
+ // src/python/cpython.ts
22088
22332
  var RESERVED_FOR_INTERPRETER = /* @__PURE__ */ new Set(["lib", "dev", "proc"]);
22089
22333
  var pyodideModule = null;
22090
22334
  var indexUrl;
@@ -22492,7 +22736,7 @@ var micropip = defineCommand({
22492
22736
  }
22493
22737
  });
22494
22738
 
22495
- // src/runtime/python.ts
22739
+ // src/python/python.ts
22496
22740
  var PYTHON_VERSION = "3.13";
22497
22741
  function configurePython(options = {}) {
22498
22742
  configureCPython({ indexURL: options.indexURL, moduleURL: options.pyodideURL });
@@ -22500,7 +22744,8 @@ function configurePython(options = {}) {
22500
22744
  ...options.backend !== void 0 ? { backend: options.backend } : {},
22501
22745
  ...options.manifest !== void 0 ? { manifest: options.manifest } : {},
22502
22746
  ...options.workerUrl !== void 0 ? { workerUrl: options.workerUrl } : {},
22503
- ...options.wheelIndex !== void 0 ? { wheelIndex: options.wheelIndex } : {}
22747
+ ...options.wheelIndex !== void 0 ? { wheelIndex: options.wheelIndex } : {},
22748
+ ...options.buildFromSource !== void 0 ? { buildFromSource: options.buildFromSource } : {}
22504
22749
  });
22505
22750
  }
22506
22751
  var isPythonAvailable = isCPythonAvailable;
@@ -22604,7 +22849,8 @@ function pythonCommands() {
22604
22849
  return usingOwnedPython() ? [python, pipCommand] : [python, micropip];
22605
22850
  }
22606
22851
 
22607
- // src/runtime/ffmpeg.ts
22852
+ // src/tools/ffmpeg.ts
22853
+ init_binary();
22608
22854
  var INSTALL_HINT = "ffmpeg is not installed in this container.\nThe FFmpeg runtime ships separately because it is a ~31MB WebAssembly build:\n npm install @ffmpeg/core";
22609
22855
  var compiled = null;
22610
22856
  async function loadFactory() {
@@ -24679,7 +24925,7 @@ unless the container was created with network: { allowOutbound: true }.`,
24679
24925
  const packageSpec = packages[0] ?? spec;
24680
24926
  const packageName = packages[0] ? splitPackageSpec(packages[0]).name : specName;
24681
24927
  let command = packages.length > 0 ? spec : basename(specName);
24682
- const run = async (binary) => {
24928
+ const run2 = async (binary) => {
24683
24929
  const env2 = {
24684
24930
  ...ctx.env,
24685
24931
  PATH: `${binDir}:${ctx.env.PATH ?? ""}`,
@@ -24696,8 +24942,8 @@ unless the container was created with network: { allowOutbound: true }.`,
24696
24942
  }).wait();
24697
24943
  };
24698
24944
  if (!version) {
24699
- if (findLocalBin(ctx, command)) return run(command);
24700
- if (ctx.kernel.which(command, ctx.cwd, ctx.env, ctx.cred)) return run(command);
24945
+ if (findLocalBin(ctx, command)) return run2(command);
24946
+ if (ctx.kernel.which(command, ctx.cwd, ctx.env, ctx.cred)) return run2(command);
24701
24947
  }
24702
24948
  if (args.has("no-install")) {
24703
24949
  ctx.warn(`command not found: ${command}`);
@@ -24735,7 +24981,7 @@ unless the container was created with network: { allowOutbound: true }.`,
24735
24981
  }
24736
24982
  command = chosen;
24737
24983
  }
24738
- return run(command);
24984
+ return run2(command);
24739
24985
  }
24740
24986
  });
24741
24987
  function makeNpmAlias(name, path) {
@@ -24929,6 +25175,9 @@ function installUserland(kernel) {
24929
25175
  }
24930
25176
  }
24931
25177
 
25178
+ // src/container/container.ts
25179
+ init_binary();
25180
+
24932
25181
  // src/container/fs.ts
24933
25182
  init_path();
24934
25183
  async function bytesFor(data) {
@@ -25126,7 +25375,7 @@ var Session = class {
25126
25375
  }
25127
25376
  };
25128
25377
 
25129
- // src/runtime/node-child-process-bridge.ts
25378
+ // src/node/node-child-process-bridge.ts
25130
25379
  var KernelChildProcess = class {
25131
25380
  pid;
25132
25381
  command;
@@ -25277,7 +25526,7 @@ function installNodeChildProcessBridge(pod, kernel, cred) {
25277
25526
  };
25278
25527
  }
25279
25528
 
25280
- // src/runtime/host-module-tracker.ts
25529
+ // src/node/host-module-tracker.ts
25281
25530
  var HostModuleTracker = class {
25282
25531
  active = 0;
25283
25532
  disposed = false;
@@ -25339,7 +25588,7 @@ var HostModuleTracker = class {
25339
25588
  }
25340
25589
  };
25341
25590
 
25342
- // src/runtime/commonjs-engine.ts
25591
+ // src/node/commonjs-engine.ts
25343
25592
  init_path();
25344
25593
  var HELPERS = {
25345
25594
  /** Import a specifier and return an ES-module-shaped namespace. */
@@ -26198,7 +26447,7 @@ function splitSpecifier(specifier) {
26198
26447
  return { name: parts.slice(0, size).join("/"), subpath: parts.slice(size).join("/") };
26199
26448
  }
26200
26449
 
26201
- // src/runtime/readable-from.ts
26450
+ // src/node/readable-from.ts
26202
26451
  function createReadableFrom(Readable) {
26203
26452
  return function from(source, options = {}) {
26204
26453
  if (source && typeof source.pipe === "function") return source;
@@ -26247,7 +26496,7 @@ function installReadableFrom(streamModule5) {
26247
26496
  streamModule5.Readable.from = createReadableFrom(streamModule5.Readable);
26248
26497
  }
26249
26498
 
26250
- // src/runtime/util-module.ts
26499
+ // src/node/util-module.ts
26251
26500
  var customInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
26252
26501
  var promisifyCustom = /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom");
26253
26502
  var BREAK_LENGTH = 72;
@@ -26621,7 +26870,7 @@ var utilModule = {
26621
26870
  };
26622
26871
  var util_module_default = utilModule;
26623
26872
 
26624
- // src/runtime/assert-module.ts
26873
+ // src/node/assert-module.ts
26625
26874
  var AssertionError = class extends Error {
26626
26875
  actual;
26627
26876
  expected;
@@ -26790,8 +27039,8 @@ var bytes = (data) => {
26790
27039
  if (data instanceof ArrayBuffer) return new Uint8Array(data);
26791
27040
  return data;
26792
27041
  };
26793
- function codec(name, run) {
26794
- const sync2 = (data, options) => Buffer2.from(run(bytes(data), options));
27042
+ function codec(name, run2) {
27043
+ const sync2 = (data, options) => Buffer2.from(run2(bytes(data), options));
26795
27044
  const async_ = (data, options, callback) => {
26796
27045
  const done = typeof options === "function" ? options : callback;
26797
27046
  const settings = typeof options === "function" ? void 0 : options;
@@ -26955,7 +27204,7 @@ var urlModule = {
26955
27204
  };
26956
27205
  var url_module_default = urlModule;
26957
27206
 
26958
- // src/runtime/core-modules.ts
27207
+ // src/node/core-modules.ts
26959
27208
  init_path();
26960
27209
  var VirtualIncomingMessage = class extends streamModule4__default.default.Readable {
26961
27210
  method;
@@ -27679,7 +27928,7 @@ function toBytes2(data, encoding) {
27679
27928
  return typeof data === "string" ? Buffer2.from(data, encoding) : data;
27680
27929
  }
27681
27930
 
27682
- // src/runtime/sync-channel.ts
27931
+ // src/worker/sync-channel.ts
27683
27932
  var STATE2 = 0;
27684
27933
  var LENGTH2 = 1;
27685
27934
  var MORE2 = 2;
@@ -27928,7 +28177,7 @@ function buildSyncFamily(syncSpawn, throughShell, defaultCwd, environmentFor) {
27928
28177
  spawnSync: unavailable("spawnSync")
27929
28178
  };
27930
28179
  }
27931
- const run = (file3, args, options) => {
28180
+ const run2 = (file3, args, options) => {
27932
28181
  const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
27933
28182
  const input = options.input === void 0 ? void 0 : typeof options.input === "string" ? options.input : new TextDecoder().decode(options.input);
27934
28183
  const inherit = options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[0] === "inherit";
@@ -27962,7 +28211,7 @@ ${result.stderr}`), {
27962
28211
  };
27963
28212
  const spawnSync = (file3, args = [], options = {}) => {
27964
28213
  const [list, opts] = Array.isArray(args) ? [args, options] : [[], args];
27965
- const result = run(file3, list, opts);
28214
+ const result = run2(file3, list, opts);
27966
28215
  return {
27967
28216
  pid: 0,
27968
28217
  status: result.status,
@@ -27975,9 +28224,9 @@ ${result.stderr}`), {
27975
28224
  };
27976
28225
  const execFileSync = (file3, args = [], options = {}) => {
27977
28226
  const [list, opts] = Array.isArray(args) ? [args, options] : [[], args];
27978
- return orThrow(run(file3, list, opts), [file3, ...list].join(" "), opts);
28227
+ return orThrow(run2(file3, list, opts), [file3, ...list].join(" "), opts);
27979
28228
  };
27980
- const execSync = (command, options = {}) => orThrow(run(command, [], { ...options, shell: options.shell ?? true }), command, options);
28229
+ const execSync = (command, options = {}) => orThrow(run2(command, [], { ...options, shell: options.shell ?? true }), command, options);
27981
28230
  return { spawnSync, execFileSync, execSync };
27982
28231
  }
27983
28232
  function normalize3(options, callback) {
@@ -27997,7 +28246,7 @@ function unavailable(name) {
27997
28246
  };
27998
28247
  }
27999
28248
 
28000
- // src/runtime/core-modules.ts
28249
+ // src/node/core-modules.ts
28001
28250
  init_signals();
28002
28251
  var CSI_KEYS = {
28003
28252
  "[A": "up",
@@ -28404,7 +28653,7 @@ function createReadlineModule(defaultInput, defaultOutput = () => void 0) {
28404
28653
  return { ...base2, promises: { ...base2, Interface, createInterface } };
28405
28654
  }
28406
28655
 
28407
- // src/runtime/core-modules.ts
28656
+ // src/node/core-modules.ts
28408
28657
  installReadableFrom(streamModule4__default.default);
28409
28658
  var Dirent = class {
28410
28659
  /** Node 20+ exposes the containing directory, and `fs.glob` consumers read it. */
@@ -29572,7 +29821,7 @@ var builtinNames2 = [
29572
29821
  ...stubNames
29573
29822
  ];
29574
29823
 
29575
- // src/runtime/memory-volume.ts
29824
+ // src/fs/memory-volume.ts
29576
29825
  init_path();
29577
29826
  var VolumeError = class extends Error {
29578
29827
  constructor(code, operation, path) {
@@ -29882,7 +30131,7 @@ var MemoryVolume = class {
29882
30131
  }
29883
30132
  };
29884
30133
 
29885
- // src/runtime/mirroring-volume.ts
30134
+ // src/fs/mirroring-volume.ts
29886
30135
  init_path();
29887
30136
  var MirroringVolume = class {
29888
30137
  constructor(inner = new MemoryVolume()) {
@@ -30288,7 +30537,8 @@ function sameBytes(a, b) {
30288
30537
  return true;
30289
30538
  }
30290
30539
 
30291
- // src/runtime/host-esbuild.ts
30540
+ // src/tools/host-esbuild.ts
30541
+ init_binary();
30292
30542
  var ASYNC_API = ["transform", "build", "context", "formatMessages", "analyzeMetafile"];
30293
30543
  function createHostEsbuild() {
30294
30544
  let loading = null;
@@ -30356,7 +30606,8 @@ function ensureProcessGlobal() {
30356
30606
  });
30357
30607
  }
30358
30608
 
30359
- // src/runtime/rolldown-node-binding.ts
30609
+ // src/tools/rolldown-node-binding.ts
30610
+ init_binary();
30360
30611
  async function loadNodeApi() {
30361
30612
  const [moduleApi, fsApi, pathApi, urlApi] = await Promise.all([
30362
30613
  nodeBuiltin("module"),
@@ -30474,7 +30725,7 @@ function resolveWorkerPath(node2) {
30474
30725
  const here = dirname3(fileURLToPath2((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
30475
30726
  const candidates = [
30476
30727
  join3(here, WORKER_FILE),
30477
- /* src/runtime → dist, for a checkout that has been built. */
30728
+ /* src/tools → dist, for a checkout that has been built. */
30478
30729
  join3(here, "..", "..", "dist", WORKER_FILE)
30479
30730
  ];
30480
30731
  return candidates.find((candidate) => existsSync(candidate)) ?? null;
@@ -30508,7 +30759,7 @@ function unreferenceWorker(worker) {
30508
30759
  worker.unref();
30509
30760
  }
30510
30761
 
30511
- // src/runtime/host-rolldown.ts
30762
+ // src/tools/host-rolldown.ts
30512
30763
  var BUNDLER_HINT = "If this is a bundler pre-bundling the worker away, exclude the binding from dependency optimisation \u2014 in Vite:\n\n optimizeDeps: { exclude: ['@rolldown/binding-wasm32-wasi'] }";
30513
30764
  var isNodeHost = typeof process !== "undefined" && Boolean(process.versions?.node);
30514
30765
  async function loadHostRolldownBinding() {
@@ -30535,7 +30786,7 @@ ${BUNDLER_HINT}`),
30535
30786
  }
30536
30787
  }
30537
30788
 
30538
- // src/runtime/local-runtime-pod.ts
30789
+ // src/worker/local-runtime-pod.ts
30539
30790
  init_path();
30540
30791
  var WASM_ALIASES = {
30541
30792
  esbuild: "esbuild-wasm",
@@ -31174,7 +31425,7 @@ function attachRolldownMirror(binding, volume, root) {
31174
31425
  volume.attach(fs, root);
31175
31426
  }
31176
31427
 
31177
- // src/runtime/remote-volume.ts
31428
+ // src/fs/remote-volume.ts
31178
31429
  var encoder8 = new TextEncoder();
31179
31430
  var decoder8 = new TextDecoder();
31180
31431
  function encodeFrame(header, body) {
@@ -31237,7 +31488,7 @@ function serveVolume(volume) {
31237
31488
  };
31238
31489
  }
31239
31490
 
31240
- // src/runtime/sync-syscalls.ts
31491
+ // src/worker/sync-syscalls.ts
31241
31492
  var SPAWN_OP = "spawnSync";
31242
31493
  function serveSyncSyscalls(options) {
31243
31494
  const volumeHandler = serveVolume(options.volume);