@khalilgharbaoui/opencode-claude-code-plugin 0.9.3 → 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 CHANGED
@@ -163,7 +163,7 @@ The account model IDs are internally suffixed, for example `claude-sonnet-4-6@wo
163
163
  "claude-code": {
164
164
  "options": {
165
165
  "cliPath": "claude",
166
- "proxyTools": ["Bash", "Edit", "Write", "WebFetch"],
166
+ "proxyTools": ["Bash", "Edit", "Write", "WebFetch", "Task"],
167
167
  "skipPermissions": true,
168
168
  "permissionMode": "default",
169
169
  "bridgeOpencodeMcp": true,
@@ -181,7 +181,8 @@ The account model IDs are internally suffixed, for example `claude-sonnet-4-6@wo
181
181
  | `cwd` | string | `process.cwd()` | Working directory for the spawned CLI. Resolved **lazily per request**, so opencode's project switching works. |
182
182
  | `skipPermissions` | boolean | `true` | Pass `--dangerously-skip-permissions` to `claude`. Ignored when `proxyTools` is set — the proxy handles permissions through opencode instead. |
183
183
  | `permissionMode` | `acceptEdits` \| `auto` \| `bypassPermissions` \| `default` \| `dontAsk` \| `plan` | – | Forwarded to `claude --permission-mode`. |
184
- | `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). |
185
186
  | `controlRequestBehavior` | `allow` \| `deny` | `allow` | Default response when `skipPermissions: false` and Claude sends a `can_use_tool` control request. |
186
187
  | `controlRequestToolBehaviors` | `Record<string, "allow" \| "deny">` | – | Per-tool override for `can_use_tool`. Example: `{ "Bash": "deny", "Read": "allow" }`. |
187
188
  | `controlRequestDenyMessage` | string | built-in message | Message returned to Claude on a deny. |
@@ -259,7 +260,7 @@ Set `interactiveSystemPrompt: false` only for diagnostics. While disabled, the i
259
260
 
260
261
  This is the core feature.
261
262
 
262
- By default, when Claude Code's CLI uses `Bash`, `Edit`, `Write`, etc., it executes them itself — bypassing opencode's permission UI, audit trail, and policy rules entirely. With `proxyTools`, you tell the plugin to disable Claude's built-in version of a tool and expose an equivalent through an in-process MCP server. Claude calls the MCP version, which blocks until opencode runs the tool through its own executor.
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.
263
264
 
264
265
  ### Default proxied tools
265
266
 
@@ -271,11 +272,18 @@ By default, when Claude Code's CLI uses `Bash`, `Edit`, `Write`, etc., it execut
271
272
  | `"WebFetch"` | `WebFetch` | `mcp__opencode_proxy__webfetch` |
272
273
  | `"Task"` | `Agent` | `mcp__opencode_proxy__task` |
273
274
 
274
- The `Task` proxy is the way to let Claude orchestrate opencode's configured subagents (`build`, `general`, custom subagents defined in `opencode.json`) instead of Claude CLI's internal-only general-purpose / Explore / Plan options. With `"Task"` in `proxyTools` and `permission.task: allow` granted to the calling agent, a Claude session can invoke `task(subagent_type="build", prompt="...")` and the subagent runs natively under opencode (with its own permission UI, lifecycle, model assignment, and Tab visibility). Without `"Task"`, Claude's built-in `Agent` tool stays enabled and Claude orchestrates subagents internally with no opencode visibility.
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.
275
283
 
276
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.
277
285
 
278
- To turn off proxying entirely:
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:
279
287
 
280
288
  ```json
281
289
  "options": { "proxyTools": [] }
@@ -292,6 +300,24 @@ To turn off proxying entirely:
292
300
  - A small per-call latency hop through `127.0.0.1:<random>/mcp`.
293
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.
294
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
+
295
321
  ---
296
322
 
297
323
  ## WebSearch routing
@@ -535,6 +561,7 @@ Workaround for autonomous compression: trigger it manually with `/dcp compress`
535
561
  - No streaming of tool inputs as they're being constructed (Anthropic's `input_json_delta`); the plugin emits them once complete.
536
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.
537
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.
538
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.
539
566
 
540
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