Shared auth runtime for OpenClaw skills
  • JavaScript 56.1%
  • TypeScript 43.9%
Find a file
2026-06-05 08:10:00 +08:00
.forgejo/workflows fix: go.mod 降级到 1.22,CI 加 GOTOOLCHAIN=local 2026-03-20 21:24:22 +08:00
dist feat: update skill auth runtime config 2026-06-05 08:10:00 +08:00
src feat: update skill auth runtime config 2026-06-05 08:10:00 +08:00
tests feat: update skill auth runtime config 2026-06-05 08:10:00 +08:00
.gitignore feat: Go 重写 auth-rt CLI,真正的零依赖二进制 2026-03-20 20:51:45 +08:00
bun.lock feat: initial auth-runtime module 2026-03-12 07:33:43 +08:00
package.json refactor(auth): use codex session runtime 2026-05-07 07:28:46 +08:00
README.md feat: update skill auth runtime config 2026-06-05 08:10:00 +08:00
tsconfig.json feat: initial auth-runtime module 2026-03-12 07:33:43 +08:00

@clawd/auth-runtime

Codex Skill 运行时授权库。当前 TS skill 直接依赖这个包,不需要 Go 二进制。

当前模型支持两种授权文件位置:

<workspace>/.yuanwei/auth.json
~/.yuanwei/auth.json

运行时会优先从当前工作目录向上查找 <workspace>/.yuanwei/auth.json,用于 Web / server-side Codex 工作区;找不到时再读取 ~/.yuanwei/auth.json,用于桌面 Codex 客户端。

不读取 ~/.codex/auth.json,不读取旧的 ~/.codex/yuanwei/session.json,不读取环境变量 token alias也不做 token 缓存。

配置文件

{
  "apiKey": "sk_xxx",
  "businessApiKey": "better-auth-session-token-or-platform-key",
  "apiBase": "https://api-gw.yuanwei-lnc.com",
  "modelBase": "https://ai.yuanwei-lnc.com/v1"
}

auth-runtime 每次业务请求前都会重新读取这个文件。

  • apiKey: 模型网关 keymodelConfig() 使用它。
  • businessApiKey: 业务 API 请求 tokenget/post/... 使用它;未配置时回退到 apiKey
  • apiBase: 业务 API 网关地址。
  • modelBase: 模型 OpenAI-compatible 地址。

使用

import { createSkillClient } from '@clawd/auth-runtime';

const client = createSkillClient();

const result = await client.post('/ecom/tasks/scrape', {
  url: 'https://detail.1688.com/offer/123.html',
});

const model = client.modelConfig();

console.log(result.status, model.baseURL);

业务 API 请求会自动带:

Authorization: Bearer <businessApiKey>

模型调用使用同一个 apiKeymodelBase

构建

bun run build