/** * Hive-mind worker execution: the MCP config handed to a spawned Claude, and * `hive-mind work`, which actually runs a queued task. * * Before this, `hive-mind task` only wrote a `pending` row to the task store. * Workers are records, not processes, and nothing ever claimed the row: the * task stayed pending and the worker stayed idle forever. `work` is the missing * consumer — claim one task, assign it to an idle hive worker, run it through * `claude -p`, and record the outcome. */ import type { Command } from '../types.js'; export interface WorkerMcpConfigOptions { /** `--mcp-config` from the caller; used verbatim when given. */ explicit?: string; cwd: string; home: string; /** Where the generated config is written (e.g. `.hive-mind/sessions`). */ outDir: string; swarmId: string; /** The ruflo MCP server to register when no source config provides one. */ rufloServer: { command: string; args: string[]; }; } /** * The MCP config file to pass to a spawned Claude. * * A source file is never passed through as-is. `~/.claude.json` is Claude * Code's whole state file; on a machine where it has no top-level * `mcpServers` (a fresh desktop), Claude exits at startup with "Invalid MCP * configuration: mcpServers: Invalid input", before any task can run. And a * config lacking a `ruflo` server leaves the worker without the tools its * prompt names. So the servers are extracted, a `ruflo` server is guaranteed, * and the result is written as a config Claude is known to accept. */ export declare function resolveWorkerMcpConfig(opts: WorkerMcpConfigOptions): string; /** * The ruflo MCP server as launched by THIS cli, so a worker and the CLI that * dispatched it share one version and one store format. `@latest` could * resolve to a different release mid-session. */ export declare function currentRufloServer(): { command: string; args: string[]; }; export interface RunOutcome { ok: boolean; output: string; exitCode: number | null; sessionId?: string; costUsd?: number; durationMs: number; } export type TaskRunner = (prompt: string, opts: { mcpConfig: string; timeoutMs: number; cwd: string; }) => Promise; /** Run one prompt through `claude -p` and parse its JSON result. */ export declare const runWithClaude: TaskRunner; export interface WorkOnceOptions { cwd: string; mcpConfig: string; runner: TaskRunner; taskId?: string; workerId?: string; defaultTimeoutMs?: number; } export type WorkOnceResult = { dispatched: false; reason: string; } | { dispatched: true; taskId: string; workerId: string; status: 'completed' | 'failed'; outcome: RunOutcome; }; /** * One dispatch cycle: the oldest pending hive task goes to an idle hive worker, * runs, and its outcome is recorded on the task. Every state change goes * through the MCP task tools, so the store is the same one `hive-mind status` * and `task status` read. */ export declare function workOnce(opts: WorkOnceOptions): Promise; export declare const workCommand: Command; //# sourceMappingURL=hive-mind-worker.d.ts.map