Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

merge: closing time / graceful shutdown (#36)

Chaitanya Giri7e225839424d
diff --cc src/main/hive.ts
index 5b040cdb,d90f219c..50c1d10a
--- a/src/main/hive.ts
+++ b/src/main/hive.ts
@@@ -537,26 -527,19 +537,36 @@@ export class HiveManager
? Object.keys(reg.agents).filter((a) => a !== msg.from && !reg.agents[a]?.isAssistant && !reg.agents[a]?.archived)
// Never deliver to self — guards a god → "human" message looping back to god.
: [resolveTo(msg.to)].filter((t) => t !== msg.from);
- for (const t of targets) this.deliver(msg, t);
+ for (const t of targets) {
+ // Enforce the assistant's send-only contract AT THE ROUTER: it has no
+ // composer, is excluded from the inbox-wake nudge, and never reads an
+ // inbox — yet direct mail used to be delivered there anyway, where it
+ // rotted unread (observed live: a task brief plus the follow-up
+ // reprimand about the unread inbox, both unread for hours). Bounce such
+ // mail to god instead, so the sender's intent surfaces immediately and
+ // nothing is silently lost.
+ if (reg.agents[t]?.isAssistant) {
+ this.deliver({
+ ...msg,
+ to: godId,
+ subject: `[bounced — "${t}" is the send-only prep assistant; route work to a real agent] ${msg.subject}`
+ }, godId);
+ continue;
+ }
+ this.deliver(msg, t);
+ }
this.appendLog({ kind: 'message', from: msg.from, to: msg.to, act: msg.act, subject: msg.subject, id: msg.id });
this.emitMessage(msg, targets);
+ // Main-process observer (e.g. the closing-time controller watching for the
+ // team's ACKs and the god's COMPLETE). Best-effort, never breaks routing.
+ try { this.routedObserver?.(msg, targets); } catch { /* observer error */ }
+ }
+
+ /** Observer invoked for EVERY routed message with its resolved targets.
+ * Used by main-process features that react to hive traffic (closing time). */
+ private routedObserver: ((msg: HiveMessage, targets: string[]) => void) | null = null;
+ setRoutedObserver(cb: ((msg: HiveMessage, targets: string[]) => void) | null): void {
+ this.routedObserver = cb;
}
/** Tell the renderer a message was routed, with its resolved recipients, so