docs(spec): copy Grok Bot handling into relay-control + dynamic rules source

Merged
AG
3d ago
+418-0

Spec only: no code, migration or deploy changes. Requested by Khaliq.

Adds docs/specs/grok-bot-dynamic-prompt.md, in three phases:

  1. Copy, not migration. Cloud's grokRoutinePrompt, connect_grok_bot_routine (webhook and polling) and what they directly need are copied into relay-control as is. That includes sender-check.ts, the parsers, routine headers, and Cloud-shaped relay.message wakes. It also includes get_event/get_recent_events for Grok connections, plus reply-mode and polling settings, because the copied prompt calls them. The copy sits behind a default-off flag. Cloud is untouched and keeps working. There is no cutover, move of bots or Cloud rollback.
  2. Dynamic prompt. The pasted routine prompt becomes a small bootstrap that calls get_agent_rules on every wake. Rules are a versioned bundle in the repo, tagged by audience (grok-bot / lead / worker), plus a per-org overlay, served over MCP and HTTP (ETag). Rules v1 is the copied prompt text, so behaviour is the same on day one. SKILL.md shrinks to the connect steps. Layered leads fetch audience=lead at startup and fall back to a pinned snapshot.
  3. Rules. Draft text for the orchestration-only rule (Grok bots don't code or decide) and the stall-watch rule.

Open decisions D1–D8 for Khaliq are in §6.

Spec only; awaiting Khaliq's review. Not for merge until the open questions are decided.

🤖 Generated with Claude Code