opencode-sandbox 0.2.0 → 0.3.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/README.md +43 -0
- package/dist/config.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -107,6 +107,9 @@ $ curl https://registry.npmjs.org
|
|
|
107
107
|
- `~/.aws/credentials`, `~/.config/gcloud`
|
|
108
108
|
- `~/.npmrc`, `~/.env`
|
|
109
109
|
|
|
110
|
+
**Filesystem (allow-read)**:
|
|
111
|
+
- Empty by default
|
|
112
|
+
|
|
110
113
|
**Filesystem (allow-write)**:
|
|
111
114
|
- Project directory
|
|
112
115
|
- Git worktree (validated — unsafe paths like `/` are rejected)
|
|
@@ -147,6 +150,7 @@ If `XDG_CONFIG_HOME` is set, it is used instead of `~/.config`.
|
|
|
147
150
|
{
|
|
148
151
|
"filesystem": {
|
|
149
152
|
"denyRead": ["~/.ssh", "~/.aws/credentials"],
|
|
153
|
+
"allowRead": ["~/.ssh/id_ed25519.pub"],
|
|
150
154
|
"allowWrite": [".", "/tmp", "/var/data"],
|
|
151
155
|
"denyWrite": [".env.production"]
|
|
152
156
|
},
|
|
@@ -164,6 +168,39 @@ If `XDG_CONFIG_HOME` is set, it is used instead of `~/.config`.
|
|
|
164
168
|
}
|
|
165
169
|
```
|
|
166
170
|
|
|
171
|
+
### Path precedence
|
|
172
|
+
|
|
173
|
+
Path precedence is inherited from `@anthropic-ai/sandbox-runtime`:
|
|
174
|
+
|
|
175
|
+
- Read: `allowRead` takes precedence over `denyRead`
|
|
176
|
+
- Write: `denyWrite` takes precedence over `allowWrite`
|
|
177
|
+
|
|
178
|
+
### Example: allow git commit signing with SSH public key
|
|
179
|
+
|
|
180
|
+
If your Git workflow needs to read a public key (for example `~/.ssh/id_ed25519.pub`) while keeping `~/.ssh` blocked by default, re-allow only that file:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
// ~/.config/opencode-sandbox/config.json
|
|
184
|
+
{
|
|
185
|
+
"filesystem": {
|
|
186
|
+
"denyRead": [
|
|
187
|
+
"~/.ssh",
|
|
188
|
+
"~/.gnupg",
|
|
189
|
+
"~/.aws/credentials",
|
|
190
|
+
"~/.azure",
|
|
191
|
+
"~/.config/gcloud",
|
|
192
|
+
"~/.config/gh",
|
|
193
|
+
"~/.kube",
|
|
194
|
+
"~/.docker/config.json",
|
|
195
|
+
"~/.npmrc",
|
|
196
|
+
"~/.netrc",
|
|
197
|
+
"~/.env"
|
|
198
|
+
],
|
|
199
|
+
"allowRead": ["~/.ssh/id_ed25519.pub"]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
167
204
|
### Example: Per-project config
|
|
168
205
|
|
|
169
206
|
```json
|
|
@@ -181,6 +218,12 @@ If `XDG_CONFIG_HOME` is set, it is used instead of `~/.config`.
|
|
|
181
218
|
OPENCODE_SANDBOX_CONFIG='{"filesystem":{"denyRead":["~/.ssh"]},"network":{"allowedDomains":["github.com"]}}' opencode
|
|
182
219
|
```
|
|
183
220
|
|
|
221
|
+
Example allowing only the SSH public key to be read:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
OPENCODE_SANDBOX_CONFIG='{"filesystem":{"denyRead":["~/.ssh","~/.gnupg","~/.aws/credentials","~/.azure","~/.config/gcloud","~/.config/gh","~/.kube","~/.docker/config.json","~/.npmrc","~/.netrc","~/.env"],"allowRead":["~/.ssh/id_ed25519.pub"]}}' opencode
|
|
225
|
+
```
|
|
226
|
+
|
|
184
227
|
### Disable
|
|
185
228
|
|
|
186
229
|
```bash
|
package/dist/config.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ function resolveConfig(projectDir, worktree, user) {
|
|
|
61
61
|
return {
|
|
62
62
|
filesystem: {
|
|
63
63
|
denyRead: user?.filesystem?.denyRead ?? DEFAULT_DENY_READ_DIRS.map((p) => path.join(homeDir, p)),
|
|
64
|
+
allowRead: user?.filesystem?.allowRead ?? [],
|
|
64
65
|
allowWrite: writePaths,
|
|
65
66
|
denyWrite: user?.filesystem?.denyWrite ?? []
|
|
66
67
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "OpenCode plugin that sandboxes agent commands using @anthropic-ai/sandbox-runtime (seatbelt on macOS, bubblewrap on Linux)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"registry": "https://registry.npmjs.org/"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@anthropic-ai/sandbox-runtime": "^0.0.
|
|
58
|
+
"@anthropic-ai/sandbox-runtime": "^0.0.43"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@opencode-ai/plugin": ">=1.0.0"
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"@opencode-ai/plugin": "^1.2.1",
|
|
66
66
|
"@opencode-ai/sdk": "^1.2.1",
|
|
67
67
|
"@types/bun": "^1.3.9",
|
|
68
|
-
"typescript": "^
|
|
68
|
+
"typescript": "^6.0.2"
|
|
69
69
|
}
|
|
70
70
|
}
|