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