/** * Subagent orchestration (E008, ren's #2): a `task` tool that spawns a * child {@link InProcessTransport} with the READ-ONLY tool set (no mutation, * no approval channel) to run a self-contained subtask, then returns the * settled assistant text. The parent keeps full control; the child is a * throwaway reader. This is the lean core of omp's task tool. * * Lifecycle hardening (ren's adversarial review, E012): the child session ID * is a uuidv7 (never Date.now — collisions aliased two children into one * slot); the parent's AbortSignal aborts the child transport; and a 5-minute * default wall-clock timeout (param-overridable) aborts a runaway child. * Both paths close the child transport, which ends its event queue and * unblocks the consumption loop. * * K3 fixes (0.1.007 review): stage resolution threads the cast's provider * (the built-in casts are nvidia-lane; the transport defaults to openrouter, * so stage resolution was dead by default) and fails loudly when a cast has * no judge for the review stage; a pre-aborted/timeout child never starts a * run (abort-before-prompt raced a full LLM turn); the JSON contract * extractor tries every fenced block and balanced span (the first fence is * often a placeholder), reads required keys from formal JSON Schema when the * contract parses as one, and caps the validated output. * * E017 (CTO-requested, known-list item): the restored STEERING channel — a * module-level registry of live child transports (sessionId → transport, * registered at construction, deleted in the run's `finally`) with * {@link steerChild}/{@link activeChildren} so the parent can name and steer * a running subagent. Every result detail object carries the child's * `sessionId` so the parent learns the name to steer. */ import { Type } from "typebox"; import type { AgentTool } from "@earendil-works/pi-agent-core"; import { type CastConfig } from "../fusion/casts.js"; /** * Steer a running child subagent (inject a user message into its turn). * Returns false when the id names no live child (unknown or already settled) * or the child rejected the message. */ export declare function steerChild(sessionId: string, message: string): boolean; /** Session ids of the currently running child subagents. */ export declare function activeChildren(): string[]; declare const TaskParams: Type.TObject<{ prompt: Type.TString; modelId: Type.TOptional; timeoutSeconds: Type.TOptional; outputSchema: Type.TOptional; stage: Type.TOptional, Type.TLiteral<"build">, Type.TLiteral<"review">]>>; }>; /** * Extract a JSON object from the child's answer and check every required key * exists. Tries ALL fenced blocks and balanced spans (latest first — the * first fence is often a format placeholder). Returns the pretty-printed * JSON, capped at 64 KiB, or an error string. */ export declare function extractAndValidateJson(answer: string, schema: string): { json?: string; error?: string; }; /** * Live progress emitted through the tool's `onUpdate` channel while the * child runs (E017 contract #3): the parent turn's `tool_execution_update` * events carry these as `partialResult.details`, letting the TUI render a * live task row instead of a silent wait. The settled result keeps the * pre-E017 shape (`content` text + `details` with `sessionId`). */ export interface TaskProgress { /** Lifecycle phase of the child run. */ status: "running" | "settling" | "timeout" | "aborted" | "error"; /** Tool the child is currently executing (last seen), if any. */ currentTool?: string; /** Tool calls the child has dispatched so far. */ toolCount: number; /** Completed child turns so far. */ turnDepth: number; /** The child's session id — the name to steer via {@link steerChild}. */ sessionId: string; /** Wall-clock milliseconds since the child run started. */ elapsedMs: number; } /** task: run a read-only subagent and return its settled answer. */ export declare function taskTool(cwd: string, parentModelId: string, options?: { castConfig?: CastConfig; }): AgentTool; export {}; //# sourceMappingURL=task.d.ts.map