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