@dxos/plugin-assistant 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934

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