@khalilgharbaoui/opencode-claude-code-plugin 0.9.2 → 0.10.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 +39 -36
- package/dist/index.d.ts +18 -0
- package/dist/index.js +530 -211
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -73,10 +73,12 @@ The plugin auto-registers the following. They appear in the model picker without
|
|
|
73
73
|
| `claude-haiku-4-5` | Claude Haiku 4.5 | 200k | 8,192 | – | 1× |
|
|
74
74
|
| `claude-sonnet-4-5` | Claude Sonnet 4.5 | 1M | 16,384 | low/medium/high/xhigh/max | 3× |
|
|
75
75
|
| `claude-sonnet-4-6` | Claude Sonnet 4.6 | 1M | 16,384 | low/medium/high/xhigh/max | 3× |
|
|
76
|
+
| `claude-sonnet-5` | Claude Sonnet 5 | 1M | 128,000 | low/medium/high/xhigh/max | 2×* |
|
|
76
77
|
| `claude-opus-4-5` | Claude Opus 4.5 | 1M | 16,384 | low/medium/high/xhigh/max | 5× |
|
|
77
78
|
| `claude-opus-4-6` | Claude Opus 4.6 | 1M | 16,384 | low/medium/high/xhigh/max | 5× |
|
|
78
79
|
| `claude-opus-4-7` | Claude Opus 4.7 | 1M | 16,384 | low/medium/high/xhigh/max | 5× |
|
|
79
80
|
| `claude-opus-4-8` | Claude Opus 4.8 | 1M | 16,384 | low/medium/high/xhigh/max | 5× |
|
|
81
|
+
| `claude-opus-5` | Claude Opus 5 | 1M | 128,000 | low/medium/high/xhigh/max | 5× |
|
|
80
82
|
| `claude-fable-5` | Claude Fable 5 | 1M | 16,384 | low/medium/high/xhigh/max | 10× |
|
|
81
83
|
| `claude-mythos-5` | Claude Mythos 5 | 1M | 16,384 | low/medium/high/xhigh/max | 10× |
|
|
82
84
|
|
|
@@ -84,7 +86,7 @@ The plugin auto-registers the following. They appear in the model picker without
|
|
|
84
86
|
|
|
85
87
|
Capabilities for every model: text + image input, text output, tool use, attachments. No temperature control, no PDF/audio/video, no interleaved streaming.
|
|
86
88
|
|
|
87
|
-
**Price ×** is each model's per-token list price relative to Haiku, the cheapest model. It's derived exactly from Anthropic's published pricing — input and output ratios both come out the same (Haiku $1/$5 = 1×, Sonnet $3/$15 = 3×, Opus
|
|
89
|
+
**Price ×** is each model's per-token list price relative to Haiku, the cheapest model. It's derived exactly from Anthropic's published pricing — input and output ratios both come out the same (Haiku $1/$5 = 1×, Sonnet $3/$15 = 3×, Opus $5/$25 = 5×, Fable 5 / Mythos 5 $10/$50 = 10×), so **Fable 5 and Mythos 5 cost 2× Opus 5**. Sonnet 5's `2×` uses its introductory $2/$10 pricing through August 31, 2026; standard $3/$15 pricing begins September 1. The same multiplier is shown as a `(N×)` suffix on the display name in opencode's model picker, since opencode has no dedicated multiplier field. On a flat Max/Pro subscription it doubles as a rough guide to how fast each model drains your usage limit.
|
|
88
90
|
|
|
89
91
|
The model ID is passed straight through to `claude --model`, so anything Claude Code accepts works.
|
|
90
92
|
|
|
@@ -94,37 +96,11 @@ Variants set the underlying reasoning effort. They're regular opencode model var
|
|
|
94
96
|
|
|
95
97
|
---
|
|
96
98
|
|
|
97
|
-
## Billing
|
|
98
|
-
|
|
99
|
-
This plugin drives Claude Code headlessly (`claude --print`), which Anthropic bills as [`claude -p` / Agent SDK usage](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan). Starting **June 15, 2026**, on subscription plans that usage no longer counts toward your normal plan limits — it draws from a separate monthly **Agent SDK credit**:
|
|
100
|
-
|
|
101
|
-
| Plan | Monthly credit |
|
|
102
|
-
|---|---|
|
|
103
|
-
| Pro | $20 |
|
|
104
|
-
| Max 5x | $100 |
|
|
105
|
-
| Max 20x | $200 |
|
|
106
|
-
| Team (Standard seats) | $20 |
|
|
107
|
-
| Team (Premium seats) | $100 |
|
|
108
|
-
| Enterprise (usage-based) | $20 |
|
|
109
|
-
| Enterprise (seat-based Premium seats) | $200 |
|
|
110
|
-
|
|
111
|
-
Credits are **per user, not pooled** across a team, and Standard seats on seat-based Enterprise plans aren't eligible. See Anthropic's [Agent SDK credit article](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan) for the authoritative table.
|
|
112
|
-
|
|
113
|
-
What this means for plugin users:
|
|
114
|
-
|
|
115
|
-
- **Claim the credit once.** It's a one-time opt-in via your Claude account; eligible users get an email with claim instructions before June 15, 2026. After that it refreshes every billing cycle, and unused credit does not roll over.
|
|
116
|
-
- **Agent SDK usage drains the credit first**, before any other source.
|
|
117
|
-
- **When the credit runs out, plugin requests stop** until the next billing cycle — unless you enable usage credits in your Claude account, in which case overflow is billed at standard API rates.
|
|
118
|
-
- **The credit is denominated in dollars at standard API rates**, so the Price × column above maps directly to how fast each model drains it — Fable 5 / Mythos 5 burn it 10× faster than Haiku, 2× faster than Opus 4.8.
|
|
119
|
-
- **API-key auth is unaffected.** If your `claude` CLI authenticates with an Anthropic API key / Console billing instead of a subscription, nothing changes — pay-as-you-go as before.
|
|
120
|
-
- **Watch for a stray `ANTHROPIC_API_KEY`.** If that variable (or `ANTHROPIC_AUTH_TOKEN`) is present in your environment, Claude Code uses it and bills pay-as-you-go — silently bypassing the subscription credit even when `claude` is logged into a plan. The plugin logs a one-time warning when it detects a key. To force subscription auth, set `ignoreAnthropicApiKey: true`, which strips the key from the `claude` spawn environment.
|
|
121
|
-
- **Interactive Claude Code in your terminal is unaffected.** The change targets programmatic usage only: the Agent SDK, `claude -p`, Claude Code GitHub Actions, and third-party apps like this plugin.
|
|
122
|
-
|
|
123
|
-
Two related dates:
|
|
124
|
-
|
|
125
|
-
- **June 15, 2026** also retires the original Claude 4 model IDs `claude-sonnet-4-20250514` and `claude-opus-4-20250514` from the API. The plugin doesn't register either, but model IDs pass straight through to `claude --model` — if you've configured one of these as an override, migrate to `claude-sonnet-4-6` / `claude-opus-4-8` before then.
|
|
126
|
-
- **June 22, 2026** is the last day [Fable 5 is included at no extra cost](https://platform.claude.com/docs/en/about-claude/models/introducing-claude-fable-5-and-claude-mythos-5) on Pro, Max, Team, and seat-based Enterprise plans. From June 23, `claude-fable-5` requires usage credits (Anthropic says it aims to fold it back into plans once capacity allows). `claude-mythos-5` is unaffected — it's Glasswing access-gated either way.
|
|
99
|
+
## Billing
|
|
127
100
|
|
|
101
|
+
This plugin drives Claude Code headlessly (Agent SDK > `claude --print`)
|
|
102
|
+
check out this page for updated information about billing: https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan
|
|
103
|
+
|
|
128
104
|
---
|
|
129
105
|
|
|
130
106
|
## Configuration
|
|
@@ -187,7 +163,7 @@ The account model IDs are internally suffixed, for example `claude-sonnet-4-6@wo
|
|
|
187
163
|
"claude-code": {
|
|
188
164
|
"options": {
|
|
189
165
|
"cliPath": "claude",
|
|
190
|
-
"proxyTools": ["Bash", "Edit", "Write", "WebFetch"],
|
|
166
|
+
"proxyTools": ["Bash", "Edit", "Write", "WebFetch", "Task"],
|
|
191
167
|
"skipPermissions": true,
|
|
192
168
|
"permissionMode": "default",
|
|
193
169
|
"bridgeOpencodeMcp": true,
|
|
@@ -205,7 +181,8 @@ The account model IDs are internally suffixed, for example `claude-sonnet-4-6@wo
|
|
|
205
181
|
| `cwd` | string | `process.cwd()` | Working directory for the spawned CLI. Resolved **lazily per request**, so opencode's project switching works. |
|
|
206
182
|
| `skipPermissions` | boolean | `true` | Pass `--dangerously-skip-permissions` to `claude`. Ignored when `proxyTools` is set — the proxy handles permissions through opencode instead. |
|
|
207
183
|
| `permissionMode` | `acceptEdits` \| `auto` \| `bypassPermissions` \| `default` \| `dontAsk` \| `plan` | – | Forwarded to `claude --permission-mode`. |
|
|
208
|
-
| `proxyTools` | string[] | `["Bash", "Edit", "Write", "WebFetch"]` | Claude built-in tools to route through opencode's executor + permission UI. See [Selective tool proxy](#selective-tool-proxy). |
|
|
184
|
+
| `proxyTools` | string[] | `["Bash", "Edit", "Write", "WebFetch", "Task"]` | Claude built-in tools to route through opencode's executor + permission UI. See [Selective tool proxy](#selective-tool-proxy). |
|
|
185
|
+
| `proxyToolTimeoutMs` | `Record<string, number>` | – | Per-tool proxy call deadline in ms, keyed by proxy tool name (`bash`, `task`, …). Defaults: 10 min flat, `task` → 60 min. For `bash`, the call's own `input.timeout` is honoured on top (`max(resolved, input.timeout)`). See [Selective tool proxy](#selective-tool-proxy). |
|
|
209
186
|
| `controlRequestBehavior` | `allow` \| `deny` | `allow` | Default response when `skipPermissions: false` and Claude sends a `can_use_tool` control request. |
|
|
210
187
|
| `controlRequestToolBehaviors` | `Record<string, "allow" \| "deny">` | – | Per-tool override for `can_use_tool`. Example: `{ "Bash": "deny", "Read": "allow" }`. |
|
|
211
188
|
| `controlRequestDenyMessage` | string | built-in message | Message returned to Claude on a deny. |
|
|
@@ -283,7 +260,7 @@ Set `interactiveSystemPrompt: false` only for diagnostics. While disabled, the i
|
|
|
283
260
|
|
|
284
261
|
This is the core feature.
|
|
285
262
|
|
|
286
|
-
By default,
|
|
263
|
+
By default, the plugin proxies `Bash`, `Edit`, `Write`, `WebFetch`, and `Task`. It disables Claude's corresponding built-in tool and exposes an equivalent through an in-process MCP server. Claude calls the MCP version, which blocks until opencode runs the tool through its own executor and permission system.
|
|
287
264
|
|
|
288
265
|
### Default proxied tools
|
|
289
266
|
|
|
@@ -295,11 +272,18 @@ By default, when Claude Code's CLI uses `Bash`, `Edit`, `Write`, etc., it execut
|
|
|
295
272
|
| `"WebFetch"` | `WebFetch` | `mcp__opencode_proxy__webfetch` |
|
|
296
273
|
| `"Task"` | `Agent` | `mcp__opencode_proxy__task` |
|
|
297
274
|
|
|
298
|
-
|
|
275
|
+
### OpenCode-native subagents
|
|
276
|
+
|
|
277
|
+
`Task` is proxied by default. The proxy disables Claude CLI's `Agent` tool and emits an unexecuted `task` call; it does not register a replacement task tool. OpenCode's built-in TaskTool remains responsible for permission checks, creating or resuming the child session, selecting the configured subagent, and foreground/background lifecycle.
|
|
278
|
+
|
|
279
|
+
- **Permissions:** the calling agent's `permission.task` rule applies to the target `subagent_type`. Grant `task: "allow"` on agents that should delegate without a prompt; an `ask` or `deny` rule remains authoritative. The plugin never bypasses this decision.
|
|
280
|
+
- **Resume:** pass the child session ID back as `task_id` to continue that subagent session. Omit it to create a fresh child.
|
|
281
|
+
- **Nested tasks:** current opencode defaults `subagent_depth` to `1`, so a first-level child cannot launch another child. Increase top-level `subagent_depth` to permit deeper nesting, and explicitly grant `permission.task` on every subagent that should delegate; opencode otherwise adds a task deny to spawned subagent sessions.
|
|
282
|
+
- **Background:** `background: true` returns after starting the child and lets opencode notify the parent when it finishes. Current opencode requires `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true` in the environment of the opencode process. Foreground is the default.
|
|
299
283
|
|
|
300
284
|
Only those five values are actually proxied; anything else you put in `proxyTools` is ignored. Proxying `Edit` also disables `MultiEdit` — opencode has no batched-edit equivalent, so Claude is forced to fan out into single `Edit` calls that each flow through the permission UI.
|
|
301
285
|
|
|
302
|
-
To
|
|
286
|
+
Without `"Task"` in `proxyTools`, Claude's built-in `Agent` tool stays enabled and Claude orchestrates subagents internally with no opencode child-session visibility. To opt out of all proxying, including Task, use an explicit empty list:
|
|
303
287
|
|
|
304
288
|
```json
|
|
305
289
|
"options": { "proxyTools": [] }
|
|
@@ -316,6 +300,24 @@ To turn off proxying entirely:
|
|
|
316
300
|
- A small per-call latency hop through `127.0.0.1:<random>/mcp`.
|
|
317
301
|
- Batched-edit ergonomics: with `Edit` proxied, Claude can no longer use `MultiEdit`, so a refactor that would have been one tool call becomes N single `Edit` calls.
|
|
318
302
|
|
|
303
|
+
### Per-tool proxy timeouts
|
|
304
|
+
|
|
305
|
+
Every proxied tool call has a deadline: if opencode hasn't resolved it (run the underlying tool and returned a result) within that many milliseconds, the call is rejected and Claude receives a timeout error. Deadlines are resolved per tool, most-specific layer winning:
|
|
306
|
+
|
|
307
|
+
1. flat default — 10 min (matches Claude CLI's own Bash ceiling)
|
|
308
|
+
2. per-tool default — **`task`: 60 min**, **`question`: 30 min**, everything else: 10 min
|
|
309
|
+
3. your `proxyToolTimeoutMs` override (case-insensitive key)
|
|
310
|
+
4. for `bash` only, the call's own `input.timeout` — the proxy never undercuts a build the caller explicitly asked to run long (`max(resolved, input.timeout)`)
|
|
311
|
+
|
|
312
|
+
The `task` and `question` defaults are deliberately generous. Subagents routinely run 20–40 min, and a question can sit on a slow operator; under the old flat 10-minute ceiling the proxy fired mid-call, Claude believed its dispatch had failed, and the subagent's eventual result was dropped (the parent turn had already ended on the timeout error). If a `task` call *does* time out, the error tells Claude not to "schedule a wake-up" — that is a Claude Code affordance which cannot fire in this headless/proxy context, so deferring silently loses the work.
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
"options": {
|
|
316
|
+
"proxyTools": ["Bash", "Edit", "Write", "WebFetch", "Task"],
|
|
317
|
+
"proxyToolTimeoutMs": { "Task": 5400000, "bash": 1800000 }
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
319
321
|
---
|
|
320
322
|
|
|
321
323
|
## WebSearch routing
|
|
@@ -559,6 +561,7 @@ Workaround for autonomous compression: trigger it manually with `/dcp compress`
|
|
|
559
561
|
- No streaming of tool inputs as they're being constructed (Anthropic's `input_json_delta`); the plugin emits them once complete.
|
|
560
562
|
- Raw chain-of-thought is not available. Claude 4 family models ship summarized thinking only. See [Extended thinking](#extended-thinking) for the full picture.
|
|
561
563
|
- Recommended Claude Code CLI: **2.1.142+**. Older CLIs work for everything else but skip the `--thinking-display` flag, so Claude Opus 4.7 turns may render empty Thinking rows. If something breaks after a Claude Code update, the CLI version is the first thing to check.
|
|
564
|
+
- **Foreground Task calls have a 30-minute proxy timeout.** The same timeout is written into Claude's generated HTTP MCP configuration so long-running opencode subagents are not cut off by Claude's 60-second default. For independent longer work, use `background: true` after enabling opencode's experimental background-subagent flag.
|
|
562
565
|
- **Subagent todos require explicit permission.** opencode's task tool gates `todowrite` per subagent: without a `permission: { todowrite: "allow" }` rule on the subagent definition, opencode injects `todowrite: false` into the tools dict and the plugin's synthetic `todowrite` emissions surface as `⚙ invalid todowrite` rows. The built-in `general` subagent denies `todowrite` by default; use a custom subagent for parallel work that needs todo visibility. Subagent todos render inline in the **subagent's** session view (navigate with the TUI's `session.child.next` / `session.parent` commands), not in the parent session's panel.
|
|
563
566
|
|
|
564
567
|
---
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ interface ClaudeCodeConfig {
|
|
|
161
161
|
controlRequestToolBehaviors?: Record<string, ControlRequestBehavior>;
|
|
162
162
|
controlRequestDenyMessage?: string;
|
|
163
163
|
proxyTools?: string[];
|
|
164
|
+
proxyToolTimeoutMs?: Record<string, number>;
|
|
164
165
|
webSearch?: WebSearchRouting;
|
|
165
166
|
hotReloadMcp?: boolean;
|
|
166
167
|
proxyOpencodeMcpTools?: boolean;
|
|
@@ -268,6 +269,23 @@ interface ClaudeCodeProviderSettings {
|
|
|
268
269
|
* (see opencode's agent docs).
|
|
269
270
|
*/
|
|
270
271
|
proxyTools?: string[];
|
|
272
|
+
/**
|
|
273
|
+
* Per-tool proxy call timeouts in milliseconds, keyed by the proxy tool
|
|
274
|
+
* name (`bash`, `edit`, `write`, `webfetch`, `task`, `question` —
|
|
275
|
+
* case-insensitive). When a proxied tool call waits longer than its
|
|
276
|
+
* deadline for opencode to resolve it, the call is rejected and Claude
|
|
277
|
+
* receives a timeout error.
|
|
278
|
+
*
|
|
279
|
+
* Defaults (used when a tool is absent here): `bash`/`edit`/`write`/
|
|
280
|
+
* `webfetch` → 10 min (matches Claude CLI's Bash ceiling); `task` →
|
|
281
|
+
* 60 min (subagents routinely run 20–40 min); `question` → 30 min
|
|
282
|
+
* (operator AFK). Setting a key here replaces the default for that tool.
|
|
283
|
+
*
|
|
284
|
+
* For `bash` specifically the call's own `input.timeout` is honoured on
|
|
285
|
+
* top: the effective deadline is `max(resolved, input.timeout)`, so a
|
|
286
|
+
* long build the caller explicitly asked to run is never undercut.
|
|
287
|
+
*/
|
|
288
|
+
proxyToolTimeoutMs?: Record<string, number>;
|
|
271
289
|
/**
|
|
272
290
|
* Strip `ANTHROPIC_API_KEY` / `ANTHROPIC_AUTH_TOKEN` from the environment of
|
|
273
291
|
* every spawned `claude` process. When an API key is present, Claude Code
|