/** * Main-side routing of subagent runs between the main thread and pooled worker threads * (served there by `./services/executor`). * * - {@link runSubprocessPlaced} runs the whole subagent (child session creation, * monitoring, lifecycle finalization) where the pool places it: on this thread or in a * worker, which stays retained afterwards while the child's session is open there. * - {@link runFollowUpTurnOnHome} sends a follow-up turn to the thread its session is homed * on; from a worker, to main, which routes it on. * - {@link revivePersistedPlaced} cold-revives a parked agent where the pool places it, like * a fresh spawn. * - A worker that dies mid-run or mid-turn turns the call into a failed `SingleResult` whose * error names the worker; the agent's ref is left `parked` (revivable from its transcript) * or `aborted` (no transcript). * * Kept apart from the thread service so importing it never evaluates the service list. */ import type { SingleResult } from "@oh-my-pi/pi-tui/tools/task"; import { type AgentRef } from "../registry/agent-registry.js"; import type { AgentSessionHandle } from "../session/agent-session-handle.js"; import { type ExecutorOptions, type FollowUpTurnOptions } from "../task/executor.js"; import type { PersistedReviveSpec } from "../task/persisted-revive.js"; import type { WorkerThreadLink } from "./protocol.js"; import { type SubagentWorkerPool } from "./subagent-worker.js"; /** Worker thread: the link follow-up turns of sessions homed elsewhere are forwarded over. */ export declare function setWorkerMainLink(link: WorkerThreadLink): void; /** * Main thread: run the subagent of `options` where `pool` places it (see * {@link SubagentWorkerPool.place}): in a worker, or through `runHere` on this thread, its * run counted either way. For a worker, the integration options are converted synchronously * at placement, so a parent telemetry config captures the caller's active span. */ export declare function runSubprocessPlaced(pool: SubagentWorkerPool, options: ExecutorOptions, runHere: (options: ExecutorOptions) => Promise): Promise; /** * Run a follow-up turn of `session`, a live session homed on another thread, on its home: * from main, the session's worker; from a worker, main (which routes on). */ export declare function runFollowUpTurnOnHome(session: AgentSessionHandle, options: FollowUpTurnOptions): Promise; /** * Main thread: cold-revive the agent of `spec` where `pool` places it, like a fresh spawn: in a * worker (returning its mirror) or through `reviveHere` on this thread. */ export declare function revivePersistedPlaced(pool: SubagentWorkerPool, spec: PersistedReviveSpec, expected: AgentRef, reviveHere: (spec: PersistedReviveSpec, expected: AgentRef) => Promise): Promise;