feat(daemon): Session 8 — OpenAI-compatible API support (Daemon Spec Phase E)
Create lib/daemon-llm.mjs — the daemon LLM wrapper that resolves daemon.llm config and routes to the correct provider/endpoint:
- provider: null + base_url → OpenAI-compat fetch to custom endpoint (supports OpenRouter, vLLM, LM Studio, text-generation-webui, any URL speaking the OpenAI Chat Completions API) - provider: "openai" ± base_url → OpenAI-compat fetch (custom or default URL) - provider: "anthropic" → delegates to completeChat (warns if base_url set) - provider: "ollama" → delegates to completeChat - no daemon config → falls through to completeChat (env auto-detect)
Exported helpers: resolveApiKey, buildDelegateConfig, callOpenAiCompat.
Config wiring confirmed (no changes needed): config.daemon.llm.base_url ← KNOWTATION_DAEMON_LLM_BASE_URL env override config.daemon.llm.api_key_env ← reads process.env[api_key_env] at call time
lib/llm-complete.mjs is untouched; existing 835 tests have zero regressions.
Add test/daemon-llm.test.mjs — 55 tests covering: resolveApiKey, buildDelegateConfig, callOpenAiCompat (unit) daemonLlm routing: all provider/base_url/api_key_env combinations, missing-key errors, HTTP-error messages, model/max_tokens pass-through loadDaemonConfig integration: env var override, YAML pass-through consolidateMemory end-to-end: base_url routing and api_key_env header verified with globalThis.fetch mocks — no real HTTP calls
Total: 890 tests, 0 failures.
0 comments
muse hub commit comment sha256:cbc803b0494f4dd356dcdc06a19c7558f6d9edcf8cf0e21d7904e078edb48d13 --body "your comment"
No comments yet. Be the first to start the discussion.