@dxos/plugin-assistant 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b

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 (481) hide show
  1. package/dist/lib/browser/BlueprintArticle-BWSLH6LG.mjs +36 -0
  2. package/dist/lib/browser/BlueprintArticle-BWSLH6LG.mjs.map +7 -0
  3. package/dist/lib/browser/ChatCompanion-U7VMDYO6.mjs +159 -0
  4. package/dist/lib/browser/ChatCompanion-U7VMDYO6.mjs.map +7 -0
  5. package/dist/lib/browser/ChatContainer-JXDZQ2EY.mjs +79 -0
  6. package/dist/lib/browser/ChatContainer-JXDZQ2EY.mjs.map +7 -0
  7. package/dist/lib/browser/{ChatDialog-X6VN6QZI.mjs → ChatDialog-5NNGCRKJ.mjs} +30 -12
  8. package/dist/lib/browser/ChatDialog-5NNGCRKJ.mjs.map +7 -0
  9. package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs +59 -0
  10. package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs.map +7 -0
  11. package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
  12. package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
  13. package/dist/lib/browser/app-graph-builder-ADZRPJ3V.mjs +199 -0
  14. package/dist/lib/browser/app-graph-builder-ADZRPJ3V.mjs.map +7 -0
  15. package/dist/lib/browser/blueprint-definition-7HPQPCL7.mjs +12 -0
  16. package/dist/lib/browser/blueprint-definition-7HPQPCL7.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-5JZRYQZL.mjs +229 -0
  18. package/dist/lib/browser/chunk-5JZRYQZL.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-7ZJIXQ2Y.mjs +335 -0
  20. package/dist/lib/browser/chunk-7ZJIXQ2Y.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-F6YX2HHA.mjs +262 -0
  22. package/dist/lib/browser/chunk-F6YX2HHA.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  24. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-LRE4VEZV.mjs +16 -0
  26. package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-SWEOO227.mjs +1930 -0
  28. package/dist/lib/browser/chunk-SWEOO227.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
  30. package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-YDSFERCV.mjs +178 -0
  32. package/dist/lib/browser/chunk-YDSFERCV.mjs.map +7 -0
  33. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
  34. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
  35. package/dist/lib/browser/index.mjs +227 -101
  36. package/dist/lib/browser/index.mjs.map +4 -4
  37. package/dist/lib/browser/intent-resolver-Q7TX3MV7.mjs +143 -0
  38. package/dist/lib/browser/intent-resolver-Q7TX3MV7.mjs.map +7 -0
  39. package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +17 -0
  40. package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +7 -0
  41. package/dist/lib/browser/meta.json +1 -1
  42. package/dist/lib/browser/react-surface-VXXS6ZVC.mjs +100 -0
  43. package/dist/lib/browser/react-surface-VXXS6ZVC.mjs.map +7 -0
  44. package/dist/lib/browser/repair-3MZXLUHO.mjs +44 -0
  45. package/dist/lib/browser/repair-3MZXLUHO.mjs.map +7 -0
  46. package/dist/lib/browser/{settings-2DGP3UTS.mjs → settings-HD5WA24I.mjs} +8 -7
  47. package/dist/lib/{node-esm/settings-47RYZOU4.mjs.map → browser/settings-HD5WA24I.mjs.map} +1 -1
  48. package/dist/lib/browser/state-GG7Z3NB7.mjs +25 -0
  49. package/dist/lib/browser/state-GG7Z3NB7.mjs.map +7 -0
  50. package/dist/lib/browser/toolkit-VYDAWNE4.mjs +17 -0
  51. package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +7 -0
  52. package/dist/lib/browser/types/index.mjs +7 -4
  53. package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs +37 -0
  54. package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs.map +7 -0
  55. package/dist/lib/node-esm/ChatCompanion-O4T7PMMC.mjs +160 -0
  56. package/dist/lib/node-esm/ChatCompanion-O4T7PMMC.mjs.map +7 -0
  57. package/dist/lib/node-esm/ChatContainer-OWAZI6ZF.mjs +80 -0
  58. package/dist/lib/node-esm/ChatContainer-OWAZI6ZF.mjs.map +7 -0
  59. package/dist/lib/node-esm/{ChatDialog-RJ6FDX4Q.mjs → ChatDialog-IBXH5FRI.mjs} +30 -12
  60. package/dist/lib/node-esm/ChatDialog-IBXH5FRI.mjs.map +7 -0
  61. package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs +60 -0
  62. package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs.map +7 -0
  63. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
  64. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
  65. package/dist/lib/node-esm/app-graph-builder-26KXQ5ZY.mjs +200 -0
  66. package/dist/lib/node-esm/app-graph-builder-26KXQ5ZY.mjs.map +7 -0
  67. package/dist/lib/node-esm/blueprint-definition-S3DNWJFV.mjs +13 -0
  68. package/dist/lib/node-esm/blueprint-definition-S3DNWJFV.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-CKW4IYLY.mjs +336 -0
  70. package/dist/lib/node-esm/chunk-CKW4IYLY.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs +230 -0
  72. package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-GWKWQSEQ.mjs +264 -0
  74. package/dist/lib/node-esm/chunk-GWKWQSEQ.mjs.map +7 -0
  75. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  76. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  77. package/dist/lib/node-esm/chunk-VGSP5WMV.mjs +180 -0
  78. package/dist/lib/node-esm/chunk-VGSP5WMV.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-WE6KTH72.mjs +25 -0
  80. package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-YWFWT57N.mjs +17 -0
  82. package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
  83. package/dist/lib/node-esm/chunk-ZNSHGWE4.mjs +1931 -0
  84. package/dist/lib/node-esm/chunk-ZNSHGWE4.mjs.map +7 -0
  85. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
  86. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
  87. package/dist/lib/node-esm/index.mjs +227 -101
  88. package/dist/lib/node-esm/index.mjs.map +4 -4
  89. package/dist/lib/node-esm/intent-resolver-LTKMN3YB.mjs +144 -0
  90. package/dist/lib/node-esm/intent-resolver-LTKMN3YB.mjs.map +7 -0
  91. package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +18 -0
  92. package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +7 -0
  93. package/dist/lib/node-esm/meta.json +1 -1
  94. package/dist/lib/node-esm/react-surface-AOBQALOV.mjs +101 -0
  95. package/dist/lib/node-esm/react-surface-AOBQALOV.mjs.map +7 -0
  96. package/dist/lib/node-esm/repair-RER5H7Y6.mjs +45 -0
  97. package/dist/lib/node-esm/repair-RER5H7Y6.mjs.map +7 -0
  98. package/dist/lib/node-esm/{settings-47RYZOU4.mjs → settings-YJQVKHH5.mjs} +8 -7
  99. package/dist/lib/{browser/settings-2DGP3UTS.mjs.map → node-esm/settings-YJQVKHH5.mjs.map} +1 -1
  100. package/dist/lib/node-esm/state-FSUHFMDM.mjs +26 -0
  101. package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +7 -0
  102. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +18 -0
  103. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +7 -0
  104. package/dist/lib/node-esm/types/index.mjs +7 -4
  105. package/dist/types/src/AssistantPlugin.d.ts +1 -1
  106. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  107. package/dist/types/src/capabilities/ai-service.d.ts +4 -0
  108. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  110. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  111. package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
  112. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/capabilities.d.ts +10 -0
  114. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
  116. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/index.d.ts +12 -3
  118. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  119. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  120. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  121. package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
  122. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  124. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  125. package/dist/types/src/capabilities/repair.d.ts +4 -0
  126. package/dist/types/src/capabilities/repair.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/settings.d.ts +1 -1
  128. package/dist/types/src/capabilities/state.d.ts +4 -0
  129. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  130. package/dist/types/src/capabilities/toolkit.d.ts +4 -0
  131. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  132. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  133. package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
  134. package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
  135. package/dist/types/src/components/Chat/Chat.d.ts +35 -21
  136. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  137. package/dist/types/src/components/Chat/events.d.ts +9 -0
  138. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  139. package/dist/types/src/components/ChatCompanion.d.ts +13 -0
  140. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
  141. package/dist/types/src/components/ChatContainer.d.ts +14 -6
  142. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  143. package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
  144. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
  145. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  146. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  147. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  148. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  149. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
  150. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  151. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
  152. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +4 -5
  153. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  154. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
  155. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  156. package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
  157. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  158. package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -10
  159. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  160. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +170 -70
  161. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  162. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  163. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  164. package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
  165. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
  166. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  167. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  168. package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
  169. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  170. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  171. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  172. package/dist/types/src/components/PromptArticle.d.ts +7 -0
  173. package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
  174. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +3 -6
  175. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  176. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +317 -7
  177. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  178. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -2
  179. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  180. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +314 -2
  181. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  182. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
  183. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  184. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  185. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  186. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  187. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  188. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +21 -0
  189. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  190. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  191. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  192. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  193. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  194. package/dist/types/src/components/Toolbox/Toolbox.d.ts +6 -11
  195. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  196. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +318 -5
  197. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  198. package/dist/types/src/components/index.d.ts +9 -6
  199. package/dist/types/src/components/index.d.ts.map +1 -1
  200. package/dist/types/src/events.d.ts +1 -1
  201. package/dist/types/src/events.d.ts.map +1 -1
  202. package/dist/types/src/functions/analysis.d.ts +5 -0
  203. package/dist/types/src/functions/analysis.d.ts.map +1 -0
  204. package/dist/types/src/functions/index.d.ts +4 -0
  205. package/dist/types/src/functions/index.d.ts.map +1 -0
  206. package/dist/types/src/functions/object-list.d.ts +10 -0
  207. package/dist/types/src/functions/object-list.d.ts.map +1 -0
  208. package/dist/types/src/functions/object-load.d.ts +8 -0
  209. package/dist/types/src/functions/object-load.d.ts.map +1 -0
  210. package/dist/types/src/hooks/index.d.ts +8 -3
  211. package/dist/types/src/hooks/index.d.ts.map +1 -1
  212. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  213. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  214. package/dist/types/src/hooks/useChatProcessor.d.ts +8 -19
  215. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  216. package/dist/types/src/hooks/useChatServices.d.ts +5 -6
  217. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  218. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  219. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  220. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  221. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  222. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  223. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  224. package/dist/types/src/hooks/useFilteredTypes.d.ts +4 -0
  225. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  226. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  227. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  228. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  229. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  230. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  231. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  232. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  233. package/dist/types/src/index.d.ts +2 -0
  234. package/dist/types/src/index.d.ts.map +1 -1
  235. package/dist/types/src/meta.d.ts +1 -2
  236. package/dist/types/src/meta.d.ts.map +1 -1
  237. package/dist/types/src/processor/index.d.ts +4 -0
  238. package/dist/types/src/processor/index.d.ts.map +1 -0
  239. package/dist/types/src/{hooks → processor}/presets.d.ts +3 -3
  240. package/dist/types/src/processor/presets.d.ts.map +1 -0
  241. package/dist/types/src/processor/processor.d.ts +75 -0
  242. package/dist/types/src/processor/processor.d.ts.map +1 -0
  243. package/dist/types/src/processor/processor.test.d.ts +2 -0
  244. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  245. package/dist/types/src/processor/update-name.d.ts +10 -0
  246. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  247. package/dist/types/src/queue-logger.d.ts.map +1 -1
  248. package/dist/types/src/testing/index.d.ts +1 -1
  249. package/dist/types/src/testing/index.d.ts.map +1 -1
  250. package/dist/types/src/testing/test-generator.d.ts +8 -0
  251. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  252. package/dist/types/src/testing/test-sequence.d.ts +0 -4
  253. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  254. package/dist/types/src/testing/test-services.d.ts +2 -2
  255. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  256. package/dist/types/src/translations.d.ts +262 -37
  257. package/dist/types/src/translations.d.ts.map +1 -1
  258. package/dist/types/src/types/Assistant.d.ts +45 -0
  259. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  260. package/dist/types/src/types/AssistantAction.d.ts +129 -0
  261. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  262. package/dist/types/src/types/defs.d.ts +2 -0
  263. package/dist/types/src/types/defs.d.ts.map +1 -0
  264. package/dist/types/src/types/index.d.ts +3 -1
  265. package/dist/types/src/types/index.d.ts.map +1 -1
  266. package/dist/types/src/types/service.d.ts +135 -85
  267. package/dist/types/src/types/service.d.ts.map +1 -1
  268. package/dist/types/tsconfig.tsbuildinfo +1 -1
  269. package/package.json +99 -93
  270. package/src/AssistantPlugin.tsx +151 -85
  271. package/src/capabilities/ai-service.ts +27 -0
  272. package/src/capabilities/app-graph-builder.ts +104 -149
  273. package/src/capabilities/blueprint-definition.ts +66 -0
  274. package/src/capabilities/capabilities.ts +17 -0
  275. package/src/capabilities/edge-model-resolver.ts +25 -0
  276. package/src/capabilities/index.ts +10 -0
  277. package/src/capabilities/intent-resolver.ts +92 -15
  278. package/src/capabilities/local-model-resolver.ts +30 -0
  279. package/src/capabilities/react-surface.tsx +27 -78
  280. package/src/capabilities/repair.ts +49 -0
  281. package/src/capabilities/state.ts +22 -0
  282. package/src/capabilities/toolkit.ts +17 -0
  283. package/src/components/AssistantSettings/AssistantSettings.tsx +83 -76
  284. package/src/components/BlueprintArticle.tsx +29 -0
  285. package/src/components/Chat/Chat.tsx +260 -217
  286. package/src/components/Chat/events.ts +13 -0
  287. package/src/components/ChatCompanion.tsx +166 -0
  288. package/src/components/ChatContainer.tsx +39 -22
  289. package/src/components/ChatDialog.tsx +25 -14
  290. package/src/components/ChatProgress/ChatProgress.tsx +67 -0
  291. package/src/components/{SequenceEditor → ChatProgress}/index.ts +1 -1
  292. package/src/components/ChatPrompt/ChatActions.tsx +10 -26
  293. package/src/components/ChatPrompt/ChatOptions.tsx +234 -0
  294. package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
  295. package/src/components/ChatPrompt/ChatReferences.tsx +31 -36
  296. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
  297. package/src/components/ChatPrompt/index.ts +1 -1
  298. package/src/components/ChatThread/ChatThread.stories.tsx +122 -116
  299. package/src/components/ChatThread/ChatThread.tsx +65 -35
  300. package/src/components/ChatThread/Link.tsx +26 -0
  301. package/src/components/ChatThread/reducers.ts +151 -0
  302. package/src/components/ChatThread/registry.tsx +174 -0
  303. package/src/components/ChatThread/sync.test.ts +89 -0
  304. package/src/components/ChatThread/sync.ts +148 -0
  305. package/src/components/ChatThread/testing/thread.md +37 -0
  306. package/src/components/PromptArticle.tsx +51 -0
  307. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +40 -19
  308. package/src/components/TemplateEditor/TemplateEditor.tsx +30 -52
  309. package/src/components/TemplateEditor/TemplateForm.stories.tsx +19 -14
  310. package/src/components/TemplateEditor/TemplateForm.tsx +8 -5
  311. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +269 -0
  312. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  313. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  314. package/src/components/ToolBlock/ToolBlock.tsx +143 -0
  315. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  316. package/src/components/ToolBlock/index.ts +6 -0
  317. package/src/components/Toolbox/Toolbox.stories.tsx +14 -23
  318. package/src/components/Toolbox/Toolbox.tsx +25 -55
  319. package/src/components/index.ts +3 -7
  320. package/src/events.ts +2 -2
  321. package/src/functions/analysis.ts +22 -0
  322. package/src/functions/index.ts +7 -0
  323. package/src/functions/object-list.ts +49 -0
  324. package/src/functions/object-load.ts +46 -0
  325. package/src/hooks/index.ts +8 -4
  326. package/src/hooks/useBlueprintRegistry.ts +95 -0
  327. package/src/hooks/useChatProcessor.ts +35 -104
  328. package/src/hooks/useChatServices.ts +33 -73
  329. package/src/hooks/useChatToolbarActions.ts +122 -0
  330. package/src/hooks/useContextBinder.ts +30 -0
  331. package/src/hooks/useContextObjects.ts +58 -0
  332. package/src/hooks/useFilteredTypes.ts +38 -0
  333. package/src/hooks/useFlush.ts +35 -0
  334. package/src/hooks/useOnline.ts +10 -0
  335. package/src/hooks/usePresets.ts +44 -0
  336. package/src/hooks/useReferencesProvider.ts +14 -11
  337. package/src/index.ts +2 -0
  338. package/src/meta.ts +9 -6
  339. package/src/processor/index.ts +7 -0
  340. package/src/{hooks → processor}/presets.ts +16 -8
  341. package/src/processor/processor.test.ts +72 -0
  342. package/src/processor/processor.ts +277 -0
  343. package/src/processor/update-name.ts +56 -0
  344. package/src/queue-logger.ts +13 -17
  345. package/src/testing/index.ts +1 -1
  346. package/src/testing/test-generator.ts +262 -0
  347. package/src/testing/test-sequence.ts +2 -27
  348. package/src/testing/test-services.ts +2 -8
  349. package/src/translations.ts +48 -26
  350. package/src/types/Assistant.ts +63 -0
  351. package/src/types/AssistantAction.ts +79 -0
  352. package/src/types/defs.ts +5 -0
  353. package/src/types/index.ts +4 -1
  354. package/src/types/service.ts +17 -9
  355. package/src/vite-env.d.ts +30 -0
  356. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs +0 -54
  357. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +0 -7
  358. package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +0 -7
  359. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +0 -162
  360. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
  361. package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs +0 -27
  362. package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +0 -7
  363. package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs +0 -223
  364. package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +0 -7
  365. package/dist/lib/browser/chunk-AEAEKWOC.mjs +0 -98
  366. package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +0 -7
  367. package/dist/lib/browser/chunk-EQDW6BYQ.mjs +0 -108
  368. package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +0 -7
  369. package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
  370. package/dist/lib/browser/chunk-FDCJSQYF.mjs.map +0 -7
  371. package/dist/lib/browser/chunk-JQBVLTM5.mjs +0 -158
  372. package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +0 -7
  373. package/dist/lib/browser/chunk-OWY4CUQY.mjs +0 -2245
  374. package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +0 -7
  375. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +0 -60
  376. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +0 -7
  377. package/dist/lib/browser/react-surface-66VY37YQ.mjs +0 -150
  378. package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +0 -7
  379. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +0 -55
  380. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +0 -7
  381. package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +0 -7
  382. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +0 -163
  383. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
  384. package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs +0 -28
  385. package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +0 -7
  386. package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs +0 -224
  387. package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +0 -7
  388. package/dist/lib/node-esm/chunk-2XL6MNPE.mjs +0 -99
  389. package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +0 -7
  390. package/dist/lib/node-esm/chunk-BISJDTBK.mjs +0 -159
  391. package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +0 -7
  392. package/dist/lib/node-esm/chunk-E33DNNDW.mjs +0 -109
  393. package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +0 -7
  394. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
  395. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs.map +0 -7
  396. package/dist/lib/node-esm/chunk-SENTQAEO.mjs +0 -2246
  397. package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +0 -7
  398. package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +0 -61
  399. package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +0 -7
  400. package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs +0 -151
  401. package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +0 -7
  402. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
  403. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
  404. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
  405. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
  406. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
  407. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
  408. package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
  409. package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
  410. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  411. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  412. package/dist/types/src/components/SequenceContainer.d.ts +0 -8
  413. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  414. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  415. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  416. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -8
  417. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  418. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  419. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  420. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  421. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  422. package/dist/types/src/hooks/chat-processor.d.ts +0 -86
  423. package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
  424. package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
  425. package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
  426. package/dist/types/src/hooks/presets.d.ts.map +0 -1
  427. package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
  428. package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
  429. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  430. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  431. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  432. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  433. package/dist/types/src/parser/index.d.ts +0 -4
  434. package/dist/types/src/parser/index.d.ts.map +0 -1
  435. package/dist/types/src/parser/query-parser.d.ts +0 -15
  436. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  437. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  438. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  439. package/dist/types/src/parser/types.d.ts +0 -24
  440. package/dist/types/src/parser/types.d.ts.map +0 -1
  441. package/dist/types/src/stories/Chat.stories.d.ts +0 -249
  442. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  443. package/dist/types/src/testing/test-functions.d.ts +0 -3
  444. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  445. package/dist/types/src/tools/function.d.ts +0 -5
  446. package/dist/types/src/tools/function.d.ts.map +0 -1
  447. package/dist/types/src/tools/index.d.ts +0 -3
  448. package/dist/types/src/tools/index.d.ts.map +0 -1
  449. package/dist/types/src/tools/openapi.d.ts +0 -10
  450. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  451. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  452. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  453. package/dist/types/src/types/schema.d.ts +0 -88
  454. package/dist/types/src/types/schema.d.ts.map +0 -1
  455. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
  456. package/src/components/ChatThread/ChatMessage.tsx +0 -268
  457. package/src/components/ChatThread/ToolBlock.tsx +0 -121
  458. package/src/components/ChatThread/reducer.ts +0 -52
  459. package/src/components/PromptSettings.tsx +0 -89
  460. package/src/components/SequenceContainer.tsx +0 -132
  461. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
  462. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  463. package/src/components/TemplateContainer.tsx +0 -24
  464. package/src/hooks/chat-processor.test.ts +0 -16
  465. package/src/hooks/chat-processor.ts +0 -314
  466. package/src/hooks/useBlueprints.ts +0 -57
  467. package/src/parser/filter-generator.test.ts +0 -32
  468. package/src/parser/filter-generator.ts +0 -81
  469. package/src/parser/index.ts +0 -7
  470. package/src/parser/query-parser.test.ts +0 -139
  471. package/src/parser/query-parser.ts +0 -199
  472. package/src/parser/types.ts +0 -34
  473. package/src/shims.d.ts +0 -8
  474. package/src/stories/Chat.stories.tsx +0 -378
  475. package/src/testing/test-functions.ts +0 -11
  476. package/src/tools/function.ts +0 -46
  477. package/src/tools/index.ts +0 -6
  478. package/src/tools/openapi.test.ts +0 -217
  479. package/src/tools/openapi.ts +0 -338
  480. package/src/types/schema.ts +0 -95
  481. package/src/typings.d.ts +0 -9
@@ -0,0 +1,95 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useSignalEffect } from '@preact/signals-react';
6
+ import { useCallback, useMemo, useState } from 'react';
7
+
8
+ import { Capabilities } from '@dxos/app-framework';
9
+ import { useCapabilities } from '@dxos/app-framework/react';
10
+ import { type AiContextBinder } from '@dxos/assistant';
11
+ import { Blueprint } from '@dxos/blueprints';
12
+ import { type Space } from '@dxos/client/echo';
13
+ import { Filter, Obj, Ref } from '@dxos/echo';
14
+ import { useQuery } from '@dxos/react-client/echo';
15
+ import { distinctBy, isNonNullable } from '@dxos/util';
16
+
17
+ /**
18
+ * Provide a registry of blueprints from plugins.
19
+ */
20
+ // TODO(burdon): Reconcile with eventual public registry.
21
+ export const useBlueprintRegistry = () => {
22
+ const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
23
+ return useMemo(() => new Blueprint.Registry(blueprints), [blueprints]);
24
+ };
25
+
26
+ export const useBlueprints = ({
27
+ blueprintRegistry,
28
+ space,
29
+ }: {
30
+ blueprintRegistry?: Blueprint.Registry;
31
+ space?: Space;
32
+ }) => {
33
+ const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [blueprintRegistry]);
34
+ const spaceBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
35
+ return useMemo(() => {
36
+ const blueprints = distinctBy([...staticBlueprints, ...spaceBlueprints], (b) => b.key);
37
+ blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
38
+ return blueprints;
39
+ }, [staticBlueprints, spaceBlueprints]);
40
+ };
41
+
42
+ /**
43
+ * Create reactive map of active blueprints (by key).
44
+ */
45
+ export const useActiveBlueprints = ({ context }: { context?: AiContextBinder }) => {
46
+ const [active, setActive] = useState<Map<string, Blueprint.Blueprint>>(new Map());
47
+
48
+ useSignalEffect(() => {
49
+ const refs = [...(context?.blueprints.value ?? [])];
50
+ const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
51
+ setActive(new Map(blueprints.map((blueprint) => [blueprint.key, blueprint])));
52
+ });
53
+
54
+ return active;
55
+ };
56
+
57
+ // TODO(burdon): Move logic into binder.
58
+ export const useBlueprintHandlers = ({
59
+ space,
60
+ context,
61
+ blueprintRegistry,
62
+ }: {
63
+ space: Space;
64
+ context?: AiContextBinder;
65
+ blueprintRegistry?: Blueprint.Registry;
66
+ }) => {
67
+ const onUpdateBlueprint = useCallback(
68
+ async (key: string, checked: boolean) => {
69
+ if (!context || !blueprintRegistry) {
70
+ return;
71
+ }
72
+
73
+ // Find existing cloned blueprint.
74
+ const objects = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
75
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
76
+ if (checked) {
77
+ if (!storedBlueprint) {
78
+ const blueprint = blueprintRegistry.getByKey(key);
79
+ if (!blueprint) {
80
+ return;
81
+ }
82
+
83
+ // NOTE: Possible race condition with other peers.
84
+ storedBlueprint = space.db.add(Obj.clone(blueprint));
85
+ }
86
+ await context.bind({ blueprints: [Ref.make(storedBlueprint)] });
87
+ } else if (storedBlueprint) {
88
+ await context.unbind({ blueprints: [Ref.make(storedBlueprint)] });
89
+ }
90
+ },
91
+ [space, context, blueprintRegistry],
92
+ );
93
+
94
+ return { onUpdateBlueprint };
95
+ };
@@ -2,142 +2,73 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Layer } from 'effect';
6
- import { useEffect, useMemo, useState } from 'react';
5
+ import { RegistryContext } from '@effect-atom/atom-react';
6
+ import type * as Runtime from 'effect/Runtime';
7
+ import { useContext, useMemo, useState } from 'react';
7
8
 
8
- import { type ExecutableTool } from '@dxos/ai';
9
- import { Capabilities, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
10
- import { Conversation, createSystemPrompt } from '@dxos/assistant';
11
- import { type ArtifactDefinition, type AssociatedArtifact, type Blueprint } from '@dxos/blueprints';
12
- import { FunctionType } from '@dxos/functions';
9
+ import { AiConversation } from '@dxos/assistant';
10
+ import { type Blueprint } from '@dxos/blueprints';
13
11
  import { log } from '@dxos/log';
14
- import { useConfig } from '@dxos/react-client';
15
- import { Filter, fullyQualifiedId, type Queue, type Space, useQuery } from '@dxos/react-client/echo';
16
- import { isNonNullable } from '@dxos/util';
12
+ import { type Queue, type Space } from '@dxos/react-client/echo';
13
+ import { useAsyncEffect } from '@dxos/react-ui';
17
14
 
18
- import { type AiServicePreset, ChatProcessor, type ChatServices } from '../hooks';
19
- import { convertFunctionToTool, createToolsFromService } from '../tools';
20
- import { type Assistant, ServiceType } from '../types';
15
+ import { AiChatProcessor, type AiChatServices, type AiServicePreset } from '../processor';
16
+ import { type Assistant } from '../types';
21
17
 
22
- type UseChatProcessorProps = {
23
- preset?: AiServicePreset;
18
+ export type UseChatProcessorProps = {
24
19
  space?: Space;
25
20
  chat?: Assistant.Chat;
26
-
27
- // TODO(burdon): Move into layer?
28
- services?: Layer.Layer<ChatServices>;
21
+ preset?: AiServicePreset;
22
+ services?: () => Promise<Runtime.Runtime<AiChatServices>>;
29
23
  blueprintRegistry?: Blueprint.Registry;
30
- // TODO(burdon): Not currently used.
31
24
  settings?: Assistant.Settings;
32
-
33
- /** @deprecated */
34
- instructions?: string;
35
- /** @deprecated */
36
- artifact?: AssociatedArtifact;
37
- /** @deprecated */
38
- noPluginArtifacts?: boolean;
39
25
  };
40
26
 
41
27
  /**
42
- * Configure and create ChatProcessor.
28
+ * Configure and create AiChatProcessor.
43
29
  */
44
30
  export const useChatProcessor = ({
45
- preset,
46
31
  space,
47
32
  chat,
33
+ preset,
48
34
  services,
49
35
  blueprintRegistry,
50
36
  settings,
51
- instructions,
52
- artifact,
53
- noPluginArtifacts,
54
- }: UseChatProcessorProps): ChatProcessor | undefined => {
55
- const { dispatchPromise: dispatch } = useIntentDispatcher();
56
- const globalTools = useCapabilities(Capabilities.Tools);
37
+ }: UseChatProcessorProps): AiChatProcessor | undefined => {
38
+ const observableRegistry = useContext(RegistryContext);
57
39
 
58
- // TODO(burdon): Spec artifacts.
59
- let artifacts: readonly ArtifactDefinition[] = useCapabilities(Capabilities.ArtifactDefinition);
60
- if (noPluginArtifacts) {
61
- artifacts = Stable.array;
62
- }
63
-
64
- // Services.
65
- const remoteServices = useQuery(space, Filter.type(ServiceType));
66
- const [serviceTools, setServiceTools] = useState<ExecutableTool[]>([]);
67
- useEffect(() => {
68
- log('creating service tools...');
69
- queueMicrotask(async () => {
70
- const tools = await Promise.all(remoteServices.map((service) => createToolsFromService(service)));
71
- setServiceTools(tools.flat());
72
- });
73
- }, [remoteServices]);
74
-
75
- // Tools and context.
76
- const config = useConfig();
77
- const functions = useQuery(space, Filter.type(FunctionType));
78
- const chatId = useMemo(() => (chat ? fullyQualifiedId(chat) : undefined), [chat]);
79
- const [tools, extensions] = useMemo(() => {
80
- log('creating tools...');
81
- const tools: ExecutableTool[] = [
82
- ...globalTools.flat(),
83
- ...serviceTools,
84
- ...functions
85
- .map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
86
- .filter(isNonNullable),
87
- ];
88
- const extensions = { space, dispatch, pivotId: chatId };
89
- return [tools, extensions];
90
- }, [dispatch, globalTools, space, chatId, serviceTools, functions]);
91
-
92
- // TODO(burdon): Create from template.
93
- const systemPrompt = useMemo(
94
- () =>
95
- createSystemPrompt({
96
- artifacts: artifacts.map((definition) => `${definition.name}\n${definition.instructions}`),
97
- artifact,
98
- instructions,
99
- }),
100
- [artifacts, artifact, instructions],
101
- );
102
-
103
- const conversation = useMemo(() => {
104
- if (!chat?.queue.target) {
40
+ // Create conversation from chat queue.
41
+ const [conversation, setConversation] = useState<AiConversation>();
42
+ useAsyncEffect(async () => {
43
+ if (!space || !chat) {
105
44
  return;
106
45
  }
107
46
 
108
- return new Conversation({ queue: chat.queue.target as Queue<any> });
109
- }, [chat?.queue.target]);
47
+ // NOTE: Passing in space and getting queue from space rather than resolving the reference.
48
+ // This is because if the chat isn't in a space yet, the reference will not be resolvable.
49
+ const queue = space.queues.get(chat.queue.dxn);
50
+ const conversation = new AiConversation(queue as Queue<any>);
51
+ await conversation.open();
52
+ setConversation(conversation);
53
+ return () => {
54
+ void conversation.close();
55
+ setConversation(undefined);
56
+ };
57
+ }, [space, chat?.queue.dxn.toString()]);
110
58
 
111
59
  // Create processor.
112
- // TODO(burdon): Updated on each query update above; should just update current processor?
113
60
  const processor = useMemo(() => {
114
61
  if (!services || !conversation) {
115
62
  return undefined;
116
63
  }
117
64
 
118
- log.info('creating processor', {
119
- preset,
120
- artifacts: artifacts.length,
121
- systemPrompt: systemPrompt.length,
122
- model: preset?.model,
123
- settings,
124
- });
125
-
126
- return new ChatProcessor(services, conversation, {
127
- tools,
128
- extensions,
65
+ log('creating processor', { preset, model: preset?.model, settings });
66
+ return new AiChatProcessor(conversation, services, {
67
+ observableRegistry,
129
68
  blueprintRegistry,
130
- artifacts,
131
- systemPrompt,
132
69
  model: preset?.model,
133
70
  });
134
- }, [services, conversation, tools, blueprintRegistry, artifacts, extensions, systemPrompt, preset]);
71
+ }, [services, conversation, blueprintRegistry, preset]);
135
72
 
136
73
  return processor;
137
74
  };
138
-
139
- // TODO(dmaretskyi): Extract.
140
- export const Stable = Object.freeze({
141
- array: [] as readonly never[],
142
- object: {} as {},
143
- });
@@ -2,90 +2,50 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Layer } from 'effect';
5
+ import * as Effect from 'effect/Effect';
6
+ import type * as Runtime from 'effect/Runtime';
6
7
  import { useMemo } from 'react';
7
- import { useDeepCompareMemoize } from 'use-deep-compare-effect';
8
8
 
9
- import { type AiService, type ToolExecutionService, ToolRegistry, type ToolResolverService } from '@dxos/ai';
10
- import { AiServiceTestingPreset } from '@dxos/ai/testing';
11
- import { Capabilities, useCapabilities } from '@dxos/app-framework';
12
- import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
9
+ import { useCapability } from '@dxos/app-framework/react';
13
10
  import { type Space } from '@dxos/client/echo';
14
- import {
15
- ConfiguredCredentialsService,
16
- CredentialsService,
17
- DatabaseService,
18
- EventLogger,
19
- FunctionCallService,
20
- QueueService,
21
- TracingService,
22
- } from '@dxos/functions';
11
+ import { TracingService } from '@dxos/functions';
12
+ import { TracingServiceExt } from '@dxos/functions-runtime';
13
+ import { AutomationCapabilities } from '@dxos/plugin-automation';
14
+ import { useClient } from '@dxos/react-client';
23
15
 
24
- export * from '@dxos/assistant';
25
-
26
- // TODO(burdon): Deconstruct into separate layers?
27
- export type ChatServices =
28
- | AiService
29
- | CredentialsService
30
- | DatabaseService
31
- | QueueService
32
- | FunctionCallService
33
- | ToolResolverService
34
- | ToolExecutionService
35
- | TracingService
36
- | EventLogger;
16
+ import { type AiChatServices } from '../processor';
17
+ import { type Assistant } from '../types';
37
18
 
38
19
  export type UseChatServicesProps = {
39
20
  space?: Space;
21
+ chat?: Assistant.Chat;
40
22
  };
41
23
 
42
24
  /**
43
25
  * Construct service layer.
44
26
  */
45
- export const useChatServices = ({ space }: UseChatServicesProps): Layer.Layer<ChatServices> | undefined => {
46
- const toolRegistry = useToolRegistry();
47
- // TODO(dmaretskyi): We can provide the plugin registry as a layer and then build the entire layer stack from there. We need to think how plugin reactivity affect our layer structure.
48
- const toolResolver = useToolResolver();
49
- const toolExecutionService = useToolExecutionService();
50
-
51
- return useMemo(() => {
52
- return Layer.mergeAll(
53
- AiServiceTestingPreset('edge-remote').pipe(Layer.orDie), // TODO(burdon): Error management?
54
- Layer.succeed(CredentialsService, new ConfiguredCredentialsService()),
55
- space ? Layer.succeed(DatabaseService, DatabaseService.make(space.db)) : DatabaseService.notAvailable,
56
- space ? Layer.succeed(QueueService, QueueService.make(space.queues)) : QueueService.notAvailable,
57
- Layer.succeed(FunctionCallService, FunctionCallService.mock()),
58
- Layer.succeed(TracingService, TracingService.noop),
59
- Layer.succeed(EventLogger, EventLogger.noop),
60
- toolResolver,
61
- toolExecutionService,
62
- );
63
- }, [space, toolRegistry, toolResolver]);
64
- };
65
-
66
- const useToolResolver = (): Layer.Layer<ToolResolverService> => {
67
- const functions = useCapabilities(Capabilities.Functions).flat();
68
- return useMemo(() => makeToolResolverFromFunctions(functions), [useDeepCompareMemoize(functions.map((f) => f.name))]);
69
- };
70
-
71
- const useToolExecutionService = (): Layer.Layer<ToolExecutionService> => {
72
- const functions = useCapabilities(Capabilities.Functions).flat();
73
- return useMemo(
74
- () => makeToolExecutionServiceFromFunctions(functions),
75
- [useDeepCompareMemoize(functions.map((f) => f.name))],
76
- );
77
- };
78
-
79
- // TODO(burdon): Factor out.
80
- const useToolRegistry = (): ToolRegistry => {
81
- const tools = useCapabilities(Capabilities.Tools).flat();
27
+ // TODO(dmaretskyi): Better return type.
28
+ export const useChatServices = ({
29
+ space,
30
+ chat,
31
+ }: UseChatServicesProps): (() => Promise<Runtime.Runtime<AiChatServices>>) | undefined => {
32
+ const client = useClient();
33
+ space ??= client.spaces.default;
34
+
35
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
82
36
  return useMemo(() => {
83
- const toolRegistry = new ToolRegistry([]);
84
- for (const tool of tools) {
85
- if (!toolRegistry.has(tool)) {
86
- toolRegistry.register(tool);
87
- }
88
- }
89
- return toolRegistry;
90
- }, [useDeepCompareMemoize(tools)]);
37
+ const runtime = runtimeResolver.getRuntime(space.id);
38
+ return () =>
39
+ runtime.runPromise(
40
+ Effect.gen(function* () {
41
+ return yield* Effect.runtime<AiChatServices>().pipe(
42
+ Effect.provide(
43
+ chat?.traceQueue?.target
44
+ ? TracingServiceExt.layerQueue(chat.traceQueue?.target)
45
+ : TracingService.layerNoop,
46
+ ),
47
+ );
48
+ }),
49
+ );
50
+ }, [space, chat?.traceQueue?.target]);
91
51
  };
@@ -0,0 +1,122 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Atom } from '@effect-atom/atom-react';
6
+ import * as Effect from 'effect/Effect';
7
+ import { useMemo } from 'react';
8
+
9
+ import { createIntent } from '@dxos/app-framework';
10
+ import { useIntentDispatcher } from '@dxos/app-framework/react';
11
+ import { Filter, Obj, Query } from '@dxos/echo';
12
+ import { invariant } from '@dxos/invariant';
13
+ import { useQuery } from '@dxos/react-client/echo';
14
+ import { MenuBuilder, useMenuActions } from '@dxos/react-ui-menu';
15
+
16
+ import { useChatContext } from '../components';
17
+ import { meta } from '../meta';
18
+ import { Assistant, AssistantAction } from '../types';
19
+
20
+ export type ChatToolbarActionsProps = {
21
+ chat?: Assistant.Chat;
22
+ companionTo?: Obj.Any;
23
+ };
24
+
25
+ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsProps) => {
26
+ const { dispatch } = useIntentDispatcher();
27
+ const { space } = useChatContext('useChatToolbarActions');
28
+ const query = companionTo
29
+ ? Query.select(Filter.id(companionTo.id)).targetOf(Assistant.CompanionTo).source()
30
+ : Query.select(Filter.nothing());
31
+
32
+ // TODO(wittjosiah): Query in react vs query in atom?
33
+ const chats = useQuery(space, query);
34
+
35
+ // Create stable reference for dependency array to avoid circular reference issues.
36
+ return useMenuActions(
37
+ useMemo(() => {
38
+ return Atom.make(() => {
39
+ const builder = MenuBuilder.make()
40
+ .root({
41
+ label: ['chat toolbar title', { ns: meta.id }],
42
+ })
43
+ .action(
44
+ 'new',
45
+ {
46
+ label: ['new thread button', { ns: meta.id }],
47
+ icon: 'ph--plus--regular',
48
+ type: 'new',
49
+ },
50
+ () =>
51
+ dispatch(
52
+ createIntent(AssistantAction.SetCurrentChat, {
53
+ companionTo,
54
+ chat: undefined,
55
+ }),
56
+ ).pipe(Effect.runPromise),
57
+ )
58
+ .action(
59
+ 'rename',
60
+ {
61
+ label: ['rename thread button', { ns: meta.id }],
62
+ icon: 'ph--magic-wand--regular',
63
+ type: 'rename',
64
+ disabled: !chat,
65
+ },
66
+ () =>
67
+ Effect.gen(function* () {
68
+ invariant(chat);
69
+ yield* dispatch(createIntent(AssistantAction.UpdateChatName, { chat }));
70
+ }).pipe(Effect.runPromise),
71
+ )
72
+ .action(
73
+ 'branch',
74
+ {
75
+ label: ['button branch thread', { ns: meta.id }],
76
+ icon: 'ph--git-branch--regular',
77
+ type: 'branch',
78
+ disabled: true,
79
+ },
80
+ () => {},
81
+ );
82
+
83
+ if (chats.length > 0) {
84
+ builder.group(
85
+ 'chats',
86
+ {
87
+ label: ['chat history label', { ns: meta.id }],
88
+ icon: 'ph--clock-counter-clockwise--regular',
89
+ selectCardinality: 'single',
90
+ variant: 'dropdownMenu',
91
+ },
92
+ (builder) => {
93
+ chats
94
+ // TODO(wittjosiah): This should be the default sort order.
95
+ .toSorted((a, b) => a.id.localeCompare(b.id))
96
+ .forEach((chat) => {
97
+ builder.action(
98
+ chat.id,
99
+ {
100
+ label: Obj.getLabel(chat) ?? ['object name placeholder', { ns: Assistant.Chat.typename }],
101
+ },
102
+ () =>
103
+ Effect.gen(function* () {
104
+ invariant(companionTo);
105
+ yield* dispatch(
106
+ createIntent(AssistantAction.SetCurrentChat, {
107
+ companionTo,
108
+ chat,
109
+ }),
110
+ );
111
+ }).pipe(Effect.runPromise),
112
+ );
113
+ });
114
+ },
115
+ );
116
+ }
117
+
118
+ return builder.build();
119
+ });
120
+ }, [chats.length, space?.id, companionTo?.id, chat?.id, dispatch]),
121
+ );
122
+ };
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useState } from 'react';
6
+
7
+ import { AiContextBinder } from '@dxos/assistant';
8
+ import { type Queue } from '@dxos/react-client/echo';
9
+ import { useAsyncEffect } from '@dxos/react-ui';
10
+
11
+ // NOTE: This takes a queue rather than a chat because the chat may not be in a space yet.
12
+ export const useContextBinder = (queue: Queue | undefined): AiContextBinder | undefined => {
13
+ const [binder, setBinder] = useState<AiContextBinder>();
14
+
15
+ useAsyncEffect(async () => {
16
+ if (!queue) {
17
+ return;
18
+ }
19
+
20
+ const binder = new AiContextBinder(queue);
21
+ await binder.open();
22
+ setBinder(binder);
23
+
24
+ return () => {
25
+ void binder.close();
26
+ };
27
+ }, [queue]);
28
+
29
+ return binder;
30
+ };
@@ -0,0 +1,58 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useCallback } from 'react';
6
+
7
+ import { type AiContextBinder } from '@dxos/assistant';
8
+ import { type DXN, type Obj, Ref } from '@dxos/echo';
9
+ import { log } from '@dxos/log';
10
+ import { type Space } from '@dxos/react-client/echo';
11
+ import { isNonNullable } from '@dxos/util';
12
+
13
+ export type UseContextObjects = {
14
+ objects: Obj.Any[];
15
+ onUpdateObject: (dxn: DXN, checked: boolean) => Promise<void>;
16
+ };
17
+
18
+ /**
19
+ * Create reactive map of active object references (by DXN string).
20
+ */
21
+ export const useContextObjects = ({
22
+ space,
23
+ context,
24
+ }: {
25
+ space?: Space;
26
+ context?: AiContextBinder;
27
+ }): UseContextObjects => {
28
+ const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable) ?? [];
29
+
30
+ const handleUpdateObject = useCallback<UseContextObjects['onUpdateObject']>(
31
+ async (dxn: DXN, checked: boolean) => {
32
+ if (!space || !context) {
33
+ return;
34
+ }
35
+
36
+ // Load the object by DXN/id from the current space.
37
+ const id = dxn.asEchoDXN();
38
+ const object = id && space.db.getObjectById(id.echoId);
39
+ if (!object) {
40
+ log.warn('Object not found', { dxn, id });
41
+ return;
42
+ }
43
+
44
+ const ref = Ref.fromDXN(dxn);
45
+ if (checked) {
46
+ await context.bind({ objects: [ref] });
47
+ } else {
48
+ await context.unbind({ objects: [ref] });
49
+ }
50
+ },
51
+ [space, context],
52
+ );
53
+
54
+ return {
55
+ objects,
56
+ onUpdateObject: handleUpdateObject,
57
+ };
58
+ };
@@ -0,0 +1,38 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Option from 'effect/Option';
6
+ import { useEffect, useState } from 'react';
7
+
8
+ import { type Type } from '@dxos/echo';
9
+ import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from '@dxos/echo/internal';
10
+ import { type Space } from '@dxos/react-client/echo';
11
+
12
+ // TODO(burdon): Pass in filter.
13
+ // TODO(wittjosiah): Factor out.
14
+ export const useFilteredTypes = (space?: Space): Type.Entity.Any[] => {
15
+ const [types, setTypes] = useState<Type.Entity.Any[]>([]);
16
+ useEffect(() => {
17
+ if (!space) {
18
+ return;
19
+ }
20
+
21
+ return space.db.schemaRegistry.query().subscribe(
22
+ (query) => {
23
+ const types = Array.from(
24
+ new Set(
25
+ [...space.db.graph.schemaRegistry.schemas, ...query.results]
26
+ .filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation)
27
+ .filter((schema) => SystemTypeAnnotation.get(schema).pipe(Option.getOrElse(() => false))),
28
+ ),
29
+ );
30
+
31
+ setTypes(types);
32
+ },
33
+ { fire: true },
34
+ );
35
+ }, [space]);
36
+
37
+ return types;
38
+ };
@@ -0,0 +1,35 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useCallback, useRef, useState } from 'react';
6
+
7
+ import { type Space } from '@dxos/client/echo';
8
+
9
+ export const useFlush = (space?: Space) => {
10
+ const [state, setState] = useState<'idle' | 'flushing' | 'flushed'>('idle');
11
+ const resetTimer = useRef<NodeJS.Timeout | null>(null);
12
+
13
+ const handleFlush = useCallback(() => {
14
+ if (!space) {
15
+ return;
16
+ }
17
+
18
+ queueMicrotask(async () => {
19
+ if (resetTimer.current) {
20
+ clearTimeout(resetTimer.current);
21
+ }
22
+
23
+ setState('flushing');
24
+ await space.db.flush();
25
+ setState('flushed');
26
+
27
+ resetTimer.current = setTimeout(() => {
28
+ setState('idle');
29
+ resetTimer.current = null;
30
+ }, 1_000);
31
+ });
32
+ }, [space]);
33
+
34
+ return { state, handleFlush };
35
+ };