opencode-fs-plugin 1.11.0 → 2.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/README.md CHANGED
@@ -140,22 +140,26 @@ work, fan out with `Promise.all` over `tools.fs.*` (or one multi-path call).
140
140
  ```
141
141
 
142
142
  The workspace (project) is read/write/exec. **Network is proxy-only by
143
- default**: every run gets its own egress proxy, no direct route, and only
144
- allowlisted hosts are reachable. Pre-approve hosts in the plugin options:
143
+ default**: every run gets its own egress proxy, no direct route, and every host
144
+ must be approved through `fs_exec_network`. There is no separate allowlist
145
+ option; the permission rules are the allowlist:
145
146
 
146
147
  ```jsonc
147
148
  {
148
- "options": {
149
- "execNetworkAllowlist": ["registry.npmjs.org", "*.npmjs.org"]
150
- }
149
+ "permissions": [
150
+ { "action": "fs_exec_network", "resource": "*", "effect": "deny" },
151
+ { "action": "fs_exec_network", "resource": "registry.npmjs.org", "effect": "allow" },
152
+ { "action": "fs_exec_network", "resource": "pypi.org", "effect": "allow" }
153
+ ]
151
154
  }
152
155
  ```
153
156
 
154
157
  A host the proxy refuses asks `fs_exec_network` with that host, and the run
155
- retries with it added. `execNetworkMode: "ip"` opts into all-IP networking after
156
- the same approval instead. External paths are separate: a blocked path asks
157
- `external_directory` for its containing directory (or the nearest existing
158
- ancestor), and the sandbox grants read/write there.
158
+ retries with it added. With no rule (base allow), that happens silently; with a
159
+ `*` deny the host fails closed instead. `execNetworkMode: "ip"` opts into all-IP
160
+ networking after the same approval instead. External paths are separate: a
161
+ blocked path asks `external_directory` for its containing directory (or the
162
+ nearest existing ancestor), and the sandbox grants read/write there.
159
163
 
160
164
  The decision comes from your `opencode.jsonc` rules (`ask`, `allow`, `deny`), the
161
165
  same as every other tool. If a path stays blocked after approval, the result
@@ -280,18 +284,18 @@ Add the registry package directly to the plugin list:
280
284
 
281
285
  ```jsonc
282
286
  {
283
- "plugins": ["opencode-fs-plugin@1.11.0"]
287
+ "plugins": ["opencode-fs-plugin@2.0.0"]
284
288
  }
285
289
  ```
286
290
 
287
- `opencode plugin add opencode-fs-plugin@1.11.0` installs it and writes the config
291
+ `opencode plugin add opencode-fs-plugin@2.0.0` installs it and writes the config
288
292
  entry. A bare `opencode-fs-plugin` follows the `latest` tag.
289
293
 
290
294
  OpenCode manages the package under its cache, so the path is not stable. If you
291
295
  also want the packaged skill, install it into a project instead:
292
296
 
293
297
  ```bash
294
- npm install opencode-fs-plugin@1.11.0
298
+ npm install opencode-fs-plugin@2.0.0
295
299
  ```
296
300
 
297
301
  ```jsonc
@@ -306,7 +310,7 @@ npm install opencode-fs-plugin@1.11.0
306
310
  Download the release tarball, then install it as a normal npm package:
307
311
 
308
312
  ```bash
309
- VERSION=1.11.0
313
+ VERSION=2.0.0
310
314
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
311
315
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
312
316
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -335,20 +339,20 @@ OpenCode installs it from Git:
335
339
 
336
340
  ```jsonc
337
341
  {
338
- "plugins": ["github:masterjg/opencode-fs-plugin#v1.11.0"]
342
+ "plugins": ["github:masterjg/opencode-fs-plugin#v2.0.0"]
339
343
  }
340
344
  ```
341
345
 
342
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.11.0'` installs the
346
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v2.0.0'` installs the
343
347
  same spec and writes the config entry. The equivalent full URL is
344
- `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.11.0`. A tag is
348
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v2.0.0`. A tag is
345
349
  checked for updates; use a full commit hash to pin it.
346
350
 
347
351
  Git plugins are installed under OpenCode's cache, so their package path is not
348
352
  stable. If you also want the packaged skill, install with npm instead:
349
353
 
350
354
  ```bash
351
- npm install "github:masterjg/opencode-fs-plugin#v1.11.0"
355
+ npm install "github:masterjg/opencode-fs-plugin#v2.0.0"
352
356
  ```
353
357
 
354
358
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
@@ -414,7 +418,8 @@ or `*` in ip mode) before retrying:
414
418
  {
415
419
  "permissions": [
416
420
  { "action": "external_directory", "resource": "$HOME/.npm/**", "effect": "ask" },
417
- { "action": "fs_exec_network", "resource": "*", "effect": "ask" }
421
+ { "action": "fs_exec_network", "resource": "*", "effect": "deny" },
422
+ { "action": "fs_exec_network", "resource": "registry.npmjs.org", "effect": "allow" }
418
423
  ]
419
424
  }
420
425
  ```
package/SPEC.md CHANGED
@@ -89,10 +89,10 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
89
89
  Network is proxy-only and external paths are denied by default; there are no
90
90
  per-call grants.
91
91
  - Network is proxy-only by default: the cage gets a procage proxy whose
92
- allowlist is the configured `execNetworkAllowlist` plus the hosts approved
93
- in this run. A refused host asks `fs_exec_network` with the host as the
94
- resource, then the run retries with it added. The decision comes from
95
- `opencode.jsonc`.
92
+ allowlist is the hosts approved through `fs_exec_network` in this run. A
93
+ refused host asks with the host as the resource, then the run retries with it
94
+ added. The permission rules are the only allowlist; there is no plugin option
95
+ for it.
96
96
  - `execNetworkMode: "ip"` opts into all-IP networking after `fs_exec_network`
97
97
  approval. In `ip` mode the policy also opens the resolver sockets used by
98
98
  systemd-resolved, nscd, and SSSD. Plain UDP DNS needs none; other Unix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fs-plugin",
3
- "version": "1.11.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.12"
@@ -158,9 +158,10 @@ override it with the fs plugin option `execAllowlist` in `opencode.jsonc`:
158
158
 
159
159
  The project is read/write/exec. **Network is proxy-only by default, and there
160
160
  are no per-call grants.** The run gets its own egress proxy with no direct
161
- route; a refused host asks `fs_exec_network` with the host and the run retries
162
- with it added. Pre-approve hosts with `execNetworkAllowlist`; set
163
- `execNetworkMode: "ip"` to opt into all-IP after approval instead. On Linux T2
161
+ route; every host must be approved through `fs_exec_network`, which asks with
162
+ the host as the resource and retries with it added. The permission rules are
163
+ the allowlist: a `*` deny plus host allows fails closed for everything else.
164
+ `execNetworkMode: "ip"` opts into all-IP after approval instead. On Linux T2
164
165
  (no network namespace) the run falls back to `ip`.
165
166
 
166
167
  ```js
package/src/core/types.ts CHANGED
@@ -34,8 +34,6 @@ export interface RunContext {
34
34
  readonly execAllowlist: readonly string[];
35
35
  /** `proxy` forces egress through the run's allowlist proxy; `ip` is all-IP. */
36
36
  readonly execNetworkMode: "proxy" | "ip";
37
- /** Hosts pre-approved for every `fs.exec` proxy run. */
38
- readonly execNetworkAllowlist: readonly string[];
39
37
  }
40
38
 
41
39
  export interface ToolSpec<I> {
package/src/index.ts CHANGED
@@ -33,7 +33,6 @@ import { findTool } from "./tools/find.js";
33
33
  import {
34
34
  execTool,
35
35
  normalizeExecAllowlist,
36
- normalizeExecNetworkAllowlist,
37
36
  normalizeExecNetworkMode,
38
37
  } from "./tools/exec.js";
39
38
  import { findmntTool } from "./tools/findmnt.js";
@@ -205,7 +204,6 @@ export default Plugin.define({
205
204
  );
206
205
  const execAllowlist = normalizeExecAllowlist(ctx.options?.execAllowlist);
207
206
  const execNetworkMode = normalizeExecNetworkMode(ctx.options?.execNetworkMode);
208
- const execNetworkAllowlist = normalizeExecNetworkAllowlist(ctx.options?.execNetworkAllowlist);
209
207
  const maxOutputBytes =
210
208
  typeof ctx.options?.maxOutputBytes === "number" && ctx.options.maxOutputBytes > 0
211
209
  ? Math.trunc(ctx.options.maxOutputBytes)
@@ -260,7 +258,6 @@ export default Plugin.define({
260
258
  maxOutputBytes,
261
259
  execAllowlist,
262
260
  execNetworkMode,
263
- execNetworkAllowlist,
264
261
  },
265
262
  parsed,
266
263
  {},
package/src/tools/exec.ts CHANGED
@@ -73,21 +73,6 @@ export function normalizeExecNetworkMode(value: unknown): ExecNetworkMode {
73
73
  throw new FsError('execNetworkMode must be "proxy" or "ip".', "invalid");
74
74
  }
75
75
 
76
- export function normalizeExecNetworkAllowlist(value: unknown): readonly string[] {
77
- if (value === undefined) return [];
78
- if (!Array.isArray(value)) {
79
- throw new FsError("execNetworkAllowlist must be an array of hosts.", "invalid");
80
- }
81
- const hosts: string[] = [];
82
- for (const entry of value) {
83
- if (typeof entry !== "string" || entry.trim() === "") {
84
- throw new FsError("execNetworkAllowlist entries must be non-empty strings.", "invalid");
85
- }
86
- hosts.push(entry.trim());
87
- }
88
- return [...new Set(hosts)];
89
- }
90
-
91
76
  /** `ip` adds all-IP networking; both modes get the local resolver sockets. */
92
77
  export function applyNetworkPolicy(doc: PolicyDocument, mode: ExecNetworkMode): void {
93
78
  doc.ipc.unix_sockets = [...RESOLVER_SOCKETS];
@@ -201,7 +186,7 @@ export const execTool: ToolSpec<Input> = {
201
186
  ? input.stdin === undefined ? undefined : Buffer.from(input.stdin)
202
187
  : await collect(io.stdin);
203
188
  let networkMode = ctx.execNetworkMode;
204
- const proxyHosts = [...ctx.execNetworkAllowlist];
189
+ const proxyHosts: string[] = [];
205
190
  let ipNetwork = false;
206
191
  const approved: Array<{ full: string }> = [];
207
192
  let outcome: ExecOutcome | undefined;
@@ -343,7 +328,7 @@ async function runCaged(ctx: RunContext, input: CagedInput): Promise<ExecOutcome
343
328
  acceptSpawnSnapshot: true,
344
329
  relax: ["waive:trust-handoff", "signals-same-user", "no-unix-sockets"] as Relaxation[],
345
330
  ...(input.networkMode === "proxy"
346
- ? { proxy: { allowlist: input.proxyHosts.length === 0 ? [PROXY_SENTINEL] : [...input.proxyHosts] } }
331
+ ? { proxy: { allowlist: [...input.proxyHosts, PROXY_SENTINEL] } }
347
332
  : {}),
348
333
  };
349
334