@dxos/plugin-assistant 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055

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 (650) hide show
  1. package/dist/lib/browser/AssistantSettings-SDYAAIS2.mjs +93 -0
  2. package/dist/lib/browser/AssistantSettings-SDYAAIS2.mjs.map +7 -0
  3. package/dist/lib/browser/BlueprintArticle-O7IDKYXB.mjs +37 -0
  4. package/dist/lib/browser/BlueprintArticle-O7IDKYXB.mjs.map +7 -0
  5. package/dist/lib/browser/ChatCompanion-QDT435XP.mjs +206 -0
  6. package/dist/lib/browser/ChatCompanion-QDT435XP.mjs.map +7 -0
  7. package/dist/lib/browser/ChatContainer-6IA3SIYM.mjs +14 -0
  8. package/dist/lib/browser/ChatDialog-TNC4CHJE.mjs +86 -0
  9. package/dist/lib/browser/ChatDialog-TNC4CHJE.mjs.map +7 -0
  10. package/dist/lib/browser/ProjectArticle-FJJFE4LS.mjs +97 -0
  11. package/dist/lib/browser/ProjectArticle-FJJFE4LS.mjs.map +7 -0
  12. package/dist/lib/browser/ProjectSettings-DDYTUL25.mjs +117 -0
  13. package/dist/lib/browser/ProjectSettings-DDYTUL25.mjs.map +7 -0
  14. package/dist/lib/browser/PromptArticle-NA7IJYBW.mjs +73 -0
  15. package/dist/lib/browser/PromptArticle-NA7IJYBW.mjs.map +7 -0
  16. package/dist/lib/browser/PromptList-LS4ZIZJP.mjs +55 -0
  17. package/dist/lib/browser/PromptList-LS4ZIZJP.mjs.map +7 -0
  18. package/dist/lib/browser/TracePanel-YPDUZKH5.mjs +407 -0
  19. package/dist/lib/browser/TracePanel-YPDUZKH5.mjs.map +7 -0
  20. package/dist/lib/browser/TriggerStatus-YVPE6X6O.mjs +105 -0
  21. package/dist/lib/browser/TriggerStatus-YVPE6X6O.mjs.map +7 -0
  22. package/dist/lib/browser/ai-service-CY2BYPH6.mjs +22 -0
  23. package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +7 -0
  24. package/dist/lib/browser/app-graph-builder-LATYLZE6.mjs +255 -0
  25. package/dist/lib/browser/app-graph-builder-LATYLZE6.mjs.map +7 -0
  26. package/dist/lib/browser/blueprint-definition-IFOVIZSP.mjs +39 -0
  27. package/dist/lib/browser/blueprint-definition-IFOVIZSP.mjs.map +7 -0
  28. package/dist/lib/browser/blueprints/index.mjs +11 -0
  29. package/dist/lib/browser/{chunk-WBG5PTSX.mjs → chunk-2VIEX4RA.mjs} +3 -3
  30. package/dist/lib/browser/chunk-2VIEX4RA.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-5B7RDLFZ.mjs +8 -0
  32. package/dist/lib/browser/chunk-5B7RDLFZ.mjs.map +7 -0
  33. package/dist/lib/browser/chunk-HE6DIUYX.mjs +149 -0
  34. package/dist/lib/browser/chunk-HE6DIUYX.mjs.map +7 -0
  35. package/dist/lib/browser/chunk-ITKPUTIW.mjs +103 -0
  36. package/dist/lib/browser/chunk-ITKPUTIW.mjs.map +7 -0
  37. package/dist/lib/browser/chunk-L6R55X33.mjs +155 -0
  38. package/dist/lib/browser/chunk-L6R55X33.mjs.map +7 -0
  39. package/dist/lib/browser/chunk-RI3GWI6T.mjs +2135 -0
  40. package/dist/lib/browser/chunk-RI3GWI6T.mjs.map +7 -0
  41. package/dist/lib/browser/{chunk-2BOE3OTW.mjs → chunk-RTUG64Q4.mjs} +99 -47
  42. package/dist/lib/browser/chunk-RTUG64Q4.mjs.map +7 -0
  43. package/dist/lib/browser/chunk-YFCVKIRQ.mjs +33 -0
  44. package/dist/lib/browser/chunk-YFCVKIRQ.mjs.map +7 -0
  45. package/dist/lib/browser/create-chat-ZYARKO3O.mjs +81 -0
  46. package/dist/lib/browser/create-chat-ZYARKO3O.mjs.map +7 -0
  47. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs +21 -0
  48. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +7 -0
  49. package/dist/lib/browser/index.mjs +263 -210
  50. package/dist/lib/browser/index.mjs.map +4 -4
  51. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs +20 -0
  52. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +7 -0
  53. package/dist/lib/browser/markdown-EKDPL7HL.mjs +114 -0
  54. package/dist/lib/browser/markdown-EKDPL7HL.mjs.map +7 -0
  55. package/dist/lib/browser/meta.json +1 -1
  56. package/dist/lib/browser/on-create-space-QBTI5UPD.mjs +23 -0
  57. package/dist/lib/browser/on-create-space-QBTI5UPD.mjs.map +7 -0
  58. package/dist/lib/browser/operation-handler-V3LRD63Z.mjs +17 -0
  59. package/dist/lib/browser/operation-handler-V3LRD63Z.mjs.map +7 -0
  60. package/dist/lib/browser/operations/index.mjs +13 -0
  61. package/dist/lib/browser/operations/index.mjs.map +7 -0
  62. package/dist/lib/browser/react-surface-RLHFSOO7.mjs +172 -0
  63. package/dist/lib/browser/react-surface-RLHFSOO7.mjs.map +7 -0
  64. package/dist/lib/browser/resolve-navigation-targets-7Z37XH6T.mjs +23 -0
  65. package/dist/lib/browser/resolve-navigation-targets-7Z37XH6T.mjs.map +7 -0
  66. package/dist/lib/browser/run-prompt-in-new-chat-BTTYZUFT.mjs +112 -0
  67. package/dist/lib/browser/run-prompt-in-new-chat-BTTYZUFT.mjs.map +7 -0
  68. package/dist/lib/browser/set-current-chat-KWOC5WYV.mjs +30 -0
  69. package/dist/lib/browser/set-current-chat-KWOC5WYV.mjs.map +7 -0
  70. package/dist/lib/browser/settings-2KRFM5GU.mjs +33 -0
  71. package/dist/lib/browser/settings-2KRFM5GU.mjs.map +7 -0
  72. package/dist/lib/browser/state-4UTSI3FD.mjs +27 -0
  73. package/dist/lib/browser/state-4UTSI3FD.mjs.map +7 -0
  74. package/dist/lib/browser/toolkit-XRSBBB3L.mjs +16 -0
  75. package/dist/lib/browser/toolkit-XRSBBB3L.mjs.map +7 -0
  76. package/dist/lib/browser/types/index.mjs +6 -4
  77. package/dist/lib/browser/update-chat-name-5FJSXO7O.mjs +36 -0
  78. package/dist/lib/browser/update-chat-name-5FJSXO7O.mjs.map +7 -0
  79. package/dist/lib/node-esm/AssistantSettings-APDXNTQQ.mjs +94 -0
  80. package/dist/lib/node-esm/AssistantSettings-APDXNTQQ.mjs.map +7 -0
  81. package/dist/lib/node-esm/BlueprintArticle-AV6BYHMQ.mjs +38 -0
  82. package/dist/lib/node-esm/BlueprintArticle-AV6BYHMQ.mjs.map +7 -0
  83. package/dist/lib/node-esm/ChatCompanion-NY7VUCQP.mjs +207 -0
  84. package/dist/lib/node-esm/ChatCompanion-NY7VUCQP.mjs.map +7 -0
  85. package/dist/lib/node-esm/ChatContainer-OERYLF4C.mjs +15 -0
  86. package/dist/lib/node-esm/ChatContainer-OERYLF4C.mjs.map +7 -0
  87. package/dist/lib/node-esm/ChatDialog-3HRJNIAC.mjs +87 -0
  88. package/dist/lib/node-esm/ChatDialog-3HRJNIAC.mjs.map +7 -0
  89. package/dist/lib/node-esm/ProjectArticle-5OD6RNVS.mjs +98 -0
  90. package/dist/lib/node-esm/ProjectArticle-5OD6RNVS.mjs.map +7 -0
  91. package/dist/lib/node-esm/ProjectSettings-JQLRY6AS.mjs +118 -0
  92. package/dist/lib/node-esm/ProjectSettings-JQLRY6AS.mjs.map +7 -0
  93. package/dist/lib/node-esm/PromptArticle-OIWAJL46.mjs +74 -0
  94. package/dist/lib/node-esm/PromptArticle-OIWAJL46.mjs.map +7 -0
  95. package/dist/lib/node-esm/PromptList-HDPYYB2R.mjs +56 -0
  96. package/dist/lib/node-esm/PromptList-HDPYYB2R.mjs.map +7 -0
  97. package/dist/lib/node-esm/TracePanel-CZ34U6TD.mjs +408 -0
  98. package/dist/lib/node-esm/TracePanel-CZ34U6TD.mjs.map +7 -0
  99. package/dist/lib/node-esm/TriggerStatus-4TPPGPPG.mjs +106 -0
  100. package/dist/lib/node-esm/TriggerStatus-4TPPGPPG.mjs.map +7 -0
  101. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +23 -0
  102. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +7 -0
  103. package/dist/lib/node-esm/app-graph-builder-7NW24QOO.mjs +256 -0
  104. package/dist/lib/node-esm/app-graph-builder-7NW24QOO.mjs.map +7 -0
  105. package/dist/lib/node-esm/blueprint-definition-SXKMCYS3.mjs +40 -0
  106. package/dist/lib/node-esm/blueprint-definition-SXKMCYS3.mjs.map +7 -0
  107. package/dist/lib/node-esm/blueprints/index.mjs +12 -0
  108. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  109. package/dist/lib/node-esm/chunk-AH2IGRRQ.mjs +34 -0
  110. package/dist/lib/node-esm/chunk-AH2IGRRQ.mjs.map +7 -0
  111. package/dist/lib/node-esm/chunk-JXAI2DNW.mjs +104 -0
  112. package/dist/lib/node-esm/chunk-JXAI2DNW.mjs.map +7 -0
  113. package/dist/lib/node-esm/chunk-KHQM4BYS.mjs +10 -0
  114. package/dist/lib/node-esm/chunk-KHQM4BYS.mjs.map +7 -0
  115. package/dist/lib/node-esm/chunk-KPVPDVSY.mjs +2136 -0
  116. package/dist/lib/node-esm/chunk-KPVPDVSY.mjs.map +7 -0
  117. package/dist/lib/node-esm/chunk-PPNS6AW4.mjs +156 -0
  118. package/dist/lib/node-esm/chunk-PPNS6AW4.mjs.map +7 -0
  119. package/dist/lib/node-esm/{chunk-3Q22TTXW.mjs → chunk-SG27NPDT.mjs} +99 -47
  120. package/dist/lib/node-esm/chunk-SG27NPDT.mjs.map +7 -0
  121. package/dist/lib/node-esm/{chunk-WE6KTH72.mjs → chunk-TEYTGR67.mjs} +3 -3
  122. package/dist/lib/node-esm/chunk-TEYTGR67.mjs.map +7 -0
  123. package/dist/lib/node-esm/chunk-YQJNIYQB.mjs +150 -0
  124. package/dist/lib/node-esm/chunk-YQJNIYQB.mjs.map +7 -0
  125. package/dist/lib/node-esm/create-chat-DBZLK27V.mjs +82 -0
  126. package/dist/lib/node-esm/create-chat-DBZLK27V.mjs.map +7 -0
  127. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +22 -0
  128. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +7 -0
  129. package/dist/lib/node-esm/index.mjs +263 -210
  130. package/dist/lib/node-esm/index.mjs.map +4 -4
  131. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +21 -0
  132. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +7 -0
  133. package/dist/lib/node-esm/markdown-RO7WIR76.mjs +115 -0
  134. package/dist/lib/node-esm/markdown-RO7WIR76.mjs.map +7 -0
  135. package/dist/lib/node-esm/meta.json +1 -1
  136. package/dist/lib/node-esm/on-create-space-7RZULGPS.mjs +24 -0
  137. package/dist/lib/node-esm/on-create-space-7RZULGPS.mjs.map +7 -0
  138. package/dist/lib/node-esm/operation-handler-JKMSHWQF.mjs +18 -0
  139. package/dist/lib/node-esm/operation-handler-JKMSHWQF.mjs.map +7 -0
  140. package/dist/lib/node-esm/operations/index.mjs +14 -0
  141. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  142. package/dist/lib/node-esm/react-surface-NDT545FO.mjs +173 -0
  143. package/dist/lib/node-esm/react-surface-NDT545FO.mjs.map +7 -0
  144. package/dist/lib/node-esm/resolve-navigation-targets-XFZJ2A5H.mjs +24 -0
  145. package/dist/lib/node-esm/resolve-navigation-targets-XFZJ2A5H.mjs.map +7 -0
  146. package/dist/lib/node-esm/run-prompt-in-new-chat-MKDE3P3E.mjs +113 -0
  147. package/dist/lib/node-esm/run-prompt-in-new-chat-MKDE3P3E.mjs.map +7 -0
  148. package/dist/lib/node-esm/set-current-chat-G3UMPQAB.mjs +31 -0
  149. package/dist/lib/node-esm/set-current-chat-G3UMPQAB.mjs.map +7 -0
  150. package/dist/lib/node-esm/settings-I4NYOU5C.mjs +34 -0
  151. package/dist/lib/node-esm/settings-I4NYOU5C.mjs.map +7 -0
  152. package/dist/lib/node-esm/state-GOZALHOZ.mjs +28 -0
  153. package/dist/lib/node-esm/state-GOZALHOZ.mjs.map +7 -0
  154. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs +17 -0
  155. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs.map +7 -0
  156. package/dist/lib/node-esm/types/index.mjs +6 -4
  157. package/dist/lib/node-esm/update-chat-name-TJ3AG762.mjs +37 -0
  158. package/dist/lib/node-esm/update-chat-name-TJ3AG762.mjs.map +7 -0
  159. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  160. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  161. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  162. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  163. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  164. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  165. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  166. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  167. package/dist/types/src/blueprints/blueprint-manager.test.d.ts +2 -0
  168. package/dist/types/src/blueprints/blueprint-manager.test.d.ts.map +1 -0
  169. package/dist/types/src/blueprints/index.d.ts +2 -0
  170. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  171. package/dist/types/src/capabilities/ai-service/ai-service.d.ts +6 -0
  172. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
  173. package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
  174. package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
  175. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  176. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  177. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  178. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  179. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +5 -0
  180. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  181. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +5 -0
  182. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  183. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +7 -0
  184. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
  185. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
  186. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
  187. package/dist/types/src/capabilities/index.d.ts +10 -11
  188. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  189. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
  190. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
  191. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +13 -0
  192. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
  193. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  194. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  195. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  196. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  197. package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
  198. package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
  199. package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
  200. package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
  201. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  202. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  203. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  204. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  205. package/dist/types/src/capabilities/settings/index.d.ts +15 -0
  206. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  207. package/dist/types/src/capabilities/settings/settings.d.ts +18 -0
  208. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  209. package/dist/types/src/capabilities/state/index.d.ts +17 -0
  210. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  211. package/dist/types/src/capabilities/state/state.d.ts +19 -0
  212. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  213. package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
  214. package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
  215. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +6 -0
  216. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
  217. package/dist/types/src/components/Chat/Chat.d.ts +27 -18
  218. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  219. package/dist/types/src/components/Chat/events.d.ts +1 -1
  220. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  221. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +6 -3
  222. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
  223. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  224. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +3 -3
  225. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  226. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
  227. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  228. package/dist/types/src/components/ChatThread/ChatThread.d.ts +3 -3
  229. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  230. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +139 -13
  231. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  232. package/dist/types/src/components/ChatThread/registry.d.ts +1 -1
  233. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
  234. package/dist/types/src/components/ChatThread/sync.d.ts +1 -1
  235. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  236. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +9 -4
  237. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  238. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +130 -5
  239. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  240. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +11 -1
  241. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  242. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +131 -6
  243. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  244. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -1
  245. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +5 -5
  246. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  247. package/dist/types/src/components/Toolbox/Toolbox.d.ts +16 -11
  248. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  249. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +130 -5
  250. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  251. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
  252. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
  253. package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
  254. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
  255. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
  256. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
  257. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
  258. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
  259. package/dist/types/src/components/Typewriter/index.d.ts +2 -0
  260. package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
  261. package/dist/types/src/components/index.d.ts +0 -6
  262. package/dist/types/src/components/index.d.ts.map +1 -1
  263. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts +8 -0
  264. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts.map +1 -0
  265. package/dist/types/src/containers/AssistantSettings/index.d.ts +3 -0
  266. package/dist/types/src/containers/AssistantSettings/index.d.ts.map +1 -0
  267. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  268. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  269. package/dist/types/src/containers/BlueprintArticle/index.d.ts +3 -0
  270. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  271. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +13 -0
  272. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  273. package/dist/types/src/containers/ChatCompanion/index.d.ts +3 -0
  274. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  275. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +20 -0
  276. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  277. package/dist/types/src/containers/ChatContainer/index.d.ts +3 -0
  278. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  279. package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
  280. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  281. package/dist/types/src/containers/ChatDialog/index.d.ts +3 -0
  282. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  283. package/dist/types/src/containers/Project/ProjectArticle.d.ts +7 -0
  284. package/dist/types/src/containers/Project/ProjectArticle.d.ts.map +1 -0
  285. package/dist/types/src/containers/Project/ProjectSettings.d.ts +6 -0
  286. package/dist/types/src/containers/Project/ProjectSettings.d.ts.map +1 -0
  287. package/dist/types/src/containers/Project/index.d.ts +7 -0
  288. package/dist/types/src/containers/Project/index.d.ts.map +1 -0
  289. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
  290. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
  291. package/dist/types/src/containers/PromptArticle/index.d.ts +3 -0
  292. package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
  293. package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
  294. package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
  295. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +445 -0
  296. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
  297. package/dist/types/src/containers/PromptList/index.d.ts +3 -0
  298. package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
  299. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +6 -0
  300. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  301. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  302. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  303. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  304. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  305. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  306. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  307. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
  308. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  309. package/dist/types/src/containers/TriggerStatus/index.d.ts +3 -0
  310. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  311. package/dist/types/src/containers/index.d.ts +12 -0
  312. package/dist/types/src/containers/index.d.ts.map +1 -0
  313. package/dist/types/src/extensions/index.d.ts +2 -0
  314. package/dist/types/src/extensions/index.d.ts.map +1 -0
  315. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  316. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  317. package/dist/types/src/hooks/index.d.ts +1 -1
  318. package/dist/types/src/hooks/index.d.ts.map +1 -1
  319. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -5
  320. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  321. package/dist/types/src/hooks/useChatProcessor.d.ts +2 -1
  322. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  323. package/dist/types/src/hooks/useChatServices.d.ts +4 -5
  324. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  325. package/dist/types/src/hooks/useChatToolbarActions.d.ts +3 -3
  326. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
  327. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  328. package/dist/types/src/hooks/useContextObjects.d.ts +7 -7
  329. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
  330. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  331. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  332. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  333. package/dist/types/src/index.d.ts +1 -1
  334. package/dist/types/src/index.d.ts.map +1 -1
  335. package/dist/types/src/meta.d.ts +2 -2
  336. package/dist/types/src/meta.d.ts.map +1 -1
  337. package/dist/types/src/operations/create-chat.d.ts +5 -0
  338. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  339. package/dist/types/src/operations/definitions.d.ts +102 -0
  340. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  341. package/dist/types/src/operations/index.d.ts +4 -0
  342. package/dist/types/src/operations/index.d.ts.map +1 -0
  343. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  344. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  345. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  346. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  347. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  348. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  349. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  350. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  351. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  352. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  353. package/dist/types/src/processor/processor.d.ts +22 -12
  354. package/dist/types/src/processor/processor.d.ts.map +1 -1
  355. package/dist/types/src/processor/update-name.d.ts +2 -2
  356. package/dist/types/src/processor/update-name.d.ts.map +1 -1
  357. package/dist/types/src/queue-logger.d.ts.map +1 -1
  358. package/dist/types/src/testing/test-generator.d.ts +3 -2
  359. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  360. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  361. package/dist/types/src/translations.d.ts +130 -5
  362. package/dist/types/src/translations.d.ts.map +1 -1
  363. package/dist/types/src/types/Assistant.d.ts +6 -35
  364. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  365. package/dist/types/src/types/capabilities.d.ts +41 -0
  366. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  367. package/dist/types/src/types/events.d.ts +5 -0
  368. package/dist/types/src/types/events.d.ts.map +1 -0
  369. package/dist/types/src/types/index.d.ts +3 -1
  370. package/dist/types/src/types/index.d.ts.map +1 -1
  371. package/dist/types/src/types/service.d.ts +10 -218
  372. package/dist/types/src/types/service.d.ts.map +1 -1
  373. package/dist/types/tsconfig.tsbuildinfo +1 -1
  374. package/package.json +127 -93
  375. package/src/AssistantPlugin.tsx +163 -130
  376. package/src/blueprints/assistant/blueprint.conversations.json +1 -0
  377. package/src/blueprints/assistant/blueprint.test.ts +48 -0
  378. package/src/blueprints/assistant/blueprint.ts +31 -0
  379. package/src/blueprints/assistant/index.ts +5 -0
  380. package/src/blueprints/blueprint-manager.conversations.json +1 -0
  381. package/src/blueprints/blueprint-manager.test.ts +123 -0
  382. package/src/blueprints/index.ts +5 -0
  383. package/src/capabilities/ai-service/ai-service.ts +30 -0
  384. package/src/capabilities/ai-service/index.ts +7 -0
  385. package/src/capabilities/app-graph-builder/app-graph-builder.ts +230 -0
  386. package/src/capabilities/app-graph-builder/index.ts +7 -0
  387. package/src/capabilities/blueprint-definition/blueprint-definition.ts +58 -0
  388. package/src/capabilities/blueprint-definition/index.ts +10 -0
  389. package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +33 -0
  390. package/src/capabilities/edge-model-resolver/index.ts +7 -0
  391. package/src/capabilities/index.ts +10 -14
  392. package/src/capabilities/local-model-resolver/index.ts +7 -0
  393. package/src/capabilities/local-model-resolver/local-model-resolver.ts +38 -0
  394. package/src/capabilities/markdown/index.ts +7 -0
  395. package/src/capabilities/markdown/markdown.ts +39 -0
  396. package/src/capabilities/operation-handler/index.ts +11 -0
  397. package/src/capabilities/operation-handler/operation-handler.ts +16 -0
  398. package/src/capabilities/react-surface/index.ts +7 -0
  399. package/src/capabilities/react-surface/react-surface.tsx +158 -0
  400. package/src/capabilities/settings/index.ts +7 -0
  401. package/src/capabilities/settings/settings.ts +31 -0
  402. package/src/capabilities/state/index.ts +7 -0
  403. package/src/capabilities/state/state.ts +28 -0
  404. package/src/capabilities/toolkit/index.ts +7 -0
  405. package/src/capabilities/toolkit/toolkit.ts +15 -0
  406. package/src/components/Chat/Chat.tsx +125 -96
  407. package/src/components/Chat/events.ts +1 -1
  408. package/src/components/ChatProgress/ChatProgress.tsx +11 -22
  409. package/src/components/ChatPrompt/ChatActions.tsx +10 -2
  410. package/src/components/ChatPrompt/ChatOptions.tsx +102 -72
  411. package/src/components/ChatPrompt/ChatReferences.tsx +17 -8
  412. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
  413. package/src/components/ChatThread/ChatThread.stories.tsx +23 -21
  414. package/src/components/ChatThread/ChatThread.tsx +20 -7
  415. package/src/components/ChatThread/Link.tsx +4 -4
  416. package/src/components/ChatThread/registry.tsx +52 -19
  417. package/src/components/ChatThread/sync.test.ts +15 -5
  418. package/src/components/ChatThread/sync.ts +22 -10
  419. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +5 -9
  420. package/src/components/TemplateEditor/TemplateEditor.tsx +49 -41
  421. package/src/components/TemplateEditor/TemplateForm.stories.tsx +20 -10
  422. package/src/components/TemplateEditor/TemplateForm.tsx +80 -34
  423. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +14 -9
  424. package/src/components/ToolBlock/ToolBlock.tsx +19 -19
  425. package/src/components/Toolbox/Toolbox.stories.tsx +11 -13
  426. package/src/components/Toolbox/Toolbox.tsx +70 -66
  427. package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
  428. package/src/components/Typewriter/Typewriter.stories.tsx +86 -0
  429. package/src/components/Typewriter/Typewriter.tsx +50 -0
  430. package/src/components/Typewriter/assistant-extension.tsx +141 -0
  431. package/src/components/Typewriter/index.ts +5 -0
  432. package/src/components/index.ts +0 -9
  433. package/src/{components → containers}/AssistantSettings/AssistantSettings.tsx +28 -20
  434. package/src/containers/AssistantSettings/index.ts +7 -0
  435. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
  436. package/src/containers/BlueprintArticle/index.ts +7 -0
  437. package/src/containers/ChatCompanion/ChatCompanion.tsx +231 -0
  438. package/src/containers/ChatCompanion/index.ts +7 -0
  439. package/src/containers/ChatContainer/ChatContainer.tsx +92 -0
  440. package/src/containers/ChatContainer/index.ts +7 -0
  441. package/src/{components → containers/ChatDialog}/ChatDialog.tsx +11 -14
  442. package/src/containers/ChatDialog/index.ts +7 -0
  443. package/src/containers/Project/ProjectArticle.tsx +128 -0
  444. package/src/containers/Project/ProjectSettings.tsx +135 -0
  445. package/src/containers/Project/index.ts +16 -0
  446. package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
  447. package/src/containers/PromptArticle/index.ts +7 -0
  448. package/src/containers/PromptList/PromptList.stories.tsx +130 -0
  449. package/src/containers/PromptList/PromptList.tsx +49 -0
  450. package/src/containers/PromptList/index.ts +7 -0
  451. package/src/containers/TracePanel/TracePanel.tsx +347 -0
  452. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  453. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  454. package/src/containers/TracePanel/index.ts +9 -0
  455. package/src/containers/TriggerStatus/TriggerStatus.tsx +144 -0
  456. package/src/containers/TriggerStatus/index.ts +7 -0
  457. package/src/containers/index.ts +17 -0
  458. package/src/extensions/index.ts +5 -0
  459. package/src/extensions/prompt-extension.ts +111 -0
  460. package/src/hooks/index.ts +1 -1
  461. package/src/hooks/useBlueprintRegistry.ts +36 -22
  462. package/src/hooks/useChatProcessor.ts +9 -3
  463. package/src/hooks/useChatServices.ts +13 -25
  464. package/src/hooks/useChatToolbarActions.ts +27 -27
  465. package/src/hooks/useContextBinder.ts +4 -2
  466. package/src/hooks/useContextObjects.ts +16 -24
  467. package/src/hooks/useFilteredTypes.ts +37 -0
  468. package/src/hooks/useReferencesProvider.ts +5 -9
  469. package/src/index.ts +1 -1
  470. package/src/meta.ts +4 -4
  471. package/src/operations/create-chat.ts +75 -0
  472. package/src/operations/definitions.ts +112 -0
  473. package/src/operations/index.ts +16 -0
  474. package/src/operations/on-create-space.ts +24 -0
  475. package/src/operations/resolve-navigation-targets.ts +26 -0
  476. package/src/operations/run-prompt-in-new-chat.ts +107 -0
  477. package/src/operations/set-current-chat.ts +27 -0
  478. package/src/operations/update-chat-name.ts +43 -0
  479. package/src/processor/processor.test.ts +15 -10
  480. package/src/processor/processor.ts +110 -54
  481. package/src/processor/update-name.ts +6 -4
  482. package/src/queue-logger.ts +4 -1
  483. package/src/testing/test-generator.ts +4 -3
  484. package/src/testing/test-sequence.ts +3 -3
  485. package/src/testing/test-services.ts +8 -6
  486. package/src/translations.ts +33 -3
  487. package/src/types/Assistant.ts +4 -39
  488. package/src/types/capabilities.ts +29 -0
  489. package/src/types/events.ts +11 -0
  490. package/src/types/index.ts +5 -1
  491. package/src/types/service.ts +14 -11
  492. package/dist/lib/browser/BlueprintArticle-IMCR3642.mjs +0 -36
  493. package/dist/lib/browser/BlueprintArticle-IMCR3642.mjs.map +0 -7
  494. package/dist/lib/browser/ChatCompanion-JYD2RIBJ.mjs +0 -158
  495. package/dist/lib/browser/ChatCompanion-JYD2RIBJ.mjs.map +0 -7
  496. package/dist/lib/browser/ChatContainer-XCPBWYIR.mjs +0 -77
  497. package/dist/lib/browser/ChatContainer-XCPBWYIR.mjs.map +0 -7
  498. package/dist/lib/browser/ChatDialog-DT7KFCRL.mjs +0 -90
  499. package/dist/lib/browser/ChatDialog-DT7KFCRL.mjs.map +0 -7
  500. package/dist/lib/browser/PromptArticle-45QX25Y5.mjs +0 -59
  501. package/dist/lib/browser/PromptArticle-45QX25Y5.mjs.map +0 -7
  502. package/dist/lib/browser/ai-service-ERTZBTP3.mjs +0 -19
  503. package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +0 -7
  504. package/dist/lib/browser/app-graph-builder-VZEXMDTY.mjs +0 -199
  505. package/dist/lib/browser/app-graph-builder-VZEXMDTY.mjs.map +0 -7
  506. package/dist/lib/browser/blueprint-definition-5FT5JGPY.mjs +0 -12
  507. package/dist/lib/browser/chunk-2BOE3OTW.mjs.map +0 -7
  508. package/dist/lib/browser/chunk-BNTPFZ7O.mjs +0 -229
  509. package/dist/lib/browser/chunk-BNTPFZ7O.mjs.map +0 -7
  510. package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs +0 -335
  511. package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs.map +0 -7
  512. package/dist/lib/browser/chunk-IXIIS4QA.mjs +0 -176
  513. package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +0 -7
  514. package/dist/lib/browser/chunk-LRE4VEZV.mjs +0 -16
  515. package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +0 -7
  516. package/dist/lib/browser/chunk-U62BTGDF.mjs +0 -1929
  517. package/dist/lib/browser/chunk-U62BTGDF.mjs.map +0 -7
  518. package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +0 -7
  519. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +0 -18
  520. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +0 -7
  521. package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs +0 -143
  522. package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs.map +0 -7
  523. package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +0 -17
  524. package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +0 -7
  525. package/dist/lib/browser/react-surface-YCSR2MSR.mjs +0 -98
  526. package/dist/lib/browser/react-surface-YCSR2MSR.mjs.map +0 -7
  527. package/dist/lib/browser/settings-NYJGNQ5I.mjs +0 -23
  528. package/dist/lib/browser/settings-NYJGNQ5I.mjs.map +0 -7
  529. package/dist/lib/browser/state-GG7Z3NB7.mjs +0 -25
  530. package/dist/lib/browser/state-GG7Z3NB7.mjs.map +0 -7
  531. package/dist/lib/browser/toolkit-VYDAWNE4.mjs +0 -17
  532. package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +0 -7
  533. package/dist/lib/node-esm/BlueprintArticle-OL2HUY6Q.mjs +0 -37
  534. package/dist/lib/node-esm/BlueprintArticle-OL2HUY6Q.mjs.map +0 -7
  535. package/dist/lib/node-esm/ChatCompanion-AHKJS25S.mjs +0 -159
  536. package/dist/lib/node-esm/ChatCompanion-AHKJS25S.mjs.map +0 -7
  537. package/dist/lib/node-esm/ChatContainer-K7OGPE3G.mjs +0 -78
  538. package/dist/lib/node-esm/ChatContainer-K7OGPE3G.mjs.map +0 -7
  539. package/dist/lib/node-esm/ChatDialog-QT6ZBX45.mjs +0 -91
  540. package/dist/lib/node-esm/ChatDialog-QT6ZBX45.mjs.map +0 -7
  541. package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs +0 -60
  542. package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs.map +0 -7
  543. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +0 -20
  544. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +0 -7
  545. package/dist/lib/node-esm/app-graph-builder-VRN6ESRR.mjs +0 -200
  546. package/dist/lib/node-esm/app-graph-builder-VRN6ESRR.mjs.map +0 -7
  547. package/dist/lib/node-esm/blueprint-definition-XW6QQVLV.mjs +0 -13
  548. package/dist/lib/node-esm/chunk-3Q22TTXW.mjs.map +0 -7
  549. package/dist/lib/node-esm/chunk-AB74FOA2.mjs +0 -230
  550. package/dist/lib/node-esm/chunk-AB74FOA2.mjs.map +0 -7
  551. package/dist/lib/node-esm/chunk-BHS747K7.mjs +0 -1930
  552. package/dist/lib/node-esm/chunk-BHS747K7.mjs.map +0 -7
  553. package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs +0 -336
  554. package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs.map +0 -7
  555. package/dist/lib/node-esm/chunk-UXTUHH24.mjs +0 -178
  556. package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +0 -7
  557. package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +0 -7
  558. package/dist/lib/node-esm/chunk-YWFWT57N.mjs +0 -17
  559. package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +0 -7
  560. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +0 -19
  561. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +0 -7
  562. package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs +0 -144
  563. package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs.map +0 -7
  564. package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +0 -18
  565. package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +0 -7
  566. package/dist/lib/node-esm/react-surface-CTW44GEM.mjs +0 -99
  567. package/dist/lib/node-esm/react-surface-CTW44GEM.mjs.map +0 -7
  568. package/dist/lib/node-esm/settings-RRHYI5KO.mjs +0 -24
  569. package/dist/lib/node-esm/settings-RRHYI5KO.mjs.map +0 -7
  570. package/dist/lib/node-esm/state-FSUHFMDM.mjs +0 -26
  571. package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +0 -7
  572. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +0 -18
  573. package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +0 -7
  574. package/dist/types/src/capabilities/ai-service.d.ts +0 -4
  575. package/dist/types/src/capabilities/ai-service.d.ts.map +0 -1
  576. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  577. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  578. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -7
  579. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  580. package/dist/types/src/capabilities/capabilities.d.ts +0 -10
  581. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  582. package/dist/types/src/capabilities/edge-model-resolver.d.ts +0 -4
  583. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +0 -1
  584. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  585. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  586. package/dist/types/src/capabilities/local-model-resolver.d.ts +0 -10
  587. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +0 -1
  588. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  589. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  590. package/dist/types/src/capabilities/settings.d.ts +0 -4
  591. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  592. package/dist/types/src/capabilities/state.d.ts +0 -4
  593. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  594. package/dist/types/src/capabilities/toolkit.d.ts +0 -4
  595. package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
  596. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +0 -6
  597. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +0 -1
  598. package/dist/types/src/components/AssistantSettings/index.d.ts +0 -2
  599. package/dist/types/src/components/AssistantSettings/index.d.ts.map +0 -1
  600. package/dist/types/src/components/BlueprintArticle.d.ts +0 -7
  601. package/dist/types/src/components/BlueprintArticle.d.ts.map +0 -1
  602. package/dist/types/src/components/ChatCompanion.d.ts +0 -13
  603. package/dist/types/src/components/ChatCompanion.d.ts.map +0 -1
  604. package/dist/types/src/components/ChatContainer.d.ts +0 -14
  605. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  606. package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
  607. package/dist/types/src/components/ChatThread/reducers.d.ts +0 -40
  608. package/dist/types/src/components/ChatThread/reducers.d.ts.map +0 -1
  609. package/dist/types/src/components/PromptArticle.d.ts +0 -7
  610. package/dist/types/src/components/PromptArticle.d.ts.map +0 -1
  611. package/dist/types/src/events.d.ts +0 -4
  612. package/dist/types/src/events.d.ts.map +0 -1
  613. package/dist/types/src/functions/analysis.d.ts +0 -5
  614. package/dist/types/src/functions/analysis.d.ts.map +0 -1
  615. package/dist/types/src/functions/index.d.ts +0 -4
  616. package/dist/types/src/functions/index.d.ts.map +0 -1
  617. package/dist/types/src/functions/object-list.d.ts +0 -10
  618. package/dist/types/src/functions/object-list.d.ts.map +0 -1
  619. package/dist/types/src/functions/object-load.d.ts +0 -8
  620. package/dist/types/src/functions/object-load.d.ts.map +0 -1
  621. package/dist/types/src/hooks/useItemTypes.d.ts +0 -4
  622. package/dist/types/src/hooks/useItemTypes.d.ts.map +0 -1
  623. package/dist/types/src/types/AssistantAction.d.ts +0 -132
  624. package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
  625. package/src/capabilities/ai-service.ts +0 -27
  626. package/src/capabilities/app-graph-builder.ts +0 -210
  627. package/src/capabilities/blueprint-definition.ts +0 -66
  628. package/src/capabilities/capabilities.ts +0 -17
  629. package/src/capabilities/edge-model-resolver.ts +0 -25
  630. package/src/capabilities/intent-resolver.ts +0 -147
  631. package/src/capabilities/local-model-resolver.ts +0 -30
  632. package/src/capabilities/react-surface.tsx +0 -87
  633. package/src/capabilities/settings.ts +0 -19
  634. package/src/capabilities/state.ts +0 -22
  635. package/src/capabilities/toolkit.ts +0 -17
  636. package/src/components/AssistantSettings/index.ts +0 -5
  637. package/src/components/BlueprintArticle.tsx +0 -29
  638. package/src/components/ChatCompanion.tsx +0 -155
  639. package/src/components/ChatContainer.tsx +0 -61
  640. package/src/components/ChatThread/reducers.ts +0 -151
  641. package/src/components/PromptArticle.tsx +0 -51
  642. package/src/events.ts +0 -11
  643. package/src/functions/analysis.ts +0 -22
  644. package/src/functions/index.ts +0 -7
  645. package/src/functions/object-list.ts +0 -48
  646. package/src/functions/object-load.ts +0 -45
  647. package/src/hooks/useItemTypes.ts +0 -37
  648. package/src/types/AssistantAction.ts +0 -79
  649. /package/dist/lib/browser/{blueprint-definition-5FT5JGPY.mjs.map → ChatContainer-6IA3SIYM.mjs.map} +0 -0
  650. /package/dist/lib/{node-esm/blueprint-definition-XW6QQVLV.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -0,0 +1,2135 @@
1
+ import {
2
+ AiChatProcessor,
3
+ AiServicePresets
4
+ } from "./chunk-RTUG64Q4.mjs";
5
+ import {
6
+ ServiceType
7
+ } from "./chunk-HE6DIUYX.mjs";
8
+ import {
9
+ definitions_exports
10
+ } from "./chunk-L6R55X33.mjs";
11
+ import {
12
+ meta
13
+ } from "./chunk-2VIEX4RA.mjs";
14
+
15
+ // src/hooks/useBlueprintRegistry.ts
16
+ import { useCallback, useEffect, useMemo, useState } from "react";
17
+ import { useCapabilities } from "@dxos/app-framework/ui";
18
+ import { AppCapabilities } from "@dxos/app-toolkit";
19
+ import { Blueprint } from "@dxos/blueprints";
20
+ import { Filter, Obj, Ref } from "@dxos/echo";
21
+ import { useQuery } from "@dxos/react-client/echo";
22
+ import { distinctBy } from "@dxos/util";
23
+ var useBlueprintRegistry = () => {
24
+ const blueprintDefinitions = useCapabilities(AppCapabilities.BlueprintDefinition);
25
+ return useMemo(() => new Blueprint.Registry(blueprintDefinitions.map((blueprint) => blueprint.make())), [
26
+ blueprintDefinitions
27
+ ]);
28
+ };
29
+ var useBlueprints = ({ blueprintRegistry, db }) => {
30
+ const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
31
+ blueprintRegistry
32
+ ]);
33
+ const spaceBlueprints = useQuery(db, Filter.type(Blueprint.Blueprint));
34
+ return useMemo(() => {
35
+ const blueprints = distinctBy([
36
+ ...staticBlueprints,
37
+ ...spaceBlueprints
38
+ ], (b) => b.key);
39
+ blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
40
+ return blueprints;
41
+ }, [
42
+ staticBlueprints,
43
+ spaceBlueprints
44
+ ]);
45
+ };
46
+ var useActiveBlueprints = ({ context }) => {
47
+ const [active, setActive] = useState(/* @__PURE__ */ new Map());
48
+ useEffect(() => {
49
+ if (!context) {
50
+ setActive(/* @__PURE__ */ new Map());
51
+ return;
52
+ }
53
+ const updateActive = () => {
54
+ const blueprints = context.getBlueprints();
55
+ setActive(new Map(blueprints.map((blueprint) => [
56
+ blueprint.key,
57
+ blueprint
58
+ ])));
59
+ };
60
+ updateActive();
61
+ return context.subscribeBlueprints(updateActive);
62
+ }, [
63
+ context
64
+ ]);
65
+ return active;
66
+ };
67
+ var useBlueprintHandlers = ({ db, context, blueprintRegistry }) => {
68
+ const onUpdateBlueprint = useCallback(async (key, checked) => {
69
+ if (!context || !blueprintRegistry) {
70
+ return;
71
+ }
72
+ const objects = await db.query(Filter.type(Blueprint.Blueprint)).run();
73
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
74
+ if (checked) {
75
+ if (!storedBlueprint) {
76
+ const blueprint = blueprintRegistry.getByKey(key);
77
+ if (!blueprint) {
78
+ return;
79
+ }
80
+ storedBlueprint = db.add(Obj.clone(blueprint));
81
+ }
82
+ await context.bind({
83
+ blueprints: [
84
+ Ref.make(storedBlueprint)
85
+ ]
86
+ });
87
+ } else if (storedBlueprint) {
88
+ await context.unbind({
89
+ blueprints: [
90
+ Ref.make(storedBlueprint)
91
+ ]
92
+ });
93
+ }
94
+ }, [
95
+ db,
96
+ context,
97
+ blueprintRegistry
98
+ ]);
99
+ return {
100
+ onUpdateBlueprint
101
+ };
102
+ };
103
+
104
+ // src/hooks/useChatProcessor.ts
105
+ import { RegistryContext } from "@effect-atom/atom-react";
106
+ import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
107
+ import { Ref as Ref2 } from "@dxos/echo";
108
+ import { AiConversation } from "@dxos/assistant";
109
+ import { log } from "@dxos/log";
110
+ import { useAsyncEffect } from "@dxos/react-ui";
111
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
112
+ var useChatProcessor = ({ space, chat, preset, services, blueprintRegistry, settings }) => {
113
+ const observableRegistry = useContext(RegistryContext);
114
+ const [conversation, setConversation] = useState2();
115
+ useAsyncEffect(async () => {
116
+ if (!space || !chat) {
117
+ return;
118
+ }
119
+ const queue = space.queues.get(chat.queue.dxn);
120
+ const conversation2 = new AiConversation({
121
+ queue,
122
+ registry: observableRegistry
123
+ });
124
+ await conversation2.open();
125
+ setConversation(conversation2);
126
+ return () => {
127
+ void conversation2.close();
128
+ setConversation(void 0);
129
+ };
130
+ }, [
131
+ space,
132
+ chat?.queue.dxn.toString()
133
+ ]);
134
+ const processor = useMemo2(() => {
135
+ if (!services || !conversation) {
136
+ return void 0;
137
+ }
138
+ log("creating processor", {
139
+ preset,
140
+ model: preset?.model,
141
+ settings
142
+ }, {
143
+ F: __dxlog_file,
144
+ L: 70,
145
+ S: void 0,
146
+ C: (f, a) => f(...a)
147
+ });
148
+ return new AiChatProcessor(conversation, services, {
149
+ chat: chat ? Ref2.make(chat) : void 0,
150
+ observableRegistry,
151
+ blueprintRegistry,
152
+ model: preset?.model
153
+ });
154
+ }, [
155
+ services,
156
+ conversation,
157
+ blueprintRegistry,
158
+ preset
159
+ ]);
160
+ return processor;
161
+ };
162
+
163
+ // src/hooks/useChatServices.ts
164
+ import * as Effect from "effect/Effect";
165
+ import { useMemo as useMemo3 } from "react";
166
+ import { useCapability } from "@dxos/app-framework/ui";
167
+ import { AutomationCapabilities } from "@dxos/plugin-automation";
168
+ import { getPersonalSpace } from "@dxos/app-toolkit";
169
+ import { useClient } from "@dxos/react-client";
170
+ var useChatServices = ({ id }) => {
171
+ const client = useClient();
172
+ id ??= getPersonalSpace(client)?.id;
173
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
174
+ return useMemo3(() => {
175
+ if (!id) {
176
+ return void 0;
177
+ }
178
+ const runtime2 = runtimeResolver.getRuntime(id);
179
+ return () => runtime2.runPromise(Effect.runtime());
180
+ }, [
181
+ id
182
+ ]);
183
+ };
184
+
185
+ // src/hooks/useChatToolbarActions.ts
186
+ import { Atom as Atom2 } from "@effect-atom/atom-react";
187
+ import * as Effect2 from "effect/Effect";
188
+ import { useMemo as useMemo10 } from "react";
189
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
190
+ import { Chat as Chat2 } from "@dxos/assistant-toolkit";
191
+ import { Filter as Filter6, Obj as Obj6, Query } from "@dxos/echo";
192
+ import { runAndForwardErrors } from "@dxos/effect";
193
+ import { invariant } from "@dxos/invariant";
194
+ import { useQuery as useQuery5 } from "@dxos/react-client/echo";
195
+ import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
196
+
197
+ // src/components/Chat/Chat.tsx
198
+ import { Prec } from "@codemirror/state";
199
+ import { keymap } from "@codemirror/view";
200
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
201
+ import { createContext } from "@radix-ui/react-context";
202
+ import * as Array2 from "effect/Array";
203
+ import * as Option4 from "effect/Option";
204
+ import React9, { useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo9, useRef as useRef3, useState as useState12 } from "react";
205
+ import { Event } from "@dxos/async";
206
+ import { Filter as Filter4, Obj as Obj5 } from "@dxos/echo";
207
+ import { useVoiceInput } from "@dxos/plugin-transcription";
208
+ import { useQuery as useQuery3 } from "@dxos/react-client/echo";
209
+ import { useIdentity } from "@dxos/react-client/halo";
210
+ import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
211
+ import { ChatEditor } from "@dxos/react-ui-chat";
212
+ import { Menu } from "@dxos/react-ui-menu";
213
+ import { Message } from "@dxos/types";
214
+ import { composable, composableProps, mx as mx6 } from "@dxos/ui-theme";
215
+ import { isTruthy } from "@dxos/util";
216
+
217
+ // src/hooks/useContextBinder.ts
218
+ import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
219
+ import { useContext as useContext2, useState as useState3 } from "react";
220
+ import { AiContextBinder } from "@dxos/assistant";
221
+ import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
222
+ var useContextBinder = (queue) => {
223
+ const registry = useContext2(RegistryContext2);
224
+ const [binder, setBinder] = useState3();
225
+ useAsyncEffect2(async () => {
226
+ if (!queue) {
227
+ return;
228
+ }
229
+ const binder2 = new AiContextBinder({
230
+ queue,
231
+ registry
232
+ });
233
+ await binder2.open();
234
+ setBinder(binder2);
235
+ return () => {
236
+ void binder2.close();
237
+ };
238
+ }, [
239
+ queue
240
+ ]);
241
+ return binder;
242
+ };
243
+
244
+ // src/hooks/useContextObjects.ts
245
+ import { Atom, useAtomValue } from "@effect-atom/atom-react";
246
+ import { useCallback as useCallback2 } from "react";
247
+ var emptyObjectsAtom = Atom.make([]);
248
+ var useContextObjects = ({ db, context }) => {
249
+ const objects = useAtomValue(context?.objects ?? emptyObjectsAtom);
250
+ const handleUpdateObject = useCallback2(async (dxn, checked) => {
251
+ if (!db || !context) {
252
+ return;
253
+ }
254
+ const ref = db.makeRef(dxn);
255
+ await ref.load();
256
+ if (checked) {
257
+ await context.bind({
258
+ objects: [
259
+ ref
260
+ ]
261
+ });
262
+ } else {
263
+ await context.unbind({
264
+ objects: [
265
+ ref
266
+ ]
267
+ });
268
+ }
269
+ }, [
270
+ db,
271
+ context
272
+ ]);
273
+ return {
274
+ objects,
275
+ onUpdateObject: handleUpdateObject
276
+ };
277
+ };
278
+
279
+ // src/hooks/useFilteredTypes.ts
280
+ import * as Option from "effect/Option";
281
+ import { useEffect as useEffect2, useState as useState4 } from "react";
282
+ import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
283
+ var useFilteredTypes = (db) => {
284
+ const [types, setTypes] = useState4([]);
285
+ useEffect2(() => {
286
+ if (!db) {
287
+ return;
288
+ }
289
+ return db.schemaRegistry.query({
290
+ location: [
291
+ "database",
292
+ "runtime"
293
+ ]
294
+ }).subscribe((query) => {
295
+ const types2 = Array.from(new Set(query.results.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option.getOrElse(() => false)))));
296
+ setTypes(types2);
297
+ }, {
298
+ fire: true
299
+ });
300
+ }, [
301
+ db
302
+ ]);
303
+ return types;
304
+ };
305
+
306
+ // src/hooks/useFlush.ts
307
+ import { useCallback as useCallback3, useRef, useState as useState5 } from "react";
308
+ var useFlush = (space) => {
309
+ const [state, setState] = useState5("idle");
310
+ const resetTimer = useRef(null);
311
+ const handleFlush = useCallback3(() => {
312
+ if (!space) {
313
+ return;
314
+ }
315
+ queueMicrotask(async () => {
316
+ if (resetTimer.current) {
317
+ clearTimeout(resetTimer.current);
318
+ }
319
+ setState("flushing");
320
+ await space.db.flush();
321
+ setState("flushed");
322
+ resetTimer.current = setTimeout(() => {
323
+ setState("idle");
324
+ resetTimer.current = null;
325
+ }, 1e3);
326
+ });
327
+ }, [
328
+ space
329
+ ]);
330
+ return {
331
+ state,
332
+ handleFlush
333
+ };
334
+ };
335
+
336
+ // src/hooks/useOnline.ts
337
+ import { useState as useState6 } from "react";
338
+ var useOnline = () => {
339
+ const [online, setOnline] = useState6(true);
340
+ return [
341
+ online,
342
+ setOnline
343
+ ];
344
+ };
345
+
346
+ // src/hooks/usePresets.ts
347
+ import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo4, useState as useState7 } from "react";
348
+ var usePresets = (online) => {
349
+ const [preset, setPreset] = useState7();
350
+ const presets = useMemo4(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
351
+ online
352
+ ]);
353
+ const presetOptions = useMemo4(() => presets.map(({ id, model, label }) => ({
354
+ id,
355
+ label: label ?? model
356
+ })), [
357
+ presets
358
+ ]);
359
+ useEffect3(() => {
360
+ setPreset(presets[0]);
361
+ }, [
362
+ presets
363
+ ]);
364
+ const handlePresetChange = useCallback4((id) => {
365
+ const preset2 = presets.find((preset3) => preset3.id === id);
366
+ if (preset2) {
367
+ setPreset(preset2);
368
+ }
369
+ }, [
370
+ presets
371
+ ]);
372
+ return {
373
+ preset,
374
+ presets: presetOptions,
375
+ onPresetChange: handlePresetChange
376
+ };
377
+ };
378
+
379
+ // src/hooks/useReferencesProvider.ts
380
+ import { useMemo as useMemo5 } from "react";
381
+ import { Filter as Filter2, Obj as Obj2 } from "@dxos/echo";
382
+ var useReferencesProvider = (space) => {
383
+ return useMemo5(() => {
384
+ if (!space) {
385
+ return void 0;
386
+ }
387
+ return {
388
+ getReferences: async ({ query }) => {
389
+ const objects = await space.db.query(Filter2.everything()).run();
390
+ return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
391
+ uri: Obj2.getDXN(object).toString(),
392
+ label: Obj2.getLabel(object) ?? ""
393
+ }));
394
+ },
395
+ resolveReference: async ({ uri }) => {
396
+ const object = await space.db.query(Filter2.id(uri)).first();
397
+ return {
398
+ uri,
399
+ label: Obj2.getLabel(object) ?? ""
400
+ };
401
+ }
402
+ };
403
+ }, [
404
+ space
405
+ ]);
406
+ };
407
+ var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
408
+
409
+ // src/components/ChatPrompt/ChatActions.tsx
410
+ import React from "react";
411
+ import { IconButton, useTranslation } from "@dxos/react-ui";
412
+ import { mx } from "@dxos/ui-theme";
413
+ var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
414
+ const { t } = useTranslation(meta.id);
415
+ return /* @__PURE__ */ React.createElement("div", {
416
+ className: mx("flex items-center me-1", classNames)
417
+ }, children, /* @__PURE__ */ React.createElement(IconButton, {
418
+ disabled: !processing,
419
+ variant: "ghost",
420
+ icon: "ph--x--regular",
421
+ iconOnly: true,
422
+ label: t("cancel processing button"),
423
+ onClick: () => onEvent?.({
424
+ type: "cancel"
425
+ })
426
+ }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
427
+ disabled: !processing,
428
+ classNames: mx(recording && "bg-primary-500"),
429
+ variant: "ghost",
430
+ icon: "ph--microphone--regular",
431
+ iconOnly: true,
432
+ noTooltip: true,
433
+ label: t("microphone button"),
434
+ onMouseDown: () => onEvent?.({
435
+ type: "record-start"
436
+ }),
437
+ onMouseUp: () => onEvent?.({
438
+ type: "record-stop"
439
+ }),
440
+ onTouchStart: () => onEvent?.({
441
+ type: "record-start"
442
+ }),
443
+ onTouchEnd: () => onEvent?.({
444
+ type: "record-stop"
445
+ })
446
+ }), /* @__PURE__ */ React.createElement(IconButton, {
447
+ variant: "ghost",
448
+ icon: "ph--wrench--regular",
449
+ iconOnly: true,
450
+ label: t("debug button"),
451
+ onClick: () => onEvent?.({
452
+ type: "toggle-debug"
453
+ })
454
+ }));
455
+ };
456
+
457
+ // src/components/ChatPrompt/ChatOptions.tsx
458
+ import * as Option2 from "effect/Option";
459
+ import React2, { useMemo as useMemo6, useState as useState8 } from "react";
460
+ import { Filter as Filter3, Obj as Obj3, Type } from "@dxos/echo";
461
+ import { Annotation } from "@dxos/echo";
462
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
463
+ import { IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
464
+ import { Listbox, SearchList, useSearchListResults } from "@dxos/react-ui-search";
465
+ import { Tabs } from "@dxos/react-ui-tabs";
466
+ import { getStyles, mx as mx2 } from "@dxos/ui-theme";
467
+ var panelClassNames = "w-[calc(100dvw-.5rem)] sm:w-max md:w-72 max-w-document-width";
468
+ var ChatOptions = ({ db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
469
+ const { t } = useTranslation2(meta.id);
470
+ return /* @__PURE__ */ React2.createElement("div", {
471
+ role: "none",
472
+ className: "flex p-2"
473
+ }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
474
+ asChild: true
475
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
476
+ variant: "ghost",
477
+ icon: "ph--plus--regular",
478
+ iconOnly: true,
479
+ label: t("context objects button")
480
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
481
+ side: "top",
482
+ classNames: panelClassNames
483
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
484
+ db,
485
+ context
486
+ })), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
487
+ asChild: true
488
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
489
+ variant: "ghost",
490
+ icon: "ph--sliders-horizontal--regular",
491
+ iconOnly: true,
492
+ label: t("context settings button")
493
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
494
+ side: "top",
495
+ classNames: panelClassNames
496
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Tabs.Root, {
497
+ orientation: "horizontal",
498
+ defaultValue: "blueprints",
499
+ defaultActivePart: "list",
500
+ tabIndex: -1
501
+ }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
502
+ classNames: mx2("max-h-(--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-h-0 [&_[role="listbox"]]:overflow-y-auto', '[&_[role="tabpanel"]]:min-h-0 [&_[role="tabpanel"]]:px-form-chrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden')
503
+ }, /* @__PURE__ */ React2.createElement(Tabs.Panel, {
504
+ value: "blueprints",
505
+ tabIndex: -1,
506
+ classNames: "dx-focus-ring-inset"
507
+ }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
508
+ blueprintRegistry,
509
+ db,
510
+ context
511
+ })), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
512
+ value: "model",
513
+ tabIndex: -1,
514
+ classNames: "dx-focus-ring-inset px-0!"
515
+ }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
516
+ presets,
517
+ preset,
518
+ onPresetChange
519
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
520
+ classNames: "justify-center p-form-chrome border-y border-subdued-separator order-last"
521
+ }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
522
+ value: "blueprints",
523
+ icon: "ph--blueprint--regular",
524
+ label: t("blueprints in context title")
525
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
526
+ value: "model",
527
+ label: t("chat model title"),
528
+ icon: "ph--cpu--regular"
529
+ }))))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
530
+ };
531
+ var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
532
+ const { t } = useTranslation2(meta.id);
533
+ const blueprints = useBlueprints({
534
+ blueprintRegistry,
535
+ db
536
+ });
537
+ const activeBlueprints = useActiveBlueprints({
538
+ context
539
+ });
540
+ const { onUpdateBlueprint } = useBlueprintHandlers({
541
+ db,
542
+ context,
543
+ blueprintRegistry
544
+ });
545
+ const { results, handleSearch } = useSearchListResults({
546
+ items: blueprints,
547
+ extract: (blueprint) => blueprint.name
548
+ });
549
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
550
+ onSearch: handleSearch
551
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
552
+ classNames: "py-form-chrome"
553
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.map((blueprint) => {
554
+ const isActive = activeBlueprints.has(blueprint.key);
555
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
556
+ classNames: "flex items-center overflow-hidden",
557
+ key: blueprint.key,
558
+ value: blueprint.key,
559
+ label: blueprint.name,
560
+ checked: isActive,
561
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
562
+ });
563
+ }))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
564
+ placeholder: t("search placeholder"),
565
+ classNames: "mb-form-chrome",
566
+ autoFocus: true
567
+ }));
568
+ };
569
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
570
+ return /* @__PURE__ */ React2.createElement(Listbox.Root, {
571
+ value: preset,
572
+ onValueChange: onPresetChange,
573
+ autoFocus: true
574
+ }, presets?.map(({ id, label }) => {
575
+ return /* @__PURE__ */ React2.createElement(Listbox.Option, {
576
+ key: id,
577
+ value: id
578
+ }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
579
+ }));
580
+ };
581
+ var ANY = "__any__";
582
+ var ObjectsPanel = ({ db, context }) => {
583
+ const { t } = useTranslation2(meta.id);
584
+ const types = useFilteredTypes(db);
585
+ const typenames = useMemo6(() => {
586
+ const typenames2 = types.map((type) => {
587
+ const typename2 = Type.getTypename(type);
588
+ return {
589
+ typename: typename2,
590
+ label: t("typename label", {
591
+ ns: typename2,
592
+ defaultValue: typename2
593
+ })
594
+ };
595
+ });
596
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
597
+ return typenames2;
598
+ }, [
599
+ types
600
+ ]);
601
+ const [typename, setTypename] = useState8(ANY);
602
+ const anyFilter = useMemo6(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
603
+ typenames
604
+ ]);
605
+ const objects = useQuery2(db, typename === ANY ? anyFilter : Filter3.typename(typename));
606
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
607
+ db,
608
+ context
609
+ });
610
+ const { results, handleSearch } = useSearchListResults({
611
+ items: objects,
612
+ extract: (object) => Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id
613
+ });
614
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
615
+ onSearch: handleSearch
616
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
617
+ classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
618
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
619
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
620
+ const { icon, hue } = Option2.fromNullable(Obj3.getSchema(object)).pipe(Option2.flatMap(Annotation.IconAnnotation.get), Option2.getOrElse(() => ({
621
+ icon: DEFAULT_OBJECT_ICON,
622
+ hue: void 0
623
+ })));
624
+ const styles = hue ? getStyles(hue) : void 0;
625
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
626
+ classNames: "flex items-center overflow-hidden",
627
+ key: object.id,
628
+ value: object.id,
629
+ icon,
630
+ iconClassNames: styles?.surfaceText,
631
+ label: Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id,
632
+ checked: isActive,
633
+ onSelect: () => onUpdateObject?.(Obj3.getDXN(object), !isActive)
634
+ });
635
+ }) : /* @__PURE__ */ React2.createElement(SearchList.Item, {
636
+ value: "__empty__",
637
+ label: t("no results")
638
+ }))), /* @__PURE__ */ React2.createElement("div", {
639
+ role: "none",
640
+ className: "grid grid-cols-[min-content_1fr] gap-2 px-form-chrome mb-form-chrome"
641
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
642
+ value: typename === ANY ? void 0 : typename,
643
+ onValueChange: setTypename
644
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
645
+ placeholder: t("type filter placeholder")
646
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
647
+ value: ANY
648
+ }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
649
+ key: typename2,
650
+ value: typename2
651
+ }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
652
+ placeholder: t("search placeholder"),
653
+ classNames: "mb-0",
654
+ autoFocus: true
655
+ })));
656
+ };
657
+ var DEFAULT_OBJECT_ICON = "ph--cube--regular";
658
+
659
+ // src/components/ChatPrompt/ChatPresets.tsx
660
+ import React3 from "react";
661
+ import { Select as Select2 } from "@dxos/react-ui";
662
+
663
+ // src/components/ChatPrompt/ChatReferences.tsx
664
+ import * as Option3 from "effect/Option";
665
+ import React4 from "react";
666
+ import { Annotation as Annotation2, Obj as Obj4 } from "@dxos/echo";
667
+ import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
668
+ import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
669
+ var ChatReferences = ({ classNames, context, db }) => {
670
+ const { t } = useTranslation3(meta.id);
671
+ const { objects, onUpdateObject } = useContextObjects({
672
+ db,
673
+ context
674
+ });
675
+ return /* @__PURE__ */ React4.createElement("ul", {
676
+ className: mx3("flex", classNames)
677
+ }, objects.map((obj) => {
678
+ const dxn = Obj4.getDXN(obj);
679
+ const typename = Obj4.getTypename(obj);
680
+ const label = Obj4.getLabel(obj) ?? (typename ? [
681
+ "object name placeholder",
682
+ {
683
+ ns: typename
684
+ }
685
+ ] : obj.id);
686
+ const { icon, hue } = Option3.fromNullable(Obj4.getSchema(obj)).pipe(Option3.flatMap(Annotation2.IconAnnotation.get), Option3.getOrElse(() => ({
687
+ icon: DEFAULT_OBJECT_ICON2,
688
+ hue: void 0
689
+ })));
690
+ const styles = hue ? getStyles2(hue) : void 0;
691
+ return /* @__PURE__ */ React4.createElement("li", {
692
+ key: dxn.toString(),
693
+ className: "dx-tag py-0 ps-2 flex items-center gap-1",
694
+ "data-hue": "neutral"
695
+ }, /* @__PURE__ */ React4.createElement(Icon, {
696
+ icon,
697
+ size: 4,
698
+ classNames: styles?.surfaceText
699
+ }), toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
700
+ icon: "ph--x--bold",
701
+ iconOnly: true,
702
+ variant: "ghost",
703
+ label: t("remove object in context label"),
704
+ classNames: "p-0 hover:bg-transparent",
705
+ size: 3,
706
+ onClick: () => onUpdateObject?.(dxn, false)
707
+ }));
708
+ }));
709
+ };
710
+ var DEFAULT_OBJECT_ICON2 = "ph--cube--regular";
711
+
712
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
713
+ import React5, { useEffect as useEffect4, useState as useState9 } from "react";
714
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
715
+ import { Spinner } from "@dxos/react-ui-sfx";
716
+ import { mx as mx4 } from "@dxos/ui-theme";
717
+ var period = 3e3;
718
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
719
+ const [init, setInit] = useState9(false);
720
+ useEffect4(() => setInit(false), [
721
+ preset
722
+ ]);
723
+ useTimeout(async () => {
724
+ setInit(true);
725
+ }, period / 2, [
726
+ preset
727
+ ]);
728
+ return /* @__PURE__ */ React5.createElement("div", {
729
+ role: "none",
730
+ className: mx4("relative flex", classNames)
731
+ }, /* @__PURE__ */ React5.createElement(Spinner, {
732
+ duration: period,
733
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
734
+ ...props
735
+ }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
736
+ asChild: true,
737
+ content: error.message
738
+ }, /* @__PURE__ */ React5.createElement("div", {
739
+ className: "absolute inset-0"
740
+ })));
741
+ };
742
+
743
+ // src/components/ChatThread/ChatThread.tsx
744
+ import React8, { forwardRef, useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo8, useState as useState11 } from "react";
745
+ import { PublicKey } from "@dxos/keys";
746
+ import { useForwardedRef } from "@dxos/react-ui";
747
+ import { MarkdownStream } from "@dxos/react-ui-components";
748
+ import { mx as mx5 } from "@dxos/ui-theme";
749
+ import { keyToFallback } from "@dxos/util";
750
+
751
+ // src/components/ChatThread/registry.tsx
752
+ import React7 from "react";
753
+ import { log as log2 } from "@dxos/log";
754
+ import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
755
+ import { PromptWidget, ReasoningWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget } from "@dxos/react-ui-components";
756
+ import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
757
+ import { ContentBlock } from "@dxos/types";
758
+ import { getXmlTextChild } from "@dxos/ui-editor";
759
+
760
+ // src/components/ToolBlock/ToolBlock.tsx
761
+ import React6, { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
762
+ import { useTranslation as useTranslation4 } from "@dxos/react-ui";
763
+ import { NumericTabs, TextCrawl, TogglePanel } from "@dxos/react-ui-components";
764
+ import { Json } from "@dxos/react-ui-syntax-highlighter";
765
+ import { isNonNullable, safeParseJson } from "@dxos/util";
766
+ var ToolBlock = ({ view, blocks = [] }) => {
767
+ const { t } = useTranslation4(meta.id);
768
+ const items = useMemo7(() => {
769
+ let lastToolCall;
770
+ const tools = [];
771
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
772
+ switch (block._tag) {
773
+ case "toolCall": {
774
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
775
+ return null;
776
+ }
777
+ const tool = tools.find((tool2) => tool2.name === block.name);
778
+ lastToolCall = {
779
+ tool,
780
+ block
781
+ };
782
+ return {
783
+ title: tool?.description ?? [
784
+ t("tool call label"),
785
+ tool?.name
786
+ ].join(" "),
787
+ content: {
788
+ ...block,
789
+ input: safeParseJson(block.input)
790
+ }
791
+ };
792
+ }
793
+ case "toolResult": {
794
+ if (block.error) {
795
+ return {
796
+ title: t("tool error label"),
797
+ content: block
798
+ };
799
+ }
800
+ const title = lastToolCall?.tool?.description ?? [
801
+ t("tool result label"),
802
+ lastToolCall?.tool?.name
803
+ ].join(" ");
804
+ lastToolCall = void 0;
805
+ return {
806
+ title,
807
+ content: {
808
+ ...block,
809
+ result: safeParseJson(block.result)
810
+ }
811
+ };
812
+ }
813
+ case "stats": {
814
+ if (!lastToolCall) {
815
+ return null;
816
+ }
817
+ return {
818
+ title: t("stats label"),
819
+ content: block
820
+ };
821
+ }
822
+ }
823
+ }).filter(isNonNullable);
824
+ }, [
825
+ blocks
826
+ ]);
827
+ const handleChangeOpen = useCallback5(() => {
828
+ setTimeout(() => {
829
+ view?.requestMeasure();
830
+ }, 1e3);
831
+ }, [
832
+ view
833
+ ]);
834
+ if (!items.length) {
835
+ return null;
836
+ }
837
+ return /* @__PURE__ */ React6.createElement(ToolPanel, {
838
+ items,
839
+ onChangeOpen: handleChangeOpen
840
+ });
841
+ };
842
+ ToolBlock.displayName = "ToolBlock";
843
+ var ToolPanel = ({ items, onChangeOpen }) => {
844
+ const tabsRef = useRef2(null);
845
+ const [selected, setSelected] = useState10(0);
846
+ const [open, setOpen] = useState10(false);
847
+ useEffect5(() => {
848
+ onChangeOpen?.(open);
849
+ if (open) {
850
+ tabsRef.current?.focus();
851
+ }
852
+ }, [
853
+ open,
854
+ onChangeOpen
855
+ ]);
856
+ const handleSelect = useCallback5((index) => {
857
+ setSelected(index);
858
+ }, []);
859
+ return /* @__PURE__ */ React6.createElement(TogglePanel.Root, {
860
+ classNames: "mt-2 w-full rounded-xs",
861
+ open,
862
+ onChangeOpen: setOpen
863
+ }, /* @__PURE__ */ React6.createElement(TogglePanel.Header, {
864
+ classNames: "text-sm text-placeholder"
865
+ }, /* @__PURE__ */ React6.createElement(TextCrawl, {
866
+ key: "status-roll",
867
+ lines: items.map((item) => item.title),
868
+ autoAdvance: true,
869
+ greedy: true
870
+ })), /* @__PURE__ */ React6.createElement(TogglePanel.Content, {
871
+ classNames: "grid grid-cols-[32px_1fr]"
872
+ }, /* @__PURE__ */ React6.createElement(NumericTabs, {
873
+ ref: tabsRef,
874
+ classNames: "p-1",
875
+ length: items.length,
876
+ selected,
877
+ onSelect: handleSelect
878
+ }), /* @__PURE__ */ React6.createElement(Json, {
879
+ data: items[selected]?.content,
880
+ classNames: "p-1 text-xs bg-transparent",
881
+ replacer: {
882
+ maxDepth: 3,
883
+ maxArrayLen: 10,
884
+ maxStringLen: 128
885
+ }
886
+ })));
887
+ };
888
+
889
+ // src/components/ChatThread/registry.tsx
890
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
891
+ var Fallback = ({ _tag, ...props }) => {
892
+ return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
893
+ classNames: "rounded-xs"
894
+ }, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
895
+ classNames: "bg-group-surface"
896
+ }, _tag), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, {
897
+ classNames: "bg-modal-surface"
898
+ }, /* @__PURE__ */ React7.createElement(Json2, {
899
+ classNames: "p-2! text-sm",
900
+ data: props
901
+ })));
902
+ };
903
+ var Summary = ({ text }) => {
904
+ return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
905
+ classNames: "rounded-sm"
906
+ }, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
907
+ classNames: "bg-group-surface"
908
+ }, "Conversation summarized"), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, {
909
+ classNames: "bg-modal-surface"
910
+ }, text));
911
+ };
912
+ var componentRegistry = {
913
+ //
914
+ // Widgets
915
+ //
916
+ prompt: {
917
+ block: true,
918
+ factory: ({ children }) => {
919
+ const text = getXmlTextChild(children);
920
+ return text ? new PromptWidget(text) : null;
921
+ }
922
+ },
923
+ reasoning: {
924
+ block: true,
925
+ factory: ({ children }) => {
926
+ const text = getXmlTextChild(children);
927
+ return text ? new ReasoningWidget(text) : null;
928
+ }
929
+ },
930
+ reference: {
931
+ block: false,
932
+ factory: ({ children, ref }) => {
933
+ const text = getXmlTextChild(children);
934
+ return text && ref ? new ReferenceWidget(text, ref) : null;
935
+ }
936
+ },
937
+ select: {
938
+ block: true,
939
+ factory: ({ children }) => {
940
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
941
+ return options?.length ? new SelectWidget(options) : null;
942
+ }
943
+ },
944
+ suggestion: {
945
+ block: true,
946
+ factory: ({ children }) => {
947
+ const text = getXmlTextChild(children);
948
+ return text ? new SuggestionWidget(text) : null;
949
+ }
950
+ },
951
+ stats: {
952
+ block: true,
953
+ factory: ({ children }) => {
954
+ const text = getXmlTextChild(children);
955
+ return text ? new SummaryWidget(text) : null;
956
+ }
957
+ },
958
+ //
959
+ // React
960
+ //
961
+ toolCall: {
962
+ block: true,
963
+ Component: ToolBlock
964
+ },
965
+ toolResult: {
966
+ block: true,
967
+ Component: Fallback
968
+ },
969
+ toolkit: {
970
+ block: true,
971
+ Component: Fallback
972
+ },
973
+ summary: {
974
+ block: true,
975
+ Component: Summary
976
+ },
977
+ //
978
+ // Fallback
979
+ //
980
+ json: {
981
+ block: true,
982
+ Component: Fallback
983
+ }
984
+ };
985
+ var blockToMarkdown = (context, message, block) => {
986
+ let str = blockToMarkdownImpl(context, message, block);
987
+ if (str && !block.pending) {
988
+ return str += "\n";
989
+ }
990
+ return str;
991
+ };
992
+ var blockToMarkdownImpl = (context, message, block) => {
993
+ log2("blockToMarkdown", {
994
+ block: JSON.stringify(block)
995
+ }, {
996
+ F: __dxlog_file2,
997
+ L: 146,
998
+ S: void 0,
999
+ C: (f, a) => f(...a)
1000
+ });
1001
+ switch (block._tag) {
1002
+ case "text": {
1003
+ if (message.sender.role === "user") {
1004
+ return `<prompt>${block.text}</prompt>`;
1005
+ } else {
1006
+ const text = block.text.trim();
1007
+ if (text.length > 0) {
1008
+ return text;
1009
+ }
1010
+ }
1011
+ break;
1012
+ }
1013
+ case "reference": {
1014
+ const dxn = block.reference.dxn;
1015
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
1016
+ }
1017
+ case "suggestion": {
1018
+ if (block.pending) {
1019
+ return;
1020
+ }
1021
+ return `<suggestion>${block.text}</suggestion>`;
1022
+ }
1023
+ case "select": {
1024
+ if (block.pending || block.options.length === 0) {
1025
+ return;
1026
+ }
1027
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1028
+ }
1029
+ case "toolCall": {
1030
+ context.updateWidget(block.toolCallId, {
1031
+ blocks: [
1032
+ block
1033
+ ]
1034
+ });
1035
+ return `<toolCall id="${block.toolCallId}" />`;
1036
+ }
1037
+ case "toolResult": {
1038
+ context.updateWidget(block.toolCallId, ({ blocks = [] } = {
1039
+ blocks: []
1040
+ }) => ({
1041
+ blocks: [
1042
+ ...blocks,
1043
+ block
1044
+ ]
1045
+ }));
1046
+ break;
1047
+ }
1048
+ case "stats": {
1049
+ return `<stats>${ContentBlock.createStatsMessage(block)}</stats>`;
1050
+ }
1051
+ case "reasoning": {
1052
+ const text = block.reasoningText ?? block.redactedText;
1053
+ if (!text) {
1054
+ return;
1055
+ }
1056
+ return `<reasoning>${text.replace(/\n/g, " ").trim()}</reasoning>`;
1057
+ }
1058
+ case "summary": {
1059
+ return `<summary>${block.content}</summary>`;
1060
+ }
1061
+ default: {
1062
+ return `<json id="${message.id}">
1063
+ ${JSON.stringify(block)}
1064
+ </json>`;
1065
+ }
1066
+ }
1067
+ };
1068
+
1069
+ // src/components/ChatThread/sync.ts
1070
+ import { log as log3 } from "@dxos/log";
1071
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1072
+ var MessageThreadContext = class {
1073
+ _widgetState;
1074
+ constructor(_widgetState) {
1075
+ this._widgetState = _widgetState;
1076
+ }
1077
+ updateWidget(id, value) {
1078
+ this._widgetState?.updateWidget(id, value);
1079
+ }
1080
+ // TODO(burdon): Resolve from hypergraph.
1081
+ getObjectLabel(_id) {
1082
+ return "Object";
1083
+ }
1084
+ };
1085
+ var MessageSyncer = class {
1086
+ _model;
1087
+ _blockRenderer;
1088
+ _initialMessageId;
1089
+ _currentMessageIndex = 0;
1090
+ _currentBlockIndex = 0;
1091
+ _currentBlockContent;
1092
+ _context;
1093
+ constructor(_model, _blockRenderer) {
1094
+ this._model = _model;
1095
+ this._blockRenderer = _blockRenderer;
1096
+ this._context = new MessageThreadContext(this._model);
1097
+ }
1098
+ get context() {
1099
+ return this._context;
1100
+ }
1101
+ reset() {
1102
+ log3("reset", void 0, {
1103
+ F: __dxlog_file3,
1104
+ L: 64,
1105
+ S: this,
1106
+ C: (f, a) => f(...a)
1107
+ });
1108
+ this._initialMessageId = void 0;
1109
+ this._currentMessageIndex = 0;
1110
+ this._currentBlockIndex = 0;
1111
+ this._currentBlockContent = void 0;
1112
+ void this._model.reset("");
1113
+ }
1114
+ /**
1115
+ * Syncs messages with the editor.
1116
+ */
1117
+ append(messages, flush = false) {
1118
+ messages = messages.map((message) => ({
1119
+ ...message,
1120
+ blocks: message.blocks.filter((block) => !block.pending || block._tag === "text")
1121
+ }));
1122
+ if (this._initialMessageId !== messages[0]?.id) {
1123
+ this.reset();
1124
+ this._initialMessageId = messages[0]?.id;
1125
+ }
1126
+ if (flush && this._model.view?.state.doc.length === 0) {
1127
+ const buffer = [];
1128
+ this.process(messages, (content2) => {
1129
+ buffer.push(content2);
1130
+ });
1131
+ const content = buffer.join("");
1132
+ this._model.view?.dispatch({
1133
+ changes: [
1134
+ {
1135
+ from: 0,
1136
+ to: this._model.view?.state.doc.length ?? 0,
1137
+ insert: content
1138
+ }
1139
+ ],
1140
+ selection: {
1141
+ anchor: content.length
1142
+ }
1143
+ });
1144
+ return true;
1145
+ } else {
1146
+ this.process(messages, (content) => {
1147
+ void this._model.append(content);
1148
+ });
1149
+ return false;
1150
+ }
1151
+ }
1152
+ process(messages, append) {
1153
+ let i = this._currentMessageIndex;
1154
+ for (const message of messages.slice(this._currentMessageIndex)) {
1155
+ if (i > this._currentMessageIndex) {
1156
+ this._currentBlockIndex = 0;
1157
+ }
1158
+ this._currentMessageIndex = i;
1159
+ let j = this._currentBlockIndex;
1160
+ for (const block of message.blocks.slice(this._currentBlockIndex)) {
1161
+ this._currentBlockIndex = j;
1162
+ const currentBlockContent = this._blockRenderer(this._context, message, block);
1163
+ if (currentBlockContent) {
1164
+ let content = "";
1165
+ if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
1166
+ content = currentBlockContent.slice(this._currentBlockContent.length);
1167
+ } else {
1168
+ content = currentBlockContent;
1169
+ }
1170
+ this._currentBlockContent = currentBlockContent;
1171
+ append(content);
1172
+ }
1173
+ if (block.pending) {
1174
+ return;
1175
+ } else {
1176
+ this._currentBlockContent = void 0;
1177
+ this._currentBlockIndex++;
1178
+ }
1179
+ j++;
1180
+ }
1181
+ i++;
1182
+ }
1183
+ }
1184
+ };
1185
+
1186
+ // src/components/ChatThread/ChatThread.tsx
1187
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent }, forwardedRef) => {
1188
+ const controllerRef = useForwardedRef(forwardedRef);
1189
+ const [controller, setController] = useState11(null);
1190
+ const refCallback = useCallback6((node) => {
1191
+ controllerRef.current = node;
1192
+ setController(node);
1193
+ }, [
1194
+ controllerRef
1195
+ ]);
1196
+ const userHue = useMemo8(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
1197
+ identity
1198
+ ]);
1199
+ useEffect6(() => {
1200
+ controller?.scrollToBottom();
1201
+ }, [
1202
+ controller,
1203
+ error
1204
+ ]);
1205
+ const syncer = useMemo8(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1206
+ controller
1207
+ ]);
1208
+ useEffect6(() => {
1209
+ const reset = syncer?.append(messages, true);
1210
+ if (reset) {
1211
+ controller?.scrollToBottom("instant");
1212
+ }
1213
+ }, [
1214
+ syncer,
1215
+ messages
1216
+ ]);
1217
+ const handleEvent = useCallback6(({ type, value }) => {
1218
+ switch (type) {
1219
+ case "submit": {
1220
+ value && onEvent?.({
1221
+ type,
1222
+ text: value
1223
+ });
1224
+ break;
1225
+ }
1226
+ }
1227
+ }, [
1228
+ onEvent
1229
+ ]);
1230
+ return /* @__PURE__ */ React8.createElement("div", {
1231
+ role: "none",
1232
+ className: mx5("flex h-full w-full justify-center overflow-hidden", classNames),
1233
+ style: {
1234
+ "--user-fill": `var(--color-${userHue}-fill)`
1235
+ }
1236
+ }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1237
+ ref: refCallback,
1238
+ registry: componentRegistry,
1239
+ cursor,
1240
+ fadeIn,
1241
+ debug,
1242
+ onEvent: handleEvent
1243
+ }));
1244
+ });
1245
+
1246
+ // src/components/Chat/Chat.tsx
1247
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
1248
+ var ChatRoot = ({ children, chat, processor, onEvent, ...props }) => {
1249
+ const [debug, setDebug] = useState12(false);
1250
+ const pending = useAtomValue2(processor.messages);
1251
+ const streaming = useAtomValue2(processor.streaming);
1252
+ const lastPrompt = useRef3(void 0);
1253
+ const storedMessages = useQuery3(chat?.queue?.target, Filter4.type(Message.Message));
1254
+ const messages = useMemo9(() => {
1255
+ return Array2.dedupeWith([
1256
+ ...storedMessages,
1257
+ ...pending
1258
+ ], ({ id: a }, { id: b }) => a === b);
1259
+ }, [
1260
+ storedMessages,
1261
+ pending
1262
+ ]);
1263
+ const event = useMemo9(() => new Event(), []);
1264
+ useEffect7(() => {
1265
+ return event.on((ev) => {
1266
+ switch (ev.type) {
1267
+ case "toggle-debug": {
1268
+ setDebug((debug2) => !debug2);
1269
+ queueMicrotask(async () => {
1270
+ const objects = processor.context.getObjects();
1271
+ const blueprints = processor.context.getBlueprints();
1272
+ const tools = await processor.getTools();
1273
+ const system = await processor.getSystemPrompt();
1274
+ console.log("Chat processor state:", {
1275
+ objects,
1276
+ blueprints
1277
+ });
1278
+ console.log(`
1279
+ ==== System Prompt ====
1280
+ ${system}
1281
+ ==== Tools ====
1282
+ ${Object.values(tools).map((tool) => JSON.stringify(tool, null, 2)).join("\n")}
1283
+ `);
1284
+ });
1285
+ break;
1286
+ }
1287
+ case "submit": {
1288
+ const text = ev.text.trim();
1289
+ if (!streaming && text.length) {
1290
+ lastPrompt.current = ev.text;
1291
+ void processor.request({
1292
+ message: text
1293
+ });
1294
+ }
1295
+ break;
1296
+ }
1297
+ case "retry": {
1298
+ if (!streaming) {
1299
+ void processor.retry();
1300
+ }
1301
+ break;
1302
+ }
1303
+ case "cancel": {
1304
+ if (streaming) {
1305
+ void processor.cancel();
1306
+ if (lastPrompt.current) {
1307
+ event.emit({
1308
+ type: "update-prompt",
1309
+ text: lastPrompt.current
1310
+ });
1311
+ }
1312
+ }
1313
+ break;
1314
+ }
1315
+ }
1316
+ onEvent?.(ev);
1317
+ });
1318
+ }, [
1319
+ event,
1320
+ processor,
1321
+ streaming,
1322
+ onEvent
1323
+ ]);
1324
+ const db = props.db ?? (chat && Obj5.getDatabase(chat));
1325
+ return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1326
+ debug,
1327
+ event,
1328
+ db,
1329
+ chat,
1330
+ messages,
1331
+ processor,
1332
+ ...props
1333
+ }, children);
1334
+ };
1335
+ ChatRoot.displayName = "Chat.Root";
1336
+ var CHAT_VIEWPORT_NAME = "Chat.Viewport";
1337
+ var ChatViewport = composable(({ children, ...props }, forwardedRef) => {
1338
+ return /* @__PURE__ */ React9.createElement("div", {
1339
+ ...composableProps(props, {
1340
+ role: "none",
1341
+ classNames: "dx-expander flex flex-col"
1342
+ }),
1343
+ ref: forwardedRef
1344
+ }, children);
1345
+ });
1346
+ ChatViewport.displayName = CHAT_VIEWPORT_NAME;
1347
+ var CHAT_THREAD_NAME = "Chat.Thread";
1348
+ var ChatThread2 = (props) => {
1349
+ const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
1350
+ const identity = useIdentity();
1351
+ const error = useAtomValue2(processor.error).pipe(Option4.getOrUndefined);
1352
+ const controllerRef = useRef3(null);
1353
+ useEffect7(() => {
1354
+ return event.on((event2) => {
1355
+ switch (event2.type) {
1356
+ case "submit":
1357
+ case "scroll-to-bottom":
1358
+ controllerRef.current?.scrollToBottom();
1359
+ break;
1360
+ case "nav-previous":
1361
+ controllerRef.current?.navigatePrevious();
1362
+ break;
1363
+ case "nav-next":
1364
+ controllerRef.current?.navigateNext();
1365
+ break;
1366
+ }
1367
+ });
1368
+ }, [
1369
+ event
1370
+ ]);
1371
+ const handleEvent = useCallback7((ev) => {
1372
+ event.emit(ev);
1373
+ }, [
1374
+ event
1375
+ ]);
1376
+ if (!identity) {
1377
+ return null;
1378
+ }
1379
+ return /* @__PURE__ */ React9.createElement(ChatThread, {
1380
+ ...props,
1381
+ identity,
1382
+ messages,
1383
+ error,
1384
+ debug,
1385
+ onEvent: handleEvent,
1386
+ ref: controllerRef
1387
+ });
1388
+ };
1389
+ ChatThread2.displayName = CHAT_THREAD_NAME;
1390
+ var CHAT_PROMPT_NAME = "Chat.Prompt";
1391
+ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1392
+ const { t } = useTranslation5(meta.id);
1393
+ const { db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
1394
+ const error = useAtomValue2(processor.error).pipe(Option4.getOrUndefined);
1395
+ const streaming = useAtomValue2(processor.streaming);
1396
+ const active = useAtomValue2(processor.active);
1397
+ const activeRef = useDynamicRef(active);
1398
+ const editorRef = useRef3(null);
1399
+ const [recordingState, setRecordingState] = useState12(false);
1400
+ useEffect7(() => {
1401
+ return event.on((event2) => {
1402
+ switch (event2.type) {
1403
+ case "update-prompt":
1404
+ if (!editorRef.current?.getText()?.length) {
1405
+ editorRef.current?.setText(event2.text);
1406
+ editorRef.current?.focus();
1407
+ }
1408
+ break;
1409
+ case "record-start":
1410
+ setRecordingState(true);
1411
+ break;
1412
+ case "record-stop":
1413
+ setRecordingState(false);
1414
+ break;
1415
+ }
1416
+ });
1417
+ }, [
1418
+ event
1419
+ ]);
1420
+ const { recording } = useVoiceInput({
1421
+ active: recordingState,
1422
+ onUpdate: (text) => {
1423
+ editorRef.current?.setText(text);
1424
+ editorRef.current?.focus();
1425
+ }
1426
+ });
1427
+ const extensions = useMemo9(() => {
1428
+ return [
1429
+ Prec.highest(keymap.of([
1430
+ {
1431
+ key: "Mod-d",
1432
+ preventDefault: true,
1433
+ run: () => {
1434
+ event.emit({
1435
+ type: "toggle-debug"
1436
+ });
1437
+ return true;
1438
+ }
1439
+ },
1440
+ {
1441
+ key: "Mod-ArrowUp",
1442
+ preventDefault: true,
1443
+ run: () => {
1444
+ event.emit({
1445
+ type: "nav-previous"
1446
+ });
1447
+ return true;
1448
+ },
1449
+ shift: () => {
1450
+ event.emit({
1451
+ type: "thread-open"
1452
+ });
1453
+ return true;
1454
+ }
1455
+ },
1456
+ {
1457
+ key: "Mod-ArrowDown",
1458
+ preventDefault: true,
1459
+ run: () => {
1460
+ event.emit({
1461
+ type: "nav-next"
1462
+ });
1463
+ return true;
1464
+ },
1465
+ shift: () => {
1466
+ event.emit({
1467
+ type: "thread-close"
1468
+ });
1469
+ return true;
1470
+ }
1471
+ }
1472
+ ]))
1473
+ ].filter(isTruthy);
1474
+ }, [
1475
+ event,
1476
+ expandable
1477
+ ]);
1478
+ const handleSubmit = useCallback7((text) => {
1479
+ if (!activeRef.current) {
1480
+ event.emit({
1481
+ type: "submit",
1482
+ text
1483
+ });
1484
+ return true;
1485
+ }
1486
+ }, [
1487
+ event
1488
+ ]);
1489
+ const handleEvent = useCallback7((ev) => {
1490
+ event.emit(ev);
1491
+ }, [
1492
+ event
1493
+ ]);
1494
+ return /* @__PURE__ */ React9.createElement("div", {
1495
+ role: "group",
1496
+ className: mx6("flex flex-col w-full dx-density-fine", outline && "bg-group-surface border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded-sm", classNames)
1497
+ }, /* @__PURE__ */ React9.createElement("div", {
1498
+ role: "none",
1499
+ className: "flex p-2 gap-2"
1500
+ }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1501
+ classNames: "p-1",
1502
+ preset,
1503
+ error,
1504
+ processing: streaming
1505
+ }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1506
+ ref: editorRef,
1507
+ autoFocus: true,
1508
+ lineWrapping: true,
1509
+ classNames: "col-span-2 pt-0.5",
1510
+ placeholder: placeholder ?? t("prompt placeholder"),
1511
+ extensions,
1512
+ onSubmit: handleSubmit
1513
+ })), db && settings && /* @__PURE__ */ React9.createElement("div", {
1514
+ role: "none",
1515
+ className: "flex items-center overflow-hidden"
1516
+ }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1517
+ db,
1518
+ blueprintRegistry: processor.blueprintRegistry,
1519
+ context: processor.context,
1520
+ preset,
1521
+ presets,
1522
+ onPresetChange
1523
+ }), /* @__PURE__ */ React9.createElement("div", {
1524
+ role: "none",
1525
+ className: "flex grow overflow-x-auto scrollbar-none"
1526
+ }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1527
+ db,
1528
+ context: processor.context
1529
+ })), /* @__PURE__ */ React9.createElement(ChatActions, {
1530
+ classNames: "col-span-2",
1531
+ microphone: true,
1532
+ recording,
1533
+ processing: streaming,
1534
+ onEvent: handleEvent
1535
+ }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
1536
+ srOnly: true
1537
+ }, t("online switch label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
1538
+ classNames: "mx-2",
1539
+ checked: online,
1540
+ onCheckedChange: onOnlineChange
1541
+ })))));
1542
+ };
1543
+ ChatPrompt.displayName = CHAT_PROMPT_NAME;
1544
+ var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
1545
+ var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
1546
+ const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
1547
+ const menuActions = useChatToolbarActions({
1548
+ chat,
1549
+ companionTo
1550
+ });
1551
+ return /* @__PURE__ */ React9.createElement(Menu.Root, {
1552
+ ...menuActions,
1553
+ attendableId
1554
+ }, /* @__PURE__ */ React9.createElement(Menu.Toolbar, {
1555
+ ...composableProps(props),
1556
+ ref: forwardedRef
1557
+ }));
1558
+ });
1559
+ ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
1560
+ var Chat = {
1561
+ Root: ChatRoot,
1562
+ Viewport: ChatViewport,
1563
+ Thread: ChatThread2,
1564
+ Prompt: ChatPrompt,
1565
+ Toolbar: ChatToolbar
1566
+ };
1567
+
1568
+ // src/components/TemplateEditor/TemplateEditor.tsx
1569
+ import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1570
+ import { composeRefs } from "@radix-ui/react-compose-refs";
1571
+ import React10 from "react";
1572
+ import { createDocAccessor } from "@dxos/echo-db";
1573
+ import { useThemeContext, useTranslation as useTranslation6 } from "@dxos/react-ui";
1574
+ import { useTextEditor } from "@dxos/react-ui-editor";
1575
+ import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
1576
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1577
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1578
+
1579
+ // src/components/TemplateEditor/extensions/handlebars-extension.ts
1580
+ import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
1581
+ import { RangeSetBuilder } from "@codemirror/state";
1582
+ import { Decoration, ViewPlugin, WidgetType, keymap as keymap2 } from "@codemirror/view";
1583
+ import { Domino, mx as mx7 } from "@dxos/ui";
1584
+ var handlebars = (_ = {}) => {
1585
+ return [
1586
+ handlebarsHighlightPlugin,
1587
+ autocompletion({
1588
+ activateOnTyping: true,
1589
+ aboveCursor: true,
1590
+ closeOnBlur: true,
1591
+ override: [
1592
+ handlebarsCompletions
1593
+ ]
1594
+ }),
1595
+ keymap2.of(completionKeymap)
1596
+ ];
1597
+ };
1598
+ var regex = {
1599
+ // {{! comment }}
1600
+ comment: /\{\{!\s*[^}]*\}\}/g,
1601
+ // {{var}}
1602
+ brackets: /\{\{[^}]*\}\}/g,
1603
+ // {{#command}} {{/command}}
1604
+ command: /\{\{[#/]([^}]+)\}\}/g,
1605
+ // {{var}}
1606
+ var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
1607
+ // @dxn:queue:data:xxx
1608
+ dxn: /@?dxn:[\w@:]+/g,
1609
+ // dxos.org/type/xxx
1610
+ url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
1611
+ };
1612
+ var tagPadding = "mx-0.5 px-1 rounded-xs";
1613
+ var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
1614
+ decorations;
1615
+ constructor(view) {
1616
+ this.decorations = this.buildDecorations(view);
1617
+ }
1618
+ update(update) {
1619
+ if (update.docChanged || update.viewportChanged || update.selectionSet) {
1620
+ this.decorations = this.buildDecorations(update.view);
1621
+ }
1622
+ }
1623
+ // NOTE: Decorations may clash with other extensions (e.g., markdown).
1624
+ buildDecorations(view) {
1625
+ const selection = view.state.selection.main;
1626
+ const decorations = [];
1627
+ for (const { from, to } of view.visibleRanges) {
1628
+ const text = view.state.doc.sliceString(from, to);
1629
+ {
1630
+ let match;
1631
+ while ((match = regex.dxn.exec(text)) !== null) {
1632
+ const start = from + match.index;
1633
+ const end = start + match[0].length;
1634
+ const overlaps = selection.to > start && selection.from <= end;
1635
+ if (!overlaps) {
1636
+ decorations.push({
1637
+ from: start,
1638
+ to: end,
1639
+ decoration: Decoration.widget({
1640
+ widget: new DXNWidget(match[0])
1641
+ })
1642
+ });
1643
+ }
1644
+ }
1645
+ }
1646
+ {
1647
+ let match;
1648
+ while ((match = regex.url.exec(text)) !== null) {
1649
+ const start = from + match.index;
1650
+ const end = start + match[0].length;
1651
+ decorations.push({
1652
+ from: start,
1653
+ to: end,
1654
+ decoration: Decoration.mark({
1655
+ class: mx7("dx-tag--blue", tagPadding)
1656
+ })
1657
+ });
1658
+ }
1659
+ }
1660
+ {
1661
+ let match;
1662
+ while ((match = regex.brackets.exec(text)) !== null) {
1663
+ const start = from + match.index;
1664
+ const end = start + match[0].length;
1665
+ decorations.push({
1666
+ from: start,
1667
+ to: end,
1668
+ decoration: Decoration.mark({
1669
+ class: "text-subdued"
1670
+ })
1671
+ });
1672
+ }
1673
+ }
1674
+ {
1675
+ let match;
1676
+ while ((match = regex.command.exec(text)) !== null) {
1677
+ const start = from + match.index + 2;
1678
+ let end = start + match[0].length - 4;
1679
+ const text2 = view.state.doc.sliceString(start, end);
1680
+ const parts = text2.split(/\s+/);
1681
+ if (parts.length > 1) {
1682
+ const idx = start + parts[0].length;
1683
+ decorations.push({
1684
+ from: idx,
1685
+ to: end,
1686
+ decoration: Decoration.mark({
1687
+ class: "text-green-text"
1688
+ })
1689
+ });
1690
+ end = idx;
1691
+ }
1692
+ decorations.push({
1693
+ from: start,
1694
+ to: end,
1695
+ decoration: Decoration.mark({
1696
+ class: "text-blue-text"
1697
+ })
1698
+ });
1699
+ }
1700
+ }
1701
+ {
1702
+ let match;
1703
+ while ((match = regex.var.exec(text)) !== null) {
1704
+ const start = from + match.index + 2;
1705
+ const end = start + match[0].length - 4;
1706
+ decorations.push({
1707
+ from: start,
1708
+ to: end,
1709
+ decoration: Decoration.mark({
1710
+ class: "text-green-text"
1711
+ })
1712
+ });
1713
+ }
1714
+ }
1715
+ }
1716
+ decorations.sort((a, b) => a.from - b.from || a.to - b.to);
1717
+ const builder = new RangeSetBuilder();
1718
+ for (const { from, to, decoration } of decorations) {
1719
+ builder.add(from, to, decoration);
1720
+ }
1721
+ return builder.finish();
1722
+ }
1723
+ }, {
1724
+ decorations: (v) => v.decorations
1725
+ });
1726
+ var DXNWidget = class extends WidgetType {
1727
+ _identifier;
1728
+ constructor(_identifier) {
1729
+ super(), this._identifier = _identifier;
1730
+ }
1731
+ ignoreEvent() {
1732
+ return false;
1733
+ }
1734
+ eq(other) {
1735
+ return this._identifier === other._identifier;
1736
+ }
1737
+ toDOM() {
1738
+ const text = this._identifier.split(":").map((part) => {
1739
+ const len = 16;
1740
+ const plen = 4;
1741
+ if (part.length > len) {
1742
+ return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
1743
+ }
1744
+ return part;
1745
+ }).join(":");
1746
+ return Domino.of("span").classNames(mx7("font-mono dx-tag--blue", tagPadding)).text(text).root;
1747
+ }
1748
+ };
1749
+ var variables = [
1750
+ "this"
1751
+ ];
1752
+ var commands = [
1753
+ "this",
1754
+ "each",
1755
+ "if",
1756
+ "unless",
1757
+ "with"
1758
+ ];
1759
+ function handlebarsCompletions(context) {
1760
+ const match = context.matchBefore(/\{\{[^}]*/);
1761
+ if (!match || match.from === match.to) {
1762
+ return null;
1763
+ }
1764
+ let type = "variable";
1765
+ let text = match.text.slice(2);
1766
+ let from = match.from + 2;
1767
+ let matches = [];
1768
+ if (text.startsWith("#") || text.startsWith("/")) {
1769
+ const idx = text.lastIndexOf(" ");
1770
+ if (idx !== -1) {
1771
+ type = "variable";
1772
+ matches = variables;
1773
+ text = text.slice(idx + 1);
1774
+ from += idx + 1;
1775
+ } else {
1776
+ type = "command";
1777
+ text = text.slice(1);
1778
+ matches = commands;
1779
+ from += 1;
1780
+ }
1781
+ } else {
1782
+ type = "variable";
1783
+ matches = variables;
1784
+ }
1785
+ const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
1786
+ type,
1787
+ label: name
1788
+ }));
1789
+ return {
1790
+ from,
1791
+ options
1792
+ };
1793
+ }
1794
+
1795
+ // src/components/TemplateEditor/extensions/xml-extension.ts
1796
+ import { syntaxTree } from "@codemirror/language";
1797
+ import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
1798
+ import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
1799
+ var xmlDecorator = (_ = {}) => {
1800
+ return [
1801
+ xmlDecoratorPlugin
1802
+ ];
1803
+ };
1804
+ var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
1805
+ decorations;
1806
+ constructor(view) {
1807
+ this.decorations = this.buildDecorations(view);
1808
+ }
1809
+ update(update) {
1810
+ if (update.docChanged || update.viewportChanged) {
1811
+ this.decorations = this.buildDecorations(update.view);
1812
+ }
1813
+ }
1814
+ buildDecorations(view) {
1815
+ const builder = new RangeSetBuilder2();
1816
+ for (const { from, to } of view.visibleRanges) {
1817
+ syntaxTree(view.state).iterate({
1818
+ from,
1819
+ to,
1820
+ enter: (node) => {
1821
+ if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
1822
+ builder.add(node.from, node.to, Decoration2.mark({
1823
+ class: "font-mono text-subdued"
1824
+ }));
1825
+ }
1826
+ }
1827
+ });
1828
+ }
1829
+ return builder.finish();
1830
+ }
1831
+ }, {
1832
+ decorations: (v) => v.decorations
1833
+ });
1834
+
1835
+ // src/components/TemplateEditor/TemplateEditor.tsx
1836
+ var TemplateEditor = composable2(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
1837
+ const { t } = useTranslation6(meta.id);
1838
+ const { themeMode } = useThemeContext();
1839
+ const { parentRef } = useTextEditor(() => {
1840
+ const text = template.source?.target;
1841
+ if (!text) {
1842
+ return {};
1843
+ }
1844
+ return {
1845
+ initialValue: text.content ?? "",
1846
+ extensions: [
1847
+ createDataExtensions({
1848
+ id,
1849
+ text: createDocAccessor(text, [
1850
+ "content"
1851
+ ])
1852
+ }),
1853
+ createBasicExtensions({
1854
+ bracketMatching: false,
1855
+ lineNumbers,
1856
+ lineWrapping: true,
1857
+ placeholder: t("template placeholder")
1858
+ }),
1859
+ createThemeExtensions({
1860
+ themeMode
1861
+ }),
1862
+ createMarkdownExtensions(),
1863
+ decorateMarkdown(),
1864
+ handlebars(),
1865
+ // xml(),
1866
+ // NOTE: Since we're using markdown only HTML nodes are parsed.
1867
+ xmlDecorator(),
1868
+ syntaxHighlighting(defaultHighlightStyle)
1869
+ ].filter(isNonNullable2)
1870
+ };
1871
+ }, [
1872
+ themeMode,
1873
+ template.source?.target,
1874
+ lineNumbers
1875
+ ]);
1876
+ return /* @__PURE__ */ React10.createElement("div", {
1877
+ ...composableProps2(props, {
1878
+ role: "none",
1879
+ classNames: [
1880
+ "h-full overflow-hidden",
1881
+ classNames
1882
+ ]
1883
+ }),
1884
+ ref: composeRefs(parentRef, forwardedRef)
1885
+ });
1886
+ });
1887
+
1888
+ // src/components/Toolbox/Toolbox.tsx
1889
+ import React11, { Fragment, useEffect as useEffect8, useState as useState13 } from "react";
1890
+ import { Operation } from "@dxos/operation";
1891
+ import { log as log4 } from "@dxos/log";
1892
+ import { Filter as Filter5, useQuery as useQuery4 } from "@dxos/react-client/echo";
1893
+ import { ScrollArea } from "@dxos/react-ui";
1894
+ import { composable as composable3, composableProps as composableProps3, mx as mx8 } from "@dxos/ui-theme";
1895
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1896
+ var Toolbox = composable3(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
1897
+ return /* @__PURE__ */ React11.createElement(ScrollArea.Root, {
1898
+ ...composableProps3(props),
1899
+ thin: true,
1900
+ orientation: "vertical",
1901
+ ref: forwardedRef
1902
+ }, /* @__PURE__ */ React11.createElement(ScrollArea.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1903
+ title: "Blueprints",
1904
+ items: blueprints.map(({ name, description, tools }) => ({
1905
+ name,
1906
+ description,
1907
+ subitems: tools.map((toolId) => ({
1908
+ name: `\u2219 ${safeToolId(toolId)}`
1909
+ }))
1910
+ }))
1911
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1912
+ title: "Blueprints",
1913
+ items: activeBlueprints.map(({ target }) => ({
1914
+ name: target?.name ?? "",
1915
+ description: target?.description ?? "",
1916
+ subitems: target?.tools.map((toolId) => ({
1917
+ name: `\u2219 ${safeToolId(toolId)}`
1918
+ }))
1919
+ }))
1920
+ }), services && services.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1921
+ title: "Services",
1922
+ items: services.map(({ service: { serviceId, name, description } }) => ({
1923
+ name: name ?? serviceId,
1924
+ description
1925
+ }))
1926
+ }), functions && functions.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
1927
+ title: "Functions",
1928
+ items: functions.map(({ name, description }) => ({
1929
+ name,
1930
+ description
1931
+ }))
1932
+ })));
1933
+ });
1934
+ Toolbox.displayName = "Toolbox";
1935
+ var Section = ({ title, items, striped }) => {
1936
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1937
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
1938
+ const subGridClassNames = mx8("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
1939
+ return /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement("h1", {
1940
+ className: "px-2 text-sm"
1941
+ }, title), /* @__PURE__ */ React11.createElement("div", {
1942
+ className: gridClassNames
1943
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React11.createElement(Fragment, {
1944
+ key: i
1945
+ }, name && /* @__PURE__ */ React11.createElement("div", {
1946
+ className: subGridClassNames
1947
+ }, /* @__PURE__ */ React11.createElement("div", {
1948
+ className: "truncate text-primary-500"
1949
+ }, name), /* @__PURE__ */ React11.createElement("div", {
1950
+ className: "line-clamp-2"
1951
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React11.createElement("div", {
1952
+ key: i2,
1953
+ className: mx8(subGridClassNames, striped && stripeClassNames)
1954
+ }, /* @__PURE__ */ React11.createElement("div", {
1955
+ className: "truncate"
1956
+ }, name2), /* @__PURE__ */ React11.createElement("div", {
1957
+ className: "line-clamp-3 text-subdued"
1958
+ }, description2)))))));
1959
+ };
1960
+ var ToolboxPanel = ({ classNames, db, processor }) => {
1961
+ const services = useQuery4(db, Filter5.type(ServiceType));
1962
+ const [serviceTools, setServiceTools] = useState13([]);
1963
+ useEffect8(() => {
1964
+ log4("creating service tools...", {
1965
+ services: services.length
1966
+ }, {
1967
+ F: __dxlog_file4,
1968
+ L: 121,
1969
+ S: void 0,
1970
+ C: (f, a) => f(...a)
1971
+ });
1972
+ queueMicrotask(async () => {
1973
+ });
1974
+ }, [
1975
+ services
1976
+ ]);
1977
+ const functions = useQuery4(db, Filter5.type(Operation.PersistentOperation));
1978
+ return /* @__PURE__ */ React11.createElement(Toolbox, {
1979
+ classNames,
1980
+ blueprints: processor?.context.getBlueprints(),
1981
+ services: serviceTools,
1982
+ functions
1983
+ });
1984
+ };
1985
+ var safeToolId = (name) => {
1986
+ return name.split("_").pop();
1987
+ };
1988
+
1989
+ // src/hooks/useChatToolbarActions.ts
1990
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
1991
+ var useChatToolbarActions = ({ chat, companionTo }) => {
1992
+ const { invoke } = useOperationInvoker();
1993
+ const { db } = useChatContext("useChatToolbarActions");
1994
+ const query = companionTo ? Query.select(Filter6.id(companionTo.id)).targetOf(Chat2.CompanionTo).source() : Query.select(Filter6.nothing());
1995
+ const chats = useQuery5(db, query);
1996
+ return useMenuActions(useMemo10(() => {
1997
+ return Atom2.make(() => {
1998
+ const builder = MenuBuilder.make().root({
1999
+ label: [
2000
+ "chat toolbar title",
2001
+ {
2002
+ ns: meta.id
2003
+ }
2004
+ ]
2005
+ }).action("new", {
2006
+ label: [
2007
+ "new thread button",
2008
+ {
2009
+ ns: meta.id
2010
+ }
2011
+ ],
2012
+ icon: "ph--plus--regular",
2013
+ type: "new",
2014
+ disabled: !companionTo
2015
+ }, () => {
2016
+ invariant(companionTo, void 0, {
2017
+ F: __dxlog_file5,
2018
+ L: 53,
2019
+ S: void 0,
2020
+ A: [
2021
+ "companionTo",
2022
+ ""
2023
+ ]
2024
+ });
2025
+ return invoke(definitions_exports.SetCurrentChat, {
2026
+ companionTo,
2027
+ chat: void 0
2028
+ }).pipe(runAndForwardErrors);
2029
+ }).action("rename", {
2030
+ label: [
2031
+ "rename thread button",
2032
+ {
2033
+ ns: meta.id
2034
+ }
2035
+ ],
2036
+ icon: "ph--magic-wand--regular",
2037
+ type: "rename",
2038
+ disabled: !chat
2039
+ }, () => Effect2.gen(function* () {
2040
+ invariant(chat, void 0, {
2041
+ F: __dxlog_file5,
2042
+ L: 70,
2043
+ S: this,
2044
+ A: [
2045
+ "chat",
2046
+ ""
2047
+ ]
2048
+ });
2049
+ yield* invoke(definitions_exports.UpdateChatName, {
2050
+ chat
2051
+ });
2052
+ }).pipe(runAndForwardErrors)).action("branch", {
2053
+ label: [
2054
+ "button branch thread",
2055
+ {
2056
+ ns: meta.id
2057
+ }
2058
+ ],
2059
+ icon: "ph--git-branch--regular",
2060
+ type: "branch",
2061
+ disabled: true
2062
+ }, () => {
2063
+ });
2064
+ if (chats.length > 0) {
2065
+ builder.group("chats", {
2066
+ label: [
2067
+ "chat history label",
2068
+ {
2069
+ ns: meta.id
2070
+ }
2071
+ ],
2072
+ icon: "ph--clock-counter-clockwise--regular",
2073
+ selectCardinality: "single",
2074
+ variant: "dropdownMenu"
2075
+ }, (builder2) => {
2076
+ chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
2077
+ builder2.action(chat2.id, {
2078
+ label: Obj6.getLabel(chat2) ?? [
2079
+ "object name placeholder",
2080
+ {
2081
+ ns: Chat2.Chat.typename
2082
+ }
2083
+ ]
2084
+ }, () => Effect2.gen(function* () {
2085
+ invariant(companionTo, void 0, {
2086
+ F: __dxlog_file5,
2087
+ L: 106,
2088
+ S: this,
2089
+ A: [
2090
+ "companionTo",
2091
+ ""
2092
+ ]
2093
+ });
2094
+ yield* invoke(definitions_exports.SetCurrentChat, {
2095
+ companionTo,
2096
+ chat: chat2
2097
+ });
2098
+ }).pipe(runAndForwardErrors));
2099
+ });
2100
+ });
2101
+ }
2102
+ return builder.build();
2103
+ });
2104
+ }, [
2105
+ chats.length,
2106
+ db?.spaceId,
2107
+ companionTo?.id,
2108
+ chat?.id,
2109
+ invoke
2110
+ ]));
2111
+ };
2112
+
2113
+ export {
2114
+ useBlueprintRegistry,
2115
+ useBlueprints,
2116
+ useActiveBlueprints,
2117
+ useBlueprintHandlers,
2118
+ useChatProcessor,
2119
+ useChatServices,
2120
+ useChatToolbarActions,
2121
+ useContextBinder,
2122
+ useContextObjects,
2123
+ useFilteredTypes,
2124
+ useFlush,
2125
+ useOnline,
2126
+ usePresets,
2127
+ useReferencesProvider,
2128
+ ChatContextProvider,
2129
+ useChatContext,
2130
+ Chat,
2131
+ TemplateEditor,
2132
+ Toolbox,
2133
+ ToolboxPanel
2134
+ };
2135
+ //# sourceMappingURL=chunk-RI3GWI6T.mjs.map