@vite-hub/sandbox 0.0.3 → 0.1.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 (60) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +388 -22
  3. package/dist/cloudflare-DO0h3Ncf.js +281 -0
  4. package/dist/cloudflare-env-BBJaBbuQ.js +39 -0
  5. package/dist/crabbox-BFCdf41h.js +1106 -0
  6. package/dist/error-diagnostics-BSysPv-D.js +166 -0
  7. package/dist/error-diagnostics-dGQqfgLt.js +99 -0
  8. package/dist/file-listing-DECFTdSl.js +26 -0
  9. package/dist/file-lock-CxyVl4Cv.js +73 -0
  10. package/dist/index-CXej1Bt0.d.ts +519 -0
  11. package/dist/index.d.ts +2 -65
  12. package/dist/index.js +277 -1172
  13. package/dist/internal/cloudflare.d.ts +4 -0
  14. package/dist/internal/cloudflare.js +16 -0
  15. package/dist/internal/host-toolchain.d.ts +22 -0
  16. package/dist/internal/host-toolchain.js +97 -0
  17. package/dist/internal/vercel.d.ts +4 -0
  18. package/dist/internal/vercel.js +16 -0
  19. package/dist/module-types-BfyRBaiP.js +7 -0
  20. package/dist/module-types-Cis4hrF1.d.ts +95 -0
  21. package/dist/remote-1Jz2oUMK.js +247 -0
  22. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  23. package/dist/runtime-DHp6ImeP.js +32 -0
  24. package/dist/runtime-type-DrmrW5m5.js +42 -0
  25. package/dist/session-DD0S1PDC.js +337 -0
  26. package/dist/shell-quote-Q3u3plif.js +6 -0
  27. package/dist/ssh.d.ts +55 -0
  28. package/dist/ssh.js +219 -0
  29. package/dist/task/index.d.ts +67 -0
  30. package/dist/task/index.js +1523 -0
  31. package/dist/task/runtime/empty-registry.d.ts +6 -0
  32. package/dist/{runtime → task/runtime}/empty-registry.js +2 -2
  33. package/dist/task/runtime/provider-loader.d.ts +20 -0
  34. package/dist/task/runtime/provider-loader.js +19 -0
  35. package/dist/task/runtime/providers/cloudflare.d.ts +28 -0
  36. package/dist/task/runtime/providers/cloudflare.js +26 -0
  37. package/dist/task/runtime/providers/vercel.d.ts +12 -0
  38. package/dist/{runtime → task/runtime}/providers/vercel.js +17 -14
  39. package/dist/task/runtime/state.d.ts +24 -0
  40. package/dist/task/runtime/state.js +73 -0
  41. package/dist/task/vite.d.ts +360 -0
  42. package/dist/task/vite.js +3643 -0
  43. package/dist/toolchain-BUVXtQ2m.js +527 -0
  44. package/dist/trusted-host-DNMJ-Oig.js +872 -0
  45. package/dist/vercel-Jtxa9TJx.js +279 -0
  46. package/package.json +103 -39
  47. package/dist/cloudflare-env-2NctU8i7.js +0 -12
  48. package/dist/module-types-DfXe133f.d.ts +0 -91
  49. package/dist/module-types-Dj1MFmHT.js +0 -7
  50. package/dist/provider-loader-hL7uHVWp.d.ts +0 -21
  51. package/dist/runtime/empty-registry.d.ts +0 -6
  52. package/dist/runtime/provider-loader.d.ts +0 -2
  53. package/dist/runtime/provider-loader.js +0 -15
  54. package/dist/runtime/providers/cloudflare.d.ts +0 -29
  55. package/dist/runtime/providers/cloudflare.js +0 -25
  56. package/dist/runtime/providers/vercel.d.ts +0 -112
  57. package/dist/runtime/state.d.ts +0 -17
  58. package/dist/runtime/state.js +0 -21
  59. package/dist/vite.d.ts +0 -24
  60. package/dist/vite.js +0 -2367
@@ -1,25 +0,0 @@
1
- import { t as getCloudflareEnv } from "../../cloudflare-env-2NctU8i7.js";
2
- import { resolveCloudflareBox } from "@vite-hub/box/_internal/cloudflare";
3
- //#region src/runtime/providers/cloudflare.ts
4
- async function resolveCloudflareSandboxBox(options, context = {}) {
5
- const env = getCloudflareEnv(context.event);
6
- const bindingName = options.provider.binding || "SANDBOX";
7
- const namespace = env?.[bindingName];
8
- if (!namespace) throw new Error(`Cloudflare sandbox requires the "${bindingName}" binding. Set sandbox.binding or run inside Cloudflare.`);
9
- return {
10
- closeAfterRun: options.provider.keepAlive === true,
11
- provider: "cloudflare",
12
- sandboxId: options.provider.sandboxId,
13
- resolveBox: async (requirements) => await resolveCloudflareBox({
14
- namespace,
15
- sandboxId: options.provider.sandboxId,
16
- cloudflare: {
17
- sleepAfter: options.provider.sleepAfter ?? "5m",
18
- keepAlive: options.provider.keepAlive,
19
- normalizeId: options.provider.normalizeId
20
- }
21
- }, requirements)
22
- };
23
- }
24
- //#endregion
25
- export { resolveCloudflareSandboxBox };
@@ -1,112 +0,0 @@
1
- import { h as VercelSandboxProviderOptions, l as SandboxDefinitionOptions } from "../../module-types-DfXe133f.js";
2
- import { ExecutionAuthority } from "@vite-hub/runtime";
3
-
4
- //#region ../box/dist/index-B2Wqvvhr.d.ts
5
- interface BoxOpenOptions {
6
- id?: string;
7
- initialize?: (session: BoxSession, context: {
8
- signal?: AbortSignal;
9
- }) => Promise<void>;
10
- signal?: AbortSignal;
11
- }
12
- interface BoxExecOptions {
13
- cwd?: string;
14
- env?: Readonly<Record<string, string>>;
15
- signal?: AbortSignal;
16
- timeout?: number;
17
- }
18
- interface BoxExecResult {
19
- readonly code: number;
20
- readonly ok: boolean;
21
- readonly stderr: string;
22
- readonly stdout: string;
23
- }
24
- interface BoxProcessExit {
25
- readonly code: number;
26
- }
27
- interface BoxProcess {
28
- readonly pid?: number;
29
- readonly stderr: ReadableStream<Uint8Array>;
30
- readonly stdout: ReadableStream<Uint8Array>;
31
- kill(signal?: string): Promise<void>;
32
- wait(): Promise<BoxProcessExit>;
33
- }
34
- interface BoxFileEntry {
35
- readonly path: string;
36
- readonly size?: number;
37
- readonly type: "directory" | "file" | "symlink";
38
- }
39
- interface BoxFileOptions {
40
- signal?: AbortSignal;
41
- }
42
- interface BoxListFilesOptions extends BoxFileOptions {
43
- recursive?: boolean;
44
- }
45
- interface BoxRemoveFileOptions extends BoxFileOptions {
46
- recursive?: boolean;
47
- }
48
- interface BoxFiles {
49
- exists(path: string, options?: BoxFileOptions): Promise<boolean>;
50
- list(path: string, options?: BoxListFilesOptions): Promise<readonly BoxFileEntry[]>;
51
- mkdir(path: string, options?: BoxFileOptions & {
52
- recursive?: boolean;
53
- }): Promise<void>;
54
- move?(source: string, destination: string, options?: BoxFileOptions): Promise<void>;
55
- read(path: string, options?: BoxFileOptions): Promise<Uint8Array | null>;
56
- remove(path: string, options?: BoxRemoveFileOptions): Promise<void>;
57
- write(path: string, contents: Uint8Array, options?: BoxFileOptions): Promise<void>;
58
- }
59
- interface BoxPorts {
60
- readonly values: readonly number[];
61
- expose(port: number, options?: {
62
- protocol?: "http" | "https" | "ws";
63
- }): Promise<URL>;
64
- }
65
- interface BoxSession {
66
- readonly cwd: string;
67
- readonly executionAuthority: ExecutionAuthority;
68
- readonly files: BoxFiles;
69
- readonly id: string;
70
- readonly ports?: BoxPorts;
71
- readonly spawn?: (command: string, args?: readonly string[], options?: BoxExecOptions) => Promise<BoxProcess>;
72
- close(): Promise<void>;
73
- exec(command: string, args?: readonly string[], options?: BoxExecOptions): Promise<BoxExecResult>;
74
- }
75
- interface BoxEnvironment {
76
- readonly env: Readonly<Record<string, string | undefined>>;
77
- }
78
- interface BoxResolvedRequirement {
79
- readonly command: string;
80
- readonly name: string;
81
- }
82
- interface BoxPlan {
83
- readonly cache: {
84
- readonly state: "disposable";
85
- };
86
- readonly environment: BoxEnvironment;
87
- readonly executionAuthority: ExecutionAuthority;
88
- readonly identity: string;
89
- readonly requirements: readonly BoxResolvedRequirement[];
90
- readonly runtime: string;
91
- readonly workspace: {
92
- readonly path?: string;
93
- readonly state: "authoritative" | "disposable";
94
- readonly workDir?: "." | "workspace";
95
- };
96
- }
97
- interface Box {
98
- readonly plan: BoxPlan;
99
- open(options?: BoxOpenOptions): Promise<BoxSession>;
100
- }
101
- //#endregion
102
- //#region src/runtime/providers/vercel.d.ts
103
- type SandboxOptions = {
104
- local: SandboxDefinitionOptions;
105
- provider: VercelSandboxProviderOptions;
106
- };
107
- declare function resolveVercelSandboxBox(options: SandboxOptions): Promise<{
108
- provider: "vercel";
109
- resolveBox: (requirements: readonly string[]) => Promise<Box>;
110
- }>;
111
- //#endregion
112
- export { resolveVercelSandboxBox };
@@ -1,17 +0,0 @@
1
- import { a as SandboxDefinitionBundle, l as SandboxDefinitionOptions, t as AgentSandboxConfig } from "../module-types-DfXe133f.js";
2
-
3
- //#region src/runtime/state.d.ts
4
- type SandboxRegistryEntry = {
5
- bundle: SandboxDefinitionBundle;
6
- options?: SandboxDefinitionOptions;
7
- };
8
- type SandboxRuntimeRegistry = Record<string, SandboxRegistryEntry | (() => Promise<{
9
- default?: SandboxRegistryEntry;
10
- }>)>;
11
- declare function getSandboxRuntimeConfig(): false | AgentSandboxConfig | undefined;
12
- declare function getSandboxRuntimeRegistry(): SandboxRuntimeRegistry | undefined;
13
- declare function setSandboxRuntimeConfig(config: false | AgentSandboxConfig | undefined): void;
14
- declare function setSandboxRuntimeRegistry(registry: SandboxRuntimeRegistry | undefined): void;
15
- declare function resetSandboxRuntimeState(): void;
16
- //#endregion
17
- export { SandboxRegistryEntry, SandboxRuntimeRegistry, getSandboxRuntimeConfig, getSandboxRuntimeRegistry, resetSandboxRuntimeState, setSandboxRuntimeConfig, setSandboxRuntimeRegistry };
@@ -1,21 +0,0 @@
1
- //#region src/runtime/state.ts
2
- let sandboxConfig;
3
- let sandboxRegistry;
4
- function getSandboxRuntimeConfig() {
5
- return sandboxConfig;
6
- }
7
- function getSandboxRuntimeRegistry() {
8
- return sandboxRegistry;
9
- }
10
- function setSandboxRuntimeConfig(config) {
11
- sandboxConfig = config;
12
- }
13
- function setSandboxRuntimeRegistry(registry) {
14
- sandboxRegistry = registry;
15
- }
16
- function resetSandboxRuntimeState() {
17
- sandboxConfig = void 0;
18
- sandboxRegistry = void 0;
19
- }
20
- //#endregion
21
- export { getSandboxRuntimeConfig, getSandboxRuntimeRegistry, resetSandboxRuntimeState, setSandboxRuntimeConfig, setSandboxRuntimeRegistry };
package/dist/vite.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { t as AgentSandboxConfig } from "./module-types-DfXe133f.js";
2
- import { Plugin } from "vite";
3
-
4
- //#region src/vite.d.ts
5
- type SandboxPublicOptions = AgentSandboxConfig | false;
6
- type SandboxVitePlugin = Plugin & {
7
- nitro: {
8
- name: string;
9
- setup: (nitro: {
10
- hooks: {
11
- hook: (name: 'build:before', callback: () => void) => void;
12
- };
13
- options: Record<string, unknown>;
14
- }) => void;
15
- };
16
- };
17
- declare function hubSandbox(options?: SandboxPublicOptions): SandboxVitePlugin;
18
- declare module 'vite' {
19
- interface UserConfig {
20
- sandbox?: SandboxPublicOptions;
21
- }
22
- }
23
- //#endregion
24
- export { SandboxPublicOptions, SandboxVitePlugin, hubSandbox };