feat(users): PATCH /users/{id}/bind-agent to backfill agents row #20

Merged
hzhang merged 1 commits from feat/user-bind-agent into main 2026-05-22 18:58:25 +00:00
Contributor

Companion endpoint for the upcoming cli hf user bind-agent subcommand. Lets admin retroactively bind an existing user to (agent_id, claw_identifier) — needed because hf user create never accepted those flags, so all 6 t2-agent users on prod (zhi/lyn/mirror/sherlock/orion/nav) have user rows but no agents row.

  • PATCH /users/{identifier}/bind-agent body {agent_id, claw_identifier} (both required)
  • perm: account.create (admin auto) — symmetric with POST /users
  • idempotent: re-binding same pair → 200 no-op
  • 409 if user is already bound to a different pair, or if agent_id is taken by another user

Pairs with HF.Cli hf user create --agent-id/--claw-identifier + hf user bind-agent (next PR).

🤖 Generated with Claude Code

Companion endpoint for the upcoming cli `hf user bind-agent` subcommand. Lets admin retroactively bind an existing user to `(agent_id, claw_identifier)` — needed because `hf user create` never accepted those flags, so all 6 t2-agent users on prod (zhi/lyn/mirror/sherlock/orion/nav) have user rows but no agents row. - `PATCH /users/{identifier}/bind-agent` body `{agent_id, claw_identifier}` (both required) - perm: `account.create` (admin auto) — symmetric with `POST /users` - idempotent: re-binding same pair → 200 no-op - 409 if user is already bound to a different pair, or if `agent_id` is taken by another user Pairs with HF.Cli `hf user create --agent-id/--claw-identifier` + `hf user bind-agent` (next PR). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hzhang added 1 commit 2026-05-22 18:58:21 +00:00
Companion endpoint for the cli's upcoming `hf user bind-agent` subcommand.
Lets admin retroactively bind an existing user to (agent_id,
claw_identifier) when that user was created before `hf user create`
supported the binding flags (i.e. all of zhi/lyn/mirror/sherlock/orion/
nav on prod today — agents table has 0 rows even though their user rows
exist).

Schema:
  PATCH /users/{identifier}/bind-agent
  body: {agent_id: str, claw_identifier: str}  // both required
  perm: account.create (admin auto)            // same as POST /users

Behaviour:
  * idempotent: re-bind to the same (agent_id, claw_identifier) → 200
    no-op, no extra row
  * 409 if user is already bound to a different pair
  * 409 if requested agent_id is already in use by another user
  * creates the agents row inline; subsequent /schedule-types/agent/
    {agent_id}/assign etc. then work normally

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

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hzhang merged commit b8e413a7ea into main 2026-05-22 18:58:25 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zhi/HarborForge.Backend#20