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