mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 17:53:39 +00:00
Closes #158009 ## What Problem This Solves Fixes empty native OpenCode session catalogs and failed transcript/activity reads after upgrading the OpenCode CLI to v2. ## User Impact OpenCode sessions remain browsable with either CLI generation, and failed CLI calls now leave a useful Gateway warning instead of only a generic catalog error. No configuration or stored-data migration is required. ## Why This Change Was Made Detect the installed CLI major version. Keep the v1 database/export commands; use v2's global session API, session export, and bounded event-head probe. Normalize the v2 transcript at the plugin boundary so browsing and upstream human-turn detection share the same interpretation. V2 calls use a private standalone server, an empty temporary config directory, and disabled project configuration; the restricted subprocess environment remains in place. V2 listing follows API cursors in batches of at least 100 until it has enough unarchived sessions. The complete scan shares the existing 30-second CLI budget and reports an error if exhausted, rather than returning a false empty catalog. ## Evidence - Real OpenCode 2.0.16, installed from the official `@opencode/cli` package in an isolated prefix: baseline Gateway `sessions.catalog.list` returned no sessions and `LOCAL_READ_FAILED`; the invoked CLI rejected `--pure` and `--format`. The candidate lists both locally seeded sessions, and `sessions.catalog.read` returns the seeded user text. - Real installed OpenCode 1.18.32 with isolated data: the same Gateway catalog RPC lists the seeded session before and after the change. Neither global CLI installation nor user OpenCode data was changed; no model inference was used. - Real v2 activity probe: baseline marker established, one external user turn detected, unchanged cursor suppressed, and a confirmed missing session distinguished from read failure. This supplemental probe invokes the plugin activity owner directly; catalog listing and reading above use the actual Gateway RPC. - Gateway logs now show `OpenCode catalog CLI failed: Error: Session not found: ses_missing158009` for a failed v2 transcript read. - Focused catalog and activity suites: 37 tests passed, 30.97 seconds wall time including worker preparation. The v2 catalog regression fails against the unchanged baseline with `OpenCode exited with code 2`. - V1/v2 transcript, activity cursor, transient failure, and missing-session coverage. Broader checks are left to CI. - Archived-first real v2 store: two recently archived sessions precede one live session. With `limitPerHost: 1`, the earlier candidate returned an empty Gateway catalog; the repaired candidate follows the API cursor and returns the live session. The archived-first regression also fails before the repair and passes afterward. - Archived-heavy real v2 fixture: 100 archived sessions precede one live session. The actual Gateway `sessions.catalog.list` request with `limitPerHost: 1` returned the live session in 2,430 ms. The regression also verifies that exhausting the shared scan deadline produces an error rather than an empty catalog. Co-authored-by: Ayaan Zaidi <hi@obviy.us>
53 lines
2 KiB
Markdown
53 lines
2 KiB
Markdown
---
|
|
summary: "Adds OpenCode model provider support to OpenClaw."
|
|
read_when:
|
|
- You are installing, configuring, or auditing the opencode plugin
|
|
title: "OpenCode plugin reference"
|
|
---
|
|
|
|
<!-- Generated file. Do not edit by hand.
|
|
Run `pnpm plugins:inventory:gen` to rebuild it. Hand-written text survives only
|
|
between the openclaw-plugin-reference:manual-start and
|
|
openclaw-plugin-reference:manual-end comment markers. -->
|
|
|
|
Adds OpenCode model provider support to OpenClaw.
|
|
|
|
## Distribution
|
|
|
|
- Package: `@openclaw/opencode-provider`
|
|
- Install route: npm or ClawHub: `clawhub:@openclaw/opencode-provider`
|
|
|
|
## Surface
|
|
|
|
- Providers: `opencode`
|
|
- Contracts: `mediaUnderstandingProviders`
|
|
|
|
<!-- openclaw-plugin-reference:manual-start -->
|
|
|
|
## Native sessions
|
|
|
|
OpenClaw auto-detects the `opencode` CLI on the Gateway and paired nodes. Stored
|
|
sessions then appear in the **OpenCode** sessions-sidebar group, with transcript
|
|
browsing through the official CLI. OpenCode v1 uses `--pure db` and `--pure export`;
|
|
v2 uses `api session.list` and `session export` with a private standalone server.
|
|
Local rows also offer **Continue**, which
|
|
creates an OpenClaw session whose first turn resumes the native OpenCode session
|
|
through ACP. OpenCode retains the full server-side model context, and the catalog
|
|
viewer continues to show that history. OpenClaw also imports the recent native
|
|
history into the adopted session transcript. Very long transcripts import only
|
|
their most recent 200 items using a 512 KiB serialized-item budget. Paired-node
|
|
rows remain view-only.
|
|
|
|
The restricted environment prevents catalog browsing from inheriting unrelated
|
|
Gateway credentials. OpenCode v1 uses `--pure`; v2 uses an empty temporary config
|
|
directory with project configuration disabled to avoid loading user plugins.
|
|
Failed CLI calls produce an `opencode/session-catalog` warning in Gateway logs.
|
|
|
|
Turn **OpenCode Session Catalog** off under **Config > Plugins > OpenCode** to
|
|
disable discovery. It is enabled by default.
|
|
|
|
<!-- openclaw-plugin-reference:manual-end -->
|
|
|
|
## Related docs
|
|
|
|
- [opencode](/providers/opencode)
|