import type { Tool } from '../types';
import type { IChatClient } from '../core/chatClient';
import { type HelperTaskType, type ModelRoutingDecision, type ModelRoutingInput, type ModelRoutingPolicy } from './modelRouting';
import { type AgentDefinition } from './agentLoader';
export interface SubagentConfig {
    name: string;
    systemPrompt: string;
    model?: string;
    tools?: Tool[];
    /** When set, only tools whose name appears in this list are visible. Applied after `tools` is resolved. */
    allowedTools?: string[];
    maxTurns?: number;
    preset?: HelperTaskType;
    routingPolicy?: ModelRoutingPolicy;
    routingInput?: Partial<ModelRoutingInput>;
    routingDecision?: ModelRoutingDecision;
    metricsProjectDir?: string;
    /** When set, resolves a built-in or custom agent definition and uses it as defaults. Explicit fields on this config still override the definition. */
    agentId?: string;
    /** Caller-provided custom agent definitions. Built-ins are consulted as a fallback. */
    customAgents?: AgentDefinition[];
    /** When set, the run is registered in the active sub-agent registry under this id so the UI bar and cancel endpoint can see it. */
    runId?: string;
    /** Optional abort signal piped into the inner queryLoop. Used by the cancel endpoint together with runId. */
    abortSignal?: AbortSignal;
    /** Optional listener invoked for every loop event. Useful for surfacing live progress to a parent UI. */
    onEvent?: (event: {
        type: string;
        [key: string]: unknown;
    }) => void;
}
export interface SubagentRoutingMetric {
    timestamp: string;
    name: string;
    preset?: HelperTaskType;
    model?: string;
    tier?: string;
    escalated?: boolean;
    reasons: string[];
    success: boolean;
    durationMs: number;
    outputChars: number;
}
export declare const AgentTool: Tool;
/**
 * Build a callable subagent tool bound to a parent chat client, the available
 * tool list, and an accessor that returns the current set of custom agent
 * definitions. The returned tool can be registered like any other tool and
 * the model can call it with `prompt` and either `agent_id` (preferred) or
 * legacy `type`.
 */
export interface SubagentToolDeps {
    getParentClient(): IChatClient;
    getAvailableTools(): Tool[];
    getCustomAgents?: () => AgentDefinition[];
    /** Optional override of runSubagent — primarily for tests. */
    runner?: typeof runSubagent;
    /**
     * Optional recall provider. When set, the subagent receives a Knowledge
     * Graph recall block prepended to its prompt so it shares the same
     * project memory as the parent chat.
     */
    getRecallContext?: (prompt: string) => Promise<string | undefined>;
}
export declare function createSubagentTool(deps: SubagentToolDeps): Tool;
export declare function runSubagent(config: SubagentConfig, prompt: string, parentClient: IChatClient, availableTools: Tool[]): Promise<string>;
export declare function resolveSubagentConfig(config: SubagentConfig, prompt: string): SubagentConfig;
export declare function appendSubagentRoutingMetric(projectDir: string, metric: SubagentRoutingMetric): Promise<string>;
export declare function listSubagentRoutingMetrics(projectDir: string, limit?: number): Promise<SubagentRoutingMetric[]>;
//# sourceMappingURL=subagent.d.ts.map