@dxos/plugin-assistant 0.8.3 → 0.8.4-main.c1de068

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 (430) hide show
  1. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs +54 -0
  2. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +7 -0
  3. package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs +72 -0
  4. package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +7 -0
  5. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +162 -0
  6. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +7 -0
  7. package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → TemplateContainer-RPJ2LBOB.mjs} +5 -6
  8. package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +7 -0
  9. package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-JTXBKE7O.mjs} +34 -36
  10. package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-AEAEKWOC.mjs +98 -0
  12. package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-BI6AHRNJ.mjs → chunk-EQDW6BYQ.mjs} +19 -68
  14. package/dist/lib/browser/chunk-EQDW6BYQ.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-JQBVLTM5.mjs +158 -0
  18. package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-OWY4CUQY.mjs +2245 -0
  20. package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +7 -0
  21. package/dist/lib/browser/index.mjs +87 -119
  22. package/dist/lib/browser/index.mjs.map +4 -4
  23. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +60 -0
  24. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +7 -0
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-66VY37YQ.mjs} +42 -51
  27. package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +7 -0
  28. package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-2DGP3UTS.mjs} +6 -6
  29. package/dist/lib/browser/settings-2DGP3UTS.mjs.map +7 -0
  30. package/dist/lib/browser/types/index.mjs +4 -20
  31. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +55 -0
  32. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +7 -0
  33. package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs +73 -0
  34. package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +7 -0
  35. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +163 -0
  36. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +7 -0
  37. package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → TemplateContainer-A3NAQCZE.mjs} +5 -6
  38. package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +7 -0
  39. package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-OWSOXFTD.mjs} +34 -36
  40. package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +7 -0
  41. package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-2XL6MNPE.mjs} +44 -33
  42. package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-BISJDTBK.mjs +159 -0
  44. package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +7 -0
  45. package/dist/lib/node-esm/{chunk-UCOFKNKN.mjs → chunk-E33DNNDW.mjs} +19 -68
  46. package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +41 -0
  48. package/dist/lib/{browser/chunk-XOZ7YMO3.mjs.map → node-esm/chunk-QN2H2EHV.mjs.map} +1 -1
  49. package/dist/lib/node-esm/chunk-SENTQAEO.mjs +2246 -0
  50. package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +7 -0
  51. package/dist/lib/node-esm/index.mjs +87 -119
  52. package/dist/lib/node-esm/index.mjs.map +4 -4
  53. package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +61 -0
  54. package/dist/lib/node-esm/intent-resolver-YPPYELY3.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-RJMRBR2M.mjs} +42 -51
  57. package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +7 -0
  58. package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-47RYZOU4.mjs} +6 -6
  59. package/dist/lib/node-esm/settings-47RYZOU4.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/components/AssistantSettings/AssistantSettings.d.ts +2 -2
  69. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  70. package/dist/types/src/components/Chat/Chat.d.ts +47 -0
  71. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
  72. package/dist/types/src/components/Chat/events.d.ts +30 -0
  73. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  74. package/dist/types/src/components/Chat/index.d.ts +3 -0
  75. package/dist/types/src/components/Chat/index.d.ts.map +1 -0
  76. package/dist/types/src/components/ChatContainer.d.ts +6 -6
  77. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  78. package/dist/types/src/components/ChatDialog.d.ts +8 -0
  79. package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
  80. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +11 -0
  81. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
  82. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +9 -0
  83. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +1 -0
  84. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  85. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  86. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +11 -0
  87. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
  88. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +8 -0
  89. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
  90. package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
  91. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
  92. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +17 -0
  93. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -0
  94. package/dist/types/src/components/ChatThread/ChatThread.d.ts +19 -0
  95. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
  96. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +241 -0
  97. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
  98. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +19 -0
  99. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -0
  100. package/dist/types/src/components/ChatThread/index.d.ts +2 -0
  101. package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
  102. package/dist/types/src/components/{Thread → ChatThread}/reducer.d.ts +4 -4
  103. package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -0
  104. package/dist/types/src/components/PromptSettings.d.ts +2 -2
  105. package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
  106. package/dist/types/src/components/SequenceContainer.d.ts +8 -0
  107. package/dist/types/src/components/SequenceContainer.d.ts.map +1 -0
  108. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +13 -0
  109. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -0
  110. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +8 -0
  111. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -0
  112. package/dist/types/src/components/SequenceEditor/index.d.ts +2 -0
  113. package/dist/types/src/components/SequenceEditor/index.d.ts.map +1 -0
  114. package/dist/types/src/components/TemplateContainer.d.ts +5 -5
  115. package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
  116. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -2
  117. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  118. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
  119. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  120. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -3
  121. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  122. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
  123. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  124. package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -4
  125. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  126. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -1
  127. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  128. package/dist/types/src/components/index.d.ts +6 -12
  129. package/dist/types/src/components/index.d.ts.map +1 -1
  130. package/dist/types/src/events.d.ts.map +1 -1
  131. package/dist/types/src/hooks/{processor.d.ts → chat-processor.d.ts} +36 -22
  132. package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
  133. package/dist/types/src/hooks/chat-processor.test.d.ts +2 -0
  134. package/dist/types/src/hooks/chat-processor.test.d.ts.map +1 -0
  135. package/dist/types/src/hooks/index.d.ts +5 -5
  136. package/dist/types/src/hooks/index.d.ts.map +1 -1
  137. package/dist/types/src/hooks/presets.d.ts +13 -0
  138. package/dist/types/src/hooks/presets.d.ts.map +1 -0
  139. package/dist/types/src/hooks/useBlueprints.d.ts +9 -0
  140. package/dist/types/src/hooks/useBlueprints.d.ts.map +1 -0
  141. package/dist/types/src/hooks/useChatProcessor.d.ts +20 -8
  142. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  143. package/dist/types/src/hooks/useChatServices.d.ts +14 -0
  144. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  145. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  146. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  147. package/dist/types/src/parser/index.d.ts +1 -1
  148. package/dist/types/src/parser/index.d.ts.map +1 -1
  149. package/dist/types/src/queue-logger.d.ts +5 -5
  150. package/dist/types/src/queue-logger.d.ts.map +1 -1
  151. package/dist/types/src/stories/Chat.stories.d.ts +249 -0
  152. package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
  153. package/dist/types/src/testing/index.d.ts +1 -1
  154. package/dist/types/src/testing/index.d.ts.map +1 -1
  155. package/dist/types/src/testing/test-sequence.d.ts +8 -0
  156. package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
  157. package/dist/types/src/translations.d.ts +77 -113
  158. package/dist/types/src/translations.d.ts.map +1 -1
  159. package/dist/types/src/types/index.d.ts +1 -3
  160. package/dist/types/src/types/index.d.ts.map +1 -1
  161. package/dist/types/src/types/schema.d.ts +88 -0
  162. package/dist/types/src/types/schema.d.ts.map +1 -0
  163. package/dist/types/src/types/service.d.ts +9 -9
  164. package/dist/types/src/types/service.d.ts.map +1 -1
  165. package/dist/types/tsconfig.tsbuildinfo +1 -1
  166. package/package.json +80 -74
  167. package/src/AssistantPlugin.tsx +20 -47
  168. package/src/capabilities/app-graph-builder.ts +35 -30
  169. package/src/capabilities/index.ts +0 -3
  170. package/src/capabilities/intent-resolver.ts +27 -14
  171. package/src/capabilities/react-surface.tsx +38 -37
  172. package/src/capabilities/settings.ts +3 -3
  173. package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
  174. package/src/components/Chat/Chat.tsx +388 -0
  175. package/src/components/Chat/events.ts +50 -0
  176. package/src/components/Chat/index.ts +7 -0
  177. package/src/components/ChatContainer.tsx +26 -20
  178. package/src/components/ChatDialog.tsx +64 -0
  179. package/src/components/ChatPrompt/ChatActions.tsx +71 -0
  180. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +52 -0
  181. package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
  182. package/src/components/ChatPrompt/ChatReferences.tsx +53 -0
  183. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
  184. package/src/components/ChatPrompt/index.ts +9 -0
  185. package/src/components/ChatThread/ChatMessage.tsx +268 -0
  186. package/src/components/ChatThread/ChatThread.stories.tsx +143 -0
  187. package/src/components/ChatThread/ChatThread.tsx +57 -0
  188. package/src/components/{Thread/ToolInvocations.tsx → ChatThread/ToolBlock.tsx} +36 -21
  189. package/src/{experimental/transcription → components/ChatThread}/index.ts +2 -0
  190. package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
  191. package/src/components/PromptSettings.tsx +43 -45
  192. package/src/components/SequenceContainer.tsx +132 -0
  193. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +32 -0
  194. package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +7 -7
  195. package/src/components/{AmbientDialog → SequenceEditor}/index.ts +1 -1
  196. package/src/components/TemplateContainer.tsx +8 -7
  197. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +28 -33
  198. package/src/components/TemplateEditor/TemplateEditor.tsx +32 -19
  199. package/src/components/TemplateEditor/TemplateForm.stories.tsx +15 -15
  200. package/src/components/TemplateEditor/TemplateForm.tsx +47 -55
  201. package/src/components/Toolbox/Toolbox.stories.tsx +5 -6
  202. package/src/components/Toolbox/Toolbox.tsx +60 -4
  203. package/src/components/index.ts +4 -5
  204. package/src/events.ts +2 -2
  205. package/src/hooks/{processor.test.ts → chat-processor.test.ts} +3 -2
  206. package/src/hooks/chat-processor.ts +314 -0
  207. package/src/hooks/index.ts +5 -5
  208. package/src/hooks/presets.ts +52 -0
  209. package/src/hooks/useBlueprints.ts +57 -0
  210. package/src/hooks/useChatProcessor.ts +143 -0
  211. package/src/hooks/useChatServices.ts +91 -0
  212. package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +14 -14
  213. package/src/parser/index.ts +1 -1
  214. package/src/queue-logger.ts +6 -6
  215. package/src/stories/Chat.stories.tsx +378 -0
  216. package/src/testing/index.ts +1 -1
  217. package/src/testing/test-functions.ts +1 -1
  218. package/src/testing/test-sequence.ts +51 -0
  219. package/src/tools/openapi.test.ts +11 -11
  220. package/src/translations.ts +43 -23
  221. package/src/types/index.ts +1 -3
  222. package/src/types/schema.ts +95 -0
  223. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
  224. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
  225. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
  226. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
  227. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
  228. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
  229. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
  230. package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
  231. package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
  232. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
  233. package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
  234. package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
  237. package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-JQFUME3B.mjs +0 -87
  239. package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
  240. package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
  241. package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
  242. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
  243. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
  244. package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
  245. package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
  246. package/dist/lib/browser/chunk-XOZ7YMO3.mjs +0 -20
  247. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
  248. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
  249. package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
  250. package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
  251. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
  252. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
  253. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
  254. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
  255. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
  256. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
  257. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
  258. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
  259. package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
  260. package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
  261. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
  262. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
  263. package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
  264. package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
  265. package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
  266. package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
  267. package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
  268. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
  269. package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
  270. package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
  271. package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
  272. package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
  273. package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
  274. package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
  275. package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
  276. package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
  277. package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
  278. package/dist/lib/node/index.cjs +0 -289
  279. package/dist/lib/node/index.cjs.map +0 -7
  280. package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
  281. package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
  282. package/dist/lib/node/meta.json +0 -1
  283. package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
  284. package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
  285. package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
  286. package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
  287. package/dist/lib/node/types/index.cjs +0 -54
  288. package/dist/lib/node/types/index.cjs.map +0 -7
  289. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
  290. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
  291. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
  292. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
  293. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
  294. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
  295. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
  296. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
  297. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
  298. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
  299. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
  300. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
  301. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
  302. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
  303. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs +0 -22
  304. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
  305. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
  306. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
  307. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
  308. package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
  309. package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
  310. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
  311. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
  312. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
  313. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
  314. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
  315. package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
  316. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  317. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  318. package/dist/types/src/capabilities/capabilities.d.ts +0 -6
  319. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  320. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
  321. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
  322. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
  323. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
  324. package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
  325. package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
  326. package/dist/types/src/components/AssistantDialog.d.ts +0 -7
  327. package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
  328. package/dist/types/src/components/BlueprintContainer.d.ts +0 -9
  329. package/dist/types/src/components/BlueprintContainer.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/Thread/Thread.d.ts +0 -28
  351. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  352. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  353. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  354. package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
  355. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
  356. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
  357. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
  358. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
  359. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  360. package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
  361. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
  362. package/dist/types/src/components/Thread/index.d.ts +0 -3
  363. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  364. package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
  365. package/dist/types/src/experimental/transcription/index.d.ts +0 -1
  366. package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
  367. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  368. package/dist/types/src/hooks/processor.test.d.ts +0 -2
  369. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  370. package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
  371. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  372. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
  373. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  374. package/dist/types/src/hooks/useServices.d.ts +0 -7
  375. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  376. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  377. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  378. package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
  379. package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
  380. package/dist/types/src/stories/Query.stories.d.ts +0 -19
  381. package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
  382. package/dist/types/src/stories/Research.stories.d.ts +0 -15
  383. package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
  384. package/dist/types/src/stories/test-data.d.ts +0 -3
  385. package/dist/types/src/stories/test-data.d.ts.map +0 -1
  386. package/dist/types/src/stories/testing.d.ts +0 -12
  387. package/dist/types/src/stories/testing.d.ts.map +0 -1
  388. package/dist/types/src/testing/test-blueprint.d.ts +0 -8
  389. package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
  390. package/dist/types/src/types/chat.d.ts +0 -23
  391. package/dist/types/src/types/chat.d.ts.map +0 -1
  392. package/dist/types/src/types/template.d.ts +0 -56
  393. package/dist/types/src/types/template.d.ts.map +0 -1
  394. package/dist/types/src/types/types.d.ts +0 -50
  395. package/dist/types/src/types/types.d.ts.map +0 -1
  396. package/src/capabilities/ai-client.ts +0 -42
  397. package/src/capabilities/capabilities.ts +0 -15
  398. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
  399. package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
  400. package/src/components/AssistantDialog.tsx +0 -37
  401. package/src/components/BlueprintContainer.tsx +0 -148
  402. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
  403. package/src/components/BlueprintEditor/index.ts +0 -5
  404. package/src/components/Prompt/Prompt.stories.tsx +0 -121
  405. package/src/components/Prompt/Prompt.tsx +0 -124
  406. package/src/components/Prompt/PromptBar.stories.tsx +0 -69
  407. package/src/components/Prompt/PromptBar.tsx +0 -105
  408. package/src/components/Prompt/autocomplete.ts +0 -218
  409. package/src/components/Prompt/index.ts +0 -6
  410. package/src/components/Prompt/references.ts +0 -180
  411. package/src/components/Thread/Thread.stories.tsx +0 -201
  412. package/src/components/Thread/Thread.tsx +0 -118
  413. package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
  414. package/src/components/Thread/ThreadContainer.tsx +0 -105
  415. package/src/components/Thread/ThreadMessage.tsx +0 -234
  416. package/src/components/Thread/index.ts +0 -6
  417. package/src/hooks/processor.ts +0 -238
  418. package/src/hooks/useChatProcessor.tsx +0 -97
  419. package/src/hooks/useMessageQueue.ts +0 -22
  420. package/src/hooks/useServices.ts +0 -28
  421. package/src/hooks/useTextInputEvents.ts +0 -49
  422. package/src/stories/Prompt.stories.tsx +0 -60
  423. package/src/stories/Query.stories.tsx +0 -514
  424. package/src/stories/Research.stories.tsx +0 -482
  425. package/src/stories/test-data.ts +0 -128
  426. package/src/stories/testing.ts +0 -60
  427. package/src/testing/test-blueprint.ts +0 -58
  428. package/src/types/chat.ts +0 -32
  429. package/src/types/template.ts +0 -66
  430. package/src/types/types.ts +0 -48
@@ -1,283 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type StoryObj, type Meta } from '@storybook/react';
8
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
9
-
10
- import { EdgeAiServiceClient, Message } from '@dxos/ai';
11
- import {
12
- Capabilities,
13
- Events,
14
- IntentPlugin,
15
- SettingsPlugin,
16
- Surface,
17
- useCapabilities,
18
- useIntentDispatcher,
19
- } from '@dxos/app-framework';
20
- import { withPluginManager } from '@dxos/app-framework/testing';
21
- import { remoteServiceEndpoints } from '@dxos/artifact-testing';
22
- import { Filter, Obj, Query, Type } from '@dxos/echo';
23
- import { invariant } from '@dxos/invariant';
24
- import { ChessPlugin } from '@dxos/plugin-chess';
25
- import { ChessType } from '@dxos/plugin-chess/types';
26
- import { ClientPlugin } from '@dxos/plugin-client';
27
- import { InboxPlugin } from '@dxos/plugin-inbox';
28
- import { MapPlugin } from '@dxos/plugin-map';
29
- import { MarkdownPlugin } from '@dxos/plugin-markdown';
30
- import { SpacePlugin } from '@dxos/plugin-space';
31
- import { TablePlugin } from '@dxos/plugin-table';
32
- import { useClient } from '@dxos/react-client';
33
- import { useQueue, useQuery } from '@dxos/react-client/echo';
34
- import { IconButton, Input, Toolbar } from '@dxos/react-ui';
35
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
36
- import { withLayout, withTheme } from '@dxos/storybook-utils';
37
-
38
- import { Thread, type ThreadProps } from './Thread';
39
- import { ChatProcessor } from '../../hooks';
40
- import { createProcessorOptions } from '../../testing';
41
- import translations from '../../translations';
42
-
43
- // TODO(burdon): Configure for local with ollama/LM studio.
44
- // const endpoints = localServiceEndpoints;
45
- const endpoints = remoteServiceEndpoints;
46
-
47
- type RenderProps = {
48
- items?: Obj.Any[];
49
- prompts?: string[];
50
- } & Pick<ThreadProps, 'debug'>;
51
-
52
- // TODO(burdon): Use ChatContainer.
53
- const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) => {
54
- const client = useClient();
55
- const space = client.spaces.default;
56
-
57
- const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
58
- const tools = useCapabilities(Capabilities.Tools);
59
-
60
- const aiClient = useMemo(() => new EdgeAiServiceClient({ endpoint: endpoints.ai }), []);
61
- const { dispatchPromise: dispatch } = useIntentDispatcher();
62
-
63
- // TODO(burdon): Replace with useChatProcessor.
64
- // const processor = useChatProcessor(space);
65
- const processor = useMemo<ChatProcessor | undefined>(() => {
66
- if (!space) {
67
- return;
68
- }
69
-
70
- return new ChatProcessor(
71
- aiClient,
72
- tools.flat(),
73
- artifactDefinitions,
74
- {
75
- space,
76
- dispatch,
77
- },
78
- createProcessorOptions(artifactDefinitions.map((definition) => definition.instructions)),
79
- );
80
- }, [aiClient, tools, space, dispatch, artifactDefinitions]);
81
-
82
- // Queue.
83
- const [queueDxn, setQueueDxn] = useState<string>(() => space.queues.create().dxn.toString());
84
- const queue = useQueue<Message>(Type.DXN.tryParse(queueDxn));
85
-
86
- useEffect(() => {
87
- if (space) {
88
- setQueueDxn(space.queues.create().dxn.toString());
89
- }
90
- }, [space]);
91
-
92
- useEffect(() => {
93
- if (queue?.objects.length === 0 && !queue.isLoading && prompts.length > 0) {
94
- void queue.append([
95
- Obj.make(Message, {
96
- role: 'assistant',
97
- content: prompts.map(
98
- (prompt) =>
99
- ({
100
- type: 'json',
101
- disposition: 'suggest',
102
- json: JSON.stringify({ text: prompt }),
103
- }) as const,
104
- ),
105
- }),
106
- ]);
107
- }
108
- }, [queueDxn, prompts, queue?.objects.length, queue?.isLoading]);
109
-
110
- // State.
111
- const query = useMemo(
112
- () => Query.select(Filter.or(...artifactDefinitions.map((definition) => Filter.type(definition.schema)))),
113
- [artifactDefinitions],
114
- );
115
- const artifactItems = useQuery(space, query);
116
- const messages = [...(queue?.objects ?? []), ...(processor?.messages.value ?? [])];
117
-
118
- const handleSubmit = useCallback(
119
- (message: string) => {
120
- requestAnimationFrame(async () => {
121
- if (!processor || !queue) {
122
- return;
123
- }
124
-
125
- if (processor.streaming.value) {
126
- await processor.cancel();
127
- }
128
-
129
- await processor.request(message, {
130
- history: queue.objects,
131
- onComplete: (messages) => {
132
- void queue.append(messages);
133
- },
134
- });
135
- });
136
-
137
- return true;
138
- },
139
- [processor, queue],
140
- );
141
-
142
- const handleDelete = useCallback(
143
- (id: string) => {
144
- invariant(Type.ObjectId.isValid(id), 'Invalid message id');
145
- void queue?.delete([id]);
146
- },
147
- [queue],
148
- );
149
-
150
- if (!space) {
151
- return <></>;
152
- }
153
-
154
- return (
155
- <div className='grid grid-cols-2 w-full h-full divide-x divide-separator overflow-hidden'>
156
- {/* Thread */}
157
- <div className='flex flex-col gap-4 overflow-hidden'>
158
- <Toolbar.Root classNames='p-2'>
159
- <Input.Root>
160
- <Input.TextInput
161
- spellCheck={false}
162
- placeholder='Queue DXN'
163
- value={queueDxn}
164
- onChange={(ev) => setQueueDxn(ev.target.value)}
165
- />
166
- <IconButton
167
- iconOnly
168
- label='Copy DXN'
169
- icon='ph--copy--regular'
170
- onClick={() => navigator.clipboard.writeText(queueDxn)}
171
- />
172
- <IconButton
173
- iconOnly
174
- label='Clear history'
175
- icon='ph--trash--regular'
176
- onClick={() => setQueueDxn(space.queues.create().dxn.toString())}
177
- />
178
- <IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
179
- </Input.Root>
180
- </Toolbar.Root>
181
-
182
- {/* TODO(burdon): Replace with ThreadContainer. */}
183
- <Thread
184
- messages={messages}
185
- processing={processor?.streaming.value}
186
- error={processor?.error.value}
187
- tools={processor?.tools}
188
- onSubmit={processor ? handleSubmit : undefined}
189
- onPrompt={processor ? handleSubmit : undefined}
190
- onDelete={processor ? handleDelete : undefined}
191
- {...props}
192
- />
193
- </div>
194
-
195
- {/* Artifacts Deck */}
196
- <div className='overflow-hidden grid grid-rows-[2fr_1fr] divide-y divide-separator'>
197
- {artifactItems.length > 0 && (
198
- <div className={mx('flex grow overflow-hidden', artifactItems.length === 1 && 'row-span-2')}>
199
- <Surface role='article' limit={1} data={{ subject: artifactItems[0] }} fallback={Fallback} />
200
- </div>
201
- )}
202
-
203
- {artifactItems.length > 1 && (
204
- <div className='flex shrink-0 overflow-hidden divide-x divide-separator'>
205
- <div className='flex flex-1 h-full'>
206
- {artifactItems.slice(1, 3).map((item, idx) => (
207
- <Surface key={idx} role='article' limit={1} data={{ subject: item }} fallback={Fallback} />
208
- ))}
209
- </div>
210
- </div>
211
- )}
212
- </div>
213
- </div>
214
- );
215
- };
216
-
217
- const meta: Meta<typeof DefaultStory> = {
218
- title: 'plugins/plugin-assistant/ThreadContainer',
219
- render: DefaultStory,
220
- decorators: [
221
- withPluginManager({
222
- plugins: [
223
- ClientPlugin({
224
- onClientInitialized: async (_, client) => {
225
- await client.halo.createIdentity();
226
- },
227
- }),
228
- SpacePlugin(),
229
- SettingsPlugin(),
230
- IntentPlugin(),
231
-
232
- // Artifacts.
233
- ChessPlugin(),
234
- InboxPlugin(),
235
- MapPlugin(),
236
- MarkdownPlugin(),
237
- TablePlugin(),
238
- ],
239
- fireEvents: [Events.SetupArtifactDefinition],
240
- }),
241
- withTheme,
242
- withLayout({ fullscreen: true }),
243
- ],
244
- parameters: {
245
- translations,
246
- },
247
- };
248
-
249
- export default meta;
250
-
251
- type Story = StoryObj<typeof DefaultStory>;
252
-
253
- export const Default: Story = {
254
- args: {
255
- debug: true,
256
- prompts: ['What tools do you have access to?', 'Show me a chess puzzle'],
257
- },
258
- };
259
-
260
- export const WithInitialItems: Story = {
261
- args: {
262
- debug: true,
263
- items: [
264
- Obj.make(ChessType, {
265
- fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
266
- }),
267
- ],
268
- },
269
- };
270
-
271
- const Fallback = ({ error }: { error?: Error }) => {
272
- const errorString = error?.toString() ?? '';
273
- return (
274
- <div role='none' className='overflow-auto p-8 attention-surface grid place-items-center'>
275
- <p
276
- role='alert'
277
- className={mx(descriptionMessage, 'break-words rounded-md p-8', errorString.length < 256 && 'text-lg')}
278
- >
279
- {error ? errorString : 'error'}
280
- </p>
281
- </div>
282
- );
283
- };
@@ -1,105 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { useCallback, type FC, useEffect } from 'react';
6
-
7
- import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/app-framework';
8
- import { type AssociatedArtifact } from '@dxos/artifact';
9
- import { DXN, Ref } from '@dxos/echo';
10
- import { invariant } from '@dxos/invariant';
11
- import { log } from '@dxos/log';
12
- import { getSpace } from '@dxos/react-client/echo';
13
- import { type ThemedClassName } from '@dxos/react-ui';
14
-
15
- import { Thread, type ThreadProps } from './Thread';
16
- import { useChatProcessor, useContextProvider, useMessageQueue } from '../../hooks';
17
- import { type AIChatType, type AssistantSettingsProps } from '../../types';
18
-
19
- export type ThreadContainerProps = {
20
- chat?: AIChatType;
21
- settings?: AssistantSettingsProps;
22
- part?: 'deck' | 'dialog';
23
- associatedArtifact?: AssociatedArtifact;
24
- } & Pick<ThreadProps, 'debug' | 'transcription' | 'onOpenChange' | 'onAddToGraph'>;
25
-
26
- // TODO(burdon): Since this only wraps Thread, just separate out hook?
27
- export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
28
- classNames,
29
- chat,
30
- settings,
31
- part,
32
- associatedArtifact,
33
- onOpenChange,
34
- ...props
35
- }) => {
36
- const space = getSpace(chat);
37
- const contextProvider = useContextProvider(space);
38
- const processor = useChatProcessor({ chat, space, settings, part, associatedArtifact });
39
- const messageQueue = useMessageQueue(chat);
40
- const { dispatchPromise: dispatch } = useIntentDispatcher();
41
- // TODO(thure): This will be referentially new on every render, is it causing overreactivity?
42
- const messages = [...(messageQueue?.objects ?? []), ...processor.messages.value];
43
-
44
- // Post last message to document.
45
- useEffect(() => {
46
- if (!processor.streaming.value && messageQueue?.objects) {
47
- const message = messageQueue.objects[messageQueue.objects.length - 1];
48
- if (space && chat && message && dispatch && associatedArtifact) {
49
- void dispatch(
50
- createIntent(CollaborationActions.InsertContent, {
51
- target: associatedArtifact,
52
- object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
53
- label: 'View proposal',
54
- }),
55
- );
56
- }
57
- }
58
- }, [messageQueue, associatedArtifact, processor.streaming.value]);
59
-
60
- const handleSubmit = useCallback(
61
- (text: string) => {
62
- // Don't accept input if still processing.
63
- if (processor.streaming.value) {
64
- log.warn('ignoring submit; still processing.');
65
- return false;
66
- }
67
-
68
- onOpenChange?.(true);
69
-
70
- invariant(messageQueue);
71
- void processor.request(text, {
72
- history: messageQueue.objects,
73
- onComplete: (messages) => {
74
- void messageQueue.append(messages);
75
- },
76
- });
77
-
78
- return true;
79
- },
80
- [processor, messageQueue, onOpenChange],
81
- );
82
-
83
- const handleCancel = useCallback(() => {
84
- if (processor.streaming.value) {
85
- void processor.cancel();
86
- }
87
- }, [processor]);
88
-
89
- return (
90
- <Thread
91
- classNames={classNames}
92
- space={space}
93
- messages={messages}
94
- processing={processor.streaming.value}
95
- error={processor.error.value}
96
- tools={processor.tools}
97
- contextProvider={contextProvider}
98
- onSubmit={handleSubmit}
99
- onCancel={handleCancel}
100
- onPrompt={handleSubmit}
101
- onOpenChange={onOpenChange}
102
- {...props}
103
- />
104
- );
105
- };
@@ -1,234 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { type FC, type PropsWithChildren } from 'react';
6
-
7
- import { type MessageContentBlock, type Message, type Tool } from '@dxos/ai';
8
- import { Surface } from '@dxos/app-framework';
9
- import { type Obj } from '@dxos/echo';
10
- import { invariant } from '@dxos/invariant';
11
- import { type Space } from '@dxos/react-client/echo';
12
- import { Button, Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
13
- import {
14
- MarkdownViewer,
15
- ToggleContainer as NativeToggleContainer,
16
- type ToggleContainerProps,
17
- } from '@dxos/react-ui-components';
18
- import { Json } from '@dxos/react-ui-syntax-highlighter';
19
- import { mx } from '@dxos/react-ui-theme';
20
- import { safeParseJson } from '@dxos/util';
21
-
22
- import { ToolBlock, isToolMessage } from './ToolInvocations';
23
- import { ToolboxContainer } from '../Toolbox';
24
-
25
- const panelClassNames = 'flex flex-col w-full px-2 bg-activeSurface rounded-md';
26
- const userClassNames = 'bg-[--user-fill] text-accentSurfaceText';
27
-
28
- const ToggleContainer = (props: ToggleContainerProps) => {
29
- return <NativeToggleContainer {...props} classNames={mx(panelClassNames, props.classNames)} />;
30
- };
31
-
32
- const MessageContainer = ({ children, classNames, user }: ThemedClassName<PropsWithChildren<{ user?: boolean }>>) => {
33
- if (!children) {
34
- return null;
35
- }
36
-
37
- return (
38
- <div role='list-item' className={mx('flex w-full', user && 'justify-end', classNames)}>
39
- <div className={mx(user ? ['px-2 py-1 rounded-md', userClassNames] : 'w-full')}>{children}</div>
40
- </div>
41
- );
42
- };
43
-
44
- export type ThreadMessageProps = ThemedClassName<{
45
- space?: Space;
46
- message: Message;
47
- debug?: boolean;
48
- tools?: Tool[];
49
- onPrompt?: (text: string) => void;
50
- onDelete?: (id: string) => void;
51
- onAddToGraph?: (object: Obj.Any) => void;
52
- }>;
53
-
54
- export const ThreadMessage: FC<ThreadMessageProps> = ({
55
- classNames,
56
- space,
57
- message,
58
- tools,
59
- onPrompt,
60
- onAddToGraph,
61
- }) => {
62
- const { role, content = [] } = message;
63
-
64
- // TODO(burdon): Restructure types to make check unnecessary.
65
- if (isToolMessage(message)) {
66
- return (
67
- <MessageContainer classNames={mx(classNames, 'animate-[fadeIn_0.5s]')}>
68
- <ToolBlock space={space} classNames={panelClassNames} message={message} tools={tools} />
69
- </MessageContainer>
70
- );
71
- }
72
-
73
- return content.map((block, idx) => {
74
- // TODO(burdon): Filter empty messages.
75
- if (block.type === 'text' && block.text.replaceAll(/\s+/g, '').length === 0) {
76
- return null;
77
- }
78
-
79
- const Component = components[block.type] ?? components.default;
80
-
81
- return (
82
- <MessageContainer
83
- key={idx}
84
- classNames={mx(classNames, 'animate-[fadeIn_0.5s]')}
85
- user={block.type === 'text' && role === 'user'}
86
- >
87
- <Component space={space} block={block} onPrompt={onPrompt} onAddToGraph={onAddToGraph} />
88
- </MessageContainer>
89
- );
90
- });
91
- };
92
-
93
- type BlockComponent = FC<{
94
- space?: Space;
95
- block: MessageContentBlock;
96
- onPrompt?: (text: string) => void;
97
- onAddToGraph?: (object: Obj.Any) => void;
98
- }>;
99
-
100
- const components: Record<string, BlockComponent> = {
101
- //
102
- // Text
103
- //
104
- ['text' as const]: ({ block }) => {
105
- invariant(block.type === 'text');
106
- // const [open, setOpen] = useState(block.disposition === 'cot' && block.pending);
107
- const title = block.disposition ? titles[block.disposition] : undefined;
108
- if (!title) {
109
- return <MarkdownViewer classNames='[&>p]:animate-[fadeIn_0.5s]' content={block.text} />;
110
- }
111
-
112
- // TOOD(burdon): Store last time user opened/closed COT.
113
- // Autoclose when streaming ends.
114
- // useEffect(() => {
115
- // if (block.disposition === 'cot' && !block.pending) {
116
- // setOpen(false);
117
- // }
118
- // }, [block.disposition, block.pending]);
119
-
120
- return (
121
- <ToggleContainer
122
- // open={open}
123
- defaultOpen={systemDispositions.includes(block.disposition ?? '') && block.pending}
124
- title={title}
125
- icon={
126
- block.pending ? (
127
- <Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
128
- ) : undefined
129
- }
130
- >
131
- <MarkdownViewer
132
- content={block.text}
133
- classNames={['pbe-2', systemDispositions.includes(block.disposition ?? '') && 'text-sm text-subdued']}
134
- />
135
- </ToggleContainer>
136
- );
137
- },
138
-
139
- //
140
- // JSON
141
- //
142
- ['json' as const]: ({ space, block, onPrompt, onAddToGraph }) => {
143
- invariant(block.type === 'json');
144
-
145
- switch (block.disposition) {
146
- case 'tool_list': {
147
- return (
148
- <ToggleContainer title={titles[block.disposition]} defaultOpen={true}>
149
- <ToolboxContainer space={space} classNames='pbe-2' />
150
- </ToggleContainer>
151
- );
152
- }
153
-
154
- case 'suggest': {
155
- const { text = '' }: { text: string } = safeParseJson(block.json ?? '{}') ?? ({} as any);
156
- return <IconButton icon='ph--lightning--regular' label={text} onClick={() => onPrompt?.(text)} />;
157
- }
158
-
159
- case 'select': {
160
- const { options = [] }: { options: string[] } = safeParseJson(block.json ?? '{}') ?? ({} as any);
161
- return (
162
- <div className='flex flex-wrap gap-1'>
163
- {options.map((option, idx) => (
164
- <Button
165
- classNames={'animate-[fadeIn_0.5s] rounded-2xl text-sm'}
166
- key={option}
167
- onClick={() => onPrompt?.(option)}
168
- >
169
- {option}
170
- </Button>
171
- ))}
172
- </div>
173
- );
174
- }
175
-
176
- case 'graph': {
177
- return (
178
- <div className='flex flex-wrap gap-1'>
179
- <Surface
180
- role='card'
181
- data={{ subject: JSON.parse(block.json ?? '{}') }}
182
- limit={1}
183
- fallback={<div className='font-mono text-xs text-pre'>{block.json}</div>}
184
- />
185
- {onAddToGraph && (
186
- <IconButton
187
- icon='ph--plus--regular'
188
- label='Add to graph'
189
- onClick={() => onAddToGraph?.(JSON.parse(block.json ?? '{}'))}
190
- />
191
- )}
192
- </div>
193
- );
194
- }
195
-
196
- default: {
197
- const title = block.disposition ? titles[block.disposition] : undefined;
198
- return (
199
- <ToggleContainer title={title ?? 'JSON'}>
200
- <Json data={safeParseJson(block.json ?? block)} classNames='!p-1 text-xs' />
201
- </ToggleContainer>
202
- );
203
- }
204
- }
205
- },
206
-
207
- //
208
- // Default
209
- //
210
- default: ({ block }) => {
211
- let title = titles[block.type];
212
- if (block.type === 'tool_use') {
213
- title = `Tool [${block.name}]`; // TODO(burdon): Get label from tool.
214
- }
215
-
216
- return (
217
- <ToggleContainer title={title ?? 'JSON'}>
218
- <Json data={block} classNames='!p-1 text-xs' />
219
- </ToggleContainer>
220
- );
221
- },
222
- };
223
-
224
- // TODO(burdon): Translations.
225
- const titles: Record<string, string> = {
226
- ['cot' as const]: 'Chain of thought',
227
- ['artifact' as const]: 'Artifact',
228
- ['tool_use' as const]: 'Tool request',
229
- ['tool_result' as const]: 'Tool result',
230
- ['tool_list' as const]: 'Tools',
231
- ['artifact-update' as const]: 'Artifact(s) changed',
232
- };
233
-
234
- const systemDispositions: string[] = ['cot', 'artifact-update'];
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export * from './Thread';
6
- export * from './ThreadContainer';