OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  claude-connect: 快速连接 Claude 与 Clawdbot 并保持同步

claude-connect: 快速连接 Claude 与 Clawdbot 并保持同步

 
  skills ·  2026-02-03 22:36:01 · 3 次点击  · 0 条评论  

名称: claude-connect
描述: "一键将 Claude 订阅连接到 Clawdbot,并保持 24/7 持续在线。安装后运行即可链接您的订阅,之后令牌将自动永久刷新。"


claude-connect

一步将您的 Claude 订阅连接到 Clawdbot。

自动完成以下操作:
- ✅ 从钥匙串读取 Claude OAuth 令牌
- ✅ 以正确的 OAuth 格式写入 Clawdbot
- ✅ 每 2 小时自动刷新(在令牌过期前)
- ✅ 成功/失败时通知您
- ✅ 与 clawdbot onboard 兼容(修复 OAuth auth-profiles 错误)


快速开始

1. 安装技能:

clawdhub install claude-connect
cd ~/clawd/skills/claude-connect

2. 确保 Claude CLI 已登录:

claude auth
# 按照浏览器登录流程操作

3. 运行安装脚本:

./install.sh

完成!令牌将每 2 小时自动刷新。


功能说明

修复 clawdbot onboard 的 OAuth 错误

运行 clawdbot onboard --auth-choice claude-cli 时,有时无法正确将 OAuth 令牌写入 auth-profiles.json

本技能:
1. 从 macOS 钥匙串(Claude CLI 存储令牌的位置)读取 OAuth 令牌
2. 以正确的 OAuth 格式写入 ~/.clawdbot/agents/main/agent/auth-profiles.json
json { "profiles": { "anthropic:claude-cli": { "type": "oauth", "provider": "anthropic", "access": "sk-ant-...", "refresh": "sk-ant-ort...", "expires": 1234567890 } } }
3. 设置自动刷新(通过 launchd 每 2 小时运行)
4. 保持您的连接 24/7 在线


安装

自动安装(推荐)

cd ~/clawd/skills/claude-connect
./install.sh

安装程序将:
- ✅ 验证 Claude CLI 是否已设置
- ✅ 创建配置文件
- ✅ 设置自动刷新任务(launchd)
- ✅ 运行首次刷新以测试

手动安装

  1. 复制示例配置文件:
    bash cp claude-oauth-refresh-config.example.json claude-oauth-refresh-config.json

  2. 编辑配置(可选):
    bash nano claude-oauth-refresh-config.json

  3. 测试刷新:
    bash ./refresh-token.sh --force

  4. 安装 launchd 任务(可选 - 用于自动刷新):
    bash cp com.clawdbot.claude-oauth-refresher.plist ~/Library/LaunchAgents/ launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist


配置

编辑 claude-oauth-refresh-config.json

{
  "refresh_buffer_minutes": 30,
  "log_file": "~/clawd/logs/claude-oauth-refresh.log",
  "notifications": {
    "on_success": true,
    "on_failure": true
  },
  "notification_target": "YOUR_CHAT_ID"
}

选项说明:
- refresh_buffer_minutes:在令牌剩余指定分钟数时刷新(默认:30)
- log_file:刷新活动日志的存储位置
- notifications.on_success:成功刷新时通知(默认:true)
- notifications.on_failure:失败时通知(默认:true)
- notification_target:您的 Telegram 聊天 ID(留空则禁用通知)


使用

手动刷新

# 立即刷新(即使未过期)
./refresh-token.sh --force

# 仅在需要时刷新
./refresh-token.sh

检查状态

# 查看最近日志
tail ~/clawd/logs/claude-oauth-refresh.log

# 检查认证配置文件
cat ~/.clawdbot/agents/main/agent/auth-profiles.json | jq '.profiles."anthropic:claude-cli"'

# 检查 Clawdbot 状态
clawdbot models status

禁用通知

向 Clawdbot 发送指令:

禁用 Claude 刷新成功通知

或编辑配置:

{
  "notifications": {
    "on_success": false,
    "on_failure": true
  }
}

工作原理

刷新流程

  1. 从钥匙串读取:从 Claude Code-credentials 获取 OAuth 令牌
  2. 检查过期时间:仅在剩余时间 < 30 分钟时刷新(或使用 --force 参数)
  3. 调用 OAuth API:获取新的访问令牌和刷新令牌
  4. 更新 auth-profiles.json:写入正确的 OAuth 格式
  5. 更新钥匙串:将新令牌同步回钥匙串
  6. 重启网关:使新令牌生效
  7. 通知:发送成功/失败消息(可选)

自动刷新(launchd)

通过 ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist 每 2 小时运行一次

控制命令:

# 停止自动刷新
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist

# 启动自动刷新
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist

# 检查是否运行
launchctl list | grep claude

故障排除

执行 onboard 后 OAuth 不工作

症状clawdbot onboard --auth-choice claude-cli 完成但 Clawdbot 无法使用令牌

修复方法:

cd ~/clawd/skills/claude-connect
./refresh-token.sh --force

这将以正确的 OAuth 格式写入令牌。

令牌持续过期

症状:8 小时后认证持续失败

修复方法:确保 launchd 任务正在运行:

launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
launchctl list | grep claude

钥匙串中无令牌

症状No 'Claude Code-credentials' entries found

修复方法:使用 Claude CLI 登录:

claude auth
# 按照浏览器流程操作

然后再次运行刷新:

./refresh-token.sh --force

卸载

cd ~/clawd/skills/claude-connect
./uninstall.sh

或手动卸载:

# 停止自动刷新
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
rm ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist

# 删除技能
rm -rf ~/clawd/skills/claude-connect

升级

如果您之前安装了旧版本:

cd ~/clawd/skills/claude-connect
./validate-update.sh  # 检查变更内容
clawdhub update claude-connect  # 更新到最新版本
./install.sh  # 如有需要,重新运行安装程序

相关文档


版本: 1.1.0
作者: TunaIssaCoding
许可证: MIT
仓库: https://github.com/TunaIssaCoding/claude-connect

3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor