secure-exec 0.2.1 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +163 -5
  2. package/dist/context.d.ts +17 -0
  3. package/dist/context.js +15 -0
  4. package/dist/index.d.ts +15 -14
  5. package/dist/index.js +15 -10
  6. package/dist/runtime.d.ts +38 -30
  7. package/dist/runtime.js +78 -71
  8. package/dist/typescript.d.ts +15 -0
  9. package/dist/typescript.js +17 -0
  10. package/package.json +51 -54
  11. package/LICENSE +0 -191
  12. package/dist/bridge-loader.d.ts +0 -1
  13. package/dist/bridge-loader.js +0 -2
  14. package/dist/bridge-setup.d.ts +0 -1
  15. package/dist/bridge-setup.js +0 -2
  16. package/dist/esm-compiler.d.ts +0 -1
  17. package/dist/esm-compiler.js +0 -2
  18. package/dist/fs-helpers.d.ts +0 -2
  19. package/dist/fs-helpers.js +0 -1
  20. package/dist/module-resolver.d.ts +0 -1
  21. package/dist/module-resolver.js +0 -2
  22. package/dist/node/bridge-setup.d.ts +0 -1
  23. package/dist/node/bridge-setup.js +0 -2
  24. package/dist/node/driver.d.ts +0 -2
  25. package/dist/node/driver.js +0 -2
  26. package/dist/node/execution-driver.d.ts +0 -2
  27. package/dist/node/execution-driver.js +0 -2
  28. package/dist/node/isolate-bootstrap.d.ts +0 -2
  29. package/dist/node/isolate-bootstrap.js +0 -1
  30. package/dist/node/module-access.d.ts +0 -2
  31. package/dist/node/module-access.js +0 -2
  32. package/dist/node/module-resolver.d.ts +0 -1
  33. package/dist/node/module-resolver.js +0 -2
  34. package/dist/package-bundler.d.ts +0 -2
  35. package/dist/package-bundler.js +0 -1
  36. package/dist/polyfills.d.ts +0 -1
  37. package/dist/polyfills.js +0 -2
  38. package/dist/runtime-driver.d.ts +0 -1
  39. package/dist/runtime-driver.js +0 -1
  40. package/dist/shared/api-types.d.ts +0 -1
  41. package/dist/shared/api-types.js +0 -1
  42. package/dist/shared/bridge-contract.d.ts +0 -2
  43. package/dist/shared/bridge-contract.js +0 -1
  44. package/dist/shared/console-formatter.d.ts +0 -2
  45. package/dist/shared/console-formatter.js +0 -1
  46. package/dist/shared/errors.d.ts +0 -2
  47. package/dist/shared/errors.js +0 -1
  48. package/dist/shared/esm-utils.d.ts +0 -1
  49. package/dist/shared/esm-utils.js +0 -2
  50. package/dist/shared/global-exposure.d.ts +0 -2
  51. package/dist/shared/global-exposure.js +0 -1
  52. package/dist/shared/in-memory-fs.d.ts +0 -1
  53. package/dist/shared/in-memory-fs.js +0 -2
  54. package/dist/shared/permissions.d.ts +0 -1
  55. package/dist/shared/permissions.js +0 -2
  56. package/dist/shared/require-setup.d.ts +0 -1
  57. package/dist/shared/require-setup.js +0 -2
  58. package/dist/types.d.ts +0 -3
  59. package/dist/types.js +0 -1
package/README.md CHANGED
@@ -1,7 +1,165 @@
1
- # Secure Exec
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/rivet-dev/agentos/main/.github/media/secure-exec-logo.png" alt="Secure Exec" height="160" />
3
+ </p>
2
4
 
3
- Secure Node.js execution without a sandbox. V8 isolate-based code execution with full Node.js and npm compatibility.
5
+ <p align="center">
6
+ Secure Node.js execution without a sandbox.<br/>Run untrusted JavaScript and TypeScript in an isolated VM with real Node.js APIs, npm packages, and a virtual filesystem.
7
+ </p>
4
8
 
5
- - [Website](https://secureexec.dev)
6
- - [Documentation](https://secureexec.dev/docs)
7
- - [GitHub](https://github.com/rivet-dev/secure-exec)
9
+ <p align="center">
10
+ <a href="https://rivet.dev/secure-exec/docs/quickstart">Quickstart</a> | <a href="https://rivet.dev/secure-exec/docs">Documentation</a> | <a href="https://rivet.dev/discord">Discord</a>
11
+ </p>
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install secure-exec
17
+ ```
18
+
19
+ Requires Node.js 22+ on Linux or macOS.
20
+
21
+ ## Run Code
22
+
23
+ Each call runs in a fresh VM that is disposed when the call finishes. Nothing is
24
+ shared between calls.
25
+
26
+ ```ts
27
+ import { evaluate, execute } from "secure-exec";
28
+
29
+ const sum = await evaluate<number>("1 + 2");
30
+ if (sum.outcome === "succeeded") console.log(sum.value); // 3
31
+
32
+ const run = await execute(`console.log("hello")`, {
33
+ output: { capture: "all" },
34
+ timeoutMs: 5_000,
35
+ });
36
+ console.log(run.stdout); // hello
37
+ ```
38
+
39
+ `evaluate` takes one expression and returns its JSON value; wrap several
40
+ statements in a function. `execute` runs a whole module for its side effects.
41
+
42
+ `outcome` is `succeeded`, `failed`, `cancelled`, or `timed_out`. Every outcome
43
+ other than `succeeded` carries an `error`, and guest stack traces arrive on
44
+ `stderr` when you capture it.
45
+
46
+ ## Configure the VM
47
+
48
+ VM options go on the call: `permissions`, `limits`, `mounts`, and the rest of
49
+ the agentOS VM options. External network access is denied unless you allow it,
50
+ and a policy is merged over the defaults.
51
+
52
+ ```ts
53
+ await evaluate(
54
+ `(async () => {
55
+ const response = await fetch("https://example.com");
56
+ await response.text();
57
+ return response.status;
58
+ })()`,
59
+ { permissions: { network: "allow" } },
60
+ );
61
+ ```
62
+
63
+ ## Keep things with a VM
64
+
65
+ The functions above are one-shot conveniences. When files, installed packages,
66
+ or a running server should outlast one call, create a VM. It is an agentOS VM
67
+ with Secure Exec's defaults.
68
+
69
+ ```ts
70
+ import { createVm } from "secure-exec";
71
+
72
+ const vm = await createVm({ permissions: { network: "allow" } });
73
+ try {
74
+ await vm.npm.install(["zod"]);
75
+ await vm.filesystem.writeFile("/workspace/data.json", JSON.stringify({ n: 40 }));
76
+
77
+ const result = await vm.javascript.evaluate<number>(
78
+ `import("node:fs").then((fs) => JSON.parse(fs.readFileSync("/workspace/data.json", "utf8")).n + 2)`,
79
+ );
80
+
81
+ const server = await vm.javascript.spawn(`/* long-running code */`);
82
+ await vm.process.kill(server.pid);
83
+ } finally {
84
+ await vm.dispose();
85
+ }
86
+ ```
87
+
88
+ `vm.javascript`, `vm.typescript`, `vm.npm`, `vm.filesystem`, `vm.network`, and
89
+ `vm.process` behave exactly as they do in agentOS.
90
+
91
+ ## Keep variables with a context
92
+
93
+ Each call on a VM starts with fresh JavaScript memory. A context keeps it, like a
94
+ REPL, and several contexts run in parallel in one VM.
95
+
96
+ ```ts
97
+ const context = await vm.createContext();
98
+
99
+ await context.execute("globalThis.total = 40");
100
+ const result = await context.evaluate<number>("total + 2");
101
+
102
+ await context.reset(); // clear state
103
+ await context.dispose(); // delete the context, keep the VM
104
+ ```
105
+
106
+ ## Host functions
107
+
108
+ Give the code your own functions without giving it your credentials. Each
109
+ collection is a global inside the VM, and each function is async.
110
+
111
+ ```ts
112
+ import { evaluate, hostFunction, hostFunctions } from "secure-exec";
113
+ import { z } from "zod";
114
+
115
+ const orders = hostFunctions({
116
+ name: "orders",
117
+ description: "Look up customer orders.",
118
+ functions: {
119
+ list: hostFunction({
120
+ description: "List a customer's orders.",
121
+ inputSchema: z.object({ customer: z.string() }),
122
+ execute: ({ customer }) => db.orders.findMany({ customer }),
123
+ }),
124
+ },
125
+ });
126
+
127
+ await evaluate(`orders.list({ customer: "c_123" }).then((rows) => rows.length)`, {
128
+ hostFunctions: [orders],
129
+ });
130
+ ```
131
+
132
+ ## TypeScript
133
+
134
+ `secure-exec/typescript` has the same `execute` and `evaluate`, plus `check`.
135
+ Running TypeScript strips types without checking them, so check first when it
136
+ matters.
137
+
138
+ ```ts
139
+ import { check, evaluate } from "secure-exec/typescript";
140
+
141
+ const checked = await check(`const total: number = "nope";`);
142
+ for (const diagnostic of checked.diagnostics) console.log(diagnostic.message);
143
+ ```
144
+
145
+ ## Lifecycle
146
+
147
+ The first call starts a shared sidecar process. Call `init()` at startup to pay
148
+ that cost ahead of time, and `shutdown()` to stop it, for example in a test
149
+ teardown hook.
150
+
151
+ ```ts
152
+ import { init, shutdown } from "secure-exec";
153
+
154
+ await init();
155
+ // ...
156
+ await shutdown();
157
+ ```
158
+
159
+ ## More
160
+
161
+ Need Python? Use the [agentOS Python execution API](https://rivet.dev/agentos/docs/python), which has the same `execute` and `evaluate` shape.
162
+
163
+ For processes, filesystem access, and agent sessions, use
164
+ [`@rivet-dev/agentos-core`](https://rivet.dev/agentos) directly. Read the [documentation](https://rivet.dev/secure-exec/docs), or browse the examples in
165
+ [`secure-exec/examples`](https://github.com/rivet-dev/agentos/tree/main/secure-exec/examples).
@@ -0,0 +1,17 @@
1
+ import type { AgentOs, CodeEvaluationResult, CodeExecutionResult, JavaScriptEvaluationOptions, JavaScriptExecutionOptions, JsonValue } from "@rivet-dev/agentos-core";
2
+ /**
3
+ * Retained JavaScript state in a VM: variables and imports survive between
4
+ * calls. A context runs one call at a time. For TypeScript in the same state,
5
+ * pass `contextId` to `vm.typescript`.
6
+ */
7
+ export interface Context extends AsyncDisposable {
8
+ readonly contextId: string;
9
+ execute(source: string, options?: Omit<JavaScriptExecutionOptions, "contextId">): Promise<CodeExecutionResult>;
10
+ evaluate<T = JsonValue>(source: string, options?: Omit<JavaScriptEvaluationOptions, "contextId">): Promise<CodeEvaluationResult<T>>;
11
+ /** Clear the retained state and keep the context. */
12
+ reset(): Promise<void>;
13
+ /** Delete the context. The VM is left running. */
14
+ dispose(): Promise<void>;
15
+ }
16
+ /** Create a context in `vm`. A VM can hold many, and they run in parallel. */
17
+ export declare function createContext(vm: AgentOs): Promise<Context>;
@@ -0,0 +1,15 @@
1
+ import { randomUUID } from "node:crypto";
2
+ /** Create a context in `vm`. A VM can hold many, and they run in parallel. */
3
+ export async function createContext(vm) {
4
+ const contextId = randomUUID();
5
+ await vm.createContext(contextId);
6
+ const dispose = () => vm.contexts.delete(contextId);
7
+ return {
8
+ contextId,
9
+ execute: (source, options) => vm.javascript.execute(source, { ...options, contextId }),
10
+ evaluate: (source, options) => vm.javascript.evaluate(source, { ...options, contextId }),
11
+ reset: () => vm.contexts.reset(contextId),
12
+ dispose,
13
+ [Symbol.asyncDispose]: dispose,
14
+ };
15
+ }
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- export { NodeRuntime } from "./runtime.js";
2
- export type { NodeRuntimeOptions } from "./runtime.js";
3
- export type { ResourceBudgets } from "./runtime-driver.js";
4
- export type { NodeRuntimeDriver, NodeRuntimeDriverFactory, NetworkAdapter, Permissions, VirtualFileSystem, } from "./types.js";
5
- export type { DirEntry, StatInfo } from "./fs-helpers.js";
6
- export type { StdioChannel, StdioEvent, StdioHook, ExecOptions, ExecResult, OSConfig, ProcessConfig, RunResult, TimingMitigation, } from "./shared/api-types.js";
7
- export { createDefaultNetworkAdapter, createNodeDriver, createNodeHostCommandExecutor, createNodeRuntimeDriverFactory, NodeExecutionDriver, NodeFileSystem, } from "@secure-exec/nodejs";
8
- export type { DefaultNetworkAdapterOptions, ModuleAccessOptions, NodeRuntimeDriverFactoryOptions, } from "@secure-exec/nodejs";
9
- export { createKernel } from "@secure-exec/core";
10
- export type { Kernel, KernelInterface } from "@secure-exec/core";
11
- export { createNodeRuntime } from "@secure-exec/nodejs";
12
- export type { BindingTree, BindingFunction } from "@secure-exec/nodejs";
13
- export { createInMemoryFileSystem } from "./shared/in-memory-fs.js";
14
- export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, } from "./shared/permissions.js";
1
+ import type { CodeEvaluationResult, CodeExecutionResult, HostFunctionSchemas, JavaScriptEvaluationOptions, JavaScriptExecutionOptions, JsonValue, LanguageExecutionOptions } from "@rivet-dev/agentos-core";
2
+ import { type OneShot } from "./runtime.js";
3
+ export type { CodeEvaluationResult, CodeExecutionResult, ExecutionErrorData, ExecutionOutputOptions, HostFunction, HostFunctionCollection, HostFunctionCollections, HttpRequest, HttpResponse, JsonValue, LimitWarning, MountConfig, OutputCapture, Permissions, ProcessDescriptor, ProcessExit, SidecarRejectionDetail, } from "@rivet-dev/agentos-core";
4
+ export { createHostDirBackend, hostDirMount, KernelError, nodeModulesMount, SidecarProcessError, SidecarProcessExited, SidecarRejectedError, SidecarSilenceTimeout, } from "@rivet-dev/agentos-core";
5
+ export type { Context } from "./context.js";
6
+ export { createVm, init, shutdown, type Vm, type VmOptions, } from "./runtime.js";
7
+ export type ExecuteOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<JavaScriptExecutionOptions, HOST_FUNCTIONS>;
8
+ export type EvaluateOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<JavaScriptEvaluationOptions, HOST_FUNCTIONS>;
9
+ export type ExecuteFileOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<LanguageExecutionOptions, HOST_FUNCTIONS>;
10
+ /** Run JavaScript for its side effects and captured output. */
11
+ export declare function execute<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(source: string, options?: ExecuteOptions<HOST_FUNCTIONS>): Promise<CodeExecutionResult>;
12
+ /** Evaluate one JavaScript expression and return its JSON value. */
13
+ export declare function evaluate<T = JsonValue, HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(source: string, options?: EvaluateOptions<HOST_FUNCTIONS>): Promise<CodeEvaluationResult<T>>;
14
+ /** Run a JavaScript file from a mount, by its path inside the VM. */
15
+ export declare function executeFile<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(path: string, options?: ExecuteFileOptions<HOST_FUNCTIONS>): Promise<CodeExecutionResult>;
package/dist/index.js CHANGED
@@ -1,10 +1,15 @@
1
- // Re-export core runtime surface.
2
- export { NodeRuntime } from "./runtime.js";
3
- // Re-export Node driver factories.
4
- export { createDefaultNetworkAdapter, createNodeDriver, createNodeHostCommandExecutor, createNodeRuntimeDriverFactory, NodeExecutionDriver, NodeFileSystem, } from "@secure-exec/nodejs";
5
- // Re-export kernel API.
6
- export { createKernel } from "@secure-exec/core";
7
- // Re-export kernel Node runtime factory.
8
- export { createNodeRuntime } from "@secure-exec/nodejs";
9
- export { createInMemoryFileSystem } from "./shared/in-memory-fs.js";
10
- export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, } from "./shared/permissions.js";
1
+ import { run } from "./runtime.js";
2
+ export { createHostDirBackend, hostDirMount, KernelError, nodeModulesMount, SidecarProcessError, SidecarProcessExited, SidecarRejectedError, SidecarSilenceTimeout, } from "@rivet-dev/agentos-core";
3
+ export { createVm, init, shutdown, } from "./runtime.js";
4
+ /** Run JavaScript for its side effects and captured output. */
5
+ export function execute(source, options) {
6
+ return run(options, (vm, operationOptions) => vm.javascript.execute(source, operationOptions));
7
+ }
8
+ /** Evaluate one JavaScript expression and return its JSON value. */
9
+ export function evaluate(source, options) {
10
+ return run(options, (vm, operationOptions) => vm.javascript.evaluate(source, operationOptions));
11
+ }
12
+ /** Run a JavaScript file from a mount, by its path inside the VM. */
13
+ export function executeFile(path, options) {
14
+ return run(options, (vm, operationOptions) => vm.javascript.executeFile(path, operationOptions));
15
+ }
package/dist/runtime.d.ts CHANGED
@@ -1,31 +1,39 @@
1
- import type { NetworkAdapter, NodeRuntimeDriverFactory, SystemDriver } from "@secure-exec/core";
2
- import type { StdioHook, ExecOptions, ExecResult, RunResult, TimingMitigation } from "@secure-exec/core";
3
- import type { ResourceBudgets } from "@secure-exec/core";
4
- export interface NodeRuntimeOptions {
5
- systemDriver: SystemDriver;
6
- runtimeDriverFactory: NodeRuntimeDriverFactory;
7
- memoryLimit?: number;
8
- cpuTimeLimitMs?: number;
9
- timingMitigation?: TimingMitigation;
10
- onStdio?: StdioHook;
11
- payloadLimits?: {
12
- base64TransferBytes?: number;
13
- jsonPayloadBytes?: number;
14
- };
15
- resourceBudgets?: ResourceBudgets;
16
- }
17
- export declare class NodeRuntime {
18
- private readonly runtimeDriver;
19
- constructor(options: NodeRuntimeOptions);
20
- get network(): Pick<NetworkAdapter, "fetch" | "dnsLookup" | "httpRequest">;
21
- get __unsafeIsoalte(): unknown;
22
- __unsafeCreateContext(options?: {
23
- env?: Record<string, string>;
24
- cwd?: string;
25
- filePath?: string;
26
- }): Promise<unknown>;
27
- run<T = unknown>(code: string, filePath?: string): Promise<RunResult<T>>;
28
- exec(code: string, options?: ExecOptions): Promise<ExecResult>;
29
- dispose(): void;
30
- terminate(): Promise<void>;
1
+ import { AgentOs, type AgentOsOptions, type HostFunctionSchemas } from "@rivet-dev/agentos-core";
2
+ import { type Context } from "./context.js";
3
+ /**
4
+ * Options for the VM that runs the code: permissions, limits, mounts, and so on.
5
+ *
6
+ * The type parameter exists only so each host function's `execute` infers its
7
+ * input from its own `inputSchema`; callers never write it.
8
+ */
9
+ export type VmOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = AgentOsOptions<HOST_FUNCTIONS>;
10
+ /**
11
+ * A VM that lives until you dispose it. Files, installed packages, and
12
+ * background processes persist across the calls you make on it. Every namespace
13
+ * is the agentOS one, unchanged, so the agentOS docs describe its behavior.
14
+ */
15
+ export interface Vm extends AsyncDisposable {
16
+ readonly javascript: Omit<AgentOs["javascript"], "npm">;
17
+ readonly typescript: AgentOs["typescript"];
18
+ readonly npm: AgentOs["javascript"]["npm"];
19
+ readonly filesystem: AgentOs["filesystem"];
20
+ readonly network: AgentOs["network"];
21
+ readonly process: AgentOs["process"];
22
+ /** Create a context: JavaScript state that survives between calls. */
23
+ createContext(): Promise<Context>;
24
+ /** Dispose the VM and everything in it. */
25
+ dispose(): Promise<void>;
31
26
  }
27
+ export declare function createVm<HOST_FUNCTIONS extends HostFunctionSchemas>(options?: VmOptions<HOST_FUNCTIONS>): Promise<Vm>;
28
+ /** Options for a one-shot call: the operation's own options plus VM options. */
29
+ export type OneShot<O, HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = Omit<O, "contextId"> & VmOptions<HOST_FUNCTIONS>;
30
+ /** Start the shared sidecar process now so the first operation does not pay for it. */
31
+ export declare function init(): Promise<void>;
32
+ /**
33
+ * Stop the shared sidecar process and every VM still running in it. Call it when
34
+ * your process should exit while work may be in flight, such as at the end of a
35
+ * test run. The next call starts a new sidecar.
36
+ */
37
+ export declare function shutdown(): Promise<void>;
38
+ /** Run `operation` in a fresh VM built from the VM options, then dispose it. */
39
+ export declare function run<O extends object, R, HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(options: (O & VmOptions<HOST_FUNCTIONS>) | undefined, operation: (vm: Vm, options: O) => Promise<R>): Promise<R>;
package/dist/runtime.js CHANGED
@@ -1,77 +1,84 @@
1
- import { createNetworkStub, filterEnv } from "@secure-exec/core";
2
- import { createSandboxCommandExecutor } from "@secure-exec/nodejs";
3
- const DEFAULT_SANDBOX_CWD = "/root";
4
- const DEFAULT_SANDBOX_HOME = "/root";
5
- const DEFAULT_SANDBOX_TMPDIR = "/tmp";
6
- export class NodeRuntime {
7
- runtimeDriver;
8
- constructor(options) {
9
- const { runtimeDriverFactory } = options;
10
- // Auto-inject sandbox command executor when none is configured
11
- const systemDriver = options.systemDriver.commandExecutor
12
- ? options.systemDriver
13
- : {
14
- ...options.systemDriver,
15
- commandExecutor: createSandboxCommandExecutor(runtimeDriverFactory, options.systemDriver),
16
- };
17
- const processConfig = {
18
- ...(systemDriver.runtime.process ?? {}),
19
- };
20
- processConfig.cwd ??= DEFAULT_SANDBOX_CWD;
21
- processConfig.env = filterEnv(processConfig.env, systemDriver.permissions);
22
- const osConfig = {
23
- ...(systemDriver.runtime.os ?? {}),
24
- };
25
- osConfig.homedir ??= DEFAULT_SANDBOX_HOME;
26
- osConfig.tmpdir ??= DEFAULT_SANDBOX_TMPDIR;
27
- this.runtimeDriver = runtimeDriverFactory.createRuntimeDriver({
28
- system: systemDriver,
29
- runtime: {
30
- process: processConfig,
31
- os: osConfig,
32
- },
33
- memoryLimit: options.memoryLimit,
34
- cpuTimeLimitMs: options.cpuTimeLimitMs,
35
- timingMitigation: options.timingMitigation,
36
- onStdio: options.onStdio,
37
- payloadLimits: options.payloadLimits,
38
- resourceBudgets: options.resourceBudgets,
39
- });
40
- }
41
- get network() {
42
- const adapter = this.runtimeDriver.network ?? createNetworkStub();
43
- return {
44
- fetch: (url, options) => adapter.fetch(url, options),
45
- dnsLookup: (hostname) => adapter.dnsLookup(hostname),
46
- httpRequest: (url, options) => adapter.httpRequest(url, options),
47
- };
48
- }
49
- get __unsafeIsoalte() {
50
- if (this.runtimeDriver.unsafeIsolate === undefined) {
51
- throw new Error("Driver runtime does not expose unsafe isolate access");
52
- }
53
- return this.runtimeDriver.unsafeIsolate;
54
- }
55
- async __unsafeCreateContext(options = {}) {
56
- if (!this.runtimeDriver.createUnsafeContext) {
57
- throw new Error("Driver runtime does not expose unsafe context creation");
58
- }
59
- return this.runtimeDriver.createUnsafeContext(options);
1
+ import { AgentOs, } from "@rivet-dev/agentos-core";
2
+ import { createContext } from "./context.js";
3
+ // Keep in sync with `AgentOsOptions`. The record type makes a missing or
4
+ // unknown key a compile error.
5
+ const VM_OPTION_KEYS = Object.keys({
6
+ user: true,
7
+ software: true,
8
+ defaultSoftware: true,
9
+ loopbackExemptPorts: true,
10
+ allowedNodeBuiltins: true,
11
+ highResolutionTime: true,
12
+ database: true,
13
+ rootFilesystem: true,
14
+ mounts: true,
15
+ sandbox: true,
16
+ scheduleDriver: true,
17
+ hostFunctions: true,
18
+ permissions: true,
19
+ sidecar: true,
20
+ limits: true,
21
+ onAgentStderr: true,
22
+ onAgentExit: true,
23
+ onLimitWarning: true,
24
+ });
25
+ export async function createVm(options = {}) {
26
+ const vm = await AgentOs.create(options);
27
+ const { npm, ...javascript } = vm.javascript;
28
+ const dispose = () => vm.dispose();
29
+ return {
30
+ javascript,
31
+ typescript: vm.typescript,
32
+ npm,
33
+ filesystem: vm.filesystem,
34
+ network: vm.network,
35
+ process: vm.process,
36
+ createContext: () => createContext(vm),
37
+ dispose,
38
+ [Symbol.asyncDispose]: dispose,
39
+ };
40
+ }
41
+ /** Start the shared sidecar process now so the first operation does not pay for it. */
42
+ export async function init() {
43
+ // A bare VM is enough to start the sidecar; skip projecting default software.
44
+ const vm = await createVm({ defaultSoftware: false });
45
+ await vm.dispose();
46
+ }
47
+ /**
48
+ * Stop the shared sidecar process and every VM still running in it. Call it when
49
+ * your process should exit while work may be in flight, such as at the end of a
50
+ * test run. The next call starts a new sidecar.
51
+ */
52
+ export async function shutdown() {
53
+ const sidecar = await AgentOs.getSharedSidecar();
54
+ await sidecar.dispose();
55
+ }
56
+ /** Run `operation` in a fresh VM built from the VM options, then dispose it. */
57
+ export async function run(options, operation) {
58
+ const vmOptions = {};
59
+ const operationOptions = {};
60
+ for (const [key, value] of Object.entries(options ?? {})) {
61
+ const isVmOption = VM_OPTION_KEYS.includes(key);
62
+ (isVmOption ? vmOptions : operationOptions)[key] = value;
60
63
  }
61
- async run(code, filePath) {
62
- return this.runtimeDriver.run(code, filePath);
64
+ const vm = await createVm(vmOptions);
65
+ let result;
66
+ try {
67
+ result = await operation(vm, operationOptions);
63
68
  }
64
- async exec(code, options) {
65
- return this.runtimeDriver.exec(code, options);
69
+ catch (error) {
70
+ throw await disposeAfterFailure(vm, error);
66
71
  }
67
- dispose() {
68
- this.runtimeDriver.dispose();
72
+ await vm.dispose();
73
+ return result;
74
+ }
75
+ /** Dispose `vm` and return the error to throw, keeping both if disposal also fails. */
76
+ async function disposeAfterFailure(vm, error) {
77
+ try {
78
+ await vm.dispose();
79
+ return error;
69
80
  }
70
- async terminate() {
71
- if (this.runtimeDriver.terminate) {
72
- await this.runtimeDriver.terminate();
73
- return;
74
- }
75
- this.runtimeDriver.dispose();
81
+ catch (disposeError) {
82
+ return new AggregateError([error, disposeError], "secure-exec operation and VM cleanup failed");
76
83
  }
77
84
  }
@@ -0,0 +1,15 @@
1
+ import type { CodeEvaluationResult, CodeExecutionResult, HostFunctionSchemas, JsonValue, TypeScriptCheckOptions, TypeScriptCheckResult, TypeScriptEvaluationOptions, TypeScriptExecutionOptions, TypeScriptFileExecutionOptions } from "@rivet-dev/agentos-core";
2
+ import { type OneShot } from "./runtime.js";
3
+ export type { TypeScriptCheckResult, TypeScriptDiagnostic, } from "@rivet-dev/agentos-core";
4
+ export type ExecuteOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<TypeScriptExecutionOptions, HOST_FUNCTIONS>;
5
+ export type EvaluateOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<TypeScriptEvaluationOptions, HOST_FUNCTIONS>;
6
+ export type ExecuteFileOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<TypeScriptFileExecutionOptions, HOST_FUNCTIONS>;
7
+ export type CheckOptions<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas> = OneShot<TypeScriptCheckOptions, HOST_FUNCTIONS>;
8
+ /** Run TypeScript for its side effects and captured output. Types are stripped, not checked. */
9
+ export declare function execute<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(source: string, options?: ExecuteOptions<HOST_FUNCTIONS>): Promise<CodeExecutionResult>;
10
+ /** Evaluate one TypeScript expression and return its JSON value. Types are stripped, not checked. */
11
+ export declare function evaluate<T = JsonValue, HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(source: string, options?: EvaluateOptions<HOST_FUNCTIONS>): Promise<CodeEvaluationResult<T>>;
12
+ /** Run a TypeScript file from a mount, by its path inside the VM. Types are stripped, not checked. */
13
+ export declare function executeFile<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(path: string, options?: ExecuteFileOptions<HOST_FUNCTIONS>): Promise<CodeExecutionResult>;
14
+ /** Type-check TypeScript without running it. */
15
+ export declare function check<HOST_FUNCTIONS extends HostFunctionSchemas = HostFunctionSchemas>(source: string, options?: CheckOptions<HOST_FUNCTIONS>): Promise<TypeScriptCheckResult>;
@@ -0,0 +1,17 @@
1
+ import { run } from "./runtime.js";
2
+ /** Run TypeScript for its side effects and captured output. Types are stripped, not checked. */
3
+ export function execute(source, options) {
4
+ return run(options, (vm, operationOptions) => vm.typescript.execute(source, operationOptions));
5
+ }
6
+ /** Evaluate one TypeScript expression and return its JSON value. Types are stripped, not checked. */
7
+ export function evaluate(source, options) {
8
+ return run(options, (vm, operationOptions) => vm.typescript.evaluate(source, operationOptions));
9
+ }
10
+ /** Run a TypeScript file from a mount, by its path inside the VM. Types are stripped, not checked. */
11
+ export function executeFile(path, options) {
12
+ return run(options, (vm, operationOptions) => vm.typescript.executeFile(path, operationOptions));
13
+ }
14
+ /** Type-check TypeScript without running it. */
15
+ export function check(source, options) {
16
+ return run(options, (vm, operationOptions) => vm.typescript.check(source, operationOptions));
17
+ }
package/package.json CHANGED
@@ -1,55 +1,52 @@
1
1
  {
2
- "name": "secure-exec",
3
- "version": "0.2.1",
4
- "type": "module",
5
- "license": "Apache-2.0",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist",
10
- "README.md"
11
- ],
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/rivet-dev/secure-exec.git",
15
- "directory": "packages/secure-exec"
16
- },
17
- "exports": {
18
- ".": {
19
- "types": "./dist/index.d.ts",
20
- "import": "./dist/index.js",
21
- "default": "./dist/index.js"
22
- }
23
- },
24
- "dependencies": {
25
- "@secure-exec/core": "0.2.1",
26
- "@secure-exec/nodejs": "0.2.1"
27
- },
28
- "devDependencies": {
29
- "@mariozechner/pi-coding-agent": "^0.60.0",
30
- "@opencode-ai/sdk": "^1.2.27",
31
- "@types/node": "^22.10.2",
32
- "@vitest/browser": "^2.1.8",
33
- "@xterm/headless": "^6.0.0",
34
- "minimatch": "^10.2.4",
35
- "node-pty": "^1.1.0",
36
- "opencode-ai": "1.3.3",
37
- "playwright": "^1.52.0",
38
- "tsx": "^4.19.2",
39
- "typescript": "^5.7.2",
40
- "vitest": "^2.1.8",
41
- "@secure-exec/v8": "0.2.1"
42
- },
43
- "scripts": {
44
- "check-types": "tsc --noEmit",
45
- "check-types:test": "vitest --typecheck --run tests/types/",
46
- "build": "tsc",
47
- "test:test-suite": "vitest run tests/test-suite/node.test.ts",
48
- "test:runtime-driver": "vitest run tests/runtime-driver/node/",
49
- "test:integration:node": "pnpm run test:test-suite && pnpm run test:runtime-driver",
50
- "test:project-matrix": "vitest run tests/project-matrix.test.ts",
51
- "test:e2e-docker": "vitest run tests/e2e-docker.test.ts",
52
- "test": "vitest run",
53
- "test:watch": "vitest"
54
- }
55
- }
2
+ "name": "secure-exec",
3
+ "version": "0.2.21",
4
+ "description": "Secure Node.js execution for AI agents: run untrusted JavaScript and TypeScript in an isolated VM.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./typescript": {
17
+ "types": "./dist/typescript.d.ts",
18
+ "import": "./dist/typescript.js",
19
+ "default": "./dist/typescript.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "homepage": "https://rivet.dev/secure-exec",
27
+ "engines": {
28
+ "node": ">=22.0.0"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "check-types": "tsc --noEmit",
36
+ "test": "vitest run"
37
+ },
38
+ "dependencies": {
39
+ "@rivet-dev/agentos-core": "0.2.21"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.10.2",
43
+ "typescript": "^5.7.2",
44
+ "vitest": "^2.1.8",
45
+ "zod": "^4.1.11"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/rivet-dev/agentos.git",
50
+ "directory": "secure-exec"
51
+ }
52
+ }
package/LICENSE DELETED
@@ -1,191 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to the Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by the Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding any notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- Copyright 2025 Rivet Gaming, Inc.
180
-
181
- Licensed under the Apache License, Version 2.0 (the "License");
182
- you may not use this file except in compliance with the License.
183
- You may obtain a copy of the License at
184
-
185
- http://www.apache.org/licenses/LICENSE-2.0
186
-
187
- Unless required by applicable law or agreed to in writing, software
188
- distributed under the License is distributed on an "AS IS" BASIS,
189
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
- See the License for the specific language governing permissions and
191
- limitations under the License.
@@ -1 +0,0 @@
1
- export { getRawBridgeCode, getBridgeAttachCode } from "@secure-exec/nodejs/internal/bridge-loader";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs — canonical source is packages/nodejs/src/bridge-loader.ts
2
- export { getRawBridgeCode, getBridgeAttachCode } from "@secure-exec/nodejs/internal/bridge-loader";
@@ -1 +0,0 @@
1
- export { getInitialBridgeGlobalsSetupCode } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core — canonical source is packages/core/src/bridge-setup.ts
2
- export { getInitialBridgeGlobalsSetupCode } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { getStaticBuiltinWrapperSource, createBuiltinESMWrapper, getEmptyBuiltinESMWrapper, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core — canonical source moved to packages/nodejs/src/esm-compiler.ts (US-003)
2
- export { getStaticBuiltinWrapperSource, createBuiltinESMWrapper, getEmptyBuiltinESMWrapper, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- export type { DirEntry, StatInfo } from "@secure-exec/core";
2
- export { exists, stat, rename, readDirWithTypes, mkdir } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { exists, stat, rename, readDirWithTypes, mkdir } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { BUILTIN_NAMED_EXPORTS, normalizeBuiltinSpecifier, getPathDir, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core — canonical source moved to packages/nodejs/src/builtin-modules.ts (US-003)
2
- export { BUILTIN_NAMED_EXPORTS, normalizeBuiltinSpecifier, getPathDir, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { emitConsoleEvent, stripDangerousEnv, createProcessConfigForExecution, } from "@secure-exec/nodejs";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs
2
- export { emitConsoleEvent, stripDangerousEnv, createProcessConfigForExecution, } from "@secure-exec/nodejs";
@@ -1,2 +0,0 @@
1
- export { createDefaultNetworkAdapter, createNodeDriver, createNodeRuntimeDriverFactory, NodeFileSystem, NodeExecutionDriver, filterEnv, isPrivateIp, } from "@secure-exec/nodejs";
2
- export type { NodeDriverOptions, NodeRuntimeDriverFactoryOptions, ModuleAccessOptions, } from "@secure-exec/nodejs";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs — canonical source is packages/nodejs/src/driver.ts
2
- export { createDefaultNetworkAdapter, createNodeDriver, createNodeRuntimeDriverFactory, NodeFileSystem, NodeExecutionDriver, filterEnv, isPrivateIp, } from "@secure-exec/nodejs";
@@ -1,2 +0,0 @@
1
- export { NodeExecutionDriver } from "@secure-exec/nodejs/internal/execution-driver";
2
- export type { NodeExecutionDriverOptions } from "@secure-exec/nodejs/internal/isolate-bootstrap";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs
2
- export { NodeExecutionDriver } from "@secure-exec/nodejs/internal/execution-driver";
@@ -1,2 +0,0 @@
1
- export type { NodeExecutionDriverOptions, BudgetState, DriverDeps, } from "@secure-exec/nodejs/internal/isolate-bootstrap";
2
- export { DEFAULT_BRIDGE_BASE64_TRANSFER_BYTES, DEFAULT_ISOLATE_JSON_PAYLOAD_BYTES, MIN_CONFIGURED_PAYLOAD_BYTES, MAX_CONFIGURED_PAYLOAD_BYTES, PAYLOAD_LIMIT_ERROR_CODE, RESOURCE_BUDGET_ERROR_CODE, DEFAULT_SANDBOX_CWD, DEFAULT_SANDBOX_HOME, DEFAULT_SANDBOX_TMPDIR, PayloadLimitError, normalizePayloadLimit, getUtf8ByteLength, getBase64EncodedByteLength, assertPayloadByteLength, assertTextPayloadSize, createBudgetState, checkBridgeBudget, parseJsonWithLimit, getExecutionTimeoutMs, getTimingMitigation, polyfillCodeCache, polyfillNamedExportsCache, hostBuiltinNamedExportsCache, hostRequire, isValidExportName, getHostBuiltinNamedExports, } from "@secure-exec/nodejs/internal/isolate-bootstrap";
@@ -1 +0,0 @@
1
- export { DEFAULT_BRIDGE_BASE64_TRANSFER_BYTES, DEFAULT_ISOLATE_JSON_PAYLOAD_BYTES, MIN_CONFIGURED_PAYLOAD_BYTES, MAX_CONFIGURED_PAYLOAD_BYTES, PAYLOAD_LIMIT_ERROR_CODE, RESOURCE_BUDGET_ERROR_CODE, DEFAULT_SANDBOX_CWD, DEFAULT_SANDBOX_HOME, DEFAULT_SANDBOX_TMPDIR, PayloadLimitError, normalizePayloadLimit, getUtf8ByteLength, getBase64EncodedByteLength, assertPayloadByteLength, assertTextPayloadSize, createBudgetState, checkBridgeBudget, parseJsonWithLimit, getExecutionTimeoutMs, getTimingMitigation, polyfillCodeCache, polyfillNamedExportsCache, hostBuiltinNamedExportsCache, hostRequire, isValidExportName, getHostBuiltinNamedExports, } from "@secure-exec/nodejs/internal/isolate-bootstrap";
@@ -1,2 +0,0 @@
1
- export { ModuleAccessFileSystem } from "@secure-exec/nodejs/internal/module-access";
2
- export type { ModuleAccessOptions } from "@secure-exec/nodejs/internal/module-access";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs — canonical source is packages/nodejs/src/module-access.ts
2
- export { ModuleAccessFileSystem } from "@secure-exec/nodejs/internal/module-access";
@@ -1 +0,0 @@
1
- export { getNearestPackageType, getModuleFormat, shouldRunAsESM, resolveReferrerDirectory, resolveESMPath, } from "@secure-exec/nodejs/internal/module-resolver";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs — canonical source is packages/nodejs/src/module-resolver.ts
2
- export { getNearestPackageType, getModuleFormat, shouldRunAsESM, resolveReferrerDirectory, resolveESMPath, } from "@secure-exec/nodejs/internal/module-resolver";
@@ -1,2 +0,0 @@
1
- export type { ResolutionCache } from "@secure-exec/core";
2
- export { createResolutionCache, resolveModule, loadFile, bundlePackage, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { createResolutionCache, resolveModule, loadFile, bundlePackage, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { bundlePolyfill, getAvailableStdlib, hasPolyfill, prebundleAllPolyfills, } from "@secure-exec/nodejs/internal/polyfills";
package/dist/polyfills.js DELETED
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/nodejs — canonical source is packages/nodejs/src/polyfills.ts
2
- export { bundlePolyfill, getAvailableStdlib, hasPolyfill, prebundleAllPolyfills, } from "@secure-exec/nodejs/internal/polyfills";
@@ -1 +0,0 @@
1
- export type { DriverRuntimeConfig, NodeRuntimeDriver, NodeRuntimeDriverFactory, PythonRuntimeDriver, PythonRuntimeDriverFactory, ResourceBudgets, RuntimeDriver, RuntimeDriverFactory, RuntimeDriverOptions, SharedRuntimeDriver, SystemDriver, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export type { ExecOptions, ExecResult, ExecutionStatus, OSConfig, ProcessConfig, PythonRunOptions, PythonRunResult, RunResult, StdioChannel, StdioEvent, StdioHook, TimingMitigation, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export type { BridgeApplyRef, BridgeApplySyncPromiseRef, BridgeApplySyncRef, BridgeGlobalKey, ChildProcessKillBridgeRef, ChildProcessSpawnStartBridgeRef, ChildProcessSpawnSyncBridgeRef, ChildProcessStdinCloseBridgeRef, ChildProcessStdinWriteBridgeRef, CryptoRandomFillBridgeRef, CryptoRandomUuidBridgeRef, DynamicImportBridgeRef, FsChmodBridgeRef, FsChownBridgeRef, FsExistsBridgeRef, FsFacadeBridge, FsLinkBridgeRef, FsLstatBridgeRef, FsMkdirBridgeRef, FsReadDirBridgeRef, FsReadFileBinaryBridgeRef, FsReadFileBridgeRef, FsReadlinkBridgeRef, FsRenameBridgeRef, FsRmdirBridgeRef, FsStatBridgeRef, FsSymlinkBridgeRef, FsTruncateBridgeRef, FsUnlinkBridgeRef, FsUtimesBridgeRef, FsWriteFileBinaryBridgeRef, FsWriteFileBridgeRef, HostBridgeGlobalKey, LoadFileBridgeRef, LoadPolyfillBridgeRef, ModuleCacheBridgeRecord, NetworkDnsLookupRawBridgeRef, NetworkFetchRawBridgeRef, NetworkHttpRequestRawBridgeRef, NetworkHttpServerCloseRawBridgeRef, NetworkHttpServerListenRawBridgeRef, UpgradeSocketWriteRawBridgeRef, UpgradeSocketEndRawBridgeRef, UpgradeSocketDestroyRawBridgeRef, ProcessErrorBridgeRef, ProcessLogBridgeRef, RegisterHandleBridgeFn, RequireFromBridgeFn, ResolveModuleBridgeRef, RuntimeBridgeGlobalKey, ScheduleTimerBridgeRef, UnregisterHandleBridgeFn, ValueOf, } from "@secure-exec/core";
2
- export { BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEYS, RUNTIME_BRIDGE_GLOBAL_KEY_LIST, RUNTIME_BRIDGE_GLOBAL_KEYS, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEYS, RUNTIME_BRIDGE_GLOBAL_KEY_LIST, RUNTIME_BRIDGE_GLOBAL_KEYS, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- export type { ConsoleSerializationBudget } from "@secure-exec/core";
2
- export { DEFAULT_CONSOLE_SERIALIZATION_BUDGET, formatConsoleArgs, getConsoleSetupCode, safeStringifyConsoleValue, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { DEFAULT_CONSOLE_SERIALIZATION_BUDGET, formatConsoleArgs, getConsoleSetupCode, safeStringifyConsoleValue, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- export type { SystemError } from "@secure-exec/core";
2
- export { createEaccesError, createEnosysError, createSystemError, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { createEaccesError, createEnosysError, createSystemError, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { extractCjsNamedExports, extractDynamicImportSpecifiers, isESM, transformDynamicImport, wrapCJSForESM, wrapCJSForESMWithModulePath, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core
2
- export { extractCjsNamedExports, extractDynamicImportSpecifiers, isESM, transformDynamicImport, wrapCJSForESM, wrapCJSForESMWithModulePath, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- export type { CustomGlobalClassification, CustomGlobalInventoryEntry, } from "@secure-exec/core";
2
- export { exposeCustomGlobal, exposeGlobalBinding, exposeMutableRuntimeStateGlobal, HARDENED_NODE_CUSTOM_GLOBALS, ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE, MUTABLE_NODE_CUSTOM_GLOBALS, NODE_CUSTOM_GLOBAL_INVENTORY, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { exposeCustomGlobal, exposeGlobalBinding, exposeMutableRuntimeStateGlobal, HARDENED_NODE_CUSTOM_GLOBALS, ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE, MUTABLE_NODE_CUSTOM_GLOBALS, NODE_CUSTOM_GLOBAL_INVENTORY, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { createInMemoryFileSystem } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core
2
- export { createInMemoryFileSystem } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createCommandExecutorStub, createFsStub, createNetworkStub, envAccessAllowed, filterEnv, wrapCommandExecutor, wrapFileSystem, wrapNetworkAdapter, } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core
2
- export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createCommandExecutorStub, createFsStub, createNetworkStub, envAccessAllowed, filterEnv, wrapCommandExecutor, wrapFileSystem, wrapNetworkAdapter, } from "@secure-exec/core";
@@ -1 +0,0 @@
1
- export { getRequireSetupCode } from "@secure-exec/core";
@@ -1,2 +0,0 @@
1
- // Re-exported from @secure-exec/core
2
- export { getRequireSetupCode } from "@secure-exec/core";
package/dist/types.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export type { ChildProcessAccessRequest, EnvAccessRequest, FsAccessRequest, NetworkAccessRequest, PermissionCheck, PermissionDecision, Permissions, VirtualDirEntry, VirtualFileSystem, VirtualStat, } from "@secure-exec/core";
2
- export type { CommandExecutor, NetworkAdapter, NetworkServerAddress, NetworkServerListenOptions, NetworkServerRequest, NetworkServerResponse, SpawnedProcess, } from "@secure-exec/core";
3
- export type { DriverRuntimeConfig, NodeRuntimeDriver, NodeRuntimeDriverFactory, PythonRuntimeDriver, PythonRuntimeDriverFactory, RuntimeDriver, RuntimeDriverFactory, RuntimeDriverOptions, SharedRuntimeDriver, SystemDriver, } from "@secure-exec/core";
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};