@dxos/plugin-assistant 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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