@escapeaihq/client-core 0.8.0 → 0.42.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 (307) hide show
  1. package/README.md +48 -4
  2. package/dist/adapters/capabilities.d.ts +10 -0
  3. package/dist/adapters/capabilities.d.ts.map +1 -0
  4. package/dist/adapters/capabilities.js +2 -0
  5. package/dist/adapters/capabilities.js.map +1 -0
  6. package/dist/adapters/chatAdapter.d.ts +38 -0
  7. package/dist/adapters/chatAdapter.d.ts.map +1 -0
  8. package/dist/adapters/chatAdapter.js +88 -0
  9. package/dist/adapters/chatAdapter.js.map +1 -0
  10. package/dist/adapters/directorAdapter.d.ts +62 -0
  11. package/dist/adapters/directorAdapter.d.ts.map +1 -0
  12. package/dist/adapters/directorAdapter.js +71 -0
  13. package/dist/adapters/directorAdapter.js.map +1 -0
  14. package/dist/adapters/imageAdapter.d.ts +44 -0
  15. package/dist/adapters/imageAdapter.d.ts.map +1 -0
  16. package/dist/adapters/imageAdapter.js +73 -0
  17. package/dist/adapters/imageAdapter.js.map +1 -0
  18. package/dist/adapters/index.d.ts +47 -0
  19. package/dist/adapters/index.d.ts.map +1 -0
  20. package/dist/adapters/index.js +41 -0
  21. package/dist/adapters/index.js.map +1 -0
  22. package/dist/adapters/registry.d.ts +98 -0
  23. package/dist/adapters/registry.d.ts.map +1 -0
  24. package/dist/adapters/registry.js +106 -0
  25. package/dist/adapters/registry.js.map +1 -0
  26. package/dist/adapters/worldAdapter.d.ts +142 -0
  27. package/dist/adapters/worldAdapter.d.ts.map +1 -0
  28. package/dist/adapters/worldAdapter.js +164 -0
  29. package/dist/adapters/worldAdapter.js.map +1 -0
  30. package/dist/admin.d.ts +200 -0
  31. package/dist/admin.d.ts.map +1 -0
  32. package/dist/admin.js +124 -0
  33. package/dist/admin.js.map +1 -0
  34. package/dist/api.d.ts +1299 -3
  35. package/dist/api.d.ts.map +1 -1
  36. package/dist/api.js +683 -95
  37. package/dist/api.js.map +1 -1
  38. package/dist/audio.d.ts +33 -1
  39. package/dist/audio.d.ts.map +1 -1
  40. package/dist/audio.js +4 -1
  41. package/dist/audio.js.map +1 -1
  42. package/dist/castProjection.d.ts +35 -0
  43. package/dist/castProjection.d.ts.map +1 -0
  44. package/dist/castProjection.js +80 -0
  45. package/dist/castProjection.js.map +1 -0
  46. package/dist/conversation/binding.d.ts +62 -0
  47. package/dist/conversation/binding.d.ts.map +1 -0
  48. package/dist/conversation/binding.js +51 -0
  49. package/dist/conversation/binding.js.map +1 -0
  50. package/dist/conversation/controller.d.ts +209 -0
  51. package/dist/conversation/controller.d.ts.map +1 -0
  52. package/dist/conversation/controller.js +342 -0
  53. package/dist/conversation/controller.js.map +1 -0
  54. package/dist/conversation/effectiveModel.d.ts +62 -0
  55. package/dist/conversation/effectiveModel.d.ts.map +1 -0
  56. package/dist/conversation/effectiveModel.js +73 -0
  57. package/dist/conversation/effectiveModel.js.map +1 -0
  58. package/dist/conversation/index.d.ts +27 -0
  59. package/dist/conversation/index.d.ts.map +1 -0
  60. package/dist/conversation/index.js +27 -0
  61. package/dist/conversation/index.js.map +1 -0
  62. package/dist/conversation/participant.d.ts +66 -0
  63. package/dist/conversation/participant.d.ts.map +1 -0
  64. package/dist/conversation/participant.js +36 -0
  65. package/dist/conversation/participant.js.map +1 -0
  66. package/dist/conversation/presence.d.ts +56 -0
  67. package/dist/conversation/presence.d.ts.map +1 -0
  68. package/dist/conversation/presence.js +34 -0
  69. package/dist/conversation/presence.js.map +1 -0
  70. package/dist/conversation/presenceBus.d.ts +42 -0
  71. package/dist/conversation/presenceBus.d.ts.map +1 -0
  72. package/dist/conversation/presenceBus.js +81 -0
  73. package/dist/conversation/presenceBus.js.map +1 -0
  74. package/dist/conversation/presenceRegistry.d.ts +49 -0
  75. package/dist/conversation/presenceRegistry.d.ts.map +1 -0
  76. package/dist/conversation/presenceRegistry.js +59 -0
  77. package/dist/conversation/presenceRegistry.js.map +1 -0
  78. package/dist/conversation/roster.d.ts +72 -0
  79. package/dist/conversation/roster.d.ts.map +1 -0
  80. package/dist/conversation/roster.js +69 -0
  81. package/dist/conversation/roster.js.map +1 -0
  82. package/dist/conversation/rosterProjection.d.ts +52 -0
  83. package/dist/conversation/rosterProjection.d.ts.map +1 -0
  84. package/dist/conversation/rosterProjection.js +74 -0
  85. package/dist/conversation/rosterProjection.js.map +1 -0
  86. package/dist/conversation/router.d.ts +74 -0
  87. package/dist/conversation/router.d.ts.map +1 -0
  88. package/dist/conversation/router.js +58 -0
  89. package/dist/conversation/router.js.map +1 -0
  90. package/dist/conversation/runtime.d.ts +64 -0
  91. package/dist/conversation/runtime.d.ts.map +1 -0
  92. package/dist/conversation/runtime.js +172 -0
  93. package/dist/conversation/runtime.js.map +1 -0
  94. package/dist/conversation/types.d.ts +99 -0
  95. package/dist/conversation/types.d.ts.map +1 -0
  96. package/dist/conversation/types.js +13 -0
  97. package/dist/conversation/types.js.map +1 -0
  98. package/dist/conversation/voice.d.ts +185 -0
  99. package/dist/conversation/voice.d.ts.map +1 -0
  100. package/dist/conversation/voice.js +307 -0
  101. package/dist/conversation/voice.js.map +1 -0
  102. package/dist/graphSchema.d.ts +260 -0
  103. package/dist/graphSchema.d.ts.map +1 -0
  104. package/dist/graphSchema.js +354 -0
  105. package/dist/graphSchema.js.map +1 -0
  106. package/dist/http.d.ts +20 -0
  107. package/dist/http.d.ts.map +1 -0
  108. package/dist/http.js +57 -0
  109. package/dist/http.js.map +1 -0
  110. package/dist/index.d.ts +9 -0
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +12 -0
  113. package/dist/index.js.map +1 -1
  114. package/dist/platformAssistant.d.ts +155 -0
  115. package/dist/platformAssistant.d.ts.map +1 -0
  116. package/dist/platformAssistant.js +256 -0
  117. package/dist/platformAssistant.js.map +1 -0
  118. package/dist/reactor/abortUtils.d.ts +16 -0
  119. package/dist/reactor/abortUtils.d.ts.map +1 -0
  120. package/dist/reactor/abortUtils.js +26 -0
  121. package/dist/reactor/abortUtils.js.map +1 -0
  122. package/dist/reactor/applyScenePrompt.d.ts +75 -0
  123. package/dist/reactor/applyScenePrompt.d.ts.map +1 -0
  124. package/dist/reactor/applyScenePrompt.js +60 -0
  125. package/dist/reactor/applyScenePrompt.js.map +1 -0
  126. package/dist/reactor/chunkDistribution.d.ts +43 -0
  127. package/dist/reactor/chunkDistribution.d.ts.map +1 -0
  128. package/dist/reactor/chunkDistribution.js +85 -0
  129. package/dist/reactor/chunkDistribution.js.map +1 -0
  130. package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
  131. package/dist/reactor/heliosCommandDispatcher.js +10 -15
  132. package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
  133. package/dist/reactor/index.d.ts +4 -0
  134. package/dist/reactor/index.d.ts.map +1 -1
  135. package/dist/reactor/index.js +7 -0
  136. package/dist/reactor/index.js.map +1 -1
  137. package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
  138. package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
  139. package/dist/reactor/longLiveCommandDispatcher.js +87 -0
  140. package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
  141. package/dist/reactor/sceneEntry.d.ts +40 -6
  142. package/dist/reactor/sceneEntry.d.ts.map +1 -1
  143. package/dist/reactor/sceneEntry.js +63 -24
  144. package/dist/reactor/sceneEntry.js.map +1 -1
  145. package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
  146. package/dist/reactor/scenesFromEnrichment.js +2 -66
  147. package/dist/reactor/scenesFromEnrichment.js.map +1 -1
  148. package/dist/reactor/seedImageOrchestrator.d.ts +42 -2
  149. package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
  150. package/dist/reactor/seedImageOrchestrator.js +173 -4
  151. package/dist/reactor/seedImageOrchestrator.js.map +1 -1
  152. package/dist/reactor/storyTimeline.d.ts +44 -0
  153. package/dist/reactor/storyTimeline.d.ts.map +1 -0
  154. package/dist/reactor/storyTimeline.js +95 -0
  155. package/dist/reactor/storyTimeline.js.map +1 -0
  156. package/dist/storyGraph.d.ts +70 -0
  157. package/dist/storyGraph.d.ts.map +1 -0
  158. package/dist/storyGraph.js +178 -0
  159. package/dist/storyGraph.js.map +1 -0
  160. package/dist/timeFormat.d.ts +10 -0
  161. package/dist/timeFormat.d.ts.map +1 -1
  162. package/dist/timeFormat.js +12 -0
  163. package/dist/timeFormat.js.map +1 -1
  164. package/dist/toolSchemas.d.ts +370 -0
  165. package/dist/toolSchemas.d.ts.map +1 -0
  166. package/dist/toolSchemas.js +182 -0
  167. package/dist/toolSchemas.js.map +1 -0
  168. package/dist/vision/VisionPublisher.d.ts +115 -0
  169. package/dist/vision/VisionPublisher.d.ts.map +1 -0
  170. package/dist/vision/VisionPublisher.js +475 -0
  171. package/dist/vision/VisionPublisher.js.map +1 -0
  172. package/dist/vision/VisionSourceController.d.ts +127 -0
  173. package/dist/vision/VisionSourceController.d.ts.map +1 -0
  174. package/dist/vision/VisionSourceController.js +284 -0
  175. package/dist/vision/VisionSourceController.js.map +1 -0
  176. package/dist/vision/credentials.d.ts +22 -0
  177. package/dist/vision/credentials.d.ts.map +1 -0
  178. package/dist/vision/credentials.js +34 -0
  179. package/dist/vision/credentials.js.map +1 -0
  180. package/dist/vision/index.d.ts +18 -0
  181. package/dist/vision/index.d.ts.map +1 -0
  182. package/dist/vision/index.js +13 -0
  183. package/dist/vision/index.js.map +1 -0
  184. package/dist/vision/sourceKinds.d.ts +65 -0
  185. package/dist/vision/sourceKinds.d.ts.map +1 -0
  186. package/dist/vision/sourceKinds.js +26 -0
  187. package/dist/vision/sourceKinds.js.map +1 -0
  188. package/dist/vision/startVisionPublisher.d.ts +38 -0
  189. package/dist/vision/startVisionPublisher.d.ts.map +1 -0
  190. package/dist/vision/startVisionPublisher.js +44 -0
  191. package/dist/vision/startVisionPublisher.js.map +1 -0
  192. package/dist/vision/types.d.ts +95 -0
  193. package/dist/vision/types.d.ts.map +1 -0
  194. package/dist/vision/types.js +12 -0
  195. package/dist/vision/types.js.map +1 -0
  196. package/dist/vision/visionScheduler.d.ts +63 -0
  197. package/dist/vision/visionScheduler.d.ts.map +1 -0
  198. package/dist/vision/visionScheduler.js +67 -0
  199. package/dist/vision/visionScheduler.js.map +1 -0
  200. package/dist/websocket.d.ts +195 -0
  201. package/dist/websocket.d.ts.map +1 -1
  202. package/dist/websocket.js +179 -1
  203. package/dist/websocket.js.map +1 -1
  204. package/package.json +11 -1
  205. package/src/__tests__/adapters-capabilities.test.ts +46 -0
  206. package/src/__tests__/adapters-chat.test.ts +172 -0
  207. package/src/__tests__/adapters-director.test.ts +95 -0
  208. package/src/__tests__/adapters-image.test.ts +133 -0
  209. package/src/__tests__/adapters-platform.test.ts +95 -0
  210. package/src/__tests__/adapters-registry.test.ts +189 -0
  211. package/src/__tests__/adapters-world.test.ts +296 -0
  212. package/src/__tests__/admin.test.ts +312 -0
  213. package/src/__tests__/adventures-party.test.ts +219 -0
  214. package/src/__tests__/adventures.test.ts +282 -0
  215. package/src/__tests__/api-pollers.test.ts +104 -0
  216. package/src/__tests__/api.clip-lookup.test.ts +64 -0
  217. package/src/__tests__/api.list-images-filters.test.ts +103 -0
  218. package/src/__tests__/api.test.ts +470 -0
  219. package/src/__tests__/audio.test.ts +65 -0
  220. package/src/__tests__/cast.test.ts +95 -0
  221. package/src/__tests__/castProjection.test.ts +167 -0
  222. package/src/__tests__/chat-auth.test.ts +91 -0
  223. package/src/__tests__/conversation/controller.test.ts +697 -0
  224. package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
  225. package/src/__tests__/conversation/headlessRenderer.ts +46 -0
  226. package/src/__tests__/conversation/presenceBus.test.ts +236 -0
  227. package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
  228. package/src/__tests__/conversation/roster.test.ts +100 -0
  229. package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
  230. package/src/__tests__/conversation/router.test.ts +81 -0
  231. package/src/__tests__/conversation/runtime.test.ts +206 -0
  232. package/src/__tests__/conversation/voice.test.ts +440 -0
  233. package/src/__tests__/documents.test.ts +360 -0
  234. package/src/__tests__/graphSchema.test.ts +326 -0
  235. package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
  236. package/src/__tests__/platformAssistant.test.ts +484 -0
  237. package/src/__tests__/reactor/applyScenePrompt.test.ts +192 -0
  238. package/src/__tests__/reactor/heliosCommandDispatcher.test.ts +4 -3
  239. package/src/__tests__/reactor/sceneEntry.test.ts +134 -10
  240. package/src/__tests__/reactor/seedImageOrchestrator.test.ts +51 -16
  241. package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
  242. package/src/__tests__/regeneration.test.ts +486 -0
  243. package/src/__tests__/stories.test.ts +171 -0
  244. package/src/__tests__/storyGraph.test.ts +134 -0
  245. package/src/__tests__/timeFormat.test.ts +22 -1
  246. package/src/__tests__/toolSchemas.test.ts +57 -0
  247. package/src/__tests__/tools-wrappers.test.ts +272 -0
  248. package/src/__tests__/videoGraph.test.ts +94 -0
  249. package/src/__tests__/websocket-vision.test.ts +265 -0
  250. package/src/__tests__/websocket.test.ts +213 -0
  251. package/src/adapters/capabilities.ts +24 -0
  252. package/src/adapters/chatAdapter.ts +114 -0
  253. package/src/adapters/directorAdapter.ts +126 -0
  254. package/src/adapters/imageAdapter.ts +100 -0
  255. package/src/adapters/index.ts +67 -0
  256. package/src/adapters/registry.ts +159 -0
  257. package/src/adapters/worldAdapter.ts +272 -0
  258. package/src/admin.ts +310 -0
  259. package/src/api.ts +1890 -162
  260. package/src/audio.ts +35 -0
  261. package/src/castProjection.ts +95 -0
  262. package/src/conversation/binding.ts +81 -0
  263. package/src/conversation/controller.ts +439 -0
  264. package/src/conversation/effectiveModel.ts +111 -0
  265. package/src/conversation/index.ts +27 -0
  266. package/src/conversation/participant.ts +71 -0
  267. package/src/conversation/presence.ts +60 -0
  268. package/src/conversation/presenceBus.ts +109 -0
  269. package/src/conversation/presenceRegistry.ts +83 -0
  270. package/src/conversation/roster.ts +111 -0
  271. package/src/conversation/rosterProjection.ts +98 -0
  272. package/src/conversation/router.ts +96 -0
  273. package/src/conversation/runtime.ts +188 -0
  274. package/src/conversation/types.ts +100 -0
  275. package/src/conversation/voice.ts +402 -0
  276. package/src/graphSchema.ts +532 -0
  277. package/src/http.ts +72 -0
  278. package/src/index.ts +12 -0
  279. package/src/platformAssistant.ts +347 -0
  280. package/src/reactor/abortUtils.ts +22 -0
  281. package/src/reactor/applyScenePrompt.ts +136 -0
  282. package/src/reactor/chunkDistribution.ts +98 -0
  283. package/src/reactor/heliosCommandDispatcher.ts +10 -18
  284. package/src/reactor/index.ts +7 -0
  285. package/src/reactor/longLiveCommandDispatcher.ts +156 -0
  286. package/src/reactor/sceneEntry.ts +104 -33
  287. package/src/reactor/scenesFromEnrichment.ts +11 -76
  288. package/src/reactor/seedImageOrchestrator.ts +200 -4
  289. package/src/reactor/storyTimeline.ts +127 -0
  290. package/src/storyGraph.ts +298 -0
  291. package/src/timeFormat.ts +13 -0
  292. package/src/toolSchemas.ts +225 -0
  293. package/src/vision/VisionPublisher.ts +553 -0
  294. package/src/vision/VisionSourceController.ts +354 -0
  295. package/src/vision/__tests__/VisionPublisher.kvs.test.ts +244 -0
  296. package/src/vision/__tests__/VisionPublisher.test.ts +301 -0
  297. package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
  298. package/src/vision/__tests__/startVisionPublisher.test.ts +251 -0
  299. package/src/vision/__tests__/toVisionRtcCredentials.test.ts +113 -0
  300. package/src/vision/__tests__/visionScheduler.test.ts +149 -0
  301. package/src/vision/credentials.ts +39 -0
  302. package/src/vision/index.ts +44 -0
  303. package/src/vision/sourceKinds.ts +75 -0
  304. package/src/vision/startVisionPublisher.ts +64 -0
  305. package/src/vision/types.ts +101 -0
  306. package/src/vision/visionScheduler.ts +102 -0
  307. package/src/websocket.ts +334 -4
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Capability auto-switch — the single, pure model-selection helper (R2.1).
3
+ *
4
+ * This is the ONE place R2 decides which model a turn runs on when a capability
5
+ * (today: `'vision'` when the webcam toggles ON) is needed that the bound
6
+ * persona's model lacks. R3's vision-source picker CONSUMES this exact helper —
7
+ * there is no parallel `resolveVisionCapability`. It is fully unit-testable: no
8
+ * I/O, no network. Capability FACTS come only from the injected R1 chat adapter
9
+ * registry (which mirrors `shared/model_config.py`); this helper never hardcodes
10
+ * which models are vision-capable.
11
+ *
12
+ * Precedence: an explicit override wins; otherwise the bound model is kept iff
13
+ * it already satisfies the needed caps; otherwise we auto-switch to the first
14
+ * registry model advertising the needed caps.
15
+ */
16
+ /** Why `resolveEffectiveModel` chose the model it returned. */
17
+ export const EffectiveModelReason = {
18
+ BOUND: 'bound',
19
+ OVERRIDE: 'override',
20
+ AUTO_SWITCH: 'auto_switch',
21
+ };
22
+ /**
23
+ * Resolve the model a turn should run on given the bound model, the needed
24
+ * capabilities, and an optional override. PURE.
25
+ *
26
+ * - `override` set ⇒ `'override'` (we trust the user's explicit pick; we do NOT
27
+ * second-guess its caps — that is the user's choice to make).
28
+ * - bound model satisfies `needed` (or `needed` is empty) ⇒ `'bound'`.
29
+ * - otherwise ⇒ `'auto_switch'` to the first registry model that satisfies
30
+ * EVERY needed cap (not just the first unmet one — a vision-only model is no
31
+ * good when `['vision','audio']` is needed), carrying `switchedFrom`. If NO
32
+ * model satisfies the full set, we keep the bound model as a fail-soft
33
+ * `'bound'` — the panel surfaces the gap rather than the helper throwing (a
34
+ * registry that lists zero vision models is a config state, not a crash).
35
+ */
36
+ export function resolveEffectiveModel(args) {
37
+ const { boundModelId, needed, override, registry } = args;
38
+ if (override) {
39
+ return { modelId: override, reason: EffectiveModelReason.OVERRIDE, needed };
40
+ }
41
+ if (needed.length === 0 || registry.satisfies(boundModelId, needed)) {
42
+ return { modelId: boundModelId, reason: EffectiveModelReason.BOUND, needed };
43
+ }
44
+ // Bound model lacks a needed cap and there's no override: auto-switch to the
45
+ // first model that satisfies the WHOLE `needed` set. We seed the candidate
46
+ // pool from the first unmet cap (every valid candidate must advertise it) then
47
+ // require `satisfies(candidate, needed)` so multi-cap requests (e.g.
48
+ // ['vision','audio']) don't settle for a vision-only model. Deterministic:
49
+ // first matching candidate in registry order.
50
+ // `unmet` is always found here (needed is non-empty and the bound model failed
51
+ // the full set). The `?:` guard below is belt-and-suspenders for this helper's
52
+ // "never throw" contract: if that invariant were ever broken, `candidate` stays
53
+ // undefined and we fall through to the fail-soft `return bound` at the end —
54
+ // never calling `listWithCapability(undefined)`.
55
+ const unmet = needed.find((cap) => !registry.satisfies(boundModelId, [cap]));
56
+ const candidate = unmet
57
+ ? registry
58
+ .listWithCapability(unmet)
59
+ .find((model) => registry.satisfies(model.id, needed))
60
+ : undefined;
61
+ if (candidate) {
62
+ return {
63
+ modelId: candidate.id,
64
+ reason: EffectiveModelReason.AUTO_SWITCH,
65
+ switchedFrom: boundModelId,
66
+ needed,
67
+ };
68
+ }
69
+ // Nothing in the registry can satisfy the gap — keep the bound model (the
70
+ // panel shows the unmet cap); fail-soft, never throw.
71
+ return { modelId: boundModelId, reason: EffectiveModelReason.BOUND, needed };
72
+ }
73
+ //# sourceMappingURL=effectiveModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectiveModel.js","sourceRoot":"","sources":["../../src/conversation/effectiveModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;CAClB,CAAC;AA+BX;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA+B;IACnE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;QACpE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAC/E,CAAC;IAED,6EAA6E;IAC7E,2EAA2E;IAC3E,+EAA+E;IAC/E,qEAAqE;IACrE,2EAA2E;IAC3E,8CAA8C;IAC9C,+EAA+E;IAC/E,+EAA+E;IAC/E,gFAAgF;IAChF,6EAA6E;IAC7E,iDAAiD;IACjD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,KAAK;QACrB,CAAC,CAAC,QAAQ;aACL,kBAAkB,CAAC,KAAK,CAAC;aACzB,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC1D,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;YACL,OAAO,EAAE,SAAS,CAAC,EAAE;YACrB,MAAM,EAAE,oBAAoB,CAAC,WAAW;YACxC,YAAY,EAAE,YAAY;YAC1B,MAAM;SACP,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,sDAAsD;IACtD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Barrel for the framework-agnostic `conversation/` core (R2.1).
3
+ *
4
+ * Re-exported from `src/index.ts` via `export * from './conversation'`. Owns the
5
+ * headless conversation state (participants, presence, bound context, model
6
+ * override + capability auto-switch) with NO DOM — the seam that lets React
7
+ * (R2.2) and PlayCanvas (R7) render the same controller.
8
+ *
9
+ * ADDITIVE-ONLY: every symbol here is new. `Citation`/`PlaybackState` and the
10
+ * `ChatModelCapability` union live on `websocket.ts` / `api.ts` and are IMPORTED
11
+ * by these modules, never re-declared — avoiding the documented ambiguous-export
12
+ * trap in the top-level barrel.
13
+ */
14
+ export * from './participant';
15
+ export * from './presenceRegistry';
16
+ export * from './binding';
17
+ export * from './effectiveModel';
18
+ export * from './controller';
19
+ export * from './types';
20
+ export * from './router';
21
+ export * from './roster';
22
+ export * from './rosterProjection';
23
+ export * from './runtime';
24
+ export * from './presence';
25
+ export * from './presenceBus';
26
+ export * from './voice';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Barrel for the framework-agnostic `conversation/` core (R2.1).
3
+ *
4
+ * Re-exported from `src/index.ts` via `export * from './conversation.js'`. Owns the
5
+ * headless conversation state (participants, presence, bound context, model
6
+ * override + capability auto-switch) with NO DOM — the seam that lets React
7
+ * (R2.2) and PlayCanvas (R7) render the same controller.
8
+ *
9
+ * ADDITIVE-ONLY: every symbol here is new. `Citation`/`PlaybackState` and the
10
+ * `ChatModelCapability` union live on `websocket.ts` / `api.ts` and are IMPORTED
11
+ * by these modules, never re-declared — avoiding the documented ambiguous-export
12
+ * trap in the top-level barrel.
13
+ */
14
+ export * from './participant.js';
15
+ export * from './presenceRegistry.js';
16
+ export * from './binding.js';
17
+ export * from './effectiveModel.js';
18
+ export * from './controller.js';
19
+ export * from './types.js';
20
+ export * from './router.js';
21
+ export * from './roster.js';
22
+ export * from './rosterProjection.js';
23
+ export * from './runtime.js';
24
+ export * from './presence.js';
25
+ export * from './presenceBus.js';
26
+ export * from './voice.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Conversation participant model (R2.1).
3
+ *
4
+ * A `ConversationParticipant` is ONE seat in a conversation — a bound persona,
5
+ * the Dungeon Master, or the human user. The headless `ConversationController`
6
+ * (controller.ts) holds a list of these plus an active one; React (R2.2) and a
7
+ * game engine (R7) both render the same list without owning its shape.
8
+ *
9
+ * `role` and `presence` are frozen constant objects — never inline the string
10
+ * literals (the cross-PR "constants over string literals" rule). The capability
11
+ * vocabulary is the EXISTING `ChatModelCapability` union from api.ts (the single
12
+ * source of truth that mirrors `shared/model_config.py:CAPABILITY_*`); R2 does
13
+ * NOT declare a parallel capability map.
14
+ */
15
+ import type { ChatModelCapability } from '../api';
16
+ /**
17
+ * The kind of seat a participant occupies. `persona` and `dm` are
18
+ * model-backed; `user` is the human. Frozen so a role can never be a raw
19
+ * string at a call site — mirrors the `ROUTE_*`/`PRESENCE_*` discipline.
20
+ */
21
+ export declare const ParticipantRole: {
22
+ readonly PERSONA: "persona";
23
+ readonly DM: "dm";
24
+ readonly USER: "user";
25
+ };
26
+ export type ParticipantRole = (typeof ParticipantRole)[keyof typeof ParticipantRole];
27
+ /**
28
+ * How a participant is rendered on the presence stage. `PRESENCE_AVATAR_3D` is
29
+ * a RESERVED stub — the kind is registerable but its renderer is a no-op until
30
+ * the R7 flagship lands (see `PresenceRendererRegistry` + tech-debt). The values
31
+ * double as the registry lookup keys.
32
+ */
33
+ export declare const PresenceKind: {
34
+ readonly PRESENCE_NONE: "none";
35
+ readonly PRESENCE_FACE_2D: "face_2d";
36
+ readonly PRESENCE_AVATAR_3D: "avatar_3d";
37
+ };
38
+ export type PresenceKind = (typeof PresenceKind)[keyof typeof PresenceKind];
39
+ /**
40
+ * One seat in a conversation. `modelId` is the bound model the capability gate
41
+ * resolves against; `capabilities` is an ADVISORY display-only mirror (see its
42
+ * field doc). Both optional: the `user` seat and presence-only participants
43
+ * carry neither.
44
+ */
45
+ export interface ConversationParticipant {
46
+ /** Stable per-conversation id for this seat (not the persona id). */
47
+ participantId: string;
48
+ /** Bound persona id, when this seat portrays a persona. */
49
+ personaId?: string;
50
+ role: ParticipantRole;
51
+ presence: PresenceKind;
52
+ /** The bound model's id, when this seat is model-backed. The capability gate
53
+ * (`resolveEffectiveModel`) resolves caps against the R1 registry keyed by
54
+ * THIS id — never the `capabilities` mirror below. */
55
+ modelId?: string;
56
+ /**
57
+ * ADVISORY / display-only mirror of the bound model's caps (e.g. for R2.2's
58
+ * capability chips). It does **NOT** gate model selection — `resolveEffectiveModel`
59
+ * reads the authoritative caps from the R1 chat registry (`registry.satisfies`),
60
+ * which mirrors `shared/model_config.py` (single source of truth). Kept so the
61
+ * renderer can show caps without a second registry lookup; never trusted for
62
+ * the auto-switch decision.
63
+ */
64
+ capabilities?: ChatModelCapability[];
65
+ }
66
+ //# sourceMappingURL=participant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.d.ts","sourceRoot":"","sources":["../../src/conversation/participant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB;;2DAEuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Conversation participant model (R2.1).
3
+ *
4
+ * A `ConversationParticipant` is ONE seat in a conversation — a bound persona,
5
+ * the Dungeon Master, or the human user. The headless `ConversationController`
6
+ * (controller.ts) holds a list of these plus an active one; React (R2.2) and a
7
+ * game engine (R7) both render the same list without owning its shape.
8
+ *
9
+ * `role` and `presence` are frozen constant objects — never inline the string
10
+ * literals (the cross-PR "constants over string literals" rule). The capability
11
+ * vocabulary is the EXISTING `ChatModelCapability` union from api.ts (the single
12
+ * source of truth that mirrors `shared/model_config.py:CAPABILITY_*`); R2 does
13
+ * NOT declare a parallel capability map.
14
+ */
15
+ /**
16
+ * The kind of seat a participant occupies. `persona` and `dm` are
17
+ * model-backed; `user` is the human. Frozen so a role can never be a raw
18
+ * string at a call site — mirrors the `ROUTE_*`/`PRESENCE_*` discipline.
19
+ */
20
+ export const ParticipantRole = {
21
+ PERSONA: 'persona',
22
+ DM: 'dm',
23
+ USER: 'user',
24
+ };
25
+ /**
26
+ * How a participant is rendered on the presence stage. `PRESENCE_AVATAR_3D` is
27
+ * a RESERVED stub — the kind is registerable but its renderer is a no-op until
28
+ * the R7 flagship lands (see `PresenceRendererRegistry` + tech-debt). The values
29
+ * double as the registry lookup keys.
30
+ */
31
+ export const PresenceKind = {
32
+ PRESENCE_NONE: 'none',
33
+ PRESENCE_FACE_2D: 'face_2d',
34
+ PRESENCE_AVATAR_3D: 'avatar_3d',
35
+ };
36
+ //# sourceMappingURL=participant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.js","sourceRoot":"","sources":["../../src/conversation/participant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,SAAS;IAClB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;CACJ,CAAC;AAIX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE,MAAM;IACrB,gBAAgB,EAAE,SAAS;IAC3B,kBAAkB,EAAE,WAAW;CACvB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `PresenceAdapter` (R7.3) — the renderer-agnostic seam the
3
+ * `ConversationRuntime` drives. React (`CharacterFace`, 2D persona face) is
4
+ * ONE implementation; a PlayCanvas 3D avatar is a FUTURE implementation
5
+ * consuming the identical contract. Zero React/DOM/PlayCanvas imports here.
6
+ *
7
+ * Every method is keyed by `personaId`, so an N-participant scene maps cleanly
8
+ * onto N presence slots regardless of renderer. The method set is derived
9
+ * STRICTLY from what the React face already does (active swap, speaking flag,
10
+ * viseme) plus mount/unmount — no speculative methods (the over-abstraction
11
+ * guard in the R7 spec).
12
+ *
13
+ * Adapter SELECTION stays on the existing R2.1 seam: hosts register a renderer
14
+ * factory per `PresenceKind` on `PresenceRendererRegistry`
15
+ * (presenceRegistry.ts) — this module does NOT re-declare a kind→factory map.
16
+ * What it adds is the per-call gating contract: `presenceBus` consults
17
+ * {@link presenceKindHasStage} so a `PRESENCE_NONE` (text-only) participant
18
+ * receives no presence calls beyond `mount`/`unmount`.
19
+ *
20
+ * Viseme coupling (the R7.3 risk note): `applyViseme` takes the *scheduled
21
+ * viseme value* (`VisemeSymbol`, from the existing `visemeScheduler`/
22
+ * `visemeGeometry` pipeline) — never a DOM node. The React adapter applies it
23
+ * to SVG; a PlayCanvas adapter applies it to morph targets.
24
+ */
25
+ import { PresenceKind } from './participant';
26
+ import type { RosterParticipant } from './types';
27
+ import type { VisemeSymbol } from '../visemeScheduler';
28
+ /**
29
+ * The renderer contract. A host implements this once per renderer (2D face,
30
+ * 3D avatar, headless recorder) and `presenceBus` drives it from
31
+ * `ConversationRuntime` transitions.
32
+ */
33
+ export interface PresenceAdapter {
34
+ /** A participant entered the scene: create its presence slot. Called for
35
+ * EVERY roster member, including `PRESENCE_NONE` (so the renderer can
36
+ * account for text-only seats), but a `none` seat gets no further calls. */
37
+ mount(participant: RosterParticipant): void;
38
+ /** The participant left the scene (or the binding was disposed): tear the
39
+ * slot down. */
40
+ unmount(personaId: string): void;
41
+ /** The turn moved: `personaId` now holds the floor (`null` = nobody, e.g.
42
+ * after a host `releaseTurn`). Stage focus/camera/highlight here. */
43
+ setActiveParticipant(personaId: string | null): void;
44
+ /** Toggle the speaking indicator for one participant. */
45
+ setSpeaking(personaId: string, speaking: boolean): void;
46
+ /** Apply one scheduled viseme value to a participant's mouth — SVG path for
47
+ * the 2D face, morph target for a 3D avatar. */
48
+ applyViseme(personaId: string, viseme: VisemeSymbol): void;
49
+ }
50
+ /**
51
+ * True when a presence kind occupies the stage — i.e. should receive
52
+ * `setActiveParticipant`/`setSpeaking`/`applyViseme` calls. `PRESENCE_NONE`
53
+ * seats are text-only: mount/unmount bookkeeping, nothing staged.
54
+ */
55
+ export declare function presenceKindHasStage(kind: PresenceKind): boolean;
56
+ //# sourceMappingURL=presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/conversation/presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;iFAE6E;IAC7E,KAAK,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C;qBACiB;IACjB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC;0EACsE;IACtE,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,yDAAyD;IACzD,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACxD;qDACiD;IACjD,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAEhE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `PresenceAdapter` (R7.3) — the renderer-agnostic seam the
3
+ * `ConversationRuntime` drives. React (`CharacterFace`, 2D persona face) is
4
+ * ONE implementation; a PlayCanvas 3D avatar is a FUTURE implementation
5
+ * consuming the identical contract. Zero React/DOM/PlayCanvas imports here.
6
+ *
7
+ * Every method is keyed by `personaId`, so an N-participant scene maps cleanly
8
+ * onto N presence slots regardless of renderer. The method set is derived
9
+ * STRICTLY from what the React face already does (active swap, speaking flag,
10
+ * viseme) plus mount/unmount — no speculative methods (the over-abstraction
11
+ * guard in the R7 spec).
12
+ *
13
+ * Adapter SELECTION stays on the existing R2.1 seam: hosts register a renderer
14
+ * factory per `PresenceKind` on `PresenceRendererRegistry`
15
+ * (presenceRegistry.ts) — this module does NOT re-declare a kind→factory map.
16
+ * What it adds is the per-call gating contract: `presenceBus` consults
17
+ * {@link presenceKindHasStage} so a `PRESENCE_NONE` (text-only) participant
18
+ * receives no presence calls beyond `mount`/`unmount`.
19
+ *
20
+ * Viseme coupling (the R7.3 risk note): `applyViseme` takes the *scheduled
21
+ * viseme value* (`VisemeSymbol`, from the existing `visemeScheduler`/
22
+ * `visemeGeometry` pipeline) — never a DOM node. The React adapter applies it
23
+ * to SVG; a PlayCanvas adapter applies it to morph targets.
24
+ */
25
+ import { PresenceKind } from './participant.js';
26
+ /**
27
+ * True when a presence kind occupies the stage — i.e. should receive
28
+ * `setActiveParticipant`/`setSpeaking`/`applyViseme` calls. `PRESENCE_NONE`
29
+ * seats are text-only: mount/unmount bookkeeping, nothing staged.
30
+ */
31
+ export function presenceKindHasStage(kind) {
32
+ return kind !== PresenceKind.PRESENCE_NONE;
33
+ }
34
+ //# sourceMappingURL=presence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/conversation/presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA2B7C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,OAAO,IAAI,KAAK,YAAY,CAAC,aAAa,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `presenceBus` (R7.3) — pure glue wiring `ConversationRuntime` state
3
+ * transitions to `PresenceAdapter` calls. No renderer dependency, no DOM, no
4
+ * network: a `turn_changed`-driven swap becomes
5
+ * `setActiveParticipant(next)` + `setSpeaking(prev,false)` + `setSpeaking(next,true)`,
6
+ * gated per participant by {@link presenceKindHasStage} so text-only
7
+ * (`PRESENCE_NONE`) seats receive nothing beyond `mount`/`unmount`.
8
+ *
9
+ * LAND-DARK: in ordinary chat / single-DM adventures the runtime's
10
+ * `activePersonaId` never moves, so after the initial staging the bus emits
11
+ * nothing — the conformance test pins exactly one `mount` + one
12
+ * `setActiveParticipant` + one `setSpeaking(true)` for the lone speaker.
13
+ *
14
+ * Visemes do not flow through runtime state (the voice pipeline lifts into
15
+ * client-core in R7.5); the binding exposes {@link PresenceBinding.applyViseme}
16
+ * as the single pass-through so R7.5 has exactly one delivery path to a face.
17
+ */
18
+ import type { ConversationRuntime } from './runtime';
19
+ import type { PresenceAdapter } from './presence';
20
+ import type { VisemeSymbol } from '../visemeScheduler';
21
+ /** Handle returned by {@link bindPresence}. */
22
+ export interface PresenceBinding {
23
+ /**
24
+ * Deliver one scheduled viseme value to `personaId`'s presence slot.
25
+ * Dropped (no adapter call) when the persona is not in the roster or its
26
+ * presence kind has no stage (`PRESENCE_NONE`).
27
+ */
28
+ applyViseme(personaId: string, viseme: VisemeSymbol): void;
29
+ /** Unsubscribe from the runtime and unmount every mounted participant.
30
+ * Idempotent. */
31
+ dispose(): void;
32
+ }
33
+ /**
34
+ * Bind a `PresenceAdapter` to a `ConversationRuntime`.
35
+ *
36
+ * On bind: `mount` every roster participant (in roster order), then stage the
37
+ * initial speaker (`setActiveParticipant` + `setSpeaking(true)`) when one is
38
+ * set and staged. Thereafter every speaker transition (server `turn_changed`
39
+ * via the runtime, or a host `releaseTurn`) is mirrored to the adapter.
40
+ */
41
+ export declare function bindPresence(runtime: ConversationRuntime, adapter: PresenceAdapter): PresenceBinding;
42
+ //# sourceMappingURL=presenceBus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenceBus.d.ts","sourceRoot":"","sources":["../../src/conversation/presenceBus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3D;sBACkB;IAClB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,GACvB,eAAe,CA4DjB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * `presenceBus` (R7.3) — pure glue wiring `ConversationRuntime` state
3
+ * transitions to `PresenceAdapter` calls. No renderer dependency, no DOM, no
4
+ * network: a `turn_changed`-driven swap becomes
5
+ * `setActiveParticipant(next)` + `setSpeaking(prev,false)` + `setSpeaking(next,true)`,
6
+ * gated per participant by {@link presenceKindHasStage} so text-only
7
+ * (`PRESENCE_NONE`) seats receive nothing beyond `mount`/`unmount`.
8
+ *
9
+ * LAND-DARK: in ordinary chat / single-DM adventures the runtime's
10
+ * `activePersonaId` never moves, so after the initial staging the bus emits
11
+ * nothing — the conformance test pins exactly one `mount` + one
12
+ * `setActiveParticipant` + one `setSpeaking(true)` for the lone speaker.
13
+ *
14
+ * Visemes do not flow through runtime state (the voice pipeline lifts into
15
+ * client-core in R7.5); the binding exposes {@link PresenceBinding.applyViseme}
16
+ * as the single pass-through so R7.5 has exactly one delivery path to a face.
17
+ */
18
+ import { presenceKindHasStage } from './presence.js';
19
+ /**
20
+ * Bind a `PresenceAdapter` to a `ConversationRuntime`.
21
+ *
22
+ * On bind: `mount` every roster participant (in roster order), then stage the
23
+ * initial speaker (`setActiveParticipant` + `setSpeaking(true)`) when one is
24
+ * set and staged. Thereafter every speaker transition (server `turn_changed`
25
+ * via the runtime, or a host `releaseTurn`) is mirrored to the adapter.
26
+ */
27
+ export function bindPresence(runtime, adapter) {
28
+ const byPersonaId = (state, personaId) => personaId === null
29
+ ? undefined
30
+ : state.participants.find((p) => p.personaId === personaId);
31
+ const staged = (state, personaId) => {
32
+ const participant = byPersonaId(state, personaId);
33
+ return participant !== undefined && presenceKindHasStage(participant.presence);
34
+ };
35
+ /** Mirror one speaker move onto the adapter, honoring the stage gate. */
36
+ const stageSpeaker = (state, prev, next) => {
37
+ const nextStaged = staged(state, next);
38
+ // A `none`-kind (or roster-unknown) speaker must never be the staged id
39
+ // (text-only contract) — the stage clears to `null` instead, exactly as
40
+ // when nobody holds the floor.
41
+ adapter.setActiveParticipant(nextStaged ? next : null);
42
+ if (prev !== null && staged(state, prev))
43
+ adapter.setSpeaking(prev, false);
44
+ if (next !== null && nextStaged)
45
+ adapter.setSpeaking(next, true);
46
+ };
47
+ // Bind-time: mount the roster, then stage the initial speaker (if any).
48
+ const initial = runtime.getState();
49
+ for (const participant of initial.participants)
50
+ adapter.mount(participant);
51
+ if (initial.activePersonaId !== null && staged(initial, initial.activePersonaId)) {
52
+ adapter.setActiveParticipant(initial.activePersonaId);
53
+ adapter.setSpeaking(initial.activePersonaId, true);
54
+ }
55
+ let lastActive = initial.activePersonaId;
56
+ const unsubscribe = runtime.subscribe((state) => {
57
+ if (state.activePersonaId !== lastActive) {
58
+ stageSpeaker(state, lastActive, state.activePersonaId);
59
+ lastActive = state.activePersonaId;
60
+ }
61
+ });
62
+ let disposed = false;
63
+ return {
64
+ applyViseme(personaId, viseme) {
65
+ if (disposed)
66
+ return;
67
+ if (staged(runtime.getState(), personaId))
68
+ adapter.applyViseme(personaId, viseme);
69
+ },
70
+ dispose() {
71
+ if (disposed)
72
+ return;
73
+ disposed = true;
74
+ unsubscribe();
75
+ for (const participant of runtime.getState().participants) {
76
+ adapter.unmount(participant.personaId);
77
+ }
78
+ },
79
+ };
80
+ }
81
+ //# sourceMappingURL=presenceBus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenceBus.js","sourceRoot":"","sources":["../../src/conversation/presenceBus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAgBlD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,OAA4B,EAC5B,OAAwB;IAExB,MAAM,WAAW,GAAG,CAClB,KAA+B,EAC/B,SAAwB,EACO,EAAE,CACjC,SAAS,KAAK,IAAI;QAChB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAEhE,MAAM,MAAM,GAAG,CAAC,KAA+B,EAAE,SAAwB,EAAW,EAAE;QACpF,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClD,OAAO,WAAW,KAAK,SAAS,IAAI,oBAAoB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjF,CAAC,CAAC;IAEF,yEAAyE;IACzE,MAAM,YAAY,GAAG,CACnB,KAA+B,EAC/B,IAAmB,EACnB,IAAmB,EACb,EAAE;QACR,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvC,wEAAwE;QACxE,wEAAwE;QACxE,+BAA+B;QAC/B,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;YAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3E,IAAI,IAAI,KAAK,IAAI,IAAI,UAAU;YAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,wEAAwE;IACxE,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnC,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3E,IAAI,OAAO,CAAC,eAAe,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QACjF,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACtD,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IACzC,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9C,IAAI,KAAK,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YACzC,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;YACvD,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACL,WAAW,CAAC,SAAiB,EAAE,MAAoB;YACjD,IAAI,QAAQ;gBAAE,OAAO;YACrB,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC;gBAAE,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACpF,CAAC;QACD,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,WAAW,EAAE,CAAC;YACd,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,CAAC;gBAC1D,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Framework-agnostic presence-renderer registry (R2.1).
3
+ *
4
+ * Mirrors the named-registry discipline of the adapter registry
5
+ * (`adapters/registry.ts` — additive `register`, fail-loud on duplicate) and
6
+ * the `reactor/promptAddonRegistry.ts` precedent: it carries renderer FACTORIES
7
+ * keyed by `PresenceKind` and never touches the DOM itself. React (R2.2)
8
+ * registers a 2D-face factory; a game engine (R7) registers a 3D one; the core
9
+ * stays engine-free.
10
+ *
11
+ * A factory yields an opaque {@link PresenceHandle} (`mount`/`update`/`destroy`)
12
+ * so the caller drives the lifecycle without the registry knowing what the
13
+ * handle is. The registry is the single seam between the headless conversation
14
+ * state and whatever paints a face.
15
+ */
16
+ import { PresenceKind } from './participant';
17
+ /**
18
+ * Opaque per-mount handle a renderer factory returns. The conversation panel
19
+ * calls `mount` to attach into a host element, `update` on each presence-state
20
+ * change, and `destroy` on teardown. `unknown` payloads keep the core agnostic
21
+ * to the engine's host/state types — each renderer narrows them.
22
+ */
23
+ export interface PresenceHandle {
24
+ mount(host: unknown): void;
25
+ update(state: unknown): void;
26
+ destroy(): void;
27
+ }
28
+ /** A renderer factory. Called once per presence mount to produce a handle. */
29
+ export type PresenceRendererFactory = () => PresenceHandle;
30
+ export declare class PresenceRendererRegistry {
31
+ private readonly factories;
32
+ /**
33
+ * Register a renderer factory for a presence kind. Additive — THROWS on a
34
+ * duplicate kind (fail-loud), matching the adapter registry's no-silent-
35
+ * overwrite contract. A renderer binding is a one-time app-init step, so a
36
+ * second registration is a wiring bug, not a runtime condition.
37
+ */
38
+ register(kind: PresenceKind, factory: PresenceRendererFactory): void;
39
+ /**
40
+ * Resolve a renderer factory for a kind. Returns the registered factory, or
41
+ * the `PRESENCE_NONE` no-op factory when the kind is unregistered (fail-soft
42
+ * — this is what lets the reserved `PRESENCE_AVATAR_3D` kind render nothing
43
+ * instead of throwing until R7 binds a real 3D renderer).
44
+ */
45
+ resolve(kind: PresenceKind): PresenceRendererFactory;
46
+ /** True iff a factory is registered for `kind` (the no-op fallback aside). */
47
+ has(kind: PresenceKind): boolean;
48
+ }
49
+ //# sourceMappingURL=presenceRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenceRegistry.d.ts","sourceRoot":"","sources":["../../src/conversation/presenceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GAAG,MAAM,cAAc,CAAC;AAkB3D,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoD;IAE9E;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAUpE;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,uBAAuB;IAIpD,8EAA8E;IAC9E,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;CAGjC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Framework-agnostic presence-renderer registry (R2.1).
3
+ *
4
+ * Mirrors the named-registry discipline of the adapter registry
5
+ * (`adapters/registry.ts` — additive `register`, fail-loud on duplicate) and
6
+ * the `reactor/promptAddonRegistry.ts` precedent: it carries renderer FACTORIES
7
+ * keyed by `PresenceKind` and never touches the DOM itself. React (R2.2)
8
+ * registers a 2D-face factory; a game engine (R7) registers a 3D one; the core
9
+ * stays engine-free.
10
+ *
11
+ * A factory yields an opaque {@link PresenceHandle} (`mount`/`update`/`destroy`)
12
+ * so the caller drives the lifecycle without the registry knowing what the
13
+ * handle is. The registry is the single seam between the headless conversation
14
+ * state and whatever paints a face.
15
+ */
16
+ /**
17
+ * The `PRESENCE_NONE` no-op handle. Returned for any unregistered kind so the
18
+ * 3D-avatar stub (and any not-yet-bound kind) fails SOFT — the caller can drive
19
+ * the lifecycle without a null check and nothing paints. Stateless, so a single
20
+ * shared instance is safe.
21
+ */
22
+ // Frozen: the no-op handle is shared by every unregistered kind, so freeze it
23
+ // against accidental mutation by a caller that mistakes it for a live renderer.
24
+ const NOOP_HANDLE = Object.freeze({
25
+ mount() { },
26
+ update() { },
27
+ destroy() { },
28
+ });
29
+ const NOOP_FACTORY = () => NOOP_HANDLE;
30
+ export class PresenceRendererRegistry {
31
+ factories = new Map();
32
+ /**
33
+ * Register a renderer factory for a presence kind. Additive — THROWS on a
34
+ * duplicate kind (fail-loud), matching the adapter registry's no-silent-
35
+ * overwrite contract. A renderer binding is a one-time app-init step, so a
36
+ * second registration is a wiring bug, not a runtime condition.
37
+ */
38
+ register(kind, factory) {
39
+ if (this.factories.has(kind)) {
40
+ throw new Error(`PresenceRendererRegistry: duplicate registration for presence kind "${kind}" — ` +
41
+ 'registration is additive and must not silently overwrite an existing renderer.');
42
+ }
43
+ this.factories.set(kind, factory);
44
+ }
45
+ /**
46
+ * Resolve a renderer factory for a kind. Returns the registered factory, or
47
+ * the `PRESENCE_NONE` no-op factory when the kind is unregistered (fail-soft
48
+ * — this is what lets the reserved `PRESENCE_AVATAR_3D` kind render nothing
49
+ * instead of throwing until R7 binds a real 3D renderer).
50
+ */
51
+ resolve(kind) {
52
+ return this.factories.get(kind) ?? NOOP_FACTORY;
53
+ }
54
+ /** True iff a factory is registered for `kind` (the no-op fallback aside). */
55
+ has(kind) {
56
+ return this.factories.has(kind);
57
+ }
58
+ }
59
+ //# sourceMappingURL=presenceRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenceRegistry.js","sourceRoot":"","sources":["../../src/conversation/presenceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH;;;;;GAKG;AACH,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,WAAW,GAAmB,MAAM,CAAC,MAAM,CAAC;IAChD,KAAK,KAAI,CAAC;IACV,MAAM,KAAI,CAAC;IACX,OAAO,KAAI,CAAC;CACb,CAAC,CAAC;AAEH,MAAM,YAAY,GAA4B,GAAG,EAAE,CAAC,WAAW,CAAC;AAEhE,MAAM,OAAO,wBAAwB;IAClB,SAAS,GAAG,IAAI,GAAG,EAAyC,CAAC;IAE9E;;;;;OAKG;IACH,QAAQ,CAAC,IAAkB,EAAE,OAAgC;QAC3D,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,uEAAuE,IAAI,MAAM;gBAC/E,gFAAgF,CACnF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAkB;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC;IAClD,CAAC;IAED,8EAA8E;IAC9E,GAAG,CAAC,IAAkB;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF"}