How ahin99/token_restart_bot works
tokenbot is a macOS daemon-like utility that keeps Claude Code and Codex five-hour usage windows rolling. Its principal workflow is a one-minute launchd tick: inspect local CLI activity, determine whether a window has expired (including buffer and quiet-hour rules), send a short provider message when due, then record the outcome for later ticks and status checks. The README documents status, plan, manual ping, and install/uninstall capabilities. The sampled source is partial, so relationships for unsampled command handlers rely on README statements.
Main entry points: tokenbot.py Tick coordinator
Components 13
Scheduling and runtime
- Tick coordinator
tokenbot.py - Launchd registration
tokenbot.py
Window and provider
- Activity reader
tokenbot.py - Window scheduler
tokenbot.py - Quiet-hour rules
tokenbot.py - Provider ping
tokenbot.py
Operations and state
- Runtime state
tokenbot.py - Bot log
tokenbot.py - Status and plan
tokenbot.py
Other components
- Operator
- launchd timer
- Claude / Codex CLI
- Provider activity logs
Connections 14
- launchd timer → Tick coordinator: runs each minute
README.md - Operator → Tick coordinator: runs tick
README.md - Tick coordinator → Activity reader: collects activity
README.md - Activity reader → Provider activity logs: reads timestamps
README.md - Tick coordinator → Window scheduler: checks window
README.md - Window scheduler → Quiet-hour rules: checks allowed time
tokenbot.py - Tick coordinator → Provider ping: sends when due
README.md - Provider ping → Claude / Codex CLI: runs CLI command
README.md - Tick coordinator → Runtime state: records outcome
README.md - Tick coordinator → Bot log: writes results
README.md - Operator → Status and plan: requests status or plan
README.md - Status and plan → Runtime state: reads state
README.md - Operator → Launchd registration: registers service
README.md - Launchd registration → launchd timer: configures timer
README.md