claude-cli: pause until reset on session-limit; harden capability-set loader

- On a Claude Code session/usage limit ('resets 7:10pm'), _call_claude_cli now
  pauses IN PLACE until the stated reset time + CLAUDE_CLI_LIMIT_BUFFER_SECONDS
  (default 60s past), then retries — up to CLAUDE_CLI_LIMIT_MAX_WAITS windows.
  Parses 12-hour reset times to their next occurrence; falls back to a fixed
  wait when no time is present. Makes long unattended runs survive reset windows.
- load_library() reports invalid capability-set JSON as a clean SystemExit
  (line number + reason) instead of a traceback; fixed a trailing-comma typo in
  data/capability_sets/dx02.json.
- Docs: USAGE.md + .env.example document the claude-cli provider and its knobs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 08:42:19 -04:00
parent fefda7481f
commit 07eb9a5411
6 changed files with 170 additions and 27 deletions

View File

@@ -1,12 +1,19 @@
# Copy to .env and fill in. The loop runs WITHOUT a key using a mock reasoner.
# Copy to .env and fill in.
# --- LLM provider ---
# LLM_PROVIDER: anthropic | openai | gemini (auto-detected if blank).
LLM_PROVIDER=anthropic
# LLM_PROVIDER: claude-cli | anthropic | openai | gemini.
# claude-cli = run inference through Claude Code headless mode (`claude -p`),
# the sanctioned way to use a Claude subscription programmatically.
# (Direct-API calls with a Claude Code OAuth token are policy-blocked.)
LLM_PROVIDER=claude-cli
CLAUDE_CLI_MODEL=sonnet
CLAUDE_CLI_TIMEOUT=300
# On a session-limit hit ("resets 7:10pm"), pause until reset + buffer, then retry:
CLAUDE_CLI_LIMIT_BUFFER_SECONDS=60
CLAUDE_CLI_LIMIT_MAX_WAITS=6
CLAUDE_CLI_LIMIT_FALLBACK_WAIT_SECONDS=3600
# Anthropic via OAuth (Claude subscription) — token from ANTHROPIC_OAUTH_TOKEN,
# else the Claude Code credential in the macOS keychain (auto-refreshed by
# Claude Code; run any `claude -p ...` command if it has expired).
# Direct Anthropic API (real API key) — use LLM_PROVIDER=anthropic:
LLM_MODEL=claude-sonnet-5
ANTHROPIC_EFFORT=low # low | medium | high | max
ANTHROPIC_USE_KEYCHAIN=1