@dxos/plugin-assistant 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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