@molecule/api-code-sandbox-docker 1.0.0

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,69 @@
1
+ /**
2
+ * Docker sandbox provider configuration.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Configuration for docker.
8
+ */
9
+ export interface DockerConfig {
10
+ /**
11
+ * Docker unix-socket path. Defaults to `/var/run/docker.sock` (or the
12
+ * `DOCKER_SOCKET_PATH` env var). This is the default transport; it is ignored
13
+ * when a TCP endpoint is selected via `host`/`port` or a `tcp://` `DOCKER_HOST`.
14
+ */
15
+ socketPath?: string;
16
+ /**
17
+ * Connect to a remote/TCP Docker daemon at this host instead of the unix
18
+ * socket. When set, the provider issues all Docker Engine API calls over
19
+ * plain TCP to `host:port` (`port` defaults to 2375) and `socketPath` is
20
+ * ignored. Also honored via `DOCKER_HOST` (`tcp://host:port`). Plain
21
+ * (unencrypted) TCP only — for a TLS-protected daemon (2376) front it with a
22
+ * local socket proxy and point `socketPath` at that.
23
+ */
24
+ host?: string;
25
+ /** TCP port for `host` (default 2375). Ignored unless `host` (or a `tcp://` `DOCKER_HOST`) selects a TCP endpoint. */
26
+ port?: number;
27
+ /** Base image for sandbox containers. Defaults to node:22-slim. Must already be present on the host — the provider never pulls images. */
28
+ baseImage?: string;
29
+ /** Default CPU allocation (cores). */
30
+ defaultCpu?: number;
31
+ /** Default memory allocation (MB). */
32
+ defaultMemoryMB?: number;
33
+ /**
34
+ * Docker network the sandbox containers attach to (sets each container's
35
+ * `NetworkMode`). Overrides the `SANDBOX_DOCKER_NETWORK` env var. Defaults to
36
+ * the ICC-off isolated `molecule-sandbox` network, auto-created on first use so
37
+ * tenants are L2-isolated by default. Setting it to the shared `bridge` gives NO
38
+ * cross-tenant isolation and is refused in production. [C1-1]
39
+ */
40
+ network?: string;
41
+ /** Container label prefix for identification. */
42
+ labelPrefix?: string;
43
+ /** Preview URL template. Use {port} placeholder. */
44
+ previewUrlTemplate?: string;
45
+ }
46
+ /**
47
+ * Container Info interface.
48
+ */
49
+ export interface ContainerInfo {
50
+ id: string;
51
+ name: string;
52
+ status: string;
53
+ ports: Array<{
54
+ host: number;
55
+ container: number;
56
+ }>;
57
+ }
58
+ /**
59
+ * Environment variables the Docker sandbox provider reads.
60
+ */
61
+ export interface ProcessEnv {
62
+ /** Unix-socket path for the Docker daemon (default `/var/run/docker.sock`). Overridden by `config.socketPath`. */
63
+ DOCKER_SOCKET_PATH?: string;
64
+ /** Docker daemon endpoint, docker-client style: `tcp://host:port` or `unix:///path/to/docker.sock`. Overridden by `config.host`/`config.socketPath`. */
65
+ DOCKER_HOST?: string;
66
+ /** Docker network sandbox containers attach to (default `molecule-sandbox`, ICC-off). Overridden by `config.network`. [C1-1] */
67
+ SANDBOX_DOCKER_NETWORK?: string;
68
+ }
69
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sHAAsH;IACtH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0IAA0I;IAC1I,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sCAAsC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kHAAkH;IAClH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,wJAAwJ;IACxJ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gIAAgI;IAChI,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAChC"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Docker sandbox provider configuration.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@molecule/api-code-sandbox-docker",
3
+ "version": "1.0.0",
4
+ "description": "Docker-based code sandbox container provider",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "sandbox",
25
+ "docker",
26
+ "container",
27
+ "code-execution"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "devDependencies": {
31
+ "@molecule/api-bond": "1.0.0",
32
+ "@molecule/api-code-sandbox": "1.0.0",
33
+ "@types/node": "26.1.2",
34
+ "typescript": "6.0.3",
35
+ "vitest": "4.1.10"
36
+ },
37
+ "peerDependencies": {
38
+ "@molecule/api-bond": "^1.0.0",
39
+ "@molecule/api-code-sandbox": "^1.0.0",
40
+ "@molecule/api-i18n": "^1.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "@molecule/api-code-sandbox": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/molecule-dev/molecule.git",
50
+ "directory": "packages/api/bonds/code-sandbox/docker"
51
+ },
52
+ "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/bonds/code-sandbox/docker",
53
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
+ }