@dxos/plugin-automation 0.7.5-labs.ff2ff30 → 0.7.5-main.5ae2ba8

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 (317) hide show
  1. package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs +132 -0
  2. package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-R4JH4TLE.mjs → chunk-OFDNNRLE.mjs} +3 -8
  4. package/dist/lib/browser/chunk-OFDNNRLE.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-U7QLNY2S.mjs +8 -0
  6. package/dist/lib/browser/chunk-U7QLNY2S.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-WY2C7JY4.mjs +119 -0
  8. package/dist/lib/browser/chunk-WY2C7JY4.mjs.map +7 -0
  9. package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs +56 -0
  10. package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +21 -377
  12. package/dist/lib/browser/index.mjs.map +4 -4
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/react-surface-SAPMN4PF.mjs +27 -0
  15. package/dist/lib/browser/react-surface-SAPMN4PF.mjs.map +7 -0
  16. package/dist/lib/node/{chunk-QXIHYOMF.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -132
  17. package/dist/lib/node/AutomationPanel-X33HHDMQ.cjs.map +7 -0
  18. package/dist/lib/node/chunk-7Q5SNGCL.cjs +148 -0
  19. package/dist/lib/node/chunk-7Q5SNGCL.cjs.map +7 -0
  20. package/dist/lib/node/chunk-CB5OB6JH.cjs +40 -0
  21. package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-EQYHOTGG.cjs → chunk-ORMEYEBE.cjs} +6 -12
  23. package/dist/lib/node/chunk-ORMEYEBE.cjs.map +7 -0
  24. package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs +72 -0
  25. package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs.map +7 -0
  26. package/dist/lib/node/index.cjs +36 -378
  27. package/dist/lib/node/index.cjs.map +4 -4
  28. package/dist/lib/node/meta.json +1 -1
  29. package/dist/lib/node/{react-surface-LWDY7SQG.cjs → react-surface-2WRVAPGR.cjs} +9 -34
  30. package/dist/lib/node/react-surface-2WRVAPGR.cjs.map +7 -0
  31. package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs +133 -0
  32. package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-EMVA6QUT.mjs → chunk-6MUUH67V.mjs} +3 -8
  34. package/dist/lib/node-esm/chunk-6MUUH67V.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs +10 -0
  36. package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-UDD2VA6G.mjs +120 -0
  38. package/dist/lib/node-esm/chunk-UDD2VA6G.mjs.map +7 -0
  39. package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs +57 -0
  40. package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs.map +7 -0
  41. package/dist/lib/node-esm/index.mjs +21 -377
  42. package/dist/lib/node-esm/index.mjs.map +4 -4
  43. package/dist/lib/node-esm/meta.json +1 -1
  44. package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs +28 -0
  45. package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs.map +7 -0
  46. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/{ai-client.d.ts → complementary-panel.d.ts} +2 -3
  48. package/dist/types/src/capabilities/complementary-panel.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/index.d.ts +1 -180
  50. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  51. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  52. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
  53. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  54. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  55. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
  56. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  57. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  58. package/dist/types/src/components/index.d.ts +1 -12
  59. package/dist/types/src/components/index.d.ts.map +1 -1
  60. package/dist/types/src/index.d.ts +1 -3
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/meta.d.ts +0 -2
  63. package/dist/types/src/meta.d.ts.map +1 -1
  64. package/dist/types/src/testing/index.d.ts +0 -1
  65. package/dist/types/src/testing/index.d.ts.map +1 -1
  66. package/dist/types/src/testing/test-functions.d.ts +0 -2
  67. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  68. package/dist/types/src/translations.d.ts +1 -94
  69. package/dist/types/src/translations.d.ts.map +1 -1
  70. package/package.json +23 -73
  71. package/src/AutomationPlugin.tsx +9 -64
  72. package/src/capabilities/complementary-panel.ts +56 -0
  73. package/src/capabilities/index.ts +1 -5
  74. package/src/capabilities/react-surface.tsx +3 -23
  75. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
  76. package/src/components/AutomationPanel/AutomationPanel.tsx +56 -49
  77. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
  78. package/src/components/index.ts +0 -8
  79. package/src/index.ts +2 -3
  80. package/src/meta.ts +1 -4
  81. package/src/testing/index.ts +0 -1
  82. package/src/testing/test-functions.ts +0 -7
  83. package/src/translations.ts +1 -29
  84. package/dist/lib/browser/AutomationPanel-VW2XIUPU.mjs +0 -8
  85. package/dist/lib/browser/AutomationPanel-VW2XIUPU.mjs.map +0 -7
  86. package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs +0 -12
  87. package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs.map +0 -7
  88. package/dist/lib/browser/ai-client-5CNY6JBF.mjs +0 -22
  89. package/dist/lib/browser/ai-client-5CNY6JBF.mjs.map +0 -7
  90. package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs +0 -197
  91. package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs.map +0 -7
  92. package/dist/lib/browser/chunk-2H2EUYXL.mjs +0 -15
  93. package/dist/lib/browser/chunk-2H2EUYXL.mjs.map +0 -7
  94. package/dist/lib/browser/chunk-DVE33EZL.mjs +0 -1602
  95. package/dist/lib/browser/chunk-DVE33EZL.mjs.map +0 -7
  96. package/dist/lib/browser/chunk-MJK7GL5P.mjs +0 -307
  97. package/dist/lib/browser/chunk-MJK7GL5P.mjs.map +0 -7
  98. package/dist/lib/browser/chunk-NQFZ6XRX.mjs +0 -243
  99. package/dist/lib/browser/chunk-NQFZ6XRX.mjs.map +0 -7
  100. package/dist/lib/browser/chunk-Q4IMHYGH.mjs +0 -150
  101. package/dist/lib/browser/chunk-Q4IMHYGH.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-R4JH4TLE.mjs.map +0 -7
  103. package/dist/lib/browser/intent-resolver-BWAXKT27.mjs +0 -29
  104. package/dist/lib/browser/intent-resolver-BWAXKT27.mjs.map +0 -7
  105. package/dist/lib/browser/react-surface-ILBDBZCN.mjs +0 -58
  106. package/dist/lib/browser/react-surface-ILBDBZCN.mjs.map +0 -7
  107. package/dist/lib/browser/types/index.mjs +0 -24
  108. package/dist/lib/browser/types/index.mjs.map +0 -7
  109. package/dist/lib/node/AutomationPanel-G6EDDYWW.cjs +0 -26
  110. package/dist/lib/node/AutomationPanel-G6EDDYWW.cjs.map +0 -7
  111. package/dist/lib/node/ChatContainer-EN24W3K4.cjs +0 -33
  112. package/dist/lib/node/ChatContainer-EN24W3K4.cjs.map +0 -7
  113. package/dist/lib/node/ai-client-FKLPDELV.cjs +0 -38
  114. package/dist/lib/node/ai-client-FKLPDELV.cjs.map +0 -7
  115. package/dist/lib/node/app-graph-builder-T76NYV42.cjs +0 -212
  116. package/dist/lib/node/app-graph-builder-T76NYV42.cjs.map +0 -7
  117. package/dist/lib/node/chunk-CJGJXNY3.cjs +0 -1586
  118. package/dist/lib/node/chunk-CJGJXNY3.cjs.map +0 -7
  119. package/dist/lib/node/chunk-EQYHOTGG.cjs.map +0 -7
  120. package/dist/lib/node/chunk-GB7245FH.cjs +0 -173
  121. package/dist/lib/node/chunk-GB7245FH.cjs.map +0 -7
  122. package/dist/lib/node/chunk-HMBKP6VG.cjs +0 -324
  123. package/dist/lib/node/chunk-HMBKP6VG.cjs.map +0 -7
  124. package/dist/lib/node/chunk-QXIHYOMF.cjs.map +0 -7
  125. package/dist/lib/node/chunk-U5Z7LFWB.cjs +0 -34
  126. package/dist/lib/node/chunk-U5Z7LFWB.cjs.map +0 -7
  127. package/dist/lib/node/intent-resolver-C6OKFVEW.cjs +0 -44
  128. package/dist/lib/node/intent-resolver-C6OKFVEW.cjs.map +0 -7
  129. package/dist/lib/node/react-surface-LWDY7SQG.cjs.map +0 -7
  130. package/dist/lib/node/types/index.cjs +0 -46
  131. package/dist/lib/node/types/index.cjs.map +0 -7
  132. package/dist/lib/node-esm/AutomationPanel-V3IWQAMO.mjs +0 -9
  133. package/dist/lib/node-esm/AutomationPanel-V3IWQAMO.mjs.map +0 -7
  134. package/dist/lib/node-esm/ChatContainer-CNTY3C2D.mjs +0 -13
  135. package/dist/lib/node-esm/ChatContainer-CNTY3C2D.mjs.map +0 -7
  136. package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs +0 -23
  137. package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs.map +0 -7
  138. package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs +0 -198
  139. package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs.map +0 -7
  140. package/dist/lib/node-esm/chunk-6HLBYDUI.mjs +0 -244
  141. package/dist/lib/node-esm/chunk-6HLBYDUI.mjs.map +0 -7
  142. package/dist/lib/node-esm/chunk-DNCXRGAF.mjs +0 -151
  143. package/dist/lib/node-esm/chunk-DNCXRGAF.mjs.map +0 -7
  144. package/dist/lib/node-esm/chunk-EMVA6QUT.mjs.map +0 -7
  145. package/dist/lib/node-esm/chunk-IJRTDSKN.mjs +0 -16
  146. package/dist/lib/node-esm/chunk-IJRTDSKN.mjs.map +0 -7
  147. package/dist/lib/node-esm/chunk-QP47VJT6.mjs +0 -1603
  148. package/dist/lib/node-esm/chunk-QP47VJT6.mjs.map +0 -7
  149. package/dist/lib/node-esm/chunk-ZLIAMW45.mjs +0 -308
  150. package/dist/lib/node-esm/chunk-ZLIAMW45.mjs.map +0 -7
  151. package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs +0 -30
  152. package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs.map +0 -7
  153. package/dist/lib/node-esm/react-surface-SBDXFVIN.mjs +0 -59
  154. package/dist/lib/node-esm/react-surface-SBDXFVIN.mjs.map +0 -7
  155. package/dist/lib/node-esm/types/index.mjs +0 -25
  156. package/dist/lib/node-esm/types/index.mjs.map +0 -7
  157. package/dist/types/src/artifacts.stories.d.ts +0 -16
  158. package/dist/types/src/artifacts.stories.d.ts.map +0 -1
  159. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  160. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -181
  161. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  162. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  163. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  164. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  165. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  166. package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts +0 -3
  167. package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts.map +0 -1
  168. package/dist/types/src/components/AmbientChatDialog/index.d.ts +0 -2
  169. package/dist/types/src/components/AmbientChatDialog/index.d.ts.map +0 -1
  170. package/dist/types/src/components/Box/StatusLine.d.ts +0 -11
  171. package/dist/types/src/components/Box/StatusLine.d.ts.map +0 -1
  172. package/dist/types/src/components/Box/StatusLine.stories.d.ts +0 -9
  173. package/dist/types/src/components/Box/StatusLine.stories.d.ts.map +0 -1
  174. package/dist/types/src/components/Box/Tabbed.d.ts +0 -15
  175. package/dist/types/src/components/Box/Tabbed.d.ts.map +0 -1
  176. package/dist/types/src/components/Box/Tabbed.stories.d.ts +0 -8
  177. package/dist/types/src/components/Box/Tabbed.stories.d.ts.map +0 -1
  178. package/dist/types/src/components/Box/ToggleContainer.d.ts +0 -13
  179. package/dist/types/src/components/Box/ToggleContainer.d.ts.map +0 -1
  180. package/dist/types/src/components/Box/ToggleContainer.stories.d.ts +0 -9
  181. package/dist/types/src/components/Box/ToggleContainer.stories.d.ts.map +0 -1
  182. package/dist/types/src/components/Box/index.d.ts +0 -4
  183. package/dist/types/src/components/Box/index.d.ts.map +0 -1
  184. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -7
  185. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +0 -1
  186. package/dist/types/src/components/ChatContainer/index.d.ts +0 -4
  187. package/dist/types/src/components/ChatContainer/index.d.ts.map +0 -1
  188. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +0 -14
  189. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +0 -1
  190. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +0 -8
  191. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +0 -1
  192. package/dist/types/src/components/MarkdownViewer/index.d.ts +0 -2
  193. package/dist/types/src/components/MarkdownViewer/index.d.ts.map +0 -1
  194. package/dist/types/src/components/Prompt/Prompt.d.ts +0 -7
  195. package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
  196. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -8
  197. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
  198. package/dist/types/src/components/Prompt/index.d.ts +0 -2
  199. package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
  200. package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts +0 -20
  201. package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts.map +0 -1
  202. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
  203. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
  204. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
  205. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
  206. package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
  207. package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
  208. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
  209. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
  210. package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
  211. package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
  212. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
  213. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
  214. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
  215. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
  216. package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
  217. package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
  218. package/dist/types/src/components/Thread/Thread.d.ts +0 -11
  219. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  220. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  221. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  222. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -12
  223. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  224. package/dist/types/src/components/Thread/index.d.ts +0 -2
  225. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  226. package/dist/types/src/hooks/email.d.ts +0 -4
  227. package/dist/types/src/hooks/email.d.ts.map +0 -1
  228. package/dist/types/src/hooks/index.d.ts +0 -6
  229. package/dist/types/src/hooks/index.d.ts.map +0 -1
  230. package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
  231. package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
  232. package/dist/types/src/hooks/processor.d.ts +0 -70
  233. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  234. package/dist/types/src/hooks/processor.test.d.ts +0 -2
  235. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  236. package/dist/types/src/hooks/useChatProcessor.d.ts +0 -7
  237. package/dist/types/src/hooks/useChatProcessor.d.ts.map +0 -1
  238. package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
  239. package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
  240. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -41
  241. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  242. package/dist/types/src/hooks/useServices.d.ts +0 -7
  243. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  244. package/dist/types/src/presets.d.ts +0 -9
  245. package/dist/types/src/presets.d.ts.map +0 -1
  246. package/dist/types/src/testing/test-services.d.ts +0 -5
  247. package/dist/types/src/testing/test-services.d.ts.map +0 -1
  248. package/dist/types/src/tools/function.d.ts +0 -5
  249. package/dist/types/src/tools/function.d.ts.map +0 -1
  250. package/dist/types/src/tools/index.d.ts +0 -3
  251. package/dist/types/src/tools/index.d.ts.map +0 -1
  252. package/dist/types/src/tools/openapi.d.ts +0 -10
  253. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  254. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  255. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  256. package/dist/types/src/types/index.d.ts +0 -4
  257. package/dist/types/src/types/index.d.ts.map +0 -1
  258. package/dist/types/src/types/registry.d.ts +0 -10
  259. package/dist/types/src/types/registry.d.ts.map +0 -1
  260. package/dist/types/src/types/schema.d.ts +0 -221
  261. package/dist/types/src/types/schema.d.ts.map +0 -1
  262. package/dist/types/src/types/types.d.ts +0 -18
  263. package/dist/types/src/types/types.d.ts.map +0 -1
  264. package/src/artifacts.stories.tsx +0 -241
  265. package/src/capabilities/ai-client.ts +0 -19
  266. package/src/capabilities/app-graph-builder.ts +0 -187
  267. package/src/capabilities/capabilities.ts +0 -12
  268. package/src/capabilities/intent-resolver.ts +0 -27
  269. package/src/components/AmbientChatDialog/AmbientChatDialog.tsx +0 -26
  270. package/src/components/AmbientChatDialog/index.ts +0 -5
  271. package/src/components/Box/StatusLine.stories.tsx +0 -52
  272. package/src/components/Box/StatusLine.tsx +0 -76
  273. package/src/components/Box/Tabbed.stories.tsx +0 -51
  274. package/src/components/Box/Tabbed.tsx +0 -89
  275. package/src/components/Box/ToggleContainer.stories.tsx +0 -110
  276. package/src/components/Box/ToggleContainer.tsx +0 -108
  277. package/src/components/Box/index.ts +0 -7
  278. package/src/components/ChatContainer/ChatContainer.tsx +0 -52
  279. package/src/components/ChatContainer/index.ts +0 -8
  280. package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +0 -56
  281. package/src/components/MarkdownViewer/MarkdownViewer.tsx +0 -79
  282. package/src/components/MarkdownViewer/index.ts +0 -5
  283. package/src/components/Prompt/Prompt.stories.tsx +0 -50
  284. package/src/components/Prompt/Prompt.tsx +0 -36
  285. package/src/components/Prompt/index.ts +0 -5
  286. package/src/components/Prompt/prompt-autocomplete.ts +0 -200
  287. package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
  288. package/src/components/PromptEditor/PromptEditor.tsx +0 -222
  289. package/src/components/PromptEditor/index.ts +0 -5
  290. package/src/components/PromptEditor/prompt-extension.ts +0 -43
  291. package/src/components/PromptEditor/types.tsx +0 -28
  292. package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -49
  293. package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -75
  294. package/src/components/ServiceRegistry/index.ts +0 -5
  295. package/src/components/Thread/Thread.stories.tsx +0 -197
  296. package/src/components/Thread/Thread.tsx +0 -156
  297. package/src/components/Thread/ThreadMessage.tsx +0 -225
  298. package/src/components/Thread/index.ts +0 -5
  299. package/src/hooks/email.ts +0 -49
  300. package/src/hooks/index.ts +0 -10
  301. package/src/hooks/invocation-handler.ts +0 -109
  302. package/src/hooks/processor.test.ts +0 -15
  303. package/src/hooks/processor.ts +0 -210
  304. package/src/hooks/useChatProcessor.tsx +0 -86
  305. package/src/hooks/useLocalTriggerManager.ts +0 -82
  306. package/src/hooks/useMessageQueue.ts +0 -23
  307. package/src/hooks/useServices.ts +0 -28
  308. package/src/presets.ts +0 -248
  309. package/src/testing/test-services.ts +0 -131
  310. package/src/tools/function.ts +0 -47
  311. package/src/tools/index.ts +0 -6
  312. package/src/tools/openapi.test.ts +0 -227
  313. package/src/tools/openapi.ts +0 -331
  314. package/src/types/index.ts +0 -7
  315. package/src/types/registry.ts +0 -26
  316. package/src/types/schema.ts +0 -132
  317. package/src/types/types.ts +0 -21
@@ -1,1586 +0,0 @@
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_CJGJXNY3_exports = {};
30
- __export(chunk_CJGJXNY3_exports, {
31
- AiClient: () => AiClient,
32
- AppGraphBuilder: () => AppGraphBuilder,
33
- ChatContainer: () => ChatContainer,
34
- ChatContainer_default: () => ChatContainer_default,
35
- IntentResolver: () => IntentResolver,
36
- MarkdownViewer: () => MarkdownViewer,
37
- ReactSurface: () => ReactSurface,
38
- Thread: () => Thread,
39
- useServices: () => useServices
40
- });
41
- module.exports = __toCommonJS(chunk_CJGJXNY3_exports);
42
- var import_chunk_U5Z7LFWB = require("./chunk-U5Z7LFWB.cjs");
43
- var import_chunk_GB7245FH = require("./chunk-GB7245FH.cjs");
44
- var import_chunk_EQYHOTGG = require("./chunk-EQYHOTGG.cjs");
45
- var import_react = __toESM(require("react"));
46
- var import_invariant = require("@dxos/invariant");
47
- var import_react_ui_stack = require("@dxos/react-ui-stack");
48
- var import_signals_core = require("@preact/signals-core");
49
- var import_artifact = require("@dxos/artifact");
50
- var import_assistant = require("@dxos/assistant");
51
- var import_echo_schema = require("@dxos/echo-schema");
52
- var import_invariant2 = require("@dxos/invariant");
53
- var import_log = require("@dxos/log");
54
- var import_react2 = require("react");
55
- var import_app_framework = require("@dxos/app-framework");
56
- var import_artifact2 = require("@dxos/artifact");
57
- var import_functions = require("@dxos/functions");
58
- var import_react_client = require("@dxos/react-client");
59
- var import_echo = require("@dxos/react-client/echo");
60
- var import_util = require("@dxos/util");
61
- var import_app_framework2 = require("@dxos/app-framework");
62
- var import_artifact3 = require("@dxos/artifact");
63
- var import_echo_schema2 = require("@dxos/echo-schema");
64
- var import_functions2 = require("@dxos/functions");
65
- var import_log2 = require("@dxos/log");
66
- var import_echo2 = require("@dxos/react-client/echo");
67
- var import_jsonpointer = __toESM(require("jsonpointer"));
68
- var import_artifact4 = require("@dxos/artifact");
69
- var import_echo_schema3 = require("@dxos/echo-schema");
70
- var import_invariant3 = require("@dxos/invariant");
71
- var import_log3 = require("@dxos/log");
72
- var import_util2 = require("@dxos/util");
73
- var import_react3 = require("react");
74
- var import_async = require("@dxos/async");
75
- var import_context = require("@dxos/context");
76
- var import_functions3 = require("@dxos/functions");
77
- var import_functions4 = require("@dxos/functions");
78
- var import_invariant4 = require("@dxos/invariant");
79
- var import_log4 = require("@dxos/log");
80
- var import_react_client2 = require("@dxos/react-client");
81
- var import_echo3 = require("@dxos/react-client/echo");
82
- var import_async2 = require("@dxos/async");
83
- var import_echo_db = require("@dxos/echo-db");
84
- var import_functions5 = require("@dxos/functions");
85
- var import_invariant5 = require("@dxos/invariant");
86
- var import_keys = require("@dxos/keys");
87
- var import_log5 = require("@dxos/log");
88
- var import_react4 = require("react");
89
- var import_keys2 = require("@dxos/keys");
90
- var import_echo4 = require("@dxos/react-client/echo");
91
- var import_react_edge_client = require("@dxos/react-edge-client");
92
- var import_react5 = require("react");
93
- var import_artifact5 = require("@dxos/artifact");
94
- var import_echo_schema4 = require("@dxos/echo-schema");
95
- var import_echo_schema5 = require("@dxos/echo-schema");
96
- var import_react6 = __toESM(require("react"));
97
- var import_react_ui = require("@dxos/react-ui");
98
- var import_react_ui_components = require("@dxos/react-ui-components");
99
- var import_react_ui_sfx = require("@dxos/react-ui-sfx");
100
- var import_react_ui_theme = require("@dxos/react-ui-theme");
101
- var import_react7 = __toESM(require("react"));
102
- var import_invariant6 = require("@dxos/invariant");
103
- var import_log6 = require("@dxos/log");
104
- var import_react_ui2 = require("@dxos/react-ui");
105
- var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
106
- var import_react_ui_theme2 = require("@dxos/react-ui-theme");
107
- var import_util3 = require("@dxos/util");
108
- var import_react8 = __toESM(require("react"));
109
- var import_react_ui_theme3 = require("@dxos/react-ui-theme");
110
- var import_react9 = __toESM(require("react"));
111
- var import_react_ui3 = require("@dxos/react-ui");
112
- var import_react_ui_theme4 = require("@dxos/react-ui-theme");
113
- var import_react10 = __toESM(require("react"));
114
- var import_react_ui4 = require("@dxos/react-ui");
115
- var import_react_ui_theme5 = require("@dxos/react-ui-theme");
116
- var import_react11 = __toESM(require("react"));
117
- var import_react_markdown = __toESM(require("react-markdown"));
118
- var import_react_ui_syntax_highlighter2 = require("@dxos/react-ui-syntax-highlighter");
119
- var import_react_ui_theme6 = require("@dxos/react-ui-theme");
120
- var import_util4 = require("@dxos/util");
121
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/hooks/processor.ts";
122
- var defaultOptions = {
123
- model: "@anthropic/claude-3-5-sonnet-20241022",
124
- systemPrompt: "you are a helpful assistant"
125
- };
126
- var ChatProcessor = class {
127
- constructor(_client, _tools, _extensions, _options = defaultOptions) {
128
- this._client = _client;
129
- this._tools = _tools;
130
- this._extensions = _extensions;
131
- this._options = _options;
132
- this._parser = new import_assistant.MixedStreamParser();
133
- this._pending = (0, import_signals_core.signal)([]);
134
- this._block = (0, import_signals_core.signal)(void 0);
135
- this._history = [];
136
- this.streaming = (0, import_signals_core.computed)(() => this._block.value !== void 0);
137
- this.messages = (0, import_signals_core.computed)(() => {
138
- const messages = [
139
- ...this._pending.value
140
- ];
141
- if (this._block.value) {
142
- const current = messages.pop();
143
- (0, import_invariant2.invariant)(current, void 0, {
144
- F: __dxlog_file,
145
- L: 78,
146
- S: this,
147
- A: [
148
- "current",
149
- ""
150
- ]
151
- });
152
- const { content, ...rest } = current;
153
- const message = {
154
- ...rest,
155
- content: [
156
- ...content,
157
- this._block.value
158
- ]
159
- };
160
- messages.push(message);
161
- }
162
- return messages;
163
- });
164
- this._parser.message.on((message) => {
165
- (0, import_signals_core.batch)(() => {
166
- this._pending.value = [
167
- ...this._pending.value,
168
- message
169
- ];
170
- this._block.value = void 0;
171
- });
172
- });
173
- this._parser.update.on((block) => {
174
- (0, import_signals_core.batch)(() => {
175
- this._block.value = block;
176
- });
177
- });
178
- }
179
- /**
180
- * Update tools.
181
- */
182
- setTools(tools) {
183
- this._tools = tools;
184
- }
185
- /**
186
- * Make GPT request.
187
- */
188
- async request(message, options = {}) {
189
- (0, import_signals_core.batch)(() => {
190
- this._history = options.history ?? [];
191
- this._pending.value = [
192
- (0, import_echo_schema.createStatic)(import_artifact.Message, {
193
- role: "user",
194
- content: [
195
- {
196
- type: "text",
197
- text: message
198
- }
199
- ]
200
- })
201
- ];
202
- this._block.value = void 0;
203
- });
204
- await this._generate();
205
- options.onComplete?.(this._pending.value);
206
- return this._reset();
207
- }
208
- /**
209
- * Cancel pending requests.
210
- * @returns Pending requests (incl. the request message).
211
- */
212
- async cancel() {
213
- import_log.log.info("cancelling...", void 0, {
214
- F: __dxlog_file,
215
- L: 141,
216
- S: this,
217
- C: (f, a) => f(...a)
218
- });
219
- this._stream?.abort();
220
- return this._reset();
221
- }
222
- async _reset() {
223
- const messages = this._pending.value;
224
- (0, import_signals_core.batch)(() => {
225
- this._history = [];
226
- this._pending.value = [];
227
- this._block.value = void 0;
228
- });
229
- return messages;
230
- }
231
- /**
232
- * Generate a response from the AI service.
233
- * Iterates over tool requests.
234
- */
235
- async _generate() {
236
- try {
237
- let more = false;
238
- do {
239
- import_log.log.info("requesting...", {
240
- history: this._history.length,
241
- messages: this._pending.value.length
242
- }, {
243
- F: __dxlog_file,
244
- L: 165,
245
- S: this,
246
- C: (f, a) => f(...a)
247
- });
248
- this._stream = await this._client.generate({
249
- ...this._options,
250
- // TODO(burdon): Rename messages or separate history/message.
251
- history: [
252
- ...this._history,
253
- ...this._pending.value
254
- ],
255
- tools: this._tools
256
- });
257
- await this._parser.parse(this._stream);
258
- await this._stream.complete();
259
- import_log.log.info("response", {
260
- messages: this._pending.value
261
- }, {
262
- F: __dxlog_file,
263
- L: 178,
264
- S: this,
265
- C: (f, a) => f(...a)
266
- });
267
- more = false;
268
- const message = this._pending.value.at(-1);
269
- (0, import_invariant2.invariant)(message, void 0, {
270
- F: __dxlog_file,
271
- L: 183,
272
- S: this,
273
- A: [
274
- "message",
275
- ""
276
- ]
277
- });
278
- if ((0, import_assistant.isToolUse)(message)) {
279
- import_log.log.info("tool request...", void 0, {
280
- F: __dxlog_file,
281
- L: 185,
282
- S: this,
283
- C: (f, a) => f(...a)
284
- });
285
- const response = await (0, import_assistant.runTools)({
286
- message: this._pending.value.at(-1),
287
- tools: this._tools ?? [],
288
- extensions: this._extensions
289
- });
290
- import_log.log.info("tool response", {
291
- response
292
- }, {
293
- F: __dxlog_file,
294
- L: 192,
295
- S: this,
296
- C: (f, a) => f(...a)
297
- });
298
- switch (response.type) {
299
- case "continue": {
300
- this._pending.value = [
301
- ...this._pending.value,
302
- response.message
303
- ];
304
- more = true;
305
- break;
306
- }
307
- }
308
- }
309
- } while (more);
310
- } catch (err) {
311
- import_log.log.catch("request failed", {
312
- err
313
- }, {
314
- F: __dxlog_file,
315
- L: 204,
316
- S: this,
317
- C: (f, a) => f(...a)
318
- });
319
- } finally {
320
- import_log.log.info("done", void 0, {
321
- F: __dxlog_file,
322
- L: 206,
323
- S: this,
324
- C: (f, a) => f(...a)
325
- });
326
- this._stream = void 0;
327
- }
328
- }
329
- };
330
- var AiClient = (0, import_app_framework2.lazy)(() => import("./ai-client-FKLPDELV.cjs"));
331
- var AppGraphBuilder = (0, import_app_framework2.lazy)(() => import("./app-graph-builder-T76NYV42.cjs"));
332
- var IntentResolver = (0, import_app_framework2.lazy)(() => import("./intent-resolver-C6OKFVEW.cjs"));
333
- var ReactSurface = (0, import_app_framework2.lazy)(() => import("./react-surface-LWDY7SQG.cjs"));
334
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/function.ts";
335
- var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
336
- if (!fn.description || !fn.inputSchema) {
337
- return void 0;
338
- }
339
- const existingFunctionUrl = (0, import_functions2.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
340
- if (!existingFunctionUrl) {
341
- return void 0;
342
- }
343
- const url = (0, import_functions2.getInvocationUrl)(existingFunctionUrl, edgeUrl, {
344
- spaceId
345
- });
346
- return (0, import_artifact3.defineTool)({
347
- name: fn.name,
348
- description: fn.description,
349
- schema: (0, import_echo_schema2.toEffectSchema)(fn.inputSchema),
350
- execute: async (input) => {
351
- import_log2.log.info("execute function tool", {
352
- name: fn.name,
353
- url,
354
- input
355
- }, {
356
- F: __dxlog_file2,
357
- L: 36,
358
- S: void 0,
359
- C: (f, a) => f(...a)
360
- });
361
- const response = await fetch(url, {
362
- method: "POST",
363
- headers: {
364
- "Content-Type": "application/json"
365
- },
366
- body: JSON.stringify(input)
367
- });
368
- return import_artifact3.ToolResult.Success(await response.text());
369
- }
370
- });
371
- };
372
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/openapi.ts";
373
- var createToolsFromService = async (service) => {
374
- (0, import_invariant3.invariant)(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
375
- F: __dxlog_file3,
376
- L: 22,
377
- S: void 0,
378
- A: [
379
- "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
380
- ""
381
- ]
382
- });
383
- const iface = service.interfaces[0];
384
- (0, import_invariant3.invariant)(iface.schemaUrl, void 0, {
385
- F: __dxlog_file3,
386
- L: 24,
387
- S: void 0,
388
- A: [
389
- "iface.schemaUrl",
390
- ""
391
- ]
392
- });
393
- (0, import_invariant3.invariant)(iface.schemaUrl, void 0, {
394
- F: __dxlog_file3,
395
- L: 25,
396
- S: void 0,
397
- A: [
398
- "iface.schemaUrl",
399
- ""
400
- ]
401
- });
402
- return createToolsFromApi(iface.schemaUrl, {
403
- authorization: iface.authorization
404
- });
405
- };
406
- var createToolsFromApi = async (url, options) => {
407
- const res = await fetch(url);
408
- const spec = await res.json();
409
- (0, import_log3.log)("spec", {
410
- spec
411
- }, {
412
- F: __dxlog_file3,
413
- L: 32,
414
- S: void 0,
415
- C: (f, a) => f(...a)
416
- });
417
- const tools = [];
418
- for (const [path, pathItem] of Object.entries(spec.paths)) {
419
- if (typeof pathItem !== "object") {
420
- continue;
421
- }
422
- const { ...methods } = pathItem;
423
- for (const [method, m] of Object.entries(methods)) {
424
- const methodItem = m;
425
- (0, import_log3.log)("methodItem", {
426
- path,
427
- method,
428
- methodItem
429
- }, {
430
- F: __dxlog_file3,
431
- L: 44,
432
- S: void 0,
433
- C: (f, a) => f(...a)
434
- });
435
- const parametersResolved = methodItem.parameters?.map((parameter) => {
436
- const resolved = resolveJsonSchema(parameter, spec);
437
- return resolved;
438
- }) ?? [];
439
- const inputSchema = {
440
- type: "object",
441
- properties: {}
442
- };
443
- const endpointParameters = [];
444
- for (const parameter of parametersResolved) {
445
- (0, import_log3.log)("parameter", {
446
- parameter
447
- }, {
448
- F: __dxlog_file3,
449
- L: 59,
450
- S: void 0,
451
- C: (f, a) => f(...a)
452
- });
453
- if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
454
- continue;
455
- }
456
- endpointParameters.push(parameter);
457
- if (parameter.schema) {
458
- inputSchema.properties[parameter.name] = (0, import_echo_schema3.normalizeSchema)(parameter.schema);
459
- } else if (typeof parameter.type === "string") {
460
- const { name, in: _in, required, ...schema } = parameter;
461
- inputSchema.properties[name] = (0, import_echo_schema3.normalizeSchema)(schema);
462
- if (required) {
463
- inputSchema.required ??= [];
464
- inputSchema.required.push(name);
465
- }
466
- }
467
- }
468
- (0, import_log3.log)("inputSchema", {
469
- inputSchema
470
- }, {
471
- F: __dxlog_file3,
472
- L: 84,
473
- S: void 0,
474
- C: (f, a) => f(...a)
475
- });
476
- import_echo_schema3.S.validateSync(import_echo_schema3.JsonSchemaType)(inputSchema);
477
- const description = methodItem.description ?? methodItem.summary;
478
- if (!description) {
479
- import_log3.log.warn("no description", {
480
- path,
481
- method
482
- }, {
483
- F: __dxlog_file3,
484
- L: 89,
485
- S: void 0,
486
- C: (f, a) => f(...a)
487
- });
488
- continue;
489
- }
490
- const endpoint = {
491
- document: spec,
492
- path,
493
- method,
494
- parameters: endpointParameters,
495
- authorization: options?.authorization
496
- };
497
- tools.push({
498
- name: getToolName(path, method, methodItem),
499
- description: options?.instructions ? `${options.instructions}
500
-
501
- ${description}` : description,
502
- parameters: inputSchema,
503
- execute: async (input) => {
504
- const response = await callApiEndpoint(endpoint, input);
505
- return import_artifact4.ToolResult.Success(response);
506
- }
507
- });
508
- }
509
- }
510
- return tools;
511
- };
512
- var getToolName = (path, method, methodItem) => {
513
- if (methodItem.operationId) {
514
- return methodItem.operationId;
515
- }
516
- let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
517
- while (name.length > MAX_TOOL_NAME_LENGTH) {
518
- const lengthBefore = name.length;
519
- for (const word of GENERIC_WORDS) {
520
- if (name.includes(word)) {
521
- name = name.replace(word, "");
522
- break;
523
- }
524
- }
525
- name = name.replaceAll("__", "_").replace(/_$/, "");
526
- const lengthAfter = name.length;
527
- if (lengthBefore === lengthAfter) {
528
- break;
529
- }
530
- }
531
- name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
532
- return name.slice(0, MAX_TOOL_NAME_LENGTH);
533
- };
534
- var MAX_TOOL_NAME_LENGTH = 64;
535
- var GENERIC_WORDS = [
536
- "services",
537
- "service",
538
- "api",
539
- "rest",
540
- "endpoint",
541
- "get",
542
- "post",
543
- "put",
544
- "delete",
545
- "patch",
546
- "head",
547
- "options",
548
- "trace",
549
- "service",
550
- "api",
551
- "endpoint"
552
- ];
553
- var callApiEndpoint = async (endpoint, input) => {
554
- import_log3.log.info("endpoint", {
555
- method: endpoint.method,
556
- name: endpoint.path,
557
- input
558
- }, {
559
- F: __dxlog_file3,
560
- L: 173,
561
- S: void 0,
562
- C: (f, a) => f(...a)
563
- });
564
- let url = getEndpointUrl(endpoint);
565
- const request = {
566
- method: endpoint.method,
567
- headers: {}
568
- };
569
- const query = new URLSearchParams();
570
- let body;
571
- for (const parameter of endpoint.parameters) {
572
- if (input[parameter.name] === void 0) {
573
- continue;
574
- }
575
- switch (parameter.in) {
576
- case "header": {
577
- if (parameter.example) {
578
- request.headers[parameter.name] = parameter.default;
579
- }
580
- break;
581
- }
582
- case "path": {
583
- url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
584
- break;
585
- }
586
- case "body": {
587
- const value = input[parameter.name];
588
- const effectSchema = (0, import_echo_schema3.toEffectSchema)(parameter.schema);
589
- import_echo_schema3.S.validateSync(effectSchema)(value);
590
- if (body) {
591
- throw new Error(`Duplicate body parameter: ${parameter.name}`);
592
- }
593
- body = value;
594
- break;
595
- }
596
- case "query": {
597
- query.set(parameter.name, input[parameter.name]);
598
- break;
599
- }
600
- }
601
- }
602
- if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
603
- request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
604
- } else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
605
- query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
606
- }
607
- if (query.size > 0) {
608
- url += `?${query.toString()}`;
609
- }
610
- if (body) {
611
- request.body = JSON.stringify(body);
612
- request.headers["Content-Type"] = "application/json";
613
- }
614
- import_log3.log.info("request", {
615
- url,
616
- request
617
- }, {
618
- F: __dxlog_file3,
619
- L: 236,
620
- S: void 0,
621
- C: (f, a) => f(...a)
622
- });
623
- const response = await fetch(url, request);
624
- import_log3.log.info("response", {
625
- ok: response.ok,
626
- status: response.status,
627
- statusText: response.statusText
628
- }, {
629
- F: __dxlog_file3,
630
- L: 239,
631
- S: void 0,
632
- C: (f, a) => f(...a)
633
- });
634
- if (response.ok) {
635
- const contentType = response.headers.get("Content-Type");
636
- if (contentType?.includes("application/json")) {
637
- return await response.json();
638
- } else {
639
- return await response.text();
640
- }
641
- } else {
642
- if (response.headers.get("Content-Type")?.includes("application/json")) {
643
- const responseBody = await response.text();
644
- let error;
645
- try {
646
- error = JSON.parse(responseBody);
647
- } catch {
648
- error = responseBody;
649
- }
650
- import_log3.log.error("error", {
651
- error
652
- }, {
653
- F: __dxlog_file3,
654
- L: 257,
655
- S: void 0,
656
- C: (f, a) => f(...a)
657
- });
658
- throw new Error(error.message);
659
- } else {
660
- const error = await response.text();
661
- import_log3.log.error("error", {
662
- error
663
- }, {
664
- F: __dxlog_file3,
665
- L: 261,
666
- S: void 0,
667
- C: (f, a) => f(...a)
668
- });
669
- throw new Error(error);
670
- }
671
- }
672
- };
673
- var getEndpointUrl = (endpoint) => {
674
- let url = "";
675
- if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
676
- url = endpoint.document.servers[0].url;
677
- } else {
678
- (0, import_invariant3.invariant)(!isV3_1(endpoint.document), void 0, {
679
- F: __dxlog_file3,
680
- L: 272,
681
- S: void 0,
682
- A: [
683
- "!isV3_1(endpoint.document)",
684
- ""
685
- ]
686
- });
687
- url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
688
- }
689
- if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
690
- url += endpoint.document.basePath;
691
- }
692
- url += endpoint.path;
693
- return url;
694
- };
695
- var resolveAuthorization = async (authorization) => {
696
- switch (authorization.type) {
697
- case "api-key": {
698
- (0, import_invariant3.invariant)(authorization.placement.type === "authorization-header", void 0, {
699
- F: __dxlog_file3,
700
- L: 288,
701
- S: void 0,
702
- A: [
703
- "authorization.placement.type === 'authorization-header'",
704
- ""
705
- ]
706
- });
707
- return `Bearer ${authorization.key}`;
708
- }
709
- case "oauth": {
710
- const response = await fetch(authorization.tokenUrl, {
711
- method: "POST",
712
- headers: {
713
- "Content-Type": "application/x-www-form-urlencoded"
714
- },
715
- body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
716
- });
717
- const data = await response.json();
718
- return `Bearer ${data.access_token}`;
719
- }
720
- default: {
721
- throw new Error(`Unknown authorization type: ${authorization.type}`);
722
- }
723
- }
724
- };
725
- var resolveJsonSchema = (schema, base) => {
726
- return (0, import_util2.deepMapValues)(schema, (value, recurse) => {
727
- if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
728
- if (value.$ref.startsWith("#")) {
729
- const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
730
- if (resolved) {
731
- return recurse(resolved);
732
- } else {
733
- import_log3.log.warn("unresolved", {
734
- ref: value.$ref,
735
- base
736
- }, {
737
- F: __dxlog_file3,
738
- L: 321,
739
- S: void 0,
740
- C: (f, a) => f(...a)
741
- });
742
- }
743
- }
744
- }
745
- return recurse(value);
746
- });
747
- };
748
- var isV3_1 = (document) => {
749
- return document.openapi === "3.0.1";
750
- };
751
- var useChatProcessor = (chat) => {
752
- const aiClient = (0, import_app_framework.useCapability)(import_chunk_U5Z7LFWB.AutomationCapabilities.AiClient);
753
- const globalTools = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.Tools);
754
- const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
755
- const { dispatchPromise: dispatch } = (0, import_app_framework.useIntentDispatcher)();
756
- const space = (0, import_echo.getSpace)(chat);
757
- const services = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_chunk_GB7245FH.ServiceType));
758
- const [serviceTools, setServiceTools] = (0, import_react2.useState)([]);
759
- (0, import_react2.useEffect)(() => {
760
- queueMicrotask(async () => {
761
- const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
762
- setServiceTools(tools2.flat());
763
- });
764
- }, [
765
- services
766
- ]);
767
- const config = (0, import_react_client.useConfig)();
768
- const functions2 = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionType));
769
- const tools = (0, import_react2.useMemo)(() => [
770
- ...globalTools.flat(),
771
- ...artifactDefinitions.flatMap((definition) => definition.tools),
772
- ...serviceTools,
773
- ...functions2.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(import_util.isNotNullOrUndefined)
774
- ], [
775
- globalTools,
776
- artifactDefinitions,
777
- serviceTools,
778
- functions2,
779
- space?.id
780
- ]);
781
- const systemPrompt = (0, import_react2.useMemo)(() => (0, import_artifact2.createSystemPrompt)({
782
- artifacts: artifactDefinitions.map((definition) => definition.instructions)
783
- }), [
784
- artifactDefinitions
785
- ]);
786
- const processor = (0, import_react2.useMemo)(() => new ChatProcessor(aiClient, tools, {
787
- space,
788
- dispatch
789
- }, {
790
- model: "@anthropic/claude-3-5-sonnet-20241022",
791
- systemPrompt
792
- }), [
793
- aiClient,
794
- tools,
795
- space,
796
- dispatch,
797
- systemPrompt
798
- ]);
799
- return processor;
800
- };
801
- var registerTriggersMutex = new import_async.Mutex();
802
- var useMessageQueue = (chat) => {
803
- const edgeClient = (0, import_react_edge_client.useEdgeClient)();
804
- const space = (0, import_echo4.getSpace)(chat);
805
- const queueDxn = (0, import_react4.useMemo)(() => new import_keys2.DXN(import_keys2.DXN.kind.QUEUE, [
806
- import_keys2.QueueSubspaceTags.DATA,
807
- space.id,
808
- chat.queue.dxn.parts.at(-1)
809
- ]), [
810
- chat.queue.dxn
811
- ]);
812
- return (0, import_react_edge_client.useQueue)(edgeClient, queueDxn);
813
- };
814
- var functions = [
815
- {
816
- name: "example.com/function/chess",
817
- version: "0.1.0",
818
- inputSchema: (0, import_echo_schema4.toJsonSchema)(import_echo_schema4.S.Struct({
819
- level: import_echo_schema4.S.Number.annotations({
820
- [import_echo_schema4.AST.TitleAnnotationId]: "Level"
821
- })
822
- }))
823
- },
824
- {
825
- name: "example.com/function/forex",
826
- version: "0.1.0",
827
- binding: "FOREX",
828
- inputSchema: (0, import_echo_schema4.toJsonSchema)(import_echo_schema4.S.Struct({
829
- from: import_echo_schema4.S.String.annotations({
830
- [import_echo_schema4.AST.TitleAnnotationId]: "Currency from"
831
- }),
832
- to: import_echo_schema4.S.String.annotations({
833
- [import_echo_schema4.AST.TitleAnnotationId]: "Currency to"
834
- })
835
- }))
836
- }
837
- ];
838
- var MockServiceRegistry = class {
839
- async queryServices(query) {
840
- return TEST_SERVICES;
841
- }
842
- };
843
- var AMADEUS_AUTH = {
844
- type: "oauth",
845
- clientId: "BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG",
846
- clientSecret: "n4qldSN7usvD57gm",
847
- tokenUrl: "https://test.api.amadeus.com/v1/security/oauth2/token",
848
- grantType: "client_credentials"
849
- };
850
- var VISUAL_CROSSING_CREDENTIALS = {
851
- type: "api-key",
852
- key: "FDPRVS953KB4GQQLD25GRT975",
853
- placement: {
854
- type: "query",
855
- name: "key"
856
- }
857
- };
858
- var TEST_SERVICES = [
859
- (0, import_echo_schema5.createStatic)(import_chunk_GB7245FH.ServiceType, {
860
- serviceId: "amadeus.com/service/FlightSearch",
861
- name: "Amadeus Flight Search",
862
- description: "Search for local and international flights.",
863
- category: "travel",
864
- interfaces: [
865
- {
866
- kind: "api",
867
- schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json",
868
- authorization: AMADEUS_AUTH
869
- }
870
- ]
871
- }),
872
- (0, import_echo_schema5.createStatic)(import_chunk_GB7245FH.ServiceType, {
873
- serviceId: "amadeus.com/service/HotelSearch",
874
- name: "Amadeus Hotel Search",
875
- description: "Search for local and international hotels.",
876
- category: "travel",
877
- interfaces: [
878
- {
879
- kind: "api",
880
- schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json",
881
- authorization: AMADEUS_AUTH
882
- }
883
- ]
884
- }),
885
- (0, import_echo_schema5.createStatic)(import_chunk_GB7245FH.ServiceType, {
886
- serviceId: "visualcrossing.com/service/Weather",
887
- name: "Visual Crossing Weather",
888
- description: "Search for global weather forecasts.",
889
- category: "weather",
890
- interfaces: [
891
- {
892
- kind: "api",
893
- schemaUrl: "https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json",
894
- authorization: VISUAL_CROSSING_CREDENTIALS
895
- }
896
- ]
897
- }),
898
- // TODO(burdon): Needs auth.
899
- (0, import_echo_schema5.createStatic)(import_chunk_GB7245FH.ServiceType, {
900
- serviceId: "abstractapi.com/service/GeoLocation",
901
- name: "Abstract GeoLocation",
902
- description: "Get the location of any IP address.",
903
- category: "geolocation",
904
- interfaces: [
905
- {
906
- kind: "api",
907
- schemaUrl: "https://api.apis.guru/v2/specs/abstractapi.com/geolocation/1.0.0/openapi.json"
908
- }
909
- ]
910
- }),
911
- //
912
- // Testing
913
- //
914
- ...Array.from({
915
- length: 20
916
- }, (_, i) => (0, import_echo_schema5.createStatic)(import_chunk_GB7245FH.ServiceType, {
917
- serviceId: `example.com/service/test-${i}`,
918
- name: `Test ${i}`,
919
- description: `Test ${i}`,
920
- category: Object.keys(import_chunk_GB7245FH.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_GB7245FH.categoryIcons).length)],
921
- interfaces: [
922
- {
923
- kind: "api",
924
- schemaUrl: "https://petstore.swagger.io/v2/swagger.json"
925
- }
926
- ]
927
- }))
928
- ];
929
- var useServices = (space, query) => {
930
- const registry = (0, import_react5.useMemo)(() => new MockServiceRegistry(), []);
931
- const [services, setServices] = (0, import_react5.useState)([]);
932
- (0, import_react5.useEffect)(() => {
933
- const t = setTimeout(async () => {
934
- const services2 = await registry.queryServices(query);
935
- setServices(services2);
936
- });
937
- return () => clearTimeout(t);
938
- }, [
939
- query,
940
- registry
941
- ]);
942
- return services;
943
- };
944
- var emptyLines = [];
945
- var StatusLine = ({ classNames, line = -1, lines = emptyLines, transition = 300, advance = 1e3, autoAdvance }) => {
946
- const containerRef = (0, import_react8.useRef)(null);
947
- const [currentLine, setCurrentLine] = (0, import_react8.useState)(line);
948
- (0, import_react8.useEffect)(() => {
949
- setCurrentLine(line);
950
- }, [
951
- line
952
- ]);
953
- (0, import_react8.useEffect)(() => {
954
- if (!autoAdvance) {
955
- return;
956
- }
957
- const next = () => {
958
- setCurrentLine((prev) => {
959
- if (prev >= lines.length - 1) {
960
- clearInterval(interval);
961
- return prev;
962
- }
963
- return prev + 1;
964
- });
965
- };
966
- next();
967
- const interval = setInterval(next, advance);
968
- return () => clearInterval(interval);
969
- }, [
970
- lines.length,
971
- autoAdvance,
972
- advance
973
- ]);
974
- (0, import_react8.useEffect)(() => {
975
- if (containerRef.current) {
976
- containerRef.current.style.transition = `transform ${transition}ms ease-in-out`;
977
- containerRef.current.style.transform = `translateY(-${currentLine * 24}px)`;
978
- }
979
- }, [
980
- currentLine
981
- ]);
982
- return /* @__PURE__ */ import_react8.default.createElement("div", {
983
- className: (0, import_react_ui_theme3.mx)("relative h-[24px] overflow-hidden", classNames)
984
- }, /* @__PURE__ */ import_react8.default.createElement("div", {
985
- ref: containerRef,
986
- className: "h-[24px]"
987
- }, /* @__PURE__ */ import_react8.default.createElement("div", {
988
- className: "flex flex-col"
989
- }, lines.map((line2, i) => /* @__PURE__ */ import_react8.default.createElement("div", {
990
- key: i,
991
- className: (0, import_react_ui_theme3.mx)("flex h-[24px] items-center")
992
- }, /* @__PURE__ */ import_react8.default.createElement("span", {
993
- className: "truncate"
994
- }, line2))))));
995
- };
996
- var numbers = [
997
- {
998
- regular: "ph--number-circle-zero--thin",
999
- active: "ph--number-circle-zero--duotone"
1000
- },
1001
- {
1002
- regular: "ph--number-circle-one--thin",
1003
- active: "ph--number-circle-one--duotone"
1004
- },
1005
- {
1006
- regular: "ph--number-circle-two--thin",
1007
- active: "ph--number-circle-two--duotone"
1008
- },
1009
- {
1010
- regular: "ph--number-circle-three--thin",
1011
- active: "ph--number-circle-three--duotone"
1012
- },
1013
- {
1014
- regular: "ph--number-circle-four--thin",
1015
- active: "ph--number-circle-four--duotone"
1016
- },
1017
- {
1018
- regular: "ph--number-circle-five--thin",
1019
- active: "ph--number-circle-five--duotone"
1020
- },
1021
- {
1022
- regular: "ph--number-circle-six--thin",
1023
- active: "ph--number-circle-six--duotone"
1024
- },
1025
- {
1026
- regular: "ph--number-circle-seven--thin",
1027
- active: "ph--number-circle-seven--duotone"
1028
- },
1029
- {
1030
- regular: "ph--number-circle-eight--thin",
1031
- active: "ph--number-circle-eight--duotone"
1032
- },
1033
- {
1034
- regular: "ph--number-circle-nine--thin",
1035
- active: "ph--number-circle-nine--duotone"
1036
- }
1037
- ];
1038
- var Tabs = /* @__PURE__ */ (0, import_react9.forwardRef)(({ classNames, length, selected = 0, onSelect }, forwardedRef) => {
1039
- return /* @__PURE__ */ import_react9.default.createElement("div", {
1040
- ref: forwardedRef,
1041
- className: (0, import_react_ui_theme4.mx)("flex flex-col overflow-hidden outline-none", classNames),
1042
- tabIndex: -1,
1043
- onKeyDown: (ev) => {
1044
- switch (ev.key) {
1045
- case "ArrowDown":
1046
- case "ArrowRight": {
1047
- ev.preventDefault();
1048
- ev.stopPropagation();
1049
- if (selected < length - 1) {
1050
- onSelect?.(selected + 1);
1051
- }
1052
- break;
1053
- }
1054
- case "ArrowUp":
1055
- case "ArrowLeft": {
1056
- ev.preventDefault();
1057
- ev.stopPropagation();
1058
- if (selected > 0) {
1059
- onSelect?.(selected - 1);
1060
- }
1061
- break;
1062
- }
1063
- case "Enter": {
1064
- ev.preventDefault();
1065
- ev.stopPropagation();
1066
- onSelect?.(selected);
1067
- break;
1068
- }
1069
- }
1070
- }
1071
- }, Array.from({
1072
- length
1073
- }).map((_, i) => {
1074
- const icon = numbers[i + 1];
1075
- return /* @__PURE__ */ import_react9.default.createElement("div", {
1076
- key: i,
1077
- className: (0, import_react_ui_theme4.mx)("relative flex w-[24px] h-[28px] justify-center cursor-pointer text-subdued", selected === i && "!text-cyan-550 !dark:text-cyan-300")
1078
- }, i < length - 1 && /* @__PURE__ */ import_react9.default.createElement("div", {
1079
- className: "absolute left-[11.5px] top-[21px] w-[1px] h-[10px] bg-neutral-400"
1080
- }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Icon, {
1081
- icon: selected === i ? icon.regular : icon.regular,
1082
- classNames: "z-10 !p-0 !w-[24px] !h-[24px] outline-none",
1083
- onClick: () => onSelect?.(i)
1084
- }));
1085
- }));
1086
- });
1087
- var ToggleContainer = ({ classNames, title, icon, open: _open, duration = 400, shrinkX = false, children, onChangeOpen }) => {
1088
- const [open, setOpen] = (0, import_react_ui4.useControlledState)(_open);
1089
- const [expandX, setExpandX] = (0, import_react10.useState)(shrinkX ? open : true);
1090
- const [expandY, setExpandY] = (0, import_react10.useState)(open);
1091
- (0, import_react10.useEffect)(() => {
1092
- let t;
1093
- if (open) {
1094
- if (shrinkX) {
1095
- setExpandX(true);
1096
- }
1097
- t = setTimeout(() => {
1098
- setExpandY(true);
1099
- }, shrinkX ? duration : 0);
1100
- } else {
1101
- setExpandY(false);
1102
- if (shrinkX) {
1103
- t = setTimeout(() => {
1104
- setExpandX(false);
1105
- }, duration);
1106
- }
1107
- }
1108
- return () => clearTimeout(t);
1109
- }, [
1110
- open
1111
- ]);
1112
- const handleToggle = () => {
1113
- if (onChangeOpen) {
1114
- onChangeOpen(!open);
1115
- } else {
1116
- setOpen((open2) => !open2);
1117
- }
1118
- };
1119
- return /* @__PURE__ */ import_react10.default.createElement("div", {
1120
- className: (0, import_react_ui_theme5.mx)("overflow-hidden", classNames)
1121
- }, title && /* @__PURE__ */ import_react10.default.createElement("div", {
1122
- className: "flex gap-1 py-1 items-center text-sm text-subdued cursor-pointer select-none",
1123
- onClick: handleToggle
1124
- }, /* @__PURE__ */ import_react10.default.createElement("div", {
1125
- className: "flex w-[24px] h-[24px] items-center justify-center"
1126
- }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Icon, {
1127
- size: 4,
1128
- icon: "ph--caret-right--regular",
1129
- style: {
1130
- transitionDuration: `${shrinkX ? duration * 2 : duration}ms`
1131
- },
1132
- classNames: [
1133
- "transition transition-transform ease-in-out",
1134
- open ? "rotate-90" : "transform-none"
1135
- ]
1136
- })), /* @__PURE__ */ import_react10.default.createElement("div", {
1137
- className: "flex-1 pis-1 pie-1 truncate"
1138
- }, title), icon), /* @__PURE__ */ import_react10.default.createElement("div", {
1139
- style: {
1140
- transitionDuration: `${duration}ms`
1141
- },
1142
- className: (0, import_react_ui_theme5.mx)("grid transition-[grid-template-columns] ease-in-out", expandX ? "grid-cols-[1fr]" : "grid-cols-[0fr]")
1143
- }, /* @__PURE__ */ import_react10.default.createElement("div", {
1144
- className: "overflow-hidden"
1145
- }, /* @__PURE__ */ import_react10.default.createElement("div", {
1146
- style: {
1147
- transitionDuration: `${duration}ms`
1148
- },
1149
- className: (0, import_react_ui_theme5.mx)("grid transition-[grid-template-rows] ease-in-out", expandY ? "grid-rows-[1fr]" : "grid-rows-[0fr]")
1150
- }, /* @__PURE__ */ import_react10.default.createElement("div", {
1151
- className: (0, import_react_ui_theme5.mx)("flex overflow-hidden transition-opacity")
1152
- }, children)))));
1153
- };
1154
- var MarkdownViewer = ({ classNames, content = "" }) => {
1155
- return /* @__PURE__ */ import_react11.default.createElement("div", {
1156
- className: (0, import_react_ui_theme6.mx)("space-y-2", classNames)
1157
- }, /* @__PURE__ */ import_react11.default.createElement(import_react_markdown.default, {
1158
- components: {
1159
- a: ({ node, children, href, ...props }) => /* @__PURE__ */ import_react11.default.createElement("a", {
1160
- href,
1161
- className: "text-primary-500 hover:text-primary-500",
1162
- target: "_blank",
1163
- rel: "noopener noreferrer",
1164
- ...props
1165
- }, children),
1166
- ol: ({ node, children, ...props }) => /* @__PURE__ */ import_react11.default.createElement("ol", {
1167
- className: "leading-tight list-decimal pl-6",
1168
- ...(0, import_util4.omit)(props, [
1169
- "ordered"
1170
- ])
1171
- }, children),
1172
- ul: ({ node, children, ...props }) => /* @__PURE__ */ import_react11.default.createElement("ul", {
1173
- className: "leading-tight list-disc pl-6",
1174
- ...(0, import_util4.omit)(props, [
1175
- "ordered"
1176
- ])
1177
- }, children),
1178
- li: ({ node, children, ...props }) => /* @__PURE__ */ import_react11.default.createElement("li", {
1179
- className: "",
1180
- ...(0, import_util4.omit)(props, [
1181
- "ordered"
1182
- ])
1183
- }, children),
1184
- blockquote: ({ node, children, ...props }) => /* @__PURE__ */ import_react11.default.createElement("blockquote", {
1185
- className: "border-l-4 border-primary-500 pl-4 my-4 text-primary-500",
1186
- ...props
1187
- }, children),
1188
- code: ({ children, className }) => {
1189
- const [_, language] = /language-(\w+)/.exec(className || "") || [];
1190
- return /* @__PURE__ */ import_react11.default.createElement(import_react_ui_syntax_highlighter2.SyntaxHighlighter, {
1191
- PreTag: "div",
1192
- language,
1193
- className: "p-0"
1194
- }, children);
1195
- }
1196
- }
1197
- }, content));
1198
- };
1199
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadMessage.tsx";
1200
- var ThreadMessage = ({ classNames, message, collapse, debug, onSuggest, onDelete }) => {
1201
- if (typeof message !== "object") {
1202
- return /* @__PURE__ */ import_react7.default.createElement("div", {
1203
- className: (0, import_react_ui_theme2.mx)(classNames)
1204
- }, message);
1205
- }
1206
- const { role, content = [] } = message;
1207
- const toolBlocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
1208
- if (collapse && toolBlocks.length > 0) {
1209
- let request;
1210
- const items = toolBlocks.map((block) => {
1211
- switch (block.type) {
1212
- case "tool_use": {
1213
- request = block;
1214
- return {
1215
- title: `Calling ${block.name}...`,
1216
- block
1217
- };
1218
- }
1219
- case "tool_result": {
1220
- if (!request) {
1221
- import_log6.log.warn("unexpected message", {
1222
- block
1223
- }, {
1224
- F: __dxlog_file4,
1225
- L: 54,
1226
- S: void 0,
1227
- C: (f, a) => f(...a)
1228
- });
1229
- return {
1230
- title: "Error",
1231
- block
1232
- };
1233
- }
1234
- return {
1235
- title: `Processed ${request.name}`,
1236
- block
1237
- };
1238
- }
1239
- default: {
1240
- request = void 0;
1241
- return {
1242
- title: "Error",
1243
- block
1244
- };
1245
- }
1246
- }
1247
- });
1248
- return /* @__PURE__ */ import_react7.default.createElement("div", {
1249
- className: (0, import_react_ui_theme2.mx)("flex", classNames)
1250
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
1251
- className: "w-full p-1 px-2 overflow-hidden rounded-md bg-baseSurface"
1252
- }, /* @__PURE__ */ import_react7.default.createElement(TabbedContainer, {
1253
- items
1254
- })));
1255
- }
1256
- return /* @__PURE__ */ import_react7.default.createElement("div", {
1257
- className: (0, import_react_ui_theme2.mx)("flex flex-col shrink-0 gap-2")
1258
- }, debug && /* @__PURE__ */ import_react7.default.createElement("div", {
1259
- className: "text-xs text-subdued"
1260
- }, message.id, " ", onDelete && /* @__PURE__ */ import_react7.default.createElement("span", {
1261
- className: "cursor-pointer underline",
1262
- onClick: () => onDelete(message.id)
1263
- }, "delete")), content.map((block, idx) => /* @__PURE__ */ import_react7.default.createElement("div", {
1264
- key: idx,
1265
- className: (0, import_react_ui_theme2.mx)("flex", classNames, block.type === "text" && role === "user" && "justify-end")
1266
- }, /* @__PURE__ */ import_react7.default.createElement(Block, {
1267
- role,
1268
- block,
1269
- onSuggest: onSuggest ?? (() => {
1270
- })
1271
- }))));
1272
- };
1273
- var Block = ({ block, role, onSuggest }) => {
1274
- const Component = componentMap[block.type] ?? componentMap.default;
1275
- return /* @__PURE__ */ import_react7.default.createElement("div", {
1276
- className: (0, import_react_ui_theme2.mx)("p-1 px-2 overflow-hidden rounded-md", (block.type !== "text" || block.disposition) && "w-full bg-baseSurface", block.type === "text" && role === "user" && "bg-primary-200 dark:bg-primary-500")
1277
- }, /* @__PURE__ */ import_react7.default.createElement(Component, {
1278
- block,
1279
- onSuggest
1280
- }));
1281
- };
1282
- var titles = {
1283
- ["cot"]: "Chain of thought",
1284
- ["artifact"]: "Artifact",
1285
- ["tool_use"]: "Tool request",
1286
- ["tool_result"]: "Tool result"
1287
- };
1288
- var componentMap = {
1289
- text: ({ block }) => {
1290
- (0, import_invariant6.invariant)(block.type === "text", void 0, {
1291
- F: __dxlog_file4,
1292
- L: 128,
1293
- S: void 0,
1294
- A: [
1295
- "block.type === 'text'",
1296
- ""
1297
- ]
1298
- });
1299
- const title = block.disposition ? titles[block.disposition] : void 0;
1300
- if (!title) {
1301
- return /* @__PURE__ */ import_react7.default.createElement(MarkdownViewer, {
1302
- content: block.text,
1303
- classNames: [
1304
- block.disposition === "cot" && "text-sm text-subdued"
1305
- ]
1306
- });
1307
- }
1308
- return /* @__PURE__ */ import_react7.default.createElement(ToggleContainer, {
1309
- title,
1310
- icon: block.pending ? /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Icon, {
1311
- icon: "ph--circle-notch--regular",
1312
- classNames: "text-subdued ml-2 animate-spin",
1313
- size: 4
1314
- }) : void 0,
1315
- open: block.disposition === "cot"
1316
- }, /* @__PURE__ */ import_react7.default.createElement(MarkdownViewer, {
1317
- content: block.text,
1318
- classNames: [
1319
- block.disposition === "cot" && "text-sm text-subdued"
1320
- ]
1321
- }));
1322
- },
1323
- json: ({ block, onSuggest }) => {
1324
- (0, import_invariant6.invariant)(block.type === "json", void 0, {
1325
- F: __dxlog_file4,
1326
- L: 152,
1327
- S: void 0,
1328
- A: [
1329
- "block.type === 'json'",
1330
- ""
1331
- ]
1332
- });
1333
- switch (block.disposition) {
1334
- case "suggest": {
1335
- const { text = "" } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
1336
- return /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Button, {
1337
- onClick: () => onSuggest(text)
1338
- }, text);
1339
- }
1340
- case "select": {
1341
- const { options = [] } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
1342
- return /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.ButtonGroup, null, options.map((option) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Button, {
1343
- key: option,
1344
- onClick: () => onSuggest(option)
1345
- }, option)));
1346
- }
1347
- default: {
1348
- const title = block.disposition ? titles[block.disposition] : void 0;
1349
- return /* @__PURE__ */ import_react7.default.createElement(ToggleContainer, {
1350
- title: title ?? "JSON"
1351
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_syntax_highlighter.Json, {
1352
- data: (0, import_util3.safeParseJson)(block.json ?? block),
1353
- classNames: "!p-1 text-xs"
1354
- }));
1355
- }
1356
- }
1357
- },
1358
- default: ({ block }) => {
1359
- let title = titles[block.type];
1360
- if (block.type === "tool_use") {
1361
- title = `Tool [${block.name}]`;
1362
- }
1363
- return /* @__PURE__ */ import_react7.default.createElement(ToggleContainer, {
1364
- title: title ?? "JSON"
1365
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_syntax_highlighter.Json, {
1366
- data: block,
1367
- classNames: "!p-1 text-xs"
1368
- }));
1369
- }
1370
- };
1371
- var TabbedContainer = ({ items }) => {
1372
- const lines = items.map((item) => item.title);
1373
- const tabsRef = (0, import_react7.useRef)(null);
1374
- const [selected, setSelected] = (0, import_react7.useState)(0);
1375
- const [open, setOpen] = (0, import_react7.useState)(false);
1376
- (0, import_react7.useEffect)(() => {
1377
- if (open) {
1378
- tabsRef.current?.focus();
1379
- }
1380
- }, [
1381
- open
1382
- ]);
1383
- const handleSelect = (index) => {
1384
- if (index === selected) {
1385
- setOpen(false);
1386
- } else {
1387
- setSelected(index);
1388
- }
1389
- };
1390
- return /* @__PURE__ */ import_react7.default.createElement(ToggleContainer, {
1391
- title: /* @__PURE__ */ import_react7.default.createElement(StatusLine, {
1392
- lines,
1393
- autoAdvance: true
1394
- }),
1395
- open,
1396
- onChangeOpen: setOpen
1397
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
1398
- className: "flex gap-2 w-full"
1399
- }, /* @__PURE__ */ import_react7.default.createElement(Tabs, {
1400
- ref: tabsRef,
1401
- length: items.length,
1402
- selected,
1403
- onSelect: handleSelect
1404
- }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_syntax_highlighter.Json, {
1405
- data: items[selected].block,
1406
- classNames: "!p-1 text-xs"
1407
- })));
1408
- };
1409
- var Thread = ({ messages, streaming, collapse, debug, onSubmit, onStop, onSuggest, onDelete }) => {
1410
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_EQYHOTGG.AUTOMATION_PLUGIN);
1411
- const scroller = (0, import_react6.useRef)(null);
1412
- const [text, setText] = (0, import_react6.useState)("");
1413
- const handleKeyDown = (0, import_react6.useCallback)((ev) => {
1414
- switch (ev.key) {
1415
- case "Escape": {
1416
- setText("");
1417
- break;
1418
- }
1419
- case "Enter": {
1420
- const value = text.trim();
1421
- if (value.length > 0) {
1422
- scroller.current?.scrollToBottom();
1423
- onSubmit?.(value);
1424
- setText("");
1425
- }
1426
- break;
1427
- }
1428
- }
1429
- }, [
1430
- text
1431
- ]);
1432
- const { messages: lines = [] } = (0, import_react6.useMemo)(() => {
1433
- if (!collapse) {
1434
- return {
1435
- messages: messages ?? []
1436
- };
1437
- }
1438
- return (messages ?? []).reduce(({ current, messages: messages2 }, message) => {
1439
- let i = 0;
1440
- for (const block of message.content) {
1441
- switch (block.type) {
1442
- case "tool_use":
1443
- case "tool_result": {
1444
- if (current) {
1445
- current.content.push(block);
1446
- } else {
1447
- current = {
1448
- id: [
1449
- message.id,
1450
- i
1451
- ].join("_"),
1452
- role: message.role,
1453
- content: [
1454
- block
1455
- ]
1456
- };
1457
- messages2.push(current);
1458
- }
1459
- break;
1460
- }
1461
- case "text":
1462
- default: {
1463
- current = void 0;
1464
- messages2.push({
1465
- id: [
1466
- message.id,
1467
- i
1468
- ].join("_"),
1469
- role: message.role,
1470
- content: [
1471
- block
1472
- ]
1473
- });
1474
- break;
1475
- }
1476
- }
1477
- i++;
1478
- }
1479
- return {
1480
- current,
1481
- messages: messages2
1482
- };
1483
- }, {
1484
- messages: []
1485
- });
1486
- }, [
1487
- messages,
1488
- collapse
1489
- ]);
1490
- return /* @__PURE__ */ import_react6.default.createElement("div", {
1491
- className: "flex flex-col grow overflow-hidden"
1492
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components.ScrollContainer, {
1493
- ref: scroller,
1494
- classNames: "py-2 gap-2 overflow-x-hidden"
1495
- }, lines.map((message) => /* @__PURE__ */ import_react6.default.createElement(ThreadMessage, {
1496
- key: message.id,
1497
- classNames: "px-4",
1498
- message,
1499
- collapse,
1500
- debug,
1501
- onSuggest,
1502
- onDelete
1503
- }))), onSubmit && /* @__PURE__ */ import_react6.default.createElement("div", {
1504
- className: "flex p-4 gap-3 items-center"
1505
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_sfx.Spinner, {
1506
- active: streaming
1507
- }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui.Input.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui.Input.TextInput, {
1508
- autoFocus: true,
1509
- classNames: "px-2 baseSurface rounded",
1510
- placeholder: t("chat input placeholder"),
1511
- value: text,
1512
- onChange: (ev) => setText(ev.target.value),
1513
- onKeyDown: handleKeyDown
1514
- })), onStop && /* @__PURE__ */ import_react6.default.createElement(import_react_ui.IconButton, {
1515
- disabled: !streaming,
1516
- classNames: (0, import_react_ui_theme.mx)("!p-1 !opacity-20 transition", streaming && "!opacity-80"),
1517
- variant: "ghost",
1518
- size: 5,
1519
- onClick: onStop,
1520
- icon: "ph--x--regular",
1521
- label: t("chat stop"),
1522
- iconOnly: true
1523
- })));
1524
- };
1525
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/ChatContainer/ChatContainer.tsx";
1526
- var ChatContainer = ({ chat, role }) => {
1527
- const processor = useChatProcessor(chat);
1528
- const messageQueue = useMessageQueue(chat);
1529
- const messages = [
1530
- ...messageQueue?.items ?? [],
1531
- ...processor.messages.value
1532
- ];
1533
- const handleSubmit = (0, import_react.useCallback)(async (text) => {
1534
- if (processor.streaming.value) {
1535
- await processor.cancel();
1536
- }
1537
- (0, import_invariant.invariant)(messageQueue, void 0, {
1538
- F: __dxlog_file5,
1539
- L: 25,
1540
- S: void 0,
1541
- A: [
1542
- "messageQueue",
1543
- ""
1544
- ]
1545
- });
1546
- await processor.request(text, {
1547
- history: messageQueue.items,
1548
- onComplete: (messages2) => messageQueue.append(messages2)
1549
- });
1550
- }, [
1551
- processor,
1552
- messageQueue
1553
- ]);
1554
- const handleStop = (0, import_react.useCallback)(() => {
1555
- if (processor.streaming.value) {
1556
- void processor.cancel();
1557
- }
1558
- }, [
1559
- processor
1560
- ]);
1561
- return /* @__PURE__ */ import_react.default.createElement(import_react_ui_stack.StackItem.Content, {
1562
- toolbar: false,
1563
- role
1564
- }, /* @__PURE__ */ import_react.default.createElement(Thread, {
1565
- messages,
1566
- streaming: processor.streaming.value,
1567
- collapse: true,
1568
- onSubmit: handleSubmit,
1569
- onSuggest: handleSubmit,
1570
- onStop: handleStop
1571
- }));
1572
- };
1573
- var ChatContainer_default = ChatContainer;
1574
- // Annotate the CommonJS export names for ESM import in node:
1575
- 0 && (module.exports = {
1576
- AiClient,
1577
- AppGraphBuilder,
1578
- ChatContainer,
1579
- ChatContainer_default,
1580
- IntentResolver,
1581
- MarkdownViewer,
1582
- ReactSurface,
1583
- Thread,
1584
- useServices
1585
- });
1586
- //# sourceMappingURL=chunk-CJGJXNY3.cjs.map