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

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