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