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

Bridge hive mail to terminal work orders

Piotr Durlejd547019b919c
diff --git a/src/main/hive.ts b/src/main/hive.ts
index 8790b20f..b2ef926d 100644
--- a/src/main/hive.ts
+++ b/src/main/hive.ts
@@ -566,11 +566,7 @@ export class HiveManager {
continue;
}
if (target && !isClaudeProvider(target.provider ?? 'claude')) {
- this.deliver({
- ...msg,
- to: godId,
- subject: `[bounced — "${t}" uses ${target.provider ?? 'custom'}; route via its terminal, not hive inbox] ${msg.subject}`
- }, godId);
+ this.emitTerminalHandoff(msg, t);
continue;
}
this.deliver(msg, t);
@@ -595,6 +591,20 @@ export class HiveManager {
});
}
+ /** Non-Claude providers cannot drain hive inbox; hand direct mail to the
+ * renderer so it can queue a terminal work order for the target PTY. */
+ private emitTerminalHandoff(msg: HiveMessage, targetId: string): void {
+ this.emit?.('hive:terminalHandoff', {
+ id: msg.id,
+ from: msg.from,
+ to: targetId,
+ act: msg.act,
+ subject: msg.subject,
+ body: msg.body,
+ createdAt: msg.created_at
+ });
+ }
+
// — router: drain outboxes → inboxes —
/** Poll-based router. Cheap and robust vs fs.watch quirks on macOS. */
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 2c9150a5..a89a5e1b 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -60,6 +60,18 @@ export interface HiveRouteEvent {
needsHuman: boolean;
}
+/** A direct hive message addressed to a provider that cannot drain hive inbox.
+ * The renderer turns this into a queued terminal work order for that agent. */
+export interface HiveTerminalHandoffEvent {
+ id: string;
+ from: string;
+ to: string;
+ act: 'request' | 'inform' | 'propose' | 'query' | 'agree' | 'refuse' | 'done';
+ subject: string;
+ body: string;
+ createdAt: string;
+}
+
export interface SpawnPtyOptions {
id: string;
cwd: string;
@@ -392,6 +404,11 @@ const api = {
ipcRenderer.on('hive:message', listener);
return () => ipcRenderer.removeListener('hive:message', listener);
},
+ onHiveTerminalHandoff: (cb: (e: HiveTerminalHandoffEvent) => void): (() => void) => {
+ const listener = (_e: IpcRendererEvent, payload: HiveTerminalHandoffEvent) => cb(payload);
+ ipcRenderer.on('hive:terminalHandoff', listener);
+ return () => ipcRenderer.removeListener('hive:terminalHandoff', listener);
+ },
// ─── Quit confirmation ───────────────────────────────────────────────────
onCloseRequested: (cb: (info: { ptyCount: number }) => void): (() => void) => {
diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.ts
index e43c9d6f..26dfbdde 100644
--- a/src/renderer/src/hooks/useHive.ts
+++ b/src/renderer/src/hooks/useHive.ts
@@ -91,6 +91,25 @@ function enrichTaskPrompt(text: string): string {
].join('\n');
}
+function terminalWorkOrderPrompt(msg: {
+ from: string;
+ subject: string;
+ body: string;
+}): string {
+ return [
+ 'WORK ORDER FROM HIVE',
+ `From: ${msg.from}`,
+ `Subject: ${msg.subject}`,
+ '',
+ msg.body,
+ '',
+ 'Notes:',
+ '- This arrived through your terminal because this provider does not support hive inbox.',
+ '- Work in your current cwd.',
+ '- When done, report changes, validation, blockers, and next step in this terminal.'
+ ].join('\n');
+}
+
/** Tool name → where the avatar walks + what it carries. */
const TOOL_STATION: Record<string, { station: StationKind; carry?: ToolKind }> = {
Read: { station: 'shelf', carry: 'Read' },
@@ -401,6 +420,29 @@ export function useHive(config: HarnessConfig | null): void {
});
}, []);
+ // 2e) Non-Claude providers cannot drain hive inbox. Direct hive mail to them
+ // arrives here as a terminal work order and is queued through the same
+ // idle-only PTY drain as human-composed messages.
+ useEffect(() => {
+ if (!config?.onboardingComplete) return;
+ return window.cth.onHiveTerminalHandoff((msg) => {
+ const { agents, enqueueMessage } = useStore.getState();
+ const target = agents.find((a) => a.id === msg.to);
+ if (target?.ptyId) {
+ enqueueMessage(target.id, terminalWorkOrderPrompt(msg));
+ return;
+ }
+ enqueueMessage(
+ GOD_ID,
+ [
+ `Terminal handoff failed for ${msg.to}: ${msg.subject}`,
+ '',
+ `Message ${msg.id} from ${msg.from} could not be queued because ${msg.to} has no live PTY. Route it manually or respawn the agent.`
+ ].join('\n')
+ );
+ });
+ }, [config?.onboardingComplete]);
+
// 3) Wake idle agents holding unread inbox messages. The assistant is
// send-only (it never receives inbox mail), so it's excluded.
useEffect(() => {