@sharpee/world-model 1.5.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/annotations/index.d.ts.map +1 -1
  2. package/annotations/index.js.map +1 -1
  3. package/annotations/types.d.ts.map +1 -1
  4. package/annotations/types.js.map +1 -1
  5. package/behaviors/attack.d.ts.map +1 -1
  6. package/behaviors/attack.js.map +1 -1
  7. package/behaviors/behavior.d.ts.map +1 -1
  8. package/behaviors/behavior.js.map +1 -1
  9. package/behaviors/index.d.ts.map +1 -1
  10. package/behaviors/index.js.map +1 -1
  11. package/capabilities/action-interceptor.d.ts.map +1 -1
  12. package/capabilities/action-interceptor.js.map +1 -1
  13. package/capabilities/capability-behavior.d.ts.map +1 -1
  14. package/capabilities/capability-behavior.js.map +1 -1
  15. package/capabilities/capability-binding.d.ts +58 -0
  16. package/capabilities/capability-binding.d.ts.map +1 -0
  17. package/capabilities/capability-binding.js +25 -0
  18. package/capabilities/capability-binding.js.map +1 -0
  19. package/capabilities/capability-defaults.d.ts.map +1 -1
  20. package/capabilities/capability-defaults.js.map +1 -1
  21. package/capabilities/capability-helpers.d.ts.map +1 -1
  22. package/capabilities/capability-helpers.js.map +1 -1
  23. package/capabilities/entity-builder.d.ts.map +1 -1
  24. package/capabilities/entity-builder.js.map +1 -1
  25. package/capabilities/index.d.ts +2 -2
  26. package/capabilities/index.d.ts.map +1 -1
  27. package/capabilities/index.js +1 -19
  28. package/capabilities/index.js.map +1 -1
  29. package/capabilities/interceptor-binding.d.ts +57 -0
  30. package/capabilities/interceptor-binding.d.ts.map +1 -0
  31. package/capabilities/interceptor-binding.js +26 -0
  32. package/capabilities/interceptor-binding.js.map +1 -0
  33. package/capabilities/interceptor-helpers.d.ts.map +1 -1
  34. package/capabilities/interceptor-helpers.js.map +1 -1
  35. package/capabilities/types.d.ts.map +1 -1
  36. package/capabilities/types.js.map +1 -1
  37. package/commands/command-types.d.ts.map +1 -1
  38. package/commands/command-types.js.map +1 -1
  39. package/commands/index.d.ts.map +1 -1
  40. package/commands/index.js.map +1 -1
  41. package/commands/parsed-command.d.ts.map +1 -1
  42. package/commands/parsed-command.js.map +1 -1
  43. package/commands/validated-command.d.ts.map +1 -1
  44. package/commands/validated-command.js.map +1 -1
  45. package/constants/action-failures.d.ts.map +1 -1
  46. package/constants/action-failures.js.map +1 -1
  47. package/constants/directions.d.ts.map +1 -1
  48. package/constants/directions.js.map +1 -1
  49. package/constants/if-events.d.ts.map +1 -1
  50. package/constants/if-events.js.map +1 -1
  51. package/constants/index.d.ts.map +1 -1
  52. package/constants/index.js.map +1 -1
  53. package/entities/entity-store.d.ts.map +1 -1
  54. package/entities/entity-store.js.map +1 -1
  55. package/entities/entity-types.d.ts.map +1 -1
  56. package/entities/entity-types.js.map +1 -1
  57. package/entities/if-entity.d.ts.map +1 -1
  58. package/entities/if-entity.js.map +1 -1
  59. package/entities/index.d.ts.map +1 -1
  60. package/entities/index.js.map +1 -1
  61. package/entities/wall-entity.d.ts.map +1 -1
  62. package/entities/wall-entity.js.map +1 -1
  63. package/events/types.d.ts.map +1 -1
  64. package/events/types.js.map +1 -1
  65. package/examples/event-handler-registration.d.ts.map +1 -1
  66. package/examples/event-handler-registration.js.map +1 -1
  67. package/extensions/base-extension.d.ts.map +1 -1
  68. package/extensions/base-extension.js.map +1 -1
  69. package/extensions/index.d.ts.map +1 -1
  70. package/extensions/index.js.map +1 -1
  71. package/extensions/loader.d.ts.map +1 -1
  72. package/extensions/loader.js.map +1 -1
  73. package/extensions/manager.d.ts.map +1 -1
  74. package/extensions/manager.js.map +1 -1
  75. package/extensions/registry.d.ts.map +1 -1
  76. package/extensions/registry.js.map +1 -1
  77. package/extensions/types.d.ts.map +1 -1
  78. package/extensions/types.js.map +1 -1
  79. package/index.d.ts +2 -0
  80. package/index.d.ts.map +1 -1
  81. package/index.js +9 -0
  82. package/index.js.map +1 -1
  83. package/interfaces/command-executor.d.ts.map +1 -1
  84. package/interfaces/command-executor.js.map +1 -1
  85. package/interfaces/command-processor.d.ts.map +1 -1
  86. package/interfaces/command-processor.js.map +1 -1
  87. package/interfaces/command-validator.d.ts.map +1 -1
  88. package/interfaces/command-validator.js.map +1 -1
  89. package/interfaces/index.d.ts.map +1 -1
  90. package/interfaces/index.js.map +1 -1
  91. package/interfaces/language-provider.d.ts.map +1 -1
  92. package/interfaces/language-provider.js.map +1 -1
  93. package/interfaces/parser.d.ts.map +1 -1
  94. package/interfaces/parser.js.map +1 -1
  95. package/package.json +3 -3
  96. package/scope/index.d.ts.map +1 -1
  97. package/scope/index.js.map +1 -1
  98. package/scope/scope-evaluator.d.ts.map +1 -1
  99. package/scope/scope-evaluator.js.map +1 -1
  100. package/scope/scope-registry.d.ts.map +1 -1
  101. package/scope/scope-registry.js.map +1 -1
  102. package/scope/scope-rule.d.ts.map +1 -1
  103. package/scope/scope-rule.js.map +1 -1
  104. package/services/index.d.ts.map +1 -1
  105. package/services/index.js.map +1 -1
  106. package/state-adjectives.d.ts +37 -0
  107. package/state-adjectives.d.ts.map +1 -0
  108. package/state-adjectives.js +58 -0
  109. package/state-adjectives.js.map +1 -0
  110. package/state-clauses.d.ts +50 -0
  111. package/state-clauses.d.ts.map +1 -0
  112. package/state-clauses.js +75 -0
  113. package/state-clauses.js.map +1 -0
  114. package/test-structure.d.ts.map +1 -1
  115. package/test-structure.js.map +1 -1
  116. package/traits/acoustic/acousticDampenerTrait.d.ts.map +1 -1
  117. package/traits/acoustic/acousticDampenerTrait.js.map +1 -1
  118. package/traits/acoustic/acousticTrait.d.ts.map +1 -1
  119. package/traits/acoustic/acousticTrait.js.map +1 -1
  120. package/traits/acoustic/index.d.ts.map +1 -1
  121. package/traits/acoustic/index.js.map +1 -1
  122. package/traits/actor/actorBehavior.d.ts.map +1 -1
  123. package/traits/actor/actorBehavior.js.map +1 -1
  124. package/traits/actor/actorTrait.d.ts.map +1 -1
  125. package/traits/actor/actorTrait.js.map +1 -1
  126. package/traits/actor/index.d.ts.map +1 -1
  127. package/traits/actor/index.js.map +1 -1
  128. package/traits/all-traits.d.ts.map +1 -1
  129. package/traits/all-traits.js.map +1 -1
  130. package/traits/attached/attachedTrait.d.ts.map +1 -1
  131. package/traits/attached/attachedTrait.js.map +1 -1
  132. package/traits/attached/index.d.ts.map +1 -1
  133. package/traits/attached/index.js.map +1 -1
  134. package/traits/breakable/breakableBehavior.d.ts.map +1 -1
  135. package/traits/breakable/breakableBehavior.js.map +1 -1
  136. package/traits/breakable/breakableTrait.d.ts.map +1 -1
  137. package/traits/breakable/breakableTrait.js.map +1 -1
  138. package/traits/breakable/index.d.ts.map +1 -1
  139. package/traits/breakable/index.js.map +1 -1
  140. package/traits/button/buttonTrait.d.ts.map +1 -1
  141. package/traits/button/buttonTrait.js.map +1 -1
  142. package/traits/button/index.d.ts.map +1 -1
  143. package/traits/button/index.js.map +1 -1
  144. package/traits/character-model/character-vocabulary.d.ts.map +1 -1
  145. package/traits/character-model/character-vocabulary.js.map +1 -1
  146. package/traits/character-model/characterModelTrait.d.ts.map +1 -1
  147. package/traits/character-model/characterModelTrait.js.map +1 -1
  148. package/traits/character-model/index.d.ts.map +1 -1
  149. package/traits/character-model/index.js.map +1 -1
  150. package/traits/climbable/climbableBehavior.d.ts.map +1 -1
  151. package/traits/climbable/climbableBehavior.js.map +1 -1
  152. package/traits/climbable/climbableTrait.d.ts.map +1 -1
  153. package/traits/climbable/climbableTrait.js.map +1 -1
  154. package/traits/climbable/index.d.ts.map +1 -1
  155. package/traits/climbable/index.js.map +1 -1
  156. package/traits/clothing/clothingTrait.d.ts.map +1 -1
  157. package/traits/clothing/clothingTrait.js.map +1 -1
  158. package/traits/clothing/index.d.ts.map +1 -1
  159. package/traits/clothing/index.js.map +1 -1
  160. package/traits/combatant/combatantBehavior.d.ts.map +1 -1
  161. package/traits/combatant/combatantBehavior.js.map +1 -1
  162. package/traits/combatant/combatantTrait.d.ts.map +1 -1
  163. package/traits/combatant/combatantTrait.js.map +1 -1
  164. package/traits/combatant/index.d.ts.map +1 -1
  165. package/traits/combatant/index.js.map +1 -1
  166. package/traits/concealment/concealedStateTrait.d.ts.map +1 -1
  167. package/traits/concealment/concealedStateTrait.js.map +1 -1
  168. package/traits/concealment/concealedVisibilityBehavior.d.ts +9 -4
  169. package/traits/concealment/concealedVisibilityBehavior.d.ts.map +1 -1
  170. package/traits/concealment/concealedVisibilityBehavior.js +9 -6
  171. package/traits/concealment/concealedVisibilityBehavior.js.map +1 -1
  172. package/traits/concealment/concealmentTrait.d.ts.map +1 -1
  173. package/traits/concealment/concealmentTrait.js.map +1 -1
  174. package/traits/concealment/index.d.ts.map +1 -1
  175. package/traits/concealment/index.js.map +1 -1
  176. package/traits/container/container-utils.d.ts.map +1 -1
  177. package/traits/container/container-utils.js.map +1 -1
  178. package/traits/container/containerBehavior.d.ts.map +1 -1
  179. package/traits/container/containerBehavior.js.map +1 -1
  180. package/traits/container/containerTrait.d.ts.map +1 -1
  181. package/traits/container/containerTrait.js.map +1 -1
  182. package/traits/container/index.d.ts.map +1 -1
  183. package/traits/container/index.js.map +1 -1
  184. package/traits/destructible/destructibleBehavior.d.ts.map +1 -1
  185. package/traits/destructible/destructibleBehavior.js.map +1 -1
  186. package/traits/destructible/destructibleTrait.d.ts.map +1 -1
  187. package/traits/destructible/destructibleTrait.js.map +1 -1
  188. package/traits/destructible/index.d.ts.map +1 -1
  189. package/traits/destructible/index.js.map +1 -1
  190. package/traits/door/doorBehavior.d.ts.map +1 -1
  191. package/traits/door/doorBehavior.js.map +1 -1
  192. package/traits/door/doorTrait.d.ts.map +1 -1
  193. package/traits/door/doorTrait.js.map +1 -1
  194. package/traits/door/index.d.ts.map +1 -1
  195. package/traits/door/index.js.map +1 -1
  196. package/traits/edible/edibleBehavior.d.ts.map +1 -1
  197. package/traits/edible/edibleBehavior.js.map +1 -1
  198. package/traits/edible/edibleTrait.d.ts.map +1 -1
  199. package/traits/edible/edibleTrait.js.map +1 -1
  200. package/traits/edible/index.d.ts.map +1 -1
  201. package/traits/edible/index.js.map +1 -1
  202. package/traits/enterable/enterableTrait.d.ts.map +1 -1
  203. package/traits/enterable/enterableTrait.js.map +1 -1
  204. package/traits/enterable/index.d.ts.map +1 -1
  205. package/traits/enterable/index.js.map +1 -1
  206. package/traits/equipped/equippedTrait.d.ts.map +1 -1
  207. package/traits/equipped/equippedTrait.js.map +1 -1
  208. package/traits/equipped/index.d.ts.map +1 -1
  209. package/traits/equipped/index.js.map +1 -1
  210. package/traits/exit/exitBehavior.d.ts.map +1 -1
  211. package/traits/exit/exitBehavior.js.map +1 -1
  212. package/traits/exit/exitTrait.d.ts.map +1 -1
  213. package/traits/exit/exitTrait.js.map +1 -1
  214. package/traits/exit/index.d.ts.map +1 -1
  215. package/traits/exit/index.js.map +1 -1
  216. package/traits/identity/identityBehavior.d.ts.map +1 -1
  217. package/traits/identity/identityBehavior.js.map +1 -1
  218. package/traits/identity/identityTrait.d.ts.map +1 -1
  219. package/traits/identity/identityTrait.js.map +1 -1
  220. package/traits/identity/index.d.ts.map +1 -1
  221. package/traits/identity/index.js.map +1 -1
  222. package/traits/implementations.d.ts.map +1 -1
  223. package/traits/implementations.js.map +1 -1
  224. package/traits/index.d.ts.map +1 -1
  225. package/traits/index.js.map +1 -1
  226. package/traits/light-source/index.d.ts.map +1 -1
  227. package/traits/light-source/index.js.map +1 -1
  228. package/traits/light-source/lightSourceBehavior.d.ts.map +1 -1
  229. package/traits/light-source/lightSourceBehavior.js.map +1 -1
  230. package/traits/light-source/lightSourceTrait.d.ts +7 -0
  231. package/traits/light-source/lightSourceTrait.d.ts.map +1 -1
  232. package/traits/light-source/lightSourceTrait.js +7 -0
  233. package/traits/light-source/lightSourceTrait.js.map +1 -1
  234. package/traits/listener/index.d.ts.map +1 -1
  235. package/traits/listener/index.js.map +1 -1
  236. package/traits/listener/listenerTrait.d.ts.map +1 -1
  237. package/traits/listener/listenerTrait.js.map +1 -1
  238. package/traits/lockable/index.d.ts.map +1 -1
  239. package/traits/lockable/index.js.map +1 -1
  240. package/traits/lockable/lockableBehavior.d.ts.map +1 -1
  241. package/traits/lockable/lockableBehavior.js.map +1 -1
  242. package/traits/lockable/lockableTrait.d.ts.map +1 -1
  243. package/traits/lockable/lockableTrait.js.map +1 -1
  244. package/traits/moveable-scenery/index.d.ts.map +1 -1
  245. package/traits/moveable-scenery/index.js.map +1 -1
  246. package/traits/moveable-scenery/moveableSceneryTrait.d.ts.map +1 -1
  247. package/traits/moveable-scenery/moveableSceneryTrait.js.map +1 -1
  248. package/traits/npc/index.d.ts.map +1 -1
  249. package/traits/npc/index.js.map +1 -1
  250. package/traits/npc/npcTrait.d.ts +1 -1
  251. package/traits/npc/npcTrait.d.ts.map +1 -1
  252. package/traits/npc/npcTrait.js.map +1 -1
  253. package/traits/obstructor-protocol.d.ts.map +1 -1
  254. package/traits/obstructor-protocol.js.map +1 -1
  255. package/traits/open-inventory/index.d.ts.map +1 -1
  256. package/traits/open-inventory/index.js.map +1 -1
  257. package/traits/open-inventory/openInventoryTrait.d.ts.map +1 -1
  258. package/traits/open-inventory/openInventoryTrait.js.map +1 -1
  259. package/traits/openable/index.d.ts.map +1 -1
  260. package/traits/openable/index.js.map +1 -1
  261. package/traits/openable/openableBehavior.d.ts.map +1 -1
  262. package/traits/openable/openableBehavior.js.map +1 -1
  263. package/traits/openable/openableTrait.d.ts.map +1 -1
  264. package/traits/openable/openableTrait.js.map +1 -1
  265. package/traits/pullable/index.d.ts.map +1 -1
  266. package/traits/pullable/index.js.map +1 -1
  267. package/traits/pullable/pullableTrait.d.ts.map +1 -1
  268. package/traits/pullable/pullableTrait.js.map +1 -1
  269. package/traits/pushable/index.d.ts.map +1 -1
  270. package/traits/pushable/index.js.map +1 -1
  271. package/traits/pushable/pushableTrait.d.ts.map +1 -1
  272. package/traits/pushable/pushableTrait.js.map +1 -1
  273. package/traits/readable/index.d.ts.map +1 -1
  274. package/traits/readable/index.js.map +1 -1
  275. package/traits/readable/readableBehavior.d.ts.map +1 -1
  276. package/traits/readable/readableBehavior.js.map +1 -1
  277. package/traits/readable/readableTrait.d.ts.map +1 -1
  278. package/traits/readable/readableTrait.js.map +1 -1
  279. package/traits/region/index.d.ts.map +1 -1
  280. package/traits/region/index.js.map +1 -1
  281. package/traits/region/regionTrait.d.ts.map +1 -1
  282. package/traits/region/regionTrait.js.map +1 -1
  283. package/traits/register-all.d.ts.map +1 -1
  284. package/traits/register-all.js.map +1 -1
  285. package/traits/room/index.d.ts.map +1 -1
  286. package/traits/room/index.js.map +1 -1
  287. package/traits/room/roomBehavior.d.ts.map +1 -1
  288. package/traits/room/roomBehavior.js.map +1 -1
  289. package/traits/room/roomTrait.d.ts.map +1 -1
  290. package/traits/room/roomTrait.js.map +1 -1
  291. package/traits/scene/index.d.ts.map +1 -1
  292. package/traits/scene/index.js.map +1 -1
  293. package/traits/scene/sceneTrait.d.ts.map +1 -1
  294. package/traits/scene/sceneTrait.js.map +1 -1
  295. package/traits/scenery/index.d.ts.map +1 -1
  296. package/traits/scenery/index.js.map +1 -1
  297. package/traits/scenery/sceneryBehavior.d.ts.map +1 -1
  298. package/traits/scenery/sceneryBehavior.js.map +1 -1
  299. package/traits/scenery/sceneryTrait.d.ts.map +1 -1
  300. package/traits/scenery/sceneryTrait.js.map +1 -1
  301. package/traits/story-info/index.d.ts.map +1 -1
  302. package/traits/story-info/index.js.map +1 -1
  303. package/traits/story-info/storyInfoTrait.d.ts.map +1 -1
  304. package/traits/story-info/storyInfoTrait.js.map +1 -1
  305. package/traits/supporter/index.d.ts.map +1 -1
  306. package/traits/supporter/index.js.map +1 -1
  307. package/traits/supporter/supporterBehavior.d.ts.map +1 -1
  308. package/traits/supporter/supporterBehavior.js.map +1 -1
  309. package/traits/supporter/supporterTrait.d.ts.map +1 -1
  310. package/traits/supporter/supporterTrait.js.map +1 -1
  311. package/traits/switchable/index.d.ts.map +1 -1
  312. package/traits/switchable/index.js.map +1 -1
  313. package/traits/switchable/switchableBehavior.d.ts.map +1 -1
  314. package/traits/switchable/switchableBehavior.js.map +1 -1
  315. package/traits/switchable/switchableTrait.d.ts +9 -0
  316. package/traits/switchable/switchableTrait.d.ts.map +1 -1
  317. package/traits/switchable/switchableTrait.js +2 -0
  318. package/traits/switchable/switchableTrait.js.map +1 -1
  319. package/traits/trait-types.d.ts.map +1 -1
  320. package/traits/trait-types.js.map +1 -1
  321. package/traits/trait.d.ts.map +1 -1
  322. package/traits/trait.js.map +1 -1
  323. package/traits/vehicle/index.d.ts.map +1 -1
  324. package/traits/vehicle/index.js.map +1 -1
  325. package/traits/vehicle/vehicleBehavior.d.ts.map +1 -1
  326. package/traits/vehicle/vehicleBehavior.js.map +1 -1
  327. package/traits/vehicle/vehicleTrait.d.ts.map +1 -1
  328. package/traits/vehicle/vehicleTrait.js.map +1 -1
  329. package/traits/weapon/index.d.ts.map +1 -1
  330. package/traits/weapon/index.js.map +1 -1
  331. package/traits/weapon/weaponBehavior.d.ts.map +1 -1
  332. package/traits/weapon/weaponBehavior.js.map +1 -1
  333. package/traits/weapon/weaponTrait.d.ts.map +1 -1
  334. package/traits/weapon/weaponTrait.js.map +1 -1
  335. package/traits/wearable/index.d.ts.map +1 -1
  336. package/traits/wearable/index.js.map +1 -1
  337. package/traits/wearable/wearableBehavior.d.ts.map +1 -1
  338. package/traits/wearable/wearableBehavior.js.map +1 -1
  339. package/traits/wearable/wearableTrait.d.ts.map +1 -1
  340. package/traits/wearable/wearableTrait.js.map +1 -1
  341. package/utils/event-utils.d.ts.map +1 -1
  342. package/utils/event-utils.js.map +1 -1
  343. package/world/AuthorModel.d.ts +15 -1
  344. package/world/AuthorModel.d.ts.map +1 -1
  345. package/world/AuthorModel.js +29 -1
  346. package/world/AuthorModel.js.map +1 -1
  347. package/world/ScoreLedger.d.ts.map +1 -1
  348. package/world/ScoreLedger.js.map +1 -1
  349. package/world/SharedDataStore.d.ts.map +1 -1
  350. package/world/SharedDataStore.js.map +1 -1
  351. package/world/SpatialIndex.d.ts.map +1 -1
  352. package/world/SpatialIndex.js.map +1 -1
  353. package/world/VisibilityBehavior.d.ts.map +1 -1
  354. package/world/VisibilityBehavior.js +4 -4
  355. package/world/VisibilityBehavior.js.map +1 -1
  356. package/world/WorldEventSystem.d.ts +1 -0
  357. package/world/WorldEventSystem.d.ts.map +1 -1
  358. package/world/WorldEventSystem.js +13 -0
  359. package/world/WorldEventSystem.js.map +1 -1
  360. package/world/WorldModel.d.ts +132 -2
  361. package/world/WorldModel.d.ts.map +1 -1
  362. package/world/WorldModel.js +112 -3
  363. package/world/WorldModel.js.map +1 -1
  364. package/world/WorldSerializer.d.ts.map +1 -1
  365. package/world/WorldSerializer.js.map +1 -1
  366. package/world/capabilities.d.ts +7 -0
  367. package/world/capabilities.d.ts.map +1 -1
  368. package/world/capabilities.js +7 -0
  369. package/world/capabilities.js.map +1 -1
  370. package/world/default-trait-registry.d.ts.map +1 -1
  371. package/world/default-trait-registry.js.map +1 -1
  372. package/world/index.d.ts.map +1 -1
  373. package/world/index.js.map +1 -1
  374. package/world/wall-creation.d.ts.map +1 -1
  375. package/world/wall-creation.js.map +1 -1
  376. package/world/wall-validation.d.ts.map +1 -1
  377. package/world/wall-validation.js.map +1 -1
  378. package/capabilities/capability-registry.d.ts +0 -115
  379. package/capabilities/capability-registry.d.ts.map +0 -1
  380. package/capabilities/capability-registry.js +0 -157
  381. package/capabilities/capability-registry.js.map +0 -1
  382. package/capabilities/interceptor-registry.d.ts +0 -125
  383. package/capabilities/interceptor-registry.d.ts.map +0 -1
  384. package/capabilities/interceptor-registry.js +0 -176
  385. package/capabilities/interceptor-registry.js.map +0 -1
@@ -1,157 +0,0 @@
1
- "use strict";
2
- /**
3
- * Capability Registry (ADR-090)
4
- *
5
- * Registry for trait-behavior bindings. Stories register behaviors
6
- * for their traits, and the dispatch system looks them up at runtime.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.registerCapabilityBehavior = registerCapabilityBehavior;
10
- exports.getBehaviorForCapability = getBehaviorForCapability;
11
- exports.getBehaviorBinding = getBehaviorBinding;
12
- exports.hasCapabilityBehavior = hasCapabilityBehavior;
13
- exports.unregisterCapabilityBehavior = unregisterCapabilityBehavior;
14
- exports.clearCapabilityRegistry = clearCapabilityRegistry;
15
- exports.getAllCapabilityBindings = getAllCapabilityBindings;
16
- /**
17
- * Registry storage: key = `${traitType}:${capability}`
18
- * Uses globalThis to ensure the registry is shared across module boundaries
19
- * (e.g., when story modules import from packages but actions run from bundle)
20
- */
21
- const CAPABILITY_REGISTRY_KEY = '__sharpee_capability_behaviors__';
22
- function getCapabilityRegistry() {
23
- const global = globalThis;
24
- if (!global[CAPABILITY_REGISTRY_KEY]) {
25
- global[CAPABILITY_REGISTRY_KEY] = new Map();
26
- }
27
- return global[CAPABILITY_REGISTRY_KEY];
28
- }
29
- const behaviorRegistry = {
30
- get size() { return getCapabilityRegistry().size; },
31
- has(key) { return getCapabilityRegistry().has(key); },
32
- get(key) { return getCapabilityRegistry().get(key); },
33
- set(key, value) { return getCapabilityRegistry().set(key, value); },
34
- delete(key) { return getCapabilityRegistry().delete(key); },
35
- clear() { return getCapabilityRegistry().clear(); },
36
- keys() { return getCapabilityRegistry().keys(); },
37
- values() { return getCapabilityRegistry().values(); },
38
- entries() { return getCapabilityRegistry().entries(); },
39
- [Symbol.iterator]() { return getCapabilityRegistry()[Symbol.iterator](); }
40
- };
41
- /**
42
- * Generate registry key for trait+capability combination.
43
- */
44
- function registryKey(traitType, capability) {
45
- return `${traitType}:${capability}`;
46
- }
47
- /**
48
- * Register a behavior for a trait+capability combination.
49
- *
50
- * Stories call this to register their behaviors during initialization.
51
- * Each trait+capability pair can only have one behavior registered.
52
- *
53
- * @param traitType - The trait type identifier (e.g., 'dungeo.trait.basket_elevator')
54
- * @param capability - The action ID (e.g., 'if.action.lowering')
55
- * @param behavior - The behavior implementation
56
- * @param options - Optional configuration (priority, resolution override, mode override)
57
- *
58
- * @example
59
- * ```typescript
60
- * // Basic registration (uses global defaults)
61
- * registerCapabilityBehavior(
62
- * BasketElevatorTrait.type,
63
- * 'if.action.lowering',
64
- * BasketLoweringBehavior
65
- * );
66
- *
67
- * // With priority and overrides
68
- * registerCapabilityBehavior(
69
- * TrollAxeTrait.type,
70
- * 'if.action.taking',
71
- * TrollAxeTakingBehavior,
72
- * { priority: 100, resolution: 'any-blocks' }
73
- * );
74
- * ```
75
- */
76
- function registerCapabilityBehavior(traitType, capability, behavior, options) {
77
- const key = registryKey(traitType, capability);
78
- if (behaviorRegistry.has(key)) {
79
- throw new Error(`Behavior already registered for trait "${traitType}" and capability "${capability}"`);
80
- }
81
- behaviorRegistry.set(key, {
82
- traitType,
83
- capability,
84
- behavior,
85
- priority: options?.priority ?? 0,
86
- resolution: options?.resolution,
87
- mode: options?.mode,
88
- validateBinding: options?.validateBinding
89
- });
90
- }
91
- /**
92
- * Get behavior for a trait instance and capability.
93
- *
94
- * Called by capability-dispatch actions to find the right behavior.
95
- *
96
- * @param trait - The trait instance
97
- * @param capability - The action ID
98
- * @returns The behavior, or undefined if not registered
99
- */
100
- function getBehaviorForCapability(trait, capability) {
101
- const binding = getBehaviorBinding(trait, capability);
102
- return binding?.behavior;
103
- }
104
- /**
105
- * Get the full binding for a trait instance and capability.
106
- *
107
- * Includes priority and configuration overrides. Used by dispatch helper
108
- * for resolution logic.
109
- *
110
- * @param trait - The trait instance
111
- * @param capability - The action ID
112
- * @returns The binding, or undefined if not registered
113
- */
114
- function getBehaviorBinding(trait, capability) {
115
- const traitType = trait.constructor.type;
116
- const key = registryKey(traitType, capability);
117
- const binding = behaviorRegistry.get(key);
118
- if (!binding) {
119
- return undefined;
120
- }
121
- // Runtime validation if provided
122
- if (binding.validateBinding && !binding.validateBinding(trait)) {
123
- throw new Error(`Behavior validation failed for trait "${traitType}", capability "${capability}"`);
124
- }
125
- return binding;
126
- }
127
- /**
128
- * Check if a behavior is registered for a trait+capability.
129
- *
130
- * @param traitType - The trait type identifier
131
- * @param capability - The action ID
132
- */
133
- function hasCapabilityBehavior(traitType, capability) {
134
- return behaviorRegistry.has(registryKey(traitType, capability));
135
- }
136
- /**
137
- * Unregister a behavior (primarily for testing).
138
- *
139
- * @param traitType - The trait type identifier
140
- * @param capability - The action ID
141
- */
142
- function unregisterCapabilityBehavior(traitType, capability) {
143
- behaviorRegistry.delete(registryKey(traitType, capability));
144
- }
145
- /**
146
- * Clear all registered behaviors (for testing).
147
- */
148
- function clearCapabilityRegistry() {
149
- behaviorRegistry.clear();
150
- }
151
- /**
152
- * Get all registered bindings (for debugging/introspection).
153
- */
154
- function getAllCapabilityBindings() {
155
- return new Map(getCapabilityRegistry());
156
- }
157
- //# sourceMappingURL=capability-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capability-registry.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/world-model/src/capabilities/capability-registry.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwGH,gEAuBC;AAWD,4DAMC;AAYD,gDAoBC;AAQD,sDAEC;AAQD,oEAEC;AAKD,0DAEC;AAKD,4DAEC;AA1KD;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AAEnE,SAAS,qBAAqB;IAC5B,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,uBAAuB,CAAC,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC5E,CAAC;IACD,OAAO,MAAM,CAAC,uBAAuB,CAAsC,CAAC;AAC9E,CAAC;AAED,MAAM,gBAAgB,GAAG;IACvB,IAAI,IAAI,KAAK,OAAO,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,GAAG,CAAC,GAAW,IAAI,OAAO,qBAAqB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7D,GAAG,CAAC,GAAW,IAAI,OAAO,qBAAqB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAA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AACH,SAAgB,uBAAuB;IACrC,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO,IAAI,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,125 +0,0 @@
1
- /**
2
- * Interceptor Registry (ADR-118)
3
- *
4
- * Registry for trait-interceptor bindings. Stories register interceptors
5
- * for their traits, and stdlib actions look them up at runtime.
6
- *
7
- * Mirrors capability-registry.ts pattern but for interceptors instead
8
- * of full-delegation behaviors.
9
- */
10
- import { ITrait } from '../traits/trait';
11
- import { ActionInterceptor } from './action-interceptor';
12
- /**
13
- * Options for registering an action interceptor.
14
- */
15
- export interface InterceptorRegistrationOptions {
16
- /** Priority for resolution (higher = checked first). Default: 0 */
17
- priority?: number;
18
- }
19
- /**
20
- * Binding between a trait type, action, and interceptor.
21
- */
22
- export interface TraitInterceptorBinding {
23
- /** Trait type identifier */
24
- traitType: string;
25
- /** Action ID this interceptor handles */
26
- actionId: string;
27
- /** The interceptor that handles this trait+action */
28
- interceptor: ActionInterceptor;
29
- /** Priority for resolution (higher = checked first) */
30
- priority: number;
31
- }
32
- /**
33
- * Register an interceptor for a trait+action combination.
34
- *
35
- * Stories call this to register their interceptors during initialization.
36
- * Each trait+action pair can only have one interceptor registered.
37
- *
38
- * @param traitType - The trait type identifier (e.g., 'dungeo.trait.inflatable')
39
- * @param actionId - The action ID (e.g., 'if.action.entering')
40
- * @param interceptor - The interceptor implementation
41
- * @param options - Optional configuration (priority)
42
- *
43
- * @example
44
- * ```typescript
45
- * // Register boat puncture interceptor
46
- * registerActionInterceptor(
47
- * InflatableTrait.type,
48
- * 'if.action.entering',
49
- * InflatableEnteringInterceptor
50
- * );
51
- *
52
- * // With priority
53
- * registerActionInterceptor(
54
- * TrollGuardianTrait.type,
55
- * 'if.action.going',
56
- * TrollGoingInterceptor,
57
- * { priority: 100 }
58
- * );
59
- * ```
60
- */
61
- export declare function registerActionInterceptor(traitType: string, actionId: string, interceptor: ActionInterceptor, options?: InterceptorRegistrationOptions): void;
62
- /**
63
- * Result from looking up an interceptor for an entity+action.
64
- */
65
- export interface InterceptorLookupResult {
66
- /** The interceptor */
67
- interceptor: ActionInterceptor;
68
- /** The trait that declared this interceptor */
69
- trait: ITrait;
70
- /** The binding metadata */
71
- binding: TraitInterceptorBinding;
72
- }
73
- /**
74
- * Get interceptor for an entity and action.
75
- *
76
- * Finds a trait on the entity that has an interceptor registered for
77
- * the given action. Looks up by trait type string in the registry.
78
- *
79
- * @param entity - The entity to check
80
- * @param actionId - The action ID
81
- * @returns The interceptor and trait, or undefined if not found
82
- *
83
- * @example
84
- * ```typescript
85
- * const result = getInterceptorForAction(boat, 'if.action.entering');
86
- * if (result) {
87
- * const { interceptor, trait, binding } = result;
88
- * // Call interceptor hooks during action execution
89
- * }
90
- * ```
91
- */
92
- export declare function getInterceptorForAction(entity: {
93
- traits: Map<string, ITrait>;
94
- }, actionId: string): InterceptorLookupResult | undefined;
95
- /**
96
- * Get the interceptor binding for a trait type and action.
97
- *
98
- * @param traitType - The trait type identifier
99
- * @param actionId - The action ID
100
- * @returns The binding, or undefined if not registered
101
- */
102
- export declare function getInterceptorBinding(traitType: string, actionId: string): TraitInterceptorBinding | undefined;
103
- /**
104
- * Check if an interceptor is registered for a trait+action.
105
- *
106
- * @param traitType - The trait type identifier
107
- * @param actionId - The action ID
108
- */
109
- export declare function hasActionInterceptor(traitType: string, actionId: string): boolean;
110
- /**
111
- * Unregister an interceptor (primarily for testing).
112
- *
113
- * @param traitType - The trait type identifier
114
- * @param actionId - The action ID
115
- */
116
- export declare function unregisterActionInterceptor(traitType: string, actionId: string): void;
117
- /**
118
- * Clear all registered interceptors (for testing).
119
- */
120
- export declare function clearInterceptorRegistry(): void;
121
- /**
122
- * Get all registered interceptor bindings (for debugging/introspection).
123
- */
124
- export declare function getAllInterceptorBindings(): Map<string, TraitInterceptorBinding>;
125
- //# sourceMappingURL=interceptor-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interceptor-registry.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/world-model/src/capabilities/interceptor-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAqB,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,WAAW,EAAE,iBAAiB,CAAC;IAC/B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAuCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,CAAC,EAAE,8BAA8B,GACvC,IAAI,CAeN;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sBAAsB;IACtB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,OAAO,EAAE,uBAAuB,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EACvC,QAAQ,EAAE,MAAM,GACf,uBAAuB,GAAG,SAAS,CA4BrC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,uBAAuB,GAAG,SAAS,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAErF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAEhF"}
@@ -1,176 +0,0 @@
1
- "use strict";
2
- /**
3
- * Interceptor Registry (ADR-118)
4
- *
5
- * Registry for trait-interceptor bindings. Stories register interceptors
6
- * for their traits, and stdlib actions look them up at runtime.
7
- *
8
- * Mirrors capability-registry.ts pattern but for interceptors instead
9
- * of full-delegation behaviors.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.registerActionInterceptor = registerActionInterceptor;
13
- exports.getInterceptorForAction = getInterceptorForAction;
14
- exports.getInterceptorBinding = getInterceptorBinding;
15
- exports.hasActionInterceptor = hasActionInterceptor;
16
- exports.unregisterActionInterceptor = unregisterActionInterceptor;
17
- exports.clearInterceptorRegistry = clearInterceptorRegistry;
18
- exports.getAllInterceptorBindings = getAllInterceptorBindings;
19
- /**
20
- * Registry storage: key = `${traitType}:${actionId}`
21
- * Uses globalThis to ensure the registry is shared across module boundaries
22
- * (e.g., when story modules import from packages but actions run from bundle)
23
- */
24
- const INTERCEPTOR_REGISTRY_KEY = '__sharpee_interceptor_registry__';
25
- // Use globalThis to share registry across module instances
26
- function getInterceptorRegistry() {
27
- const global = globalThis;
28
- if (!global[INTERCEPTOR_REGISTRY_KEY]) {
29
- global[INTERCEPTOR_REGISTRY_KEY] = new Map();
30
- }
31
- return global[INTERCEPTOR_REGISTRY_KEY];
32
- }
33
- // For backwards compatibility, expose as const (but delegates to globalThis)
34
- const interceptorRegistry = {
35
- get size() { return getInterceptorRegistry().size; },
36
- has(key) { return getInterceptorRegistry().has(key); },
37
- get(key) { return getInterceptorRegistry().get(key); },
38
- set(key, value) { return getInterceptorRegistry().set(key, value); },
39
- delete(key) { return getInterceptorRegistry().delete(key); },
40
- clear() { return getInterceptorRegistry().clear(); },
41
- keys() { return getInterceptorRegistry().keys(); },
42
- values() { return getInterceptorRegistry().values(); },
43
- entries() { return getInterceptorRegistry().entries(); },
44
- [Symbol.iterator]() { return getInterceptorRegistry()[Symbol.iterator](); }
45
- };
46
- /**
47
- * Generate registry key for trait+action combination.
48
- */
49
- function registryKey(traitType, actionId) {
50
- return `${traitType}:${actionId}`;
51
- }
52
- /**
53
- * Register an interceptor for a trait+action combination.
54
- *
55
- * Stories call this to register their interceptors during initialization.
56
- * Each trait+action pair can only have one interceptor registered.
57
- *
58
- * @param traitType - The trait type identifier (e.g., 'dungeo.trait.inflatable')
59
- * @param actionId - The action ID (e.g., 'if.action.entering')
60
- * @param interceptor - The interceptor implementation
61
- * @param options - Optional configuration (priority)
62
- *
63
- * @example
64
- * ```typescript
65
- * // Register boat puncture interceptor
66
- * registerActionInterceptor(
67
- * InflatableTrait.type,
68
- * 'if.action.entering',
69
- * InflatableEnteringInterceptor
70
- * );
71
- *
72
- * // With priority
73
- * registerActionInterceptor(
74
- * TrollGuardianTrait.type,
75
- * 'if.action.going',
76
- * TrollGoingInterceptor,
77
- * { priority: 100 }
78
- * );
79
- * ```
80
- */
81
- function registerActionInterceptor(traitType, actionId, interceptor, options) {
82
- const key = registryKey(traitType, actionId);
83
- if (interceptorRegistry.has(key)) {
84
- throw new Error(`Interceptor already registered for trait "${traitType}" and action "${actionId}"`);
85
- }
86
- interceptorRegistry.set(key, {
87
- traitType,
88
- actionId,
89
- interceptor,
90
- priority: options?.priority ?? 0
91
- });
92
- }
93
- /**
94
- * Get interceptor for an entity and action.
95
- *
96
- * Finds a trait on the entity that has an interceptor registered for
97
- * the given action. Looks up by trait type string in the registry.
98
- *
99
- * @param entity - The entity to check
100
- * @param actionId - The action ID
101
- * @returns The interceptor and trait, or undefined if not found
102
- *
103
- * @example
104
- * ```typescript
105
- * const result = getInterceptorForAction(boat, 'if.action.entering');
106
- * if (result) {
107
- * const { interceptor, trait, binding } = result;
108
- * // Call interceptor hooks during action execution
109
- * }
110
- * ```
111
- */
112
- function getInterceptorForAction(entity, actionId) {
113
- // Find all traits that have an interceptor registered for this action
114
- const candidates = [];
115
- for (const trait of entity.traits.values()) {
116
- // Look up interceptor by trait type string (more reliable than static property)
117
- const traitType = trait.type;
118
- const key = registryKey(traitType, actionId);
119
- const binding = interceptorRegistry.get(key);
120
- if (binding) {
121
- candidates.push({ trait, binding });
122
- }
123
- }
124
- if (candidates.length === 0) {
125
- return undefined;
126
- }
127
- // Sort by priority (highest first) and return the first one
128
- candidates.sort((a, b) => b.binding.priority - a.binding.priority);
129
- const { trait, binding } = candidates[0];
130
- return {
131
- interceptor: binding.interceptor,
132
- trait,
133
- binding
134
- };
135
- }
136
- /**
137
- * Get the interceptor binding for a trait type and action.
138
- *
139
- * @param traitType - The trait type identifier
140
- * @param actionId - The action ID
141
- * @returns The binding, or undefined if not registered
142
- */
143
- function getInterceptorBinding(traitType, actionId) {
144
- return interceptorRegistry.get(registryKey(traitType, actionId));
145
- }
146
- /**
147
- * Check if an interceptor is registered for a trait+action.
148
- *
149
- * @param traitType - The trait type identifier
150
- * @param actionId - The action ID
151
- */
152
- function hasActionInterceptor(traitType, actionId) {
153
- return interceptorRegistry.has(registryKey(traitType, actionId));
154
- }
155
- /**
156
- * Unregister an interceptor (primarily for testing).
157
- *
158
- * @param traitType - The trait type identifier
159
- * @param actionId - The action ID
160
- */
161
- function unregisterActionInterceptor(traitType, actionId) {
162
- interceptorRegistry.delete(registryKey(traitType, actionId));
163
- }
164
- /**
165
- * Clear all registered interceptors (for testing).
166
- */
167
- function clearInterceptorRegistry() {
168
- interceptorRegistry.clear();
169
- }
170
- /**
171
- * Get all registered interceptor bindings (for debugging/introspection).
172
- */
173
- function getAllInterceptorBindings() {
174
- return new Map(interceptorRegistry);
175
- }
176
- //# sourceMappingURL=interceptor-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interceptor-registry.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/world-model/src/capabilities/interceptor-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA6FH,8DAoBC;AAiCD,0DA+BC;AASD,sDAKC;AAQD,oDAEC;AAQD,kEAEC;AAKD,4DAEC;AAKD,8DAEC;AAtMD;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAEpE,2DAA2D;AAC3D,SAAS,sBAAsB;IAC7B,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,wBAAwB,CAAC,GAAG,IAAI,GAAG,EAAmC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC,wBAAwB,CAAyC,CAAC;AAClF,CAAC;AAED,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG;IAC1B,IAAI,IAAI,KAAK,OAAO,sBAAsB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,GAAG,CAAC,GAAW,IAAI,OAAO,sBAAsB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,GAAW,IAAI,OAAO,sBAAsB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,GAAW,EAAE,KAA8B,IAAI,OAAO,sBAAsB,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACrG,MAAM,CAAC,GAAW,IAAI,OAAO,sBAAsB,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAA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