@dxos/plugin-assistant 0.8.4-main.3eb6e50203 → 0.8.4-main.422d1c7879

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 (658) hide show
  1. package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs +97 -0
  2. package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs.map +7 -0
  3. package/dist/lib/browser/blueprints/index.mjs +3 -7
  4. package/dist/lib/browser/chunk-ATHYBVGN.mjs +176 -0
  5. package/dist/lib/browser/chunk-ATHYBVGN.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-EZRS3J25.mjs +30 -0
  7. package/dist/lib/browser/chunk-EZRS3J25.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-LMVTXH54.mjs +154 -0
  9. package/dist/lib/browser/chunk-LMVTXH54.mjs.map +7 -0
  10. package/dist/lib/browser/cli/index.mjs +74 -0
  11. package/dist/lib/browser/cli/index.mjs.map +7 -0
  12. package/dist/lib/browser/create-chat-LBZHGVSN.mjs +82 -0
  13. package/dist/lib/browser/create-chat-LBZHGVSN.mjs.map +7 -0
  14. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs +65 -0
  15. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +3308 -264
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/on-create-space-54RNX5JI.mjs +22 -0
  20. package/dist/lib/browser/on-create-space-54RNX5JI.mjs.map +7 -0
  21. package/dist/lib/browser/operations/index.mjs +13 -0
  22. package/dist/lib/browser/operations/index.mjs.map +7 -0
  23. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs +22 -0
  24. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs.map +7 -0
  25. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs +136 -0
  26. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs.map +7 -0
  27. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs +54 -0
  28. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs.map +7 -0
  29. package/dist/lib/browser/types/index.mjs +1 -4
  30. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs +71 -0
  31. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs.map +7 -0
  32. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs +98 -0
  33. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs.map +7 -0
  34. package/dist/lib/node-esm/blueprints/index.mjs +3 -7
  35. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +32 -0
  36. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs +177 -0
  38. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs +155 -0
  40. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs.map +7 -0
  41. package/dist/lib/node-esm/cli/index.mjs +75 -0
  42. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  43. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs +83 -0
  44. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs.map +7 -0
  45. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs +66 -0
  46. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs.map +7 -0
  47. package/dist/lib/node-esm/index.mjs +3308 -264
  48. package/dist/lib/node-esm/index.mjs.map +4 -4
  49. package/dist/lib/node-esm/meta.json +1 -1
  50. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs +23 -0
  51. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs.map +7 -0
  52. package/dist/lib/node-esm/operations/index.mjs +14 -0
  53. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  54. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs +23 -0
  55. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs.map +7 -0
  56. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs +137 -0
  57. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs.map +7 -0
  58. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs +55 -0
  59. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs.map +7 -0
  60. package/dist/lib/node-esm/types/index.mjs +1 -4
  61. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs +72 -0
  62. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs.map +7 -0
  63. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  64. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  65. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  66. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  67. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  68. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  69. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  70. package/dist/types/src/blueprints/index.d.ts +1 -6
  71. package/dist/types/src/blueprints/index.d.ts.map +1 -1
  72. package/dist/types/src/capabilities/ai-service.d.ts +6 -0
  73. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  74. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  75. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  76. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  77. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  78. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
  79. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
  80. package/dist/types/src/capabilities/{edge-model-resolver/edge-model-resolver.d.ts → edge-model-resolver.d.ts} +1 -1
  81. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  82. package/dist/types/src/capabilities/index.d.ts +29 -11
  83. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  84. package/dist/types/src/capabilities/local-model-resolver.d.ts +16 -0
  85. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  86. package/dist/types/src/capabilities/markdown.d.ts +5 -0
  87. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  88. package/dist/types/src/capabilities/migrations.d.ts +5 -0
  89. package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
  90. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  91. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  92. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  93. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  94. package/dist/types/src/capabilities/settings.d.ts +6 -0
  95. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  96. package/dist/types/src/capabilities/state.d.ts +21 -0
  97. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  98. package/dist/types/src/capabilities/toolkit.d.ts +6 -0
  99. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  100. package/dist/types/src/cli/index.d.ts +2 -0
  101. package/dist/types/src/cli/index.d.ts.map +1 -0
  102. package/dist/types/src/cli/plugin.d.ts +10 -0
  103. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  104. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -6
  105. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  106. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -0
  107. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
  108. package/dist/types/src/components/AssistantSettings/index.d.ts +1 -1
  109. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
  110. package/dist/types/src/components/Chat/Chat.d.ts +15 -14
  111. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  112. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +6 -3
  113. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
  114. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +2 -1
  115. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  116. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +2 -0
  117. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  118. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
  119. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
  120. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  121. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts +14 -0
  122. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts.map +1 -0
  123. package/dist/types/src/components/ChatThread/ChatThread.d.ts +2 -2
  124. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  125. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +6 -426
  126. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  127. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts +42 -0
  128. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
  129. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
  130. package/dist/types/src/components/ChatThread/sync.d.ts +43 -16
  131. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  132. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
  133. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
  134. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
  135. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
  136. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
  137. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
  138. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts +15 -0
  139. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts.map +1 -0
  140. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
  141. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
  142. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts +18 -0
  143. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -0
  144. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
  145. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
  146. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
  147. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
  148. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
  149. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
  150. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +25 -0
  151. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -0
  152. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
  153. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
  154. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
  155. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
  156. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
  157. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
  158. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts +15 -0
  159. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
  160. package/dist/types/src/components/ChatThread/widgets/index.d.ts +11 -0
  161. package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
  162. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +10 -0
  163. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
  164. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
  165. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
  166. package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
  167. package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
  168. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +5 -4
  169. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  170. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +1 -419
  171. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  172. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  173. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -419
  174. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  175. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +0 -9
  176. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  177. package/dist/types/src/components/Toolbox/Toolbox.d.ts +10 -8
  178. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  179. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -419
  180. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  181. package/dist/types/src/components/index.d.ts +3 -11
  182. package/dist/types/src/components/index.d.ts.map +1 -1
  183. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
  184. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
  185. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
  186. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
  187. package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
  188. package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
  189. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
  190. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
  191. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
  192. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
  193. package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
  194. package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
  195. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  196. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  197. package/dist/types/src/containers/BlueprintArticle/index.d.ts +2 -0
  198. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  199. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +18 -0
  200. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  201. package/dist/types/src/containers/ChatCompanion/index.d.ts +2 -0
  202. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  203. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +12 -0
  204. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  205. package/dist/types/src/containers/ChatContainer/index.d.ts +2 -0
  206. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  207. package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +0 -1
  208. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  209. package/dist/types/src/containers/ChatDialog/index.d.ts +2 -0
  210. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  211. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
  212. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
  213. package/dist/types/src/containers/PromptArticle/index.d.ts +2 -0
  214. package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
  215. package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
  216. package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
  217. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +21 -0
  218. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
  219. package/dist/types/src/containers/PromptList/index.d.ts +2 -0
  220. package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
  221. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +7 -0
  222. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  223. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +16 -0
  224. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -0
  225. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  226. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  227. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  228. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  229. package/dist/types/src/containers/TracePanel/execution-graph.d.ts +17 -0
  230. package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
  231. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  232. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  233. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +5 -0
  234. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  235. package/dist/types/src/containers/TriggerStatus/index.d.ts +2 -0
  236. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  237. package/dist/types/src/containers/index.d.ts +12 -0
  238. package/dist/types/src/containers/index.d.ts.map +1 -0
  239. package/dist/types/src/extensions/index.d.ts +2 -0
  240. package/dist/types/src/extensions/index.d.ts.map +1 -0
  241. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  242. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  243. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  244. package/dist/types/src/hooks/useChatProcessor.d.ts +5 -5
  245. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  246. package/dist/types/src/hooks/useChatServices.d.ts +3 -6
  247. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  248. package/dist/types/src/hooks/useContextBinder.d.ts +3 -2
  249. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  250. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
  251. package/dist/types/src/hooks/useFilteredTypes.d.ts +1 -1
  252. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -1
  253. package/dist/types/src/hooks/usePresets.d.ts +1 -1
  254. package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
  255. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  256. package/dist/types/src/index.d.ts +1 -1
  257. package/dist/types/src/index.d.ts.map +1 -1
  258. package/dist/types/src/meta.d.ts +2 -0
  259. package/dist/types/src/meta.d.ts.map +1 -1
  260. package/dist/types/src/operations/create-chat.d.ts +5 -0
  261. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  262. package/dist/types/src/operations/definitions.d.ts +135 -0
  263. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  264. package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
  265. package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
  266. package/dist/types/src/operations/index.d.ts +4 -0
  267. package/dist/types/src/operations/index.d.ts.map +1 -0
  268. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  269. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  270. package/dist/types/src/operations/prompt.test.d.ts +2 -0
  271. package/dist/types/src/operations/prompt.test.d.ts.map +1 -0
  272. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  273. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  274. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  275. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  276. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  277. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  278. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  279. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  280. package/dist/types/src/processor/index.d.ts +0 -1
  281. package/dist/types/src/processor/index.d.ts.map +1 -1
  282. package/dist/types/src/processor/presets.d.ts +1 -1
  283. package/dist/types/src/processor/presets.d.ts.map +1 -1
  284. package/dist/types/src/processor/processor.d.ts +30 -29
  285. package/dist/types/src/processor/processor.d.ts.map +1 -1
  286. package/dist/types/src/queue-logger.d.ts.map +1 -1
  287. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  288. package/dist/types/src/testing/test-generator.test.d.ts +2 -0
  289. package/dist/types/src/testing/test-generator.test.d.ts.map +1 -0
  290. package/dist/types/src/testing/test-services.d.ts +1 -1
  291. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  292. package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
  293. package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
  294. package/dist/types/src/translations.d.ts +2 -419
  295. package/dist/types/src/translations.d.ts.map +1 -1
  296. package/dist/types/src/types/Assistant.d.ts +14 -14
  297. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  298. package/dist/types/src/types/Settings.d.ts +11 -0
  299. package/dist/types/src/types/Settings.d.ts.map +1 -0
  300. package/dist/types/src/types/capabilities.d.ts +12 -13
  301. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  302. package/dist/types/src/types/index.d.ts +0 -1
  303. package/dist/types/src/types/index.d.ts.map +1 -1
  304. package/dist/types/src/types/service.d.ts.map +1 -1
  305. package/dist/types/tsconfig.tsbuildinfo +1 -1
  306. package/package.json +112 -95
  307. package/src/AssistantPlugin.tsx +115 -46
  308. package/src/blueprints/assistant/blueprint.test.ts +46 -0
  309. package/src/blueprints/assistant/blueprint.ts +31 -0
  310. package/src/blueprints/assistant/index.ts +5 -0
  311. package/src/blueprints/index.ts +1 -8
  312. package/src/capabilities/app-graph-builder.ts +162 -0
  313. package/src/capabilities/blueprint-definition.ts +58 -0
  314. package/src/capabilities/companion-chat-provisioner.ts +164 -0
  315. package/src/capabilities/index.ts +22 -11
  316. package/src/capabilities/{local-model-resolver/local-model-resolver.ts → local-model-resolver.ts} +14 -4
  317. package/src/capabilities/markdown.ts +40 -0
  318. package/src/capabilities/migrations.ts +35 -0
  319. package/src/capabilities/operation-handler.ts +16 -0
  320. package/src/capabilities/react-surface.tsx +161 -0
  321. package/src/capabilities/{settings/settings.ts → settings.ts} +2 -2
  322. package/src/capabilities/{state/state.ts → state.ts} +11 -3
  323. package/src/capabilities/toolkit.ts +13 -0
  324. package/src/{components/Typewriter → cli}/index.ts +1 -1
  325. package/src/cli/plugin.ts +84 -0
  326. package/src/components/AssistantSettings/AssistantSettings.stories.tsx +34 -0
  327. package/src/components/AssistantSettings/AssistantSettings.tsx +104 -92
  328. package/src/components/AssistantSettings/index.ts +2 -2
  329. package/src/components/Chat/Chat.tsx +80 -64
  330. package/src/components/ChatProgress/ChatProgress.tsx +9 -6
  331. package/src/components/ChatPrompt/ChatActions.tsx +24 -12
  332. package/src/components/ChatPrompt/ChatOptions.stories.tsx +122 -0
  333. package/src/components/ChatPrompt/ChatOptions.tsx +205 -39
  334. package/src/components/ChatPrompt/ChatReferences.tsx +18 -8
  335. package/src/components/ChatThread/Anchor.stories.tsx +95 -0
  336. package/src/components/ChatThread/ChatThread.stories.tsx +61 -68
  337. package/src/components/ChatThread/ChatThread.tsx +28 -24
  338. package/src/components/ChatThread/MarkdownStream.stories.tsx +280 -0
  339. package/src/components/ChatThread/registry.tsx +117 -44
  340. package/src/components/ChatThread/sync.test.ts +111 -17
  341. package/src/components/ChatThread/sync.ts +92 -96
  342. package/src/components/ChatThread/testing/reasoning.md +25 -0
  343. package/src/components/ChatThread/testing/thinking.md +21 -0
  344. package/src/components/ChatThread/testing/thread-1.md +30 -0
  345. package/src/components/ChatThread/testing/{thread.md → thread-2.md} +19 -0
  346. package/src/components/ChatThread/testing/thread-widgets.md +79 -0
  347. package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
  348. package/src/components/ChatThread/tool-widget-state.ts +48 -0
  349. package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
  350. package/src/components/ChatThread/widgets/PromptWidget.ts +30 -0
  351. package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
  352. package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
  353. package/src/components/ChatThread/widgets/ReferenceWidget.ts +31 -0
  354. package/src/components/ChatThread/widgets/SelectWidget.ts +37 -0
  355. package/src/components/ChatThread/widgets/StatsWidget.ts +29 -0
  356. package/src/components/ChatThread/widgets/StatusWidget.ts +131 -0
  357. package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
  358. package/src/components/ChatThread/widgets/SummaryWidget.tsx +28 -0
  359. package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +54 -0
  360. package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
  361. package/src/components/ChatThread/widgets/index.ts +14 -0
  362. package/src/components/ProcessTree/ProcessTree.stories.tsx +109 -0
  363. package/src/components/ProcessTree/ProcessTree.tsx +86 -0
  364. package/src/components/ProcessTree/index.ts +5 -0
  365. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +3 -8
  366. package/src/components/TemplateEditor/TemplateEditor.tsx +50 -42
  367. package/src/components/TemplateEditor/TemplateForm.stories.tsx +6 -5
  368. package/src/components/TemplateEditor/TemplateForm.tsx +9 -10
  369. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +5 -5
  370. package/src/components/ToolBlock/ToolBlock.tsx +22 -21
  371. package/src/components/Toolbox/Toolbox.stories.tsx +4 -6
  372. package/src/components/Toolbox/Toolbox.tsx +65 -58
  373. package/src/components/index.ts +3 -16
  374. package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
  375. package/src/containers/AgentArticle/AgentArticle.tsx +200 -0
  376. package/src/containers/AgentArticle/index.ts +5 -0
  377. package/src/containers/AgentProperties/AgentProperties.stories.tsx +100 -0
  378. package/src/containers/AgentProperties/AgentProperties.tsx +127 -0
  379. package/src/containers/AgentProperties/index.ts +5 -0
  380. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
  381. package/src/containers/BlueprintArticle/index.ts +5 -0
  382. package/src/containers/ChatCompanion/ChatCompanion.tsx +142 -0
  383. package/src/containers/ChatCompanion/index.ts +5 -0
  384. package/src/containers/ChatContainer/ChatContainer.tsx +95 -0
  385. package/src/containers/ChatContainer/index.ts +5 -0
  386. package/src/{components → containers/ChatDialog}/ChatDialog.tsx +7 -10
  387. package/src/containers/ChatDialog/index.ts +5 -0
  388. package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
  389. package/src/containers/PromptArticle/index.ts +5 -0
  390. package/src/containers/PromptList/PromptList.stories.tsx +129 -0
  391. package/src/containers/PromptList/PromptList.tsx +49 -0
  392. package/src/containers/PromptList/index.ts +5 -0
  393. package/src/containers/TracePanel/TracePanel.stories.tsx +272 -0
  394. package/src/containers/TracePanel/TracePanel.tsx +113 -0
  395. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  396. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  397. package/src/containers/TracePanel/execution-graph.ts +452 -0
  398. package/src/containers/TracePanel/index.ts +9 -0
  399. package/src/containers/TriggerStatus/TriggerStatus.tsx +129 -0
  400. package/src/containers/TriggerStatus/index.ts +5 -0
  401. package/src/containers/index.ts +16 -0
  402. package/src/extensions/index.ts +5 -0
  403. package/src/extensions/prompt-extension.ts +111 -0
  404. package/src/hooks/useBlueprintRegistry.ts +6 -2
  405. package/src/hooks/useChatProcessor.ts +35 -23
  406. package/src/hooks/useChatServices.ts +6 -27
  407. package/src/hooks/useChatToolbarActions.ts +9 -9
  408. package/src/hooks/useContextBinder.ts +17 -6
  409. package/src/hooks/useContextObjects.ts +8 -4
  410. package/src/hooks/useFilteredTypes.ts +3 -3
  411. package/src/hooks/usePresets.ts +2 -1
  412. package/src/hooks/useReferencesProvider.ts +1 -5
  413. package/src/index.ts +1 -1
  414. package/src/meta.ts +6 -3
  415. package/src/operations/create-chat.ts +80 -0
  416. package/src/operations/definitions.ts +127 -0
  417. package/src/operations/ensure-companion-chat.ts +61 -0
  418. package/src/operations/index.ts +17 -0
  419. package/src/operations/on-create-space.ts +24 -0
  420. package/src/operations/prompt.test.ts +79 -0
  421. package/src/operations/resolve-navigation-targets.ts +26 -0
  422. package/src/operations/run-prompt-in-new-chat.ts +113 -0
  423. package/src/operations/set-current-chat.ts +50 -0
  424. package/src/operations/update-chat-name.ts +61 -0
  425. package/src/processor/index.ts +0 -1
  426. package/src/processor/presets.ts +11 -3
  427. package/src/processor/processor.test.ts +18 -50
  428. package/src/processor/processor.ts +178 -158
  429. package/src/queue-logger.ts +19 -8
  430. package/src/testing/data/trace-timeline.dx.json +2120 -0
  431. package/src/testing/test-generator.test.ts +81 -0
  432. package/src/testing/test-generator.ts +79 -42
  433. package/src/testing/test-sequence.ts +3 -3
  434. package/src/testing/test-services.ts +2 -2
  435. package/src/testing/trace-timeline.conversations.json +1 -0
  436. package/src/testing/trace-timeline.test.ts +246 -0
  437. package/src/translations.ts +153 -102
  438. package/src/types/Assistant.ts +4 -18
  439. package/src/types/Settings.ts +21 -0
  440. package/src/types/capabilities.ts +11 -3
  441. package/src/types/events.ts +2 -2
  442. package/src/types/index.ts +0 -1
  443. package/src/types/service.ts +5 -5
  444. package/dist/lib/browser/BlueprintArticle-6SP2ZWJ2.mjs +0 -30
  445. package/dist/lib/browser/BlueprintArticle-6SP2ZWJ2.mjs.map +0 -7
  446. package/dist/lib/browser/ChatCompanion-CAKFZAWN.mjs +0 -200
  447. package/dist/lib/browser/ChatCompanion-CAKFZAWN.mjs.map +0 -7
  448. package/dist/lib/browser/ChatContainer-QB37VONJ.mjs +0 -73
  449. package/dist/lib/browser/ChatContainer-QB37VONJ.mjs.map +0 -7
  450. package/dist/lib/browser/ChatDialog-ASVBLOOS.mjs +0 -85
  451. package/dist/lib/browser/ChatDialog-ASVBLOOS.mjs.map +0 -7
  452. package/dist/lib/browser/InitiativeContainer-V522FCYH.mjs +0 -266
  453. package/dist/lib/browser/InitiativeContainer-V522FCYH.mjs.map +0 -7
  454. package/dist/lib/browser/PromptArticle-PK3CBRUB.mjs +0 -52
  455. package/dist/lib/browser/PromptArticle-PK3CBRUB.mjs.map +0 -7
  456. package/dist/lib/browser/ai-service-CY2BYPH6.mjs +0 -22
  457. package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +0 -7
  458. package/dist/lib/browser/app-graph-builder-MUZGUQSC.mjs +0 -234
  459. package/dist/lib/browser/app-graph-builder-MUZGUQSC.mjs.map +0 -7
  460. package/dist/lib/browser/blueprint-definition-YAGWYVCL.mjs +0 -14
  461. package/dist/lib/browser/blueprint-definition-YAGWYVCL.mjs.map +0 -7
  462. package/dist/lib/browser/chunk-3ETBCBMH.mjs +0 -47
  463. package/dist/lib/browser/chunk-3ETBCBMH.mjs.map +0 -7
  464. package/dist/lib/browser/chunk-6BVCG5SJ.mjs +0 -230
  465. package/dist/lib/browser/chunk-6BVCG5SJ.mjs.map +0 -7
  466. package/dist/lib/browser/chunk-DKQMSMBN.mjs +0 -326
  467. package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +0 -7
  468. package/dist/lib/browser/chunk-EXVT7D4B.mjs +0 -23
  469. package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +0 -7
  470. package/dist/lib/browser/chunk-IJYAKPEU.mjs +0 -286
  471. package/dist/lib/browser/chunk-IJYAKPEU.mjs.map +0 -7
  472. package/dist/lib/browser/chunk-JA7PUZC7.mjs +0 -1974
  473. package/dist/lib/browser/chunk-JA7PUZC7.mjs.map +0 -7
  474. package/dist/lib/browser/chunk-POPBT2AQ.mjs +0 -198
  475. package/dist/lib/browser/chunk-POPBT2AQ.mjs.map +0 -7
  476. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs +0 -21
  477. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +0 -7
  478. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs +0 -20
  479. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +0 -7
  480. package/dist/lib/browser/operation-resolver-2673CFJS.mjs +0 -133
  481. package/dist/lib/browser/operation-resolver-2673CFJS.mjs.map +0 -7
  482. package/dist/lib/browser/react-surface-T3FN4GVP.mjs +0 -125
  483. package/dist/lib/browser/react-surface-T3FN4GVP.mjs.map +0 -7
  484. package/dist/lib/browser/repair-IRXDYF4R.mjs +0 -51
  485. package/dist/lib/browser/repair-IRXDYF4R.mjs.map +0 -7
  486. package/dist/lib/browser/settings-XF6GKHCG.mjs +0 -33
  487. package/dist/lib/browser/settings-XF6GKHCG.mjs.map +0 -7
  488. package/dist/lib/browser/state-OYDPWLKA.mjs +0 -26
  489. package/dist/lib/browser/state-OYDPWLKA.mjs.map +0 -7
  490. package/dist/lib/browser/toolkit-IDXQCSTX.mjs +0 -19
  491. package/dist/lib/browser/toolkit-IDXQCSTX.mjs.map +0 -7
  492. package/dist/lib/node-esm/BlueprintArticle-7LI6UXKZ.mjs +0 -31
  493. package/dist/lib/node-esm/BlueprintArticle-7LI6UXKZ.mjs.map +0 -7
  494. package/dist/lib/node-esm/ChatCompanion-W4PGOCGR.mjs +0 -201
  495. package/dist/lib/node-esm/ChatCompanion-W4PGOCGR.mjs.map +0 -7
  496. package/dist/lib/node-esm/ChatContainer-ECFQVH6O.mjs +0 -74
  497. package/dist/lib/node-esm/ChatContainer-ECFQVH6O.mjs.map +0 -7
  498. package/dist/lib/node-esm/ChatDialog-AFLPYSIU.mjs +0 -86
  499. package/dist/lib/node-esm/ChatDialog-AFLPYSIU.mjs.map +0 -7
  500. package/dist/lib/node-esm/InitiativeContainer-U4LGO3BW.mjs +0 -267
  501. package/dist/lib/node-esm/InitiativeContainer-U4LGO3BW.mjs.map +0 -7
  502. package/dist/lib/node-esm/PromptArticle-BHPABYLT.mjs +0 -53
  503. package/dist/lib/node-esm/PromptArticle-BHPABYLT.mjs.map +0 -7
  504. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +0 -23
  505. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +0 -7
  506. package/dist/lib/node-esm/app-graph-builder-4QN5M6PD.mjs +0 -235
  507. package/dist/lib/node-esm/app-graph-builder-4QN5M6PD.mjs.map +0 -7
  508. package/dist/lib/node-esm/blueprint-definition-H3LFAEK2.mjs +0 -15
  509. package/dist/lib/node-esm/blueprint-definition-H3LFAEK2.mjs.map +0 -7
  510. package/dist/lib/node-esm/chunk-2LEN26ZQ.mjs +0 -48
  511. package/dist/lib/node-esm/chunk-2LEN26ZQ.mjs.map +0 -7
  512. package/dist/lib/node-esm/chunk-3XC7LQSO.mjs +0 -1975
  513. package/dist/lib/node-esm/chunk-3XC7LQSO.mjs.map +0 -7
  514. package/dist/lib/node-esm/chunk-75PHXBN3.mjs +0 -327
  515. package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +0 -7
  516. package/dist/lib/node-esm/chunk-F6LA7XNS.mjs +0 -199
  517. package/dist/lib/node-esm/chunk-F6LA7XNS.mjs.map +0 -7
  518. package/dist/lib/node-esm/chunk-LB72WG6R.mjs +0 -231
  519. package/dist/lib/node-esm/chunk-LB72WG6R.mjs.map +0 -7
  520. package/dist/lib/node-esm/chunk-MJD5XWQV.mjs +0 -288
  521. package/dist/lib/node-esm/chunk-MJD5XWQV.mjs.map +0 -7
  522. package/dist/lib/node-esm/chunk-POWB2BPC.mjs +0 -25
  523. package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +0 -7
  524. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +0 -22
  525. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +0 -7
  526. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +0 -21
  527. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +0 -7
  528. package/dist/lib/node-esm/operation-resolver-2ZD2DXOU.mjs +0 -134
  529. package/dist/lib/node-esm/operation-resolver-2ZD2DXOU.mjs.map +0 -7
  530. package/dist/lib/node-esm/react-surface-T4VMCCKZ.mjs +0 -126
  531. package/dist/lib/node-esm/react-surface-T4VMCCKZ.mjs.map +0 -7
  532. package/dist/lib/node-esm/repair-DMI55PON.mjs +0 -52
  533. package/dist/lib/node-esm/repair-DMI55PON.mjs.map +0 -7
  534. package/dist/lib/node-esm/settings-NGGZA7S7.mjs +0 -34
  535. package/dist/lib/node-esm/settings-NGGZA7S7.mjs.map +0 -7
  536. package/dist/lib/node-esm/state-VSCPGN7R.mjs +0 -27
  537. package/dist/lib/node-esm/state-VSCPGN7R.mjs.map +0 -7
  538. package/dist/lib/node-esm/toolkit-JPRJRDDB.mjs +0 -20
  539. package/dist/lib/node-esm/toolkit-JPRJRDDB.mjs.map +0 -7
  540. package/dist/types/src/blueprints/assistant-blueprint.d.ts +0 -11
  541. package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +0 -1
  542. package/dist/types/src/capabilities/ai-service/ai-service.d.ts +0 -6
  543. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +0 -1
  544. package/dist/types/src/capabilities/ai-service/index.d.ts +0 -3
  545. package/dist/types/src/capabilities/ai-service/index.d.ts.map +0 -1
  546. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
  547. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
  548. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
  549. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
  550. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -26
  551. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
  552. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -4
  553. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
  554. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +0 -1
  555. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +0 -3
  556. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +0 -1
  557. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +0 -3
  558. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +0 -1
  559. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +0 -13
  560. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +0 -1
  561. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  562. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  563. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  564. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  565. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  566. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  567. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  568. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  569. package/dist/types/src/capabilities/repair/index.d.ts +0 -3
  570. package/dist/types/src/capabilities/repair/index.d.ts.map +0 -1
  571. package/dist/types/src/capabilities/repair/repair.d.ts +0 -6
  572. package/dist/types/src/capabilities/repair/repair.d.ts.map +0 -1
  573. package/dist/types/src/capabilities/settings/index.d.ts +0 -15
  574. package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
  575. package/dist/types/src/capabilities/settings/settings.d.ts +0 -18
  576. package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
  577. package/dist/types/src/capabilities/state/index.d.ts +0 -11
  578. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  579. package/dist/types/src/capabilities/state/state.d.ts +0 -13
  580. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  581. package/dist/types/src/capabilities/toolkit/index.d.ts +0 -3
  582. package/dist/types/src/capabilities/toolkit/index.d.ts.map +0 -1
  583. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +0 -6
  584. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +0 -1
  585. package/dist/types/src/components/BlueprintArticle.d.ts +0 -7
  586. package/dist/types/src/components/BlueprintArticle.d.ts.map +0 -1
  587. package/dist/types/src/components/ChatCompanion.d.ts +0 -13
  588. package/dist/types/src/components/ChatCompanion.d.ts.map +0 -1
  589. package/dist/types/src/components/ChatContainer.d.ts +0 -19
  590. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  591. package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
  592. package/dist/types/src/components/InitiativeContainer.d.ts +0 -9
  593. package/dist/types/src/components/InitiativeContainer.d.ts.map +0 -1
  594. package/dist/types/src/components/PromptArticle.d.ts +0 -7
  595. package/dist/types/src/components/PromptArticle.d.ts.map +0 -1
  596. package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts +0 -4
  597. package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts.map +0 -1
  598. package/dist/types/src/components/TriggerStatus/index.d.ts +0 -2
  599. package/dist/types/src/components/TriggerStatus/index.d.ts.map +0 -1
  600. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +0 -12
  601. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +0 -1
  602. package/dist/types/src/components/Typewriter/Typewriter.d.ts +0 -11
  603. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +0 -1
  604. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +0 -7
  605. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +0 -1
  606. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +0 -5
  607. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +0 -1
  608. package/dist/types/src/components/Typewriter/index.d.ts +0 -2
  609. package/dist/types/src/components/Typewriter/index.d.ts.map +0 -1
  610. package/dist/types/src/functions/index.d.ts +0 -4
  611. package/dist/types/src/functions/index.d.ts.map +0 -1
  612. package/dist/types/src/functions/object-list.d.ts +0 -10
  613. package/dist/types/src/functions/object-list.d.ts.map +0 -1
  614. package/dist/types/src/functions/object-load.d.ts +0 -8
  615. package/dist/types/src/functions/object-load.d.ts.map +0 -1
  616. package/dist/types/src/functions/object-search.d.ts +0 -10
  617. package/dist/types/src/functions/object-search.d.ts.map +0 -1
  618. package/dist/types/src/processor/update-name.d.ts +0 -10
  619. package/dist/types/src/processor/update-name.d.ts.map +0 -1
  620. package/dist/types/src/types/AssistantAction.d.ts +0 -97
  621. package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
  622. package/src/blueprints/assistant-blueprint.ts +0 -57
  623. package/src/capabilities/ai-service/index.ts +0 -7
  624. package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -200
  625. package/src/capabilities/app-graph-builder/index.ts +0 -7
  626. package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -74
  627. package/src/capabilities/blueprint-definition/index.ts +0 -8
  628. package/src/capabilities/edge-model-resolver/index.ts +0 -7
  629. package/src/capabilities/local-model-resolver/index.ts +0 -7
  630. package/src/capabilities/operation-resolver/index.ts +0 -7
  631. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -112
  632. package/src/capabilities/react-surface/index.ts +0 -7
  633. package/src/capabilities/react-surface/react-surface.tsx +0 -111
  634. package/src/capabilities/repair/index.ts +0 -7
  635. package/src/capabilities/repair/repair.ts +0 -62
  636. package/src/capabilities/settings/index.ts +0 -7
  637. package/src/capabilities/state/index.ts +0 -7
  638. package/src/capabilities/toolkit/index.ts +0 -7
  639. package/src/capabilities/toolkit/toolkit.ts +0 -27
  640. package/src/components/BlueprintArticle.tsx +0 -28
  641. package/src/components/ChatCompanion.tsx +0 -226
  642. package/src/components/ChatContainer.tsx +0 -68
  643. package/src/components/InitiativeContainer.tsx +0 -340
  644. package/src/components/PromptArticle.tsx +0 -49
  645. package/src/components/TriggerStatus/TriggerStatus.tsx +0 -142
  646. package/src/components/TriggerStatus/index.ts +0 -5
  647. package/src/components/Typewriter/AssistantToolbar.tsx +0 -161
  648. package/src/components/Typewriter/Typewriter.stories.tsx +0 -83
  649. package/src/components/Typewriter/Typewriter.tsx +0 -54
  650. package/src/components/Typewriter/assistant-extension.tsx +0 -144
  651. package/src/functions/index.ts +0 -7
  652. package/src/functions/object-list.ts +0 -49
  653. package/src/functions/object-load.ts +0 -44
  654. package/src/functions/object-search.ts +0 -46
  655. package/src/processor/update-name.ts +0 -58
  656. package/src/types/AssistantAction.ts +0 -76
  657. /package/src/capabilities/{ai-service/ai-service.ts → ai-service.ts} +0 -0
  658. /package/src/capabilities/{edge-model-resolver/edge-model-resolver.ts → edge-model-resolver.ts} +0 -0
@@ -1,315 +1,3373 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- AssistantSettings,
4
- BlueprintArticle,
5
- Chat,
6
- ChatCompanion,
7
- ChatContainer,
8
- ChatContextProvider,
9
- ChatDialog,
10
- InitiativeContainer,
11
- PromptArticle,
12
- Toolbox,
13
- ToolboxContainer,
14
- TriggerStatus,
15
- useActiveBlueprints,
16
- useBlueprintHandlers,
17
- useBlueprintRegistry,
18
- useBlueprints,
19
- useChatContext,
20
- useChatProcessor,
21
- useChatServices,
22
- useChatToolbarActions,
23
- useContextBinder,
24
- useContextObjects,
25
- useFilteredTypes,
26
- useFlush,
27
- useOnline,
28
- usePresets,
29
- useReferencesProvider
30
- } from "./chunk-3XC7LQSO.mjs";
31
- import "./chunk-MJD5XWQV.mjs";
32
- import {
33
- TemplateEditor
34
- } from "./chunk-75PHXBN3.mjs";
3
+ blueprint_default
4
+ } from "./chunk-NZIKC7AN.mjs";
35
5
  import {
36
6
  ApiAuthorization,
37
7
  AssistantCapabilities,
38
8
  AssistantEvents,
39
- AssistantOperation,
40
9
  Assistant_exports,
41
10
  LLM_PROVIDERS,
42
11
  ServiceType,
43
12
  categoryIcons
44
- } from "./chunk-LB72WG6R.mjs";
45
- import {
46
- ASSISTANT_DIALOG,
47
- meta
48
- } from "./chunk-POWB2BPC.mjs";
49
- import "./chunk-2LEN26ZQ.mjs";
13
+ } from "./chunk-W3JZ2F4T.mjs";
50
14
  import {
51
- assistant_blueprint_exports
52
- } from "./chunk-F6LA7XNS.mjs";
15
+ UpdateChatName
16
+ } from "./chunk-PXAJSTGZ.mjs";
53
17
  import "./chunk-HSLMI22Q.mjs";
54
18
 
55
- // src/capabilities/ai-service/index.ts
56
- import { Capability } from "@dxos/app-framework";
57
- var AiService = Capability.lazy("AiService", () => import("./ai-service-ZI3A6RVG.mjs"));
19
+ // src/components/index.ts
20
+ import { lazy } from "react";
21
+
22
+ // src/components/Chat/Chat.tsx
23
+ import { Prec } from "@codemirror/state";
24
+ import { keymap } from "@codemirror/view";
25
+ import { useAtomValue } from "@effect-atom/atom-react";
26
+ import { createContext } from "@radix-ui/react-context";
27
+ import * as Array2 from "effect/Array";
28
+ import * as Option3 from "effect/Option";
29
+ import React11, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState5 } from "react";
30
+ import { Event } from "@dxos/async";
31
+ import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
32
+ import { useVoiceInput } from "@dxos/plugin-transcription";
33
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
34
+ import { useIdentity } from "@dxos/react-client/halo";
35
+ import { Input as Input2, useDynamicRef, useTranslation as useTranslation6 } from "@dxos/react-ui";
36
+ import { ChatEditor } from "@dxos/react-ui-chat";
37
+ import { Menu } from "@dxos/react-ui-menu";
38
+ import { Message } from "@dxos/types";
39
+ import { composable, composableProps, mx as mx7 } from "@dxos/ui-theme";
40
+ import { isTruthy, trim } from "@dxos/util";
41
+ import { useChatToolbarActions } from "#hooks";
42
+ import { meta as meta6 } from "#meta";
43
+
44
+ // src/components/ChatPrompt/ChatActions.tsx
45
+ import React from "react";
46
+ import { IconButton, useTranslation } from "@dxos/react-ui";
47
+ import { mx } from "@dxos/ui-theme";
48
+ import { meta } from "#meta";
49
+ var ChatActions = ({ classNames, children, microphone, recording, processing, debug, onEvent }) => {
50
+ const { t } = useTranslation(meta.id);
51
+ return /* @__PURE__ */ React.createElement("div", {
52
+ className: mx("flex items-center me-1", classNames)
53
+ }, children, /* @__PURE__ */ React.createElement(IconButton, {
54
+ disabled: !processing,
55
+ variant: "ghost",
56
+ icon: "ph--x--regular",
57
+ iconOnly: true,
58
+ label: t("cancel-processing.button"),
59
+ onClick: () => onEvent?.({
60
+ type: "cancel"
61
+ })
62
+ }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
63
+ disabled: !processing,
64
+ classNames: mx(recording && "bg-primary-500"),
65
+ variant: "ghost",
66
+ icon: "ph--microphone--regular",
67
+ iconOnly: true,
68
+ noTooltip: true,
69
+ label: t("microphone.button"),
70
+ onMouseDown: () => onEvent?.({
71
+ type: "record-start"
72
+ }),
73
+ onMouseUp: () => onEvent?.({
74
+ type: "record-stop"
75
+ }),
76
+ onTouchStart: () => onEvent?.({
77
+ type: "record-start"
78
+ }),
79
+ onTouchEnd: () => onEvent?.({
80
+ type: "record-stop"
81
+ })
82
+ }), debug && /* @__PURE__ */ React.createElement(IconButton, {
83
+ variant: "ghost",
84
+ icon: "ph--wrench--regular",
85
+ iconOnly: true,
86
+ label: t("debug.button"),
87
+ onClick: () => onEvent?.({
88
+ type: "toggle-debug"
89
+ })
90
+ }));
91
+ };
92
+
93
+ // src/components/ChatPrompt/ChatOptions.tsx
94
+ import * as Option from "effect/Option";
95
+ import React2, { useCallback, useMemo, useState } from "react";
96
+ import { McpServer } from "@dxos/assistant-toolkit";
97
+ import { Annotation, Filter, Obj, Type } from "@dxos/echo";
98
+ import { useQuery } from "@dxos/react-client/echo";
99
+ import { IconButton as IconButton2, Input, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
100
+ import { Listbox, SearchList, useSearchListResults } from "@dxos/react-ui-search";
101
+ import { Tabs } from "@dxos/react-ui-tabs";
102
+ import { getStyles, mx as mx2 } from "@dxos/ui-theme";
103
+ import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
104
+ import { meta as meta2 } from "#meta";
105
+ var styles = {
106
+ panel: "w-[calc(100dvw-.5rem)] sm:w-max md:w-popover-default-width max-w-document-width",
107
+ toolbar: "p-form-chrome border-t border-separator"
108
+ };
109
+ var ChatOptions = ({ db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
110
+ const { t } = useTranslation2(meta2.id);
111
+ return /* @__PURE__ */ React2.createElement("div", {
112
+ role: "none",
113
+ className: "flex p-2"
114
+ }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
115
+ asChild: true
116
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
117
+ variant: "ghost",
118
+ icon: "ph--plus--regular",
119
+ iconOnly: true,
120
+ label: t("context-objects.button")
121
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
122
+ side: "top",
123
+ classNames: styles.panel
124
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
125
+ db,
126
+ context
127
+ })), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
128
+ asChild: true
129
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
130
+ variant: "ghost",
131
+ icon: "ph--sliders-horizontal--regular",
132
+ iconOnly: true,
133
+ label: t("context-settings.button")
134
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
135
+ side: "top",
136
+ classNames: styles.panel
137
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Tabs.Root, {
138
+ orientation: "horizontal",
139
+ defaultValue: "model",
140
+ defaultActivePart: "list",
141
+ tabIndex: -1
142
+ }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
143
+ // TODO(burdon): Simplify styles.
144
+ classNames: mx2("max-h-(--radix-popover-content-available-height) grid grid-rows-[1fr_min-content]", '[&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content]', '[&_[role="listbox"]]:min-h-0 [&_[role="listbox"]]:overflow-y-auto', '[&_[role="tabpanel"]]:min-h-0 [&_[role="tabpanel"]]:px-form-chrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden')
145
+ }, /* @__PURE__ */ React2.createElement(Tabs.Panel, {
146
+ value: "model",
147
+ tabIndex: -1,
148
+ classNames: "dx-focus-ring-inset"
149
+ }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
150
+ presets,
151
+ preset,
152
+ onPresetChange
153
+ })), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
154
+ value: "mcp-servers",
155
+ tabIndex: -1,
156
+ classNames: "dx-focus-ring-inset"
157
+ }, /* @__PURE__ */ React2.createElement(McpServersPanel, {
158
+ db
159
+ })), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
160
+ value: "blueprints",
161
+ tabIndex: -1,
162
+ classNames: "dx-focus-ring-inset"
163
+ }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
164
+ blueprintRegistry,
165
+ db,
166
+ context
167
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
168
+ classNames: styles.toolbar
169
+ }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
170
+ value: "model",
171
+ icon: "ph--cpu--regular",
172
+ label: t("chat-model.title")
173
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
174
+ value: "blueprints",
175
+ icon: "ph--blueprint--regular",
176
+ label: t("blueprints-in-context.title")
177
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
178
+ value: "mcp-servers",
179
+ icon: "ph--plugs-connected--regular",
180
+ label: t("mcp-servers.title")
181
+ }))))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
182
+ };
183
+ var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
184
+ const { t } = useTranslation2(meta2.id);
185
+ const blueprints = useBlueprints({
186
+ blueprintRegistry,
187
+ db
188
+ });
189
+ const activeBlueprints = useActiveBlueprints({
190
+ context
191
+ });
192
+ const { onUpdateBlueprint } = useBlueprintHandlers({
193
+ db,
194
+ context,
195
+ blueprintRegistry
196
+ });
197
+ const { results, handleSearch } = useSearchListResults({
198
+ items: blueprints,
199
+ extract: (blueprint) => blueprint.name
200
+ });
201
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
202
+ onSearch: handleSearch
203
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
204
+ classNames: "py-form-chrome"
205
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.map((blueprint) => {
206
+ const isActive = activeBlueprints.has(blueprint.key);
207
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
208
+ classNames: "flex items-center overflow-hidden",
209
+ key: blueprint.key,
210
+ value: blueprint.key,
211
+ label: blueprint.name,
212
+ checked: isActive,
213
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
214
+ });
215
+ }))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
216
+ placeholder: t("search.placeholder"),
217
+ classNames: "mb-form-chrome",
218
+ autoFocus: true
219
+ }));
220
+ };
221
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
222
+ return /* @__PURE__ */ React2.createElement(Listbox.Root, {
223
+ value: preset,
224
+ onValueChange: onPresetChange,
225
+ autoFocus: true
226
+ }, presets?.map(({ id, label }) => {
227
+ return /* @__PURE__ */ React2.createElement(Listbox.Option, {
228
+ key: id,
229
+ value: id
230
+ }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
231
+ }));
232
+ };
233
+ var McpServersPanel = ({ db }) => {
234
+ const { t } = useTranslation2(meta2.id);
235
+ const servers = useQuery(db, Filter.type(McpServer.McpServer));
236
+ const [adding, setAdding] = useState(false);
237
+ const handleAdd = useCallback((name, url, protocol, apiKey) => {
238
+ db.add(Obj.make(McpServer.McpServer, {
239
+ name,
240
+ url,
241
+ protocol,
242
+ apiKey,
243
+ enabled: true
244
+ }));
245
+ setAdding(false);
246
+ }, [
247
+ db
248
+ ]);
249
+ const handleToggle = useCallback((server, enabled) => {
250
+ Obj.change(server, (server2) => {
251
+ server2.enabled = enabled;
252
+ });
253
+ }, []);
254
+ const handleRemove = useCallback((server) => {
255
+ db.remove(server);
256
+ }, [
257
+ db
258
+ ]);
259
+ return /* @__PURE__ */ React2.createElement("div", {
260
+ className: "py-form-chrome space-y-2"
261
+ }, servers.map((server) => /* @__PURE__ */ React2.createElement("div", {
262
+ key: server.id,
263
+ className: "flex items-center gap-2 px-form-chrome"
264
+ }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
265
+ srOnly: true
266
+ }, server.name), /* @__PURE__ */ React2.createElement(Input.Switch, {
267
+ checked: server.enabled !== false,
268
+ onCheckedChange: (checked) => handleToggle(server, !!checked)
269
+ })), /* @__PURE__ */ React2.createElement("span", {
270
+ className: "flex-1 truncate text-sm"
271
+ }, server.name), /* @__PURE__ */ React2.createElement("span", {
272
+ className: "truncate text-xs text-description"
273
+ }, server.url), /* @__PURE__ */ React2.createElement(IconButton2, {
274
+ variant: "ghost",
275
+ icon: "ph--x--regular",
276
+ iconOnly: true,
277
+ label: t("mcp-server-remove.label"),
278
+ onClick: () => handleRemove(server)
279
+ }))), adding ? /* @__PURE__ */ React2.createElement(McpServerForm, {
280
+ onSubmit: handleAdd,
281
+ onCancel: () => setAdding(false)
282
+ }) : /* @__PURE__ */ React2.createElement("div", {
283
+ role: "none",
284
+ className: "px-form-chrome"
285
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
286
+ variant: "ghost",
287
+ icon: "ph--plus--regular",
288
+ label: t("mcp-server-add.label"),
289
+ onClick: () => setAdding(true)
290
+ })));
291
+ };
292
+ var McpServerForm = ({ onSubmit, onCancel }) => {
293
+ const { t } = useTranslation2(meta2.id);
294
+ const [name, setName] = useState("");
295
+ const [url, setUrl] = useState("");
296
+ const [protocol, setProtocol] = useState("sse");
297
+ const [apiKey, setApiKey] = useState("");
298
+ const canSubmit = name.trim().length > 0 && url.trim().length > 0;
299
+ const handleSubmit = useCallback(() => {
300
+ if (canSubmit) {
301
+ onSubmit(name.trim(), url.trim(), protocol, apiKey.trim() || void 0);
302
+ }
303
+ }, [
304
+ canSubmit,
305
+ name,
306
+ url,
307
+ protocol,
308
+ apiKey,
309
+ onSubmit
310
+ ]);
311
+ return /* @__PURE__ */ React2.createElement("div", {
312
+ className: "space-y-2 px-form-chrome"
313
+ }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
314
+ srOnly: true
315
+ }, t("mcp-server-name.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
316
+ placeholder: t("mcp-server-name.placeholder"),
317
+ value: name,
318
+ onChange: (event) => setName(event.target.value),
319
+ autoFocus: true
320
+ })), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
321
+ srOnly: true
322
+ }, t("mcp-server-url.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
323
+ placeholder: t("mcp-server-url.placeholder"),
324
+ value: url,
325
+ onChange: (event) => setUrl(event.target.value)
326
+ })), /* @__PURE__ */ React2.createElement(Select.Root, {
327
+ value: protocol,
328
+ onValueChange: (value2) => setProtocol(value2)
329
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
330
+ placeholder: t("mcp-server-protocol.label")
331
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
332
+ value: "sse"
333
+ }, "SSE"), /* @__PURE__ */ React2.createElement(Select.Option, {
334
+ value: "http"
335
+ }, "HTTP"))))), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
336
+ srOnly: true
337
+ }, t("mcp-server-api-key.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
338
+ type: "password",
339
+ placeholder: t("mcp-server-api-key.placeholder"),
340
+ value: apiKey,
341
+ onChange: (event) => setApiKey(event.target.value)
342
+ })), /* @__PURE__ */ React2.createElement("div", {
343
+ role: "none",
344
+ className: "flex gap-2"
345
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
346
+ variant: "ghost",
347
+ icon: "ph--check--regular",
348
+ iconOnly: true,
349
+ label: t("save.button"),
350
+ onClick: handleSubmit,
351
+ disabled: !canSubmit
352
+ }), /* @__PURE__ */ React2.createElement(IconButton2, {
353
+ variant: "ghost",
354
+ icon: "ph--x--regular",
355
+ iconOnly: true,
356
+ label: t("cancel.button"),
357
+ onClick: onCancel
358
+ })));
359
+ };
360
+ var ANY = "__any__";
361
+ var ObjectsPanel = ({ db, context }) => {
362
+ const { t } = useTranslation2(meta2.id);
363
+ const types = useFilteredTypes(db);
364
+ const typenames = useMemo(() => {
365
+ const typenames2 = types.map((type) => {
366
+ const typename2 = Type.getTypename(type);
367
+ return {
368
+ typename: typename2,
369
+ label: t("typename.label", {
370
+ ns: typename2,
371
+ defaultValue: typename2
372
+ })
373
+ };
374
+ });
375
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
376
+ return typenames2;
377
+ }, [
378
+ types
379
+ ]);
380
+ const [typename, setTypename] = useState(ANY);
381
+ const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
382
+ typenames
383
+ ]);
384
+ const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
385
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
386
+ db,
387
+ context
388
+ });
389
+ const { results, handleSearch } = useSearchListResults({
390
+ items: objects,
391
+ extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
392
+ });
393
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
394
+ onSearch: handleSearch
395
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
396
+ classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
397
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
398
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
399
+ const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
400
+ icon: "ph--cube--regular",
401
+ hue: void 0
402
+ })));
403
+ const styles2 = hue ? getStyles(hue) : void 0;
404
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
405
+ classNames: "flex items-center overflow-hidden",
406
+ key: object.id,
407
+ value: object.id,
408
+ icon,
409
+ iconClassNames: styles2?.surfaceText,
410
+ label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
411
+ checked: isActive,
412
+ onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
413
+ });
414
+ }) : /* @__PURE__ */ React2.createElement(SearchList.Item, {
415
+ value: "__empty__",
416
+ label: t("no-results.message")
417
+ }))), /* @__PURE__ */ React2.createElement("div", {
418
+ role: "none",
419
+ className: mx2("flex flex-col", styles.toolbar)
420
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
421
+ value: typename === ANY ? void 0 : typename,
422
+ onValueChange: setTypename
423
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
424
+ placeholder: t("type-filter.placeholder")
425
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
426
+ value: ANY
427
+ }, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
428
+ key: typename2,
429
+ value: typename2
430
+ }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
431
+ placeholder: t("search.placeholder"),
432
+ autoFocus: true
433
+ })));
434
+ };
435
+
436
+ // src/components/ChatPrompt/ChatPresets.tsx
437
+ import React3 from "react";
438
+ import { Select as Select2 } from "@dxos/react-ui";
439
+
440
+ // src/components/ChatPrompt/ChatReferences.tsx
441
+ import * as Option2 from "effect/Option";
442
+ import React4 from "react";
443
+ import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
444
+ import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
445
+ import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
446
+ import { useContextObjects as useContextObjects2 } from "#hooks";
447
+ import { meta as meta3 } from "#meta";
448
+ var ChatReferences = ({ classNames, context, db }) => {
449
+ const { t } = useTranslation3(meta3.id);
450
+ const { objects, onUpdateObject } = useContextObjects2({
451
+ db,
452
+ context
453
+ });
454
+ return /* @__PURE__ */ React4.createElement("ul", {
455
+ className: mx3("flex", classNames)
456
+ }, objects.map((obj) => {
457
+ const dxn = Obj2.getDXN(obj);
458
+ const typename = Obj2.getTypename(obj);
459
+ const label = Obj2.getLabel(obj) ?? (typename ? [
460
+ "object-name.placeholder",
461
+ {
462
+ ns: typename
463
+ }
464
+ ] : obj.id);
465
+ const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
466
+ icon: DEFAULT_OBJECT_ICON,
467
+ hue: void 0
468
+ })));
469
+ const styles2 = hue ? getStyles2(hue) : void 0;
470
+ return /* @__PURE__ */ React4.createElement("li", {
471
+ key: dxn.toString(),
472
+ className: "dx-tag py-0 ps-2 flex items-center gap-1",
473
+ "data-hue": "neutral"
474
+ }, /* @__PURE__ */ React4.createElement(Icon, {
475
+ icon,
476
+ size: 4,
477
+ classNames: styles2?.surfaceText
478
+ }), toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
479
+ icon: "ph--x--bold",
480
+ iconOnly: true,
481
+ variant: "ghost",
482
+ label: t("remove-object-in-context.label"),
483
+ classNames: "p-0 hover:bg-transparent",
484
+ size: 3,
485
+ onClick: () => onUpdateObject?.(dxn, false)
486
+ }));
487
+ }));
488
+ };
489
+ var DEFAULT_OBJECT_ICON = "ph--cube--regular";
490
+
491
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
492
+ import React5, { useEffect, useState as useState2 } from "react";
493
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
494
+ import { Spinner } from "@dxos/react-ui-sfx";
495
+ import { mx as mx4 } from "@dxos/ui-theme";
496
+ var period = 3e3;
497
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
498
+ const [init, setInit] = useState2(false);
499
+ useEffect(() => setInit(false), [
500
+ preset
501
+ ]);
502
+ useTimeout(async () => {
503
+ setInit(true);
504
+ }, period / 2, [
505
+ preset
506
+ ]);
507
+ return /* @__PURE__ */ React5.createElement("div", {
508
+ role: "none",
509
+ className: mx4("relative flex", classNames)
510
+ }, /* @__PURE__ */ React5.createElement(Spinner, {
511
+ duration: period,
512
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
513
+ ...props
514
+ }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
515
+ asChild: true,
516
+ content: error.message
517
+ }, /* @__PURE__ */ React5.createElement("div", {
518
+ className: "absolute inset-0"
519
+ })));
520
+ };
521
+
522
+ // src/components/ChatThread/ChatThread.tsx
523
+ import React10, { forwardRef, useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
524
+ import { PublicKey } from "@dxos/keys";
525
+ import { setRef } from "@dxos/react-ui";
526
+ import { MarkdownStream } from "@dxos/react-ui-components";
527
+ import { mx as mx6 } from "@dxos/ui-theme";
528
+ import { keyToFallback } from "@dxos/util";
529
+
530
+ // src/components/ChatThread/registry.tsx
531
+ import React9 from "react";
532
+ import { log } from "@dxos/log";
533
+ import { getXmlTextChild } from "@dxos/ui-editor";
534
+
535
+ // src/components/ChatThread/tool-widget-state.ts
536
+ var applyToolBlockToWidgetState = (context, block) => {
537
+ switch (block._tag) {
538
+ case "toolCall": {
539
+ context.updateWidget(block.toolCallId, {
540
+ blocks: [
541
+ block
542
+ ]
543
+ });
544
+ break;
545
+ }
546
+ case "toolResult": {
547
+ context.updateWidget(block.toolCallId, ({ blocks = [] } = {
548
+ blocks: []
549
+ }) => ({
550
+ blocks: [
551
+ ...blocks,
552
+ block
553
+ ]
554
+ }));
555
+ break;
556
+ }
557
+ default: {
558
+ break;
559
+ }
560
+ }
561
+ };
562
+ var rehydrateToolWidgetsFromMessages = (context, messages) => {
563
+ for (const message of messages) {
564
+ for (const block of message.blocks) {
565
+ applyToolBlockToWidgetState(context, block);
566
+ }
567
+ }
568
+ };
569
+
570
+ // src/components/ChatThread/widgets/FallbackWidget.tsx
571
+ import React6 from "react";
572
+ import { TogglePanel } from "@dxos/react-ui-components";
573
+ import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
574
+ var FallbackWidget = ({ _tag, ...props }) => {
575
+ return /* @__PURE__ */ React6.createElement(TogglePanel.Root, null, /* @__PURE__ */ React6.createElement(TogglePanel.Header, {
576
+ classNames: "bg-group-surface"
577
+ }, _tag), /* @__PURE__ */ React6.createElement(TogglePanel.Content, {
578
+ classNames: "bg-modal-surface"
579
+ }, /* @__PURE__ */ React6.createElement(TogglePanel.Viewport, null, /* @__PURE__ */ React6.createElement(JsonHighlighter, {
580
+ classNames: "p-2! text-sm",
581
+ data: props
582
+ }))));
583
+ };
584
+ FallbackWidget.displayName = "Fallback";
585
+
586
+ // src/components/ChatThread/widgets/PromptWidget.ts
587
+ import { WidgetType } from "@codemirror/view";
588
+ import { Domino } from "@dxos/ui";
589
+ var PromptWidget = class extends WidgetType {
590
+ text;
591
+ constructor(text) {
592
+ super(), this.text = text;
593
+ }
594
+ eq(other) {
595
+ return this.text === other.text;
596
+ }
597
+ /**
598
+ * NOTE: An ancestor element must set `data-hue` so `.dx-panel` resolves to the user's hue tokens
599
+ * (see `packages/ui/ui-theme/src/css/components/panel.css`).
600
+ */
601
+ toDOM() {
602
+ return Domino.of("div").classNames("flex justify-end my-2").append(Domino.of("div").classNames("dx-panel px-3 py-1.5 rounded-sm").text(this.text)).root;
603
+ }
604
+ };
605
+
606
+ // src/components/ChatThread/widgets/ReasoningWidget.ts
607
+ import { WidgetType as WidgetType2 } from "@codemirror/view";
608
+ import { Domino as Domino2 } from "@dxos/ui";
609
+ var ReasoningWidget = class extends WidgetType2 {
610
+ text;
611
+ #pos;
612
+ /** The timer id last registered for this instance (may differ from the map if superseded). */
613
+ #ownedTimerId = null;
614
+ constructor(text, pos) {
615
+ super(), this.text = text;
616
+ this.#pos = pos === void 0 || pos === "" ? "reasoning" : String(pos);
617
+ }
618
+ eq(other) {
619
+ return this.text === other.text && this.#pos === other.#pos;
620
+ }
621
+ toDOM() {
622
+ const root = Domino2.of("div").classNames("pt-2 pb-2").append(Domino2.of("div").classNames("relative overflow-hidden p-px rounded-sm border border-subdued-separator").attributes({
623
+ "data-trail-container": ""
624
+ }).append(Domino2.of("div").classNames("relative z-10 bg-base-surface rounded-sm text-sm text-description px-2 py-1").append(Domino2.of("div").classNames("max-h-[5lh] overflow-y-auto").text(this.text).attributes({
625
+ "data-reasoning-text": ""
626
+ })), Domino2.of("div").attributes({
627
+ "data-id": this.#pos
628
+ }))).root;
629
+ return root;
630
+ }
631
+ updateDOM(dom) {
632
+ dom.querySelector("[data-reasoning-text]")?.replaceChildren(this.text);
633
+ const container = dom.querySelector("[data-trail-container]");
634
+ let trailHost = container?.querySelector("[data-id]");
635
+ if (container && !trailHost) {
636
+ trailHost = Domino2.of("div").attributes({
637
+ "data-id": this.#pos
638
+ }).root;
639
+ container.append(trailHost);
640
+ }
641
+ if (trailHost?.childElementCount === 0) {
642
+ trailHost.append(...createTrailLayers());
643
+ }
644
+ this.#scheduleTrailRemoval(dom);
645
+ return true;
646
+ }
647
+ destroy(_dom) {
648
+ this.#clearOwnedTrailTimer();
649
+ }
650
+ #scheduleTrailRemoval(dom) {
651
+ const previous = trailRemovalTimers.get(this.#pos);
652
+ if (previous !== void 0) {
653
+ clearTimeout(previous);
654
+ }
655
+ const timerId = setTimeout(() => {
656
+ if (trailRemovalTimers.get(this.#pos) !== timerId) {
657
+ return;
658
+ }
659
+ trailRemovalTimers.delete(this.#pos);
660
+ this.#ownedTimerId = null;
661
+ dom.querySelector("[data-id]")?.remove();
662
+ }, TRAIL_REMOVAL_DELAY_MS);
663
+ trailRemovalTimers.set(this.#pos, timerId);
664
+ this.#ownedTimerId = timerId;
665
+ }
666
+ #clearOwnedTrailTimer() {
667
+ const active = trailRemovalTimers.get(this.#pos);
668
+ if (active !== void 0 && active === this.#ownedTimerId) {
669
+ clearTimeout(active);
670
+ trailRemovalTimers.delete(this.#pos);
671
+ }
672
+ this.#ownedTimerId = null;
673
+ }
674
+ };
675
+ var trail = [
676
+ "absolute z-0 aspect-[2/1] w-16",
677
+ "bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
678
+ "[offset-anchor:100%_50%] [offset-path:border-box]"
679
+ ];
680
+ var TRAIL_REMOVAL_DELAY_MS = 1e3;
681
+ var trailRemovalTimers = /* @__PURE__ */ new Map();
682
+ var createTrailLayers = () => [
683
+ Domino2.of("div").classNames(...trail, "animate-trail").root,
684
+ Domino2.of("div").classNames(...trail, "animate-trail-offset").root
685
+ ];
686
+
687
+ // src/components/ChatThread/widgets/ReferenceWidget.ts
688
+ import { WidgetType as WidgetType3 } from "@codemirror/view";
689
+ import { Domino as Domino3 } from "@dxos/ui";
690
+ var ReferenceWidget = class extends WidgetType3 {
691
+ text;
692
+ dxn;
693
+ constructor(text, dxn) {
694
+ super(), this.text = text, this.dxn = dxn;
695
+ }
696
+ eq(other) {
697
+ return this.dxn === other.dxn;
698
+ }
699
+ toDOM() {
700
+ return Domino3.of("div").classNames("pt-2 pb-2").append(Domino3.of("dx-anchor").classNames("dx-tag--anchor").attributes({
701
+ dxn: this.dxn
702
+ }).text(this.text)).root;
703
+ }
704
+ };
705
+
706
+ // src/components/ChatThread/widgets/SelectWidget.ts
707
+ import { WidgetType as WidgetType4 } from "@codemirror/view";
708
+ import { Domino as Domino4 } from "@dxos/ui";
709
+ var SelectWidget = class extends WidgetType4 {
710
+ options;
711
+ constructor(options) {
712
+ super(), this.options = options;
713
+ }
714
+ eq(other) {
715
+ return JSON.stringify(this.options) === JSON.stringify(other.options);
716
+ }
717
+ /**
718
+ * NOTE: Container must set var based on user's identity.
719
+ */
720
+ toDOM() {
721
+ return Domino4.of("div").attributes({
722
+ role: "group"
723
+ }).classNames("flex flex-wrap pt-2 pb-2 gap-1").append(...this.options.map((option) => Domino4.of("button").classNames("dx-button inline-block max-w-[100cqi]").attributes({
724
+ "data-action": "submit",
725
+ "data-value": option,
726
+ "data-density": "fine"
727
+ }).text(option))).root;
728
+ }
729
+ };
730
+
731
+ // src/components/ChatThread/widgets/StatsWidget.ts
732
+ import { WidgetType as WidgetType5 } from "@codemirror/view";
733
+ import { Domino as Domino5 } from "@dxos/ui";
734
+ var StatsWidget = class extends WidgetType5 {
735
+ text;
736
+ constructor(text) {
737
+ super(), this.text = text;
738
+ }
739
+ eq(other) {
740
+ return this.text === other.text;
741
+ }
742
+ toDOM() {
743
+ return Domino5.of("div").classNames("pt-2 pb-4 text-sm text-placeholder").text(this.text).root;
744
+ }
745
+ updateDOM(dom) {
746
+ dom.textContent = this.text;
747
+ return true;
748
+ }
749
+ };
750
+
751
+ // src/components/ChatThread/widgets/SummaryWidget.tsx
752
+ import React7 from "react";
753
+ import { useTranslation as useTranslation4 } from "@dxos/react-ui";
754
+ import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
755
+ import { meta as meta4 } from "#meta";
756
+ var SummaryWidget = ({ children }) => {
757
+ const { t } = useTranslation4(meta4.id);
758
+ return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
759
+ classNames: "border border-separator rounded-sm"
760
+ }, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
761
+ classNames: "text-sm bg-group-surface"
762
+ }, t("summary.label")), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, null, /* @__PURE__ */ React7.createElement("div", {
763
+ role: "none",
764
+ className: "p-1 text-sm text-description"
765
+ }, children)));
766
+ };
767
+
768
+ // src/components/ChatThread/widgets/SuggestionWidget.ts
769
+ import { WidgetType as WidgetType6 } from "@codemirror/view";
770
+ import { Domino as Domino6, mx as mx5 } from "@dxos/ui";
771
+ var SuggestionWidget = class extends WidgetType6 {
772
+ text;
773
+ constructor(text) {
774
+ super(), this.text = text;
775
+ }
776
+ eq(other) {
777
+ return this.text === other.text;
778
+ }
779
+ toDOM() {
780
+ return Domino6.of("span").classNames(mx5("inline-flex max-w-[calc(100cqi-8px)] my-1 pe-2 overflow-hidden")).append(Domino6.of("button").attributes({
781
+ "data-action": "submit",
782
+ "data-density": "fine",
783
+ "data-value": this.text
784
+ }).classNames(mx5("dx-button gap-2 w-full overflow-hidden")).append(Domino6.of("dx-icon").attributes({
785
+ icon: "ph--lightning--regular"
786
+ }), Domino6.of("span").classNames("flex-1 truncate min-w-0").text(this.text))).root;
787
+ }
788
+ };
789
+
790
+ // src/components/ChatThread/widgets/ToolWidget.tsx
791
+ import React8, { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
792
+ import { useTranslation as useTranslation5 } from "@dxos/react-ui";
793
+ import { NumericTabs, TextCrawl, TogglePanel as TogglePanel3 } from "@dxos/react-ui-components";
794
+ import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
795
+ import { isNonNullable, safeParseJson } from "@dxos/util";
796
+ import { meta as meta5 } from "#meta";
797
+ var ToolWidget = ({ view, blocks = [] }) => {
798
+ const { t } = useTranslation5(meta5.id);
799
+ const items = useMemo2(() => {
800
+ let lastToolCall;
801
+ const tools = [];
802
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
803
+ switch (block._tag) {
804
+ case "toolCall": {
805
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
806
+ return null;
807
+ }
808
+ const tool = tools.find((tool2) => tool2.name === block.name);
809
+ lastToolCall = {
810
+ tool,
811
+ block
812
+ };
813
+ return {
814
+ title: tool?.description ?? [
815
+ t("tool-call.label"),
816
+ block.name
817
+ ].filter(Boolean).join(" "),
818
+ content: {
819
+ ...block,
820
+ input: safeParseJson(block.input)
821
+ }
822
+ };
823
+ }
824
+ case "toolResult": {
825
+ if (block.error) {
826
+ return {
827
+ title: t("tool-error.label"),
828
+ content: block
829
+ };
830
+ }
831
+ const title = lastToolCall?.tool?.description ?? [
832
+ t("tool-result.label"),
833
+ lastToolCall?.block.name
834
+ ].filter(Boolean).join(" ");
835
+ lastToolCall = void 0;
836
+ return {
837
+ title,
838
+ content: {
839
+ ...block,
840
+ result: safeParseJson(block.result)
841
+ }
842
+ };
843
+ }
844
+ case "stats": {
845
+ if (!lastToolCall) {
846
+ return null;
847
+ }
848
+ return {
849
+ title: t("stats.label"),
850
+ content: block
851
+ };
852
+ }
853
+ }
854
+ }).filter(isNonNullable);
855
+ }, [
856
+ blocks,
857
+ t
858
+ ]);
859
+ const handleChangeOpen = useCallback2(() => {
860
+ setTimeout(() => {
861
+ view?.requestMeasure();
862
+ }, 1e3);
863
+ }, [
864
+ view
865
+ ]);
866
+ if (!items.length) {
867
+ return null;
868
+ }
869
+ return /* @__PURE__ */ React8.createElement(ToolPanel, {
870
+ items,
871
+ onChangeOpen: handleChangeOpen
872
+ });
873
+ };
874
+ var ToolPanel = ({ items, onChangeOpen }) => {
875
+ const tabsRef = useRef(null);
876
+ const [selected, setSelected] = useState3(0);
877
+ const [open, setOpen] = useState3(false);
878
+ useEffect2(() => {
879
+ setSelected((prev) => Math.min(prev, Math.max(0, items.length - 1)));
880
+ }, [
881
+ items.length
882
+ ]);
883
+ useEffect2(() => {
884
+ onChangeOpen?.(open);
885
+ if (open) {
886
+ tabsRef.current?.focus();
887
+ }
888
+ }, [
889
+ open,
890
+ onChangeOpen
891
+ ]);
892
+ const handleSelect = useCallback2((index) => {
893
+ setSelected(index);
894
+ }, []);
895
+ return /* @__PURE__ */ React8.createElement(TogglePanel3.Root, {
896
+ open,
897
+ onChangeOpen: setOpen
898
+ }, /* @__PURE__ */ React8.createElement(TogglePanel3.Header, {
899
+ classNames: "text-sm text-placeholder"
900
+ }, /* @__PURE__ */ React8.createElement(TextCrawl, {
901
+ key: "status-roll",
902
+ lines: items.map((item) => item.title),
903
+ autoAdvance: true,
904
+ greedy: true
905
+ })), /* @__PURE__ */ React8.createElement(TogglePanel3.Content, null, /* @__PURE__ */ React8.createElement(TogglePanel3.Viewport, {
906
+ classNames: "grid grid-cols-[32px_1fr]"
907
+ }, /* @__PURE__ */ React8.createElement(NumericTabs, {
908
+ ref: tabsRef,
909
+ classNames: "p-1",
910
+ length: items.length,
911
+ selected,
912
+ onSelect: handleSelect
913
+ }), /* @__PURE__ */ React8.createElement(JsonHighlighter2, {
914
+ data: items[selected]?.content,
915
+ classNames: "p-1 text-xs bg-transparent",
916
+ replacer: {
917
+ maxDepth: 3,
918
+ maxArrayLen: 10,
919
+ maxStringLen: 128
920
+ }
921
+ }))));
922
+ };
923
+
924
+ // src/components/ChatThread/widgets/StatusWidget.ts
925
+ import { WidgetType as WidgetType7 } from "@codemirror/view";
926
+ import { Domino as Domino7 } from "@dxos/ui";
927
+ var StatusWidget = class extends WidgetType7 {
928
+ text;
929
+ #pos;
930
+ /** The timer id last registered for this instance (may differ from the map if superseded). */
931
+ #ownedTimerId = null;
932
+ constructor(text, pos) {
933
+ super(), this.text = text;
934
+ this.#pos = pos === void 0 || pos === "" ? "status" : String(pos);
935
+ }
936
+ eq(other) {
937
+ return this.text === other.text && this.#pos === other.#pos;
938
+ }
939
+ toDOM() {
940
+ return Domino7.of("div").classNames("py-0.5").append(Domino7.of("div").classNames("relative overflow-hidden rounded-sm").append(Domino7.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(Domino7.of("div").classNames("flex h-5 w-full shrink-0 items-center justify-center self-start").append(Domino7.of("span").classNames("block size-1.5 shrink-0 rounded-full bg-current opacity-45")), Domino7.of("div").classNames("relative min-w-0").append(Domino7.of("div").classNames("relative z-10 rounded-sm text-sm leading-5").attributes({
941
+ "data-status-text": ""
942
+ }).text(this.text), Domino7.of("div").attributes({
943
+ "data-id": this.#pos
944
+ }))))).root;
945
+ }
946
+ updateDOM(dom) {
947
+ dom.querySelector("[data-status-text]")?.replaceChildren(this.text);
948
+ const trailHost = dom.querySelector("[data-id]");
949
+ if (trailHost?.childElementCount === 0) {
950
+ trailHost.append(...createTrailLayers2());
951
+ }
952
+ this.#scheduleTrailRemoval(dom);
953
+ return true;
954
+ }
955
+ destroy(_dom) {
956
+ this.#clearOwnedTrailTimer();
957
+ }
958
+ #scheduleTrailRemoval(dom) {
959
+ const previous = trailRemovalTimers2.get(this.#pos);
960
+ if (previous !== void 0) {
961
+ clearTimeout(previous);
962
+ }
963
+ const timerId = setTimeout(() => {
964
+ if (trailRemovalTimers2.get(this.#pos) !== timerId) {
965
+ return;
966
+ }
967
+ trailRemovalTimers2.delete(this.#pos);
968
+ this.#ownedTimerId = null;
969
+ dom.querySelector("[data-id]")?.remove();
970
+ }, TRAIL_REMOVAL_DELAY_MS2);
971
+ trailRemovalTimers2.set(this.#pos, timerId);
972
+ this.#ownedTimerId = timerId;
973
+ }
974
+ #clearOwnedTrailTimer() {
975
+ const active = trailRemovalTimers2.get(this.#pos);
976
+ if (active !== void 0 && active === this.#ownedTimerId) {
977
+ clearTimeout(active);
978
+ trailRemovalTimers2.delete(this.#pos);
979
+ }
980
+ this.#ownedTimerId = null;
981
+ }
982
+ };
983
+ var trail2 = [
984
+ "absolute z-0 aspect-[2/1] w-16",
985
+ "bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
986
+ "[offset-anchor:100%_50%] [offset-path:border-box]"
987
+ ];
988
+ var TRAIL_REMOVAL_DELAY_MS2 = 1e3;
989
+ var trailRemovalTimers2 = /* @__PURE__ */ new Map();
990
+ var createTrailLayers2 = () => [
991
+ Domino7.of("div").classNames(...trail2, "animate-trail").root,
992
+ Domino7.of("div").classNames(...trail2, "animate-trail-offset").root
993
+ ];
994
+
995
+ // src/components/ChatThread/registry.tsx
996
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
997
+ var componentRegistry = {
998
+ //
999
+ // DOM Widgets
1000
+ //
1001
+ prompt: {
1002
+ block: true,
1003
+ factory: ({ children }) => {
1004
+ const text = getXmlTextChild(children);
1005
+ return text ? new PromptWidget(text) : null;
1006
+ }
1007
+ },
1008
+ synthetic: {
1009
+ block: true,
1010
+ factory: ({ children, range }) => {
1011
+ const text = getXmlTextChild(children);
1012
+ return text ? new ReasoningWidget(text, range.from) : null;
1013
+ }
1014
+ },
1015
+ reasoning: {
1016
+ block: true,
1017
+ streaming: true,
1018
+ factory: ({ children, range }) => {
1019
+ const text = getXmlTextChild(children);
1020
+ return text ? new ReasoningWidget(text, range.from) : null;
1021
+ }
1022
+ },
1023
+ reference: {
1024
+ block: false,
1025
+ factory: ({ children, ref }) => {
1026
+ const text = getXmlTextChild(children);
1027
+ return text && ref ? new ReferenceWidget(text, ref) : null;
1028
+ }
1029
+ },
1030
+ select: {
1031
+ block: true,
1032
+ factory: ({ children }) => {
1033
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1034
+ return options?.length ? new SelectWidget(options) : null;
1035
+ }
1036
+ },
1037
+ suggestion: {
1038
+ block: true,
1039
+ factory: ({ children }) => {
1040
+ const text = getXmlTextChild(children);
1041
+ return text ? new SuggestionWidget(text) : null;
1042
+ }
1043
+ },
1044
+ stats: {
1045
+ block: true,
1046
+ factory: ({ children }) => {
1047
+ const text = getXmlTextChild(children);
1048
+ return text ? new StatsWidget(text) : null;
1049
+ }
1050
+ },
1051
+ status: {
1052
+ block: true,
1053
+ streaming: true,
1054
+ factory: ({ children, range }) => {
1055
+ const text = getXmlTextChild(children);
1056
+ return text ? new StatusWidget(text, range.from) : null;
1057
+ }
1058
+ },
1059
+ //
1060
+ // React Widgets (portaled outside of the editor)
1061
+ //
1062
+ summary: {
1063
+ block: true,
1064
+ Component: SummaryWidget
1065
+ },
1066
+ toolCall: {
1067
+ block: true,
1068
+ Component: (props) => /* @__PURE__ */ React9.createElement("div", {
1069
+ role: "none",
1070
+ className: "py-2"
1071
+ }, /* @__PURE__ */ React9.createElement(ToolWidget, props))
1072
+ },
1073
+ toolResult: {
1074
+ block: true,
1075
+ Component: FallbackWidget
1076
+ },
1077
+ toolkit: {
1078
+ block: true,
1079
+ Component: FallbackWidget
1080
+ },
1081
+ //
1082
+ // Fallback
1083
+ //
1084
+ json: {
1085
+ block: true,
1086
+ Component: FallbackWidget
1087
+ }
1088
+ };
1089
+ var blockToMarkdown = (context, message, block) => {
1090
+ let str = blockToMarkdownImpl(context, message, block);
1091
+ if (str && !block.pending) {
1092
+ return str += "\n";
1093
+ }
1094
+ return str;
1095
+ };
1096
+ var blockToMarkdownImpl = (context, message, block) => {
1097
+ log("blockToMarkdown", {
1098
+ block: JSON.stringify(block)
1099
+ }, {
1100
+ F: __dxlog_file,
1101
+ L: 150,
1102
+ S: void 0,
1103
+ C: (f, a) => f(...a)
1104
+ });
1105
+ switch (block._tag) {
1106
+ case "text": {
1107
+ if (message.sender.role === "user") {
1108
+ if (block.disposition === "synthetic") {
1109
+ return renderXMLBlock("synthetic", {
1110
+ content: block.text,
1111
+ pending: block.pending
1112
+ });
1113
+ } else {
1114
+ return `<prompt>${block.text}</prompt>`;
1115
+ }
1116
+ } else {
1117
+ const text = block.text.trim();
1118
+ if (text.length > 0) {
1119
+ return text;
1120
+ }
1121
+ }
1122
+ break;
1123
+ }
1124
+ case "reference": {
1125
+ if (block.pending) {
1126
+ return;
1127
+ }
1128
+ const dxn = block.reference.dxn;
1129
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
1130
+ }
1131
+ case "suggestion": {
1132
+ if (block.pending) {
1133
+ return;
1134
+ }
1135
+ return `<suggestion>${block.text}</suggestion>`;
1136
+ }
1137
+ case "select": {
1138
+ if (block.pending || block.options.length === 0) {
1139
+ return;
1140
+ }
1141
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1142
+ }
1143
+ case "toolCall": {
1144
+ applyToolBlockToWidgetState(context, block);
1145
+ return `<toolCall id="${block.toolCallId}" />`;
1146
+ }
1147
+ case "toolResult": {
1148
+ applyToolBlockToWidgetState(context, block);
1149
+ break;
1150
+ }
1151
+ case "stats": {
1152
+ return "";
1153
+ }
1154
+ case "reasoning": {
1155
+ let text = block.reasoningText ?? block.redactedText;
1156
+ if (!text) {
1157
+ return;
1158
+ }
1159
+ return renderXMLBlock("reasoning", {
1160
+ content: text,
1161
+ pending: block.pending
1162
+ });
1163
+ }
1164
+ case "summary": {
1165
+ return renderXMLBlock("summary", {
1166
+ content: block.content,
1167
+ pending: block.pending
1168
+ });
1169
+ }
1170
+ case "status": {
1171
+ return renderXMLBlock("status", {
1172
+ content: block.statusText,
1173
+ pending: block.pending
1174
+ });
1175
+ }
1176
+ default: {
1177
+ return `<json id="${message.id}">
1178
+ ${JSON.stringify(block)}
1179
+ </json>`;
1180
+ }
1181
+ }
1182
+ };
1183
+ var escapeXmlTextContent = (raw) => raw.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1184
+ var renderXMLBlock = (tag, opts) => {
1185
+ const content = escapeXmlTextContent((opts.content ?? "").replace(/\n\n/g, " ").trim());
1186
+ if (opts.pending) {
1187
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}`;
1188
+ } else {
1189
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}</${tag}>`;
1190
+ }
1191
+ };
1192
+
1193
+ // src/components/ChatThread/sync.ts
1194
+ var MessageThreadContext = class {
1195
+ _widgetState;
1196
+ constructor(_widgetState) {
1197
+ this._widgetState = _widgetState;
1198
+ }
1199
+ updateWidget(id, value2) {
1200
+ this._widgetState?.updateWidget(id, value2);
1201
+ }
1202
+ // TODO(burdon): Resolve name from hypergraph.
1203
+ getObjectLabel(_id) {
1204
+ return "Object";
1205
+ }
1206
+ };
1207
+ var MessageSyncer = class {
1208
+ _document;
1209
+ _renderer;
1210
+ _threadId;
1211
+ _completed = 0;
1212
+ _trailing = 0;
1213
+ _context;
1214
+ constructor(_document, _renderer) {
1215
+ this._document = _document;
1216
+ this._renderer = _renderer;
1217
+ this._context = new MessageThreadContext(this._document);
1218
+ }
1219
+ get context() {
1220
+ return this._context;
1221
+ }
1222
+ /**
1223
+ * Replace the document with the rendering of `messages`. Use on mount, on thread switch,
1224
+ * and from {@link update} when it detects an identity change in `messages[0]`.
1225
+ */
1226
+ reset(messages = []) {
1227
+ this._threadId = messages[0]?.id;
1228
+ this._completed = 0;
1229
+ this._trailing = 0;
1230
+ const buffer = this._walk(messages);
1231
+ void this._document.setContent(buffer).then(() => {
1232
+ rehydrateToolWidgetsFromMessages(this._context, messages);
1233
+ });
1234
+ }
1235
+ /**
1236
+ * Stream the suffix of the rendered messages into the document.
1237
+ * Returns `true` if the document was replaced (initial mount or thread switch), `false`
1238
+ * if the call was a streaming append (or a no-op).
1239
+ */
1240
+ update(messages) {
1241
+ if (messages[0]?.id !== this._threadId) {
1242
+ this.reset(messages);
1243
+ return true;
1244
+ }
1245
+ const buffer = this._walk(messages);
1246
+ if (buffer.length > 0) {
1247
+ void this._document.append(buffer);
1248
+ }
1249
+ return false;
1250
+ }
1251
+ /**
1252
+ * Walk flat blocks starting at `_completed`, advancing the cursors and returning the chars
1253
+ * to append. Blocks before `_completed` are skipped — their renderer is never re-invoked,
1254
+ * which preserves single-shot side effects (e.g. tool widget state mutation).
1255
+ */
1256
+ _walk(messages) {
1257
+ let buffer = "";
1258
+ let index = 0;
1259
+ outer: for (const message of messages) {
1260
+ for (const block of message.blocks) {
1261
+ if (index < this._completed) {
1262
+ index++;
1263
+ continue;
1264
+ }
1265
+ const rendered = this._renderer(this._context, message, block) ?? "";
1266
+ if (rendered.length > this._trailing) {
1267
+ buffer += rendered.slice(this._trailing);
1268
+ }
1269
+ if (block.pending) {
1270
+ if (rendered.length > this._trailing) {
1271
+ this._trailing = rendered.length;
1272
+ }
1273
+ break outer;
1274
+ }
1275
+ this._completed = index + 1;
1276
+ this._trailing = 0;
1277
+ index++;
1278
+ }
1279
+ }
1280
+ return buffer;
1281
+ }
1282
+ };
1283
+
1284
+ // src/components/ChatThread/ChatThread.tsx
1285
+ var defaultOptions = {
1286
+ autoScroll: true,
1287
+ // The `wire` extension intercepts append transactions, buffers the text, and drips it into
1288
+ // the editor one character at a time (200 chars/sec by default) while keeping XML elements,
1289
+ // markdown links and images atomic. It's what gives the smooth char-by-char typewriter you
1290
+ // see in the MarkdownStream/Reasoning story.
1291
+ wire: true,
1292
+ cursor: true
1293
+ };
1294
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, options = defaultOptions, debug = false, onEvent }, forwardedRef) => {
1295
+ const [controller, setController] = useState4(null);
1296
+ const handleMarkdownStreamRef = useCallback3((instance) => {
1297
+ setController(instance);
1298
+ setRef(forwardedRef, instance);
1299
+ }, [
1300
+ forwardedRef
1301
+ ]);
1302
+ const userHue = useMemo3(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
1303
+ identity
1304
+ ]);
1305
+ useEffect3(() => {
1306
+ controller?.scrollToBottom();
1307
+ }, [
1308
+ controller,
1309
+ error
1310
+ ]);
1311
+ const syncer = useMemo3(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1312
+ controller
1313
+ ]);
1314
+ useEffect3(() => {
1315
+ if (!syncer) {
1316
+ return;
1317
+ }
1318
+ if (syncer.update(messages)) {
1319
+ controller?.scrollToBottom("instant");
1320
+ }
1321
+ }, [
1322
+ controller,
1323
+ syncer,
1324
+ messages
1325
+ ]);
1326
+ const handleEvent = useCallback3(({ type, value: value2 }) => {
1327
+ switch (type) {
1328
+ case "submit": {
1329
+ value2 && onEvent?.({
1330
+ type,
1331
+ text: value2
1332
+ });
1333
+ break;
1334
+ }
1335
+ }
1336
+ }, [
1337
+ onEvent
1338
+ ]);
1339
+ return /* @__PURE__ */ React10.createElement("div", {
1340
+ role: "none",
1341
+ "data-hue": userHue,
1342
+ className: mx6("flex h-full w-full justify-center overflow-hidden", classNames)
1343
+ }, /* @__PURE__ */ React10.createElement(MarkdownStream, {
1344
+ registry: componentRegistry,
1345
+ options,
1346
+ debug,
1347
+ onEvent: handleEvent,
1348
+ ref: handleMarkdownStreamRef
1349
+ }));
1350
+ });
1351
+
1352
+ // src/components/Chat/Chat.tsx
1353
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
1354
+ var ChatRoot = ({ children, chat, queue, processor, onEvent, ...props }) => {
1355
+ const [debug, setDebug] = useState5(false);
1356
+ const pending = useAtomValue(processor.messages);
1357
+ const streaming = useAtomValue(processor.streaming);
1358
+ const lastPrompt = useRef2(void 0);
1359
+ const storedMessages = useQuery2(queue, Filter2.type(Message.Message));
1360
+ const messages = useMemo4(() => {
1361
+ return Array2.dedupeWith([
1362
+ ...storedMessages,
1363
+ ...pending
1364
+ ], ({ id: a }, { id: b }) => a === b);
1365
+ }, [
1366
+ storedMessages,
1367
+ pending
1368
+ ]);
1369
+ const dump = useCallback4(async () => {
1370
+ const objects = processor.context.getObjects();
1371
+ const blueprints = processor.context.getBlueprints();
1372
+ const system = await processor.getSystemPrompt();
1373
+ const tools = await processor.getTools();
1374
+ console.group("Chat", {
1375
+ objects,
1376
+ blueprints
1377
+ });
1378
+ console.log(trim`
1379
+ System Prompt:
1380
+ ${system}
1381
+ `);
1382
+ console.log(trim`
1383
+ Tools:
1384
+ ${Object.values(tools).map((tool) => JSON.stringify(tool, null, 2)).join("\n")}
1385
+ `);
1386
+ console.groupEnd();
1387
+ }, [
1388
+ processor
1389
+ ]);
1390
+ const event = useMemo4(() => new Event(), []);
1391
+ useEffect4(() => {
1392
+ return event.on((ev) => {
1393
+ switch (ev.type) {
1394
+ case "toggle-debug": {
1395
+ setDebug((debug2) => {
1396
+ if (debug2) {
1397
+ return false;
1398
+ } else {
1399
+ void dump();
1400
+ return true;
1401
+ }
1402
+ });
1403
+ break;
1404
+ }
1405
+ case "submit": {
1406
+ const text = ev.text.trim();
1407
+ if (!streaming && text.length) {
1408
+ lastPrompt.current = ev.text;
1409
+ void processor.request({
1410
+ message: text
1411
+ });
1412
+ }
1413
+ break;
1414
+ }
1415
+ case "retry": {
1416
+ if (!streaming) {
1417
+ void processor.retry();
1418
+ }
1419
+ break;
1420
+ }
1421
+ case "cancel": {
1422
+ if (streaming) {
1423
+ void processor.cancel();
1424
+ if (lastPrompt.current) {
1425
+ event.emit({
1426
+ type: "update-prompt",
1427
+ text: lastPrompt.current
1428
+ });
1429
+ }
1430
+ }
1431
+ break;
1432
+ }
1433
+ }
1434
+ onEvent?.(ev);
1435
+ });
1436
+ }, [
1437
+ event,
1438
+ dump,
1439
+ processor,
1440
+ streaming,
1441
+ onEvent
1442
+ ]);
1443
+ const db = props.db ?? (chat && Obj3.getDatabase(chat));
1444
+ return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
1445
+ debug,
1446
+ event,
1447
+ db,
1448
+ chat,
1449
+ messages,
1450
+ processor,
1451
+ ...props
1452
+ }, children);
1453
+ };
1454
+ ChatRoot.displayName = "Chat.Root";
1455
+ var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
1456
+ var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
1457
+ const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
1458
+ const menuActions = useChatToolbarActions({
1459
+ chat,
1460
+ companionTo
1461
+ });
1462
+ return /* @__PURE__ */ React11.createElement(Menu.Root, {
1463
+ ...menuActions,
1464
+ attendableId
1465
+ }, /* @__PURE__ */ React11.createElement(Menu.Toolbar, {
1466
+ ...composableProps(props),
1467
+ ref: forwardedRef
1468
+ }));
1469
+ });
1470
+ ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
1471
+ var CHAT_VIEWPORT_NAME = "Chat.Viewport";
1472
+ var ChatViewport = composable(({ children, ...props }, forwardedRef) => {
1473
+ return /* @__PURE__ */ React11.createElement("div", {
1474
+ ...composableProps(props, {
1475
+ classNames: "dx-expander flex flex-col"
1476
+ }),
1477
+ ref: forwardedRef
1478
+ }, children);
1479
+ });
1480
+ ChatViewport.displayName = CHAT_VIEWPORT_NAME;
1481
+ var CHAT_THREAD_NAME = "Chat.Thread";
1482
+ var ChatThread2 = (props) => {
1483
+ const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
1484
+ const identity = useIdentity();
1485
+ const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
1486
+ const controllerRef = useRef2(null);
1487
+ useEffect4(() => {
1488
+ return event.on((event2) => {
1489
+ switch (event2.type) {
1490
+ case "submit":
1491
+ case "scroll-to-bottom":
1492
+ controllerRef.current?.scrollToBottom();
1493
+ break;
1494
+ case "nav-previous":
1495
+ controllerRef.current?.navigatePrevious();
1496
+ break;
1497
+ case "nav-next":
1498
+ controllerRef.current?.navigateNext();
1499
+ break;
1500
+ }
1501
+ });
1502
+ }, [
1503
+ event
1504
+ ]);
1505
+ const handleEvent = useCallback4((ev) => {
1506
+ event.emit(ev);
1507
+ }, [
1508
+ event
1509
+ ]);
1510
+ if (!identity) {
1511
+ return null;
1512
+ }
1513
+ return /* @__PURE__ */ React11.createElement(ChatThread, {
1514
+ ...props,
1515
+ identity,
1516
+ messages,
1517
+ error,
1518
+ debug,
1519
+ onEvent: handleEvent,
1520
+ ref: controllerRef
1521
+ });
1522
+ };
1523
+ ChatThread2.displayName = CHAT_THREAD_NAME;
1524
+ var CHAT_PROMPT_NAME = "Chat.Prompt";
1525
+ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1526
+ const { t } = useTranslation6(meta6.id);
1527
+ const { db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
1528
+ const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
1529
+ const streaming = useAtomValue(processor.streaming);
1530
+ const active = useAtomValue(processor.active);
1531
+ const activeRef = useDynamicRef(active);
1532
+ const editorRef = useRef2(null);
1533
+ const [recordingState, setRecordingState] = useState5(false);
1534
+ useEffect4(() => {
1535
+ return event.on((event2) => {
1536
+ switch (event2.type) {
1537
+ case "update-prompt":
1538
+ if (!editorRef.current?.getText()?.length) {
1539
+ editorRef.current?.setText(event2.text);
1540
+ editorRef.current?.focus();
1541
+ }
1542
+ break;
1543
+ case "record-start":
1544
+ setRecordingState(true);
1545
+ break;
1546
+ case "record-stop":
1547
+ setRecordingState(false);
1548
+ break;
1549
+ }
1550
+ });
1551
+ }, [
1552
+ event
1553
+ ]);
1554
+ const { recording } = useVoiceInput({
1555
+ active: recordingState,
1556
+ onUpdate: (text) => {
1557
+ editorRef.current?.setText(text);
1558
+ editorRef.current?.focus();
1559
+ }
1560
+ });
1561
+ const extensions = useMemo4(() => {
1562
+ return [
1563
+ Prec.highest(keymap.of([
1564
+ {
1565
+ key: "Mod-d",
1566
+ preventDefault: true,
1567
+ run: () => {
1568
+ event.emit({
1569
+ type: "toggle-debug"
1570
+ });
1571
+ return true;
1572
+ }
1573
+ },
1574
+ {
1575
+ key: "Mod-ArrowUp",
1576
+ preventDefault: true,
1577
+ run: () => {
1578
+ event.emit({
1579
+ type: "nav-previous"
1580
+ });
1581
+ return true;
1582
+ },
1583
+ shift: () => {
1584
+ event.emit({
1585
+ type: "thread-open"
1586
+ });
1587
+ return true;
1588
+ }
1589
+ },
1590
+ {
1591
+ key: "Mod-ArrowDown",
1592
+ preventDefault: true,
1593
+ run: () => {
1594
+ event.emit({
1595
+ type: "nav-next"
1596
+ });
1597
+ return true;
1598
+ },
1599
+ shift: () => {
1600
+ event.emit({
1601
+ type: "thread-close"
1602
+ });
1603
+ return true;
1604
+ }
1605
+ }
1606
+ ]))
1607
+ ].filter(isTruthy);
1608
+ }, [
1609
+ event,
1610
+ expandable
1611
+ ]);
1612
+ const handleSubmit = useCallback4((text) => {
1613
+ if (!activeRef.current) {
1614
+ event.emit({
1615
+ type: "submit",
1616
+ text
1617
+ });
1618
+ return true;
1619
+ }
1620
+ }, [
1621
+ event
1622
+ ]);
1623
+ const handleEvent = useCallback4((ev) => {
1624
+ event.emit(ev);
1625
+ }, [
1626
+ event
1627
+ ]);
1628
+ return /* @__PURE__ */ React11.createElement("div", {
1629
+ role: "group",
1630
+ className: mx7("flex flex-col w-full dx-density-fine", outline && "bg-group-surface border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded-sm", classNames)
1631
+ }, /* @__PURE__ */ React11.createElement("div", {
1632
+ role: "none",
1633
+ className: "flex p-2 gap-2"
1634
+ }, /* @__PURE__ */ React11.createElement(ChatStatusIndicator, {
1635
+ classNames: "p-1",
1636
+ preset,
1637
+ error,
1638
+ processing: streaming
1639
+ }), /* @__PURE__ */ React11.createElement(ChatEditor, {
1640
+ ref: editorRef,
1641
+ autoFocus: true,
1642
+ lineWrapping: true,
1643
+ classNames: "col-span-2 pt-0.5",
1644
+ placeholder: placeholder ?? t("prompt.placeholder"),
1645
+ extensions,
1646
+ onSubmit: handleSubmit
1647
+ })), db && settings && /* @__PURE__ */ React11.createElement("div", {
1648
+ role: "none",
1649
+ className: "flex items-center overflow-hidden"
1650
+ }, /* @__PURE__ */ React11.createElement(ChatOptions, {
1651
+ db,
1652
+ blueprintRegistry: processor.blueprintRegistry,
1653
+ context: processor.context,
1654
+ preset,
1655
+ presets,
1656
+ onPresetChange
1657
+ }), /* @__PURE__ */ React11.createElement("div", {
1658
+ role: "none",
1659
+ className: "flex grow overflow-x-auto scrollbar-none"
1660
+ }, /* @__PURE__ */ React11.createElement(ChatReferences, {
1661
+ db,
1662
+ context: processor.context
1663
+ })), /* @__PURE__ */ React11.createElement(ChatActions, {
1664
+ classNames: "col-span-2",
1665
+ microphone: true,
1666
+ recording,
1667
+ processing: streaming,
1668
+ onEvent: handleEvent
1669
+ }, online !== void 0 && /* @__PURE__ */ React11.createElement(Input2.Root, null, /* @__PURE__ */ React11.createElement(Input2.Label, {
1670
+ srOnly: true
1671
+ }, t("online-switch.label")), /* @__PURE__ */ React11.createElement(Input2.Switch, {
1672
+ classNames: "mx-2",
1673
+ checked: online,
1674
+ onCheckedChange: onOnlineChange
1675
+ })))));
1676
+ };
1677
+ ChatPrompt.displayName = CHAT_PROMPT_NAME;
1678
+ var Chat = {
1679
+ Root: ChatRoot,
1680
+ Toolbar: ChatToolbar,
1681
+ Viewport: ChatViewport,
1682
+ Thread: ChatThread2,
1683
+ Prompt: ChatPrompt
1684
+ };
1685
+
1686
+ // src/components/ProcessTree/ProcessTree.tsx
1687
+ import * as Match from "effect/Match";
1688
+ import React12 from "react";
1689
+ import { Process } from "@dxos/functions-runtime";
1690
+ import { Icon as Icon2, ScrollArea, Treegrid } from "@dxos/react-ui";
1691
+ import { composable as composable2, composableProps as composableProps2, mx as mx8 } from "@dxos/ui-theme";
1692
+ var ProcessTree = composable2(({ processes, onProcessSelect, ...props }, forwardedRef) => {
1693
+ const filteredProcesses = [
1694
+ ...processes.filter((process) => [
1695
+ Process.State.RUNNING,
1696
+ Process.State.HYBERNATING
1697
+ ].includes(process.state)),
1698
+ ...processes.filter((process) => [
1699
+ Process.State.IDLE
1700
+ ].includes(process.state)).slice(0, 3),
1701
+ ...processes.filter((process) => [
1702
+ Process.State.SUCCEEDED,
1703
+ Process.State.FAILED,
1704
+ Process.State.TERMINATED
1705
+ ].includes(process.state)).slice(0, 3)
1706
+ ];
1707
+ return /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
1708
+ ...composableProps2(props, {
1709
+ classNames: "dx-expander"
1710
+ }),
1711
+ thin: true,
1712
+ ref: forwardedRef
1713
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React12.createElement(Treegrid.Root, {
1714
+ gridTemplateColumns: "1fr"
1715
+ }, filteredProcesses.filter((process) => process.parentPid === null).map((process) => {
1716
+ const activeChildren = filteredProcesses.filter((candidate) => candidate.parentPid?.toString() === process.pid.toString() && candidate.state === Process.State.RUNNING);
1717
+ return /* @__PURE__ */ React12.createElement(Treegrid.Row, {
1718
+ key: process.pid.toString(),
1719
+ id: process.pid.toString(),
1720
+ parentOf: process.parentPid?.toString()
1721
+ }, /* @__PURE__ */ React12.createElement(Treegrid.Cell, {
1722
+ indent: true,
1723
+ classNames: "flex items-center p-1 gap-2 min-w-0",
1724
+ onClick: () => onProcessSelect?.(process)
1725
+ }, /* @__PURE__ */ React12.createElement(Icon2, {
1726
+ size: 4,
1727
+ classNames: mx8(process.state === Process.State.RUNNING && "animate-spin", process.state === Process.State.FAILED && "text-error-text", process.state === Process.State.SUCCEEDED && "text-success-text"),
1728
+ 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"))
1729
+ }), /* @__PURE__ */ React12.createElement("div", {
1730
+ role: "none",
1731
+ className: "flex items-center gap-2 text-xs overflow-hidden"
1732
+ }, /* @__PURE__ */ React12.createElement("span", {
1733
+ className: "truncate text-description"
1734
+ }, process.params.name))));
1735
+ }))));
1736
+ });
1737
+
1738
+ // src/components/TemplateEditor/TemplateEditor.tsx
1739
+ import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1740
+ import { composeRefs } from "@radix-ui/react-compose-refs";
1741
+ import React13 from "react";
1742
+ import { createDocAccessor } from "@dxos/echo-db";
1743
+ import { useThemeContext, useTranslation as useTranslation7 } from "@dxos/react-ui";
1744
+ import { useTextEditor } from "@dxos/react-ui-editor";
1745
+ import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
1746
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
1747
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1748
+ import { meta as meta7 } from "#meta";
1749
+
1750
+ // src/components/TemplateEditor/extensions/handlebars-extension.ts
1751
+ import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
1752
+ import { RangeSetBuilder } from "@codemirror/state";
1753
+ import { Decoration, ViewPlugin, WidgetType as WidgetType8, keymap as keymap2 } from "@codemirror/view";
1754
+ import { Domino as Domino8, mx as mx9 } from "@dxos/ui";
1755
+ var handlebars = (_ = {}) => {
1756
+ return [
1757
+ handlebarsHighlightPlugin,
1758
+ autocompletion({
1759
+ activateOnTyping: true,
1760
+ aboveCursor: true,
1761
+ closeOnBlur: true,
1762
+ override: [
1763
+ handlebarsCompletions
1764
+ ]
1765
+ }),
1766
+ keymap2.of(completionKeymap)
1767
+ ];
1768
+ };
1769
+ var regex = {
1770
+ // {{! comment }}
1771
+ comment: /\{\{!\s*[^}]*\}\}/g,
1772
+ // {{var}}
1773
+ brackets: /\{\{[^}]*\}\}/g,
1774
+ // {{#command}} {{/command}}
1775
+ command: /\{\{[#/]([^}]+)\}\}/g,
1776
+ // {{var}}
1777
+ var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
1778
+ // @dxn:queue:data:xxx
1779
+ dxn: /@?dxn:[\w@:]+/g,
1780
+ // example.com/path/xxx
1781
+ url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
1782
+ };
1783
+ var tagPadding = "mx-0.5 px-1 rounded-xs";
1784
+ var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
1785
+ decorations;
1786
+ constructor(view) {
1787
+ this.decorations = this.buildDecorations(view);
1788
+ }
1789
+ update(update) {
1790
+ if (update.docChanged || update.viewportChanged || update.selectionSet) {
1791
+ this.decorations = this.buildDecorations(update.view);
1792
+ }
1793
+ }
1794
+ // NOTE: Decorations may clash with other extensions (e.g., markdown).
1795
+ buildDecorations(view) {
1796
+ const selection = view.state.selection.main;
1797
+ const decorations = [];
1798
+ for (const { from, to } of view.visibleRanges) {
1799
+ const text = view.state.doc.sliceString(from, to);
1800
+ {
1801
+ let match;
1802
+ while ((match = regex.dxn.exec(text)) !== null) {
1803
+ const start = from + match.index;
1804
+ const end = start + match[0].length;
1805
+ const overlaps = selection.to > start && selection.from <= end;
1806
+ if (!overlaps) {
1807
+ decorations.push({
1808
+ from: start,
1809
+ to: end,
1810
+ decoration: Decoration.widget({
1811
+ widget: new DXNWidget(match[0])
1812
+ })
1813
+ });
1814
+ }
1815
+ }
1816
+ }
1817
+ {
1818
+ let match;
1819
+ while ((match = regex.url.exec(text)) !== null) {
1820
+ const start = from + match.index;
1821
+ const end = start + match[0].length;
1822
+ decorations.push({
1823
+ from: start,
1824
+ to: end,
1825
+ decoration: Decoration.mark({
1826
+ class: mx9("dx-tag--blue", tagPadding)
1827
+ })
1828
+ });
1829
+ }
1830
+ }
1831
+ {
1832
+ let match;
1833
+ while ((match = regex.brackets.exec(text)) !== null) {
1834
+ const start = from + match.index;
1835
+ const end = start + match[0].length;
1836
+ decorations.push({
1837
+ from: start,
1838
+ to: end,
1839
+ decoration: Decoration.mark({
1840
+ class: "text-subdued"
1841
+ })
1842
+ });
1843
+ }
1844
+ }
1845
+ {
1846
+ let match;
1847
+ while ((match = regex.command.exec(text)) !== null) {
1848
+ const start = from + match.index + 2;
1849
+ let end = start + match[0].length - 4;
1850
+ const text2 = view.state.doc.sliceString(start, end);
1851
+ const parts = text2.split(/\s+/);
1852
+ if (parts.length > 1) {
1853
+ const idx = start + parts[0].length;
1854
+ decorations.push({
1855
+ from: idx,
1856
+ to: end,
1857
+ decoration: Decoration.mark({
1858
+ class: "text-green-text"
1859
+ })
1860
+ });
1861
+ end = idx;
1862
+ }
1863
+ decorations.push({
1864
+ from: start,
1865
+ to: end,
1866
+ decoration: Decoration.mark({
1867
+ class: "text-blue-text"
1868
+ })
1869
+ });
1870
+ }
1871
+ }
1872
+ {
1873
+ let match;
1874
+ while ((match = regex.var.exec(text)) !== null) {
1875
+ const start = from + match.index + 2;
1876
+ const end = start + match[0].length - 4;
1877
+ decorations.push({
1878
+ from: start,
1879
+ to: end,
1880
+ decoration: Decoration.mark({
1881
+ class: "text-green-text"
1882
+ })
1883
+ });
1884
+ }
1885
+ }
1886
+ }
1887
+ decorations.sort((a, b) => a.from - b.from || a.to - b.to);
1888
+ const builder = new RangeSetBuilder();
1889
+ for (const { from, to, decoration } of decorations) {
1890
+ builder.add(from, to, decoration);
1891
+ }
1892
+ return builder.finish();
1893
+ }
1894
+ }, {
1895
+ decorations: (v) => v.decorations
1896
+ });
1897
+ var DXNWidget = class extends WidgetType8 {
1898
+ _identifier;
1899
+ constructor(_identifier) {
1900
+ super(), this._identifier = _identifier;
1901
+ }
1902
+ ignoreEvent() {
1903
+ return false;
1904
+ }
1905
+ eq(other) {
1906
+ return this._identifier === other._identifier;
1907
+ }
1908
+ toDOM() {
1909
+ const text = this._identifier.split(":").map((part) => {
1910
+ const len = 16;
1911
+ const plen = 4;
1912
+ if (part.length > len) {
1913
+ return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
1914
+ }
1915
+ return part;
1916
+ }).join(":");
1917
+ return Domino8.of("span").classNames(mx9("font-mono dx-tag--blue", tagPadding)).text(text).root;
1918
+ }
1919
+ };
1920
+ var variables = [
1921
+ "this"
1922
+ ];
1923
+ var commands = [
1924
+ "this",
1925
+ "each",
1926
+ "if",
1927
+ "unless",
1928
+ "with"
1929
+ ];
1930
+ function handlebarsCompletions(context) {
1931
+ const match = context.matchBefore(/\{\{[^}]*/);
1932
+ if (!match || match.from === match.to) {
1933
+ return null;
1934
+ }
1935
+ let type = "variable";
1936
+ let text = match.text.slice(2);
1937
+ let from = match.from + 2;
1938
+ let matches = [];
1939
+ if (text.startsWith("#") || text.startsWith("/")) {
1940
+ const idx = text.lastIndexOf(" ");
1941
+ if (idx !== -1) {
1942
+ type = "variable";
1943
+ matches = variables;
1944
+ text = text.slice(idx + 1);
1945
+ from += idx + 1;
1946
+ } else {
1947
+ type = "command";
1948
+ text = text.slice(1);
1949
+ matches = commands;
1950
+ from += 1;
1951
+ }
1952
+ } else {
1953
+ type = "variable";
1954
+ matches = variables;
1955
+ }
1956
+ const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
1957
+ type,
1958
+ label: name
1959
+ }));
1960
+ return {
1961
+ from,
1962
+ options
1963
+ };
1964
+ }
1965
+
1966
+ // src/components/TemplateEditor/extensions/xml-extension.ts
1967
+ import { syntaxTree } from "@codemirror/language";
1968
+ import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
1969
+ import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
1970
+ var xmlDecorator = (_ = {}) => {
1971
+ return [
1972
+ xmlDecoratorPlugin
1973
+ ];
1974
+ };
1975
+ var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
1976
+ decorations;
1977
+ constructor(view) {
1978
+ this.decorations = this.buildDecorations(view);
1979
+ }
1980
+ update(update) {
1981
+ if (update.docChanged || update.viewportChanged) {
1982
+ this.decorations = this.buildDecorations(update.view);
1983
+ }
1984
+ }
1985
+ buildDecorations(view) {
1986
+ const builder = new RangeSetBuilder2();
1987
+ for (const { from, to } of view.visibleRanges) {
1988
+ syntaxTree(view.state).iterate({
1989
+ from,
1990
+ to,
1991
+ enter: (node) => {
1992
+ if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
1993
+ builder.add(node.from, node.to, Decoration2.mark({
1994
+ class: "font-mono text-subdued"
1995
+ }));
1996
+ }
1997
+ }
1998
+ });
1999
+ }
2000
+ return builder.finish();
2001
+ }
2002
+ }, {
2003
+ decorations: (v) => v.decorations
2004
+ });
2005
+
2006
+ // src/components/TemplateEditor/TemplateEditor.tsx
2007
+ var TemplateEditor = composable3(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
2008
+ const { t } = useTranslation7(meta7.id);
2009
+ const { themeMode } = useThemeContext();
2010
+ const { parentRef } = useTextEditor(() => {
2011
+ const text = template.source?.target;
2012
+ if (!text) {
2013
+ return {};
2014
+ }
2015
+ return {
2016
+ initialValue: text.content ?? "",
2017
+ extensions: [
2018
+ createDataExtensions({
2019
+ id,
2020
+ text: createDocAccessor(text, [
2021
+ "content"
2022
+ ])
2023
+ }),
2024
+ createBasicExtensions({
2025
+ bracketMatching: false,
2026
+ lineNumbers,
2027
+ lineWrapping: true,
2028
+ placeholder: t("template.placeholder")
2029
+ }),
2030
+ createThemeExtensions({
2031
+ themeMode
2032
+ }),
2033
+ createMarkdownExtensions(),
2034
+ decorateMarkdown(),
2035
+ handlebars(),
2036
+ // xml(),
2037
+ // NOTE: Since we're using markdown only HTML nodes are parsed.
2038
+ xmlDecorator(),
2039
+ syntaxHighlighting(defaultHighlightStyle)
2040
+ ].filter(isNonNullable2)
2041
+ };
2042
+ }, [
2043
+ themeMode,
2044
+ template.source?.target,
2045
+ lineNumbers
2046
+ ]);
2047
+ return /* @__PURE__ */ React13.createElement("div", {
2048
+ ...composableProps3(props, {
2049
+ role: "none",
2050
+ classNames: [
2051
+ "h-full overflow-hidden",
2052
+ classNames
2053
+ ]
2054
+ }),
2055
+ ref: composeRefs(parentRef, forwardedRef)
2056
+ });
2057
+ });
2058
+
2059
+ // src/components/Toolbox/Toolbox.tsx
2060
+ import React14, { Fragment, useEffect as useEffect5, useState as useState6 } from "react";
2061
+ import { log as log2 } from "@dxos/log";
2062
+ import { Operation } from "@dxos/operation";
2063
+ import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
2064
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
2065
+ import { composable as composable4, composableProps as composableProps4, mx as mx10 } from "@dxos/ui-theme";
2066
+ import { ServiceType as ServiceType2 } from "#types";
2067
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
2068
+ var Toolbox = composable4(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
2069
+ return /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
2070
+ ...composableProps4(props),
2071
+ thin: true,
2072
+ orientation: "vertical",
2073
+ ref: forwardedRef
2074
+ }, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
2075
+ title: "Blueprints",
2076
+ items: blueprints.map(({ name, description, tools }) => ({
2077
+ name,
2078
+ description,
2079
+ subitems: tools.map((toolId) => ({
2080
+ name: `\u2219 ${safeToolId(toolId)}`
2081
+ }))
2082
+ }))
2083
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
2084
+ title: "Blueprints",
2085
+ items: activeBlueprints.map(({ target }) => ({
2086
+ name: target?.name ?? "",
2087
+ description: target?.description ?? "",
2088
+ subitems: target?.tools.map((toolId) => ({
2089
+ name: `\u2219 ${safeToolId(toolId)}`
2090
+ }))
2091
+ }))
2092
+ }), services && services.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
2093
+ title: "Services",
2094
+ items: services.map(({ service: { serviceId, name, description } }) => ({
2095
+ name: name ?? serviceId,
2096
+ description
2097
+ }))
2098
+ }), functions && functions.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
2099
+ title: "Functions",
2100
+ items: functions.map(({ name, description }) => ({
2101
+ name,
2102
+ description
2103
+ }))
2104
+ })));
2105
+ });
2106
+ Toolbox.displayName = "Toolbox";
2107
+ var Section = ({ title, items, striped }) => {
2108
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
2109
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
2110
+ const subGridClassNames = mx10("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
2111
+ return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("h1", {
2112
+ className: "px-2 text-sm"
2113
+ }, title), /* @__PURE__ */ React14.createElement("div", {
2114
+ className: gridClassNames
2115
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React14.createElement(Fragment, {
2116
+ key: i
2117
+ }, name && /* @__PURE__ */ React14.createElement("div", {
2118
+ className: subGridClassNames
2119
+ }, /* @__PURE__ */ React14.createElement("div", {
2120
+ className: "truncate text-primary-500"
2121
+ }, name), /* @__PURE__ */ React14.createElement("div", {
2122
+ className: "line-clamp-2"
2123
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React14.createElement("div", {
2124
+ key: i2,
2125
+ className: mx10(subGridClassNames, striped && stripeClassNames)
2126
+ }, /* @__PURE__ */ React14.createElement("div", {
2127
+ className: "truncate"
2128
+ }, name2), /* @__PURE__ */ React14.createElement("div", {
2129
+ className: "line-clamp-3 text-subdued"
2130
+ }, description2)))))));
2131
+ };
2132
+ var ToolboxPanel = ({ classNames, db, processor }) => {
2133
+ const services = useQuery3(db, Filter3.type(ServiceType2));
2134
+ const [serviceTools, setServiceTools] = useState6([]);
2135
+ useEffect5(() => {
2136
+ log2("creating service tools...", {
2137
+ services: services.length
2138
+ }, {
2139
+ F: __dxlog_file2,
2140
+ L: 122,
2141
+ S: void 0,
2142
+ C: (f, a) => f(...a)
2143
+ });
2144
+ queueMicrotask(async () => {
2145
+ });
2146
+ }, [
2147
+ services
2148
+ ]);
2149
+ const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
2150
+ return /* @__PURE__ */ React14.createElement(Toolbox, {
2151
+ classNames,
2152
+ blueprints: processor?.context.getBlueprints(),
2153
+ services: serviceTools,
2154
+ functions
2155
+ });
2156
+ };
2157
+ var safeToolId = (name) => {
2158
+ return name.split("_").pop();
2159
+ };
2160
+
2161
+ // src/components/index.ts
2162
+ var AssistantSettings = lazy(() => import("./AssistantSettings-UVUTKO7E.mjs"));
2163
+
2164
+ // src/hooks/useBlueprintRegistry.ts
2165
+ import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo5, useState as useState7 } from "react";
2166
+ import { useCapabilities } from "@dxos/app-framework/ui";
2167
+ import { AppCapabilities } from "@dxos/app-toolkit";
2168
+ import { Blueprint } from "@dxos/blueprints";
2169
+ import { Filter as Filter4, Obj as Obj4, Ref } from "@dxos/echo";
2170
+ import { useQuery as useQuery4 } from "@dxos/react-client/echo";
2171
+ import { distinctBy } from "@dxos/util";
2172
+ var useBlueprintRegistry = () => {
2173
+ const blueprintDefinitions = useCapabilities(AppCapabilities.BlueprintDefinition);
2174
+ return useMemo5(() => new Blueprint.Registry(blueprintDefinitions.map((blueprint) => blueprint.make())), [
2175
+ blueprintDefinitions
2176
+ ]);
2177
+ };
2178
+ var useBlueprints2 = ({ blueprintRegistry, db }) => {
2179
+ const staticBlueprints = useMemo5(() => blueprintRegistry?.query() ?? [], [
2180
+ blueprintRegistry
2181
+ ]);
2182
+ const spaceBlueprints = useQuery4(db, Filter4.type(Blueprint.Blueprint));
2183
+ return useMemo5(() => {
2184
+ const blueprints = distinctBy([
2185
+ ...staticBlueprints,
2186
+ ...spaceBlueprints
2187
+ ], (b) => b.key);
2188
+ blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
2189
+ return blueprints;
2190
+ }, [
2191
+ staticBlueprints,
2192
+ spaceBlueprints
2193
+ ]);
2194
+ };
2195
+ var useActiveBlueprints2 = ({ context }) => {
2196
+ const [active, setActive] = useState7(/* @__PURE__ */ new Map());
2197
+ useEffect6(() => {
2198
+ if (!context) {
2199
+ setActive(/* @__PURE__ */ new Map());
2200
+ return;
2201
+ }
2202
+ const updateActive = () => {
2203
+ const blueprints = context.getBlueprints();
2204
+ setActive(new Map(blueprints.map((blueprint) => [
2205
+ blueprint.key,
2206
+ blueprint
2207
+ ])));
2208
+ };
2209
+ updateActive();
2210
+ return context.subscribeBlueprints(updateActive);
2211
+ }, [
2212
+ context
2213
+ ]);
2214
+ return active;
2215
+ };
2216
+ var useBlueprintHandlers2 = ({ db, context, blueprintRegistry }) => {
2217
+ const onUpdateBlueprint = useCallback5(async (key, checked) => {
2218
+ if (!context || !blueprintRegistry) {
2219
+ return;
2220
+ }
2221
+ const objects = await db.query(Filter4.type(Blueprint.Blueprint)).run();
2222
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
2223
+ if (checked) {
2224
+ if (!storedBlueprint) {
2225
+ const blueprint = blueprintRegistry.getByKey(key);
2226
+ if (!blueprint) {
2227
+ return;
2228
+ }
2229
+ storedBlueprint = db.add(Obj4.clone(blueprint));
2230
+ }
2231
+ await context.bind({
2232
+ blueprints: [
2233
+ Ref.make(storedBlueprint)
2234
+ ]
2235
+ });
2236
+ } else if (storedBlueprint) {
2237
+ await context.unbind({
2238
+ blueprints: [
2239
+ Ref.make(storedBlueprint)
2240
+ ]
2241
+ });
2242
+ }
2243
+ }, [
2244
+ db,
2245
+ context,
2246
+ blueprintRegistry
2247
+ ]);
2248
+ return {
2249
+ onUpdateBlueprint
2250
+ };
2251
+ };
2252
+
2253
+ // src/hooks/useChatProcessor.ts
2254
+ import { RegistryContext } from "@effect-atom/atom-react";
2255
+ import * as Effect2 from "effect/Effect";
2256
+ import { useContext, useMemo as useMemo6, useState as useState8 } from "react";
2257
+ import { AiSession } from "@dxos/assistant";
2258
+ import { Ref as Ref2 } from "@dxos/echo";
2259
+ import { createFeedServiceLayer } from "@dxos/echo-db";
2260
+ import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
2261
+ import { log as log4 } from "@dxos/log";
2262
+ import { useAsyncEffect } from "@dxos/react-ui";
58
2263
 
59
- // src/capabilities/app-graph-builder/index.ts
60
- import { Capability as Capability2 } from "@dxos/app-framework";
61
- var AppGraphBuilder = Capability2.lazy("AppGraphBuilder", () => import("./app-graph-builder-4QN5M6PD.mjs"));
2264
+ // src/processor/presets.ts
2265
+ import * as Schema from "effect/Schema";
2266
+ var ModelProviders = [
2267
+ "dxos-local",
2268
+ "dxos-remote",
2269
+ "lm-studio",
2270
+ "ollama"
2271
+ ];
2272
+ var ModelProvider = Schema.Literal(...ModelProviders);
2273
+ var createModelLabel = (model) => {
2274
+ const parts = model.split("/");
2275
+ return parts[parts.length - 1];
2276
+ };
2277
+ var AiServicePresets = [
2278
+ {
2279
+ provider: "dxos-remote",
2280
+ model: "@anthropic/claude-opus-4-6"
2281
+ },
2282
+ {
2283
+ provider: "dxos-remote",
2284
+ model: "@anthropic/claude-sonnet-4-5"
2285
+ },
2286
+ {
2287
+ provider: "dxos-remote",
2288
+ model: "@anthropic/claude-3-5-haiku-20241022"
2289
+ },
2290
+ {
2291
+ provider: "ollama",
2292
+ model: "gpt-oss:20b"
2293
+ },
2294
+ {
2295
+ provider: "ollama",
2296
+ model: "gemma4:latest"
2297
+ },
2298
+ {
2299
+ provider: "lm-studio",
2300
+ model: "@google/gemma-3-27b"
2301
+ },
2302
+ {
2303
+ provider: "lm-studio",
2304
+ model: "@meta/llama-3.2-3b-instruct"
2305
+ },
2306
+ {
2307
+ model: "deepseek-r1:latest",
2308
+ provider: "dxos-local"
2309
+ }
2310
+ ].map(({ model, provider }, i) => ({
2311
+ id: `preset-${i}`,
2312
+ provider,
2313
+ model,
2314
+ label: createModelLabel(model)
2315
+ }));
62
2316
 
63
- // src/capabilities/blueprint-definition/index.ts
64
- import { Capability as Capability3 } from "@dxos/app-framework";
65
- var BlueprintDefinition = Capability3.lazy("BlueprintDefinition", () => import("./blueprint-definition-H3LFAEK2.mjs"));
2317
+ // src/processor/processor.ts
2318
+ import { Atom, Registry } from "@effect-atom/atom-react";
2319
+ import * as Effect from "effect/Effect";
2320
+ import * as Fiber from "effect/Fiber";
2321
+ import * as Option4 from "effect/Option";
2322
+ import * as Stream from "effect/Stream";
2323
+ import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
2324
+ import { AiContextService, createSystemPrompt, formatSystemPrompt, AgentService, PartialBlock, ToolExecutionServices } from "@dxos/assistant";
2325
+ import { Obj as Obj5 } from "@dxos/echo";
2326
+ import { runAndForwardErrors, unwrapExit } from "@dxos/effect";
2327
+ import { Trace } from "@dxos/functions";
2328
+ import { log as log3 } from "@dxos/log";
2329
+ import { Operation as Operation2 } from "@dxos/operation";
2330
+ import { Message as Message2 } from "@dxos/types";
2331
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
2332
+ var defaultOptions2 = {
2333
+ model: DEFAULT_EDGE_MODEL,
2334
+ autoUpdateNameChance: 0.1
2335
+ };
2336
+ var AiChatProcessor = class {
2337
+ _conversation;
2338
+ _runtime;
2339
+ _feed;
2340
+ _options;
2341
+ #registry;
2342
+ /** Pending messages (finalized, non-streaming). */
2343
+ #pending = Atom.make([]);
2344
+ /** Currently streaming messages (from ephemeral trace events). */
2345
+ #streaming = Atom.make([]);
2346
+ /** Set of message IDs that have been finalized (non-pending delivered via ephemeral). */
2347
+ #finalizedIds = /* @__PURE__ */ new Set();
2348
+ /** Currently active request fiber. */
2349
+ #requestFiber;
2350
+ /** Last request (for retries). */
2351
+ #lastRequest;
2352
+ /** Streaming state. */
2353
+ streaming = Atom.make((get) => get(this.#streaming).length > 0);
2354
+ /** Active state. */
2355
+ active = Atom.make(false);
2356
+ /** Array of Messages (incl. the current message being streamed). */
2357
+ messages = Atom.make((get) => [
2358
+ ...get(this.#pending),
2359
+ ...get(this.#streaming)
2360
+ ]);
2361
+ /** Last error. */
2362
+ error = Atom.make(Option4.none());
2363
+ constructor(_conversation, _runtime, _feed, _options = defaultOptions2) {
2364
+ this._conversation = _conversation;
2365
+ this._runtime = _runtime;
2366
+ this._feed = _feed;
2367
+ this._options = _options;
2368
+ this.#registry = this._options.observableRegistry ?? Registry.make();
2369
+ if (this._options.model && !this._options.system) {
2370
+ const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
2371
+ this._options.system = createSystemPrompt(capabilities);
2372
+ }
2373
+ }
2374
+ get context() {
2375
+ return this._conversation.context;
2376
+ }
2377
+ get conversation() {
2378
+ return this._conversation;
2379
+ }
2380
+ get blueprintRegistry() {
2381
+ return this._options.blueprintRegistry;
2382
+ }
2383
+ get system() {
2384
+ return this._options.system ?? "";
2385
+ }
2386
+ async getTools() {
2387
+ return this._runtime.runPromise(Effect.provide(this._conversation.getTools(), ToolExecutionServices));
2388
+ }
2389
+ async getSystemPrompt() {
2390
+ return this._runtime.runPromise(Effect.gen(this, function* () {
2391
+ const blueprints = this.context.getBlueprints();
2392
+ const objects = this.context.getObjects();
2393
+ return yield* formatSystemPrompt({
2394
+ system: this._options.system,
2395
+ blueprints,
2396
+ objects
2397
+ });
2398
+ }).pipe(Effect.provideService(AiContextService, {
2399
+ binder: this.context
2400
+ }), Effect.orDie));
2401
+ }
2402
+ /**
2403
+ * Initiates a new request via AgentService.
2404
+ */
2405
+ async request(requestProp) {
2406
+ if (this.#requestFiber) {
2407
+ await this.cancel();
2408
+ }
2409
+ try {
2410
+ this.#lastRequest = requestProp;
2411
+ this.#registry.set(this.error, Option4.none());
2412
+ this.#registry.set(this.active, true);
2413
+ const effect = Effect.gen(this, function* () {
2414
+ log3.info("init agent session", {
2415
+ feed: Obj5.getDXN(this._feed).toString(),
2416
+ model: this._options.model
2417
+ }, {
2418
+ F: __dxlog_file3,
2419
+ L: 166,
2420
+ S: this,
2421
+ C: (f, a) => f(...a)
2422
+ });
2423
+ const session = yield* AgentService.getSession(this._feed, {
2424
+ model: this._options.model
2425
+ });
2426
+ const ephemeralStream = session.subscribeEphemeral();
2427
+ yield* ephemeralStream.pipe(Stream.runForEach((message) => Effect.sync(() => {
2428
+ for (const event of message.events) {
2429
+ if (Trace.isOfType(PartialBlock, event)) {
2430
+ this.#handleEphemeralMessage(event.data);
2431
+ }
2432
+ }
2433
+ })), Effect.fork);
2434
+ log3("chat processor submitting prompt", {
2435
+ length: requestProp.message.length
2436
+ }, {
2437
+ F: __dxlog_file3,
2438
+ L: 182,
2439
+ S: this,
2440
+ C: (f, a) => f(...a)
2441
+ });
2442
+ yield* session.submitPrompt(requestProp.message);
2443
+ log3("chat processor submitPrompt returned, waiting for agent", {}, {
2444
+ F: __dxlog_file3,
2445
+ L: 184,
2446
+ S: this,
2447
+ C: (f, a) => f(...a)
2448
+ });
2449
+ yield* session.waitForCompletion();
2450
+ log3.info("session complete", void 0, {
2451
+ F: __dxlog_file3,
2452
+ L: 186,
2453
+ S: this,
2454
+ C: (f, a) => f(...a)
2455
+ });
2456
+ this.#flushStreaming();
2457
+ yield* this.#maybeUpdateChatName();
2458
+ });
2459
+ this.#requestFiber = this._runtime.runFork(effect);
2460
+ try {
2461
+ await this._runtime.runPromise(Fiber.join(this.#requestFiber));
2462
+ } catch (err) {
2463
+ if (err._tag === "InterruptedException" || err.message?.includes("interrupted")) {
2464
+ return;
2465
+ }
2466
+ throw err;
2467
+ }
2468
+ this.#registry.set(this.error, Option4.none());
2469
+ this.#lastRequest = void 0;
2470
+ this.#requestFiber = void 0;
2471
+ } catch (err) {
2472
+ log3.error("request failed", {
2473
+ error: err
2474
+ }, {
2475
+ F: __dxlog_file3,
2476
+ L: 208,
2477
+ S: this,
2478
+ C: (f, a) => f(...a)
2479
+ });
2480
+ this.#registry.set(this.error, Option4.some(new Error("AI service error", {
2481
+ cause: err
2482
+ })));
2483
+ } finally {
2484
+ log3.info("setting active to false", void 0, {
2485
+ F: __dxlog_file3,
2486
+ L: 211,
2487
+ S: this,
2488
+ C: (f, a) => f(...a)
2489
+ });
2490
+ this.#registry.set(this.active, false);
2491
+ this.#requestFiber = void 0;
2492
+ }
2493
+ }
2494
+ /**
2495
+ * Cancels the current request.
2496
+ */
2497
+ async cancel() {
2498
+ await runAndForwardErrors(Effect.gen(this, function* () {
2499
+ if (this.#requestFiber) {
2500
+ yield* Fiber.interrupt(this.#requestFiber);
2501
+ }
2502
+ }));
2503
+ this.#requestFiber = void 0;
2504
+ this.#registry.set(this.active, false);
2505
+ }
2506
+ /**
2507
+ * Retry last failed request.
2508
+ */
2509
+ async retry() {
2510
+ if (this.#lastRequest) {
2511
+ return this.request(this.#lastRequest);
2512
+ }
2513
+ }
2514
+ /**
2515
+ * Update the current chat's name.
2516
+ */
2517
+ async updateName(chat) {
2518
+ unwrapExit(await this._runtime.runPromiseExit(Operation2.invoke(UpdateChatName, {
2519
+ chat
2520
+ })));
2521
+ }
2522
+ /**
2523
+ * Handles an ephemeral message from the agent process.
2524
+ * Both pending and completed blocks arrive here. Completed blocks are deduped
2525
+ * against messages already written to the feed queue to handle the race between
2526
+ * ephemeral delivery and feed replication.
2527
+ */
2528
+ #handleEphemeralMessage(event) {
2529
+ const isPending = event.block.pending;
2530
+ const message = Obj5.make(Message2.Message, {
2531
+ id: event.messageId,
2532
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2533
+ sender: {
2534
+ role: event.role
2535
+ },
2536
+ blocks: [
2537
+ event.block
2538
+ ]
2539
+ });
2540
+ if (isPending) {
2541
+ if (this.#finalizedIds.has(event.messageId)) {
2542
+ return;
2543
+ }
2544
+ this.#registry.update(this.#streaming, (streaming) => {
2545
+ const idx = streaming.findIndex((existing) => existing.id === event.messageId);
2546
+ if (idx >= 0) {
2547
+ const updated = [
2548
+ ...streaming
2549
+ ];
2550
+ updated[idx] = message;
2551
+ return updated;
2552
+ }
2553
+ return [
2554
+ ...streaming,
2555
+ message
2556
+ ];
2557
+ });
2558
+ } else {
2559
+ this.#finalizedIds.add(event.messageId);
2560
+ this.#registry.update(this.#streaming, (streaming) => streaming.filter((existing) => existing.id !== message.id));
2561
+ this.#registry.update(this.#pending, (pending) => {
2562
+ if (pending.some((existing) => existing.id === message.id)) {
2563
+ return pending;
2564
+ }
2565
+ return [
2566
+ ...pending,
2567
+ message
2568
+ ];
2569
+ });
2570
+ }
2571
+ }
2572
+ /**
2573
+ * Move remaining streaming messages to pending (called when agent completes).
2574
+ */
2575
+ #flushStreaming() {
2576
+ const remaining = this.#registry.get(this.#streaming);
2577
+ if (remaining.length > 0) {
2578
+ this.#registry.update(this.#pending, (pending) => [
2579
+ ...pending,
2580
+ ...remaining
2581
+ ]);
2582
+ this.#registry.set(this.#streaming, []);
2583
+ }
2584
+ this.#finalizedIds.clear();
2585
+ }
2586
+ /**
2587
+ * Conditionally schedule chat name update in detached fork mode.
2588
+ * Updates if chat has no name OR based on random chance (default 10%).
2589
+ */
2590
+ #maybeUpdateChatName() {
2591
+ const chat = this._options.chat?.target;
2592
+ if (!chat) {
2593
+ return Effect.void;
2594
+ }
2595
+ const chance = this._options.autoUpdateNameChance ?? defaultOptions2.autoUpdateNameChance ?? 0.1;
2596
+ const shouldUpdate = !chat.name || Math.random() < chance;
2597
+ if (!shouldUpdate) {
2598
+ return Effect.void;
2599
+ }
2600
+ log3.info("scheduling chat name update", {
2601
+ hasName: !!chat.name,
2602
+ chance
2603
+ }, {
2604
+ F: __dxlog_file3,
2605
+ L: 318,
2606
+ S: this,
2607
+ C: (f, a) => f(...a)
2608
+ });
2609
+ return Operation2.schedule(UpdateChatName, {
2610
+ chat
2611
+ });
2612
+ }
2613
+ };
66
2614
 
67
- // src/capabilities/edge-model-resolver/index.ts
68
- import { Capability as Capability4 } from "@dxos/app-framework";
69
- var EdgeModelResolver = Capability4.lazy("EdgeModelResolver", () => import("./edge-model-resolver-CMJ3KNLQ.mjs"));
2615
+ // src/hooks/useChatProcessor.ts
2616
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
2617
+ var useChatProcessor = ({ space, chat, preset, runtime: runtime3, blueprintRegistry, settings }) => {
2618
+ const observableRegistry = useContext(RegistryContext);
2619
+ const [session, setSession] = useState8();
2620
+ useAsyncEffect(async () => {
2621
+ if (!space || !chat) {
2622
+ return;
2623
+ }
2624
+ const feedTarget = chat.feed.target;
2625
+ if (!feedTarget) {
2626
+ return;
2627
+ }
2628
+ const feedServiceLayer = createFeedServiceLayer(space.queues);
2629
+ const runtime4 = await runAndForwardErrors2(Effect2.runtime().pipe(Effect2.provide(feedServiceLayer)));
2630
+ const session2 = new AiSession({
2631
+ feed: feedTarget,
2632
+ runtime: runtime4,
2633
+ registry: observableRegistry
2634
+ });
2635
+ await session2.open();
2636
+ setSession(session2);
2637
+ return () => {
2638
+ void session2.close();
2639
+ setSession(void 0);
2640
+ };
2641
+ }, [
2642
+ space,
2643
+ chat?.feed.target
2644
+ ]);
2645
+ const feed = chat?.feed.target;
2646
+ const processor = useMemo6(() => {
2647
+ if (!runtime3 || !session || !chat || !feed) {
2648
+ return void 0;
2649
+ }
2650
+ log4("creating processor", {
2651
+ preset,
2652
+ model: preset?.model,
2653
+ settings
2654
+ }, {
2655
+ F: __dxlog_file4,
2656
+ L: 80,
2657
+ S: void 0,
2658
+ C: (f, a) => f(...a)
2659
+ });
2660
+ return new AiChatProcessor(session, runtime3, feed, {
2661
+ chat: chat ? Ref2.make(chat) : void 0,
2662
+ observableRegistry,
2663
+ blueprintRegistry,
2664
+ model: preset?.model
2665
+ });
2666
+ }, [
2667
+ runtime3,
2668
+ session,
2669
+ blueprintRegistry,
2670
+ preset,
2671
+ feed
2672
+ ]);
2673
+ return processor;
2674
+ };
70
2675
 
71
- // src/capabilities/local-model-resolver/index.ts
72
- import { Capability as Capability5 } from "@dxos/app-framework";
73
- var LocalModelResolver = Capability5.lazy("LocalModelResolver", () => import("./local-model-resolver-FFDAKOXN.mjs"));
2676
+ // src/hooks/useChatServices.ts
2677
+ import { useMemo as useMemo7 } from "react";
2678
+ import { useCapability } from "@dxos/app-framework/ui";
2679
+ import { getPersonalSpace } from "@dxos/app-toolkit";
2680
+ import { AutomationCapabilities } from "@dxos/plugin-automation/types";
2681
+ import { useClient } from "@dxos/react-client";
2682
+ var useChatServices = ({ id }) => {
2683
+ const client = useClient();
2684
+ id ??= getPersonalSpace(client)?.id;
2685
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
2686
+ return useMemo7(() => !id ? void 0 : runtimeResolver.getRuntime(id), [
2687
+ id
2688
+ ]);
2689
+ };
74
2690
 
75
- // src/capabilities/operation-resolver/index.ts
76
- import { Capability as Capability6 } from "@dxos/app-framework";
77
- var OperationResolver = Capability6.lazy("OperationResolver", () => import("./operation-resolver-2ZD2DXOU.mjs"));
2691
+ // src/hooks/useChatToolbarActions.ts
2692
+ import { Atom as Atom2 } from "@effect-atom/atom-react";
2693
+ import * as Effect3 from "effect/Effect";
2694
+ import { useMemo as useMemo8 } from "react";
2695
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
2696
+ import { Chat as Chat2 } from "@dxos/assistant-toolkit";
2697
+ import { Filter as Filter5, Obj as Obj6, Query } from "@dxos/echo";
2698
+ import { runAndForwardErrors as runAndForwardErrors3 } from "@dxos/effect";
2699
+ import { invariant } from "@dxos/invariant";
2700
+ import { useQuery as useQuery5 } from "@dxos/react-client/echo";
2701
+ import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
2702
+ import { useChatContext as useChatContext2 } from "#components";
2703
+ import { meta as meta8 } from "#meta";
2704
+ import { AssistantOperation } from "#operations";
2705
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
2706
+ var useChatToolbarActions2 = ({ chat, companionTo }) => {
2707
+ const { invoke } = useOperationInvoker();
2708
+ const { db } = useChatContext2("useChatToolbarActions");
2709
+ const query = companionTo ? Query.select(Filter5.id(companionTo.id)).targetOf(Chat2.CompanionTo).source() : Query.select(Filter5.nothing());
2710
+ const chats = useQuery5(db, query);
2711
+ return useMenuActions(useMemo8(() => {
2712
+ return Atom2.make(() => {
2713
+ const builder = MenuBuilder.make().root({
2714
+ label: [
2715
+ "chat-toolbar.title",
2716
+ {
2717
+ ns: meta8.id
2718
+ }
2719
+ ]
2720
+ }).action("new", {
2721
+ label: [
2722
+ "new-thread.button",
2723
+ {
2724
+ ns: meta8.id
2725
+ }
2726
+ ],
2727
+ icon: "ph--plus--regular",
2728
+ type: "new",
2729
+ disabled: !companionTo
2730
+ }, () => {
2731
+ invariant(companionTo, void 0, {
2732
+ F: __dxlog_file5,
2733
+ L: 53,
2734
+ S: void 0,
2735
+ A: [
2736
+ "companionTo",
2737
+ ""
2738
+ ]
2739
+ });
2740
+ return invoke(AssistantOperation.SetCurrentChat, {
2741
+ companionTo,
2742
+ chat: void 0
2743
+ }).pipe(runAndForwardErrors3);
2744
+ }).action("rename", {
2745
+ label: [
2746
+ "rename-thread.button",
2747
+ {
2748
+ ns: meta8.id
2749
+ }
2750
+ ],
2751
+ icon: "ph--magic-wand--regular",
2752
+ type: "rename",
2753
+ disabled: !chat
2754
+ }, () => Effect3.gen(function* () {
2755
+ invariant(chat, void 0, {
2756
+ F: __dxlog_file5,
2757
+ L: 70,
2758
+ S: this,
2759
+ A: [
2760
+ "chat",
2761
+ ""
2762
+ ]
2763
+ });
2764
+ yield* invoke(AssistantOperation.UpdateChatName, {
2765
+ chat
2766
+ });
2767
+ }).pipe(runAndForwardErrors3)).action("branch", {
2768
+ label: [
2769
+ "branch-thread.menu",
2770
+ {
2771
+ ns: meta8.id
2772
+ }
2773
+ ],
2774
+ icon: "ph--git-branch--regular",
2775
+ type: "branch",
2776
+ disabled: true
2777
+ }, () => {
2778
+ });
2779
+ if (chats.length > 0) {
2780
+ builder.group("chats", {
2781
+ label: [
2782
+ "chat-history.label",
2783
+ {
2784
+ ns: meta8.id
2785
+ }
2786
+ ],
2787
+ icon: "ph--clock-counter-clockwise--regular",
2788
+ selectCardinality: "single",
2789
+ variant: "dropdownMenu"
2790
+ }, (builder2) => {
2791
+ chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
2792
+ builder2.action(chat2.id, {
2793
+ label: Obj6.getLabel(chat2) ?? [
2794
+ "object-name.placeholder",
2795
+ {
2796
+ ns: Chat2.Chat.typename
2797
+ }
2798
+ ]
2799
+ }, () => Effect3.gen(function* () {
2800
+ invariant(companionTo, void 0, {
2801
+ F: __dxlog_file5,
2802
+ L: 106,
2803
+ S: this,
2804
+ A: [
2805
+ "companionTo",
2806
+ ""
2807
+ ]
2808
+ });
2809
+ yield* invoke(AssistantOperation.SetCurrentChat, {
2810
+ companionTo,
2811
+ chat: chat2
2812
+ });
2813
+ }).pipe(runAndForwardErrors3));
2814
+ });
2815
+ });
2816
+ }
2817
+ return builder.build();
2818
+ });
2819
+ }, [
2820
+ chats.length,
2821
+ db?.spaceId,
2822
+ companionTo?.id,
2823
+ chat?.id,
2824
+ invoke
2825
+ ]));
2826
+ };
78
2827
 
79
- // src/capabilities/react-surface/index.ts
80
- import { Capability as Capability7 } from "@dxos/app-framework";
81
- var ReactSurface = Capability7.lazy("ReactSurface", () => import("./react-surface-T4VMCCKZ.mjs"));
2828
+ // src/hooks/useContextBinder.ts
2829
+ import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
2830
+ import * as Effect4 from "effect/Effect";
2831
+ import { useContext as useContext2, useState as useState9 } from "react";
2832
+ import { AiContextBinder } from "@dxos/assistant";
2833
+ import { createFeedServiceLayer as createFeedServiceLayer2 } from "@dxos/echo-db";
2834
+ import { runAndForwardErrors as runAndForwardErrors4 } from "@dxos/effect";
2835
+ import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
2836
+ var useContextBinder = (space, feed) => {
2837
+ const registry = useContext2(RegistryContext2);
2838
+ const [binder, setBinder] = useState9();
2839
+ useAsyncEffect2(async () => {
2840
+ setBinder(void 0);
2841
+ if (!space || !feed) {
2842
+ return;
2843
+ }
2844
+ const feedServiceLayer = createFeedServiceLayer2(space.queues);
2845
+ const runtime3 = await runAndForwardErrors4(Effect4.runtime().pipe(Effect4.provide(feedServiceLayer)));
2846
+ const binder2 = new AiContextBinder({
2847
+ feed,
2848
+ runtime: runtime3,
2849
+ registry
2850
+ });
2851
+ await binder2.open();
2852
+ setBinder(binder2);
2853
+ return () => {
2854
+ void binder2.close();
2855
+ };
2856
+ }, [
2857
+ space,
2858
+ feed
2859
+ ]);
2860
+ return binder;
2861
+ };
82
2862
 
83
- // src/capabilities/repair/index.ts
84
- import { Capability as Capability8 } from "@dxos/app-framework";
85
- var Repair = Capability8.lazy("Repair", () => import("./repair-DMI55PON.mjs"));
2863
+ // src/hooks/useContextObjects.ts
2864
+ import { Atom as Atom3, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
2865
+ import { useCallback as useCallback6 } from "react";
2866
+ var emptyObjectsAtom = Atom3.make([]);
2867
+ var useContextObjects3 = ({ db, context }) => {
2868
+ const objects = useAtomValue2(context?.objects ?? emptyObjectsAtom);
2869
+ const handleUpdateObject = useCallback6(async (dxn, checked) => {
2870
+ if (!db || !context) {
2871
+ return;
2872
+ }
2873
+ const ref = db.makeRef(dxn);
2874
+ await ref.load();
2875
+ if (checked) {
2876
+ await context.bind({
2877
+ objects: [
2878
+ ref
2879
+ ]
2880
+ });
2881
+ } else {
2882
+ await context.unbind({
2883
+ objects: [
2884
+ ref
2885
+ ]
2886
+ });
2887
+ }
2888
+ }, [
2889
+ db,
2890
+ context
2891
+ ]);
2892
+ return {
2893
+ objects,
2894
+ onUpdateObject: handleUpdateObject
2895
+ };
2896
+ };
86
2897
 
87
- // src/capabilities/settings/index.ts
88
- import { Capability as Capability9 } from "@dxos/app-framework";
89
- var Settings = Capability9.lazy("Settings", () => import("./settings-NGGZA7S7.mjs"));
2898
+ // src/hooks/useFilteredTypes.ts
2899
+ import * as Option5 from "effect/Option";
2900
+ import { useEffect as useEffect7, useState as useState10 } from "react";
2901
+ import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
2902
+ var useFilteredTypes2 = (db) => {
2903
+ const [types, setTypes] = useState10([]);
2904
+ useEffect7(() => {
2905
+ if (!db) {
2906
+ return;
2907
+ }
2908
+ return db.schemaRegistry.query({
2909
+ location: [
2910
+ "database",
2911
+ "runtime"
2912
+ ]
2913
+ }).subscribe((query) => {
2914
+ const types2 = Array.from(new Set(query.results.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option5.getOrElse(() => false)))));
2915
+ setTypes(types2);
2916
+ }, {
2917
+ fire: true
2918
+ });
2919
+ }, [
2920
+ db
2921
+ ]);
2922
+ return types;
2923
+ };
90
2924
 
91
- // src/capabilities/state/index.ts
92
- import { Capability as Capability10 } from "@dxos/app-framework";
93
- var AssistantState = Capability10.lazy("AssistantState", () => import("./state-VSCPGN7R.mjs"));
2925
+ // src/hooks/useFlush.ts
2926
+ import { useCallback as useCallback7, useRef as useRef3, useState as useState11 } from "react";
2927
+ var useFlush = (space) => {
2928
+ const [state, setState] = useState11("idle");
2929
+ const resetTimer = useRef3(null);
2930
+ const handleFlush = useCallback7(() => {
2931
+ if (!space) {
2932
+ return;
2933
+ }
2934
+ queueMicrotask(async () => {
2935
+ if (resetTimer.current) {
2936
+ clearTimeout(resetTimer.current);
2937
+ }
2938
+ setState("flushing");
2939
+ await space.db.flush();
2940
+ setState("flushed");
2941
+ resetTimer.current = setTimeout(() => {
2942
+ setState("idle");
2943
+ resetTimer.current = null;
2944
+ }, 1e3);
2945
+ });
2946
+ }, [
2947
+ space
2948
+ ]);
2949
+ return {
2950
+ state,
2951
+ handleFlush
2952
+ };
2953
+ };
94
2954
 
95
- // src/capabilities/toolkit/index.ts
96
- import { Capability as Capability11 } from "@dxos/app-framework";
97
- var Toolkit = Capability11.lazy("Toolkit", () => import("./toolkit-JPRJRDDB.mjs"));
2955
+ // src/hooks/useOnline.ts
2956
+ import { useState as useState12 } from "react";
2957
+ var useOnline = () => {
2958
+ const [online, setOnline] = useState12(true);
2959
+ return [
2960
+ online,
2961
+ setOnline
2962
+ ];
2963
+ };
2964
+
2965
+ // src/hooks/usePresets.ts
2966
+ import { useCallback as useCallback8, useEffect as useEffect8, useMemo as useMemo9, useState as useState13 } from "react";
2967
+ var usePresets = (online) => {
2968
+ const [preset, setPreset] = useState13();
2969
+ const presets = useMemo9(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
2970
+ online
2971
+ ]);
2972
+ const presetOptions = useMemo9(() => presets.map(({ id, model, label }) => ({
2973
+ id,
2974
+ label: label ?? model
2975
+ })), [
2976
+ presets
2977
+ ]);
2978
+ useEffect8(() => {
2979
+ setPreset(presets[0]);
2980
+ }, [
2981
+ presets
2982
+ ]);
2983
+ const handlePresetChange = useCallback8((id) => {
2984
+ const preset2 = presets.find((preset3) => preset3.id === id);
2985
+ if (preset2) {
2986
+ setPreset(preset2);
2987
+ }
2988
+ }, [
2989
+ presets
2990
+ ]);
2991
+ return {
2992
+ preset,
2993
+ presets: presetOptions,
2994
+ onPresetChange: handlePresetChange
2995
+ };
2996
+ };
2997
+
2998
+ // src/hooks/useReferencesProvider.ts
2999
+ import { useMemo as useMemo10 } from "react";
3000
+ import { Filter as Filter6, Obj as Obj7 } from "@dxos/echo";
3001
+ var useReferencesProvider = (space) => {
3002
+ return useMemo10(() => {
3003
+ if (!space) {
3004
+ return void 0;
3005
+ }
3006
+ return {
3007
+ getReferences: async ({ query }) => {
3008
+ const objects = await space.db.query(Filter6.everything()).run();
3009
+ return objects.filter((object) => stringMatch(query, Obj7.getLabel(object) ?? "")).filter((object) => !!Obj7.getDXN(object)).map((object) => ({
3010
+ uri: Obj7.getDXN(object).toString(),
3011
+ label: Obj7.getLabel(object) ?? ""
3012
+ }));
3013
+ },
3014
+ resolveReference: async ({ uri }) => {
3015
+ const object = await space.db.query(Filter6.id(uri)).first();
3016
+ return {
3017
+ uri,
3018
+ label: Obj7.getLabel(object) ?? ""
3019
+ };
3020
+ }
3021
+ };
3022
+ }, [
3023
+ space
3024
+ ]);
3025
+ };
3026
+ var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
3027
+
3028
+ // src/meta.ts
3029
+ import { trim as trim2 } from "@dxos/util";
3030
+ var meta9 = {
3031
+ id: "org.dxos.plugin.assistant",
3032
+ name: "Assistant",
3033
+ description: trim2`
3034
+ Intelligent AI assistant that can analyze and interact with objects across your spaces.
3035
+ Chat naturally to get insights, search content, and perform actions using AI-powered context awareness.
3036
+ `,
3037
+ icon: "ph--sparkle--regular",
3038
+ iconHue: "sky",
3039
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-assistant",
3040
+ tags: [
3041
+ "labs"
3042
+ ]
3043
+ };
3044
+ var ASSISTANT_DIALOG = `${meta9.id}.assistant.dialog`;
3045
+ var ASSISTANT_COMPANION_VARIANT = "assistant-chat";
98
3046
 
99
3047
  // src/translations.ts
100
- import { Chat as Chat2, Initiative } from "@dxos/assistant-toolkit";
101
- import { Blueprint, Prompt } from "@dxos/blueprints";
3048
+ import { Chat as Chat3, Agent, McpServer as McpServer2 } from "@dxos/assistant-toolkit";
3049
+ import { Blueprint as Blueprint2, Prompt } from "@dxos/blueprints";
102
3050
  import { Sequence } from "@dxos/conductor";
103
- import { Type } from "@dxos/echo";
3051
+ import { Type as Type2 } from "@dxos/echo";
3052
+ import { translations as componentsTranslations } from "@dxos/react-ui-components";
3053
+ import { translations as formTranslations } from "@dxos/react-ui-form";
3054
+ import { meta as meta10 } from "#meta";
104
3055
  var translations = [
3056
+ ...componentsTranslations,
3057
+ ...formTranslations,
105
3058
  {
106
3059
  "en-US": {
107
3060
  // TODO(burdon): From assistant.
108
- [Blueprint.Blueprint.typename]: {
109
- "typename label": "Blueprint",
110
- "typename label_zero": "Blueprints",
111
- "typename label_one": "Blueprint",
112
- "typename label_other": "Blueprints",
113
- "object name placeholder": "New blueprint",
114
- "rename object label": "Rename blueprint",
115
- "delete object label": "Delete blueprint",
116
- "object deleted label": "Blueprint deleted"
3061
+ [Blueprint2.Blueprint.typename]: {
3062
+ "typename.label": "Blueprint",
3063
+ "typename.label_zero": "Blueprints",
3064
+ "typename.label_one": "Blueprint",
3065
+ "typename.label_other": "Blueprints",
3066
+ "object-name.placeholder": "New blueprint",
3067
+ "add-object.label": "Add blueprint",
3068
+ "rename-object.label": "Rename blueprint",
3069
+ "delete-object.label": "Delete blueprint",
3070
+ "object-deleted.label": "Blueprint deleted"
117
3071
  },
118
- [Type.getTypename(Prompt.Prompt)]: {
119
- "typename label": "Prompt",
120
- "typename label_zero": "Prompts",
121
- "typename label_one": "Prompt",
122
- "typename label_other": "Prompts",
123
- "object name placeholder": "New prompt",
124
- "rename object label": "Rename prompt",
125
- "delete object label": "Delete prompt",
126
- "object deleted label": "Prompt deleted"
3072
+ [Type2.getTypename(Prompt.Prompt)]: {
3073
+ "typename.label": "Prompt",
3074
+ "typename.label_zero": "Prompts",
3075
+ "typename.label_one": "Prompt",
3076
+ "typename.label_other": "Prompts",
3077
+ "object-name.placeholder": "New prompt",
3078
+ "add-object.label": "Add prompt",
3079
+ "rename-object.label": "Rename prompt",
3080
+ "delete-object.label": "Delete prompt",
3081
+ "object-deleted.label": "Prompt deleted"
127
3082
  },
128
3083
  // TODO(burdon): From conductor.
129
3084
  [Sequence.typename]: {
130
- "typename label": "Sequence",
131
- "typename label_zero": "Sequences",
132
- "typename label_one": "Sequence",
133
- "typename label_other": "Sequences",
134
- "object name placeholder": "New sequence",
135
- "rename object label": "Rename sequence",
136
- "delete object label": "Delete sequence",
137
- "object deleted label": "Sequence deleted"
3085
+ "typename.label": "Sequence",
3086
+ "typename.label_zero": "Sequences",
3087
+ "typename.label_one": "Sequence",
3088
+ "typename.label_other": "Sequences",
3089
+ "object-name.placeholder": "New sequence",
3090
+ "add-object.label": "Add sequence",
3091
+ "rename-object.label": "Rename sequence",
3092
+ "delete-object.label": "Delete sequence",
3093
+ "object-deleted.label": "Sequence deleted"
3094
+ },
3095
+ [Chat3.Chat.typename]: {
3096
+ "typename.label": "AI Chat",
3097
+ "object-name.placeholder": "New AI Chat",
3098
+ "add-object.label": "Add AI chat",
3099
+ "rename-object.label": "Rename AI Chat",
3100
+ "delete-object.label": "Delete AI Chat",
3101
+ "object-deleted.label": "AI Chat deleted"
138
3102
  },
139
- [Chat2.Chat.typename]: {
140
- "typename label": "AI Chat",
141
- "object name placeholder": "New AI Chat",
142
- "rename object label": "Rename AI Chat",
143
- "delete object label": "Delete AI Chat",
144
- "object deleted label": "AI Chat deleted"
3103
+ [McpServer2.McpServer.typename]: {
3104
+ "typename.label": "MCP Server",
3105
+ "typename.label_zero": "MCP Servers",
3106
+ "typename.label_one": "MCP Server",
3107
+ "typename.label_other": "MCP Servers"
145
3108
  },
146
- [Initiative.Initiative.typename]: {
147
- "typename label": "Initiative",
148
- "typename label_zero": "Initiatives",
149
- "typename label_one": "Initiative",
150
- "typename label_other": "Initiatives",
151
- "object name placeholder": "New initiative",
152
- "rename object label": "Rename initiative",
153
- "delete object label": "Delete initiative",
154
- "object deleted label": "Initiative deleted"
3109
+ [Agent.Agent.typename]: {
3110
+ "typename.label": "Agent",
3111
+ "typename.label_zero": "Agents",
3112
+ "typename.label_one": "Agent",
3113
+ "typename.label_other": "Agents",
3114
+ "object-name.placeholder": "New agent",
3115
+ "add-object.label": "Add agent",
3116
+ "rename-object.label": "Rename agent",
3117
+ "delete-object.label": "Delete agent",
3118
+ "object-deleted.label": "Agent deleted"
155
3119
  },
156
3120
  // TODO(burdon): Reconcile with react-ui-chat.
157
- [meta.id]: {
158
- "templates label": "Templates",
159
- "open ambient chat label": "Open Assistant",
160
- "assistant chat label": "Assistant",
161
- "plugin name": "Assistant",
162
- "settings title": "Assistant settings",
163
- "object placeholder": "New prompt",
164
- "create object label": "Create prompt",
165
- "create trigger label": "Create trigger",
166
- "create stack section label": "Create prompt",
167
- "command placeholder": "Enter slash command...",
168
- "template placeholder": "Enter template...",
169
- "value placeholder": "Enter value...",
170
- "prompt rules label": "Prompt Rules",
171
- "typename placeholder": "Enter typename of objects which this template is for",
172
- "description placeholder": "Enter description of when this template should be used",
173
- "select preset template placeholder": "Select preset",
174
- "service registry label": "Service Registry",
175
- "type filter placeholder": "Type",
176
- "any type filter label": "Any",
177
- "no blueprint message": "No active blueprints",
178
- "tool call label": "Calling tool...",
179
- "tool result label": "Success",
180
- "tool error label": "Tool call failed",
181
- "invocations label": "Invocations",
182
- "assistant dialog title": "Assistant",
183
- "open assistant label": "Open assistant",
184
- "reset blueprints label": "Reset blueprints",
185
- "no tools": "No tools are configured",
186
- "no results": "No results",
187
- "cancel button": "Cancel",
188
- "save button": "Save",
189
- "new thread button": "New Chat",
190
- "rename thread button": "Rename Chat",
191
- "chat history label": "Chat History",
192
- "chat update name label": "Update AI Chat name",
193
- "toolkit label": "Toolkit",
194
- "summary label": "Summary",
195
- "search placeholder": "Search...",
196
- "prompt placeholder": "Enter question or command...",
197
- "context objects button": "Add to context",
198
- "context settings button": "Chat settings",
199
- "microphone button": "Click to speak",
200
- "cancel processing button": "Stop processing",
201
- "blueprints in context title": "Blueprints",
202
- "objects in context title": "Content",
203
- "remove object in context label": "Remove document",
204
- "chat model title": "Model",
205
- "settings default label": "Default",
206
- "settings custom prompts label": "Use custom prompts",
207
- "settings llm provider label": "LLM provider",
208
- "settings edge llm model label": "Remote language model",
209
- "settings ollama llm model label": "Ollama language model",
3121
+ [meta10.id]: {
3122
+ "templates.label": "Templates",
3123
+ "open-ambient-chat.label": "Open Assistant",
3124
+ "assistant-chat.label": "Assistant",
3125
+ "plugin.name": "Assistant",
3126
+ "settings.title": "Assistant settings",
3127
+ "object.placeholder": "New prompt",
3128
+ "create-object.label": "Create prompt",
3129
+ "create-trigger.label": "Create trigger",
3130
+ "create-stack-section.label": "Create prompt",
3131
+ "command.placeholder": "Enter slash command...",
3132
+ "template.placeholder": "Enter template...",
3133
+ "value.placeholder": "Enter value...",
3134
+ "prompt-rules.label": "Prompt Rules",
3135
+ "typename.placeholder": "Enter typename of objects which this template is for",
3136
+ "description.placeholder": "Enter description of when this template should be used",
3137
+ "select-preset-template.placeholder": "Select preset",
3138
+ "service-registry.label": "Service Registry",
3139
+ "type-filter.placeholder": "Type",
3140
+ "any-type-filter.label": "Any",
3141
+ "no-blueprint.message": "No active blueprints",
3142
+ "tool-call.label": "Calling",
3143
+ "tool-result.label": "Success",
3144
+ "tool-error.label": "Tool call failed",
3145
+ "invocations.label": "Invocations",
3146
+ "trace.label": "Trace",
3147
+ "assistant-dialog.title": "Assistant",
3148
+ "open-assistant.label": "Open assistant",
3149
+ "reset-blueprints.label": "Reset blueprints",
3150
+ "no-results.message": "No results",
3151
+ "cancel.button": "Cancel",
3152
+ "save.button": "Save",
3153
+ "new-thread.button": "New Chat",
3154
+ "rename-thread.button": "Rename Chat",
3155
+ "chat-history.label": "Chat History",
3156
+ "chat-update-name.label": "Update AI Chat name",
3157
+ "toolkit.label": "Toolkit",
3158
+ "stats.label": "Stats",
3159
+ "summary.label": "Summary",
3160
+ "thinking.label": "Thinking",
3161
+ "search.placeholder": "Search...",
3162
+ "prompt.placeholder": "Enter question or command...",
3163
+ "context-objects.button": "Add to context",
3164
+ "context-settings.button": "Chat settings",
3165
+ "microphone.button": "Click to speak",
3166
+ "cancel-processing.button": "Stop processing",
3167
+ "blueprints-in-context.title": "Blueprints",
3168
+ "objects-in-context.title": "Content",
3169
+ "remove-object-in-context.label": "Remove document",
3170
+ "chat-model.title": "Models",
3171
+ "mcp-servers.title": "MCP",
3172
+ "mcp-server-add.label": "Add MCP server",
3173
+ "mcp-server-remove.label": "Remove MCP server",
3174
+ "mcp-server-name.label": "Server name",
3175
+ "mcp-server-name.placeholder": "Name",
3176
+ "mcp-server-url.label": "Server URL",
3177
+ "mcp-server-url.placeholder": "https://...",
3178
+ "mcp-server-protocol.label": "Protocol",
3179
+ "mcp-server-api-key.label": "API key",
3180
+ "mcp-server-api-key.placeholder": "API key (optional)",
3181
+ "debug.button": "Debug",
3182
+ "online-switch.label": "Online",
3183
+ "run-prompt.label": "Run prompt",
3184
+ "typename.label": "Typename",
3185
+ "branch-thread.menu": "Branch chat",
3186
+ "chat-toolbar.title": "Chat toolbar",
3187
+ "settings.default.label": "Default",
3188
+ "settings.custom-prompts.label": "Use custom prompts",
3189
+ "settings.custom-prompts.description": "Allow the assistant to use custom prompts defined in your spaces.",
3190
+ "settings.llm-provider.label": "LLM provider",
3191
+ "settings.llm-provider.description": "Select which language model service to use for AI responses.",
3192
+ "settings.edge-llm-model.label": "Remote language model",
3193
+ "settings.edge-llm-model.description": "Choose the remote language model used for AI requests.",
3194
+ "settings.ollama-llm-model.label": "Ollama language model",
3195
+ "settings.ollama-llm-model.description": "Choose the locally hosted Ollama model for AI requests.",
3196
+ "settings.default-llm-model.label": "Default language model",
210
3197
  // Trigger status
211
- "trigger status disabled label": "Triggers disabled",
212
- "trigger status idle label": "Triggers idle",
213
- "trigger status running label": "Trigger running",
214
- "trigger status error label": "Trigger error",
215
- "trigger runtime label": "Trigger Runtime",
216
- "trigger runtime description": "Enable automatic trigger execution",
217
- "trigger last invocation label": "Last run",
218
- "trigger duration label": "Duration"
3198
+ "trigger-status-disabled.label": "Triggers disabled",
3199
+ "trigger-status-idle.label": "Triggers idle",
3200
+ "trigger-status-edge.label": "Triggers will run on EDGE",
3201
+ "trigger-status-running.label": "Trigger running",
3202
+ "trigger-status-error.label": "Trigger error",
3203
+ "trigger-runtime.label": "Auto trigger execution",
3204
+ "trigger-last-invocation.label": "Last run",
3205
+ "trigger-duration.label": "Duration",
3206
+ // AgentArticle.
3207
+ "project-empty-spec.message": "Open the Properties companion to configure the agent.",
3208
+ "project-empty-spec.description": "Open the Assistant companion to interact with the agent.",
3209
+ "artifacts.label": "Artifacts",
3210
+ "input-queue.label": "Inputs",
3211
+ // AgentProperties.
3212
+ "instructions.label": "Instructions",
3213
+ "instructions.placeholder": "Enter instructions, goals, and constraints for the assistant.",
3214
+ "reset-history.button": "Reset",
3215
+ "subscriptions.label": "Subscriptions"
219
3216
  }
220
3217
  }
221
3218
  }
222
3219
  ];
223
3220
 
224
3221
  // src/AssistantPlugin.tsx
225
- import * as Effect from "effect/Effect";
226
- import { ActivationEvents, Capability as Capability12, Plugin } from "@dxos/app-framework";
3222
+ import * as Effect5 from "effect/Effect";
3223
+ import * as Option6 from "effect/Option";
3224
+ import { ActivationEvent, ActivationEvents, Capability, Plugin } from "@dxos/app-framework";
227
3225
  import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
228
- import { Chat as Chat3, Initiative as Initiative2, ResearchGraph } from "@dxos/assistant-toolkit";
229
- import { Blueprint as Blueprint2, Prompt as Prompt2 } from "@dxos/blueprints";
3226
+ import { ContextBinding } from "@dxos/assistant";
3227
+ import { Agent as Agent2, AgentBlueprint, Chat as Chat4, McpServer as McpServer3, Memory, Plan, ResearchGraph } from "@dxos/assistant-toolkit";
3228
+ import { Blueprint as Blueprint3, Prompt as Prompt2 } from "@dxos/blueprints";
230
3229
  import { Sequence as Sequence2 } from "@dxos/conductor";
231
- import { Obj, Type as Type2 } from "@dxos/echo";
232
- import { Operation } from "@dxos/operation";
233
- import { AutomationCapabilities } from "@dxos/plugin-automation/types";
3230
+ import { Annotation as Annotation3, Feed, Obj as Obj8, Type as Type3 } from "@dxos/echo";
3231
+ import { Operation as Operation3 } from "@dxos/operation";
3232
+ import { AutomationCapabilities as AutomationCapabilities2 } from "@dxos/plugin-automation/types";
234
3233
  import { ClientEvents } from "@dxos/plugin-client/types";
3234
+ import { DeckEvents } from "@dxos/plugin-deck/types";
3235
+ import { MarkdownEvents } from "@dxos/plugin-markdown";
3236
+ import { SpaceOperation } from "@dxos/plugin-space/operations";
235
3237
  import { SpaceCapabilities, SpaceEvents } from "@dxos/plugin-space/types";
236
- import { HasSubject } from "@dxos/types";
237
- var AssistantPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
3238
+ import { Text } from "@dxos/schema";
3239
+ import { HasSubject, Message as Message3 } from "@dxos/types";
3240
+ import { AiService, AppGraphBuilder, AssistantState, BlueprintDefinition, CompanionChatProvisioner, EdgeModelResolver, LocalModelResolver, MarkdownExtension, Migrations, OperationHandler, ReactSurface, Settings, Toolkit } from "#capabilities";
3241
+ import { meta as meta11 } from "#meta";
3242
+ import { AssistantOperation as AssistantOperation2 } from "#operations";
3243
+ import { AssistantEvents as AssistantEvents2 } from "#types";
3244
+ var AssistantPlugin = Plugin.define(meta11).pipe(AppPlugin.addAppGraphModule({
238
3245
  activate: AppGraphBuilder
239
3246
  }), AppPlugin.addBlueprintDefinitionModule({
240
3247
  activate: BlueprintDefinition
241
3248
  }), AppPlugin.addMetadataModule({
242
3249
  metadata: [
243
3250
  {
244
- id: Type2.getTypename(Chat3.Chat),
3251
+ id: Type3.getTypename(Chat4.Chat),
245
3252
  metadata: {
246
- icon: "ph--atom--regular",
247
- iconHue: "sky",
248
- createObject: (props) => Effect.sync(() => Chat3.make(props))
3253
+ icon: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option6.getOrThrow).icon,
3254
+ iconHue: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option6.getOrThrow).hue ?? "white",
3255
+ createObject: (props, options) => Effect5.gen(function* () {
3256
+ const { object } = yield* Operation3.invoke(AssistantOperation2.CreateChat, {
3257
+ db: options.db,
3258
+ name: props?.name
3259
+ });
3260
+ return yield* Operation3.invoke(SpaceOperation.AddObject, {
3261
+ object,
3262
+ target: options.target,
3263
+ hidden: true,
3264
+ targetNodeId: options.targetNodeId
3265
+ });
3266
+ })
249
3267
  }
250
3268
  },
251
3269
  {
252
- id: Type2.getTypename(Blueprint2.Blueprint),
3270
+ id: Type3.getTypename(Blueprint3.Blueprint),
253
3271
  metadata: {
254
- icon: "ph--blueprint--regular",
255
- iconHue: "sky",
256
- inputSchema: AssistantOperation.BlueprintForm,
257
- createObject: (props) => Effect.sync(() => Blueprint2.make(props))
3272
+ icon: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option6.getOrThrow).icon,
3273
+ iconHue: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option6.getOrThrow).hue ?? "white",
3274
+ inputSchema: AssistantOperation2.BlueprintForm,
3275
+ createObject: (props, options) => Effect5.gen(function* () {
3276
+ const object = Blueprint3.make(props);
3277
+ return yield* Operation3.invoke(SpaceOperation.AddObject, {
3278
+ object,
3279
+ target: options.target,
3280
+ hidden: true,
3281
+ targetNodeId: options.targetNodeId
3282
+ });
3283
+ })
258
3284
  }
259
3285
  },
260
3286
  {
261
- id: Type2.getTypename(Prompt2.Prompt),
3287
+ id: Type3.getTypename(Prompt2.Prompt),
262
3288
  metadata: {
263
- icon: "ph--scroll--regular",
264
- iconHue: "sky",
265
- createObject: (props) => Effect.sync(() => Prompt2.make(props))
3289
+ icon: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option6.getOrThrow).icon,
3290
+ iconHue: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option6.getOrThrow).hue ?? "white",
3291
+ createObject: (props, options) => Effect5.gen(function* () {
3292
+ const object = Prompt2.make(props);
3293
+ return yield* Operation3.invoke(SpaceOperation.AddObject, {
3294
+ object,
3295
+ target: options.target,
3296
+ hidden: true,
3297
+ targetNodeId: options.targetNodeId
3298
+ });
3299
+ })
266
3300
  }
267
3301
  },
268
3302
  {
269
- id: Type2.getTypename(Sequence2),
3303
+ id: Type3.getTypename(Sequence2),
270
3304
  metadata: {
271
- icon: "ph--circuitry--regular",
272
- iconHue: "sky",
273
- createObject: (props) => Effect.sync(() => Obj.make(Sequence2, props)),
274
- addToCollectionOnCreate: true
3305
+ icon: Annotation3.IconAnnotation.get(Sequence2).pipe(Option6.getOrThrow).icon,
3306
+ iconHue: Annotation3.IconAnnotation.get(Sequence2).pipe(Option6.getOrThrow).hue ?? "white",
3307
+ createObject: (props, options) => Effect5.gen(function* () {
3308
+ const object = Obj8.make(Sequence2, props);
3309
+ return yield* Operation3.invoke(SpaceOperation.AddObject, {
3310
+ object,
3311
+ target: options.target,
3312
+ hidden: true,
3313
+ targetNodeId: options.targetNodeId
3314
+ });
3315
+ })
275
3316
  }
276
3317
  },
277
3318
  {
278
- id: Type2.getTypename(Initiative2.Initiative),
3319
+ id: Type3.getTypename(Agent2.Agent),
279
3320
  metadata: {
280
- icon: "ph--circuitry--regular",
281
- iconHue: "sky",
282
- createObject: (_, { db }) => Initiative2.makeInitialized({
283
- name: "New Initiative",
284
- spec: "Not specified yet"
285
- }, Initiative2.makeBlueprint()).pipe(withComputeRuntime(db.spaceId)),
286
- addToCollectionOnCreate: true
3321
+ icon: Annotation3.IconAnnotation.get(Agent2.Agent).pipe(Option6.getOrThrow).icon,
3322
+ iconHue: Annotation3.IconAnnotation.get(Agent2.Agent).pipe(Option6.getOrThrow).hue ?? "white",
3323
+ createObject: (props, options) => Effect5.gen(function* () {
3324
+ const object = yield* Agent2.makeInitialized({
3325
+ name: "",
3326
+ instructions: ""
3327
+ }, AgentBlueprint.make()).pipe(withComputeRuntime(options.db.spaceId));
3328
+ return yield* Operation3.invoke(SpaceOperation.AddObject, {
3329
+ object,
3330
+ target: options.target,
3331
+ hidden: true,
3332
+ targetNodeId: options.targetNodeId
3333
+ });
3334
+ })
287
3335
  }
288
3336
  }
289
3337
  ]
290
- }), AppPlugin.addOperationResolverModule({
291
- activate: OperationResolver
3338
+ }), AppPlugin.addOperationHandlerModule({
3339
+ activate: OperationHandler
292
3340
  }), AppPlugin.addSchemaModule({
293
3341
  schema: [
294
- Chat3.Chat,
295
- Chat3.CompanionTo,
296
- Blueprint2.Blueprint,
3342
+ Chat4.Chat,
3343
+ Chat4.CompanionTo,
3344
+ Blueprint3.Blueprint,
3345
+ ContextBinding,
3346
+ Feed.Feed,
297
3347
  HasSubject.HasSubject,
3348
+ Message3.Message,
298
3349
  Prompt2.Prompt,
299
- ResearchGraph,
300
- Initiative2.Initiative,
301
- Initiative2.Plan,
302
- Sequence2
3350
+ ResearchGraph.ResearchGraph,
3351
+ Agent2.Agent,
3352
+ McpServer3.McpServer,
3353
+ Plan.Plan,
3354
+ Sequence2,
3355
+ Memory.Memory,
3356
+ Text.Text
303
3357
  ]
304
3358
  }), AppPlugin.addSettingsModule({
305
3359
  activate: Settings
306
3360
  }), AppPlugin.addSurfaceModule({
307
3361
  activate: ReactSurface,
308
- activatesBefore: [
3362
+ firesBeforeActivation: [
309
3363
  AppActivationEvents.SetupArtifactDefinition
310
3364
  ]
311
3365
  }), AppPlugin.addTranslationsModule({
312
3366
  translations
3367
+ }), Plugin.addModule({
3368
+ id: "markdown",
3369
+ activatesOn: MarkdownEvents.SetupExtensions,
3370
+ activate: MarkdownExtension
313
3371
  }), Plugin.addModule({
314
3372
  // TODO(wittjosiah): Does not integrate with settings store.
315
3373
  // Should this be a different event?
@@ -319,19 +3377,16 @@ var AssistantPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
319
3377
  }), Plugin.addModule({
320
3378
  id: "on-space-created",
321
3379
  activatesOn: SpaceEvents.SpaceCreated,
322
- activate: () => Effect.succeed(Capability12.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation.invoke(AssistantOperation.OnCreateSpace, params)))
323
- }), Plugin.addModule({
324
- activatesOn: ClientEvents.SpacesReady,
325
- activate: Repair
3380
+ activate: () => Effect5.succeed(Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation3.invoke(AssistantOperation2.OnCreateSpace, params)))
326
3381
  }), Plugin.addModule({
327
- activatesOn: AssistantEvents.SetupAiServiceProviders,
3382
+ activatesOn: AssistantEvents2.SetupAiServiceProviders,
328
3383
  activate: EdgeModelResolver
329
3384
  }), Plugin.addModule({
330
- activatesOn: AssistantEvents.SetupAiServiceProviders,
3385
+ activatesOn: AssistantEvents2.SetupAiServiceProviders,
331
3386
  activate: LocalModelResolver
332
3387
  }), Plugin.addModule({
333
- activatesBefore: [
334
- AssistantEvents.SetupAiServiceProviders
3388
+ firesBeforeActivation: [
3389
+ AssistantEvents2.SetupAiServiceProviders
335
3390
  ],
336
3391
  // TODO(dmaretskyi): This should activate lazily when the AI chat is used.
337
3392
  activatesOn: ActivationEvents.Startup,
@@ -340,61 +3395,50 @@ var AssistantPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
340
3395
  // TODO(wittjosiah): Use a different event.
341
3396
  activatesOn: ActivationEvents.Startup,
342
3397
  activate: Toolkit
3398
+ }), Plugin.addModule({
3399
+ activatesOn: ActivationEvent.allOf(ActivationEvents.OperationInvokerReady, AppActivationEvents.AppGraphReady, DeckEvents.StateReady),
3400
+ activate: CompanionChatProvisioner
3401
+ }), Plugin.addModule({
3402
+ activatesOn: ClientEvents.SetupMigration,
3403
+ activate: Migrations
343
3404
  }), Plugin.make);
344
- var withComputeRuntime = (spaceId) => (effect) => Effect.gen(function* () {
345
- const provider = yield* Capability12.get(AutomationCapabilities.ComputeRuntime).pipe(Effect.orDie);
346
- const runtime = yield* provider.getRuntime(spaceId).runtimeEffect;
347
- return yield* effect.pipe(Effect.provide(runtime));
3405
+ var withComputeRuntime = (spaceId) => (effect) => Effect5.gen(function* () {
3406
+ const provider = yield* Capability.get(AutomationCapabilities2.ComputeRuntime).pipe(Effect5.orDie);
3407
+ const runtime3 = yield* provider.getRuntime(spaceId).runtimeEffect;
3408
+ return yield* effect.pipe(Effect5.provide(runtime3));
348
3409
  });
349
3410
  export {
3411
+ ASSISTANT_COMPANION_VARIANT,
350
3412
  ASSISTANT_DIALOG,
351
- AiService,
352
3413
  ApiAuthorization,
353
- AppGraphBuilder,
354
3414
  Assistant_exports as Assistant,
355
- assistant_blueprint_exports as AssistantBlueprint,
3415
+ blueprint_default as AssistantBlueprint,
356
3416
  AssistantCapabilities,
357
3417
  AssistantEvents,
358
- AssistantOperation,
359
3418
  AssistantPlugin,
360
3419
  AssistantSettings,
361
- AssistantState,
362
- BlueprintArticle,
363
- BlueprintDefinition,
364
3420
  Chat,
365
- ChatCompanion,
366
- ChatContainer,
367
3421
  ChatContextProvider,
368
- ChatDialog,
369
- EdgeModelResolver,
370
- InitiativeContainer,
371
3422
  LLM_PROVIDERS,
372
- LocalModelResolver,
373
- OperationResolver,
374
- PromptArticle,
375
- ReactSurface,
376
- Repair,
3423
+ ProcessTree,
377
3424
  ServiceType,
378
- Settings,
379
3425
  TemplateEditor,
380
3426
  Toolbox,
381
- ToolboxContainer,
382
- Toolkit,
383
- TriggerStatus,
3427
+ ToolboxPanel,
384
3428
  categoryIcons,
385
- meta,
3429
+ meta9 as meta,
386
3430
  translations,
387
- useActiveBlueprints,
388
- useBlueprintHandlers,
3431
+ useActiveBlueprints2 as useActiveBlueprints,
3432
+ useBlueprintHandlers2 as useBlueprintHandlers,
389
3433
  useBlueprintRegistry,
390
- useBlueprints,
3434
+ useBlueprints2 as useBlueprints,
391
3435
  useChatContext,
392
3436
  useChatProcessor,
393
3437
  useChatServices,
394
- useChatToolbarActions,
3438
+ useChatToolbarActions2 as useChatToolbarActions,
395
3439
  useContextBinder,
396
- useContextObjects,
397
- useFilteredTypes,
3440
+ useContextObjects3 as useContextObjects,
3441
+ useFilteredTypes2 as useFilteredTypes,
398
3442
  useFlush,
399
3443
  useOnline,
400
3444
  usePresets,