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