eve 0.8.6 → 0.9.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/CHANGELOG.md +18 -1
- package/bin/eve.d.ts +5 -0
- package/bin/eve.js +15 -13
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +5 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +9 -6
- package/dist/src/compiled/.vendor-stamp.json +2 -1
- package/dist/src/compiled/semver/LICENSE +15 -0
- package/dist/src/compiled/semver/index.d.ts +23 -0
- package/dist/src/compiled/semver/index.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-options.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/docker-options.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +4 -4
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/ensure.d.ts +1 -1
- package/dist/src/execution/sandbox/lazy-backend.d.ts +2 -2
- package/dist/src/execution/sandbox/logging-session.js +2 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/sandbox.d.ts +1 -1
- package/dist/src/internal/authored-definition/sandbox.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +1 -1
- package/dist/src/internal/nitro/host/dev-watcher-log.d.ts +3 -0
- package/dist/src/internal/nitro/host/dev-watcher-log.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -1
- package/dist/src/public/sandbox/backends/default.d.ts +10 -10
- package/dist/src/public/sandbox/backends/default.js +1 -1
- package/dist/src/public/sandbox/backends/docker.d.ts +1 -1
- package/dist/src/public/sandbox/backends/docker.js +1 -1
- package/dist/src/public/sandbox/backends/just-bash.d.ts +1 -1
- package/dist/src/public/sandbox/backends/just-bash.js +1 -1
- package/dist/src/public/sandbox/backends/microsandbox.d.ts +1 -1
- package/dist/src/public/sandbox/backends/microsandbox.js +1 -1
- package/dist/src/public/sandbox/backends/vercel.d.ts +1 -1
- package/dist/src/public/sandbox/backends/vercel.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +2 -2
- package/dist/src/public/sandbox/docker.d.ts +2 -0
- package/dist/src/public/sandbox/docker.js +1 -0
- package/dist/src/public/sandbox/index.d.ts +1 -9
- package/dist/src/public/sandbox/index.js +1 -1
- package/dist/src/public/sandbox/just-bash-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/just-bash.d.ts +2 -0
- package/dist/src/public/sandbox/just-bash.js +1 -0
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/microsandbox.d.ts +2 -0
- package/dist/src/public/sandbox/microsandbox.js +1 -0
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/vercel.d.ts +2 -0
- package/dist/src/public/sandbox/vercel.js +1 -0
- package/dist/src/runtime/resolve-sandbox.d.ts +1 -1
- package/dist/src/runtime/resolve-sandbox.js +1 -1
- package/dist/src/runtime/sandbox/registry.d.ts +2 -2
- package/dist/src/runtime/sandbox/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/setup/boxes/add-channels.d.ts +4 -6
- package/dist/src/setup/boxes/add-channels.js +1 -1
- package/dist/src/setup/boxes/scaffold.d.ts +2 -2
- package/dist/src/setup/boxes/scaffold.js +1 -1
- package/dist/src/setup/node-engine.d.ts +31 -0
- package/dist/src/setup/node-engine.js +1 -0
- package/dist/src/setup/onboarding.d.ts +3 -2
- package/dist/src/setup/onboarding.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.d.ts +10 -5
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +17 -4
- package/dist/src/setup/scaffold/create/project.js +9 -5
- package/dist/src/setup/scaffold/index.d.ts +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +4 -2
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/scaffold/update/package-json.d.ts +12 -1
- package/dist/src/setup/scaffold/update/package-json.js +1 -1
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/shared/sandbox-backend.d.ts +4 -4
- package/dist/src/shared/sandbox-definition.d.ts +4 -4
- package/docs/getting-started.mdx +2 -2
- package/docs/guides/deployment.md +4 -3
- package/docs/reference/cli.md +2 -0
- package/docs/sandbox.mdx +21 -19
- package/package.json +27 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";const DEFAULT_DOCKER_SANDBOX_IMAGE=`ghcr.io/vercel/eve:latest`;function resolveDockerSandboxOptions(e={}){return{env:e.env??{},image:e.image??`ghcr.io/vercel/eve:latest`,networkPolicy:e.networkPolicy??`allow-all`,pullPolicy:e.pullPolicy??`if-not-present`}}function createDockerSandboxOptionsHash(t){return createHash(`sha256`).update(JSON.stringify(
|
|
1
|
+
import{createHash}from"node:crypto";const DEFAULT_DOCKER_SANDBOX_IMAGE=`ghcr.io/vercel/eve:latest`;function resolveDockerSandboxOptions(e={}){return{env:e.env??{},image:e.image??`ghcr.io/vercel/eve:latest`,networkPolicy:e.networkPolicy??`allow-all`,pullPolicy:e.pullPolicy??`if-not-present`}}function createDockerSandboxOptionsHash(t){return createHash(`sha256`).update(JSON.stringify(dockerOptionsForHash(t))).digest(`hex`).slice(0,20)}function dockerOptionsForHash(e){return{env:sortStringRecord(e.env),image:e.image,networkPolicy:e.networkPolicy,pullPolicy:e.pullPolicy}}function sortStringRecord(e){return Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}export{DEFAULT_DOCKER_SANDBOX_IMAGE,createDockerSandboxOptionsHash,resolveDockerSandboxOptions};
|
|
@@ -9,7 +9,7 @@ export { DOCKER_TEMPLATE_IMAGE_REPOSITORY, pruneDockerSandboxTemplates, } from "
|
|
|
9
9
|
export declare const DOCKER_BACKEND_NAME = "docker";
|
|
10
10
|
/**
|
|
11
11
|
* Construction input for {@link createDockerSandboxBackend}. Internal —
|
|
12
|
-
* the public surface is the `
|
|
12
|
+
* the public surface is the `docker()` factory under
|
|
13
13
|
* `eve/sandbox`.
|
|
14
14
|
*/
|
|
15
15
|
export interface CreateDockerSandboxBackendInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname}from"node:path";import{mkdir,readFile,writeFile}from"node:fs/promises";import{loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{createFileBackedInternalSandboxSession,pathExists}from"#execution/sandbox/bindings/local-backend-utils.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{buildSandboxSession}from"#execution/sandbox/session.js";let justBashModulePromise;async function loadJustBashModule(e){return justBashModulePromise??=loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.autoInstall,importModule:async()=>await import(`just-bash`),missingMessage:"The just-bash sandbox backend requires the `just-bash` package, which is not bundled with Eve. Install it in your application (for example `pnpm add -D just-bash`), or use
|
|
1
|
+
import{dirname}from"node:path";import{mkdir,readFile,writeFile}from"node:fs/promises";import{loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{createFileBackedInternalSandboxSession,pathExists}from"#execution/sandbox/bindings/local-backend-utils.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{buildSandboxSession}from"#execution/sandbox/session.js";let justBashModulePromise;async function loadJustBashModule(e){return justBashModulePromise??=loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.autoInstall,importModule:async()=>await import(`just-bash`),missingMessage:"The just-bash sandbox backend requires the `just-bash` package, which is not bundled with Eve. Install it in your application (for example `pnpm add -D just-bash`), or use docker() / defaultSandbox() instead.",packageName:`just-bash`}).catch(e=>{throw justBashModulePromise=void 0,e}),await justBashModulePromise}async function createBashSandbox(n){let{ReadWriteFs:r,Sandbox:i}=await loadJustBashModule({appRoot:n.appRoot,autoInstall:n.autoInstall}),o=resolveLocalSandboxFilesystemRootPath(n.rootPath),s=resolveLocalSandboxMetadataPath(n.rootPath),c=await readLocalMetadata(s);await mkdir(o,{recursive:!0});let l=new r({allowSymlinks:!0,maxFileReadSize:2**53-1,root:o});await ensureLocalSandboxDirectories(l);let u=await i.create({cwd:WORKSPACE_ROOT,env:c?.env,fs:l,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureState(){return await writeLocalMetadata(s,{env:{...u.bashEnvInstance.getEnv()},version:1}),{rootPath:n.rootPath}},async dispose(){await u.stop()},async readFileBytes(e){let t;try{t=await l.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async removePath(e){await l.rm(e.path,{force:e.force,recursive:e.recursive})},rootPath:n.rootPath,sessionKey:n.sessionKey,async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${shellQuote(e.workingDirectory)} && ${e.command} )`;return adaptJustBashCommandToSandboxProcess(await u.runCommand({args:[t],cmd:`eval`,detached:!0,env:e.env,signal:e.abortSignal}))},async writeFiles(t){for(let n of t){let t=dirname(n.path);await l.mkdir(t,{recursive:!0}),await l.writeFile(n.path,n.content)}}}}function adaptJustBashCommandToSandboxProcess(e){let t=new TextEncoder,n,r,i=!1,a,o=new ReadableStream({start(e){n=e}}),s=new ReadableStream({start(e){r=e}});return(async()=>{try{for await(let i of e.logs()){let e=t.encode(i.data);i.type===`stdout`?n?.enqueue(e):r?.enqueue(e)}}catch(e){a=e,n?.error(e),r?.error(e)}finally{i=!0,a===void 0&&(n?.close(),r?.close())}})(),{stdout:o,stderr:s,async wait(){let t=await e.wait();for(;!i;)await new Promise(e=>setTimeout(e,0));if(a!==void 0)throw a;return{exitCode:t.exitCode}},async kill(){await e.kill()}}}async function justBashSetNetworkPolicyUnsupported(){throw Error(`setNetworkPolicy() is not supported on the just-bash sandbox backend. just-bash applies its network policy only at sandbox creation (no run-time update) and does not run git or other binaries. Use docker() for coarse egress control or vercel() / microsandbox() for credential brokering.`)}function createJustBashHandle(e,t){let n=buildSandboxSession(createFileBackedInternalSandboxSession({id:e.sessionKey,sandbox:e}),justBashSetNetworkPolicyUnsupported);return{session:n,useSessionFn:async()=>n,async captureState(){return{backendName:t,metadata:await e.captureState()??{},sessionKey:e.sessionKey}},async dispose(){await e.dispose()}}}function resolveLocalSandboxFilesystemRootPath(e){return`${e}/fs`}function resolveLocalSandboxMetadataPath(e){return`${e}/metadata.json`}async function ensureLocalSandboxDirectories(e){await e.mkdir(WORKSPACE_ROOT,{recursive:!0})}async function readLocalMetadata(e){if(!await pathExists(e))return null;let t=JSON.parse(await readFile(e,`utf8`));return t.version!==1||!isStringRecord(t.env)?null:{env:t.env,version:1}}async function writeLocalMetadata(n,i){await mkdir(dirname(n),{recursive:!0}),await writeFile(n,`${JSON.stringify(i,null,2)}\n`)}function isStringRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`)}export{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported};
|
|
@@ -7,7 +7,7 @@ import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-san
|
|
|
7
7
|
export declare const JUST_BASH_BACKEND_NAME = "just-bash";
|
|
8
8
|
/**
|
|
9
9
|
* Construction input for {@link createJustBashSandboxBackend}. Internal —
|
|
10
|
-
* the public surface is the `
|
|
10
|
+
* the public surface is the `justbash()` factory under
|
|
11
11
|
* `eve/sandbox`.
|
|
12
12
|
*/
|
|
13
13
|
export interface CreateJustBashSandboxBackendInput {
|
|
@@ -23,7 +23,7 @@ export interface ResolvedMicrosandboxOptions {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Applies defaults to `
|
|
26
|
+
* Applies defaults to `microsandbox(opts)`.
|
|
27
27
|
*/
|
|
28
28
|
export declare function resolveMicrosandboxOptions(options: MicrosandboxCreateOptions | undefined): ResolvedMicrosandboxOptions;
|
|
29
29
|
/**
|
|
@@ -2,7 +2,7 @@ import type { Sandbox as MicrosandboxSandbox } from "microsandbox";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synchronously reports whether this host can run microsandbox at all:
|
|
4
4
|
* macOS on Apple Silicon, or Linux (glibc) with KVM available. Used by
|
|
5
|
-
* `
|
|
5
|
+
* `defaultSandbox()`'s availability chain.
|
|
6
6
|
*/
|
|
7
7
|
export declare function isMicrosandboxPlatformSupported(): boolean;
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import{access}from"node:fs/promises";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";function isMicrosandboxPlatformSupported(){return process.platform===`darwin`&&process.arch===`arm64`?!0:process.platform===`linux`&&(process.arch===`x64`||process.arch===`arm64`)&&isGlibcLinux()?process.env.MSB_PATH!==void 0||existsSync(`/dev/kvm`):!1}function isGlibcLinux(){try{return typeof(process.report?.getReport())?.header?.glibcVersionRuntime==`string`}catch{return!1}}async function assertMicrosandboxPlatformCandidate(){if(!(process.platform===`darwin`&&process.arch===`arm64`)){if(process.platform===`linux`&&(process.arch===`x64`||process.arch===`arm64`)){if(!isGlibcLinux())throw Error(`The microsandbox sandbox backend requires a glibc-based Linux distribution; musl hosts are not supported. Use
|
|
1
|
+
import{existsSync}from"node:fs";import{access}from"node:fs/promises";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";function isMicrosandboxPlatformSupported(){return process.platform===`darwin`&&process.arch===`arm64`?!0:process.platform===`linux`&&(process.arch===`x64`||process.arch===`arm64`)&&isGlibcLinux()?process.env.MSB_PATH!==void 0||existsSync(`/dev/kvm`):!1}function isGlibcLinux(){try{return typeof(process.report?.getReport())?.header?.glibcVersionRuntime==`string`}catch{return!1}}async function assertMicrosandboxPlatformCandidate(){if(!(process.platform===`darwin`&&process.arch===`arm64`)){if(process.platform===`linux`&&(process.arch===`x64`||process.arch===`arm64`)){if(!isGlibcLinux())throw Error(`The microsandbox sandbox backend requires a glibc-based Linux distribution; musl hosts are not supported. Use docker() or vercel() instead.`);if(process.env.MSB_PATH!==void 0||await doesPathExist(`/dev/kvm`))return;throw Error("The microsandbox sandbox backend requires Linux with KVM enabled. `/dev/kvm` is not available on this host. Enable KVM, set MSB_PATH for a custom runtime, or use docker() / vercel().")}throw Error(`The microsandbox sandbox backend supports Linux with KVM or macOS on Apple Silicon. Current host is ${process.platform}/${process.arch}. Use docker() or vercel() on this host.`)}}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}async function ensureMicrosandboxBaseRuntime(e,t={}){let n=await collectMicrosandboxBaseRuntimeOutput(await e.execStreamWith(`bash`,e=>e.args([`-lc`,MICROSANDBOX_BASE_SETUP_SCRIPT]).cwd(`/`).user(`root`)),t.log);if(n.exitCode!==0)throw Error(`Failed to initialize the microsandbox base runtime. ${n.stderr||n.stdout}`.trim())}async function collectMicrosandboxBaseRuntimeOutput(e,t){let n=new TextDecoder,r=new TextDecoder,i=``,a=``,o=``,s=``,c;for await(let l of e)if(l.kind===`stdout`){let e=n.decode(l.data,{stream:!0});i=appendOutput(i,e),o=emitMicrosandboxBaseRuntimeLogs(o+e,t)}else if(l.kind===`stderr`){let e=r.decode(l.data,{stream:!0});a=appendOutput(a,e),s=emitMicrosandboxBaseRuntimeLogs(s+e,t)}else if(l.kind===`exited`){c=l.code;break}let l=n.decode(),u=r.decode();if(l.length>0&&(i=appendOutput(i,l),o=emitMicrosandboxBaseRuntimeLogs(o+l,t)),u.length>0&&(a=appendOutput(a,u),s=emitMicrosandboxBaseRuntimeLogs(s+u,t)),emitMicrosandboxBaseRuntimeLogLine(o,t),emitMicrosandboxBaseRuntimeLogLine(s,t),c===void 0)throw Error(`Microsandbox base runtime setup ended without an exit event.`);return{exitCode:c,stderr:a,stdout:i}}function emitMicrosandboxBaseRuntimeLogs(e,t){let n=e.split(/\r?\n/u),r=n.pop()??``;for(let e of n)emitMicrosandboxBaseRuntimeLogLine(e,t);return r}function emitMicrosandboxBaseRuntimeLogLine(e,t){let n=e.match(/^eve-base-runtime: ?(.*)$/u)?.[1];n!==void 0&&n.length>0&&t?.(n)}function appendOutput(e,t){let n=e+t;return n.length>2e4?n.slice(-2e4):n}const MICROSANDBOX_BASE_SETUP_SCRIPT=`
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
log_step() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{posix}from"node:path";import{access}from"node:fs/promises";import{createHash,randomUUID}from"node:crypto";import{isEveDevEnvironment,loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{assertMicrosandboxPlatformCandidate,ensureMicrosandboxBaseRuntime}from"#execution/sandbox/bindings/microsandbox-platform.js";import{MICROSANDBOX_METADATA_VERSION,writeSessionMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";import{applyMicrosandboxNetwork,createMicrosandboxNetworkPlan,createTransformBrokerEnvironment}from"#execution/sandbox/bindings/microsandbox-network.js";import{adaptMicrosandboxExecToSandboxProcess}from"#execution/sandbox/bindings/microsandbox-process.js";const MICROSANDBOX_STOP_TIMEOUT_MS=1e4;var MicrosandboxVm=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a,o){this.#e=e,this.#i=t,this.#a=n,this.#n=r,this.#t=i,this.#r=a,this.#o=o}get id(){return this.#e.sessionKey}async captureState(e){if(this.#r=e,isEveDevEnvironment())return this.#t!==void 0&&await this.writeMetadata(this.#t,e),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION};let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`);return await this.stopAndSnapshot(n),this.#o=n,this.#t!==void 0&&await this.writeMetadata(this.#t,e),t!==void 0&&await removeSnapshotIfExists(this.#e.module,t),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:n,version:MICROSANDBOX_METADATA_VERSION}}async detach(){await this.#i.detach().catch(()=>{})}async readFileBytes(e){try{let t=this.#i.fs();return await t.exists(e)?Buffer.from(await t.read(e)):null}catch{return null}}async removePath(e){let t=`${e.force===!0?`f`:``}${e.recursive===!0?`r`:``}`,n=`${t.length>0?`rm -${t}`:`rm`} -- ${shellQuote(e.path)}`;await this.runInternalCommand({abortSignal:e.abortSignal,command:n,user:MICROSANDBOX_USER})}async removePersisted(){await removeSandboxIfExists(this.#e.module,this.#a),this.#o!==void 0&&await removeSnapshotIfExists(this.#e.module,this.#o)}async setNetworkPolicy(e){let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`),i=this.#a;await this.stopAndSnapshot(n),await removeSandboxIfExists(this.#e.module,i);let a=createProviderName(`eve-sbx-ses`,`${this.#e.sessionKey}:${randomUUID()}`);this.#i=await createMicrosandbox({fromSnapshot:n,module:this.#e.module,name:a,networkPolicy:e,options:this.#e.options,tags:this.#e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT}),this.#a=a,this.#n=e,this.#o=void 0,this.#t!==void 0&&this.#r!==void 0&&await this.writeMetadata(this.#t,this.#r),await removeSnapshotIfExists(this.#e.module,n),t!==void 0&&await removeSnapshotIfExists(this.#e.module,t)}async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t={...this.#e.options.env,...createTransformBrokerEnvironment(createMicrosandboxNetworkPlan(this.#n)),...e.env},n=await this.#i.execStreamWith(`bash`,n=>n.args([`-lc`,e.command]).cwd(e.workingDirectory??WORKSPACE_ROOT).envs(t).user(MICROSANDBOX_USER));return e.abortSignal!==void 0&&e.abortSignal.addEventListener(`abort`,()=>{n.kill().catch(()=>{})},{once:!0}),adaptMicrosandboxExecToSandboxProcess(n)}async stopAndSnapshot(e){await this.#i.stop().catch(()=>{}),await stopAndSnapshotMicrosandboxSandbox(this.#e.module,this.#a,e)}async writeFiles(t){let n=this.#i.fs();for(let r of t){let t=posix.dirname(r.path);await this.runInternalCommand({command:`mkdir -p ${shellQuote(t)}`,user:MICROSANDBOX_USER}),await n.write(r.path,r.content),await this.runInternalCommand({command:`chown ${MICROSANDBOX_USER}:${MICROSANDBOX_USER} ${shellQuote(r.path)}`,user:`root`})}}async writeMetadata(e,t){this.#t=e,this.#r=t,await writeSessionMetadata(e,{networkPolicy:this.#n,optionsHash:t,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION})}async runInternalCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=await this.#i.execWith(`bash`,t=>t.args([`-lc`,e.command]).cwd(WORKSPACE_ROOT).user(e.user));if(t.code!==0){let n=e.failureMessage??`Microsandbox command failed.`;throw Error(`${n} ${t.stderr()}`.trim())}}};async function createPreparedMicrosandbox(e){let t=e.setupBaseRuntime?`allow-all`:e.networkPolicy,n=await createMicrosandbox({fromSnapshot:e.fromSnapshot,module:e.module,name:e.name,networkPolicy:t,options:e.options,tags:e.tags,user:e.setupBaseRuntime?void 0:MICROSANDBOX_USER,workdir:e.setupBaseRuntime?`/`:WORKSPACE_ROOT}),r=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.name,t);return e.setupBaseRuntime&&(await withProgressHeartbeat(`preparing base runtime inside VM`,e.log,async()=>{await ensureMicrosandboxBaseRuntime(n,{log:e.log})}),e.networkPolicy!==void 0&&e.networkPolicy!==`allow-all`&&(e.log?.(`applying network policy`),await r.setNetworkPolicy(e.networkPolicy))),r}async function connectMicrosandbox(e){let t;try{t=await e.module.Sandbox.get(e.metadata.sandboxName)}catch(t){if(!isMicrosandboxNotFoundError(t)||e.metadata.stateSnapshotName===void 0)throw t;return await restoreMicrosandboxSessionSnapshot(e)}if(t.status!==`running`&&t.status!==`draining`&&e.metadata.stateSnapshotName!==void 0)return await restoreMicrosandboxSessionSnapshot(e);let n=t.status===`running`||t.status===`draining`?await t.connectWithTimeout(1e4):await t.startDetached();return new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.metadata.sandboxName,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName)}async function restoreMicrosandboxSessionSnapshot(e){if(e.metadata.stateSnapshotName===void 0||!await snapshotExists(e.module,e.metadata.stateSnapshotName))throw Error(`Microsandbox session snapshot is missing for sandbox "${e.metadata.sandboxName}".`);let t=createProviderName(`eve-sbx-ses`,`${e.sessionKey}:${randomUUID()}`),n=await createMicrosandbox({fromSnapshot:e.metadata.stateSnapshotName,module:e.module,name:t,networkPolicy:e.metadata.networkPolicy,options:e.options,tags:e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT});await removeSandboxIfExists(e.module,e.metadata.sandboxName);let i=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,t,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName);return await i.writeMetadata(e.metadataPath,e.metadata.optionsHash),i}async function loadMicrosandboxModule(e){e.log?.(`checking microsandbox platform support`),await assertMicrosandboxPlatformCandidate();let t=await withProgressHeartbeat(`loading microsandbox npm package`,e.log,()=>loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.options.setup.autoInstall,importModule:async()=>await import(`microsandbox`),missingMessage:"The microsandbox sandbox backend requires the `microsandbox` package, which is not bundled with Eve. Install it in your application (for example `pnpm add -D microsandbox`), or use dockerBackend() / vercelSandboxBackend() instead.",packageName:`microsandbox`}));if(e.log?.(`checking microsandbox VM runtime`),!t.isInstalled()){if(!e.options.setup.autoInstall||!isEveDevEnvironment())throw Error("The microsandbox VM runtime is not installed. Run `npx microsandbox install`, set MSB_PATH for a custom install, or let `eve dev` install it automatically with microsandboxBackend({ setup: { autoInstall: true } }).");await withProgressHeartbeat(`installing microsandbox VM runtime`,e.log,async()=>{await t.setup().skipVerify(e.options.setup.skipVerify).install()})}return e.log?.(`microsandbox runtime ready`),t}async function withProgressHeartbeat(e,t,n){if(t?.(e),t===void 0)return await n();let r=Date.now(),i=setInterval(()=>{t(`${e} (${Math.round((Date.now()-r)/1e3)}s elapsed)`)},1e4);i.unref?.();try{return await n()}finally{clearInterval(i)}}async function loadMicrosandboxWithoutInstall(){try{let e=await import(`microsandbox`);return e.isInstalled()?e:null}catch{return null}}async function stopAndSnapshotMicrosandboxSandbox(e,t,n){for(let r=0;r<3;r+=1){let i=await e.Sandbox.get(t);await i.stopWithTimeout(r===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{});try{await i.snapshot(n);return}catch(e){if(!isMicrosandboxSnapshotSourceRunningError(e)||r===2)throw e;await i.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250))}}}async function snapshotExists(e,t){try{return await e.Snapshot.get(t),!0}catch(e){if(isMicrosandboxNotFoundError(e))return!1;throw e}}async function sandboxExists(e,t){try{return await e.Sandbox.get(t),!0}catch(e){if(isMicrosandboxNotFoundError(e))return!1;throw e}}async function removeSnapshotIfExists(e,t){try{await e.Snapshot.remove(t,{force:!0})}catch(e){if(!isMicrosandboxNotFoundError(e))throw e}}function createProviderName(e,t,n=``){return`${e}-${createStableHash(`${t}:${n}`).slice(0,32)}`}function createStableHash(e){return createHash(`sha256`).update(e).digest(`hex`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}async function createMicrosandbox(e){let t=e.module.Sandbox.builder(e.name).cpus(e.options.cpus).detached(!0).envs(e.options.env).labels(resolveMicrosandboxLabels(e.tags)).memory(e.options.memoryMiB).pullPolicy(e.options.pullPolicy).replace().workdir(e.workdir);return t=e.fromSnapshot===void 0?t.image(e.options.image):t.fromSnapshot(e.fromSnapshot),e.user!==void 0&&(t=t.user(e.user)),await applyMicrosandboxNetwork(t,e.networkPolicy).create()}async function removeSandboxIfExists(e,t){for(let n=0;n<3;n+=1)try{let r=await e.Sandbox.get(t);await r.stopWithTimeout(n===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{}),await r.remove();return}catch(r){if(isMicrosandboxNotFoundError(r))return;if(isMicrosandboxStillRunningError(r)&&n<2){await(await e.Sandbox.get(t).catch(()=>null))?.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250));continue}throw r}}function isMicrosandboxNotFoundError(e){return e instanceof Error?/not found|not exist|no such/i.test(e.message):!1}function isMicrosandboxStillRunningError(e){return e instanceof Error?/still running/i.test(e.message):!1}function isMicrosandboxSnapshotSourceRunningError(e){return e instanceof Error?/snapshot source sandbox .*not stopped|SnapshotSandboxRunning/i.test(e.message):!1}function resolveMicrosandboxLabels(e){return{"eve.backend":`microsandbox`,...withDevelopmentSandboxTags(e)}}export{MicrosandboxVm,connectMicrosandbox,createPreparedMicrosandbox,createProviderName,createStableHash,doesPathExist,loadMicrosandboxModule,loadMicrosandboxWithoutInstall,removeSnapshotIfExists,sandboxExists,snapshotExists,stopAndSnapshotMicrosandboxSandbox};
|
|
1
|
+
import{posix}from"node:path";import{access}from"node:fs/promises";import{createHash,randomUUID}from"node:crypto";import{isEveDevEnvironment,loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{assertMicrosandboxPlatformCandidate,ensureMicrosandboxBaseRuntime}from"#execution/sandbox/bindings/microsandbox-platform.js";import{MICROSANDBOX_METADATA_VERSION,writeSessionMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";import{applyMicrosandboxNetwork,createMicrosandboxNetworkPlan,createTransformBrokerEnvironment}from"#execution/sandbox/bindings/microsandbox-network.js";import{adaptMicrosandboxExecToSandboxProcess}from"#execution/sandbox/bindings/microsandbox-process.js";const MICROSANDBOX_STOP_TIMEOUT_MS=1e4;var MicrosandboxVm=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a,o){this.#e=e,this.#i=t,this.#a=n,this.#n=r,this.#t=i,this.#r=a,this.#o=o}get id(){return this.#e.sessionKey}async captureState(e){if(this.#r=e,isEveDevEnvironment())return this.#t!==void 0&&await this.writeMetadata(this.#t,e),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION};let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`);return await this.stopAndSnapshot(n),this.#o=n,this.#t!==void 0&&await this.writeMetadata(this.#t,e),t!==void 0&&await removeSnapshotIfExists(this.#e.module,t),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:n,version:MICROSANDBOX_METADATA_VERSION}}async detach(){await this.#i.detach().catch(()=>{})}async readFileBytes(e){try{let t=this.#i.fs();return await t.exists(e)?Buffer.from(await t.read(e)):null}catch{return null}}async removePath(e){let t=`${e.force===!0?`f`:``}${e.recursive===!0?`r`:``}`,n=`${t.length>0?`rm -${t}`:`rm`} -- ${shellQuote(e.path)}`;await this.runInternalCommand({abortSignal:e.abortSignal,command:n,user:MICROSANDBOX_USER})}async removePersisted(){await removeSandboxIfExists(this.#e.module,this.#a),this.#o!==void 0&&await removeSnapshotIfExists(this.#e.module,this.#o)}async setNetworkPolicy(e){let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`),i=this.#a;await this.stopAndSnapshot(n),await removeSandboxIfExists(this.#e.module,i);let a=createProviderName(`eve-sbx-ses`,`${this.#e.sessionKey}:${randomUUID()}`);this.#i=await createMicrosandbox({fromSnapshot:n,module:this.#e.module,name:a,networkPolicy:e,options:this.#e.options,tags:this.#e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT}),this.#a=a,this.#n=e,this.#o=void 0,this.#t!==void 0&&this.#r!==void 0&&await this.writeMetadata(this.#t,this.#r),await removeSnapshotIfExists(this.#e.module,n),t!==void 0&&await removeSnapshotIfExists(this.#e.module,t)}async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t={...this.#e.options.env,...createTransformBrokerEnvironment(createMicrosandboxNetworkPlan(this.#n)),...e.env},n=await this.#i.execStreamWith(`bash`,n=>n.args([`-lc`,e.command]).cwd(e.workingDirectory??WORKSPACE_ROOT).envs(t).user(MICROSANDBOX_USER));return e.abortSignal!==void 0&&e.abortSignal.addEventListener(`abort`,()=>{n.kill().catch(()=>{})},{once:!0}),adaptMicrosandboxExecToSandboxProcess(n)}async stopAndSnapshot(e){await this.#i.stop().catch(()=>{}),await stopAndSnapshotMicrosandboxSandbox(this.#e.module,this.#a,e)}async writeFiles(t){let n=this.#i.fs();for(let r of t){let t=posix.dirname(r.path);await this.runInternalCommand({command:`mkdir -p ${shellQuote(t)}`,user:MICROSANDBOX_USER}),await n.write(r.path,r.content),await this.runInternalCommand({command:`chown ${MICROSANDBOX_USER}:${MICROSANDBOX_USER} ${shellQuote(r.path)}`,user:`root`})}}async writeMetadata(e,t){this.#t=e,this.#r=t,await writeSessionMetadata(e,{networkPolicy:this.#n,optionsHash:t,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION})}async runInternalCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=await this.#i.execWith(`bash`,t=>t.args([`-lc`,e.command]).cwd(WORKSPACE_ROOT).user(e.user));if(t.code!==0){let n=e.failureMessage??`Microsandbox command failed.`;throw Error(`${n} ${t.stderr()}`.trim())}}};async function createPreparedMicrosandbox(e){let t=e.setupBaseRuntime?`allow-all`:e.networkPolicy,n=await createMicrosandbox({fromSnapshot:e.fromSnapshot,module:e.module,name:e.name,networkPolicy:t,options:e.options,tags:e.tags,user:e.setupBaseRuntime?void 0:MICROSANDBOX_USER,workdir:e.setupBaseRuntime?`/`:WORKSPACE_ROOT}),r=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.name,t);return e.setupBaseRuntime&&(await withProgressHeartbeat(`preparing base runtime inside VM`,e.log,async()=>{await ensureMicrosandboxBaseRuntime(n,{log:e.log})}),e.networkPolicy!==void 0&&e.networkPolicy!==`allow-all`&&(e.log?.(`applying network policy`),await r.setNetworkPolicy(e.networkPolicy))),r}async function connectMicrosandbox(e){let t;try{t=await e.module.Sandbox.get(e.metadata.sandboxName)}catch(t){if(!isMicrosandboxNotFoundError(t)||e.metadata.stateSnapshotName===void 0)throw t;return await restoreMicrosandboxSessionSnapshot(e)}if(t.status!==`running`&&t.status!==`draining`&&e.metadata.stateSnapshotName!==void 0)return await restoreMicrosandboxSessionSnapshot(e);let n=t.status===`running`||t.status===`draining`?await t.connectWithTimeout(1e4):await t.startDetached();return new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.metadata.sandboxName,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName)}async function restoreMicrosandboxSessionSnapshot(e){if(e.metadata.stateSnapshotName===void 0||!await snapshotExists(e.module,e.metadata.stateSnapshotName))throw Error(`Microsandbox session snapshot is missing for sandbox "${e.metadata.sandboxName}".`);let t=createProviderName(`eve-sbx-ses`,`${e.sessionKey}:${randomUUID()}`),n=await createMicrosandbox({fromSnapshot:e.metadata.stateSnapshotName,module:e.module,name:t,networkPolicy:e.metadata.networkPolicy,options:e.options,tags:e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT});await removeSandboxIfExists(e.module,e.metadata.sandboxName);let i=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,t,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName);return await i.writeMetadata(e.metadataPath,e.metadata.optionsHash),i}async function loadMicrosandboxModule(e){e.log?.(`checking microsandbox platform support`),await assertMicrosandboxPlatformCandidate();let t=await withProgressHeartbeat(`loading microsandbox npm package`,e.log,()=>loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.options.setup.autoInstall,importModule:async()=>await import(`microsandbox`),missingMessage:"The microsandbox sandbox backend requires the `microsandbox` package, which is not bundled with Eve. Install it in your application (for example `pnpm add -D microsandbox`), or use docker() / vercel() instead.",packageName:`microsandbox`}));if(e.log?.(`checking microsandbox VM runtime`),!t.isInstalled()){if(!e.options.setup.autoInstall||!isEveDevEnvironment())throw Error("The microsandbox VM runtime is not installed. Run `npx microsandbox install`, set MSB_PATH for a custom install, or let `eve dev` install it automatically with microsandbox({ setup: { autoInstall: true } }).");await withProgressHeartbeat(`installing microsandbox VM runtime`,e.log,async()=>{await t.setup().skipVerify(e.options.setup.skipVerify).install()})}return e.log?.(`microsandbox runtime ready`),t}async function withProgressHeartbeat(e,t,n){if(t?.(e),t===void 0)return await n();let r=Date.now(),i=setInterval(()=>{t(`${e} (${Math.round((Date.now()-r)/1e3)}s elapsed)`)},1e4);i.unref?.();try{return await n()}finally{clearInterval(i)}}async function loadMicrosandboxWithoutInstall(){try{let e=await import(`microsandbox`);return e.isInstalled()?e:null}catch{return null}}async function stopAndSnapshotMicrosandboxSandbox(e,t,n){for(let r=0;r<3;r+=1){let i=await e.Sandbox.get(t);await i.stopWithTimeout(r===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{});try{await i.snapshot(n);return}catch(e){if(!isMicrosandboxSnapshotSourceRunningError(e)||r===2)throw e;await i.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250))}}}async function snapshotExists(e,t){try{return await e.Snapshot.get(t),!0}catch(e){if(isMicrosandboxNotFoundError(e))return!1;throw e}}async function sandboxExists(e,t){try{return await e.Sandbox.get(t),!0}catch(e){if(isMicrosandboxNotFoundError(e))return!1;throw e}}async function removeSnapshotIfExists(e,t){try{await e.Snapshot.remove(t,{force:!0})}catch(e){if(!isMicrosandboxNotFoundError(e))throw e}}function createProviderName(e,t,n=``){return`${e}-${createStableHash(`${t}:${n}`).slice(0,32)}`}function createStableHash(e){return createHash(`sha256`).update(e).digest(`hex`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}async function createMicrosandbox(e){let t=e.module.Sandbox.builder(e.name).cpus(e.options.cpus).detached(!0).envs(e.options.env).labels(resolveMicrosandboxLabels(e.tags)).memory(e.options.memoryMiB).pullPolicy(e.options.pullPolicy).replace().workdir(e.workdir);return t=e.fromSnapshot===void 0?t.image(e.options.image):t.fromSnapshot(e.fromSnapshot),e.user!==void 0&&(t=t.user(e.user)),await applyMicrosandboxNetwork(t,e.networkPolicy).create()}async function removeSandboxIfExists(e,t){for(let n=0;n<3;n+=1)try{let r=await e.Sandbox.get(t);await r.stopWithTimeout(n===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{}),await r.remove();return}catch(r){if(isMicrosandboxNotFoundError(r))return;if(isMicrosandboxStillRunningError(r)&&n<2){await(await e.Sandbox.get(t).catch(()=>null))?.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250));continue}throw r}}function isMicrosandboxNotFoundError(e){return e instanceof Error?/not found|not exist|no such/i.test(e.message):!1}function isMicrosandboxStillRunningError(e){return e instanceof Error?/still running/i.test(e.message):!1}function isMicrosandboxSnapshotSourceRunningError(e){return e instanceof Error?/snapshot source sandbox .*not stopped|SnapshotSandboxRunning/i.test(e.message):!1}function resolveMicrosandboxLabels(e){return{"eve.backend":`microsandbox`,...withDevelopmentSandboxTags(e)}}export{MicrosandboxVm,connectMicrosandbox,createPreparedMicrosandbox,createProviderName,createStableHash,doesPathExist,loadMicrosandboxModule,loadMicrosandboxWithoutInstall,removeSnapshotIfExists,sandboxExists,snapshotExists,stopAndSnapshotMicrosandboxSandbox};
|
|
@@ -8,7 +8,7 @@ export { pruneMicrosandboxTemplates } from "#execution/sandbox/bindings/microsan
|
|
|
8
8
|
export declare const MICROSANDBOX_BACKEND_NAME = "microsandbox";
|
|
9
9
|
/**
|
|
10
10
|
* Construction input for {@link createMicrosandboxSandboxBackend}.
|
|
11
|
-
* Internal — the public surface is the `
|
|
11
|
+
* Internal — the public surface is the `microsandbox()` factory
|
|
12
12
|
* under `eve/sandbox`.
|
|
13
13
|
*/
|
|
14
14
|
export interface CreateMicrosandboxSandboxBackendInput {
|
|
@@ -3,11 +3,11 @@ import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
|
|
|
3
3
|
import type { VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions } from "#public/sandbox/vercel-sandbox.js";
|
|
4
4
|
import { type CreateVercelSandbox, type VercelSandboxModule } from "#execution/sandbox/bindings/vercel-create-sdk.js";
|
|
5
5
|
/**
|
|
6
|
-
* Construction input for {@link
|
|
7
|
-
* the public surface is the `
|
|
6
|
+
* Construction input for {@link createVercelSandbox}. Internal —
|
|
7
|
+
* the public surface is the `vercel()` factory under
|
|
8
8
|
* `eve/sandbox`.
|
|
9
9
|
*/
|
|
10
|
-
export interface
|
|
10
|
+
export interface CreateVercelSandboxInput {
|
|
11
11
|
readonly createSandbox?: CreateVercelSandbox;
|
|
12
12
|
readonly createOptions?: SandboxCreateOptions;
|
|
13
13
|
readonly loadSandboxModule?: () => Promise<VercelSandboxModule>;
|
|
@@ -20,4 +20,4 @@ export interface CreateVercelSandboxBackendInput {
|
|
|
20
20
|
* prewarm time, session at first-time session-create). On resume
|
|
21
21
|
* (`Sandbox.get`) no create happens, so they are not re-applied.
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function createVercelSandbox(input?: CreateVercelSandboxInput): SandboxBackend<VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";function
|
|
1
|
+
import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},r=e.createSandbox??createVercelEveImageSandbox,u=new Map;return{name:`vercel`,async create(e){let s=resolveVercelSandboxTags(n.tags,e.tags),l=e.templateKey===null?null:await readTemplateForCreate({createOptions:n,loadSandboxModule:t,prewarmedTemplates:u,templateKey:e.templateKey}),d=await t(),f;try{f=await ensureSession({createOptions:n,createSandbox:r,existingMetadata:e.existingMetadata,sandboxModule:d,sessionKey:e.sessionKey,snapshotId:l?.snapshotId,tags:s})}catch(t){throw l!==null&&isVercelSnapshotUnavailableError(t)?(u.delete(l.templateKey),await(await getNamedVercelSandbox({createOptions:n,sandboxModule:d,sandboxName:l.sandboxName}))?.delete(),new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:l.templateKey})):Error(`Failed to create sandbox session "${e.sessionKey}": ${errorMessage(t)}`,{cause:t})}return l===null&&f.created&&(await ensureVercelSandboxBaseRuntime(f.sandbox),await applyInitialVercelNetworkPolicy(f.sandbox,n.networkPolicy)),createHandle(f.sandbox,e.sessionKey)},async prewarm(e){let i;try{i=await ensureTemplate({bootstrap:e.bootstrap,createOptions:n,createSandbox:r,loadSandboxModule:t,log:e.log,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}return u.set(e.templateKey,i.template),{reused:i.reused}}}}async function readTemplate(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await e.loadSandboxModule(),r=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:n,sandboxName:e.templateKey});if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey}}async function readTemplateForCreate(e){try{return await readTemplate(e)}catch(t){throw SandboxTemplateNotProvisionedError.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),i=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),s=resolveVercelSandboxTags(e.createOptions.tags,e.tags),c=extractAuthorSnapshotId(e.createOptions);if(i!==null&&isUnprovisionedTerminalTemplateSandbox(i,c)&&(await i.delete(),i=null),i===null?i=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!1,tags:s})}):await ensureVercelSandboxTags(i,s),typeof i.currentSnapshotId==`string`&&i.currentSnapshotId.length>0&&i.currentSnapshotId!==c)return{reused:!0,template:{sandboxName:i.name,snapshotId:i.currentSnapshotId,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(i),await applyInitialVercelNetworkPolicy(i,e.createOptions.networkPolicy);let l=buildSandboxSession(createVercelInternalSandboxSession(i,e.templateKey),createVercelNetworkPolicySetter(i));e.bootstrap!==void 0&&(e.log?.(`running sandbox bootstrap`),await e.bootstrap({use:async t=>(t!==void 0&&await i.update(t),createLoggingSandboxSession({log:e.log,session:l}))}));for(let t of e.seedFiles)typeof t.content==`string`?await l.writeTextFile({content:t.content,path:t.path}):await l.writeBinaryFile({content:t.content,path:t.path});let u=await i.snapshot();return{reused:!1,template:{sandboxName:i.name,snapshotId:u.snapshotId,templateKey:e.templateKey}}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t);return e.tags!==void 0&&(r.tags=e.tags),{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}function createSessionCreateParams(e,t){if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...e.createOptions,name:t,persistent:!0});let{runtime:n,source:r,...i}=e.createOptions;return{...i,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function withBaseSetupNetworkPolicy(e){return{...e,networkPolicy:`allow-all`}}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e)),useSessionFn:async n=>(n!==void 0&&await e.update(n),buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function createVercelNetworkPolicySetter(e){return async t=>{await e.update({networkPolicy:t})}}function createVercelInternalSandboxSession(n,r){return{id:r,resolvePath:resolveVercelSandboxPath,async spawn(t){return adaptVercelCommandToSandboxProcess(await n.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:t.env,signal:t.abortSignal}))},async readFile(e){return await n.readFile({path:e.path})??null},async writeFile(e){let r=await streamToBuffer(e.content);await n.writeFiles([{content:r,path:e.path}])},async removePath(e){await n.fs.rm(e.path,{force:e.force,recursive:e.recursive,signal:e.abortSignal})}}}function adaptVercelCommandToSandboxProcess(e){let t=new TextEncoder,n,r,i=!1,a,o=new ReadableStream({start(e){n=e}}),s=new ReadableStream({start(e){r=e}});return(async()=>{try{for await(let i of e.logs()){let e=t.encode(i.data);i.stream===`stdout`?n?.enqueue(e):r?.enqueue(e)}}catch(e){a=e,n?.error(e),r?.error(e)}finally{i=!0,a===void 0&&(n?.close(),r?.close())}})(),{stdout:o,stderr:s,async wait(){let t=await e.wait();for(;!i;)await new Promise(e=>setTimeout(e,0));if(a!==void 0)throw a;return{exitCode:t.exitCode}},async kill(){await e.kill()}}}function resolveVercelSandboxPath(t){return t.startsWith(`/`)?t:`${WORKSPACE_ROOT}/${t}`}function isUnprovisionedTerminalTemplateSandbox(e,t){let n=e.currentSnapshotId;return typeof n==`string`&&n.length>0&&n!==t?!1:e.status===`aborted`||e.status===`failed`||e.status===`stopped`}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. Eve reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercel().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function errorMessage(e){if(e instanceof Error){let t=e.json,n=e.text,r=typeof n==`string`&&n.length>0?n:t===void 0?void 0:JSON.stringify(t);return r===void 0?e.message:`${e.message}: ${r}`}return String(e)}const DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandbox};
|
|
@@ -21,7 +21,7 @@ export interface EnsureSandboxAccessInput {
|
|
|
21
21
|
*
|
|
22
22
|
* Every agent has exactly one sandbox. The sandbox carries its own
|
|
23
23
|
* `SandboxBackend` value (resolved from the authored module or
|
|
24
|
-
* substituted with `
|
|
24
|
+
* substituted with `defaultSandbox()` when omitted), and the runtime
|
|
25
25
|
* simply calls `backend.create(...)`.
|
|
26
26
|
*/
|
|
27
27
|
export declare function ensureSandboxAccess(input: EnsureSandboxAccessInput): Promise<SandboxAccess>;
|
|
@@ -5,9 +5,9 @@ import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
|
|
|
5
5
|
* `.create`, or `.prewarm`. Subsequent accesses return the same cached
|
|
6
6
|
* underlying backend.
|
|
7
7
|
*
|
|
8
|
-
* Used by `
|
|
8
|
+
* Used by `defaultSandbox()` for env-conditional selection, and by the
|
|
9
9
|
* authored-definition normalizer when an author passes a callback to
|
|
10
|
-
* `SandboxDefinition.backend` (e.g. `backend: () =>
|
|
10
|
+
* `SandboxDefinition.backend` (e.g. `backend: () => vercel({...})`)
|
|
11
11
|
* so the factory runs at first use rather than at module load — while
|
|
12
12
|
* still preserving backend-internal state (such as the Vercel backend's
|
|
13
13
|
* prewarmed-templates map) across every framework call.
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
function createLoggingSandboxSession(e){let{log:t,session:n}=e;return
|
|
1
|
+
function createLoggingSandboxSession(e){let{log:t,session:n}=e;return{...n,async run(e){t?.(`bootstrap run: ${formatCommand(e.command)}`);let r=await n.run(e);if(r.exitCode===1)throw Error(formatBootstrapRunFailure(e.command,r));return r},async spawn(e){return t?.(`bootstrap spawn: ${formatCommand(e.command)}`),await n.spawn(e)},async setNetworkPolicy(e){return t?.(`bootstrap set network policy: ${formatNetworkPolicy(e)}`),await n.setNetworkPolicy(e)},async writeFile(e){return t?.(`bootstrap write file: ${e.path}`),await n.writeFile(e)},async writeBinaryFile(e){return t?.(`bootstrap write binary file: ${e.path} (${e.content.byteLength} bytes)`),await n.writeBinaryFile(e)},async writeTextFile(e){return t?.(`bootstrap write text file: ${e.path} (${e.content.length} chars)`),await n.writeTextFile(e)},async removePath(e){return t?.(`bootstrap remove path: ${e.path}`),await n.removePath(e)}}}function formatBootstrapRunFailure(e,t){return[`Sandbox bootstrap failed because sandbox.run command exited with code 1:`,e,``,`stdout:`,t.stdout,``,`stderr:`,t.stderr].join(`
|
|
2
|
+
`)}function formatCommand(e){return truncateOneLine(e)}function formatNetworkPolicy(e){return truncateOneLine(typeof e==`string`?e:JSON.stringify(e))}function truncateOneLine(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{createLoggingSandboxSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.9.1`,WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -8,7 +8,7 @@ type NormalizedSandboxDefinition = Readonly<Omit<SandboxDefinition, "backend">>
|
|
|
8
8
|
/**
|
|
9
9
|
* Normalizes one authored sandbox definition into the canonical internal
|
|
10
10
|
* shape. If the author supplied a `backend` callback (e.g.
|
|
11
|
-
* `backend: () =>
|
|
11
|
+
* `backend: () => vercel({...})`), it is wrapped via
|
|
12
12
|
* {@link lazyBackend} so downstream consumers always see a plain
|
|
13
13
|
* `SandboxBackend` value — the callback fires exactly once on first
|
|
14
14
|
* access and the resulting backend is memoized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectFunction,expectObjectRecord,expectOnlyKnownKeys}from"#internal/authored-module.js";import{lazyBackend}from"#execution/sandbox/lazy-backend.js";function normalizeSandboxDefinition(n,r){let i=expectObjectRecord(n,r);expectOnlyKnownKeys(i,[`backend`,`bootstrap`,`description`,`onSession`,`revalidationKey`],r);let a={};if(i.backend!==void 0&&(a.backend=expectSandboxBackend(i.backend,r)),i.description!==void 0){if(typeof i.description!=`string`)throw Error(`${r} The "description" field must be a string when set.`);a.description=i.description}if(i.bootstrap!==void 0&&(a.bootstrap=expectFunction(i.bootstrap,r)),i.revalidationKey!==void 0&&(a.revalidationKey=expectFunction(i.revalidationKey,r)),a.bootstrap===void 0&&a.revalidationKey!==void 0)throw Error(`${r} The "revalidationKey" field can only be set when "bootstrap" is set.`);return i.onSession!==void 0&&(a.onSession=expectFunction(i.onSession,r)),a}function expectSandboxBackend(e,t){if(typeof e==`function`)return lazyBackend(e);let r=expectObjectRecord(e,`${t} The "backend" field must be a SandboxBackend value (use
|
|
1
|
+
import{expectFunction,expectObjectRecord,expectOnlyKnownKeys}from"#internal/authored-module.js";import{lazyBackend}from"#execution/sandbox/lazy-backend.js";function normalizeSandboxDefinition(n,r){let i=expectObjectRecord(n,r);expectOnlyKnownKeys(i,[`backend`,`bootstrap`,`description`,`onSession`,`revalidationKey`],r);let a={};if(i.backend!==void 0&&(a.backend=expectSandboxBackend(i.backend,r)),i.description!==void 0){if(typeof i.description!=`string`)throw Error(`${r} The "description" field must be a string when set.`);a.description=i.description}if(i.bootstrap!==void 0&&(a.bootstrap=expectFunction(i.bootstrap,r)),i.revalidationKey!==void 0&&(a.revalidationKey=expectFunction(i.revalidationKey,r)),a.bootstrap===void 0&&a.revalidationKey!==void 0)throw Error(`${r} The "revalidationKey" field can only be set when "bootstrap" is set.`);return i.onSession!==void 0&&(a.onSession=expectFunction(i.onSession,r)),a}function expectSandboxBackend(e,t){if(typeof e==`function`)return lazyBackend(e);let r=expectObjectRecord(e,`${t} The "backend" field must be a SandboxBackend value (use docker(), vercel(), or your own factory) or a zero-arg function returning one.`);if(typeof r.name!=`string`||r.name.length===0)throw Error(`${t} The "backend" value must expose a non-empty string "name" identifier.`);if(typeof r.create!=`function`)throw Error(`${t} The "backend" value must expose a "create" function.`);if(r.prewarm!==void 0&&typeof r.prewarm!=`function`)throw Error(`${t} The "backend.prewarm" property must be a function when set.`);return r}export{normalizeSandboxDefinition};
|
|
@@ -3,7 +3,7 @@ import type { NitroBuildSurface, PreparedApplicationHost } from "#internal/nitro
|
|
|
3
3
|
/**
|
|
4
4
|
* Hosted Vercel builds can prune local sandbox backends only when the
|
|
5
5
|
* app did not explicitly configure one. Omitted backends resolve through
|
|
6
|
-
* `
|
|
6
|
+
* `defaultSandbox()`, which selects Vercel on hosted Vercel and never
|
|
7
7
|
* needs local runtime code there.
|
|
8
8
|
*/
|
|
9
9
|
export declare function shouldPruneLocalSandboxBackends(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute,relative,sep}from"node:path";const AUTHORED_ARTIFACTS_UPDATED_LOG_LINE=`[eve:dev] authored artifacts updated.`,STRUCTURAL_RELOAD_LOG_LINE=`[eve:dev] structural change detected, reloading Nitro worker...`;function formatChangeDetectedLogLine(e,t){return`[eve:dev] change detected (${formatChangeEventList(e,t)}), rebuilding authored artifacts...`}const CHANGE_DETECTED_PATTERN=/^\[eve:dev\] change detected \(\d+ events?: (.+)\), rebuilding authored artifacts\.\.\.$/u,MORE_EVENTS_PATTERN=/^\+(\d+) more$/u;function parseDevRebuildLogLine(e){if(e===`[eve:dev] authored artifacts updated.`)return{kind:`rebuilt`};if(e===`[eve:dev] structural change detected, reloading Nitro worker...`)return{kind:`reloading`};let t=
|
|
1
|
+
import{isAbsolute,relative,sep}from"node:path";const AUTHORED_ARTIFACTS_UPDATED_LOG_LINE=`[eve:dev] authored artifacts updated.`,STRUCTURAL_RELOAD_LOG_LINE=`[eve:dev] structural change detected, reloading Nitro worker...`;function formatChangeDetectedLogLine(e,t){return`[eve:dev] change detected (${formatChangeEventList(e,t)}), rebuilding authored artifacts...`}const CHANGE_DETECTED_PATTERN=/^\[eve:dev\] change detected \(\d+ events?: (.+)\), rebuilding authored artifacts\.\.\.$/u,MORE_EVENTS_PATTERN=/^\+(\d+) more$/u,REBUILD_FAILED_PATTERN=/^\[eve:dev\] rebuild (?:failed|queue error): (.+)$/u;function parseDevRebuildLogLine(e){if(e===`[eve:dev] authored artifacts updated.`)return{kind:`rebuilt`};if(e===`[eve:dev] structural change detected, reloading Nitro worker...`)return{kind:`reloading`};let t=REBUILD_FAILED_PATTERN.exec(e);if(t!==null)return{kind:`failed`,message:t[1]};let n=CHANGE_DETECTED_PATTERN.exec(e);if(n===null)return;let r=[],i=0;for(let e of n[1].split(`, `)){let t=MORE_EVENTS_PATTERN.exec(e);if(t!==null){i+=Number(t[1]);continue}let n=e.indexOf(` `);if(n===-1)return;r.push({event:e.slice(0,n),path:e.slice(n+1)})}if(r.length!==0)return{kind:`rebuilding`,events:r,more:i}}function formatChangeEventList(e,t){let n=`${t.length} event${t.length===1?``:`s`}`,r=t.slice(0,6).map(t=>`${t.event} ${formatChangeEventPath(e,t.path)}`),i=t.length-r.length;return i>0&&r.push(`+${i} more`),`${n}: ${r.join(`, `)}`}function formatChangeEventPath(r,i){let a=relative(r,i),o=a===`..`||a.startsWith(`..${sep}`)||isAbsolute(a);return(a.length>0&&!o?a:i).replaceAll(`\\`,`/`)}export{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine,parseDevRebuildLogLine};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{EVE_DEV_ENV_FLAG}from"#internal/application/optional-package-install.js";import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,clearInitializedDevelopmentSandboxBackendNames,createDevelopmentSandboxRunId,getInitializedDevelopmentSandboxBackendNames}from"#execution/sandbox/development-run.js";import{pruneDevelopmentRuntimeArtifactsSnapshotsInBackground}from"#internal/nitro/dev-runtime-artifacts.js";import{build,createDevServer,prepare}from"nitro/builder";import{createApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{pruneLocalSandboxTemplatesInBackground,stopDevelopmentSandboxResources}from"#execution/sandbox/bindings/local.js";import{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS}from"#internal/nitro/host/ports.js";const MAX_ALLOWED_DEVELOPMENT_SERVER_PORT=65535,WORKFLOW_LOCAL_BASE_URL_ENV=`WORKFLOW_LOCAL_BASE_URL`,PORT_ENV=`PORT`,WILDCARD_LISTEN_HOSTNAMES=new Set([`[::]`,`::`,`0.0.0.0`]);function normalizeDevelopmentServerClientUrl(e){let t=new URL(e);return WILDCARD_LISTEN_HOSTNAMES.has(t.hostname)?(t.hostname=`127.0.0.1`,t.toString()):e}function isAddressInUseError(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function resolveDevelopmentServerPort(e){let t=typeof e==`string`?Number(e):e??DEFAULT_DEVELOPMENT_SERVER_PORT;if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function readEnvironmentPort(){let e=process.env[PORT_ENV];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid ${PORT_ENV} environment variable "${e}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function
|
|
1
|
+
import{join}from"node:path";import{mkdir,readFile,rm,writeFile}from"node:fs/promises";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{EVE_DEV_ENV_FLAG}from"#internal/application/optional-package-install.js";import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,clearInitializedDevelopmentSandboxBackendNames,createDevelopmentSandboxRunId,getInitializedDevelopmentSandboxBackendNames}from"#execution/sandbox/development-run.js";import{pruneDevelopmentRuntimeArtifactsSnapshotsInBackground}from"#internal/nitro/dev-runtime-artifacts.js";import{build,createDevServer,prepare}from"nitro/builder";import{createApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{pruneLocalSandboxTemplatesInBackground,stopDevelopmentSandboxResources}from"#execution/sandbox/bindings/local.js";import{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS}from"#internal/nitro/host/ports.js";const MAX_ALLOWED_DEVELOPMENT_SERVER_PORT=65535,WORKFLOW_LOCAL_BASE_URL_ENV=`WORKFLOW_LOCAL_BASE_URL`,PORT_ENV=`PORT`,WILDCARD_LISTEN_HOSTNAMES=new Set([`[::]`,`::`,`0.0.0.0`]);function normalizeDevelopmentServerClientUrl(e){let t=new URL(e);return WILDCARD_LISTEN_HOSTNAMES.has(t.hostname)?(t.hostname=`127.0.0.1`,t.toString()):e}function isAddressInUseError(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function resolveDevelopmentServerPort(e){let t=typeof e==`string`?Number(e):e??DEFAULT_DEVELOPMENT_SERVER_PORT;if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function readEnvironmentPort(){let e=process.env[PORT_ENV];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid ${PORT_ENV} environment variable "${e}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function resolveDevelopmentProcessIdPath(t){return join(t,`.eve`,`dev-process.pid`)}function parseProcessId(e){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:void 0}function isProcessRunning(e){try{return process.kill(e,0),!0}catch(e){return e instanceof Error&&`code`in e&&e.code===`EPERM`}}function formatKillCommand(e){return process.platform===`win32`?`taskkill /PID ${e}`:`kill ${e}`}async function readActiveDevelopmentProcessId(e){let t;try{t=parseProcessId(await readFile(resolveDevelopmentProcessIdPath(e),`utf8`))}catch{return}if(!(t===void 0||!isProcessRunning(t)))return t}async function writeDevelopmentProcessId(a){let o=resolveDevelopmentProcessIdPath(a),s=await readActiveDevelopmentProcessId(a);if(s!==void 0)throw Error([`A dev server is already running for this Eve agent (pid ${s}).`,`To stop it, run: ${formatKillCommand(s)}`].join(`
|
|
2
|
+
`));return await mkdir(join(a,`.eve`),{recursive:!0}),await writeFile(o,`${process.pid}\n`,`utf8`),async()=>{let e;try{e=parseProcessId(await readFile(o,`utf8`))}catch{return}e===process.pid&&await rm(o,{force:!0})}}function resolveDevelopmentServerPorts(e){let t=resolveDevelopmentServerPort(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function installWorkflowLocalQueueEnvironment(e){let t=process.env[WORKFLOW_LOCAL_BASE_URL_ENV],n=process.env[PORT_ENV],r=new URL(normalizeDevelopmentServerClientUrl(e));return process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=r.origin,r.port&&(process.env[PORT_ENV]=r.port),()=>{t===void 0?delete process.env[WORKFLOW_LOCAL_BASE_URL_ENV]:process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=t,n===void 0?delete process.env[PORT_ENV]:process.env[PORT_ENV]=n}}function attachTemporarySocketErrorHandler(e){let onSocketError=()=>{};return e.once(`error`,onSocketError),()=>{e.off(`error`,onSocketError)}}function shouldProxyDevelopmentServerWebSocketUpgrades(e){return e.options.features.websocket===!0||e.options.experimental.websocket===!0}function guardDevelopmentServerWebSocketUpgrades(e,t){let n=t.upgrade.bind(t),r=shouldProxyDevelopmentServerWebSocketUpgrades(e);t.upgrade=async(e,t,i)=>{if(!r){t.destroyed||t.destroy();return}let a=attachTemporarySocketErrorHandler(t);try{await n(e,t,i)}catch{t.destroyed||t.destroy()}finally{a()}}}async function listenForDevelopmentServer(e){let t=resolveDevelopmentServerPorts({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r,silent:!0});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!isAddressInUseError(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function startDevelopmentServer(e,t={}){process.env[EVE_DEV_ENV_FLAG]??=`1`,loadDevelopmentEnvironmentFiles(e);let n=process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV],r=createDevelopmentSandboxRunId();process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=r;let i,u,d,f,p;try{let o=await prepareApplicationHost(e,{dev:!0});p=await writeDevelopmentProcessId(o.appRoot),pruneDevelopmentRuntimeArtifactsSnapshotsInBackground(o.appRoot);let s=resolveNitroCompiledArtifactsSource(createNitroArtifactsConfig({appRoot:o.appRoot,dev:!0}));startDevelopmentSandboxPrewarmInBackground({appRoot:o.appRoot,compiledArtifactsSource:s}),pruneLocalSandboxTemplatesInBackground(o.appRoot),i=await createApplicationNitro(o,!0),u=createDevServer(i),guardDevelopmentServerWebSocketUpgrades(i,u);let c=t.host??i.options.devServer.hostname,l=t.port??readEnvironmentPort(),m=l??i.options.devServer.port,h=await listenForDevelopmentServer({devServer:u,host:c,port:m,retryOnAddressInUse:l===void 0});if(!h.url)throw Error(`Nitro dev server did not expose a URL.`);d=installWorkflowLocalQueueEnvironment(h.url),await prepare(i),await build(i);let{startAuthoredSourceWatcher:g}=await import(`#internal/nitro/host/dev-authored-source-watcher.js`);f=await g({nitro:i,preparedHost:o});let _=d;if(_===void 0)throw Error(`Workflow local queue environment was not initialized.`);let v=f,y=u,b=i;return{async close(){try{await v.close(),await y.close(),await b.close(),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)})}finally{clearInitializedDevelopmentSandboxBackendNames(r),await p?.(),_(),restoreDevelopmentSandboxRunId(n)}},url:normalizeDevelopmentServerClientUrl(h.url)}}catch(e){throw await f?.close().catch(()=>{}),d?.(),await u?.close().catch(()=>{}),await i?.close().catch(()=>{}),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)}).catch(()=>{}),clearInitializedDevelopmentSandboxBackendNames(r),await p?.().catch(()=>{}),restoreDevelopmentSandboxRunId(n),e}}function restoreDevelopmentSandboxRunId(e){if(e===void 0){delete process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV];return}process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=e}export{normalizeDevelopmentServerClientUrl,startDevelopmentServer};
|
|
@@ -4,21 +4,21 @@ import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-san
|
|
|
4
4
|
import type { MicrosandboxCreateOptions } from "#public/sandbox/microsandbox-sandbox.js";
|
|
5
5
|
import type { VercelSandboxCreateOptions } from "#public/sandbox/vercel-sandbox.js";
|
|
6
6
|
/**
|
|
7
|
-
* Input to {@link
|
|
7
|
+
* Input to {@link defaultSandbox}: a separate options bag per inner
|
|
8
8
|
* backend. The framework picks one backend at runtime based on
|
|
9
9
|
* availability and passes it the matching bag; the others are ignored.
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
11
|
+
export interface DefaultSandboxOptions {
|
|
12
12
|
readonly docker?: DockerSandboxCreateOptions;
|
|
13
13
|
readonly justBash?: JustBashSandboxCreateOptions;
|
|
14
14
|
readonly microsandbox?: MicrosandboxCreateOptions;
|
|
15
15
|
readonly vercel?: VercelSandboxCreateOptions;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Availability probes behind {@link
|
|
18
|
+
* Availability probes behind {@link defaultSandbox}'s selection chain.
|
|
19
19
|
* Injectable so selection logic is testable without touching the host.
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
21
|
+
export interface DefaultSandboxProbes {
|
|
22
22
|
readonly isDeployedOnVercel: () => boolean;
|
|
23
23
|
readonly isDockerAvailable: () => boolean;
|
|
24
24
|
readonly isMicrosandboxSupported: () => boolean;
|
|
@@ -37,13 +37,13 @@ export interface DefaultBackendProbes {
|
|
|
37
37
|
* auto-installs the package into the project.
|
|
38
38
|
*
|
|
39
39
|
* The selection is cached for the process lifetime. To pin a backend
|
|
40
|
-
* unconditionally, configure its factory directly (`
|
|
41
|
-
* `
|
|
42
|
-
* `
|
|
40
|
+
* unconditionally, configure its factory directly (`docker()`,
|
|
41
|
+
* `microsandbox()`, `justbash()`,
|
|
42
|
+
* `vercel()`).
|
|
43
43
|
*/
|
|
44
|
-
export declare function
|
|
44
|
+
export declare function defaultSandbox(opts?: DefaultSandboxOptions): SandboxBackend;
|
|
45
45
|
/**
|
|
46
|
-
* The selection chain behind {@link
|
|
46
|
+
* The selection chain behind {@link defaultSandbox}. Internal —
|
|
47
47
|
* exported for tests, which inject probes.
|
|
48
48
|
*/
|
|
49
|
-
export declare function
|
|
49
|
+
export declare function selectDefaultSandbox(opts: DefaultSandboxOptions | undefined, probes: DefaultSandboxProbes): SandboxBackend;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lazyBackend}from"#execution/sandbox/lazy-backend.js";import{isDockerDaemonAvailableSync,isMicrosandboxPlatformSupported}from"#execution/sandbox/bindings/local.js";import{
|
|
1
|
+
import{lazyBackend}from"#execution/sandbox/lazy-backend.js";import{isDockerDaemonAvailableSync,isMicrosandboxPlatformSupported}from"#execution/sandbox/bindings/local.js";import{docker}from"#public/sandbox/backends/docker.js";import{justbash}from"#public/sandbox/backends/just-bash.js";import{microsandbox}from"#public/sandbox/backends/microsandbox.js";import{vercel}from"#public/sandbox/backends/vercel.js";const PRODUCTION_PROBES={isDeployedOnVercel:()=>!!process.env.VERCEL,isDockerAvailable:()=>isDockerDaemonAvailableSync(),isMicrosandboxSupported:()=>isMicrosandboxPlatformSupported()};function defaultSandbox(t){return lazyBackend(()=>selectDefaultSandbox(t,PRODUCTION_PROBES))}function selectDefaultSandbox(e,t){return t.isDeployedOnVercel()?vercel(e?.vercel):t.isDockerAvailable()?docker(e?.docker):t.isMicrosandboxSupported()?microsandbox(e?.microsandbox):justbash(e?.justBash)}export{defaultSandbox,selectDefaultSandbox};
|
|
@@ -11,4 +11,4 @@ import type { DockerSandboxCreateOptions } from "#public/sandbox/docker-sandbox.
|
|
|
11
11
|
* Configuring this backend pins it unconditionally — when you want
|
|
12
12
|
* fallback behavior, use `defaultBackend()` instead.
|
|
13
13
|
*/
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function docker(opts?: DockerSandboxCreateOptions): SandboxBackend;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDockerSandboxBackend}from"#execution/sandbox/bindings/local.js";function
|
|
1
|
+
import{createDockerSandboxBackend}from"#execution/sandbox/bindings/local.js";function docker(e){return createDockerSandboxBackend({createOptions:e})}export{docker};
|
|
@@ -14,4 +14,4 @@ import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-san
|
|
|
14
14
|
* unconditionally — when you want fallback behavior, use
|
|
15
15
|
* `defaultBackend()` instead.
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function justbash(opts?: JustBashSandboxCreateOptions): SandboxBackend;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createJustBashSandboxBackend}from"#execution/sandbox/bindings/local.js";function
|
|
1
|
+
import{createJustBashSandboxBackend}from"#execution/sandbox/bindings/local.js";function justbash(e){return createJustBashSandboxBackend({createOptions:e})}export{justbash};
|
|
@@ -14,4 +14,4 @@ import type { MicrosandboxBootstrapUseOptions, MicrosandboxCreateOptions, Micros
|
|
|
14
14
|
* Configuring this backend pins it unconditionally — when you want
|
|
15
15
|
* fallback behavior, use `defaultBackend()` instead.
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function microsandbox(opts?: MicrosandboxCreateOptions): SandboxBackend<MicrosandboxBootstrapUseOptions, MicrosandboxSessionUseOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMicrosandboxSandboxBackend}from"#execution/sandbox/bindings/local.js";function
|
|
1
|
+
import{createMicrosandboxSandboxBackend}from"#execution/sandbox/bindings/local.js";function microsandbox(e){return createMicrosandboxSandboxBackend({createOptions:e})}export{microsandbox};
|
|
@@ -26,4 +26,4 @@ import type { VercelSandboxBootstrapUseOptions, VercelSandboxCreateOptions, Verc
|
|
|
26
26
|
* SDK's `update` under the hood, overriding any overlapping field
|
|
27
27
|
* from `opts`.
|
|
28
28
|
*/
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function vercel(opts?: VercelSandboxCreateOptions): SandboxBackend<VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createVercelSandbox}from"#execution/sandbox/bindings/vercel.js";function vercel(e){return createVercelSandbox({createOptions:e})}export{vercel};
|
|
@@ -13,11 +13,11 @@ export type DockerSandboxPullPolicy = "if-not-present" | "always" | "never";
|
|
|
13
13
|
* Docker supports coarse-grained egress control only: `"allow-all"`
|
|
14
14
|
* attaches the container to the default bridge network, `"deny-all"`
|
|
15
15
|
* runs it with networking disabled. Domain-level policies and
|
|
16
|
-
* credential brokering require `
|
|
16
|
+
* credential brokering require `vercel()`.
|
|
17
17
|
*/
|
|
18
18
|
export type DockerSandboxNetworkPolicy = "allow-all" | "deny-all";
|
|
19
19
|
/**
|
|
20
|
-
* Options accepted by `
|
|
20
|
+
* Options accepted by `docker(opts)`.
|
|
21
21
|
*/
|
|
22
22
|
export interface DockerSandboxCreateOptions {
|
|
23
23
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{docker}from"#public/sandbox/backends/docker.js";export{docker};
|
|
@@ -6,12 +6,4 @@ export { defineSandbox, type SandboxBootstrapContext, type SandboxBootstrapUseFn
|
|
|
6
6
|
export type { SandboxBackend, SandboxBackendCreateInput, SandboxBackendHandle, SandboxBackendPrewarmInput, SandboxBackendRuntimeContext, SandboxBackendSessionState, SandboxSeedFile, } from "#public/definitions/sandbox-backend.js";
|
|
7
7
|
export type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
|
|
8
8
|
export { SandboxTemplateNotProvisionedError } from "#public/definitions/sandbox-backend.js";
|
|
9
|
-
export { defaultBackend, type DefaultBackendOptions } from "#public/sandbox/backends/default.js";
|
|
10
|
-
export { dockerBackend } from "#public/sandbox/backends/docker.js";
|
|
11
|
-
export { justBashBackend } from "#public/sandbox/backends/just-bash.js";
|
|
12
|
-
export { microsandboxBackend } from "#public/sandbox/backends/microsandbox.js";
|
|
13
|
-
export { vercelSandboxBackend } from "#public/sandbox/backends/vercel.js";
|
|
14
|
-
export type { DockerSandboxCreateOptions, DockerSandboxNetworkPolicy, DockerSandboxPullPolicy, } from "#public/sandbox/docker-sandbox.js";
|
|
15
|
-
export type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-sandbox.js";
|
|
16
|
-
export type { MicrosandboxBootstrapUseOptions, MicrosandboxCreateOptions, MicrosandboxSessionUseOptions, } from "#public/sandbox/microsandbox-sandbox.js";
|
|
17
|
-
export type { VercelSandboxBootstrapUseOptions, VercelSandboxCreateOptions, VercelSandboxSessionUseOptions, } from "#public/sandbox/vercel-sandbox.js";
|
|
9
|
+
export { defaultSandbox as defaultBackend, type DefaultSandboxOptions as DefaultBackendOptions, } from "#public/sandbox/backends/default.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{
|
|
1
|
+
import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{defineSandbox}from"#public/definitions/sandbox.js";import{defaultSandbox as defaultBackend}from"#public/sandbox/backends/default.js";export{SandboxTemplateNotProvisionedError,defaultBackend,defineSandbox};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{justbash}from"#public/sandbox/backends/just-bash.js";export{justbash};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
|
|
2
2
|
/**
|
|
3
|
-
* Options accepted by `
|
|
3
|
+
* Options accepted by `microsandbox(opts)`.
|
|
4
4
|
*
|
|
5
5
|
* The microsandbox backend runs sandboxes in lightweight local VMs via
|
|
6
6
|
* [microsandbox](https://www.npmjs.com/package/microsandbox). Options
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{microsandbox}from"#public/sandbox/backends/microsandbox.js";export{microsandbox};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sandbox as SdkSandbox, SandboxUpdateParams } from "#compiled/@vercel/sandbox/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Options accepted by `
|
|
3
|
+
* Options accepted by `vercel(opts)`. Forwarded to Vercel
|
|
4
4
|
* Sandbox creation for every fresh sandbox the framework creates
|
|
5
5
|
* (template at prewarm time, session at first-time session-create).
|
|
6
6
|
* Skipped on resume (`Sandbox.get`) since no create happens there.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{vercel}from"#public/sandbox/backends/vercel.js";export{vercel};
|