/**
 * SemanticKernelAdapter -- Orchestrator adapter for Microsoft Semantic Kernel.
 *
 * Hook surface: Semantic Kernel's IFunctionInvocationFilter interface. The
 * adapter provides a filter class the customer registers with the Kernel:
 *
 *   const adapter = new SemanticKernelAdapter(config);
 *   adapter.initialize(orchConfig);
 *   const filter = adapter.toFunctionInvocationFilter();
 *   kernel.functionInvocationFilters.push(filter);
 *
 * Planner lifecycle: plan creation, plan execution, and per-step auditing
 * are intercepted at both the InvokePromptAsync and InvokeFunctionAsync paths.
 * In older SK versions, InvokePromptAsync synthesises a prompt at runtime and
 * bypasses function-level filters. The adapter intercepts both paths
 * explicitly so neither is missed.
 *
 * Kernel memory access governance: memory reads through the kernel are gated
 * through the same policy dispatch as function invocations.
 *
 * Skill-to-skill delegation: SK's plugin/function invocation chaining maps
 * onto the DelegationDecision contract. When function A invokes function B,
 * that constitutes a skill-to-skill delegation and fires preDelegation.
 *
 * DEFERRED-SK-TS-BINDING: Verify TypeScript binding filter registration API
 * at implementation time. The C# binding uses:
 *   kernel.FunctionInvocationFilters.Add(filter)
 * The TS binding (as of 2026-04-22) uses:
 *   kernel.functionInvocationFilters.push(filter)
 * Confirm method name and array vs AddRange pattern before going to prod.
 *
 * No live Semantic Kernel SDK installed. All framework surfaces are shims.
 * Tests use in-process fakes only.
 *
 * Spec: P3-ORCH-01, Section 2.8, AC 16-17
 * @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';
/** Context for a function invocation (maps to SK FunctionInvocationContext). */
export interface SKFunctionInvocationContext {
    /** Unique invocation identifier */
    invocationId: string;
    /** Plugin name (formerly "skill" name) */
    pluginName: string;
    /** Function name within the plugin */
    functionName: string;
    /** Fully-qualified function name: pluginName.functionName */
    fullyQualifiedName: string;
    /** Whether this invocation was triggered by InvokePromptAsync (vs InvokeFunctionAsync) */
    isPromptInvocation: boolean;
    /** Whether this is a memory-read operation */
    isMemoryRead: boolean;
    /** Arguments passed to the function */
    arguments: Record<string, unknown>;
    /** Metadata about the function */
    functionMetadata?: {
        description?: string;
        isSemanticFunction?: boolean;
    };
    /** ISO-8601 timestamp */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/** Result from a function invocation. */
export interface SKFunctionResult {
    invocationId: string;
    pluginName: string;
    functionName: string;
    success: boolean;
    value?: unknown;
    error?: string;
    durationMs?: number;
}
/** Context for a planner invocation. */
export interface SKPlannerContext {
    /** Unique plan execution identifier */
    planId: string;
    /** The goal/objective for the planner */
    goal: string;
    /** Planner type: sequential, stepwise, handlebars, etc. */
    plannerType: string;
    /** Steps in the generated plan */
    steps: SKPlanStep[];
    /** ISO-8601 timestamp when the plan was created */
    createdAt: string;
    metadata?: Record<string, unknown>;
}
/** A single step in a Semantic Kernel plan. */
export interface SKPlanStep {
    /** Step index (0-based) */
    stepIndex: number;
    /** Plugin to invoke */
    pluginName: string;
    /** Function to invoke */
    functionName: string;
    /** Description of this step */
    description?: string;
    /** Parameters for this step */
    parameters: Record<string, unknown>;
}
/** A skill-to-skill delegation event. */
export interface SKSkillDelegationEvent {
    /** Unique delegation identifier */
    delegationId: string;
    /** Calling plugin */
    callerPlugin: string;
    /** Calling function */
    callerFunction: string;
    /** Target plugin being delegated to */
    targetPlugin: string;
    /** Target function being delegated to */
    targetFunction: string;
    /** Arguments passed */
    args: Record<string, unknown>;
    /** ISO-8601 timestamp */
    timestamp: string;
    metadata?: Record<string, unknown>;
}
/**
 * Semantic Kernel function invocation filter.
 *
 * Mirrors the IFunctionInvocationFilter interface from the TS SK binding.
 *
 * DEFERRED-SK-TS-BINDING: Confirm the exact method signature matches the
 * TS binding release. The C# interface uses InvokeAsync(context, next);
 * the TS interface may differ.
 */
export declare class SKGovernanceFilter {
    private adapter;
    constructor(adapter: SemanticKernelAdapter);
    /**
     * Called before a function is invoked (IFunctionInvocationFilter.OnFunctionInvokingAsync).
     * Returns false to block the invocation. Throws OrchestratorError on denial.
     */
    onFunctionInvoking(ctx: SKFunctionInvocationContext): Promise<TaskDecision>;
    /**
     * Called after a function is invoked (IFunctionInvocationFilter.OnFunctionInvokedAsync).
     * Audit hook.
     */
    onFunctionInvoked(ctx: SKFunctionInvocationContext, result: SKFunctionResult): Promise<void>;
}
export interface SemanticKernelAdapterConfig {
    /**
     * Plugin names allowed to be invoked under governance.
     * An empty array causes all function invocations to be denied (fail closed).
     */
    allowedPlugins: string[];
    /**
     * Functions (as "pluginName.functionName") that require reviewer approval.
     */
    sensitiveFunctions: string[];
    /**
     * Plugin names that are treated as memory plugins.
     * Memory reads from these plugins are gated as memory-access operations.
     */
    memoryPluginNames: string[];
    /**
     * Maximum number of steps in a governed plan.
     * Undefined means no limit.
     */
    maxPlanSteps?: number;
}
export declare class SemanticKernelAdapter extends BaseOrchestratorAdapter {
    readonly adapterId = "semantic-kernel";
    readonly orchestratorId = "semantic-kernel";
    private skConfig;
    constructor(config: SemanticKernelAdapterConfig);
    /**
     * Return an SKGovernanceFilter wired to this adapter.
     * Customers register the filter with their Kernel instance:
     *   kernel.functionInvocationFilters.push(adapter.toFunctionInvocationFilter());
     */
    toFunctionInvocationFilter(): SKGovernanceFilter;
    /**
     * Governance check before function invocation.
     *
     * Intercepts both paths:
     *   1. InvokeFunctionAsync -- standard function-level path (all SK versions)
     *   2. InvokePromptAsync -- prompt synthesis path (ctx.isPromptInvocation == true)
     *      Older SK versions bypass function-level filters on this path;
     *      the adapter handles it explicitly here.
     *
     * Memory reads are gated as a separate class of operation.
     *
     * Sensitive functions (by fullyQualifiedName) are routed to the
     * human-reviewer tier.
     */
    handleFunctionInvoking(ctx: SKFunctionInvocationContext): Promise<TaskDecision>;
    /** Audit hook after function invocation. */
    handleFunctionInvoked(ctx: SKFunctionInvocationContext, result: SKFunctionResult): Promise<void>;
    /**
     * Planner governance: intercept plan creation and emit audit events.
     * Each step in the plan emits plan-step-begin / plan-step-end pairs
     * via the existing traversePlanTree or inline here for SK-specific plans.
     */
    handlePlannerExecution(plannerCtx: SKPlannerContext): Promise<PlanDecision>;
    /**
     * Skill-to-skill delegation governance.
     * When a SK function invokes another function, this constitutes a
     * skill-to-skill delegation mapped to the DelegationDecision contract.
     */
    handleSkillDelegation(event: SKSkillDelegationEvent): 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=semantic-kernel.d.ts.map