@dxos/plugin-automation 0.7.5-main.e9bb01b → 0.7.5-staging.2ff1350

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 (301) hide show
  1. package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs +8 -0
  2. package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs.map +7 -0
  3. package/dist/lib/browser/ChatContainer-AZPLZJ5H.mjs +12 -0
  4. package/dist/lib/browser/ChatContainer-AZPLZJ5H.mjs.map +7 -0
  5. package/dist/lib/browser/ai-client-T2PBJISL.mjs +22 -0
  6. package/dist/lib/browser/ai-client-T2PBJISL.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-F22H4YBQ.mjs +111 -0
  8. package/dist/lib/browser/app-graph-builder-F22H4YBQ.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-67KDIIM6.mjs +15 -0
  10. package/dist/lib/browser/chunk-67KDIIM6.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-DQ7ZSYJJ.mjs → chunk-HZSTXZWK.mjs} +3 -1
  12. package/dist/lib/browser/chunk-HZSTXZWK.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-L2YLAKCS.mjs +151 -0
  14. package/dist/lib/browser/chunk-L2YLAKCS.mjs.map +7 -0
  15. package/dist/lib/{node-esm/AutomationPanel-MW42U6I4.mjs → browser/chunk-LJ7F4KDM.mjs} +26 -15
  16. package/dist/lib/browser/chunk-LJ7F4KDM.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-M4MWUOUC.mjs +382 -0
  18. package/dist/lib/browser/chunk-M4MWUOUC.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-U435IUIA.mjs +1775 -0
  20. package/dist/lib/browser/chunk-U435IUIA.mjs.map +7 -0
  21. package/dist/lib/browser/index.mjs +127 -42
  22. package/dist/lib/browser/index.mjs.map +4 -4
  23. package/dist/lib/browser/intent-resolver-MONKAKTY.mjs +30 -0
  24. package/dist/lib/browser/intent-resolver-MONKAKTY.mjs.map +7 -0
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/react-surface-7QWCWE4K.mjs +58 -0
  27. package/dist/lib/browser/react-surface-7QWCWE4K.mjs.map +7 -0
  28. package/dist/lib/browser/types/index.mjs +14 -3
  29. package/dist/lib/node/AutomationPanel-6COLKRIB.cjs +26 -0
  30. package/dist/lib/node/AutomationPanel-6COLKRIB.cjs.map +7 -0
  31. package/dist/lib/node/ChatContainer-SBEUFMQ3.cjs +33 -0
  32. package/dist/lib/node/ChatContainer-SBEUFMQ3.cjs.map +7 -0
  33. package/dist/lib/node/ai-client-L5GUSAER.cjs +38 -0
  34. package/dist/lib/node/ai-client-L5GUSAER.cjs.map +7 -0
  35. package/dist/lib/node/app-graph-builder-OCSH5R6U.cjs +123 -0
  36. package/dist/lib/node/app-graph-builder-OCSH5R6U.cjs.map +7 -0
  37. package/dist/lib/node/{chunk-TQEDPRY5.cjs → chunk-BAQRBGOJ.cjs} +7 -4
  38. package/dist/lib/node/chunk-BAQRBGOJ.cjs.map +7 -0
  39. package/dist/lib/node/chunk-BZFAEBME.cjs +1747 -0
  40. package/dist/lib/node/chunk-BZFAEBME.cjs.map +7 -0
  41. package/dist/lib/node/chunk-K3F5JNZ6.cjs +394 -0
  42. package/dist/lib/node/chunk-K3F5JNZ6.cjs.map +7 -0
  43. package/dist/lib/node/chunk-NUOYHYAF.cjs +174 -0
  44. package/dist/lib/node/chunk-NUOYHYAF.cjs.map +7 -0
  45. package/dist/lib/node/{AutomationPanel-H5WE4FIU.cjs → chunk-V4L7LTWM.cjs} +34 -18
  46. package/dist/lib/node/chunk-V4L7LTWM.cjs.map +7 -0
  47. package/dist/lib/node/chunk-VNBYGJ4K.cjs +34 -0
  48. package/dist/lib/node/chunk-VNBYGJ4K.cjs.map +7 -0
  49. package/dist/lib/node/index.cjs +157 -86
  50. package/dist/lib/node/index.cjs.map +4 -4
  51. package/dist/lib/node/intent-resolver-KQGTYVF2.cjs +45 -0
  52. package/dist/lib/node/intent-resolver-KQGTYVF2.cjs.map +7 -0
  53. package/dist/lib/node/meta.json +1 -1
  54. package/dist/lib/node/{react-surface-S6U5ISJ6.cjs → react-surface-IXKIJFRP.cjs} +31 -12
  55. package/dist/lib/node/react-surface-IXKIJFRP.cjs.map +7 -0
  56. package/dist/lib/node/types/index.cjs +17 -6
  57. package/dist/lib/node/types/index.cjs.map +2 -2
  58. package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs +9 -0
  59. package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs.map +7 -0
  60. package/dist/lib/node-esm/ChatContainer-JCDLYMDZ.mjs +13 -0
  61. package/dist/lib/node-esm/ChatContainer-JCDLYMDZ.mjs.map +7 -0
  62. package/dist/lib/node-esm/ai-client-45LZLW7V.mjs +23 -0
  63. package/dist/lib/node-esm/ai-client-45LZLW7V.mjs.map +7 -0
  64. package/dist/lib/node-esm/app-graph-builder-XSM7DETF.mjs +112 -0
  65. package/dist/lib/node-esm/app-graph-builder-XSM7DETF.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-53FFD4VO.mjs +1776 -0
  67. package/dist/lib/node-esm/chunk-53FFD4VO.mjs.map +7 -0
  68. package/dist/lib/{browser/AutomationPanel-KT3YFV56.mjs → node-esm/chunk-AWAU4BHR.mjs} +27 -14
  69. package/dist/lib/node-esm/chunk-AWAU4BHR.mjs.map +7 -0
  70. package/dist/lib/node-esm/{chunk-JFHI22MF.mjs → chunk-IG4GSWZN.mjs} +3 -1
  71. package/dist/lib/node-esm/chunk-IG4GSWZN.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-K5NNSGIV.mjs +152 -0
  73. package/dist/lib/node-esm/chunk-K5NNSGIV.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-RAT3GSJP.mjs +383 -0
  75. package/dist/lib/node-esm/chunk-RAT3GSJP.mjs.map +7 -0
  76. package/dist/lib/node-esm/chunk-SS7U6GCX.mjs +16 -0
  77. package/dist/lib/node-esm/chunk-SS7U6GCX.mjs.map +7 -0
  78. package/dist/lib/node-esm/index.mjs +127 -42
  79. package/dist/lib/node-esm/index.mjs.map +4 -4
  80. package/dist/lib/node-esm/intent-resolver-XSZRLU6V.mjs +31 -0
  81. package/dist/lib/node-esm/intent-resolver-XSZRLU6V.mjs.map +7 -0
  82. package/dist/lib/node-esm/meta.json +1 -1
  83. package/dist/lib/node-esm/react-surface-FZAAAXGR.mjs +59 -0
  84. package/dist/lib/node-esm/react-surface-FZAAAXGR.mjs.map +7 -0
  85. package/dist/lib/node-esm/types/index.mjs +14 -3
  86. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/ai-client.d.ts +5 -0
  88. package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/app-graph-builder.d.ts +23 -22
  90. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  92. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/index.d.ts +3 -0
  94. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  96. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  98. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
  99. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
  100. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
  101. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
  102. package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
  103. package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
  104. package/dist/types/src/components/AssistantDialog/AssistantDialog.d.ts +6 -0
  105. package/dist/types/src/components/AssistantDialog/AssistantDialog.d.ts.map +1 -0
  106. package/dist/types/src/components/AssistantDialog/index.d.ts +2 -0
  107. package/dist/types/src/components/AssistantDialog/index.d.ts.map +1 -0
  108. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
  109. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  110. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +6 -0
  111. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -0
  112. package/dist/types/src/components/ChatContainer/index.d.ts +4 -0
  113. package/dist/types/src/components/ChatContainer/index.d.ts.map +1 -0
  114. package/dist/types/src/components/Prompt/Prompt.d.ts +13 -0
  115. package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
  116. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
  117. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
  118. package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
  119. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
  120. package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
  121. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
  122. package/dist/types/src/components/Prompt/index.d.ts +3 -0
  123. package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
  124. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +1 -2
  125. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +1 -1
  126. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
  127. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
  128. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
  129. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
  130. package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
  131. package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
  132. package/dist/types/src/components/Thread/Thread.d.ts +15 -0
  133. package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
  134. package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
  135. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
  136. package/dist/types/src/components/Thread/ThreadContainer.d.ts +8 -0
  137. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
  138. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
  139. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
  140. package/dist/types/src/components/Thread/ThreadMessage.d.ts +13 -0
  141. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
  142. package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
  143. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
  144. package/dist/types/src/components/Thread/index.d.ts +3 -0
  145. package/dist/types/src/components/Thread/index.d.ts.map +1 -0
  146. package/dist/types/src/components/Thread/reducer.d.ts +12 -0
  147. package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
  148. package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
  149. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
  150. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
  151. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
  152. package/dist/types/src/components/Toolbox/index.d.ts +2 -0
  153. package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
  154. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
  155. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  156. package/dist/types/src/components/index.d.ts +13 -2
  157. package/dist/types/src/components/index.d.ts.map +1 -1
  158. package/dist/types/src/hooks/index.d.ts +5 -0
  159. package/dist/types/src/hooks/index.d.ts.map +1 -1
  160. package/dist/types/src/hooks/processor.d.ts +75 -0
  161. package/dist/types/src/hooks/processor.d.ts.map +1 -0
  162. package/dist/types/src/hooks/processor.test.d.ts +2 -0
  163. package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
  164. package/dist/types/src/hooks/useChatProcessor.d.ts +7 -0
  165. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
  166. package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
  167. package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
  168. package/dist/types/src/hooks/useServices.d.ts +7 -0
  169. package/dist/types/src/hooks/useServices.d.ts.map +1 -0
  170. package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
  171. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
  172. package/dist/types/src/meta.d.ts +1 -0
  173. package/dist/types/src/meta.d.ts.map +1 -1
  174. package/dist/types/src/testing/index.d.ts +2 -1
  175. package/dist/types/src/testing/index.d.ts.map +1 -1
  176. package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +3 -1
  177. package/dist/types/src/testing/test-functions.d.ts.map +1 -0
  178. package/dist/types/src/testing/test-services.d.ts +5 -0
  179. package/dist/types/src/testing/test-services.d.ts.map +1 -0
  180. package/dist/types/src/tools/function.d.ts +5 -0
  181. package/dist/types/src/tools/function.d.ts.map +1 -0
  182. package/dist/types/src/tools/index.d.ts +3 -0
  183. package/dist/types/src/tools/index.d.ts.map +1 -0
  184. package/dist/types/src/tools/openapi.d.ts +10 -0
  185. package/dist/types/src/tools/openapi.d.ts.map +1 -0
  186. package/dist/types/src/tools/openapi.test.d.ts +2 -0
  187. package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
  188. package/dist/types/src/translations.d.ts +95 -2
  189. package/dist/types/src/translations.d.ts.map +1 -1
  190. package/dist/types/src/types/index.d.ts +2 -0
  191. package/dist/types/src/types/index.d.ts.map +1 -1
  192. package/dist/types/src/types/registry.d.ts +10 -0
  193. package/dist/types/src/types/registry.d.ts.map +1 -0
  194. package/dist/types/src/types/schema.d.ts +161 -3
  195. package/dist/types/src/types/schema.d.ts.map +1 -1
  196. package/dist/types/src/types/types.d.ts +19 -0
  197. package/dist/types/src/types/types.d.ts.map +1 -0
  198. package/package.json +59 -40
  199. package/src/AutomationPlugin.tsx +51 -14
  200. package/src/capabilities/ai-client.ts +19 -0
  201. package/src/capabilities/app-graph-builder.ts +83 -110
  202. package/src/capabilities/capabilities.ts +12 -0
  203. package/src/capabilities/index.ts +4 -0
  204. package/src/capabilities/intent-resolver.ts +26 -0
  205. package/src/capabilities/react-surface.tsx +21 -6
  206. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
  207. package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
  208. package/src/components/AmbientDialog/index.ts +5 -0
  209. package/src/components/AssistantDialog/AssistantDialog.tsx +23 -0
  210. package/src/components/AssistantDialog/index.ts +5 -0
  211. package/src/components/ChatContainer/ChatContainer.tsx +19 -0
  212. package/src/components/ChatContainer/index.ts +9 -0
  213. package/src/components/Prompt/Prompt.stories.tsx +79 -0
  214. package/src/components/Prompt/Prompt.tsx +79 -0
  215. package/src/components/Prompt/PromptBar.tsx +100 -0
  216. package/src/components/Prompt/autocomplete.ts +212 -0
  217. package/src/components/Prompt/index.ts +6 -0
  218. package/src/components/PromptEditor/PromptEditor.stories.tsx +3 -3
  219. package/src/components/PromptEditor/PromptEditor.tsx +3 -3
  220. package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
  221. package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
  222. package/src/components/ServiceRegistry/index.ts +5 -0
  223. package/src/components/Thread/Thread.stories.tsx +210 -0
  224. package/src/components/Thread/Thread.tsx +106 -0
  225. package/src/components/Thread/ThreadContainer.stories.tsx +245 -0
  226. package/src/components/Thread/ThreadContainer.tsx +67 -0
  227. package/src/components/Thread/ThreadMessage.tsx +187 -0
  228. package/src/components/Thread/ToolInvocations.tsx +86 -0
  229. package/src/components/Thread/index.ts +6 -0
  230. package/src/components/Thread/reducer.ts +52 -0
  231. package/src/components/Toolbox/Toolbox.stories.tsx +66 -0
  232. package/src/components/Toolbox/Toolbox.tsx +89 -0
  233. package/src/components/Toolbox/index.ts +5 -0
  234. package/src/components/TriggerEditor/TriggerEditor.tsx +18 -11
  235. package/src/components/index.ts +10 -1
  236. package/src/hooks/index.ts +6 -0
  237. package/src/hooks/processor.test.ts +15 -0
  238. package/src/hooks/processor.ts +218 -0
  239. package/src/hooks/useChatProcessor.tsx +75 -0
  240. package/src/hooks/useMessageQueue.ts +23 -0
  241. package/src/hooks/useServices.ts +28 -0
  242. package/src/hooks/useTextInputEvents.ts +49 -0
  243. package/src/meta.ts +2 -0
  244. package/src/testing/index.ts +2 -1
  245. package/src/testing/{testing.ts → test-functions.ts} +9 -2
  246. package/src/testing/test-services.ts +131 -0
  247. package/src/tools/function.ts +47 -0
  248. package/src/tools/index.ts +6 -0
  249. package/src/tools/openapi.test.ts +224 -0
  250. package/src/tools/openapi.ts +331 -0
  251. package/src/translations.ts +17 -2
  252. package/src/types/index.ts +2 -0
  253. package/src/types/registry.ts +26 -0
  254. package/src/types/schema.ts +95 -1
  255. package/src/types/types.ts +22 -0
  256. package/src/typings.d.ts +9 -0
  257. package/dist/lib/browser/AssistantPanel-NTOUHOWA.mjs +0 -339
  258. package/dist/lib/browser/AssistantPanel-NTOUHOWA.mjs.map +0 -7
  259. package/dist/lib/browser/AutomationPanel-KT3YFV56.mjs.map +0 -7
  260. package/dist/lib/browser/app-graph-builder-6FSMLMT4.mjs +0 -131
  261. package/dist/lib/browser/app-graph-builder-6FSMLMT4.mjs.map +0 -7
  262. package/dist/lib/browser/chunk-4ODBJDXM.mjs +0 -10
  263. package/dist/lib/browser/chunk-4ODBJDXM.mjs.map +0 -7
  264. package/dist/lib/browser/chunk-DL6LB2NI.mjs +0 -43
  265. package/dist/lib/browser/chunk-DL6LB2NI.mjs.map +0 -7
  266. package/dist/lib/browser/chunk-DQ7ZSYJJ.mjs.map +0 -7
  267. package/dist/lib/browser/react-surface-5YTE5MRE.mjs +0 -34
  268. package/dist/lib/browser/react-surface-5YTE5MRE.mjs.map +0 -7
  269. package/dist/lib/node/AssistantPanel-U7GDWPRC.cjs +0 -359
  270. package/dist/lib/node/AssistantPanel-U7GDWPRC.cjs.map +0 -7
  271. package/dist/lib/node/AutomationPanel-H5WE4FIU.cjs.map +0 -7
  272. package/dist/lib/node/app-graph-builder-65TBXO3I.cjs +0 -147
  273. package/dist/lib/node/app-graph-builder-65TBXO3I.cjs.map +0 -7
  274. package/dist/lib/node/chunk-JNDMZQH7.cjs +0 -68
  275. package/dist/lib/node/chunk-JNDMZQH7.cjs.map +0 -7
  276. package/dist/lib/node/chunk-JUSXT4U5.cjs +0 -43
  277. package/dist/lib/node/chunk-JUSXT4U5.cjs.map +0 -7
  278. package/dist/lib/node/chunk-TQEDPRY5.cjs.map +0 -7
  279. package/dist/lib/node/react-surface-S6U5ISJ6.cjs.map +0 -7
  280. package/dist/lib/node-esm/AssistantPanel-M67P24GS.mjs +0 -340
  281. package/dist/lib/node-esm/AssistantPanel-M67P24GS.mjs.map +0 -7
  282. package/dist/lib/node-esm/AutomationPanel-MW42U6I4.mjs.map +0 -7
  283. package/dist/lib/node-esm/app-graph-builder-4SD4F3KN.mjs +0 -132
  284. package/dist/lib/node-esm/app-graph-builder-4SD4F3KN.mjs.map +0 -7
  285. package/dist/lib/node-esm/chunk-GIAYUM5I.mjs +0 -45
  286. package/dist/lib/node-esm/chunk-GIAYUM5I.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-JFHI22MF.mjs.map +0 -7
  288. package/dist/lib/node-esm/chunk-XVIEXSEZ.mjs +0 -12
  289. package/dist/lib/node-esm/chunk-XVIEXSEZ.mjs.map +0 -7
  290. package/dist/lib/node-esm/react-surface-RWTR3TKT.mjs +0 -35
  291. package/dist/lib/node-esm/react-surface-RWTR3TKT.mjs.map +0 -7
  292. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
  293. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
  294. package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
  295. package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
  296. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
  297. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
  298. package/dist/types/src/testing/testing.d.ts.map +0 -1
  299. package/src/components/AssistantPanel/AssistantPanel.tsx +0 -227
  300. package/src/components/AssistantPanel/index.ts +0 -7
  301. package/src/components/AssistantPanel/system-instructions.ts +0 -166
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Message } from '@dxos/artifact';
6
+
7
+ // TODO(burdon): Move to util?
8
+ type Reducer<R, I> = (acc: R, value: I) => R;
9
+
10
+ /**
11
+ * Reducer that collapses related message blocks into single messages.
12
+ * For example, combines tool request/response pairs into a single message.
13
+ */
14
+ export const messageReducer: Reducer<{ messages: Message[]; current?: Message }, Message> = (
15
+ { current, messages },
16
+ message,
17
+ ) => {
18
+ let i = 0;
19
+ for (const block of message.content) {
20
+ switch (block.type) {
21
+ case 'tool_use':
22
+ case 'tool_result': {
23
+ if (current) {
24
+ current.content.push(block);
25
+ } else {
26
+ current = {
27
+ id: [message.id, i].join('_'),
28
+ role: message.role,
29
+ content: [block],
30
+ };
31
+ messages.push(current);
32
+ }
33
+ break;
34
+ }
35
+
36
+ case 'text':
37
+ default: {
38
+ current = undefined;
39
+ messages.push({
40
+ id: [message.id, i].join('_'),
41
+ role: message.role,
42
+ content: [block],
43
+ });
44
+ break;
45
+ }
46
+ }
47
+
48
+ i++;
49
+ }
50
+
51
+ return { current, messages };
52
+ };
@@ -0,0 +1,66 @@
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 } 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 } from './Toolbox';
21
+
22
+ const Render = () => {
23
+ const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
24
+ return (
25
+ <div>
26
+ <Toolbox artifacts={artifactDefinitions} classNames='w-[30rem] h-[15rem] rounded-md border border-neutral-500' />
27
+ </div>
28
+ );
29
+ };
30
+
31
+ const meta: Meta<typeof Toolbox> = {
32
+ title: 'plugins/plugin-automation/Toolbox',
33
+ component: Toolbox,
34
+ render: Render,
35
+ decorators: [
36
+ withSignals,
37
+ withPluginManager({
38
+ plugins: [
39
+ ClientPlugin({
40
+ onClientInitialized: async (_, client) => {
41
+ await client.halo.createIdentity();
42
+ },
43
+ }),
44
+ SpacePlugin({ observability: false }),
45
+ IntentPlugin(),
46
+ ChessPlugin(),
47
+ MapPlugin(),
48
+ TablePlugin(),
49
+ ],
50
+ capabilities,
51
+ }),
52
+ withTheme,
53
+ withLayout({ tooltips: true }),
54
+ ],
55
+ parameters: {
56
+ layout: 'centered',
57
+ },
58
+ };
59
+
60
+ export default meta;
61
+
62
+ type Story = Meta<typeof Toolbox>;
63
+
64
+ export const Default: Story = {
65
+ args: {},
66
+ };
@@ -0,0 +1,89 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useState, useEffect } from 'react';
6
+
7
+ import { Capabilities, useCapabilities } from '@dxos/app-framework';
8
+ import { 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
+ functions?: FunctionType[];
21
+ services?: { service: ServiceType; tools: Tool[] }[];
22
+ striped?: boolean;
23
+ }>;
24
+
25
+ const stripClassNames = 'odd:bg-neutral-50 dark:odd:bg-neutral-800';
26
+
27
+ export const Toolbox = ({ classNames, artifacts, functions, services, striped }: ToolboxProps) => {
28
+ return (
29
+ <div className={mx('flex overflow-hidden box-content py-2', classNames)}>
30
+ <div className='grid grid-cols-[6rem_8rem_1fr] overflow-y-auto'>
31
+ {artifacts?.map(({ id, tools, ...rest }) =>
32
+ tools.map(({ name, description }, i) => (
33
+ <div
34
+ key={`${id}-${i}`}
35
+ className={mx('col-span-full grid grid-cols-subgrid text-xs px-2', striped && stripClassNames)}
36
+ >
37
+ <div className='text-primary-500 truncate'>{i === 0 && id}</div>
38
+ <div className='truncate'>{name}</div>
39
+ <div className='text-subdued line-clamp-3'>{description}</div>
40
+ </div>
41
+ )),
42
+ )}
43
+ {functions?.map(({ name, description }) => (
44
+ <div
45
+ key={name}
46
+ className={mx('col-span-full grid grid-cols-subgrid text-xs px-2', striped && stripClassNames)}
47
+ >
48
+ <div className='text-primary-500 truncate'>function</div>
49
+ <div className='truncate'>{name}</div>
50
+ <div className='truncate'>{description}</div>
51
+ </div>
52
+ ))}
53
+ {services?.map(({ service, tools }) =>
54
+ tools.map(({ name, description }, i) => (
55
+ <div
56
+ key={`${service.id}-${name}`}
57
+ className={mx('col-span-full grid grid-cols-subgrid text-xs px-2', striped && stripClassNames)}
58
+ >
59
+ <div className='text-primary-500 truncate'>{i === 0 && service.serviceId}</div>
60
+ <div className='truncate'>{name}</div>
61
+ <div className='truncate'>{description}</div>
62
+ </div>
63
+ )),
64
+ )}
65
+ </div>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export const ToolboxContainer = ({ classNames, space }: ThemedClassName<{ space?: Space }>) => {
71
+ const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
72
+ const functions = useQuery(space, Filter.schema(FunctionType));
73
+
74
+ const services = useQuery(space, Filter.schema(ServiceType));
75
+ const [serviceTools, setServiceTools] = useState<{ service: ServiceType; tools: Tool[] }[]>([]);
76
+ useEffect(() => {
77
+ log('creating service tools...');
78
+ queueMicrotask(async () => {
79
+ const tools = await Promise.all(
80
+ services.map(async (service) => ({ service, tools: await createToolsFromService(service) })),
81
+ );
82
+ setServiceTools(tools);
83
+ });
84
+ }, [services]);
85
+
86
+ return (
87
+ <Toolbox classNames={classNames} artifacts={artifactDefinitions} functions={functions} services={serviceTools} />
88
+ );
89
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './Toolbox';
@@ -2,8 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useState } from 'react';
5
+ import React, { useEffect, useState } from 'react';
6
6
 
7
+ import { ComputeGraph } from '@dxos/conductor';
7
8
  import {
8
9
  FunctionType,
9
10
  FunctionTriggerSchema,
@@ -29,6 +30,7 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
29
30
  const { t } = useTranslation(AUTOMATION_PLUGIN);
30
31
 
31
32
  const functions = useQuery(space, Filter.schema(FunctionType));
33
+ const workflows = useQuery(space, Filter.schema(ComputeGraph));
32
34
  const scripts = useQuery(space, Filter.schema(ScriptType));
33
35
 
34
36
  const handleSave = (values: FunctionTriggerType) => {
@@ -45,10 +47,7 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
45
47
  ['function' satisfies keyof FunctionTriggerType]: (props) => (
46
48
  <SelectInput
47
49
  {...props}
48
- options={functions.map((fn) => ({
49
- value: fn.name,
50
- label: getFunctionName(scripts, fn),
51
- }))}
50
+ options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
52
51
  />
53
52
  ),
54
53
  ['spec.type' as const]: (props) => (
@@ -62,11 +61,9 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
62
61
  ),
63
62
  ['meta' as const]: (props) => {
64
63
  const meta = props.getValue()!;
65
-
64
+ useEffect(() => props.onValueChange('object', { ...meta }), []);
66
65
  const [newMetaFieldName, setNewMetaFieldName] = useState('');
67
66
 
68
- React.useEffect(() => props.onValueChange('object', { ...meta }), []);
69
-
70
67
  return (
71
68
  <>
72
69
  <div>{props.label}</div>
@@ -75,7 +72,12 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
75
72
  return (
76
73
  <div key={compositeKey} role='none' className='flex items-center mt-2 gap-1'>
77
74
  <div role='none' className='flex-1'>
78
- <TextInput {...props} type={'string'} label={key} />
75
+ <TextInput
76
+ {...props}
77
+ getValue={() => (props.getValue() as any)[key]}
78
+ type={'string'}
79
+ label={key}
80
+ />
79
81
  </div>
80
82
  <IconButton
81
83
  icon='ph--trash--regular'
@@ -123,6 +125,11 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
123
125
  );
124
126
  };
125
127
 
126
- const getFunctionName = (scripts: ScriptType[], fn: FunctionType) => {
127
- return scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
128
+ const getWorkflowOptions = (graphs: ComputeGraph[]) => {
129
+ return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
130
+ };
131
+
132
+ const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
133
+ const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
134
+ return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));
128
135
  };
@@ -4,5 +4,14 @@
4
4
 
5
5
  import { lazy } from 'react';
6
6
 
7
- export const AssistantPanel = lazy(() => import('./AssistantPanel'));
7
+ export * from './AssistantDialog';
8
+ export * from './AutomationPanel';
9
+ export * from './ChatContainer';
10
+ export * from './PromptEditor';
11
+ export * from './ServiceRegistry';
12
+ export * from './Thread';
13
+ export * from './TriggerEditor';
14
+ export * from './Toolbox';
15
+
8
16
  export const AutomationPanel = lazy(() => import('./AutomationPanel'));
17
+ export const ChatContainer = lazy(() => import('./ChatContainer'));
@@ -2,4 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ export * from './processor';
6
+
7
+ export * from './useChatProcessor';
5
8
  export * from './useLocalTriggerManager';
9
+ export * from './useMessageQueue';
10
+ export * from './useServices';
11
+ export * from './useTextInputEvents';
@@ -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,218 @@
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 AIServiceClientImpl,
13
+ type GenerateRequest,
14
+ type GenerationStream,
15
+ MixedStreamParser,
16
+ } from '@dxos/assistant';
17
+ import { createStatic } from '@dxos/echo-schema';
18
+ import { invariant } from '@dxos/invariant';
19
+ import { log } from '@dxos/log';
20
+ import { type Space } from '@dxos/react-client/echo';
21
+
22
+ // TODO(burdon): Factor out.
23
+ declare global {
24
+ interface ToolContextExtensions {
25
+ space?: Space;
26
+ dispatch?: PromiseIntentDispatcher;
27
+ }
28
+ }
29
+
30
+ type RequestOptions = {
31
+ history?: Message[];
32
+ onComplete?: (messages: Message[]) => void;
33
+ };
34
+
35
+ export type ChatProcessorOptions = Pick<GenerateRequest, 'model' | 'systemPrompt'>;
36
+
37
+ const defaultOptions: ChatProcessorOptions = {
38
+ model: '@anthropic/claude-3-5-sonnet-20241022',
39
+ systemPrompt: 'you are a helpful assistant',
40
+ };
41
+
42
+ /**
43
+ * Handles interactions with the AI service.
44
+ * Maintains a queue of messages and handles streaming responses from the AI service.
45
+ * Executes tools based on AI responses.
46
+ * Supports cancellation of in-progress requests.
47
+ */
48
+ export class ChatProcessor {
49
+ /** SSE stream parser. */
50
+ private readonly _parser = new MixedStreamParser();
51
+
52
+ /** Current streaming response (iterator). */
53
+ private _stream: GenerationStream | undefined;
54
+
55
+ /** Pending messages (incl. the user request). */
56
+ private readonly _pending: Signal<Message[]> = signal([]);
57
+
58
+ /** Current streaming block (from the AI service). */
59
+ private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
60
+
61
+ /** Prior history from queue. */
62
+ private _history: Message[] = [];
63
+
64
+ /**
65
+ * Streaming state.
66
+ * @reactive
67
+ */
68
+ public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
69
+
70
+ /**
71
+ * Last error.
72
+ * @reactive
73
+ */
74
+ public readonly error: Signal<Error | undefined> = signal(undefined);
75
+
76
+ /**
77
+ * Array of Messages (incl. the current message being streamed).
78
+ * @reactive
79
+ */
80
+ public readonly messages: Signal<Message[]> = computed(() => {
81
+ const messages = [...this._pending.value];
82
+ if (this._block.value) {
83
+ const current = messages.pop();
84
+ invariant(current);
85
+ const { content, ...rest } = current;
86
+ const message = { ...rest, content: [...content, this._block.value] };
87
+ messages.push(message);
88
+ }
89
+
90
+ return messages;
91
+ });
92
+
93
+ constructor(
94
+ private readonly _client: AIServiceClientImpl,
95
+ private _tools?: Tool[],
96
+ private readonly _extensions?: ToolContextExtensions,
97
+ private readonly _options: ChatProcessorOptions = defaultOptions,
98
+ ) {
99
+ // Message complete.
100
+ this._parser.message.on((message) => {
101
+ batch(() => {
102
+ this._pending.value = [...this._pending.value, message];
103
+ this._block.value = undefined;
104
+ });
105
+ });
106
+
107
+ // Streaming update (happens before message complete).
108
+ this._parser.update.on((block) => {
109
+ batch(() => {
110
+ this._block.value = block;
111
+ });
112
+ });
113
+ }
114
+
115
+ /**
116
+ * Update tools.
117
+ */
118
+ setTools(tools: Tool[]) {
119
+ this._tools = tools;
120
+ }
121
+
122
+ /**
123
+ * Make GPT request.
124
+ */
125
+ async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
126
+ batch(() => {
127
+ this._history = options.history ?? [];
128
+ this._pending.value = [
129
+ createStatic(Message, {
130
+ role: 'user',
131
+ content: [{ type: 'text', text: message }],
132
+ }),
133
+ ];
134
+ this._block.value = undefined;
135
+ });
136
+
137
+ await this._generate();
138
+ options.onComplete?.(this._pending.value);
139
+ return this._reset();
140
+ }
141
+
142
+ /**
143
+ * Cancel pending requests.
144
+ * @returns Pending requests (incl. the request message).
145
+ */
146
+ async cancel(): Promise<Message[]> {
147
+ log.info('cancelling...');
148
+ this._stream?.abort();
149
+ return this._reset();
150
+ }
151
+
152
+ private async _reset(): Promise<Message[]> {
153
+ const messages = this._pending.value;
154
+ batch(() => {
155
+ this._history = [];
156
+ this._pending.value = [];
157
+ this._block.value = undefined;
158
+ });
159
+
160
+ return messages;
161
+ }
162
+
163
+ /**
164
+ * Generate a response from the AI service.
165
+ * Iterates over tool requests.
166
+ */
167
+ private async _generate() {
168
+ try {
169
+ let more = false;
170
+ do {
171
+ log.info('requesting', { history: this._history.length, messages: this._pending.value.length });
172
+ this._stream = await this._client.generate({
173
+ ...this._options,
174
+ // TODO(burdon): Rename messages or separate history/message.
175
+ history: [...this._history, ...this._pending.value],
176
+ tools: this._tools,
177
+ });
178
+
179
+ // Wait until complete.
180
+ await this._parser.parse(this._stream);
181
+ await this._stream.complete();
182
+
183
+ // Add messages.
184
+ log.info('response', { messages: this._pending.value });
185
+
186
+ // Resolve tool use locally.
187
+ more = false;
188
+ const message = this._pending.value.at(-1);
189
+ invariant(message);
190
+ if (isToolUse(message)) {
191
+ log.info('tool request...');
192
+ const response = await runTools({
193
+ message: this._pending.value.at(-1)!,
194
+ tools: this._tools ?? [],
195
+ extensions: this._extensions,
196
+ });
197
+
198
+ log.info('tool response', { response });
199
+ switch (response.type) {
200
+ case 'continue': {
201
+ this._pending.value = [...this._pending.value, response.message];
202
+ more = true;
203
+ break;
204
+ }
205
+ }
206
+ }
207
+ } while (more);
208
+
209
+ log.info('done');
210
+ } catch (err) {
211
+ log.catch(err);
212
+ this.error.value = new Error('AI service error', { cause: err });
213
+ } finally {
214
+ this._stream = undefined;
215
+ this.error.value = undefined;
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,75 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useMemo, useState } from 'react';
6
+
7
+ import { Capabilities, useCapabilities, useCapability, useIntentDispatcher } from '@dxos/app-framework';
8
+ import { createSystemPrompt, type Tool } from '@dxos/artifact';
9
+ import { FunctionType } from '@dxos/functions';
10
+ import { log } from '@dxos/log';
11
+ import { useConfig } from '@dxos/react-client';
12
+ import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
13
+ import { isNonNullable } from '@dxos/util';
14
+
15
+ import { AutomationCapabilities } from '../capabilities';
16
+ import { ChatProcessor } from '../hooks';
17
+ import { covertFunctionToTool, createToolsFromService } from '../tools';
18
+ import { ServiceType } from '../types';
19
+
20
+ /**
21
+ * Creates a processor for the chat.
22
+ */
23
+ export const useChatProcessor = (space?: Space): ChatProcessor => {
24
+ const aiClient = useCapability(AutomationCapabilities.AiClient);
25
+ const globalTools = useCapabilities(Capabilities.Tools);
26
+ const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
27
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
28
+
29
+ // Services.
30
+ const services = useQuery(space, Filter.schema(ServiceType));
31
+ const [serviceTools, setServiceTools] = useState<Tool[]>([]);
32
+ useEffect(() => {
33
+ log('creating service tools...');
34
+ queueMicrotask(async () => {
35
+ const tools = await Promise.all(services.map((service) => createToolsFromService(service)));
36
+ setServiceTools(tools.flat());
37
+ });
38
+ }, [services]);
39
+
40
+ // Tools and context.
41
+ const config = useConfig();
42
+ const functions = useQuery(space, Filter.schema(FunctionType));
43
+ const [tools, extensions] = useMemo(() => {
44
+ log('creating tools...');
45
+ const tools = [
46
+ ...globalTools.flat(),
47
+ ...artifactDefinitions.flatMap((definition) => definition.tools),
48
+ ...serviceTools,
49
+ ...functions
50
+ .map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
51
+ .filter(isNonNullable),
52
+ ];
53
+ const extensions = { space, dispatch };
54
+ return [tools, extensions];
55
+ }, [dispatch, globalTools, artifactDefinitions, space, serviceTools, functions]);
56
+
57
+ // Prompt.
58
+ const systemPrompt = useMemo(
59
+ () => createSystemPrompt({ artifacts: artifactDefinitions.map((definition) => definition.instructions) }),
60
+ [artifactDefinitions],
61
+ );
62
+
63
+ // Create processor.
64
+ // TODO(burdon): Updated on each query update above. Should just update current processor.
65
+ const processor = useMemo(() => {
66
+ log.info('creating processor...');
67
+ return new ChatProcessor(aiClient, tools, extensions, {
68
+ // TODO(burdon): Move to settings.
69
+ model: '@anthropic/claude-3-5-sonnet-20241022',
70
+ systemPrompt,
71
+ });
72
+ }, [aiClient, tools, extensions, systemPrompt]);
73
+
74
+ return processor;
75
+ };
@@ -0,0 +1,23 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useMemo } from 'react';
6
+
7
+ import { type Message } from '@dxos/artifact';
8
+ import { DXN, QueueSubspaceTags } from '@dxos/keys';
9
+ import { getSpace } from '@dxos/react-client/echo';
10
+ import { useEdgeClient, useQueue } from '@dxos/react-edge-client';
11
+
12
+ import { type AIChatType } from '../types';
13
+
14
+ export const useMessageQueue = (chat?: AIChatType) => {
15
+ const space = getSpace(chat);
16
+ const queueDxn = useMemo(() => {
17
+ const dxn = space && chat?.queue.dxn;
18
+ return dxn ? new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, space.id, dxn.parts.at(-1)!]) : undefined;
19
+ }, [space, chat?.queue.dxn]);
20
+
21
+ const edgeClient = useEdgeClient();
22
+ return useQueue<Message>(edgeClient, queueDxn);
23
+ };
@@ -0,0 +1,28 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useMemo, useState } from 'react';
6
+
7
+ import { type Space } from '@dxos/client/echo';
8
+
9
+ import { MockServiceRegistry } from '../testing';
10
+ import { type ServiceType, type ServiceQuery } from '../types';
11
+
12
+ /**
13
+ * Retrieves matching services from the registry.
14
+ */
15
+ export const useServices = (space: Space, query?: ServiceQuery): ServiceType[] => {
16
+ const registry = useMemo(() => new MockServiceRegistry(), []);
17
+ const [services, setServices] = useState<ServiceType[]>([]);
18
+ useEffect(() => {
19
+ const t = setTimeout(async () => {
20
+ const services = await registry.queryServices(query);
21
+ setServices(services);
22
+ });
23
+
24
+ return () => clearTimeout(t);
25
+ }, [query, registry]);
26
+
27
+ return services;
28
+ };