@dxos/plugin-assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (295) hide show
  1. package/dist/lib/browser/AssistantDialog-K6POM23O.mjs +46 -0
  2. package/dist/lib/browser/AssistantDialog-K6POM23O.mjs.map +7 -0
  3. package/dist/lib/browser/ChatContainer-QTO4LE2C.mjs +39 -0
  4. package/dist/lib/{node-esm/ChatContainer-FAYGNMQW.mjs.map → browser/ChatContainer-QTO4LE2C.mjs.map} +1 -1
  5. package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs +28 -0
  6. package/dist/lib/{node-esm/TemplateContainer-3LEBT5ZC.mjs.map → browser/TemplateContainer-AKUYL4AV.mjs.map} +1 -1
  7. package/dist/lib/browser/{ai-client-5PRCXI7N.mjs → ai-client-COXVUC6V.mjs} +4 -4
  8. package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +7 -0
  9. package/dist/lib/browser/{app-graph-builder-HTK3HFGM.mjs → app-graph-builder-YH4EGNBC.mjs} +45 -28
  10. package/dist/lib/browser/app-graph-builder-YH4EGNBC.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-TXJWGWJ7.mjs → chunk-3F44MBHU.mjs} +3 -3
  12. package/dist/lib/browser/chunk-3F44MBHU.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-IHEBFO5O.mjs +205 -0
  14. package/dist/lib/browser/chunk-IHEBFO5O.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-JQFUME3B.mjs +87 -0
  16. package/dist/lib/{node-esm/chunk-PBZA7XJR.mjs.map → browser/chunk-JQFUME3B.mjs.map} +1 -1
  17. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +96 -0
  18. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-OWZHLWW5.mjs → chunk-QTW7KVDO.mjs} +1595 -1452
  20. package/dist/lib/browser/chunk-QTW7KVDO.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-USJBRB3H.mjs +155 -0
  22. package/dist/lib/browser/chunk-USJBRB3H.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-3HCI5FIL.mjs → chunk-XOZ7YMO3.mjs} +3 -3
  24. package/dist/lib/browser/{chunk-3HCI5FIL.mjs.map → chunk-XOZ7YMO3.mjs.map} +1 -1
  25. package/dist/lib/browser/index.mjs +24 -10
  26. package/dist/lib/browser/index.mjs.map +3 -3
  27. package/dist/lib/browser/{intent-resolver-QV5AAVJZ.mjs → intent-resolver-63EAHENI.mjs} +6 -5
  28. package/dist/lib/browser/intent-resolver-63EAHENI.mjs.map +7 -0
  29. package/dist/lib/browser/meta.json +1 -1
  30. package/dist/lib/browser/react-surface-XCV6NR75.mjs +131 -0
  31. package/dist/lib/browser/react-surface-XCV6NR75.mjs.map +7 -0
  32. package/dist/lib/browser/{settings-OZX7J65A.mjs → settings-SHNQ4XXP.mjs} +3 -3
  33. package/dist/lib/browser/types/index.mjs +4 -2
  34. package/dist/lib/node/AssistantDialog-FDATKYE5.cjs +72 -0
  35. package/dist/lib/node/AssistantDialog-FDATKYE5.cjs.map +7 -0
  36. package/dist/lib/node/{ChatContainer-WVAAOEOH.cjs → ChatContainer-5CLHJOIQ.cjs} +25 -19
  37. package/dist/lib/node/{ChatContainer-WVAAOEOH.cjs.map → ChatContainer-5CLHJOIQ.cjs.map} +1 -1
  38. package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs → TemplateContainer-CTG2MB4W.cjs} +18 -12
  39. package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs.map → TemplateContainer-CTG2MB4W.cjs.map} +1 -1
  40. package/dist/lib/node/{ai-client-OUPSRQT7.cjs → ai-client-R2CGEYZW.cjs} +12 -12
  41. package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +7 -0
  42. package/dist/lib/node/{app-graph-builder-LEO63CZZ.cjs → app-graph-builder-PSHIOW3Q.cjs} +62 -46
  43. package/dist/lib/node/app-graph-builder-PSHIOW3Q.cjs.map +7 -0
  44. package/dist/lib/node/{chunk-XI2ARIEO.cjs → chunk-4EEWTDQK.cjs} +45 -39
  45. package/dist/lib/node/{chunk-XI2ARIEO.cjs.map → chunk-4EEWTDQK.cjs.map} +1 -1
  46. package/dist/lib/node/chunk-FLJWJ35M.cjs +181 -0
  47. package/dist/lib/node/chunk-FLJWJ35M.cjs.map +7 -0
  48. package/dist/lib/node/{chunk-OOHFSPWR.cjs → chunk-H4A42LNR.cjs} +1126 -983
  49. package/dist/lib/node/chunk-H4A42LNR.cjs.map +7 -0
  50. package/dist/lib/node/chunk-HRNIUYVQ.cjs +128 -0
  51. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +7 -0
  52. package/dist/lib/node/{chunk-Q5XWEMHB.cjs → chunk-P74TWGMG.cjs} +6 -6
  53. package/dist/lib/node/{chunk-Q5XWEMHB.cjs.map → chunk-P74TWGMG.cjs.map} +1 -1
  54. package/dist/lib/node/chunk-RXPA2C2A.cjs +230 -0
  55. package/dist/lib/node/chunk-RXPA2C2A.cjs.map +7 -0
  56. package/dist/lib/node/{chunk-GBUNQ257.cjs → chunk-TS3H5OSX.cjs} +7 -7
  57. package/dist/lib/node/chunk-TS3H5OSX.cjs.map +7 -0
  58. package/dist/lib/node/index.cjs +72 -59
  59. package/dist/lib/node/index.cjs.map +3 -3
  60. package/dist/lib/node/{intent-resolver-QDGZMWLY.cjs → intent-resolver-66F7WLW6.cjs} +13 -12
  61. package/dist/lib/node/intent-resolver-66F7WLW6.cjs.map +7 -0
  62. package/dist/lib/node/meta.json +1 -1
  63. package/dist/lib/node/react-surface-TASAPRPQ.cjs +145 -0
  64. package/dist/lib/node/react-surface-TASAPRPQ.cjs.map +7 -0
  65. package/dist/lib/node/{settings-WLTC7XO5.cjs → settings-ERKLO6IO.cjs} +8 -8
  66. package/dist/lib/node/types/index.cjs +16 -14
  67. package/dist/lib/node/types/index.cjs.map +2 -2
  68. package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs +47 -0
  69. package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs.map +7 -0
  70. package/dist/lib/node-esm/ChatContainer-QTC5NYE2.mjs +40 -0
  71. package/dist/lib/{browser/ChatContainer-ZNKENYKZ.mjs.map → node-esm/ChatContainer-QTC5NYE2.mjs.map} +1 -1
  72. package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs +29 -0
  73. package/dist/lib/{browser/TemplateContainer-WKU5XFSO.mjs.map → node-esm/TemplateContainer-IVDQ4XQG.mjs.map} +1 -1
  74. package/dist/lib/node-esm/{ai-client-RZQWEDUX.mjs → ai-client-I5LXHMOZ.mjs} +4 -4
  75. package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +7 -0
  76. package/dist/lib/node-esm/{app-graph-builder-WXJNZDYB.mjs → app-graph-builder-Z3GMMJMD.mjs} +45 -28
  77. package/dist/lib/node-esm/app-graph-builder-Z3GMMJMD.mjs.map +7 -0
  78. package/dist/lib/node-esm/{chunk-ECRK6TUQ.mjs → chunk-BB2TAT4P.mjs} +3 -3
  79. package/dist/lib/node-esm/{chunk-ECRK6TUQ.mjs.map → chunk-BB2TAT4P.mjs.map} +1 -1
  80. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +98 -0
  81. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +7 -0
  82. package/dist/lib/node-esm/{chunk-6JK5HEUQ.mjs → chunk-HLPGKJ7N.mjs} +3 -3
  83. package/dist/lib/node-esm/chunk-HLPGKJ7N.mjs.map +7 -0
  84. package/dist/lib/node-esm/{chunk-PBZA7XJR.mjs → chunk-OYN6HLXZ.mjs} +42 -36
  85. package/dist/lib/{browser/chunk-NFUHCW2J.mjs.map → node-esm/chunk-OYN6HLXZ.mjs.map} +1 -1
  86. package/dist/lib/node-esm/chunk-QU626JMR.mjs +156 -0
  87. package/dist/lib/node-esm/chunk-QU626JMR.mjs.map +7 -0
  88. package/dist/lib/node-esm/{chunk-ED55ZE4G.mjs → chunk-SI5LOQEO.mjs} +1595 -1452
  89. package/dist/lib/node-esm/chunk-SI5LOQEO.mjs.map +7 -0
  90. package/dist/lib/node-esm/chunk-ZKBACPIW.mjs +206 -0
  91. package/dist/lib/node-esm/chunk-ZKBACPIW.mjs.map +7 -0
  92. package/dist/lib/node-esm/index.mjs +24 -10
  93. package/dist/lib/node-esm/index.mjs.map +3 -3
  94. package/dist/lib/node-esm/{intent-resolver-Q3I6S6HN.mjs → intent-resolver-X3PWH7KM.mjs} +6 -5
  95. package/dist/lib/node-esm/intent-resolver-X3PWH7KM.mjs.map +7 -0
  96. package/dist/lib/node-esm/meta.json +1 -1
  97. package/dist/lib/node-esm/react-surface-QMIQCXUM.mjs +132 -0
  98. package/dist/lib/node-esm/react-surface-QMIQCXUM.mjs.map +7 -0
  99. package/dist/lib/node-esm/{settings-CLE57WEP.mjs → settings-IVQRZUCU.mjs} +3 -3
  100. package/dist/lib/node-esm/types/index.mjs +4 -2
  101. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  102. package/dist/types/src/capabilities/ai-client.d.ts +1 -1
  103. package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
  104. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  105. package/dist/types/src/capabilities/capabilities.d.ts +1 -1
  106. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  107. package/dist/types/src/capabilities/index.d.ts +1 -1
  108. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  109. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  110. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  111. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +3 -1
  112. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -1
  113. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +8 -0
  114. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +1 -0
  115. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +8 -0
  116. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +1 -0
  117. package/dist/types/src/components/BlueprintEditor/index.d.ts +2 -0
  118. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +1 -0
  119. package/dist/types/src/components/Prompt/Prompt.d.ts +5 -2
  120. package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -1
  121. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +6 -3
  122. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -1
  123. package/dist/types/src/components/Prompt/PromptBar.d.ts +9 -4
  124. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -1
  125. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +9 -0
  126. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +1 -0
  127. package/dist/types/src/components/Prompt/autocomplete.d.ts +5 -1
  128. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -1
  129. package/dist/types/src/components/Thread/Thread.d.ts +2 -2
  130. package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
  131. package/dist/types/src/components/Thread/ThreadContainer.d.ts +1 -1
  132. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
  133. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +2 -2
  134. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
  135. package/dist/types/src/components/Thread/ThreadMessage.d.ts +4 -2
  136. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
  137. package/dist/types/src/components/Thread/ToolInvocations.d.ts +1 -1
  138. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -1
  139. package/dist/types/src/components/Thread/reducer.d.ts +1 -1
  140. package/dist/types/src/components/Thread/reducer.d.ts.map +1 -1
  141. package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -1
  142. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  143. package/dist/types/src/components/index.d.ts +2 -0
  144. package/dist/types/src/components/index.d.ts.map +1 -1
  145. package/dist/types/src/experimental/transcription/index.d.ts +1 -0
  146. package/dist/types/src/experimental/transcription/index.d.ts.map +1 -0
  147. package/dist/types/src/hooks/processor.d.ts +6 -5
  148. package/dist/types/src/hooks/processor.d.ts.map +1 -1
  149. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  150. package/dist/types/src/hooks/useMessageQueue.d.ts +11 -7
  151. package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
  152. package/dist/types/src/parser/filter-generator.d.ts +4 -0
  153. package/dist/types/src/parser/filter-generator.d.ts.map +1 -0
  154. package/dist/types/src/parser/filter-generator.test.d.ts +2 -0
  155. package/dist/types/src/parser/filter-generator.test.d.ts.map +1 -0
  156. package/dist/types/src/parser/index.d.ts +4 -0
  157. package/dist/types/src/parser/index.d.ts.map +1 -0
  158. package/dist/types/src/parser/query-parser.d.ts +15 -0
  159. package/dist/types/src/parser/query-parser.d.ts.map +1 -0
  160. package/dist/types/src/parser/query-parser.test.d.ts +2 -0
  161. package/dist/types/src/parser/query-parser.test.d.ts.map +1 -0
  162. package/dist/types/src/parser/types.d.ts +24 -0
  163. package/dist/types/src/parser/types.d.ts.map +1 -0
  164. package/dist/types/src/stories/Prompt.stories.d.ts +8 -0
  165. package/dist/types/src/stories/Prompt.stories.d.ts.map +1 -0
  166. package/dist/types/src/stories/Query.stories.d.ts +19 -0
  167. package/dist/types/src/stories/Query.stories.d.ts.map +1 -0
  168. package/dist/types/src/stories/Research.stories.d.ts +15 -0
  169. package/dist/types/src/stories/Research.stories.d.ts.map +1 -0
  170. package/dist/types/src/stories/test-data.d.ts +3 -0
  171. package/dist/types/src/stories/test-data.d.ts.map +1 -0
  172. package/dist/types/src/stories/testing.d.ts +12 -0
  173. package/dist/types/src/stories/testing.d.ts.map +1 -0
  174. package/dist/types/src/testing/blueprint.d.ts +7 -0
  175. package/dist/types/src/testing/blueprint.d.ts.map +1 -0
  176. package/dist/types/src/testing/index.d.ts +1 -0
  177. package/dist/types/src/testing/index.d.ts.map +1 -1
  178. package/dist/types/src/testing/test-functions.d.ts +1 -1
  179. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  180. package/dist/types/src/tools/function.d.ts +4 -4
  181. package/dist/types/src/tools/function.d.ts.map +1 -1
  182. package/dist/types/src/tools/openapi.d.ts +3 -3
  183. package/dist/types/src/tools/openapi.d.ts.map +1 -1
  184. package/dist/types/src/translations.d.ts +63 -6
  185. package/dist/types/src/translations.d.ts.map +1 -1
  186. package/dist/types/src/types/chat.d.ts +18 -8
  187. package/dist/types/src/types/chat.d.ts.map +1 -1
  188. package/dist/types/src/types/types.d.ts +6 -3
  189. package/dist/types/src/types/types.d.ts.map +1 -1
  190. package/package.json +73 -61
  191. package/src/AssistantPlugin.tsx +5 -4
  192. package/src/capabilities/ai-client.ts +1 -1
  193. package/src/capabilities/app-graph-builder.ts +34 -24
  194. package/src/capabilities/capabilities.ts +1 -1
  195. package/src/capabilities/intent-resolver.ts +3 -2
  196. package/src/capabilities/react-surface.tsx +58 -13
  197. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -1
  198. package/src/components/AmbientDialog/AmbientDialog.tsx +27 -13
  199. package/src/components/AssistantDialog.tsx +1 -1
  200. package/src/components/AssistantSettings/AssistantSettings.tsx +1 -1
  201. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +32 -0
  202. package/src/components/BlueprintEditor/BlueprintEditor.tsx +41 -0
  203. package/src/components/BlueprintEditor/index.ts +5 -0
  204. package/src/components/Prompt/Prompt.stories.tsx +59 -52
  205. package/src/components/Prompt/Prompt.tsx +24 -10
  206. package/src/components/Prompt/PromptBar.stories.tsx +68 -0
  207. package/src/components/Prompt/PromptBar.tsx +82 -80
  208. package/src/components/Prompt/autocomplete.ts +14 -8
  209. package/src/components/Prompt/references.ts +3 -3
  210. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
  211. package/src/components/TemplateEditor/TemplateForm.stories.tsx +1 -1
  212. package/src/components/Thread/Thread.stories.tsx +2 -2
  213. package/src/components/Thread/Thread.tsx +2 -2
  214. package/src/components/Thread/ThreadContainer.stories.tsx +77 -47
  215. package/src/components/Thread/ThreadContainer.tsx +8 -9
  216. package/src/components/Thread/ThreadMessage.tsx +43 -8
  217. package/src/components/Thread/ToolInvocations.tsx +9 -7
  218. package/src/components/Thread/reducer.ts +1 -1
  219. package/src/components/Toolbox/Toolbox.stories.tsx +1 -1
  220. package/src/components/Toolbox/Toolbox.tsx +2 -1
  221. package/src/components/index.ts +2 -0
  222. package/src/experimental/transcription/index.ts +3 -0
  223. package/src/hooks/processor.ts +65 -27
  224. package/src/hooks/useChatProcessor.tsx +4 -4
  225. package/src/hooks/useContextProvider.ts +6 -6
  226. package/src/hooks/useMessageQueue.ts +4 -4
  227. package/src/meta.ts +2 -2
  228. package/src/parser/filter-generator.test.ts +32 -0
  229. package/src/parser/filter-generator.ts +81 -0
  230. package/src/parser/index.ts +7 -0
  231. package/src/parser/query-parser.test.ts +139 -0
  232. package/src/parser/query-parser.ts +199 -0
  233. package/src/parser/types.ts +34 -0
  234. package/src/shims.d.ts +8 -0
  235. package/src/stories/Prompt.stories.tsx +59 -0
  236. package/src/stories/Query.stories.tsx +448 -0
  237. package/src/stories/Research.stories.tsx +495 -0
  238. package/src/stories/test-data.ts +128 -0
  239. package/src/stories/testing.ts +64 -0
  240. package/src/testing/blueprint.ts +47 -0
  241. package/src/testing/index.ts +1 -0
  242. package/src/testing/test-functions.ts +1 -1
  243. package/src/tools/function.ts +8 -7
  244. package/src/tools/openapi.test.ts +18 -19
  245. package/src/tools/openapi.ts +20 -14
  246. package/src/translations.ts +4 -2
  247. package/src/types/chat.ts +27 -4
  248. package/src/types/types.ts +3 -1
  249. package/dist/lib/browser/AssistantDialog-DTWVEQBB.mjs +0 -117
  250. package/dist/lib/browser/AssistantDialog-DTWVEQBB.mjs.map +0 -7
  251. package/dist/lib/browser/ChatContainer-ZNKENYKZ.mjs +0 -33
  252. package/dist/lib/browser/TemplateContainer-WKU5XFSO.mjs +0 -22
  253. package/dist/lib/browser/ai-client-5PRCXI7N.mjs.map +0 -7
  254. package/dist/lib/browser/app-graph-builder-HTK3HFGM.mjs.map +0 -7
  255. package/dist/lib/browser/chunk-5P7U35RJ.mjs +0 -192
  256. package/dist/lib/browser/chunk-5P7U35RJ.mjs.map +0 -7
  257. package/dist/lib/browser/chunk-7VDZP5WX.mjs +0 -143
  258. package/dist/lib/browser/chunk-7VDZP5WX.mjs.map +0 -7
  259. package/dist/lib/browser/chunk-NFUHCW2J.mjs +0 -81
  260. package/dist/lib/browser/chunk-OWZHLWW5.mjs.map +0 -7
  261. package/dist/lib/browser/chunk-TXJWGWJ7.mjs.map +0 -7
  262. package/dist/lib/browser/intent-resolver-QV5AAVJZ.mjs.map +0 -7
  263. package/dist/lib/browser/react-surface-JJPYWEIN.mjs +0 -90
  264. package/dist/lib/browser/react-surface-JJPYWEIN.mjs.map +0 -7
  265. package/dist/lib/node/AssistantDialog-RJJHZI63.cjs +0 -141
  266. package/dist/lib/node/AssistantDialog-RJJHZI63.cjs.map +0 -7
  267. package/dist/lib/node/ai-client-OUPSRQT7.cjs.map +0 -7
  268. package/dist/lib/node/app-graph-builder-LEO63CZZ.cjs.map +0 -7
  269. package/dist/lib/node/chunk-GBUNQ257.cjs.map +0 -7
  270. package/dist/lib/node/chunk-GQ3XS5FZ.cjs +0 -169
  271. package/dist/lib/node/chunk-GQ3XS5FZ.cjs.map +0 -7
  272. package/dist/lib/node/chunk-OOHFSPWR.cjs.map +0 -7
  273. package/dist/lib/node/chunk-VG2UQY4S.cjs +0 -216
  274. package/dist/lib/node/chunk-VG2UQY4S.cjs.map +0 -7
  275. package/dist/lib/node/intent-resolver-QDGZMWLY.cjs.map +0 -7
  276. package/dist/lib/node/react-surface-XNEIJJYJ.cjs +0 -106
  277. package/dist/lib/node/react-surface-XNEIJJYJ.cjs.map +0 -7
  278. package/dist/lib/node-esm/AssistantDialog-D33WZUGR.mjs +0 -118
  279. package/dist/lib/node-esm/AssistantDialog-D33WZUGR.mjs.map +0 -7
  280. package/dist/lib/node-esm/ChatContainer-FAYGNMQW.mjs +0 -34
  281. package/dist/lib/node-esm/TemplateContainer-3LEBT5ZC.mjs +0 -23
  282. package/dist/lib/node-esm/ai-client-RZQWEDUX.mjs.map +0 -7
  283. package/dist/lib/node-esm/app-graph-builder-WXJNZDYB.mjs.map +0 -7
  284. package/dist/lib/node-esm/chunk-6JK5HEUQ.mjs.map +0 -7
  285. package/dist/lib/node-esm/chunk-74GFINWJ.mjs +0 -144
  286. package/dist/lib/node-esm/chunk-74GFINWJ.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-ED55ZE4G.mjs.map +0 -7
  288. package/dist/lib/node-esm/chunk-UZWYXNR5.mjs +0 -193
  289. package/dist/lib/node-esm/chunk-UZWYXNR5.mjs.map +0 -7
  290. package/dist/lib/node-esm/intent-resolver-Q3I6S6HN.mjs.map +0 -7
  291. package/dist/lib/node-esm/react-surface-RI3JONQY.mjs +0 -91
  292. package/dist/lib/node-esm/react-surface-RI3JONQY.mjs.map +0 -7
  293. /package/dist/lib/browser/{settings-OZX7J65A.mjs.map → settings-SHNQ4XXP.mjs.map} +0 -0
  294. /package/dist/lib/node/{settings-WLTC7XO5.cjs.map → settings-ERKLO6IO.cjs.map} +0 -0
  295. /package/dist/lib/node-esm/{settings-CLE57WEP.mjs.map → settings-IVQRZUCU.mjs.map} +0 -0
@@ -26,11 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_OOHFSPWR_exports = {};
30
- __export(chunk_OOHFSPWR_exports, {
29
+ var chunk_H4A42LNR_exports = {};
30
+ __export(chunk_H4A42LNR_exports, {
31
31
  AiClient: () => AiClient,
32
32
  AppGraphBuilder: () => AppGraphBuilder,
33
33
  IntentResolver: () => IntentResolver,
34
+ Prompt: () => Prompt,
35
+ PromptBar: () => PromptBar,
34
36
  ReactSurface: () => ReactSurface,
35
37
  Settings: () => Settings,
36
38
  Thread: () => Thread,
@@ -38,98 +40,515 @@ __export(chunk_OOHFSPWR_exports, {
38
40
  Toolbox: () => Toolbox,
39
41
  ToolboxContainer: () => ToolboxContainer
40
42
  });
41
- module.exports = __toCommonJS(chunk_OOHFSPWR_exports);
42
- var import_chunk_GBUNQ257 = require("./chunk-GBUNQ257.cjs");
43
- var import_chunk_VG2UQY4S = require("./chunk-VG2UQY4S.cjs");
44
- var import_chunk_Q5XWEMHB = require("./chunk-Q5XWEMHB.cjs");
43
+ module.exports = __toCommonJS(chunk_H4A42LNR_exports);
44
+ var import_chunk_TS3H5OSX = require("./chunk-TS3H5OSX.cjs");
45
+ var import_chunk_RXPA2C2A = require("./chunk-RXPA2C2A.cjs");
46
+ var import_chunk_P74TWGMG = require("./chunk-P74TWGMG.cjs");
47
+ var import_tracking = require("@preact-signals/safe-react/tracking");
48
+ var import_state = require("@codemirror/state");
45
49
  var import_react = __toESM(require("react"));
50
+ var import_react_ui = require("@dxos/react-ui");
51
+ var import_react_ui_editor = require("@dxos/react-ui-editor");
52
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
53
+ var import_util = require("@dxos/util");
54
+ var import_state2 = require("@codemirror/state");
55
+ var import_view = require("@codemirror/view");
56
+ var import_autocomplete = require("@codemirror/autocomplete");
57
+ var import_state3 = require("@codemirror/state");
58
+ var import_view2 = require("@codemirror/view");
59
+ var import_async = require("@dxos/async");
60
+ var import_tracking2 = require("@preact-signals/safe-react/tracking");
61
+ var import_react2 = __toESM(require("react"));
62
+ var import_plugin_transcription = require("@dxos/plugin-transcription");
63
+ var import_react_ui2 = require("@dxos/react-ui");
64
+ var import_react_ui_sfx = require("@dxos/react-ui-sfx");
65
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
66
+ var import_tracking3 = require("@preact-signals/safe-react/tracking");
67
+ var import_react3 = __toESM(require("react"));
68
+ var import_ai = require("@dxos/ai");
46
69
  var import_app_framework = require("@dxos/app-framework");
47
- var import_artifact = require("@dxos/artifact");
48
70
  var import_functions = require("@dxos/functions");
49
71
  var import_log = require("@dxos/log");
50
72
  var import_echo = require("@dxos/react-client/echo");
51
- var import_react_ui_theme = require("@dxos/react-ui-theme");
52
- var import_artifact2 = require("@dxos/artifact");
73
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
74
+ var import_ai2 = require("@dxos/ai");
53
75
  var import_echo_schema = require("@dxos/echo-schema");
54
76
  var import_functions2 = require("@dxos/functions");
55
77
  var import_log2 = require("@dxos/log");
56
78
  var import_echo2 = require("@dxos/react-client/echo");
57
79
  var import_effect = require("effect");
58
80
  var import_jsonpointer = __toESM(require("jsonpointer"));
59
- var import_artifact3 = require("@dxos/artifact");
81
+ var import_ai3 = require("@dxos/ai");
60
82
  var import_echo_schema2 = require("@dxos/echo-schema");
61
83
  var import_invariant = require("@dxos/invariant");
62
84
  var import_log3 = require("@dxos/log");
63
- var import_util = require("@dxos/util");
64
- var import_react2 = __toESM(require("react"));
85
+ var import_util2 = require("@dxos/util");
86
+ var import_tracking4 = require("@preact-signals/safe-react/tracking");
87
+ var import_react4 = __toESM(require("react"));
65
88
  var import_halo = require("@dxos/react-client/halo");
66
89
  var import_react_ui_components = require("@dxos/react-ui-components");
67
- var import_react_ui_theme2 = require("@dxos/react-ui-theme");
68
- var import_util2 = require("@dxos/util");
69
- var import_react3 = __toESM(require("react"));
90
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
91
+ var import_util3 = require("@dxos/util");
92
+ var import_tracking5 = require("@preact-signals/safe-react/tracking");
93
+ var import_react5 = __toESM(require("react"));
94
+ var import_app_framework2 = require("@dxos/app-framework");
70
95
  var import_invariant2 = require("@dxos/invariant");
71
- var import_react_ui = require("@dxos/react-ui");
96
+ var import_react_ui3 = require("@dxos/react-ui");
72
97
  var import_react_ui_components2 = require("@dxos/react-ui-components");
73
98
  var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
74
- var import_react_ui_theme3 = require("@dxos/react-ui-theme");
75
- var import_util3 = require("@dxos/util");
76
- var import_react4 = __toESM(require("react"));
99
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
100
+ var import_util4 = require("@dxos/util");
101
+ var import_tracking6 = require("@preact-signals/safe-react/tracking");
102
+ var import_react6 = __toESM(require("react"));
77
103
  var import_log4 = require("@dxos/log");
78
104
  var import_react_ui_components3 = require("@dxos/react-ui-components");
79
105
  var import_react_ui_syntax_highlighter2 = require("@dxos/react-ui-syntax-highlighter");
80
- var import_util4 = require("@dxos/util");
81
- var import_state = require("@codemirror/state");
82
- var import_react5 = __toESM(require("react"));
83
- var import_react_ui2 = require("@dxos/react-ui");
84
- var import_react_ui_editor = require("@dxos/react-ui-editor");
85
- var import_react_ui_theme4 = require("@dxos/react-ui-theme");
86
- var import_state2 = require("@codemirror/state");
87
- var import_view = require("@codemirror/view");
88
- var import_autocomplete = require("@codemirror/autocomplete");
89
- var import_state3 = require("@codemirror/state");
90
- var import_view2 = require("@codemirror/view");
91
- var import_async = require("@dxos/async");
92
- var import_react6 = __toESM(require("react"));
93
- var import_plugin_transcription = require("@dxos/plugin-transcription");
94
- var import_react_ui3 = require("@dxos/react-ui");
95
- var import_react_ui_sfx = require("@dxos/react-ui-sfx");
96
- var import_react_ui_theme5 = require("@dxos/react-ui-theme");
106
+ var import_util5 = require("@dxos/util");
107
+ var import_tracking7 = require("@preact-signals/safe-react/tracking");
97
108
  var import_react7 = __toESM(require("react"));
98
- var import_app_framework2 = require("@dxos/app-framework");
109
+ var import_app_framework3 = require("@dxos/app-framework");
99
110
  var import_invariant3 = require("@dxos/invariant");
100
111
  var import_keys = require("@dxos/keys");
101
112
  var import_live_object = require("@dxos/live-object");
102
113
  var import_log5 = require("@dxos/log");
103
114
  var import_echo3 = require("@dxos/react-client/echo");
104
115
  var import_signals_core = require("@preact/signals-core");
116
+ var import_ai4 = require("@dxos/ai");
105
117
  var import_assistant = require("@dxos/assistant");
106
118
  var import_invariant4 = require("@dxos/invariant");
107
119
  var import_log6 = require("@dxos/log");
108
120
  var import_echo4 = require("@dxos/react-client/echo");
121
+ var import_tracking8 = require("@preact-signals/safe-react/tracking");
109
122
  var import_react8 = require("react");
110
- var import_app_framework3 = require("@dxos/app-framework");
111
- var import_artifact4 = require("@dxos/artifact");
112
- var import_assistant2 = require("@dxos/assistant");
123
+ var import_ai5 = require("@dxos/ai");
124
+ var import_app_framework4 = require("@dxos/app-framework");
125
+ var import_artifact = require("@dxos/artifact");
113
126
  var import_functions3 = require("@dxos/functions");
114
127
  var import_log7 = require("@dxos/log");
115
128
  var import_react_client = require("@dxos/react-client");
116
129
  var import_echo5 = require("@dxos/react-client/echo");
117
- var import_util5 = require("@dxos/util");
118
- var import_app_framework4 = require("@dxos/app-framework");
130
+ var import_util6 = require("@dxos/util");
131
+ var import_app_framework5 = require("@dxos/app-framework");
119
132
  var import_react9 = require("react");
120
133
  var import_echo_schema3 = require("@dxos/echo-schema");
121
134
  var import_echo6 = require("@dxos/react-client/echo");
122
135
  var import_react10 = require("react");
123
- var import_artifact5 = require("@dxos/artifact");
124
- var import_assistant3 = require("@dxos/assistant");
136
+ var import_testing = require("@dxos/ai/testing");
137
+ var import_assistant2 = require("@dxos/assistant");
138
+ var import_schema = require("@dxos/schema");
139
+ var import_util7 = require("@dxos/util");
140
+ var import_ai6 = require("@dxos/ai");
141
+ var import_artifact2 = require("@dxos/artifact");
125
142
  var import_echo_schema4 = require("@dxos/echo-schema");
143
+ var import_tracking9 = require("@preact-signals/safe-react/tracking");
126
144
  var import_react11 = require("react");
127
145
  var import_react12 = require("react");
128
- var import_app_framework5 = require("@dxos/app-framework");
146
+ var import_app_framework6 = require("@dxos/app-framework");
129
147
  var import_echo7 = require("@dxos/client/echo");
130
148
  var import_echo8 = require("@dxos/echo");
131
149
  var import_echo_schema5 = require("@dxos/echo-schema");
132
150
  var import_log8 = require("@dxos/log");
151
+ var autocompleteExtension = ({ onSubmit, onSuggest, onCancel }) => {
152
+ const suggest = import_view.ViewPlugin.fromClass(class {
153
+ constructor(view) {
154
+ this._currentSuggestion = null;
155
+ this._decorations = this.computeDecorations(view);
156
+ }
157
+ update(update) {
158
+ if (update.docChanged || update.selectionSet) {
159
+ this._decorations = this.computeDecorations(update.view);
160
+ }
161
+ }
162
+ computeDecorations(view) {
163
+ const text = view.state.doc.toString();
164
+ const suggestions = onSuggest?.(text) ?? [];
165
+ if (!suggestions.length) {
166
+ this._currentSuggestion = null;
167
+ return import_view.Decoration.none;
168
+ }
169
+ this._currentSuggestion = suggestions[0];
170
+ const suffix = this._currentSuggestion.slice(text.length);
171
+ if (!suffix) {
172
+ return import_view.Decoration.none;
173
+ }
174
+ return import_view.Decoration.set([
175
+ import_view.Decoration.widget({
176
+ widget: new InlineSuggestionWidget(suffix),
177
+ side: 1
178
+ }).range(view.state.doc.length)
179
+ ]);
180
+ }
181
+ completeSuggestion(view) {
182
+ if (!this._currentSuggestion) {
183
+ return false;
184
+ }
185
+ const text = view.state.doc.toString();
186
+ const suffix = this._currentSuggestion.slice(text.length);
187
+ if (!suffix) {
188
+ return false;
189
+ }
190
+ view.dispatch({
191
+ changes: {
192
+ from: view.state.doc.length,
193
+ insert: suffix
194
+ },
195
+ selection: {
196
+ anchor: view.state.doc.length + suffix.length
197
+ }
198
+ });
199
+ return true;
200
+ }
201
+ }, {
202
+ decorations: (v) => v._decorations
203
+ });
204
+ return [
205
+ suggest,
206
+ import_view.EditorView.theme({
207
+ ".cm-inline-suggestion": {
208
+ opacity: 0.4
209
+ }
210
+ }),
211
+ import_state2.Prec.highest(import_view.keymap.of([
212
+ {
213
+ key: "Tab",
214
+ preventDefault: true,
215
+ run: (view) => {
216
+ const plugin = view.plugin(suggest);
217
+ return plugin?.completeSuggestion(view) ?? false;
218
+ }
219
+ },
220
+ {
221
+ key: "ArrowRight",
222
+ preventDefault: true,
223
+ run: (view) => {
224
+ if (view.state.selection.main.head !== view.state.doc.length) {
225
+ return false;
226
+ }
227
+ const plugin = view.plugin(suggest);
228
+ return plugin?.completeSuggestion(view) ?? false;
229
+ }
230
+ },
231
+ {
232
+ key: "Enter",
233
+ preventDefault: true,
234
+ run: (view) => {
235
+ const text = view.state.doc.toString().trim();
236
+ if (text.length > 0 && onSubmit) {
237
+ const reset = onSubmit(text);
238
+ if (reset) {
239
+ view.dispatch({
240
+ changes: {
241
+ from: 0,
242
+ to: view.state.doc.length,
243
+ insert: ""
244
+ }
245
+ });
246
+ }
247
+ }
248
+ return true;
249
+ }
250
+ },
251
+ {
252
+ key: "Shift-Enter",
253
+ preventDefault: true,
254
+ run: (view) => {
255
+ view.dispatch({
256
+ changes: {
257
+ from: view.state.selection.main.head,
258
+ insert: "\n"
259
+ },
260
+ selection: {
261
+ anchor: view.state.selection.main.head + 1,
262
+ head: view.state.selection.main.head + 1
263
+ }
264
+ });
265
+ return true;
266
+ }
267
+ },
268
+ {
269
+ key: "Escape",
270
+ preventDefault: true,
271
+ run: (view) => {
272
+ view.dispatch({
273
+ changes: {
274
+ from: 0,
275
+ to: view.state.doc.length,
276
+ insert: ""
277
+ }
278
+ });
279
+ onCancel?.();
280
+ return true;
281
+ }
282
+ }
283
+ ]))
284
+ ];
285
+ };
286
+ var InlineSuggestionWidget = class extends import_view.WidgetType {
287
+ constructor(suffix) {
288
+ super(), this.suffix = suffix;
289
+ }
290
+ toDOM() {
291
+ const span = document.createElement("span");
292
+ span.textContent = this.suffix;
293
+ span.className = "cm-inline-suggestion";
294
+ return span;
295
+ }
296
+ eq(other) {
297
+ return other.suffix === this.suffix;
298
+ }
299
+ };
300
+ var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
301
+ if (triggerCharacter.length !== 1) {
302
+ throw new Error("triggerCharacter must be a single character");
303
+ }
304
+ const decorationField = import_view2.ViewPlugin.fromClass(class ReferenceView {
305
+ constructor(view) {
306
+ this._mutex = new import_async.Mutex();
307
+ this.decorations = import_view2.Decoration.set([]);
308
+ queueMicrotask(async () => {
309
+ const guard = await this._mutex.acquire();
310
+ try {
311
+ this.decorations = await this._computeDecorations(view);
312
+ } finally {
313
+ guard.release();
314
+ }
315
+ });
316
+ }
317
+ update(update) {
318
+ if (update.docChanged) {
319
+ queueMicrotask(async () => {
320
+ const guard = await this._mutex.acquire();
321
+ try {
322
+ this.decorations = await this._computeDecorations(update.view);
323
+ } finally {
324
+ guard.release();
325
+ }
326
+ });
327
+ }
328
+ }
329
+ async _computeDecorations(view) {
330
+ const text = view.state.doc.toString();
331
+ const references = text.matchAll(new RegExp(`${triggerCharacter}[a-zA-Z0-9@:]+\\s`, "g"));
332
+ const decorations = [];
333
+ for (const match of references) {
334
+ const reference = match[0];
335
+ const uri = reference.slice(1, -1);
336
+ const data = await provider.resolveReference({
337
+ uri
338
+ });
339
+ if (data) {
340
+ decorations.push(import_view2.Decoration.replace({
341
+ widget: new ReferenceWidget(data)
342
+ }).range(match.index, match.index + reference.length));
343
+ }
344
+ }
345
+ return import_view2.Decoration.set(decorations);
346
+ }
347
+ }, {
348
+ decorations: (v) => v.decorations,
349
+ provide: (plugin) => [
350
+ import_view2.EditorView.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? import_state3.RangeSet.empty)
351
+ ]
352
+ });
353
+ return [
354
+ decorationField,
355
+ import_view2.EditorView.theme({
356
+ ".cm-reference-pill": {
357
+ borderRadius: "0.25rem",
358
+ borderWidth: "1px",
359
+ marginRight: "0.25rem",
360
+ marginLeft: "0.25rem"
361
+ }
362
+ }),
363
+ (0, import_autocomplete.autocompletion)({
364
+ activateOnTyping: true,
365
+ override: [
366
+ async (context) => {
367
+ const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
368
+ if (!match || match?.to === match?.from) {
369
+ return null;
370
+ }
371
+ const query = match.text.slice(1);
372
+ const references = await provider.getReferences({
373
+ query
374
+ });
375
+ return {
376
+ from: match.from,
377
+ filter: false,
378
+ options: references.map((reference) => ({
379
+ label: reference.label,
380
+ apply: `${triggerCharacter}${reference.uri} `
381
+ }))
382
+ };
383
+ }
384
+ ],
385
+ closeOnBlur: !debug,
386
+ tooltipClass: () => "shadow rounded",
387
+ aboveCursor: true
388
+ }),
389
+ import_view2.keymap.of(import_autocomplete.completionKeymap)
390
+ ];
391
+ };
392
+ var ReferenceWidget = class extends import_view2.WidgetType {
393
+ constructor(data) {
394
+ super(), this.data = data;
395
+ }
396
+ toDOM() {
397
+ const span = document.createElement("span");
398
+ span.textContent = `@ ${this.data.label}`;
399
+ span.className = "cm-reference-pill";
400
+ return span;
401
+ }
402
+ eq(other) {
403
+ return other.data.uri === this.data.uri;
404
+ }
405
+ ignoreEvent() {
406
+ return true;
407
+ }
408
+ };
409
+ var Prompt = /* @__PURE__ */ (0, import_react.forwardRef)(({ classNames, extensions, references, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onCancel, onOpenChange }, forwardRef3) => {
410
+ var _effect = (0, import_tracking.useSignals)();
411
+ try {
412
+ const { themeMode } = (0, import_react_ui.useThemeContext)();
413
+ const { parentRef, view } = (0, import_react_ui_editor.useTextEditor)({
414
+ debug: true,
415
+ autoFocus,
416
+ extensions: [
417
+ autocompleteExtension({
418
+ onSubmit,
419
+ onSuggest,
420
+ onCancel
421
+ }),
422
+ (0, import_react_ui_editor.createBasicExtensions)({
423
+ bracketMatching: false,
424
+ lineWrapping,
425
+ placeholder
426
+ }),
427
+ (0, import_react_ui_editor.createThemeExtensions)({
428
+ themeMode
429
+ }),
430
+ references ? promptReferences({
431
+ provider: references
432
+ }) : [],
433
+ import_state.Prec.highest(import_react_ui_editor.keymap.of([
434
+ {
435
+ key: "cmd-ArrowUp",
436
+ preventDefault: true,
437
+ run: () => {
438
+ onOpenChange?.(true);
439
+ return true;
440
+ }
441
+ },
442
+ {
443
+ key: "cmd-ArrowDown",
444
+ preventDefault: true,
445
+ run: () => {
446
+ onOpenChange?.(false);
447
+ return true;
448
+ }
449
+ }
450
+ ])),
451
+ extensions
452
+ ].filter(import_util.isNonNullable)
453
+ }, [
454
+ themeMode,
455
+ extensions,
456
+ onSubmit,
457
+ onSuggest
458
+ ]);
459
+ (0, import_react.useImperativeHandle)(forwardRef3, () => {
460
+ return {
461
+ focus: () => {
462
+ view?.focus();
463
+ },
464
+ setText: (text) => {
465
+ view?.dispatch({
466
+ changes: {
467
+ from: 0,
468
+ to: view.state.doc.length,
469
+ insert: text
470
+ },
471
+ selection: {
472
+ anchor: text.length,
473
+ head: text.length
474
+ }
475
+ });
476
+ }
477
+ };
478
+ }, [
479
+ view,
480
+ onSubmit
481
+ ]);
482
+ return /* @__PURE__ */ import_react.default.createElement("div", {
483
+ ref: parentRef,
484
+ className: (0, import_react_ui_theme.mx)("w-full", classNames)
485
+ });
486
+ } finally {
487
+ _effect.f();
488
+ }
489
+ });
490
+ var PromptBar = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, placeholder, processing, error, microphone, references, onCancel, ...props }, forwardedRef) => {
491
+ var _effect = (0, import_tracking2.useSignals)();
492
+ try {
493
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_P74TWGMG.ASSISTANT_PLUGIN);
494
+ const promptRef = (0, import_react_ui2.useForwardedRef)(forwardedRef);
495
+ const [active, setActive] = (0, import_react2.useState)(false);
496
+ const { recording } = (0, import_plugin_transcription.useVoiceInput)({
497
+ active,
498
+ onUpdate: (text) => {
499
+ promptRef.current?.setText(text);
500
+ promptRef.current?.focus();
501
+ }
502
+ });
503
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
504
+ className: (0, import_react_ui_theme2.mx)("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
505
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
506
+ className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
507
+ }, error && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Tooltip.Trigger, {
508
+ content: error.message,
509
+ delayDuration: 0
510
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Icon, {
511
+ icon: "ph--warning-circle--regular",
512
+ classNames: import_react_ui_theme2.errorText,
513
+ size: 5
514
+ })) || /* @__PURE__ */ import_react2.default.createElement(import_react_ui_sfx.Spinner, {
515
+ active: processing
516
+ })), /* @__PURE__ */ import_react2.default.createElement(Prompt, {
517
+ ref: promptRef,
518
+ autoFocus: true,
519
+ classNames: "pbs-2",
520
+ lineWrapping: true,
521
+ placeholder: placeholder ?? t("prompt placeholder"),
522
+ references,
523
+ onCancel,
524
+ ...props
525
+ }), (onCancel || microphone) && /* @__PURE__ */ import_react2.default.createElement("div", {
526
+ className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
527
+ }, processing && onCancel && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.IconButton, {
528
+ classNames: "px-1.5",
529
+ variant: "ghost",
530
+ size: 5,
531
+ icon: "ph--x--regular",
532
+ iconOnly: true,
533
+ label: t("cancel processing button"),
534
+ onClick: onCancel
535
+ }), !processing && microphone && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.IconButton, {
536
+ classNames: (0, import_react_ui_theme2.mx)("px-1.5", recording && "bg-primary-500"),
537
+ variant: "ghost",
538
+ size: 5,
539
+ icon: "ph--microphone--regular",
540
+ iconOnly: true,
541
+ noTooltip: true,
542
+ label: t("microphone button"),
543
+ onMouseDown: () => setActive(true),
544
+ onMouseUp: () => setActive(false),
545
+ onTouchStart: () => setActive(true),
546
+ onTouchEnd: () => setActive(false)
547
+ })));
548
+ } finally {
549
+ _effect.f();
550
+ }
551
+ });
133
552
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
134
553
  var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
135
554
  if (!fn.description || !fn.inputSchema) {
@@ -142,7 +561,7 @@ var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
142
561
  const url = (0, import_functions2.getInvocationUrl)(existingFunctionUrl, edgeUrl, {
143
562
  spaceId
144
563
  });
145
- return (0, import_artifact2.defineTool)("user-function", {
564
+ return (0, import_ai2.createTool)("user-function", {
146
565
  name: fn.name,
147
566
  description: fn.description,
148
567
  schema: (0, import_echo_schema.toEffectSchema)(fn.inputSchema),
@@ -164,7 +583,7 @@ var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
164
583
  },
165
584
  body: JSON.stringify(input)
166
585
  });
167
- return import_artifact2.ToolResult.Success(await response.text());
586
+ return import_ai2.ToolResult.Success(await response.text());
168
587
  }
169
588
  });
170
589
  };
@@ -209,7 +628,7 @@ var createToolsFromApi = async (url, options) => {
209
628
  spec
210
629
  }, {
211
630
  F: __dxlog_file2,
212
- L: 33,
631
+ L: 36,
213
632
  S: void 0,
214
633
  C: (f, a) => f(...a)
215
634
  });
@@ -227,7 +646,7 @@ var createToolsFromApi = async (url, options) => {
227
646
  methodItem
228
647
  }, {
229
648
  F: __dxlog_file2,
230
- L: 45,
649
+ L: 47,
231
650
  S: void 0,
232
651
  C: (f, a) => f(...a)
233
652
  });
@@ -245,7 +664,7 @@ var createToolsFromApi = async (url, options) => {
245
664
  parameter
246
665
  }, {
247
666
  F: __dxlog_file2,
248
- L: 60,
667
+ L: 63,
249
668
  S: void 0,
250
669
  C: (f, a) => f(...a)
251
670
  });
@@ -268,7 +687,7 @@ var createToolsFromApi = async (url, options) => {
268
687
  inputSchema
269
688
  }, {
270
689
  F: __dxlog_file2,
271
- L: 85,
690
+ L: 88,
272
691
  S: void 0,
273
692
  C: (f, a) => f(...a)
274
693
  });
@@ -280,7 +699,7 @@ var createToolsFromApi = async (url, options) => {
280
699
  method
281
700
  }, {
282
701
  F: __dxlog_file2,
283
- L: 90,
702
+ L: 93,
284
703
  S: void 0,
285
704
  C: (f, a) => f(...a)
286
705
  });
@@ -293,17 +712,20 @@ var createToolsFromApi = async (url, options) => {
293
712
  parameters: endpointParameters,
294
713
  authorization: options?.authorization
295
714
  };
296
- tools.push({
297
- name: getToolName(path, method, methodItem),
298
- description: options?.instructions ? `${options.instructions}
715
+ tools.push(
716
+ // TODO(burdon): Namespace?
717
+ (0, import_ai3.createRawTool)("openapi", {
718
+ name: getToolName(path, method, methodItem),
719
+ description: options?.instructions ? `${options.instructions}
299
720
 
300
721
  ${description}` : description,
301
- parameters: inputSchema,
302
- execute: async (input) => {
303
- const response = await callApiEndpoint(endpoint, input);
304
- return import_artifact3.ToolResult.Success(response);
305
- }
306
- });
722
+ parameters: inputSchema,
723
+ execute: async (input) => {
724
+ const response = await callApiEndpoint(endpoint, input);
725
+ return import_ai3.ToolResult.Success(response);
726
+ }
727
+ })
728
+ );
307
729
  }
308
730
  }
309
731
  return tools;
@@ -356,7 +778,7 @@ var callApiEndpoint = async (endpoint, input) => {
356
778
  input
357
779
  }, {
358
780
  F: __dxlog_file2,
359
- L: 174,
781
+ L: 180,
360
782
  S: void 0,
361
783
  C: (f, a) => f(...a)
362
784
  });
@@ -415,7 +837,7 @@ var callApiEndpoint = async (endpoint, input) => {
415
837
  request
416
838
  }, {
417
839
  F: __dxlog_file2,
418
- L: 237,
840
+ L: 243,
419
841
  S: void 0,
420
842
  C: (f, a) => f(...a)
421
843
  });
@@ -426,7 +848,7 @@ var callApiEndpoint = async (endpoint, input) => {
426
848
  statusText: response.statusText
427
849
  }, {
428
850
  F: __dxlog_file2,
429
- L: 240,
851
+ L: 246,
430
852
  S: void 0,
431
853
  C: (f, a) => f(...a)
432
854
  });
@@ -450,7 +872,7 @@ var callApiEndpoint = async (endpoint, input) => {
450
872
  error
451
873
  }, {
452
874
  F: __dxlog_file2,
453
- L: 258,
875
+ L: 264,
454
876
  S: void 0,
455
877
  C: (f, a) => f(...a)
456
878
  });
@@ -461,7 +883,7 @@ var callApiEndpoint = async (endpoint, input) => {
461
883
  error
462
884
  }, {
463
885
  F: __dxlog_file2,
464
- L: 262,
886
+ L: 268,
465
887
  S: void 0,
466
888
  C: (f, a) => f(...a)
467
889
  });
@@ -476,7 +898,7 @@ var getEndpointUrl = (endpoint) => {
476
898
  } else {
477
899
  (0, import_invariant.invariant)(!isV3_1(endpoint.document), void 0, {
478
900
  F: __dxlog_file2,
479
- L: 273,
901
+ L: 279,
480
902
  S: void 0,
481
903
  A: [
482
904
  "!isV3_1(endpoint.document)",
@@ -496,7 +918,7 @@ var resolveAuthorization = async (authorization) => {
496
918
  case "api-key": {
497
919
  (0, import_invariant.invariant)(authorization.placement.type === "authorization-header", void 0, {
498
920
  F: __dxlog_file2,
499
- L: 289,
921
+ L: 295,
500
922
  S: void 0,
501
923
  A: [
502
924
  "authorization.placement.type === 'authorization-header'",
@@ -522,7 +944,7 @@ var resolveAuthorization = async (authorization) => {
522
944
  }
523
945
  };
524
946
  var resolveJsonSchema = (schema, base) => {
525
- return (0, import_util.deepMapValues)(schema, (value, recurse) => {
947
+ return (0, import_util2.deepMapValues)(schema, (value, recurse) => {
526
948
  if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
527
949
  if (value.$ref.startsWith("#")) {
528
950
  const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
@@ -534,7 +956,7 @@ var resolveJsonSchema = (schema, base) => {
534
956
  base
535
957
  }, {
536
958
  F: __dxlog_file2,
537
- L: 322,
959
+ L: 328,
538
960
  S: void 0,
539
961
  C: (f, a) => f(...a)
540
962
  });
@@ -549,91 +971,106 @@ var isV3_1 = (document2) => {
549
971
  };
550
972
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
551
973
  var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
552
- return /* @__PURE__ */ import_react.default.createElement("div", {
553
- className: (0, import_react_ui_theme.mx)("flex flex-col overflow-y-auto box-content", classNames)
554
- }, artifacts && artifacts.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
555
- title: "Artifacts",
556
- items: artifacts.map(({ name, description, tools }) => ({
557
- name,
558
- description,
559
- subitems: tools.map(({ name: name2, description: description2 }) => ({
560
- name: `\u2219 ${(0, import_artifact.parseToolName)(name2)}`,
561
- description: description2
974
+ var _effect = (0, import_tracking3.useSignals)();
975
+ try {
976
+ return /* @__PURE__ */ import_react3.default.createElement("div", {
977
+ className: (0, import_react_ui_theme3.mx)("flex flex-col overflow-y-auto box-content", classNames)
978
+ }, artifacts && artifacts.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
979
+ title: "Artifacts",
980
+ items: artifacts.map(({ name, description, tools }) => ({
981
+ name,
982
+ description,
983
+ subitems: tools.map(({ name: name2, description: description2 }) => ({
984
+ name: `\u2219 ${(0, import_ai.parseToolName)(name2)}`,
985
+ description: description2
986
+ }))
987
+ }))
988
+ }), services && services.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
989
+ title: "Services",
990
+ items: services.map(({ service: { serviceId, name, description }, tools }) => ({
991
+ name: name ?? serviceId,
992
+ description,
993
+ subitems: tools.map(({ name: name2, description: description2 }) => ({
994
+ name: `\u2219 ${name2}`,
995
+ description: description2
996
+ }))
562
997
  }))
563
- }))
564
- }), services && services.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
565
- title: "Services",
566
- items: services.map(({ service: { serviceId, name, description }, tools }) => ({
567
- name: name ?? serviceId,
568
- description,
569
- subitems: tools.map(({ name: name2, description: description2 }) => ({
570
- name: `\u2219 ${name2}`,
571
- description: description2
998
+ }), functions && functions.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
999
+ title: "Functions",
1000
+ items: functions.map(({ name, description }) => ({
1001
+ name,
1002
+ description
572
1003
  }))
573
- }))
574
- }), functions && functions.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
575
- title: "Functions",
576
- items: functions.map(({ name, description }) => ({
577
- name,
578
- description
579
- }))
580
- }));
1004
+ }));
1005
+ } finally {
1006
+ _effect.f();
1007
+ }
581
1008
  };
582
1009
  var Section = ({ title, items, striped }) => {
583
- const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
584
- const gridClassNames = "grid grid-cols-[8rem_1fr]";
585
- const subGridClassNames = (0, import_react_ui_theme.mx)("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
586
- return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h1", {
587
- className: "px-2 text-sm"
588
- }, title), /* @__PURE__ */ import_react.default.createElement("div", {
589
- className: gridClassNames
590
- }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, {
591
- key: i
592
- }, name && /* @__PURE__ */ import_react.default.createElement("div", {
593
- className: subGridClassNames
594
- }, /* @__PURE__ */ import_react.default.createElement("div", {
595
- className: "truncate text-primary-500"
596
- }, name), /* @__PURE__ */ import_react.default.createElement("div", {
597
- className: "line-clamp-2"
598
- }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ import_react.default.createElement("div", {
599
- key: i2,
600
- className: (0, import_react_ui_theme.mx)(subGridClassNames, striped && stripeClassNames)
601
- }, /* @__PURE__ */ import_react.default.createElement("div", {
602
- className: "truncate"
603
- }, name2), /* @__PURE__ */ import_react.default.createElement("div", {
604
- className: "line-clamp-3 text-subdued"
605
- }, description2)))))));
1010
+ var _effect = (0, import_tracking3.useSignals)();
1011
+ try {
1012
+ const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1013
+ const gridClassNames = "grid grid-cols-[8rem_1fr]";
1014
+ const subGridClassNames = (0, import_react_ui_theme3.mx)("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
1015
+ return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement("h1", {
1016
+ className: "px-2 text-sm"
1017
+ }, title), /* @__PURE__ */ import_react3.default.createElement("div", {
1018
+ className: gridClassNames
1019
+ }, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ import_react3.default.createElement(import_react3.Fragment, {
1020
+ key: i
1021
+ }, name && /* @__PURE__ */ import_react3.default.createElement("div", {
1022
+ className: subGridClassNames
1023
+ }, /* @__PURE__ */ import_react3.default.createElement("div", {
1024
+ className: "truncate text-primary-500"
1025
+ }, name), /* @__PURE__ */ import_react3.default.createElement("div", {
1026
+ className: "line-clamp-2"
1027
+ }, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ import_react3.default.createElement("div", {
1028
+ key: i2,
1029
+ className: (0, import_react_ui_theme3.mx)(subGridClassNames, striped && stripeClassNames)
1030
+ }, /* @__PURE__ */ import_react3.default.createElement("div", {
1031
+ className: "truncate"
1032
+ }, name2), /* @__PURE__ */ import_react3.default.createElement("div", {
1033
+ className: "line-clamp-3 text-subdued"
1034
+ }, description2)))))));
1035
+ } finally {
1036
+ _effect.f();
1037
+ }
606
1038
  };
607
1039
  var ToolboxContainer = ({ classNames, space }) => {
608
- const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
609
- const services = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_chunk_VG2UQY4S.ServiceType));
610
- const [serviceTools, setServiceTools] = (0, import_react.useState)([]);
611
- (0, import_react.useEffect)(() => {
612
- (0, import_log.log)("creating service tools...", {
613
- services: services.length
614
- }, {
615
- F: __dxlog_file3,
616
- L: 99,
617
- S: void 0,
618
- C: (f, a) => f(...a)
619
- });
620
- queueMicrotask(async () => {
621
- const tools = await Promise.all(services.map(async (service) => ({
622
- service,
623
- tools: await createToolsFromService(service)
624
- })));
625
- setServiceTools(tools);
1040
+ var _effect = (0, import_tracking3.useSignals)();
1041
+ try {
1042
+ const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
1043
+ const services = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_chunk_RXPA2C2A.ServiceType));
1044
+ const [serviceTools, setServiceTools] = (0, import_react3.useState)([]);
1045
+ (0, import_react3.useEffect)(() => {
1046
+ (0, import_log.log)("creating service tools...", {
1047
+ services: services.length
1048
+ }, {
1049
+ F: __dxlog_file3,
1050
+ L: 100,
1051
+ S: void 0,
1052
+ C: (f, a) => f(...a)
1053
+ });
1054
+ queueMicrotask(async () => {
1055
+ const tools = await Promise.all(services.map(async (service) => ({
1056
+ service,
1057
+ tools: await createToolsFromService(service)
1058
+ })));
1059
+ setServiceTools(tools);
1060
+ });
1061
+ }, [
1062
+ services
1063
+ ]);
1064
+ const functions = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_functions.FunctionType));
1065
+ return /* @__PURE__ */ import_react3.default.createElement(Toolbox, {
1066
+ classNames,
1067
+ artifacts: artifactDefinitions,
1068
+ services: serviceTools,
1069
+ functions
626
1070
  });
627
- }, [
628
- services
629
- ]);
630
- const functions = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_functions.FunctionType));
631
- return /* @__PURE__ */ import_react.default.createElement(Toolbox, {
632
- classNames,
633
- artifacts: artifactDefinitions,
634
- services: serviceTools,
635
- functions
636
- });
1071
+ } finally {
1072
+ _effect.f();
1073
+ }
637
1074
  };
638
1075
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
639
1076
  var isToolMessage = (message) => {
@@ -642,164 +1079,199 @@ var isToolMessage = (message) => {
642
1079
  var getToolName2 = (tool) => {
643
1080
  return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
644
1081
  };
645
- var getToolCaption = (tool) => {
1082
+ var getToolCaption = (tool, status) => {
646
1083
  if (!tool) {
647
1084
  return "Calling tool...";
648
1085
  }
649
- return tool.caption ?? `Calling ${getToolName2(tool)}...`;
1086
+ return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
650
1087
  };
651
1088
  var ToolBlock = ({ classNames, message, tools }) => {
652
- const { content = [] } = message;
653
- let request;
654
- const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
655
- const items = blocks.map((block) => {
656
- switch (block.type) {
657
- case "tool_use": {
658
- if (block.pending && request?.block.id === block.id) {
659
- return null;
660
- }
661
- request = {
662
- tool: tools?.find((tool) => tool.name === block.name),
663
- block
664
- };
665
- return {
666
- title: getToolCaption(request.tool),
667
- block
668
- };
669
- }
670
- case "tool_result": {
671
- if (!request) {
672
- import_log4.log.warn("unexpected message", {
673
- block
1089
+ var _effect = (0, import_tracking6.useSignals)();
1090
+ try {
1091
+ const { content = [] } = message;
1092
+ let request;
1093
+ const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
1094
+ const items = blocks.map((block) => {
1095
+ switch (block.type) {
1096
+ case "tool_use": {
1097
+ if (block.pending && request?.block.id === block.id) {
1098
+ return null;
1099
+ }
1100
+ import_log4.log.info("tool_use", {
1101
+ tool: request?.tool,
1102
+ status: block.currentStatus
674
1103
  }, {
675
1104
  F: __dxlog_file4,
676
- L: 52,
1105
+ L: 46,
677
1106
  S: void 0,
678
1107
  C: (f, a) => f(...a)
679
1108
  });
1109
+ request = {
1110
+ tool: tools?.find((tool) => tool.name === block.name),
1111
+ block
1112
+ };
1113
+ return {
1114
+ title: getToolCaption(request.tool, block.currentStatus),
1115
+ block
1116
+ };
1117
+ }
1118
+ case "tool_result": {
1119
+ if (!request) {
1120
+ import_log4.log.warn("unexpected message", {
1121
+ block
1122
+ }, {
1123
+ F: __dxlog_file4,
1124
+ L: 54,
1125
+ S: void 0,
1126
+ C: (f, a) => f(...a)
1127
+ });
1128
+ return {
1129
+ title: "Error",
1130
+ block
1131
+ };
1132
+ }
1133
+ return {
1134
+ title: `${getToolCaption(request.tool, void 0)} (Success)`,
1135
+ block
1136
+ };
1137
+ }
1138
+ default: {
1139
+ request = void 0;
680
1140
  return {
681
1141
  title: "Error",
682
1142
  block
683
1143
  };
684
1144
  }
685
- return {
686
- title: `${getToolCaption(request.tool)} (Success)`,
687
- block
688
- };
689
- }
690
- default: {
691
- request = void 0;
692
- return {
693
- title: "Error",
694
- block
695
- };
696
1145
  }
697
- }
698
- }).filter(import_util4.isNonNullable);
699
- return /* @__PURE__ */ import_react4.default.createElement(ToolContainer, {
700
- classNames,
701
- items
702
- });
1146
+ }).filter(import_util5.isNonNullable);
1147
+ return /* @__PURE__ */ import_react6.default.createElement(ToolContainer, {
1148
+ classNames,
1149
+ items
1150
+ });
1151
+ } finally {
1152
+ _effect.f();
1153
+ }
703
1154
  };
704
1155
  var ToolContainer = ({ classNames, items }) => {
705
- const tabsRef = (0, import_react4.useRef)(null);
706
- const [selected, setSelected] = (0, import_react4.useState)(0);
707
- const [open, setOpen] = (0, import_react4.useState)(false);
708
- (0, import_react4.useEffect)(() => {
709
- if (open) {
710
- tabsRef.current?.focus();
711
- }
712
- }, [
713
- open
714
- ]);
715
- const handleSelect = (index) => {
716
- if (index === selected) {
717
- setOpen(false);
718
- } else {
719
- setSelected(index);
720
- }
721
- };
722
- const title = (0, import_react4.useMemo)(() => {
723
- const lines = items.map((item) => item.title).filter(import_util4.isNotFalsy);
724
- return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.StatusRoll, {
725
- key: "status-roll",
726
- lines,
727
- duration: 1e3,
728
- autoAdvance: true
729
- });
730
- }, [
731
- items
732
- ]);
733
- return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.ToggleContainer, {
734
- classNames: [
735
- "flex flex-col",
736
- classNames
737
- ],
738
- title,
739
- open,
740
- onChangeOpen: setOpen
741
- }, /* @__PURE__ */ import_react4.default.createElement("div", {
742
- className: "grid grid-cols-[32px_1fr]"
743
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.NumericTabs, {
744
- ref: tabsRef,
745
- length: items.length,
746
- selected,
747
- onSelect: handleSelect
748
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_syntax_highlighter2.Json, {
749
- data: items[selected].block,
750
- classNames: "!p-1 text-xs"
751
- })));
1156
+ var _effect = (0, import_tracking6.useSignals)();
1157
+ try {
1158
+ const tabsRef = (0, import_react6.useRef)(null);
1159
+ const [selected, setSelected] = (0, import_react6.useState)(0);
1160
+ const [open, setOpen] = (0, import_react6.useState)(false);
1161
+ (0, import_react6.useEffect)(() => {
1162
+ if (open) {
1163
+ tabsRef.current?.focus();
1164
+ }
1165
+ }, [
1166
+ open
1167
+ ]);
1168
+ const handleSelect = (index) => {
1169
+ if (index === selected) {
1170
+ setOpen(false);
1171
+ } else {
1172
+ setSelected(index);
1173
+ }
1174
+ };
1175
+ const title = (0, import_react6.useMemo)(() => {
1176
+ const lines = items.map((item) => item.title).filter(import_util5.isNotFalsy);
1177
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.StatusRoll, {
1178
+ key: "status-roll",
1179
+ lines,
1180
+ duration: 1e3,
1181
+ autoAdvance: true
1182
+ });
1183
+ }, [
1184
+ items
1185
+ ]);
1186
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.ToggleContainer, {
1187
+ classNames: [
1188
+ "flex flex-col",
1189
+ classNames
1190
+ ],
1191
+ title,
1192
+ open,
1193
+ onChangeOpen: setOpen
1194
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
1195
+ className: "grid grid-cols-[32px_1fr]"
1196
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.NumericTabs, {
1197
+ ref: tabsRef,
1198
+ length: items.length,
1199
+ selected,
1200
+ onSelect: handleSelect
1201
+ }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_syntax_highlighter2.Json, {
1202
+ data: items[selected].block,
1203
+ classNames: "!p-1 text-xs"
1204
+ })));
1205
+ } finally {
1206
+ _effect.f();
1207
+ }
752
1208
  };
753
1209
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
754
- var panelClassNames = "flex flex-col w-full px-2 bg-groupSurface rounded-md";
1210
+ var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-md";
755
1211
  var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
756
1212
  var ToggleContainer2 = (props) => {
757
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.ToggleContainer, {
758
- ...props,
759
- classNames: (0, import_react_ui_theme3.mx)(panelClassNames, props.classNames)
760
- });
1213
+ var _effect = (0, import_tracking5.useSignals)();
1214
+ try {
1215
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.ToggleContainer, {
1216
+ ...props,
1217
+ classNames: (0, import_react_ui_theme5.mx)(panelClassNames, props.classNames)
1218
+ });
1219
+ } finally {
1220
+ _effect.f();
1221
+ }
761
1222
  };
762
1223
  var MessageContainer = ({ children, classNames, user }) => {
763
- if (!children) {
764
- return null;
1224
+ var _effect = (0, import_tracking5.useSignals)();
1225
+ try {
1226
+ if (!children) {
1227
+ return null;
1228
+ }
1229
+ return /* @__PURE__ */ import_react5.default.createElement("div", {
1230
+ role: "list-item",
1231
+ className: (0, import_react_ui_theme5.mx)("flex w-full", user && "justify-end", classNames)
1232
+ }, /* @__PURE__ */ import_react5.default.createElement("div", {
1233
+ className: (0, import_react_ui_theme5.mx)(user ? [
1234
+ "px-2 py-1 rounded-md",
1235
+ userClassNames
1236
+ ] : "w-full")
1237
+ }, children));
1238
+ } finally {
1239
+ _effect.f();
765
1240
  }
766
- return /* @__PURE__ */ import_react3.default.createElement("div", {
767
- role: "list-item",
768
- className: (0, import_react_ui_theme3.mx)("flex w-full", user && "justify-end", classNames)
769
- }, /* @__PURE__ */ import_react3.default.createElement("div", {
770
- className: (0, import_react_ui_theme3.mx)(user ? [
771
- "px-2 py-1 rounded-md",
772
- userClassNames
773
- ] : "w-full")
774
- }, children));
775
1241
  };
776
- var ThreadMessage = ({ classNames, space, message, tools, onPrompt }) => {
777
- const { role, content = [] } = message;
778
- if (isToolMessage(message)) {
779
- return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
780
- classNames: (0, import_react_ui_theme3.mx)(classNames, "animate-[fadeIn_0.5s]")
781
- }, /* @__PURE__ */ import_react3.default.createElement(ToolBlock, {
782
- space,
783
- classNames: panelClassNames,
784
- message,
785
- tools
786
- }));
787
- }
788
- return content.map((block, idx) => {
789
- if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
790
- return null;
1242
+ var ThreadMessage = ({ classNames, space, message, tools, onPrompt, onAddToGraph }) => {
1243
+ var _effect = (0, import_tracking5.useSignals)();
1244
+ try {
1245
+ const { role, content = [] } = message;
1246
+ if (isToolMessage(message)) {
1247
+ return /* @__PURE__ */ import_react5.default.createElement(MessageContainer, {
1248
+ classNames: (0, import_react_ui_theme5.mx)(classNames, "animate-[fadeIn_0.5s]")
1249
+ }, /* @__PURE__ */ import_react5.default.createElement(ToolBlock, {
1250
+ space,
1251
+ classNames: panelClassNames,
1252
+ message,
1253
+ tools
1254
+ }));
791
1255
  }
792
- const Component = components[block.type] ?? components.default;
793
- return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
794
- key: idx,
795
- classNames: (0, import_react_ui_theme3.mx)(classNames, "animate-[fadeIn_0.5s]"),
796
- user: block.type === "text" && role === "user"
797
- }, /* @__PURE__ */ import_react3.default.createElement(Component, {
798
- space,
799
- block,
800
- onPrompt
801
- }));
802
- });
1256
+ return content.map((block, idx) => {
1257
+ if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1258
+ return null;
1259
+ }
1260
+ const Component = components[block.type] ?? components.default;
1261
+ return /* @__PURE__ */ import_react5.default.createElement(MessageContainer, {
1262
+ key: idx,
1263
+ classNames: (0, import_react_ui_theme5.mx)(classNames, "animate-[fadeIn_0.5s]"),
1264
+ user: block.type === "text" && role === "user"
1265
+ }, /* @__PURE__ */ import_react5.default.createElement(Component, {
1266
+ space,
1267
+ block,
1268
+ onPrompt,
1269
+ onAddToGraph
1270
+ }));
1271
+ });
1272
+ } finally {
1273
+ _effect.f();
1274
+ }
803
1275
  };
804
1276
  var components = {
805
1277
  //
@@ -808,7 +1280,7 @@ var components = {
808
1280
  ["text"]: ({ block }) => {
809
1281
  (0, import_invariant2.invariant)(block.type === "text", void 0, {
810
1282
  F: __dxlog_file5,
811
- L: 90,
1283
+ L: 105,
812
1284
  S: void 0,
813
1285
  A: [
814
1286
  "block.type === 'text'",
@@ -817,21 +1289,21 @@ var components = {
817
1289
  });
818
1290
  const title = block.disposition ? titles[block.disposition] : void 0;
819
1291
  if (!title) {
820
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.MarkdownViewer, {
1292
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
821
1293
  classNames: "[&>p]:animate-[fadeIn_0.5s]",
822
1294
  content: block.text
823
1295
  });
824
1296
  }
825
- return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
1297
+ return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
826
1298
  // open={open}
827
1299
  defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
828
1300
  title,
829
- icon: block.pending ? /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Icon, {
1301
+ icon: block.pending ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Icon, {
830
1302
  icon: "ph--circle-notch--regular",
831
1303
  classNames: "text-subdued ml-2 animate-spin",
832
1304
  size: 4
833
1305
  }) : void 0
834
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.MarkdownViewer, {
1306
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
835
1307
  content: block.text,
836
1308
  classNames: [
837
1309
  "pbe-2",
@@ -842,10 +1314,10 @@ var components = {
842
1314
  //
843
1315
  // JSON
844
1316
  //
845
- ["json"]: ({ space, block, onPrompt }) => {
1317
+ ["json"]: ({ space, block, onPrompt, onAddToGraph }) => {
846
1318
  (0, import_invariant2.invariant)(block.type === "json", void 0, {
847
1319
  F: __dxlog_file5,
848
- L: 128,
1320
+ L: 143,
849
1321
  S: void 0,
850
1322
  A: [
851
1323
  "block.type === 'json'",
@@ -854,38 +1326,56 @@ var components = {
854
1326
  });
855
1327
  switch (block.disposition) {
856
1328
  case "tool_list": {
857
- return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
1329
+ return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
858
1330
  title: titles[block.disposition],
859
1331
  defaultOpen: true
860
- }, /* @__PURE__ */ import_react3.default.createElement(ToolboxContainer, {
1332
+ }, /* @__PURE__ */ import_react5.default.createElement(ToolboxContainer, {
861
1333
  space,
862
1334
  classNames: "pbe-2"
863
1335
  }));
864
1336
  }
865
1337
  case "suggest": {
866
- const { text = "" } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
867
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui.IconButton, {
1338
+ const { text = "" } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
1339
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.IconButton, {
868
1340
  icon: "ph--lightning--regular",
869
1341
  label: text,
870
1342
  onClick: () => onPrompt?.(text)
871
1343
  });
872
1344
  }
873
1345
  case "select": {
874
- const { options = [] } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
875
- return /* @__PURE__ */ import_react3.default.createElement("div", {
1346
+ const { options = [] } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
1347
+ return /* @__PURE__ */ import_react5.default.createElement("div", {
876
1348
  className: "flex flex-wrap gap-1"
877
- }, options.map((option, idx) => /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Button, {
1349
+ }, options.map((option, idx) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Button, {
878
1350
  classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
879
1351
  key: option,
880
1352
  onClick: () => onPrompt?.(option)
881
1353
  }, option)));
882
1354
  }
1355
+ case "graph": {
1356
+ return /* @__PURE__ */ import_react5.default.createElement("div", {
1357
+ className: "flex flex-wrap gap-1"
1358
+ }, /* @__PURE__ */ import_react5.default.createElement(import_app_framework2.Surface, {
1359
+ role: "card",
1360
+ data: {
1361
+ subject: JSON.parse(block.json ?? "{}")
1362
+ },
1363
+ limit: 1,
1364
+ fallback: /* @__PURE__ */ import_react5.default.createElement("div", {
1365
+ className: "font-mono text-xs text-pre"
1366
+ }, block.json)
1367
+ }), onAddToGraph && /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.IconButton, {
1368
+ icon: "ph--plus--regular",
1369
+ label: "Add to graph",
1370
+ onClick: () => onAddToGraph?.(JSON.parse(block.json ?? "{}"))
1371
+ }));
1372
+ }
883
1373
  default: {
884
1374
  const title = block.disposition ? titles[block.disposition] : void 0;
885
- return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
1375
+ return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
886
1376
  title: title ?? "JSON"
887
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
888
- data: (0, import_util3.safeParseJson)(block.json ?? block),
1377
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
1378
+ data: (0, import_util4.safeParseJson)(block.json ?? block),
889
1379
  classNames: "!p-1 text-xs"
890
1380
  }));
891
1381
  }
@@ -899,9 +1389,9 @@ var components = {
899
1389
  if (block.type === "tool_use") {
900
1390
  title = `Tool [${block.name}]`;
901
1391
  }
902
- return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
1392
+ return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
903
1393
  title: title ?? "JSON"
904
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
1394
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
905
1395
  data: block,
906
1396
  classNames: "!p-1 text-xs"
907
1397
  }));
@@ -938,494 +1428,110 @@ var messageReducer = ({ current, messages }, message) => {
938
1428
  block
939
1429
  ]
940
1430
  };
941
- messages.push(current);
942
- }
943
- break;
944
- }
945
- case "text":
946
- default: {
947
- current = void 0;
948
- messages.push({
949
- id: [
950
- message.id,
951
- i
952
- ].join("_"),
953
- role: message.role,
954
- content: [
955
- block
956
- ]
957
- });
958
- break;
959
- }
960
- }
961
- i++;
962
- }
963
- return {
964
- current,
965
- messages
966
- };
967
- };
968
- var createAutocompleteExtension = ({ onSubmit, onSuggest }) => {
969
- const suggestionPlugin = import_view.ViewPlugin.fromClass(class {
970
- constructor(view) {
971
- this._currentSuggestion = null;
972
- this._decorations = this.computeDecorations(view);
973
- }
974
- update(update) {
975
- if (update.docChanged || update.selectionSet) {
976
- this._decorations = this.computeDecorations(update.view);
977
- }
978
- }
979
- computeDecorations(view) {
980
- const text = view.state.doc.toString();
981
- const suggestions = onSuggest?.(text) ?? [];
982
- if (!suggestions.length) {
983
- this._currentSuggestion = null;
984
- return import_view.Decoration.none;
985
- }
986
- this._currentSuggestion = suggestions[0];
987
- const suffix = this._currentSuggestion.slice(text.length);
988
- if (!suffix) {
989
- return import_view.Decoration.none;
990
- }
991
- return import_view.Decoration.set([
992
- import_view.Decoration.widget({
993
- widget: new InlineSuggestionWidget(suffix),
994
- side: 1
995
- }).range(view.state.doc.length)
996
- ]);
997
- }
998
- completeSuggestion(view) {
999
- if (!this._currentSuggestion) {
1000
- return false;
1001
- }
1002
- const text = view.state.doc.toString();
1003
- const suffix = this._currentSuggestion.slice(text.length);
1004
- if (!suffix) {
1005
- return false;
1006
- }
1007
- view.dispatch({
1008
- changes: {
1009
- from: view.state.doc.length,
1010
- insert: suffix
1011
- },
1012
- selection: {
1013
- anchor: view.state.doc.length + suffix.length
1014
- }
1015
- });
1016
- return true;
1017
- }
1018
- }, {
1019
- decorations: (v) => v._decorations
1020
- });
1021
- return [
1022
- suggestionPlugin,
1023
- import_view.EditorView.theme({
1024
- ".cm-inline-suggestion": {
1025
- opacity: 0.4
1026
- }
1027
- }),
1028
- // Accept the current suggestion.
1029
- import_state2.Prec.highest(import_view.keymap.of([
1030
- {
1031
- key: "Tab",
1032
- preventDefault: true,
1033
- run: (view) => {
1034
- const plugin = view.plugin(suggestionPlugin);
1035
- return plugin?.completeSuggestion(view) ?? false;
1036
- }
1037
- },
1038
- {
1039
- key: "ArrowRight",
1040
- preventDefault: true,
1041
- run: (view) => {
1042
- if (view.state.selection.main.head !== view.state.doc.length) {
1043
- return false;
1044
- }
1045
- const plugin = view.plugin(suggestionPlugin);
1046
- return plugin?.completeSuggestion(view) ?? false;
1047
- }
1048
- },
1049
- {
1050
- key: "Enter",
1051
- preventDefault: true,
1052
- run: (view) => {
1053
- const text = view.state.doc.toString().trim();
1054
- if (text.length > 0 && onSubmit) {
1055
- const reset = onSubmit(text);
1056
- if (reset) {
1057
- view.dispatch({
1058
- changes: {
1059
- from: 0,
1060
- to: view.state.doc.length,
1061
- insert: ""
1062
- }
1063
- });
1064
- }
1065
- }
1066
- return true;
1067
- }
1068
- },
1069
- {
1070
- key: "Shift-Enter",
1071
- preventDefault: true,
1072
- run: (view) => {
1073
- view.dispatch({
1074
- changes: {
1075
- from: view.state.selection.main.head,
1076
- insert: "\n"
1077
- },
1078
- selection: {
1079
- anchor: view.state.selection.main.head + 1,
1080
- head: view.state.selection.main.head + 1
1081
- }
1082
- });
1083
- return true;
1084
- }
1085
- },
1086
- {
1087
- key: "Escape",
1088
- preventDefault: true,
1089
- run: (view) => {
1090
- view.dispatch({
1091
- changes: {
1092
- from: 0,
1093
- to: view.state.doc.length,
1094
- insert: ""
1095
- }
1096
- });
1097
- return true;
1098
- }
1099
- }
1100
- ]))
1101
- ];
1102
- };
1103
- var InlineSuggestionWidget = class extends import_view.WidgetType {
1104
- constructor(suffix) {
1105
- super();
1106
- this.suffix = suffix;
1107
- }
1108
- toDOM() {
1109
- const span = document.createElement("span");
1110
- span.textContent = this.suffix;
1111
- span.className = "cm-inline-suggestion";
1112
- return span;
1113
- }
1114
- eq(other) {
1115
- return other.suffix === this.suffix;
1116
- }
1117
- };
1118
- var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
1119
- if (triggerCharacter.length !== 1) {
1120
- throw new Error("triggerCharacter must be a single character");
1121
- }
1122
- const decorationField = import_view2.ViewPlugin.fromClass(class ReferenceView {
1123
- constructor(view) {
1124
- this._mutex = new import_async.Mutex();
1125
- this.decorations = import_view2.Decoration.set([]);
1126
- queueMicrotask(async () => {
1127
- const guard = await this._mutex.acquire();
1128
- try {
1129
- this.decorations = await this._computeDecorations(view);
1130
- } finally {
1131
- guard.release();
1431
+ messages.push(current);
1132
1432
  }
1133
- });
1134
- }
1135
- update(update) {
1136
- if (update.docChanged) {
1137
- queueMicrotask(async () => {
1138
- const guard = await this._mutex.acquire();
1139
- try {
1140
- this.decorations = await this._computeDecorations(update.view);
1141
- } finally {
1142
- guard.release();
1143
- }
1144
- });
1433
+ break;
1145
1434
  }
1146
- }
1147
- async _computeDecorations(view) {
1148
- const text = view.state.doc.toString();
1149
- const references = text.matchAll(new RegExp(`${triggerCharacter}[a-zA-Z0-9@:]+\\s`, "g"));
1150
- const decorations = [];
1151
- for (const match of references) {
1152
- const reference = match[0];
1153
- const uri = reference.slice(1, -1);
1154
- const data = await provider.resolveReference({
1155
- uri
1435
+ case "text":
1436
+ default: {
1437
+ current = void 0;
1438
+ messages.push({
1439
+ id: [
1440
+ message.id,
1441
+ i
1442
+ ].join("_"),
1443
+ role: message.role,
1444
+ content: [
1445
+ block
1446
+ ]
1156
1447
  });
1157
- if (data) {
1158
- decorations.push(import_view2.Decoration.replace({
1159
- widget: new ReferenceWidget(data)
1160
- }).range(match.index, match.index + reference.length));
1161
- }
1448
+ break;
1162
1449
  }
1163
- return import_view2.Decoration.set(decorations);
1164
1450
  }
1165
- }, {
1166
- decorations: (v) => v.decorations,
1167
- provide: (plugin) => [
1168
- import_view2.EditorView.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? import_state3.RangeSet.empty)
1169
- ]
1170
- });
1171
- return [
1172
- decorationField,
1173
- import_view2.EditorView.theme({
1174
- ".cm-reference-pill": {
1175
- borderRadius: "0.25rem",
1176
- borderWidth: "1px",
1177
- marginRight: "0.25rem",
1178
- marginLeft: "0.25rem"
1179
- }
1180
- }),
1181
- (0, import_autocomplete.autocompletion)({
1182
- activateOnTyping: true,
1183
- override: [
1184
- async (context) => {
1185
- const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
1186
- if (!match || match?.to === match?.from) {
1187
- return null;
1188
- }
1189
- const query = match.text.slice(1);
1190
- const references = await provider.getReferences({
1191
- query
1192
- });
1193
- return {
1194
- from: match.from,
1195
- filter: false,
1196
- options: references.map((reference) => ({
1197
- label: reference.label,
1198
- apply: `${triggerCharacter}${reference.uri} `
1199
- }))
1200
- };
1201
- }
1202
- ],
1203
- closeOnBlur: !debug,
1204
- tooltipClass: () => "shadow rounded",
1205
- aboveCursor: true
1206
- }),
1207
- import_view2.keymap.of(import_autocomplete.completionKeymap)
1208
- ];
1209
- };
1210
- var ReferenceWidget = class extends import_view2.WidgetType {
1211
- constructor(data) {
1212
- super();
1213
- this.data = data;
1214
- }
1215
- toDOM() {
1216
- const span = document.createElement("span");
1217
- span.textContent = `@ ${this.data.label}`;
1218
- span.className = "cm-reference-pill";
1219
- return span;
1220
- }
1221
- eq(other) {
1222
- return other.data.uri === this.data.uri;
1223
- }
1224
- ignoreEvent() {
1225
- return true;
1451
+ i++;
1226
1452
  }
1453
+ return {
1454
+ current,
1455
+ messages
1456
+ };
1227
1457
  };
1228
- var Prompt = /* @__PURE__ */ (0, import_react5.forwardRef)(({ classNames, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onOpenChange, references }, forwardRef2) => {
1229
- const { themeMode } = (0, import_react_ui2.useThemeContext)();
1230
- const { parentRef, view } = (0, import_react_ui_editor.useTextEditor)({
1231
- debug: true,
1232
- autoFocus,
1233
- extensions: [
1234
- (0, import_react_ui_editor.createBasicExtensions)({
1235
- bracketMatching: false,
1236
- lineWrapping,
1237
- placeholder
1238
- }),
1239
- (0, import_react_ui_editor.createThemeExtensions)({
1240
- themeMode
1241
- }),
1242
- references ? promptReferences({
1243
- provider: references
1244
- }) : [],
1245
- createAutocompleteExtension({
1246
- onSubmit,
1247
- onSuggest
1248
- }),
1249
- import_state.Prec.highest(import_react_ui_editor.keymap.of([
1250
- {
1251
- key: "cmd-ArrowUp",
1252
- preventDefault: true,
1253
- run: (view2) => {
1254
- onOpenChange?.(true);
1255
- return true;
1256
- }
1257
- },
1258
- {
1259
- key: "cmd-ArrowDown",
1260
- preventDefault: true,
1261
- run: (view2) => {
1262
- onOpenChange?.(false);
1263
- return true;
1264
- }
1265
- }
1266
- ]))
1267
- ]
1268
- }, [
1269
- themeMode,
1270
- onSubmit,
1271
- onSuggest
1272
- ]);
1273
- (0, import_react5.useImperativeHandle)(forwardRef2, () => {
1274
- return {
1275
- focus: () => {
1276
- view?.focus();
1277
- },
1278
- setText: (text) => {
1279
- view?.dispatch({
1280
- changes: {
1281
- from: 0,
1282
- to: view.state.doc.length,
1283
- insert: text
1284
- },
1285
- selection: {
1286
- anchor: text.length,
1287
- head: text.length
1288
- }
1458
+ var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
1459
+ var _effect = (0, import_tracking4.useSignals)();
1460
+ try {
1461
+ const scroller = (0, import_react4.useRef)(null);
1462
+ const identity = (0, import_halo.useIdentity)();
1463
+ const fallbackValue = (0, import_util3.keyToFallback)(identity.identityKey);
1464
+ const userHue = identity.profile?.data?.hue || fallbackValue.hue;
1465
+ const handleSubmit = (0, import_react4.useCallback)((value) => {
1466
+ onSubmit?.(value);
1467
+ scroller.current?.scrollToBottom();
1468
+ return true;
1469
+ }, [
1470
+ onSubmit
1471
+ ]);
1472
+ const { messages: filteredMessages = [] } = (0, import_react4.useMemo)(() => {
1473
+ if (collapse) {
1474
+ return (messages ?? []).reduce(messageReducer, {
1475
+ messages: []
1289
1476
  });
1477
+ } else {
1478
+ return {
1479
+ messages: messages ?? []
1480
+ };
1481
+ }
1482
+ }, [
1483
+ messages,
1484
+ collapse
1485
+ ]);
1486
+ const references = (0, import_react4.useMemo)(() => {
1487
+ if (!contextProvider) {
1488
+ return void 0;
1290
1489
  }
1291
- };
1292
- }, [
1293
- view,
1294
- onSubmit
1295
- ]);
1296
- return /* @__PURE__ */ import_react5.default.createElement("div", {
1297
- ref: parentRef,
1298
- className: (0, import_react_ui_theme4.mx)("w-full", classNames)
1299
- });
1300
- });
1301
- var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, references, ...props }) => {
1302
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_Q5XWEMHB.ASSISTANT_PLUGIN);
1303
- const promptRef = (0, import_react6.useRef)(null);
1304
- const [active, setActive] = (0, import_react6.useState)(false);
1305
- const { recording } = (0, import_plugin_transcription.useVoiceInput)({
1306
- active,
1307
- onUpdate: (text) => {
1308
- promptRef.current?.setText(text);
1309
- promptRef.current?.focus();
1310
- }
1311
- });
1312
- return /* @__PURE__ */ import_react6.default.createElement("div", {
1313
- className: (0, import_react_ui_theme5.mx)("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
1314
- }, /* @__PURE__ */ import_react6.default.createElement("div", {
1315
- className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
1316
- }, error && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
1317
- content: error.message,
1318
- delayDuration: 0
1319
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Icon, {
1320
- icon: "ph--warning-circle--regular",
1321
- classNames: import_react_ui_theme5.errorText,
1322
- size: 5
1323
- })) || /* @__PURE__ */ import_react6.default.createElement(import_react_ui_sfx.Spinner, {
1324
- active: processing
1325
- })), /* @__PURE__ */ import_react6.default.createElement(Prompt, {
1326
- ref: promptRef,
1327
- autoFocus: true,
1328
- classNames: "pbs-2",
1329
- lineWrapping: true,
1330
- placeholder: placeholder ?? t("prompt placeholder"),
1331
- references,
1332
- ...props
1333
- }), (onCancel || microphone) && /* @__PURE__ */ import_react6.default.createElement("div", {
1334
- className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
1335
- }, processing && onCancel && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
1336
- classNames: "px-1.5",
1337
- variant: "ghost",
1338
- size: 5,
1339
- icon: "ph--x--regular",
1340
- iconOnly: true,
1341
- label: t("cancel processing button"),
1342
- onClick: onCancel
1343
- }), !processing && microphone && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
1344
- classNames: (0, import_react_ui_theme5.mx)("px-1.5", recording && "bg-primary-500"),
1345
- variant: "ghost",
1346
- size: 5,
1347
- icon: "ph--microphone--regular",
1348
- iconOnly: true,
1349
- noTooltip: true,
1350
- label: t("microphone button"),
1351
- onMouseDown: () => setActive(true),
1352
- onMouseUp: () => setActive(false),
1353
- onTouchStart: () => setActive(true),
1354
- onTouchEnd: () => setActive(false)
1355
- })));
1356
- };
1357
- var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
1358
- const scroller = (0, import_react2.useRef)(null);
1359
- const identity = (0, import_halo.useIdentity)();
1360
- const fallbackValue = (0, import_util2.keyToFallback)(identity.identityKey);
1361
- const userHue = identity.profile?.data?.hue || fallbackValue.hue;
1362
- const handleSubmit = (0, import_react2.useCallback)((value) => {
1363
- onSubmit?.(value);
1364
- scroller.current?.scrollToBottom();
1365
- return true;
1366
- }, [
1367
- onSubmit
1368
- ]);
1369
- const { messages: filteredMessages = [] } = (0, import_react2.useMemo)(() => {
1370
- if (collapse) {
1371
- return (messages ?? []).reduce(messageReducer, {
1372
- messages: []
1373
- });
1374
- } else {
1375
1490
  return {
1376
- messages: messages ?? []
1491
+ getReferences: async ({ query }) => contextProvider.query({
1492
+ query
1493
+ }),
1494
+ resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
1495
+ uri
1496
+ })
1377
1497
  };
1378
- }
1379
- }, [
1380
- messages,
1381
- collapse
1382
- ]);
1383
- const references = (0, import_react2.useMemo)(() => {
1384
- if (!contextProvider) {
1385
- return void 0;
1386
- }
1387
- return {
1388
- getReferences: async ({ query }) => contextProvider.query({
1389
- query
1390
- }),
1391
- resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
1392
- uri
1393
- })
1394
- };
1395
- }, [
1396
- contextProvider
1397
- ]);
1398
- return /* @__PURE__ */ import_react2.default.createElement("div", {
1399
- role: "none",
1400
- className: (0, import_react_ui_theme2.mx)("flex flex-col grow overflow-hidden", classNames)
1401
- }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui_components.ScrollContainer, {
1402
- ref: scroller,
1403
- fade: true
1404
- }, /* @__PURE__ */ import_react2.default.createElement("div", {
1405
- role: "none",
1406
- className: (0, import_react_ui_theme2.mx)(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1407
- style: {
1408
- "--user-fill": `var(--dx-${userHue}Fill)`
1409
- }
1410
- }, filteredMessages.map((message) => /* @__PURE__ */ import_react2.default.createElement(ThreadMessage, {
1411
- key: message.id,
1412
- classNames: "px-4 pbe-4",
1413
- space,
1414
- message,
1415
- ...props
1416
- })))), onSubmit && /* @__PURE__ */ import_react2.default.createElement(PromptBar, {
1417
- microphone: transcription,
1418
- processing,
1419
- error,
1420
- onSubmit: handleSubmit,
1421
- onCancel,
1422
- onOpenChange,
1423
- references
1424
- }));
1498
+ }, [
1499
+ contextProvider
1500
+ ]);
1501
+ return /* @__PURE__ */ import_react4.default.createElement("div", {
1502
+ role: "none",
1503
+ className: (0, import_react_ui_theme4.mx)("flex flex-col grow overflow-hidden", classNames)
1504
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components.ScrollContainer, {
1505
+ ref: scroller,
1506
+ fade: true
1507
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
1508
+ role: "none",
1509
+ className: (0, import_react_ui_theme4.mx)(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1510
+ style: {
1511
+ "--user-fill": `var(--dx-${userHue}Fill)`
1512
+ }
1513
+ }, filteredMessages.map((message) => /* @__PURE__ */ import_react4.default.createElement(ThreadMessage, {
1514
+ key: message.id,
1515
+ classNames: "px-4 pbe-4",
1516
+ space,
1517
+ message,
1518
+ ...props
1519
+ })))), onSubmit && /* @__PURE__ */ import_react4.default.createElement(PromptBar, {
1520
+ microphone: transcription,
1521
+ processing,
1522
+ error,
1523
+ onSubmit: handleSubmit,
1524
+ onCancel,
1525
+ onOpenChange,
1526
+ references
1527
+ }));
1528
+ } finally {
1529
+ _effect.f();
1530
+ }
1425
1531
  };
1426
1532
  var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/processor.ts";
1427
1533
  var defaultOptions = {
1428
- model: import_assistant.DEFAULT_EDGE_MODEL,
1534
+ model: import_ai4.DEFAULT_EDGE_MODEL,
1429
1535
  systemPrompt: "you are a helpful assistant"
1430
1536
  };
1431
1537
  var ChatProcessor = class {
@@ -1447,7 +1553,7 @@ var ChatProcessor = class {
1447
1553
  const current = messages.pop();
1448
1554
  (0, import_invariant4.invariant)(current, void 0, {
1449
1555
  F: __dxlog_file6,
1450
- L: 70,
1556
+ L: 79,
1451
1557
  S: this,
1452
1558
  A: [
1453
1559
  "current",
@@ -1466,6 +1572,24 @@ var ChatProcessor = class {
1466
1572
  }
1467
1573
  return messages;
1468
1574
  });
1575
+ this._artifactDiffResolver = async (artifacts) => {
1576
+ const space = this._extensions?.space;
1577
+ if (!space) {
1578
+ return /* @__PURE__ */ new Map();
1579
+ }
1580
+ const versions = /* @__PURE__ */ new Map();
1581
+ await Promise.all(artifacts.map(async (artifact) => {
1582
+ const { objects: [object] } = await space.db.query(import_echo4.Filter.ids(artifact.id)).run();
1583
+ if (!object) {
1584
+ return;
1585
+ }
1586
+ versions.set(artifact.id, {
1587
+ version: (0, import_echo4.getVersion)(object),
1588
+ diff: `Current state: ${JSON.stringify(object)}`
1589
+ });
1590
+ }));
1591
+ return versions;
1592
+ };
1469
1593
  }
1470
1594
  get tools() {
1471
1595
  return this._tools;
@@ -1503,6 +1627,35 @@ var ChatProcessor = class {
1503
1627
  message2
1504
1628
  ];
1505
1629
  });
1630
+ this._session.toolStatusReport.on(({ message: message2, status }) => {
1631
+ const msg = this._pending.peek().find((m) => m.id === message2.id);
1632
+ const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
1633
+ if (!toolUse) {
1634
+ return;
1635
+ }
1636
+ const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
1637
+ if (block) {
1638
+ this._pending.value = this._pending.value.map((m) => {
1639
+ if (m.id === message2.id) {
1640
+ return {
1641
+ ...m,
1642
+ content: m.content.map((b) => b.type === "tool_use" && b.id === toolUse.id ? {
1643
+ ...b,
1644
+ currentStatus: status
1645
+ } : b)
1646
+ };
1647
+ }
1648
+ return m;
1649
+ });
1650
+ } else {
1651
+ import_log6.log.warn("no block for status report", void 0, {
1652
+ F: __dxlog_file6,
1653
+ L: 155,
1654
+ S: this,
1655
+ C: (f, a) => f(...a)
1656
+ });
1657
+ }
1658
+ });
1506
1659
  try {
1507
1660
  const messages = await this._session.run({
1508
1661
  client: this._ai,
@@ -1513,26 +1666,7 @@ var ChatProcessor = class {
1513
1666
  prompt: message,
1514
1667
  systemPrompt: this._options.systemPrompt,
1515
1668
  extensions: this._extensions,
1516
- artifactDiffResolver: async (artifacts) => {
1517
- const space = this._extensions?.space;
1518
- if (!space) {
1519
- return /* @__PURE__ */ new Map();
1520
- }
1521
- const versions = /* @__PURE__ */ new Map();
1522
- await Promise.all(artifacts.map(async (artifact) => {
1523
- const { objects: [object] } = await space.db.query({
1524
- id: artifact.id
1525
- }).run();
1526
- if (!object) {
1527
- return;
1528
- }
1529
- versions.set(artifact.id, {
1530
- version: (0, import_echo4.getVersion)(object),
1531
- diff: `Current state: ${JSON.stringify(object)}`
1532
- });
1533
- }));
1534
- return versions;
1535
- },
1669
+ artifactDiffResolver: this._artifactDiffResolver,
1536
1670
  generationOptions: {
1537
1671
  model: this._options.model
1538
1672
  }
@@ -1541,7 +1675,7 @@ var ChatProcessor = class {
1541
1675
  messages
1542
1676
  }, {
1543
1677
  F: __dxlog_file6,
1544
- L: 160,
1678
+ L: 175,
1545
1679
  S: this,
1546
1680
  C: (f, a) => f(...a)
1547
1681
  });
@@ -1549,7 +1683,7 @@ var ChatProcessor = class {
1549
1683
  } catch (err) {
1550
1684
  import_log6.log.catch(err, void 0, {
1551
1685
  F: __dxlog_file6,
1552
- L: 163,
1686
+ L: 178,
1553
1687
  S: this,
1554
1688
  C: (f, a) => f(...a)
1555
1689
  });
@@ -1574,7 +1708,7 @@ var ChatProcessor = class {
1574
1708
  async cancel() {
1575
1709
  import_log6.log.info("cancelling...", void 0, {
1576
1710
  F: __dxlog_file6,
1577
- L: 181,
1711
+ L: 196,
1578
1712
  S: this,
1579
1713
  C: (f, a) => f(...a)
1580
1714
  });
@@ -1596,11 +1730,11 @@ var AIServiceOverloadedError = class extends Error {
1596
1730
  this.code = "AI_SERVICE_OVERLOADED";
1597
1731
  }
1598
1732
  };
1599
- var AiClient = (0, import_app_framework4.lazy)(() => import("./ai-client-OUPSRQT7.cjs"));
1600
- var AppGraphBuilder = (0, import_app_framework4.lazy)(() => import("./app-graph-builder-LEO63CZZ.cjs"));
1601
- var IntentResolver = (0, import_app_framework4.lazy)(() => import("./intent-resolver-QDGZMWLY.cjs"));
1602
- var ReactSurface = (0, import_app_framework4.lazy)(() => import("./react-surface-XNEIJJYJ.cjs"));
1603
- var Settings = (0, import_app_framework4.lazy)(() => import("./settings-WLTC7XO5.cjs"));
1733
+ var AiClient = (0, import_app_framework5.lazy)(() => import("./ai-client-R2CGEYZW.cjs"));
1734
+ var AppGraphBuilder = (0, import_app_framework5.lazy)(() => import("./app-graph-builder-PSHIOW3Q.cjs"));
1735
+ var IntentResolver = (0, import_app_framework5.lazy)(() => import("./intent-resolver-66F7WLW6.cjs"));
1736
+ var ReactSurface = (0, import_app_framework5.lazy)(() => import("./react-surface-TASAPRPQ.cjs"));
1737
+ var Settings = (0, import_app_framework5.lazy)(() => import("./settings-ERKLO6IO.cjs"));
1604
1738
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
1605
1739
  var useChatProcessor = ({
1606
1740
  chat,
@@ -1610,101 +1744,106 @@ var useChatProcessor = ({
1610
1744
  part,
1611
1745
  associatedArtifact
1612
1746
  }) => {
1613
- const aiClient = (0, import_app_framework3.useCapability)(import_chunk_GBUNQ257.AssistantCapabilities.AiClient);
1614
- const globalTools = (0, import_app_framework3.useCapabilities)(import_app_framework3.Capabilities.Tools);
1615
- const artifactDefinitions = (0, import_app_framework3.useCapabilities)(import_app_framework3.Capabilities.ArtifactDefinition);
1616
- const { dispatchPromise: dispatch } = (0, import_app_framework3.useIntentDispatcher)();
1617
- const services = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_chunk_VG2UQY4S.ServiceType));
1618
- const [serviceTools, setServiceTools] = (0, import_react8.useState)([]);
1619
- (0, import_react8.useEffect)(() => {
1620
- (0, import_log7.log)("creating service tools...", void 0, {
1621
- F: __dxlog_file7,
1622
- L: 49,
1623
- S: void 0,
1624
- C: (f, a) => f(...a)
1625
- });
1626
- queueMicrotask(async () => {
1627
- const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
1628
- setServiceTools(tools2.flat());
1629
- });
1630
- }, [
1631
- services
1632
- ]);
1633
- const config = (0, import_react_client.useConfig)();
1634
- const functions = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_functions3.FunctionType));
1635
- const chatId = (0, import_react8.useMemo)(() => chat ? (0, import_echo5.fullyQualifiedId)(chat) : void 0, [
1636
- chat
1637
- ]);
1638
- const [tools, extensions] = (0, import_react8.useMemo)(() => {
1639
- (0, import_log7.log)("creating tools...", void 0, {
1640
- F: __dxlog_file7,
1641
- L: 61,
1642
- S: void 0,
1643
- C: (f, a) => f(...a)
1644
- });
1645
- const tools2 = [
1646
- ...globalTools.flat(),
1647
- ...serviceTools,
1648
- ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(import_util5.isNonNullable)
1649
- ];
1650
- const extensions2 = {
1651
- space,
1747
+ var _effect = (0, import_tracking8.useSignals)();
1748
+ try {
1749
+ const aiClient = (0, import_app_framework4.useCapability)(import_chunk_TS3H5OSX.AssistantCapabilities.AiClient);
1750
+ const globalTools = (0, import_app_framework4.useCapabilities)(import_app_framework4.Capabilities.Tools);
1751
+ const artifactDefinitions = (0, import_app_framework4.useCapabilities)(import_app_framework4.Capabilities.ArtifactDefinition);
1752
+ const { dispatchPromise: dispatch } = (0, import_app_framework4.useIntentDispatcher)();
1753
+ const services = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_chunk_RXPA2C2A.ServiceType));
1754
+ const [serviceTools, setServiceTools] = (0, import_react8.useState)([]);
1755
+ (0, import_react8.useEffect)(() => {
1756
+ (0, import_log7.log)("creating service tools...", void 0, {
1757
+ F: __dxlog_file7,
1758
+ L: 49,
1759
+ S: void 0,
1760
+ C: (f, a) => f(...a)
1761
+ });
1762
+ queueMicrotask(async () => {
1763
+ const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
1764
+ setServiceTools(tools2.flat());
1765
+ });
1766
+ }, [
1767
+ services
1768
+ ]);
1769
+ const config = (0, import_react_client.useConfig)();
1770
+ const functions = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_functions3.FunctionType));
1771
+ const chatId = (0, import_react8.useMemo)(() => chat ? (0, import_echo5.fullyQualifiedId)(chat) : void 0, [
1772
+ chat
1773
+ ]);
1774
+ const [tools, extensions] = (0, import_react8.useMemo)(() => {
1775
+ (0, import_log7.log)("creating tools...", void 0, {
1776
+ F: __dxlog_file7,
1777
+ L: 61,
1778
+ S: void 0,
1779
+ C: (f, a) => f(...a)
1780
+ });
1781
+ const tools2 = [
1782
+ ...globalTools.flat(),
1783
+ ...serviceTools,
1784
+ ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(import_util6.isNonNullable)
1785
+ ];
1786
+ const extensions2 = {
1787
+ space,
1788
+ dispatch,
1789
+ pivotId: chatId,
1790
+ part
1791
+ };
1792
+ return [
1793
+ tools2,
1794
+ extensions2
1795
+ ];
1796
+ }, [
1652
1797
  dispatch,
1653
- pivotId: chatId,
1654
- part
1655
- };
1656
- return [
1657
- tools2,
1658
- extensions2
1659
- ];
1660
- }, [
1661
- dispatch,
1662
- globalTools,
1663
- space,
1664
- chatId,
1665
- serviceTools,
1666
- functions
1667
- ]);
1668
- const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact4.createSystemPrompt)({
1669
- artifacts: artifactDefinitions.map((definition) => `${definition.name}
1798
+ globalTools,
1799
+ space,
1800
+ chatId,
1801
+ serviceTools,
1802
+ functions
1803
+ ]);
1804
+ const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact.createSystemPrompt)({
1805
+ artifacts: artifactDefinitions.map((definition) => `${definition.name}
1670
1806
  ${definition.instructions}`),
1671
- associatedArtifact
1672
- }), [
1673
- artifactDefinitions,
1674
- associatedArtifact
1675
- ]);
1676
- const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? import_assistant2.DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? import_assistant2.DEFAULT_EDGE_MODEL;
1677
- const processor = (0, import_react8.useMemo)(() => {
1678
- (0, import_log7.log)("creating processor...", {
1679
- settings
1680
- }, {
1681
- F: __dxlog_file7,
1682
- L: 92,
1683
- S: void 0,
1684
- C: (f, a) => f(...a)
1685
- });
1686
- return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
1807
+ associatedArtifact
1808
+ }), [
1809
+ artifactDefinitions,
1810
+ associatedArtifact
1811
+ ]);
1812
+ const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? import_ai5.DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? import_ai5.DEFAULT_EDGE_MODEL;
1813
+ const processor = (0, import_react8.useMemo)(() => {
1814
+ (0, import_log7.log)("creating processor...", {
1815
+ settings
1816
+ }, {
1817
+ F: __dxlog_file7,
1818
+ L: 92,
1819
+ S: void 0,
1820
+ C: (f, a) => f(...a)
1821
+ });
1822
+ return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
1823
+ model,
1824
+ systemPrompt
1825
+ });
1826
+ }, [
1827
+ aiClient.value,
1828
+ tools,
1829
+ artifactDefinitions,
1830
+ extensions,
1687
1831
  model,
1688
1832
  systemPrompt
1689
- });
1690
- }, [
1691
- aiClient.value,
1692
- tools,
1693
- artifactDefinitions,
1694
- extensions,
1695
- model,
1696
- systemPrompt
1697
- ]);
1698
- return processor;
1833
+ ]);
1834
+ return processor;
1835
+ } finally {
1836
+ _effect.f();
1837
+ }
1699
1838
  };
1700
1839
  var useMessageQueue = (chat) => {
1701
1840
  const space = (0, import_echo6.getSpace)(chat);
1702
1841
  const queueDxn = (0, import_react9.useMemo)(() => {
1703
- const dxn = space && chat?.assistantChatQueue.dxn;
1704
- return dxn ? (0, import_echo_schema3.createQueueDxn)(space.id) : void 0;
1842
+ const dxn = space && chat?.queue.dxn;
1843
+ return dxn ? (0, import_echo_schema3.createQueueDxn)(space.id, dxn.parts.at(-1)) : void 0;
1705
1844
  }, [
1706
1845
  space,
1707
- chat?.assistantChatQueue.dxn
1846
+ chat?.queue.dxn
1708
1847
  ]);
1709
1848
  return (0, import_echo6.useQueue)(queueDxn);
1710
1849
  };
@@ -1724,7 +1863,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
1724
1863
  }
1725
1864
  };
1726
1865
  var TEST_SERVICES = [
1727
- (0, import_echo_schema4.create)(import_chunk_VG2UQY4S.ServiceType, {
1866
+ (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
1728
1867
  serviceId: "amadeus.com/service/FlightSearch",
1729
1868
  name: "Amadeus Flight Search",
1730
1869
  description: "Search for local and international flights.",
@@ -1737,7 +1876,7 @@ var TEST_SERVICES = [
1737
1876
  }
1738
1877
  ]
1739
1878
  }),
1740
- (0, import_echo_schema4.create)(import_chunk_VG2UQY4S.ServiceType, {
1879
+ (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
1741
1880
  serviceId: "amadeus.com/service/HotelSearch",
1742
1881
  name: "Amadeus Hotel Search",
1743
1882
  description: "Search for local and international hotels.",
@@ -1750,7 +1889,7 @@ var TEST_SERVICES = [
1750
1889
  }
1751
1890
  ]
1752
1891
  }),
1753
- (0, import_echo_schema4.create)(import_chunk_VG2UQY4S.ServiceType, {
1892
+ (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
1754
1893
  serviceId: "visualcrossing.com/service/Weather",
1755
1894
  name: "Visual Crossing Weather",
1756
1895
  description: "Search for global weather forecasts.",
@@ -1764,7 +1903,7 @@ var TEST_SERVICES = [
1764
1903
  ]
1765
1904
  }),
1766
1905
  // TODO(burdon): Needs auth.
1767
- (0, import_echo_schema4.create)(import_chunk_VG2UQY4S.ServiceType, {
1906
+ (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
1768
1907
  serviceId: "abstractapi.com/service/GeoLocation",
1769
1908
  name: "Abstract GeoLocation",
1770
1909
  description: "Get the location of any IP address.",
@@ -1781,11 +1920,11 @@ var TEST_SERVICES = [
1781
1920
  //
1782
1921
  ...Array.from({
1783
1922
  length: 20
1784
- }, (_, i) => (0, import_echo_schema4.create)(import_chunk_VG2UQY4S.ServiceType, {
1923
+ }, (_, i) => (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
1785
1924
  serviceId: `example.com/service/test-${i}`,
1786
1925
  name: `Test ${i}`,
1787
1926
  description: `Test ${i}`,
1788
- category: Object.keys(import_chunk_VG2UQY4S.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_VG2UQY4S.categoryIcons).length)],
1927
+ category: Object.keys(import_chunk_RXPA2C2A.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_RXPA2C2A.categoryIcons).length)],
1789
1928
  interfaces: [
1790
1929
  {
1791
1930
  kind: "api",
@@ -1797,7 +1936,7 @@ var TEST_SERVICES = [
1797
1936
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts";
1798
1937
  var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
1799
1938
  var useContextProvider = (space) => {
1800
- const artifactDefinitions = (0, import_app_framework5.useCapabilities)(import_app_framework5.Capabilities.ArtifactDefinition);
1939
+ const artifactDefinitions = (0, import_app_framework6.useCapabilities)(import_app_framework6.Capabilities.ArtifactDefinition);
1801
1940
  return (0, import_react12.useMemo)(() => {
1802
1941
  if (!space) {
1803
1942
  return void 0;
@@ -1809,7 +1948,7 @@ var useContextProvider = (space) => {
1809
1948
  return objects.map((object) => {
1810
1949
  import_log8.log.info("object", {
1811
1950
  object,
1812
- label: (0, import_echo_schema5.getLabel)(import_echo8.Type.getSchema(object), object)
1951
+ label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object)
1813
1952
  }, {
1814
1953
  F: __dxlog_file8,
1815
1954
  L: 38,
@@ -1817,18 +1956,16 @@ var useContextProvider = (space) => {
1817
1956
  C: (f, a) => f(...a)
1818
1957
  });
1819
1958
  return object;
1820
- }).filter((object) => stringMatch(query, (0, import_echo_schema5.getLabel)(import_echo8.Type.getSchema(object), object) ?? "")).filter((object) => !!(0, import_echo_schema5.getDXN)(object)).map((object) => ({
1959
+ }).filter((object) => stringMatch(query, (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? "")).filter((object) => !!(0, import_echo_schema5.getDXN)(object)).map((object) => ({
1821
1960
  uri: (0, import_echo_schema5.getDXN)(object).toString(),
1822
- label: (0, import_echo_schema5.getLabel)(import_echo8.Type.getSchema(object), object) ?? ""
1961
+ label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? ""
1823
1962
  }));
1824
1963
  },
1825
1964
  resolveMetadata: async ({ uri }) => {
1826
- const object = await space.db.query({
1827
- id: uri
1828
- }).first();
1965
+ const object = await space.db.query(import_echo7.Filter.ids(uri)).first();
1829
1966
  return {
1830
1967
  uri,
1831
- label: (0, import_echo_schema5.getLabel)(import_echo8.Type.getSchema(object), object) ?? ""
1968
+ label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? ""
1832
1969
  };
1833
1970
  }
1834
1971
  };
@@ -1839,100 +1976,106 @@ var useContextProvider = (space) => {
1839
1976
  };
1840
1977
  var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
1841
1978
  var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, onOpenChange, ...props }) => {
1842
- const space = (0, import_echo3.getSpace)(chat);
1843
- const contextProvider = useContextProvider(space);
1844
- const processor = useChatProcessor({
1845
- chat,
1846
- space,
1847
- settings,
1848
- part,
1849
- associatedArtifact
1850
- });
1851
- const messageQueue = useMessageQueue(chat);
1852
- const { dispatchPromise: dispatch } = (0, import_app_framework2.useIntentDispatcher)();
1853
- const messages = [
1854
- ...messageQueue?.items ?? [],
1855
- ...processor.messages.value
1856
- ];
1857
- (0, import_react7.useEffect)(() => {
1858
- if (!processor.streaming.value && messageQueue?.items) {
1859
- const message = messageQueue.items[messageQueue.items.length - 1];
1860
- if (space && chat && message && dispatch && associatedArtifact) {
1861
- void dispatch((0, import_app_framework2.createIntent)(import_app_framework2.CollaborationActions.InsertContent, {
1862
- spaceId: space.id,
1863
- target: (0, import_live_object.makeRef)(associatedArtifact),
1864
- object: (0, import_live_object.refFromDXN)(new import_keys.DXN(import_keys.DXN.kind.QUEUE, [
1865
- ...chat.assistantChatQueue.dxn.parts,
1866
- message.id
1867
- ])),
1868
- label: "View proposal"
1869
- }));
1979
+ var _effect = (0, import_tracking7.useSignals)();
1980
+ try {
1981
+ const space = (0, import_echo3.getSpace)(chat);
1982
+ const contextProvider = useContextProvider(space);
1983
+ const processor = useChatProcessor({
1984
+ chat,
1985
+ space,
1986
+ settings,
1987
+ part,
1988
+ associatedArtifact
1989
+ });
1990
+ const messageQueue = useMessageQueue(chat);
1991
+ const { dispatchPromise: dispatch } = (0, import_app_framework3.useIntentDispatcher)();
1992
+ const messages = [
1993
+ ...messageQueue?.objects ?? [],
1994
+ ...processor.messages.value
1995
+ ];
1996
+ (0, import_react7.useEffect)(() => {
1997
+ if (!processor.streaming.value && messageQueue?.objects) {
1998
+ const message = messageQueue.objects[messageQueue.objects.length - 1];
1999
+ if (space && chat && message && dispatch && associatedArtifact) {
2000
+ void dispatch((0, import_app_framework3.createIntent)(import_app_framework3.CollaborationActions.InsertContent, {
2001
+ target: associatedArtifact,
2002
+ object: (0, import_live_object.refFromDXN)(new import_keys.DXN(import_keys.DXN.kind.QUEUE, [
2003
+ ...chat.queue.dxn.parts,
2004
+ message.id
2005
+ ])),
2006
+ label: "View proposal"
2007
+ }));
2008
+ }
1870
2009
  }
1871
- }
1872
- }, [
1873
- messageQueue,
1874
- associatedArtifact,
1875
- processor.streaming.value
1876
- ]);
1877
- const handleSubmit = (0, import_react7.useCallback)((text) => {
1878
- if (processor.streaming.value) {
1879
- import_log5.log.warn("ignoring submit; still processing.", void 0, {
2010
+ }, [
2011
+ messageQueue,
2012
+ associatedArtifact,
2013
+ processor.streaming.value
2014
+ ]);
2015
+ const handleSubmit = (0, import_react7.useCallback)((text) => {
2016
+ if (processor.streaming.value) {
2017
+ import_log5.log.warn("ignoring submit; still processing.", void 0, {
2018
+ F: __dxlog_file9,
2019
+ L: 65,
2020
+ S: void 0,
2021
+ C: (f, a) => f(...a)
2022
+ });
2023
+ return false;
2024
+ }
2025
+ onOpenChange?.(true);
2026
+ (0, import_invariant3.invariant)(messageQueue, void 0, {
1880
2027
  F: __dxlog_file9,
1881
- L: 66,
2028
+ L: 71,
1882
2029
  S: void 0,
1883
- C: (f, a) => f(...a)
2030
+ A: [
2031
+ "messageQueue",
2032
+ ""
2033
+ ]
1884
2034
  });
1885
- return false;
1886
- }
1887
- onOpenChange?.(true);
1888
- (0, import_invariant3.invariant)(messageQueue, void 0, {
1889
- F: __dxlog_file9,
1890
- L: 72,
1891
- S: void 0,
1892
- A: [
1893
- "messageQueue",
1894
- ""
1895
- ]
1896
- });
1897
- void processor.request(text, {
1898
- history: messageQueue.items,
1899
- onComplete: (messages2) => {
1900
- messageQueue.append(messages2);
2035
+ void processor.request(text, {
2036
+ history: messageQueue.objects,
2037
+ onComplete: (messages2) => {
2038
+ messageQueue.append(messages2);
2039
+ }
2040
+ });
2041
+ return true;
2042
+ }, [
2043
+ processor,
2044
+ messageQueue,
2045
+ onOpenChange
2046
+ ]);
2047
+ const handleCancel = (0, import_react7.useCallback)(() => {
2048
+ if (processor.streaming.value) {
2049
+ void processor.cancel();
1901
2050
  }
2051
+ }, [
2052
+ processor
2053
+ ]);
2054
+ return /* @__PURE__ */ import_react7.default.createElement(Thread, {
2055
+ classNames,
2056
+ space,
2057
+ messages,
2058
+ processing: processor.streaming.value,
2059
+ error: processor.error.value,
2060
+ tools: processor.tools,
2061
+ contextProvider,
2062
+ onSubmit: handleSubmit,
2063
+ onCancel: handleCancel,
2064
+ onPrompt: handleSubmit,
2065
+ onOpenChange,
2066
+ ...props
1902
2067
  });
1903
- return true;
1904
- }, [
1905
- processor,
1906
- messageQueue,
1907
- onOpenChange
1908
- ]);
1909
- const handleCancel = (0, import_react7.useCallback)(() => {
1910
- if (processor.streaming.value) {
1911
- void processor.cancel();
1912
- }
1913
- }, [
1914
- processor
1915
- ]);
1916
- return /* @__PURE__ */ import_react7.default.createElement(Thread, {
1917
- classNames,
1918
- space,
1919
- messages,
1920
- processing: processor.streaming.value,
1921
- error: processor.error.value,
1922
- tools: processor.tools,
1923
- contextProvider,
1924
- onSubmit: handleSubmit,
1925
- onCancel: handleCancel,
1926
- onPrompt: handleSubmit,
1927
- onOpenChange,
1928
- ...props
1929
- });
2068
+ } finally {
2069
+ _effect.f();
2070
+ }
1930
2071
  };
1931
2072
  // Annotate the CommonJS export names for ESM import in node:
1932
2073
  0 && (module.exports = {
1933
2074
  AiClient,
1934
2075
  AppGraphBuilder,
1935
2076
  IntentResolver,
2077
+ Prompt,
2078
+ PromptBar,
1936
2079
  ReactSurface,
1937
2080
  Settings,
1938
2081
  Thread,
@@ -1940,4 +2083,4 @@ var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, o
1940
2083
  Toolbox,
1941
2084
  ToolboxContainer
1942
2085
  });
1943
- //# sourceMappingURL=chunk-OOHFSPWR.cjs.map
2086
+ //# sourceMappingURL=chunk-H4A42LNR.cjs.map