@memberjunction/ng-conversations 6.3.0-edge.0 → 6.3.0-edge.2

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 (272) hide show
  1. package/README.md +60 -22
  2. package/dist/assets/edge-ai.worker.js +35168 -0
  3. package/dist/lib/components/agent/agent-instance-editor-modal.component.d.ts +186 -0
  4. package/dist/lib/components/agent/agent-instance-editor-modal.component.d.ts.map +1 -0
  5. package/dist/lib/components/agent/agent-instance-editor-modal.component.js +2202 -0
  6. package/dist/lib/components/agent/agent-instance-editor-modal.component.js.map +1 -0
  7. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts +39 -6
  8. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts.map +1 -1
  9. package/dist/lib/components/artifact/artifact-share-modal.component.js +773 -204
  10. package/dist/lib/components/artifact/artifact-share-modal.component.js.map +1 -1
  11. package/dist/lib/components/collection/collection-tree.component.d.ts.map +1 -1
  12. package/dist/lib/components/collection/collection-tree.component.js +19 -18
  13. package/dist/lib/components/collection/collection-tree.component.js.map +1 -1
  14. package/dist/lib/components/collection/collection-view.component.d.ts +6 -4
  15. package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
  16. package/dist/lib/components/collection/collection-view.component.js +35 -17
  17. package/dist/lib/components/collection/collection-view.component.js.map +1 -1
  18. package/dist/lib/components/collection/collections-full-view.component.d.ts +1 -0
  19. package/dist/lib/components/collection/collections-full-view.component.d.ts.map +1 -1
  20. package/dist/lib/components/collection/collections-full-view.component.js +108 -106
  21. package/dist/lib/components/collection/collections-full-view.component.js.map +1 -1
  22. package/dist/lib/components/composer/ai-composer.component.d.ts +15 -1
  23. package/dist/lib/components/composer/ai-composer.component.d.ts.map +1 -1
  24. package/dist/lib/components/composer/ai-composer.component.js +43 -4
  25. package/dist/lib/components/composer/ai-composer.component.js.map +1 -1
  26. package/dist/lib/components/conversation/conversation-agent-picker.component.d.ts +20 -2
  27. package/dist/lib/components/conversation/conversation-agent-picker.component.d.ts.map +1 -1
  28. package/dist/lib/components/conversation/conversation-agent-picker.component.js +378 -62
  29. package/dist/lib/components/conversation/conversation-agent-picker.component.js.map +1 -1
  30. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +94 -18
  31. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
  32. package/dist/lib/components/conversation/conversation-chat-area.component.js +732 -439
  33. package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
  34. package/dist/lib/components/conversation/conversation-list.component.d.ts +19 -1
  35. package/dist/lib/components/conversation/conversation-list.component.d.ts.map +1 -1
  36. package/dist/lib/components/conversation/conversation-list.component.js +184 -89
  37. package/dist/lib/components/conversation/conversation-list.component.js.map +1 -1
  38. package/dist/lib/components/export/export-modal.component.d.ts +7 -2
  39. package/dist/lib/components/export/export-modal.component.d.ts.map +1 -1
  40. package/dist/lib/components/export/export-modal.component.js +13 -2
  41. package/dist/lib/components/export/export-modal.component.js.map +1 -1
  42. package/dist/lib/components/library/library-create-dialog.component.d.ts +136 -0
  43. package/dist/lib/components/library/library-create-dialog.component.d.ts.map +1 -0
  44. package/dist/lib/components/library/library-create-dialog.component.js +1620 -0
  45. package/dist/lib/components/library/library-create-dialog.component.js.map +1 -0
  46. package/dist/lib/components/library/library-full-view.component.d.ts +10 -4
  47. package/dist/lib/components/library/library-full-view.component.d.ts.map +1 -1
  48. package/dist/lib/components/library/library-full-view.component.js +216 -40
  49. package/dist/lib/components/library/library-full-view.component.js.map +1 -1
  50. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts +97 -0
  51. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts.map +1 -0
  52. package/dist/lib/components/library/library-remote-drive-pane.component.js +1229 -0
  53. package/dist/lib/components/library/library-remote-drive-pane.component.js.map +1 -0
  54. package/dist/lib/components/library/library-workspace.component.d.ts +293 -0
  55. package/dist/lib/components/library/library-workspace.component.d.ts.map +1 -0
  56. package/dist/lib/components/library/library-workspace.component.js +5121 -0
  57. package/dist/lib/components/library/library-workspace.component.js.map +1 -0
  58. package/dist/lib/components/library/library.models.d.ts +192 -0
  59. package/dist/lib/components/library/library.models.d.ts.map +1 -0
  60. package/dist/lib/components/library/library.models.js +2 -0
  61. package/dist/lib/components/library/library.models.js.map +1 -0
  62. package/dist/lib/components/message/agent-handoff-card.component.js +1 -1
  63. package/dist/lib/components/message/agent-handoff-card.component.js.map +1 -1
  64. package/dist/lib/components/message/conversation-message-rating.component.d.ts +5 -0
  65. package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
  66. package/dist/lib/components/message/conversation-message-rating.component.js +72 -16
  67. package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
  68. package/dist/lib/components/message/message-input.component.d.ts +33 -14
  69. package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
  70. package/dist/lib/components/message/message-input.component.js +142 -75
  71. package/dist/lib/components/message/message-input.component.js.map +1 -1
  72. package/dist/lib/components/message/message-item.component.d.ts +51 -4
  73. package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
  74. package/dist/lib/components/message/message-item.component.js +640 -399
  75. package/dist/lib/components/message/message-item.component.js.map +1 -1
  76. package/dist/lib/components/message/message-list.component.d.ts +15 -1
  77. package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
  78. package/dist/lib/components/message/message-list.component.js +75 -3
  79. package/dist/lib/components/message/message-list.component.js.map +1 -1
  80. package/dist/lib/components/navigation/conversation-navigation.component.js +9 -9
  81. package/dist/lib/components/navigation/conversation-navigation.component.js.map +1 -1
  82. package/dist/lib/components/overlay/chat-overlay.component.d.ts +94 -6
  83. package/dist/lib/components/overlay/chat-overlay.component.d.ts.map +1 -1
  84. package/dist/lib/components/overlay/chat-overlay.component.js +249 -59
  85. package/dist/lib/components/overlay/chat-overlay.component.js.map +1 -1
  86. package/dist/lib/components/project/project-form-modal.component.d.ts +6 -0
  87. package/dist/lib/components/project/project-form-modal.component.d.ts.map +1 -1
  88. package/dist/lib/components/project/project-form-modal.component.js +81 -61
  89. package/dist/lib/components/project/project-form-modal.component.js.map +1 -1
  90. package/dist/lib/components/project/project-selector.component.d.ts +5 -0
  91. package/dist/lib/components/project/project-selector.component.d.ts.map +1 -1
  92. package/dist/lib/components/project/project-selector.component.js +11 -4
  93. package/dist/lib/components/project/project-selector.component.js.map +1 -1
  94. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts +55 -0
  95. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts.map +1 -0
  96. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js +974 -0
  97. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js.map +1 -0
  98. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts +66 -0
  99. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts.map +1 -0
  100. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js +253 -0
  101. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js.map +1 -0
  102. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts +80 -0
  103. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts.map +1 -0
  104. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js +49 -0
  105. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js.map +1 -0
  106. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts +54 -0
  107. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts.map +1 -0
  108. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js +386 -0
  109. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js.map +1 -0
  110. package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts +28 -1
  111. package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts.map +1 -1
  112. package/dist/lib/components/realtime/capture/realtime-capture-channel.js +53 -1
  113. package/dist/lib/components/realtime/capture/realtime-capture-channel.js.map +1 -1
  114. package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
  115. package/dist/lib/components/realtime/channels/client-context-channel.js +23 -7
  116. package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
  117. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +1 -0
  118. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -1
  119. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +15 -2
  120. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -1
  121. package/dist/lib/components/realtime/media/media-channel.d.ts +32 -11
  122. package/dist/lib/components/realtime/media/media-channel.d.ts.map +1 -1
  123. package/dist/lib/components/realtime/media/media-channel.js +186 -23
  124. package/dist/lib/components/realtime/media/media-channel.js.map +1 -1
  125. package/dist/lib/components/realtime/media/realtime-media-surface.component.d.ts +9 -1
  126. package/dist/lib/components/realtime/media/realtime-media-surface.component.d.ts.map +1 -1
  127. package/dist/lib/components/realtime/media/realtime-media-surface.component.js +33 -10
  128. package/dist/lib/components/realtime/media/realtime-media-surface.component.js.map +1 -1
  129. package/dist/lib/components/realtime/realtime-agent-banner.component.js +3 -3
  130. package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
  131. package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
  132. package/dist/lib/components/realtime/realtime-agent-picker.component.js +3 -3
  133. package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
  134. package/dist/lib/components/realtime/realtime-composer.component.js +6 -4
  135. package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
  136. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +82 -33
  137. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
  138. package/dist/lib/components/realtime/realtime-session-overlay.component.js +521 -191
  139. package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
  140. package/dist/lib/components/realtime/realtime-session-state.d.ts.map +1 -1
  141. package/dist/lib/components/realtime/realtime-session-state.js +1 -1
  142. package/dist/lib/components/realtime/realtime-session-state.js.map +1 -1
  143. package/dist/lib/components/realtime/realtime-session-thread.component.d.ts.map +1 -1
  144. package/dist/lib/components/realtime/realtime-session-thread.component.js +90 -5
  145. package/dist/lib/components/realtime/realtime-session-thread.component.js.map +1 -1
  146. package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -1
  147. package/dist/lib/components/realtime/realtime-surface-stage.model.js +2 -1
  148. package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -1
  149. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts +11 -4
  150. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts.map +1 -1
  151. package/dist/lib/components/realtime/realtime-surface-tab-style.js +24 -5
  152. package/dist/lib/components/realtime/realtime-surface-tab-style.js.map +1 -1
  153. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +7 -9
  154. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
  155. package/dist/lib/components/realtime/realtime-surface-tabs.model.js +25 -15
  156. package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
  157. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +30 -1
  158. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts.map +1 -1
  159. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js +150 -2
  160. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js.map +1 -1
  161. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts +101 -3
  162. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts.map +1 -1
  163. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js +503 -55
  164. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
  165. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts +48 -5
  166. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts.map +1 -1
  167. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js +249 -53
  168. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js.map +1 -1
  169. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
  170. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +1 -1
  171. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
  172. package/dist/lib/components/search/search-panel.component.d.ts +10 -0
  173. package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
  174. package/dist/lib/components/search/search-panel.component.js +25 -3
  175. package/dist/lib/components/search/search-panel.component.js.map +1 -1
  176. package/dist/lib/components/share/share-modal.component.d.ts.map +1 -1
  177. package/dist/lib/components/share/share-modal.component.js +181 -127
  178. package/dist/lib/components/share/share-modal.component.js.map +1 -1
  179. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +14 -1
  180. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -1
  181. package/dist/lib/components/sidebar/conversation-sidebar.component.js +50 -11
  182. package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -1
  183. package/dist/lib/components/sidebar/my-agents-section.component.d.ts +78 -0
  184. package/dist/lib/components/sidebar/my-agents-section.component.d.ts.map +1 -0
  185. package/dist/lib/components/sidebar/my-agents-section.component.js +450 -0
  186. package/dist/lib/components/sidebar/my-agents-section.component.js.map +1 -0
  187. package/dist/lib/components/task/tasks-full-view.component.d.ts +31 -8
  188. package/dist/lib/components/task/tasks-full-view.component.d.ts.map +1 -1
  189. package/dist/lib/components/task/tasks-full-view.component.js +701 -497
  190. package/dist/lib/components/task/tasks-full-view.component.js.map +1 -1
  191. package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
  192. package/dist/lib/components/workspace/conversation-workspace.component.js +15 -2
  193. package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
  194. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts +1 -0
  195. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts.map +1 -1
  196. package/dist/lib/composer-plugins/base-conversation-mention.provider.js +13 -1
  197. package/dist/lib/composer-plugins/base-conversation-mention.provider.js.map +1 -1
  198. package/dist/lib/conversations.module.d.ts +78 -71
  199. package/dist/lib/conversations.module.d.ts.map +1 -1
  200. package/dist/lib/conversations.module.js +68 -1
  201. package/dist/lib/conversations.module.js.map +1 -1
  202. package/dist/lib/models/agent-turn.model.d.ts +7 -1
  203. package/dist/lib/models/agent-turn.model.d.ts.map +1 -1
  204. package/dist/lib/models/agent-turn.model.js.map +1 -1
  205. package/dist/lib/services/agent-state.service.d.ts.map +1 -1
  206. package/dist/lib/services/agent-state.service.js +14 -3
  207. package/dist/lib/services/agent-state.service.js.map +1 -1
  208. package/dist/lib/services/artifact-permission.service.d.ts.map +1 -1
  209. package/dist/lib/services/artifact-permission.service.js +14 -3
  210. package/dist/lib/services/artifact-permission.service.js.map +1 -1
  211. package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
  212. package/dist/lib/services/artifact-state.service.js +43 -11
  213. package/dist/lib/services/artifact-state.service.js.map +1 -1
  214. package/dist/lib/services/conversation-agent.service.d.ts +31 -21
  215. package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
  216. package/dist/lib/services/conversation-agent.service.js +84 -35
  217. package/dist/lib/services/conversation-agent.service.js.map +1 -1
  218. package/dist/lib/services/conversation-tasks-filter.d.ts +59 -2
  219. package/dist/lib/services/conversation-tasks-filter.d.ts.map +1 -1
  220. package/dist/lib/services/conversation-tasks-filter.js +222 -18
  221. package/dist/lib/services/conversation-tasks-filter.js.map +1 -1
  222. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts +85 -0
  223. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts.map +1 -0
  224. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js +257 -0
  225. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js.map +1 -0
  226. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts +85 -0
  227. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts.map +1 -0
  228. package/dist/lib/services/edge-ai/edge-ai-protocol.js +10 -0
  229. package/dist/lib/services/edge-ai/edge-ai-protocol.js.map +1 -0
  230. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts +90 -0
  231. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts.map +1 -0
  232. package/dist/lib/services/edge-ai/edge-ai-worker-host.js +386 -0
  233. package/dist/lib/services/edge-ai/edge-ai-worker-host.js.map +1 -0
  234. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts +13 -0
  235. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts.map +1 -0
  236. package/dist/lib/services/edge-ai/edge-ai.worker.js +201 -0
  237. package/dist/lib/services/edge-ai/edge-ai.worker.js.map +1 -0
  238. package/dist/lib/services/export.service.d.ts +64 -0
  239. package/dist/lib/services/export.service.d.ts.map +1 -1
  240. package/dist/lib/services/export.service.js +185 -6
  241. package/dist/lib/services/export.service.js.map +1 -1
  242. package/dist/lib/services/library-creation.service.d.ts +304 -0
  243. package/dist/lib/services/library-creation.service.d.ts.map +1 -0
  244. package/dist/lib/services/library-creation.service.js +1244 -0
  245. package/dist/lib/services/library-creation.service.js.map +1 -0
  246. package/dist/lib/services/realtime-pairing.d.ts +3 -3
  247. package/dist/lib/services/realtime-pairing.js +4 -4
  248. package/dist/lib/services/realtime-pairing.js.map +1 -1
  249. package/dist/lib/services/realtime-session-review.service.d.ts +14 -0
  250. package/dist/lib/services/realtime-session-review.service.d.ts.map +1 -1
  251. package/dist/lib/services/realtime-session-review.service.js +46 -4
  252. package/dist/lib/services/realtime-session-review.service.js.map +1 -1
  253. package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
  254. package/dist/lib/services/realtime-session.service.js +2 -1
  255. package/dist/lib/services/realtime-session.service.js.map +1 -1
  256. package/dist/lib/services/search.service.d.ts +19 -2
  257. package/dist/lib/services/search.service.d.ts.map +1 -1
  258. package/dist/lib/services/search.service.js +99 -36
  259. package/dist/lib/services/search.service.js.map +1 -1
  260. package/dist/lib/utils/agent-handoff-map.js +1 -1
  261. package/dist/lib/utils/agent-handoff-map.js.map +1 -1
  262. package/dist/lib/utils/agent-turn-routing.js +1 -1
  263. package/dist/lib/utils/agent-turn-routing.js.map +1 -1
  264. package/dist/lib/utils/decision-routing.d.ts +5 -2
  265. package/dist/lib/utils/decision-routing.d.ts.map +1 -1
  266. package/dist/lib/utils/decision-routing.js +9 -4
  267. package/dist/lib/utils/decision-routing.js.map +1 -1
  268. package/dist/public-api.d.ts +15 -0
  269. package/dist/public-api.d.ts.map +1 -1
  270. package/dist/public-api.js +17 -1
  271. package/dist/public-api.js.map +1 -1
  272. package/package.json +42 -37
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session-state.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AACzD,OAAO,EACL,eAAe,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,wBAAwB,EAC7H,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAkB,MAAM,kCAAkC,CAAC;AAE5F;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,SAAS,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IACzC,kDAAkD;IAClD,mBAAmB,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAC5D,mCAAmC;IACnC,iBAAiB,EAAE,UAAU,CAAC,wBAAwB,CAAC,CAAC;IACxD,4CAA4C;IAC5C,oBAAoB,EAAE,UAAU,CAAC,2BAA2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C/E,KAAK,IAAI,IAAI;IAKpB;;;;;;;;;;OAUG;IACI,qBAAqB,CAAC,EAAE,GAAE,IAAiB,GAAG,IAAI;IAczD,+HAA+H;IAC/H,OAAO,CAAC,UAAU;IAuDlB,0FAA0F;IAC1F,OAAO,CAAC,UAAU;IAgBlB,wFAAwF;IACxF,OAAO,CAAC,UAAU;IAqBlB,oFAAoF;IACpF,OAAO,CAAC,QAAQ;IAsDhB,sEAAsE;IACtE,OAAO,CAAC,WAAW;IAKnB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAmCjB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAYnB,+EAA+E;IAC/E,OAAO,CAAC,YAAY;IAIpB,iFAAiF;IACjF,OAAO,CAAC,eAAe;IAKvB,6EAA6E;IAC7E,OAAO,CAAC,WAAW;IAKnB,+CAA+C;IAC/C,OAAO,CAAC,KAAK;CAQd"}
1
+ {"version":3,"file":"realtime-session-state.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AACzD,OAAO,EACL,eAAe,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,wBAAwB,EAC7H,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAkB,MAAM,kCAAkC,CAAC;AAE5F;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,SAAS,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IACzC,kDAAkD;IAClD,mBAAmB,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAC5D,mCAAmC;IACnC,iBAAiB,EAAE,UAAU,CAAC,wBAAwB,CAAC,CAAC;IACxD,4CAA4C;IAC5C,oBAAoB,EAAE,UAAU,CAAC,2BAA2B,CAAC,CAAC;IAC9D,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,UA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,CAAC,EAAE,GAAE,IAAiB,GAAG,IAAI;IAczD,+HAA+H;IAC/H,OAAO,CAAC,UAAU;IAuDlB,0FAA0F;IAC1F,OAAO,CAAC,UAAU;IAgBlB,wFAAwF;IACxF,OAAO,CAAC,UAAU;IAqBlB,oFAAoF;IACpF,OAAO,CAAC,QAAQ;IAsDhB,sEAAsE;IACtE,OAAO,CAAC,WAAW;IAKnB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAmCjB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAYnB,+EAA+E;IAC/E,OAAO,CAAC,YAAY;IAIpB,iFAAiF;IACjF,OAAO,CAAC,eAAe;IAKvB,6EAA6E;IAC7E,OAAO,CAAC,WAAW;IAKnB,+CAA+C;IAC/C,OAAO,CAAC,KAAK;CAQd"}
@@ -46,7 +46,7 @@ export function FormatElapsed(ms) {
46
46
  */
47
47
  export class RealtimeSessionState {
48
48
  /** Display name used for new delegation cards (set by the overlay's AgentName input). */
49
- AgentName = 'Sage';
49
+ AgentName = 'Assistant';
50
50
  /** The merged, chronological thread (captions + delegation cards), oldest first. */
51
51
  Items = [];
52
52
  /** All delegation cards of the session, NEWEST first — the activity rail's list. */
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session-state.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAgB,MAAM,MAAM,CAAC;AAIzD,OAAO,EAA4B,cAAc,EAAE,MAAM,kCAAkC,CAAC;AA0G5F,yFAAyF;AACzF,kFAAkF;AAElF;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAe;IAC7D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,eAAe,CAAC,CAAC,OAAO,iBAAiB,CAAC;QAC/C,KAAK,kBAAkB,CAAC,CAAC,OAAO,qBAAqB,CAAC;QACtD,KAAK,kBAAkB,CAAC,CAAC,OAAO,iBAAiB,CAAC;QAClD,KA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,CAAC;QACpB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,+EAA+E;IACvE,YAAY;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACjE,CAAC;IAED,iFAAiF;IACzE,eAAe;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;QACxE,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAED,6EAA6E;IACrE,WAAW,CAAC,MAAc;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;IACnG,CAAC;IAED,+CAA+C;IACvC,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { Observable, Subject, Subscription } from 'rxjs';\nimport {\n RealtimeCaption, RealtimeDelegationProgress, RealtimeDelegationResult, RealtimeDelegationNarration, RealtimeThoughtNarration\n} from '@memberjunction/realtime-runtime';\nimport { ParsedDelegationArtifact, FormatToolName } from '@memberjunction/realtime-runtime';\n\n/**\n * The reactive session streams {@link RealtimeSessionState} merges — structurally\n * satisfied by `RealtimeSessionService`. Narrowed to an interface so the state (and its unit\n * tests) depend only on the streams, not on the full service / GraphQL import chain.\n */\nexport interface RealtimeSessionStreams {\n /** Growing user/assistant caption list. */\n Captions$: Observable<RealtimeCaption[]>;\n /** Progress updates from delegated agent runs. */\n DelegationProgress$: Observable<RealtimeDelegationProgress>;\n /** Terminal delegation results. */\n DelegationResult$: Observable<RealtimeDelegationResult>;\n /** Ephemeral spoken progress narrations. */\n DelegationNarration$: Observable<RealtimeDelegationNarration>;\n /** Model-authored thought / reasoning narrations. */\n ThoughtNarration$?: Observable<RealtimeThoughtNarration>;\n}\n\n/**\n * The view-model for one delegated tool/agent call in the live session. Built by\n * {@link RealtimeSessionState} from the `DelegationProgress$` / `DelegationResult$`\n * streams (correlated by `CallID`) and rendered both inline in the session thread\n * and as a compact card in the activity rail.\n *\n * Card objects are treated as IMMUTABLE — every progress/result event REPLACES the\n * card object (and the arrays containing it) so Angular bindings always see fresh\n * references and in-place updates reliably re-render.\n */\nexport interface RealtimeDelegationCardVM {\n /** What this card represents: a delegated agent run, a direct action, or model-authored narration. */\n Kind: 'agent' | 'action' | 'narration';\n /** The `invoke-target-agent` or direct-action call this card represents. */\n CallID: string;\n /** Display name of the delegated agent (e.g. \"Sage\") or formatted direct action title (e.g. \"Get Weather\"). */\n AgentName: string;\n /** The raw tool name when Kind === 'action' (e.g. \"File_Storage_List_Objects\"). */\n ToolName?: string;\n /** Latest human-readable progress message from the stream. */\n LatestMessage: string;\n /** The delegation phase (`prompt_execution` | `action_execution` | `direct_action` | …). */\n LatestStep: string;\n /** Optional completion percentage (0–100) when the server supplies it. */\n Percentage?: number;\n /** `true` once the delegation reached a terminal result. */\n Done: boolean;\n /** Whether the delegated work succeeded (meaningful once {@link Done} is true). */\n Success: boolean;\n /** Short run identifier (e.g. \"#a3f1\") if known; shown in expanded provenance detail. */\n RunRef?: string;\n /**\n * ID of the delegated agent run (`MJ: AI Agent Runs`) once the result reports it.\n * Powers the gear-gated \"Open run\" developer link on the card / rail entry.\n */\n RunID?: string;\n /** The real result text once the delegation completes. */\n Result?: string | null;\n /**\n * Artifacts the delegated run produced (set with the terminal result). Powers the\n * \"View\" affordance on done cards / rail entries and the surface panel's artifact tabs.\n */\n Artifacts?: ParsedDelegationArtifact[];\n /** Epoch ms when the first progress event for this call arrived. */\n StartedAt: number;\n /** Epoch ms when the terminal result arrived. */\n FinishedAt?: number;\n}\n\n/** A caption turn (user or assistant) in the unified thread. */\nexport interface RealtimeThreadCaptionItem {\n Kind: 'caption';\n Role: 'User' | 'Assistant';\n Text: string;\n}\n\n/** A delegation card in the unified thread (working → done chip). */\nexport interface RealtimeThreadDelegationItem {\n Kind: 'delegation';\n Card: RealtimeDelegationCardVM;\n}\n\n/**\n * A SESSION-BOUNDARY divider in the unified thread — a subtle, token-styled rule marking\n * where one session leg ends and another begins. Two producers:\n * - review→live continuation ({@link RealtimeSessionState.StartLiveContinuation}):\n * \"Resumed live session · <time>\" before the new live items;\n * - multi-leg session review (`BuildReviewThreadItems` over a `lastSessionId` chain):\n * \"Session leg · started <time>\" between legs, carrying the PREVIOUS leg's CloseReason\n * as a small chip so the reader sees why that leg ended.\n */\nexport interface RealtimeThreadDividerItem {\n Kind: 'divider';\n /** The divider's label (e.g. \"Resumed live session\", \"Session leg\"). */\n Label: string;\n /** Timestamp rendered after the label (\"· <time>\"), or null when unknown. */\n At: Date | null;\n /** Font Awesome icon class rendered before the label (e.g. `fa-solid fa-phone`). */\n Icon: string;\n /** Why the PRECEDING leg closed (review chains only) — rendered as a small chip. */\n CloseReason?: string | null;\n}\n\n/** One entry in the chronological thread: a caption bubble, a delegation card, or a leg divider. */\nexport type RealtimeThreadItem = RealtimeThreadCaptionItem | RealtimeThreadDelegationItem | RealtimeThreadDividerItem;\n\n// `FormatToolName` now lives in `@memberjunction/realtime-runtime`; import it from there\n// directly rather than through this module (MJ forbids cross-package re-exports).\n\n/**\n * Maps a raw delegation step id to a human-friendly phrase. Unknown steps fall back to\n * the raw progress message (per product direction) so the UI never shows snake_case ids.\n */\nexport function FriendlyStepLabel(step: string, message: string): string {\n switch (step) {\n case 'direct_action': return 'Looking that up';\n case 'prompt_execution': return 'Thinking it through';\n case 'action_execution': return 'Running actions';\n case 'subagent_execution': return 'Working with another agent';\n case 'decision_processing': return 'Deciding next steps';\n default: return message || 'Working';\n }\n}\n\n/** Formats an elapsed duration in ms as a compact human string (\"8s\", \"1m 04s\"). */\nexport function FormatElapsed(ms: number): string {\n const totalSec = Math.max(0, Math.round(ms / 1000));\n if (totalSec < 60) {\n return `${totalSec}s`;\n }\n const m = Math.floor(totalSec / 60);\n const s = totalSec % 60;\n return `${m}m ${s.toString().padStart(2, '0')}s`;\n}\n\n/**\n * SINGLE SOURCE of merged live-session state, owned by the overlay shell\n * (`RealtimeSessionOverlayComponent`) and passed via `@Input()` to BOTH the session\n * thread and the activity rail — so the per-CallID card bookkeeping and subscription\n * logic exists exactly once.\n *\n * Merges FOUR reactive streams from {@link RealtimeSessionService}:\n * - `Captions$` — growing user/assistant caption list → appended to {@link Items}.\n * - `DelegationProgress$` — first event per `CallID` inserts a working card at the thread\n * tail; later events REPLACE the card immutably (new object +\n * new arrays) so change detection always fires.\n * - `DelegationResult$` — flips the card to Done/Failed with the real result text.\n * - `DelegationNarration$` — the EPHEMERAL spoken progress note (latest only, never\n * accumulated), cleared when no delegation is running anymore.\n *\n * Consumers subscribe to {@link Changed$} and `markForCheck()`; all exposed collections\n * are replaced (never mutated) on change.\n */\nexport class RealtimeSessionState {\n /** Display name used for new delegation cards (set by the overlay's AgentName input). */\n public AgentName = 'Sage';\n\n /** The merged, chronological thread (captions + delegation cards), oldest first. */\n public Items: RealtimeThreadItem[] = [];\n\n /** All delegation cards of the session, NEWEST first — the activity rail's list. */\n public Cards: RealtimeDelegationCardVM[] = [];\n\n /** Latest ephemeral narration text, or null when none should be shown. */\n public Narration: string | null = null;\n\n /** CallID of the most recently started, still-running delegation (anchors the live note). */\n public ActiveCallId: string | null = null;\n\n /** Emits after every state change so views can mark themselves for check. */\n public readonly Changed$ = new Subject<void>();\n\n /** Number of captions already merged into {@link Items} (append-only bookkeeping). */\n private placedCaptionCount = 0;\n /** Live card lookup by CallID (insertion order = start order). */\n private cardsByCallId = new Map<string, RealtimeDelegationCardVM>();\n private subs: Subscription[] = [];\n\n /** True while at least one delegation is still running. */\n public get HasRunningDelegation(): boolean {\n return this.ActiveCallId !== null;\n }\n\n /** Subscribes to the session streams. Call once from the owning overlay shell. */\n public Attach(voice: RealtimeSessionStreams): void {\n if (this.subs.length > 0) {\n return; // already attached\n }\n this.subs.push(\n voice.Captions$.subscribe(c => this.onCaptions(c)),\n voice.DelegationProgress$.subscribe(p => this.onProgress(p)),\n voice.DelegationResult$.subscribe(r => this.onResult(r)),\n voice.DelegationNarration$.subscribe(n => this.onNarration(n))\n );\n if (voice.ThoughtNarration$) {\n this.subs.push(\n voice.ThoughtNarration$.subscribe(t => this.onThought(t))\n );\n }\n }\n\n /** Unsubscribes from all session streams. Call from the owning shell's ngOnDestroy. */\n public Detach(): void {\n for (const s of this.subs) {\n s.unsubscribe();\n }\n this.subs = [];\n }\n\n /**\n * SESSION REVIEW population path: replaces ALL merged state with a pre-built\n * HISTORICAL thread (caption turns + done delegation cards, oldest first — see\n * `BuildReviewThreadItems`). Resets the live-stream bookkeeping first, so a later\n * live session starts from a clean merge baseline; delegation cards are indexed by\n * CallID so the rail's {@link Cards} list and {@link ActiveCallId} derive normally.\n */\n public LoadHistoricalItems(items: RealtimeThreadItem[]): void {\n this.reset();\n this.Items = items.map(item => {\n if (item.Kind === 'delegation') {\n const card: RealtimeDelegationCardVM = item.Card.Kind\n ? item.Card\n : { ...item.Card, Kind: 'agent' };\n this.cardsByCallId.set(card.CallID, card);\n return { Kind: 'delegation', Card: card };\n }\n return item;\n });\n this.rebuildCards();\n this.recomputeActive();\n this.Changed$.next();\n }\n\n /** Clears all merged state and notifies subscribers (e.g. leaving session review). */\n public Clear(): void {\n this.reset();\n this.Changed$.next();\n }\n\n /**\n * REVIEW→LIVE continuation path: KEEPS the historical thread (and its delegation cards\n * in the rail) and appends a \"Resumed live session\" {@link RealtimeThreadDividerItem},\n * then resets only the LIVE-merge bookkeeping so the new session's captions and cards\n * append cleanly AFTER the divider:\n * - `placedCaptionCount` → 0 (the fresh session's caption stream starts empty, so the\n * start-of-session `[]` emission is a no-op rather than a reset);\n * - the ephemeral narration is dropped (nothing is running yet);\n * - historical cards stay indexed by CallID — new live CallIDs are unique, so live\n * cards insert alongside them and `ActiveCallId` recomputes normally.\n */\n public StartLiveContinuation(at: Date = new Date()): void {\n const divider: RealtimeThreadDividerItem = {\n Kind: 'divider',\n Label: 'Resumed live session',\n At: at,\n Icon: 'fa-solid fa-phone'\n };\n this.Items = [...this.Items, divider];\n this.Narration = null;\n this.placedCaptionCount = 0;\n this.recomputeActive();\n this.Changed$.next();\n }\n\n /** Appends any newly-arrived captions, keeping order relative to delegation cards, and updates streaming captions in place. */\n private onCaptions(captions: RealtimeCaption[]): void {\n if (captions.length < this.placedCaptionCount) {\n // Captions are cleared on a fresh session — reset all merge state.\n this.reset();\n this.Changed$.next();\n return;\n }\n\n // Find the indices in this.Items of the captions already placed in the current session.\n // They are the last `placedCaptionCount` caption items in this.Items.\n const liveCaptionIndices: number[] = [];\n for (let idx = this.Items.length - 1; idx >= 0 && liveCaptionIndices.length < this.placedCaptionCount; idx--) {\n if (this.Items[idx].Kind === 'caption') {\n liveCaptionIndices.unshift(idx);\n }\n }\n\n let nextItems = this.Items;\n let hasChanges = false;\n\n // 1. Update any already-placed captions in place if their text or role changed (e.g. streaming deltas or corrections)\n const updateCount = Math.min(this.placedCaptionCount, liveCaptionIndices.length);\n for (let i = 0; i < updateCount; i++) {\n const itemIdx = liveCaptionIndices[i];\n const current = nextItems[itemIdx] as RealtimeThreadCaptionItem;\n const incoming = captions[i];\n if (current.Role !== incoming.Role || current.Text !== incoming.Text) {\n if (nextItems === this.Items) {\n nextItems = [...this.Items];\n }\n nextItems[itemIdx] = { Kind: 'caption', Role: incoming.Role, Text: incoming.Text };\n hasChanges = true;\n }\n }\n\n // 2. Append newly-arrived captions\n if (captions.length > this.placedCaptionCount) {\n const appended: RealtimeThreadItem[] = [];\n for (let i = this.placedCaptionCount; i < captions.length; i++) {\n appended.push({ Kind: 'caption', Role: captions[i].Role, Text: captions[i].Text });\n }\n if (nextItems === this.Items) {\n nextItems = [...this.Items];\n }\n nextItems = [...nextItems, ...appended];\n this.placedCaptionCount = captions.length;\n hasChanges = true;\n }\n\n if (hasChanges) {\n this.Items = nextItems;\n this.Changed$.next();\n }\n }\n\n /** Inserts a new working card, or immutably replaces the existing one for this CallID. */\n private onProgress(progress: RealtimeDelegationProgress): void {\n const existing = this.cardsByCallId.get(progress.CallID);\n if (existing) {\n this.replaceCard({\n ...existing,\n ToolName: progress.ToolName ?? existing.ToolName,\n LatestStep: progress.Step,\n LatestMessage: progress.Message,\n Percentage: progress.Percentage\n });\n } else {\n this.insertCard(progress);\n }\n this.Changed$.next();\n }\n\n /** Creates a working card for a first-seen CallID and appends it to the thread tail. */\n private insertCard(progress: RealtimeDelegationProgress): void {\n const isAction = !!progress.ToolName && progress.ToolName !== 'invoke-target-agent';\n const card: RealtimeDelegationCardVM = {\n CallID: progress.CallID,\n Kind: isAction ? 'action' : 'agent',\n ToolName: progress.ToolName,\n AgentName: isAction ? FormatToolName(progress.ToolName!) : this.AgentName,\n LatestStep: progress.Step,\n LatestMessage: progress.Message,\n Percentage: progress.Percentage,\n Done: false,\n Success: false,\n RunRef: this.shortRunRef(progress.CallID),\n StartedAt: Date.now()\n };\n this.cardsByCallId.set(progress.CallID, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n }\n\n /** Flips the card for a finished delegation to Done/Failed with its real result. */\n private onResult(result: RealtimeDelegationResult): void {\n const existing = this.cardsByCallId.get(result.CallID);\n if (!existing) {\n if (!result.ToolName) {\n return; // untracked result without tool name — ignore\n }\n // Create-or-update safety net: if a terminal result arrives without prior progress\n // (e.g. fast direct action or missed stream packet), construct and insert the done card\n // rather than dropping the result.\n const isAction = result.ToolName !== 'invoke-target-agent';\n const toolName = result.ToolName;\n const card: RealtimeDelegationCardVM = {\n CallID: result.CallID,\n Kind: isAction ? 'action' : 'agent',\n ToolName: toolName,\n AgentName: isAction ? FormatToolName(toolName) : this.AgentName,\n LatestStep: isAction ? 'direct_action' : 'decision_processing',\n LatestMessage: isAction ? `Executed ${FormatToolName(toolName)}` : 'Completed',\n Done: true,\n Success: result.Success,\n Result: result.Output,\n RunRef: this.shortRunRef(result.CallID),\n RunID: result.RunID,\n Artifacts: isAction ? undefined : result.Artifacts,\n StartedAt: Date.now(),\n FinishedAt: Date.now()\n };\n this.cardsByCallId.set(result.CallID, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n if (!this.HasRunningDelegation) {\n this.Narration = null;\n }\n this.Changed$.next();\n return;\n }\n this.replaceCard({\n ...existing,\n ToolName: result.ToolName ?? existing.ToolName,\n Done: true,\n Success: result.Success,\n Result: result.Output,\n RunID: result.RunID ?? existing.RunID,\n Artifacts: existing.Kind === 'action' ? undefined : (result.Artifacts ?? existing.Artifacts),\n FinishedAt: Date.now()\n });\n if (!this.HasRunningDelegation) {\n // All delegations finished — the live narration note fades away.\n this.Narration = null;\n }\n this.Changed$.next();\n }\n\n /** Latest narration REPLACES the previous one (never accumulated). */\n private onNarration(narration: RealtimeDelegationNarration): void {\n this.Narration = narration.Text;\n this.Changed$.next();\n }\n\n /**\n * Creates or updates a narration delegation card representing model-authored thought / reasoning.\n * Cards are immutable; narration cards are excluded from anchoring the live narration note (Reviewer Items 21 & 22).\n */\n private onThought(thought: RealtimeThoughtNarration): void {\n const callId = thought.CallID ?? 'model-thought';\n const isDone = thought.IsFinal ?? true;\n const existing = this.cardsByCallId.get(callId);\n if (existing) {\n this.replaceCard({\n ...existing,\n LatestMessage: thought.Text,\n Done: isDone,\n Success: true,\n Result: isDone ? thought.Text : existing.Result,\n FinishedAt: isDone ? Date.now() : existing.FinishedAt,\n });\n } else {\n const card: RealtimeDelegationCardVM = {\n CallID: callId,\n Kind: 'narration',\n AgentName: this.AgentName,\n LatestStep: 'reasoning',\n LatestMessage: thought.Text,\n Done: isDone,\n Success: true,\n Result: isDone ? thought.Text : null,\n RunRef: this.shortRunRef(callId),\n StartedAt: Date.now(),\n FinishedAt: isDone ? Date.now() : undefined,\n };\n this.cardsByCallId.set(callId, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n }\n this.Changed$.next();\n }\n\n /**\n * Immutable replacement of a card: new card object, new thread-item wrapper, new\n * Items array, rebuilt Cards array — so every binding sees a fresh reference.\n */\n private replaceCard(card: RealtimeDelegationCardVM): void {\n this.cardsByCallId.set(card.CallID, card);\n const idx = this.Items.findIndex(i => i.Kind === 'delegation' && i.Card.CallID === card.CallID);\n if (idx >= 0) {\n const next = [...this.Items];\n next[idx] = { Kind: 'delegation', Card: card };\n this.Items = next;\n }\n this.rebuildCards();\n this.recomputeActive();\n }\n\n /** Rebuilds the rail's newest-first card list from the (start-ordered) map. */\n private rebuildCards(): void {\n this.Cards = Array.from(this.cardsByCallId.values()).reverse();\n }\n\n /** Recomputes which still-running delegation anchors the live narration note. */\n private recomputeActive(): void {\n const running = this.Cards.find(c => !c.Done && c.Kind !== 'narration');\n this.ActiveCallId = running ? running.CallID : null;\n }\n\n /** Derives a short, stable run reference (e.g. \"#a3f1\") from the call id. */\n private shortRunRef(callId: string): string {\n const compact = callId.replace(/[^a-z0-9]/gi, '');\n return compact.length >= 4 ? `#${compact.slice(-4).toLowerCase()}` : `#${compact.toLowerCase()}`;\n }\n\n /** Clears all merged state (fresh session). */\n private reset(): void {\n this.Items = [];\n this.Cards = [];\n this.Narration = null;\n this.ActiveCallId = null;\n this.placedCaptionCount = 0;\n this.cardsByCallId.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"realtime-session-state.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAgB,MAAM,MAAM,CAAC;AAIzD,OAAO,EAA4B,cAAc,EAAE,MAAM,kCAAkC,CAAC;AA0G5F,yFAAyF;AACzF,kFAAkF;AAElF;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAe;IAC7D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,eAAe,CAAC,CAAC,OAAO,iBAAiB,CAAC;QAC/C,KAAK,kBAAkB,CAAC,CAAC,OAAO,qBAAqB,CAAC;QACtD,KAAK,kBAAkB,CAAC,CAAC,OAAO,iBAAiB,CAAC;QAClD,KAAK,oBAAoB,CAAC,CAAC,OAAO,4BAA4B,CAAC;QAC/D,KAAK,qBAAqB,CAAC,CAAC,OAAO,qBAAqB,CAAC;QACzD,OAAO,CAAC,CAAC,OAAO,OAAO,IAAI,SAAS,CAAC;IACvC,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACpD,IAAI,QAAQ,GAAG,EAAE,EAAE,CAAC;QAClB,OAAO,GAAG,QAAQ,GAAG,CAAC;IACxB,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAC;IACxB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC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ClD,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;IACnG,CAAC;IAED,+CAA+C;IACvC,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { Observable, Subject, Subscription } from 'rxjs';\nimport {\n RealtimeCaption, RealtimeDelegationProgress, RealtimeDelegationResult, RealtimeDelegationNarration, RealtimeThoughtNarration\n} from '@memberjunction/realtime-runtime';\nimport { ParsedDelegationArtifact, FormatToolName } from '@memberjunction/realtime-runtime';\n\n/**\n * The reactive session streams {@link RealtimeSessionState} merges — structurally\n * satisfied by `RealtimeSessionService`. Narrowed to an interface so the state (and its unit\n * tests) depend only on the streams, not on the full service / GraphQL import chain.\n */\nexport interface RealtimeSessionStreams {\n /** Growing user/assistant caption list. */\n Captions$: Observable<RealtimeCaption[]>;\n /** Progress updates from delegated agent runs. */\n DelegationProgress$: Observable<RealtimeDelegationProgress>;\n /** Terminal delegation results. */\n DelegationResult$: Observable<RealtimeDelegationResult>;\n /** Ephemeral spoken progress narrations. */\n DelegationNarration$: Observable<RealtimeDelegationNarration>;\n /** Model-authored thought / reasoning narrations. */\n ThoughtNarration$?: Observable<RealtimeThoughtNarration>;\n}\n\n/**\n * The view-model for one delegated tool/agent call in the live session. Built by\n * {@link RealtimeSessionState} from the `DelegationProgress$` / `DelegationResult$`\n * streams (correlated by `CallID`) and rendered both inline in the session thread\n * and as a compact card in the activity rail.\n *\n * Card objects are treated as IMMUTABLE — every progress/result event REPLACES the\n * card object (and the arrays containing it) so Angular bindings always see fresh\n * references and in-place updates reliably re-render.\n */\nexport interface RealtimeDelegationCardVM {\n /** What this card represents: a delegated agent run, a direct action, or model-authored narration. */\n Kind: 'agent' | 'action' | 'narration';\n /** The `invoke-target-agent` or direct-action call this card represents. */\n CallID: string;\n /** Display name of the delegated agent (e.g. \"Sage\") or formatted direct action title (e.g. \"Get Weather\"). */\n AgentName: string;\n /** The raw tool name when Kind === 'action' (e.g. \"File_Storage_List_Objects\"). */\n ToolName?: string;\n /** Latest human-readable progress message from the stream. */\n LatestMessage: string;\n /** The delegation phase (`prompt_execution` | `action_execution` | `direct_action` | …). */\n LatestStep: string;\n /** Optional completion percentage (0–100) when the server supplies it. */\n Percentage?: number;\n /** `true` once the delegation reached a terminal result. */\n Done: boolean;\n /** Whether the delegated work succeeded (meaningful once {@link Done} is true). */\n Success: boolean;\n /** Short run identifier (e.g. \"#a3f1\") if known; shown in expanded provenance detail. */\n RunRef?: string;\n /**\n * ID of the delegated agent run (`MJ: AI Agent Runs`) once the result reports it.\n * Powers the gear-gated \"Open run\" developer link on the card / rail entry.\n */\n RunID?: string;\n /** The real result text once the delegation completes. */\n Result?: string | null;\n /**\n * Artifacts the delegated run produced (set with the terminal result). Powers the\n * \"View\" affordance on done cards / rail entries and the surface panel's artifact tabs.\n */\n Artifacts?: ParsedDelegationArtifact[];\n /** Epoch ms when the first progress event for this call arrived. */\n StartedAt: number;\n /** Epoch ms when the terminal result arrived. */\n FinishedAt?: number;\n}\n\n/** A caption turn (user or assistant) in the unified thread. */\nexport interface RealtimeThreadCaptionItem {\n Kind: 'caption';\n Role: 'User' | 'Assistant';\n Text: string;\n}\n\n/** A delegation card in the unified thread (working → done chip). */\nexport interface RealtimeThreadDelegationItem {\n Kind: 'delegation';\n Card: RealtimeDelegationCardVM;\n}\n\n/**\n * A SESSION-BOUNDARY divider in the unified thread — a subtle, token-styled rule marking\n * where one session leg ends and another begins. Two producers:\n * - review→live continuation ({@link RealtimeSessionState.StartLiveContinuation}):\n * \"Resumed live session · <time>\" before the new live items;\n * - multi-leg session review (`BuildReviewThreadItems` over a `lastSessionId` chain):\n * \"Session leg · started <time>\" between legs, carrying the PREVIOUS leg's CloseReason\n * as a small chip so the reader sees why that leg ended.\n */\nexport interface RealtimeThreadDividerItem {\n Kind: 'divider';\n /** The divider's label (e.g. \"Resumed live session\", \"Session leg\"). */\n Label: string;\n /** Timestamp rendered after the label (\"· <time>\"), or null when unknown. */\n At: Date | null;\n /** Font Awesome icon class rendered before the label (e.g. `fa-solid fa-phone`). */\n Icon: string;\n /** Why the PRECEDING leg closed (review chains only) — rendered as a small chip. */\n CloseReason?: string | null;\n}\n\n/** One entry in the chronological thread: a caption bubble, a delegation card, or a leg divider. */\nexport type RealtimeThreadItem = RealtimeThreadCaptionItem | RealtimeThreadDelegationItem | RealtimeThreadDividerItem;\n\n// `FormatToolName` now lives in `@memberjunction/realtime-runtime`; import it from there\n// directly rather than through this module (MJ forbids cross-package re-exports).\n\n/**\n * Maps a raw delegation step id to a human-friendly phrase. Unknown steps fall back to\n * the raw progress message (per product direction) so the UI never shows snake_case ids.\n */\nexport function FriendlyStepLabel(step: string, message: string): string {\n switch (step) {\n case 'direct_action': return 'Looking that up';\n case 'prompt_execution': return 'Thinking it through';\n case 'action_execution': return 'Running actions';\n case 'subagent_execution': return 'Working with another agent';\n case 'decision_processing': return 'Deciding next steps';\n default: return message || 'Working';\n }\n}\n\n/** Formats an elapsed duration in ms as a compact human string (\"8s\", \"1m 04s\"). */\nexport function FormatElapsed(ms: number): string {\n const totalSec = Math.max(0, Math.round(ms / 1000));\n if (totalSec < 60) {\n return `${totalSec}s`;\n }\n const m = Math.floor(totalSec / 60);\n const s = totalSec % 60;\n return `${m}m ${s.toString().padStart(2, '0')}s`;\n}\n\n/**\n * SINGLE SOURCE of merged live-session state, owned by the overlay shell\n * (`RealtimeSessionOverlayComponent`) and passed via `@Input()` to BOTH the session\n * thread and the activity rail — so the per-CallID card bookkeeping and subscription\n * logic exists exactly once.\n *\n * Merges FOUR reactive streams from {@link RealtimeSessionService}:\n * - `Captions$` — growing user/assistant caption list → appended to {@link Items}.\n * - `DelegationProgress$` — first event per `CallID` inserts a working card at the thread\n * tail; later events REPLACE the card immutably (new object +\n * new arrays) so change detection always fires.\n * - `DelegationResult$` — flips the card to Done/Failed with the real result text.\n * - `DelegationNarration$` — the EPHEMERAL spoken progress note (latest only, never\n * accumulated), cleared when no delegation is running anymore.\n *\n * Consumers subscribe to {@link Changed$} and `markForCheck()`; all exposed collections\n * are replaced (never mutated) on change.\n */\nexport class RealtimeSessionState {\n /** Display name used for new delegation cards (set by the overlay's AgentName input). */\n public AgentName = 'Assistant';\n\n /** The merged, chronological thread (captions + delegation cards), oldest first. */\n public Items: RealtimeThreadItem[] = [];\n\n /** All delegation cards of the session, NEWEST first — the activity rail's list. */\n public Cards: RealtimeDelegationCardVM[] = [];\n\n /** Latest ephemeral narration text, or null when none should be shown. */\n public Narration: string | null = null;\n\n /** CallID of the most recently started, still-running delegation (anchors the live note). */\n public ActiveCallId: string | null = null;\n\n /** Emits after every state change so views can mark themselves for check. */\n public readonly Changed$ = new Subject<void>();\n\n /** Number of captions already merged into {@link Items} (append-only bookkeeping). */\n private placedCaptionCount = 0;\n /** Live card lookup by CallID (insertion order = start order). */\n private cardsByCallId = new Map<string, RealtimeDelegationCardVM>();\n private subs: Subscription[] = [];\n\n /** True while at least one delegation is still running. */\n public get HasRunningDelegation(): boolean {\n return this.ActiveCallId !== null;\n }\n\n /** Subscribes to the session streams. Call once from the owning overlay shell. */\n public Attach(voice: RealtimeSessionStreams): void {\n if (this.subs.length > 0) {\n return; // already attached\n }\n this.subs.push(\n voice.Captions$.subscribe(c => this.onCaptions(c)),\n voice.DelegationProgress$.subscribe(p => this.onProgress(p)),\n voice.DelegationResult$.subscribe(r => this.onResult(r)),\n voice.DelegationNarration$.subscribe(n => this.onNarration(n))\n );\n if (voice.ThoughtNarration$) {\n this.subs.push(\n voice.ThoughtNarration$.subscribe(t => this.onThought(t))\n );\n }\n }\n\n /** Unsubscribes from all session streams. Call from the owning shell's ngOnDestroy. */\n public Detach(): void {\n for (const s of this.subs) {\n s.unsubscribe();\n }\n this.subs = [];\n }\n\n /**\n * SESSION REVIEW population path: replaces ALL merged state with a pre-built\n * HISTORICAL thread (caption turns + done delegation cards, oldest first — see\n * `BuildReviewThreadItems`). Resets the live-stream bookkeeping first, so a later\n * live session starts from a clean merge baseline; delegation cards are indexed by\n * CallID so the rail's {@link Cards} list and {@link ActiveCallId} derive normally.\n */\n public LoadHistoricalItems(items: RealtimeThreadItem[]): void {\n this.reset();\n this.Items = items.map(item => {\n if (item.Kind === 'delegation') {\n const card: RealtimeDelegationCardVM = item.Card.Kind\n ? item.Card\n : { ...item.Card, Kind: 'agent' };\n this.cardsByCallId.set(card.CallID, card);\n return { Kind: 'delegation', Card: card };\n }\n return item;\n });\n this.rebuildCards();\n this.recomputeActive();\n this.Changed$.next();\n }\n\n /** Clears all merged state and notifies subscribers (e.g. leaving session review). */\n public Clear(): void {\n this.reset();\n this.Changed$.next();\n }\n\n /**\n * REVIEW→LIVE continuation path: KEEPS the historical thread (and its delegation cards\n * in the rail) and appends a \"Resumed live session\" {@link RealtimeThreadDividerItem},\n * then resets only the LIVE-merge bookkeeping so the new session's captions and cards\n * append cleanly AFTER the divider:\n * - `placedCaptionCount` → 0 (the fresh session's caption stream starts empty, so the\n * start-of-session `[]` emission is a no-op rather than a reset);\n * - the ephemeral narration is dropped (nothing is running yet);\n * - historical cards stay indexed by CallID — new live CallIDs are unique, so live\n * cards insert alongside them and `ActiveCallId` recomputes normally.\n */\n public StartLiveContinuation(at: Date = new Date()): void {\n const divider: RealtimeThreadDividerItem = {\n Kind: 'divider',\n Label: 'Resumed live session',\n At: at,\n Icon: 'fa-solid fa-phone'\n };\n this.Items = [...this.Items, divider];\n this.Narration = null;\n this.placedCaptionCount = 0;\n this.recomputeActive();\n this.Changed$.next();\n }\n\n /** Appends any newly-arrived captions, keeping order relative to delegation cards, and updates streaming captions in place. */\n private onCaptions(captions: RealtimeCaption[]): void {\n if (captions.length < this.placedCaptionCount) {\n // Captions are cleared on a fresh session — reset all merge state.\n this.reset();\n this.Changed$.next();\n return;\n }\n\n // Find the indices in this.Items of the captions already placed in the current session.\n // They are the last `placedCaptionCount` caption items in this.Items.\n const liveCaptionIndices: number[] = [];\n for (let idx = this.Items.length - 1; idx >= 0 && liveCaptionIndices.length < this.placedCaptionCount; idx--) {\n if (this.Items[idx].Kind === 'caption') {\n liveCaptionIndices.unshift(idx);\n }\n }\n\n let nextItems = this.Items;\n let hasChanges = false;\n\n // 1. Update any already-placed captions in place if their text or role changed (e.g. streaming deltas or corrections)\n const updateCount = Math.min(this.placedCaptionCount, liveCaptionIndices.length);\n for (let i = 0; i < updateCount; i++) {\n const itemIdx = liveCaptionIndices[i];\n const current = nextItems[itemIdx] as RealtimeThreadCaptionItem;\n const incoming = captions[i];\n if (current.Role !== incoming.Role || current.Text !== incoming.Text) {\n if (nextItems === this.Items) {\n nextItems = [...this.Items];\n }\n nextItems[itemIdx] = { Kind: 'caption', Role: incoming.Role, Text: incoming.Text };\n hasChanges = true;\n }\n }\n\n // 2. Append newly-arrived captions\n if (captions.length > this.placedCaptionCount) {\n const appended: RealtimeThreadItem[] = [];\n for (let i = this.placedCaptionCount; i < captions.length; i++) {\n appended.push({ Kind: 'caption', Role: captions[i].Role, Text: captions[i].Text });\n }\n if (nextItems === this.Items) {\n nextItems = [...this.Items];\n }\n nextItems = [...nextItems, ...appended];\n this.placedCaptionCount = captions.length;\n hasChanges = true;\n }\n\n if (hasChanges) {\n this.Items = nextItems;\n this.Changed$.next();\n }\n }\n\n /** Inserts a new working card, or immutably replaces the existing one for this CallID. */\n private onProgress(progress: RealtimeDelegationProgress): void {\n const existing = this.cardsByCallId.get(progress.CallID);\n if (existing) {\n this.replaceCard({\n ...existing,\n ToolName: progress.ToolName ?? existing.ToolName,\n LatestStep: progress.Step,\n LatestMessage: progress.Message,\n Percentage: progress.Percentage\n });\n } else {\n this.insertCard(progress);\n }\n this.Changed$.next();\n }\n\n /** Creates a working card for a first-seen CallID and appends it to the thread tail. */\n private insertCard(progress: RealtimeDelegationProgress): void {\n const isAction = !!progress.ToolName && progress.ToolName !== 'invoke-target-agent';\n const card: RealtimeDelegationCardVM = {\n CallID: progress.CallID,\n Kind: isAction ? 'action' : 'agent',\n ToolName: progress.ToolName,\n AgentName: isAction ? FormatToolName(progress.ToolName!) : this.AgentName,\n LatestStep: progress.Step,\n LatestMessage: progress.Message,\n Percentage: progress.Percentage,\n Done: false,\n Success: false,\n RunRef: this.shortRunRef(progress.CallID),\n StartedAt: Date.now()\n };\n this.cardsByCallId.set(progress.CallID, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n }\n\n /** Flips the card for a finished delegation to Done/Failed with its real result. */\n private onResult(result: RealtimeDelegationResult): void {\n const existing = this.cardsByCallId.get(result.CallID);\n if (!existing) {\n if (!result.ToolName) {\n return; // untracked result without tool name — ignore\n }\n // Create-or-update safety net: if a terminal result arrives without prior progress\n // (e.g. fast direct action or missed stream packet), construct and insert the done card\n // rather than dropping the result.\n const isAction = result.ToolName !== 'invoke-target-agent';\n const toolName = result.ToolName;\n const card: RealtimeDelegationCardVM = {\n CallID: result.CallID,\n Kind: isAction ? 'action' : 'agent',\n ToolName: toolName,\n AgentName: isAction ? FormatToolName(toolName) : this.AgentName,\n LatestStep: isAction ? 'direct_action' : 'decision_processing',\n LatestMessage: isAction ? `Executed ${FormatToolName(toolName)}` : 'Completed',\n Done: true,\n Success: result.Success,\n Result: result.Output,\n RunRef: this.shortRunRef(result.CallID),\n RunID: result.RunID,\n Artifacts: isAction ? undefined : result.Artifacts,\n StartedAt: Date.now(),\n FinishedAt: Date.now()\n };\n this.cardsByCallId.set(result.CallID, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n if (!this.HasRunningDelegation) {\n this.Narration = null;\n }\n this.Changed$.next();\n return;\n }\n this.replaceCard({\n ...existing,\n ToolName: result.ToolName ?? existing.ToolName,\n Done: true,\n Success: result.Success,\n Result: result.Output,\n RunID: result.RunID ?? existing.RunID,\n Artifacts: existing.Kind === 'action' ? undefined : (result.Artifacts ?? existing.Artifacts),\n FinishedAt: Date.now()\n });\n if (!this.HasRunningDelegation) {\n // All delegations finished — the live narration note fades away.\n this.Narration = null;\n }\n this.Changed$.next();\n }\n\n /** Latest narration REPLACES the previous one (never accumulated). */\n private onNarration(narration: RealtimeDelegationNarration): void {\n this.Narration = narration.Text;\n this.Changed$.next();\n }\n\n /**\n * Creates or updates a narration delegation card representing model-authored thought / reasoning.\n * Cards are immutable; narration cards are excluded from anchoring the live narration note (Reviewer Items 21 & 22).\n */\n private onThought(thought: RealtimeThoughtNarration): void {\n const callId = thought.CallID ?? 'model-thought';\n const isDone = thought.IsFinal ?? true;\n const existing = this.cardsByCallId.get(callId);\n if (existing) {\n this.replaceCard({\n ...existing,\n LatestMessage: thought.Text,\n Done: isDone,\n Success: true,\n Result: isDone ? thought.Text : existing.Result,\n FinishedAt: isDone ? Date.now() : existing.FinishedAt,\n });\n } else {\n const card: RealtimeDelegationCardVM = {\n CallID: callId,\n Kind: 'narration',\n AgentName: this.AgentName,\n LatestStep: 'reasoning',\n LatestMessage: thought.Text,\n Done: isDone,\n Success: true,\n Result: isDone ? thought.Text : null,\n RunRef: this.shortRunRef(callId),\n StartedAt: Date.now(),\n FinishedAt: isDone ? Date.now() : undefined,\n };\n this.cardsByCallId.set(callId, card);\n this.Items = [...this.Items, { Kind: 'delegation', Card: card }];\n this.rebuildCards();\n this.recomputeActive();\n }\n this.Changed$.next();\n }\n\n /**\n * Immutable replacement of a card: new card object, new thread-item wrapper, new\n * Items array, rebuilt Cards array — so every binding sees a fresh reference.\n */\n private replaceCard(card: RealtimeDelegationCardVM): void {\n this.cardsByCallId.set(card.CallID, card);\n const idx = this.Items.findIndex(i => i.Kind === 'delegation' && i.Card.CallID === card.CallID);\n if (idx >= 0) {\n const next = [...this.Items];\n next[idx] = { Kind: 'delegation', Card: card };\n this.Items = next;\n }\n this.rebuildCards();\n this.recomputeActive();\n }\n\n /** Rebuilds the rail's newest-first card list from the (start-ordered) map. */\n private rebuildCards(): void {\n this.Cards = Array.from(this.cardsByCallId.values()).reverse();\n }\n\n /** Recomputes which still-running delegation anchors the live narration note. */\n private recomputeActive(): void {\n const running = this.Cards.find(c => !c.Done && c.Kind !== 'narration');\n this.ActiveCallId = running ? running.CallID : null;\n }\n\n /** Derives a short, stable run reference (e.g. \"#a3f1\") from the call id. */\n private shortRunRef(callId: string): string {\n const compact = callId.replace(/[^a-z0-9]/gi, '');\n return compact.length >= 4 ? `#${compact.slice(-4).toLowerCase()}` : `#${compact.toLowerCase()}`;\n }\n\n /** Clears all merged state (fresh session). */\n private reset(): void {\n this.Items = [];\n this.Cards = [];\n this.Narration = null;\n this.ActiveCallId = null;\n this.placedCaptionCount = 0;\n this.cardsByCallId.clear();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session-thread.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-thread.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACM,YAAY,EAAwC,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAEnG,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;;AAE5E;;;;;;;;;;GAUG;AACH,qBAOa,8BAA+B,YAAW,MAAM,EAAE,gBAAgB,EAAE,SAAS;IAC7D,OAAO,CAAC,YAAY,CAAC,CAA0B;IAE1E,8DAA8D;IACrD,SAAS,SAAU;IAE5B;;;;OAIG;IACM,QAAQ,SAAS;IAE1B,6DAA6D;IAClC,KAAK,EAAG,oBAAoB,CAAC;IAExD,oFAAoF;IAC3E,YAAY,UAAQ;IAE7B,mFAAmF;IAC1E,OAAO,UAAS;IAEzB,gGAAgG;IACvF,iBAAiB,UAAQ;IAElC,wFAAwF;IAC9E,gBAAgB,uBAA8B;IAExD,qGAAqG;IAC3F,qBAAqB,yCAAgD;IAE/E,uFAAuF;IAC7E,eAAe,uBAA8B;IAEvD,2FAA2F;IAC3F,OAAO,CAAC,aAAa,CAAK;IAC1B,uDAAuD;IACvD,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,UAAU,CAAC,CAAe;IAClC,OAAO,CAAC,GAAG,CAAiD;IAE5D,QAAQ,IAAI,IAAI;IAKhB,kBAAkB,IAAI,IAAI;IAO1B,WAAW,IAAI,IAAI;IAInB,+CAA+C;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAQjE,kFAAkF;IAC3E,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO;IAOvD,yEAAyE;IAClE,aAAa,cAAqB;IAEzC;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;IAO3D,2EAA2E;IACpE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIzC,gFAAgF;IACzE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAYzD;;;OAGG;IACI,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAclE,gFAAgF;IAChF,OAAO,CAAC,cAAc;yCA9HX,8BAA8B;2CAA9B,8BAA8B;CAqI1C"}
1
+ {"version":3,"file":"realtime-session-thread.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-thread.component.ts"],"names":[],"mappings":"AA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E,MAAM,GAAG,OAAO;IAIzC,gFAAgF;IACzE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAYzD;;;OAGG;IACI,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAgBlE,gFAAgF;IAChF,OAAO,CAAC,cAAc;yCAhIX,8BAA8B;2CAA9B,8BAA8B;CAuI1C"}
@@ -158,6 +158,89 @@ function RealtimeSessionThreadComponent_ForEmpty_3_Template(rf, ctx) { if (rf &
158
158
  i0.ɵɵtext(1, "The live transcript and any delegated work will appear here.");
159
159
  i0.ɵɵelementEnd();
160
160
  } }
161
+ function isBlank(c) {
162
+ return c === ' ' || c === '\t';
163
+ }
164
+ /** Index just past the spaces and tabs starting at `from`. */
165
+ function skipBlanks(text, from) {
166
+ let i = from;
167
+ while (i < text.length && isBlank(text[i])) {
168
+ i++;
169
+ }
170
+ return i;
171
+ }
172
+ /** Index past an optional `—` and the whitespace after it (the `(?:—\s*)?` of a pattern). */
173
+ function skipEmDash(text, at) {
174
+ if (text[at] !== '—') {
175
+ return at;
176
+ }
177
+ let i = at + 1;
178
+ while (i < text.length && /\s/.test(text[i])) {
179
+ i++;
180
+ }
181
+ return i;
182
+ }
183
+ /**
184
+ * Replace each run of spaces or tabs that `tail` accepts, together with what `tail` matched after it,
185
+ * left to right. This is `.replace(/[ \t]+<tail>/g, …)` for a tail that cannot start with a space or
186
+ * tab, scanned once: the regex retries from every position inside a long run of spaces with no tail
187
+ * after it, which is quadratic (CodeQL js/polynomial-redos). A match can only start where a run
188
+ * starts, since starting later reaches the same run end.
189
+ */
190
+ function replaceAfterBlankRuns(text, tail) {
191
+ let out = '';
192
+ let copied = 0;
193
+ let i = 0;
194
+ while (i < text.length) {
195
+ if (!isBlank(text[i])) {
196
+ i++;
197
+ continue;
198
+ }
199
+ const runStart = i;
200
+ i = skipBlanks(text, i);
201
+ const match = tail(text, i);
202
+ if (match) {
203
+ out += text.slice(copied, runStart) + match.Replacement;
204
+ copied = match.End;
205
+ i = match.End;
206
+ }
207
+ }
208
+ return out + text.slice(copied);
209
+ }
210
+ /** `(?:—\s*)?(#{1,6}[ \t]+)` → a blank line, then the hashes and their spaces. */
211
+ function headingTail(text, at) {
212
+ const start = skipEmDash(text, at);
213
+ let hashEnd = start;
214
+ while (hashEnd < text.length && text[hashEnd] === '#') {
215
+ hashEnd++;
216
+ }
217
+ const hashes = hashEnd - start;
218
+ if (hashes < 1 || hashes > 6 || !isBlank(text[hashEnd] ?? '')) {
219
+ return null;
220
+ }
221
+ const end = skipBlanks(text, hashEnd);
222
+ return { Replacement: '\n\n' + text.slice(start, end), End: end };
223
+ }
224
+ /** `(?:—\s*)?(---|___|\*\*\*)[ \t]*` → the rule on its own paragraph. */
225
+ function ruleTail(text, at) {
226
+ const start = skipEmDash(text, at);
227
+ const rule = ['---', '___', '***'].find((r) => text.startsWith(r, start));
228
+ if (!rule) {
229
+ return null;
230
+ }
231
+ return { Replacement: `\n\n${rule}\n\n`, End: skipBlanks(text, start + rule.length) };
232
+ }
233
+ /** `-[ \t]+(?=[A-Za-z0-9\*])` → a new `- ` list line. */
234
+ function bulletTail(text, at) {
235
+ if (text[at] !== '-') {
236
+ return null;
237
+ }
238
+ const end = skipBlanks(text, at + 1);
239
+ if (end === at + 1 || !/[A-Za-z0-9*]/.test(text[end] ?? '')) {
240
+ return null;
241
+ }
242
+ return { Replacement: '\n- ', End: end };
243
+ }
161
244
  /**
162
245
  * The unified, chronological live thread for the call overlay: caption bubbles
163
246
  * interleaved with delegation cards exactly where they happened.
@@ -172,7 +255,7 @@ function RealtimeSessionThreadComponent_ForEmpty_3_Template(rf, ctx) { if (rf &
172
255
  export class RealtimeSessionThreadComponent {
173
256
  scrollAnchor;
174
257
  /** Display name of the agent (caption avatar / meta line). */
175
- AgentName = 'Sage';
258
+ AgentName = 'Assistant';
176
259
  /**
177
260
  * Display name of the signed-in user for their turns — consistent with the main
178
261
  * chat's sender names, and ready for multi-user sessions where "You" stops meaning
@@ -266,11 +349,13 @@ export class RealtimeSessionThreadComponent {
266
349
  }
267
350
  let cleaned = text;
268
351
  // Restore newlines before markdown headings on same line: "Title ### Heading" -> "Title\n\n### Heading"
269
- cleaned = cleaned.replace(/[ \t]+(?:—\s*)?(#{1,6}[ \t]+)/g, '\n\n$1');
352
+ // Each step scans by index rather than with `/[ \t]+…/g`, which is quadratic on a long run of
353
+ // spaces (CodeQL js/polynomial-redos); see replaceAfterBlankRuns.
354
+ cleaned = replaceAfterBlankRuns(cleaned, headingTail);
270
355
  // Restore newlines around horizontal rules on same line: "Text --- ##" -> "Text\n\n---\n\n##"
271
- cleaned = cleaned.replace(/[ \t]+(?:—\s*)?(---|___|\*\*\*)[ \t]*/g, '\n\n$1\n\n');
356
+ cleaned = replaceAfterBlankRuns(cleaned, ruleTail);
272
357
  // Restore newlines before bullet items on same line: "around: - Item 1 - Item 2" -> "around:\n- Item 1\n- Item 2"
273
- cleaned = cleaned.replace(/[ \t]+-[ \t]+(?=[A-Za-z0-9\*])/g, '\n- ');
358
+ cleaned = replaceAfterBlankRuns(cleaned, bulletTail);
274
359
  return cleaned;
275
360
  }
276
361
  /** Marks for check on every state change; auto-scrolls when the thread grew. */
@@ -323,5 +408,5 @@ export class RealtimeSessionThreadComponent {
323
408
  }], CancelRequested: [{
324
409
  type: Output
325
410
  }] }); })();
326
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(RealtimeSessionThreadComponent, { className: "RealtimeSessionThreadComponent", filePath: "src/lib/components/realtime/realtime-session-thread.component.ts", lineNumber: 30 }); })();
411
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(RealtimeSessionThreadComponent, { className: "RealtimeSessionThreadComponent", filePath: "src/lib/components/realtime/realtime-session-thread.component.ts", lineNumber: 126 }); })();
327
412
  //# sourceMappingURL=realtime-session-thread.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session-thread.component.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-thread.component.ts","../../../../src/lib/components/realtime/realtime-session-thread.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAc,SAAS,EAC7D,iBAAiB,EAAE,MAAM,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;;;;;;ICErE,gCAAwB;IAAA,YAAc;IAAA,iBAAO;;;IAArB,cAAc;IAAd,qCAAc;;;IAEtC,YAAgB;IAAA,gCAAoB;IAAA,4BAAO;IAAA,iBAAO;;;IAAlD,iDAAgB;;;;IASd,AADF,+BAA4B,iBAKkB;IAD1C,kRAAS,wCAA8B,KAAC;IAExC,4BAAM;IAAA,YAAoD;IAAA,iBAAO;IACjE,wBAAoI;IAExI,AADE,iBAAS,EACL;;;;IAJF,cAAyC;;IACnC,eAAoD;IAApD,8EAAoD;IACtC,cAA0C;IAAC,AAA3C,6DAA0C,kDAA8C;;;IArBtH,AADF,8BAA4G,aACjF;IAAA,YAA2E;IAAA,iBAAM;IAExG,AADF,8BAAuB,aACE;IAGnB,AAFF,6HAA4B,2FAEnB;IAGX,iBAAM;IAEJ,AADF,+BAAkK,cAC0B;IACxL,kCAA6I;IAC/I,iBAAM;IACN,8HAA6B;IAcnC,AADE,AADE,iBAAM,EACF,EACF;;;;;;IA5BsD,AAA1C,qDAAyC,6CAAgD;IAChF,eAA2E;IAA3E,4GAA2E;IAGhG,eAIC;IAJD,iDAIC;IAEiB,eAAsE;IAAC,AAAvE,mGAAsE,qFAAuE;IACnI,cAA8E;IAAC,AAA/E,2GAA8E,6FAA+E;IAC1K,cAAsC;IAAoC,AAAnC,AAAvC,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ewChild, AfterViewChecked, OnInit, OnDestroy,\n ChangeDetectorRef, inject\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MarkdownModule } from '@memberjunction/ng-markdown';\nimport { Subscription } from 'rxjs';\nimport { RealtimeSessionState, RealtimeThreadItem } from './realtime-session-state';\nimport { RealtimeDelegationCardComponent } from './realtime-delegation-card.component';\nimport { ParsedDelegationArtifact } from '@memberjunction/realtime-runtime';\n\n/**\n * The unified, chronological live thread for the call overlay: caption bubbles\n * interleaved with delegation cards exactly where they happened.\n *\n * PURELY PRESENTATIONAL over {@link RealtimeSessionState} — the overlay shell owns the\n * state object (which merges the service streams once) and passes it here AND to the\n * activity rail, so there is exactly one copy of the per-CallID merge logic.\n *\n * Also renders the EPHEMERAL narration \"live note\": indented, muted, italic text under\n * the ACTIVE working card (latest narration only — replaced, never accumulated).\n */\n@Component({\n standalone: true,\n selector: 'mj-realtime-session-thread',\n imports: [CommonModule, RealtimeDelegationCardComponent, MarkdownModule],\n templateUrl: './realtime-session-thread.component.html',\n styleUrl: './realtime-session-thread.component.css'\n})\nexport class RealtimeSessionThreadComponent implements OnInit, AfterViewChecked, OnDestroy {\n @ViewChild('scrollAnchor') private scrollAnchor?: ElementRef<HTMLElement>;\n\n /** Display name of the agent (caption avatar / meta line). */\n @Input() AgentName = 'Sage';\n\n /**\n * Display name of the signed-in user for their turns — consistent with the main\n * chat's sender names, and ready for multi-user sessions where \"You\" stops meaning\n * anything. Hosts bind the current user's name; the default keeps old hosts working.\n */\n @Input() UserName = 'You';\n\n /** Shared live-session state, owned by the overlay shell. */\n @Input({ required: true }) State!: RealtimeSessionState;\n\n /** Whether to render caption bubbles (toggled by the controls' captions button). */\n @Input() ShowCaptions = true;\n\n /** Whether developer affordances on delegation cards are revealed (gear-gated). */\n @Input() DevMode = false;\n\n /** Whether inline markdown links in caption bubbles open in a new browser tab. Default true. */\n @Input() OpenLinksInNewTab = true;\n\n /** Re-emitted from a delegation card's dev \"Open run\" link (the delegated run's ID). */\n @Output() OpenRunRequested = new EventEmitter<string>();\n\n /** Re-emitted from a delegation card's \"View\" artifact chip (focuses the artifact's surface tab). */\n @Output() OpenArtifactRequested = new EventEmitter<ParsedDelegationArtifact>();\n\n /** Re-emitted from a WORKING delegation card's ✕ cancel affordance (the call's ID). */\n @Output() CancelRequested = new EventEmitter<string>();\n\n /** Item count at the last change notification, to auto-scroll only when the list grows. */\n private lastItemCount = 0;\n /** Drives auto-scroll: set whenever the list grows. */\n private pendingScroll = false;\n\n private changedSub?: Subscription;\n private cdr = inject(ChangeDetectorRef, { optional: true });\n\n ngOnInit(): void {\n this.changedSub = this.State.Changed$.subscribe(() => this.onStateChanged());\n this.lastItemCount = this.State.Items.length;\n }\n\n ngAfterViewChecked(): void {\n if (this.pendingScroll) {\n this.pendingScroll = false;\n this.scrollAnchor?.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'end' });\n }\n }\n\n ngOnDestroy(): void {\n this.changedSub?.unsubscribe();\n }\n\n /** track fn for the @for over thread items. */\n public TrackItem(index: number, item: RealtimeThreadItem): string {\n switch (item.Kind) {\n case 'delegation': return `d:${item.Card.CallID}`;\n case 'divider': return `s:${index}`;\n default: return `c:${index}`;\n }\n }\n\n /** True when the live narration note should render under THIS delegation item. */\n public ShowsLiveNote(item: RealtimeThreadItem): boolean {\n return item.Kind === 'delegation'\n && !item.Card.Done\n && this.State.Narration !== null\n && item.Card.CallID === this.State.ActiveCallId;\n }\n\n /** Set of item indices whose long text has been expanded by the user. */\n public ExpandedItems = new Set<number>();\n\n /**\n * Returns true when the caption text is considered a \"long blob\" (>280 chars or >4 lines)\n * that warrants height clamping and an expand/collapse toggle.\n */\n public IsLongText(text: string | null | undefined): boolean {\n if (!text) {\n return false;\n }\n return text.length > 280 || text.split('\\n').length > 4;\n }\n\n /** Returns whether the caption item at the specified index is expanded. */\n public IsExpanded(index: number): boolean {\n return this.ExpandedItems.has(index);\n }\n\n /** Toggles expanded/collapsed state for the caption item at the given index. */\n public ToggleExpanded(index: number, event?: Event): void {\n if (event) {\n event.stopPropagation();\n }\n if (this.ExpandedItems.has(index)) {\n this.ExpandedItems.delete(index);\n } else {\n this.ExpandedItems.add(index);\n }\n this.cdr?.markForCheck();\n }\n\n /**\n * Prepares text for markdown rendering, restoring structure (headings, horizontal rules,\n * bullet items) if newlines were stripped by single-line input paste or speech-to-text.\n */\n public FormatMarkdownText(text: string | null | undefined): string {\n if (!text) {\n return '';\n }\n let cleaned = text;\n // Restore newlines before markdown headings on same line: \"Title ### Heading\" -> \"Title\\n\\n### Heading\"\n cleaned = cleaned.replace(/[ \\t]+(?:—\\s*)?(#{1,6}[ \\t]+)/g, '\\n\\n$1');\n // Restore newlines around horizontal rules on same line: \"Text --- ##\" -> \"Text\\n\\n---\\n\\n##\"\n cleaned = cleaned.replace(/[ \\t]+(?:—\\s*)?(---|___|\\*\\*\\*)[ \\t]*/g, '\\n\\n$1\\n\\n');\n // Restore newlines before bullet items on same line: \"around: - Item 1 - Item 2\" -> \"around:\\n- Item 1\\n- Item 2\"\n cleaned = cleaned.replace(/[ \\t]+-[ \\t]+(?=[A-Za-z0-9\\*])/g, '\\n- ');\n return cleaned;\n }\n\n /** Marks for check on every state change; auto-scrolls when the thread grew. */\n private onStateChanged(): void {\n if (this.State.Items.length > this.lastItemCount) {\n this.pendingScroll = true;\n }\n this.lastItemCount = this.State.Items.length;\n this.cdr?.markForCheck();\n }\n}\n","<div class=\"thread\">\n @for (item of State.Items; track TrackItem($index, item)) {\n @switch (item.Kind) {\n @case ('caption') {\n @if (ShowCaptions) {\n <div class=\"turn\" [class.turn--user]=\"item.Role === 'User'\" [class.turn--agent]=\"item.Role === 'Assistant'\">\n <div class=\"turn-avatar\">{{ (item.Role === 'User' ? UserName : AgentName).charAt(0).toUpperCase() }}</div>\n <div class=\"turn-body\">\n <div class=\"turn-meta\">\n @if (item.Role === 'User') {\n <span class=\"typed-tag\">{{ UserName }}</span>\n } @else {\n {{ AgentName }} <span class=\"muted\">· voice</span>\n }\n </div>\n <div class=\"bubble\" [class.bubble--clamped]=\"IsLongText(item.Text) && !IsExpanded($index)\" [class.bubble--expanded]=\"IsLongText(item.Text) && IsExpanded($index)\">\n <div class=\"bubble-content\" [class.bubble-content--clamped]=\"IsLongText(item.Text) && !IsExpanded($index)\" [class.bubble-content--expanded]=\"IsLongText(item.Text) && IsExpanded($index)\">\n <mj-markdown [data]=\"FormatMarkdownText(item.Text)\" [enableCollapsibleHeadings]=\"true\" [OpenLinksInNewTab]=\"OpenLinksInNewTab\"></mj-markdown>\n </div>\n @if (IsLongText(item.Text)) {\n <div class=\"bubble-actions\">\n <button\n type=\"button\"\n class=\"bubble-expand-btn\"\n (click)=\"ToggleExpanded($index, $event)\"\n [attr.aria-expanded]=\"IsExpanded($index)\">\n <span>{{ IsExpanded($index) ? 'Show less' : 'Show more' }}</span>\n <i class=\"fa-solid\" [class.fa-chevron-up]=\"IsExpanded($index)\" [class.fa-chevron-down]=\"!IsExpanded($index)\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n }\n @case ('divider') {\n <!-- Session-leg boundary: subtle rule marking a resume / chained leg -->\n <div class=\"thread-divider\" role=\"separator\">\n <span class=\"thread-divider__line\" aria-hidden=\"true\"></span>\n <span class=\"thread-divider__label\">\n <i [class]=\"item.Icon\" aria-hidden=\"true\"></i>\n {{ item.Label }}\n @if (item.At) {\n <span class=\"thread-divider__time\">· {{ item.At | date:'MMM d, h:mm a' }}</span>\n }\n </span>\n @if (item.CloseReason) {\n <span class=\"thread-divider__chip\" title=\"Why the previous session leg ended\">{{ item.CloseReason }}</span>\n }\n <span class=\"thread-divider__line\" aria-hidden=\"true\"></span>\n </div>\n }\n @case ('delegation') {\n <div class=\"delegation-block\">\n <mj-realtime-delegation-card\n [Card]=\"item.Card\"\n [DevMode]=\"DevMode\"\n (OpenRunRequested)=\"OpenRunRequested.emit($event)\"\n (OpenArtifactRequested)=\"OpenArtifactRequested.emit($event)\"\n (CancelRequested)=\"CancelRequested.emit($event)\">\n </mj-realtime-delegation-card>\n @if (ShowsLiveNote(item)) {\n <!-- Ephemeral narration: latest only, never persisted, fades with completion -->\n <div class=\"live-note\" role=\"status\" aria-live=\"polite\">\n <i class=\"fa-solid fa-comment-dots\" aria-hidden=\"true\"></i>\n {{ State.Narration }}\n </div>\n }\n </div>\n }\n }\n } @empty {\n <div class=\"thread-empty\">The live transcript and any delegated work will appear here.</div>\n }\n <div #scrollAnchor></div>\n</div>\n"]}
1
+ {"version":3,"file":"realtime-session-thread.component.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-session-thread.component.ts","../../../../src/lib/components/realtime/realtime-session-thread.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAc,SAAS,EAC7D,iBAAiB,EAAE,MAAM,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;;;;;;ICErE,gCAAwB;IAAA,YAAc;IAAA,iBAAO;;;IAArB,cAAc;IAAd,qCAAc;;;IAEtC,YAAgB;IAAA,gCAAoB;IAAA,4BAAO;IAAA,iBAAO;;;IAAlD,iDAAgB;;;;IASd,AADF,+BAA4B,iBAKkB;IAD1C,kRAAS,wCAA8B,KAAC;IAExC,4BAAM;IAAA,YAAoD;IAAA,iBAAO;IACjE,wBAAoI;IAExI,AADE,iBAAS,EACL;;;;IAJF,cAAyC;;IACnC,eAAoD;IAApD,8EAAoD;IACtC,cAA0C;IAAC,AAA3C,6DAA0C,kDAA8C;;;IArBtH,AADF,8BAA4G,aACjF;IAAA,YAA2E;IAAA,iBAAM;IAExG,AADF,8BAAuB,aACE;IAGnB,AAFF,6HAA4B,2FAEnB;IAGX,iBAAM;IAEJ,AADF,+BAAk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E;QAClE,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACtD,8FAA8F;QAC9F,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,kHAAkH;QAClH,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,gFAAgF;IACxE,cAAc;QACpB,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;QAC7C,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC;IAC3B,CAAC;wHAtIU,8BAA8B;6DAA9B,8BAA8B;;;;;;YC7H3C,8BAAoB;YAClB,gLAyEC;YACD,+BAAyB;YAC3B,iBAAM;;YA3EJ,cAyEC;YAzED,8BAyEC;4BD+CS,YAAY,EAAE,+BAA+B,EAAE,cAAc;;iFAI5D,8BAA8B;cAP1C,SAAS;6BACI,IAAI,YACN,4BAA4B,WAC7B,CAAC,YAAY,EAAE,+BAA+B,EAAE,cAAc,CAAC;;kBAKvE,SAAS;mBAAC,cAAc;;kBAGxB,KAAK;;kBAOL,KAAK;;kBAGL,KAAK;mBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;kBAGxB,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,MAAM;;kBAGN,MAAM;;kBAGN,MAAM;;kFAhCI,8BAA8B","sourcesContent":["import {\n Component, EventEmitter, Input, Output, ElementRef, ViewChild, AfterViewChecked, OnInit, OnDestroy,\n ChangeDetectorRef, inject\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MarkdownModule } from '@memberjunction/ng-markdown';\nimport { Subscription } from 'rxjs';\nimport { RealtimeSessionState, RealtimeThreadItem } from './realtime-session-state';\nimport { RealtimeDelegationCardComponent } from './realtime-delegation-card.component';\nimport { ParsedDelegationArtifact } from '@memberjunction/realtime-runtime';\n\nfunction isBlank(c: string): boolean {\n return c === ' ' || c === '\\t';\n}\n\n/** Index just past the spaces and tabs starting at `from`. */\nfunction skipBlanks(text: string, from: number): number {\n let i = from;\n while (i < text.length && isBlank(text[i])) {\n i++;\n }\n return i;\n}\n\n/** Index past an optional `—` and the whitespace after it (the `(?:—\\s*)?` of a pattern). */\nfunction skipEmDash(text: string, at: number): number {\n if (text[at] !== '—') {\n return at;\n }\n let i = at + 1;\n while (i < text.length && /\\s/.test(text[i])) {\n i++;\n }\n return i;\n}\n\n/** What a {@link replaceAfterBlankRuns} tail matched: the text to write and where the match ends. */\ninterface BlankRunTail {\n Replacement: string;\n End: number;\n}\n\n/**\n * Replace each run of spaces or tabs that `tail` accepts, together with what `tail` matched after it,\n * left to right. This is `.replace(/[ \\t]+<tail>/g, …)` for a tail that cannot start with a space or\n * tab, scanned once: the regex retries from every position inside a long run of spaces with no tail\n * after it, which is quadratic (CodeQL js/polynomial-redos). A match can only start where a run\n * starts, since starting later reaches the same run end.\n */\nfunction replaceAfterBlankRuns(text: string, tail: (text: string, at: number) => BlankRunTail | null): string {\n let out = '';\n let copied = 0;\n let i = 0;\n while (i < text.length) {\n if (!isBlank(text[i])) {\n i++;\n continue;\n }\n const runStart = i;\n i = skipBlanks(text, i);\n const match = tail(text, i);\n if (match) {\n out += text.slice(copied, runStart) + match.Replacement;\n copied = match.End;\n i = match.End;\n }\n }\n return out + text.slice(copied);\n}\n\n/** `(?:—\\s*)?(#{1,6}[ \\t]+)` → a blank line, then the hashes and their spaces. */\nfunction headingTail(text: string, at: number): BlankRunTail | null {\n const start = skipEmDash(text, at);\n let hashEnd = start;\n while (hashEnd < text.length && text[hashEnd] === '#') {\n hashEnd++;\n }\n const hashes = hashEnd - start;\n if (hashes < 1 || hashes > 6 || !isBlank(text[hashEnd] ?? '')) {\n return null;\n }\n const end = skipBlanks(text, hashEnd);\n return { Replacement: '\\n\\n' + text.slice(start, end), End: end };\n}\n\n/** `(?:—\\s*)?(---|___|\\*\\*\\*)[ \\t]*` → the rule on its own paragraph. */\nfunction ruleTail(text: string, at: number): BlankRunTail | null {\n const start = skipEmDash(text, at);\n const rule = ['---', '___', '***'].find((r) => text.startsWith(r, start));\n if (!rule) {\n return null;\n }\n return { Replacement: `\\n\\n${rule}\\n\\n`, End: skipBlanks(text, start + rule.length) };\n}\n\n/** `-[ \\t]+(?=[A-Za-z0-9\\*])` → a new `- ` list line. */\nfunction bulletTail(text: string, at: number): BlankRunTail | null {\n if (text[at] !== '-') {\n return null;\n }\n const end = skipBlanks(text, at + 1);\n if (end === at + 1 || !/[A-Za-z0-9*]/.test(text[end] ?? '')) {\n return null;\n }\n return { Replacement: '\\n- ', End: end };\n}\n\n/**\n * The unified, chronological live thread for the call overlay: caption bubbles\n * interleaved with delegation cards exactly where they happened.\n *\n * PURELY PRESENTATIONAL over {@link RealtimeSessionState} — the overlay shell owns the\n * state object (which merges the service streams once) and passes it here AND to the\n * activity rail, so there is exactly one copy of the per-CallID merge logic.\n *\n * Also renders the EPHEMERAL narration \"live note\": indented, muted, italic text under\n * the ACTIVE working card (latest narration only — replaced, never accumulated).\n */\n@Component({\n standalone: true,\n selector: 'mj-realtime-session-thread',\n imports: [CommonModule, RealtimeDelegationCardComponent, MarkdownModule],\n templateUrl: './realtime-session-thread.component.html',\n styleUrl: './realtime-session-thread.component.css'\n})\nexport class RealtimeSessionThreadComponent implements OnInit, AfterViewChecked, OnDestroy {\n @ViewChild('scrollAnchor') private scrollAnchor?: ElementRef<HTMLElement>;\n\n /** Display name of the agent (caption avatar / meta line). */\n @Input() AgentName = 'Assistant';\n\n /**\n * Display name of the signed-in user for their turns — consistent with the main\n * chat's sender names, and ready for multi-user sessions where \"You\" stops meaning\n * anything. Hosts bind the current user's name; the default keeps old hosts working.\n */\n @Input() UserName = 'You';\n\n /** Shared live-session state, owned by the overlay shell. */\n @Input({ required: true }) State!: RealtimeSessionState;\n\n /** Whether to render caption bubbles (toggled by the controls' captions button). */\n @Input() ShowCaptions = true;\n\n /** Whether developer affordances on delegation cards are revealed (gear-gated). */\n @Input() DevMode = false;\n\n /** Whether inline markdown links in caption bubbles open in a new browser tab. Default true. */\n @Input() OpenLinksInNewTab = true;\n\n /** Re-emitted from a delegation card's dev \"Open run\" link (the delegated run's ID). */\n @Output() OpenRunRequested = new EventEmitter<string>();\n\n /** Re-emitted from a delegation card's \"View\" artifact chip (focuses the artifact's surface tab). */\n @Output() OpenArtifactRequested = new EventEmitter<ParsedDelegationArtifact>();\n\n /** Re-emitted from a WORKING delegation card's ✕ cancel affordance (the call's ID). */\n @Output() CancelRequested = new EventEmitter<string>();\n\n /** Item count at the last change notification, to auto-scroll only when the list grows. */\n private lastItemCount = 0;\n /** Drives auto-scroll: set whenever the list grows. */\n private pendingScroll = false;\n\n private changedSub?: Subscription;\n private cdr = inject(ChangeDetectorRef, { optional: true });\n\n ngOnInit(): void {\n this.changedSub = this.State.Changed$.subscribe(() => this.onStateChanged());\n this.lastItemCount = this.State.Items.length;\n }\n\n ngAfterViewChecked(): void {\n if (this.pendingScroll) {\n this.pendingScroll = false;\n this.scrollAnchor?.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'end' });\n }\n }\n\n ngOnDestroy(): void {\n this.changedSub?.unsubscribe();\n }\n\n /** track fn for the @for over thread items. */\n public TrackItem(index: number, item: RealtimeThreadItem): string {\n switch (item.Kind) {\n case 'delegation': return `d:${item.Card.CallID}`;\n case 'divider': return `s:${index}`;\n default: return `c:${index}`;\n }\n }\n\n /** True when the live narration note should render under THIS delegation item. */\n public ShowsLiveNote(item: RealtimeThreadItem): boolean {\n return item.Kind === 'delegation'\n && !item.Card.Done\n && this.State.Narration !== null\n && item.Card.CallID === this.State.ActiveCallId;\n }\n\n /** Set of item indices whose long text has been expanded by the user. */\n public ExpandedItems = new Set<number>();\n\n /**\n * Returns true when the caption text is considered a \"long blob\" (>280 chars or >4 lines)\n * that warrants height clamping and an expand/collapse toggle.\n */\n public IsLongText(text: string | null | undefined): boolean {\n if (!text) {\n return false;\n }\n return text.length > 280 || text.split('\\n').length > 4;\n }\n\n /** Returns whether the caption item at the specified index is expanded. */\n public IsExpanded(index: number): boolean {\n return this.ExpandedItems.has(index);\n }\n\n /** Toggles expanded/collapsed state for the caption item at the given index. */\n public ToggleExpanded(index: number, event?: Event): void {\n if (event) {\n event.stopPropagation();\n }\n if (this.ExpandedItems.has(index)) {\n this.ExpandedItems.delete(index);\n } else {\n this.ExpandedItems.add(index);\n }\n this.cdr?.markForCheck();\n }\n\n /**\n * Prepares text for markdown rendering, restoring structure (headings, horizontal rules,\n * bullet items) if newlines were stripped by single-line input paste or speech-to-text.\n */\n public FormatMarkdownText(text: string | null | undefined): string {\n if (!text) {\n return '';\n }\n let cleaned = text;\n // Restore newlines before markdown headings on same line: \"Title ### Heading\" -> \"Title\\n\\n### Heading\"\n // Each step scans by index rather than with `/[ \\t]+…/g`, which is quadratic on a long run of\n // spaces (CodeQL js/polynomial-redos); see replaceAfterBlankRuns.\n cleaned = replaceAfterBlankRuns(cleaned, headingTail);\n // Restore newlines around horizontal rules on same line: \"Text --- ##\" -> \"Text\\n\\n---\\n\\n##\"\n cleaned = replaceAfterBlankRuns(cleaned, ruleTail);\n // Restore newlines before bullet items on same line: \"around: - Item 1 - Item 2\" -> \"around:\\n- Item 1\\n- Item 2\"\n cleaned = replaceAfterBlankRuns(cleaned, bulletTail);\n return cleaned;\n }\n\n /** Marks for check on every state change; auto-scrolls when the thread grew. */\n private onStateChanged(): void {\n if (this.State.Items.length > this.lastItemCount) {\n this.pendingScroll = true;\n }\n this.lastItemCount = this.State.Items.length;\n this.cdr?.markForCheck();\n }\n}\n","<div class=\"thread\">\n @for (item of State.Items; track TrackItem($index, item)) {\n @switch (item.Kind) {\n @case ('caption') {\n @if (ShowCaptions) {\n <div class=\"turn\" [class.turn--user]=\"item.Role === 'User'\" [class.turn--agent]=\"item.Role === 'Assistant'\">\n <div class=\"turn-avatar\">{{ (item.Role === 'User' ? UserName : AgentName).charAt(0).toUpperCase() }}</div>\n <div class=\"turn-body\">\n <div class=\"turn-meta\">\n @if (item.Role === 'User') {\n <span class=\"typed-tag\">{{ UserName }}</span>\n } @else {\n {{ AgentName }} <span class=\"muted\">· voice</span>\n }\n </div>\n <div class=\"bubble\" [class.bubble--clamped]=\"IsLongText(item.Text) && !IsExpanded($index)\" [class.bubble--expanded]=\"IsLongText(item.Text) && IsExpanded($index)\">\n <div class=\"bubble-content\" [class.bubble-content--clamped]=\"IsLongText(item.Text) && !IsExpanded($index)\" [class.bubble-content--expanded]=\"IsLongText(item.Text) && IsExpanded($index)\">\n <mj-markdown [data]=\"FormatMarkdownText(item.Text)\" [enableCollapsibleHeadings]=\"true\" [OpenLinksInNewTab]=\"OpenLinksInNewTab\"></mj-markdown>\n </div>\n @if (IsLongText(item.Text)) {\n <div class=\"bubble-actions\">\n <button\n type=\"button\"\n class=\"bubble-expand-btn\"\n (click)=\"ToggleExpanded($index, $event)\"\n [attr.aria-expanded]=\"IsExpanded($index)\">\n <span>{{ IsExpanded($index) ? 'Show less' : 'Show more' }}</span>\n <i class=\"fa-solid\" [class.fa-chevron-up]=\"IsExpanded($index)\" [class.fa-chevron-down]=\"!IsExpanded($index)\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n }\n @case ('divider') {\n <!-- Session-leg boundary: subtle rule marking a resume / chained leg -->\n <div class=\"thread-divider\" role=\"separator\">\n <span class=\"thread-divider__line\" aria-hidden=\"true\"></span>\n <span class=\"thread-divider__label\">\n <i [class]=\"item.Icon\" aria-hidden=\"true\"></i>\n {{ item.Label }}\n @if (item.At) {\n <span class=\"thread-divider__time\">· {{ item.At | date:'MMM d, h:mm a' }}</span>\n }\n </span>\n @if (item.CloseReason) {\n <span class=\"thread-divider__chip\" title=\"Why the previous session leg ended\">{{ item.CloseReason }}</span>\n }\n <span class=\"thread-divider__line\" aria-hidden=\"true\"></span>\n </div>\n }\n @case ('delegation') {\n <div class=\"delegation-block\">\n <mj-realtime-delegation-card\n [Card]=\"item.Card\"\n [DevMode]=\"DevMode\"\n (OpenRunRequested)=\"OpenRunRequested.emit($event)\"\n (OpenArtifactRequested)=\"OpenArtifactRequested.emit($event)\"\n (CancelRequested)=\"CancelRequested.emit($event)\">\n </mj-realtime-delegation-card>\n @if (ShowsLiveNote(item)) {\n <!-- Ephemeral narration: latest only, never persisted, fades with completion -->\n <div class=\"live-note\" role=\"status\" aria-live=\"polite\">\n <i class=\"fa-solid fa-comment-dots\" aria-hidden=\"true\"></i>\n {{ State.Narration }}\n </div>\n }\n </div>\n }\n }\n } @empty {\n <div class=\"thread-empty\">The live transcript and any delegated work will appear here.</div>\n }\n <div #scrollAnchor></div>\n</div>\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-surface-stage.model.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-stage.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoE,KAAK,kBAAkB,EAAqB,MAAM,0CAA0C,CAAC;AACxK,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,yBAAyB;IACpC,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IACxE,6DAA6D;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,UAAU,CAAuD;IACzE,iDAAiD;IACjD,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ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":"realtime-surface-stage.model.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-stage.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoE,KAAK,kBAAkB,EAAqB,MAAM,0CAA0C,CAAC;AACxK,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,yBAAyB;IACpC,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IACxE,6DAA6D;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,UAAU,CAAuD;IACzE,iDAAiD;IACjD,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,iBAAiB,CAAkE;IAE3F,mHAAmH;IACnH,IAAW,QAAQ,IAAI,SAAS,iBAAiB,EAAE,CAElD;IAED,yGAAyG;IACzG,IAAW,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAEhE;IAED,iHAAiH;IACjH,IAAW,iBAAiB,IAAI,WAAW,CAAC,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC,CAElF;IAED,4EAA4E;IAC5E,IAAW,KAAK,IAAI,SAAS,kBAAkB,EAAE,CAEhD;IAED,4DAA4D;IAC5D,IAAW,QAAQ,IAAI,MAAM,GAAG,IAAI,CAOnC;IAED,wEAAwE;IACjE,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,GAAG,IAAI;IAI/D,4GAA4G;IACrG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,mBAAmB,EAAE;IAI9D;;;OAGG;IACI,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB;IAK1D,iHAAiH;IAC1G,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAMxD,iHAAiH;IAC1G,QAAQ,CAAC,QAAQ,EAAE,SAAS,yBAAyB,EAAE,GAAG,IAAI;IAWrE,iHAAiH;IAC1G,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK7C,+DAA+D;IACxD,SAAS,CAAC,KAAK,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI;IAK5D;;;OAGG;IACI,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO;IASjE,+EAA+E;IACxE,WAAW,IAAI,IAAI;IAK1B,OAAO,CAAC,MAAM;IAcd,mHAAmH;IACnH,OAAO,CAAC,uBAAuB;IAO/B,iHAAiH;IACjH,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,iBAAiB;CAc1B"}
@@ -116,7 +116,8 @@ export class RealtimeSurfaceStageModel {
116
116
  update() {
117
117
  this.resolvePlacements();
118
118
  for (const [key, placement] of this.placements) {
119
- if (placement === 'stage' || placement === 'pip' || (placement === 'tab' && key === this.activeTabKey)) {
119
+ const carriesAgentVideo = this.plugins.get(key)?.ShowsAgentVideo === true;
120
+ if (placement === 'stage' || placement === 'pip' || (placement === 'tab' && (key === this.activeTabKey || carriesAgentVideo))) {
120
121
  this.seen.add(key);
121
122
  }
122
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-surface-stage.model.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-stage.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,wBAAwB,EAA8C,MAAM,0CAA0C,CAAC;AAIxK;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,yBAAyB;IACpC,2EAA2E;IAC1D,OAAO,GAAG,IAAI,GAAG,EAAqC,CAAC;IAC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AC,CAAC;AACvF,CAAC;AAED,SAAS,cAAc,CAAC,CAA2C,EAAE,CAA2C;IAC9G,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,YAAY,CAAC,CAA+B,EAAE,CAA+B;IACpF,OAAO,CACL,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,KAAK,CACL,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACb,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CACzI,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { PlacementOffStage, RecordPlacementMove, ResolveSurfacePlacements, type MediaPlacementMove, type MediaSurface } from '@memberjunction/ai-realtime-client/media';\nimport type { MediaStagePlacement, MediaStageSurface } from '@memberjunction/ng-realtime-media';\nimport type { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';\n\n/**\n * Which channel surfaces the call overlay's stage (`mj-media-stage`) holds, and where each one shows.\n *\n * **Placement.** Every surface starts where its channel's registry row places it (`SurfacePlacement`: its tab, unless the\n * row says otherwise). The user moves it to the stage (it fills the call), into a picture-in-picture box, to its tab, or\n * out of sight, within the placements the row allows; the moves are kept in order, one per surface, and resolved by\n * `ResolveSurfacePlacements`, so the most recent move to the stage wins it, the surface it displaces returns to where its\n * channel places it, and picture-in-picture boxes stack newest first. The host saves {@link Moves} and loads them back\n * ({@link LoadMoves}), so a layout carries over to later sessions.\n *\n * **Creation.** A channel's surface is created the first time it is seen (its tab shows it, or it is on the stage or\n * in a picture-in-picture box) and kept until the channel leaves the session. Moving it, hiding the panel or switching tabs only changes where it\n * shows, so a whiteboard keeps its view and a stream keeps playing.\n *\n * Pure state with no Angular: the overlay reports the session's channels, the channel tab the panel is showing and\n * the user's moves, and binds {@link Surfaces} to the stage.\n */\nexport class RealtimeSurfaceStageModel {\n /** Channels with a surface, by key, in the order their tabs registered. */\n private readonly plugins = new Map<string, BaseRealtimeChannelClient>();\n /** Keys whose surface has been seen, so it stays created. */\n private readonly seen = new Set<string>();\n private moves: MediaPlacementMove[] = [];\n private activeTabKey: string | null = null;\n private placements: ReadonlyMap<string, MediaStagePlacement> = new Map();\n /** Picture-in-picture surfaces, newest first. */\n private pipOrder: readonly string[] = [];\n private surfaces: readonly MediaStageSurface[] = [];\n private allowedPlacements: ReadonlyMap<string, readonly MediaStagePlacement[]> = new Map();\n\n /** The stage's surfaces. The array is replaced only when a surface or a placement changes, so it binds cheaply. */\n public get Surfaces(): readonly MediaStageSurface[] {\n return this.surfaces;\n }\n\n /** Where each registered channel's surface is placed, by key. Replaced only when a placement changes. */\n public get Placements(): ReadonlyMap<string, MediaStagePlacement> {\n return this.placements;\n }\n\n /** Where the user may move each registered channel's surface, by key. Replaced only when the channels change. */\n public get AllowedPlacements(): ReadonlyMap<string, readonly MediaStagePlacement[]> {\n return this.allowedPlacements;\n }\n\n /** The user's moves, oldest first, one per surface: what the host saves. */\n public get Moves(): readonly MediaPlacementMove[] {\n return this.moves;\n }\n\n /** The channel whose surface is on the stage, or `null`. */\n public get StageKey(): string | null {\n for (const [key, placement] of this.placements) {\n if (placement === 'stage') {\n return key;\n }\n }\n return null;\n }\n\n /** The plugin behind a surface, or `null` once its channel has left. */\n public PluginFor(key: string): BaseRealtimeChannelClient | null {\n return this.plugins.get(key) ?? null;\n }\n\n /** Where the user may move a channel's surface; nowhere for a channel without a surface in this session. */\n public AllowedFor(key: string): readonly MediaStagePlacement[] {\n return this.allowedPlacements.get(key) ?? [];\n }\n\n /**\n * Where a channel's surface goes when it leaves the stage (the user leaves the focus layout, or the channel lets go of\n * it): where its channel places it, or the first of picture-in-picture, tab and hidden that it allows.\n */\n public OffStagePlacement(key: string): MediaStagePlacement {\n const plugin = this.plugins.get(key);\n return plugin ? PlacementOffStage(surfaceOf(plugin)) : 'tab';\n }\n\n /** A channel with a surface got its tab. Registering its key again follows the channel's new plugin instance. */\n public Register(plugin: BaseRealtimeChannelClient): void {\n this.plugins.set(plugin.ChannelName, plugin);\n this.updateAllowedPlacements();\n this.update();\n }\n\n /** The session's channels changed: a surface whose plugin is no longer among them is dropped. Moves are kept. */\n public KeepOnly(channels: readonly BaseRealtimeChannelClient[]): void {\n for (const [key, plugin] of [...this.plugins]) {\n if (!channels.includes(plugin)) {\n this.plugins.delete(key);\n this.seen.delete(key);\n }\n }\n this.updateAllowedPlacements();\n this.update();\n }\n\n /** The channel whose tab the panel is showing, or `null` when it shows none (another tab, collapsed, hidden). */\n public SetActiveTab(key: string | null): void {\n this.activeTabKey = key;\n this.update();\n }\n\n /** Starts from saved moves, such as the user's last layout. */\n public LoadMoves(moves: readonly MediaPlacementMove[]): void {\n this.moves = [...moves];\n this.update();\n }\n\n /**\n * Moves a channel's surface. Returns `false`, changing nothing, for a channel without a surface in this session, a\n * placement its channel does not allow, or the placement it already has.\n */\n public Move(key: string, placement: MediaStagePlacement): boolean {\n if (!this.AllowedFor(key).includes(placement) || this.placements.get(key) === placement) {\n return false;\n }\n this.moves = RecordPlacementMove(this.moves, { SurfaceKey: key, Placement: placement });\n this.update();\n return true;\n }\n\n /** Forgets every move: each surface returns to where its channel places it. */\n public ResetLayout(): void {\n this.moves = [];\n this.update();\n }\n\n private update(): void {\n this.resolvePlacements();\n for (const [key, placement] of this.placements) {\n if (placement === 'stage' || placement === 'pip' || (placement === 'tab' && key === this.activeTabKey)) {\n this.seen.add(key);\n }\n }\n const surfaces = [...this.plugins.keys()].filter((key) => this.seen.has(key)).map((key) => this.surfaceFor(key));\n if (!sameSurfaces(surfaces, this.surfaces)) {\n this.surfaces = surfaces;\n }\n }\n\n /** Rebuilds {@link AllowedPlacements} from the registered channels, keeping the map when nothing in it changed. */\n private updateAllowedPlacements(): void {\n const allowed = new Map([...this.plugins].map(([key, plugin]) => [key, plugin.SurfacePlacement.Allowed]));\n if (!sameAllowedPlacements(allowed, this.allowedPlacements)) {\n this.allowedPlacements = allowed;\n }\n }\n\n /** A stage surface for a channel: its placement, its name, and where it stacks when it is picture-in-picture. */\n private surfaceFor(key: string): MediaStageSurface {\n const placement = this.placements.get(key) ?? 'tab';\n const surface: MediaStageSurface = { Key: key, Placement: placement, Label: this.plugins.get(key)?.TabTitle };\n return placement === 'pip' ? { ...surface, PipIndex: this.pipOrder.indexOf(key) } : surface;\n }\n\n private resolvePlacements(): void {\n const resolved = ResolveSurfacePlacements([...this.plugins.values()].map(surfaceOf), this.moves);\n const placements = new Map<string, MediaStagePlacement>();\n if (resolved.Stage) {\n placements.set(resolved.Stage.Key, 'stage');\n }\n resolved.Pips.forEach((surface) => placements.set(surface.Key, 'pip'));\n resolved.Tabs.forEach((surface) => placements.set(surface.Key, 'tab'));\n resolved.Hidden.forEach((surface) => placements.set(surface.Key, 'hidden'));\n if (!samePlacements(placements, this.placements)) {\n this.placements = placements;\n }\n this.pipOrder = resolved.Pips.map((surface) => surface.Key);\n }\n}\n\n/** A channel's surface as the layout model sees it: where its channel places it unless moved, and where it may go. */\nfunction surfaceOf(plugin: BaseRealtimeChannelClient): MediaSurface {\n const { Default, Allowed } = plugin.SurfacePlacement;\n return { Key: plugin.ChannelName, Label: plugin.TabTitle, DefaultPlacement: Default, AllowedPlacements: Allowed };\n}\n\nfunction sameAllowedPlacements(\n a: ReadonlyMap<string, readonly MediaStagePlacement[]>,\n b: ReadonlyMap<string, readonly MediaStagePlacement[]>\n): boolean {\n return a.size === b.size && [...a].every(([key, allowed]) => b.get(key) === allowed);\n}\n\nfunction samePlacements(a: ReadonlyMap<string, MediaStagePlacement>, b: ReadonlyMap<string, MediaStagePlacement>): boolean {\n return a.size === b.size && [...a].every(([key, placement]) => b.get(key) === placement);\n}\n\nfunction sameSurfaces(a: readonly MediaStageSurface[], b: readonly MediaStageSurface[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (surface, i) =>\n surface.Key === b[i].Key && surface.Placement === b[i].Placement && surface.Label === b[i].Label && surface.PipIndex === b[i].PipIndex\n )\n );\n}\n"]}
1
+ {"version":3,"file":"realtime-surface-stage.model.js","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-stage.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,wBAAwB,EAA8C,MAAM,0CAA0C,CAAC;AAIxK;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,yBAAyB;IACpC,2EAA2E;IAC1D,OAAO,GAAG,IAAI,GAAG,EAAqC,CAAC;IACxE,6DAA6D;IAC5C,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,GAAyB,EAAE,CAAC;IACjC,YAAY,GAAkB,IAAI,CAAC;IACnC,UAAU,GAA6C,IAAI,GAAG,EAAE,CAAC;IACzE,iDAAiD;IACzC,QAAQ,GAAsB,EAAE,CAAC;IACjC,QAAQ,GAAiC,EAAE,CAAC;IAC5C,iBAAiB,GAAwD,IAAI,GAAG,EAAE,CAAC;IAE3F,mHAAmH;IACnH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,yGAAyG;IACzG,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,iHAAiH;IACjH,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,4EAA4E;IAC5E,IAAW,KAAK;QACd,OA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E,CAAC,EAAE,EAAE,CACb,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CACzI,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { PlacementOffStage, RecordPlacementMove, ResolveSurfacePlacements, type MediaPlacementMove, type MediaSurface } from '@memberjunction/ai-realtime-client/media';\nimport type { MediaStagePlacement, MediaStageSurface } from '@memberjunction/ng-realtime-media';\nimport type { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';\n\n/**\n * Which channel surfaces the call overlay's stage (`mj-media-stage`) holds, and where each one shows.\n *\n * **Placement.** Every surface starts where its channel's registry row places it (`SurfacePlacement`: its tab, unless the\n * row says otherwise). The user moves it to the stage (it fills the call), into a picture-in-picture box, to its tab, or\n * out of sight, within the placements the row allows; the moves are kept in order, one per surface, and resolved by\n * `ResolveSurfacePlacements`, so the most recent move to the stage wins it, the surface it displaces returns to where its\n * channel places it, and picture-in-picture boxes stack newest first. The host saves {@link Moves} and loads them back\n * ({@link LoadMoves}), so a layout carries over to later sessions.\n *\n * **Creation.** A channel's surface is created the first time it is seen (its tab shows it, or it is on the stage or\n * in a picture-in-picture box) and kept until the channel leaves the session. Moving it, hiding the panel or switching tabs only changes where it\n * shows, so a whiteboard keeps its view and a stream keeps playing.\n *\n * Pure state with no Angular: the overlay reports the session's channels, the channel tab the panel is showing and\n * the user's moves, and binds {@link Surfaces} to the stage.\n */\nexport class RealtimeSurfaceStageModel {\n /** Channels with a surface, by key, in the order their tabs registered. */\n private readonly plugins = new Map<string, BaseRealtimeChannelClient>();\n /** Keys whose surface has been seen, so it stays created. */\n private readonly seen = new Set<string>();\n private moves: MediaPlacementMove[] = [];\n private activeTabKey: string | null = null;\n private placements: ReadonlyMap<string, MediaStagePlacement> = new Map();\n /** Picture-in-picture surfaces, newest first. */\n private pipOrder: readonly string[] = [];\n private surfaces: readonly MediaStageSurface[] = [];\n private allowedPlacements: ReadonlyMap<string, readonly MediaStagePlacement[]> = new Map();\n\n /** The stage's surfaces. The array is replaced only when a surface or a placement changes, so it binds cheaply. */\n public get Surfaces(): readonly MediaStageSurface[] {\n return this.surfaces;\n }\n\n /** Where each registered channel's surface is placed, by key. Replaced only when a placement changes. */\n public get Placements(): ReadonlyMap<string, MediaStagePlacement> {\n return this.placements;\n }\n\n /** Where the user may move each registered channel's surface, by key. Replaced only when the channels change. */\n public get AllowedPlacements(): ReadonlyMap<string, readonly MediaStagePlacement[]> {\n return this.allowedPlacements;\n }\n\n /** The user's moves, oldest first, one per surface: what the host saves. */\n public get Moves(): readonly MediaPlacementMove[] {\n return this.moves;\n }\n\n /** The channel whose surface is on the stage, or `null`. */\n public get StageKey(): string | null {\n for (const [key, placement] of this.placements) {\n if (placement === 'stage') {\n return key;\n }\n }\n return null;\n }\n\n /** The plugin behind a surface, or `null` once its channel has left. */\n public PluginFor(key: string): BaseRealtimeChannelClient | null {\n return this.plugins.get(key) ?? null;\n }\n\n /** Where the user may move a channel's surface; nowhere for a channel without a surface in this session. */\n public AllowedFor(key: string): readonly MediaStagePlacement[] {\n return this.allowedPlacements.get(key) ?? [];\n }\n\n /**\n * Where a channel's surface goes when it leaves the stage (the user leaves the focus layout, or the channel lets go of\n * it): where its channel places it, or the first of picture-in-picture, tab and hidden that it allows.\n */\n public OffStagePlacement(key: string): MediaStagePlacement {\n const plugin = this.plugins.get(key);\n return plugin ? PlacementOffStage(surfaceOf(plugin)) : 'tab';\n }\n\n /** A channel with a surface got its tab. Registering its key again follows the channel's new plugin instance. */\n public Register(plugin: BaseRealtimeChannelClient): void {\n this.plugins.set(plugin.ChannelName, plugin);\n this.updateAllowedPlacements();\n this.update();\n }\n\n /** The session's channels changed: a surface whose plugin is no longer among them is dropped. Moves are kept. */\n public KeepOnly(channels: readonly BaseRealtimeChannelClient[]): void {\n for (const [key, plugin] of [...this.plugins]) {\n if (!channels.includes(plugin)) {\n this.plugins.delete(key);\n this.seen.delete(key);\n }\n }\n this.updateAllowedPlacements();\n this.update();\n }\n\n /** The channel whose tab the panel is showing, or `null` when it shows none (another tab, collapsed, hidden). */\n public SetActiveTab(key: string | null): void {\n this.activeTabKey = key;\n this.update();\n }\n\n /** Starts from saved moves, such as the user's last layout. */\n public LoadMoves(moves: readonly MediaPlacementMove[]): void {\n this.moves = [...moves];\n this.update();\n }\n\n /**\n * Moves a channel's surface. Returns `false`, changing nothing, for a channel without a surface in this session, a\n * placement its channel does not allow, or the placement it already has.\n */\n public Move(key: string, placement: MediaStagePlacement): boolean {\n if (!this.AllowedFor(key).includes(placement) || this.placements.get(key) === placement) {\n return false;\n }\n this.moves = RecordPlacementMove(this.moves, { SurfaceKey: key, Placement: placement });\n this.update();\n return true;\n }\n\n /** Forgets every move: each surface returns to where its channel places it. */\n public ResetLayout(): void {\n this.moves = [];\n this.update();\n }\n\n private update(): void {\n this.resolvePlacements();\n for (const [key, placement] of this.placements) {\n const carriesAgentVideo = this.plugins.get(key)?.ShowsAgentVideo === true;\n if (placement === 'stage' || placement === 'pip' || (placement === 'tab' && (key === this.activeTabKey || carriesAgentVideo))) {\n this.seen.add(key);\n }\n }\n const surfaces = [...this.plugins.keys()].filter((key) => this.seen.has(key)).map((key) => this.surfaceFor(key));\n if (!sameSurfaces(surfaces, this.surfaces)) {\n this.surfaces = surfaces;\n }\n }\n\n /** Rebuilds {@link AllowedPlacements} from the registered channels, keeping the map when nothing in it changed. */\n private updateAllowedPlacements(): void {\n const allowed = new Map([...this.plugins].map(([key, plugin]) => [key, plugin.SurfacePlacement.Allowed]));\n if (!sameAllowedPlacements(allowed, this.allowedPlacements)) {\n this.allowedPlacements = allowed;\n }\n }\n\n /** A stage surface for a channel: its placement, its name, and where it stacks when it is picture-in-picture. */\n private surfaceFor(key: string): MediaStageSurface {\n const placement = this.placements.get(key) ?? 'tab';\n const surface: MediaStageSurface = { Key: key, Placement: placement, Label: this.plugins.get(key)?.TabTitle };\n return placement === 'pip' ? { ...surface, PipIndex: this.pipOrder.indexOf(key) } : surface;\n }\n\n private resolvePlacements(): void {\n const resolved = ResolveSurfacePlacements([...this.plugins.values()].map(surfaceOf), this.moves);\n const placements = new Map<string, MediaStagePlacement>();\n if (resolved.Stage) {\n placements.set(resolved.Stage.Key, 'stage');\n }\n resolved.Pips.forEach((surface) => placements.set(surface.Key, 'pip'));\n resolved.Tabs.forEach((surface) => placements.set(surface.Key, 'tab'));\n resolved.Hidden.forEach((surface) => placements.set(surface.Key, 'hidden'));\n if (!samePlacements(placements, this.placements)) {\n this.placements = placements;\n }\n this.pipOrder = resolved.Pips.map((surface) => surface.Key);\n }\n}\n\n/** A channel's surface as the layout model sees it: where its channel places it unless moved, and where it may go. */\nfunction surfaceOf(plugin: BaseRealtimeChannelClient): MediaSurface {\n const { Default, Allowed } = plugin.SurfacePlacement;\n return { Key: plugin.ChannelName, Label: plugin.TabTitle, DefaultPlacement: Default, AllowedPlacements: Allowed };\n}\n\nfunction sameAllowedPlacements(\n a: ReadonlyMap<string, readonly MediaStagePlacement[]>,\n b: ReadonlyMap<string, readonly MediaStagePlacement[]>\n): boolean {\n return a.size === b.size && [...a].every(([key, allowed]) => b.get(key) === allowed);\n}\n\nfunction samePlacements(a: ReadonlyMap<string, MediaStagePlacement>, b: ReadonlyMap<string, MediaStagePlacement>): boolean {\n return a.size === b.size && [...a].every(([key, placement]) => b.get(key) === placement);\n}\n\nfunction sameSurfaces(a: readonly MediaStageSurface[], b: readonly MediaStageSurface[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (surface, i) =>\n surface.Key === b[i].Key && surface.Placement === b[i].Placement && surface.Label === b[i].Label && surface.PipIndex === b[i].PipIndex\n )\n );\n}\n"]}
@@ -20,11 +20,11 @@ export declare function IsWhiteboardChannel(channelName: string | null | undefin
20
20
  * Whether a channel should get its surface tab registered UP FRONT (at the
21
21
  * registry-resolved emission) rather than waiting for first use.
22
22
  *
23
- * True only for the whiteboard (see {@link IsWhiteboardChannel}) OR a channel the agent has
24
- * already used this session (`hasBeenUsed`). Every other channel stays tab-less until its
25
- * first activity registers it — keeping the strip decluttered to the surfaces actually in play.
23
+ * True only when the channel has ALREADY been used this session (`hasBeenUsed`).
24
+ * Every channel — including the whiteboard — stays tab-less until first activity or
25
+ * prior-state restore registers it, keeping the strip decluttered to surfaces actually in play.
26
26
  */
27
- export declare function ShouldRegisterChannelTabUpFront(channelName: string, hasBeenUsed: boolean): boolean;
27
+ export declare function ShouldRegisterChannelTabUpFront(_channelName: string, hasBeenUsed: boolean): boolean;
28
28
  /**
29
29
  * Whether the Activity tab should be shown yet. Gated on ≥1 underlying agent run having
30
30
  * occurred this session (`agentRunCount`) — the Activity surface is for async delegation,
@@ -67,4 +67,11 @@ export declare function ClampActivitySplitPercent(percent: number): number;
67
67
  export declare function ParseActivitySplitPercent(raw: string | null | undefined): number | null;
68
68
  /** Serializes the right-pane width percentage for persistence (`{ "percent": number }`). */
69
69
  export declare function SerializeActivitySplitPercent(percent: number): string;
70
+ /**
71
+ * Deterministic display rank for left-cluster surface channel tabs so the strip keeps a
72
+ * consistent order (`Workspace`, `Whiteboard`, `Browser`, `Media`, then custom/other channels,
73
+ * then `Recording`) across live calls, session review, and multi-leg resume — regardless of
74
+ * which channel restores or mounts first.
75
+ */
76
+ export declare function ChannelTabSortOrder(channelKey: string | null | undefined): number;
70
77
  //# sourceMappingURL=realtime-surface-tab-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-surface-tab-style.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-tab-style.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEnF;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAElG;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAE1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUzD;AAID,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AAEtE,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAiBvF;AAED,4FAA4F;AAC5F,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErE"}
1
+ {"version":3,"file":"realtime-surface-tab-style.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-surface-tab-style.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEnF;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAEnG;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAE1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUzD;AAID,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AAEtE,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAiBvF;AAED,4FAA4F;AAC5F,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErE;AAUD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAKjF"}