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