@antseed/provider-claude-oauth

中文文档
0.1.64发布于 2026/11/07TypeScriptES Module近 30 天下载 2624

Third-party Anthropic Claude provider with OAuth authentication

原始使用文档
文档目录11 节
  1. How to Create a Plugin
  2. Plugin Manifest Format
  3. ConfigField Types
  4. Using provider-core
  5. Testing Locally
  6. Publishing to npm
  7. Installing via antseed plugin add
  8. Configuration Reference
  9. Persistent authentication for development/testing
  10. Failure isolation
  11. License

@antseed/provider-claude-oauth

Testing and development only. This plugin uses OAuth credentials from a personal Claude subscription. Reselling subscription-based access violates Anthropic's Terms of Service and is not permitted. Use this plugin only for local development, testing, and demo purposes.

Third-party Anthropic Claude provider plugin with OAuth authentication for Antseed. This plugin demonstrates how a third-party developer can build, test, and publish an Antseed provider plugin using @antseed/provider-core.

How to Create a Plugin

  1. Create a new directory under plugins/ (or anywhere on disk).
  2. Add a package.json with @antseed/provider-core as a dependency and @antseed/node as a peer dependency.
  3. Implement and default-export an AntseedProviderPlugin object from src/index.ts.
  4. Build with tsc and test with vitest.

Plugin Manifest Format

Every provider plugin must default-export an object satisfying AntseedProviderPlugin:

import type { AntseedProviderPlugin, ConfigField } from '@antseed/node';

const plugin: AntseedProviderPlugin = {
  name: 'my-provider',           // unique plugin name
  displayName: 'My Provider',    // human-readable label
  version: '0.1.0',
  type: 'provider',
  description: 'Description of the provider',
  configSchema: [                // fields the user fills in
    { key: 'API_KEY', label: 'API Key', type: 'secret', required: true },
  ],
  createProvider(config) {
    // Return a Provider instance
  },
};
export default plugin;

ConfigField Types

TypeDescription
stringPlain text input
numberNumeric input
booleanToggle / checkbox
secretMasked input (tokens, keys)
string[]Comma-separated list of strings

Using provider-core

The @antseed/provider-core package provides reusable building blocks:

  • BaseProvider -- Implements the Provider interface and wires up HttpRelay.
  • StaticTokenProvider -- Wraps a static API key with no refresh logic.
  • OAuthTokenProvider -- Manages OAuth access/refresh token pairs with automatic renewal.
  • HttpRelay -- Forwards requests to an upstream API with auth header swapping, model validation, and concurrency control.
import { BaseProvider, OAuthTokenProvider, StaticTokenProvider } from '@antseed/provider-core';

Testing Locally

# Install dependencies
npm install

# Build the plugin
npm run build

# Run tests
npm test

To test the plugin end-to-end with a local Antseed node, link it:

cd plugins/provider-claude-oauth
npm link

cd /path/to/your/antseed-project
npm link @anthropic/provider-claude-oauth

Then configure the plugin in your node's plugin config with the required config fields.

Publishing to npm

  1. Ensure package.json has the correct name, version, and description.
  2. Build the plugin: npm run build
  3. Login to npm: npm login
  4. Publish: npm publish --access public

For scoped packages like @anthropic/provider-claude-oauth, use --access public to publish as a public package.

Installing via antseed plugin add

Once published, users can install the plugin:

antseed plugin add @anthropic/provider-claude-oauth

This will download the plugin from npm, register it with the local Antseed node, and prompt the user to configure the required fields (access token, etc.).

Configuration Reference

KeyTypeRequiredDefaultDescription
CLAUDE_ACCESS_TOKENsecretConditional--Required unless an existing credential file supplies it
CLAUDE_AUTH_FILEstringNo--Writable development/testing OAuth credential file
CLAUDE_REFRESH_TOKENsecretNo--OAuth refresh token for auto-renewal
CLAUDE_TOKEN_EXPIRES_ATnumberNo--Epoch ms when access token expires
CLAUDE_OAUTH_CLIENT_IDstringYes--OAuth application client ID used when refreshing tokens
ANTSEED_INPUT_USD_PER_MILLIONnumberNo10Input token price (USD per 1M)
ANTSEED_OUTPUT_USD_PER_MILLIONnumberNo10Output token price (USD per 1M)
ANTSEED_MAX_CONCURRENCYnumberNo5Max concurrent requests
ANTSEED_ALLOWED_SERVICESstring[]No--Comma-separated list of service IDs

Persistent authentication for development/testing

Set CLAUDE_AUTH_FILE to a file in a private, writable directory that survives restarts. Create the directory beforehand, restrict its permissions, and use an absolute path. The plugin creates credential files with mode 0600 and atomically replaces them after refresh. Files are plaintext credentials, not encrypted storage; keep them out of version control and protect any backups.

  • On first use, supply CLAUDE_ACCESS_TOKEN and CLAUDE_REFRESH_TOKEN, plus CLAUDE_TOKEN_EXPIRES_AT (epoch milliseconds) when known. These initialize the file only if it does not exist.
  • An existing file is authoritative, even if environment credentials differ. Its JSON fields are accessToken, refreshToken, and expiresAt (epoch milliseconds). Environment credentials can be removed after initialization.
  • The plugin saves rotated tokens before completing refresh. If saving fails, it retains the new tokens in memory and retries saving rather than reverting to the old file. Fix storage errors before restarting: unsaved rotations cannot survive a process crash.
  • Only one process may own/refresh a credential file and its OAuth session. This is not a cross-process credential synchronization mechanism.
  • To repair revoked credentials, stop other credential writers and atomically replace the file with a valid token pair and expiry. The next request or health probe reloads it; restarting the development process is not required. Invalid files are rejected rather than silently replaced with older environment values.
  • Without CLAUDE_AUTH_FILE, environment-only behavior remains supported. Without a refresh token, the access token is static and stops working when it expires.

Failure isolation

With model health checks enabled (the CLI default), an OAuth refresh failure at provider initialization leaves that provider unavailable instead of terminating the multi-provider development process. Other providers continue normally. Health probes retry and restore each affected service only after it responds successfully. Refresh attempts have exponential backoff from one second to a maximum of one minute; actual retries occur on requests/probes, not on a separate refresh timer. The default health sweep interval is five minutes.

Missing configuration, invalid credential files, and unrelated initialization errors remain fatal. Disabling model health checks retains fail-fast initialization, since no background recovery loop would be running. A revoked refresh token still requires re-authentication; retries cannot make revoked credentials valid.

This plugin remains for testing and development only, not subscription-access resale. No change to authentication reliability changes that restriction.

License

See the root repository LICENSE file.

版本与发布记录

@antseed/provider-claude-oauth 共发布 65 个版本,首次发布于 2026/02/24;过去 12 个月发布了 65 个版本。

版本发布日期距今
0.1.64latest2026/11/07今天
0.1.632026/11/043 天前
0.1.622026/11/043 天前
0.1.612026/11/016 天前
0.1.602026/10/299 天前
0.1.592026/10/2612 天前

关于 @antseed/provider-claude-oauth 的常见问题

@antseed/provider-claude-oauth 是什么?

Third-party Anthropic Claude provider with OAuth authentication

如何安装 @antseed/provider-claude-oauth?

在项目目录运行 npm install @antseed/provider-claude-oauth,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@antseed/node(>=0.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@antseed/provider-claude-oauth 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@antseed/provider-claude-oauth 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@antseed/provider-claude-oauth 可以商用吗?

@antseed/provider-claude-oauth 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@antseed/provider-claude-oauth 的下载量有多少?

根据 npm 官方下载统计,@antseed/provider-claude-oauth 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,624 次,日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@antseed/provider-claude-oauth 还在维护吗?

最新版本 0.1.64 发布于 2026/11/07(今天);至今共发布 65 个版本,其中过去 12 个月发布了 65 个;首次发布于 2026/02/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。