feat(cli): add 'hf agent status' wrapper for POST /calendar/agent/status

The plan-schedule workflow needs to report agent runtime status
(idle/busy/on_call/exhausted/offline) at the end of planning, but the
cli had no wrapper for this — workflows were dropping inline curl in
the middle of their procedure to hit the backend.

This adds 'hf agent status --set <status> [--reason ...] [--recovery-at ...]'.
The endpoint identifies the agent purely from X-Agent-ID + X-Claw-Identifier
headers (no token), so the cli reads AGENT_ID from env and falls back
to hostname() for CLAW_IDENTIFIER if it isn't set — same convention
the openclaw plugin uses. Refuses to send if AGENT_ID env is missing,
since this only makes sense from a pcexec/agent runtime context.

Surface entry added so 'hf --help' lists it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hanghang zhang
2026-05-22 19:08:27 +01:00
parent 8dd58bad43
commit 6ace6f2594
3 changed files with 160 additions and 0 deletions

View File

@@ -54,6 +54,19 @@ func main() {
discordID = filtered[1]
}
commands.RunUserUpdateDiscordID(filtered[0], discordID, tokenFlag)
case "agent":
// `hf agent <sub>` — currently only `status` is implemented (wraps
// `POST /calendar/agent/status`, identifies caller via
// AGENT_ID/CLAW_IDENTIFIER env, no token needed).
if len(args) < 2 {
output.Error("usage: hf agent status --set <idle|busy|on_call|exhausted|offline>")
}
switch args[1] {
case "status":
commands.RunAgentStatus(args[2:])
default:
output.Errorf("unknown agent subcommand: %s", args[1])
}
default:
if group, ok := findGroup(args[0]); ok {
handleGroup(group, args[1:])