@composio/client 0.1.0-alpha.8 → 2.0.0-rc.1

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 (815) hide show
  1. package/README.md +32 -354
  2. package/dist/api-key-revocation-BZL5FAx7.mjs +24 -0
  3. package/dist/auth-CEq4JqWm.mjs +17 -0
  4. package/dist/auth-configs-CyksMqNB.mjs +48 -0
  5. package/dist/clanker-4wByThQJ.mjs +23 -0
  6. package/dist/cli-Bi4_ORQO.mjs +45 -0
  7. package/dist/client-CK6bm7nf.d.mts +22777 -0
  8. package/dist/config-BLBbhLe1.mjs +10 -0
  9. package/dist/config-DnyMhILW.d.mts +9 -0
  10. package/dist/connected-accounts-B-qN_yLT.mjs +67 -0
  11. package/dist/consumer-DWlaGBmh.mjs +34 -0
  12. package/dist/custom-BQWoONFY.mjs +22 -0
  13. package/dist/files-B-UnEejx.mjs +29 -0
  14. package/dist/files-CNZ-ttVS.mjs +45 -0
  15. package/dist/generate-DSqfJENZ.mjs +22 -0
  16. package/dist/index.d.mts +5 -0
  17. package/dist/index.mjs +1091 -0
  18. package/dist/link-CukKZMxs.mjs +22 -0
  19. package/dist/logs-B87z4hq7.mjs +36 -0
  20. package/dist/manage-By-b66OH.mjs +26 -0
  21. package/dist/mcp-B0wla_93.mjs +73 -0
  22. package/dist/migration-CBhnoN-Y.mjs +10 -0
  23. package/dist/migration-CKGKuRO3.d.mts +9 -0
  24. package/dist/org-BSq_z6fP.mjs +44 -0
  25. package/dist/owner-BDkEFEVF.mjs +17 -0
  26. package/dist/project-C0h91WGF.mjs +42 -0
  27. package/dist/project-Cj-NKnWZ.mjs +24 -0
  28. package/dist/project-D-c0Zrrl.mjs +22 -0
  29. package/dist/project-_s0fWHut.mjs +29 -0
  30. package/dist/realtime-BcHoYszT.mjs +26 -0
  31. package/dist/request-DwPfYYNF.mjs +1203 -0
  32. package/dist/resources/api-key-revocation.d.mts +2 -0
  33. package/dist/resources/api-key-revocation.mjs +3 -0
  34. package/dist/resources/auth/auth.d.mts +2 -0
  35. package/dist/resources/auth/auth.mjs +3 -0
  36. package/dist/resources/auth/index.d.mts +2 -0
  37. package/dist/resources/auth/index.mjs +4 -0
  38. package/dist/resources/auth/session.d.mts +2 -0
  39. package/dist/resources/auth/session.mjs +3 -0
  40. package/dist/resources/auth-configs.d.mts +2 -0
  41. package/dist/resources/auth-configs.mjs +3 -0
  42. package/dist/resources/auth.d.mts +2 -0
  43. package/dist/resources/auth.mjs +5 -0
  44. package/dist/resources/cli/cli.d.mts +2 -0
  45. package/dist/resources/cli/cli.mjs +3 -0
  46. package/dist/resources/cli/index.d.mts +2 -0
  47. package/dist/resources/cli/index.mjs +4 -0
  48. package/dist/resources/cli/realtime.d.mts +2 -0
  49. package/dist/resources/cli/realtime.mjs +3 -0
  50. package/dist/resources/cli.d.mts +2 -0
  51. package/dist/resources/cli.mjs +5 -0
  52. package/dist/resources/connected-accounts.d.mts +2 -0
  53. package/dist/resources/connected-accounts.mjs +3 -0
  54. package/dist/resources/files.d.mts +2 -0
  55. package/dist/resources/files.mjs +3 -0
  56. package/dist/resources/index.d.mts +3 -0
  57. package/dist/resources/index.mjs +16 -0
  58. package/dist/resources/link.d.mts +2 -0
  59. package/dist/resources/link.mjs +3 -0
  60. package/dist/resources/logs/index.d.mts +2 -0
  61. package/dist/resources/logs/index.mjs +5 -0
  62. package/dist/resources/logs/logs.d.mts +2 -0
  63. package/dist/resources/logs/logs.mjs +3 -0
  64. package/dist/resources/logs/tools.d.mts +2 -0
  65. package/dist/resources/logs/tools.mjs +3 -0
  66. package/dist/resources/logs/triggers.d.mts +2 -0
  67. package/dist/resources/logs/triggers.mjs +3 -0
  68. package/dist/resources/logs.d.mts +2 -0
  69. package/dist/resources/logs.mjs +6 -0
  70. package/dist/resources/mcp/custom.d.mts +2 -0
  71. package/dist/resources/mcp/custom.mjs +3 -0
  72. package/dist/resources/mcp/generate.d.mts +2 -0
  73. package/dist/resources/mcp/generate.mjs +3 -0
  74. package/dist/resources/mcp/index.d.mts +2 -0
  75. package/dist/resources/mcp/index.mjs +5 -0
  76. package/dist/resources/mcp/mcp.d.mts +2 -0
  77. package/dist/resources/mcp/mcp.mjs +3 -0
  78. package/dist/resources/mcp.d.mts +2 -0
  79. package/dist/resources/mcp.mjs +6 -0
  80. package/dist/resources/migration.d.mts +2 -0
  81. package/dist/resources/migration.mjs +3 -0
  82. package/dist/resources/org/clanker.d.mts +2 -0
  83. package/dist/resources/org/clanker.mjs +3 -0
  84. package/dist/resources/org/consumer/consumer.d.mts +2 -0
  85. package/dist/resources/org/consumer/consumer.mjs +3 -0
  86. package/dist/resources/org/consumer/index.d.mts +2 -0
  87. package/dist/resources/org/consumer/index.mjs +4 -0
  88. package/dist/resources/org/consumer/project.d.mts +2 -0
  89. package/dist/resources/org/consumer/project.mjs +3 -0
  90. package/dist/resources/org/consumer.d.mts +2 -0
  91. package/dist/resources/org/consumer.mjs +5 -0
  92. package/dist/resources/org/index.d.mts +2 -0
  93. package/dist/resources/org/index.mjs +8 -0
  94. package/dist/resources/org/org.d.mts +2 -0
  95. package/dist/resources/org/org.mjs +3 -0
  96. package/dist/resources/org/owner/index.d.mts +2 -0
  97. package/dist/resources/org/owner/index.mjs +4 -0
  98. package/dist/resources/org/owner/owner.d.mts +2 -0
  99. package/dist/resources/org/owner/owner.mjs +3 -0
  100. package/dist/resources/org/owner/project.d.mts +2 -0
  101. package/dist/resources/org/owner/project.mjs +3 -0
  102. package/dist/resources/org/owner.d.mts +2 -0
  103. package/dist/resources/org/owner.mjs +5 -0
  104. package/dist/resources/org/project.d.mts +2 -0
  105. package/dist/resources/org/project.mjs +3 -0
  106. package/dist/resources/org/usage.d.mts +2 -0
  107. package/dist/resources/org/usage.mjs +3 -0
  108. package/dist/resources/org.d.mts +2 -0
  109. package/dist/resources/org.mjs +9 -0
  110. package/dist/resources/project/config.d.mts +2 -0
  111. package/dist/resources/project/config.mjs +3 -0
  112. package/dist/resources/project/index.d.mts +3 -0
  113. package/dist/resources/project/index.mjs +4 -0
  114. package/dist/resources/project/project.d.mts +2 -0
  115. package/dist/resources/project/project.mjs +3 -0
  116. package/dist/resources/project/usage.d.mts +2 -0
  117. package/dist/resources/project/usage.mjs +3 -0
  118. package/dist/resources/project.d.mts +3 -0
  119. package/dist/resources/project.mjs +5 -0
  120. package/dist/resources/tool-router/index.d.mts +2 -0
  121. package/dist/resources/tool-router/index.mjs +4 -0
  122. package/dist/resources/tool-router/session/files.d.mts +2 -0
  123. package/dist/resources/tool-router/session/files.mjs +3 -0
  124. package/dist/resources/tool-router/session/index.d.mts +2 -0
  125. package/dist/resources/tool-router/session/index.mjs +4 -0
  126. package/dist/resources/tool-router/session/session.d.mts +2 -0
  127. package/dist/resources/tool-router/session/session.mjs +3 -0
  128. package/dist/resources/tool-router/session.d.mts +2 -0
  129. package/dist/resources/tool-router/session.mjs +5 -0
  130. package/dist/resources/tool-router/tool-router.d.mts +2 -0
  131. package/dist/resources/tool-router/tool-router.mjs +3 -0
  132. package/dist/resources/tool-router.d.mts +2 -0
  133. package/dist/resources/tool-router.mjs +5 -0
  134. package/dist/resources/toolkits.d.mts +2 -0
  135. package/dist/resources/toolkits.mjs +3 -0
  136. package/dist/resources/tools.d.mts +2 -0
  137. package/dist/resources/tools.mjs +3 -0
  138. package/dist/resources/trigger-instances/index.d.mts +2 -0
  139. package/dist/resources/trigger-instances/index.mjs +4 -0
  140. package/dist/resources/trigger-instances/manage.d.mts +2 -0
  141. package/dist/resources/trigger-instances/manage.mjs +3 -0
  142. package/dist/resources/trigger-instances/trigger-instances.d.mts +2 -0
  143. package/dist/resources/trigger-instances/trigger-instances.mjs +3 -0
  144. package/dist/resources/trigger-instances.d.mts +2 -0
  145. package/dist/resources/trigger-instances.mjs +5 -0
  146. package/dist/resources/triggers-types.d.mts +2 -0
  147. package/dist/resources/triggers-types.mjs +3 -0
  148. package/dist/resources/webhook-endpoints.d.mts +2 -0
  149. package/dist/resources/webhook-endpoints.mjs +3 -0
  150. package/dist/resources/webhook-subscriptions.d.mts +2 -0
  151. package/dist/resources/webhook-subscriptions.mjs +3 -0
  152. package/dist/session-DNm4GFO-.mjs +21 -0
  153. package/dist/session-Do3wHYNe.mjs +97 -0
  154. package/dist/tool-router-5OfsPkJ_.mjs +14 -0
  155. package/dist/toolkits-CcE90C2S.mjs +43 -0
  156. package/dist/tools-B5uEInC8.mjs +30 -0
  157. package/dist/tools-CdVgfSpk.mjs +63 -0
  158. package/dist/trigger-instances-lkKWqHgd.mjs +33 -0
  159. package/dist/triggers-DNx9yjbS.mjs +26 -0
  160. package/dist/triggers-types-MjEcrPbH.mjs +31 -0
  161. package/dist/usage-CKyu9RzD.mjs +29 -0
  162. package/dist/usage-Cv9VNy5H.mjs +29 -0
  163. package/dist/webhook-endpoints-DIyg3YlR.mjs +46 -0
  164. package/dist/webhook-subscriptions-B7AgTACq.mjs +48 -0
  165. package/package.json +73 -129
  166. package/CHANGELOG.md +0 -82
  167. package/LICENSE +0 -201
  168. package/api-promise.d.mts +0 -2
  169. package/api-promise.d.mts.map +0 -1
  170. package/api-promise.d.ts +0 -2
  171. package/api-promise.d.ts.map +0 -1
  172. package/api-promise.js +0 -19
  173. package/api-promise.js.map +0 -1
  174. package/api-promise.mjs +0 -2
  175. package/api-promise.mjs.map +0 -1
  176. package/client.d.mts +0 -224
  177. package/client.d.mts.map +0 -1
  178. package/client.d.ts +0 -224
  179. package/client.d.ts.map +0 -1
  180. package/client.js +0 -502
  181. package/client.js.map +0 -1
  182. package/client.mjs +0 -475
  183. package/client.mjs.map +0 -1
  184. package/core/api-promise.d.mts +0 -47
  185. package/core/api-promise.d.mts.map +0 -1
  186. package/core/api-promise.d.ts +0 -47
  187. package/core/api-promise.d.ts.map +0 -1
  188. package/core/api-promise.js +0 -84
  189. package/core/api-promise.js.map +0 -1
  190. package/core/api-promise.mjs +0 -80
  191. package/core/api-promise.mjs.map +0 -1
  192. package/core/error.d.mts +0 -47
  193. package/core/error.d.mts.map +0 -1
  194. package/core/error.d.ts +0 -47
  195. package/core/error.d.ts.map +0 -1
  196. package/core/error.js +0 -113
  197. package/core/error.js.map +0 -1
  198. package/core/error.mjs +0 -97
  199. package/core/error.mjs.map +0 -1
  200. package/core/resource.d.mts +0 -6
  201. package/core/resource.d.mts.map +0 -1
  202. package/core/resource.d.ts +0 -6
  203. package/core/resource.d.ts.map +0 -1
  204. package/core/resource.js +0 -11
  205. package/core/resource.js.map +0 -1
  206. package/core/resource.mjs +0 -7
  207. package/core/resource.mjs.map +0 -1
  208. package/core/uploads.d.mts +0 -3
  209. package/core/uploads.d.mts.map +0 -1
  210. package/core/uploads.d.ts +0 -3
  211. package/core/uploads.d.ts.map +0 -1
  212. package/core/uploads.js +0 -6
  213. package/core/uploads.js.map +0 -1
  214. package/core/uploads.mjs +0 -2
  215. package/core/uploads.mjs.map +0 -1
  216. package/error.d.mts +0 -2
  217. package/error.d.mts.map +0 -1
  218. package/error.d.ts +0 -2
  219. package/error.d.ts.map +0 -1
  220. package/error.js +0 -19
  221. package/error.js.map +0 -1
  222. package/error.mjs +0 -2
  223. package/error.mjs.map +0 -1
  224. package/index.d.mts +0 -6
  225. package/index.d.mts.map +0 -1
  226. package/index.d.ts +0 -6
  227. package/index.d.ts.map +0 -1
  228. package/index.js +0 -30
  229. package/index.js.map +0 -1
  230. package/index.mjs +0 -7
  231. package/index.mjs.map +0 -1
  232. package/internal/builtin-types.d.mts +0 -75
  233. package/internal/builtin-types.d.mts.map +0 -1
  234. package/internal/builtin-types.d.ts +0 -75
  235. package/internal/builtin-types.d.ts.map +0 -1
  236. package/internal/builtin-types.js +0 -4
  237. package/internal/builtin-types.js.map +0 -1
  238. package/internal/builtin-types.mjs +0 -3
  239. package/internal/builtin-types.mjs.map +0 -1
  240. package/internal/detect-platform.d.mts +0 -15
  241. package/internal/detect-platform.d.mts.map +0 -1
  242. package/internal/detect-platform.d.ts +0 -15
  243. package/internal/detect-platform.d.ts.map +0 -1
  244. package/internal/detect-platform.js +0 -162
  245. package/internal/detect-platform.js.map +0 -1
  246. package/internal/detect-platform.mjs +0 -157
  247. package/internal/detect-platform.mjs.map +0 -1
  248. package/internal/errors.d.mts +0 -3
  249. package/internal/errors.d.mts.map +0 -1
  250. package/internal/errors.d.ts +0 -3
  251. package/internal/errors.d.ts.map +0 -1
  252. package/internal/errors.js +0 -41
  253. package/internal/errors.js.map +0 -1
  254. package/internal/errors.mjs +0 -36
  255. package/internal/errors.mjs.map +0 -1
  256. package/internal/headers.d.mts +0 -21
  257. package/internal/headers.d.mts.map +0 -1
  258. package/internal/headers.d.ts +0 -21
  259. package/internal/headers.d.ts.map +0 -1
  260. package/internal/headers.js +0 -77
  261. package/internal/headers.js.map +0 -1
  262. package/internal/headers.mjs +0 -72
  263. package/internal/headers.mjs.map +0 -1
  264. package/internal/parse.d.mts +0 -13
  265. package/internal/parse.d.mts.map +0 -1
  266. package/internal/parse.d.ts +0 -13
  267. package/internal/parse.d.ts.map +0 -1
  268. package/internal/parse.js +0 -36
  269. package/internal/parse.js.map +0 -1
  270. package/internal/parse.mjs +0 -32
  271. package/internal/parse.mjs.map +0 -1
  272. package/internal/qs/formats.d.mts +0 -6
  273. package/internal/qs/formats.d.mts.map +0 -1
  274. package/internal/qs/formats.d.ts +0 -6
  275. package/internal/qs/formats.d.ts.map +0 -1
  276. package/internal/qs/formats.js +0 -11
  277. package/internal/qs/formats.js.map +0 -1
  278. package/internal/qs/formats.mjs +0 -8
  279. package/internal/qs/formats.mjs.map +0 -1
  280. package/internal/qs/index.d.mts +0 -10
  281. package/internal/qs/index.d.mts.map +0 -1
  282. package/internal/qs/index.d.ts +0 -10
  283. package/internal/qs/index.d.ts.map +0 -1
  284. package/internal/qs/index.js +0 -14
  285. package/internal/qs/index.js.map +0 -1
  286. package/internal/qs/index.mjs +0 -10
  287. package/internal/qs/index.mjs.map +0 -1
  288. package/internal/qs/stringify.d.mts +0 -3
  289. package/internal/qs/stringify.d.mts.map +0 -1
  290. package/internal/qs/stringify.d.ts +0 -3
  291. package/internal/qs/stringify.d.ts.map +0 -1
  292. package/internal/qs/stringify.js +0 -280
  293. package/internal/qs/stringify.js.map +0 -1
  294. package/internal/qs/stringify.mjs +0 -276
  295. package/internal/qs/stringify.mjs.map +0 -1
  296. package/internal/qs/types.d.mts +0 -57
  297. package/internal/qs/types.d.mts.map +0 -1
  298. package/internal/qs/types.d.ts +0 -57
  299. package/internal/qs/types.d.ts.map +0 -1
  300. package/internal/qs/types.js +0 -3
  301. package/internal/qs/types.js.map +0 -1
  302. package/internal/qs/types.mjs +0 -2
  303. package/internal/qs/types.mjs.map +0 -1
  304. package/internal/qs/utils.d.mts +0 -14
  305. package/internal/qs/utils.d.mts.map +0 -1
  306. package/internal/qs/utils.d.ts +0 -14
  307. package/internal/qs/utils.d.ts.map +0 -1
  308. package/internal/qs/utils.js +0 -229
  309. package/internal/qs/utils.js.map +0 -1
  310. package/internal/qs/utils.mjs +0 -217
  311. package/internal/qs/utils.mjs.map +0 -1
  312. package/internal/request-options.d.mts +0 -33
  313. package/internal/request-options.d.mts.map +0 -1
  314. package/internal/request-options.d.ts +0 -33
  315. package/internal/request-options.d.ts.map +0 -1
  316. package/internal/request-options.js +0 -14
  317. package/internal/request-options.js.map +0 -1
  318. package/internal/request-options.mjs +0 -10
  319. package/internal/request-options.mjs.map +0 -1
  320. package/internal/shim-types.d.mts +0 -28
  321. package/internal/shim-types.d.ts +0 -28
  322. package/internal/shims/crypto.d.mts +0 -13
  323. package/internal/shims/crypto.d.mts.map +0 -1
  324. package/internal/shims/crypto.d.ts +0 -13
  325. package/internal/shims/crypto.d.ts.map +0 -1
  326. package/internal/shims/crypto.js +0 -13
  327. package/internal/shims/crypto.js.map +0 -1
  328. package/internal/shims/crypto.mjs +0 -9
  329. package/internal/shims/crypto.mjs.map +0 -1
  330. package/internal/shims/file.d.mts +0 -23
  331. package/internal/shims/file.d.mts.map +0 -1
  332. package/internal/shims/file.d.ts +0 -23
  333. package/internal/shims/file.d.ts.map +0 -1
  334. package/internal/shims/file.js +0 -16
  335. package/internal/shims/file.js.map +0 -1
  336. package/internal/shims/file.mjs +0 -12
  337. package/internal/shims/file.mjs.map +0 -1
  338. package/internal/shims/getBuiltinModule.d.mts +0 -11
  339. package/internal/shims/getBuiltinModule.d.mts.map +0 -1
  340. package/internal/shims/getBuiltinModule.d.ts +0 -11
  341. package/internal/shims/getBuiltinModule.d.ts.map +0 -1
  342. package/internal/shims/getBuiltinModule.js +0 -71
  343. package/internal/shims/getBuiltinModule.js.map +0 -1
  344. package/internal/shims/getBuiltinModule.mjs +0 -67
  345. package/internal/shims/getBuiltinModule.mjs.map +0 -1
  346. package/internal/shims/nullGetBuiltinModule.d.mts +0 -2
  347. package/internal/shims/nullGetBuiltinModule.d.mts.map +0 -1
  348. package/internal/shims/nullGetBuiltinModule.d.ts +0 -2
  349. package/internal/shims/nullGetBuiltinModule.d.ts.map +0 -1
  350. package/internal/shims/nullGetBuiltinModule.js +0 -5
  351. package/internal/shims/nullGetBuiltinModule.js.map +0 -1
  352. package/internal/shims/nullGetBuiltinModule.mjs +0 -2
  353. package/internal/shims/nullGetBuiltinModule.mjs.map +0 -1
  354. package/internal/shims.d.mts +0 -20
  355. package/internal/shims.d.mts.map +0 -1
  356. package/internal/shims.d.ts +0 -20
  357. package/internal/shims.d.ts.map +0 -1
  358. package/internal/shims.js +0 -93
  359. package/internal/shims.js.map +0 -1
  360. package/internal/shims.mjs +0 -85
  361. package/internal/shims.mjs.map +0 -1
  362. package/internal/to-file.d.mts +0 -46
  363. package/internal/to-file.d.mts.map +0 -1
  364. package/internal/to-file.d.ts +0 -46
  365. package/internal/to-file.d.ts.map +0 -1
  366. package/internal/to-file.js +0 -91
  367. package/internal/to-file.js.map +0 -1
  368. package/internal/to-file.mjs +0 -87
  369. package/internal/to-file.mjs.map +0 -1
  370. package/internal/types.d.mts +0 -68
  371. package/internal/types.d.mts.map +0 -1
  372. package/internal/types.d.ts +0 -68
  373. package/internal/types.d.ts.map +0 -1
  374. package/internal/types.js +0 -4
  375. package/internal/types.js.map +0 -1
  376. package/internal/types.mjs +0 -3
  377. package/internal/types.mjs.map +0 -1
  378. package/internal/uploads.d.mts +0 -44
  379. package/internal/uploads.d.mts.map +0 -1
  380. package/internal/uploads.d.ts +0 -44
  381. package/internal/uploads.d.ts.map +0 -1
  382. package/internal/uploads.js +0 -131
  383. package/internal/uploads.js.map +0 -1
  384. package/internal/uploads.mjs +0 -122
  385. package/internal/uploads.mjs.map +0 -1
  386. package/internal/utils/base64.d.mts +0 -3
  387. package/internal/utils/base64.d.mts.map +0 -1
  388. package/internal/utils/base64.d.ts +0 -3
  389. package/internal/utils/base64.d.ts.map +0 -1
  390. package/internal/utils/base64.js +0 -33
  391. package/internal/utils/base64.js.map +0 -1
  392. package/internal/utils/base64.mjs +0 -28
  393. package/internal/utils/base64.mjs.map +0 -1
  394. package/internal/utils/env.d.mts +0 -9
  395. package/internal/utils/env.d.mts.map +0 -1
  396. package/internal/utils/env.d.ts +0 -9
  397. package/internal/utils/env.d.ts.map +0 -1
  398. package/internal/utils/env.js +0 -22
  399. package/internal/utils/env.js.map +0 -1
  400. package/internal/utils/env.mjs +0 -18
  401. package/internal/utils/env.mjs.map +0 -1
  402. package/internal/utils/log.d.mts +0 -38
  403. package/internal/utils/log.d.mts.map +0 -1
  404. package/internal/utils/log.d.ts +0 -38
  405. package/internal/utils/log.d.ts.map +0 -1
  406. package/internal/utils/log.js +0 -86
  407. package/internal/utils/log.js.map +0 -1
  408. package/internal/utils/log.mjs +0 -80
  409. package/internal/utils/log.mjs.map +0 -1
  410. package/internal/utils/path.d.mts +0 -15
  411. package/internal/utils/path.d.mts.map +0 -1
  412. package/internal/utils/path.d.ts +0 -15
  413. package/internal/utils/path.d.ts.map +0 -1
  414. package/internal/utils/path.js +0 -58
  415. package/internal/utils/path.js.map +0 -1
  416. package/internal/utils/path.mjs +0 -53
  417. package/internal/utils/path.mjs.map +0 -1
  418. package/internal/utils/sleep.d.mts +0 -2
  419. package/internal/utils/sleep.d.mts.map +0 -1
  420. package/internal/utils/sleep.d.ts +0 -2
  421. package/internal/utils/sleep.d.ts.map +0 -1
  422. package/internal/utils/sleep.js +0 -7
  423. package/internal/utils/sleep.js.map +0 -1
  424. package/internal/utils/sleep.mjs +0 -3
  425. package/internal/utils/sleep.mjs.map +0 -1
  426. package/internal/utils/uuid.d.mts +0 -5
  427. package/internal/utils/uuid.d.mts.map +0 -1
  428. package/internal/utils/uuid.d.ts +0 -5
  429. package/internal/utils/uuid.d.ts.map +0 -1
  430. package/internal/utils/uuid.js +0 -20
  431. package/internal/utils/uuid.js.map +0 -1
  432. package/internal/utils/uuid.mjs +0 -16
  433. package/internal/utils/uuid.mjs.map +0 -1
  434. package/internal/utils/values.d.mts +0 -16
  435. package/internal/utils/values.d.mts.map +0 -1
  436. package/internal/utils/values.d.ts +0 -16
  437. package/internal/utils/values.d.ts.map +0 -1
  438. package/internal/utils/values.js +0 -109
  439. package/internal/utils/values.js.map +0 -1
  440. package/internal/utils/values.mjs +0 -92
  441. package/internal/utils/values.mjs.map +0 -1
  442. package/internal/utils.d.mts +0 -7
  443. package/internal/utils.d.mts.map +0 -1
  444. package/internal/utils.d.ts +0 -7
  445. package/internal/utils.d.ts.map +0 -1
  446. package/internal/utils.js +0 -24
  447. package/internal/utils.js.map +0 -1
  448. package/internal/utils.mjs +0 -8
  449. package/internal/utils.mjs.map +0 -1
  450. package/resource.d.mts +0 -2
  451. package/resource.d.mts.map +0 -1
  452. package/resource.d.ts +0 -2
  453. package/resource.d.ts.map +0 -1
  454. package/resource.js +0 -19
  455. package/resource.js.map +0 -1
  456. package/resource.mjs +0 -2
  457. package/resource.mjs.map +0 -1
  458. package/resources/action-execution.d.mts +0 -155
  459. package/resources/action-execution.d.mts.map +0 -1
  460. package/resources/action-execution.d.ts +0 -155
  461. package/resources/action-execution.d.ts.map +0 -1
  462. package/resources/action-execution.js +0 -19
  463. package/resources/action-execution.js.map +0 -1
  464. package/resources/action-execution.mjs +0 -15
  465. package/resources/action-execution.mjs.map +0 -1
  466. package/resources/auth/auth.d.mts +0 -10
  467. package/resources/auth/auth.d.mts.map +0 -1
  468. package/resources/auth/auth.d.ts +0 -10
  469. package/resources/auth/auth.d.ts.map +0 -1
  470. package/resources/auth/auth.js +0 -39
  471. package/resources/auth/auth.js.map +0 -1
  472. package/resources/auth/auth.mjs +0 -12
  473. package/resources/auth/auth.mjs.map +0 -1
  474. package/resources/auth/index.d.mts +0 -3
  475. package/resources/auth/index.d.mts.map +0 -1
  476. package/resources/auth/index.d.ts +0 -3
  477. package/resources/auth/index.d.ts.map +0 -1
  478. package/resources/auth/index.js +0 -9
  479. package/resources/auth/index.js.map +0 -1
  480. package/resources/auth/index.mjs +0 -4
  481. package/resources/auth/index.mjs.map +0 -1
  482. package/resources/auth/session.d.mts +0 -75
  483. package/resources/auth/session.d.mts.map +0 -1
  484. package/resources/auth/session.d.ts +0 -75
  485. package/resources/auth/session.d.ts.map +0 -1
  486. package/resources/auth/session.js +0 -12
  487. package/resources/auth/session.js.map +0 -1
  488. package/resources/auth/session.mjs +0 -8
  489. package/resources/auth/session.mjs.map +0 -1
  490. package/resources/auth-configs.d.mts +0 -217
  491. package/resources/auth-configs.d.mts.map +0 -1
  492. package/resources/auth-configs.d.ts +0 -217
  493. package/resources/auth-configs.d.ts.map +0 -1
  494. package/resources/auth-configs.js +0 -29
  495. package/resources/auth-configs.js.map +0 -1
  496. package/resources/auth-configs.mjs +0 -25
  497. package/resources/auth-configs.mjs.map +0 -1
  498. package/resources/auth.d.mts +0 -2
  499. package/resources/auth.d.mts.map +0 -1
  500. package/resources/auth.d.ts +0 -2
  501. package/resources/auth.d.ts.map +0 -1
  502. package/resources/auth.js +0 -19
  503. package/resources/auth.js.map +0 -1
  504. package/resources/auth.mjs +0 -3
  505. package/resources/auth.mjs.map +0 -1
  506. package/resources/cli.d.mts +0 -124
  507. package/resources/cli.d.mts.map +0 -1
  508. package/resources/cli.d.ts +0 -124
  509. package/resources/cli.d.ts.map +0 -1
  510. package/resources/cli.js +0 -18
  511. package/resources/cli.js.map +0 -1
  512. package/resources/cli.mjs +0 -14
  513. package/resources/cli.mjs.map +0 -1
  514. package/resources/connected-accounts.d.mts +0 -449
  515. package/resources/connected-accounts.d.mts.map +0 -1
  516. package/resources/connected-accounts.d.ts +0 -449
  517. package/resources/connected-accounts.d.ts.map +0 -1
  518. package/resources/connected-accounts.js +0 -28
  519. package/resources/connected-accounts.js.map +0 -1
  520. package/resources/connected-accounts.mjs +0 -24
  521. package/resources/connected-accounts.mjs.map +0 -1
  522. package/resources/index.d.mts +0 -14
  523. package/resources/index.d.mts.map +0 -1
  524. package/resources/index.d.ts +0 -14
  525. package/resources/index.d.ts.map +0 -1
  526. package/resources/index.js +0 -31
  527. package/resources/index.js.map +0 -1
  528. package/resources/index.mjs +0 -15
  529. package/resources/index.mjs.map +0 -1
  530. package/resources/mcp/command.d.mts +0 -34
  531. package/resources/mcp/command.d.mts.map +0 -1
  532. package/resources/mcp/command.d.ts +0 -34
  533. package/resources/mcp/command.d.ts.map +0 -1
  534. package/resources/mcp/command.js +0 -12
  535. package/resources/mcp/command.js.map +0 -1
  536. package/resources/mcp/command.mjs +0 -8
  537. package/resources/mcp/command.mjs.map +0 -1
  538. package/resources/mcp/index.d.mts +0 -3
  539. package/resources/mcp/index.d.mts.map +0 -1
  540. package/resources/mcp/index.d.ts +0 -3
  541. package/resources/mcp/index.d.ts.map +0 -1
  542. package/resources/mcp/index.js +0 -9
  543. package/resources/mcp/index.js.map +0 -1
  544. package/resources/mcp/index.mjs +0 -4
  545. package/resources/mcp/index.mjs.map +0 -1
  546. package/resources/mcp/mcp.d.mts +0 -378
  547. package/resources/mcp/mcp.d.mts.map +0 -1
  548. package/resources/mcp/mcp.d.ts +0 -378
  549. package/resources/mcp/mcp.d.ts.map +0 -1
  550. package/resources/mcp/mcp.js +0 -66
  551. package/resources/mcp/mcp.js.map +0 -1
  552. package/resources/mcp/mcp.mjs +0 -39
  553. package/resources/mcp/mcp.mjs.map +0 -1
  554. package/resources/mcp.d.mts +0 -2
  555. package/resources/mcp.d.mts.map +0 -1
  556. package/resources/mcp.d.ts +0 -2
  557. package/resources/mcp.d.ts.map +0 -1
  558. package/resources/mcp.js +0 -19
  559. package/resources/mcp.js.map +0 -1
  560. package/resources/mcp.mjs +0 -3
  561. package/resources/mcp.mjs.map +0 -1
  562. package/resources/org/api-key.d.mts +0 -17
  563. package/resources/org/api-key.d.mts.map +0 -1
  564. package/resources/org/api-key.d.ts +0 -17
  565. package/resources/org/api-key.d.ts.map +0 -1
  566. package/resources/org/api-key.js +0 -15
  567. package/resources/org/api-key.js.map +0 -1
  568. package/resources/org/api-key.mjs +0 -11
  569. package/resources/org/api-key.mjs.map +0 -1
  570. package/resources/org/index.d.mts +0 -4
  571. package/resources/org/index.d.mts.map +0 -1
  572. package/resources/org/index.d.ts +0 -4
  573. package/resources/org/index.d.ts.map +0 -1
  574. package/resources/org/index.js +0 -11
  575. package/resources/org/index.js.map +0 -1
  576. package/resources/org/index.mjs +0 -5
  577. package/resources/org/index.mjs.map +0 -1
  578. package/resources/org/org.d.mts +0 -14
  579. package/resources/org/org.d.mts.map +0 -1
  580. package/resources/org/org.d.ts +0 -14
  581. package/resources/org/org.d.ts.map +0 -1
  582. package/resources/org/org.js +0 -43
  583. package/resources/org/org.js.map +0 -1
  584. package/resources/org/org.mjs +0 -16
  585. package/resources/org/org.mjs.map +0 -1
  586. package/resources/org/project/api-keys.d.mts +0 -109
  587. package/resources/org/project/api-keys.d.mts.map +0 -1
  588. package/resources/org/project/api-keys.d.ts +0 -109
  589. package/resources/org/project/api-keys.d.ts.map +0 -1
  590. package/resources/org/project/api-keys.js +0 -23
  591. package/resources/org/project/api-keys.js.map +0 -1
  592. package/resources/org/project/api-keys.mjs +0 -19
  593. package/resources/org/project/api-keys.mjs.map +0 -1
  594. package/resources/org/project/index.d.mts +0 -5
  595. package/resources/org/project/index.d.mts.map +0 -1
  596. package/resources/org/project/index.d.ts +0 -5
  597. package/resources/org/project/index.d.ts.map +0 -1
  598. package/resources/org/project/index.js +0 -13
  599. package/resources/org/project/index.js.map +0 -1
  600. package/resources/org/project/index.mjs +0 -6
  601. package/resources/org/project/index.mjs.map +0 -1
  602. package/resources/org/project/project.d.mts +0 -90
  603. package/resources/org/project/project.d.mts.map +0 -1
  604. package/resources/org/project/project.d.ts +0 -90
  605. package/resources/org/project/project.d.ts.map +0 -1
  606. package/resources/org/project/project.js +0 -60
  607. package/resources/org/project/project.js.map +0 -1
  608. package/resources/org/project/project.mjs +0 -33
  609. package/resources/org/project/project.mjs.map +0 -1
  610. package/resources/org/project/trigger.d.mts +0 -51
  611. package/resources/org/project/trigger.d.mts.map +0 -1
  612. package/resources/org/project/trigger.d.ts +0 -51
  613. package/resources/org/project/trigger.d.ts.map +0 -1
  614. package/resources/org/project/trigger.js +0 -16
  615. package/resources/org/project/trigger.js.map +0 -1
  616. package/resources/org/project/trigger.mjs +0 -12
  617. package/resources/org/project/trigger.mjs.map +0 -1
  618. package/resources/org/project/webhook.d.mts +0 -92
  619. package/resources/org/project/webhook.d.mts.map +0 -1
  620. package/resources/org/project/webhook.d.ts +0 -92
  621. package/resources/org/project/webhook.d.ts.map +0 -1
  622. package/resources/org/project/webhook.js +0 -24
  623. package/resources/org/project/webhook.js.map +0 -1
  624. package/resources/org/project/webhook.mjs +0 -20
  625. package/resources/org/project/webhook.mjs.map +0 -1
  626. package/resources/org/project.d.mts +0 -2
  627. package/resources/org/project.d.mts.map +0 -1
  628. package/resources/org/project.d.ts +0 -2
  629. package/resources/org/project.d.ts.map +0 -1
  630. package/resources/org/project.js +0 -19
  631. package/resources/org/project.js.map +0 -1
  632. package/resources/org/project.mjs +0 -3
  633. package/resources/org/project.mjs.map +0 -1
  634. package/resources/org.d.mts +0 -2
  635. package/resources/org.d.mts.map +0 -1
  636. package/resources/org.d.ts +0 -2
  637. package/resources/org.d.ts.map +0 -1
  638. package/resources/org.js +0 -19
  639. package/resources/org.js.map +0 -1
  640. package/resources/org.mjs +0 -3
  641. package/resources/org.mjs.map +0 -1
  642. package/resources/team-members.d.mts +0 -57
  643. package/resources/team-members.d.mts.map +0 -1
  644. package/resources/team-members.d.ts +0 -57
  645. package/resources/team-members.d.ts.map +0 -1
  646. package/resources/team-members.js +0 -22
  647. package/resources/team-members.js.map +0 -1
  648. package/resources/team-members.mjs +0 -18
  649. package/resources/team-members.mjs.map +0 -1
  650. package/resources/toolkits.d.mts +0 -141
  651. package/resources/toolkits.d.mts.map +0 -1
  652. package/resources/toolkits.d.ts +0 -141
  653. package/resources/toolkits.d.ts.map +0 -1
  654. package/resources/toolkits.js +0 -19
  655. package/resources/toolkits.js.map +0 -1
  656. package/resources/toolkits.mjs +0 -15
  657. package/resources/toolkits.mjs.map +0 -1
  658. package/resources/tools.d.mts +0 -168
  659. package/resources/tools.d.mts.map +0 -1
  660. package/resources/tools.d.ts +0 -168
  661. package/resources/tools.d.ts.map +0 -1
  662. package/resources/tools.js +0 -28
  663. package/resources/tools.js.map +0 -1
  664. package/resources/tools.mjs +0 -24
  665. package/resources/tools.mjs.map +0 -1
  666. package/resources/trigger-instances/handle.d.mts +0 -25
  667. package/resources/trigger-instances/handle.d.mts.map +0 -1
  668. package/resources/trigger-instances/handle.d.ts +0 -25
  669. package/resources/trigger-instances/handle.d.ts.map +0 -1
  670. package/resources/trigger-instances/handle.js +0 -18
  671. package/resources/trigger-instances/handle.js.map +0 -1
  672. package/resources/trigger-instances/handle.mjs +0 -14
  673. package/resources/trigger-instances/handle.mjs.map +0 -1
  674. package/resources/trigger-instances/index.d.mts +0 -3
  675. package/resources/trigger-instances/index.d.mts.map +0 -1
  676. package/resources/trigger-instances/index.d.ts +0 -3
  677. package/resources/trigger-instances/index.d.ts.map +0 -1
  678. package/resources/trigger-instances/index.js +0 -9
  679. package/resources/trigger-instances/index.js.map +0 -1
  680. package/resources/trigger-instances/index.mjs +0 -4
  681. package/resources/trigger-instances/index.mjs.map +0 -1
  682. package/resources/trigger-instances/trigger-instances.d.mts +0 -126
  683. package/resources/trigger-instances/trigger-instances.d.mts.map +0 -1
  684. package/resources/trigger-instances/trigger-instances.d.ts +0 -126
  685. package/resources/trigger-instances/trigger-instances.d.ts.map +0 -1
  686. package/resources/trigger-instances/trigger-instances.js +0 -53
  687. package/resources/trigger-instances/trigger-instances.js.map +0 -1
  688. package/resources/trigger-instances/trigger-instances.mjs +0 -26
  689. package/resources/trigger-instances/trigger-instances.mjs.map +0 -1
  690. package/resources/trigger-instances.d.mts +0 -2
  691. package/resources/trigger-instances.d.mts.map +0 -1
  692. package/resources/trigger-instances.d.ts +0 -2
  693. package/resources/trigger-instances.d.ts.map +0 -1
  694. package/resources/trigger-instances.js +0 -19
  695. package/resources/trigger-instances.js.map +0 -1
  696. package/resources/trigger-instances.mjs +0 -3
  697. package/resources/trigger-instances.mjs.map +0 -1
  698. package/resources/trigger.d.mts +0 -73
  699. package/resources/trigger.d.mts.map +0 -1
  700. package/resources/trigger.d.ts +0 -73
  701. package/resources/trigger.d.ts.map +0 -1
  702. package/resources/trigger.js +0 -12
  703. package/resources/trigger.js.map +0 -1
  704. package/resources/trigger.mjs +0 -8
  705. package/resources/trigger.mjs.map +0 -1
  706. package/resources/triggers-types.d.mts +0 -59
  707. package/resources/triggers-types.d.mts.map +0 -1
  708. package/resources/triggers-types.d.ts +0 -59
  709. package/resources/triggers-types.d.ts.map +0 -1
  710. package/resources/triggers-types.js +0 -19
  711. package/resources/triggers-types.js.map +0 -1
  712. package/resources/triggers-types.mjs +0 -15
  713. package/resources/triggers-types.mjs.map +0 -1
  714. package/resources.d.mts +0 -2
  715. package/resources.d.mts.map +0 -1
  716. package/resources.d.ts +0 -2
  717. package/resources.d.ts.map +0 -1
  718. package/resources.js +0 -18
  719. package/resources.js.map +0 -1
  720. package/resources.mjs +0 -2
  721. package/resources.mjs.map +0 -1
  722. package/src/api-promise.ts +0 -2
  723. package/src/client.ts +0 -938
  724. package/src/core/README.md +0 -3
  725. package/src/core/api-promise.ts +0 -92
  726. package/src/core/error.ts +0 -130
  727. package/src/core/resource.ts +0 -11
  728. package/src/core/uploads.ts +0 -2
  729. package/src/error.ts +0 -2
  730. package/src/index.ts +0 -22
  731. package/src/internal/README.md +0 -3
  732. package/src/internal/builtin-types.ts +0 -93
  733. package/src/internal/detect-platform.ts +0 -196
  734. package/src/internal/errors.ts +0 -33
  735. package/src/internal/headers.ts +0 -96
  736. package/src/internal/parse.ts +0 -50
  737. package/src/internal/qs/LICENSE.md +0 -13
  738. package/src/internal/qs/README.md +0 -3
  739. package/src/internal/qs/formats.ts +0 -9
  740. package/src/internal/qs/index.ts +0 -13
  741. package/src/internal/qs/stringify.ts +0 -388
  742. package/src/internal/qs/types.ts +0 -71
  743. package/src/internal/qs/utils.ts +0 -265
  744. package/src/internal/request-options.ts +0 -37
  745. package/src/internal/shim-types.d.ts +0 -28
  746. package/src/internal/shims/crypto.ts +0 -18
  747. package/src/internal/shims/file.ts +0 -32
  748. package/src/internal/shims/getBuiltinModule.ts +0 -66
  749. package/src/internal/shims/nullGetBuiltinModule.ts +0 -1
  750. package/src/internal/shims.ts +0 -107
  751. package/src/internal/to-file.ts +0 -152
  752. package/src/internal/types.ts +0 -92
  753. package/src/internal/uploads.ts +0 -175
  754. package/src/internal/utils/base64.ts +0 -37
  755. package/src/internal/utils/env.ts +0 -18
  756. package/src/internal/utils/log.ts +0 -127
  757. package/src/internal/utils/path.ts +0 -63
  758. package/src/internal/utils/sleep.ts +0 -3
  759. package/src/internal/utils/uuid.ts +0 -19
  760. package/src/internal/utils/values.ts +0 -102
  761. package/src/internal/utils.ts +0 -8
  762. package/src/lib/.keep +0 -4
  763. package/src/resource.ts +0 -2
  764. package/src/resources/action-execution.ts +0 -244
  765. package/src/resources/auth/auth.ts +0 -15
  766. package/src/resources/auth/index.ts +0 -4
  767. package/src/resources/auth/session.ts +0 -127
  768. package/src/resources/auth-configs.ts +0 -362
  769. package/src/resources/auth.ts +0 -3
  770. package/src/resources/cli.ts +0 -166
  771. package/src/resources/connected-accounts.ts +0 -661
  772. package/src/resources/index.ts +0 -105
  773. package/src/resources/mcp/command.ts +0 -47
  774. package/src/resources/mcp/index.ts +0 -17
  775. package/src/resources/mcp/mcp.ts +0 -519
  776. package/src/resources/mcp.ts +0 -3
  777. package/src/resources/org/api-key.ts +0 -30
  778. package/src/resources/org/index.ts +0 -12
  779. package/src/resources/org/org.ts +0 -39
  780. package/src/resources/org/project/api-keys.ts +0 -156
  781. package/src/resources/org/project/index.ts +0 -35
  782. package/src/resources/org/project/project.ts +0 -206
  783. package/src/resources/org/project/trigger.ts +0 -95
  784. package/src/resources/org/project/webhook.ts +0 -131
  785. package/src/resources/org/project.ts +0 -3
  786. package/src/resources/org.ts +0 -3
  787. package/src/resources/team-members.ts +0 -111
  788. package/src/resources/toolkits.ts +0 -232
  789. package/src/resources/tools.ts +0 -270
  790. package/src/resources/trigger-instances/handle.ts +0 -45
  791. package/src/resources/trigger-instances/index.ts +0 -19
  792. package/src/resources/trigger-instances/trigger-instances.ts +0 -202
  793. package/src/resources/trigger-instances.ts +0 -3
  794. package/src/resources/trigger.ts +0 -108
  795. package/src/resources/triggers-types.ts +0 -105
  796. package/src/resources.ts +0 -1
  797. package/src/tsconfig.json +0 -11
  798. package/src/uploads.ts +0 -2
  799. package/src/version.ts +0 -1
  800. package/uploads.d.mts +0 -2
  801. package/uploads.d.mts.map +0 -1
  802. package/uploads.d.ts +0 -2
  803. package/uploads.d.ts.map +0 -1
  804. package/uploads.js +0 -19
  805. package/uploads.js.map +0 -1
  806. package/uploads.mjs +0 -2
  807. package/uploads.mjs.map +0 -1
  808. package/version.d.mts +0 -2
  809. package/version.d.mts.map +0 -1
  810. package/version.d.ts +0 -2
  811. package/version.d.ts.map +0 -1
  812. package/version.js +0 -5
  813. package/version.js.map +0 -1
  814. package/version.mjs +0 -2
  815. package/version.mjs.map +0 -1
@@ -0,0 +1,1203 @@
1
+ //#region src/compat/error.ts
2
+ /**
3
+ * Stainless-compatible error hierarchy.
4
+ *
5
+ * Downstream code does `instanceof` checks and reads `status` / `error` /
6
+ * `headers` on these classes (see docs/research/drop-in-contract.md §4), so
7
+ * both the class names and the inheritance chain are part of the drop-in
8
+ * contract: `BadRequestError extends APIError extends ComposioError extends Error`.
9
+ */
10
+ var ComposioError = class extends Error {};
11
+ var APIError = class APIError extends ComposioError {
12
+ /** HTTP status for the response that caused the error. */
13
+ status;
14
+ /** HTTP headers of the response that caused the error. */
15
+ headers;
16
+ /** JSON body of the response that caused the error. */
17
+ error;
18
+ constructor(status, error, message, headers) {
19
+ super(APIError.makeMessage(status, error, message));
20
+ this.status = status;
21
+ this.headers = headers;
22
+ this.error = error;
23
+ }
24
+ static makeMessage(status, error, message) {
25
+ const errorMessage = error?.message;
26
+ const msg = errorMessage ? typeof errorMessage === "string" ? errorMessage : JSON.stringify(errorMessage) : error ? JSON.stringify(error) : message;
27
+ if (status && msg) return `${status} ${msg}`;
28
+ if (status) return `${status} status code (no body)`;
29
+ if (msg) return msg;
30
+ return "(no status code or body)";
31
+ }
32
+ static generate(status, errorResponse, message, headers) {
33
+ if (!status || !headers) return new APIConnectionError({
34
+ message,
35
+ cause: errorResponse
36
+ });
37
+ const error = errorResponse;
38
+ if (status === 400) return new BadRequestError(status, error, message, headers);
39
+ if (status === 401) return new AuthenticationError(status, error, message, headers);
40
+ if (status === 403) return new PermissionDeniedError(status, error, message, headers);
41
+ if (status === 404) return new NotFoundError(status, error, message, headers);
42
+ if (status === 409) return new ConflictError(status, error, message, headers);
43
+ if (status === 422) return new UnprocessableEntityError(status, error, message, headers);
44
+ if (status === 429) return new RateLimitError(status, error, message, headers);
45
+ if (status >= 500) return new InternalServerError(status, error, message, headers);
46
+ return new APIError(status, error, message, headers);
47
+ }
48
+ };
49
+ var APIUserAbortError = class extends APIError {
50
+ constructor({ message } = {}) {
51
+ super(void 0, void 0, message ?? "Request was aborted.", void 0);
52
+ }
53
+ };
54
+ var APIConnectionError = class extends APIError {
55
+ constructor({ message, cause }) {
56
+ super(void 0, void 0, message ?? "Connection error.", void 0);
57
+ if (cause) this.cause = cause;
58
+ }
59
+ };
60
+ var APIConnectionTimeoutError = class extends APIConnectionError {
61
+ constructor({ message } = {}) {
62
+ super({ message: message ?? "Request timed out." });
63
+ }
64
+ };
65
+ var BadRequestError = class extends APIError {};
66
+ var AuthenticationError = class extends APIError {};
67
+ var PermissionDeniedError = class extends APIError {};
68
+ var NotFoundError = class extends APIError {};
69
+ var ConflictError = class extends APIError {};
70
+ var UnprocessableEntityError = class extends APIError {};
71
+ var RateLimitError = class extends APIError {};
72
+ var InternalServerError = class extends APIError {};
73
+
74
+ //#endregion
75
+ //#region src/compat/credentials.ts
76
+ /**
77
+ * The credential transport boundary.
78
+ *
79
+ * The design record makes authentication part of the runtime contract in both
80
+ * languages, with four rules. Three of them are enforced here and in
81
+ * `request.ts`; the fourth is a property of what this client's messages are
82
+ * built from, and is pinned by test rather than by code:
83
+ *
84
+ * 0. **A request carries exactly one credential header**, chosen from the
85
+ * operation's declared security schemes. Not a record rule — it is a
86
+ * measured property of the API (two credential headers on one request is a
87
+ * 401, even where either alone is a 200), so the four rules below are all
88
+ * stated about *the* credential a request carries, and {@link selectScheme}
89
+ * decides which one that is. See wayfinder ticket 48 and §4 of
90
+ * `docs/research/drop-in-contract.md`.
91
+ * 1. **A credentialed API origin must use HTTPS.** Plain `http:` is permitted
92
+ * only for loopback development endpoints — which is exactly what the
93
+ * sanctioned `environment: 'local'` default (`http://localhost:9900`) is.
94
+ * Enforced by {@link assertCredentialTransport} at construction and again
95
+ * by {@link credentialForRequest} at dispatch, because `apiKey` and
96
+ * `baseURL` are both public mutable fields on the client.
97
+ * 2. **The credential is attached only to requests whose origin matches the
98
+ * configured API origin.** {@link credentialForRequest} returns `null`
99
+ * off-origin, and the header is simply not sent.
100
+ * 3. **Credentials are never forwarded across an origin-changing redirect.**
101
+ * The kernel follows redirects itself (`request.ts`) rather than delegating
102
+ * to `fetch`, and every hop re-enters the header build — so the credential
103
+ * decision is re-derived from *that hop's* URL and rule 3 mostly falls out
104
+ * of rule 2. What does not fall out is the caller's own credential headers,
105
+ * which rule 2 deliberately leaves alone: {@link withdrawCredentials}
106
+ * removes those once a chain has changed origin.
107
+ * 4. **Credential-bearing values are redacted from logs and error messages.**
108
+ * Nothing here to do: no message this client constructs ever reads a
109
+ * request header or a request URL. `APIError.makeMessage` is built from the
110
+ * status and the response *body*; the deprecation notice is built from the
111
+ * operation template and parsed public response-header values. Pinned in
112
+ * `test/unit/credential-boundary.test.ts` so it stays true.
113
+ *
114
+ * ### Failure modes, and why they differ
115
+ *
116
+ * Rule 1 **throws**. A plaintext credentialed origin is a configuration
117
+ * mistake with no safe interpretation: dropping the key instead would turn it
118
+ * into a stream of confusing 401s that never names the real cause, and sending
119
+ * it is the thing being prevented. Throwing at construction puts the error on
120
+ * the line that made the mistake.
121
+ *
122
+ * Rule 2 **drops the credential and continues**. The record states it as an
123
+ * attachment rule, not an error, and the runtime genuinely cannot tell an
124
+ * attack from a legitimate off-origin fetch — this API mints presigned upload
125
+ * and download URLs (`files.createPresignedURL`,
126
+ * `session.files.createDownloadURL`) that live on a storage origin, and a
127
+ * caller reaching one through the escape hatch is doing something reasonable.
128
+ * Dropping makes that safe; throwing would make it impossible.
129
+ *
130
+ * Rule 3 **follows the hop without the credential** rather than refusing to
131
+ * hop. Refusing was the first spelling, and it was overruled on a parity
132
+ * argument worth recording: Stainless followed redirects, no differential
133
+ * fixture redirects, so a green suite would have been evidence that the
134
+ * *tests* do not redirect — not that production does not. The rule itself is
135
+ * unchanged; only the remedy is.
136
+ *
137
+ * ### Divergence from Stainless
138
+ *
139
+ * Deliberate, and sanctioned by the design record: the published Stainless
140
+ * client enforces none of this. Redirect *following* is no longer part of the
141
+ * divergence — both clients follow — but what rides along on the hop is. See
142
+ * §4 of `docs/research/drop-in-contract.md` and wayfinder ticket 40.
143
+ */
144
+ /**
145
+ * The three credential classes this API accepts, and the header each one puts
146
+ * on the wire.
147
+ *
148
+ * These are the `apiKey`-in-header schemes `spec/openapi.json` declares under
149
+ * `components.securitySchemes`. The fourth declared one, `CookieAuth`, is
150
+ * referenced by no operation and is not a thing a client library places.
151
+ */
152
+ const SCHEME_HEADERS = {
153
+ ApiKeyAuth: "x-api-key",
154
+ UserApiKeyAuth: "x-user-api-key",
155
+ OrgApiKeyAuth: "x-org-api-key"
156
+ };
157
+ /** The scheme a request authenticates with when its operation names none. */
158
+ const DEFAULT_SCHEME = "ApiKeyAuth";
159
+ const valueFor = (scheme, credentials) => scheme === "ApiKeyAuth" ? credentials.apiKey : scheme === "UserApiKeyAuth" ? credentials.userApiKey : credentials.orgApiKey;
160
+ /**
161
+ * Whether anything beyond the project key is configured — the condition that
162
+ * makes per-operation selection able to change an outcome at all.
163
+ *
164
+ * Load-bearing rather than an optimization. With only `apiKey` set, every
165
+ * branch of {@link selectScheme} lands on `ApiKeyAuth`: it wins wherever it is
166
+ * an accepted alternative, and where it is not, the alternative is unconfigured
167
+ * and the fallback is `ApiKeyAuth` again. So the client that every existing
168
+ * caller constructs never consults the operation table, and "an `apiKey`-only
169
+ * client emits byte-identical requests on all 104 operations" is a property of
170
+ * the code shape rather than a claim tests have to keep re-establishing.
171
+ */
172
+ const hasAlternateCredential = (credentials) => credentials.userApiKey !== null || credentials.orgApiKey !== null;
173
+ /**
174
+ * Which credential a request declaring `schemes` should carry.
175
+ *
176
+ * **Exactly one, always** — and the API says so itself. Measured against
177
+ * production on 2026-08-06, `GET /toolkits` answers 200 for `x-api-key` alone
178
+ * and 200 for `x-user-api-key` alone, and answers both together with
179
+ * `401 HTTP_Unauthorized`:
180
+ *
181
+ * > Multiple authentication modes were provided. Provide exactly one
182
+ * > authentication mode per request. Provided: ApiKeyAuth via x-api-key,
183
+ * > UserApiKeyAuth via x-user-api-key.
184
+ *
185
+ * The platform names the schemes by their OpenAPI names, so this is the same
186
+ * vocabulary `security` is written in rather than a coincidence of headers. It
187
+ * holds for `x-api-key` + `x-org-api-key` too, and on an operation that accepts
188
+ * only one of them. There is therefore no additive "send the user key as well"
189
+ * model available, and the choice has to be made per request rather than
190
+ * accumulated.
191
+ *
192
+ * The precedence exists to make the change free where it must be free:
193
+ *
194
+ * 1. **`ApiKeyAuth` wins wherever the operation accepts it** and an `apiKey` is
195
+ * configured — 85 of the 104 operations, every wire byte preserved.
196
+ * 2. Otherwise the first scheme the operation names that this client both
197
+ * recognizes *and* holds a credential for. That is what makes the 16
198
+ * `UserApiKeyAuth`-only and `OrgApiKeyAuth`-only operations reachable.
199
+ * 3. Otherwise `ApiKeyAuth`, which is what this client did before any of this
200
+ * existed. A `UserApiKeyAuth`-only operation called by a client with no user
201
+ * key still sends `x-api-key` and still fails the same way — which is what
202
+ * keeps `cli.realtime.auth` and `cli.realtime.credentials` pinned against
203
+ * the Stainless oracle in `test/unit/differential-wire.test.ts`.
204
+ *
205
+ * Rule 3 is also where a scheme name this client does not know lands. Three of
206
+ * them exist: `security` references `no_auth` (3 operations) and
207
+ * `workbench_access_key` (1) and `components.securitySchemes` declares neither.
208
+ * Those four operations receive `x-api-key` today and are differentially
209
+ * pinned doing so, so resolving an unknown name to "no credential" would be a
210
+ * wire change made on the strength of a spec defect. A later generator pass
211
+ * must not "fix" that.
212
+ */
213
+ const selectScheme = (schemes, credentials) => {
214
+ if (schemes === void 0 || schemes.length === 0) return DEFAULT_SCHEME;
215
+ if (schemes.includes(DEFAULT_SCHEME) && credentials.apiKey !== null) return DEFAULT_SCHEME;
216
+ for (const scheme of schemes) {
217
+ if (!Object.hasOwn(SCHEME_HEADERS, scheme)) continue;
218
+ const known = scheme;
219
+ if (valueFor(known, credentials) !== null) return known;
220
+ }
221
+ return DEFAULT_SCHEME;
222
+ };
223
+ /**
224
+ * What counts as loopback, pinned rather than assumed. `localhost` is not the
225
+ * whole set:
226
+ *
227
+ * - `localhost`, and any name under it (`api.localhost`). RFC 6761 §6.3
228
+ * reserves the whole `.localhost` TLD to resolve to the loopback interface,
229
+ * and container-era dev setups do use subdomains of it.
230
+ * - The entire IPv4 loopback block `127.0.0.0/8`, not just `127.0.0.1`.
231
+ * - The IPv6 loopback `::1`. `URL` hands hostnames back bracketed and in
232
+ * canonical compressed form, so `http://[0:0:0:0:0:0:0:1]/` arrives here as
233
+ * `[::1]`.
234
+ *
235
+ * Everything else is not loopback, deliberately. `0.0.0.0` in particular is the
236
+ * unspecified address, not a loopback one; it happens to reach the local host
237
+ * on some platforms and fails on others, and a rule that depends on the
238
+ * platform is not a rule. The IPv4-mapped spelling `::ffff:127.0.0.1` is
239
+ * refused for the same reason — Python's `ipaddress` answers it differently
240
+ * across interpreter versions, and nobody configures a development endpoint
241
+ * that way. The error message names the accepted set so a developer who typed
242
+ * `0.0.0.0` sees the fix immediately.
243
+ */
244
+ const LOOPBACK_IPV4 = /^127(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
245
+ const isLoopbackHostname = (hostname) => {
246
+ const host = hostname.trim().toLowerCase().replace(/^\[|\]$/g, "");
247
+ if (host === "localhost" || host.endsWith(".localhost")) return true;
248
+ if (host === "::1") return true;
249
+ return LOOPBACK_IPV4.test(host);
250
+ };
251
+ /** The URL, parsed, when it is absolute and http(s); `null` otherwise. */
252
+ const parseHTTPURL = (value) => {
253
+ try {
254
+ const url = new URL(value);
255
+ return url.protocol === "http:" || url.protocol === "https:" ? url : null;
256
+ } catch {
257
+ return null;
258
+ }
259
+ };
260
+ /** Whether a credential may be sent to this origin at all. */
261
+ const isCredentialSafeOrigin = (url) => url.protocol === "https:" || url.protocol === "http:" && isLoopbackHostname(url.hostname);
262
+ const LOOPBACK_DESCRIPTION = "localhost, *.localhost, 127.0.0.0/8, [::1]";
263
+ const insecureOriginMessage = (baseURL) => `Refusing to send a Composio API credential to ${baseURL}: a credentialed API origin must use HTTPS. Plain http:// is permitted only for loopback development endpoints (${LOOPBACK_DESCRIPTION}). Pass an https:// baseURL, use environment: 'local', or construct the client without credentials.`;
264
+ /** Whether the client holds anything at all that rule 1 has to protect. */
265
+ const anyCredential = (credentials) => credentials.apiKey !== null || hasAlternateCredential(credentials);
266
+ /**
267
+ * Rule 1 at construction time: a client that holds a credential must be
268
+ * pointed at an origin that can carry one. Knowable before any request is
269
+ * made, so it fails on the constructor call rather than on the first dispatch.
270
+ *
271
+ * A `baseURL` that is not an absolute http(s) URL fails the same way — a
272
+ * credential cannot be sent over a scheme this client does not speak, and the
273
+ * alternative is a `TypeError` from `new URL()` one layer down.
274
+ *
275
+ * Every configured credential counts, not just `apiKey`: which one a given
276
+ * request carries is decided per operation, so a client holding *any* of them
277
+ * is a client that can put one on the wire.
278
+ */
279
+ const assertCredentialTransport = (baseURL, credentials) => {
280
+ if (!anyCredential(credentials)) return;
281
+ const url = parseHTTPURL(baseURL);
282
+ if (url === null || !isCredentialSafeOrigin(url)) throw new ComposioError(insecureOriginMessage(baseURL));
283
+ };
284
+ /**
285
+ * The credential this request may carry, or `null` for none.
286
+ *
287
+ * Rules 1 and 2 at dispatch time. Both re-checks are load-bearing rather than
288
+ * belt-and-braces: `apiKey` and `baseURL` are public mutable fields, so the
289
+ * construction-time check can be invalidated by an assignment, and the request
290
+ * URL is *not* guaranteed to sit on the configured origin. `buildURL`
291
+ * concatenates `baseURL + path` and the escape hatch (`client.get(path)`)
292
+ * takes an arbitrary path, so a path that does not begin with `/` extends the
293
+ * *authority* rather than the path: `client.get('.evil.example/x')` against
294
+ * `https://backend.composio.dev` resolves to
295
+ * `https://backend.composio.dev.evil.example/x`, and `client.get(':8443/x')`
296
+ * changes the port. Both were carrying `x-api-key` before this boundary
297
+ * existed. (The userinfo spelling — `client.get('@evil.example/x')` — reaches
298
+ * a third origin too, but `fetch` refuses to construct a `Request` from a URL
299
+ * with credentials, so that one dies at the transport instead. httpx has no
300
+ * such objection, which is why the Python port checks the same thing.)
301
+ */
302
+ const credentialForRequest = (baseURL, scheme, credentials, requestURL) => {
303
+ const value = valueFor(scheme, credentials);
304
+ if (value === null) return null;
305
+ const base = parseHTTPURL(baseURL);
306
+ const target = parseHTTPURL(requestURL);
307
+ if (base === null || target === null) return null;
308
+ if (base.origin !== target.origin) return null;
309
+ if (!isCredentialSafeOrigin(target)) throw new ComposioError(insecureOriginMessage(baseURL));
310
+ return {
311
+ name: SCHEME_HEADERS[scheme],
312
+ value
313
+ };
314
+ };
315
+ /**
316
+ * The credential headers a *caller* can place that are not the one this client
317
+ * attaches — `x-api-key` is excluded because a caller setting it is overriding
318
+ * the client's own value in the same slot, which is pinned Stainless behaviour,
319
+ * not a second credential.
320
+ */
321
+ const FOREIGN_CREDENTIAL_HEADERS = ["x-user-api-key", "x-org-api-key"];
322
+ /**
323
+ * Whether the caller has placed a credential of their own, in which case the
324
+ * client must not add one beside it.
325
+ *
326
+ * Not a courtesy: this API answers a request carrying two credential headers
327
+ * with `401 HTTP_Unauthorized`, so attaching `x-api-key` next to a caller's
328
+ * `x-user-api-key` does not weaken the call, it *breaks* it. Three released
329
+ * methods make that reachable without any `defaultHeaders` at all —
330
+ * `cli.createCodactFailure`, `org.consumer.project.resolve` and
331
+ * `org.consumer.listConnectedToolkits` declare `x-user-api-key` as a `required`
332
+ * header parameter, which the generator folds into their params object. Calling
333
+ * them the way their signature asks for returned 401 until this rule existed.
334
+ *
335
+ * Header merging is replayed rather than approximated, because a later source
336
+ * may carry `null` to delete what an earlier one set (`buildHeaders`).
337
+ */
338
+ const callerPlacedCredential = (sources) => {
339
+ const placed = /* @__PURE__ */ new Set();
340
+ for (const source of sources) {
341
+ if (!source) continue;
342
+ for (const [name, value] of Object.entries(source)) {
343
+ const header = name.toLowerCase();
344
+ if (!FOREIGN_CREDENTIAL_HEADERS.includes(header)) continue;
345
+ if (value === void 0) continue;
346
+ if (value === null) placed.delete(header);
347
+ else placed.add(header);
348
+ }
349
+ }
350
+ return placed.size > 0;
351
+ };
352
+ /**
353
+ * Header names that carry a credential and must not survive an origin change.
354
+ *
355
+ * The first three are what `fetch` itself would have stripped had it been
356
+ * following the redirect (Fetch §4.4 "HTTP-redirect fetch" deletes
357
+ * `Authorization` cross-origin; `Cookie` and `Proxy-Authorization` are
358
+ * forbidden header names a page cannot set and a server-side fetch does not
359
+ * carry across origins). Following redirects by hand means taking that job on.
360
+ * `x-api-key` joins them because it is *this* API's credential, and because the
361
+ * Fetch spec would not have stripped it — a custom header rides along a
362
+ * cross-origin redirect, which is the hole this whole module exists to close.
363
+ *
364
+ * `x-user-api-key` and `x-org-api-key` are the spec's other two credential
365
+ * schemes (`UserApiKeyAuth`, `OrgApiKeyAuth`), and they belong here for the same
366
+ * reason `x-api-key` does — the kernel attaches all three (wayfinder ticket 48)
367
+ * and a caller can place the latter two directly besides. They were listed here
368
+ * one ticket *before* the attachment work, because omitting them cost more than
369
+ * a missed withdrawal: {@link carriesCredentials} answered `false` for a request
370
+ * carrying only one of them, so `request.ts` classified it as credential-free
371
+ * and handed the whole chain to `fetch` at `redirect: 'follow'` — the exact leak
372
+ * rule 3 exists to close, arriving through a different header name.
373
+ *
374
+ * This list is the repo's answer to "which header names carry a credential",
375
+ * and the live parity harness needs the same answer: it redacts these values
376
+ * where it renders a captured request into a summary someone reads on a
377
+ * terminal. It cannot import them — the harness runs under `node
378
+ * --experimental-transform-types`, which does not resolve this module's `.js`
379
+ * specifiers — so `packages/parity/src/core/compare.ts` mirrors the list and a
380
+ * test there reads this file to hold the two in step, the same arrangement the
381
+ * Python driver's protocol version already uses.
382
+ */
383
+ const CREDENTIAL_HEADERS = [
384
+ "authorization",
385
+ "cookie",
386
+ "proxy-authorization",
387
+ "x-api-key",
388
+ "x-user-api-key",
389
+ "x-org-api-key"
390
+ ];
391
+ /**
392
+ * Rule 3 for headers the caller placed, applied when a redirect chain changes
393
+ * origin.
394
+ *
395
+ * Rule 2 deliberately leaves a caller's own `defaultHeaders` / per-request
396
+ * headers alone on the *initial* request, even off-origin: the caller chose
397
+ * that URL, and an escape-hatch call to a presigned storage URL carrying its
398
+ * own `Authorization` is a legitimate thing to do. A redirect target is chosen
399
+ * by the *server*, not the caller, so the same consent does not extend to it.
400
+ *
401
+ * Withdrawal is **sticky** for the rest of the chain: once a hop has left the
402
+ * origin it started on, no later hop re-attaches a credential, not even one
403
+ * that lands back on the configured API origin. A real API does not bounce a
404
+ * caller off-site and back, and "no credential after the chain leaves" is one
405
+ * sentence rather than a case analysis.
406
+ */
407
+ const withdrawCredentials = (headers) => {
408
+ for (const name of CREDENTIAL_HEADERS) headers.delete(name);
409
+ };
410
+ /**
411
+ * Whether these headers carry anything that must not cross an origin change —
412
+ * the exact complement of {@link withdrawCredentials}, sharing its list so the
413
+ * two cannot drift apart.
414
+ *
415
+ * `request.ts` asks this before the *first* dispatch of a chain. A request
416
+ * carrying nothing credential-bearing has nothing to protect, so following it
417
+ * by hand buys nothing the platform's own following does not already give:
418
+ * `fetch` strips exactly these header names across a cross-origin hop, applies
419
+ * the same method rewrite, and enforces the same 20-hop budget. Delegating is
420
+ * therefore provably equivalent there — and it is the only way a *browser* can
421
+ * follow a redirect at all.
422
+ */
423
+ const carriesCredentials = (headers) => CREDENTIAL_HEADERS.some((name) => headers.has(name));
424
+
425
+ //#endregion
426
+ //#region src/compat/deprecation.ts
427
+ /**
428
+ * Field-size ceiling. A deprecation notice is decoration on a response that
429
+ * has already been paid for, so an oversized field is dropped rather than
430
+ * parsed — there is no message worth building out of 2 KiB of `Link`.
431
+ */
432
+ const MAX_FIELD_LENGTH = 2048;
433
+ /** No message this client emits may smuggle control characters into a log. */
434
+ const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/;
435
+ /**
436
+ * How many distinct (operation, notice) pairs one client instance will ever
437
+ * warn about. Generated methods draw from a fixed table of ~100 and a server
438
+ * revises a notice rarely, so the bound is unreachable in practice; it exists
439
+ * because both halves of the key are ultimately server- or caller-controlled —
440
+ * an escape-hatch caller (`client.get('/api/v3.1/…/{id}')`) keys on the
441
+ * substituted path, and a server rotating `Sunset` or `Link` on every response
442
+ * mints a fresh pair each time. Past the ceiling the client stops warning
443
+ * rather than growing a set forever.
444
+ */
445
+ const MAX_TRACKED_NOTICES = 1024;
446
+ const readField = (headers, name) => {
447
+ const value = headers.get(name);
448
+ if (value === null) return null;
449
+ if (value.length > MAX_FIELD_LENGTH || CONTROL_CHARACTERS.test(value)) return null;
450
+ return value;
451
+ };
452
+ /**
453
+ * RFC 9651 §3.3.7 sf-date: `@` then integer seconds since the epoch, possibly
454
+ * negative. Anything else — including the pre-RFC `true` and bare HTTP-date
455
+ * spellings the draft years produced — yields no date; the notice still fires,
456
+ * because the server sending the field at all is the signal.
457
+ */
458
+ const parseStructuredDate = (value) => {
459
+ const match = /^@(-?\d{1,15})$/.exec(value.trim());
460
+ if (match === null) return null;
461
+ const date = /* @__PURE__ */ new Date(Number(match[1]) * 1e3);
462
+ return Number.isNaN(date.getTime()) ? null : date;
463
+ };
464
+ const MONTHS = [
465
+ "Jan",
466
+ "Feb",
467
+ "Mar",
468
+ "Apr",
469
+ "May",
470
+ "Jun",
471
+ "Jul",
472
+ "Aug",
473
+ "Sep",
474
+ "Oct",
475
+ "Nov",
476
+ "Dec"
477
+ ];
478
+ const DAY = "(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)";
479
+ const DAY_LONG = "(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)";
480
+ const MONTH = `(${MONTHS.join("|")})`;
481
+ const TIME = "(\\d{2}):(\\d{2}):(\\d{2})";
482
+ /** `day-name "," SP 2DIGIT SP month SP 4DIGIT SP time-of-day SP GMT` */
483
+ const IMF_FIXDATE = new RegExp(`^${DAY}, (\\d{2}) ${MONTH} (\\d{4}) ${TIME} GMT$`);
484
+ /** `day-name-l "," SP 2DIGIT "-" month "-" 2DIGIT SP time-of-day SP GMT` */
485
+ const RFC850_DATE = new RegExp(`^${DAY_LONG}, (\\d{2})-${MONTH}-(\\d{2}) ${TIME} GMT$`);
486
+ /** `day-name SP month SP ( 2DIGIT / ( SP 1DIGIT ) ) SP time-of-day SP 4DIGIT` */
487
+ const ASCTIME_DATE = new RegExp(`^${DAY} ${MONTH} (\\d{2}| \\d) ${TIME} (\\d{4})$`);
488
+ const isLeapYear = (year) => year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
489
+ const daysInMonth = (year, month) => month === 2 ? isLeapYear(year) ? 29 : 28 : month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;
490
+ /**
491
+ * RFC 8594 `Sunset`: an HTTP-date, which RFC 7231 §7.1.1.1 defines as exactly
492
+ * three forms — IMF-fixdate (the only one a sender may generate), and the
493
+ * obsolete rfc850-date and asctime-date a recipient must still accept. All
494
+ * three denote UTC; only IMF-fixdate and rfc850-date spell the `GMT` literal,
495
+ * and asctime-date carries no zone because it never means anything else.
496
+ *
497
+ * Written out by hand rather than delegated to `Date.parse`, which is not a
498
+ * conformance bug but three:
499
+ *
500
+ * - It **fabricates dates.** `Sat, 31 Feb 2018 23:59:59 GMT` parsed as
501
+ * 2018-03-03 — the client would have told a caller its endpoint disappears
502
+ * on a date the server never sent. The calendar is checked here instead of
503
+ * normalized, so an impossible day yields no date at all.
504
+ * - It is **host-dependent.** For any input outside the ISO-8601 grammar,
505
+ * `Date.parse` is implementation-defined, and V8 falls back to a lenient
506
+ * reader that applies the *local* offset when a value carries no zone. Both
507
+ * `December 31, 2018` and a zone-less `Sat, 31 Dec 2018 23:59:59` therefore
508
+ * produced a different instant on a developer's laptop than in CI — a
509
+ * parsed field with no stable value.
510
+ * - It **disagreed with the Python client**, whose RFC-5322 reader rejected
511
+ * every one of those inputs. The two clients are held to identical parses;
512
+ * `test/fixtures/http-date-vectors.json` is the table both suites read.
513
+ *
514
+ * Rejection is not a silencer: an unparseable `Sunset` leaves the removal date
515
+ * out of the warning, and the notice still fires on the field's presence — the
516
+ * same stance `parseStructuredDate` takes on `Deprecation`.
517
+ */
518
+ const parseHttpDate = (value) => {
519
+ const trimmed = value.trim();
520
+ let fields = null;
521
+ const imf = IMF_FIXDATE.exec(trimmed);
522
+ if (imf !== null) fields = [
523
+ Number(imf[3]),
524
+ imf[2],
525
+ imf[1],
526
+ imf.slice(4, 7)
527
+ ];
528
+ else {
529
+ const rfc850 = RFC850_DATE.exec(trimmed);
530
+ if (rfc850 !== null) {
531
+ const short = Number(rfc850[3]);
532
+ fields = [
533
+ short < 70 ? 2e3 + short : 1900 + short,
534
+ rfc850[2],
535
+ rfc850[1],
536
+ rfc850.slice(4, 7)
537
+ ];
538
+ } else {
539
+ const asctime = ASCTIME_DATE.exec(trimmed);
540
+ if (asctime !== null) fields = [
541
+ Number(asctime[6]),
542
+ asctime[1],
543
+ asctime[2].trim(),
544
+ asctime.slice(3, 6)
545
+ ];
546
+ }
547
+ }
548
+ if (fields === null) return null;
549
+ const [year, month, day, time] = fields;
550
+ const monthIndex = MONTHS.indexOf(month);
551
+ const dayNumber = Number(day);
552
+ const [hour, minute, second] = time.map(Number);
553
+ if (year < 1) return null;
554
+ if (dayNumber < 1 || dayNumber > daysInMonth(year, monthIndex + 1)) return null;
555
+ if (hour > 23 || minute > 59 || second > 59) return null;
556
+ const date = new Date(Date.UTC(year, monthIndex, dayNumber, hour, minute, second));
557
+ if (year < 100) date.setUTCFullYear(year);
558
+ return date;
559
+ };
560
+ /**
561
+ * RFC 8288 `Link`, enough of it: a comma-separated list of `<target>` followed
562
+ * by `;`-separated parameters, where a parameter value may be quoted (and may
563
+ * therefore contain commas and semicolons). Only `rel` and the presence of
564
+ * `anchor` are retained. Malformed input truncates the list instead of failing
565
+ * — whatever parsed before the damage is still usable.
566
+ *
567
+ * Per RFC 8288 §3.3 only the *first* `rel` on a link counts; later occurrences
568
+ * are ignored. Accumulating them instead would let `rel=alternate;
569
+ * rel=deprecation` smuggle an arbitrary target into the relation this client
570
+ * acts on.
571
+ */
572
+ const parseLinkField = (value) => {
573
+ const links = [];
574
+ let index = 0;
575
+ const isSpace = (char) => char === " " || char === " ";
576
+ while (index < value.length) {
577
+ while (index < value.length && (value[index] === "," || isSpace(value[index]))) index++;
578
+ if (value[index] !== "<") break;
579
+ const close = value.indexOf(">", index);
580
+ if (close < 0) break;
581
+ const target = value.slice(index + 1, close).trim();
582
+ index = close + 1;
583
+ const rels = [];
584
+ let seenRel = false;
585
+ let anchored = false;
586
+ while (index < value.length) {
587
+ while (index < value.length && isSpace(value[index])) index++;
588
+ if (value[index] === ",") {
589
+ index++;
590
+ break;
591
+ }
592
+ if (value[index] !== ";") {
593
+ index++;
594
+ continue;
595
+ }
596
+ index++;
597
+ const nameStart = index;
598
+ while (index < value.length && !"=;,".includes(value[index] ?? "")) index++;
599
+ const name = value.slice(nameStart, index).trim().toLowerCase();
600
+ let parameter = "";
601
+ if (value[index] === "=") {
602
+ index++;
603
+ while (index < value.length && isSpace(value[index])) index++;
604
+ if (value[index] === "\"") {
605
+ index++;
606
+ while (index < value.length && value[index] !== "\"") {
607
+ if (value[index] === "\\" && index + 1 < value.length) {
608
+ parameter += value[index + 1];
609
+ index += 2;
610
+ continue;
611
+ }
612
+ parameter += value[index];
613
+ index++;
614
+ }
615
+ index++;
616
+ } else {
617
+ const start = index;
618
+ while (index < value.length && value[index] !== ";" && value[index] !== ",") index++;
619
+ parameter = value.slice(start, index).trim();
620
+ }
621
+ }
622
+ if (name === "rel" && !seenRel) {
623
+ seenRel = true;
624
+ for (const rel of parameter.split(/\s+/)) if (rel !== "") rels.push(rel.toLowerCase());
625
+ }
626
+ if (name === "anchor") anchored = true;
627
+ }
628
+ links.push({
629
+ target,
630
+ rels,
631
+ anchored
632
+ });
633
+ }
634
+ return links;
635
+ };
636
+ const httpURL = (target, baseURL) => {
637
+ try {
638
+ const url = new URL(target, baseURL);
639
+ return url.protocol === "http:" || url.protocol === "https:" ? url : null;
640
+ } catch {
641
+ return null;
642
+ }
643
+ };
644
+ /**
645
+ * A successor is only followed as far as *naming* it, and only when it lands
646
+ * on the API this client is configured against.
647
+ *
648
+ * Two different URLs are in play and conflating them is a real exposure. The
649
+ * *context* is the URL the response actually came from, which is what RFC 8288
650
+ * §3.1 resolves a relative target against — and after a redirect that is not
651
+ * the URL we asked for. The *origin allowlist* is the client's configured
652
+ * `baseURL`, and it stays the allowlist precisely because a redirected
653
+ * response must not be able to nominate itself: resolving against the context
654
+ * but validating against `baseURL` is what stops a cross-origin hop from
655
+ * emitting a relative link that lands back on our origin and passes the check.
656
+ */
657
+ const sameOriginURL = (target, contextURL, baseURL) => {
658
+ const url = httpURL(target, contextURL);
659
+ if (url === null) return null;
660
+ const base = httpURL(baseURL, baseURL);
661
+ return base !== null && url.origin === base.origin ? url : null;
662
+ };
663
+ /**
664
+ * The notice a response carries, or `null` when it carries none. The
665
+ * `Deprecation` field's *presence* is what marks the operation deprecated;
666
+ * `Sunset` and `Link` only enrich the message.
667
+ *
668
+ * `contextURL` is the response's own URL (post-redirect), the context RFC 8288
669
+ * resolves relative link targets against; `baseURL` is the configured API
670
+ * origin a successor must land on.
671
+ */
672
+ const parseDeprecation = (headers, contextURL, baseURL) => {
673
+ const deprecation = readField(headers, "deprecation");
674
+ if (deprecation === null) return null;
675
+ const sunset = readField(headers, "sunset");
676
+ const link = readField(headers, "link");
677
+ const links = link === null ? [] : parseLinkField(link);
678
+ const targetFor = (rel) => links.find((candidate) => !candidate.anchored && candidate.rels.includes(rel))?.target ?? null;
679
+ const documentation = targetFor("deprecation");
680
+ const successor = targetFor("successor-version");
681
+ return {
682
+ deprecatedAt: parseStructuredDate(deprecation),
683
+ sunsetAt: sunset === null ? null : parseHttpDate(sunset),
684
+ documentation: documentation === null ? null : httpURL(documentation, contextURL)?.href ?? null,
685
+ successor: successor === null ? null : sameOriginURL(successor, contextURL, baseURL)
686
+ };
687
+ };
688
+ const pathSegments = (path) => (path.split(/[?#]/, 1)[0] ?? "").split("/").filter((segment) => segment !== "");
689
+ const isTemplateParam = (segment) => segment.startsWith("{") && segment.endsWith("}");
690
+ /**
691
+ * The operation a dispatched request belongs to, recovered from the path it
692
+ * went out on. Path parameters are percent-encoded on the way out
693
+ * (`encodeURIPath`), which encodes `/` and leaves the unreserved characters
694
+ * every literal template segment is made of — so a substituted path has the
695
+ * same segment count as its template and its literal segments compare byte for
696
+ * byte.
697
+ *
698
+ * Where a parameterized template and a literal one overlap
699
+ * (`/toolkits/{slug}` against `/toolkits/categories`) the literal wins, which
700
+ * is the same most-specific-first rule the server routes by.
701
+ *
702
+ * **Known limit of recovering identity from the path.** Two accessors can emit
703
+ * byte-identical requests — `client.toolkits.retrieve('categories')` and
704
+ * `client.toolkits.retrieveCategories()` both dispatch
705
+ * `GET /api/v3.1/toolkits/categories` — so nothing observable distinguishes
706
+ * them here and the literal sibling is always the one named. The warning text
707
+ * can therefore name the sibling rather than the accessor the caller wrote,
708
+ * and the warn-once record is charged to that same sibling. This is
709
+ * inherent to reverse-matching, not a bug in the matcher: the only fix is to
710
+ * thread operation identity through dispatch, which this design deliberately
711
+ * declined (wayfinder ticket 34). The affected pairs are few and the
712
+ * consequence is a misnamed advisory, never a wrong call.
713
+ */
714
+ const matchOperation = (method, path, operations) => {
715
+ const segments = pathSegments(path);
716
+ let best = null;
717
+ let bestLiterals = -1;
718
+ for (const operation of operations) {
719
+ if (operation.method !== method) continue;
720
+ const template = pathSegments(operation.path);
721
+ if (template.length !== segments.length) continue;
722
+ let literals = 0;
723
+ let matched = true;
724
+ for (const [index, part] of template.entries()) {
725
+ if (isTemplateParam(part)) continue;
726
+ if (part !== segments[index]) {
727
+ matched = false;
728
+ break;
729
+ }
730
+ literals++;
731
+ }
732
+ if (matched && literals > bestLiterals) {
733
+ best = operation;
734
+ bestLiterals = literals;
735
+ }
736
+ }
737
+ return best;
738
+ };
739
+ /**
740
+ * The client chain a successor URL names, under the *same* HTTP method.
741
+ *
742
+ * RFC 5829's `successor-version` points at a resource, and an earlier revision
743
+ * of this code fell back to any unambiguous match under a different method
744
+ * when the same one missed. That was wrong in a way that matters: it could
745
+ * answer a deprecated `GET` with "use `client.<resource>.create` instead", telling the
746
+ * caller to replace a read with a write. A successor named under a different
747
+ * method is not a successor for *this* operation, so it is left unnamed and
748
+ * the raw URL is printed instead — accurate and unhelpful beats confident and
749
+ * wrong.
750
+ */
751
+ const matchSuccessorChain = (method, successor, operations) => matchOperation(method, successor.pathname, operations)?.chain ?? null;
752
+ const chainLabel = (chain) => `\`client.${chain.join(".")}\``;
753
+ const formatDeprecationWarning = (subject, notice, successorChain) => {
754
+ const parts = [`Composio: ${subject} is deprecated.`];
755
+ if (notice.deprecatedAt !== null) parts.push(`Announced ${notice.deprecatedAt.toISOString()}.`);
756
+ if (notice.sunsetAt !== null) parts.push(`Scheduled for removal on ${notice.sunsetAt.toISOString()}.`);
757
+ if (successorChain !== null) parts.push(`Use ${chainLabel(successorChain)} instead.`);
758
+ else if (notice.successor !== null) parts.push(`Successor: ${notice.successor.href}.`);
759
+ if (notice.documentation !== null) parts.push(`See ${notice.documentation}`);
760
+ return parts.join(" ");
761
+ };
762
+ /**
763
+ * NUL joins the halves of a warn-once key. Neither a client chain nor a URL
764
+ * the WHATWG parser produced can carry one, so no pair of distinct components
765
+ * can collide by concatenation.
766
+ */
767
+ const KEY_SEPARATOR = "\0";
768
+ /**
769
+ * What makes one notice *distinct* from another, for the warn-once record.
770
+ *
771
+ * Derived from the parsed fields rather than the raw header bytes on purpose:
772
+ * a requoted `Link` or a stray space around `Deprecation` reads as the same
773
+ * notice and must not warn a second time. The three fields here are the ones a
774
+ * caller acts on — when the deprecation was announced, when the operation
775
+ * stops being served, and what replaces it. `documentation` is deliberately
776
+ * excluded: it points at prose *about* this notice, so the platform moving its
777
+ * developer notes to another URL is not news worth repeating a warning for.
778
+ */
779
+ const noticeKey = (notice) => [
780
+ notice.deprecatedAt?.getTime() ?? "",
781
+ notice.sunsetAt?.getTime() ?? "",
782
+ notice.successor?.href ?? ""
783
+ ].join(KEY_SEPARATOR);
784
+ /**
785
+ * The interceptor itself: at most one warning per distinct notice per
786
+ * deprecated operation per client instance.
787
+ *
788
+ * It sits at the single response exit in `makeRequest`, after the retry
789
+ * decision has settled, so a response that is about to be discarded and
790
+ * retried never warns and a logical call warns at most once however the caller
791
+ * consumes it — `APIPromise` awaits one `makeRequest` per call and hands the
792
+ * same `Response` to `asResponse()`, `withResponse()` and the parsed path
793
+ * alike.
794
+ */
795
+ const inspectDeprecation = ({ response, method, path, baseURL, operations, seen, warn }) => {
796
+ const notice = parseDeprecation(response.headers, response.url || baseURL, baseURL);
797
+ if (notice === null) return;
798
+ const operation = matchOperation(method, path, operations);
799
+ const key = `${operation === null ? `${method} ${pathSegments(path).join("/")}` : operation.chain.join(".")}${KEY_SEPARATOR}${noticeKey(notice)}`;
800
+ if (seen.has(key)) return;
801
+ if (seen.size >= MAX_TRACKED_NOTICES) return;
802
+ seen.add(key);
803
+ const successorChain = notice.successor === null ? null : matchSuccessorChain(method, notice.successor, operations);
804
+ const subject = operation === null ? `${method.toUpperCase()} ${path}` : chainLabel(operation.chain);
805
+ warn(formatDeprecationWarning(subject, notice, successorChain));
806
+ };
807
+
808
+ //#endregion
809
+ //#region src/compat/request.ts
810
+ /**
811
+ * Percent-encode everything that isn't a RFC-3986 pchar, leaving safe chars
812
+ * (unreserved / sub-delims / ":" / "@") readable.
813
+ */
814
+ const encodeURIPath = (str) => str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
815
+ /**
816
+ * Template tag interpolating path params percent-encoded, rejecting values
817
+ * that would introduce `.` / `..` (or percent-encoded variants) path segments.
818
+ */
819
+ const path = (statics, ...params) => {
820
+ let result = statics[0] ?? "";
821
+ params.forEach((param, index) => {
822
+ result += encodeURIPath(String(param)) + (statics[index + 1] ?? "");
823
+ });
824
+ const pathOnly = result.split(/[?#]/, 1)[0] ?? "";
825
+ if (/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/i.test(pathOnly)) throw new ComposioError(`Path parameters result in path with invalid segments: ${result}`);
826
+ return result;
827
+ };
828
+ /**
829
+ * Stainless-flavored query serialization: `arrayFormat: 'comma'` (arrays become
830
+ * one comma-joined param), `undefined` entries dropped, `null` entries kept as
831
+ * empty values, and plain-object values expanded qs-style into bracket
832
+ * notation (`toolkit_versions[github]=v1`, the whole key percent-encoded) —
833
+ * pinned differentially against Stainless via `tools.retrieve`'s object
834
+ * `toolkit_versions` param (wayfinder ticket 23).
835
+ */
836
+ const stringifyQuery = (query) => {
837
+ const parts = [];
838
+ const append = (key, value) => {
839
+ if (value === void 0) return;
840
+ if (value === null) {
841
+ parts.push(`${encodeURIComponent(key)}=`);
842
+ return;
843
+ }
844
+ if (Array.isArray(value)) {
845
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.join(","))}`);
846
+ return;
847
+ }
848
+ if (typeof value === "object") {
849
+ for (const [subKey, subValue] of Object.entries(value)) append(`${key}[${subKey}]`, subValue);
850
+ return;
851
+ }
852
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
853
+ };
854
+ for (const [key, value] of Object.entries(query)) append(key, value);
855
+ return parts.join("&");
856
+ };
857
+ const buildURL = (config, options) => {
858
+ const base = config.baseURL;
859
+ const joined = base.endsWith("/") && options.path.startsWith("/") ? options.path.slice(1) : options.path;
860
+ const url = new URL(base + joined);
861
+ const query = {
862
+ ...Object.fromEntries(url.searchParams),
863
+ ...config.defaultQuery,
864
+ ...options.query
865
+ };
866
+ const search = stringifyQuery(query);
867
+ if (search) url.search = search;
868
+ return url.toString();
869
+ };
870
+ /**
871
+ * Merges header sources in Stainless precedence order (later wins); a `null`
872
+ * value deletes the header, `undefined` leaves it untouched.
873
+ */
874
+ const buildHeaders = (sources) => {
875
+ const headers = new Headers();
876
+ for (const source of sources) {
877
+ if (!source) continue;
878
+ for (const [name, value] of Object.entries(source)) {
879
+ if (value === void 0) continue;
880
+ if (value === null) headers.delete(name);
881
+ else headers.set(name, value);
882
+ }
883
+ }
884
+ return headers;
885
+ };
886
+ /**
887
+ * JSON body encoding. A resource method always passes the `body` key when its
888
+ * operation defines a request body — even an omitted optional body arrives as
889
+ * `{}` — so `Content-Type: application/json` is kept for those; operations
890
+ * with no body at all (GET/DELETE) send neither body nor content-type.
891
+ */
892
+ const buildBody = (options) => {
893
+ if (!("body" in options) || options.body === void 0) return {
894
+ body: void 0,
895
+ bodyHeaders: void 0
896
+ };
897
+ return {
898
+ body: JSON.stringify(options.body),
899
+ bodyHeaders: { "content-type": "application/json" }
900
+ };
901
+ };
902
+ const safeJSON = (text) => {
903
+ try {
904
+ return JSON.parse(text);
905
+ } catch {
906
+ return;
907
+ }
908
+ };
909
+ const castToError = (err) => {
910
+ if (err instanceof Error) return err;
911
+ if (typeof err === "object" && err !== null) try {
912
+ return new Error(JSON.stringify(err));
913
+ } catch {}
914
+ return new Error(String(err));
915
+ };
916
+ const validatePositiveInteger = (name, value) => {
917
+ if (!Number.isInteger(value)) throw new ComposioError(`${name} must be an integer`);
918
+ if (value < 0) throw new ComposioError(`${name} must be a positive integer`);
919
+ };
920
+ const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
921
+ 408,
922
+ 409,
923
+ 429
924
+ ]);
925
+ const shouldRetryResponse = (response) => {
926
+ const explicit = response.headers.get("x-should-retry");
927
+ if (explicit === "true") return true;
928
+ if (explicit === "false") return false;
929
+ return RETRYABLE_STATUSES.has(response.status) || response.status >= 500;
930
+ };
931
+ /**
932
+ * Ceiling for server-supplied retry delays. A `retry-after(-ms)` value is
933
+ * honored only when `0 <= ms < 60_000`; anything negative, non-finite, or a
934
+ * minute and beyond falls back to exponential backoff instead of collapsing
935
+ * the backoff to zero or stalling the caller for the server's whim.
936
+ */
937
+ const MAX_RETRY_AFTER_MILLIS = 6e4;
938
+ /**
939
+ * How long to wait before retry number `numRetries + 1`: `retry-after-ms`
940
+ * (milliseconds), then `retry-after` (seconds or HTTP date), then exponential
941
+ * backoff `min(0.5s · 2^n, 8s)` with up to 25% downward jitter. A
942
+ * header-derived delay is used only when it is finite and within
943
+ * `[0, MAX_RETRY_AFTER_MILLIS)`; out-of-range values fall through to the
944
+ * backoff.
945
+ */
946
+ const retryDelayMillis = (numRetries, headers) => {
947
+ let headerDelayMillis;
948
+ const retryAfterMs = parseFloat(headers?.get("retry-after-ms") ?? "");
949
+ if (!Number.isNaN(retryAfterMs)) headerDelayMillis = retryAfterMs;
950
+ else {
951
+ const retryAfter = headers?.get("retry-after");
952
+ if (retryAfter) {
953
+ const seconds = parseFloat(retryAfter);
954
+ if (!Number.isNaN(seconds)) headerDelayMillis = seconds * 1e3;
955
+ else {
956
+ const untilDate = Date.parse(retryAfter) - Date.now();
957
+ if (!Number.isNaN(untilDate)) headerDelayMillis = untilDate;
958
+ }
959
+ }
960
+ }
961
+ if (headerDelayMillis !== void 0 && headerDelayMillis >= 0 && headerDelayMillis < MAX_RETRY_AFTER_MILLIS) return headerDelayMillis;
962
+ return Math.min(.5 * 2 ** numRetries, 8) * (1 - Math.random() * .25) * 1e3;
963
+ };
964
+ const REDIRECT_STATUSES = /* @__PURE__ */ new Set([
965
+ 301,
966
+ 302,
967
+ 303,
968
+ 307,
969
+ 308
970
+ ]);
971
+ /**
972
+ * How many hops one attempt will follow before giving up. Twenty is what the
973
+ * Fetch spec budgets and what undici and every browser enforce, so a chain this
974
+ * kernel refuses is one the platform would have refused too.
975
+ */
976
+ const MAX_REDIRECTS = 20;
977
+ const TOO_MANY_REDIRECTS = `The API redirected more than ${MAX_REDIRECTS} times; the chain was abandoned.`;
978
+ /**
979
+ * The one environment-dependent behavior in the kernel, stated rather than
980
+ * degraded into — and narrowed to the case where safety cannot be proved.
981
+ *
982
+ * Following redirects by hand requires reading the `Location` off a 3xx, and
983
+ * only a runtime that hands back the real response can offer that — Node,
984
+ * Deno and Bun do. A **browser** answers `redirect: 'manual'` with a *filtered*
985
+ * response (`type: 'opaqueredirect'`, status 0, no headers), so there is
986
+ * nothing to read and manual following is not implementable there.
987
+ *
988
+ * Dispatching at `redirect: 'follow'` instead is exactly what this module
989
+ * exists to prevent *when a credential is attached*: the Fetch spec deletes
990
+ * only `Authorization` across a cross-origin redirect, so a custom `x-api-key`
991
+ * rides along, and an attacker-controlled origin that answers the preflight
992
+ * with a permissive `Access-Control-Allow-Headers` harvests it. (CORS bounds
993
+ * that — any request carrying `x-api-key` is preflighted, so the third party
994
+ * has to cooperate — but bounded is not prevented.)
995
+ *
996
+ * When *nothing* credential-bearing is going out that reasoning has no
997
+ * premise, so the first dispatch of such a chain is delegated (see
998
+ * `carriesCredentials`) and a browser follows it normally. That is where
999
+ * real-world redirects on this API actually live: an escape-hatch fetch of a
1000
+ * presigned storage URL, which rule 2 has already stripped our key from, and
1001
+ * which S3 and GCS commonly answer with a 302.
1002
+ *
1003
+ * What is left is a *credentialed* request that redirects in a browser. It
1004
+ * gets a named error rather than a silent leak — and on this API that is very
1005
+ * nearly unreachable: the only redirects the platform serves are same-origin
1006
+ * edge normalizations (wayfinder ticket 40 records the recon), and `buildURL`
1007
+ * cannot construct a URL that triggers one.
1008
+ */
1009
+ const OPAQUE_REDIRECT = "The API responded with a redirect that this runtime will not let the client read (an opaque redirect, in a browser). Redirects are followed only where the response can be inspected, because a credential must never cross an origin change.";
1010
+ const isOpaqueRedirect = (response) => response.type === "opaqueredirect";
1011
+ /**
1012
+ * Fetch's own method rewrite (§4.4 "HTTP-redirect fetch", step 13): a 303
1013
+ * turns any non-GET into a GET, and a 301/302 does the same to a POST — both
1014
+ * dropping the body. 307 and 308 preserve the method and the body, which is
1015
+ * what they exist for. Following by hand means reproducing this, or a caller's
1016
+ * POST silently becomes a POST to somewhere it was never sent before.
1017
+ */
1018
+ /**
1019
+ * The `Location` a hop points at, resolved against the URL it arrived on, or
1020
+ * `null` when there is nothing followable there — unparseable, or a scheme
1021
+ * this client does not speak (`data:`, `file:`, an app link). `null` hands the
1022
+ * 3xx back as the response it is, which is what `fetch` does with a `Location`
1023
+ * it cannot use.
1024
+ */
1025
+ const resolveLocation = (location, from) => {
1026
+ try {
1027
+ return parseHTTPURL(new URL(location, from).href);
1028
+ } catch {
1029
+ return null;
1030
+ }
1031
+ };
1032
+ const rewriteForRedirect = (status, method) => status === 303 && method !== "GET" && method !== "HEAD" || (status === 301 || status === 302) && method === "POST";
1033
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1034
+ /**
1035
+ * Indirection over `sleep` so kernel tests can capture retry delays instead
1036
+ * of waiting them out on the wall clock. Internal seam only — deliberately
1037
+ * not re-exported from `compat/index.ts`, so the public package surface is
1038
+ * unchanged.
1039
+ */
1040
+ const kernelInternals = { sleep };
1041
+ /**
1042
+ * The headers for one hop, built fresh from the URL that hop is going to.
1043
+ *
1044
+ * This is where rule 3 mostly stops needing machinery of its own: the
1045
+ * credential is re-derived per hop from the *request* URL rather than carried
1046
+ * along from the last one, so a hop that leaves the configured API origin
1047
+ * simply does not get a key. `withdrawn` covers what that cannot — the
1048
+ * caller's own credential headers, which are legitimate on the URL the caller
1049
+ * chose and are dropped once the *server* has chosen one.
1050
+ */
1051
+ const buildRequestHeaders = (config, options, requestURL, bodyHeaders, withdrawn, scheme) => {
1052
+ const credential = withdrawn || callerPlacedCredential([config.defaultHeaders, options.headers]) ? null : credentialForRequest(config.baseURL, scheme, config.credentials, requestURL);
1053
+ const headers = buildHeaders([
1054
+ {
1055
+ accept: "application/json",
1056
+ "user-agent": config.userAgent
1057
+ },
1058
+ credential === null ? void 0 : { [credential.name]: credential.value },
1059
+ config.defaultHeaders,
1060
+ bodyHeaders,
1061
+ options.headers
1062
+ ]);
1063
+ if (withdrawn) withdrawCredentials(headers);
1064
+ return headers;
1065
+ };
1066
+ /**
1067
+ * The credential class this logical request authenticates with, decided once
1068
+ * from the operation the *caller* invoked.
1069
+ *
1070
+ * Deliberately not re-derived per redirect hop. A hop's URL was chosen by the
1071
+ * server, so matching it back to a template would let the server's choice
1072
+ * change which of the caller's credentials goes out; the operation the caller
1073
+ * asked for is the honest answer for the whole chain, and rule 3 already
1074
+ * withdraws everything once a hop leaves the origin.
1075
+ *
1076
+ * The table is skipped outright unless a second credential is configured. With
1077
+ * only `apiKey` set the answer is `ApiKeyAuth` down every branch of
1078
+ * {@link selectScheme}, so an existing caller pays nothing for a feature they
1079
+ * do not use, and their requests are byte-identical by construction rather
1080
+ * than by assertion.
1081
+ */
1082
+ const schemeForRequest = (config, options) => {
1083
+ if (!hasAlternateCredential(config.credentials)) return "ApiKeyAuth";
1084
+ return selectScheme(matchOperation(options.method, options.path, config.operations ?? [])?.schemes, config.credentials);
1085
+ };
1086
+ /**
1087
+ * One attempt: the request, plus however many redirects it takes to land on a
1088
+ * non-3xx response.
1089
+ *
1090
+ * The whole chain sits **inside one attempt** — one entry in the retry budget,
1091
+ * one per-attempt timeout covering every hop. Both follow from what a redirect
1092
+ * is: the caller made one logical request, so a chain must not consume
1093
+ * `maxRetries` (a 3xx is not a failure to retry) and must not be able to
1094
+ * multiply the caller's time budget by the hop limit. A retry re-issues the
1095
+ * *original* request, chain and all.
1096
+ *
1097
+ * Everything the server chose is re-derived rather than carried: the headers
1098
+ * (see `buildRequestHeaders`), the method and body (fetch's own 301/302/303
1099
+ * rewrite), and the query, which is left to the `Location` URL because the
1100
+ * server picked it. `config.defaultQuery` is applied to the URL the caller
1101
+ * asked for, not to the one it was sent to.
1102
+ */
1103
+ const dispatchWithRedirects = async (config, options, initialURL, initialBody, initialBodyHeaders, signal, scheme) => {
1104
+ let url = initialURL;
1105
+ let method = options.method.toUpperCase();
1106
+ let body = initialBody;
1107
+ let bodyHeaders = initialBodyHeaders;
1108
+ let withdrawn = false;
1109
+ for (let hop = 0;; hop++) {
1110
+ const headers = buildRequestHeaders(config, options, url, bodyHeaders, withdrawn, scheme);
1111
+ const delegated = hop === 0 && !carriesCredentials(headers);
1112
+ const response = await config.fetch.call(void 0, url, {
1113
+ method,
1114
+ headers,
1115
+ ...body !== void 0 ? { body } : {},
1116
+ ...config.fetchOptions,
1117
+ ...options.fetchOptions,
1118
+ redirect: delegated ? "follow" : "manual",
1119
+ signal
1120
+ });
1121
+ if (delegated) return response;
1122
+ if (isOpaqueRedirect(response)) throw new APIConnectionError({ message: OPAQUE_REDIRECT });
1123
+ if (!REDIRECT_STATUSES.has(response.status)) return response;
1124
+ const location = response.headers.get("location");
1125
+ if (location === null) return response;
1126
+ const target = resolveLocation(location, url);
1127
+ if (target === null) return response;
1128
+ if (hop >= MAX_REDIRECTS) throw new APIConnectionError({ message: TOO_MANY_REDIRECTS });
1129
+ response.body?.cancel().catch(() => void 0);
1130
+ if (target.origin !== new URL(url).origin) withdrawn = true;
1131
+ if (rewriteForRedirect(response.status, method)) {
1132
+ method = "GET";
1133
+ body = void 0;
1134
+ bodyHeaders = void 0;
1135
+ }
1136
+ url = target.href;
1137
+ }
1138
+ };
1139
+ /**
1140
+ * The dispatch kernel: one attempt loop with Stainless runtime semantics —
1141
+ * per-attempt timeouts (timeouts and connection errors are retried, like
1142
+ * HTTP-level 408/409/429/5xx and `x-should-retry`), `retry-after(-ms)`
1143
+ * honored, abort → `APIUserAbortError`. Resolves with the raw un-consumed
1144
+ * `Response` regardless of HTTP status; body parsing and error mapping are
1145
+ * strictly deferred to `APIPromise`.
1146
+ *
1147
+ * Redirects are followed inside an attempt by `dispatchWithRedirects`, so the
1148
+ * single response exit below still fires `onResponse` **once per logical
1149
+ * call** rather than once per hop — the once-per-call guarantee ticket 34
1150
+ * built the deprecation interceptor on. The `Response` handed back is the
1151
+ * final hop's, so `response.url` is still "the URL this response came from",
1152
+ * which is what `deprecation.ts` resolves relative `Link` targets against.
1153
+ */
1154
+ async function makeRequest(config, options) {
1155
+ if (options.timeout !== void 0) validatePositiveInteger("timeout", options.timeout);
1156
+ const maxRetries = options.maxRetries ?? config.maxRetries;
1157
+ validatePositiveInteger("maxRetries", maxRetries);
1158
+ const timeout = options.timeout ?? config.timeout;
1159
+ const url = buildURL(config, options);
1160
+ const { body, bodyHeaders } = buildBody(options);
1161
+ const userSignal = options.signal ?? void 0;
1162
+ const scheme = schemeForRequest(config, options);
1163
+ for (let numRetries = 0;; numRetries++) {
1164
+ if (userSignal?.aborted) throw new APIUserAbortError();
1165
+ const retriesRemaining = maxRetries - numRetries;
1166
+ const controller = new AbortController();
1167
+ const abort = () => controller.abort();
1168
+ userSignal?.addEventListener("abort", abort, { once: true });
1169
+ const timer = setTimeout(abort, timeout);
1170
+ let result;
1171
+ try {
1172
+ result = await dispatchWithRedirects(config, options, url, body, bodyHeaders, controller.signal, scheme);
1173
+ } catch (cause) {
1174
+ if (cause instanceof ComposioError) throw cause;
1175
+ result = castToError(cause);
1176
+ } finally {
1177
+ clearTimeout(timer);
1178
+ userSignal?.removeEventListener("abort", abort);
1179
+ }
1180
+ if (result instanceof Error) {
1181
+ if (userSignal?.aborted) throw new APIUserAbortError();
1182
+ const isTimeout = controller.signal.aborted || /timed? ?out/i.test(String(result) + ("cause" in result ? String(result.cause) : ""));
1183
+ if (retriesRemaining > 0) {
1184
+ await kernelInternals.sleep(retryDelayMillis(numRetries));
1185
+ continue;
1186
+ }
1187
+ if (isTimeout) throw new APIConnectionTimeoutError();
1188
+ throw new APIConnectionError({ cause: result });
1189
+ }
1190
+ if (!result.ok && retriesRemaining > 0 && shouldRetryResponse(result)) {
1191
+ result.body?.cancel().catch(() => void 0);
1192
+ await kernelInternals.sleep(retryDelayMillis(numRetries, result.headers));
1193
+ continue;
1194
+ }
1195
+ if (config.onResponse !== void 0) try {
1196
+ config.onResponse(result, options);
1197
+ } catch {}
1198
+ return result;
1199
+ }
1200
+ }
1201
+
1202
+ //#endregion
1203
+ export { PermissionDeniedError as _, inspectDeprecation as a, APIConnectionTimeoutError as c, AuthenticationError as d, BadRequestError as f, NotFoundError as g, InternalServerError as h, safeJSON as i, APIError as l, ConflictError as m, makeRequest as n, assertCredentialTransport as o, ComposioError as p, path as r, APIConnectionError as s, castToError as t, APIUserAbortError as u, RateLimitError as v, UnprocessableEntityError as y };