/**
 * OpenAIAgentsAdapter -- Orchestrator adapter for the OpenAI Agents SDK.
 *
 * Hook surface: OpenAI Agents SDK Runner.run lifecycle. The adapter exposes
 * a wrapRunner(runner) method that returns a governance-wrapped runner.
 * Customers substitute their runner with the wrapped version:
 *
 *   const adapter = new OpenAIAgentsAdapter(config);
 *   adapter.initialize(orchConfig);
 *   const result = await adapter.wrapRunner(runner).run(agent, input);
 *
 * Handoff governance: The Agents SDK's agent-to-agent handoff is a
 * first-class primitive. Handoffs map onto the DelegationDecision contract.
 * A governance check fires at each handoff boundary before the SDK routes
 * control to the target agent.
 *
 * Tool-call governance: Distinct from the OpenAI LLM provider adapter
 * (src/llm-adapters/openai.ts). The Agents SDK adapter fires at handoff and
 * plan boundaries. The provider adapter fires at the model call level.
 * Both emit to the same audit chain with distinct event types:
 *   - Agents SDK layer: 'orchestrator:delegation-approved/denied' (handoff)
 *   - Provider layer:   'llm:request-intercepted' (model call)
 * No duplicate enforcement path is created.
 *
 * Session-state auditing: The Runner maintains session state across turns.
 * The adapter emits state transitions as part of the audit trail using
 * orchestrator:plan-step-begin / orchestrator:plan-step-end pairs.
 *
 * DEFERRED-OPENAI-AGENTS-V1-API: Verify Runner hook surface at implementation
 * time. As of 2026-04-22 the Agents SDK is at v1.x; the Runner.run lifecycle
 * hooks (on_handoff, on_tool_call, on_run_start, on_run_end) are confirmed
 * in the Python SDK. The TypeScript SDK hook surface needs verification.
 *
 * No live OpenAI Agents SDK installed. All framework surfaces are shims.
 * Tests use in-process fakes only.
 *
 * Spec: P3-ORCH-01, Section 2.7, AC 14-15
 * @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';
/** An agent definition in the OpenAI Agents SDK. */
export interface OAAgent {
    /** Unique agent name */
    name: string;
    /** Optional role label for governance policy dispatch */
    role?: string;
    /** Model identifier used by this agent */
    model?: string;
    /** Metadata */
    metadata?: Record<string, unknown>;
}
/** Represents a run in the OpenAI Agents SDK. */
export interface OARunContext {
    /** Unique run ID (generated by the SDK) */
    runId: string;
    /** The agent being run */
    agent: OAAgent;
    /** The input to the run */
    input: string | Record<string, unknown>;
    /** ISO-8601 timestamp of run start */
    startedAt: string;
    /** Session state at the start of the run */
    sessionState?: Record<string, unknown>;
    /** Metadata from the caller */
    metadata?: Record<string, unknown>;
}
/** Run completion event from the SDK. */
export interface OARunResult {
    runId: string;
    success: boolean;
    /** Final output from the agent */
    output?: string | Record<string, unknown>;
    /** Updated session state after the run */
    finalState?: Record<string, unknown>;
    /** Error message if the run failed */
    error?: string;
    durationMs?: number;
}
/** Handoff event: one agent handing control to another. */
export interface OAHandoffEvent {
    /** Unique identifier for this handoff */
    handoffId: string;
    /** Run ID this handoff belongs to */
    runId: string;
    /** The agent handing off */
    fromAgent: OAAgent;
    /** The agent receiving control */
    toAgent: OAAgent;
    /** Input passed to the target agent */
    handoffInput: string | Record<string, unknown>;
    /** ISO-8601 timestamp */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/** Tool/function call event from the Agents SDK. */
export interface OAToolCallEvent {
    /** Unique identifier for this tool call */
    toolCallId: string;
    /** Run ID this call belongs to */
    runId: string;
    /** Agent initiating the tool call */
    callerAgent: OAAgent;
    /** Tool name */
    toolName: string;
    /** Tool arguments */
    args: Record<string, unknown>;
    /** ISO-8601 timestamp */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/** Session state transition event. */
export interface OAStateTransitionEvent {
    /** Run ID */
    runId: string;
    /** Description of the state transition */
    transitionDescription: string;
    /** State before the transition */
    previousState: Record<string, unknown>;
    /** State after the transition */
    newState: Record<string, unknown>;
    /** Zero-based step index */
    stepIndex: number;
    /** ISO-8601 timestamp */
    timestamp: string;
}
/**
 * Governance-wrapped Runner returned by OpenAIAgentsAdapter.wrapRunner().
 *
 * DEFERRED-OPENAI-AGENTS-V1-API: The actual Runner class interface needs
 * verification against the SDK. This shim exposes the hooks as explicit
 * methods that the customer's integration code or a thin SDK wrapper calls.
 */
export declare class GovernanceWrappedRunner {
    private adapter;
    constructor(adapter: OpenAIAgentsAdapter);
    /**
     * Called when a run starts (maps to Runner.run entry).
     * Governance check; throws OrchestratorError if denied.
     */
    onRunStart(ctx: OARunContext): Promise<WorkflowDecision>;
    /**
     * Called when a run completes.
     * Audit hook.
     */
    onRunEnd(ctx: OARunContext, result: OARunResult): Promise<void>;
    /**
     * Called before a handoff (agent-to-agent control transfer).
     * Governance check; throws OrchestratorError if denied.
     */
    onHandoff(event: OAHandoffEvent): Promise<DelegationDecision>;
    /**
     * Called before a tool/function call at the Agents SDK layer.
     * Distinct from the LLM provider adapter tool-use check.
     */
    onToolCall(event: OAToolCallEvent): Promise<TaskDecision>;
    /**
     * Called when session state transitions between steps.
     * Emits orchestrator:plan-step-begin / plan-step-end pair.
     */
    onStateTransition(event: OAStateTransitionEvent): Promise<void>;
}
export interface OpenAIAgentsAdapterConfig {
    /**
     * Agent names permitted to be run under governance.
     * Empty array causes all run starts to be denied (fail closed).
     */
    allowedAgents: string[];
    /**
     * Tool names that require reviewer approval at the Agents SDK layer.
     * Note: this is orthogonal to the LLM provider adapter's tool check.
     */
    sensitiveTools: string[];
    /**
     * Agent names that require governance approval before receiving a handoff.
     * Empty means all handoffs are allowed (after general approval check).
     */
    sensitiveHandoffTargets: string[];
    /**
     * Maximum number of plan steps per run.
     * Undefined means no limit.
     */
    maxPlanSteps?: number;
}
export declare class OpenAIAgentsAdapter extends BaseOrchestratorAdapter {
    readonly adapterId = "openai-agents";
    readonly orchestratorId = "openai-agents";
    private agentsConfig;
    constructor(config: OpenAIAgentsAdapterConfig);
    /**
     * Return a GovernanceWrappedRunner wired to this adapter.
     * Consumers substitute this for their SDK Runner.
     */
    wrapRunner(_runner?: unknown): GovernanceWrappedRunner;
    /**
     * Governance check on run start.
     * Validates the agent against the allowedAgents list.
     */
    handleRunStart(ctx: OARunContext): Promise<WorkflowDecision>;
    /** Audit hook on run completion. */
    handleRunEnd(ctx: OARunContext, result: OARunResult): Promise<void>;
    /**
     * Handoff governance.
     * Agent-to-agent handoffs are first-class primitives mapping onto
     * the DelegationDecision contract.
     *
     * Sensitive handoff targets require reviewer approval.
     * This is distinct from the LLM provider adapter: the provider adapter
     * fires at the model call; this adapter fires at the handoff boundary.
     */
    handleHandoff(event: OAHandoffEvent): Promise<DelegationDecision>;
    /**
     * Tool-call governance at the Agents SDK layer.
     * This fires at plan/handoff boundaries, not at the model call level.
     * The LLM provider adapter fires at model call level via a separate path.
     * Both emit to the same audit chain with distinct event types (AC 15).
     */
    handleToolCall(event: OAToolCallEvent): Promise<TaskDecision>;
    /**
     * Session state transition auditing.
     * Emits orchestrator:plan-step-begin / plan-step-end pair per transition.
     */
    handleStateTransition(event: OAStateTransitionEvent): Promise<void>;
    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=openai-agents.d.ts.map