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