feat BREAKING hub feat/companion-design-openrouter-lane #1 / 2
aaronrene · 9 days ago · Jun 5, 2026 · Diff

feat(hub): UI to select the completeChat provider + OpenRouter in Integrations

Closes the gap where the chat lane (MCP summarize + Hub proposal LLM jobs) could only be chosen via the KNOWTATION_CHAT_PROVIDER env var. Adds an admin-only "AI model provider" control under Settings → Integrations (DeepInfra / OpenAI / Anthropic / OpenRouter / Ollama / auto-detect) and an OpenRouter integration tile + guide.

Resolution & persistence: - lib/llm-complete.mjs: provider precedence is now env KNOWTATION_CHAT_PROVIDER (operator lock, wins) → config.llm.provider (UI) → auto-detect. Adds an explicit `ollama` lane (forces local even when cloud keys exist) via an extracted ollamaChat(); error messages are source-agnostic. Fully backward compatible (env still wins; no config → unchanged). - lib/config.mjs: loadConfig exposes the top-level `llm` block from local.yaml; new loadLlmConfig + normalizeChatProviderInput strictly whitelist the provider (CHAT_PROVIDERS) so a malformed/hostile value can never reach completeChat or be persisted. - lib/daemon-llm.mjs: buildDelegateConfig pins llm.provider for the anthropic/ollama daemon lanes so consolidation is never hijacked by the global chat provider. - hub/server.mjs: GET /api/v1/settings exposes a `chat` block (provider, providers, env_locked, key_available); new admin-only POST /api/v1/settings/chat validates + persists llm.provider to config/local.yaml and 409s when the env lock is set.

UI: - web/hub: selector loads from settings, reflects env-lock + admin gating, saves via the API; OpenRouter tile/guide documents the BYO-key env wiring (key stays in server env, never the UI) and the no-managed-fallback privacy contract.

Tests: 7-tier coverage across resolution, config parsing, endpoint authz/validation/security, and the integration guide/UI wiring. Targeted regression 207/207 + config/daemon 105/105 green.

sha256:7c3a895ff145e068015993d2e7299895b18e2d5ecf833c4268f042f90372b33c sha
+24 ~37 −4 symbols
sha256:be73c42b094c636a196246c6a1a1944f876512f34b94810bab174e6ecf6fd448 snapshot
+24
symbols added
~37
symbols modified
−4
symbols removed
0
dead code introduced
Semantic Changes 65 symbols
+ chatRouteSource function function chatRouteSource L26–33
+ readRepoFile function function readRepoFile L22–24
+ clearChatEnv function function clearChatEnv L33–35
+ mockByHost function function mockByHost L44–55
+ restoreEnv function function restoreEnv L37–42
~ lib/config.mjs .mjs 2 symbols added, 1 symbol modified
+ loadLlmConfig function function loadLlmConfig L296–308
+ normalizeChatProviderInput function function normalizeChatProviderInput L269–283
~ lib/daemon-llm.mjs .mjs 1 symbol modified
~ lib/llm-complete.mjs .mjs 1 symbol added, 2 symbols modified
+ ollamaChat function async_function ollamaChat L225–261
~ web/hub/hub.js .js 2 symbols added, 1 symbol modified
+ applyChatProviderSettings function function applyChatProviderSettings L9921–9976
+ chatProviderKeyHintText function function chatProviderKeyHintText L9899–9919
~ web/hub/index.html .html 14 symbols added, 4 symbols removed, 32 symbols modified
details@1918 section details@1918 L1918–1923
details@1924 section details@1924 L1924–1929
details@1930 section details@1930 L1930–1935
details@1936 section details@1936 L1936–1941
+ button#btn-chat-provider-save section button#btn-chat-provider-save L1151–1151
+ button[OpenRouter — setup details] section button[OpenRouter — setup details] L1156–1160
+ details@1980 section details@1980 L1980–1985
+ details@1986 section details@1986 L1986–1991
+ details@1992 section details@1992 L1992–1997
+ details@1998 section details@1998 L1998–2005
+ div#integ-model-grid section div#integ-model-grid L1155–1161
+ div#settings-chat-provider section div#settings-chat-provider L1137–1154
+ h3: AI model provider section h3: AI model provider L1132–1135
+ p#chat-provider-admin-hint section p#chat-provider-admin-hint L1149–1149
+ p#chat-provider-env-hint section p#chat-provider-env-hint L1148–1148
+ p#chat-provider-key-hint section p#chat-provider-key-hint L1147–1147
+ select#chat-provider-select section select#chat-provider-select L1139–1146
+ span#chat-provider-msg section span#chat-provider-msg L1152–1152

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:7c3a895ff145e068015993d2e7299895b18e2d5ecf833c4268f042f90372b33c --body "your comment"