@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-review.service.js","sourceRoot":"","sources":["../../../src/lib/services/realtime-session-review.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAqB,QAAQ,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAA4B,cAAc,EAAE,MAAM,kCAAkC,CAAC;;AAsE5F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,gBAAiF;IAEjF,MAAM,MAAM,GAAG,IAAI,GAAG,EAA6C,CAAC;IACpE,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACnD,IAAI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EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,+EAA+E;IACvE,kBAAkB,CAAC,GAAkB;QAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsB,CAAC;YACpD,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,iGAAiG;IACzF,MAAM,CAAC,KAAuC;QACpD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;sHAjVU,4BAA4B;gEAA5B,4BAA4B,WAA5B,4BAA4B,mBADf,MAAM;;iFACnB,4BAA4B;cADxC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { IMetadataProvider, Metadata, RunView, RunViewParams } from '@memberjunction/core';\nimport type { MJAIAgentSessionEntity } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { RealtimeDelegationCardVM, RealtimeThreadItem } from '../components/realtime/realtime-session-state';\nimport { ParsedDelegationArtifact, FormatToolName } from '@memberjunction/realtime-runtime';\n\n/**\n * Why a reviewed session was closed, as stamped server-side by `SessionManager.CloseSession`\n * (mirrors `MJAIAgentSessionEntity.CloseReason`). `null` means the session is still open OR a\n * legacy row was closed before the column existed.\n */\nexport type RealtimeReviewCloseReason = NonNullable<MJAIAgentSessionEntity['CloseReason']>;\n\n/**\n * One historical caption turn of a reviewed session (a persisted `MJ: Conversation Details` row).\n *\n * Carries BOTH the thread-rendering fields (`Role`/`Text`/`At`) AND the raw fields the time-aligned\n * evidence player reads (`ID`, `Message`, `__mj_CreatedAt`, `UtteranceStartMs`, `UtteranceEndMs`) so\n * a review's turns can be handed straight to {@link RealtimeEvidencePlaybackComponent} for the\n * Recording tab — this shape structurally satisfies that player's `EvidencePlaybackTurn` input.\n */\nexport interface RealtimeSessionReviewTurn {\n /** `MJ: Conversation Details.ID` — the player's `@for` track key. */\n ID: string;\n /** Who spoke the turn. Persisted `AI` rows map to `Assistant`. */\n Role: 'User' | 'Assistant';\n /** The transcript text. */\n Text: string;\n /** The raw transcript text (mirrors {@link Text}) — the player reads `Message`. */\n Message: string | null;\n /** When the turn was persisted (`__mj_CreatedAt`), or null when unknown. Aliases {@link At}. */\n __mj_CreatedAt: Date | null;\n /** When the turn was persisted (`__mj_CreatedAt`), or null when unknown. */\n At: Date | null;\n /** Precise media-relative start (ms from recording t0), or null when the driver supplied no timing. */\n UtteranceStartMs: number | null;\n /** Precise media-relative end (ms from recording t0), or null. */\n UtteranceEndMs: number | null;\n}\n\n/**\n * A compact preview of one DELEGATED agent run the reviewed session spawned (an\n * `MJ: AI Agent Runs` row linked via `AgentSessionID`, EXCLUDING the co-agent's own\n * observability run). Carries just enough to render a done delegation card.\n */\nexport interface RealtimeSessionReviewRun {\n /** `MJ: AI Agent Runs.ID`. */\n RunID: string;\n /** The delegated agent's id. */\n AgentID: string;\n /** Denormalized agent display name from the run view, when available. */\n AgentName: string | null;\n /** Terminal (or last-known) run status (`Completed` | `Failed` | `Running` | …). */\n Status: string;\n /** Whether the run reported success. */\n Success: boolean;\n /** The run's user-facing result message, when one was recorded. */\n Message: string | null;\n /** The run's error message, when it failed. */\n ErrorMessage: string | null;\n /** The final step the run reported (`Success` | `Failed` | `Retry` | …), when known. */\n FinalStep: string | null;\n StartedAt: Date | null;\n CompletedAt: Date | null;\n}\n\n/** The persisted state of one interactive channel of the reviewed session. */\nexport interface RealtimeSessionReviewChannelState {\n /** Channel display name (e.g. `Whiteboard`), denormalized on the session-channel row. */\n ChannelName: string;\n /** The channel's serialized state of record (`AIAgentSessionChannel.Config`), or null when none was saved. */\n StateJson: string | null;\n}\n\n/**\n * MULTI-LEG channel-state merge: folds every leg's channel rows into one state set,\n * NEWEST leg wins per channel name — but only a leg that actually SAVED state counts.\n * A resumed session whose final leg never touched the whiteboard therefore still\n * reviews with the board an EARLIER leg drew (previously only the primary/newest leg's\n * rows were consulted, so that board silently vanished from review).\n *\n * @param legChannelStates Per-leg channel states, ordered OLDEST → NEWEST (the chain order).\n * @returns One entry per channel name (case-insensitive), each from the newest leg that\n * saved a non-empty state; channels no leg ever saved keep a null-state entry so the\n * review still knows the channel existed.\n */\nexport function MergeChainChannelStates(\n legChannelStates: ReadonlyArray<ReadonlyArray<RealtimeSessionReviewChannelState>>\n): RealtimeSessionReviewChannelState[] {\n const byName = new Map<string, RealtimeSessionReviewChannelState>();\n for (const leg of legChannelStates) {\n for (const state of leg) {\n const key = state.ChannelName.trim().toLowerCase();\n if (key.length === 0) {\n continue;\n }\n const existing = byName.get(key);\n const hasState = typeof state.StateJson === 'string' && state.StateJson.trim().length > 0;\n // Later legs are newer: a saved state always supersedes; a null/empty state only\n // registers the channel's existence and never clobbers an earlier saved board.\n if (!existing || hasState) {\n byName.set(key, hasState ? state : (existing ?? state));\n }\n }\n }\n return [...byName.values()];\n}\n\n/**\n * A direct action or channel tool execution performed during the reviewed session\n * (stored as a hidden `MJ: Conversation Details` turn with `type: 'realtime_tool_execution'`).\n */\nexport interface RealtimeSessionReviewAction {\n /** `MJ: Conversation Details.ID`. */\n ID: string;\n /** Correlated tool call id (`MJ: Conversation Details.ExternalID`), falling back to ID. */\n CallID: string;\n /** The tool/action name (e.g. `File_Storage_List_Objects` or `Whiteboard_draw_shape`). */\n ToolName: string;\n /** Serialized argument payload, when recorded. */\n ArgsJson: string | null;\n /** Serialized result payload, when recorded. */\n ResultJson: string | null;\n /** Whether the execution reported success. */\n Success: boolean;\n /** Execution duration in ms (`MJ: Conversation Details.CompletionTime`). */\n DurationMs: number;\n /** When the tool execution was recorded (`MJ: Conversation Details.__mj_CreatedAt`). */\n At: Date | null;\n}\n\n/**\n * One LEG of a reviewed session chain: a single `MJ: AI Agent Sessions` row plus its own\n * caption turns and delegated-run previews. A session resumed via `lastSessionId` chains\n * legs together (newest leg's `LastSessionID` → prior leg); the review loader walks that\n * chain BACKWARDS (capped — see the loader docs) so review mode can render the FULL\n * conversation arc chronologically, with a divider between legs.\n */\nexport interface RealtimeSessionReviewLeg {\n /** `MJ: AI Agent Sessions.ID` of this leg. */\n SessionID: string;\n /** When this leg started (`__mj_CreatedAt`). */\n StartedAt: Date | null;\n /** When this leg closed (null while still open). */\n ClosedAt: Date | null;\n /** Why this leg closed (null while open / legacy rows). */\n CloseReason: RealtimeReviewCloseReason | null;\n /** This leg's chronological caption turns (oldest first). */\n Turns: RealtimeSessionReviewTurn[];\n /** This leg's delegated-run previews (oldest first, minus its co-agent observability run). */\n DelegatedRuns: RealtimeSessionReviewRun[];\n /** This leg's direct action and channel tool executions. */\n DirectActions?: RealtimeSessionReviewAction[];\n}\n\n/**\n * Everything the call overlay's SESSION REVIEW mode renders for one past realtime session:\n * the session identity/lifecycle row, the chronological caption turns, previews of the\n * delegated runs, and the saved per-channel states (e.g. the whiteboard board).\n */\nexport interface RealtimeSessionReview {\n /** `MJ: AI Agent Sessions.ID` of the reviewed session. */\n SessionID: string;\n /** The session's fronting agent id (`AIAgentSession.AgentID` — usually the Realtime Co-Agent). */\n AgentID: string;\n /** Display name shown in the review banner (target agent when resolvable, else the session agent). */\n AgentName: string;\n /**\n * The agent a RESUMED live session should front: the session Config's `targetAgentID`,\n * falling back to the session's own `AgentID` when the config doesn't carry one.\n */\n TargetAgentID: string;\n /** Conversation the session was bound to, when any. */\n ConversationID: string | null;\n Status: 'Active' | 'Closed' | 'Idle';\n CloseReason: RealtimeReviewCloseReason | null;\n /** When the session started (`__mj_CreatedAt`). */\n StartedAt: Date | null;\n LastActiveAt: Date | null;\n ClosedAt: Date | null;\n /**\n * The `MJ: Files` id of the reviewed session's recorded audio, or null when nothing was recorded.\n * When set, review mode resolves a signed download URL and shows a Recording tab with the\n * time-aligned evidence player. From the PRIMARY (reviewed) leg only.\n */\n RecordingFileID: string | null;\n /** Recording alignment origin (t0), used by the playback transcript sync. From the primary leg. */\n RecordingStartedAt: Date | null;\n /** What was captured (`Audio` / `AudioVideo`), or null. From the primary leg. */\n RecordingMedia: string | null;\n /** Chronological caption turns (oldest first) — ALL legs of the chain, flattened. */\n Turns: RealtimeSessionReviewTurn[];\n /** Delegated run previews (oldest first, all legs), minus each leg's co-agent observability run. */\n DelegatedRuns: RealtimeSessionReviewRun[];\n /** Direct action and channel tool executions (oldest first, all legs). */\n DirectActions?: RealtimeSessionReviewAction[];\n /**\n * Saved channel states, one per session-channel row that carried a name. Channel state\n * (e.g. the whiteboard board) is the LATEST leg's only — earlier legs' states were\n * superseded when the chain resumed.\n */\n ChannelStates: RealtimeSessionReviewChannelState[];\n /**\n * The session-chain LEGS, chronological (oldest first; the LAST leg is the reviewed\n * session itself). Single-session reviews carry exactly one leg. Drives the per-leg\n * dividers `BuildReviewThreadItems` renders.\n */\n Legs: RealtimeSessionReviewLeg[];\n /**\n * ARTIFACTS attached to the chain's conversation history: every `MJ: Conversation\n * Detail Artifacts` junction (Direction `Output`) hanging off the chain's\n * session-stamped `Conversation Details`, resolved to `{ArtifactID, ArtifactVersionID,\n * Name}`. Review mode registers each as an (unfocused) artifact tab on the surface\n * panel, and they carry into a resumed live session. Empty when none / on any\n * tolerated load failure.\n */\n Artifacts: ParsedDelegationArtifact[];\n}\n\n// ── Raw row shapes (ResultType: 'simple', narrowed Fields) ──────────────────\n\ninterface SessionRow {\n ID: string;\n AgentID: string;\n Agent: string | null;\n Status: 'Active' | 'Closed' | 'Idle';\n ConversationID: string | null;\n Config: string | null;\n LastSessionID: string | null;\n LastActiveAt: string | null;\n ClosedAt: string | null;\n CloseReason: RealtimeReviewCloseReason | null;\n RecordingFileID: string | null;\n RecordingStartedAt: string | null;\n RecordingMedia: string | null;\n __mj_CreatedAt: string | null;\n}\n\ninterface DetailRow {\n ID: string;\n Role: 'AI' | 'Error' | 'User';\n Message: string | null;\n HiddenToUser: boolean;\n UserID: string | null;\n Status: string | null;\n ExternalID?: string | null;\n CompletionTime?: number | null;\n UtteranceStartMs: number | null;\n UtteranceEndMs: number | null;\n __mj_CreatedAt: string | null;\n}\n\ninterface RunRow {\n ID: string;\n AgentID: string;\n Agent: string | null;\n Status: string;\n Success: boolean | null;\n Message: string | null;\n ErrorMessage: string | null;\n FinalStep: string | null;\n StartedAt: string | null;\n CompletedAt: string | null;\n}\n\ninterface ChannelRow {\n ID: string;\n Channel: string | null;\n Config: string | null;\n}\n\ninterface DetailArtifactJunctionRow {\n ID: string;\n ConversationDetailID: string;\n ArtifactVersionID: string | null;\n}\n\ninterface ArtifactVersionRow {\n ID: string;\n ArtifactID: string;\n /** Version display name (nullable on the row). */\n Name: string | null;\n /** Denormalized parent-artifact name from the version view. */\n Artifact: string | null;\n}\n\n/** The raw rows of ONE chain leg, before mapping to the public review shapes. */\ninterface LegRows {\n session: SessionRow;\n details: DetailRow[];\n runs: RunRow[];\n channels: ChannelRow[];\n}\n\n/** The Config-JSON keys the realtime voice stack persists on `AIAgentSession.Config`. */\ninterface SessionConfigJson {\n targetAgentID?: string;\n coAgentRunID?: string;\n}\n\nconst SESSION_FIELDS = ['ID', 'AgentID', 'Agent', 'Status', 'ConversationID', 'Config', 'LastSessionID', 'LastActiveAt', 'ClosedAt', 'CloseReason', 'RecordingFileID', 'RecordingStartedAt', 'RecordingMedia', '__mj_CreatedAt'];\nconst DETAIL_FIELDS = ['ID', 'Role', 'Message', 'HiddenToUser', 'UserID', 'Status', 'ExternalID', 'CompletionTime', 'UtteranceStartMs', 'UtteranceEndMs', '__mj_CreatedAt'];\nconst RUN_FIELDS = ['ID', 'AgentID', 'Agent', 'Status', 'Success', 'Message', 'ErrorMessage', 'FinalStep', 'StartedAt', 'CompletedAt'];\nconst CHANNEL_FIELDS = ['ID', 'Channel', 'Config'];\nconst JUNCTION_FIELDS = ['ID', 'ConversationDetailID', 'ArtifactVersionID'];\nconst VERSION_FIELDS = ['ID', 'ArtifactID', 'Name', 'Artifact'];\n\n/** Maximum number of chain legs the review loader walks (the reviewed session included). */\nexport const MAX_REVIEW_LEGS = 5;\n/** Maximum total caption-detail rows loaded across the whole chain (oldest legs trimmed first). */\nexport const MAX_REVIEW_DETAILS = 500;\n\n// ── Review → thread-item mapping (pure, unit-testable) ──────────────────────\n\n/** Maps one delegated-run preview to the done delegation-card VM the thread/rail render. */\nexport function BuildReviewDelegationCard(run: RealtimeSessionReviewRun, fallbackAgentName: string): RealtimeDelegationCardVM {\n const startedAt = run.StartedAt?.getTime() ?? 0;\n return {\n Kind: 'agent',\n CallID: run.RunID,\n AgentName: run.AgentName || fallbackAgentName,\n LatestMessage: run.Message ?? run.ErrorMessage ?? run.Status,\n LatestStep: run.FinalStep ?? '',\n Done: true,\n Success: run.Success,\n RunRef: shortRunRef(run.RunID),\n RunID: run.RunID,\n Result: run.Message ?? run.ErrorMessage ?? null,\n StartedAt: startedAt,\n FinishedAt: run.CompletedAt?.getTime() ?? startedAt\n };\n}\n\n/** Maps one direct-action execution to the done action-card VM the thread/rail render. */\nexport function BuildReviewActionCard(action: RealtimeSessionReviewAction): RealtimeDelegationCardVM {\n const at = action.At?.getTime() ?? 0;\n const toolTitle = FormatToolName(action.ToolName);\n return {\n Kind: 'action',\n CallID: action.CallID,\n ToolName: action.ToolName,\n AgentName: toolTitle,\n LatestMessage: `Executed ${toolTitle}`,\n LatestStep: 'direct_action',\n Done: true,\n Success: action.Success,\n RunRef: shortRunRef(action.CallID),\n Result: action.ResultJson,\n StartedAt: at,\n FinishedAt: at + action.DurationMs\n };\n}\n\n/**\n * Builds the chronological thread (caption turns + done delegation cards + done action cards, oldest first)\n * for a reviewed session — the items `RealtimeSessionState.LoadHistoricalItems` takes.\n *\n * CHAIN-AWARE: when the review carries multiple {@link RealtimeSessionReview.Legs}, each\n * leg's items render in leg order with a `divider` item between legs (\"Session leg\n * started · <time>\", carrying the PREVIOUS leg's CloseReason as a chip). A single-leg\n * review (or a legless legacy shape) renders the flat thread with no divider —\n * byte-identical to the pre-chain behavior.\n */\nexport function BuildReviewThreadItems(review: RealtimeSessionReview): RealtimeThreadItem[] {\n const legs = review.Legs ?? [];\n if (legs.length <= 1) {\n const only = legs[0];\n return buildLegThreadItems(\n only?.Turns ?? review.Turns,\n only?.DelegatedRuns ?? review.DelegatedRuns,\n only?.DirectActions ?? review.DirectActions ?? [],\n review.AgentName\n );\n }\n const items: RealtimeThreadItem[] = [];\n legs.forEach((leg, i) => {\n if (i > 0) {\n items.push({\n Kind: 'divider',\n Label: 'Session leg started',\n At: leg.StartedAt,\n Icon: 'fa-solid fa-arrows-rotate',\n CloseReason: legs[i - 1].CloseReason ?? null\n });\n }\n items.push(...buildLegThreadItems(leg.Turns, leg.DelegatedRuns, leg.DirectActions ?? [], review.AgentName));\n });\n return items;\n}\n\n/**\n * Builds ONE leg's chronological items (caption turns + done delegation cards + done action cards,\n * oldest first). Entries without a timestamp sort to the front, preserving their relative order.\n */\nfunction buildLegThreadItems(\n turns: RealtimeSessionReviewTurn[],\n runs: RealtimeSessionReviewRun[],\n actions: RealtimeSessionReviewAction[],\n fallbackAgentName: string\n): RealtimeThreadItem[] {\n const stamped: Array<{ At: number; Item: RealtimeThreadItem }> = [];\n for (const turn of turns) {\n stamped.push({ At: turn.At?.getTime() ?? 0, Item: { Kind: 'caption', Role: turn.Role, Text: turn.Text } });\n }\n for (const run of runs) {\n stamped.push({ At: run.StartedAt?.getTime() ?? 0, Item: { Kind: 'delegation', Card: BuildReviewDelegationCard(run, fallbackAgentName) } });\n }\n for (const action of actions) {\n stamped.push({ At: action.At?.getTime() ?? 0, Item: { Kind: 'delegation', Card: BuildReviewActionCard(action) } });\n }\n // Array.prototype.sort is stable — equal timestamps keep their build order.\n stamped.sort((a, b) => a.At - b.At);\n return stamped.map(s => s.Item);\n}\n\n/** Derives a short run reference (e.g. \"#a3f1\") from the run id — mirrors the live cards. */\nfunction shortRunRef(runId: string): string {\n const compact = runId.replace(/[^a-z0-9]/gi, '');\n return compact.length >= 4 ? `#${compact.slice(-4).toLowerCase()}` : `#${compact.toLowerCase()}`;\n}\n\n/**\n * STATELESS loader for the call overlay's SESSION REVIEW mode: given a past\n * `MJ: AI Agent Sessions` id, batch-loads the session row, its persisted caption turns\n * (`MJ: Conversation Details` linked by `AgentSessionID`), its delegated agent runs\n * (minus the co-agent observability run named in the session Config's `coAgentRunID`),\n * and its saved channel states — and folds them into one {@link RealtimeSessionReview}.\n *\n * CHAIN-AWARE: when the reviewed session carries a `LastSessionID` (it RESUMED an earlier\n * session), the loader walks the chain BACKWARDS — capped at {@link MAX_REVIEW_LEGS} legs\n * and {@link MAX_REVIEW_DETAILS} caption rows total (oldest legs trimmed first), with a\n * cycle guard so a corrupt A→B→A chain can never loop — and surfaces ALL legs\n * chronologically on {@link RealtimeSessionReview.Legs}. Channel state stays the\n * reviewed (latest) leg's only. The chain's conversation-history ARTIFACTS (junction\n * rows on the session-stamped details) are collected onto\n * {@link RealtimeSessionReview.Artifacts}.\n *\n * TOLERANT by design: any missing piece degrades to an empty collection; the loader\n * returns `null` only when the reviewed session row itself can't be found.\n */\n@Injectable({ providedIn: 'root' })\nexport class RealtimeSessionReviewService {\n /**\n * Loads everything review mode renders for one past session (and its prior-leg chain).\n *\n * @param agentSessionId The `MJ: AI Agent Sessions.ID` to review.\n * @param provider Optional metadata provider (multi-server apps); falls back to the global default.\n * @returns The assembled review, or `null` when the session doesn't exist / can't be read.\n */\n public async LoadSessionReview(agentSessionId: string, provider?: IMetadataProvider): Promise<RealtimeSessionReview | null> {\n const trimmed = agentSessionId?.trim() ?? '';\n if (trimmed.length === 0) {\n return null;\n }\n try {\n const md = provider ?? Metadata.Provider;\n const primary = await this.loadLegRows(trimmed, md, true);\n if (!primary) {\n return null;\n }\n const chain = await this.collectChainLegs(primary, md);\n const artifacts = await this.loadChainArtifacts(chain, md);\n return this.assembleReview(chain, artifacts);\n } catch (error) {\n console.error('[RealtimeSessionReview] Failed to load session review:', error);\n return null;\n }\n }\n\n /**\n * One batched RunViews pass for one chain leg: session row + caption turns + linked\n * runs (+ channel rows for the PRIMARY leg only — channel state is latest-leg-only).\n * Returns `null` when the session row can't be found.\n */\n private async loadLegRows(\n agentSessionId: string,\n provider: IMetadataProvider,\n includeChannels: boolean\n ): Promise<LegRows | null> {\n const safeID = agentSessionId.replace(/'/g, \"''\");\n const rv = RunView.FromMetadataProvider(provider);\n const queries: RunViewParams[] = [\n { EntityName: 'MJ: AI Agent Sessions', ExtraFilter: `ID='${safeID}'`, Fields: SESSION_FIELDS, ResultType: 'simple' as const },\n {\n EntityName: 'MJ: Conversation Details', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: DETAIL_FIELDS,\n OrderBy: '__mj_CreatedAt ASC', MaxRows: MAX_REVIEW_DETAILS, ResultType: 'simple' as const\n },\n { EntityName: 'MJ: AI Agent Runs', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: RUN_FIELDS, OrderBy: 'StartedAt ASC', ResultType: 'simple' as const }\n ];\n if (includeChannels) {\n queries.push({ EntityName: 'MJ: AI Agent Session Channels', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: CHANNEL_FIELDS, ResultType: 'simple' as const });\n }\n const [sessionResult, detailResult, runResult, channelResult] = await rv.RunViews(queries);\n const sessions = (sessionResult?.Success ? sessionResult.Results : []) as SessionRow[];\n const session = sessions[0] ?? null;\n if (!session) {\n return null;\n }\n return {\n session,\n details: (detailResult?.Success ? detailResult.Results : []) as DetailRow[],\n runs: (runResult?.Success ? runResult.Results : []) as RunRow[],\n channels: (channelResult?.Success ? channelResult.Results : []) as ChannelRow[]\n };\n }\n\n /**\n * Walks the `LastSessionID` chain BACKWARDS from the reviewed (primary) leg, collecting\n * raw leg rows OLDEST-FIRST (primary last). Safety rails:\n * - at most {@link MAX_REVIEW_LEGS} legs total;\n * - at most {@link MAX_REVIEW_DETAILS} caption rows across the chain — an older leg\n * whose details would overflow the budget is trimmed to its NEWEST rows and ends\n * the walk;\n * - a visited-set cycle guard (case-insensitive ids) so A→B→A can never loop;\n * - a leg that fails to load simply ends the walk (the collected legs still render).\n */\n private async collectChainLegs(primary: LegRows, provider: IMetadataProvider): Promise<LegRows[]> {\n const chain: LegRows[] = [primary];\n const visited = new Set<string>([this.normalizeID(primary.session.ID)]);\n let cursor = primary.session.LastSessionID ?? null;\n let detailBudget = MAX_REVIEW_DETAILS - primary.details.length;\n\n while (cursor && chain.length < MAX_REVIEW_LEGS && detailBudget > 0) {\n const key = this.normalizeID(cursor);\n if (visited.has(key)) {\n console.warn(`[RealtimeSessionReview] Session chain cycle detected at ${cursor} — stopping the walk.`);\n break;\n }\n visited.add(key);\n const leg = await this.loadLegRows(cursor, provider, false);\n if (!leg) {\n break;\n }\n if (leg.details.length > detailBudget) {\n // Keep this leg's NEWEST rows (details arrive oldest-first) and end the walk.\n leg.details = leg.details.slice(leg.details.length - detailBudget);\n detailBudget = 0;\n } else {\n detailBudget -= leg.details.length;\n }\n chain.unshift(leg);\n cursor = leg.session.LastSessionID ?? null;\n }\n return chain;\n }\n\n /**\n * Collects the chain's conversation-history ARTIFACTS: `MJ: Conversation Detail\n * Artifacts` junction rows (Direction `Output`) hanging off the chain's session-stamped\n * details, resolved through `MJ: Artifact Versions` to `{ArtifactID, ArtifactVersionID,\n * Name}` (version name, falling back to the artifact name). Order follows junction\n * creation; duplicate versions are deduped. TOLERANT: any failure returns `[]`.\n */\n private async loadChainArtifacts(chain: LegRows[], provider: IMetadataProvider): Promise<ParsedDelegationArtifact[]> {\n const detailIDs = chain.flatMap(leg => leg.details.map(d => d.ID)).filter(id => typeof id === 'string' && id.length > 0);\n if (detailIDs.length === 0) {\n return [];\n }\n try {\n const rv = RunView.FromMetadataProvider(provider);\n const detailList = detailIDs.map(id => `'${id.replace(/'/g, \"''\")}'`).join(',');\n const [junctionResult] = await rv.RunViews([{\n EntityName: 'MJ: Conversation Detail Artifacts',\n ExtraFilter: `ConversationDetailID IN (${detailList}) AND Direction='Output'`,\n Fields: JUNCTION_FIELDS,\n OrderBy: '__mj_CreatedAt ASC',\n ResultType: 'simple'\n }]);\n const junctions = (junctionResult?.Success ? junctionResult.Results : []) as DetailArtifactJunctionRow[];\n const versionIDs = this.uniqueVersionIDs(junctions);\n if (versionIDs.length === 0) {\n return [];\n }\n\n const versionList = versionIDs.map(id => `'${id.replace(/'/g, \"''\")}'`).join(',');\n const [versionResult] = await rv.RunViews([{\n EntityName: 'MJ: Artifact Versions',\n ExtraFilter: `ID IN (${versionList})`,\n Fields: VERSION_FIELDS,\n ResultType: 'simple'\n }]);\n const versions = (versionResult?.Success ? versionResult.Results : []) as ArtifactVersionRow[];\n const byID = new Map<string, ArtifactVersionRow>(versions.map(v => [this.normalizeID(v.ID), v]));\n\n const artifacts: ParsedDelegationArtifact[] = [];\n for (const versionID of versionIDs) {\n const row = byID.get(this.normalizeID(versionID));\n if (!row?.ArtifactID) {\n continue; // junction points at an unreadable / deleted version — skip\n }\n artifacts.push({\n ArtifactID: row.ArtifactID,\n ArtifactVersionID: row.ID,\n Name: row.Name?.trim() || row.Artifact?.trim() || 'Artifact'\n });\n }\n return artifacts;\n } catch (error) {\n console.warn('[RealtimeSessionReview] Artifact collection failed — review renders without artifact tabs.', error);\n return [];\n }\n }\n\n /** Unique, non-empty `ArtifactVersionID`s from junction rows, in arrival order (case-insensitive dedupe). */\n private uniqueVersionIDs(junctions: DetailArtifactJunctionRow[]): string[] {\n const seen = new Set<string>();\n const ids: string[] = [];\n for (const j of junctions) {\n const id = typeof j.ArtifactVersionID === 'string' ? j.ArtifactVersionID.trim() : '';\n if (id.length === 0 || seen.has(this.normalizeID(id))) {\n continue;\n }\n seen.add(this.normalizeID(id));\n ids.push(id);\n }\n return ids;\n }\n\n /** Case-insensitive UUID key for Set/Map membership (SQL Server uppercase vs PostgreSQL lowercase). */\n private normalizeID(id: string): string {\n return (id ?? '').trim().toLowerCase();\n }\n\n /**\n * Folds the chain's raw leg rows into the typed review. The PRIMARY (reviewed) leg —\n * the chain's LAST entry — supplies identity/lifecycle/channel state; turns and runs\n * are surfaced both per-leg (`Legs`) and flattened chronologically (`Turns` /\n * `DelegatedRuns`). Each leg excludes ITS OWN config's co-agent observability run.\n */\n private assembleReview(chain: LegRows[], artifacts: ParsedDelegationArtifact[]): RealtimeSessionReview {\n const primary = chain[chain.length - 1];\n const session = primary.session;\n const config = this.parseSessionConfig(session.Config);\n const legs = chain.map(leg => this.mapLeg(leg));\n return {\n SessionID: session.ID,\n AgentID: session.AgentID,\n AgentName: session.Agent || 'the agent',\n TargetAgentID: config.targetAgentID ?? session.AgentID,\n ConversationID: session.ConversationID ?? null,\n Status: session.Status,\n CloseReason: session.CloseReason ?? null,\n StartedAt: this.toDate(session.__mj_CreatedAt),\n LastActiveAt: this.toDate(session.LastActiveAt),\n ClosedAt: this.toDate(session.ClosedAt),\n RecordingFileID: session.RecordingFileID ?? null,\n RecordingStartedAt: this.toDate(session.RecordingStartedAt),\n RecordingMedia: session.RecordingMedia ?? null,\n Turns: legs.flatMap(l => l.Turns),\n DelegatedRuns: legs.flatMap(l => l.DelegatedRuns),\n DirectActions: legs.flatMap(l => l.DirectActions ?? []),\n // Multi-leg: newest leg with a SAVED state wins per channel — a final leg that\n // never touched the board no longer hides an earlier leg's drawing from review.\n ChannelStates: MergeChainChannelStates(chain.map(leg => this.mapChannels(leg.channels))),\n Legs: legs,\n Artifacts: artifacts\n };\n }\n\n /** Maps one leg's raw rows to the public leg shape (per-leg co-agent-run exclusion). */\n private mapLeg(leg: LegRows): RealtimeSessionReviewLeg {\n const config = this.parseSessionConfig(leg.session.Config);\n return {\n SessionID: leg.session.ID,\n StartedAt: this.toDate(leg.session.__mj_CreatedAt),\n ClosedAt: this.toDate(leg.session.ClosedAt),\n CloseReason: leg.session.CloseReason ?? null,\n Turns: this.mapTurns(leg.details),\n DelegatedRuns: this.mapRuns(leg.runs, config.coAgentRunID ?? null),\n DirectActions: this.mapDirectActions(leg.details)\n };\n }\n\n /** Hidden detail rows with realtime_tool_execution payload → direct-action reviews. */\n private mapDirectActions(details: DetailRow[]): RealtimeSessionReviewAction[] {\n const actions: RealtimeSessionReviewAction[] = [];\n for (const row of details) {\n if (!row.HiddenToUser || row.Role !== 'AI' || !row.Message) {\n continue;\n }\n try {\n const parsed = JSON.parse(row.Message) as {\n type?: string;\n callId?: string | null;\n toolName?: string;\n argsJson?: string | null;\n resultJson?: string | null;\n success?: boolean;\n durationMs?: number;\n };\n if (parsed && parsed.type === 'realtime_tool_execution' && typeof parsed.toolName === 'string') {\n const createdAt = this.toDate(row.__mj_CreatedAt);\n actions.push({\n ID: row.ID,\n CallID: parsed.callId || row.ExternalID || row.ID,\n ToolName: parsed.toolName,\n ArgsJson: parsed.argsJson ?? null,\n ResultJson: parsed.resultJson ?? null,\n Success: typeof parsed.success === 'boolean' ? parsed.success : (row.Status === 'Complete'),\n DurationMs: typeof parsed.durationMs === 'number' ? parsed.durationMs : (row.CompletionTime ?? 0),\n At: createdAt\n });\n }\n } catch {\n // Not a JSON fact payload — ignore\n }\n }\n return actions;\n }\n\n /** Persisted detail rows → caption turns: visible `User`/`AI` rows with text (AI → Assistant). */\n private mapTurns(details: DetailRow[]): RealtimeSessionReviewTurn[] {\n const turns: RealtimeSessionReviewTurn[] = [];\n for (const row of details) {\n const text = row.Message?.trim() ?? '';\n if (row.HiddenToUser || text.length === 0 || (row.Role !== 'User' && row.Role !== 'AI')) {\n continue;\n }\n const createdAt = this.toDate(row.__mj_CreatedAt);\n turns.push({\n ID: row.ID,\n Role: row.Role === 'AI' ? 'Assistant' : 'User',\n Text: text,\n Message: text,\n __mj_CreatedAt: createdAt,\n At: createdAt,\n UtteranceStartMs: row.UtteranceStartMs ?? null,\n UtteranceEndMs: row.UtteranceEndMs ?? null\n });\n }\n return turns;\n }\n\n /** Linked run rows → delegated-run previews, EXCLUDING the co-agent's observability run. */\n private mapRuns(runs: RunRow[], coAgentRunId: string | null): RealtimeSessionReviewRun[] {\n return runs\n .filter(r => !coAgentRunId || !UUIDsEqual(r.ID, coAgentRunId))\n .map(r => ({\n RunID: r.ID,\n AgentID: r.AgentID,\n AgentName: r.Agent ?? null,\n Status: r.Status ?? '',\n Success: r.Success === true,\n Message: r.Message ?? null,\n ErrorMessage: r.ErrorMessage ?? null,\n FinalStep: r.FinalStep ?? null,\n StartedAt: this.toDate(r.StartedAt),\n CompletedAt: this.toDate(r.CompletedAt)\n }));\n }\n\n /** Session-channel rows → named channel states (rows without a channel name are skipped). */\n private mapChannels(channels: ChannelRow[]): RealtimeSessionReviewChannelState[] {\n return channels\n .filter(c => !!c.Channel)\n .map(c => ({ ChannelName: c.Channel as string, StateJson: c.Config ?? null }));\n }\n\n /** Tolerant Config JSON parse — malformed/missing payloads degrade to `{}`. */\n private parseSessionConfig(raw: string | null): SessionConfigJson {\n if (!raw) {\n return {};\n }\n try {\n const parsed = JSON.parse(raw) as SessionConfigJson;\n return parsed && typeof parsed === 'object' ? parsed : {};\n } catch {\n return {};\n }\n }\n\n /** Tolerant date conversion — view rows arrive as ISO strings (or Dates from some providers). */\n private toDate(value: string | Date | null | undefined): Date | null {\n if (value == null) {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return isNaN(date.getTime()) ? null : date;\n }\n}\n"]}
1
+ {"version":3,"file":"realtime-session-review.service.js","sourceRoot":"","sources":["../../../src/lib/services/realtime-session-review.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAA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,CAAC;IACnF,CAAC;IAED,+EAA+E;IACvE,kBAAkB,CAAC,GAAkB;QAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsB,CAAC;YACpD,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,iGAAiG;IACzF,MAAM,CAAC,KAAuC;QACpD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;sHAxYU,4BAA4B;gEAA5B,4BAA4B,WAA5B,4BAA4B,mBADf,MAAM;;iFACnB,4BAA4B;cADxC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { AIEngineBase } from '@memberjunction/ai-engine-base';\nimport { IMetadataProvider, Metadata, RunView, RunViewParams } from '@memberjunction/core';\nimport type { MJAIAgentSessionEntity } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { RealtimeDelegationCardVM, RealtimeThreadItem } from '../components/realtime/realtime-session-state';\nimport { ParsedDelegationArtifact, FormatToolName } from '@memberjunction/realtime-runtime';\n\n/**\n * Why a reviewed session was closed, as stamped server-side by `SessionManager.CloseSession`\n * (mirrors `MJAIAgentSessionEntity.CloseReason`). `null` means the session is still open OR a\n * legacy row was closed before the column existed.\n */\nexport type RealtimeReviewCloseReason = NonNullable<MJAIAgentSessionEntity['CloseReason']>;\n\n/**\n * One historical caption turn of a reviewed session (a persisted `MJ: Conversation Details` row).\n *\n * Carries BOTH the thread-rendering fields (`Role`/`Text`/`At`) AND the raw fields the time-aligned\n * evidence player reads (`ID`, `Message`, `__mj_CreatedAt`, `UtteranceStartMs`, `UtteranceEndMs`) so\n * a review's turns can be handed straight to {@link RealtimeEvidencePlaybackComponent} for the\n * Recording tab — this shape structurally satisfies that player's `EvidencePlaybackTurn` input.\n */\nexport interface RealtimeSessionReviewTurn {\n /** `MJ: Conversation Details.ID` — the player's `@for` track key. */\n ID: string;\n /** Who spoke the turn. Persisted `AI` rows map to `Assistant`. */\n Role: 'User' | 'Assistant';\n /** The transcript text. */\n Text: string;\n /** The raw transcript text (mirrors {@link Text}) — the player reads `Message`. */\n Message: string | null;\n /** When the turn was persisted (`__mj_CreatedAt`), or null when unknown. Aliases {@link At}. */\n __mj_CreatedAt: Date | null;\n /** When the turn was persisted (`__mj_CreatedAt`), or null when unknown. */\n At: Date | null;\n /** Precise media-relative start (ms from recording t0), or null when the driver supplied no timing. */\n UtteranceStartMs: number | null;\n /** Precise media-relative end (ms from recording t0), or null. */\n UtteranceEndMs: number | null;\n}\n\n/**\n * A compact preview of one DELEGATED agent run the reviewed session spawned (an\n * `MJ: AI Agent Runs` row linked via `AgentSessionID`, EXCLUDING the co-agent's own\n * observability run). Carries just enough to render a done delegation card.\n */\nexport interface RealtimeSessionReviewRun {\n /** `MJ: AI Agent Runs.ID`. */\n RunID: string;\n /** The delegated agent's id. */\n AgentID: string;\n /** Denormalized agent display name from the run view, when available. */\n AgentName: string | null;\n /** Terminal (or last-known) run status (`Completed` | `Failed` | `Running` | …). */\n Status: string;\n /** Whether the run reported success. */\n Success: boolean;\n /** The run's user-facing result message, when one was recorded. */\n Message: string | null;\n /** The run's error message, when it failed. */\n ErrorMessage: string | null;\n /** The final step the run reported (`Success` | `Failed` | `Retry` | …), when known. */\n FinalStep: string | null;\n StartedAt: Date | null;\n CompletedAt: Date | null;\n}\n\n/** The persisted state of one interactive channel of the reviewed session. */\nexport interface RealtimeSessionReviewChannelState {\n /** Channel display name (e.g. `Whiteboard`), denormalized on the session-channel row. */\n ChannelName: string;\n /** The channel's serialized state of record (`AIAgentSessionChannel.Config`), or null when none was saved. */\n StateJson: string | null;\n}\n\n/**\n * MULTI-LEG channel-state merge: folds every leg's channel rows into one state set,\n * NEWEST leg wins per channel name — but only a leg that actually SAVED state counts.\n * A resumed session whose final leg never touched the whiteboard therefore still\n * reviews with the board an EARLIER leg drew (previously only the primary/newest leg's\n * rows were consulted, so that board silently vanished from review).\n *\n * @param legChannelStates Per-leg channel states, ordered OLDEST → NEWEST (the chain order).\n * @returns One entry per channel name (case-insensitive), each from the newest leg that\n * saved a non-empty state; channels no leg ever saved keep a null-state entry so the\n * review still knows the channel existed.\n */\nexport function MergeChainChannelStates(\n legChannelStates: ReadonlyArray<ReadonlyArray<RealtimeSessionReviewChannelState>>\n): RealtimeSessionReviewChannelState[] {\n const byName = new Map<string, RealtimeSessionReviewChannelState>();\n for (const leg of legChannelStates) {\n for (const state of leg) {\n const key = state.ChannelName.trim().toLowerCase();\n if (key.length === 0) {\n continue;\n }\n const existing = byName.get(key);\n const hasState = typeof state.StateJson === 'string' && state.StateJson.trim().length > 0;\n // Later legs are newer: a saved state always supersedes; a null/empty state only\n // registers the channel's existence and never clobbers an earlier saved board.\n if (!existing || hasState) {\n byName.set(key, hasState ? state : (existing ?? state));\n }\n }\n }\n return [...byName.values()];\n}\n\n/**\n * A direct action or channel tool execution performed during the reviewed session\n * (stored as a hidden `MJ: Conversation Details` turn with `type: 'realtime_tool_execution'`).\n */\nexport interface RealtimeSessionReviewAction {\n /** `MJ: Conversation Details.ID`. */\n ID: string;\n /** Correlated tool call id (`MJ: Conversation Details.ExternalID`), falling back to ID. */\n CallID: string;\n /** The tool/action name (e.g. `File_Storage_List_Objects` or `Whiteboard_draw_shape`). */\n ToolName: string;\n /** Serialized argument payload, when recorded. */\n ArgsJson: string | null;\n /** Serialized result payload, when recorded. */\n ResultJson: string | null;\n /** Whether the execution reported success. */\n Success: boolean;\n /** Execution duration in ms (`MJ: Conversation Details.CompletionTime`). */\n DurationMs: number;\n /** When the tool execution was recorded (`MJ: Conversation Details.__mj_CreatedAt`). */\n At: Date | null;\n}\n\n/**\n * One LEG of a reviewed session chain: a single `MJ: AI Agent Sessions` row plus its own\n * caption turns and delegated-run previews. A session resumed via `lastSessionId` chains\n * legs together (newest leg's `LastSessionID` → prior leg); the review loader walks that\n * chain BACKWARDS (capped — see the loader docs) so review mode can render the FULL\n * conversation arc chronologically, with a divider between legs.\n */\nexport interface RealtimeSessionReviewLeg {\n /** `MJ: AI Agent Sessions.ID` of this leg. */\n SessionID: string;\n /** When this leg started (`__mj_CreatedAt`). */\n StartedAt: Date | null;\n /** When this leg closed (null while still open). */\n ClosedAt: Date | null;\n /** Why this leg closed (null while open / legacy rows). */\n CloseReason: RealtimeReviewCloseReason | null;\n /** This leg's chronological caption turns (oldest first). */\n Turns: RealtimeSessionReviewTurn[];\n /** This leg's delegated-run previews (oldest first, minus its co-agent observability run). */\n DelegatedRuns: RealtimeSessionReviewRun[];\n /** This leg's direct action and channel tool executions. */\n DirectActions?: RealtimeSessionReviewAction[];\n}\n\n/**\n * Everything the call overlay's SESSION REVIEW mode renders for one past realtime session:\n * the session identity/lifecycle row, the chronological caption turns, previews of the\n * delegated runs, and the saved per-channel states (e.g. the whiteboard board).\n */\nexport interface RealtimeSessionReview {\n /** `MJ: AI Agent Sessions.ID` of the reviewed session. */\n SessionID: string;\n /** The session's fronting agent id (`AIAgentSession.AgentID` — usually the Realtime Co-Agent). */\n AgentID: string;\n /** Display name shown in the review banner (target agent when resolvable, else the session agent). */\n AgentName: string;\n /**\n * The agent a RESUMED live session should front: the session Config's `targetAgentID`,\n * falling back to the session's own `AgentID` when the config doesn't carry one.\n */\n TargetAgentID: string;\n /** Conversation the session was bound to, when any. */\n ConversationID: string | null;\n Status: 'Active' | 'Closed' | 'Idle';\n CloseReason: RealtimeReviewCloseReason | null;\n /** When the session started (`__mj_CreatedAt`). */\n StartedAt: Date | null;\n LastActiveAt: Date | null;\n ClosedAt: Date | null;\n /**\n * The `MJ: Files` id of the reviewed session's recorded audio, or null when nothing was recorded.\n * When set, review mode resolves a signed download URL and shows a Recording tab with the\n * time-aligned evidence player. From the PRIMARY (reviewed) leg only.\n */\n RecordingFileID: string | null;\n /** Recording alignment origin (t0), used by the playback transcript sync. From the primary leg. */\n RecordingStartedAt: Date | null;\n /** What was captured (`Audio` / `AudioVideo`), or null. From the primary leg. */\n RecordingMedia: string | null;\n /** Chronological caption turns (oldest first) — ALL legs of the chain, flattened. */\n Turns: RealtimeSessionReviewTurn[];\n /** Delegated run previews (oldest first, all legs), minus each leg's co-agent observability run. */\n DelegatedRuns: RealtimeSessionReviewRun[];\n /** Direct action and channel tool executions (oldest first, all legs). */\n DirectActions?: RealtimeSessionReviewAction[];\n /**\n * Saved channel states, one per session-channel row that carried a name. Channel state\n * (e.g. the whiteboard board) is the LATEST leg's only — earlier legs' states were\n * superseded when the chain resumed.\n */\n ChannelStates: RealtimeSessionReviewChannelState[];\n /**\n * The session-chain LEGS, chronological (oldest first; the LAST leg is the reviewed\n * session itself). Single-session reviews carry exactly one leg. Drives the per-leg\n * dividers `BuildReviewThreadItems` renders.\n */\n Legs: RealtimeSessionReviewLeg[];\n /**\n * ARTIFACTS attached to the chain's conversation history: every `MJ: Conversation\n * Detail Artifacts` junction (Direction `Output`) hanging off the chain's\n * session-stamped `Conversation Details`, resolved to `{ArtifactID, ArtifactVersionID,\n * Name}`. Review mode registers each as an (unfocused) artifact tab on the surface\n * panel, and they carry into a resumed live session. Empty when none / on any\n * tolerated load failure.\n */\n /** Artifacts attached to the chain's conversation history... */\n Artifacts: ParsedDelegationArtifact[];\n /**\n * The voice model id resolved for the reviewed session (from `Config.realtimeMintSnapshot.modelID`),\n * when recorded. Passed as `preferredModelId` on resume so a user who chose e.g. Grok Voice 3 keeps\n * that same voice model instead of dropping back to the co-agent's default model.\n */\n ModelID?: string | null;\n}\n\n// ── Raw row shapes (ResultType: 'simple', narrowed Fields) ──────────────────\n\ninterface SessionRow {\n ID: string;\n AgentID: string;\n Agent: string | null;\n Status: 'Active' | 'Closed' | 'Idle';\n ConversationID: string | null;\n Config: string | null;\n LastSessionID: string | null;\n LastActiveAt: string | null;\n ClosedAt: string | null;\n CloseReason: RealtimeReviewCloseReason | null;\n RecordingFileID: string | null;\n RecordingStartedAt: string | null;\n RecordingMedia: string | null;\n __mj_CreatedAt: string | null;\n}\n\ninterface DetailRow {\n ID: string;\n Role: 'AI' | 'Error' | 'User';\n Message: string | null;\n HiddenToUser: boolean;\n UserID: string | null;\n Status: string | null;\n ExternalID?: string | null;\n CompletionTime?: number | null;\n UtteranceStartMs: number | null;\n UtteranceEndMs: number | null;\n __mj_CreatedAt: string | null;\n}\n\ninterface RunRow {\n ID: string;\n AgentID: string;\n Agent: string | null;\n Status: string;\n Success: boolean | null;\n Message: string | null;\n ErrorMessage: string | null;\n FinalStep: string | null;\n StartedAt: string | null;\n CompletedAt: string | null;\n}\n\ninterface ChannelRow {\n ID: string;\n Channel: string | null;\n Config: string | null;\n}\n\ninterface DetailArtifactJunctionRow {\n ID: string;\n ConversationDetailID: string;\n ArtifactVersionID: string | null;\n}\n\ninterface ArtifactVersionRow {\n ID: string;\n ArtifactID: string;\n /** Version display name (nullable on the row). */\n Name: string | null;\n /** Denormalized parent-artifact name from the version view. */\n Artifact: string | null;\n}\n\n/** The raw rows of ONE chain leg, before mapping to the public review shapes. */\ninterface LegRows {\n session: SessionRow;\n details: DetailRow[];\n runs: RunRow[];\n channels: ChannelRow[];\n}\n\n/** The Config-JSON keys the realtime voice stack persists on `AIAgentSession.Config`. */\ninterface SessionConfigJson {\n targetAgentID?: string;\n coAgentRunID?: string;\n realtimeMintSnapshot?: {\n modelID?: string;\n };\n}\n\nconst SESSION_FIELDS = ['ID', 'AgentID', 'Agent', 'Status', 'ConversationID', 'Config', 'LastSessionID', 'LastActiveAt', 'ClosedAt', 'CloseReason', 'RecordingFileID', 'RecordingStartedAt', 'RecordingMedia', '__mj_CreatedAt'];\nconst DETAIL_FIELDS = ['ID', 'Role', 'Message', 'HiddenToUser', 'UserID', 'Status', 'ExternalID', 'CompletionTime', 'UtteranceStartMs', 'UtteranceEndMs', '__mj_CreatedAt'];\nconst RUN_FIELDS = ['ID', 'AgentID', 'Agent', 'Status', 'Success', 'Message', 'ErrorMessage', 'FinalStep', 'StartedAt', 'CompletedAt'];\nconst CHANNEL_FIELDS = ['ID', 'Channel', 'Config'];\nconst JUNCTION_FIELDS = ['ID', 'ConversationDetailID', 'ArtifactVersionID'];\nconst VERSION_FIELDS = ['ID', 'ArtifactID', 'Name', 'Artifact'];\n\n/** Maximum number of chain legs the review loader walks (the reviewed session included). */\nexport const MAX_REVIEW_LEGS = 5;\n/** Maximum total caption-detail rows loaded across the whole chain (oldest legs trimmed first). */\nexport const MAX_REVIEW_DETAILS = 500;\n\n// ── Review → thread-item mapping (pure, unit-testable) ──────────────────────\n\n/** Maps one delegated-run preview to the done delegation-card VM the thread/rail render. */\nexport function BuildReviewDelegationCard(run: RealtimeSessionReviewRun, fallbackAgentName: string): RealtimeDelegationCardVM {\n const startedAt = run.StartedAt?.getTime() ?? 0;\n return {\n Kind: 'agent',\n CallID: run.RunID,\n AgentName: run.AgentName || fallbackAgentName,\n LatestMessage: run.Message ?? run.ErrorMessage ?? run.Status,\n LatestStep: run.FinalStep ?? '',\n Done: true,\n Success: run.Success,\n RunRef: shortRunRef(run.RunID),\n RunID: run.RunID,\n Result: run.Message ?? run.ErrorMessage ?? null,\n StartedAt: startedAt,\n FinishedAt: run.CompletedAt?.getTime() ?? startedAt\n };\n}\n\n/** Maps one direct-action execution to the done action-card VM the thread/rail render. */\nexport function BuildReviewActionCard(action: RealtimeSessionReviewAction): RealtimeDelegationCardVM {\n const at = action.At?.getTime() ?? 0;\n const toolTitle = FormatToolName(action.ToolName);\n return {\n Kind: 'action',\n CallID: action.CallID,\n ToolName: action.ToolName,\n AgentName: toolTitle,\n LatestMessage: `Executed ${toolTitle}`,\n LatestStep: 'direct_action',\n Done: true,\n Success: action.Success,\n RunRef: shortRunRef(action.CallID),\n Result: action.ResultJson,\n StartedAt: at,\n FinishedAt: at + action.DurationMs\n };\n}\n\n/**\n * Builds the chronological thread (caption turns + done delegation cards + done action cards, oldest first)\n * for a reviewed session — the items `RealtimeSessionState.LoadHistoricalItems` takes.\n *\n * CHAIN-AWARE: when the review carries multiple {@link RealtimeSessionReview.Legs}, each\n * leg's items render in leg order with a `divider` item between legs (\"Session leg\n * started · <time>\", carrying the PREVIOUS leg's CloseReason as a chip). A single-leg\n * review (or a legless legacy shape) renders the flat thread with no divider —\n * byte-identical to the pre-chain behavior.\n */\nexport function BuildReviewThreadItems(review: RealtimeSessionReview): RealtimeThreadItem[] {\n const legs = review.Legs ?? [];\n if (legs.length <= 1) {\n const only = legs[0];\n return buildLegThreadItems(\n only?.Turns ?? review.Turns,\n only?.DelegatedRuns ?? review.DelegatedRuns,\n only?.DirectActions ?? review.DirectActions ?? [],\n review.AgentName\n );\n }\n const items: RealtimeThreadItem[] = [];\n legs.forEach((leg, i) => {\n if (i > 0) {\n items.push({\n Kind: 'divider',\n Label: 'Session leg started',\n At: leg.StartedAt,\n Icon: 'fa-solid fa-arrows-rotate',\n CloseReason: legs[i - 1].CloseReason ?? null\n });\n }\n items.push(...buildLegThreadItems(leg.Turns, leg.DelegatedRuns, leg.DirectActions ?? [], review.AgentName));\n });\n return items;\n}\n\n/**\n * Builds ONE leg's chronological items (caption turns + done delegation cards + done action cards,\n * oldest first). Entries without a timestamp sort to the front, preserving their relative order.\n */\nfunction buildLegThreadItems(\n turns: RealtimeSessionReviewTurn[],\n runs: RealtimeSessionReviewRun[],\n actions: RealtimeSessionReviewAction[],\n fallbackAgentName: string\n): RealtimeThreadItem[] {\n const stamped: Array<{ At: number; Item: RealtimeThreadItem }> = [];\n for (const turn of turns) {\n stamped.push({ At: turn.At?.getTime() ?? 0, Item: { Kind: 'caption', Role: turn.Role, Text: turn.Text } });\n }\n for (const run of runs) {\n stamped.push({ At: run.StartedAt?.getTime() ?? 0, Item: { Kind: 'delegation', Card: BuildReviewDelegationCard(run, fallbackAgentName) } });\n }\n for (const action of actions) {\n stamped.push({ At: action.At?.getTime() ?? 0, Item: { Kind: 'delegation', Card: BuildReviewActionCard(action) } });\n }\n // Array.prototype.sort is stable — equal timestamps keep their build order.\n stamped.sort((a, b) => a.At - b.At);\n return stamped.map(s => s.Item);\n}\n\n/** Derives a short run reference (e.g. \"#a3f1\") from the run id — mirrors the live cards. */\nfunction shortRunRef(runId: string): string {\n const compact = runId.replace(/[^a-z0-9]/gi, '');\n return compact.length >= 4 ? `#${compact.slice(-4).toLowerCase()}` : `#${compact.toLowerCase()}`;\n}\n\n/**\n * STATELESS loader for the call overlay's SESSION REVIEW mode: given a past\n * `MJ: AI Agent Sessions` id, batch-loads the session row, its persisted caption turns\n * (`MJ: Conversation Details` linked by `AgentSessionID`), its delegated agent runs\n * (minus the co-agent observability run named in the session Config's `coAgentRunID`),\n * and its saved channel states — and folds them into one {@link RealtimeSessionReview}.\n *\n * CHAIN-AWARE: when the reviewed session carries a `LastSessionID` (it RESUMED an earlier\n * session), the loader walks the chain BACKWARDS — capped at {@link MAX_REVIEW_LEGS} legs\n * and {@link MAX_REVIEW_DETAILS} caption rows total (oldest legs trimmed first), with a\n * cycle guard so a corrupt A→B→A chain can never loop — and surfaces ALL legs\n * chronologically on {@link RealtimeSessionReview.Legs}. Channel state stays the\n * reviewed (latest) leg's only. The chain's conversation-history ARTIFACTS (junction\n * rows on the session-stamped details) are collected onto\n * {@link RealtimeSessionReview.Artifacts}.\n *\n * TOLERANT by design: any missing piece degrades to an empty collection; the loader\n * returns `null` only when the reviewed session row itself can't be found.\n */\n@Injectable({ providedIn: 'root' })\nexport class RealtimeSessionReviewService {\n /**\n * Loads everything review mode renders for one past session (and its prior-leg chain).\n *\n * @param agentSessionId The `MJ: AI Agent Sessions.ID` to review.\n * @param provider Optional metadata provider (multi-server apps); falls back to the global default.\n * @returns The assembled review, or `null` when the session doesn't exist / can't be read.\n */\n public async LoadSessionReview(agentSessionId: string, provider?: IMetadataProvider): Promise<RealtimeSessionReview | null> {\n const trimmed = agentSessionId?.trim() ?? '';\n if (trimmed.length === 0) {\n return null;\n }\n try {\n const md = provider ?? Metadata.Provider;\n const primary = await this.loadLegRows(trimmed, md, true);\n if (!primary) {\n return null;\n }\n const chain = await this.collectChainLegs(primary, md);\n const artifacts = await this.loadChainArtifacts(chain, md);\n const primaryConfig = this.parseSessionConfig(primary.session.Config);\n const fallbackName = primary.session.Agent || 'the agent';\n const targetAgentName = await this.resolveTargetAgentName(\n primaryConfig.targetAgentID,\n primary.session.AgentID,\n fallbackName,\n md\n );\n return this.assembleReview(chain, artifacts, targetAgentName);\n } catch (error) {\n console.error('[RealtimeSessionReview] Failed to load session review:', error);\n return null;\n }\n }\n\n /**\n * One batched RunViews pass for one chain leg: session row + caption turns + linked\n * runs (+ channel rows for the PRIMARY leg only — channel state is latest-leg-only).\n * Returns `null` when the session row can't be found.\n */\n private async loadLegRows(\n agentSessionId: string,\n provider: IMetadataProvider,\n includeChannels: boolean\n ): Promise<LegRows | null> {\n const safeID = agentSessionId.replace(/'/g, \"''\");\n const rv = RunView.FromMetadataProvider(provider);\n const queries: RunViewParams[] = [\n { EntityName: 'MJ: AI Agent Sessions', ExtraFilter: `ID='${safeID}'`, Fields: SESSION_FIELDS, ResultType: 'simple' as const },\n {\n EntityName: 'MJ: Conversation Details', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: DETAIL_FIELDS,\n OrderBy: '__mj_CreatedAt ASC', MaxRows: MAX_REVIEW_DETAILS, ResultType: 'simple' as const\n },\n { EntityName: 'MJ: AI Agent Runs', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: RUN_FIELDS, OrderBy: 'StartedAt ASC', ResultType: 'simple' as const }\n ];\n if (includeChannels) {\n queries.push({ EntityName: 'MJ: AI Agent Session Channels', ExtraFilter: `AgentSessionID='${safeID}'`, Fields: CHANNEL_FIELDS, ResultType: 'simple' as const });\n }\n const [sessionResult, detailResult, runResult, channelResult] = await rv.RunViews(queries);\n const sessions = (sessionResult?.Success ? sessionResult.Results : []) as SessionRow[];\n const session = sessions[0] ?? null;\n if (!session) {\n return null;\n }\n return {\n session,\n details: (detailResult?.Success ? detailResult.Results : []) as DetailRow[],\n runs: (runResult?.Success ? runResult.Results : []) as RunRow[],\n channels: (channelResult?.Success ? channelResult.Results : []) as ChannelRow[]\n };\n }\n\n /**\n * Walks the `LastSessionID` chain BACKWARDS from the reviewed (primary) leg, collecting\n * raw leg rows OLDEST-FIRST (primary last). Safety rails:\n * - at most {@link MAX_REVIEW_LEGS} legs total;\n * - at most {@link MAX_REVIEW_DETAILS} caption rows across the chain — an older leg\n * whose details would overflow the budget is trimmed to its NEWEST rows and ends\n * the walk;\n * - a visited-set cycle guard (case-insensitive ids) so A→B→A can never loop;\n * - a leg that fails to load simply ends the walk (the collected legs still render).\n */\n private async collectChainLegs(primary: LegRows, provider: IMetadataProvider): Promise<LegRows[]> {\n const chain: LegRows[] = [primary];\n const visited = new Set<string>([this.normalizeID(primary.session.ID)]);\n let cursor = primary.session.LastSessionID ?? null;\n let detailBudget = MAX_REVIEW_DETAILS - primary.details.length;\n\n while (cursor && chain.length < MAX_REVIEW_LEGS && detailBudget > 0) {\n const key = this.normalizeID(cursor);\n if (visited.has(key)) {\n console.warn(`[RealtimeSessionReview] Session chain cycle detected at ${cursor} — stopping the walk.`);\n break;\n }\n visited.add(key);\n const leg = await this.loadLegRows(cursor, provider, true);\n if (!leg) {\n break;\n }\n if (leg.details.length > detailBudget) {\n // Keep this leg's NEWEST rows (details arrive oldest-first) and end the walk.\n leg.details = leg.details.slice(leg.details.length - detailBudget);\n detailBudget = 0;\n } else {\n detailBudget -= leg.details.length;\n }\n chain.unshift(leg);\n cursor = leg.session.LastSessionID ?? null;\n }\n return chain;\n }\n\n /**\n * Collects the chain's conversation-history ARTIFACTS: `MJ: Conversation Detail\n * Artifacts` junction rows (Direction `Output`) hanging off the chain's session-stamped\n * details, resolved through `MJ: Artifact Versions` to `{ArtifactID, ArtifactVersionID,\n * Name}` (version name, falling back to the artifact name). Order follows junction\n * creation; duplicate versions are deduped. TOLERANT: any failure returns `[]`.\n */\n private async loadChainArtifacts(chain: LegRows[], provider: IMetadataProvider): Promise<ParsedDelegationArtifact[]> {\n const detailIDs = chain.flatMap(leg => leg.details.map(d => d.ID)).filter(id => typeof id === 'string' && id.length > 0);\n if (detailIDs.length === 0) {\n return [];\n }\n try {\n const rv = RunView.FromMetadataProvider(provider);\n const detailList = detailIDs.map(id => `'${id.replace(/'/g, \"''\")}'`).join(',');\n const [junctionResult] = await rv.RunViews([{\n EntityName: 'MJ: Conversation Detail Artifacts',\n ExtraFilter: `ConversationDetailID IN (${detailList}) AND Direction='Output'`,\n Fields: JUNCTION_FIELDS,\n OrderBy: '__mj_CreatedAt ASC',\n ResultType: 'simple'\n }]);\n const junctions = (junctionResult?.Success ? junctionResult.Results : []) as DetailArtifactJunctionRow[];\n const versionIDs = this.uniqueVersionIDs(junctions);\n if (versionIDs.length === 0) {\n return [];\n }\n\n const versionList = versionIDs.map(id => `'${id.replace(/'/g, \"''\")}'`).join(',');\n const [versionResult] = await rv.RunViews([{\n EntityName: 'MJ: Artifact Versions',\n ExtraFilter: `ID IN (${versionList})`,\n Fields: VERSION_FIELDS,\n ResultType: 'simple'\n }]);\n const versions = (versionResult?.Success ? versionResult.Results : []) as ArtifactVersionRow[];\n const byID = new Map<string, ArtifactVersionRow>(versions.map(v => [this.normalizeID(v.ID), v]));\n\n const artifacts: ParsedDelegationArtifact[] = [];\n for (const versionID of versionIDs) {\n const row = byID.get(this.normalizeID(versionID));\n if (!row?.ArtifactID) {\n continue; // junction points at an unreadable / deleted version — skip\n }\n artifacts.push({\n ArtifactID: row.ArtifactID,\n ArtifactVersionID: row.ID,\n Name: row.Name?.trim() || row.Artifact?.trim() || 'Artifact'\n });\n }\n return artifacts;\n } catch (error) {\n console.warn('[RealtimeSessionReview] Artifact collection failed — review renders without artifact tabs.', error);\n return [];\n }\n }\n\n /** Unique, non-empty `ArtifactVersionID`s from junction rows, in arrival order (case-insensitive dedupe). */\n private uniqueVersionIDs(junctions: DetailArtifactJunctionRow[]): string[] {\n const seen = new Set<string>();\n const ids: string[] = [];\n for (const j of junctions) {\n const id = typeof j.ArtifactVersionID === 'string' ? j.ArtifactVersionID.trim() : '';\n if (id.length === 0 || seen.has(this.normalizeID(id))) {\n continue;\n }\n seen.add(this.normalizeID(id));\n ids.push(id);\n }\n return ids;\n }\n\n /** Case-insensitive UUID key for Set/Map membership (SQL Server uppercase vs PostgreSQL lowercase). */\n private normalizeID(id: string): string {\n return (id ?? '').trim().toLowerCase();\n }\n\n /**\n * Resolves the human-facing target agent name (e.g. `\"Sage\"`) for sessions hosted by the\n * `\"Realtime Co-Agent\"`, using {@link AIEngineBase}'s cached agent catalog. Falls back to\n * the session's `Agent` string (`\"Realtime Co-Agent\"` or `\"the agent\"`) when the session has\n * no distinct `targetAgentID` or agent metadata is unavailable.\n */\n private async resolveTargetAgentName(\n targetAgentID: string | null | undefined,\n sessionAgentID: string,\n fallbackName: string,\n provider: IMetadataProvider\n ): Promise<string> {\n const trimmedTarget = targetAgentID?.trim() ?? '';\n if (!trimmedTarget || UUIDsEqual(trimmedTarget, sessionAgentID)) {\n return fallbackName;\n }\n try {\n const engine = AIEngineBase.GetProviderInstance<AIEngineBase>(provider, AIEngineBase) as AIEngineBase;\n if ((engine.Agents?.length ?? 0) === 0 && (provider.Entities?.length ?? 0) > 0) {\n await engine.Config(false, undefined, provider);\n }\n const match = (engine.Agents ?? []).find(a => UUIDsEqual(a.ID, trimmedTarget));\n if (match?.Name?.trim()) {\n return match.Name.trim();\n }\n } catch {\n // Tolerant: retain fallbackName when engine catalog cannot be loaded.\n }\n return fallbackName;\n }\n\n /**\n * Folds the chain's raw leg rows into the typed review. The PRIMARY (reviewed) leg —\n * the chain's LAST entry — supplies identity/lifecycle/channel state; turns and runs\n * are surfaced both per-leg (`Legs`) and flattened chronologically (`Turns` /\n * `DelegatedRuns`). Each leg excludes ITS OWN config's co-agent observability run.\n */\n private assembleReview(\n chain: LegRows[],\n artifacts: ParsedDelegationArtifact[],\n resolvedAgentName?: string\n ): RealtimeSessionReview {\n const primary = chain[chain.length - 1];\n const session = primary.session;\n const config = this.parseSessionConfig(session.Config);\n const legs = chain.map(leg => this.mapLeg(leg));\n let modelId: string | null = config.realtimeMintSnapshot?.modelID?.trim() || null;\n if (!modelId) {\n for (let i = chain.length - 2; i >= 0; i--) {\n const legConfig = this.parseSessionConfig(chain[i].session.Config);\n const legModelId = legConfig.realtimeMintSnapshot?.modelID?.trim();\n if (legModelId) {\n modelId = legModelId;\n break;\n }\n }\n }\n return {\n SessionID: session.ID,\n AgentID: session.AgentID,\n AgentName: resolvedAgentName || session.Agent || 'the agent',\n TargetAgentID: config.targetAgentID ?? session.AgentID,\n ModelID: modelId,\n ConversationID: session.ConversationID ?? null,\n Status: session.Status,\n CloseReason: session.CloseReason ?? null,\n StartedAt: this.toDate(session.__mj_CreatedAt),\n LastActiveAt: this.toDate(session.LastActiveAt),\n ClosedAt: this.toDate(session.ClosedAt),\n RecordingFileID: session.RecordingFileID ?? null,\n RecordingStartedAt: this.toDate(session.RecordingStartedAt),\n RecordingMedia: session.RecordingMedia ?? null,\n Turns: legs.flatMap(l => l.Turns),\n DelegatedRuns: legs.flatMap(l => l.DelegatedRuns),\n DirectActions: legs.flatMap(l => l.DirectActions ?? []),\n // Multi-leg: newest leg with a SAVED state wins per channel — a final leg that\n // never touched the board no longer hides an earlier leg's drawing from review.\n ChannelStates: MergeChainChannelStates(chain.map(leg => this.mapChannels(leg.channels))),\n Legs: legs,\n Artifacts: artifacts\n };\n }\n\n /** Maps one leg's raw rows to the public leg shape (per-leg co-agent-run exclusion). */\n private mapLeg(leg: LegRows): RealtimeSessionReviewLeg {\n const config = this.parseSessionConfig(leg.session.Config);\n return {\n SessionID: leg.session.ID,\n StartedAt: this.toDate(leg.session.__mj_CreatedAt),\n ClosedAt: this.toDate(leg.session.ClosedAt),\n CloseReason: leg.session.CloseReason ?? null,\n Turns: this.mapTurns(leg.details),\n DelegatedRuns: this.mapRuns(leg.runs, config.coAgentRunID ?? null),\n DirectActions: this.mapDirectActions(leg.details)\n };\n }\n\n /** Hidden detail rows with realtime_tool_execution payload → direct-action reviews. */\n private mapDirectActions(details: DetailRow[]): RealtimeSessionReviewAction[] {\n const actions: RealtimeSessionReviewAction[] = [];\n for (const row of details) {\n if (!row.HiddenToUser || row.Role !== 'AI' || !row.Message) {\n continue;\n }\n try {\n const parsed = JSON.parse(row.Message) as {\n type?: string;\n callId?: string | null;\n toolName?: string;\n argsJson?: string | null;\n resultJson?: string | null;\n success?: boolean;\n durationMs?: number;\n };\n if (parsed && parsed.type === 'realtime_tool_execution' && typeof parsed.toolName === 'string') {\n const createdAt = this.toDate(row.__mj_CreatedAt);\n actions.push({\n ID: row.ID,\n CallID: parsed.callId || row.ExternalID || row.ID,\n ToolName: parsed.toolName,\n ArgsJson: parsed.argsJson ?? null,\n ResultJson: parsed.resultJson ?? null,\n Success: typeof parsed.success === 'boolean' ? parsed.success : (row.Status === 'Complete'),\n DurationMs: typeof parsed.durationMs === 'number' ? parsed.durationMs : (row.CompletionTime ?? 0),\n At: createdAt\n });\n }\n } catch {\n // Not a JSON fact payload — ignore\n }\n }\n return actions;\n }\n\n /** Persisted detail rows → caption turns: visible `User`/`AI` rows with text (AI → Assistant). */\n private mapTurns(details: DetailRow[]): RealtimeSessionReviewTurn[] {\n const turns: RealtimeSessionReviewTurn[] = [];\n for (const row of details) {\n const text = row.Message?.trim() ?? '';\n if (row.HiddenToUser || text.length === 0 || (row.Role !== 'User' && row.Role !== 'AI')) {\n continue;\n }\n const createdAt = this.toDate(row.__mj_CreatedAt);\n turns.push({\n ID: row.ID,\n Role: row.Role === 'AI' ? 'Assistant' : 'User',\n Text: text,\n Message: text,\n __mj_CreatedAt: createdAt,\n At: createdAt,\n UtteranceStartMs: row.UtteranceStartMs ?? null,\n UtteranceEndMs: row.UtteranceEndMs ?? null\n });\n }\n return turns;\n }\n\n /** Linked run rows → delegated-run previews, EXCLUDING the co-agent's observability run. */\n private mapRuns(runs: RunRow[], coAgentRunId: string | null): RealtimeSessionReviewRun[] {\n return runs\n .filter(r => !coAgentRunId || !UUIDsEqual(r.ID, coAgentRunId))\n .map(r => ({\n RunID: r.ID,\n AgentID: r.AgentID,\n AgentName: r.Agent ?? null,\n Status: r.Status ?? '',\n Success: r.Success === true,\n Message: r.Message ?? null,\n ErrorMessage: r.ErrorMessage ?? null,\n FinalStep: r.FinalStep ?? null,\n StartedAt: this.toDate(r.StartedAt),\n CompletedAt: this.toDate(r.CompletedAt)\n }));\n }\n\n /** Session-channel rows → named channel states (rows without a channel name are skipped). */\n private mapChannels(channels: ChannelRow[]): RealtimeSessionReviewChannelState[] {\n return channels\n .filter(c => !!c.Channel)\n .map(c => ({ ChannelName: c.Channel as string, StateJson: c.Config ?? null }));\n }\n\n /** Tolerant Config JSON parse — malformed/missing payloads degrade to `{}`. */\n private parseSessionConfig(raw: string | null): SessionConfigJson {\n if (!raw) {\n return {};\n }\n try {\n const parsed = JSON.parse(raw) as SessionConfigJson;\n return parsed && typeof parsed === 'object' ? parsed : {};\n } catch {\n return {};\n }\n }\n\n /** Tolerant date conversion — view rows arrive as ISO strings (or Dates from some providers). */\n private toDate(value: string | Date | null | undefined): Date | null {\n if (value == null) {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return isNaN(date.getTime()) ? null : date;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/realtime-session.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;;AA8B1E;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,sBAAuB,SAAQ,sBAAsB;;IAQ9D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CAAC,6BAA6B,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,qBAAqB,GAAG,IAAI;yCA/BlG,sBAAsB;6CAAtB,sBAAsB;CAyClC;AAED,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAEhC,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CACxG;AAED,yFAAyF;AACzF,MAAM,WAAW,qBAAqB;IAElC,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAC;IAElD,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC1E"}
1
+ {"version":3,"file":"realtime-session.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/realtime-session.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;;AAgC1E;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,sBAAuB,SAAQ,sBAAsB;;IAQ9D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CAAC,6BAA6B,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,qBAAqB,GAAG,IAAI;yCA/BlG,sBAAsB;6CAAtB,sBAAsB;CAyClC;AAED,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAEhC,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CACxG;AAED,yFAAyF;AACzF,MAAM,WAAW,qBAAqB;IAElC,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAC;IAElD,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC1E"}
@@ -1,6 +1,6 @@
1
1
  import { Injectable } from '@angular/core';
2
2
  import { RealtimeSessionRuntime } from '@memberjunction/realtime-runtime';
3
- import { LoadAssemblyAIRealtimeClient, LoadElevenLabsRealtimeClient, LoadElevenRealtimeClient, LoadGeminiRealtimeClient, LoadHuggingFaceRealtimeClient, LoadOpenAILiveClient, LoadOpenAIRealtimeClient, LoadxAIRealtimeClient, } from '@memberjunction/ai-realtime-client';
3
+ import { LoadAssemblyAIRealtimeClient, LoadAssemblyAIVoiceRealtimeClient, LoadElevenLabsRealtimeClient, LoadElevenRealtimeClient, LoadGeminiRealtimeClient, LoadHuggingFaceRealtimeClient, LoadOpenAILiveClient, LoadOpenAIRealtimeClient, LoadxAIRealtimeClient, } from '@memberjunction/ai-realtime-client';
4
4
  import { BrowserRealtimeMediaHost } from './browser-realtime-media-host';
5
5
  import * as i0 from "@angular/core";
6
6
  // Tree-shaking prevention: client drivers are resolved dynamically through the ClassFactory (by
@@ -16,6 +16,7 @@ LoadOpenAILiveClient();
16
16
  LoadGeminiRealtimeClient();
17
17
  LoadElevenLabsRealtimeClient();
18
18
  LoadAssemblyAIRealtimeClient();
19
+ LoadAssemblyAIVoiceRealtimeClient();
19
20
  LoadxAIRealtimeClient();
20
21
  LoadElevenRealtimeClient();
21
22
  LoadHuggingFaceRealtimeClient();
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-session.service.js","sourceRoot":"","sources":["../../../src/lib/services/realtime-session.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,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CAAC;gBAC1C,sFAAsF;gBACtF,sFAAsF;gBACtF,IAAI,CAAC,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACjD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;gHAxCQ,sBAAsB;gEAAtB,sBAAsB,WAAtB,sBAAsB,mBADT,MAAM;;iFACnB,sBAAsB;cADlC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { RealtimeSessionRuntime } from '@memberjunction/realtime-runtime';\nimport {\n LoadAssemblyAIRealtimeClient,\n LoadElevenLabsRealtimeClient,\n LoadElevenRealtimeClient,\n LoadGeminiRealtimeClient,\n LoadHuggingFaceRealtimeClient,\n LoadOpenAILiveClient,\n LoadOpenAIRealtimeClient,\n LoadxAIRealtimeClient,\n} from '@memberjunction/ai-realtime-client';\nimport { BrowserRealtimeMediaHost } from './browser-realtime-media-host';\n\n// Tree-shaking prevention: client drivers are resolved dynamically through the ClassFactory (by\n// the server-reported Provider key), so these static calls are what keep their @RegisterClass side\n// effects from being eliminated by the bundler.\n//\n// NOTE: the interactive-channel plugins (resolved dynamically from the `MJ: AI Agent Channels`\n// registry by ClientPluginClass key) get the same treatment, but their Load calls live in\n// `conversations.module.ts` — plugins carry Angular surface COMPONENTS, and this service stays\n// component-free.\nLoadOpenAIRealtimeClient();\nLoadOpenAILiveClient();\nLoadGeminiRealtimeClient();\nLoadElevenLabsRealtimeClient();\nLoadAssemblyAIRealtimeClient();\nLoadxAIRealtimeClient();\nLoadElevenRealtimeClient();\nLoadHuggingFaceRealtimeClient();\n\n/**\n * Angular host for MemberJunction's realtime co-agent sessions.\n *\n * All orchestration — mint, driver resolution, transcripts, tool relay, delegation narration,\n * channel lifecycle, usage relay, teardown — lives in\n * {@link RealtimeSessionRuntime} (`@memberjunction/realtime-runtime`), which is framework-agnostic\n * and shared with every other host, including the React Native app. This class supplies the three\n * things that are genuinely Angular/browser: the `@Injectable` shell that lets components inject\n * it, the browser's media host, and the page-lifecycle wiring that sends the recording's terminal\n * request when the tab is hidden or unloaded (#5294).\n *\n * Consumers are unaffected by that split — the injectable token, class name, and public surface\n * are unchanged. Types that used to be declared in this file (`RealtimeCaption`,\n * `RealtimeConnectionState`, `RealtimeSessionRunOptions`, …) now come from\n * `@memberjunction/realtime-runtime`; import them from there directly, since MJ does not\n * re-export across package boundaries.\n */\n@Injectable({ providedIn: 'root' })\nexport class RealtimeSessionService extends RealtimeSessionRuntime {\n constructor() {\n super(new BrowserRealtimeMediaHost());\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n this.WireRecordingTerminalTriggers(window, document);\n }\n }\n\n /**\n * Sends the recording terminal (tail shard + counts, as a keepalive request) when the page is\n * going away: on `pagehide`, and when the page becomes hidden — the last event a mobile browser\n * reliably fires before it may discard a backgrounded tab without any unload event. Both handlers\n * only call the runtime's synchronous {@link RealtimeSessionRuntime.SendRecordingTerminal} (`pagehide`\n * through {@link RealtimeSessionRuntime.SendPageHideSignals}), which does no IndexedDB work and no\n * encoding: there is no time for either while a page is unloading.\n * It does nothing when no call is recording, and repeating it is safe (a sent tail is sealed, so a\n * call that continues after the tab comes back sends its later shards at new indexes).\n *\n * `pagehide` goes through {@link RealtimeSessionRuntime.SendPageHideSignals}, which also closes the\n * server session with a `keepalive` request when the page is going away for good (not entering the\n * back/forward cache); a hidden tab never closes it, the user may come back.\n *\n * There is deliberately no `beforeunload` prompt any more: shards already on the server plus the\n * terminal make closing the tab safe, and a `beforeunload` listener blocks the back/forward cache.\n *\n * The service is a root singleton, so these listeners live exactly as long as the app and are\n * never removed.\n *\n * @param page the page-lifecycle event target (`window`)\n * @param visibility the visibility source (`document`)\n */\n protected WireRecordingTerminalTriggers(page: PageHideEventTarget, visibility: VisibilityEventSource): void {\n page.addEventListener('pagehide', (event) => this.SendPageHideSignals({ Persisted: event.persisted }));\n visibility.addEventListener('visibilitychange', () => {\n if (visibility.visibilityState === 'hidden') {\n // Not final: the user may come back and the call go on, so the server only stamps the\n // counts and assembles after its grace period instead of rewriting the recording now.\n this.SendRecordingTerminal({ Final: false });\n }\n });\n }\n}\n\n/** The slice of `window` the terminal wiring needs; `window` itself satisfies it. */\nexport interface PageHideEventTarget {\n // case-violation-ok-legacy-back-compat: mirrors the DOM EventTarget API so `window` itself satisfies this interface\n addEventListener(type: 'pagehide', listener: (event: { readonly persisted: boolean }) => void): void;\n}\n\n/** The slice of `document` the terminal wiring needs; `document` itself satisfies it. */\nexport interface VisibilityEventSource {\n // case-violation-ok-legacy-back-compat: mirrors the DOM Document API so `document` itself satisfies this interface\n readonly visibilityState: DocumentVisibilityState;\n // case-violation-ok-legacy-back-compat: mirrors the DOM EventTarget API so `document` itself satisfies this interface\n addEventListener(type: 'visibilitychange', listener: () => void): void;\n}\n"]}
1
+ {"version":3,"file":"realtime-session.service.js","sourceRoot":"","sources":["../../../src/lib/services/realtime-session.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACH,4BAA4B,EAC5B,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;;AAEzE,gGAAgG;AAChG,mGAAmG;AACnG,gDAAgD;AAChD,EAAE;AACF,+FAA+F;AAC/F,0FAA0F;AAC1F,+FAA+F;AAC/F,kBAAkB;AAClB,wBAAwB,EAAE,CAAC;AAC3B,oBAAoB,EAAE,CAAC;AACvB,wBAAwB,EAAE,CAAC;AAC3B,4BAA4B,EAAE,CAAC;AAC/B,4BAA4B,EAAE,CAAC;AAC/B,iCAAiC,EAAE,CAAC;AACpC,qBAAqB,EAAE,CAAC;AACxB,wBAAwB,EAAE,CAAC;AAC3B,6BAA6B,EAAE,CAAC;AAEhC;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAC9D;QACI,KAAK,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACnE,IAAI,CAAC,6BAA6B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACO,6BAA6B,CAAC,IAAyB,EAAE,UAAiC;QAChG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACvG,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;YACjD,IAAI,UAAU,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;gBAC1C,sFAAsF;gBACtF,sFAAsF;gBACtF,IAAI,CAAC,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACjD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;gHAxCQ,sBAAsB;gEAAtB,sBAAsB,WAAtB,sBAAsB,mBADT,MAAM;;iFACnB,sBAAsB;cADlC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { RealtimeSessionRuntime } from '@memberjunction/realtime-runtime';\nimport {\n LoadAssemblyAIRealtimeClient,\n LoadAssemblyAIVoiceRealtimeClient,\n LoadElevenLabsRealtimeClient,\n LoadElevenRealtimeClient,\n LoadGeminiRealtimeClient,\n LoadHuggingFaceRealtimeClient,\n LoadOpenAILiveClient,\n LoadOpenAIRealtimeClient,\n LoadxAIRealtimeClient,\n} from '@memberjunction/ai-realtime-client';\nimport { BrowserRealtimeMediaHost } from './browser-realtime-media-host';\n\n// Tree-shaking prevention: client drivers are resolved dynamically through the ClassFactory (by\n// the server-reported Provider key), so these static calls are what keep their @RegisterClass side\n// effects from being eliminated by the bundler.\n//\n// NOTE: the interactive-channel plugins (resolved dynamically from the `MJ: AI Agent Channels`\n// registry by ClientPluginClass key) get the same treatment, but their Load calls live in\n// `conversations.module.ts` — plugins carry Angular surface COMPONENTS, and this service stays\n// component-free.\nLoadOpenAIRealtimeClient();\nLoadOpenAILiveClient();\nLoadGeminiRealtimeClient();\nLoadElevenLabsRealtimeClient();\nLoadAssemblyAIRealtimeClient();\nLoadAssemblyAIVoiceRealtimeClient();\nLoadxAIRealtimeClient();\nLoadElevenRealtimeClient();\nLoadHuggingFaceRealtimeClient();\n\n/**\n * Angular host for MemberJunction's realtime co-agent sessions.\n *\n * All orchestration — mint, driver resolution, transcripts, tool relay, delegation narration,\n * channel lifecycle, usage relay, teardown — lives in\n * {@link RealtimeSessionRuntime} (`@memberjunction/realtime-runtime`), which is framework-agnostic\n * and shared with every other host, including the React Native app. This class supplies the three\n * things that are genuinely Angular/browser: the `@Injectable` shell that lets components inject\n * it, the browser's media host, and the page-lifecycle wiring that sends the recording's terminal\n * request when the tab is hidden or unloaded (#5294).\n *\n * Consumers are unaffected by that split — the injectable token, class name, and public surface\n * are unchanged. Types that used to be declared in this file (`RealtimeCaption`,\n * `RealtimeConnectionState`, `RealtimeSessionRunOptions`, …) now come from\n * `@memberjunction/realtime-runtime`; import them from there directly, since MJ does not\n * re-export across package boundaries.\n */\n@Injectable({ providedIn: 'root' })\nexport class RealtimeSessionService extends RealtimeSessionRuntime {\n constructor() {\n super(new BrowserRealtimeMediaHost());\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n this.WireRecordingTerminalTriggers(window, document);\n }\n }\n\n /**\n * Sends the recording terminal (tail shard + counts, as a keepalive request) when the page is\n * going away: on `pagehide`, and when the page becomes hidden — the last event a mobile browser\n * reliably fires before it may discard a backgrounded tab without any unload event. Both handlers\n * only call the runtime's synchronous {@link RealtimeSessionRuntime.SendRecordingTerminal} (`pagehide`\n * through {@link RealtimeSessionRuntime.SendPageHideSignals}), which does no IndexedDB work and no\n * encoding: there is no time for either while a page is unloading.\n * It does nothing when no call is recording, and repeating it is safe (a sent tail is sealed, so a\n * call that continues after the tab comes back sends its later shards at new indexes).\n *\n * `pagehide` goes through {@link RealtimeSessionRuntime.SendPageHideSignals}, which also closes the\n * server session with a `keepalive` request when the page is going away for good (not entering the\n * back/forward cache); a hidden tab never closes it, the user may come back.\n *\n * There is deliberately no `beforeunload` prompt any more: shards already on the server plus the\n * terminal make closing the tab safe, and a `beforeunload` listener blocks the back/forward cache.\n *\n * The service is a root singleton, so these listeners live exactly as long as the app and are\n * never removed.\n *\n * @param page the page-lifecycle event target (`window`)\n * @param visibility the visibility source (`document`)\n */\n protected WireRecordingTerminalTriggers(page: PageHideEventTarget, visibility: VisibilityEventSource): void {\n page.addEventListener('pagehide', (event) => this.SendPageHideSignals({ Persisted: event.persisted }));\n visibility.addEventListener('visibilitychange', () => {\n if (visibility.visibilityState === 'hidden') {\n // Not final: the user may come back and the call go on, so the server only stamps the\n // counts and assembles after its grace period instead of rewriting the recording now.\n this.SendRecordingTerminal({ Final: false });\n }\n });\n }\n}\n\n/** The slice of `window` the terminal wiring needs; `window` itself satisfies it. */\nexport interface PageHideEventTarget {\n // case-violation-ok-legacy-back-compat: mirrors the DOM EventTarget API so `window` itself satisfies this interface\n addEventListener(type: 'pagehide', listener: (event: { readonly persisted: boolean }) => void): void;\n}\n\n/** The slice of `document` the terminal wiring needs; `document` itself satisfies it. */\nexport interface VisibilityEventSource {\n // case-violation-ok-legacy-back-compat: mirrors the DOM Document API so `document` itself satisfies this interface\n readonly visibilityState: DocumentVisibilityState;\n // case-violation-ok-legacy-back-compat: mirrors the DOM EventTarget API so `document` itself satisfies this interface\n addEventListener(type: 'visibilitychange', listener: () => void): void;\n}\n"]}
@@ -88,6 +88,12 @@ export declare class SearchService {
88
88
  /** @deprecated Use {@link SearchResults$}. */
89
89
  get searchResults$(): Observable<GroupedSearchResults>;
90
90
  private _provider;
91
+ /**
92
+ * Bumped by every {@link Search} call and by {@link ClearResults}. A search publishes its
93
+ * results and clears the busy flag only while its generation is still the newest, so a slow
94
+ * older search cannot replace newer results or end the busy state of a newer one.
95
+ */
96
+ private _searchGeneration;
91
97
  constructor(artifactPermissions: ArtifactPermissionService);
92
98
  /**
93
99
  * Set the metadata provider this service should use. When unset, falls back to Metadata.Provider.
@@ -103,6 +109,8 @@ export declare class SearchService {
103
109
  * Search across all content types
104
110
  */
105
111
  Search(query: string, environmentId: string, currentUser: UserInfo): Promise<GroupedSearchResults>;
112
+ /** True when no newer search or clear has started since the given generation. */
113
+ private isCurrentSearch;
106
114
  /** @deprecated Use {@link Search}. */
107
115
  search(query: string, environmentId: string, currentUser: UserInfo): Promise<GroupedSearchResults>;
108
116
  /**
@@ -125,6 +133,15 @@ export declare class SearchService {
125
133
  * Includes artifacts from both conversations and collections
126
134
  */
127
135
  private searchArtifacts;
136
+ /**
137
+ * The first collection each artifact sits in, keyed by lower-cased artifact ID.
138
+ *
139
+ * Two batched reads, each filtering only its own entity's columns (no subquery on another
140
+ * entity's view, so it runs on every provider): the artifacts' versions, then the
141
+ * collection rows for those versions. A failed read leaves the artifacts without a
142
+ * collection, as before.
143
+ */
144
+ private loadArtifactCollections;
128
145
  /**
129
146
  * Search collections by name and description
130
147
  * Includes both owned collections and shared collections user has access to
@@ -204,11 +221,11 @@ export declare class SearchService {
204
221
  /** @deprecated Use {@link ClearRecentSearches}. */
205
222
  clearRecentSearches(): void;
206
223
  /**
207
- * Load recent searches from localStorage
224
+ * Load recent searches from server-backed UserInfoEngine
208
225
  */
209
226
  private loadRecentSearches;
210
227
  /**
211
- * Save recent searches to localStorage
228
+ * Save recent searches via UserInfoEngine
212
229
  */
213
230
  private saveRecentSearches;
214
231
  static ɵfac: i0.ɵɵFactoryDeclaration<SearchService, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"search.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/search.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAe,MAAM,MAAM,CAAC;AAYhE,OAAO,EAAW,QAAQ,EAAY,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;;AAG1E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;AAE/F;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,eAAe,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,OAAO,CAAC;AAExG;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAaD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,SAAS,E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