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