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