@dxos/plugin-assistant 0.8.4-main.67995b8 → 0.8.4-main.ae835ea

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 (479) hide show
  1. package/dist/lib/browser/{BlueprintContainer-IZ4AK5EO.mjs → BlueprintContainer-GMSYKGSO.mjs} +14 -6
  2. package/dist/lib/browser/BlueprintContainer-GMSYKGSO.mjs.map +7 -0
  3. package/dist/lib/browser/ChatCompanion-M3FDKTQM.mjs +151 -0
  4. package/dist/lib/browser/ChatCompanion-M3FDKTQM.mjs.map +7 -0
  5. package/dist/lib/browser/{ChatContainer-RP3QEXYX.mjs → ChatContainer-KAH7XITI.mjs} +34 -14
  6. package/dist/lib/browser/ChatContainer-KAH7XITI.mjs.map +7 -0
  7. package/dist/lib/browser/{ChatDialog-ZVLXFHEY.mjs → ChatDialog-ZWRGABW6.mjs} +27 -12
  8. package/dist/lib/browser/ChatDialog-ZWRGABW6.mjs.map +7 -0
  9. package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
  10. package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
  11. package/dist/lib/browser/{app-graph-builder-XSEOKJLG.mjs → app-graph-builder-R5T7BJPC.mjs} +60 -41
  12. package/dist/lib/browser/app-graph-builder-R5T7BJPC.mjs.map +7 -0
  13. package/dist/lib/browser/blueprint-definition-AGTDXTXO.mjs +13 -0
  14. package/dist/lib/browser/blueprint-definition-AGTDXTXO.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-357IHWQL.mjs +1519 -0
  16. package/dist/lib/browser/chunk-357IHWQL.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-A2NVNXPL.mjs +170 -0
  18. package/dist/lib/browser/chunk-A2NVNXPL.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-CQW6UPJM.mjs +199 -0
  20. package/dist/lib/browser/chunk-CQW6UPJM.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-GNI6HL6G.mjs +219 -0
  22. package/dist/lib/browser/chunk-GNI6HL6G.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-GXHZTOWJ.mjs +378 -0
  24. package/dist/lib/browser/chunk-GXHZTOWJ.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  26. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-L5OA5OGS.mjs +262 -0
  28. package/dist/lib/browser/chunk-L5OA5OGS.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-MEN5WTLA.mjs +182 -0
  30. package/dist/lib/browser/chunk-MEN5WTLA.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-PUG24BEC.mjs +277 -0
  32. package/dist/lib/browser/chunk-PUG24BEC.mjs.map +7 -0
  33. package/dist/lib/browser/chunk-SJJV3HEX.mjs +16 -0
  34. package/dist/lib/browser/chunk-SJJV3HEX.mjs.map +7 -0
  35. package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
  36. package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
  37. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
  38. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
  39. package/dist/lib/browser/index.mjs +185 -76
  40. package/dist/lib/browser/index.mjs.map +4 -4
  41. package/dist/lib/browser/intent-resolver-3C5TABOX.mjs +136 -0
  42. package/dist/lib/browser/intent-resolver-3C5TABOX.mjs.map +7 -0
  43. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs +17 -0
  44. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs.map +7 -0
  45. package/dist/lib/browser/meta.json +1 -1
  46. package/dist/lib/browser/react-surface-EYKA5IFU.mjs +90 -0
  47. package/dist/lib/browser/react-surface-EYKA5IFU.mjs.map +7 -0
  48. package/dist/lib/browser/{settings-5GTTCVGD.mjs → settings-VMVBYZLN.mjs} +8 -7
  49. package/dist/lib/{node-esm/settings-J2EXEM5H.mjs.map → browser/settings-VMVBYZLN.mjs.map} +1 -1
  50. package/dist/lib/browser/state-CFREPBB6.mjs +21 -0
  51. package/dist/lib/browser/state-CFREPBB6.mjs.map +7 -0
  52. package/dist/lib/browser/toolkit-F3NQ7TSI.mjs +21 -0
  53. package/dist/lib/browser/toolkit-F3NQ7TSI.mjs.map +7 -0
  54. package/dist/lib/browser/types/index.mjs +7 -4
  55. package/dist/lib/node-esm/{BlueprintContainer-RGTMNLNX.mjs → BlueprintContainer-6GBLMK4Z.mjs} +14 -6
  56. package/dist/lib/node-esm/BlueprintContainer-6GBLMK4Z.mjs.map +7 -0
  57. package/dist/lib/node-esm/ChatCompanion-OV426GCP.mjs +152 -0
  58. package/dist/lib/node-esm/ChatCompanion-OV426GCP.mjs.map +7 -0
  59. package/dist/lib/node-esm/{ChatContainer-W3W6FWV3.mjs → ChatContainer-UKY7NHFY.mjs} +34 -14
  60. package/dist/lib/node-esm/ChatContainer-UKY7NHFY.mjs.map +7 -0
  61. package/dist/lib/node-esm/{ChatDialog-QW4JRKVO.mjs → ChatDialog-2BDQIEXH.mjs} +27 -12
  62. package/dist/lib/node-esm/ChatDialog-2BDQIEXH.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-PANCJUHV.mjs → app-graph-builder-I52RYVWH.mjs} +60 -41
  66. package/dist/lib/node-esm/app-graph-builder-I52RYVWH.mjs.map +7 -0
  67. package/dist/lib/node-esm/blueprint-definition-CFCUD2VC.mjs +14 -0
  68. package/dist/lib/node-esm/blueprint-definition-CFCUD2VC.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-2CAETDW2.mjs +183 -0
  70. package/dist/lib/node-esm/chunk-2CAETDW2.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-4J5FYNNM.mjs +171 -0
  72. package/dist/lib/node-esm/chunk-4J5FYNNM.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-5ARE4R2I.mjs +220 -0
  74. package/dist/lib/node-esm/chunk-5ARE4R2I.mjs.map +7 -0
  75. package/dist/lib/node-esm/chunk-7ZYOYW7F.mjs +264 -0
  76. package/dist/lib/node-esm/chunk-7ZYOYW7F.mjs.map +7 -0
  77. package/dist/lib/node-esm/chunk-HJPIYMWD.mjs +1520 -0
  78. package/dist/lib/node-esm/chunk-HJPIYMWD.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  80. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-O36P4LN5.mjs +200 -0
  82. package/dist/lib/node-esm/chunk-O36P4LN5.mjs.map +7 -0
  83. package/dist/lib/node-esm/chunk-WE6KTH72.mjs +25 -0
  84. package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
  85. package/dist/lib/node-esm/chunk-XM4BVQQR.mjs +278 -0
  86. package/dist/lib/node-esm/chunk-XM4BVQQR.mjs.map +7 -0
  87. package/dist/lib/node-esm/chunk-XQBL2SBL.mjs +17 -0
  88. package/dist/lib/node-esm/chunk-XQBL2SBL.mjs.map +7 -0
  89. package/dist/lib/node-esm/chunk-YIO5MEPR.mjs +380 -0
  90. package/dist/lib/node-esm/chunk-YIO5MEPR.mjs.map +7 -0
  91. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
  92. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
  93. package/dist/lib/node-esm/index.mjs +185 -76
  94. package/dist/lib/node-esm/index.mjs.map +4 -4
  95. package/dist/lib/node-esm/intent-resolver-HQ27YALS.mjs +137 -0
  96. package/dist/lib/node-esm/intent-resolver-HQ27YALS.mjs.map +7 -0
  97. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs +18 -0
  98. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs.map +7 -0
  99. package/dist/lib/node-esm/meta.json +1 -1
  100. package/dist/lib/node-esm/react-surface-UOC3CBPH.mjs +91 -0
  101. package/dist/lib/node-esm/react-surface-UOC3CBPH.mjs.map +7 -0
  102. package/dist/lib/node-esm/{settings-J2EXEM5H.mjs → settings-7AUVNDM2.mjs} +8 -7
  103. package/dist/lib/{browser/settings-5GTTCVGD.mjs.map → node-esm/settings-7AUVNDM2.mjs.map} +1 -1
  104. package/dist/lib/node-esm/state-XXND44OW.mjs +22 -0
  105. package/dist/lib/node-esm/state-XXND44OW.mjs.map +7 -0
  106. package/dist/lib/node-esm/toolkit-7CH5UNSQ.mjs +22 -0
  107. package/dist/lib/node-esm/toolkit-7CH5UNSQ.mjs.map +7 -0
  108. package/dist/lib/node-esm/types/index.mjs +7 -4
  109. package/dist/types/src/AssistantPlugin.d.ts +1 -1
  110. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  111. package/dist/types/src/capabilities/ai-service.d.ts +4 -0
  112. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  114. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  115. package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
  116. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/capabilities.d.ts +11 -0
  118. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
  120. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/index.d.ts +11 -3
  122. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  123. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  124. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  125. package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
  126. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  128. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  129. package/dist/types/src/capabilities/settings.d.ts +1 -1
  130. package/dist/types/src/capabilities/state.d.ts +4 -0
  131. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  132. package/dist/types/src/capabilities/toolkit.d.ts +4 -0
  133. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  134. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  135. package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
  136. package/dist/types/src/components/Chat/Chat.d.ts +21 -17
  137. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  138. package/dist/types/src/components/Chat/events.d.ts +5 -0
  139. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  140. package/dist/types/src/components/ChatCompanion.d.ts +13 -0
  141. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
  142. package/dist/types/src/components/ChatContainer.d.ts +4 -4
  143. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  144. package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
  145. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
  146. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  147. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  148. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  150. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
  151. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  152. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
  153. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +4 -5
  154. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  155. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
  156. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  157. package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
  158. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  159. package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -7
  160. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  161. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +120 -33
  162. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  163. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  164. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  165. package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
  166. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
  167. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  168. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  169. package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
  170. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  171. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  172. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  173. package/dist/types/src/components/ChatToolbar/ChatToolbar.d.ts +6 -0
  174. package/dist/types/src/components/ChatToolbar/ChatToolbar.d.ts.map +1 -0
  175. package/dist/types/src/components/ChatToolbar/index.d.ts +2 -0
  176. package/dist/types/src/components/ChatToolbar/index.d.ts.map +1 -0
  177. package/dist/types/src/components/ChatToolbar/useChatToolbarActions.d.ts +9 -0
  178. package/dist/types/src/components/ChatToolbar/useChatToolbarActions.d.ts.map +1 -0
  179. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -6
  180. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  181. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +265 -7
  182. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  183. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
  184. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  185. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +262 -2
  186. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  187. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
  188. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
  189. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
  190. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  191. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  192. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  193. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  194. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  195. package/dist/types/src/components/Toolbox/Toolbox.d.ts +6 -11
  196. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  197. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +266 -5
  198. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  199. package/dist/types/src/components/index.d.ts +4 -5
  200. package/dist/types/src/components/index.d.ts.map +1 -1
  201. package/dist/types/src/events.d.ts +1 -1
  202. package/dist/types/src/events.d.ts.map +1 -1
  203. package/dist/types/src/functions/analysis.d.ts +5 -0
  204. package/dist/types/src/functions/analysis.d.ts.map +1 -0
  205. package/dist/types/src/functions/index.d.ts +4 -0
  206. package/dist/types/src/functions/index.d.ts.map +1 -0
  207. package/dist/types/src/functions/object-list.d.ts +10 -0
  208. package/dist/types/src/functions/object-list.d.ts.map +1 -0
  209. package/dist/types/src/functions/object-load.d.ts +8 -0
  210. package/dist/types/src/functions/object-load.d.ts.map +1 -0
  211. package/dist/types/src/hooks/index.d.ts +7 -3
  212. package/dist/types/src/hooks/index.d.ts.map +1 -1
  213. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  214. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  215. package/dist/types/src/hooks/useChatProcessor.d.ts +8 -21
  216. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  217. package/dist/types/src/hooks/useChatServices.d.ts +5 -6
  218. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  219. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  220. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  221. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  222. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  223. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  224. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  225. package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
  226. package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
  227. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  228. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  229. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  230. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  231. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  232. package/dist/types/src/index.d.ts +2 -0
  233. package/dist/types/src/index.d.ts.map +1 -1
  234. package/dist/types/src/meta.d.ts +1 -2
  235. package/dist/types/src/meta.d.ts.map +1 -1
  236. package/dist/types/src/processor/index.d.ts +4 -0
  237. package/dist/types/src/processor/index.d.ts.map +1 -0
  238. package/dist/types/src/{hooks → processor}/presets.d.ts +3 -3
  239. package/dist/types/src/processor/presets.d.ts.map +1 -0
  240. package/dist/types/src/processor/processor.d.ts +74 -0
  241. package/dist/types/src/processor/processor.d.ts.map +1 -0
  242. package/dist/types/src/processor/processor.test.d.ts +2 -0
  243. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  244. package/dist/types/src/processor/update-name.d.ts +10 -0
  245. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  246. package/dist/types/src/testing/index.d.ts +1 -1
  247. package/dist/types/src/testing/index.d.ts.map +1 -1
  248. package/dist/types/src/testing/test-generator.d.ts +7 -0
  249. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  250. package/dist/types/src/testing/test-sequence.d.ts +0 -4
  251. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  252. package/dist/types/src/testing/test-services.d.ts +2 -2
  253. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  254. package/dist/types/src/toolkits/AssistantToolkit.d.ts +21 -0
  255. package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +1 -0
  256. package/dist/types/src/toolkits/SystemToolkit.d.ts +69 -0
  257. package/dist/types/src/toolkits/SystemToolkit.d.ts.map +1 -0
  258. package/dist/types/src/toolkits/index.d.ts +3 -0
  259. package/dist/types/src/toolkits/index.d.ts.map +1 -0
  260. package/dist/types/src/translations.d.ts +29 -12
  261. package/dist/types/src/translations.d.ts.map +1 -1
  262. package/dist/types/src/types/Assistant.d.ts +48 -0
  263. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  264. package/dist/types/src/types/AssistantAction.d.ts +119 -0
  265. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  266. package/dist/types/src/types/defs.d.ts +2 -0
  267. package/dist/types/src/types/defs.d.ts.map +1 -0
  268. package/dist/types/src/types/index.d.ts +3 -1
  269. package/dist/types/src/types/index.d.ts.map +1 -1
  270. package/dist/types/src/types/service.d.ts +21 -18
  271. package/dist/types/src/types/service.d.ts.map +1 -1
  272. package/dist/types/tsconfig.tsbuildinfo +1 -1
  273. package/package.json +97 -96
  274. package/src/AssistantPlugin.tsx +154 -107
  275. package/src/capabilities/ai-service.ts +27 -0
  276. package/src/capabilities/app-graph-builder.ts +76 -51
  277. package/src/capabilities/blueprint-definition.ts +66 -0
  278. package/src/capabilities/capabilities.ts +18 -0
  279. package/src/capabilities/edge-model-resolver.ts +25 -0
  280. package/src/capabilities/index.ts +9 -0
  281. package/src/capabilities/intent-resolver.ts +72 -23
  282. package/src/capabilities/local-model-resolver.ts +30 -0
  283. package/src/capabilities/react-surface.tsx +10 -77
  284. package/src/capabilities/state.ts +20 -0
  285. package/src/capabilities/toolkit.ts +19 -0
  286. package/src/components/AssistantSettings/AssistantSettings.tsx +83 -76
  287. package/src/components/BlueprintContainer.tsx +8 -2
  288. package/src/components/Chat/Chat.tsx +189 -181
  289. package/src/components/Chat/events.ts +7 -0
  290. package/src/components/ChatCompanion.tsx +136 -0
  291. package/src/components/ChatContainer.tsx +19 -13
  292. package/src/components/ChatDialog.tsx +18 -14
  293. package/src/components/ChatProgress/ChatProgress.tsx +67 -0
  294. package/src/components/{SequenceEditor → ChatProgress}/index.ts +1 -1
  295. package/src/components/ChatPrompt/ChatActions.tsx +10 -24
  296. package/src/components/ChatPrompt/ChatOptions.tsx +225 -0
  297. package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
  298. package/src/components/ChatPrompt/ChatReferences.tsx +31 -36
  299. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
  300. package/src/components/ChatPrompt/index.ts +1 -1
  301. package/src/components/ChatThread/ChatThread.stories.tsx +98 -112
  302. package/src/components/ChatThread/ChatThread.tsx +69 -29
  303. package/src/components/ChatThread/Link.tsx +26 -0
  304. package/src/components/ChatThread/reducers.ts +151 -0
  305. package/src/components/ChatThread/registry.tsx +184 -0
  306. package/src/components/ChatThread/sync.test.ts +81 -0
  307. package/src/components/ChatThread/sync.ts +113 -0
  308. package/src/components/ChatToolbar/ChatToolbar.tsx +23 -0
  309. package/src/components/ChatToolbar/index.ts +5 -0
  310. package/src/components/ChatToolbar/useChatToolbarActions.ts +126 -0
  311. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +28 -15
  312. package/src/components/TemplateEditor/TemplateEditor.tsx +29 -54
  313. package/src/components/TemplateEditor/TemplateForm.stories.tsx +15 -10
  314. package/src/components/TemplateEditor/TemplateForm.tsx +4 -2
  315. package/src/components/TemplateEditor/handlebars-extension.ts +166 -0
  316. package/src/components/ToolBlock/ToolBlock.tsx +152 -0
  317. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  318. package/src/components/ToolBlock/index.ts +6 -0
  319. package/src/components/Toolbox/Toolbox.stories.tsx +14 -23
  320. package/src/components/Toolbox/Toolbox.tsx +23 -53
  321. package/src/components/index.ts +3 -6
  322. package/src/events.ts +2 -2
  323. package/src/functions/analysis.ts +22 -0
  324. package/src/functions/index.ts +7 -0
  325. package/src/functions/object-list.ts +48 -0
  326. package/src/functions/object-load.ts +45 -0
  327. package/src/hooks/index.ts +7 -4
  328. package/src/hooks/useBlueprintRegistry.ts +94 -0
  329. package/src/hooks/useChatProcessor.ts +30 -99
  330. package/src/hooks/useChatServices.ts +30 -49
  331. package/src/hooks/useContextBinder.ts +30 -0
  332. package/src/hooks/useContextObjects.ts +58 -0
  333. package/src/hooks/useFlush.ts +35 -0
  334. package/src/hooks/useItemTypes.ts +37 -0
  335. package/src/hooks/useOnline.ts +10 -0
  336. package/src/hooks/usePresets.ts +44 -0
  337. package/src/hooks/useReferencesProvider.ts +11 -9
  338. package/src/index.ts +2 -0
  339. package/src/meta.ts +9 -6
  340. package/src/processor/index.ts +7 -0
  341. package/src/{hooks → processor}/presets.ts +15 -7
  342. package/src/processor/processor.test.ts +81 -0
  343. package/src/processor/processor.ts +277 -0
  344. package/src/processor/update-name.ts +57 -0
  345. package/src/queue-logger.ts +10 -10
  346. package/src/testing/index.ts +1 -1
  347. package/src/testing/test-generator.ts +261 -0
  348. package/src/testing/test-sequence.ts +2 -27
  349. package/src/testing/test-services.ts +2 -8
  350. package/src/toolkits/AssistantToolkit.ts +55 -0
  351. package/src/toolkits/SystemToolkit.ts +292 -0
  352. package/src/toolkits/index.ts +6 -0
  353. package/src/translations.ts +32 -12
  354. package/src/types/Assistant.ts +63 -0
  355. package/src/types/AssistantAction.ts +70 -0
  356. package/src/types/defs.ts +5 -0
  357. package/src/types/index.ts +4 -1
  358. package/src/types/service.ts +17 -9
  359. package/src/vite-env.d.ts +30 -0
  360. package/dist/lib/browser/BlueprintContainer-IZ4AK5EO.mjs.map +0 -7
  361. package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs.map +0 -7
  362. package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs.map +0 -7
  363. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +0 -162
  364. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
  365. package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs.map +0 -7
  366. package/dist/lib/browser/chunk-63GG6U6D.mjs +0 -2226
  367. package/dist/lib/browser/chunk-63GG6U6D.mjs.map +0 -7
  368. package/dist/lib/browser/chunk-7W7LHTRH.mjs +0 -171
  369. package/dist/lib/browser/chunk-7W7LHTRH.mjs.map +0 -7
  370. package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
  371. package/dist/lib/browser/chunk-FDCJSQYF.mjs.map +0 -7
  372. package/dist/lib/browser/chunk-KFXSBNZR.mjs +0 -89
  373. package/dist/lib/browser/chunk-KFXSBNZR.mjs.map +0 -7
  374. package/dist/lib/browser/chunk-LERGF5YG.mjs +0 -108
  375. package/dist/lib/browser/chunk-LERGF5YG.mjs.map +0 -7
  376. package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs +0 -75
  377. package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs.map +0 -7
  378. package/dist/lib/browser/react-surface-3GYEHQRP.mjs +0 -150
  379. package/dist/lib/browser/react-surface-3GYEHQRP.mjs.map +0 -7
  380. package/dist/lib/node-esm/BlueprintContainer-RGTMNLNX.mjs.map +0 -7
  381. package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs.map +0 -7
  382. package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs.map +0 -7
  383. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +0 -163
  384. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
  385. package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs.map +0 -7
  386. package/dist/lib/node-esm/chunk-BFO3KHYL.mjs +0 -2227
  387. package/dist/lib/node-esm/chunk-BFO3KHYL.mjs.map +0 -7
  388. package/dist/lib/node-esm/chunk-MS3PJARN.mjs +0 -109
  389. package/dist/lib/node-esm/chunk-MS3PJARN.mjs.map +0 -7
  390. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
  391. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs.map +0 -7
  392. package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs +0 -90
  393. package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs.map +0 -7
  394. package/dist/lib/node-esm/chunk-Z7PUODRT.mjs +0 -172
  395. package/dist/lib/node-esm/chunk-Z7PUODRT.mjs.map +0 -7
  396. package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs +0 -76
  397. package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs.map +0 -7
  398. package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs +0 -151
  399. package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs.map +0 -7
  400. package/dist/types/src/capability-definitions.d.ts +0 -7
  401. package/dist/types/src/capability-definitions.d.ts.map +0 -1
  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/hooks/chat-processor.d.ts +0 -86
  421. package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
  422. package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
  423. package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
  424. package/dist/types/src/hooks/presets.d.ts.map +0 -1
  425. package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
  426. package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
  427. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  428. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  429. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  430. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  431. package/dist/types/src/parser/index.d.ts +0 -4
  432. package/dist/types/src/parser/index.d.ts.map +0 -1
  433. package/dist/types/src/parser/query-parser.d.ts +0 -15
  434. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  435. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  436. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  437. package/dist/types/src/parser/types.d.ts +0 -24
  438. package/dist/types/src/parser/types.d.ts.map +0 -1
  439. package/dist/types/src/stories/Chat.stories.d.ts +0 -207
  440. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  441. package/dist/types/src/testing/test-functions.d.ts +0 -3
  442. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  443. package/dist/types/src/tools/function.d.ts +0 -5
  444. package/dist/types/src/tools/function.d.ts.map +0 -1
  445. package/dist/types/src/tools/index.d.ts +0 -3
  446. package/dist/types/src/tools/index.d.ts.map +0 -1
  447. package/dist/types/src/tools/openapi.d.ts +0 -10
  448. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  449. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  450. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  451. package/dist/types/src/types/schema.d.ts +0 -120
  452. package/dist/types/src/types/schema.d.ts.map +0 -1
  453. package/src/capability-definitions.ts +0 -15
  454. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
  455. package/src/components/ChatThread/ChatMessage.tsx +0 -268
  456. package/src/components/ChatThread/ToolBlock.tsx +0 -121
  457. package/src/components/ChatThread/reducer.ts +0 -52
  458. package/src/components/PromptSettings.tsx +0 -89
  459. package/src/components/SequenceContainer.tsx +0 -132
  460. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
  461. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  462. package/src/hooks/chat-processor.test.ts +0 -16
  463. package/src/hooks/chat-processor.ts +0 -314
  464. package/src/hooks/useBlueprints.ts +0 -57
  465. package/src/parser/filter-generator.test.ts +0 -32
  466. package/src/parser/filter-generator.ts +0 -81
  467. package/src/parser/index.ts +0 -7
  468. package/src/parser/query-parser.test.ts +0 -139
  469. package/src/parser/query-parser.ts +0 -199
  470. package/src/parser/types.ts +0 -34
  471. package/src/shims.d.ts +0 -8
  472. package/src/stories/Chat.stories.tsx +0 -371
  473. package/src/testing/test-functions.ts +0 -11
  474. package/src/tools/function.ts +0 -46
  475. package/src/tools/index.ts +0 -6
  476. package/src/tools/openapi.test.ts +0 -217
  477. package/src/tools/openapi.ts +0 -338
  478. package/src/types/schema.ts +0 -108
  479. package/src/typings.d.ts +0 -9
@@ -0,0 +1,1519 @@
1
+ import {
2
+ AiChatProcessor,
3
+ AiServicePresets
4
+ } from "./chunk-L5OA5OGS.mjs";
5
+ import {
6
+ meta
7
+ } from "./chunk-WBG5PTSX.mjs";
8
+
9
+ // src/hooks/useBlueprintRegistry.ts
10
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
11
+ import { useSignalEffect } from "@preact/signals-react";
12
+ import { useCallback, useMemo, useState } from "react";
13
+ import { Capabilities, useCapabilities } from "@dxos/app-framework";
14
+ import { Blueprint } from "@dxos/blueprints";
15
+ import { Filter, Obj, Ref } from "@dxos/echo";
16
+ import { useQuery } from "@dxos/react-client/echo";
17
+ import { distinctBy, isNonNullable } from "@dxos/util";
18
+ var useBlueprintRegistry = () => {
19
+ const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
20
+ return useMemo(() => new Blueprint.Registry(blueprints), [
21
+ blueprints
22
+ ]);
23
+ };
24
+ var useBlueprints = ({ blueprintRegistry, space }) => {
25
+ const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
26
+ blueprintRegistry
27
+ ]);
28
+ const spaceBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
29
+ return useMemo(() => {
30
+ const blueprints = distinctBy([
31
+ ...staticBlueprints,
32
+ ...spaceBlueprints
33
+ ], (b) => b.key);
34
+ blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
35
+ return blueprints;
36
+ }, [
37
+ staticBlueprints,
38
+ spaceBlueprints
39
+ ]);
40
+ };
41
+ var useActiveBlueprints = ({ context }) => {
42
+ var _effect = _useSignals();
43
+ try {
44
+ const [active, setActive] = useState(/* @__PURE__ */ new Map());
45
+ useSignalEffect(() => {
46
+ const refs = [
47
+ ...context?.blueprints.value ?? []
48
+ ];
49
+ const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
50
+ setActive(new Map(blueprints.map((blueprint) => [
51
+ blueprint.key,
52
+ blueprint
53
+ ])));
54
+ });
55
+ return active;
56
+ } finally {
57
+ _effect.f();
58
+ }
59
+ };
60
+ var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
61
+ const onUpdateBlueprint = useCallback(async (key, checked) => {
62
+ if (!context || !blueprintRegistry) {
63
+ return;
64
+ }
65
+ const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
66
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
67
+ if (checked) {
68
+ if (!storedBlueprint) {
69
+ const blueprint = blueprintRegistry.getByKey(key);
70
+ if (!blueprint) {
71
+ return;
72
+ }
73
+ storedBlueprint = space.db.add(Obj.clone(blueprint));
74
+ }
75
+ await context.bind({
76
+ blueprints: [
77
+ Ref.make(storedBlueprint)
78
+ ]
79
+ });
80
+ } else if (storedBlueprint) {
81
+ await context.unbind({
82
+ blueprints: [
83
+ Ref.make(storedBlueprint)
84
+ ]
85
+ });
86
+ }
87
+ }, [
88
+ space,
89
+ context,
90
+ blueprintRegistry
91
+ ]);
92
+ return {
93
+ onUpdateBlueprint
94
+ };
95
+ };
96
+
97
+ // src/hooks/useChatProcessor.ts
98
+ import { RegistryContext } from "@effect-rx/rx-react";
99
+ import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
100
+ import { AiConversation } from "@dxos/assistant";
101
+ import { log } from "@dxos/log";
102
+ import { useAsyncEffect } from "@dxos/react-ui";
103
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
104
+ var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
105
+ const observableRegistry = useContext(RegistryContext);
106
+ const [conversation, setConversation] = useState2();
107
+ useAsyncEffect(async () => {
108
+ if (!chat?.queue.target) {
109
+ return;
110
+ }
111
+ const conversation2 = new AiConversation(chat.queue.target);
112
+ await conversation2.open();
113
+ setConversation(conversation2);
114
+ return () => {
115
+ void conversation2.close();
116
+ };
117
+ }, [
118
+ chat?.queue.target
119
+ ]);
120
+ const processor = useMemo2(() => {
121
+ if (!services || !conversation) {
122
+ return void 0;
123
+ }
124
+ log("creating processor", {
125
+ preset,
126
+ model: preset?.model,
127
+ settings
128
+ }, {
129
+ F: __dxlog_file,
130
+ L: 60,
131
+ S: void 0,
132
+ C: (f, a) => f(...a)
133
+ });
134
+ return new AiChatProcessor(conversation, services, {
135
+ observableRegistry,
136
+ blueprintRegistry,
137
+ model: preset?.model
138
+ });
139
+ }, [
140
+ services,
141
+ conversation,
142
+ blueprintRegistry,
143
+ preset
144
+ ]);
145
+ return processor;
146
+ };
147
+
148
+ // src/hooks/useChatServices.ts
149
+ import * as Effect from "effect/Effect";
150
+ import { useMemo as useMemo3 } from "react";
151
+ import { useCapability } from "@dxos/app-framework";
152
+ import { TracingService } from "@dxos/functions";
153
+ import { AutomationCapabilities } from "@dxos/plugin-automation";
154
+ import { useClient } from "@dxos/react-client";
155
+ var useChatServices = ({ space, chat }) => {
156
+ const client = useClient();
157
+ space ??= client.spaces.default;
158
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
159
+ return useMemo3(() => {
160
+ const runtime2 = runtimeResolver.getRuntime(space.id);
161
+ return () => runtime2.runPromise(Effect.gen(function* () {
162
+ return yield* Effect.runtime().pipe(Effect.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
163
+ }));
164
+ }, [
165
+ space,
166
+ chat?.traceQueue?.target
167
+ ]);
168
+ };
169
+
170
+ // src/hooks/useContextBinder.ts
171
+ import { useState as useState3 } from "react";
172
+ import { AiContextBinder } from "@dxos/assistant";
173
+ import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
174
+ var useContextBinder = (chat) => {
175
+ const [binder, setBinder] = useState3();
176
+ useAsyncEffect2(async () => {
177
+ if (!chat?.queue.target) {
178
+ return;
179
+ }
180
+ const binder2 = new AiContextBinder(chat.queue.target);
181
+ await binder2.open();
182
+ setBinder(binder2);
183
+ return () => {
184
+ void binder2.close();
185
+ };
186
+ }, [
187
+ chat?.queue.target
188
+ ]);
189
+ return binder;
190
+ };
191
+
192
+ // src/hooks/useContextObjects.ts
193
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
194
+ import { useCallback as useCallback2 } from "react";
195
+ import { Ref as Ref2 } from "@dxos/echo";
196
+ import { log as log2 } from "@dxos/log";
197
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
198
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
199
+ var useContextObjects = ({ space, context }) => {
200
+ var _effect = _useSignals2();
201
+ try {
202
+ const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
203
+ const handleUpdateObject = useCallback2(async (dxn, checked) => {
204
+ if (!space || !context) {
205
+ return;
206
+ }
207
+ const id = dxn.asEchoDXN();
208
+ const object = id && await space.db.getObjectById(id.echoId);
209
+ if (!object) {
210
+ log2.warn("Object not found", {
211
+ dxn,
212
+ id
213
+ }, {
214
+ F: __dxlog_file2,
215
+ L: 40,
216
+ S: void 0,
217
+ C: (f, a) => f(...a)
218
+ });
219
+ return;
220
+ }
221
+ const ref = Ref2.fromDXN(dxn);
222
+ if (checked) {
223
+ await context.bind({
224
+ objects: [
225
+ ref
226
+ ]
227
+ });
228
+ } else {
229
+ await context.unbind({
230
+ objects: [
231
+ ref
232
+ ]
233
+ });
234
+ }
235
+ }, [
236
+ space,
237
+ context
238
+ ]);
239
+ return {
240
+ objects,
241
+ onUpdateObject: handleUpdateObject
242
+ };
243
+ } finally {
244
+ _effect.f();
245
+ }
246
+ };
247
+
248
+ // src/hooks/useFlush.ts
249
+ import { useCallback as useCallback3, useRef, useState as useState4 } from "react";
250
+ var useFlush = (space) => {
251
+ const [state, setState] = useState4("idle");
252
+ const resetTimer = useRef(null);
253
+ const handleFlush = useCallback3(() => {
254
+ if (!space) {
255
+ return;
256
+ }
257
+ queueMicrotask(async () => {
258
+ if (resetTimer.current) {
259
+ clearTimeout(resetTimer.current);
260
+ }
261
+ setState("flushing");
262
+ await space.db.flush();
263
+ setState("flushed");
264
+ resetTimer.current = setTimeout(() => {
265
+ setState("idle");
266
+ resetTimer.current = null;
267
+ }, 1e3);
268
+ });
269
+ }, [
270
+ space
271
+ ]);
272
+ return {
273
+ state,
274
+ handleFlush
275
+ };
276
+ };
277
+
278
+ // src/hooks/useItemTypes.ts
279
+ import * as Option from "effect/Option";
280
+ import { useEffect, useState as useState5 } from "react";
281
+ import { ItemAnnotation } from "@dxos/schema";
282
+ var useItemTypes = (space) => {
283
+ const [types, setTypes] = useState5([]);
284
+ useEffect(() => {
285
+ if (!space) {
286
+ return;
287
+ }
288
+ return space.db.schemaRegistry.query().subscribe((query) => {
289
+ const types2 = Array.from(new Set([
290
+ ...space.db.graph.schemaRegistry.schemas,
291
+ ...query.results
292
+ ].filter((type) => Option.isSome(ItemAnnotation.get(type)))));
293
+ setTypes(types2);
294
+ }, {
295
+ fire: true
296
+ });
297
+ }, [
298
+ space
299
+ ]);
300
+ return types;
301
+ };
302
+
303
+ // src/hooks/useOnline.ts
304
+ import { useState as useState6 } from "react";
305
+ var useOnline = () => {
306
+ const [online, setOnline] = useState6(true);
307
+ return [
308
+ online,
309
+ setOnline
310
+ ];
311
+ };
312
+
313
+ // src/hooks/usePresets.ts
314
+ import { useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo4, useState as useState7 } from "react";
315
+ var usePresets = (online) => {
316
+ const [preset, setPreset] = useState7();
317
+ const presets = useMemo4(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
318
+ online
319
+ ]);
320
+ const presetOptions = useMemo4(() => presets.map(({ id, model, label }) => ({
321
+ id,
322
+ label: label ?? model
323
+ })), [
324
+ presets
325
+ ]);
326
+ useEffect2(() => {
327
+ setPreset(presets[0]);
328
+ }, [
329
+ presets
330
+ ]);
331
+ const handlePresetChange = useCallback4((id) => {
332
+ const preset2 = presets.find((preset3) => preset3.id === id);
333
+ if (preset2) {
334
+ setPreset(preset2);
335
+ }
336
+ }, [
337
+ presets
338
+ ]);
339
+ return {
340
+ preset,
341
+ presets: presetOptions,
342
+ onPresetChange: handlePresetChange
343
+ };
344
+ };
345
+
346
+ // src/hooks/useReferencesProvider.ts
347
+ import { useMemo as useMemo5 } from "react";
348
+ import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
349
+ import { Filter as Filter2, Obj as Obj2 } from "@dxos/echo";
350
+ var useReferencesProvider = (space) => {
351
+ const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
352
+ return useMemo5(() => {
353
+ if (!space) {
354
+ return void 0;
355
+ }
356
+ return {
357
+ getReferences: async ({ query }) => {
358
+ const { objects } = await space.db.query(Filter2.everything()).run();
359
+ return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
360
+ uri: Obj2.getDXN(object).toString(),
361
+ label: Obj2.getLabel(object) ?? ""
362
+ }));
363
+ },
364
+ resolveReference: async ({ uri }) => {
365
+ const object = await space.db.query(Filter2.ids(uri)).first();
366
+ return {
367
+ uri,
368
+ label: Obj2.getLabel(object) ?? ""
369
+ };
370
+ }
371
+ };
372
+ }, [
373
+ space,
374
+ blueprints
375
+ ]);
376
+ };
377
+ var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
378
+
379
+ // src/components/Chat/Chat.tsx
380
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
381
+ import { Prec } from "@codemirror/state";
382
+ import { keymap } from "@codemirror/view";
383
+ import { useRxValue } from "@effect-rx/rx-react";
384
+ import { createContext } from "@radix-ui/react-context";
385
+ import * as Array2 from "effect/Array";
386
+ import * as Option2 from "effect/Option";
387
+ import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState12 } from "react";
388
+ import { Event } from "@dxos/async";
389
+ import { Obj as Obj5 } from "@dxos/echo";
390
+ import { useVoiceInput } from "@dxos/plugin-transcription";
391
+ import { getSpace, useQueue } from "@dxos/react-client/echo";
392
+ import { useIdentity } from "@dxos/react-client/halo";
393
+ import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
394
+ import { ChatEditor, references } from "@dxos/react-ui-chat";
395
+ import { mx as mx5 } from "@dxos/react-ui-theme";
396
+ import { DataType } from "@dxos/schema";
397
+ import { isTruthy } from "@dxos/util";
398
+
399
+ // src/components/ChatPrompt/ChatActions.tsx
400
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
401
+ import React from "react";
402
+ import { IconButton, useTranslation } from "@dxos/react-ui";
403
+ import { mx } from "@dxos/react-ui-theme";
404
+ var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
405
+ var _effect = _useSignals3();
406
+ try {
407
+ const { t } = useTranslation(meta.id);
408
+ return /* @__PURE__ */ React.createElement("div", {
409
+ className: mx("flex items-center mie-1", classNames)
410
+ }, children, /* @__PURE__ */ React.createElement(IconButton, {
411
+ disabled: !processing,
412
+ variant: "ghost",
413
+ size: 5,
414
+ icon: "ph--x--regular",
415
+ iconOnly: true,
416
+ label: t("button cancel processing"),
417
+ onClick: () => onEvent?.({
418
+ type: "cancel"
419
+ })
420
+ }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
421
+ disabled: !processing,
422
+ classNames: mx(recording && "bg-primary-500"),
423
+ variant: "ghost",
424
+ size: 5,
425
+ icon: "ph--microphone--regular",
426
+ iconOnly: true,
427
+ noTooltip: true,
428
+ label: t("button microphone"),
429
+ onMouseDown: () => onEvent?.({
430
+ type: "record-start"
431
+ }),
432
+ onMouseUp: () => onEvent?.({
433
+ type: "record-stop"
434
+ }),
435
+ onTouchStart: () => onEvent?.({
436
+ type: "record-start"
437
+ }),
438
+ onTouchEnd: () => onEvent?.({
439
+ type: "record-stop"
440
+ })
441
+ }));
442
+ } finally {
443
+ _effect.f();
444
+ }
445
+ };
446
+
447
+ // src/components/ChatPrompt/ChatOptions.tsx
448
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
449
+ import React2, { useMemo as useMemo6, useState as useState8 } from "react";
450
+ import { Filter as Filter3, Obj as Obj3, Type } from "@dxos/echo";
451
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
452
+ import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
453
+ import { Listbox, SearchList } from "@dxos/react-ui-searchlist";
454
+ import { Tabs } from "@dxos/react-ui-tabs";
455
+ var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-72 max-is-[--text-content]";
456
+ var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
457
+ var _effect = _useSignals4();
458
+ try {
459
+ const { t } = useTranslation2(meta.id);
460
+ return /* @__PURE__ */ React2.createElement("div", {
461
+ role: "none",
462
+ className: "flex gap-0.5"
463
+ }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
464
+ asChild: true
465
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
466
+ variant: "ghost",
467
+ icon: "ph--plus--regular",
468
+ iconOnly: true,
469
+ size: 5,
470
+ label: t("button context objects")
471
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
472
+ side: "top",
473
+ classNames: panelClassNames
474
+ }, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
475
+ space,
476
+ context
477
+ }), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
478
+ asChild: true
479
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
480
+ variant: "ghost",
481
+ icon: "ph--sliders-horizontal--regular",
482
+ iconOnly: true,
483
+ size: 5,
484
+ label: t("button context settings")
485
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
486
+ side: "top",
487
+ classNames: panelClassNames
488
+ }, /* @__PURE__ */ React2.createElement(Tabs.Root, {
489
+ orientation: "horizontal",
490
+ defaultValue: "blueprints",
491
+ defaultActivePart: "list",
492
+ tabIndex: -1
493
+ }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
494
+ classNames: 'max-bs-[--radix-popover-content-available-height] grid grid-rows-[1fr_min-content] [&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content] [&_[role="listbox"]]:min-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'
495
+ }, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
496
+ value: "blueprints",
497
+ tabIndex: -1,
498
+ classNames: "dx-focus-ring-inset"
499
+ }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
500
+ blueprintRegistry,
501
+ space,
502
+ context
503
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
504
+ value: "model",
505
+ tabIndex: -1,
506
+ classNames: "dx-focus-ring-inset !pli-0"
507
+ }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
508
+ presets,
509
+ preset,
510
+ onPresetChange
511
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
512
+ classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
513
+ }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
514
+ value: "blueprints",
515
+ icon: "ph--blueprint--regular",
516
+ label: t("blueprints in context title")
517
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
518
+ value: "model",
519
+ label: t("chat model title"),
520
+ icon: "ph--cpu--regular"
521
+ })))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
522
+ } finally {
523
+ _effect.f();
524
+ }
525
+ };
526
+ var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
527
+ var _effect = _useSignals4();
528
+ try {
529
+ const { t } = useTranslation2(meta.id);
530
+ const blueprints = useBlueprints({
531
+ blueprintRegistry,
532
+ space
533
+ });
534
+ const activeBlueprints = useActiveBlueprints({
535
+ context
536
+ });
537
+ const { onUpdateBlueprint } = useBlueprintHandlers({
538
+ space,
539
+ context,
540
+ blueprintRegistry
541
+ });
542
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
543
+ classNames: "plb-cardSpacingChrome"
544
+ }, blueprints.map((blueprint) => {
545
+ const isActive = activeBlueprints.has(blueprint.key);
546
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
547
+ classNames: "flex items-center overflow-hidden",
548
+ key: blueprint.key,
549
+ value: blueprint.name,
550
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
551
+ }, /* @__PURE__ */ React2.createElement("div", {
552
+ className: "grow truncate"
553
+ }, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
554
+ icon: "ph--check--regular",
555
+ classNames: [
556
+ !isActive && "invisible"
557
+ ]
558
+ }));
559
+ })), /* @__PURE__ */ React2.createElement(SearchList.Input, {
560
+ placeholder: t("search placeholder"),
561
+ classNames: "mbe-cardSpacingChrome",
562
+ autoFocus: true
563
+ }));
564
+ } finally {
565
+ _effect.f();
566
+ }
567
+ };
568
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
569
+ var _effect = _useSignals4();
570
+ try {
571
+ return /* @__PURE__ */ React2.createElement(Listbox.Root, {
572
+ value: preset,
573
+ onValueChange: onPresetChange,
574
+ autoFocus: true
575
+ }, presets?.map(({ id, label }) => {
576
+ return /* @__PURE__ */ React2.createElement(Listbox.Option, {
577
+ key: id,
578
+ value: id
579
+ }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
580
+ }));
581
+ } finally {
582
+ _effect.f();
583
+ }
584
+ };
585
+ var ANY = "__any__";
586
+ var ObjectsPanel = ({ space, context }) => {
587
+ var _effect = _useSignals4();
588
+ try {
589
+ const { t } = useTranslation2(meta.id);
590
+ const types = useItemTypes(space);
591
+ const typenames = useMemo6(() => {
592
+ const typenames2 = types.map((type) => {
593
+ const typename2 = Type.getTypename(type);
594
+ return {
595
+ typename: typename2,
596
+ label: t("typename label", {
597
+ ns: typename2,
598
+ defaultValue: typename2
599
+ })
600
+ };
601
+ });
602
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
603
+ return typenames2;
604
+ }, [
605
+ types
606
+ ]);
607
+ const [typename, setTypename] = useState8(ANY);
608
+ const anyFilter = useMemo6(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
609
+ typenames
610
+ ]);
611
+ const objects = useQuery2(space, typename === ANY ? anyFilter : Filter3.typename(typename));
612
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
613
+ space,
614
+ context
615
+ });
616
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
617
+ classNames: "p-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
618
+ }, objects.length ? objects.map((object) => {
619
+ const label = Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id;
620
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
621
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
622
+ classNames: "flex items-center overflow-hidden",
623
+ key: object.id,
624
+ value: object.id,
625
+ onSelect: () => onUpdateObject?.(Obj3.getDXN(object), !isActive)
626
+ }, /* @__PURE__ */ React2.createElement("div", {
627
+ className: "grow truncate"
628
+ }, label), /* @__PURE__ */ React2.createElement(Icon, {
629
+ icon: "ph--check--regular",
630
+ classNames: [
631
+ !isActive && "invisible"
632
+ ]
633
+ }));
634
+ }) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
635
+ role: "none",
636
+ className: "grid grid-cols-[min-content_1fr] gap-2 pli-cardSpacingChrome mbe-cardSpacingChrome"
637
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
638
+ value: typename === ANY ? void 0 : typename,
639
+ onValueChange: setTypename
640
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
641
+ density: "fine",
642
+ placeholder: t("type filter placeholder")
643
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
644
+ value: ANY
645
+ }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
646
+ key: typename2,
647
+ value: typename2
648
+ }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
649
+ placeholder: t("search placeholder"),
650
+ classNames: "mbe-0",
651
+ autoFocus: true
652
+ })));
653
+ } finally {
654
+ _effect.f();
655
+ }
656
+ };
657
+
658
+ // src/components/ChatPrompt/ChatPresets.tsx
659
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
660
+ import React3 from "react";
661
+ import { Select as Select2 } from "@dxos/react-ui";
662
+
663
+ // src/components/ChatPrompt/ChatReferences.tsx
664
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
665
+ import React4 from "react";
666
+ import { Obj as Obj4 } from "@dxos/echo";
667
+ import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
668
+ import { mx as mx2 } from "@dxos/react-ui-theme";
669
+ var ChatReferences = ({ classNames, context, space }) => {
670
+ var _effect = _useSignals6();
671
+ try {
672
+ const { t } = useTranslation3(meta.id);
673
+ const { objects, onUpdateObject } = useContextObjects({
674
+ space,
675
+ context
676
+ });
677
+ return /* @__PURE__ */ React4.createElement("ul", {
678
+ className: mx2("flex flex-wrap", classNames)
679
+ }, objects.map((obj) => {
680
+ const dxn = Obj4.getDXN(obj);
681
+ const typename = Obj4.getTypename(obj);
682
+ const label = Obj4.getLabel(obj) ?? (typename ? [
683
+ "object name placeholder",
684
+ {
685
+ ns: typename
686
+ }
687
+ ] : obj.id);
688
+ return /* @__PURE__ */ React4.createElement("li", {
689
+ key: dxn.toString(),
690
+ className: "dx-tag plb-0 pis-2 flex items-center",
691
+ "data-hue": "neutral"
692
+ }, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
693
+ iconOnly: true,
694
+ variant: "ghost",
695
+ label: t("remove object in context label"),
696
+ classNames: "p-0 hover:bg-transparent",
697
+ size: 3,
698
+ icon: "ph--x--bold",
699
+ onClick: () => onUpdateObject?.(dxn, false)
700
+ }));
701
+ }));
702
+ } finally {
703
+ _effect.f();
704
+ }
705
+ };
706
+
707
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
708
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
709
+ import React5, { useEffect as useEffect3, useState as useState9 } from "react";
710
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
711
+ import { Spinner } from "@dxos/react-ui-sfx";
712
+ import { mx as mx3 } from "@dxos/react-ui-theme";
713
+ var period = 3e3;
714
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
715
+ var _effect = _useSignals7();
716
+ try {
717
+ const [init, setInit] = useState9(false);
718
+ useEffect3(() => setInit(false), [
719
+ preset
720
+ ]);
721
+ useTimeout(async () => {
722
+ setInit(true);
723
+ }, period / 2, [
724
+ preset
725
+ ]);
726
+ return /* @__PURE__ */ React5.createElement("div", {
727
+ role: "none",
728
+ className: mx3("relative flex", classNames)
729
+ }, /* @__PURE__ */ React5.createElement(Spinner, {
730
+ duration: period,
731
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
732
+ ...props
733
+ }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
734
+ asChild: true,
735
+ content: error.message
736
+ }, /* @__PURE__ */ React5.createElement("div", {
737
+ className: "absolute inset-0"
738
+ })));
739
+ } finally {
740
+ _effect.f();
741
+ }
742
+ };
743
+
744
+ // src/components/ChatThread/ChatThread.tsx
745
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
746
+ import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo8, useState as useState11 } from "react";
747
+ import { PublicKey } from "@dxos/keys";
748
+ import { MarkdownStream } from "@dxos/react-ui-components";
749
+ import { mx as mx4 } from "@dxos/react-ui-theme";
750
+ import { keyToFallback } from "@dxos/util";
751
+
752
+ // src/components/ChatThread/registry.tsx
753
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
754
+ import React7 from "react";
755
+ import { log as log3 } from "@dxos/log";
756
+ import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
757
+ import { getXmlTextChild } from "@dxos/react-ui-editor";
758
+ import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
759
+ import { ContentBlock } from "@dxos/schema";
760
+
761
+ // src/components/ToolBlock/ToolBlock.tsx
762
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
763
+ import React6, { useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
764
+ import { useTranslation as useTranslation4 } from "@dxos/react-ui";
765
+ import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
766
+ import { Json } from "@dxos/react-ui-syntax-highlighter";
767
+ import { isNonNullable as isNonNullable3, safeParseJson } from "@dxos/util";
768
+ var ToolBlock = ({ blocks = [] }) => {
769
+ var _effect = _useSignals8();
770
+ try {
771
+ const { t } = useTranslation4(meta.id);
772
+ const getToolCaption = (tool, status) => {
773
+ if (!tool) {
774
+ return t("calling tool label");
775
+ }
776
+ return status?.message ?? tool.description ?? [
777
+ t("calling label"),
778
+ tool.name
779
+ ].join(" ");
780
+ };
781
+ const items = useMemo7(() => {
782
+ let lastToolCall;
783
+ const tools = [];
784
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
785
+ switch (block._tag) {
786
+ case "toolCall": {
787
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
788
+ return null;
789
+ }
790
+ const tool = tools.find((tool2) => tool2.name === block.name);
791
+ lastToolCall = {
792
+ tool,
793
+ block
794
+ };
795
+ return {
796
+ title: getToolCaption(lastToolCall?.tool),
797
+ content: {
798
+ ...block,
799
+ input: safeParseJson(block.input)
800
+ }
801
+ };
802
+ }
803
+ case "toolResult": {
804
+ if (block.error) {
805
+ return {
806
+ title: t("error label"),
807
+ content: block
808
+ };
809
+ }
810
+ const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
811
+ lastToolCall = void 0;
812
+ return {
813
+ title,
814
+ content: {
815
+ ...block,
816
+ result: safeParseJson(block.result)
817
+ }
818
+ };
819
+ }
820
+ case "summary": {
821
+ if (!lastToolCall) {
822
+ return null;
823
+ }
824
+ return {
825
+ title: t("summary label"),
826
+ content: block
827
+ };
828
+ }
829
+ }
830
+ }).filter(isNonNullable3);
831
+ }, [
832
+ blocks
833
+ ]);
834
+ if (!items.length) {
835
+ return null;
836
+ }
837
+ return /* @__PURE__ */ React6.createElement(ToolContainer, {
838
+ items
839
+ });
840
+ } finally {
841
+ _effect.f();
842
+ }
843
+ };
844
+ ToolBlock.displayName = "ToolBlock";
845
+ var ToolContainer = ({ items }) => {
846
+ var _effect = _useSignals8();
847
+ try {
848
+ const tabsRef = useRef2(null);
849
+ const [selected, setSelected] = useState10(0);
850
+ const [open, setOpen] = useState10(false);
851
+ useEffect4(() => {
852
+ if (open) {
853
+ tabsRef.current?.focus();
854
+ }
855
+ }, [
856
+ open
857
+ ]);
858
+ const handleSelect = (index) => {
859
+ setSelected(index);
860
+ };
861
+ const data = items[selected]?.content;
862
+ return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
863
+ classNames: chatMessagePanel,
864
+ open,
865
+ onChangeOpen: setOpen
866
+ }, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
867
+ classNames: chatMessagePanelHeader
868
+ }, /* @__PURE__ */ React6.createElement(TextCrawl, {
869
+ key: "status-roll",
870
+ lines: items.map((item) => item.title)
871
+ })), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
872
+ classNames: [
873
+ "grid grid-cols-[32px_1fr]",
874
+ chatMessagePanelContent
875
+ ]
876
+ }, /* @__PURE__ */ React6.createElement(NumericTabs, {
877
+ ref: tabsRef,
878
+ classNames: "p-1",
879
+ length: items.length,
880
+ selected,
881
+ onSelect: handleSelect
882
+ }), /* @__PURE__ */ React6.createElement(Json, {
883
+ data,
884
+ classNames: chatMessageJson,
885
+ replacer: {
886
+ maxDepth: 3,
887
+ maxArrayLen: 10,
888
+ maxStringLen: 128
889
+ }
890
+ })));
891
+ } finally {
892
+ _effect.f();
893
+ }
894
+ };
895
+
896
+ // src/components/ChatThread/registry.tsx
897
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
898
+ var Fallback = ({ _tag, ...props }) => {
899
+ var _effect = _useSignals9();
900
+ try {
901
+ return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
902
+ classNames: "rounded-sm"
903
+ }, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
904
+ classNames: "bg-groupSurface"
905
+ }, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
906
+ classNames: "bg-modalSurface"
907
+ }, /* @__PURE__ */ React7.createElement(Json2, {
908
+ classNames: "!p-2 text-sm",
909
+ data: props
910
+ })));
911
+ } finally {
912
+ _effect.f();
913
+ }
914
+ };
915
+ var componentRegistry = {
916
+ //
917
+ // Widgets
918
+ //
919
+ ["prompt"]: {
920
+ block: true,
921
+ factory: (props) => {
922
+ const text = getXmlTextChild(props.children);
923
+ return text ? new PromptWidget(text) : null;
924
+ }
925
+ },
926
+ ["reference"]: {
927
+ block: false,
928
+ factory: (props) => {
929
+ const text = getXmlTextChild(props.children);
930
+ return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
931
+ }
932
+ },
933
+ ["select"]: {
934
+ block: true,
935
+ factory: (props) => {
936
+ const options = props.children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
937
+ return options?.length ? new SelectWidget(options) : null;
938
+ }
939
+ },
940
+ ["suggestion"]: {
941
+ block: true,
942
+ factory: (props) => {
943
+ const text = getXmlTextChild(props.children);
944
+ return text ? new SuggestionWidget(text) : null;
945
+ }
946
+ },
947
+ ["summary"]: {
948
+ block: true,
949
+ factory: (props) => {
950
+ const text = getXmlTextChild(props.children);
951
+ return text ? new SummaryWidget(text) : null;
952
+ }
953
+ },
954
+ //
955
+ // React
956
+ //
957
+ ["toolCall"]: {
958
+ block: true,
959
+ Component: ToolBlock
960
+ },
961
+ ["toolResult"]: {
962
+ block: true,
963
+ Component: Fallback
964
+ },
965
+ ["toolkit"]: {
966
+ block: true,
967
+ Component: Fallback
968
+ },
969
+ //
970
+ // Fallback
971
+ //
972
+ ["json"]: {
973
+ block: true,
974
+ Component: Fallback
975
+ }
976
+ };
977
+ var blockToMarkdown = (context, message, block) => {
978
+ let str = _blockToMarkdown(context, message, block);
979
+ if (str && !block.pending) {
980
+ return str += "\n";
981
+ }
982
+ return str;
983
+ };
984
+ var _blockToMarkdown = (context, message, block) => {
985
+ log3("blockToMarkdown", {
986
+ block: JSON.stringify(block)
987
+ }, {
988
+ F: __dxlog_file3,
989
+ L: 125,
990
+ S: void 0,
991
+ C: (f, a) => f(...a)
992
+ });
993
+ switch (block._tag) {
994
+ case "text": {
995
+ if (message.sender.role === "user") {
996
+ return `
997
+ <prompt>${block.text}</prompt>
998
+ `;
999
+ } else {
1000
+ const text = block.text.trim();
1001
+ if (text.length > 0) {
1002
+ return text;
1003
+ }
1004
+ }
1005
+ break;
1006
+ }
1007
+ case "suggestion": {
1008
+ if (block.pending) {
1009
+ return;
1010
+ }
1011
+ return `<suggestion>${block.text}</suggestion>`;
1012
+ }
1013
+ case "select": {
1014
+ if (block.pending || block.options.length === 0) {
1015
+ return;
1016
+ }
1017
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1018
+ }
1019
+ // TODO(burdon): Need label.
1020
+ case "reference": {
1021
+ return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
1022
+ }
1023
+ // case 'toolkit': {
1024
+ // return `<toolkit />`;
1025
+ // }
1026
+ case "toolCall": {
1027
+ context.updateWidget(block.toolCallId, {
1028
+ blocks: [
1029
+ block
1030
+ ]
1031
+ });
1032
+ return `<toolCall id="${block.toolCallId}" />`;
1033
+ }
1034
+ case "toolResult": {
1035
+ context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
1036
+ blocks: [
1037
+ ...blocks,
1038
+ block
1039
+ ]
1040
+ }));
1041
+ break;
1042
+ }
1043
+ case "summary": {
1044
+ return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
1045
+ }
1046
+ // TODO(burdon): Need stable ID.
1047
+ default: {
1048
+ return `<json id="${message.id}">
1049
+ ${JSON.stringify(block)}
1050
+ </json>`;
1051
+ }
1052
+ }
1053
+ };
1054
+
1055
+ // src/components/ChatThread/sync.ts
1056
+ import { log as log4 } from "@dxos/log";
1057
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1058
+ var MessageThreadContext = class {
1059
+ _widgetState;
1060
+ constructor(_widgetState) {
1061
+ this._widgetState = _widgetState;
1062
+ }
1063
+ updateWidget(id, value) {
1064
+ this._widgetState?.updateWidget(id, value);
1065
+ }
1066
+ };
1067
+ var MessageSyncer = class {
1068
+ _model;
1069
+ _blockRenderer;
1070
+ _initialMessageId;
1071
+ _currentMessageIndex = 0;
1072
+ _currentBlockIndex = 0;
1073
+ _currentBlockContent;
1074
+ _context;
1075
+ constructor(_model, _blockRenderer) {
1076
+ this._model = _model;
1077
+ this._blockRenderer = _blockRenderer;
1078
+ this._context = new MessageThreadContext(this._model);
1079
+ }
1080
+ get context() {
1081
+ return this._context;
1082
+ }
1083
+ reset() {
1084
+ log4("reset", void 0, {
1085
+ F: __dxlog_file4,
1086
+ L: 58,
1087
+ S: this,
1088
+ C: (f, a) => f(...a)
1089
+ });
1090
+ this._initialMessageId = void 0;
1091
+ this._currentMessageIndex = 0;
1092
+ this._currentBlockIndex = 0;
1093
+ this._currentBlockContent = void 0;
1094
+ void this._model.reset("");
1095
+ }
1096
+ sync(messages) {
1097
+ log4("sync", {
1098
+ messages: messages.map((message) => message.blocks.length),
1099
+ currentMessageIndex: this._currentMessageIndex,
1100
+ currentBlockIndex: this._currentBlockIndex,
1101
+ currentBlockContent: this._currentBlockContent
1102
+ }, {
1103
+ F: __dxlog_file4,
1104
+ L: 67,
1105
+ S: this,
1106
+ C: (f, a) => f(...a)
1107
+ });
1108
+ if (this._initialMessageId !== messages[0]?.id) {
1109
+ this.reset();
1110
+ this._initialMessageId = messages[0]?.id;
1111
+ }
1112
+ let i = this._currentMessageIndex;
1113
+ for (const message of messages.slice(this._currentMessageIndex)) {
1114
+ if (i > this._currentMessageIndex) {
1115
+ this._currentBlockIndex = 0;
1116
+ }
1117
+ this._currentMessageIndex = i;
1118
+ let j = this._currentBlockIndex;
1119
+ for (const block of message.blocks.slice(this._currentBlockIndex)) {
1120
+ this._currentBlockIndex = j;
1121
+ const currentBlockContent = this._blockRenderer(this._context, message, block);
1122
+ if (currentBlockContent) {
1123
+ let content = "";
1124
+ if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
1125
+ content = currentBlockContent.slice(this._currentBlockContent.length);
1126
+ } else {
1127
+ content = currentBlockContent;
1128
+ }
1129
+ void this._model.append(content);
1130
+ this._currentBlockContent = currentBlockContent;
1131
+ log4("append", {
1132
+ message: i,
1133
+ block: j,
1134
+ content
1135
+ }, {
1136
+ F: __dxlog_file4,
1137
+ L: 99,
1138
+ S: this,
1139
+ C: (f, a) => f(...a)
1140
+ });
1141
+ }
1142
+ if (block.pending) {
1143
+ return;
1144
+ } else {
1145
+ this._currentBlockContent = void 0;
1146
+ this._currentBlockIndex++;
1147
+ }
1148
+ j++;
1149
+ }
1150
+ i++;
1151
+ }
1152
+ }
1153
+ };
1154
+
1155
+ // src/components/ChatThread/ChatThread.tsx
1156
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, overscroll, onEvent }, forwardedRef) => {
1157
+ var _effect = _useSignals10();
1158
+ try {
1159
+ const userHue = useMemo8(() => {
1160
+ return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1161
+ }, [
1162
+ identity
1163
+ ]);
1164
+ const [controller, setController] = useState11(null);
1165
+ useImperativeHandle(forwardedRef, () => controller ? controller : null, [
1166
+ controller
1167
+ ]);
1168
+ useEffect5(() => {
1169
+ controller?.scrollToBottom();
1170
+ }, [
1171
+ controller,
1172
+ error
1173
+ ]);
1174
+ const syncer = useMemo8(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1175
+ controller
1176
+ ]);
1177
+ useEffect5(() => {
1178
+ syncer?.sync(messages);
1179
+ }, [
1180
+ syncer,
1181
+ messages
1182
+ ]);
1183
+ const handleEvent = useCallback5((ev) => {
1184
+ switch (ev.type) {
1185
+ case "submit": {
1186
+ ev.value && onEvent?.({
1187
+ type: "submit",
1188
+ text: ev.value
1189
+ });
1190
+ break;
1191
+ }
1192
+ }
1193
+ }, [
1194
+ onEvent
1195
+ ]);
1196
+ return /* @__PURE__ */ React8.createElement("div", {
1197
+ className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
1198
+ style: {
1199
+ "--user-fill": `var(--dx-${userHue}Fill)`
1200
+ }
1201
+ }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1202
+ ref: setController,
1203
+ registry: componentRegistry,
1204
+ cursor,
1205
+ fadeIn,
1206
+ overscroll,
1207
+ onEvent: handleEvent
1208
+ }));
1209
+ } finally {
1210
+ _effect.f();
1211
+ }
1212
+ });
1213
+
1214
+ // src/components/Chat/Chat.tsx
1215
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
1216
+ var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1217
+ var _effect = _useSignals11();
1218
+ try {
1219
+ const [debug, setDebug] = useState12(false);
1220
+ const space = getSpace(chat);
1221
+ const queue = useQueue(chat?.queue.dxn);
1222
+ const pending = useRxValue(processor.messages);
1223
+ const streaming = useRxValue(processor.streaming);
1224
+ const lastPrompt = useRef3(void 0);
1225
+ const messages = useMemo9(() => {
1226
+ const queueMessages = queue?.objects?.filter(Obj5.instanceOf(DataType.Message)) ?? [];
1227
+ return Array2.dedupeWith([
1228
+ ...queueMessages,
1229
+ ...pending
1230
+ ], (a, b) => a.id === b.id);
1231
+ }, [
1232
+ queue?.objects,
1233
+ pending
1234
+ ]);
1235
+ const event = useMemo9(() => new Event(), []);
1236
+ useEffect6(() => {
1237
+ return event.on((ev) => {
1238
+ switch (ev.type) {
1239
+ case "toggle-debug": {
1240
+ setDebug((current) => !current);
1241
+ break;
1242
+ }
1243
+ case "submit": {
1244
+ const text = ev.text.trim();
1245
+ if (!streaming && text.length) {
1246
+ lastPrompt.current = ev.text;
1247
+ void processor.request({
1248
+ message: text
1249
+ });
1250
+ }
1251
+ break;
1252
+ }
1253
+ case "retry": {
1254
+ if (!streaming) {
1255
+ void processor.retry();
1256
+ }
1257
+ break;
1258
+ }
1259
+ case "cancel": {
1260
+ if (streaming) {
1261
+ void processor.cancel();
1262
+ if (lastPrompt.current) {
1263
+ event.emit({
1264
+ type: "update-prompt",
1265
+ text: lastPrompt.current
1266
+ });
1267
+ }
1268
+ }
1269
+ break;
1270
+ }
1271
+ default: {
1272
+ onEvent?.(ev);
1273
+ }
1274
+ }
1275
+ });
1276
+ }, [
1277
+ event,
1278
+ processor,
1279
+ streaming,
1280
+ onEvent
1281
+ ]);
1282
+ if (!space) {
1283
+ return null;
1284
+ }
1285
+ return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1286
+ debug,
1287
+ event,
1288
+ chat,
1289
+ space,
1290
+ messages,
1291
+ processor,
1292
+ ...props
1293
+ }, /* @__PURE__ */ React9.createElement("div", {
1294
+ role: "none",
1295
+ className: mx5("flex flex-col bs-full is-full", classNames)
1296
+ }, children));
1297
+ } finally {
1298
+ _effect.f();
1299
+ }
1300
+ };
1301
+ ChatRoot.displayName = "Chat.Root";
1302
+ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1303
+ var _effect = _useSignals11();
1304
+ try {
1305
+ const { t } = useTranslation5(meta.id);
1306
+ const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1307
+ const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
1308
+ const streaming = useRxValue(processor.streaming);
1309
+ const active = useRxValue(processor.active);
1310
+ const activeRef = useDynamicRef(active);
1311
+ const editorRef = useRef3(null);
1312
+ const [recordingState, setRecordingState] = useState12(false);
1313
+ useEffect6(() => {
1314
+ return event.on((event2) => {
1315
+ switch (event2.type) {
1316
+ case "update-prompt":
1317
+ if (!editorRef.current?.getText()?.length) {
1318
+ editorRef.current?.setText(event2.text);
1319
+ editorRef.current?.focus();
1320
+ }
1321
+ break;
1322
+ case "record-start":
1323
+ setRecordingState(true);
1324
+ break;
1325
+ case "record-stop":
1326
+ setRecordingState(false);
1327
+ break;
1328
+ }
1329
+ });
1330
+ }, [
1331
+ event
1332
+ ]);
1333
+ const { recording } = useVoiceInput({
1334
+ active: recordingState,
1335
+ onUpdate: (text) => {
1336
+ editorRef.current?.setText(text);
1337
+ editorRef.current?.focus();
1338
+ }
1339
+ });
1340
+ const referencesProvider = useReferencesProvider(space);
1341
+ const extensions = useMemo9(() => {
1342
+ return [
1343
+ referencesProvider && references({
1344
+ provider: referencesProvider
1345
+ }),
1346
+ Prec.highest(keymap.of([
1347
+ {
1348
+ key: "cmd-d",
1349
+ preventDefault: true,
1350
+ run: () => {
1351
+ event.emit({
1352
+ type: "toggle-debug"
1353
+ });
1354
+ return true;
1355
+ }
1356
+ },
1357
+ expandable && {
1358
+ key: "cmd-ArrowUp",
1359
+ preventDefault: true,
1360
+ run: () => {
1361
+ event.emit({
1362
+ type: "thread-open"
1363
+ });
1364
+ return true;
1365
+ }
1366
+ },
1367
+ expandable && {
1368
+ key: "cmd-ArrowDown",
1369
+ preventDefault: true,
1370
+ run: () => {
1371
+ event.emit({
1372
+ type: "thread-close"
1373
+ });
1374
+ return true;
1375
+ }
1376
+ }
1377
+ ].filter(isTruthy)))
1378
+ ].filter(isTruthy);
1379
+ }, [
1380
+ event,
1381
+ expandable,
1382
+ referencesProvider
1383
+ ]);
1384
+ const handleSubmit = useCallback6((text) => {
1385
+ if (!activeRef.current) {
1386
+ event.emit({
1387
+ type: "submit",
1388
+ text
1389
+ });
1390
+ return true;
1391
+ }
1392
+ }, [
1393
+ event
1394
+ ]);
1395
+ const handleEvent = useCallback6((ev) => {
1396
+ event.emit(ev);
1397
+ }, [
1398
+ event
1399
+ ]);
1400
+ return /* @__PURE__ */ React9.createElement("div", {
1401
+ role: "group",
1402
+ className: mx5("flex flex-col is-full density-fine", outline && [
1403
+ "p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
1404
+ ], classNames)
1405
+ }, /* @__PURE__ */ React9.createElement("div", {
1406
+ role: "none",
1407
+ className: "flex gap-2"
1408
+ }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1409
+ classNames: "p-1",
1410
+ preset,
1411
+ error,
1412
+ processing: streaming
1413
+ }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1414
+ ref: editorRef,
1415
+ autoFocus: true,
1416
+ lineWrapping: true,
1417
+ classNames: "col-span-2 pbs-0.5",
1418
+ placeholder: placeholder ?? t("prompt placeholder"),
1419
+ extensions,
1420
+ onSubmit: handleSubmit
1421
+ })), settings && /* @__PURE__ */ React9.createElement("div", {
1422
+ role: "none",
1423
+ className: "flex pbs-2 items-center"
1424
+ }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1425
+ space,
1426
+ blueprintRegistry: processor.blueprintRegistry,
1427
+ context: processor.context,
1428
+ preset,
1429
+ presets,
1430
+ onPresetChange
1431
+ }), /* @__PURE__ */ React9.createElement("div", {
1432
+ role: "none",
1433
+ className: "pli-cardSpacingChrome grow"
1434
+ }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1435
+ space,
1436
+ context: processor.context
1437
+ })), /* @__PURE__ */ React9.createElement(ChatActions, {
1438
+ classNames: "col-span-2",
1439
+ microphone: true,
1440
+ recording,
1441
+ processing: streaming,
1442
+ onEvent: handleEvent
1443
+ }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
1444
+ srOnly: true
1445
+ }, t("online switch label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
1446
+ classNames: "mis-2 mie-2",
1447
+ checked: online,
1448
+ onCheckedChange: onOnlineChange
1449
+ })))));
1450
+ } finally {
1451
+ _effect.f();
1452
+ }
1453
+ };
1454
+ ChatPrompt.displayName = "Chat.Prompt";
1455
+ var ChatThread2 = (props) => {
1456
+ var _effect = _useSignals11();
1457
+ try {
1458
+ const { event, messages, processor } = useChatContext(ChatThread2.displayName);
1459
+ const identity = useIdentity();
1460
+ const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
1461
+ const scrollerRef = useRef3(null);
1462
+ useEffect6(() => {
1463
+ return event.on((event2) => {
1464
+ switch (event2.type) {
1465
+ case "submit":
1466
+ case "scroll-to-bottom":
1467
+ scrollerRef.current?.scrollToBottom();
1468
+ break;
1469
+ }
1470
+ });
1471
+ }, [
1472
+ event
1473
+ ]);
1474
+ const handleEvent = useCallback6((ev) => {
1475
+ event.emit(ev);
1476
+ }, [
1477
+ event
1478
+ ]);
1479
+ if (!identity) {
1480
+ return null;
1481
+ }
1482
+ return /* @__PURE__ */ React9.createElement(ChatThread, {
1483
+ ...props,
1484
+ ref: scrollerRef,
1485
+ identity,
1486
+ messages,
1487
+ error,
1488
+ onEvent: handleEvent
1489
+ });
1490
+ } finally {
1491
+ _effect.f();
1492
+ }
1493
+ };
1494
+ ChatThread2.displayName = "Chat.Thread";
1495
+ var Chat = {
1496
+ Root: ChatRoot,
1497
+ Prompt: ChatPrompt,
1498
+ Thread: ChatThread2
1499
+ };
1500
+
1501
+ export {
1502
+ useBlueprintRegistry,
1503
+ useBlueprints,
1504
+ useActiveBlueprints,
1505
+ useBlueprintHandlers,
1506
+ useChatProcessor,
1507
+ useChatServices,
1508
+ useContextBinder,
1509
+ useContextObjects,
1510
+ useFlush,
1511
+ useItemTypes,
1512
+ useOnline,
1513
+ usePresets,
1514
+ useReferencesProvider,
1515
+ ChatContextProvider,
1516
+ useChatContext,
1517
+ Chat
1518
+ };
1519
+ //# sourceMappingURL=chunk-357IHWQL.mjs.map