import type { Usage } from "@earendil-works/pi-ai"; import type { PiLaunch } from "./index.ts"; export declare const DEFAULT_MAX_TURNS = 50; export declare const EXECUTION_BUDGET_ENV = "PI_SUBAGENT_EXECUTION_BUDGET"; export interface EphemeralSubagentExecutionBudget { maxTurns: number; maxMs: number; startedAt: number; maxTokens?: number; } export interface EphemeralSubagentTimeout { idleMs: number; maxMs: number; } export interface EphemeralSubagentExecutorOptions { maxConcurrency: number; maxTurns?: number; maxTokens?: number; timeout: EphemeralSubagentTimeout; } export type EphemeralSubagentActivityEvent = { type: "tool_execution_start"; toolCallId: string; toolName: string; path?: string; } | { type: "tool_execution_end"; toolCallId: string; toolName: string; } | { type: "message_end"; }; export interface EphemeralSubagentRunInput { signal?: AbortSignal; onUpdate?: (text: string) => void; onTokens?: (tokens: number) => void; onActivity?: (event: EphemeralSubagentActivityEvent) => void; prepare: () => Promise<{ launch: PiLaunch; task: string; cwd: string; }>; } interface EphemeralSubagentResultBase { exitCode: number; output: string; outputTruncated: boolean; stderr: string; stopReason?: string; errorMessage?: string; usage?: Usage; } export type EphemeralSubagentResult = (EphemeralSubagentResultBase & { outcome: "success"; }) | (EphemeralSubagentResultBase & { outcome: "failure"; }); export type EphemeralSubagentErrorCode = "aborted" | "timeout" | "turn_limit" | "token_limit" | "spawn" | "protocol" | "prepare" | "callback"; export declare class EphemeralSubagentError extends Error { name: string; readonly code: EphemeralSubagentErrorCode; readonly usage?: Usage; readonly output?: string; constructor(code: EphemeralSubagentErrorCode, message: string, cause?: unknown, usage?: Usage, output?: string); } export interface EphemeralSubagentExecutor { run(input: EphemeralSubagentRunInput): Promise; } /** * Creates a bounded ephemeral executor for callers already running inside Pi. * It reuses the active Pi process invocation; it does not resolve a standalone Pi installation. */ export declare function createEphemeralSubagentExecutor(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor; export declare function capEphemeralSubagentOutput(text: string): string; export declare function addUsage(left: Usage | undefined, right: Usage | undefined): Usage | undefined; export declare function formatDuration(milliseconds: number): string; export {};