import { type SpawnOptions } from "node:child_process"; import { Type, type Static } from "typebox"; import type { ExtensionAPI, ExtensionContext, ToolDefinition } from "@earendil-works/pi-coding-agent"; export declare function delegateSpawnOptions(cwd: string, env: NodeJS.ProcessEnv): SpawnOptions; /** Snapshot of currently-running delegate runs, for the TUI status widget. */ export declare function runningRunsSnapshot(): { runId: string; agent: string; task: string; startedAt: number; }[]; /** Minimal writable surface accepted by makeEventApplier — real WriteStreams * in production, in-memory collectors in tests. */ export interface EventApplierWriters { reply: { write(chunk: string): void; }; activity: { write(chunk: string): void; } | null; } export interface EventApplier { handleEventLine(line: string): void; getReplyText(): string; /** omp fallback: `-p` prints the plain reply as raw stdout; append it * straight through (no event parsing). */ appendRaw(text: string): void; } /** Applies parsed delegate JSON-event lines to the live reply/activity files. * Extracted from the spawn closure so the write logic is unit-testable. * * reply-delta (text_delta) is streamed to the reply file as it arrives; * reply-complete (text_end) carries the authoritative full content of the * text block — any portion not already written is appended (tracked via * msgWritten) so a final answer that arrives without preceding deltas is * never lost from the file. */ export declare function makeEventApplier(opts: { showThinking: boolean; }, writers: EventApplierWriters): EventApplier; declare const DelegateParams: Type.TObject<{ agent: Type.TString; task: Type.TString; cwd: Type.TOptional; model: Type.TOptional; async: Type.TOptional; showThinking: Type.TOptional; }>; type DelegateArgs = Static; declare const CancelParams: Type.TObject<{ runId: Type.TString; }>; declare const WaitParams: Type.TObject<{ runId: Type.TString; timeout: Type.TOptional; }>; export declare function makeDelegateTool(pi: ExtensionAPI): ToolDefinition; /** If the delegate already delivered its result via a system notification * (the close handler injected before this wait was called), return a short * "already delivered" message pointing at the result file, so the model * never sees the same result twice (once via the injected notification, * once via this tool result). Returns null when the run was NOT injected, * in which case the caller delivers the full payload via formatRunResult(). */ export declare function injectedWaitMessage(run: { injected?: boolean; result?: { file: string; }; }, runId: string, remainingLine: string): string | null; export declare function makeDelegateWaitTool(_pi: ExtensionAPI): ToolDefinition; export declare function makeDelegateCancelTool(_pi: ExtensionAPI): ToolDefinition; export declare function buildChildArgs(args: DelegateArgs, rolePrompt: string, ctx: ExtensionContext): Promise<{ cliArgs: string[]; tmpDir: string; isAsync: boolean; useJsonStream: boolean; }>; export {};