@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,354 +1,2567 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- AssistantSettings,
4
- BlueprintArticle,
5
- Chat,
6
- ChatCompanion,
7
- ChatContainer,
8
- ChatContextProvider,
9
- ChatDialog,
10
- PromptArticle,
11
- Toolbox,
12
- ToolboxContainer,
13
- useActiveBlueprints,
14
- useBlueprintHandlers,
15
- useBlueprintRegistry,
16
- useBlueprints,
17
- useChatContext,
18
- useChatProcessor,
19
- useChatServices,
20
- useChatToolbarActions,
21
- useContextBinder,
22
- useContextObjects,
23
- useFilteredTypes,
24
- useFlush,
25
- useOnline,
26
- usePresets,
27
- useReferencesProvider
28
- } from "./chunk-XI5T3MJC.mjs";
29
- import "./chunk-ZRIPP7YF.mjs";
3
+ AiChatProcessor,
4
+ AiServicePresets
5
+ } from "./chunk-POJO5MTX.mjs";
30
6
  import {
31
- TemplateEditor
32
- } from "./chunk-75PHXBN3.mjs";
7
+ blueprint_default
8
+ } from "./chunk-NZIKC7AN.mjs";
33
9
  import {
34
10
  ApiAuthorization,
35
11
  AssistantCapabilities,
36
12
  AssistantEvents,
37
- AssistantOperation,
38
13
  Assistant_exports,
39
14
  LLM_PROVIDERS,
40
15
  ServiceType,
41
16
  categoryIcons
42
- } from "./chunk-355W5B27.mjs";
43
- import {
44
- ASSISTANT_DIALOG,
45
- meta
46
- } from "./chunk-POWB2BPC.mjs";
47
- import "./chunk-MSBPC4RJ.mjs";
48
- import {
49
- assistant_blueprint_exports
50
- } from "./chunk-DCA5QWQT.mjs";
17
+ } from "./chunk-PY4X6FJT.mjs";
51
18
  import "./chunk-HSLMI22Q.mjs";
52
19
 
53
- // src/capabilities/ai-service/index.ts
54
- import { Capability } from "@dxos/app-framework";
55
- var AiService = Capability.lazy("AiService", () => import("./ai-service-PXKKCFIF.mjs"));
20
+ // src/components/index.ts
21
+ import { lazy } from "react";
22
+
23
+ // src/components/Chat/Chat.tsx
24
+ import { Prec } from "@codemirror/state";
25
+ import { keymap } from "@codemirror/view";
26
+ import { useAtomValue } from "@effect-atom/atom-react";
27
+ import { createContext } from "@radix-ui/react-context";
28
+ import * as Array2 from "effect/Array";
29
+ import * as Option3 from "effect/Option";
30
+ import React9, { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState5 } from "react";
31
+ import { Event } from "@dxos/async";
32
+ import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
33
+ import { useVoiceInput } from "@dxos/plugin-transcription";
34
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
35
+ import { useIdentity } from "@dxos/react-client/halo";
36
+ import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
37
+ import { ChatEditor } from "@dxos/react-ui-chat";
38
+ import { Menu } from "@dxos/react-ui-menu";
39
+ import { Message } from "@dxos/types";
40
+ import { composable, composableProps, mx as mx6 } from "@dxos/ui-theme";
41
+ import { isTruthy } from "@dxos/util";
42
+ import { useChatToolbarActions } from "#hooks";
43
+ import { meta as meta5 } from "#meta";
44
+
45
+ // src/components/ChatPrompt/ChatActions.tsx
46
+ import React from "react";
47
+ import { IconButton, useTranslation } from "@dxos/react-ui";
48
+ import { mx } from "@dxos/ui-theme";
49
+ import { meta } from "#meta";
50
+ var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
51
+ const { t } = useTranslation(meta.id);
52
+ return /* @__PURE__ */ React.createElement("div", {
53
+ className: mx("flex items-center me-1", classNames)
54
+ }, children, /* @__PURE__ */ React.createElement(IconButton, {
55
+ disabled: !processing,
56
+ variant: "ghost",
57
+ icon: "ph--x--regular",
58
+ iconOnly: true,
59
+ label: t("cancel-processing.button"),
60
+ onClick: () => onEvent?.({
61
+ type: "cancel"
62
+ })
63
+ }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
64
+ disabled: !processing,
65
+ classNames: mx(recording && "bg-primary-500"),
66
+ variant: "ghost",
67
+ icon: "ph--microphone--regular",
68
+ iconOnly: true,
69
+ noTooltip: true,
70
+ label: t("microphone.button"),
71
+ onMouseDown: () => onEvent?.({
72
+ type: "record-start"
73
+ }),
74
+ onMouseUp: () => onEvent?.({
75
+ type: "record-stop"
76
+ }),
77
+ onTouchStart: () => onEvent?.({
78
+ type: "record-start"
79
+ }),
80
+ onTouchEnd: () => onEvent?.({
81
+ type: "record-stop"
82
+ })
83
+ }), /* @__PURE__ */ React.createElement(IconButton, {
84
+ variant: "ghost",
85
+ icon: "ph--wrench--regular",
86
+ iconOnly: true,
87
+ label: t("debug.button"),
88
+ onClick: () => onEvent?.({
89
+ type: "toggle-debug"
90
+ })
91
+ }));
92
+ };
93
+
94
+ // src/components/ChatPrompt/ChatOptions.tsx
95
+ import * as Option from "effect/Option";
96
+ import React2, { useMemo, useState } from "react";
97
+ import { Filter, Obj, Type } from "@dxos/echo";
98
+ import { Annotation } from "@dxos/echo";
99
+ import { useQuery } from "@dxos/react-client/echo";
100
+ import { IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
101
+ import { Listbox, SearchList, useSearchListResults } from "@dxos/react-ui-search";
102
+ import { Tabs } from "@dxos/react-ui-tabs";
103
+ import { getStyles, mx as mx2 } from "@dxos/ui-theme";
104
+ import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
105
+ import { meta as meta2 } from "#meta";
106
+ var panelClassNames = "w-[calc(100dvw-.5rem)] sm:w-max md:w-72 max-w-document-width";
107
+ var ChatOptions = ({ db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
108
+ const { t } = useTranslation2(meta2.id);
109
+ return /* @__PURE__ */ React2.createElement("div", {
110
+ role: "none",
111
+ className: "flex p-2"
112
+ }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
113
+ asChild: true
114
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
115
+ variant: "ghost",
116
+ icon: "ph--plus--regular",
117
+ iconOnly: true,
118
+ label: t("context-objects.button")
119
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
120
+ side: "top",
121
+ classNames: panelClassNames
122
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
123
+ db,
124
+ context
125
+ })), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
126
+ asChild: true
127
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
128
+ variant: "ghost",
129
+ icon: "ph--sliders-horizontal--regular",
130
+ iconOnly: true,
131
+ label: t("context-settings.button")
132
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
133
+ side: "top",
134
+ classNames: panelClassNames
135
+ }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Tabs.Root, {
136
+ orientation: "horizontal",
137
+ defaultValue: "blueprints",
138
+ defaultActivePart: "list",
139
+ tabIndex: -1
140
+ }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
141
+ classNames: mx2("max-h-(--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-h-0 [&_[role="listbox"]]:overflow-y-auto', '[&_[role="tabpanel"]]:min-h-0 [&_[role="tabpanel"]]:px-form-chrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden')
142
+ }, /* @__PURE__ */ React2.createElement(Tabs.Panel, {
143
+ value: "blueprints",
144
+ tabIndex: -1,
145
+ classNames: "dx-focus-ring-inset"
146
+ }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
147
+ blueprintRegistry,
148
+ db,
149
+ context
150
+ })), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
151
+ value: "model",
152
+ tabIndex: -1,
153
+ classNames: "dx-focus-ring-inset px-0!"
154
+ }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
155
+ presets,
156
+ preset,
157
+ onPresetChange
158
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
159
+ classNames: "justify-center p-form-chrome border-y border-subdued-separator order-last"
160
+ }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
161
+ value: "blueprints",
162
+ icon: "ph--blueprint--regular",
163
+ label: t("blueprints-in-context.title")
164
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
165
+ value: "model",
166
+ label: t("chat-model.title"),
167
+ icon: "ph--cpu--regular"
168
+ }))))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
169
+ };
170
+ var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
171
+ const { t } = useTranslation2(meta2.id);
172
+ const blueprints = useBlueprints({
173
+ blueprintRegistry,
174
+ db
175
+ });
176
+ const activeBlueprints = useActiveBlueprints({
177
+ context
178
+ });
179
+ const { onUpdateBlueprint } = useBlueprintHandlers({
180
+ db,
181
+ context,
182
+ blueprintRegistry
183
+ });
184
+ const { results, handleSearch } = useSearchListResults({
185
+ items: blueprints,
186
+ extract: (blueprint) => blueprint.name
187
+ });
188
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
189
+ onSearch: handleSearch
190
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
191
+ classNames: "py-form-chrome"
192
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.map((blueprint) => {
193
+ const isActive = activeBlueprints.has(blueprint.key);
194
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
195
+ classNames: "flex items-center overflow-hidden",
196
+ key: blueprint.key,
197
+ value: blueprint.key,
198
+ label: blueprint.name,
199
+ checked: isActive,
200
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
201
+ });
202
+ }))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
203
+ placeholder: t("search.placeholder"),
204
+ classNames: "mb-form-chrome",
205
+ autoFocus: true
206
+ }));
207
+ };
208
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
209
+ return /* @__PURE__ */ React2.createElement(Listbox.Root, {
210
+ value: preset,
211
+ onValueChange: onPresetChange,
212
+ autoFocus: true
213
+ }, presets?.map(({ id, label }) => {
214
+ return /* @__PURE__ */ React2.createElement(Listbox.Option, {
215
+ key: id,
216
+ value: id
217
+ }, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
218
+ }));
219
+ };
220
+ var ANY = "__any__";
221
+ var ObjectsPanel = ({ db, context }) => {
222
+ const { t } = useTranslation2(meta2.id);
223
+ const types = useFilteredTypes(db);
224
+ const typenames = useMemo(() => {
225
+ const typenames2 = types.map((type) => {
226
+ const typename2 = Type.getTypename(type);
227
+ return {
228
+ typename: typename2,
229
+ label: t("typename.label", {
230
+ ns: typename2,
231
+ defaultValue: typename2
232
+ })
233
+ };
234
+ });
235
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
236
+ return typenames2;
237
+ }, [
238
+ types
239
+ ]);
240
+ const [typename, setTypename] = useState(ANY);
241
+ const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
242
+ typenames
243
+ ]);
244
+ const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
245
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
246
+ db,
247
+ context
248
+ });
249
+ const { results, handleSearch } = useSearchListResults({
250
+ items: objects,
251
+ extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
252
+ });
253
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
254
+ onSearch: handleSearch
255
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
256
+ classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
257
+ }, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
258
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
259
+ const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
260
+ icon: DEFAULT_OBJECT_ICON,
261
+ hue: void 0
262
+ })));
263
+ const styles = hue ? getStyles(hue) : void 0;
264
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
265
+ classNames: "flex items-center overflow-hidden",
266
+ key: object.id,
267
+ value: object.id,
268
+ icon,
269
+ iconClassNames: styles?.surfaceText,
270
+ label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
271
+ checked: isActive,
272
+ onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
273
+ });
274
+ }) : /* @__PURE__ */ React2.createElement(SearchList.Item, {
275
+ value: "__empty__",
276
+ label: t("no-results.message")
277
+ }))), /* @__PURE__ */ React2.createElement("div", {
278
+ role: "none",
279
+ className: "grid grid-cols-[min-content_1fr] gap-2 px-form-chrome mb-form-chrome"
280
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
281
+ value: typename === ANY ? void 0 : typename,
282
+ onValueChange: setTypename
283
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
284
+ placeholder: t("type-filter.placeholder")
285
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
286
+ value: ANY
287
+ }, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
288
+ key: typename2,
289
+ value: typename2
290
+ }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
291
+ placeholder: t("search.placeholder"),
292
+ classNames: "mb-0",
293
+ autoFocus: true
294
+ })));
295
+ };
296
+ var DEFAULT_OBJECT_ICON = "ph--cube--regular";
297
+
298
+ // src/components/ChatPrompt/ChatPresets.tsx
299
+ import React3 from "react";
300
+ import { Select as Select2 } from "@dxos/react-ui";
301
+
302
+ // src/components/ChatPrompt/ChatReferences.tsx
303
+ import * as Option2 from "effect/Option";
304
+ import React4 from "react";
305
+ import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
306
+ import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
307
+ import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
308
+ import { useContextObjects as useContextObjects2 } from "#hooks";
309
+ import { meta as meta3 } from "#meta";
310
+ var ChatReferences = ({ classNames, context, db }) => {
311
+ const { t } = useTranslation3(meta3.id);
312
+ const { objects, onUpdateObject } = useContextObjects2({
313
+ db,
314
+ context
315
+ });
316
+ return /* @__PURE__ */ React4.createElement("ul", {
317
+ className: mx3("flex", classNames)
318
+ }, objects.map((obj) => {
319
+ const dxn = Obj2.getDXN(obj);
320
+ const typename = Obj2.getTypename(obj);
321
+ const label = Obj2.getLabel(obj) ?? (typename ? [
322
+ "object-name.placeholder",
323
+ {
324
+ ns: typename
325
+ }
326
+ ] : obj.id);
327
+ const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
328
+ icon: DEFAULT_OBJECT_ICON2,
329
+ hue: void 0
330
+ })));
331
+ const styles = hue ? getStyles2(hue) : void 0;
332
+ return /* @__PURE__ */ React4.createElement("li", {
333
+ key: dxn.toString(),
334
+ className: "dx-tag py-0 ps-2 flex items-center gap-1",
335
+ "data-hue": "neutral"
336
+ }, /* @__PURE__ */ React4.createElement(Icon, {
337
+ icon,
338
+ size: 4,
339
+ classNames: styles?.surfaceText
340
+ }), toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
341
+ icon: "ph--x--bold",
342
+ iconOnly: true,
343
+ variant: "ghost",
344
+ label: t("remove-object-in-context.label"),
345
+ classNames: "p-0 hover:bg-transparent",
346
+ size: 3,
347
+ onClick: () => onUpdateObject?.(dxn, false)
348
+ }));
349
+ }));
350
+ };
351
+ var DEFAULT_OBJECT_ICON2 = "ph--cube--regular";
352
+
353
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
354
+ import React5, { useEffect, useState as useState2 } from "react";
355
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
356
+ import { Spinner } from "@dxos/react-ui-sfx";
357
+ import { mx as mx4 } from "@dxos/ui-theme";
358
+ var period = 3e3;
359
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
360
+ const [init, setInit] = useState2(false);
361
+ useEffect(() => setInit(false), [
362
+ preset
363
+ ]);
364
+ useTimeout(async () => {
365
+ setInit(true);
366
+ }, period / 2, [
367
+ preset
368
+ ]);
369
+ return /* @__PURE__ */ React5.createElement("div", {
370
+ role: "none",
371
+ className: mx4("relative flex", classNames)
372
+ }, /* @__PURE__ */ React5.createElement(Spinner, {
373
+ duration: period,
374
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
375
+ ...props
376
+ }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
377
+ asChild: true,
378
+ content: error.message
379
+ }, /* @__PURE__ */ React5.createElement("div", {
380
+ className: "absolute inset-0"
381
+ })));
382
+ };
383
+
384
+ // src/components/ChatThread/ChatThread.tsx
385
+ import React8, { forwardRef, useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
386
+ import { PublicKey } from "@dxos/keys";
387
+ import { useForwardedRef } from "@dxos/react-ui";
388
+ import { MarkdownStream } from "@dxos/react-ui-components";
389
+ import { mx as mx5 } from "@dxos/ui-theme";
390
+ import { keyToFallback } from "@dxos/util";
391
+
392
+ // src/components/ChatThread/registry.tsx
393
+ import React7 from "react";
394
+ import { log } from "@dxos/log";
395
+ import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
396
+ import { PromptWidget, ReasoningWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget } from "@dxos/react-ui-components";
397
+ import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
398
+ import { ContentBlock } from "@dxos/types";
399
+ import { getXmlTextChild } from "@dxos/ui-editor";
400
+
401
+ // src/components/ToolBlock/ToolBlock.tsx
402
+ import React6, { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
403
+ import { useTranslation as useTranslation4 } from "@dxos/react-ui";
404
+ import { NumericTabs, TextCrawl, TogglePanel } from "@dxos/react-ui-components";
405
+ import { Json } from "@dxos/react-ui-syntax-highlighter";
406
+ import { isNonNullable, safeParseJson } from "@dxos/util";
407
+ import { meta as meta4 } from "#meta";
408
+ var ToolBlock = ({ view, blocks = [] }) => {
409
+ const { t } = useTranslation4(meta4.id);
410
+ const items = useMemo2(() => {
411
+ let lastToolCall;
412
+ const tools = [];
413
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
414
+ switch (block._tag) {
415
+ case "toolCall": {
416
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
417
+ return null;
418
+ }
419
+ const tool = tools.find((tool2) => tool2.name === block.name);
420
+ lastToolCall = {
421
+ tool,
422
+ block
423
+ };
424
+ return {
425
+ title: tool?.description ?? [
426
+ t("tool-call.label"),
427
+ tool?.name
428
+ ].join(" "),
429
+ content: {
430
+ ...block,
431
+ input: safeParseJson(block.input)
432
+ }
433
+ };
434
+ }
435
+ case "toolResult": {
436
+ if (block.error) {
437
+ return {
438
+ title: t("tool-error.label"),
439
+ content: block
440
+ };
441
+ }
442
+ const title = lastToolCall?.tool?.description ?? [
443
+ t("tool-result.label"),
444
+ lastToolCall?.tool?.name
445
+ ].join(" ");
446
+ lastToolCall = void 0;
447
+ return {
448
+ title,
449
+ content: {
450
+ ...block,
451
+ result: safeParseJson(block.result)
452
+ }
453
+ };
454
+ }
455
+ case "stats": {
456
+ if (!lastToolCall) {
457
+ return null;
458
+ }
459
+ return {
460
+ title: t("stats.label"),
461
+ content: block
462
+ };
463
+ }
464
+ }
465
+ }).filter(isNonNullable);
466
+ }, [
467
+ blocks
468
+ ]);
469
+ const handleChangeOpen = useCallback(() => {
470
+ setTimeout(() => {
471
+ view?.requestMeasure();
472
+ }, 1e3);
473
+ }, [
474
+ view
475
+ ]);
476
+ if (!items.length) {
477
+ return null;
478
+ }
479
+ return /* @__PURE__ */ React6.createElement(ToolPanel, {
480
+ items,
481
+ onChangeOpen: handleChangeOpen
482
+ });
483
+ };
484
+ ToolBlock.displayName = "ToolBlock";
485
+ var ToolPanel = ({ items, onChangeOpen }) => {
486
+ const tabsRef = useRef(null);
487
+ const [selected, setSelected] = useState3(0);
488
+ const [open, setOpen] = useState3(false);
489
+ useEffect2(() => {
490
+ onChangeOpen?.(open);
491
+ if (open) {
492
+ tabsRef.current?.focus();
493
+ }
494
+ }, [
495
+ open,
496
+ onChangeOpen
497
+ ]);
498
+ const handleSelect = useCallback((index) => {
499
+ setSelected(index);
500
+ }, []);
501
+ return /* @__PURE__ */ React6.createElement(TogglePanel.Root, {
502
+ classNames: "mt-2 w-full rounded-xs",
503
+ open,
504
+ onChangeOpen: setOpen
505
+ }, /* @__PURE__ */ React6.createElement(TogglePanel.Header, {
506
+ classNames: "text-sm text-placeholder"
507
+ }, /* @__PURE__ */ React6.createElement(TextCrawl, {
508
+ key: "status-roll",
509
+ lines: items.map((item) => item.title),
510
+ autoAdvance: true,
511
+ greedy: true
512
+ })), /* @__PURE__ */ React6.createElement(TogglePanel.Content, {
513
+ classNames: "grid grid-cols-[32px_1fr]"
514
+ }, /* @__PURE__ */ React6.createElement(NumericTabs, {
515
+ ref: tabsRef,
516
+ classNames: "p-1",
517
+ length: items.length,
518
+ selected,
519
+ onSelect: handleSelect
520
+ }), /* @__PURE__ */ React6.createElement(Json.Data, {
521
+ data: items[selected]?.content,
522
+ classNames: "p-1 text-xs bg-transparent",
523
+ replacer: {
524
+ maxDepth: 3,
525
+ maxArrayLen: 10,
526
+ maxStringLen: 128
527
+ }
528
+ })));
529
+ };
530
+
531
+ // src/components/ChatThread/registry.tsx
532
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
533
+ var Fallback = ({ _tag, ...props }) => {
534
+ return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
535
+ classNames: "rounded-xs"
536
+ }, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
537
+ classNames: "bg-group-surface"
538
+ }, _tag), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, {
539
+ classNames: "bg-modal-surface"
540
+ }, /* @__PURE__ */ React7.createElement(Json2.Data, {
541
+ classNames: "p-2! text-sm",
542
+ data: props
543
+ })));
544
+ };
545
+ var Summary = ({ text }) => {
546
+ return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
547
+ classNames: "rounded-sm"
548
+ }, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
549
+ classNames: "bg-group-surface"
550
+ }, "Conversation summarized"), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, {
551
+ classNames: "bg-modal-surface"
552
+ }, text));
553
+ };
554
+ var componentRegistry = {
555
+ //
556
+ // Widgets
557
+ //
558
+ prompt: {
559
+ block: true,
560
+ factory: ({ children }) => {
561
+ const text = getXmlTextChild(children);
562
+ return text ? new PromptWidget(text) : null;
563
+ }
564
+ },
565
+ reasoning: {
566
+ block: true,
567
+ factory: ({ children }) => {
568
+ const text = getXmlTextChild(children);
569
+ return text ? new ReasoningWidget(text) : null;
570
+ }
571
+ },
572
+ reference: {
573
+ block: false,
574
+ factory: ({ children, ref }) => {
575
+ const text = getXmlTextChild(children);
576
+ return text && ref ? new ReferenceWidget(text, ref) : null;
577
+ }
578
+ },
579
+ select: {
580
+ block: true,
581
+ factory: ({ children }) => {
582
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
583
+ return options?.length ? new SelectWidget(options) : null;
584
+ }
585
+ },
586
+ suggestion: {
587
+ block: true,
588
+ factory: ({ children }) => {
589
+ const text = getXmlTextChild(children);
590
+ return text ? new SuggestionWidget(text) : null;
591
+ }
592
+ },
593
+ stats: {
594
+ block: true,
595
+ factory: ({ children }) => {
596
+ const text = getXmlTextChild(children);
597
+ return text ? new SummaryWidget(text) : null;
598
+ }
599
+ },
600
+ //
601
+ // React
602
+ //
603
+ toolCall: {
604
+ block: true,
605
+ Component: ToolBlock
606
+ },
607
+ toolResult: {
608
+ block: true,
609
+ Component: Fallback
610
+ },
611
+ toolkit: {
612
+ block: true,
613
+ Component: Fallback
614
+ },
615
+ summary: {
616
+ block: true,
617
+ Component: Summary
618
+ },
619
+ //
620
+ // Fallback
621
+ //
622
+ json: {
623
+ block: true,
624
+ Component: Fallback
625
+ }
626
+ };
627
+ var blockToMarkdown = (context, message, block) => {
628
+ let str = blockToMarkdownImpl(context, message, block);
629
+ if (str && !block.pending) {
630
+ return str += "\n";
631
+ }
632
+ return str;
633
+ };
634
+ var blockToMarkdownImpl = (context, message, block) => {
635
+ log("blockToMarkdown", {
636
+ block: JSON.stringify(block)
637
+ }, {
638
+ F: __dxlog_file,
639
+ L: 146,
640
+ S: void 0,
641
+ C: (f, a) => f(...a)
642
+ });
643
+ switch (block._tag) {
644
+ case "text": {
645
+ if (message.sender.role === "user") {
646
+ return `<prompt>${block.text}</prompt>`;
647
+ } else {
648
+ const text = block.text.trim();
649
+ if (text.length > 0) {
650
+ return text;
651
+ }
652
+ }
653
+ break;
654
+ }
655
+ case "reference": {
656
+ const dxn = block.reference.dxn;
657
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
658
+ }
659
+ case "suggestion": {
660
+ if (block.pending) {
661
+ return;
662
+ }
663
+ return `<suggestion>${block.text}</suggestion>`;
664
+ }
665
+ case "select": {
666
+ if (block.pending || block.options.length === 0) {
667
+ return;
668
+ }
669
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
670
+ }
671
+ case "toolCall": {
672
+ context.updateWidget(block.toolCallId, {
673
+ blocks: [
674
+ block
675
+ ]
676
+ });
677
+ return `<toolCall id="${block.toolCallId}" />`;
678
+ }
679
+ case "toolResult": {
680
+ context.updateWidget(block.toolCallId, ({ blocks = [] } = {
681
+ blocks: []
682
+ }) => ({
683
+ blocks: [
684
+ ...blocks,
685
+ block
686
+ ]
687
+ }));
688
+ break;
689
+ }
690
+ case "stats": {
691
+ return `<stats>${ContentBlock.createStatsMessage(block)}</stats>`;
692
+ }
693
+ case "reasoning": {
694
+ const text = block.reasoningText ?? block.redactedText;
695
+ if (!text) {
696
+ return;
697
+ }
698
+ return `<reasoning>${text.replace(/\n/g, " ").trim()}</reasoning>`;
699
+ }
700
+ case "summary": {
701
+ return `<summary>${block.content}</summary>`;
702
+ }
703
+ default: {
704
+ return `<json id="${message.id}">
705
+ ${JSON.stringify(block)}
706
+ </json>`;
707
+ }
708
+ }
709
+ };
710
+
711
+ // src/components/ChatThread/sync.ts
712
+ import { log as log2 } from "@dxos/log";
713
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
714
+ var MessageThreadContext = class {
715
+ _widgetState;
716
+ constructor(_widgetState) {
717
+ this._widgetState = _widgetState;
718
+ }
719
+ updateWidget(id, value2) {
720
+ this._widgetState?.updateWidget(id, value2);
721
+ }
722
+ // TODO(burdon): Resolve from hypergraph.
723
+ getObjectLabel(_id) {
724
+ return "Object";
725
+ }
726
+ };
727
+ var MessageSyncer = class {
728
+ _model;
729
+ _blockRenderer;
730
+ _initialMessageId;
731
+ _currentMessageIndex = 0;
732
+ _currentBlockIndex = 0;
733
+ _currentBlockContent;
734
+ _context;
735
+ constructor(_model, _blockRenderer) {
736
+ this._model = _model;
737
+ this._blockRenderer = _blockRenderer;
738
+ this._context = new MessageThreadContext(this._model);
739
+ }
740
+ get context() {
741
+ return this._context;
742
+ }
743
+ reset() {
744
+ log2("reset", void 0, {
745
+ F: __dxlog_file2,
746
+ L: 64,
747
+ S: this,
748
+ C: (f, a) => f(...a)
749
+ });
750
+ this._initialMessageId = void 0;
751
+ this._currentMessageIndex = 0;
752
+ this._currentBlockIndex = 0;
753
+ this._currentBlockContent = void 0;
754
+ void this._model.reset("");
755
+ }
756
+ /**
757
+ * Syncs messages with the editor.
758
+ */
759
+ append(messages, flush = false) {
760
+ messages = messages.map((message) => ({
761
+ ...message,
762
+ blocks: message.blocks.filter((block) => !block.pending || block._tag === "text")
763
+ }));
764
+ if (this._initialMessageId !== messages[0]?.id) {
765
+ this.reset();
766
+ this._initialMessageId = messages[0]?.id;
767
+ }
768
+ if (flush && this._model.view?.state.doc.length === 0) {
769
+ const buffer = [];
770
+ this.process(messages, (content2) => {
771
+ buffer.push(content2);
772
+ });
773
+ const content = buffer.join("");
774
+ this._model.view?.dispatch({
775
+ changes: [
776
+ {
777
+ from: 0,
778
+ to: this._model.view?.state.doc.length ?? 0,
779
+ insert: content
780
+ }
781
+ ],
782
+ selection: {
783
+ anchor: content.length
784
+ }
785
+ });
786
+ return true;
787
+ } else {
788
+ this.process(messages, (content) => {
789
+ void this._model.append(content);
790
+ });
791
+ return false;
792
+ }
793
+ }
794
+ process(messages, append) {
795
+ let i = this._currentMessageIndex;
796
+ for (const message of messages.slice(this._currentMessageIndex)) {
797
+ if (i > this._currentMessageIndex) {
798
+ this._currentBlockIndex = 0;
799
+ }
800
+ this._currentMessageIndex = i;
801
+ let j = this._currentBlockIndex;
802
+ for (const block of message.blocks.slice(this._currentBlockIndex)) {
803
+ this._currentBlockIndex = j;
804
+ const currentBlockContent = this._blockRenderer(this._context, message, block);
805
+ if (currentBlockContent) {
806
+ let content = "";
807
+ if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
808
+ content = currentBlockContent.slice(this._currentBlockContent.length);
809
+ } else {
810
+ content = currentBlockContent;
811
+ }
812
+ this._currentBlockContent = currentBlockContent;
813
+ append(content);
814
+ }
815
+ if (block.pending) {
816
+ return;
817
+ } else {
818
+ this._currentBlockContent = void 0;
819
+ this._currentBlockIndex++;
820
+ }
821
+ j++;
822
+ }
823
+ i++;
824
+ }
825
+ }
826
+ };
827
+
828
+ // src/components/ChatThread/ChatThread.tsx
829
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent }, forwardedRef) => {
830
+ const controllerRef = useForwardedRef(forwardedRef);
831
+ const [controller, setController] = useState4(null);
832
+ const refCallback = useCallback2((node) => {
833
+ controllerRef.current = node;
834
+ setController(node);
835
+ }, [
836
+ controllerRef
837
+ ]);
838
+ const userHue = useMemo3(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
839
+ identity
840
+ ]);
841
+ useEffect3(() => {
842
+ controller?.scrollToBottom();
843
+ }, [
844
+ controller,
845
+ error
846
+ ]);
847
+ const syncer = useMemo3(() => controller && new MessageSyncer(controller, blockToMarkdown), [
848
+ controller
849
+ ]);
850
+ useEffect3(() => {
851
+ const reset = syncer?.append(messages, true);
852
+ if (reset) {
853
+ controller?.scrollToBottom("instant");
854
+ }
855
+ }, [
856
+ syncer,
857
+ messages
858
+ ]);
859
+ const handleEvent = useCallback2(({ type, value: value2 }) => {
860
+ switch (type) {
861
+ case "submit": {
862
+ value2 && onEvent?.({
863
+ type,
864
+ text: value2
865
+ });
866
+ break;
867
+ }
868
+ }
869
+ }, [
870
+ onEvent
871
+ ]);
872
+ return /* @__PURE__ */ React8.createElement("div", {
873
+ role: "none",
874
+ className: mx5("flex h-full w-full justify-center overflow-hidden", classNames),
875
+ style: {
876
+ "--user-fill": `var(--color-${userHue}-fill)`
877
+ }
878
+ }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
879
+ ref: refCallback,
880
+ registry: componentRegistry,
881
+ cursor,
882
+ fadeIn,
883
+ debug,
884
+ onEvent: handleEvent
885
+ }));
886
+ });
887
+
888
+ // src/components/Chat/Chat.tsx
889
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
890
+ var ChatRoot = ({ children, chat, queue, processor, onEvent, ...props }) => {
891
+ const [debug, setDebug] = useState5(false);
892
+ const pending = useAtomValue(processor.messages);
893
+ const streaming = useAtomValue(processor.streaming);
894
+ const lastPrompt = useRef2(void 0);
895
+ const storedMessages = useQuery2(queue, Filter2.type(Message.Message));
896
+ const messages = useMemo4(() => {
897
+ return Array2.dedupeWith([
898
+ ...storedMessages,
899
+ ...pending
900
+ ], ({ id: a }, { id: b }) => a === b);
901
+ }, [
902
+ storedMessages,
903
+ pending
904
+ ]);
905
+ const event = useMemo4(() => new Event(), []);
906
+ useEffect4(() => {
907
+ return event.on((ev) => {
908
+ switch (ev.type) {
909
+ case "toggle-debug": {
910
+ setDebug((debug2) => !debug2);
911
+ queueMicrotask(async () => {
912
+ const objects = processor.context.getObjects();
913
+ const blueprints = processor.context.getBlueprints();
914
+ const tools = await processor.getTools();
915
+ const system = await processor.getSystemPrompt();
916
+ console.log("Chat processor state:", {
917
+ objects,
918
+ blueprints
919
+ });
920
+ console.log(`
921
+ ==== System Prompt ====
922
+ ${system}
923
+ ==== Tools ====
924
+ ${Object.values(tools).map((tool) => JSON.stringify(tool, null, 2)).join("\n")}
925
+ `);
926
+ });
927
+ break;
928
+ }
929
+ case "submit": {
930
+ const text = ev.text.trim();
931
+ if (!streaming && text.length) {
932
+ lastPrompt.current = ev.text;
933
+ void processor.request({
934
+ message: text
935
+ });
936
+ }
937
+ break;
938
+ }
939
+ case "retry": {
940
+ if (!streaming) {
941
+ void processor.retry();
942
+ }
943
+ break;
944
+ }
945
+ case "cancel": {
946
+ if (streaming) {
947
+ void processor.cancel();
948
+ if (lastPrompt.current) {
949
+ event.emit({
950
+ type: "update-prompt",
951
+ text: lastPrompt.current
952
+ });
953
+ }
954
+ }
955
+ break;
956
+ }
957
+ }
958
+ onEvent?.(ev);
959
+ });
960
+ }, [
961
+ event,
962
+ processor,
963
+ streaming,
964
+ onEvent
965
+ ]);
966
+ const db = props.db ?? (chat && Obj3.getDatabase(chat));
967
+ return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
968
+ debug,
969
+ event,
970
+ db,
971
+ chat,
972
+ messages,
973
+ processor,
974
+ ...props
975
+ }, children);
976
+ };
977
+ ChatRoot.displayName = "Chat.Root";
978
+ var CHAT_VIEWPORT_NAME = "Chat.Viewport";
979
+ var ChatViewport = composable(({ children, ...props }, forwardedRef) => {
980
+ return /* @__PURE__ */ React9.createElement("div", {
981
+ ...composableProps(props, {
982
+ classNames: "dx-expander flex flex-col"
983
+ }),
984
+ ref: forwardedRef
985
+ }, children);
986
+ });
987
+ ChatViewport.displayName = CHAT_VIEWPORT_NAME;
988
+ var CHAT_THREAD_NAME = "Chat.Thread";
989
+ var ChatThread2 = (props) => {
990
+ const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
991
+ const identity = useIdentity();
992
+ const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
993
+ const controllerRef = useRef2(null);
994
+ useEffect4(() => {
995
+ return event.on((event2) => {
996
+ switch (event2.type) {
997
+ case "submit":
998
+ case "scroll-to-bottom":
999
+ controllerRef.current?.scrollToBottom();
1000
+ break;
1001
+ case "nav-previous":
1002
+ controllerRef.current?.navigatePrevious();
1003
+ break;
1004
+ case "nav-next":
1005
+ controllerRef.current?.navigateNext();
1006
+ break;
1007
+ }
1008
+ });
1009
+ }, [
1010
+ event
1011
+ ]);
1012
+ const handleEvent = useCallback3((ev) => {
1013
+ event.emit(ev);
1014
+ }, [
1015
+ event
1016
+ ]);
1017
+ if (!identity) {
1018
+ return null;
1019
+ }
1020
+ return /* @__PURE__ */ React9.createElement(ChatThread, {
1021
+ ...props,
1022
+ identity,
1023
+ messages,
1024
+ error,
1025
+ debug,
1026
+ onEvent: handleEvent,
1027
+ ref: controllerRef
1028
+ });
1029
+ };
1030
+ ChatThread2.displayName = CHAT_THREAD_NAME;
1031
+ var CHAT_PROMPT_NAME = "Chat.Prompt";
1032
+ var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1033
+ const { t } = useTranslation5(meta5.id);
1034
+ const { db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
1035
+ const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
1036
+ const streaming = useAtomValue(processor.streaming);
1037
+ const active = useAtomValue(processor.active);
1038
+ const activeRef = useDynamicRef(active);
1039
+ const editorRef = useRef2(null);
1040
+ const [recordingState, setRecordingState] = useState5(false);
1041
+ useEffect4(() => {
1042
+ return event.on((event2) => {
1043
+ switch (event2.type) {
1044
+ case "update-prompt":
1045
+ if (!editorRef.current?.getText()?.length) {
1046
+ editorRef.current?.setText(event2.text);
1047
+ editorRef.current?.focus();
1048
+ }
1049
+ break;
1050
+ case "record-start":
1051
+ setRecordingState(true);
1052
+ break;
1053
+ case "record-stop":
1054
+ setRecordingState(false);
1055
+ break;
1056
+ }
1057
+ });
1058
+ }, [
1059
+ event
1060
+ ]);
1061
+ const { recording } = useVoiceInput({
1062
+ active: recordingState,
1063
+ onUpdate: (text) => {
1064
+ editorRef.current?.setText(text);
1065
+ editorRef.current?.focus();
1066
+ }
1067
+ });
1068
+ const extensions = useMemo4(() => {
1069
+ return [
1070
+ Prec.highest(keymap.of([
1071
+ {
1072
+ key: "Mod-d",
1073
+ preventDefault: true,
1074
+ run: () => {
1075
+ event.emit({
1076
+ type: "toggle-debug"
1077
+ });
1078
+ return true;
1079
+ }
1080
+ },
1081
+ {
1082
+ key: "Mod-ArrowUp",
1083
+ preventDefault: true,
1084
+ run: () => {
1085
+ event.emit({
1086
+ type: "nav-previous"
1087
+ });
1088
+ return true;
1089
+ },
1090
+ shift: () => {
1091
+ event.emit({
1092
+ type: "thread-open"
1093
+ });
1094
+ return true;
1095
+ }
1096
+ },
1097
+ {
1098
+ key: "Mod-ArrowDown",
1099
+ preventDefault: true,
1100
+ run: () => {
1101
+ event.emit({
1102
+ type: "nav-next"
1103
+ });
1104
+ return true;
1105
+ },
1106
+ shift: () => {
1107
+ event.emit({
1108
+ type: "thread-close"
1109
+ });
1110
+ return true;
1111
+ }
1112
+ }
1113
+ ]))
1114
+ ].filter(isTruthy);
1115
+ }, [
1116
+ event,
1117
+ expandable
1118
+ ]);
1119
+ const handleSubmit = useCallback3((text) => {
1120
+ if (!activeRef.current) {
1121
+ event.emit({
1122
+ type: "submit",
1123
+ text
1124
+ });
1125
+ return true;
1126
+ }
1127
+ }, [
1128
+ event
1129
+ ]);
1130
+ const handleEvent = useCallback3((ev) => {
1131
+ event.emit(ev);
1132
+ }, [
1133
+ event
1134
+ ]);
1135
+ return /* @__PURE__ */ React9.createElement("div", {
1136
+ role: "group",
1137
+ className: mx6("flex flex-col w-full dx-density-fine", outline && "bg-group-surface border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded-sm", classNames)
1138
+ }, /* @__PURE__ */ React9.createElement("div", {
1139
+ role: "none",
1140
+ className: "flex p-2 gap-2"
1141
+ }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1142
+ classNames: "p-1",
1143
+ preset,
1144
+ error,
1145
+ processing: streaming
1146
+ }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1147
+ ref: editorRef,
1148
+ autoFocus: true,
1149
+ lineWrapping: true,
1150
+ classNames: "col-span-2 pt-0.5",
1151
+ placeholder: placeholder ?? t("prompt.placeholder"),
1152
+ extensions,
1153
+ onSubmit: handleSubmit
1154
+ })), db && settings && /* @__PURE__ */ React9.createElement("div", {
1155
+ role: "none",
1156
+ className: "flex items-center overflow-hidden"
1157
+ }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1158
+ db,
1159
+ blueprintRegistry: processor.blueprintRegistry,
1160
+ context: processor.context,
1161
+ preset,
1162
+ presets,
1163
+ onPresetChange
1164
+ }), /* @__PURE__ */ React9.createElement("div", {
1165
+ role: "none",
1166
+ className: "flex grow overflow-x-auto scrollbar-none"
1167
+ }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1168
+ db,
1169
+ context: processor.context
1170
+ })), /* @__PURE__ */ React9.createElement(ChatActions, {
1171
+ classNames: "col-span-2",
1172
+ microphone: true,
1173
+ recording,
1174
+ processing: streaming,
1175
+ onEvent: handleEvent
1176
+ }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
1177
+ srOnly: true
1178
+ }, t("online-switch.label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
1179
+ classNames: "mx-2",
1180
+ checked: online,
1181
+ onCheckedChange: onOnlineChange
1182
+ })))));
1183
+ };
1184
+ ChatPrompt.displayName = CHAT_PROMPT_NAME;
1185
+ var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
1186
+ var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
1187
+ const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
1188
+ const menuActions = useChatToolbarActions({
1189
+ chat,
1190
+ companionTo
1191
+ });
1192
+ return /* @__PURE__ */ React9.createElement(Menu.Root, {
1193
+ ...menuActions,
1194
+ attendableId
1195
+ }, /* @__PURE__ */ React9.createElement(Menu.Toolbar, {
1196
+ ...composableProps(props),
1197
+ ref: forwardedRef
1198
+ }));
1199
+ });
1200
+ ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
1201
+ var Chat = {
1202
+ Root: ChatRoot,
1203
+ Viewport: ChatViewport,
1204
+ Thread: ChatThread2,
1205
+ Prompt: ChatPrompt,
1206
+ Toolbar: ChatToolbar
1207
+ };
1208
+
1209
+ // src/components/ProcessTree/ProcessTree.tsx
1210
+ import * as Match from "effect/Match";
1211
+ import React10 from "react";
1212
+ import { Process } from "@dxos/functions-runtime";
1213
+ import { Icon as Icon2, ScrollArea, Treegrid } from "@dxos/react-ui";
1214
+ import { composable as composable2, composableProps as composableProps2, mx as mx7 } from "@dxos/ui-theme";
1215
+ var ProcessTree = composable2(({ processes, onProcessSelect, ...props }, forwardedRef) => {
1216
+ const filteredProcesses = [
1217
+ ...processes.filter((process) => [
1218
+ Process.State.RUNNING,
1219
+ Process.State.HYBERNATING
1220
+ ].includes(process.state)),
1221
+ ...processes.filter((process) => [
1222
+ Process.State.IDLE
1223
+ ].includes(process.state)).slice(0, 3),
1224
+ ...processes.filter((process) => [
1225
+ Process.State.SUCCEEDED,
1226
+ Process.State.FAILED,
1227
+ Process.State.TERMINATED
1228
+ ].includes(process.state)).slice(0, 3)
1229
+ ];
1230
+ return /* @__PURE__ */ React10.createElement(ScrollArea.Root, {
1231
+ ...composableProps2(props, {
1232
+ classNames: "dx-expander"
1233
+ }),
1234
+ thin: true,
1235
+ ref: forwardedRef
1236
+ }, /* @__PURE__ */ React10.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React10.createElement(Treegrid.Root, {
1237
+ gridTemplateColumns: "1fr"
1238
+ }, filteredProcesses.filter((process) => process.parentPid === null).map((process) => {
1239
+ const activeChildren = filteredProcesses.filter((candidate) => candidate.parentPid?.toString() === process.pid.toString() && candidate.state === Process.State.RUNNING);
1240
+ return /* @__PURE__ */ React10.createElement(Treegrid.Row, {
1241
+ key: process.pid.toString(),
1242
+ id: process.pid.toString(),
1243
+ parentOf: process.parentPid?.toString()
1244
+ }, /* @__PURE__ */ React10.createElement(Treegrid.Cell, {
1245
+ indent: true,
1246
+ classNames: "flex items-center p-1 gap-2 min-w-0",
1247
+ onClick: () => onProcessSelect?.(process)
1248
+ }, /* @__PURE__ */ React10.createElement(Icon2, {
1249
+ size: 4,
1250
+ icon: Match.value(process.state).pipe(Match.when(Process.State.RUNNING, () => "ph--spinner-gap--regular"), Match.when(Process.State.SUCCEEDED, () => "ph--check-circle--regular"), Match.when(Process.State.FAILED, () => "ph--warning--regular"), Match.when(Process.State.HYBERNATING, () => "ph--spinner--regular"), Match.when(Process.State.IDLE, () => "ph--hourglass--regular"), Match.when(Process.State.TERMINATING, () => "ph--x-circle--regular"), Match.when(Process.State.TERMINATED, () => "ph--x-circle--regular"), Match.orElse(() => "ph--spinner-gap--regular")),
1251
+ classNames: mx7(process.state === Process.State.RUNNING && "animate-spin", process.state === Process.State.FAILED && "text-error-text", process.state === Process.State.SUCCEEDED && "text-success-text")
1252
+ }), /* @__PURE__ */ React10.createElement("div", {
1253
+ role: "none",
1254
+ className: "flex items-center gap-2 text-xs overflow-hidden"
1255
+ }, /* @__PURE__ */ React10.createElement("span", {
1256
+ className: "text-description"
1257
+ }, process.params.name), activeChildren.length > 0 && /* @__PURE__ */ React10.createElement("span", {
1258
+ className: "text-xs text-description ml-1"
1259
+ }, activeChildren[0].params.name))));
1260
+ }))));
1261
+ });
1262
+
1263
+ // src/components/TemplateEditor/TemplateEditor.tsx
1264
+ import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1265
+ import { composeRefs } from "@radix-ui/react-compose-refs";
1266
+ import React11 from "react";
1267
+ import { createDocAccessor } from "@dxos/echo-db";
1268
+ import { useThemeContext, useTranslation as useTranslation6 } from "@dxos/react-ui";
1269
+ import { useTextEditor } from "@dxos/react-ui-editor";
1270
+ import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
1271
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
1272
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1273
+ import { meta as meta6 } from "#meta";
1274
+
1275
+ // src/components/TemplateEditor/extensions/handlebars-extension.ts
1276
+ import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
1277
+ import { RangeSetBuilder } from "@codemirror/state";
1278
+ import { Decoration, ViewPlugin, WidgetType, keymap as keymap2 } from "@codemirror/view";
1279
+ import { Domino, mx as mx8 } from "@dxos/ui";
1280
+ var handlebars = (_ = {}) => {
1281
+ return [
1282
+ handlebarsHighlightPlugin,
1283
+ autocompletion({
1284
+ activateOnTyping: true,
1285
+ aboveCursor: true,
1286
+ closeOnBlur: true,
1287
+ override: [
1288
+ handlebarsCompletions
1289
+ ]
1290
+ }),
1291
+ keymap2.of(completionKeymap)
1292
+ ];
1293
+ };
1294
+ var regex = {
1295
+ // {{! comment }}
1296
+ comment: /\{\{!\s*[^}]*\}\}/g,
1297
+ // {{var}}
1298
+ brackets: /\{\{[^}]*\}\}/g,
1299
+ // {{#command}} {{/command}}
1300
+ command: /\{\{[#/]([^}]+)\}\}/g,
1301
+ // {{var}}
1302
+ var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
1303
+ // @dxn:queue:data:xxx
1304
+ dxn: /@?dxn:[\w@:]+/g,
1305
+ // dxos.org/type/xxx
1306
+ url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
1307
+ };
1308
+ var tagPadding = "mx-0.5 px-1 rounded-xs";
1309
+ var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
1310
+ decorations;
1311
+ constructor(view) {
1312
+ this.decorations = this.buildDecorations(view);
1313
+ }
1314
+ update(update) {
1315
+ if (update.docChanged || update.viewportChanged || update.selectionSet) {
1316
+ this.decorations = this.buildDecorations(update.view);
1317
+ }
1318
+ }
1319
+ // NOTE: Decorations may clash with other extensions (e.g., markdown).
1320
+ buildDecorations(view) {
1321
+ const selection = view.state.selection.main;
1322
+ const decorations = [];
1323
+ for (const { from, to } of view.visibleRanges) {
1324
+ const text = view.state.doc.sliceString(from, to);
1325
+ {
1326
+ let match;
1327
+ while ((match = regex.dxn.exec(text)) !== null) {
1328
+ const start = from + match.index;
1329
+ const end = start + match[0].length;
1330
+ const overlaps = selection.to > start && selection.from <= end;
1331
+ if (!overlaps) {
1332
+ decorations.push({
1333
+ from: start,
1334
+ to: end,
1335
+ decoration: Decoration.widget({
1336
+ widget: new DXNWidget(match[0])
1337
+ })
1338
+ });
1339
+ }
1340
+ }
1341
+ }
1342
+ {
1343
+ let match;
1344
+ while ((match = regex.url.exec(text)) !== null) {
1345
+ const start = from + match.index;
1346
+ const end = start + match[0].length;
1347
+ decorations.push({
1348
+ from: start,
1349
+ to: end,
1350
+ decoration: Decoration.mark({
1351
+ class: mx8("dx-tag--blue", tagPadding)
1352
+ })
1353
+ });
1354
+ }
1355
+ }
1356
+ {
1357
+ let match;
1358
+ while ((match = regex.brackets.exec(text)) !== null) {
1359
+ const start = from + match.index;
1360
+ const end = start + match[0].length;
1361
+ decorations.push({
1362
+ from: start,
1363
+ to: end,
1364
+ decoration: Decoration.mark({
1365
+ class: "text-subdued"
1366
+ })
1367
+ });
1368
+ }
1369
+ }
1370
+ {
1371
+ let match;
1372
+ while ((match = regex.command.exec(text)) !== null) {
1373
+ const start = from + match.index + 2;
1374
+ let end = start + match[0].length - 4;
1375
+ const text2 = view.state.doc.sliceString(start, end);
1376
+ const parts = text2.split(/\s+/);
1377
+ if (parts.length > 1) {
1378
+ const idx = start + parts[0].length;
1379
+ decorations.push({
1380
+ from: idx,
1381
+ to: end,
1382
+ decoration: Decoration.mark({
1383
+ class: "text-green-text"
1384
+ })
1385
+ });
1386
+ end = idx;
1387
+ }
1388
+ decorations.push({
1389
+ from: start,
1390
+ to: end,
1391
+ decoration: Decoration.mark({
1392
+ class: "text-blue-text"
1393
+ })
1394
+ });
1395
+ }
1396
+ }
1397
+ {
1398
+ let match;
1399
+ while ((match = regex.var.exec(text)) !== null) {
1400
+ const start = from + match.index + 2;
1401
+ const end = start + match[0].length - 4;
1402
+ decorations.push({
1403
+ from: start,
1404
+ to: end,
1405
+ decoration: Decoration.mark({
1406
+ class: "text-green-text"
1407
+ })
1408
+ });
1409
+ }
1410
+ }
1411
+ }
1412
+ decorations.sort((a, b) => a.from - b.from || a.to - b.to);
1413
+ const builder = new RangeSetBuilder();
1414
+ for (const { from, to, decoration } of decorations) {
1415
+ builder.add(from, to, decoration);
1416
+ }
1417
+ return builder.finish();
1418
+ }
1419
+ }, {
1420
+ decorations: (v) => v.decorations
1421
+ });
1422
+ var DXNWidget = class extends WidgetType {
1423
+ _identifier;
1424
+ constructor(_identifier) {
1425
+ super(), this._identifier = _identifier;
1426
+ }
1427
+ ignoreEvent() {
1428
+ return false;
1429
+ }
1430
+ eq(other) {
1431
+ return this._identifier === other._identifier;
1432
+ }
1433
+ toDOM() {
1434
+ const text = this._identifier.split(":").map((part) => {
1435
+ const len = 16;
1436
+ const plen = 4;
1437
+ if (part.length > len) {
1438
+ return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
1439
+ }
1440
+ return part;
1441
+ }).join(":");
1442
+ return Domino.of("span").classNames(mx8("font-mono dx-tag--blue", tagPadding)).text(text).root;
1443
+ }
1444
+ };
1445
+ var variables = [
1446
+ "this"
1447
+ ];
1448
+ var commands = [
1449
+ "this",
1450
+ "each",
1451
+ "if",
1452
+ "unless",
1453
+ "with"
1454
+ ];
1455
+ function handlebarsCompletions(context) {
1456
+ const match = context.matchBefore(/\{\{[^}]*/);
1457
+ if (!match || match.from === match.to) {
1458
+ return null;
1459
+ }
1460
+ let type = "variable";
1461
+ let text = match.text.slice(2);
1462
+ let from = match.from + 2;
1463
+ let matches = [];
1464
+ if (text.startsWith("#") || text.startsWith("/")) {
1465
+ const idx = text.lastIndexOf(" ");
1466
+ if (idx !== -1) {
1467
+ type = "variable";
1468
+ matches = variables;
1469
+ text = text.slice(idx + 1);
1470
+ from += idx + 1;
1471
+ } else {
1472
+ type = "command";
1473
+ text = text.slice(1);
1474
+ matches = commands;
1475
+ from += 1;
1476
+ }
1477
+ } else {
1478
+ type = "variable";
1479
+ matches = variables;
1480
+ }
1481
+ const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
1482
+ type,
1483
+ label: name
1484
+ }));
1485
+ return {
1486
+ from,
1487
+ options
1488
+ };
1489
+ }
1490
+
1491
+ // src/components/TemplateEditor/extensions/xml-extension.ts
1492
+ import { syntaxTree } from "@codemirror/language";
1493
+ import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
1494
+ import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
1495
+ var xmlDecorator = (_ = {}) => {
1496
+ return [
1497
+ xmlDecoratorPlugin
1498
+ ];
1499
+ };
1500
+ var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
1501
+ decorations;
1502
+ constructor(view) {
1503
+ this.decorations = this.buildDecorations(view);
1504
+ }
1505
+ update(update) {
1506
+ if (update.docChanged || update.viewportChanged) {
1507
+ this.decorations = this.buildDecorations(update.view);
1508
+ }
1509
+ }
1510
+ buildDecorations(view) {
1511
+ const builder = new RangeSetBuilder2();
1512
+ for (const { from, to } of view.visibleRanges) {
1513
+ syntaxTree(view.state).iterate({
1514
+ from,
1515
+ to,
1516
+ enter: (node) => {
1517
+ if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
1518
+ builder.add(node.from, node.to, Decoration2.mark({
1519
+ class: "font-mono text-subdued"
1520
+ }));
1521
+ }
1522
+ }
1523
+ });
1524
+ }
1525
+ return builder.finish();
1526
+ }
1527
+ }, {
1528
+ decorations: (v) => v.decorations
1529
+ });
56
1530
 
57
- // src/capabilities/app-graph-builder/index.ts
58
- import { Capability as Capability2 } from "@dxos/app-framework";
59
- var AppGraphBuilder = Capability2.lazy("AppGraphBuilder", () => import("./app-graph-builder-TJCUEXW5.mjs"));
1531
+ // src/components/TemplateEditor/TemplateEditor.tsx
1532
+ var TemplateEditor = composable3(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
1533
+ const { t } = useTranslation6(meta6.id);
1534
+ const { themeMode } = useThemeContext();
1535
+ const { parentRef } = useTextEditor(() => {
1536
+ const text = template.source?.target;
1537
+ if (!text) {
1538
+ return {};
1539
+ }
1540
+ return {
1541
+ initialValue: text.content ?? "",
1542
+ extensions: [
1543
+ createDataExtensions({
1544
+ id,
1545
+ text: createDocAccessor(text, [
1546
+ "content"
1547
+ ])
1548
+ }),
1549
+ createBasicExtensions({
1550
+ bracketMatching: false,
1551
+ lineNumbers,
1552
+ lineWrapping: true,
1553
+ placeholder: t("template.placeholder")
1554
+ }),
1555
+ createThemeExtensions({
1556
+ themeMode
1557
+ }),
1558
+ createMarkdownExtensions(),
1559
+ decorateMarkdown(),
1560
+ handlebars(),
1561
+ // xml(),
1562
+ // NOTE: Since we're using markdown only HTML nodes are parsed.
1563
+ xmlDecorator(),
1564
+ syntaxHighlighting(defaultHighlightStyle)
1565
+ ].filter(isNonNullable2)
1566
+ };
1567
+ }, [
1568
+ themeMode,
1569
+ template.source?.target,
1570
+ lineNumbers
1571
+ ]);
1572
+ return /* @__PURE__ */ React11.createElement("div", {
1573
+ ...composableProps3(props, {
1574
+ role: "none",
1575
+ classNames: [
1576
+ "h-full overflow-hidden",
1577
+ classNames
1578
+ ]
1579
+ }),
1580
+ ref: composeRefs(parentRef, forwardedRef)
1581
+ });
1582
+ });
60
1583
 
61
- // src/capabilities/blueprint-definition/index.ts
62
- import { Capability as Capability3 } from "@dxos/app-framework";
63
- var BlueprintDefinition = Capability3.lazy("BlueprintDefinition", () => import("./blueprint-definition-SEMDEIYG.mjs"));
1584
+ // src/components/Toolbox/Toolbox.tsx
1585
+ import React12, { Fragment, useEffect as useEffect5, useState as useState6 } from "react";
1586
+ import { Operation } from "@dxos/operation";
1587
+ import { log as log3 } from "@dxos/log";
1588
+ import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
1589
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1590
+ import { composable as composable4, composableProps as composableProps4, mx as mx9 } from "@dxos/ui-theme";
1591
+ import { ServiceType as ServiceType2 } from "#types";
1592
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1593
+ var Toolbox = composable4(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
1594
+ return /* @__PURE__ */ React12.createElement(ScrollArea2.Root, {
1595
+ ...composableProps4(props),
1596
+ thin: true,
1597
+ orientation: "vertical",
1598
+ ref: forwardedRef
1599
+ }, /* @__PURE__ */ React12.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React12.createElement(Section, {
1600
+ title: "Blueprints",
1601
+ items: blueprints.map(({ name, description, tools }) => ({
1602
+ name,
1603
+ description,
1604
+ subitems: tools.map((toolId) => ({
1605
+ name: `\u2219 ${safeToolId(toolId)}`
1606
+ }))
1607
+ }))
1608
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React12.createElement(Section, {
1609
+ title: "Blueprints",
1610
+ items: activeBlueprints.map(({ target }) => ({
1611
+ name: target?.name ?? "",
1612
+ description: target?.description ?? "",
1613
+ subitems: target?.tools.map((toolId) => ({
1614
+ name: `\u2219 ${safeToolId(toolId)}`
1615
+ }))
1616
+ }))
1617
+ }), services && services.length > 0 && /* @__PURE__ */ React12.createElement(Section, {
1618
+ title: "Services",
1619
+ items: services.map(({ service: { serviceId, name, description } }) => ({
1620
+ name: name ?? serviceId,
1621
+ description
1622
+ }))
1623
+ }), functions && functions.length > 0 && /* @__PURE__ */ React12.createElement(Section, {
1624
+ title: "Functions",
1625
+ items: functions.map(({ name, description }) => ({
1626
+ name,
1627
+ description
1628
+ }))
1629
+ })));
1630
+ });
1631
+ Toolbox.displayName = "Toolbox";
1632
+ var Section = ({ title, items, striped }) => {
1633
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1634
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
1635
+ const subGridClassNames = mx9("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
1636
+ return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("h1", {
1637
+ className: "px-2 text-sm"
1638
+ }, title), /* @__PURE__ */ React12.createElement("div", {
1639
+ className: gridClassNames
1640
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React12.createElement(Fragment, {
1641
+ key: i
1642
+ }, name && /* @__PURE__ */ React12.createElement("div", {
1643
+ className: subGridClassNames
1644
+ }, /* @__PURE__ */ React12.createElement("div", {
1645
+ className: "truncate text-primary-500"
1646
+ }, name), /* @__PURE__ */ React12.createElement("div", {
1647
+ className: "line-clamp-2"
1648
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React12.createElement("div", {
1649
+ key: i2,
1650
+ className: mx9(subGridClassNames, striped && stripeClassNames)
1651
+ }, /* @__PURE__ */ React12.createElement("div", {
1652
+ className: "truncate"
1653
+ }, name2), /* @__PURE__ */ React12.createElement("div", {
1654
+ className: "line-clamp-3 text-subdued"
1655
+ }, description2)))))));
1656
+ };
1657
+ var ToolboxPanel = ({ classNames, db, processor }) => {
1658
+ const services = useQuery3(db, Filter3.type(ServiceType2));
1659
+ const [serviceTools, setServiceTools] = useState6([]);
1660
+ useEffect5(() => {
1661
+ log3("creating service tools...", {
1662
+ services: services.length
1663
+ }, {
1664
+ F: __dxlog_file3,
1665
+ L: 121,
1666
+ S: void 0,
1667
+ C: (f, a) => f(...a)
1668
+ });
1669
+ queueMicrotask(async () => {
1670
+ });
1671
+ }, [
1672
+ services
1673
+ ]);
1674
+ const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
1675
+ return /* @__PURE__ */ React12.createElement(Toolbox, {
1676
+ classNames,
1677
+ blueprints: processor?.context.getBlueprints(),
1678
+ services: serviceTools,
1679
+ functions
1680
+ });
1681
+ };
1682
+ var safeToolId = (name) => {
1683
+ return name.split("_").pop();
1684
+ };
64
1685
 
65
- // src/capabilities/edge-model-resolver/index.ts
66
- import { Capability as Capability4 } from "@dxos/app-framework";
67
- var EdgeModelResolver = Capability4.lazy("EdgeModelResolver", () => import("./edge-model-resolver-G5KMODPO.mjs"));
1686
+ // src/components/index.ts
1687
+ var AssistantSettings = lazy(() => import("./AssistantSettings-Z5ZZWWSN.mjs"));
68
1688
 
69
- // src/capabilities/local-model-resolver/index.ts
70
- import { Capability as Capability5 } from "@dxos/app-framework";
71
- var LocalModelResolver = Capability5.lazy("LocalModelResolver", () => import("./local-model-resolver-KDZLYI7Y.mjs"));
1689
+ // src/hooks/useBlueprintRegistry.ts
1690
+ import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo5, useState as useState7 } from "react";
1691
+ import { useCapabilities } from "@dxos/app-framework/ui";
1692
+ import { AppCapabilities } from "@dxos/app-toolkit";
1693
+ import { Blueprint } from "@dxos/blueprints";
1694
+ import { Filter as Filter4, Obj as Obj4, Ref } from "@dxos/echo";
1695
+ import { useQuery as useQuery4 } from "@dxos/react-client/echo";
1696
+ import { distinctBy } from "@dxos/util";
1697
+ var useBlueprintRegistry = () => {
1698
+ const blueprintDefinitions = useCapabilities(AppCapabilities.BlueprintDefinition);
1699
+ return useMemo5(() => new Blueprint.Registry(blueprintDefinitions.map((blueprint) => blueprint.make())), [
1700
+ blueprintDefinitions
1701
+ ]);
1702
+ };
1703
+ var useBlueprints2 = ({ blueprintRegistry, db }) => {
1704
+ const staticBlueprints = useMemo5(() => blueprintRegistry?.query() ?? [], [
1705
+ blueprintRegistry
1706
+ ]);
1707
+ const spaceBlueprints = useQuery4(db, Filter4.type(Blueprint.Blueprint));
1708
+ return useMemo5(() => {
1709
+ const blueprints = distinctBy([
1710
+ ...staticBlueprints,
1711
+ ...spaceBlueprints
1712
+ ], (b) => b.key);
1713
+ blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
1714
+ return blueprints;
1715
+ }, [
1716
+ staticBlueprints,
1717
+ spaceBlueprints
1718
+ ]);
1719
+ };
1720
+ var useActiveBlueprints2 = ({ context }) => {
1721
+ const [active, setActive] = useState7(/* @__PURE__ */ new Map());
1722
+ useEffect6(() => {
1723
+ if (!context) {
1724
+ setActive(/* @__PURE__ */ new Map());
1725
+ return;
1726
+ }
1727
+ const updateActive = () => {
1728
+ const blueprints = context.getBlueprints();
1729
+ setActive(new Map(blueprints.map((blueprint) => [
1730
+ blueprint.key,
1731
+ blueprint
1732
+ ])));
1733
+ };
1734
+ updateActive();
1735
+ return context.subscribeBlueprints(updateActive);
1736
+ }, [
1737
+ context
1738
+ ]);
1739
+ return active;
1740
+ };
1741
+ var useBlueprintHandlers2 = ({ db, context, blueprintRegistry }) => {
1742
+ const onUpdateBlueprint = useCallback4(async (key, checked) => {
1743
+ if (!context || !blueprintRegistry) {
1744
+ return;
1745
+ }
1746
+ const objects = await db.query(Filter4.type(Blueprint.Blueprint)).run();
1747
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
1748
+ if (checked) {
1749
+ if (!storedBlueprint) {
1750
+ const blueprint = blueprintRegistry.getByKey(key);
1751
+ if (!blueprint) {
1752
+ return;
1753
+ }
1754
+ storedBlueprint = db.add(Obj4.clone(blueprint));
1755
+ }
1756
+ await context.bind({
1757
+ blueprints: [
1758
+ Ref.make(storedBlueprint)
1759
+ ]
1760
+ });
1761
+ } else if (storedBlueprint) {
1762
+ await context.unbind({
1763
+ blueprints: [
1764
+ Ref.make(storedBlueprint)
1765
+ ]
1766
+ });
1767
+ }
1768
+ }, [
1769
+ db,
1770
+ context,
1771
+ blueprintRegistry
1772
+ ]);
1773
+ return {
1774
+ onUpdateBlueprint
1775
+ };
1776
+ };
72
1777
 
73
- // src/capabilities/operation-resolver/index.ts
74
- import { Capability as Capability6 } from "@dxos/app-framework";
75
- var OperationResolver = Capability6.lazy("OperationResolver", () => import("./operation-resolver-SX4WMNA7.mjs"));
1778
+ // src/hooks/useChatProcessor.ts
1779
+ import { RegistryContext } from "@effect-atom/atom-react";
1780
+ import { useContext, useMemo as useMemo6, useState as useState8 } from "react";
1781
+ import { Feed, Ref as Ref2 } from "@dxos/echo";
1782
+ import { AiConversation } from "@dxos/assistant";
1783
+ import { log as log4 } from "@dxos/log";
1784
+ import { useAsyncEffect } from "@dxos/react-ui";
1785
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
1786
+ var useChatProcessor = ({ space, chat, preset, runtime, blueprintRegistry, settings }) => {
1787
+ const observableRegistry = useContext(RegistryContext);
1788
+ const [conversation, setConversation] = useState8();
1789
+ useAsyncEffect(async () => {
1790
+ if (!space || !chat) {
1791
+ return;
1792
+ }
1793
+ const feedTarget = chat.feed.target;
1794
+ const queueDxn = feedTarget ? Feed.getQueueDxn(feedTarget) : void 0;
1795
+ if (!queueDxn) {
1796
+ return;
1797
+ }
1798
+ const queue = space.queues.get(queueDxn);
1799
+ const conversation2 = new AiConversation({
1800
+ queue,
1801
+ registry: observableRegistry
1802
+ });
1803
+ await conversation2.open();
1804
+ setConversation(conversation2);
1805
+ return () => {
1806
+ void conversation2.close();
1807
+ setConversation(void 0);
1808
+ };
1809
+ }, [
1810
+ space,
1811
+ chat?.feed.target
1812
+ ]);
1813
+ const feed = chat?.feed.target;
1814
+ const processor = useMemo6(() => {
1815
+ if (!runtime || !conversation || !chat || !feed) {
1816
+ return void 0;
1817
+ }
1818
+ log4("creating processor", {
1819
+ preset,
1820
+ model: preset?.model,
1821
+ settings
1822
+ }, {
1823
+ F: __dxlog_file4,
1824
+ L: 73,
1825
+ S: void 0,
1826
+ C: (f, a) => f(...a)
1827
+ });
1828
+ return new AiChatProcessor(conversation, runtime, feed, {
1829
+ chat: chat ? Ref2.make(chat) : void 0,
1830
+ observableRegistry,
1831
+ blueprintRegistry,
1832
+ model: preset?.model
1833
+ });
1834
+ }, [
1835
+ runtime,
1836
+ conversation,
1837
+ blueprintRegistry,
1838
+ preset,
1839
+ feed
1840
+ ]);
1841
+ return processor;
1842
+ };
76
1843
 
77
- // src/capabilities/react-surface/index.ts
78
- import { Capability as Capability7 } from "@dxos/app-framework";
79
- var ReactSurface = Capability7.lazy("ReactSurface", () => import("./react-surface-ST6V7LPE.mjs"));
1844
+ // src/hooks/useChatServices.ts
1845
+ import { useMemo as useMemo7 } from "react";
1846
+ import { useCapability } from "@dxos/app-framework/ui";
1847
+ import { AutomationCapabilities } from "@dxos/plugin-automation/types";
1848
+ import { getPersonalSpace } from "@dxos/app-toolkit";
1849
+ import { useClient } from "@dxos/react-client";
1850
+ var useChatServices = ({ id }) => {
1851
+ const client = useClient();
1852
+ id ??= getPersonalSpace(client)?.id;
1853
+ const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
1854
+ return useMemo7(() => !id ? void 0 : runtimeResolver.getRuntime(id), [
1855
+ id
1856
+ ]);
1857
+ };
80
1858
 
81
- // src/capabilities/repair/index.ts
82
- import { Capability as Capability8 } from "@dxos/app-framework";
83
- var Repair = Capability8.lazy("Repair", () => import("./repair-QJ7CQDKU.mjs"));
1859
+ // src/hooks/useChatToolbarActions.ts
1860
+ import { Atom } from "@effect-atom/atom-react";
1861
+ import * as Effect from "effect/Effect";
1862
+ import { useMemo as useMemo8 } from "react";
1863
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
1864
+ import { Chat as Chat2 } from "@dxos/assistant-toolkit";
1865
+ import { Filter as Filter5, Obj as Obj5, Query } from "@dxos/echo";
1866
+ import { runAndForwardErrors } from "@dxos/effect";
1867
+ import { invariant } from "@dxos/invariant";
1868
+ import { useQuery as useQuery5 } from "@dxos/react-client/echo";
1869
+ import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
1870
+ import { useChatContext as useChatContext2 } from "#components";
1871
+ import { meta as meta7 } from "#meta";
1872
+ import { AssistantOperation } from "#operations";
1873
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
1874
+ var useChatToolbarActions2 = ({ chat, companionTo }) => {
1875
+ const { invoke } = useOperationInvoker();
1876
+ const { db } = useChatContext2("useChatToolbarActions");
1877
+ const query = companionTo ? Query.select(Filter5.id(companionTo.id)).targetOf(Chat2.CompanionTo).source() : Query.select(Filter5.nothing());
1878
+ const chats = useQuery5(db, query);
1879
+ return useMenuActions(useMemo8(() => {
1880
+ return Atom.make(() => {
1881
+ const builder = MenuBuilder.make().root({
1882
+ label: [
1883
+ "chat-toolbar.title",
1884
+ {
1885
+ ns: meta7.id
1886
+ }
1887
+ ]
1888
+ }).action("new", {
1889
+ label: [
1890
+ "new-thread.button",
1891
+ {
1892
+ ns: meta7.id
1893
+ }
1894
+ ],
1895
+ icon: "ph--plus--regular",
1896
+ type: "new",
1897
+ disabled: !companionTo
1898
+ }, () => {
1899
+ invariant(companionTo, void 0, {
1900
+ F: __dxlog_file5,
1901
+ L: 53,
1902
+ S: void 0,
1903
+ A: [
1904
+ "companionTo",
1905
+ ""
1906
+ ]
1907
+ });
1908
+ return invoke(AssistantOperation.SetCurrentChat, {
1909
+ companionTo,
1910
+ chat: void 0
1911
+ }).pipe(runAndForwardErrors);
1912
+ }).action("rename", {
1913
+ label: [
1914
+ "rename-thread.button",
1915
+ {
1916
+ ns: meta7.id
1917
+ }
1918
+ ],
1919
+ icon: "ph--magic-wand--regular",
1920
+ type: "rename",
1921
+ disabled: !chat
1922
+ }, () => Effect.gen(function* () {
1923
+ invariant(chat, void 0, {
1924
+ F: __dxlog_file5,
1925
+ L: 70,
1926
+ S: this,
1927
+ A: [
1928
+ "chat",
1929
+ ""
1930
+ ]
1931
+ });
1932
+ yield* invoke(AssistantOperation.UpdateChatName, {
1933
+ chat
1934
+ });
1935
+ }).pipe(runAndForwardErrors)).action("branch", {
1936
+ label: [
1937
+ "branch-thread.menu",
1938
+ {
1939
+ ns: meta7.id
1940
+ }
1941
+ ],
1942
+ icon: "ph--git-branch--regular",
1943
+ type: "branch",
1944
+ disabled: true
1945
+ }, () => {
1946
+ });
1947
+ if (chats.length > 0) {
1948
+ builder.group("chats", {
1949
+ label: [
1950
+ "chat-history.label",
1951
+ {
1952
+ ns: meta7.id
1953
+ }
1954
+ ],
1955
+ icon: "ph--clock-counter-clockwise--regular",
1956
+ selectCardinality: "single",
1957
+ variant: "dropdownMenu"
1958
+ }, (builder2) => {
1959
+ chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
1960
+ builder2.action(chat2.id, {
1961
+ label: Obj5.getLabel(chat2) ?? [
1962
+ "object-name.placeholder",
1963
+ {
1964
+ ns: Chat2.Chat.typename
1965
+ }
1966
+ ]
1967
+ }, () => Effect.gen(function* () {
1968
+ invariant(companionTo, void 0, {
1969
+ F: __dxlog_file5,
1970
+ L: 106,
1971
+ S: this,
1972
+ A: [
1973
+ "companionTo",
1974
+ ""
1975
+ ]
1976
+ });
1977
+ yield* invoke(AssistantOperation.SetCurrentChat, {
1978
+ companionTo,
1979
+ chat: chat2
1980
+ });
1981
+ }).pipe(runAndForwardErrors));
1982
+ });
1983
+ });
1984
+ }
1985
+ return builder.build();
1986
+ });
1987
+ }, [
1988
+ chats.length,
1989
+ db?.spaceId,
1990
+ companionTo?.id,
1991
+ chat?.id,
1992
+ invoke
1993
+ ]));
1994
+ };
84
1995
 
85
- // src/capabilities/settings/index.ts
86
- import { Capability as Capability9 } from "@dxos/app-framework";
87
- var Settings = Capability9.lazy("Settings", () => import("./settings-CQEOHR3R.mjs"));
1996
+ // src/hooks/useContextBinder.ts
1997
+ import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1998
+ import { useContext as useContext2, useState as useState9 } from "react";
1999
+ import { AiContextBinder } from "@dxos/assistant";
2000
+ import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
2001
+ var useContextBinder = (queue) => {
2002
+ const registry = useContext2(RegistryContext2);
2003
+ const [binder, setBinder] = useState9();
2004
+ useAsyncEffect2(async () => {
2005
+ if (!queue) {
2006
+ return;
2007
+ }
2008
+ const binder2 = new AiContextBinder({
2009
+ queue,
2010
+ registry
2011
+ });
2012
+ await binder2.open();
2013
+ setBinder(binder2);
2014
+ return () => {
2015
+ void binder2.close();
2016
+ };
2017
+ }, [
2018
+ queue
2019
+ ]);
2020
+ return binder;
2021
+ };
88
2022
 
89
- // src/capabilities/state/index.ts
90
- import { Capability as Capability10 } from "@dxos/app-framework";
91
- var AssistantState = Capability10.lazy("AssistantState", () => import("./state-HDON4REW.mjs"));
2023
+ // src/hooks/useContextObjects.ts
2024
+ import { Atom as Atom2, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
2025
+ import { useCallback as useCallback5 } from "react";
2026
+ var emptyObjectsAtom = Atom2.make([]);
2027
+ var useContextObjects3 = ({ db, context }) => {
2028
+ const objects = useAtomValue2(context?.objects ?? emptyObjectsAtom);
2029
+ const handleUpdateObject = useCallback5(async (dxn, checked) => {
2030
+ if (!db || !context) {
2031
+ return;
2032
+ }
2033
+ const ref = db.makeRef(dxn);
2034
+ await ref.load();
2035
+ if (checked) {
2036
+ await context.bind({
2037
+ objects: [
2038
+ ref
2039
+ ]
2040
+ });
2041
+ } else {
2042
+ await context.unbind({
2043
+ objects: [
2044
+ ref
2045
+ ]
2046
+ });
2047
+ }
2048
+ }, [
2049
+ db,
2050
+ context
2051
+ ]);
2052
+ return {
2053
+ objects,
2054
+ onUpdateObject: handleUpdateObject
2055
+ };
2056
+ };
92
2057
 
93
- // src/capabilities/toolkit/index.ts
94
- import { Capability as Capability11 } from "@dxos/app-framework";
95
- var Toolkit = Capability11.lazy("Toolkit", () => import("./toolkit-OWGCEKOO.mjs"));
2058
+ // src/hooks/useFilteredTypes.ts
2059
+ import * as Option4 from "effect/Option";
2060
+ import { useEffect as useEffect7, useState as useState10 } from "react";
2061
+ import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
2062
+ var useFilteredTypes2 = (db) => {
2063
+ const [types, setTypes] = useState10([]);
2064
+ useEffect7(() => {
2065
+ if (!db) {
2066
+ return;
2067
+ }
2068
+ return db.schemaRegistry.query({
2069
+ location: [
2070
+ "database",
2071
+ "runtime"
2072
+ ]
2073
+ }).subscribe((query) => {
2074
+ const types2 = Array.from(new Set(query.results.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option4.getOrElse(() => false)))));
2075
+ setTypes(types2);
2076
+ }, {
2077
+ fire: true
2078
+ });
2079
+ }, [
2080
+ db
2081
+ ]);
2082
+ return types;
2083
+ };
2084
+
2085
+ // src/hooks/useFlush.ts
2086
+ import { useCallback as useCallback6, useRef as useRef3, useState as useState11 } from "react";
2087
+ var useFlush = (space) => {
2088
+ const [state, setState] = useState11("idle");
2089
+ const resetTimer = useRef3(null);
2090
+ const handleFlush = useCallback6(() => {
2091
+ if (!space) {
2092
+ return;
2093
+ }
2094
+ queueMicrotask(async () => {
2095
+ if (resetTimer.current) {
2096
+ clearTimeout(resetTimer.current);
2097
+ }
2098
+ setState("flushing");
2099
+ await space.db.flush();
2100
+ setState("flushed");
2101
+ resetTimer.current = setTimeout(() => {
2102
+ setState("idle");
2103
+ resetTimer.current = null;
2104
+ }, 1e3);
2105
+ });
2106
+ }, [
2107
+ space
2108
+ ]);
2109
+ return {
2110
+ state,
2111
+ handleFlush
2112
+ };
2113
+ };
2114
+
2115
+ // src/hooks/useOnline.ts
2116
+ import { useState as useState12 } from "react";
2117
+ var useOnline = () => {
2118
+ const [online, setOnline] = useState12(true);
2119
+ return [
2120
+ online,
2121
+ setOnline
2122
+ ];
2123
+ };
2124
+
2125
+ // src/hooks/usePresets.ts
2126
+ import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo9, useState as useState13 } from "react";
2127
+ var usePresets = (online) => {
2128
+ const [preset, setPreset] = useState13();
2129
+ const presets = useMemo9(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
2130
+ online
2131
+ ]);
2132
+ const presetOptions = useMemo9(() => presets.map(({ id, model, label }) => ({
2133
+ id,
2134
+ label: label ?? model
2135
+ })), [
2136
+ presets
2137
+ ]);
2138
+ useEffect8(() => {
2139
+ setPreset(presets[0]);
2140
+ }, [
2141
+ presets
2142
+ ]);
2143
+ const handlePresetChange = useCallback7((id) => {
2144
+ const preset2 = presets.find((preset3) => preset3.id === id);
2145
+ if (preset2) {
2146
+ setPreset(preset2);
2147
+ }
2148
+ }, [
2149
+ presets
2150
+ ]);
2151
+ return {
2152
+ preset,
2153
+ presets: presetOptions,
2154
+ onPresetChange: handlePresetChange
2155
+ };
2156
+ };
2157
+
2158
+ // src/hooks/useReferencesProvider.ts
2159
+ import { useMemo as useMemo10 } from "react";
2160
+ import { Filter as Filter6, Obj as Obj6 } from "@dxos/echo";
2161
+ var useReferencesProvider = (space) => {
2162
+ return useMemo10(() => {
2163
+ if (!space) {
2164
+ return void 0;
2165
+ }
2166
+ return {
2167
+ getReferences: async ({ query }) => {
2168
+ const objects = await space.db.query(Filter6.everything()).run();
2169
+ return objects.filter((object) => stringMatch(query, Obj6.getLabel(object) ?? "")).filter((object) => !!Obj6.getDXN(object)).map((object) => ({
2170
+ uri: Obj6.getDXN(object).toString(),
2171
+ label: Obj6.getLabel(object) ?? ""
2172
+ }));
2173
+ },
2174
+ resolveReference: async ({ uri }) => {
2175
+ const object = await space.db.query(Filter6.id(uri)).first();
2176
+ return {
2177
+ uri,
2178
+ label: Obj6.getLabel(object) ?? ""
2179
+ };
2180
+ }
2181
+ };
2182
+ }, [
2183
+ space
2184
+ ]);
2185
+ };
2186
+ var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
2187
+
2188
+ // src/meta.ts
2189
+ import { trim } from "@dxos/util";
2190
+ var meta8 = {
2191
+ id: "org.dxos.plugin.assistant",
2192
+ name: "Assistant",
2193
+ description: trim`
2194
+ Intelligent AI assistant that can analyze and interact with objects across your spaces.
2195
+ Chat naturally to get insights, search content, and perform actions using AI-powered context awareness.
2196
+ `,
2197
+ icon: "ph--atom--regular",
2198
+ iconHue: "sky",
2199
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-assistant",
2200
+ tags: [
2201
+ "labs"
2202
+ ]
2203
+ };
2204
+ var ASSISTANT_DIALOG = `${meta8.id}.assistant.dialog`;
2205
+ var ASSISTANT_COMPANION_VARIANT = "assistant-chat";
96
2206
 
97
2207
  // src/translations.ts
98
- import { Blueprint, Prompt } from "@dxos/blueprints";
2208
+ import { Chat as Chat3, Project } from "@dxos/assistant-toolkit";
2209
+ import { Blueprint as Blueprint2, Prompt } from "@dxos/blueprints";
99
2210
  import { Sequence } from "@dxos/conductor";
100
- import { Type } from "@dxos/echo";
2211
+ import { Type as Type2 } from "@dxos/echo";
2212
+ import { meta as meta9 } from "#meta";
101
2213
  var translations = [
102
2214
  {
103
2215
  "en-US": {
104
2216
  // TODO(burdon): From assistant.
105
- [Blueprint.Blueprint.typename]: {
106
- "typename label": "Blueprint",
107
- "typename label_zero": "Blueprints",
108
- "typename label_one": "Blueprint",
109
- "typename label_other": "Blueprints",
110
- "object name placeholder": "New blueprint",
111
- "rename object label": "Rename blueprint",
112
- "delete object label": "Delete blueprint",
113
- "object deleted label": "Blueprint deleted"
2217
+ [Blueprint2.Blueprint.typename]: {
2218
+ "typename.label": "Blueprint",
2219
+ "typename.label_zero": "Blueprints",
2220
+ "typename.label_one": "Blueprint",
2221
+ "typename.label_other": "Blueprints",
2222
+ "object-name.placeholder": "New blueprint",
2223
+ "add-object.label": "Add blueprint",
2224
+ "rename-object.label": "Rename blueprint",
2225
+ "delete-object.label": "Delete blueprint",
2226
+ "object-deleted.label": "Blueprint deleted"
114
2227
  },
115
- [Type.getTypename(Prompt.Prompt)]: {
116
- "typename label": "Prompt",
117
- "typename label_zero": "Prompts",
118
- "typename label_one": "Prompt",
119
- "typename label_other": "Prompts",
120
- "object name placeholder": "New prompt",
121
- "rename object label": "Rename prompt",
122
- "delete object label": "Delete prompt",
123
- "object deleted label": "Prompt deleted"
2228
+ [Type2.getTypename(Prompt.Prompt)]: {
2229
+ "typename.label": "Prompt",
2230
+ "typename.label_zero": "Prompts",
2231
+ "typename.label_one": "Prompt",
2232
+ "typename.label_other": "Prompts",
2233
+ "object-name.placeholder": "New prompt",
2234
+ "add-object.label": "Add prompt",
2235
+ "rename-object.label": "Rename prompt",
2236
+ "delete-object.label": "Delete prompt",
2237
+ "object-deleted.label": "Prompt deleted"
124
2238
  },
125
2239
  // TODO(burdon): From conductor.
126
2240
  [Sequence.typename]: {
127
- "typename label": "Sequence",
128
- "typename label_zero": "Sequences",
129
- "typename label_one": "Sequence",
130
- "typename label_other": "Sequences",
131
- "object name placeholder": "New sequence",
132
- "rename object label": "Rename sequence",
133
- "delete object label": "Delete sequence",
134
- "object deleted label": "Sequence deleted"
2241
+ "typename.label": "Sequence",
2242
+ "typename.label_zero": "Sequences",
2243
+ "typename.label_one": "Sequence",
2244
+ "typename.label_other": "Sequences",
2245
+ "object-name.placeholder": "New sequence",
2246
+ "add-object.label": "Add sequence",
2247
+ "rename-object.label": "Rename sequence",
2248
+ "delete-object.label": "Delete sequence",
2249
+ "object-deleted.label": "Sequence deleted"
135
2250
  },
136
- [Assistant_exports.Chat.typename]: {
137
- "typename label": "AI Chat",
138
- "object name placeholder": "New AI Chat",
139
- "rename object label": "Rename AI Chat",
140
- "delete object label": "Delete AI Chat",
141
- "object deleted label": "AI Chat deleted"
2251
+ [Chat3.Chat.typename]: {
2252
+ "typename.label": "AI Chat",
2253
+ "object-name.placeholder": "New AI Chat",
2254
+ "add-object.label": "Add AI chat",
2255
+ "rename-object.label": "Rename AI Chat",
2256
+ "delete-object.label": "Delete AI Chat",
2257
+ "object-deleted.label": "AI Chat deleted"
2258
+ },
2259
+ [Project.Project.typename]: {
2260
+ "typename.label": "Project",
2261
+ "typename.label_zero": "Projects",
2262
+ "typename.label_one": "Project",
2263
+ "typename.label_other": "Projects",
2264
+ "object-name.placeholder": "New project",
2265
+ "add-object.label": "Add project",
2266
+ "rename-object.label": "Rename project",
2267
+ "delete-object.label": "Delete project",
2268
+ "object-deleted.label": "Project deleted"
142
2269
  },
143
2270
  // TODO(burdon): Reconcile with react-ui-chat.
144
- [meta.id]: {
145
- "templates label": "Templates",
146
- "open ambient chat label": "Open Assistant",
147
- "assistant chat label": "Assistant",
148
- "plugin name": "Assistant",
149
- "settings title": "Assistant settings",
150
- "object placeholder": "New prompt",
151
- "create object label": "Create prompt",
152
- "create trigger label": "Create trigger",
153
- "create stack section label": "Create prompt",
154
- "command placeholder": "Enter slash command...",
155
- "template placeholder": "Enter template...",
156
- "value placeholder": "Enter value...",
157
- "prompt rules label": "Prompt Rules",
158
- "typename placeholder": "Enter typename of objects which this template is for",
159
- "description placeholder": "Enter description of when this template should be used",
160
- "select preset template placeholder": "Select preset",
161
- "service registry label": "Service Registry",
162
- "type filter placeholder": "Type",
163
- "any type filter label": "Any",
164
- "no blueprint message": "No active blueprints",
165
- "tool call label": "Calling tool...",
166
- "tool result label": "Success",
167
- "tool error label": "Tool call failed",
168
- "invocations label": "Invocations",
169
- "assistant dialog title": "Assistant",
170
- "open assistant label": "Open assistant",
171
- "no tools": "No tools are configured",
172
- "no results": "No results",
173
- "cancel button": "Cancel",
174
- "save button": "Save",
175
- "new thread button": "New Chat",
176
- "rename thread button": "Rename Chat",
177
- "chat history label": "Chat History",
178
- "chat update name label": "Update AI Chat name",
179
- "toolkit label": "Toolkit",
180
- "summary label": "Summary",
181
- "search placeholder": "Search...",
182
- "prompt placeholder": "Enter question or command...",
183
- "context objects button": "Add to context",
184
- "context settings button": "Chat settings",
185
- "microphone button": "Click to speak",
186
- "cancel processing button": "Stop processing",
187
- "blueprints in context title": "Blueprints",
188
- "objects in context title": "Content",
189
- "remove object in context label": "Remove document",
190
- "chat model title": "Model",
191
- "settings default label": "Default",
192
- "settings custom prompts label": "Use custom prompts",
193
- "settings llm provider label": "LLM provider",
194
- "settings edge llm model label": "Remote language model",
195
- "settings ollama llm model label": "Ollama language model"
2271
+ [meta9.id]: {
2272
+ "templates.label": "Templates",
2273
+ "open-ambient-chat.label": "Open Assistant",
2274
+ "assistant-chat.label": "Assistant",
2275
+ "plugin.name": "Assistant",
2276
+ "settings.title": "Assistant settings",
2277
+ "object.placeholder": "New prompt",
2278
+ "create-object.label": "Create prompt",
2279
+ "create-trigger.label": "Create trigger",
2280
+ "create-stack-section.label": "Create prompt",
2281
+ "command.placeholder": "Enter slash command...",
2282
+ "template.placeholder": "Enter template...",
2283
+ "value.placeholder": "Enter value...",
2284
+ "prompt-rules.label": "Prompt Rules",
2285
+ "typename.placeholder": "Enter typename of objects which this template is for",
2286
+ "description.placeholder": "Enter description of when this template should be used",
2287
+ "select-preset-template.placeholder": "Select preset",
2288
+ "service-registry.label": "Service Registry",
2289
+ "type-filter.placeholder": "Type",
2290
+ "any-type-filter.label": "Any",
2291
+ "no-blueprint.message": "No active blueprints",
2292
+ "tool-call.label": "Calling tool...",
2293
+ "tool-result.label": "Success",
2294
+ "tool-error.label": "Tool call failed",
2295
+ "invocations.label": "Invocations",
2296
+ "trace.label": "Trace",
2297
+ "assistant-dialog.title": "Assistant",
2298
+ "open-assistant.label": "Open assistant",
2299
+ "reset-blueprints.label": "Reset blueprints",
2300
+ "no-results.message": "No results",
2301
+ "cancel.button": "Cancel",
2302
+ "save.button": "Save",
2303
+ "new-thread.button": "New Chat",
2304
+ "rename-thread.button": "Rename Chat",
2305
+ "chat-history.label": "Chat History",
2306
+ "chat-update-name.label": "Update AI Chat name",
2307
+ "toolkit.label": "Toolkit",
2308
+ "stats.label": "Stats",
2309
+ "search.placeholder": "Search...",
2310
+ "prompt.placeholder": "Enter question or command...",
2311
+ "context-objects.button": "Add to context",
2312
+ "context-settings.button": "Chat settings",
2313
+ "microphone.button": "Click to speak",
2314
+ "cancel-processing.button": "Stop processing",
2315
+ "blueprints-in-context.title": "Blueprints",
2316
+ "objects-in-context.title": "Content",
2317
+ "remove-object-in-context.label": "Remove document",
2318
+ "chat-model.title": "Model",
2319
+ "settings.default.label": "Default",
2320
+ "settings.custom-prompts.label": "Use custom prompts",
2321
+ "settings.custom-prompts.description": "Allow the assistant to use custom prompts defined in your spaces.",
2322
+ "settings.llm-provider.label": "LLM provider",
2323
+ "settings.llm-provider.description": "Select which language model service to use for AI responses.",
2324
+ "settings.edge-llm-model.label": "Remote language model",
2325
+ "settings.edge-llm-model.description": "Choose the remote language model used for AI requests.",
2326
+ "settings.ollama-llm-model.label": "Ollama language model",
2327
+ "settings.ollama-llm-model.description": "Choose the locally hosted Ollama model for AI requests.",
2328
+ "settings.default-llm-model.label": "Default language model",
2329
+ // Trigger status
2330
+ "trigger-status-disabled.label": "Triggers disabled",
2331
+ "trigger-status-idle.label": "Triggers idle",
2332
+ "trigger-status-running.label": "Trigger running",
2333
+ "trigger-status-error.label": "Trigger error",
2334
+ "trigger-runtime.label": "Auto trigger execution",
2335
+ "trigger-last-invocation.label": "Last run",
2336
+ "trigger-duration.label": "Duration",
2337
+ "debug.button": "Debug",
2338
+ "online-switch.label": "Online",
2339
+ "run-prompt.label": "Run prompt",
2340
+ "typename.label": "Typename",
2341
+ "branch-thread.menu": "Branch chat",
2342
+ "chat-toolbar.title": "Chat toolbar",
2343
+ // ProjectSettings
2344
+ "instructions.label": "Instructions",
2345
+ "reset-history.button": "Reset",
2346
+ "subscriptions.label": "Subscriptions"
196
2347
  }
197
2348
  }
198
2349
  }
199
2350
  ];
200
2351
 
201
2352
  // src/AssistantPlugin.tsx
202
- import * as Effect from "effect/Effect";
203
- import { Capability as Capability12, Common, Plugin } from "@dxos/app-framework";
204
- import { ResearchGraph } from "@dxos/assistant-toolkit";
205
- import { Blueprint as Blueprint2, Prompt as Prompt2 } from "@dxos/blueprints";
2353
+ import * as Effect2 from "effect/Effect";
2354
+ import { ActivationEvent, ActivationEvents, Capability, Plugin } from "@dxos/app-framework";
2355
+ import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
2356
+ import { Chat as Chat4, Memory, Plan, Project as Project2, ProjectBlueprint, ResearchGraph } from "@dxos/assistant-toolkit";
2357
+ import { Blueprint as Blueprint3, Prompt as Prompt2 } from "@dxos/blueprints";
206
2358
  import { Sequence as Sequence2 } from "@dxos/conductor";
207
- import { Obj, Type as Type2 } from "@dxos/echo";
208
- import { Operation } from "@dxos/operation";
2359
+ import { Annotation as Annotation3, Obj as Obj7, Type as Type3 } from "@dxos/echo";
2360
+ import { Operation as Operation2 } from "@dxos/operation";
2361
+ import { AutomationCapabilities as AutomationCapabilities2 } from "@dxos/plugin-automation/types";
209
2362
  import { ClientEvents } from "@dxos/plugin-client/types";
2363
+ import { MarkdownEvents } from "@dxos/plugin-markdown";
210
2364
  import { SpaceCapabilities, SpaceEvents } from "@dxos/plugin-space/types";
2365
+ import { SpaceOperation } from "@dxos/plugin-space/operations";
211
2366
  import { HasSubject } from "@dxos/types";
212
- var AssistantPlugin = Plugin.define(meta).pipe(Common.Plugin.addTranslationsModule({
213
- translations
214
- }), Common.Plugin.addSettingsModule({
215
- activate: Settings
216
- }), Plugin.addModule({
217
- // TODO(wittjosiah): Does not integrate with settings store.
218
- // Should this be a different event?
219
- // Should settings store be renamed to be more generic?
220
- activatesOn: Common.ActivationEvent.SetupSettings,
221
- activate: AssistantState
222
- }), Common.Plugin.addMetadataModule({
2367
+ import { meta as meta10 } from "#meta";
2368
+ import { AssistantEvents as AssistantEvents2 } from "#types";
2369
+ import { AssistantOperation as AssistantOperation2 } from "#operations";
2370
+ import * as Option5 from "effect/Option";
2371
+ import { AiService, AppGraphBuilder, AssistantState, BlueprintDefinition, CompanionChatProvisioner, EdgeModelResolver, LocalModelResolver, MarkdownExtension, Migrations, OperationHandler, ReactSurface, Settings, Toolkit } from "#capabilities";
2372
+ var AssistantPlugin = Plugin.define(meta10).pipe(AppPlugin.addAppGraphModule({
2373
+ activate: AppGraphBuilder
2374
+ }), AppPlugin.addBlueprintDefinitionModule({
2375
+ activate: BlueprintDefinition
2376
+ }), AppPlugin.addMetadataModule({
223
2377
  metadata: [
224
2378
  {
225
- id: Type2.getTypename(Assistant_exports.Chat),
2379
+ id: Type3.getTypename(Chat4.Chat),
2380
+ metadata: {
2381
+ icon: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option5.getOrThrow).icon,
2382
+ iconHue: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option5.getOrThrow).hue ?? "white",
2383
+ createObject: (props, options) => Effect2.gen(function* () {
2384
+ const { object } = yield* Operation2.invoke(AssistantOperation2.CreateChat, {
2385
+ db: options.db,
2386
+ name: props?.name
2387
+ });
2388
+ return yield* Operation2.invoke(SpaceOperation.AddObject, {
2389
+ object,
2390
+ target: options.target,
2391
+ hidden: true,
2392
+ targetNodeId: options.targetNodeId
2393
+ });
2394
+ })
2395
+ }
2396
+ },
2397
+ {
2398
+ id: Type3.getTypename(Blueprint3.Blueprint),
226
2399
  metadata: {
227
- icon: "ph--atom--regular",
228
- iconHue: "sky",
229
- createObject: (props) => Effect.sync(() => Assistant_exports.make(props))
2400
+ icon: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option5.getOrThrow).icon,
2401
+ iconHue: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option5.getOrThrow).hue ?? "white",
2402
+ inputSchema: AssistantOperation2.BlueprintForm,
2403
+ createObject: (props, options) => Effect2.gen(function* () {
2404
+ const object = Blueprint3.make(props);
2405
+ return yield* Operation2.invoke(SpaceOperation.AddObject, {
2406
+ object,
2407
+ target: options.target,
2408
+ hidden: true,
2409
+ targetNodeId: options.targetNodeId
2410
+ });
2411
+ })
230
2412
  }
231
2413
  },
232
2414
  {
233
- id: Type2.getTypename(Blueprint2.Blueprint),
2415
+ id: Type3.getTypename(Prompt2.Prompt),
234
2416
  metadata: {
235
- icon: "ph--blueprint--regular",
236
- iconHue: "sky",
237
- inputSchema: AssistantOperation.BlueprintForm,
238
- createObject: (props) => Effect.sync(() => Blueprint2.make(props))
2417
+ icon: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option5.getOrThrow).icon,
2418
+ iconHue: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option5.getOrThrow).hue ?? "white",
2419
+ createObject: (props, options) => Effect2.gen(function* () {
2420
+ const object = Prompt2.make(props);
2421
+ return yield* Operation2.invoke(SpaceOperation.AddObject, {
2422
+ object,
2423
+ target: options.target,
2424
+ hidden: true,
2425
+ targetNodeId: options.targetNodeId
2426
+ });
2427
+ })
239
2428
  }
240
2429
  },
241
2430
  {
242
- id: Type2.getTypename(Prompt2.Prompt),
2431
+ id: Type3.getTypename(Sequence2),
243
2432
  metadata: {
244
- icon: "ph--scroll--regular",
245
- iconHue: "sky",
246
- createObject: (props) => Effect.sync(() => Prompt2.make(props))
2433
+ icon: Annotation3.IconAnnotation.get(Sequence2).pipe(Option5.getOrThrow).icon,
2434
+ iconHue: Annotation3.IconAnnotation.get(Sequence2).pipe(Option5.getOrThrow).hue ?? "white",
2435
+ createObject: (props, options) => Effect2.gen(function* () {
2436
+ const object = Obj7.make(Sequence2, props);
2437
+ return yield* Operation2.invoke(SpaceOperation.AddObject, {
2438
+ object,
2439
+ target: options.target,
2440
+ hidden: true,
2441
+ targetNodeId: options.targetNodeId
2442
+ });
2443
+ })
247
2444
  }
248
2445
  },
249
2446
  {
250
- id: Type2.getTypename(Sequence2),
2447
+ id: Type3.getTypename(Project2.Project),
251
2448
  metadata: {
252
- icon: "ph--circuitry--regular",
253
- iconHue: "sky",
254
- createObject: (props) => Effect.sync(() => Obj.make(Sequence2, props)),
255
- addToCollectionOnCreate: true
2449
+ icon: Annotation3.IconAnnotation.get(Project2.Project).pipe(Option5.getOrThrow).icon,
2450
+ iconHue: Annotation3.IconAnnotation.get(Project2.Project).pipe(Option5.getOrThrow).hue ?? "white",
2451
+ createObject: (props, options) => Effect2.gen(function* () {
2452
+ const object = yield* Project2.makeInitialized({
2453
+ name: "New Project",
2454
+ spec: "Not specified yet"
2455
+ }, ProjectBlueprint.make()).pipe(withComputeRuntime(options.db.spaceId));
2456
+ return yield* Operation2.invoke(SpaceOperation.AddObject, {
2457
+ object,
2458
+ target: options.target,
2459
+ hidden: true,
2460
+ targetNodeId: options.targetNodeId
2461
+ });
2462
+ })
256
2463
  }
257
2464
  }
258
2465
  ]
259
- }), Common.Plugin.addSchemaModule({
2466
+ }), AppPlugin.addOperationHandlerModule({
2467
+ activate: OperationHandler
2468
+ }), AppPlugin.addSchemaModule({
260
2469
  schema: [
261
- Assistant_exports.Chat,
262
- Assistant_exports.CompanionTo,
263
- Blueprint2.Blueprint,
2470
+ Chat4.Chat,
2471
+ Chat4.CompanionTo,
2472
+ Blueprint3.Blueprint,
264
2473
  HasSubject.HasSubject,
265
2474
  Prompt2.Prompt,
266
- ResearchGraph,
267
- Sequence2
2475
+ ResearchGraph.ResearchGraph,
2476
+ Project2.Project,
2477
+ Plan.Plan,
2478
+ Sequence2,
2479
+ Memory.Memory
268
2480
  ]
269
- }), Plugin.addModule({
270
- id: "on-space-created",
271
- activatesOn: SpaceEvents.SpaceCreated,
272
- activate: () => Effect.succeed(Capability12.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation.invoke(AssistantOperation.OnCreateSpace, params)))
273
- }), Plugin.addModule({
274
- activatesOn: ClientEvents.SpacesReady,
275
- activate: Repair
276
- }), Common.Plugin.addAppGraphModule({
277
- activate: AppGraphBuilder
278
- }), Common.Plugin.addOperationResolverModule({
279
- activate: OperationResolver
280
- }), Common.Plugin.addSurfaceModule({
2481
+ }), AppPlugin.addSettingsModule({
2482
+ activate: Settings
2483
+ }), AppPlugin.addSurfaceModule({
281
2484
  activate: ReactSurface,
282
2485
  activatesBefore: [
283
- Common.ActivationEvent.SetupArtifactDefinition
2486
+ AppActivationEvents.SetupArtifactDefinition
284
2487
  ]
2488
+ }), AppPlugin.addTranslationsModule({
2489
+ translations
2490
+ }), Plugin.addModule({
2491
+ id: "markdown",
2492
+ activatesOn: MarkdownEvents.SetupExtensions,
2493
+ activate: MarkdownExtension
2494
+ }), Plugin.addModule({
2495
+ // TODO(wittjosiah): Does not integrate with settings store.
2496
+ // Should this be a different event?
2497
+ // Should settings store be renamed to be more generic?
2498
+ activatesOn: AppActivationEvents.SetupSettings,
2499
+ activate: AssistantState
285
2500
  }), Plugin.addModule({
286
- activatesOn: AssistantEvents.SetupAiServiceProviders,
2501
+ id: "on-space-created",
2502
+ activatesOn: SpaceEvents.SpaceCreated,
2503
+ activate: () => Effect2.succeed(Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation2.invoke(AssistantOperation2.OnCreateSpace, params)))
2504
+ }), Plugin.addModule({
2505
+ activatesOn: AssistantEvents2.SetupAiServiceProviders,
287
2506
  activate: EdgeModelResolver
288
2507
  }), Plugin.addModule({
289
- activatesOn: AssistantEvents.SetupAiServiceProviders,
2508
+ activatesOn: AssistantEvents2.SetupAiServiceProviders,
290
2509
  activate: LocalModelResolver
291
2510
  }), Plugin.addModule({
292
2511
  activatesBefore: [
293
- AssistantEvents.SetupAiServiceProviders
2512
+ AssistantEvents2.SetupAiServiceProviders
294
2513
  ],
295
2514
  // TODO(dmaretskyi): This should activate lazily when the AI chat is used.
296
- activatesOn: Common.ActivationEvent.Startup,
2515
+ activatesOn: ActivationEvents.Startup,
297
2516
  activate: AiService
298
- }), Common.Plugin.addBlueprintDefinitionModule({
299
- activate: BlueprintDefinition
300
2517
  }), Plugin.addModule({
301
2518
  // TODO(wittjosiah): Use a different event.
302
- activatesOn: Common.ActivationEvent.Startup,
2519
+ activatesOn: ActivationEvents.Startup,
303
2520
  activate: Toolkit
2521
+ }), Plugin.addModule({
2522
+ activatesOn: ActivationEvent.allOf(ActivationEvents.OperationInvokerReady, AppActivationEvents.AppGraphReady, AppActivationEvents.LayoutReady),
2523
+ activate: CompanionChatProvisioner
2524
+ }), Plugin.addModule({
2525
+ activatesOn: ClientEvents.SetupMigration,
2526
+ activate: Migrations
304
2527
  }), Plugin.make);
2528
+ var withComputeRuntime = (spaceId) => (effect) => Effect2.gen(function* () {
2529
+ const provider = yield* Capability.get(AutomationCapabilities2.ComputeRuntime).pipe(Effect2.orDie);
2530
+ const runtime = yield* provider.getRuntime(spaceId).runtimeEffect;
2531
+ return yield* effect.pipe(Effect2.provide(runtime));
2532
+ });
305
2533
  export {
2534
+ ASSISTANT_COMPANION_VARIANT,
306
2535
  ASSISTANT_DIALOG,
307
- AiService,
308
2536
  ApiAuthorization,
309
- AppGraphBuilder,
310
2537
  Assistant_exports as Assistant,
311
- assistant_blueprint_exports as AssistantBlueprint,
2538
+ blueprint_default as AssistantBlueprint,
312
2539
  AssistantCapabilities,
313
2540
  AssistantEvents,
314
- AssistantOperation,
315
2541
  AssistantPlugin,
316
2542
  AssistantSettings,
317
- AssistantState,
318
- BlueprintArticle,
319
- BlueprintDefinition,
320
2543
  Chat,
321
- ChatCompanion,
322
- ChatContainer,
323
2544
  ChatContextProvider,
324
- ChatDialog,
325
- EdgeModelResolver,
326
2545
  LLM_PROVIDERS,
327
- LocalModelResolver,
328
- OperationResolver,
329
- PromptArticle,
330
- ReactSurface,
331
- Repair,
2546
+ ProcessTree,
332
2547
  ServiceType,
333
- Settings,
334
2548
  TemplateEditor,
335
2549
  Toolbox,
336
- ToolboxContainer,
337
- Toolkit,
2550
+ ToolboxPanel,
338
2551
  categoryIcons,
339
- meta,
2552
+ meta8 as meta,
340
2553
  translations,
341
- useActiveBlueprints,
342
- useBlueprintHandlers,
2554
+ useActiveBlueprints2 as useActiveBlueprints,
2555
+ useBlueprintHandlers2 as useBlueprintHandlers,
343
2556
  useBlueprintRegistry,
344
- useBlueprints,
2557
+ useBlueprints2 as useBlueprints,
345
2558
  useChatContext,
346
2559
  useChatProcessor,
347
2560
  useChatServices,
348
- useChatToolbarActions,
2561
+ useChatToolbarActions2 as useChatToolbarActions,
349
2562
  useContextBinder,
350
- useContextObjects,
351
- useFilteredTypes,
2563
+ useContextObjects3 as useContextObjects,
2564
+ useFilteredTypes2 as useFilteredTypes,
352
2565
  useFlush,
353
2566
  useOnline,
354
2567
  usePresets,