/** * Capability Dispatch Helper for Universal Dispatch * * Enables capability dispatch for ALL stdlib actions, not just specialized verbs. * When an entity's trait declares a capability for an action, the trait's behavior * handles the action instead of the stdlib default. * * This enables patterns like: * - Troll blocking: TrollTrait handles 'if.action.going' to block passage * - Custom containers: ChestTrait handles 'if.action.opening' for locked chest * - Guardian items: AxeTrait handles 'if.action.taking' while troll guards it * * Resolution modes (ADR-090 extension): * - first-wins: First entity with capability determines result * - any-blocks: Any entity returning valid: false blocks * - all-must-pass: All entities must return valid: true * - highest-priority: Only highest priority entity is checked */ import { ISemanticEvent } from '@sharpee/core'; import { IFEntity, CapabilityBehavior, CapabilitySharedData, ITrait, CapabilityResolution } from '@sharpee/world-model'; import { ActionContext, ValidationResult } from '@sharpee/stdlib'; /** * A single capability claim from an entity. */ export interface CapabilityClaim { /** The entity making the claim */ entity: IFEntity; /** The trait claiming the capability */ trait: ITrait; /** The behavior to use */ behavior: CapabilityBehavior; /** Priority for resolution ordering */ priority: number; /** Resolution override from binding (if any) */ resolutionOverride?: CapabilityResolution; } /** * Result of checking for capability dispatch. */ export interface CapabilityDispatchCheck { /** Whether capability dispatch should be used */ shouldDispatch: boolean; /** The trait claiming the capability (if found) - for single dispatch */ trait?: ITrait; /** The behavior to use (if found) - for single dispatch */ behavior?: CapabilityBehavior; /** The entity with the capability - for single dispatch */ entity?: IFEntity; /** All claims found (for multi-entity resolution) */ claims?: CapabilityClaim[]; /** Resolution mode to use */ resolution?: CapabilityResolution; } /** * Data stored for capability dispatch between phases. */ export interface CapabilityDispatchData { trait: ITrait; behavior: CapabilityBehavior; entityId: string; entityName: string; sharedData: CapabilitySharedData; } /** * Check if capability dispatch should be used for this action and target. * * @param actionId - The action being executed * @param target - The target entity (directObject) - for backward compatibility * @returns Check result with trait and behavior if dispatch should be used */ export declare function checkCapabilityDispatch(actionId: string, target: IFEntity | undefined): CapabilityDispatchCheck; /** * Check if capability dispatch should be used for this action across multiple entities. * * Collects all capability claims from the provided entities, sorts by priority, * and returns the appropriate dispatch information based on resolution config. * * @param actionId - The action being executed * @param entities - All entities involved in the action (directObject, indirectObject, etc.) * @returns Check result with claims and resolution mode */ export declare function checkCapabilityDispatchMulti(actionId: string, entities: (IFEntity | undefined)[]): CapabilityDispatchCheck; /** * Execute capability dispatch validation phase. * * Handles resolution modes: * - first-wins/highest-priority: Single behavior validates * - any-blocks: All behaviors validate, any false blocks * - all-must-pass: All behaviors must return true * * @returns ValidationResult with dispatch data if valid */ export declare function executeCapabilityValidate(check: CapabilityDispatchCheck, context: ActionContext): ValidationResult; /** * Execute capability dispatch execute phase. */ export declare function executeCapabilityExecute(context: ActionContext): void; /** * Execute capability dispatch report phase. */ export declare function executeCapabilityReport(context: ActionContext): ISemanticEvent[]; /** * Execute capability dispatch blocked phase. */ export declare function executeCapabilityBlocked(context: ActionContext, result: ValidationResult, actionId: string): ISemanticEvent[]; //# sourceMappingURL=capability-dispatch-helper.d.ts.map