@dxos/plugin-assistant 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5

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 (676) 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/blueprints/index.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-ATHYBVGN.mjs +176 -0
  6. package/dist/lib/browser/chunk-ATHYBVGN.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-EZRS3J25.mjs +30 -0
  8. package/dist/lib/browser/chunk-EZRS3J25.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  10. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-LMVTXH54.mjs +154 -0
  12. package/dist/lib/browser/chunk-LMVTXH54.mjs.map +7 -0
  13. package/dist/lib/browser/create-chat-LBZHGVSN.mjs +82 -0
  14. package/dist/lib/browser/create-chat-LBZHGVSN.mjs.map +7 -0
  15. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs +65 -0
  16. package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +3410 -223
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/on-create-space-54RNX5JI.mjs +22 -0
  21. package/dist/lib/browser/on-create-space-54RNX5JI.mjs.map +7 -0
  22. package/dist/lib/browser/operations/index.mjs +13 -0
  23. package/dist/lib/browser/operations/index.mjs.map +7 -0
  24. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs +22 -0
  25. package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs.map +7 -0
  26. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs +136 -0
  27. package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs.map +7 -0
  28. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs +54 -0
  29. package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs.map +7 -0
  30. package/dist/lib/browser/types/index.mjs +8 -14
  31. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs +71 -0
  32. package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs.map +7 -0
  33. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs +98 -0
  34. package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs.map +7 -0
  35. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  36. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  38. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +32 -0
  40. package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs +177 -0
  42. package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs +155 -0
  44. package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs.map +7 -0
  45. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs +83 -0
  46. package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs.map +7 -0
  47. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs +66 -0
  48. package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +3410 -223
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/meta.json +1 -1
  52. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs +23 -0
  53. package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs.map +7 -0
  54. package/dist/lib/node-esm/operations/index.mjs +14 -0
  55. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  56. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs +23 -0
  57. package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs.map +7 -0
  58. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs +137 -0
  59. package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs.map +7 -0
  60. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs +55 -0
  61. package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs.map +7 -0
  62. package/dist/lib/node-esm/types/index.mjs +8 -14
  63. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs +72 -0
  64. package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs.map +7 -0
  65. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  66. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  67. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  68. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  69. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  70. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  71. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  72. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  73. package/dist/types/src/blueprints/index.d.ts +2 -0
  74. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  75. package/dist/types/src/capabilities/ai-service.d.ts +6 -0
  76. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  78. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  79. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  80. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
  82. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
  83. package/dist/types/src/capabilities/edge-model-resolver.d.ts +7 -0
  84. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  85. package/dist/types/src/capabilities/index.d.ts +29 -6
  86. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/local-model-resolver.d.ts +16 -0
  88. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/markdown.d.ts +5 -0
  90. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/migrations.d.ts +5 -0
  92. package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  94. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  96. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/settings.d.ts +4 -2
  98. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/state.d.ts +21 -0
  100. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/toolkit.d.ts +6 -0
  102. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  103. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -4
  104. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  105. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -0
  106. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
  107. package/dist/types/src/components/AssistantSettings/index.d.ts +1 -1
  108. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
  109. package/dist/types/src/components/Chat/Chat.d.ts +41 -19
  110. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  111. package/dist/types/src/components/Chat/events.d.ts +39 -0
  112. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  113. package/dist/types/src/components/Chat/index.d.ts +1 -0
  114. package/dist/types/src/components/Chat/index.d.ts.map +1 -1
  115. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +10 -0
  116. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  117. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  118. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  119. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +7 -5
  120. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  121. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +22 -0
  122. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  123. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
  124. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
  125. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  126. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  127. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +5 -6
  128. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  129. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +7 -4
  130. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  131. package/dist/types/src/components/ChatPrompt/index.d.ts +2 -2
  132. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  133. package/dist/types/src/components/ChatThread/ChatThread.d.ts +13 -17
  134. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  135. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +24 -221
  136. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  137. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  138. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  139. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts +35 -0
  140. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
  141. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  142. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  143. package/dist/types/src/components/ChatThread/sync.d.ts +43 -0
  144. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  145. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  146. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  147. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
  148. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
  150. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
  151. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
  152. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
  153. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts +14 -0
  154. package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts.map +1 -0
  155. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
  156. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
  157. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts +18 -0
  158. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -0
  159. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
  160. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
  161. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
  162. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
  163. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
  164. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
  165. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +25 -0
  166. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -0
  167. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
  168. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
  169. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
  170. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
  171. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
  172. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
  173. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts +15 -0
  174. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
  175. package/dist/types/src/components/ChatThread/widgets/index.d.ts +11 -0
  176. package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
  177. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +10 -0
  178. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
  179. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
  180. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
  181. package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
  182. package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
  183. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +9 -11
  184. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  185. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +13 -7
  186. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  187. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +16 -5
  188. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  189. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +10 -2
  190. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  191. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
  192. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  193. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  194. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  195. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  196. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  197. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +12 -0
  198. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  199. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  200. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  201. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  202. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  203. package/dist/types/src/components/Toolbox/Toolbox.d.ts +17 -21
  204. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  205. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +14 -5
  206. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  207. package/dist/types/src/components/index.d.ts +3 -8
  208. package/dist/types/src/components/index.d.ts.map +1 -1
  209. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
  210. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
  211. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
  212. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
  213. package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
  214. package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
  215. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
  216. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
  217. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
  218. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
  219. package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
  220. package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
  221. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  222. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  223. package/dist/types/src/containers/BlueprintArticle/index.d.ts +2 -0
  224. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  225. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +18 -0
  226. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  227. package/dist/types/src/containers/ChatCompanion/index.d.ts +2 -0
  228. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  229. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +12 -0
  230. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  231. package/dist/types/src/containers/ChatContainer/index.d.ts +2 -0
  232. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  233. package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
  234. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  235. package/dist/types/src/containers/ChatDialog/index.d.ts +2 -0
  236. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  237. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
  238. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
  239. package/dist/types/src/containers/PromptArticle/index.d.ts +2 -0
  240. package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
  241. package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
  242. package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
  243. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +21 -0
  244. package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
  245. package/dist/types/src/containers/PromptList/index.d.ts +2 -0
  246. package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
  247. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +9 -0
  248. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  249. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +15 -0
  250. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -0
  251. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  252. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  253. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  254. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  255. package/dist/types/src/containers/TracePanel/execution-graph.d.ts +17 -0
  256. package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
  257. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  258. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  259. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
  260. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  261. package/dist/types/src/containers/TriggerStatus/index.d.ts +2 -0
  262. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  263. package/dist/types/src/containers/index.d.ts +12 -0
  264. package/dist/types/src/containers/index.d.ts.map +1 -0
  265. package/dist/types/src/extensions/index.d.ts +2 -0
  266. package/dist/types/src/extensions/index.d.ts.map +1 -0
  267. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  268. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  269. package/dist/types/src/hooks/index.d.ts +10 -5
  270. package/dist/types/src/hooks/index.d.ts.map +1 -1
  271. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  272. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  273. package/dist/types/src/hooks/useChatProcessor.d.ts +12 -24
  274. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  275. package/dist/types/src/hooks/useChatServices.d.ts +10 -0
  276. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  277. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  278. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  279. package/dist/types/src/hooks/useContextBinder.d.ts +5 -0
  280. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  281. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  282. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  283. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  284. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  285. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  286. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  287. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  288. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  289. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  290. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  291. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  292. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  293. package/dist/types/src/index.d.ts +3 -2
  294. package/dist/types/src/index.d.ts.map +1 -1
  295. package/dist/types/src/meta.d.ts +5 -4
  296. package/dist/types/src/meta.d.ts.map +1 -1
  297. package/dist/types/src/operations/create-chat.d.ts +5 -0
  298. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  299. package/dist/types/src/operations/definitions.d.ts +135 -0
  300. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  301. package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
  302. package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
  303. package/dist/types/src/operations/index.d.ts +4 -0
  304. package/dist/types/src/operations/index.d.ts.map +1 -0
  305. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  306. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  307. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  308. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  309. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  310. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  311. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  312. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  313. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  314. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  315. package/dist/types/src/processor/index.d.ts +3 -0
  316. package/dist/types/src/processor/index.d.ts.map +1 -0
  317. package/dist/types/src/processor/presets.d.ts +13 -0
  318. package/dist/types/src/processor/presets.d.ts.map +1 -0
  319. package/dist/types/src/processor/processor.d.ts +80 -0
  320. package/dist/types/src/processor/processor.d.ts.map +1 -0
  321. package/dist/types/src/processor/processor.test.d.ts +2 -0
  322. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  323. package/dist/types/src/queue-logger.d.ts.map +1 -1
  324. package/dist/types/src/testing/index.d.ts +1 -1
  325. package/dist/types/src/testing/index.d.ts.map +1 -1
  326. package/dist/types/src/testing/test-generator.d.ts +8 -0
  327. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  328. package/dist/types/src/testing/test-sequence.d.ts +0 -4
  329. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  330. package/dist/types/src/testing/test-services.d.ts +2 -2
  331. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  332. package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
  333. package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
  334. package/dist/types/src/translations.d.ts +2 -64
  335. package/dist/types/src/translations.d.ts.map +1 -1
  336. package/dist/types/src/types/Assistant.d.ts +20 -0
  337. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  338. package/dist/types/src/types/Settings.d.ts +11 -0
  339. package/dist/types/src/types/Settings.d.ts.map +1 -0
  340. package/dist/types/src/types/capabilities.d.ts +32 -0
  341. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  342. package/dist/types/src/types/defs.d.ts +2 -0
  343. package/dist/types/src/types/defs.d.ts.map +1 -0
  344. package/dist/types/src/types/events.d.ts +5 -0
  345. package/dist/types/src/types/events.d.ts.map +1 -0
  346. package/dist/types/src/types/index.d.ts +5 -2
  347. package/dist/types/src/types/index.d.ts.map +1 -1
  348. package/dist/types/src/types/service.d.ts +14 -213
  349. package/dist/types/src/types/service.d.ts.map +1 -1
  350. package/dist/types/tsconfig.tsbuildinfo +1 -1
  351. package/package.json +151 -93
  352. package/src/AssistantPlugin.tsx +222 -114
  353. package/src/blueprints/assistant/blueprint.test.ts +46 -0
  354. package/src/blueprints/assistant/blueprint.ts +31 -0
  355. package/src/blueprints/assistant/index.ts +5 -0
  356. package/src/{components/SequenceEditor → blueprints}/index.ts +1 -1
  357. package/src/capabilities/ai-service.ts +30 -0
  358. package/src/capabilities/app-graph-builder.ts +192 -227
  359. package/src/capabilities/blueprint-definition.ts +58 -0
  360. package/src/capabilities/companion-chat-provisioner.ts +164 -0
  361. package/src/capabilities/edge-model-resolver.ts +33 -0
  362. package/src/capabilities/index.ts +21 -8
  363. package/src/capabilities/local-model-resolver.ts +48 -0
  364. package/src/capabilities/markdown.ts +40 -0
  365. package/src/capabilities/migrations.ts +35 -0
  366. package/src/capabilities/operation-handler.ts +16 -0
  367. package/src/capabilities/react-surface.tsx +140 -123
  368. package/src/capabilities/settings.ts +24 -12
  369. package/src/capabilities/state.ts +35 -0
  370. package/src/capabilities/toolkit.ts +13 -0
  371. package/src/components/AssistantSettings/AssistantSettings.stories.tsx +34 -0
  372. package/src/components/AssistantSettings/AssistantSettings.tsx +102 -75
  373. package/src/components/AssistantSettings/index.ts +2 -2
  374. package/src/components/Chat/Chat.tsx +310 -184
  375. package/src/components/Chat/events.ts +63 -0
  376. package/src/components/Chat/index.ts +2 -0
  377. package/src/components/ChatProgress/ChatProgress.tsx +56 -0
  378. package/src/components/ChatProgress/index.ts +5 -0
  379. package/src/components/ChatPrompt/ChatActions.tsx +46 -47
  380. package/src/components/ChatPrompt/ChatOptions.stories.tsx +122 -0
  381. package/src/components/ChatPrompt/ChatOptions.tsx +404 -0
  382. package/src/components/ChatPrompt/ChatPresets.tsx +29 -0
  383. package/src/components/ChatPrompt/ChatReferences.tsx +42 -37
  384. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +33 -17
  385. package/src/components/ChatPrompt/index.ts +2 -3
  386. package/src/components/ChatThread/ChatThread.stories.tsx +120 -125
  387. package/src/components/ChatThread/ChatThread.tsx +80 -50
  388. package/src/components/ChatThread/Link.tsx +26 -0
  389. package/src/components/ChatThread/MarkdownStream.stories.tsx +243 -0
  390. package/src/components/ChatThread/registry.tsx +238 -0
  391. package/src/components/ChatThread/sync.test.ts +99 -0
  392. package/src/components/ChatThread/sync.ts +165 -0
  393. package/src/components/ChatThread/testing/thinking.md +21 -0
  394. package/src/components/ChatThread/testing/thread-1.md +30 -0
  395. package/src/components/ChatThread/testing/thread-2.md +56 -0
  396. package/src/components/ChatThread/testing/thread-widgets.md +79 -0
  397. package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
  398. package/src/components/ChatThread/tool-widget-state.ts +48 -0
  399. package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
  400. package/src/components/ChatThread/widgets/PromptWidget.ts +28 -0
  401. package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
  402. package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
  403. package/src/components/ChatThread/widgets/ReferenceWidget.ts +31 -0
  404. package/src/components/ChatThread/widgets/SelectWidget.ts +37 -0
  405. package/src/components/ChatThread/widgets/StatsWidget.ts +29 -0
  406. package/src/components/ChatThread/widgets/StatusWidget.ts +133 -0
  407. package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
  408. package/src/components/ChatThread/widgets/SummaryWidget.tsx +28 -0
  409. package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +54 -0
  410. package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
  411. package/src/components/ChatThread/widgets/index.ts +14 -0
  412. package/src/components/ProcessTree/ProcessTree.stories.tsx +109 -0
  413. package/src/components/ProcessTree/ProcessTree.tsx +86 -0
  414. package/src/components/ProcessTree/index.ts +5 -0
  415. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +54 -43
  416. package/src/components/TemplateEditor/TemplateEditor.tsx +62 -60
  417. package/src/components/TemplateEditor/TemplateForm.stories.tsx +39 -25
  418. package/src/components/TemplateEditor/TemplateForm.tsx +123 -81
  419. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  420. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  421. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  422. package/src/components/ToolBlock/ToolBlock.tsx +144 -0
  423. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  424. package/src/components/ToolBlock/index.ts +6 -0
  425. package/src/components/Toolbox/Toolbox.stories.tsx +17 -29
  426. package/src/components/Toolbox/Toolbox.tsx +88 -110
  427. package/src/components/index.ts +3 -11
  428. package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
  429. package/src/containers/AgentArticle/AgentArticle.tsx +198 -0
  430. package/src/containers/AgentArticle/index.ts +5 -0
  431. package/src/containers/AgentProperties/AgentProperties.stories.tsx +100 -0
  432. package/src/containers/AgentProperties/AgentProperties.tsx +158 -0
  433. package/src/containers/AgentProperties/index.ts +5 -0
  434. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
  435. package/src/containers/BlueprintArticle/index.ts +5 -0
  436. package/src/containers/ChatCompanion/ChatCompanion.tsx +142 -0
  437. package/src/containers/ChatCompanion/index.ts +5 -0
  438. package/src/containers/ChatContainer/ChatContainer.tsx +95 -0
  439. package/src/containers/ChatContainer/index.ts +5 -0
  440. package/src/containers/ChatDialog/ChatDialog.tsx +72 -0
  441. package/src/containers/ChatDialog/index.ts +5 -0
  442. package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
  443. package/src/containers/PromptArticle/index.ts +5 -0
  444. package/src/containers/PromptList/PromptList.stories.tsx +129 -0
  445. package/src/containers/PromptList/PromptList.tsx +49 -0
  446. package/src/containers/PromptList/index.ts +5 -0
  447. package/src/containers/TracePanel/TracePanel.stories.tsx +230 -0
  448. package/src/containers/TracePanel/TracePanel.tsx +114 -0
  449. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  450. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  451. package/src/containers/TracePanel/execution-graph.ts +425 -0
  452. package/src/containers/TracePanel/index.ts +9 -0
  453. package/src/containers/TriggerStatus/TriggerStatus.tsx +144 -0
  454. package/src/containers/TriggerStatus/index.ts +5 -0
  455. package/src/containers/index.ts +16 -0
  456. package/src/extensions/index.ts +5 -0
  457. package/src/extensions/prompt-extension.ts +111 -0
  458. package/src/hooks/index.ts +10 -6
  459. package/src/hooks/useBlueprintRegistry.ts +109 -0
  460. package/src/hooks/useChatProcessor.ts +90 -0
  461. package/src/hooks/useChatServices.ts +26 -0
  462. package/src/hooks/useChatToolbarActions.ts +122 -0
  463. package/src/hooks/useContextBinder.ts +43 -0
  464. package/src/hooks/useContextObjects.ts +50 -0
  465. package/src/hooks/useFilteredTypes.ts +37 -0
  466. package/src/hooks/useFlush.ts +35 -0
  467. package/src/hooks/useOnline.ts +10 -0
  468. package/src/hooks/usePresets.ts +45 -0
  469. package/src/hooks/useReferencesProvider.ts +54 -0
  470. package/src/index.ts +3 -2
  471. package/src/meta.ts +15 -9
  472. package/src/operations/create-chat.ts +80 -0
  473. package/src/operations/definitions.ts +127 -0
  474. package/src/operations/ensure-companion-chat.ts +61 -0
  475. package/src/operations/index.ts +17 -0
  476. package/src/operations/on-create-space.ts +24 -0
  477. package/src/operations/resolve-navigation-targets.ts +26 -0
  478. package/src/operations/run-prompt-in-new-chat.ts +113 -0
  479. package/src/operations/set-current-chat.ts +50 -0
  480. package/src/operations/update-chat-name.ts +61 -0
  481. package/src/processor/index.ts +6 -0
  482. package/src/processor/presets.ts +68 -0
  483. package/src/processor/processor.test.ts +40 -0
  484. package/src/processor/processor.ts +321 -0
  485. package/src/queue-logger.ts +33 -23
  486. package/src/testing/index.ts +1 -1
  487. package/src/testing/test-generator.ts +293 -0
  488. package/src/testing/test-sequence.ts +5 -32
  489. package/src/testing/test-services.ts +10 -14
  490. package/src/testing/trace-timeline.conversations.json +1 -0
  491. package/src/testing/trace-timeline.test.ts +246 -0
  492. package/src/translations.ts +166 -55
  493. package/src/types/Assistant.ts +14 -0
  494. package/src/types/Settings.ts +21 -0
  495. package/src/types/capabilities.ts +35 -0
  496. package/src/types/defs.ts +5 -0
  497. package/src/types/events.ts +11 -0
  498. package/src/types/index.ts +8 -2
  499. package/src/types/service.ts +27 -16
  500. package/src/vite-env.d.ts +30 -0
  501. package/dist/lib/browser/ChatContainer-6XNB5NEI.mjs +0 -57
  502. package/dist/lib/browser/ChatContainer-6XNB5NEI.mjs.map +0 -7
  503. package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs +0 -74
  504. package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs.map +0 -7
  505. package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs +0 -322
  506. package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs.map +0 -7
  507. package/dist/lib/browser/TemplateContainer-6ZGGH5T4.mjs +0 -28
  508. package/dist/lib/browser/TemplateContainer-6ZGGH5T4.mjs.map +0 -7
  509. package/dist/lib/browser/ai-client-ML7OQWAO.mjs +0 -39
  510. package/dist/lib/browser/ai-client-ML7OQWAO.mjs.map +0 -7
  511. package/dist/lib/browser/app-graph-builder-UJ5NHRGK.mjs +0 -223
  512. package/dist/lib/browser/app-graph-builder-UJ5NHRGK.mjs.map +0 -7
  513. package/dist/lib/browser/chunk-44HZKIAW.mjs +0 -87
  514. package/dist/lib/browser/chunk-44HZKIAW.mjs.map +0 -7
  515. package/dist/lib/browser/chunk-LKP65RPA.mjs +0 -20
  516. package/dist/lib/browser/chunk-LKP65RPA.mjs.map +0 -7
  517. package/dist/lib/browser/chunk-NTBGTFTV.mjs +0 -15
  518. package/dist/lib/browser/chunk-NTBGTFTV.mjs.map +0 -7
  519. package/dist/lib/browser/chunk-OZL4OHTU.mjs +0 -157
  520. package/dist/lib/browser/chunk-OZL4OHTU.mjs.map +0 -7
  521. package/dist/lib/browser/chunk-TQ3QW3HJ.mjs +0 -2072
  522. package/dist/lib/browser/chunk-TQ3QW3HJ.mjs.map +0 -7
  523. package/dist/lib/browser/chunk-TU7UUGWQ.mjs +0 -203
  524. package/dist/lib/browser/chunk-TU7UUGWQ.mjs.map +0 -7
  525. package/dist/lib/browser/chunk-WPZ4UANI.mjs +0 -16
  526. package/dist/lib/browser/chunk-WPZ4UANI.mjs.map +0 -7
  527. package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs +0 -42
  528. package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs.map +0 -7
  529. package/dist/lib/browser/react-surface-TMF7JJA4.mjs +0 -156
  530. package/dist/lib/browser/react-surface-TMF7JJA4.mjs.map +0 -7
  531. package/dist/lib/browser/settings-N4HEXADL.mjs +0 -22
  532. package/dist/lib/browser/settings-N4HEXADL.mjs.map +0 -7
  533. package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs +0 -58
  534. package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs.map +0 -7
  535. package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs +0 -75
  536. package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs.map +0 -7
  537. package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs +0 -323
  538. package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs.map +0 -7
  539. package/dist/lib/node-esm/TemplateContainer-6KRNEMVE.mjs +0 -29
  540. package/dist/lib/node-esm/TemplateContainer-6KRNEMVE.mjs.map +0 -7
  541. package/dist/lib/node-esm/ai-client-2FQ434CT.mjs +0 -40
  542. package/dist/lib/node-esm/ai-client-2FQ434CT.mjs.map +0 -7
  543. package/dist/lib/node-esm/app-graph-builder-MEQ5CYNI.mjs +0 -224
  544. package/dist/lib/node-esm/app-graph-builder-MEQ5CYNI.mjs.map +0 -7
  545. package/dist/lib/node-esm/chunk-D3HTVK5D.mjs +0 -2073
  546. package/dist/lib/node-esm/chunk-D3HTVK5D.mjs.map +0 -7
  547. package/dist/lib/node-esm/chunk-E6V2RUQ2.mjs +0 -16
  548. package/dist/lib/node-esm/chunk-E6V2RUQ2.mjs.map +0 -7
  549. package/dist/lib/node-esm/chunk-HVMVHP4R.mjs +0 -158
  550. package/dist/lib/node-esm/chunk-HVMVHP4R.mjs.map +0 -7
  551. package/dist/lib/node-esm/chunk-HXKRKIN2.mjs +0 -18
  552. package/dist/lib/node-esm/chunk-HXKRKIN2.mjs.map +0 -7
  553. package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +0 -22
  554. package/dist/lib/node-esm/chunk-KOC6ESG7.mjs.map +0 -7
  555. package/dist/lib/node-esm/chunk-VESVUAOS.mjs +0 -88
  556. package/dist/lib/node-esm/chunk-VESVUAOS.mjs.map +0 -7
  557. package/dist/lib/node-esm/chunk-YYUVTTVK.mjs +0 -204
  558. package/dist/lib/node-esm/chunk-YYUVTTVK.mjs.map +0 -7
  559. package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs +0 -43
  560. package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs.map +0 -7
  561. package/dist/lib/node-esm/react-surface-6XL6SWL2.mjs +0 -157
  562. package/dist/lib/node-esm/react-surface-6XL6SWL2.mjs.map +0 -7
  563. package/dist/lib/node-esm/settings-WQ76EG6O.mjs +0 -23
  564. package/dist/lib/node-esm/settings-WQ76EG6O.mjs.map +0 -7
  565. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  566. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  567. package/dist/types/src/capabilities/capabilities.d.ts +0 -6
  568. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  569. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  570. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  571. package/dist/types/src/components/ChatContainer.d.ts +0 -11
  572. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  573. package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
  574. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
  575. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
  576. package/dist/types/src/components/ChatPrompt/events.d.ts +0 -17
  577. package/dist/types/src/components/ChatPrompt/events.d.ts.map +0 -1
  578. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -18
  579. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
  580. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -18
  581. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
  582. package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
  583. package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
  584. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  585. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  586. package/dist/types/src/components/SequenceContainer.d.ts +0 -9
  587. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  588. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  589. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  590. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -8
  591. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  592. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  593. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  594. package/dist/types/src/components/TemplateContainer.d.ts +0 -9
  595. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  596. package/dist/types/src/events.d.ts +0 -4
  597. package/dist/types/src/events.d.ts.map +0 -1
  598. package/dist/types/src/hooks/chat-processor.d.ts +0 -82
  599. package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
  600. package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
  601. package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
  602. package/dist/types/src/hooks/useBlueprints.d.ts +0 -4
  603. package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
  604. package/dist/types/src/hooks/useContextProvider.d.ts +0 -23
  605. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  606. package/dist/types/src/hooks/useServiceContainer.d.ts +0 -8
  607. package/dist/types/src/hooks/useServiceContainer.d.ts.map +0 -1
  608. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  609. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  610. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  611. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  612. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  613. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  614. package/dist/types/src/parser/index.d.ts +0 -4
  615. package/dist/types/src/parser/index.d.ts.map +0 -1
  616. package/dist/types/src/parser/query-parser.d.ts +0 -15
  617. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  618. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  619. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  620. package/dist/types/src/parser/types.d.ts +0 -24
  621. package/dist/types/src/parser/types.d.ts.map +0 -1
  622. package/dist/types/src/stories/Chat.stories.d.ts +0 -199
  623. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  624. package/dist/types/src/testing/test-functions.d.ts +0 -3
  625. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  626. package/dist/types/src/tools/function.d.ts +0 -5
  627. package/dist/types/src/tools/function.d.ts.map +0 -1
  628. package/dist/types/src/tools/index.d.ts +0 -3
  629. package/dist/types/src/tools/index.d.ts.map +0 -1
  630. package/dist/types/src/tools/openapi.d.ts +0 -10
  631. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  632. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  633. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  634. package/dist/types/src/types/schema.d.ts +0 -71
  635. package/dist/types/src/types/schema.d.ts.map +0 -1
  636. package/dist/types/src/types/template.d.ts +0 -56
  637. package/dist/types/src/types/template.d.ts.map +0 -1
  638. package/src/capabilities/ai-client.ts +0 -39
  639. package/src/capabilities/capabilities.ts +0 -14
  640. package/src/capabilities/intent-resolver.ts +0 -45
  641. package/src/components/ChatContainer.tsx +0 -45
  642. package/src/components/ChatDialog.tsx +0 -65
  643. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
  644. package/src/components/ChatPrompt/events.ts +0 -12
  645. package/src/components/ChatThread/ChatMessage.tsx +0 -238
  646. package/src/components/ChatThread/ToolBlock.tsx +0 -111
  647. package/src/components/ChatThread/reducer.ts +0 -52
  648. package/src/components/PromptSettings.tsx +0 -91
  649. package/src/components/SequenceContainer.tsx +0 -139
  650. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
  651. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  652. package/src/components/TemplateContainer.tsx +0 -25
  653. package/src/events.ts +0 -11
  654. package/src/hooks/chat-processor.test.ts +0 -15
  655. package/src/hooks/chat-processor.ts +0 -281
  656. package/src/hooks/useBlueprints.ts +0 -31
  657. package/src/hooks/useChatProcessor.tsx +0 -142
  658. package/src/hooks/useContextProvider.ts +0 -61
  659. package/src/hooks/useServiceContainer.ts +0 -42
  660. package/src/hooks/useTextInputEvents.ts +0 -49
  661. package/src/parser/filter-generator.test.ts +0 -32
  662. package/src/parser/filter-generator.ts +0 -81
  663. package/src/parser/index.ts +0 -7
  664. package/src/parser/query-parser.test.ts +0 -139
  665. package/src/parser/query-parser.ts +0 -199
  666. package/src/parser/types.ts +0 -34
  667. package/src/shims.d.ts +0 -8
  668. package/src/stories/Chat.stories.tsx +0 -269
  669. package/src/testing/test-functions.ts +0 -11
  670. package/src/tools/function.ts +0 -46
  671. package/src/tools/index.ts +0 -6
  672. package/src/tools/openapi.test.ts +0 -217
  673. package/src/tools/openapi.ts +0 -338
  674. package/src/types/schema.ts +0 -86
  675. package/src/types/template.ts +0 -66
  676. package/src/typings.d.ts +0 -9
@@ -1,2073 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ServiceType
4
- } from "./chunk-YYUVTTVK.mjs";
5
- import {
6
- AssistantCapabilities
7
- } from "./chunk-E6V2RUQ2.mjs";
8
- import {
9
- meta
10
- } from "./chunk-KOC6ESG7.mjs";
11
-
12
- // src/hooks/useChatProcessor.tsx
13
- import { useEffect as useEffect2, useMemo as useMemo3, useState as useState4 } from "react";
14
- import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/ai";
15
- import { Capabilities as Capabilities3, useCapabilities as useCapabilities3, useIntentDispatcher } from "@dxos/app-framework";
16
- import { createSystemPrompt } from "@dxos/artifact";
17
- import { Conversation } from "@dxos/assistant";
18
- import { FunctionType } from "@dxos/functions";
19
- import { log as log5 } from "@dxos/log";
20
- import { useConfig } from "@dxos/react-client";
21
- import { Filter as Filter3, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
22
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
23
-
24
- // src/hooks/chat-processor.ts
25
- import { batch, computed, signal } from "@preact/signals-core";
26
- import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
27
- import { Context } from "@dxos/context";
28
- import { log } from "@dxos/log";
29
- import { Filter, getVersion } from "@dxos/react-client/echo";
30
- function _ts_add_disposable_resource(env, value, async) {
31
- if (value !== null && value !== void 0) {
32
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
33
- var dispose, inner;
34
- if (async) {
35
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
36
- dispose = value[Symbol.asyncDispose];
37
- }
38
- if (dispose === void 0) {
39
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
40
- dispose = value[Symbol.dispose];
41
- if (async) inner = dispose;
42
- }
43
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
44
- if (inner) dispose = function() {
45
- try {
46
- inner.call(this);
47
- } catch (e) {
48
- return Promise.reject(e);
49
- }
50
- };
51
- env.stack.push({
52
- value,
53
- dispose,
54
- async
55
- });
56
- } else if (async) {
57
- env.stack.push({
58
- async: true
59
- });
60
- }
61
- return value;
62
- }
63
- function _ts_dispose_resources(env) {
64
- var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
65
- var e = new Error(message);
66
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
67
- };
68
- return (_ts_dispose_resources = function _ts_dispose_resources2(env2) {
69
- function fail(e) {
70
- env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
71
- env2.hasError = true;
72
- }
73
- var r, s = 0;
74
- function next() {
75
- while (r = env2.stack.pop()) {
76
- try {
77
- if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
78
- if (r.dispose) {
79
- var result = r.dispose.call(r.value);
80
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
81
- fail(e);
82
- return next();
83
- });
84
- } else s |= 1;
85
- } catch (e) {
86
- fail(e);
87
- }
88
- }
89
- if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
90
- if (env2.hasError) throw env2.error;
91
- }
92
- return next();
93
- })(env);
94
- }
95
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
96
- var defaultOptions = {
97
- model: DEFAULT_EDGE_MODEL,
98
- systemPrompt: "you are a helpful assistant"
99
- };
100
- var ChatProcessor = class {
101
- constructor(_conversation, _options = defaultOptions) {
102
- this._conversation = _conversation;
103
- this._options = _options;
104
- this._pending = signal([]);
105
- this._block = signal(void 0);
106
- this.streaming = computed(() => this._block.value !== void 0);
107
- this.error = signal(void 0);
108
- this.messages = computed(() => {
109
- const messages = [
110
- ...this._pending.value
111
- ];
112
- if (this._block.value && messages.length) {
113
- const { content, ...rest } = messages.pop();
114
- const message = {
115
- ...rest,
116
- content: [
117
- ...content,
118
- this._block.value
119
- ]
120
- };
121
- messages.push(message);
122
- }
123
- return messages;
124
- });
125
- this._session = void 0;
126
- this._artifactDiffResolver = async (artifacts) => {
127
- const space = this._options.extensions?.space;
128
- if (!space) {
129
- return /* @__PURE__ */ new Map();
130
- }
131
- const versions = /* @__PURE__ */ new Map();
132
- await Promise.all(artifacts.map(async (artifact) => {
133
- const { objects: [object] } = await space.db.query(Filter.ids(artifact.id)).run();
134
- if (!object) {
135
- return;
136
- }
137
- versions.set(artifact.id, {
138
- version: getVersion(object),
139
- diff: `Current state: ${JSON.stringify(object)}`
140
- });
141
- }));
142
- return versions;
143
- };
144
- this._tools = [
145
- ..._options.tools ?? []
146
- ];
147
- }
148
- get conversation() {
149
- return this._conversation;
150
- }
151
- get context() {
152
- return this._conversation.context;
153
- }
154
- get blueprintRegistry() {
155
- return this._options.blueprintRegistry;
156
- }
157
- get tools() {
158
- return this._tools;
159
- }
160
- /**
161
- * @deprecated Replace with blueprints
162
- */
163
- setTools(tools) {
164
- this._tools = tools;
165
- }
166
- /**
167
- * Make GPT request.
168
- */
169
- async request(message, options = {}) {
170
- const env = {
171
- stack: [],
172
- error: void 0,
173
- hasError: false
174
- };
175
- try {
176
- const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
177
- F: __dxlog_file,
178
- L: 140
179
- }), true);
180
- this._conversation.onBegin.on(ctx, (session) => {
181
- log.info("onBegin", {
182
- session,
183
- isDisposed: ctx.disposed
184
- }, {
185
- F: __dxlog_file,
186
- L: 143,
187
- S: this,
188
- C: (f, a) => f(...a)
189
- });
190
- this._session = session;
191
- ctx.onDispose(() => {
192
- log.info("onDispose", {
193
- session,
194
- isDisposed: ctx.disposed
195
- }, {
196
- F: __dxlog_file,
197
- L: 147,
198
- S: this,
199
- C: (f, a) => f(...a)
200
- });
201
- if (this._session === session) {
202
- this._session = void 0;
203
- }
204
- });
205
- session.message.on((message2) => {
206
- batch(() => {
207
- this._pending.value = [
208
- ...this._pending.value,
209
- message2
210
- ];
211
- this._block.value = void 0;
212
- });
213
- });
214
- session.update.on((block) => {
215
- batch(() => {
216
- this._block.value = block;
217
- });
218
- });
219
- session.userMessage.on((message2) => {
220
- log.info("userMessage", {
221
- message: message2
222
- }, {
223
- F: __dxlog_file,
224
- L: 169,
225
- S: this,
226
- C: (f, a) => f(...a)
227
- });
228
- this._pending.value = [
229
- ...this._pending.value,
230
- message2
231
- ];
232
- });
233
- session.toolStatusReport.on(({ message: message2, status }) => {
234
- const msg = this._pending.peek().find((m) => m.id === message2.id);
235
- const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
236
- if (!toolUse) {
237
- return;
238
- }
239
- const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
240
- if (block) {
241
- this._pending.value = this._pending.value.map((m) => {
242
- if (m.id === message2.id) {
243
- return {
244
- ...m,
245
- content: m.content.map((block2) => block2.type === "tool_use" && block2.id === toolUse.id ? {
246
- ...block2,
247
- currentStatus: status
248
- } : block2)
249
- };
250
- }
251
- return m;
252
- });
253
- } else {
254
- log.warn("no block for status report", void 0, {
255
- F: __dxlog_file,
256
- L: 197,
257
- S: this,
258
- C: (f, a) => f(...a)
259
- });
260
- }
261
- });
262
- });
263
- try {
264
- const messages = await this._conversation.run({
265
- artifacts: [
266
- ...this._options.artifacts ?? []
267
- ],
268
- requiredArtifactIds: this._options.artifacts?.map((artifact) => artifact.id) ?? [],
269
- // TODO(dmaretskyi): Migrate to Effect's AiToolkit.
270
- tools: this._tools ?? [],
271
- systemPrompt: this._options.systemPrompt,
272
- prompt: message,
273
- extensions: this._options.extensions,
274
- artifactDiffResolver: this._artifactDiffResolver,
275
- generationOptions: {
276
- model: this._options.model
277
- }
278
- });
279
- log("completed", {
280
- messages
281
- }, {
282
- F: __dxlog_file,
283
- L: 218,
284
- S: this,
285
- C: (f, a) => f(...a)
286
- });
287
- } catch (err) {
288
- log.catch(err, void 0, {
289
- F: __dxlog_file,
290
- L: 220,
291
- S: this,
292
- C: (f, a) => f(...a)
293
- });
294
- if (err instanceof Error && err.message.includes("Overloaded")) {
295
- this.error.value = new AiServiceOverloadedError("AI service overloaded", {
296
- cause: err
297
- });
298
- } else {
299
- this.error.value = new Error("AI service error", {
300
- cause: err
301
- });
302
- }
303
- }
304
- return this._reset();
305
- } catch (e) {
306
- env.error = e;
307
- env.hasError = true;
308
- } finally {
309
- const result = _ts_dispose_resources(env);
310
- if (result) await result;
311
- }
312
- }
313
- /**
314
- * Cancel pending requests.
315
- * @returns Pending requests (incl. the request message).
316
- */
317
- async cancel() {
318
- log.info("cancelling...", void 0, {
319
- F: __dxlog_file,
320
- L: 236,
321
- S: this,
322
- C: (f, a) => f(...a)
323
- });
324
- this._session?.abort();
325
- return this._reset();
326
- }
327
- async _reset() {
328
- const messages = this._pending.value;
329
- batch(() => {
330
- this._pending.value = [];
331
- this._block.value = void 0;
332
- });
333
- return messages;
334
- }
335
- };
336
- var AiServiceOverloadedError = class extends Error {
337
- constructor() {
338
- super(...arguments);
339
- this.code = "AI_SERVICE_OVERLOADED";
340
- }
341
- };
342
-
343
- // src/hooks/useBlueprints.ts
344
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
345
- import { useCallback, useState } from "react";
346
- import { Ref } from "@dxos/echo";
347
- import { log as log2 } from "@dxos/log";
348
- import { useTimeout } from "@dxos/react-ui";
349
- import { isNonNullable } from "@dxos/util";
350
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useBlueprints.ts";
351
- var useBlueprints = (context) => {
352
- var _effect = _useSignals();
353
- try {
354
- const [blueprints, setBlueprints] = useState([]);
355
- useTimeout(async () => {
356
- const blueprints2 = (await Ref.Array.loadAll(context.blueprints.value ?? [])).filter(isNonNullable);
357
- setBlueprints(blueprints2);
358
- }, 0, [
359
- context
360
- ]);
361
- const handleUpdate = useCallback((key, active) => {
362
- log2.info("update", {
363
- key,
364
- active
365
- }, {
366
- F: __dxlog_file2,
367
- L: 27,
368
- S: void 0,
369
- C: (f, a) => f(...a)
370
- });
371
- }, []);
372
- return [
373
- blueprints,
374
- handleUpdate
375
- ];
376
- } finally {
377
- _effect.f();
378
- }
379
- };
380
-
381
- // src/hooks/useContextProvider.ts
382
- import { useMemo } from "react";
383
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
384
- import { Filter as Filter2, Obj } from "@dxos/echo";
385
- var useContextProvider = (space) => {
386
- const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
387
- return useMemo(() => {
388
- if (!space) {
389
- return void 0;
390
- }
391
- return {
392
- query: async ({ query }) => {
393
- const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
394
- const { objects } = await space.db.query(Filter2.or(...artifactSchemas.map((schema) => Filter2.type(schema)))).run();
395
- return objects.filter((object) => stringMatch(query, Obj.getLabel(object) ?? "")).filter((object) => !!Obj.getDXN(object)).map((object) => ({
396
- uri: Obj.getDXN(object).toString(),
397
- label: Obj.getLabel(object) ?? ""
398
- }));
399
- },
400
- resolveMetadata: async ({ uri }) => {
401
- const object = await space.db.query(Filter2.ids(uri)).first();
402
- return {
403
- uri,
404
- label: Obj.getLabel(object) ?? ""
405
- };
406
- }
407
- };
408
- }, [
409
- space,
410
- artifactDefinitions
411
- ]);
412
- };
413
- var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
414
-
415
- // src/hooks/useServiceContainer.ts
416
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
417
- import { useEffect, useMemo as useMemo2, useState as useState2 } from "react";
418
- import { ToolRegistry } from "@dxos/ai";
419
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability } from "@dxos/app-framework";
420
- import { AiService, DatabaseService, QueueService, ServiceContainer, ToolResolverService } from "@dxos/functions";
421
- var useServiceContainer = ({ space }) => {
422
- var _effect = _useSignals2();
423
- try {
424
- const aiClient = useCapability(AssistantCapabilities.AiClient);
425
- const tools = useCapabilities2(Capabilities2.Tools).flat();
426
- const [toolRegistry] = useState2(() => new ToolRegistry([]));
427
- useEffect(() => {
428
- for (const tool of tools) {
429
- if (!toolRegistry.has(tool)) {
430
- toolRegistry.register(tool);
431
- }
432
- }
433
- }, [
434
- toolRegistry,
435
- JSON.stringify(tools.map((tool) => tool.id))
436
- ]);
437
- return useMemo2(() => new ServiceContainer().setServices({
438
- ai: AiService.make(aiClient.value),
439
- database: space ? DatabaseService.make(space.db) : void 0,
440
- queues: space ? QueueService.make(space.queues, void 0) : void 0,
441
- // eventLogger: consoleLogger,
442
- toolResolver: ToolResolverService.make(toolRegistry)
443
- }), [
444
- space,
445
- aiClient
446
- ]);
447
- } finally {
448
- _effect.f();
449
- }
450
- };
451
-
452
- // src/hooks/useTextInputEvents.ts
453
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
454
- import { useState as useState3, useCallback as useCallback2 } from "react";
455
-
456
- // src/tools/function.ts
457
- import { createTool, ToolResult } from "@dxos/ai";
458
- import { Type } from "@dxos/echo";
459
- import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
460
- import { log as log3 } from "@dxos/log";
461
- import { getMeta } from "@dxos/react-client/echo";
462
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
463
- var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
464
- if (!fn.description || !fn.inputSchema) {
465
- return void 0;
466
- }
467
- const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
468
- if (!existingFunctionUrl) {
469
- return void 0;
470
- }
471
- const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
472
- spaceId
473
- });
474
- return createTool("user-function", {
475
- name: fn.name,
476
- description: fn.description,
477
- schema: Type.toEffectSchema(fn.inputSchema),
478
- execute: async (input) => {
479
- log3.info("execute function tool", {
480
- name: fn.name,
481
- url,
482
- input
483
- }, {
484
- F: __dxlog_file3,
485
- L: 34,
486
- S: void 0,
487
- C: (f, a) => f(...a)
488
- });
489
- const response = await fetch(url, {
490
- method: "POST",
491
- headers: {
492
- "Content-Type": "application/json"
493
- },
494
- body: JSON.stringify(input)
495
- });
496
- return ToolResult.Success(await response.text());
497
- }
498
- });
499
- };
500
-
501
- // src/tools/openapi.ts
502
- import { Schema } from "effect";
503
- import jsonpointer from "jsonpointer";
504
- import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
505
- import { Type as Type2 } from "@dxos/echo";
506
- import { normalizeSchema } from "@dxos/echo-schema";
507
- import { invariant } from "@dxos/invariant";
508
- import { log as log4 } from "@dxos/log";
509
- import { deepMapValues } from "@dxos/util";
510
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
511
- var createToolsFromService = async (service) => {
512
- invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
513
- F: __dxlog_file4,
514
- L: 24,
515
- S: void 0,
516
- A: [
517
- "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
518
- ""
519
- ]
520
- });
521
- const iface = service.interfaces[0];
522
- invariant(iface.schemaUrl, void 0, {
523
- F: __dxlog_file4,
524
- L: 26,
525
- S: void 0,
526
- A: [
527
- "iface.schemaUrl",
528
- ""
529
- ]
530
- });
531
- invariant(iface.schemaUrl, void 0, {
532
- F: __dxlog_file4,
533
- L: 27,
534
- S: void 0,
535
- A: [
536
- "iface.schemaUrl",
537
- ""
538
- ]
539
- });
540
- return createToolsFromApi(iface.schemaUrl, {
541
- authorization: iface.authorization
542
- });
543
- };
544
- var createToolsFromApi = async (url, options) => {
545
- const res = await fetch(url);
546
- const spec = await res.json();
547
- log4("spec", {
548
- spec
549
- }, {
550
- F: __dxlog_file4,
551
- L: 37,
552
- S: void 0,
553
- C: (f, a) => f(...a)
554
- });
555
- const tools = [];
556
- for (const [path, pathItem] of Object.entries(spec.paths)) {
557
- if (typeof pathItem !== "object") {
558
- continue;
559
- }
560
- const { ...methods } = pathItem;
561
- for (const [method, m] of Object.entries(methods)) {
562
- const methodItem = m;
563
- log4("methodItem", {
564
- path,
565
- method,
566
- methodItem
567
- }, {
568
- F: __dxlog_file4,
569
- L: 48,
570
- S: void 0,
571
- C: (f, a) => f(...a)
572
- });
573
- const parametersResolved = methodItem.parameters?.map((parameter) => {
574
- const resolved = resolveJsonSchema(parameter, spec);
575
- return resolved;
576
- }) ?? [];
577
- const inputSchema = {
578
- type: "object",
579
- properties: {}
580
- };
581
- const endpointParameters = [];
582
- for (const parameter of parametersResolved) {
583
- log4("parameter", {
584
- parameter
585
- }, {
586
- F: __dxlog_file4,
587
- L: 63,
588
- S: void 0,
589
- C: (f, a) => f(...a)
590
- });
591
- if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
592
- continue;
593
- }
594
- endpointParameters.push(parameter);
595
- if (parameter.schema) {
596
- inputSchema.properties[parameter.name] = normalizeSchema(parameter.schema);
597
- } else if (typeof parameter.type === "string") {
598
- const { name, in: _in, required, ...schema } = parameter;
599
- inputSchema.properties[name] = normalizeSchema(schema);
600
- if (required) {
601
- inputSchema.required ??= [];
602
- inputSchema.required.push(name);
603
- }
604
- }
605
- }
606
- log4("inputSchema", {
607
- inputSchema
608
- }, {
609
- F: __dxlog_file4,
610
- L: 88,
611
- S: void 0,
612
- C: (f, a) => f(...a)
613
- });
614
- Schema.validateSync(Type2.JsonSchema)(inputSchema);
615
- const description = methodItem.description ?? methodItem.summary;
616
- if (!description) {
617
- log4.warn("no description", {
618
- path,
619
- method
620
- }, {
621
- F: __dxlog_file4,
622
- L: 93,
623
- S: void 0,
624
- C: (f, a) => f(...a)
625
- });
626
- continue;
627
- }
628
- const endpoint = {
629
- document: spec,
630
- path,
631
- method,
632
- parameters: endpointParameters,
633
- authorization: options?.authorization
634
- };
635
- tools.push(
636
- // TODO(burdon): Namespace?
637
- createRawTool("openapi", {
638
- name: getToolName(path, method, methodItem),
639
- description: options?.instructions ? `${options.instructions}
640
-
641
- ${description}` : description,
642
- parameters: inputSchema,
643
- execute: async (input) => {
644
- const response = await callApiEndpoint(endpoint, input);
645
- return ToolResult2.Success(response);
646
- }
647
- })
648
- );
649
- }
650
- }
651
- return tools;
652
- };
653
- var getToolName = (path, method, methodItem) => {
654
- if (methodItem.operationId) {
655
- return methodItem.operationId;
656
- }
657
- let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
658
- while (name.length > MAX_TOOL_NAME_LENGTH) {
659
- const lengthBefore = name.length;
660
- for (const word of GENERIC_WORDS) {
661
- if (name.includes(word)) {
662
- name = name.replace(word, "");
663
- break;
664
- }
665
- }
666
- name = name.replaceAll("__", "_").replace(/_$/, "");
667
- const lengthAfter = name.length;
668
- if (lengthBefore === lengthAfter) {
669
- break;
670
- }
671
- }
672
- name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
673
- return name.slice(0, MAX_TOOL_NAME_LENGTH);
674
- };
675
- var MAX_TOOL_NAME_LENGTH = 64;
676
- var GENERIC_WORDS = [
677
- "services",
678
- "service",
679
- "api",
680
- "rest",
681
- "endpoint",
682
- "get",
683
- "post",
684
- "put",
685
- "delete",
686
- "patch",
687
- "head",
688
- "options",
689
- "trace",
690
- "service",
691
- "api",
692
- "endpoint"
693
- ];
694
- var callApiEndpoint = async (endpoint, input) => {
695
- log4.info("endpoint", {
696
- method: endpoint.method,
697
- name: endpoint.path,
698
- input
699
- }, {
700
- F: __dxlog_file4,
701
- L: 180,
702
- S: void 0,
703
- C: (f, a) => f(...a)
704
- });
705
- let url = getEndpointUrl(endpoint);
706
- const request = {
707
- method: endpoint.method,
708
- headers: {}
709
- };
710
- const query = new URLSearchParams();
711
- let body;
712
- for (const parameter of endpoint.parameters) {
713
- if (input[parameter.name] === void 0) {
714
- continue;
715
- }
716
- switch (parameter.in) {
717
- case "header": {
718
- if (parameter.example) {
719
- request.headers[parameter.name] = parameter.default;
720
- }
721
- break;
722
- }
723
- case "path": {
724
- url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
725
- break;
726
- }
727
- case "body": {
728
- const value = input[parameter.name];
729
- const effectSchema = Type2.toEffectSchema(parameter.schema);
730
- Schema.validateSync(effectSchema)(value);
731
- if (body) {
732
- throw new Error(`Duplicate body parameter: ${parameter.name}`);
733
- }
734
- body = value;
735
- break;
736
- }
737
- case "query": {
738
- query.set(parameter.name, input[parameter.name]);
739
- break;
740
- }
741
- }
742
- }
743
- if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
744
- request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
745
- } else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
746
- query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
747
- }
748
- if (query.size > 0) {
749
- url += `?${query.toString()}`;
750
- }
751
- if (body) {
752
- request.body = JSON.stringify(body);
753
- request.headers["Content-Type"] = "application/json";
754
- }
755
- log4.info("request", {
756
- url,
757
- request
758
- }, {
759
- F: __dxlog_file4,
760
- L: 243,
761
- S: void 0,
762
- C: (f, a) => f(...a)
763
- });
764
- const response = await fetch(url, request);
765
- log4.info("response", {
766
- ok: response.ok,
767
- status: response.status,
768
- statusText: response.statusText
769
- }, {
770
- F: __dxlog_file4,
771
- L: 246,
772
- S: void 0,
773
- C: (f, a) => f(...a)
774
- });
775
- if (response.ok) {
776
- const contentType = response.headers.get("Content-Type");
777
- if (contentType?.includes("application/json")) {
778
- return await response.json();
779
- } else {
780
- return await response.text();
781
- }
782
- } else {
783
- if (response.headers.get("Content-Type")?.includes("application/json")) {
784
- const responseBody = await response.text();
785
- let error;
786
- try {
787
- error = JSON.parse(responseBody);
788
- } catch {
789
- error = responseBody;
790
- }
791
- log4.error("error", {
792
- error
793
- }, {
794
- F: __dxlog_file4,
795
- L: 264,
796
- S: void 0,
797
- C: (f, a) => f(...a)
798
- });
799
- throw new Error(error.message);
800
- } else {
801
- const error = await response.text();
802
- log4.error("error", {
803
- error
804
- }, {
805
- F: __dxlog_file4,
806
- L: 268,
807
- S: void 0,
808
- C: (f, a) => f(...a)
809
- });
810
- throw new Error(error);
811
- }
812
- }
813
- };
814
- var getEndpointUrl = (endpoint) => {
815
- let url = "";
816
- if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
817
- url = endpoint.document.servers[0].url;
818
- } else {
819
- invariant(!isV3_1(endpoint.document), void 0, {
820
- F: __dxlog_file4,
821
- L: 279,
822
- S: void 0,
823
- A: [
824
- "!isV3_1(endpoint.document)",
825
- ""
826
- ]
827
- });
828
- url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
829
- }
830
- if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
831
- url += endpoint.document.basePath;
832
- }
833
- url += endpoint.path;
834
- return url;
835
- };
836
- var resolveAuthorization = async (authorization) => {
837
- switch (authorization.type) {
838
- case "api-key": {
839
- invariant(authorization.placement.type === "authorization-header", void 0, {
840
- F: __dxlog_file4,
841
- L: 295,
842
- S: void 0,
843
- A: [
844
- "authorization.placement.type === 'authorization-header'",
845
- ""
846
- ]
847
- });
848
- return `Bearer ${authorization.key}`;
849
- }
850
- case "oauth": {
851
- const response = await fetch(authorization.tokenUrl, {
852
- method: "POST",
853
- headers: {
854
- "Content-Type": "application/x-www-form-urlencoded"
855
- },
856
- body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
857
- });
858
- const data = await response.json();
859
- return `Bearer ${data.access_token}`;
860
- }
861
- default: {
862
- throw new Error(`Unknown authorization type: ${authorization.type}`);
863
- }
864
- }
865
- };
866
- var resolveJsonSchema = (schema, base) => {
867
- return deepMapValues(schema, (value, recurse) => {
868
- if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
869
- if (value.$ref.startsWith("#")) {
870
- const resolved = jsonpointer.get(base, value.$ref.slice(1));
871
- if (resolved) {
872
- return recurse(resolved);
873
- } else {
874
- log4.warn("unresolved", {
875
- ref: value.$ref,
876
- base
877
- }, {
878
- F: __dxlog_file4,
879
- L: 328,
880
- S: void 0,
881
- C: (f, a) => f(...a)
882
- });
883
- }
884
- }
885
- }
886
- return recurse(value);
887
- });
888
- };
889
- var isV3_1 = (document) => {
890
- return document.openapi === "3.0.1";
891
- };
892
-
893
- // src/hooks/useChatProcessor.tsx
894
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
895
- var useChatProcessor = ({ part = "deck", space, chat, serviceContainer, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
896
- const { dispatchPromise: dispatch } = useIntentDispatcher();
897
- const globalTools = useCapabilities3(Capabilities3.Tools);
898
- let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
899
- if (noPluginArtifacts) {
900
- artifacts = Stable.array;
901
- }
902
- const services = useQuery(space, Filter3.type(ServiceType));
903
- const [serviceTools, setServiceTools] = useState4([]);
904
- useEffect2(() => {
905
- log5("creating service tools...", void 0, {
906
- F: __dxlog_file5,
907
- L: 65,
908
- S: void 0,
909
- C: (f, a) => f(...a)
910
- });
911
- queueMicrotask(async () => {
912
- const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
913
- setServiceTools(tools2.flat());
914
- });
915
- }, [
916
- services
917
- ]);
918
- const config = useConfig();
919
- const functions = useQuery(space, Filter3.type(FunctionType));
920
- const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
921
- chat
922
- ]);
923
- const [tools, extensions] = useMemo3(() => {
924
- log5("creating tools...", void 0, {
925
- F: __dxlog_file5,
926
- L: 77,
927
- S: void 0,
928
- C: (f, a) => f(...a)
929
- });
930
- const tools2 = [
931
- ...globalTools.flat(),
932
- ...serviceTools,
933
- ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
934
- ];
935
- const extensions2 = {
936
- part,
937
- space,
938
- dispatch,
939
- pivotId: chatId
940
- };
941
- return [
942
- tools2,
943
- extensions2
944
- ];
945
- }, [
946
- dispatch,
947
- globalTools,
948
- space,
949
- chatId,
950
- serviceTools,
951
- functions
952
- ]);
953
- const systemPrompt = useMemo3(() => createSystemPrompt({
954
- artifacts: artifacts.map((definition) => `${definition.name}
955
- ${definition.instructions}`),
956
- artifact,
957
- instructions
958
- }), [
959
- artifacts,
960
- artifact,
961
- instructions
962
- ]);
963
- const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
964
- const conversation = useMemo3(() => {
965
- if (!chat?.queue.target) {
966
- return;
967
- }
968
- return new Conversation({
969
- serviceContainer,
970
- queue: chat.queue.target
971
- });
972
- }, [
973
- chat?.queue.target,
974
- serviceContainer
975
- ]);
976
- const processor = useMemo3(() => {
977
- if (!conversation) {
978
- return void 0;
979
- }
980
- log5("creating processor...", {
981
- settings
982
- }, {
983
- F: __dxlog_file5,
984
- L: 124,
985
- S: void 0,
986
- C: (f, a) => f(...a)
987
- });
988
- return new ChatProcessor(conversation, {
989
- tools,
990
- extensions,
991
- blueprintRegistry,
992
- artifacts,
993
- systemPrompt,
994
- model
995
- });
996
- }, [
997
- conversation,
998
- tools,
999
- blueprintRegistry,
1000
- artifacts,
1001
- extensions,
1002
- systemPrompt,
1003
- model
1004
- ]);
1005
- return processor;
1006
- };
1007
- var Stable = Object.freeze({
1008
- array: [],
1009
- object: {}
1010
- });
1011
-
1012
- // src/components/Toolbox/Toolbox.tsx
1013
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
1014
- import React, { useState as useState5, useEffect as useEffect3, Fragment } from "react";
1015
- import { parseToolName } from "@dxos/ai";
1016
- import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
1017
- import { FunctionType as FunctionType2 } from "@dxos/functions";
1018
- import { log as log6 } from "@dxos/log";
1019
- import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
1020
- import { useTranslation } from "@dxos/react-ui";
1021
- import { mx } from "@dxos/react-ui-theme";
1022
- var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1023
- var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
1024
- var _effect = _useSignals4();
1025
- try {
1026
- const { t } = useTranslation(meta.id);
1027
- return /* @__PURE__ */ React.createElement("div", {
1028
- className: mx("flex flex-col overflow-y-auto box-content", classNames)
1029
- }, blueprints && blueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1030
- title: "Blueprints",
1031
- items: blueprints.map(({ target }) => ({
1032
- name: target?.name ?? "",
1033
- description: target?.description ?? "",
1034
- subitems: target?.tools.map((toolId) => ({
1035
- name: `\u2219 ${parseToolName(toolId)}`
1036
- }))
1037
- }))
1038
- }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1039
- title: "Blueprints",
1040
- items: activeBlueprints.map(({ target }) => ({
1041
- name: target?.name ?? "",
1042
- description: target?.description ?? "",
1043
- subitems: target?.tools.map((toolId) => ({
1044
- name: `\u2219 ${parseToolName(toolId)}`
1045
- }))
1046
- }))
1047
- }), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1048
- title: "Artifacts",
1049
- items: artifacts.map(({ name, description, tools }) => ({
1050
- name,
1051
- description,
1052
- subitems: tools.map(({ name: name2, description: description2 }) => ({
1053
- name: `\u2219 ${parseToolName(name2)}`,
1054
- description: description2
1055
- }))
1056
- }))
1057
- }), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1058
- title: "Services",
1059
- items: services.map(({ service: { serviceId, name, description }, tools }) => ({
1060
- name: name ?? serviceId,
1061
- description,
1062
- subitems: tools.map(({ name: name2, description: description2 }) => ({
1063
- name: `\u2219 ${name2}`,
1064
- description: description2
1065
- }))
1066
- }))
1067
- }), functions && functions.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1068
- title: "Functions",
1069
- items: functions.map(({ name, description }) => ({
1070
- name,
1071
- description
1072
- }))
1073
- }), !blueprints?.length && !activeBlueprints?.length && !artifacts?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
1074
- } finally {
1075
- _effect.f();
1076
- }
1077
- };
1078
- var Section = ({ title, items, striped }) => {
1079
- var _effect = _useSignals4();
1080
- try {
1081
- const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1082
- const gridClassNames = "grid grid-cols-[8rem_1fr]";
1083
- const subGridClassNames = mx("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
1084
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h1", {
1085
- className: "px-2 text-sm"
1086
- }, title), /* @__PURE__ */ React.createElement("div", {
1087
- className: gridClassNames
1088
- }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React.createElement(Fragment, {
1089
- key: i
1090
- }, name && /* @__PURE__ */ React.createElement("div", {
1091
- className: subGridClassNames
1092
- }, /* @__PURE__ */ React.createElement("div", {
1093
- className: "truncate text-primary-500"
1094
- }, name), /* @__PURE__ */ React.createElement("div", {
1095
- className: "line-clamp-2"
1096
- }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React.createElement("div", {
1097
- key: i2,
1098
- className: mx(subGridClassNames, striped && stripeClassNames)
1099
- }, /* @__PURE__ */ React.createElement("div", {
1100
- className: "truncate"
1101
- }, name2), /* @__PURE__ */ React.createElement("div", {
1102
- className: "line-clamp-3 text-subdued"
1103
- }, description2)))))));
1104
- } finally {
1105
- _effect.f();
1106
- }
1107
- };
1108
- var ToolboxContainer = ({ classNames, space, processor }) => {
1109
- var _effect = _useSignals4();
1110
- try {
1111
- const artifactDefinitions = useCapabilities4(Capabilities4.ArtifactDefinition);
1112
- const services = useQuery2(space, Filter4.type(ServiceType));
1113
- const [serviceTools, setServiceTools] = useState5([]);
1114
- useEffect3(() => {
1115
- log6("creating service tools...", {
1116
- services: services.length
1117
- }, {
1118
- F: __dxlog_file6,
1119
- L: 147,
1120
- S: void 0,
1121
- C: (f, a) => f(...a)
1122
- });
1123
- queueMicrotask(async () => {
1124
- const tools = await Promise.all(services.map(async (service) => ({
1125
- service,
1126
- tools: await createToolsFromService(service)
1127
- })));
1128
- setServiceTools(tools);
1129
- });
1130
- }, [
1131
- services
1132
- ]);
1133
- const functions = useQuery2(space, Filter4.type(FunctionType2));
1134
- return /* @__PURE__ */ React.createElement(Toolbox, {
1135
- classNames,
1136
- blueprints: processor?.context.blueprints.value,
1137
- artifacts: artifactDefinitions,
1138
- services: serviceTools,
1139
- functions
1140
- });
1141
- } finally {
1142
- _effect.f();
1143
- }
1144
- };
1145
-
1146
- // src/components/Chat/Chat.tsx
1147
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1148
- import { Prec } from "@codemirror/state";
1149
- import { keymap } from "@codemirror/view";
1150
- import { createContext } from "@radix-ui/react-context";
1151
- import { dedupeWith } from "effect/Array";
1152
- import React9, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef2, useState as useState7 } from "react";
1153
- import { Message } from "@dxos/ai";
1154
- import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
1155
- import { Event } from "@dxos/async";
1156
- import { DXN, Obj as Obj3, Ref as Ref3 } from "@dxos/echo";
1157
- import { log as log8 } from "@dxos/log";
1158
- import { useVoiceInput } from "@dxos/plugin-transcription";
1159
- import { getSpace, useQueue } from "@dxos/react-client/echo";
1160
- import { useIdentity } from "@dxos/react-client/halo";
1161
- import { useTranslation as useTranslation5 } from "@dxos/react-ui";
1162
- import { ChatEditor, references } from "@dxos/react-ui-chat";
1163
- import { mx as mx5 } from "@dxos/react-ui-theme";
1164
- import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
1165
-
1166
- // src/components/ChatPrompt/ChatActions.tsx
1167
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1168
- import React2 from "react";
1169
- import { IconButton, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
1170
- import { mx as mx2 } from "@dxos/react-ui-theme";
1171
- var ChatActions = ({ microphone, recording, processing, onEvent }) => {
1172
- var _effect = _useSignals5();
1173
- try {
1174
- const { t } = useTranslation2(meta.id);
1175
- return /* @__PURE__ */ React2.createElement("div", {
1176
- className: "flex items-center mie-1"
1177
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
1178
- value: "ollama",
1179
- disabled: true
1180
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
1181
- classNames: "mie-2 text-sm"
1182
- }), /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Option, {
1183
- value: "ollama",
1184
- classNames: "text-sm"
1185
- }, "Ollama"))), processing && /* @__PURE__ */ React2.createElement(IconButton, {
1186
- disabled: !processing,
1187
- classNames: "px-1.5",
1188
- variant: "ghost",
1189
- size: 5,
1190
- icon: "ph--x--regular",
1191
- iconOnly: true,
1192
- label: t("button cancel processing"),
1193
- onClick: () => onEvent?.({
1194
- type: "cancel"
1195
- })
1196
- }) || /* @__PURE__ */ React2.createElement(IconButton, {
1197
- classNames: "px-1.5",
1198
- variant: "ghost",
1199
- size: 5,
1200
- icon: "ph--arrow-down--regular",
1201
- iconOnly: true,
1202
- label: t("button scroll down"),
1203
- onClick: () => onEvent?.({
1204
- type: "scroll-to-bottom"
1205
- })
1206
- }), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
1207
- disabled: !processing,
1208
- classNames: mx2("px-1.5", recording && "bg-primary-500"),
1209
- variant: "ghost",
1210
- size: 5,
1211
- icon: "ph--microphone--regular",
1212
- iconOnly: true,
1213
- noTooltip: true,
1214
- label: t("button microphone"),
1215
- onMouseDown: () => onEvent?.({
1216
- type: "record-start"
1217
- }),
1218
- onMouseUp: () => onEvent?.({
1219
- type: "record-stop"
1220
- }),
1221
- onTouchStart: () => onEvent?.({
1222
- type: "record-start"
1223
- }),
1224
- onTouchEnd: () => onEvent?.({
1225
- type: "record-stop"
1226
- })
1227
- }));
1228
- } finally {
1229
- _effect.f();
1230
- }
1231
- };
1232
-
1233
- // src/components/ChatPrompt/ChatOptionsMenu.tsx
1234
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1235
- import React3, { useMemo as useMemo4 } from "react";
1236
- import { DropdownMenu, IconButton as IconButton2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
1237
- var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
1238
- var _effect = _useSignals6();
1239
- try {
1240
- const { t } = useTranslation3(meta.id);
1241
- const blueprintOptions = useMemo4(() => blueprintRegistry?.query().map((blueprint) => ({
1242
- key: blueprint.key,
1243
- label: blueprint.name
1244
- })), [
1245
- blueprintRegistry
1246
- ]);
1247
- return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
1248
- asChild: true,
1249
- disabled: !blueprintOptions?.length
1250
- }, /* @__PURE__ */ React3.createElement(IconButton2, {
1251
- icon: "ph--plus--regular",
1252
- variant: "ghost",
1253
- size: 5,
1254
- iconOnly: true,
1255
- label: t("button add blueprint")
1256
- })), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
1257
- side: "left"
1258
- }, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprintOptions?.map((option) => /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
1259
- key: option.key
1260
- }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Checkbox, {
1261
- checked: !!blueprints?.find((blueprint) => blueprint.key === option.key),
1262
- onCheckedChange: (checked) => onChange?.(option.key, !!checked)
1263
- }), /* @__PURE__ */ React3.createElement(Input.Label, {
1264
- classNames: "m-0"
1265
- }, option.label))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
1266
- } finally {
1267
- _effect.f();
1268
- }
1269
- };
1270
-
1271
- // src/components/ChatPrompt/ChatReferences.tsx
1272
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1273
- import React4, { useCallback as useCallback3 } from "react";
1274
- import { Filter as Filter5, Obj as Obj2, Ref as Ref2 } from "@dxos/echo";
1275
- import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
1276
- import { TagPicker } from "@dxos/react-ui-tag-picker";
1277
- import { isNonNullable as isNonNullable3 } from "@dxos/util";
1278
- var ChatReferences = ({ classNames, space, context, onUpdate }) => {
1279
- var _effect = _useSignals7();
1280
- try {
1281
- const { t } = useTranslation4(meta.id);
1282
- const [items] = useAsyncState(async () => {
1283
- const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
1284
- return objects.filter(isNonNullable3).map((obj) => ({
1285
- id: obj.id,
1286
- label: Obj2.getLabel(obj) ?? obj.id
1287
- }));
1288
- }, [
1289
- context
1290
- ]);
1291
- const handleSearch = useCallback3((text, ids) => {
1292
- const objects = space.db.query(Filter5.everything()).runSync();
1293
- return objects.map(({ object }) => ({
1294
- id: object.id,
1295
- label: Obj2.getLabel(object) ?? ""
1296
- })).filter(({ id, label }) => !ids.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
1297
- }, [
1298
- space
1299
- ]);
1300
- return /* @__PURE__ */ React4.createElement(TagPicker, {
1301
- classNames,
1302
- mode: "multi-select",
1303
- placeholder: t("context objects placeholder"),
1304
- items,
1305
- onSearch: handleSearch,
1306
- onUpdate
1307
- });
1308
- } finally {
1309
- _effect.f();
1310
- }
1311
- };
1312
-
1313
- // src/components/ChatPrompt/ChatStatusIndicator.tsx
1314
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1315
- import React5 from "react";
1316
- import { Icon, Tooltip } from "@dxos/react-ui";
1317
- import { Spinner } from "@dxos/react-ui-sfx";
1318
- import { errorText } from "@dxos/react-ui-theme";
1319
- var ChatStatusIndicator = ({ error, processing }) => {
1320
- var _effect = _useSignals8();
1321
- try {
1322
- if (error) {
1323
- return /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
1324
- content: error.message,
1325
- delayDuration: 0
1326
- }, /* @__PURE__ */ React5.createElement(Icon, {
1327
- icon: "ph--warning-circle--regular",
1328
- classNames: errorText,
1329
- size: 5
1330
- }));
1331
- }
1332
- return /* @__PURE__ */ React5.createElement(Spinner, {
1333
- active: processing
1334
- });
1335
- } finally {
1336
- _effect.f();
1337
- }
1338
- };
1339
-
1340
- // src/components/ChatThread/ChatThread.tsx
1341
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1342
- import React8, { forwardRef, useMemo as useMemo6 } from "react";
1343
- import { PublicKey } from "@dxos/keys";
1344
- import { ScrollContainer } from "@dxos/react-ui-components";
1345
- import { mx as mx4 } from "@dxos/react-ui-theme";
1346
- import { keyToFallback } from "@dxos/util";
1347
-
1348
- // src/components/ChatThread/ChatMessage.tsx
1349
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1350
- import React7 from "react";
1351
- import { Surface } from "@dxos/app-framework";
1352
- import { invariant as invariant2 } from "@dxos/invariant";
1353
- import { Button, Icon as Icon2, IconButton as IconButton3 } from "@dxos/react-ui";
1354
- import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
1355
- import { mx as mx3 } from "@dxos/react-ui-theme";
1356
- import { safeParseJson } from "@dxos/util";
1357
-
1358
- // src/components/ChatThread/ToolBlock.tsx
1359
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1360
- import React6, { useEffect as useEffect4, useMemo as useMemo5, useRef, useState as useState6 } from "react";
1361
- import { log as log7 } from "@dxos/log";
1362
- import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
1363
- import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
1364
- import { isNonNullable as isNonNullable4, isNotFalsy } from "@dxos/util";
1365
- var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
1366
- var isToolMessage = (message) => {
1367
- return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
1368
- };
1369
- var getToolName2 = (tool) => {
1370
- return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
1371
- };
1372
- var getToolCaption = (tool, status) => {
1373
- if (!tool) {
1374
- return "Calling tool...";
1375
- }
1376
- return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
1377
- };
1378
- var ToolBlock = ({ classNames, message, tools }) => {
1379
- var _effect = _useSignals9();
1380
- try {
1381
- const { content = [] } = message;
1382
- let request;
1383
- const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
1384
- const items = blocks.map((block) => {
1385
- switch (block.type) {
1386
- case "tool_use": {
1387
- if (block.pending && request?.block.id === block.id) {
1388
- return null;
1389
- }
1390
- request = {
1391
- tool: tools?.find((tool) => tool.name === block.name),
1392
- block
1393
- };
1394
- return {
1395
- title: getToolCaption(request.tool, block.currentStatus),
1396
- block
1397
- };
1398
- }
1399
- case "tool_result": {
1400
- if (!request) {
1401
- log7.warn("unexpected message", {
1402
- block
1403
- }, {
1404
- F: __dxlog_file7,
1405
- L: 55,
1406
- S: void 0,
1407
- C: (f, a) => f(...a)
1408
- });
1409
- return {
1410
- title: "Error",
1411
- block
1412
- };
1413
- }
1414
- return {
1415
- title: `${getToolCaption(request.tool, void 0)} (Success)`,
1416
- block
1417
- };
1418
- }
1419
- default: {
1420
- request = void 0;
1421
- return {
1422
- title: "Error",
1423
- block
1424
- };
1425
- }
1426
- }
1427
- }).filter(isNonNullable4);
1428
- return /* @__PURE__ */ React6.createElement(ToolContainer, {
1429
- classNames,
1430
- items
1431
- });
1432
- } finally {
1433
- _effect.f();
1434
- }
1435
- };
1436
- var ToolContainer = ({ classNames, items }) => {
1437
- var _effect = _useSignals9();
1438
- try {
1439
- const tabsRef = useRef(null);
1440
- const [selected, setSelected] = useState6(0);
1441
- const [open, setOpen] = useState6(false);
1442
- useEffect4(() => {
1443
- if (open) {
1444
- tabsRef.current?.focus();
1445
- }
1446
- }, [
1447
- open
1448
- ]);
1449
- const handleSelect = (index) => {
1450
- if (index === selected) {
1451
- setOpen(false);
1452
- } else {
1453
- setSelected(index);
1454
- }
1455
- };
1456
- const title = useMemo5(() => {
1457
- const lines = items.map((item) => item.title).filter(isNotFalsy);
1458
- return /* @__PURE__ */ React6.createElement(StatusRoll, {
1459
- key: "status-roll",
1460
- lines,
1461
- duration: 1e3,
1462
- autoAdvance: true
1463
- });
1464
- }, [
1465
- items
1466
- ]);
1467
- return /* @__PURE__ */ React6.createElement(ToggleContainer, {
1468
- classNames: [
1469
- "flex flex-col",
1470
- classNames
1471
- ],
1472
- title,
1473
- open,
1474
- onChangeOpen: setOpen
1475
- }, /* @__PURE__ */ React6.createElement("div", {
1476
- className: "w-full grid grid-cols-[32px_1fr]"
1477
- }, /* @__PURE__ */ React6.createElement(NumericTabs, {
1478
- ref: tabsRef,
1479
- length: items.length,
1480
- selected,
1481
- onSelect: handleSelect
1482
- }), /* @__PURE__ */ React6.createElement(Json, {
1483
- data: items[selected].block
1484
- })));
1485
- } finally {
1486
- _effect.f();
1487
- }
1488
- };
1489
- var Json = ({ data }) => {
1490
- var _effect = _useSignals9();
1491
- try {
1492
- return /* @__PURE__ */ React6.createElement(NativeJson, {
1493
- data,
1494
- classNames: "!p-1 text-xs bg-transparent"
1495
- });
1496
- } finally {
1497
- _effect.f();
1498
- }
1499
- };
1500
-
1501
- // src/components/ChatThread/ChatMessage.tsx
1502
- var __dxlog_file8 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
1503
- var ChatMessage = ({ classNames, space, processor, message, tools, onPrompt, onAddToGraph }) => {
1504
- var _effect = _useSignals10();
1505
- try {
1506
- const { role, content = [] } = message;
1507
- if (isToolMessage(message)) {
1508
- return /* @__PURE__ */ React7.createElement(MessageContainer, {
1509
- classNames: mx3(classNames, "animate-[fadeIn_0.5s]")
1510
- }, /* @__PURE__ */ React7.createElement(ToolBlock, {
1511
- classNames: panelClassNames,
1512
- message,
1513
- tools
1514
- }));
1515
- }
1516
- return content.map((block, idx) => {
1517
- if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1518
- return null;
1519
- }
1520
- const Component = components[block.type] ?? components.default;
1521
- return /* @__PURE__ */ React7.createElement(MessageContainer, {
1522
- key: idx,
1523
- classNames: mx3(classNames, "animate-[fadeIn_0.5s]"),
1524
- user: block.type === "text" && role === "user"
1525
- }, /* @__PURE__ */ React7.createElement(Component, {
1526
- space,
1527
- processor,
1528
- block,
1529
- onPrompt,
1530
- onAddToGraph
1531
- }));
1532
- });
1533
- } finally {
1534
- _effect.f();
1535
- }
1536
- };
1537
- var components = {
1538
- //
1539
- // Text
1540
- //
1541
- ["text"]: ({ block }) => {
1542
- invariant2(block.type === "text", void 0, {
1543
- F: __dxlog_file8,
1544
- L: 90,
1545
- S: void 0,
1546
- A: [
1547
- "block.type === 'text'",
1548
- ""
1549
- ]
1550
- });
1551
- const title = block.disposition ? titles[block.disposition] : void 0;
1552
- if (!title) {
1553
- return /* @__PURE__ */ React7.createElement(MarkdownViewer, {
1554
- classNames: "[&>p]:animate-[fadeIn_0.5s]",
1555
- content: block.text
1556
- });
1557
- }
1558
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1559
- // open={open}
1560
- defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
1561
- title,
1562
- icon: block.pending ? /* @__PURE__ */ React7.createElement(Icon2, {
1563
- icon: "ph--circle-notch--regular",
1564
- classNames: "text-subdued ml-2 animate-spin",
1565
- size: 4
1566
- }) : void 0
1567
- }, /* @__PURE__ */ React7.createElement(MarkdownViewer, {
1568
- content: block.text,
1569
- classNames: [
1570
- "pbe-2",
1571
- systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
1572
- ]
1573
- }));
1574
- },
1575
- //
1576
- // JSON
1577
- //
1578
- ["json"]: ({ space, processor, block, onPrompt, onAddToGraph }) => {
1579
- invariant2(block.type === "json", void 0, {
1580
- F: __dxlog_file8,
1581
- L: 128,
1582
- S: void 0,
1583
- A: [
1584
- "block.type === 'json'",
1585
- ""
1586
- ]
1587
- });
1588
- switch (block.disposition) {
1589
- case "tool_list": {
1590
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1591
- title: titles[block.disposition],
1592
- defaultOpen: true
1593
- }, /* @__PURE__ */ React7.createElement(ToolboxContainer, {
1594
- space,
1595
- processor,
1596
- classNames: "pbe-2"
1597
- }));
1598
- }
1599
- case "suggest": {
1600
- const { text = "" } = safeParseJson(block.json ?? "{}") ?? {};
1601
- return /* @__PURE__ */ React7.createElement(IconButton3, {
1602
- icon: "ph--lightning--regular",
1603
- label: text,
1604
- onClick: () => onPrompt?.(text)
1605
- });
1606
- }
1607
- case "select": {
1608
- const { options = [] } = safeParseJson(block.json ?? "{}") ?? {};
1609
- return /* @__PURE__ */ React7.createElement("div", {
1610
- className: "flex flex-wrap gap-1"
1611
- }, options.map((option, idx) => /* @__PURE__ */ React7.createElement(Button, {
1612
- classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
1613
- key: option,
1614
- onClick: () => onPrompt?.(option)
1615
- }, option)));
1616
- }
1617
- case "graph": {
1618
- return /* @__PURE__ */ React7.createElement("div", {
1619
- className: "flex flex-wrap gap-1"
1620
- }, /* @__PURE__ */ React7.createElement(Surface, {
1621
- role: "card",
1622
- data: {
1623
- subject: JSON.parse(block.json ?? "{}")
1624
- },
1625
- limit: 1,
1626
- fallback: /* @__PURE__ */ React7.createElement("div", {
1627
- className: "font-mono text-xs text-pre"
1628
- }, block.json)
1629
- }), onAddToGraph && /* @__PURE__ */ React7.createElement(IconButton3, {
1630
- icon: "ph--plus--regular",
1631
- label: "Add to graph",
1632
- onClick: () => onAddToGraph?.(JSON.parse(block.json ?? "{}"))
1633
- }));
1634
- }
1635
- default: {
1636
- const title = block.disposition ? titles[block.disposition] : void 0;
1637
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1638
- title: title ?? "JSON"
1639
- }, /* @__PURE__ */ React7.createElement(Json, {
1640
- data: safeParseJson(block.json ?? block)
1641
- }));
1642
- }
1643
- }
1644
- },
1645
- //
1646
- // Default
1647
- //
1648
- default: ({ block }) => {
1649
- let title = titles[block.type];
1650
- if (block.type === "tool_use") {
1651
- title = `Tool [${block.name}]`;
1652
- }
1653
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1654
- title: title ?? "JSON"
1655
- }, /* @__PURE__ */ React7.createElement(Json, {
1656
- data: block
1657
- }));
1658
- }
1659
- };
1660
- var titles = {
1661
- ["cot"]: "Chain of thought",
1662
- ["artifact"]: "Artifact",
1663
- ["tool_use"]: "Tool request",
1664
- ["tool_result"]: "Tool result",
1665
- ["tool_list"]: "Tools",
1666
- ["artifact-update"]: "Artifact(s) changed"
1667
- };
1668
- var systemDispositions = [
1669
- "cot",
1670
- "artifact-update"
1671
- ];
1672
- var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-sm";
1673
- var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
1674
- var ToggleContainer2 = (props) => {
1675
- var _effect = _useSignals10();
1676
- try {
1677
- return /* @__PURE__ */ React7.createElement(NativeToggleContainer, {
1678
- ...props,
1679
- classNames: mx3(panelClassNames, props.classNames)
1680
- });
1681
- } finally {
1682
- _effect.f();
1683
- }
1684
- };
1685
- var MessageContainer = ({ children, classNames, user }) => {
1686
- var _effect = _useSignals10();
1687
- try {
1688
- if (!children) {
1689
- return null;
1690
- }
1691
- return /* @__PURE__ */ React7.createElement("div", {
1692
- role: "list-item",
1693
- className: mx3("flex w-full", user && "justify-end", classNames)
1694
- }, /* @__PURE__ */ React7.createElement("div", {
1695
- className: mx3(user ? [
1696
- "px-2 py-1 rounded-sm",
1697
- userClassNames
1698
- ] : "w-full")
1699
- }, children));
1700
- } finally {
1701
- _effect.f();
1702
- }
1703
- };
1704
-
1705
- // src/components/ChatThread/reducer.ts
1706
- var messageReducer = ({ current, messages }, message) => {
1707
- let i = 0;
1708
- for (const block of message.content) {
1709
- switch (block.type) {
1710
- case "tool_use":
1711
- case "tool_result": {
1712
- if (current) {
1713
- current.content.push(block);
1714
- } else {
1715
- current = {
1716
- id: [
1717
- message.id,
1718
- i
1719
- ].join("_"),
1720
- role: message.role,
1721
- content: [
1722
- block
1723
- ]
1724
- };
1725
- messages.push(current);
1726
- }
1727
- break;
1728
- }
1729
- case "text":
1730
- default: {
1731
- current = void 0;
1732
- messages.push({
1733
- id: [
1734
- message.id,
1735
- i
1736
- ].join("_"),
1737
- role: message.role,
1738
- content: [
1739
- block
1740
- ]
1741
- });
1742
- break;
1743
- }
1744
- }
1745
- i++;
1746
- }
1747
- return {
1748
- current,
1749
- messages
1750
- };
1751
- };
1752
-
1753
- // src/components/ChatThread/ChatThread.tsx
1754
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, processor, messages, collapse = true, ...props }, forwardedRef) => {
1755
- var _effect = _useSignals11();
1756
- try {
1757
- const userHue = useMemo6(() => {
1758
- return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1759
- }, [
1760
- identity
1761
- ]);
1762
- const { messages: filteredMessages = [] } = useMemo6(() => {
1763
- if (collapse) {
1764
- return (messages ?? []).reduce(messageReducer, {
1765
- messages: []
1766
- });
1767
- } else {
1768
- return {
1769
- messages: messages ?? []
1770
- };
1771
- }
1772
- }, [
1773
- messages,
1774
- collapse
1775
- ]);
1776
- return /* @__PURE__ */ React8.createElement(ScrollContainer, {
1777
- ref: forwardedRef,
1778
- classNames,
1779
- fade: true
1780
- }, /* @__PURE__ */ React8.createElement("div", {
1781
- role: "none",
1782
- className: mx4(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1783
- style: {
1784
- "--user-fill": `var(--dx-${userHue}Fill)`
1785
- }
1786
- }, filteredMessages.map((message) => /* @__PURE__ */ React8.createElement(ChatMessage, {
1787
- key: message.id,
1788
- classNames: "px-4 pbe-4",
1789
- space,
1790
- processor,
1791
- message,
1792
- ...props
1793
- }))));
1794
- } finally {
1795
- _effect.f();
1796
- }
1797
- });
1798
-
1799
- // src/components/Chat/Chat.tsx
1800
- var __dxlog_file9 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
1801
- var Endcap = ({ children }) => {
1802
- var _effect = _useSignals12();
1803
- try {
1804
- return /* @__PURE__ */ React9.createElement("div", {
1805
- className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
1806
- }, children);
1807
- } finally {
1808
- _effect.f();
1809
- }
1810
- };
1811
- var [ChatContextProvider, useChatContext] = createContext("Chat");
1812
- var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...props }) => {
1813
- var _effect = _useSignals12();
1814
- try {
1815
- const space = getSpace(chat);
1816
- const queue = useQueue(chat?.queue.dxn);
1817
- const messages = useMemo7(() => dedupeWith([
1818
- ...queue?.objects?.filter(Obj3.instanceOf(Message)) ?? [],
1819
- ...processor?.messages.value ?? []
1820
- ], (a, b) => a.id === b.id), [
1821
- queue?.objects,
1822
- processor?.messages.value
1823
- ]);
1824
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
1825
- useEffect5(() => {
1826
- if (!processor?.streaming.value && queue?.objects && artifact) {
1827
- const message = queue.objects[queue.objects.length - 1];
1828
- if (dispatch && space && chat && message) {
1829
- void dispatch(createIntent(CollaborationActions.InsertContent, {
1830
- target: artifact,
1831
- object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
1832
- ...chat.queue.dxn.parts,
1833
- message.id
1834
- ])),
1835
- label: "View proposal"
1836
- }));
1837
- }
1838
- }
1839
- }, [
1840
- queue,
1841
- processor?.streaming.value
1842
- ]);
1843
- const event = useMemo7(() => new Event(), []);
1844
- useEffect5(() => {
1845
- return event.on((event2) => {
1846
- switch (event2.type) {
1847
- case "submit": {
1848
- if (!processor.streaming.value) {
1849
- void processor.request(event2.text);
1850
- }
1851
- break;
1852
- }
1853
- case "cancel": {
1854
- void processor.cancel();
1855
- break;
1856
- }
1857
- }
1858
- onEvent?.(event2);
1859
- });
1860
- }, [
1861
- event,
1862
- onEvent
1863
- ]);
1864
- if (!space) {
1865
- return null;
1866
- }
1867
- return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1868
- event,
1869
- chat,
1870
- space,
1871
- processor,
1872
- messages,
1873
- ...props
1874
- }, /* @__PURE__ */ React9.createElement("div", {
1875
- role: "none",
1876
- className: mx5("flex flex-col grow", classNames)
1877
- }, children));
1878
- } finally {
1879
- _effect.f();
1880
- }
1881
- };
1882
- ChatRoot.displayName = "Chat.Root";
1883
- var ChatThread2 = (props) => {
1884
- var _effect = _useSignals12();
1885
- try {
1886
- const { event, space, processor, messages } = useChatContext(ChatThread2.displayName);
1887
- const identity = useIdentity();
1888
- const scrollerRef = useRef2(null);
1889
- useEffect5(() => {
1890
- return event.on((event2) => {
1891
- switch (event2.type) {
1892
- case "submit":
1893
- case "scroll-to-bottom":
1894
- scrollerRef.current?.scrollToBottom("smooth");
1895
- break;
1896
- }
1897
- });
1898
- }, [
1899
- event
1900
- ]);
1901
- const handlePrompt = useCallback4((text) => {
1902
- if (!processor.streaming.value) {
1903
- event.emit({
1904
- type: "submit",
1905
- text
1906
- });
1907
- return true;
1908
- }
1909
- }, [
1910
- processor,
1911
- event
1912
- ]);
1913
- if (!identity) {
1914
- return null;
1915
- }
1916
- return /* @__PURE__ */ React9.createElement(ChatThread, {
1917
- ...props,
1918
- ref: scrollerRef,
1919
- identity,
1920
- space,
1921
- messages,
1922
- tools: processor?.tools,
1923
- onPrompt: handlePrompt
1924
- });
1925
- } finally {
1926
- _effect.f();
1927
- }
1928
- };
1929
- ChatThread2.displayName = "Chat.Thread";
1930
- var ChatPrompt = ({ classNames, placeholder, expandable }) => {
1931
- var _effect = _useSignals12();
1932
- try {
1933
- const { t } = useTranslation5(meta.id);
1934
- const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1935
- const [active, setActive] = useState7(false);
1936
- useEffect5(() => {
1937
- return event.on((event2) => {
1938
- switch (event2.type) {
1939
- case "record-start":
1940
- setActive(true);
1941
- break;
1942
- case "record-stop":
1943
- setActive(false);
1944
- break;
1945
- }
1946
- });
1947
- }, [
1948
- event
1949
- ]);
1950
- const editorRef = useRef2(null);
1951
- const { recording } = useVoiceInput({
1952
- active,
1953
- onUpdate: (text) => {
1954
- editorRef.current?.setText(text);
1955
- editorRef.current?.focus();
1956
- }
1957
- });
1958
- const [blueprints, handleUpdateBlueprints] = useBlueprints(processor.context);
1959
- const contextProvider = useContextProvider(space);
1960
- const extensions = useMemo7(() => {
1961
- return [
1962
- contextProvider && references({
1963
- provider: {
1964
- getReferences: async ({ query }) => contextProvider.query({
1965
- query
1966
- }),
1967
- resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
1968
- uri
1969
- })
1970
- }
1971
- }),
1972
- expandable && Prec.highest(keymap.of([
1973
- {
1974
- key: "cmd-ArrowUp",
1975
- preventDefault: true,
1976
- run: () => {
1977
- event.emit({
1978
- type: "thread-open"
1979
- });
1980
- return true;
1981
- }
1982
- },
1983
- {
1984
- key: "cmd-ArrowDown",
1985
- preventDefault: true,
1986
- run: () => {
1987
- event.emit({
1988
- type: "thread-close"
1989
- });
1990
- return true;
1991
- }
1992
- }
1993
- ]))
1994
- ].filter(isNotFalsy2);
1995
- }, [
1996
- event,
1997
- expandable,
1998
- contextProvider
1999
- ]);
2000
- const handleSubmit = useCallback4((text) => {
2001
- if (!processor.streaming.value) {
2002
- event.emit({
2003
- type: "submit",
2004
- text
2005
- });
2006
- return true;
2007
- }
2008
- }, [
2009
- processor,
2010
- event
2011
- ]);
2012
- const handleEvent = useCallback4((ev) => {
2013
- event.emit(ev);
2014
- }, [
2015
- event
2016
- ]);
2017
- const handleUpdateReferences = useCallback4((ids) => {
2018
- log8.info("update", {
2019
- ids
2020
- }, {
2021
- F: __dxlog_file9,
2022
- L: 289,
2023
- S: void 0,
2024
- C: (f, a) => f(...a)
2025
- });
2026
- }, []);
2027
- return /* @__PURE__ */ React9.createElement("div", {
2028
- className: mx5("is-full grid grid-cols-[var(--rail-action)_1fr_min-content] grid-rows-[min-content_var(--rail-action)]", classNames)
2029
- }, /* @__PURE__ */ React9.createElement(Endcap, null, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
2030
- error: processor.error.value,
2031
- processing: processor.streaming.value
2032
- })), /* @__PURE__ */ React9.createElement(ChatEditor, {
2033
- ref: editorRef,
2034
- autoFocus: true,
2035
- lineWrapping: true,
2036
- classNames: "col-span-2 pis-1 pbs-2",
2037
- placeholder: placeholder ?? t("prompt placeholder"),
2038
- extensions,
2039
- onSubmit: handleSubmit
2040
- }), /* @__PURE__ */ React9.createElement(ChatOptionsMenu, {
2041
- blueprintRegistry: processor.blueprintRegistry,
2042
- blueprints,
2043
- onChange: handleUpdateBlueprints
2044
- }), /* @__PURE__ */ React9.createElement(ChatReferences, {
2045
- classNames: "flex pis-1 items-center",
2046
- space,
2047
- context: processor.context,
2048
- onUpdate: handleUpdateReferences
2049
- }), /* @__PURE__ */ React9.createElement(ChatActions, {
2050
- microphone: true,
2051
- recording,
2052
- processing: processor.streaming.value,
2053
- onEvent: handleEvent
2054
- }));
2055
- } finally {
2056
- _effect.f();
2057
- }
2058
- };
2059
- ChatPrompt.displayName = "Chat.Prompt";
2060
- var Chat = {
2061
- Root: ChatRoot,
2062
- Thread: ChatThread2,
2063
- Prompt: ChatPrompt
2064
- };
2065
-
2066
- export {
2067
- useChatProcessor,
2068
- useServiceContainer,
2069
- Toolbox,
2070
- ToolboxContainer,
2071
- Chat
2072
- };
2073
- //# sourceMappingURL=chunk-D3HTVK5D.mjs.map