Commit Graph

6 Commits

Author SHA1 Message Date
e10ce7f53a feat: add ClaudeCodeProvider for subscription users
Wraps @anthropic-ai/claude-agent-sdk so Claude Pro/Max subscribers (who
do not have a console API key) can use this library by authenticating
through the local `claude` CLI. Subscribers run `claude login` once and
the provider picks up the credentials automatically.

Provider behavior:
- query() is invoked in single-turn mode (maxTurns: 1, allowedTools: [])
  to behave as plain text completion by default. Both knobs are
  configurable for agentic use cases.
- Conversation history is flattened to a single prompt with role labels.
- doStream() emits text deltas as the SDK yields successive assistant
  messages. doComplete() accumulates and returns the final result.
- SDKAssistantMessageError codes (authentication_failed, billing_error,
  rate_limit, model_not_found, ...) map to AIErrorType variants.
- ClaudeCodeConfig.apiKey is optional — when omitted the SDK falls back
  to ANTHROPIC_API_KEY or local subscription credentials. The base
  validator is overridden to allow this.

Tradeoffs:
- Requires the `claude` CLI installed and logged in on the host. This
  is not suitable for typical server-side production deployments; it is
  the official path for subscription accounts.
- Higher latency (CLI process spawn) than the direct Anthropic API.
- The agent SDK is heavy. Bundle grows ~750KB; bun build now uses
  --target node so the SDK's Node built-in imports resolve correctly.

Wired into PROVIDER_REGISTRY ('claude-code'), createClaudeCodeProvider,
SUPPORTED_PROVIDERS, and re-exported from the package entry.
2026-05-21 14:16:11 +02:00
bb37e61eaf refactor: extract constants, parameterize validators, simplify factory
Quick-win refactors from the Refactoring Guru catalog:

- Replace Magic Number with Symbolic Constant: extract DEFAULT_TIMEOUT_MS,
  DEFAULT_MAX_RETRIES, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, default
  models per provider, and validation prompt into src/constants.ts.
- Parameterize Method: collapse validateTemperature / validateTopP /
  validateMaxTokens (and the inline timeout/maxRetries checks) into a
  single validateNumberInRange helper with bounds metadata.
- Inline Class / Remove Middle Man: drop the unused ProviderRegistry
  class from utils/factory.ts. createProvider now dispatches through
  the PROVIDER_REGISTRY const directly instead of a parallel switch.

Also fixes stale VERSION constant in src/index.ts (was 1.3.1).
2026-05-21 13:35:12 +02:00
664a775724 feat(docs): update README with OpenWebUI support details 2025-05-28 12:31:11 +02:00
5da37f388f feat: add Google Gemini provider integration and docs 2025-05-28 12:13:29 +02:00
aa2fd98cc1 feat: add OpenAI provider integration and examples 2025-05-28 12:04:10 +02:00
42902445fb feat: add initial implementation of Simple AI Provider package 2025-05-28 11:54:24 +02:00