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
fix(cli-agents): Crush seed via type-into-tui — no more 'Unknown command' (ondev-b)
Chaitanya Giri4c750d372fe7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f4ad2623..ef9c6134 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -55,6 +55,7 @@ sleep-frozen message router and Codex workers' filesystem permissions.### Fixed- **Codex hive workers get full filesystem + auto-approval from spawn (parity with Claude).** A Codex-engine agent in auto mode launched with `-a never -s workspace-write`, whose sandbox scopes writes to the PTY cwd (the user's project). But a hive worker must also write to its agent folder at `<harnessHome>/hive/agents/<id>/` (move `inbox/` → `.done/`, append `memory.md`, drop outbox JSON, write deliverables) — a **different path tree from cwd**, which `workspace-write` blocked. So a freshly spawned Codex worker couldn't complete HIVE PROTOCOL housekeeping and reported "it does not have permissions … grant write permission to the agent folder." Codex's auto-mode flag is now `--dangerously-bypass-approvals-and-sandbox` — the documented equivalent of Claude's `bypassPermissions` / Antigravity's `--dangerously-skip-permissions` (skip all approval prompts **and** drop the OS sandbox), so a Codex worker has the same filesystem access and auto-approval as a Claude worker from the get-go (`src/shared/agentProvider.ts`; reference/copy updated in `src/shared/codexCommands.ts`, `OnboardingWizard.tsx`, `renderer/store/config.ts`). Claude/agy/antigravity behavior is unchanged.- **Re-arm the hive message router on wake (god→worker delivery survives sleep).** The outbox→inbox router is a `setInterval` (`hive.routeOnce` every ~1.5s) that, like the always-on beats, freezes during true macOS system sleep. `onSystemResume()` already re-armed the mission scheduler, the fleet/breaker beats, and keep-awake on `powerMonitor` `resume`/`unlock-screen` — but it never re-armed the router. So after a long sleep (e.g. laptop closed overnight) the scheduler→god path recovered while **every agent's outbox silently stopped draining**: god→worker, worker↔worker, and broadcast mail piled up undelivered, and no `message` event was logged. The resume handler now re-arms the router (clear-then-set, idempotent) **and** immediately drains the accumulated backlog instead of waiting for the first post-wake tick; the renderer's idle inbox-wake nudge then wakes each parked recipient once its mail lands (`src/main/index.ts`). Verified by `scripts/verify-keepalive-catchup.mjs` (now also reproduces the pre-fix backlog stall and proves the re-arm + flush).+- **Crush no longer dies with `Unknown command` on spawn (the hive protocol now reaches it).** A Crush worker was launched as `crush --model <m> --yolo "You are …(the whole hive protocol)"` — the protocol passed as a positional arg. But bare `crush` is an interactive Bubble Tea TUI on a Cobra root command, which reads the first positional as a **subcommand**, so it aborted with `unknown command "You are…"`; the protocol never reached the model, the worker never learned it was a hive agent, and the PTY died. Crush has no `--prompt` flag and `crush run` is one-shot, so the protocol is now **typed into the TUI** instead: a new preset capability `seedDelivery:'type-into-tui'` makes the spawn drop the positional (`crush [--model m] [--yolo]`) and hand the protocol back as a `seedPrompt`, which the renderer types in as the worker's first turn after a boot-grace — through the **same per-pty write-chain as the inbox-wake nudge**, so the seed and a nudge can never jam onto one line. Covers fresh Crush spawns, restores, and Crush-as-Michael (`src/shared/agentProvider.ts`, `src/main/hive.ts`, `src/main/index.ts`, `src/preload/index.ts`, `src/renderer/src/hooks/useHive.ts`, `AddAgentModal.tsx`, `AgentStrip.tsx`, `store.ts`).- **Auto restart-and-continue after a first-time engine-CLI install (no dead-end).** When an agent's engine binary (OpenCode/Crush/pi.dev/Codex/…) wasn't installed, the missing-CLI short-circuit ran the provider's installer in the PTY, then printed *"click restart & continue to launch the agent"* — but no such button exists for a not-yet-started agent, so the PTY just sat at `process exited (code 0)` and the agent dead-ended. Now, on a **clean install exit**, the PTY-exit handler auto restart-and-continues: it re-runs the *same* spawn into the *same* pty/window (carrying a `noAutoInstall` flag) so the freshly-installed CLI launches with no user click, and the renderer re-arms that terminal in place (clears the "process exited" line, re-enables input) via a new `pty:relaunch` signal. Provider-agnostic (every engine's installer path) and idempotent by construction — `noAutoInstall` guarantees the installer can never fire twice, and providers with no bundled installer (manual-hint-only) are never armed for relaunch. The install banner copy is now honest ("Installed — launching the agent…") (`src/main/index.ts`, `src/main/pty.ts`, `src/preload/index.ts`, `src/renderer/src/components/terminalPool.ts`).## [0.3.0] — 2026-06-21diff --git a/src/main/hive.ts b/src/main/hive.tsindex de024dfb..6d86cfae 100644--- a/src/main/hive.ts+++ b/src/main/hive.ts@@ -134,6 +134,11 @@ export interface Registry {export interface SpawnInjection {args: string[];env: Record<string, string>;+ /** The hive-protocol seed to TYPE into the TUI after boot rather than pass on+ * argv — set only for `seedDelivery:'type-into-tui'` providers (Crush), whose+ * bare TUI rejects a positional seed. The renderer types it through the same+ * per-pty write-chain as the inbox-wake nudge. (ondev-b) */+ seedPrompt?: string;}const HOP_CAP = 12;@@ -477,8 +482,12 @@ export class HiveManager {}} catch (e) { console.error(`[hive] install ${desc.kind} bridge failed:`, e); }}- // Inject the protocol text whichever way the CLI accepts it. If a provider- // somehow exposes neither a flag nor a positional prompt, spawn bare.+ // Inject the protocol text whichever way the CLI accepts it.+ // type-into-tui (Crush): the bare TUI reads a positional as a Cobra subcommand+ // → `Unknown command`. So DROP the positional and hand the protocol back as+ // seedPrompt; the renderer types it into the TUI after boot (ondev-b).+ if (preset.seedDelivery === 'type-into-tui') return { args: [...preArgs], env, seedPrompt: prompt };+ // If a provider somehow exposes neither a flag nor a positional prompt, spawn bare.if (flag) return { args: [...preArgs, flag, prompt], env };// Positional initial prompt (codex). Append as a trailing argv element.return { args: [...preArgs, prompt], env };diff --git a/src/main/index.ts b/src/main/index.tsindex 7d6bfc39..b4acc3ca 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -1756,7 +1756,7 @@ ipcMain.handle('pty:spawn', async (evt, opts: AgentSpawnOptions) => {* it can ALSO be invoked by the god-triggered ephemeral-worker watcher (which has* no renderer `evt`). `owner` is the window that should receive this PTY's output* (null → the primary window). Behavior-identical to the prior inline handler. */-async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebContents | null): Promise<{ ok: boolean; error?: string; worktreePath?: string; resumeNotFound?: boolean; resumed?: boolean }> {+async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebContents | null): Promise<{ ok: boolean; error?: string; worktreePath?: string; resumeNotFound?: boolean; resumed?: boolean; seedPrompt?: string }> {// Which CLI is this? Explicit wins; else inferred from the binary// (claude/codex/agy). Non-Claude providers skip every Claude-only spawn step// below. Persist the resolved provider onto opts (+ hive meta) so the registry@@ -1857,6 +1857,10 @@ async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebConten// If the agent carries hive metadata, provision its workspace and add// provider-specific spawn injection. Non-Claude providers get shared AGENT_*// env only; Claude Code also gets prompt/settings hook args.+ // Protocol seed that must be TYPED into a bare TUI after boot (Crush —+ // seedDelivery:'type-into-tui') rather than passed on argv. Surfaced in the spawn+ // result so the renderer types it through the per-pty write-chain. (ondev-b)+ let seedPrompt: string | undefined;if (opts.hive && hive.enabled()) {try {const inj = await hive.ensureAgent(@@ -1871,6 +1875,7 @@ async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebConten});opts.args = [...(opts.args ?? []), ...inj.args];+ seedPrompt = inj.seedPrompt;// Point the agent's mempalace CLI at the shared palace + the `kg` CLI at the// enterprise knowledge store (both no-ops / empty when their flags are off).opts.env = { ...(opts.env ?? {}), ...inj.env, ...memory.env(), ...knowledge.env() };@@ -2021,7 +2026,7 @@ async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebConten// The restore flow re-enters this exact worktree (cwd = worktreePath) so a// restored isolated agent resumes in the CORRECT checkout, not the base repo.const worktreePath = worktreePaths.get(opts.id);- return { ...res, ...(worktreePath ? { worktreePath } : {}), ...(resumeNotFound ? { resumeNotFound: true } : {}), ...(didResume ? { resumed: true } : {}) };+ return { ...res, ...(worktreePath ? { worktreePath } : {}), ...(resumeNotFound ? { resumeNotFound: true } : {}), ...(didResume ? { resumed: true } : {}), ...(seedPrompt ? { seedPrompt } : {}) };}ipcMain.handle('pty:write', (_evt, id: string, data: string) => {if (typeof id !== 'string' || typeof data !== 'string') return { ok: false, error: 'invalid args' };diff --git a/src/preload/index.ts b/src/preload/index.tsindex ea3265c6..5044f7c4 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -430,7 +430,7 @@ const api = {version: __APP_VERSION__,// ─── PTY ─────────────────────────────────────────────────────────────────- spawnPty: (opts: SpawnPtyOptions): Promise<{ ok: boolean; error?: string; worktreePath?: string; resumeNotFound?: boolean; resumed?: boolean }> =>+ spawnPty: (opts: SpawnPtyOptions): Promise<{ ok: boolean; error?: string; worktreePath?: string; resumeNotFound?: boolean; resumed?: boolean; seedPrompt?: string }> =>ipcRenderer.invoke('pty:spawn', opts),writePty: (id: string, data: string): Promise<{ ok: boolean; error?: string }> =>ipcRenderer.invoke('pty:write', id, data),diff --git a/src/renderer/src/components/AddAgentModal.tsx b/src/renderer/src/components/AddAgentModal.tsxindex c339caaa..499e5d5b 100644--- a/src/renderer/src/components/AddAgentModal.tsx+++ b/src/renderer/src/components/AddAgentModal.tsx@@ -340,6 +340,9 @@ export function AddAgentModal({ onClose, config, onConfigChange }: AddAgentModal// Persist the resolved worktree path (set only when isolation provisioned// one) so a restart can re-enter this exact worktree — see restoreTeam.worktreePath: spawnRes.worktreePath,+ // Crush (seedDelivery:'type-into-tui') hands its hive protocol back here+ // instead of on argv; useHive types it into the TUI after boot. (ondev-b)+ seedPrompt: spawnRes.seedPrompt,recentTextTs: Date.now()};addAgent(agent);diff --git a/src/renderer/src/components/AgentStrip.tsx b/src/renderer/src/components/AgentStrip.tsxindex 9560d43b..9afe1dd8 100644--- a/src/renderer/src/components/AgentStrip.tsx+++ b/src/renderer/src/components/AgentStrip.tsx@@ -108,6 +108,10 @@ export function AgentStrip({ config }: AgentStripProps) {// as a plain base-cwd agent going forward (a future restore won't keep// re-probing a dead path).worktreePath: worktreeGone ? undefined : a.worktreePath,+ // Crush spawns bare (no positional protocol) and hands the seed back+ // here; useHive types it after boot. Re-seeding a resumed worker is+ // idempotent (it just re-reads its inbox per protocol). (ondev-b)+ seedPrompt: res.seedPrompt,carrying: undefined,currentStation: 'desk',recentTextTs: Date.now()diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.tsindex fadb39f6..c4ff560b 100644--- a/src/renderer/src/hooks/useHive.ts+++ b/src/renderer/src/hooks/useHive.ts@@ -188,6 +188,9 @@ export function useHive(config: HarnessConfig | null): void {// must leave the agent alone — set while its boot sequence is typing so nothing// collides with /remote-control + the orientation prompt.const bootGraceUntil = useRef<Record<string, number>>({});+ // Agents whose one-time TUI protocol seed (Crush, seedDelivery:'type-into-tui')+ // has already been typed — guards effect #3b against re-seeding. (ondev-b)+ const seeded = useRef<Set<string>>(new Set());const seenTerminalHandoffs = useRef<Set<string>>(new Set());// Per-pty timestamp guarding auto-revive (effect #7) against a double-respawn// when power-resume + screen-unlock arrive back-to-back: an id revived (or@@ -281,6 +284,10 @@ export function useHive(config: HarnessConfig | null): void {// orientation prompt (fresh spawns only) is submitted next.submitToPty(GOD_PTY, '/remote-control', REMOTE_CONTROL_SETTLE_MS).catch(() => { /* best-effort */ });if (!resumedGod) {+ // A type-into-tui god (Crush) can't ride its hive protocol on argv, so the+ // main process hands it back as seedPrompt — type it FIRST (identity), then+ // the orientation kick. Serialized via writeChains so they can't jam. (ondev-b)+ if (res.seedPrompt) submitToPty(GOD_PTY, res.seedPrompt).catch(() => { /* pty may have died */ });submitToPty(GOD_PTY, INITIAL_GOD_PROMPT).catch(() => { /* pty may have died */ });}}, GOD_BOOT_MS));@@ -520,6 +527,35 @@ export function useHive(config: HarnessConfig | null): void {return () => clearInterval(iv);}, [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+ // protocol back as `seedPrompt`; we TYPE it as the worker's first turn after a+ // boot-grace (TUI finished painting), ONCE per agent. Routed through the SAME+ // per-pty submit chain + boot-grace as the inbox-wake nudge so the seed and a+ // nudge can never jam onto one line. (god-as-Crush is seeded in its own boot+ // sequence above; this covers workers.) (ondev-b)+ useEffect(() => {+ if (!config?.onboardingComplete) return;+ const iv = setInterval(() => {+ const { agents, updateAgent } = useStore.getState();+ for (const a of agents) {+ if (!a.ptyId || a.isGod || !a.seedPrompt || seeded.current.has(a.id)) continue;+ seeded.current.add(a.id);+ const ptyId = a.ptyId;+ const seed = a.seedPrompt;+ // Hold the nudge/quiesce typers off this agent until the seed lands + settles.+ bootGraceUntil.current[a.id] = Date.now() + BOOT_GRACE_MS;+ // Clear the record now so it isn't re-seen (the ref also guards) or persisted.+ updateAgent(a.id, { seedPrompt: undefined });+ setTimeout(() => {+ submitToPty(ptyId, seed).catch(() => { /* pty may have died */ });+ }, GOD_BOOT_MS);+ }+ }, 1500);+ return () => clearInterval(iv);+ }, [config?.onboardingComplete]);+// 4) Drain each agent's queued messages to its terminal, one at a time, the// moment the agent goes idle. This is what lets the user keep sending// messages while the agent's "cloud terminal" is mid-run: the messagesdiff --git a/src/renderer/src/store/store.ts b/src/renderer/src/store/store.tsindex 4b765756..9078b395 100644--- a/src/renderer/src/store/store.ts+++ b/src/renderer/src/store/store.ts@@ -80,6 +80,11 @@ export interface Agent {* (in the store's `archivedAgents` list + the hive registry) but flagged and* kept off the floor; only live-PTY agents are 'active'. */archived?: boolean;+ /** Hive protocol to TYPE into this agent's TUI as its first turn, set at spawn+ * for `seedDelivery:'type-into-tui'` providers (Crush) whose bare TUI rejects a+ * positional seed. useHive types it once after boot-grace then clears it.+ * Ephemeral spawn state — not persisted. (ondev-b) */+ seedPrompt?: string;}export interface FeedEntry {@@ -223,12 +228,12 @@ const LS_QUEUES = 'cth.messageQueues';// Fields that are large or transient — not worth persisting across reloads.// contextTokens/contextLimit describe a LIVE session; persisting them showed a// dead session's context gauge after a restart until the poll caught up.-type PersistedAgent = Omit<Agent, 'recentAssistantText' | 'recentTextTs' | 'blockReason' | 'contextTokens' | 'contextLimit'>;+type PersistedAgent = Omit<Agent, 'recentAssistantText' | 'recentTextTs' | 'blockReason' | 'contextTokens' | 'contextLimit' | 'seedPrompt'>;function persistAgents(agents: Agent[], selectedId: string | null): void {try {- const slim: PersistedAgent[] = agents.map(({ recentAssistantText, recentTextTs, blockReason, contextTokens, contextLimit, ...rest }) => {- void recentAssistantText; void recentTextTs; void blockReason; void contextTokens; void contextLimit;+ const slim: PersistedAgent[] = agents.map(({ recentAssistantText, recentTextTs, blockReason, contextTokens, contextLimit, seedPrompt, ...rest }) => {+ void recentAssistantText; void recentTextTs; void blockReason; void contextTokens; void contextLimit; void seedPrompt;return rest;});window.localStorage.setItem(LS_AGENTS, JSON.stringify(slim));@@ -259,8 +264,8 @@ function loadPersistedAgents(): Agent[] {function persistArchived(archived: Agent[]): void {try {- const slim: PersistedAgent[] = archived.map(({ recentAssistantText, recentTextTs, blockReason, contextTokens, contextLimit, ...rest }) => {- void recentAssistantText; void recentTextTs; void blockReason; void contextTokens; void contextLimit;+ const slim: PersistedAgent[] = archived.map(({ recentAssistantText, recentTextTs, blockReason, contextTokens, contextLimit, seedPrompt, ...rest }) => {+ void recentAssistantText; void recentTextTs; void blockReason; void contextTokens; void contextLimit; void seedPrompt;return rest;});window.localStorage.setItem(LS_ARCHIVED, JSON.stringify(slim));@@ -289,8 +294,8 @@ function loadPersistedArchived(): Agent[] {function persistRestorable(restorable: Agent[]): void {try {- const slim: PersistedAgent[] = restorable.map(({ recentAssistantText, recentTextTs, blockReason, ...rest }) => {- void recentAssistantText; void recentTextTs; void blockReason;+ const slim: PersistedAgent[] = restorable.map(({ recentAssistantText, recentTextTs, blockReason, seedPrompt, ...rest }) => {+ void recentAssistantText; void recentTextTs; void blockReason; void seedPrompt;return rest;});window.localStorage.setItem(LS_RESTORABLE, JSON.stringify(slim));diff --git a/src/shared/agentProvider.ts b/src/shared/agentProvider.tsindex 7356640e..93a8cd03 100644--- a/src/shared/agentProvider.ts+++ b/src/shared/agentProvider.ts@@ -116,6 +116,15 @@ export interface AgentProviderPreset {* takes its initial prompt POSITIONALLY (Codex: `codex "<prompt>"`) and the* injection branch appends it as a quoted trailing arg instead of a flag. */initialPromptFlag?: string;+ /** How the hive protocol seed is delivered for a CLI that takes NEITHER a flag+ * nor a positional seed. `'type-into-tui'` = the CLI is a bare interactive TUI+ * that rejects a positional initial prompt (Crush: its first positional is read+ * as a Cobra SUBCOMMAND → `Unknown command "You are…"`), so the harness must NOT+ * append the protocol to argv — it spawns the bare TUI and hands the protocol+ * back as `seedPrompt`, which the renderer types into the TUI's editor after boot+ * (through the SAME per-pty write-chain as the inbox-wake nudge, so they can't+ * collide). Absent/undefined = today's flag-or-positional behavior. (ondev-b) */+ seedDelivery?: 'type-into-tui';/** Flag to resume a prior session on respawn, given the recorded session id* (Claude `--resume <sid>`, Antigravity `--conversation <id>`). undefined = no* resume support, spawn fresh. */@@ -309,10 +318,13 @@ export const AGENT_PROVIDER_PRESETS: AgentProviderPreset[] = [// Live runtime (proxy parse of Crush traffic + synthesized Stop) is UNVERIFIED// pending keys; the renderer idle nudge is the guaranteed drain fallback.canReceiveInbox: true,- // Protocol rides as the session's initial prompt, POSITIONAL like codex. UNKNOWN- // whether the bare TUI accepts a positional seed — if not, the harness types the- // protocol as the TUI's first message (renderer nudge). humanQA.+ // Bare `crush` is an interactive Bubble Tea TUI on a Cobra root command: the+ // first positional is parsed as a SUBCOMMAND, so a positional seed dies with+ // `unknown command "You are…"` (ondev-b live repro / spec-crush MF3). Crush has+ // NO --prompt flag either. So neither flag nor positional works → deliver the+ // protocol by TYPING it into the TUI after boot (renderer nudge path).initialPromptFlag: undefined,+ seedDelivery: 'type-into-tui',resumeFlag: '--session', // Crush supports resume by id (also --continue for most-recent)installCommand: 'npm install -g @charmland/crush', // trusted, hardcoded (brew/go/winget also valid)docsUrl: 'https://github.com/charmbracelet/crush'