Configure the Hub's AI provider for web clients (v0.16.0) - #15
Merged
Conversation
The dashboard's :ai and :ide run their provider calls through the Hub so no browser holds an API key — but omnyserver's shell broker served no AI at all: it built the omnyshell HubBroker without an aiProxy, so a web client's fetchHubAiConfig always returned "unavailable". - ShellHub.fromGrants gains an `aiConfig` and passes `aiProxy: HttpProxyService(defaultConfig: aiConfig)` to the broker. That one wiring makes fetchHubAiConfig and the credential-injecting proxy work — the key stays on the Hub. - `hub start --ai-config` (default <OMNYSERVER_HOME>/ai.yaml) loads the config via AiConfigIo.load and threads it in under --shell; startup reports whether AI is configured. - New `omnyserver ai config | show | test` command, mirroring omnyshell's: config writes provider/model/key/mode/language (600, `--key -` for a hidden prompt), show prints it with the key masked, test makes a live provider call. Keys may also come from ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY. Almost entirely reuse — AiConfig, AiConfigIo, HttpProxyService, providerFor and validateModels are public in the omnyshell package omnyserver already depends on. Adds `http` (used by `ai test`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the dashboard
:ai/:idework (shipped in dashboard 0.3.0): those agents proxy their provider calls through the Hub so no browser holds an API key — but omnyserver's Hub served no AI, so:aihad no default and only worked with a key typed into the dashboard. This gives the Hub an AI provider.The gap
omnyserver's
ShellHub.fromGrantsbuilt the omnyshellHubBrokerwithout anaiProxy, so a web client'sfetchHubAiConfigalways answeredavailable: falseand every proxy request was rejected.Changes
ShellHub.fromGrants(aiConfig:)→ passesaiProxy: HttpProxyService(defaultConfig: aiConfig)to the broker. That single wiring lights upfetchHubAiConfig(key-less discovery) and the credential-injecting proxy — the key stays on the Hub.hub start --ai-config(default<OMNYSERVER_HOME>/ai.yaml) →AiConfigIo.load→ threaded in under--shell. Startup reportsHub AI: <provider> — proxying …ornot configured.omnyserver ai config | show | test— mirrorsomnyshell ai …:configwrites provider/model/key/mode/language to~/.omnyserver/ai.yaml(mode 600;--key -reads from a hidden prompt)showprints the resolved config, key maskedtestvalidates the key + models with a live provider requestANTHROPIC_API_KEY/OPENAI_API_KEY/GEMINI_API_KEYAlmost entirely reuse
AiConfig,AiConfigIo,HttpProxyService,providerFor,validateModelsare all public in theomnyshellpackage omnyserver already depends on — this is CLI glue + the one broker wiring. Addshttp(forai test).Verification
shell_hub_ai_test.dart(aiConfig → broker gets a proxy; without → none) andai_command_test.dart(subprocessconfig/show/errors, isolated home).ai configwrites~/.omnyserver/ai.yaml,ai showreflects it (key masked), andhub start --shellreportsHub AI: anthropic — proxying :ai for web clients(ornot configuredwhen absent).Note
The reused
AiConfigIowrites a header comment reading~/.omnyshell/ai.yamleven in omnyserver's file — cosmetic only (it's a comment), left as-is to avoid a needless omnyshell patch.🤖 Generated with Claude Code