@dxos/plugin-assistant 0.8.4-main.406dc2a → 0.8.4-main.548089c

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 (318) hide show
  1. package/dist/lib/browser/BlueprintArticle-UGPRZRBG.mjs +36 -0
  2. package/dist/lib/browser/BlueprintArticle-UGPRZRBG.mjs.map +7 -0
  3. package/dist/lib/browser/{ChatCompanion-BDZ55ZRF.mjs → ChatCompanion-BZGANK56.mjs} +58 -50
  4. package/dist/lib/browser/ChatCompanion-BZGANK56.mjs.map +7 -0
  5. package/dist/lib/browser/{ChatContainer-RYGNN73X.mjs → ChatContainer-OG6Y3NHI.mjs} +22 -18
  6. package/dist/lib/browser/ChatContainer-OG6Y3NHI.mjs.map +7 -0
  7. package/dist/lib/browser/{ChatDialog-MVHH2U66.mjs → ChatDialog-NKNUCC3R.mjs} +8 -4
  8. package/dist/lib/browser/ChatDialog-NKNUCC3R.mjs.map +7 -0
  9. package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs +89 -0
  10. package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs.map +7 -0
  11. package/dist/lib/browser/{app-graph-builder-2U7SLCRX.mjs → app-graph-builder-CJ5ZUG5I.mjs} +62 -17
  12. package/dist/lib/browser/app-graph-builder-CJ5ZUG5I.mjs.map +7 -0
  13. package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs → blueprint-definition-5FT5JGPY.mjs} +4 -4
  14. package/dist/lib/browser/chunk-AO6XHMQ7.mjs +262 -0
  15. package/dist/lib/browser/chunk-AO6XHMQ7.mjs.map +7 -0
  16. package/dist/lib/browser/{chunk-FP56WB24.mjs → chunk-BNTPFZ7O.mjs} +30 -13
  17. package/dist/lib/browser/chunk-BNTPFZ7O.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs +335 -0
  19. package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-2CE2KPKZ.mjs → chunk-IXIIS4QA.mjs} +37 -36
  21. package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +7 -0
  22. package/dist/lib/browser/{chunk-5EGXHCAZ.mjs → chunk-LRE4VEZV.mjs} +2 -2
  23. package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
  24. package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
  25. package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
  26. package/dist/lib/browser/{chunk-WRJGOT5P.mjs → chunk-Y4C2CMME.mjs} +772 -620
  27. package/dist/lib/browser/chunk-Y4C2CMME.mjs.map +7 -0
  28. package/dist/lib/browser/index.mjs +78 -62
  29. package/dist/lib/browser/index.mjs.map +3 -3
  30. package/dist/lib/browser/{intent-resolver-3GOJMBXJ.mjs → intent-resolver-42A4SLIQ.mjs} +49 -20
  31. package/dist/lib/browser/intent-resolver-42A4SLIQ.mjs.map +7 -0
  32. package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs → local-model-resolver-34MVHRKD.mjs} +2 -2
  33. package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs.map → local-model-resolver-34MVHRKD.mjs.map} +2 -2
  34. package/dist/lib/browser/meta.json +1 -1
  35. package/dist/lib/browser/{react-surface-FTKCE6GG.mjs → react-surface-TULJF2Y3.mjs} +22 -31
  36. package/dist/lib/browser/react-surface-TULJF2Y3.mjs.map +7 -0
  37. package/dist/lib/browser/{settings-HBF32KV6.mjs → settings-NYJGNQ5I.mjs} +3 -3
  38. package/dist/lib/browser/{state-LXTS54DI.mjs → state-GG7Z3NB7.mjs} +7 -3
  39. package/dist/lib/browser/{state-LXTS54DI.mjs.map → state-GG7Z3NB7.mjs.map} +3 -3
  40. package/dist/lib/browser/toolkit-VYDAWNE4.mjs +17 -0
  41. package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +7 -0
  42. package/dist/lib/browser/types/index.mjs +2 -2
  43. package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs +37 -0
  44. package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs.map +7 -0
  45. package/dist/lib/node-esm/{ChatCompanion-XFNXVZIP.mjs → ChatCompanion-LKWZTSCI.mjs} +58 -50
  46. package/dist/lib/node-esm/ChatCompanion-LKWZTSCI.mjs.map +7 -0
  47. package/dist/lib/node-esm/{ChatContainer-UTJGCQXF.mjs → ChatContainer-HGAAKVB3.mjs} +22 -18
  48. package/dist/lib/node-esm/ChatContainer-HGAAKVB3.mjs.map +7 -0
  49. package/dist/lib/node-esm/{ChatDialog-QEYZ4IOV.mjs → ChatDialog-QA545GGB.mjs} +8 -4
  50. package/dist/lib/node-esm/ChatDialog-QA545GGB.mjs.map +7 -0
  51. package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs +90 -0
  52. package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs.map +7 -0
  53. package/dist/lib/node-esm/{app-graph-builder-OKNLR7H2.mjs → app-graph-builder-XPQLG755.mjs} +62 -17
  54. package/dist/lib/node-esm/app-graph-builder-XPQLG755.mjs.map +7 -0
  55. package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs → blueprint-definition-XW6QQVLV.mjs} +4 -4
  56. package/dist/lib/node-esm/chunk-3YVWS6OI.mjs +264 -0
  57. package/dist/lib/node-esm/chunk-3YVWS6OI.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-TNR46C3L.mjs → chunk-AB74FOA2.mjs} +30 -13
  59. package/dist/lib/node-esm/chunk-AB74FOA2.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs +336 -0
  61. package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs.map +7 -0
  62. package/dist/lib/node-esm/{chunk-U2NYUS2N.mjs → chunk-UXTUHH24.mjs} +37 -36
  63. package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +7 -0
  64. package/dist/lib/node-esm/{chunk-UFKLCEAE.mjs → chunk-VI6S3Q5H.mjs} +772 -620
  65. package/dist/lib/node-esm/chunk-VI6S3Q5H.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-73ABYRYX.mjs → chunk-WE6KTH72.mjs} +7 -2
  67. package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-XQGWSZ4T.mjs → chunk-YWFWT57N.mjs} +2 -2
  69. package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
  70. package/dist/lib/node-esm/index.mjs +78 -62
  71. package/dist/lib/node-esm/index.mjs.map +3 -3
  72. package/dist/lib/node-esm/{intent-resolver-6XLVTRDJ.mjs → intent-resolver-Y6I3IDSI.mjs} +49 -20
  73. package/dist/lib/node-esm/intent-resolver-Y6I3IDSI.mjs.map +7 -0
  74. package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs → local-model-resolver-TP2NTSAX.mjs} +2 -2
  75. package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs.map → local-model-resolver-TP2NTSAX.mjs.map} +2 -2
  76. package/dist/lib/node-esm/meta.json +1 -1
  77. package/dist/lib/node-esm/{react-surface-K7ZXQLAP.mjs → react-surface-C4WY3WRR.mjs} +22 -31
  78. package/dist/lib/node-esm/react-surface-C4WY3WRR.mjs.map +7 -0
  79. package/dist/lib/node-esm/{settings-CWP6MTWP.mjs → settings-RRHYI5KO.mjs} +3 -3
  80. package/dist/lib/node-esm/{state-BO6GUFLB.mjs → state-FSUHFMDM.mjs} +7 -3
  81. package/dist/lib/node-esm/{state-BO6GUFLB.mjs.map → state-FSUHFMDM.mjs.map} +3 -3
  82. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +18 -0
  83. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +7 -0
  84. package/dist/lib/node-esm/types/index.mjs +2 -2
  85. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  86. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
  88. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/capabilities.d.ts +2 -3
  90. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  92. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  94. package/dist/types/src/capabilities/toolkit.d.ts +1 -1
  95. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
  96. package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
  97. package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
  98. package/dist/types/src/components/Chat/Chat.d.ts +18 -8
  99. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  100. package/dist/types/src/components/Chat/events.d.ts +4 -0
  101. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  102. package/dist/types/src/components/ChatCompanion.d.ts +2 -2
  103. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
  104. package/dist/types/src/components/ChatContainer.d.ts +7 -4
  105. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  106. package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
  107. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  108. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  109. package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -9
  110. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  111. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +123 -70
  112. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  113. package/dist/types/src/components/ChatThread/reducers.d.ts +5 -5
  114. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -1
  115. package/dist/types/src/components/ChatThread/sync.d.ts +12 -6
  116. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  117. package/dist/types/src/components/PromptArticle.d.ts +7 -0
  118. package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
  119. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
  120. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  121. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +111 -61
  122. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  123. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +111 -61
  124. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  125. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  126. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  127. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  128. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  129. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  130. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +9 -7
  131. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  132. package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -2
  133. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  134. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +111 -60
  135. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  136. package/dist/types/src/components/index.d.ts +4 -9
  137. package/dist/types/src/components/index.d.ts.map +1 -1
  138. package/dist/types/src/functions/index.d.ts +2 -2
  139. package/dist/types/src/functions/index.d.ts.map +1 -1
  140. package/dist/types/src/functions/{list.d.ts → object-list.d.ts} +1 -1
  141. package/dist/types/src/functions/object-list.d.ts.map +1 -0
  142. package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +1 -1
  143. package/dist/types/src/functions/object-load.d.ts.map +1 -0
  144. package/dist/types/src/hooks/index.d.ts +1 -0
  145. package/dist/types/src/hooks/index.d.ts.map +1 -1
  146. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  147. package/dist/types/src/hooks/useChatProcessor.d.ts +3 -1
  148. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  149. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  150. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  151. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  152. package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
  153. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  154. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  155. package/dist/types/src/meta.d.ts.map +1 -1
  156. package/dist/types/src/processor/index.d.ts +1 -0
  157. package/dist/types/src/processor/index.d.ts.map +1 -1
  158. package/dist/types/src/processor/processor.d.ts +6 -6
  159. package/dist/types/src/processor/processor.d.ts.map +1 -1
  160. package/dist/types/src/processor/update-name.d.ts +10 -0
  161. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  162. package/dist/types/src/queue-logger.d.ts.map +1 -1
  163. package/dist/types/src/testing/test-generator.d.ts +2 -2
  164. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  165. package/dist/types/src/translations.d.ts +239 -26
  166. package/dist/types/src/translations.d.ts.map +1 -1
  167. package/dist/types/src/types/Assistant.d.ts +0 -3
  168. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  169. package/dist/types/src/types/AssistantAction.d.ts +29 -4
  170. package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
  171. package/dist/types/src/types/service.d.ts +9 -6
  172. package/dist/types/src/types/service.d.ts.map +1 -1
  173. package/dist/types/tsconfig.tsbuildinfo +1 -1
  174. package/package.json +78 -73
  175. package/src/AssistantPlugin.tsx +20 -2
  176. package/src/capabilities/app-graph-builder.ts +62 -15
  177. package/src/capabilities/blueprint-definition.ts +38 -36
  178. package/src/capabilities/capabilities.ts +2 -3
  179. package/src/capabilities/intent-resolver.ts +66 -15
  180. package/src/capabilities/local-model-resolver.ts +1 -1
  181. package/src/capabilities/react-surface.tsx +16 -20
  182. package/src/capabilities/state.ts +2 -0
  183. package/src/capabilities/toolkit.ts +9 -160
  184. package/src/components/BlueprintArticle.tsx +29 -0
  185. package/src/components/Chat/Chat.tsx +112 -58
  186. package/src/components/Chat/events.ts +6 -0
  187. package/src/components/ChatCompanion.tsx +62 -43
  188. package/src/components/ChatContainer.tsx +27 -17
  189. package/src/components/ChatDialog.tsx +9 -2
  190. package/src/components/ChatProgress/ChatProgress.tsx +1 -1
  191. package/src/components/ChatPrompt/ChatActions.tsx +2 -4
  192. package/src/components/ChatPrompt/ChatOptions.tsx +26 -23
  193. package/src/components/ChatPrompt/ChatReferences.tsx +2 -2
  194. package/src/components/ChatThread/ChatThread.stories.tsx +45 -26
  195. package/src/components/ChatThread/ChatThread.tsx +25 -35
  196. package/src/components/ChatThread/reducers.ts +6 -6
  197. package/src/components/ChatThread/registry.tsx +23 -33
  198. package/src/components/ChatThread/sync.test.ts +20 -12
  199. package/src/components/ChatThread/sync.ts +47 -12
  200. package/src/components/ChatThread/testing/thread.md +37 -0
  201. package/src/components/PromptArticle.tsx +85 -0
  202. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +14 -4
  203. package/src/components/TemplateEditor/TemplateEditor.tsx +17 -8
  204. package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
  205. package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
  206. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +269 -0
  207. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  208. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  209. package/src/components/ToolBlock/ToolBlock.tsx +33 -42
  210. package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
  211. package/src/components/Toolbox/Toolbox.tsx +5 -5
  212. package/src/components/index.ts +2 -5
  213. package/src/functions/analysis.ts +1 -1
  214. package/src/functions/index.ts +2 -2
  215. package/src/functions/{list.ts → object-list.ts} +4 -4
  216. package/src/functions/{load.ts → object-load.ts} +3 -4
  217. package/src/hooks/index.ts +1 -0
  218. package/src/hooks/useBlueprintRegistry.ts +2 -1
  219. package/src/hooks/useChatProcessor.ts +12 -12
  220. package/src/hooks/useChatServices.ts +7 -5
  221. package/src/hooks/useChatToolbarActions.ts +122 -0
  222. package/src/hooks/useContextBinder.ts +6 -6
  223. package/src/hooks/useReferencesProvider.ts +2 -1
  224. package/src/meta.ts +6 -1
  225. package/src/processor/index.ts +1 -0
  226. package/src/processor/presets.ts +1 -1
  227. package/src/processor/processor.test.ts +8 -18
  228. package/src/processor/processor.ts +14 -39
  229. package/src/processor/update-name.ts +56 -0
  230. package/src/queue-logger.ts +4 -8
  231. package/src/testing/test-generator.ts +10 -10
  232. package/src/translations.ts +24 -16
  233. package/src/types/Assistant.ts +4 -5
  234. package/src/types/AssistantAction.ts +21 -4
  235. package/src/types/service.ts +2 -2
  236. package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs +0 -28
  237. package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs.map +0 -7
  238. package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +0 -7
  239. package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +0 -7
  240. package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +0 -7
  241. package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs +0 -150
  242. package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +0 -7
  243. package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +0 -7
  244. package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +0 -7
  245. package/dist/lib/browser/chunk-43I2LR6O.mjs +0 -216
  246. package/dist/lib/browser/chunk-43I2LR6O.mjs.map +0 -7
  247. package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +0 -7
  248. package/dist/lib/browser/chunk-5RICKAMN.mjs +0 -18
  249. package/dist/lib/browser/chunk-5RICKAMN.mjs.map +0 -7
  250. package/dist/lib/browser/chunk-CQ7UHYTT.mjs +0 -296
  251. package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +0 -7
  252. package/dist/lib/browser/chunk-FP56WB24.mjs.map +0 -7
  253. package/dist/lib/browser/chunk-JZRZVB2A.mjs +0 -170
  254. package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +0 -7
  255. package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +0 -7
  256. package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +0 -7
  257. package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +0 -7
  258. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +0 -199
  259. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +0 -7
  260. package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs +0 -29
  261. package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs.map +0 -7
  262. package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +0 -7
  263. package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +0 -7
  264. package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +0 -7
  265. package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs +0 -151
  266. package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +0 -7
  267. package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +0 -7
  268. package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +0 -7
  269. package/dist/lib/node-esm/chunk-DSE2IILK.mjs +0 -217
  270. package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +0 -7
  271. package/dist/lib/node-esm/chunk-E2WXZND7.mjs +0 -297
  272. package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +0 -7
  273. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +0 -171
  274. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +0 -7
  275. package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +0 -7
  276. package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +0 -7
  277. package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +0 -7
  278. package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +0 -7
  279. package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +0 -7
  280. package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +0 -7
  281. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +0 -200
  282. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +0 -7
  283. package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
  284. package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
  285. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  286. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  287. package/dist/types/src/components/SequenceContainer.d.ts +0 -8
  288. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  289. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  290. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  291. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -269
  292. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  293. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  294. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  295. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +0 -1
  296. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -5
  297. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  298. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  299. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  300. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +0 -11
  301. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
  302. package/dist/types/src/functions/list.d.ts.map +0 -1
  303. package/dist/types/src/functions/load.d.ts.map +0 -1
  304. package/src/components/BlueprintContainer.tsx +0 -24
  305. package/src/components/PromptSettings.tsx +0 -90
  306. package/src/components/SequenceContainer.tsx +0 -131
  307. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -35
  308. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  309. package/src/components/SequenceEditor/index.ts +0 -5
  310. package/src/components/TemplateEditor/handlebars-extension.ts +0 -165
  311. package/src/components/Toolbar/Toolbar.tsx +0 -21
  312. package/src/components/Toolbar/index.ts +0 -5
  313. package/src/components/Toolbar/useChatToolbarActions.ts +0 -126
  314. /package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs.map → blueprint-definition-5FT5JGPY.mjs.map} +0 -0
  315. /package/dist/lib/browser/{settings-HBF32KV6.mjs.map → settings-NYJGNQ5I.mjs.map} +0 -0
  316. /package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs.map → blueprint-definition-XW6QQVLV.mjs.map} +0 -0
  317. /package/dist/lib/node-esm/{settings-CWP6MTWP.mjs.map → settings-RRHYI5KO.mjs.map} +0 -0
  318. /package/dist/types/src/components/TemplateEditor/{handlebars-extension.d.ts → extensions/handlebars-extension.d.ts} +0 -0
@@ -1,13 +1,97 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ AiChatProcessor,
4
+ AiServicePresets
5
+ } from "./chunk-3YVWS6OI.mjs";
6
+ import {
7
+ AssistantAction_exports,
8
+ Assistant_exports,
9
+ LLM_PROVIDERS,
10
+ ServiceType
11
+ } from "./chunk-AB74FOA2.mjs";
2
12
  import {
3
13
  meta
4
- } from "./chunk-73ABYRYX.mjs";
14
+ } from "./chunk-WE6KTH72.mjs";
5
15
 
6
- // src/hooks/useBlueprintRegistry.ts
16
+ // src/components/AssistantSettings/AssistantSettings.tsx
7
17
  import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
18
+ import React from "react";
19
+ import { DEFAULT_EDGE_MODELS, DEFAULT_OLLAMA_MODELS } from "@dxos/ai";
20
+ import { Input, Select, useTranslation } from "@dxos/react-ui";
21
+ import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from "@dxos/react-ui-form";
22
+ var DEFAULT_VALUE = "__default";
23
+ var LLM_PROVIDER_LABELS = {
24
+ edge: "DXOS",
25
+ ollama: "Ollama",
26
+ lmstudio: "LM Studio"
27
+ };
28
+ var AssistantSettings = ({ settings }) => {
29
+ var _effect = _useSignals();
30
+ try {
31
+ const { t } = useTranslation(meta.id);
32
+ return /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
33
+ title: t("settings title", {
34
+ ns: meta.id
35
+ })
36
+ }, /* @__PURE__ */ React.createElement(ControlGroup, null, /* @__PURE__ */ React.createElement(ControlItemInput, {
37
+ title: t("settings custom prompts label")
38
+ }, /* @__PURE__ */ React.createElement(Input.Switch, {
39
+ checked: !!settings.customPrompts,
40
+ onCheckedChange: (checked) => settings.customPrompts = checked
41
+ })), /* @__PURE__ */ React.createElement(ControlItemInput, {
42
+ title: t("settings llm provider label")
43
+ }, /* @__PURE__ */ React.createElement(Select.Root, {
44
+ value: settings.llmProvider ?? "edge",
45
+ onValueChange: (value) => {
46
+ settings.llmProvider = value === DEFAULT_VALUE ? void 0 : value;
47
+ }
48
+ }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
49
+ placeholder: t("settings llm provider label")
50
+ }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
51
+ value: DEFAULT_VALUE
52
+ }, t("settings default label")), LLM_PROVIDERS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
53
+ key: model,
54
+ value: model
55
+ }, LLM_PROVIDER_LABELS[model]))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))), /* @__PURE__ */ React.createElement(ControlItemInput, {
56
+ title: t("settings edge llm model label")
57
+ }, /* @__PURE__ */ React.createElement(Select.Root, {
58
+ value: settings.edgeModel ?? DEFAULT_VALUE,
59
+ onValueChange: (value) => {
60
+ settings.edgeModel = value === DEFAULT_VALUE ? void 0 : value;
61
+ }
62
+ }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
63
+ placeholder: t("settings default llm model label")
64
+ }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
65
+ value: DEFAULT_VALUE
66
+ }, t("settings default label")), DEFAULT_EDGE_MODELS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
67
+ key: model,
68
+ value: model
69
+ }, model))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))), /* @__PURE__ */ React.createElement(ControlItemInput, {
70
+ title: t("settings ollama llm model label")
71
+ }, /* @__PURE__ */ React.createElement(Select.Root, {
72
+ value: settings.ollamaModel ?? DEFAULT_VALUE,
73
+ onValueChange: (value) => {
74
+ settings.ollamaModel = value === DEFAULT_VALUE ? void 0 : value;
75
+ }
76
+ }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
77
+ placeholder: t("settings default llm model label")
78
+ }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
79
+ value: DEFAULT_VALUE
80
+ }, t("settings default label")), DEFAULT_OLLAMA_MODELS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
81
+ key: model,
82
+ value: model
83
+ }, model))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))))));
84
+ } finally {
85
+ _effect.f();
86
+ }
87
+ };
88
+
89
+ // src/hooks/useBlueprintRegistry.ts
90
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
8
91
  import { useSignalEffect } from "@preact/signals-react";
9
92
  import { useCallback, useMemo, useState } from "react";
10
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
93
+ import { Capabilities } from "@dxos/app-framework";
94
+ import { useCapabilities } from "@dxos/app-framework/react";
11
95
  import { Blueprint } from "@dxos/blueprints";
12
96
  import { Filter, Obj, Ref } from "@dxos/echo";
13
97
  import { useQuery } from "@dxos/react-client/echo";
@@ -36,7 +120,7 @@ var useBlueprints = ({ blueprintRegistry, space }) => {
36
120
  ]);
37
121
  };
38
122
  var useActiveBlueprints = ({ context }) => {
39
- var _effect = _useSignals();
123
+ var _effect = _useSignals2();
40
124
  try {
41
125
  const [active, setActive] = useState(/* @__PURE__ */ new Map());
42
126
  useSignalEffect(() => {
@@ -92,303 +176,42 @@ var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
92
176
  };
93
177
 
94
178
  // src/hooks/useChatProcessor.ts
95
- import { RegistryContext } from "@effect-rx/rx-react";
179
+ import { RegistryContext } from "@effect-atom/atom-react";
96
180
  import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
97
181
  import { AiConversation } from "@dxos/assistant";
98
- import { log as log2 } from "@dxos/log";
99
- import { useAsyncEffect } from "@dxos/react-ui";
100
-
101
- // src/processor/presets.ts
102
- import * as Schema from "effect/Schema";
103
- var ModelProviders = [
104
- "dxos-local",
105
- "dxos-remote",
106
- "lm-studio"
107
- ];
108
- var ModelProvider = Schema.Literal(...ModelProviders);
109
- var createModelLabel = (model) => {
110
- const parts = model.split("/");
111
- return parts[parts.length - 1];
112
- };
113
- var AiServicePresets = [
114
- {
115
- provider: "dxos-remote",
116
- model: "@anthropic/claude-opus-4-0"
117
- },
118
- {
119
- provider: "dxos-remote",
120
- model: "@anthropic/claude-sonnet-4-0"
121
- },
122
- {
123
- provider: "dxos-remote",
124
- model: "@anthropic/claude-3-5-haiku-20241022"
125
- },
126
- {
127
- provider: "lm-studio",
128
- model: "@google/gemma-3-27b"
129
- },
130
- {
131
- provider: "lm-studio",
132
- model: "@mlx-community/llama-3.2-3b-instruct"
133
- },
134
- {
135
- model: "deepseek-r1:latest",
136
- provider: "dxos-local"
137
- }
138
- ].map(({ model, provider }, i) => ({
139
- id: `preset-${i}`,
140
- provider,
141
- model,
142
- label: createModelLabel(model)
143
- }));
144
-
145
- // src/processor/processor.ts
146
- import { Registry, Rx } from "@effect-rx/rx-react";
147
- import * as Cause from "effect/Cause";
148
- import * as Effect from "effect/Effect";
149
- import * as Exit from "effect/Exit";
150
- import * as Fiber from "effect/Fiber";
151
- import * as Option from "effect/Option";
152
- import * as Runtime from "effect/Runtime";
153
- import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
154
- import { AiSession, ArtifactDiffResolver, GenerationObserver, createSystemPrompt } from "@dxos/assistant";
155
- import { Obj as Obj2 } from "@dxos/echo";
156
- import { throwCause } from "@dxos/effect";
157
182
  import { log } from "@dxos/log";
158
- import { DataType } from "@dxos/schema";
159
- import { trim } from "@dxos/util";
160
- function _define_property(obj, key, value) {
161
- if (key in obj) {
162
- Object.defineProperty(obj, key, {
163
- value,
164
- enumerable: true,
165
- configurable: true,
166
- writable: true
167
- });
168
- } else {
169
- obj[key] = value;
170
- }
171
- return obj;
172
- }
173
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
174
- var defaultOptions = {
175
- model: DEFAULT_EDGE_MODEL
176
- };
177
- var AiChatProcessor = class {
178
- get context() {
179
- return this._conversation.context;
180
- }
181
- get conversation() {
182
- return this._conversation;
183
- }
184
- get blueprintRegistry() {
185
- return this._options.blueprintRegistry;
186
- }
187
- /**
188
- * Initiates a new request.
189
- */
190
- async request(requestParam) {
191
- if (this._fiber) {
192
- await this.cancel();
193
- }
194
- try {
195
- this._lastRequest = requestParam;
196
- this._rx.set(this.error, Option.none());
197
- this._rx.set(this.active, true);
198
- const request = this._conversation.createRequest({
199
- system: this._options.system,
200
- prompt: requestParam.message,
201
- observer: this._observer
202
- });
203
- const runtime2 = await this._services();
204
- this._fiber = request.pipe(
205
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
206
- // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
207
- Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
208
- Effect.asVoid,
209
- Runtime.runFork(runtime2)
210
- );
211
- const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
212
- if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
213
- throwCause(response.cause);
214
- }
215
- this._rx.set(this.error, Option.none());
216
- this._lastRequest = void 0;
217
- this._fiber = void 0;
218
- } catch (error) {
219
- log.error("request failed", {
220
- error
221
- }, {
222
- F: __dxlog_file,
223
- L: 187,
224
- S: this,
225
- C: (f, a) => f(...a)
226
- });
227
- this._rx.set(this.error, Option.some(new Error("AI service error", {
228
- cause: error
229
- })));
230
- } finally {
231
- this._fiber = void 0;
232
- this._rx.set(this.active, false);
233
- }
234
- }
235
- /**
236
- * Cancels the current request.
237
- */
238
- async cancel() {
239
- await Effect.runPromise(Effect.gen(this, function* () {
240
- if (this._fiber) {
241
- yield* this._fiber.pipe(Fiber.interrupt);
242
- }
243
- }));
244
- this._fiber = void 0;
245
- this._rx.set(this.active, false);
246
- }
247
- /**
248
- * Retry last failed request.
249
- */
250
- async retry() {
251
- if (this._lastRequest) {
252
- return this.request(this._lastRequest);
253
- }
254
- }
255
- /**
256
- * Update the current chat's name.
257
- */
258
- async updateName(chat) {
259
- const runtime2 = await this._services();
260
- const system = trim`
261
- It is extremely important that you respond only with the title and nothing else.
262
- If you cannot do this effectively respond with "New Chat".
263
- `;
264
- const history = await this._conversation.getHistory();
265
- const fiber = Effect.gen(this, function* () {
266
- const session = new AiSession();
267
- return yield* session.run({
268
- system,
269
- prompt: "Suggest a name for this chat",
270
- history
271
- });
272
- }).pipe(
273
- // TODO(burdon): Use simpler model.
274
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
275
- Effect.tap((messages) => {
276
- const message = messages.find((message2) => message2.sender.role === "assistant");
277
- const title = message?.blocks.find((b) => b._tag === "text")?.text;
278
- if (title) {
279
- chat.name = title;
280
- }
281
- }),
282
- Runtime.runFork(runtime2)
283
- );
284
- const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
285
- if (!Exit.isSuccess(response)) {
286
- throwCause(response.cause);
287
- }
288
- }
289
- constructor(_conversation, _services, _options = defaultOptions) {
290
- _define_property(this, "_conversation", void 0);
291
- _define_property(this, "_services", void 0);
292
- _define_property(this, "_options", void 0);
293
- _define_property(this, "_rx", void 0);
294
- _define_property(this, "_observer", void 0);
295
- _define_property(this, "_fiber", void 0);
296
- _define_property(this, "_lastRequest", void 0);
297
- _define_property(this, "_pending", void 0);
298
- _define_property(this, "_streaming", void 0);
299
- _define_property(this, "streaming", void 0);
300
- _define_property(this, "active", void 0);
301
- _define_property(this, "messages", void 0);
302
- _define_property(this, "error", void 0);
303
- _define_property(this, "_artifactDiffResolver", void 0);
304
- _define_property(this, "_onMessage", void 0);
305
- _define_property(this, "_onBlock", void 0);
306
- this._conversation = _conversation;
307
- this._services = _services;
308
- this._options = _options;
309
- this._pending = Rx.make([]);
310
- this._streaming = Rx.make(Option.none());
311
- this.streaming = Rx.make((get) => Option.isSome(get(this._streaming)));
312
- this.active = Rx.make(false);
313
- this.messages = Rx.make((get) => Option.match(get(this._streaming), {
314
- onNone: () => get(this._pending),
315
- onSome: (streaming) => [
316
- ...get(this._pending),
317
- streaming
318
- ]
319
- }));
320
- this.error = Rx.make(Option.none());
321
- this._artifactDiffResolver = {
322
- resolve: async (_artifacts) => {
323
- const versions = /* @__PURE__ */ new Map();
324
- return versions;
325
- }
326
- };
327
- this._onMessage = Effect.fn((function* (message) {
328
- this._rx.set(this._streaming, Option.none());
329
- this._rx.update(this._pending, (pending) => [
330
- ...pending,
331
- message
332
- ]);
333
- }).bind(this));
334
- this._onBlock = Effect.fn((function* (block) {
335
- this._rx.update(this._streaming, (streaming) => {
336
- const blocks = streaming.pipe(Option.map((streaming2) => streaming2.blocks.filter((b) => !b.pending)), Option.getOrElse(() => []));
337
- return Option.some(Obj2.make(DataType.Message, {
338
- created: (/* @__PURE__ */ new Date()).toISOString(),
339
- sender: {
340
- role: "assistant"
341
- },
342
- blocks: [
343
- ...blocks,
344
- block
345
- ]
346
- }));
347
- });
348
- }).bind(this));
349
- this._rx = this._options.observableRegistry ?? Registry.make();
350
- this._observer = GenerationObserver.make({
351
- onBlock: this._onBlock,
352
- onMessage: this._onMessage
353
- });
354
- if (this._options.model && !this._options.system) {
355
- const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
356
- this._options.system = createSystemPrompt(capabilities);
357
- }
358
- }
359
- };
360
-
361
- // src/hooks/useChatProcessor.ts
362
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
363
- var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
183
+ import { useAsyncEffect } from "@dxos/react-ui";
184
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
185
+ var useChatProcessor = ({ space, chat, preset, services, blueprintRegistry, settings }) => {
364
186
  const observableRegistry = useContext(RegistryContext);
365
187
  const [conversation, setConversation] = useState2();
366
188
  useAsyncEffect(async () => {
367
- if (!chat?.queue.target) {
189
+ if (!space || !chat) {
368
190
  return;
369
191
  }
370
- const conversation2 = new AiConversation({
371
- queue: chat.queue.target
372
- });
192
+ const queue = space.queues.get(chat.queue.dxn);
193
+ const conversation2 = new AiConversation(queue);
373
194
  await conversation2.open();
374
195
  setConversation(conversation2);
375
196
  return () => {
376
197
  void conversation2.close();
198
+ setConversation(void 0);
377
199
  };
378
200
  }, [
379
- chat?.queue.target
201
+ space,
202
+ chat?.queue.dxn.toString()
380
203
  ]);
381
204
  const processor = useMemo2(() => {
382
205
  if (!services || !conversation) {
383
206
  return void 0;
384
207
  }
385
- log2("creating processor", {
208
+ log("creating processor", {
386
209
  preset,
387
210
  model: preset?.model,
388
211
  settings
389
212
  }, {
390
- F: __dxlog_file2,
391
- L: 60,
213
+ F: __dxlog_file,
214
+ L: 65,
392
215
  S: void 0,
393
216
  C: (f, a) => f(...a)
394
217
  });
@@ -407,20 +230,21 @@ var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings })
407
230
  };
408
231
 
409
232
  // src/hooks/useChatServices.ts
410
- import * as Effect2 from "effect/Effect";
233
+ import * as Effect from "effect/Effect";
411
234
  import { useMemo as useMemo3 } from "react";
412
- import { useCapability } from "@dxos/app-framework";
235
+ import { useCapability } from "@dxos/app-framework/react";
413
236
  import { TracingService } from "@dxos/functions";
237
+ import { TracingServiceExt } from "@dxos/functions-runtime";
414
238
  import { AutomationCapabilities } from "@dxos/plugin-automation";
415
239
  import { useClient } from "@dxos/react-client";
416
240
  var useChatServices = ({ space, chat }) => {
417
241
  const client = useClient();
418
- space ?? (space = client.spaces.default);
419
- const computeRuntimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
242
+ space ??= client.spaces.default;
243
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
420
244
  return useMemo3(() => {
421
- const runtime2 = computeRuntimeResolver.getRuntime(space.id);
422
- return () => runtime2.runPromise(Effect2.gen(function* () {
423
- return yield* Effect2.runtime().pipe(Effect2.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
245
+ const runtime2 = runtimeResolver.getRuntime(space.id);
246
+ return () => runtime2.runPromise(Effect.gen(function* () {
247
+ return yield* Effect.runtime().pipe(Effect.provide(chat?.traceQueue?.target ? TracingServiceExt.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
424
248
  }));
425
249
  }, [
426
250
  space,
@@ -428,37 +252,72 @@ var useChatServices = ({ space, chat }) => {
428
252
  ]);
429
253
  };
430
254
 
255
+ // src/hooks/useChatToolbarActions.ts
256
+ import { Atom } from "@effect-atom/atom-react";
257
+ import * as Effect2 from "effect/Effect";
258
+ import { useMemo as useMemo10 } from "react";
259
+ import { createIntent } from "@dxos/app-framework";
260
+ import { useIntentDispatcher } from "@dxos/app-framework/react";
261
+ import { Filter as Filter5, Obj as Obj6, Query } from "@dxos/echo";
262
+ import { invariant } from "@dxos/invariant";
263
+ import { useQuery as useQuery4 } from "@dxos/react-client/echo";
264
+ import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
265
+
266
+ // src/components/index.ts
267
+ import { lazy } from "react";
268
+
269
+ // src/components/Chat/Chat.tsx
270
+ import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
271
+ import { Prec } from "@codemirror/state";
272
+ import { keymap } from "@codemirror/view";
273
+ import { useAtomValue } from "@effect-atom/atom-react";
274
+ import { createContext } from "@radix-ui/react-context";
275
+ import * as Array2 from "effect/Array";
276
+ import * as Option2 from "effect/Option";
277
+ import React10, { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState11 } from "react";
278
+ import { Event } from "@dxos/async";
279
+ import { Obj as Obj5 } from "@dxos/echo";
280
+ import { useVoiceInput } from "@dxos/plugin-transcription";
281
+ import { getSpace, useQueue } from "@dxos/react-client/echo";
282
+ import { useIdentity } from "@dxos/react-client/halo";
283
+ import { Input as Input2, useDynamicRef, useTranslation as useTranslation6 } from "@dxos/react-ui";
284
+ import { ChatEditor, references } from "@dxos/react-ui-chat";
285
+ import { MenuProvider, ToolbarMenu } from "@dxos/react-ui-menu";
286
+ import { mx as mx5 } from "@dxos/react-ui-theme";
287
+ import { Message } from "@dxos/types";
288
+ import { isTruthy } from "@dxos/util";
289
+
431
290
  // src/hooks/useContextBinder.ts
432
291
  import { useState as useState3 } from "react";
433
292
  import { AiContextBinder } from "@dxos/assistant";
434
293
  import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
435
- var useContextBinder = (chat) => {
294
+ var useContextBinder = (queue) => {
436
295
  const [binder, setBinder] = useState3();
437
296
  useAsyncEffect2(async () => {
438
- if (!chat?.queue.target) {
297
+ if (!queue) {
439
298
  return;
440
299
  }
441
- const binder2 = new AiContextBinder(chat.queue.target);
300
+ const binder2 = new AiContextBinder(queue);
442
301
  await binder2.open();
443
302
  setBinder(binder2);
444
303
  return () => {
445
304
  void binder2.close();
446
305
  };
447
306
  }, [
448
- chat?.queue.target
307
+ queue
449
308
  ]);
450
309
  return binder;
451
310
  };
452
311
 
453
312
  // src/hooks/useContextObjects.ts
454
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
313
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
455
314
  import { useCallback as useCallback2 } from "react";
456
315
  import { Ref as Ref2 } from "@dxos/echo";
457
- import { log as log3 } from "@dxos/log";
316
+ import { log as log2 } from "@dxos/log";
458
317
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
459
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
318
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
460
319
  var useContextObjects = ({ space, context }) => {
461
- var _effect = _useSignals2();
320
+ var _effect = _useSignals3();
462
321
  try {
463
322
  const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
464
323
  const handleUpdateObject = useCallback2(async (dxn, checked) => {
@@ -468,11 +327,11 @@ var useContextObjects = ({ space, context }) => {
468
327
  const id = dxn.asEchoDXN();
469
328
  const object = id && await space.db.getObjectById(id.echoId);
470
329
  if (!object) {
471
- log3.warn("Object not found", {
330
+ log2.warn("Object not found", {
472
331
  dxn,
473
332
  id
474
333
  }, {
475
- F: __dxlog_file3,
334
+ F: __dxlog_file2,
476
335
  L: 40,
477
336
  S: void 0,
478
337
  C: (f, a) => f(...a)
@@ -537,7 +396,7 @@ var useFlush = (space) => {
537
396
  };
538
397
 
539
398
  // src/hooks/useItemTypes.ts
540
- import * as Option2 from "effect/Option";
399
+ import * as Option from "effect/Option";
541
400
  import { useEffect, useState as useState5 } from "react";
542
401
  import { ItemAnnotation } from "@dxos/schema";
543
402
  var useItemTypes = (space) => {
@@ -550,7 +409,7 @@ var useItemTypes = (space) => {
550
409
  const types2 = Array.from(new Set([
551
410
  ...space.db.graph.schemaRegistry.schemas,
552
411
  ...query.results
553
- ].filter((type) => Option2.isSome(ItemAnnotation.get(type)))));
412
+ ].filter((type) => Option.isSome(ItemAnnotation.get(type)))));
554
413
  setTypes(types2);
555
414
  }, {
556
415
  fire: true
@@ -606,8 +465,9 @@ var usePresets = (online) => {
606
465
 
607
466
  // src/hooks/useReferencesProvider.ts
608
467
  import { useMemo as useMemo5 } from "react";
609
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
610
- import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
468
+ import { Capabilities as Capabilities2 } from "@dxos/app-framework";
469
+ import { useCapabilities as useCapabilities2 } from "@dxos/app-framework/react";
470
+ import { Filter as Filter2, Obj as Obj2 } from "@dxos/echo";
611
471
  var useReferencesProvider = (space) => {
612
472
  const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
613
473
  return useMemo5(() => {
@@ -617,16 +477,16 @@ var useReferencesProvider = (space) => {
617
477
  return {
618
478
  getReferences: async ({ query }) => {
619
479
  const { objects } = await space.db.query(Filter2.everything()).run();
620
- return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
621
- uri: Obj3.getDXN(object).toString(),
622
- label: Obj3.getLabel(object) ?? ""
480
+ return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
481
+ uri: Obj2.getDXN(object).toString(),
482
+ label: Obj2.getLabel(object) ?? ""
623
483
  }));
624
484
  },
625
485
  resolveReference: async ({ uri }) => {
626
486
  const object = await space.db.query(Filter2.ids(uri)).first();
627
487
  return {
628
488
  uri,
629
- label: Obj3.getLabel(object) ?? ""
489
+ label: Obj2.getLabel(object) ?? ""
630
490
  };
631
491
  }
632
492
  };
@@ -637,56 +497,34 @@ var useReferencesProvider = (space) => {
637
497
  };
638
498
  var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
639
499
 
640
- // src/components/Chat/Chat.tsx
641
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
642
- import { Prec } from "@codemirror/state";
643
- import { keymap } from "@codemirror/view";
644
- import { useRxValue } from "@effect-rx/rx-react";
645
- import { createContext } from "@radix-ui/react-context";
646
- import * as Array2 from "effect/Array";
647
- import * as Option3 from "effect/Option";
648
- import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState12 } from "react";
649
- import { Event } from "@dxos/async";
650
- import { Obj as Obj6 } from "@dxos/echo";
651
- import { useVoiceInput } from "@dxos/plugin-transcription";
652
- import { getSpace, useQueue } from "@dxos/react-client/echo";
653
- import { useIdentity } from "@dxos/react-client/halo";
654
- import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
655
- import { ChatEditor, references } from "@dxos/react-ui-chat";
656
- import { mx as mx5 } from "@dxos/react-ui-theme";
657
- import { DataType as DataType2 } from "@dxos/schema";
658
- import { isTruthy } from "@dxos/util";
659
-
660
500
  // src/components/ChatPrompt/ChatActions.tsx
661
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
662
- import React from "react";
663
- import { IconButton, useTranslation } from "@dxos/react-ui";
501
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
502
+ import React2 from "react";
503
+ import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
664
504
  import { mx } from "@dxos/react-ui-theme";
665
505
  var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
666
- var _effect = _useSignals3();
506
+ var _effect = _useSignals4();
667
507
  try {
668
- const { t } = useTranslation(meta.id);
669
- return /* @__PURE__ */ React.createElement("div", {
508
+ const { t } = useTranslation2(meta.id);
509
+ return /* @__PURE__ */ React2.createElement("div", {
670
510
  className: mx("flex items-center mie-1", classNames)
671
- }, children, /* @__PURE__ */ React.createElement(IconButton, {
511
+ }, children, /* @__PURE__ */ React2.createElement(IconButton, {
672
512
  disabled: !processing,
673
513
  variant: "ghost",
674
- size: 5,
675
514
  icon: "ph--x--regular",
676
515
  iconOnly: true,
677
- label: t("button cancel processing"),
516
+ label: t("cancel processing button"),
678
517
  onClick: () => onEvent?.({
679
518
  type: "cancel"
680
519
  })
681
- }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
520
+ }), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
682
521
  disabled: !processing,
683
522
  classNames: mx(recording && "bg-primary-500"),
684
523
  variant: "ghost",
685
- size: 5,
686
524
  icon: "ph--microphone--regular",
687
525
  iconOnly: true,
688
526
  noTooltip: true,
689
- label: t("button microphone"),
527
+ label: t("microphone button"),
690
528
  onMouseDown: () => onEvent?.({
691
529
  type: "record-start"
692
530
  }),
@@ -706,88 +544,86 @@ var ChatActions = ({ classNames, children, microphone, recording, processing, on
706
544
  };
707
545
 
708
546
  // src/components/ChatPrompt/ChatOptions.tsx
709
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
710
- import React2, { useMemo as useMemo6, useState as useState8 } from "react";
711
- import { Filter as Filter3, Obj as Obj4, Type } from "@dxos/echo";
547
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
548
+ import React3, { useMemo as useMemo6, useState as useState8 } from "react";
549
+ import { Filter as Filter3, Obj as Obj3, Type } from "@dxos/echo";
712
550
  import { useQuery as useQuery2 } from "@dxos/react-client/echo";
713
- import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
551
+ import { Icon, IconButton as IconButton2, Popover, Select as Select2, useTranslation as useTranslation3 } from "@dxos/react-ui";
714
552
  import { Listbox, SearchList } from "@dxos/react-ui-searchlist";
715
553
  import { Tabs } from "@dxos/react-ui-tabs";
716
554
  var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-72 max-is-[--text-content]";
717
555
  var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
718
- var _effect = _useSignals4();
556
+ var _effect = _useSignals5();
719
557
  try {
720
- const { t } = useTranslation2(meta.id);
721
- return /* @__PURE__ */ React2.createElement("div", {
558
+ const { t } = useTranslation3(meta.id);
559
+ return /* @__PURE__ */ React3.createElement("div", {
722
560
  role: "none",
723
- className: "flex gap-0.5"
724
- }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
561
+ className: "flex"
562
+ }, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
725
563
  asChild: true
726
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
564
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
727
565
  variant: "ghost",
728
566
  icon: "ph--plus--regular",
729
567
  iconOnly: true,
730
- size: 5,
731
- label: t("button context objects")
732
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
568
+ label: t("context objects button")
569
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
733
570
  side: "top",
734
571
  classNames: panelClassNames
735
- }, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
572
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
736
573
  space,
737
574
  context
738
- }), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
575
+ })), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
739
576
  asChild: true
740
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
577
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
741
578
  variant: "ghost",
742
579
  icon: "ph--sliders-horizontal--regular",
743
580
  iconOnly: true,
744
- size: 5,
745
- label: t("button context settings")
746
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
581
+ label: t("context settings button")
582
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
747
583
  side: "top",
748
584
  classNames: panelClassNames
749
- }, /* @__PURE__ */ React2.createElement(Tabs.Root, {
585
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(Tabs.Root, {
750
586
  orientation: "horizontal",
751
587
  defaultValue: "blueprints",
752
588
  defaultActivePart: "list",
753
589
  tabIndex: -1
754
- }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
590
+ }, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
755
591
  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'
756
- }, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
592
+ }, /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
757
593
  value: "blueprints",
758
594
  tabIndex: -1,
759
595
  classNames: "dx-focus-ring-inset"
760
- }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
596
+ }, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
761
597
  blueprintRegistry,
762
598
  space,
763
599
  context
764
- })), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
600
+ })), /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
765
601
  value: "model",
766
602
  tabIndex: -1,
767
603
  classNames: "dx-focus-ring-inset !pli-0"
768
- }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
604
+ }, /* @__PURE__ */ React3.createElement(ModelsPanel, {
769
605
  presets,
770
606
  preset,
771
607
  onPresetChange
772
- })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
608
+ })), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
773
609
  classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
774
- }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
610
+ }, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
775
611
  value: "blueprints",
776
612
  icon: "ph--blueprint--regular",
777
613
  label: t("blueprints in context title")
778
- }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
614
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
779
615
  value: "model",
780
616
  label: t("chat model title"),
781
617
  icon: "ph--cpu--regular"
782
- })))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
618
+ }))))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
783
619
  } finally {
784
620
  _effect.f();
785
621
  }
786
622
  };
787
623
  var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
788
- var _effect = _useSignals4();
624
+ var _effect = _useSignals5();
789
625
  try {
790
- const { t } = useTranslation2(meta.id);
626
+ const { t } = useTranslation3(meta.id);
791
627
  const blueprints = useBlueprints({
792
628
  blueprintRegistry,
793
629
  space
@@ -800,24 +636,24 @@ var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
800
636
  context,
801
637
  blueprintRegistry
802
638
  });
803
- return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
639
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, null, /* @__PURE__ */ React3.createElement(SearchList.Content, {
804
640
  classNames: "plb-cardSpacingChrome"
805
641
  }, blueprints.map((blueprint) => {
806
642
  const isActive = activeBlueprints.has(blueprint.key);
807
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
643
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
808
644
  classNames: "flex items-center overflow-hidden",
809
645
  key: blueprint.key,
810
646
  value: blueprint.name,
811
647
  onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
812
- }, /* @__PURE__ */ React2.createElement("div", {
648
+ }, /* @__PURE__ */ React3.createElement("div", {
813
649
  className: "grow truncate"
814
- }, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
650
+ }, blueprint.name), /* @__PURE__ */ React3.createElement(Icon, {
815
651
  icon: "ph--check--regular",
816
652
  classNames: [
817
653
  !isActive && "invisible"
818
654
  ]
819
655
  }));
820
- })), /* @__PURE__ */ React2.createElement(SearchList.Input, {
656
+ })), /* @__PURE__ */ React3.createElement(SearchList.Input, {
821
657
  placeholder: t("search placeholder"),
822
658
  classNames: "mbe-cardSpacingChrome",
823
659
  autoFocus: true
@@ -827,17 +663,17 @@ var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
827
663
  }
828
664
  };
829
665
  var ModelsPanel = ({ presets, preset, onPresetChange }) => {
830
- var _effect = _useSignals4();
666
+ var _effect = _useSignals5();
831
667
  try {
832
- return /* @__PURE__ */ React2.createElement(Listbox.Root, {
668
+ return /* @__PURE__ */ React3.createElement(Listbox.Root, {
833
669
  value: preset,
834
670
  onValueChange: onPresetChange,
835
671
  autoFocus: true
836
672
  }, presets?.map(({ id, label }) => {
837
- return /* @__PURE__ */ React2.createElement(Listbox.Option, {
673
+ return /* @__PURE__ */ React3.createElement(Listbox.Option, {
838
674
  key: id,
839
675
  value: id
840
- }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
676
+ }, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null));
841
677
  }));
842
678
  } finally {
843
679
  _effect.f();
@@ -845,9 +681,9 @@ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
845
681
  };
846
682
  var ANY = "__any__";
847
683
  var ObjectsPanel = ({ space, context }) => {
848
- var _effect = _useSignals4();
684
+ var _effect = _useSignals5();
849
685
  try {
850
- const { t } = useTranslation2(meta.id);
686
+ const { t } = useTranslation3(meta.id);
851
687
  const types = useItemTypes(space);
852
688
  const typenames = useMemo6(() => {
853
689
  const typenames2 = types.map((type) => {
@@ -874,39 +710,39 @@ var ObjectsPanel = ({ space, context }) => {
874
710
  space,
875
711
  context
876
712
  });
877
- return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
713
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, null, /* @__PURE__ */ React3.createElement(SearchList.Content, {
878
714
  classNames: "p-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
879
715
  }, objects.length ? objects.map((object) => {
880
- const label = Obj4.getLabel(object) ?? Obj4.getTypename(object) ?? object.id;
716
+ const label = Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id;
881
717
  const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
882
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
718
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
883
719
  classNames: "flex items-center overflow-hidden",
884
720
  key: object.id,
885
721
  value: object.id,
886
- onSelect: () => onUpdateObject?.(Obj4.getDXN(object), !isActive)
887
- }, /* @__PURE__ */ React2.createElement("div", {
722
+ onSelect: () => onUpdateObject?.(Obj3.getDXN(object), !isActive)
723
+ }, /* @__PURE__ */ React3.createElement("div", {
888
724
  className: "grow truncate"
889
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
725
+ }, label), /* @__PURE__ */ React3.createElement(Icon, {
890
726
  icon: "ph--check--regular",
891
727
  classNames: [
892
728
  !isActive && "invisible"
893
729
  ]
894
730
  }));
895
- }) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
731
+ }) : /* @__PURE__ */ React3.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React3.createElement("div", {
896
732
  role: "none",
897
733
  className: "grid grid-cols-[min-content_1fr] gap-2 pli-cardSpacingChrome mbe-cardSpacingChrome"
898
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
734
+ }, /* @__PURE__ */ React3.createElement(Select2.Root, {
899
735
  value: typename === ANY ? void 0 : typename,
900
736
  onValueChange: setTypename
901
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
737
+ }, /* @__PURE__ */ React3.createElement(Select2.TriggerButton, {
902
738
  density: "fine",
903
739
  placeholder: t("type filter placeholder")
904
- }), /* @__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, {
740
+ }), /* @__PURE__ */ React3.createElement(Select2.Portal, null, /* @__PURE__ */ React3.createElement(Select2.Content, null, /* @__PURE__ */ React3.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select2.Viewport, null, /* @__PURE__ */ React3.createElement(Select2.Option, {
905
741
  value: ANY
906
- }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
742
+ }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select2.Option, {
907
743
  key: typename2,
908
744
  value: typename2
909
- }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
745
+ }, label))), /* @__PURE__ */ React3.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select2.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
910
746
  placeholder: t("search placeholder"),
911
747
  classNames: "mbe-0",
912
748
  autoFocus: true
@@ -917,46 +753,46 @@ var ObjectsPanel = ({ space, context }) => {
917
753
  };
918
754
 
919
755
  // src/components/ChatPrompt/ChatPresets.tsx
920
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
921
- import React3 from "react";
922
- import { Select as Select2 } from "@dxos/react-ui";
923
-
924
- // src/components/ChatPrompt/ChatReferences.tsx
925
756
  import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
926
757
  import React4 from "react";
927
- import { Obj as Obj5 } from "@dxos/echo";
928
- import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
758
+ import { Select as Select3 } from "@dxos/react-ui";
759
+
760
+ // src/components/ChatPrompt/ChatReferences.tsx
761
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
762
+ import React5 from "react";
763
+ import { Obj as Obj4 } from "@dxos/echo";
764
+ import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
929
765
  import { mx as mx2 } from "@dxos/react-ui-theme";
930
766
  var ChatReferences = ({ classNames, context, space }) => {
931
- var _effect = _useSignals6();
767
+ var _effect = _useSignals7();
932
768
  try {
933
- const { t } = useTranslation3(meta.id);
769
+ const { t } = useTranslation4(meta.id);
934
770
  const { objects, onUpdateObject } = useContextObjects({
935
771
  space,
936
772
  context
937
773
  });
938
- return /* @__PURE__ */ React4.createElement("ul", {
939
- className: mx2("flex flex-wrap", classNames)
774
+ return /* @__PURE__ */ React5.createElement("ul", {
775
+ className: mx2("flex", classNames)
940
776
  }, objects.map((obj) => {
941
- const dxn = Obj5.getDXN(obj);
942
- const typename = Obj5.getTypename(obj);
943
- const label = Obj5.getLabel(obj) ?? (typename ? [
777
+ const dxn = Obj4.getDXN(obj);
778
+ const typename = Obj4.getTypename(obj);
779
+ const label = Obj4.getLabel(obj) ?? (typename ? [
944
780
  "object name placeholder",
945
781
  {
946
782
  ns: typename
947
783
  }
948
784
  ] : obj.id);
949
- return /* @__PURE__ */ React4.createElement("li", {
785
+ return /* @__PURE__ */ React5.createElement("li", {
950
786
  key: dxn.toString(),
951
787
  className: "dx-tag plb-0 pis-2 flex items-center",
952
788
  "data-hue": "neutral"
953
- }, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
789
+ }, toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
790
+ icon: "ph--x--bold",
954
791
  iconOnly: true,
955
792
  variant: "ghost",
956
793
  label: t("remove object in context label"),
957
794
  classNames: "p-0 hover:bg-transparent",
958
795
  size: 3,
959
- icon: "ph--x--bold",
960
796
  onClick: () => onUpdateObject?.(dxn, false)
961
797
  }));
962
798
  }));
@@ -966,14 +802,14 @@ var ChatReferences = ({ classNames, context, space }) => {
966
802
  };
967
803
 
968
804
  // src/components/ChatPrompt/ChatStatusIndicator.tsx
969
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
970
- import React5, { useEffect as useEffect3, useState as useState9 } from "react";
805
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
806
+ import React6, { useEffect as useEffect3, useState as useState9 } from "react";
971
807
  import { Tooltip, useTimeout } from "@dxos/react-ui";
972
808
  import { Spinner } from "@dxos/react-ui-sfx";
973
809
  import { mx as mx3 } from "@dxos/react-ui-theme";
974
810
  var period = 3e3;
975
811
  var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
976
- var _effect = _useSignals7();
812
+ var _effect = _useSignals8();
977
813
  try {
978
814
  const [init, setInit] = useState9(false);
979
815
  useEffect3(() => setInit(false), [
@@ -984,17 +820,17 @@ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props })
984
820
  }, period / 2, [
985
821
  preset
986
822
  ]);
987
- return /* @__PURE__ */ React5.createElement("div", {
823
+ return /* @__PURE__ */ React6.createElement("div", {
988
824
  role: "none",
989
825
  className: mx3("relative flex", classNames)
990
- }, /* @__PURE__ */ React5.createElement(Spinner, {
826
+ }, /* @__PURE__ */ React6.createElement(Spinner, {
991
827
  duration: period,
992
828
  state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
993
829
  ...props
994
- }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
830
+ }), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
995
831
  asChild: true,
996
832
  content: error.message
997
- }, /* @__PURE__ */ React5.createElement("div", {
833
+ }, /* @__PURE__ */ React6.createElement("div", {
998
834
  className: "absolute inset-0"
999
835
  })));
1000
836
  } finally {
@@ -1003,42 +839,34 @@ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props })
1003
839
  };
1004
840
 
1005
841
  // src/components/ChatThread/ChatThread.tsx
1006
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1007
- import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo8, useState as useState11 } from "react";
842
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
843
+ import React9, { forwardRef, useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo8 } from "react";
1008
844
  import { PublicKey } from "@dxos/keys";
845
+ import { useForwardedRef } from "@dxos/react-ui";
1009
846
  import { MarkdownStream } from "@dxos/react-ui-components";
1010
847
  import { mx as mx4 } from "@dxos/react-ui-theme";
1011
848
  import { keyToFallback } from "@dxos/util";
1012
849
 
1013
850
  // src/components/ChatThread/registry.tsx
1014
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1015
- import React7 from "react";
1016
- import { log as log4 } from "@dxos/log";
851
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
852
+ import React8 from "react";
853
+ import { log as log3 } from "@dxos/log";
1017
854
  import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
1018
855
  import { getXmlTextChild } from "@dxos/react-ui-editor";
1019
856
  import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
1020
- import { ContentBlock } from "@dxos/schema";
857
+ import { ContentBlock } from "@dxos/types";
1021
858
 
1022
859
  // src/components/ToolBlock/ToolBlock.tsx
1023
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1024
- import React6, { useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
1025
- import { useTranslation as useTranslation4 } from "@dxos/react-ui";
1026
- import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
860
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
861
+ import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
862
+ import { useTranslation as useTranslation5 } from "@dxos/react-ui";
863
+ import { NumericTabs, TextCrawl, ToggleContainer } from "@dxos/react-ui-components";
1027
864
  import { Json } from "@dxos/react-ui-syntax-highlighter";
1028
865
  import { isNonNullable as isNonNullable3, safeParseJson } from "@dxos/util";
1029
- var ToolBlock = ({ blocks = [] }) => {
1030
- var _effect = _useSignals8();
866
+ var ToolBlock = ({ view, blocks = [] }) => {
867
+ var _effect = _useSignals9();
1031
868
  try {
1032
- const { t } = useTranslation4(meta.id);
1033
- const getToolCaption = (tool, status) => {
1034
- if (!tool) {
1035
- return t("calling tool label");
1036
- }
1037
- return status?.message ?? tool.description ?? [
1038
- t("calling label"),
1039
- tool.name
1040
- ].join(" ");
1041
- };
869
+ const { t } = useTranslation5(meta.id);
1042
870
  const items = useMemo7(() => {
1043
871
  let lastToolCall;
1044
872
  const tools = [];
@@ -1054,7 +882,10 @@ var ToolBlock = ({ blocks = [] }) => {
1054
882
  block
1055
883
  };
1056
884
  return {
1057
- title: getToolCaption(lastToolCall?.tool),
885
+ title: tool?.description ?? [
886
+ t("tool call label"),
887
+ tool?.name
888
+ ].join(" "),
1058
889
  content: {
1059
890
  ...block,
1060
891
  input: safeParseJson(block.input)
@@ -1064,11 +895,14 @@ var ToolBlock = ({ blocks = [] }) => {
1064
895
  case "toolResult": {
1065
896
  if (block.error) {
1066
897
  return {
1067
- title: t("error label"),
898
+ title: t("tool error label"),
1068
899
  content: block
1069
900
  };
1070
901
  }
1071
- const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
902
+ const title = lastToolCall?.tool?.description ?? [
903
+ t("tool result label"),
904
+ lastToolCall?.tool?.name
905
+ ].join(" ");
1072
906
  lastToolCall = void 0;
1073
907
  return {
1074
908
  title,
@@ -1092,57 +926,65 @@ var ToolBlock = ({ blocks = [] }) => {
1092
926
  }, [
1093
927
  blocks
1094
928
  ]);
929
+ const handleChangeOpen = useCallback5(() => {
930
+ setTimeout(() => {
931
+ view?.requestMeasure();
932
+ }, 1e3);
933
+ }, [
934
+ view
935
+ ]);
1095
936
  if (!items.length) {
1096
937
  return null;
1097
938
  }
1098
- return /* @__PURE__ */ React6.createElement(ToolContainer, {
1099
- items
939
+ return /* @__PURE__ */ React7.createElement(ToolContainer, {
940
+ items,
941
+ onChangeOpen: handleChangeOpen
1100
942
  });
1101
943
  } finally {
1102
944
  _effect.f();
1103
945
  }
1104
946
  };
1105
947
  ToolBlock.displayName = "ToolBlock";
1106
- var ToolContainer = ({ items }) => {
1107
- var _effect = _useSignals8();
948
+ var ToolContainer = ({ items, onChangeOpen }) => {
949
+ var _effect = _useSignals9();
1108
950
  try {
1109
951
  const tabsRef = useRef2(null);
1110
952
  const [selected, setSelected] = useState10(0);
1111
953
  const [open, setOpen] = useState10(false);
1112
954
  useEffect4(() => {
955
+ onChangeOpen?.(open);
1113
956
  if (open) {
1114
957
  tabsRef.current?.focus();
1115
958
  }
1116
959
  }, [
960
+ onChangeOpen,
1117
961
  open
1118
962
  ]);
1119
963
  const handleSelect = (index) => {
1120
964
  setSelected(index);
1121
965
  };
1122
- const data = items[selected]?.content;
1123
- return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
1124
- classNames: chatMessagePanel,
966
+ return /* @__PURE__ */ React7.createElement(ToggleContainer.Root, {
967
+ classNames: "mbs-2 is-full rounded-sm",
1125
968
  open,
1126
969
  onChangeOpen: setOpen
1127
- }, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
1128
- classNames: chatMessagePanelHeader
1129
- }, /* @__PURE__ */ React6.createElement(TextCrawl, {
970
+ }, /* @__PURE__ */ React7.createElement(ToggleContainer.Header, {
971
+ classNames: "text-sm text-placeholder"
972
+ }, /* @__PURE__ */ React7.createElement(TextCrawl, {
1130
973
  key: "status-roll",
1131
- lines: items.map((item) => item.title)
1132
- })), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
1133
- classNames: [
1134
- "grid grid-cols-[32px_1fr]",
1135
- chatMessagePanelContent
1136
- ]
1137
- }, /* @__PURE__ */ React6.createElement(NumericTabs, {
974
+ lines: items.map((item) => item.title),
975
+ autoAdvance: true,
976
+ greedy: true
977
+ })), /* @__PURE__ */ React7.createElement(ToggleContainer.Content, {
978
+ classNames: "grid grid-cols-[32px_1fr]"
979
+ }, /* @__PURE__ */ React7.createElement(NumericTabs, {
1138
980
  ref: tabsRef,
1139
981
  classNames: "p-1",
1140
982
  length: items.length,
1141
983
  selected,
1142
984
  onSelect: handleSelect
1143
- }), /* @__PURE__ */ React6.createElement(Json, {
1144
- data,
1145
- classNames: chatMessageJson,
985
+ }), /* @__PURE__ */ React7.createElement(Json, {
986
+ data: items[selected]?.content,
987
+ classNames: "p-1 text-xs bg-transparent",
1146
988
  replacer: {
1147
989
  maxDepth: 3,
1148
990
  maxArrayLen: 10,
@@ -1155,17 +997,17 @@ var ToolContainer = ({ items }) => {
1155
997
  };
1156
998
 
1157
999
  // src/components/ChatThread/registry.tsx
1158
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1000
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1159
1001
  var Fallback = ({ _tag, ...props }) => {
1160
- var _effect = _useSignals9();
1002
+ var _effect = _useSignals10();
1161
1003
  try {
1162
- return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
1004
+ return /* @__PURE__ */ React8.createElement(ToggleContainer2.Root, {
1163
1005
  classNames: "rounded-sm"
1164
- }, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
1006
+ }, /* @__PURE__ */ React8.createElement(ToggleContainer2.Header, {
1165
1007
  classNames: "bg-groupSurface"
1166
- }, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
1008
+ }, _tag), /* @__PURE__ */ React8.createElement(ToggleContainer2.Content, {
1167
1009
  classNames: "bg-modalSurface"
1168
- }, /* @__PURE__ */ React7.createElement(Json2, {
1010
+ }, /* @__PURE__ */ React8.createElement(Json2, {
1169
1011
  classNames: "!p-2 text-sm",
1170
1012
  data: props
1171
1013
  })));
@@ -1179,36 +1021,36 @@ var componentRegistry = {
1179
1021
  //
1180
1022
  ["prompt"]: {
1181
1023
  block: true,
1182
- factory: (props) => {
1183
- const text = getXmlTextChild(props.children);
1024
+ factory: ({ children }) => {
1025
+ const text = getXmlTextChild(children);
1184
1026
  return text ? new PromptWidget(text) : null;
1185
1027
  }
1186
1028
  },
1187
1029
  ["reference"]: {
1188
1030
  block: false,
1189
- factory: (props) => {
1190
- const text = getXmlTextChild(props.children);
1191
- return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
1031
+ factory: ({ children, ref }) => {
1032
+ const text = getXmlTextChild(children);
1033
+ return text && ref ? new ReferenceWidget(text, ref) : null;
1192
1034
  }
1193
1035
  },
1194
1036
  ["select"]: {
1195
1037
  block: true,
1196
- factory: (props) => {
1197
- const options = props.children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1038
+ factory: ({ children }) => {
1039
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1198
1040
  return options?.length ? new SelectWidget(options) : null;
1199
1041
  }
1200
1042
  },
1201
1043
  ["suggestion"]: {
1202
1044
  block: true,
1203
- factory: (props) => {
1204
- const text = getXmlTextChild(props.children);
1045
+ factory: ({ children }) => {
1046
+ const text = getXmlTextChild(children);
1205
1047
  return text ? new SuggestionWidget(text) : null;
1206
1048
  }
1207
1049
  },
1208
1050
  ["summary"]: {
1209
1051
  block: true,
1210
- factory: (props) => {
1211
- const text = getXmlTextChild(props.children);
1052
+ factory: ({ children }) => {
1053
+ const text = getXmlTextChild(children);
1212
1054
  return text ? new SummaryWidget(text) : null;
1213
1055
  }
1214
1056
  },
@@ -1236,17 +1078,17 @@ var componentRegistry = {
1236
1078
  }
1237
1079
  };
1238
1080
  var blockToMarkdown = (context, message, block) => {
1239
- let str = _blockToMarkdown(context, message, block);
1081
+ let str = blockToMarkdownImpl(context, message, block);
1240
1082
  if (str && !block.pending) {
1241
1083
  return str += "\n";
1242
1084
  }
1243
1085
  return str;
1244
1086
  };
1245
- var _blockToMarkdown = (context, message, block) => {
1246
- log4("blockToMarkdown", {
1087
+ var blockToMarkdownImpl = (context, message, block) => {
1088
+ log3("blockToMarkdown", {
1247
1089
  block: JSON.stringify(block)
1248
1090
  }, {
1249
- F: __dxlog_file4,
1091
+ F: __dxlog_file3,
1250
1092
  L: 125,
1251
1093
  S: void 0,
1252
1094
  C: (f, a) => f(...a)
@@ -1254,9 +1096,7 @@ var _blockToMarkdown = (context, message, block) => {
1254
1096
  switch (block._tag) {
1255
1097
  case "text": {
1256
1098
  if (message.sender.role === "user") {
1257
- return `
1258
- <prompt>${block.text}</prompt>
1259
- `;
1099
+ return `<prompt>${block.text}</prompt>`;
1260
1100
  } else {
1261
1101
  const text = block.text.trim();
1262
1102
  if (text.length > 0) {
@@ -1265,6 +1105,10 @@ var _blockToMarkdown = (context, message, block) => {
1265
1105
  }
1266
1106
  break;
1267
1107
  }
1108
+ case "reference": {
1109
+ const dxn = block.reference.dxn;
1110
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
1111
+ }
1268
1112
  case "suggestion": {
1269
1113
  if (block.pending) {
1270
1114
  return;
@@ -1277,13 +1121,6 @@ var _blockToMarkdown = (context, message, block) => {
1277
1121
  }
1278
1122
  return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1279
1123
  }
1280
- // TODO(burdon): Need label.
1281
- case "reference": {
1282
- return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
1283
- }
1284
- // case 'toolkit': {
1285
- // return `<toolkit />`;
1286
- // }
1287
1124
  case "toolCall": {
1288
1125
  context.updateWidget(block.toolCallId, {
1289
1126
  blocks: [
@@ -1304,7 +1141,6 @@ var _blockToMarkdown = (context, message, block) => {
1304
1141
  case "summary": {
1305
1142
  return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
1306
1143
  }
1307
- // TODO(burdon): Need stable ID.
1308
1144
  default: {
1309
1145
  return `<json id="${message.id}">
1310
1146
  ${JSON.stringify(block)}
@@ -1314,38 +1150,41 @@ ${JSON.stringify(block)}
1314
1150
  };
1315
1151
 
1316
1152
  // src/components/ChatThread/sync.ts
1317
- import { log as log5 } from "@dxos/log";
1318
- function _define_property2(obj, key, value) {
1319
- if (key in obj) {
1320
- Object.defineProperty(obj, key, {
1321
- value,
1322
- enumerable: true,
1323
- configurable: true,
1324
- writable: true
1325
- });
1326
- } else {
1327
- obj[key] = value;
1328
- }
1329
- return obj;
1330
- }
1331
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1153
+ import { log as log4 } from "@dxos/log";
1154
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1332
1155
  var MessageThreadContext = class {
1156
+ _widgetState;
1157
+ constructor(_widgetState) {
1158
+ this._widgetState = _widgetState;
1159
+ }
1333
1160
  updateWidget(id, value) {
1334
1161
  this._widgetState?.updateWidget(id, value);
1335
1162
  }
1336
- constructor(_widgetState) {
1337
- _define_property2(this, "_widgetState", void 0);
1338
- this._widgetState = _widgetState;
1163
+ // TODO(burdon): Resolve from hypergraph.
1164
+ getObjectLabel(_id) {
1165
+ return "Object";
1339
1166
  }
1340
1167
  };
1341
1168
  var MessageSyncer = class {
1169
+ _model;
1170
+ _blockRenderer;
1171
+ _initialMessageId;
1172
+ _currentMessageIndex = 0;
1173
+ _currentBlockIndex = 0;
1174
+ _currentBlockContent;
1175
+ _context;
1176
+ constructor(_model, _blockRenderer) {
1177
+ this._model = _model;
1178
+ this._blockRenderer = _blockRenderer;
1179
+ this._context = new MessageThreadContext(this._model);
1180
+ }
1342
1181
  get context() {
1343
1182
  return this._context;
1344
1183
  }
1345
1184
  reset() {
1346
- log5("reset", void 0, {
1347
- F: __dxlog_file5,
1348
- L: 58,
1185
+ log4("reset", void 0, {
1186
+ F: __dxlog_file4,
1187
+ L: 64,
1349
1188
  S: this,
1350
1189
  C: (f, a) => f(...a)
1351
1190
  });
@@ -1355,22 +1194,53 @@ var MessageSyncer = class {
1355
1194
  this._currentBlockContent = void 0;
1356
1195
  void this._model.reset("");
1357
1196
  }
1358
- sync(messages) {
1359
- log5("sync", {
1197
+ /**
1198
+ * Syncs messages with the editor.
1199
+ */
1200
+ append(messages, flush = false) {
1201
+ if (this._initialMessageId !== messages[0]?.id) {
1202
+ this.reset();
1203
+ this._initialMessageId = messages[0]?.id;
1204
+ }
1205
+ if (flush && this._model.view?.state.doc.length === 0) {
1206
+ const buffer = [];
1207
+ this.process(messages, (content2) => {
1208
+ buffer.push(content2);
1209
+ });
1210
+ const content = buffer.join("");
1211
+ this._model.view?.dispatch({
1212
+ changes: [
1213
+ {
1214
+ from: 0,
1215
+ to: this._model.view?.state.doc.length ?? 0,
1216
+ insert: content
1217
+ }
1218
+ ],
1219
+ selection: {
1220
+ anchor: content.length
1221
+ }
1222
+ });
1223
+ return true;
1224
+ } else {
1225
+ this.process(messages, (content) => {
1226
+ void this._model.append(content);
1227
+ });
1228
+ return false;
1229
+ }
1230
+ }
1231
+ process(messages, append) {
1232
+ log4("sync", {
1233
+ doc: this._model.view?.state.doc.length,
1360
1234
  messages: messages.map((message) => message.blocks.length),
1361
1235
  currentMessageIndex: this._currentMessageIndex,
1362
1236
  currentBlockIndex: this._currentBlockIndex,
1363
1237
  currentBlockContent: this._currentBlockContent
1364
1238
  }, {
1365
- F: __dxlog_file5,
1366
- L: 67,
1239
+ F: __dxlog_file4,
1240
+ L: 105,
1367
1241
  S: this,
1368
1242
  C: (f, a) => f(...a)
1369
1243
  });
1370
- if (this._initialMessageId !== messages[0]?.id) {
1371
- this.reset();
1372
- this._initialMessageId = messages[0]?.id;
1373
- }
1374
1244
  let i = this._currentMessageIndex;
1375
1245
  for (const message of messages.slice(this._currentMessageIndex)) {
1376
1246
  if (i > this._currentMessageIndex) {
@@ -1388,18 +1258,18 @@ var MessageSyncer = class {
1388
1258
  } else {
1389
1259
  content = currentBlockContent;
1390
1260
  }
1391
- void this._model.append(content);
1392
- this._currentBlockContent = currentBlockContent;
1393
- log5("append", {
1261
+ log4("append", {
1394
1262
  message: i,
1395
1263
  block: j,
1396
1264
  content
1397
1265
  }, {
1398
- F: __dxlog_file5,
1399
- L: 99,
1266
+ F: __dxlog_file4,
1267
+ L: 132,
1400
1268
  S: this,
1401
1269
  C: (f, a) => f(...a)
1402
1270
  });
1271
+ this._currentBlockContent = currentBlockContent;
1272
+ append(content);
1403
1273
  }
1404
1274
  if (block.pending) {
1405
1275
  return;
@@ -1412,35 +1282,17 @@ var MessageSyncer = class {
1412
1282
  i++;
1413
1283
  }
1414
1284
  }
1415
- constructor(_model, _blockRenderer) {
1416
- _define_property2(this, "_model", void 0);
1417
- _define_property2(this, "_blockRenderer", void 0);
1418
- _define_property2(this, "_initialMessageId", void 0);
1419
- _define_property2(this, "_currentMessageIndex", void 0);
1420
- _define_property2(this, "_currentBlockIndex", void 0);
1421
- _define_property2(this, "_currentBlockContent", void 0);
1422
- _define_property2(this, "_context", void 0);
1423
- this._model = _model;
1424
- this._blockRenderer = _blockRenderer;
1425
- this._currentMessageIndex = 0;
1426
- this._currentBlockIndex = 0;
1427
- this._context = new MessageThreadContext(this._model);
1428
- }
1429
1285
  };
1430
1286
 
1431
1287
  // src/components/ChatThread/ChatThread.tsx
1432
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, overscroll, onEvent }, forwardedRef) => {
1433
- var _effect = _useSignals10();
1288
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent }, forwardedRef) => {
1289
+ var _effect = _useSignals11();
1434
1290
  try {
1435
- const userHue = useMemo8(() => {
1436
- return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1437
- }, [
1291
+ const controllerRef = useForwardedRef(forwardedRef);
1292
+ const controller = controllerRef.current;
1293
+ const userHue = useMemo8(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
1438
1294
  identity
1439
1295
  ]);
1440
- const [controller, setController] = useState11(null);
1441
- useImperativeHandle(forwardedRef, () => controller ? controller : null, [
1442
- controller
1443
- ]);
1444
1296
  useEffect5(() => {
1445
1297
  controller?.scrollToBottom();
1446
1298
  }, [
@@ -1451,17 +1303,20 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages =
1451
1303
  controller
1452
1304
  ]);
1453
1305
  useEffect5(() => {
1454
- syncer?.sync(messages);
1306
+ const reset = syncer?.append(messages, true);
1307
+ if (reset) {
1308
+ controller?.scrollToBottom("instant");
1309
+ }
1455
1310
  }, [
1456
1311
  syncer,
1457
1312
  messages
1458
1313
  ]);
1459
- const handleEvent = useCallback5((ev) => {
1460
- switch (ev.type) {
1314
+ const handleEvent = useCallback6(({ type, value }) => {
1315
+ switch (type) {
1461
1316
  case "submit": {
1462
- ev.value && onEvent?.({
1463
- type: "submit",
1464
- text: ev.value
1317
+ value && onEvent?.({
1318
+ type,
1319
+ text: value
1465
1320
  });
1466
1321
  break;
1467
1322
  }
@@ -1469,17 +1324,18 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages =
1469
1324
  }, [
1470
1325
  onEvent
1471
1326
  ]);
1472
- return /* @__PURE__ */ React8.createElement("div", {
1327
+ return /* @__PURE__ */ React9.createElement("div", {
1328
+ role: "none",
1473
1329
  className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
1474
1330
  style: {
1475
1331
  "--user-fill": `var(--dx-${userHue}Fill)`
1476
1332
  }
1477
- }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1478
- ref: setController,
1333
+ }, /* @__PURE__ */ React9.createElement(MarkdownStream, {
1334
+ ref: controllerRef,
1479
1335
  registry: componentRegistry,
1480
1336
  cursor,
1481
1337
  fadeIn,
1482
- overscroll,
1338
+ debug,
1483
1339
  onEvent: handleEvent
1484
1340
  }));
1485
1341
  } finally {
@@ -1489,21 +1345,20 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages =
1489
1345
 
1490
1346
  // src/components/Chat/Chat.tsx
1491
1347
  var [ChatContextProvider, useChatContext] = createContext("Chat");
1492
- var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1493
- var _effect = _useSignals11();
1348
+ var ChatRoot = ({ children, chat, processor, onEvent, ...props }) => {
1349
+ var _effect = _useSignals12();
1494
1350
  try {
1495
- const [debug, setDebug] = useState12(false);
1496
- const space = getSpace(chat);
1497
- const queue = useQueue(chat?.queue.dxn);
1498
- const pending = useRxValue(processor.messages);
1499
- const streaming = useRxValue(processor.streaming);
1351
+ const [debug, setDebug] = useState11(false);
1352
+ const pending = useAtomValue(processor.messages);
1353
+ const streaming = useAtomValue(processor.streaming);
1500
1354
  const lastPrompt = useRef3(void 0);
1355
+ const queue = useQueue(chat?.queue.dxn);
1501
1356
  const messages = useMemo9(() => {
1502
- const queueMessages = queue?.objects?.filter(Obj6.instanceOf(DataType2.Message)) ?? [];
1357
+ const queueMessages = queue?.objects?.filter(Obj5.instanceOf(Message.Message)) ?? [];
1503
1358
  return Array2.dedupeWith([
1504
1359
  ...queueMessages,
1505
1360
  ...pending
1506
- ], (a, b) => a.id === b.id);
1361
+ ], ({ id: a }, { id: b }) => a === b);
1507
1362
  }, [
1508
1363
  queue?.objects,
1509
1364
  pending
@@ -1544,10 +1399,8 @@ var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) =>
1544
1399
  }
1545
1400
  break;
1546
1401
  }
1547
- default: {
1548
- onEvent?.(ev);
1549
- }
1550
1402
  }
1403
+ onEvent?.(ev);
1551
1404
  });
1552
1405
  }, [
1553
1406
  event,
@@ -1555,37 +1408,43 @@ var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) =>
1555
1408
  streaming,
1556
1409
  onEvent
1557
1410
  ]);
1558
- if (!space) {
1559
- return null;
1560
- }
1561
- return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1411
+ const space = props.space ?? getSpace(chat);
1412
+ return /* @__PURE__ */ React10.createElement(ChatContextProvider, {
1562
1413
  debug,
1563
1414
  event,
1564
- chat,
1565
1415
  space,
1416
+ chat,
1566
1417
  messages,
1567
1418
  processor,
1568
1419
  ...props
1569
- }, /* @__PURE__ */ React9.createElement("div", {
1420
+ }, children);
1421
+ } finally {
1422
+ _effect.f();
1423
+ }
1424
+ };
1425
+ ChatRoot.displayName = "Chat.Root";
1426
+ var ChatViewport = ({ classNames, children }) => {
1427
+ var _effect = _useSignals12();
1428
+ try {
1429
+ return /* @__PURE__ */ React10.createElement("div", {
1570
1430
  role: "none",
1571
1431
  className: mx5("flex flex-col bs-full is-full", classNames)
1572
- }, children));
1432
+ }, children);
1573
1433
  } finally {
1574
1434
  _effect.f();
1575
1435
  }
1576
1436
  };
1577
- ChatRoot.displayName = "Chat.Root";
1578
1437
  var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1579
- var _effect = _useSignals11();
1438
+ var _effect = _useSignals12();
1580
1439
  try {
1581
- const { t } = useTranslation5(meta.id);
1582
- const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1583
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1584
- const streaming = useRxValue(processor.streaming);
1585
- const active = useRxValue(processor.active);
1440
+ const { t } = useTranslation6(meta.id);
1441
+ const { space, processor, event } = useChatContext(ChatPrompt.displayName);
1442
+ const error = useAtomValue(processor.error).pipe(Option2.getOrUndefined);
1443
+ const streaming = useAtomValue(processor.streaming);
1444
+ const active = useAtomValue(processor.active);
1586
1445
  const activeRef = useDynamicRef(active);
1587
1446
  const editorRef = useRef3(null);
1588
- const [recordingState, setRecordingState] = useState12(false);
1447
+ const [recordingState, setRecordingState] = useState11(false);
1589
1448
  useEffect6(() => {
1590
1449
  return event.on((event2) => {
1591
1450
  switch (event2.type) {
@@ -1621,7 +1480,7 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1621
1480
  }),
1622
1481
  Prec.highest(keymap.of([
1623
1482
  {
1624
- key: "cmd-d",
1483
+ key: "Mod-d",
1625
1484
  preventDefault: true,
1626
1485
  run: () => {
1627
1486
  event.emit({
@@ -1630,26 +1489,48 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1630
1489
  return true;
1631
1490
  }
1632
1491
  },
1633
- expandable && {
1634
- key: "cmd-ArrowUp",
1492
+ {
1493
+ key: "Mod-ArrowUp",
1635
1494
  preventDefault: true,
1636
1495
  run: () => {
1637
1496
  event.emit({
1638
- type: "thread-open"
1497
+ type: "nav-previous"
1639
1498
  });
1640
1499
  return true;
1641
1500
  }
1642
1501
  },
1643
- expandable && {
1644
- key: "cmd-ArrowDown",
1502
+ {
1503
+ key: "Mod-ArrowDown",
1645
1504
  preventDefault: true,
1646
1505
  run: () => {
1647
1506
  event.emit({
1648
- type: "thread-close"
1507
+ type: "nav-next"
1649
1508
  });
1650
1509
  return true;
1651
1510
  }
1652
- }
1511
+ },
1512
+ ...expandable ? [
1513
+ {
1514
+ key: "Shift-Mod-ArrowUp",
1515
+ preventDefault: true,
1516
+ run: () => {
1517
+ event.emit({
1518
+ type: "thread-open"
1519
+ });
1520
+ return true;
1521
+ }
1522
+ },
1523
+ {
1524
+ key: "Shift-Mod-ArrowDown",
1525
+ preventDefault: true,
1526
+ run: () => {
1527
+ event.emit({
1528
+ type: "thread-close"
1529
+ });
1530
+ return true;
1531
+ }
1532
+ }
1533
+ ] : []
1653
1534
  ].filter(isTruthy)))
1654
1535
  ].filter(isTruthy);
1655
1536
  }, [
@@ -1657,7 +1538,7 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1657
1538
  expandable,
1658
1539
  referencesProvider
1659
1540
  ]);
1660
- const handleSubmit = useCallback6((text) => {
1541
+ const handleSubmit = useCallback7((text) => {
1661
1542
  if (!activeRef.current) {
1662
1543
  event.emit({
1663
1544
  type: "submit",
@@ -1668,25 +1549,25 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1668
1549
  }, [
1669
1550
  event
1670
1551
  ]);
1671
- const handleEvent = useCallback6((ev) => {
1552
+ const handleEvent = useCallback7((ev) => {
1672
1553
  event.emit(ev);
1673
1554
  }, [
1674
1555
  event
1675
1556
  ]);
1676
- return /* @__PURE__ */ React9.createElement("div", {
1557
+ return /* @__PURE__ */ React10.createElement("div", {
1677
1558
  role: "group",
1678
1559
  className: mx5("flex flex-col is-full density-fine", outline && [
1679
1560
  "p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
1680
1561
  ], classNames)
1681
- }, /* @__PURE__ */ React9.createElement("div", {
1562
+ }, /* @__PURE__ */ React10.createElement("div", {
1682
1563
  role: "none",
1683
1564
  className: "flex gap-2"
1684
- }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1565
+ }, /* @__PURE__ */ React10.createElement(ChatStatusIndicator, {
1685
1566
  classNames: "p-1",
1686
1567
  preset,
1687
1568
  error,
1688
1569
  processing: streaming
1689
- }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1570
+ }), /* @__PURE__ */ React10.createElement(ChatEditor, {
1690
1571
  ref: editorRef,
1691
1572
  autoFocus: true,
1692
1573
  lineWrapping: true,
@@ -1694,32 +1575,32 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1694
1575
  placeholder: placeholder ?? t("prompt placeholder"),
1695
1576
  extensions,
1696
1577
  onSubmit: handleSubmit
1697
- })), settings && /* @__PURE__ */ React9.createElement("div", {
1578
+ })), space && settings && /* @__PURE__ */ React10.createElement("div", {
1698
1579
  role: "none",
1699
- className: "flex pbs-2 items-center"
1700
- }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1580
+ className: "flex pbs-2 items-center overflow-hidden"
1581
+ }, /* @__PURE__ */ React10.createElement(ChatOptions, {
1701
1582
  space,
1702
1583
  blueprintRegistry: processor.blueprintRegistry,
1703
1584
  context: processor.context,
1704
1585
  preset,
1705
1586
  presets,
1706
1587
  onPresetChange
1707
- }), /* @__PURE__ */ React9.createElement("div", {
1588
+ }), /* @__PURE__ */ React10.createElement("div", {
1708
1589
  role: "none",
1709
- className: "pli-cardSpacingChrome grow"
1710
- }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1590
+ className: "flex grow overflow-x-auto scrollbar-none"
1591
+ }, /* @__PURE__ */ React10.createElement(ChatReferences, {
1711
1592
  space,
1712
1593
  context: processor.context
1713
- })), /* @__PURE__ */ React9.createElement(ChatActions, {
1594
+ })), /* @__PURE__ */ React10.createElement(ChatActions, {
1714
1595
  classNames: "col-span-2",
1715
1596
  microphone: true,
1716
1597
  recording,
1717
1598
  processing: streaming,
1718
1599
  onEvent: handleEvent
1719
- }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
1600
+ }, online !== void 0 && /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Label, {
1720
1601
  srOnly: true
1721
- }, t("online switch label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
1722
- classNames: "mis-2 mie-2",
1602
+ }, t("online switch label")), /* @__PURE__ */ React10.createElement(Input2.Switch, {
1603
+ classNames: "mli-2",
1723
1604
  checked: online,
1724
1605
  onCheckedChange: onOnlineChange
1725
1606
  })))));
@@ -1729,25 +1610,31 @@ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandabl
1729
1610
  };
1730
1611
  ChatPrompt.displayName = "Chat.Prompt";
1731
1612
  var ChatThread2 = (props) => {
1732
- var _effect = _useSignals11();
1613
+ var _effect = _useSignals12();
1733
1614
  try {
1734
- const { event, messages, processor } = useChatContext(ChatThread2.displayName);
1615
+ const { debug, event, messages, processor } = useChatContext(ChatThread2.displayName);
1735
1616
  const identity = useIdentity();
1736
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1737
- const scrollerRef = useRef3(null);
1617
+ const error = useAtomValue(processor.error).pipe(Option2.getOrUndefined);
1618
+ const controllerRef = useRef3(null);
1738
1619
  useEffect6(() => {
1739
1620
  return event.on((event2) => {
1740
1621
  switch (event2.type) {
1741
1622
  case "submit":
1742
1623
  case "scroll-to-bottom":
1743
- scrollerRef.current?.scrollToBottom();
1624
+ controllerRef.current?.scrollToBottom();
1625
+ break;
1626
+ case "nav-previous":
1627
+ controllerRef.current?.navigatePrevious();
1628
+ break;
1629
+ case "nav-next":
1630
+ controllerRef.current?.navigateNext();
1744
1631
  break;
1745
1632
  }
1746
1633
  });
1747
1634
  }, [
1748
1635
  event
1749
1636
  ]);
1750
- const handleEvent = useCallback6((ev) => {
1637
+ const handleEvent = useCallback7((ev) => {
1751
1638
  event.emit(ev);
1752
1639
  }, [
1753
1640
  event
@@ -1755,32 +1642,290 @@ var ChatThread2 = (props) => {
1755
1642
  if (!identity) {
1756
1643
  return null;
1757
1644
  }
1758
- return /* @__PURE__ */ React9.createElement(ChatThread, {
1645
+ return /* @__PURE__ */ React10.createElement(ChatThread, {
1759
1646
  ...props,
1760
- ref: scrollerRef,
1761
1647
  identity,
1762
1648
  messages,
1763
1649
  error,
1764
- onEvent: handleEvent
1650
+ debug,
1651
+ onEvent: handleEvent,
1652
+ ref: controllerRef
1765
1653
  });
1766
1654
  } finally {
1767
1655
  _effect.f();
1768
1656
  }
1769
1657
  };
1770
1658
  ChatThread2.displayName = "Chat.Thread";
1659
+ var ChatToolbar = ({ classNames, companionTo }) => {
1660
+ var _effect = _useSignals12();
1661
+ try {
1662
+ const { chat } = useChatContext(ChatToolbar.displayName);
1663
+ const menu = useChatToolbarActions({
1664
+ chat,
1665
+ companionTo
1666
+ });
1667
+ return /* @__PURE__ */ React10.createElement(MenuProvider, {
1668
+ ...menu,
1669
+ attendableId: companionTo ? Obj5.getDXN(companionTo).toString() : chat ? Obj5.getDXN(chat).toString() : ""
1670
+ }, /* @__PURE__ */ React10.createElement(ToolbarMenu, {
1671
+ classNames,
1672
+ textBlockWidth: true
1673
+ }));
1674
+ } finally {
1675
+ _effect.f();
1676
+ }
1677
+ };
1678
+ ChatToolbar.displayName = "Chat.Toolbar";
1771
1679
  var Chat = {
1772
1680
  Root: ChatRoot,
1681
+ Viewport: ChatViewport,
1773
1682
  Prompt: ChatPrompt,
1774
- Thread: ChatThread2
1683
+ Thread: ChatThread2,
1684
+ Toolbar: ChatToolbar
1685
+ };
1686
+
1687
+ // src/components/Toolbox/Toolbox.tsx
1688
+ import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1689
+ import React11, { Fragment, useEffect as useEffect7, useState as useState12 } from "react";
1690
+ import { Function } from "@dxos/functions";
1691
+ import { log as log5 } from "@dxos/log";
1692
+ import { Filter as Filter4, useQuery as useQuery3 } from "@dxos/react-client/echo";
1693
+ import { useTranslation as useTranslation7 } from "@dxos/react-ui";
1694
+ import { mx as mx6 } from "@dxos/react-ui-theme";
1695
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1696
+ var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
1697
+ var _effect = _useSignals13();
1698
+ try {
1699
+ const { t } = useTranslation7(meta.id);
1700
+ return /* @__PURE__ */ React11.createElement("div", {
1701
+ className: mx6("flex flex-col overflow-y-auto box-content", classNames)
1702
+ }, blueprints && blueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1703
+ title: "Blueprints",
1704
+ items: blueprints.map(({ target }) => ({
1705
+ name: target?.name ?? "",
1706
+ description: target?.description ?? "",
1707
+ subitems: target?.tools.map((toolId) => ({
1708
+ name: `\u2219 ${safeToolId(toolId)}`
1709
+ }))
1710
+ }))
1711
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1712
+ title: "Blueprints",
1713
+ items: activeBlueprints.map(({ target }) => ({
1714
+ name: target?.name ?? "",
1715
+ description: target?.description ?? "",
1716
+ subitems: target?.tools.map((toolId) => ({
1717
+ name: `\u2219 ${safeToolId(toolId)}`
1718
+ }))
1719
+ }))
1720
+ }), services && services.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1721
+ title: "Services",
1722
+ items: services.map(({ service: { serviceId, name, description } }) => ({
1723
+ name: name ?? serviceId,
1724
+ description
1725
+ }))
1726
+ }), functions && functions.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1727
+ title: "Functions",
1728
+ items: functions.map(({ name, description }) => ({
1729
+ name,
1730
+ description
1731
+ }))
1732
+ }));
1733
+ } finally {
1734
+ _effect.f();
1735
+ }
1736
+ };
1737
+ var Section = ({ title, items, striped }) => {
1738
+ var _effect = _useSignals13();
1739
+ try {
1740
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1741
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
1742
+ const subGridClassNames = mx6("col-span-full grid grid-cols-subgrid text-xs pli-2", striped && stripeClassNames);
1743
+ return /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement("h1", {
1744
+ className: "pli-2 text-sm"
1745
+ }, title), /* @__PURE__ */ React11.createElement("div", {
1746
+ className: gridClassNames
1747
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React11.createElement(Fragment, {
1748
+ key: i
1749
+ }, name && /* @__PURE__ */ React11.createElement("div", {
1750
+ className: subGridClassNames
1751
+ }, /* @__PURE__ */ React11.createElement("div", {
1752
+ className: "truncate text-primary-500"
1753
+ }, name), /* @__PURE__ */ React11.createElement("div", {
1754
+ className: "line-clamp-2"
1755
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React11.createElement("div", {
1756
+ key: i2,
1757
+ className: mx6(subGridClassNames, striped && stripeClassNames)
1758
+ }, /* @__PURE__ */ React11.createElement("div", {
1759
+ className: "truncate"
1760
+ }, name2), /* @__PURE__ */ React11.createElement("div", {
1761
+ className: "line-clamp-3 text-subdued"
1762
+ }, description2)))))));
1763
+ } finally {
1764
+ _effect.f();
1765
+ }
1766
+ };
1767
+ var ToolboxContainer = ({ classNames, space, processor }) => {
1768
+ var _effect = _useSignals13();
1769
+ try {
1770
+ const services = useQuery3(space, Filter4.type(ServiceType));
1771
+ const [serviceTools, setServiceTools] = useState12([]);
1772
+ useEffect7(() => {
1773
+ log5("creating service tools...", {
1774
+ services: services.length
1775
+ }, {
1776
+ F: __dxlog_file5,
1777
+ L: 117,
1778
+ S: void 0,
1779
+ C: (f, a) => f(...a)
1780
+ });
1781
+ queueMicrotask(async () => {
1782
+ });
1783
+ }, [
1784
+ services
1785
+ ]);
1786
+ const functions = useQuery3(space, Filter4.type(Function.Function));
1787
+ return /* @__PURE__ */ React11.createElement(Toolbox, {
1788
+ classNames,
1789
+ blueprints: processor?.context.blueprints.value,
1790
+ services: serviceTools,
1791
+ functions
1792
+ });
1793
+ } finally {
1794
+ _effect.f();
1795
+ }
1796
+ };
1797
+ var safeToolId = (name) => {
1798
+ return name.split("_").pop();
1799
+ };
1800
+
1801
+ // src/components/index.ts
1802
+ var BlueprintArticle = lazy(() => import("./BlueprintArticle-RPZ2363K.mjs"));
1803
+ var ChatCompanion = lazy(() => import("./ChatCompanion-LKWZTSCI.mjs"));
1804
+ var ChatContainer = lazy(() => import("./ChatContainer-HGAAKVB3.mjs"));
1805
+ var ChatDialog = lazy(() => import("./ChatDialog-QA545GGB.mjs"));
1806
+ var PromptArticle = lazy(() => import("./PromptArticle-JW46XL4M.mjs"));
1807
+
1808
+ // src/hooks/useChatToolbarActions.ts
1809
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
1810
+ var useChatToolbarActions = ({ chat, companionTo }) => {
1811
+ const { dispatch } = useIntentDispatcher();
1812
+ const { space } = useChatContext("useChatToolbarActions");
1813
+ const query = companionTo ? Query.select(Filter5.ids(companionTo.id)).targetOf(Assistant_exports.CompanionTo).source() : Query.select(Filter5.nothing());
1814
+ const chats = useQuery4(space, query);
1815
+ return useMenuActions(useMemo10(() => {
1816
+ return Atom.make(() => {
1817
+ const builder = MenuBuilder.make().root({
1818
+ label: [
1819
+ "chat toolbar title",
1820
+ {
1821
+ ns: meta.id
1822
+ }
1823
+ ]
1824
+ }).action("new", {
1825
+ label: [
1826
+ "new thread button",
1827
+ {
1828
+ ns: meta.id
1829
+ }
1830
+ ],
1831
+ icon: "ph--plus--regular",
1832
+ type: "new"
1833
+ }, () => dispatch(createIntent(AssistantAction_exports.SetCurrentChat, {
1834
+ companionTo,
1835
+ chat: void 0
1836
+ })).pipe(Effect2.runPromise)).action("rename", {
1837
+ label: [
1838
+ "rename thread button",
1839
+ {
1840
+ ns: meta.id
1841
+ }
1842
+ ],
1843
+ icon: "ph--magic-wand--regular",
1844
+ type: "rename",
1845
+ disabled: !chat
1846
+ }, () => Effect2.gen(function* () {
1847
+ invariant(chat, void 0, {
1848
+ F: __dxlog_file6,
1849
+ L: 68,
1850
+ S: this,
1851
+ A: [
1852
+ "chat",
1853
+ ""
1854
+ ]
1855
+ });
1856
+ yield* dispatch(createIntent(AssistantAction_exports.UpdateChatName, {
1857
+ chat
1858
+ }));
1859
+ }).pipe(Effect2.runPromise)).action("branch", {
1860
+ label: [
1861
+ "button branch thread",
1862
+ {
1863
+ ns: meta.id
1864
+ }
1865
+ ],
1866
+ icon: "ph--git-branch--regular",
1867
+ type: "branch",
1868
+ disabled: true
1869
+ }, () => {
1870
+ });
1871
+ if (chats.length > 0) {
1872
+ builder.group("chats", {
1873
+ label: [
1874
+ "chat history label",
1875
+ {
1876
+ ns: meta.id
1877
+ }
1878
+ ],
1879
+ icon: "ph--clock-counter-clockwise--regular",
1880
+ selectCardinality: "single",
1881
+ variant: "dropdownMenu"
1882
+ }, (builder2) => {
1883
+ chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
1884
+ builder2.action(chat2.id, {
1885
+ label: Obj6.getLabel(chat2) ?? [
1886
+ "object name placeholder",
1887
+ {
1888
+ ns: Assistant_exports.Chat.typename
1889
+ }
1890
+ ]
1891
+ }, () => Effect2.gen(function* () {
1892
+ invariant(companionTo, void 0, {
1893
+ F: __dxlog_file6,
1894
+ L: 104,
1895
+ S: this,
1896
+ A: [
1897
+ "companionTo",
1898
+ ""
1899
+ ]
1900
+ });
1901
+ yield* dispatch(createIntent(AssistantAction_exports.SetCurrentChat, {
1902
+ companionTo,
1903
+ chat: chat2
1904
+ }));
1905
+ }).pipe(Effect2.runPromise));
1906
+ });
1907
+ });
1908
+ }
1909
+ return builder.build();
1910
+ });
1911
+ }, [
1912
+ chats.length,
1913
+ space?.id,
1914
+ companionTo?.id,
1915
+ chat?.id,
1916
+ dispatch
1917
+ ]));
1775
1918
  };
1776
1919
 
1777
1920
  export {
1921
+ AssistantSettings,
1778
1922
  useBlueprintRegistry,
1779
1923
  useBlueprints,
1780
1924
  useActiveBlueprints,
1781
1925
  useBlueprintHandlers,
1782
1926
  useChatProcessor,
1783
1927
  useChatServices,
1928
+ useChatToolbarActions,
1784
1929
  useContextBinder,
1785
1930
  useContextObjects,
1786
1931
  useFlush,
@@ -1790,6 +1935,13 @@ export {
1790
1935
  useReferencesProvider,
1791
1936
  ChatContextProvider,
1792
1937
  useChatContext,
1793
- Chat
1938
+ Chat,
1939
+ Toolbox,
1940
+ ToolboxContainer,
1941
+ BlueprintArticle,
1942
+ ChatCompanion,
1943
+ ChatContainer,
1944
+ ChatDialog,
1945
+ PromptArticle
1794
1946
  };
1795
- //# sourceMappingURL=chunk-UFKLCEAE.mjs.map
1947
+ //# sourceMappingURL=chunk-VI6S3Q5H.mjs.map