fix: OpenCode event streaming + bypass permission mode

Three independent fixes for the OpenCode agent adapter:

1. Wrong API endpoints: /event/subscribe → /event, /session/{id}/prompt → /session/{id}/message
2. Untagged enum mis-dispatch: replace serde_json::from_value with manual type-field dispatch
3. Wire permissionMode "bypass" for OpenCode: allow in normalize_permission_mode() and pass
   --dangerously-skip-permissions to CLI (both spawn and spawn_streaming)

Tested with OpenCode 1.1.48 + Kimi K2.5.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
WellDunDun 2026-02-01 10:59:34 +03:00 committed by Nathan Flurry
parent 87a4e81d31
commit 9c7a08a165
2 changed files with 99 additions and 14 deletions

View file

@ -268,6 +268,9 @@ impl AgentManager {
if let Some(variant) = options.variant.as_deref() {
command.arg("--variant").arg(variant);
}
if options.permission_mode.as_deref() == Some("bypass") {
command.arg("--dangerously-skip-permissions");
}
if let Some(session_id) = options.session_id.as_deref() {
command.arg("-s").arg(session_id);
}
@ -632,6 +635,9 @@ impl AgentManager {
if let Some(variant) = options.variant.as_deref() {
command.arg("--variant").arg(variant);
}
if options.permission_mode.as_deref() == Some("bypass") {
command.arg("--dangerously-skip-permissions");
}
if let Some(session_id) = options.session_id.as_deref() {
command.arg("-s").arg(session_id);
}