manager events: Spawned/Rebuilt/Killed/Destroyed + start button
This commit is contained in:
parent
06ea0cf283
commit
37c6504462
9 changed files with 165 additions and 70 deletions
|
|
@ -132,8 +132,11 @@ async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
|||
match recv {
|
||||
Ok(ManagerResponse::Message { from, body }) => {
|
||||
if from == SYSTEM_SENDER {
|
||||
// Helper events (ApprovalResolved, etc.) — log + surface
|
||||
// in live view but don't burn a claude turn on them.
|
||||
// Helper events (ApprovalResolved / Spawned / Rebuilt /
|
||||
// Killed / Destroyed) — these are FYI for the manager;
|
||||
// we surface them in the live view and forward them as
|
||||
// a normal claude turn so the manager can react (e.g.
|
||||
// greet a newly-spawned agent, retry a failed rebuild).
|
||||
let parsed = serde_json::from_str::<HelperEvent>(&body).ok();
|
||||
if let Some(event) = parsed {
|
||||
tracing::info!(?event, "helper event");
|
||||
|
|
@ -141,7 +144,9 @@ async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
|||
tracing::info!(%from, %body, "system message");
|
||||
}
|
||||
bus.emit(LiveEvent::Note(format!("[system] {body}")));
|
||||
continue;
|
||||
// Fall through: drive a turn with the event in the wake
|
||||
// prompt body so claude sees it. Sender stays "system"
|
||||
// so the wake prompt can label it as such.
|
||||
}
|
||||
tracing::info!(%from, %body, "manager inbox");
|
||||
bus.emit(LiveEvent::TurnStart {
|
||||
|
|
@ -172,6 +177,15 @@ async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
|||
/// prompt doesn't have access to, and points the manager at its own
|
||||
/// editable config repo for self-modification.
|
||||
fn format_wake_prompt(label: &str, from: &str, body: &str) -> String {
|
||||
let from_note = if from == SYSTEM_SENDER {
|
||||
"\n The sender `system` means this is a hyperhive helper event \
|
||||
(JSON body, `event` field discriminates): `approval_resolved`, \
|
||||
`spawned`, `rebuilt`, `killed`, `destroyed`. Use these to react to \
|
||||
lifecycle changes — e.g. greet a freshly-spawned agent, retry a \
|
||||
failed rebuild, or note the change to the operator.\n"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!(
|
||||
"You are the hyperhive manager `{label}` in a multi-agent system. You \
|
||||
coordinate sub-agents and relay between them and the operator.\n\
|
||||
|
|
@ -179,7 +193,7 @@ fn format_wake_prompt(label: &str, from: &str, body: &str) -> String {
|
|||
Incoming message from `{from}`:\n\
|
||||
---\n\
|
||||
{body}\n\
|
||||
---\n\
|
||||
---\n{from_note}
|
||||
\n\
|
||||
Tools (hyperhive surface):\n\
|
||||
- `mcp__hyperhive__recv()` — drain one more message from your inbox.\n\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue