@dxos/plugin-assistant 0.8.4-main.c4373fc → 0.8.4-main.d9fc60f731

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