@rlemaigre/sbx 0.1.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.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/api.d.ts +91 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +216 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +144 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +49 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +21 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/run.d.ts +9 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +49 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/undeploy.d.ts +6 -0
- package/dist/commands/undeploy.d.ts.map +1 -0
- package/dist/commands/undeploy.js +28 -0
- package/dist/commands/undeploy.js.map +1 -0
- package/dist/config.d.ts +99 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +165 -0
- package/dist/config.js.map +1 -0
- package/dist/lib/config.d.ts +51 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +47 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/network.d.ts +18 -0
- package/dist/lib/network.d.ts.map +1 -0
- package/dist/lib/network.js +31 -0
- package/dist/lib/network.js.map +1 -0
- package/dist/lib/paths.d.ts +12 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +21 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/vfs.d.ts +15 -0
- package/dist/lib/vfs.d.ts.map +1 -0
- package/dist/lib/vfs.js +44 -0
- package/dist/lib/vfs.js.map +1 -0
- package/dist/templates/config.template.yaml +47 -0
- package/dist/templates/shim.template.cmd +2 -0
- package/dist/templates/shim.template.sh +2 -0
- package/package.json +43 -0
package/dist/lib/vfs.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VFS provider building from config mounts and shadow rules.
|
|
4
|
+
*
|
|
5
|
+
* Builds the RealFS → Readonly → Shadow mount chain per SPECS §2.1.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildVFSProviders = buildVFSProviders;
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const minimatch_1 = require("minimatch");
|
|
11
|
+
const gondolin_1 = require("@earendil-works/gondolin");
|
|
12
|
+
function expandTilde(path) {
|
|
13
|
+
if (!path.startsWith("~"))
|
|
14
|
+
return path;
|
|
15
|
+
const home = process.env.HOME;
|
|
16
|
+
if (!home)
|
|
17
|
+
throw new Error("HOME environment variable not set");
|
|
18
|
+
return (0, node_path_1.resolve)(home, path.slice(1));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build VFS providers from config mounts and shadow rules.
|
|
22
|
+
*
|
|
23
|
+
* Mount chain: RealFS → Readonly (if readOnly) → Shadow (if shadow paths).
|
|
24
|
+
* Global shadow is merged with per-mount shadow.
|
|
25
|
+
*/
|
|
26
|
+
function buildVFSProviders(config) {
|
|
27
|
+
const mounts = {};
|
|
28
|
+
const globalShadow = config.shadow ?? [];
|
|
29
|
+
for (const mount of config.mounts ?? []) {
|
|
30
|
+
let provider = new gondolin_1.RealFSProvider(expandTilde(mount.hostPath));
|
|
31
|
+
if (mount.readOnly) {
|
|
32
|
+
provider = new gondolin_1.ReadonlyProvider(provider);
|
|
33
|
+
}
|
|
34
|
+
const shadowPaths = [...globalShadow, ...(mount.shadow ?? [])];
|
|
35
|
+
if (shadowPaths.length > 0) {
|
|
36
|
+
provider = new gondolin_1.ShadowProvider(provider, {
|
|
37
|
+
shouldShadow: (info) => shadowPaths.some((p) => (0, minimatch_1.minimatch)(info.path, `/${p}`, { dot: true })),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
mounts[mount.guestPath] = provider;
|
|
41
|
+
}
|
|
42
|
+
return mounts;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=vfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vfs.js","sourceRoot":"","sources":["../../src/lib/vfs.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA2BH,8CA6BC;AAtDD,yCAAoC;AACpC,yCAAsC;AAEtC,uDAIkC;AAKlC,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAChE,OAAO,IAAA,mBAAO,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,MAAsB;IAEtB,MAAM,MAAM,GAAoC,EAAE,CAAC;IACnD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAEzC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACxC,IAAI,QAAQ,GAAoB,IAAI,yBAAc,CAChD,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC5B,CAAC;QAEF,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,QAAQ,GAAG,IAAI,2BAAgB,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,WAAW,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/D,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,QAAQ,GAAG,IAAI,yBAAc,CAAC,QAAQ,EAAE;gBACtC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,IAAA,qBAAS,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7C;aACJ,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Sandboxed Coding Assistant — example config
|
|
2
|
+
# Edit this file and run `sbx deploy <name>` to install the shim.
|
|
3
|
+
|
|
4
|
+
# Command to run inside the VM (required)
|
|
5
|
+
cmd: pi
|
|
6
|
+
|
|
7
|
+
# Shell commands to run on first boot
|
|
8
|
+
setup:
|
|
9
|
+
- apk add --no-cache nodejs npm git ripgrep
|
|
10
|
+
|
|
11
|
+
# Outbound network policy
|
|
12
|
+
network:
|
|
13
|
+
# Allowed hostnames for HTTP/TLS egress (wildcards supported)
|
|
14
|
+
allowedHosts:
|
|
15
|
+
- api.anthropic.com
|
|
16
|
+
- "*.github.com"
|
|
17
|
+
# Scoped exceptions for internal hosts (internal ranges are always blocked)
|
|
18
|
+
allowedInternalHosts: []
|
|
19
|
+
|
|
20
|
+
# Host filesystem mounts
|
|
21
|
+
mounts:
|
|
22
|
+
- hostPath: "/home/user/project"
|
|
23
|
+
guestPath: "/workspace"
|
|
24
|
+
readOnly: false
|
|
25
|
+
# Per-mount shadow rules (added to global shadow)
|
|
26
|
+
shadow:
|
|
27
|
+
- ".git"
|
|
28
|
+
|
|
29
|
+
# Global files/directories to shadow (hide from guest, relative to each mount)
|
|
30
|
+
shadow:
|
|
31
|
+
- ".env"
|
|
32
|
+
- ".npmrc"
|
|
33
|
+
- ".aws/"
|
|
34
|
+
|
|
35
|
+
# Environment variables to set in the guest
|
|
36
|
+
env:
|
|
37
|
+
NODE_ENV: production
|
|
38
|
+
|
|
39
|
+
# Secrets to inject via host-side HTTP interception
|
|
40
|
+
# Key name maps to host env var of the same name (read at runtime)
|
|
41
|
+
secrets:
|
|
42
|
+
ANTHROPIC_API_KEY:
|
|
43
|
+
hosts:
|
|
44
|
+
- api.anthropic.com
|
|
45
|
+
GITHUB_TOKEN:
|
|
46
|
+
hosts:
|
|
47
|
+
- "*.github.com"
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rlemaigre/sbx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sandboxed AI Agents — TypeScript API and CLI for Gondolin micro-VMs",
|
|
5
|
+
"main": "dist/api.js",
|
|
6
|
+
"types": "dist/api.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sbx": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/rlemaigre/sbx.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"sandbox",
|
|
20
|
+
"vm",
|
|
21
|
+
"gondolin",
|
|
22
|
+
"micro-vm",
|
|
23
|
+
"ai-agent"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc && mkdir -p dist/templates && cp src/templates/* dist/templates/",
|
|
27
|
+
"prepublishOnly": "tsc && mkdir -p dist/templates && cp src/templates/* dist/templates/",
|
|
28
|
+
"test": "tsx --test --test-concurrency=1 test/*.test.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@earendil-works/gondolin": "^0.12.0",
|
|
32
|
+
"commander": "^15.0.0",
|
|
33
|
+
"js-yaml": "^4.2.0",
|
|
34
|
+
"minimatch": "^10.2.5",
|
|
35
|
+
"tiny-invariant": "^1.3.3"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/js-yaml": "^4.0.9",
|
|
39
|
+
"@types/node": "^24.13.1",
|
|
40
|
+
"tsx": "^4.22.4",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
42
|
+
}
|
|
43
|
+
}
|