GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — feat(plugin): let plugins assert permissions by rekram1-node · Pull Request #54930 · anomalyco/opencode Conversation
|
| Outcome | Effect plugins | Promise plugins |
|---|---|---|
| Allowed | succeeds | resolves |
| Deny rule | fails with Tool.Error (BlockedError attached) |
rejects with that Tool.Error |
| Rejected with feedback | fails with Tool.Error (feedback as message, CorrectedError attached) |
rejects with that Tool.Error |
| Plain rejection | defect, so the step ends, as with built-in tools | rejects with DeclinedError; rethrowing it from a tool ends the step (#54913) |
Failing with Tool.Error matches the tool error type, so an Effect tool can yield* the call without mapping errors, and tool.execute.before hooks can use it to gate a call. No error classes are added to @opencode/schema.
Addresses the in-process request in #52540 and the plugin-side gating in #37164. A tool-context shortcut and enforcing options.permission for tools that never assert (#50652, #47177) are left for follow-ups.
packages/core/test/plugin/permission-assert.test.ts covers both plugin flavours against a permission service that returns each outcome: input forwarding (including decoding plain Promise input), deny and feedback becoming Tool.Error with the original attached, and a plain rejection staying a decline.
The core plugin and permission tests pass, and so does typecheck, apart from one existing @opencode/app error that is also on dev.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ce4f9d8 to
bb374d1
Compare
bb374d1 to
3f9a520
Compare
There was an error while loading. Please reload this page.
…OpenCode 2.0.29's permission assert
Caw on OpenCode ran his shell without the hub's gate deciding it:
- LEAD_GATED_TOOLS.opencode named `bash`, 1.x's action. 2.0's is `shell`
("In V2, use permissions, shell, and subagent instead of permission, bash,
and task", opencode.ai/v2/docs/permissions). The agent's `#asked` matched
his asks against it (opencode-session.ts LEAD_ASKED), so a `shell` ask was
answered by his permission mode. The hub's LEAD_SHELL_TOOLS read `bash` too.
- In his place the plugin's replacing `shell` never asked at all: 2.0.28 gave
plugins no way to ("Plugins had no in-process way to ask for permission.
Built-in tools call Permission.assert, but the plugin permission domain only
exposed list, get, reply, and the evaluate hook", anomalyco/opencode#54930,
shipped in 2.0.29).
Now:
- core LEAD_GATED_TOOLS.opencode is ["shell", "edit"] (2.0's `edit` covers
write and patch), and LEAD_SHELL_TOOLS is {Bash, shell}. The other 1.x
`bash` names a 2.0 shell call meets are 2.0's too: hub web-reads SHELLS
(a shell's URL makes a wake external, which the gate reads), continuation
SHELL_TOOLS and the permission card's presentation (pi keeps `bash`). The
denied-tool lists stay in Claude's names, which opencodeToolsFor maps to
2.0's actions (Bash→shell, Agent→subagent).
- OpenCode is pinned to 2.0.29: core OPENCODE_VERSION, the one pin (the tool
catalog's exactVersion, the adapter's start check, the install command), and
@opencode/client 2.0.29. The repo has no @opencode/plugin dependency: the
plugin is generated JavaScript.
- The plugin's `shell`, for a session bounded by a workspace (a delegate in a
clone, Caw in his place), asks first through ctx.permission.assert: action
`shell`, the command as its resource and in its metadata (the gate reads
`command`), save the command, the call as its source. A deny or rejection
throws and nothing runs. A person's session in a lead's place still runs the
built-in, which asks on its own. No shell call runs without an ask.
2.0.29's other changes the adapter meets (v2.0.28...v2.0.29): a Promise
`execute.before` rejection is now that call's own Tool.Error (#55263); a
response cut at its output limit is continued with a synthetic user message
"Your last response hit the output token limit (stop reason: length)..."
(#53876); top-level `policies` replace `experimental.policies` (#55297), which
the adapter does not write; managed config wins (#55267).
Probe-kit caw-hands: `CAW_HARNESS=opencode` runs a, s, b and a new r with
Caw on OpenCode: `rm notes.txt` raises the card and Deny keeps the file; a
read-only `cat notes.txt` runs with no card. It needs a real boundary. In this
workspace, on 2.0.29: carry-live case 5 ALL PASS (a person's OpenCode shell
through the built-in on the host), send-backgrounds ALL PASS (claude,
opencode, pi).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.