@dxos/plugin-assistant 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f

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 (721) hide show
  1. package/dist/lib/browser/BlueprintArticle-6SP2ZWJ2.mjs +30 -0
  2. package/dist/lib/browser/BlueprintArticle-6SP2ZWJ2.mjs.map +7 -0
  3. package/dist/lib/browser/ChatCompanion-JOTRKE7B.mjs +200 -0
  4. package/dist/lib/browser/ChatCompanion-JOTRKE7B.mjs.map +7 -0
  5. package/dist/lib/browser/ChatContainer-ESDLG5JY.mjs +73 -0
  6. package/dist/lib/browser/ChatContainer-ESDLG5JY.mjs.map +7 -0
  7. package/dist/lib/browser/ChatDialog-LKY3FTYO.mjs +85 -0
  8. package/dist/lib/browser/ChatDialog-LKY3FTYO.mjs.map +7 -0
  9. package/dist/lib/browser/InitiativeContainer-T2SQ4O6J.mjs +267 -0
  10. package/dist/lib/browser/InitiativeContainer-T2SQ4O6J.mjs.map +7 -0
  11. package/dist/lib/browser/PromptArticle-PK3CBRUB.mjs +52 -0
  12. package/dist/lib/browser/PromptArticle-PK3CBRUB.mjs.map +7 -0
  13. package/dist/lib/browser/ai-service-CY2BYPH6.mjs +22 -0
  14. package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +7 -0
  15. package/dist/lib/browser/app-graph-builder-MUZGUQSC.mjs +234 -0
  16. package/dist/lib/browser/app-graph-builder-MUZGUQSC.mjs.map +7 -0
  17. package/dist/lib/browser/blueprint-definition-YAGWYVCL.mjs +14 -0
  18. package/dist/lib/browser/blueprint-definition-YAGWYVCL.mjs.map +7 -0
  19. package/dist/lib/browser/blueprints/index.mjs +12 -0
  20. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-3ETBCBMH.mjs +47 -0
  22. package/dist/lib/browser/chunk-3ETBCBMH.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-6BVCG5SJ.mjs +230 -0
  24. package/dist/lib/browser/chunk-6BVCG5SJ.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-DKQMSMBN.mjs +326 -0
  26. package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-EXVT7D4B.mjs +23 -0
  28. package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-IJYAKPEU.mjs +286 -0
  30. package/dist/lib/browser/chunk-IJYAKPEU.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-POPBT2AQ.mjs +198 -0
  34. package/dist/lib/browser/chunk-POPBT2AQ.mjs.map +7 -0
  35. package/dist/lib/browser/chunk-Q4QUMX62.mjs +1974 -0
  36. package/dist/lib/browser/chunk-Q4QUMX62.mjs.map +7 -0
  37. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs +21 -0
  38. package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +7 -0
  39. package/dist/lib/browser/index.mjs +329 -207
  40. package/dist/lib/browser/index.mjs.map +4 -4
  41. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs +20 -0
  42. package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +7 -0
  43. package/dist/lib/browser/meta.json +1 -1
  44. package/dist/lib/browser/operation-resolver-2673CFJS.mjs +133 -0
  45. package/dist/lib/browser/operation-resolver-2673CFJS.mjs.map +7 -0
  46. package/dist/lib/browser/react-surface-I7YJVK4K.mjs +125 -0
  47. package/dist/lib/browser/react-surface-I7YJVK4K.mjs.map +7 -0
  48. package/dist/lib/browser/repair-IRXDYF4R.mjs +51 -0
  49. package/dist/lib/browser/repair-IRXDYF4R.mjs.map +7 -0
  50. package/dist/lib/browser/settings-XF6GKHCG.mjs +33 -0
  51. package/dist/lib/browser/settings-XF6GKHCG.mjs.map +7 -0
  52. package/dist/lib/browser/state-OYDPWLKA.mjs +26 -0
  53. package/dist/lib/browser/state-OYDPWLKA.mjs.map +7 -0
  54. package/dist/lib/browser/toolkit-IDXQCSTX.mjs +19 -0
  55. package/dist/lib/browser/toolkit-IDXQCSTX.mjs.map +7 -0
  56. package/dist/lib/browser/types/index.mjs +11 -20
  57. package/dist/lib/node-esm/BlueprintArticle-7LI6UXKZ.mjs +31 -0
  58. package/dist/lib/node-esm/BlueprintArticle-7LI6UXKZ.mjs.map +7 -0
  59. package/dist/lib/node-esm/ChatCompanion-52OWAARX.mjs +201 -0
  60. package/dist/lib/node-esm/ChatCompanion-52OWAARX.mjs.map +7 -0
  61. package/dist/lib/node-esm/ChatContainer-VLWSQ3ZO.mjs +74 -0
  62. package/dist/lib/node-esm/ChatContainer-VLWSQ3ZO.mjs.map +7 -0
  63. package/dist/lib/node-esm/ChatDialog-5DUQIF2T.mjs +86 -0
  64. package/dist/lib/node-esm/ChatDialog-5DUQIF2T.mjs.map +7 -0
  65. package/dist/lib/node-esm/InitiativeContainer-ATD3D23L.mjs +268 -0
  66. package/dist/lib/node-esm/InitiativeContainer-ATD3D23L.mjs.map +7 -0
  67. package/dist/lib/node-esm/PromptArticle-BHPABYLT.mjs +53 -0
  68. package/dist/lib/node-esm/PromptArticle-BHPABYLT.mjs.map +7 -0
  69. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +23 -0
  70. package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +7 -0
  71. package/dist/lib/node-esm/app-graph-builder-4QN5M6PD.mjs +235 -0
  72. package/dist/lib/node-esm/app-graph-builder-4QN5M6PD.mjs.map +7 -0
  73. package/dist/lib/node-esm/blueprint-definition-H3LFAEK2.mjs +15 -0
  74. package/dist/lib/node-esm/blueprint-definition-H3LFAEK2.mjs.map +7 -0
  75. package/dist/lib/node-esm/blueprints/index.mjs +13 -0
  76. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  77. package/dist/lib/node-esm/chunk-2LEN26ZQ.mjs +48 -0
  78. package/dist/lib/node-esm/chunk-2LEN26ZQ.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-75PHXBN3.mjs +327 -0
  80. package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-ESDMBGF7.mjs +1975 -0
  82. package/dist/lib/node-esm/chunk-ESDMBGF7.mjs.map +7 -0
  83. package/dist/lib/node-esm/chunk-F6LA7XNS.mjs +199 -0
  84. package/dist/lib/node-esm/chunk-F6LA7XNS.mjs.map +7 -0
  85. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  86. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  87. package/dist/lib/node-esm/chunk-LB72WG6R.mjs +231 -0
  88. package/dist/lib/node-esm/chunk-LB72WG6R.mjs.map +7 -0
  89. package/dist/lib/node-esm/chunk-MJD5XWQV.mjs +288 -0
  90. package/dist/lib/node-esm/chunk-MJD5XWQV.mjs.map +7 -0
  91. package/dist/lib/node-esm/chunk-POWB2BPC.mjs +25 -0
  92. package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +7 -0
  93. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +22 -0
  94. package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +7 -0
  95. package/dist/lib/node-esm/index.mjs +329 -207
  96. package/dist/lib/node-esm/index.mjs.map +4 -4
  97. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +21 -0
  98. package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +7 -0
  99. package/dist/lib/node-esm/meta.json +1 -1
  100. package/dist/lib/node-esm/operation-resolver-2ZD2DXOU.mjs +134 -0
  101. package/dist/lib/node-esm/operation-resolver-2ZD2DXOU.mjs.map +7 -0
  102. package/dist/lib/node-esm/react-surface-2CWJ6GZW.mjs +126 -0
  103. package/dist/lib/node-esm/react-surface-2CWJ6GZW.mjs.map +7 -0
  104. package/dist/lib/node-esm/repair-DMI55PON.mjs +52 -0
  105. package/dist/lib/node-esm/repair-DMI55PON.mjs.map +7 -0
  106. package/dist/lib/node-esm/settings-NGGZA7S7.mjs +34 -0
  107. package/dist/lib/node-esm/settings-NGGZA7S7.mjs.map +7 -0
  108. package/dist/lib/node-esm/state-VSCPGN7R.mjs +27 -0
  109. package/dist/lib/node-esm/state-VSCPGN7R.mjs.map +7 -0
  110. package/dist/lib/node-esm/toolkit-JPRJRDDB.mjs +20 -0
  111. package/dist/lib/node-esm/toolkit-JPRJRDDB.mjs.map +7 -0
  112. package/dist/lib/node-esm/types/index.mjs +11 -20
  113. package/dist/types/src/AssistantPlugin.d.ts +2 -1
  114. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  115. package/dist/types/src/blueprints/assistant-blueprint.d.ts +11 -0
  116. package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +1 -0
  117. package/dist/types/src/blueprints/index.d.ts +7 -0
  118. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/ai-service/ai-service.d.ts +6 -0
  120. package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
  122. package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  124. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  125. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  126. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +26 -0
  128. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  129. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +4 -0
  130. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  131. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +7 -0
  132. package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
  133. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
  134. package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
  135. package/dist/types/src/capabilities/index.d.ts +11 -6
  136. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  137. package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
  138. package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
  139. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +13 -0
  140. package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
  141. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  142. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  143. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  144. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  145. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  146. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  147. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  148. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  149. package/dist/types/src/capabilities/repair/index.d.ts +3 -0
  150. package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
  151. package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
  152. package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
  153. package/dist/types/src/capabilities/settings/index.d.ts +15 -0
  154. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  155. package/dist/types/src/capabilities/settings/settings.d.ts +18 -0
  156. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  157. package/dist/types/src/capabilities/state/index.d.ts +11 -0
  158. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  159. package/dist/types/src/capabilities/state/state.d.ts +13 -0
  160. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  161. package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
  162. package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
  163. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +6 -0
  164. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
  165. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +6 -4
  166. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  167. package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
  168. package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
  169. package/dist/types/src/components/Chat/Chat.d.ts +63 -0
  170. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
  171. package/dist/types/src/components/Chat/events.d.ts +39 -0
  172. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  173. package/dist/types/src/components/Chat/index.d.ts +3 -0
  174. package/dist/types/src/components/Chat/index.d.ts.map +1 -0
  175. package/dist/types/src/components/ChatCompanion.d.ts +13 -0
  176. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
  177. package/dist/types/src/components/ChatContainer.d.ts +17 -9
  178. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  179. package/dist/types/src/components/ChatDialog.d.ts +8 -0
  180. package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
  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 +11 -0
  186. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
  187. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
  188. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  189. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  190. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  191. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +10 -0
  192. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
  193. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +10 -0
  194. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
  195. package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
  196. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
  197. package/dist/types/src/components/ChatThread/ChatThread.d.ts +21 -0
  198. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
  199. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +455 -0
  200. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
  201. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  202. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  203. package/dist/types/src/components/ChatThread/index.d.ts +2 -0
  204. package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
  205. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  206. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  207. package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
  208. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  209. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  210. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  211. package/dist/types/src/components/InitiativeContainer.d.ts +9 -0
  212. package/dist/types/src/components/InitiativeContainer.d.ts.map +1 -0
  213. package/dist/types/src/components/PromptArticle.d.ts +7 -0
  214. package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
  215. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +5 -8
  216. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  217. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +431 -7
  218. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  219. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +16 -5
  220. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  221. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +429 -3
  222. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  223. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
  224. package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
  225. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
  226. package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
  227. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
  228. package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
  229. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +21 -0
  230. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  231. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  232. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  233. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  234. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  235. package/dist/types/src/components/Toolbox/Toolbox.d.ts +13 -12
  236. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  237. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +432 -5
  238. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  239. package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts +4 -0
  240. package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts.map +1 -0
  241. package/dist/types/src/components/TriggerStatus/index.d.ts +2 -0
  242. package/dist/types/src/components/TriggerStatus/index.d.ts.map +1 -0
  243. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
  244. package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
  245. package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
  246. package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
  247. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
  248. package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
  249. package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
  250. package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
  251. package/dist/types/src/components/Typewriter/index.d.ts +2 -0
  252. package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
  253. package/dist/types/src/components/index.d.ts +11 -14
  254. package/dist/types/src/components/index.d.ts.map +1 -1
  255. package/dist/types/src/functions/index.d.ts +4 -0
  256. package/dist/types/src/functions/index.d.ts.map +1 -0
  257. package/dist/types/src/functions/object-list.d.ts +10 -0
  258. package/dist/types/src/functions/object-list.d.ts.map +1 -0
  259. package/dist/types/src/functions/object-load.d.ts +8 -0
  260. package/dist/types/src/functions/object-load.d.ts.map +1 -0
  261. package/dist/types/src/functions/object-search.d.ts +10 -0
  262. package/dist/types/src/functions/object-search.d.ts.map +1 -0
  263. package/dist/types/src/hooks/index.d.ts +10 -5
  264. package/dist/types/src/hooks/index.d.ts.map +1 -1
  265. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
  266. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  267. package/dist/types/src/hooks/useChatProcessor.d.ts +13 -11
  268. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  269. package/dist/types/src/hooks/useChatServices.d.ts +13 -0
  270. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  271. package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
  272. package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
  273. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  274. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  275. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  276. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  277. package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
  278. package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
  279. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  280. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  281. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  282. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  283. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  284. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  285. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  286. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  287. package/dist/types/src/index.d.ts +2 -1
  288. package/dist/types/src/index.d.ts.map +1 -1
  289. package/dist/types/src/meta.d.ts +3 -4
  290. package/dist/types/src/meta.d.ts.map +1 -1
  291. package/dist/types/src/processor/index.d.ts +4 -0
  292. package/dist/types/src/processor/index.d.ts.map +1 -0
  293. package/dist/types/src/processor/presets.d.ts +13 -0
  294. package/dist/types/src/processor/presets.d.ts.map +1 -0
  295. package/dist/types/src/processor/processor.d.ts +79 -0
  296. package/dist/types/src/processor/processor.d.ts.map +1 -0
  297. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  298. package/dist/types/src/processor/update-name.d.ts +10 -0
  299. package/dist/types/src/processor/update-name.d.ts.map +1 -0
  300. package/dist/types/src/queue-logger.d.ts +5 -5
  301. package/dist/types/src/queue-logger.d.ts.map +1 -1
  302. package/dist/types/src/testing/index.d.ts +2 -2
  303. package/dist/types/src/testing/index.d.ts.map +1 -1
  304. package/dist/types/src/testing/test-generator.d.ts +8 -0
  305. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  306. package/dist/types/src/testing/test-sequence.d.ts +4 -0
  307. package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
  308. package/dist/types/src/testing/test-services.d.ts +2 -2
  309. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  310. package/dist/types/src/translations.d.ts +416 -113
  311. package/dist/types/src/translations.d.ts.map +1 -1
  312. package/dist/types/src/types/Assistant.d.ts +20 -0
  313. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  314. package/dist/types/src/types/AssistantAction.d.ts +97 -0
  315. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  316. package/dist/types/src/types/capabilities.d.ts +33 -0
  317. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  318. package/dist/types/src/types/defs.d.ts +2 -0
  319. package/dist/types/src/types/defs.d.ts.map +1 -0
  320. package/dist/types/src/types/events.d.ts +5 -0
  321. package/dist/types/src/types/events.d.ts.map +1 -0
  322. package/dist/types/src/types/index.d.ts +6 -3
  323. package/dist/types/src/types/index.d.ts.map +1 -1
  324. package/dist/types/src/types/service.d.ts +14 -213
  325. package/dist/types/src/types/service.d.ts.map +1 -1
  326. package/dist/types/tsconfig.tsbuildinfo +1 -1
  327. package/package.json +127 -92
  328. package/src/AssistantPlugin.tsx +159 -115
  329. package/src/blueprints/assistant-blueprint.ts +57 -0
  330. package/src/blueprints/index.ts +12 -0
  331. package/src/capabilities/ai-service/ai-service.ts +30 -0
  332. package/src/capabilities/ai-service/index.ts +7 -0
  333. package/src/capabilities/app-graph-builder/app-graph-builder.ts +200 -0
  334. package/src/capabilities/app-graph-builder/index.ts +7 -0
  335. package/src/capabilities/blueprint-definition/blueprint-definition.ts +74 -0
  336. package/src/capabilities/blueprint-definition/index.ts +8 -0
  337. package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +33 -0
  338. package/src/capabilities/edge-model-resolver/index.ts +7 -0
  339. package/src/capabilities/index.ts +11 -9
  340. package/src/capabilities/local-model-resolver/index.ts +7 -0
  341. package/src/capabilities/local-model-resolver/local-model-resolver.ts +38 -0
  342. package/src/capabilities/operation-resolver/index.ts +7 -0
  343. package/src/capabilities/operation-resolver/operation-resolver.ts +112 -0
  344. package/src/capabilities/react-surface/index.ts +7 -0
  345. package/src/capabilities/react-surface/react-surface.tsx +111 -0
  346. package/src/capabilities/repair/index.ts +7 -0
  347. package/src/capabilities/repair/repair.ts +62 -0
  348. package/src/capabilities/settings/index.ts +7 -0
  349. package/src/capabilities/settings/settings.ts +31 -0
  350. package/src/capabilities/state/index.ts +7 -0
  351. package/src/capabilities/state/state.ts +27 -0
  352. package/src/capabilities/toolkit/index.ts +7 -0
  353. package/src/capabilities/toolkit/toolkit.ts +27 -0
  354. package/src/components/AssistantSettings/AssistantSettings.tsx +94 -79
  355. package/src/components/BlueprintArticle.tsx +28 -0
  356. package/src/components/Chat/Chat.tsx +458 -0
  357. package/src/components/Chat/events.ts +63 -0
  358. package/src/components/Chat/index.ts +7 -0
  359. package/src/components/ChatCompanion.tsx +226 -0
  360. package/src/components/ChatContainer.tsx +55 -26
  361. package/src/components/ChatDialog.tsx +75 -0
  362. package/src/components/ChatProgress/ChatProgress.tsx +53 -0
  363. package/src/components/{AmbientDialog → ChatProgress}/index.ts +1 -1
  364. package/src/components/ChatPrompt/ChatActions.tsx +63 -0
  365. package/src/components/ChatPrompt/ChatOptions.tsx +238 -0
  366. package/src/components/ChatPrompt/ChatPresets.tsx +29 -0
  367. package/src/components/ChatPrompt/ChatReferences.tsx +47 -0
  368. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +42 -0
  369. package/src/components/ChatPrompt/index.ts +9 -0
  370. package/src/components/ChatThread/ChatThread.stories.tsx +150 -0
  371. package/src/components/ChatThread/ChatThread.tsx +96 -0
  372. package/src/components/ChatThread/Link.tsx +26 -0
  373. package/src/{experimental/transcription → components/ChatThread}/index.ts +2 -0
  374. package/src/components/ChatThread/registry.tsx +174 -0
  375. package/src/components/ChatThread/sync.test.ts +97 -0
  376. package/src/components/ChatThread/sync.ts +154 -0
  377. package/src/components/ChatThread/testing/thread.md +37 -0
  378. package/src/components/InitiativeContainer.tsx +340 -0
  379. package/src/components/PromptArticle.tsx +49 -0
  380. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +57 -41
  381. package/src/components/TemplateEditor/TemplateEditor.tsx +40 -46
  382. package/src/components/TemplateEditor/TemplateForm.stories.tsx +39 -26
  383. package/src/components/TemplateEditor/TemplateForm.tsx +121 -79
  384. package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
  385. package/src/components/TemplateEditor/extensions/index.ts +6 -0
  386. package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
  387. package/src/components/ToolBlock/ToolBlock.tsx +143 -0
  388. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  389. package/src/components/ToolBlock/index.ts +6 -0
  390. package/src/components/Toolbox/Toolbox.stories.tsx +18 -29
  391. package/src/components/Toolbox/Toolbox.tsx +77 -53
  392. package/src/components/TriggerStatus/TriggerStatus.tsx +142 -0
  393. package/src/components/TriggerStatus/index.ts +5 -0
  394. package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
  395. package/src/components/Typewriter/Typewriter.stories.tsx +83 -0
  396. package/src/components/Typewriter/Typewriter.tsx +54 -0
  397. package/src/components/Typewriter/assistant-extension.tsx +144 -0
  398. package/src/components/Typewriter/index.ts +5 -0
  399. package/src/components/index.ts +16 -12
  400. package/src/functions/index.ts +7 -0
  401. package/src/functions/object-list.ts +49 -0
  402. package/src/functions/object-load.ts +44 -0
  403. package/src/functions/object-search.ts +46 -0
  404. package/src/hooks/index.ts +10 -6
  405. package/src/hooks/useBlueprintRegistry.ts +105 -0
  406. package/src/hooks/useChatProcessor.ts +78 -0
  407. package/src/hooks/useChatServices.ts +47 -0
  408. package/src/hooks/useChatToolbarActions.ts +122 -0
  409. package/src/hooks/useContextBinder.ts +32 -0
  410. package/src/hooks/useContextObjects.ts +46 -0
  411. package/src/hooks/useFilteredTypes.ts +37 -0
  412. package/src/hooks/useFlush.ts +35 -0
  413. package/src/hooks/useOnline.ts +10 -0
  414. package/src/hooks/usePresets.ts +44 -0
  415. package/src/hooks/useReferencesProvider.ts +58 -0
  416. package/src/index.ts +2 -1
  417. package/src/meta.ts +11 -8
  418. package/src/processor/index.ts +7 -0
  419. package/src/processor/presets.ts +60 -0
  420. package/src/processor/processor.test.ts +72 -0
  421. package/src/processor/processor.ts +301 -0
  422. package/src/processor/update-name.ts +58 -0
  423. package/src/queue-logger.ts +23 -24
  424. package/src/testing/index.ts +2 -2
  425. package/src/testing/test-generator.ts +262 -0
  426. package/src/testing/test-sequence.ts +26 -0
  427. package/src/testing/test-services.ts +10 -14
  428. package/src/translations.ts +90 -27
  429. package/src/types/Assistant.ts +28 -0
  430. package/src/types/AssistantAction.ts +76 -0
  431. package/src/types/capabilities.ts +27 -0
  432. package/src/types/defs.ts +5 -0
  433. package/src/types/events.ts +11 -0
  434. package/src/types/index.ts +9 -3
  435. package/src/types/service.ts +25 -14
  436. package/src/vite-env.d.ts +30 -0
  437. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
  438. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
  439. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
  440. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
  441. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
  442. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
  443. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs +0 -28
  444. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
  445. package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
  446. package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
  447. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs +0 -225
  448. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
  449. package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
  450. package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
  451. package/dist/lib/browser/chunk-BI6AHRNJ.mjs +0 -157
  452. package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
  453. package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
  454. package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
  455. package/dist/lib/browser/chunk-JQFUME3B.mjs +0 -87
  456. package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
  457. package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
  458. package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
  459. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
  460. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
  461. package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
  462. package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
  463. package/dist/lib/browser/chunk-XOZ7YMO3.mjs +0 -20
  464. package/dist/lib/browser/chunk-XOZ7YMO3.mjs.map +0 -7
  465. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
  466. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
  467. package/dist/lib/browser/react-surface-LXCNUSZN.mjs +0 -159
  468. package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
  469. package/dist/lib/browser/settings-XRHXVWGB.mjs +0 -22
  470. package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
  471. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
  472. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
  473. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
  474. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
  475. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
  476. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
  477. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
  478. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
  479. package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
  480. package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
  481. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
  482. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
  483. package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
  484. package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
  485. package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
  486. package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
  487. package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
  488. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
  489. package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
  490. package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
  491. package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
  492. package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
  493. package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
  494. package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
  495. package/dist/lib/node/chunk-P74TWGMG.cjs +0 -44
  496. package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
  497. package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
  498. package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
  499. package/dist/lib/node/index.cjs +0 -289
  500. package/dist/lib/node/index.cjs.map +0 -7
  501. package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
  502. package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
  503. package/dist/lib/node/meta.json +0 -1
  504. package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
  505. package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
  506. package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
  507. package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
  508. package/dist/lib/node/types/index.cjs +0 -54
  509. package/dist/lib/node/types/index.cjs.map +0 -7
  510. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
  511. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
  512. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
  513. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
  514. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
  515. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
  516. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs +0 -29
  517. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
  518. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
  519. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
  520. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs +0 -226
  521. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
  522. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
  523. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
  524. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
  525. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
  526. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs +0 -22
  527. package/dist/lib/node-esm/chunk-BB2TAT4P.mjs.map +0 -7
  528. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
  529. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
  530. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
  531. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
  532. package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
  533. package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
  534. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs +0 -88
  535. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
  536. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs +0 -158
  537. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
  538. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
  539. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
  540. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs +0 -160
  541. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
  542. package/dist/lib/node-esm/settings-5IAY6BT4.mjs +0 -23
  543. package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
  544. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  545. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  546. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  547. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  548. package/dist/types/src/capabilities/capabilities.d.ts +0 -6
  549. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  550. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  551. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  552. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  553. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  554. package/dist/types/src/capabilities/settings.d.ts +0 -4
  555. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  556. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
  557. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
  558. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
  559. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
  560. package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
  561. package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
  562. package/dist/types/src/components/AssistantDialog.d.ts +0 -7
  563. package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
  564. package/dist/types/src/components/BlueprintContainer.d.ts +0 -9
  565. package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
  566. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
  567. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
  568. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
  569. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
  570. package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
  571. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
  572. package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
  573. package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
  574. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
  575. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
  576. package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
  577. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
  578. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
  579. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
  580. package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
  581. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
  582. package/dist/types/src/components/Prompt/index.d.ts +0 -3
  583. package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
  584. package/dist/types/src/components/Prompt/references.d.ts +0 -30
  585. package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
  586. package/dist/types/src/components/PromptSettings.d.ts +0 -6
  587. package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
  588. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  589. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  590. package/dist/types/src/components/Thread/Thread.d.ts +0 -28
  591. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  592. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  593. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  594. package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
  595. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
  596. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
  597. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
  598. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
  599. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  600. package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
  601. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
  602. package/dist/types/src/components/Thread/index.d.ts +0 -3
  603. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  604. package/dist/types/src/components/Thread/reducer.d.ts +0 -12
  605. package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
  606. package/dist/types/src/events.d.ts +0 -4
  607. package/dist/types/src/events.d.ts.map +0 -1
  608. package/dist/types/src/experimental/transcription/index.d.ts +0 -1
  609. package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
  610. package/dist/types/src/hooks/processor.d.ts +0 -72
  611. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  612. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  613. package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
  614. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  615. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
  616. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  617. package/dist/types/src/hooks/useServices.d.ts +0 -7
  618. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  619. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  620. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  621. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  622. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  623. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  624. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  625. package/dist/types/src/parser/index.d.ts +0 -4
  626. package/dist/types/src/parser/index.d.ts.map +0 -1
  627. package/dist/types/src/parser/query-parser.d.ts +0 -15
  628. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  629. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  630. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  631. package/dist/types/src/parser/types.d.ts +0 -24
  632. package/dist/types/src/parser/types.d.ts.map +0 -1
  633. package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
  634. package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
  635. package/dist/types/src/stories/Query.stories.d.ts +0 -19
  636. package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
  637. package/dist/types/src/stories/Research.stories.d.ts +0 -15
  638. package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
  639. package/dist/types/src/stories/test-data.d.ts +0 -3
  640. package/dist/types/src/stories/test-data.d.ts.map +0 -1
  641. package/dist/types/src/stories/testing.d.ts +0 -12
  642. package/dist/types/src/stories/testing.d.ts.map +0 -1
  643. package/dist/types/src/testing/test-blueprint.d.ts +0 -8
  644. package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
  645. package/dist/types/src/testing/test-functions.d.ts +0 -3
  646. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  647. package/dist/types/src/tools/function.d.ts +0 -5
  648. package/dist/types/src/tools/function.d.ts.map +0 -1
  649. package/dist/types/src/tools/index.d.ts +0 -3
  650. package/dist/types/src/tools/index.d.ts.map +0 -1
  651. package/dist/types/src/tools/openapi.d.ts +0 -10
  652. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  653. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  654. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  655. package/dist/types/src/types/chat.d.ts +0 -23
  656. package/dist/types/src/types/chat.d.ts.map +0 -1
  657. package/dist/types/src/types/template.d.ts +0 -56
  658. package/dist/types/src/types/template.d.ts.map +0 -1
  659. package/dist/types/src/types/types.d.ts +0 -50
  660. package/dist/types/src/types/types.d.ts.map +0 -1
  661. package/src/capabilities/ai-client.ts +0 -42
  662. package/src/capabilities/app-graph-builder.ts +0 -248
  663. package/src/capabilities/capabilities.ts +0 -15
  664. package/src/capabilities/intent-resolver.ts +0 -45
  665. package/src/capabilities/react-surface.tsx +0 -137
  666. package/src/capabilities/settings.ts +0 -19
  667. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
  668. package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
  669. package/src/components/AssistantDialog.tsx +0 -37
  670. package/src/components/BlueprintContainer.tsx +0 -148
  671. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
  672. package/src/components/BlueprintEditor/BlueprintEditor.tsx +0 -50
  673. package/src/components/BlueprintEditor/index.ts +0 -5
  674. package/src/components/Prompt/Prompt.stories.tsx +0 -121
  675. package/src/components/Prompt/Prompt.tsx +0 -124
  676. package/src/components/Prompt/PromptBar.stories.tsx +0 -69
  677. package/src/components/Prompt/PromptBar.tsx +0 -105
  678. package/src/components/Prompt/autocomplete.ts +0 -218
  679. package/src/components/Prompt/index.ts +0 -6
  680. package/src/components/Prompt/references.ts +0 -180
  681. package/src/components/PromptSettings.tsx +0 -91
  682. package/src/components/TemplateContainer.tsx +0 -23
  683. package/src/components/Thread/Thread.stories.tsx +0 -201
  684. package/src/components/Thread/Thread.tsx +0 -118
  685. package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
  686. package/src/components/Thread/ThreadContainer.tsx +0 -105
  687. package/src/components/Thread/ThreadMessage.tsx +0 -234
  688. package/src/components/Thread/ToolInvocations.tsx +0 -106
  689. package/src/components/Thread/index.ts +0 -6
  690. package/src/components/Thread/reducer.ts +0 -52
  691. package/src/events.ts +0 -11
  692. package/src/hooks/processor.test.ts +0 -15
  693. package/src/hooks/processor.ts +0 -238
  694. package/src/hooks/useChatProcessor.tsx +0 -97
  695. package/src/hooks/useContextProvider.ts +0 -55
  696. package/src/hooks/useMessageQueue.ts +0 -22
  697. package/src/hooks/useServices.ts +0 -28
  698. package/src/hooks/useTextInputEvents.ts +0 -49
  699. package/src/parser/filter-generator.test.ts +0 -32
  700. package/src/parser/filter-generator.ts +0 -81
  701. package/src/parser/index.ts +0 -7
  702. package/src/parser/query-parser.test.ts +0 -139
  703. package/src/parser/query-parser.ts +0 -199
  704. package/src/parser/types.ts +0 -34
  705. package/src/shims.d.ts +0 -8
  706. package/src/stories/Prompt.stories.tsx +0 -60
  707. package/src/stories/Query.stories.tsx +0 -514
  708. package/src/stories/Research.stories.tsx +0 -482
  709. package/src/stories/test-data.ts +0 -128
  710. package/src/stories/testing.ts +0 -60
  711. package/src/testing/test-blueprint.ts +0 -58
  712. package/src/testing/test-functions.ts +0 -11
  713. package/src/tools/function.ts +0 -46
  714. package/src/tools/index.ts +0 -6
  715. package/src/tools/openapi.test.ts +0 -217
  716. package/src/tools/openapi.ts +0 -338
  717. package/src/types/chat.ts +0 -32
  718. package/src/types/template.ts +0 -66
  719. package/src/types/types.ts +0 -48
  720. package/src/typings.d.ts +0 -9
  721. /package/dist/types/src/{hooks → processor}/processor.test.d.ts +0 -0
@@ -1,2102 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ServiceType,
4
- categoryIcons
5
- } from "./chunk-J6UXXZGJ.mjs";
6
- import {
7
- AssistantCapabilities
8
- } from "./chunk-3UEZLJ2V.mjs";
9
- import {
10
- ASSISTANT_PLUGIN
11
- } from "./chunk-BB2TAT4P.mjs";
12
-
13
- // packages/plugins/plugin-assistant/src/components/Prompt/Prompt.tsx
14
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
15
- import { Prec as Prec2 } from "@codemirror/state";
16
- import React, { forwardRef, useImperativeHandle } from "react";
17
- import { useThemeContext } from "@dxos/react-ui";
18
- import { createBasicExtensions, createThemeExtensions, keymap as keymap3, useTextEditor } from "@dxos/react-ui-editor";
19
- import { mx } from "@dxos/react-ui-theme";
20
- import { isNonNullable } from "@dxos/util";
21
-
22
- // packages/plugins/plugin-assistant/src/components/Prompt/autocomplete.ts
23
- import { Prec } from "@codemirror/state";
24
- import { EditorView, Decoration, ViewPlugin, keymap, WidgetType } from "@codemirror/view";
25
- var autocompleteExtension = ({ onSubmit, onSuggest, onCancel }) => {
26
- const suggest = ViewPlugin.fromClass(class {
27
- constructor(view) {
28
- this._currentSuggestion = null;
29
- this._decorations = this.computeDecorations(view);
30
- }
31
- update(update) {
32
- if (update.docChanged || update.selectionSet) {
33
- this._decorations = this.computeDecorations(update.view);
34
- }
35
- }
36
- computeDecorations(view) {
37
- const text = view.state.doc.toString();
38
- const suggestions = onSuggest?.(text) ?? [];
39
- if (!suggestions.length) {
40
- this._currentSuggestion = null;
41
- return Decoration.none;
42
- }
43
- this._currentSuggestion = suggestions[0];
44
- const suffix = this._currentSuggestion.slice(text.length);
45
- if (!suffix) {
46
- return Decoration.none;
47
- }
48
- return Decoration.set([
49
- Decoration.widget({
50
- widget: new InlineSuggestionWidget(suffix),
51
- side: 1
52
- }).range(view.state.doc.length)
53
- ]);
54
- }
55
- completeSuggestion(view) {
56
- if (!this._currentSuggestion) {
57
- return false;
58
- }
59
- const text = view.state.doc.toString();
60
- const suffix = this._currentSuggestion.slice(text.length);
61
- if (!suffix) {
62
- return false;
63
- }
64
- view.dispatch({
65
- changes: {
66
- from: view.state.doc.length,
67
- insert: suffix
68
- },
69
- selection: {
70
- anchor: view.state.doc.length + suffix.length
71
- }
72
- });
73
- return true;
74
- }
75
- }, {
76
- decorations: (v) => v._decorations
77
- });
78
- return [
79
- suggest,
80
- EditorView.theme({
81
- ".cm-inline-suggestion": {
82
- opacity: 0.4
83
- }
84
- }),
85
- Prec.highest(keymap.of([
86
- {
87
- key: "Tab",
88
- preventDefault: true,
89
- run: (view) => {
90
- const plugin = view.plugin(suggest);
91
- return plugin?.completeSuggestion(view) ?? false;
92
- }
93
- },
94
- {
95
- key: "ArrowRight",
96
- preventDefault: true,
97
- run: (view) => {
98
- if (view.state.selection.main.head !== view.state.doc.length) {
99
- return false;
100
- }
101
- const plugin = view.plugin(suggest);
102
- return plugin?.completeSuggestion(view) ?? false;
103
- }
104
- },
105
- {
106
- key: "Enter",
107
- preventDefault: true,
108
- run: (view) => {
109
- const text = view.state.doc.toString().trim();
110
- if (text.length > 0 && onSubmit) {
111
- const reset = onSubmit(text);
112
- if (reset) {
113
- view.dispatch({
114
- changes: {
115
- from: 0,
116
- to: view.state.doc.length,
117
- insert: ""
118
- }
119
- });
120
- }
121
- }
122
- return true;
123
- }
124
- },
125
- {
126
- key: "Shift-Enter",
127
- preventDefault: true,
128
- run: (view) => {
129
- view.dispatch({
130
- changes: {
131
- from: view.state.selection.main.head,
132
- insert: "\n"
133
- },
134
- selection: {
135
- anchor: view.state.selection.main.head + 1,
136
- head: view.state.selection.main.head + 1
137
- }
138
- });
139
- return true;
140
- }
141
- },
142
- {
143
- key: "Escape",
144
- preventDefault: true,
145
- run: (view) => {
146
- view.dispatch({
147
- changes: {
148
- from: 0,
149
- to: view.state.doc.length,
150
- insert: ""
151
- }
152
- });
153
- onCancel?.();
154
- return true;
155
- }
156
- }
157
- ]))
158
- ];
159
- };
160
- var InlineSuggestionWidget = class extends WidgetType {
161
- constructor(suffix) {
162
- super(), this.suffix = suffix;
163
- }
164
- toDOM() {
165
- const span = document.createElement("span");
166
- span.textContent = this.suffix;
167
- span.className = "cm-inline-suggestion";
168
- return span;
169
- }
170
- eq(other) {
171
- return other.suffix === this.suffix;
172
- }
173
- };
174
-
175
- // packages/plugins/plugin-assistant/src/components/Prompt/references.ts
176
- import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
177
- import { RangeSet } from "@codemirror/state";
178
- import { Decoration as Decoration2, EditorView as EditorView2, keymap as keymap2, ViewPlugin as ViewPlugin2, WidgetType as WidgetType2 } from "@codemirror/view";
179
- import { Mutex } from "@dxos/async";
180
- var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
181
- if (triggerCharacter.length !== 1) {
182
- throw new Error("triggerCharacter must be a single character");
183
- }
184
- const decorationField = ViewPlugin2.fromClass(class ReferenceView {
185
- constructor(view) {
186
- this._mutex = new Mutex();
187
- this.decorations = Decoration2.set([]);
188
- queueMicrotask(async () => {
189
- const guard = await this._mutex.acquire();
190
- try {
191
- this.decorations = await this._computeDecorations(view);
192
- } finally {
193
- guard.release();
194
- }
195
- });
196
- }
197
- update(update) {
198
- if (update.docChanged) {
199
- queueMicrotask(async () => {
200
- const guard = await this._mutex.acquire();
201
- try {
202
- this.decorations = await this._computeDecorations(update.view);
203
- } finally {
204
- guard.release();
205
- }
206
- });
207
- }
208
- }
209
- async _computeDecorations(view) {
210
- const text = view.state.doc.toString();
211
- const references = text.matchAll(new RegExp(`${triggerCharacter}[a-zA-Z0-9@:]+\\s`, "g"));
212
- const decorations = [];
213
- for (const match of references) {
214
- const reference = match[0];
215
- const uri = reference.slice(1, -1);
216
- const data = await provider.resolveReference({
217
- uri
218
- });
219
- if (data) {
220
- decorations.push(Decoration2.replace({
221
- widget: new ReferenceWidget(data)
222
- }).range(match.index, match.index + reference.length));
223
- }
224
- }
225
- return Decoration2.set(decorations);
226
- }
227
- }, {
228
- decorations: (v) => v.decorations,
229
- provide: (plugin) => [
230
- EditorView2.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? RangeSet.empty)
231
- ]
232
- });
233
- return [
234
- decorationField,
235
- EditorView2.theme({
236
- ".cm-reference-pill": {
237
- borderRadius: "0.25rem",
238
- borderWidth: "1px",
239
- marginRight: "0.25rem",
240
- marginLeft: "0.25rem"
241
- }
242
- }),
243
- autocompletion({
244
- activateOnTyping: true,
245
- override: [
246
- async (context) => {
247
- const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
248
- if (!match || match?.to === match?.from) {
249
- return null;
250
- }
251
- const query = match.text.slice(1);
252
- const references = await provider.getReferences({
253
- query
254
- });
255
- return {
256
- from: match.from,
257
- filter: false,
258
- options: references.map((reference) => ({
259
- label: reference.label,
260
- apply: `${triggerCharacter}${reference.uri} `
261
- }))
262
- };
263
- }
264
- ],
265
- closeOnBlur: !debug,
266
- tooltipClass: () => "shadow rounded",
267
- aboveCursor: true
268
- }),
269
- keymap2.of(completionKeymap)
270
- ];
271
- };
272
- var ReferenceWidget = class extends WidgetType2 {
273
- constructor(data) {
274
- super(), this.data = data;
275
- }
276
- toDOM() {
277
- const span = document.createElement("span");
278
- span.textContent = `@ ${this.data.label}`;
279
- span.className = "cm-reference-pill";
280
- return span;
281
- }
282
- eq(other) {
283
- return other.data.uri === this.data.uri;
284
- }
285
- ignoreEvent() {
286
- return true;
287
- }
288
- };
289
-
290
- // packages/plugins/plugin-assistant/src/components/Prompt/Prompt.tsx
291
- var Prompt = /* @__PURE__ */ forwardRef(({ classNames, extensions, references, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onCancel, onOpenChange }, forwardRef3) => {
292
- var _effect = _useSignals();
293
- try {
294
- const { themeMode } = useThemeContext();
295
- const { parentRef, view } = useTextEditor({
296
- debug: true,
297
- autoFocus,
298
- extensions: [
299
- autocompleteExtension({
300
- onSubmit,
301
- onSuggest,
302
- onCancel
303
- }),
304
- createBasicExtensions({
305
- bracketMatching: false,
306
- lineWrapping,
307
- placeholder
308
- }),
309
- createThemeExtensions({
310
- themeMode
311
- }),
312
- references ? promptReferences({
313
- provider: references
314
- }) : [],
315
- Prec2.highest(keymap3.of([
316
- {
317
- key: "cmd-ArrowUp",
318
- preventDefault: true,
319
- run: () => {
320
- onOpenChange?.(true);
321
- return true;
322
- }
323
- },
324
- {
325
- key: "cmd-ArrowDown",
326
- preventDefault: true,
327
- run: () => {
328
- onOpenChange?.(false);
329
- return true;
330
- }
331
- }
332
- ])),
333
- extensions
334
- ].filter(isNonNullable)
335
- }, [
336
- themeMode,
337
- extensions,
338
- onSubmit,
339
- onSuggest
340
- ]);
341
- useImperativeHandle(forwardRef3, () => {
342
- return {
343
- focus: () => {
344
- view?.focus();
345
- },
346
- setText: (text) => {
347
- view?.dispatch({
348
- changes: {
349
- from: 0,
350
- to: view.state.doc.length,
351
- insert: text
352
- },
353
- selection: {
354
- anchor: text.length,
355
- head: text.length
356
- }
357
- });
358
- }
359
- };
360
- }, [
361
- view,
362
- onSubmit
363
- ]);
364
- return /* @__PURE__ */ React.createElement("div", {
365
- ref: parentRef,
366
- className: mx("w-full", classNames)
367
- });
368
- } finally {
369
- _effect.f();
370
- }
371
- });
372
-
373
- // packages/plugins/plugin-assistant/src/components/Prompt/PromptBar.tsx
374
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
375
- import React2, { forwardRef as forwardRef2, useState } from "react";
376
- import { useVoiceInput } from "@dxos/plugin-transcription";
377
- import { Icon, IconButton, Tooltip, useForwardedRef, useTranslation } from "@dxos/react-ui";
378
- import { Spinner } from "@dxos/react-ui-sfx";
379
- import { errorText, mx as mx2 } from "@dxos/react-ui-theme";
380
- var PromptBar = /* @__PURE__ */ forwardRef2(({ classNames, placeholder, processing, error, microphone, references, onCancel, ...props }, forwardedRef) => {
381
- var _effect = _useSignals2();
382
- try {
383
- const { t } = useTranslation(ASSISTANT_PLUGIN);
384
- const promptRef = useForwardedRef(forwardedRef);
385
- const [active, setActive] = useState(false);
386
- const { recording } = useVoiceInput({
387
- active,
388
- onUpdate: (text) => {
389
- promptRef.current?.setText(text);
390
- promptRef.current?.focus();
391
- }
392
- });
393
- return /* @__PURE__ */ React2.createElement("div", {
394
- className: mx2("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
395
- }, /* @__PURE__ */ React2.createElement("div", {
396
- className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
397
- }, error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
398
- content: error.message,
399
- delayDuration: 0
400
- }, /* @__PURE__ */ React2.createElement(Icon, {
401
- icon: "ph--warning-circle--regular",
402
- classNames: errorText,
403
- size: 5
404
- })) || /* @__PURE__ */ React2.createElement(Spinner, {
405
- active: processing
406
- })), /* @__PURE__ */ React2.createElement(Prompt, {
407
- ref: promptRef,
408
- autoFocus: true,
409
- classNames: "pbs-2",
410
- lineWrapping: true,
411
- placeholder: placeholder ?? t("prompt placeholder"),
412
- references,
413
- onCancel,
414
- ...props
415
- }), (onCancel || microphone) && /* @__PURE__ */ React2.createElement("div", {
416
- className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
417
- }, processing && onCancel && /* @__PURE__ */ React2.createElement(IconButton, {
418
- classNames: "px-1.5",
419
- variant: "ghost",
420
- size: 5,
421
- icon: "ph--x--regular",
422
- iconOnly: true,
423
- label: t("cancel processing button"),
424
- onClick: onCancel
425
- }), !processing && microphone && /* @__PURE__ */ React2.createElement(IconButton, {
426
- classNames: mx2("px-1.5", recording && "bg-primary-500"),
427
- variant: "ghost",
428
- size: 5,
429
- icon: "ph--microphone--regular",
430
- iconOnly: true,
431
- noTooltip: true,
432
- label: t("microphone button"),
433
- onMouseDown: () => setActive(true),
434
- onMouseUp: () => setActive(false),
435
- onTouchStart: () => setActive(true),
436
- onTouchEnd: () => setActive(false)
437
- })));
438
- } finally {
439
- _effect.f();
440
- }
441
- });
442
-
443
- // packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx
444
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
445
- import React3, { useState as useState2, useEffect, Fragment } from "react";
446
- import { parseToolName } from "@dxos/ai";
447
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
448
- import { FunctionType } from "@dxos/functions";
449
- import { log as log3 } from "@dxos/log";
450
- import { Filter, useQuery } from "@dxos/react-client/echo";
451
- import { mx as mx3 } from "@dxos/react-ui-theme";
452
-
453
- // packages/plugins/plugin-assistant/src/tools/function.ts
454
- import { createTool, ToolResult } from "@dxos/ai";
455
- import { Type } from "@dxos/echo";
456
- import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
457
- import { log } from "@dxos/log";
458
- import { getMeta } from "@dxos/react-client/echo";
459
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
460
- var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
461
- if (!fn.description || !fn.inputSchema) {
462
- return void 0;
463
- }
464
- const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
465
- if (!existingFunctionUrl) {
466
- return void 0;
467
- }
468
- const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
469
- spaceId
470
- });
471
- return createTool("user-function", {
472
- name: fn.name,
473
- description: fn.description,
474
- schema: Type.toEffectSchema(fn.inputSchema),
475
- execute: async (input) => {
476
- log.info("execute function tool", {
477
- name: fn.name,
478
- url,
479
- input
480
- }, {
481
- F: __dxlog_file,
482
- L: 34,
483
- S: void 0,
484
- C: (f, a) => f(...a)
485
- });
486
- const response = await fetch(url, {
487
- method: "POST",
488
- headers: {
489
- "Content-Type": "application/json"
490
- },
491
- body: JSON.stringify(input)
492
- });
493
- return ToolResult.Success(await response.text());
494
- }
495
- });
496
- };
497
-
498
- // packages/plugins/plugin-assistant/src/tools/openapi.ts
499
- import { Schema } from "effect";
500
- import jsonpointer from "jsonpointer";
501
- import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
502
- import { Type as Type2 } from "@dxos/echo";
503
- import { normalizeSchema } from "@dxos/echo-schema";
504
- import { invariant } from "@dxos/invariant";
505
- import { log as log2 } from "@dxos/log";
506
- import { deepMapValues } from "@dxos/util";
507
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
508
- var createToolsFromService = async (service) => {
509
- invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
510
- F: __dxlog_file2,
511
- L: 24,
512
- S: void 0,
513
- A: [
514
- "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
515
- ""
516
- ]
517
- });
518
- const iface = service.interfaces[0];
519
- invariant(iface.schemaUrl, void 0, {
520
- F: __dxlog_file2,
521
- L: 26,
522
- S: void 0,
523
- A: [
524
- "iface.schemaUrl",
525
- ""
526
- ]
527
- });
528
- invariant(iface.schemaUrl, void 0, {
529
- F: __dxlog_file2,
530
- L: 27,
531
- S: void 0,
532
- A: [
533
- "iface.schemaUrl",
534
- ""
535
- ]
536
- });
537
- return createToolsFromApi(iface.schemaUrl, {
538
- authorization: iface.authorization
539
- });
540
- };
541
- var createToolsFromApi = async (url, options) => {
542
- const res = await fetch(url);
543
- const spec = await res.json();
544
- log2("spec", {
545
- spec
546
- }, {
547
- F: __dxlog_file2,
548
- L: 37,
549
- S: void 0,
550
- C: (f, a) => f(...a)
551
- });
552
- const tools = [];
553
- for (const [path, pathItem] of Object.entries(spec.paths)) {
554
- if (typeof pathItem !== "object") {
555
- continue;
556
- }
557
- const { ...methods } = pathItem;
558
- for (const [method, m] of Object.entries(methods)) {
559
- const methodItem = m;
560
- log2("methodItem", {
561
- path,
562
- method,
563
- methodItem
564
- }, {
565
- F: __dxlog_file2,
566
- L: 48,
567
- S: void 0,
568
- C: (f, a) => f(...a)
569
- });
570
- const parametersResolved = methodItem.parameters?.map((parameter) => {
571
- const resolved = resolveJsonSchema(parameter, spec);
572
- return resolved;
573
- }) ?? [];
574
- const inputSchema = {
575
- type: "object",
576
- properties: {}
577
- };
578
- const endpointParameters = [];
579
- for (const parameter of parametersResolved) {
580
- log2("parameter", {
581
- parameter
582
- }, {
583
- F: __dxlog_file2,
584
- L: 63,
585
- S: void 0,
586
- C: (f, a) => f(...a)
587
- });
588
- if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
589
- continue;
590
- }
591
- endpointParameters.push(parameter);
592
- if (parameter.schema) {
593
- inputSchema.properties[parameter.name] = normalizeSchema(parameter.schema);
594
- } else if (typeof parameter.type === "string") {
595
- const { name, in: _in, required, ...schema } = parameter;
596
- inputSchema.properties[name] = normalizeSchema(schema);
597
- if (required) {
598
- inputSchema.required ??= [];
599
- inputSchema.required.push(name);
600
- }
601
- }
602
- }
603
- log2("inputSchema", {
604
- inputSchema
605
- }, {
606
- F: __dxlog_file2,
607
- L: 88,
608
- S: void 0,
609
- C: (f, a) => f(...a)
610
- });
611
- Schema.validateSync(Type2.JsonSchema)(inputSchema);
612
- const description = methodItem.description ?? methodItem.summary;
613
- if (!description) {
614
- log2.warn("no description", {
615
- path,
616
- method
617
- }, {
618
- F: __dxlog_file2,
619
- L: 93,
620
- S: void 0,
621
- C: (f, a) => f(...a)
622
- });
623
- continue;
624
- }
625
- const endpoint = {
626
- document: spec,
627
- path,
628
- method,
629
- parameters: endpointParameters,
630
- authorization: options?.authorization
631
- };
632
- tools.push(
633
- // TODO(burdon): Namespace?
634
- createRawTool("openapi", {
635
- name: getToolName(path, method, methodItem),
636
- description: options?.instructions ? `${options.instructions}
637
-
638
- ${description}` : description,
639
- parameters: inputSchema,
640
- execute: async (input) => {
641
- const response = await callApiEndpoint(endpoint, input);
642
- return ToolResult2.Success(response);
643
- }
644
- })
645
- );
646
- }
647
- }
648
- return tools;
649
- };
650
- var getToolName = (path, method, methodItem) => {
651
- if (methodItem.operationId) {
652
- return methodItem.operationId;
653
- }
654
- let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
655
- while (name.length > MAX_TOOL_NAME_LENGTH) {
656
- const lengthBefore = name.length;
657
- for (const word of GENERIC_WORDS) {
658
- if (name.includes(word)) {
659
- name = name.replace(word, "");
660
- break;
661
- }
662
- }
663
- name = name.replaceAll("__", "_").replace(/_$/, "");
664
- const lengthAfter = name.length;
665
- if (lengthBefore === lengthAfter) {
666
- break;
667
- }
668
- }
669
- name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
670
- return name.slice(0, MAX_TOOL_NAME_LENGTH);
671
- };
672
- var MAX_TOOL_NAME_LENGTH = 64;
673
- var GENERIC_WORDS = [
674
- "services",
675
- "service",
676
- "api",
677
- "rest",
678
- "endpoint",
679
- "get",
680
- "post",
681
- "put",
682
- "delete",
683
- "patch",
684
- "head",
685
- "options",
686
- "trace",
687
- "service",
688
- "api",
689
- "endpoint"
690
- ];
691
- var callApiEndpoint = async (endpoint, input) => {
692
- log2.info("endpoint", {
693
- method: endpoint.method,
694
- name: endpoint.path,
695
- input
696
- }, {
697
- F: __dxlog_file2,
698
- L: 180,
699
- S: void 0,
700
- C: (f, a) => f(...a)
701
- });
702
- let url = getEndpointUrl(endpoint);
703
- const request = {
704
- method: endpoint.method,
705
- headers: {}
706
- };
707
- const query = new URLSearchParams();
708
- let body;
709
- for (const parameter of endpoint.parameters) {
710
- if (input[parameter.name] === void 0) {
711
- continue;
712
- }
713
- switch (parameter.in) {
714
- case "header": {
715
- if (parameter.example) {
716
- request.headers[parameter.name] = parameter.default;
717
- }
718
- break;
719
- }
720
- case "path": {
721
- url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
722
- break;
723
- }
724
- case "body": {
725
- const value = input[parameter.name];
726
- const effectSchema = Type2.toEffectSchema(parameter.schema);
727
- Schema.validateSync(effectSchema)(value);
728
- if (body) {
729
- throw new Error(`Duplicate body parameter: ${parameter.name}`);
730
- }
731
- body = value;
732
- break;
733
- }
734
- case "query": {
735
- query.set(parameter.name, input[parameter.name]);
736
- break;
737
- }
738
- }
739
- }
740
- if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
741
- request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
742
- } else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
743
- query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
744
- }
745
- if (query.size > 0) {
746
- url += `?${query.toString()}`;
747
- }
748
- if (body) {
749
- request.body = JSON.stringify(body);
750
- request.headers["Content-Type"] = "application/json";
751
- }
752
- log2.info("request", {
753
- url,
754
- request
755
- }, {
756
- F: __dxlog_file2,
757
- L: 243,
758
- S: void 0,
759
- C: (f, a) => f(...a)
760
- });
761
- const response = await fetch(url, request);
762
- log2.info("response", {
763
- ok: response.ok,
764
- status: response.status,
765
- statusText: response.statusText
766
- }, {
767
- F: __dxlog_file2,
768
- L: 246,
769
- S: void 0,
770
- C: (f, a) => f(...a)
771
- });
772
- if (response.ok) {
773
- const contentType = response.headers.get("Content-Type");
774
- if (contentType?.includes("application/json")) {
775
- return await response.json();
776
- } else {
777
- return await response.text();
778
- }
779
- } else {
780
- if (response.headers.get("Content-Type")?.includes("application/json")) {
781
- const responseBody = await response.text();
782
- let error;
783
- try {
784
- error = JSON.parse(responseBody);
785
- } catch {
786
- error = responseBody;
787
- }
788
- log2.error("error", {
789
- error
790
- }, {
791
- F: __dxlog_file2,
792
- L: 264,
793
- S: void 0,
794
- C: (f, a) => f(...a)
795
- });
796
- throw new Error(error.message);
797
- } else {
798
- const error = await response.text();
799
- log2.error("error", {
800
- error
801
- }, {
802
- F: __dxlog_file2,
803
- L: 268,
804
- S: void 0,
805
- C: (f, a) => f(...a)
806
- });
807
- throw new Error(error);
808
- }
809
- }
810
- };
811
- var getEndpointUrl = (endpoint) => {
812
- let url = "";
813
- if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
814
- url = endpoint.document.servers[0].url;
815
- } else {
816
- invariant(!isV3_1(endpoint.document), void 0, {
817
- F: __dxlog_file2,
818
- L: 279,
819
- S: void 0,
820
- A: [
821
- "!isV3_1(endpoint.document)",
822
- ""
823
- ]
824
- });
825
- url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
826
- }
827
- if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
828
- url += endpoint.document.basePath;
829
- }
830
- url += endpoint.path;
831
- return url;
832
- };
833
- var resolveAuthorization = async (authorization) => {
834
- switch (authorization.type) {
835
- case "api-key": {
836
- invariant(authorization.placement.type === "authorization-header", void 0, {
837
- F: __dxlog_file2,
838
- L: 295,
839
- S: void 0,
840
- A: [
841
- "authorization.placement.type === 'authorization-header'",
842
- ""
843
- ]
844
- });
845
- return `Bearer ${authorization.key}`;
846
- }
847
- case "oauth": {
848
- const response = await fetch(authorization.tokenUrl, {
849
- method: "POST",
850
- headers: {
851
- "Content-Type": "application/x-www-form-urlencoded"
852
- },
853
- body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
854
- });
855
- const data = await response.json();
856
- return `Bearer ${data.access_token}`;
857
- }
858
- default: {
859
- throw new Error(`Unknown authorization type: ${authorization.type}`);
860
- }
861
- }
862
- };
863
- var resolveJsonSchema = (schema, base) => {
864
- return deepMapValues(schema, (value, recurse) => {
865
- if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
866
- if (value.$ref.startsWith("#")) {
867
- const resolved = jsonpointer.get(base, value.$ref.slice(1));
868
- if (resolved) {
869
- return recurse(resolved);
870
- } else {
871
- log2.warn("unresolved", {
872
- ref: value.$ref,
873
- base
874
- }, {
875
- F: __dxlog_file2,
876
- L: 328,
877
- S: void 0,
878
- C: (f, a) => f(...a)
879
- });
880
- }
881
- }
882
- }
883
- return recurse(value);
884
- });
885
- };
886
- var isV3_1 = (document2) => {
887
- return document2.openapi === "3.0.1";
888
- };
889
-
890
- // packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx
891
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
892
- var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
893
- var _effect = _useSignals3();
894
- try {
895
- return /* @__PURE__ */ React3.createElement("div", {
896
- className: mx3("flex flex-col overflow-y-auto box-content", classNames)
897
- }, artifacts && artifacts.length > 0 && /* @__PURE__ */ React3.createElement(Section, {
898
- title: "Artifacts",
899
- items: artifacts.map(({ name, description, tools }) => ({
900
- name,
901
- description,
902
- subitems: tools.map(({ name: name2, description: description2 }) => ({
903
- name: `\u2219 ${parseToolName(name2)}`,
904
- description: description2
905
- }))
906
- }))
907
- }), services && services.length > 0 && /* @__PURE__ */ React3.createElement(Section, {
908
- title: "Services",
909
- items: services.map(({ service: { serviceId, name, description }, tools }) => ({
910
- name: name ?? serviceId,
911
- description,
912
- subitems: tools.map(({ name: name2, description: description2 }) => ({
913
- name: `\u2219 ${name2}`,
914
- description: description2
915
- }))
916
- }))
917
- }), functions && functions.length > 0 && /* @__PURE__ */ React3.createElement(Section, {
918
- title: "Functions",
919
- items: functions.map(({ name, description }) => ({
920
- name,
921
- description
922
- }))
923
- }));
924
- } finally {
925
- _effect.f();
926
- }
927
- };
928
- var Section = ({ title, items, striped }) => {
929
- var _effect = _useSignals3();
930
- try {
931
- const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
932
- const gridClassNames = "grid grid-cols-[8rem_1fr]";
933
- const subGridClassNames = mx3("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
934
- return /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement("h1", {
935
- className: "px-2 text-sm"
936
- }, title), /* @__PURE__ */ React3.createElement("div", {
937
- className: gridClassNames
938
- }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React3.createElement(Fragment, {
939
- key: i
940
- }, name && /* @__PURE__ */ React3.createElement("div", {
941
- className: subGridClassNames
942
- }, /* @__PURE__ */ React3.createElement("div", {
943
- className: "truncate text-primary-500"
944
- }, name), /* @__PURE__ */ React3.createElement("div", {
945
- className: "line-clamp-2"
946
- }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React3.createElement("div", {
947
- key: i2,
948
- className: mx3(subGridClassNames, striped && stripeClassNames)
949
- }, /* @__PURE__ */ React3.createElement("div", {
950
- className: "truncate"
951
- }, name2), /* @__PURE__ */ React3.createElement("div", {
952
- className: "line-clamp-3 text-subdued"
953
- }, description2)))))));
954
- } finally {
955
- _effect.f();
956
- }
957
- };
958
- var ToolboxContainer = ({ classNames, space }) => {
959
- var _effect = _useSignals3();
960
- try {
961
- const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
962
- const services = useQuery(space, Filter.type(ServiceType));
963
- const [serviceTools, setServiceTools] = useState2([]);
964
- useEffect(() => {
965
- log3("creating service tools...", {
966
- services: services.length
967
- }, {
968
- F: __dxlog_file3,
969
- L: 100,
970
- S: void 0,
971
- C: (f, a) => f(...a)
972
- });
973
- queueMicrotask(async () => {
974
- const tools = await Promise.all(services.map(async (service) => ({
975
- service,
976
- tools: await createToolsFromService(service)
977
- })));
978
- setServiceTools(tools);
979
- });
980
- }, [
981
- services
982
- ]);
983
- const functions = useQuery(space, Filter.type(FunctionType));
984
- return /* @__PURE__ */ React3.createElement(Toolbox, {
985
- classNames,
986
- artifacts: artifactDefinitions,
987
- services: serviceTools,
988
- functions
989
- });
990
- } finally {
991
- _effect.f();
992
- }
993
- };
994
-
995
- // packages/plugins/plugin-assistant/src/components/Thread/Thread.tsx
996
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
997
- import React6, { useCallback, useMemo as useMemo2, useRef as useRef2 } from "react";
998
- import { useIdentity } from "@dxos/react-client/halo";
999
- import { ScrollContainer } from "@dxos/react-ui-components";
1000
- import { mx as mx5 } from "@dxos/react-ui-theme";
1001
- import { keyToFallback } from "@dxos/util";
1002
-
1003
- // packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx
1004
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1005
- import React5 from "react";
1006
- import { Surface } from "@dxos/app-framework";
1007
- import { invariant as invariant2 } from "@dxos/invariant";
1008
- import { Button, Icon as Icon2, IconButton as IconButton2 } from "@dxos/react-ui";
1009
- import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
1010
- import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
1011
- import { mx as mx4 } from "@dxos/react-ui-theme";
1012
- import { safeParseJson } from "@dxos/util";
1013
-
1014
- // packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx
1015
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
1016
- import React4, { useEffect as useEffect2, useMemo, useRef, useState as useState3 } from "react";
1017
- import { log as log4 } from "@dxos/log";
1018
- import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
1019
- import { Json } from "@dxos/react-ui-syntax-highlighter";
1020
- import { isNonNullable as isNonNullable2, isNotFalsy } from "@dxos/util";
1021
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
1022
- var isToolMessage = (message) => {
1023
- return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
1024
- };
1025
- var getToolName2 = (tool) => {
1026
- return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
1027
- };
1028
- var getToolCaption = (tool, status) => {
1029
- if (!tool) {
1030
- return "Calling tool...";
1031
- }
1032
- return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
1033
- };
1034
- var ToolBlock = ({ classNames, message, tools }) => {
1035
- var _effect = _useSignals4();
1036
- try {
1037
- const { content = [] } = message;
1038
- let request;
1039
- const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
1040
- const items = blocks.map((block) => {
1041
- switch (block.type) {
1042
- case "tool_use": {
1043
- if (block.pending && request?.block.id === block.id) {
1044
- return null;
1045
- }
1046
- log4.info("tool_use", {
1047
- tool: request?.tool,
1048
- status: block.currentStatus
1049
- }, {
1050
- F: __dxlog_file4,
1051
- L: 46,
1052
- S: void 0,
1053
- C: (f, a) => f(...a)
1054
- });
1055
- request = {
1056
- tool: tools?.find((tool) => tool.name === block.name),
1057
- block
1058
- };
1059
- return {
1060
- title: getToolCaption(request.tool, block.currentStatus),
1061
- block
1062
- };
1063
- }
1064
- case "tool_result": {
1065
- if (!request) {
1066
- log4.warn("unexpected message", {
1067
- block
1068
- }, {
1069
- F: __dxlog_file4,
1070
- L: 54,
1071
- S: void 0,
1072
- C: (f, a) => f(...a)
1073
- });
1074
- return {
1075
- title: "Error",
1076
- block
1077
- };
1078
- }
1079
- return {
1080
- title: `${getToolCaption(request.tool, void 0)} (Success)`,
1081
- block
1082
- };
1083
- }
1084
- default: {
1085
- request = void 0;
1086
- return {
1087
- title: "Error",
1088
- block
1089
- };
1090
- }
1091
- }
1092
- }).filter(isNonNullable2);
1093
- return /* @__PURE__ */ React4.createElement(ToolContainer, {
1094
- classNames,
1095
- items
1096
- });
1097
- } finally {
1098
- _effect.f();
1099
- }
1100
- };
1101
- var ToolContainer = ({ classNames, items }) => {
1102
- var _effect = _useSignals4();
1103
- try {
1104
- const tabsRef = useRef(null);
1105
- const [selected, setSelected] = useState3(0);
1106
- const [open, setOpen] = useState3(false);
1107
- useEffect2(() => {
1108
- if (open) {
1109
- tabsRef.current?.focus();
1110
- }
1111
- }, [
1112
- open
1113
- ]);
1114
- const handleSelect = (index) => {
1115
- if (index === selected) {
1116
- setOpen(false);
1117
- } else {
1118
- setSelected(index);
1119
- }
1120
- };
1121
- const title = useMemo(() => {
1122
- const lines = items.map((item) => item.title).filter(isNotFalsy);
1123
- return /* @__PURE__ */ React4.createElement(StatusRoll, {
1124
- key: "status-roll",
1125
- lines,
1126
- duration: 1e3,
1127
- autoAdvance: true
1128
- });
1129
- }, [
1130
- items
1131
- ]);
1132
- return /* @__PURE__ */ React4.createElement(ToggleContainer, {
1133
- classNames: [
1134
- "flex flex-col",
1135
- classNames
1136
- ],
1137
- title,
1138
- open,
1139
- onChangeOpen: setOpen
1140
- }, /* @__PURE__ */ React4.createElement("div", {
1141
- className: "grid grid-cols-[32px_1fr]"
1142
- }, /* @__PURE__ */ React4.createElement(NumericTabs, {
1143
- ref: tabsRef,
1144
- length: items.length,
1145
- selected,
1146
- onSelect: handleSelect
1147
- }), /* @__PURE__ */ React4.createElement(Json, {
1148
- data: items[selected].block,
1149
- classNames: "!p-1 text-xs"
1150
- })));
1151
- } finally {
1152
- _effect.f();
1153
- }
1154
- };
1155
-
1156
- // packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx
1157
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
1158
- var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-md";
1159
- var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
1160
- var ToggleContainer2 = (props) => {
1161
- var _effect = _useSignals5();
1162
- try {
1163
- return /* @__PURE__ */ React5.createElement(NativeToggleContainer, {
1164
- ...props,
1165
- classNames: mx4(panelClassNames, props.classNames)
1166
- });
1167
- } finally {
1168
- _effect.f();
1169
- }
1170
- };
1171
- var MessageContainer = ({ children, classNames, user }) => {
1172
- var _effect = _useSignals5();
1173
- try {
1174
- if (!children) {
1175
- return null;
1176
- }
1177
- return /* @__PURE__ */ React5.createElement("div", {
1178
- role: "list-item",
1179
- className: mx4("flex w-full", user && "justify-end", classNames)
1180
- }, /* @__PURE__ */ React5.createElement("div", {
1181
- className: mx4(user ? [
1182
- "px-2 py-1 rounded-md",
1183
- userClassNames
1184
- ] : "w-full")
1185
- }, children));
1186
- } finally {
1187
- _effect.f();
1188
- }
1189
- };
1190
- var ThreadMessage = ({ classNames, space, message, tools, onPrompt, onAddToGraph }) => {
1191
- var _effect = _useSignals5();
1192
- try {
1193
- const { role, content = [] } = message;
1194
- if (isToolMessage(message)) {
1195
- return /* @__PURE__ */ React5.createElement(MessageContainer, {
1196
- classNames: mx4(classNames, "animate-[fadeIn_0.5s]")
1197
- }, /* @__PURE__ */ React5.createElement(ToolBlock, {
1198
- space,
1199
- classNames: panelClassNames,
1200
- message,
1201
- tools
1202
- }));
1203
- }
1204
- return content.map((block, idx) => {
1205
- if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1206
- return null;
1207
- }
1208
- const Component = components[block.type] ?? components.default;
1209
- return /* @__PURE__ */ React5.createElement(MessageContainer, {
1210
- key: idx,
1211
- classNames: mx4(classNames, "animate-[fadeIn_0.5s]"),
1212
- user: block.type === "text" && role === "user"
1213
- }, /* @__PURE__ */ React5.createElement(Component, {
1214
- space,
1215
- block,
1216
- onPrompt,
1217
- onAddToGraph
1218
- }));
1219
- });
1220
- } finally {
1221
- _effect.f();
1222
- }
1223
- };
1224
- var components = {
1225
- //
1226
- // Text
1227
- //
1228
- ["text"]: ({ block }) => {
1229
- invariant2(block.type === "text", void 0, {
1230
- F: __dxlog_file5,
1231
- L: 105,
1232
- S: void 0,
1233
- A: [
1234
- "block.type === 'text'",
1235
- ""
1236
- ]
1237
- });
1238
- const title = block.disposition ? titles[block.disposition] : void 0;
1239
- if (!title) {
1240
- return /* @__PURE__ */ React5.createElement(MarkdownViewer, {
1241
- classNames: "[&>p]:animate-[fadeIn_0.5s]",
1242
- content: block.text
1243
- });
1244
- }
1245
- return /* @__PURE__ */ React5.createElement(ToggleContainer2, {
1246
- // open={open}
1247
- defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
1248
- title,
1249
- icon: block.pending ? /* @__PURE__ */ React5.createElement(Icon2, {
1250
- icon: "ph--circle-notch--regular",
1251
- classNames: "text-subdued ml-2 animate-spin",
1252
- size: 4
1253
- }) : void 0
1254
- }, /* @__PURE__ */ React5.createElement(MarkdownViewer, {
1255
- content: block.text,
1256
- classNames: [
1257
- "pbe-2",
1258
- systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
1259
- ]
1260
- }));
1261
- },
1262
- //
1263
- // JSON
1264
- //
1265
- ["json"]: ({ space, block, onPrompt, onAddToGraph }) => {
1266
- invariant2(block.type === "json", void 0, {
1267
- F: __dxlog_file5,
1268
- L: 143,
1269
- S: void 0,
1270
- A: [
1271
- "block.type === 'json'",
1272
- ""
1273
- ]
1274
- });
1275
- switch (block.disposition) {
1276
- case "tool_list": {
1277
- return /* @__PURE__ */ React5.createElement(ToggleContainer2, {
1278
- title: titles[block.disposition],
1279
- defaultOpen: true
1280
- }, /* @__PURE__ */ React5.createElement(ToolboxContainer, {
1281
- space,
1282
- classNames: "pbe-2"
1283
- }));
1284
- }
1285
- case "suggest": {
1286
- const { text = "" } = safeParseJson(block.json ?? "{}") ?? {};
1287
- return /* @__PURE__ */ React5.createElement(IconButton2, {
1288
- icon: "ph--lightning--regular",
1289
- label: text,
1290
- onClick: () => onPrompt?.(text)
1291
- });
1292
- }
1293
- case "select": {
1294
- const { options = [] } = safeParseJson(block.json ?? "{}") ?? {};
1295
- return /* @__PURE__ */ React5.createElement("div", {
1296
- className: "flex flex-wrap gap-1"
1297
- }, options.map((option, idx) => /* @__PURE__ */ React5.createElement(Button, {
1298
- classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
1299
- key: option,
1300
- onClick: () => onPrompt?.(option)
1301
- }, option)));
1302
- }
1303
- case "graph": {
1304
- return /* @__PURE__ */ React5.createElement("div", {
1305
- className: "flex flex-wrap gap-1"
1306
- }, /* @__PURE__ */ React5.createElement(Surface, {
1307
- role: "card",
1308
- data: {
1309
- subject: JSON.parse(block.json ?? "{}")
1310
- },
1311
- limit: 1,
1312
- fallback: /* @__PURE__ */ React5.createElement("div", {
1313
- className: "font-mono text-xs text-pre"
1314
- }, block.json)
1315
- }), onAddToGraph && /* @__PURE__ */ React5.createElement(IconButton2, {
1316
- icon: "ph--plus--regular",
1317
- label: "Add to graph",
1318
- onClick: () => onAddToGraph?.(JSON.parse(block.json ?? "{}"))
1319
- }));
1320
- }
1321
- default: {
1322
- const title = block.disposition ? titles[block.disposition] : void 0;
1323
- return /* @__PURE__ */ React5.createElement(ToggleContainer2, {
1324
- title: title ?? "JSON"
1325
- }, /* @__PURE__ */ React5.createElement(Json2, {
1326
- data: safeParseJson(block.json ?? block),
1327
- classNames: "!p-1 text-xs"
1328
- }));
1329
- }
1330
- }
1331
- },
1332
- //
1333
- // Default
1334
- //
1335
- default: ({ block }) => {
1336
- let title = titles[block.type];
1337
- if (block.type === "tool_use") {
1338
- title = `Tool [${block.name}]`;
1339
- }
1340
- return /* @__PURE__ */ React5.createElement(ToggleContainer2, {
1341
- title: title ?? "JSON"
1342
- }, /* @__PURE__ */ React5.createElement(Json2, {
1343
- data: block,
1344
- classNames: "!p-1 text-xs"
1345
- }));
1346
- }
1347
- };
1348
- var titles = {
1349
- ["cot"]: "Chain of thought",
1350
- ["artifact"]: "Artifact",
1351
- ["tool_use"]: "Tool request",
1352
- ["tool_result"]: "Tool result",
1353
- ["tool_list"]: "Tools",
1354
- ["artifact-update"]: "Artifact(s) changed"
1355
- };
1356
- var systemDispositions = [
1357
- "cot",
1358
- "artifact-update"
1359
- ];
1360
-
1361
- // packages/plugins/plugin-assistant/src/components/Thread/reducer.ts
1362
- var messageReducer = ({ current, messages }, message) => {
1363
- let i = 0;
1364
- for (const block of message.content) {
1365
- switch (block.type) {
1366
- case "tool_use":
1367
- case "tool_result": {
1368
- if (current) {
1369
- current.content.push(block);
1370
- } else {
1371
- current = {
1372
- id: [
1373
- message.id,
1374
- i
1375
- ].join("_"),
1376
- role: message.role,
1377
- content: [
1378
- block
1379
- ]
1380
- };
1381
- messages.push(current);
1382
- }
1383
- break;
1384
- }
1385
- case "text":
1386
- default: {
1387
- current = void 0;
1388
- messages.push({
1389
- id: [
1390
- message.id,
1391
- i
1392
- ].join("_"),
1393
- role: message.role,
1394
- content: [
1395
- block
1396
- ]
1397
- });
1398
- break;
1399
- }
1400
- }
1401
- i++;
1402
- }
1403
- return {
1404
- current,
1405
- messages
1406
- };
1407
- };
1408
-
1409
- // packages/plugins/plugin-assistant/src/components/Thread/Thread.tsx
1410
- var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
1411
- var _effect = _useSignals6();
1412
- try {
1413
- const scroller = useRef2(null);
1414
- const identity = useIdentity();
1415
- const fallbackValue = keyToFallback(identity.identityKey);
1416
- const userHue = identity.profile?.data?.hue || fallbackValue.hue;
1417
- const handleSubmit = useCallback((value) => {
1418
- onSubmit?.(value);
1419
- scroller.current?.scrollToBottom();
1420
- return true;
1421
- }, [
1422
- onSubmit
1423
- ]);
1424
- const { messages: filteredMessages = [] } = useMemo2(() => {
1425
- if (collapse) {
1426
- return (messages ?? []).reduce(messageReducer, {
1427
- messages: []
1428
- });
1429
- } else {
1430
- return {
1431
- messages: messages ?? []
1432
- };
1433
- }
1434
- }, [
1435
- messages,
1436
- collapse
1437
- ]);
1438
- const references = useMemo2(() => {
1439
- if (!contextProvider) {
1440
- return void 0;
1441
- }
1442
- return {
1443
- getReferences: async ({ query }) => contextProvider.query({
1444
- query
1445
- }),
1446
- resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
1447
- uri
1448
- })
1449
- };
1450
- }, [
1451
- contextProvider
1452
- ]);
1453
- return /* @__PURE__ */ React6.createElement("div", {
1454
- role: "none",
1455
- className: mx5("flex flex-col grow overflow-hidden", classNames)
1456
- }, /* @__PURE__ */ React6.createElement(ScrollContainer, {
1457
- ref: scroller,
1458
- fade: true
1459
- }, /* @__PURE__ */ React6.createElement("div", {
1460
- role: "none",
1461
- className: mx5(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1462
- style: {
1463
- "--user-fill": `var(--dx-${userHue}Fill)`
1464
- }
1465
- }, filteredMessages.map((message) => /* @__PURE__ */ React6.createElement(ThreadMessage, {
1466
- key: message.id,
1467
- classNames: "px-4 pbe-4",
1468
- space,
1469
- message,
1470
- ...props
1471
- })))), onSubmit && /* @__PURE__ */ React6.createElement(PromptBar, {
1472
- microphone: transcription,
1473
- processing,
1474
- error,
1475
- onSubmit: handleSubmit,
1476
- onCancel,
1477
- onOpenChange,
1478
- references
1479
- }));
1480
- } finally {
1481
- _effect.f();
1482
- }
1483
- };
1484
-
1485
- // packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx
1486
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1487
- import React7, { useCallback as useCallback3, useEffect as useEffect5 } from "react";
1488
- import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
1489
- import { DXN, Ref } from "@dxos/echo";
1490
- import { invariant as invariant4 } from "@dxos/invariant";
1491
- import { log as log7 } from "@dxos/log";
1492
- import { getSpace as getSpace2 } from "@dxos/react-client/echo";
1493
-
1494
- // packages/plugins/plugin-assistant/src/hooks/processor.ts
1495
- import { batch, computed, signal } from "@preact/signals-core";
1496
- import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
1497
- import { AISession } from "@dxos/assistant";
1498
- import { invariant as invariant3 } from "@dxos/invariant";
1499
- import { log as log5 } from "@dxos/log";
1500
- import { Filter as Filter2, getVersion } from "@dxos/react-client/echo";
1501
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/processor.ts";
1502
- var defaultOptions = {
1503
- model: DEFAULT_EDGE_MODEL,
1504
- systemPrompt: "you are a helpful assistant"
1505
- };
1506
- var ChatProcessor = class {
1507
- constructor(_ai, _tools, _artifacts, _extensions, _options = defaultOptions) {
1508
- this._ai = _ai;
1509
- this._tools = _tools;
1510
- this._artifacts = _artifacts;
1511
- this._extensions = _extensions;
1512
- this._options = _options;
1513
- this._pending = signal([]);
1514
- this._block = signal(void 0);
1515
- this.streaming = computed(() => this._block.value !== void 0);
1516
- this.error = signal(void 0);
1517
- this.messages = computed(() => {
1518
- const messages = [
1519
- ...this._pending.value
1520
- ];
1521
- if (this._block.value) {
1522
- const current = messages.pop();
1523
- invariant3(current, void 0, {
1524
- F: __dxlog_file6,
1525
- L: 79,
1526
- S: this,
1527
- A: [
1528
- "current",
1529
- ""
1530
- ]
1531
- });
1532
- const { content, ...rest } = current;
1533
- const message = {
1534
- ...rest,
1535
- content: [
1536
- ...content,
1537
- this._block.value
1538
- ]
1539
- };
1540
- messages.push(message);
1541
- }
1542
- return messages;
1543
- });
1544
- this._artifactDiffResolver = async (artifacts) => {
1545
- const space = this._extensions?.space;
1546
- if (!space) {
1547
- return /* @__PURE__ */ new Map();
1548
- }
1549
- const versions = /* @__PURE__ */ new Map();
1550
- await Promise.all(artifacts.map(async (artifact) => {
1551
- const { objects: [object] } = await space.db.query(Filter2.ids(artifact.id)).run();
1552
- if (!object) {
1553
- return;
1554
- }
1555
- versions.set(artifact.id, {
1556
- version: getVersion(object),
1557
- diff: `Current state: ${JSON.stringify(object)}`
1558
- });
1559
- }));
1560
- return versions;
1561
- };
1562
- }
1563
- get tools() {
1564
- return this._tools;
1565
- }
1566
- /**
1567
- * Update tools.
1568
- */
1569
- setTools(tools) {
1570
- this._tools = tools;
1571
- }
1572
- /**
1573
- * Make GPT request.
1574
- */
1575
- async request(message, options = {}) {
1576
- this._session = new AISession({
1577
- operationModel: "configured"
1578
- });
1579
- this._session.message.on((message2) => {
1580
- batch(() => {
1581
- this._pending.value = [
1582
- ...this._pending.value,
1583
- message2
1584
- ];
1585
- this._block.value = void 0;
1586
- });
1587
- });
1588
- this._session.update.on((block) => {
1589
- batch(() => {
1590
- this._block.value = block;
1591
- });
1592
- });
1593
- this._session.userMessage.on((message2) => {
1594
- this._pending.value = [
1595
- ...this._pending.value,
1596
- message2
1597
- ];
1598
- });
1599
- this._session.toolStatusReport.on(({ message: message2, status }) => {
1600
- const msg = this._pending.peek().find((m) => m.id === message2.id);
1601
- const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
1602
- if (!toolUse) {
1603
- return;
1604
- }
1605
- const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
1606
- if (block) {
1607
- this._pending.value = this._pending.value.map((m) => {
1608
- if (m.id === message2.id) {
1609
- return {
1610
- ...m,
1611
- content: m.content.map((b) => b.type === "tool_use" && b.id === toolUse.id ? {
1612
- ...b,
1613
- currentStatus: status
1614
- } : b)
1615
- };
1616
- }
1617
- return m;
1618
- });
1619
- } else {
1620
- log5.warn("no block for status report", void 0, {
1621
- F: __dxlog_file6,
1622
- L: 155,
1623
- S: this,
1624
- C: (f, a) => f(...a)
1625
- });
1626
- }
1627
- });
1628
- try {
1629
- const messages = await this._session.run({
1630
- client: this._ai,
1631
- history: options.history ?? [],
1632
- artifacts: this._artifacts ?? [],
1633
- requiredArtifactIds: this._artifacts?.map((artifact) => artifact.id) ?? [],
1634
- tools: this._tools ?? [],
1635
- prompt: message,
1636
- systemPrompt: this._options.systemPrompt,
1637
- extensions: this._extensions,
1638
- artifactDiffResolver: this._artifactDiffResolver,
1639
- generationOptions: {
1640
- model: this._options.model
1641
- }
1642
- });
1643
- log5("completed", {
1644
- messages
1645
- }, {
1646
- F: __dxlog_file6,
1647
- L: 175,
1648
- S: this,
1649
- C: (f, a) => f(...a)
1650
- });
1651
- options.onComplete?.(this._pending.value);
1652
- } catch (err) {
1653
- log5.catch(err, void 0, {
1654
- F: __dxlog_file6,
1655
- L: 178,
1656
- S: this,
1657
- C: (f, a) => f(...a)
1658
- });
1659
- if (err instanceof Error && err.message.includes("Overloaded")) {
1660
- this.error.value = new AiServiceOverloadedError("AI service overloaded", {
1661
- cause: err
1662
- });
1663
- } else {
1664
- this.error.value = new Error("AI service error", {
1665
- cause: err
1666
- });
1667
- }
1668
- } finally {
1669
- this._session = void 0;
1670
- }
1671
- return this._reset();
1672
- }
1673
- /**
1674
- * Cancel pending requests.
1675
- * @returns Pending requests (incl. the request message).
1676
- */
1677
- async cancel() {
1678
- log5.info("cancelling...", void 0, {
1679
- F: __dxlog_file6,
1680
- L: 196,
1681
- S: this,
1682
- C: (f, a) => f(...a)
1683
- });
1684
- this._session?.abort();
1685
- return this._reset();
1686
- }
1687
- async _reset() {
1688
- const messages = this._pending.value;
1689
- batch(() => {
1690
- this._pending.value = [];
1691
- this._block.value = void 0;
1692
- });
1693
- return messages;
1694
- }
1695
- };
1696
- var AiServiceOverloadedError = class extends Error {
1697
- constructor() {
1698
- super(...arguments);
1699
- this.code = "AI_SERVICE_OVERLOADED";
1700
- }
1701
- };
1702
-
1703
- // packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx
1704
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1705
- import { useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
1706
- import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/ai";
1707
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability, useIntentDispatcher } from "@dxos/app-framework";
1708
- import { createSystemPrompt } from "@dxos/artifact";
1709
- import { FunctionType as FunctionType2 } from "@dxos/functions";
1710
- import { log as log6 } from "@dxos/log";
1711
- import { useConfig } from "@dxos/react-client";
1712
- import { Filter as Filter3, fullyQualifiedId, useQuery as useQuery2 } from "@dxos/react-client/echo";
1713
- import { isNonNullable as isNonNullable3 } from "@dxos/util";
1714
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
1715
- var useChatProcessor = ({
1716
- chat,
1717
- space,
1718
- settings,
1719
- // part = 'deck',
1720
- part,
1721
- associatedArtifact
1722
- }) => {
1723
- var _effect = _useSignals7();
1724
- try {
1725
- const aiClient = useCapability(AssistantCapabilities.AiClient);
1726
- const globalTools = useCapabilities2(Capabilities2.Tools);
1727
- const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
1728
- const { dispatchPromise: dispatch } = useIntentDispatcher();
1729
- const services = useQuery2(space, Filter3.type(ServiceType));
1730
- const [serviceTools, setServiceTools] = useState4([]);
1731
- useEffect3(() => {
1732
- log6("creating service tools...", void 0, {
1733
- F: __dxlog_file7,
1734
- L: 49,
1735
- S: void 0,
1736
- C: (f, a) => f(...a)
1737
- });
1738
- queueMicrotask(async () => {
1739
- const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
1740
- setServiceTools(tools2.flat());
1741
- });
1742
- }, [
1743
- services
1744
- ]);
1745
- const config = useConfig();
1746
- const functions = useQuery2(space, Filter3.type(FunctionType2));
1747
- const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
1748
- chat
1749
- ]);
1750
- const [tools, extensions] = useMemo3(() => {
1751
- log6("creating tools...", void 0, {
1752
- F: __dxlog_file7,
1753
- L: 61,
1754
- S: void 0,
1755
- C: (f, a) => f(...a)
1756
- });
1757
- const tools2 = [
1758
- ...globalTools.flat(),
1759
- ...serviceTools,
1760
- ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable3)
1761
- ];
1762
- const extensions2 = {
1763
- space,
1764
- dispatch,
1765
- pivotId: chatId,
1766
- part
1767
- };
1768
- return [
1769
- tools2,
1770
- extensions2
1771
- ];
1772
- }, [
1773
- dispatch,
1774
- globalTools,
1775
- space,
1776
- chatId,
1777
- serviceTools,
1778
- functions
1779
- ]);
1780
- const systemPrompt = useMemo3(() => createSystemPrompt({
1781
- artifacts: artifactDefinitions.map((definition) => `${definition.name}
1782
- ${definition.instructions}`),
1783
- associatedArtifact
1784
- }), [
1785
- artifactDefinitions,
1786
- associatedArtifact
1787
- ]);
1788
- const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
1789
- const processor = useMemo3(() => {
1790
- log6("creating processor...", {
1791
- settings
1792
- }, {
1793
- F: __dxlog_file7,
1794
- L: 92,
1795
- S: void 0,
1796
- C: (f, a) => f(...a)
1797
- });
1798
- return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
1799
- model,
1800
- systemPrompt
1801
- });
1802
- }, [
1803
- aiClient.value,
1804
- tools,
1805
- artifactDefinitions,
1806
- extensions,
1807
- model,
1808
- systemPrompt
1809
- ]);
1810
- return processor;
1811
- } finally {
1812
- _effect.f();
1813
- }
1814
- };
1815
-
1816
- // packages/plugins/plugin-assistant/src/hooks/useMessageQueue.ts
1817
- import { useMemo as useMemo4 } from "react";
1818
- import { createQueueDXN } from "@dxos/echo-schema";
1819
- import { getSpace, useQueue } from "@dxos/react-client/echo";
1820
- var useMessageQueue = (chat) => {
1821
- const space = getSpace(chat);
1822
- const queueDxn = useMemo4(() => {
1823
- const dxn = space && chat?.queue.dxn;
1824
- return dxn ? createQueueDXN(space.id, dxn.parts.at(-1)) : void 0;
1825
- }, [
1826
- space,
1827
- chat?.queue.dxn
1828
- ]);
1829
- return useQueue(queueDxn);
1830
- };
1831
-
1832
- // packages/plugins/plugin-assistant/src/hooks/useServices.ts
1833
- import { useEffect as useEffect4, useMemo as useMemo5, useState as useState5 } from "react";
1834
-
1835
- // packages/plugins/plugin-assistant/src/testing/test-blueprint.ts
1836
- import { ToolRegistry } from "@dxos/ai";
1837
- import { EXA_API_KEY } from "@dxos/ai/testing";
1838
- import { BlueprintParser, createExaTool, createGraphWriterTool, createLocalSearchTool } from "@dxos/assistant";
1839
- import { DataTypes } from "@dxos/schema";
1840
- import { isNonNullable as isNonNullable4 } from "@dxos/util";
1841
- var RESEARCH_BLUEPRINT_DEFINITION = {
1842
- steps: [
1843
- {
1844
- instructions: "Research information and entities related to the selected objects.",
1845
- tools: [
1846
- "search/web_search"
1847
- ]
1848
- },
1849
- {
1850
- instructions: "Based on your research find matching entires that are already in the graph. Do exaustive research.",
1851
- tools: [
1852
- "search/local_search"
1853
- ]
1854
- },
1855
- {
1856
- instructions: "Add researched data to the graph. Make connections to existing objects.",
1857
- tools: [
1858
- "search/local_search",
1859
- "graph/writer"
1860
- ]
1861
- }
1862
- ]
1863
- };
1864
- var RESEARCH_BLUEPRINT = BlueprintParser.create().parse(RESEARCH_BLUEPRINT_DEFINITION);
1865
-
1866
- // packages/plugins/plugin-assistant/src/testing/test-functions.ts
1867
- import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL3 } from "@dxos/ai";
1868
- import { createSystemPrompt as createSystemPrompt2 } from "@dxos/artifact";
1869
-
1870
- // packages/plugins/plugin-assistant/src/testing/test-services.ts
1871
- import { Obj } from "@dxos/echo";
1872
- var AMADEUS_AUTH = {
1873
- type: "oauth",
1874
- clientId: "BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG",
1875
- clientSecret: "n4qldSN7usvD57gm",
1876
- tokenUrl: "https://test.api.amadeus.com/v1/security/oauth2/token",
1877
- grantType: "client_credentials"
1878
- };
1879
- var VISUAL_CROSSING_CREDENTIALS = {
1880
- type: "api-key",
1881
- key: "FDPRVS953KB4GQQLD25GRT975",
1882
- placement: {
1883
- type: "query",
1884
- name: "key"
1885
- }
1886
- };
1887
- var TEST_SERVICES = [
1888
- Obj.make(ServiceType, {
1889
- serviceId: "amadeus.com/service/FlightSearch",
1890
- name: "Amadeus Flight Search",
1891
- description: "Search for local and international flights.",
1892
- category: "travel",
1893
- interfaces: [
1894
- {
1895
- kind: "api",
1896
- schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json",
1897
- authorization: AMADEUS_AUTH
1898
- }
1899
- ]
1900
- }),
1901
- Obj.make(ServiceType, {
1902
- serviceId: "amadeus.com/service/HotelSearch",
1903
- name: "Amadeus Hotel Search",
1904
- description: "Search for local and international hotels.",
1905
- category: "travel",
1906
- interfaces: [
1907
- {
1908
- kind: "api",
1909
- schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json",
1910
- authorization: AMADEUS_AUTH
1911
- }
1912
- ]
1913
- }),
1914
- Obj.make(ServiceType, {
1915
- serviceId: "visualcrossing.com/service/Weather",
1916
- name: "Visual Crossing Weather",
1917
- description: "Search for global weather forecasts.",
1918
- category: "weather",
1919
- interfaces: [
1920
- {
1921
- kind: "api",
1922
- schemaUrl: "https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json",
1923
- authorization: VISUAL_CROSSING_CREDENTIALS
1924
- }
1925
- ]
1926
- }),
1927
- // TODO(burdon): Needs auth.
1928
- Obj.make(ServiceType, {
1929
- serviceId: "abstractapi.com/service/GeoLocation",
1930
- name: "Abstract GeoLocation",
1931
- description: "Get the location of any IP address.",
1932
- category: "geolocation",
1933
- interfaces: [
1934
- {
1935
- kind: "api",
1936
- schemaUrl: "https://api.apis.guru/v2/specs/abstractapi.com/geolocation/1.0.0/openapi.json"
1937
- }
1938
- ]
1939
- }),
1940
- //
1941
- // Testing
1942
- //
1943
- ...Array.from({
1944
- length: 20
1945
- }, (_, i) => Obj.make(ServiceType, {
1946
- serviceId: `example.com/service/test-${i}`,
1947
- name: `Test ${i}`,
1948
- description: `Test ${i}`,
1949
- category: Object.keys(categoryIcons)[Math.floor(Math.random() * Object.keys(categoryIcons).length)],
1950
- interfaces: [
1951
- {
1952
- kind: "api",
1953
- schemaUrl: "https://petstore.swagger.io/v2/swagger.json"
1954
- }
1955
- ]
1956
- }))
1957
- ];
1958
-
1959
- // packages/plugins/plugin-assistant/src/hooks/useTextInputEvents.ts
1960
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1961
- import { useState as useState6, useCallback as useCallback2 } from "react";
1962
-
1963
- // packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts
1964
- import { useMemo as useMemo6 } from "react";
1965
- import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
1966
- import { Filter as Filter4, Obj as Obj2 } from "@dxos/echo";
1967
- var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
1968
- var useContextProvider = (space) => {
1969
- const artifactDefinitions = useCapabilities3(Capabilities3.ArtifactDefinition);
1970
- return useMemo6(() => {
1971
- if (!space) {
1972
- return void 0;
1973
- }
1974
- return {
1975
- query: async ({ query }) => {
1976
- const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
1977
- const { objects } = await space.db.query(Filter4.or(...artifactSchemas.map((schema) => Filter4.type(schema)))).run();
1978
- return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
1979
- uri: Obj2.getDXN(object).toString(),
1980
- label: Obj2.getLabel(object) ?? ""
1981
- }));
1982
- },
1983
- resolveMetadata: async ({ uri }) => {
1984
- const object = await space.db.query(Filter4.ids(uri)).first();
1985
- return {
1986
- uri,
1987
- label: Obj2.getLabel(object) ?? ""
1988
- };
1989
- }
1990
- };
1991
- }, [
1992
- space,
1993
- artifactDefinitions
1994
- ]);
1995
- };
1996
-
1997
- // packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx
1998
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
1999
- var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, onOpenChange, ...props }) => {
2000
- var _effect = _useSignals9();
2001
- try {
2002
- const space = getSpace2(chat);
2003
- const contextProvider = useContextProvider(space);
2004
- const processor = useChatProcessor({
2005
- chat,
2006
- space,
2007
- settings,
2008
- part,
2009
- associatedArtifact
2010
- });
2011
- const messageQueue = useMessageQueue(chat);
2012
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
2013
- const messages = [
2014
- ...messageQueue?.objects ?? [],
2015
- ...processor.messages.value
2016
- ];
2017
- useEffect5(() => {
2018
- if (!processor.streaming.value && messageQueue?.objects) {
2019
- const message = messageQueue.objects[messageQueue.objects.length - 1];
2020
- if (space && chat && message && dispatch && associatedArtifact) {
2021
- void dispatch(createIntent(CollaborationActions.InsertContent, {
2022
- target: associatedArtifact,
2023
- object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [
2024
- ...chat.queue.dxn.parts,
2025
- message.id
2026
- ])),
2027
- label: "View proposal"
2028
- }));
2029
- }
2030
- }
2031
- }, [
2032
- messageQueue,
2033
- associatedArtifact,
2034
- processor.streaming.value
2035
- ]);
2036
- const handleSubmit = useCallback3((text) => {
2037
- if (processor.streaming.value) {
2038
- log7.warn("ignoring submit; still processing.", void 0, {
2039
- F: __dxlog_file8,
2040
- L: 64,
2041
- S: void 0,
2042
- C: (f, a) => f(...a)
2043
- });
2044
- return false;
2045
- }
2046
- onOpenChange?.(true);
2047
- invariant4(messageQueue, void 0, {
2048
- F: __dxlog_file8,
2049
- L: 70,
2050
- S: void 0,
2051
- A: [
2052
- "messageQueue",
2053
- ""
2054
- ]
2055
- });
2056
- void processor.request(text, {
2057
- history: messageQueue.objects,
2058
- onComplete: (messages2) => {
2059
- void messageQueue.append(messages2);
2060
- }
2061
- });
2062
- return true;
2063
- }, [
2064
- processor,
2065
- messageQueue,
2066
- onOpenChange
2067
- ]);
2068
- const handleCancel = useCallback3(() => {
2069
- if (processor.streaming.value) {
2070
- void processor.cancel();
2071
- }
2072
- }, [
2073
- processor
2074
- ]);
2075
- return /* @__PURE__ */ React7.createElement(Thread, {
2076
- classNames,
2077
- space,
2078
- messages,
2079
- processing: processor.streaming.value,
2080
- error: processor.error.value,
2081
- tools: processor.tools,
2082
- contextProvider,
2083
- onSubmit: handleSubmit,
2084
- onCancel: handleCancel,
2085
- onPrompt: handleSubmit,
2086
- onOpenChange,
2087
- ...props
2088
- });
2089
- } finally {
2090
- _effect.f();
2091
- }
2092
- };
2093
-
2094
- export {
2095
- Prompt,
2096
- PromptBar,
2097
- Toolbox,
2098
- ToolboxContainer,
2099
- Thread,
2100
- ThreadContainer
2101
- };
2102
- //# sourceMappingURL=chunk-OD574YIU.mjs.map