import type { DeterministicReplayEngine } from '@pellux/goodvibes-sdk/platform/core/deterministic-replay';
import type { PermissionSimulator } from '@pellux/goodvibes-sdk/platform/runtime/permissions/simulation';
import type { OpsControlPlane } from '../ops/control-plane.js';
/**
 * Discriminated union of all action kinds that can be attached to a
 * diagnostic entry.
 */
export type DiagnosticActionType = 'load-replay' | 'run-policy-simulation' | 'jump-to-task' | 'jump-to-agent' | 'jump-to-tool-call' | 'retry-task' | 'cancel-task' | 'cancel-agent';
/**
 * Permission tier required to dispatch an action.
 *
 * - `read` — read-only navigation; no state mutation.
 * - `operator` — state-mutating actions available to operators.
 * - `admin` — destructive or sensitive actions requiring elevated access.
 */
export type DiagnosticActionPermission = 'read' | 'operator' | 'admin';
export interface LoadReplayPayload {
    readonly runId: string;
}
export interface RunPolicySimulationPayload {
    readonly toolName: string;
    readonly args: Record<string, unknown>;
}
export interface JumpToTaskPayload {
    readonly taskId: string;
}
export interface JumpToAgentPayload {
    readonly agentId: string;
}
export interface JumpToToolCallPayload {
    readonly callId: string;
}
export interface RetryTaskPayload {
    readonly taskId: string;
    readonly note?: string;
}
export interface CancelTaskPayload {
    readonly taskId: string;
    readonly note?: string;
}
export interface CancelAgentPayload {
    readonly agentId: string;
    readonly note?: string;
}
export type DiagnosticActionPayload = LoadReplayPayload | RunPolicySimulationPayload | JumpToTaskPayload | JumpToAgentPayload | JumpToToolCallPayload | RetryTaskPayload | CancelTaskPayload | CancelAgentPayload;
/** Load-replay action. */
export interface LoadReplayAction {
    readonly type: 'load-replay';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: LoadReplayPayload;
}
/** Run-policy-simulation action. */
export interface RunPolicySimulationAction {
    readonly type: 'run-policy-simulation';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: RunPolicySimulationPayload;
}
/** Jump-to-task action. */
export interface JumpToTaskAction {
    readonly type: 'jump-to-task';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: JumpToTaskPayload;
}
/** Jump-to-agent action. */
export interface JumpToAgentAction {
    readonly type: 'jump-to-agent';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: JumpToAgentPayload;
}
/** Jump-to-tool-call action. */
export interface JumpToToolCallAction {
    readonly type: 'jump-to-tool-call';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: JumpToToolCallPayload;
}
/** Retry-task action. */
export interface RetryTaskAction {
    readonly type: 'retry-task';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: RetryTaskPayload;
}
/** Cancel-task action. */
export interface CancelTaskAction {
    readonly type: 'cancel-task';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: CancelTaskPayload;
}
/** Cancel-agent action. */
export interface CancelAgentAction {
    readonly type: 'cancel-agent';
    readonly permission: DiagnosticActionPermission;
    readonly label: string;
    readonly payload: CancelAgentPayload;
}
/**
 * Discriminated union of all actionable bindings that can be attached to a
 * diagnostic entry. TypeScript narrows the payload type via the `type`
 * discriminant, eliminating the need for unsafe `as` casts in the dispatcher.
 */
export type DiagnosticAction = LoadReplayAction | RunPolicySimulationAction | JumpToTaskAction | JumpToAgentAction | JumpToToolCallAction | RetryTaskAction | CancelTaskAction | CancelAgentAction;
/**
 * A high-severity diagnostic entry with attached remediation actions.
 *
 * The acceptance criterion requires every high-severity diagnostic to have
 * at least one remediation action. Callers that produce `HighSeverityDiagnostic`
 * values must always supply a non-empty `actions` array.
 */
export interface HighSeverityDiagnostic {
    /** Unique entry identifier (correlation ID). */
    readonly id: string;
    /** Short human-readable description of the problem. */
    readonly summary: string;
    /** Domain this diagnostic originates from. */
    readonly domain: string;
    /** Severity — always 'error' or 'warn' for high-severity entries. */
    readonly severity: 'error' | 'warn';
    /** Epoch ms when this diagnostic was produced. */
    readonly ts: number;
    /** Session identifier for correlation. */
    readonly sessionId: string;
    /** Trace identifier for correlation. */
    readonly traceId: string;
    /**
     * Ordered list of remediation actions.
     * Must be non-empty for high-severity entries.
     */
    readonly actions: readonly [DiagnosticAction, ...DiagnosticAction[]];
}
/**
 * Result returned by the dispatcher after attempting to execute an action.
 */
export interface ActionResult {
    /** Whether the action executed successfully. */
    readonly success: boolean;
    /** Human-readable message describing the outcome. */
    readonly message: string;
    /**
     * Whether the failure was due to a permission check (as opposed to a
     * runtime error in the handler).
     */
    readonly permissionDenied?: boolean;
}
/**
 * Navigation callback invoked when a jump action targets a panel entry.
 * The UI registers this callback to implement panel-switching and focus.
 */
export type NavigateToEntryCallback = (target: 'task' | 'agent' | 'tool-call', id: string) => void;
/**
 * Caller-supplied permission check.
 *
 * Receives the required permission tier and returns `true` if the current
 * session/user satisfies that tier. Defaults to allowing 'read' and
 * 'operator' and denying 'admin'.
 */
export type PermissionChecker = (required: DiagnosticActionPermission) => boolean;
/**
 * Configuration for DiagnosticActionDispatcher.
 *
 * All handler fields are optional. When a handler is absent, dispatching
 * an action of the corresponding type returns a graceful failure result
 * rather than throwing.
 */
export interface DiagnosticActionDispatcherConfig {
    /**
     * Replay engine for 'load-replay' actions.
     * When absent, load-replay actions return an error result.
     */
    readonly replayEngine?: DeterministicReplayEngine;
    /**
     * Permission simulator for 'run-policy-simulation' actions.
     * When absent, policy simulation actions return an error result.
     */
    readonly simulator?: PermissionSimulator;
    /**
     * Ops control plane for 'retry-task', 'cancel-task', 'cancel-agent'.
     * When absent, those actions return an error result.
     */
    readonly controlPlane?: OpsControlPlane;
    /**
     * Navigation callback for 'jump-to-*' actions.
     * When absent, jump actions return a success result with a warning note.
     */
    readonly navigateTo?: NavigateToEntryCallback;
    /**
     * Permission checker invoked before dispatching each action.
     * Defaults to: read=allow, operator=allow, admin=deny.
     */
    readonly checkPermission?: PermissionChecker;
}
/**
 * DiagnosticActionDispatcher — executes diagnostic entry actions.
 *
 * Routes incoming DiagnosticAction values to the appropriate handler,
 * performing a permission check before dispatch. All errors are caught
 * and converted to ActionResult failures so callers never receive thrown
 * exceptions from this API.
 *
 * Usage:
 * ```ts
 * const dispatcher = new DiagnosticActionDispatcher({
 *   replayEngine,
 *   simulator,
 *   controlPlane,
 *   navigateTo: (target, id) => focusPanel(target, id),
 * });
 *
 * const result = await dispatcher.dispatch(action);
 * if (!result.success) {
 *   showError(result.message);
 * }
 * ```
 */
export declare class DiagnosticActionDispatcher {
    private readonly _replayEngine;
    private readonly _simulator;
    private readonly _controlPlane;
    private readonly _navigateTo;
    private readonly _checkPermission;
    constructor(config?: DiagnosticActionDispatcherConfig);
    /**
     * Dispatch a diagnostic action.
     *
     * Performs a permission check, then delegates to the appropriate handler.
     * All handler errors are caught and returned as failure ActionResults.
     *
     * @param action - The action to execute.
     * @returns An ActionResult describing the outcome.
     */
    dispatch(action: DiagnosticAction): Promise<ActionResult>;
    private _route;
    private _handleLoadReplay;
    private _handlePolicySimulation;
    private _handleJump;
    private _handleRetryTask;
    private _handleCancelTask;
    private _handleCancelAgent;
}
/**
 * Build a 'load-replay' action for a forensics run ID.
 */
export declare function buildLoadReplayAction(runId: string): DiagnosticAction;
/**
 * Build a 'run-policy-simulation' action for a tool call.
 */
export declare function buildRunPolicySimulationAction(toolName: string, args: Record<string, unknown>): DiagnosticAction;
/**
 * Build a 'jump-to-task' action.
 */
export declare function buildJumpToTaskAction(taskId: string): DiagnosticAction;
/**
 * Build a 'jump-to-agent' action.
 */
export declare function buildJumpToAgentAction(agentId: string): DiagnosticAction;
/**
 * Build a 'jump-to-tool-call' action.
 */
export declare function buildJumpToToolCallAction(callId: string): DiagnosticAction;
/**
 * Build a 'retry-task' action.
 */
export declare function buildRetryTaskAction(taskId: string, note?: string): DiagnosticAction;
/**
 * Build a 'cancel-task' action.
 */
export declare function buildCancelTaskAction(taskId: string, note?: string): DiagnosticAction;
/**
 * Build a 'cancel-agent' action.
 */
export declare function buildCancelAgentAction(agentId: string, note?: string): DiagnosticAction;
/**
 * Create a HighSeverityDiagnostic from a task failure.
 *
 * Attaches retry and jump-to-task actions. Satisfies the acceptance criterion
 * that every high-severity diagnostic has at least one remediation action.
 */
export declare function diagnosticFromTaskFailure(opts: {
    taskId: string;
    description: string;
    error: string;
    sessionId: string;
    traceId: string;
    ts: number;
}): HighSeverityDiagnostic;
/**
 * Create a HighSeverityDiagnostic from an agent failure.
 *
 * Attaches cancel and jump-to-agent actions.
 */
export declare function diagnosticFromAgentFailure(opts: {
    agentId: string;
    task: string;
    error: string;
    sessionId: string;
    traceId: string;
    ts: number;
}): HighSeverityDiagnostic;
/**
 * Create a HighSeverityDiagnostic from a tool contract violation.
 *
 * Attaches a policy simulation action and optionally a jump-to-tool-call action.
 */
export declare function diagnosticFromToolContractViolation(opts: {
    toolName: string;
    message: string;
    callId?: string;
    sessionId: string;
    traceId: string;
    ts: number;
}): HighSeverityDiagnostic;
/**
 * Create a HighSeverityDiagnostic from a forensics/replay run.
 *
 * Attaches a load-replay action so the operator can step through the run.
 */
export declare function diagnosticFromForensicsRun(opts: {
    runId: string;
    summary: string;
    sessionId: string;
    traceId: string;
    ts: number;
}): HighSeverityDiagnostic;
//# sourceMappingURL=actions.d.ts.map