/**
 * src/mesh/dispatcher.ts
 *
 * Mesh dispatcher — routes a {@link DispatchIntent} to a concrete executor
 * (LLM, OODA, MCP tool, plugin, fallback) and returns a uniform result shape.
 *
 * @experimental — sprint-585. Public API may change before v1.x freeze.
 *
 * The dispatcher knows NOTHING about budget tokens or capability attenuation —
 * those concerns live in `delegate.ts`. Keep this module narrowly scoped to
 * "given an intent kind, run the right executor".
 *
 * Default classifier is a heuristic (no LLM call). Callers may inject their own.
 */
import type { MeshAgentKind } from "./types.js";
export interface DispatchIntent {
    /** Resolved kind — caller (or default classifier) decided which executor to use. */
    readonly kind: MeshAgentKind;
    /** Natural-language need. */
    readonly need: string;
    /** Optional context (structured data stringified, or free text). */
    readonly context?: string;
    /** Wall-clock deadline in ms. */
    readonly deadline_ms?: number;
    /** Max cost in EUR. */
    readonly max_cost_eur?: number;
    /** Optional MCP tool name (only used when kind === "mcp-tool"). */
    readonly toolName?: string;
    /** Opaque MCP tool args (only used when kind === "mcp-tool"). */
    readonly toolArgs?: unknown;
}
export interface DispatchResult {
    readonly output: string;
    readonly costEur: number;
    readonly durationMs: number;
    /** True if the executor stopped on deadline before producing a final answer. */
    readonly truncated: boolean;
}
export interface MeshDispatcher {
    dispatch(intent: DispatchIntent): Promise<DispatchResult>;
}
/**
 * Default heuristic classifier — zero LLM cost.
 *
 *  - OODA when need contains an OODA hint OR has ≥ 3 sentence-terminating marks.
 *  - MCP-tool when need contains an MCP hint and is short (< 80 chars).
 *  - LLM-router otherwise.
 *
 * Note: callers wanting LLM-based classification should inject a custom
 * `classifier` via {@link DispatcherConfig}.
 */
export declare function defaultClassifier(need: string): MeshAgentKind;
export interface DispatcherConfig {
    /** Override the default heuristic classifier. */
    readonly classifier?: (need: string) => MeshAgentKind;
    /**
     * Executor for `kind === "llm-router"`.
     * Must respect `deadline_ms` (caller-provided).
     */
    readonly llmExecutor?: (prompt: string, deadlineMs: number) => Promise<string>;
    /**
     * Executor for `kind === "ooda"`. Receives need + optional context.
     * Must respect `deadline_ms` (passed via 3rd arg).
     */
    readonly oodaExecutor?: (need: string, context: string | undefined, deadlineMs: number) => Promise<string>;
    /**
     * Registry of MCP tools. Keyed by tool name; values are pre-bound async fns.
     */
    readonly mcpTools?: Readonly<Record<string, (args: unknown) => Promise<string>>>;
    /**
     * Optional plugin executor (last-resort, kind === "plugin").
     */
    readonly pluginExecutor?: (need: string, context: string | undefined) => Promise<string>;
    /**
     * Fallback executor when no other kind matches. Default: echoes need.
     */
    readonly fallbackExecutor?: (intent: DispatchIntent) => Promise<string>;
    /**
     * Cost model in EUR per millisecond. Default 0 (free-tier accounting).
     * Production: inject a model that consults `tracking/provider-usage`.
     */
    readonly costPerMs?: number;
}
/**
 * Default dispatcher — composes injected executors into a uniform
 * "intent → result" pipeline, including deadline enforcement and cost
 * accounting.
 *
 * Concurrency notes:
 *  - Uses `AbortController` + `setTimeout` to enforce `deadline_ms`.
 *  - On deadline trip, returns `truncated: true` and the executor must respect
 *    the abort signal it received via Promise.race.
 */
export declare class DefaultMeshDispatcher implements MeshDispatcher {
    private readonly classifier;
    private readonly llm;
    private readonly ooda;
    private readonly mcpTools;
    private readonly plugin;
    private readonly fallback;
    private readonly costPerMs;
    constructor(config?: DispatcherConfig);
    /** Classify a need without dispatching — exposed for callers that pre-route. */
    classify(need: string): MeshAgentKind;
    dispatch(intent: DispatchIntent): Promise<DispatchResult>;
    private executorFor;
    private runWithDeadline;
}
export declare class DeadlineExceededError extends Error {
    readonly name = "MeshDeadlineExceededError";
    readonly partial?: string;
    constructor(deadlineMs: number, partial?: string);
}
export declare class MeshDispatchError extends Error {
    readonly name = "MeshDispatchError";
    readonly code: string;
    constructor(message: string, code: string);
}
//# sourceMappingURL=dispatcher.d.ts.map