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