import { type AgentMessage } from '@earendil-works/pi-agent-core'; import type { Api, Model } from '@earendil-works/pi-ai'; import type { Config } from '../config/schema.js'; import type { MessageBus } from '../infra/bus/index.js'; import type { AgentTool } from '@earendil-works/pi-agent-core'; import type { ToolExecutorConfig } from './tools/executor.js'; export interface BuildChildToolsOptions { workspace: string; bus: MessageBus; model: Model; agentId?: string; getConfig: () => Config | undefined; toolExecutorConfig?: Partial; } export interface DelegateChildProgressHooks { mode: 'steps' | 'full'; onProgress: (event: { type: 'tool_start' | 'tool_end' | 'iteration' | 'text_delta' | 'thinking_delta'; toolCallId?: string; toolName?: string; args?: Record; isError?: boolean; count?: number; max?: number; delta?: string; }) => void; } export interface DelegateChildHandleOptions { workspace: string; goal: string; context?: string; requesterSessionKey?: string; allowedToolNames: string[]; maxIterations: number; model: Model; bus: MessageBus; agentId?: string; getConfig: () => Config | undefined; toolExecutorConfig?: Partial; /** * Construct the child agent's tool set. Injected by the caller (delegate-tool) * so this module does not import `tools/factory.js` (which would form a * factory ↔ delegate-tool ↔ child-agent-factory cycle). */ buildChildTools: (opts: BuildChildToolsOptions) => AgentTool[]; /** Optional live progress for workflow subagents. */ progressHooks?: DelegateChildProgressHooks; /** Optional persisted transcript snapshots for hidden workflow subagent sessions. */ onTranscriptSnapshot?: (messages: AgentMessage[]) => void | Promise; } export interface DelegateChildRunResult { summary: string; toolIterations: number; messages: AgentMessage[]; } export interface DelegateChildHandle { run(): Promise; abort(): void; } /** * Build an isolated tool factory (no extensions, no session memory hooks) and a child {@link Agent}. */ export declare function createDelegateChildHandle(options: DelegateChildHandleOptions): DelegateChildHandle;