@dxos/plugin-assistant 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (619) hide show
  1. package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs +31 -0
  2. package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs.map +7 -0
  3. package/dist/lib/browser/ChatCompanion-GFSJZTOT.mjs +153 -0
  4. package/dist/lib/browser/ChatCompanion-GFSJZTOT.mjs.map +7 -0
  5. package/dist/lib/browser/ChatContainer-IHAPBIZE.mjs +72 -0
  6. package/dist/lib/browser/ChatContainer-IHAPBIZE.mjs.map +7 -0
  7. package/dist/lib/browser/ChatDialog-EGRMPCTL.mjs +85 -0
  8. package/dist/lib/browser/ChatDialog-EGRMPCTL.mjs.map +7 -0
  9. package/dist/lib/browser/PromptArticle-K362ZPAE.mjs +53 -0
  10. package/dist/lib/browser/PromptArticle-K362ZPAE.mjs.map +7 -0
  11. package/dist/lib/browser/ai-service-5GUDOEWF.mjs +21 -0
  12. package/dist/lib/browser/ai-service-5GUDOEWF.mjs.map +7 -0
  13. package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs +212 -0
  14. package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs.map +7 -0
  15. package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs +14 -0
  16. package/dist/lib/browser/blueprints/index.mjs +12 -0
  17. package/dist/lib/browser/chunk-A75V4MOQ.mjs +1832 -0
  18. package/dist/lib/browser/chunk-A75V4MOQ.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-DKQMSMBN.mjs +326 -0
  20. package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-EXVT7D4B.mjs +23 -0
  22. package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-ML3QCFKA.mjs +265 -0
  24. package/dist/lib/browser/chunk-ML3QCFKA.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-MRJVYGLU.mjs +208 -0
  26. package/dist/lib/browser/chunk-MRJVYGLU.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-V772AMZM.mjs +250 -0
  28. package/dist/lib/browser/chunk-V772AMZM.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-WGQTU6UJ.mjs +41 -0
  30. package/dist/lib/browser/chunk-WGQTU6UJ.mjs.map +7 -0
  31. package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs +20 -0
  32. package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs.map +7 -0
  33. package/dist/lib/browser/index.mjs +229 -216
  34. package/dist/lib/browser/index.mjs.map +4 -4
  35. package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs +19 -0
  36. package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs.map +7 -0
  37. package/dist/lib/browser/meta.json +1 -1
  38. package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs +132 -0
  39. package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs.map +7 -0
  40. package/dist/lib/browser/react-surface-S7SBFOSW.mjs +109 -0
  41. package/dist/lib/browser/react-surface-S7SBFOSW.mjs.map +7 -0
  42. package/dist/lib/browser/repair-6QGAKOVM.mjs +54 -0
  43. package/dist/lib/browser/repair-6QGAKOVM.mjs.map +7 -0
  44. package/dist/lib/browser/settings-4ZDLUMYE.mjs +32 -0
  45. package/dist/lib/browser/settings-4ZDLUMYE.mjs.map +7 -0
  46. package/dist/lib/browser/state-AN6336ZX.mjs +26 -0
  47. package/dist/lib/browser/state-AN6336ZX.mjs.map +7 -0
  48. package/dist/lib/browser/toolkit-7AVTEPMA.mjs +18 -0
  49. package/dist/lib/browser/toolkit-7AVTEPMA.mjs.map +7 -0
  50. package/dist/lib/browser/types/index.mjs +8 -4
  51. package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs +32 -0
  52. package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs.map +7 -0
  53. package/dist/lib/node-esm/ChatCompanion-UR7DXZ54.mjs +154 -0
  54. package/dist/lib/node-esm/ChatCompanion-UR7DXZ54.mjs.map +7 -0
  55. package/dist/lib/node-esm/ChatContainer-YMLLGOZK.mjs +73 -0
  56. package/dist/lib/node-esm/ChatContainer-YMLLGOZK.mjs.map +7 -0
  57. package/dist/lib/node-esm/ChatDialog-D24WJPK4.mjs +86 -0
  58. package/dist/lib/node-esm/ChatDialog-D24WJPK4.mjs.map +7 -0
  59. package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs +54 -0
  60. package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs.map +7 -0
  61. package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs +22 -0
  62. package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs.map +7 -0
  63. package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs +213 -0
  64. package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs.map +7 -0
  65. package/dist/lib/node-esm/{blueprint-definition-B6UDX5U3.mjs → blueprint-definition-SEMDEIYG.mjs} +6 -4
  66. package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs.map +7 -0
  67. package/dist/lib/node-esm/blueprints/index.mjs +13 -0
  68. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-355W5B27.mjs +251 -0
  70. package/dist/lib/node-esm/chunk-355W5B27.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-4BERCIES.mjs +1833 -0
  72. package/dist/lib/node-esm/chunk-4BERCIES.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-75PHXBN3.mjs +327 -0
  74. package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +7 -0
  75. package/dist/lib/node-esm/chunk-DCA5QWQT.mjs +209 -0
  76. package/dist/lib/node-esm/chunk-DCA5QWQT.mjs.map +7 -0
  77. package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs +42 -0
  78. package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-POWB2BPC.mjs +25 -0
  80. package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs +267 -0
  82. package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs.map +7 -0
  83. package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs +21 -0
  84. package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs.map +7 -0
  85. package/dist/lib/node-esm/index.mjs +229 -216
  86. package/dist/lib/node-esm/index.mjs.map +4 -4
  87. package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs +20 -0
  88. package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs.map +7 -0
  89. package/dist/lib/node-esm/meta.json +1 -1
  90. package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs +133 -0
  91. package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs.map +7 -0
  92. package/dist/lib/node-esm/react-surface-ZR6FXGLF.mjs +110 -0
  93. package/dist/lib/node-esm/react-surface-ZR6FXGLF.mjs.map +7 -0
  94. package/dist/lib/node-esm/repair-QJ7CQDKU.mjs +55 -0
  95. package/dist/lib/node-esm/repair-QJ7CQDKU.mjs.map +7 -0
  96. package/dist/lib/node-esm/settings-CQEOHR3R.mjs +33 -0
  97. package/dist/lib/node-esm/settings-CQEOHR3R.mjs.map +7 -0
  98. package/dist/lib/node-esm/state-HDON4REW.mjs +27 -0
  99. package/dist/lib/node-esm/state-HDON4REW.mjs.map +7 -0
  100. package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs +19 -0
  101. package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs.map +7 -0
  102. package/dist/lib/node-esm/types/index.mjs +8 -4
  103. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  104. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  105. package/dist/types/src/blueprints/assistant-blueprint.d.ts +209 -0
  106. package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +1 -0
  107. package/dist/types/src/blueprints/index.d.ts +7 -0
  108. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/ai-service/ai-service.d.ts +5 -0
  110. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
  112. package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  114. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  116. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +21 -0
  118. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +4 -0
  120. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +6 -0
  122. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
  124. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
  125. package/dist/types/src/capabilities/index.d.ts +10 -11
  126. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  127. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
  128. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
  129. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +12 -0
  130. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
  131. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  132. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  133. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  134. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  135. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  136. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  137. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  138. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  139. package/dist/types/src/capabilities/repair/index.d.ts +3 -0
  140. package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
  141. package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
  142. package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
  143. package/dist/types/src/capabilities/settings/index.d.ts +15 -0
  144. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  145. package/dist/types/src/capabilities/settings/settings.d.ts +17 -0
  146. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  147. package/dist/types/src/capabilities/state/index.d.ts +11 -0
  148. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  149. package/dist/types/src/capabilities/state/state.d.ts +13 -0
  150. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  151. package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
  152. package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
  153. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +5 -0
  154. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
  155. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -2
  156. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  157. package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
  158. package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
  159. package/dist/types/src/components/Chat/Chat.d.ts +23 -13
  160. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  161. package/dist/types/src/components/Chat/events.d.ts +5 -1
  162. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  163. package/dist/types/src/components/ChatCompanion.d.ts +2 -2
  164. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
  165. package/dist/types/src/components/ChatContainer.d.ts +13 -5
  166. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  167. package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
  168. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
  169. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  170. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +3 -3
  171. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  172. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
  173. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  174. package/dist/types/src/components/ChatThread/ChatThread.d.ts +7 -8
  175. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  176. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +133 -74
  177. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  178. package/dist/types/src/components/ChatThread/reducers.d.ts +5 -5
  179. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -1
  180. package/dist/types/src/components/ChatThread/registry.d.ts +1 -1
  181. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
  182. package/dist/types/src/components/ChatThread/sync.d.ts +12 -6
  183. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
  184. package/dist/types/src/components/PromptArticle.d.ts +7 -0
  185. package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
  186. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
  187. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  188. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +116 -61
  189. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  190. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +12 -2
  191. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  192. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +117 -62
  193. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  194. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  195. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  196. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  197. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  198. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  199. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +10 -8
  200. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
  201. package/dist/types/src/components/Toolbox/Toolbox.d.ts +6 -7
  202. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  203. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +116 -61
  204. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  205. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
  206. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
  207. package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
  208. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
  209. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
  210. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
  211. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
  212. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
  213. package/dist/types/src/components/Typewriter/index.d.ts +2 -0
  214. package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
  215. package/dist/types/src/components/index.d.ts +10 -9
  216. package/dist/types/src/components/index.d.ts.map +1 -1
  217. package/dist/types/src/functions/index.d.ts +3 -3
  218. package/dist/types/src/functions/index.d.ts.map +1 -1
  219. package/dist/types/src/functions/{list.d.ts → object-list.d.ts} +3 -3
  220. package/dist/types/src/functions/object-list.d.ts.map +1 -0
  221. package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +2 -2
  222. package/dist/types/src/functions/object-load.d.ts.map +1 -0
  223. package/dist/types/src/functions/object-search.d.ts +10 -0
  224. package/dist/types/src/functions/object-search.d.ts.map +1 -0
  225. package/dist/types/src/hooks/index.d.ts +2 -2
  226. package/dist/types/src/hooks/index.d.ts.map +1 -1
  227. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -4
  228. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  229. package/dist/types/src/hooks/useChatProcessor.d.ts +4 -2
  230. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  231. package/dist/types/src/hooks/useChatServices.d.ts +4 -4
  232. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  233. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  234. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  235. package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
  236. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
  237. package/dist/types/src/hooks/useContextObjects.d.ts +7 -7
  238. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
  239. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  240. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  241. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  242. package/dist/types/src/index.d.ts +2 -1
  243. package/dist/types/src/index.d.ts.map +1 -1
  244. package/dist/types/src/meta.d.ts +3 -4
  245. package/dist/types/src/meta.d.ts.map +1 -1
  246. package/dist/types/src/processor/index.d.ts +1 -0
  247. package/dist/types/src/processor/index.d.ts.map +1 -1
  248. package/dist/types/src/processor/presets.d.ts +1 -1
  249. package/dist/types/src/processor/presets.d.ts.map +1 -1
  250. package/dist/types/src/processor/processor.d.ts +19 -17
  251. package/dist/types/src/processor/processor.d.ts.map +1 -1
  252. package/dist/types/src/processor/update-name.d.ts +10 -0
  253. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  254. package/dist/types/src/queue-logger.d.ts.map +1 -1
  255. package/dist/types/src/testing/index.d.ts +0 -2
  256. package/dist/types/src/testing/index.d.ts.map +1 -1
  257. package/dist/types/src/testing/test-generator.d.ts +6 -5
  258. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  259. package/dist/types/src/testing/test-services.d.ts +2 -2
  260. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  261. package/dist/types/src/translations.d.ts +244 -26
  262. package/dist/types/src/translations.d.ts.map +1 -1
  263. package/dist/types/src/types/Assistant.d.ts +20 -20
  264. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  265. package/dist/types/src/types/AssistantAction.d.ts +89 -101
  266. package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
  267. package/dist/types/src/types/capabilities.d.ts +33 -0
  268. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  269. package/dist/types/src/types/events.d.ts +5 -0
  270. package/dist/types/src/types/events.d.ts.map +1 -0
  271. package/dist/types/src/types/index.d.ts +3 -1
  272. package/dist/types/src/types/index.d.ts.map +1 -1
  273. package/dist/types/src/types/service.d.ts +14 -216
  274. package/dist/types/src/types/service.d.ts.map +1 -1
  275. package/dist/types/tsconfig.tsbuildinfo +1 -1
  276. package/package.json +118 -117
  277. package/src/AssistantPlugin.tsx +114 -146
  278. package/src/blueprints/assistant-blueprint.ts +62 -0
  279. package/src/blueprints/index.ts +12 -0
  280. package/src/capabilities/ai-service/ai-service.ts +29 -0
  281. package/src/capabilities/ai-service/index.ts +7 -0
  282. package/src/capabilities/app-graph-builder/app-graph-builder.ts +180 -0
  283. package/src/capabilities/app-graph-builder/index.ts +7 -0
  284. package/src/capabilities/blueprint-definition/blueprint-definition.ts +60 -0
  285. package/src/capabilities/blueprint-definition/index.ts +8 -0
  286. package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +32 -0
  287. package/src/capabilities/edge-model-resolver/index.ts +7 -0
  288. package/src/capabilities/index.ts +10 -14
  289. package/src/capabilities/local-model-resolver/index.ts +7 -0
  290. package/src/capabilities/local-model-resolver/local-model-resolver.ts +37 -0
  291. package/src/capabilities/operation-resolver/index.ts +7 -0
  292. package/src/capabilities/operation-resolver/operation-resolver.ts +110 -0
  293. package/src/capabilities/react-surface/index.ts +7 -0
  294. package/src/capabilities/react-surface/react-surface.tsx +95 -0
  295. package/src/capabilities/repair/index.ts +7 -0
  296. package/src/capabilities/repair/repair.ts +63 -0
  297. package/src/capabilities/settings/index.ts +7 -0
  298. package/src/capabilities/settings/settings.ts +30 -0
  299. package/src/capabilities/state/index.ts +7 -0
  300. package/src/capabilities/state/state.ts +27 -0
  301. package/src/capabilities/toolkit/index.ts +7 -0
  302. package/src/capabilities/toolkit/toolkit.ts +26 -0
  303. package/src/components/AssistantSettings/AssistantSettings.tsx +13 -5
  304. package/src/components/BlueprintArticle.tsx +29 -0
  305. package/src/components/Chat/Chat.tsx +193 -151
  306. package/src/components/Chat/events.ts +7 -1
  307. package/src/components/ChatCompanion.tsx +143 -91
  308. package/src/components/ChatContainer.tsx +40 -30
  309. package/src/components/ChatDialog.tsx +13 -7
  310. package/src/components/ChatProgress/ChatProgress.tsx +4 -18
  311. package/src/components/ChatPrompt/ChatActions.tsx +3 -5
  312. package/src/components/ChatPrompt/ChatOptions.tsx +104 -99
  313. package/src/components/ChatPrompt/ChatReferences.tsx +7 -8
  314. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
  315. package/src/components/ChatThread/ChatThread.stories.tsx +62 -42
  316. package/src/components/ChatThread/ChatThread.tsx +29 -35
  317. package/src/components/ChatThread/Link.tsx +3 -3
  318. package/src/components/ChatThread/reducers.ts +6 -6
  319. package/src/components/ChatThread/registry.tsx +26 -41
  320. package/src/components/ChatThread/sync.test.ts +33 -18
  321. package/src/components/ChatThread/sync.ts +54 -13
  322. package/src/components/ChatThread/testing/thread.md +37 -0
  323. package/src/components/PromptArticle.tsx +50 -0
  324. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +16 -8
  325. package/src/components/TemplateEditor/TemplateEditor.tsx +24 -12
  326. package/src/components/TemplateEditor/TemplateForm.stories.tsx +17 -11
  327. package/src/components/TemplateEditor/TemplateForm.tsx +77 -30
  328. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  329. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  330. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  331. package/src/components/ToolBlock/ToolBlock.tsx +40 -49
  332. package/src/components/Toolbox/Toolbox.stories.tsx +11 -15
  333. package/src/components/Toolbox/Toolbox.tsx +18 -19
  334. package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
  335. package/src/components/Typewriter/Typewriter.stories.tsx +83 -0
  336. package/src/components/Typewriter/Typewriter.tsx +54 -0
  337. package/src/components/Typewriter/assistant-extension.tsx +144 -0
  338. package/src/components/Typewriter/index.ts +5 -0
  339. package/src/components/index.ts +2 -5
  340. package/src/functions/index.ts +3 -3
  341. package/src/functions/{list.ts → object-list.ts} +10 -7
  342. package/src/functions/{load.ts → object-load.ts} +15 -10
  343. package/src/functions/object-search.ts +46 -0
  344. package/src/hooks/index.ts +2 -2
  345. package/src/hooks/useBlueprintRegistry.ts +44 -19
  346. package/src/hooks/useChatProcessor.ts +25 -14
  347. package/src/hooks/useChatServices.ts +16 -17
  348. package/src/hooks/useChatToolbarActions.ts +121 -0
  349. package/src/hooks/useContextBinder.ts +21 -7
  350. package/src/hooks/useContextObjects.ts +13 -25
  351. package/src/hooks/useFilteredTypes.ts +37 -0
  352. package/src/hooks/useReferencesProvider.ts +7 -6
  353. package/src/index.ts +2 -1
  354. package/src/meta.ts +11 -8
  355. package/src/processor/index.ts +1 -0
  356. package/src/processor/presets.ts +2 -2
  357. package/src/processor/processor.test.ts +19 -24
  358. package/src/processor/processor.ts +51 -78
  359. package/src/processor/update-name.ts +59 -0
  360. package/src/queue-logger.ts +8 -9
  361. package/src/testing/index.ts +0 -2
  362. package/src/testing/test-generator.ts +19 -14
  363. package/src/testing/test-services.ts +10 -14
  364. package/src/translations.ts +28 -16
  365. package/src/types/Assistant.ts +13 -12
  366. package/src/types/AssistantAction.ts +65 -52
  367. package/src/types/capabilities.ts +27 -0
  368. package/src/types/events.ts +11 -0
  369. package/src/types/index.ts +3 -1
  370. package/src/types/service.ts +25 -14
  371. package/dist/lib/browser/BlueprintContainer-6MZHBQ25.mjs +0 -29
  372. package/dist/lib/browser/BlueprintContainer-6MZHBQ25.mjs.map +0 -7
  373. package/dist/lib/browser/ChatCompanion-B4DLQE6Y.mjs +0 -124
  374. package/dist/lib/browser/ChatCompanion-B4DLQE6Y.mjs.map +0 -7
  375. package/dist/lib/browser/ChatContainer-Z7A3RKOY.mjs +0 -73
  376. package/dist/lib/browser/ChatContainer-Z7A3RKOY.mjs.map +0 -7
  377. package/dist/lib/browser/ChatDialog-PL5TSGD5.mjs +0 -86
  378. package/dist/lib/browser/ChatDialog-PL5TSGD5.mjs.map +0 -7
  379. package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs +0 -150
  380. package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs.map +0 -7
  381. package/dist/lib/browser/ai-service-4VESSFNB.mjs +0 -18
  382. package/dist/lib/browser/ai-service-4VESSFNB.mjs.map +0 -7
  383. package/dist/lib/browser/app-graph-builder-BBDHBJXA.mjs +0 -153
  384. package/dist/lib/browser/app-graph-builder-BBDHBJXA.mjs.map +0 -7
  385. package/dist/lib/browser/blueprint-definition-3SATLYJW.mjs +0 -12
  386. package/dist/lib/browser/chunk-BBT6KNXA.mjs +0 -165
  387. package/dist/lib/browser/chunk-BBT6KNXA.mjs.map +0 -7
  388. package/dist/lib/browser/chunk-JDI4FEKA.mjs +0 -299
  389. package/dist/lib/browser/chunk-JDI4FEKA.mjs.map +0 -7
  390. package/dist/lib/browser/chunk-O4LUJEDV.mjs +0 -20
  391. package/dist/lib/browser/chunk-O4LUJEDV.mjs.map +0 -7
  392. package/dist/lib/browser/chunk-PQI3MGDN.mjs +0 -169
  393. package/dist/lib/browser/chunk-PQI3MGDN.mjs.map +0 -7
  394. package/dist/lib/browser/chunk-SMIVXXAI.mjs +0 -202
  395. package/dist/lib/browser/chunk-SMIVXXAI.mjs.map +0 -7
  396. package/dist/lib/browser/chunk-TMKK6VCA.mjs +0 -216
  397. package/dist/lib/browser/chunk-TMKK6VCA.mjs.map +0 -7
  398. package/dist/lib/browser/chunk-YKODYEYR.mjs +0 -16
  399. package/dist/lib/browser/chunk-YKODYEYR.mjs.map +0 -7
  400. package/dist/lib/browser/chunk-YOBHCEEI.mjs +0 -1941
  401. package/dist/lib/browser/chunk-YOBHCEEI.mjs.map +0 -7
  402. package/dist/lib/browser/edge-model-resolver-6YWYDPTS.mjs +0 -18
  403. package/dist/lib/browser/edge-model-resolver-6YWYDPTS.mjs.map +0 -7
  404. package/dist/lib/browser/intent-resolver-MRZJU255.mjs +0 -112
  405. package/dist/lib/browser/intent-resolver-MRZJU255.mjs.map +0 -7
  406. package/dist/lib/browser/local-model-resolver-QXLLTV2H.mjs +0 -17
  407. package/dist/lib/browser/local-model-resolver-QXLLTV2H.mjs.map +0 -7
  408. package/dist/lib/browser/react-surface-UKMOARXR.mjs +0 -107
  409. package/dist/lib/browser/react-surface-UKMOARXR.mjs.map +0 -7
  410. package/dist/lib/browser/settings-4AJ34FKF.mjs +0 -23
  411. package/dist/lib/browser/settings-4AJ34FKF.mjs.map +0 -7
  412. package/dist/lib/browser/state-ABR7YSSA.mjs +0 -21
  413. package/dist/lib/browser/state-ABR7YSSA.mjs.map +0 -7
  414. package/dist/lib/browser/toolkit-U7SKGAIC.mjs +0 -191
  415. package/dist/lib/browser/toolkit-U7SKGAIC.mjs.map +0 -7
  416. package/dist/lib/node-esm/BlueprintContainer-MUHW5HNY.mjs +0 -30
  417. package/dist/lib/node-esm/BlueprintContainer-MUHW5HNY.mjs.map +0 -7
  418. package/dist/lib/node-esm/ChatCompanion-DK6FULBU.mjs +0 -125
  419. package/dist/lib/node-esm/ChatCompanion-DK6FULBU.mjs.map +0 -7
  420. package/dist/lib/node-esm/ChatContainer-7IN7ZICQ.mjs +0 -74
  421. package/dist/lib/node-esm/ChatContainer-7IN7ZICQ.mjs.map +0 -7
  422. package/dist/lib/node-esm/ChatDialog-LPE653RZ.mjs +0 -87
  423. package/dist/lib/node-esm/ChatDialog-LPE653RZ.mjs.map +0 -7
  424. package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs +0 -151
  425. package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs.map +0 -7
  426. package/dist/lib/node-esm/ai-service-I5JU4JN2.mjs +0 -19
  427. package/dist/lib/node-esm/ai-service-I5JU4JN2.mjs.map +0 -7
  428. package/dist/lib/node-esm/app-graph-builder-EMR5JF6Z.mjs +0 -154
  429. package/dist/lib/node-esm/app-graph-builder-EMR5JF6Z.mjs.map +0 -7
  430. package/dist/lib/node-esm/chunk-4WLFSXZG.mjs +0 -170
  431. package/dist/lib/node-esm/chunk-4WLFSXZG.mjs.map +0 -7
  432. package/dist/lib/node-esm/chunk-5MYWJPYA.mjs +0 -167
  433. package/dist/lib/node-esm/chunk-5MYWJPYA.mjs.map +0 -7
  434. package/dist/lib/node-esm/chunk-7YOGZI66.mjs +0 -203
  435. package/dist/lib/node-esm/chunk-7YOGZI66.mjs.map +0 -7
  436. package/dist/lib/node-esm/chunk-FHRJMZ7L.mjs +0 -17
  437. package/dist/lib/node-esm/chunk-FHRJMZ7L.mjs.map +0 -7
  438. package/dist/lib/node-esm/chunk-GCNF3CQU.mjs +0 -217
  439. package/dist/lib/node-esm/chunk-GCNF3CQU.mjs.map +0 -7
  440. package/dist/lib/node-esm/chunk-H3ZC4UL7.mjs +0 -300
  441. package/dist/lib/node-esm/chunk-H3ZC4UL7.mjs.map +0 -7
  442. package/dist/lib/node-esm/chunk-VFY2JG62.mjs +0 -22
  443. package/dist/lib/node-esm/chunk-VFY2JG62.mjs.map +0 -7
  444. package/dist/lib/node-esm/chunk-X2YUKRBE.mjs +0 -1942
  445. package/dist/lib/node-esm/chunk-X2YUKRBE.mjs.map +0 -7
  446. package/dist/lib/node-esm/edge-model-resolver-A7B6QHLL.mjs +0 -19
  447. package/dist/lib/node-esm/edge-model-resolver-A7B6QHLL.mjs.map +0 -7
  448. package/dist/lib/node-esm/intent-resolver-CIXO3KMY.mjs +0 -113
  449. package/dist/lib/node-esm/intent-resolver-CIXO3KMY.mjs.map +0 -7
  450. package/dist/lib/node-esm/local-model-resolver-JCYDHAZY.mjs +0 -18
  451. package/dist/lib/node-esm/local-model-resolver-JCYDHAZY.mjs.map +0 -7
  452. package/dist/lib/node-esm/react-surface-5NDJAWA2.mjs +0 -108
  453. package/dist/lib/node-esm/react-surface-5NDJAWA2.mjs.map +0 -7
  454. package/dist/lib/node-esm/settings-K2QW4ATZ.mjs +0 -24
  455. package/dist/lib/node-esm/settings-K2QW4ATZ.mjs.map +0 -7
  456. package/dist/lib/node-esm/state-6UHESJI5.mjs +0 -22
  457. package/dist/lib/node-esm/state-6UHESJI5.mjs.map +0 -7
  458. package/dist/lib/node-esm/toolkit-LNLRBVDU.mjs +0 -192
  459. package/dist/lib/node-esm/toolkit-LNLRBVDU.mjs.map +0 -7
  460. package/dist/types/src/capabilities/ai-service.d.ts +0 -4
  461. package/dist/types/src/capabilities/ai-service.d.ts.map +0 -1
  462. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  463. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  464. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -7
  465. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  466. package/dist/types/src/capabilities/capabilities.d.ts +0 -11
  467. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  468. package/dist/types/src/capabilities/edge-model-resolver.d.ts +0 -4
  469. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +0 -1
  470. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  471. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  472. package/dist/types/src/capabilities/local-model-resolver.d.ts +0 -10
  473. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +0 -1
  474. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  475. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  476. package/dist/types/src/capabilities/settings.d.ts +0 -4
  477. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  478. package/dist/types/src/capabilities/state.d.ts +0 -4
  479. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  480. package/dist/types/src/capabilities/toolkit.d.ts +0 -4
  481. package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
  482. package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
  483. package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
  484. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  485. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  486. package/dist/types/src/components/SequenceContainer.d.ts +0 -8
  487. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  488. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  489. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  490. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -267
  491. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  492. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  493. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  494. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +0 -1
  495. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -5
  496. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  497. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  498. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  499. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +0 -11
  500. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
  501. package/dist/types/src/events.d.ts +0 -4
  502. package/dist/types/src/events.d.ts.map +0 -1
  503. package/dist/types/src/execution-graph/execution-graph.d.ts +0 -21
  504. package/dist/types/src/execution-graph/execution-graph.d.ts.map +0 -1
  505. package/dist/types/src/execution-graph/index.d.ts +0 -2
  506. package/dist/types/src/execution-graph/index.d.ts.map +0 -1
  507. package/dist/types/src/functions/analysis.d.ts +0 -5
  508. package/dist/types/src/functions/analysis.d.ts.map +0 -1
  509. package/dist/types/src/functions/list.d.ts.map +0 -1
  510. package/dist/types/src/functions/load.d.ts.map +0 -1
  511. package/dist/types/src/hooks/useExecutionGraph.d.ts +0 -6
  512. package/dist/types/src/hooks/useExecutionGraph.d.ts.map +0 -1
  513. package/dist/types/src/hooks/useItemTypes.d.ts +0 -4
  514. package/dist/types/src/hooks/useItemTypes.d.ts.map +0 -1
  515. package/dist/types/src/stories/Chat.stories.d.ts +0 -31
  516. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  517. package/dist/types/src/stories/components/BlueprintContainer.d.ts +0 -4
  518. package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +0 -1
  519. package/dist/types/src/stories/components/ChatContainer.d.ts +0 -4
  520. package/dist/types/src/stories/components/ChatContainer.d.ts.map +0 -1
  521. package/dist/types/src/stories/components/ChessContainer.d.ts +0 -4
  522. package/dist/types/src/stories/components/ChessContainer.d.ts.map +0 -1
  523. package/dist/types/src/stories/components/CommentsContainer.d.ts +0 -4
  524. package/dist/types/src/stories/components/CommentsContainer.d.ts.map +0 -1
  525. package/dist/types/src/stories/components/DebugCard.d.ts +0 -8
  526. package/dist/types/src/stories/components/DebugCard.d.ts.map +0 -1
  527. package/dist/types/src/stories/components/GraphContainer.d.ts +0 -6
  528. package/dist/types/src/stories/components/GraphContainer.d.ts.map +0 -1
  529. package/dist/types/src/stories/components/InvocationsContainer.d.ts +0 -4
  530. package/dist/types/src/stories/components/InvocationsContainer.d.ts.map +0 -1
  531. package/dist/types/src/stories/components/LoggingContainer.d.ts +0 -7
  532. package/dist/types/src/stories/components/LoggingContainer.d.ts.map +0 -1
  533. package/dist/types/src/stories/components/MessageContainer.d.ts +0 -4
  534. package/dist/types/src/stories/components/MessageContainer.d.ts.map +0 -1
  535. package/dist/types/src/stories/components/ProjectContainer.d.ts +0 -4
  536. package/dist/types/src/stories/components/ProjectContainer.d.ts.map +0 -1
  537. package/dist/types/src/stories/components/PromptContainer.d.ts +0 -6
  538. package/dist/types/src/stories/components/PromptContainer.d.ts.map +0 -1
  539. package/dist/types/src/stories/components/ResearchInputStack.d.ts +0 -4
  540. package/dist/types/src/stories/components/ResearchInputStack.d.ts.map +0 -1
  541. package/dist/types/src/stories/components/ResearchOutputStack.d.ts +0 -4
  542. package/dist/types/src/stories/components/ResearchOutputStack.d.ts.map +0 -1
  543. package/dist/types/src/stories/components/TasksContainer.d.ts +0 -4
  544. package/dist/types/src/stories/components/TasksContainer.d.ts.map +0 -1
  545. package/dist/types/src/stories/components/TokenManagerContainer.d.ts +0 -3
  546. package/dist/types/src/stories/components/TokenManagerContainer.d.ts.map +0 -1
  547. package/dist/types/src/stories/components/TriggersContainer.d.ts +0 -3
  548. package/dist/types/src/stories/components/TriggersContainer.d.ts.map +0 -1
  549. package/dist/types/src/stories/components/index.d.ts +0 -17
  550. package/dist/types/src/stories/components/index.d.ts.map +0 -1
  551. package/dist/types/src/stories/components/types.d.ts +0 -7
  552. package/dist/types/src/stories/components/types.d.ts.map +0 -1
  553. package/dist/types/src/stories/testing/data.d.ts +0 -9
  554. package/dist/types/src/stories/testing/data.d.ts.map +0 -1
  555. package/dist/types/src/stories/testing/index.d.ts +0 -3
  556. package/dist/types/src/stories/testing/index.d.ts.map +0 -1
  557. package/dist/types/src/stories/testing/schema.d.ts +0 -7
  558. package/dist/types/src/stories/testing/schema.d.ts.map +0 -1
  559. package/dist/types/src/stories/testing/testing.d.ts +0 -48
  560. package/dist/types/src/stories/testing/testing.d.ts.map +0 -1
  561. package/dist/types/src/testing/test-data.d.ts +0 -14
  562. package/dist/types/src/testing/test-data.d.ts.map +0 -1
  563. package/dist/types/src/testing/test-functions.d.ts +0 -6
  564. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  565. package/src/capabilities/ai-service.ts +0 -26
  566. package/src/capabilities/app-graph-builder.ts +0 -162
  567. package/src/capabilities/blueprint-definition.ts +0 -61
  568. package/src/capabilities/capabilities.ts +0 -18
  569. package/src/capabilities/edge-model-resolver.ts +0 -25
  570. package/src/capabilities/intent-resolver.ts +0 -94
  571. package/src/capabilities/local-model-resolver.ts +0 -30
  572. package/src/capabilities/react-surface.tsx +0 -91
  573. package/src/capabilities/settings.ts +0 -19
  574. package/src/capabilities/state.ts +0 -20
  575. package/src/capabilities/toolkit.ts +0 -163
  576. package/src/components/BlueprintContainer.tsx +0 -24
  577. package/src/components/PromptSettings.tsx +0 -90
  578. package/src/components/SequenceContainer.tsx +0 -131
  579. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -33
  580. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  581. package/src/components/SequenceEditor/index.ts +0 -5
  582. package/src/components/TemplateEditor/handlebars-extension.ts +0 -165
  583. package/src/components/Toolbar/Toolbar.tsx +0 -21
  584. package/src/components/Toolbar/index.ts +0 -5
  585. package/src/components/Toolbar/useChatToolbarActions.ts +0 -126
  586. package/src/events.ts +0 -11
  587. package/src/execution-graph/execution-graph.ts +0 -211
  588. package/src/execution-graph/index.ts +0 -5
  589. package/src/functions/analysis.ts +0 -20
  590. package/src/hooks/useExecutionGraph.ts +0 -20
  591. package/src/hooks/useItemTypes.ts +0 -37
  592. package/src/stories/Chat.stories.tsx +0 -804
  593. package/src/stories/components/BlueprintContainer.tsx +0 -34
  594. package/src/stories/components/ChatContainer.tsx +0 -74
  595. package/src/stories/components/ChessContainer.tsx +0 -17
  596. package/src/stories/components/CommentsContainer.tsx +0 -25
  597. package/src/stories/components/DebugCard.tsx +0 -61
  598. package/src/stories/components/GraphContainer.tsx +0 -119
  599. package/src/stories/components/InvocationsContainer.tsx +0 -17
  600. package/src/stories/components/LoggingContainer.tsx +0 -33
  601. package/src/stories/components/MessageContainer.tsx +0 -22
  602. package/src/stories/components/ProjectContainer.tsx +0 -17
  603. package/src/stories/components/PromptContainer.tsx +0 -52
  604. package/src/stories/components/ResearchInputStack.tsx +0 -30
  605. package/src/stories/components/ResearchOutputStack.tsx +0 -29
  606. package/src/stories/components/TasksContainer.tsx +0 -49
  607. package/src/stories/components/TokenManagerContainer.tsx +0 -14
  608. package/src/stories/components/TriggersContainer.tsx +0 -12
  609. package/src/stories/components/index.ts +0 -21
  610. package/src/stories/components/types.ts +0 -11
  611. package/src/stories/testing/data.ts +0 -142
  612. package/src/stories/testing/index.ts +0 -6
  613. package/src/stories/testing/schema.ts +0 -17
  614. package/src/stories/testing/testing.tsx +0 -284
  615. package/src/testing/test-data.ts +0 -255
  616. package/src/testing/test-functions.ts +0 -16
  617. /package/dist/lib/browser/{blueprint-definition-3SATLYJW.mjs.map → blueprint-definition-DGHH7MUU.mjs.map} +0 -0
  618. /package/dist/lib/{node-esm/blueprint-definition-B6UDX5U3.mjs.map → browser/blueprints/index.mjs.map} +0 -0
  619. /package/dist/types/src/components/TemplateEditor/{handlebars-extension.d.ts → extensions/handlebars-extension.d.ts} +0 -0
@@ -1,1942 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- meta
4
- } from "./chunk-VFY2JG62.mjs";
5
-
6
- // src/hooks/useBlueprintRegistry.ts
7
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
8
- import { useSignalEffect } from "@preact/signals-react";
9
- import { useCallback, useMemo, useState } from "react";
10
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
11
- import { Blueprint } from "@dxos/blueprints";
12
- import { Filter, Obj, Ref } from "@dxos/echo";
13
- import { isNonNullable } from "@dxos/util";
14
- var useBlueprintRegistry = () => {
15
- const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
16
- return useMemo(() => new Blueprint.Registry(blueprints), [
17
- blueprints
18
- ]);
19
- };
20
- var useBlueprints = ({ blueprintRegistry }) => useMemo(() => blueprintRegistry?.query() ?? [], [
21
- blueprintRegistry
22
- ]);
23
- var useActiveBlueprints = ({ context }) => {
24
- var _effect = _useSignals();
25
- try {
26
- const [active, setActive] = useState(/* @__PURE__ */ new Map());
27
- useSignalEffect(() => {
28
- const refs = [
29
- ...context?.blueprints.value ?? []
30
- ];
31
- const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
32
- setActive(new Map(blueprints.map((blueprint) => [
33
- blueprint.key,
34
- blueprint
35
- ])));
36
- });
37
- return active;
38
- } finally {
39
- _effect.f();
40
- }
41
- };
42
- var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
43
- const onUpdateBlueprint = useCallback(async (key, checked) => {
44
- if (!context || !blueprintRegistry) {
45
- return;
46
- }
47
- const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
48
- let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
49
- if (checked) {
50
- if (!storedBlueprint) {
51
- const blueprint = blueprintRegistry.getByKey(key);
52
- if (!blueprint) {
53
- return;
54
- }
55
- storedBlueprint = space.db.add(Obj.clone(blueprint));
56
- }
57
- await context.bind({
58
- blueprints: [
59
- Ref.make(storedBlueprint)
60
- ]
61
- });
62
- } else if (storedBlueprint) {
63
- await context.unbind({
64
- blueprints: [
65
- Ref.make(storedBlueprint)
66
- ]
67
- });
68
- }
69
- }, [
70
- space,
71
- context,
72
- blueprintRegistry
73
- ]);
74
- return {
75
- onUpdateBlueprint
76
- };
77
- };
78
-
79
- // src/hooks/useChatProcessor.ts
80
- import { RegistryContext } from "@effect-rx/rx-react";
81
- import { useContext, useMemo as useMemo2 } from "react";
82
- import { AiConversation } from "@dxos/assistant";
83
- import { log as log2 } from "@dxos/log";
84
-
85
- // src/processor/presets.ts
86
- import { Schema } from "effect";
87
- var ModelProviders = [
88
- "dxos-local",
89
- "dxos-remote",
90
- "lm-studio"
91
- ];
92
- var ModelProvider = Schema.Literal(...ModelProviders);
93
- var createModelLabel = (model) => {
94
- const parts = model.split("/");
95
- return parts[parts.length - 1];
96
- };
97
- var AiServicePresets = [
98
- {
99
- provider: "dxos-remote",
100
- model: "@anthropic/claude-opus-4-0"
101
- },
102
- {
103
- provider: "dxos-remote",
104
- model: "@anthropic/claude-sonnet-4-0"
105
- },
106
- {
107
- provider: "dxos-remote",
108
- model: "@anthropic/claude-3-5-haiku-20241022"
109
- },
110
- {
111
- provider: "lm-studio",
112
- model: "@google/gemma-3-27b"
113
- },
114
- {
115
- provider: "lm-studio",
116
- model: "@mlx-community/llama-3.2-3b-instruct"
117
- },
118
- {
119
- model: "deepseek-r1:latest",
120
- provider: "dxos-local"
121
- }
122
- ].map(({ model, provider }, i) => ({
123
- id: `preset-${i}`,
124
- provider,
125
- model,
126
- label: createModelLabel(model)
127
- }));
128
-
129
- // src/processor/processor.ts
130
- import { Registry, Rx } from "@effect-rx/rx-react";
131
- import { Cause, Effect, Exit, Fiber, Option, Runtime } from "effect";
132
- import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
133
- import { AiSession, ArtifactDiffResolver, GenerationObserver, createSystemPrompt } from "@dxos/assistant";
134
- import { Obj as Obj2 } from "@dxos/echo";
135
- import { throwCause } from "@dxos/effect";
136
- import { log } from "@dxos/log";
137
- import { DataType } from "@dxos/schema";
138
- import { trim } from "@dxos/util";
139
- function _define_property(obj, key, value) {
140
- if (key in obj) {
141
- Object.defineProperty(obj, key, {
142
- value,
143
- enumerable: true,
144
- configurable: true,
145
- writable: true
146
- });
147
- } else {
148
- obj[key] = value;
149
- }
150
- return obj;
151
- }
152
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
153
- var defaultOptions = {
154
- model: DEFAULT_EDGE_MODEL
155
- };
156
- var AiChatProcessor = class {
157
- get context() {
158
- return this._conversation.context;
159
- }
160
- get conversation() {
161
- return this._conversation;
162
- }
163
- get blueprintRegistry() {
164
- return this._options.blueprintRegistry;
165
- }
166
- /**
167
- * Initiates a new request.
168
- */
169
- async request(requestParam) {
170
- if (this._fiber) {
171
- await this.cancel();
172
- }
173
- try {
174
- this._lastRequest = requestParam;
175
- this._rx.set(this.error, Option.none());
176
- this._rx.set(this.active, true);
177
- const request = this._conversation.createRequest({
178
- system: this._options.system,
179
- prompt: requestParam.message,
180
- observer: this._observer
181
- });
182
- const runtime = await this._services();
183
- this._fiber = request.pipe(
184
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
185
- // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
186
- Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
187
- Effect.asVoid,
188
- Effect.tapErrorCause((cause) => {
189
- log.error("request failed", {
190
- cause
191
- }, {
192
- F: __dxlog_file,
193
- L: 170,
194
- S: this,
195
- C: (f, a) => f(...a)
196
- });
197
- return Effect.void;
198
- }),
199
- Runtime.runFork(runtime)
200
- );
201
- const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
202
- if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
203
- throwCause(response.cause);
204
- }
205
- this._rx.set(this.error, Option.none());
206
- this._lastRequest = void 0;
207
- this._fiber = void 0;
208
- } catch (err) {
209
- log.error("request failed", {
210
- err
211
- }, {
212
- F: __dxlog_file,
213
- L: 186,
214
- S: this,
215
- C: (f, a) => f(...a)
216
- });
217
- this._rx.set(this.error, Option.some(new Error("AI service error", {
218
- cause: err
219
- })));
220
- } finally {
221
- this._fiber = void 0;
222
- this._rx.set(this.active, false);
223
- }
224
- }
225
- /**
226
- * Cancels the current request.
227
- */
228
- async cancel() {
229
- await Effect.runPromise(Effect.gen(this, function* () {
230
- if (this._fiber) {
231
- yield* this._fiber.pipe(Fiber.interrupt);
232
- }
233
- }));
234
- this._fiber = void 0;
235
- this._rx.set(this.active, false);
236
- }
237
- /**
238
- * Retry last failed request.
239
- */
240
- async retry() {
241
- if (this._lastRequest) {
242
- return this.request(this._lastRequest);
243
- }
244
- }
245
- /**
246
- * Update the current chat's name.
247
- */
248
- async updateName(chat) {
249
- const runtime = await this._services();
250
- const system = trim`
251
- It is extremely important that you respond only with the title and nothing else.
252
- If you cannot do this effectively respond with "New Chat".
253
- `;
254
- const history = await this._conversation.getHistory();
255
- const fiber = Effect.gen(this, function* () {
256
- const session = new AiSession();
257
- return yield* session.run({
258
- system,
259
- prompt: "Suggest a name for this chat",
260
- history
261
- });
262
- }).pipe(
263
- // TODO(burdon): Use simpler model.
264
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
265
- Effect.tap((messages) => {
266
- const message = messages.find((message2) => message2.sender.role === "assistant");
267
- const title = message?.blocks.find((b) => b._tag === "text")?.text;
268
- if (title) {
269
- chat.name = title;
270
- }
271
- }),
272
- Runtime.runFork(runtime)
273
- );
274
- const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
275
- if (!Exit.isSuccess(response)) {
276
- throwCause(response.cause);
277
- }
278
- }
279
- constructor(_conversation, _services, _options = defaultOptions) {
280
- _define_property(this, "_conversation", void 0);
281
- _define_property(this, "_services", void 0);
282
- _define_property(this, "_options", void 0);
283
- _define_property(this, "_rx", void 0);
284
- _define_property(this, "_observer", void 0);
285
- _define_property(this, "_fiber", void 0);
286
- _define_property(this, "_lastRequest", void 0);
287
- _define_property(this, "_pending", void 0);
288
- _define_property(this, "_streaming", void 0);
289
- _define_property(this, "streaming", void 0);
290
- _define_property(this, "active", void 0);
291
- _define_property(this, "messages", void 0);
292
- _define_property(this, "error", void 0);
293
- _define_property(this, "_artifactDiffResolver", void 0);
294
- _define_property(this, "_onMessage", void 0);
295
- _define_property(this, "_onBlock", void 0);
296
- this._conversation = _conversation;
297
- this._services = _services;
298
- this._options = _options;
299
- this._pending = Rx.make([]);
300
- this._streaming = Rx.make(Option.none());
301
- this.streaming = Rx.make((get) => Option.isSome(get(this._streaming)));
302
- this.active = Rx.make(false);
303
- this.messages = Rx.make((get) => Option.match(get(this._streaming), {
304
- onNone: () => get(this._pending),
305
- onSome: (streaming) => [
306
- ...get(this._pending),
307
- streaming
308
- ]
309
- }));
310
- this.error = Rx.make(Option.none());
311
- this._artifactDiffResolver = {
312
- resolve: async (_artifacts) => {
313
- const versions = /* @__PURE__ */ new Map();
314
- return versions;
315
- }
316
- };
317
- this._onMessage = Effect.fn((function* (message) {
318
- this._rx.set(this._streaming, Option.none());
319
- this._rx.update(this._pending, (pending) => [
320
- ...pending,
321
- message
322
- ]);
323
- }).bind(this));
324
- this._onBlock = Effect.fn((function* (block) {
325
- this._rx.update(this._streaming, (streaming) => {
326
- const blocks = streaming.pipe(Option.map((streaming2) => streaming2.blocks.filter((b) => !b.pending)), Option.getOrElse(() => []));
327
- return Option.some(Obj2.make(DataType.Message, {
328
- created: (/* @__PURE__ */ new Date()).toISOString(),
329
- sender: {
330
- role: "assistant"
331
- },
332
- blocks: [
333
- ...blocks,
334
- block
335
- ]
336
- }));
337
- });
338
- }).bind(this));
339
- this._rx = this._options.observableRegistry ?? Registry.make();
340
- this._observer = GenerationObserver.make({
341
- onBlock: this._onBlock,
342
- onMessage: this._onMessage
343
- });
344
- if (this._options.model && !this._options.system) {
345
- const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
346
- this._options.system = createSystemPrompt(capabilities);
347
- }
348
- }
349
- };
350
-
351
- // src/hooks/useChatProcessor.ts
352
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
353
- var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
354
- const observableRegistry = useContext(RegistryContext);
355
- const conversation = useMemo2(() => {
356
- if (!chat?.queue.target) {
357
- return;
358
- }
359
- return new AiConversation({
360
- queue: chat.queue.target
361
- });
362
- }, [
363
- chat?.queue.target
364
- ]);
365
- const processor = useMemo2(() => {
366
- if (!services || !conversation) {
367
- return void 0;
368
- }
369
- log2("creating processor", {
370
- preset,
371
- model: preset?.model,
372
- settings
373
- }, {
374
- F: __dxlog_file2,
375
- L: 52,
376
- S: void 0,
377
- C: (f, a) => f(...a)
378
- });
379
- return new AiChatProcessor(conversation, services, {
380
- observableRegistry,
381
- blueprintRegistry,
382
- model: preset?.model
383
- });
384
- }, [
385
- services,
386
- conversation,
387
- blueprintRegistry,
388
- preset
389
- ]);
390
- return processor;
391
- };
392
-
393
- // src/hooks/useChatServices.ts
394
- import { Effect as Effect2 } from "effect";
395
- import { useMemo as useMemo3 } from "react";
396
- import { useCapability } from "@dxos/app-framework";
397
- import { TracingService } from "@dxos/functions";
398
- import { AutomationCapabilities } from "@dxos/plugin-automation";
399
- import { useClient } from "@dxos/react-client";
400
- var useChatServices = ({ space, chat }) => {
401
- const client = useClient();
402
- space ?? (space = client.spaces.default);
403
- const computeRuntimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
404
- return useMemo3(() => {
405
- const runtime = computeRuntimeResolver.getRuntime(space.id);
406
- return () => runtime.runPromise(Effect2.gen(function* () {
407
- return yield* Effect2.runtime().pipe(Effect2.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
408
- }));
409
- }, [
410
- space,
411
- chat?.traceQueue?.target
412
- ]);
413
- };
414
-
415
- // src/hooks/useContextBinder.ts
416
- import { useMemo as useMemo4 } from "react";
417
- import { AiContextBinder } from "@dxos/assistant";
418
- var useContextBinder = (chat) => {
419
- const binder = useMemo4(() => {
420
- const queue = chat?.queue.target;
421
- return queue && new AiContextBinder(queue);
422
- }, [
423
- chat
424
- ]);
425
- return binder;
426
- };
427
-
428
- // src/hooks/useOnline.ts
429
- import { useState as useState2 } from "react";
430
- var useOnline = () => {
431
- const [online, setOnline] = useState2(true);
432
- return [
433
- online,
434
- setOnline
435
- ];
436
- };
437
-
438
- // src/hooks/usePresets.ts
439
- import { useCallback as useCallback2, useEffect, useMemo as useMemo5, useState as useState3 } from "react";
440
- var usePresets = (online) => {
441
- const [preset, setPreset] = useState3();
442
- const presets = useMemo5(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
443
- online
444
- ]);
445
- const presetOptions = useMemo5(() => presets.map(({ id, model, label }) => ({
446
- id,
447
- label: label ?? model
448
- })), [
449
- presets
450
- ]);
451
- useEffect(() => {
452
- setPreset(presets[0]);
453
- }, [
454
- presets
455
- ]);
456
- const handlePresetChange = useCallback2((id) => {
457
- const preset2 = presets.find((preset3) => preset3.id === id);
458
- if (preset2) {
459
- setPreset(preset2);
460
- }
461
- }, [
462
- presets
463
- ]);
464
- return {
465
- preset,
466
- presets: presetOptions,
467
- onPresetChange: handlePresetChange
468
- };
469
- };
470
-
471
- // src/hooks/useContextObjects.ts
472
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
473
- import { useCallback as useCallback3 } from "react";
474
- import { Ref as Ref2 } from "@dxos/echo";
475
- import { log as log3 } from "@dxos/log";
476
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
477
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
478
- var useContextObjects = ({ space, context }) => {
479
- var _effect = _useSignals2();
480
- try {
481
- const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
482
- const handleUpdateObject = useCallback3(async (dxn, checked) => {
483
- if (!space || !context) {
484
- return;
485
- }
486
- const id = dxn.asEchoDXN();
487
- const object = id && await space.db.getObjectById(id.echoId);
488
- if (!object) {
489
- log3.warn("Object not found", {
490
- dxn,
491
- id
492
- }, {
493
- F: __dxlog_file3,
494
- L: 40,
495
- S: void 0,
496
- C: (f, a) => f(...a)
497
- });
498
- return;
499
- }
500
- const ref = Ref2.fromDXN(dxn);
501
- if (checked) {
502
- await context.bind({
503
- objects: [
504
- ref
505
- ]
506
- });
507
- } else {
508
- await context.unbind({
509
- objects: [
510
- ref
511
- ]
512
- });
513
- }
514
- }, [
515
- space,
516
- context
517
- ]);
518
- return {
519
- objects,
520
- onUpdateObject: handleUpdateObject
521
- };
522
- } finally {
523
- _effect.f();
524
- }
525
- };
526
-
527
- // src/hooks/useExecutionGraph.ts
528
- import { useMemo as useMemo6 } from "react";
529
- import { Obj as Obj4 } from "@dxos/echo";
530
- import { useQueue } from "@dxos/react-client/echo";
531
-
532
- // src/execution-graph/execution-graph.ts
533
- import { AgentStatus } from "@dxos/ai";
534
- import { Obj as Obj3 } from "@dxos/echo";
535
- import { MESSAGE_PROPERTY_TOOL_CALL_ID } from "@dxos/functions";
536
- import { LogLevel } from "@dxos/log";
537
- import { ContentBlock, DataType as DataType2 } from "@dxos/schema";
538
- import { isNotFalsy } from "@dxos/util";
539
- function _define_property2(obj, key, value) {
540
- if (key in obj) {
541
- Object.defineProperty(obj, key, {
542
- value,
543
- enumerable: true,
544
- configurable: true,
545
- writable: true
546
- });
547
- } else {
548
- obj[key] = value;
549
- }
550
- return obj;
551
- }
552
- var ExecutionGraph = class {
553
- /**
554
- * Adds events to the graph.
555
- */
556
- addEvents(events) {
557
- for (const event of events) {
558
- if (Obj3.instanceOf(DataType2.Message, event)) {
559
- const messageCommits = messageToCommit(event);
560
- this._commits.push(...messageCommits);
561
- messageCommits.map((c) => c.branch).forEach((branch) => this._branchNames.add(branch));
562
- } else if (Obj3.instanceOf(AgentStatus, event)) {
563
- const branch = getBranchName({
564
- parentMessage: event.parentMessage,
565
- toolCallId: event.toolCallId
566
- });
567
- this._branchNames.add(branch);
568
- this._commits.push({
569
- id: event.id,
570
- branch,
571
- message: event.message,
572
- icon: "ph--flag--regular",
573
- parents: event.parentMessage && event.toolCallId ? [
574
- getToolCallId(event.parentMessage, event.toolCallId)
575
- ] : void 0
576
- });
577
- }
578
- }
579
- }
580
- /**
581
- * Returns the current state of the graph.
582
- */
583
- getGraph(lastRequest = false) {
584
- const idx = lastRequest ? this._commits.findLastIndex((c) => c.tags?.includes("user")) : -1;
585
- const commits = idx === -1 ? this._commits : this._commits.slice(idx);
586
- return {
587
- branches: Array.from(this._branchNames),
588
- commits
589
- };
590
- }
591
- constructor() {
592
- _define_property2(this, "_commits", []);
593
- _define_property2(this, "_branchNames", /* @__PURE__ */ new Set());
594
- }
595
- };
596
- var messageToCommit = (message) => {
597
- return message.blocks.map((block, idx) => {
598
- const branch = getMessageBranch(message);
599
- const parent = getParentId(message);
600
- const parents = parent ? [
601
- parent
602
- ] : [];
603
- switch (block._tag) {
604
- case "text":
605
- if (!block.text.trim().length) {
606
- return null;
607
- }
608
- return {
609
- id: getGenericBlockId(message.id, idx),
610
- branch,
611
- parents,
612
- ...message.sender.role === "user" ? {
613
- icon: "ph--user--regular",
614
- tags: [
615
- "user"
616
- ],
617
- message: "Processing request..."
618
- } : {
619
- icon: "ph--robot--regular",
620
- message: `Response (${block.text.split(" ").length} words)`
621
- }
622
- };
623
- case "toolCall":
624
- return {
625
- id: getToolCallId(message.id, block.toolCallId),
626
- branch,
627
- parents,
628
- icon: "ph--wrench--regular",
629
- level: LogLevel.INFO,
630
- // TODO(burdon): Lookup tool name/description?
631
- message: `Calling tool (${block.name})`
632
- };
633
- case "toolResult":
634
- return {
635
- id: getToolResultId(message.id, block.toolCallId),
636
- branch,
637
- parents,
638
- icon: block.error ? "ph--x-circle--regular" : "ph--check-circle--regular",
639
- level: block.error ? LogLevel.ERROR : LogLevel.INFO,
640
- message: block.error ? "Tool error: " + block.error : "Tool call succeeded"
641
- };
642
- case "summary":
643
- return {
644
- id: getGenericBlockId(message.id, idx),
645
- branch,
646
- parents,
647
- icon: "ph--rocket--regular",
648
- level: LogLevel.INFO,
649
- message: ContentBlock.createSummaryMessage(block)
650
- };
651
- case "status":
652
- return {
653
- id: getGenericBlockId(message.id, idx),
654
- branch,
655
- parents,
656
- message: block.statusText,
657
- level: LogLevel.INFO,
658
- icon: "ph--flag--regular"
659
- };
660
- case "reasoning":
661
- return {
662
- id: getGenericBlockId(message.id, idx),
663
- branch,
664
- parents,
665
- message: block.reasoningText ?? "Thinking...",
666
- icon: "ph--brain--regular"
667
- };
668
- case "reference":
669
- return {
670
- id: getGenericBlockId(message.id, idx),
671
- branch,
672
- parents,
673
- icon: "ph--link--regular",
674
- message: stringifyRef(block.reference)
675
- };
676
- default:
677
- return null;
678
- }
679
- }).filter(isNotFalsy);
680
- };
681
- var getToolCallId = (messageId, toolCallId) => `${messageId}_toolCall_${toolCallId}`;
682
- var getToolResultId = (messageId, toolCallId) => `${messageId}_toolResult_${toolCallId}`;
683
- var getGenericBlockId = (messageId, idx) => `${messageId}_block_${idx}`;
684
- var getBranchName = (options) => {
685
- if (options.parentMessage && options.toolCallId) {
686
- return `${options.parentMessage}_${options.toolCallId}`;
687
- } else if (options.parentMessage) {
688
- return options.parentMessage;
689
- } else {
690
- return "main";
691
- }
692
- };
693
- var getMessageBranch = (message) => {
694
- return getBranchName({
695
- parentMessage: message.parentMessage,
696
- toolCallId: message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]
697
- });
698
- };
699
- var getParentId = (message) => {
700
- if (message.parentMessage && message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]) {
701
- return getToolCallId(message.parentMessage, message.properties[MESSAGE_PROPERTY_TOOL_CALL_ID]);
702
- } else {
703
- return void 0;
704
- }
705
- };
706
- var stringifyRef = (ref) => {
707
- if (ref.target) {
708
- return stringifyObject(ref.target);
709
- }
710
- return ref.dxn.asEchoDXN()?.echoId ?? ref.dxn.asQueueDXN()?.objectId ?? "";
711
- };
712
- var stringifyObject = (obj) => {
713
- return Obj3.getLabel(obj) ?? Obj3.getTypename(obj) ?? obj.id;
714
- };
715
-
716
- // src/hooks/useExecutionGraph.ts
717
- var useExecutionGraph = (queueRef, lastRequest = false) => {
718
- const queue = useQueue(queueRef?.dxn);
719
- return useMemo6(() => {
720
- const graph = new ExecutionGraph();
721
- graph.addEvents(queue?.objects.filter(Obj4.isObject) ?? []);
722
- return graph.getGraph(lastRequest);
723
- }, [
724
- queue?.objects,
725
- lastRequest
726
- ]);
727
- };
728
-
729
- // src/hooks/useFlush.ts
730
- import { useCallback as useCallback4, useRef, useState as useState4 } from "react";
731
-
732
- // src/hooks/useItemTypes.ts
733
- import { Option as Option2 } from "effect";
734
- import { useEffect as useEffect2, useState as useState5 } from "react";
735
- import { ItemAnnotation } from "@dxos/schema";
736
- var useItemTypes = (space) => {
737
- const [types, setTypes] = useState5([]);
738
- useEffect2(() => {
739
- if (!space) {
740
- return;
741
- }
742
- return space.db.schemaRegistry.query().subscribe((query) => {
743
- const types2 = Array.from(new Set([
744
- ...space.db.graph.schemaRegistry.schemas,
745
- ...query.results
746
- ].filter((type) => Option2.isSome(ItemAnnotation.get(type)))));
747
- setTypes(types2);
748
- }, {
749
- fire: true
750
- });
751
- }, [
752
- space
753
- ]);
754
- return types;
755
- };
756
-
757
- // src/hooks/useReferencesProvider.ts
758
- import { useMemo as useMemo7 } from "react";
759
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
760
- import { Filter as Filter2, Obj as Obj5 } from "@dxos/echo";
761
- var useReferencesProvider = (space) => {
762
- const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
763
- return useMemo7(() => {
764
- if (!space) {
765
- return void 0;
766
- }
767
- return {
768
- getReferences: async ({ query }) => {
769
- const { objects } = await space.db.query(Filter2.everything()).run();
770
- return objects.filter((object) => stringMatch(query, Obj5.getLabel(object) ?? "")).filter((object) => !!Obj5.getDXN(object)).map((object) => ({
771
- uri: Obj5.getDXN(object).toString(),
772
- label: Obj5.getLabel(object) ?? ""
773
- }));
774
- },
775
- resolveReference: async ({ uri }) => {
776
- const object = await space.db.query(Filter2.ids(uri)).first();
777
- return {
778
- uri,
779
- label: Obj5.getLabel(object) ?? ""
780
- };
781
- }
782
- };
783
- }, [
784
- space,
785
- blueprints
786
- ]);
787
- };
788
- var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
789
-
790
- // src/components/Chat/Chat.tsx
791
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
792
- import { Prec } from "@codemirror/state";
793
- import { keymap } from "@codemirror/view";
794
- import { useRxValue } from "@effect-rx/rx-react";
795
- import { createContext } from "@radix-ui/react-context";
796
- import { Array as Array2, Option as Option3 } from "effect";
797
- import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo11, useRef as useRef3, useState as useState10 } from "react";
798
- import { Event } from "@dxos/async";
799
- import { Obj as Obj8 } from "@dxos/echo";
800
- import { useVoiceInput } from "@dxos/plugin-transcription";
801
- import { getSpace, useQueue as useQueue2 } from "@dxos/react-client/echo";
802
- import { useIdentity } from "@dxos/react-client/halo";
803
- import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
804
- import { ChatEditor, references } from "@dxos/react-ui-chat";
805
- import { mx as mx5 } from "@dxos/react-ui-theme";
806
- import { DataType as DataType3 } from "@dxos/schema";
807
- import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
808
-
809
- // src/components/ChatPrompt/ChatActions.tsx
810
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
811
- import React from "react";
812
- import { IconButton, useTranslation } from "@dxos/react-ui";
813
- import { mx } from "@dxos/react-ui-theme";
814
- var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
815
- var _effect = _useSignals3();
816
- try {
817
- const { t } = useTranslation(meta.id);
818
- return /* @__PURE__ */ React.createElement("div", {
819
- className: mx("flex items-center mie-1", classNames)
820
- }, children, /* @__PURE__ */ React.createElement(IconButton, {
821
- disabled: !processing,
822
- variant: "ghost",
823
- size: 5,
824
- icon: "ph--x--regular",
825
- iconOnly: true,
826
- label: t("button cancel processing"),
827
- onClick: () => onEvent?.({
828
- type: "cancel"
829
- })
830
- }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
831
- disabled: !processing,
832
- classNames: mx(recording && "bg-primary-500"),
833
- variant: "ghost",
834
- size: 5,
835
- icon: "ph--microphone--regular",
836
- iconOnly: true,
837
- noTooltip: true,
838
- label: t("button microphone"),
839
- onMouseDown: () => onEvent?.({
840
- type: "record-start"
841
- }),
842
- onMouseUp: () => onEvent?.({
843
- type: "record-stop"
844
- }),
845
- onTouchStart: () => onEvent?.({
846
- type: "record-start"
847
- }),
848
- onTouchEnd: () => onEvent?.({
849
- type: "record-stop"
850
- })
851
- }));
852
- } finally {
853
- _effect.f();
854
- }
855
- };
856
-
857
- // src/components/ChatPrompt/ChatOptions.tsx
858
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
859
- import React2, { useMemo as useMemo8, useState as useState6 } from "react";
860
- import { Filter as Filter3, Obj as Obj6, Type } from "@dxos/echo";
861
- import { useQuery } from "@dxos/react-client/echo";
862
- import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
863
- import { SearchList } from "@dxos/react-ui-searchlist";
864
- import { Tabs } from "@dxos/react-ui-tabs";
865
- var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-[25rem] max-is-[--text-content]";
866
- var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
867
- var _effect = _useSignals4();
868
- try {
869
- const { t } = useTranslation2(meta.id);
870
- return /* @__PURE__ */ React2.createElement("div", {
871
- role: "none",
872
- className: "flex gap-0.5"
873
- }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
874
- asChild: true
875
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
876
- variant: "ghost",
877
- icon: "ph--plus--regular",
878
- iconOnly: true,
879
- size: 5,
880
- label: t("button context objects")
881
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
882
- side: "top",
883
- classNames: panelClassNames
884
- }, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
885
- space,
886
- context
887
- }), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
888
- asChild: true
889
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
890
- variant: "ghost",
891
- icon: "ph--sliders-horizontal--regular",
892
- iconOnly: true,
893
- size: 5,
894
- label: t("button context settings")
895
- })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
896
- side: "top",
897
- classNames: panelClassNames
898
- }, /* @__PURE__ */ React2.createElement(Tabs.Root, {
899
- orientation: "horizontal",
900
- defaultValue: "blueprints",
901
- defaultActivePart: "list"
902
- }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
903
- classNames: 'max-bs-[--radix-popover-content-available-height] grid grid-rows-[1fr_min-content] [&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content] [&_[role="listbox"]]:min-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'
904
- }, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
905
- value: "blueprints"
906
- }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
907
- blueprintRegistry,
908
- space,
909
- context
910
- })), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
911
- value: "model"
912
- }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
913
- presets,
914
- preset,
915
- onPresetChange
916
- })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
917
- classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
918
- }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
919
- value: "blueprints",
920
- icon: "ph--blueprint--regular",
921
- label: t("blueprints in context title")
922
- }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
923
- value: "model",
924
- label: t("chat model title"),
925
- icon: "ph--cpu--regular"
926
- })))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
927
- } finally {
928
- _effect.f();
929
- }
930
- };
931
- var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
932
- var _effect = _useSignals4();
933
- try {
934
- const { t } = useTranslation2(meta.id);
935
- const blueprints = useBlueprints({
936
- blueprintRegistry
937
- });
938
- const activeBlueprints = useActiveBlueprints({
939
- context
940
- });
941
- const { onUpdateBlueprint } = useBlueprintHandlers({
942
- space,
943
- context,
944
- blueprintRegistry
945
- });
946
- return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
947
- classNames: "plb-cardSpacingChrome"
948
- }, blueprints.map((blueprint) => {
949
- const isActive = activeBlueprints.has(blueprint.key);
950
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
951
- classNames: "flex items-center overflow-hidden",
952
- key: blueprint.key,
953
- value: blueprint.name,
954
- onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
955
- }, /* @__PURE__ */ React2.createElement("div", {
956
- className: "grow truncate"
957
- }, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
958
- icon: "ph--check--regular",
959
- classNames: [
960
- !isActive && "invisible"
961
- ]
962
- }));
963
- })), /* @__PURE__ */ React2.createElement(SearchList.Input, {
964
- placeholder: t("search placeholder"),
965
- classNames: "mbe-cardSpacingChrome"
966
- }));
967
- } finally {
968
- _effect.f();
969
- }
970
- };
971
- var ModelsPanel = ({ presets, preset, onPresetChange }) => {
972
- var _effect = _useSignals4();
973
- try {
974
- return /* @__PURE__ */ React2.createElement("ul", {
975
- role: "listbox",
976
- className: "plb-cardSpacingChrome"
977
- }, presets?.map(({ id, label }) => {
978
- const isActive = preset === id;
979
- return /* @__PURE__ */ React2.createElement("li", {
980
- role: "option",
981
- key: id,
982
- "aria-selected": isActive,
983
- tabIndex: 0,
984
- className: "overflow-hidden dx-focus-ring flex gap-2 p-1 pis-2 pie-2 items-center rounded-sm select-none cursor-pointer hover:bg-hoverOverlay",
985
- onClick: () => onPresetChange?.(id)
986
- }, /* @__PURE__ */ React2.createElement("div", {
987
- className: "grow truncate"
988
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
989
- icon: "ph--check--regular",
990
- classNames: [
991
- !isActive && "invisible"
992
- ]
993
- }));
994
- }));
995
- } finally {
996
- _effect.f();
997
- }
998
- };
999
- var ANY = "__any__";
1000
- var ObjectsPanel = ({ space, context }) => {
1001
- var _effect = _useSignals4();
1002
- try {
1003
- const { t } = useTranslation2(meta.id);
1004
- const types = useItemTypes(space);
1005
- const typenames = useMemo8(() => {
1006
- const typenames2 = types.map((type) => {
1007
- const typename2 = Type.getTypename(type);
1008
- return {
1009
- typename: typename2,
1010
- label: t("typename label", {
1011
- ns: typename2,
1012
- defaultValue: typename2
1013
- })
1014
- };
1015
- });
1016
- typenames2.sort((a, b) => a.label.localeCompare(b.label));
1017
- return typenames2;
1018
- }, [
1019
- types
1020
- ]);
1021
- const [typename, setTypename] = useState6(ANY);
1022
- const anyFilter = useMemo8(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
1023
- typenames
1024
- ]);
1025
- const objects = useQuery(space, typename === ANY ? anyFilter : Filter3.typename(typename));
1026
- const { objects: contextObjects, onUpdateObject } = useContextObjects({
1027
- space,
1028
- context
1029
- });
1030
- return /* @__PURE__ */ React2.createElement(SearchList.Root, {
1031
- classNames: "pis-2 pie-2"
1032
- }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
1033
- classNames: "plb-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
1034
- }, objects.length ? objects.map((object) => {
1035
- const label = Obj6.getLabel(object) ?? Obj6.getTypename(object) ?? object.id;
1036
- const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
1037
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
1038
- classNames: "flex items-center overflow-hidden",
1039
- key: object.id,
1040
- value: object.id,
1041
- onSelect: () => onUpdateObject?.(Obj6.getDXN(object), !isActive)
1042
- }, /* @__PURE__ */ React2.createElement("div", {
1043
- className: "grow truncate"
1044
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
1045
- icon: "ph--check--regular",
1046
- classNames: [
1047
- !isActive && "invisible"
1048
- ]
1049
- }));
1050
- }) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
1051
- role: "none",
1052
- className: "grid grid-cols-[min-content_1fr] gap-2 mbe-cardSpacingChrome"
1053
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
1054
- value: typename === ANY ? void 0 : typename,
1055
- onValueChange: setTypename
1056
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
1057
- density: "fine",
1058
- placeholder: t("type filter placeholder")
1059
- }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
1060
- value: ANY
1061
- }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
1062
- key: typename2,
1063
- value: typename2
1064
- }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
1065
- placeholder: t("search placeholder"),
1066
- classNames: "mbe-0"
1067
- })));
1068
- } finally {
1069
- _effect.f();
1070
- }
1071
- };
1072
-
1073
- // src/components/ChatPrompt/ChatPresets.tsx
1074
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1075
- import React3 from "react";
1076
- import { Select as Select2 } from "@dxos/react-ui";
1077
-
1078
- // src/components/ChatPrompt/ChatReferences.tsx
1079
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1080
- import React4 from "react";
1081
- import { Obj as Obj7 } from "@dxos/echo";
1082
- import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
1083
- import { mx as mx2 } from "@dxos/react-ui-theme";
1084
- var ChatReferences = ({ classNames, context, space }) => {
1085
- var _effect = _useSignals6();
1086
- try {
1087
- const { t } = useTranslation3(meta.id);
1088
- const { objects, onUpdateObject } = useContextObjects({
1089
- space,
1090
- context
1091
- });
1092
- return /* @__PURE__ */ React4.createElement("ul", {
1093
- className: mx2("flex flex-wrap", classNames)
1094
- }, objects.map((obj) => {
1095
- const dxn = Obj7.getDXN(obj);
1096
- const typename = Obj7.getTypename(obj);
1097
- const label = Obj7.getLabel(obj) ?? (typename ? [
1098
- "object name placeholder",
1099
- {
1100
- ns: typename
1101
- }
1102
- ] : obj.id);
1103
- return /* @__PURE__ */ React4.createElement("li", {
1104
- key: dxn.toString(),
1105
- className: "dx-tag plb-0 pis-2 flex items-center",
1106
- "data-hue": "neutral"
1107
- }, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
1108
- iconOnly: true,
1109
- variant: "ghost",
1110
- label: t("remove object in context label"),
1111
- classNames: "p-0 hover:bg-transparent",
1112
- size: 3,
1113
- icon: "ph--x--bold",
1114
- onClick: () => onUpdateObject?.(dxn, false)
1115
- }));
1116
- }));
1117
- } finally {
1118
- _effect.f();
1119
- }
1120
- };
1121
-
1122
- // src/components/ChatPrompt/ChatStatusIndicator.tsx
1123
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1124
- import React5, { useEffect as useEffect3, useState as useState7 } from "react";
1125
- import { Tooltip, useTimeout } from "@dxos/react-ui";
1126
- import { Spinner } from "@dxos/react-ui-sfx";
1127
- import { mx as mx3 } from "@dxos/react-ui-theme";
1128
- var period = 3e3;
1129
- var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
1130
- var _effect = _useSignals7();
1131
- try {
1132
- const [init, setInit] = useState7(false);
1133
- useEffect3(() => setInit(false), [
1134
- preset
1135
- ]);
1136
- useTimeout(async () => {
1137
- setInit(true);
1138
- }, period / 2, [
1139
- preset
1140
- ]);
1141
- return /* @__PURE__ */ React5.createElement("div", {
1142
- role: "none",
1143
- className: mx3("relative flex", classNames)
1144
- }, /* @__PURE__ */ React5.createElement(Spinner, {
1145
- duration: period,
1146
- state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
1147
- ...props
1148
- }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
1149
- asChild: true,
1150
- content: error.message
1151
- }, /* @__PURE__ */ React5.createElement("div", {
1152
- className: "absolute inset-0"
1153
- })));
1154
- } finally {
1155
- _effect.f();
1156
- }
1157
- };
1158
-
1159
- // src/components/ChatThread/ChatThread.tsx
1160
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1161
- import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo10, useState as useState9 } from "react";
1162
- import { PublicKey } from "@dxos/keys";
1163
- import { MarkdownStream } from "@dxos/react-ui-components";
1164
- import { mx as mx4 } from "@dxos/react-ui-theme";
1165
- import { keyToFallback } from "@dxos/util";
1166
-
1167
- // src/components/ChatThread/registry.tsx
1168
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1169
- import React7 from "react";
1170
- import { log as log4 } from "@dxos/log";
1171
- import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
1172
- import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
1173
- import { ContentBlock as ContentBlock2 } from "@dxos/schema";
1174
-
1175
- // src/components/ToolBlock/ToolBlock.tsx
1176
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1177
- import React6, { useEffect as useEffect4, useMemo as useMemo9, useRef as useRef2, useState as useState8 } from "react";
1178
- import { useTranslation as useTranslation4 } from "@dxos/react-ui";
1179
- import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
1180
- import { Json } from "@dxos/react-ui-syntax-highlighter";
1181
- import { isNonNullable as isNonNullable3 } from "@dxos/util";
1182
- import { safeParseJson } from "@dxos/util";
1183
- var ToolBlock = ({ blocks = [] }) => {
1184
- var _effect = _useSignals8();
1185
- try {
1186
- const { t } = useTranslation4(meta.id);
1187
- const getToolCaption = (tool, status) => {
1188
- if (!tool) {
1189
- return t("calling tool label");
1190
- }
1191
- return status?.message ?? tool.description ?? [
1192
- t("calling label"),
1193
- tool.name
1194
- ].join(" ");
1195
- };
1196
- const items = useMemo9(() => {
1197
- let lastToolCall;
1198
- const tools = [];
1199
- return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
1200
- switch (block._tag) {
1201
- case "toolCall": {
1202
- if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
1203
- return null;
1204
- }
1205
- const tool = tools.find((tool2) => tool2.name === block.name);
1206
- lastToolCall = {
1207
- tool,
1208
- block
1209
- };
1210
- return {
1211
- title: getToolCaption(lastToolCall?.tool),
1212
- content: {
1213
- ...block,
1214
- input: safeParseJson(block.input)
1215
- }
1216
- };
1217
- }
1218
- case "toolResult": {
1219
- if (block.error) {
1220
- return {
1221
- title: t("error label"),
1222
- content: block
1223
- };
1224
- }
1225
- const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
1226
- lastToolCall = void 0;
1227
- return {
1228
- title,
1229
- content: {
1230
- ...block,
1231
- result: safeParseJson(block.result)
1232
- }
1233
- };
1234
- }
1235
- case "summary": {
1236
- if (!lastToolCall) {
1237
- return null;
1238
- }
1239
- return {
1240
- title: t("summary label"),
1241
- content: block
1242
- };
1243
- }
1244
- }
1245
- }).filter(isNonNullable3);
1246
- }, [
1247
- blocks
1248
- ]);
1249
- if (!items.length) {
1250
- return null;
1251
- }
1252
- return /* @__PURE__ */ React6.createElement(ToolContainer, {
1253
- items
1254
- });
1255
- } finally {
1256
- _effect.f();
1257
- }
1258
- };
1259
- ToolBlock.displayName = "ToolBlock";
1260
- var ToolContainer = ({ items }) => {
1261
- var _effect = _useSignals8();
1262
- try {
1263
- const tabsRef = useRef2(null);
1264
- const [selected, setSelected] = useState8(0);
1265
- const [open, setOpen] = useState8(false);
1266
- useEffect4(() => {
1267
- if (open) {
1268
- tabsRef.current?.focus();
1269
- }
1270
- }, [
1271
- open
1272
- ]);
1273
- const handleSelect = (index) => {
1274
- setSelected(index);
1275
- };
1276
- const data = items[selected]?.content;
1277
- return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
1278
- classNames: chatMessagePanel,
1279
- open,
1280
- onChangeOpen: setOpen
1281
- }, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
1282
- classNames: chatMessagePanelHeader
1283
- }, /* @__PURE__ */ React6.createElement(TextCrawl, {
1284
- key: "status-roll",
1285
- lines: items.map((item) => item.title)
1286
- })), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
1287
- classNames: [
1288
- "grid grid-cols-[32px_1fr]",
1289
- chatMessagePanelContent
1290
- ]
1291
- }, /* @__PURE__ */ React6.createElement(NumericTabs, {
1292
- ref: tabsRef,
1293
- classNames: "p-1",
1294
- length: items.length,
1295
- selected,
1296
- onSelect: handleSelect
1297
- }), /* @__PURE__ */ React6.createElement(Json, {
1298
- data,
1299
- classNames: chatMessageJson,
1300
- replacer: {
1301
- maxDepth: 3,
1302
- maxArrayLen: 10,
1303
- maxStringLen: 128
1304
- }
1305
- })));
1306
- } finally {
1307
- _effect.f();
1308
- }
1309
- };
1310
-
1311
- // src/components/ChatThread/registry.tsx
1312
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1313
- var Fallback = ({ _tag, ...props }) => {
1314
- var _effect = _useSignals9();
1315
- try {
1316
- return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
1317
- classNames: "rounded-sm"
1318
- }, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
1319
- classNames: "bg-groupSurface"
1320
- }, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
1321
- classNames: "bg-modalSurface"
1322
- }, /* @__PURE__ */ React7.createElement(Json2, {
1323
- classNames: "!p-2 text-sm",
1324
- data: props
1325
- })));
1326
- } finally {
1327
- _effect.f();
1328
- }
1329
- };
1330
- var getTextChild = (children) => {
1331
- const child = children?.[0];
1332
- return typeof child === "string" ? child : null;
1333
- };
1334
- var componentRegistry = {
1335
- //
1336
- // Widgets
1337
- //
1338
- ["prompt"]: {
1339
- block: true,
1340
- factory: (props) => {
1341
- const text = getTextChild(props.children);
1342
- return text ? new PromptWidget(text) : null;
1343
- }
1344
- },
1345
- ["reference"]: {
1346
- block: false,
1347
- factory: (props) => {
1348
- const text = getTextChild(props.children);
1349
- return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
1350
- }
1351
- },
1352
- ["select"]: {
1353
- block: true,
1354
- factory: (props) => {
1355
- const options = props.children?.map((option) => option._tag === "option" && getTextChild(option.children)).filter(Boolean);
1356
- return options?.length ? new SelectWidget(options) : null;
1357
- }
1358
- },
1359
- ["suggestion"]: {
1360
- block: true,
1361
- factory: (props) => {
1362
- const text = getTextChild(props.children);
1363
- return text ? new SuggestionWidget(text) : null;
1364
- }
1365
- },
1366
- ["summary"]: {
1367
- block: true,
1368
- factory: (props) => {
1369
- const text = getTextChild(props.children);
1370
- return text ? new SummaryWidget(text) : null;
1371
- }
1372
- },
1373
- //
1374
- // React
1375
- //
1376
- ["toolCall"]: {
1377
- block: true,
1378
- Component: ToolBlock
1379
- },
1380
- ["toolResult"]: {
1381
- block: true,
1382
- Component: Fallback
1383
- },
1384
- ["toolkit"]: {
1385
- block: true,
1386
- Component: Fallback
1387
- },
1388
- //
1389
- // Fallback
1390
- //
1391
- ["json"]: {
1392
- block: true,
1393
- Component: Fallback
1394
- }
1395
- };
1396
- var blockToMarkdown = (context, message, block) => {
1397
- let str = _blockToMarkdown(context, message, block);
1398
- if (str && !block.pending) {
1399
- return str += "\n";
1400
- }
1401
- return str;
1402
- };
1403
- var _blockToMarkdown = (context, message, block) => {
1404
- log4("blockToMarkdown", {
1405
- block: JSON.stringify(block)
1406
- }, {
1407
- F: __dxlog_file4,
1408
- L: 130,
1409
- S: void 0,
1410
- C: (f, a) => f(...a)
1411
- });
1412
- switch (block._tag) {
1413
- case "text": {
1414
- if (message.sender.role === "user") {
1415
- return `
1416
- <prompt>${block.text}</prompt>
1417
- `;
1418
- } else {
1419
- const text = block.text.trim();
1420
- if (text.length > 0) {
1421
- return text;
1422
- }
1423
- }
1424
- break;
1425
- }
1426
- case "suggestion": {
1427
- if (block.pending) {
1428
- return;
1429
- }
1430
- return `<suggestion>${block.text}</suggestion>`;
1431
- }
1432
- case "select": {
1433
- if (block.pending || block.options.length === 0) {
1434
- return;
1435
- }
1436
- return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1437
- }
1438
- // TODO(burdon): Need label.
1439
- case "reference": {
1440
- return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
1441
- }
1442
- // case 'toolkit': {
1443
- // return `<toolkit />`;
1444
- // }
1445
- case "toolCall": {
1446
- context.updateWidget(block.toolCallId, {
1447
- blocks: [
1448
- block
1449
- ]
1450
- });
1451
- return `<toolCall id="${block.toolCallId}" />`;
1452
- }
1453
- case "toolResult": {
1454
- context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
1455
- blocks: [
1456
- ...blocks,
1457
- block
1458
- ]
1459
- }));
1460
- break;
1461
- }
1462
- case "summary": {
1463
- return `<summary>${ContentBlock2.createSummaryMessage(block)}</summary>`;
1464
- }
1465
- // TODO(burdon): Need stable ID.
1466
- default: {
1467
- return `<json id="${message.id}">
1468
- ${JSON.stringify(block)}
1469
- </json>`;
1470
- }
1471
- }
1472
- };
1473
-
1474
- // src/components/ChatThread/sync.ts
1475
- import { log as log5 } from "@dxos/log";
1476
- function _define_property3(obj, key, value) {
1477
- if (key in obj) {
1478
- Object.defineProperty(obj, key, {
1479
- value,
1480
- enumerable: true,
1481
- configurable: true,
1482
- writable: true
1483
- });
1484
- } else {
1485
- obj[key] = value;
1486
- }
1487
- return obj;
1488
- }
1489
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1490
- var MessageThreadContext = class {
1491
- updateWidget(id, value) {
1492
- this._widgetState?.updateWidget(id, value);
1493
- }
1494
- constructor(_widgetState) {
1495
- _define_property3(this, "_widgetState", void 0);
1496
- this._widgetState = _widgetState;
1497
- }
1498
- };
1499
- var MessageSyncer = class {
1500
- get context() {
1501
- return this._context;
1502
- }
1503
- reset() {
1504
- log5("reset", void 0, {
1505
- F: __dxlog_file5,
1506
- L: 58,
1507
- S: this,
1508
- C: (f, a) => f(...a)
1509
- });
1510
- this._initialMessageId = void 0;
1511
- this._currentMessageIndex = 0;
1512
- this._currentBlockIndex = 0;
1513
- this._currentBlockContent = void 0;
1514
- void this._model.reset("");
1515
- }
1516
- sync(messages) {
1517
- log5("sync", {
1518
- messages: messages.map((m) => m.blocks.length),
1519
- currentMessageIndex: this._currentMessageIndex,
1520
- currentBlockIndex: this._currentBlockIndex,
1521
- currentBlockContent: this._currentBlockContent
1522
- }, {
1523
- F: __dxlog_file5,
1524
- L: 67,
1525
- S: this,
1526
- C: (f, a) => f(...a)
1527
- });
1528
- if (this._initialMessageId !== messages[0]?.id) {
1529
- this.reset();
1530
- this._initialMessageId = messages[0]?.id;
1531
- }
1532
- let i = this._currentMessageIndex;
1533
- for (const message of messages.slice(this._currentMessageIndex)) {
1534
- if (i > this._currentMessageIndex) {
1535
- this._currentBlockIndex = 0;
1536
- }
1537
- this._currentMessageIndex = i;
1538
- let j = this._currentBlockIndex;
1539
- for (const block of message.blocks.slice(this._currentBlockIndex)) {
1540
- this._currentBlockIndex = j;
1541
- const currentBlockContent = this._blockRenderer(this._context, message, block);
1542
- if (currentBlockContent) {
1543
- let content = "";
1544
- if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
1545
- content = currentBlockContent.slice(this._currentBlockContent.length);
1546
- } else {
1547
- content = currentBlockContent;
1548
- }
1549
- void this._model.append(content);
1550
- this._currentBlockContent = currentBlockContent;
1551
- log5("append", {
1552
- message: i,
1553
- block: j,
1554
- content
1555
- }, {
1556
- F: __dxlog_file5,
1557
- L: 99,
1558
- S: this,
1559
- C: (f, a) => f(...a)
1560
- });
1561
- }
1562
- if (block.pending) {
1563
- return;
1564
- } else {
1565
- this._currentBlockContent = void 0;
1566
- this._currentBlockIndex++;
1567
- }
1568
- j++;
1569
- }
1570
- i++;
1571
- }
1572
- }
1573
- constructor(_model, _blockRenderer) {
1574
- _define_property3(this, "_model", void 0);
1575
- _define_property3(this, "_blockRenderer", void 0);
1576
- _define_property3(this, "_initialMessageId", void 0);
1577
- _define_property3(this, "_currentMessageIndex", void 0);
1578
- _define_property3(this, "_currentBlockIndex", void 0);
1579
- _define_property3(this, "_currentBlockContent", void 0);
1580
- _define_property3(this, "_context", void 0);
1581
- this._model = _model;
1582
- this._blockRenderer = _blockRenderer;
1583
- this._currentMessageIndex = 0;
1584
- this._currentBlockIndex = 0;
1585
- this._context = new MessageThreadContext(this._model);
1586
- }
1587
- };
1588
-
1589
- // src/components/ChatThread/ChatThread.tsx
1590
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, onEvent }, forwardedRef) => {
1591
- var _effect = _useSignals10();
1592
- try {
1593
- const userHue = useMemo10(() => {
1594
- return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1595
- }, [
1596
- identity
1597
- ]);
1598
- const [controller, setController] = useState9(null);
1599
- useImperativeHandle(forwardedRef, () => controller ? controller : null, [
1600
- controller
1601
- ]);
1602
- useEffect5(() => {
1603
- controller?.scrollToBottom();
1604
- }, [
1605
- controller,
1606
- error
1607
- ]);
1608
- const syncer = useMemo10(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1609
- controller
1610
- ]);
1611
- useEffect5(() => {
1612
- syncer?.sync(messages);
1613
- }, [
1614
- syncer,
1615
- messages
1616
- ]);
1617
- const handleEvent = useCallback5((ev) => {
1618
- switch (ev.type) {
1619
- case "submit": {
1620
- ev.value && onEvent?.({
1621
- type: "submit",
1622
- text: ev.value
1623
- });
1624
- break;
1625
- }
1626
- }
1627
- }, [
1628
- onEvent
1629
- ]);
1630
- return /* @__PURE__ */ React8.createElement("div", {
1631
- className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
1632
- style: {
1633
- "--user-fill": `var(--dx-${userHue}Fill)`
1634
- }
1635
- }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1636
- ref: setController,
1637
- classNames: "bs-full max-is-prose overflow-hidden",
1638
- registry: componentRegistry,
1639
- cursor,
1640
- fadeIn,
1641
- onEvent: handleEvent
1642
- }));
1643
- } finally {
1644
- _effect.f();
1645
- }
1646
- });
1647
-
1648
- // src/components/Chat/Chat.tsx
1649
- var [ChatContextProvider, useChatContext] = createContext("Chat");
1650
- var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1651
- var _effect = _useSignals11();
1652
- try {
1653
- const [debug, setDebug] = useState10(false);
1654
- const space = getSpace(chat);
1655
- const queue = useQueue2(chat?.queue.dxn);
1656
- const pending = useRxValue(processor.messages);
1657
- const streaming = useRxValue(processor.streaming);
1658
- const lastPrompt = useRef3(void 0);
1659
- const messages = useMemo11(() => {
1660
- const queueMessages = queue?.objects?.filter(Obj8.instanceOf(DataType3.Message)) ?? [];
1661
- return Array2.dedupeWith([
1662
- ...queueMessages,
1663
- ...pending
1664
- ], (a, b) => a.id === b.id);
1665
- }, [
1666
- queue?.objects,
1667
- pending
1668
- ]);
1669
- const event = useMemo11(() => new Event(), []);
1670
- useEffect6(() => {
1671
- return event.on((ev) => {
1672
- switch (ev.type) {
1673
- case "toggle-debug": {
1674
- setDebug((current) => !current);
1675
- break;
1676
- }
1677
- case "submit": {
1678
- const text = ev.text.trim();
1679
- if (!streaming && text.length) {
1680
- lastPrompt.current = ev.text;
1681
- void processor.request({
1682
- message: text
1683
- });
1684
- }
1685
- break;
1686
- }
1687
- case "retry": {
1688
- if (!streaming) {
1689
- void processor.retry();
1690
- }
1691
- break;
1692
- }
1693
- case "cancel": {
1694
- if (streaming) {
1695
- void processor.cancel();
1696
- if (lastPrompt.current) {
1697
- event.emit({
1698
- type: "update-prompt",
1699
- text: lastPrompt.current
1700
- });
1701
- }
1702
- }
1703
- break;
1704
- }
1705
- default: {
1706
- onEvent?.(ev);
1707
- }
1708
- }
1709
- });
1710
- }, [
1711
- event,
1712
- processor,
1713
- streaming,
1714
- onEvent
1715
- ]);
1716
- if (!space) {
1717
- return null;
1718
- }
1719
- return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1720
- debug,
1721
- event,
1722
- chat,
1723
- space,
1724
- messages,
1725
- processor,
1726
- ...props
1727
- }, /* @__PURE__ */ React9.createElement("div", {
1728
- role: "none",
1729
- className: mx5("flex flex-col h-full overflow-hidden", classNames)
1730
- }, children));
1731
- } finally {
1732
- _effect.f();
1733
- }
1734
- };
1735
- ChatRoot.displayName = "Chat.Root";
1736
- var ChatPrompt = ({ classNames, outline, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1737
- var _effect = _useSignals11();
1738
- try {
1739
- const { t } = useTranslation5(meta.id);
1740
- const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1741
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1742
- const streaming = useRxValue(processor.streaming);
1743
- const active = useRxValue(processor.active);
1744
- const activeRef = useDynamicRef(active);
1745
- const editorRef = useRef3(null);
1746
- const [recordingState, setRecordingState] = useState10(false);
1747
- useEffect6(() => {
1748
- return event.on((event2) => {
1749
- switch (event2.type) {
1750
- case "update-prompt":
1751
- if (!editorRef.current?.getText()?.length) {
1752
- editorRef.current?.setText(event2.text);
1753
- editorRef.current?.focus();
1754
- }
1755
- break;
1756
- case "record-start":
1757
- setRecordingState(true);
1758
- break;
1759
- case "record-stop":
1760
- setRecordingState(false);
1761
- break;
1762
- }
1763
- });
1764
- }, [
1765
- event
1766
- ]);
1767
- const { recording } = useVoiceInput({
1768
- active: recordingState,
1769
- onUpdate: (text) => {
1770
- editorRef.current?.setText(text);
1771
- editorRef.current?.focus();
1772
- }
1773
- });
1774
- const referencesProvider = useReferencesProvider(space);
1775
- const extensions = useMemo11(() => {
1776
- return [
1777
- referencesProvider && references({
1778
- provider: referencesProvider
1779
- }),
1780
- Prec.highest(keymap.of([
1781
- {
1782
- key: "cmd-d",
1783
- preventDefault: true,
1784
- run: () => {
1785
- event.emit({
1786
- type: "toggle-debug"
1787
- });
1788
- return true;
1789
- }
1790
- },
1791
- expandable && {
1792
- key: "cmd-ArrowUp",
1793
- preventDefault: true,
1794
- run: () => {
1795
- event.emit({
1796
- type: "thread-open"
1797
- });
1798
- return true;
1799
- }
1800
- },
1801
- expandable && {
1802
- key: "cmd-ArrowDown",
1803
- preventDefault: true,
1804
- run: () => {
1805
- event.emit({
1806
- type: "thread-close"
1807
- });
1808
- return true;
1809
- }
1810
- }
1811
- ].filter(isNotFalsy2)))
1812
- ].filter(isNotFalsy2);
1813
- }, [
1814
- event,
1815
- expandable,
1816
- referencesProvider
1817
- ]);
1818
- const handleSubmit = useCallback6((text) => {
1819
- if (!activeRef.current) {
1820
- event.emit({
1821
- type: "submit",
1822
- text
1823
- });
1824
- return true;
1825
- }
1826
- }, [
1827
- event
1828
- ]);
1829
- const handleEvent = useCallback6((ev) => {
1830
- event.emit(ev);
1831
- }, [
1832
- event
1833
- ]);
1834
- return /* @__PURE__ */ React9.createElement("div", {
1835
- className: mx5("is-full flex flex-col density-fine", outline && [
1836
- "p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
1837
- ], classNames)
1838
- }, /* @__PURE__ */ React9.createElement("div", {
1839
- className: "flex gap-2"
1840
- }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1841
- classNames: "p-1",
1842
- preset,
1843
- error,
1844
- processing: streaming
1845
- }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1846
- ref: editorRef,
1847
- autoFocus: true,
1848
- lineWrapping: true,
1849
- classNames: "col-span-2 pbs-0.5",
1850
- placeholder: placeholder ?? t("prompt placeholder"),
1851
- extensions,
1852
- onSubmit: handleSubmit
1853
- })), /* @__PURE__ */ React9.createElement("div", {
1854
- className: "flex pbs-2 items-center"
1855
- }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1856
- space,
1857
- blueprintRegistry: processor.blueprintRegistry,
1858
- context: processor.context,
1859
- preset,
1860
- presets,
1861
- onPresetChange
1862
- }), /* @__PURE__ */ React9.createElement("div", {
1863
- role: "none",
1864
- className: "pli-cardSpacingChrome grow"
1865
- }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1866
- space,
1867
- context: processor.context
1868
- })), /* @__PURE__ */ React9.createElement(ChatActions, {
1869
- classNames: "col-span-2",
1870
- microphone: true,
1871
- recording,
1872
- processing: streaming,
1873
- onEvent: handleEvent
1874
- }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Switch, {
1875
- classNames: "mis-2 mie-2",
1876
- checked: online,
1877
- onCheckedChange: onOnlineChange
1878
- })))));
1879
- } finally {
1880
- _effect.f();
1881
- }
1882
- };
1883
- ChatPrompt.displayName = "Chat.Prompt";
1884
- var ChatThread2 = (props) => {
1885
- var _effect = _useSignals11();
1886
- try {
1887
- const { event, messages, processor } = useChatContext(ChatThread2.displayName);
1888
- const identity = useIdentity();
1889
- const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1890
- const scrollerRef = useRef3(null);
1891
- useEffect6(() => {
1892
- return event.on((event2) => {
1893
- switch (event2.type) {
1894
- case "submit":
1895
- case "scroll-to-bottom":
1896
- scrollerRef.current?.scrollToBottom();
1897
- break;
1898
- }
1899
- });
1900
- }, [
1901
- event
1902
- ]);
1903
- const handleEvent = useCallback6((ev) => {
1904
- event.emit(ev);
1905
- }, [
1906
- event
1907
- ]);
1908
- if (!identity) {
1909
- return null;
1910
- }
1911
- return /* @__PURE__ */ React9.createElement(ChatThread, {
1912
- ...props,
1913
- ref: scrollerRef,
1914
- identity,
1915
- messages,
1916
- error,
1917
- onEvent: handleEvent
1918
- });
1919
- } finally {
1920
- _effect.f();
1921
- }
1922
- };
1923
- ChatThread2.displayName = "Chat.Thread";
1924
- var Chat = {
1925
- Root: ChatRoot,
1926
- Prompt: ChatPrompt,
1927
- Thread: ChatThread2
1928
- };
1929
-
1930
- export {
1931
- useBlueprintRegistry,
1932
- useChatProcessor,
1933
- useChatServices,
1934
- useContextBinder,
1935
- useExecutionGraph,
1936
- useOnline,
1937
- usePresets,
1938
- ChatContextProvider,
1939
- useChatContext,
1940
- Chat
1941
- };
1942
- //# sourceMappingURL=chunk-X2YUKRBE.mjs.map