Repository navigation
Conversation
OpenCode 2 does not run v1 hook plugins. Keep the existing server() entrypoint and add setup() so one package serves both, adapting MCP, recall, capture, and lifecycle events to the v2 shapes. Refs volcengine#5226
| error: data.error ?? data.message, | ||
| }] | ||
| } | ||
| if (type === "session.message.content.updated") { |
There was a problem hiding this comment.
[P1] Capture the assistant events emitted by OpenCode v2
I tested this PR with OpenCode 2.0.15 using a successful opencode run. The event stream emitted session.text.started, session.text.delta, and session.text.ended, but no session.message.content.updated. OpenViking persisted the user message but not the assistant reply. In an isolated copy of the PR, mapping session.text.ended to the existing message/part events made the reply persist, confirming the missing event mapping as the cause. Please handle the actual v2 text events and add a test using their real event shape; the same end-to-end check should cover tool results.
|
The v1/v2 entrypoint split and shared runtime look reasonable. The v2 event adapter needs another design pass, though: it currently assumes a complete Please establish which v2 events are the source of truth for completed assistant text and tool results, how prompt and streamed events are deduplicated, and when a session is safe to flush. Then test those real event sequences end to end. The inline finding shows a concrete failure caused by the current assumption. |
|
Superseded by #5341. I preserved the original commit and authorship there, then added the v2.0.15 lifecycle, capture, injection, MCP, test, and documentation fixes. Thanks for the initial implementation. |
Description
OpenCode 2 does not run v1 hook plugins. This keeps the existing
server()entrypoint and addssetup()so@openviking/opencode-pluginworks on OpenCode 1.18.29+ and OpenCode 2 without a top-level@opencode/pluginimport.Human Involvement
Related Issue
Related to #5226
Type of Change
Changes Made
{ id, setup, server }from the OpenCode plugin. OpenCode 1 still callsserver()/OpenVikingPlugin; OpenCode 2 callssetup().ctx.mcp.transformusing the v2 local server schema (timeoutis{ startup, catalog, execution }, not a number).sessioncontextsystem text, not the persisted prompt.session.created,session.deleted,session.compacted,session.execution.succeeded|interrupted|failed, andsession.message.content.updated. User text is captured from theprompthook."plugin"; OpenCode 2 normalizes that key to"plugins".Testing
Not yet exercised in a live OpenCode 2.0.x session. This Mac is still OpenCode 1.18.31; the v1 hook path was covered by the existing plugin tests.
Checklist
Additional Notes
v1 session/recall/MCP proxy code is unchanged in behavior. The v2 adapter is the only new seam. Compaction commits both from the
compactionhook and fromsession.compacted, matching the existing v1 double path.