← 返回
AI智能

RedLine

Live rate-limit awareness for Claude.ai (Max/Pro) and OpenAI (Plus/Pro/Codex). Never hit the red line again — your agent checks remaining budget every heartb...
Claude.ai (Max/Pro) 与 OpenAI (Plus/Pro/Codex) 的实时速率限制感知。告别限额红线——您的代理会在每次心跳时检查剩余额度。
wgj
AI智能 clawhub v0.2.0 1 版本 99896.5 Key: 无需
★ 1
Stars
📥 945
下载
💾 30
安装
1
版本
#latest

概述

Usage Pacing

Check live rate-limit usage for Claude.ai and OpenAI/Codex plans, then apply pacing tiers to avoid hitting limits.

Scripts

claude-usage

Reads the Claude Code OAuth token from macOS Keychain and calls the Anthropic usage API.

# Human-readable output with color bars
scripts/claude-usage

# JSON output (for programmatic use)
scripts/claude-usage --json

Requirements:

  • macOS with security CLI (Keychain access)
  • Claude Code OAuth token in Keychain (run claude login to set up)
  • Token needs user:profile scope (standard Claude Code login provides this)

Token location: macOS Keychain, service Claude Code-credentials, account = your macOS username.

openai-usage

Reads the OpenAI OAuth token from OpenClaw's auth-profiles and calls the ChatGPT usage API.

# Human-readable output with color bars
scripts/openai-usage

# JSON output
scripts/openai-usage --json

Requirements:

  • OpenClaw with an authenticated openai-codex profile (run openclaw auth openai-codex)
  • Auth profiles at ~/.openclaw/agents/main/agent/auth-profiles.json

Pacing Tiers

Wire both scripts into your heartbeat to automatically pace work based on remaining budget:

TierRemainingBehavior
---------------------------
🟢 GREEN>50%Normal operations
🟡 YELLOW25-50%Skip sub-agents, defer non-urgent research
🟠 ORANGE10-25%Essential replies only, no proactive checks
🔴 RED<10%Critical only, warn user

Heartbeat integration

Add to your HEARTBEAT.md:

## Usage pacing (every heartbeat)
- Run `scripts/claude-usage --json` and `scripts/openai-usage --json` to check rate limits.
- Store readings in memory/heartbeat-state.json under "usage.claude" and "usage.openai".
- Apply pacing tiers:
  - GREEN (>50% left): normal ops
  - YELLOW (25-50%): skip sub-agents, defer non-urgent research
  - ORANGE (10-25%): essential replies only, no proactive checks
  - RED (<10%): critical only, warn user
- If entering YELLOW or worse, mention it briefly when next messaging.

JSON output format

Claude (--json):

{
  "five_hour": {"utilization": 39.0, "resets_at": "2026-02-18T04:00:00Z"},
  "seven_day": {"utilization": 12.0, "resets_at": "2026-02-24T03:00:00Z"},
  "extra_usage": {"is_enabled": true, "used_credits": 5044, "monthly_limit": 5000}
}

OpenAI (--json):

{
  "plan_type": "plus",
  "rate_limit": {
    "primary_window": {"used_percent": 0, "limit_window_seconds": 10800, "reset_at": 1771556400},
    "secondary_window": {"used_percent": 34, "limit_window_seconds": 86400, "reset_at": 1771556400}
  },
  "credits": {"balance": "882.99"}
}

版本历史

共 1 个版本

  • v0.2.0 当前
    2026-03-29 06:43 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,100
ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 839 📥 213,425
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,061 📥 799,434