import type { OperationSession, CapabilityContext } from '@zhin.js/feature-kit'; import type { UserInteraction } from '@zhin.js/im-contract'; import type { PluginId, RuntimeSnapshot } from '@zhin.js/plugin-runtime'; /** Handler context contains only generation-safe capabilities and user interactions. */ export interface HandlerContext extends CapabilityContext { /** Canonical message operations share their bound view; native events without a message projection have none. */ readonly session: OperationSession | undefined; readonly interaction?: UserInteraction; } export interface HandlerDispatchOptions { /** Complete, leased snapshot for this operation rather than provider build order. */ readonly snapshot?: RuntimeSnapshot; /** Cancellation of this actual dispatch, including non-message Endpoint events. */ readonly signal?: AbortSignal; /** Build a user interaction for this dispatch (message or side-event). */ resolveInteraction?: (event: string, args: readonly unknown[], owner: PluginId) => UserInteraction | undefined; /** * A handler threw `error`: resolve `true` once the runtime answered it (dispatch continues with * the next handler), `false` to let it propagate. */ recover?: (error: unknown, owner: PluginId, args: readonly unknown[]) => boolean | Promise; }