@intentic/sandbox-run 1.176.3
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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/fly.d.ts +40 -0
- package/dist/fly.d.ts.map +1 -0
- package/dist/fly.js +21 -0
- package/dist/fly.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/quote.d.ts +6 -0
- package/dist/quote.d.ts.map +1 -0
- package/dist/quote.js +18 -0
- package/dist/quote.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artur Kurowski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @intentic/sandbox-run
|
|
2
|
+
|
|
3
|
+
The sandbox container's run contract — every path that creates a sandbox composes its `docker run` from here.
|
|
4
|
+
|
|
5
|
+
Names, capability posture, the environment allowlist, runtime directives, and the emitter that turns all of it
|
|
6
|
+
into a command line. There are several ways a sandbox comes into existence (the CLI, the daemon, the desktop
|
|
7
|
+
app); this package is why they cannot disagree about what one is.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- Define the container's identity: its name, image, labels and volumes.
|
|
12
|
+
- Define its posture: which capabilities it gets, and which it is denied.
|
|
13
|
+
- Define the environment allowlist — what is allowed to cross into the box.
|
|
14
|
+
- Emit the `docker run` invocation, correctly quoted.
|
|
15
|
+
|
|
16
|
+
## Key files
|
|
17
|
+
|
|
18
|
+
- [src/index.ts](src/index.ts) — the contract and the docker-run emitter; the surface every docker-shaped flow uses.
|
|
19
|
+
- [src/fly.ts](src/fly.ts) — the hosted flavor: the same contract emitted as a Fly Machine config (one VM per
|
|
20
|
+
sandbox, one volume standing in for the three docker ones, cloudflared in-box behind the `SANDBOX_VM` switch).
|
|
21
|
+
- [src/quote.ts](src/quote.ts) — shell quoting, which is the part that is easy to get subtly wrong.
|
|
22
|
+
- [src/quote-contract.integration.test.ts](src/quote-contract.integration.test.ts) — the emitted command run for
|
|
23
|
+
real, because a quoting bug is invisible to a unit test that only compares strings.
|
|
24
|
+
|
|
25
|
+
## How it fits
|
|
26
|
+
|
|
27
|
+
Consumed by every creation path. It depends on nothing that would stop a browser importing it, which is
|
|
28
|
+
deliberate: the UI that offers to create a sandbox and the daemon that creates one describe it identically.
|
|
29
|
+
|
|
30
|
+
## Conventions & gotchas
|
|
31
|
+
|
|
32
|
+
- The allowlist is a floor, not a suggestion. Anything not named does not cross into the container, and widening
|
|
33
|
+
it is a security decision rather than a convenience one.
|
package/dist/fly.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const FLY_VOLUME_PATH = "/data";
|
|
2
|
+
export declare const FLY_VOLUME_LAYOUT: {
|
|
3
|
+
readonly workspace: "/data/work";
|
|
4
|
+
readonly history: "/data/history";
|
|
5
|
+
readonly docker: "/data/docker";
|
|
6
|
+
};
|
|
7
|
+
export interface FlyMachineRun {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly image: string;
|
|
10
|
+
readonly baseImage: string;
|
|
11
|
+
readonly guest: {
|
|
12
|
+
readonly cpus: number;
|
|
13
|
+
readonly memoryMb: number;
|
|
14
|
+
};
|
|
15
|
+
readonly volumeId: string;
|
|
16
|
+
readonly env?: readonly (readonly [string, string])[];
|
|
17
|
+
}
|
|
18
|
+
export interface FlyMachineConfig {
|
|
19
|
+
readonly image: string;
|
|
20
|
+
readonly guest: {
|
|
21
|
+
readonly cpu_kind: "shared";
|
|
22
|
+
readonly cpus: number;
|
|
23
|
+
readonly memory_mb: number;
|
|
24
|
+
};
|
|
25
|
+
readonly env: Record<string, string>;
|
|
26
|
+
readonly mounts: readonly {
|
|
27
|
+
readonly volume: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
}[];
|
|
30
|
+
readonly restart: {
|
|
31
|
+
readonly policy: "on-failure";
|
|
32
|
+
readonly max_retries: number;
|
|
33
|
+
};
|
|
34
|
+
readonly auto_destroy: false;
|
|
35
|
+
readonly init?: {
|
|
36
|
+
readonly exec: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare const flyMachineConfig: (run: FlyMachineRun) => FlyMachineConfig;
|
|
40
|
+
//# sourceMappingURL=fly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fly.d.ts","sourceRoot":"","sources":["../src/fly.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,eAAe,UAAU,C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,MAAM,EAAE,CAAA;KAAE,CAAC;CACxD;AAED,eAAO,MAAM,gBAAgB,QAAS,aAAa,KAAG,gBAepD,CAAC"}
|
package/dist/fly.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const FLY_VOLUME_PATH = "/data";
|
|
2
|
+
export const FLY_VOLUME_LAYOUT = {
|
|
3
|
+
workspace: `${FLY_VOLUME_PATH}/work`,
|
|
4
|
+
history: `${FLY_VOLUME_PATH}/history`,
|
|
5
|
+
docker: `${FLY_VOLUME_PATH}/docker`,
|
|
6
|
+
};
|
|
7
|
+
export const flyMachineConfig = (run) => ({
|
|
8
|
+
image: run.image,
|
|
9
|
+
guest: { cpu_kind: "shared", cpus: run.guest.cpus, memory_mb: run.guest.memoryMb },
|
|
10
|
+
env: Object.fromEntries([
|
|
11
|
+
["SANDBOX_NAME", run.name],
|
|
12
|
+
["SANDBOX_IMAGE", run.image],
|
|
13
|
+
["SANDBOX_BASE_IMAGE", run.baseImage],
|
|
14
|
+
["SANDBOX_VM", "1"],
|
|
15
|
+
...(run.env ?? []).filter(([, value]) => value !== ""),
|
|
16
|
+
]),
|
|
17
|
+
mounts: [{ volume: run.volumeId, path: FLY_VOLUME_PATH }],
|
|
18
|
+
restart: { policy: "on-failure", max_retries: 3 },
|
|
19
|
+
auto_destroy: false,
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=fly.js.map
|
package/dist/fly.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fly.js","sourceRoot":"","sources":["../src/fly.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,SAAS,EAAE,GAAG,eAAe,OAAO;IACpC,OAAO,EAAE,GAAG,eAAe,UAAU;IACrC,MAAM,EAAE,GAAG,eAAe,SAAS;CAC7B,CAAC;AAoCX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAkB,EAAoB,EAAE,CAAC,CAAC;IACvE,KAAK,EAAE,GAAG,CAAC,KAAK;IAChB,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE;IAClF,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC;QACpB,CAAC,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC;QAC1B,CAAC,eAAe,EAAE,GAAG,CAAC,KAAK,CAAC;QAC5B,CAAC,oBAAoB,EAAE,GAAG,CAAC,SAAS,CAAC;QAGrC,CAAC,YAAY,EAAE,GAAG,CAAC;QACnB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;KACzD,CAAC;IACF,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IACzD,OAAO,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,EAAE;IACjD,YAAY,EAAE,KAAK;CACtB,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare const ORIGIN_HOST = "intentic-sandbox-workspace";
|
|
2
|
+
export interface SandboxNames {
|
|
3
|
+
readonly container: string;
|
|
4
|
+
readonly tunnelContainer: string;
|
|
5
|
+
readonly workspaceVolume: string;
|
|
6
|
+
readonly historyVolume: string;
|
|
7
|
+
readonly dockerVolume: string;
|
|
8
|
+
readonly network: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sandboxNames: (slug: string) => SandboxNames;
|
|
11
|
+
export declare const SANDBOX_CAPABILITIES: readonly ["SYS_ADMIN", "SYS_PTRACE"];
|
|
12
|
+
export declare const RUNTIME_DIRECTIVE_PREFIX = "# intentic:runtime ";
|
|
13
|
+
export declare const RUNTIME_DIRECTIVES: readonly ["--device=/dev/net/tun", "--cap-add=NET_ADMIN", "--privileged", "--gpus=all"];
|
|
14
|
+
export interface OptionalDirective {
|
|
15
|
+
readonly token: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly env: string;
|
|
18
|
+
readonly probe: {
|
|
19
|
+
readonly kind: "runtime";
|
|
20
|
+
readonly name: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "device";
|
|
23
|
+
readonly path: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const OPTIONAL_DIRECTIVES: readonly OptionalDirective[];
|
|
27
|
+
export declare const optionalDirective: (token: string) => OptionalDirective | undefined;
|
|
28
|
+
export declare const runtimeDirectivesOf: (overlay: string) => string[];
|
|
29
|
+
export declare const REPLAY_ENV: readonly ["WORKSPACE_ROOT", "HISTORY_ROOT", "AGENT_AUTH_DIR", "SANDBOX_HOST", "SANDBOX_PORT", "SANDBOX_NAME", "PREVIEW_PORT", "GOOGLE_CLIENT_ID", "CONNECT_TOKEN", "OWNER_EMAIL", "WEB_ORIGIN", "SANDBOX_PUBLIC_URL", "PLATFORM_URL", "ZROK_TOKEN", "ZROK_API", "ZROK_NAMESPACE", "CLOUDFLARE_API_TOKEN", "HOST_SSH_KEY", "SELF_HOST_USER", "SYNC_PAIR_TOKEN", "HOST_PAIR_TOKEN", "HOST_PLATFORM", "HOST_LABEL", "SELF_HOST_ADDRESS", "SELF_HOST_VIA"];
|
|
30
|
+
export declare const parseNulEnv: (dump: string) => [string, string][];
|
|
31
|
+
export declare const replayableEnv: (pairs: readonly (readonly [string, string])[]) => [string, string][];
|
|
32
|
+
export declare const HEALTH: {
|
|
33
|
+
readonly url: "http://localhost:8787/health";
|
|
34
|
+
readonly attempts: 15;
|
|
35
|
+
readonly intervalSeconds: 2;
|
|
36
|
+
};
|
|
37
|
+
export declare const localDaemonPort: (sandboxId: string) => number;
|
|
38
|
+
export declare const localDaemonUrl: (sandboxId: string, zone: string | undefined) => string | undefined;
|
|
39
|
+
export declare const localDaemonUrlInsecure: (sandboxId: string) => string;
|
|
40
|
+
export interface SandboxRun {
|
|
41
|
+
readonly names: SandboxNames;
|
|
42
|
+
readonly image: string;
|
|
43
|
+
readonly baseImage: string;
|
|
44
|
+
readonly environmentHash?: string;
|
|
45
|
+
readonly channel?: string;
|
|
46
|
+
readonly previousImage?: string;
|
|
47
|
+
readonly env?: readonly (readonly [string, string])[];
|
|
48
|
+
readonly runtime?: readonly string[];
|
|
49
|
+
readonly mounts?: readonly string[];
|
|
50
|
+
readonly ports?: readonly string[];
|
|
51
|
+
readonly labels?: readonly string[];
|
|
52
|
+
readonly dns?: readonly string[];
|
|
53
|
+
readonly sandboxId?: string;
|
|
54
|
+
readonly localPublish?: boolean;
|
|
55
|
+
readonly unsupported?: readonly string[];
|
|
56
|
+
readonly init?: boolean;
|
|
57
|
+
readonly alias?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare const sandboxRunArgv: (run: SandboxRun) => string[];
|
|
60
|
+
export declare const sandboxRunCommand: (run: SandboxRun) => string;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AAExD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,YAAY,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AAE,MAAM,CAAC;IAG5B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAUhC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAGzC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,eAAO,MAAM,cAAc,QAAS,UAAU,KAAG,MAAM,EAsDtD,CAAC;AAIF,eAAO,MAAM,iBAAiB,QAAS,UAAU,KAAG,MAAsE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { DAEMON_PORT, LOCAL_PORT } from "@intentic/constants";
|
|
2
|
+
import { shellQuote } from "./quote.js";
|
|
3
|
+
export const ORIGIN_HOST = "intentic-sandbox-workspace";
|
|
4
|
+
export const sandboxNames = (slug) => ({
|
|
5
|
+
container: `intentic-sandbox-${slug}`,
|
|
6
|
+
tunnelContainer: `intentic-sandbox-tunnel-${slug}`,
|
|
7
|
+
workspaceVolume: `intentic-workspace-${slug}`,
|
|
8
|
+
historyVolume: `intentic-history-${slug}`,
|
|
9
|
+
dockerVolume: `intentic-docker-${slug}`,
|
|
10
|
+
network: `intentic-workspace-${slug}`,
|
|
11
|
+
});
|
|
12
|
+
export const SANDBOX_CAPABILITIES = ["SYS_ADMIN", "SYS_PTRACE"];
|
|
13
|
+
export const RUNTIME_DIRECTIVE_PREFIX = "# intentic:runtime ";
|
|
14
|
+
export const RUNTIME_DIRECTIVES = ["--device=/dev/net/tun", "--cap-add=NET_ADMIN", "--privileged", "--gpus=all"];
|
|
15
|
+
export const OPTIONAL_DIRECTIVES = [
|
|
16
|
+
{
|
|
17
|
+
token: "--gpus=all",
|
|
18
|
+
name: "NVIDIA GPU access",
|
|
19
|
+
env: "SANDBOX_GPU",
|
|
20
|
+
probe: { kind: "runtime", name: "nvidia" },
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
export const optionalDirective = (token) => OPTIONAL_DIRECTIVES.find((entry) => entry.token === token);
|
|
24
|
+
export const runtimeDirectivesOf = (overlay) => {
|
|
25
|
+
const tokens = [];
|
|
26
|
+
for (const line of overlay.split("\n")) {
|
|
27
|
+
if (!line.startsWith(RUNTIME_DIRECTIVE_PREFIX)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
for (const token of line.slice(RUNTIME_DIRECTIVE_PREFIX.length).trim().split(/\s+/)) {
|
|
31
|
+
if (!RUNTIME_DIRECTIVES.includes(token)) {
|
|
32
|
+
throw new Error(`unsupported runtime directive '${token}' in the approved overlay`);
|
|
33
|
+
}
|
|
34
|
+
tokens.push(token);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return tokens;
|
|
38
|
+
};
|
|
39
|
+
export const REPLAY_ENV = [
|
|
40
|
+
"WORKSPACE_ROOT",
|
|
41
|
+
"HISTORY_ROOT",
|
|
42
|
+
"AGENT_AUTH_DIR",
|
|
43
|
+
"SANDBOX_HOST",
|
|
44
|
+
"SANDBOX_PORT",
|
|
45
|
+
"SANDBOX_NAME",
|
|
46
|
+
"PREVIEW_PORT",
|
|
47
|
+
"GOOGLE_CLIENT_ID",
|
|
48
|
+
"CONNECT_TOKEN",
|
|
49
|
+
"OWNER_EMAIL",
|
|
50
|
+
"WEB_ORIGIN",
|
|
51
|
+
"SANDBOX_PUBLIC_URL",
|
|
52
|
+
"PLATFORM_URL",
|
|
53
|
+
"ZROK_TOKEN",
|
|
54
|
+
"ZROK_API",
|
|
55
|
+
"ZROK_NAMESPACE",
|
|
56
|
+
"CLOUDFLARE_API_TOKEN",
|
|
57
|
+
"HOST_SSH_KEY",
|
|
58
|
+
"SELF_HOST_USER",
|
|
59
|
+
"SYNC_PAIR_TOKEN",
|
|
60
|
+
"HOST_PAIR_TOKEN",
|
|
61
|
+
"HOST_PLATFORM",
|
|
62
|
+
"HOST_LABEL",
|
|
63
|
+
"SELF_HOST_ADDRESS",
|
|
64
|
+
"SELF_HOST_VIA",
|
|
65
|
+
];
|
|
66
|
+
export const parseNulEnv = (dump) => dump
|
|
67
|
+
.split("\0")
|
|
68
|
+
.filter((entry) => entry.includes("="))
|
|
69
|
+
.map((entry) => {
|
|
70
|
+
const eq = entry.indexOf("=");
|
|
71
|
+
return [entry.slice(0, eq), entry.slice(eq + 1)];
|
|
72
|
+
});
|
|
73
|
+
export const replayableEnv = (pairs) => REPLAY_ENV.flatMap((name) => {
|
|
74
|
+
const value = pairs.find(([key]) => key === name)?.[1];
|
|
75
|
+
return value === undefined || value === "" ? [] : [[name, value]];
|
|
76
|
+
});
|
|
77
|
+
export const HEALTH = { url: `http://localhost:${DAEMON_PORT}/health`, attempts: 15, intervalSeconds: 2 };
|
|
78
|
+
const LOCAL_PORT_BASE = 28000;
|
|
79
|
+
const LOCAL_PORT_SPAN = 4000;
|
|
80
|
+
export const localDaemonPort = (sandboxId) => LOCAL_PORT_BASE + (Number.parseInt(sandboxId.slice(0, 6), 16) % LOCAL_PORT_SPAN);
|
|
81
|
+
export const localDaemonUrl = (sandboxId, zone) => zone === undefined || zone === "" ? undefined : `https://local-${sandboxId}.${zone}:${localDaemonPort(sandboxId)}`;
|
|
82
|
+
export const localDaemonUrlInsecure = (sandboxId) => `http://127.0.0.1:${localDaemonPort(sandboxId)}`;
|
|
83
|
+
export const sandboxRunArgv = (run) => {
|
|
84
|
+
const asked = OPTIONAL_DIRECTIVES.filter((entry) => (run.runtime ?? []).includes(entry.token));
|
|
85
|
+
const dropped = new Set(asked.filter((entry) => (run.unsupported ?? []).includes(entry.token)).map((entry) => entry.token));
|
|
86
|
+
return [
|
|
87
|
+
"run",
|
|
88
|
+
"-d",
|
|
89
|
+
...(run.init === false ? [] : ["--init"]),
|
|
90
|
+
"--restart",
|
|
91
|
+
"unless-stopped",
|
|
92
|
+
"--name",
|
|
93
|
+
run.names.container,
|
|
94
|
+
...(run.labels ?? []).flatMap((label) => ["--label", label]),
|
|
95
|
+
"--network",
|
|
96
|
+
run.names.network,
|
|
97
|
+
...(run.alias === false ? [] : ["--network-alias", ORIGIN_HOST]),
|
|
98
|
+
"--add-host",
|
|
99
|
+
"host.docker.internal:host-gateway",
|
|
100
|
+
...(run.dns ?? []).flatMap((server) => ["--dns", server]),
|
|
101
|
+
"--log-opt",
|
|
102
|
+
"max-size=10m",
|
|
103
|
+
"--log-opt",
|
|
104
|
+
"max-file=3",
|
|
105
|
+
...SANDBOX_CAPABILITIES.map((cap) => `--cap-add=${cap}`),
|
|
106
|
+
...(run.runtime ?? []).filter((token) => !dropped.has(token)),
|
|
107
|
+
...(run.ports ?? []).flatMap((port) => ["-p", port]),
|
|
108
|
+
...(run.sandboxId !== undefined && run.localPublish !== false ? ["-p", `127.0.0.1:${localDaemonPort(run.sandboxId)}:${LOCAL_PORT}`] : []),
|
|
109
|
+
"-v",
|
|
110
|
+
`${run.names.workspaceVolume}:/work`,
|
|
111
|
+
"-v",
|
|
112
|
+
`${run.names.historyVolume}:/history`,
|
|
113
|
+
"-v",
|
|
114
|
+
`${run.names.dockerVolume}:/var/lib/docker`,
|
|
115
|
+
...(run.mounts ?? []).flatMap((mount) => ["-v", mount]),
|
|
116
|
+
"-e",
|
|
117
|
+
`SANDBOX_NAME=${run.names.container}`,
|
|
118
|
+
"-e",
|
|
119
|
+
`SANDBOX_IMAGE=${run.image}`,
|
|
120
|
+
"-e",
|
|
121
|
+
`SANDBOX_BASE_IMAGE=${run.baseImage}`,
|
|
122
|
+
...(run.environmentHash === undefined ? [] : ["-e", `SANDBOX_ENVIRONMENT_HASH=${run.environmentHash}`]),
|
|
123
|
+
...(run.channel === undefined ? [] : ["-e", `SANDBOX_CHANNEL=${run.channel}`]),
|
|
124
|
+
...(run.previousImage === undefined ? [] : ["-e", `SANDBOX_PREVIOUS_IMAGE=${run.previousImage}`]),
|
|
125
|
+
...asked.flatMap((entry) => ["-e", `${entry.env}=${dropped.has(entry.token) ? "unsupported" : "all"}`]),
|
|
126
|
+
...(run.env ?? []).flatMap(([name, value]) => ["-e", `${name}=${value}`]),
|
|
127
|
+
run.image,
|
|
128
|
+
];
|
|
129
|
+
};
|
|
130
|
+
export const sandboxRunCommand = (run) => ["docker", ...sandboxRunArgv(run).map(shellQuote)].join(" ");
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA4BxC,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAWxD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAgB,EAAE,CAAC,CAAC;IACzD,SAAS,EAAE,oBAAoB,IAAI,EAAE;IACrC,eAAe,EAAE,2BAA2B,IAAI,EAAE;IAClD,eAAe,EAAE,sBAAsB,IAAI,EAAE;IAC7C,aAAa,EAAE,oBAAoB,IAAI,EAAE;IACzC,YAAY,EAAE,mBAAmB,IAAI,EAAE;IACvC,OAAO,EAAE,sBAAsB,IAAI,EAAE;CACxC,CAAC,CAAC;AAkBH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU,CAAC;AAUzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,uBAAuB,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,CAAU,CAAC;AAwC1H,MAAM,CAAC,MAAM,mBAAmB,GAAiC;IAC7D;QACI,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,mBAAmB;QACzB,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC7C;CACJ,CAAC;AAEF,MA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iB,GAAG,CAAC,GAAe,EAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/quote.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const shellQuote: (word: string) => string;
|
|
2
|
+
export declare const sqlLiteral: (value: string) => string;
|
|
3
|
+
export declare const sqlIdentifier: (name: string) => string;
|
|
4
|
+
export declare const envLine: (key: string, value: string) => string;
|
|
5
|
+
export declare const dockerEnvLine: (key: string, value: string) => string;
|
|
6
|
+
//# sourceMappingURL=quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAA+E,CAAC;AAM1H,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAA4C,CAAC;AASxF,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,MAA2C,CAAC;AA0BzF,eAAO,MAAM,OAAO,QAAS,MAAM,SAAS,MAAM,KAAG,MAMpD,CAAC;AASF,eAAO,MAAM,aAAa,QAAS,MAAM,SAAS,MAAM,KAAG,MAO1D,CAAC"}
|
package/dist/quote.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const PLAIN_WORD = /^[\w@%+=:,./-]+$/;
|
|
2
|
+
export const shellQuote = (word) => (PLAIN_WORD.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`);
|
|
3
|
+
export const sqlLiteral = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
4
|
+
export const sqlIdentifier = (name) => `"${name.replaceAll(`"`, `""`)}"`;
|
|
5
|
+
export const envLine = (key, value) => {
|
|
6
|
+
const delimiter = [`'`, `"`, "`"].find((candidate) => !value.includes(candidate));
|
|
7
|
+
if (delimiter === undefined) {
|
|
8
|
+
throw new Error(`cannot write ${key} to a .env: the value contains all three quote characters, which its parser cannot express`);
|
|
9
|
+
}
|
|
10
|
+
return `${key}=${delimiter}${value}${delimiter}\n`;
|
|
11
|
+
};
|
|
12
|
+
export const dockerEnvLine = (key, value) => {
|
|
13
|
+
if (value.includes("\n")) {
|
|
14
|
+
throw new Error(`cannot write ${key} to a docker --env-file: the value contains a newline, which that file's parser reads as the start of another variable`);
|
|
15
|
+
}
|
|
16
|
+
return `${key}=${value}\n`;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AA+BA,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAKtC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAM1H,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AASxF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AA0BzF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE;IAC1D,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,4FAA4F,CAAC,CAAC;IACrI,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,SAAS,GAAG,KAAK,GAAG,SAAS,IAAI,CAAC;AACvD,CAAC,CAAC;AASF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE;IAChE,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACX,gBAAgB,GAAG,wHAAwH,CAC9I,CAAC;IACN,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;AAC/B,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intentic/sandbox-run",
|
|
3
|
+
"version": "1.176.3",
|
|
4
|
+
"description": "The sandbox container's run contract — names, capability posture, env allowlist, runtime directives, and the docker-run emitter every creation path composes from",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/intentic/intentic.git",
|
|
10
|
+
"directory": "_sandbox/sandbox-run"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"registry": "https://registry.npmjs.org/"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": {
|
|
23
|
+
"@intentic/src": "./src/index.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"@intentic/src": "./src/index.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./fly": {
|
|
32
|
+
"types": "./dist/fly.d.ts",
|
|
33
|
+
"import": {
|
|
34
|
+
"@intentic/src": "./src/fly.ts",
|
|
35
|
+
"default": "./dist/fly.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"@intentic/src": "./src/fly.ts",
|
|
39
|
+
"default": "./dist/fly.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"./quote": {
|
|
43
|
+
"types": "./dist/quote.d.ts",
|
|
44
|
+
"import": {
|
|
45
|
+
"@intentic/src": "./src/quote.ts",
|
|
46
|
+
"default": "./dist/quote.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"@intentic/src": "./src/quote.ts",
|
|
50
|
+
"default": "./dist/quote.js"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"tslib": "2.8.1",
|
|
56
|
+
"@intentic/constants": "1.176.3"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "24.13.2",
|
|
60
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
61
|
+
"vitest": "4.1.10",
|
|
62
|
+
"@intentic/testing": "0.0.0",
|
|
63
|
+
"@intentic/tsconfig": "0.0.0"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsgo",
|
|
67
|
+
"typecheck": "tsgo --noEmit -p tsconfig.test.json",
|
|
68
|
+
"watch": "tsgo --build --watch",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:watch": "vitest"
|
|
71
|
+
}
|
|
72
|
+
}
|