@dxos/plugin-assistant 0.8.4-main.2e9d522 → 0.8.4-main.3eb6e50203

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