import type { Mastra } from '../../index.js';
import type { AgentExecutionOptions } from '../../agent/index.js';
import type { MultiPrimitiveExecutionOptions, NetworkOptions } from '../../agent/agent.types.js';
import { Agent } from '../../agent/index.js';
import type { MessageListInput } from '../../agent/message-list/index.js';
import type { StructuredOutputOptions } from '../../agent/types.js';
import type { ObservabilityContext } from '../../observability/index.js';
import { ProcessorRunner } from '../../processors/runner.js';
import type { RequestContext } from '../../request-context/index.js';
import { MastraAgentNetworkStream } from '../../stream/MastraAgentNetworkStream.js';
import type { IdGeneratorContext } from '../../types/index.js';
import type { Step } from '../../workflows/step.js';
import type { CompletionConfig } from './validation.js';
/**
 * Type for ID generator function that can optionally accept context
 */
type NetworkIdGenerator = (context?: IdGeneratorContext) => string;
/** @internal Exported for testing purposes */
export declare function getRoutingAgent({ requestContext, agent, routingConfig, memoryConfig, }: {
    agent: Agent;
    requestContext: RequestContext;
    routingConfig?: {
        additionalInstructions?: string;
    };
    memoryConfig?: any;
}): Promise<Agent<"routing-agent", import("../../agent").ToolsInput, undefined, unknown>>;
export declare function getLastMessage(messages: MessageListInput): string;
export declare function prepareMemoryStep({ threadId, resourceId, messages, routingAgent, requestContext, generateId, memoryConfig, ...rest }: {
    threadId: string;
    resourceId: string;
    messages: MessageListInput;
    routingAgent: Agent;
    requestContext: RequestContext;
    generateId: NetworkIdGenerator;
    memoryConfig?: any;
} & Partial<ObservabilityContext>): Promise<{
    thread: import("../../memory").StorageThreadType | undefined;
}>;
export declare function createNetworkLoop({ networkName, requestContext, runId, agent, generateId, routingAgentOptions, routingAgentMemoryConfig, routing, onStepFinish, onError, onAbort, abortSignal, }: {
    networkName: string;
    requestContext: RequestContext;
    runId: string;
    agent: Agent;
    routingAgentOptions?: Pick<MultiPrimitiveExecutionOptions, 'modelSettings'>;
    routingAgentMemoryConfig?: any;
    generateId: NetworkIdGenerator;
    routing?: {
        additionalInstructions?: string;
        verboseIntrospection?: boolean;
    };
    onStepFinish?: (event: any) => Promise<void> | void;
    onError?: ({ error }: {
        error: Error | string;
    }) => Promise<void> | void;
    onAbort?: (event: any) => Promise<void> | void;
    abortSignal?: AbortSignal;
}): Promise<{
    networkWorkflow: import("../../workflows").Workflow<import("../../workflows").DefaultEngineType, Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "Agent-Network-Outer-Workflow", unknown, {
        task: string;
        primitiveId: string;
        primitiveType: "tool" | "none" | "agent" | "workflow";
        iteration: number;
        isOneOff: boolean;
        verboseIntrospection: boolean;
        result?: string | undefined;
        threadId?: string | undefined;
        threadResourceId?: string | undefined;
    }, {
        task: string;
        primitiveId: string;
        primitiveType: "tool" | "none" | "agent" | "workflow";
        prompt: string;
        result: string;
        iteration: number;
        isOneOff: boolean;
        isComplete?: boolean | undefined;
        completionReason?: string | undefined;
        threadId?: string | undefined;
        threadResourceId?: string | undefined;
    }, {
        task: string;
        primitiveId: string;
        primitiveType: "tool" | "none" | "agent" | "workflow";
        iteration: number;
        isOneOff: boolean;
        verboseIntrospection: boolean;
        result?: string | undefined;
        threadId?: string | undefined;
        threadResourceId?: string | undefined;
    }, unknown>;
    processorRunner: ProcessorRunner | null;
}>;
export declare function networkLoop<OUTPUT = undefined>({ networkName, requestContext, runId, routingAgent, routingAgentOptions, generateId, maxIterations, threadId, resourceId, messages, validation, routing, onIterationComplete, resumeData, autoResumeSuspendedTools, mastra, structuredOutput, onStepFinish, onError, onAbort, abortSignal, }: {
    networkName: string;
    requestContext: RequestContext;
    runId: string;
    routingAgent: Agent<any, any, any, any>;
    routingAgentOptions?: AgentExecutionOptions<OUTPUT>;
    generateId: NetworkIdGenerator;
    maxIterations: number;
    threadId?: string;
    resourceId?: string;
    messages: MessageListInput;
    /**
     * Completion checks configuration.
     * When provided, runs checks to verify task completion.
     */
    validation?: CompletionConfig;
    /**
     * Optional routing configuration to customize primitive selection behavior.
     */
    routing?: {
        additionalInstructions?: string;
        verboseIntrospection?: boolean;
    };
    /**
     * Optional callback fired after each iteration completes.
     */
    onIterationComplete?: (context: {
        iteration: number;
        primitiveId: string;
        primitiveType: 'agent' | 'workflow' | 'tool' | 'none';
        result: string;
        isComplete: boolean;
    }) => void | Promise<void>;
    /**
     * Structured output configuration for the network's final result.
     * When provided, generates a structured response matching the schema.
     */
    structuredOutput?: OUTPUT extends {} ? StructuredOutputOptions<OUTPUT> : never;
    resumeData?: any;
    autoResumeSuspendedTools?: boolean;
    mastra?: Mastra;
    onStepFinish?: NetworkOptions<OUTPUT>['onStepFinish'];
    onError?: NetworkOptions<OUTPUT>['onError'];
    onAbort?: NetworkOptions<OUTPUT>['onAbort'];
    abortSignal?: NetworkOptions<OUTPUT>['abortSignal'];
}): Promise<MastraAgentNetworkStream<OUTPUT>>;
export {};
//# sourceMappingURL=index.d.ts.map