@dxos/plugin-assistant 0.8.4-main.4a85c3132b → 0.8.4-main.4f23b4e393

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 (784) hide show
  1. package/dist/lib/neutral/AgentArticle-5XDDEXMP.mjs +169 -0
  2. package/dist/lib/neutral/AgentArticle-5XDDEXMP.mjs.map +7 -0
  3. package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs +100 -0
  4. package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs.map +7 -0
  5. package/dist/lib/neutral/AssistantPlugin.mjs +99 -0
  6. package/dist/lib/neutral/AssistantPlugin.mjs.map +7 -0
  7. package/dist/lib/neutral/AssistantPlugin.node.mjs +46 -0
  8. package/dist/lib/neutral/AssistantPlugin.node.mjs.map +7 -0
  9. package/dist/lib/neutral/AssistantSettings-GG52BLKS.mjs +40 -0
  10. package/dist/lib/neutral/AssistantSettings-GG52BLKS.mjs.map +7 -0
  11. package/dist/lib/{browser/BlueprintArticle-CCS25MNW.mjs → neutral/BlueprintArticle-U7LUBFOS.mjs} +6 -15
  12. package/dist/lib/neutral/BlueprintArticle-U7LUBFOS.mjs.map +7 -0
  13. package/dist/lib/neutral/ChatCompanion-L33PFOFB.mjs +130 -0
  14. package/dist/lib/neutral/ChatCompanion-L33PFOFB.mjs.map +7 -0
  15. package/dist/lib/neutral/ChatContainer-VYVJYPPN.mjs +8 -0
  16. package/dist/lib/{browser/ChatDialog-AET7GVIB.mjs → neutral/ChatDialog-QKZLG7SQ.mjs} +13 -26
  17. package/dist/lib/neutral/ChatDialog-QKZLG7SQ.mjs.map +7 -0
  18. package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs +28 -0
  19. package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs.map +7 -0
  20. package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs +116 -0
  21. package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs.map +7 -0
  22. package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs +48 -0
  23. package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs.map +7 -0
  24. package/dist/lib/neutral/TracePanel-HYVPDIAA.mjs +565 -0
  25. package/dist/lib/neutral/TracePanel-HYVPDIAA.mjs.map +7 -0
  26. package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs +92 -0
  27. package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs.map +7 -0
  28. package/dist/lib/{browser/ai-service-CY2BYPH6.mjs → neutral/ai-service-GJXMI5OI.mjs} +2 -2
  29. package/dist/lib/{browser/ai-service-CY2BYPH6.mjs.map → neutral/ai-service-GJXMI5OI.mjs.map} +3 -3
  30. package/dist/lib/neutral/app-graph-builder-LHRT43KA.mjs +189 -0
  31. package/dist/lib/neutral/app-graph-builder-LHRT43KA.mjs.map +7 -0
  32. package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs +32 -0
  33. package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs.map +7 -0
  34. package/dist/lib/{browser → neutral}/blueprints/index.mjs +1 -1
  35. package/dist/lib/neutral/capabilities/index.mjs +35 -0
  36. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  37. package/dist/lib/{browser/chunk-EXVT7D4B.mjs → neutral/chunk-4CQZCMRP.mjs} +7 -5
  38. package/dist/lib/neutral/chunk-4CQZCMRP.mjs.map +7 -0
  39. package/dist/lib/neutral/chunk-5H6UJHLF.mjs +30 -0
  40. package/dist/lib/neutral/chunk-5H6UJHLF.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-A4SCD32D.mjs +106 -0
  42. package/dist/lib/neutral/chunk-A4SCD32D.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-OT2QDO3T.mjs +8 -0
  44. package/dist/lib/neutral/chunk-OT2QDO3T.mjs.map +7 -0
  45. package/dist/lib/neutral/chunk-VHPTYKYD.mjs +361 -0
  46. package/dist/lib/neutral/chunk-VHPTYKYD.mjs.map +7 -0
  47. package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs +116 -0
  48. package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs.map +7 -0
  49. package/dist/lib/neutral/components/index.mjs +2297 -0
  50. package/dist/lib/neutral/components/index.mjs.map +7 -0
  51. package/dist/lib/neutral/containers/index.mjs +29 -0
  52. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  53. package/dist/lib/neutral/create-chat-5VM2UUWY.mjs +71 -0
  54. package/dist/lib/neutral/create-chat-5VM2UUWY.mjs.map +7 -0
  55. package/dist/lib/neutral/create-object-UZCJCPWM.mjs +93 -0
  56. package/dist/lib/neutral/create-object-UZCJCPWM.mjs.map +7 -0
  57. package/dist/lib/{browser/edge-model-resolver-YTMFQEN5.mjs → neutral/edge-model-resolver-XDNBZ3US.mjs} +2 -2
  58. package/dist/lib/{browser/edge-model-resolver-YTMFQEN5.mjs.map → neutral/edge-model-resolver-XDNBZ3US.mjs.map} +3 -3
  59. package/dist/lib/neutral/ensure-companion-chat-5S4LZM2H.mjs +58 -0
  60. package/dist/lib/neutral/ensure-companion-chat-5S4LZM2H.mjs.map +7 -0
  61. package/dist/lib/neutral/hooks/index.mjs +930 -0
  62. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  63. package/dist/lib/neutral/index.mjs +32 -0
  64. package/dist/lib/{browser/local-model-resolver-CGRQH37T.mjs → neutral/local-model-resolver-I2BENFFS.mjs} +8 -4
  65. package/dist/lib/neutral/local-model-resolver-I2BENFFS.mjs.map +7 -0
  66. package/dist/lib/neutral/markdown-KTBFOMFM.mjs +110 -0
  67. package/dist/lib/neutral/markdown-KTBFOMFM.mjs.map +7 -0
  68. package/dist/lib/neutral/meta.json +1 -0
  69. package/dist/lib/neutral/meta.mjs +12 -0
  70. package/dist/lib/neutral/migrations-7DEMVBOG.mjs +28 -0
  71. package/dist/lib/neutral/migrations-7DEMVBOG.mjs.map +7 -0
  72. package/dist/lib/neutral/on-create-space-Q2R7OSP6.mjs +19 -0
  73. package/dist/lib/neutral/on-create-space-Q2R7OSP6.mjs.map +7 -0
  74. package/dist/lib/neutral/operation-handler-SF36MOB5.mjs +13 -0
  75. package/dist/lib/neutral/operation-handler-SF36MOB5.mjs.map +7 -0
  76. package/dist/lib/neutral/operations/index.mjs +8 -0
  77. package/dist/lib/neutral/plugin.mjs +16 -0
  78. package/dist/lib/neutral/plugin.mjs.map +7 -0
  79. package/dist/lib/neutral/react-surface-2WAPE25I.mjs +174 -0
  80. package/dist/lib/neutral/react-surface-2WAPE25I.mjs.map +7 -0
  81. package/dist/lib/neutral/resolve-navigation-targets-VXBSWV5L.mjs +20 -0
  82. package/dist/lib/neutral/resolve-navigation-targets-VXBSWV5L.mjs.map +7 -0
  83. package/dist/lib/neutral/run-prompt-in-new-chat-XEPT5MOM.mjs +100 -0
  84. package/dist/lib/neutral/run-prompt-in-new-chat-XEPT5MOM.mjs.map +7 -0
  85. package/dist/lib/neutral/set-current-chat-ZFDCYK5I.mjs +48 -0
  86. package/dist/lib/neutral/set-current-chat-ZFDCYK5I.mjs.map +7 -0
  87. package/dist/lib/{browser/settings-YREVQAZ5.mjs → neutral/settings-W4BLWQ53.mjs} +6 -11
  88. package/dist/lib/neutral/settings-W4BLWQ53.mjs.map +7 -0
  89. package/dist/lib/neutral/state-H3G7QCU6.mjs +28 -0
  90. package/dist/lib/neutral/state-H3G7QCU6.mjs.map +7 -0
  91. package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs +14 -0
  92. package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs.map +7 -0
  93. package/dist/lib/neutral/translations.mjs +174 -0
  94. package/dist/lib/neutral/translations.mjs.map +7 -0
  95. package/dist/lib/neutral/types/index.mjs +20 -0
  96. package/dist/lib/neutral/update-chat-name-ENXRUMDJ.mjs +54 -0
  97. package/dist/lib/neutral/update-chat-name-ENXRUMDJ.mjs.map +7 -0
  98. package/dist/types/src/AssistantPlugin.d.ts +1 -0
  99. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  100. package/dist/types/src/AssistantPlugin.node.d.ts +4 -0
  101. package/dist/types/src/AssistantPlugin.node.d.ts.map +1 -0
  102. package/dist/types/src/AssistantPlugin.test.d.ts +2 -0
  103. package/dist/types/src/AssistantPlugin.test.d.ts.map +1 -0
  104. package/dist/types/src/blueprints/assistant/blueprint.d.ts +2 -2
  105. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -1
  106. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  108. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  109. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  110. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
  111. package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
  112. package/dist/types/src/capabilities/create-object.d.ts +31 -0
  113. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  114. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/index.d.ts +55 -11
  116. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  117. package/dist/types/src/capabilities/local-model-resolver.d.ts +16 -0
  118. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/{repair/repair.d.ts → markdown.d.ts} +2 -3
  120. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/migrations.d.ts +6 -0
  122. package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  124. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  125. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  126. package/dist/types/src/capabilities/settings.d.ts +6 -0
  127. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  128. package/dist/types/src/capabilities/state.d.ts +21 -0
  129. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  130. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  131. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +6 -0
  132. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -0
  133. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -0
  134. package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
  135. package/dist/types/src/components/AssistantSettings/index.d.ts +2 -0
  136. package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -0
  137. package/dist/types/src/components/Chat/Chat.d.ts +43 -47
  138. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  139. package/dist/types/src/components/Chat/context.d.ts +29 -0
  140. package/dist/types/src/components/Chat/context.d.ts.map +1 -0
  141. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +2 -1
  142. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  143. package/dist/types/src/components/ChatPrompt/ChatMcpErrors.d.ts +12 -0
  144. package/dist/types/src/components/ChatPrompt/ChatMcpErrors.d.ts.map +1 -0
  145. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +8 -4
  146. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  147. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
  148. package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
  150. package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts +28 -0
  151. package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts.map +1 -0
  152. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +2 -2
  153. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  154. package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts +20 -0
  155. package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts.map +1 -0
  156. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  157. package/dist/types/src/components/ChatPrompt/index.d.ts +3 -0
  158. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  159. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts +14 -0
  160. package/dist/types/src/components/ChatThread/Anchor.stories.d.ts.map +1 -0
  161. package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -3
  162. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  163. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +10 -430
  164. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  165. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -1
  166. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts +42 -0
  167. package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
  168. package/dist/types/src/components/ChatThread/registry.d.ts +18 -0
  169. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
  170. package/dist/types/src/components/ChatThread/sync.d.ts +44 -17
  171. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  172. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
  173. package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
  174. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
  175. package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
  176. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
  177. package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
  178. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
  179. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
  180. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts +18 -0
  181. package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -0
  182. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
  183. package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
  184. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
  185. package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
  186. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
  187. package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
  188. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +12 -0
  189. package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -0
  190. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
  191. package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
  192. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
  193. package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
  194. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
  195. package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
  196. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts +15 -0
  197. package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
  198. package/dist/types/src/components/ChatThread/widgets/defaults.d.ts +5 -0
  199. package/dist/types/src/components/ChatThread/widgets/defaults.d.ts.map +1 -0
  200. package/dist/types/src/components/ChatThread/widgets/index.d.ts +10 -0
  201. package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
  202. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +11 -0
  203. package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
  204. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +7 -0
  205. package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
  206. package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
  207. package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
  208. package/dist/types/src/components/TaskList/TaskList.d.ts +10 -0
  209. package/dist/types/src/components/TaskList/TaskList.d.ts.map +1 -0
  210. package/dist/types/src/components/TaskList/TaskList.stories.d.ts +16 -0
  211. package/dist/types/src/components/TaskList/TaskList.stories.d.ts.map +1 -0
  212. package/dist/types/src/components/TaskList/index.d.ts +2 -0
  213. package/dist/types/src/components/TaskList/index.d.ts.map +1 -0
  214. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +6 -5
  215. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  216. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +1 -419
  217. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  218. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +4 -5
  219. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  220. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +2 -420
  221. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  222. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -1
  223. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -1
  224. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +4 -13
  225. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  226. package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -9
  227. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  228. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -419
  229. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  230. package/dist/types/src/components/index.d.ts +4 -0
  231. package/dist/types/src/components/index.d.ts.map +1 -1
  232. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
  233. package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
  234. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
  235. package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
  236. package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
  237. package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
  238. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
  239. package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
  240. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
  241. package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
  242. package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
  243. package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
  244. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +4 -4
  245. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -1
  246. package/dist/types/src/containers/BlueprintArticle/index.d.ts +1 -2
  247. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -1
  248. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +14 -8
  249. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -1
  250. package/dist/types/src/containers/ChatCompanion/index.d.ts +1 -2
  251. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -1
  252. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +6 -12
  253. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -1
  254. package/dist/types/src/containers/ChatContainer/index.d.ts +1 -2
  255. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -1
  256. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -1
  257. package/dist/types/src/containers/ChatDialog/index.d.ts +1 -2
  258. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -1
  259. package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts +6 -0
  260. package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts.map +1 -0
  261. package/dist/types/src/containers/PlanArticle/index.d.ts +2 -0
  262. package/dist/types/src/containers/PlanArticle/index.d.ts.map +1 -0
  263. package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts +6 -0
  264. package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -0
  265. package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts +15 -0
  266. package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts.map +1 -0
  267. package/dist/types/src/containers/RoutineArticle/index.d.ts +2 -0
  268. package/dist/types/src/containers/RoutineArticle/index.d.ts.map +1 -0
  269. package/dist/types/src/containers/RoutineList/RoutineList.d.ts +6 -0
  270. package/dist/types/src/containers/RoutineList/RoutineList.d.ts.map +1 -0
  271. package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts +21 -0
  272. package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts.map +1 -0
  273. package/dist/types/src/containers/RoutineList/index.d.ts +2 -0
  274. package/dist/types/src/containers/RoutineList/index.d.ts.map +1 -0
  275. package/dist/types/src/containers/TracePanel/TracePanel.d.ts +8 -0
  276. package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
  277. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +13 -0
  278. package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -0
  279. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
  280. package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
  281. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
  282. package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
  283. package/dist/types/src/containers/TracePanel/execution-graph.d.ts +97 -0
  284. package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
  285. package/dist/types/src/containers/TracePanel/execution-graph.test.d.ts +2 -0
  286. package/dist/types/src/containers/TracePanel/execution-graph.test.d.ts.map +1 -0
  287. package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
  288. package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
  289. package/dist/types/src/containers/TracePanel/testing/index.d.ts +3 -0
  290. package/dist/types/src/containers/TracePanel/testing/index.d.ts.map +1 -0
  291. package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts +14 -0
  292. package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts.map +1 -0
  293. package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts +12 -0
  294. package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts.map +1 -0
  295. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +3 -2
  296. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -1
  297. package/dist/types/src/containers/TriggerStatus/index.d.ts +1 -2
  298. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -1
  299. package/dist/types/src/containers/index.d.ts +6 -3
  300. package/dist/types/src/containers/index.d.ts.map +1 -1
  301. package/dist/types/src/extensions/index.d.ts +2 -0
  302. package/dist/types/src/extensions/index.d.ts.map +1 -0
  303. package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
  304. package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
  305. package/dist/types/src/feed-logger.d.ts +13 -0
  306. package/dist/types/src/feed-logger.d.ts.map +1 -0
  307. package/dist/types/src/hooks/index.d.ts +2 -0
  308. package/dist/types/src/hooks/index.d.ts.map +1 -1
  309. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +4 -4
  310. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  311. package/dist/types/src/hooks/useChatKeymap.d.ts +12 -0
  312. package/dist/types/src/hooks/useChatKeymap.d.ts.map +1 -0
  313. package/dist/types/src/hooks/useChatProcessor.d.ts +6 -6
  314. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  315. package/dist/types/src/hooks/useChatServices.d.ts +3 -6
  316. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  317. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
  318. package/dist/types/src/hooks/useContextBinder.d.ts +4 -3
  319. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  320. package/dist/types/src/hooks/useContextObjects.d.ts +2 -2
  321. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
  322. package/dist/types/src/hooks/useDebug.d.ts +10 -0
  323. package/dist/types/src/hooks/useDebug.d.ts.map +1 -0
  324. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -1
  325. package/dist/types/src/hooks/useFlush.d.ts +1 -1
  326. package/dist/types/src/hooks/useFlush.d.ts.map +1 -1
  327. package/dist/types/src/hooks/usePresets.d.ts +1 -1
  328. package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
  329. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  330. package/dist/types/src/index.d.ts +0 -5
  331. package/dist/types/src/index.d.ts.map +1 -1
  332. package/dist/types/src/meta.d.ts +2 -0
  333. package/dist/types/src/meta.d.ts.map +1 -1
  334. package/dist/types/src/operations/create-chat.d.ts +5 -0
  335. package/dist/types/src/operations/create-chat.d.ts.map +1 -0
  336. package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
  337. package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
  338. package/dist/types/src/operations/index.d.ts +3 -0
  339. package/dist/types/src/operations/index.d.ts.map +1 -0
  340. package/dist/types/src/operations/on-create-space.d.ts +5 -0
  341. package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
  342. package/dist/types/src/operations/prompt.test.d.ts +2 -0
  343. package/dist/types/src/operations/prompt.test.d.ts.map +1 -0
  344. package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
  345. package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
  346. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
  347. package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
  348. package/dist/types/src/operations/set-current-chat.d.ts +5 -0
  349. package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
  350. package/dist/types/src/operations/update-chat-name.d.ts +5 -0
  351. package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
  352. package/dist/types/src/plugin.d.ts +4 -0
  353. package/dist/types/src/plugin.d.ts.map +1 -0
  354. package/dist/types/src/processor/index.d.ts +0 -1
  355. package/dist/types/src/processor/index.d.ts.map +1 -1
  356. package/dist/types/src/processor/presets.d.ts +1 -1
  357. package/dist/types/src/processor/presets.d.ts.map +1 -1
  358. package/dist/types/src/processor/processor.d.ts +54 -35
  359. package/dist/types/src/processor/processor.d.ts.map +1 -1
  360. package/dist/types/src/testing/index.d.ts +1 -0
  361. package/dist/types/src/testing/index.d.ts.map +1 -1
  362. package/dist/types/src/testing/test-generator.d.ts +2 -3
  363. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  364. package/dist/types/src/testing/test-generator.test.d.ts +2 -0
  365. package/dist/types/src/testing/test-generator.test.d.ts.map +1 -0
  366. package/dist/types/src/testing/test-sequence.d.ts +3 -3
  367. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  368. package/dist/types/src/testing/test-services.d.ts +1 -1
  369. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  370. package/dist/types/src/testing/test-trace.d.ts +5 -0
  371. package/dist/types/src/testing/test-trace.d.ts.map +1 -0
  372. package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
  373. package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
  374. package/dist/types/src/translations.d.ts +2 -419
  375. package/dist/types/src/translations.d.ts.map +1 -1
  376. package/dist/types/src/types/Assistant.d.ts +30 -14
  377. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  378. package/dist/types/src/types/AssistantCapabilities.d.ts +30 -0
  379. package/dist/types/src/types/AssistantCapabilities.d.ts.map +1 -0
  380. package/dist/types/src/types/AssistantEvents.d.ts +3 -0
  381. package/dist/types/src/types/AssistantEvents.d.ts.map +1 -0
  382. package/dist/types/src/types/AssistantOperation.d.ts +142 -0
  383. package/dist/types/src/types/AssistantOperation.d.ts.map +1 -0
  384. package/dist/types/src/types/Settings.d.ts +26 -0
  385. package/dist/types/src/types/Settings.d.ts.map +1 -0
  386. package/dist/types/src/types/index.d.ts +3 -4
  387. package/dist/types/src/types/index.d.ts.map +1 -1
  388. package/dist/types/src/types/service.d.ts +1 -1
  389. package/dist/types/src/types/service.d.ts.map +1 -1
  390. package/dist/types/tsconfig.tsbuildinfo +1 -1
  391. package/package.json +165 -109
  392. package/src/AssistantPlugin.node.ts +44 -0
  393. package/src/AssistantPlugin.test.ts +35 -0
  394. package/src/AssistantPlugin.ts +126 -0
  395. package/src/blueprints/assistant/blueprint.test.ts +15 -17
  396. package/src/blueprints/assistant/blueprint.ts +11 -7
  397. package/src/capabilities/app-graph-builder.ts +192 -0
  398. package/src/capabilities/blueprint-definition.ts +56 -0
  399. package/src/capabilities/companion-chat-provisioner.ts +163 -0
  400. package/src/capabilities/create-object.ts +107 -0
  401. package/src/capabilities/index.ts +24 -11
  402. package/src/capabilities/{local-model-resolver/local-model-resolver.ts → local-model-resolver.ts} +14 -4
  403. package/src/capabilities/markdown.ts +40 -0
  404. package/src/capabilities/migrations.ts +28 -0
  405. package/src/capabilities/operation-handler.ts +16 -0
  406. package/src/capabilities/react-surface.tsx +175 -0
  407. package/src/capabilities/{settings/settings.ts → settings.ts} +2 -2
  408. package/src/capabilities/{state/state.ts → state.ts} +11 -3
  409. package/src/capabilities/{toolkit/toolkit.ts → toolkit.ts} +2 -4
  410. package/src/components/AssistantSettings/AssistantSettings.stories.tsx +35 -0
  411. package/src/components/AssistantSettings/AssistantSettings.tsx +43 -0
  412. package/src/components/AssistantSettings/index.ts +5 -0
  413. package/src/components/Chat/Chat.tsx +118 -286
  414. package/src/components/Chat/context.ts +39 -0
  415. package/src/components/ChatPrompt/ChatActions.tsx +28 -16
  416. package/src/components/ChatPrompt/ChatMcpErrors.tsx +50 -0
  417. package/src/components/ChatPrompt/ChatOptions.stories.tsx +136 -0
  418. package/src/components/ChatPrompt/ChatOptions.tsx +243 -57
  419. package/src/components/ChatPrompt/ChatPrompt.tsx +182 -0
  420. package/src/components/ChatPrompt/ChatReferences.tsx +7 -7
  421. package/src/components/ChatPrompt/ChatStatus.tsx +123 -0
  422. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
  423. package/src/components/ChatPrompt/index.ts +3 -0
  424. package/src/components/ChatThread/Anchor.stories.tsx +95 -0
  425. package/src/components/ChatThread/ChatThread.stories.tsx +65 -75
  426. package/src/components/ChatThread/ChatThread.tsx +46 -29
  427. package/src/components/ChatThread/DEBUG.md +41 -0
  428. package/src/components/ChatThread/MarkdownStream.stories.tsx +281 -0
  429. package/src/components/ChatThread/registry.tsx +148 -65
  430. package/src/components/ChatThread/sync.test.ts +186 -28
  431. package/src/components/ChatThread/sync.ts +93 -103
  432. package/src/components/ChatThread/testing/reasoning.md +25 -0
  433. package/src/components/ChatThread/testing/thinking.md +21 -0
  434. package/src/components/ChatThread/testing/thread-1.md +30 -0
  435. package/src/components/ChatThread/testing/{thread.md → thread-2.md} +19 -0
  436. package/src/components/ChatThread/testing/thread-widgets.md +79 -0
  437. package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
  438. package/src/components/ChatThread/tool-widget-state.ts +48 -0
  439. package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
  440. package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
  441. package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
  442. package/src/components/ChatThread/widgets/ReferenceWidget.ts +33 -0
  443. package/src/components/ChatThread/widgets/SelectWidget.ts +39 -0
  444. package/src/components/ChatThread/widgets/StatsWidget.ts +31 -0
  445. package/src/components/ChatThread/widgets/StatusWidget.ts +53 -0
  446. package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
  447. package/src/components/ChatThread/widgets/SummaryWidget.tsx +27 -0
  448. package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +55 -0
  449. package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
  450. package/src/components/ChatThread/widgets/defaults.ts +8 -0
  451. package/src/components/ChatThread/widgets/index.ts +13 -0
  452. package/src/components/ProcessTree/ProcessTree.stories.tsx +83 -0
  453. package/src/components/ProcessTree/ProcessTree.tsx +119 -0
  454. package/src/components/ProcessTree/index.ts +5 -0
  455. package/src/components/TaskList/TaskList.stories.tsx +44 -0
  456. package/src/components/TaskList/TaskList.tsx +45 -0
  457. package/src/components/{Typewriter → TaskList}/index.ts +1 -1
  458. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +5 -9
  459. package/src/components/TemplateEditor/TemplateEditor.tsx +51 -43
  460. package/src/components/TemplateEditor/TemplateForm.stories.tsx +8 -10
  461. package/src/components/TemplateEditor/TemplateForm.tsx +52 -73
  462. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +1 -1
  463. package/src/components/ToolBlock/ToolBlock.tsx +20 -19
  464. package/src/components/Toolbox/Toolbox.stories.tsx +7 -8
  465. package/src/components/Toolbox/Toolbox.tsx +66 -59
  466. package/src/components/index.ts +6 -0
  467. package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
  468. package/src/containers/AgentArticle/AgentArticle.tsx +204 -0
  469. package/src/containers/AgentArticle/index.ts +5 -0
  470. package/src/containers/AgentProperties/AgentProperties.stories.tsx +101 -0
  471. package/src/containers/AgentProperties/AgentProperties.tsx +127 -0
  472. package/src/containers/AgentProperties/index.ts +5 -0
  473. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +7 -8
  474. package/src/containers/BlueprintArticle/index.ts +1 -3
  475. package/src/containers/ChatCompanion/ChatCompanion.tsx +27 -123
  476. package/src/containers/ChatCompanion/index.ts +1 -3
  477. package/src/containers/ChatContainer/ChatContainer.tsx +62 -24
  478. package/src/containers/ChatContainer/index.ts +1 -3
  479. package/src/containers/ChatDialog/ChatDialog.tsx +8 -14
  480. package/src/containers/ChatDialog/index.ts +1 -3
  481. package/src/containers/PlanArticle/PlanArticle.tsx +33 -0
  482. package/src/containers/PlanArticle/index.ts +5 -0
  483. package/src/containers/RoutineArticle/RoutineArticle.stories.tsx +75 -0
  484. package/src/containers/RoutineArticle/RoutineArticle.tsx +109 -0
  485. package/src/containers/RoutineArticle/index.ts +5 -0
  486. package/src/containers/RoutineList/RoutineList.stories.tsx +130 -0
  487. package/src/containers/RoutineList/RoutineList.tsx +50 -0
  488. package/src/containers/RoutineList/index.ts +5 -0
  489. package/src/containers/TracePanel/TracePanel.stories.tsx +285 -0
  490. package/src/containers/TracePanel/TracePanel.tsx +167 -0
  491. package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
  492. package/src/containers/TracePanel/dxn-extractor.ts +178 -0
  493. package/src/containers/TracePanel/execution-graph.test.ts +382 -0
  494. package/src/containers/TracePanel/execution-graph.ts +621 -0
  495. package/src/containers/TracePanel/index.ts +9 -0
  496. package/src/containers/TracePanel/testing/index.ts +6 -0
  497. package/src/containers/TracePanel/testing/simulated-agent.ts +114 -0
  498. package/src/containers/TracePanel/testing/snapshot-playback.ts +45 -0
  499. package/src/containers/TriggerStatus/TriggerStatus.tsx +41 -62
  500. package/src/containers/TriggerStatus/index.ts +1 -3
  501. package/src/containers/index.ts +6 -4
  502. package/src/extensions/index.ts +5 -0
  503. package/src/extensions/prompt-extension.ts +111 -0
  504. package/src/{queue-logger.ts → feed-logger.ts} +45 -24
  505. package/src/hooks/index.ts +2 -0
  506. package/src/hooks/useBlueprintRegistry.ts +5 -4
  507. package/src/hooks/useChatKeymap.ts +52 -0
  508. package/src/hooks/useChatProcessor.ts +36 -24
  509. package/src/hooks/useChatServices.ts +5 -26
  510. package/src/hooks/useChatToolbarActions.ts +9 -9
  511. package/src/hooks/useContextBinder.ts +19 -8
  512. package/src/hooks/useContextObjects.ts +10 -6
  513. package/src/hooks/useDebug.ts +38 -0
  514. package/src/hooks/useFilteredTypes.ts +1 -1
  515. package/src/hooks/usePresets.ts +2 -1
  516. package/src/index.ts +0 -6
  517. package/src/meta.ts +6 -3
  518. package/src/operations/create-chat.ts +78 -0
  519. package/src/operations/ensure-companion-chat.ts +63 -0
  520. package/src/operations/index.ts +15 -0
  521. package/src/operations/on-create-space.ts +24 -0
  522. package/src/operations/prompt.test.ts +77 -0
  523. package/src/operations/resolve-navigation-targets.ts +26 -0
  524. package/src/operations/run-prompt-in-new-chat.ts +112 -0
  525. package/src/operations/set-current-chat.ts +49 -0
  526. package/src/operations/update-chat-name.ts +61 -0
  527. package/src/plugin.ts +11 -0
  528. package/src/processor/index.ts +0 -1
  529. package/src/processor/presets.ts +11 -3
  530. package/src/processor/processor.test.ts +18 -51
  531. package/src/processor/processor.ts +219 -163
  532. package/src/testing/data/trace-timeline.dx.json +4657 -0
  533. package/src/testing/index.ts +1 -0
  534. package/src/testing/test-generator.test.ts +70 -0
  535. package/src/testing/test-generator.ts +214 -192
  536. package/src/testing/test-sequence.ts +3 -3
  537. package/src/testing/test-services.ts +1 -1
  538. package/src/testing/test-trace.ts +20 -0
  539. package/src/testing/trace-timeline.conversations.json +1 -0
  540. package/src/testing/trace-timeline.test.ts +250 -0
  541. package/src/translations.ts +154 -107
  542. package/src/types/Assistant.ts +16 -18
  543. package/src/types/AssistantCapabilities.ts +35 -0
  544. package/src/types/AssistantEvents.ts +11 -0
  545. package/src/types/AssistantOperation.ts +128 -0
  546. package/src/types/Settings.ts +76 -0
  547. package/src/types/index.ts +5 -4
  548. package/src/types/service.ts +3 -3
  549. package/dist/lib/browser/AssistantSettings-2LFAG5OQ.mjs +0 -93
  550. package/dist/lib/browser/AssistantSettings-2LFAG5OQ.mjs.map +0 -7
  551. package/dist/lib/browser/BlueprintArticle-CCS25MNW.mjs.map +0 -7
  552. package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs +0 -202
  553. package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs.map +0 -7
  554. package/dist/lib/browser/ChatContainer-ZGRSZ5EU.mjs +0 -12
  555. package/dist/lib/browser/ChatDialog-AET7GVIB.mjs.map +0 -7
  556. package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs +0 -91
  557. package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs.map +0 -7
  558. package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs +0 -194
  559. package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs.map +0 -7
  560. package/dist/lib/browser/PromptArticle-USQO4WX6.mjs +0 -71
  561. package/dist/lib/browser/PromptArticle-USQO4WX6.mjs.map +0 -7
  562. package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs +0 -122
  563. package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs.map +0 -7
  564. package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs +0 -234
  565. package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs.map +0 -7
  566. package/dist/lib/browser/blueprint-definition-5LQNBZON.mjs +0 -35
  567. package/dist/lib/browser/blueprint-definition-5LQNBZON.mjs.map +0 -7
  568. package/dist/lib/browser/chunk-7DXYAXLZ.mjs +0 -230
  569. package/dist/lib/browser/chunk-7DXYAXLZ.mjs.map +0 -7
  570. package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +0 -7
  571. package/dist/lib/browser/chunk-JYY5AD65.mjs +0 -286
  572. package/dist/lib/browser/chunk-JYY5AD65.mjs.map +0 -7
  573. package/dist/lib/browser/chunk-LEXIQDXZ.mjs +0 -26
  574. package/dist/lib/browser/chunk-LEXIQDXZ.mjs.map +0 -7
  575. package/dist/lib/browser/chunk-RU4G5NY4.mjs +0 -69
  576. package/dist/lib/browser/chunk-RU4G5NY4.mjs.map +0 -7
  577. package/dist/lib/browser/chunk-UUA6GNGG.mjs +0 -2125
  578. package/dist/lib/browser/chunk-UUA6GNGG.mjs.map +0 -7
  579. package/dist/lib/browser/index.mjs +0 -386
  580. package/dist/lib/browser/index.mjs.map +0 -7
  581. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +0 -7
  582. package/dist/lib/browser/meta.json +0 -1
  583. package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs +0 -136
  584. package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs.map +0 -7
  585. package/dist/lib/browser/react-surface-KYQSZO2I.mjs +0 -144
  586. package/dist/lib/browser/react-surface-KYQSZO2I.mjs.map +0 -7
  587. package/dist/lib/browser/repair-ZFZWZALX.mjs +0 -52
  588. package/dist/lib/browser/repair-ZFZWZALX.mjs.map +0 -7
  589. package/dist/lib/browser/settings-YREVQAZ5.mjs.map +0 -7
  590. package/dist/lib/browser/state-MPG42ZO4.mjs +0 -26
  591. package/dist/lib/browser/state-MPG42ZO4.mjs.map +0 -7
  592. package/dist/lib/browser/toolkit-XRSBBB3L.mjs +0 -16
  593. package/dist/lib/browser/toolkit-XRSBBB3L.mjs.map +0 -7
  594. package/dist/lib/browser/types/index.mjs +0 -23
  595. package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs +0 -94
  596. package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs.map +0 -7
  597. package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs +0 -37
  598. package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs.map +0 -7
  599. package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs +0 -203
  600. package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs.map +0 -7
  601. package/dist/lib/node-esm/ChatContainer-IFHDIFJH.mjs +0 -13
  602. package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs +0 -86
  603. package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs.map +0 -7
  604. package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs +0 -92
  605. package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs.map +0 -7
  606. package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs +0 -195
  607. package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs.map +0 -7
  608. package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs +0 -72
  609. package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs.map +0 -7
  610. package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs +0 -123
  611. package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs.map +0 -7
  612. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +0 -23
  613. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +0 -7
  614. package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs +0 -235
  615. package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs.map +0 -7
  616. package/dist/lib/node-esm/blueprint-definition-CMJWGGJO.mjs +0 -36
  617. package/dist/lib/node-esm/blueprint-definition-CMJWGGJO.mjs.map +0 -7
  618. package/dist/lib/node-esm/blueprints/index.mjs +0 -9
  619. package/dist/lib/node-esm/chunk-3QBVFAYO.mjs +0 -28
  620. package/dist/lib/node-esm/chunk-3QBVFAYO.mjs.map +0 -7
  621. package/dist/lib/node-esm/chunk-6NCLKQCL.mjs +0 -70
  622. package/dist/lib/node-esm/chunk-6NCLKQCL.mjs.map +0 -7
  623. package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs +0 -2126
  624. package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs.map +0 -7
  625. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  626. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  627. package/dist/lib/node-esm/chunk-JMBYVUD6.mjs +0 -288
  628. package/dist/lib/node-esm/chunk-JMBYVUD6.mjs.map +0 -7
  629. package/dist/lib/node-esm/chunk-MWYYLALM.mjs +0 -231
  630. package/dist/lib/node-esm/chunk-MWYYLALM.mjs.map +0 -7
  631. package/dist/lib/node-esm/chunk-POWB2BPC.mjs +0 -25
  632. package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +0 -7
  633. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +0 -22
  634. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +0 -7
  635. package/dist/lib/node-esm/index.mjs +0 -387
  636. package/dist/lib/node-esm/index.mjs.map +0 -7
  637. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +0 -21
  638. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +0 -7
  639. package/dist/lib/node-esm/meta.json +0 -1
  640. package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs +0 -137
  641. package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs.map +0 -7
  642. package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs +0 -145
  643. package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs.map +0 -7
  644. package/dist/lib/node-esm/repair-LXFVOK4B.mjs +0 -53
  645. package/dist/lib/node-esm/repair-LXFVOK4B.mjs.map +0 -7
  646. package/dist/lib/node-esm/settings-N452OW6Y.mjs +0 -34
  647. package/dist/lib/node-esm/settings-N452OW6Y.mjs.map +0 -7
  648. package/dist/lib/node-esm/state-WHZFKIEL.mjs +0 -27
  649. package/dist/lib/node-esm/state-WHZFKIEL.mjs.map +0 -7
  650. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs +0 -17
  651. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs.map +0 -7
  652. package/dist/lib/node-esm/types/index.mjs +0 -24
  653. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +0 -1
  654. package/dist/types/src/capabilities/ai-service/index.d.ts +0 -3
  655. package/dist/types/src/capabilities/ai-service/index.d.ts.map +0 -1
  656. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
  657. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
  658. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
  659. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -6
  660. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
  661. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
  662. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
  663. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +0 -1
  664. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +0 -3
  665. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +0 -1
  666. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +0 -3
  667. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +0 -1
  668. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +0 -13
  669. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +0 -1
  670. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  671. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  672. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  673. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  674. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  675. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  676. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  677. package/dist/types/src/capabilities/repair/index.d.ts +0 -3
  678. package/dist/types/src/capabilities/repair/index.d.ts.map +0 -1
  679. package/dist/types/src/capabilities/repair/repair.d.ts.map +0 -1
  680. package/dist/types/src/capabilities/settings/index.d.ts +0 -15
  681. package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
  682. package/dist/types/src/capabilities/settings/settings.d.ts +0 -18
  683. package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
  684. package/dist/types/src/capabilities/state/index.d.ts +0 -11
  685. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  686. package/dist/types/src/capabilities/state/state.d.ts +0 -13
  687. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  688. package/dist/types/src/capabilities/toolkit/index.d.ts +0 -3
  689. package/dist/types/src/capabilities/toolkit/index.d.ts.map +0 -1
  690. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +0 -1
  691. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +0 -7
  692. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +0 -1
  693. package/dist/types/src/components/ChatProgress/index.d.ts +0 -2
  694. package/dist/types/src/components/ChatProgress/index.d.ts.map +0 -1
  695. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +0 -12
  696. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +0 -1
  697. package/dist/types/src/components/Typewriter/Typewriter.d.ts +0 -11
  698. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +0 -1
  699. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +0 -7
  700. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +0 -1
  701. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +0 -5
  702. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +0 -1
  703. package/dist/types/src/components/Typewriter/index.d.ts +0 -2
  704. package/dist/types/src/components/Typewriter/index.d.ts.map +0 -1
  705. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts +0 -8
  706. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts.map +0 -1
  707. package/dist/types/src/containers/AssistantSettings/index.d.ts +0 -3
  708. package/dist/types/src/containers/AssistantSettings/index.d.ts.map +0 -1
  709. package/dist/types/src/containers/Project/ProjectArticle.d.ts +0 -7
  710. package/dist/types/src/containers/Project/ProjectArticle.d.ts.map +0 -1
  711. package/dist/types/src/containers/Project/ProjectSettings.d.ts +0 -6
  712. package/dist/types/src/containers/Project/ProjectSettings.d.ts.map +0 -1
  713. package/dist/types/src/containers/Project/index.d.ts +0 -7
  714. package/dist/types/src/containers/Project/index.d.ts.map +0 -1
  715. package/dist/types/src/containers/Project/triggers.d.ts +0 -6
  716. package/dist/types/src/containers/Project/triggers.d.ts.map +0 -1
  717. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +0 -6
  718. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +0 -1
  719. package/dist/types/src/containers/PromptArticle/index.d.ts +0 -3
  720. package/dist/types/src/containers/PromptArticle/index.d.ts.map +0 -1
  721. package/dist/types/src/processor/update-name.d.ts +0 -10
  722. package/dist/types/src/processor/update-name.d.ts.map +0 -1
  723. package/dist/types/src/queue-logger.d.ts +0 -11
  724. package/dist/types/src/queue-logger.d.ts.map +0 -1
  725. package/dist/types/src/types/AssistantAction.d.ts +0 -93
  726. package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
  727. package/dist/types/src/types/capabilities.d.ts +0 -33
  728. package/dist/types/src/types/capabilities.d.ts.map +0 -1
  729. package/dist/types/src/types/defs.d.ts +0 -2
  730. package/dist/types/src/types/defs.d.ts.map +0 -1
  731. package/dist/types/src/types/events.d.ts +0 -5
  732. package/dist/types/src/types/events.d.ts.map +0 -1
  733. package/src/AssistantPlugin.tsx +0 -172
  734. package/src/blueprints/assistant/blueprint.conversations.json +0 -1
  735. package/src/capabilities/ai-service/index.ts +0 -7
  736. package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -198
  737. package/src/capabilities/app-graph-builder/index.ts +0 -7
  738. package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -50
  739. package/src/capabilities/blueprint-definition/index.ts +0 -7
  740. package/src/capabilities/edge-model-resolver/index.ts +0 -7
  741. package/src/capabilities/local-model-resolver/index.ts +0 -7
  742. package/src/capabilities/operation-resolver/index.ts +0 -7
  743. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -121
  744. package/src/capabilities/react-surface/index.ts +0 -7
  745. package/src/capabilities/react-surface/react-surface.tsx +0 -121
  746. package/src/capabilities/repair/index.ts +0 -7
  747. package/src/capabilities/repair/repair.ts +0 -69
  748. package/src/capabilities/settings/index.ts +0 -7
  749. package/src/capabilities/state/index.ts +0 -7
  750. package/src/capabilities/toolkit/index.ts +0 -7
  751. package/src/components/ChatProgress/ChatProgress.tsx +0 -53
  752. package/src/components/ChatProgress/index.ts +0 -5
  753. package/src/components/Typewriter/AssistantToolbar.tsx +0 -161
  754. package/src/components/Typewriter/Typewriter.stories.tsx +0 -86
  755. package/src/components/Typewriter/Typewriter.tsx +0 -54
  756. package/src/components/Typewriter/assistant-extension.tsx +0 -142
  757. package/src/containers/AssistantSettings/AssistantSettings.tsx +0 -120
  758. package/src/containers/AssistantSettings/index.ts +0 -7
  759. package/src/containers/Project/ProjectArticle.tsx +0 -117
  760. package/src/containers/Project/ProjectSettings.tsx +0 -118
  761. package/src/containers/Project/index.ts +0 -16
  762. package/src/containers/Project/triggers.ts +0 -131
  763. package/src/containers/PromptArticle/PromptArticle.tsx +0 -59
  764. package/src/containers/PromptArticle/index.ts +0 -7
  765. package/src/processor/update-name.ts +0 -58
  766. package/src/types/AssistantAction.ts +0 -76
  767. package/src/types/capabilities.ts +0 -27
  768. package/src/types/defs.ts +0 -5
  769. package/src/types/events.ts +0 -11
  770. /package/dist/lib/{browser/ChatContainer-ZGRSZ5EU.mjs.map → neutral/ChatContainer-VYVJYPPN.mjs.map} +0 -0
  771. /package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
  772. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
  773. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
  774. /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
  775. /package/dist/lib/{node-esm/ChatContainer-IFHDIFJH.mjs.map → neutral/meta.mjs.map} +0 -0
  776. /package/dist/lib/{node-esm/blueprints → neutral/operations}/index.mjs.map +0 -0
  777. /package/dist/lib/{node-esm → neutral}/types/index.mjs.map +0 -0
  778. /package/dist/types/src/capabilities/{ai-service/ai-service.d.ts → ai-service.d.ts} +0 -0
  779. /package/dist/types/src/capabilities/{app-graph-builder/app-graph-builder.d.ts → app-graph-builder.d.ts} +0 -0
  780. /package/dist/types/src/capabilities/{edge-model-resolver/edge-model-resolver.d.ts → edge-model-resolver.d.ts} +0 -0
  781. /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
  782. /package/dist/types/src/capabilities/{toolkit/toolkit.d.ts → toolkit.d.ts} +0 -0
  783. /package/src/capabilities/{ai-service/ai-service.ts → ai-service.ts} +0 -0
  784. /package/src/capabilities/{edge-model-resolver/edge-model-resolver.ts → edge-model-resolver.ts} +0 -0
@@ -0,0 +1,2297 @@
1
+ import "../chunk-J5LGTIGS.mjs";
2
+
3
+ // src/components/index.ts
4
+ import { lazy } from "react";
5
+
6
+ // src/components/Chat/Chat.tsx
7
+ import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
8
+ import * as Array from "effect/Array";
9
+ import * as Option4 from "effect/Option";
10
+ import React15, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo5, useRef as useRef3, useState as useState7 } from "react";
11
+ import { Agent } from "@dxos/assistant-toolkit";
12
+ import { Event } from "@dxos/async";
13
+ import { Filter as Filter2, Obj as Obj3, Query } from "@dxos/echo";
14
+ import { useQuery as useQuery2 } from "@dxos/react-client/echo";
15
+ import { useIdentity } from "@dxos/react-client/halo";
16
+ import { Menu } from "@dxos/react-ui-menu";
17
+ import { Message as Message2 } from "@dxos/types";
18
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
19
+ import { useChatKeymapExtensions as useChatKeymapExtensions2, useChatToolbarActions, useDebug } from "#hooks";
20
+
21
+ // src/components/ChatPrompt/ChatActions.tsx
22
+ import React from "react";
23
+ import { IconButton, useTranslation } from "@dxos/react-ui";
24
+ import { mx } from "@dxos/ui-theme";
25
+ import { meta } from "#meta";
26
+ var ChatActions = ({ classNames, children, microphone, recording, processing, debug, onEvent }) => {
27
+ const { t } = useTranslation(meta.id);
28
+ return /* @__PURE__ */ React.createElement("div", {
29
+ className: mx("flex items-center", classNames)
30
+ }, children, microphone && /* @__PURE__ */ React.createElement(IconButton, {
31
+ disabled: !processing,
32
+ classNames: mx(recording && "bg-primary-500"),
33
+ variant: "ghost",
34
+ icon: "ph--microphone--regular",
35
+ iconOnly: true,
36
+ noTooltip: true,
37
+ label: t("microphone.button"),
38
+ onMouseDown: () => onEvent?.({
39
+ type: "record-start"
40
+ }),
41
+ onMouseUp: () => onEvent?.({
42
+ type: "record-stop"
43
+ }),
44
+ onTouchStart: () => onEvent?.({
45
+ type: "record-start"
46
+ }),
47
+ onTouchEnd: () => onEvent?.({
48
+ type: "record-stop"
49
+ })
50
+ }), debug && /* @__PURE__ */ React.createElement(IconButton, {
51
+ variant: "ghost",
52
+ icon: "ph--wrench--regular",
53
+ iconOnly: true,
54
+ label: t("debug.button"),
55
+ onClick: () => onEvent?.({
56
+ type: "toggle-debug"
57
+ })
58
+ }), /* @__PURE__ */ React.createElement(IconButton, {
59
+ disabled: !processing,
60
+ variant: "ghost",
61
+ icon: "ph--x--regular",
62
+ iconOnly: true,
63
+ label: t("cancel-processing.button"),
64
+ onClick: () => onEvent?.({
65
+ type: "cancel"
66
+ })
67
+ }));
68
+ };
69
+
70
+ // src/components/ChatPrompt/ChatMcpErrors.tsx
71
+ import { useAtomValue } from "@effect-atom/atom-react";
72
+ import React2, { useCallback } from "react";
73
+ import { Message, useTranslation as useTranslation2 } from "@dxos/react-ui";
74
+ import { meta as meta2 } from "#meta";
75
+ var ChatMcpErrors = ({ classNames, processor }) => {
76
+ const { t } = useTranslation2(meta2.id);
77
+ const errors = useAtomValue(processor.mcpErrors);
78
+ const handleDismiss = useCallback(() => {
79
+ processor.dismissMcpErrors();
80
+ }, [
81
+ processor
82
+ ]);
83
+ if (errors.length === 0) {
84
+ return null;
85
+ }
86
+ return /* @__PURE__ */ React2.createElement(Message.Root, {
87
+ classNames: [
88
+ "m-1",
89
+ classNames
90
+ ],
91
+ valence: "warning"
92
+ }, /* @__PURE__ */ React2.createElement(Message.Title, {
93
+ onClose: handleDismiss
94
+ }, t("mcp-server-error.label")), /* @__PURE__ */ React2.createElement(Message.Content, {
95
+ asChild: true
96
+ }, /* @__PURE__ */ React2.createElement("ul", {
97
+ className: "flex flex-col gap-0.5 text-sm"
98
+ }, errors.map((error) => /* @__PURE__ */ React2.createElement("li", {
99
+ key: `${error.url}::${error.protocol}`,
100
+ className: "truncate"
101
+ }, /* @__PURE__ */ React2.createElement("span", {
102
+ className: "font-mono"
103
+ }, error.url), " \u2014 ", /* @__PURE__ */ React2.createElement("span", null, error.message))))));
104
+ };
105
+
106
+ // src/components/ChatPrompt/ChatOptions.tsx
107
+ import * as Option from "effect/Option";
108
+ import React3, { useCallback as useCallback2, useMemo, useState } from "react";
109
+ import { McpServer } from "@dxos/assistant-toolkit";
110
+ import { Annotation, Filter, Obj, Type } from "@dxos/echo";
111
+ import { useObject, useQuery } from "@dxos/react-client/echo";
112
+ import { IconButton as IconButton2, Input, Popover, Select, useTranslation as useTranslation3 } from "@dxos/react-ui";
113
+ import { Listbox } from "@dxos/react-ui-list";
114
+ import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
115
+ import { Tabs } from "@dxos/react-ui-tabs";
116
+ import { getStyles, mx as mx2 } from "@dxos/ui-theme";
117
+ import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
118
+ import { meta as meta3 } from "#meta";
119
+ import { Assistant } from "#types";
120
+ var styles = {
121
+ panel: "w-[calc(100dvw-.5rem)] sm:w-max max-w-document-width",
122
+ toolbar: "p-0! gap-0! border-t border-separator"
123
+ };
124
+ var ChatOptions = ({ chat, db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
125
+ const { t } = useTranslation3(meta3.id);
126
+ return /* @__PURE__ */ React3.createElement("div", {
127
+ className: "flex"
128
+ }, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
129
+ asChild: true
130
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
131
+ variant: "ghost",
132
+ icon: "ph--plus--regular",
133
+ iconOnly: true,
134
+ label: t("context-objects.button")
135
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
136
+ side: "top",
137
+ classNames: styles.panel
138
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
139
+ db,
140
+ context
141
+ })), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
142
+ asChild: true
143
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
144
+ variant: "ghost",
145
+ icon: "ph--sliders-horizontal--regular",
146
+ iconOnly: true,
147
+ label: t("context-settings.button")
148
+ })), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
149
+ side: "top",
150
+ classNames: styles.panel
151
+ }, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(Tabs.Root, {
152
+ classNames: "flex",
153
+ orientation: "horizontal",
154
+ defaultValue: "view",
155
+ defaultActivePart: "list",
156
+ tabIndex: -1
157
+ }, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
158
+ classNames: mx2("grid grid-rows-[1fr_40px] w-full")
159
+ }, /* @__PURE__ */ React3.createElement(Tabs.Panel, {
160
+ tabIndex: -1,
161
+ classNames: "dx-focus-ring-inset overflow-hidden",
162
+ value: "view"
163
+ }, /* @__PURE__ */ React3.createElement(ViewPanel, {
164
+ chat
165
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
166
+ tabIndex: -1,
167
+ classNames: "dx-focus-ring-inset overflow-hidden",
168
+ value: "blueprints"
169
+ }, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
170
+ blueprintRegistry,
171
+ db,
172
+ context
173
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
174
+ tabIndex: -1,
175
+ classNames: "dx-focus-ring-inset overflow-hidden",
176
+ value: "mcp-servers"
177
+ }, /* @__PURE__ */ React3.createElement(McpServersPanel, {
178
+ db
179
+ })), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
180
+ tabIndex: -1,
181
+ classNames: "dx-focus-ring-inset overflow-hidden",
182
+ value: "model"
183
+ }, /* @__PURE__ */ React3.createElement(ModelsPanel, {
184
+ presets,
185
+ preset,
186
+ onPresetChange
187
+ })), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
188
+ classNames: [
189
+ styles.toolbar
190
+ ]
191
+ }, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
192
+ value: "view",
193
+ icon: "ph--eye--regular",
194
+ label: t("chat-view.title")
195
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
196
+ value: "blueprints",
197
+ icon: "ph--blueprint--regular",
198
+ label: t("options.blueprints.title")
199
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
200
+ value: "mcp-servers",
201
+ icon: "ph--plugs-connected--regular",
202
+ label: t("options.mcp.title")
203
+ }), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
204
+ value: "model",
205
+ icon: "ph--cpu--regular",
206
+ label: t("options.chat-model.title")
207
+ }))))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
208
+ };
209
+ var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
210
+ const { t } = useTranslation3(meta3.id);
211
+ const blueprints = useBlueprints({
212
+ blueprintRegistry,
213
+ db
214
+ });
215
+ const activeBlueprints = useActiveBlueprints({
216
+ context
217
+ });
218
+ const { onUpdateBlueprint } = useBlueprintHandlers({
219
+ db,
220
+ context,
221
+ blueprintRegistry
222
+ });
223
+ const { results, handleSearch } = useSearchListResults({
224
+ items: blueprints,
225
+ extract: (blueprint) => blueprint.name
226
+ });
227
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, {
228
+ onSearch: handleSearch
229
+ }, /* @__PURE__ */ React3.createElement(SearchList.Content, {
230
+ classNames: "flex flex-col"
231
+ }, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.map((blueprint) => {
232
+ const isActive = activeBlueprints.has(blueprint.key);
233
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
234
+ classNames: "flex items-center overflow-hidden",
235
+ key: blueprint.key,
236
+ value: blueprint.key,
237
+ label: blueprint.name,
238
+ checked: isActive,
239
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
240
+ });
241
+ })), /* @__PURE__ */ React3.createElement(SearchList.Input, {
242
+ placeholder: t("search.placeholder"),
243
+ classNames: "border-t border-separator",
244
+ autoFocus: true
245
+ })));
246
+ };
247
+ var ViewPanel = ({ chat }) => {
248
+ const { t } = useTranslation3(meta3.id);
249
+ const [view, setView] = useObject(chat, "view");
250
+ const value2 = view ?? "normal";
251
+ return /* @__PURE__ */ React3.createElement(Listbox.Root, {
252
+ value: value2,
253
+ onValueChange: setView,
254
+ autoFocus: true
255
+ }, Assistant.ChatViews.map((view2) => /* @__PURE__ */ React3.createElement(Listbox.Option, {
256
+ key: view2,
257
+ value: view2
258
+ }, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, t(`chat-view.${view2}.label`, {
259
+ defaultValue: view2
260
+ })), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null))));
261
+ };
262
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
263
+ return /* @__PURE__ */ React3.createElement(Listbox.Root, {
264
+ value: preset,
265
+ onValueChange: onPresetChange,
266
+ autoFocus: true
267
+ }, presets?.map(({ id, label }) => {
268
+ return /* @__PURE__ */ React3.createElement(Listbox.Option, {
269
+ key: id,
270
+ value: id
271
+ }, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null));
272
+ }));
273
+ };
274
+ var McpServersPanel = ({ db }) => {
275
+ const { t } = useTranslation3(meta3.id);
276
+ const servers = useQuery(db, Filter.type(McpServer.McpServer));
277
+ const [adding, setAdding] = useState(false);
278
+ const handleAdd = useCallback2((name, url, protocol, apiKey) => {
279
+ db.add(Obj.make(McpServer.McpServer, {
280
+ name,
281
+ url,
282
+ protocol,
283
+ apiKey,
284
+ enabled: true
285
+ }));
286
+ setAdding(false);
287
+ }, [
288
+ db
289
+ ]);
290
+ const handleRemove = useCallback2((server) => {
291
+ db.remove(server);
292
+ }, [
293
+ db
294
+ ]);
295
+ return /* @__PURE__ */ React3.createElement("div", {
296
+ className: "p-form-chrome"
297
+ }, servers.map((server) => /* @__PURE__ */ React3.createElement(McpServerRow, {
298
+ key: server.id,
299
+ server,
300
+ onRemove: handleRemove
301
+ })), adding ? /* @__PURE__ */ React3.createElement(McpServerForm, {
302
+ onSubmit: handleAdd,
303
+ onCancel: () => setAdding(false)
304
+ }) : /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement(IconButton2, {
305
+ variant: "ghost",
306
+ icon: "ph--plus--regular",
307
+ label: t("mcp-server-add.label"),
308
+ onClick: () => setAdding(true)
309
+ })));
310
+ };
311
+ var McpServerRow = ({ server, onRemove }) => {
312
+ const { t } = useTranslation3(meta3.id);
313
+ const [enabled, setEnabled] = useObject(server, "enabled");
314
+ return /* @__PURE__ */ React3.createElement("div", {
315
+ className: "flex items-center gap-2 px-form-chrome"
316
+ }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
317
+ srOnly: true
318
+ }, server.name), /* @__PURE__ */ React3.createElement(Input.Switch, {
319
+ checked: enabled !== false,
320
+ onCheckedChange: (checked) => setEnabled(!!checked)
321
+ })), /* @__PURE__ */ React3.createElement("span", {
322
+ className: "flex-1 truncate text-sm"
323
+ }, server.name), /* @__PURE__ */ React3.createElement("span", {
324
+ className: "truncate text-xs text-description"
325
+ }, server.url), /* @__PURE__ */ React3.createElement(IconButton2, {
326
+ variant: "ghost",
327
+ icon: "ph--x--regular",
328
+ iconOnly: true,
329
+ label: t("mcp-server-remove.label"),
330
+ onClick: () => onRemove(server)
331
+ }));
332
+ };
333
+ var McpServerForm = ({ onSubmit, onCancel }) => {
334
+ const { t } = useTranslation3(meta3.id);
335
+ const [name, setName] = useState("");
336
+ const [url, setUrl] = useState("");
337
+ const [protocol, setProtocol] = useState("sse");
338
+ const [apiKey, setApiKey] = useState("");
339
+ const canSubmit = name.trim().length > 0 && url.trim().length > 0;
340
+ const handleSubmit = useCallback2(() => {
341
+ if (canSubmit) {
342
+ onSubmit(name.trim(), url.trim(), protocol, apiKey.trim() || void 0);
343
+ }
344
+ }, [
345
+ canSubmit,
346
+ name,
347
+ url,
348
+ protocol,
349
+ apiKey,
350
+ onSubmit
351
+ ]);
352
+ return /* @__PURE__ */ React3.createElement("div", {
353
+ className: "space-y-2 px-form-chrome"
354
+ }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
355
+ srOnly: true
356
+ }, t("mcp-server-name.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
357
+ placeholder: t("mcp-server-name.placeholder"),
358
+ value: name,
359
+ onChange: (event) => setName(event.target.value),
360
+ autoFocus: true
361
+ })), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
362
+ srOnly: true
363
+ }, t("mcp-server-url.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
364
+ placeholder: t("mcp-server-url.placeholder"),
365
+ value: url,
366
+ onChange: (event) => setUrl(event.target.value)
367
+ })), /* @__PURE__ */ React3.createElement(Select.Root, {
368
+ value: protocol,
369
+ onValueChange: (value2) => setProtocol(value2)
370
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
371
+ placeholder: t("mcp-server-protocol.label")
372
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
373
+ value: "sse"
374
+ }, "SSE"), /* @__PURE__ */ React3.createElement(Select.Option, {
375
+ value: "http"
376
+ }, "HTTP"))))), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
377
+ srOnly: true
378
+ }, t("mcp-server-api-key.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
379
+ type: "password",
380
+ placeholder: t("mcp-server-api-key.placeholder"),
381
+ value: apiKey,
382
+ onChange: (event) => setApiKey(event.target.value)
383
+ })), /* @__PURE__ */ React3.createElement("div", {
384
+ className: "flex gap-2"
385
+ }, /* @__PURE__ */ React3.createElement(IconButton2, {
386
+ variant: "ghost",
387
+ icon: "ph--check--regular",
388
+ iconOnly: true,
389
+ label: t("save.button"),
390
+ onClick: handleSubmit,
391
+ disabled: !canSubmit
392
+ }), /* @__PURE__ */ React3.createElement(IconButton2, {
393
+ variant: "ghost",
394
+ icon: "ph--x--regular",
395
+ iconOnly: true,
396
+ label: t("cancel.button"),
397
+ onClick: onCancel
398
+ })));
399
+ };
400
+ var ANY = "__any__";
401
+ var ObjectsPanel = ({ db, context }) => {
402
+ const { t } = useTranslation3(meta3.id);
403
+ const types = useFilteredTypes(db);
404
+ const typenames = useMemo(() => {
405
+ const typenames2 = types.map((type) => {
406
+ const typename2 = Type.getTypename(type);
407
+ return {
408
+ typename: typename2,
409
+ label: t("typename.label", {
410
+ ns: typename2,
411
+ defaultValue: typename2
412
+ })
413
+ };
414
+ });
415
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
416
+ return typenames2;
417
+ }, [
418
+ types
419
+ ]);
420
+ const [typename, setTypename] = useState(ANY);
421
+ const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
422
+ typenames
423
+ ]);
424
+ const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
425
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
426
+ db,
427
+ context
428
+ });
429
+ const { results, handleSearch } = useSearchListResults({
430
+ items: objects,
431
+ extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
432
+ });
433
+ return /* @__PURE__ */ React3.createElement(SearchList.Root, {
434
+ onSearch: handleSearch
435
+ }, /* @__PURE__ */ React3.createElement(SearchList.Content, {
436
+ classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
437
+ }, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
438
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
439
+ const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
440
+ icon: "ph--cube--regular",
441
+ hue: void 0
442
+ })));
443
+ const styles3 = hue ? getStyles(hue) : void 0;
444
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
445
+ classNames: "flex items-center overflow-hidden",
446
+ key: object.id,
447
+ value: object.id,
448
+ icon,
449
+ iconClassNames: styles3?.foreground,
450
+ label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
451
+ checked: isActive,
452
+ onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
453
+ });
454
+ }) : /* @__PURE__ */ React3.createElement(SearchList.Item, {
455
+ value: "__empty__",
456
+ label: t("no-results.message")
457
+ }))), /* @__PURE__ */ React3.createElement("div", {
458
+ className: mx2("flex flex-col", styles.toolbar)
459
+ }, /* @__PURE__ */ React3.createElement(Select.Root, {
460
+ value: typename === ANY ? void 0 : typename,
461
+ onValueChange: setTypename
462
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
463
+ placeholder: t("type-filter.placeholder")
464
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
465
+ value: ANY
466
+ }, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select.Option, {
467
+ key: typename2,
468
+ value: typename2
469
+ }, label))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
470
+ placeholder: t("search.placeholder"),
471
+ autoFocus: true
472
+ })));
473
+ };
474
+
475
+ // src/components/ChatPrompt/ChatPresets.tsx
476
+ import React4 from "react";
477
+ import { Select as Select2 } from "@dxos/react-ui";
478
+
479
+ // src/components/ChatPrompt/ChatPrompt.tsx
480
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
481
+ import * as Option3 from "effect/Option";
482
+ import React7, { useCallback as useCallback3, useEffect as useEffect2, useRef, useState as useState3 } from "react";
483
+ import { useVoiceInput } from "@dxos/plugin-transcription";
484
+ import { Input as Input2, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
485
+ import { ChatEditor } from "@dxos/react-ui-chat";
486
+ import { mx as mx5 } from "@dxos/ui-theme";
487
+ import { useChatKeymapExtensions } from "#hooks";
488
+ import { meta as meta5 } from "#meta";
489
+
490
+ // src/components/ChatPrompt/ChatReferences.tsx
491
+ import * as Option2 from "effect/Option";
492
+ import React5 from "react";
493
+ import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
494
+ import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
495
+ import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
496
+ import { useContextObjects as useContextObjects2 } from "#hooks";
497
+ import { meta as meta4 } from "#meta";
498
+ var ChatReferences = ({ classNames, context, db }) => {
499
+ const { t } = useTranslation4(meta4.id);
500
+ const { objects, onUpdateObject } = useContextObjects2({
501
+ db,
502
+ context
503
+ });
504
+ return /* @__PURE__ */ React5.createElement("ul", {
505
+ className: mx3("flex", classNames)
506
+ }, objects.map((obj) => {
507
+ const dxn = Obj2.getDXN(obj);
508
+ const typename = Obj2.getTypename(obj);
509
+ const label = Obj2.getLabel(obj) ?? (typename ? [
510
+ "object-name.placeholder",
511
+ {
512
+ ns: typename
513
+ }
514
+ ] : obj.id);
515
+ const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
516
+ icon: DEFAULT_OBJECT_ICON,
517
+ hue: void 0
518
+ })));
519
+ const styles3 = hue ? getStyles2(hue) : void 0;
520
+ return /* @__PURE__ */ React5.createElement("li", {
521
+ key: dxn.toString(),
522
+ className: "dx-tag py-0 ps-2 flex items-center gap-1",
523
+ "data-hue": "neutral"
524
+ }, /* @__PURE__ */ React5.createElement(Icon, {
525
+ icon,
526
+ size: 4,
527
+ classNames: styles3?.foreground
528
+ }), toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
529
+ icon: "ph--x--bold",
530
+ iconOnly: true,
531
+ variant: "ghost",
532
+ label: t("remove-object.label"),
533
+ classNames: "p-0 hover:bg-transparent",
534
+ size: 3,
535
+ onClick: () => onUpdateObject?.(dxn, false)
536
+ }));
537
+ }));
538
+ };
539
+ var DEFAULT_OBJECT_ICON = "ph--cube--regular";
540
+
541
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
542
+ import React6, { useEffect, useState as useState2 } from "react";
543
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
544
+ import { Spinner } from "@dxos/react-ui-sfx";
545
+ import { mx as mx4 } from "@dxos/ui-theme";
546
+ var period = 3e3;
547
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
548
+ const [init, setInit] = useState2(false);
549
+ useEffect(() => setInit(false), [
550
+ preset
551
+ ]);
552
+ useTimeout(async () => {
553
+ setInit(true);
554
+ }, period / 2, [
555
+ preset
556
+ ]);
557
+ return /* @__PURE__ */ React6.createElement("div", {
558
+ className: mx4("relative flex", classNames)
559
+ }, /* @__PURE__ */ React6.createElement(Spinner, {
560
+ duration: period,
561
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
562
+ ...props
563
+ }), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
564
+ asChild: true,
565
+ content: error.message
566
+ }, /* @__PURE__ */ React6.createElement("div", {
567
+ className: "absolute inset-0"
568
+ })));
569
+ };
570
+
571
+ // src/components/ChatPrompt/ChatPrompt.tsx
572
+ var ChatPrompt = ({ classNames, outline, chat, db, processor, event, online, placeholder, onOnlineChange, onPresetChange, settings = true, presets, preset }) => {
573
+ const { t } = useTranslation5(meta5.id);
574
+ const error = useAtomValue2(processor.error).pipe(Option3.getOrUndefined);
575
+ const streaming = useAtomValue2(processor.streaming);
576
+ const active = useAtomValue2(processor.active);
577
+ const activeRef = useDynamicRef(active);
578
+ const editorRef = useRef(null);
579
+ const [recordingState, setRecordingState] = useState3(false);
580
+ useEffect2(() => {
581
+ return event.on((ev) => {
582
+ switch (ev.type) {
583
+ case "update-prompt":
584
+ if (!editorRef.current?.getText()?.length) {
585
+ editorRef.current?.setText(ev.text);
586
+ editorRef.current?.focus();
587
+ }
588
+ break;
589
+ case "record-start":
590
+ setRecordingState(true);
591
+ break;
592
+ case "record-stop":
593
+ setRecordingState(false);
594
+ break;
595
+ }
596
+ });
597
+ }, [
598
+ event
599
+ ]);
600
+ const { recording } = useVoiceInput({
601
+ active: recordingState,
602
+ onUpdate: (text) => {
603
+ editorRef.current?.setText(text);
604
+ editorRef.current?.focus();
605
+ }
606
+ });
607
+ const extensions = useChatKeymapExtensions({
608
+ event
609
+ });
610
+ const handleSubmit = useCallback3((text) => {
611
+ if (!activeRef.current) {
612
+ event.emit({
613
+ type: "submit",
614
+ text
615
+ });
616
+ return true;
617
+ }
618
+ }, [
619
+ event
620
+ ]);
621
+ const handleEvent = useCallback3((ev) => {
622
+ event.emit(ev);
623
+ }, [
624
+ event
625
+ ]);
626
+ return /* @__PURE__ */ React7.createElement("div", {
627
+ role: "group",
628
+ className: mx5("flex flex-col w-full dx-density-fine", outline && "bg-group-surface rounded-sm! border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator", classNames)
629
+ }, /* @__PURE__ */ React7.createElement(ChatMcpErrors, {
630
+ processor
631
+ }), /* @__PURE__ */ React7.createElement("div", {
632
+ className: "flex p-2 gap-2"
633
+ }, /* @__PURE__ */ React7.createElement(ChatStatusIndicator, {
634
+ classNames: "p-1",
635
+ preset,
636
+ error,
637
+ processing: streaming
638
+ }), /* @__PURE__ */ React7.createElement(ChatEditor, {
639
+ ref: editorRef,
640
+ autoFocus: true,
641
+ lineWrapping: true,
642
+ classNames: "col-span-2 pt-0.5",
643
+ placeholder: placeholder ?? t("prompt.placeholder"),
644
+ extensions,
645
+ onSubmit: handleSubmit
646
+ })), db && settings && /* @__PURE__ */ React7.createElement("div", {
647
+ className: "flex items-center overflow-hidden p-1.5"
648
+ }, /* @__PURE__ */ React7.createElement(ChatOptions, {
649
+ chat,
650
+ db,
651
+ blueprintRegistry: processor.blueprintRegistry,
652
+ context: processor.context,
653
+ preset,
654
+ presets,
655
+ onPresetChange
656
+ }), /* @__PURE__ */ React7.createElement("div", {
657
+ className: "flex h-8 grow overflow-x-auto scrollbar-none"
658
+ }, /* @__PURE__ */ React7.createElement(ChatReferences, {
659
+ db,
660
+ context: processor.context
661
+ })), /* @__PURE__ */ React7.createElement(ChatActions, {
662
+ classNames: "col-span-2",
663
+ microphone: true,
664
+ recording,
665
+ processing: streaming,
666
+ onEvent: handleEvent
667
+ }, online !== void 0 && /* @__PURE__ */ React7.createElement(Input2.Root, null, /* @__PURE__ */ React7.createElement(Input2.Label, {
668
+ srOnly: true
669
+ }, t("online-switch.label")), /* @__PURE__ */ React7.createElement(Input2.Switch, {
670
+ classNames: "mx-1",
671
+ checked: online,
672
+ onCheckedChange: onOnlineChange
673
+ })))));
674
+ };
675
+ ChatPrompt.displayName = "Chat.Prompt";
676
+
677
+ // src/components/ChatPrompt/ChatStatus.tsx
678
+ import React8, { useEffect as useEffect3, useMemo as useMemo2, useState as useState4 } from "react";
679
+ import { ChatStatus as NaturalChatStatus, formatElapsed } from "@dxos/react-ui-chat";
680
+ import { Matrix } from "@dxos/react-ui-sfx";
681
+ import { Unit } from "@dxos/util";
682
+
683
+ // src/components/Chat/context.ts
684
+ import { createContext } from "@radix-ui/react-context";
685
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
686
+
687
+ // src/components/ChatPrompt/ChatStatus.tsx
688
+ var CHAT_STREAM_STATUS_NAME = "Chat.StreamStatus";
689
+ var TICK_MS = 1e3;
690
+ var ChatStatus = ({ classNames, icon }) => {
691
+ const { messages, requestTiming } = useChatContext(CHAT_STREAM_STATUS_NAME);
692
+ const { lastOutputTokens, sessionTotalTokens } = useMemo2(() => {
693
+ let last;
694
+ let total = 0;
695
+ for (const message of messages) {
696
+ for (const block of message.blocks) {
697
+ if (isStats(block) && block.usage) {
698
+ last = block.usage.outputTokens;
699
+ total += block.usage.totalTokens ?? 0;
700
+ }
701
+ }
702
+ }
703
+ return {
704
+ lastOutputTokens: last,
705
+ sessionTotalTokens: total
706
+ };
707
+ }, [
708
+ messages
709
+ ]);
710
+ const isRunning = requestTiming != null && requestTiming.endedAt == null;
711
+ const show = requestTiming || lastOutputTokens || sessionTotalTokens > 0;
712
+ if (!show) {
713
+ return null;
714
+ }
715
+ return /* @__PURE__ */ React8.createElement(NaturalChatStatus.Root, {
716
+ defaultRunning: false,
717
+ classNames: [
718
+ "py-2 gap-2 text-sm",
719
+ classNames
720
+ ]
721
+ }, icon && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Icon, null, /* @__PURE__ */ React8.createElement(Matrix, {
722
+ classNames: "w-5 h-5",
723
+ dotClassNames: "bg-primary-500",
724
+ dim: 4,
725
+ dotSize: 3,
726
+ count: 10,
727
+ interval: 500,
728
+ active: isRunning
729
+ })), show && /* @__PURE__ */ React8.createElement("div", {
730
+ className: "flex items-center"
731
+ }, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, /* @__PURE__ */ React8.createElement(Elapsed, {
732
+ timing: requestTiming
733
+ })), lastOutputTokens != null && /* @__PURE__ */ React8.createElement(React8.Fragment, null, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u2193 ", Unit.Thousand(lastOutputTokens).toString())), sessionTotalTokens > 0 && /* @__PURE__ */ React8.createElement(React8.Fragment, null, (requestTiming || lastOutputTokens != null) && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u03A3 ", Unit.Thousand(sessionTotalTokens).toString()))));
734
+ };
735
+ var Elapsed = ({ timing }) => {
736
+ const isRunning = timing.endedAt == null;
737
+ const [now, setNow] = useState4(Date.now());
738
+ useEffect3(() => {
739
+ if (!isRunning) {
740
+ return;
741
+ }
742
+ const id = setInterval(() => setNow(Date.now()), TICK_MS);
743
+ return () => clearInterval(id);
744
+ }, [
745
+ isRunning
746
+ ]);
747
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, formatElapsed((timing.endedAt ?? now) - timing.startedAt));
748
+ };
749
+ var isStats = (block) => block._tag === "stats";
750
+
751
+ // src/components/ChatThread/ChatThread.tsx
752
+ import React13, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo4, useState as useState6 } from "react";
753
+ import { PublicKey } from "@dxos/keys";
754
+ import { setRef } from "@dxos/react-ui";
755
+ import { MarkdownStream } from "@dxos/react-ui-markdown";
756
+ import { keyToFallback } from "@dxos/util";
757
+
758
+ // src/components/ChatThread/registry.tsx
759
+ import React12 from "react";
760
+ import { log } from "@dxos/log";
761
+ import { getXmlTextChild } from "@dxos/ui-editor";
762
+
763
+ // src/components/ChatThread/tool-widget-state.ts
764
+ var applyToolBlockToWidgetState = (context, block) => {
765
+ switch (block._tag) {
766
+ case "toolCall": {
767
+ context.updateWidget(block.toolCallId, {
768
+ blocks: [
769
+ block
770
+ ]
771
+ });
772
+ break;
773
+ }
774
+ case "toolResult": {
775
+ context.updateWidget(block.toolCallId, ({ blocks = [] } = {
776
+ blocks: []
777
+ }) => ({
778
+ blocks: [
779
+ ...blocks,
780
+ block
781
+ ]
782
+ }));
783
+ break;
784
+ }
785
+ default: {
786
+ break;
787
+ }
788
+ }
789
+ };
790
+ var rehydrateToolWidgetsFromMessages = (context, messages) => {
791
+ for (const message of messages) {
792
+ for (const block of message.blocks) {
793
+ applyToolBlockToWidgetState(context, block);
794
+ }
795
+ }
796
+ };
797
+
798
+ // src/components/ChatThread/widgets/FallbackWidget.tsx
799
+ import React9 from "react";
800
+ import { TogglePanel } from "@dxos/react-ui-components";
801
+ import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
802
+ var FallbackWidget = ({ _tag, ...props }) => {
803
+ return /* @__PURE__ */ React9.createElement(TogglePanel.Root, null, /* @__PURE__ */ React9.createElement(TogglePanel.Header, {
804
+ classNames: "bg-group-surface"
805
+ }, _tag), /* @__PURE__ */ React9.createElement(TogglePanel.Content, {
806
+ classNames: "bg-modal-surface"
807
+ }, /* @__PURE__ */ React9.createElement(TogglePanel.Viewport, null, /* @__PURE__ */ React9.createElement(JsonHighlighter, {
808
+ classNames: "p-2! text-sm",
809
+ data: props
810
+ }))));
811
+ };
812
+ FallbackWidget.displayName = "Fallback";
813
+
814
+ // src/components/ChatThread/widgets/ReasoningWidget.ts
815
+ import { WidgetType } from "@codemirror/view";
816
+ import { Domino } from "@dxos/ui";
817
+
818
+ // src/components/ChatThread/widgets/defaults.ts
819
+ var styles2 = {
820
+ padding: "my-4",
821
+ border: "border border-subdued-separator rounded-sm"
822
+ };
823
+
824
+ // src/components/ChatThread/widgets/ReasoningWidget.ts
825
+ var ReasoningWidget = class extends WidgetType {
826
+ text;
827
+ #pos;
828
+ /** The timer id last registered for this instance (may differ from the map if superseded). */
829
+ #ownedTimerId = null;
830
+ constructor(text, pos) {
831
+ super(), this.text = text;
832
+ this.#pos = pos === void 0 || pos === "" ? "reasoning" : String(pos);
833
+ }
834
+ eq(other) {
835
+ return this.text === other.text && this.#pos === other.#pos;
836
+ }
837
+ toDOM() {
838
+ return Domino.of("div").classNames(styles2.padding).append(Domino.of("div").classNames("relative overflow-hidden p-px", styles2.border).attributes({
839
+ "data-trail-container": ""
840
+ }).append(Domino.of("div").classNames("relative z-10 bg-base-surface rounded-sm text-sm text-subdued py-1").append(Domino.of("div").classNames("px-2 max-h-[5lh] overflow-y-auto dx-scrollbar-thin").text(this.text).attributes({
841
+ "data-reasoning-text": ""
842
+ })), Domino.of("div").attributes({
843
+ "data-id": this.#pos
844
+ }))).root;
845
+ }
846
+ updateDOM(dom) {
847
+ dom.querySelector("[data-reasoning-text]")?.replaceChildren(this.text);
848
+ const container = dom.querySelector("[data-trail-container]");
849
+ let trailHost = container?.querySelector("[data-id]");
850
+ if (container && !trailHost) {
851
+ trailHost = Domino.of("div").attributes({
852
+ "data-id": this.#pos
853
+ }).root;
854
+ container.append(trailHost);
855
+ }
856
+ if (trailHost?.childElementCount === 0) {
857
+ trailHost.append(...createTrailLayers());
858
+ }
859
+ this.#scheduleTrailRemoval(dom);
860
+ return true;
861
+ }
862
+ destroy(_dom) {
863
+ this.#clearOwnedTrailTimer();
864
+ }
865
+ #scheduleTrailRemoval(dom) {
866
+ const previous = trailRemovalTimers.get(this.#pos);
867
+ if (previous !== void 0) {
868
+ clearTimeout(previous);
869
+ }
870
+ const timerId = setTimeout(() => {
871
+ if (trailRemovalTimers.get(this.#pos) !== timerId) {
872
+ return;
873
+ }
874
+ trailRemovalTimers.delete(this.#pos);
875
+ this.#ownedTimerId = null;
876
+ dom.querySelector("[data-id]")?.remove();
877
+ }, TRAIL_REMOVAL_DELAY_MS);
878
+ trailRemovalTimers.set(this.#pos, timerId);
879
+ this.#ownedTimerId = timerId;
880
+ }
881
+ #clearOwnedTrailTimer() {
882
+ const active = trailRemovalTimers.get(this.#pos);
883
+ if (active !== void 0 && active === this.#ownedTimerId) {
884
+ clearTimeout(active);
885
+ trailRemovalTimers.delete(this.#pos);
886
+ }
887
+ this.#ownedTimerId = null;
888
+ }
889
+ };
890
+ var trail = [
891
+ "absolute z-0 aspect-[2/1] w-16",
892
+ "bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
893
+ "[offset-anchor:100%_50%] [offset-path:border-box]"
894
+ ];
895
+ var TRAIL_REMOVAL_DELAY_MS = 1e3;
896
+ var trailRemovalTimers = /* @__PURE__ */ new Map();
897
+ var createTrailLayers = () => [
898
+ Domino.of("div").classNames(...trail, "animate-trail").root,
899
+ Domino.of("div").classNames(...trail, "animate-trail-offset").root
900
+ ];
901
+
902
+ // src/components/ChatThread/widgets/ReferenceWidget.ts
903
+ import { WidgetType as WidgetType2 } from "@codemirror/view";
904
+ import { Domino as Domino2 } from "@dxos/ui";
905
+ var ReferenceWidget = class extends WidgetType2 {
906
+ text;
907
+ dxn;
908
+ constructor(text, dxn) {
909
+ super(), this.text = text, this.dxn = dxn;
910
+ }
911
+ eq(other) {
912
+ return this.dxn === other.dxn;
913
+ }
914
+ toDOM() {
915
+ return Domino2.of("div").classNames(styles2.padding).append(Domino2.of("dx-anchor").classNames("dx-tag--anchor").attributes({
916
+ dxn: this.dxn
917
+ }).text(this.text)).root;
918
+ }
919
+ };
920
+
921
+ // src/components/ChatThread/widgets/SelectWidget.ts
922
+ import { WidgetType as WidgetType3 } from "@codemirror/view";
923
+ import { Domino as Domino3 } from "@dxos/ui";
924
+ var SelectWidget = class extends WidgetType3 {
925
+ options;
926
+ constructor(options) {
927
+ super(), this.options = options;
928
+ }
929
+ eq(other) {
930
+ return JSON.stringify(this.options) === JSON.stringify(other.options);
931
+ }
932
+ /**
933
+ * NOTE: Container must set var based on user's identity.
934
+ */
935
+ toDOM() {
936
+ return Domino3.of("div").attributes({
937
+ role: "group"
938
+ }).classNames(styles2.padding, "flex flex-wrap gap-1").append(...this.options.map((option) => Domino3.of("button").classNames("dx-button inline-block max-w-[100cqi]").attributes({
939
+ "data-action": "submit",
940
+ "data-value": option,
941
+ "data-density": "fine"
942
+ }).text(option))).root;
943
+ }
944
+ };
945
+
946
+ // src/components/ChatThread/widgets/StatsWidget.ts
947
+ import { WidgetType as WidgetType4 } from "@codemirror/view";
948
+ import { Domino as Domino4 } from "@dxos/ui";
949
+ var StatsWidget = class extends WidgetType4 {
950
+ text;
951
+ constructor(text) {
952
+ super(), this.text = text;
953
+ }
954
+ eq(other) {
955
+ return this.text === other.text;
956
+ }
957
+ toDOM() {
958
+ return Domino4.of("div").classNames(styles2.padding, "text-sm text-placeholder").text(this.text).root;
959
+ }
960
+ updateDOM(dom) {
961
+ dom.textContent = this.text;
962
+ return true;
963
+ }
964
+ };
965
+
966
+ // src/components/ChatThread/widgets/StatusWidget.ts
967
+ import { WidgetType as WidgetType5 } from "@codemirror/view";
968
+ import { Domino as Domino5 } from "@dxos/ui";
969
+ var StatusWidget = class extends WidgetType5 {
970
+ text;
971
+ constructor(text) {
972
+ super(), this.text = text;
973
+ }
974
+ eq(other) {
975
+ return this.text === other.text;
976
+ }
977
+ toDOM() {
978
+ return Domino5.of("div").classNames(styles2.padding).append(Domino5.of("div").classNames("relative overflow-hidden rounded-sm").append(Domino5.of("div").classNames("grid grid-cols-[24px_1fr] gap-x-0.5 gap-y-0 items-start px-0.5 py-0.5 text-placeholder").append(Domino5.of("div").classNames("flex h-5 w-full shrink-0 items-center justify-center self-start").append(Domino5.of("span").classNames("block size-1.5 shrink-0 rounded-full bg-current opacity-45")), Domino5.of("div").classNames("relative min-w-0").append(Domino5.of("div").classNames("relative z-10 rounded-sm text-sm leading-5").attributes({
979
+ "data-status-text": ""
980
+ }).text(this.text))))).root;
981
+ }
982
+ updateDOM(dom) {
983
+ dom.querySelector("[data-status-text]")?.replaceChildren(this.text);
984
+ return true;
985
+ }
986
+ };
987
+
988
+ // src/components/ChatThread/widgets/SummaryWidget.tsx
989
+ import React10 from "react";
990
+ import { useTranslation as useTranslation6 } from "@dxos/react-ui";
991
+ import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
992
+ import { meta as meta6 } from "#meta";
993
+ var SummaryWidget = ({ children }) => {
994
+ const { t } = useTranslation6(meta6.id);
995
+ return /* @__PURE__ */ React10.createElement(TogglePanel2.Root, {
996
+ classNames: styles2.border
997
+ }, /* @__PURE__ */ React10.createElement(TogglePanel2.Header, {
998
+ classNames: "text-sm bg-group-surface"
999
+ }, t("summary.label")), /* @__PURE__ */ React10.createElement(TogglePanel2.Content, null, /* @__PURE__ */ React10.createElement("div", {
1000
+ className: "p-1 text-sm text-subdued"
1001
+ }, children)));
1002
+ };
1003
+
1004
+ // src/components/ChatThread/widgets/SuggestionWidget.ts
1005
+ import { WidgetType as WidgetType6 } from "@codemirror/view";
1006
+ import { Domino as Domino6, mx as mx6 } from "@dxos/ui";
1007
+ var SuggestionWidget = class extends WidgetType6 {
1008
+ text;
1009
+ constructor(text) {
1010
+ super(), this.text = text;
1011
+ }
1012
+ eq(other) {
1013
+ return this.text === other.text;
1014
+ }
1015
+ toDOM() {
1016
+ return Domino6.of("span").classNames(mx6("inline-flex max-w-[calc(100cqi-8px)] my-1 pe-2 overflow-hidden")).append(Domino6.of("button").attributes({
1017
+ "data-action": "submit",
1018
+ "data-density": "fine",
1019
+ "data-value": this.text
1020
+ }).classNames(mx6("dx-button gap-2 w-full overflow-hidden")).append(Domino6.of("dx-icon").attributes({
1021
+ icon: "ph--lightning--regular"
1022
+ }), Domino6.of("span").classNames("flex-1 truncate min-w-0").text(this.text))).root;
1023
+ }
1024
+ };
1025
+
1026
+ // src/components/ChatThread/widgets/ToolWidget.tsx
1027
+ import React11, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
1028
+ import { useTranslation as useTranslation7 } from "@dxos/react-ui";
1029
+ import { NumericTabs, TextCrawl, TogglePanel as TogglePanel3 } from "@dxos/react-ui-components";
1030
+ import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
1031
+ import { isNonNullable, safeParseJson } from "@dxos/util";
1032
+ import { meta as meta7 } from "#meta";
1033
+ var ToolWidget = ({ view, blocks = [] }) => {
1034
+ const { t } = useTranslation7(meta7.id);
1035
+ const items = useMemo3(() => {
1036
+ let lastToolCall;
1037
+ const tools = [];
1038
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
1039
+ switch (block._tag) {
1040
+ case "toolCall": {
1041
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
1042
+ return null;
1043
+ }
1044
+ const tool = tools.find((tool2) => tool2.name === block.name);
1045
+ lastToolCall = {
1046
+ tool,
1047
+ block
1048
+ };
1049
+ return {
1050
+ title: tool?.description ?? [
1051
+ t("tool-call.label"),
1052
+ block.name
1053
+ ].filter(Boolean).join(" "),
1054
+ content: {
1055
+ ...block,
1056
+ input: safeParseJson(block.input)
1057
+ }
1058
+ };
1059
+ }
1060
+ case "toolResult": {
1061
+ if (block.error) {
1062
+ return {
1063
+ title: t("tool-error.label"),
1064
+ content: block
1065
+ };
1066
+ }
1067
+ const title = lastToolCall?.tool?.description ?? [
1068
+ t("tool-result.label"),
1069
+ lastToolCall?.block.name
1070
+ ].filter(Boolean).join(" ");
1071
+ lastToolCall = void 0;
1072
+ return {
1073
+ title,
1074
+ content: {
1075
+ ...block,
1076
+ result: safeParseJson(block.result)
1077
+ }
1078
+ };
1079
+ }
1080
+ case "stats": {
1081
+ if (!lastToolCall) {
1082
+ return null;
1083
+ }
1084
+ return {
1085
+ title: t("stats.label"),
1086
+ content: block
1087
+ };
1088
+ }
1089
+ }
1090
+ }).filter(isNonNullable);
1091
+ }, [
1092
+ blocks,
1093
+ t
1094
+ ]);
1095
+ const handleChangeOpen = useCallback4(() => {
1096
+ setTimeout(() => {
1097
+ view?.requestMeasure();
1098
+ }, 1e3);
1099
+ }, [
1100
+ view
1101
+ ]);
1102
+ if (!items.length) {
1103
+ return null;
1104
+ }
1105
+ return /* @__PURE__ */ React11.createElement(ToolPanel, {
1106
+ items,
1107
+ onChangeOpen: handleChangeOpen
1108
+ });
1109
+ };
1110
+ var ToolPanel = ({ items, onChangeOpen }) => {
1111
+ const tabsRef = useRef2(null);
1112
+ const [selected, setSelected] = useState5(0);
1113
+ const [open, setOpen] = useState5(false);
1114
+ useEffect4(() => {
1115
+ setSelected((prev) => Math.min(prev, Math.max(0, items.length - 1)));
1116
+ }, [
1117
+ items.length
1118
+ ]);
1119
+ useEffect4(() => {
1120
+ onChangeOpen?.(open);
1121
+ if (open) {
1122
+ tabsRef.current?.focus();
1123
+ }
1124
+ }, [
1125
+ open,
1126
+ onChangeOpen
1127
+ ]);
1128
+ const handleSelect = useCallback4((index) => {
1129
+ setSelected(index);
1130
+ }, []);
1131
+ return /* @__PURE__ */ React11.createElement(TogglePanel3.Root, {
1132
+ open,
1133
+ onChangeOpen: setOpen
1134
+ }, /* @__PURE__ */ React11.createElement(TogglePanel3.Header, {
1135
+ classNames: "text-sm text-placeholder"
1136
+ }, /* @__PURE__ */ React11.createElement(TextCrawl, {
1137
+ key: "status-roll",
1138
+ lines: items.map((item) => item.title),
1139
+ autoAdvance: true,
1140
+ greedy: true
1141
+ })), /* @__PURE__ */ React11.createElement(TogglePanel3.Content, null, /* @__PURE__ */ React11.createElement(TogglePanel3.Viewport, {
1142
+ classNames: "grid grid-cols-[32px_1fr]"
1143
+ }, /* @__PURE__ */ React11.createElement(NumericTabs, {
1144
+ ref: tabsRef,
1145
+ classNames: "p-1",
1146
+ length: items.length,
1147
+ selected,
1148
+ onSelect: handleSelect
1149
+ }), /* @__PURE__ */ React11.createElement(JsonHighlighter2, {
1150
+ data: items[selected]?.content,
1151
+ classNames: "p-1 text-xs bg-transparent",
1152
+ replacer: {
1153
+ maxDepth: 3,
1154
+ maxArrayLen: 10,
1155
+ maxStringLen: 128
1156
+ }
1157
+ }))));
1158
+ };
1159
+
1160
+ // src/components/ChatThread/registry.tsx
1161
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1162
+ var componentRegistry = {
1163
+ //
1164
+ // Block-only (no widget — see note above).
1165
+ //
1166
+ prompt: {
1167
+ block: true
1168
+ },
1169
+ //
1170
+ // DOM Widgets
1171
+ //
1172
+ synthetic: {
1173
+ block: true,
1174
+ factory: ({ children, range }) => {
1175
+ const text = getXmlTextChild(children);
1176
+ return text ? new ReasoningWidget(text, range.from) : null;
1177
+ }
1178
+ },
1179
+ reasoning: {
1180
+ block: true,
1181
+ streaming: true,
1182
+ factory: ({ children, range }) => {
1183
+ const text = getXmlTextChild(children);
1184
+ return text ? new ReasoningWidget(text, range.from) : null;
1185
+ }
1186
+ },
1187
+ reference: {
1188
+ block: false,
1189
+ factory: ({ children, ref }) => {
1190
+ const text = getXmlTextChild(children);
1191
+ return text && ref ? new ReferenceWidget(text, ref) : null;
1192
+ }
1193
+ },
1194
+ select: {
1195
+ block: true,
1196
+ factory: ({ children }) => {
1197
+ const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
1198
+ return options?.length ? new SelectWidget(options) : null;
1199
+ }
1200
+ },
1201
+ suggestion: {
1202
+ block: true,
1203
+ factory: ({ children }) => {
1204
+ const text = getXmlTextChild(children);
1205
+ return text ? new SuggestionWidget(text) : null;
1206
+ }
1207
+ },
1208
+ stats: {
1209
+ block: true,
1210
+ factory: ({ children }) => {
1211
+ const text = getXmlTextChild(children);
1212
+ return text ? new StatsWidget(text) : null;
1213
+ }
1214
+ },
1215
+ status: {
1216
+ block: true,
1217
+ streaming: true,
1218
+ factory: ({ children }) => {
1219
+ const text = getXmlTextChild(children);
1220
+ return text ? new StatusWidget(text) : null;
1221
+ }
1222
+ },
1223
+ //
1224
+ // React Widgets (portaled outside of the editor)
1225
+ //
1226
+ summary: {
1227
+ block: true,
1228
+ Component: SummaryWidget
1229
+ },
1230
+ toolCall: {
1231
+ block: true,
1232
+ Component: (props) => /* @__PURE__ */ React12.createElement("div", {
1233
+ className: "py-2"
1234
+ }, /* @__PURE__ */ React12.createElement(ToolWidget, props))
1235
+ },
1236
+ toolResult: {
1237
+ block: true,
1238
+ Component: FallbackWidget
1239
+ },
1240
+ toolkit: {
1241
+ block: true,
1242
+ Component: FallbackWidget
1243
+ },
1244
+ //
1245
+ // Fallback
1246
+ //
1247
+ json: {
1248
+ block: true,
1249
+ Component: FallbackWidget
1250
+ }
1251
+ };
1252
+ var blockToMarkdown = createBlockRenderer("normal");
1253
+ function createBlockRenderer(viewType) {
1254
+ return (context, message, block) => {
1255
+ if (!isBlockVisible(viewType, message, block)) {
1256
+ return;
1257
+ }
1258
+ let str = blockToMarkdownImpl(context, message, block);
1259
+ if (str && !block.pending) {
1260
+ return str += "\n";
1261
+ }
1262
+ return str;
1263
+ };
1264
+ }
1265
+ var isBlockVisible = (viewType, message, block) => {
1266
+ switch (viewType) {
1267
+ case "debug":
1268
+ return true;
1269
+ case "normal":
1270
+ return block._tag !== "reasoning";
1271
+ case "summary":
1272
+ return block._tag === "text" && block.disposition !== "synthetic";
1273
+ case "thinking":
1274
+ default:
1275
+ return true;
1276
+ }
1277
+ };
1278
+ var blockToMarkdownImpl = (context, message, block) => {
1279
+ log("blockToMarkdown", {
1280
+ block: JSON.stringify(block)
1281
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 154, S: void 0 });
1282
+ switch (block._tag) {
1283
+ case "text": {
1284
+ if (message.sender.role === "user") {
1285
+ if (block.disposition === "synthetic") {
1286
+ return renderXMLBlock("synthetic", {
1287
+ content: block.text,
1288
+ pending: block.pending
1289
+ });
1290
+ } else {
1291
+ return `
1292
+ <prompt>${block.text}</prompt>`;
1293
+ }
1294
+ } else {
1295
+ const text = block.text.trim();
1296
+ if (text.length > 0) {
1297
+ return text;
1298
+ }
1299
+ }
1300
+ break;
1301
+ }
1302
+ case "reference": {
1303
+ if (block.pending) {
1304
+ return;
1305
+ }
1306
+ const dxn = block.reference.dxn;
1307
+ return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
1308
+ }
1309
+ case "suggestion": {
1310
+ if (block.pending) {
1311
+ return;
1312
+ }
1313
+ return `<suggestion>${block.text}</suggestion>`;
1314
+ }
1315
+ case "select": {
1316
+ if (block.pending || block.options.length === 0) {
1317
+ return;
1318
+ }
1319
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1320
+ }
1321
+ case "toolCall": {
1322
+ applyToolBlockToWidgetState(context, block);
1323
+ return `<toolCall id="${block.toolCallId}" />`;
1324
+ }
1325
+ case "toolResult": {
1326
+ applyToolBlockToWidgetState(context, block);
1327
+ break;
1328
+ }
1329
+ case "stats": {
1330
+ return "";
1331
+ }
1332
+ case "reasoning": {
1333
+ let text = block.reasoningText ?? block.redactedText;
1334
+ if (!text) {
1335
+ return;
1336
+ }
1337
+ return renderXMLBlock("reasoning", {
1338
+ content: text,
1339
+ pending: block.pending
1340
+ });
1341
+ }
1342
+ case "summary": {
1343
+ return renderXMLBlock("summary", {
1344
+ content: block.content,
1345
+ pending: block.pending
1346
+ });
1347
+ }
1348
+ case "status": {
1349
+ return renderXMLBlock("status", {
1350
+ content: block.statusText,
1351
+ pending: block.pending
1352
+ });
1353
+ }
1354
+ default: {
1355
+ return `<json id="${message.id}">
1356
+ ${JSON.stringify(block)}
1357
+ </json>`;
1358
+ }
1359
+ }
1360
+ };
1361
+ var escapeXmlTextContent = (raw) => raw.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1362
+ var renderXMLBlock = (tag, opts) => {
1363
+ const content = escapeXmlTextContent((opts.content ?? "").replace(/\n\n/g, " ").trim());
1364
+ if (opts.pending) {
1365
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}`;
1366
+ } else {
1367
+ return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}</${tag}>`;
1368
+ }
1369
+ };
1370
+
1371
+ // src/components/ChatThread/sync.ts
1372
+ var MessageThreadContext = class {
1373
+ _widgetState;
1374
+ constructor(_widgetState) {
1375
+ this._widgetState = _widgetState;
1376
+ }
1377
+ updateWidget(id, value2) {
1378
+ this._widgetState?.updateWidget(id, value2);
1379
+ }
1380
+ // TODO(burdon): Resolve name from hypergraph.
1381
+ getObjectLabel(_id) {
1382
+ return "Object";
1383
+ }
1384
+ };
1385
+ var MessageSyncer = class {
1386
+ _document;
1387
+ _renderer;
1388
+ _threadId;
1389
+ _completed = 0;
1390
+ _trailing = 0;
1391
+ _context;
1392
+ constructor(_document, _renderer) {
1393
+ this._document = _document;
1394
+ this._renderer = _renderer;
1395
+ this._context = new MessageThreadContext(this._document);
1396
+ }
1397
+ get context() {
1398
+ return this._context;
1399
+ }
1400
+ /**
1401
+ * Replace the document with the rendering of `messages`. Use on mount, on thread switch,
1402
+ * and from {@link update} when it detects an identity change in `messages[0]`.
1403
+ */
1404
+ reset(messages = []) {
1405
+ this._threadId = messages[0]?.id;
1406
+ this._completed = 0;
1407
+ this._trailing = 0;
1408
+ const buffer = this._walk(messages);
1409
+ void this._document.setContent(buffer).then(() => {
1410
+ rehydrateToolWidgetsFromMessages(this._context, messages);
1411
+ });
1412
+ }
1413
+ /**
1414
+ * Stream the suffix of the rendered messages into the document.
1415
+ * Returns `true` if the document was replaced (initial mount or thread switch), `false`
1416
+ * if the call was a streaming append (or a no-op).
1417
+ */
1418
+ update(messages) {
1419
+ if (messages[0]?.id !== this._threadId) {
1420
+ this.reset(messages);
1421
+ return true;
1422
+ }
1423
+ const buffer = this._walk(messages);
1424
+ if (buffer.length > 0) {
1425
+ void this._document.append(buffer);
1426
+ }
1427
+ return false;
1428
+ }
1429
+ /**
1430
+ * Walk flat blocks starting at `_completed`, advancing the cursors and returning the chars
1431
+ * to append. Blocks before `_completed` are skipped — their renderer is never re-invoked,
1432
+ * which preserves single-shot side effects (e.g. tool widget state mutation).
1433
+ */
1434
+ _walk(messages) {
1435
+ let buffer = "";
1436
+ let index = 0;
1437
+ outer: for (const message of messages) {
1438
+ for (const block of message.blocks) {
1439
+ if (index < this._completed) {
1440
+ index++;
1441
+ continue;
1442
+ }
1443
+ const rendered = this._renderer(this._context, message, block) ?? "";
1444
+ if (rendered.length > this._trailing) {
1445
+ buffer += rendered.slice(this._trailing);
1446
+ }
1447
+ if (block.pending) {
1448
+ if (rendered.length > this._trailing) {
1449
+ this._trailing = rendered.length;
1450
+ }
1451
+ break outer;
1452
+ }
1453
+ this._completed = index + 1;
1454
+ this._trailing = 0;
1455
+ index++;
1456
+ }
1457
+ }
1458
+ return buffer;
1459
+ }
1460
+ };
1461
+
1462
+ // src/components/ChatThread/ChatThread.tsx
1463
+ var defaultOptions = {
1464
+ autoScroll: true,
1465
+ cursor: false,
1466
+ fader: false,
1467
+ typewriter: true
1468
+ };
1469
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, options = defaultOptions, footer, debug = false, extensions, viewType, onEvent }, forwardedRef) => {
1470
+ const [controller, setController] = useState6(null);
1471
+ const handleMarkdownStreamRef = useCallback5((instance) => {
1472
+ setController(instance);
1473
+ setRef(forwardedRef, instance);
1474
+ }, [
1475
+ forwardedRef
1476
+ ]);
1477
+ const userHue = useMemo4(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
1478
+ identity
1479
+ ]);
1480
+ useEffect5(() => {
1481
+ controller?.scrollToBottom();
1482
+ }, [
1483
+ controller,
1484
+ error
1485
+ ]);
1486
+ const renderer = useMemo4(() => createBlockRenderer(viewType), [
1487
+ viewType
1488
+ ]);
1489
+ const syncer = useMemo4(() => controller && new MessageSyncer(controller, renderer), [
1490
+ controller,
1491
+ renderer
1492
+ ]);
1493
+ useEffect5(() => {
1494
+ if (!syncer) {
1495
+ return;
1496
+ }
1497
+ if (syncer.update(messages)) {
1498
+ controller?.scrollToBottom("instant");
1499
+ }
1500
+ }, [
1501
+ controller,
1502
+ syncer,
1503
+ messages
1504
+ ]);
1505
+ const handleEvent = useCallback5(({ type, value: value2 }) => {
1506
+ switch (type) {
1507
+ case "submit": {
1508
+ value2 && onEvent?.({
1509
+ type,
1510
+ text: value2
1511
+ });
1512
+ break;
1513
+ }
1514
+ }
1515
+ }, [
1516
+ onEvent
1517
+ ]);
1518
+ return /* @__PURE__ */ React13.createElement("div", {
1519
+ "data-hue": userHue,
1520
+ className: "contents"
1521
+ }, /* @__PURE__ */ React13.createElement(MarkdownStream, {
1522
+ key: viewType,
1523
+ classNames,
1524
+ registry: componentRegistry,
1525
+ options,
1526
+ debug,
1527
+ extensions,
1528
+ footer,
1529
+ onEvent: handleEvent,
1530
+ ref: handleMarkdownStreamRef
1531
+ }));
1532
+ });
1533
+
1534
+ // src/components/TaskList/TaskList.tsx
1535
+ import React14 from "react";
1536
+ import { useObject as useObject2 } from "@dxos/react-client/echo";
1537
+ import { Icon as Icon2, Tag } from "@dxos/react-ui";
1538
+ import { Row, RowList } from "@dxos/react-ui-list";
1539
+ import { composable, composableProps } from "@dxos/ui-theme";
1540
+ var TaskList = composable(({ plan, ...props }, forwardedRef) => {
1541
+ const [snapshot] = useObject2(plan);
1542
+ const tasks = snapshot?.tasks ?? [];
1543
+ return /* @__PURE__ */ React14.createElement(RowList.Root, null, /* @__PURE__ */ React14.createElement(RowList.Viewport, {
1544
+ ...composableProps(props, {
1545
+ classNames: "dx-container"
1546
+ }),
1547
+ ref: forwardedRef
1548
+ }, /* @__PURE__ */ React14.createElement(RowList.Content, {
1549
+ "aria-label": "Tasks"
1550
+ }, tasks.map((task) => /* @__PURE__ */ React14.createElement(Row, {
1551
+ key: task.id,
1552
+ id: task.id,
1553
+ classNames: "py-0"
1554
+ }, /* @__PURE__ */ React14.createElement("div", {
1555
+ className: "flex items-center gap-2"
1556
+ }, /* @__PURE__ */ React14.createElement(Icon2, {
1557
+ icon: task.status === "done" ? "ph--check--regular" : "ph--circle--regular",
1558
+ classNames: task.status === "done" ? "text-success-text" : void 0,
1559
+ size: 4
1560
+ }), /* @__PURE__ */ React14.createElement("span", {
1561
+ className: "sr-only"
1562
+ }, task.status === "done" ? "done" : task.status === "in-progress" ? "in progress" : "to do"), /* @__PURE__ */ React14.createElement("span", {
1563
+ className: "truncate flex-1"
1564
+ }, task.title), task.status === "in-progress" && /* @__PURE__ */ React14.createElement(Tag, {
1565
+ palette: "info"
1566
+ }, "pending")))))));
1567
+ });
1568
+
1569
+ // src/components/Chat/Chat.tsx
1570
+ var ChatRoot = ({ children, chat, feed, processor, onEvent, ...props }) => {
1571
+ const [debug, setDebug] = useState7(false);
1572
+ const streaming = useAtomValue3(processor.streaming);
1573
+ const active = useAtomValue3(processor.active);
1574
+ const requestTiming = useRequestTiming({
1575
+ active
1576
+ });
1577
+ const lastPrompt = useRef3(void 0);
1578
+ const db = props.db ?? (chat && Obj3.getDatabase(chat));
1579
+ const feedMessages = useQuery2(db, feed ? Query.select(Filter2.type(Message2.Message)).from(feed) : Query.select(Filter2.nothing()));
1580
+ const pendingMessages = useAtomValue3(processor.messages);
1581
+ const messages = useMemo5(() => Array.dedupeWith([
1582
+ ...feedMessages,
1583
+ ...pendingMessages
1584
+ ], ({ id: a }, { id: b }) => a === b), [
1585
+ feedMessages,
1586
+ pendingMessages
1587
+ ]);
1588
+ const dump = useDebug({
1589
+ processor
1590
+ });
1591
+ const event = useMemo5(() => new Event(), []);
1592
+ useEffect6(() => {
1593
+ return event.on((ev) => {
1594
+ switch (ev.type) {
1595
+ case "toggle-debug": {
1596
+ setDebug((debug2) => {
1597
+ if (debug2) {
1598
+ return false;
1599
+ } else {
1600
+ void dump();
1601
+ return true;
1602
+ }
1603
+ });
1604
+ break;
1605
+ }
1606
+ case "submit": {
1607
+ const text = ev.text.trim();
1608
+ if (!streaming && text.length) {
1609
+ lastPrompt.current = ev.text;
1610
+ void processor.request({
1611
+ message: text
1612
+ });
1613
+ }
1614
+ break;
1615
+ }
1616
+ case "retry": {
1617
+ if (!streaming) {
1618
+ void processor.retry();
1619
+ }
1620
+ break;
1621
+ }
1622
+ case "cancel": {
1623
+ if (streaming) {
1624
+ void processor.cancel();
1625
+ if (lastPrompt.current) {
1626
+ event.emit({
1627
+ type: "update-prompt",
1628
+ text: lastPrompt.current
1629
+ });
1630
+ }
1631
+ }
1632
+ break;
1633
+ }
1634
+ }
1635
+ onEvent?.(ev);
1636
+ });
1637
+ }, [
1638
+ event,
1639
+ dump,
1640
+ processor,
1641
+ streaming,
1642
+ onEvent
1643
+ ]);
1644
+ return /* @__PURE__ */ React15.createElement(ChatContextProvider, {
1645
+ debug,
1646
+ event,
1647
+ db,
1648
+ chat,
1649
+ messages,
1650
+ processor,
1651
+ requestTiming,
1652
+ ...props
1653
+ }, children);
1654
+ };
1655
+ ChatRoot.displayName = "Chat.Root";
1656
+ var useRequestTiming = ({ active }) => {
1657
+ const [requestTiming, setRequestTiming] = useState7(null);
1658
+ useEffect6(() => {
1659
+ if (active) {
1660
+ setRequestTiming({
1661
+ startedAt: Date.now(),
1662
+ endedAt: null
1663
+ });
1664
+ } else {
1665
+ setRequestTiming((prev) => prev && prev.endedAt == null ? {
1666
+ ...prev,
1667
+ endedAt: Date.now()
1668
+ } : prev);
1669
+ }
1670
+ }, [
1671
+ active
1672
+ ]);
1673
+ return requestTiming;
1674
+ };
1675
+ var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
1676
+ var ChatToolbar = composable2(({ attendableId, companionTo, ...props }, forwardedRef) => {
1677
+ const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
1678
+ const menuActions = useChatToolbarActions({
1679
+ chat,
1680
+ companionTo
1681
+ });
1682
+ return /* @__PURE__ */ React15.createElement(Menu.Root, {
1683
+ ...menuActions,
1684
+ attendableId
1685
+ }, /* @__PURE__ */ React15.createElement(Menu.Toolbar, {
1686
+ ...composableProps2(props),
1687
+ ref: forwardedRef
1688
+ }));
1689
+ });
1690
+ ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
1691
+ var CHAT_CONTENT_NAME = "Chat.Content";
1692
+ var ChatContent = composable2(({ children, ...props }, forwardedRef) => {
1693
+ return /* @__PURE__ */ React15.createElement("div", {
1694
+ ...composableProps2(props, {
1695
+ classNames: "dx-expander flex flex-col"
1696
+ }),
1697
+ ref: forwardedRef
1698
+ }, children);
1699
+ });
1700
+ ChatContent.displayName = CHAT_CONTENT_NAME;
1701
+ var CHAT_THREAD_NAME = "Chat.Thread";
1702
+ var ChatThread2 = ({ viewType, debug: debugProp, ...props }) => {
1703
+ const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
1704
+ const debugView = viewType === "debug";
1705
+ const identity = useIdentity();
1706
+ const error = useAtomValue3(processor.error).pipe(Option4.getOrUndefined);
1707
+ const extensions = useChatKeymapExtensions2({
1708
+ event
1709
+ });
1710
+ const controllerRef = useRef3(null);
1711
+ useEffect6(() => {
1712
+ return event.on((event2) => {
1713
+ switch (event2.type) {
1714
+ case "submit":
1715
+ case "scroll-to-bottom":
1716
+ controllerRef.current?.scrollToBottom();
1717
+ break;
1718
+ case "nav-previous":
1719
+ controllerRef.current?.navigatePrevious();
1720
+ break;
1721
+ case "nav-next":
1722
+ controllerRef.current?.navigateNext();
1723
+ break;
1724
+ }
1725
+ });
1726
+ }, [
1727
+ event
1728
+ ]);
1729
+ const handleEvent = useCallback6((ev) => {
1730
+ event.emit(ev);
1731
+ }, [
1732
+ event
1733
+ ]);
1734
+ if (!identity) {
1735
+ return /* @__PURE__ */ React15.createElement("div", {
1736
+ className: "dx-expander"
1737
+ });
1738
+ }
1739
+ return /* @__PURE__ */ React15.createElement(ChatThread, {
1740
+ ...props,
1741
+ identity,
1742
+ messages,
1743
+ error,
1744
+ debug: debugProp ?? (debug || debugView),
1745
+ viewType,
1746
+ extensions,
1747
+ onEvent: handleEvent,
1748
+ ref: controllerRef
1749
+ });
1750
+ };
1751
+ ChatThread2.displayName = CHAT_THREAD_NAME;
1752
+ var CHAT_PROMPT_NAME = "Chat.Prompt";
1753
+ var ChatPrompt2 = (props) => {
1754
+ const { chat, db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
1755
+ return /* @__PURE__ */ React15.createElement(ChatPrompt, {
1756
+ ...props,
1757
+ chat,
1758
+ db,
1759
+ processor,
1760
+ event
1761
+ });
1762
+ };
1763
+ ChatPrompt2.displayName = CHAT_PROMPT_NAME;
1764
+ var CHAT_TASK_LIST_NAME = "Chat.TaskList";
1765
+ var ChatTaskList = composable2(({ plan: planProp, ...props }, forwardedRef) => {
1766
+ const { chat } = useChatContext(CHAT_TASK_LIST_NAME);
1767
+ const parent = chat ? Obj3.getParent(chat) : void 0;
1768
+ const agent = parent && Obj3.instanceOf(Agent.Agent, parent) ? parent : void 0;
1769
+ const plan = planProp ?? agent?.plan.target;
1770
+ if (!plan) {
1771
+ return null;
1772
+ }
1773
+ return /* @__PURE__ */ React15.createElement(TaskList, {
1774
+ ...props,
1775
+ plan,
1776
+ ref: forwardedRef
1777
+ });
1778
+ });
1779
+ ChatTaskList.displayName = CHAT_TASK_LIST_NAME;
1780
+ var Chat = {
1781
+ Root: ChatRoot,
1782
+ Toolbar: ChatToolbar,
1783
+ Content: ChatContent,
1784
+ Prompt: ChatPrompt2,
1785
+ Status: ChatStatus,
1786
+ Thread: ChatThread2,
1787
+ TaskList: ChatTaskList
1788
+ };
1789
+
1790
+ // src/components/ProcessTree/ProcessTree.tsx
1791
+ import * as Match from "effect/Match";
1792
+ import * as Option5 from "effect/Option";
1793
+ import React16 from "react";
1794
+ import { Process } from "@dxos/functions-runtime";
1795
+ import { Icon as Icon3, IconButton as IconButton4, ScrollArea, Tooltip as Tooltip2, Treegrid } from "@dxos/react-ui";
1796
+ import { composable as composable3, composableProps as composableProps3, mx as mx7 } from "@dxos/ui-theme";
1797
+ import { Unit as Unit2 } from "@dxos/util";
1798
+ var ProcessTree = composable3(({ processes, onProcessSelect, onProcessTerminate, ...props }, forwardedRef) => {
1799
+ const sortedProcesses = [
1800
+ ...processes.filter((process) => [
1801
+ Process.State.RUNNING,
1802
+ Process.State.HYBERNATING
1803
+ ].includes(process.state)),
1804
+ ...processes.filter((process) => [
1805
+ Process.State.IDLE
1806
+ ].includes(process.state)).slice(0, 3),
1807
+ ...processes.filter((process) => [
1808
+ Process.State.SUCCEEDED,
1809
+ Process.State.FAILED,
1810
+ Process.State.TERMINATED
1811
+ ].includes(process.state))
1812
+ ].sort((a, b) => {
1813
+ const aCompletedAt = Option5.getOrElse(a.completedAt, () => Infinity);
1814
+ const bCompletedAt = Option5.getOrElse(b.completedAt, () => Infinity);
1815
+ return bCompletedAt - aCompletedAt;
1816
+ });
1817
+ return /* @__PURE__ */ React16.createElement(ScrollArea.Root, {
1818
+ ...composableProps3(props, {
1819
+ classNames: "dx-expander"
1820
+ }),
1821
+ thin: true,
1822
+ ref: forwardedRef
1823
+ }, /* @__PURE__ */ React16.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React16.createElement(Treegrid.Root, {
1824
+ gridTemplateColumns: "1fr"
1825
+ }, sortedProcesses.filter((process) => process.parentPid === null).map((process) => {
1826
+ return /* @__PURE__ */ React16.createElement(Treegrid.Row, {
1827
+ key: process.pid.toString(),
1828
+ id: process.pid.toString(),
1829
+ parentOf: process.parentPid?.toString()
1830
+ }, /* @__PURE__ */ React16.createElement(Treegrid.Cell, {
1831
+ indent: true,
1832
+ classNames: mx7("grid grid-cols-[min-content_1fr_min-content_min-content] items-center gap-1 min-w-0", onProcessSelect && "dx-hover"),
1833
+ onClick: () => onProcessSelect?.(process)
1834
+ }, /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, {
1835
+ className: "p-1",
1836
+ content: process.state.toString()
1837
+ }, /* @__PURE__ */ React16.createElement(Icon3, {
1838
+ size: 4,
1839
+ synchronized: true,
1840
+ 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"),
1841
+ 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"))
1842
+ })), /* @__PURE__ */ React16.createElement("div", {
1843
+ className: "flex items-center gap-2 text-xs overflow-hidden"
1844
+ }, /* @__PURE__ */ React16.createElement("span", {
1845
+ className: "truncate text-description select-none"
1846
+ }, process.params.name ?? process.pid.toString())), [
1847
+ Process.State.FAILED,
1848
+ Process.State.SUCCEEDED
1849
+ ].includes(process.state) && /* @__PURE__ */ React16.createElement("div", {
1850
+ className: "text-xs text-description tabular-nums"
1851
+ }, Unit2.Millisecond(process.metrics.wallTime).toString()) || /* @__PURE__ */ React16.createElement("div", null), onProcessTerminate && /* @__PURE__ */ React16.createElement(IconButton4, {
1852
+ classNames: "min-h-0 p-1",
1853
+ icon: "ph--x--regular",
1854
+ iconOnly: true,
1855
+ variant: "ghost",
1856
+ size: 4,
1857
+ label: "Actions",
1858
+ onClick: (event) => {
1859
+ event.stopPropagation();
1860
+ onProcessTerminate?.(process);
1861
+ }
1862
+ })));
1863
+ }))));
1864
+ });
1865
+
1866
+ // src/components/TemplateEditor/TemplateEditor.tsx
1867
+ import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1868
+ import { composeRefs } from "@radix-ui/react-compose-refs";
1869
+ import React17 from "react";
1870
+ import { createDocAccessor } from "@dxos/echo-db";
1871
+ import { useThemeContext, useTranslation as useTranslation8 } from "@dxos/react-ui";
1872
+ import { useTextEditor } from "@dxos/react-ui-editor";
1873
+ import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
1874
+ import { composable as composable4, composableProps as composableProps4 } from "@dxos/ui-theme";
1875
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1876
+ import { meta as meta8 } from "#meta";
1877
+
1878
+ // src/components/TemplateEditor/extensions/handlebars-extension.ts
1879
+ import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
1880
+ import { RangeSetBuilder } from "@codemirror/state";
1881
+ import { Decoration, ViewPlugin, WidgetType as WidgetType7, keymap } from "@codemirror/view";
1882
+ import { Domino as Domino7, mx as mx8 } from "@dxos/ui";
1883
+ var handlebars = (_ = {}) => {
1884
+ return [
1885
+ handlebarsHighlightPlugin,
1886
+ autocompletion({
1887
+ activateOnTyping: true,
1888
+ aboveCursor: true,
1889
+ closeOnBlur: true,
1890
+ override: [
1891
+ handlebarsCompletions
1892
+ ]
1893
+ }),
1894
+ keymap.of(completionKeymap)
1895
+ ];
1896
+ };
1897
+ var regex = {
1898
+ // {{! comment }}
1899
+ comment: /\{\{!\s*[^}]*\}\}/g,
1900
+ // {{var}}
1901
+ brackets: /\{\{[^}]*\}\}/g,
1902
+ // {{#command}} {{/command}}
1903
+ command: /\{\{[#/]([^}]+)\}\}/g,
1904
+ // {{var}}
1905
+ var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
1906
+ // @dxn:queue:data:xxx
1907
+ dxn: /@?dxn:[\w@:]+/g,
1908
+ // example.com/path/xxx
1909
+ url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
1910
+ };
1911
+ var tagPadding = "mx-0.5 px-1 rounded-xs";
1912
+ var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
1913
+ decorations;
1914
+ constructor(view) {
1915
+ this.decorations = this.buildDecorations(view);
1916
+ }
1917
+ update(update) {
1918
+ if (update.docChanged || update.viewportChanged || update.selectionSet) {
1919
+ this.decorations = this.buildDecorations(update.view);
1920
+ }
1921
+ }
1922
+ // NOTE: Decorations may clash with other extensions (e.g., markdown).
1923
+ buildDecorations(view) {
1924
+ const selection = view.state.selection.main;
1925
+ const decorations = [];
1926
+ for (const { from, to } of view.visibleRanges) {
1927
+ const text = view.state.doc.sliceString(from, to);
1928
+ {
1929
+ let match;
1930
+ while ((match = regex.dxn.exec(text)) !== null) {
1931
+ const start = from + match.index;
1932
+ const end = start + match[0].length;
1933
+ const overlaps = selection.to > start && selection.from <= end;
1934
+ if (!overlaps) {
1935
+ decorations.push({
1936
+ from: start,
1937
+ to: end,
1938
+ decoration: Decoration.widget({
1939
+ widget: new DXNWidget(match[0])
1940
+ })
1941
+ });
1942
+ }
1943
+ }
1944
+ }
1945
+ {
1946
+ let match;
1947
+ while ((match = regex.url.exec(text)) !== null) {
1948
+ const start = from + match.index;
1949
+ const end = start + match[0].length;
1950
+ decorations.push({
1951
+ from: start,
1952
+ to: end,
1953
+ decoration: Decoration.mark({
1954
+ class: mx8("dx-tag--blue", tagPadding)
1955
+ })
1956
+ });
1957
+ }
1958
+ }
1959
+ {
1960
+ let match;
1961
+ while ((match = regex.brackets.exec(text)) !== null) {
1962
+ const start = from + match.index;
1963
+ const end = start + match[0].length;
1964
+ decorations.push({
1965
+ from: start,
1966
+ to: end,
1967
+ decoration: Decoration.mark({
1968
+ class: "text-subdued"
1969
+ })
1970
+ });
1971
+ }
1972
+ }
1973
+ {
1974
+ let match;
1975
+ while ((match = regex.command.exec(text)) !== null) {
1976
+ const start = from + match.index + 2;
1977
+ let end = start + match[0].length - 4;
1978
+ const text2 = view.state.doc.sliceString(start, end);
1979
+ const parts = text2.split(/\s+/);
1980
+ if (parts.length > 1) {
1981
+ const idx = start + parts[0].length;
1982
+ decorations.push({
1983
+ from: idx,
1984
+ to: end,
1985
+ decoration: Decoration.mark({
1986
+ class: "text-green-text"
1987
+ })
1988
+ });
1989
+ end = idx;
1990
+ }
1991
+ decorations.push({
1992
+ from: start,
1993
+ to: end,
1994
+ decoration: Decoration.mark({
1995
+ class: "text-blue-text"
1996
+ })
1997
+ });
1998
+ }
1999
+ }
2000
+ {
2001
+ let match;
2002
+ while ((match = regex.var.exec(text)) !== null) {
2003
+ const start = from + match.index + 2;
2004
+ const end = start + match[0].length - 4;
2005
+ decorations.push({
2006
+ from: start,
2007
+ to: end,
2008
+ decoration: Decoration.mark({
2009
+ class: "text-green-text"
2010
+ })
2011
+ });
2012
+ }
2013
+ }
2014
+ }
2015
+ decorations.sort((a, b) => a.from - b.from || a.to - b.to);
2016
+ const builder = new RangeSetBuilder();
2017
+ for (const { from, to, decoration } of decorations) {
2018
+ builder.add(from, to, decoration);
2019
+ }
2020
+ return builder.finish();
2021
+ }
2022
+ }, {
2023
+ decorations: (v) => v.decorations
2024
+ });
2025
+ var DXNWidget = class extends WidgetType7 {
2026
+ _identifier;
2027
+ constructor(_identifier) {
2028
+ super(), this._identifier = _identifier;
2029
+ }
2030
+ ignoreEvent() {
2031
+ return false;
2032
+ }
2033
+ eq(other) {
2034
+ return this._identifier === other._identifier;
2035
+ }
2036
+ toDOM() {
2037
+ const text = this._identifier.split(":").map((part) => {
2038
+ const len = 16;
2039
+ const plen = 4;
2040
+ if (part.length > len) {
2041
+ return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
2042
+ }
2043
+ return part;
2044
+ }).join(":");
2045
+ return Domino7.of("span").classNames(mx8("font-mono dx-tag--blue", tagPadding)).text(text).root;
2046
+ }
2047
+ };
2048
+ var variables = [
2049
+ "this"
2050
+ ];
2051
+ var commands = [
2052
+ "this",
2053
+ "each",
2054
+ "if",
2055
+ "unless",
2056
+ "with"
2057
+ ];
2058
+ function handlebarsCompletions(context) {
2059
+ const match = context.matchBefore(/\{\{[^}]*/);
2060
+ if (!match || match.from === match.to) {
2061
+ return null;
2062
+ }
2063
+ let type = "variable";
2064
+ let text = match.text.slice(2);
2065
+ let from = match.from + 2;
2066
+ let matches = [];
2067
+ if (text.startsWith("#") || text.startsWith("/")) {
2068
+ const idx = text.lastIndexOf(" ");
2069
+ if (idx !== -1) {
2070
+ type = "variable";
2071
+ matches = variables;
2072
+ text = text.slice(idx + 1);
2073
+ from += idx + 1;
2074
+ } else {
2075
+ type = "command";
2076
+ text = text.slice(1);
2077
+ matches = commands;
2078
+ from += 1;
2079
+ }
2080
+ } else {
2081
+ type = "variable";
2082
+ matches = variables;
2083
+ }
2084
+ const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
2085
+ type,
2086
+ label: name
2087
+ }));
2088
+ return {
2089
+ from,
2090
+ options
2091
+ };
2092
+ }
2093
+
2094
+ // src/components/TemplateEditor/extensions/xml-extension.ts
2095
+ import { syntaxTree } from "@codemirror/language";
2096
+ import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
2097
+ import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
2098
+ var xmlDecorator = (_ = {}) => {
2099
+ return [
2100
+ xmlDecoratorPlugin
2101
+ ];
2102
+ };
2103
+ var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
2104
+ decorations;
2105
+ constructor(view) {
2106
+ this.decorations = this.buildDecorations(view);
2107
+ }
2108
+ update(update) {
2109
+ if (update.docChanged || update.viewportChanged) {
2110
+ this.decorations = this.buildDecorations(update.view);
2111
+ }
2112
+ }
2113
+ buildDecorations(view) {
2114
+ const builder = new RangeSetBuilder2();
2115
+ for (const { from, to } of view.visibleRanges) {
2116
+ syntaxTree(view.state).iterate({
2117
+ from,
2118
+ to,
2119
+ enter: (node) => {
2120
+ if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
2121
+ builder.add(node.from, node.to, Decoration2.mark({
2122
+ class: "font-mono text-subdued"
2123
+ }));
2124
+ }
2125
+ }
2126
+ });
2127
+ }
2128
+ return builder.finish();
2129
+ }
2130
+ }, {
2131
+ decorations: (v) => v.decorations
2132
+ });
2133
+
2134
+ // src/components/TemplateEditor/TemplateEditor.tsx
2135
+ var TemplateEditor = composable4(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
2136
+ const { t } = useTranslation8(meta8.id);
2137
+ const { themeMode } = useThemeContext();
2138
+ const { parentRef } = useTextEditor(() => {
2139
+ const target = template.source?.target;
2140
+ if (!target) {
2141
+ return {};
2142
+ }
2143
+ return {
2144
+ initialValue: target.content ?? "",
2145
+ extensions: [
2146
+ createDataExtensions({
2147
+ id,
2148
+ text: createDocAccessor(target, [
2149
+ "content"
2150
+ ])
2151
+ }),
2152
+ createBasicExtensions({
2153
+ bracketMatching: false,
2154
+ lineNumbers,
2155
+ lineWrapping: true,
2156
+ placeholder: t("template.placeholder")
2157
+ }),
2158
+ createThemeExtensions({
2159
+ themeMode
2160
+ }),
2161
+ createMarkdownExtensions(),
2162
+ decorateMarkdown(),
2163
+ handlebars(),
2164
+ // xml(),
2165
+ // NOTE: Since we're using markdown only HTML nodes are parsed.
2166
+ xmlDecorator(),
2167
+ syntaxHighlighting(defaultHighlightStyle)
2168
+ ].filter(isNonNullable2)
2169
+ };
2170
+ }, [
2171
+ themeMode,
2172
+ template.source?.target,
2173
+ lineNumbers
2174
+ ]);
2175
+ return /* @__PURE__ */ React17.createElement("div", {
2176
+ ...composableProps4(props, {
2177
+ role: "none",
2178
+ classNames: [
2179
+ "h-full overflow-hidden",
2180
+ classNames
2181
+ ]
2182
+ }),
2183
+ ref: composeRefs(parentRef, forwardedRef)
2184
+ });
2185
+ });
2186
+
2187
+ // src/components/Toolbox/Toolbox.tsx
2188
+ import React18, { Fragment, useEffect as useEffect7, useState as useState8 } from "react";
2189
+ import { Operation } from "@dxos/compute";
2190
+ import { Filter as Filter3 } from "@dxos/echo";
2191
+ import { log as log2 } from "@dxos/log";
2192
+ import { useQuery as useQuery3 } from "@dxos/react-client/echo";
2193
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
2194
+ import { composable as composable5, composableProps as composableProps5, mx as mx9 } from "@dxos/ui-theme";
2195
+ import { ServiceType } from "#types";
2196
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
2197
+ var Toolbox = composable5(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
2198
+ return /* @__PURE__ */ React18.createElement(ScrollArea2.Root, {
2199
+ ...composableProps5(props),
2200
+ thin: true,
2201
+ orientation: "vertical",
2202
+ ref: forwardedRef
2203
+ }, /* @__PURE__ */ React18.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React18.createElement(Section, {
2204
+ title: "Blueprints",
2205
+ items: blueprints.map(({ name, description, tools }) => ({
2206
+ name,
2207
+ description,
2208
+ subitems: tools.map((toolId) => ({
2209
+ name: `\u2219 ${safeToolId(toolId)}`
2210
+ }))
2211
+ }))
2212
+ }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React18.createElement(Section, {
2213
+ title: "Blueprints",
2214
+ items: activeBlueprints.map(({ target }) => ({
2215
+ name: target?.name ?? "",
2216
+ description: target?.description ?? "",
2217
+ subitems: target?.tools.map((toolId) => ({
2218
+ name: `\u2219 ${safeToolId(toolId)}`
2219
+ }))
2220
+ }))
2221
+ }), services && services.length > 0 && /* @__PURE__ */ React18.createElement(Section, {
2222
+ title: "Services",
2223
+ items: services.map(({ service: { serviceId, name, description } }) => ({
2224
+ name: name ?? serviceId,
2225
+ description
2226
+ }))
2227
+ }), functions && functions.length > 0 && /* @__PURE__ */ React18.createElement(Section, {
2228
+ title: "Functions",
2229
+ items: functions.map(({ name, description }) => ({
2230
+ name,
2231
+ description
2232
+ }))
2233
+ })));
2234
+ });
2235
+ Toolbox.displayName = "Toolbox";
2236
+ var Section = ({ title, items, striped }) => {
2237
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
2238
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
2239
+ const subGridClassNames = mx9("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
2240
+ return /* @__PURE__ */ React18.createElement("div", null, /* @__PURE__ */ React18.createElement("h1", {
2241
+ className: "px-2 text-sm"
2242
+ }, title), /* @__PURE__ */ React18.createElement("div", {
2243
+ className: gridClassNames
2244
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React18.createElement(Fragment, {
2245
+ key: i
2246
+ }, name && /* @__PURE__ */ React18.createElement("div", {
2247
+ className: subGridClassNames
2248
+ }, /* @__PURE__ */ React18.createElement("div", {
2249
+ className: "truncate text-primary-500"
2250
+ }, name), /* @__PURE__ */ React18.createElement("div", {
2251
+ className: "line-clamp-2"
2252
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React18.createElement("div", {
2253
+ key: i2,
2254
+ className: mx9(subGridClassNames, striped && stripeClassNames)
2255
+ }, /* @__PURE__ */ React18.createElement("div", {
2256
+ className: "truncate"
2257
+ }, name2), /* @__PURE__ */ React18.createElement("div", {
2258
+ className: "line-clamp-3 text-subdued"
2259
+ }, description2)))))));
2260
+ };
2261
+ var ToolboxPanel = ({ classNames, db, processor }) => {
2262
+ const services = useQuery3(db, Filter3.type(ServiceType));
2263
+ const [serviceTools, setServiceTools] = useState8([]);
2264
+ useEffect7(() => {
2265
+ log2("creating service tools...", {
2266
+ services: services.length
2267
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: void 0 });
2268
+ queueMicrotask(async () => {
2269
+ });
2270
+ }, [
2271
+ services
2272
+ ]);
2273
+ const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
2274
+ return /* @__PURE__ */ React18.createElement(Toolbox, {
2275
+ classNames,
2276
+ blueprints: processor?.context.getBlueprints(),
2277
+ services: serviceTools,
2278
+ functions
2279
+ });
2280
+ };
2281
+ var safeToolId = (name) => {
2282
+ return name.split("_").pop();
2283
+ };
2284
+
2285
+ // src/components/index.ts
2286
+ var AssistantSettings = lazy(() => import("../AssistantSettings-GG52BLKS.mjs"));
2287
+ export {
2288
+ AssistantSettings,
2289
+ Chat,
2290
+ ProcessTree,
2291
+ TaskList,
2292
+ TemplateEditor,
2293
+ Toolbox,
2294
+ ToolboxPanel,
2295
+ useChatContext
2296
+ };
2297
+ //# sourceMappingURL=index.mjs.map