Skip to main content

Module limit_heartbeat

Module limit_heartbeat 

Source
Expand description

Limit heartbeat: the only way the node reads provider limits on purpose.

One light service PTY per signed-in provider account (claude, codex, grok, kimi), outside the node’s managed sessions: never shown in HQ, no record, no m4a account, no workspace. It runs the provider CLI in its own scratch folder and, every interval (env HATCHERY_LIMIT_HEARTBEAT_SECS, default 45, 15..=3600; 0 turns it off), types the provider’s own local limit screen (/usage for claude, grok and kimi, /status for codex), reads it off the screen into crate::provider_limits (source heartbeat) and closes it with Escape. Only slash commands are typed: no prompt, no model turn. A CLI that is not signed in (none, or a screen that asks to log in) gets no heartbeat until a later check. grok and kimi have no auth status: their limit screen is the sign-in test. Tokens, OAuth and credential files are never touched.

A first start in the scratch folder may ask whether to trust it; the heartbeat answers the default (“yes”) for its own folder only.

Constants§

PROVIDERS
RELAUNCH_MIN
A CLI start may itself cost the account (start-up requests), so the PTY is kept for the life of the node and a new one is started at most this often; the readings in between are slash commands into the same CLI.

Functions§

command_for
The slash command that shows provider’s limits.
interval_from
The heartbeat interval: None when off.
relaunch_after
Wait before the next start after a session that lived lived.
scratch_base
start
state_dir: the folder of the node state file.
trust_keys
Keys that answer a start-up question about trusting the heartbeat’s own scratch folder with “yes”: Enter when the selected option already says yes, else Down then Enter (claude selects “No, exit” first). None when the screen asks nothing of the kind.