/** * Message Processing Control * * Purpose: * - Provide chat-scoped runtime controls for stopping active message processing. * * Features: * - Registers per-chat processing handles with abort signals. * - Cancels queued and active LLM calls by `worldId` and `chatId`. * - Stops active shell command executions for the same session scope. * - Returns deterministic stop results for IPC/UI feedback. * * Implementation Notes: * - Stop requests are idempotent for repeated calls on the same active operation. * - Abort signals are scoped to active processing handles and released on completion. * - Existing persisted output is preserved; only in-flight work is interrupted. * * Recent Changes: * - 2026-03-04: Added stale-handle self-healing in `hasActiveChatMessageProcessing()` to clear orphaned chat locks. * - 2026-02-13: Added chat-scoped processing handle registry with abort signals so stop requests also prevent follow-up continuation work. * - 2026-02-14: Added `hasActiveChatMessageProcessing()` for chat-scoped lock checks (e.g., message edit guards). */ export interface ChatMessageProcessingHandle { worldId: string; chatId: string; operationId: string; signal: AbortSignal; isStopped: () => boolean; throwIfStopped: () => void; complete: () => void; } export declare function beginChatMessageProcessing(worldId: string, chatId: string): ChatMessageProcessingHandle; export declare function hasActiveChatMessageProcessing(worldId: string, chatId: string): boolean; export declare function throwIfMessageProcessingStopped(signal?: AbortSignal): void; export declare function isMessageProcessingCanceledError(error: unknown): boolean; export interface StopMessageProcessingResult { success: true; worldId: string; chatId: string; stopped: boolean; reason: 'stopped' | 'no-active-process'; stoppedOperations: number; llm: { canceledPending: number; abortedActive: number; }; shell: { killed: number; }; processing: { abortedActive: number; }; } export declare function stopMessageProcessing(worldId: string, chatId: string): StopMessageProcessingResult;