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