@dxos/plugin-assistant 0.8.3 → 0.8.4-main.1c7ec43d41

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 (853) hide show
  1. package/dist/lib/browser/AssistantSettings-GG52BLKS.mjs +40 -0
  2. package/dist/lib/browser/AssistantSettings-GG52BLKS.mjs.map +7 -0
  3. package/dist/lib/browser/blueprints/index.mjs +31 -0
  4. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-DVOOFAWU.mjs +175 -0
  6. package/dist/lib/browser/chunk-DVOOFAWU.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  8. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-QZERAFAR.mjs +195 -0
  10. package/dist/lib/browser/chunk-QZERAFAR.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-RSLHZTJH.mjs +2253 -0
  12. package/dist/lib/browser/chunk-RSLHZTJH.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-RYVWX6AD.mjs +932 -0
  14. package/dist/lib/browser/chunk-RYVWX6AD.mjs.map +7 -0
  15. package/dist/lib/browser/cli/index.mjs +73 -0
  16. package/dist/lib/browser/cli/index.mjs.map +7 -0
  17. package/dist/lib/browser/components/index.mjs +20 -0
  18. package/dist/lib/browser/components/index.mjs.map +7 -0
  19. package/dist/lib/browser/create-chat-E2ZLVTLP.mjs +73 -0
  20. package/dist/lib/browser/create-chat-E2ZLVTLP.mjs.map +7 -0
  21. package/dist/lib/browser/ensure-companion-chat-5TPMUPUL.mjs +65 -0
  22. package/dist/lib/browser/ensure-companion-chat-5TPMUPUL.mjs.map +7 -0
  23. package/dist/lib/browser/hooks/index.mjs +39 -0
  24. package/dist/lib/browser/hooks/index.mjs.map +7 -0
  25. package/dist/lib/browser/index.mjs +68 -264
  26. package/dist/lib/browser/index.mjs.map +4 -4
  27. package/dist/lib/browser/meta.json +1 -1
  28. package/dist/lib/browser/on-create-space-4J3KTNAJ.mjs +22 -0
  29. package/dist/lib/browser/on-create-space-4J3KTNAJ.mjs.map +7 -0
  30. package/dist/lib/browser/operations/index.mjs +13 -0
  31. package/dist/lib/browser/operations/index.mjs.map +7 -0
  32. package/dist/lib/browser/resolve-navigation-targets-3ZPQE6SZ.mjs +22 -0
  33. package/dist/lib/browser/resolve-navigation-targets-3ZPQE6SZ.mjs.map +7 -0
  34. package/dist/lib/browser/run-prompt-in-new-chat-5Y5CWP6Y.mjs +106 -0
  35. package/dist/lib/browser/run-prompt-in-new-chat-5Y5CWP6Y.mjs.map +7 -0
  36. package/dist/lib/browser/set-current-chat-JCY2THT3.mjs +54 -0
  37. package/dist/lib/browser/set-current-chat-JCY2THT3.mjs.map +7 -0
  38. package/dist/lib/browser/translations.mjs +173 -0
  39. package/dist/lib/browser/translations.mjs.map +7 -0
  40. package/dist/lib/browser/types/index.mjs +8 -22
  41. package/dist/lib/browser/update-chat-name-VWKNUON7.mjs +56 -0
  42. package/dist/lib/browser/update-chat-name-VWKNUON7.mjs.map +7 -0
  43. package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs +41 -0
  44. package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs.map +7 -0
  45. package/dist/lib/node-esm/blueprints/index.mjs +32 -0
  46. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-BHBN2PFD.mjs +2255 -0
  48. package/dist/lib/node-esm/chunk-BHBN2PFD.mjs.map +7 -0
  49. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  50. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  51. package/dist/lib/node-esm/chunk-MBDVPB4V.mjs +176 -0
  52. package/dist/lib/node-esm/chunk-MBDVPB4V.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-WTT4XU46.mjs +196 -0
  54. package/dist/lib/node-esm/chunk-WTT4XU46.mjs.map +7 -0
  55. package/dist/lib/node-esm/chunk-Y2HSA4US.mjs +933 -0
  56. package/dist/lib/node-esm/chunk-Y2HSA4US.mjs.map +7 -0
  57. package/dist/lib/node-esm/cli/index.mjs +74 -0
  58. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  59. package/dist/lib/node-esm/components/index.mjs +21 -0
  60. package/dist/lib/node-esm/components/index.mjs.map +7 -0
  61. package/dist/lib/node-esm/create-chat-UQQ3542N.mjs +74 -0
  62. package/dist/lib/node-esm/create-chat-UQQ3542N.mjs.map +7 -0
  63. package/dist/lib/node-esm/ensure-companion-chat-T4YCTT73.mjs +66 -0
  64. package/dist/lib/node-esm/ensure-companion-chat-T4YCTT73.mjs.map +7 -0
  65. package/dist/lib/node-esm/hooks/index.mjs +40 -0
  66. package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
  67. package/dist/lib/node-esm/index.mjs +68 -264
  68. package/dist/lib/node-esm/index.mjs.map +4 -4
  69. package/dist/lib/node-esm/meta.json +1 -1
  70. package/dist/lib/node-esm/on-create-space-M63UBTTT.mjs +23 -0
  71. package/dist/lib/node-esm/on-create-space-M63UBTTT.mjs.map +7 -0
  72. package/dist/lib/node-esm/operations/index.mjs +14 -0
  73. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  74. package/dist/lib/node-esm/resolve-navigation-targets-HO77CAFT.mjs +23 -0
  75. package/dist/lib/node-esm/resolve-navigation-targets-HO77CAFT.mjs.map +7 -0
  76. package/dist/lib/node-esm/run-prompt-in-new-chat-V6VQJ3GL.mjs +107 -0
  77. package/dist/lib/node-esm/run-prompt-in-new-chat-V6VQJ3GL.mjs.map +7 -0
  78. package/dist/lib/node-esm/set-current-chat-FIGKWDTF.mjs +55 -0
  79. package/dist/lib/node-esm/set-current-chat-FIGKWDTF.mjs.map +7 -0
  80. package/dist/lib/node-esm/translations.mjs +174 -0
  81. package/dist/lib/node-esm/translations.mjs.map +7 -0
  82. package/dist/lib/node-esm/types/index.mjs +8 -22
  83. package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs +57 -0
  84. package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs.map +7 -0
  85. package/dist/types/src/AssistantPlugin.d.ts +3 -1
  86. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  87. package/dist/types/src/AssistantPlugin.node.d.ts +4 -0
  88. package/dist/types/src/AssistantPlugin.node.d.ts.map +1 -0
  89. package/dist/types/src/AssistantPlugin.test.d.ts +2 -0
  90. package/dist/types/src/AssistantPlugin.test.d.ts.map +1 -0
  91. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  92. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  93. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  94. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  95. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  96. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  97. package/dist/types/src/blueprints/index.d.ts +2 -0
  98. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/ai-service.d.ts +6 -0
  100. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  102. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  103. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  104. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
  106. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/create-object.d.ts +31 -0
  108. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/edge-model-resolver.d.ts +7 -0
  110. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/index.d.ts +55 -6
  112. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  113. package/dist/types/src/capabilities/local-model-resolver.d.ts +16 -0
  114. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/markdown.d.ts +5 -0
  116. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/migrations.d.ts +5 -0
  118. package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  120. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  122. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  123. package/dist/types/src/capabilities/settings.d.ts +4 -2
  124. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  125. package/dist/types/src/capabilities/state.d.ts +21 -0
  126. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/toolkit.d.ts +6 -0
  128. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  129. package/dist/types/src/cli/index.d.ts +2 -0
  130. package/dist/types/src/cli/index.d.ts.map +1 -0
  131. package/dist/types/src/cli/plugin.d.ts +10 -0
  132. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  133. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -4
  134. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  135. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -0
  136. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
  137. package/dist/types/src/components/AssistantSettings/index.d.ts +1 -1
  138. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
  139. package/dist/types/src/components/Chat/Chat.d.ts +54 -0
  140. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
  141. package/dist/types/src/components/Chat/context.d.ts +29 -0
  142. package/dist/types/src/components/Chat/context.d.ts.map +1 -0
  143. package/dist/types/src/components/Chat/events.d.ts +39 -0
  144. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  145. package/dist/types/src/components/Chat/index.d.ts +3 -0
  146. package/dist/types/src/components/Chat/index.d.ts.map +1 -0
  147. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +12 -0
  148. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatPrompt/ChatMcpErrors.d.ts +12 -0
  150. package/dist/types/src/components/ChatPrompt/ChatMcpErrors.d.ts.map +1 -0
  151. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +24 -0
  152. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  153. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
  154. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
  155. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  156. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  157. package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts +28 -0
  158. package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts.map +1 -0
  159. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +10 -0
  160. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
  161. package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts +20 -0
  162. package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts.map +1 -0
  163. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +10 -0
  164. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
  165. package/dist/types/src/components/ChatPrompt/index.d.ts +9 -0
  166. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
  167. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts +14 -0
  168. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts.map +1 -0
  169. package/dist/types/src/components/ChatThread/ChatThread.d.ts +24 -0
  170. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
  171. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +36 -0
  172. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
  173. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  174. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  175. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts +42 -0
  176. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
  177. package/dist/types/src/components/ChatThread/index.d.ts +2 -0
  178. package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
  179. package/dist/types/src/components/ChatThread/registry.d.ts +29 -0
  180. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  181. package/dist/types/src/components/ChatThread/sync.d.ts +69 -0
  182. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  183. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  184. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  185. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
  186. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
  187. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
  188. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
  189. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
  190. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
  191. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
  192. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
  193. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts +18 -0
  194. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -0
  195. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
  196. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
  197. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
  198. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
  199. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
  200. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
  201. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +12 -0
  202. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -0
  203. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
  204. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
  205. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
  206. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
  207. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
  208. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
  209. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts +15 -0
  210. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
  211. package/dist/types/src/components/ChatThread/widgets/defaults.d.ts +5 -0
  212. package/dist/types/src/components/ChatThread/widgets/defaults.d.ts.map +1 -0
  213. package/dist/types/src/components/ChatThread/widgets/index.d.ts +10 -0
  214. package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
  215. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +11 -0
  216. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
  217. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +7 -0
  218. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
  219. package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
  220. package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
  221. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +9 -11
  222. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  223. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +13 -7
  224. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  225. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +16 -6
  226. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  227. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +11 -3
  228. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  229. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
  230. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  231. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  232. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  233. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  234. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  235. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +12 -0
  236. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  237. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  238. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  239. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  240. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  241. package/dist/types/src/components/Toolbox/Toolbox.d.ts +17 -14
  242. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  243. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +14 -5
  244. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  245. package/dist/types/src/components/index.d.ts +4 -15
  246. package/dist/types/src/components/index.d.ts.map +1 -1
  247. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
  248. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
  249. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
  250. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
  251. package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
  252. package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
  253. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
  254. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
  255. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
  256. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
  257. package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
  258. package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
  259. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  260. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  261. package/dist/types/src/containers/BlueprintArticle/index.d.ts +2 -0
  262. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  263. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +18 -0
  264. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  265. package/dist/types/src/containers/ChatCompanion/index.d.ts +2 -0
  266. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  267. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +12 -0
  268. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  269. package/dist/types/src/containers/ChatContainer/index.d.ts +2 -0
  270. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  271. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts +7 -0
  272. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  273. package/dist/types/src/containers/ChatDialog/index.d.ts +2 -0
  274. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  275. package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts +6 -0
  276. package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -0
  277. package/dist/types/src/containers/RoutineArticle/index.d.ts +2 -0
  278. package/dist/types/src/containers/RoutineArticle/index.d.ts.map +1 -0
  279. package/dist/types/src/containers/RoutineList/RoutineList.d.ts +6 -0
  280. package/dist/types/src/containers/RoutineList/RoutineList.d.ts.map +1 -0
  281. package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts +21 -0
  282. package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts.map +1 -0
  283. package/dist/types/src/containers/RoutineList/index.d.ts +2 -0
  284. package/dist/types/src/containers/RoutineList/index.d.ts.map +1 -0
  285. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +8 -0
  286. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  287. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +13 -0
  288. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -0
  289. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  290. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  291. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  292. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  293. package/dist/types/src/containers/TracePanel/execution-graph.d.ts +97 -0
  294. package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
  295. package/dist/types/src/containers/TracePanel/execution-graph.test.d.ts +2 -0
  296. package/dist/types/src/containers/TracePanel/execution-graph.test.d.ts.map +1 -0
  297. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  298. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  299. package/dist/types/src/containers/TracePanel/testing/index.d.ts +3 -0
  300. package/dist/types/src/containers/TracePanel/testing/index.d.ts.map +1 -0
  301. package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts +14 -0
  302. package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts.map +1 -0
  303. package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts +12 -0
  304. package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts.map +1 -0
  305. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +5 -0
  306. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  307. package/dist/types/src/containers/TriggerStatus/index.d.ts +2 -0
  308. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  309. package/dist/types/src/containers/index.d.ts +12 -0
  310. package/dist/types/src/containers/index.d.ts.map +1 -0
  311. package/dist/types/src/extensions/index.d.ts +2 -0
  312. package/dist/types/src/extensions/index.d.ts.map +1 -0
  313. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  314. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  315. package/dist/types/src/hooks/index.d.ts +12 -5
  316. package/dist/types/src/hooks/index.d.ts.map +1 -1
  317. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  318. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  319. package/dist/types/src/hooks/useChatKeymap.d.ts +12 -0
  320. package/dist/types/src/hooks/useChatKeymap.d.ts.map +1 -0
  321. package/dist/types/src/hooks/useChatProcessor.d.ts +13 -11
  322. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  323. package/dist/types/src/hooks/useChatServices.d.ts +10 -0
  324. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  325. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  326. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  327. package/dist/types/src/hooks/useContextBinder.d.ts +5 -0
  328. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  329. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  330. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  331. package/dist/types/src/hooks/useDebug.d.ts +10 -0
  332. package/dist/types/src/hooks/useDebug.d.ts.map +1 -0
  333. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  334. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  335. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  336. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  337. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  338. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  339. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  340. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  341. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  342. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  343. package/dist/types/src/index.d.ts +4 -5
  344. package/dist/types/src/index.d.ts.map +1 -1
  345. package/dist/types/src/meta.d.ts +5 -4
  346. package/dist/types/src/meta.d.ts.map +1 -1
  347. package/dist/types/src/operations/create-chat.d.ts +5 -0
  348. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  349. package/dist/types/src/operations/definitions.d.ts +142 -0
  350. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  351. package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
  352. package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
  353. package/dist/types/src/operations/index.d.ts +4 -0
  354. package/dist/types/src/operations/index.d.ts.map +1 -0
  355. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  356. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  357. package/dist/types/src/operations/prompt.test.d.ts +2 -0
  358. package/dist/types/src/operations/prompt.test.d.ts.map +1 -0
  359. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  360. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  361. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  362. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  363. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  364. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  365. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  366. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  367. package/dist/types/src/processor/index.d.ts +3 -0
  368. package/dist/types/src/processor/index.d.ts.map +1 -0
  369. package/dist/types/src/processor/presets.d.ts +13 -0
  370. package/dist/types/src/processor/presets.d.ts.map +1 -0
  371. package/dist/types/src/processor/processor.d.ts +98 -0
  372. package/dist/types/src/processor/processor.d.ts.map +1 -0
  373. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  374. package/dist/types/src/queue-logger.d.ts +5 -5
  375. package/dist/types/src/queue-logger.d.ts.map +1 -1
  376. package/dist/types/src/testing/index.d.ts +3 -2
  377. package/dist/types/src/testing/index.d.ts.map +1 -1
  378. package/dist/types/src/testing/test-generator.d.ts +8 -0
  379. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  380. package/dist/types/src/testing/test-generator.test.d.ts +2 -0
  381. package/dist/types/src/testing/test-generator.test.d.ts.map +1 -0
  382. package/dist/types/src/testing/test-sequence.d.ts +4 -0
  383. package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
  384. package/dist/types/src/testing/test-services.d.ts +2 -2
  385. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  386. package/dist/types/src/testing/test-trace.d.ts +5 -0
  387. package/dist/types/src/testing/test-trace.d.ts.map +1 -0
  388. package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
  389. package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
  390. package/dist/types/src/translations.d.ts +2 -116
  391. package/dist/types/src/translations.d.ts.map +1 -1
  392. package/dist/types/src/types/Assistant.d.ts +36 -0
  393. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  394. package/dist/types/src/types/Settings.d.ts +26 -0
  395. package/dist/types/src/types/Settings.d.ts.map +1 -0
  396. package/dist/types/src/types/capabilities.d.ts +32 -0
  397. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  398. package/dist/types/src/types/events.d.ts +5 -0
  399. package/dist/types/src/types/events.d.ts.map +1 -0
  400. package/dist/types/src/types/index.d.ts +4 -3
  401. package/dist/types/src/types/index.d.ts.map +1 -1
  402. package/dist/types/src/types/service.d.ts +14 -213
  403. package/dist/types/src/types/service.d.ts.map +1 -1
  404. package/dist/types/tsconfig.tsbuildinfo +1 -1
  405. package/package.json +173 -99
  406. package/src/AssistantPlugin.node.ts +44 -0
  407. package/src/AssistantPlugin.test.ts +35 -0
  408. package/src/AssistantPlugin.tsx +118 -116
  409. package/src/blueprints/assistant/blueprint.test.ts +46 -0
  410. package/src/blueprints/assistant/blueprint.ts +31 -0
  411. package/src/blueprints/assistant/index.ts +5 -0
  412. package/src/{experimental/transcription → blueprints}/index.ts +2 -0
  413. package/src/capabilities/ai-service.ts +30 -0
  414. package/src/capabilities/app-graph-builder.ts +178 -233
  415. package/src/capabilities/blueprint-definition.ts +56 -0
  416. package/src/capabilities/companion-chat-provisioner.ts +164 -0
  417. package/src/capabilities/create-object.ts +107 -0
  418. package/src/capabilities/edge-model-resolver.ts +33 -0
  419. package/src/capabilities/index.ts +23 -8
  420. package/src/capabilities/local-model-resolver.ts +48 -0
  421. package/src/capabilities/markdown.ts +40 -0
  422. package/src/capabilities/migrations.ts +28 -0
  423. package/src/capabilities/operation-handler.ts +16 -0
  424. package/src/capabilities/react-surface.tsx +153 -123
  425. package/src/capabilities/settings.ts +24 -12
  426. package/src/capabilities/state.ts +35 -0
  427. package/src/capabilities/toolkit.ts +13 -0
  428. package/src/cli/index.ts +5 -0
  429. package/src/cli/plugin.ts +83 -0
  430. package/src/components/AssistantSettings/AssistantSettings.stories.tsx +35 -0
  431. package/src/components/AssistantSettings/AssistantSettings.tsx +34 -96
  432. package/src/components/AssistantSettings/index.ts +2 -2
  433. package/src/components/Chat/Chat.tsx +270 -0
  434. package/src/components/Chat/context.ts +39 -0
  435. package/src/components/Chat/events.ts +63 -0
  436. package/src/components/Chat/index.ts +7 -0
  437. package/src/components/ChatPrompt/ChatActions.tsx +75 -0
  438. package/src/components/ChatPrompt/ChatMcpErrors.tsx +50 -0
  439. package/src/components/ChatPrompt/ChatOptions.stories.tsx +136 -0
  440. package/src/components/ChatPrompt/ChatOptions.tsx +444 -0
  441. package/src/components/ChatPrompt/ChatPresets.tsx +29 -0
  442. package/src/components/ChatPrompt/ChatPrompt.tsx +182 -0
  443. package/src/components/ChatPrompt/ChatReferences.tsx +57 -0
  444. package/src/components/ChatPrompt/ChatStatus.tsx +123 -0
  445. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +42 -0
  446. package/src/components/ChatPrompt/index.ts +12 -0
  447. package/src/components/ChatThread/Anchor.stories.tsx +95 -0
  448. package/src/components/ChatThread/ChatThread.stories.tsx +143 -0
  449. package/src/components/ChatThread/ChatThread.tsx +113 -0
  450. package/src/components/ChatThread/DEBUG.md +41 -0
  451. package/src/components/ChatThread/Link.tsx +26 -0
  452. package/src/components/ChatThread/MarkdownStream.stories.tsx +281 -0
  453. package/src/components/{AmbientDialog → ChatThread}/index.ts +1 -1
  454. package/src/components/ChatThread/registry.tsx +290 -0
  455. package/src/components/ChatThread/sync.test.ts +257 -0
  456. package/src/components/ChatThread/sync.ts +150 -0
  457. package/src/components/ChatThread/testing/reasoning.md +25 -0
  458. package/src/components/ChatThread/testing/thinking.md +21 -0
  459. package/src/components/ChatThread/testing/thread-1.md +30 -0
  460. package/src/components/ChatThread/testing/thread-2.md +56 -0
  461. package/src/components/ChatThread/testing/thread-widgets.md +79 -0
  462. package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
  463. package/src/components/ChatThread/tool-widget-state.ts +48 -0
  464. package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
  465. package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
  466. package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
  467. package/src/components/ChatThread/widgets/ReferenceWidget.ts +33 -0
  468. package/src/components/ChatThread/widgets/SelectWidget.ts +39 -0
  469. package/src/components/ChatThread/widgets/StatsWidget.ts +31 -0
  470. package/src/components/ChatThread/widgets/StatusWidget.ts +53 -0
  471. package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
  472. package/src/components/ChatThread/widgets/SummaryWidget.tsx +29 -0
  473. package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +55 -0
  474. package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
  475. package/src/components/ChatThread/widgets/defaults.ts +8 -0
  476. package/src/components/ChatThread/widgets/index.ts +13 -0
  477. package/src/components/ProcessTree/ProcessTree.stories.tsx +83 -0
  478. package/src/components/ProcessTree/ProcessTree.tsx +119 -0
  479. package/src/components/ProcessTree/index.ts +5 -0
  480. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +55 -43
  481. package/src/components/TemplateEditor/TemplateEditor.tsx +62 -60
  482. package/src/components/TemplateEditor/TemplateForm.stories.tsx +41 -30
  483. package/src/components/TemplateEditor/TemplateForm.tsx +122 -102
  484. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  485. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  486. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  487. package/src/components/ToolBlock/ToolBlock.tsx +144 -0
  488. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  489. package/src/components/ToolBlock/index.ts +6 -0
  490. package/src/components/Toolbox/Toolbox.stories.tsx +18 -30
  491. package/src/components/Toolbox/Toolbox.tsx +91 -60
  492. package/src/components/index.ts +4 -13
  493. package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
  494. package/src/containers/AgentArticle/AgentArticle.tsx +200 -0
  495. package/src/containers/AgentArticle/index.ts +5 -0
  496. package/src/containers/AgentProperties/AgentProperties.stories.tsx +101 -0
  497. package/src/containers/AgentProperties/AgentProperties.tsx +127 -0
  498. package/src/containers/AgentProperties/index.ts +5 -0
  499. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
  500. package/src/containers/BlueprintArticle/index.ts +5 -0
  501. package/src/containers/ChatCompanion/ChatCompanion.tsx +129 -0
  502. package/src/containers/ChatCompanion/index.ts +5 -0
  503. package/src/containers/ChatContainer/ChatContainer.tsx +105 -0
  504. package/src/containers/ChatContainer/index.ts +5 -0
  505. package/src/containers/ChatDialog/ChatDialog.tsx +66 -0
  506. package/src/containers/ChatDialog/index.ts +5 -0
  507. package/src/containers/RoutineArticle/RoutineArticle.tsx +59 -0
  508. package/src/containers/RoutineArticle/index.ts +5 -0
  509. package/src/containers/RoutineList/RoutineList.stories.tsx +130 -0
  510. package/src/containers/RoutineList/RoutineList.tsx +50 -0
  511. package/src/containers/RoutineList/index.ts +5 -0
  512. package/src/containers/TracePanel/TracePanel.stories.tsx +285 -0
  513. package/src/containers/TracePanel/TracePanel.tsx +167 -0
  514. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  515. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  516. package/src/containers/TracePanel/execution-graph.test.ts +382 -0
  517. package/src/containers/TracePanel/execution-graph.ts +621 -0
  518. package/src/containers/TracePanel/index.ts +9 -0
  519. package/src/containers/TracePanel/testing/index.ts +6 -0
  520. package/src/containers/TracePanel/testing/simulated-agent.ts +114 -0
  521. package/src/containers/TracePanel/testing/snapshot-playback.ts +45 -0
  522. package/src/containers/TriggerStatus/TriggerStatus.tsx +129 -0
  523. package/src/containers/TriggerStatus/index.ts +5 -0
  524. package/src/containers/index.ts +16 -0
  525. package/src/extensions/index.ts +5 -0
  526. package/src/extensions/prompt-extension.ts +111 -0
  527. package/src/hooks/index.ts +12 -6
  528. package/src/hooks/useBlueprintRegistry.ts +109 -0
  529. package/src/hooks/useChatKeymap.ts +52 -0
  530. package/src/hooks/useChatProcessor.ts +90 -0
  531. package/src/hooks/useChatServices.ts +26 -0
  532. package/src/hooks/useChatToolbarActions.ts +122 -0
  533. package/src/hooks/useContextBinder.ts +43 -0
  534. package/src/hooks/useContextObjects.ts +50 -0
  535. package/src/hooks/useDebug.ts +38 -0
  536. package/src/hooks/useFilteredTypes.ts +37 -0
  537. package/src/hooks/useFlush.ts +35 -0
  538. package/src/hooks/useOnline.ts +10 -0
  539. package/src/hooks/usePresets.ts +45 -0
  540. package/src/hooks/useReferencesProvider.ts +54 -0
  541. package/src/index.ts +8 -5
  542. package/src/meta.ts +15 -9
  543. package/src/operations/create-chat.ts +79 -0
  544. package/src/operations/definitions.ts +126 -0
  545. package/src/operations/ensure-companion-chat.ts +61 -0
  546. package/src/operations/index.ts +17 -0
  547. package/src/operations/on-create-space.ts +24 -0
  548. package/src/operations/prompt.test.ts +77 -0
  549. package/src/operations/resolve-navigation-targets.ts +26 -0
  550. package/src/operations/run-prompt-in-new-chat.ts +112 -0
  551. package/src/operations/set-current-chat.ts +50 -0
  552. package/src/operations/update-chat-name.ts +61 -0
  553. package/src/processor/index.ts +6 -0
  554. package/src/processor/presets.ts +68 -0
  555. package/src/processor/processor.test.ts +40 -0
  556. package/src/processor/processor.ts +352 -0
  557. package/src/queue-logger.ts +39 -29
  558. package/src/testing/data/trace-timeline.dx.json +4657 -0
  559. package/src/testing/index.ts +3 -2
  560. package/src/testing/test-generator.test.ts +81 -0
  561. package/src/testing/test-generator.ts +299 -0
  562. package/src/testing/test-sequence.ts +26 -0
  563. package/src/testing/test-services.ts +10 -14
  564. package/src/testing/test-trace.ts +20 -0
  565. package/src/testing/trace-timeline.conversations.json +1 -0
  566. package/src/testing/trace-timeline.test.ts +250 -0
  567. package/src/translations.ts +164 -55
  568. package/src/types/Assistant.ts +24 -0
  569. package/src/types/Settings.ts +76 -0
  570. package/src/types/capabilities.ts +35 -0
  571. package/src/types/events.ts +11 -0
  572. package/src/types/index.ts +7 -3
  573. package/src/types/service.ts +27 -16
  574. package/src/vite-env.d.ts +30 -0
  575. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
  576. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
  577. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
  578. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
  579. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
  580. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
  581. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs +0 -28
  582. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
  583. package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
  584. package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
  585. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs +0 -225
  586. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
  587. package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
  588. package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
  589. package/dist/lib/browser/chunk-BI6AHRNJ.mjs +0 -157
  590. package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
  591. package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
  592. package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
  593. package/dist/lib/browser/chunk-JQFUME3B.mjs +0 -87
  594. package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
  595. package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
  596. package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
  597. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
  598. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
  599. package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
  600. package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
  601. package/dist/lib/browser/chunk-XOZ7YMO3.mjs +0 -20
  602. package/dist/lib/browser/chunk-XOZ7YMO3.mjs.map +0 -7
  603. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
  604. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
  605. package/dist/lib/browser/react-surface-LXCNUSZN.mjs +0 -159
  606. package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
  607. package/dist/lib/browser/settings-XRHXVWGB.mjs +0 -22
  608. package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
  609. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
  610. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
  611. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
  612. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
  613. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
  614. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
  615. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
  616. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
  617. package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
  618. package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
  619. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
  620. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
  621. package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
  622. package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
  623. package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
  624. package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
  625. package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
  626. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
  627. package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
  628. package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
  629. package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
  630. package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
  631. package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
  632. package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
  633. package/dist/lib/node/chunk-P74TWGMG.cjs +0 -44
  634. package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
  635. package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
  636. package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
  637. package/dist/lib/node/index.cjs +0 -289
  638. package/dist/lib/node/index.cjs.map +0 -7
  639. package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
  640. package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
  641. package/dist/lib/node/meta.json +0 -1
  642. package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
  643. package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
  644. package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
  645. package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
  646. package/dist/lib/node/types/index.cjs +0 -54
  647. package/dist/lib/node/types/index.cjs.map +0 -7
  648. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
  649. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
  650. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
  651. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
  652. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
  653. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
  654. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs +0 -29
  655. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
  656. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
  657. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
  658. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs +0 -226
  659. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
  660. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
  661. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
  662. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
  663. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
  664. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs +0 -22
  665. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs.map +0 -7
  666. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
  667. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
  668. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
  669. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
  670. package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
  671. package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
  672. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs +0 -88
  673. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
  674. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs +0 -158
  675. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
  676. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
  677. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
  678. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs +0 -160
  679. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
  680. package/dist/lib/node-esm/settings-5IAY6BT4.mjs +0 -23
  681. package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
  682. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  683. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  684. package/dist/types/src/capabilities/capabilities.d.ts +0 -6
  685. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  686. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  687. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  688. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
  689. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
  690. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
  691. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
  692. package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
  693. package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
  694. package/dist/types/src/components/AssistantDialog.d.ts +0 -7
  695. package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
  696. package/dist/types/src/components/BlueprintContainer.d.ts +0 -9
  697. package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
  698. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
  699. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
  700. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
  701. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
  702. package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
  703. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
  704. package/dist/types/src/components/ChatContainer.d.ts +0 -11
  705. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  706. package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
  707. package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
  708. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
  709. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
  710. package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
  711. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
  712. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
  713. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
  714. package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
  715. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
  716. package/dist/types/src/components/Prompt/index.d.ts +0 -3
  717. package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
  718. package/dist/types/src/components/Prompt/references.d.ts +0 -30
  719. package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
  720. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  721. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  722. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  723. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  724. package/dist/types/src/components/Thread/Thread.d.ts +0 -28
  725. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  726. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  727. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  728. package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
  729. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
  730. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
  731. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
  732. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
  733. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  734. package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
  735. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
  736. package/dist/types/src/components/Thread/index.d.ts +0 -3
  737. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  738. package/dist/types/src/components/Thread/reducer.d.ts +0 -12
  739. package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
  740. package/dist/types/src/events.d.ts +0 -4
  741. package/dist/types/src/events.d.ts.map +0 -1
  742. package/dist/types/src/experimental/transcription/index.d.ts +0 -1
  743. package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
  744. package/dist/types/src/hooks/processor.d.ts +0 -72
  745. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  746. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  747. package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
  748. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  749. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
  750. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  751. package/dist/types/src/hooks/useServices.d.ts +0 -7
  752. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  753. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  754. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  755. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  756. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  757. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  758. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  759. package/dist/types/src/parser/index.d.ts +0 -4
  760. package/dist/types/src/parser/index.d.ts.map +0 -1
  761. package/dist/types/src/parser/query-parser.d.ts +0 -15
  762. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  763. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  764. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  765. package/dist/types/src/parser/types.d.ts +0 -24
  766. package/dist/types/src/parser/types.d.ts.map +0 -1
  767. package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
  768. package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
  769. package/dist/types/src/stories/Query.stories.d.ts +0 -19
  770. package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
  771. package/dist/types/src/stories/Research.stories.d.ts +0 -15
  772. package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
  773. package/dist/types/src/stories/test-data.d.ts +0 -3
  774. package/dist/types/src/stories/test-data.d.ts.map +0 -1
  775. package/dist/types/src/stories/testing.d.ts +0 -12
  776. package/dist/types/src/stories/testing.d.ts.map +0 -1
  777. package/dist/types/src/testing/test-blueprint.d.ts +0 -8
  778. package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
  779. package/dist/types/src/testing/test-functions.d.ts +0 -3
  780. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  781. package/dist/types/src/tools/function.d.ts +0 -5
  782. package/dist/types/src/tools/function.d.ts.map +0 -1
  783. package/dist/types/src/tools/index.d.ts +0 -3
  784. package/dist/types/src/tools/index.d.ts.map +0 -1
  785. package/dist/types/src/tools/openapi.d.ts +0 -10
  786. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  787. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  788. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  789. package/dist/types/src/types/chat.d.ts +0 -23
  790. package/dist/types/src/types/chat.d.ts.map +0 -1
  791. package/dist/types/src/types/template.d.ts +0 -56
  792. package/dist/types/src/types/template.d.ts.map +0 -1
  793. package/dist/types/src/types/types.d.ts +0 -50
  794. package/dist/types/src/types/types.d.ts.map +0 -1
  795. package/src/capabilities/ai-client.ts +0 -42
  796. package/src/capabilities/capabilities.ts +0 -15
  797. package/src/capabilities/intent-resolver.ts +0 -45
  798. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
  799. package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
  800. package/src/components/AssistantDialog.tsx +0 -37
  801. package/src/components/BlueprintContainer.tsx +0 -148
  802. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
  803. package/src/components/BlueprintEditor/BlueprintEditor.tsx +0 -50
  804. package/src/components/BlueprintEditor/index.ts +0 -5
  805. package/src/components/ChatContainer.tsx +0 -39
  806. package/src/components/Prompt/Prompt.stories.tsx +0 -121
  807. package/src/components/Prompt/Prompt.tsx +0 -124
  808. package/src/components/Prompt/PromptBar.stories.tsx +0 -69
  809. package/src/components/Prompt/PromptBar.tsx +0 -105
  810. package/src/components/Prompt/autocomplete.ts +0 -218
  811. package/src/components/Prompt/index.ts +0 -6
  812. package/src/components/Prompt/references.ts +0 -180
  813. package/src/components/PromptSettings.tsx +0 -91
  814. package/src/components/TemplateContainer.tsx +0 -23
  815. package/src/components/Thread/Thread.stories.tsx +0 -201
  816. package/src/components/Thread/Thread.tsx +0 -118
  817. package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
  818. package/src/components/Thread/ThreadContainer.tsx +0 -105
  819. package/src/components/Thread/ThreadMessage.tsx +0 -234
  820. package/src/components/Thread/ToolInvocations.tsx +0 -106
  821. package/src/components/Thread/index.ts +0 -6
  822. package/src/components/Thread/reducer.ts +0 -52
  823. package/src/events.ts +0 -11
  824. package/src/hooks/processor.test.ts +0 -15
  825. package/src/hooks/processor.ts +0 -238
  826. package/src/hooks/useChatProcessor.tsx +0 -97
  827. package/src/hooks/useContextProvider.ts +0 -55
  828. package/src/hooks/useMessageQueue.ts +0 -22
  829. package/src/hooks/useServices.ts +0 -28
  830. package/src/hooks/useTextInputEvents.ts +0 -49
  831. package/src/parser/filter-generator.test.ts +0 -32
  832. package/src/parser/filter-generator.ts +0 -81
  833. package/src/parser/index.ts +0 -7
  834. package/src/parser/query-parser.test.ts +0 -139
  835. package/src/parser/query-parser.ts +0 -199
  836. package/src/parser/types.ts +0 -34
  837. package/src/shims.d.ts +0 -8
  838. package/src/stories/Prompt.stories.tsx +0 -60
  839. package/src/stories/Query.stories.tsx +0 -514
  840. package/src/stories/Research.stories.tsx +0 -482
  841. package/src/stories/test-data.ts +0 -128
  842. package/src/stories/testing.ts +0 -60
  843. package/src/testing/test-blueprint.ts +0 -58
  844. package/src/testing/test-functions.ts +0 -11
  845. package/src/tools/function.ts +0 -46
  846. package/src/tools/index.ts +0 -6
  847. package/src/tools/openapi.test.ts +0 -217
  848. package/src/tools/openapi.ts +0 -338
  849. package/src/types/chat.ts +0 -32
  850. package/src/types/template.ts +0 -66
  851. package/src/types/types.ts +0 -48
  852. package/src/typings.d.ts +0 -9
  853. /package/dist/types/src/{hooks → processor}/processor.test.d.ts +0 -0
@@ -0,0 +1,2253 @@
1
+ // src/components/index.ts
2
+ import { lazy } from "react";
3
+
4
+ // src/components/Chat/Chat.tsx
5
+ import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
6
+ import * as Array from "effect/Array";
7
+ import * as Option4 from "effect/Option";
8
+ import React14, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo5, useRef as useRef3, useState as useState7 } from "react";
9
+ import { Event } from "@dxos/async";
10
+ import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
11
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
12
+ import { useIdentity } from "@dxos/react-client/halo";
13
+ import { Menu } from "@dxos/react-ui-menu";
14
+ import { Message as Message2 } from "@dxos/types";
15
+ import { composable, composableProps } from "@dxos/ui-theme";
16
+ import { useChatKeymapExtensions as useChatKeymapExtensions2, useChatToolbarActions, useDebug } from "#hooks";
17
+
18
+ // src/components/ChatPrompt/ChatActions.tsx
19
+ import React from "react";
20
+ import { IconButton, useTranslation } from "@dxos/react-ui";
21
+ import { mx } from "@dxos/ui-theme";
22
+ import { meta } from "#meta";
23
+ var ChatActions = ({ classNames, children, microphone, recording, processing, debug, onEvent }) => {
24
+ const { t } = useTranslation(meta.id);
25
+ return /* @__PURE__ */ React.createElement("div", {
26
+ className: mx("flex items-center", classNames)
27
+ }, children, microphone && /* @__PURE__ */ React.createElement(IconButton, {
28
+ disabled: !processing,
29
+ classNames: mx(recording && "bg-primary-500"),
30
+ variant: "ghost",
31
+ icon: "ph--microphone--regular",
32
+ iconOnly: true,
33
+ noTooltip: true,
34
+ label: t("microphone.button"),
35
+ onMouseDown: () => onEvent?.({
36
+ type: "record-start"
37
+ }),
38
+ onMouseUp: () => onEvent?.({
39
+ type: "record-stop"
40
+ }),
41
+ onTouchStart: () => onEvent?.({
42
+ type: "record-start"
43
+ }),
44
+ onTouchEnd: () => onEvent?.({
45
+ type: "record-stop"
46
+ })
47
+ }), debug && /* @__PURE__ */ React.createElement(IconButton, {
48
+ variant: "ghost",
49
+ icon: "ph--wrench--regular",
50
+ iconOnly: true,
51
+ label: t("debug.button"),
52
+ onClick: () => onEvent?.({
53
+ type: "toggle-debug"
54
+ })
55
+ }), /* @__PURE__ */ React.createElement(IconButton, {
56
+ disabled: !processing,
57
+ variant: "ghost",
58
+ icon: "ph--x--regular",
59
+ iconOnly: true,
60
+ label: t("cancel-processing.button"),
61
+ onClick: () => onEvent?.({
62
+ type: "cancel"
63
+ })
64
+ }));
65
+ };
66
+
67
+ // src/components/ChatPrompt/ChatMcpErrors.tsx
68
+ import { useAtomValue } from "@effect-atom/atom-react";
69
+ import React2, { useCallback } from "react";
70
+ import { Message, useTranslation as useTranslation2 } from "@dxos/react-ui";
71
+ import { meta as meta2 } from "#meta";
72
+ var ChatMcpErrors = ({ classNames, processor }) => {
73
+ const { t } = useTranslation2(meta2.id);
74
+ const errors = useAtomValue(processor.mcpErrors);
75
+ const handleDismiss = useCallback(() => {
76
+ processor.dismissMcpErrors();
77
+ }, [
78
+ processor
79
+ ]);
80
+ if (errors.length === 0) {
81
+ return null;
82
+ }
83
+ return /* @__PURE__ */ React2.createElement(Message.Root, {
84
+ classNames: [
85
+ "m-1",
86
+ classNames
87
+ ],
88
+ valence: "warning"
89
+ }, /* @__PURE__ */ React2.createElement(Message.Title, {
90
+ onClose: handleDismiss
91
+ }, t("mcp-server-error.label")), /* @__PURE__ */ React2.createElement(Message.Content, {
92
+ asChild: true
93
+ }, /* @__PURE__ */ React2.createElement("ul", {
94
+ className: "flex flex-col gap-0.5 text-sm"
95
+ }, errors.map((error) => /* @__PURE__ */ React2.createElement("li", {
96
+ key: `${error.url}::${error.protocol}`,
97
+ className: "truncate"
98
+ }, /* @__PURE__ */ React2.createElement("span", {
99
+ className: "font-mono"
100
+ }, error.url), " \u2014 ", /* @__PURE__ */ React2.createElement("span", null, error.message))))));
101
+ };
102
+
103
+ // src/components/ChatPrompt/ChatOptions.tsx
104
+ import * as Option from "effect/Option";
105
+ import React3, { useCallback as useCallback2, useMemo, useState } from "react";
106
+ import { McpServer } from "@dxos/assistant-toolkit";
107
+ import { Annotation, Filter, Obj, Type } from "@dxos/echo";
108
+ import { useObject, useQuery } from "@dxos/react-client/echo";
109
+ import { IconButton as IconButton2, Input, Popover, Select, useTranslation as useTranslation3 } from "@dxos/react-ui";
110
+ import { Listbox } from "@dxos/react-ui-list";
111
+ import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
112
+ import { Tabs } from "@dxos/react-ui-tabs";
113
+ import { getStyles, mx as mx2 } from "@dxos/ui-theme";
114
+ import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
115
+ import { meta as meta3 } from "#meta";
116
+ import { Assistant } from "#types";
117
+ var styles = {
118
+ panel: "w-[calc(100dvw-.5rem)] sm:w-max max-w-document-width",
119
+ toolbar: "p-0! gap-0! border-t border-separator"
120
+ };
121
+ var ChatOptions = ({ chat, db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
122
+ const { t } = useTranslation3(meta3.id);
123
+ return /* @__PURE__ */ React3.createElement("div", {
124
+ role: "none",
125
+ className: "flex"
126
+ }, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
127
+ asChild: true
128
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
129
+ variant: "ghost",
130
+ icon: "ph--plus--regular",
131
+ iconOnly: true,
132
+ label: t("context-objects.button")
133
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
134
+ side: "top",
135
+ classNames: styles.panel
136
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
137
+ db,
138
+ context
139
+ })), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
140
+ asChild: true
141
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
142
+ variant: "ghost",
143
+ icon: "ph--sliders-horizontal--regular",
144
+ iconOnly: true,
145
+ label: t("context-settings.button")
146
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
147
+ side: "top",
148
+ classNames: styles.panel
149
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(Tabs.Root, {
150
+ classNames: "flex",
151
+ orientation: "horizontal",
152
+ defaultValue: "view",
153
+ defaultActivePart: "list",
154
+ tabIndex: -1
155
+ }, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
156
+ classNames: mx2("grid grid-rows-[1fr_40px] w-full")
157
+ }, /* @__PURE__ */ React3.createElement(Tabs.Panel, {
158
+ tabIndex: -1,
159
+ classNames: "dx-focus-ring-inset overflow-hidden",
160
+ value: "view"
161
+ }, /* @__PURE__ */ React3.createElement(ViewPanel, {
162
+ chat
163
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
164
+ tabIndex: -1,
165
+ classNames: "dx-focus-ring-inset overflow-hidden",
166
+ value: "blueprints"
167
+ }, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
168
+ blueprintRegistry,
169
+ db,
170
+ context
171
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
172
+ tabIndex: -1,
173
+ classNames: "dx-focus-ring-inset overflow-hidden",
174
+ value: "mcp-servers"
175
+ }, /* @__PURE__ */ React3.createElement(McpServersPanel, {
176
+ db
177
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
178
+ tabIndex: -1,
179
+ classNames: "dx-focus-ring-inset overflow-hidden",
180
+ value: "model"
181
+ }, /* @__PURE__ */ React3.createElement(ModelsPanel, {
182
+ presets,
183
+ preset,
184
+ onPresetChange
185
+ })), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
186
+ classNames: [
187
+ styles.toolbar
188
+ ]
189
+ }, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
190
+ value: "view",
191
+ icon: "ph--eye--regular",
192
+ label: t("chat-view.title")
193
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
194
+ value: "blueprints",
195
+ icon: "ph--blueprint--regular",
196
+ label: t("options.blueprints.title")
197
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
198
+ value: "mcp-servers",
199
+ icon: "ph--plugs-connected--regular",
200
+ label: t("options.mcp.title")
201
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
202
+ value: "model",
203
+ icon: "ph--cpu--regular",
204
+ label: t("options.chat-model.title")
205
+ }))))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
206
+ };
207
+ var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
208
+ const { t } = useTranslation3(meta3.id);
209
+ const blueprints = useBlueprints({
210
+ blueprintRegistry,
211
+ db
212
+ });
213
+ const activeBlueprints = useActiveBlueprints({
214
+ context
215
+ });
216
+ const { onUpdateBlueprint } = useBlueprintHandlers({
217
+ db,
218
+ context,
219
+ blueprintRegistry
220
+ });
221
+ const { results, handleSearch } = useSearchListResults({
222
+ items: blueprints,
223
+ extract: (blueprint) => blueprint.name
224
+ });
225
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, {
226
+ onSearch: handleSearch
227
+ }, /* @__PURE__ */ React3.createElement(SearchList.Content, {
228
+ classNames: "flex flex-col"
229
+ }, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.map((blueprint) => {
230
+ const isActive = activeBlueprints.has(blueprint.key);
231
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
232
+ classNames: "flex items-center overflow-hidden",
233
+ key: blueprint.key,
234
+ value: blueprint.key,
235
+ label: blueprint.name,
236
+ checked: isActive,
237
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
238
+ });
239
+ })), /* @__PURE__ */ React3.createElement(SearchList.Input, {
240
+ placeholder: t("search.placeholder"),
241
+ classNames: "border-t border-separator",
242
+ autoFocus: true
243
+ })));
244
+ };
245
+ var ViewPanel = ({ chat }) => {
246
+ const { t } = useTranslation3(meta3.id);
247
+ const [view, setView] = useObject(chat, "view");
248
+ const value2 = view ?? "normal";
249
+ return /* @__PURE__ */ React3.createElement(Listbox.Root, {
250
+ value: value2,
251
+ onValueChange: setView,
252
+ autoFocus: true
253
+ }, Assistant.ChatViews.map((view2) => /* @__PURE__ */ React3.createElement(Listbox.Option, {
254
+ key: view2,
255
+ value: view2
256
+ }, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, t(`chat-view.${view2}.label`, {
257
+ defaultValue: view2
258
+ })), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null))));
259
+ };
260
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
261
+ return /* @__PURE__ */ React3.createElement(Listbox.Root, {
262
+ value: preset,
263
+ onValueChange: onPresetChange,
264
+ autoFocus: true
265
+ }, presets?.map(({ id, label }) => {
266
+ return /* @__PURE__ */ React3.createElement(Listbox.Option, {
267
+ key: id,
268
+ value: id
269
+ }, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null));
270
+ }));
271
+ };
272
+ var McpServersPanel = ({ db }) => {
273
+ const { t } = useTranslation3(meta3.id);
274
+ const servers = useQuery(db, Filter.type(McpServer.McpServer));
275
+ const [adding, setAdding] = useState(false);
276
+ const handleAdd = useCallback2((name, url, protocol, apiKey) => {
277
+ db.add(Obj.make(McpServer.McpServer, {
278
+ name,
279
+ url,
280
+ protocol,
281
+ apiKey,
282
+ enabled: true
283
+ }));
284
+ setAdding(false);
285
+ }, [
286
+ db
287
+ ]);
288
+ const handleRemove = useCallback2((server) => {
289
+ db.remove(server);
290
+ }, [
291
+ db
292
+ ]);
293
+ return /* @__PURE__ */ React3.createElement("div", {
294
+ className: "p-form-chrome"
295
+ }, servers.map((server) => /* @__PURE__ */ React3.createElement(McpServerRow, {
296
+ key: server.id,
297
+ server,
298
+ onRemove: handleRemove
299
+ })), adding ? /* @__PURE__ */ React3.createElement(McpServerForm, {
300
+ onSubmit: handleAdd,
301
+ onCancel: () => setAdding(false)
302
+ }) : /* @__PURE__ */ React3.createElement("div", {
303
+ role: "none"
304
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
305
+ variant: "ghost",
306
+ icon: "ph--plus--regular",
307
+ label: t("mcp-server-add.label"),
308
+ onClick: () => setAdding(true)
309
+ })));
310
+ };
311
+ var McpServerRow = ({ server, onRemove }) => {
312
+ const { t } = useTranslation3(meta3.id);
313
+ const [enabled, setEnabled] = useObject(server, "enabled");
314
+ return /* @__PURE__ */ React3.createElement("div", {
315
+ className: "flex items-center gap-2 px-form-chrome"
316
+ }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
317
+ srOnly: true
318
+ }, server.name), /* @__PURE__ */ React3.createElement(Input.Switch, {
319
+ checked: enabled !== false,
320
+ onCheckedChange: (checked) => setEnabled(!!checked)
321
+ })), /* @__PURE__ */ React3.createElement("span", {
322
+ className: "flex-1 truncate text-sm"
323
+ }, server.name), /* @__PURE__ */ React3.createElement("span", {
324
+ className: "truncate text-xs text-description"
325
+ }, server.url), /* @__PURE__ */ React3.createElement(IconButton2, {
326
+ variant: "ghost",
327
+ icon: "ph--x--regular",
328
+ iconOnly: true,
329
+ label: t("mcp-server-remove.label"),
330
+ onClick: () => onRemove(server)
331
+ }));
332
+ };
333
+ var McpServerForm = ({ onSubmit, onCancel }) => {
334
+ const { t } = useTranslation3(meta3.id);
335
+ const [name, setName] = useState("");
336
+ const [url, setUrl] = useState("");
337
+ const [protocol, setProtocol] = useState("sse");
338
+ const [apiKey, setApiKey] = useState("");
339
+ const canSubmit = name.trim().length > 0 && url.trim().length > 0;
340
+ const handleSubmit = useCallback2(() => {
341
+ if (canSubmit) {
342
+ onSubmit(name.trim(), url.trim(), protocol, apiKey.trim() || void 0);
343
+ }
344
+ }, [
345
+ canSubmit,
346
+ name,
347
+ url,
348
+ protocol,
349
+ apiKey,
350
+ onSubmit
351
+ ]);
352
+ return /* @__PURE__ */ React3.createElement("div", {
353
+ className: "space-y-2 px-form-chrome"
354
+ }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
355
+ srOnly: true
356
+ }, t("mcp-server-name.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
357
+ placeholder: t("mcp-server-name.placeholder"),
358
+ value: name,
359
+ onChange: (event) => setName(event.target.value),
360
+ autoFocus: true
361
+ })), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
362
+ srOnly: true
363
+ }, t("mcp-server-url.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
364
+ placeholder: t("mcp-server-url.placeholder"),
365
+ value: url,
366
+ onChange: (event) => setUrl(event.target.value)
367
+ })), /* @__PURE__ */ React3.createElement(Select.Root, {
368
+ value: protocol,
369
+ onValueChange: (value2) => setProtocol(value2)
370
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
371
+ placeholder: t("mcp-server-protocol.label")
372
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
373
+ value: "sse"
374
+ }, "SSE"), /* @__PURE__ */ React3.createElement(Select.Option, {
375
+ value: "http"
376
+ }, "HTTP"))))), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
377
+ srOnly: true
378
+ }, t("mcp-server-api-key.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
379
+ type: "password",
380
+ placeholder: t("mcp-server-api-key.placeholder"),
381
+ value: apiKey,
382
+ onChange: (event) => setApiKey(event.target.value)
383
+ })), /* @__PURE__ */ React3.createElement("div", {
384
+ role: "none",
385
+ className: "flex gap-2"
386
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
387
+ variant: "ghost",
388
+ icon: "ph--check--regular",
389
+ iconOnly: true,
390
+ label: t("save.button"),
391
+ onClick: handleSubmit,
392
+ disabled: !canSubmit
393
+ }), /* @__PURE__ */ React3.createElement(IconButton2, {
394
+ variant: "ghost",
395
+ icon: "ph--x--regular",
396
+ iconOnly: true,
397
+ label: t("cancel.button"),
398
+ onClick: onCancel
399
+ })));
400
+ };
401
+ var ANY = "__any__";
402
+ var ObjectsPanel = ({ db, context }) => {
403
+ const { t } = useTranslation3(meta3.id);
404
+ const types = useFilteredTypes(db);
405
+ const typenames = useMemo(() => {
406
+ const typenames2 = types.map((type) => {
407
+ const typename2 = Type.getTypename(type);
408
+ return {
409
+ typename: typename2,
410
+ label: t("typename.label", {
411
+ ns: typename2,
412
+ defaultValue: typename2
413
+ })
414
+ };
415
+ });
416
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
417
+ return typenames2;
418
+ }, [
419
+ types
420
+ ]);
421
+ const [typename, setTypename] = useState(ANY);
422
+ const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
423
+ typenames
424
+ ]);
425
+ const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
426
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
427
+ db,
428
+ context
429
+ });
430
+ const { results, handleSearch } = useSearchListResults({
431
+ items: objects,
432
+ extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
433
+ });
434
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, {
435
+ onSearch: handleSearch
436
+ }, /* @__PURE__ */ React3.createElement(SearchList.Content, {
437
+ classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
438
+ }, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
439
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
440
+ const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
441
+ icon: "ph--cube--regular",
442
+ hue: void 0
443
+ })));
444
+ const styles3 = hue ? getStyles(hue) : void 0;
445
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
446
+ classNames: "flex items-center overflow-hidden",
447
+ key: object.id,
448
+ value: object.id,
449
+ icon,
450
+ iconClassNames: styles3?.surfaceText,
451
+ label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
452
+ checked: isActive,
453
+ onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
454
+ });
455
+ }) : /* @__PURE__ */ React3.createElement(SearchList.Item, {
456
+ value: "__empty__",
457
+ label: t("no-results.message")
458
+ }))), /* @__PURE__ */ React3.createElement("div", {
459
+ role: "none",
460
+ className: mx2("flex flex-col", styles.toolbar)
461
+ }, /* @__PURE__ */ React3.createElement(Select.Root, {
462
+ value: typename === ANY ? void 0 : typename,
463
+ onValueChange: setTypename
464
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
465
+ placeholder: t("type-filter.placeholder")
466
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
467
+ value: ANY
468
+ }, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select.Option, {
469
+ key: typename2,
470
+ value: typename2
471
+ }, label))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
472
+ placeholder: t("search.placeholder"),
473
+ autoFocus: true
474
+ })));
475
+ };
476
+
477
+ // src/components/ChatPrompt/ChatPresets.tsx
478
+ import React4 from "react";
479
+ import { Select as Select2 } from "@dxos/react-ui";
480
+
481
+ // src/components/ChatPrompt/ChatPrompt.tsx
482
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
483
+ import * as Option3 from "effect/Option";
484
+ import React7, { useCallback as useCallback3, useEffect as useEffect2, useRef, useState as useState3 } from "react";
485
+ import { useVoiceInput } from "@dxos/plugin-transcription";
486
+ import { Input as Input2, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
487
+ import { ChatEditor } from "@dxos/react-ui-chat";
488
+ import { mx as mx5 } from "@dxos/ui-theme";
489
+ import { useChatKeymapExtensions } from "#hooks";
490
+ import { meta as meta5 } from "#meta";
491
+
492
+ // src/components/ChatPrompt/ChatReferences.tsx
493
+ import * as Option2 from "effect/Option";
494
+ import React5 from "react";
495
+ import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
496
+ import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
497
+ import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
498
+ import { useContextObjects as useContextObjects2 } from "#hooks";
499
+ import { meta as meta4 } from "#meta";
500
+ var ChatReferences = ({ classNames, context, db }) => {
501
+ const { t } = useTranslation4(meta4.id);
502
+ const { objects, onUpdateObject } = useContextObjects2({
503
+ db,
504
+ context
505
+ });
506
+ return /* @__PURE__ */ React5.createElement("ul", {
507
+ className: mx3("flex", classNames)
508
+ }, objects.map((obj) => {
509
+ const dxn = Obj2.getDXN(obj);
510
+ const typename = Obj2.getTypename(obj);
511
+ const label = Obj2.getLabel(obj) ?? (typename ? [
512
+ "object-name.placeholder",
513
+ {
514
+ ns: typename
515
+ }
516
+ ] : obj.id);
517
+ const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
518
+ icon: DEFAULT_OBJECT_ICON,
519
+ hue: void 0
520
+ })));
521
+ const styles3 = hue ? getStyles2(hue) : void 0;
522
+ return /* @__PURE__ */ React5.createElement("li", {
523
+ key: dxn.toString(),
524
+ className: "dx-tag py-0 ps-2 flex items-center gap-1",
525
+ "data-hue": "neutral"
526
+ }, /* @__PURE__ */ React5.createElement(Icon, {
527
+ icon,
528
+ size: 4,
529
+ classNames: styles3?.surfaceText
530
+ }), toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
531
+ icon: "ph--x--bold",
532
+ iconOnly: true,
533
+ variant: "ghost",
534
+ label: t("remove-object.label"),
535
+ classNames: "p-0 hover:bg-transparent",
536
+ size: 3,
537
+ onClick: () => onUpdateObject?.(dxn, false)
538
+ }));
539
+ }));
540
+ };
541
+ var DEFAULT_OBJECT_ICON = "ph--cube--regular";
542
+
543
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
544
+ import React6, { useEffect, useState as useState2 } from "react";
545
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
546
+ import { Spinner } from "@dxos/react-ui-sfx";
547
+ import { mx as mx4 } from "@dxos/ui-theme";
548
+ var period = 3e3;
549
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
550
+ const [init, setInit] = useState2(false);
551
+ useEffect(() => setInit(false), [
552
+ preset
553
+ ]);
554
+ useTimeout(async () => {
555
+ setInit(true);
556
+ }, period / 2, [
557
+ preset
558
+ ]);
559
+ return /* @__PURE__ */ React6.createElement("div", {
560
+ role: "none",
561
+ className: mx4("relative flex", classNames)
562
+ }, /* @__PURE__ */ React6.createElement(Spinner, {
563
+ duration: period,
564
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
565
+ ...props
566
+ }), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
567
+ asChild: true,
568
+ content: error.message
569
+ }, /* @__PURE__ */ React6.createElement("div", {
570
+ className: "absolute inset-0"
571
+ })));
572
+ };
573
+
574
+ // src/components/ChatPrompt/ChatPrompt.tsx
575
+ var ChatPrompt = ({ classNames, outline, chat, db, processor, event, online, placeholder, onOnlineChange, onPresetChange, settings = true, presets, preset }) => {
576
+ const { t } = useTranslation5(meta5.id);
577
+ const error = useAtomValue2(processor.error).pipe(Option3.getOrUndefined);
578
+ const streaming = useAtomValue2(processor.streaming);
579
+ const active = useAtomValue2(processor.active);
580
+ const activeRef = useDynamicRef(active);
581
+ const editorRef = useRef(null);
582
+ const [recordingState, setRecordingState] = useState3(false);
583
+ useEffect2(() => {
584
+ return event.on((ev) => {
585
+ switch (ev.type) {
586
+ case "update-prompt":
587
+ if (!editorRef.current?.getText()?.length) {
588
+ editorRef.current?.setText(ev.text);
589
+ editorRef.current?.focus();
590
+ }
591
+ break;
592
+ case "record-start":
593
+ setRecordingState(true);
594
+ break;
595
+ case "record-stop":
596
+ setRecordingState(false);
597
+ break;
598
+ }
599
+ });
600
+ }, [
601
+ event
602
+ ]);
603
+ const { recording } = useVoiceInput({
604
+ active: recordingState,
605
+ onUpdate: (text) => {
606
+ editorRef.current?.setText(text);
607
+ editorRef.current?.focus();
608
+ }
609
+ });
610
+ const extensions = useChatKeymapExtensions({
611
+ event
612
+ });
613
+ const handleSubmit = useCallback3((text) => {
614
+ if (!activeRef.current) {
615
+ event.emit({
616
+ type: "submit",
617
+ text
618
+ });
619
+ return true;
620
+ }
621
+ }, [
622
+ event
623
+ ]);
624
+ const handleEvent = useCallback3((ev) => {
625
+ event.emit(ev);
626
+ }, [
627
+ event
628
+ ]);
629
+ return /* @__PURE__ */ React7.createElement("div", {
630
+ role: "group",
631
+ className: mx5("flex flex-col w-full dx-density-fine", outline && "bg-group-surface rounded-sm! border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator", classNames)
632
+ }, /* @__PURE__ */ React7.createElement(ChatMcpErrors, {
633
+ processor
634
+ }), /* @__PURE__ */ React7.createElement("div", {
635
+ role: "none",
636
+ className: "flex p-2 gap-2"
637
+ }, /* @__PURE__ */ React7.createElement(ChatStatusIndicator, {
638
+ classNames: "p-1",
639
+ preset,
640
+ error,
641
+ processing: streaming
642
+ }), /* @__PURE__ */ React7.createElement(ChatEditor, {
643
+ ref: editorRef,
644
+ autoFocus: true,
645
+ lineWrapping: true,
646
+ classNames: "col-span-2 pt-0.5",
647
+ placeholder: placeholder ?? t("prompt.placeholder"),
648
+ extensions,
649
+ onSubmit: handleSubmit
650
+ })), db && settings && /* @__PURE__ */ React7.createElement("div", {
651
+ role: "none",
652
+ className: "flex items-center overflow-hidden p-1.5"
653
+ }, /* @__PURE__ */ React7.createElement(ChatOptions, {
654
+ chat,
655
+ db,
656
+ blueprintRegistry: processor.blueprintRegistry,
657
+ context: processor.context,
658
+ preset,
659
+ presets,
660
+ onPresetChange
661
+ }), /* @__PURE__ */ React7.createElement("div", {
662
+ role: "none",
663
+ className: "flex h-8 grow overflow-x-auto scrollbar-none"
664
+ }, /* @__PURE__ */ React7.createElement(ChatReferences, {
665
+ db,
666
+ context: processor.context
667
+ })), /* @__PURE__ */ React7.createElement(ChatActions, {
668
+ classNames: "col-span-2",
669
+ microphone: true,
670
+ recording,
671
+ processing: streaming,
672
+ onEvent: handleEvent
673
+ }, online !== void 0 && /* @__PURE__ */ React7.createElement(Input2.Root, null, /* @__PURE__ */ React7.createElement(Input2.Label, {
674
+ srOnly: true
675
+ }, t("online-switch.label")), /* @__PURE__ */ React7.createElement(Input2.Switch, {
676
+ classNames: "mx-1",
677
+ checked: online,
678
+ onCheckedChange: onOnlineChange
679
+ })))));
680
+ };
681
+ ChatPrompt.displayName = "Chat.Prompt";
682
+
683
+ // src/components/ChatPrompt/ChatStatus.tsx
684
+ import React8, { useEffect as useEffect3, useMemo as useMemo2, useState as useState4 } from "react";
685
+ import { ChatStatus as NaturalChatStatus, formatElapsed } from "@dxos/react-ui-chat";
686
+ import { Matrix } from "@dxos/react-ui-sfx";
687
+ import { Unit } from "@dxos/util";
688
+
689
+ // src/components/Chat/context.ts
690
+ import { createContext } from "@radix-ui/react-context";
691
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
692
+
693
+ // src/components/ChatPrompt/ChatStatus.tsx
694
+ var CHAT_STREAM_STATUS_NAME = "Chat.StreamStatus";
695
+ var TICK_MS = 1e3;
696
+ var ChatStatus = ({ classNames, icon }) => {
697
+ const { messages, requestTiming } = useChatContext(CHAT_STREAM_STATUS_NAME);
698
+ const { lastOutputTokens, sessionTotalTokens } = useMemo2(() => {
699
+ let last;
700
+ let total = 0;
701
+ for (const message of messages) {
702
+ for (const block of message.blocks) {
703
+ if (isStats(block) && block.usage) {
704
+ last = block.usage.outputTokens;
705
+ total += block.usage.totalTokens ?? 0;
706
+ }
707
+ }
708
+ }
709
+ return {
710
+ lastOutputTokens: last,
711
+ sessionTotalTokens: total
712
+ };
713
+ }, [
714
+ messages
715
+ ]);
716
+ const isRunning = requestTiming != null && requestTiming.endedAt == null;
717
+ const show = requestTiming || lastOutputTokens || sessionTotalTokens > 0;
718
+ if (!show) {
719
+ return null;
720
+ }
721
+ return /* @__PURE__ */ React8.createElement(NaturalChatStatus.Root, {
722
+ defaultRunning: false,
723
+ classNames: [
724
+ "py-2 gap-2 text-sm",
725
+ classNames
726
+ ]
727
+ }, icon && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Icon, null, /* @__PURE__ */ React8.createElement(Matrix, {
728
+ classNames: "w-5 h-5",
729
+ dotClassNames: "bg-primary-500",
730
+ dim: 4,
731
+ dotSize: 3,
732
+ count: 10,
733
+ interval: 500,
734
+ active: isRunning
735
+ })), show && /* @__PURE__ */ React8.createElement("div", {
736
+ role: "none",
737
+ className: "flex items-center"
738
+ }, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, /* @__PURE__ */ React8.createElement(Elapsed, {
739
+ timing: requestTiming
740
+ })), lastOutputTokens != null && /* @__PURE__ */ React8.createElement(React8.Fragment, null, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u2193 ", Unit.Thousand(lastOutputTokens).toString())), sessionTotalTokens > 0 && /* @__PURE__ */ React8.createElement(React8.Fragment, null, (requestTiming || lastOutputTokens != null) && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u03A3 ", Unit.Thousand(sessionTotalTokens).toString()))));
741
+ };
742
+ var Elapsed = ({ timing }) => {
743
+ const isRunning = timing.endedAt == null;
744
+ const [now, setNow] = useState4(Date.now());
745
+ useEffect3(() => {
746
+ if (!isRunning) {
747
+ return;
748
+ }
749
+ const id = setInterval(() => setNow(Date.now()), TICK_MS);
750
+ return () => clearInterval(id);
751
+ }, [
752
+ isRunning
753
+ ]);
754
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, formatElapsed((timing.endedAt ?? now) - timing.startedAt));
755
+ };
756
+ var isStats = (block) => block._tag === "stats";
757
+
758
+ // src/components/ChatThread/ChatThread.tsx
759
+ import React13, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo4, useState as useState6 } from "react";
760
+ import { PublicKey } from "@dxos/keys";
761
+ import { setRef } from "@dxos/react-ui";
762
+ import { MarkdownStream } from "@dxos/react-ui-markdown";
763
+ import { keyToFallback } from "@dxos/util";
764
+
765
+ // src/components/ChatThread/registry.tsx
766
+ import React12 from "react";
767
+ import { log } from "@dxos/log";
768
+ import { getXmlTextChild } from "@dxos/ui-editor";
769
+
770
+ // src/components/ChatThread/tool-widget-state.ts
771
+ var applyToolBlockToWidgetState = (context, block) => {
772
+ switch (block._tag) {
773
+ case "toolCall": {
774
+ context.updateWidget(block.toolCallId, {
775
+ blocks: [
776
+ block
777
+ ]
778
+ });
779
+ break;
780
+ }
781
+ case "toolResult": {
782
+ context.updateWidget(block.toolCallId, ({ blocks = [] } = {
783
+ blocks: []
784
+ }) => ({
785
+ blocks: [
786
+ ...blocks,
787
+ block
788
+ ]
789
+ }));
790
+ break;
791
+ }
792
+ default: {
793
+ break;
794
+ }
795
+ }
796
+ };
797
+ var rehydrateToolWidgetsFromMessages = (context, messages) => {
798
+ for (const message of messages) {
799
+ for (const block of message.blocks) {
800
+ applyToolBlockToWidgetState(context, block);
801
+ }
802
+ }
803
+ };
804
+
805
+ // src/components/ChatThread/widgets/FallbackWidget.tsx
806
+ import React9 from "react";
807
+ import { TogglePanel } from "@dxos/react-ui-components";
808
+ import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
809
+ var FallbackWidget = ({ _tag, ...props }) => {
810
+ return /* @__PURE__ */ React9.createElement(TogglePanel.Root, null, /* @__PURE__ */ React9.createElement(TogglePanel.Header, {
811
+ classNames: "bg-group-surface"
812
+ }, _tag), /* @__PURE__ */ React9.createElement(TogglePanel.Content, {
813
+ classNames: "bg-modal-surface"
814
+ }, /* @__PURE__ */ React9.createElement(TogglePanel.Viewport, null, /* @__PURE__ */ React9.createElement(JsonHighlighter, {
815
+ classNames: "p-2! text-sm",
816
+ data: props
817
+ }))));
818
+ };
819
+ FallbackWidget.displayName = "Fallback";
820
+
821
+ // src/components/ChatThread/widgets/ReasoningWidget.ts
822
+ import { WidgetType } from "@codemirror/view";
823
+ import { Domino } from "@dxos/ui";
824
+
825
+ // src/components/ChatThread/widgets/defaults.ts
826
+ var styles2 = {
827
+ padding: "my-4",
828
+ border: "border border-subdued-separator rounded-sm"
829
+ };
830
+
831
+ // src/components/ChatThread/widgets/ReasoningWidget.ts
832
+ var ReasoningWidget = class extends WidgetType {
833
+ text;
834
+ #pos;
835
+ /** The timer id last registered for this instance (may differ from the map if superseded). */
836
+ #ownedTimerId = null;
837
+ constructor(text, pos) {
838
+ super(), this.text = text;
839
+ this.#pos = pos === void 0 || pos === "" ? "reasoning" : String(pos);
840
+ }
841
+ eq(other) {
842
+ return this.text === other.text && this.#pos === other.#pos;
843
+ }
844
+ toDOM() {
845
+ return Domino.of("div").classNames(styles2.padding).append(Domino.of("div").classNames("relative overflow-hidden p-px", styles2.border).attributes({
846
+ "data-trail-container": ""
847
+ }).append(Domino.of("div").classNames("relative z-10 bg-base-surface rounded-sm text-sm text-subdued py-1").append(Domino.of("div").classNames("px-2 max-h-[5lh] overflow-y-auto dx-scrollbar-thin").text(this.text).attributes({
848
+ "data-reasoning-text": ""
849
+ })), Domino.of("div").attributes({
850
+ "data-id": this.#pos
851
+ }))).root;
852
+ }
853
+ updateDOM(dom) {
854
+ dom.querySelector("[data-reasoning-text]")?.replaceChildren(this.text);
855
+ const container = dom.querySelector("[data-trail-container]");
856
+ let trailHost = container?.querySelector("[data-id]");
857
+ if (container && !trailHost) {
858
+ trailHost = Domino.of("div").attributes({
859
+ "data-id": this.#pos
860
+ }).root;
861
+ container.append(trailHost);
862
+ }
863
+ if (trailHost?.childElementCount === 0) {
864
+ trailHost.append(...createTrailLayers());
865
+ }
866
+ this.#scheduleTrailRemoval(dom);
867
+ return true;
868
+ }
869
+ destroy(_dom) {
870
+ this.#clearOwnedTrailTimer();
871
+ }
872
+ #scheduleTrailRemoval(dom) {
873
+ const previous = trailRemovalTimers.get(this.#pos);
874
+ if (previous !== void 0) {
875
+ clearTimeout(previous);
876
+ }
877
+ const timerId = setTimeout(() => {
878
+ if (trailRemovalTimers.get(this.#pos) !== timerId) {
879
+ return;
880
+ }
881
+ trailRemovalTimers.delete(this.#pos);
882
+ this.#ownedTimerId = null;
883
+ dom.querySelector("[data-id]")?.remove();
884
+ }, TRAIL_REMOVAL_DELAY_MS);
885
+ trailRemovalTimers.set(this.#pos, timerId);
886
+ this.#ownedTimerId = timerId;
887
+ }
888
+ #clearOwnedTrailTimer() {
889
+ const active = trailRemovalTimers.get(this.#pos);
890
+ if (active !== void 0 && active === this.#ownedTimerId) {
891
+ clearTimeout(active);
892
+ trailRemovalTimers.delete(this.#pos);
893
+ }
894
+ this.#ownedTimerId = null;
895
+ }
896
+ };
897
+ var trail = [
898
+ "absolute z-0 aspect-[2/1] w-16",
899
+ "bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
900
+ "[offset-anchor:100%_50%] [offset-path:border-box]"
901
+ ];
902
+ var TRAIL_REMOVAL_DELAY_MS = 1e3;
903
+ var trailRemovalTimers = /* @__PURE__ */ new Map();
904
+ var createTrailLayers = () => [
905
+ Domino.of("div").classNames(...trail, "animate-trail").root,
906
+ Domino.of("div").classNames(...trail, "animate-trail-offset").root
907
+ ];
908
+
909
+ // src/components/ChatThread/widgets/ReferenceWidget.ts
910
+ import { WidgetType as WidgetType2 } from "@codemirror/view";
911
+ import { Domino as Domino2 } from "@dxos/ui";
912
+ var ReferenceWidget = class extends WidgetType2 {
913
+ text;
914
+ dxn;
915
+ constructor(text, dxn) {
916
+ super(), this.text = text, this.dxn = dxn;
917
+ }
918
+ eq(other) {
919
+ return this.dxn === other.dxn;
920
+ }
921
+ toDOM() {
922
+ return Domino2.of("div").classNames(styles2.padding).append(Domino2.of("dx-anchor").classNames("dx-tag--anchor").attributes({
923
+ dxn: this.dxn
924
+ }).text(this.text)).root;
925
+ }
926
+ };
927
+
928
+ // src/components/ChatThread/widgets/SelectWidget.ts
929
+ import { WidgetType as WidgetType3 } from "@codemirror/view";
930
+ import { Domino as Domino3 } from "@dxos/ui";
931
+ var SelectWidget = class extends WidgetType3 {
932
+ options;
933
+ constructor(options) {
934
+ super(), this.options = options;
935
+ }
936
+ eq(other) {
937
+ return JSON.stringify(this.options) === JSON.stringify(other.options);
938
+ }
939
+ /**
940
+ * NOTE: Container must set var based on user's identity.
941
+ */
942
+ toDOM() {
943
+ return Domino3.of("div").attributes({
944
+ role: "group"
945
+ }).classNames(styles2.padding, "flex flex-wrap gap-1").append(...this.options.map((option) => Domino3.of("button").classNames("dx-button inline-block max-w-[100cqi]").attributes({
946
+ "data-action": "submit",
947
+ "data-value": option,
948
+ "data-density": "fine"
949
+ }).text(option))).root;
950
+ }
951
+ };
952
+
953
+ // src/components/ChatThread/widgets/StatsWidget.ts
954
+ import { WidgetType as WidgetType4 } from "@codemirror/view";
955
+ import { Domino as Domino4 } from "@dxos/ui";
956
+ var StatsWidget = class extends WidgetType4 {
957
+ text;
958
+ constructor(text) {
959
+ super(), this.text = text;
960
+ }
961
+ eq(other) {
962
+ return this.text === other.text;
963
+ }
964
+ toDOM() {
965
+ return Domino4.of("div").classNames(styles2.padding, "text-sm text-placeholder").text(this.text).root;
966
+ }
967
+ updateDOM(dom) {
968
+ dom.textContent = this.text;
969
+ return true;
970
+ }
971
+ };
972
+
973
+ // src/components/ChatThread/widgets/StatusWidget.ts
974
+ import { WidgetType as WidgetType5 } from "@codemirror/view";
975
+ import { Domino as Domino5 } from "@dxos/ui";
976
+ var StatusWidget = class extends WidgetType5 {
977
+ text;
978
+ constructor(text) {
979
+ super(), this.text = text;
980
+ }
981
+ eq(other) {
982
+ return this.text === other.text;
983
+ }
984
+ toDOM() {
985
+ return Domino5.of("div").classNames(styles2.padding).append(Domino5.of("div").classNames("relative overflow-hidden rounded-sm").append(Domino5.of("div").classNames("grid grid-cols-[24px_1fr] gap-x-0.5 gap-y-0 items-start px-0.5 py-0.5 text-placeholder").append(Domino5.of("div").classNames("flex h-5 w-full shrink-0 items-center justify-center self-start").append(Domino5.of("span").classNames("block size-1.5 shrink-0 rounded-full bg-current opacity-45")), Domino5.of("div").classNames("relative min-w-0").append(Domino5.of("div").classNames("relative z-10 rounded-sm text-sm leading-5").attributes({
986
+ "data-status-text": ""
987
+ }).text(this.text))))).root;
988
+ }
989
+ updateDOM(dom) {
990
+ dom.querySelector("[data-status-text]")?.replaceChildren(this.text);
991
+ return true;
992
+ }
993
+ };
994
+
995
+ // src/components/ChatThread/widgets/SummaryWidget.tsx
996
+ import React10 from "react";
997
+ import { useTranslation as useTranslation6 } from "@dxos/react-ui";
998
+ import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
999
+ import { meta as meta6 } from "#meta";
1000
+ var SummaryWidget = ({ children }) => {
1001
+ const { t } = useTranslation6(meta6.id);
1002
+ return /* @__PURE__ */ React10.createElement(TogglePanel2.Root, {
1003
+ classNames: styles2.border
1004
+ }, /* @__PURE__ */ React10.createElement(TogglePanel2.Header, {
1005
+ classNames: "text-sm bg-group-surface"
1006
+ }, t("summary.label")), /* @__PURE__ */ React10.createElement(TogglePanel2.Content, null, /* @__PURE__ */ React10.createElement("div", {
1007
+ role: "none",
1008
+ className: "p-1 text-sm text-subdued"
1009
+ }, children)));
1010
+ };
1011
+
1012
+ // src/components/ChatThread/widgets/SuggestionWidget.ts
1013
+ import { WidgetType as WidgetType6 } from "@codemirror/view";
1014
+ import { Domino as Domino6, mx as mx6 } from "@dxos/ui";
1015
+ var SuggestionWidget = class extends WidgetType6 {
1016
+ text;
1017
+ constructor(text) {
1018
+ super(), this.text = text;
1019
+ }
1020
+ eq(other) {
1021
+ return this.text === other.text;
1022
+ }
1023
+ toDOM() {
1024
+ return Domino6.of("span").classNames(mx6("inline-flex max-w-[calc(100cqi-8px)] my-1 pe-2 overflow-hidden")).append(Domino6.of("button").attributes({
1025
+ "data-action": "submit",
1026
+ "data-density": "fine",
1027
+ "data-value": this.text
1028
+ }).classNames(mx6("dx-button gap-2 w-full overflow-hidden")).append(Domino6.of("dx-icon").attributes({
1029
+ icon: "ph--lightning--regular"
1030
+ }), Domino6.of("span").classNames("flex-1 truncate min-w-0").text(this.text))).root;
1031
+ }
1032
+ };
1033
+
1034
+ // src/components/ChatThread/widgets/ToolWidget.tsx
1035
+ import React11, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
1036
+ import { useTranslation as useTranslation7 } from "@dxos/react-ui";
1037
+ import { NumericTabs, TextCrawl, TogglePanel as TogglePanel3 } from "@dxos/react-ui-components";
1038
+ import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
1039
+ import { isNonNullable, safeParseJson } from "@dxos/util";
1040
+ import { meta as meta7 } from "#meta";
1041
+ var ToolWidget = ({ view, blocks = [] }) => {
1042
+ const { t } = useTranslation7(meta7.id);
1043
+ const items = useMemo3(() => {
1044
+ let lastToolCall;
1045
+ const tools = [];
1046
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
1047
+ switch (block._tag) {
1048
+ case "toolCall": {
1049
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
1050
+ return null;
1051
+ }
1052
+ const tool = tools.find((tool2) => tool2.name === block.name);
1053
+ lastToolCall = {
1054
+ tool,
1055
+ block
1056
+ };
1057
+ return {
1058
+ title: tool?.description ?? [
1059
+ t("tool-call.label"),
1060
+ block.name
1061
+ ].filter(Boolean).join(" "),
1062
+ content: {
1063
+ ...block,
1064
+ input: safeParseJson(block.input)
1065
+ }
1066
+ };
1067
+ }
1068
+ case "toolResult": {
1069
+ if (block.error) {
1070
+ return {
1071
+ title: t("tool-error.label"),
1072
+ content: block
1073
+ };
1074
+ }
1075
+ const title = lastToolCall?.tool?.description ?? [
1076
+ t("tool-result.label"),
1077
+ lastToolCall?.block.name
1078
+ ].filter(Boolean).join(" ");
1079
+ lastToolCall = void 0;
1080
+ return {
1081
+ title,
1082
+ content: {
1083
+ ...block,
1084
+ result: safeParseJson(block.result)
1085
+ }
1086
+ };
1087
+ }
1088
+ case "stats": {
1089
+ if (!lastToolCall) {
1090
+ return null;
1091
+ }
1092
+ return {
1093
+ title: t("stats.label"),
1094
+ content: block
1095
+ };
1096
+ }
1097
+ }
1098
+ }).filter(isNonNullable);
1099
+ }, [
1100
+ blocks,
1101
+ t
1102
+ ]);
1103
+ const handleChangeOpen = useCallback4(() => {
1104
+ setTimeout(() => {
1105
+ view?.requestMeasure();
1106
+ }, 1e3);
1107
+ }, [
1108
+ view
1109
+ ]);
1110
+ if (!items.length) {
1111
+ return null;
1112
+ }
1113
+ return /* @__PURE__ */ React11.createElement(ToolPanel, {
1114
+ items,
1115
+ onChangeOpen: handleChangeOpen
1116
+ });
1117
+ };
1118
+ var ToolPanel = ({ items, onChangeOpen }) => {
1119
+ const tabsRef = useRef2(null);
1120
+ const [selected, setSelected] = useState5(0);
1121
+ const [open, setOpen] = useState5(false);
1122
+ useEffect4(() => {
1123
+ setSelected((prev) => Math.min(prev, Math.max(0, items.length - 1)));
1124
+ }, [
1125
+ items.length
1126
+ ]);
1127
+ useEffect4(() => {
1128
+ onChangeOpen?.(open);
1129
+ if (open) {
1130
+ tabsRef.current?.focus();
1131
+ }
1132
+ }, [
1133
+ open,
1134
+ onChangeOpen
1135
+ ]);
1136
+ const handleSelect = useCallback4((index) => {
1137
+ setSelected(index);
1138
+ }, []);
1139
+ return /* @__PURE__ */ React11.createElement(TogglePanel3.Root, {
1140
+ open,
1141
+ onChangeOpen: setOpen
1142
+ }, /* @__PURE__ */ React11.createElement(TogglePanel3.Header, {
1143
+ classNames: "text-sm text-placeholder"
1144
+ }, /* @__PURE__ */ React11.createElement(TextCrawl, {
1145
+ key: "status-roll",
1146
+ lines: items.map((item) => item.title),
1147
+ autoAdvance: true,
1148
+ greedy: true
1149
+ })), /* @__PURE__ */ React11.createElement(TogglePanel3.Content, null, /* @__PURE__ */ React11.createElement(TogglePanel3.Viewport, {
1150
+ classNames: "grid grid-cols-[32px_1fr]"
1151
+ }, /* @__PURE__ */ React11.createElement(NumericTabs, {
1152
+ ref: tabsRef,
1153
+ classNames: "p-1",
1154
+ length: items.length,
1155
+ selected,
1156
+ onSelect: handleSelect
1157
+ }), /* @__PURE__ */ React11.createElement(JsonHighlighter2, {
1158
+ data: items[selected]?.content,
1159
+ classNames: "p-1 text-xs bg-transparent",
1160
+ replacer: {
1161
+ maxDepth: 3,
1162
+ maxArrayLen: 10,
1163
+ maxStringLen: 128
1164
+ }
1165
+ }))));
1166
+ };
1167
+
1168
+ // src/components/ChatThread/registry.tsx
1169
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1170
+ var componentRegistry = {
1171
+ //
1172
+ // Block-only (no widget — see note above).
1173
+ //
1174
+ prompt: {
1175
+ block: true
1176
+ },
1177
+ //
1178
+ // DOM Widgets
1179
+ //
1180
+ synthetic: {
1181
+ block: true,
1182
+ factory: ({ children, range }) => {
1183
+ const text = getXmlTextChild(children);
1184
+ return text ? new ReasoningWidget(text, range.from) : null;
1185
+ }
1186
+ },
1187
+ reasoning: {
1188
+ block: true,
1189
+ streaming: true,
1190
+ factory: ({ children, range }) => {
1191
+ const text = getXmlTextChild(children);
1192
+ return text ? new ReasoningWidget(text, range.from) : null;
1193
+ }
1194
+ },
1195
+ reference: {
1196
+ block: false,
1197
+ factory: ({ children, ref }) => {
1198
+ const text = getXmlTextChild(children);
1199
+ return text && ref ? new ReferenceWidget(text, ref) : null;
1200
+ }
1201
+ },
1202
+ select: {
1203
+ block: true,
1204
+ factory: ({ children }) => {
1205
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1206
+ return options?.length ? new SelectWidget(options) : null;
1207
+ }
1208
+ },
1209
+ suggestion: {
1210
+ block: true,
1211
+ factory: ({ children }) => {
1212
+ const text = getXmlTextChild(children);
1213
+ return text ? new SuggestionWidget(text) : null;
1214
+ }
1215
+ },
1216
+ stats: {
1217
+ block: true,
1218
+ factory: ({ children }) => {
1219
+ const text = getXmlTextChild(children);
1220
+ return text ? new StatsWidget(text) : null;
1221
+ }
1222
+ },
1223
+ status: {
1224
+ block: true,
1225
+ streaming: true,
1226
+ factory: ({ children }) => {
1227
+ const text = getXmlTextChild(children);
1228
+ return text ? new StatusWidget(text) : null;
1229
+ }
1230
+ },
1231
+ //
1232
+ // React Widgets (portaled outside of the editor)
1233
+ //
1234
+ summary: {
1235
+ block: true,
1236
+ Component: SummaryWidget
1237
+ },
1238
+ toolCall: {
1239
+ block: true,
1240
+ Component: (props) => /* @__PURE__ */ React12.createElement("div", {
1241
+ role: "none",
1242
+ className: "py-2"
1243
+ }, /* @__PURE__ */ React12.createElement(ToolWidget, props))
1244
+ },
1245
+ toolResult: {
1246
+ block: true,
1247
+ Component: FallbackWidget
1248
+ },
1249
+ toolkit: {
1250
+ block: true,
1251
+ Component: FallbackWidget
1252
+ },
1253
+ //
1254
+ // Fallback
1255
+ //
1256
+ json: {
1257
+ block: true,
1258
+ Component: FallbackWidget
1259
+ }
1260
+ };
1261
+ var blockToMarkdown = createBlockRenderer("normal");
1262
+ function createBlockRenderer(viewType) {
1263
+ return (context, message, block) => {
1264
+ if (!isBlockVisible(viewType, message, block)) {
1265
+ return;
1266
+ }
1267
+ let str = blockToMarkdownImpl(context, message, block);
1268
+ if (str && !block.pending) {
1269
+ return str += "\n";
1270
+ }
1271
+ return str;
1272
+ };
1273
+ }
1274
+ var isBlockVisible = (viewType, message, block) => {
1275
+ switch (viewType) {
1276
+ case "debug":
1277
+ return true;
1278
+ case "normal":
1279
+ return block._tag !== "reasoning";
1280
+ case "summary":
1281
+ return block._tag === "text" && block.disposition !== "synthetic";
1282
+ case "thinking":
1283
+ default:
1284
+ return true;
1285
+ }
1286
+ };
1287
+ var blockToMarkdownImpl = (context, message, block) => {
1288
+ log("blockToMarkdown", {
1289
+ block: JSON.stringify(block)
1290
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 155, S: void 0 });
1291
+ switch (block._tag) {
1292
+ case "text": {
1293
+ if (message.sender.role === "user") {
1294
+ if (block.disposition === "synthetic") {
1295
+ return renderXMLBlock("synthetic", {
1296
+ content: block.text,
1297
+ pending: block.pending
1298
+ });
1299
+ } else {
1300
+ return `
1301
+ <prompt>${block.text}</prompt>`;
1302
+ }
1303
+ } else {
1304
+ const text = block.text.trim();
1305
+ if (text.length > 0) {
1306
+ return text;
1307
+ }
1308
+ }
1309
+ break;
1310
+ }
1311
+ case "reference": {
1312
+ if (block.pending) {
1313
+ return;
1314
+ }
1315
+ const dxn = block.reference.dxn;
1316
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
1317
+ }
1318
+ case "suggestion": {
1319
+ if (block.pending) {
1320
+ return;
1321
+ }
1322
+ return `<suggestion>${block.text}</suggestion>`;
1323
+ }
1324
+ case "select": {
1325
+ if (block.pending || block.options.length === 0) {
1326
+ return;
1327
+ }
1328
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1329
+ }
1330
+ case "toolCall": {
1331
+ applyToolBlockToWidgetState(context, block);
1332
+ return `<toolCall id="${block.toolCallId}" />`;
1333
+ }
1334
+ case "toolResult": {
1335
+ applyToolBlockToWidgetState(context, block);
1336
+ break;
1337
+ }
1338
+ case "stats": {
1339
+ return "";
1340
+ }
1341
+ case "reasoning": {
1342
+ let text = block.reasoningText ?? block.redactedText;
1343
+ if (!text) {
1344
+ return;
1345
+ }
1346
+ return renderXMLBlock("reasoning", {
1347
+ content: text,
1348
+ pending: block.pending
1349
+ });
1350
+ }
1351
+ case "summary": {
1352
+ return renderXMLBlock("summary", {
1353
+ content: block.content,
1354
+ pending: block.pending
1355
+ });
1356
+ }
1357
+ case "status": {
1358
+ return renderXMLBlock("status", {
1359
+ content: block.statusText,
1360
+ pending: block.pending
1361
+ });
1362
+ }
1363
+ default: {
1364
+ return `<json id="${message.id}">
1365
+ ${JSON.stringify(block)}
1366
+ </json>`;
1367
+ }
1368
+ }
1369
+ };
1370
+ var escapeXmlTextContent = (raw) => raw.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1371
+ var renderXMLBlock = (tag, opts) => {
1372
+ const content = escapeXmlTextContent((opts.content ?? "").replace(/\n\n/g, " ").trim());
1373
+ if (opts.pending) {
1374
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}`;
1375
+ } else {
1376
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}</${tag}>`;
1377
+ }
1378
+ };
1379
+
1380
+ // src/components/ChatThread/sync.ts
1381
+ var MessageThreadContext = class {
1382
+ _widgetState;
1383
+ constructor(_widgetState) {
1384
+ this._widgetState = _widgetState;
1385
+ }
1386
+ updateWidget(id, value2) {
1387
+ this._widgetState?.updateWidget(id, value2);
1388
+ }
1389
+ // TODO(burdon): Resolve name from hypergraph.
1390
+ getObjectLabel(_id) {
1391
+ return "Object";
1392
+ }
1393
+ };
1394
+ var MessageSyncer = class {
1395
+ _document;
1396
+ _renderer;
1397
+ _threadId;
1398
+ _completed = 0;
1399
+ _trailing = 0;
1400
+ _context;
1401
+ constructor(_document, _renderer) {
1402
+ this._document = _document;
1403
+ this._renderer = _renderer;
1404
+ this._context = new MessageThreadContext(this._document);
1405
+ }
1406
+ get context() {
1407
+ return this._context;
1408
+ }
1409
+ /**
1410
+ * Replace the document with the rendering of `messages`. Use on mount, on thread switch,
1411
+ * and from {@link update} when it detects an identity change in `messages[0]`.
1412
+ */
1413
+ reset(messages = []) {
1414
+ this._threadId = messages[0]?.id;
1415
+ this._completed = 0;
1416
+ this._trailing = 0;
1417
+ const buffer = this._walk(messages);
1418
+ void this._document.setContent(buffer).then(() => {
1419
+ rehydrateToolWidgetsFromMessages(this._context, messages);
1420
+ });
1421
+ }
1422
+ /**
1423
+ * Stream the suffix of the rendered messages into the document.
1424
+ * Returns `true` if the document was replaced (initial mount or thread switch), `false`
1425
+ * if the call was a streaming append (or a no-op).
1426
+ */
1427
+ update(messages) {
1428
+ if (messages[0]?.id !== this._threadId) {
1429
+ this.reset(messages);
1430
+ return true;
1431
+ }
1432
+ const buffer = this._walk(messages);
1433
+ if (buffer.length > 0) {
1434
+ void this._document.append(buffer);
1435
+ }
1436
+ return false;
1437
+ }
1438
+ /**
1439
+ * Walk flat blocks starting at `_completed`, advancing the cursors and returning the chars
1440
+ * to append. Blocks before `_completed` are skipped — their renderer is never re-invoked,
1441
+ * which preserves single-shot side effects (e.g. tool widget state mutation).
1442
+ */
1443
+ _walk(messages) {
1444
+ let buffer = "";
1445
+ let index = 0;
1446
+ outer: for (const message of messages) {
1447
+ for (const block of message.blocks) {
1448
+ if (index < this._completed) {
1449
+ index++;
1450
+ continue;
1451
+ }
1452
+ const rendered = this._renderer(this._context, message, block) ?? "";
1453
+ if (rendered.length > this._trailing) {
1454
+ buffer += rendered.slice(this._trailing);
1455
+ }
1456
+ if (block.pending) {
1457
+ if (rendered.length > this._trailing) {
1458
+ this._trailing = rendered.length;
1459
+ }
1460
+ break outer;
1461
+ }
1462
+ this._completed = index + 1;
1463
+ this._trailing = 0;
1464
+ index++;
1465
+ }
1466
+ }
1467
+ return buffer;
1468
+ }
1469
+ };
1470
+
1471
+ // src/components/ChatThread/ChatThread.tsx
1472
+ var defaultOptions = {
1473
+ autoScroll: true,
1474
+ cursor: false,
1475
+ fader: false,
1476
+ typewriter: true
1477
+ };
1478
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, options = defaultOptions, footer, debug = false, extensions, viewType, onEvent }, forwardedRef) => {
1479
+ const [controller, setController] = useState6(null);
1480
+ const handleMarkdownStreamRef = useCallback5((instance) => {
1481
+ setController(instance);
1482
+ setRef(forwardedRef, instance);
1483
+ }, [
1484
+ forwardedRef
1485
+ ]);
1486
+ const userHue = useMemo4(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
1487
+ identity
1488
+ ]);
1489
+ useEffect5(() => {
1490
+ controller?.scrollToBottom();
1491
+ }, [
1492
+ controller,
1493
+ error
1494
+ ]);
1495
+ const renderer = useMemo4(() => createBlockRenderer(viewType), [
1496
+ viewType
1497
+ ]);
1498
+ const syncer = useMemo4(() => controller && new MessageSyncer(controller, renderer), [
1499
+ controller,
1500
+ renderer
1501
+ ]);
1502
+ useEffect5(() => {
1503
+ if (!syncer) {
1504
+ return;
1505
+ }
1506
+ if (syncer.update(messages)) {
1507
+ controller?.scrollToBottom("instant");
1508
+ }
1509
+ }, [
1510
+ controller,
1511
+ syncer,
1512
+ messages
1513
+ ]);
1514
+ const handleEvent = useCallback5(({ type, value: value2 }) => {
1515
+ switch (type) {
1516
+ case "submit": {
1517
+ value2 && onEvent?.({
1518
+ type,
1519
+ text: value2
1520
+ });
1521
+ break;
1522
+ }
1523
+ }
1524
+ }, [
1525
+ onEvent
1526
+ ]);
1527
+ return /* @__PURE__ */ React13.createElement("div", {
1528
+ role: "none",
1529
+ "data-hue": userHue,
1530
+ className: "contents"
1531
+ }, /* @__PURE__ */ React13.createElement(MarkdownStream, {
1532
+ key: viewType,
1533
+ classNames,
1534
+ registry: componentRegistry,
1535
+ options,
1536
+ debug,
1537
+ extensions,
1538
+ footer,
1539
+ onEvent: handleEvent,
1540
+ ref: handleMarkdownStreamRef
1541
+ }));
1542
+ });
1543
+
1544
+ // src/components/Chat/Chat.tsx
1545
+ var ChatRoot = ({ children, chat, feed, processor, onEvent, ...props }) => {
1546
+ const [debug, setDebug] = useState7(false);
1547
+ const streaming = useAtomValue3(processor.streaming);
1548
+ const active = useAtomValue3(processor.active);
1549
+ const requestTiming = useRequestTiming({
1550
+ active
1551
+ });
1552
+ const lastPrompt = useRef3(void 0);
1553
+ const db = props.db ?? (chat && Obj3.getDatabase(chat));
1554
+ const feedMessages = useQuery2(feed, Filter2.type(Message2.Message));
1555
+ const pendingMessages = useAtomValue3(processor.messages);
1556
+ const messages = useMemo5(() => Array.dedupeWith([
1557
+ ...feedMessages,
1558
+ ...pendingMessages
1559
+ ], ({ id: a }, { id: b }) => a === b), [
1560
+ feedMessages,
1561
+ pendingMessages
1562
+ ]);
1563
+ const dump = useDebug({
1564
+ processor
1565
+ });
1566
+ const event = useMemo5(() => new Event(), []);
1567
+ useEffect6(() => {
1568
+ return event.on((ev) => {
1569
+ switch (ev.type) {
1570
+ case "toggle-debug": {
1571
+ setDebug((debug2) => {
1572
+ if (debug2) {
1573
+ return false;
1574
+ } else {
1575
+ void dump();
1576
+ return true;
1577
+ }
1578
+ });
1579
+ break;
1580
+ }
1581
+ case "submit": {
1582
+ const text = ev.text.trim();
1583
+ if (!streaming && text.length) {
1584
+ lastPrompt.current = ev.text;
1585
+ void processor.request({
1586
+ message: text
1587
+ });
1588
+ }
1589
+ break;
1590
+ }
1591
+ case "retry": {
1592
+ if (!streaming) {
1593
+ void processor.retry();
1594
+ }
1595
+ break;
1596
+ }
1597
+ case "cancel": {
1598
+ if (streaming) {
1599
+ void processor.cancel();
1600
+ if (lastPrompt.current) {
1601
+ event.emit({
1602
+ type: "update-prompt",
1603
+ text: lastPrompt.current
1604
+ });
1605
+ }
1606
+ }
1607
+ break;
1608
+ }
1609
+ }
1610
+ onEvent?.(ev);
1611
+ });
1612
+ }, [
1613
+ event,
1614
+ dump,
1615
+ processor,
1616
+ streaming,
1617
+ onEvent
1618
+ ]);
1619
+ return /* @__PURE__ */ React14.createElement(ChatContextProvider, {
1620
+ debug,
1621
+ event,
1622
+ db,
1623
+ chat,
1624
+ messages,
1625
+ processor,
1626
+ requestTiming,
1627
+ ...props
1628
+ }, children);
1629
+ };
1630
+ ChatRoot.displayName = "Chat.Root";
1631
+ var useRequestTiming = ({ active }) => {
1632
+ const [requestTiming, setRequestTiming] = useState7(null);
1633
+ useEffect6(() => {
1634
+ if (active) {
1635
+ setRequestTiming({
1636
+ startedAt: Date.now(),
1637
+ endedAt: null
1638
+ });
1639
+ } else {
1640
+ setRequestTiming((prev) => prev && prev.endedAt == null ? {
1641
+ ...prev,
1642
+ endedAt: Date.now()
1643
+ } : prev);
1644
+ }
1645
+ }, [
1646
+ active
1647
+ ]);
1648
+ return requestTiming;
1649
+ };
1650
+ var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
1651
+ var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
1652
+ const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
1653
+ const menuActions = useChatToolbarActions({
1654
+ chat,
1655
+ companionTo
1656
+ });
1657
+ return /* @__PURE__ */ React14.createElement(Menu.Root, {
1658
+ ...menuActions,
1659
+ attendableId
1660
+ }, /* @__PURE__ */ React14.createElement(Menu.Toolbar, {
1661
+ ...composableProps(props),
1662
+ ref: forwardedRef
1663
+ }));
1664
+ });
1665
+ ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
1666
+ var CHAT_CONTENT_NAME = "Chat.Content";
1667
+ var ChatContent = composable(({ children, ...props }, forwardedRef) => {
1668
+ return /* @__PURE__ */ React14.createElement("div", {
1669
+ ...composableProps(props, {
1670
+ classNames: "dx-expander flex flex-col"
1671
+ }),
1672
+ ref: forwardedRef
1673
+ }, children);
1674
+ });
1675
+ ChatContent.displayName = CHAT_CONTENT_NAME;
1676
+ var CHAT_THREAD_NAME = "Chat.Thread";
1677
+ var ChatThread2 = ({ viewType, debug: debugProp, ...props }) => {
1678
+ const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
1679
+ const debugView = viewType === "debug";
1680
+ const identity = useIdentity();
1681
+ const error = useAtomValue3(processor.error).pipe(Option4.getOrUndefined);
1682
+ const extensions = useChatKeymapExtensions2({
1683
+ event
1684
+ });
1685
+ const controllerRef = useRef3(null);
1686
+ useEffect6(() => {
1687
+ return event.on((event2) => {
1688
+ switch (event2.type) {
1689
+ case "submit":
1690
+ case "scroll-to-bottom":
1691
+ controllerRef.current?.scrollToBottom();
1692
+ break;
1693
+ case "nav-previous":
1694
+ controllerRef.current?.navigatePrevious();
1695
+ break;
1696
+ case "nav-next":
1697
+ controllerRef.current?.navigateNext();
1698
+ break;
1699
+ }
1700
+ });
1701
+ }, [
1702
+ event
1703
+ ]);
1704
+ const handleEvent = useCallback6((ev) => {
1705
+ event.emit(ev);
1706
+ }, [
1707
+ event
1708
+ ]);
1709
+ if (!identity) {
1710
+ return null;
1711
+ }
1712
+ return /* @__PURE__ */ React14.createElement(ChatThread, {
1713
+ ...props,
1714
+ identity,
1715
+ messages,
1716
+ error,
1717
+ debug: debugProp ?? (debug || debugView),
1718
+ viewType,
1719
+ extensions,
1720
+ onEvent: handleEvent,
1721
+ ref: controllerRef
1722
+ });
1723
+ };
1724
+ ChatThread2.displayName = CHAT_THREAD_NAME;
1725
+ var CHAT_PROMPT_NAME = "Chat.Prompt";
1726
+ var ChatPrompt2 = (props) => {
1727
+ const { chat, db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
1728
+ return /* @__PURE__ */ React14.createElement(ChatPrompt, {
1729
+ ...props,
1730
+ chat,
1731
+ db,
1732
+ processor,
1733
+ event
1734
+ });
1735
+ };
1736
+ ChatPrompt2.displayName = CHAT_PROMPT_NAME;
1737
+ var Chat = {
1738
+ Root: ChatRoot,
1739
+ Toolbar: ChatToolbar,
1740
+ Content: ChatContent,
1741
+ Prompt: ChatPrompt2,
1742
+ Status: ChatStatus,
1743
+ Thread: ChatThread2
1744
+ };
1745
+
1746
+ // src/components/ProcessTree/ProcessTree.tsx
1747
+ import * as Match from "effect/Match";
1748
+ import * as Option5 from "effect/Option";
1749
+ import React15 from "react";
1750
+ import { Process } from "@dxos/functions-runtime";
1751
+ import { Icon as Icon2, IconButton as IconButton4, ScrollArea, Tooltip as Tooltip2, Treegrid } from "@dxos/react-ui";
1752
+ import { composable as composable2, composableProps as composableProps2, mx as mx7 } from "@dxos/ui-theme";
1753
+ import { Unit as Unit2 } from "@dxos/util";
1754
+ var ProcessTree = composable2(({ processes, onProcessSelect, onProcessTerminate, ...props }, forwardedRef) => {
1755
+ const sortedProcesses = [
1756
+ ...processes.filter((process) => [
1757
+ Process.State.RUNNING,
1758
+ Process.State.HYBERNATING
1759
+ ].includes(process.state)),
1760
+ ...processes.filter((process) => [
1761
+ Process.State.IDLE
1762
+ ].includes(process.state)).slice(0, 3),
1763
+ ...processes.filter((process) => [
1764
+ Process.State.SUCCEEDED,
1765
+ Process.State.FAILED,
1766
+ Process.State.TERMINATED
1767
+ ].includes(process.state))
1768
+ ].sort((a, b) => {
1769
+ const aCompletedAt = Option5.getOrElse(a.completedAt, () => Infinity);
1770
+ const bCompletedAt = Option5.getOrElse(b.completedAt, () => Infinity);
1771
+ return bCompletedAt - aCompletedAt;
1772
+ });
1773
+ return /* @__PURE__ */ React15.createElement(ScrollArea.Root, {
1774
+ ...composableProps2(props, {
1775
+ classNames: "dx-expander"
1776
+ }),
1777
+ thin: true,
1778
+ ref: forwardedRef
1779
+ }, /* @__PURE__ */ React15.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React15.createElement(Treegrid.Root, {
1780
+ gridTemplateColumns: "1fr"
1781
+ }, sortedProcesses.filter((process) => process.parentPid === null).map((process) => {
1782
+ return /* @__PURE__ */ React15.createElement(Treegrid.Row, {
1783
+ key: process.pid.toString(),
1784
+ id: process.pid.toString(),
1785
+ parentOf: process.parentPid?.toString()
1786
+ }, /* @__PURE__ */ React15.createElement(Treegrid.Cell, {
1787
+ indent: true,
1788
+ classNames: mx7("grid grid-cols-[min-content_1fr_min-content_min-content] items-center gap-1 min-w-0", onProcessSelect && "dx-hover"),
1789
+ onClick: () => onProcessSelect?.(process)
1790
+ }, /* @__PURE__ */ React15.createElement(Tooltip2.Trigger, {
1791
+ className: "p-1",
1792
+ content: process.state.toString()
1793
+ }, /* @__PURE__ */ React15.createElement(Icon2, {
1794
+ size: 4,
1795
+ synchronized: true,
1796
+ classNames: mx7(process.state === Process.State.RUNNING && "animate-spin", process.state === Process.State.FAILED && "text-error-text", process.state === Process.State.SUCCEEDED && "text-success-text"),
1797
+ icon: Match.value(process.state).pipe(Match.when(Process.State.RUNNING, () => "ph--spinner-gap--regular"), Match.when(Process.State.SUCCEEDED, () => "ph--check-circle--regular"), Match.when(Process.State.FAILED, () => "ph--warning--regular"), Match.when(Process.State.HYBERNATING, () => "ph--spinner--regular"), Match.when(Process.State.IDLE, () => "ph--hourglass--regular"), Match.when(Process.State.TERMINATING, () => "ph--x-circle--regular"), Match.when(Process.State.TERMINATED, () => "ph--x-circle--regular"), Match.orElse(() => "ph--spinner-gap--regular"))
1798
+ })), /* @__PURE__ */ React15.createElement("div", {
1799
+ role: "none",
1800
+ className: "flex items-center gap-2 text-xs overflow-hidden"
1801
+ }, /* @__PURE__ */ React15.createElement("span", {
1802
+ className: "truncate text-description select-none"
1803
+ }, process.params.name ?? process.pid.toString())), [
1804
+ Process.State.FAILED,
1805
+ Process.State.SUCCEEDED
1806
+ ].includes(process.state) && /* @__PURE__ */ React15.createElement("div", {
1807
+ className: "text-xs text-description tabular-nums"
1808
+ }, Unit2.Millisecond(process.metrics.wallTime).toString()) || /* @__PURE__ */ React15.createElement("div", null), onProcessTerminate && /* @__PURE__ */ React15.createElement(IconButton4, {
1809
+ classNames: "min-h-0 p-1",
1810
+ icon: "ph--x--regular",
1811
+ iconOnly: true,
1812
+ variant: "ghost",
1813
+ size: 4,
1814
+ label: "Actions",
1815
+ onClick: (event) => {
1816
+ event.stopPropagation();
1817
+ onProcessTerminate?.(process);
1818
+ }
1819
+ })));
1820
+ }))));
1821
+ });
1822
+
1823
+ // src/components/TemplateEditor/TemplateEditor.tsx
1824
+ import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1825
+ import { composeRefs } from "@radix-ui/react-compose-refs";
1826
+ import React16 from "react";
1827
+ import { createDocAccessor } from "@dxos/echo-db";
1828
+ import { useThemeContext, useTranslation as useTranslation8 } from "@dxos/react-ui";
1829
+ import { useTextEditor } from "@dxos/react-ui-editor";
1830
+ import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
1831
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
1832
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1833
+ import { meta as meta8 } from "#meta";
1834
+
1835
+ // src/components/TemplateEditor/extensions/handlebars-extension.ts
1836
+ import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
1837
+ import { RangeSetBuilder } from "@codemirror/state";
1838
+ import { Decoration, ViewPlugin, WidgetType as WidgetType7, keymap } from "@codemirror/view";
1839
+ import { Domino as Domino7, mx as mx8 } from "@dxos/ui";
1840
+ var handlebars = (_ = {}) => {
1841
+ return [
1842
+ handlebarsHighlightPlugin,
1843
+ autocompletion({
1844
+ activateOnTyping: true,
1845
+ aboveCursor: true,
1846
+ closeOnBlur: true,
1847
+ override: [
1848
+ handlebarsCompletions
1849
+ ]
1850
+ }),
1851
+ keymap.of(completionKeymap)
1852
+ ];
1853
+ };
1854
+ var regex = {
1855
+ // {{! comment }}
1856
+ comment: /\{\{!\s*[^}]*\}\}/g,
1857
+ // {{var}}
1858
+ brackets: /\{\{[^}]*\}\}/g,
1859
+ // {{#command}} {{/command}}
1860
+ command: /\{\{[#/]([^}]+)\}\}/g,
1861
+ // {{var}}
1862
+ var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
1863
+ // @dxn:queue:data:xxx
1864
+ dxn: /@?dxn:[\w@:]+/g,
1865
+ // example.com/path/xxx
1866
+ url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
1867
+ };
1868
+ var tagPadding = "mx-0.5 px-1 rounded-xs";
1869
+ var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
1870
+ decorations;
1871
+ constructor(view) {
1872
+ this.decorations = this.buildDecorations(view);
1873
+ }
1874
+ update(update) {
1875
+ if (update.docChanged || update.viewportChanged || update.selectionSet) {
1876
+ this.decorations = this.buildDecorations(update.view);
1877
+ }
1878
+ }
1879
+ // NOTE: Decorations may clash with other extensions (e.g., markdown).
1880
+ buildDecorations(view) {
1881
+ const selection = view.state.selection.main;
1882
+ const decorations = [];
1883
+ for (const { from, to } of view.visibleRanges) {
1884
+ const text = view.state.doc.sliceString(from, to);
1885
+ {
1886
+ let match;
1887
+ while ((match = regex.dxn.exec(text)) !== null) {
1888
+ const start = from + match.index;
1889
+ const end = start + match[0].length;
1890
+ const overlaps = selection.to > start && selection.from <= end;
1891
+ if (!overlaps) {
1892
+ decorations.push({
1893
+ from: start,
1894
+ to: end,
1895
+ decoration: Decoration.widget({
1896
+ widget: new DXNWidget(match[0])
1897
+ })
1898
+ });
1899
+ }
1900
+ }
1901
+ }
1902
+ {
1903
+ let match;
1904
+ while ((match = regex.url.exec(text)) !== null) {
1905
+ const start = from + match.index;
1906
+ const end = start + match[0].length;
1907
+ decorations.push({
1908
+ from: start,
1909
+ to: end,
1910
+ decoration: Decoration.mark({
1911
+ class: mx8("dx-tag--blue", tagPadding)
1912
+ })
1913
+ });
1914
+ }
1915
+ }
1916
+ {
1917
+ let match;
1918
+ while ((match = regex.brackets.exec(text)) !== null) {
1919
+ const start = from + match.index;
1920
+ const end = start + match[0].length;
1921
+ decorations.push({
1922
+ from: start,
1923
+ to: end,
1924
+ decoration: Decoration.mark({
1925
+ class: "text-subdued"
1926
+ })
1927
+ });
1928
+ }
1929
+ }
1930
+ {
1931
+ let match;
1932
+ while ((match = regex.command.exec(text)) !== null) {
1933
+ const start = from + match.index + 2;
1934
+ let end = start + match[0].length - 4;
1935
+ const text2 = view.state.doc.sliceString(start, end);
1936
+ const parts = text2.split(/\s+/);
1937
+ if (parts.length > 1) {
1938
+ const idx = start + parts[0].length;
1939
+ decorations.push({
1940
+ from: idx,
1941
+ to: end,
1942
+ decoration: Decoration.mark({
1943
+ class: "text-green-text"
1944
+ })
1945
+ });
1946
+ end = idx;
1947
+ }
1948
+ decorations.push({
1949
+ from: start,
1950
+ to: end,
1951
+ decoration: Decoration.mark({
1952
+ class: "text-blue-text"
1953
+ })
1954
+ });
1955
+ }
1956
+ }
1957
+ {
1958
+ let match;
1959
+ while ((match = regex.var.exec(text)) !== null) {
1960
+ const start = from + match.index + 2;
1961
+ const end = start + match[0].length - 4;
1962
+ decorations.push({
1963
+ from: start,
1964
+ to: end,
1965
+ decoration: Decoration.mark({
1966
+ class: "text-green-text"
1967
+ })
1968
+ });
1969
+ }
1970
+ }
1971
+ }
1972
+ decorations.sort((a, b) => a.from - b.from || a.to - b.to);
1973
+ const builder = new RangeSetBuilder();
1974
+ for (const { from, to, decoration } of decorations) {
1975
+ builder.add(from, to, decoration);
1976
+ }
1977
+ return builder.finish();
1978
+ }
1979
+ }, {
1980
+ decorations: (v) => v.decorations
1981
+ });
1982
+ var DXNWidget = class extends WidgetType7 {
1983
+ _identifier;
1984
+ constructor(_identifier) {
1985
+ super(), this._identifier = _identifier;
1986
+ }
1987
+ ignoreEvent() {
1988
+ return false;
1989
+ }
1990
+ eq(other) {
1991
+ return this._identifier === other._identifier;
1992
+ }
1993
+ toDOM() {
1994
+ const text = this._identifier.split(":").map((part) => {
1995
+ const len = 16;
1996
+ const plen = 4;
1997
+ if (part.length > len) {
1998
+ return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
1999
+ }
2000
+ return part;
2001
+ }).join(":");
2002
+ return Domino7.of("span").classNames(mx8("font-mono dx-tag--blue", tagPadding)).text(text).root;
2003
+ }
2004
+ };
2005
+ var variables = [
2006
+ "this"
2007
+ ];
2008
+ var commands = [
2009
+ "this",
2010
+ "each",
2011
+ "if",
2012
+ "unless",
2013
+ "with"
2014
+ ];
2015
+ function handlebarsCompletions(context) {
2016
+ const match = context.matchBefore(/\{\{[^}]*/);
2017
+ if (!match || match.from === match.to) {
2018
+ return null;
2019
+ }
2020
+ let type = "variable";
2021
+ let text = match.text.slice(2);
2022
+ let from = match.from + 2;
2023
+ let matches = [];
2024
+ if (text.startsWith("#") || text.startsWith("/")) {
2025
+ const idx = text.lastIndexOf(" ");
2026
+ if (idx !== -1) {
2027
+ type = "variable";
2028
+ matches = variables;
2029
+ text = text.slice(idx + 1);
2030
+ from += idx + 1;
2031
+ } else {
2032
+ type = "command";
2033
+ text = text.slice(1);
2034
+ matches = commands;
2035
+ from += 1;
2036
+ }
2037
+ } else {
2038
+ type = "variable";
2039
+ matches = variables;
2040
+ }
2041
+ const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
2042
+ type,
2043
+ label: name
2044
+ }));
2045
+ return {
2046
+ from,
2047
+ options
2048
+ };
2049
+ }
2050
+
2051
+ // src/components/TemplateEditor/extensions/xml-extension.ts
2052
+ import { syntaxTree } from "@codemirror/language";
2053
+ import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
2054
+ import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
2055
+ var xmlDecorator = (_ = {}) => {
2056
+ return [
2057
+ xmlDecoratorPlugin
2058
+ ];
2059
+ };
2060
+ var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
2061
+ decorations;
2062
+ constructor(view) {
2063
+ this.decorations = this.buildDecorations(view);
2064
+ }
2065
+ update(update) {
2066
+ if (update.docChanged || update.viewportChanged) {
2067
+ this.decorations = this.buildDecorations(update.view);
2068
+ }
2069
+ }
2070
+ buildDecorations(view) {
2071
+ const builder = new RangeSetBuilder2();
2072
+ for (const { from, to } of view.visibleRanges) {
2073
+ syntaxTree(view.state).iterate({
2074
+ from,
2075
+ to,
2076
+ enter: (node) => {
2077
+ if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
2078
+ builder.add(node.from, node.to, Decoration2.mark({
2079
+ class: "font-mono text-subdued"
2080
+ }));
2081
+ }
2082
+ }
2083
+ });
2084
+ }
2085
+ return builder.finish();
2086
+ }
2087
+ }, {
2088
+ decorations: (v) => v.decorations
2089
+ });
2090
+
2091
+ // src/components/TemplateEditor/TemplateEditor.tsx
2092
+ var TemplateEditor = composable3(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
2093
+ const { t } = useTranslation8(meta8.id);
2094
+ const { themeMode } = useThemeContext();
2095
+ const { parentRef } = useTextEditor(() => {
2096
+ const target = template.source?.target;
2097
+ if (!target) {
2098
+ return {};
2099
+ }
2100
+ return {
2101
+ initialValue: target.content ?? "",
2102
+ extensions: [
2103
+ createDataExtensions({
2104
+ id,
2105
+ text: createDocAccessor(target, [
2106
+ "content"
2107
+ ])
2108
+ }),
2109
+ createBasicExtensions({
2110
+ bracketMatching: false,
2111
+ lineNumbers,
2112
+ lineWrapping: true,
2113
+ placeholder: t("template.placeholder")
2114
+ }),
2115
+ createThemeExtensions({
2116
+ themeMode
2117
+ }),
2118
+ createMarkdownExtensions(),
2119
+ decorateMarkdown(),
2120
+ handlebars(),
2121
+ // xml(),
2122
+ // NOTE: Since we're using markdown only HTML nodes are parsed.
2123
+ xmlDecorator(),
2124
+ syntaxHighlighting(defaultHighlightStyle)
2125
+ ].filter(isNonNullable2)
2126
+ };
2127
+ }, [
2128
+ themeMode,
2129
+ template.source?.target,
2130
+ lineNumbers
2131
+ ]);
2132
+ return /* @__PURE__ */ React16.createElement("div", {
2133
+ ...composableProps3(props, {
2134
+ role: "none",
2135
+ classNames: [
2136
+ "h-full overflow-hidden",
2137
+ classNames
2138
+ ]
2139
+ }),
2140
+ ref: composeRefs(parentRef, forwardedRef)
2141
+ });
2142
+ });
2143
+
2144
+ // src/components/Toolbox/Toolbox.tsx
2145
+ import React17, { Fragment, useEffect as useEffect7, useState as useState8 } from "react";
2146
+ import { Operation } from "@dxos/compute";
2147
+ import { log as log2 } from "@dxos/log";
2148
+ import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
2149
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
2150
+ import { composable as composable4, composableProps as composableProps4, mx as mx9 } from "@dxos/ui-theme";
2151
+ import { ServiceType } from "#types";
2152
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
2153
+ var Toolbox = composable4(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
2154
+ return /* @__PURE__ */ React17.createElement(ScrollArea2.Root, {
2155
+ ...composableProps4(props),
2156
+ thin: true,
2157
+ orientation: "vertical",
2158
+ ref: forwardedRef
2159
+ }, /* @__PURE__ */ React17.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
2160
+ title: "Blueprints",
2161
+ items: blueprints.map(({ name, description, tools }) => ({
2162
+ name,
2163
+ description,
2164
+ subitems: tools.map((toolId) => ({
2165
+ name: `\u2219 ${safeToolId(toolId)}`
2166
+ }))
2167
+ }))
2168
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
2169
+ title: "Blueprints",
2170
+ items: activeBlueprints.map(({ target }) => ({
2171
+ name: target?.name ?? "",
2172
+ description: target?.description ?? "",
2173
+ subitems: target?.tools.map((toolId) => ({
2174
+ name: `\u2219 ${safeToolId(toolId)}`
2175
+ }))
2176
+ }))
2177
+ }), services && services.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
2178
+ title: "Services",
2179
+ items: services.map(({ service: { serviceId, name, description } }) => ({
2180
+ name: name ?? serviceId,
2181
+ description
2182
+ }))
2183
+ }), functions && functions.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
2184
+ title: "Functions",
2185
+ items: functions.map(({ name, description }) => ({
2186
+ name,
2187
+ description
2188
+ }))
2189
+ })));
2190
+ });
2191
+ Toolbox.displayName = "Toolbox";
2192
+ var Section = ({ title, items, striped }) => {
2193
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
2194
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
2195
+ const subGridClassNames = mx9("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
2196
+ return /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement("h1", {
2197
+ className: "px-2 text-sm"
2198
+ }, title), /* @__PURE__ */ React17.createElement("div", {
2199
+ className: gridClassNames
2200
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React17.createElement(Fragment, {
2201
+ key: i
2202
+ }, name && /* @__PURE__ */ React17.createElement("div", {
2203
+ className: subGridClassNames
2204
+ }, /* @__PURE__ */ React17.createElement("div", {
2205
+ className: "truncate text-primary-500"
2206
+ }, name), /* @__PURE__ */ React17.createElement("div", {
2207
+ className: "line-clamp-2"
2208
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React17.createElement("div", {
2209
+ key: i2,
2210
+ className: mx9(subGridClassNames, striped && stripeClassNames)
2211
+ }, /* @__PURE__ */ React17.createElement("div", {
2212
+ className: "truncate"
2213
+ }, name2), /* @__PURE__ */ React17.createElement("div", {
2214
+ className: "line-clamp-3 text-subdued"
2215
+ }, description2)))))));
2216
+ };
2217
+ var ToolboxPanel = ({ classNames, db, processor }) => {
2218
+ const services = useQuery3(db, Filter3.type(ServiceType));
2219
+ const [serviceTools, setServiceTools] = useState8([]);
2220
+ useEffect7(() => {
2221
+ log2("creating service tools...", {
2222
+ services: services.length
2223
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 80, S: void 0 });
2224
+ queueMicrotask(async () => {
2225
+ });
2226
+ }, [
2227
+ services
2228
+ ]);
2229
+ const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
2230
+ return /* @__PURE__ */ React17.createElement(Toolbox, {
2231
+ classNames,
2232
+ blueprints: processor?.context.getBlueprints(),
2233
+ services: serviceTools,
2234
+ functions
2235
+ });
2236
+ };
2237
+ var safeToolId = (name) => {
2238
+ return name.split("_").pop();
2239
+ };
2240
+
2241
+ // src/components/index.ts
2242
+ var AssistantSettings = lazy(() => import("./AssistantSettings-GG52BLKS.mjs"));
2243
+
2244
+ export {
2245
+ useChatContext,
2246
+ Chat,
2247
+ ProcessTree,
2248
+ TemplateEditor,
2249
+ Toolbox,
2250
+ ToolboxPanel,
2251
+ AssistantSettings
2252
+ };
2253
+ //# sourceMappingURL=chunk-RSLHZTJH.mjs.map