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