@dxos/plugin-assistant 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0

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