@dxos/plugin-assistant 0.7.5-labs.a8b535d

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 (305) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +15 -0
  3. package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs +116 -0
  4. package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs.map +7 -0
  5. package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs +33 -0
  6. package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs.map +7 -0
  7. package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs +23 -0
  8. package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs.map +7 -0
  9. package/dist/lib/browser/ai-client-RTCGRKZE.mjs +22 -0
  10. package/dist/lib/browser/ai-client-RTCGRKZE.mjs.map +7 -0
  11. package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs +110 -0
  12. package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-EUMPBC4T.mjs +81 -0
  14. package/dist/lib/browser/chunk-EUMPBC4T.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-FRIKXDDQ.mjs +162 -0
  16. package/dist/lib/browser/chunk-FRIKXDDQ.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-G7B54APW.mjs +106 -0
  18. package/dist/lib/browser/chunk-G7B54APW.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-NFVIZS3B.mjs +1804 -0
  20. package/dist/lib/browser/chunk-NFVIZS3B.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-NV7SVHMV.mjs +20 -0
  22. package/dist/lib/browser/chunk-NV7SVHMV.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-VZ4W6SHE.mjs +15 -0
  24. package/dist/lib/browser/chunk-VZ4W6SHE.mjs.map +7 -0
  25. package/dist/lib/browser/index.mjs +218 -0
  26. package/dist/lib/browser/index.mjs.map +7 -0
  27. package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs +44 -0
  28. package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs.map +7 -0
  29. package/dist/lib/browser/meta.json +1 -0
  30. package/dist/lib/browser/react-surface-JLXNWOI6.mjs +69 -0
  31. package/dist/lib/browser/react-surface-JLXNWOI6.mjs.map +7 -0
  32. package/dist/lib/browser/settings-JTT62IHD.mjs +22 -0
  33. package/dist/lib/browser/settings-JTT62IHD.mjs.map +7 -0
  34. package/dist/lib/browser/types/index.mjs +24 -0
  35. package/dist/lib/browser/types/index.mjs.map +7 -0
  36. package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs +140 -0
  37. package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs.map +7 -0
  38. package/dist/lib/node/ChatContainer-CVHXNHGA.cjs +61 -0
  39. package/dist/lib/node/ChatContainer-CVHXNHGA.cjs.map +7 -0
  40. package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs +53 -0
  41. package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs.map +7 -0
  42. package/dist/lib/node/ai-client-YANJEPO3.cjs +38 -0
  43. package/dist/lib/node/ai-client-YANJEPO3.cjs.map +7 -0
  44. package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs +122 -0
  45. package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs.map +7 -0
  46. package/dist/lib/node/chunk-37GI4NYH.cjs +183 -0
  47. package/dist/lib/node/chunk-37GI4NYH.cjs.map +7 -0
  48. package/dist/lib/node/chunk-GNPXCHFT.cjs +44 -0
  49. package/dist/lib/node/chunk-GNPXCHFT.cjs.map +7 -0
  50. package/dist/lib/node/chunk-IXJCGW7U.cjs +130 -0
  51. package/dist/lib/node/chunk-IXJCGW7U.cjs.map +7 -0
  52. package/dist/lib/node/chunk-NV4TQQSU.cjs +111 -0
  53. package/dist/lib/node/chunk-NV4TQQSU.cjs.map +7 -0
  54. package/dist/lib/node/chunk-XUTDR7HI.cjs +1781 -0
  55. package/dist/lib/node/chunk-XUTDR7HI.cjs.map +7 -0
  56. package/dist/lib/node/chunk-ZGH6F5YA.cjs +34 -0
  57. package/dist/lib/node/chunk-ZGH6F5YA.cjs.map +7 -0
  58. package/dist/lib/node/index.cjs +226 -0
  59. package/dist/lib/node/index.cjs.map +7 -0
  60. package/dist/lib/node/intent-resolver-YMMAFVOB.cjs +58 -0
  61. package/dist/lib/node/intent-resolver-YMMAFVOB.cjs.map +7 -0
  62. package/dist/lib/node/meta.json +1 -0
  63. package/dist/lib/node/react-surface-BSUZQ3HZ.cjs +85 -0
  64. package/dist/lib/node/react-surface-BSUZQ3HZ.cjs.map +7 -0
  65. package/dist/lib/node/settings-4YEO7KXF.cjs +36 -0
  66. package/dist/lib/node/settings-4YEO7KXF.cjs.map +7 -0
  67. package/dist/lib/node/types/index.cjs +46 -0
  68. package/dist/lib/node/types/index.cjs.map +7 -0
  69. package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs +117 -0
  70. package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs.map +7 -0
  71. package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs +34 -0
  72. package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs.map +7 -0
  73. package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs +24 -0
  74. package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs.map +7 -0
  75. package/dist/lib/node-esm/ai-client-66IBZVCX.mjs +23 -0
  76. package/dist/lib/node-esm/ai-client-66IBZVCX.mjs.map +7 -0
  77. package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs +111 -0
  78. package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-77ARTFBA.mjs +16 -0
  80. package/dist/lib/node-esm/chunk-77ARTFBA.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-7JENJTLB.mjs +1805 -0
  82. package/dist/lib/node-esm/chunk-7JENJTLB.mjs.map +7 -0
  83. package/dist/lib/node-esm/chunk-7SV6X6XU.mjs +22 -0
  84. package/dist/lib/node-esm/chunk-7SV6X6XU.mjs.map +7 -0
  85. package/dist/lib/node-esm/chunk-AMQMVQJO.mjs +107 -0
  86. package/dist/lib/node-esm/chunk-AMQMVQJO.mjs.map +7 -0
  87. package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs +163 -0
  88. package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs.map +7 -0
  89. package/dist/lib/node-esm/chunk-LBQGJE5T.mjs +82 -0
  90. package/dist/lib/node-esm/chunk-LBQGJE5T.mjs.map +7 -0
  91. package/dist/lib/node-esm/index.mjs +219 -0
  92. package/dist/lib/node-esm/index.mjs.map +7 -0
  93. package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs +45 -0
  94. package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs.map +7 -0
  95. package/dist/lib/node-esm/meta.json +1 -0
  96. package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs +70 -0
  97. package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs.map +7 -0
  98. package/dist/lib/node-esm/settings-S7P5RWQI.mjs +23 -0
  99. package/dist/lib/node-esm/settings-S7P5RWQI.mjs.map +7 -0
  100. package/dist/lib/node-esm/types/index.mjs +25 -0
  101. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  102. package/dist/types/src/AssistantPlugin.d.ts +2 -0
  103. package/dist/types/src/AssistantPlugin.d.ts.map +1 -0
  104. package/dist/types/src/capabilities/ai-client.d.ts +5 -0
  105. package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
  106. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  107. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  108. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  109. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  110. package/dist/types/src/capabilities/index.d.ts +183 -0
  111. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  112. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  113. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  114. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  115. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  116. package/dist/types/src/capabilities/settings.d.ts +4 -0
  117. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  118. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
  119. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
  120. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
  121. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
  122. package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
  123. package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
  124. package/dist/types/src/components/AssistantDialog.d.ts +7 -0
  125. package/dist/types/src/components/AssistantDialog.d.ts.map +1 -0
  126. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +5 -0
  127. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -0
  128. package/dist/types/src/components/AssistantSettings/index.d.ts +2 -0
  129. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -0
  130. package/dist/types/src/components/ChatContainer.d.ts +7 -0
  131. package/dist/types/src/components/ChatContainer.d.ts.map +1 -0
  132. package/dist/types/src/components/Prompt/Prompt.d.ts +17 -0
  133. package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
  134. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
  135. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
  136. package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
  137. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
  138. package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
  139. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
  140. package/dist/types/src/components/Prompt/index.d.ts +3 -0
  141. package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
  142. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
  143. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
  144. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
  145. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
  146. package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
  147. package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
  148. package/dist/types/src/components/TemplateContainer.d.ts +7 -0
  149. package/dist/types/src/components/TemplateContainer.d.ts.map +1 -0
  150. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +12 -0
  151. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
  152. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +12 -0
  153. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
  154. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +10 -0
  155. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
  156. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +8 -0
  157. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
  158. package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
  159. package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
  160. package/dist/types/src/components/TemplateEditor/types.d.ts +18 -0
  161. package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
  162. package/dist/types/src/components/Thread/Thread.d.ts +17 -0
  163. package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
  164. package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
  165. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
  166. package/dist/types/src/components/Thread/ThreadContainer.d.ts +10 -0
  167. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
  168. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
  169. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
  170. package/dist/types/src/components/Thread/ThreadMessage.d.ts +14 -0
  171. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
  172. package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
  173. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
  174. package/dist/types/src/components/Thread/index.d.ts +3 -0
  175. package/dist/types/src/components/Thread/index.d.ts.map +1 -0
  176. package/dist/types/src/components/Thread/reducer.d.ts +12 -0
  177. package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
  178. package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
  179. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
  180. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
  181. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
  182. package/dist/types/src/components/Toolbox/index.d.ts +2 -0
  183. package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
  184. package/dist/types/src/components/index.d.ts +17 -0
  185. package/dist/types/src/components/index.d.ts.map +1 -0
  186. package/dist/types/src/hooks/email.d.ts +4 -0
  187. package/dist/types/src/hooks/email.d.ts.map +1 -0
  188. package/dist/types/src/hooks/index.d.ts +7 -0
  189. package/dist/types/src/hooks/index.d.ts.map +1 -0
  190. package/dist/types/src/hooks/invocation-handler.d.ts +5 -0
  191. package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -0
  192. package/dist/types/src/hooks/processor.d.ts +76 -0
  193. package/dist/types/src/hooks/processor.d.ts.map +1 -0
  194. package/dist/types/src/hooks/processor.test.d.ts +2 -0
  195. package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
  196. package/dist/types/src/hooks/useChatProcessor.d.ts +8 -0
  197. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
  198. package/dist/types/src/hooks/useLocalTriggerManager.d.ts +3 -0
  199. package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +1 -0
  200. package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
  201. package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
  202. package/dist/types/src/hooks/useServices.d.ts +7 -0
  203. package/dist/types/src/hooks/useServices.d.ts.map +1 -0
  204. package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
  205. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
  206. package/dist/types/src/index.d.ts +5 -0
  207. package/dist/types/src/index.d.ts.map +1 -0
  208. package/dist/types/src/meta.d.ts +11 -0
  209. package/dist/types/src/meta.d.ts.map +1 -0
  210. package/dist/types/src/testing/index.d.ts +3 -0
  211. package/dist/types/src/testing/index.d.ts.map +1 -0
  212. package/dist/types/src/testing/test-functions.d.ts +3 -0
  213. package/dist/types/src/testing/test-functions.d.ts.map +1 -0
  214. package/dist/types/src/testing/test-services.d.ts +5 -0
  215. package/dist/types/src/testing/test-services.d.ts.map +1 -0
  216. package/dist/types/src/tools/function.d.ts +5 -0
  217. package/dist/types/src/tools/function.d.ts.map +1 -0
  218. package/dist/types/src/tools/index.d.ts +3 -0
  219. package/dist/types/src/tools/index.d.ts.map +1 -0
  220. package/dist/types/src/tools/openapi.d.ts +10 -0
  221. package/dist/types/src/tools/openapi.d.ts.map +1 -0
  222. package/dist/types/src/tools/openapi.test.d.ts +2 -0
  223. package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
  224. package/dist/types/src/translations.d.ts +82 -0
  225. package/dist/types/src/translations.d.ts.map +1 -0
  226. package/dist/types/src/types/chat.d.ts +12 -0
  227. package/dist/types/src/types/chat.d.ts.map +1 -0
  228. package/dist/types/src/types/index.d.ts +5 -0
  229. package/dist/types/src/types/index.d.ts.map +1 -0
  230. package/dist/types/src/types/service.d.ts +160 -0
  231. package/dist/types/src/types/service.d.ts.map +1 -0
  232. package/dist/types/src/types/template.d.ts +40 -0
  233. package/dist/types/src/types/template.d.ts.map +1 -0
  234. package/dist/types/src/types/types.d.ts +37 -0
  235. package/dist/types/src/types/types.d.ts.map +1 -0
  236. package/dist/types/tsconfig.tsbuildinfo +1 -0
  237. package/package.json +120 -0
  238. package/src/AssistantPlugin.tsx +105 -0
  239. package/src/capabilities/ai-client.ts +19 -0
  240. package/src/capabilities/app-graph-builder.ts +100 -0
  241. package/src/capabilities/capabilities.ts +12 -0
  242. package/src/capabilities/index.ts +13 -0
  243. package/src/capabilities/intent-resolver.ts +38 -0
  244. package/src/capabilities/react-surface.tsx +49 -0
  245. package/src/capabilities/settings.ts +19 -0
  246. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
  247. package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
  248. package/src/components/AmbientDialog/index.ts +5 -0
  249. package/src/components/AssistantDialog.tsx +31 -0
  250. package/src/components/AssistantSettings/AssistantSettings.tsx +49 -0
  251. package/src/components/AssistantSettings/index.ts +5 -0
  252. package/src/components/ChatContainer.tsx +27 -0
  253. package/src/components/Prompt/Prompt.stories.tsx +79 -0
  254. package/src/components/Prompt/Prompt.tsx +100 -0
  255. package/src/components/Prompt/PromptBar.tsx +100 -0
  256. package/src/components/Prompt/autocomplete.ts +212 -0
  257. package/src/components/Prompt/index.ts +6 -0
  258. package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
  259. package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
  260. package/src/components/ServiceRegistry/index.ts +5 -0
  261. package/src/components/TemplateContainer.tsx +21 -0
  262. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +83 -0
  263. package/src/components/TemplateEditor/TemplateEditor.tsx +76 -0
  264. package/src/components/TemplateEditor/TemplateForm.stories.tsx +65 -0
  265. package/src/components/TemplateEditor/TemplateForm.tsx +184 -0
  266. package/src/components/TemplateEditor/index.ts +5 -0
  267. package/src/components/TemplateEditor/types.tsx +28 -0
  268. package/src/components/Thread/Thread.stories.tsx +212 -0
  269. package/src/components/Thread/Thread.tsx +97 -0
  270. package/src/components/Thread/ThreadContainer.stories.tsx +268 -0
  271. package/src/components/Thread/ThreadContainer.tsx +79 -0
  272. package/src/components/Thread/ThreadMessage.tsx +188 -0
  273. package/src/components/Thread/ToolInvocations.tsx +104 -0
  274. package/src/components/Thread/index.ts +6 -0
  275. package/src/components/Thread/reducer.ts +52 -0
  276. package/src/components/Toolbox/Toolbox.stories.tsx +69 -0
  277. package/src/components/Toolbox/Toolbox.tsx +115 -0
  278. package/src/components/Toolbox/index.ts +5 -0
  279. package/src/components/index.ts +15 -0
  280. package/src/hooks/email.ts +49 -0
  281. package/src/hooks/index.ts +11 -0
  282. package/src/hooks/invocation-handler.ts +109 -0
  283. package/src/hooks/processor.test.ts +15 -0
  284. package/src/hooks/processor.ts +228 -0
  285. package/src/hooks/useChatProcessor.tsx +80 -0
  286. package/src/hooks/useLocalTriggerManager.ts +82 -0
  287. package/src/hooks/useMessageQueue.ts +23 -0
  288. package/src/hooks/useServices.ts +28 -0
  289. package/src/hooks/useTextInputEvents.ts +49 -0
  290. package/src/index.ts +9 -0
  291. package/src/meta.ts +18 -0
  292. package/src/testing/index.ts +6 -0
  293. package/src/testing/test-functions.ts +11 -0
  294. package/src/testing/test-services.ts +131 -0
  295. package/src/tools/function.ts +47 -0
  296. package/src/tools/index.ts +6 -0
  297. package/src/tools/openapi.test.ts +224 -0
  298. package/src/tools/openapi.ts +331 -0
  299. package/src/translations.ts +49 -0
  300. package/src/types/chat.ts +11 -0
  301. package/src/types/index.ts +8 -0
  302. package/src/types/service.ts +102 -0
  303. package/src/types/template.ts +34 -0
  304. package/src/types/types.ts +41 -0
  305. package/src/typings.d.ts +9 -0
@@ -0,0 +1,69 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import '@dxos-theme';
6
+
7
+ import { type Meta } from '@storybook/react';
8
+ import React from 'react';
9
+
10
+ import { IntentPlugin, Capabilities, useCapabilities, SettingsPlugin } from '@dxos/app-framework';
11
+ import { withPluginManager } from '@dxos/app-framework/testing';
12
+ import { capabilities } from '@dxos/artifact-testing';
13
+ import { ChessPlugin } from '@dxos/plugin-chess';
14
+ import { ClientPlugin } from '@dxos/plugin-client';
15
+ import { MapPlugin } from '@dxos/plugin-map';
16
+ import { SpacePlugin } from '@dxos/plugin-space';
17
+ import { TablePlugin } from '@dxos/plugin-table';
18
+ import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
19
+
20
+ import { Toolbox, type ToolboxProps } from './Toolbox';
21
+ import translations from '../../translations';
22
+
23
+ const Render = (props: ToolboxProps) => {
24
+ const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
25
+ return (
26
+ <Toolbox
27
+ {...props}
28
+ artifacts={artifactDefinitions}
29
+ classNames='w-[30rem] h-[15rem] rounded-md border border-separator py-1'
30
+ />
31
+ );
32
+ };
33
+
34
+ const meta: Meta<typeof Toolbox> = {
35
+ title: 'plugins/plugin-automation/Toolbox',
36
+ component: Toolbox,
37
+ render: Render,
38
+ decorators: [
39
+ withSignals,
40
+ withPluginManager({
41
+ plugins: [
42
+ ClientPlugin({
43
+ onClientInitialized: async (_, client) => {
44
+ await client.halo.createIdentity();
45
+ },
46
+ }),
47
+ SpacePlugin({ observability: false }),
48
+ SettingsPlugin(),
49
+ IntentPlugin(),
50
+ ChessPlugin(),
51
+ MapPlugin(),
52
+ TablePlugin(),
53
+ ],
54
+ capabilities,
55
+ }),
56
+ withTheme,
57
+ withLayout({ tooltips: true }),
58
+ ],
59
+ parameters: {
60
+ translations,
61
+ layout: 'centered',
62
+ },
63
+ };
64
+
65
+ export default meta;
66
+
67
+ type Story = Meta<typeof Toolbox>;
68
+
69
+ export const Default: Story = {};
@@ -0,0 +1,115 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useState, useEffect, Fragment, type FC } from 'react';
6
+
7
+ import { Capabilities, useCapabilities } from '@dxos/app-framework';
8
+ import { parseToolName, type ArtifactDefinition, type Tool } from '@dxos/artifact';
9
+ import { FunctionType } from '@dxos/functions';
10
+ import { log } from '@dxos/log';
11
+ import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
12
+ import { type ThemedClassName } from '@dxos/react-ui';
13
+ import { mx } from '@dxos/react-ui-theme';
14
+
15
+ import { createToolsFromService } from '../../tools';
16
+ import { ServiceType } from '../../types';
17
+
18
+ export type ToolboxProps = ThemedClassName<{
19
+ artifacts?: ArtifactDefinition[];
20
+ services?: { service: ServiceType; tools: Tool[] }[];
21
+ functions?: FunctionType[];
22
+ striped?: boolean;
23
+ }>;
24
+
25
+ export const Toolbox = ({ classNames, artifacts, functions, services, striped }: ToolboxProps) => {
26
+ return (
27
+ <div className={mx('flex flex-col overflow-y-auto box-content', classNames)}>
28
+ {artifacts && artifacts.length > 0 && (
29
+ <Section
30
+ title='Artifacts'
31
+ items={artifacts.map(({ name, description, tools }) => ({
32
+ name,
33
+ description,
34
+ subitems: tools.map(({ name, description }) => ({ name: `∙ ${parseToolName(name)}`, description })),
35
+ }))}
36
+ />
37
+ )}
38
+
39
+ {services && services.length > 0 && (
40
+ <Section
41
+ title='Services'
42
+ items={services.map(({ service: { serviceId, name, description }, tools }) => ({
43
+ name: name ?? serviceId,
44
+ description,
45
+ subitems: tools.map(({ name, description }) => ({ name: `∙ ${name}`, description })),
46
+ }))}
47
+ />
48
+ )}
49
+
50
+ {functions && functions.length > 0 && (
51
+ <Section title='Functions' items={functions.map(({ name, description }) => ({ name, description }))} />
52
+ )}
53
+ </div>
54
+ );
55
+ };
56
+
57
+ const Section: FC<{
58
+ title: string;
59
+ items: { name: string; description?: string; subitems?: { name: string; description?: string }[] }[];
60
+ striped?: boolean;
61
+ }> = ({ title, items, striped }) => {
62
+ const stripeClassNames = 'odd:bg-neutral-50 dark:odd:bg-neutral-800';
63
+ const gridClassNames = 'grid grid-cols-[8rem_1fr]';
64
+ const subGridClassNames = mx('col-span-full grid grid-cols-subgrid text-xs px-2', striped && stripeClassNames);
65
+
66
+ return (
67
+ <div>
68
+ <h1 className='px-2 text-sm'>{title}</h1>
69
+ <div className={gridClassNames}>
70
+ {items.map(({ name, description, subitems }, i) => (
71
+ <Fragment key={i}>
72
+ {name && (
73
+ <div className={subGridClassNames}>
74
+ <div className='truncate text-primary-500'>{name}</div>
75
+ <div className='line-clamp-2'>{description}</div>
76
+ </div>
77
+ )}
78
+ {subitems?.map(({ name, description }, i) => (
79
+ <div key={i} className={mx(subGridClassNames, striped && stripeClassNames)}>
80
+ <div className='truncate'>{name}</div>
81
+ <div className='line-clamp-3 text-subdued'>{description}</div>
82
+ </div>
83
+ ))}
84
+ </Fragment>
85
+ ))}
86
+ </div>
87
+ </div>
88
+ );
89
+ };
90
+
91
+ export const ToolboxContainer = ({ classNames, space }: ThemedClassName<{ space?: Space }>) => {
92
+ // Plugin artifacts.
93
+ const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
94
+
95
+ // Registered services.
96
+ const services = useQuery(space, Filter.schema(ServiceType));
97
+ const [serviceTools, setServiceTools] = useState<{ service: ServiceType; tools: Tool[] }[]>([]);
98
+ useEffect(() => {
99
+ log('creating service tools...', { services: services.length });
100
+ queueMicrotask(async () => {
101
+ const tools = await Promise.all(
102
+ services.map(async (service) => ({ service, tools: await createToolsFromService(service) })),
103
+ );
104
+
105
+ setServiceTools(tools);
106
+ });
107
+ }, [services]);
108
+
109
+ // Deployed functions.
110
+ const functions = useQuery(space, Filter.schema(FunctionType));
111
+
112
+ return (
113
+ <Toolbox classNames={classNames} artifacts={artifactDefinitions} services={serviceTools} functions={functions} />
114
+ );
115
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './Toolbox';
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { lazy } from 'react';
6
+
7
+ export * from './AssistantSettings';
8
+ export * from './ServiceRegistry';
9
+ export * from './TemplateEditor';
10
+ export * from './Thread';
11
+ export * from './Toolbox';
12
+
13
+ export const AssistantDialog = lazy(() => import('./AssistantDialog'));
14
+ export const ChatContainer = lazy(() => import('./ChatContainer'));
15
+ export const TemplateContainer = lazy(() => import('./TemplateContainer'));
@@ -0,0 +1,49 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { findObjectWithForeignKey } from '@dxos/echo-db';
6
+ import { foreignKey } from '@dxos/echo-schema';
7
+ import { log } from '@dxos/log';
8
+ import { MailboxType } from '@dxos/plugin-inbox/types';
9
+ import { MessageType } from '@dxos/plugin-space/types';
10
+ import { type Space, Filter, create, makeRef } from '@dxos/react-client/echo';
11
+
12
+ export const SOURCE_ID = 'hub.dxos.network/api/mailbox';
13
+
14
+ export const handleEmail = async (space: Space, data: any) => {
15
+ const { messages } = data;
16
+
17
+ // Create mailbox if doesn't exist.
18
+ const { objects: mailboxes } = await space.db.query(Filter.schema(MailboxType)).run();
19
+ const mailbox = mailboxes[0] ?? space.db.add(create(MailboxType, { messages: [] }));
20
+
21
+ log.info('messages', { count: messages.length, existingMailbox: mailboxes.length > 0 });
22
+
23
+ const { objects } = await space.db.query(Filter.schema(MessageType)).run();
24
+ for (const message of messages) {
25
+ let object = findObjectWithForeignKey(objects, { source: SOURCE_ID, id: String(message.id) });
26
+ if (!object) {
27
+ object = space.db.add(
28
+ create(
29
+ MessageType,
30
+ {
31
+ sender: { email: message.from },
32
+ timestamp: new Date(message.created).toISOString(),
33
+ text: message.body,
34
+ properties: {
35
+ subject: message.subject,
36
+ to: [{ email: message.to }],
37
+ },
38
+ },
39
+ {
40
+ keys: [foreignKey(SOURCE_ID, String(message.id))],
41
+ },
42
+ ),
43
+ );
44
+ mailbox.messages?.push(makeRef(object));
45
+ }
46
+ }
47
+
48
+ return 200;
49
+ };
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './processor';
6
+
7
+ export * from './useChatProcessor';
8
+ export * from './useLocalTriggerManager';
9
+ export * from './useMessageQueue';
10
+ export * from './useServices';
11
+ export * from './useTextInputEvents';
@@ -0,0 +1,109 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { sleep } from '@dxos/async';
6
+ import { getObjectCore, ResultFormat } from '@dxos/echo-db';
7
+ import { type AnyObjectData } from '@dxos/echo-schema';
8
+ import { FunctionType } from '@dxos/functions';
9
+ import { type FunctionTrigger } from '@dxos/functions';
10
+ import { invariant } from '@dxos/invariant';
11
+ import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
12
+ import { log } from '@dxos/log';
13
+ import { type Client, type Config } from '@dxos/react-client';
14
+ import { type Space } from '@dxos/react-client/echo';
15
+
16
+ const MAX_RETRIES = 3;
17
+ const RETRY_DELAY = 1_000;
18
+
19
+ const callFunction = async (funcUrl: string, trigger: any, data: any) => {
20
+ const body = { event: 'trigger', trigger, data };
21
+
22
+ let retryCount = 0;
23
+ while (retryCount < MAX_RETRIES) {
24
+ log.info('exec', { funcUrl, body, retryCount });
25
+ const response = await fetch(funcUrl, {
26
+ method: 'POST',
27
+ headers: {
28
+ 'Content-Type': 'application/json',
29
+ },
30
+ body: JSON.stringify(body),
31
+ });
32
+
33
+ const data = await response.text();
34
+ log.info('response', { status: response.status, body: data });
35
+ if (response.status === 409) {
36
+ retryCount++;
37
+ await sleep(RETRY_DELAY * Math.min(retryCount, 2));
38
+ continue;
39
+ }
40
+
41
+ return { status: response.status, data };
42
+ }
43
+ return { status: 500 };
44
+ };
45
+
46
+ export const invokeFunction = async (client: Client, space: Space, trigger: FunctionTrigger, data: any) => {
47
+ try {
48
+ invariant(trigger.spec);
49
+ invariant(trigger.function);
50
+
51
+ const script = await space.db.query({ id: trigger.function }, { format: ResultFormat.Plain }).first();
52
+ const { objects: functions } = await space.db
53
+ .query({ __typename: FunctionType.typename }, { format: ResultFormat.Plain })
54
+ .run();
55
+ const func = functions.find((fn) => referenceEquals(fn.source, trigger.function!)) as AnyObjectData | undefined;
56
+ const funcSlug = func?.__meta.keys.find((key) => key.source === USERFUNCTIONS_META_KEY)?.id;
57
+ if (!funcSlug) {
58
+ log.warn('function not deployed', { scriptId: script.id, name: script.name });
59
+ return 404;
60
+ }
61
+
62
+ const funcUrl = getFunctionUrl(client.config, funcSlug, space.id);
63
+ const triggerData: AnyObjectData = {
64
+ ...getObjectCore(trigger).toPlainObject(),
65
+ // TODO: Remove when functions can query by DXN.
66
+ promptId: trigger.meta?.prompt?.id,
67
+ };
68
+ // TODO: Remove when functions can add objects and easily modify collections (push, splice).
69
+ return (await callFunction(funcUrl, triggerData, data)).status;
70
+ } catch (err) {
71
+ return 400;
72
+ }
73
+ };
74
+
75
+ const USERFUNCTIONS_META_KEY = 'dxos.org/service/function';
76
+
77
+ const getFunctionUrl = (config: Config, slug: string, spaceId?: string) => {
78
+ const baseUrl = new URL('functions/', config.values.runtime?.services?.edge?.url);
79
+
80
+ // Leading slashes cause the URL to be treated as an absolute path.
81
+ const relativeUrl = slug.replace(/^\//, '');
82
+ const url = new URL(`./${relativeUrl}`, baseUrl.toString());
83
+ spaceId && url.searchParams.set('spaceId', spaceId);
84
+ url.protocol = 'https';
85
+ return url.toString();
86
+ };
87
+
88
+ // TODO(dmaretskyi): Factor out.
89
+
90
+ type ReferenceLike = { '/': string } | string;
91
+
92
+ const referenceEquals = (a: ReferenceLike, b: ReferenceLike): boolean => {
93
+ const aDXN = toDXN(a);
94
+ const bDXN = toDXN(b);
95
+ return aDXN.toString() === bDXN.toString();
96
+ };
97
+
98
+ const toDXN = (ref: ReferenceLike): DXN => {
99
+ if (typeof ref === 'string') {
100
+ if (ref.startsWith('dxn:')) {
101
+ return DXN.parse(ref);
102
+ } else {
103
+ return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, ref]);
104
+ }
105
+ }
106
+
107
+ invariant(typeof ref['/'] === 'string');
108
+ return DXN.parse(ref['/']);
109
+ };
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, it } from 'vitest';
6
+
7
+ import { ChatProcessor } from './processor';
8
+
9
+ describe('ChatProcessor', () => {
10
+ it('should be instantiable', ({ expect }) => {
11
+ const client = {} as any; // TODO(burdon): Create mock.
12
+ const processor = new ChatProcessor(client);
13
+ expect(processor).toBeDefined();
14
+ });
15
+ });
@@ -0,0 +1,228 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Signal, batch, computed, signal } from '@preact/signals-core';
6
+
7
+ import { type PromiseIntentDispatcher } from '@dxos/app-framework';
8
+ import { type Tool, Message, type MessageContentBlock } from '@dxos/artifact';
9
+ import {
10
+ isToolUse,
11
+ runTools,
12
+ type GenerateRequest,
13
+ type GenerationStream,
14
+ MixedStreamParser,
15
+ DEFAULT_LLM_MODEL,
16
+ type AIService,
17
+ } from '@dxos/assistant';
18
+ import { createStatic } from '@dxos/echo-schema';
19
+ import { invariant } from '@dxos/invariant';
20
+ import { log } from '@dxos/log';
21
+ import { type Space } from '@dxos/react-client/echo';
22
+
23
+ // TODO(burdon): Factor out.
24
+ declare global {
25
+ interface ToolContextExtensions {
26
+ space?: Space;
27
+ dispatch?: PromiseIntentDispatcher;
28
+ }
29
+ }
30
+
31
+ type RequestOptions = {
32
+ history?: Message[];
33
+ onComplete?: (messages: Message[]) => void;
34
+ };
35
+
36
+ export type ChatProcessorOptions = Pick<GenerateRequest, 'model' | 'systemPrompt'>;
37
+
38
+ const defaultOptions: ChatProcessorOptions = {
39
+ model: DEFAULT_LLM_MODEL,
40
+ systemPrompt: 'you are a helpful assistant',
41
+ };
42
+
43
+ /**
44
+ * Handles interactions with the AI service.
45
+ * Maintains a queue of messages and handles streaming responses from the AI service.
46
+ * Executes tools based on AI responses.
47
+ * Supports cancellation of in-progress requests.
48
+ */
49
+ export class ChatProcessor {
50
+ /** SSE stream parser. */
51
+ private readonly _parser = new MixedStreamParser();
52
+
53
+ /** Current streaming response. */
54
+ private _stream: GenerationStream | undefined;
55
+
56
+ /** Pending messages (incl. the current user request). */
57
+ private readonly _pending: Signal<Message[]> = signal([]);
58
+
59
+ /** Current streaming block (from the AI service). */
60
+ private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
61
+
62
+ /** Prior history from queue. */
63
+ private _history: Message[] = [];
64
+
65
+ /**
66
+ * Streaming state.
67
+ * @reactive
68
+ */
69
+ public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
70
+
71
+ /**
72
+ * Last error.
73
+ * @reactive
74
+ */
75
+ public readonly error: Signal<Error | undefined> = signal(undefined);
76
+
77
+ /**
78
+ * Array of Messages (incl. the current message being streamed).
79
+ * @reactive
80
+ */
81
+ public readonly messages: Signal<Message[]> = computed(() => {
82
+ const messages = [...this._pending.value];
83
+ if (this._block.value) {
84
+ const current = messages.pop();
85
+ invariant(current);
86
+ const { content, ...rest } = current;
87
+ const message = { ...rest, content: [...content, this._block.value] };
88
+ messages.push(message);
89
+ }
90
+
91
+ return messages;
92
+ });
93
+
94
+ constructor(
95
+ private readonly _service: AIService,
96
+ private _tools?: Tool[],
97
+ private readonly _extensions?: ToolContextExtensions,
98
+ private readonly _options: ChatProcessorOptions = defaultOptions,
99
+ ) {
100
+ // Message complete.
101
+ this._parser.message.on((message) => {
102
+ batch(() => {
103
+ this._pending.value = [...this._pending.value, message];
104
+ this._block.value = undefined;
105
+ });
106
+ });
107
+
108
+ // Streaming update (happens before message complete).
109
+ this._parser.update.on((block) => {
110
+ batch(() => {
111
+ this._block.value = block;
112
+ });
113
+ });
114
+ }
115
+
116
+ get tools() {
117
+ return this._tools;
118
+ }
119
+
120
+ /**
121
+ * Update tools.
122
+ */
123
+ setTools(tools: Tool[]) {
124
+ this._tools = tools;
125
+ }
126
+
127
+ /**
128
+ * Make GPT request.
129
+ */
130
+ async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
131
+ batch(() => {
132
+ this._history = options.history ?? [];
133
+ this._pending.value = [
134
+ createStatic(Message, {
135
+ role: 'user',
136
+ content: [{ type: 'text', text: message }],
137
+ }),
138
+ ];
139
+ this._block.value = undefined;
140
+ });
141
+
142
+ await this._request();
143
+ options.onComplete?.(this._pending.value);
144
+ return this._reset();
145
+ }
146
+
147
+ /**
148
+ * Cancel pending requests.
149
+ * @returns Pending requests (incl. the request message).
150
+ */
151
+ async cancel(): Promise<Message[]> {
152
+ log.info('cancelling...');
153
+ this._stream?.abort();
154
+ return this._reset();
155
+ }
156
+
157
+ private async _reset(): Promise<Message[]> {
158
+ const messages = this._pending.value;
159
+ batch(() => {
160
+ this._history = [];
161
+ this._pending.value = [];
162
+ this._block.value = undefined;
163
+ });
164
+
165
+ return messages;
166
+ }
167
+
168
+ /**
169
+ * Generate a response from the AI service.
170
+ * Iterates over tool requests.
171
+ */
172
+ private async _request() {
173
+ try {
174
+ let more = false;
175
+ do {
176
+ log('request', {
177
+ pending: this._pending.value.length,
178
+ history: this._history.length,
179
+ tools: this._tools?.map((tool) => tool.name),
180
+ });
181
+
182
+ // Open request stream.
183
+ this._stream = await this._service.exec({
184
+ ...this._options,
185
+ // TODO(burdon): Rename messages or separate history/message.
186
+ history: [...this._history, ...this._pending.value],
187
+ tools: this._tools,
188
+ });
189
+
190
+ // Wait until complete.
191
+ await this._parser.parse(this._stream);
192
+ await this._stream.complete();
193
+
194
+ // Add messages.
195
+ log('response', { pending: this._pending.value });
196
+
197
+ // Resolve tool use locally.
198
+ more = false;
199
+ const message = this._pending.value.at(-1);
200
+ invariant(message);
201
+ if (isToolUse(message)) {
202
+ log('tool request...');
203
+ const response = await runTools({
204
+ message: this._pending.value.at(-1)!,
205
+ tools: this._tools ?? [],
206
+ extensions: this._extensions,
207
+ });
208
+
209
+ log('tool response', { response });
210
+ switch (response.type) {
211
+ case 'continue': {
212
+ this._pending.value = [...this._pending.value, response.message];
213
+ more = true;
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ } while (more);
219
+
220
+ this.error.value = undefined;
221
+ } catch (err) {
222
+ log.catch(err);
223
+ this.error.value = new Error('AI service error', { cause: err });
224
+ } finally {
225
+ this._stream = undefined;
226
+ }
227
+ }
228
+ }