feat(cli): add Codex-aware auto peer delivery

Default peer CLI and MCP messages to auto, steering eligible Codex turns and queueing otherwise. Preserve explicit delivery modes and uncertain-send safety, and clarify steer guidance for important time-sensitive findings.
This commit is contained in:
weishu
2026-10-29 22:02:43 +08:00
parent f48a6696cf
commit 9384ce031b
13 changed files with 270 additions and 84 deletions
+16 -4
View File
@@ -47,12 +47,21 @@ Choose a supported coding agent from your terminal and control its sessions remo
- `hapi inspect-peer <session-id-or-prefix>` - Read-only peer metadata + recent message text (no resume). Prefer this or MCP `inspect_peer` when a user cites `[title](/sessions/<id>)` or Copy-reference `See session "…" (/sessions/<id>) for context`. `/sessions/<id>` is a hub path, not a local file. Optional `--limit`.
- `hapi set-mode <session-id-or-prefix> <mode>` - Change the permission mode of an existing session, like the web permission picker. Active sessions switch immediately; inactive ones use it on next resume. An invalid mode prints the modes allowed for that agent.
Peer messages default to `queue`: wait for the next turn, or resume an inactive
session. Use `--delivery-mode steer` to request insertion into an active Pi,
Codex, or Cursor ACP turn. MCP `ping_peer` accepts the same optional
`deliveryMode: "queue" | "steer"` field.
Peer messages default to `auto`: use the target's live state to steer an active
Codex turn when steering is available; otherwise queue, resuming an inactive
session if needed. Auto currently queues for all other agent flavors. Prefer
auto for routine collaboration when queueing is an acceptable fallback.
Use explicit `queue` for non-urgent updates that can wait. Use `steer` for
important, time-sensitive findings the peer needs to know now, not after its
current turn: a correction that invalidates its assumptions, a blocker, or a
result that changes its next action. State why it matters now and what the peer
should adjust. Steer requires insertion into an active Pi, Codex, or Cursor ACP
turn; it does not abort that turn or guarantee an immediate response. MCP `ping_peer` accepts
the same optional `deliveryMode: "auto" | "queue" | "steer"` field. Auto is
resolved by the peer sender; ordinary web/native chat delivery is unchanged.
```bash
hapi ping-peer <session-id> 'The dependency is ready' --delivery-mode auto
hapi ping-peer <session-id> 'Run the next check' --delivery-mode queue
hapi ping-peer <session-id> 'Use the corrected input path' --delivery-mode steer
```
@@ -64,6 +73,9 @@ acknowledges consumption. Steer messages retain the same peer identity prefix.
Steer rejects unsupported agents, idle targets, and inactive targets before
sending. It reuses the queued-message Steer action: success reports `steered`,
or `invoked` if the target consumed the message before the action arrived.
Auto uses Codex's `steeringActive` state and control capabilities, not just
`active` or `thinking`. If the turn changes after selection, auto uses the same
safe error handling as explicit steer; it does not resend or silently retry.
If steering fails after the message was accepted, the error includes its
`localId`; it may still be queued or already consumed. Inspect the target
before retrying; do not automatically resend the prompt. Steering does not