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