Shared auth runtime for OpenClaw skills
  • JavaScript 52.9%
  • TypeScript 47.1%
Find a file
ywkj b11d40e924
All checks were successful
test-auth-runtime / test (push) Successful in 1m1s
fix(ci): run auth tests with Bun test runner
2026-07-15 09:09:11 +08:00
.forgejo/workflows fix: allow business-only skill runtime auth 2026-07-15 09:07:50 +08:00
dist fix: allow business-only skill runtime auth 2026-07-15 09:07:50 +08:00
src fix: allow business-only skill runtime auth 2026-07-15 09:07:50 +08:00
tests fix: allow business-only skill runtime auth 2026-07-15 09:07:50 +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 fix(ci): run auth tests with Bun test runner 2026-07-15 09:09:11 +08:00
README.md fix: allow business-only skill runtime auth 2026-07-15 09:07:50 +08:00
tsconfig.json feat: initial auth-runtime module 2026-03-12 07:33:43 +08:00

@clawd/auth-runtime

Codex Skill 运行时授权库。它只负责消费 runtime auth 文件并调用业务 API不负责登录、SkillHub 分发授权或 CI 注册。

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

<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、浏览器 cookie、client key 或 skreg_* registry token也不做 token 缓存。

配置文件

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

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

  • businessApiKey: 业务 API 请求 tokenget/post/... 使用它。
  • apiBase: 业务 API 网关地址。
  • apiKey: 可选模型网关 key只有 modelConfig() 使用它。
  • modelBase: 可选模型网关地址;纯业务 API skill 不需要模型配置。
  • 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;纯业务 API Skill 只要求 businessApiKeyapiBase

构建

bun run build