@secure-exec/sandbox 0.0.0-split-runtime-preview.7b0dded

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.
@@ -0,0 +1,2 @@
1
+ export type { SandboxFsOptions, SandboxMountPluginConfig, } from "./mount.js";
2
+ export { createSandboxFs } from "./mount.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createSandboxFs } from "./mount.js";
@@ -0,0 +1,27 @@
1
+ import type { MountConfigJsonObject, NativeMountPluginDescriptor } from "@secure-exec/core/descriptors";
2
+ import type { SandboxAgent } from "sandbox-agent";
3
+ export interface SandboxFsOptions {
4
+ /** A connected SandboxAgent client instance. */
5
+ client: SandboxAgent;
6
+ /** Base path to scope all operations under. Defaults to "/". */
7
+ basePath?: string;
8
+ /** Per-request timeout for sandbox-agent HTTP calls. */
9
+ timeoutMs?: number;
10
+ /** Maximum file size allowed for buffered pread/truncate fallbacks. */
11
+ maxFullReadBytes?: number;
12
+ }
13
+ export type SandboxMountPluginConfig = MountConfigJsonObject & {
14
+ baseUrl: string;
15
+ token?: string;
16
+ headers?: Record<string, string>;
17
+ basePath?: string;
18
+ timeoutMs?: number;
19
+ maxFullReadBytes?: number;
20
+ };
21
+ /**
22
+ * Create a declarative sandbox-agent mount plugin descriptor.
23
+ *
24
+ * This keeps the legacy helper name while routing first-party sandbox mounts
25
+ * through the native `sandbox_agent` plugin instead of a JS VFS backend.
26
+ */
27
+ export declare function createSandboxFs(options: SandboxFsOptions): NativeMountPluginDescriptor<SandboxMountPluginConfig>;
package/dist/mount.js ADDED
@@ -0,0 +1,45 @@
1
+ function normalizeHeaders(headers) {
2
+ if (!headers) {
3
+ return undefined;
4
+ }
5
+ if (headers instanceof Headers) {
6
+ return Object.fromEntries(headers.entries());
7
+ }
8
+ if (Array.isArray(headers)) {
9
+ return Object.fromEntries(headers);
10
+ }
11
+ return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
12
+ }
13
+ function getSerializableClientConfig(client) {
14
+ const serializable = client;
15
+ const baseUrl = serializable.baseUrl?.trim().replace(/\/+$/, "");
16
+ if (!baseUrl) {
17
+ throw new Error("SandboxAgent client does not expose a serializable baseUrl; connect with a standard sandbox-agent client instance");
18
+ }
19
+ return {
20
+ baseUrl,
21
+ ...(serializable.token ? { token: serializable.token } : {}),
22
+ ...(serializable.defaultHeaders
23
+ ? { headers: normalizeHeaders(serializable.defaultHeaders) }
24
+ : {}),
25
+ };
26
+ }
27
+ /**
28
+ * Create a declarative sandbox-agent mount plugin descriptor.
29
+ *
30
+ * This keeps the legacy helper name while routing first-party sandbox mounts
31
+ * through the native `sandbox_agent` plugin instead of a JS VFS backend.
32
+ */
33
+ export function createSandboxFs(options) {
34
+ return {
35
+ id: "sandbox_agent",
36
+ config: {
37
+ ...getSerializableClientConfig(options.client),
38
+ ...(options.basePath ? { basePath: options.basePath } : {}),
39
+ ...(options.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}),
40
+ ...(options.maxFullReadBytes != null
41
+ ? { maxFullReadBytes: options.maxFullReadBytes }
42
+ : {}),
43
+ },
44
+ };
45
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@secure-exec/sandbox",
3
+ "version": "0.0.0-split-runtime-preview.7b0dded",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./mount": {
18
+ "types": "./dist/mount.d.ts",
19
+ "import": "./dist/mount.js",
20
+ "default": "./dist/mount.js"
21
+ }
22
+ },
23
+ "scripts": {
24
+ "check-types": "tsc --noEmit",
25
+ "build": "tsc",
26
+ "test": "vitest run"
27
+ },
28
+ "dependencies": {
29
+ "@secure-exec/core": "0.0.0-split-runtime-preview.7b0dded",
30
+ "sandbox-agent": "^0.4.2"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.10.2",
34
+ "typescript": "^5.7.2",
35
+ "vitest": "^2.1.8"
36
+ }
37
+ }