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