SuperAPI AI 工具集

claude-connect

智能体与模型

查看项目

更新于 10-16 05:57

技能介绍

claude-connect 是一个用于把 Claude 订阅连接到 Clawdbot 的技能,目标是让连接保持 24/7 在线。它会在安装后自动完成令牌链接,并持续自动刷新令牌。

用途 该技能主要解决 Clawdbot 的 OAuth 认证配置问题。当运行 clawdbot onboard --auth-choice claude-cli 时,有时不会正确地把 OAuth 令牌写入 auth-profiles.json,导致 Clawdbot 无法使用令牌。claude-connect 通过读取 macOS Keychain 中的 Claude OAuth 令牌,并以正确的 OAuth 格式写入 Clawdbot 配置来修复该问题。

主要能力

  • 从 Keychain 读取 Claude OAuth 令牌(Claude CLI 存储令牌的位置)。
  • 将令牌以正确的 OAuth 格式写入 ~/.clawdbot/agents/main/agent/auth-profiles.json,示例结构包含 type、provider、access、refresh、expires 字段。
  • 通过 launchd 每 2 小时自动刷新一次令牌(在过期前刷新)。
  • 在成功或失败时发送通知。
  • 与 clawdbot onboard 配合使用,修复 OAuth auth-profiles 问题。
  • 提供手动刷新、状态检查、禁用通知、卸载和升级等操作。

使用方式 快速开始:

  1. 安装技能: clawdhub install claude-connect cd ~/clawd/skills/claude-connect

  2. 确保 Claude CLI 已登录: claude auth

按浏览器登录流程操作

  1. 运行安装脚本: ./install.sh

安装脚本会验证 Claude CLI 是否已设置、创建配置文件、设置自动刷新任务(launchd),并运行首次刷新进行测试。

手动安装: 复制示例配置: cp claude-oauth-refresh-config.example.json claude-oauth-refresh-config.json

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

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

安装 launchd 任务(可选,用于自动刷新): 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:刷新活动日志位置。
  • 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 models status

禁用通知:可让 Clawdbot 执行“Disable Claude refresh success notifications”,或编辑配置把 notifications.on_success 设为 false。

自动刷新控制:

停止自动刷新

launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist

启动自动刷新

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

检查是否运行

launchctl list | grep claude

工作原理 刷新流程:从 Keychain 读取 Claude Code-credentials 中的 OAuth 令牌;检查过期时间,仅在剩余不足 30 分钟(或使用 --force)时刷新;调用 OAuth API 获取新的 access 与 refresh 令牌;更新 auth-profiles.json 为正确的 OAuth 格式;把新令牌同步回 Keychain;重启 Gateway 以加载新令牌;可选发送成功/失败通知。 自动刷新:通过 ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist 每 2 小时运行一次。

适用场景

  • 使用 Clawdbot 并希望连接 Claude 订阅、保持长期在线。
  • 遇到 clawdbot onboard 后 OAuth 令牌未正确写入、Clawdbot 无法使用令牌的情况。
  • 需要令牌在过期前自动刷新、避免认证失败。
  • 希望在刷新成功或失败时收到通知。

限制与注意事项

  • 该技能依赖 macOS Keychain 与 launchd,因此从资料看主要面向 macOS 环境。
  • 需要先通过 Claude CLI 登录(claude auth)。
  • 通知功能依赖 Telegram 聊天 ID(notification_target)。
  • 资料未提供其他平台支持、收费或价格信息。

故障排查

  • onboard 后 OAuth 不工作:运行 ./refresh-token.sh --force 以正确 OAuth 格式写入令牌。
  • 令牌持续过期:确保 launchd 任务在运行(launchctl load ... 并 launchctl list | grep claude)。
  • Keychain 中没有令牌:先用 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。另见 QUICKSTART.md(60 秒设置指南)、UPGRADE.md(从旧版本升级)、Clawdbot 文档(模型认证)。