@dxos/plugin-assistant 0.8.3 → 0.8.4-main.5acf9ea

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 (432) hide show
  1. package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → BlueprintContainer-IZ4AK5EO.mjs} +10 -10
  2. package/dist/lib/browser/BlueprintContainer-IZ4AK5EO.mjs.map +7 -0
  3. package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs +54 -0
  4. package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs.map +7 -0
  5. package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs +72 -0
  6. package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs.map +7 -0
  7. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +162 -0
  8. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +7 -0
  9. package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-XSEOKJLG.mjs} +25 -86
  10. package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-63GG6U6D.mjs +2226 -0
  12. package/dist/lib/browser/chunk-63GG6U6D.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-7W7LHTRH.mjs +171 -0
  14. package/dist/lib/browser/chunk-7W7LHTRH.mjs.map +7 -0
  15. package/dist/lib/{node/chunk-P74TWGMG.cjs → browser/chunk-FDCJSQYF.mjs} +10 -14
  16. package/dist/lib/{node-esm/chunk-BB2TAT4P.mjs.map → browser/chunk-FDCJSQYF.mjs.map} +1 -1
  17. package/dist/lib/browser/{chunk-JQFUME3B.mjs → chunk-KFXSBNZR.mjs} +36 -34
  18. package/dist/lib/browser/chunk-KFXSBNZR.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-BI6AHRNJ.mjs → chunk-LERGF5YG.mjs} +19 -68
  20. package/dist/lib/browser/chunk-LERGF5YG.mjs.map +7 -0
  21. package/dist/lib/browser/index.mjs +99 -119
  22. package/dist/lib/browser/index.mjs.map +4 -4
  23. package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs +75 -0
  24. package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs.map +7 -0
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-3GYEHQRP.mjs} +44 -53
  27. package/dist/lib/browser/react-surface-3GYEHQRP.mjs.map +7 -0
  28. package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-5GTTCVGD.mjs} +6 -6
  29. package/dist/lib/browser/settings-5GTTCVGD.mjs.map +7 -0
  30. package/dist/lib/browser/types/index.mjs +4 -20
  31. package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → BlueprintContainer-RGTMNLNX.mjs} +10 -10
  32. package/dist/lib/node-esm/BlueprintContainer-RGTMNLNX.mjs.map +7 -0
  33. package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs +55 -0
  34. package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs.map +7 -0
  35. package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs +73 -0
  36. package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs.map +7 -0
  37. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +163 -0
  38. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +7 -0
  39. package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-PANCJUHV.mjs} +25 -86
  40. package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-BFO3KHYL.mjs +2227 -0
  42. package/dist/lib/node-esm/chunk-BFO3KHYL.mjs.map +7 -0
  43. package/dist/lib/node-esm/{chunk-UCOFKNKN.mjs → chunk-MS3PJARN.mjs} +19 -68
  44. package/dist/lib/node-esm/chunk-MS3PJARN.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +41 -0
  46. package/dist/lib/{browser/chunk-XOZ7YMO3.mjs.map → node-esm/chunk-QN2H2EHV.mjs.map} +1 -1
  47. package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-VIIMA3XQ.mjs} +36 -34
  48. package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs.map +7 -0
  49. package/dist/lib/node-esm/chunk-Z7PUODRT.mjs +172 -0
  50. package/dist/lib/node-esm/chunk-Z7PUODRT.mjs.map +7 -0
  51. package/dist/lib/node-esm/index.mjs +99 -119
  52. package/dist/lib/node-esm/index.mjs.map +4 -4
  53. package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs +76 -0
  54. package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs.map +7 -0
  55. package/dist/lib/node-esm/meta.json +1 -1
  56. package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-QDQWJ7FZ.mjs} +44 -53
  57. package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs.map +7 -0
  58. package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-J2EXEM5H.mjs} +6 -6
  59. package/dist/lib/node-esm/settings-J2EXEM5H.mjs.map +7 -0
  60. package/dist/lib/node-esm/types/index.mjs +4 -20
  61. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  62. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  63. package/dist/types/src/capabilities/index.d.ts +1 -3
  64. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  65. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  66. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  67. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  68. package/dist/types/src/capability-definitions.d.ts +7 -0
  69. package/dist/types/src/capability-definitions.d.ts.map +1 -0
  70. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +2 -2
  71. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  72. package/dist/types/src/components/BlueprintContainer.d.ts +5 -6
  73. package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
  74. package/dist/types/src/components/Chat/Chat.d.ts +47 -0
  75. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
  76. package/dist/types/src/components/Chat/events.d.ts +30 -0
  77. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  78. package/dist/types/src/components/Chat/index.d.ts +3 -0
  79. package/dist/types/src/components/Chat/index.d.ts.map +1 -0
  80. package/dist/types/src/components/ChatContainer.d.ts +6 -6
  81. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  82. package/dist/types/src/components/ChatDialog.d.ts +8 -0
  83. package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
  84. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +11 -0
  85. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
  86. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +9 -0
  87. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +1 -0
  88. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  89. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  90. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +11 -0
  91. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
  92. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +8 -0
  93. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
  94. package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
  95. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
  96. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +17 -0
  97. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -0
  98. package/dist/types/src/components/ChatThread/ChatThread.d.ts +19 -0
  99. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
  100. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +199 -0
  101. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
  102. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +19 -0
  103. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -0
  104. package/dist/types/src/components/ChatThread/index.d.ts +2 -0
  105. package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
  106. package/dist/types/src/components/{Thread → ChatThread}/reducer.d.ts +4 -4
  107. package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -0
  108. package/dist/types/src/components/PromptSettings.d.ts +2 -2
  109. package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
  110. package/dist/types/src/components/SequenceContainer.d.ts +8 -0
  111. package/dist/types/src/components/SequenceContainer.d.ts.map +1 -0
  112. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +13 -0
  113. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -0
  114. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +8 -0
  115. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -0
  116. package/dist/types/src/components/SequenceEditor/index.d.ts +2 -0
  117. package/dist/types/src/components/SequenceEditor/index.d.ts.map +1 -0
  118. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +4 -3
  119. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  120. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
  121. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  122. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +5 -4
  123. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  124. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
  125. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  126. package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -4
  127. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  128. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -1
  129. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  130. package/dist/types/src/components/index.d.ts +6 -12
  131. package/dist/types/src/components/index.d.ts.map +1 -1
  132. package/dist/types/src/events.d.ts.map +1 -1
  133. package/dist/types/src/hooks/{processor.d.ts → chat-processor.d.ts} +36 -22
  134. package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
  135. package/dist/types/src/hooks/chat-processor.test.d.ts +2 -0
  136. package/dist/types/src/hooks/chat-processor.test.d.ts.map +1 -0
  137. package/dist/types/src/hooks/index.d.ts +5 -5
  138. package/dist/types/src/hooks/index.d.ts.map +1 -1
  139. package/dist/types/src/hooks/presets.d.ts +13 -0
  140. package/dist/types/src/hooks/presets.d.ts.map +1 -0
  141. package/dist/types/src/hooks/useBlueprints.d.ts +9 -0
  142. package/dist/types/src/hooks/useBlueprints.d.ts.map +1 -0
  143. package/dist/types/src/hooks/useChatProcessor.d.ts +20 -8
  144. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  145. package/dist/types/src/hooks/useChatServices.d.ts +14 -0
  146. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  147. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  148. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  149. package/dist/types/src/parser/index.d.ts +1 -1
  150. package/dist/types/src/parser/index.d.ts.map +1 -1
  151. package/dist/types/src/queue-logger.d.ts +5 -5
  152. package/dist/types/src/queue-logger.d.ts.map +1 -1
  153. package/dist/types/src/stories/Chat.stories.d.ts +207 -0
  154. package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
  155. package/dist/types/src/testing/index.d.ts +1 -1
  156. package/dist/types/src/testing/index.d.ts.map +1 -1
  157. package/dist/types/src/testing/test-sequence.d.ts +8 -0
  158. package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
  159. package/dist/types/src/translations.d.ts +68 -113
  160. package/dist/types/src/translations.d.ts.map +1 -1
  161. package/dist/types/src/types/index.d.ts +1 -3
  162. package/dist/types/src/types/index.d.ts.map +1 -1
  163. package/dist/types/src/types/schema.d.ts +120 -0
  164. package/dist/types/src/types/schema.d.ts.map +1 -0
  165. package/dist/types/src/types/service.d.ts +9 -9
  166. package/dist/types/src/types/service.d.ts.map +1 -1
  167. package/dist/types/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +84 -76
  169. package/src/AssistantPlugin.tsx +43 -44
  170. package/src/capabilities/app-graph-builder.ts +24 -103
  171. package/src/capabilities/index.ts +0 -3
  172. package/src/capabilities/intent-resolver.ts +41 -14
  173. package/src/capabilities/react-surface.tsx +38 -37
  174. package/src/capabilities/settings.ts +3 -3
  175. package/src/capability-definitions.ts +15 -0
  176. package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
  177. package/src/components/BlueprintContainer.tsx +9 -133
  178. package/src/components/Chat/Chat.tsx +388 -0
  179. package/src/components/Chat/events.ts +50 -0
  180. package/src/components/Chat/index.ts +7 -0
  181. package/src/components/ChatContainer.tsx +26 -20
  182. package/src/components/ChatDialog.tsx +64 -0
  183. package/src/components/ChatPrompt/ChatActions.tsx +71 -0
  184. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +52 -0
  185. package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
  186. package/src/components/ChatPrompt/ChatReferences.tsx +53 -0
  187. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
  188. package/src/components/ChatPrompt/index.ts +9 -0
  189. package/src/components/ChatThread/ChatMessage.tsx +268 -0
  190. package/src/components/ChatThread/ChatThread.stories.tsx +143 -0
  191. package/src/components/ChatThread/ChatThread.tsx +57 -0
  192. package/src/components/{Thread/ToolInvocations.tsx → ChatThread/ToolBlock.tsx} +36 -21
  193. package/src/{experimental/transcription → components/ChatThread}/index.ts +2 -0
  194. package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
  195. package/src/components/PromptSettings.tsx +43 -45
  196. package/src/components/SequenceContainer.tsx +132 -0
  197. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +32 -0
  198. package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +7 -7
  199. package/src/components/{AmbientDialog → SequenceEditor}/index.ts +1 -1
  200. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +29 -34
  201. package/src/components/TemplateEditor/TemplateEditor.tsx +39 -24
  202. package/src/components/TemplateEditor/TemplateForm.stories.tsx +17 -17
  203. package/src/components/TemplateEditor/TemplateForm.tsx +50 -57
  204. package/src/components/Toolbox/Toolbox.stories.tsx +5 -6
  205. package/src/components/Toolbox/Toolbox.tsx +60 -4
  206. package/src/components/index.ts +4 -5
  207. package/src/events.ts +2 -2
  208. package/src/hooks/{processor.test.ts → chat-processor.test.ts} +3 -2
  209. package/src/hooks/chat-processor.ts +314 -0
  210. package/src/hooks/index.ts +5 -5
  211. package/src/hooks/presets.ts +52 -0
  212. package/src/hooks/useBlueprints.ts +57 -0
  213. package/src/hooks/useChatProcessor.ts +143 -0
  214. package/src/hooks/useChatServices.ts +67 -0
  215. package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +14 -14
  216. package/src/parser/index.ts +1 -1
  217. package/src/queue-logger.ts +6 -6
  218. package/src/stories/Chat.stories.tsx +371 -0
  219. package/src/testing/index.ts +1 -1
  220. package/src/testing/test-functions.ts +1 -1
  221. package/src/testing/test-sequence.ts +51 -0
  222. package/src/tools/openapi.test.ts +11 -11
  223. package/src/translations.ts +39 -28
  224. package/src/types/index.ts +1 -3
  225. package/src/types/schema.ts +108 -0
  226. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
  227. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
  228. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
  229. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
  230. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
  231. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
  232. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
  233. package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
  234. package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
  235. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
  237. package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
  239. package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
  240. package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
  241. package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
  242. package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
  243. package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
  244. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
  245. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
  246. package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
  247. package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
  248. package/dist/lib/browser/chunk-XOZ7YMO3.mjs +0 -20
  249. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
  250. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
  251. package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
  252. package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
  253. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
  254. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
  255. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
  256. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
  257. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
  258. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
  259. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
  260. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
  261. package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
  262. package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
  263. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
  264. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
  265. package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
  266. package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
  267. package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
  268. package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
  269. package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
  270. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
  271. package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
  272. package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
  273. package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
  274. package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
  275. package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
  276. package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
  277. package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
  278. package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
  279. package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
  280. package/dist/lib/node/index.cjs +0 -289
  281. package/dist/lib/node/index.cjs.map +0 -7
  282. package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
  283. package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
  284. package/dist/lib/node/meta.json +0 -1
  285. package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
  286. package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
  287. package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
  288. package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
  289. package/dist/lib/node/types/index.cjs +0 -54
  290. package/dist/lib/node/types/index.cjs.map +0 -7
  291. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
  292. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
  293. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
  294. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
  295. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
  296. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
  297. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
  298. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
  299. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
  300. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
  301. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
  302. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
  303. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
  304. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
  305. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs +0 -22
  306. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
  307. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
  308. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
  309. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
  310. package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
  311. package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
  312. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
  313. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
  314. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
  315. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
  316. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
  317. package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
  318. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  319. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  320. package/dist/types/src/capabilities/capabilities.d.ts +0 -6
  321. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  322. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
  323. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
  324. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
  325. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
  326. package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
  327. package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
  328. package/dist/types/src/components/AssistantDialog.d.ts +0 -7
  329. package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
  330. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
  331. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
  332. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
  333. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
  334. package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
  335. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
  336. package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
  337. package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
  338. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
  339. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
  340. package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
  341. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
  342. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
  343. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
  344. package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
  345. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
  346. package/dist/types/src/components/Prompt/index.d.ts +0 -3
  347. package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
  348. package/dist/types/src/components/Prompt/references.d.ts +0 -30
  349. package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
  350. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  351. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  352. package/dist/types/src/components/Thread/Thread.d.ts +0 -28
  353. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  354. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  355. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  356. package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
  357. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
  358. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
  359. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
  360. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
  361. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  362. package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
  363. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
  364. package/dist/types/src/components/Thread/index.d.ts +0 -3
  365. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  366. package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
  367. package/dist/types/src/experimental/transcription/index.d.ts +0 -1
  368. package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
  369. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  370. package/dist/types/src/hooks/processor.test.d.ts +0 -2
  371. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  372. package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
  373. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  374. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
  375. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  376. package/dist/types/src/hooks/useServices.d.ts +0 -7
  377. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  378. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  379. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  380. package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
  381. package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
  382. package/dist/types/src/stories/Query.stories.d.ts +0 -19
  383. package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
  384. package/dist/types/src/stories/Research.stories.d.ts +0 -15
  385. package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
  386. package/dist/types/src/stories/test-data.d.ts +0 -3
  387. package/dist/types/src/stories/test-data.d.ts.map +0 -1
  388. package/dist/types/src/stories/testing.d.ts +0 -12
  389. package/dist/types/src/stories/testing.d.ts.map +0 -1
  390. package/dist/types/src/testing/test-blueprint.d.ts +0 -8
  391. package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
  392. package/dist/types/src/types/chat.d.ts +0 -23
  393. package/dist/types/src/types/chat.d.ts.map +0 -1
  394. package/dist/types/src/types/template.d.ts +0 -56
  395. package/dist/types/src/types/template.d.ts.map +0 -1
  396. package/dist/types/src/types/types.d.ts +0 -50
  397. package/dist/types/src/types/types.d.ts.map +0 -1
  398. package/src/capabilities/ai-client.ts +0 -42
  399. package/src/capabilities/capabilities.ts +0 -15
  400. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
  401. package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
  402. package/src/components/AssistantDialog.tsx +0 -37
  403. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
  404. package/src/components/BlueprintEditor/index.ts +0 -5
  405. package/src/components/Prompt/Prompt.stories.tsx +0 -121
  406. package/src/components/Prompt/Prompt.tsx +0 -124
  407. package/src/components/Prompt/PromptBar.stories.tsx +0 -69
  408. package/src/components/Prompt/PromptBar.tsx +0 -105
  409. package/src/components/Prompt/autocomplete.ts +0 -218
  410. package/src/components/Prompt/index.ts +0 -6
  411. package/src/components/Prompt/references.ts +0 -180
  412. package/src/components/TemplateContainer.tsx +0 -23
  413. package/src/components/Thread/Thread.stories.tsx +0 -201
  414. package/src/components/Thread/Thread.tsx +0 -118
  415. package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
  416. package/src/components/Thread/ThreadContainer.tsx +0 -105
  417. package/src/components/Thread/ThreadMessage.tsx +0 -234
  418. package/src/components/Thread/index.ts +0 -6
  419. package/src/hooks/processor.ts +0 -238
  420. package/src/hooks/useChatProcessor.tsx +0 -97
  421. package/src/hooks/useMessageQueue.ts +0 -22
  422. package/src/hooks/useServices.ts +0 -28
  423. package/src/hooks/useTextInputEvents.ts +0 -49
  424. package/src/stories/Prompt.stories.tsx +0 -60
  425. package/src/stories/Query.stories.tsx +0 -514
  426. package/src/stories/Research.stories.tsx +0 -482
  427. package/src/stories/test-data.ts +0 -128
  428. package/src/stories/testing.ts +0 -60
  429. package/src/testing/test-blueprint.ts +0 -58
  430. package/src/types/chat.ts +0 -32
  431. package/src/types/template.ts +0 -66
  432. package/src/types/types.ts +0 -48
@@ -0,0 +1,388 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Extension, Prec } from '@codemirror/state';
6
+ import { keymap } from '@codemirror/view';
7
+ import { createContext } from '@radix-ui/react-context';
8
+ import { dedupeWith } from 'effect/Array';
9
+ import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
+
11
+ import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/app-framework';
12
+ import { Event } from '@dxos/async';
13
+ import { DXN, Obj, Ref } from '@dxos/echo';
14
+ import { log } from '@dxos/log';
15
+ import { useVoiceInput } from '@dxos/plugin-transcription';
16
+ import { type Expando, getSpace, useQueue, type Space } from '@dxos/react-client/echo';
17
+ import { useIdentity } from '@dxos/react-client/halo';
18
+ import { Input, useTranslation, type ThemedClassName } from '@dxos/react-ui';
19
+ import { ChatEditor, type ChatEditorController, type ChatEditorProps, references } from '@dxos/react-ui-chat';
20
+ import { type ScrollController } from '@dxos/react-ui-components';
21
+ import { mx } from '@dxos/react-ui-theme';
22
+ import { DataType } from '@dxos/schema';
23
+ import { isNotFalsy } from '@dxos/util';
24
+
25
+ import { type ChatEvent } from './events';
26
+ import { type ChatProcessor, useBlueprints, useReferencesProvider } from '../../hooks';
27
+ import { meta } from '../../meta';
28
+ import { type Assistant } from '../../types';
29
+ import {
30
+ ChatActions,
31
+ type ChatActionsProps,
32
+ ChatOptionsMenu,
33
+ ChatPresets,
34
+ type ChatPresetsProps,
35
+ ChatReferences,
36
+ type ChatReferencesProps,
37
+ ChatStatusIndicator,
38
+ } from '../ChatPrompt';
39
+ import { ChatThread as NativeChatThread, type ChatThreadProps as NativeChatThreadProps } from '../ChatThread';
40
+
41
+ // TODO(burdon): Factor out.
42
+ const Endcap = ({ children }: PropsWithChildren) => {
43
+ return (
44
+ <div className='grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center'>{children}</div>
45
+ );
46
+ };
47
+
48
+ //
49
+ // Context
50
+ // NOTE: The context should not be exported. It is only used internally.
51
+ // Components outside of this Radix-style group shuld define their own APIs.
52
+ //
53
+
54
+ // TODO(burdon): Inject via effect layer.
55
+ type ChatContextValue = {
56
+ debug?: boolean;
57
+ event: Event<ChatEvent>;
58
+ space: Space;
59
+ chat: Assistant.Chat;
60
+ processor: ChatProcessor;
61
+ messages: DataType.Message[];
62
+
63
+ /** @deprecated Remove and replace with context. */
64
+ artifact?: Expando;
65
+ };
66
+
67
+ // NOTE: Do not export.
68
+ const [ChatContextProvider, useChatContext] = createContext<ChatContextValue>('Chat');
69
+
70
+ //
71
+ // Root
72
+ //
73
+
74
+ type ChatRootProps = ThemedClassName<
75
+ PropsWithChildren<
76
+ Pick<ChatContextValue, 'chat' | 'processor' | 'artifact'> & {
77
+ onEvent?: (event: ChatEvent) => void;
78
+ }
79
+ >
80
+ >;
81
+
82
+ const ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...props }: ChatRootProps) => {
83
+ const [debug, setDebug] = useState(false);
84
+ const space = getSpace(chat);
85
+
86
+ // Messages.
87
+ const queue = useQueue<DataType.Message>(chat?.queue.dxn);
88
+ const messages = useMemo(
89
+ () =>
90
+ dedupeWith(
91
+ [...(queue?.objects?.filter(Obj.instanceOf(DataType.Message)) ?? []), ...(processor?.messages.value ?? [])],
92
+ (a, b) => a.id === b.id,
93
+ ),
94
+ [queue?.objects, processor?.messages.value],
95
+ );
96
+
97
+ // TODO(burdon): Replace with tool.
98
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
99
+ useEffect(() => {
100
+ if (!processor?.streaming.value && queue?.objects && artifact) {
101
+ const message = queue.objects[queue.objects.length - 1];
102
+ if (dispatch && space && chat && message) {
103
+ void dispatch(
104
+ createIntent(CollaborationActions.InsertContent, {
105
+ target: artifact,
106
+ object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
107
+ label: 'View proposal',
108
+ }),
109
+ );
110
+ }
111
+ }
112
+ }, [queue, processor?.streaming.value]);
113
+
114
+ // Events.
115
+ const event = useMemo(() => new Event<ChatEvent>(), []);
116
+ useEffect(() => {
117
+ return event.on((event) => {
118
+ switch (event.type) {
119
+ case 'toggle-debug': {
120
+ setDebug((debug) => !debug);
121
+ break;
122
+ }
123
+
124
+ case 'submit': {
125
+ if (!processor.streaming.value) {
126
+ void processor.request(event.text);
127
+ }
128
+ break;
129
+ }
130
+
131
+ case 'cancel': {
132
+ void processor.cancel();
133
+ break;
134
+ }
135
+
136
+ default: {
137
+ onEvent?.(event);
138
+ }
139
+ }
140
+ });
141
+ }, [event, onEvent]);
142
+
143
+ if (!space) {
144
+ return null;
145
+ }
146
+
147
+ return (
148
+ <ChatContextProvider
149
+ debug={debug}
150
+ event={event}
151
+ chat={chat}
152
+ space={space}
153
+ processor={processor}
154
+ messages={messages}
155
+ {...props}
156
+ >
157
+ <div role='none' className={mx('flex flex-col h-full overflow-hidden', classNames)}>
158
+ {children}
159
+ </div>
160
+ </ChatContextProvider>
161
+ );
162
+ };
163
+
164
+ ChatRoot.displayName = 'Chat.Root';
165
+
166
+ //
167
+ // Thread
168
+ //
169
+
170
+ type ChatThreadProps = Omit<NativeChatThreadProps, 'identity' | 'space' | 'messages' | 'tools' | 'onEvent'>;
171
+
172
+ const ChatThread = (props: ChatThreadProps) => {
173
+ const { debug, event, space, processor, messages } = useChatContext(ChatThread.displayName);
174
+ const identity = useIdentity();
175
+
176
+ const scrollerRef = useRef<ScrollController>(null);
177
+ useEffect(() => {
178
+ return event.on((event) => {
179
+ switch (event.type) {
180
+ case 'submit':
181
+ case 'scroll-to-bottom':
182
+ scrollerRef.current?.scrollToBottom('smooth');
183
+ break;
184
+ }
185
+ });
186
+ }, [event]);
187
+
188
+ if (!identity) {
189
+ return null;
190
+ }
191
+
192
+ return (
193
+ <NativeChatThread
194
+ {...props}
195
+ ref={scrollerRef}
196
+ debug={debug}
197
+ identity={identity}
198
+ space={space}
199
+ messages={messages}
200
+ tools={processor?.tools}
201
+ onEvent={(ev) => event.emit(ev)}
202
+ />
203
+ );
204
+ };
205
+
206
+ ChatThread.displayName = 'Chat.Thread';
207
+
208
+ //
209
+ // Prompt
210
+ //
211
+
212
+ type ChatPromptProps = ThemedClassName<
213
+ Pick<ChatEditorProps, 'placeholder'> &
214
+ Omit<ChatPresetsProps, 'onChange'> & {
215
+ expandable?: boolean;
216
+ online?: boolean;
217
+ onChangeOnline?: (online: boolean) => void;
218
+ onChangePreset?: ChatPresetsProps['onChange'];
219
+ }
220
+ >;
221
+
222
+ const ChatPrompt = ({
223
+ classNames,
224
+ placeholder,
225
+ expandable,
226
+ online,
227
+ presets,
228
+ preset,
229
+ onChangePreset,
230
+ onChangeOnline,
231
+ }: ChatPromptProps) => {
232
+ const { t } = useTranslation(meta.id);
233
+ const { space, event, processor } = useChatContext(ChatPrompt.displayName);
234
+
235
+ const [active, setActive] = useState(false);
236
+ useEffect(() => {
237
+ return event.on((event) => {
238
+ switch (event.type) {
239
+ case 'record-start':
240
+ setActive(true);
241
+ break;
242
+ case 'record-stop':
243
+ setActive(false);
244
+ break;
245
+ }
246
+ });
247
+ }, [event]);
248
+
249
+ const editorRef = useRef<ChatEditorController>(null);
250
+
251
+ // TODO(burdon): Configure capability in TranscriptionPlugin.
252
+ const { recording } = useVoiceInput({
253
+ active,
254
+ onUpdate: (text) => {
255
+ editorRef.current?.setText(text);
256
+ editorRef.current?.focus();
257
+ },
258
+ });
259
+
260
+ const [blueprints, handleUpdateBlueprints] = useBlueprints(space, processor.context, processor.blueprintRegistry);
261
+
262
+ // TODO(burdon): Reconcile with object tags.
263
+ const contextProvider = useReferencesProvider(space);
264
+ const extensions = useMemo<Extension[]>(() => {
265
+ return [
266
+ contextProvider && references({ provider: contextProvider }),
267
+ expandable &&
268
+ Prec.highest(
269
+ keymap.of([
270
+ {
271
+ key: 'cmd-d',
272
+ preventDefault: true,
273
+ run: () => {
274
+ event.emit({ type: 'toggle-debug' });
275
+ return true;
276
+ },
277
+ },
278
+ {
279
+ key: 'cmd-ArrowUp',
280
+ preventDefault: true,
281
+ run: () => {
282
+ event.emit({ type: 'thread-open' });
283
+ return true;
284
+ },
285
+ },
286
+ {
287
+ key: 'cmd-ArrowDown',
288
+ preventDefault: true,
289
+ run: () => {
290
+ event.emit({ type: 'thread-close' });
291
+ return true;
292
+ },
293
+ },
294
+ ]),
295
+ ),
296
+ ].filter(isNotFalsy);
297
+ }, [event, expandable, contextProvider]);
298
+
299
+ const handleSubmit = useCallback<NonNullable<ChatEditorProps['onSubmit']>>(
300
+ (text) => {
301
+ if (!processor.streaming.value) {
302
+ event.emit({ type: 'submit', text });
303
+ return true;
304
+ }
305
+ },
306
+ [processor, event],
307
+ );
308
+
309
+ const handleEvent = useCallback<NonNullable<ChatActionsProps['onEvent']>>(
310
+ (ev) => {
311
+ event.emit(ev);
312
+ },
313
+ [event],
314
+ );
315
+
316
+ // TODO(burdon): Update context.
317
+ const handleUpdateReferences = useCallback<NonNullable<ChatReferencesProps['onUpdate']>>((ids) => {
318
+ log.info('update', { ids });
319
+ }, []);
320
+
321
+ return (
322
+ <div
323
+ className={mx(
324
+ 'is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]',
325
+ classNames,
326
+ )}
327
+ >
328
+ <Endcap>
329
+ <ChatStatusIndicator preset={preset} error={processor.error.value} processing={processor.streaming.value} />
330
+ </Endcap>
331
+
332
+ <ChatEditor
333
+ ref={editorRef}
334
+ autoFocus
335
+ lineWrapping
336
+ classNames='col-span-2 pis-1 pbs-2'
337
+ placeholder={placeholder ?? t('prompt placeholder')}
338
+ extensions={extensions}
339
+ onSubmit={handleSubmit}
340
+ />
341
+
342
+ <div />
343
+ <ChatReferences
344
+ classNames='col-span-2 flex pis-1 items-center'
345
+ space={space}
346
+ context={processor.context}
347
+ onUpdate={handleUpdateReferences}
348
+ />
349
+
350
+ <ChatOptionsMenu
351
+ blueprintRegistry={processor.blueprintRegistry}
352
+ blueprints={blueprints}
353
+ onChange={handleUpdateBlueprints}
354
+ />
355
+ <ChatActions
356
+ classNames='col-span-2'
357
+ microphone={true}
358
+ recording={recording}
359
+ processing={processor.streaming.value}
360
+ onEvent={handleEvent}
361
+ >
362
+ <>
363
+ <div className='grow' />
364
+ {presets && <ChatPresets preset={preset} presets={presets} onChange={onChangePreset} />}
365
+ {online !== undefined && (
366
+ <Input.Root>
367
+ <Input.Switch classNames='mis-2 mie-2' checked={online} onCheckedChange={onChangeOnline} />
368
+ </Input.Root>
369
+ )}
370
+ </>
371
+ </ChatActions>
372
+ </div>
373
+ );
374
+ };
375
+
376
+ ChatPrompt.displayName = 'Chat.Prompt';
377
+
378
+ //
379
+ // Chat
380
+ //
381
+
382
+ export const Chat = {
383
+ Root: ChatRoot,
384
+ Thread: ChatThread,
385
+ Prompt: ChatPrompt,
386
+ };
387
+
388
+ export type { ChatRootProps, ChatThreadProps, ChatPromptProps, ChatEvent };
@@ -0,0 +1,50 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Obj } from '@dxos/echo';
6
+
7
+ /**
8
+ * The main `ChatRoot` manages the `ChatContextValue` which contains an `event` property that subcomponents
9
+ * can subscribe to and submit events. Unhandled events are passed to the external `onEvent` callback.
10
+ */
11
+ export type ChatEvent =
12
+ | {
13
+ type: 'toggle-debug';
14
+ }
15
+ //
16
+ // Thread
17
+ //
18
+ | {
19
+ type: 'submit';
20
+ text: string;
21
+ }
22
+ | {
23
+ type: 'cancel';
24
+ }
25
+ | {
26
+ type: 'delete';
27
+ id: string;
28
+ }
29
+ | {
30
+ type: 'add';
31
+ object: Obj.Any;
32
+ }
33
+ //
34
+ // UX
35
+ //
36
+ | {
37
+ type: 'scroll-to-bottom';
38
+ }
39
+ | {
40
+ type: 'thread-open';
41
+ }
42
+ | {
43
+ type: 'thread-close';
44
+ }
45
+ | {
46
+ type: 'record-start';
47
+ }
48
+ | {
49
+ type: 'record-stop';
50
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './events';
6
+
7
+ export * from './Chat';
@@ -2,36 +2,42 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { type FC } from 'react';
5
+ import React from 'react';
6
6
 
7
- import { Capabilities, useCapabilities, useCapability } from '@dxos/app-framework';
8
- import { type AssociatedArtifact } from '@dxos/artifact';
9
- import { TranscriptionCapabilities } from '@dxos/plugin-transcription';
7
+ import { Capabilities, useCapability } from '@dxos/app-framework';
8
+ import { type AssociatedArtifact } from '@dxos/blueprints';
9
+ import { getSpace } from '@dxos/client/echo';
10
10
  import { StackItem } from '@dxos/react-ui-stack';
11
11
 
12
- import { ThreadContainer } from './Thread';
13
- import { ASSISTANT_PLUGIN } from '../meta';
14
- import { type AssistantSettingsProps, type AIChatType } from '../types';
12
+ import { Chat } from './Chat';
13
+ import { useChatProcessor, useChatServices } from '../hooks';
14
+ import { meta } from '../meta';
15
+ import { type Assistant } from '../types';
15
16
 
16
17
  export type ChatContainerProps = {
17
18
  role: string;
18
- chat: AIChatType;
19
- associatedArtifact?: AssociatedArtifact;
19
+ chat: Assistant.Chat;
20
+ artifact?: AssociatedArtifact;
20
21
  };
21
22
 
22
- // TODO(burdon): Attention.
23
- export const ChatContainer: FC<ChatContainerProps> = ({ role, chat, associatedArtifact }) => {
24
- const transcription = useCapabilities(TranscriptionCapabilities.Transcriber).length > 0;
25
- const settings = useCapability(Capabilities.SettingsStore).getStore<AssistantSettingsProps>(ASSISTANT_PLUGIN)?.value;
23
+ export const ChatContainer = ({ role, chat, artifact }: ChatContainerProps) => {
24
+ const space = getSpace(chat);
25
+ const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
26
+ const services = useChatServices({ space });
27
+ const processor = useChatProcessor({ chat, services, settings });
28
+ if (!processor) {
29
+ return null;
30
+ }
26
31
 
32
+ // TODO(burdon): Add attention attributes.
27
33
  return (
28
- <StackItem.Content role={role} classNames='container-max-width'>
29
- <ThreadContainer
30
- chat={chat}
31
- settings={settings}
32
- transcription={transcription}
33
- associatedArtifact={associatedArtifact}
34
- />
34
+ <StackItem.Content classNames='container-max-width'>
35
+ <Chat.Root chat={chat} processor={processor} artifact={artifact}>
36
+ <Chat.Thread />
37
+ <div className='pbe-4 pis-2 pie-2'>
38
+ <Chat.Prompt classNames='border border-subduedSeparator rounded-md' />
39
+ </div>
40
+ </Chat.Root>
35
41
  </StackItem.Content>
36
42
  );
37
43
  };
@@ -0,0 +1,64 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useState } from 'react';
6
+
7
+ import { useCapability, Capabilities } from '@dxos/app-framework';
8
+ import { getSpace } from '@dxos/client/echo';
9
+ import { useTranslation } from '@dxos/react-ui';
10
+ import { ChatDialog as NativeChatDialog } from '@dxos/react-ui-chat';
11
+
12
+ import { Chat, type ChatRootProps } from './Chat';
13
+ import { useChatProcessor, useChatServices } from '../hooks';
14
+ import { meta } from '../meta';
15
+ import { type Assistant } from '../types';
16
+
17
+ export type ChatDialogProps = {
18
+ chat?: Assistant.Chat;
19
+ };
20
+
21
+ export const ChatDialog = ({ chat }: ChatDialogProps) => {
22
+ const { t } = useTranslation(meta.id);
23
+
24
+ const space = getSpace(chat);
25
+ const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
26
+ const services = useChatServices({ space });
27
+ const processor = useChatProcessor({ chat, services, settings });
28
+
29
+ // TODO(burdon): Refocus when open.
30
+ const [open, setOpen] = useState(true);
31
+ const [expanded, setExpanded] = useState(false);
32
+ const handleEvent = useCallback<NonNullable<ChatRootProps['onEvent']>>((event) => {
33
+ switch (event.type) {
34
+ case 'submit':
35
+ case 'thread-open':
36
+ setOpen(true);
37
+ setExpanded(true);
38
+ break;
39
+ case 'thread-close':
40
+ setOpen(false);
41
+ break;
42
+ }
43
+ }, []);
44
+
45
+ if (!chat || !processor) {
46
+ return null;
47
+ }
48
+
49
+ return (
50
+ <Chat.Root chat={chat} processor={processor} onEvent={handleEvent}>
51
+ <NativeChatDialog.Root open={open} expanded={expanded} onOpenChange={setOpen}>
52
+ <NativeChatDialog.Header title={t('assistant dialog title')} />
53
+ <NativeChatDialog.Content>
54
+ <Chat.Thread />
55
+ </NativeChatDialog.Content>
56
+ <NativeChatDialog.Footer>
57
+ <Chat.Prompt expandable />
58
+ </NativeChatDialog.Footer>
59
+ </NativeChatDialog.Root>
60
+ </Chat.Root>
61
+ );
62
+ };
63
+
64
+ export default ChatDialog;
@@ -0,0 +1,71 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { type PropsWithChildren } from 'react';
6
+
7
+ import { IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
8
+ import { mx } from '@dxos/react-ui-theme';
9
+
10
+ import { meta } from '../../meta';
11
+ import { type ChatEvent } from '../Chat';
12
+
13
+ export type ChatActionsProps = ThemedClassName<
14
+ PropsWithChildren<{
15
+ microphone?: boolean;
16
+ recording?: boolean;
17
+ processing?: boolean;
18
+ onEvent?: (event: ChatEvent) => void;
19
+ }>
20
+ >;
21
+
22
+ export const ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }: ChatActionsProps) => {
23
+ const { t } = useTranslation(meta.id);
24
+
25
+ return (
26
+ <div className={mx('flex items-center mie-1', classNames)}>
27
+ {children}
28
+
29
+ {(processing && (
30
+ <IconButton
31
+ disabled={!processing}
32
+ classNames='px-1.5'
33
+ variant='ghost'
34
+ size={5}
35
+ icon='ph--x--regular'
36
+ iconOnly
37
+ label={t('button cancel processing')}
38
+ onClick={() => onEvent?.({ type: 'cancel' })}
39
+ />
40
+ )) || (
41
+ <IconButton
42
+ disabled
43
+ classNames='px-1.5'
44
+ variant='ghost'
45
+ size={5}
46
+ icon='ph--arrow-down--regular'
47
+ iconOnly
48
+ label={t('button scroll down')}
49
+ onClick={() => onEvent?.({ type: 'scroll-to-bottom' })}
50
+ />
51
+ )}
52
+
53
+ {microphone && (
54
+ <IconButton
55
+ disabled={!processing}
56
+ classNames={mx('px-1.5', recording && 'bg-primary-500')}
57
+ variant='ghost'
58
+ size={5}
59
+ icon='ph--microphone--regular'
60
+ iconOnly
61
+ noTooltip
62
+ label={t('button microphone')}
63
+ onMouseDown={() => onEvent?.({ type: 'record-start' })}
64
+ onMouseUp={() => onEvent?.({ type: 'record-stop' })}
65
+ onTouchStart={() => onEvent?.({ type: 'record-start' })}
66
+ onTouchEnd={() => onEvent?.({ type: 'record-stop' })}
67
+ />
68
+ )}
69
+ </div>
70
+ );
71
+ };
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useMemo } from 'react';
6
+
7
+ import { type Blueprint } from '@dxos/blueprints';
8
+ import { DropdownMenu, IconButton, Input, useTranslation } from '@dxos/react-ui';
9
+
10
+ import { meta } from '../../meta';
11
+
12
+ export type ChatOptionsMenuProps = {
13
+ blueprintRegistry?: Blueprint.Registry;
14
+ blueprints?: Blueprint.Blueprint[];
15
+ onChange?: (key: string, active: boolean) => void;
16
+ };
17
+
18
+ export const ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }: ChatOptionsMenuProps) => {
19
+ const { t } = useTranslation(meta.id);
20
+ const blueprintOptions = useMemo(
21
+ () => blueprintRegistry?.query().map((blueprint) => ({ key: blueprint.key, label: blueprint.name })),
22
+ [blueprintRegistry],
23
+ );
24
+
25
+ return (
26
+ <DropdownMenu.Root>
27
+ <DropdownMenu.Trigger asChild disabled={!blueprintOptions?.length}>
28
+ <IconButton icon='ph--plus--regular' variant='ghost' size={5} iconOnly label={t('button add blueprint')} />
29
+ </DropdownMenu.Trigger>
30
+ <DropdownMenu.Portal>
31
+ <DropdownMenu.Content side='left'>
32
+ <DropdownMenu.Viewport>
33
+ {blueprintOptions?.map((option) => (
34
+ <DropdownMenu.Item key={option.key}>
35
+ <Input.Root>
36
+ <Input.Checkbox
37
+ checked={!!blueprints?.find((blueprint) => blueprint.key === option.key)}
38
+ onCheckedChange={(checked) => onChange?.(option.key, !!checked)}
39
+ />
40
+ {/* TODO(burdon): Remove need for custom margin. */}
41
+ {/* TODO(burdon): Clicking on label doesn't toggle checkbox. */}
42
+ <Input.Label classNames='m-0'>{option.label}</Input.Label>
43
+ </Input.Root>
44
+ </DropdownMenu.Item>
45
+ ))}
46
+ </DropdownMenu.Viewport>
47
+ <DropdownMenu.Arrow />
48
+ </DropdownMenu.Content>
49
+ </DropdownMenu.Portal>
50
+ </DropdownMenu.Root>
51
+ );
52
+ };