Add provider runtime metadata: supportsServer and isAvailable()#538
Merged
Conversation
…-07a, S-07d) Also adds supportsServer to test-only AiProvider subclasses in packages/test that were missing the new abstract member, fixing the build. https://claude.ai/code/session_018FeLmEJ4iJWrnGMAg8idUK
Override AiProvider.isAvailable() on WebBrowserProvider to return false when none of the Chrome Built-in AI globals (LanguageModel, Summarizer, Translator, Rewriter, LanguageDetector) are present, replacing the renderer's former ad-hoc isChromeBuiltinAiAvailable check with the uniform provider probe. https://claude.ai/code/session_018FeLmEJ4iJWrnGMAg8idUK
… invariant (S-07a/c)
Adds a constructor-only regression test asserting that the Anthropic and OpenAI client builders pass provider_config.base_url through to the SDK ctor, so a future proxy can repoint providers without changing provider code. https://claude.ai/code/session_018FeLmEJ4iJWrnGMAg8idUK
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
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.
Summary
Introduces runtime metadata and availability probing for AI providers to support deployment-aware provider selection and credential threading. Adds
supportsServerproperty to all providers and implementsisAvailable()probe for environment-dependent providers like Chrome Built-in AI.Key Changes
New abstract property
supportsServeronAiProviderbase class to declare whether a provider can run server-side (Bun/Node), orthogonal toisLocal. Defaults totruein cloud provider mixin.New
isAvailable()method onAiProviderfor runtime environment probing. Returnstrueby default; overridden by environment-dependent providers (e.g., Chrome AI checks forwindow.LanguageModel,window.Summarizer, etc.).Updated
CloudProviderMetadatainterface to include optionalsupportsServerfield, enabling declarative metadata for cloud providers (Anthropic, OpenAI, Ollama).Implemented
isAvailable()override inWebBrowserProviderto check for Chrome AI globals, replacing the renderer's former ad-hocisChromeBuiltinAiAvailablecall with a uniform provider-level probe.Updated all provider implementations (Cactus, HuggingFace Transformers, MLX, llama.cpp, TensorFlow MediaPipe, and test providers) to declare
supportsServerproperty.Added comprehensive test coverage:
ProviderRuntimeMetadata.test.ts: Validates metadata declarations across all providers, verifies renderer-only providers cannot be cloud-reachable, and ensures credential threading safety.ProviderBaseUrlSeam.test.ts: Contract tests for HTTP providerbase_urlrepointing (Decision S-07b).Implementation Details
supportsServeris orthogonal toisLocal: a provider can be local (Ollama) yet server-capable, or cloud-based and not local.isAvailable()probe is async to support future environment checks that may require async operations.LanguageModel,Summarizer,Translator,Rewriter,LanguageDetector) to determine availability.supportsBrowser=truevia mixin, though spec calls forfalse(deferred per task report).https://claude.ai/code/session_018FeLmEJ4iJWrnGMAg8idUK