/** * Interrupt Store (Svelte 5 Runes) * * Rune-based reactive state for managing interrupt state using a lightweight state machine. * Ensures valid state transitions and prevents deadlocks. * * @module stores/interruptStore */ import { SvelteMap } from 'svelte/reactivity'; import type { Interrupt } from '../types/interrupt.js'; import { type InterruptState, type TransitionResult } from '../types/interruptState.js'; /** * Extended interrupt with state machine */ export interface InterruptWithState extends Interrupt { /** State machine state for UI interaction tracking */ machineState: InterruptState; } /** * Get the reactive interrupts map. * Use this in components within $derived() for reactivity. */ export declare function getInterruptsMap(): SvelteMap; /** * Get pending interrupt IDs (interrupts not in a terminal state) */ export declare function getPendingInterruptIds(): string[]; /** * Get pending interrupts array (interrupts not in a terminal state) */ export declare function getPendingInterrupts(): InterruptWithState[]; /** * Get count of pending interrupts */ export declare function getPendingInterruptCount(): number; /** * Get resolved interrupts array */ export declare function getResolvedInterrupts(): InterruptWithState[]; /** * Check if any interrupt is currently submitting */ export declare function getIsAnySubmitting(): boolean; /** * Interrupt store actions for modifying state */ export declare const interruptActions: { /** * Add or update an interrupt in the store * * @param interrupt - The interrupt to add or update */ addInterrupt: (interrupt: Interrupt) => void; /** * Add multiple interrupts to the store * * @param interruptList - Array of interrupts to add */ addInterrupts: (interruptList: Interrupt[]) => void; /** * Start submitting an interrupt (user clicked submit) * * @param interruptId - The interrupt ID * @param value - The value being submitted * @returns Transition result */ startSubmit: (interruptId: string, value: unknown) => TransitionResult; /** * Start cancelling an interrupt (user clicked cancel) * * @param interruptId - The interrupt ID * @returns Transition result */ startCancel: (interruptId: string) => TransitionResult; /** * Mark submission as successful * * @param interruptId - The interrupt ID * @returns Transition result */ submitSuccess: (interruptId: string) => TransitionResult; /** * Mark submission as failed * * @param interruptId - The interrupt ID * @param error - Error message * @returns Transition result */ submitFailure: (interruptId: string, error: string) => TransitionResult; /** * Retry a failed submission * * @param interruptId - The interrupt ID * @returns Transition result */ retry: (interruptId: string) => TransitionResult; /** * Reset an interrupt to idle state * * @param interruptId - The interrupt ID * @returns Transition result */ resetInterrupt: (interruptId: string) => TransitionResult; /** * Mark an interrupt as resolved with the user's response * * @param interruptId - The interrupt ID * @param value - The resolved value */ resolveInterrupt: (interruptId: string, value: unknown) => void; /** * Mark an interrupt as cancelled * * @param interruptId - The interrupt ID */ cancelInterrupt: (interruptId: string) => void; /** * Remove an interrupt from the store * * @param interruptId - The interrupt ID to remove */ removeInterrupt: (interruptId: string) => void; /** * Clear all interrupts for a specific session * * @param sessionId - The session ID to clear interrupts for */ clearSessionInterrupts: (sessionId: string) => void; /** * Alias for clearSessionInterrupts */ clearInterrupts: () => void; /** * Reset all interrupt state */ reset: () => void; }; /** * Get an interrupt by ID * * @param interruptId - The interrupt ID * @returns The interrupt or undefined */ export declare function getInterrupt(interruptId: string): InterruptWithState | undefined; /** * Check if an interrupt is pending (not resolved or cancelled) * * @param interruptId - The interrupt ID * @returns True if the interrupt exists and is pending */ export declare function isInterruptPending(interruptId: string): boolean; /** * Check if an interrupt is currently submitting * * @param interruptId - The interrupt ID * @returns True if the interrupt is being submitted */ export declare function isInterruptSubmitting(interruptId: string): boolean; /** * Get the error for an interrupt * * @param interruptId - The interrupt ID * @returns The error message or undefined */ export declare function getInterruptError(interruptId: string): string | undefined; /** * Get an interrupt by its associated message ID * * @param messageId - The message ID * @returns The interrupt or undefined */ export declare function getInterruptByMessageId(messageId: string): InterruptWithState | undefined; /** * Check if an interrupt has an error * * @param interruptId - The interrupt ID * @returns True if the interrupt has an error */ export declare function interruptHasError(interruptId: string): boolean;