/**
 * AutoGenAdapter -- Orchestrator adapter for Microsoft AutoGen v0.4.
 *
 * Hook surface: AutoGen v0.4 AgentRuntime message interceptor. The adapter
 * exposes a toMessageInterceptor() method returning an interceptor object
 * that customers register with AgentRuntime:
 *
 *   const adapter = new AutoGenAdapter(config);
 *   adapter.initialize(orchConfig);
 *   const interceptor = adapter.toMessageInterceptor();
 *   runtime.addInterceptor(interceptor);
 *
 * Group-chat governance: each GroupChatManager.step() call maps to a plan
 * step. The adapter emits orchestrator:plan-step-begin and
 * orchestrator:plan-step-end around each step.
 *
 * Termination auditing: when a group chat terminates via speaker-selection
 * exhaustion (no speaker found), the adapter emits
 * orchestrator:termination-by-exhaustion WARN so operators can identify
 * runaway loops.
 *
 * Function-call governance: agent function calls are pre-approved before the
 * LLM dispatches the tool. This is distinct from the LLM provider adapter
 * which fires at the model call level.
 *
 * DEFERRED-AUTOGEN-V04-API: Verify that the AgentRuntime interceptor surface
 * fires before LLM dispatch (not after) at implementation time. The v0.4
 * interceptor API changed from the v0.2 middleware pattern. If the intercept
 * fires after LLM dispatch, the governance check must be restructured.
 *
 * No live AutoGen SDK installed. All framework surfaces are shims.
 * Tests use fake interceptor dispatch with in-process fakes only.
 *
 * Spec: P3-ORCH-01, Section 2.4, AC 8-9
 * @connexum/ai-governance
 */
import { BaseOrchestratorAdapter } from './base';
import { OrchestratorCapabilities, WorkflowContext, WorkflowDecision, WorkflowStepContext, WorkflowStepDecision, WorkflowResult, RoleEdgeContext, RoleEdgeDecision, OrchestratorError } from './index';
import type { TaskContext, TaskDecision, PlanContext, PlanDecision, DelegationContext, DelegationDecision } from './orchestrator-adapter';
/** A message routed between agents in an AutoGen group chat. */
export interface AutoGenMessage {
    /** Unique message identifier */
    messageId: string;
    /** Sender agent name */
    sender: string;
    /** Recipient agent name (or broadcast identifier) */
    recipient: string;
    /** Message content */
    content: string | Record<string, unknown>;
    /** Message type -- text, function_call, function_result, termination */
    messageType: 'text' | 'function_call' | 'function_result' | 'termination';
    /** ISO-8601 timestamp */
    timestamp: string;
    /** Metadata from the AutoGen runtime */
    metadata?: Record<string, unknown>;
}
/** Context for a single GroupChatManager step. */
export interface AutoGenGroupChatStep {
    /** Unique identifier for the group chat session */
    sessionId: string;
    /** Group chat name */
    groupName: string;
    /** Zero-based step index in the chat */
    stepIndex: number;
    /** The agent selected to speak at this step */
    selectedSpeaker?: string;
    /** Whether the step ended because no speaker was found */
    speakerExhausted: boolean;
    /** Messages produced in this step */
    messages: AutoGenMessage[];
    /** ISO-8601 timestamp of the step */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/** A function call request from an AutoGen agent. */
export interface AutoGenFunctionCall {
    /** Unique identifier for this function call */
    callId: string;
    /** Session this call belongs to */
    sessionId: string;
    /** Agent initiating the function call */
    callerAgent: string;
    /** Function/tool name being called */
    functionName: string;
    /** Arguments passed to the function */
    args: Record<string, unknown>;
    /** ISO-8601 timestamp */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/** A message routing event (agent-to-agent delegation). */
export interface AutoGenRoutingEvent {
    /** Unique event identifier */
    routingId: string;
    /** Session this event belongs to */
    sessionId: string;
    /** Source agent */
    fromAgent: string;
    /** Destination agent */
    toAgent: string;
    /** Message being routed */
    message: AutoGenMessage;
    /** Permissions or capabilities being granted with the routing */
    grantedPermissions: string[];
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/**
 * Interceptor object returned by AutoGenAdapter.toMessageInterceptor().
 *
 * Customers register it with AgentRuntime:
 *   runtime.addInterceptor(interceptor);
 *
 * DEFERRED-AUTOGEN-V04-API: The exact registration method name
 * (addInterceptor vs registerMiddleware vs addHook) must be confirmed
 * against the v0.4 release. The method names on this shim are illustrative.
 */
export declare class AutoGenMessageInterceptor {
    private adapter;
    constructor(adapter: AutoGenAdapter);
    /**
     * Called before a message is delivered to the recipient agent.
     * Governance check; returns false to block the message.
     */
    beforeMessage(message: AutoGenMessage): Promise<TaskDecision>;
    /**
     * Called after a message is delivered.
     * Audit hook.
     */
    afterMessage(message: AutoGenMessage): Promise<void>;
    /**
     * Called before a function/tool invocation.
     * Governance check; throws OrchestratorError to block the call.
     */
    beforeFunctionCall(call: AutoGenFunctionCall): Promise<TaskDecision>;
    /**
     * Called when a GroupChatManager step begins.
     * Emits orchestrator:plan-step-begin.
     */
    onGroupChatStepBegin(step: AutoGenGroupChatStep): Promise<void>;
    /**
     * Called when a GroupChatManager step ends.
     * Emits orchestrator:plan-step-end. When speakerExhausted is true,
     * also emits orchestrator:termination-by-exhaustion WARN.
     */
    onGroupChatStepEnd(step: AutoGenGroupChatStep): Promise<void>;
    /**
     * Called when an agent-to-agent routing event occurs.
     * Maps onto the DelegationDecision contract.
     */
    onRouting(event: AutoGenRoutingEvent): Promise<DelegationDecision>;
}
export interface AutoGenAdapterConfig {
    /**
     * Agent names allowed to participate in governed group chats.
     * Empty array causes all group chat steps to be denied (fail closed).
     */
    allowedAgents: string[];
    /**
     * Function/tool names that require reviewer approval before execution.
     */
    sensitiveFunctions: string[];
    /**
     * Maximum steps per group chat session.
     * Sessions exceeding this limit emit termination-by-exhaustion and deny further steps.
     * Undefined means no limit.
     */
    maxGroupChatSteps?: number;
}
export declare class AutoGenAdapter extends BaseOrchestratorAdapter {
    readonly adapterId = "autogen";
    readonly orchestratorId = "autogen";
    private autogenConfig;
    /** Track step counts per session for max-steps enforcement. */
    private sessionStepCounts;
    constructor(config: AutoGenAdapterConfig);
    /**
     * Return an AutoGenMessageInterceptor wired to this adapter.
     * Customers register the returned interceptor with AgentRuntime.
     */
    toMessageInterceptor(): AutoGenMessageInterceptor;
    /**
     * Governance check before a message is delivered.
     * Checks the sender against the allowed agent list and circuit breaker.
     */
    handleMessageBefore(message: AutoGenMessage): Promise<TaskDecision>;
    /** Audit hook after a message is delivered. */
    handleMessageAfter(message: AutoGenMessage): Promise<void>;
    /**
     * Governance check before a function/tool call.
     * Sensitive functions are routed to the human-reviewer tier.
     */
    handleFunctionCallBefore(call: AutoGenFunctionCall): Promise<TaskDecision>;
    /**
     * GroupChatManager step begin.
     * Emits orchestrator:plan-step-begin.
     * Enforces max-step limit.
     */
    handleGroupChatStepBegin(step: AutoGenGroupChatStep): Promise<void>;
    /**
     * GroupChatManager step end.
     * Emits orchestrator:plan-step-end.
     * When speakerExhausted is true, also emits
     * orchestrator:termination-by-exhaustion WARN.
     */
    handleGroupChatStepEnd(step: AutoGenGroupChatStep): Promise<void>;
    /**
     * Agent-to-agent routing governance.
     * Maps onto the DelegationDecision contract.
     */
    handleRouting(event: AutoGenRoutingEvent): Promise<DelegationDecision>;
    startWorkflow(ctx: WorkflowContext): Promise<WorkflowDecision>;
    stepWorkflow(ctx: WorkflowStepContext): Promise<WorkflowStepDecision>;
    completeWorkflow(ctx: WorkflowContext, result: WorkflowResult): Promise<void>;
    preTask(task: TaskContext): Promise<TaskDecision>;
    postTask(task: TaskContext, result: Record<string, unknown>): Promise<void>;
    prePlan(plan: PlanContext): Promise<PlanDecision>;
    postPlan(plan: PlanContext, result: Record<string, unknown>): Promise<void>;
    preDelegation(d: DelegationContext): Promise<DelegationDecision>;
    postDelegation(d: DelegationContext, result: Record<string, unknown>): Promise<void>;
    invokeRoleEdge(edge: RoleEdgeContext): Promise<RoleEdgeDecision>;
    translateError(raw: unknown): OrchestratorError;
    getOrchestratorCapabilities(): OrchestratorCapabilities;
}
//# sourceMappingURL=autogen.d.ts.map