@vite-hub/sandbox 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +20 -0
  2. package/dist/{abortable-CR01hzfi.js → abortable-DrHeTo1e.js} +1 -2
  3. package/dist/{cloudflare-DOrMY3MJ.js → cloudflare-DrNRQPeh.js} +13 -17
  4. package/dist/{cloudflare-env-lookup-DzI6Xv1Y.js → cloudflare-env-lookup-BNbNil7g.js} +1 -2
  5. package/dist/{cloudflare-failure-CFQhalfh.js → cloudflare-failure-f-3P3ul-.js} +1 -2
  6. package/dist/{container-BVb0fw3z.js → container-DOadzngt.js} +7 -9
  7. package/dist/{crabbox-BU8W1gVC.js → crabbox-C7KeIKnH.js} +7 -8
  8. package/dist/{error-diagnostics-BJtLRL9w.js → error-diagnostics-CApUyzzu.js} +1 -2
  9. package/dist/{error-diagnostics-BNQwU9yq.js → error-diagnostics-D9n0ZmdN.js} +8 -5
  10. package/dist/{file-listing-CHtRrfo1.js → file-listing-BF122soX.js} +3 -4
  11. package/dist/{file-lock-D0-XPogS.js → file-lock-CqA7b491.js} +3 -4
  12. package/dist/{index-DHl0T43e.d.ts → index-D9DogaoF.d.ts} +0 -14
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +12 -13
  15. package/dist/internal/cloudflare.d.ts +2 -5
  16. package/dist/internal/cloudflare.js +3 -4
  17. package/dist/internal/host-toolchain.d.ts +2 -4
  18. package/dist/internal/host-toolchain.js +4 -5
  19. package/dist/internal/vercel.d.ts +2 -4
  20. package/dist/internal/vercel.js +3 -4
  21. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  22. package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
  23. package/dist/{module-types-NYnG3NGz.d.ts → module-types-DHr6oC3h.d.ts} +18 -13
  24. package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
  25. package/dist/{provider-loader-Cvqoz7_Z.d.ts → provider-loader-CLIIEEmR.d.ts} +2 -6
  26. package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-qvRcW1PC.js} +13 -10
  27. package/dist/{remote-fjUPBiLJ.js → remote-DlyX1drC.js} +5 -6
  28. package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
  29. package/dist/{runtime-DHp6ImeP.js → runtime-EtWFVKud.js} +1 -2
  30. package/dist/{runtime-type-Deo4qzxN.js → runtime-type-Dk-rJXlr.js} +1 -2
  31. package/dist/{session-e0lyzjJ3.js → session-DmUiyj4O.js} +5 -8
  32. package/dist/{shell-quote-Q3u3plif.js → shell-quote-MrD49m3N.js} +1 -2
  33. package/dist/ssh.d.ts +1 -3
  34. package/dist/ssh.js +5 -7
  35. package/dist/task/index.d.ts +2 -16
  36. package/dist/task/index.js +345 -142
  37. package/dist/task/runtime/empty-registry.d.ts +0 -2
  38. package/dist/task/runtime/empty-registry.js +1 -2
  39. package/dist/task/runtime/provider-loader.d.ts +1 -1
  40. package/dist/task/runtime/provider-loader.js +2 -3
  41. package/dist/task/runtime/providers/cloudflare.d.ts +3 -4
  42. package/dist/task/runtime/providers/cloudflare.js +3 -4
  43. package/dist/task/runtime/providers/local.d.ts +2 -4
  44. package/dist/task/runtime/providers/local.js +3 -4
  45. package/dist/task/runtime/providers/vercel.d.ts +3 -4
  46. package/dist/task/runtime/providers/vercel.js +6 -8
  47. package/dist/task/runtime/state.d.ts +3 -4
  48. package/dist/task/runtime/state.js +2 -3
  49. package/dist/task/vite.d.ts +23 -24
  50. package/dist/task/vite.js +63 -74
  51. package/dist/{toolchain-DF9eutyQ.js → toolchain-DFFxmw3N.js} +6 -7
  52. package/dist/transfer-options-LTUzbHDw.js +18 -0
  53. package/dist/{trusted-host-DLYiKP8a.js → trusted-host-CwMs64h1.js} +8 -9
  54. package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
  55. package/dist/{vercel-qyDr7NvU.js → vercel-DT74kDyI.js} +9 -13
  56. package/dist/{vercel-credentials-BNTh2X-Y.js → vercel-credentials-BH5lPJxs.js} +3 -5
  57. package/package.json +10 -10
package/dist/task/vite.js CHANGED
@@ -1,7 +1,8 @@
1
- import { n as invariantError, t as invariant } from "../invariant-DolT9EEx.js";
2
- import { t as sandboxTaskErrorDiagnostics } from "../error-diagnostics-BNQwU9yq.js";
3
- import { t as getSandboxTaskFeatureDriver } from "../module-types-B0LQ5H2S.js";
4
- import { a as resolveCloudflareSandboxTaskInstanceType, i as readSandboxTaskSize, n as assertCloudflareInstanceTypeFits, o as resolveVercelSandboxTaskVcpus, r as describeCloudflareInstanceType, t as vercelCredentialEnv } from "../vercel-credentials-BNTh2X-Y.js";
1
+ import { t as sandboxTaskErrorDiagnostics } from "../error-diagnostics-D9n0ZmdN.js";
2
+ import { a as resolveCloudflareSandboxTaskInstanceType, i as readSandboxTaskSize, n as assertCloudflareInstanceTypeFits, o as resolveVercelSandboxTaskVcpus, r as describeCloudflareInstanceType, t as vercelCredentialEnv } from "../vercel-credentials-BH5lPJxs.js";
3
+ import { n as invariantError, t as invariant } from "../invariant-Dj2R1eMr.js";
4
+ import { t as assertSandboxTaskTransferOptions } from "../transfer-options-LTUzbHDw.js";
5
+ import { t as getSandboxTaskFeatureDriver } from "../module-types-CWcBHyEs.js";
5
6
  import { builtinModules, createRequire, isBuiltin } from "node:module";
6
7
  import { createHash, randomUUID } from "node:crypto";
7
8
  import { copyFile, glob, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, stat, symlink, writeFile } from "node:fs/promises";
@@ -16,7 +17,7 @@ import { findDynamicImports, resolvePathSync } from "mlly";
16
17
  import { resolveModule } from "local-pkg";
17
18
  import { dirname as dirname$2, join as join$2, normalize as normalize$1 } from "node:path/posix";
18
19
  import picomatch from "picomatch";
19
- //#region ../internal/src/build/paths.ts
20
+ // ../internal/src/build/paths.ts
20
21
  function generatedDirSegments(productName) {
21
22
  return [".vitehub", productName];
22
23
  }
@@ -36,16 +37,14 @@ function realpathIfExists(path) {
36
37
  return resolve$1(path);
37
38
  }
38
39
  }
39
- //#endregion
40
- //#region ../internal/src/inspect.ts
40
+ // ../internal/src/inspect.ts
41
41
  function relativeDefinitionFile(projectRoot, file) {
42
42
  return relative$1(projectRoot, file).replaceAll("\\", "/");
43
43
  }
44
44
  const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
45
45
  new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
46
46
  new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
47
- //#endregion
48
- //#region ../internal/src/error-diagnostics.ts
47
+ // ../internal/src/error-diagnostics.ts
49
48
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
50
49
  const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
51
50
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
@@ -302,6 +301,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
302
301
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
303
302
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
304
303
  },
304
+ INTERNAL_SITE_TOKEN_TOO_LONG: {
305
+ why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
306
+ fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
307
+ },
305
308
  INTERNAL_SQLITE_ARGUMENT_INVALID: {
306
309
  why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
307
310
  fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
@@ -316,8 +319,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
316
319
  }
317
320
  }
318
321
  });
319
- //#endregion
320
- //#region ../internal/src/object.ts
322
+ // ../internal/src/object.ts
321
323
  /** A non-null object that is not an array. Functions do not pass. */
322
324
  function isRecord(value) {
323
325
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -328,8 +330,7 @@ function isPlainRecord(value) {
328
330
  if (prototype === null) return true;
329
331
  return Object.getPrototypeOf(prototype) === null && Object.hasOwn(prototype, "constructor") && prototype.constructor?.name === "Object";
330
332
  }
331
- //#endregion
332
- //#region ../internal/src/build/vite.ts
333
+ // ../internal/src/build/vite.ts
333
334
  const projectRootDirectoryMarkers = [
334
335
  ["server", "agents"],
335
336
  ["server", "channels"],
@@ -442,8 +443,7 @@ function hostFromNitroPreset(value) {
442
443
  if (normalized === "node" || normalized.startsWith("node-")) return "node";
443
444
  if (normalized.startsWith("vercel")) return "vercel";
444
445
  }
445
- //#endregion
446
- //#region ../internal/src/hosting.ts
446
+ // ../internal/src/hosting.ts
447
447
  /**
448
448
  * Returns the Nitro preset name that this build targets, as the developer wrote it.
449
449
  * The order is `nitro.preset`, `hosting`, `NITRO_PRESET`, `SERVER_PRESET`, then `VITEHUB_HOST`.
@@ -475,8 +475,7 @@ function getSupportedHostingProvider(hosting, supportedProviders) {
475
475
  if (!provider || !supportedProviders.includes(provider)) return void 0;
476
476
  return provider;
477
477
  }
478
- //#endregion
479
- //#region ../internal/src/definition-catalog.ts
478
+ // ../internal/src/definition-catalog.ts
480
479
  const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
481
480
  const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
482
481
  const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
@@ -618,8 +617,7 @@ function mergeNitroExternal(value, addition) {
618
617
  if (typeof value === "function") return (source, importer, isResolved) => source === addition || Boolean(value(source, importer, isResolved));
619
618
  return value;
620
619
  }
621
- //#endregion
622
- //#region src/task/internal/shared/cloudflare-wrangler.ts
620
+ // src/task/internal/shared/cloudflare-wrangler.ts
623
621
  function compareNumericStrings(left, right) {
624
622
  return left.localeCompare(right, void 0, { numeric: true });
625
623
  }
@@ -718,8 +716,7 @@ function finalizeCloudflareWranglerConfig(target) {
718
716
  wrangler.migrations = mergeMigrations(wrangler.migrations);
719
717
  validateDurableObjectMigrations(wrangler);
720
718
  }
721
- //#endregion
722
- //#region src/task/cloudflare.ts
719
+ // src/task/cloudflare.ts
723
720
  const defaultCloudflareSandboxBinding = "SANDBOX";
724
721
  const defaultCloudflareSandboxClassName = "Sandbox";
725
722
  const defaultCloudflareSandboxMaxInstances = 12;
@@ -917,8 +914,7 @@ async function configureCloudflareSandboxNitro(targetValue, rootDir, options = {
917
914
  if (finalizeWrangler) finalizeCloudflareWranglerConfig(target);
918
915
  return target;
919
916
  }
920
- //#endregion
921
- //#region src/task/internal/typescript.ts
917
+ // src/task/internal/typescript.ts
922
918
  const require = createRequire(import.meta.url);
923
919
  function loadTypeScript() {
924
920
  try {
@@ -928,8 +924,7 @@ function loadTypeScript() {
928
924
  throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_C0013({ message: "[vitehub] Sandbox Tasks read their definitions with TypeScript. Install `typescript` in the app." });
929
925
  }
930
926
  }
931
- //#endregion
932
- //#region src/task/internal/shared/discovered-definition/ast.ts
927
+ // src/task/internal/shared/discovered-definition/ast.ts
933
928
  const filesystemModuleSpecifiers = /* @__PURE__ */ new Set([
934
929
  "child_process",
935
930
  "fs",
@@ -1433,13 +1428,11 @@ async function injectTypeImportsFromUnimport(source, id, imports) {
1433
1428
  }
1434
1429
  return injectTypeImports(source, pendingImports, id);
1435
1430
  }
1436
- //#endregion
1437
- //#region src/task/internal/shared/server-imports.ts
1431
+ // src/task/internal/shared/server-imports.ts
1438
1432
  function isServerAutoImportEnabled(imports) {
1439
1433
  return imports !== false && imports?.autoImport !== false;
1440
1434
  }
1441
- //#endregion
1442
- //#region src/task/internal/shared/discovered-definition/bundler.ts
1435
+ // src/task/internal/shared/discovered-definition/bundler.ts
1443
1436
  function isJsxDefinition(filename) {
1444
1437
  return filename.endsWith(".tsx") || filename.endsWith(".jsx");
1445
1438
  }
@@ -1508,8 +1501,7 @@ async function bundleDiscoveredDefinitionModuleGraph(options) {
1508
1501
  modules
1509
1502
  };
1510
1503
  }
1511
- //#endregion
1512
- //#region src/task/internal/shared/discovered-definition.ts
1504
+ // src/task/internal/shared/discovered-definition.ts
1513
1505
  function normalizeDir(rootDir, dir) {
1514
1506
  if (typeof dir === "string") return isAbsolute$1(dir) ? dir : resolve$1(rootDir, dir);
1515
1507
  return {
@@ -1595,18 +1587,15 @@ async function createDiscoveredDefinitionCompiler(options = {}) {
1595
1587
  return await injectSource(await readFile(id, "utf8"), id);
1596
1588
  } };
1597
1589
  }
1598
- //#endregion
1599
- //#region src/task/internal/shared/feature-definitions.ts
1590
+ // src/task/internal/shared/feature-definitions.ts
1600
1591
  function toTemplateSafeName(name) {
1601
1592
  return name.replace(/[^a-z0-9/_:-]/gi, "_").replace(/\//g, "__").replace(/:/g, "__");
1602
1593
  }
1603
- //#endregion
1604
- //#region src/task/internal/shared/file-import-specifier.ts
1594
+ // src/task/internal/shared/file-import-specifier.ts
1605
1595
  function createFileImportSpecifier(file, platform = process.platform) {
1606
1596
  return pathToFileURL(file, { windows: platform === "win32" }).href;
1607
1597
  }
1608
- //#endregion
1609
- //#region src/task/internal/shared/module-resolve.ts
1598
+ // src/task/internal/shared/module-resolve.ts
1610
1599
  function normalizePaths(paths) {
1611
1600
  if (paths?.length) return paths;
1612
1601
  if (typeof process !== "undefined") return [process.cwd()];
@@ -1635,8 +1624,7 @@ function tryResolveModule(id, options = {}) {
1635
1624
  continue;
1636
1625
  }
1637
1626
  }
1638
- //#endregion
1639
- //#region src/task/internal/shared/feature-runtime-path.ts
1627
+ // src/task/internal/shared/feature-runtime-path.ts
1640
1628
  function resolveExistingModulePath(path) {
1641
1629
  if (existsSync(path)) return path;
1642
1630
  for (const extension of [
@@ -1668,8 +1656,7 @@ function resolveFeatureRuntimePath(importMetaUrl, packageId, sourceRelativePath,
1668
1656
  if (packagePath) return join$1(dirname$1(packagePath), distRelativePath);
1669
1657
  return sourcePath;
1670
1658
  }
1671
- //#endregion
1672
- //#region src/task/project.ts
1659
+ // src/task/project.ts
1673
1660
  const sandboxTaskProjectSourceFiles = /* @__PURE__ */ new WeakMap();
1674
1661
  function getSandboxTaskProjectSourceFiles(project) {
1675
1662
  return sandboxTaskProjectSourceFiles.get(project) || [];
@@ -1754,13 +1741,16 @@ function parseSandboxTaskProjectOptions(manifest, path) {
1754
1741
  const sandbox = manifest.vitehub.sandboxTask;
1755
1742
  if (typeof sandbox === "undefined") return void 0;
1756
1743
  if (!isRecord(sandbox)) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0058({ message: `[vitehub] Sandbox package manifest "vitehub.sandboxTask" must be an object: ${path}` });
1757
- const unsupported = Object.keys(sandbox).filter((key) => key !== "timeout");
1744
+ const unsupported = Object.keys(sandbox).filter((key) => key !== "timeout" && key !== "transfer");
1758
1745
  if (unsupported.length) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0059({ message: `[vitehub] Sandbox package manifest "vitehub.sandboxTask" has unsupported keys: ${unsupported.join(", ")}.` });
1759
- const timeout = sandbox.timeout;
1760
- if (timeout === void 0) return void 0;
1761
- const numericTimeout = Number(timeout);
1762
- if (numericTimeout !== timeout || !Number.isInteger(numericTimeout) || numericTimeout <= 0 || numericTimeout > maxTimeout) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0060({ message: `[vitehub] Sandbox package manifest "vitehub.sandboxTask.timeout" must be a positive integer no greater than ${maxTimeout}.` });
1763
- return { timeout: numericTimeout };
1746
+ const { timeout, transfer } = sandbox;
1747
+ if (timeout !== void 0 && (typeof timeout !== "number" || !Number.isInteger(timeout) || timeout <= 0 || timeout > maxTimeout)) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0060({ message: `[vitehub] Sandbox package manifest "vitehub.sandboxTask.timeout" must be a positive integer no greater than ${maxTimeout}.` });
1748
+ assertSandboxTaskTransferOptions(transfer);
1749
+ if (timeout === void 0 && transfer === void 0) return void 0;
1750
+ return {
1751
+ ...timeout === void 0 ? {} : { timeout },
1752
+ ...transfer === void 0 ? {} : { transfer }
1753
+ };
1764
1754
  }
1765
1755
  function pnpmPatchPaths(manifest) {
1766
1756
  if (!isRecord(manifest.pnpm) || !isRecord(manifest.pnpm.patchedDependencies)) return [];
@@ -1931,8 +1921,7 @@ async function findLockfile(directories, root, manager) {
1931
1921
  };
1932
1922
  }
1933
1923
  }
1934
- //#endregion
1935
- //#region src/task/internal/package-entry.ts
1924
+ // src/task/internal/package-entry.ts
1936
1925
  const runtimeExportConditions = /* @__PURE__ */ new Set([
1937
1926
  "default",
1938
1927
  "import",
@@ -2269,8 +2258,7 @@ function prepareExecutablePackageProject(project, entry) {
2269
2258
  }
2270
2259
  };
2271
2260
  }
2272
- //#endregion
2273
- //#region src/task/bundle.ts
2261
+ // src/task/bundle.ts
2274
2262
  const SHIM_NAMESPACE = "vitehub-sandbox-task-runtime-shim";
2275
2263
  const SHIM_ID = `\0${SHIM_NAMESPACE}`;
2276
2264
  const builtinModuleSet$1 = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
@@ -2420,8 +2408,7 @@ async function bundleSandboxTaskDefinition(source, file, options = {}) {
2420
2408
  }
2421
2409
  };
2422
2410
  }
2423
- //#endregion
2424
- //#region src/task/definition-options.ts
2411
+ // src/task/definition-options.ts
2425
2412
  const sandboxTaskDefinitionSyntax = "`defineSandboxTask({ handler, ...options })`";
2426
2413
  function readStaticValue(node) {
2427
2414
  const ts = loadTypeScript();
@@ -2557,8 +2544,7 @@ async function extractSandboxTaskDefinitionMetadata(file) {
2557
2544
  ...project !== void 0 ? { project } : {}
2558
2545
  } : void 0;
2559
2546
  }
2560
- //#endregion
2561
- //#region src/task/type-template.ts
2547
+ // src/task/type-template.ts
2562
2548
  const sandboxTaskTypeTemplateFilename = "runtime/sandbox-task.d.ts";
2563
2549
  function createDefinitionContract(definition) {
2564
2550
  const module = `typeof import(${JSON.stringify(definition.handler)})`;
@@ -2582,8 +2568,7 @@ function createSandboxTaskTypeTemplateContents(definitions) {
2582
2568
  ``
2583
2569
  ].join("\n");
2584
2570
  }
2585
- //#endregion
2586
- //#region src/task/feature.ts
2571
+ // src/task/feature.ts
2587
2572
  const sandboxTaskRuntimeStateSpecifier = "@vite-hub/sandbox/task/runtime/state";
2588
2573
  const sandboxTaskRuntimeSpecifier = "@vite-hub/sandbox/internal/task/runtime";
2589
2574
  const sandboxTaskRuntimeProviderSpecifiers = {
@@ -2819,8 +2804,7 @@ async function createSandboxTaskFeaturePlan(sandboxTaskConfig, definitions, path
2819
2804
  cloudflare: cloudflareOptions
2820
2805
  };
2821
2806
  }
2822
- //#endregion
2823
- //#region src/task/discovery.ts
2807
+ // src/task/discovery.ts
2824
2808
  const sandboxTaskSuffixPattern = /\.sandbox-task\.(?:c|m)?[jt]s$/i;
2825
2809
  const sandboxTaskEntrypointFilenames = [
2826
2810
  "index.ts",
@@ -2891,8 +2875,7 @@ function discoverSandboxTaskDefinitions(options) {
2891
2875
  const serverScanDirs = roots.map((root) => resolve$1(root, "server"));
2892
2876
  return mergeDefinitions("Sandbox Task", discoverDefinitions("Sandbox Task", [createSuffixDefinitionSource("vite-suffix", roots, sandboxTaskSuffixPattern, normalizeSuffixSandboxTaskName, { createDefinition: createDiscoveredSandboxTaskDefinition("vite-suffix", "definition") })]), discoverServerSandboxTaskDefinitions(serverScanDirs));
2893
2877
  }
2894
- //#endregion
2895
- //#region src/task/internal/runtime-generation.ts
2878
+ // src/task/internal/runtime-generation.ts
2896
2879
  const generationMarker = "// vitehub-sandbox-task-generation: ";
2897
2880
  const generationLockClaimStaleMs = 3e4;
2898
2881
  const generationLockInitializationStaleMs = 5e3;
@@ -3248,8 +3231,7 @@ async function pruneSandboxTaskRuntimeGeneration(path, remove = rm) {
3248
3231
  force: true
3249
3232
  }).catch(() => {});
3250
3233
  }
3251
- //#endregion
3252
- //#region src/task/internal/runtime-preparation.ts
3234
+ // src/task/internal/runtime-preparation.ts
3253
3235
  const SANDBOX_PACKAGE_ID$1 = "@vite-hub/sandbox/task";
3254
3236
  const SANDBOX_REGISTRY_ID = "#vitehub-sandbox-task-registry";
3255
3237
  const builtinModuleSet = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
@@ -3595,8 +3577,7 @@ async function prepareSandboxTaskRuntime(options) {
3595
3577
  watchFiles: plan.watchFiles || []
3596
3578
  };
3597
3579
  }
3598
- //#endregion
3599
- //#region src/task/inspect.ts
3580
+ // src/task/inspect.ts
3600
3581
  /** Lists Sandbox Task Definitions and package entries as serializable inspection summaries. */
3601
3582
  function inspectSandboxTaskDefinitions(options) {
3602
3583
  return discoverSandboxTaskDefinitions({ rootDir: options.rootDir }).map((definition) => ({
@@ -3649,8 +3630,7 @@ const sandboxTaskConsoleSection = {
3649
3630
  notice: "Running Sandbox Tasks, files, processes, logs, ports, and lifecycle state are not included in this build-time catalog."
3650
3631
  }
3651
3632
  };
3652
- //#endregion
3653
- //#region src/task/deployment-env.ts
3633
+ // src/task/deployment-env.ts
3654
3634
  const owners = ["sandbox"];
3655
3635
  /**
3656
3636
  * The variables that Sandbox Tasks read on the deployed host. A Vercel Sandbox reads its token, team, and project from
@@ -3673,19 +3653,20 @@ function sandboxDeploymentEnv(config, driver, context) {
3673
3653
  owners
3674
3654
  }]);
3675
3655
  }
3676
- //#endregion
3677
- //#region src/task/vite.ts
3656
+ // src/task/vite.ts
3678
3657
  const SANDBOX_PACKAGE_ID = "@vite-hub/sandbox/task";
3679
3658
  const SANDBOX_PACKAGE_NAME = "@vite-hub/sandbox";
3680
3659
  const SANDBOX_PROVIDER_LOADER_ID = "vitehub-sandbox-task-provider-loader";
3681
3660
  const SANDBOX_STATE_ID = "#vitehub/sandbox-task";
3682
3661
  const RESOLVED_SANDBOX_STATE_ID = "\0vitehub:sandbox-task:state";
3683
3662
  const SANDBOX_STATE_ID_PATTERN = /^(?:#vitehub\/sandbox-task|\0vitehub:sandbox-task:state)$/;
3684
- function mergeSandboxTaskNitroProviderAliases(nitro, aliases) {
3663
+ function mergeSandboxTaskNitroProviderAliases(nitro, aliases, frameworkSpecifier) {
3685
3664
  const providerAliases = Object.fromEntries(sandboxTaskProviderLoaderSpecifiers.flatMap((specifier) => {
3686
3665
  const replacement = aliases[specifier];
3687
3666
  return replacement ? [[specifier, replacement]] : [];
3688
3667
  }));
3668
+ const facade = aliases[SANDBOX_PACKAGE_ID];
3669
+ if (frameworkSpecifier && facade) providerAliases[frameworkSpecifier] = facade;
3689
3670
  if (!Object.keys(providerAliases).length) return;
3690
3671
  nitro.alias = {
3691
3672
  ...isRecord(nitro.alias) ? nitro.alias : {},
@@ -3815,14 +3796,23 @@ function hubSandboxTask(options) {
3815
3796
  if (localDev && nitroOptions?.dev && runner === "miniflare") throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_LOCAL_NITRO_RUNNER();
3816
3797
  }
3817
3798
  const sandboxTaskNitroModule = (nitro) => {
3818
- const options = nitro.options;
3799
+ const { options } = nitro;
3819
3800
  nitroOptions = options;
3820
3801
  assertLocalDevRunner();
3821
3802
  mergeSandboxTaskNitroNoExternals(options, selectedProvider);
3822
- if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases);
3803
+ if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases, internalOptions?.providerImportSpecifier);
3823
3804
  nitro.hooks.hook("build:before", () => {
3824
3805
  mergeSandboxTaskNitroNoExternals(options, selectedProvider);
3825
- if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases);
3806
+ if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases, internalOptions?.providerImportSpecifier);
3807
+ });
3808
+ if (options.dev) nitro.hooks.hook("build:config", (_nitro, config) => {
3809
+ const resolver = config.builder === "rolldown" ? config.rolldown?.resolve : void 0;
3810
+ const specifier = internalOptions?.providerImportSpecifier;
3811
+ const facade = generatedAliases[SANDBOX_PACKAGE_ID];
3812
+ if (resolver && selectedProvider && specifier && facade) resolver.alias = {
3813
+ ...resolver.alias,
3814
+ [specifier]: facade
3815
+ };
3826
3816
  });
3827
3817
  };
3828
3818
  function cloneConfigValue(value) {
@@ -3992,5 +3982,4 @@ function hubSandboxTask(options) {
3992
3982
  }
3993
3983
  };
3994
3984
  }
3995
- //#endregion
3996
3985
  export { discoverSandboxTaskDefinitions, hubSandboxTask, inspectSandboxTaskDefinitions, sandboxTaskConsoleSection, sandboxTaskRuntimeStateModule };
@@ -1,11 +1,11 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { t as sandboxErrorDiagnostics } from "./error-diagnostics-BJtLRL9w.js";
3
- import { t as shellQuote } from "./shell-quote-Q3u3plif.js";
4
- import { t as abortable } from "./abortable-CR01hzfi.js";
5
- import { t as runtimeRecord } from "./runtime-type-Deo4qzxN.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
3
+ import { t as abortable } from "./abortable-DrHeTo1e.js";
4
+ import { t as runtimeRecord } from "./runtime-type-Dk-rJXlr.js";
5
+ import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { maxSatisfying, minVersion, rcompare, valid, validRange } from "semver";
8
- //#region src/internal/toolchain.ts
8
+ // src/internal/toolchain.ts
9
9
  var toolchain_exports = /* @__PURE__ */ __exportAll({
10
10
  nodeDistribution: () => nodeDistribution,
11
11
  normalizeToolchain: () => normalizeToolchain,
@@ -518,5 +518,4 @@ function trimSlash(value) {
518
518
  function processEnvironment() {
519
519
  return globalThis.process?.env ?? {};
520
520
  }
521
- //#endregion
522
521
  export { verifyToolchain as a, toolchain_exports as i, provisionToolchain as n, toolchainProjectFiles as r, normalizeToolchain as t };
@@ -0,0 +1,18 @@
1
+ import { t as sandboxTaskErrorDiagnostics } from "./error-diagnostics-D9n0ZmdN.js";
2
+ // src/task/transfer-options.ts
3
+ const transferKeys = /* @__PURE__ */ new Set([
4
+ "maxInputBytes",
5
+ "maxOutputBytes",
6
+ "maxDepth",
7
+ "maxSidecars",
8
+ "maxSidecarBytes"
9
+ ]);
10
+ const maxTransferLimit = 1073741824;
11
+ function assertSandboxTaskTransferOptions(transfer) {
12
+ if (transfer === void 0) return;
13
+ if (typeof transfer !== "object" || transfer === null || Array.isArray(transfer)) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_TRANSFER_INVALID({ problem: "must be an object" });
14
+ const invalidKeys = Object.keys(transfer).filter((key) => !transferKeys.has(key));
15
+ if (invalidKeys.length > 0) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_TRANSFER_INVALID({ problem: `supports only ${[...transferKeys].join(", ")}. Unsupported: ${invalidKeys.join(", ")}` });
16
+ for (const [key, value] of Object.entries(transfer)) if (value !== void 0 && (!Number.isSafeInteger(value) || value <= 0 || value > maxTransferLimit)) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_TRANSFER_INVALID({ problem: `sets ${key} to ${String(value)}. Each limit must be a whole number from 1 to ${maxTransferLimit}` });
17
+ }
18
+ export { assertSandboxTaskTransferOptions as t };
@@ -1,10 +1,10 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { r as markBuiltInSandboxRuntime } from "./runtime-DHp6ImeP.js";
3
- import { t as sandboxErrorDiagnostics } from "./error-diagnostics-BJtLRL9w.js";
4
- import { t as stopMarkedProcesses } from "./process-sweep-CMaujWE5.js";
5
- import { a as sandboxRequirementSecrets, i as sandboxRequirementPlan, n as collectSandboxRequirementOutput, o as sandboxRequirementSignal, r as sandboxRequirementError, s as materializeGitCheckout, t as createSandboxSession } from "./session-e0lyzjJ3.js";
6
- import { t as acquireFileLock } from "./file-lock-D0-XPogS.js";
7
- import { t as isTrustedHostReservedCommandEnvironmentKey } from "./trusted-host-environment-CWKJ7DD_.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
3
+ import { t as stopMarkedProcesses } from "./process-sweep-DVaTb2pO.js";
4
+ import { t as isTrustedHostReservedCommandEnvironmentKey } from "./trusted-host-environment-BJE5hGtQ.js";
5
+ import { a as sandboxRequirementSecrets, i as sandboxRequirementPlan, n as collectSandboxRequirementOutput, o as sandboxRequirementSignal, r as sandboxRequirementError, s as materializeGitCheckout, t as createSandboxSession } from "./session-DmUiyj4O.js";
6
+ import { r as markBuiltInSandboxRuntime } from "./runtime-EtWFVKud.js";
7
+ import { t as acquireFileLock } from "./file-lock-CqA7b491.js";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import { access, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, symlink, writeFile } from "node:fs/promises";
10
10
  import { basename, delimiter, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
@@ -14,7 +14,7 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
14
14
  import { tmpdir } from "node:os";
15
15
  import { constants } from "node:fs";
16
16
  import { Readable, Writable } from "node:stream";
17
- //#region src/internal/trusted-host.ts
17
+ // src/internal/trusted-host.ts
18
18
  var trusted_host_exports = /* @__PURE__ */ __exportAll({ createTrustedHostRuntime: () => createTrustedHostRuntime });
19
19
  const baseEnvironmentKeys = [
20
20
  "ComSpec",
@@ -719,5 +719,4 @@ function waitForExit(child) {
719
719
  if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();
720
720
  return new Promise((resolvePromise) => child.once("close", () => resolvePromise()));
721
721
  }
722
- //#endregion
723
722
  export { trusted_host_exports as n, createTrustedHostRuntime as t };
@@ -1,4 +1,4 @@
1
- //#region src/internal/trusted-host-environment.ts
1
+ // src/internal/trusted-host-environment.ts
2
2
  const reservedCommandEnvironmentKeys = /* @__PURE__ */ new Set([
3
3
  "CODEX_HOME",
4
4
  "HOME",
@@ -12,5 +12,4 @@ const reservedCommandEnvironmentKeys = /* @__PURE__ */ new Set([
12
12
  function isTrustedHostReservedCommandEnvironmentKey(name) {
13
13
  return reservedCommandEnvironmentKeys.has(name);
14
14
  }
15
- //#endregion
16
15
  export { isTrustedHostReservedCommandEnvironmentKey as t };
@@ -1,17 +1,14 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { r as markBuiltInSandboxRuntime } from "./runtime-DHp6ImeP.js";
3
- import { t as sandboxErrorDiagnostics } from "./error-diagnostics-BJtLRL9w.js";
4
- import { t as shellQuote } from "./shell-quote-Q3u3plif.js";
5
- import { t as listCommandFiles } from "./file-listing-CHtRrfo1.js";
6
- import { i as resolveRemoteEnvironment, n as openRemoteSandbox, r as remoteSandboxPlan, t as collectProcessOutput } from "./remote-fjUPBiLJ.js";
7
- import { n as killOnAbort } from "./abortable-CR01hzfi.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { t as listCommandFiles } from "./file-listing-BF122soX.js";
3
+ import { i as resolveRemoteEnvironment, n as openRemoteSandbox, r as remoteSandboxPlan, t as collectProcessOutput } from "./remote-DlyX1drC.js";
4
+ import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
5
+ import { r as markBuiltInSandboxRuntime } from "./runtime-EtWFVKud.js";
6
+ import { n as killOnAbort } from "./abortable-DrHeTo1e.js";
7
+ import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { posix } from "node:path";
10
- //#region src/vercel.ts
11
- var vercel_exports = /* @__PURE__ */ __exportAll({
12
- createVercelRuntime: () => createVercelRuntime,
13
- loadVercelSandbox: () => loadVercelSandbox
14
- });
10
+ // src/vercel.ts
11
+ var vercel_exports = /* @__PURE__ */ __exportAll({ createVercelRuntime: () => createVercelRuntime });
15
12
  const vercelSignalNames = [
16
13
  "SIGHUP",
17
14
  "SIGINT",
@@ -356,5 +353,4 @@ function vercelSignal(signal) {
356
353
  });
357
354
  return known;
358
355
  }
359
- //#endregion
360
356
  export { loadVercelSandbox as n, vercel_exports as r, createVercelRuntime as t };
@@ -1,5 +1,5 @@
1
- import { t as sandboxTaskErrorDiagnostics } from "./error-diagnostics-BNQwU9yq.js";
2
- //#region src/task/size.ts
1
+ import { t as sandboxTaskErrorDiagnostics } from "./error-diagnostics-D9n0ZmdN.js";
2
+ // src/task/size.ts
3
3
  const cloudflareInstanceTypes = [
4
4
  {
5
5
  name: "lite",
@@ -114,8 +114,7 @@ function resolveVercelSandboxTaskVcpus(options) {
114
114
  function formatRequest(cpu, memory) {
115
115
  return [cpu === void 0 ? "" : `cpu: ${cpu}`, memory === void 0 ? "" : `memory: ${memory}`].filter(Boolean).join(", ");
116
116
  }
117
- //#endregion
118
- //#region src/task/vercel-credentials.ts
117
+ // src/task/vercel-credentials.ts
119
118
  const vercelCredentialEnv = {
120
119
  token: {
121
120
  names: ["VITE_SANDBOX_TOKEN", "VERCEL_TOKEN"],
@@ -130,5 +129,4 @@ const vercelCredentialEnv = {
130
129
  secret: false
131
130
  }
132
131
  };
133
- //#endregion
134
132
  export { resolveCloudflareSandboxTaskInstanceType as a, readSandboxTaskSize as i, assertCloudflareInstanceTypeFits as n, resolveVercelSandboxTaskVcpus as o, describeCloudflareInstanceType as r, vercelCredentialEnv as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/sandbox",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Portable, isolated Sandboxes for ViteHub Agents, and Sandbox Tasks that run named package projects in them.",
5
5
  "keywords": [
6
6
  "agent",
@@ -114,19 +114,19 @@
114
114
  }
115
115
  },
116
116
  "dependencies": {
117
- "@vite-hub/runtime": "0.5.0",
118
- "local-pkg": "^1.2.1",
117
+ "@vite-hub/runtime": "0.6.0",
118
+ "local-pkg": "^2.0.0",
119
119
  "mlly": "^1.8.2",
120
120
  "nostics": "1.4.0",
121
121
  "pathe": "^2.0.3",
122
122
  "picomatch": "^4.0.7",
123
- "semver": "^7.8.5",
124
- "unimport": "^6.5.0",
123
+ "semver": "^7.8.6",
124
+ "unimport": "^7.0.3",
125
125
  "yaml": "^2.9.1"
126
126
  },
127
127
  "devDependencies": {
128
128
  "@cloudflare/sandbox": "^1.0.3",
129
- "@types/node": "^24.19.1",
129
+ "@types/node": "^24.19.2",
130
130
  "@types/picomatch": "^4.0.3",
131
131
  "@types/semver": "^7.8.0",
132
132
  "@types/ssh2": "^1.15.6",
@@ -136,12 +136,12 @@
136
136
  "miniflare": "4.20260730.0",
137
137
  "ofetch": "^1.5.1",
138
138
  "publint": "^0.3.25",
139
- "rollup": "^4.64.0",
139
+ "rollup": "^4.68.8",
140
140
  "ssh2": "^1.17.0",
141
141
  "typescript": "^6.0.3",
142
- "vite": "^8.2.2",
143
- "vite-plus": "^0.3.3",
144
- "vitest": "^4.1.11",
142
+ "vite": "^8.3.8",
143
+ "vite-plus": "^1.7.0",
144
+ "vitest": "5.1.0",
145
145
  "zod": "^4.6.7"
146
146
  },
147
147
  "peerDependencies": {