opencode-fs-plugin 1.11.0 → 3.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@3.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@3.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@3.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=3.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#v3.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#v3.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#v3.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#v3.0.0"
352
356
  ```
353
357
 
354
358
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
@@ -402,7 +406,8 @@ The skill ID is `filesystem`; `@filesystem` loads it explicitly.
402
406
  ## Permissions
403
407
 
404
408
  Every tool asserts an action named after the tool (`fs_cp`, `fs_rm`,
405
- `fs_pipe` stages, and so on). Internal paths use project-relative resources;
409
+ `fs_pipe` stages, and so on), except `fs.http_request`, which reuses the
410
+ built-in `webfetch` action. Internal paths use project-relative resources;
406
411
  external targets first require `external_directory` on the absolute boundary.
407
412
  `allow always` persists the same patterns as the built-in tools.
408
413
 
@@ -414,7 +419,8 @@ or `*` in ip mode) before retrying:
414
419
  {
415
420
  "permissions": [
416
421
  { "action": "external_directory", "resource": "$HOME/.npm/**", "effect": "ask" },
417
- { "action": "fs_exec_network", "resource": "*", "effect": "ask" }
422
+ { "action": "fs_exec_network", "resource": "*", "effect": "deny" },
423
+ { "action": "fs_exec_network", "resource": "registry.npmjs.org", "effect": "allow" }
418
424
  ]
419
425
  }
420
426
  ```
@@ -424,19 +430,19 @@ Keep both rules explicit. Plugin actions match OpenCode's base
424
430
  `fs_exec_network` or `external_directory` resource is allowed without a prompt,
425
431
  not asked.
426
432
 
427
- `fs.http_request` is allowed by default, like `fetch`. Its resource is the
428
- request host (`example.com:8443`), so requests can be restricted per host:
433
+ `fs.http_request` reuses the built-in `webfetch` permission, with the requested
434
+ URL as the resource, so one rule set covers both tools:
429
435
 
430
436
  ```jsonc
431
437
  {
432
438
  "permissions": [
433
- { "action": "fs_http_request", "resource": "api.github.com", "effect": "allow" },
434
- { "action": "fs_http_request", "resource": "*", "effect": "ask" }
439
+ { "action": "webfetch", "resource": "*", "effect": "deny" },
440
+ { "action": "webfetch", "resource": "https://api.github.com/*", "effect": "allow" }
435
441
  ]
436
442
  }
437
443
  ```
438
444
 
439
- Redirects re-assert the rule against each new host.
445
+ Redirects re-assert the rule against each new URL.
440
446
 
441
447
  Agent rules can use wildcards:
442
448
 
package/SPEC.md CHANGED
@@ -67,8 +67,9 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
67
67
 
68
68
  - `fs.http_request` supports `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `HEAD`
69
69
  over `http:`/`https:` only; other schemes fail with `unsupported`.
70
- - Requests are allowed by default. The permission resource is the request host,
71
- and every redirect hop re-asserts `fs_http_request` for the new host.
70
+ - Requests are allowed by default. `fs.http_request` asserts the built-in
71
+ `webfetch` action with the requested URL as the resource; there is no separate
72
+ `fs_http_request` action. Every redirect hop re-asserts it for the new URL.
72
73
  - Redirects are followed manually: 301/302 rewrite `POST` to `GET`, 303 always
73
74
  does, and the hop count is bounded by `maxRedirects`.
74
75
  - `output` streams the response to a temporary file in the target directory and
@@ -89,10 +90,10 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
89
90
  Network is proxy-only and external paths are denied by default; there are no
90
91
  per-call grants.
91
92
  - 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`.
93
+ allowlist is the hosts approved through `fs_exec_network` in this run. A
94
+ refused host asks with the host as the resource, then the run retries with it
95
+ added. The permission rules are the only allowlist; there is no plugin option
96
+ for it.
96
97
  - `execNetworkMode: "ip"` opts into all-IP networking after `fs_exec_network`
97
98
  approval. In `ip` mode the policy also opens the resolver sockets used by
98
99
  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": "3.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
@@ -481,10 +482,9 @@ hidden inside a pipeline. Do not work around a denied tool with shell.
481
482
  `fs_exec_network` with the refused host (or `*` in `ip` mode), then retries.
482
483
  There are no per-call grants and no shell.
483
484
 
484
- `fs_http_request` is allowed by default, like `fetch`. Its resource is the
485
- request host; rules can allow one host and ask or deny the rest. Each redirect
486
- hop is checked against the new host. Nothing blocks localhost or private
487
- addresses by default.
485
+ `fs_http_request` reuses the built-in `webfetch` permission with the requested
486
+ URL as the resource, so one rule set covers both; each redirect hop is checked
487
+ against its URL. Nothing blocks localhost or private addresses by default.
488
488
 
489
489
  ## Errors and output
490
490
 
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
 
@@ -194,13 +194,13 @@ async function request(
194
194
  url: URL,
195
195
  options: RequestOptions,
196
196
  ): Promise<{ response: Response; finalUrl: string }> {
197
- const gate = ctx.permissionFor("fs_http_request");
197
+ const gate = ctx.permissionFor("webfetch");
198
198
  let current = url;
199
199
  let method = options.method;
200
200
  let body = options.body;
201
201
 
202
202
  for (let redirects = 0; ; redirects++) {
203
- await gate.assertTrusted([current.host]);
203
+ await gate.assertTrusted([current.toString()]);
204
204
  const response = await fetch(current, {
205
205
  method,
206
206
  headers: options.headers,