@dxos/plugin-assistant 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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