@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.
- package/README.md +20 -0
- package/dist/{abortable-CR01hzfi.js → abortable-DrHeTo1e.js} +1 -2
- package/dist/{cloudflare-DOrMY3MJ.js → cloudflare-DrNRQPeh.js} +13 -17
- package/dist/{cloudflare-env-lookup-DzI6Xv1Y.js → cloudflare-env-lookup-BNbNil7g.js} +1 -2
- package/dist/{cloudflare-failure-CFQhalfh.js → cloudflare-failure-f-3P3ul-.js} +1 -2
- package/dist/{container-BVb0fw3z.js → container-DOadzngt.js} +7 -9
- package/dist/{crabbox-BU8W1gVC.js → crabbox-C7KeIKnH.js} +7 -8
- package/dist/{error-diagnostics-BJtLRL9w.js → error-diagnostics-CApUyzzu.js} +1 -2
- package/dist/{error-diagnostics-BNQwU9yq.js → error-diagnostics-D9n0ZmdN.js} +8 -5
- package/dist/{file-listing-CHtRrfo1.js → file-listing-BF122soX.js} +3 -4
- package/dist/{file-lock-D0-XPogS.js → file-lock-CqA7b491.js} +3 -4
- package/dist/{index-DHl0T43e.d.ts → index-D9DogaoF.d.ts} +0 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -13
- package/dist/internal/cloudflare.d.ts +2 -5
- package/dist/internal/cloudflare.js +3 -4
- package/dist/internal/host-toolchain.d.ts +2 -4
- package/dist/internal/host-toolchain.js +4 -5
- package/dist/internal/vercel.d.ts +2 -4
- package/dist/internal/vercel.js +3 -4
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
- package/dist/{module-types-NYnG3NGz.d.ts → module-types-DHr6oC3h.d.ts} +18 -13
- package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
- package/dist/{provider-loader-Cvqoz7_Z.d.ts → provider-loader-CLIIEEmR.d.ts} +2 -6
- package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-qvRcW1PC.js} +13 -10
- package/dist/{remote-fjUPBiLJ.js → remote-DlyX1drC.js} +5 -6
- package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
- package/dist/{runtime-DHp6ImeP.js → runtime-EtWFVKud.js} +1 -2
- package/dist/{runtime-type-Deo4qzxN.js → runtime-type-Dk-rJXlr.js} +1 -2
- package/dist/{session-e0lyzjJ3.js → session-DmUiyj4O.js} +5 -8
- package/dist/{shell-quote-Q3u3plif.js → shell-quote-MrD49m3N.js} +1 -2
- package/dist/ssh.d.ts +1 -3
- package/dist/ssh.js +5 -7
- package/dist/task/index.d.ts +2 -16
- package/dist/task/index.js +345 -142
- package/dist/task/runtime/empty-registry.d.ts +0 -2
- package/dist/task/runtime/empty-registry.js +1 -2
- package/dist/task/runtime/provider-loader.d.ts +1 -1
- package/dist/task/runtime/provider-loader.js +2 -3
- package/dist/task/runtime/providers/cloudflare.d.ts +3 -4
- package/dist/task/runtime/providers/cloudflare.js +3 -4
- package/dist/task/runtime/providers/local.d.ts +2 -4
- package/dist/task/runtime/providers/local.js +3 -4
- package/dist/task/runtime/providers/vercel.d.ts +3 -4
- package/dist/task/runtime/providers/vercel.js +6 -8
- package/dist/task/runtime/state.d.ts +3 -4
- package/dist/task/runtime/state.js +2 -3
- package/dist/task/vite.d.ts +23 -24
- package/dist/task/vite.js +63 -74
- package/dist/{toolchain-DF9eutyQ.js → toolchain-DFFxmw3N.js} +6 -7
- package/dist/transfer-options-LTUzbHDw.js +18 -0
- package/dist/{trusted-host-DLYiKP8a.js → trusted-host-CwMs64h1.js} +8 -9
- package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
- package/dist/{vercel-qyDr7NvU.js → vercel-DT74kDyI.js} +9 -13
- package/dist/{vercel-credentials-BNTh2X-Y.js → vercel-credentials-BH5lPJxs.js} +3 -5
- package/package.json +10 -10
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Q as VercelSandboxSource, X as VercelSandboxNetworkPolicy, st as SandboxNetworkPolicy } from "./index-
|
|
1
|
+
import { Q as VercelSandboxSource, X as VercelSandboxNetworkPolicy, st as SandboxNetworkPolicy } from "./index-D9DogaoF.js";
|
|
2
2
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/task/project.d.ts
|
|
4
3
|
type SandboxTaskPackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
5
4
|
interface SandboxTaskProjectFile {
|
|
6
5
|
contents: string;
|
|
@@ -18,8 +17,6 @@ interface SandboxTaskProject {
|
|
|
18
17
|
options?: SandboxTaskProjectOptions;
|
|
19
18
|
packagePath: string;
|
|
20
19
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/task/runtime/result.d.ts
|
|
23
20
|
declare const sandboxTaskRunErrors: import("@vite-hub/runtime").ErrorCatalog<{
|
|
24
21
|
readonly SANDBOX_TASK_RUN_FAILED: {
|
|
25
22
|
readonly why: ({ name, code }: {
|
|
@@ -36,8 +33,6 @@ declare const sandboxTaskRunErrors: import("@vite-hub/runtime").ErrorCatalog<{
|
|
|
36
33
|
};
|
|
37
34
|
};
|
|
38
35
|
}>;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/task/size.d.ts
|
|
41
36
|
/** The size of the machine that runs every Sandbox Task. Both values are minimums. */
|
|
42
37
|
interface SandboxTaskSizeOptions {
|
|
43
38
|
/** Minimum vCPUs. ViteHub picks the smallest provider size that gives at least this many. */
|
|
@@ -45,8 +40,6 @@ interface SandboxTaskSizeOptions {
|
|
|
45
40
|
/** Minimum memory in MiB. ViteHub picks the smallest provider size that gives at least this much. */
|
|
46
41
|
memory?: number;
|
|
47
42
|
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/task/module-types.d.ts
|
|
50
43
|
type SandboxTaskDriver = 'cloudflare' | 'vercel';
|
|
51
44
|
interface CloudflareSandboxTaskOptions {
|
|
52
45
|
sleepAfter?: string | number;
|
|
@@ -109,13 +102,26 @@ type SandboxTaskRunArguments<TPayload> = undefined extends TPayload ? [payload?:
|
|
|
109
102
|
type SandboxTaskDefinitionHandler<TPayload = unknown, TResult = unknown> = (payload: TPayload, context: Record<string, unknown>) => TResult | Promise<TResult>;
|
|
110
103
|
type SandboxTaskDefinitionPayload<THandler extends (...args: any[]) => any> = Parameters<THandler> extends [infer TPayload, ...unknown[]] ? TPayload : unknown;
|
|
111
104
|
type SandboxTaskDefinitionResult<THandler extends (...args: any[]) => any> = Awaited<ReturnType<THandler>>;
|
|
105
|
+
/** The limits on the values that cross the Sandbox boundary. Each limit is a whole number from 1 to 1073741824. */
|
|
106
|
+
interface SandboxTaskTransferOptions {
|
|
107
|
+
/** The largest payload and context JSON, in UTF-8 bytes. Default: 4194304 (4 MiB). */
|
|
108
|
+
maxInputBytes?: number;
|
|
109
|
+
/** The largest result JSON, in UTF-8 bytes. Default: 4194304 (4 MiB). */
|
|
110
|
+
maxOutputBytes?: number;
|
|
111
|
+
/** The deepest nesting of arrays and objects in one direction. Default: 32. */
|
|
112
|
+
maxDepth?: number;
|
|
113
|
+
/** The largest number of `Blob`, `Uint8Array`, and `Buffer` values in one direction. Default: 64. */
|
|
114
|
+
maxSidecars?: number;
|
|
115
|
+
/** The largest total size of the binary values in one direction, in bytes. Default: 67108864 (64 MiB). */
|
|
116
|
+
maxSidecarBytes?: number;
|
|
117
|
+
}
|
|
112
118
|
interface SandboxTaskDefinitionOptions {
|
|
113
119
|
timeout?: number;
|
|
114
120
|
env?: Record<string, string>;
|
|
121
|
+
/** The limits on the payload, the context, and the result of a run. */
|
|
122
|
+
transfer?: SandboxTaskTransferOptions;
|
|
115
123
|
}
|
|
116
|
-
|
|
117
|
-
timeout?: number;
|
|
118
|
-
}
|
|
124
|
+
type SandboxTaskProjectOptions = Pick<SandboxTaskDefinitionOptions, 'timeout' | 'transfer'>;
|
|
119
125
|
interface SandboxTaskDefinitionInput<TPayload = unknown, TResult = unknown> extends SandboxTaskDefinitionOptions {
|
|
120
126
|
/** Force project packaging on or off. Omit to detect project use automatically. */
|
|
121
127
|
project?: boolean;
|
|
@@ -134,5 +140,4 @@ type SandboxTaskDefinitionFromHandler<THandler extends (...args: any[]) => any>
|
|
|
134
140
|
*/
|
|
135
141
|
type SandboxTaskRunResult<TResult = unknown> = [error: ReturnType<typeof sandboxTaskRunErrors.SANDBOX_TASK_RUN_FAILED>, data: undefined] | [error: undefined, data: TResult];
|
|
136
142
|
declare function getSandboxTaskFeatureDriver(config?: AgentSandboxTaskConfig | false): SandboxTaskDefinitionDriverOptions | undefined;
|
|
137
|
-
|
|
138
|
-
export { VercelSandboxTaskDriverOptions as _, SandboxTaskDefinitionBundle as a, SandboxTaskDefinitionHandler as c, SandboxTaskDevOptions as d, SandboxTaskDriver as f, SandboxTaskRunResult as g, SandboxTaskRunArguments as h, SandboxTaskDefinition as i, SandboxTaskDefinitionInput as l, SandboxTaskProjectOptions as m, CloudflareSandboxTaskDefinitionDriverOptions as n, SandboxTaskDefinitionDriverOptions as o, SandboxTaskExecutionOptions as p, CloudflareSandboxTaskOptions as r, SandboxTaskDefinitionFromHandler as s, AgentSandboxTaskConfig as t, SandboxTaskDefinitionOptions as u, getSandboxTaskFeatureDriver as v, SandboxTaskSizeOptions as y };
|
|
143
|
+
export { SandboxTaskTransferOptions as _, SandboxTaskDefinitionBundle as a, SandboxTaskSizeOptions as b, SandboxTaskDefinitionHandler as c, SandboxTaskDevOptions as d, SandboxTaskDriver as f, SandboxTaskRunResult as g, SandboxTaskRunArguments as h, SandboxTaskDefinition as i, SandboxTaskDefinitionInput as l, SandboxTaskProjectOptions as m, CloudflareSandboxTaskDefinitionDriverOptions as n, SandboxTaskDefinitionDriverOptions as o, SandboxTaskExecutionOptions as p, CloudflareSandboxTaskOptions as r, SandboxTaskDefinitionFromHandler as s, AgentSandboxTaskConfig as t, SandboxTaskDefinitionOptions as u, VercelSandboxTaskDriverOptions as v, getSandboxTaskFeatureDriver as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, readdir } from "node:fs/promises";
|
|
2
2
|
import { setTimeout } from "node:timers/promises";
|
|
3
|
-
|
|
3
|
+
// ../internal/src/process-sweep.ts
|
|
4
4
|
const maxRounds = 10;
|
|
5
5
|
/**
|
|
6
6
|
* Stops every process of this user that started with `name=value` in its environment: SIGTERM, then
|
|
@@ -29,5 +29,4 @@ function signal(pid, name) {
|
|
|
29
29
|
process.kill(pid, name);
|
|
30
30
|
} catch {}
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export { stopMarkedProcesses as t };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { l as Sandbox } from "./index-
|
|
2
|
-
import { f as SandboxTaskDriver, o as SandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "./module-types-
|
|
1
|
+
import { l as Sandbox } from "./index-D9DogaoF.js";
|
|
2
|
+
import { f as SandboxTaskDriver, o as SandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "./module-types-DHr6oC3h.js";
|
|
3
3
|
import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
4
|
-
//#region src/task/runtime/task-sandbox.d.ts
|
|
5
4
|
/** `local` runs a Sandbox Task as a process on this machine, which only `vite dev` does. */
|
|
6
5
|
type SandboxTaskExecutionProvider = 'cloudflare' | 'vercel' | 'local';
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/task/runtime/provider-loader.d.ts
|
|
9
6
|
interface ResolvedTaskSandbox {
|
|
10
7
|
provider: SandboxTaskExecutionProvider;
|
|
11
8
|
resolveSandbox: (requirements: readonly string[]) => Promise<Sandbox>;
|
|
@@ -20,5 +17,4 @@ interface SandboxTaskRuntimeProvider {
|
|
|
20
17
|
} | any) => Promise<ResolvedTaskSandbox>;
|
|
21
18
|
}
|
|
22
19
|
declare function loadSandboxTaskRuntimeProvider(provider: SandboxTaskDriver): Promise<SandboxTaskRuntimeProvider>;
|
|
23
|
-
//#endregion
|
|
24
20
|
export { SandboxTaskRuntimeProvider as n, loadSandboxTaskRuntimeProvider as r, ResolvedTaskSandbox as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
1
|
+
import { t as getActiveCloudflareEnv } from "./cloudflare-env-lookup-BNbNil7g.js";
|
|
2
|
+
import { t as assertSandboxTaskTransferOptions } from "./transfer-options-LTUzbHDw.js";
|
|
3
|
+
import { t as sandboxTaskErrorDiagnostics } from "./error-diagnostics-D9n0ZmdN.js";
|
|
3
4
|
import { ViteHubError, getViteHubErrorShape } from "@vite-hub/runtime";
|
|
4
|
-
|
|
5
|
+
// src/task/sandbox-task/errors.ts
|
|
5
6
|
function sanitizeSandboxTaskDetail(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
6
7
|
if (value === null || typeof value === "boolean") return value;
|
|
7
8
|
if (typeof value === "string") return value.slice(0, 16384);
|
|
@@ -45,8 +46,7 @@ function sandboxTaskError(message, metadata = {}) {
|
|
|
45
46
|
function isSandboxTaskError(value) {
|
|
46
47
|
return getViteHubErrorShape(value)?.code.startsWith("SANDBOX_TASK_") === true;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
//#region src/task/internal/shared/provider-detection.ts
|
|
49
|
+
// src/task/internal/shared/provider-detection.ts
|
|
50
50
|
function createProviderDetector(rules) {
|
|
51
51
|
return () => {
|
|
52
52
|
for (const rule of rules) if (rule.when()) return rule.provider;
|
|
@@ -63,9 +63,12 @@ const isVercel = () => {
|
|
|
63
63
|
const env = getRuntimeEnv();
|
|
64
64
|
return !!(env.VERCEL || env.VERCEL_ENV);
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// src/task/runtime/provider-resolution.ts
|
|
67
|
+
const allowedDefinitionKeys = /* @__PURE__ */ new Set([
|
|
68
|
+
"timeout",
|
|
69
|
+
"env",
|
|
70
|
+
"transfer"
|
|
71
|
+
]);
|
|
69
72
|
const maxTimeout = 2147483647;
|
|
70
73
|
/** The timeout of a Sandbox Task run that sets no `timeout`, on every provider. */
|
|
71
74
|
const DEFAULT_SANDBOX_TASK_TIMEOUT_MS = 3e5;
|
|
@@ -114,8 +117,9 @@ function unsupportedHostedSandboxTaskProviderError(provider) {
|
|
|
114
117
|
}
|
|
115
118
|
function assertSandboxTaskDefinitionOptions(local) {
|
|
116
119
|
const invalidKeys = Object.keys(local).filter((key) => !allowedDefinitionKeys.has(key));
|
|
117
|
-
if (invalidKeys.length > 0) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0069({ message: `[vitehub] Sandbox Task Definition options only support timeout and
|
|
120
|
+
if (invalidKeys.length > 0) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0069({ message: `[vitehub] Sandbox Task Definition options only support timeout, env, and transfer. Unsupported: ${invalidKeys.join(", ")}` });
|
|
118
121
|
if (local.timeout !== void 0 && (!Number.isInteger(local.timeout) || local.timeout <= 0 || local.timeout > maxTimeout)) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0070({ message: `[vitehub] Sandbox Task Definition timeout must be a positive integer no greater than ${maxTimeout}.` });
|
|
122
|
+
assertSandboxTaskTransferOptions(local.transfer);
|
|
119
123
|
}
|
|
120
124
|
async function resolveTaskSandbox(provider, providerOptions, local) {
|
|
121
125
|
return await (await (await import("#vitehub-sandbox-task-provider-loader")).loadSandboxTaskRuntimeProvider(provider)).resolveTaskSandbox({
|
|
@@ -129,5 +133,4 @@ function withSandboxTaskProvider(provider, options) {
|
|
|
129
133
|
driver: provider
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
|
-
//#endregion
|
|
133
136
|
export { resolveTaskSandbox as a, isSandboxTaskError as c, resolveRuntimeProvider as i, sandboxTaskError as l, assertSandboxTaskDefinitionOptions as n, unsupportedHostedSandboxTaskProviderError as o, createCloudflareExecutionSandboxId as r, withSandboxTaskProvider as s, DEFAULT_SANDBOX_TASK_TIMEOUT_MS as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as shellQuote } from "./shell-quote-
|
|
3
|
-
import {
|
|
1
|
+
import { a as sandboxRequirementSecrets, i as sandboxRequirementPlan, o as sandboxRequirementSignal, r as sandboxRequirementError, s as materializeGitCheckout, t as createSandboxSession } from "./session-DmUiyj4O.js";
|
|
2
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
3
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
4
4
|
import { normalizeExecutionAuthority } from "@vite-hub/runtime";
|
|
5
|
-
|
|
5
|
+
// src/internal/remote.ts
|
|
6
6
|
async function resolveRemoteSandboxRuntime(runtime, requirements) {
|
|
7
7
|
const resolvedRequirements = requirements.map((command) => ({
|
|
8
8
|
args: [],
|
|
@@ -165,7 +165,7 @@ async function settleFileOperations(operations, signal) {
|
|
|
165
165
|
}
|
|
166
166
|
async function provisionRemoteToolchain(input, session, options, environment) {
|
|
167
167
|
const { abortSignal, home, workspace } = options;
|
|
168
|
-
const { provisionToolchain, readProjectFilesWithShell, verifyToolchain } = await import("./toolchain-
|
|
168
|
+
const { provisionToolchain, readProjectFilesWithShell, verifyToolchain } = await import("./toolchain-DFFxmw3N.js").then((n) => n.i);
|
|
169
169
|
const run = async (script) => await session.run({
|
|
170
170
|
abortSignal,
|
|
171
171
|
command: `sh -c ${shellQuote(script)}`,
|
|
@@ -257,5 +257,4 @@ function snapshotStream(read) {
|
|
|
257
257
|
}
|
|
258
258
|
} });
|
|
259
259
|
}
|
|
260
|
-
//#endregion
|
|
261
260
|
export { resolveRemoteSandboxRuntime as a, resolveRemoteEnvironment as i, openRemoteSandbox as n, snapshotStream as o, remoteSandboxPlan as r, collectProcessOutput as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __exportAll = (all, no_symbols) => {
|
|
5
5
|
let target = {};
|
|
@@ -10,5 +10,4 @@ var __exportAll = (all, no_symbols) => {
|
|
|
10
10
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
11
|
return target;
|
|
12
12
|
};
|
|
13
|
-
//#endregion
|
|
14
13
|
export { __exportAll as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/runtime.ts
|
|
2
2
|
const builtInSandboxRuntime = Symbol.for("vitehub.sandbox.internal-runtime");
|
|
3
3
|
function isFunction(value) {
|
|
4
4
|
return typeof value === "function";
|
|
@@ -28,5 +28,4 @@ function markBuiltInSandboxRuntime(runtime) {
|
|
|
28
28
|
Object.defineProperty(runtime, builtInSandboxRuntime, { value: true });
|
|
29
29
|
return runtime;
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
31
|
export { isBuiltInSandboxRuntime as n, markBuiltInSandboxRuntime as r, hasDeclaredSandboxRuntimeMember as t };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/runtime-type.ts
|
|
2
2
|
/** Returns a plain JSON-style object, or undefined for primitives, arrays, and functions. */
|
|
3
3
|
function runtimeRecord(value) {
|
|
4
4
|
if (value === null || Object(value) !== value || Array.isArray(value)) return;
|
|
5
5
|
if (Object.prototype.toString.call(value) !== "[object Object]") return;
|
|
6
6
|
return value;
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { runtimeRecord as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { t as shellQuote } from "./shell-quote-
|
|
1
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
2
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
3
3
|
import { posix } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/internal/git-checkout.ts
|
|
5
5
|
async function materializeGitCheckout(checkout, workspace, runner) {
|
|
6
6
|
await run("initialize", [
|
|
7
7
|
"init",
|
|
@@ -57,8 +57,7 @@ async function materializeGitCheckout(checkout, workspace, runner) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/internal/requirements.ts
|
|
60
|
+
// src/internal/requirements.ts
|
|
62
61
|
const maximumDiagnosticLength = 4e3;
|
|
63
62
|
function sandboxRequirementPlan(requirements) {
|
|
64
63
|
return requirements.map(({ command, name, timeout }) => ({
|
|
@@ -152,8 +151,7 @@ function redactDiagnosticJson(value, patterns) {
|
|
|
152
151
|
}
|
|
153
152
|
return value;
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
//#region src/internal/session.ts
|
|
154
|
+
// src/internal/session.ts
|
|
157
155
|
function isExcludedSandboxPath(path, excluded) {
|
|
158
156
|
const normalized = posix.normalize(path);
|
|
159
157
|
return excluded.some((item) => {
|
|
@@ -334,5 +332,4 @@ function commandLine(command, args) {
|
|
|
334
332
|
function assertPort(port) {
|
|
335
333
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw sandboxErrorDiagnostics.SANDBOX_R0129({ message: "[vitehub] Sandbox ports must be integers between 1 and 65535." });
|
|
336
334
|
}
|
|
337
|
-
//#endregion
|
|
338
335
|
export { sandboxRequirementSecrets as a, sandboxRequirementPlan as i, collectSandboxRequirementOutput as n, sandboxRequirementSignal as o, sandboxRequirementError as r, materializeGitCheckout as s, createSandboxSession as t };
|
package/dist/ssh.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/ssh.d.ts
|
|
2
1
|
export interface SshLaunchOptions {
|
|
3
2
|
host: string;
|
|
4
3
|
user: string;
|
|
@@ -59,5 +58,4 @@ export interface SshServer {
|
|
|
59
58
|
close(options?: SshServerCloseOptions): Promise<void>;
|
|
60
59
|
}
|
|
61
60
|
/** An authenticated command server, not a filesystem or network sandbox. */
|
|
62
|
-
export declare function serveSsh(options: SshServerOptions): Promise<SshServer>;
|
|
63
|
-
//#endregion
|
|
61
|
+
export declare function serveSsh(options: SshServerOptions): Promise<SshServer>;
|
package/dist/ssh.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
2
|
+
import { t as stopMarkedProcesses } from "./process-sweep-DVaTb2pO.js";
|
|
3
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { execFile, spawn } from "node:child_process";
|
|
7
7
|
import { once } from "node:events";
|
|
8
8
|
import { createServer } from "node:net";
|
|
9
9
|
import { promisify } from "node:util";
|
|
10
|
-
|
|
10
|
+
// src/ssh-launcher.injected.ts
|
|
11
11
|
/**
|
|
12
12
|
* Source text of the SSH launcher. It runs in its own Node process outside the application bundle, with only Node and
|
|
13
13
|
* OpenSSH, so its errors are plain. Its exit status and stderr reach the caller of `sshLaunch()`.
|
|
@@ -95,8 +95,7 @@ try {
|
|
|
95
95
|
if (temporary) await rm(temporary, { recursive: true, force: true })
|
|
96
96
|
}
|
|
97
97
|
`;
|
|
98
|
-
|
|
99
|
-
//#region src/ssh.ts
|
|
98
|
+
// src/ssh.ts
|
|
100
99
|
const maxTimeoutMs = 2147483647;
|
|
101
100
|
const environmentName = /^[A-Z_][A-Z0-9_]*$/;
|
|
102
101
|
const commandEnvironmentKey = "VITEHUB_SSH_COMMAND";
|
|
@@ -286,5 +285,4 @@ async function serveSsh(options) {
|
|
|
286
285
|
}
|
|
287
286
|
};
|
|
288
287
|
}
|
|
289
|
-
//#endregion
|
|
290
288
|
export { serveSsh, sshLaunch };
|
package/dist/task/index.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as SandboxTaskTransferOptions, a as SandboxTaskDefinitionBundle, b as SandboxTaskSizeOptions, c as SandboxTaskDefinitionHandler, d as SandboxTaskDevOptions, f as SandboxTaskDriver, g as SandboxTaskRunResult, h as SandboxTaskRunArguments, i as SandboxTaskDefinition, l as SandboxTaskDefinitionInput, m as SandboxTaskProjectOptions, n as CloudflareSandboxTaskDefinitionDriverOptions, o as SandboxTaskDefinitionDriverOptions, p as SandboxTaskExecutionOptions, r as CloudflareSandboxTaskOptions, s as SandboxTaskDefinitionFromHandler, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions, v as VercelSandboxTaskDriverOptions, y as getSandboxTaskFeatureDriver } from "../module-types-DHr6oC3h.js";
|
|
2
2
|
import { ExecutionAuthority, ViteHubContext } from "@vite-hub/runtime";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
import { SandboxTaskDefinitionModules } from "#vitehub-sandbox-task-registry";
|
|
5
|
-
//#region src/task/runtime/registry.d.ts
|
|
6
5
|
export declare function defineSandboxTask<THandler extends (...args: any[]) => any>(input: SandboxTaskDefinitionInput<Parameters<THandler>[0], Awaited<ReturnType<THandler>>> & {
|
|
7
6
|
handler: THandler;
|
|
8
7
|
}): SandboxTaskDefinitionFromHandler<THandler>;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/task/internal/shared/request-payload.d.ts
|
|
11
8
|
/** Read the JSON body of the request in the event's Standard Context, or `fallback` when the body is not JSON. */
|
|
12
9
|
export declare function readRequestPayload(event: ViteHubContext, fallback?: unknown): Promise<unknown>;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/task/internal/shared/validation.d.ts
|
|
15
10
|
interface ValidationIssue {
|
|
16
11
|
message: string;
|
|
17
12
|
path?: readonly unknown[];
|
|
@@ -38,8 +33,6 @@ interface ValidationOptions<TValue = unknown> {
|
|
|
38
33
|
}
|
|
39
34
|
export declare function readValidatedPayload<TInput, TOutput>(payload: TInput, validate: StandardSchemaValidator<TInput, TOutput>, options?: ValidationOptions<TInput>): Promise<TOutput>;
|
|
40
35
|
export declare function readValidatedPayload<TInput, TResult>(payload: TInput, validate: ValidationFunction<TInput, TResult>, options?: ValidationOptions<TInput>): Promise<ValidationResult<TInput, Awaited<TResult>>>;
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/task/runtime/registry-types.d.ts
|
|
43
36
|
type SandboxTaskDefinitionName = keyof SandboxTaskDefinitionModules;
|
|
44
37
|
type SandboxTaskRegistryDefinition<TName extends keyof SandboxTaskDefinitionModules> = SandboxTaskDefinitionModules[TName];
|
|
45
38
|
type SandboxTaskPayload<TDefinition> = TDefinition extends {
|
|
@@ -52,18 +45,12 @@ type DecodedSandboxValue<TValue, TApplyToJSON extends boolean = true> = TValue e
|
|
|
52
45
|
toJSON(key: string): infer TSerialized;
|
|
53
46
|
} ? DecodedSandboxValue<TSerialized, false> | (TValue extends Date ? null : never) : DecodedSandboxJson<TValue>;
|
|
54
47
|
type DecodedSandboxJson<TValue> = TValue extends string | number | boolean | null ? TValue : TValue extends InstanceType<StringConstructor> ? string : TValue extends InstanceType<NumberConstructor> ? number : TValue extends InstanceType<BooleanConstructor> ? boolean : TValue extends readonly unknown[] ? { [TIndex in keyof TValue]: DecodedSandboxValue<TValue[TIndex]>; } : TValue extends ((...args: never[]) => unknown) | undefined | bigint | symbol ? never : TValue extends object ? { [TKey in keyof TValue as TKey extends symbol ? never : TValue[TKey] extends ((...args: never[]) => unknown) ? never : TKey]: DecodedSandboxValue<TValue[TKey]>; } : TValue;
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/task/runtime/public.d.ts
|
|
57
48
|
/**
|
|
58
49
|
* Run a Sandbox Task by its name. `data` is the decoded handler result, such as a JSON value or a native `Response`.
|
|
59
50
|
* A failed run returns `SANDBOX_TASK_RUN_FAILED`, and `toResponse(error)` answers with its status.
|
|
60
51
|
*/
|
|
61
52
|
export declare function runSandboxTask<const TName extends string>(name: TName, ...args: SandboxTaskRunArguments<TName extends SandboxTaskDefinitionName ? SandboxTaskPayload<SandboxTaskRegistryDefinition<TName>> : unknown>): Promise<SandboxTaskRunResult<TName extends SandboxTaskDefinitionName ? SandboxTaskResult<SandboxTaskRegistryDefinition<TName>> : unknown>>;
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/task/runtime/provider-resolution.d.ts
|
|
64
53
|
export declare function unsupportedHostedSandboxTaskProviderError(provider: unknown): Error;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/task/runtime/runtime.d.ts
|
|
67
54
|
interface SandboxTaskRunner {
|
|
68
55
|
readonly executionAuthority: ExecutionAuthority;
|
|
69
56
|
name: string;
|
|
@@ -74,5 +61,4 @@ type ResolvedSandboxTaskRunner<TPayload, TResult> = Omit<SandboxTaskRunner, 'run
|
|
|
74
61
|
};
|
|
75
62
|
export declare function resolveSandboxTaskRunner<const TName extends SandboxTaskDefinitionName>(name: TName): Promise<ResolvedSandboxTaskRunner<SandboxTaskPayload<SandboxTaskRegistryDefinition<TName>>, SandboxTaskResult<SandboxTaskRegistryDefinition<TName>>>>;
|
|
76
63
|
export declare function resolveSandboxTaskRunner<TPayload = unknown, TResult = unknown>(name?: string): Promise<ResolvedSandboxTaskRunner<TPayload, TResult>>;
|
|
77
|
-
|
|
78
|
-
export type { AgentSandboxTaskConfig, CloudflareSandboxTaskDefinitionDriverOptions, CloudflareSandboxTaskOptions, SandboxTaskDefinition, SandboxTaskDefinitionBundle, SandboxTaskDefinitionDriverOptions, SandboxTaskDefinitionFromHandler, SandboxTaskDefinitionHandler, SandboxTaskDefinitionInput, SandboxTaskDefinitionOptions, SandboxTaskDevOptions, SandboxTaskDriver, SandboxTaskExecutionOptions, SandboxTaskProjectOptions, SandboxTaskRunArguments, SandboxTaskRunResult, SandboxTaskRunner, SandboxTaskSizeOptions, VercelSandboxTaskDriverOptions, getSandboxTaskFeatureDriver };
|
|
64
|
+
export type { AgentSandboxTaskConfig, CloudflareSandboxTaskDefinitionDriverOptions, CloudflareSandboxTaskOptions, SandboxTaskDefinition, SandboxTaskDefinitionBundle, SandboxTaskDefinitionDriverOptions, SandboxTaskDefinitionFromHandler, SandboxTaskDefinitionHandler, SandboxTaskDefinitionInput, SandboxTaskDefinitionOptions, SandboxTaskDevOptions, SandboxTaskDriver, SandboxTaskExecutionOptions, SandboxTaskProjectOptions, SandboxTaskRunArguments, SandboxTaskRunResult, SandboxTaskRunner, SandboxTaskSizeOptions, SandboxTaskTransferOptions, VercelSandboxTaskDriverOptions, getSandboxTaskFeatureDriver };
|