fix(shared): separate host vs Docker OpenAI base URLs for local LLM - #11
Conversation
|
Thanks for this — it solves a real problem cleanly. With a single repo-root I checked out Two asks before merge: 1. The CLI needs the same treatment (blocking)
While you're in there: consider having the CLI reuse shared's 2. Please declare the embedding behavior change in the PR description
Design alternative I considered (fine to keep your approach)Instead of a new env var, host processes could auto-rewrite Minor, no action needed:
Happy to merge once the CLI piece is in. |
ff47495 to
02b48ad
Compare
…ack env Sensing MCP configs from robrain install only had the Docker URL, so global installs failed on the host; doctor also printed host.docker.internal.
|
Fixed, the CLI now propagates the host URL correctly, and |
Fixes #10
Fix Summary
When running a local OpenAI-compatible server with Perception in Docker, one shared
OPENAI_BASE_URLvariable cannot work for everyone:localhostmeans the container, but you needhost.docker.internalto reach the local server on the host.host.docker.internaloften breaks Nodefetch, whilelocalhostworks.So we were forced to pick one URL and break either Perception or Synthesis.
This change adds an optional host-side URL:
OPENAI_BASE_URL, used by Perception (Docker), typicallyhttp://host.docker.internal:<port>/v1OPENAI_HOST_BASE_URL, preferred by Sensing / Synthesis on the host, typicallyhttp://127.0.0.1:<port>/v1Sensing and Synthesis call
resolveOpenAiBaseUrl(..., { preferHost: true })(same for embeddings). Perception keeps usingOPENAI_BASE_URLonly. IfOPENAI_HOST_BASE_URLis unset, host processes fall back toOPENAI_BASE_URL(host-only).resolveEmbeddingConfignow goes throughresolveOpenAiBaseUrlas well, so embeddings get the same trimming, empty-string -> default, andlocalhost->127.0.0.1normalization as the chat path (including Perception in Docker).CLI:
robrain installwrites both URLs into Sensing MCP env so a globally installed user is not stuck with only the Docker URL inmcp.json.robrain doctorprints the host-resolved URL.robrain upseedsOPENAI_HOST_BASE_URL. The CLI keeps its own resolver (no@robrain/shareddependency) but mirrors the sharedpreferHostcontract.BASE_URL vars are still only for optional fully-local mode.