@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime-artifact-workspace-surface.component.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,KAAK,EAGL,MAAM,GACP,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,eAAe,EAAkC,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;;;;;IAuB7D,8BAAsB;IACpB,uBAAwE;IACxE,4BAA2B;IAAA,0CAA0B;IAAA,iBAAI;IACzD,4BAA0B;IACxB,YACF;IACF,AADE,iBAAI,EACA;;;IAFF,eACF;IADE,oIACF;;;IAsBQ,gCAA8B;IAAA,YAA2B;IAAA,iBAAO;;;IAAlC,cAA2B;IAA3B,mDAA2B;;;;IAhB7D,kCAYC;IADC,gPAAS,sCAA4B,KAAC;IAEtC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B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAClD,CAAC;iVArLU,yCAAyC,yBAAzC,yCAAyC;6DAAzC,yCAAyC;YA1NlD,8BAAiE;YAS7D,AARF,2GAA8B,2EAQrB;YAyEX,iBAAM;;YAjFJ,cAgFC;YAhFD,oDAgFC;4BApFK,eAAe;;iFA6Nd,yCAAyC;cAhOrD,SAAS;6BACI,IAAI,YACN,wCAAwC,WACzC,CAAC,eAAe,CAAC,mBACT,uBAAuB,CAAC,MAAM,YACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFT;;kBAkJA,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAEL,KAAK;;kFAhBK,yCAAyC","sourcesContent":["import {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n OnDestroy,\n OnInit,\n inject,\n} from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport type { UserInfo } from '@memberjunction/core';\nimport { ArtifactsModule, type ArtifactVersionSavedEvent } from '@memberjunction/ng-artifacts';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport type { ArtifactWorkspaceEngine } from './artifact-workspace-engine';\nimport type {\n ArtifactNavigateToAnchorPayload,\n ArtifactSelectionAnchor,\n ArtifactSelectionDelta,\n ArtifactViewerNavigationAnchor,\n ArtifactWorkspaceRecord,\n} from './artifact-workspace-types';\n\n/**\n * Live tab-managed workspace surface for the `ArtifactWorkspace` realtime channel.\n * Hosts collaborative Docs, Spreadsheets, Slide Decks, and Whiteboards side-by-side\n * with a live voice/co-agent session via `<mj-artifact-viewer-panel>`.\n */\n@Component({\n standalone: true,\n selector: 'mj-realtime-artifact-workspace-surface',\n imports: [ArtifactsModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"aw-surface\" data-testid=\"artifact-workspace-surface\">\n @if (Instances.length === 0) {\n <div class=\"aw-empty\">\n <i class=\"fa-solid fa-file-lines aw-empty__icon\" aria-hidden=\"true\"></i>\n <p class=\"aw-empty__title\">No workspace document open</p>\n <p class=\"aw-empty__hint\">\n {{ AgentName }} can open or build Docs, Spreadsheets, and Slide Decks here for live collaboration.\n </p>\n </div>\n } @else {\n <div class=\"aw-tabbar\">\n <div class=\"aw-tabs\" role=\"tablist\" aria-label=\"Open workspace artifacts\">\n @for (record of Instances; track record.InstanceID) {\n <button\n type=\"button\"\n class=\"aw-tab\"\n role=\"tab\"\n [id]=\"'aw-tab-' + record.InstanceID\"\n [class.aw-tab--active]=\"record.InstanceID === ActiveID\"\n [attr.aria-selected]=\"record.InstanceID === ActiveID\"\n [attr.aria-controls]=\"'aw-panel-' + record.InstanceID\"\n [attr.tabindex]=\"record.InstanceID === ActiveID ? 0 : -1\"\n [attr.data-instance]=\"record.InstanceID\"\n [title]=\"record.Name\"\n (click)=\"SelectTab(record.InstanceID)\"\n >\n <i [class]=\"IconForType(record)\" aria-hidden=\"true\"></i>\n <span class=\"aw-tab__name\">{{ record.Name }}</span>\n @if (record.VersionNumber) {\n <span class=\"aw-tab__version\">v{{ record.VersionNumber }}</span>\n }\n </button>\n }\n </div>\n @if (!ReadOnly && ActiveRecord; as active) {\n <button\n type=\"button\"\n class=\"aw-close\"\n [attr.aria-label]=\"'Close ' + active.Name\"\n [title]=\"'Close ' + active.Name\"\n (click)=\"CloseTab(active.InstanceID)\"\n >\n <i class=\"fa-solid fa-xmark\" aria-hidden=\"true\"></i>\n </button>\n }\n </div>\n <div class=\"aw-panes\">\n @if (!IsRehydrating) {\n @for (record of Instances; track record.InstanceID) {\n <div\n class=\"aw-pane\"\n role=\"tabpanel\"\n [hidden]=\"record.InstanceID !== ActiveID\"\n [id]=\"'aw-panel-' + record.InstanceID\"\n [attr.aria-labelledby]=\"'aw-tab-' + record.InstanceID\"\n [attr.data-instance]=\"record.InstanceID\"\n >\n @if (CurrentUser; as user) {\n <mj-artifact-viewer-panel\n [artifactId]=\"record.ArtifactID\"\n [versionNumber]=\"record.VersionNumber\"\n [currentUser]=\"user\"\n [Provider]=\"Provider\"\n [environmentId]=\"EnvironmentID\"\n [refreshTrigger]=\"RefreshTrigger$\"\n [canEdit]=\"ReadOnly ? false : (record.CanEdit ?? false)\"\n [viewMode]=\"ReadOnly ? 'edit' : (record.ViewMode ?? 'edit')\"\n [navigationAnchor]=\"GetNavigationAnchorForRecord(record)\"\n [showHeader]=\"false\"\n [showTabs]=\"false\"\n [showSaveToCollection]=\"false\"\n [showCloseButton]=\"false\"\n [showMaximizeButton]=\"false\"\n (VersionSaved)=\"OnViewerVersionSaved(record.InstanceID, $event)\"\n (selectionChanged)=\"ReportSelectionAnchor(record.InstanceID, $event)\"\n ></mj-artifact-viewer-panel>\n }\n </div>\n }\n }\n </div>\n }\n </div>\n `,\n styles: [\n `\n :host {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n min-height: 0;\n }\n .aw-surface {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n min-height: 0;\n background: var(--mj-bg-surface);\n color: var(--mj-text-primary);\n }\n .aw-empty {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 24px;\n text-align: center;\n color: var(--mj-text-secondary);\n }\n .aw-empty__icon {\n font-size: 28px;\n color: var(--mj-brand-primary);\n opacity: 0.75;\n }\n .aw-empty__title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-primary);\n }\n .aw-empty__hint {\n margin: 0;\n font-size: 12px;\n max-width: 320px;\n }\n .aw-tabbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 6px 10px;\n background: var(--mj-bg-surface-sunken);\n border-bottom: 1px solid var(--mj-border-default);\n flex-shrink: 0;\n }\n .aw-tabs {\n display: flex;\n align-items: center;\n gap: 4px;\n overflow-x: auto;\n min-width: 0;\n }\n .aw-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 5px 10px;\n border-radius: 6px;\n border: 1px solid transparent;\n background: transparent;\n color: var(--mj-text-secondary);\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n white-space: nowrap;\n }\n .aw-tab:hover {\n background: var(--mj-bg-surface-hover);\n color: var(--mj-text-primary);\n }\n .aw-tab--active {\n background: var(--mj-bg-surface);\n border-color: var(--mj-border-default);\n color: var(--mj-text-primary);\n font-weight: 600;\n }\n .aw-tab__name {\n max-width: 180px;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .aw-tab__version {\n font-size: 11px;\n color: var(--mj-text-muted);\n }\n .aw-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n border-radius: 6px;\n border: 1px solid var(--mj-border-subtle);\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n cursor: pointer;\n flex-shrink: 0;\n }\n .aw-close:hover {\n background: var(--mj-bg-surface-hover);\n color: var(--mj-text-primary);\n }\n .aw-panes {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n }\n .aw-pane {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n }\n .aw-pane[hidden] {\n display: none;\n }\n .aw-pane > mj-artifact-viewer-panel {\n flex: 1;\n min-height: 0;\n }\n `,\n ],\n})\nexport class RealtimeArtifactWorkspaceSurfaceComponent\n extends BaseAngularComponent\n implements OnInit, OnDestroy\n{\n private _engine: ArtifactWorkspaceEngine | null = null;\n private subscription: Subscription | null = null;\n private navSubscription: Subscription | null = null;\n private anchorHighlightTimer: ReturnType<typeof setTimeout> | null = null;\n private readonly cdr = inject(ChangeDetectorRef);\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n @Input() public AgentName = 'The agent';\n @Input() public CurrentUser: UserInfo | null = null;\n @Input() public EnvironmentID = '';\n @Input() public ReadOnly = false;\n\n @Input()\n public set Engine(value: ArtifactWorkspaceEngine | null) {\n if (value === this._engine) {\n return;\n }\n this._engine = value;\n this.resubscribe();\n this.cdr.markForCheck();\n }\n public get Engine(): ArtifactWorkspaceEngine | null {\n return this._engine;\n }\n\n public Instances: readonly ArtifactWorkspaceRecord[] = [];\n public ActiveID: string | null = null;\n public IsRehydrating = false;\n public ActiveNavigationAnchor: ArtifactNavigateToAnchorPayload | null = null;\n private activeViewerAnchor: ArtifactViewerNavigationAnchor | null = null;\n public OnUserSelected: ((instanceId: string) => void) | null = null;\n public OnUserClosed: ((instanceId: string) => void) | null = null;\n public OnUserVersionSaved: ((instanceId: string, event: ArtifactVersionSavedEvent) => void) | null = null;\n public OnUserSelectionChanged: ((delta: ArtifactSelectionDelta) => void) | null = null;\n\n public get RefreshTrigger$() {\n return this._engine?.RefreshTrigger$;\n }\n\n public get ActiveRecord(): ArtifactWorkspaceRecord | null {\n return this.Instances.find((r) => r.InstanceID === this.ActiveID) ?? null;\n }\n\n public ngOnInit(): void {\n this.resubscribe();\n }\n\n public ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n this.subscription = null;\n this.navSubscription?.unsubscribe();\n this.navSubscription = null;\n if (this.anchorHighlightTimer) {\n clearTimeout(this.anchorHighlightTimer);\n this.anchorHighlightTimer = null;\n }\n }\n\n public SelectTab(instanceId: string): void {\n this._engine?.SetActive(instanceId);\n this.OnUserSelected?.(instanceId);\n }\n\n public CloseTab(instanceId: string): void {\n this._engine?.Remove(instanceId);\n this.OnUserClosed?.(instanceId);\n }\n\n public OnViewerVersionSaved(instanceId: string, event: ArtifactVersionSavedEvent): void {\n this._engine?.UpdateRecordMetadata(instanceId, {\n ArtifactVersionID: event.VersionID,\n VersionNumber: event.VersionNumber,\n });\n this.OnUserVersionSaved?.(instanceId, event);\n this.cdr.markForCheck();\n }\n\n public ReportSelectionAnchor(instanceId: string, anchor: ArtifactSelectionAnchor): void {\n const record = this._engine?.UpdateSelection(instanceId, anchor);\n if (!record) {\n return;\n }\n this.OnUserSelectionChanged?.({\n instanceId,\n artifactId: record.ArtifactID,\n artifactTypeName: record.ArtifactTypeName,\n anchor,\n });\n this.cdr.markForCheck();\n }\n\n public GetNavigationAnchorForRecord(record: ArtifactWorkspaceRecord): ArtifactViewerNavigationAnchor | null {\n if (!this.ActiveNavigationAnchor || !this.activeViewerAnchor) {\n return null;\n }\n if (\n this.ActiveNavigationAnchor.InstanceID === record.InstanceID ||\n this.ActiveNavigationAnchor.ArtifactID === record.ArtifactID\n ) {\n return this.activeViewerAnchor;\n }\n return null;\n }\n\n public GetActiveElement(): HTMLElement | null {\n return this.elementRef.nativeElement.querySelector<HTMLElement>('.aw-pane:not([hidden])');\n }\n\n public IconForType(record: ArtifactWorkspaceRecord): string {\n const t = record.ArtifactTypeName?.trim().toLowerCase() ?? '';\n if (t.includes('spreadsheet') || t.includes('excel')) {\n return 'fa-solid fa-table';\n }\n if (t.includes('presentation') || t.includes('slide')) {\n return 'fa-solid fa-display';\n }\n if (t.includes('whiteboard')) {\n return 'fa-solid fa-diagram-project';\n }\n return 'fa-solid fa-file-lines';\n }\n\n private resubscribe(): void {\n this.subscription?.unsubscribe();\n this.subscription = null;\n this.navSubscription?.unsubscribe();\n this.navSubscription = null;\n if (!this._engine) {\n this.Instances = [];\n this.ActiveID = null;\n this.IsRehydrating = false;\n this.ActiveNavigationAnchor = null;\n this.activeViewerAnchor = null;\n return;\n }\n this.syncFromEngine();\n this.subscription = this._engine.Changed$.subscribe(() => {\n this.syncFromEngine();\n this.cdr.markForCheck();\n });\n this.navSubscription = this._engine.NavigateAnchor$.subscribe((payload) => {\n this.ActiveNavigationAnchor = payload;\n this.activeViewerAnchor = {\n ...(payload.Sheet !== undefined ? { Sheet: payload.Sheet } : {}),\n ...(payload.Range !== undefined ? { Range: payload.Range } : {}),\n ...(payload.SlideNumber !== undefined ? { SlideNumber: payload.SlideNumber } : {}),\n ...(payload.SlideID !== undefined ? { SlideID: payload.SlideID } : {}),\n ...(payload.ElementID !== undefined ? { ElementID: payload.ElementID } : {}),\n ...(payload.Heading !== undefined ? { Heading: payload.Heading } : {}),\n ...(payload.BlockID !== undefined ? { BlockID: payload.BlockID } : {}),\n ...(payload.HighlightMs !== undefined ? { HighlightMs: payload.HighlightMs } : {}),\n };\n if (this.anchorHighlightTimer) {\n clearTimeout(this.anchorHighlightTimer);\n this.anchorHighlightTimer = null;\n }\n const highlightMs = payload.HighlightMs;\n if (typeof highlightMs === 'number' && highlightMs > 0) {\n this.anchorHighlightTimer = setTimeout(() => {\n if (this.ActiveNavigationAnchor === payload) {\n this.ActiveNavigationAnchor = null;\n this.activeViewerAnchor = null;\n this.cdr.markForCheck();\n }\n }, highlightMs);\n }\n this.cdr.markForCheck();\n });\n }\n\n private syncFromEngine(): void {\n if (!this._engine) {\n return;\n }\n this.Instances = this._engine.Instances;\n this.ActiveID = this._engine.ActiveID;\n this.IsRehydrating = this._engine.IsRehydrating;\n }\n}\n"]}
@@ -9,14 +9,41 @@ export declare const REALTIME_CAMERA_CHANNEL_NAME = "Camera";
9
9
  export declare const REALTIME_SCREEN_SHARE_CHANNEL_NAME = "ScreenShare";
10
10
  export declare const REALTIME_CAMERA_CHANNEL_CLASS = "RealtimeCameraChannel";
11
11
  export declare const REALTIME_SCREEN_SHARE_CHANNEL_CLASS = "RealtimeScreenShareChannel";
12
+ /**
13
+ * Viewport width (px) at and above which the call overlay renders its side-panel surface tabs
14
+ * (matches the `max-width: 860px` breakpoint in `realtime-surface-tabs.component.css` and
15
+ * `realtime-session-overlay.component.css`).
16
+ */
17
+ export declare const REALTIME_SIDE_PANEL_MIN_WIDTH_PX = 861;
18
+ /**
19
+ * True when the browser viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, where
20
+ * side-panel tabs are hidden and mobile browsers do not offer `getDisplayMedia` screen capture.
21
+ */
22
+ export declare function IsNarrowRealtimeViewport(): boolean;
23
+ /**
24
+ * Decides whether a channel plugin can participate in a narrow/mobile call where the side panel is hidden:
25
+ * headless channels (`ClientContext`), inline stage avatar video (`Avatar`), and camera PiP stay active,
26
+ * while side-panel tab surfaces (`Whiteboard`, `ArtifactWorkspace`, `RemoteBrowser`, `Media`,
27
+ * `InteractiveComponent`, `IdentityVerification`, etc.) and desktop screen share are omitted so the agent
28
+ * never acts on a surface the user cannot see.
29
+ */
30
+ export declare function IsMobileCallChannelAllowed(plugin: BaseRealtimeChannelClient): boolean;
12
31
  /**
13
32
  * The channels the conversations UI brings to its calls: the Camera and Screen Share channels are opt-in, so a call has
14
33
  * them only when its host (or the agent's or app's configuration) asks. An agent or app can still exclude them.
15
34
  */
16
35
  export declare const CONVERSATION_CALL_HOST_CHANNELS: readonly RealtimeHostChannelDeclaration[];
36
+ /**
37
+ * Reason surfaced to the voice co-agent when side-panel channels (Whiteboard, Workspace, etc.) are
38
+ * omitted below {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, so it explains why the surface cannot be
39
+ * shown on mobile or in a narrow window rather than claiming a permissions/access issue.
40
+ */
41
+ export declare const MOBILE_DESKTOP_ONLY_CHANNEL_REASON = "Requires a wider desktop view and is not available on mobile or narrow screens right now.";
17
42
  /**
18
43
  * The start options the conversations UI passes with every call it starts: the channels it brings, and the camera check
19
- * its call overlay shows the first time the user turns the camera on in a call.
44
+ * its call overlay shows the first time the user turns the camera on in a call. Evaluated once at call start: when the
45
+ * viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX} (where the side panel is hidden), screen share and
46
+ * side-panel tab channels are omitted at mint so the agent shares common ground with what the user can actually see.
20
47
  */
21
48
  export declare function ConversationCallStartOptions(): RealtimeSessionStartOptions;
22
49
  /** What tells the two capture channels apart. */
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-capture-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/capture/realtime-capture-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAqC,KAAK,yBAAyB,EAA4B,MAAM,8BAA8B,CAAC;AAC3I,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EACjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAA8B,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,gHAAgH;AAChH,eAAO,MAAM,4BAA4B,WAAW,CAAC;AACrD,eAAO,MAAM,kCAAkC,gBAAgB,CAAC;AAChE,eAAO,MAAM,6BAA6B,0BAA0B,CAAC;AACrE,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,SAAS,8BAA8B,EAGnF,CAAC;AAEH;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,2BAA2B,CAE1E;AAED,iDAAiD;AACjD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAID;;;;;;;;;;;;GAYG;AACH,8BAAsB,sBAAuB,SAAQ,yBAAyB,CAAC,+BAA+B,CAAC;IAC7G,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,WAAW,CAAsB;IAEzC,8DAA8D;IAC9D,SAAS,CAAC,QAAQ,KAAK,IAAI,IAAI,kBAAkB,CAAC;IAElD,mFAAmF;IACnF,IAAW,KAAK,IAAI,oBAAoB,CAGvC;IAED,uCAAuC;IACvC,IAAoB,WAAW,IAAI,mBAAmB,CAErD;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAoB,QAAQ,IAAI,MAAM,CAErC;IAED,IAAoB,OAAO,IAAI,MAAM,CAEpC;IAEe,aAAa,IAAI,yBAAyB;IA4B1C,QAAQ,IAAI,UAAU;IAItB,mBAAmB,IAAI,IAAI,CAAC,+BAA+B,CAAC;cAIzD,YAAY,IAAI,IAAI;IASvC,4FAA4F;cACzE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,yBAAyB;IAMxD,aAAa,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI;IAKtD,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI;IAY5D,aAAa,IAAI,IAAI;IAIrB,OAAO,IAAI,IAAI;IAU/B,yFAAyF;IACzF,OAAO,CAAC,aAAa;IAOrB,yEAAyE;IACzE,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,KAAK;CAed;AAED,qGAAqG;AACrG,qBACa,qBAAsB,SAAQ,sBAAsB;IAC/D,cAAuB,IAAI,IAAI,kBAAkB,CAahD;CACF;AAED,wGAAwG;AACxG,qBACa,0BAA2B,SAAQ,sBAAsB;IACpE,cAAuB,IAAI,IAAI,kBAAkB,CAchD;CACF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
1
+ {"version":3,"file":"realtime-capture-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/capture/realtime-capture-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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 -14,6 +14,42 @@ export const REALTIME_CAMERA_CHANNEL_NAME = 'Camera';
14
14
  export const REALTIME_SCREEN_SHARE_CHANNEL_NAME = 'ScreenShare';
15
15
  export const REALTIME_CAMERA_CHANNEL_CLASS = 'RealtimeCameraChannel';
16
16
  export const REALTIME_SCREEN_SHARE_CHANNEL_CLASS = 'RealtimeScreenShareChannel';
17
+ /**
18
+ * Viewport width (px) at and above which the call overlay renders its side-panel surface tabs
19
+ * (matches the `max-width: 860px` breakpoint in `realtime-surface-tabs.component.css` and
20
+ * `realtime-session-overlay.component.css`).
21
+ */
22
+ export const REALTIME_SIDE_PANEL_MIN_WIDTH_PX = 861;
23
+ /**
24
+ * True when the browser viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, where
25
+ * side-panel tabs are hidden and mobile browsers do not offer `getDisplayMedia` screen capture.
26
+ */
27
+ export function IsNarrowRealtimeViewport() {
28
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
29
+ return false;
30
+ }
31
+ return window.matchMedia(`(max-width: ${REALTIME_SIDE_PANEL_MIN_WIDTH_PX - 1}px)`).matches;
32
+ }
33
+ /**
34
+ * Decides whether a channel plugin can participate in a narrow/mobile call where the side panel is hidden:
35
+ * headless channels (`ClientContext`), inline stage avatar video (`Avatar`), and camera PiP stay active,
36
+ * while side-panel tab surfaces (`Whiteboard`, `ArtifactWorkspace`, `RemoteBrowser`, `Media`,
37
+ * `InteractiveComponent`, `IdentityVerification`, etc.) and desktop screen share are omitted so the agent
38
+ * never acts on a surface the user cannot see.
39
+ */
40
+ export function IsMobileCallChannelAllowed(plugin) {
41
+ const descriptor = plugin.GetDescriptor();
42
+ if (descriptor.DisplayPolicy === 'headless') {
43
+ return true;
44
+ }
45
+ if (plugin.ShowsAgentVideo) {
46
+ return true;
47
+ }
48
+ if (plugin.CaptureKind != null) {
49
+ return plugin.CaptureKind !== 'screen';
50
+ }
51
+ return plugin.SurfacePlacement.Default !== 'tab';
52
+ }
17
53
  /**
18
54
  * The channels the conversations UI brings to its calls: the Camera and Screen Share channels are opt-in, so a call has
19
55
  * them only when its host (or the agent's or app's configuration) asks. An agent or app can still exclude them.
@@ -22,11 +58,27 @@ export const CONVERSATION_CALL_HOST_CHANNELS = Object.freeze([
22
58
  { ClientPluginClass: REALTIME_CAMERA_CHANNEL_CLASS },
23
59
  { ClientPluginClass: REALTIME_SCREEN_SHARE_CHANNEL_CLASS },
24
60
  ]);
61
+ /**
62
+ * Reason surfaced to the voice co-agent when side-panel channels (Whiteboard, Workspace, etc.) are
63
+ * omitted below {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, so it explains why the surface cannot be
64
+ * shown on mobile or in a narrow window rather than claiming a permissions/access issue.
65
+ */
66
+ export const MOBILE_DESKTOP_ONLY_CHANNEL_REASON = 'Requires a wider desktop view and is not available on mobile or narrow screens right now.';
25
67
  /**
26
68
  * The start options the conversations UI passes with every call it starts: the channels it brings, and the camera check
27
- * its call overlay shows the first time the user turns the camera on in a call.
69
+ * its call overlay shows the first time the user turns the camera on in a call. Evaluated once at call start: when the
70
+ * viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX} (where the side panel is hidden), screen share and
71
+ * side-panel tab channels are omitted at mint so the agent shares common ground with what the user can actually see.
28
72
  */
29
73
  export function ConversationCallStartOptions() {
74
+ if (IsNarrowRealtimeViewport()) {
75
+ return {
76
+ HostChannels: [{ ClientPluginClass: REALTIME_CAMERA_CHANNEL_CLASS }],
77
+ ChannelFilter: IsMobileCallChannelAllowed,
78
+ ChannelFilterReason: MOBILE_DESKTOP_ONLY_CHANNEL_REASON,
79
+ CameraCheck: true,
80
+ };
81
+ }
30
82
  return { HostChannels: [...CONVERSATION_CALL_HOST_CHANNELS], CameraCheck: true };
31
83
  }
32
84
  const STATUS_VALUES = ['off', 'asked', 'starting', 'on', 'failed'];
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-capture-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/real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3B,OAAO,EAAE,qBAAqB;YAC9B,YAAY,EACV,uHAAuH;gBACvH,mHAAmH;gBACnH,uHAAuH;gBACvH,mBAAmB;YACrB,MAAM,EAAE,mHAAmH;YAC3H,UAAU,EAAE,kEAAkE;SAC/E,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,0BAA0B;IADtC,aAAa,CAAC,yBAAyB,EAAE,mCAAmC,CAAC;GACjE,0BAA0B,CAgBtC;;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,sEAAsE;AACxE,CAAC","sourcesContent":["import type { Type } from '@angular/core';\nimport type { Subscription } from 'rxjs';\nimport { RegisterClass } from '@memberjunction/global';\nimport type { JSONObject } from '@memberjunction/ai';\nimport { REALTIME_CHANNEL_CONTRACT_VERSION, type RealtimeChannelDescriptor, type RealtimeChannelNoun } from '@memberjunction/ai-core-plus';\nimport {\n BaseRealtimeChannelClient,\n type ChannelExposureSettings,\n type RealtimeCaptureKind,\n type RealtimeChannelVerbResult,\n type RealtimeHostChannelDeclaration,\n type RealtimeSessionStartOptions,\n} from '@memberjunction/realtime-runtime';\nimport { RealtimeCaptureModel, type RealtimeCaptureChange } from './realtime-capture-model';\nimport { RealtimeCaptureSurfaceComponent } from './realtime-capture-surface.component';\n\n/** The registry keys (`MJ: AI Agent Channels` → `Name` and `ClientPluginClass`) of the two capture channels. */\nexport const REALTIME_CAMERA_CHANNEL_NAME = 'Camera';\nexport const REALTIME_SCREEN_SHARE_CHANNEL_NAME = 'ScreenShare';\nexport const REALTIME_CAMERA_CHANNEL_CLASS = 'RealtimeCameraChannel';\nexport const REALTIME_SCREEN_SHARE_CHANNEL_CLASS = 'RealtimeScreenShareChannel';\n\n/**\n * The channels the conversations UI brings to its calls: the Camera and Screen Share channels are opt-in, so a call has\n * them only when its host (or the agent's or app's configuration) asks. An agent or app can still exclude them.\n */\nexport const CONVERSATION_CALL_HOST_CHANNELS: readonly RealtimeHostChannelDeclaration[] = Object.freeze([\n { ClientPluginClass: REALTIME_CAMERA_CHANNEL_CLASS },\n { ClientPluginClass: REALTIME_SCREEN_SHARE_CHANNEL_CLASS },\n]);\n\n/**\n * The start options the conversations UI passes with every call it starts: the channels it brings, and the camera check\n * its call overlay shows the first time the user turns the camera on in a call.\n */\nexport function ConversationCallStartOptions(): RealtimeSessionStartOptions {\n return { HostChannels: [...CONVERSATION_CALL_HOST_CHANNELS], CameraCheck: true };\n}\n\n/** What tells the two capture channels apart. */\ninterface CaptureChannelText {\n Kind: RealtimeCaptureKind;\n Key: string;\n DisplayName: string;\n TabIcon: string;\n Instructions: string;\n Status: string;\n ReasonHint: string;\n}\n\nconst STATUS_VALUES = ['off', 'asked', 'starting', 'on', 'failed'];\n\n/**\n * A channel that fronts one of the runtime's captures: the user's camera or a shared screen. It is the agent's contract\n * for asking to see it, and the capture's policy (`CaptureKind`): the runtime starts the capture only while this channel\n * is in the call and may show the agent pixels.\n *\n * **The agent only asks.** Opening the channel, with a `reason`, is the request: the channel's surface appears where its\n * registry row places it (picture-in-picture) and shows the ask, with the user's choice of turning it on or \"Not now\".\n * Only the user starts or stops the capture; the agent learns what happened from the channel's `status`.\n *\n * Both channels are `on-demand` (listed in the agent's catalog, mounted when opened), `opt-in` (a call has them only when\n * its host or configuration asks for them; the conversations UI brings them, see {@link CONVERSATION_CALL_HOST_CHANNELS})\n * and may show the agent pixels. Their server half is the generic `ClientOnlyChannelServer`.\n */\nexport abstract class RealtimeCaptureChannel extends BaseRealtimeChannelClient<RealtimeCaptureSurfaceComponent> {\n private model: RealtimeCaptureModel | null = null;\n private capturesSub: Subscription | null = null;\n private sourcesSub: Subscription | null = null;\n private surfaceSubs: Subscription[] = [];\n\n /** What makes this channel the camera or the screen share. */\n protected abstract get Text(): CaptureChannelText;\n\n /** The channel's state. Public so the surface and tests share the one instance. */\n public get Model(): RealtimeCaptureModel {\n this.model ??= new RealtimeCaptureModel(this.CaptureKind);\n return this.model;\n }\n\n /** The capture this channel fronts. */\n public override get CaptureKind(): RealtimeCaptureKind {\n return this.Text.Kind;\n }\n\n public get ChannelName(): string {\n return this.Text.Key;\n }\n\n public override get TabTitle(): string {\n return this.Text.DisplayName;\n }\n\n public override get TabIcon(): string {\n return this.Text.TabIcon;\n }\n\n public override GetDescriptor(): RealtimeChannelDescriptor {\n const text = this.Text;\n return {\n Key: text.Key,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: text.DisplayName,\n OwningPackage: '@memberjunction/ng-conversations',\n Instructions: text.Instructions,\n Nouns: this.nouns(text),\n Verbs: [],\n Inputs: {\n type: 'object',\n properties: { reason: { type: 'string', maxLength: 200, description: text.ReasonHint } },\n additionalProperties: false,\n },\n Events: [\n { Name: 'asked', Description: 'Your request is showing to the user.' },\n { Name: 'declined', Description: 'The user said \"Not now\" to your request.' },\n { Name: 'started', Description: 'The user turned it on; you receive it as video.' },\n { Name: 'stopped', Description: 'The user turned it off.' },\n { Name: 'failed', Description: 'It could not start; the payload says why.' },\n ],\n DisplayPolicy: 'on-demand',\n DefaultAvailability: 'opt-in',\n MaxExposure: 'pixels',\n };\n }\n\n public override GetState(): JSONObject {\n return this.Model.ToState();\n }\n\n public override GetSurfaceComponent(): Type<RealtimeCaptureSurfaceComponent> {\n return RealtimeCaptureSurfaceComponent;\n }\n\n protected override OnInitialize(): void {\n this.Model.OnChange((change) => this.onModelChange(change));\n this.Model.SetAgentCanSee(this.Exposure === 'pixels');\n // The sources first, so the model knows whether the capture's frames are sent before it hears the capture is on.\n this.sourcesSub = this.Context?.VideoSources$?.subscribe((sources) => this.Model.FollowVideoSources(sources)) ?? null;\n this.capturesSub =\n this.Context?.Captures$?.subscribe((states) => this.Model.FollowCapture(this.CaptureKind === 'camera' ? states.Camera : states.Screen)) ?? null;\n }\n\n /** The agent's request: opening the channel, again or for the first time, asks the user. */\n protected override OnOpen(inputs: JSONObject): RealtimeChannelVerbResult {\n const reason = typeof inputs['reason'] === 'string' ? inputs['reason'] : null;\n const asked = this.Model.Ask(reason);\n return { Success: true, Result: { asked, status: this.Model.View.Status } };\n }\n\n public override ApplyExposure(settings: ChannelExposureSettings): void {\n super.ApplyExposure(settings);\n this.Model.SetAgentCanSee(this.Exposure === 'pixels');\n }\n\n public override BindSurface(instance: RealtimeCaptureSurfaceComponent): void {\n this.unbindSurfaceOutputs();\n instance.Model = this.Model;\n instance.AgentName = this.Context?.AgentName ?? 'The assistant';\n this.surfaceSubs = [\n instance.StartRequested.subscribe(() => void this.Context?.StartCapture?.(this.CaptureKind)),\n instance.DeclineRequested.subscribe(() => this.Model.Decline()),\n instance.StopRequested.subscribe(() => this.Context?.StopCapture?.(this.CaptureKind)),\n instance.ChangeRequested.subscribe(() => this.changeShare()),\n ];\n }\n\n public override UnbindSurface(): void {\n this.unbindSurfaceOutputs();\n }\n\n public override Dispose(): void {\n this.capturesSub?.unsubscribe();\n this.capturesSub = null;\n this.sourcesSub?.unsubscribe();\n this.sourcesSub = null;\n this.unbindSurfaceOutputs();\n this.Model.OnChange(null);\n super.Dispose();\n }\n\n /** Streams the change's event, and tells the agent (one coalesced note) what changed. */\n private onModelChange(change: RealtimeCaptureChange): void {\n if (change.Event) {\n this.EmitChannelEvent(change.Event.Name, change.Event.Payload);\n }\n this.RecordChange({ Author: change.Event?.Name === 'asked' ? 'agent' : change.Event ? 'user' : 'system' });\n }\n\n /** \"Change\" on a share: stops it and asks the browser's picker again. */\n private changeShare(): void {\n this.Context?.StopCapture?.(this.CaptureKind);\n void this.Context?.StartCapture?.(this.CaptureKind);\n }\n\n private unbindSurfaceOutputs(): void {\n this.surfaceSubs.forEach((sub) => sub.unsubscribe());\n this.surfaceSubs = [];\n }\n\n private nouns(text: CaptureChannelText): RealtimeChannelNoun[] {\n const nouns: RealtimeChannelNoun[] = [\n { Name: 'status', Description: text.Status, Schema: { type: 'string', enum: STATUS_VALUES } },\n { Name: 'reason', Description: 'The reason your standing request shows the user, or empty.', Schema: { type: 'string' } },\n { Name: 'problem', Description: 'Why it last failed to start, in plain words, or empty.', Schema: { type: 'string' } },\n ];\n if (this.CaptureKind === 'screen') {\n nouns.push({\n Name: 'surface',\n Description: 'What the user shares while on: their entire screen, a window or a browser tab (\"unknown\" when the browser does not say).',\n Schema: { type: 'string', enum: ['screen', 'window', 'tab', 'unknown'] },\n });\n }\n return nouns;\n }\n}\n\n/** The CAMERA channel: the agent asks to see the user's camera; only the user turns it on or off. */\n@RegisterClass(BaseRealtimeChannelClient, REALTIME_CAMERA_CHANNEL_CLASS)\nexport class RealtimeCameraChannel extends RealtimeCaptureChannel {\n protected override get Text(): CaptureChannelText {\n return {\n Kind: 'camera',\n Key: REALTIME_CAMERA_CHANNEL_NAME,\n DisplayName: 'Camera',\n TabIcon: 'fa-solid fa-video',\n Instructions:\n \"The user's camera. To see it, open this channel with a short `reason` the user will read (for example, to look at \" +\n 'something they are holding). That only asks: the user decides, and only they turn the camera on or off, so never say ' +\n 'you turned it on. Once it is on you receive it as video. If the user says no, do not ask again unless they bring it up.',\n Status: 'off; asked (your request is showing); starting; on (you receive the camera); failed (see problem).',\n ReasonHint: 'Why you want to see their camera, in a few words they will read.',\n };\n }\n}\n\n/** The SCREEN SHARE channel: the agent asks to see the user's screen; only the user shares or stops. */\n@RegisterClass(BaseRealtimeChannelClient, REALTIME_SCREEN_SHARE_CHANNEL_CLASS)\nexport class RealtimeScreenShareChannel extends RealtimeCaptureChannel {\n protected override get Text(): CaptureChannelText {\n return {\n Kind: 'screen',\n Key: REALTIME_SCREEN_SHARE_CHANNEL_NAME,\n DisplayName: 'Screen share',\n TabIcon: 'fa-solid fa-display',\n Instructions:\n \"The user's screen. To see it, open this channel with a short `reason` the user will read (for example, to look at an \" +\n 'error they mention). That only asks: the user picks a screen, window or tab in their browser and can stop at any ' +\n 'time, so never say you started it. Once shared you receive it as video. If the user says no, do not ask again unless ' +\n 'they bring it up.',\n Status: 'off; asked (your request is showing); starting (the user is choosing); on (you receive it); failed (see problem).',\n ReasonHint: 'Why you want to see their screen, in a few words they will read.',\n };\n }\n}\n\n/**\n * Tree-shaking prevention: the channels are resolved through the ClassFactory by their registry rows' `ClientPluginClass`\n * keys, so this static call keeps their `@RegisterClass` side effects alive.\n */\nexport function LoadRealtimeCaptureChannels(): void {\n // intentional no-op: the import side effect performs the registration\n}\n"]}
1
+ {"version":3,"file":"realtime-capture-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/capture/realtime-capture-channel.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,iCAAiC,EAA4D,MAAM,8BAA8B,CAAC;AAC3I,OAAO,EACL,yBAAyB,GAM1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAA8B,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,gHAAgH;AAChH,MAAM,CAAC,MAAM,4BAA4B,GAAG,QAAQ,CAAC;AACrD,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAChE,MAAM,CAAC,MAAM,6BAA6B,GAAG,uBAAuB,CAAC;AACrE,MAAM,CAAC,MAAM,mCAAmC,GAAG,4BAA4B,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7E,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,gCAAgC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC7F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAiC;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAC1C,IAAI,UAAU,CAAC,aAAa,K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ACL,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,kCAAkC;YACvC,WAAW,EAAE,cAAc;YAC3B,OAAO,EAAE,qBAAqB;YAC9B,YAAY,EACV,uHAAuH;gBACvH,mHAAmH;gBACnH,uHAAuH;gBACvH,mBAAmB;YACrB,MAAM,EAAE,mHAAmH;YAC3H,UAAU,EAAE,kEAAkE;SAC/E,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,0BAA0B;IADtC,aAAa,CAAC,yBAAyB,EAAE,mCAAmC,CAAC;GACjE,0BAA0B,CAgBtC;;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,sEAAsE;AACxE,CAAC","sourcesContent":["import type { Type } from '@angular/core';\nimport type { Subscription } from 'rxjs';\nimport { RegisterClass } from '@memberjunction/global';\nimport type { JSONObject } from '@memberjunction/ai';\nimport { REALTIME_CHANNEL_CONTRACT_VERSION, type RealtimeChannelDescriptor, type RealtimeChannelNoun } from '@memberjunction/ai-core-plus';\nimport {\n BaseRealtimeChannelClient,\n type ChannelExposureSettings,\n type RealtimeCaptureKind,\n type RealtimeChannelVerbResult,\n type RealtimeHostChannelDeclaration,\n type RealtimeSessionStartOptions,\n} from '@memberjunction/realtime-runtime';\nimport { RealtimeCaptureModel, type RealtimeCaptureChange } from './realtime-capture-model';\nimport { RealtimeCaptureSurfaceComponent } from './realtime-capture-surface.component';\n\n/** The registry keys (`MJ: AI Agent Channels` → `Name` and `ClientPluginClass`) of the two capture channels. */\nexport const REALTIME_CAMERA_CHANNEL_NAME = 'Camera';\nexport const REALTIME_SCREEN_SHARE_CHANNEL_NAME = 'ScreenShare';\nexport const REALTIME_CAMERA_CHANNEL_CLASS = 'RealtimeCameraChannel';\nexport const REALTIME_SCREEN_SHARE_CHANNEL_CLASS = 'RealtimeScreenShareChannel';\n\n/**\n * Viewport width (px) at and above which the call overlay renders its side-panel surface tabs\n * (matches the `max-width: 860px` breakpoint in `realtime-surface-tabs.component.css` and\n * `realtime-session-overlay.component.css`).\n */\nexport const REALTIME_SIDE_PANEL_MIN_WIDTH_PX = 861;\n\n/**\n * True when the browser viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, where\n * side-panel tabs are hidden and mobile browsers do not offer `getDisplayMedia` screen capture.\n */\nexport function IsNarrowRealtimeViewport(): boolean {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return false;\n }\n return window.matchMedia(`(max-width: ${REALTIME_SIDE_PANEL_MIN_WIDTH_PX - 1}px)`).matches;\n}\n\n/**\n * Decides whether a channel plugin can participate in a narrow/mobile call where the side panel is hidden:\n * headless channels (`ClientContext`), inline stage avatar video (`Avatar`), and camera PiP stay active,\n * while side-panel tab surfaces (`Whiteboard`, `ArtifactWorkspace`, `RemoteBrowser`, `Media`,\n * `InteractiveComponent`, `IdentityVerification`, etc.) and desktop screen share are omitted so the agent\n * never acts on a surface the user cannot see.\n */\nexport function IsMobileCallChannelAllowed(plugin: BaseRealtimeChannelClient): boolean {\n const descriptor = plugin.GetDescriptor();\n if (descriptor.DisplayPolicy === 'headless') {\n return true;\n }\n if (plugin.ShowsAgentVideo) {\n return true;\n }\n if (plugin.CaptureKind != null) {\n return plugin.CaptureKind !== 'screen';\n }\n return plugin.SurfacePlacement.Default !== 'tab';\n}\n\n/**\n * The channels the conversations UI brings to its calls: the Camera and Screen Share channels are opt-in, so a call has\n * them only when its host (or the agent's or app's configuration) asks. An agent or app can still exclude them.\n */\nexport const CONVERSATION_CALL_HOST_CHANNELS: readonly RealtimeHostChannelDeclaration[] = Object.freeze([\n { ClientPluginClass: REALTIME_CAMERA_CHANNEL_CLASS },\n { ClientPluginClass: REALTIME_SCREEN_SHARE_CHANNEL_CLASS },\n]);\n\n/**\n * Reason surfaced to the voice co-agent when side-panel channels (Whiteboard, Workspace, etc.) are\n * omitted below {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX}, so it explains why the surface cannot be\n * shown on mobile or in a narrow window rather than claiming a permissions/access issue.\n */\nexport const MOBILE_DESKTOP_ONLY_CHANNEL_REASON =\n 'Requires a wider desktop view and is not available on mobile or narrow screens right now.';\n\n/**\n * The start options the conversations UI passes with every call it starts: the channels it brings, and the camera check\n * its call overlay shows the first time the user turns the camera on in a call. Evaluated once at call start: when the\n * viewport is narrower than {@link REALTIME_SIDE_PANEL_MIN_WIDTH_PX} (where the side panel is hidden), screen share and\n * side-panel tab channels are omitted at mint so the agent shares common ground with what the user can actually see.\n */\nexport function ConversationCallStartOptions(): RealtimeSessionStartOptions {\n if (IsNarrowRealtimeViewport()) {\n return {\n HostChannels: [{ ClientPluginClass: REALTIME_CAMERA_CHANNEL_CLASS }],\n ChannelFilter: IsMobileCallChannelAllowed,\n ChannelFilterReason: MOBILE_DESKTOP_ONLY_CHANNEL_REASON,\n CameraCheck: true,\n };\n }\n return { HostChannels: [...CONVERSATION_CALL_HOST_CHANNELS], CameraCheck: true };\n}\n\n/** What tells the two capture channels apart. */\ninterface CaptureChannelText {\n Kind: RealtimeCaptureKind;\n Key: string;\n DisplayName: string;\n TabIcon: string;\n Instructions: string;\n Status: string;\n ReasonHint: string;\n}\n\nconst STATUS_VALUES = ['off', 'asked', 'starting', 'on', 'failed'];\n\n/**\n * A channel that fronts one of the runtime's captures: the user's camera or a shared screen. It is the agent's contract\n * for asking to see it, and the capture's policy (`CaptureKind`): the runtime starts the capture only while this channel\n * is in the call and may show the agent pixels.\n *\n * **The agent only asks.** Opening the channel, with a `reason`, is the request: the channel's surface appears where its\n * registry row places it (picture-in-picture) and shows the ask, with the user's choice of turning it on or \"Not now\".\n * Only the user starts or stops the capture; the agent learns what happened from the channel's `status`.\n *\n * Both channels are `on-demand` (listed in the agent's catalog, mounted when opened), `opt-in` (a call has them only when\n * its host or configuration asks for them; the conversations UI brings them, see {@link CONVERSATION_CALL_HOST_CHANNELS})\n * and may show the agent pixels. Their server half is the generic `ClientOnlyChannelServer`.\n */\nexport abstract class RealtimeCaptureChannel extends BaseRealtimeChannelClient<RealtimeCaptureSurfaceComponent> {\n private model: RealtimeCaptureModel | null = null;\n private capturesSub: Subscription | null = null;\n private sourcesSub: Subscription | null = null;\n private surfaceSubs: Subscription[] = [];\n\n /** What makes this channel the camera or the screen share. */\n protected abstract get Text(): CaptureChannelText;\n\n /** The channel's state. Public so the surface and tests share the one instance. */\n public get Model(): RealtimeCaptureModel {\n this.model ??= new RealtimeCaptureModel(this.CaptureKind);\n return this.model;\n }\n\n /** The capture this channel fronts. */\n public override get CaptureKind(): RealtimeCaptureKind {\n return this.Text.Kind;\n }\n\n public get ChannelName(): string {\n return this.Text.Key;\n }\n\n public override get TabTitle(): string {\n return this.Text.DisplayName;\n }\n\n public override get TabIcon(): string {\n return this.Text.TabIcon;\n }\n\n public override GetDescriptor(): RealtimeChannelDescriptor {\n const text = this.Text;\n return {\n Key: text.Key,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: text.DisplayName,\n OwningPackage: '@memberjunction/ng-conversations',\n Instructions: text.Instructions,\n Nouns: this.nouns(text),\n Verbs: [],\n Inputs: {\n type: 'object',\n properties: { reason: { type: 'string', maxLength: 200, description: text.ReasonHint } },\n additionalProperties: false,\n },\n Events: [\n { Name: 'asked', Description: 'Your request is showing to the user.' },\n { Name: 'declined', Description: 'The user said \"Not now\" to your request.' },\n { Name: 'started', Description: 'The user turned it on; you receive it as video.' },\n { Name: 'stopped', Description: 'The user turned it off.' },\n { Name: 'failed', Description: 'It could not start; the payload says why.' },\n ],\n DisplayPolicy: 'on-demand',\n DefaultAvailability: 'opt-in',\n MaxExposure: 'pixels',\n };\n }\n\n public override GetState(): JSONObject {\n return this.Model.ToState();\n }\n\n public override GetSurfaceComponent(): Type<RealtimeCaptureSurfaceComponent> {\n return RealtimeCaptureSurfaceComponent;\n }\n\n protected override OnInitialize(): void {\n this.Model.OnChange((change) => this.onModelChange(change));\n this.Model.SetAgentCanSee(this.Exposure === 'pixels');\n // The sources first, so the model knows whether the capture's frames are sent before it hears the capture is on.\n this.sourcesSub = this.Context?.VideoSources$?.subscribe((sources) => this.Model.FollowVideoSources(sources)) ?? null;\n this.capturesSub =\n this.Context?.Captures$?.subscribe((states) => this.Model.FollowCapture(this.CaptureKind === 'camera' ? states.Camera : states.Screen)) ?? null;\n }\n\n /** The agent's request: opening the channel, again or for the first time, asks the user. */\n protected override OnOpen(inputs: JSONObject): RealtimeChannelVerbResult {\n const reason = typeof inputs['reason'] === 'string' ? inputs['reason'] : null;\n const asked = this.Model.Ask(reason);\n return { Success: true, Result: { asked, status: this.Model.View.Status } };\n }\n\n public override ApplyExposure(settings: ChannelExposureSettings): void {\n super.ApplyExposure(settings);\n this.Model.SetAgentCanSee(this.Exposure === 'pixels');\n }\n\n public override BindSurface(instance: RealtimeCaptureSurfaceComponent): void {\n this.unbindSurfaceOutputs();\n instance.Model = this.Model;\n instance.AgentName = this.Context?.AgentName ?? 'The assistant';\n this.surfaceSubs = [\n instance.StartRequested.subscribe(() => void this.Context?.StartCapture?.(this.CaptureKind)),\n instance.DeclineRequested.subscribe(() => this.Model.Decline()),\n instance.StopRequested.subscribe(() => this.Context?.StopCapture?.(this.CaptureKind)),\n instance.ChangeRequested.subscribe(() => this.changeShare()),\n ];\n }\n\n public override UnbindSurface(): void {\n this.unbindSurfaceOutputs();\n }\n\n public override Dispose(): void {\n this.capturesSub?.unsubscribe();\n this.capturesSub = null;\n this.sourcesSub?.unsubscribe();\n this.sourcesSub = null;\n this.unbindSurfaceOutputs();\n this.Model.OnChange(null);\n super.Dispose();\n }\n\n /** Streams the change's event, and tells the agent (one coalesced note) what changed. */\n private onModelChange(change: RealtimeCaptureChange): void {\n if (change.Event) {\n this.EmitChannelEvent(change.Event.Name, change.Event.Payload);\n }\n this.RecordChange({ Author: change.Event?.Name === 'asked' ? 'agent' : change.Event ? 'user' : 'system' });\n }\n\n /** \"Change\" on a share: stops it and asks the browser's picker again. */\n private changeShare(): void {\n this.Context?.StopCapture?.(this.CaptureKind);\n void this.Context?.StartCapture?.(this.CaptureKind);\n }\n\n private unbindSurfaceOutputs(): void {\n this.surfaceSubs.forEach((sub) => sub.unsubscribe());\n this.surfaceSubs = [];\n }\n\n private nouns(text: CaptureChannelText): RealtimeChannelNoun[] {\n const nouns: RealtimeChannelNoun[] = [\n { Name: 'status', Description: text.Status, Schema: { type: 'string', enum: STATUS_VALUES } },\n { Name: 'reason', Description: 'The reason your standing request shows the user, or empty.', Schema: { type: 'string' } },\n { Name: 'problem', Description: 'Why it last failed to start, in plain words, or empty.', Schema: { type: 'string' } },\n ];\n if (this.CaptureKind === 'screen') {\n nouns.push({\n Name: 'surface',\n Description: 'What the user shares while on: their entire screen, a window or a browser tab (\"unknown\" when the browser does not say).',\n Schema: { type: 'string', enum: ['screen', 'window', 'tab', 'unknown'] },\n });\n }\n return nouns;\n }\n}\n\n/** The CAMERA channel: the agent asks to see the user's camera; only the user turns it on or off. */\n@RegisterClass(BaseRealtimeChannelClient, REALTIME_CAMERA_CHANNEL_CLASS)\nexport class RealtimeCameraChannel extends RealtimeCaptureChannel {\n protected override get Text(): CaptureChannelText {\n return {\n Kind: 'camera',\n Key: REALTIME_CAMERA_CHANNEL_NAME,\n DisplayName: 'Camera',\n TabIcon: 'fa-solid fa-video',\n Instructions:\n \"The user's camera. To see it, open this channel with a short `reason` the user will read (for example, to look at \" +\n 'something they are holding). That only asks: the user decides, and only they turn the camera on or off, so never say ' +\n 'you turned it on. Once it is on you receive it as video. If the user says no, do not ask again unless they bring it up.',\n Status: 'off; asked (your request is showing); starting; on (you receive the camera); failed (see problem).',\n ReasonHint: 'Why you want to see their camera, in a few words they will read.',\n };\n }\n}\n\n/** The SCREEN SHARE channel: the agent asks to see the user's screen; only the user shares or stops. */\n@RegisterClass(BaseRealtimeChannelClient, REALTIME_SCREEN_SHARE_CHANNEL_CLASS)\nexport class RealtimeScreenShareChannel extends RealtimeCaptureChannel {\n protected override get Text(): CaptureChannelText {\n return {\n Kind: 'screen',\n Key: REALTIME_SCREEN_SHARE_CHANNEL_NAME,\n DisplayName: 'Screen share',\n TabIcon: 'fa-solid fa-display',\n Instructions:\n \"The user's screen. To see it, open this channel with a short `reason` the user will read (for example, to look at an \" +\n 'error they mention). That only asks: the user picks a screen, window or tab in their browser and can stop at any ' +\n 'time, so never say you started it. Once shared you receive it as video. If the user says no, do not ask again unless ' +\n 'they bring it up.',\n Status: 'off; asked (your request is showing); starting (the user is choosing); on (you receive it); failed (see problem).',\n ReasonHint: 'Why you want to see their screen, in a few words they will read.',\n };\n }\n}\n\n/**\n * Tree-shaking prevention: the channels are resolved through the ClassFactory by their registry rows' `ClientPluginClass`\n * keys, so this static call keeps their `@RegisterClass` side effects alive.\n */\nexport function LoadRealtimeCaptureChannels(): void {\n // intentional no-op: the import side effect performs the registration\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"client-context-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAc,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAKL,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,0HAA0H;AAC1H,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,4BAA4B,gBAAgB,CAAC;AAE1D,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAsC/C;;;GAGG;AACH,qBACa,oBAAqB,SAAQ,yBAAyB,CAAC,MAAM,CAAC;IACzE,4FAA4F;IAC5F,OAAO,CAAC,aAAa,CAA6B;IAClD,gHAAgH;IAChH,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,oEAAoE;IACpE,OAAO,CAAC,eAAe,CAAmC;IAC1D,0EAA0E;IAC1E,OAAO,CAAC,aAAa,CAA8C;IAEnE,+DAA+D;IAC/D,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,0FAA0F;IAC1F,IAAW,cAAc,IAAI,MAAM,CAElC;IAED,kFAAkF;IAClF,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,6CAA6C;IACtC,kBAAkB,IAAI,sBAAsB,EAAE;IAIrD;;;;OAIG;IACa,aAAa,IAAI,yBAAyB;IAgB1D;;;;;;;;OAQG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBhF,+FAA+F;YACjF,kBAAkB;IAchC,+GAA+G;IAC/G,OAAO,CAAC,wBAAwB;IAahC,qCAAqC;IAC9B,WAAW,IAAI,IAAI;IAI1B;;;;;OAKG;cACgB,YAAY,IAAI,IAAI;IA0BvC;;;OAGG;IACI,YAAY,IAAI,IAAI;IA0B3B,qEAAqE;IACrE,OAAO,CAAC,SAAS;IAkBjB,wHAAwH;IACxH,OAAO,CAAC,WAAW;IAanB,gGAAgG;IAChF,OAAO,IAAI,IAAI;CAWhC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
1
+ {"version":3,"file":"client-context-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAc,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAKL,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,0HAA0H;AAC1H,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,4BAA4B,gBAAgB,CAAC;AAE1D,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAsC/C;;;GAGG;AACH,qBACa,oBAAqB,SAAQ,yBAAyB,CAAC,MAAM,CAAC;IACzE,4FAA4F;IAC5F,OAAO,CAAC,aAAa,CAA6B;IAClD,gHAAgH;IAChH,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,oEAAoE;IACpE,OAAO,CAAC,eAAe,CAAmC;IAC1D,0EAA0E;IAC1E,OAAO,CAAC,aAAa,CAA8C;IAEnE,+DAA+D;IAC/D,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,0FAA0F;IAC1F,IAAW,cAAc,IAAI,MAAM,CAElC;IAED,kFAAkF;IAClF,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,6CAA6C;IACtC,kBAAkB,IAAI,sBAAsB,EAAE;IAIrD;;;;OAIG;IACa,aAAa,IAAI,yBAAyB;IAkB1D;;;;;;;;OAQG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwChF,+FAA+F;YACjF,kBAAkB;IAchC,+GAA+G;IAC/G,OAAO,CAAC,wBAAwB;IAahC,qCAAqC;IAC9B,WAAW,IAAI,IAAI;IAI1B;;;;;OAKG;cACgB,YAAY,IAAI,IAAI;IA0BvC;;;OAGG;IACI,YAAY,IAAI,IAAI;IA0B3B,qEAAqE;IACrE,OAAO,CAAC,SAAS;IAkBjB,wHAAwH;IACxH,OAAO,CAAC,WAAW;IAanB,gGAAgG;IAChF,OAAO,IAAI,IAAI;CAWhC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
@@ -47,12 +47,12 @@ export const CONTEXT_TOOL_NAME = 'ContextTool';
47
47
  const CONTEXT_TOOL_DEFINITION = {
48
48
  Name: CONTEXT_TOOL_NAME,
49
49
  Description: "Perform an action in the application the user is currently in, or on one of the interactive " +
50
- "channels listed in your channel notes. The set of valid actions (the client tools and the things " +
51
- "you can do on the current surface) is provided to you continuously as context — only call actions " +
52
- "listed as currently available. Pass the action name and its parameters. To act on an interactive " +
53
- "channel instead of the app, also pass `target` naming the channel (and, for a channel that has " +
54
- "several, the instance); to open a channel that is available but not open yet, use action \"open\" " +
55
- "with that target.",
50
+ "channels listed in your channel notes, OR peek read-only at what surface/tab the user is looking at " +
51
+ "right now. To inspect the active tab (Workspace, Whiteboard, Remote Browser, Media, Activity) and " +
52
+ "each open channel's state without mutating anything, pass action \"get_workspace_state\" (or " +
53
+ "\"get_active_surface\" / \"peek_workspace\") with empty params {}. Otherwise, pass an action from your " +
54
+ "context catalog; to act on an interactive channel instead of the app, pass `target` naming the channel " +
55
+ "(and instance if multi-instance); to open an available channel, use action \"open\" with that target.",
56
56
  ParametersSchema: {
57
57
  type: 'object',
58
58
  properties: {
@@ -120,7 +120,9 @@ let ClientContextChannel = class ClientContextChannel extends BaseRealtimeChanne
120
120
  Version: REALTIME_CHANNEL_CONTRACT_VERSION,
121
121
  DisplayName: this.TabTitle,
122
122
  Instructions: 'Keeps you aware of where the user is in the app and lets you act there through ContextTool. ' +
123
- 'It is not itself something to operate.',
123
+ 'For a read-only peek at which surface/tab the user is looking at and open channel states ' +
124
+ '(Workspace, Whiteboard, Remote Browser, Media, Activity), call ContextTool with ' +
125
+ '{ "action": "get_workspace_state", "params": {} } (or "get_active_surface" / "peek_workspace").',
124
126
  Nouns: [],
125
127
  Verbs: [],
126
128
  DisplayPolicy: 'headless',
@@ -145,6 +147,20 @@ let ClientContextChannel = class ClientContextChannel extends BaseRealtimeChanne
145
147
  if (!parsed.action) {
146
148
  return JSON.stringify({ success: false, output: 'ContextTool requires an "action" naming the tool to run.' });
147
149
  }
150
+ if (!parsed.target) {
151
+ const normalizedAction = parsed.action.trim().toLowerCase();
152
+ if (normalizedAction === 'get_workspace_state' ||
153
+ normalizedAction === 'get_active_surface' ||
154
+ normalizedAction === 'peek_workspace') {
155
+ return JSON.stringify({
156
+ success: true,
157
+ output: {
158
+ surfaceSnapshot: this.Context?.GetSurfaceSnapshot?.() ?? null,
159
+ appContext: this.baselineSnapshot ?? null,
160
+ },
161
+ });
162
+ }
163
+ }
148
164
  if (parsed.target) {
149
165
  return this.applyChannelAction(parsed.action, parsed.params, parsed.target);
150
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client-context-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,iCAAiC,GAGlC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,0HAA0H;AAC1H,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,wFAAwF;AACxF,MAAM,CAAC,MAAM,4BAA4B,GAAG,aAAa,CAAC;AAE1D,kGAAkG;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C,uGAAuG;AACvG,MAAM,uBAAuB,GAA2B;IACtD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,8FAA8F;QAC9F,mGAAmG;QACnG,oGAAoG;QACpG,mGAAmG;QACnG,iGAAiG;QACjG,oGAAoG;QACpG,mBAAmB;IACrB,gBAAgB,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yFAAyF;aACvG;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gEAAgE;aAC9E;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yFAAyF;gBACtG,UAAU,EAAE;oBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mDAA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7B,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF,CAAA;AApOY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,EAAE,sBAAsB,CAAC;GACpD,oBAAoB,CAoOhC;;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,gFAAgF;AAClF,CAAC","sourcesContent":["/**\n * @fileoverview The headless **Client Context** channel — the browser half of the live wire that\n * keeps the realtime co-agent continuously aware of the user's app context and lets it act in the\n * app through a single stable proxy tool.\n *\n * Paired with `ClientContextChannelServer` (`@memberjunction/ai-agents`) via the seeded\n * `MJ: AI Agent Channels` row (`Name: 'ClientContextChannel'`, `IsHeadless: 1`,\n * `ClientPluginClass: 'ClientContextChannel'`).\n *\n * Two responsibilities, both client-side (no server round-trip in the client-direct topology):\n *\n * 1. **Perception (streaming).** It subscribes to the host's live app-context stream\n * ({@link RealtimeChannelContext.AppContext$}, fed by Explorer from `NavigationService`) and, on\n * every change, pushes a compact `SendContextNote` so the model always knows where the user is,\n * what they see, and which tools/agents are available — the *continuous* half of client-context\n * delivery (the session-start half is injected into the companion prompt server-side at mint).\n *\n * 2. **Action (the `ContextTool` proxy).** It declares ONE stable tool, `ContextTool`, so the\n * provider tool surface never changes mid-session (which connect-bound providers reject). The\n * model invokes any currently-available surface client tool via `ContextTool({ action, params })`;\n * the channel routes that to the host's {@link RealtimeChannelContext.ExecuteClientTool} (which runs\n * the surface handler the host registered from `SetAgentClientTools`) and returns a structured\n * result the model narrates.\n *\n * **Headless:** no surface component — it never mounts a tab (`GetSurfaceComponent` stays `null`;\n * `BindSurface` is a no-op). It is a wire, not a panel.\n *\n * @module @memberjunction/ng-conversations\n */\nimport { RegisterClass } from '@memberjunction/global';\nimport { JSONObject, RealtimeToolDefinition } from '@memberjunction/ai';\nimport {\n DiffAppContextSnapshot,\n FormatAppContextNote,\n REALTIME_CHANNEL_CONTRACT_VERSION,\n type AppContextSnapshot,\n type RealtimeChannelDescriptor,\n} from '@memberjunction/ai-core-plus';\nimport { Subscription } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { BaseRealtimeChannelClient, type RealtimeContextActionResult } from '@memberjunction/realtime-runtime';\n\n/** Coalescing window (ms) that collapses synchronous/rapid navigation + dashboard hydration bursts into one wire note. */\nexport const CLIENT_CONTEXT_COALESCE_MS = 250;\n\n/** Replaceable reconnect-memory state key for the active application screen context. */\nexport const APP_CONTEXT_MEMORY_STATE_KEY = 'app-context';\n\n/** The stable name of the single proxy tool this channel registers with the realtime provider. */\nexport const CONTEXT_TOOL_NAME = 'ContextTool';\n\n/** The single stable proxy tool — declared once; the live catalog of valid `action`s rides context. */\nconst CONTEXT_TOOL_DEFINITION: RealtimeToolDefinition = {\n Name: CONTEXT_TOOL_NAME,\n Description:\n \"Perform an action in the application the user is currently in, or on one of the interactive \" +\n \"channels listed in your channel notes. The set of valid actions (the client tools and the things \" +\n \"you can do on the current surface) is provided to you continuously as context — only call actions \" +\n \"listed as currently available. Pass the action name and its parameters. To act on an interactive \" +\n \"channel instead of the app, also pass `target` naming the channel (and, for a channel that has \" +\n \"several, the instance); to open a channel that is available but not open yet, use action \\\"open\\\" \" +\n \"with that target.\",\n ParametersSchema: {\n type: 'object',\n properties: {\n action: {\n type: 'string',\n description: 'The name of a currently-available action/tool to run (from the context you were given).'\n },\n params: {\n type: 'object',\n description: \"The action's parameters, matching its advertised input schema.\"\n },\n target: {\n type: 'object',\n description: 'Set this to act on an interactive channel rather than the app. Omit it for app actions.',\n properties: {\n channel: { type: 'string', description: 'The channel to address (from your channel notes).' },\n instance: { type: 'string', description: 'Which instance, for a channel that has several. Usually omitted.' }\n },\n required: ['channel']\n }\n },\n required: ['action']\n }\n};\n\n/**\n * The headless Client Context channel client. One instance per realtime session (created by the\n * session service from the `MJ: AI Agent Channels` registry — never construct directly).\n */\n@RegisterClass(BaseRealtimeChannelClient, 'ClientContextChannel')\nexport class ClientContextChannel extends BaseRealtimeChannelClient<object> {\n /** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */\n private appContextSub: Subscription | null = null;\n /** Last snapshot known by the live model (seeded from initial BehaviorSubject value or last flushed update). */\n private baselineSnapshot: AppContextSnapshot | null = null;\n /** Latest snapshot buffered inside the active coalescing window. */\n private pendingSnapshot: AppContextSnapshot | null = null;\n /** Active burst-coalescing timer; cleared on flush or {@link Dispose}. */\n private coalesceTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */\n public get ChannelName(): string {\n return 'ClientContextChannel';\n }\n\n /** Routing prefix — the single `ContextTool` matches `ContextTool`.startsWith(prefix). */\n public get ToolNamePrefix(): string {\n return CONTEXT_TOOL_NAME;\n }\n\n /** Headless — never rendered, but the abstract contract requires a label/icon. */\n public get TabTitle(): string {\n return 'App Context';\n }\n public get TabIcon(): string {\n return 'fa-solid fa-satellite-dish';\n }\n\n /** Declares the single stable proxy tool. */\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return [CONTEXT_TOOL_DEFINITION];\n }\n\n /**\n * The channel's self-description. It has NO verbs of its own: it is the door, not a room — `ContextTool`\n * runs app client tools, or addresses another channel through `target`. Declaring that explicitly keeps\n * it from being addressed as if it were a channel with things to do.\n */\n public override GetDescriptor(): RealtimeChannelDescriptor {\n return {\n Key: this.ChannelName,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: this.TabTitle,\n Instructions:\n 'Keeps you aware of where the user is in the app and lets you act there through ContextTool. ' +\n 'It is not itself something to operate.',\n Nouns: [],\n Verbs: [],\n DisplayPolicy: 'headless',\n DefaultAvailability: 'all-sessions',\n MaxExposure: 'state'\n };\n }\n\n /**\n * Routes a `ContextTool({ action, params, target? })` call. With a `target` the call is handed to the\n * runtime, which validates it against the addressed channel's verb schema (a malformed call comes back\n * as a structured, model-recoverable error) and opens an `on-demand` channel when asked; without one it\n * runs the host's registered surface client tool, exactly as before.\n *\n * Tolerant: malformed args, a missing host executor, or an unknown/throwing tool all serialize to\n * a structured `{ success: false, output }` the model narrates (never throws).\n */\n public async ApplyAgentTool(toolName: string, argsJson: string): Promise<string> {\n if (toolName !== CONTEXT_TOOL_NAME) {\n return JSON.stringify({ success: false, output: `Unknown context tool \"${toolName}\".` });\n }\n const parsed = this.parseArgs(argsJson);\n if (!parsed.action) {\n return JSON.stringify({ success: false, output: 'ContextTool requires an \"action\" naming the tool to run.' });\n }\n if (parsed.target) {\n return this.applyChannelAction(parsed.action, parsed.params, parsed.target);\n }\n const executor = this.Context?.ExecuteClientTool;\n if (!executor) {\n return JSON.stringify({\n success: false,\n output: 'No app surface is available to perform that action right now.'\n });\n }\n const result = await executor(parsed.action, parsed.params);\n return result.Success\n ? JSON.stringify({ success: true, output: result.Result ?? 'Done.' })\n : JSON.stringify({ success: false, output: result.ErrorMessage ?? 'The action could not be performed.' });\n }\n\n /** Runs a channel-addressed call through the runtime and serializes its structured outcome. */\n private async applyChannelAction(\n action: string,\n params: Record<string, unknown>,\n target: { channel: string; instance?: string }\n ): Promise<string> {\n const dispatch = this.Context?.DispatchContextAction;\n if (!dispatch) {\n return JSON.stringify({ success: false, output: 'Channel actions are not available in this session.' });\n }\n // The params came off the wire as JSON, so they are JSON by construction.\n const outcome = await dispatch({ Target: { Channel: target.channel, Instance: target.instance }, Action: action, Params: params as JSONObject });\n return JSON.stringify(this.serializeDispatchOutcome(outcome));\n }\n\n /** The model-facing shape of a dispatch outcome: success carries the result; a refusal carries what to fix. */\n private serializeDispatchOutcome(outcome: RealtimeContextActionResult): Record<string, unknown> {\n if (outcome.Success) {\n return { success: true, output: outcome.Result ?? 'Done.' };\n }\n return {\n success: false,\n output: outcome.ErrorMessage ?? 'The action could not be performed.',\n errorCode: outcome.ErrorCode,\n ...(outcome.Details ? { details: outcome.Details } : {}),\n ...(outcome.Available ? { available: outcome.Available } : {})\n };\n }\n\n /** Headless — no surface to bind. */\n public BindSurface(): void {\n /* no-op: this channel renders no surface */\n }\n\n /**\n * Subscribes to the host's live app-context stream and streams each coalesced delta to the model as a\n * compact context note while keeping only the latest full snapshot in reconnect memory under\n * `StateKey: 'app-context'`. Null-safe — hosts that supply no `AppContext$` (custom apps) simply get\n * no streaming, and the session-start prompt injection still applies.\n */\n protected override OnInitialize(): void {\n const stream = this.Context?.AppContext$;\n if (!stream) {\n return;\n }\n let subscribingSynchronously = true;\n this.appContextSub = stream\n .pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))\n .subscribe((snapshot) => {\n if (!snapshot) {\n return;\n }\n if (subscribingSynchronously) {\n // BehaviorSubject's current value was already injected into SystemPrompt at session mint:\n // record it as the diff baseline without sending a duplicate t=0 wire note.\n this.baselineSnapshot = snapshot;\n return;\n }\n this.pendingSnapshot = snapshot;\n if (this.coalesceTimer === null) {\n this.coalesceTimer = setTimeout(() => this.FlushPending(), CLIENT_CONTEXT_COALESCE_MS);\n }\n });\n subscribingSynchronously = false;\n }\n\n /**\n * Immediately flushes any buffered `AppContext$` update, emitting a compact delta on the live wire\n * and recording the full latest snapshot under `StateKey: 'app-context'` for reconnect continuity.\n */\n public FlushPending(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n const latest = this.pendingSnapshot;\n this.pendingSnapshot = null;\n if (!latest) {\n return;\n }\n const delta = DiffAppContextSnapshot(this.baselineSnapshot, latest);\n this.baselineSnapshot = latest;\n if (!delta) {\n return;\n }\n const wireNote = FormatAppContextNote(delta);\n if (!wireNote) {\n return;\n }\n const fullMemoryNote = FormatAppContextNote(latest);\n this.Context?.SendContextNote(wireNote, {\n StateKey: APP_CONTEXT_MEMORY_STATE_KEY,\n ...(fullMemoryNote && fullMemoryNote !== wireNote ? { MemoryText: fullMemoryNote } : {}),\n });\n }\n\n /** Tolerantly parses the `{ action, params, target? }` arguments. */\n private parseArgs(argsJson: string): {\n action: string | null;\n params: Record<string, unknown>;\n target: { channel: string; instance?: string } | null;\n } {\n try {\n const parsed = JSON.parse(argsJson) as { action?: unknown; params?: unknown; target?: unknown };\n const action = typeof parsed.action === 'string' && parsed.action.trim().length > 0 ? parsed.action.trim() : null;\n const params =\n parsed.params && typeof parsed.params === 'object' && !Array.isArray(parsed.params)\n ? (parsed.params as Record<string, unknown>)\n : {};\n return { action, params, target: this.parseTarget(parsed.target) };\n } catch {\n return { action: null, params: {}, target: null };\n }\n }\n\n /** Reads a `target` — `{ channel, instance? }` — or `null` when absent or unusable (the call is then an app action). */\n private parseTarget(raw: unknown): { channel: string; instance?: string } | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n return null;\n }\n const target = raw as { channel?: unknown; instance?: unknown };\n const channel = typeof target.channel === 'string' ? target.channel.trim() : '';\n if (channel.length === 0) {\n return null;\n }\n const instance = typeof target.instance === 'string' && target.instance.trim().length > 0 ? target.instance.trim() : undefined;\n return instance ? { channel, instance } : { channel };\n }\n\n /** Unsubscribes the app-context stream, cancels any pending coalescer timer, and tears down. */\n public override Dispose(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n this.pendingSnapshot = null;\n this.baselineSnapshot = null;\n this.appContextSub?.unsubscribe();\n this.appContextSub = null;\n super.Dispose();\n }\n}\n\n/**\n * Tree-shaking prevention for {@link ClientContextChannel}'s `@RegisterClass` registration. Called\n * from a static code path in `conversations.module.ts` so the registration always executes —\n * mirroring every other realtime channel client.\n */\nexport function LoadClientContextChannel(): void {\n // no-op — the import + call create a static reference bundlers cannot eliminate\n}\n"]}
1
+ {"version":3,"file":"client-context-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAA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AC,aAAa,KAAK,IAAI,EAAE,CAAC;YAChC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF,CAAA;AAtPY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,EAAE,sBAAsB,CAAC;GACpD,oBAAoB,CAsPhC;;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,gFAAgF;AAClF,CAAC","sourcesContent":["/**\n * @fileoverview The headless **Client Context** channel — the browser half of the live wire that\n * keeps the realtime co-agent continuously aware of the user's app context and lets it act in the\n * app through a single stable proxy tool.\n *\n * Paired with `ClientContextChannelServer` (`@memberjunction/ai-agents`) via the seeded\n * `MJ: AI Agent Channels` row (`Name: 'ClientContextChannel'`, `IsHeadless: 1`,\n * `ClientPluginClass: 'ClientContextChannel'`).\n *\n * Two responsibilities, both client-side (no server round-trip in the client-direct topology):\n *\n * 1. **Perception (streaming).** It subscribes to the host's live app-context stream\n * ({@link RealtimeChannelContext.AppContext$}, fed by Explorer from `NavigationService`) and, on\n * every change, pushes a compact `SendContextNote` so the model always knows where the user is,\n * what they see, and which tools/agents are available — the *continuous* half of client-context\n * delivery (the session-start half is injected into the companion prompt server-side at mint).\n *\n * 2. **Action (the `ContextTool` proxy).** It declares ONE stable tool, `ContextTool`, so the\n * provider tool surface never changes mid-session (which connect-bound providers reject). The\n * model invokes any currently-available surface client tool via `ContextTool({ action, params })`;\n * the channel routes that to the host's {@link RealtimeChannelContext.ExecuteClientTool} (which runs\n * the surface handler the host registered from `SetAgentClientTools`) and returns a structured\n * result the model narrates.\n *\n * **Headless:** no surface component — it never mounts a tab (`GetSurfaceComponent` stays `null`;\n * `BindSurface` is a no-op). It is a wire, not a panel.\n *\n * @module @memberjunction/ng-conversations\n */\nimport { RegisterClass } from '@memberjunction/global';\nimport { JSONObject, RealtimeToolDefinition } from '@memberjunction/ai';\nimport {\n DiffAppContextSnapshot,\n FormatAppContextNote,\n REALTIME_CHANNEL_CONTRACT_VERSION,\n type AppContextSnapshot,\n type RealtimeChannelDescriptor,\n} from '@memberjunction/ai-core-plus';\nimport { Subscription } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { BaseRealtimeChannelClient, type RealtimeContextActionResult } from '@memberjunction/realtime-runtime';\n\n/** Coalescing window (ms) that collapses synchronous/rapid navigation + dashboard hydration bursts into one wire note. */\nexport const CLIENT_CONTEXT_COALESCE_MS = 250;\n\n/** Replaceable reconnect-memory state key for the active application screen context. */\nexport const APP_CONTEXT_MEMORY_STATE_KEY = 'app-context';\n\n/** The stable name of the single proxy tool this channel registers with the realtime provider. */\nexport const CONTEXT_TOOL_NAME = 'ContextTool';\n\n/** The single stable proxy tool — declared once; the live catalog of valid `action`s rides context. */\nconst CONTEXT_TOOL_DEFINITION: RealtimeToolDefinition = {\n Name: CONTEXT_TOOL_NAME,\n Description:\n \"Perform an action in the application the user is currently in, or on one of the interactive \" +\n \"channels listed in your channel notes, OR peek read-only at what surface/tab the user is looking at \" +\n \"right now. To inspect the active tab (Workspace, Whiteboard, Remote Browser, Media, Activity) and \" +\n \"each open channel's state without mutating anything, pass action \\\"get_workspace_state\\\" (or \" +\n \"\\\"get_active_surface\\\" / \\\"peek_workspace\\\") with empty params {}. Otherwise, pass an action from your \" +\n \"context catalog; to act on an interactive channel instead of the app, pass `target` naming the channel \" +\n \"(and instance if multi-instance); to open an available channel, use action \\\"open\\\" with that target.\",\n ParametersSchema: {\n type: 'object',\n properties: {\n action: {\n type: 'string',\n description: 'The name of a currently-available action/tool to run (from the context you were given).'\n },\n params: {\n type: 'object',\n description: \"The action's parameters, matching its advertised input schema.\"\n },\n target: {\n type: 'object',\n description: 'Set this to act on an interactive channel rather than the app. Omit it for app actions.',\n properties: {\n channel: { type: 'string', description: 'The channel to address (from your channel notes).' },\n instance: { type: 'string', description: 'Which instance, for a channel that has several. Usually omitted.' }\n },\n required: ['channel']\n }\n },\n required: ['action']\n }\n};\n\n/**\n * The headless Client Context channel client. One instance per realtime session (created by the\n * session service from the `MJ: AI Agent Channels` registry — never construct directly).\n */\n@RegisterClass(BaseRealtimeChannelClient, 'ClientContextChannel')\nexport class ClientContextChannel extends BaseRealtimeChannelClient<object> {\n /** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */\n private appContextSub: Subscription | null = null;\n /** Last snapshot known by the live model (seeded from initial BehaviorSubject value or last flushed update). */\n private baselineSnapshot: AppContextSnapshot | null = null;\n /** Latest snapshot buffered inside the active coalescing window. */\n private pendingSnapshot: AppContextSnapshot | null = null;\n /** Active burst-coalescing timer; cleared on flush or {@link Dispose}. */\n private coalesceTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */\n public get ChannelName(): string {\n return 'ClientContextChannel';\n }\n\n /** Routing prefix — the single `ContextTool` matches `ContextTool`.startsWith(prefix). */\n public get ToolNamePrefix(): string {\n return CONTEXT_TOOL_NAME;\n }\n\n /** Headless — never rendered, but the abstract contract requires a label/icon. */\n public get TabTitle(): string {\n return 'App Context';\n }\n public get TabIcon(): string {\n return 'fa-solid fa-satellite-dish';\n }\n\n /** Declares the single stable proxy tool. */\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return [CONTEXT_TOOL_DEFINITION];\n }\n\n /**\n * The channel's self-description. It has NO verbs of its own: it is the door, not a room — `ContextTool`\n * runs app client tools, or addresses another channel through `target`. Declaring that explicitly keeps\n * it from being addressed as if it were a channel with things to do.\n */\n public override GetDescriptor(): RealtimeChannelDescriptor {\n return {\n Key: this.ChannelName,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: this.TabTitle,\n Instructions:\n 'Keeps you aware of where the user is in the app and lets you act there through ContextTool. ' +\n 'For a read-only peek at which surface/tab the user is looking at and open channel states ' +\n '(Workspace, Whiteboard, Remote Browser, Media, Activity), call ContextTool with ' +\n '{ \"action\": \"get_workspace_state\", \"params\": {} } (or \"get_active_surface\" / \"peek_workspace\").',\n Nouns: [],\n Verbs: [],\n DisplayPolicy: 'headless',\n DefaultAvailability: 'all-sessions',\n MaxExposure: 'state'\n };\n }\n\n /**\n * Routes a `ContextTool({ action, params, target? })` call. With a `target` the call is handed to the\n * runtime, which validates it against the addressed channel's verb schema (a malformed call comes back\n * as a structured, model-recoverable error) and opens an `on-demand` channel when asked; without one it\n * runs the host's registered surface client tool, exactly as before.\n *\n * Tolerant: malformed args, a missing host executor, or an unknown/throwing tool all serialize to\n * a structured `{ success: false, output }` the model narrates (never throws).\n */\n public async ApplyAgentTool(toolName: string, argsJson: string): Promise<string> {\n if (toolName !== CONTEXT_TOOL_NAME) {\n return JSON.stringify({ success: false, output: `Unknown context tool \"${toolName}\".` });\n }\n const parsed = this.parseArgs(argsJson);\n if (!parsed.action) {\n return JSON.stringify({ success: false, output: 'ContextTool requires an \"action\" naming the tool to run.' });\n }\n if (!parsed.target) {\n const normalizedAction = parsed.action.trim().toLowerCase();\n if (\n normalizedAction === 'get_workspace_state' ||\n normalizedAction === 'get_active_surface' ||\n normalizedAction === 'peek_workspace'\n ) {\n return JSON.stringify({\n success: true,\n output: {\n surfaceSnapshot: this.Context?.GetSurfaceSnapshot?.() ?? null,\n appContext: this.baselineSnapshot ?? null,\n },\n });\n }\n }\n if (parsed.target) {\n return this.applyChannelAction(parsed.action, parsed.params, parsed.target);\n }\n const executor = this.Context?.ExecuteClientTool;\n if (!executor) {\n return JSON.stringify({\n success: false,\n output: 'No app surface is available to perform that action right now.'\n });\n }\n const result = await executor(parsed.action, parsed.params);\n return result.Success\n ? JSON.stringify({ success: true, output: result.Result ?? 'Done.' })\n : JSON.stringify({ success: false, output: result.ErrorMessage ?? 'The action could not be performed.' });\n }\n\n /** Runs a channel-addressed call through the runtime and serializes its structured outcome. */\n private async applyChannelAction(\n action: string,\n params: Record<string, unknown>,\n target: { channel: string; instance?: string }\n ): Promise<string> {\n const dispatch = this.Context?.DispatchContextAction;\n if (!dispatch) {\n return JSON.stringify({ success: false, output: 'Channel actions are not available in this session.' });\n }\n // The params came off the wire as JSON, so they are JSON by construction.\n const outcome = await dispatch({ Target: { Channel: target.channel, Instance: target.instance }, Action: action, Params: params as JSONObject });\n return JSON.stringify(this.serializeDispatchOutcome(outcome));\n }\n\n /** The model-facing shape of a dispatch outcome: success carries the result; a refusal carries what to fix. */\n private serializeDispatchOutcome(outcome: RealtimeContextActionResult): Record<string, unknown> {\n if (outcome.Success) {\n return { success: true, output: outcome.Result ?? 'Done.' };\n }\n return {\n success: false,\n output: outcome.ErrorMessage ?? 'The action could not be performed.',\n errorCode: outcome.ErrorCode,\n ...(outcome.Details ? { details: outcome.Details } : {}),\n ...(outcome.Available ? { available: outcome.Available } : {})\n };\n }\n\n /** Headless — no surface to bind. */\n public BindSurface(): void {\n /* no-op: this channel renders no surface */\n }\n\n /**\n * Subscribes to the host's live app-context stream and streams each coalesced delta to the model as a\n * compact context note while keeping only the latest full snapshot in reconnect memory under\n * `StateKey: 'app-context'`. Null-safe — hosts that supply no `AppContext$` (custom apps) simply get\n * no streaming, and the session-start prompt injection still applies.\n */\n protected override OnInitialize(): void {\n const stream = this.Context?.AppContext$;\n if (!stream) {\n return;\n }\n let subscribingSynchronously = true;\n this.appContextSub = stream\n .pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))\n .subscribe((snapshot) => {\n if (!snapshot) {\n return;\n }\n if (subscribingSynchronously) {\n // BehaviorSubject's current value was already injected into SystemPrompt at session mint:\n // record it as the diff baseline without sending a duplicate t=0 wire note.\n this.baselineSnapshot = snapshot;\n return;\n }\n this.pendingSnapshot = snapshot;\n if (this.coalesceTimer === null) {\n this.coalesceTimer = setTimeout(() => this.FlushPending(), CLIENT_CONTEXT_COALESCE_MS);\n }\n });\n subscribingSynchronously = false;\n }\n\n /**\n * Immediately flushes any buffered `AppContext$` update, emitting a compact delta on the live wire\n * and recording the full latest snapshot under `StateKey: 'app-context'` for reconnect continuity.\n */\n public FlushPending(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n const latest = this.pendingSnapshot;\n this.pendingSnapshot = null;\n if (!latest) {\n return;\n }\n const delta = DiffAppContextSnapshot(this.baselineSnapshot, latest);\n this.baselineSnapshot = latest;\n if (!delta) {\n return;\n }\n const wireNote = FormatAppContextNote(delta);\n if (!wireNote) {\n return;\n }\n const fullMemoryNote = FormatAppContextNote(latest);\n this.Context?.SendContextNote(wireNote, {\n StateKey: APP_CONTEXT_MEMORY_STATE_KEY,\n ...(fullMemoryNote && fullMemoryNote !== wireNote ? { MemoryText: fullMemoryNote } : {}),\n });\n }\n\n /** Tolerantly parses the `{ action, params, target? }` arguments. */\n private parseArgs(argsJson: string): {\n action: string | null;\n params: Record<string, unknown>;\n target: { channel: string; instance?: string } | null;\n } {\n try {\n const parsed = JSON.parse(argsJson) as { action?: unknown; params?: unknown; target?: unknown };\n const action = typeof parsed.action === 'string' && parsed.action.trim().length > 0 ? parsed.action.trim() : null;\n const params =\n parsed.params && typeof parsed.params === 'object' && !Array.isArray(parsed.params)\n ? (parsed.params as Record<string, unknown>)\n : {};\n return { action, params, target: this.parseTarget(parsed.target) };\n } catch {\n return { action: null, params: {}, target: null };\n }\n }\n\n /** Reads a `target` — `{ channel, instance? }` — or `null` when absent or unusable (the call is then an app action). */\n private parseTarget(raw: unknown): { channel: string; instance?: string } | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n return null;\n }\n const target = raw as { channel?: unknown; instance?: unknown };\n const channel = typeof target.channel === 'string' ? target.channel.trim() : '';\n if (channel.length === 0) {\n return null;\n }\n const instance = typeof target.instance === 'string' && target.instance.trim().length > 0 ? target.instance.trim() : undefined;\n return instance ? { channel, instance } : { channel };\n }\n\n /** Unsubscribes the app-context stream, cancels any pending coalescer timer, and tears down. */\n public override Dispose(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n this.pendingSnapshot = null;\n this.baselineSnapshot = null;\n this.appContextSub?.unsubscribe();\n this.appContextSub = null;\n super.Dispose();\n }\n}\n\n/**\n * Tree-shaking prevention for {@link ClientContextChannel}'s `@RegisterClass` registration. Called\n * from a static code path in `conversations.module.ts` so the registration always executes —\n * mirroring every other realtime channel client.\n */\nexport function LoadClientContextChannel(): void {\n // no-op — the import + call create a static reference bundlers cannot eliminate\n}\n"]}
@@ -123,6 +123,7 @@ export declare class InteractiveComponentChannel extends BaseRealtimeChannelClie
123
123
  * configuration says not to swap, the agent is told one exists); with auto-open on, a component that is not open is opened.
124
124
  */
125
125
  OnDelegationArtifacts(artifacts: readonly ParsedDelegationArtifact[]): Promise<void>;
126
+ private isDelegatedArtifactCandidate;
126
127
  /** Opens a delegated artifact; one that is not a component is ignored (expected), anything else is logged. */
127
128
  private autoOpen;
128
129
  /** Moves an open instance to the version a delegated run produced, when that version is newer. */
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-component-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/interactive-component-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEH,KAAK,oBAAoB,EAEzB,KAAK,yBAAyB,EAGjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACH,yBAAyB,EAGzB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EACjC,MAAM,kCAAkC,CA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e;IACf,OAAO,CAAC,aAAa;IAQrB,qDAAqD;YACvC,aAAa;IAgC3B,kFAAkF;YACpE,aAAa;IAa3B,6FAA6F;YAC/E,UAAU;IA8CxB,6CAA6C;IAC7C,OAAO,CAAC,QAAQ;IAehB,+FAA+F;IAC/F,OAAO,CAAC,WAAW;IAenB;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IA4BjF,yCAAyC;IACzC,OAAO,CAAC,UAAU;IAOlB;;;OAGG;IACH,OAAO,CAAC,cAAc;CASzB;AAED;;;;GAIG;AACH,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
1
+ {"version":3,"file":"interactive-component-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/interactive-component-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEH,KAAK,oBAAoB,EAEzB,KAAK,yBAAyB,EAGjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACH,yBAAyB,EAGzB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAoD,MAAM,6BAA6B,CAAC;AAOxH,OAAO,EAAE,4CAA4C,EAAE,MAAM,oDAAoD,CAAC;AAElH,OAAO,EAMH,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAE7B,KAAK,0BAA0B,EAElC,MAAM,+BAA+B,CAAC;AA2CvC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBACa,2BAA4B,SAAQ,yBAAyB,CAAC,4CAA4C,CAAC;IACpH,oCAAoC;IACpC,SAAgB,MAAM,0BAAkF;IAExG,2FAA2F;IACp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OAAO,CAAC,cAAc;CASzB;AAED;;;;GAIG;AACH,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
@@ -13,6 +13,7 @@ import { SummarizeDataState, ToBoundedJson } from './component-data-state';
13
13
  import { ComponentInstanceEngine, InstanceLimitError } from './component-instance-engine';
14
14
  import { ParseInteractiveComponentConfig } from './interactive-component-config';
15
15
  import { ChannelFrameCapture } from '@memberjunction/ng-realtime-channels';
16
+ import { IsCollaborativeArtifactDescriptor, IsComponentArtifactDescriptor, } from '../artifact-workspace/artifact-workspace-types';
16
17
  import { RealtimeInteractiveComponentSurfaceComponent } from './realtime-interactive-component-surface.component';
17
18
  import { RunViewComponentArtifactSource } from './run-view-component-artifact-source';
18
19
  import { BUILTIN_VERBS, ComponentArtifactError, DEFAULT_INTERACTIVE_COMPONENT_CONFIG, INTERACTIVE_COMPONENT_CHANNEL_KEY, INTERACTIVE_COMPONENT_CLIENT_PLUGIN_CLASS, } from './interactive-component-types';
@@ -427,7 +428,8 @@ let InteractiveComponentChannel = class InteractiveComponentChannel extends Base
427
428
  if (artifacts.some((a) => this.Engine.FindByArtifact(a.ArtifactID))) {
428
429
  return true;
429
430
  }
430
- return artifacts.length > 0 && ParseInteractiveComponentConfig(config).Config.AutoOpenDelegatedComponents;
431
+ const candidateArtifacts = artifacts.filter((a) => this.isDelegatedArtifactCandidate(a));
432
+ return candidateArtifacts.length > 0 && ParseInteractiveComponentConfig(config).Config.AutoOpenDelegatedComponents;
431
433
  }
432
434
  /**
433
435
  * Takes a delegated run's artifacts: an artifact that is already open moves to its newer version (or, when the
@@ -438,12 +440,23 @@ let InteractiveComponentChannel = class InteractiveComponentChannel extends Base
438
440
  const open = this.Engine.FindByArtifact(artifact.ArtifactID);
439
441
  if (open) {
440
442
  await this.takeNewerVersion(open, artifact);
443
+ continue;
441
444
  }
442
- else if (this.Config.AutoOpenDelegatedComponents) {
445
+ if (!this.isDelegatedArtifactCandidate(artifact)) {
446
+ continue;
447
+ }
448
+ if (this.Config.AutoOpenDelegatedComponents) {
443
449
  await this.autoOpen(artifact);
444
450
  }
445
451
  }
446
452
  }
453
+ isDelegatedArtifactCandidate(artifact) {
454
+ if (IsCollaborativeArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass)) {
455
+ return false;
456
+ }
457
+ return (IsComponentArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass) ||
458
+ (!artifact.ArtifactTypeName?.trim() && !artifact.DriverClass?.trim()));
459
+ }
447
460
  /** Opens a delegated artifact; one that is not a component is ignored (expected), anything else is logged. */
448
461
  async autoOpen(artifact) {
449
462
  const opened = await this.Open({ artifactVersionId: artifact.ArtifactVersionID });