@dxos/plugin-assistant 0.8.4-main.72ec0f3 → 0.8.4-main.765dc60934

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