@niwa-labs/sandbox 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +21 -2
- package/package.json +15 -4
- package/src/access.ts +642 -0
- package/src/index.ts +68 -0
- package/src/launch.ts +403 -0
- package/src/nono.ts +349 -0
- package/src/paths.ts +31 -0
- package/src/profile.ts +140 -0
- package/src/profiles.ts +62 -0
- package/src/sandbox.ts +124 -0
- package/src/spawn.ts +147 -0
- package/src/spec.ts +60 -0
- package/src/srt.ts +187 -0
- package/test/access.test.ts +367 -0
- package/test/box-process.test.ts +327 -0
- package/test/launcher-env.test.ts +144 -0
- package/test/live.test.ts +259 -0
- package/test/manifest.test.ts +231 -0
- package/tsconfig.json +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Niwa Labs contributors
|
|
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
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @niwa-labs/sandbox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Process boxes (srt and nono), `BoxSpec`, launching a process inside a box, and how a box gets its access.
|
|
4
|
+
|
|
5
|
+
- A **profile** is the paths a program needs: `{ read?, write?, net? }`, or a function of
|
|
6
|
+
`{ home, env, bin }` (`bin(name)` gives the program's path, its real path and its package root).
|
|
7
|
+
`@niwa-labs/sandbox/profiles` is the catalog: `git`, `node`, `bun`, `npm`, `cargo`, `uv`.
|
|
8
|
+
- `sandbox({ adapter?, profiles?, closed? })` is a host's sandbox: the catalog, the host's own
|
|
9
|
+
profiles (their names typed by augmenting `BoxProfiles`), and the profile of every harness
|
|
10
|
+
installation, given by the sessions module.
|
|
11
|
+
- A box asks with `{ allow: [...] }` (added to the host's default) or `{ only: [...] }` (replacing it):
|
|
12
|
+
`"project"` (the working directory, writable), `"toolchains"` (the PATH, Homebrew and the catalog's
|
|
13
|
+
programs, readable), a profile's name, `{ read }`, `{ write }`, `{ net }`.
|
|
14
|
+
- The plan guarantees the paths it allows and the paths it closes: every path a profile names is closed
|
|
15
|
+
to every box that did not take it (programs excepted), and so are `~/.ssh`, `~/.aws`, `~/.gnupg`,
|
|
16
|
+
`~/Library/Keychains` and niwa's own secrets, unless a place in them is asked for by name. The rest is
|
|
17
|
+
the sandbox's own: srt reads it, nono does not. A sandbox that cannot hold the plan refuses it with
|
|
18
|
+
`BoxRefused`, every reason at once.
|
|
19
|
+
- Widening beyond the host's default needs a rule of the caller's grant: `box.use@<profile>`,
|
|
20
|
+
`box.read@<path>`, `box.write@<path>`, `box.net@<host>`.
|
|
21
|
+
- `BoxManifest` is what is recorded of a box: the request and where each item came from, the paths and
|
|
22
|
+
their origins, what was closed and left out, the rules taken, and the policy the sandbox applies.
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niwa-labs/sandbox",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./profiles": "./src/profiles.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@anthropic-ai/sandbox-runtime": "^0.0.83",
|
|
12
|
+
"zod": "^4.6.7"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@niwa-labs/testing": "0.0.0"
|
|
16
|
+
}
|
|
17
|
+
}
|