@dxos/plugin-assistant 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

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