@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.
- 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-ClSiUwCm.js} +1 -2
- 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-NYnG3NGz.d.ts → module-types-B3uJG1po.d.ts} +1 -9
- package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
- package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
- package/dist/{provider-loader-Cvqoz7_Z.d.ts → provider-loader-CNKHrWXG.d.ts} +2 -6
- package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-Cl2NKhRP.js} +5 -8
- 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 +1 -15
- package/dist/task/index.js +21 -37
- 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 +22 -23
- package/dist/task/vite.js +53 -68
- package/dist/{toolchain-DF9eutyQ.js → toolchain-DFFxmw3N.js} +6 -7
- 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-BGuXoKxG.js} +3 -5
- package/package.json +10 -10
|
@@ -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 VercelSandboxTaskDriverOptions, a as SandboxTaskDefinitionBundle, 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 getSandboxTaskFeatureDriver, y as SandboxTaskSizeOptions } from "../module-types-
|
|
1
|
+
import { _ as VercelSandboxTaskDriverOptions, a as SandboxTaskDefinitionBundle, 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 getSandboxTaskFeatureDriver, y as SandboxTaskSizeOptions } from "../module-types-B3uJG1po.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
|
-
//#endregion
|
|
78
64
|
export type { AgentSandboxTaskConfig, CloudflareSandboxTaskDefinitionDriverOptions, CloudflareSandboxTaskOptions, SandboxTaskDefinition, SandboxTaskDefinitionBundle, SandboxTaskDefinitionDriverOptions, SandboxTaskDefinitionFromHandler, SandboxTaskDefinitionHandler, SandboxTaskDefinitionInput, SandboxTaskDefinitionOptions, SandboxTaskDevOptions, SandboxTaskDriver, SandboxTaskExecutionOptions, SandboxTaskProjectOptions, SandboxTaskRunArguments, SandboxTaskRunResult, SandboxTaskRunner, SandboxTaskSizeOptions, VercelSandboxTaskDriverOptions, getSandboxTaskFeatureDriver };
|
package/dist/task/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as isTrustedHostReservedCommandEnvironmentKey } from "../trusted-host-environment-
|
|
1
|
+
import { t as sandboxTaskErrorDiagnostics } from "../error-diagnostics-ClSiUwCm.js";
|
|
2
|
+
import { a as resolveTaskSandbox, c as isSandboxTaskError, i as resolveRuntimeProvider, l as sandboxTaskError, n as assertSandboxTaskDefinitionOptions, o as unsupportedHostedSandboxTaskProviderError, r as createCloudflareExecutionSandboxId, s as withSandboxTaskProvider } from "../provider-resolution-Cl2NKhRP.js";
|
|
3
|
+
import { n as cloudflareRetryDelays, r as readCloudflareFailure, t as canRetryCloudflareRequest } from "../cloudflare-failure-f-3P3ul-.js";
|
|
4
|
+
import { t as isTrustedHostReservedCommandEnvironmentKey } from "../trusted-host-environment-BJE5hGtQ.js";
|
|
5
5
|
import { getSandboxTaskRuntimeConfig, getSandboxTaskRuntimeLocalProvider, getSandboxTaskRuntimeRegistry } from "./runtime/state.js";
|
|
6
|
-
import { t as getSandboxTaskFeatureDriver } from "../module-types-
|
|
6
|
+
import { t as getSandboxTaskFeatureDriver } from "../module-types-CWcBHyEs.js";
|
|
7
7
|
import { defineErrors, getViteHubErrorShape } from "@vite-hub/runtime";
|
|
8
8
|
import { types } from "node:util";
|
|
9
9
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
10
10
|
import { deserializeResponse, isSerializedResponse } from "@vite-hub/runtime/internal/response";
|
|
11
11
|
import { dirname } from "pathe";
|
|
12
|
-
|
|
12
|
+
// src/task/internal/shared/definition.ts
|
|
13
13
|
function assertDefinitionHandler(functionName, handler, label) {
|
|
14
14
|
if (typeof handler !== "function") throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_C0010({ message: `[vitehub] \`${functionName}()\` requires a ${label} as the first argument.` });
|
|
15
15
|
}
|
|
@@ -23,8 +23,7 @@ function validateDefinitionOptions(functionName, options, config) {
|
|
|
23
23
|
if (invalidKeys.length) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_C0012({ message: `[vitehub] \`${functionName}()\` ${config.invalidKeysMessage}. Unsupported keys: ${invalidKeys.join(", ")}.` });
|
|
24
24
|
return options;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
//#region src/task/runtime/registry.ts
|
|
26
|
+
// src/task/runtime/registry.ts
|
|
28
27
|
function createSandboxTaskDefinition(functionName, input) {
|
|
29
28
|
if (input instanceof Object && Object.hasOwn(input, "run")) throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_C0014({ message: `[vitehub] \`${functionName}({ run })\` was renamed. Pass the Sandbox handler as \`handler\`: \`${functionName}({ handler })\`.` });
|
|
30
29
|
const validated = validateDefinitionOptions(functionName, input, {
|
|
@@ -48,14 +47,12 @@ function createSandboxTaskDefinition(functionName, input) {
|
|
|
48
47
|
function defineSandboxTask(input) {
|
|
49
48
|
return createSandboxTaskDefinition("defineSandboxTask", input);
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
//#region src/task/internal/shared/request-payload.ts
|
|
50
|
+
// src/task/internal/shared/request-payload.ts
|
|
53
51
|
/** Read the JSON body of the request in the event's Standard Context, or `fallback` when the body is not JSON. */
|
|
54
52
|
async function readRequestPayload(event, fallback = {}) {
|
|
55
53
|
return await getStandardContext(event).req.json().catch(() => fallback);
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
//#region src/task/internal/shared/validation.ts
|
|
55
|
+
// src/task/internal/shared/validation.ts
|
|
59
56
|
const VALIDATION_FAILED = "Validation failed";
|
|
60
57
|
function isObject(value) {
|
|
61
58
|
return !!value && typeof value === "object";
|
|
@@ -148,8 +145,7 @@ async function readValidatedPayload(payload, validate, options) {
|
|
|
148
145
|
throw createValidationError(error);
|
|
149
146
|
}
|
|
150
147
|
}
|
|
151
|
-
|
|
152
|
-
//#region src/task/internal/shared/utils.ts
|
|
148
|
+
// src/task/internal/shared/utils.ts
|
|
153
149
|
async function sleep(ms, signal) {
|
|
154
150
|
if (signal?.aborted) throw signal.reason;
|
|
155
151
|
await new Promise((resolve, reject) => {
|
|
@@ -165,8 +161,7 @@ async function sleep(ms, signal) {
|
|
|
165
161
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
166
162
|
});
|
|
167
163
|
}
|
|
168
|
-
|
|
169
|
-
//#region src/task/runtime/binary-sidecars.ts
|
|
164
|
+
// src/task/runtime/binary-sidecars.ts
|
|
170
165
|
const SANDBOX_VALUE_MARKER = "vitehub:sandbox-task:value";
|
|
171
166
|
function isPlainObject(value) {
|
|
172
167
|
if (!value || typeof value !== "object") return false;
|
|
@@ -303,8 +298,7 @@ async function decodeSandboxTaskValue(sandbox, value, assetsDir, label, signal)
|
|
|
303
298
|
});
|
|
304
299
|
return descriptor.kind === "blob" ? new Blob([bytes], { type: descriptor.type || "" }) : descriptor.kind === "buffer" ? Buffer.from(bytes) : bytes;
|
|
305
300
|
}
|
|
306
|
-
|
|
307
|
-
//#region src/task/runtime/error-normalization.ts
|
|
301
|
+
// src/task/runtime/error-normalization.ts
|
|
308
302
|
function readSandboxTaskErrorMetadata(error) {
|
|
309
303
|
if (!error || typeof error !== "object") return void 0;
|
|
310
304
|
const metadata = error;
|
|
@@ -362,8 +356,7 @@ function readErrorMessage(error) {
|
|
|
362
356
|
function sandboxTaskCode(code) {
|
|
363
357
|
return code?.startsWith("SANDBOX_TASK_") ? code : "SANDBOX_TASK_RUNTIME_ERROR";
|
|
364
358
|
}
|
|
365
|
-
|
|
366
|
-
//#region src/task/runtime/entry-script.injected.ts
|
|
359
|
+
// src/task/runtime/entry-script.injected.ts
|
|
367
360
|
const EXEC_STDIO_OUTPUT_MARKER = "__VITEHUB_OUTPUT__";
|
|
368
361
|
function createEntrySource(definitionPath, execution = "definition", env) {
|
|
369
362
|
const invocation = execution === "module" ? [
|
|
@@ -668,8 +661,7 @@ function createEntrySource(definitionPath, execution = "definition", env) {
|
|
|
668
661
|
``
|
|
669
662
|
].join("\n");
|
|
670
663
|
}
|
|
671
|
-
|
|
672
|
-
//#region src/task/runtime/execution-files.ts
|
|
664
|
+
// src/task/runtime/execution-files.ts
|
|
673
665
|
const DEFAULT_DEFINITION_ENTRY = "definition.js";
|
|
674
666
|
function normalizeSandboxTaskDefinitionBundle(source) {
|
|
675
667
|
if (typeof source === "string") return {
|
|
@@ -735,8 +727,7 @@ async function writeSandboxTaskDefinitionBundle(sandbox, baseDir, bundle, signal
|
|
|
735
727
|
else await sandbox.exec("chmod", [mode.toString(8), `${baseDir}/${path}`]);
|
|
736
728
|
}));
|
|
737
729
|
}
|
|
738
|
-
|
|
739
|
-
//#region src/task/runtime/definition-preparation.ts
|
|
730
|
+
// src/task/runtime/definition-preparation.ts
|
|
740
731
|
const projectPreparations = /* @__PURE__ */ new Map();
|
|
741
732
|
async function prepareSandboxTaskDefinition(sandbox, bundle, baseDir, options) {
|
|
742
733
|
const project = bundle.project;
|
|
@@ -834,8 +825,7 @@ async function prepareSandboxTaskProjectAtomically(sandbox, bundle, projectDir,
|
|
|
834
825
|
]).catch(() => {});
|
|
835
826
|
}
|
|
836
827
|
}
|
|
837
|
-
|
|
838
|
-
//#region src/task/runtime/output-recovery.ts
|
|
828
|
+
// src/task/runtime/output-recovery.ts
|
|
839
829
|
const MIN_EXEC_OUTPUT_RECOVERY_TIMEOUT_MS = 2e4;
|
|
840
830
|
const DEFAULT_EXEC_OUTPUT_RECOVERY_TIMEOUT_MS = 6e4;
|
|
841
831
|
const MAX_EXEC_OUTPUT_RECOVERY_TIMEOUT_MS = 12e4;
|
|
@@ -998,8 +988,7 @@ async function readExecOutputWithRecovery(sandbox, outputPath, error, timeout, e
|
|
|
998
988
|
}
|
|
999
989
|
return await waitForCloudflareOutput(sandbox, outputPath, error, timeout, execution, signal);
|
|
1000
990
|
}
|
|
1001
|
-
|
|
1002
|
-
//#region src/task/runtime/execute.ts
|
|
991
|
+
// src/task/runtime/execute.ts
|
|
1003
992
|
const SANDBOX_CLEANUP_GRACE_MS = 1e3;
|
|
1004
993
|
function toJson(value, label) {
|
|
1005
994
|
try {
|
|
@@ -1185,8 +1174,7 @@ async function executeSandboxTaskDefinition(sandbox, definitionName, definitionO
|
|
|
1185
1174
|
if (externalAbort) externalSignal?.removeEventListener("abort", externalAbort);
|
|
1186
1175
|
}
|
|
1187
1176
|
}
|
|
1188
|
-
|
|
1189
|
-
//#region src/task/runtime/task-sandbox.ts
|
|
1177
|
+
// src/task/runtime/task-sandbox.ts
|
|
1190
1178
|
function createTaskSandbox(session, provider, closesAfterRun) {
|
|
1191
1179
|
return {
|
|
1192
1180
|
executionAuthority: session.executionAuthority,
|
|
@@ -1217,8 +1205,7 @@ function createTaskSandbox(session, provider, closesAfterRun) {
|
|
|
1217
1205
|
}
|
|
1218
1206
|
};
|
|
1219
1207
|
}
|
|
1220
|
-
|
|
1221
|
-
//#region src/task/runtime/result.ts
|
|
1208
|
+
// src/task/runtime/result.ts
|
|
1222
1209
|
const sandboxTaskRunErrors = /*#__PURE__*/ defineErrors({
|
|
1223
1210
|
docs: "https://vitehub.dev/docs/sandbox/diagnostics",
|
|
1224
1211
|
codes: { SANDBOX_TASK_RUN_FAILED: {
|
|
@@ -1250,8 +1237,7 @@ function runFailed(name, error) {
|
|
|
1250
1237
|
value: statusFor(error)
|
|
1251
1238
|
});
|
|
1252
1239
|
}
|
|
1253
|
-
|
|
1254
|
-
//#region src/task/runtime/runtime.ts
|
|
1240
|
+
// src/task/runtime/runtime.ts
|
|
1255
1241
|
const cloudflareRunQueues = /* @__PURE__ */ new Map();
|
|
1256
1242
|
async function awaitWithAbort(promise, signal) {
|
|
1257
1243
|
if (!signal) return await promise;
|
|
@@ -1413,10 +1399,8 @@ async function runSandboxTaskRuntime(name, payload, options) {
|
|
|
1413
1399
|
return [runFailed(name ?? "", toSandboxTaskError(error)), void 0];
|
|
1414
1400
|
}
|
|
1415
1401
|
}
|
|
1416
|
-
|
|
1417
|
-
//#region src/task/runtime/public.ts
|
|
1402
|
+
// src/task/runtime/public.ts
|
|
1418
1403
|
async function runSandboxTask(name, payload, options) {
|
|
1419
1404
|
return await runSandboxTaskRuntime(name, payload, options);
|
|
1420
1405
|
}
|
|
1421
|
-
//#endregion
|
|
1422
1406
|
export { defineSandboxTask, readRequestPayload, readValidatedPayload, resolveSandboxTaskRunner, runSandboxTask, unsupportedHostedSandboxTaskProviderError };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/task/runtime/empty-registry.ts
|
|
2
2
|
function getRuntimeRegistry() {
|
|
3
3
|
return globalThis.__vitehubSandboxTaskRegistry || {};
|
|
4
4
|
}
|
|
@@ -16,5 +16,4 @@ const registry = new Proxy({}, {
|
|
|
16
16
|
return Object.getOwnPropertyDescriptor(getRuntimeRegistry(), key);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
//#endregion
|
|
20
19
|
export { registry as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SandboxTaskRuntimeProvider, r as loadSandboxTaskRuntimeProvider, t as ResolvedTaskSandbox } from "../../provider-loader-
|
|
1
|
+
import { n as SandboxTaskRuntimeProvider, r as loadSandboxTaskRuntimeProvider, t as ResolvedTaskSandbox } from "../../provider-loader-CNKHrWXG.js";
|
|
2
2
|
export { ResolvedTaskSandbox, SandboxTaskRuntimeProvider, loadSandboxTaskRuntimeProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-
|
|
2
|
-
|
|
1
|
+
import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-ClSiUwCm.js";
|
|
2
|
+
// src/task/runtime/provider-loader.ts
|
|
3
3
|
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
4
4
|
async function loadSandboxTaskRuntimeProvider(provider) {
|
|
5
5
|
if (provider === "cloudflare") {
|
|
@@ -12,5 +12,4 @@ async function loadSandboxTaskRuntimeProvider(provider) {
|
|
|
12
12
|
}
|
|
13
13
|
throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0068({ message: `[vitehub] Unsupported sandbox provider: ${provider}` });
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { loadSandboxTaskRuntimeProvider };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { l as Sandbox } from "../../../index-
|
|
2
|
-
import { n as CloudflareSandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-
|
|
3
|
-
//#region src/task/runtime/providers/cloudflare.d.ts
|
|
1
|
+
import { l as Sandbox } from "../../../index-D9DogaoF.js";
|
|
2
|
+
import { n as CloudflareSandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-B3uJG1po.js";
|
|
4
3
|
type SandboxTaskOptions = {
|
|
5
4
|
local: SandboxTaskDefinitionOptions;
|
|
6
5
|
provider: CloudflareSandboxTaskDefinitionDriverOptions;
|
|
@@ -11,4 +10,4 @@ export declare function resolveCloudflareTaskSandbox(options: SandboxTaskOptions
|
|
|
11
10
|
sandboxId: string | undefined;
|
|
12
11
|
resolveSandbox: (requirements: readonly string[]) => Promise<Sandbox>;
|
|
13
12
|
}>;
|
|
14
|
-
|
|
13
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveCloudflareSandbox } from "../../../internal/cloudflare.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
|
|
2
|
+
import { t as getActiveCloudflareEnv } from "../../../cloudflare-env-lookup-BNbNil7g.js";
|
|
3
|
+
import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-ClSiUwCm.js";
|
|
4
|
+
// src/task/runtime/providers/cloudflare.ts
|
|
5
5
|
/** Resolve the Sandbox namespace from the bindings of the active Cloudflare request. */
|
|
6
6
|
async function resolveCloudflareTaskSandbox(options) {
|
|
7
7
|
const env = getActiveCloudflareEnv();
|
|
@@ -23,5 +23,4 @@ async function resolveCloudflareTaskSandbox(options) {
|
|
|
23
23
|
}, requirements)
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
//#endregion
|
|
27
26
|
export { resolveCloudflareTaskSandbox };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { t as ResolvedTaskSandbox } from "../../../provider-loader-
|
|
2
|
-
//#region src/task/runtime/providers/local.d.ts
|
|
1
|
+
import { t as ResolvedTaskSandbox } from "../../../provider-loader-CNKHrWXG.js";
|
|
3
2
|
/**
|
|
4
3
|
* `vite dev` runs each Sandbox Task as a Node process on this machine, in a temporary directory that the run removes.
|
|
5
4
|
* The process is not isolated: the Sandbox `executionAuthority` says `isolation: "none"`.
|
|
6
5
|
*/
|
|
7
|
-
export declare function resolveLocalTaskSandbox(): ResolvedTaskSandbox;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function resolveLocalTaskSandbox(): ResolvedTaskSandbox;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as resolveRemoteSandboxRuntime } from "../../../remote-
|
|
2
|
-
import { t as createTrustedHostRuntime } from "../../../trusted-host-
|
|
3
|
-
|
|
1
|
+
import { a as resolveRemoteSandboxRuntime } from "../../../remote-DlyX1drC.js";
|
|
2
|
+
import { t as createTrustedHostRuntime } from "../../../trusted-host-CwMs64h1.js";
|
|
3
|
+
// src/task/runtime/providers/local.ts
|
|
4
4
|
/**
|
|
5
5
|
* `vite dev` runs each Sandbox Task as a Node process on this machine, in a temporary directory that the run removes.
|
|
6
6
|
* The process is not isolated: the Sandbox `executionAuthority` says `isolation: "none"`.
|
|
@@ -11,5 +11,4 @@ function resolveLocalTaskSandbox() {
|
|
|
11
11
|
resolveSandbox: async (requirements) => await resolveRemoteSandboxRuntime(createTrustedHostRuntime(), requirements)
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { resolveLocalTaskSandbox };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { l as Sandbox } from "../../../index-
|
|
2
|
-
import { _ as VercelSandboxTaskDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-
|
|
3
|
-
//#region src/task/runtime/providers/vercel.d.ts
|
|
1
|
+
import { l as Sandbox } from "../../../index-D9DogaoF.js";
|
|
2
|
+
import { _ as VercelSandboxTaskDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-B3uJG1po.js";
|
|
4
3
|
type SandboxTaskOptions = {
|
|
5
4
|
local: SandboxTaskDefinitionOptions;
|
|
6
5
|
provider: VercelSandboxTaskDriverOptions;
|
|
@@ -9,4 +8,4 @@ export declare function resolveVercelTaskSandbox(options: SandboxTaskOptions): P
|
|
|
9
8
|
provider: "vercel";
|
|
10
9
|
resolveSandbox: (requirements: readonly string[]) => Promise<Sandbox>;
|
|
11
10
|
}>;
|
|
12
|
-
|
|
11
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as loadVercelSandbox } from "../../../vercel-qyDr7NvU.js";
|
|
2
1
|
import { resolveVercelSandbox } from "../../../internal/vercel.js";
|
|
3
|
-
import {
|
|
4
|
-
import "../../../
|
|
5
|
-
import {
|
|
6
|
-
|
|
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,8 +13,7 @@ function readEnv(env, ...names) {
|
|
|
13
13
|
if (value) return value;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
//#region src/task/runtime/providers/vercel.ts
|
|
16
|
+
// src/task/runtime/providers/vercel.ts
|
|
18
17
|
const VERCEL_TASK_SANDBOX_HEADROOM_MS = 3e4;
|
|
19
18
|
function readConfigCredential(value) {
|
|
20
19
|
return value?.trim() || void 0;
|
|
@@ -76,5 +75,4 @@ function withPlanLimitError(create) {
|
|
|
76
75
|
function vercelTimeoutLimit(message) {
|
|
77
76
|
return /`timeout` restricted to [^\n]+/.exec(message)?.[0];
|
|
78
77
|
}
|
|
79
|
-
//#endregion
|
|
80
78
|
export { resolveVercelTaskSandbox };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as SandboxTaskDefinitionBundle, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions } from "../../module-types-
|
|
2
|
-
import { t as ResolvedTaskSandbox } from "../../provider-loader-
|
|
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
|
-
|
|
27
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-
|
|
1
|
+
import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-ClSiUwCm.js";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
|
|
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 };
|