@dxos/plugin-automation 0.7.5-labs.e27f9b9 → 0.7.5-labs.f400bbc

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 (288) 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-HKX3D3ZP.mjs → chunk-OFDNNRLE.mjs} +4 -7
  4. package/dist/lib/browser/{chunk-HKX3D3ZP.mjs.map → chunk-OFDNNRLE.mjs.map} +3 -3
  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 +22 -372
  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-WWU5FVAO.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -131
  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-5VF5JKUN.cjs → chunk-ORMEYEBE.cjs} +7 -10
  23. package/dist/lib/node/{chunk-5VF5JKUN.cjs.map → chunk-ORMEYEBE.cjs.map} +3 -3
  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 +37 -373
  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-5HYLBDC3.cjs → react-surface-2WRVAPGR.cjs} +9 -28
  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-X3LPRWIL.mjs → chunk-6MUUH67V.mjs} +4 -7
  34. package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs.map → chunk-6MUUH67V.mjs.map} +3 -3
  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 +22 -372
  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-SS5WCRJ2.mjs → react-surface-QWLPOYXO.mjs} +5 -28
  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 -11
  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 -1
  63. package/dist/types/src/meta.d.ts.map +1 -1
  64. package/dist/types/src/testing/index.d.ts +1 -1
  65. package/dist/types/src/testing/index.d.ts.map +1 -1
  66. package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +1 -3
  67. package/dist/types/src/testing/test-functions.d.ts.map +1 -0
  68. package/dist/types/src/translations.d.ts +2 -92
  69. package/dist/types/src/translations.d.ts.map +1 -1
  70. package/package.json +23 -71
  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 +1 -13
  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/TriggerEditor/TriggerEditor.tsx +8 -5
  79. package/src/components/index.ts +0 -7
  80. package/src/index.ts +2 -3
  81. package/src/meta.ts +3 -3
  82. package/src/testing/index.ts +1 -1
  83. package/src/testing/{testing.ts → test-functions.ts} +0 -7
  84. package/src/translations.ts +2 -29
  85. package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs +0 -8
  86. package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs.map +0 -7
  87. package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs +0 -12
  88. package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs.map +0 -7
  89. package/dist/lib/browser/ai-client-AARXEMMJ.mjs +0 -22
  90. package/dist/lib/browser/ai-client-AARXEMMJ.mjs.map +0 -7
  91. package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs +0 -162
  92. package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs.map +0 -7
  93. package/dist/lib/browser/chunk-5SLV6AUA.mjs +0 -1367
  94. package/dist/lib/browser/chunk-5SLV6AUA.mjs.map +0 -7
  95. package/dist/lib/browser/chunk-7XADMUOW.mjs +0 -205
  96. package/dist/lib/browser/chunk-7XADMUOW.mjs.map +0 -7
  97. package/dist/lib/browser/chunk-HZ4TA7HY.mjs +0 -15
  98. package/dist/lib/browser/chunk-HZ4TA7HY.mjs.map +0 -7
  99. package/dist/lib/browser/chunk-IYSMXX6Q.mjs +0 -283
  100. package/dist/lib/browser/chunk-IYSMXX6Q.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-RAVNWHNE.mjs +0 -242
  102. package/dist/lib/browser/chunk-RAVNWHNE.mjs.map +0 -7
  103. package/dist/lib/browser/intent-resolver-754MPV7H.mjs +0 -29
  104. package/dist/lib/browser/intent-resolver-754MPV7H.mjs.map +0 -7
  105. package/dist/lib/browser/react-surface-4QZ6AKBF.mjs +0 -50
  106. package/dist/lib/browser/react-surface-4QZ6AKBF.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-LRDEDGXI.cjs +0 -26
  110. package/dist/lib/node/AutomationPanel-LRDEDGXI.cjs.map +0 -7
  111. package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs +0 -33
  112. package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs.map +0 -7
  113. package/dist/lib/node/ai-client-SA35GN5Q.cjs +0 -38
  114. package/dist/lib/node/ai-client-SA35GN5Q.cjs.map +0 -7
  115. package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs +0 -178
  116. package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs.map +0 -7
  117. package/dist/lib/node/chunk-6VMSH4P6.cjs +0 -1364
  118. package/dist/lib/node/chunk-6VMSH4P6.cjs.map +0 -7
  119. package/dist/lib/node/chunk-HEYQONXC.cjs +0 -302
  120. package/dist/lib/node/chunk-HEYQONXC.cjs.map +0 -7
  121. package/dist/lib/node/chunk-LU4HQWJD.cjs +0 -226
  122. package/dist/lib/node/chunk-LU4HQWJD.cjs.map +0 -7
  123. package/dist/lib/node/chunk-WWU5FVAO.cjs.map +0 -7
  124. package/dist/lib/node/chunk-ZS5RZ7RM.cjs +0 -34
  125. package/dist/lib/node/chunk-ZS5RZ7RM.cjs.map +0 -7
  126. package/dist/lib/node/intent-resolver-CNVBSG4E.cjs +0 -44
  127. package/dist/lib/node/intent-resolver-CNVBSG4E.cjs.map +0 -7
  128. package/dist/lib/node/react-surface-5HYLBDC3.cjs.map +0 -7
  129. package/dist/lib/node/types/index.cjs +0 -46
  130. package/dist/lib/node/types/index.cjs.map +0 -7
  131. package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs +0 -9
  132. package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs.map +0 -7
  133. package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs +0 -13
  134. package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs.map +0 -7
  135. package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs +0 -23
  136. package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs.map +0 -7
  137. package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs +0 -163
  138. package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs.map +0 -7
  139. package/dist/lib/node-esm/chunk-3KB5HRXA.mjs +0 -284
  140. package/dist/lib/node-esm/chunk-3KB5HRXA.mjs.map +0 -7
  141. package/dist/lib/node-esm/chunk-EVTLHDM2.mjs +0 -206
  142. package/dist/lib/node-esm/chunk-EVTLHDM2.mjs.map +0 -7
  143. package/dist/lib/node-esm/chunk-ISYLEDVU.mjs +0 -16
  144. package/dist/lib/node-esm/chunk-ISYLEDVU.mjs.map +0 -7
  145. package/dist/lib/node-esm/chunk-MS7OIGVR.mjs +0 -243
  146. package/dist/lib/node-esm/chunk-MS7OIGVR.mjs.map +0 -7
  147. package/dist/lib/node-esm/chunk-WISKXX7U.mjs +0 -1368
  148. package/dist/lib/node-esm/chunk-WISKXX7U.mjs.map +0 -7
  149. package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs +0 -30
  150. package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs.map +0 -7
  151. package/dist/lib/node-esm/react-surface-SS5WCRJ2.mjs.map +0 -7
  152. package/dist/lib/node-esm/types/index.mjs +0 -25
  153. package/dist/lib/node-esm/types/index.mjs.map +0 -7
  154. package/dist/types/src/artifacts.stories.d.ts +0 -16
  155. package/dist/types/src/artifacts.stories.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  157. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
  158. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  159. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  160. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  161. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  162. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  163. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -8
  164. package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +0 -1
  165. package/dist/types/src/components/ChatContainer/index.d.ts +0 -4
  166. package/dist/types/src/components/ChatContainer/index.d.ts.map +0 -1
  167. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +0 -14
  168. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +0 -1
  169. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +0 -8
  170. package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +0 -1
  171. package/dist/types/src/components/MarkdownViewer/index.d.ts +0 -2
  172. package/dist/types/src/components/MarkdownViewer/index.d.ts.map +0 -1
  173. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
  174. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
  175. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
  176. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
  177. package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
  178. package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
  179. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
  180. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
  181. package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
  182. package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
  183. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
  184. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
  185. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
  186. package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
  187. package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
  188. package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
  189. package/dist/types/src/components/Thread/ScrollContainer.d.ts +0 -15
  190. package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +0 -1
  191. package/dist/types/src/components/Thread/StatusLine.d.ts +0 -11
  192. package/dist/types/src/components/Thread/StatusLine.d.ts.map +0 -1
  193. package/dist/types/src/components/Thread/StatusLine.stories.d.ts +0 -9
  194. package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +0 -1
  195. package/dist/types/src/components/Thread/Tabbed.d.ts +0 -9
  196. package/dist/types/src/components/Thread/Tabbed.d.ts.map +0 -1
  197. package/dist/types/src/components/Thread/Tabbed.stories.d.ts +0 -8
  198. package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +0 -1
  199. package/dist/types/src/components/Thread/Thread.d.ts +0 -11
  200. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  201. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -10
  202. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  203. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -12
  204. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  205. package/dist/types/src/components/Thread/ToggleContainer.d.ts +0 -13
  206. package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +0 -1
  207. package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts +0 -9
  208. package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +0 -1
  209. package/dist/types/src/components/Thread/index.d.ts +0 -2
  210. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  211. package/dist/types/src/hooks/email.d.ts +0 -4
  212. package/dist/types/src/hooks/email.d.ts.map +0 -1
  213. package/dist/types/src/hooks/index.d.ts +0 -4
  214. package/dist/types/src/hooks/index.d.ts.map +0 -1
  215. package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
  216. package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
  217. package/dist/types/src/hooks/processor.d.ts +0 -65
  218. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  219. package/dist/types/src/hooks/processor.test.d.ts +0 -2
  220. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  221. package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
  222. package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
  223. package/dist/types/src/hooks/useServiceRegistry.d.ts +0 -3
  224. package/dist/types/src/hooks/useServiceRegistry.d.ts.map +0 -1
  225. package/dist/types/src/presets.d.ts +0 -9
  226. package/dist/types/src/presets.d.ts.map +0 -1
  227. package/dist/types/src/testing/testing.d.ts.map +0 -1
  228. package/dist/types/src/tools/function.d.ts +0 -5
  229. package/dist/types/src/tools/function.d.ts.map +0 -1
  230. package/dist/types/src/tools/index.d.ts +0 -3
  231. package/dist/types/src/tools/index.d.ts.map +0 -1
  232. package/dist/types/src/tools/openapi.d.ts +0 -10
  233. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  234. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  235. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  236. package/dist/types/src/types/index.d.ts +0 -4
  237. package/dist/types/src/types/index.d.ts.map +0 -1
  238. package/dist/types/src/types/registry.d.ts +0 -9
  239. package/dist/types/src/types/registry.d.ts.map +0 -1
  240. package/dist/types/src/types/schema.d.ts +0 -196
  241. package/dist/types/src/types/schema.d.ts.map +0 -1
  242. package/dist/types/src/types/types.d.ts +0 -18
  243. package/dist/types/src/types/types.d.ts.map +0 -1
  244. package/src/artifacts.stories.tsx +0 -241
  245. package/src/capabilities/ai-client.ts +0 -19
  246. package/src/capabilities/app-graph-builder.ts +0 -156
  247. package/src/capabilities/capabilities.ts +0 -12
  248. package/src/capabilities/intent-resolver.ts +0 -27
  249. package/src/components/ChatContainer/ChatContainer.tsx +0 -117
  250. package/src/components/ChatContainer/index.ts +0 -8
  251. package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +0 -56
  252. package/src/components/MarkdownViewer/MarkdownViewer.tsx +0 -79
  253. package/src/components/MarkdownViewer/index.ts +0 -5
  254. package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
  255. package/src/components/PromptEditor/PromptEditor.tsx +0 -222
  256. package/src/components/PromptEditor/index.ts +0 -5
  257. package/src/components/PromptEditor/prompt-extension.ts +0 -43
  258. package/src/components/PromptEditor/types.tsx +0 -28
  259. package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -48
  260. package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -75
  261. package/src/components/ServiceRegistry/index.ts +0 -5
  262. package/src/components/Thread/ScrollContainer.tsx +0 -92
  263. package/src/components/Thread/StatusLine.stories.tsx +0 -52
  264. package/src/components/Thread/StatusLine.tsx +0 -76
  265. package/src/components/Thread/Tabbed.stories.tsx +0 -52
  266. package/src/components/Thread/Tabbed.tsx +0 -72
  267. package/src/components/Thread/Thread.stories.tsx +0 -190
  268. package/src/components/Thread/Thread.tsx +0 -156
  269. package/src/components/Thread/ThreadMessage.tsx +0 -195
  270. package/src/components/Thread/ToggleContainer.stories.tsx +0 -111
  271. package/src/components/Thread/ToggleContainer.tsx +0 -103
  272. package/src/components/Thread/index.ts +0 -5
  273. package/src/hooks/email.ts +0 -49
  274. package/src/hooks/index.ts +0 -8
  275. package/src/hooks/invocation-handler.ts +0 -109
  276. package/src/hooks/processor.test.ts +0 -15
  277. package/src/hooks/processor.ts +0 -201
  278. package/src/hooks/useLocalTriggerManager.ts +0 -82
  279. package/src/hooks/useServiceRegistry.ts +0 -22
  280. package/src/presets.ts +0 -248
  281. package/src/tools/function.ts +0 -47
  282. package/src/tools/index.ts +0 -6
  283. package/src/tools/openapi.test.ts +0 -227
  284. package/src/tools/openapi.ts +0 -331
  285. package/src/types/index.ts +0 -7
  286. package/src/types/registry.ts +0 -89
  287. package/src/types/schema.ts +0 -120
  288. package/src/types/types.ts +0 -21
@@ -1,47 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { defineTool, ToolResult } from '@dxos/artifact';
6
- import type { Tool } from '@dxos/artifact';
7
- import { toEffectSchema } from '@dxos/echo-schema';
8
- import { getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
9
- import type { FunctionType } from '@dxos/functions';
10
- import { log } from '@dxos/log';
11
- import type { SpaceId } from '@dxos/react-client/echo';
12
- import { getMeta } from '@dxos/react-client/echo';
13
-
14
- export const covertFunctionToTool = (
15
- fn: FunctionType,
16
- edgeUrl: string,
17
- spaceId?: SpaceId | undefined,
18
- ): Tool | undefined => {
19
- if (!fn.description || !fn.inputSchema) {
20
- return undefined;
21
- }
22
-
23
- const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
24
- if (!existingFunctionUrl) {
25
- return undefined;
26
- }
27
- const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
28
- spaceId,
29
- });
30
-
31
- return defineTool({
32
- name: fn.name,
33
- description: fn.description,
34
- schema: toEffectSchema(fn.inputSchema),
35
- execute: async (input) => {
36
- log.info('execute function tool', { name: fn.name, url, input });
37
- const response = await fetch(url, {
38
- method: 'POST',
39
- headers: {
40
- 'Content-Type': 'application/json',
41
- },
42
- body: JSON.stringify(input),
43
- });
44
- return ToolResult.Success(await response.text());
45
- },
46
- });
47
- };
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export * from './function';
6
- export * from './openapi';
@@ -1,227 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { describe, expect, test } from 'vitest';
6
-
7
- import { AIServiceClientImpl } from '@dxos/assistant';
8
- import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
9
- import { log } from '@dxos/log';
10
-
11
- import { createToolsFromApi, resolveAuthorization } from './openapi';
12
- import { ChatProcessor } from '../hooks';
13
- import type { ApiAuthorization } from '../types';
14
-
15
- describe('openapi', () => {
16
- describe('mapping', () => {
17
- test('amadeus flight availabilities', async () => {
18
- const tools = await createToolsFromApi(FLIGHT_SEARCH_API);
19
-
20
- log.info('tools', { tools });
21
- // for (const tool of tools) {
22
- // const schema = tool.parameters;
23
- // // log.info('schema', { schema });
24
- // }
25
- });
26
-
27
- test('amadeus hotel search', async () => {
28
- const tools = await createToolsFromApi(HOTEL_SEARCH_API);
29
-
30
- log.info('tools', { tools });
31
- });
32
-
33
- test('amadeus hotel name autocomplete', async () => {
34
- const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API);
35
-
36
- log.info('tools', { tools });
37
- });
38
-
39
- test.only('weather', async () => {
40
- const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
41
-
42
- log.info('tools', { tools });
43
- });
44
- });
45
-
46
- describe.skip('invoke tools', () => {
47
- test('amadeus hotel name autocomplete', async () => {
48
- const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
49
-
50
- const result = await tools[0].execute!({
51
- keyword: 'William Vale Brooklyn',
52
- subType: ['HOTEL_LEISURE', 'HOTEL_GDS'],
53
- countryCode: 'US',
54
- });
55
-
56
- log.info('result', { result });
57
- });
58
-
59
- test('weather API', async () => {
60
- const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
61
- const forecastTool = tools.find((t) => t.name.includes('forecast'));
62
-
63
- const result = await forecastTool?.execute!({
64
- locations: 'Brooklyn, NY',
65
- aggregateHours: '24',
66
- });
67
-
68
- log.info('result', { result });
69
- });
70
- });
71
-
72
- describe.skip('AI uses tools', () => {
73
- test('amadeus flight availabilities', { timeout: 60_000 }, async () => {
74
- const tools = await createToolsFromApi(FLIGHT_SEARCH_API, {
75
- authorization: AMADEUS_AUTH,
76
- });
77
-
78
- const client = new AIServiceClientImpl({
79
- endpoint: AI_SERVICE_ENDPOINT.LOCAL,
80
- });
81
- const processor = new ChatProcessor(client, tools);
82
- const reply = await processor.request(
83
- `What is the cheapest flight from New York to Paris? going on ${new Date().toISOString()} and returning after a week. 1 adult traveler`,
84
- );
85
-
86
- log.info('reply', { reply });
87
- });
88
-
89
- // TODO(dmaretskyi): Doesn't work.
90
- test('amadeus hotel name autocomplete', { timeout: 60_000 }, async () => {
91
- const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
92
-
93
- const client = new AIServiceClientImpl({
94
- endpoint: AI_SERVICE_ENDPOINT.LOCAL,
95
- });
96
- const processor = new ChatProcessor(client, tools);
97
- const reply = await processor.request('Find me the William Wale in Brooklyn New York');
98
-
99
- log.info('reply', { reply });
100
- });
101
-
102
- test.only('weather forecast', { timeout: 60_000 }, async () => {
103
- const tools = await createToolsFromApi(WEATHER_API, {
104
- authorization: VISUAL_CROSSING_CREDENTIALS,
105
- instructions: WEATHER_INSTRUCTIONS,
106
- });
107
-
108
- const client = new AIServiceClientImpl({
109
- endpoint: AI_SERVICE_ENDPOINT.LOCAL,
110
- });
111
- const processor = new ChatProcessor(client, tools);
112
- const reply = await processor.request(
113
- `Today's date is ${new Date().toISOString().split('T')[0]}. Give me weather forecast for Warsaw for next 5 days.`,
114
- );
115
-
116
- log.info('reply', { reply });
117
- });
118
- });
119
-
120
- describe.skip('invoke api directly', { timeout: 10_000 }, () => {
121
- test('amadeus flight availabilities', async () => {
122
- const response = await fetch('https://test.api.amadeus.com/v1/shopping/availability/flight-availabilities', {
123
- method: 'POST',
124
- headers: {
125
- accept: 'application/vnd.amadeus+json',
126
- 'X-HTTP-Method-Override': 'GET',
127
- 'Content-Type': 'application/vnd.amadeus+json',
128
- Authorization: await resolveAuthorization(AMADEUS_AUTH),
129
- },
130
- body: JSON.stringify({
131
- originDestinations: [
132
- {
133
- departureDateTime: {
134
- date: new Date().toISOString().split('T')[0],
135
- time: new Date().toTimeString().split(' ')[0],
136
- },
137
- destinationLocationCode: 'MAD',
138
- id: '1',
139
- originLocationCode: 'BOS',
140
- },
141
- ],
142
- sources: ['GDS'],
143
- travelers: [
144
- {
145
- id: '1',
146
- travelerType: 'ADULT',
147
- },
148
- ],
149
- }),
150
- });
151
-
152
- log.info('response', { status: response.status, body: await response.json() });
153
- expect(response.status).toBe(200);
154
- });
155
-
156
- test.only('amadeus hotel name autocomplete', async () => {
157
- const response = await fetch(
158
- 'https://test.api.amadeus.com/v1/reference-data/locations/hotel?keyword=PARI&subtype=HOTEL_LEISURE,HOTEL_GDS',
159
- {
160
- method: 'GET',
161
- headers: {
162
- // accept: 'application/vnd.amadeus+json',
163
- // 'X-HTTP-Method-Override': 'GET',
164
- Authorization: await resolveAuthorization(AMADEUS_AUTH),
165
- },
166
- },
167
- );
168
-
169
- log.info('response', { status: response.status, body: await response.json() });
170
- expect(response.status).toBe(200);
171
- });
172
- });
173
-
174
- describe.skip('rapidapi', () => {
175
- test('amadeus flight availabilities', async () => {
176
- const departureDate = new Date().toISOString().split('T')[0];
177
- const arrivalDate = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
178
-
179
- const url = `https://amadeus-api2.p.rapidapi.com/serpapi-flight-search?departure_id=PEK&arrival_id=AUS&outbound_date=${departureDate}&return_date=${arrivalDate}&currency=USD&hl=en`;
180
- const options = {
181
- method: 'GET',
182
- headers: {
183
- 'x-rapidapi-key': RAPID_API_CREDENTIALS.key,
184
- 'x-rapidapi-host': 'amadeus-api2.p.rapidapi.com',
185
- },
186
- };
187
-
188
- const response = await fetch(url, options);
189
- log.info('response', { status: response.status, body: await response.json() });
190
- expect(response.status).toBe(200);
191
- });
192
- });
193
- });
194
-
195
- const FLIGHT_SEARCH_API =
196
- 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json';
197
- const HOTEL_SEARCH_API = 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json';
198
- const HOTEL_NAME_AUTOCOMPLETE_API =
199
- 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-name-autocomplete/1.0.3/swagger.json';
200
- const WEATHER_API = 'https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json';
201
-
202
- const WEATHER_INSTRUCTIONS = `
203
- If the user doesn't provide a date, use today's date.
204
- Make sure to provide the start and end dates when possible to reduce the amount of data returned.
205
- Use the tool that accepts the date parameters.
206
- `;
207
-
208
- const AMADEUS_AUTH: ApiAuthorization = {
209
- type: 'oauth',
210
- clientId: 'BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG',
211
- clientSecret: 'n4qldSN7usvD57gm',
212
- tokenUrl: 'https://test.api.amadeus.com/v1/security/oauth2/token',
213
- grantType: 'client_credentials',
214
- };
215
-
216
- const VISUAL_CROSSING_CREDENTIALS: ApiAuthorization = {
217
- type: 'api-key',
218
- key: 'FDPRVS953KB4GQQLD25GRT975',
219
- placement: {
220
- type: 'query',
221
- name: 'key',
222
- },
223
- };
224
-
225
- const RAPID_API_CREDENTIALS = {
226
- key: '92271b6740msh32fd821d70f050dp16665bjsna69195c9e838',
227
- };
@@ -1,331 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import jsonpointer from 'jsonpointer';
6
- import { type OpenAPIV2, type OpenAPIV3_1 } from 'openapi-types';
7
-
8
- import { ToolResult, type Tool } from '@dxos/artifact';
9
- import { JsonSchemaType, normalizeSchema, S, toEffectSchema } from '@dxos/echo-schema';
10
- import { invariant } from '@dxos/invariant';
11
- import { log } from '@dxos/log';
12
- import { deepMapValues } from '@dxos/util';
13
-
14
- import type { ApiAuthorization, ServiceType } from '../types';
15
-
16
- export type CreateToolsFromApiOptions = {
17
- authorization?: ApiAuthorization;
18
- instructions?: string;
19
- };
20
-
21
- export const createToolsFromService = async (service: ServiceType): Promise<Tool[]> => {
22
- invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === 'api');
23
- const iface = service.interfaces[0];
24
- invariant(iface.schemaUrl);
25
- invariant(iface.schemaUrl);
26
- return createToolsFromApi(iface.schemaUrl, { authorization: iface.authorization });
27
- };
28
-
29
- export const createToolsFromApi = async (url: string, options?: CreateToolsFromApiOptions): Promise<Tool[]> => {
30
- const res = await fetch(url);
31
- const spec = (await res.json()) as OpenAPIV2.Document;
32
- log('spec', { spec });
33
-
34
- const tools: Tool[] = [];
35
- for (const [path, pathItem] of Object.entries(spec.paths)) {
36
- if (typeof pathItem !== 'object') {
37
- continue;
38
- }
39
-
40
- // TODO(burdon): ???
41
- const { ...methods } = pathItem;
42
- for (const [method, m] of Object.entries(methods)) {
43
- const methodItem: OpenAPIV2.OperationObject = m as OpenAPIV2.OperationObject;
44
- log('methodItem', { path, method, methodItem });
45
-
46
- const parametersResolved: OpenAPIV2.ParameterObject[] =
47
- methodItem.parameters?.map((parameter: any) => {
48
- const resolved = resolveJsonSchema(parameter, spec);
49
- return resolved;
50
- }) ?? [];
51
-
52
- const inputSchema: JsonSchemaType = {
53
- type: 'object',
54
- properties: {},
55
- };
56
-
57
- const endpointParameters: OpenAPIV2.ParameterObject[] = [];
58
- for (const parameter of parametersResolved) {
59
- log('parameter', { parameter });
60
-
61
- if (
62
- options?.authorization?.type === 'api-key' &&
63
- options.authorization.placement.type === 'query' &&
64
- parameter.in === 'query' &&
65
- parameter.name === options.authorization.placement.name
66
- ) {
67
- continue;
68
- }
69
-
70
- endpointParameters.push(parameter);
71
-
72
- if (parameter.schema) {
73
- inputSchema.properties![parameter.name] = normalizeSchema(parameter.schema);
74
- } else if (typeof parameter.type === 'string') {
75
- const { name, in: _in, required, ...schema } = parameter;
76
- inputSchema.properties![name] = normalizeSchema(schema);
77
- if (required) {
78
- inputSchema.required ??= [];
79
- inputSchema.required!.push(name);
80
- }
81
- }
82
- }
83
-
84
- log('inputSchema', { inputSchema });
85
- S.validateSync(JsonSchemaType)(inputSchema);
86
-
87
- const description = methodItem.description ?? methodItem.summary;
88
- if (!description) {
89
- log.warn('no description', { path, method });
90
- continue;
91
- }
92
-
93
- const endpoint: EndpointDescriptor = {
94
- document: spec,
95
- path,
96
- method,
97
- parameters: endpointParameters,
98
- authorization: options?.authorization,
99
- };
100
-
101
- tools.push({
102
- name: getToolName(path, method, methodItem),
103
- description: options?.instructions ? `${options.instructions}\n\n${description}` : description,
104
- parameters: inputSchema,
105
- execute: async (input) => {
106
- const response = await callApiEndpoint(endpoint, input);
107
- return ToolResult.Success(response);
108
- },
109
- });
110
- }
111
- }
112
-
113
- return tools;
114
- };
115
-
116
- const getToolName = (path: string, method: string, methodItem: OpenAPIV2.OperationObject) => {
117
- if (methodItem.operationId) {
118
- return methodItem.operationId;
119
- }
120
-
121
- // Generate a name from the path and method.
122
- let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, '_')}`;
123
- while (name.length > MAX_TOOL_NAME_LENGTH) {
124
- const lengthBefore = name.length;
125
-
126
- for (const word of GENERIC_WORDS) {
127
- if (name.includes(word)) {
128
- name = name.replace(word, '');
129
- break;
130
- }
131
- }
132
- name = name.replaceAll('__', '_').replace(/_$/, '');
133
-
134
- const lengthAfter = name.length;
135
- if (lengthBefore === lengthAfter) {
136
- break;
137
- }
138
- }
139
- name = name.replaceAll('__', '_').replace(/_$/, '').replace(/^_/, '');
140
-
141
- return name.slice(0, MAX_TOOL_NAME_LENGTH);
142
- };
143
-
144
- const MAX_TOOL_NAME_LENGTH = 64;
145
- const GENERIC_WORDS = [
146
- 'services',
147
- 'service',
148
- 'api',
149
- 'rest',
150
- 'endpoint',
151
- 'get',
152
- 'post',
153
- 'put',
154
- 'delete',
155
- 'patch',
156
- 'head',
157
- 'options',
158
- 'trace',
159
- 'service',
160
- 'api',
161
- 'endpoint',
162
- ];
163
-
164
- type EndpointDescriptor = {
165
- document: OpenAPIV3_1.Document | OpenAPIV2.Document;
166
- path: string;
167
- method: string;
168
- parameters: OpenAPIV2.ParameterObject[];
169
- authorization?: ApiAuthorization;
170
- };
171
-
172
- const callApiEndpoint = async (endpoint: EndpointDescriptor, input: any) => {
173
- log.info('endpoint', { method: endpoint.method, name: endpoint.path, input });
174
-
175
- let url = getEndpointUrl(endpoint);
176
- const request: RequestInit = {
177
- method: endpoint.method,
178
- headers: {},
179
- };
180
- const query = new URLSearchParams();
181
- let body: any;
182
- for (const parameter of endpoint.parameters) {
183
- if (input[parameter.name] === undefined) {
184
- continue;
185
- }
186
-
187
- switch (parameter.in) {
188
- case 'header': {
189
- if (parameter.example) {
190
- (request.headers as any)[parameter.name] = parameter.default;
191
- }
192
- break;
193
- }
194
- case 'path': {
195
- url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
196
- break;
197
- }
198
- case 'body': {
199
- const value = input[parameter.name];
200
-
201
- // Client-side validation
202
- const effectSchema = toEffectSchema(parameter.schema);
203
- S.validateSync(effectSchema)(value);
204
-
205
- if (body) {
206
- throw new Error(`Duplicate body parameter: ${parameter.name}`);
207
- }
208
- body = value;
209
- break;
210
- }
211
- case 'query': {
212
- query.set(parameter.name, input[parameter.name]);
213
- break;
214
- }
215
- }
216
- }
217
-
218
- if (
219
- (endpoint.authorization?.type === 'api-key' && endpoint.authorization.placement.type === 'authorization-header') ||
220
- endpoint.authorization?.type === 'oauth'
221
- ) {
222
- (request.headers as any).Authorization = await resolveAuthorization(endpoint.authorization);
223
- } else if (endpoint.authorization?.type === 'api-key' && endpoint.authorization.placement.type === 'query') {
224
- query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
225
- }
226
-
227
- if (query.size > 0) {
228
- url += `?${query.toString()}`;
229
- }
230
-
231
- if (body) {
232
- request.body = JSON.stringify(body);
233
- (request.headers as any)['Content-Type'] = 'application/json';
234
- }
235
-
236
- log.info('request', { url, request });
237
- const response = await fetch(url, request);
238
-
239
- log.info('response', { ok: response.ok, status: response.status, statusText: response.statusText });
240
-
241
- if (response.ok) {
242
- const contentType = response.headers.get('Content-Type');
243
- if (contentType?.includes('application/json')) {
244
- return await response.json();
245
- } else {
246
- return await response.text();
247
- }
248
- } else {
249
- if (response.headers.get('Content-Type')?.includes('application/json')) {
250
- const responseBody = await response.text();
251
- let error: any;
252
- try {
253
- error = JSON.parse(responseBody);
254
- } catch {
255
- error = responseBody;
256
- }
257
- log.error('error', { error });
258
- throw new Error(error.message);
259
- } else {
260
- const error = await response.text();
261
- log.error('error', { error });
262
- throw new Error(error);
263
- }
264
- }
265
- };
266
-
267
- const getEndpointUrl = (endpoint: EndpointDescriptor) => {
268
- let url = '';
269
- if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
270
- url = endpoint.document.servers[0].url;
271
- } else {
272
- invariant(!isV3_1(endpoint.document));
273
- url = `${endpoint.document.schemes?.[0] ?? 'https'}://${endpoint.document.host}`;
274
- }
275
-
276
- if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
277
- url += endpoint.document.basePath;
278
- }
279
-
280
- url += endpoint.path;
281
-
282
- return url;
283
- };
284
-
285
- export const resolveAuthorization = async (authorization: ApiAuthorization): Promise<string> => {
286
- switch (authorization.type) {
287
- case 'api-key': {
288
- invariant(authorization.placement.type === 'authorization-header');
289
- return `Bearer ${authorization.key}`;
290
- }
291
- case 'oauth': {
292
- const response = await fetch(authorization.tokenUrl, {
293
- method: 'POST',
294
- headers: {
295
- 'Content-Type': 'application/x-www-form-urlencoded',
296
- },
297
- body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`,
298
- });
299
- const data = await response.json();
300
- return `Bearer ${data.access_token}`;
301
- }
302
- default: {
303
- throw new Error(`Unknown authorization type: ${(authorization as any).type}`);
304
- }
305
- }
306
- };
307
-
308
- /**
309
- * Resolves all $ref properties in a JSON schema.
310
- * Doesn't assume the structure of the schema.
311
- * The function looks from $ref properties in the schema and resolves them to their values in the base object.
312
- */
313
- const resolveJsonSchema = (schema: any, base: any) => {
314
- return deepMapValues(schema, (value, recurse) => {
315
- if (typeof value === 'object' && value !== null && '$ref' in value && typeof value.$ref === 'string') {
316
- if (value.$ref.startsWith('#')) {
317
- const resolved = jsonpointer.get(base, value.$ref.slice(1));
318
- if (resolved) {
319
- return recurse(resolved);
320
- } else {
321
- log.warn('unresolved', { ref: value.$ref, base });
322
- }
323
- }
324
- }
325
- return recurse(value);
326
- });
327
- };
328
-
329
- const isV3_1 = (document: OpenAPIV3_1.Document | OpenAPIV2.Document): document is OpenAPIV3_1.Document => {
330
- return (document as any).openapi === '3.0.1';
331
- };
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './registry';
6
- export * from './schema';
7
- export * from './types';