@dxos/plugin-automation 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (364) hide show
  1. package/dist/lib/browser/AssistantDialog-V67OWLRP.mjs +116 -0
  2. package/dist/lib/browser/AssistantDialog-V67OWLRP.mjs.map +7 -0
  3. package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs +8 -0
  4. package/dist/lib/browser/ChatContainer-5BS6THNV.mjs +33 -0
  5. package/dist/lib/browser/ChatContainer-5BS6THNV.mjs.map +7 -0
  6. package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs +23 -0
  7. package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs.map +7 -0
  8. package/dist/lib/browser/ai-client-T2PBJISL.mjs +22 -0
  9. package/dist/lib/browser/ai-client-T2PBJISL.mjs.map +7 -0
  10. package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs +110 -0
  11. package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-62E2AEXF.mjs +162 -0
  13. package/dist/lib/browser/chunk-62E2AEXF.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-67KDIIM6.mjs +15 -0
  15. package/dist/lib/browser/chunk-67KDIIM6.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-BQ4WHY4D.mjs +1818 -0
  17. package/dist/lib/browser/chunk-BQ4WHY4D.mjs.map +7 -0
  18. package/dist/lib/browser/{chunk-X5KMOH3I.mjs → chunk-HZSTXZWK.mjs} +6 -4
  19. package/dist/lib/browser/chunk-HZSTXZWK.mjs.map +7 -0
  20. package/dist/lib/browser/chunk-LJ7F4KDM.mjs +243 -0
  21. package/dist/lib/browser/chunk-LJ7F4KDM.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-QH5E22EL.mjs +108 -0
  23. package/dist/lib/browser/chunk-QH5E22EL.mjs.map +7 -0
  24. package/dist/lib/browser/chunk-XAIWETH6.mjs +81 -0
  25. package/dist/lib/browser/chunk-XAIWETH6.mjs.map +7 -0
  26. package/dist/lib/browser/index.mjs +210 -467
  27. package/dist/lib/browser/index.mjs.map +4 -4
  28. package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs +44 -0
  29. package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs.map +7 -0
  30. package/dist/lib/browser/meta.json +1 -1
  31. package/dist/lib/browser/react-surface-KEKVLCPQ.mjs +80 -0
  32. package/dist/lib/browser/react-surface-KEKVLCPQ.mjs.map +7 -0
  33. package/dist/lib/browser/settings-FE5DDWOE.mjs +22 -0
  34. package/dist/lib/browser/settings-FE5DDWOE.mjs.map +7 -0
  35. package/dist/lib/browser/types/index.mjs +18 -9
  36. package/dist/lib/node/AssistantDialog-E62O72KI.cjs +140 -0
  37. package/dist/lib/node/AssistantDialog-E62O72KI.cjs.map +7 -0
  38. package/dist/lib/node/{meta.cjs → AutomationPanel-6COLKRIB.cjs} +7 -11
  39. package/dist/lib/node/AutomationPanel-6COLKRIB.cjs.map +7 -0
  40. package/dist/lib/node/ChatContainer-4QTLL7TH.cjs +61 -0
  41. package/dist/lib/node/ChatContainer-4QTLL7TH.cjs.map +7 -0
  42. package/dist/lib/node/TemplateContainer-3YCM6XPU.cjs +53 -0
  43. package/dist/lib/node/TemplateContainer-3YCM6XPU.cjs.map +7 -0
  44. package/dist/lib/node/ai-client-L5GUSAER.cjs +38 -0
  45. package/dist/lib/node/ai-client-L5GUSAER.cjs.map +7 -0
  46. package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs +122 -0
  47. package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs.map +7 -0
  48. package/dist/lib/node/chunk-3QSK6IPK.cjs +133 -0
  49. package/dist/lib/node/chunk-3QSK6IPK.cjs.map +7 -0
  50. package/dist/lib/node/chunk-76F5BCJE.cjs +111 -0
  51. package/dist/lib/node/chunk-76F5BCJE.cjs.map +7 -0
  52. package/dist/lib/node/chunk-B37JIAOP.cjs +1795 -0
  53. package/dist/lib/node/chunk-B37JIAOP.cjs.map +7 -0
  54. package/dist/lib/node/{chunk-DTJ7XVO2.cjs → chunk-BAQRBGOJ.cjs} +11 -8
  55. package/dist/lib/node/chunk-BAQRBGOJ.cjs.map +7 -0
  56. package/dist/lib/node/chunk-UVWK2XJE.cjs +183 -0
  57. package/dist/lib/node/chunk-UVWK2XJE.cjs.map +7 -0
  58. package/dist/lib/node/chunk-V4L7LTWM.cjs +267 -0
  59. package/dist/lib/node/chunk-V4L7LTWM.cjs.map +7 -0
  60. package/dist/lib/node/chunk-VNBYGJ4K.cjs +34 -0
  61. package/dist/lib/node/chunk-VNBYGJ4K.cjs.map +7 -0
  62. package/dist/lib/node/index.cjs +201 -473
  63. package/dist/lib/node/index.cjs.map +4 -4
  64. package/dist/lib/node/intent-resolver-4MQZULXW.cjs +58 -0
  65. package/dist/lib/node/intent-resolver-4MQZULXW.cjs.map +7 -0
  66. package/dist/lib/node/meta.json +1 -1
  67. package/dist/lib/node/react-surface-4RVHY6WI.cjs +95 -0
  68. package/dist/lib/node/react-surface-4RVHY6WI.cjs.map +7 -0
  69. package/dist/lib/node/settings-GOIB2WJQ.cjs +36 -0
  70. package/dist/lib/node/settings-GOIB2WJQ.cjs.map +7 -0
  71. package/dist/lib/node/types/index.cjs +19 -10
  72. package/dist/lib/node/types/index.cjs.map +2 -2
  73. package/dist/lib/node-esm/AssistantDialog-IPRBJKWA.mjs +117 -0
  74. package/dist/lib/node-esm/AssistantDialog-IPRBJKWA.mjs.map +7 -0
  75. package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs +9 -0
  76. package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs +34 -0
  77. package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs.map +7 -0
  78. package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs +24 -0
  79. package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs.map +7 -0
  80. package/dist/lib/node-esm/ai-client-45LZLW7V.mjs +23 -0
  81. package/dist/lib/node-esm/ai-client-45LZLW7V.mjs.map +7 -0
  82. package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs +111 -0
  83. package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs.map +7 -0
  84. package/dist/lib/node-esm/chunk-5BKKHYO5.mjs +163 -0
  85. package/dist/lib/node-esm/chunk-5BKKHYO5.mjs.map +7 -0
  86. package/dist/lib/node-esm/chunk-AWAU4BHR.mjs +244 -0
  87. package/dist/lib/node-esm/chunk-AWAU4BHR.mjs.map +7 -0
  88. package/dist/lib/node-esm/chunk-CAWPHOY4.mjs +82 -0
  89. package/dist/lib/node-esm/chunk-CAWPHOY4.mjs.map +7 -0
  90. package/dist/lib/node-esm/chunk-I32H7MCF.mjs +109 -0
  91. package/dist/lib/node-esm/chunk-I32H7MCF.mjs.map +7 -0
  92. package/dist/lib/node-esm/{chunk-HNOBZHWK.mjs → chunk-IG4GSWZN.mjs} +6 -4
  93. package/dist/lib/node-esm/chunk-IG4GSWZN.mjs.map +7 -0
  94. package/dist/lib/node-esm/chunk-QHKP5HT2.mjs +1819 -0
  95. package/dist/lib/node-esm/chunk-QHKP5HT2.mjs.map +7 -0
  96. package/dist/lib/node-esm/chunk-SS7U6GCX.mjs +16 -0
  97. package/dist/lib/node-esm/chunk-SS7U6GCX.mjs.map +7 -0
  98. package/dist/lib/node-esm/index.mjs +210 -467
  99. package/dist/lib/node-esm/index.mjs.map +4 -4
  100. package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs +45 -0
  101. package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs.map +7 -0
  102. package/dist/lib/node-esm/meta.json +1 -1
  103. package/dist/lib/node-esm/react-surface-5ILD642V.mjs +81 -0
  104. package/dist/lib/node-esm/react-surface-5ILD642V.mjs.map +7 -0
  105. package/dist/lib/node-esm/settings-ANNQPPRY.mjs +23 -0
  106. package/dist/lib/node-esm/settings-ANNQPPRY.mjs.map +7 -0
  107. package/dist/lib/node-esm/types/index.mjs +18 -9
  108. package/dist/types/src/AutomationPlugin.d.ts +1 -3
  109. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  110. package/dist/types/src/capabilities/ai-client.d.ts +5 -0
  111. package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
  112. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  113. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  114. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  115. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  116. package/dist/types/src/capabilities/index.d.ts +183 -0
  117. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  118. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  119. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  120. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  121. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  122. package/dist/types/src/capabilities/settings.d.ts +4 -0
  123. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  124. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
  125. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
  126. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
  127. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
  128. package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
  129. package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
  130. package/dist/types/src/components/AssistantDialog.d.ts +7 -0
  131. package/dist/types/src/components/AssistantDialog.d.ts.map +1 -0
  132. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
  133. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  134. package/dist/types/src/components/AutomationSettings/AutomationSettings.d.ts +5 -0
  135. package/dist/types/src/components/AutomationSettings/AutomationSettings.d.ts.map +1 -0
  136. package/dist/types/src/components/AutomationSettings/index.d.ts +2 -0
  137. package/dist/types/src/components/AutomationSettings/index.d.ts.map +1 -0
  138. package/dist/types/src/components/ChatContainer.d.ts +7 -0
  139. package/dist/types/src/components/ChatContainer.d.ts.map +1 -0
  140. package/dist/types/src/components/Prompt/Prompt.d.ts +17 -0
  141. package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
  142. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
  143. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
  144. package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
  145. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
  146. package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
  147. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
  148. package/dist/types/src/components/Prompt/index.d.ts +3 -0
  149. package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
  150. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
  151. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
  152. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
  153. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
  154. package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
  155. package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
  156. package/dist/types/src/components/TemplateContainer.d.ts +7 -0
  157. package/dist/types/src/components/TemplateContainer.d.ts.map +1 -0
  158. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +12 -0
  159. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
  160. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +8 -0
  161. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
  162. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +10 -0
  163. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
  164. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +8 -0
  165. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
  166. package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
  167. package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
  168. package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
  169. package/dist/types/src/components/Thread/Thread.d.ts +17 -0
  170. package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
  171. package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
  172. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
  173. package/dist/types/src/components/Thread/ThreadContainer.d.ts +10 -0
  174. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
  175. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
  176. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
  177. package/dist/types/src/components/Thread/ThreadMessage.d.ts +13 -0
  178. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
  179. package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
  180. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
  181. package/dist/types/src/components/Thread/index.d.ts +3 -0
  182. package/dist/types/src/components/Thread/index.d.ts.map +1 -0
  183. package/dist/types/src/components/Thread/reducer.d.ts +12 -0
  184. package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
  185. package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
  186. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
  187. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
  188. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
  189. package/dist/types/src/components/Toolbox/index.d.ts +2 -0
  190. package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
  191. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -3
  192. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  193. package/dist/types/src/components/index.d.ts +19 -2
  194. package/dist/types/src/components/index.d.ts.map +1 -1
  195. package/dist/types/src/hooks/index.d.ts +5 -0
  196. package/dist/types/src/hooks/index.d.ts.map +1 -1
  197. package/dist/types/src/hooks/processor.d.ts +75 -0
  198. package/dist/types/src/hooks/processor.d.ts.map +1 -0
  199. package/dist/types/src/hooks/processor.test.d.ts +2 -0
  200. package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
  201. package/dist/types/src/hooks/useChatProcessor.d.ts +8 -0
  202. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
  203. package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
  204. package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
  205. package/dist/types/src/hooks/useServices.d.ts +7 -0
  206. package/dist/types/src/hooks/useServices.d.ts.map +1 -0
  207. package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
  208. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
  209. package/dist/types/src/index.d.ts +2 -4
  210. package/dist/types/src/index.d.ts.map +1 -1
  211. package/dist/types/src/meta.d.ts +2 -2
  212. package/dist/types/src/meta.d.ts.map +1 -1
  213. package/dist/types/src/testing/index.d.ts +2 -1
  214. package/dist/types/src/testing/index.d.ts.map +1 -1
  215. package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +3 -1
  216. package/dist/types/src/testing/test-functions.d.ts.map +1 -0
  217. package/dist/types/src/testing/test-services.d.ts +5 -0
  218. package/dist/types/src/testing/test-services.d.ts.map +1 -0
  219. package/dist/types/src/tools/function.d.ts +5 -0
  220. package/dist/types/src/tools/function.d.ts.map +1 -0
  221. package/dist/types/src/tools/index.d.ts +3 -0
  222. package/dist/types/src/tools/index.d.ts.map +1 -0
  223. package/dist/types/src/tools/openapi.d.ts +10 -0
  224. package/dist/types/src/tools/openapi.d.ts.map +1 -0
  225. package/dist/types/src/tools/openapi.test.d.ts +2 -0
  226. package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
  227. package/dist/types/src/translations.d.ts +117 -2
  228. package/dist/types/src/translations.d.ts.map +1 -1
  229. package/dist/types/src/types/chat.d.ts +12 -0
  230. package/dist/types/src/types/chat.d.ts.map +1 -0
  231. package/dist/types/src/types/index.d.ts +3 -1
  232. package/dist/types/src/types/index.d.ts.map +1 -1
  233. package/dist/types/src/types/service.d.ts +160 -0
  234. package/dist/types/src/types/service.d.ts.map +1 -0
  235. package/dist/types/src/types/template.d.ts +40 -0
  236. package/dist/types/src/types/template.d.ts.map +1 -0
  237. package/dist/types/src/types/types.d.ts +35 -5
  238. package/dist/types/src/types/types.d.ts.map +1 -1
  239. package/dist/types/tsconfig.tsbuildinfo +1 -1
  240. package/package.json +62 -48
  241. package/src/AutomationPlugin.tsx +102 -193
  242. package/src/capabilities/ai-client.ts +19 -0
  243. package/src/capabilities/app-graph-builder.ts +99 -0
  244. package/src/capabilities/capabilities.ts +12 -0
  245. package/src/capabilities/index.ts +13 -0
  246. package/src/capabilities/intent-resolver.ts +38 -0
  247. package/src/capabilities/react-surface.tsx +63 -0
  248. package/src/capabilities/settings.ts +19 -0
  249. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
  250. package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
  251. package/src/components/AmbientDialog/index.ts +5 -0
  252. package/src/components/AssistantDialog.tsx +33 -0
  253. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +2 -2
  254. package/src/components/AutomationPanel/AutomationPanel.tsx +54 -37
  255. package/src/components/AutomationSettings/AutomationSettings.tsx +49 -0
  256. package/src/components/AutomationSettings/index.ts +5 -0
  257. package/src/components/ChatContainer.tsx +29 -0
  258. package/src/components/Prompt/Prompt.stories.tsx +79 -0
  259. package/src/components/Prompt/Prompt.tsx +100 -0
  260. package/src/components/Prompt/PromptBar.tsx +100 -0
  261. package/src/components/Prompt/autocomplete.ts +212 -0
  262. package/src/components/Prompt/index.ts +6 -0
  263. package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
  264. package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
  265. package/src/components/ServiceRegistry/index.ts +5 -0
  266. package/src/components/TemplateContainer.tsx +21 -0
  267. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +72 -0
  268. package/src/components/TemplateEditor/TemplateEditor.tsx +76 -0
  269. package/src/components/TemplateEditor/TemplateForm.stories.tsx +65 -0
  270. package/src/components/TemplateEditor/TemplateForm.tsx +184 -0
  271. package/src/components/{PromptEditor → TemplateEditor}/index.ts +1 -1
  272. package/src/components/Thread/Thread.stories.tsx +212 -0
  273. package/src/components/Thread/Thread.tsx +97 -0
  274. package/src/components/Thread/ThreadContainer.stories.tsx +258 -0
  275. package/src/components/Thread/ThreadContainer.tsx +78 -0
  276. package/src/components/Thread/ThreadMessage.tsx +187 -0
  277. package/src/components/Thread/ToolInvocations.tsx +93 -0
  278. package/src/components/Thread/index.ts +6 -0
  279. package/src/components/Thread/reducer.ts +52 -0
  280. package/src/components/Toolbox/Toolbox.stories.tsx +65 -0
  281. package/src/components/Toolbox/Toolbox.tsx +117 -0
  282. package/src/components/Toolbox/index.ts +5 -0
  283. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +2 -2
  284. package/src/components/TriggerEditor/TriggerEditor.tsx +78 -14
  285. package/src/components/index.ts +11 -1
  286. package/src/hooks/index.ts +6 -0
  287. package/src/hooks/processor.test.ts +15 -0
  288. package/src/hooks/processor.ts +219 -0
  289. package/src/hooks/useChatProcessor.tsx +77 -0
  290. package/src/hooks/useMessageQueue.ts +23 -0
  291. package/src/hooks/useServices.ts +28 -0
  292. package/src/hooks/useTextInputEvents.ts +49 -0
  293. package/src/index.ts +3 -6
  294. package/src/meta.ts +5 -2
  295. package/src/testing/index.ts +2 -1
  296. package/src/testing/{testing.ts → test-functions.ts} +9 -2
  297. package/src/testing/test-services.ts +131 -0
  298. package/src/tools/function.ts +47 -0
  299. package/src/tools/index.ts +6 -0
  300. package/src/tools/openapi.test.ts +224 -0
  301. package/src/tools/openapi.ts +331 -0
  302. package/src/translations.ts +36 -2
  303. package/src/types/chat.ts +11 -0
  304. package/src/types/index.ts +3 -1
  305. package/src/types/service.ts +102 -0
  306. package/src/types/template.ts +34 -0
  307. package/src/types/types.ts +34 -20
  308. package/src/typings.d.ts +9 -0
  309. package/dist/lib/browser/AssistantPanel-32FH2RA6.mjs +0 -339
  310. package/dist/lib/browser/AssistantPanel-32FH2RA6.mjs.map +0 -7
  311. package/dist/lib/browser/AutomationPanel-ABGPG5LE.mjs +0 -151
  312. package/dist/lib/browser/AutomationPanel-ABGPG5LE.mjs.map +0 -7
  313. package/dist/lib/browser/chunk-DN5M2QL5.mjs +0 -49
  314. package/dist/lib/browser/chunk-DN5M2QL5.mjs.map +0 -7
  315. package/dist/lib/browser/chunk-X5KMOH3I.mjs.map +0 -7
  316. package/dist/lib/browser/meta.mjs +0 -9
  317. package/dist/lib/node/AssistantPanel-XANI7YNV.cjs +0 -359
  318. package/dist/lib/node/AssistantPanel-XANI7YNV.cjs.map +0 -7
  319. package/dist/lib/node/AutomationPanel-VADY3HMP.cjs +0 -171
  320. package/dist/lib/node/AutomationPanel-VADY3HMP.cjs.map +0 -7
  321. package/dist/lib/node/chunk-DTJ7XVO2.cjs.map +0 -7
  322. package/dist/lib/node/chunk-NIL4TP6U.cjs +0 -73
  323. package/dist/lib/node/chunk-NIL4TP6U.cjs.map +0 -7
  324. package/dist/lib/node/meta.cjs.map +0 -7
  325. package/dist/lib/node-esm/AssistantPanel-5M6O6JV7.mjs +0 -340
  326. package/dist/lib/node-esm/AssistantPanel-5M6O6JV7.mjs.map +0 -7
  327. package/dist/lib/node-esm/AutomationPanel-EETYIDPA.mjs +0 -152
  328. package/dist/lib/node-esm/AutomationPanel-EETYIDPA.mjs.map +0 -7
  329. package/dist/lib/node-esm/chunk-GCHXTXVT.mjs +0 -51
  330. package/dist/lib/node-esm/chunk-GCHXTXVT.mjs.map +0 -7
  331. package/dist/lib/node-esm/chunk-HNOBZHWK.mjs.map +0 -7
  332. package/dist/lib/node-esm/meta.mjs +0 -10
  333. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
  334. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
  335. package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
  336. package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
  337. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
  338. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
  339. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
  340. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
  341. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
  342. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
  343. package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
  344. package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
  345. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
  346. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
  347. package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
  348. package/dist/types/src/presets.d.ts +0 -9
  349. package/dist/types/src/presets.d.ts.map +0 -1
  350. package/dist/types/src/testing/testing.d.ts.map +0 -1
  351. package/dist/types/src/types/schema.d.ts +0 -63
  352. package/dist/types/src/types/schema.d.ts.map +0 -1
  353. package/src/components/AssistantPanel/AssistantPanel.tsx +0 -230
  354. package/src/components/AssistantPanel/index.ts +0 -7
  355. package/src/components/AssistantPanel/system-instructions.ts +0 -166
  356. package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
  357. package/src/components/PromptEditor/PromptEditor.tsx +0 -222
  358. package/src/components/PromptEditor/prompt-extension.ts +0 -43
  359. package/src/presets.ts +0 -248
  360. package/src/types/schema.ts +0 -38
  361. /package/dist/lib/browser/{meta.mjs.map → AutomationPanel-NCKK3CFN.mjs.map} +0 -0
  362. /package/dist/lib/node-esm/{meta.mjs.map → AutomationPanel-3MPIAO7R.mjs.map} +0 -0
  363. /package/dist/types/src/components/{PromptEditor → TemplateEditor}/types.d.ts +0 -0
  364. /package/src/components/{PromptEditor → TemplateEditor}/types.tsx +0 -0
@@ -0,0 +1,1795 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_B37JIAOP_exports = {};
30
+ __export(chunk_B37JIAOP_exports, {
31
+ AiClient: () => AiClient,
32
+ AppGraphBuilder: () => AppGraphBuilder,
33
+ AutomationSettings: () => AutomationSettings,
34
+ IntentResolver: () => IntentResolver,
35
+ ReactSurface: () => ReactSurface,
36
+ Thread: () => Thread,
37
+ ThreadContainer: () => ThreadContainer,
38
+ Toolbox: () => Toolbox,
39
+ ToolboxContainer: () => ToolboxContainer,
40
+ useServices: () => useServices
41
+ });
42
+ module.exports = __toCommonJS(chunk_B37JIAOP_exports);
43
+ var import_chunk_VNBYGJ4K = require("./chunk-VNBYGJ4K.cjs");
44
+ var import_chunk_UVWK2XJE = require("./chunk-UVWK2XJE.cjs");
45
+ var import_chunk_BAQRBGOJ = require("./chunk-BAQRBGOJ.cjs");
46
+ var import_react = __toESM(require("react"));
47
+ var import_app_framework = require("@dxos/app-framework");
48
+ var import_functions = require("@dxos/functions");
49
+ var import_log = require("@dxos/log");
50
+ var import_echo = require("@dxos/react-client/echo");
51
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
52
+ var import_artifact = require("@dxos/artifact");
53
+ var import_echo_schema = require("@dxos/echo-schema");
54
+ var import_functions2 = require("@dxos/functions");
55
+ var import_log2 = require("@dxos/log");
56
+ var import_echo2 = require("@dxos/react-client/echo");
57
+ var import_jsonpointer = __toESM(require("jsonpointer"));
58
+ var import_artifact2 = require("@dxos/artifact");
59
+ var import_echo_schema2 = require("@dxos/echo-schema");
60
+ var import_invariant = require("@dxos/invariant");
61
+ var import_log3 = require("@dxos/log");
62
+ var import_util = require("@dxos/util");
63
+ var import_react2 = __toESM(require("react"));
64
+ var import_halo = require("@dxos/react-client/halo");
65
+ var import_react_ui_components = require("@dxos/react-ui-components");
66
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
67
+ var import_util2 = require("@dxos/util");
68
+ var import_react3 = __toESM(require("react"));
69
+ var import_invariant2 = require("@dxos/invariant");
70
+ var import_react_ui = require("@dxos/react-ui");
71
+ var import_react_ui_components2 = require("@dxos/react-ui-components");
72
+ var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
73
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
74
+ var import_util3 = require("@dxos/util");
75
+ var import_react4 = __toESM(require("react"));
76
+ var import_log4 = require("@dxos/log");
77
+ var import_react_ui_components3 = require("@dxos/react-ui-components");
78
+ var import_react_ui_syntax_highlighter2 = require("@dxos/react-ui-syntax-highlighter");
79
+ var import_util4 = require("@dxos/util");
80
+ var import_react5 = __toESM(require("react"));
81
+ var import_react_ui2 = require("@dxos/react-ui");
82
+ var import_react_ui_editor = require("@dxos/react-ui-editor");
83
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
84
+ var import_state = require("@codemirror/state");
85
+ var import_view = require("@codemirror/view");
86
+ var import_react6 = __toESM(require("react"));
87
+ var import_plugin_transcription = require("@dxos/plugin-transcription");
88
+ var import_react_ui3 = require("@dxos/react-ui");
89
+ var import_react_ui_sfx = require("@dxos/react-ui-sfx");
90
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
91
+ var import_react7 = __toESM(require("react"));
92
+ var import_invariant3 = require("@dxos/invariant");
93
+ var import_log5 = require("@dxos/log");
94
+ var import_echo3 = require("@dxos/react-client/echo");
95
+ var import_signals_core = require("@preact/signals-core");
96
+ var import_artifact3 = require("@dxos/artifact");
97
+ var import_assistant = require("@dxos/assistant");
98
+ var import_echo_schema3 = require("@dxos/echo-schema");
99
+ var import_invariant4 = require("@dxos/invariant");
100
+ var import_log6 = require("@dxos/log");
101
+ var import_react8 = require("react");
102
+ var import_app_framework2 = require("@dxos/app-framework");
103
+ var import_artifact4 = require("@dxos/artifact");
104
+ var import_assistant2 = require("@dxos/assistant");
105
+ var import_functions3 = require("@dxos/functions");
106
+ var import_log7 = require("@dxos/log");
107
+ var import_react_client = require("@dxos/react-client");
108
+ var import_echo4 = require("@dxos/react-client/echo");
109
+ var import_util5 = require("@dxos/util");
110
+ var import_app_framework3 = require("@dxos/app-framework");
111
+ var import_react9 = require("react");
112
+ var import_async = require("@dxos/async");
113
+ var import_context = require("@dxos/context");
114
+ var import_functions4 = require("@dxos/functions");
115
+ var import_functions5 = require("@dxos/functions");
116
+ var import_invariant5 = require("@dxos/invariant");
117
+ var import_log8 = require("@dxos/log");
118
+ var import_react_client2 = require("@dxos/react-client");
119
+ var import_echo5 = require("@dxos/react-client/echo");
120
+ var import_async2 = require("@dxos/async");
121
+ var import_echo_db = require("@dxos/echo-db");
122
+ var import_functions6 = require("@dxos/functions");
123
+ var import_invariant6 = require("@dxos/invariant");
124
+ var import_keys = require("@dxos/keys");
125
+ var import_log9 = require("@dxos/log");
126
+ var import_react10 = require("react");
127
+ var import_keys2 = require("@dxos/keys");
128
+ var import_echo6 = require("@dxos/react-client/echo");
129
+ var import_react_edge_client = require("@dxos/react-edge-client");
130
+ var import_react11 = require("react");
131
+ var import_artifact5 = require("@dxos/artifact");
132
+ var import_assistant3 = require("@dxos/assistant");
133
+ var import_echo_schema4 = require("@dxos/echo-schema");
134
+ var import_echo_schema5 = require("@dxos/echo-schema");
135
+ var import_react12 = require("react");
136
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/function.ts";
137
+ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
138
+ if (!fn.description || !fn.inputSchema) {
139
+ return void 0;
140
+ }
141
+ const existingFunctionUrl = (0, import_functions2.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
142
+ if (!existingFunctionUrl) {
143
+ return void 0;
144
+ }
145
+ const url = (0, import_functions2.getInvocationUrl)(existingFunctionUrl, edgeUrl, {
146
+ spaceId
147
+ });
148
+ return (0, import_artifact.defineTool)({
149
+ name: fn.name,
150
+ description: fn.description,
151
+ schema: (0, import_echo_schema.toEffectSchema)(fn.inputSchema),
152
+ execute: async (input) => {
153
+ import_log2.log.info("execute function tool", {
154
+ name: fn.name,
155
+ url,
156
+ input
157
+ }, {
158
+ F: __dxlog_file,
159
+ L: 36,
160
+ S: void 0,
161
+ C: (f, a) => f(...a)
162
+ });
163
+ const response = await fetch(url, {
164
+ method: "POST",
165
+ headers: {
166
+ "Content-Type": "application/json"
167
+ },
168
+ body: JSON.stringify(input)
169
+ });
170
+ return import_artifact.ToolResult.Success(await response.text());
171
+ }
172
+ });
173
+ };
174
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/openapi.ts";
175
+ var createToolsFromService = async (service) => {
176
+ (0, import_invariant.invariant)(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
177
+ F: __dxlog_file2,
178
+ L: 22,
179
+ S: void 0,
180
+ A: [
181
+ "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
182
+ ""
183
+ ]
184
+ });
185
+ const iface = service.interfaces[0];
186
+ (0, import_invariant.invariant)(iface.schemaUrl, void 0, {
187
+ F: __dxlog_file2,
188
+ L: 24,
189
+ S: void 0,
190
+ A: [
191
+ "iface.schemaUrl",
192
+ ""
193
+ ]
194
+ });
195
+ (0, import_invariant.invariant)(iface.schemaUrl, void 0, {
196
+ F: __dxlog_file2,
197
+ L: 25,
198
+ S: void 0,
199
+ A: [
200
+ "iface.schemaUrl",
201
+ ""
202
+ ]
203
+ });
204
+ return createToolsFromApi(iface.schemaUrl, {
205
+ authorization: iface.authorization
206
+ });
207
+ };
208
+ var createToolsFromApi = async (url, options) => {
209
+ const res = await fetch(url);
210
+ const spec = await res.json();
211
+ (0, import_log3.log)("spec", {
212
+ spec
213
+ }, {
214
+ F: __dxlog_file2,
215
+ L: 32,
216
+ S: void 0,
217
+ C: (f, a) => f(...a)
218
+ });
219
+ const tools = [];
220
+ for (const [path, pathItem] of Object.entries(spec.paths)) {
221
+ if (typeof pathItem !== "object") {
222
+ continue;
223
+ }
224
+ const { ...methods } = pathItem;
225
+ for (const [method, m] of Object.entries(methods)) {
226
+ const methodItem = m;
227
+ (0, import_log3.log)("methodItem", {
228
+ path,
229
+ method,
230
+ methodItem
231
+ }, {
232
+ F: __dxlog_file2,
233
+ L: 44,
234
+ S: void 0,
235
+ C: (f, a) => f(...a)
236
+ });
237
+ const parametersResolved = methodItem.parameters?.map((parameter) => {
238
+ const resolved = resolveJsonSchema(parameter, spec);
239
+ return resolved;
240
+ }) ?? [];
241
+ const inputSchema = {
242
+ type: "object",
243
+ properties: {}
244
+ };
245
+ const endpointParameters = [];
246
+ for (const parameter of parametersResolved) {
247
+ (0, import_log3.log)("parameter", {
248
+ parameter
249
+ }, {
250
+ F: __dxlog_file2,
251
+ L: 59,
252
+ S: void 0,
253
+ C: (f, a) => f(...a)
254
+ });
255
+ if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
256
+ continue;
257
+ }
258
+ endpointParameters.push(parameter);
259
+ if (parameter.schema) {
260
+ inputSchema.properties[parameter.name] = (0, import_echo_schema2.normalizeSchema)(parameter.schema);
261
+ } else if (typeof parameter.type === "string") {
262
+ const { name, in: _in, required, ...schema } = parameter;
263
+ inputSchema.properties[name] = (0, import_echo_schema2.normalizeSchema)(schema);
264
+ if (required) {
265
+ inputSchema.required ??= [];
266
+ inputSchema.required.push(name);
267
+ }
268
+ }
269
+ }
270
+ (0, import_log3.log)("inputSchema", {
271
+ inputSchema
272
+ }, {
273
+ F: __dxlog_file2,
274
+ L: 84,
275
+ S: void 0,
276
+ C: (f, a) => f(...a)
277
+ });
278
+ import_echo_schema2.S.validateSync(import_echo_schema2.JsonSchemaType)(inputSchema);
279
+ const description = methodItem.description ?? methodItem.summary;
280
+ if (!description) {
281
+ import_log3.log.warn("no description", {
282
+ path,
283
+ method
284
+ }, {
285
+ F: __dxlog_file2,
286
+ L: 89,
287
+ S: void 0,
288
+ C: (f, a) => f(...a)
289
+ });
290
+ continue;
291
+ }
292
+ const endpoint = {
293
+ document: spec,
294
+ path,
295
+ method,
296
+ parameters: endpointParameters,
297
+ authorization: options?.authorization
298
+ };
299
+ tools.push({
300
+ name: getToolName(path, method, methodItem),
301
+ description: options?.instructions ? `${options.instructions}
302
+
303
+ ${description}` : description,
304
+ parameters: inputSchema,
305
+ execute: async (input) => {
306
+ const response = await callApiEndpoint(endpoint, input);
307
+ return import_artifact2.ToolResult.Success(response);
308
+ }
309
+ });
310
+ }
311
+ }
312
+ return tools;
313
+ };
314
+ var getToolName = (path, method, methodItem) => {
315
+ if (methodItem.operationId) {
316
+ return methodItem.operationId;
317
+ }
318
+ let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
319
+ while (name.length > MAX_TOOL_NAME_LENGTH) {
320
+ const lengthBefore = name.length;
321
+ for (const word of GENERIC_WORDS) {
322
+ if (name.includes(word)) {
323
+ name = name.replace(word, "");
324
+ break;
325
+ }
326
+ }
327
+ name = name.replaceAll("__", "_").replace(/_$/, "");
328
+ const lengthAfter = name.length;
329
+ if (lengthBefore === lengthAfter) {
330
+ break;
331
+ }
332
+ }
333
+ name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
334
+ return name.slice(0, MAX_TOOL_NAME_LENGTH);
335
+ };
336
+ var MAX_TOOL_NAME_LENGTH = 64;
337
+ var GENERIC_WORDS = [
338
+ "services",
339
+ "service",
340
+ "api",
341
+ "rest",
342
+ "endpoint",
343
+ "get",
344
+ "post",
345
+ "put",
346
+ "delete",
347
+ "patch",
348
+ "head",
349
+ "options",
350
+ "trace",
351
+ "service",
352
+ "api",
353
+ "endpoint"
354
+ ];
355
+ var callApiEndpoint = async (endpoint, input) => {
356
+ import_log3.log.info("endpoint", {
357
+ method: endpoint.method,
358
+ name: endpoint.path,
359
+ input
360
+ }, {
361
+ F: __dxlog_file2,
362
+ L: 173,
363
+ S: void 0,
364
+ C: (f, a) => f(...a)
365
+ });
366
+ let url = getEndpointUrl(endpoint);
367
+ const request = {
368
+ method: endpoint.method,
369
+ headers: {}
370
+ };
371
+ const query = new URLSearchParams();
372
+ let body;
373
+ for (const parameter of endpoint.parameters) {
374
+ if (input[parameter.name] === void 0) {
375
+ continue;
376
+ }
377
+ switch (parameter.in) {
378
+ case "header": {
379
+ if (parameter.example) {
380
+ request.headers[parameter.name] = parameter.default;
381
+ }
382
+ break;
383
+ }
384
+ case "path": {
385
+ url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
386
+ break;
387
+ }
388
+ case "body": {
389
+ const value = input[parameter.name];
390
+ const effectSchema = (0, import_echo_schema2.toEffectSchema)(parameter.schema);
391
+ import_echo_schema2.S.validateSync(effectSchema)(value);
392
+ if (body) {
393
+ throw new Error(`Duplicate body parameter: ${parameter.name}`);
394
+ }
395
+ body = value;
396
+ break;
397
+ }
398
+ case "query": {
399
+ query.set(parameter.name, input[parameter.name]);
400
+ break;
401
+ }
402
+ }
403
+ }
404
+ if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
405
+ request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
406
+ } else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
407
+ query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
408
+ }
409
+ if (query.size > 0) {
410
+ url += `?${query.toString()}`;
411
+ }
412
+ if (body) {
413
+ request.body = JSON.stringify(body);
414
+ request.headers["Content-Type"] = "application/json";
415
+ }
416
+ import_log3.log.info("request", {
417
+ url,
418
+ request
419
+ }, {
420
+ F: __dxlog_file2,
421
+ L: 236,
422
+ S: void 0,
423
+ C: (f, a) => f(...a)
424
+ });
425
+ const response = await fetch(url, request);
426
+ import_log3.log.info("response", {
427
+ ok: response.ok,
428
+ status: response.status,
429
+ statusText: response.statusText
430
+ }, {
431
+ F: __dxlog_file2,
432
+ L: 239,
433
+ S: void 0,
434
+ C: (f, a) => f(...a)
435
+ });
436
+ if (response.ok) {
437
+ const contentType = response.headers.get("Content-Type");
438
+ if (contentType?.includes("application/json")) {
439
+ return await response.json();
440
+ } else {
441
+ return await response.text();
442
+ }
443
+ } else {
444
+ if (response.headers.get("Content-Type")?.includes("application/json")) {
445
+ const responseBody = await response.text();
446
+ let error;
447
+ try {
448
+ error = JSON.parse(responseBody);
449
+ } catch {
450
+ error = responseBody;
451
+ }
452
+ import_log3.log.error("error", {
453
+ error
454
+ }, {
455
+ F: __dxlog_file2,
456
+ L: 257,
457
+ S: void 0,
458
+ C: (f, a) => f(...a)
459
+ });
460
+ throw new Error(error.message);
461
+ } else {
462
+ const error = await response.text();
463
+ import_log3.log.error("error", {
464
+ error
465
+ }, {
466
+ F: __dxlog_file2,
467
+ L: 261,
468
+ S: void 0,
469
+ C: (f, a) => f(...a)
470
+ });
471
+ throw new Error(error);
472
+ }
473
+ }
474
+ };
475
+ var getEndpointUrl = (endpoint) => {
476
+ let url = "";
477
+ if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
478
+ url = endpoint.document.servers[0].url;
479
+ } else {
480
+ (0, import_invariant.invariant)(!isV3_1(endpoint.document), void 0, {
481
+ F: __dxlog_file2,
482
+ L: 272,
483
+ S: void 0,
484
+ A: [
485
+ "!isV3_1(endpoint.document)",
486
+ ""
487
+ ]
488
+ });
489
+ url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
490
+ }
491
+ if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
492
+ url += endpoint.document.basePath;
493
+ }
494
+ url += endpoint.path;
495
+ return url;
496
+ };
497
+ var resolveAuthorization = async (authorization) => {
498
+ switch (authorization.type) {
499
+ case "api-key": {
500
+ (0, import_invariant.invariant)(authorization.placement.type === "authorization-header", void 0, {
501
+ F: __dxlog_file2,
502
+ L: 288,
503
+ S: void 0,
504
+ A: [
505
+ "authorization.placement.type === 'authorization-header'",
506
+ ""
507
+ ]
508
+ });
509
+ return `Bearer ${authorization.key}`;
510
+ }
511
+ case "oauth": {
512
+ const response = await fetch(authorization.tokenUrl, {
513
+ method: "POST",
514
+ headers: {
515
+ "Content-Type": "application/x-www-form-urlencoded"
516
+ },
517
+ body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
518
+ });
519
+ const data = await response.json();
520
+ return `Bearer ${data.access_token}`;
521
+ }
522
+ default: {
523
+ throw new Error(`Unknown authorization type: ${authorization.type}`);
524
+ }
525
+ }
526
+ };
527
+ var resolveJsonSchema = (schema, base) => {
528
+ return (0, import_util.deepMapValues)(schema, (value, recurse) => {
529
+ if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
530
+ if (value.$ref.startsWith("#")) {
531
+ const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
532
+ if (resolved) {
533
+ return recurse(resolved);
534
+ } else {
535
+ import_log3.log.warn("unresolved", {
536
+ ref: value.$ref,
537
+ base
538
+ }, {
539
+ F: __dxlog_file2,
540
+ L: 321,
541
+ S: void 0,
542
+ C: (f, a) => f(...a)
543
+ });
544
+ }
545
+ }
546
+ }
547
+ return recurse(value);
548
+ });
549
+ };
550
+ var isV3_1 = (document2) => {
551
+ return document2.openapi === "3.0.1";
552
+ };
553
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Toolbox/Toolbox.tsx";
554
+ var stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
555
+ var Toolbox = ({ classNames, artifacts, functions: functions2, services, striped }) => {
556
+ const gridClassNames = "grid grid-cols-[8rem_8rem_1fr]";
557
+ const subGridClassNames = (0, import_react_ui_theme.mx)("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
558
+ return /* @__PURE__ */ import_react.default.createElement("div", {
559
+ className: (0, import_react_ui_theme.mx)("flex flex-col overflow-y-auto box-content", classNames)
560
+ }, artifacts && artifacts.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h1", {
561
+ className: "px-2 text-sm"
562
+ }, "Artifacts"), /* @__PURE__ */ import_react.default.createElement("div", {
563
+ className: gridClassNames
564
+ }, artifacts.map(({ id, description, tools }) => /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, {
565
+ key: id
566
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
567
+ className: subGridClassNames
568
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
569
+ className: "text-primary-500 truncate"
570
+ }, id), /* @__PURE__ */ import_react.default.createElement("div", {
571
+ className: "col-span-2 line-clamp-2"
572
+ }, description)), tools.map(({ name, description: description2 }, i) => /* @__PURE__ */ import_react.default.createElement("div", {
573
+ key: `${name}-${i}`,
574
+ className: subGridClassNames
575
+ }, /* @__PURE__ */ import_react.default.createElement("div", null), /* @__PURE__ */ import_react.default.createElement("div", {
576
+ className: "truncate"
577
+ }, name), /* @__PURE__ */ import_react.default.createElement("div", {
578
+ className: "text-subdued line-clamp-3"
579
+ }, description2))))))), services && services.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h1", {
580
+ className: "px-2 text-sm"
581
+ }, "Services"), /* @__PURE__ */ import_react.default.createElement("div", {
582
+ className: gridClassNames
583
+ }, services.map(({ service, tools }) => /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, {
584
+ key: service.serviceId
585
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
586
+ className: subGridClassNames
587
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
588
+ className: "text-primary-500 truncate"
589
+ }, service.name ?? service.serviceId), /* @__PURE__ */ import_react.default.createElement("div", {
590
+ className: "col-span-2 line-clamp-2"
591
+ }, service.description)), tools.map(({ name, description }, i) => /* @__PURE__ */ import_react.default.createElement("div", {
592
+ key: name,
593
+ className: (0, import_react_ui_theme.mx)(subGridClassNames, striped && stripeClassNames)
594
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
595
+ className: "text-primary-500 truncate"
596
+ }, i === 0 && service.serviceId), /* @__PURE__ */ import_react.default.createElement("div", {
597
+ className: "truncate"
598
+ }, name), /* @__PURE__ */ import_react.default.createElement("div", {
599
+ className: "truncate"
600
+ }, description))))))), functions2 && functions2.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h1", {
601
+ className: "px-2 text-sm"
602
+ }, "Functions"), /* @__PURE__ */ import_react.default.createElement("div", {
603
+ className: gridClassNames
604
+ }, functions2.map(({ name, description }) => /* @__PURE__ */ import_react.default.createElement("div", {
605
+ key: name,
606
+ className: (0, import_react_ui_theme.mx)(subGridClassNames, striped && stripeClassNames)
607
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
608
+ className: "text-primary-500 truncate"
609
+ }, "function"), /* @__PURE__ */ import_react.default.createElement("div", {
610
+ className: "truncate"
611
+ }, name), /* @__PURE__ */ import_react.default.createElement("div", {
612
+ className: "truncate"
613
+ }, description))))));
614
+ };
615
+ var ToolboxContainer = ({ classNames, space }) => {
616
+ const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
617
+ const functions2 = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionType));
618
+ const services = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_chunk_UVWK2XJE.ServiceType));
619
+ const [serviceTools, setServiceTools] = (0, import_react.useState)([]);
620
+ (0, import_react.useEffect)(() => {
621
+ (0, import_log.log)("creating service tools...", void 0, {
622
+ F: __dxlog_file3,
623
+ L: 104,
624
+ S: void 0,
625
+ C: (f, a) => f(...a)
626
+ });
627
+ queueMicrotask(async () => {
628
+ const tools = await Promise.all(services.map(async (service) => ({
629
+ service,
630
+ tools: await createToolsFromService(service)
631
+ })));
632
+ setServiceTools(tools);
633
+ });
634
+ }, [
635
+ services
636
+ ]);
637
+ return /* @__PURE__ */ import_react.default.createElement(Toolbox, {
638
+ classNames,
639
+ artifacts: artifactDefinitions,
640
+ functions: functions2,
641
+ services: serviceTools
642
+ });
643
+ };
644
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Thread/ToolInvocations.tsx";
645
+ var isToolMessage = (message) => {
646
+ return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
647
+ };
648
+ var ToolBlock = ({ classNames, message }) => {
649
+ const { content = [] } = message;
650
+ let request;
651
+ const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
652
+ const items = blocks.map((block, i) => {
653
+ switch (block.type) {
654
+ case "tool_use": {
655
+ if (block.id === request?.id && block.pending) {
656
+ return null;
657
+ }
658
+ request = block;
659
+ return {
660
+ title: `Calling ${block.name}...`,
661
+ block
662
+ };
663
+ }
664
+ case "tool_result": {
665
+ if (!request) {
666
+ import_log4.log.warn("unexpected message", {
667
+ block
668
+ }, {
669
+ F: __dxlog_file4,
670
+ L: 41,
671
+ S: void 0,
672
+ C: (f, a) => f(...a)
673
+ });
674
+ return {
675
+ title: "Error",
676
+ block
677
+ };
678
+ }
679
+ return {
680
+ title: `Processed ${request.name}`,
681
+ block
682
+ };
683
+ }
684
+ default: {
685
+ request = void 0;
686
+ return {
687
+ title: "Error",
688
+ block
689
+ };
690
+ }
691
+ }
692
+ }).filter(import_util4.isNonNullable);
693
+ return /* @__PURE__ */ import_react4.default.createElement(ToolContainer, {
694
+ classNames,
695
+ items
696
+ });
697
+ };
698
+ var ToolContainer = ({ classNames, items }) => {
699
+ const tabsRef = (0, import_react4.useRef)(null);
700
+ const [selected, setSelected] = (0, import_react4.useState)(0);
701
+ const [open, setOpen] = (0, import_react4.useState)(false);
702
+ (0, import_react4.useEffect)(() => {
703
+ if (open) {
704
+ tabsRef.current?.focus();
705
+ }
706
+ }, [
707
+ open
708
+ ]);
709
+ const handleSelect = (index) => {
710
+ if (index === selected) {
711
+ setOpen(false);
712
+ } else {
713
+ setSelected(index);
714
+ }
715
+ };
716
+ const title = (0, import_react4.useMemo)(() => {
717
+ const lines = items.map((item) => item.title).filter(import_util4.isNotFalsy);
718
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.StatusRoll, {
719
+ key: "status-roll",
720
+ lines,
721
+ autoAdvance: true
722
+ });
723
+ }, [
724
+ items
725
+ ]);
726
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.ToggleContainer, {
727
+ classNames: [
728
+ "flex flex-col",
729
+ classNames
730
+ ],
731
+ title,
732
+ open,
733
+ onChangeOpen: setOpen
734
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
735
+ className: "grid grid-cols-[32px_1fr]"
736
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.NumericTabs, {
737
+ ref: tabsRef,
738
+ length: items.length,
739
+ selected,
740
+ onSelect: handleSelect
741
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_syntax_highlighter2.Json, {
742
+ data: items[selected].block,
743
+ classNames: "!p-1 text-xs"
744
+ })));
745
+ };
746
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadMessage.tsx";
747
+ var panelClassNames = "flex flex-col w-full px-2 bg-groupSurface rounded-md";
748
+ var userClassNames = "bg-[--user-fill]";
749
+ var ToggleContainer2 = (props) => {
750
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.ToggleContainer, {
751
+ ...props,
752
+ classNames: (0, import_react_ui_theme3.mx)(panelClassNames, props.classNames)
753
+ });
754
+ };
755
+ var MessageContainer = ({ children, classNames, user }) => {
756
+ if (!children) {
757
+ return null;
758
+ }
759
+ return /* @__PURE__ */ import_react3.default.createElement("div", {
760
+ role: "list-item",
761
+ className: (0, import_react_ui_theme3.mx)("flex w-full", user && "justify-end", classNames)
762
+ }, /* @__PURE__ */ import_react3.default.createElement("div", {
763
+ className: (0, import_react_ui_theme3.mx)(user ? [
764
+ "px-2 py-1 rounded-md",
765
+ userClassNames
766
+ ] : "w-full")
767
+ }, children));
768
+ };
769
+ var ThreadMessage = ({ classNames, space, message, onPrompt }) => {
770
+ const { role, content = [] } = message;
771
+ if (isToolMessage(message)) {
772
+ return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
773
+ classNames
774
+ }, /* @__PURE__ */ import_react3.default.createElement(ToolBlock, {
775
+ space,
776
+ classNames: panelClassNames,
777
+ message
778
+ }));
779
+ }
780
+ return content.map((block, idx) => {
781
+ if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
782
+ return null;
783
+ }
784
+ const Component = components[block.type] ?? components.default;
785
+ return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
786
+ key: idx,
787
+ classNames,
788
+ user: block.type === "text" && role === "user"
789
+ }, /* @__PURE__ */ import_react3.default.createElement(Component, {
790
+ space,
791
+ block,
792
+ onPrompt
793
+ }));
794
+ });
795
+ };
796
+ var components = {
797
+ //
798
+ // Text
799
+ //
800
+ ["text"]: ({ block }) => {
801
+ (0, import_invariant2.invariant)(block.type === "text", void 0, {
802
+ F: __dxlog_file5,
803
+ L: 85,
804
+ S: void 0,
805
+ A: [
806
+ "block.type === 'text'",
807
+ ""
808
+ ]
809
+ });
810
+ const title = block.disposition ? titles[block.disposition] : void 0;
811
+ if (!title) {
812
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.MarkdownViewer, {
813
+ content: block.text
814
+ });
815
+ }
816
+ return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
817
+ // open={open}
818
+ defaultOpen: block.disposition === "cot" && block.pending,
819
+ title,
820
+ icon: block.pending ? /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Icon, {
821
+ icon: "ph--circle-notch--regular",
822
+ classNames: "text-subdued ml-2 animate-spin",
823
+ size: 4
824
+ }) : void 0
825
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.MarkdownViewer, {
826
+ content: block.text,
827
+ classNames: [
828
+ "pbe-2",
829
+ block.disposition === "cot" && "text-sm text-subdued"
830
+ ]
831
+ }));
832
+ },
833
+ //
834
+ // JSON
835
+ //
836
+ ["json"]: ({ space, block, onPrompt }) => {
837
+ (0, import_invariant2.invariant)(block.type === "json", void 0, {
838
+ F: __dxlog_file5,
839
+ L: 123,
840
+ S: void 0,
841
+ A: [
842
+ "block.type === 'json'",
843
+ ""
844
+ ]
845
+ });
846
+ switch (block.disposition) {
847
+ case "tool_list": {
848
+ return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
849
+ title: titles[block.disposition],
850
+ defaultOpen: true
851
+ }, /* @__PURE__ */ import_react3.default.createElement(ToolboxContainer, {
852
+ space,
853
+ classNames: "pbe-2"
854
+ }));
855
+ }
856
+ case "suggest": {
857
+ const { text = "" } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
858
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui.IconButton, {
859
+ icon: "ph--lightning--regular",
860
+ label: text,
861
+ onClick: () => onPrompt?.(text)
862
+ });
863
+ }
864
+ case "select": {
865
+ const { options = [] } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
866
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui.ButtonGroup, null, options.map((option) => /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Button, {
867
+ key: option,
868
+ onClick: () => onPrompt?.(option)
869
+ }, option)));
870
+ }
871
+ default: {
872
+ const title = block.disposition ? titles[block.disposition] : void 0;
873
+ return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
874
+ title: title ?? "JSON"
875
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
876
+ data: (0, import_util3.safeParseJson)(block.json ?? block),
877
+ classNames: "!p-1 text-xs"
878
+ }));
879
+ }
880
+ }
881
+ },
882
+ //
883
+ // Default
884
+ //
885
+ default: ({ block }) => {
886
+ let title = titles[block.type];
887
+ if (block.type === "tool_use") {
888
+ title = `Tool [${block.name}]`;
889
+ }
890
+ return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
891
+ title: title ?? "JSON"
892
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
893
+ data: block,
894
+ classNames: "!p-1 text-xs"
895
+ }));
896
+ }
897
+ };
898
+ var titles = {
899
+ ["cot"]: "Chain of thought",
900
+ ["artifact"]: "Artifact",
901
+ ["tool_use"]: "Tool request",
902
+ ["tool_result"]: "Tool result",
903
+ ["tool_list"]: "Tools"
904
+ };
905
+ var messageReducer = ({ current, messages }, message) => {
906
+ let i = 0;
907
+ for (const block of message.content) {
908
+ switch (block.type) {
909
+ case "tool_use":
910
+ case "tool_result": {
911
+ if (current) {
912
+ current.content.push(block);
913
+ } else {
914
+ current = {
915
+ id: [
916
+ message.id,
917
+ i
918
+ ].join("_"),
919
+ role: message.role,
920
+ content: [
921
+ block
922
+ ]
923
+ };
924
+ messages.push(current);
925
+ }
926
+ break;
927
+ }
928
+ case "text":
929
+ default: {
930
+ current = void 0;
931
+ messages.push({
932
+ id: [
933
+ message.id,
934
+ i
935
+ ].join("_"),
936
+ role: message.role,
937
+ content: [
938
+ block
939
+ ]
940
+ });
941
+ break;
942
+ }
943
+ }
944
+ i++;
945
+ }
946
+ return {
947
+ current,
948
+ messages
949
+ };
950
+ };
951
+ var createAutocompleteExtension = ({ onSubmit, onSuggest }) => {
952
+ const suggestionPlugin = import_view.ViewPlugin.fromClass(class {
953
+ constructor(view) {
954
+ this._currentSuggestion = null;
955
+ this._decorations = this.computeDecorations(view);
956
+ }
957
+ update(update) {
958
+ if (update.docChanged || update.selectionSet) {
959
+ this._decorations = this.computeDecorations(update.view);
960
+ }
961
+ }
962
+ computeDecorations(view) {
963
+ const text = view.state.doc.toString();
964
+ const suggestions = onSuggest?.(text) ?? [];
965
+ if (!suggestions.length) {
966
+ this._currentSuggestion = null;
967
+ return import_view.Decoration.none;
968
+ }
969
+ this._currentSuggestion = suggestions[0];
970
+ const suffix = this._currentSuggestion.slice(text.length);
971
+ if (!suffix) {
972
+ return import_view.Decoration.none;
973
+ }
974
+ return import_view.Decoration.set([
975
+ import_view.Decoration.widget({
976
+ widget: new InlineSuggestionWidget(suffix),
977
+ side: 1
978
+ }).range(view.state.doc.length)
979
+ ]);
980
+ }
981
+ completeSuggestion(view) {
982
+ if (!this._currentSuggestion) {
983
+ return false;
984
+ }
985
+ const text = view.state.doc.toString();
986
+ const suffix = this._currentSuggestion.slice(text.length);
987
+ if (!suffix) {
988
+ return false;
989
+ }
990
+ view.dispatch({
991
+ changes: {
992
+ from: view.state.doc.length,
993
+ insert: suffix
994
+ },
995
+ selection: {
996
+ anchor: view.state.doc.length + suffix.length
997
+ }
998
+ });
999
+ return true;
1000
+ }
1001
+ }, {
1002
+ decorations: (v) => v._decorations
1003
+ });
1004
+ return [
1005
+ suggestionPlugin,
1006
+ import_view.EditorView.theme({
1007
+ ".cm-inline-suggestion": {
1008
+ opacity: 0.4
1009
+ }
1010
+ }),
1011
+ // Accept the current suggestion.
1012
+ import_state.Prec.highest(import_view.keymap.of([
1013
+ {
1014
+ key: "Tab",
1015
+ preventDefault: true,
1016
+ run: (view) => {
1017
+ const plugin = view.plugin(suggestionPlugin);
1018
+ return plugin?.completeSuggestion(view) ?? false;
1019
+ }
1020
+ },
1021
+ {
1022
+ key: "ArrowRight",
1023
+ preventDefault: true,
1024
+ run: (view) => {
1025
+ if (view.state.selection.main.head !== view.state.doc.length) {
1026
+ return false;
1027
+ }
1028
+ const plugin = view.plugin(suggestionPlugin);
1029
+ return plugin?.completeSuggestion(view) ?? false;
1030
+ }
1031
+ },
1032
+ {
1033
+ key: "Enter",
1034
+ preventDefault: true,
1035
+ run: (view) => {
1036
+ const text = view.state.doc.toString().trim();
1037
+ if (text.length > 0 && onSubmit) {
1038
+ const reset = onSubmit(text);
1039
+ if (reset) {
1040
+ view.dispatch({
1041
+ changes: {
1042
+ from: 0,
1043
+ to: view.state.doc.length,
1044
+ insert: ""
1045
+ }
1046
+ });
1047
+ }
1048
+ }
1049
+ return true;
1050
+ }
1051
+ },
1052
+ {
1053
+ key: "Shift-Enter",
1054
+ preventDefault: true,
1055
+ run: (view) => {
1056
+ view.dispatch({
1057
+ changes: {
1058
+ from: view.state.selection.main.head,
1059
+ insert: "\n"
1060
+ },
1061
+ selection: {
1062
+ anchor: view.state.selection.main.head + 1,
1063
+ head: view.state.selection.main.head + 1
1064
+ }
1065
+ });
1066
+ return true;
1067
+ }
1068
+ },
1069
+ {
1070
+ key: "Escape",
1071
+ preventDefault: true,
1072
+ run: (view) => {
1073
+ view.dispatch({
1074
+ changes: {
1075
+ from: 0,
1076
+ to: view.state.doc.length,
1077
+ insert: ""
1078
+ }
1079
+ });
1080
+ return true;
1081
+ }
1082
+ }
1083
+ ]))
1084
+ ];
1085
+ };
1086
+ var InlineSuggestionWidget = class extends import_view.WidgetType {
1087
+ constructor(suffix) {
1088
+ super();
1089
+ this.suffix = suffix;
1090
+ }
1091
+ toDOM() {
1092
+ const span = document.createElement("span");
1093
+ span.textContent = this.suffix;
1094
+ span.className = "cm-inline-suggestion";
1095
+ return span;
1096
+ }
1097
+ eq(other) {
1098
+ return other.suffix === this.suffix;
1099
+ }
1100
+ };
1101
+ var Prompt = /* @__PURE__ */ (0, import_react5.forwardRef)(({ classNames, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onOpenChange }, forwardRef2) => {
1102
+ const { themeMode } = (0, import_react_ui2.useThemeContext)();
1103
+ const { parentRef, view } = (0, import_react_ui_editor.useTextEditor)({
1104
+ autoFocus,
1105
+ extensions: [
1106
+ (0, import_react_ui_editor.createBasicExtensions)({
1107
+ bracketMatching: false,
1108
+ lineWrapping,
1109
+ placeholder
1110
+ }),
1111
+ (0, import_react_ui_editor.createThemeExtensions)({
1112
+ themeMode
1113
+ }),
1114
+ createAutocompleteExtension({
1115
+ onSubmit,
1116
+ onSuggest
1117
+ }),
1118
+ import_react_ui_editor.keymap.of([
1119
+ {
1120
+ key: "Alt-ArrowUp",
1121
+ preventDefault: true,
1122
+ run: (view2) => {
1123
+ onOpenChange?.(true);
1124
+ return true;
1125
+ }
1126
+ },
1127
+ {
1128
+ key: "Alt-ArrowDown",
1129
+ preventDefault: true,
1130
+ run: (view2) => {
1131
+ onOpenChange?.(false);
1132
+ return true;
1133
+ }
1134
+ }
1135
+ ])
1136
+ ]
1137
+ }, [
1138
+ themeMode,
1139
+ onSubmit,
1140
+ onSuggest
1141
+ ]);
1142
+ (0, import_react5.useImperativeHandle)(forwardRef2, () => {
1143
+ return {
1144
+ focus: () => {
1145
+ view?.focus();
1146
+ },
1147
+ setText: (text) => {
1148
+ view?.dispatch({
1149
+ changes: {
1150
+ from: 0,
1151
+ to: view.state.doc.length,
1152
+ insert: text
1153
+ },
1154
+ selection: {
1155
+ anchor: text.length,
1156
+ head: text.length
1157
+ }
1158
+ });
1159
+ }
1160
+ };
1161
+ }, [
1162
+ view,
1163
+ onSubmit
1164
+ ]);
1165
+ return /* @__PURE__ */ import_react5.default.createElement("div", {
1166
+ ref: parentRef,
1167
+ className: (0, import_react_ui_theme4.mx)("w-full overflow-hidden", classNames)
1168
+ });
1169
+ });
1170
+ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, ...props }) => {
1171
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BAQRBGOJ.AUTOMATION_PLUGIN);
1172
+ const promptRef = (0, import_react6.useRef)(null);
1173
+ const [active, setActive] = (0, import_react6.useState)(false);
1174
+ const { recording } = (0, import_plugin_transcription.useVoiceInput)({
1175
+ active,
1176
+ onUpdate: (text) => {
1177
+ promptRef.current?.setText(text);
1178
+ promptRef.current?.focus();
1179
+ }
1180
+ });
1181
+ return /* @__PURE__ */ import_react6.default.createElement("div", {
1182
+ className: (0, import_react_ui_theme5.mx)("flex shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
1183
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
1184
+ className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
1185
+ }, error && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Icon, {
1186
+ icon: "ph--warning-circle--regular",
1187
+ classNames: import_react_ui_theme5.errorText,
1188
+ size: 5
1189
+ }) || /* @__PURE__ */ import_react6.default.createElement(import_react_ui_sfx.Spinner, {
1190
+ active: processing
1191
+ })), /* @__PURE__ */ import_react6.default.createElement(Prompt, {
1192
+ ref: promptRef,
1193
+ autoFocus: true,
1194
+ classNames: "pbs-2",
1195
+ lineWrapping: true,
1196
+ placeholder: placeholder ?? t("prompt placeholder"),
1197
+ ...props
1198
+ }), (onCancel || microphone) && /* @__PURE__ */ import_react6.default.createElement("div", {
1199
+ className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
1200
+ }, processing && onCancel && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
1201
+ classNames: "px-1.5",
1202
+ variant: "ghost",
1203
+ size: 5,
1204
+ icon: "ph--x--regular",
1205
+ iconOnly: true,
1206
+ label: t("cancel processing button"),
1207
+ onClick: onCancel
1208
+ }), !processing && microphone && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
1209
+ classNames: (0, import_react_ui_theme5.mx)("px-1.5", recording && "bg-primary-500"),
1210
+ variant: "ghost",
1211
+ size: 5,
1212
+ icon: "ph--microphone--regular",
1213
+ iconOnly: true,
1214
+ noTooltip: true,
1215
+ label: t("microphone button"),
1216
+ onMouseDown: () => setActive(true),
1217
+ onMouseUp: () => setActive(false),
1218
+ onTouchStart: () => setActive(true),
1219
+ onTouchEnd: () => setActive(false)
1220
+ })));
1221
+ };
1222
+ var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, ...props }) => {
1223
+ const scroller = (0, import_react2.useRef)(null);
1224
+ const identity = (0, import_halo.useIdentity)();
1225
+ const fallbackValue = (0, import_util2.keyToFallback)(identity.identityKey);
1226
+ const userHue = identity.profile?.data?.hue || fallbackValue.hue;
1227
+ const handleSubmit = (0, import_react2.useCallback)((value) => {
1228
+ onSubmit?.(value);
1229
+ scroller.current?.scrollToBottom();
1230
+ return true;
1231
+ }, [
1232
+ onSubmit
1233
+ ]);
1234
+ const { messages: filteredMessages = [] } = (0, import_react2.useMemo)(() => {
1235
+ if (collapse) {
1236
+ return (messages ?? []).reduce(messageReducer, {
1237
+ messages: []
1238
+ });
1239
+ } else {
1240
+ return {
1241
+ messages: messages ?? []
1242
+ };
1243
+ }
1244
+ }, [
1245
+ messages,
1246
+ collapse
1247
+ ]);
1248
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
1249
+ role: "none",
1250
+ className: (0, import_react_ui_theme2.mx)("flex flex-col grow overflow-hidden", classNames)
1251
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui_components.ScrollContainer, {
1252
+ ref: scroller,
1253
+ fade: true
1254
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
1255
+ role: "none",
1256
+ className: (0, import_react_ui_theme2.mx)(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1257
+ style: {
1258
+ "--user-fill": `var(--dx-${userHue}Fill)`
1259
+ }
1260
+ }, filteredMessages.map((message) => /* @__PURE__ */ import_react2.default.createElement(ThreadMessage, {
1261
+ key: message.id,
1262
+ classNames: "px-4 pbe-4",
1263
+ space,
1264
+ message,
1265
+ ...props
1266
+ })))), onSubmit && /* @__PURE__ */ import_react2.default.createElement(PromptBar, {
1267
+ microphone: transcription,
1268
+ processing,
1269
+ error,
1270
+ onSubmit: handleSubmit,
1271
+ onCancel,
1272
+ onOpenChange
1273
+ }));
1274
+ };
1275
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/hooks/processor.ts";
1276
+ var defaultOptions = {
1277
+ model: import_assistant.DEFAULT_LLM_MODEL,
1278
+ systemPrompt: "you are a helpful assistant"
1279
+ };
1280
+ var ChatProcessor = class {
1281
+ constructor(_client, _tools, _extensions, _options = defaultOptions) {
1282
+ this._client = _client;
1283
+ this._tools = _tools;
1284
+ this._extensions = _extensions;
1285
+ this._options = _options;
1286
+ this._parser = new import_assistant.MixedStreamParser();
1287
+ this._pending = (0, import_signals_core.signal)([]);
1288
+ this._block = (0, import_signals_core.signal)(void 0);
1289
+ this._history = [];
1290
+ this.streaming = (0, import_signals_core.computed)(() => this._block.value !== void 0);
1291
+ this.error = (0, import_signals_core.signal)(void 0);
1292
+ this.messages = (0, import_signals_core.computed)(() => {
1293
+ const messages = [
1294
+ ...this._pending.value
1295
+ ];
1296
+ if (this._block.value) {
1297
+ const current = messages.pop();
1298
+ (0, import_invariant4.invariant)(current, void 0, {
1299
+ F: __dxlog_file6,
1300
+ L: 85,
1301
+ S: this,
1302
+ A: [
1303
+ "current",
1304
+ ""
1305
+ ]
1306
+ });
1307
+ const { content, ...rest } = current;
1308
+ const message = {
1309
+ ...rest,
1310
+ content: [
1311
+ ...content,
1312
+ this._block.value
1313
+ ]
1314
+ };
1315
+ messages.push(message);
1316
+ }
1317
+ return messages;
1318
+ });
1319
+ this._parser.message.on((message) => {
1320
+ (0, import_signals_core.batch)(() => {
1321
+ this._pending.value = [
1322
+ ...this._pending.value,
1323
+ message
1324
+ ];
1325
+ this._block.value = void 0;
1326
+ });
1327
+ });
1328
+ this._parser.update.on((block) => {
1329
+ (0, import_signals_core.batch)(() => {
1330
+ this._block.value = block;
1331
+ });
1332
+ });
1333
+ }
1334
+ /**
1335
+ * Update tools.
1336
+ */
1337
+ setTools(tools) {
1338
+ this._tools = tools;
1339
+ }
1340
+ /**
1341
+ * Make GPT request.
1342
+ */
1343
+ async request(message, options = {}) {
1344
+ (0, import_signals_core.batch)(() => {
1345
+ this._history = options.history ?? [];
1346
+ this._pending.value = [
1347
+ (0, import_echo_schema3.createStatic)(import_artifact3.Message, {
1348
+ role: "user",
1349
+ content: [
1350
+ {
1351
+ type: "text",
1352
+ text: message
1353
+ }
1354
+ ]
1355
+ })
1356
+ ];
1357
+ this._block.value = void 0;
1358
+ });
1359
+ await this._generate();
1360
+ options.onComplete?.(this._pending.value);
1361
+ return this._reset();
1362
+ }
1363
+ /**
1364
+ * Cancel pending requests.
1365
+ * @returns Pending requests (incl. the request message).
1366
+ */
1367
+ async cancel() {
1368
+ import_log6.log.info("cancelling...", void 0, {
1369
+ F: __dxlog_file6,
1370
+ L: 148,
1371
+ S: this,
1372
+ C: (f, a) => f(...a)
1373
+ });
1374
+ this._stream?.abort();
1375
+ return this._reset();
1376
+ }
1377
+ async _reset() {
1378
+ const messages = this._pending.value;
1379
+ (0, import_signals_core.batch)(() => {
1380
+ this._history = [];
1381
+ this._pending.value = [];
1382
+ this._block.value = void 0;
1383
+ });
1384
+ return messages;
1385
+ }
1386
+ /**
1387
+ * Generate a response from the AI service.
1388
+ * Iterates over tool requests.
1389
+ */
1390
+ async _generate() {
1391
+ try {
1392
+ let more = false;
1393
+ do {
1394
+ import_log6.log.info("requesting", {
1395
+ history: this._history.length,
1396
+ messages: this._pending.value.length
1397
+ }, {
1398
+ F: __dxlog_file6,
1399
+ L: 172,
1400
+ S: this,
1401
+ C: (f, a) => f(...a)
1402
+ });
1403
+ this._stream = await this._client.generate({
1404
+ ...this._options,
1405
+ // TODO(burdon): Rename messages or separate history/message.
1406
+ history: [
1407
+ ...this._history,
1408
+ ...this._pending.value
1409
+ ],
1410
+ tools: this._tools
1411
+ });
1412
+ await this._parser.parse(this._stream);
1413
+ await this._stream.complete();
1414
+ import_log6.log.info("response", {
1415
+ messages: this._pending.value
1416
+ }, {
1417
+ F: __dxlog_file6,
1418
+ L: 185,
1419
+ S: this,
1420
+ C: (f, a) => f(...a)
1421
+ });
1422
+ more = false;
1423
+ const message = this._pending.value.at(-1);
1424
+ (0, import_invariant4.invariant)(message, void 0, {
1425
+ F: __dxlog_file6,
1426
+ L: 190,
1427
+ S: this,
1428
+ A: [
1429
+ "message",
1430
+ ""
1431
+ ]
1432
+ });
1433
+ if ((0, import_assistant.isToolUse)(message)) {
1434
+ import_log6.log.info("tool request...", void 0, {
1435
+ F: __dxlog_file6,
1436
+ L: 192,
1437
+ S: this,
1438
+ C: (f, a) => f(...a)
1439
+ });
1440
+ const response = await (0, import_assistant.runTools)({
1441
+ message: this._pending.value.at(-1),
1442
+ tools: this._tools ?? [],
1443
+ extensions: this._extensions
1444
+ });
1445
+ import_log6.log.info("tool response", {
1446
+ response
1447
+ }, {
1448
+ F: __dxlog_file6,
1449
+ L: 199,
1450
+ S: this,
1451
+ C: (f, a) => f(...a)
1452
+ });
1453
+ switch (response.type) {
1454
+ case "continue": {
1455
+ this._pending.value = [
1456
+ ...this._pending.value,
1457
+ response.message
1458
+ ];
1459
+ more = true;
1460
+ break;
1461
+ }
1462
+ }
1463
+ }
1464
+ } while (more);
1465
+ import_log6.log.info("done", void 0, {
1466
+ F: __dxlog_file6,
1467
+ L: 210,
1468
+ S: this,
1469
+ C: (f, a) => f(...a)
1470
+ });
1471
+ } catch (err) {
1472
+ import_log6.log.catch(err, void 0, {
1473
+ F: __dxlog_file6,
1474
+ L: 212,
1475
+ S: this,
1476
+ C: (f, a) => f(...a)
1477
+ });
1478
+ this.error.value = new Error("AI service error", {
1479
+ cause: err
1480
+ });
1481
+ } finally {
1482
+ this._stream = void 0;
1483
+ this.error.value = void 0;
1484
+ }
1485
+ }
1486
+ };
1487
+ var AiClient = (0, import_app_framework3.lazy)(() => import("./ai-client-L5GUSAER.cjs"));
1488
+ var AutomationSettings = (0, import_app_framework3.lazy)(() => import("./settings-GOIB2WJQ.cjs"));
1489
+ var AppGraphBuilder = (0, import_app_framework3.lazy)(() => import("./app-graph-builder-ECNVGTRT.cjs"));
1490
+ var IntentResolver = (0, import_app_framework3.lazy)(() => import("./intent-resolver-4MQZULXW.cjs"));
1491
+ var ReactSurface = (0, import_app_framework3.lazy)(() => import("./react-surface-4RVHY6WI.cjs"));
1492
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/hooks/useChatProcessor.tsx";
1493
+ var useChatProcessor = (space, settings) => {
1494
+ const aiClient = (0, import_app_framework2.useCapability)(import_chunk_VNBYGJ4K.AutomationCapabilities.AiClient);
1495
+ const globalTools = (0, import_app_framework2.useCapabilities)(import_app_framework2.Capabilities.Tools);
1496
+ const artifactDefinitions = (0, import_app_framework2.useCapabilities)(import_app_framework2.Capabilities.ArtifactDefinition);
1497
+ const { dispatchPromise: dispatch } = (0, import_app_framework2.useIntentDispatcher)();
1498
+ const services = (0, import_echo4.useQuery)(space, import_echo4.Filter.schema(import_chunk_UVWK2XJE.ServiceType));
1499
+ const [serviceTools, setServiceTools] = (0, import_react8.useState)([]);
1500
+ (0, import_react8.useEffect)(() => {
1501
+ (0, import_log7.log)("creating service tools...", void 0, {
1502
+ F: __dxlog_file7,
1503
+ L: 34,
1504
+ S: void 0,
1505
+ C: (f, a) => f(...a)
1506
+ });
1507
+ queueMicrotask(async () => {
1508
+ const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
1509
+ setServiceTools(tools2.flat());
1510
+ });
1511
+ }, [
1512
+ services
1513
+ ]);
1514
+ const config = (0, import_react_client.useConfig)();
1515
+ const functions2 = (0, import_echo4.useQuery)(space, import_echo4.Filter.schema(import_functions3.FunctionType));
1516
+ const [tools, extensions] = (0, import_react8.useMemo)(() => {
1517
+ (0, import_log7.log)("creating tools...", void 0, {
1518
+ F: __dxlog_file7,
1519
+ L: 45,
1520
+ S: void 0,
1521
+ C: (f, a) => f(...a)
1522
+ });
1523
+ const tools2 = [
1524
+ ...globalTools.flat(),
1525
+ ...artifactDefinitions.flatMap((definition) => definition.tools),
1526
+ ...serviceTools,
1527
+ ...functions2.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(import_util5.isNonNullable)
1528
+ ];
1529
+ const extensions2 = {
1530
+ space,
1531
+ dispatch
1532
+ };
1533
+ return [
1534
+ tools2,
1535
+ extensions2
1536
+ ];
1537
+ }, [
1538
+ dispatch,
1539
+ globalTools,
1540
+ artifactDefinitions,
1541
+ space,
1542
+ serviceTools,
1543
+ functions2
1544
+ ]);
1545
+ const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact4.createSystemPrompt)({
1546
+ artifacts: artifactDefinitions.map((definition) => definition.instructions)
1547
+ }), [
1548
+ artifactDefinitions
1549
+ ]);
1550
+ const processor = (0, import_react8.useMemo)(() => {
1551
+ (0, import_log7.log)("creating processor...", {
1552
+ settings
1553
+ }, {
1554
+ F: __dxlog_file7,
1555
+ L: 67,
1556
+ S: void 0,
1557
+ C: (f, a) => f(...a)
1558
+ });
1559
+ return new ChatProcessor(aiClient, tools, extensions, {
1560
+ // TODO(burdon): Remove defualt (let backend decide if not specified).
1561
+ model: settings?.llmModel ?? import_assistant2.DEFAULT_LLM_MODEL,
1562
+ // TOOD(burdon): Query.
1563
+ systemPrompt
1564
+ });
1565
+ }, [
1566
+ aiClient,
1567
+ tools,
1568
+ extensions,
1569
+ systemPrompt,
1570
+ settings?.llmModel
1571
+ ]);
1572
+ return processor;
1573
+ };
1574
+ var registerTriggersMutex = new import_async.Mutex();
1575
+ var useMessageQueue = (chat) => {
1576
+ const space = (0, import_echo6.getSpace)(chat);
1577
+ const queueDxn = (0, import_react10.useMemo)(() => {
1578
+ const dxn = space && chat?.queue.dxn;
1579
+ return dxn ? new import_keys2.DXN(import_keys2.DXN.kind.QUEUE, [
1580
+ import_keys2.QueueSubspaceTags.DATA,
1581
+ space.id,
1582
+ dxn.parts.at(-1)
1583
+ ]) : void 0;
1584
+ }, [
1585
+ space,
1586
+ chat?.queue.dxn
1587
+ ]);
1588
+ const edgeClient = (0, import_react_edge_client.useEdgeClient)();
1589
+ return (0, import_react_edge_client.useQueue)(edgeClient, queueDxn);
1590
+ };
1591
+ var functions = [
1592
+ {
1593
+ name: "example.com/function/chess",
1594
+ version: "0.1.0",
1595
+ inputSchema: (0, import_echo_schema4.toJsonSchema)(import_echo_schema4.S.Struct({
1596
+ level: import_echo_schema4.S.Number.annotations({
1597
+ [import_echo_schema4.AST.TitleAnnotationId]: "Level"
1598
+ })
1599
+ }))
1600
+ },
1601
+ {
1602
+ name: "example.com/function/forex",
1603
+ version: "0.1.0",
1604
+ binding: "FOREX",
1605
+ inputSchema: (0, import_echo_schema4.toJsonSchema)(import_echo_schema4.S.Struct({
1606
+ from: import_echo_schema4.S.String.annotations({
1607
+ [import_echo_schema4.AST.TitleAnnotationId]: "Currency from"
1608
+ }),
1609
+ to: import_echo_schema4.S.String.annotations({
1610
+ [import_echo_schema4.AST.TitleAnnotationId]: "Currency to"
1611
+ })
1612
+ }))
1613
+ }
1614
+ ];
1615
+ var MockServiceRegistry = class {
1616
+ async queryServices(query) {
1617
+ return TEST_SERVICES;
1618
+ }
1619
+ };
1620
+ var AMADEUS_AUTH = {
1621
+ type: "oauth",
1622
+ clientId: "BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG",
1623
+ clientSecret: "n4qldSN7usvD57gm",
1624
+ tokenUrl: "https://test.api.amadeus.com/v1/security/oauth2/token",
1625
+ grantType: "client_credentials"
1626
+ };
1627
+ var VISUAL_CROSSING_CREDENTIALS = {
1628
+ type: "api-key",
1629
+ key: "FDPRVS953KB4GQQLD25GRT975",
1630
+ placement: {
1631
+ type: "query",
1632
+ name: "key"
1633
+ }
1634
+ };
1635
+ var TEST_SERVICES = [
1636
+ (0, import_echo_schema5.createStatic)(import_chunk_UVWK2XJE.ServiceType, {
1637
+ serviceId: "amadeus.com/service/FlightSearch",
1638
+ name: "Amadeus Flight Search",
1639
+ description: "Search for local and international flights.",
1640
+ category: "travel",
1641
+ interfaces: [
1642
+ {
1643
+ kind: "api",
1644
+ schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json",
1645
+ authorization: AMADEUS_AUTH
1646
+ }
1647
+ ]
1648
+ }),
1649
+ (0, import_echo_schema5.createStatic)(import_chunk_UVWK2XJE.ServiceType, {
1650
+ serviceId: "amadeus.com/service/HotelSearch",
1651
+ name: "Amadeus Hotel Search",
1652
+ description: "Search for local and international hotels.",
1653
+ category: "travel",
1654
+ interfaces: [
1655
+ {
1656
+ kind: "api",
1657
+ schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json",
1658
+ authorization: AMADEUS_AUTH
1659
+ }
1660
+ ]
1661
+ }),
1662
+ (0, import_echo_schema5.createStatic)(import_chunk_UVWK2XJE.ServiceType, {
1663
+ serviceId: "visualcrossing.com/service/Weather",
1664
+ name: "Visual Crossing Weather",
1665
+ description: "Search for global weather forecasts.",
1666
+ category: "weather",
1667
+ interfaces: [
1668
+ {
1669
+ kind: "api",
1670
+ schemaUrl: "https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json",
1671
+ authorization: VISUAL_CROSSING_CREDENTIALS
1672
+ }
1673
+ ]
1674
+ }),
1675
+ // TODO(burdon): Needs auth.
1676
+ (0, import_echo_schema5.createStatic)(import_chunk_UVWK2XJE.ServiceType, {
1677
+ serviceId: "abstractapi.com/service/GeoLocation",
1678
+ name: "Abstract GeoLocation",
1679
+ description: "Get the location of any IP address.",
1680
+ category: "geolocation",
1681
+ interfaces: [
1682
+ {
1683
+ kind: "api",
1684
+ schemaUrl: "https://api.apis.guru/v2/specs/abstractapi.com/geolocation/1.0.0/openapi.json"
1685
+ }
1686
+ ]
1687
+ }),
1688
+ //
1689
+ // Testing
1690
+ //
1691
+ ...Array.from({
1692
+ length: 20
1693
+ }, (_, i) => (0, import_echo_schema5.createStatic)(import_chunk_UVWK2XJE.ServiceType, {
1694
+ serviceId: `example.com/service/test-${i}`,
1695
+ name: `Test ${i}`,
1696
+ description: `Test ${i}`,
1697
+ category: Object.keys(import_chunk_UVWK2XJE.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_UVWK2XJE.categoryIcons).length)],
1698
+ interfaces: [
1699
+ {
1700
+ kind: "api",
1701
+ schemaUrl: "https://petstore.swagger.io/v2/swagger.json"
1702
+ }
1703
+ ]
1704
+ }))
1705
+ ];
1706
+ var useServices = (space, query) => {
1707
+ const registry = (0, import_react11.useMemo)(() => new MockServiceRegistry(), []);
1708
+ const [services, setServices] = (0, import_react11.useState)([]);
1709
+ (0, import_react11.useEffect)(() => {
1710
+ const t = setTimeout(async () => {
1711
+ const services2 = await registry.queryServices(query);
1712
+ setServices(services2);
1713
+ });
1714
+ return () => clearTimeout(t);
1715
+ }, [
1716
+ query,
1717
+ registry
1718
+ ]);
1719
+ return services;
1720
+ };
1721
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadContainer.tsx";
1722
+ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) => {
1723
+ const space = (0, import_echo3.getSpace)(chat);
1724
+ const processor = useChatProcessor(space, settings);
1725
+ const messageQueue = useMessageQueue(chat);
1726
+ const messages = [
1727
+ ...messageQueue?.items ?? [],
1728
+ ...processor.messages.value
1729
+ ];
1730
+ const handleSubmit = (0, import_react7.useCallback)((text) => {
1731
+ if (processor.streaming.value) {
1732
+ import_log5.log.warn("ignoring submit; still processing.", void 0, {
1733
+ F: __dxlog_file8,
1734
+ L: 39,
1735
+ S: void 0,
1736
+ C: (f, a) => f(...a)
1737
+ });
1738
+ return false;
1739
+ }
1740
+ onOpenChange?.(true);
1741
+ (0, import_invariant3.invariant)(messageQueue, void 0, {
1742
+ F: __dxlog_file8,
1743
+ L: 45,
1744
+ S: void 0,
1745
+ A: [
1746
+ "messageQueue",
1747
+ ""
1748
+ ]
1749
+ });
1750
+ void processor.request(text, {
1751
+ history: messageQueue.items,
1752
+ onComplete: (messages2) => {
1753
+ messageQueue.append(messages2);
1754
+ }
1755
+ });
1756
+ return true;
1757
+ }, [
1758
+ processor,
1759
+ messageQueue,
1760
+ onOpenChange
1761
+ ]);
1762
+ const handleCancel = (0, import_react7.useCallback)(() => {
1763
+ if (processor.streaming.value) {
1764
+ void processor.cancel();
1765
+ }
1766
+ }, [
1767
+ processor
1768
+ ]);
1769
+ return /* @__PURE__ */ import_react7.default.createElement(Thread, {
1770
+ classNames,
1771
+ space,
1772
+ messages,
1773
+ processing: processor.streaming.value,
1774
+ error: processor.error.value,
1775
+ onSubmit: handleSubmit,
1776
+ onCancel: handleCancel,
1777
+ onPrompt: handleSubmit,
1778
+ onOpenChange,
1779
+ ...props
1780
+ });
1781
+ };
1782
+ // Annotate the CommonJS export names for ESM import in node:
1783
+ 0 && (module.exports = {
1784
+ AiClient,
1785
+ AppGraphBuilder,
1786
+ AutomationSettings,
1787
+ IntentResolver,
1788
+ ReactSurface,
1789
+ Thread,
1790
+ ThreadContainer,
1791
+ Toolbox,
1792
+ ToolboxContainer,
1793
+ useServices
1794
+ });
1795
+ //# sourceMappingURL=chunk-B37JIAOP.cjs.map