chat: add model switching and preloaded instructions

Expose the OpenCode model list and session model switch over the chat protocol,
carry a per-session model provider on chat rows, and apply a preloaded behavior
brief as a durable session instruction entry when a chat is created.
This commit is contained in:
2026-10-20 14:58:20 +01:00
parent f982c0b712
commit 6bfe4c8921
12 changed files with 468 additions and 17 deletions
+7
View File
@@ -64,6 +64,11 @@ export const Protocol = Object.freeze({
CHAT_STAR: "chat_star",
CHAT_RENAME: "chat_rename",
CHAT_BACKENDS: "chat_backends",
// Model selection for one chat. `chat_models` uses the usual `chat_query`
// session body and replies in `chat_models`; `chat_model` carries
// `{session_id,provider,model}` in `chat_model` and echoes it.
CHAT_MODELS: "chat_models",
CHAT_MODEL: "chat_model",
// The shared live stream (C5). `chat_subscribe` attaches this connection to one
// session's stream (body: the session id); the server then pushes `chat_event`
// frames without a matching request id, so every client watching a session sees
@@ -119,6 +124,8 @@ export const ChatKeys = Object.freeze({
ANSWER: "chat_answer",
RENAME: "chat_rename",
BACKENDS: "chat_backends",
MODELS: "chat_models",
MODEL: "chat_model",
// The composer's payloads (C8/C9). `chat_interrupt` deliberately has no key of
// its own: its body is the same `chat_query` the other session-scoped commands
// carry (internal/protocol/chat.go ChatQuery, Chat.kt interruptRequest), so a