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.
72 lines
1.7 KiB
JSON
72 lines
1.7 KiB
JSON
{
|
|
"name": "simple-ai-provider",
|
|
"version": "2.0.1",
|
|
"description": "A simple and extensible AI provider package for easy integration of multiple AI services",
|
|
"main": "dist/index.js",
|
|
"module": "dist/index.mjs",
|
|
"types": "dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"import": "./dist/index.mjs",
|
|
"require": "./dist/index.js",
|
|
"types": "./dist/index.d.ts"
|
|
}
|
|
},
|
|
"files": [
|
|
"dist",
|
|
"README.md",
|
|
"package.json"
|
|
],
|
|
"scripts": {
|
|
"build": "bun run build:clean && bun run build:types && bun run build:esm && bun run build:cjs",
|
|
"build:clean": "rm -rf dist",
|
|
"build:types": "tsc --project tsconfig.build.json",
|
|
"build:esm": "bun build src/index.ts --outfile dist/index.mjs --format esm --target node",
|
|
"build:cjs": "bun build src/index.ts --outfile dist/index.js --format cjs --target node",
|
|
"dev": "bun run src/index.ts",
|
|
"test": "bun test",
|
|
"prepublishOnly": "bun run build"
|
|
},
|
|
"keywords": [
|
|
"ai",
|
|
"claude",
|
|
"anthropic",
|
|
"openai",
|
|
"gpt",
|
|
"gemini",
|
|
"google",
|
|
"provider",
|
|
"typescript",
|
|
"nodejs",
|
|
"openwebui",
|
|
"llm",
|
|
"unified-api",
|
|
"structured-output",
|
|
"response-types",
|
|
"type-safe"
|
|
],
|
|
"author": "Jan-Marlon Leibl",
|
|
"license": "MIT",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://gitea.jleibl.net/jleibl/simple-ai-provider.git"
|
|
},
|
|
"dependencies": {
|
|
"@anthropic-ai/claude-agent-sdk": "^0.3.146",
|
|
"@anthropic-ai/sdk": "^0.97.0",
|
|
"@google/genai": "^2.5.0",
|
|
"openai": "^6.0.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/bun": "^1.3.14",
|
|
"@types/node": "^25.0.0",
|
|
"typescript": "^6.0.0"
|
|
},
|
|
"peerDependencies": {
|
|
"typescript": "^5 || ^6"
|
|
},
|
|
"engines": {
|
|
"node": ">=18.0.0"
|
|
}
|
|
}
|