@dxos/plugin-assistant 0.8.4-main.ead640a → 0.8.4-main.effb148878

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