/**
 * src/mesh/delegate.ts
 *
 * `mesh.delegate()` — intent-based dispatch to the best available agent.
 *
 * @experimental — sprint-585. Public API may change before v1.x freeze.
 *
 * Replaces manual `withCompute()` boilerplate with a one-liner:
 *
 *     const r = await meshDelegate({ need: "summarize the spec" }, dispatcher);
 *
 * Responsibilities:
 *   1. Classify need → AgentKind (via dispatcher.classify or injected hint).
 *   2. Apply capability attenuation if a parent token is present.
 *   3. Forward to dispatcher with budget/deadline guards.
 *   4. Build a delegation chain link for audit.
 *
 * Streaming (`onChunk`) is a best-effort surface — the dispatcher must opt-in
 * by exposing a `dispatchStream` (not part of base contract). When unavailable,
 * the final result is delivered as a single chunk after completion.
 */
import { type AttenuatedToken } from "./attenuation.js";
import { DefaultMeshDispatcher, type MeshDispatcher } from "./dispatcher.js";
import type { DelegationLink, MeshAgentKind } from "./types.js";
export interface DelegateChunk {
    readonly text: string;
    readonly done: boolean;
    readonly agentKind?: MeshAgentKind;
}
export interface DelegateOptions {
    /** Natural language description of the need. */
    readonly need: string;
    /** Optional structured or free-form context. Serialized to JSON if object. */
    readonly context?: string | Record<string, unknown>;
    /** Caller-requested capabilities (subject to attenuation if parentToken present). */
    readonly capabilities?: ReadonlyArray<string>;
    /** Wall-clock budget in ms. Default 30 000. */
    readonly deadline_ms?: number;
    /** Cost cap in EUR. Default 0.01. */
    readonly max_cost_eur?: number;
    /** Parent token — when present, child scope = parent ∩ requested capabilities. */
    readonly parentToken?: AttenuatedToken;
    /** Optional streaming callback. */
    readonly onChunk?: (chunk: DelegateChunk) => void;
    /** Optional pre-resolved kind — skips classifier. */
    readonly kind?: MeshAgentKind;
    /** Stable child agent identifier (for delegation chain audit). Default: random. */
    readonly childId?: string;
    /** MCP tool name (only when kind === "mcp-tool"). */
    readonly toolName?: string;
    /** MCP tool args (only when kind === "mcp-tool"). */
    readonly toolArgs?: unknown;
}
export interface DelegateResult<T = string> {
    readonly output: T;
    readonly agentKind: MeshAgentKind;
    readonly delegationChain: ReadonlyArray<DelegationLink>;
    readonly costEur: number;
    readonly durationMs: number;
    readonly truncated: boolean;
    /** Token issued to the child — empty when no parentToken given. */
    readonly childToken?: AttenuatedToken;
}
export declare class DelegateAttenuationError extends Error {
    readonly name = "DelegateAttenuationError";
}
/**
 * Delegate a need to the best available agent.
 *
 * Routing priority (when `kind` not pre-set):
 *  1. Dispatcher's `classify(need)` hook if present.
 *  2. Heuristic — see `defaultClassifier`.
 *
 * Capability attenuation:
 *  - If `parentToken` is provided, child scope = parent ∩ requested.
 *  - Empty intersection raises {@link DelegateAttenuationError}.
 *
 * Budget guards:
 *  - When `parentToken.budgetEur < max_cost_eur`, the effective max is parent's.
 *  - Negative budget or deadline → RangeError.
 */
export declare function meshDelegate<T = string>(options: DelegateOptions, dispatcher: MeshDispatcher): Promise<DelegateResult<T>>;
/**
 * Factory variant — binds a dispatcher so callers can call `delegate(opts)`
 * without re-passing the dispatcher every time.
 *
 * Useful for DI in long-lived services.
 */
export declare function createMeshDelegate(dispatcher: MeshDispatcher): <T = string>(options: DelegateOptions) => Promise<DelegateResult<T>>;
/**
 * Re-export DefaultMeshDispatcher as a convenience so callers can do:
 *
 *     import { meshDelegate, DefaultMeshDispatcher } from "@vauban-org/agent-sdk";
 */
export { DefaultMeshDispatcher };
//# sourceMappingURL=delegate.d.ts.map