feat(worker): implement agent provider registry pattern (#171) #222

Merged
jack merged 3 commits from feat/171-agent-registry into main 2026-01-24 19:20:37 +00:00
Owner

Summary

  • Add AgentProviderDefinition interface for provider metadata (name, displayName, envKey, priority)
  • Replace hardcoded switch statement with dynamic provider registry
  • Add registerProvider/unregisterProvider/getAvailableProviders functions
  • Support configurable fallback order via AI_PROVIDER_FALLBACK setting
  • Built-in providers registered with priority (mistral=20, anthropic=10)
  • Maintain backwards compatibility with registerAgent (deprecated)

New Settings

  • AI_PROVIDER_FALLBACK: Array of provider names for custom fallback order

Example Usage

// Register custom provider
registerProvider({
  name: 'ollama',
  displayName: 'Ollama Local',
  envKey: 'OLLAMA_BASE_URL',
  isAvailable: () => !!process.env.OLLAMA_BASE_URL,
  create: () => new OllamaAgent(),
  priority: 5,
});

// Get available providers sorted by priority
const providers = getAvailableProviders();

Test plan

  • Verify default agent selection works with priority-based fallback
  • Test custom AI_PROVIDER_FALLBACK setting
  • Verify registerProvider adds new provider to registry
  • Check backwards compatibility with registerAgent

Closes #171

🤖 Generated with Claude Code

## Summary - Add `AgentProviderDefinition` interface for provider metadata (name, displayName, envKey, priority) - Replace hardcoded switch statement with dynamic provider registry - Add `registerProvider`/`unregisterProvider`/`getAvailableProviders` functions - Support configurable fallback order via `AI_PROVIDER_FALLBACK` setting - Built-in providers registered with priority (mistral=20, anthropic=10) - Maintain backwards compatibility with `registerAgent` (deprecated) ## New Settings - `AI_PROVIDER_FALLBACK`: Array of provider names for custom fallback order ## Example Usage ```typescript // Register custom provider registerProvider({ name: 'ollama', displayName: 'Ollama Local', envKey: 'OLLAMA_BASE_URL', isAvailable: () => !!process.env.OLLAMA_BASE_URL, create: () => new OllamaAgent(), priority: 5, }); // Get available providers sorted by priority const providers = getAvailableProviders(); ``` ## Test plan - [ ] Verify default agent selection works with priority-based fallback - [ ] Test custom AI_PROVIDER_FALLBACK setting - [ ] Verify registerProvider adds new provider to registry - [ ] Check backwards compatibility with registerAgent Closes #171 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(worker): implement agent provider registry pattern (#171)
All checks were successful
CI / build (pull_request) Successful in 46s
3ede87ff69
- Add AgentProviderDefinition interface for provider metadata
- Replace hardcoded switch with dynamic provider registry
- Add registerProvider/unregisterProvider/getAvailableProviders functions
- Support configurable fallback order via AI_PROVIDER_FALLBACK setting
- Built-in providers registered with priority (mistral=20, anthropic=10)
- Maintain backwards compatibility with registerAgent (deprecated)

New settings:
- AI_PROVIDER_FALLBACK: array of provider names for custom fallback order

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merge branch 'main' into feat/171-agent-registry
All checks were successful
CI / build (pull_request) Successful in 42s
2296bafdec
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merge branch 'main' into feat/171-agent-registry
All checks were successful
CI / build (pull_request) Successful in 40s
94fadae3c5
jack merged commit 78a230c0d0 into main 2026-01-24 19:20:37 +00:00
Sign in to join this conversation.
No description provided.