Skip to content

Add provider runtime metadata: supportsServer and isAvailable()#538

Merged
sroussey merged 5 commits into
mainfrom
claude/awesome-hawking-mlgn9
May 28, 2026
Merged

Add provider runtime metadata: supportsServer and isAvailable()#538
sroussey merged 5 commits into
mainfrom
claude/awesome-hawking-mlgn9

Conversation

@sroussey
Copy link
Copy Markdown
Collaborator

Summary

Introduces runtime metadata and availability probing for AI providers to support deployment-aware provider selection and credential threading. Adds supportsServer property to all providers and implements isAvailable() probe for environment-dependent providers like Chrome Built-in AI.

Key Changes

  • New abstract property supportsServer on AiProvider base class to declare whether a provider can run server-side (Bun/Node), orthogonal to isLocal. Defaults to true in cloud provider mixin.

  • New isAvailable() method on AiProvider for runtime environment probing. Returns true by default; overridden by environment-dependent providers (e.g., Chrome AI checks for window.LanguageModel, window.Summarizer, etc.).

  • Updated CloudProviderMetadata interface to include optional supportsServer field, enabling declarative metadata for cloud providers (Anthropic, OpenAI, Ollama).

  • Implemented isAvailable() override in WebBrowserProvider to check for Chrome AI globals, replacing the renderer's former ad-hoc isChromeBuiltinAiAvailable call with a uniform provider-level probe.

  • Updated all provider implementations (Cactus, HuggingFace Transformers, MLX, llama.cpp, TensorFlow MediaPipe, and test providers) to declare supportsServer property.

  • 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 provider base_url repointing (Decision S-07b).

Implementation Details

  • supportsServer is orthogonal to isLocal: a provider can be local (Ollama) yet server-capable, or cloud-based and not local.
  • The isAvailable() probe is async to support future environment checks that may require async operations.
  • Chrome Built-in AI checks five API globals (LanguageModel, Summarizer, Translator, Rewriter, LanguageDetector) to determine availability.
  • Test notes document known discrepancies: Anthropic and OpenAI currently default supportsBrowser=true via mixin, though spec calls for false (deferred per task report).

https://claude.ai/code/session_018FeLmEJ4iJWrnGMAg8idUK

claude added 5 commits May 27, 2026 23:47
…-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
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
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 62.11% 24617 / 39631
🔵 Statements 61.97% 25471 / 41100
🔵 Functions 63.04% 4662 / 7395
🔵 Branches 50.79% 12071 / 23763
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
providers/huggingface-transformers/src/ai/HuggingFaceTransformersProvider.ts 0% 100% 0% 0% 28-64
providers/huggingface-transformers/src/ai/HuggingFaceTransformersQueuedProvider.ts 7.14% 0% 0% 7.14% 29-120
Generated in workflow #2444 for commit 678f125 by the Vitest Coverage Report Action

@sroussey sroussey merged commit 522c2be into main May 28, 2026
13 checks passed
@sroussey sroussey deleted the claude/awesome-hawking-mlgn9 branch May 28, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants