@dxos/plugin-assistant 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae

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 (618) hide show
  1. package/dist/lib/browser/AssistantSettings-2LFAG5OQ.mjs +93 -0
  2. package/dist/lib/browser/AssistantSettings-2LFAG5OQ.mjs.map +7 -0
  3. package/dist/lib/browser/BlueprintArticle-CCS25MNW.mjs +36 -0
  4. package/dist/lib/browser/BlueprintArticle-CCS25MNW.mjs.map +7 -0
  5. package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs +202 -0
  6. package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs.map +7 -0
  7. package/dist/lib/browser/ChatContainer-ZGRSZ5EU.mjs +12 -0
  8. package/dist/lib/browser/ChatContainer-ZGRSZ5EU.mjs.map +7 -0
  9. package/dist/lib/browser/ChatDialog-AET7GVIB.mjs +85 -0
  10. package/dist/lib/browser/ChatDialog-AET7GVIB.mjs.map +7 -0
  11. package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs +91 -0
  12. package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs.map +7 -0
  13. package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs +194 -0
  14. package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs.map +7 -0
  15. package/dist/lib/browser/PromptArticle-USQO4WX6.mjs +71 -0
  16. package/dist/lib/browser/PromptArticle-USQO4WX6.mjs.map +7 -0
  17. package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs +122 -0
  18. package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs.map +7 -0
  19. package/dist/lib/browser/ai-service-CY2BYPH6.mjs +22 -0
  20. package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +7 -0
  21. package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs +234 -0
  22. package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs.map +7 -0
  23. package/dist/lib/browser/blueprint-definition-RB5RHZZM.mjs +34 -0
  24. package/dist/lib/browser/blueprint-definition-RB5RHZZM.mjs.map +7 -0
  25. package/dist/lib/browser/blueprints/index.mjs +8 -0
  26. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-7DXYAXLZ.mjs +230 -0
  28. package/dist/lib/browser/chunk-7DXYAXLZ.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-EXVT7D4B.mjs +23 -0
  30. package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  32. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  33. package/dist/lib/browser/chunk-JYY5AD65.mjs +286 -0
  34. package/dist/lib/browser/chunk-JYY5AD65.mjs.map +7 -0
  35. package/dist/lib/browser/chunk-LEXIQDXZ.mjs +26 -0
  36. package/dist/lib/browser/chunk-LEXIQDXZ.mjs.map +7 -0
  37. package/dist/lib/browser/chunk-RU4G5NY4.mjs +69 -0
  38. package/dist/lib/browser/chunk-RU4G5NY4.mjs.map +7 -0
  39. package/dist/lib/browser/chunk-UUA6GNGG.mjs +2125 -0
  40. package/dist/lib/browser/chunk-UUA6GNGG.mjs.map +7 -0
  41. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs +21 -0
  42. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +7 -0
  43. package/dist/lib/browser/index.mjs +299 -161
  44. package/dist/lib/browser/index.mjs.map +4 -4
  45. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs +20 -0
  46. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +7 -0
  47. package/dist/lib/browser/meta.json +1 -1
  48. package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs +136 -0
  49. package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs.map +7 -0
  50. package/dist/lib/browser/react-surface-KYQSZO2I.mjs +144 -0
  51. package/dist/lib/browser/react-surface-KYQSZO2I.mjs.map +7 -0
  52. package/dist/lib/browser/repair-ZFZWZALX.mjs +52 -0
  53. package/dist/lib/browser/repair-ZFZWZALX.mjs.map +7 -0
  54. package/dist/lib/browser/settings-YREVQAZ5.mjs +33 -0
  55. package/dist/lib/browser/settings-YREVQAZ5.mjs.map +7 -0
  56. package/dist/lib/browser/state-MPG42ZO4.mjs +26 -0
  57. package/dist/lib/browser/state-MPG42ZO4.mjs.map +7 -0
  58. package/dist/lib/browser/toolkit-XRSBBB3L.mjs +16 -0
  59. package/dist/lib/browser/toolkit-XRSBBB3L.mjs.map +7 -0
  60. package/dist/lib/browser/types/index.mjs +11 -4
  61. package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs +94 -0
  62. package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs.map +7 -0
  63. package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs +37 -0
  64. package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs.map +7 -0
  65. package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs +203 -0
  66. package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs.map +7 -0
  67. package/dist/lib/node-esm/ChatContainer-IFHDIFJH.mjs +13 -0
  68. package/dist/lib/node-esm/ChatContainer-IFHDIFJH.mjs.map +7 -0
  69. package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs +86 -0
  70. package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs.map +7 -0
  71. package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs +92 -0
  72. package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs.map +7 -0
  73. package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs +195 -0
  74. package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs.map +7 -0
  75. package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs +72 -0
  76. package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs.map +7 -0
  77. package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs +123 -0
  78. package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs.map +7 -0
  79. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +23 -0
  80. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +7 -0
  81. package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs +235 -0
  82. package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs.map +7 -0
  83. package/dist/lib/node-esm/blueprint-definition-L7XKRYIW.mjs +35 -0
  84. package/dist/lib/node-esm/blueprint-definition-L7XKRYIW.mjs.map +7 -0
  85. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  86. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  87. package/dist/lib/node-esm/chunk-3QBVFAYO.mjs +28 -0
  88. package/dist/lib/node-esm/chunk-3QBVFAYO.mjs.map +7 -0
  89. package/dist/lib/node-esm/chunk-6NCLKQCL.mjs +70 -0
  90. package/dist/lib/node-esm/chunk-6NCLKQCL.mjs.map +7 -0
  91. package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs +2126 -0
  92. package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs.map +7 -0
  93. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  94. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  95. package/dist/lib/node-esm/chunk-JMBYVUD6.mjs +288 -0
  96. package/dist/lib/node-esm/chunk-JMBYVUD6.mjs.map +7 -0
  97. package/dist/lib/node-esm/chunk-MWYYLALM.mjs +231 -0
  98. package/dist/lib/node-esm/chunk-MWYYLALM.mjs.map +7 -0
  99. package/dist/lib/node-esm/chunk-POWB2BPC.mjs +25 -0
  100. package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +7 -0
  101. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +22 -0
  102. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +7 -0
  103. package/dist/lib/node-esm/index.mjs +299 -161
  104. package/dist/lib/node-esm/index.mjs.map +4 -4
  105. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +21 -0
  106. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +7 -0
  107. package/dist/lib/node-esm/meta.json +1 -1
  108. package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs +137 -0
  109. package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs.map +7 -0
  110. package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs +145 -0
  111. package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs.map +7 -0
  112. package/dist/lib/node-esm/repair-LXFVOK4B.mjs +53 -0
  113. package/dist/lib/node-esm/repair-LXFVOK4B.mjs.map +7 -0
  114. package/dist/lib/node-esm/settings-N452OW6Y.mjs +34 -0
  115. package/dist/lib/node-esm/settings-N452OW6Y.mjs.map +7 -0
  116. package/dist/lib/node-esm/state-WHZFKIEL.mjs +27 -0
  117. package/dist/lib/node-esm/state-WHZFKIEL.mjs.map +7 -0
  118. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs +17 -0
  119. package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs.map +7 -0
  120. package/dist/lib/node-esm/types/index.mjs +11 -4
  121. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  122. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  123. package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
  124. package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
  125. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
  126. package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
  127. package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
  128. package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
  129. package/dist/types/src/blueprints/index.d.ts +2 -0
  130. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  131. package/dist/types/src/capabilities/ai-service/ai-service.d.ts +6 -0
  132. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
  133. package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
  134. package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
  135. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  136. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  137. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  138. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  139. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
  140. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  141. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  142. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  143. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +7 -0
  144. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
  145. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
  146. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
  147. package/dist/types/src/capabilities/index.d.ts +11 -4
  148. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  149. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
  150. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
  151. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +13 -0
  152. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
  153. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  154. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  155. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  156. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  157. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  158. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  159. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  160. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  161. package/dist/types/src/capabilities/repair/index.d.ts +3 -0
  162. package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
  163. package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
  164. package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
  165. package/dist/types/src/capabilities/settings/index.d.ts +15 -0
  166. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  167. package/dist/types/src/capabilities/settings/settings.d.ts +18 -0
  168. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  169. package/dist/types/src/capabilities/state/index.d.ts +11 -0
  170. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  171. package/dist/types/src/capabilities/state/state.d.ts +13 -0
  172. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  173. package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
  174. package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
  175. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +6 -0
  176. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
  177. package/dist/types/src/components/Chat/Chat.d.ts +39 -22
  178. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  179. package/dist/types/src/components/Chat/events.d.ts +10 -1
  180. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  181. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
  182. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  183. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  184. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  185. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  186. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
  187. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  188. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
  189. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +5 -6
  190. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  191. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
  192. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  193. package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
  194. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  195. package/dist/types/src/components/ChatThread/ChatThread.d.ts +13 -11
  196. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  197. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +285 -71
  198. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  199. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  200. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  201. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  202. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  203. package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
  204. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  205. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  206. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  207. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +3 -6
  208. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  209. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +431 -7
  210. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  211. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +13 -2
  212. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  213. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +428 -2
  214. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  215. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
  216. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  217. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  218. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  219. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  220. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  221. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +21 -0
  222. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  223. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  224. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  225. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  226. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  227. package/dist/types/src/components/Toolbox/Toolbox.d.ts +9 -15
  228. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  229. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +432 -5
  230. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  231. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
  232. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
  233. package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
  234. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
  235. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
  236. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
  237. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
  238. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
  239. package/dist/types/src/components/Typewriter/index.d.ts +2 -0
  240. package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
  241. package/dist/types/src/components/index.d.ts +0 -8
  242. package/dist/types/src/components/index.d.ts.map +1 -1
  243. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts +8 -0
  244. package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts.map +1 -0
  245. package/dist/types/src/containers/AssistantSettings/index.d.ts +3 -0
  246. package/dist/types/src/containers/AssistantSettings/index.d.ts.map +1 -0
  247. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
  248. package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
  249. package/dist/types/src/containers/BlueprintArticle/index.d.ts +3 -0
  250. package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
  251. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +12 -0
  252. package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
  253. package/dist/types/src/containers/ChatCompanion/index.d.ts +3 -0
  254. package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
  255. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +18 -0
  256. package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
  257. package/dist/types/src/containers/ChatContainer/index.d.ts +3 -0
  258. package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
  259. package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
  260. package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
  261. package/dist/types/src/containers/ChatDialog/index.d.ts +3 -0
  262. package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
  263. package/dist/types/src/containers/Project/ProjectArticle.d.ts +7 -0
  264. package/dist/types/src/containers/Project/ProjectArticle.d.ts.map +1 -0
  265. package/dist/types/src/containers/Project/ProjectSettings.d.ts +6 -0
  266. package/dist/types/src/containers/Project/ProjectSettings.d.ts.map +1 -0
  267. package/dist/types/src/containers/Project/index.d.ts +7 -0
  268. package/dist/types/src/containers/Project/index.d.ts.map +1 -0
  269. package/dist/types/src/containers/Project/triggers.d.ts +6 -0
  270. package/dist/types/src/containers/Project/triggers.d.ts.map +1 -0
  271. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
  272. package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
  273. package/dist/types/src/containers/PromptArticle/index.d.ts +3 -0
  274. package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
  275. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
  276. package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  277. package/dist/types/src/containers/TriggerStatus/index.d.ts +3 -0
  278. package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
  279. package/dist/types/src/containers/index.d.ts +10 -0
  280. package/dist/types/src/containers/index.d.ts.map +1 -0
  281. package/dist/types/src/hooks/index.d.ts +8 -3
  282. package/dist/types/src/hooks/index.d.ts.map +1 -1
  283. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  284. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  285. package/dist/types/src/hooks/useChatProcessor.d.ts +10 -20
  286. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  287. package/dist/types/src/hooks/useChatServices.d.ts +7 -8
  288. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  289. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  290. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  291. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  292. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  293. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  294. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  295. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  296. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  297. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  298. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  299. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  300. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  301. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  302. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  303. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
  304. package/dist/types/src/index.d.ts +3 -1
  305. package/dist/types/src/index.d.ts.map +1 -1
  306. package/dist/types/src/meta.d.ts +3 -4
  307. package/dist/types/src/meta.d.ts.map +1 -1
  308. package/dist/types/src/processor/index.d.ts +4 -0
  309. package/dist/types/src/processor/index.d.ts.map +1 -0
  310. package/dist/types/src/{hooks → processor}/presets.d.ts +3 -3
  311. package/dist/types/src/processor/presets.d.ts.map +1 -0
  312. package/dist/types/src/processor/processor.d.ts +79 -0
  313. package/dist/types/src/processor/processor.d.ts.map +1 -0
  314. package/dist/types/src/processor/processor.test.d.ts +2 -0
  315. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  316. package/dist/types/src/processor/update-name.d.ts +10 -0
  317. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  318. package/dist/types/src/queue-logger.d.ts.map +1 -1
  319. package/dist/types/src/testing/index.d.ts +1 -1
  320. package/dist/types/src/testing/index.d.ts.map +1 -1
  321. package/dist/types/src/testing/test-generator.d.ts +8 -0
  322. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  323. package/dist/types/src/testing/test-sequence.d.ts +0 -4
  324. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  325. package/dist/types/src/testing/test-services.d.ts +2 -2
  326. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  327. package/dist/types/src/translations.d.ts +376 -37
  328. package/dist/types/src/translations.d.ts.map +1 -1
  329. package/dist/types/src/types/Assistant.d.ts +20 -0
  330. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  331. package/dist/types/src/types/AssistantAction.d.ts +93 -0
  332. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  333. package/dist/types/src/types/capabilities.d.ts +33 -0
  334. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  335. package/dist/types/src/types/defs.d.ts +2 -0
  336. package/dist/types/src/types/defs.d.ts.map +1 -0
  337. package/dist/types/src/types/events.d.ts +5 -0
  338. package/dist/types/src/types/events.d.ts.map +1 -0
  339. package/dist/types/src/types/index.d.ts +6 -1
  340. package/dist/types/src/types/index.d.ts.map +1 -1
  341. package/dist/types/src/types/service.d.ts +14 -213
  342. package/dist/types/src/types/service.d.ts.map +1 -1
  343. package/dist/types/tsconfig.tsbuildinfo +1 -1
  344. package/package.json +125 -96
  345. package/src/AssistantPlugin.tsx +162 -88
  346. package/src/blueprints/assistant/blueprint.conversations.json +1 -0
  347. package/src/blueprints/assistant/blueprint.test.ts +48 -0
  348. package/src/blueprints/assistant/blueprint.ts +27 -0
  349. package/src/blueprints/assistant/index.ts +5 -0
  350. package/src/{components/SequenceEditor → blueprints}/index.ts +1 -1
  351. package/src/capabilities/ai-service/ai-service.ts +30 -0
  352. package/src/capabilities/ai-service/index.ts +7 -0
  353. package/src/capabilities/app-graph-builder/app-graph-builder.ts +198 -0
  354. package/src/capabilities/app-graph-builder/index.ts +7 -0
  355. package/src/capabilities/blueprint-definition/blueprint-definition.ts +48 -0
  356. package/src/capabilities/blueprint-definition/index.ts +7 -0
  357. package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +33 -0
  358. package/src/capabilities/edge-model-resolver/index.ts +7 -0
  359. package/src/capabilities/index.ts +11 -6
  360. package/src/capabilities/local-model-resolver/index.ts +7 -0
  361. package/src/capabilities/local-model-resolver/local-model-resolver.ts +38 -0
  362. package/src/capabilities/operation-resolver/index.ts +7 -0
  363. package/src/capabilities/operation-resolver/operation-resolver.ts +121 -0
  364. package/src/capabilities/react-surface/index.ts +7 -0
  365. package/src/capabilities/react-surface/react-surface.tsx +121 -0
  366. package/src/capabilities/repair/index.ts +7 -0
  367. package/src/capabilities/repair/repair.ts +69 -0
  368. package/src/capabilities/settings/index.ts +7 -0
  369. package/src/capabilities/settings/settings.ts +31 -0
  370. package/src/capabilities/state/index.ts +7 -0
  371. package/src/capabilities/state/state.ts +27 -0
  372. package/src/capabilities/toolkit/index.ts +7 -0
  373. package/src/capabilities/toolkit/toolkit.ts +15 -0
  374. package/src/components/Chat/Chat.tsx +278 -198
  375. package/src/components/Chat/events.ts +14 -1
  376. package/src/components/ChatProgress/ChatProgress.tsx +53 -0
  377. package/src/components/ChatProgress/index.ts +5 -0
  378. package/src/components/ChatPrompt/ChatActions.tsx +20 -28
  379. package/src/components/ChatPrompt/ChatOptions.tsx +258 -0
  380. package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
  381. package/src/components/ChatPrompt/ChatReferences.tsx +42 -38
  382. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
  383. package/src/components/ChatPrompt/index.ts +1 -1
  384. package/src/components/ChatThread/ChatThread.stories.tsx +124 -117
  385. package/src/components/ChatThread/ChatThread.tsx +75 -36
  386. package/src/components/ChatThread/Link.tsx +26 -0
  387. package/src/components/ChatThread/registry.tsx +207 -0
  388. package/src/components/ChatThread/sync.test.ts +99 -0
  389. package/src/components/ChatThread/sync.ts +160 -0
  390. package/src/components/ChatThread/testing/thread.md +37 -0
  391. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +41 -20
  392. package/src/components/TemplateEditor/TemplateEditor.tsx +33 -52
  393. package/src/components/TemplateEditor/TemplateForm.stories.tsx +30 -17
  394. package/src/components/TemplateEditor/TemplateForm.tsx +85 -36
  395. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  396. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  397. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  398. package/src/components/ToolBlock/ToolBlock.tsx +143 -0
  399. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  400. package/src/components/ToolBlock/index.ts +6 -0
  401. package/src/components/Toolbox/Toolbox.stories.tsx +19 -29
  402. package/src/components/Toolbox/Toolbox.tsx +68 -100
  403. package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
  404. package/src/components/Typewriter/Typewriter.stories.tsx +86 -0
  405. package/src/components/Typewriter/Typewriter.tsx +54 -0
  406. package/src/components/Typewriter/assistant-extension.tsx +142 -0
  407. package/src/components/Typewriter/index.ts +5 -0
  408. package/src/components/index.ts +0 -13
  409. package/src/containers/AssistantSettings/AssistantSettings.tsx +120 -0
  410. package/src/containers/AssistantSettings/index.ts +7 -0
  411. package/src/containers/BlueprintArticle/BlueprintArticle.tsx +30 -0
  412. package/src/containers/BlueprintArticle/index.ts +7 -0
  413. package/src/containers/ChatCompanion/ChatCompanion.tsx +225 -0
  414. package/src/containers/ChatCompanion/index.ts +7 -0
  415. package/src/containers/ChatContainer/ChatContainer.tsx +69 -0
  416. package/src/containers/ChatContainer/index.ts +7 -0
  417. package/src/containers/ChatDialog/ChatDialog.tsx +72 -0
  418. package/src/containers/ChatDialog/index.ts +7 -0
  419. package/src/containers/Project/ProjectArticle.tsx +117 -0
  420. package/src/containers/Project/ProjectSettings.tsx +118 -0
  421. package/src/containers/Project/index.ts +16 -0
  422. package/src/containers/Project/triggers.ts +131 -0
  423. package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
  424. package/src/containers/PromptArticle/index.ts +7 -0
  425. package/src/containers/TriggerStatus/TriggerStatus.tsx +150 -0
  426. package/src/containers/TriggerStatus/index.ts +7 -0
  427. package/src/containers/index.ts +15 -0
  428. package/src/hooks/index.ts +8 -4
  429. package/src/hooks/useBlueprintRegistry.ts +108 -0
  430. package/src/hooks/useChatProcessor.ts +40 -105
  431. package/src/hooks/useChatServices.ts +31 -75
  432. package/src/hooks/useChatToolbarActions.ts +122 -0
  433. package/src/hooks/useContextBinder.ts +32 -0
  434. package/src/hooks/useContextObjects.ts +46 -0
  435. package/src/hooks/useFilteredTypes.ts +37 -0
  436. package/src/hooks/useFlush.ts +35 -0
  437. package/src/hooks/useOnline.ts +10 -0
  438. package/src/hooks/usePresets.ts +44 -0
  439. package/src/hooks/useReferencesProvider.ts +12 -13
  440. package/src/index.ts +3 -1
  441. package/src/meta.ts +11 -8
  442. package/src/processor/index.ts +7 -0
  443. package/src/{hooks → processor}/presets.ts +16 -8
  444. package/src/processor/processor.test.ts +73 -0
  445. package/src/processor/processor.ts +296 -0
  446. package/src/processor/update-name.ts +58 -0
  447. package/src/queue-logger.ts +17 -18
  448. package/src/testing/index.ts +1 -1
  449. package/src/testing/test-generator.ts +262 -0
  450. package/src/testing/test-sequence.ts +5 -30
  451. package/src/testing/test-services.ts +10 -14
  452. package/src/translations.ts +71 -28
  453. package/src/types/Assistant.ts +28 -0
  454. package/src/types/AssistantAction.ts +76 -0
  455. package/src/types/capabilities.ts +27 -0
  456. package/src/types/defs.ts +5 -0
  457. package/src/types/events.ts +11 -0
  458. package/src/types/index.ts +9 -1
  459. package/src/types/service.ts +27 -16
  460. package/src/vite-env.d.ts +30 -0
  461. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs +0 -54
  462. package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +0 -7
  463. package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs +0 -72
  464. package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +0 -7
  465. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +0 -162
  466. package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
  467. package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs +0 -27
  468. package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +0 -7
  469. package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs +0 -223
  470. package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +0 -7
  471. package/dist/lib/browser/chunk-AEAEKWOC.mjs +0 -98
  472. package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +0 -7
  473. package/dist/lib/browser/chunk-EQDW6BYQ.mjs +0 -108
  474. package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +0 -7
  475. package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
  476. package/dist/lib/browser/chunk-FDCJSQYF.mjs.map +0 -7
  477. package/dist/lib/browser/chunk-JQBVLTM5.mjs +0 -158
  478. package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +0 -7
  479. package/dist/lib/browser/chunk-OWY4CUQY.mjs +0 -2245
  480. package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +0 -7
  481. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +0 -60
  482. package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +0 -7
  483. package/dist/lib/browser/react-surface-66VY37YQ.mjs +0 -150
  484. package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +0 -7
  485. package/dist/lib/browser/settings-2DGP3UTS.mjs +0 -22
  486. package/dist/lib/browser/settings-2DGP3UTS.mjs.map +0 -7
  487. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +0 -55
  488. package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +0 -7
  489. package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs +0 -73
  490. package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +0 -7
  491. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +0 -163
  492. package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
  493. package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs +0 -28
  494. package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +0 -7
  495. package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs +0 -224
  496. package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +0 -7
  497. package/dist/lib/node-esm/chunk-2XL6MNPE.mjs +0 -99
  498. package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +0 -7
  499. package/dist/lib/node-esm/chunk-BISJDTBK.mjs +0 -159
  500. package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +0 -7
  501. package/dist/lib/node-esm/chunk-E33DNNDW.mjs +0 -109
  502. package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +0 -7
  503. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
  504. package/dist/lib/node-esm/chunk-QN2H2EHV.mjs.map +0 -7
  505. package/dist/lib/node-esm/chunk-SENTQAEO.mjs +0 -2246
  506. package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +0 -7
  507. package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +0 -61
  508. package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +0 -7
  509. package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs +0 -151
  510. package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +0 -7
  511. package/dist/lib/node-esm/settings-47RYZOU4.mjs +0 -23
  512. package/dist/lib/node-esm/settings-47RYZOU4.mjs.map +0 -7
  513. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  514. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  515. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  516. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  517. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  518. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  519. package/dist/types/src/capabilities/settings.d.ts +0 -4
  520. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  521. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +0 -6
  522. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +0 -1
  523. package/dist/types/src/components/AssistantSettings/index.d.ts +0 -2
  524. package/dist/types/src/components/AssistantSettings/index.d.ts.map +0 -1
  525. package/dist/types/src/components/ChatContainer.d.ts +0 -11
  526. package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
  527. package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
  528. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
  529. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
  530. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
  531. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
  532. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
  533. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
  534. package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
  535. package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
  536. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  537. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  538. package/dist/types/src/components/SequenceContainer.d.ts +0 -8
  539. package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
  540. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
  541. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
  542. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -8
  543. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
  544. package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
  545. package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
  546. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  547. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  548. package/dist/types/src/events.d.ts +0 -4
  549. package/dist/types/src/events.d.ts.map +0 -1
  550. package/dist/types/src/hooks/chat-processor.d.ts +0 -86
  551. package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
  552. package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
  553. package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
  554. package/dist/types/src/hooks/presets.d.ts.map +0 -1
  555. package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
  556. package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
  557. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  558. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  559. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  560. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  561. package/dist/types/src/parser/index.d.ts +0 -4
  562. package/dist/types/src/parser/index.d.ts.map +0 -1
  563. package/dist/types/src/parser/query-parser.d.ts +0 -15
  564. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  565. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  566. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  567. package/dist/types/src/parser/types.d.ts +0 -24
  568. package/dist/types/src/parser/types.d.ts.map +0 -1
  569. package/dist/types/src/stories/Chat.stories.d.ts +0 -249
  570. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  571. package/dist/types/src/testing/test-functions.d.ts +0 -3
  572. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  573. package/dist/types/src/tools/function.d.ts +0 -5
  574. package/dist/types/src/tools/function.d.ts.map +0 -1
  575. package/dist/types/src/tools/index.d.ts +0 -3
  576. package/dist/types/src/tools/index.d.ts.map +0 -1
  577. package/dist/types/src/tools/openapi.d.ts +0 -10
  578. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  579. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  580. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  581. package/dist/types/src/types/schema.d.ts +0 -88
  582. package/dist/types/src/types/schema.d.ts.map +0 -1
  583. package/src/capabilities/app-graph-builder.ts +0 -253
  584. package/src/capabilities/intent-resolver.ts +0 -58
  585. package/src/capabilities/react-surface.tsx +0 -138
  586. package/src/capabilities/settings.ts +0 -19
  587. package/src/components/AssistantSettings/AssistantSettings.tsx +0 -105
  588. package/src/components/AssistantSettings/index.ts +0 -5
  589. package/src/components/ChatContainer.tsx +0 -45
  590. package/src/components/ChatDialog.tsx +0 -64
  591. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
  592. package/src/components/ChatThread/ChatMessage.tsx +0 -268
  593. package/src/components/ChatThread/ToolBlock.tsx +0 -121
  594. package/src/components/ChatThread/reducer.ts +0 -52
  595. package/src/components/PromptSettings.tsx +0 -89
  596. package/src/components/SequenceContainer.tsx +0 -132
  597. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
  598. package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
  599. package/src/components/TemplateContainer.tsx +0 -24
  600. package/src/events.ts +0 -11
  601. package/src/hooks/chat-processor.test.ts +0 -16
  602. package/src/hooks/chat-processor.ts +0 -314
  603. package/src/hooks/useBlueprints.ts +0 -57
  604. package/src/parser/filter-generator.test.ts +0 -32
  605. package/src/parser/filter-generator.ts +0 -81
  606. package/src/parser/index.ts +0 -7
  607. package/src/parser/query-parser.test.ts +0 -139
  608. package/src/parser/query-parser.ts +0 -199
  609. package/src/parser/types.ts +0 -34
  610. package/src/shims.d.ts +0 -8
  611. package/src/stories/Chat.stories.tsx +0 -378
  612. package/src/testing/test-functions.ts +0 -11
  613. package/src/tools/function.ts +0 -46
  614. package/src/tools/index.ts +0 -6
  615. package/src/tools/openapi.test.ts +0 -217
  616. package/src/tools/openapi.ts +0 -338
  617. package/src/types/schema.ts +0 -95
  618. package/src/typings.d.ts +0 -9
@@ -1,2246 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ServiceType
4
- } from "./chunk-BISJDTBK.mjs";
5
- import {
6
- __export,
7
- __reExport,
8
- meta
9
- } from "./chunk-QN2H2EHV.mjs";
10
-
11
- // src/hooks/useChatProcessor.ts
12
- import { useEffect as useEffect2, useMemo as useMemo3, useState as useState2 } from "react";
13
- import { Capabilities as Capabilities3, useCapabilities as useCapabilities3, useIntentDispatcher } from "@dxos/app-framework";
14
- import { Conversation, createSystemPrompt } from "@dxos/assistant";
15
- import { FunctionType } from "@dxos/functions";
16
- import { log as log5 } from "@dxos/log";
17
- import { useConfig } from "@dxos/react-client";
18
- import { Filter as Filter3, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
19
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
20
-
21
- // src/hooks/index.ts
22
- var hooks_exports = {};
23
- __export(hooks_exports, {
24
- AiServiceOverloadedError: () => AiServiceOverloadedError,
25
- AiServicePresets: () => AiServicePresets,
26
- ChatProcessor: () => ChatProcessor,
27
- Stable: () => Stable,
28
- useBlueprints: () => useBlueprints,
29
- useChatProcessor: () => useChatProcessor,
30
- useChatServices: () => useChatServices,
31
- useReferencesProvider: () => useReferencesProvider
32
- });
33
-
34
- // src/hooks/chat-processor.ts
35
- import { batch, computed, signal } from "@preact/signals-core";
36
- import { Effect } from "effect";
37
- import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
38
- import { ArtifactDiffResolver } from "@dxos/assistant";
39
- import { Context } from "@dxos/context";
40
- import { Obj } from "@dxos/echo";
41
- import { runAndForwardErrors } from "@dxos/effect";
42
- import { log } from "@dxos/log";
43
- import { Filter, getVersion } from "@dxos/react-client/echo";
44
- import { DataType } from "@dxos/schema";
45
- function _ts_add_disposable_resource(env, value, async) {
46
- if (value !== null && value !== void 0) {
47
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
48
- var dispose, inner;
49
- if (async) {
50
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
51
- dispose = value[Symbol.asyncDispose];
52
- }
53
- if (dispose === void 0) {
54
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
55
- dispose = value[Symbol.dispose];
56
- if (async) inner = dispose;
57
- }
58
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
59
- if (inner) dispose = function() {
60
- try {
61
- inner.call(this);
62
- } catch (e) {
63
- return Promise.reject(e);
64
- }
65
- };
66
- env.stack.push({
67
- value,
68
- dispose,
69
- async
70
- });
71
- } else if (async) {
72
- env.stack.push({
73
- async: true
74
- });
75
- }
76
- return value;
77
- }
78
- function _ts_dispose_resources(env) {
79
- var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
80
- var e = new Error(message);
81
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
82
- };
83
- return (_ts_dispose_resources = function _ts_dispose_resources2(env2) {
84
- function fail(e) {
85
- env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
86
- env2.hasError = true;
87
- }
88
- var r, s = 0;
89
- function next() {
90
- while (r = env2.stack.pop()) {
91
- try {
92
- if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
93
- if (r.dispose) {
94
- var result = r.dispose.call(r.value);
95
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
96
- fail(e);
97
- return next();
98
- });
99
- } else s |= 1;
100
- } catch (e) {
101
- fail(e);
102
- }
103
- }
104
- if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
105
- if (env2.hasError) throw env2.error;
106
- }
107
- return next();
108
- })(env);
109
- }
110
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
111
- var defaultOptions = {
112
- model: DEFAULT_EDGE_MODEL,
113
- systemPrompt: "you are a helpful assistant"
114
- };
115
- var ChatProcessor = class {
116
- constructor(_services, _conversation, _options = defaultOptions) {
117
- this._services = _services;
118
- this._conversation = _conversation;
119
- this._options = _options;
120
- this._pending = signal([]);
121
- this._streaming = signal(void 0);
122
- this.streaming = computed(() => this._streaming.value !== void 0);
123
- this.error = signal(void 0);
124
- this.messages = computed(() => {
125
- const messages = [
126
- ...this._pending.value
127
- ];
128
- if (this._streaming.value) {
129
- messages.push(Obj.make(DataType.Message, this._streaming.value));
130
- }
131
- return messages;
132
- });
133
- this._session = void 0;
134
- this._artifactDiffResolver = {
135
- resolve: async (artifacts) => {
136
- const space = this._options.extensions?.space;
137
- if (!space) {
138
- return /* @__PURE__ */ new Map();
139
- }
140
- const versions = /* @__PURE__ */ new Map();
141
- await Promise.all(artifacts.map(async (artifact) => {
142
- const { objects: [object] } = await space.db.query(Filter.ids(artifact.id)).run();
143
- if (!object) {
144
- return;
145
- }
146
- versions.set(artifact.id, {
147
- version: getVersion(object),
148
- diff: `Current state: ${JSON.stringify(object)}`
149
- });
150
- }));
151
- return versions;
152
- }
153
- };
154
- this._tools = [
155
- ..._options.tools ?? []
156
- ];
157
- }
158
- get conversation() {
159
- return this._conversation;
160
- }
161
- get context() {
162
- return this._conversation.context;
163
- }
164
- get blueprintRegistry() {
165
- return this._options.blueprintRegistry;
166
- }
167
- get tools() {
168
- return this._tools;
169
- }
170
- /**
171
- * @deprecated Replace with blueprints
172
- */
173
- setTools(tools) {
174
- this._tools = tools;
175
- }
176
- /**
177
- * Make GPT request.
178
- */
179
- async request(message, options = {}) {
180
- const env = {
181
- stack: [],
182
- error: void 0,
183
- hasError: false
184
- };
185
- try {
186
- const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
187
- F: __dxlog_file,
188
- L: 138
189
- }), true);
190
- this._conversation.onBegin.on(ctx, (session) => {
191
- log.info("onBegin", {
192
- session,
193
- isDisposed: ctx.disposed
194
- }, {
195
- F: __dxlog_file,
196
- L: 141,
197
- S: this,
198
- C: (f, a) => f(...a)
199
- });
200
- this._session = session;
201
- ctx.onDispose(() => {
202
- log.info("onDispose", {
203
- session,
204
- isDisposed: ctx.disposed
205
- }, {
206
- F: __dxlog_file,
207
- L: 145,
208
- S: this,
209
- C: (f, a) => f(...a)
210
- });
211
- if (this._session === session) {
212
- this._session = void 0;
213
- }
214
- });
215
- session.userMessage.on((message2) => {
216
- log.info("userMessage", {
217
- message: message2
218
- }, {
219
- F: __dxlog_file,
220
- L: 153,
221
- S: this,
222
- C: (f, a) => f(...a)
223
- });
224
- this._pending.value = [
225
- ...this._pending.value,
226
- message2
227
- ];
228
- });
229
- session.message.on((message2) => {
230
- batch(() => {
231
- this._pending.value = [
232
- ...this._pending.value,
233
- message2
234
- ];
235
- this._streaming.value = void 0;
236
- });
237
- });
238
- session.update.on((block) => {
239
- batch(() => {
240
- if (!this._streaming.value) {
241
- this._streaming.value = Obj.make(DataType.Message, {
242
- created: (/* @__PURE__ */ new Date()).toISOString(),
243
- sender: {
244
- role: "assistant"
245
- },
246
- blocks: [
247
- block
248
- ]
249
- });
250
- } else if (this._streaming.value.blocks.at(-1)?.pending === true) {
251
- this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
252
- } else {
253
- this._streaming.value.blocks.push(block);
254
- }
255
- });
256
- });
257
- session.block.on((block) => {
258
- if (!this._streaming.value) {
259
- this._streaming.value = Obj.make(DataType.Message, {
260
- created: (/* @__PURE__ */ new Date()).toISOString(),
261
- sender: {
262
- role: "assistant"
263
- },
264
- blocks: [
265
- block
266
- ]
267
- });
268
- } else if (this._streaming.value.blocks.at(-1)?.pending === true) {
269
- this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
270
- } else {
271
- this._streaming.value.blocks.push(block);
272
- }
273
- });
274
- });
275
- try {
276
- const messages = await runAndForwardErrors(this._conversation.run({
277
- prompt: message,
278
- // TODO(burdon): Construct from blueprints?
279
- systemPrompt: this._options.systemPrompt
280
- }).pipe(
281
- //
282
- Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
283
- // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
284
- Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
285
- Effect.provide(this._services),
286
- Effect.tapErrorCause((cause) => {
287
- log.error("error", {
288
- cause
289
- }, {
290
- F: __dxlog_file,
291
- L: 243,
292
- S: this,
293
- C: (f, a) => f(...a)
294
- });
295
- return Effect.void;
296
- })
297
- ));
298
- log("completed", {
299
- messages
300
- }, {
301
- F: __dxlog_file,
302
- L: 249,
303
- S: this,
304
- C: (f, a) => f(...a)
305
- });
306
- } catch (err) {
307
- log.catch(err, void 0, {
308
- F: __dxlog_file,
309
- L: 251,
310
- S: this,
311
- C: (f, a) => f(...a)
312
- });
313
- if (err instanceof Error && err.message.includes("Overloaded")) {
314
- this.error.value = new AiServiceOverloadedError("AI service overloaded", {
315
- cause: err
316
- });
317
- } else {
318
- this.error.value = new Error("AI service error", {
319
- cause: err
320
- });
321
- }
322
- }
323
- return this._reset();
324
- } catch (e) {
325
- env.error = e;
326
- env.hasError = true;
327
- } finally {
328
- const result = _ts_dispose_resources(env);
329
- if (result) await result;
330
- }
331
- }
332
- /**
333
- * Cancel pending requests.
334
- * @returns Pending requests (incl. the request message).
335
- */
336
- async cancel() {
337
- log.info("cancelling...", void 0, {
338
- F: __dxlog_file,
339
- L: 267,
340
- S: this,
341
- C: (f, a) => f(...a)
342
- });
343
- this._session?.abort();
344
- return this._reset();
345
- }
346
- async _reset() {
347
- const messages = this._pending.value;
348
- batch(() => {
349
- this._pending.value = [];
350
- this._streaming.value = void 0;
351
- });
352
- return messages;
353
- }
354
- };
355
- var AiServiceOverloadedError = class extends Error {
356
- constructor() {
357
- super(...arguments);
358
- this.code = "AI_SERVICE_OVERLOADED";
359
- }
360
- };
361
-
362
- // src/hooks/presets.ts
363
- import { Schema } from "effect";
364
- var ModelProviders = [
365
- "dxos-local",
366
- "dxos-remote",
367
- "lm-studio"
368
- ];
369
- var ModelProvider = Schema.Literal(...ModelProviders);
370
- var createModelLabel = (model) => {
371
- const parts = model.split("/");
372
- return parts[parts.length - 1];
373
- };
374
- var AiServicePresets = [
375
- {
376
- provider: "dxos-remote",
377
- model: "@anthropic/claude-3-5-haiku-20241022"
378
- },
379
- {
380
- provider: "dxos-remote",
381
- model: "@anthropic/claude-opus-4-0"
382
- },
383
- {
384
- provider: "lm-studio",
385
- model: "@google/gemma-3-12b"
386
- },
387
- {
388
- provider: "lm-studio",
389
- model: "@mlx-community/llama-3.2-3b-instruct"
390
- }
391
- ].map(({ model, provider }, i) => ({
392
- id: `preset-${i}`,
393
- provider,
394
- model,
395
- label: createModelLabel(model)
396
- }));
397
-
398
- // src/hooks/useBlueprints.ts
399
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
400
- import { effect } from "@preact/signals-react";
401
- import { useCallback, useEffect, useState } from "react";
402
- import { Blueprint } from "@dxos/blueprints";
403
- import { Obj as Obj2, Ref } from "@dxos/echo";
404
- import { log as log2 } from "@dxos/log";
405
- import { isNonNullable } from "@dxos/util";
406
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useBlueprints.ts";
407
- var useBlueprints = (space, context, blueprintRegistry) => {
408
- var _effect = _useSignals();
409
- try {
410
- const [blueprints, setBlueprints] = useState([]);
411
- useEffect(() => {
412
- let t;
413
- effect(() => {
414
- const refs = [
415
- ...context.blueprints.value ?? []
416
- ];
417
- t = setTimeout(async () => {
418
- const blueprints2 = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
419
- setBlueprints(blueprints2);
420
- });
421
- });
422
- return () => clearTimeout(t);
423
- }, [
424
- context
425
- ]);
426
- const handleUpdate = useCallback((key, active) => {
427
- log2.info("update", {
428
- key,
429
- active
430
- }, {
431
- F: __dxlog_file2,
432
- L: 41,
433
- S: void 0,
434
- C: (f, a) => f(...a)
435
- });
436
- if (active) {
437
- const blueprint = blueprintRegistry?.getByKey(key);
438
- if (blueprint) {
439
- const { id: _id, ...data } = blueprint;
440
- const obj = space.db.add(Obj2.make(Blueprint.Blueprint, data));
441
- void context.bind({
442
- blueprints: [
443
- Ref.make(obj)
444
- ]
445
- });
446
- }
447
- }
448
- }, [
449
- space,
450
- context
451
- ]);
452
- return [
453
- blueprints,
454
- handleUpdate
455
- ];
456
- } finally {
457
- _effect.f();
458
- }
459
- };
460
-
461
- // src/hooks/useChatServices.ts
462
- var useChatServices_exports = {};
463
- __export(useChatServices_exports, {
464
- useChatServices: () => useChatServices
465
- });
466
- __reExport(useChatServices_exports, assistant_star);
467
- import { Layer } from "effect";
468
- import { useMemo } from "react";
469
- import { useDeepCompareMemoize } from "use-deep-compare-effect";
470
- import { ToolRegistry } from "@dxos/ai";
471
- import { AiServiceTestingPreset } from "@dxos/ai/testing";
472
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
473
- import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
474
- import { ConfiguredCredentialsService, CredentialsService, DatabaseService, EventLogger, FunctionCallService, QueueService, TracingService } from "@dxos/functions";
475
- import * as assistant_star from "@dxos/assistant";
476
- var useChatServices = ({ space }) => {
477
- const toolRegistry = useToolRegistry();
478
- const toolResolver = useToolResolver();
479
- const toolExecutionService = useToolExecutionService();
480
- return useMemo(() => {
481
- return Layer.mergeAll(AiServiceTestingPreset("edge-remote").pipe(Layer.orDie), Layer.succeed(CredentialsService, new ConfiguredCredentialsService()), space ? Layer.succeed(DatabaseService, DatabaseService.make(space.db)) : DatabaseService.notAvailable, space ? Layer.succeed(QueueService, QueueService.make(space.queues)) : QueueService.notAvailable, Layer.succeed(FunctionCallService, FunctionCallService.mock()), Layer.succeed(TracingService, TracingService.noop), Layer.succeed(EventLogger, EventLogger.noop), toolResolver, toolExecutionService);
482
- }, [
483
- space,
484
- toolRegistry,
485
- toolResolver
486
- ]);
487
- };
488
- var useToolResolver = () => {
489
- const functions = useCapabilities(Capabilities.Functions).flat();
490
- return useMemo(() => makeToolResolverFromFunctions(functions), [
491
- useDeepCompareMemoize(functions.map((f) => f.name))
492
- ]);
493
- };
494
- var useToolExecutionService = () => {
495
- const functions = useCapabilities(Capabilities.Functions).flat();
496
- return useMemo(() => makeToolExecutionServiceFromFunctions(functions), [
497
- useDeepCompareMemoize(functions.map((f) => f.name))
498
- ]);
499
- };
500
- var useToolRegistry = () => {
501
- const tools = useCapabilities(Capabilities.Tools).flat();
502
- return useMemo(() => {
503
- const toolRegistry = new ToolRegistry([]);
504
- for (const tool of tools) {
505
- if (!toolRegistry.has(tool)) {
506
- toolRegistry.register(tool);
507
- }
508
- }
509
- return toolRegistry;
510
- }, [
511
- useDeepCompareMemoize(tools)
512
- ]);
513
- };
514
-
515
- // src/hooks/index.ts
516
- __reExport(hooks_exports, useChatServices_exports);
517
-
518
- // src/hooks/useReferencesProvider.ts
519
- import { useMemo as useMemo2 } from "react";
520
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
521
- import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
522
- var useReferencesProvider = (space) => {
523
- const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
524
- return useMemo2(() => {
525
- if (!space) {
526
- return void 0;
527
- }
528
- return {
529
- getReferences: async ({ query }) => {
530
- const schemas = artifactDefinitions.map((artifact) => artifact.schema);
531
- const { objects } = await space.db.query(Filter2.or(...schemas.map((schema) => Filter2.type(schema)))).run();
532
- return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
533
- uri: Obj3.getDXN(object).toString(),
534
- label: Obj3.getLabel(object) ?? ""
535
- }));
536
- },
537
- resolveReference: async ({ uri }) => {
538
- const object = await space.db.query(Filter2.ids(uri)).first();
539
- return {
540
- uri,
541
- label: Obj3.getLabel(object) ?? ""
542
- };
543
- }
544
- };
545
- }, [
546
- space,
547
- artifactDefinitions
548
- ]);
549
- };
550
- var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
551
-
552
- // src/tools/function.ts
553
- import { createTool, ToolResult } from "@dxos/ai";
554
- import { Type } from "@dxos/echo";
555
- import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
556
- import { log as log3 } from "@dxos/log";
557
- import { getMeta } from "@dxos/react-client/echo";
558
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
559
- var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
560
- if (!fn.description || !fn.inputSchema) {
561
- return void 0;
562
- }
563
- const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
564
- if (!existingFunctionUrl) {
565
- return void 0;
566
- }
567
- const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
568
- spaceId
569
- });
570
- return createTool("user-function", {
571
- name: fn.name,
572
- description: fn.description,
573
- schema: Type.toEffectSchema(fn.inputSchema),
574
- execute: async (input) => {
575
- log3.info("execute function tool", {
576
- name: fn.name,
577
- url,
578
- input
579
- }, {
580
- F: __dxlog_file3,
581
- L: 34,
582
- S: void 0,
583
- C: (f, a) => f(...a)
584
- });
585
- const response = await fetch(url, {
586
- method: "POST",
587
- headers: {
588
- "Content-Type": "application/json"
589
- },
590
- body: JSON.stringify(input)
591
- });
592
- return ToolResult.Success(await response.text());
593
- }
594
- });
595
- };
596
-
597
- // src/tools/openapi.ts
598
- import { Schema as Schema2 } from "effect";
599
- import jsonpointer from "jsonpointer";
600
- import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
601
- import { Type as Type2 } from "@dxos/echo";
602
- import { normalizeSchema } from "@dxos/echo-schema";
603
- import { invariant } from "@dxos/invariant";
604
- import { log as log4 } from "@dxos/log";
605
- import { deepMapValues } from "@dxos/util";
606
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
607
- var createToolsFromService = async (service) => {
608
- invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
609
- F: __dxlog_file4,
610
- L: 24,
611
- S: void 0,
612
- A: [
613
- "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
614
- ""
615
- ]
616
- });
617
- const iface = service.interfaces[0];
618
- invariant(iface.schemaUrl, void 0, {
619
- F: __dxlog_file4,
620
- L: 26,
621
- S: void 0,
622
- A: [
623
- "iface.schemaUrl",
624
- ""
625
- ]
626
- });
627
- invariant(iface.schemaUrl, void 0, {
628
- F: __dxlog_file4,
629
- L: 27,
630
- S: void 0,
631
- A: [
632
- "iface.schemaUrl",
633
- ""
634
- ]
635
- });
636
- return createToolsFromApi(iface.schemaUrl, {
637
- authorization: iface.authorization
638
- });
639
- };
640
- var createToolsFromApi = async (url, options) => {
641
- const res = await fetch(url);
642
- const spec = await res.json();
643
- log4("spec", {
644
- spec
645
- }, {
646
- F: __dxlog_file4,
647
- L: 37,
648
- S: void 0,
649
- C: (f, a) => f(...a)
650
- });
651
- const tools = [];
652
- for (const [path, pathItem] of Object.entries(spec.paths)) {
653
- if (typeof pathItem !== "object") {
654
- continue;
655
- }
656
- const { ...methods } = pathItem;
657
- for (const [method, m] of Object.entries(methods)) {
658
- const methodItem = m;
659
- log4("methodItem", {
660
- path,
661
- method,
662
- methodItem
663
- }, {
664
- F: __dxlog_file4,
665
- L: 48,
666
- S: void 0,
667
- C: (f, a) => f(...a)
668
- });
669
- const parametersResolved = methodItem.parameters?.map((parameter) => {
670
- const resolved = resolveJsonSchema(parameter, spec);
671
- return resolved;
672
- }) ?? [];
673
- const inputSchema = {
674
- type: "object",
675
- properties: {}
676
- };
677
- const endpointParameters = [];
678
- for (const parameter of parametersResolved) {
679
- log4("parameter", {
680
- parameter
681
- }, {
682
- F: __dxlog_file4,
683
- L: 63,
684
- S: void 0,
685
- C: (f, a) => f(...a)
686
- });
687
- if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
688
- continue;
689
- }
690
- endpointParameters.push(parameter);
691
- if (parameter.schema) {
692
- inputSchema.properties[parameter.name] = normalizeSchema(parameter.schema);
693
- } else if (typeof parameter.type === "string") {
694
- const { name, in: _in, required, ...schema } = parameter;
695
- inputSchema.properties[name] = normalizeSchema(schema);
696
- if (required) {
697
- inputSchema.required ??= [];
698
- inputSchema.required.push(name);
699
- }
700
- }
701
- }
702
- log4("inputSchema", {
703
- inputSchema
704
- }, {
705
- F: __dxlog_file4,
706
- L: 88,
707
- S: void 0,
708
- C: (f, a) => f(...a)
709
- });
710
- Schema2.validateSync(Type2.JsonSchema)(inputSchema);
711
- const description = methodItem.description ?? methodItem.summary;
712
- if (!description) {
713
- log4.warn("no description", {
714
- path,
715
- method
716
- }, {
717
- F: __dxlog_file4,
718
- L: 93,
719
- S: void 0,
720
- C: (f, a) => f(...a)
721
- });
722
- continue;
723
- }
724
- const endpoint = {
725
- document: spec,
726
- path,
727
- method,
728
- parameters: endpointParameters,
729
- authorization: options?.authorization
730
- };
731
- tools.push(
732
- // TODO(burdon): Namespace?
733
- createRawTool("openapi", {
734
- name: getToolName(path, method, methodItem),
735
- description: options?.instructions ? `${options.instructions}
736
-
737
- ${description}` : description,
738
- parameters: inputSchema,
739
- execute: async (input) => {
740
- const response = await callApiEndpoint(endpoint, input);
741
- return ToolResult2.Success(response);
742
- }
743
- })
744
- );
745
- }
746
- }
747
- return tools;
748
- };
749
- var getToolName = (path, method, methodItem) => {
750
- if (methodItem.operationId) {
751
- return methodItem.operationId;
752
- }
753
- let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
754
- while (name.length > MAX_TOOL_NAME_LENGTH) {
755
- const lengthBefore = name.length;
756
- for (const word of GENERIC_WORDS) {
757
- if (name.includes(word)) {
758
- name = name.replace(word, "");
759
- break;
760
- }
761
- }
762
- name = name.replaceAll("__", "_").replace(/_$/, "");
763
- const lengthAfter = name.length;
764
- if (lengthBefore === lengthAfter) {
765
- break;
766
- }
767
- }
768
- name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
769
- return name.slice(0, MAX_TOOL_NAME_LENGTH);
770
- };
771
- var MAX_TOOL_NAME_LENGTH = 64;
772
- var GENERIC_WORDS = [
773
- "services",
774
- "service",
775
- "api",
776
- "rest",
777
- "endpoint",
778
- "get",
779
- "post",
780
- "put",
781
- "delete",
782
- "patch",
783
- "head",
784
- "options",
785
- "trace",
786
- "service",
787
- "api",
788
- "endpoint"
789
- ];
790
- var callApiEndpoint = async (endpoint, input) => {
791
- log4.info("endpoint", {
792
- method: endpoint.method,
793
- name: endpoint.path,
794
- input
795
- }, {
796
- F: __dxlog_file4,
797
- L: 180,
798
- S: void 0,
799
- C: (f, a) => f(...a)
800
- });
801
- let url = getEndpointUrl(endpoint);
802
- const request = {
803
- method: endpoint.method,
804
- headers: {}
805
- };
806
- const query = new URLSearchParams();
807
- let body;
808
- for (const parameter of endpoint.parameters) {
809
- if (input[parameter.name] === void 0) {
810
- continue;
811
- }
812
- switch (parameter.in) {
813
- case "header": {
814
- if (parameter.example) {
815
- request.headers[parameter.name] = parameter.default;
816
- }
817
- break;
818
- }
819
- case "path": {
820
- url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
821
- break;
822
- }
823
- case "body": {
824
- const value = input[parameter.name];
825
- const effectSchema = Type2.toEffectSchema(parameter.schema);
826
- Schema2.validateSync(effectSchema)(value);
827
- if (body) {
828
- throw new Error(`Duplicate body parameter: ${parameter.name}`);
829
- }
830
- body = value;
831
- break;
832
- }
833
- case "query": {
834
- query.set(parameter.name, input[parameter.name]);
835
- break;
836
- }
837
- }
838
- }
839
- if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
840
- request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
841
- } else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
842
- query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
843
- }
844
- if (query.size > 0) {
845
- url += `?${query.toString()}`;
846
- }
847
- if (body) {
848
- request.body = JSON.stringify(body);
849
- request.headers["Content-Type"] = "application/json";
850
- }
851
- log4.info("request", {
852
- url,
853
- request
854
- }, {
855
- F: __dxlog_file4,
856
- L: 243,
857
- S: void 0,
858
- C: (f, a) => f(...a)
859
- });
860
- const response = await fetch(url, request);
861
- log4.info("response", {
862
- ok: response.ok,
863
- status: response.status,
864
- statusText: response.statusText
865
- }, {
866
- F: __dxlog_file4,
867
- L: 246,
868
- S: void 0,
869
- C: (f, a) => f(...a)
870
- });
871
- if (response.ok) {
872
- const contentType = response.headers.get("Content-Type");
873
- if (contentType?.includes("application/json")) {
874
- return await response.json();
875
- } else {
876
- return await response.text();
877
- }
878
- } else {
879
- if (response.headers.get("Content-Type")?.includes("application/json")) {
880
- const responseBody = await response.text();
881
- let error;
882
- try {
883
- error = JSON.parse(responseBody);
884
- } catch {
885
- error = responseBody;
886
- }
887
- log4.error("error", {
888
- error
889
- }, {
890
- F: __dxlog_file4,
891
- L: 264,
892
- S: void 0,
893
- C: (f, a) => f(...a)
894
- });
895
- throw new Error(error.message);
896
- } else {
897
- const error = await response.text();
898
- log4.error("error", {
899
- error
900
- }, {
901
- F: __dxlog_file4,
902
- L: 268,
903
- S: void 0,
904
- C: (f, a) => f(...a)
905
- });
906
- throw new Error(error);
907
- }
908
- }
909
- };
910
- var getEndpointUrl = (endpoint) => {
911
- let url = "";
912
- if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
913
- url = endpoint.document.servers[0].url;
914
- } else {
915
- invariant(!isV3_1(endpoint.document), void 0, {
916
- F: __dxlog_file4,
917
- L: 279,
918
- S: void 0,
919
- A: [
920
- "!isV3_1(endpoint.document)",
921
- ""
922
- ]
923
- });
924
- url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
925
- }
926
- if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
927
- url += endpoint.document.basePath;
928
- }
929
- url += endpoint.path;
930
- return url;
931
- };
932
- var resolveAuthorization = async (authorization) => {
933
- switch (authorization.type) {
934
- case "api-key": {
935
- invariant(authorization.placement.type === "authorization-header", void 0, {
936
- F: __dxlog_file4,
937
- L: 295,
938
- S: void 0,
939
- A: [
940
- "authorization.placement.type === 'authorization-header'",
941
- ""
942
- ]
943
- });
944
- return `Bearer ${authorization.key}`;
945
- }
946
- case "oauth": {
947
- const response = await fetch(authorization.tokenUrl, {
948
- method: "POST",
949
- headers: {
950
- "Content-Type": "application/x-www-form-urlencoded"
951
- },
952
- body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
953
- });
954
- const data = await response.json();
955
- return `Bearer ${data.access_token}`;
956
- }
957
- default: {
958
- throw new Error(`Unknown authorization type: ${authorization.type}`);
959
- }
960
- }
961
- };
962
- var resolveJsonSchema = (schema, base) => {
963
- return deepMapValues(schema, (value, recurse) => {
964
- if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
965
- if (value.$ref.startsWith("#")) {
966
- const resolved = jsonpointer.get(base, value.$ref.slice(1));
967
- if (resolved) {
968
- return recurse(resolved);
969
- } else {
970
- log4.warn("unresolved", {
971
- ref: value.$ref,
972
- base
973
- }, {
974
- F: __dxlog_file4,
975
- L: 328,
976
- S: void 0,
977
- C: (f, a) => f(...a)
978
- });
979
- }
980
- }
981
- }
982
- return recurse(value);
983
- });
984
- };
985
- var isV3_1 = (document) => {
986
- return document.openapi === "3.0.1";
987
- };
988
-
989
- // src/hooks/useChatProcessor.ts
990
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
991
- var useChatProcessor = ({ preset, space, chat, services, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
992
- const { dispatchPromise: dispatch } = useIntentDispatcher();
993
- const globalTools = useCapabilities3(Capabilities3.Tools);
994
- let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
995
- if (noPluginArtifacts) {
996
- artifacts = Stable.array;
997
- }
998
- const remoteServices = useQuery(space, Filter3.type(ServiceType));
999
- const [serviceTools, setServiceTools] = useState2([]);
1000
- useEffect2(() => {
1001
- log5("creating service tools...", void 0, {
1002
- F: __dxlog_file5,
1003
- L: 68,
1004
- S: void 0,
1005
- C: (f, a) => f(...a)
1006
- });
1007
- queueMicrotask(async () => {
1008
- const tools2 = await Promise.all(remoteServices.map((service) => createToolsFromService(service)));
1009
- setServiceTools(tools2.flat());
1010
- });
1011
- }, [
1012
- remoteServices
1013
- ]);
1014
- const config = useConfig();
1015
- const functions = useQuery(space, Filter3.type(FunctionType));
1016
- const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
1017
- chat
1018
- ]);
1019
- const [tools, extensions] = useMemo3(() => {
1020
- log5("creating tools...", void 0, {
1021
- F: __dxlog_file5,
1022
- L: 80,
1023
- S: void 0,
1024
- C: (f, a) => f(...a)
1025
- });
1026
- const tools2 = [
1027
- ...globalTools.flat(),
1028
- ...serviceTools,
1029
- ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
1030
- ];
1031
- const extensions2 = {
1032
- space,
1033
- dispatch,
1034
- pivotId: chatId
1035
- };
1036
- return [
1037
- tools2,
1038
- extensions2
1039
- ];
1040
- }, [
1041
- dispatch,
1042
- globalTools,
1043
- space,
1044
- chatId,
1045
- serviceTools,
1046
- functions
1047
- ]);
1048
- const systemPrompt = useMemo3(() => createSystemPrompt({
1049
- artifacts: artifacts.map((definition) => `${definition.name}
1050
- ${definition.instructions}`),
1051
- artifact,
1052
- instructions
1053
- }), [
1054
- artifacts,
1055
- artifact,
1056
- instructions
1057
- ]);
1058
- const conversation = useMemo3(() => {
1059
- if (!chat?.queue.target) {
1060
- return;
1061
- }
1062
- return new Conversation({
1063
- queue: chat.queue.target
1064
- });
1065
- }, [
1066
- chat?.queue.target
1067
- ]);
1068
- const processor = useMemo3(() => {
1069
- if (!services || !conversation) {
1070
- return void 0;
1071
- }
1072
- log5.info("creating processor", {
1073
- preset,
1074
- artifacts: artifacts.length,
1075
- systemPrompt: systemPrompt.length,
1076
- model: preset?.model,
1077
- settings
1078
- }, {
1079
- F: __dxlog_file5,
1080
- L: 118,
1081
- S: void 0,
1082
- C: (f, a) => f(...a)
1083
- });
1084
- return new ChatProcessor(services, conversation, {
1085
- tools,
1086
- extensions,
1087
- blueprintRegistry,
1088
- artifacts,
1089
- systemPrompt,
1090
- model: preset?.model
1091
- });
1092
- }, [
1093
- services,
1094
- conversation,
1095
- tools,
1096
- blueprintRegistry,
1097
- artifacts,
1098
- extensions,
1099
- systemPrompt,
1100
- preset
1101
- ]);
1102
- return processor;
1103
- };
1104
- var Stable = Object.freeze({
1105
- array: [],
1106
- object: {}
1107
- });
1108
-
1109
- // src/components/Toolbox/Toolbox.tsx
1110
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
1111
- import React, { useState as useState3, useEffect as useEffect3, Fragment } from "react";
1112
- import { parseToolName } from "@dxos/ai";
1113
- import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
1114
- import { FunctionType as FunctionType2 } from "@dxos/functions";
1115
- import { log as log6 } from "@dxos/log";
1116
- import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
1117
- import { useTranslation } from "@dxos/react-ui";
1118
- import { mx } from "@dxos/react-ui-theme";
1119
- var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1120
- var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
1121
- var _effect = _useSignals2();
1122
- try {
1123
- const { t } = useTranslation(meta.id);
1124
- return /* @__PURE__ */ React.createElement("div", {
1125
- className: mx("flex flex-col overflow-y-auto box-content", classNames)
1126
- }, blueprints && blueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1127
- title: "Blueprints",
1128
- items: blueprints.map(({ target }) => ({
1129
- name: target?.name ?? "",
1130
- description: target?.description ?? "",
1131
- subitems: target?.tools.map((toolId) => ({
1132
- name: `\u2219 ${parseToolName(toolId)}`
1133
- }))
1134
- }))
1135
- }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1136
- title: "Blueprints",
1137
- items: activeBlueprints.map(({ target }) => ({
1138
- name: target?.name ?? "",
1139
- description: target?.description ?? "",
1140
- subitems: target?.tools.map((toolId) => ({
1141
- name: `\u2219 ${parseToolName(toolId)}`
1142
- }))
1143
- }))
1144
- }), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1145
- title: "Artifacts",
1146
- items: artifacts.map(({ name, description, tools }) => ({
1147
- name,
1148
- description,
1149
- subitems: tools.map(({ name: name2, description: description2 }) => ({
1150
- name: `\u2219 ${parseToolName(name2)}`,
1151
- description: description2
1152
- }))
1153
- }))
1154
- }), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1155
- title: "Services",
1156
- items: services.map(({ service: { serviceId, name, description }, tools }) => ({
1157
- name: name ?? serviceId,
1158
- description,
1159
- subitems: tools.map(({ name: name2, description: description2 }) => ({
1160
- name: `\u2219 ${name2}`,
1161
- description: description2
1162
- }))
1163
- }))
1164
- }), functions && functions.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1165
- title: "Functions",
1166
- items: functions.map(({ name, description }) => ({
1167
- name,
1168
- description
1169
- }))
1170
- }), !blueprints?.length && !activeBlueprints?.length && !artifacts?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
1171
- } finally {
1172
- _effect.f();
1173
- }
1174
- };
1175
- var Section = ({ title, items, striped }) => {
1176
- var _effect = _useSignals2();
1177
- try {
1178
- const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1179
- const gridClassNames = "grid grid-cols-[8rem_1fr]";
1180
- const subGridClassNames = mx("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
1181
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h1", {
1182
- className: "px-2 text-sm"
1183
- }, title), /* @__PURE__ */ React.createElement("div", {
1184
- className: gridClassNames
1185
- }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React.createElement(Fragment, {
1186
- key: i
1187
- }, name && /* @__PURE__ */ React.createElement("div", {
1188
- className: subGridClassNames
1189
- }, /* @__PURE__ */ React.createElement("div", {
1190
- className: "truncate text-primary-500"
1191
- }, name), /* @__PURE__ */ React.createElement("div", {
1192
- className: "line-clamp-2"
1193
- }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React.createElement("div", {
1194
- key: i2,
1195
- className: mx(subGridClassNames, striped && stripeClassNames)
1196
- }, /* @__PURE__ */ React.createElement("div", {
1197
- className: "truncate"
1198
- }, name2), /* @__PURE__ */ React.createElement("div", {
1199
- className: "line-clamp-3 text-subdued"
1200
- }, description2)))))));
1201
- } finally {
1202
- _effect.f();
1203
- }
1204
- };
1205
- var ToolboxContainer = ({ classNames, space, processor }) => {
1206
- var _effect = _useSignals2();
1207
- try {
1208
- const artifactDefinitions = useCapabilities4(Capabilities4.ArtifactDefinition);
1209
- const services = useQuery2(space, Filter4.type(ServiceType));
1210
- const [serviceTools, setServiceTools] = useState3([]);
1211
- useEffect3(() => {
1212
- log6("creating service tools...", {
1213
- services: services.length
1214
- }, {
1215
- F: __dxlog_file6,
1216
- L: 150,
1217
- S: void 0,
1218
- C: (f, a) => f(...a)
1219
- });
1220
- queueMicrotask(async () => {
1221
- const tools = await Promise.all(services.map(async (service) => ({
1222
- service,
1223
- tools: await createToolsFromService(service)
1224
- })));
1225
- setServiceTools(tools);
1226
- });
1227
- }, [
1228
- services
1229
- ]);
1230
- const functions = useQuery2(space, Filter4.type(FunctionType2));
1231
- return /* @__PURE__ */ React.createElement(Toolbox, {
1232
- classNames,
1233
- blueprints: processor?.context.blueprints.value,
1234
- artifacts: artifactDefinitions,
1235
- services: serviceTools,
1236
- functions
1237
- });
1238
- } finally {
1239
- _effect.f();
1240
- }
1241
- };
1242
-
1243
- // src/components/Chat/Chat.tsx
1244
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1245
- import { Prec } from "@codemirror/state";
1246
- import { keymap } from "@codemirror/view";
1247
- import { createContext } from "@radix-ui/react-context";
1248
- import { dedupeWith } from "effect/Array";
1249
- import React10, { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2, useState as useState6 } from "react";
1250
- import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
1251
- import { Event } from "@dxos/async";
1252
- import { DXN, Obj as Obj5, Ref as Ref3 } from "@dxos/echo";
1253
- import { log as log8 } from "@dxos/log";
1254
- import { useVoiceInput } from "@dxos/plugin-transcription";
1255
- import { getSpace, useQueue } from "@dxos/react-client/echo";
1256
- import { useIdentity } from "@dxos/react-client/halo";
1257
- import { Input as Input2, useTranslation as useTranslation6 } from "@dxos/react-ui";
1258
- import { ChatEditor, references } from "@dxos/react-ui-chat";
1259
- import { mx as mx6 } from "@dxos/react-ui-theme";
1260
- import { DataType as DataType2 } from "@dxos/schema";
1261
- import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
1262
-
1263
- // src/components/ChatPrompt/ChatActions.tsx
1264
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
1265
- import React2 from "react";
1266
- import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
1267
- import { mx as mx2 } from "@dxos/react-ui-theme";
1268
- var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
1269
- var _effect = _useSignals3();
1270
- try {
1271
- const { t } = useTranslation2(meta.id);
1272
- return /* @__PURE__ */ React2.createElement("div", {
1273
- className: mx2("flex items-center mie-1", classNames)
1274
- }, children, processing && /* @__PURE__ */ React2.createElement(IconButton, {
1275
- disabled: !processing,
1276
- classNames: "px-1.5",
1277
- variant: "ghost",
1278
- size: 5,
1279
- icon: "ph--x--regular",
1280
- iconOnly: true,
1281
- label: t("button cancel processing"),
1282
- onClick: () => onEvent?.({
1283
- type: "cancel"
1284
- })
1285
- }) || /* @__PURE__ */ React2.createElement(IconButton, {
1286
- disabled: true,
1287
- classNames: "px-1.5",
1288
- variant: "ghost",
1289
- size: 5,
1290
- icon: "ph--arrow-down--regular",
1291
- iconOnly: true,
1292
- label: t("button scroll down"),
1293
- onClick: () => onEvent?.({
1294
- type: "scroll-to-bottom"
1295
- })
1296
- }), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
1297
- disabled: !processing,
1298
- classNames: mx2("px-1.5", recording && "bg-primary-500"),
1299
- variant: "ghost",
1300
- size: 5,
1301
- icon: "ph--microphone--regular",
1302
- iconOnly: true,
1303
- noTooltip: true,
1304
- label: t("button microphone"),
1305
- onMouseDown: () => onEvent?.({
1306
- type: "record-start"
1307
- }),
1308
- onMouseUp: () => onEvent?.({
1309
- type: "record-stop"
1310
- }),
1311
- onTouchStart: () => onEvent?.({
1312
- type: "record-start"
1313
- }),
1314
- onTouchEnd: () => onEvent?.({
1315
- type: "record-stop"
1316
- })
1317
- }));
1318
- } finally {
1319
- _effect.f();
1320
- }
1321
- };
1322
-
1323
- // src/components/ChatPrompt/ChatOptionsMenu.tsx
1324
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
1325
- import React3, { useMemo as useMemo4 } from "react";
1326
- import { DropdownMenu, IconButton as IconButton2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
1327
- var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
1328
- var _effect = _useSignals4();
1329
- try {
1330
- const { t } = useTranslation3(meta.id);
1331
- const blueprintOptions = useMemo4(() => blueprintRegistry?.query().map((blueprint) => ({
1332
- key: blueprint.key,
1333
- label: blueprint.name
1334
- })), [
1335
- blueprintRegistry
1336
- ]);
1337
- return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
1338
- asChild: true,
1339
- disabled: !blueprintOptions?.length
1340
- }, /* @__PURE__ */ React3.createElement(IconButton2, {
1341
- icon: "ph--plus--regular",
1342
- variant: "ghost",
1343
- size: 5,
1344
- iconOnly: true,
1345
- label: t("button add blueprint")
1346
- })), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
1347
- side: "left"
1348
- }, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprintOptions?.map((option) => /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
1349
- key: option.key
1350
- }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Checkbox, {
1351
- checked: !!blueprints?.find((blueprint) => blueprint.key === option.key),
1352
- onCheckedChange: (checked) => onChange?.(option.key, !!checked)
1353
- }), /* @__PURE__ */ React3.createElement(Input.Label, {
1354
- classNames: "m-0"
1355
- }, option.label))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
1356
- } finally {
1357
- _effect.f();
1358
- }
1359
- };
1360
-
1361
- // src/components/ChatPrompt/ChatPresets.tsx
1362
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1363
- import React4 from "react";
1364
- import { Select } from "@dxos/react-ui";
1365
- var ChatPresets = ({ presets, preset, onChange }) => {
1366
- var _effect = _useSignals5();
1367
- try {
1368
- return /* @__PURE__ */ React4.createElement(Select.Root, {
1369
- value: preset,
1370
- onValueChange: onChange
1371
- }, /* @__PURE__ */ React4.createElement(Select.TriggerButton, {
1372
- classNames: "text-sm"
1373
- }), /* @__PURE__ */ React4.createElement(Select.Content, null, presets?.map(({ id, label }) => /* @__PURE__ */ React4.createElement(Select.Option, {
1374
- key: id,
1375
- value: id,
1376
- classNames: "text-sm"
1377
- }, label))));
1378
- } finally {
1379
- _effect.f();
1380
- }
1381
- };
1382
-
1383
- // src/components/ChatPrompt/ChatReferences.tsx
1384
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1385
- import React5, { useCallback as useCallback2 } from "react";
1386
- import { Filter as Filter5, Obj as Obj4, Ref as Ref2 } from "@dxos/echo";
1387
- import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
1388
- import { TagPicker } from "@dxos/react-ui-tag-picker";
1389
- import { mx as mx3 } from "@dxos/react-ui-theme";
1390
- import { isNonNullable as isNonNullable3 } from "@dxos/util";
1391
- var ChatReferences = ({ classNames, space, context, onUpdate }) => {
1392
- var _effect = _useSignals6();
1393
- try {
1394
- const { t: _t } = useTranslation4(meta.id);
1395
- const [items] = useAsyncState(async () => {
1396
- const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
1397
- return objects.filter(isNonNullable3).map((obj) => ({
1398
- id: obj.id,
1399
- label: Obj4.getLabel(obj) ?? obj.id
1400
- }));
1401
- }, [
1402
- context
1403
- ]);
1404
- const handleSearch = useCallback2((text, ids) => {
1405
- const objects = space.db.query(Filter5.everything()).runSync();
1406
- return objects.map(({ object }) => ({
1407
- id: object.id,
1408
- label: Obj4.getLabel(object) ?? ""
1409
- })).filter(({ id, label }) => !ids.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
1410
- }, [
1411
- space
1412
- ]);
1413
- return /* @__PURE__ */ React5.createElement(TagPicker, {
1414
- classNames: mx3("h-[1.75rem] text-sm", classNames),
1415
- mode: "multi-select",
1416
- // placeholder={t('context objects placeholder')}
1417
- items,
1418
- onSearch: handleSearch,
1419
- onUpdate
1420
- });
1421
- } finally {
1422
- _effect.f();
1423
- }
1424
- };
1425
-
1426
- // src/components/ChatPrompt/ChatStatusIndicator.tsx
1427
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1428
- import React6, { useEffect as useEffect4, useState as useState4 } from "react";
1429
- import { Icon, Tooltip, useTimeout } from "@dxos/react-ui";
1430
- import { Spinner } from "@dxos/react-ui-sfx";
1431
- import { errorText } from "@dxos/react-ui-theme";
1432
- var ChatStatusIndicator = ({ preset, error, processing }) => {
1433
- var _effect = _useSignals7();
1434
- try {
1435
- const [init, setInit] = useState4(false);
1436
- useEffect4(() => {
1437
- setInit(false);
1438
- }, [
1439
- preset
1440
- ]);
1441
- useTimeout(async () => {
1442
- setInit(true);
1443
- }, 1500, [
1444
- preset
1445
- ]);
1446
- if (error) {
1447
- return /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
1448
- content: error.message,
1449
- delayDuration: 0
1450
- }, /* @__PURE__ */ React6.createElement(Icon, {
1451
- icon: "ph--warning-circle--regular",
1452
- classNames: errorText,
1453
- size: 5
1454
- }));
1455
- }
1456
- return /* @__PURE__ */ React6.createElement(Spinner, {
1457
- state: !init ? "flash" : processing ? "spin" : "pulse"
1458
- });
1459
- } finally {
1460
- _effect.f();
1461
- }
1462
- };
1463
-
1464
- // src/components/ChatThread/ChatThread.tsx
1465
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1466
- import React9, { forwardRef, useMemo as useMemo6 } from "react";
1467
- import { PublicKey } from "@dxos/keys";
1468
- import { ScrollContainer } from "@dxos/react-ui-components";
1469
- import { mx as mx5 } from "@dxos/react-ui-theme";
1470
- import { keyToFallback } from "@dxos/util";
1471
-
1472
- // src/components/ChatThread/ChatMessage.tsx
1473
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1474
- import React8, { Fragment as Fragment2 } from "react";
1475
- import { Surface } from "@dxos/app-framework";
1476
- import { invariant as invariant2 } from "@dxos/invariant";
1477
- import { Button, Icon as Icon2, IconButton as IconButton3, useTranslation as useTranslation5 } from "@dxos/react-ui";
1478
- import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
1479
- import { mx as mx4 } from "@dxos/react-ui-theme";
1480
- import { safeParseJson } from "@dxos/util";
1481
-
1482
- // src/components/ChatThread/ToolBlock.tsx
1483
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1484
- import React7, { useEffect as useEffect5, useMemo as useMemo5, useRef, useState as useState5 } from "react";
1485
- import { log as log7 } from "@dxos/log";
1486
- import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
1487
- import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
1488
- import { isNonNullable as isNonNullable4, isNotFalsy } from "@dxos/util";
1489
- var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
1490
- var isToolMessage = (message) => {
1491
- return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
1492
- };
1493
- var getToolName2 = (tool) => {
1494
- return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
1495
- };
1496
- var getToolCaption = (tool, status) => {
1497
- if (!tool) {
1498
- return "Calling tool...";
1499
- }
1500
- return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
1501
- };
1502
- var ToolBlock = ({ classNames, message, tools }) => {
1503
- var _effect = _useSignals8();
1504
- try {
1505
- const { blocks = [] } = message;
1506
- let request;
1507
- const toolBlocks = blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult");
1508
- const items = toolBlocks.map((block) => {
1509
- switch (block._tag) {
1510
- case "toolCall": {
1511
- if (block.pending && request?.block.toolCallId === block.toolCallId) {
1512
- return null;
1513
- }
1514
- request = {
1515
- tool: tools?.find((tool) => tool.name === block.name),
1516
- block
1517
- };
1518
- return {
1519
- title: getToolCaption(request.tool, void 0),
1520
- block
1521
- };
1522
- }
1523
- case "toolResult": {
1524
- if (!request) {
1525
- log7.warn("unexpected message", {
1526
- block
1527
- }, {
1528
- F: __dxlog_file7,
1529
- L: 59,
1530
- S: void 0,
1531
- C: (f, a) => f(...a)
1532
- });
1533
- return {
1534
- title: "Error",
1535
- block
1536
- };
1537
- }
1538
- return {
1539
- title: `${getToolCaption(request.tool, void 0)} (Success)`,
1540
- block
1541
- };
1542
- }
1543
- default: {
1544
- request = void 0;
1545
- return {
1546
- title: "Error",
1547
- block
1548
- };
1549
- }
1550
- }
1551
- }).filter(isNonNullable4);
1552
- return /* @__PURE__ */ React7.createElement(ToolContainer, {
1553
- classNames,
1554
- items
1555
- });
1556
- } finally {
1557
- _effect.f();
1558
- }
1559
- };
1560
- var ToolContainer = ({ classNames, items }) => {
1561
- var _effect = _useSignals8();
1562
- try {
1563
- const tabsRef = useRef(null);
1564
- const [selected, setSelected] = useState5(0);
1565
- const [open, setOpen] = useState5(false);
1566
- useEffect5(() => {
1567
- if (open) {
1568
- tabsRef.current?.focus();
1569
- }
1570
- }, [
1571
- open
1572
- ]);
1573
- const handleSelect = (index) => {
1574
- if (index === selected) {
1575
- setOpen(false);
1576
- } else {
1577
- setSelected(index);
1578
- }
1579
- };
1580
- const title = useMemo5(() => {
1581
- const lines = items.map((item) => item.title).filter(isNotFalsy);
1582
- return /* @__PURE__ */ React7.createElement(StatusRoll, {
1583
- key: "status-roll",
1584
- lines,
1585
- duration: 1e3,
1586
- autoAdvance: true
1587
- });
1588
- }, [
1589
- items
1590
- ]);
1591
- return /* @__PURE__ */ React7.createElement(ToggleContainer, {
1592
- classNames: [
1593
- "flex flex-col",
1594
- classNames
1595
- ],
1596
- title,
1597
- open,
1598
- onChangeOpen: setOpen
1599
- }, /* @__PURE__ */ React7.createElement("div", {
1600
- className: "w-full grid grid-cols-[32px_1fr]"
1601
- }, /* @__PURE__ */ React7.createElement(NumericTabs, {
1602
- ref: tabsRef,
1603
- length: items.length,
1604
- selected,
1605
- onSelect: handleSelect
1606
- }), /* @__PURE__ */ React7.createElement(Json, {
1607
- data: items[selected].block
1608
- })));
1609
- } finally {
1610
- _effect.f();
1611
- }
1612
- };
1613
- var Json = ({ data }) => {
1614
- var _effect = _useSignals8();
1615
- try {
1616
- return /* @__PURE__ */ React7.createElement(NativeJson, {
1617
- data,
1618
- classNames: "!p-1 text-xs bg-transparent"
1619
- });
1620
- } finally {
1621
- _effect.f();
1622
- }
1623
- };
1624
-
1625
- // src/components/ChatThread/ChatMessage.tsx
1626
- var __dxlog_file8 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
1627
- var ChatMessage = ({ classNames, debug, space, message, processor, tools, onEvent }) => {
1628
- var _effect = _useSignals9();
1629
- try {
1630
- const { t } = useTranslation5(meta.id);
1631
- const { sender: { role }, blocks } = message;
1632
- if (isToolMessage(message)) {
1633
- return /* @__PURE__ */ React8.createElement(MessageContainer, {
1634
- classNames: mx4(classNames, "animate-[fadeIn_0.5s]")
1635
- }, /* @__PURE__ */ React8.createElement(ToolBlock, {
1636
- classNames: panelClasses,
1637
- message,
1638
- tools
1639
- }));
1640
- }
1641
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, debug && /* @__PURE__ */ React8.createElement("div", {
1642
- className: mx4("flex justify-end text-subdued", marginClasses)
1643
- }, /* @__PURE__ */ React8.createElement("pre", {
1644
- className: "text-xs"
1645
- }, JSON.stringify({
1646
- created: message.created
1647
- }))), blocks.map((block, idx) => {
1648
- if (block._tag === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1649
- return null;
1650
- }
1651
- const Component = components[block._tag] ?? components.default;
1652
- if (!Component) {
1653
- return null;
1654
- }
1655
- return /* @__PURE__ */ React8.createElement(Fragment2, {
1656
- key: idx
1657
- }, /* @__PURE__ */ React8.createElement(MessageContainer, {
1658
- classNames,
1659
- user: block._tag === "text" && role === "user"
1660
- }, /* @__PURE__ */ React8.createElement(Component, {
1661
- space,
1662
- processor,
1663
- block,
1664
- onEvent
1665
- })), debug && /* @__PURE__ */ React8.createElement("div", {
1666
- className: mx4("flex justify-end text-subdued", marginClasses)
1667
- }, /* @__PURE__ */ React8.createElement("pre", {
1668
- className: "text-xs"
1669
- }, JSON.stringify({
1670
- block: block._tag
1671
- }))));
1672
- }), /* @__PURE__ */ React8.createElement("div", {
1673
- className: mx4("flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100", marginClasses)
1674
- }, /* @__PURE__ */ React8.createElement(IconButton3, {
1675
- classNames: "animate-[fadeIn_0.5s]",
1676
- icon: "ph--trash--regular",
1677
- iconOnly: true,
1678
- label: t("button delete message"),
1679
- onClick: () => onEvent?.({
1680
- type: "delete",
1681
- id: message.id
1682
- })
1683
- })));
1684
- } finally {
1685
- _effect.f();
1686
- }
1687
- };
1688
- var components = {
1689
- //
1690
- // Text
1691
- //
1692
- ["text"]: ({ block }) => {
1693
- invariant2(block._tag === "text", void 0, {
1694
- F: __dxlog_file8,
1695
- L: 113,
1696
- S: void 0,
1697
- A: [
1698
- "block._tag === 'text'",
1699
- ""
1700
- ]
1701
- });
1702
- const title = block.disposition ? titles[block.disposition] : void 0;
1703
- if (!title) {
1704
- return /* @__PURE__ */ React8.createElement(MarkdownViewer, {
1705
- content: block.text
1706
- });
1707
- }
1708
- return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
1709
- // open={open}
1710
- defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
1711
- title,
1712
- icon: block.pending ? /* @__PURE__ */ React8.createElement(Icon2, {
1713
- icon: "ph--circle-notch--regular",
1714
- classNames: "text-subdued animate-spin",
1715
- size: 4
1716
- }) : void 0
1717
- }, /* @__PURE__ */ React8.createElement(MarkdownViewer, {
1718
- content: block.text,
1719
- classNames: [
1720
- "pbe-2",
1721
- systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
1722
- ]
1723
- }));
1724
- },
1725
- //
1726
- // JSON
1727
- //
1728
- ["json"]: ({ space, processor, block, onEvent }) => {
1729
- invariant2(block._tag === "json", void 0, {
1730
- F: __dxlog_file8,
1731
- L: 151,
1732
- S: void 0,
1733
- A: [
1734
- "block._tag === 'json'",
1735
- ""
1736
- ]
1737
- });
1738
- switch (block.disposition) {
1739
- case "tool_list": {
1740
- return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
1741
- title: titles[block.disposition],
1742
- defaultOpen: true
1743
- }, /* @__PURE__ */ React8.createElement(ToolboxContainer, {
1744
- space,
1745
- processor,
1746
- classNames: "pbe-2"
1747
- }));
1748
- }
1749
- case "suggest": {
1750
- const { text = "" } = safeParseJson(block.data ?? "{}") ?? {};
1751
- return /* @__PURE__ */ React8.createElement(IconButton3, {
1752
- icon: "ph--lightning--regular",
1753
- label: text,
1754
- onClick: () => onEvent?.({
1755
- type: "submit",
1756
- text
1757
- })
1758
- });
1759
- }
1760
- case "select": {
1761
- const { options = [] } = safeParseJson(block.data ?? "{}") ?? {};
1762
- return /* @__PURE__ */ React8.createElement("div", {
1763
- className: "flex flex-wrap gap-1"
1764
- }, options.map((text, idx) => /* @__PURE__ */ React8.createElement(Button, {
1765
- classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
1766
- key: idx,
1767
- onClick: () => onEvent?.({
1768
- type: "submit",
1769
- text
1770
- })
1771
- }, text)));
1772
- }
1773
- case "graph": {
1774
- return /* @__PURE__ */ React8.createElement("div", {
1775
- className: "flex flex-wrap gap-1"
1776
- }, /* @__PURE__ */ React8.createElement(Surface, {
1777
- role: "card",
1778
- data: {
1779
- subject: JSON.parse(block.data ?? "{}")
1780
- },
1781
- limit: 1,
1782
- fallback: /* @__PURE__ */ React8.createElement("div", {
1783
- className: "font-mono text-xs text-pre"
1784
- }, block.data)
1785
- }), onEvent && /* @__PURE__ */ React8.createElement(IconButton3, {
1786
- icon: "ph--plus--regular",
1787
- label: "Add to graph",
1788
- onClick: () => onEvent?.({
1789
- type: "add",
1790
- object: JSON.parse(block.data ?? "{}")
1791
- })
1792
- }));
1793
- }
1794
- default: {
1795
- const title = block.disposition ? titles[block.disposition] : void 0;
1796
- return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
1797
- title: title ?? "JSON"
1798
- }, /* @__PURE__ */ React8.createElement(Json, {
1799
- data: safeParseJson(block.data ?? block)
1800
- }));
1801
- }
1802
- }
1803
- },
1804
- //
1805
- // Default
1806
- //
1807
- default: ({ block }) => {
1808
- let title = titles[block._tag];
1809
- if (block._tag === "toolCall") {
1810
- title = `Tool [${block.name}]`;
1811
- } else {
1812
- title = block._tag;
1813
- }
1814
- return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
1815
- title: title ?? "JSON"
1816
- }, /* @__PURE__ */ React8.createElement(Json, {
1817
- data: block
1818
- }));
1819
- }
1820
- };
1821
- var titles = {
1822
- ["cot"]: "Chain of thought",
1823
- ["artifact"]: "Artifact",
1824
- ["tool_use"]: "Tool request",
1825
- ["tool_result"]: "Tool result",
1826
- ["tool_list"]: "Tools",
1827
- ["artifact-update"]: "Artifact(s) changed"
1828
- };
1829
- var systemDispositions = [
1830
- "cot",
1831
- "artifact-update"
1832
- ];
1833
- var panelClasses = "flex flex-col is-full bg-activeSurface rounded-sm";
1834
- var marginClasses = "pie-4 pis-4";
1835
- var paddingClasses = "pis-2 pie-2 pbs-0.5 pbe-0.5";
1836
- var MessageContainer = ({ classNames, children, user }) => {
1837
- var _effect = _useSignals9();
1838
- try {
1839
- if (!children) {
1840
- return null;
1841
- }
1842
- return /* @__PURE__ */ React8.createElement("div", {
1843
- role: "list-item",
1844
- className: mx4("flex is-full", user && "justify-end", marginClasses, classNames)
1845
- }, /* @__PURE__ */ React8.createElement("div", {
1846
- className: mx4(user ? [
1847
- "rounded-sm",
1848
- "bg-[--user-fill] text-accentSurfaceText",
1849
- paddingClasses
1850
- ] : "is-full")
1851
- }, children));
1852
- } finally {
1853
- _effect.f();
1854
- }
1855
- };
1856
- var ToggleContainer2 = (props) => {
1857
- var _effect = _useSignals9();
1858
- try {
1859
- return /* @__PURE__ */ React8.createElement(NativeToggleContainer, {
1860
- ...props,
1861
- classNames: mx4(panelClasses, props.classNames)
1862
- });
1863
- } finally {
1864
- _effect.f();
1865
- }
1866
- };
1867
-
1868
- // src/components/ChatThread/reducer.ts
1869
- var messageReducer = ({ current, messages }, message) => {
1870
- let i = 0;
1871
- for (const block of message.blocks) {
1872
- switch (block._tag) {
1873
- case "toolCall":
1874
- case "toolResult": {
1875
- if (current) {
1876
- current.blocks.push(block);
1877
- } else {
1878
- current = {
1879
- ...message,
1880
- id: [
1881
- message.id,
1882
- i
1883
- ].join("_"),
1884
- blocks: [
1885
- block
1886
- ]
1887
- };
1888
- messages.push(current);
1889
- }
1890
- break;
1891
- }
1892
- case "text":
1893
- default: {
1894
- current = void 0;
1895
- messages.push({
1896
- ...message,
1897
- id: [
1898
- message.id,
1899
- i
1900
- ].join("_"),
1901
- blocks: [
1902
- block
1903
- ]
1904
- });
1905
- break;
1906
- }
1907
- }
1908
- i++;
1909
- }
1910
- return {
1911
- current,
1912
- messages
1913
- };
1914
- };
1915
-
1916
- // src/components/ChatThread/ChatThread.tsx
1917
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, collapse = true, ...props }, forwardedRef) => {
1918
- var _effect = _useSignals10();
1919
- try {
1920
- const userHue = useMemo6(() => {
1921
- return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1922
- }, [
1923
- identity
1924
- ]);
1925
- const { messages: filteredMessages = [] } = useMemo6(() => {
1926
- if (collapse) {
1927
- return (messages ?? []).reduce(messageReducer, {
1928
- messages: []
1929
- });
1930
- } else {
1931
- return {
1932
- messages: messages ?? []
1933
- };
1934
- }
1935
- }, [
1936
- messages,
1937
- collapse
1938
- ]);
1939
- return /* @__PURE__ */ React9.createElement(ScrollContainer, {
1940
- ref: forwardedRef,
1941
- classNames,
1942
- fade: true
1943
- }, /* @__PURE__ */ React9.createElement("div", {
1944
- role: "none",
1945
- className: mx5(filteredMessages.length > 0 && "pbs-4 pbe-4"),
1946
- style: {
1947
- "--user-fill": `var(--dx-${userHue}Fill)`
1948
- }
1949
- }, filteredMessages.map((message) => /* @__PURE__ */ React9.createElement(ChatMessage, {
1950
- key: message.id,
1951
- message,
1952
- ...props
1953
- }))));
1954
- } finally {
1955
- _effect.f();
1956
- }
1957
- });
1958
-
1959
- // src/components/Chat/Chat.tsx
1960
- var __dxlog_file9 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
1961
- var Endcap = ({ children }) => {
1962
- var _effect = _useSignals11();
1963
- try {
1964
- return /* @__PURE__ */ React10.createElement("div", {
1965
- className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
1966
- }, children);
1967
- } finally {
1968
- _effect.f();
1969
- }
1970
- };
1971
- var [ChatContextProvider, useChatContext] = createContext("Chat");
1972
- var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...props }) => {
1973
- var _effect = _useSignals11();
1974
- try {
1975
- const [debug, setDebug] = useState6(false);
1976
- const space = getSpace(chat);
1977
- const queue = useQueue(chat?.queue.dxn);
1978
- const messages = useMemo7(() => dedupeWith([
1979
- ...queue?.objects?.filter(Obj5.instanceOf(DataType2.Message)) ?? [],
1980
- ...processor?.messages.value ?? []
1981
- ], (a, b) => a.id === b.id), [
1982
- queue?.objects,
1983
- processor?.messages.value
1984
- ]);
1985
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
1986
- useEffect6(() => {
1987
- if (!processor?.streaming.value && queue?.objects && artifact) {
1988
- const message = queue.objects[queue.objects.length - 1];
1989
- if (dispatch && space && chat && message) {
1990
- void dispatch(createIntent(CollaborationActions.InsertContent, {
1991
- target: artifact,
1992
- object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
1993
- ...chat.queue.dxn.parts,
1994
- message.id
1995
- ])),
1996
- label: "View proposal"
1997
- }));
1998
- }
1999
- }
2000
- }, [
2001
- queue,
2002
- processor?.streaming.value
2003
- ]);
2004
- const event = useMemo7(() => new Event(), []);
2005
- useEffect6(() => {
2006
- return event.on((event2) => {
2007
- switch (event2.type) {
2008
- case "toggle-debug": {
2009
- setDebug((debug2) => !debug2);
2010
- break;
2011
- }
2012
- case "submit": {
2013
- if (!processor.streaming.value) {
2014
- void processor.request(event2.text);
2015
- }
2016
- break;
2017
- }
2018
- case "cancel": {
2019
- void processor.cancel();
2020
- break;
2021
- }
2022
- default: {
2023
- onEvent?.(event2);
2024
- }
2025
- }
2026
- });
2027
- }, [
2028
- event,
2029
- onEvent
2030
- ]);
2031
- if (!space) {
2032
- return null;
2033
- }
2034
- return /* @__PURE__ */ React10.createElement(ChatContextProvider, {
2035
- debug,
2036
- event,
2037
- chat,
2038
- space,
2039
- processor,
2040
- messages,
2041
- ...props
2042
- }, /* @__PURE__ */ React10.createElement("div", {
2043
- role: "none",
2044
- className: mx6("flex flex-col h-full overflow-hidden", classNames)
2045
- }, children));
2046
- } finally {
2047
- _effect.f();
2048
- }
2049
- };
2050
- ChatRoot.displayName = "Chat.Root";
2051
- var ChatThread2 = (props) => {
2052
- var _effect = _useSignals11();
2053
- try {
2054
- const { debug, event, space, processor, messages } = useChatContext(ChatThread2.displayName);
2055
- const identity = useIdentity();
2056
- const scrollerRef = useRef2(null);
2057
- useEffect6(() => {
2058
- return event.on((event2) => {
2059
- switch (event2.type) {
2060
- case "submit":
2061
- case "scroll-to-bottom":
2062
- scrollerRef.current?.scrollToBottom("smooth");
2063
- break;
2064
- }
2065
- });
2066
- }, [
2067
- event
2068
- ]);
2069
- if (!identity) {
2070
- return null;
2071
- }
2072
- return /* @__PURE__ */ React10.createElement(ChatThread, {
2073
- ...props,
2074
- ref: scrollerRef,
2075
- debug,
2076
- identity,
2077
- space,
2078
- messages,
2079
- tools: processor?.tools,
2080
- onEvent: (ev) => event.emit(ev)
2081
- });
2082
- } finally {
2083
- _effect.f();
2084
- }
2085
- };
2086
- ChatThread2.displayName = "Chat.Thread";
2087
- var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset, onChangePreset, onChangeOnline }) => {
2088
- var _effect = _useSignals11();
2089
- try {
2090
- const { t } = useTranslation6(meta.id);
2091
- const { space, event, processor } = useChatContext(ChatPrompt.displayName);
2092
- const [active, setActive] = useState6(false);
2093
- useEffect6(() => {
2094
- return event.on((event2) => {
2095
- switch (event2.type) {
2096
- case "record-start":
2097
- setActive(true);
2098
- break;
2099
- case "record-stop":
2100
- setActive(false);
2101
- break;
2102
- }
2103
- });
2104
- }, [
2105
- event
2106
- ]);
2107
- const editorRef = useRef2(null);
2108
- const { recording } = useVoiceInput({
2109
- active,
2110
- onUpdate: (text) => {
2111
- editorRef.current?.setText(text);
2112
- editorRef.current?.focus();
2113
- }
2114
- });
2115
- const [blueprints, handleUpdateBlueprints] = useBlueprints(space, processor.context, processor.blueprintRegistry);
2116
- const contextProvider = useReferencesProvider(space);
2117
- const extensions = useMemo7(() => {
2118
- return [
2119
- contextProvider && references({
2120
- provider: contextProvider
2121
- }),
2122
- expandable && Prec.highest(keymap.of([
2123
- {
2124
- key: "cmd-d",
2125
- preventDefault: true,
2126
- run: () => {
2127
- event.emit({
2128
- type: "toggle-debug"
2129
- });
2130
- return true;
2131
- }
2132
- },
2133
- {
2134
- key: "cmd-ArrowUp",
2135
- preventDefault: true,
2136
- run: () => {
2137
- event.emit({
2138
- type: "thread-open"
2139
- });
2140
- return true;
2141
- }
2142
- },
2143
- {
2144
- key: "cmd-ArrowDown",
2145
- preventDefault: true,
2146
- run: () => {
2147
- event.emit({
2148
- type: "thread-close"
2149
- });
2150
- return true;
2151
- }
2152
- }
2153
- ]))
2154
- ].filter(isNotFalsy2);
2155
- }, [
2156
- event,
2157
- expandable,
2158
- contextProvider
2159
- ]);
2160
- const handleSubmit = useCallback3((text) => {
2161
- if (!processor.streaming.value) {
2162
- event.emit({
2163
- type: "submit",
2164
- text
2165
- });
2166
- return true;
2167
- }
2168
- }, [
2169
- processor,
2170
- event
2171
- ]);
2172
- const handleEvent = useCallback3((ev) => {
2173
- event.emit(ev);
2174
- }, [
2175
- event
2176
- ]);
2177
- const handleUpdateReferences = useCallback3((ids) => {
2178
- log8.info("update", {
2179
- ids
2180
- }, {
2181
- F: __dxlog_file9,
2182
- L: 318,
2183
- S: void 0,
2184
- C: (f, a) => f(...a)
2185
- });
2186
- }, []);
2187
- return /* @__PURE__ */ React10.createElement("div", {
2188
- className: mx6("is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]", classNames)
2189
- }, /* @__PURE__ */ React10.createElement(Endcap, null, /* @__PURE__ */ React10.createElement(ChatStatusIndicator, {
2190
- preset,
2191
- error: processor.error.value,
2192
- processing: processor.streaming.value
2193
- })), /* @__PURE__ */ React10.createElement(ChatEditor, {
2194
- ref: editorRef,
2195
- autoFocus: true,
2196
- lineWrapping: true,
2197
- classNames: "col-span-2 pis-1 pbs-2",
2198
- placeholder: placeholder ?? t("prompt placeholder"),
2199
- extensions,
2200
- onSubmit: handleSubmit
2201
- }), /* @__PURE__ */ React10.createElement("div", null), /* @__PURE__ */ React10.createElement(ChatReferences, {
2202
- classNames: "col-span-2 flex pis-1 items-center",
2203
- space,
2204
- context: processor.context,
2205
- onUpdate: handleUpdateReferences
2206
- }), /* @__PURE__ */ React10.createElement(ChatOptionsMenu, {
2207
- blueprintRegistry: processor.blueprintRegistry,
2208
- blueprints,
2209
- onChange: handleUpdateBlueprints
2210
- }), /* @__PURE__ */ React10.createElement(ChatActions, {
2211
- classNames: "col-span-2",
2212
- microphone: true,
2213
- recording,
2214
- processing: processor.streaming.value,
2215
- onEvent: handleEvent
2216
- }, /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("div", {
2217
- className: "grow"
2218
- }), presets && /* @__PURE__ */ React10.createElement(ChatPresets, {
2219
- preset,
2220
- presets,
2221
- onChange: onChangePreset
2222
- }), online !== void 0 && /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Switch, {
2223
- classNames: "mis-2 mie-2",
2224
- checked: online,
2225
- onCheckedChange: onChangeOnline
2226
- })))));
2227
- } finally {
2228
- _effect.f();
2229
- }
2230
- };
2231
- ChatPrompt.displayName = "Chat.Prompt";
2232
- var Chat = {
2233
- Root: ChatRoot,
2234
- Thread: ChatThread2,
2235
- Prompt: ChatPrompt
2236
- };
2237
-
2238
- export {
2239
- useChatProcessor,
2240
- useChatServices,
2241
- hooks_exports,
2242
- Toolbox,
2243
- ToolboxContainer,
2244
- Chat
2245
- };
2246
- //# sourceMappingURL=chunk-SENTQAEO.mjs.map