@vite-hub/sandbox 0.4.1 → 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-Cog_r2Me.js → cloudflare-DrNRQPeh.js} +13 -27
  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-CqfD8yuE.js → container-DOadzngt.js} +7 -13
  6. package/dist/{crabbox-sbV3Zjuo.js → crabbox-C7KeIKnH.js} +7 -12
  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-DsoQAUb7.d.ts → index-D9DogaoF.d.ts} +0 -15
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +12 -14
  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-BoOZiNN4.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-BDgDJ6bX.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-70ZVZZlq.js → remote-DlyX1drC.js} +5 -10
  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 +11 -9
  34. package/dist/task/index.d.ts +1 -16
  35. package/dist/task/index.js +23 -44
  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 +9 -16
  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 +24 -23
  49. package/dist/task/vite.js +108 -116
  50. package/dist/{toolchain-BIVGMRty.js → toolchain-DFFxmw3N.js} +6 -13
  51. package/dist/{trusted-host-RanFsFSB.js → trusted-host-CwMs64h1.js} +39 -24
  52. package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
  53. package/dist/{vercel-BGGrNpza.js → vercel-DT74kDyI.js} +33 -29
  54. package/dist/{size-DJNpXeAt.js → vercel-credentials-BGuXoKxG.js} +18 -4
  55. package/package.json +10 -10
@@ -1,9 +1,9 @@
1
- import { n as loadVercelSandbox } from "../../../vercel-BGGrNpza.js";
2
1
  import { resolveVercelSandbox } from "../../../internal/vercel.js";
3
- import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-BNQwU9yq.js";
4
- import "../../../provider-resolution-BrQfEQo0.js";
5
- import { a as resolveVercelSandboxTaskVcpus } from "../../../size-DJNpXeAt.js";
6
- //#region ../internal/src/env.ts
2
+ import { n as loadVercelSandbox } from "../../../vercel-DT74kDyI.js";
3
+ import { o as resolveVercelSandboxTaskVcpus, t as vercelCredentialEnv } from "../../../vercel-credentials-BGuXoKxG.js";
4
+ import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-ClSiUwCm.js";
5
+ import "../../../provider-resolution-Cl2NKhRP.js";
6
+ // ../internal/src/env.ts
7
7
  function trimmed(value) {
8
8
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
9
9
  }
@@ -13,12 +13,7 @@ function readEnv(env, ...names) {
13
13
  if (value) return value;
14
14
  }
15
15
  }
16
- //#endregion
17
- //#region src/task/runtime/providers/vercel.ts
18
- /**
19
- * The Vercel VM timeout starts at create, but the task timeout starts after the Sandbox opens.
20
- * The VM gets this extra time so that ViteHub, not the VM, ends a run at the task timeout.
21
- */
16
+ // src/task/runtime/providers/vercel.ts
22
17
  const VERCEL_TASK_SANDBOX_HEADROOM_MS = 3e4;
23
18
  function readConfigCredential(value) {
24
19
  return value?.trim() || void 0;
@@ -26,9 +21,9 @@ function readConfigCredential(value) {
26
21
  function resolveEnvCredentials() {
27
22
  const env = typeof process !== "undefined" ? process.env : {};
28
23
  return {
29
- token: readEnv(env, "VITE_SANDBOX_TOKEN", "VERCEL_TOKEN"),
30
- teamId: readEnv(env, "VITE_SANDBOX_TEAM_ID", "VERCEL_TEAM_ID"),
31
- projectId: readEnv(env, "VITE_SANDBOX_PROJECT_ID", "VERCEL_PROJECT_ID")
24
+ token: readEnv(env, ...vercelCredentialEnv.token.names),
25
+ teamId: readEnv(env, ...vercelCredentialEnv.teamId.names),
26
+ projectId: readEnv(env, ...vercelCredentialEnv.projectId.names)
32
27
  };
33
28
  }
34
29
  function resolveCredentials(provider) {
@@ -62,7 +57,6 @@ async function resolveVercelTaskSandbox(options) {
62
57
  }, requirements)
63
58
  };
64
59
  }
65
- /** Reports a session timeout above the Vercel plan maximum with its own code and the limit from Vercel. */
66
60
  function withPlanLimitError(create) {
67
61
  return async (createOptions) => {
68
62
  try {
@@ -81,5 +75,4 @@ function withPlanLimitError(create) {
81
75
  function vercelTimeoutLimit(message) {
82
76
  return /`timeout` restricted to [^\n]+/.exec(message)?.[0];
83
77
  }
84
- //#endregion
85
78
  export { resolveVercelTaskSandbox };
@@ -1,6 +1,5 @@
1
- import { a as SandboxTaskDefinitionBundle, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions } from "../../module-types-BoOZiNN4.js";
2
- import { t as ResolvedTaskSandbox } from "../../provider-loader-BDgDJ6bX.js";
3
- //#region src/task/runtime/state.d.ts
1
+ import { a as SandboxTaskDefinitionBundle, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions } from "../../module-types-B3uJG1po.js";
2
+ import { t as ResolvedTaskSandbox } from "../../provider-loader-CNKHrWXG.js";
4
3
  export type SandboxTaskRegistryEntry = {
5
4
  bundle: SandboxTaskDefinitionBundle;
6
5
  options?: SandboxTaskDefinitionOptions;
@@ -25,4 +24,4 @@ export declare function getSandboxTaskRuntimeLocalProvider(): (() => Promise<Res
25
24
  export declare function setSandboxTaskRuntimeLocalProvider(provider: (() => Promise<ResolvedTaskSandbox>) | undefined): void;
26
25
  export declare function setSandboxTaskRuntimeRegistry(registry: SandboxTaskRuntimeRegistry | undefined): void;
27
26
  export declare function resetSandboxTaskRuntimeState(): void;
28
- //#endregion
27
+ export {};
@@ -1,6 +1,6 @@
1
- import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-BNQwU9yq.js";
1
+ import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-ClSiUwCm.js";
2
2
  import { pathToFileURL } from "node:url";
3
- //#region src/task/runtime/state.ts
3
+ // src/task/runtime/state.ts
4
4
  let sandboxTaskConfig;
5
5
  let sandboxTaskLocalProvider;
6
6
  let sandboxTaskRegistry;
@@ -78,5 +78,4 @@ function resetSandboxTaskRuntimeState() {
78
78
  sandboxTaskRegistry = void 0;
79
79
  generatedRegistries.clear();
80
80
  }
81
- //#endregion
82
81
  export { createGeneratedSandboxTaskModuleSpecifier, createGeneratedSandboxTaskRuntimeRegistry, getSandboxTaskRuntimeConfig, getSandboxTaskRuntimeLocalProvider, getSandboxTaskRuntimeRegistry, resetSandboxTaskRuntimeState, setSandboxTaskRuntimeConfig, setSandboxTaskRuntimeLocalProvider, setSandboxTaskRuntimeRegistry };
@@ -1,10 +1,7 @@
1
- import { t as AgentSandboxTaskConfig } from "../module-types-BoOZiNN4.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;
@@ -54,6 +51,8 @@ interface ViteHubResourceSummary {
54
51
  owner: string;
55
52
  /** Absent when no id is known yet. */
56
53
  source?: ViteHubResourceIdSource;
54
+ /** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
55
+ standalone?: boolean;
57
56
  }
58
57
  interface ViteHubInspectionContributor {
59
58
  definitions?: readonly ViteHubDefinitionInspector[];
@@ -64,8 +63,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
64
63
  interface ViteHubInspectionPluginMetadata {
65
64
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
66
65
  }
67
- //#endregion
68
- //#region ../internal/src/build/deployment-plan-output.d.ts
69
66
  /**
70
67
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
71
68
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -95,8 +92,6 @@ interface DeploymentEnvContext {
95
92
  * Return names only, never values.
96
93
  */
97
94
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
98
- //#endregion
99
- //#region src/task/internal/shared/feature-definitions.d.ts
100
95
  interface ScannedDefinition {
101
96
  name: string;
102
97
  handler: string;
@@ -105,8 +100,6 @@ interface ScannedDefinition {
105
100
  sourcePath: string;
106
101
  };
107
102
  }
108
- //#endregion
109
- //#region src/task/discovery.d.ts
110
103
  interface DiscoveredSandboxTaskDefinition extends ScannedDefinition {
111
104
  kind: 'definition' | 'package-entry';
112
105
  source: 'server-sandbox-tasks' | 'vite-suffix';
@@ -119,8 +112,6 @@ export declare function discoverSandboxTaskDefinitions(options: {
119
112
  mode: 'server-sandbox-tasks';
120
113
  scanDirs: string[];
121
114
  }): DiscoveredSandboxTaskDefinition[];
122
- //#endregion
123
- //#region ../internal/src/console.d.ts
124
115
  type MaybePromise<T> = T | Promise<T>;
125
116
  /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
126
117
  interface ViteHubConsoleDefinitionCatalogView {
@@ -452,8 +443,6 @@ interface ViteHubConsoleDocumentSetup {
452
443
  */
453
444
  schedule?: ViteHubConsoleDocumentHint;
454
445
  }
455
- //#endregion
456
- //#region src/task/inspect.d.ts
457
446
  interface SandboxTaskInspectionOptions {
458
447
  projectRoot: string;
459
448
  rootDir: string;
@@ -462,9 +451,27 @@ interface SandboxTaskInspectionOptions {
462
451
  export declare function inspectSandboxTaskDefinitions(options: SandboxTaskInspectionOptions): ViteHubDefinitionSummary[];
463
452
  /** Console section that lists discovered Sandbox Task Definitions. `vitehub inspect definitions` reads the same data. */
464
453
  export declare const sandboxTaskConsoleSection: ViteHubConsoleSectionContribution<SandboxTaskInspectionOptions>;
465
- //#endregion
466
- //#region src/task/vite.d.ts
467
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
+ };
468
475
  export type SandboxTaskVitePlugin = Plugin & {
469
476
  /** The variables that Sandbox Tasks read on the deployed host. See `sandboxDeploymentEnv()`. */
470
477
  api: {
@@ -473,16 +480,10 @@ export type SandboxTaskVitePlugin = Plugin & {
473
480
  vitehub: ViteHubInspectionPluginMetadata;
474
481
  nitro: {
475
482
  name: string;
476
- setup: (nitro: {
477
- hooks: {
478
- hook: (name: 'build:before', callback: () => void) => void;
479
- };
480
- options: Record<string, unknown>;
481
- }) => void;
483
+ setup: (nitro: SandboxTaskNitroHost) => void;
482
484
  };
483
485
  };
484
486
  /** The path of the Sandbox Task runtime state module. Generated code of other owners imports it by path. */
485
487
  export declare const sandboxTaskRuntimeStateModule: string;
486
488
  export declare function hubSandboxTask(options?: SandboxTaskOptions): SandboxTaskVitePlugin;
487
- //#endregion
488
489
  export type { DiscoveredSandboxTaskDefinition, SandboxTaskInspectionOptions };