@dxos/plugin-assistant 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (627) hide show
  1. package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs +97 -0
  2. package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs.map +7 -0
  3. package/dist/lib/browser/blueprints/index.mjs +8 -0
  4. package/dist/lib/browser/chunk-ATHYBVGN.mjs +176 -0
  5. package/dist/lib/browser/chunk-ATHYBVGN.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-EZRS3J25.mjs +30 -0
  7. package/dist/lib/browser/chunk-EZRS3J25.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-LMVTXH54.mjs +154 -0
  9. package/dist/lib/browser/chunk-LMVTXH54.mjs.map +7 -0
  10. package/dist/lib/browser/cli/index.mjs +74 -0
  11. package/dist/lib/browser/cli/index.mjs.map +7 -0
  12. package/dist/lib/browser/create-chat-LBZHGVSN.mjs +82 -0
  13. package/dist/lib/browser/create-chat-LBZHGVSN.mjs.map +7 -0
  14. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs +65 -0
  15. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +3388 -308
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/on-create-space-54RNX5JI.mjs +22 -0
  20. package/dist/lib/browser/on-create-space-54RNX5JI.mjs.map +7 -0
  21. package/dist/lib/browser/operations/index.mjs +13 -0
  22. package/dist/lib/browser/operations/index.mjs.map +7 -0
  23. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs +22 -0
  24. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs.map +7 -0
  25. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs +136 -0
  26. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs.map +7 -0
  27. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs +54 -0
  28. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs.map +7 -0
  29. package/dist/lib/browser/types/index.mjs +5 -4
  30. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs +71 -0
  31. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs.map +7 -0
  32. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs +98 -0
  33. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs.map +7 -0
  34. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  35. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +32 -0
  36. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs +177 -0
  38. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs +155 -0
  40. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs.map +7 -0
  41. package/dist/lib/node-esm/cli/index.mjs +75 -0
  42. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  43. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs +83 -0
  44. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs.map +7 -0
  45. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs +66 -0
  46. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs.map +7 -0
  47. package/dist/lib/node-esm/index.mjs +3388 -308
  48. package/dist/lib/node-esm/index.mjs.map +4 -4
  49. package/dist/lib/node-esm/meta.json +1 -1
  50. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs +23 -0
  51. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs.map +7 -0
  52. package/dist/lib/node-esm/operations/index.mjs +14 -0
  53. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  54. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs +23 -0
  55. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs.map +7 -0
  56. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs +137 -0
  57. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs.map +7 -0
  58. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs +55 -0
  59. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs.map +7 -0
  60. package/dist/lib/node-esm/types/index.mjs +5 -4
  61. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs +72 -0
  62. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs.map +7 -0
  63. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  64. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  65. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  66. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  67. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  68. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  69. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  70. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  71. package/dist/types/src/blueprints/index.d.ts +2 -0
  72. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  73. package/dist/types/src/capabilities/ai-service.d.ts +4 -2
  74. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  76. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  77. package/dist/types/src/capabilities/blueprint-definition.d.ts +4 -6
  78. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  79. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
  80. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/edge-model-resolver.d.ts +6 -3
  82. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
  83. package/dist/types/src/capabilities/index.d.ts +29 -12
  84. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  85. package/dist/types/src/capabilities/local-model-resolver.d.ts +9 -3
  86. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/markdown.d.ts +5 -0
  88. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/migrations.d.ts +5 -0
  90. package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  92. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  94. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/settings.d.ts +4 -2
  96. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/state.d.ts +19 -2
  98. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/toolkit.d.ts +4 -2
  100. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
  101. package/dist/types/src/cli/index.d.ts +2 -0
  102. package/dist/types/src/cli/index.d.ts.map +1 -0
  103. package/dist/types/src/cli/plugin.d.ts +10 -0
  104. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  105. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -4
  106. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  107. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -0
  108. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
  109. package/dist/types/src/components/AssistantSettings/index.d.ts +1 -1
  110. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
  111. package/dist/types/src/components/Chat/Chat.d.ts +28 -15
  112. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  113. package/dist/types/src/components/Chat/events.d.ts +5 -1
  114. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  115. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +6 -3
  116. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
  117. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +2 -1
  118. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  119. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +5 -3
  120. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  121. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
  122. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
  123. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
  124. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  125. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts +14 -0
  126. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts.map +1 -0
  127. package/dist/types/src/components/ChatThread/ChatThread.d.ts +7 -10
  128. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  129. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +15 -262
  130. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts +42 -0
  132. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
  133. package/dist/types/src/components/ChatThread/registry.d.ts +1 -1
  134. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
  135. package/dist/types/src/components/ChatThread/sync.d.ts +50 -17
  136. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  137. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
  138. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
  139. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
  140. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
  141. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
  142. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
  143. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts +15 -0
  144. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts.map +1 -0
  145. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
  146. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
  147. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts +18 -0
  148. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
  150. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
  151. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
  152. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
  153. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
  154. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
  155. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +25 -0
  156. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -0
  157. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
  158. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
  159. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
  160. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
  161. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
  162. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
  163. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts +15 -0
  164. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
  165. package/dist/types/src/components/ChatThread/widgets/index.d.ts +11 -0
  166. package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
  167. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +10 -0
  168. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
  169. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
  170. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
  171. package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
  172. package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
  173. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +6 -4
  174. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  175. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +1 -250
  176. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  177. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +11 -1
  178. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  179. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +2 -251
  180. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  181. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  182. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  183. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  184. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  185. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  186. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +6 -13
  187. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  188. package/dist/types/src/components/Toolbox/Toolbox.d.ts +13 -12
  189. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  190. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -249
  191. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  192. package/dist/types/src/components/index.d.ts +3 -11
  193. package/dist/types/src/components/index.d.ts.map +1 -1
  194. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
  195. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
  196. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
  197. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
  198. package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
  199. package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
  200. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
  201. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
  202. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
  203. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
  204. package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
  205. package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
  206. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  207. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  208. package/dist/types/src/containers/BlueprintArticle/index.d.ts +2 -0
  209. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  210. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +18 -0
  211. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  212. package/dist/types/src/containers/ChatCompanion/index.d.ts +2 -0
  213. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  214. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +12 -0
  215. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  216. package/dist/types/src/containers/ChatContainer/index.d.ts +2 -0
  217. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  218. package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
  219. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  220. package/dist/types/src/containers/ChatDialog/index.d.ts +2 -0
  221. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  222. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
  223. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
  224. package/dist/types/src/containers/PromptArticle/index.d.ts +2 -0
  225. package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
  226. package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
  227. package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
  228. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +21 -0
  229. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
  230. package/dist/types/src/containers/PromptList/index.d.ts +2 -0
  231. package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
  232. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +7 -0
  233. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  234. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +16 -0
  235. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -0
  236. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  237. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  238. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  239. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  240. package/dist/types/src/containers/TracePanel/execution-graph.d.ts +17 -0
  241. package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
  242. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  243. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  244. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +5 -0
  245. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  246. package/dist/types/src/containers/TriggerStatus/index.d.ts +2 -0
  247. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  248. package/dist/types/src/containers/index.d.ts +12 -0
  249. package/dist/types/src/containers/index.d.ts.map +1 -0
  250. package/dist/types/src/extensions/index.d.ts +2 -0
  251. package/dist/types/src/extensions/index.d.ts.map +1 -0
  252. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  253. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  254. package/dist/types/src/hooks/index.d.ts +2 -1
  255. package/dist/types/src/hooks/index.d.ts.map +1 -1
  256. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -5
  257. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  258. package/dist/types/src/hooks/useChatProcessor.d.ts +9 -6
  259. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  260. package/dist/types/src/hooks/useChatServices.d.ts +5 -8
  261. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  262. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  263. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  264. package/dist/types/src/hooks/useContextBinder.d.ts +3 -2
  265. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  266. package/dist/types/src/hooks/useContextObjects.d.ts +7 -7
  267. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
  268. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  269. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  270. package/dist/types/src/hooks/usePresets.d.ts +1 -1
  271. package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
  272. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  273. package/dist/types/src/index.d.ts +1 -2
  274. package/dist/types/src/index.d.ts.map +1 -1
  275. package/dist/types/src/meta.d.ts +4 -2
  276. package/dist/types/src/meta.d.ts.map +1 -1
  277. package/dist/types/src/operations/create-chat.d.ts +5 -0
  278. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  279. package/dist/types/src/operations/definitions.d.ts +135 -0
  280. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  281. package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
  282. package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
  283. package/dist/types/src/operations/index.d.ts +4 -0
  284. package/dist/types/src/operations/index.d.ts.map +1 -0
  285. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  286. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  287. package/dist/types/src/operations/prompt.test.d.ts +2 -0
  288. package/dist/types/src/operations/prompt.test.d.ts.map +1 -0
  289. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  290. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  291. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  292. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  293. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  294. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  295. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  296. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  297. package/dist/types/src/processor/presets.d.ts +1 -1
  298. package/dist/types/src/processor/presets.d.ts.map +1 -1
  299. package/dist/types/src/processor/processor.d.ts +41 -35
  300. package/dist/types/src/processor/processor.d.ts.map +1 -1
  301. package/dist/types/src/queue-logger.d.ts.map +1 -1
  302. package/dist/types/src/testing/test-generator.d.ts +5 -4
  303. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  304. package/dist/types/src/testing/test-generator.test.d.ts +2 -0
  305. package/dist/types/src/testing/test-generator.test.d.ts.map +1 -0
  306. package/dist/types/src/testing/test-services.d.ts +1 -1
  307. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  308. package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
  309. package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
  310. package/dist/types/src/translations.d.ts +2 -87
  311. package/dist/types/src/translations.d.ts.map +1 -1
  312. package/dist/types/src/types/Assistant.d.ts +18 -49
  313. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  314. package/dist/types/src/types/Settings.d.ts +11 -0
  315. package/dist/types/src/types/Settings.d.ts.map +1 -0
  316. package/dist/types/src/types/capabilities.d.ts +32 -0
  317. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  318. package/dist/types/src/types/events.d.ts +5 -0
  319. package/dist/types/src/types/events.d.ts.map +1 -0
  320. package/dist/types/src/types/index.d.ts +3 -1
  321. package/dist/types/src/types/index.d.ts.map +1 -1
  322. package/dist/types/src/types/service.d.ts +10 -212
  323. package/dist/types/src/types/service.d.ts.map +1 -1
  324. package/dist/types/tsconfig.tsbuildinfo +1 -1
  325. package/package.json +144 -98
  326. package/src/AssistantPlugin.tsx +190 -119
  327. package/src/blueprints/assistant/blueprint.test.ts +46 -0
  328. package/src/blueprints/assistant/blueprint.ts +31 -0
  329. package/src/blueprints/assistant/index.ts +5 -0
  330. package/src/{components/Toolbar → blueprints}/index.ts +1 -1
  331. package/src/capabilities/ai-service.ts +20 -17
  332. package/src/capabilities/app-graph-builder.ts +143 -144
  333. package/src/capabilities/blueprint-definition.ts +49 -55
  334. package/src/capabilities/companion-chat-provisioner.ts +164 -0
  335. package/src/capabilities/edge-model-resolver.ts +22 -14
  336. package/src/capabilities/index.ts +21 -14
  337. package/src/capabilities/local-model-resolver.ts +31 -13
  338. package/src/capabilities/markdown.ts +40 -0
  339. package/src/capabilities/migrations.ts +35 -0
  340. package/src/capabilities/operation-handler.ts +16 -0
  341. package/src/capabilities/react-surface.tsx +147 -77
  342. package/src/capabilities/settings.ts +24 -12
  343. package/src/capabilities/state.ts +27 -12
  344. package/src/capabilities/toolkit.ts +6 -161
  345. package/src/cli/index.ts +5 -0
  346. package/src/cli/plugin.ts +84 -0
  347. package/src/components/AssistantSettings/AssistantSettings.stories.tsx +34 -0
  348. package/src/components/AssistantSettings/AssistantSettings.tsx +105 -85
  349. package/src/components/AssistantSettings/index.ts +2 -2
  350. package/src/components/Chat/Chat.tsx +225 -147
  351. package/src/components/Chat/events.ts +7 -1
  352. package/src/components/ChatProgress/ChatProgress.tsx +11 -22
  353. package/src/components/ChatPrompt/ChatActions.tsx +26 -8
  354. package/src/components/ChatPrompt/ChatOptions.stories.tsx +122 -0
  355. package/src/components/ChatPrompt/ChatOptions.tsx +272 -93
  356. package/src/components/ChatPrompt/ChatReferences.tsx +23 -14
  357. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
  358. package/src/components/ChatThread/Anchor.stories.tsx +95 -0
  359. package/src/components/ChatThread/ChatThread.stories.tsx +76 -62
  360. package/src/components/ChatThread/ChatThread.tsx +47 -44
  361. package/src/components/ChatThread/Link.tsx +4 -4
  362. package/src/components/ChatThread/MarkdownStream.stories.tsx +280 -0
  363. package/src/components/ChatThread/registry.tsx +132 -69
  364. package/src/components/ChatThread/sync.test.ts +130 -20
  365. package/src/components/ChatThread/sync.ts +104 -67
  366. package/src/components/ChatThread/testing/reasoning.md +25 -0
  367. package/src/components/ChatThread/testing/thinking.md +21 -0
  368. package/src/components/ChatThread/testing/thread-1.md +30 -0
  369. package/src/components/ChatThread/testing/thread-2.md +56 -0
  370. package/src/components/ChatThread/testing/thread-widgets.md +79 -0
  371. package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
  372. package/src/components/ChatThread/tool-widget-state.ts +48 -0
  373. package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
  374. package/src/components/ChatThread/widgets/PromptWidget.ts +30 -0
  375. package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
  376. package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
  377. package/src/components/ChatThread/widgets/ReferenceWidget.ts +31 -0
  378. package/src/components/ChatThread/widgets/SelectWidget.ts +37 -0
  379. package/src/components/ChatThread/widgets/StatsWidget.ts +29 -0
  380. package/src/components/ChatThread/widgets/StatusWidget.ts +131 -0
  381. package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
  382. package/src/components/ChatThread/widgets/SummaryWidget.tsx +28 -0
  383. package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +54 -0
  384. package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
  385. package/src/components/ChatThread/widgets/index.ts +14 -0
  386. package/src/components/ProcessTree/ProcessTree.stories.tsx +109 -0
  387. package/src/components/ProcessTree/ProcessTree.tsx +86 -0
  388. package/src/components/ProcessTree/index.ts +5 -0
  389. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +18 -13
  390. package/src/components/TemplateEditor/TemplateEditor.tsx +59 -39
  391. package/src/components/TemplateEditor/TemplateForm.stories.tsx +20 -11
  392. package/src/components/TemplateEditor/TemplateForm.tsx +83 -37
  393. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  394. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  395. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  396. package/src/components/ToolBlock/ToolBlock.tsx +46 -54
  397. package/src/components/Toolbox/Toolbox.stories.tsx +11 -14
  398. package/src/components/Toolbox/Toolbox.tsx +70 -65
  399. package/src/components/index.ts +3 -10
  400. package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
  401. package/src/containers/AgentArticle/AgentArticle.tsx +200 -0
  402. package/src/containers/AgentArticle/index.ts +5 -0
  403. package/src/containers/AgentProperties/AgentProperties.stories.tsx +100 -0
  404. package/src/containers/AgentProperties/AgentProperties.tsx +127 -0
  405. package/src/containers/AgentProperties/index.ts +5 -0
  406. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
  407. package/src/containers/BlueprintArticle/index.ts +5 -0
  408. package/src/containers/ChatCompanion/ChatCompanion.tsx +142 -0
  409. package/src/containers/ChatCompanion/index.ts +5 -0
  410. package/src/containers/ChatContainer/ChatContainer.tsx +95 -0
  411. package/src/containers/ChatContainer/index.ts +5 -0
  412. package/src/{components → containers/ChatDialog}/ChatDialog.tsx +19 -15
  413. package/src/containers/ChatDialog/index.ts +5 -0
  414. package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
  415. package/src/containers/PromptArticle/index.ts +5 -0
  416. package/src/containers/PromptList/PromptList.stories.tsx +129 -0
  417. package/src/containers/PromptList/PromptList.tsx +49 -0
  418. package/src/containers/PromptList/index.ts +5 -0
  419. package/src/containers/TracePanel/TracePanel.stories.tsx +272 -0
  420. package/src/containers/TracePanel/TracePanel.tsx +113 -0
  421. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  422. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  423. package/src/containers/TracePanel/execution-graph.ts +452 -0
  424. package/src/containers/TracePanel/index.ts +9 -0
  425. package/src/containers/TriggerStatus/TriggerStatus.tsx +129 -0
  426. package/src/containers/TriggerStatus/index.ts +5 -0
  427. package/src/containers/index.ts +16 -0
  428. package/src/extensions/index.ts +5 -0
  429. package/src/extensions/prompt-extension.ts +111 -0
  430. package/src/hooks/index.ts +2 -1
  431. package/src/hooks/useBlueprintRegistry.ts +36 -21
  432. package/src/hooks/useChatProcessor.ts +44 -28
  433. package/src/hooks/useChatServices.ts +10 -33
  434. package/src/hooks/useChatToolbarActions.ts +122 -0
  435. package/src/hooks/useContextBinder.ts +20 -7
  436. package/src/hooks/useContextObjects.ts +16 -24
  437. package/src/hooks/useFilteredTypes.ts +37 -0
  438. package/src/hooks/usePresets.ts +2 -1
  439. package/src/hooks/useReferencesProvider.ts +5 -8
  440. package/src/index.ts +1 -2
  441. package/src/meta.ts +14 -6
  442. package/src/operations/create-chat.ts +80 -0
  443. package/src/operations/definitions.ts +127 -0
  444. package/src/operations/ensure-companion-chat.ts +61 -0
  445. package/src/operations/index.ts +17 -0
  446. package/src/operations/on-create-space.ts +24 -0
  447. package/src/operations/prompt.test.ts +79 -0
  448. package/src/operations/resolve-navigation-targets.ts +26 -0
  449. package/src/operations/run-prompt-in-new-chat.ts +113 -0
  450. package/src/operations/set-current-chat.ts +50 -0
  451. package/src/operations/update-chat-name.ts +61 -0
  452. package/src/processor/presets.ts +12 -4
  453. package/src/processor/processor.test.ts +20 -61
  454. package/src/processor/processor.ts +200 -181
  455. package/src/queue-logger.ts +24 -14
  456. package/src/testing/data/trace-timeline.dx.json +2120 -0
  457. package/src/testing/test-generator.test.ts +81 -0
  458. package/src/testing/test-generator.ts +86 -48
  459. package/src/testing/test-sequence.ts +3 -3
  460. package/src/testing/test-services.ts +9 -7
  461. package/src/testing/trace-timeline.conversations.json +1 -0
  462. package/src/testing/trace-timeline.test.ts +246 -0
  463. package/src/translations.ts +161 -77
  464. package/src/types/Assistant.ts +8 -58
  465. package/src/types/Settings.ts +21 -0
  466. package/src/types/capabilities.ts +35 -0
  467. package/src/types/events.ts +11 -0
  468. package/src/types/index.ts +5 -1
  469. package/src/types/service.ts +14 -11
  470. package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs +0 -28
  471. package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs.map +0 -7
  472. package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs +0 -150
  473. package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +0 -7
  474. package/dist/lib/browser/ChatContainer-RYGNN73X.mjs +0 -73
  475. package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +0 -7
  476. package/dist/lib/browser/ChatDialog-MVHH2U66.mjs +0 -86
  477. package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +0 -7
  478. package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs +0 -150
  479. package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +0 -7
  480. package/dist/lib/browser/ai-service-ERTZBTP3.mjs +0 -19
  481. package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +0 -7
  482. package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs +0 -154
  483. package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +0 -7
  484. package/dist/lib/browser/blueprint-definition-NSJARW5U.mjs +0 -12
  485. package/dist/lib/browser/chunk-2CE2KPKZ.mjs +0 -175
  486. package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +0 -7
  487. package/dist/lib/browser/chunk-43I2LR6O.mjs +0 -216
  488. package/dist/lib/browser/chunk-43I2LR6O.mjs.map +0 -7
  489. package/dist/lib/browser/chunk-5EGXHCAZ.mjs +0 -16
  490. package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +0 -7
  491. package/dist/lib/browser/chunk-5RICKAMN.mjs +0 -18
  492. package/dist/lib/browser/chunk-5RICKAMN.mjs.map +0 -7
  493. package/dist/lib/browser/chunk-CQ7UHYTT.mjs +0 -296
  494. package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +0 -7
  495. package/dist/lib/browser/chunk-FP56WB24.mjs +0 -212
  496. package/dist/lib/browser/chunk-FP56WB24.mjs.map +0 -7
  497. package/dist/lib/browser/chunk-JZRZVB2A.mjs +0 -170
  498. package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +0 -7
  499. package/dist/lib/browser/chunk-WRJGOT5P.mjs +0 -1794
  500. package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +0 -7
  501. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +0 -18
  502. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +0 -7
  503. package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs +0 -114
  504. package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +0 -7
  505. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs +0 -17
  506. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs.map +0 -7
  507. package/dist/lib/browser/react-surface-FTKCE6GG.mjs +0 -107
  508. package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +0 -7
  509. package/dist/lib/browser/settings-HBF32KV6.mjs +0 -23
  510. package/dist/lib/browser/settings-HBF32KV6.mjs.map +0 -7
  511. package/dist/lib/browser/state-LXTS54DI.mjs +0 -21
  512. package/dist/lib/browser/state-LXTS54DI.mjs.map +0 -7
  513. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +0 -199
  514. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +0 -7
  515. package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs +0 -29
  516. package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs.map +0 -7
  517. package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs +0 -151
  518. package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +0 -7
  519. package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs +0 -74
  520. package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +0 -7
  521. package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs +0 -87
  522. package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +0 -7
  523. package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs +0 -151
  524. package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +0 -7
  525. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +0 -20
  526. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +0 -7
  527. package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs +0 -155
  528. package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +0 -7
  529. package/dist/lib/node-esm/blueprint-definition-WD2IVMAI.mjs +0 -13
  530. package/dist/lib/node-esm/chunk-73ABYRYX.mjs +0 -20
  531. package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +0 -7
  532. package/dist/lib/node-esm/chunk-DSE2IILK.mjs +0 -217
  533. package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +0 -7
  534. package/dist/lib/node-esm/chunk-E2WXZND7.mjs +0 -297
  535. package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +0 -7
  536. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +0 -171
  537. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +0 -7
  538. package/dist/lib/node-esm/chunk-TNR46C3L.mjs +0 -213
  539. package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +0 -7
  540. package/dist/lib/node-esm/chunk-U2NYUS2N.mjs +0 -177
  541. package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +0 -7
  542. package/dist/lib/node-esm/chunk-UFKLCEAE.mjs +0 -1795
  543. package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +0 -7
  544. package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs +0 -17
  545. package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +0 -7
  546. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +0 -19
  547. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +0 -7
  548. package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs +0 -115
  549. package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +0 -7
  550. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs +0 -18
  551. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs.map +0 -7
  552. package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs +0 -108
  553. package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +0 -7
  554. package/dist/lib/node-esm/settings-CWP6MTWP.mjs +0 -24
  555. package/dist/lib/node-esm/settings-CWP6MTWP.mjs.map +0 -7
  556. package/dist/lib/node-esm/state-BO6GUFLB.mjs +0 -22
  557. package/dist/lib/node-esm/state-BO6GUFLB.mjs.map +0 -7
  558. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +0 -200
  559. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +0 -7
  560. package/dist/types/src/capabilities/capabilities.d.ts +0 -11
  561. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  562. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  563. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  564. package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
  565. package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
  566. package/dist/types/src/components/ChatCompanion.d.ts +0 -13
  567. package/dist/types/src/components/ChatCompanion.d.ts.map +0 -1
  568. package/dist/types/src/components/ChatContainer.d.ts +0 -11
  569. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  570. package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
  571. package/dist/types/src/components/ChatThread/reducers.d.ts +0 -40
  572. package/dist/types/src/components/ChatThread/reducers.d.ts.map +0 -1
  573. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  574. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  575. package/dist/types/src/components/SequenceContainer.d.ts +0 -8
  576. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  577. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  578. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  579. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -269
  580. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  581. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  582. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  583. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +0 -1
  584. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -5
  585. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  586. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  587. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  588. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +0 -11
  589. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
  590. package/dist/types/src/events.d.ts +0 -4
  591. package/dist/types/src/events.d.ts.map +0 -1
  592. package/dist/types/src/functions/analysis.d.ts +0 -5
  593. package/dist/types/src/functions/analysis.d.ts.map +0 -1
  594. package/dist/types/src/functions/index.d.ts +0 -4
  595. package/dist/types/src/functions/index.d.ts.map +0 -1
  596. package/dist/types/src/functions/list.d.ts +0 -10
  597. package/dist/types/src/functions/list.d.ts.map +0 -1
  598. package/dist/types/src/functions/load.d.ts +0 -8
  599. package/dist/types/src/functions/load.d.ts.map +0 -1
  600. package/dist/types/src/hooks/useItemTypes.d.ts +0 -4
  601. package/dist/types/src/hooks/useItemTypes.d.ts.map +0 -1
  602. package/dist/types/src/types/AssistantAction.d.ts +0 -107
  603. package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
  604. package/src/capabilities/capabilities.ts +0 -18
  605. package/src/capabilities/intent-resolver.ts +0 -96
  606. package/src/components/BlueprintContainer.tsx +0 -24
  607. package/src/components/ChatCompanion.tsx +0 -136
  608. package/src/components/ChatContainer.tsx +0 -51
  609. package/src/components/ChatThread/reducers.ts +0 -151
  610. package/src/components/PromptSettings.tsx +0 -90
  611. package/src/components/SequenceContainer.tsx +0 -131
  612. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -35
  613. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  614. package/src/components/SequenceEditor/index.ts +0 -5
  615. package/src/components/TemplateEditor/handlebars-extension.ts +0 -165
  616. package/src/components/Toolbar/Toolbar.tsx +0 -21
  617. package/src/components/Toolbar/useChatToolbarActions.ts +0 -126
  618. package/src/events.ts +0 -11
  619. package/src/functions/analysis.ts +0 -22
  620. package/src/functions/index.ts +0 -7
  621. package/src/functions/list.ts +0 -48
  622. package/src/functions/load.ts +0 -46
  623. package/src/hooks/useItemTypes.ts +0 -37
  624. package/src/types/AssistantAction.ts +0 -62
  625. /package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs.map → blueprints/index.mjs.map} +0 -0
  626. /package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs.map → blueprints/index.mjs.map} +0 -0
  627. /package/dist/types/src/components/TemplateEditor/{handlebars-extension.d.ts → extensions/handlebars-extension.d.ts} +0 -0
@@ -1,1795 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- meta
4
- } from "./chunk-73ABYRYX.mjs";
5
-
6
- // src/hooks/useBlueprintRegistry.ts
7
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
8
- import { useSignalEffect } from "@preact/signals-react";
9
- import { useCallback, useMemo, useState } from "react";
10
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
11
- import { Blueprint } from "@dxos/blueprints";
12
- import { Filter, Obj, Ref } from "@dxos/echo";
13
- import { useQuery } from "@dxos/react-client/echo";
14
- import { distinctBy, isNonNullable } from "@dxos/util";
15
- var useBlueprintRegistry = () => {
16
- const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
17
- return useMemo(() => new Blueprint.Registry(blueprints), [
18
- blueprints
19
- ]);
20
- };
21
- var useBlueprints = ({ blueprintRegistry, space }) => {
22
- const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
23
- blueprintRegistry
24
- ]);
25
- const spaceBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
26
- return useMemo(() => {
27
- const blueprints = distinctBy([
28
- ...staticBlueprints,
29
- ...spaceBlueprints
30
- ], (b) => b.key);
31
- blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
32
- return blueprints;
33
- }, [
34
- staticBlueprints,
35
- spaceBlueprints
36
- ]);
37
- };
38
- var useActiveBlueprints = ({ context }) => {
39
- var _effect = _useSignals();
40
- try {
41
- const [active, setActive] = useState(/* @__PURE__ */ new Map());
42
- useSignalEffect(() => {
43
- const refs = [
44
- ...context?.blueprints.value ?? []
45
- ];
46
- const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
47
- setActive(new Map(blueprints.map((blueprint) => [
48
- blueprint.key,
49
- blueprint
50
- ])));
51
- });
52
- return active;
53
- } finally {
54
- _effect.f();
55
- }
56
- };
57
- var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
58
- const onUpdateBlueprint = useCallback(async (key, checked) => {
59
- if (!context || !blueprintRegistry) {
60
- return;
61
- }
62
- const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
63
- let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
64
- if (checked) {
65
- if (!storedBlueprint) {
66
- const blueprint = blueprintRegistry.getByKey(key);
67
- if (!blueprint) {
68
- return;
69
- }
70
- storedBlueprint = space.db.add(Obj.clone(blueprint));
71
- }
72
- await context.bind({
73
- blueprints: [
74
- Ref.make(storedBlueprint)
75
- ]
76
- });
77
- } else if (storedBlueprint) {
78
- await context.unbind({
79
- blueprints: [
80
- Ref.make(storedBlueprint)
81
- ]
82
- });
83
- }
84
- }, [
85
- space,
86
- context,
87
- blueprintRegistry
88
- ]);
89
- return {
90
- onUpdateBlueprint
91
- };
92
- };
93
-
94
- // src/hooks/useChatProcessor.ts
95
- import { RegistryContext } from "@effect-rx/rx-react";
96
- import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
97
- import { AiConversation } from "@dxos/assistant";
98
- import { log as log2 } from "@dxos/log";
99
- import { useAsyncEffect } from "@dxos/react-ui";
100
-
101
- // src/processor/presets.ts
102
- import * as Schema from "effect/Schema";
103
- var ModelProviders = [
104
- "dxos-local",
105
- "dxos-remote",
106
- "lm-studio"
107
- ];
108
- var ModelProvider = Schema.Literal(...ModelProviders);
109
- var createModelLabel = (model) => {
110
- const parts = model.split("/");
111
- return parts[parts.length - 1];
112
- };
113
- var AiServicePresets = [
114
- {
115
- provider: "dxos-remote",
116
- model: "@anthropic/claude-opus-4-0"
117
- },
118
- {
119
- provider: "dxos-remote",
120
- model: "@anthropic/claude-sonnet-4-0"
121
- },
122
- {
123
- provider: "dxos-remote",
124
- model: "@anthropic/claude-3-5-haiku-20241022"
125
- },
126
- {
127
- provider: "lm-studio",
128
- model: "@google/gemma-3-27b"
129
- },
130
- {
131
- provider: "lm-studio",
132
- model: "@mlx-community/llama-3.2-3b-instruct"
133
- },
134
- {
135
- model: "deepseek-r1:latest",
136
- provider: "dxos-local"
137
- }
138
- ].map(({ model, provider }, i) => ({
139
- id: `preset-${i}`,
140
- provider,
141
- model,
142
- label: createModelLabel(model)
143
- }));
144
-
145
- // src/processor/processor.ts
146
- import { Registry, Rx } from "@effect-rx/rx-react";
147
- import * as Cause from "effect/Cause";
148
- import * as Effect from "effect/Effect";
149
- import * as Exit from "effect/Exit";
150
- import * as Fiber from "effect/Fiber";
151
- import * as Option from "effect/Option";
152
- import * as Runtime from "effect/Runtime";
153
- import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
154
- import { AiSession, ArtifactDiffResolver, GenerationObserver, createSystemPrompt } from "@dxos/assistant";
155
- import { Obj as Obj2 } from "@dxos/echo";
156
- import { throwCause } from "@dxos/effect";
157
- import { log } from "@dxos/log";
158
- import { DataType } from "@dxos/schema";
159
- import { trim } from "@dxos/util";
160
- function _define_property(obj, key, value) {
161
- if (key in obj) {
162
- Object.defineProperty(obj, key, {
163
- value,
164
- enumerable: true,
165
- configurable: true,
166
- writable: true
167
- });
168
- } else {
169
- obj[key] = value;
170
- }
171
- return obj;
172
- }
173
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
174
- var defaultOptions = {
175
- model: DEFAULT_EDGE_MODEL
176
- };
177
- var AiChatProcessor = class {
178
- get context() {
179
- return this._conversation.context;
180
- }
181
- get conversation() {
182
- return this._conversation;
183
- }
184
- get blueprintRegistry() {
185
- return this._options.blueprintRegistry;
186
- }
187
- /**
188
- * Initiates a new request.
189
- */
190
- async request(requestParam) {
191
- if (this._fiber) {
192
- await this.cancel();
193
- }
194
- try {
195
- this._lastRequest = requestParam;
196
- this._rx.set(this.error, Option.none());
197
- this._rx.set(this.active, true);
198
- const request = this._conversation.createRequest({
199
- system: this._options.system,
200
- prompt: requestParam.message,
201
- observer: this._observer
202
- });
203
- const runtime2 = await this._services();
204
- this._fiber = request.pipe(
205
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
206
- // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
207
- Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
208
- Effect.asVoid,
209
- Runtime.runFork(runtime2)
210
- );
211
- const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
212
- if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
213
- throwCause(response.cause);
214
- }
215
- this._rx.set(this.error, Option.none());
216
- this._lastRequest = void 0;
217
- this._fiber = void 0;
218
- } catch (error) {
219
- log.error("request failed", {
220
- error
221
- }, {
222
- F: __dxlog_file,
223
- L: 187,
224
- S: this,
225
- C: (f, a) => f(...a)
226
- });
227
- this._rx.set(this.error, Option.some(new Error("AI service error", {
228
- cause: error
229
- })));
230
- } finally {
231
- this._fiber = void 0;
232
- this._rx.set(this.active, false);
233
- }
234
- }
235
- /**
236
- * Cancels the current request.
237
- */
238
- async cancel() {
239
- await Effect.runPromise(Effect.gen(this, function* () {
240
- if (this._fiber) {
241
- yield* this._fiber.pipe(Fiber.interrupt);
242
- }
243
- }));
244
- this._fiber = void 0;
245
- this._rx.set(this.active, false);
246
- }
247
- /**
248
- * Retry last failed request.
249
- */
250
- async retry() {
251
- if (this._lastRequest) {
252
- return this.request(this._lastRequest);
253
- }
254
- }
255
- /**
256
- * Update the current chat's name.
257
- */
258
- async updateName(chat) {
259
- const runtime2 = await this._services();
260
- const system = trim`
261
- It is extremely important that you respond only with the title and nothing else.
262
- If you cannot do this effectively respond with "New Chat".
263
- `;
264
- const history = await this._conversation.getHistory();
265
- const fiber = Effect.gen(this, function* () {
266
- const session = new AiSession();
267
- return yield* session.run({
268
- system,
269
- prompt: "Suggest a name for this chat",
270
- history
271
- });
272
- }).pipe(
273
- // TODO(burdon): Use simpler model.
274
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
275
- Effect.tap((messages) => {
276
- const message = messages.find((message2) => message2.sender.role === "assistant");
277
- const title = message?.blocks.find((b) => b._tag === "text")?.text;
278
- if (title) {
279
- chat.name = title;
280
- }
281
- }),
282
- Runtime.runFork(runtime2)
283
- );
284
- const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
285
- if (!Exit.isSuccess(response)) {
286
- throwCause(response.cause);
287
- }
288
- }
289
- constructor(_conversation, _services, _options = defaultOptions) {
290
- _define_property(this, "_conversation", void 0);
291
- _define_property(this, "_services", void 0);
292
- _define_property(this, "_options", void 0);
293
- _define_property(this, "_rx", void 0);
294
- _define_property(this, "_observer", void 0);
295
- _define_property(this, "_fiber", void 0);
296
- _define_property(this, "_lastRequest", void 0);
297
- _define_property(this, "_pending", void 0);
298
- _define_property(this, "_streaming", void 0);
299
- _define_property(this, "streaming", void 0);
300
- _define_property(this, "active", void 0);
301
- _define_property(this, "messages", void 0);
302
- _define_property(this, "error", void 0);
303
- _define_property(this, "_artifactDiffResolver", void 0);
304
- _define_property(this, "_onMessage", void 0);
305
- _define_property(this, "_onBlock", void 0);
306
- this._conversation = _conversation;
307
- this._services = _services;
308
- this._options = _options;
309
- this._pending = Rx.make([]);
310
- this._streaming = Rx.make(Option.none());
311
- this.streaming = Rx.make((get) => Option.isSome(get(this._streaming)));
312
- this.active = Rx.make(false);
313
- this.messages = Rx.make((get) => Option.match(get(this._streaming), {
314
- onNone: () => get(this._pending),
315
- onSome: (streaming) => [
316
- ...get(this._pending),
317
- streaming
318
- ]
319
- }));
320
- this.error = Rx.make(Option.none());
321
- this._artifactDiffResolver = {
322
- resolve: async (_artifacts) => {
323
- const versions = /* @__PURE__ */ new Map();
324
- return versions;
325
- }
326
- };
327
- this._onMessage = Effect.fn((function* (message) {
328
- this._rx.set(this._streaming, Option.none());
329
- this._rx.update(this._pending, (pending) => [
330
- ...pending,
331
- message
332
- ]);
333
- }).bind(this));
334
- this._onBlock = Effect.fn((function* (block) {
335
- this._rx.update(this._streaming, (streaming) => {
336
- const blocks = streaming.pipe(Option.map((streaming2) => streaming2.blocks.filter((b) => !b.pending)), Option.getOrElse(() => []));
337
- return Option.some(Obj2.make(DataType.Message, {
338
- created: (/* @__PURE__ */ new Date()).toISOString(),
339
- sender: {
340
- role: "assistant"
341
- },
342
- blocks: [
343
- ...blocks,
344
- block
345
- ]
346
- }));
347
- });
348
- }).bind(this));
349
- this._rx = this._options.observableRegistry ?? Registry.make();
350
- this._observer = GenerationObserver.make({
351
- onBlock: this._onBlock,
352
- onMessage: this._onMessage
353
- });
354
- if (this._options.model && !this._options.system) {
355
- const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
356
- this._options.system = createSystemPrompt(capabilities);
357
- }
358
- }
359
- };
360
-
361
- // src/hooks/useChatProcessor.ts
362
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
363
- var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
364
- const observableRegistry = useContext(RegistryContext);
365
- const [conversation, setConversation] = useState2();
366
- useAsyncEffect(async () => {
367
- if (!chat?.queue.target) {
368
- return;
369
- }
370
- const conversation2 = new AiConversation({
371
- queue: chat.queue.target
372
- });
373
- await conversation2.open();
374
- setConversation(conversation2);
375
- return () => {
376
- void conversation2.close();
377
- };
378
- }, [
379
- chat?.queue.target
380
- ]);
381
- const processor = useMemo2(() => {
382
- if (!services || !conversation) {
383
- return void 0;
384
- }
385
- log2("creating processor", {
386
- preset,
387
- model: preset?.model,
388
- settings
389
- }, {
390
- F: __dxlog_file2,
391
- L: 60,
392
- S: void 0,
393
- C: (f, a) => f(...a)
394
- });
395
- return new AiChatProcessor(conversation, services, {
396
- observableRegistry,
397
- blueprintRegistry,
398
- model: preset?.model
399
- });
400
- }, [
401
- services,
402
- conversation,
403
- blueprintRegistry,
404
- preset
405
- ]);
406
- return processor;
407
- };
408
-
409
- // src/hooks/useChatServices.ts
410
- import * as Effect2 from "effect/Effect";
411
- import { useMemo as useMemo3 } from "react";
412
- import { useCapability } from "@dxos/app-framework";
413
- import { TracingService } from "@dxos/functions";
414
- import { AutomationCapabilities } from "@dxos/plugin-automation";
415
- import { useClient } from "@dxos/react-client";
416
- var useChatServices = ({ space, chat }) => {
417
- const client = useClient();
418
- space ?? (space = client.spaces.default);
419
- const computeRuntimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
420
- return useMemo3(() => {
421
- const runtime2 = computeRuntimeResolver.getRuntime(space.id);
422
- return () => runtime2.runPromise(Effect2.gen(function* () {
423
- return yield* Effect2.runtime().pipe(Effect2.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
424
- }));
425
- }, [
426
- space,
427
- chat?.traceQueue?.target
428
- ]);
429
- };
430
-
431
- // src/hooks/useContextBinder.ts
432
- import { useState as useState3 } from "react";
433
- import { AiContextBinder } from "@dxos/assistant";
434
- import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
435
- var useContextBinder = (chat) => {
436
- const [binder, setBinder] = useState3();
437
- useAsyncEffect2(async () => {
438
- if (!chat?.queue.target) {
439
- return;
440
- }
441
- const binder2 = new AiContextBinder(chat.queue.target);
442
- await binder2.open();
443
- setBinder(binder2);
444
- return () => {
445
- void binder2.close();
446
- };
447
- }, [
448
- chat?.queue.target
449
- ]);
450
- return binder;
451
- };
452
-
453
- // src/hooks/useContextObjects.ts
454
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
455
- import { useCallback as useCallback2 } from "react";
456
- import { Ref as Ref2 } from "@dxos/echo";
457
- import { log as log3 } from "@dxos/log";
458
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
459
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
460
- var useContextObjects = ({ space, context }) => {
461
- var _effect = _useSignals2();
462
- try {
463
- const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
464
- const handleUpdateObject = useCallback2(async (dxn, checked) => {
465
- if (!space || !context) {
466
- return;
467
- }
468
- const id = dxn.asEchoDXN();
469
- const object = id && await space.db.getObjectById(id.echoId);
470
- if (!object) {
471
- log3.warn("Object not found", {
472
- dxn,
473
- id
474
- }, {
475
- F: __dxlog_file3,
476
- L: 40,
477
- S: void 0,
478
- C: (f, a) => f(...a)
479
- });
480
- return;
481
- }
482
- const ref = Ref2.fromDXN(dxn);
483
- if (checked) {
484
- await context.bind({
485
- objects: [
486
- ref
487
- ]
488
- });
489
- } else {
490
- await context.unbind({
491
- objects: [
492
- ref
493
- ]
494
- });
495
- }
496
- }, [
497
- space,
498
- context
499
- ]);
500
- return {
501
- objects,
502
- onUpdateObject: handleUpdateObject
503
- };
504
- } finally {
505
- _effect.f();
506
- }
507
- };
508
-
509
- // src/hooks/useFlush.ts
510
- import { useCallback as useCallback3, useRef, useState as useState4 } from "react";
511
- var useFlush = (space) => {
512
- const [state, setState] = useState4("idle");
513
- const resetTimer = useRef(null);
514
- const handleFlush = useCallback3(() => {
515
- if (!space) {
516
- return;
517
- }
518
- queueMicrotask(async () => {
519
- if (resetTimer.current) {
520
- clearTimeout(resetTimer.current);
521
- }
522
- setState("flushing");
523
- await space.db.flush();
524
- setState("flushed");
525
- resetTimer.current = setTimeout(() => {
526
- setState("idle");
527
- resetTimer.current = null;
528
- }, 1e3);
529
- });
530
- }, [
531
- space
532
- ]);
533
- return {
534
- state,
535
- handleFlush
536
- };
537
- };
538
-
539
- // src/hooks/useItemTypes.ts
540
- import * as Option2 from "effect/Option";
541
- import { useEffect, useState as useState5 } from "react";
542
- import { ItemAnnotation } from "@dxos/schema";
543
- var useItemTypes = (space) => {
544
- const [types, setTypes] = useState5([]);
545
- useEffect(() => {
546
- if (!space) {
547
- return;
548
- }
549
- return space.db.schemaRegistry.query().subscribe((query) => {
550
- const types2 = Array.from(new Set([
551
- ...space.db.graph.schemaRegistry.schemas,
552
- ...query.results
553
- ].filter((type) => Option2.isSome(ItemAnnotation.get(type)))));
554
- setTypes(types2);
555
- }, {
556
- fire: true
557
- });
558
- }, [
559
- space
560
- ]);
561
- return types;
562
- };
563
-
564
- // src/hooks/useOnline.ts
565
- import { useState as useState6 } from "react";
566
- var useOnline = () => {
567
- const [online, setOnline] = useState6(true);
568
- return [
569
- online,
570
- setOnline
571
- ];
572
- };
573
-
574
- // src/hooks/usePresets.ts
575
- import { useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo4, useState as useState7 } from "react";
576
- var usePresets = (online) => {
577
- const [preset, setPreset] = useState7();
578
- const presets = useMemo4(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
579
- online
580
- ]);
581
- const presetOptions = useMemo4(() => presets.map(({ id, model, label }) => ({
582
- id,
583
- label: label ?? model
584
- })), [
585
- presets
586
- ]);
587
- useEffect2(() => {
588
- setPreset(presets[0]);
589
- }, [
590
- presets
591
- ]);
592
- const handlePresetChange = useCallback4((id) => {
593
- const preset2 = presets.find((preset3) => preset3.id === id);
594
- if (preset2) {
595
- setPreset(preset2);
596
- }
597
- }, [
598
- presets
599
- ]);
600
- return {
601
- preset,
602
- presets: presetOptions,
603
- onPresetChange: handlePresetChange
604
- };
605
- };
606
-
607
- // src/hooks/useReferencesProvider.ts
608
- import { useMemo as useMemo5 } from "react";
609
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
610
- import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
611
- var useReferencesProvider = (space) => {
612
- const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
613
- return useMemo5(() => {
614
- if (!space) {
615
- return void 0;
616
- }
617
- return {
618
- getReferences: async ({ query }) => {
619
- const { objects } = await space.db.query(Filter2.everything()).run();
620
- return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
621
- uri: Obj3.getDXN(object).toString(),
622
- label: Obj3.getLabel(object) ?? ""
623
- }));
624
- },
625
- resolveReference: async ({ uri }) => {
626
- const object = await space.db.query(Filter2.ids(uri)).first();
627
- return {
628
- uri,
629
- label: Obj3.getLabel(object) ?? ""
630
- };
631
- }
632
- };
633
- }, [
634
- space,
635
- blueprints
636
- ]);
637
- };
638
- var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
639
-
640
- // src/components/Chat/Chat.tsx
641
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
642
- import { Prec } from "@codemirror/state";
643
- import { keymap } from "@codemirror/view";
644
- import { useRxValue } from "@effect-rx/rx-react";
645
- import { createContext } from "@radix-ui/react-context";
646
- import * as Array2 from "effect/Array";
647
- import * as Option3 from "effect/Option";
648
- import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState12 } from "react";
649
- import { Event } from "@dxos/async";
650
- import { Obj as Obj6 } from "@dxos/echo";
651
- import { useVoiceInput } from "@dxos/plugin-transcription";
652
- import { getSpace, useQueue } from "@dxos/react-client/echo";
653
- import { useIdentity } from "@dxos/react-client/halo";
654
- import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
655
- import { ChatEditor, references } from "@dxos/react-ui-chat";
656
- import { mx as mx5 } from "@dxos/react-ui-theme";
657
- import { DataType as DataType2 } from "@dxos/schema";
658
- import { isTruthy } from "@dxos/util";
659
-
660
- // src/components/ChatPrompt/ChatActions.tsx
661
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
662
- import React from "react";
663
- import { IconButton, useTranslation } from "@dxos/react-ui";
664
- import { mx } from "@dxos/react-ui-theme";
665
- var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
666
- var _effect = _useSignals3();
667
- try {
668
- const { t } = useTranslation(meta.id);
669
- return /* @__PURE__ */ React.createElement("div", {
670
- className: mx("flex items-center mie-1", classNames)
671
- }, children, /* @__PURE__ */ React.createElement(IconButton, {
672
- disabled: !processing,
673
- variant: "ghost",
674
- size: 5,
675
- icon: "ph--x--regular",
676
- iconOnly: true,
677
- label: t("button cancel processing"),
678
- onClick: () => onEvent?.({
679
- type: "cancel"
680
- })
681
- }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
682
- disabled: !processing,
683
- classNames: mx(recording && "bg-primary-500"),
684
- variant: "ghost",
685
- size: 5,
686
- icon: "ph--microphone--regular",
687
- iconOnly: true,
688
- noTooltip: true,
689
- label: t("button microphone"),
690
- onMouseDown: () => onEvent?.({
691
- type: "record-start"
692
- }),
693
- onMouseUp: () => onEvent?.({
694
- type: "record-stop"
695
- }),
696
- onTouchStart: () => onEvent?.({
697
- type: "record-start"
698
- }),
699
- onTouchEnd: () => onEvent?.({
700
- type: "record-stop"
701
- })
702
- }));
703
- } finally {
704
- _effect.f();
705
- }
706
- };
707
-
708
- // src/components/ChatPrompt/ChatOptions.tsx
709
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
710
- import React2, { useMemo as useMemo6, useState as useState8 } from "react";
711
- import { Filter as Filter3, Obj as Obj4, Type } from "@dxos/echo";
712
- import { useQuery as useQuery2 } from "@dxos/react-client/echo";
713
- import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
714
- import { Listbox, SearchList } from "@dxos/react-ui-searchlist";
715
- import { Tabs } from "@dxos/react-ui-tabs";
716
- var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-72 max-is-[--text-content]";
717
- var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
718
- var _effect = _useSignals4();
719
- try {
720
- const { t } = useTranslation2(meta.id);
721
- return /* @__PURE__ */ React2.createElement("div", {
722
- role: "none",
723
- className: "flex gap-0.5"
724
- }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
725
- asChild: true
726
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
727
- variant: "ghost",
728
- icon: "ph--plus--regular",
729
- iconOnly: true,
730
- size: 5,
731
- label: t("button context objects")
732
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
733
- side: "top",
734
- classNames: panelClassNames
735
- }, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
736
- space,
737
- context
738
- }), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
739
- asChild: true
740
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
741
- variant: "ghost",
742
- icon: "ph--sliders-horizontal--regular",
743
- iconOnly: true,
744
- size: 5,
745
- label: t("button context settings")
746
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
747
- side: "top",
748
- classNames: panelClassNames
749
- }, /* @__PURE__ */ React2.createElement(Tabs.Root, {
750
- orientation: "horizontal",
751
- defaultValue: "blueprints",
752
- defaultActivePart: "list",
753
- tabIndex: -1
754
- }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
755
- classNames: 'max-bs-[--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-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'
756
- }, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
757
- value: "blueprints",
758
- tabIndex: -1,
759
- classNames: "dx-focus-ring-inset"
760
- }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
761
- blueprintRegistry,
762
- space,
763
- context
764
- })), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
765
- value: "model",
766
- tabIndex: -1,
767
- classNames: "dx-focus-ring-inset !pli-0"
768
- }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
769
- presets,
770
- preset,
771
- onPresetChange
772
- })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
773
- classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
774
- }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
775
- value: "blueprints",
776
- icon: "ph--blueprint--regular",
777
- label: t("blueprints in context title")
778
- }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
779
- value: "model",
780
- label: t("chat model title"),
781
- icon: "ph--cpu--regular"
782
- })))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
783
- } finally {
784
- _effect.f();
785
- }
786
- };
787
- var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
788
- var _effect = _useSignals4();
789
- try {
790
- const { t } = useTranslation2(meta.id);
791
- const blueprints = useBlueprints({
792
- blueprintRegistry,
793
- space
794
- });
795
- const activeBlueprints = useActiveBlueprints({
796
- context
797
- });
798
- const { onUpdateBlueprint } = useBlueprintHandlers({
799
- space,
800
- context,
801
- blueprintRegistry
802
- });
803
- return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
804
- classNames: "plb-cardSpacingChrome"
805
- }, blueprints.map((blueprint) => {
806
- const isActive = activeBlueprints.has(blueprint.key);
807
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
808
- classNames: "flex items-center overflow-hidden",
809
- key: blueprint.key,
810
- value: blueprint.name,
811
- onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
812
- }, /* @__PURE__ */ React2.createElement("div", {
813
- className: "grow truncate"
814
- }, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
815
- icon: "ph--check--regular",
816
- classNames: [
817
- !isActive && "invisible"
818
- ]
819
- }));
820
- })), /* @__PURE__ */ React2.createElement(SearchList.Input, {
821
- placeholder: t("search placeholder"),
822
- classNames: "mbe-cardSpacingChrome",
823
- autoFocus: true
824
- }));
825
- } finally {
826
- _effect.f();
827
- }
828
- };
829
- var ModelsPanel = ({ presets, preset, onPresetChange }) => {
830
- var _effect = _useSignals4();
831
- try {
832
- return /* @__PURE__ */ React2.createElement(Listbox.Root, {
833
- value: preset,
834
- onValueChange: onPresetChange,
835
- autoFocus: true
836
- }, presets?.map(({ id, label }) => {
837
- return /* @__PURE__ */ React2.createElement(Listbox.Option, {
838
- key: id,
839
- value: id
840
- }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
841
- }));
842
- } finally {
843
- _effect.f();
844
- }
845
- };
846
- var ANY = "__any__";
847
- var ObjectsPanel = ({ space, context }) => {
848
- var _effect = _useSignals4();
849
- try {
850
- const { t } = useTranslation2(meta.id);
851
- const types = useItemTypes(space);
852
- const typenames = useMemo6(() => {
853
- const typenames2 = types.map((type) => {
854
- const typename2 = Type.getTypename(type);
855
- return {
856
- typename: typename2,
857
- label: t("typename label", {
858
- ns: typename2,
859
- defaultValue: typename2
860
- })
861
- };
862
- });
863
- typenames2.sort((a, b) => a.label.localeCompare(b.label));
864
- return typenames2;
865
- }, [
866
- types
867
- ]);
868
- const [typename, setTypename] = useState8(ANY);
869
- const anyFilter = useMemo6(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
870
- typenames
871
- ]);
872
- const objects = useQuery2(space, typename === ANY ? anyFilter : Filter3.typename(typename));
873
- const { objects: contextObjects, onUpdateObject } = useContextObjects({
874
- space,
875
- context
876
- });
877
- return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
878
- classNames: "p-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
879
- }, objects.length ? objects.map((object) => {
880
- const label = Obj4.getLabel(object) ?? Obj4.getTypename(object) ?? object.id;
881
- const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
882
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
883
- classNames: "flex items-center overflow-hidden",
884
- key: object.id,
885
- value: object.id,
886
- onSelect: () => onUpdateObject?.(Obj4.getDXN(object), !isActive)
887
- }, /* @__PURE__ */ React2.createElement("div", {
888
- className: "grow truncate"
889
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
890
- icon: "ph--check--regular",
891
- classNames: [
892
- !isActive && "invisible"
893
- ]
894
- }));
895
- }) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
896
- role: "none",
897
- className: "grid grid-cols-[min-content_1fr] gap-2 pli-cardSpacingChrome mbe-cardSpacingChrome"
898
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
899
- value: typename === ANY ? void 0 : typename,
900
- onValueChange: setTypename
901
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
902
- density: "fine",
903
- placeholder: t("type filter placeholder")
904
- }), /* @__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, {
905
- value: ANY
906
- }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
907
- key: typename2,
908
- value: typename2
909
- }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
910
- placeholder: t("search placeholder"),
911
- classNames: "mbe-0",
912
- autoFocus: true
913
- })));
914
- } finally {
915
- _effect.f();
916
- }
917
- };
918
-
919
- // src/components/ChatPrompt/ChatPresets.tsx
920
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
921
- import React3 from "react";
922
- import { Select as Select2 } from "@dxos/react-ui";
923
-
924
- // src/components/ChatPrompt/ChatReferences.tsx
925
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
926
- import React4 from "react";
927
- import { Obj as Obj5 } from "@dxos/echo";
928
- import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
929
- import { mx as mx2 } from "@dxos/react-ui-theme";
930
- var ChatReferences = ({ classNames, context, space }) => {
931
- var _effect = _useSignals6();
932
- try {
933
- const { t } = useTranslation3(meta.id);
934
- const { objects, onUpdateObject } = useContextObjects({
935
- space,
936
- context
937
- });
938
- return /* @__PURE__ */ React4.createElement("ul", {
939
- className: mx2("flex flex-wrap", classNames)
940
- }, objects.map((obj) => {
941
- const dxn = Obj5.getDXN(obj);
942
- const typename = Obj5.getTypename(obj);
943
- const label = Obj5.getLabel(obj) ?? (typename ? [
944
- "object name placeholder",
945
- {
946
- ns: typename
947
- }
948
- ] : obj.id);
949
- return /* @__PURE__ */ React4.createElement("li", {
950
- key: dxn.toString(),
951
- className: "dx-tag plb-0 pis-2 flex items-center",
952
- "data-hue": "neutral"
953
- }, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
954
- iconOnly: true,
955
- variant: "ghost",
956
- label: t("remove object in context label"),
957
- classNames: "p-0 hover:bg-transparent",
958
- size: 3,
959
- icon: "ph--x--bold",
960
- onClick: () => onUpdateObject?.(dxn, false)
961
- }));
962
- }));
963
- } finally {
964
- _effect.f();
965
- }
966
- };
967
-
968
- // src/components/ChatPrompt/ChatStatusIndicator.tsx
969
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
970
- import React5, { useEffect as useEffect3, useState as useState9 } from "react";
971
- import { Tooltip, useTimeout } from "@dxos/react-ui";
972
- import { Spinner } from "@dxos/react-ui-sfx";
973
- import { mx as mx3 } from "@dxos/react-ui-theme";
974
- var period = 3e3;
975
- var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
976
- var _effect = _useSignals7();
977
- try {
978
- const [init, setInit] = useState9(false);
979
- useEffect3(() => setInit(false), [
980
- preset
981
- ]);
982
- useTimeout(async () => {
983
- setInit(true);
984
- }, period / 2, [
985
- preset
986
- ]);
987
- return /* @__PURE__ */ React5.createElement("div", {
988
- role: "none",
989
- className: mx3("relative flex", classNames)
990
- }, /* @__PURE__ */ React5.createElement(Spinner, {
991
- duration: period,
992
- state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
993
- ...props
994
- }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
995
- asChild: true,
996
- content: error.message
997
- }, /* @__PURE__ */ React5.createElement("div", {
998
- className: "absolute inset-0"
999
- })));
1000
- } finally {
1001
- _effect.f();
1002
- }
1003
- };
1004
-
1005
- // src/components/ChatThread/ChatThread.tsx
1006
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1007
- import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo8, useState as useState11 } from "react";
1008
- import { PublicKey } from "@dxos/keys";
1009
- import { MarkdownStream } from "@dxos/react-ui-components";
1010
- import { mx as mx4 } from "@dxos/react-ui-theme";
1011
- import { keyToFallback } from "@dxos/util";
1012
-
1013
- // src/components/ChatThread/registry.tsx
1014
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1015
- import React7 from "react";
1016
- import { log as log4 } from "@dxos/log";
1017
- import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
1018
- import { getXmlTextChild } from "@dxos/react-ui-editor";
1019
- import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
1020
- import { ContentBlock } from "@dxos/schema";
1021
-
1022
- // src/components/ToolBlock/ToolBlock.tsx
1023
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1024
- import React6, { useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
1025
- import { useTranslation as useTranslation4 } from "@dxos/react-ui";
1026
- import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
1027
- import { Json } from "@dxos/react-ui-syntax-highlighter";
1028
- import { isNonNullable as isNonNullable3, safeParseJson } from "@dxos/util";
1029
- var ToolBlock = ({ blocks = [] }) => {
1030
- var _effect = _useSignals8();
1031
- try {
1032
- const { t } = useTranslation4(meta.id);
1033
- const getToolCaption = (tool, status) => {
1034
- if (!tool) {
1035
- return t("calling tool label");
1036
- }
1037
- return status?.message ?? tool.description ?? [
1038
- t("calling label"),
1039
- tool.name
1040
- ].join(" ");
1041
- };
1042
- const items = useMemo7(() => {
1043
- let lastToolCall;
1044
- const tools = [];
1045
- return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
1046
- switch (block._tag) {
1047
- case "toolCall": {
1048
- if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
1049
- return null;
1050
- }
1051
- const tool = tools.find((tool2) => tool2.name === block.name);
1052
- lastToolCall = {
1053
- tool,
1054
- block
1055
- };
1056
- return {
1057
- title: getToolCaption(lastToolCall?.tool),
1058
- content: {
1059
- ...block,
1060
- input: safeParseJson(block.input)
1061
- }
1062
- };
1063
- }
1064
- case "toolResult": {
1065
- if (block.error) {
1066
- return {
1067
- title: t("error label"),
1068
- content: block
1069
- };
1070
- }
1071
- const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
1072
- lastToolCall = void 0;
1073
- return {
1074
- title,
1075
- content: {
1076
- ...block,
1077
- result: safeParseJson(block.result)
1078
- }
1079
- };
1080
- }
1081
- case "summary": {
1082
- if (!lastToolCall) {
1083
- return null;
1084
- }
1085
- return {
1086
- title: t("summary label"),
1087
- content: block
1088
- };
1089
- }
1090
- }
1091
- }).filter(isNonNullable3);
1092
- }, [
1093
- blocks
1094
- ]);
1095
- if (!items.length) {
1096
- return null;
1097
- }
1098
- return /* @__PURE__ */ React6.createElement(ToolContainer, {
1099
- items
1100
- });
1101
- } finally {
1102
- _effect.f();
1103
- }
1104
- };
1105
- ToolBlock.displayName = "ToolBlock";
1106
- var ToolContainer = ({ items }) => {
1107
- var _effect = _useSignals8();
1108
- try {
1109
- const tabsRef = useRef2(null);
1110
- const [selected, setSelected] = useState10(0);
1111
- const [open, setOpen] = useState10(false);
1112
- useEffect4(() => {
1113
- if (open) {
1114
- tabsRef.current?.focus();
1115
- }
1116
- }, [
1117
- open
1118
- ]);
1119
- const handleSelect = (index) => {
1120
- setSelected(index);
1121
- };
1122
- const data = items[selected]?.content;
1123
- return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
1124
- classNames: chatMessagePanel,
1125
- open,
1126
- onChangeOpen: setOpen
1127
- }, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
1128
- classNames: chatMessagePanelHeader
1129
- }, /* @__PURE__ */ React6.createElement(TextCrawl, {
1130
- key: "status-roll",
1131
- lines: items.map((item) => item.title)
1132
- })), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
1133
- classNames: [
1134
- "grid grid-cols-[32px_1fr]",
1135
- chatMessagePanelContent
1136
- ]
1137
- }, /* @__PURE__ */ React6.createElement(NumericTabs, {
1138
- ref: tabsRef,
1139
- classNames: "p-1",
1140
- length: items.length,
1141
- selected,
1142
- onSelect: handleSelect
1143
- }), /* @__PURE__ */ React6.createElement(Json, {
1144
- data,
1145
- classNames: chatMessageJson,
1146
- replacer: {
1147
- maxDepth: 3,
1148
- maxArrayLen: 10,
1149
- maxStringLen: 128
1150
- }
1151
- })));
1152
- } finally {
1153
- _effect.f();
1154
- }
1155
- };
1156
-
1157
- // src/components/ChatThread/registry.tsx
1158
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1159
- var Fallback = ({ _tag, ...props }) => {
1160
- var _effect = _useSignals9();
1161
- try {
1162
- return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
1163
- classNames: "rounded-sm"
1164
- }, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
1165
- classNames: "bg-groupSurface"
1166
- }, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
1167
- classNames: "bg-modalSurface"
1168
- }, /* @__PURE__ */ React7.createElement(Json2, {
1169
- classNames: "!p-2 text-sm",
1170
- data: props
1171
- })));
1172
- } finally {
1173
- _effect.f();
1174
- }
1175
- };
1176
- var componentRegistry = {
1177
- //
1178
- // Widgets
1179
- //
1180
- ["prompt"]: {
1181
- block: true,
1182
- factory: (props) => {
1183
- const text = getXmlTextChild(props.children);
1184
- return text ? new PromptWidget(text) : null;
1185
- }
1186
- },
1187
- ["reference"]: {
1188
- block: false,
1189
- factory: (props) => {
1190
- const text = getXmlTextChild(props.children);
1191
- return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
1192
- }
1193
- },
1194
- ["select"]: {
1195
- block: true,
1196
- factory: (props) => {
1197
- const options = props.children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1198
- return options?.length ? new SelectWidget(options) : null;
1199
- }
1200
- },
1201
- ["suggestion"]: {
1202
- block: true,
1203
- factory: (props) => {
1204
- const text = getXmlTextChild(props.children);
1205
- return text ? new SuggestionWidget(text) : null;
1206
- }
1207
- },
1208
- ["summary"]: {
1209
- block: true,
1210
- factory: (props) => {
1211
- const text = getXmlTextChild(props.children);
1212
- return text ? new SummaryWidget(text) : null;
1213
- }
1214
- },
1215
- //
1216
- // React
1217
- //
1218
- ["toolCall"]: {
1219
- block: true,
1220
- Component: ToolBlock
1221
- },
1222
- ["toolResult"]: {
1223
- block: true,
1224
- Component: Fallback
1225
- },
1226
- ["toolkit"]: {
1227
- block: true,
1228
- Component: Fallback
1229
- },
1230
- //
1231
- // Fallback
1232
- //
1233
- ["json"]: {
1234
- block: true,
1235
- Component: Fallback
1236
- }
1237
- };
1238
- var blockToMarkdown = (context, message, block) => {
1239
- let str = _blockToMarkdown(context, message, block);
1240
- if (str && !block.pending) {
1241
- return str += "\n";
1242
- }
1243
- return str;
1244
- };
1245
- var _blockToMarkdown = (context, message, block) => {
1246
- log4("blockToMarkdown", {
1247
- block: JSON.stringify(block)
1248
- }, {
1249
- F: __dxlog_file4,
1250
- L: 125,
1251
- S: void 0,
1252
- C: (f, a) => f(...a)
1253
- });
1254
- switch (block._tag) {
1255
- case "text": {
1256
- if (message.sender.role === "user") {
1257
- return `
1258
- <prompt>${block.text}</prompt>
1259
- `;
1260
- } else {
1261
- const text = block.text.trim();
1262
- if (text.length > 0) {
1263
- return text;
1264
- }
1265
- }
1266
- break;
1267
- }
1268
- case "suggestion": {
1269
- if (block.pending) {
1270
- return;
1271
- }
1272
- return `<suggestion>${block.text}</suggestion>`;
1273
- }
1274
- case "select": {
1275
- if (block.pending || block.options.length === 0) {
1276
- return;
1277
- }
1278
- return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1279
- }
1280
- // TODO(burdon): Need label.
1281
- case "reference": {
1282
- return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
1283
- }
1284
- // case 'toolkit': {
1285
- // return `<toolkit />`;
1286
- // }
1287
- case "toolCall": {
1288
- context.updateWidget(block.toolCallId, {
1289
- blocks: [
1290
- block
1291
- ]
1292
- });
1293
- return `<toolCall id="${block.toolCallId}" />`;
1294
- }
1295
- case "toolResult": {
1296
- context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
1297
- blocks: [
1298
- ...blocks,
1299
- block
1300
- ]
1301
- }));
1302
- break;
1303
- }
1304
- case "summary": {
1305
- return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
1306
- }
1307
- // TODO(burdon): Need stable ID.
1308
- default: {
1309
- return `<json id="${message.id}">
1310
- ${JSON.stringify(block)}
1311
- </json>`;
1312
- }
1313
- }
1314
- };
1315
-
1316
- // src/components/ChatThread/sync.ts
1317
- import { log as log5 } from "@dxos/log";
1318
- function _define_property2(obj, key, value) {
1319
- if (key in obj) {
1320
- Object.defineProperty(obj, key, {
1321
- value,
1322
- enumerable: true,
1323
- configurable: true,
1324
- writable: true
1325
- });
1326
- } else {
1327
- obj[key] = value;
1328
- }
1329
- return obj;
1330
- }
1331
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1332
- var MessageThreadContext = class {
1333
- updateWidget(id, value) {
1334
- this._widgetState?.updateWidget(id, value);
1335
- }
1336
- constructor(_widgetState) {
1337
- _define_property2(this, "_widgetState", void 0);
1338
- this._widgetState = _widgetState;
1339
- }
1340
- };
1341
- var MessageSyncer = class {
1342
- get context() {
1343
- return this._context;
1344
- }
1345
- reset() {
1346
- log5("reset", void 0, {
1347
- F: __dxlog_file5,
1348
- L: 58,
1349
- S: this,
1350
- C: (f, a) => f(...a)
1351
- });
1352
- this._initialMessageId = void 0;
1353
- this._currentMessageIndex = 0;
1354
- this._currentBlockIndex = 0;
1355
- this._currentBlockContent = void 0;
1356
- void this._model.reset("");
1357
- }
1358
- sync(messages) {
1359
- log5("sync", {
1360
- messages: messages.map((message) => message.blocks.length),
1361
- currentMessageIndex: this._currentMessageIndex,
1362
- currentBlockIndex: this._currentBlockIndex,
1363
- currentBlockContent: this._currentBlockContent
1364
- }, {
1365
- F: __dxlog_file5,
1366
- L: 67,
1367
- S: this,
1368
- C: (f, a) => f(...a)
1369
- });
1370
- if (this._initialMessageId !== messages[0]?.id) {
1371
- this.reset();
1372
- this._initialMessageId = messages[0]?.id;
1373
- }
1374
- let i = this._currentMessageIndex;
1375
- for (const message of messages.slice(this._currentMessageIndex)) {
1376
- if (i > this._currentMessageIndex) {
1377
- this._currentBlockIndex = 0;
1378
- }
1379
- this._currentMessageIndex = i;
1380
- let j = this._currentBlockIndex;
1381
- for (const block of message.blocks.slice(this._currentBlockIndex)) {
1382
- this._currentBlockIndex = j;
1383
- const currentBlockContent = this._blockRenderer(this._context, message, block);
1384
- if (currentBlockContent) {
1385
- let content = "";
1386
- if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
1387
- content = currentBlockContent.slice(this._currentBlockContent.length);
1388
- } else {
1389
- content = currentBlockContent;
1390
- }
1391
- void this._model.append(content);
1392
- this._currentBlockContent = currentBlockContent;
1393
- log5("append", {
1394
- message: i,
1395
- block: j,
1396
- content
1397
- }, {
1398
- F: __dxlog_file5,
1399
- L: 99,
1400
- S: this,
1401
- C: (f, a) => f(...a)
1402
- });
1403
- }
1404
- if (block.pending) {
1405
- return;
1406
- } else {
1407
- this._currentBlockContent = void 0;
1408
- this._currentBlockIndex++;
1409
- }
1410
- j++;
1411
- }
1412
- i++;
1413
- }
1414
- }
1415
- constructor(_model, _blockRenderer) {
1416
- _define_property2(this, "_model", void 0);
1417
- _define_property2(this, "_blockRenderer", void 0);
1418
- _define_property2(this, "_initialMessageId", void 0);
1419
- _define_property2(this, "_currentMessageIndex", void 0);
1420
- _define_property2(this, "_currentBlockIndex", void 0);
1421
- _define_property2(this, "_currentBlockContent", void 0);
1422
- _define_property2(this, "_context", void 0);
1423
- this._model = _model;
1424
- this._blockRenderer = _blockRenderer;
1425
- this._currentMessageIndex = 0;
1426
- this._currentBlockIndex = 0;
1427
- this._context = new MessageThreadContext(this._model);
1428
- }
1429
- };
1430
-
1431
- // src/components/ChatThread/ChatThread.tsx
1432
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, overscroll, onEvent }, forwardedRef) => {
1433
- var _effect = _useSignals10();
1434
- try {
1435
- const userHue = useMemo8(() => {
1436
- return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1437
- }, [
1438
- identity
1439
- ]);
1440
- const [controller, setController] = useState11(null);
1441
- useImperativeHandle(forwardedRef, () => controller ? controller : null, [
1442
- controller
1443
- ]);
1444
- useEffect5(() => {
1445
- controller?.scrollToBottom();
1446
- }, [
1447
- controller,
1448
- error
1449
- ]);
1450
- const syncer = useMemo8(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1451
- controller
1452
- ]);
1453
- useEffect5(() => {
1454
- syncer?.sync(messages);
1455
- }, [
1456
- syncer,
1457
- messages
1458
- ]);
1459
- const handleEvent = useCallback5((ev) => {
1460
- switch (ev.type) {
1461
- case "submit": {
1462
- ev.value && onEvent?.({
1463
- type: "submit",
1464
- text: ev.value
1465
- });
1466
- break;
1467
- }
1468
- }
1469
- }, [
1470
- onEvent
1471
- ]);
1472
- return /* @__PURE__ */ React8.createElement("div", {
1473
- className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
1474
- style: {
1475
- "--user-fill": `var(--dx-${userHue}Fill)`
1476
- }
1477
- }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1478
- ref: setController,
1479
- registry: componentRegistry,
1480
- cursor,
1481
- fadeIn,
1482
- overscroll,
1483
- onEvent: handleEvent
1484
- }));
1485
- } finally {
1486
- _effect.f();
1487
- }
1488
- });
1489
-
1490
- // src/components/Chat/Chat.tsx
1491
- var [ChatContextProvider, useChatContext] = createContext("Chat");
1492
- var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1493
- var _effect = _useSignals11();
1494
- try {
1495
- const [debug, setDebug] = useState12(false);
1496
- const space = getSpace(chat);
1497
- const queue = useQueue(chat?.queue.dxn);
1498
- const pending = useRxValue(processor.messages);
1499
- const streaming = useRxValue(processor.streaming);
1500
- const lastPrompt = useRef3(void 0);
1501
- const messages = useMemo9(() => {
1502
- const queueMessages = queue?.objects?.filter(Obj6.instanceOf(DataType2.Message)) ?? [];
1503
- return Array2.dedupeWith([
1504
- ...queueMessages,
1505
- ...pending
1506
- ], (a, b) => a.id === b.id);
1507
- }, [
1508
- queue?.objects,
1509
- pending
1510
- ]);
1511
- const event = useMemo9(() => new Event(), []);
1512
- useEffect6(() => {
1513
- return event.on((ev) => {
1514
- switch (ev.type) {
1515
- case "toggle-debug": {
1516
- setDebug((current) => !current);
1517
- break;
1518
- }
1519
- case "submit": {
1520
- const text = ev.text.trim();
1521
- if (!streaming && text.length) {
1522
- lastPrompt.current = ev.text;
1523
- void processor.request({
1524
- message: text
1525
- });
1526
- }
1527
- break;
1528
- }
1529
- case "retry": {
1530
- if (!streaming) {
1531
- void processor.retry();
1532
- }
1533
- break;
1534
- }
1535
- case "cancel": {
1536
- if (streaming) {
1537
- void processor.cancel();
1538
- if (lastPrompt.current) {
1539
- event.emit({
1540
- type: "update-prompt",
1541
- text: lastPrompt.current
1542
- });
1543
- }
1544
- }
1545
- break;
1546
- }
1547
- default: {
1548
- onEvent?.(ev);
1549
- }
1550
- }
1551
- });
1552
- }, [
1553
- event,
1554
- processor,
1555
- streaming,
1556
- onEvent
1557
- ]);
1558
- if (!space) {
1559
- return null;
1560
- }
1561
- return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1562
- debug,
1563
- event,
1564
- chat,
1565
- space,
1566
- messages,
1567
- processor,
1568
- ...props
1569
- }, /* @__PURE__ */ React9.createElement("div", {
1570
- role: "none",
1571
- className: mx5("flex flex-col bs-full is-full", classNames)
1572
- }, children));
1573
- } finally {
1574
- _effect.f();
1575
- }
1576
- };
1577
- ChatRoot.displayName = "Chat.Root";
1578
- var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1579
- var _effect = _useSignals11();
1580
- try {
1581
- const { t } = useTranslation5(meta.id);
1582
- const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1583
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1584
- const streaming = useRxValue(processor.streaming);
1585
- const active = useRxValue(processor.active);
1586
- const activeRef = useDynamicRef(active);
1587
- const editorRef = useRef3(null);
1588
- const [recordingState, setRecordingState] = useState12(false);
1589
- useEffect6(() => {
1590
- return event.on((event2) => {
1591
- switch (event2.type) {
1592
- case "update-prompt":
1593
- if (!editorRef.current?.getText()?.length) {
1594
- editorRef.current?.setText(event2.text);
1595
- editorRef.current?.focus();
1596
- }
1597
- break;
1598
- case "record-start":
1599
- setRecordingState(true);
1600
- break;
1601
- case "record-stop":
1602
- setRecordingState(false);
1603
- break;
1604
- }
1605
- });
1606
- }, [
1607
- event
1608
- ]);
1609
- const { recording } = useVoiceInput({
1610
- active: recordingState,
1611
- onUpdate: (text) => {
1612
- editorRef.current?.setText(text);
1613
- editorRef.current?.focus();
1614
- }
1615
- });
1616
- const referencesProvider = useReferencesProvider(space);
1617
- const extensions = useMemo9(() => {
1618
- return [
1619
- referencesProvider && references({
1620
- provider: referencesProvider
1621
- }),
1622
- Prec.highest(keymap.of([
1623
- {
1624
- key: "cmd-d",
1625
- preventDefault: true,
1626
- run: () => {
1627
- event.emit({
1628
- type: "toggle-debug"
1629
- });
1630
- return true;
1631
- }
1632
- },
1633
- expandable && {
1634
- key: "cmd-ArrowUp",
1635
- preventDefault: true,
1636
- run: () => {
1637
- event.emit({
1638
- type: "thread-open"
1639
- });
1640
- return true;
1641
- }
1642
- },
1643
- expandable && {
1644
- key: "cmd-ArrowDown",
1645
- preventDefault: true,
1646
- run: () => {
1647
- event.emit({
1648
- type: "thread-close"
1649
- });
1650
- return true;
1651
- }
1652
- }
1653
- ].filter(isTruthy)))
1654
- ].filter(isTruthy);
1655
- }, [
1656
- event,
1657
- expandable,
1658
- referencesProvider
1659
- ]);
1660
- const handleSubmit = useCallback6((text) => {
1661
- if (!activeRef.current) {
1662
- event.emit({
1663
- type: "submit",
1664
- text
1665
- });
1666
- return true;
1667
- }
1668
- }, [
1669
- event
1670
- ]);
1671
- const handleEvent = useCallback6((ev) => {
1672
- event.emit(ev);
1673
- }, [
1674
- event
1675
- ]);
1676
- return /* @__PURE__ */ React9.createElement("div", {
1677
- role: "group",
1678
- className: mx5("flex flex-col is-full density-fine", outline && [
1679
- "p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
1680
- ], classNames)
1681
- }, /* @__PURE__ */ React9.createElement("div", {
1682
- role: "none",
1683
- className: "flex gap-2"
1684
- }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1685
- classNames: "p-1",
1686
- preset,
1687
- error,
1688
- processing: streaming
1689
- }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1690
- ref: editorRef,
1691
- autoFocus: true,
1692
- lineWrapping: true,
1693
- classNames: "col-span-2 pbs-0.5",
1694
- placeholder: placeholder ?? t("prompt placeholder"),
1695
- extensions,
1696
- onSubmit: handleSubmit
1697
- })), settings && /* @__PURE__ */ React9.createElement("div", {
1698
- role: "none",
1699
- className: "flex pbs-2 items-center"
1700
- }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1701
- space,
1702
- blueprintRegistry: processor.blueprintRegistry,
1703
- context: processor.context,
1704
- preset,
1705
- presets,
1706
- onPresetChange
1707
- }), /* @__PURE__ */ React9.createElement("div", {
1708
- role: "none",
1709
- className: "pli-cardSpacingChrome grow"
1710
- }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1711
- space,
1712
- context: processor.context
1713
- })), /* @__PURE__ */ React9.createElement(ChatActions, {
1714
- classNames: "col-span-2",
1715
- microphone: true,
1716
- recording,
1717
- processing: streaming,
1718
- onEvent: handleEvent
1719
- }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
1720
- srOnly: true
1721
- }, t("online switch label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
1722
- classNames: "mis-2 mie-2",
1723
- checked: online,
1724
- onCheckedChange: onOnlineChange
1725
- })))));
1726
- } finally {
1727
- _effect.f();
1728
- }
1729
- };
1730
- ChatPrompt.displayName = "Chat.Prompt";
1731
- var ChatThread2 = (props) => {
1732
- var _effect = _useSignals11();
1733
- try {
1734
- const { event, messages, processor } = useChatContext(ChatThread2.displayName);
1735
- const identity = useIdentity();
1736
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1737
- const scrollerRef = useRef3(null);
1738
- useEffect6(() => {
1739
- return event.on((event2) => {
1740
- switch (event2.type) {
1741
- case "submit":
1742
- case "scroll-to-bottom":
1743
- scrollerRef.current?.scrollToBottom();
1744
- break;
1745
- }
1746
- });
1747
- }, [
1748
- event
1749
- ]);
1750
- const handleEvent = useCallback6((ev) => {
1751
- event.emit(ev);
1752
- }, [
1753
- event
1754
- ]);
1755
- if (!identity) {
1756
- return null;
1757
- }
1758
- return /* @__PURE__ */ React9.createElement(ChatThread, {
1759
- ...props,
1760
- ref: scrollerRef,
1761
- identity,
1762
- messages,
1763
- error,
1764
- onEvent: handleEvent
1765
- });
1766
- } finally {
1767
- _effect.f();
1768
- }
1769
- };
1770
- ChatThread2.displayName = "Chat.Thread";
1771
- var Chat = {
1772
- Root: ChatRoot,
1773
- Prompt: ChatPrompt,
1774
- Thread: ChatThread2
1775
- };
1776
-
1777
- export {
1778
- useBlueprintRegistry,
1779
- useBlueprints,
1780
- useActiveBlueprints,
1781
- useBlueprintHandlers,
1782
- useChatProcessor,
1783
- useChatServices,
1784
- useContextBinder,
1785
- useContextObjects,
1786
- useFlush,
1787
- useItemTypes,
1788
- useOnline,
1789
- usePresets,
1790
- useReferencesProvider,
1791
- ChatContextProvider,
1792
- useChatContext,
1793
- Chat
1794
- };
1795
- //# sourceMappingURL=chunk-UFKLCEAE.mjs.map