Template for creating new OpenClaw skills
Go to file Use this template
ywkj 68eab3d6c1 fix: auth-rt auto-install 使用永久路径 ~/.local/share/auth-runtime
修复之前 clone 到 /tmp 后删除导致 wrapper 指向不存在路径的问题。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 20:34:21 +08:00
.forgejo/workflows feat: initial skill template 2026-03-14 10:35:01 +08:00
scripts refactor: 移除 @clawd/auth-runtime npm 依赖,改用 auth-cli.ts CLI wrapper 2026-03-20 14:44:09 +08:00
src chore: auth-rt 默认路径改为 ~/.local/bin/ 2026-03-20 18:35:37 +08:00
.gitignore feat: initial skill template 2026-03-14 10:35:01 +08:00
README.md refactor: auth-cli.ts 改用 auth-rt 二进制,更新 README 2026-03-20 18:26:32 +08:00
SKILL.md refactor: 移除 @clawd/auth-runtime npm 依赖,改用 auth-cli.ts CLI wrapper 2026-03-20 14:44:09 +08:00
install.sh fix: auth-rt auto-install 使用永久路径 ~/.local/share/auth-runtime 2026-03-20 20:34:21 +08:00
package.json refactor: 移除 @clawd/auth-runtime npm 依赖,改用 auth-cli.ts CLI wrapper 2026-03-20 14:44:09 +08:00

README.md

template-skill

新 skill 的基础模版。

认证机制auth-cli.ts

每个 skill 内置一份 src/auth-cli.ts,它是一个薄 wrapper通过 subprocess 调用 auth-rt 二进制。

不使用 npm 依赖auth-runtime 更新时只需重新编译二进制,不需要改动任何 skill。

工作原理

skill/src/index.ts
  → import { createSkillClient } from './auth-cli.ts'
  → auth-cli.ts 通过 spawnSync 调用 auth-rt 二进制
  → auth-rt 处理 token/session/request

使用方式

import { createSkillClient } from './auth-cli.ts';

const client = createSkillClient({
  apiBase: process.env.API_BASE,  // 可选
  dryRun: false,                  // 可选dry-run 模式返回模拟数据
});

// API 调用
const res = await client.post('/ecom/your/endpoint', { param: 'value' });
// res = { status: 200, body: '...' }

// 获取 session
const session = await client.session();
// session = { accessToken: '...', expiresIn: 900 }

前置条件

每台运行 skill 的机器上必须安装 auth-rt 二进制:

git clone http://192.168.0.108:3030/agent-skills/auth-runtime.git ~/clawd/skills/auth-runtime
cd ~/clawd/skills/auth-runtime && ./install.sh
# 安装到 ~/.openclaw/bin/auth-rt

确保 ~/.openclaw/bin 在 PATH 中,或通过 AUTH_RT_BIN 环境变量指定路径。

auth-runtime 更新流程

auth-runtime 代码变更后:

cd ~/clawd/skills/auth-runtime && git pull && ./install.sh

重新编译即可,无需改动任何 skill 代码

新建 skill 检查清单

  1. 从此模版创建仓库
  2. 确认 src/auth-cli.ts 已包含(直接从模版继承)
  3. src/index.tsimport { createSkillClient } from './auth-cli.ts'
  4. package.json不要 添加 @clawd/auth-runtime 依赖
  5. install.sh 中包含 auth-rt 二进制检查