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

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