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
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
Merge branch 'pr-162' into integration/v0.4.5
Chaitanya Girid031d5db5b7d
diff --cc src/renderer/src/hooks/useHive.tsindex 3e0b90cc,62063381..380ee952--- a/src/renderer/src/hooks/useHive.ts+++ b/src/renderer/src/hooks/useHive.ts@@@ -48,26 -46,12 +48,32 @@@ const BOOT_GRACE_MS = 35_000// submitToPty additionally waits for the terminal's readiness handshake.const SEED_BOOT_MS = 12_000;+/** Hive-aware / hooks-bridge engines get standing goals via HookServer+ * (SessionStart + UserPromptSubmit). Cursor and other no-hook engines need the+ * goal prepended onto queued PTY deliveries so an Edit Agent save still lands+ * on the next drain cycle without a restart. */+function usesHookStandingGoal(agent: Agent): boolean {+ const provider = inferAgentProvider(agent.command, agent.provider);+ const preset = providerPreset(provider);+ if (preset.hiveAware) return true;+ return bridgeOf(provider)?.kind === 'hooks';+}++/** Prepend `<goal>…</goal>` for engines that cannot inject via hooks. Reads the+ * live store field, so a just-saved goal is picked up on the next queue flush. */+function withStandingGoal(agent: Agent, text: string): string {+ const goal = agent.goal?.trim();+ if (!goal || usesHookStandingGoal(agent)) return text;+ if (text.includes('<goal>')) return text;+ return `<goal>\n${goal}\n</goal>\n\n${text}`;+}++ // The standard inbox-wake nudge — ONE shared string because two paths queue it+ // (effect #3's poll and the main watchdog's re-fire, #151) and dedupe against+ // the queue by content so an agent is never nudged twice for the same mail.+ const INBOX_NUDGE =+ 'You have new hive inbox message(s) — read your inbox, act on them now, and move handled ones to inbox/.done/. Act autonomously; only message god if you genuinely need a decision.';+// The first thing Michael (god) is told on a fresh spawn — orient him and put// him to work running the floor. Kept terse and action-oriented.const INITIAL_GOD_PROMPT = [@@@ -666,17 -609,16 +672,17 @@@ export function useHive(config: Harnessfor (const a of agents) {try {const inbox = await window.cth.hiveInbox(a.id);- // Dedup by the newest message id, not the count — a count can oscillate- // as messages drain and re-arrive, which would re-nudge for the same set.- const newest = inbox.length- ? inbox.map((m) => m.id).sort().slice(-1)[0]- : '';- if (newest && nudged.current[a.id] !== newest) {- useStore.getState().enqueueMessage(a.id, INBOX_NUDGE);- nudged.current[a.id] = newest;- } else if (!newest) {- nudged.current[a.id] = '';+ // Nudge on any id we have not nudged for yet. Draining shrinks the set+ // and introduces nothing new, so it stays quiet; a genuinely new message+ // fires regardless of how its id happens to sort.+ const seen = nudged.current[a.id] ?? (nudged.current[a.id] = new Set());+ const fresh = inbox.filter((m) => m.id && !seen.has(m.id));+ if (fresh.length) {+ useStore.getState().enqueueMessage(+ a.id,- 'You have new hive inbox message(s) — read your inbox, act on them now, and move handled ones to inbox/.done/. Act autonomously; only message god if you genuinely need a decision.'++ INBOX_NUDGE+ );+ for (const m of fresh) seen.add(m.id);}} catch { /* ignore */ }}@@@ -684,6 -626,36 +690,38 @@@return () => clearInterval(iv);}, [config?.onboardingComplete]);+ // 3c) The main-process wake watchdog (#151). Effect #3 is a single renderer+ // timer with a single-shot dedup — one wedged store status or one stale+ // key and a durable inbox message stalls until app restart (god survives+ // this because the heartbeat re-delivers HIS digest from main). Main+ // re-fires when a pty sits quiet with mail undrained; we re-drive the+ // SAME queue + drain path, so every typing guard (idle-only, boot grace,+ // pause, draft/picker safety) still holds.+ useEffect(() => {+ if (!config?.onboardingComplete) return;+ return window.cth.onHiveInboxWake?.((p) => {+ if (!p?.agentId) return;+ const { agents, messageQueues, enqueueMessage, updateAgent } = useStore.getState();+ const a = agents.find((x) => x.id === p.agentId);+ if (!a?.ptyId) return;+ // Main has watched this pty stay quiet ≥30s while the store still says+ // 'working' — that status is wedged (a live turn repaints constantly) and+ // it is exactly what blocks the drain. Reconcile to idle the same way the+ // quiesce poll (#2) does. 'waiting'/'blocked'/'looping' are deliberate+ // holds (HITL prompt / breaker) and are never overridden.+ if (a.status === 'working' && (p.idleMs ?? 0) >= 30_000) {+ updateAgent(a.id, { status: 'idle', action: 'awaiting', carrying: undefined });+ }+ // Queue the standard nudge unless one is already waiting — and remember+ // the newest id so effect #3's own tick doesn't queue a duplicate.+ const queued = messageQueues[a.id] ?? [];+ if (!queued.some((m) => m.text === INBOX_NUDGE)) enqueueMessage(a.id, INBOX_NUDGE);- if (p.newestId) nudged.current[a.id] = p.newestId;++ // Renderer-side dedupe is a per-id Set (#130), so record the id rather++ // than overwriting a single slot — otherwise effect #3 re-nudges for it.++ if (p.newestId) (nudged.current[a.id] ??= new Set()).add(p.newestId);+ });+ }, [config?.onboardingComplete]);+// 3b) Seed a fresh "type-into-tui" worker (Crush) with the hive protocol. Its// bare TUI rejects a positional seed (Cobra reads it as a subcommand →// `Unknown command`), so the main process spawns it bare and hands the