Files
open-agent-sdk-typescript/src/providers/index.ts
T
idoubi 85dff47d74 feat: add skills system, hooks integration, and OpenAI-compatible provider
- Add skill system with types, registry, SkillTool, and 5 bundled skills
  (simplify, commit, review, debug, test)
- Integrate hooks into QueryEngine at 9 lifecycle points (SessionStart,
  UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure,
  PreCompact, PostCompact, Stop, SessionEnd)
- Add LLM provider abstraction supporting both Anthropic Messages API
  and OpenAI Chat Completions API (works with GPT, DeepSeek, Qwen, etc.)
- Add CODEANY_API_TYPE env var ('anthropic-messages' | 'openai-completions')
  with auto-detection from model name
- Remove all ANTHROPIC_* env var references, only support CODEANY_* prefix
- Add model pricing and context windows for OpenAI/DeepSeek models
- Remove direct @anthropic-ai/sdk dependency from all files except the
  Anthropic provider (types.ts, engine.ts, etc. are now provider-agnostic)
- Add PermissionBehavior type export
- Bump version to 0.2.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 23:29:29 +08:00

35 lines
1.1 KiB
TypeScript

/**
* LLM Provider Factory
*
* Creates the appropriate provider based on API type configuration.
*/
export type { ApiType, LLMProvider, CreateMessageParams, CreateMessageResponse, NormalizedMessageParam, NormalizedContentBlock, NormalizedTool, NormalizedResponseBlock } from './types.js'
export { AnthropicProvider } from './anthropic.js'
export { OpenAIProvider } from './openai.js'
import type { ApiType, LLMProvider } from './types.js'
import { AnthropicProvider } from './anthropic.js'
import { OpenAIProvider } from './openai.js'
/**
* Create an LLM provider based on the API type.
*
* @param apiType - 'anthropic-messages' or 'openai-completions'
* @param opts - API credentials
*/
export function createProvider(
apiType: ApiType,
opts: { apiKey?: string; baseURL?: string },
): LLMProvider {
switch (apiType) {
case 'anthropic-messages':
return new AnthropicProvider(opts)
case 'openai-completions':
return new OpenAIProvider(opts)
default:
throw new Error(`Unsupported API type: ${apiType}. Use 'anthropic-messages' or 'openai-completions'.`)
}
}