mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
feat(peer): forward peer replies back to the caller with waitForReply (#2167)
* feat(peer): spawn_peer and reply forwarding for peer sessions Peer sessions could only fire messages at each other: the caller had to poll inspect_peer to learn that a peer finished, and nothing woke it once it ended its turn. There was also no way to start a peer for new work. - spawn_peer starts a session on the caller's machine (directory and agent default to the caller's) and sends it a task. - ping_peer gains waitForReply. - In both cases the caller's CLI watches the peer and, when its turn ends, posts the peer's latest reply into the caller session, which starts the caller's next turn. spawn_peer needs manual approval like ping_peer. No hub changes. * refactor(peer): drop own spawn_peer; add waitForReply to upstream spawn_peer Upstream #1922 ships spawn_peer (spawn, rename, remit delivery, fresh-child wait, manual approval). Remove this PR's duplicate spawnPeer and keep only reply forwarding: spawnPeer now returns the remit's ping-peer localId and resolved flavor, and MCP spawn_peer/ping_peer share one waitForReply hook. Add a steered-task attribution test. Co-Authored-By: Claude <noreply@anthropic.com> * fix(peer): keep waiting for a task an offline peer has not read The hub keeps unconsumed peer tasks for replay, so a peer that goes offline before reading the task can still run it after a resume. Only a stop after consumption ends the reply watch. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
LIST_PEERS_TOOL_DESCRIPTION,
|
||||
PEER_DELIVERY_MODE_DESCRIPTION,
|
||||
PEER_WAKE_PARAM_DESCRIPTION,
|
||||
PEER_WAIT_FOR_REPLY_PARAM_DESCRIPTION,
|
||||
PING_PEER_TOOL_DESCRIPTION,
|
||||
SESSION_ID_PREFIX_PARAM_DESCRIPTION,
|
||||
SPAWN_PEER_TOOL_DESCRIPTION,
|
||||
@@ -223,6 +224,7 @@ export async function runHappyMcpStdioBridge(argv: string[]): Promise<void> {
|
||||
message: z.string().min(1).describe('Message text to deliver to the target session'),
|
||||
deliveryMode: PeerDeliveryModeSchema.optional().describe(PEER_DELIVERY_MODE_DESCRIPTION),
|
||||
wake: z.boolean().optional().describe(PEER_WAKE_PARAM_DESCRIPTION),
|
||||
waitForReply: z.boolean().optional().describe(PEER_WAIT_FOR_REPLY_PARAM_DESCRIPTION),
|
||||
});
|
||||
|
||||
if (toolNames.has('ping_peer')) {
|
||||
@@ -273,6 +275,7 @@ export async function runHappyMcpStdioBridge(argv: string[]): Promise<void> {
|
||||
'Permission mode for the new session. Omit to use hub/stock default (yolo). '
|
||||
+ 'Pass only to tighten or when the operator names a mode — do not clone the parent session.'
|
||||
),
|
||||
waitForReply: z.boolean().optional().describe(PEER_WAIT_FOR_REPLY_PARAM_DESCRIPTION),
|
||||
});
|
||||
|
||||
if (toolNames.has('spawn_peer')) {
|
||||
|
||||
Reference in New Issue
Block a user