@dxos/plugin-assistant 0.8.4-main.c1de068 → 0.8.4-main.c351d160a8

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