@vite-hub/sandbox 0.5.0 → 0.5.1

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 (55) hide show
  1. package/dist/{abortable-CR01hzfi.js → abortable-DrHeTo1e.js} +1 -2
  2. package/dist/{cloudflare-DOrMY3MJ.js → cloudflare-DrNRQPeh.js} +13 -17
  3. package/dist/{cloudflare-env-lookup-DzI6Xv1Y.js → cloudflare-env-lookup-BNbNil7g.js} +1 -2
  4. package/dist/{cloudflare-failure-CFQhalfh.js → cloudflare-failure-f-3P3ul-.js} +1 -2
  5. package/dist/{container-BVb0fw3z.js → container-DOadzngt.js} +7 -9
  6. package/dist/{crabbox-BU8W1gVC.js → crabbox-C7KeIKnH.js} +7 -8
  7. package/dist/{error-diagnostics-BJtLRL9w.js → error-diagnostics-CApUyzzu.js} +1 -2
  8. package/dist/{error-diagnostics-BNQwU9yq.js → error-diagnostics-ClSiUwCm.js} +1 -2
  9. package/dist/{file-listing-CHtRrfo1.js → file-listing-BF122soX.js} +3 -4
  10. package/dist/{file-lock-D0-XPogS.js → file-lock-CqA7b491.js} +3 -4
  11. package/dist/{index-DHl0T43e.d.ts → index-D9DogaoF.d.ts} +0 -14
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +12 -13
  14. package/dist/internal/cloudflare.d.ts +2 -5
  15. package/dist/internal/cloudflare.js +3 -4
  16. package/dist/internal/host-toolchain.d.ts +2 -4
  17. package/dist/internal/host-toolchain.js +4 -5
  18. package/dist/internal/vercel.d.ts +2 -4
  19. package/dist/internal/vercel.js +3 -4
  20. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  21. package/dist/{module-types-NYnG3NGz.d.ts → module-types-B3uJG1po.d.ts} +1 -9
  22. package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
  23. package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
  24. package/dist/{provider-loader-Cvqoz7_Z.d.ts → provider-loader-CNKHrWXG.d.ts} +2 -6
  25. package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-Cl2NKhRP.js} +5 -8
  26. package/dist/{remote-fjUPBiLJ.js → remote-DlyX1drC.js} +5 -6
  27. package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
  28. package/dist/{runtime-DHp6ImeP.js → runtime-EtWFVKud.js} +1 -2
  29. package/dist/{runtime-type-Deo4qzxN.js → runtime-type-Dk-rJXlr.js} +1 -2
  30. package/dist/{session-e0lyzjJ3.js → session-DmUiyj4O.js} +5 -8
  31. package/dist/{shell-quote-Q3u3plif.js → shell-quote-MrD49m3N.js} +1 -2
  32. package/dist/ssh.d.ts +1 -3
  33. package/dist/ssh.js +5 -7
  34. package/dist/task/index.d.ts +1 -15
  35. package/dist/task/index.js +21 -37
  36. package/dist/task/runtime/empty-registry.d.ts +0 -2
  37. package/dist/task/runtime/empty-registry.js +1 -2
  38. package/dist/task/runtime/provider-loader.d.ts +1 -1
  39. package/dist/task/runtime/provider-loader.js +2 -3
  40. package/dist/task/runtime/providers/cloudflare.d.ts +3 -4
  41. package/dist/task/runtime/providers/cloudflare.js +3 -4
  42. package/dist/task/runtime/providers/local.d.ts +2 -4
  43. package/dist/task/runtime/providers/local.js +3 -4
  44. package/dist/task/runtime/providers/vercel.d.ts +3 -4
  45. package/dist/task/runtime/providers/vercel.js +6 -8
  46. package/dist/task/runtime/state.d.ts +3 -4
  47. package/dist/task/runtime/state.js +2 -3
  48. package/dist/task/vite.d.ts +22 -23
  49. package/dist/task/vite.js +53 -68
  50. package/dist/{toolchain-DF9eutyQ.js → toolchain-DFFxmw3N.js} +6 -7
  51. package/dist/{trusted-host-DLYiKP8a.js → trusted-host-CwMs64h1.js} +8 -9
  52. package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
  53. package/dist/{vercel-qyDr7NvU.js → vercel-DT74kDyI.js} +9 -13
  54. package/dist/{vercel-credentials-BNTh2X-Y.js → vercel-credentials-BGuXoKxG.js} +3 -5
  55. package/package.json +10 -10
@@ -1,10 +1,7 @@
1
- import { t as AgentSandboxTaskConfig } from "../module-types-NYnG3NGz.js";
1
+ import { t as AgentSandboxTaskConfig } from "../module-types-B3uJG1po.js";
2
2
  import { Plugin } from "vite";
3
- //#region ../internal/src/deployment.d.ts
4
3
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
5
4
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
6
- //#endregion
7
- //#region ../internal/src/inspect.d.ts
8
5
  interface ViteHubDefinitionField {
9
6
  label: string;
10
7
  value: string;
@@ -66,8 +63,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
66
63
  interface ViteHubInspectionPluginMetadata {
67
64
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
68
65
  }
69
- //#endregion
70
- //#region ../internal/src/build/deployment-plan-output.d.ts
71
66
  /**
72
67
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
73
68
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -97,8 +92,6 @@ interface DeploymentEnvContext {
97
92
  * Return names only, never values.
98
93
  */
99
94
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
100
- //#endregion
101
- //#region src/task/internal/shared/feature-definitions.d.ts
102
95
  interface ScannedDefinition {
103
96
  name: string;
104
97
  handler: string;
@@ -107,8 +100,6 @@ interface ScannedDefinition {
107
100
  sourcePath: string;
108
101
  };
109
102
  }
110
- //#endregion
111
- //#region src/task/discovery.d.ts
112
103
  interface DiscoveredSandboxTaskDefinition extends ScannedDefinition {
113
104
  kind: 'definition' | 'package-entry';
114
105
  source: 'server-sandbox-tasks' | 'vite-suffix';
@@ -121,8 +112,6 @@ export declare function discoverSandboxTaskDefinitions(options: {
121
112
  mode: 'server-sandbox-tasks';
122
113
  scanDirs: string[];
123
114
  }): DiscoveredSandboxTaskDefinition[];
124
- //#endregion
125
- //#region ../internal/src/console.d.ts
126
115
  type MaybePromise<T> = T | Promise<T>;
127
116
  /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
128
117
  interface ViteHubConsoleDefinitionCatalogView {
@@ -454,8 +443,6 @@ interface ViteHubConsoleDocumentSetup {
454
443
  */
455
444
  schedule?: ViteHubConsoleDocumentHint;
456
445
  }
457
- //#endregion
458
- //#region src/task/inspect.d.ts
459
446
  interface SandboxTaskInspectionOptions {
460
447
  projectRoot: string;
461
448
  rootDir: string;
@@ -464,9 +451,27 @@ interface SandboxTaskInspectionOptions {
464
451
  export declare function inspectSandboxTaskDefinitions(options: SandboxTaskInspectionOptions): ViteHubDefinitionSummary[];
465
452
  /** Console section that lists discovered Sandbox Task Definitions. `vitehub inspect definitions` reads the same data. */
466
453
  export declare const sandboxTaskConsoleSection: ViteHubConsoleSectionContribution<SandboxTaskInspectionOptions>;
467
- //#endregion
468
- //#region src/task/vite.d.ts
469
454
  export type SandboxTaskOptions = AgentSandboxTaskConfig | false;
455
+ type SandboxTaskNitroBuildConfig = {
456
+ builder: string;
457
+ rolldown?: {
458
+ resolve?: {
459
+ alias?: Record<string, string | string[] | false>;
460
+ };
461
+ };
462
+ };
463
+ type SandboxTaskNitroHost = {
464
+ hooks: {
465
+ hook(name: 'build:before', callback: () => void): void;
466
+ hook(name: 'build:config', callback: (nitro: unknown, config: SandboxTaskNitroBuildConfig) => void): void;
467
+ };
468
+ options: {
469
+ alias?: unknown;
470
+ dev?: boolean;
471
+ devServer?: unknown;
472
+ noExternals?: unknown;
473
+ };
474
+ };
470
475
  export type SandboxTaskVitePlugin = Plugin & {
471
476
  /** The variables that Sandbox Tasks read on the deployed host. See `sandboxDeploymentEnv()`. */
472
477
  api: {
@@ -475,16 +480,10 @@ export type SandboxTaskVitePlugin = Plugin & {
475
480
  vitehub: ViteHubInspectionPluginMetadata;
476
481
  nitro: {
477
482
  name: string;
478
- setup: (nitro: {
479
- hooks: {
480
- hook: (name: 'build:before', callback: () => void) => void;
481
- };
482
- options: Record<string, unknown>;
483
- }) => void;
483
+ setup: (nitro: SandboxTaskNitroHost) => void;
484
484
  };
485
485
  };
486
486
  /** The path of the Sandbox Task runtime state module. Generated code of other owners imports it by path. */
487
487
  export declare const sandboxTaskRuntimeStateModule: string;
488
488
  export declare function hubSandboxTask(options?: SandboxTaskOptions): SandboxTaskVitePlugin;
489
- //#endregion
490
489
  export type { DiscoveredSandboxTaskDefinition, SandboxTaskInspectionOptions };
package/dist/task/vite.js CHANGED
@@ -1,7 +1,7 @@
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-ClSiUwCm.js";
2
+ import { a as resolveCloudflareSandboxTaskInstanceType, i as readSandboxTaskSize, n as assertCloudflareInstanceTypeFits, o as resolveVercelSandboxTaskVcpus, r as describeCloudflareInstanceType, t as vercelCredentialEnv } from "../vercel-credentials-BGuXoKxG.js";
3
+ import { n as invariantError, t as invariant } from "../invariant-Dj2R1eMr.js";
4
+ import { t as getSandboxTaskFeatureDriver } from "../module-types-CWcBHyEs.js";
5
5
  import { builtinModules, createRequire, isBuiltin } from "node:module";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { copyFile, glob, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, stat, symlink, writeFile } from "node:fs/promises";
@@ -16,7 +16,7 @@ import { findDynamicImports, resolvePathSync } from "mlly";
16
16
  import { resolveModule } from "local-pkg";
17
17
  import { dirname as dirname$2, join as join$2, normalize as normalize$1 } from "node:path/posix";
18
18
  import picomatch from "picomatch";
19
- //#region ../internal/src/build/paths.ts
19
+ // ../internal/src/build/paths.ts
20
20
  function generatedDirSegments(productName) {
21
21
  return [".vitehub", productName];
22
22
  }
@@ -36,16 +36,14 @@ function realpathIfExists(path) {
36
36
  return resolve$1(path);
37
37
  }
38
38
  }
39
- //#endregion
40
- //#region ../internal/src/inspect.ts
39
+ // ../internal/src/inspect.ts
41
40
  function relativeDefinitionFile(projectRoot, file) {
42
41
  return relative$1(projectRoot, file).replaceAll("\\", "/");
43
42
  }
44
43
  const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
45
44
  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
45
  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
46
+ // ../internal/src/error-diagnostics.ts
49
47
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
50
48
  const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
51
49
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
@@ -302,6 +300,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
302
300
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
303
301
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
304
302
  },
303
+ INTERNAL_SITE_TOKEN_TOO_LONG: {
304
+ why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
305
+ fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
306
+ },
305
307
  INTERNAL_SQLITE_ARGUMENT_INVALID: {
306
308
  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
309
  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 +318,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
316
318
  }
317
319
  }
318
320
  });
319
- //#endregion
320
- //#region ../internal/src/object.ts
321
+ // ../internal/src/object.ts
321
322
  /** A non-null object that is not an array. Functions do not pass. */
322
323
  function isRecord(value) {
323
324
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -328,8 +329,7 @@ function isPlainRecord(value) {
328
329
  if (prototype === null) return true;
329
330
  return Object.getPrototypeOf(prototype) === null && Object.hasOwn(prototype, "constructor") && prototype.constructor?.name === "Object";
330
331
  }
331
- //#endregion
332
- //#region ../internal/src/build/vite.ts
332
+ // ../internal/src/build/vite.ts
333
333
  const projectRootDirectoryMarkers = [
334
334
  ["server", "agents"],
335
335
  ["server", "channels"],
@@ -442,8 +442,7 @@ function hostFromNitroPreset(value) {
442
442
  if (normalized === "node" || normalized.startsWith("node-")) return "node";
443
443
  if (normalized.startsWith("vercel")) return "vercel";
444
444
  }
445
- //#endregion
446
- //#region ../internal/src/hosting.ts
445
+ // ../internal/src/hosting.ts
447
446
  /**
448
447
  * Returns the Nitro preset name that this build targets, as the developer wrote it.
449
448
  * The order is `nitro.preset`, `hosting`, `NITRO_PRESET`, `SERVER_PRESET`, then `VITEHUB_HOST`.
@@ -475,8 +474,7 @@ function getSupportedHostingProvider(hosting, supportedProviders) {
475
474
  if (!provider || !supportedProviders.includes(provider)) return void 0;
476
475
  return provider;
477
476
  }
478
- //#endregion
479
- //#region ../internal/src/definition-catalog.ts
477
+ // ../internal/src/definition-catalog.ts
480
478
  const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
481
479
  const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
482
480
  const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
@@ -618,8 +616,7 @@ function mergeNitroExternal(value, addition) {
618
616
  if (typeof value === "function") return (source, importer, isResolved) => source === addition || Boolean(value(source, importer, isResolved));
619
617
  return value;
620
618
  }
621
- //#endregion
622
- //#region src/task/internal/shared/cloudflare-wrangler.ts
619
+ // src/task/internal/shared/cloudflare-wrangler.ts
623
620
  function compareNumericStrings(left, right) {
624
621
  return left.localeCompare(right, void 0, { numeric: true });
625
622
  }
@@ -718,8 +715,7 @@ function finalizeCloudflareWranglerConfig(target) {
718
715
  wrangler.migrations = mergeMigrations(wrangler.migrations);
719
716
  validateDurableObjectMigrations(wrangler);
720
717
  }
721
- //#endregion
722
- //#region src/task/cloudflare.ts
718
+ // src/task/cloudflare.ts
723
719
  const defaultCloudflareSandboxBinding = "SANDBOX";
724
720
  const defaultCloudflareSandboxClassName = "Sandbox";
725
721
  const defaultCloudflareSandboxMaxInstances = 12;
@@ -917,8 +913,7 @@ async function configureCloudflareSandboxNitro(targetValue, rootDir, options = {
917
913
  if (finalizeWrangler) finalizeCloudflareWranglerConfig(target);
918
914
  return target;
919
915
  }
920
- //#endregion
921
- //#region src/task/internal/typescript.ts
916
+ // src/task/internal/typescript.ts
922
917
  const require = createRequire(import.meta.url);
923
918
  function loadTypeScript() {
924
919
  try {
@@ -928,8 +923,7 @@ function loadTypeScript() {
928
923
  throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_C0013({ message: "[vitehub] Sandbox Tasks read their definitions with TypeScript. Install `typescript` in the app." });
929
924
  }
930
925
  }
931
- //#endregion
932
- //#region src/task/internal/shared/discovered-definition/ast.ts
926
+ // src/task/internal/shared/discovered-definition/ast.ts
933
927
  const filesystemModuleSpecifiers = /* @__PURE__ */ new Set([
934
928
  "child_process",
935
929
  "fs",
@@ -1433,13 +1427,11 @@ async function injectTypeImportsFromUnimport(source, id, imports) {
1433
1427
  }
1434
1428
  return injectTypeImports(source, pendingImports, id);
1435
1429
  }
1436
- //#endregion
1437
- //#region src/task/internal/shared/server-imports.ts
1430
+ // src/task/internal/shared/server-imports.ts
1438
1431
  function isServerAutoImportEnabled(imports) {
1439
1432
  return imports !== false && imports?.autoImport !== false;
1440
1433
  }
1441
- //#endregion
1442
- //#region src/task/internal/shared/discovered-definition/bundler.ts
1434
+ // src/task/internal/shared/discovered-definition/bundler.ts
1443
1435
  function isJsxDefinition(filename) {
1444
1436
  return filename.endsWith(".tsx") || filename.endsWith(".jsx");
1445
1437
  }
@@ -1508,8 +1500,7 @@ async function bundleDiscoveredDefinitionModuleGraph(options) {
1508
1500
  modules
1509
1501
  };
1510
1502
  }
1511
- //#endregion
1512
- //#region src/task/internal/shared/discovered-definition.ts
1503
+ // src/task/internal/shared/discovered-definition.ts
1513
1504
  function normalizeDir(rootDir, dir) {
1514
1505
  if (typeof dir === "string") return isAbsolute$1(dir) ? dir : resolve$1(rootDir, dir);
1515
1506
  return {
@@ -1595,18 +1586,15 @@ async function createDiscoveredDefinitionCompiler(options = {}) {
1595
1586
  return await injectSource(await readFile(id, "utf8"), id);
1596
1587
  } };
1597
1588
  }
1598
- //#endregion
1599
- //#region src/task/internal/shared/feature-definitions.ts
1589
+ // src/task/internal/shared/feature-definitions.ts
1600
1590
  function toTemplateSafeName(name) {
1601
1591
  return name.replace(/[^a-z0-9/_:-]/gi, "_").replace(/\//g, "__").replace(/:/g, "__");
1602
1592
  }
1603
- //#endregion
1604
- //#region src/task/internal/shared/file-import-specifier.ts
1593
+ // src/task/internal/shared/file-import-specifier.ts
1605
1594
  function createFileImportSpecifier(file, platform = process.platform) {
1606
1595
  return pathToFileURL(file, { windows: platform === "win32" }).href;
1607
1596
  }
1608
- //#endregion
1609
- //#region src/task/internal/shared/module-resolve.ts
1597
+ // src/task/internal/shared/module-resolve.ts
1610
1598
  function normalizePaths(paths) {
1611
1599
  if (paths?.length) return paths;
1612
1600
  if (typeof process !== "undefined") return [process.cwd()];
@@ -1635,8 +1623,7 @@ function tryResolveModule(id, options = {}) {
1635
1623
  continue;
1636
1624
  }
1637
1625
  }
1638
- //#endregion
1639
- //#region src/task/internal/shared/feature-runtime-path.ts
1626
+ // src/task/internal/shared/feature-runtime-path.ts
1640
1627
  function resolveExistingModulePath(path) {
1641
1628
  if (existsSync(path)) return path;
1642
1629
  for (const extension of [
@@ -1668,8 +1655,7 @@ function resolveFeatureRuntimePath(importMetaUrl, packageId, sourceRelativePath,
1668
1655
  if (packagePath) return join$1(dirname$1(packagePath), distRelativePath);
1669
1656
  return sourcePath;
1670
1657
  }
1671
- //#endregion
1672
- //#region src/task/project.ts
1658
+ // src/task/project.ts
1673
1659
  const sandboxTaskProjectSourceFiles = /* @__PURE__ */ new WeakMap();
1674
1660
  function getSandboxTaskProjectSourceFiles(project) {
1675
1661
  return sandboxTaskProjectSourceFiles.get(project) || [];
@@ -1931,8 +1917,7 @@ async function findLockfile(directories, root, manager) {
1931
1917
  };
1932
1918
  }
1933
1919
  }
1934
- //#endregion
1935
- //#region src/task/internal/package-entry.ts
1920
+ // src/task/internal/package-entry.ts
1936
1921
  const runtimeExportConditions = /* @__PURE__ */ new Set([
1937
1922
  "default",
1938
1923
  "import",
@@ -2269,8 +2254,7 @@ function prepareExecutablePackageProject(project, entry) {
2269
2254
  }
2270
2255
  };
2271
2256
  }
2272
- //#endregion
2273
- //#region src/task/bundle.ts
2257
+ // src/task/bundle.ts
2274
2258
  const SHIM_NAMESPACE = "vitehub-sandbox-task-runtime-shim";
2275
2259
  const SHIM_ID = `\0${SHIM_NAMESPACE}`;
2276
2260
  const builtinModuleSet$1 = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
@@ -2420,8 +2404,7 @@ async function bundleSandboxTaskDefinition(source, file, options = {}) {
2420
2404
  }
2421
2405
  };
2422
2406
  }
2423
- //#endregion
2424
- //#region src/task/definition-options.ts
2407
+ // src/task/definition-options.ts
2425
2408
  const sandboxTaskDefinitionSyntax = "`defineSandboxTask({ handler, ...options })`";
2426
2409
  function readStaticValue(node) {
2427
2410
  const ts = loadTypeScript();
@@ -2557,8 +2540,7 @@ async function extractSandboxTaskDefinitionMetadata(file) {
2557
2540
  ...project !== void 0 ? { project } : {}
2558
2541
  } : void 0;
2559
2542
  }
2560
- //#endregion
2561
- //#region src/task/type-template.ts
2543
+ // src/task/type-template.ts
2562
2544
  const sandboxTaskTypeTemplateFilename = "runtime/sandbox-task.d.ts";
2563
2545
  function createDefinitionContract(definition) {
2564
2546
  const module = `typeof import(${JSON.stringify(definition.handler)})`;
@@ -2582,8 +2564,7 @@ function createSandboxTaskTypeTemplateContents(definitions) {
2582
2564
  ``
2583
2565
  ].join("\n");
2584
2566
  }
2585
- //#endregion
2586
- //#region src/task/feature.ts
2567
+ // src/task/feature.ts
2587
2568
  const sandboxTaskRuntimeStateSpecifier = "@vite-hub/sandbox/task/runtime/state";
2588
2569
  const sandboxTaskRuntimeSpecifier = "@vite-hub/sandbox/internal/task/runtime";
2589
2570
  const sandboxTaskRuntimeProviderSpecifiers = {
@@ -2819,8 +2800,7 @@ async function createSandboxTaskFeaturePlan(sandboxTaskConfig, definitions, path
2819
2800
  cloudflare: cloudflareOptions
2820
2801
  };
2821
2802
  }
2822
- //#endregion
2823
- //#region src/task/discovery.ts
2803
+ // src/task/discovery.ts
2824
2804
  const sandboxTaskSuffixPattern = /\.sandbox-task\.(?:c|m)?[jt]s$/i;
2825
2805
  const sandboxTaskEntrypointFilenames = [
2826
2806
  "index.ts",
@@ -2891,8 +2871,7 @@ function discoverSandboxTaskDefinitions(options) {
2891
2871
  const serverScanDirs = roots.map((root) => resolve$1(root, "server"));
2892
2872
  return mergeDefinitions("Sandbox Task", discoverDefinitions("Sandbox Task", [createSuffixDefinitionSource("vite-suffix", roots, sandboxTaskSuffixPattern, normalizeSuffixSandboxTaskName, { createDefinition: createDiscoveredSandboxTaskDefinition("vite-suffix", "definition") })]), discoverServerSandboxTaskDefinitions(serverScanDirs));
2893
2873
  }
2894
- //#endregion
2895
- //#region src/task/internal/runtime-generation.ts
2874
+ // src/task/internal/runtime-generation.ts
2896
2875
  const generationMarker = "// vitehub-sandbox-task-generation: ";
2897
2876
  const generationLockClaimStaleMs = 3e4;
2898
2877
  const generationLockInitializationStaleMs = 5e3;
@@ -3248,8 +3227,7 @@ async function pruneSandboxTaskRuntimeGeneration(path, remove = rm) {
3248
3227
  force: true
3249
3228
  }).catch(() => {});
3250
3229
  }
3251
- //#endregion
3252
- //#region src/task/internal/runtime-preparation.ts
3230
+ // src/task/internal/runtime-preparation.ts
3253
3231
  const SANDBOX_PACKAGE_ID$1 = "@vite-hub/sandbox/task";
3254
3232
  const SANDBOX_REGISTRY_ID = "#vitehub-sandbox-task-registry";
3255
3233
  const builtinModuleSet = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
@@ -3595,8 +3573,7 @@ async function prepareSandboxTaskRuntime(options) {
3595
3573
  watchFiles: plan.watchFiles || []
3596
3574
  };
3597
3575
  }
3598
- //#endregion
3599
- //#region src/task/inspect.ts
3576
+ // src/task/inspect.ts
3600
3577
  /** Lists Sandbox Task Definitions and package entries as serializable inspection summaries. */
3601
3578
  function inspectSandboxTaskDefinitions(options) {
3602
3579
  return discoverSandboxTaskDefinitions({ rootDir: options.rootDir }).map((definition) => ({
@@ -3649,8 +3626,7 @@ const sandboxTaskConsoleSection = {
3649
3626
  notice: "Running Sandbox Tasks, files, processes, logs, ports, and lifecycle state are not included in this build-time catalog."
3650
3627
  }
3651
3628
  };
3652
- //#endregion
3653
- //#region src/task/deployment-env.ts
3629
+ // src/task/deployment-env.ts
3654
3630
  const owners = ["sandbox"];
3655
3631
  /**
3656
3632
  * The variables that Sandbox Tasks read on the deployed host. A Vercel Sandbox reads its token, team, and project from
@@ -3673,19 +3649,20 @@ function sandboxDeploymentEnv(config, driver, context) {
3673
3649
  owners
3674
3650
  }]);
3675
3651
  }
3676
- //#endregion
3677
- //#region src/task/vite.ts
3652
+ // src/task/vite.ts
3678
3653
  const SANDBOX_PACKAGE_ID = "@vite-hub/sandbox/task";
3679
3654
  const SANDBOX_PACKAGE_NAME = "@vite-hub/sandbox";
3680
3655
  const SANDBOX_PROVIDER_LOADER_ID = "vitehub-sandbox-task-provider-loader";
3681
3656
  const SANDBOX_STATE_ID = "#vitehub/sandbox-task";
3682
3657
  const RESOLVED_SANDBOX_STATE_ID = "\0vitehub:sandbox-task:state";
3683
3658
  const SANDBOX_STATE_ID_PATTERN = /^(?:#vitehub\/sandbox-task|\0vitehub:sandbox-task:state)$/;
3684
- function mergeSandboxTaskNitroProviderAliases(nitro, aliases) {
3659
+ function mergeSandboxTaskNitroProviderAliases(nitro, aliases, frameworkSpecifier) {
3685
3660
  const providerAliases = Object.fromEntries(sandboxTaskProviderLoaderSpecifiers.flatMap((specifier) => {
3686
3661
  const replacement = aliases[specifier];
3687
3662
  return replacement ? [[specifier, replacement]] : [];
3688
3663
  }));
3664
+ const facade = aliases[SANDBOX_PACKAGE_ID];
3665
+ if (frameworkSpecifier && facade) providerAliases[frameworkSpecifier] = facade;
3689
3666
  if (!Object.keys(providerAliases).length) return;
3690
3667
  nitro.alias = {
3691
3668
  ...isRecord(nitro.alias) ? nitro.alias : {},
@@ -3815,14 +3792,23 @@ function hubSandboxTask(options) {
3815
3792
  if (localDev && nitroOptions?.dev && runner === "miniflare") throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_LOCAL_NITRO_RUNNER();
3816
3793
  }
3817
3794
  const sandboxTaskNitroModule = (nitro) => {
3818
- const options = nitro.options;
3795
+ const { options } = nitro;
3819
3796
  nitroOptions = options;
3820
3797
  assertLocalDevRunner();
3821
3798
  mergeSandboxTaskNitroNoExternals(options, selectedProvider);
3822
- if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases);
3799
+ if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases, internalOptions?.providerImportSpecifier);
3823
3800
  nitro.hooks.hook("build:before", () => {
3824
3801
  mergeSandboxTaskNitroNoExternals(options, selectedProvider);
3825
- if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases);
3802
+ if (selectedProvider) mergeSandboxTaskNitroProviderAliases(options, generatedAliases, internalOptions?.providerImportSpecifier);
3803
+ });
3804
+ if (options.dev) nitro.hooks.hook("build:config", (_nitro, config) => {
3805
+ const resolver = config.builder === "rolldown" ? config.rolldown?.resolve : void 0;
3806
+ const specifier = internalOptions?.providerImportSpecifier;
3807
+ const facade = generatedAliases[SANDBOX_PACKAGE_ID];
3808
+ if (resolver && selectedProvider && specifier && facade) resolver.alias = {
3809
+ ...resolver.alias,
3810
+ [specifier]: facade
3811
+ };
3826
3812
  });
3827
3813
  };
3828
3814
  function cloneConfigValue(value) {
@@ -3992,5 +3978,4 @@ function hubSandboxTask(options) {
3992
3978
  }
3993
3979
  };
3994
3980
  }
3995
- //#endregion
3996
3981
  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 };
@@ -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-ClSiUwCm.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.5.1",
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.5.1",
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": {