import type { InvocationState, InvokableAgent } from '../types/agent.js';
import type { MultiAgentInput } from './multiagent.js';
import type { MultiAgentStreamEvent } from './events.js';
import { NodeResult } from './state.js';
import type { MultiAgentState, NodeResultUpdate } from './state.js';
import type { MultiAgent } from './multiagent.js';
import type { z } from 'zod';
/**
 * Known node type identifiers with extensibility for custom nodes.
 */
export type NodeType = 'agentNode' | 'multiAgentNode' | (string & {});
/**
 * Configuration for a node execution.
 */
export interface NodeConfig {
    /**
     * Optional description of what this node does.
     */
    description?: string;
}
/**
 * Per-invocation options passed from the orchestrator to a node.
 */
export interface NodeInputOptions {
    /**
     * Structured output schema for this node invocation.
     */
    structuredOutputSchema?: z.ZodSchema;
    /**
     * Per-invocation state forwarded to the node's underlying agent. See
     * {@link InvocationState}. Shared by reference across all nodes so one node's
     * hooks/tools can read state written by a previous node.
     */
    invocationState?: InvocationState;
    /**
     * Cancellation signal forwarded to the node's underlying agent. Used by
     * orchestrators to enforce per-node timeouts or propagate external cancellation.
     */
    cancelSignal?: AbortSignal;
}
/**
 * Abstract base class for all multi-agent orchestration nodes.
 *
 * Uses the template method pattern: {@link stream} handles orchestration
 * boilerplate (duration measurement, status tracking, error capture) and
 * delegates to {@link handle} for node-specific execution logic.
 */
export declare abstract class Node {
    readonly type: string;
    /** Unique identifier for this node within the orchestration. */
    readonly id: string;
    /** Per-node configuration. */
    readonly config: NodeConfig;
    /**
     * @param id - Unique identifier for this node within the orchestration
     * @param config - Per-node configuration
     */
    constructor(id: string, config: NodeConfig);
    /**
     * Execute the node. Handles duration measurement, error capture,
     * and delegates to handle() for node-specific logic.
     *
     * @param input - Input to pass to the node (string or content blocks)
     * @param state - The current multi-agent state
     * @param options - Per-invocation options from the orchestrator
     * @returns Async generator yielding streaming events and returning a NodeResult
     */
    stream(input: MultiAgentInput, state: MultiAgentState, options?: NodeInputOptions): AsyncGenerator<MultiAgentStreamEvent, NodeResult, undefined>;
    /**
     * Node-specific execution logic implemented by subclasses.
     *
     * @param input - Input to process (string or content blocks)
     * @param state - The current multi-agent state
     * @param options - Per-invocation options from the orchestrator
     * @returns Async generator yielding streaming events and returning a partial result
     */
    abstract handle(input: MultiAgentInput, state: MultiAgentState, options?: NodeInputOptions): AsyncGenerator<MultiAgentStreamEvent, NodeResultUpdate, undefined>;
}
/**
 * Options for creating an {@link AgentNode}.
 */
export interface AgentNodeOptions {
    /** The agent to wrap as a node. */
    agent: InvokableAgent;
    /**
     * Per-node wall-clock ceiling in milliseconds. Overrides the orchestrator's
     * default node timeout. Cancellation is cooperative — a tool that neither
     * polls its cancel signal nor forwards it to a cancellable API can run past
     * this deadline.
     */
    timeout?: number;
    /**
     * When `true`, the wrapped agent accumulates state (messages, appState,
     * modelState) across node executions. Useful for graph patterns where a
     * node is revisited and should build on its previous work (e.g., an
     * analyst that accumulates findings, or iterative refinement).
     *
     * When `false` (default), the agent's state is snapshotted before each
     * execution and restored in `finally`, so the node is stateless across
     * visits.
     *
     * Throws at construction time when set to `true` with a non-`Agent`
     * `InvokableAgent`, since snapshot/restore only applies to `Agent` instances.
     */
    preserveContext?: boolean;
}
/**
 * Node that wraps an {@link InvokableAgent} instance for multi-agent orchestration.
 *
 * By default, when the wrapped agent is an {@link Agent} instance, its internal
 * state is snapshot/restored around each execution so it remains unchanged
 * after the node completes. Pass `preserveContext: true` to opt out and let the
 * wrapped agent accumulate state across node executions.
 */
export declare class AgentNode extends Node {
    readonly type: "agentNode";
    private readonly _agent;
    /**
     * Per-node wall-clock ceiling in milliseconds. When set, overrides the orchestrator's
     * `nodeTimeout` for this node. Undefined means "fall back to the orchestrator's setting."
     * See {@link AgentNodeOptions.timeout}.
     */
    readonly timeout?: number;
    /**
     * Whether the wrapped agent retains state across node executions.
     * See {@link AgentNodeOptions.preserveContext}.
     */
    readonly preserveContext: boolean;
    constructor(options: AgentNodeOptions);
    get agent(): InvokableAgent;
    /**
     * Executes the wrapped agent, yielding each agent streaming event
     * wrapped in a {@link NodeStreamUpdateEvent}.
     *
     * @param input - Input to pass to the agent
     * @param state - The current multi-agent state
     * @param options - Per-invocation options from the orchestrator
     * @returns Async generator yielding streaming events and returning the agent's content blocks
     */
    handle(input: MultiAgentInput, state: MultiAgentState, options?: NodeInputOptions): AsyncGenerator<MultiAgentStreamEvent, NodeResultUpdate, undefined>;
}
/**
 * Options for creating a {@link MultiAgentNode}.
 */
export interface MultiAgentNodeOptions extends NodeConfig {
    /** The orchestrator to wrap as a node. */
    orchestrator: MultiAgent;
}
/**
 * Node that wraps a multi-agent orchestrator (e.g. Graph) for nested composition.
 *
 * Inner {@link NodeStreamUpdateEvent}s pass through to preserve the original
 * node's identity. All other events are wrapped in a new {@link NodeStreamUpdateEvent}
 * tagged with this node's identity.
 */
export declare class MultiAgentNode extends Node {
    readonly type: "multiAgentNode";
    private readonly _orchestrator;
    constructor(options: MultiAgentNodeOptions);
    get orchestrator(): MultiAgent;
    /**
     * Executes the wrapped orchestrator. Inner {@link NodeStreamUpdateEvent}s
     * pass through as-is; all other events are wrapped in a new
     * {@link NodeStreamUpdateEvent} tagged with this node's identity.
     *
     * @param input - Input to pass to the orchestrator
     * @param state - The current multi-agent state
     * @param options - Per-invocation options. `invocationState` is forwarded to the
     *   nested orchestrator; `structuredOutputSchema` is not applicable here.
     * @returns Async generator yielding streaming events and returning the orchestrator's content
     */
    handle(input: MultiAgentInput, state: MultiAgentState, options?: NodeInputOptions): AsyncGenerator<MultiAgentStreamEvent, NodeResultUpdate, undefined>;
}
/**
 * A node definition accepted by orchestration constructors.
 *
 * Pass an {@link InvokableAgent} or {@link MultiAgent} directly for the simple case,
 * use typed options objects for per-node configuration, or provide pre-built
 * {@link Node} instances for full control.
 */
export type NodeDefinition = InvokableAgent | MultiAgent | Node | AgentNodeOptions | MultiAgentNodeOptions;
//# sourceMappingURL=nodes.d.ts.map