@agentuity/server 1.0.31 → 1.0.33

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 (566) hide show
  1. package/AGENTS.md +1 -0
  2. package/dist/api/api.d.ts +1 -227
  3. package/dist/api/api.d.ts.map +1 -1
  4. package/dist/api/api.js +1 -637
  5. package/dist/api/api.js.map +1 -1
  6. package/dist/api/index.d.ts +1 -17
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +1 -17
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/org/env-delete.d.ts +1 -22
  11. package/dist/api/org/env-delete.d.ts.map +1 -1
  12. package/dist/api/org/env-delete.js +1 -24
  13. package/dist/api/org/env-delete.js.map +1 -1
  14. package/dist/api/org/env-get.d.ts +1 -32
  15. package/dist/api/org/env-get.d.ts.map +1 -1
  16. package/dist/api/org/env-get.js +1 -25
  17. package/dist/api/org/env-get.js.map +1 -1
  18. package/dist/api/org/env-update.d.ts +1 -23
  19. package/dist/api/org/env-update.d.ts.map +1 -1
  20. package/dist/api/org/env-update.js +1 -25
  21. package/dist/api/org/env-update.js.map +1 -1
  22. package/dist/api/project/get.d.ts +1 -42
  23. package/dist/api/project/get.d.ts.map +1 -1
  24. package/dist/api/project/get.js +1 -35
  25. package/dist/api/project/get.js.map +1 -1
  26. package/dist/api/project/list.d.ts +1 -47
  27. package/dist/api/project/list.d.ts.map +1 -1
  28. package/dist/api/project/list.js +1 -37
  29. package/dist/api/project/list.js.map +1 -1
  30. package/dist/api/project/malware.d.ts +1 -70
  31. package/dist/api/project/malware.d.ts.map +1 -1
  32. package/dist/api/project/malware.js +1 -41
  33. package/dist/api/project/malware.js.map +1 -1
  34. package/dist/api/region/create.d.ts +1 -80
  35. package/dist/api/region/create.d.ts.map +1 -1
  36. package/dist/api/region/create.js +1 -176
  37. package/dist/api/region/create.js.map +1 -1
  38. package/dist/api/sandbox/client.d.ts +1 -190
  39. package/dist/api/sandbox/client.d.ts.map +1 -1
  40. package/dist/api/sandbox/client.js +1 -260
  41. package/dist/api/sandbox/client.js.map +1 -1
  42. package/dist/api/sandbox/pause.d.ts +1 -21
  43. package/dist/api/sandbox/pause.d.ts.map +1 -1
  44. package/dist/api/sandbox/pause.js +1 -24
  45. package/dist/api/sandbox/pause.js.map +1 -1
  46. package/dist/api/sandbox/resume.d.ts +1 -21
  47. package/dist/api/sandbox/resume.d.ts.map +1 -1
  48. package/dist/api/sandbox/resume.js +1 -24
  49. package/dist/api/sandbox/resume.js.map +1 -1
  50. package/dist/api/sandbox/util.d.ts +1 -284
  51. package/dist/api/sandbox/util.d.ts.map +1 -1
  52. package/dist/api/sandbox/util.js +1 -210
  53. package/dist/api/sandbox/util.js.map +1 -1
  54. package/dist/api/user/whoami.d.ts +1 -38
  55. package/dist/api/user/whoami.d.ts.map +1 -1
  56. package/dist/api/user/whoami.js +1 -26
  57. package/dist/api/user/whoami.js.map +1 -1
  58. package/dist/index.d.ts +1 -4
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +3 -12
  61. package/dist/index.js.map +1 -1
  62. package/dist/util/resources.js +2 -2
  63. package/dist/util/resources.js.map +1 -1
  64. package/package.json +4 -4
  65. package/src/api/api.ts +1 -936
  66. package/src/api/index.ts +1 -17
  67. package/src/api/org/env-delete.ts +1 -37
  68. package/src/api/org/env-get.ts +1 -43
  69. package/src/api/org/env-update.ts +1 -38
  70. package/src/api/project/get.ts +1 -49
  71. package/src/api/project/list.ts +1 -54
  72. package/src/api/project/malware.ts +1 -68
  73. package/src/api/region/create.ts +1 -207
  74. package/src/api/sandbox/client.ts +1 -460
  75. package/src/api/sandbox/pause.ts +1 -39
  76. package/src/api/sandbox/resume.ts +1 -39
  77. package/src/api/sandbox/util.ts +1 -276
  78. package/src/api/user/whoami.ts +1 -32
  79. package/src/index.ts +3 -30
  80. package/src/util/resources.ts +2 -2
  81. package/dist/api/apikey/create.d.ts +0 -33
  82. package/dist/api/apikey/create.d.ts.map +0 -1
  83. package/dist/api/apikey/create.js +0 -23
  84. package/dist/api/apikey/create.js.map +0 -1
  85. package/dist/api/apikey/delete.d.ts +0 -19
  86. package/dist/api/apikey/delete.d.ts.map +0 -1
  87. package/dist/api/apikey/delete.js +0 -19
  88. package/dist/api/apikey/delete.js.map +0 -1
  89. package/dist/api/apikey/get.d.ts +0 -45
  90. package/dist/api/apikey/get.d.ts.map +0 -1
  91. package/dist/api/apikey/get.js +0 -36
  92. package/dist/api/apikey/get.js.map +0 -1
  93. package/dist/api/apikey/index.d.ts +0 -6
  94. package/dist/api/apikey/index.d.ts.map +0 -1
  95. package/dist/api/apikey/index.js +0 -6
  96. package/dist/api/apikey/index.js.map +0 -1
  97. package/dist/api/apikey/list.d.ts +0 -64
  98. package/dist/api/apikey/list.d.ts.map +0 -1
  99. package/dist/api/apikey/list.js +0 -46
  100. package/dist/api/apikey/list.js.map +0 -1
  101. package/dist/api/apikey/util.d.ts +0 -23
  102. package/dist/api/apikey/util.d.ts.map +0 -1
  103. package/dist/api/apikey/util.js +0 -3
  104. package/dist/api/apikey/util.js.map +0 -1
  105. package/dist/api/db/index.d.ts +0 -5
  106. package/dist/api/db/index.d.ts.map +0 -1
  107. package/dist/api/db/index.js +0 -5
  108. package/dist/api/db/index.js.map +0 -1
  109. package/dist/api/db/logs.d.ts +0 -70
  110. package/dist/api/db/logs.d.ts.map +0 -1
  111. package/dist/api/db/logs.js +0 -59
  112. package/dist/api/db/logs.js.map +0 -1
  113. package/dist/api/db/query.d.ts +0 -39
  114. package/dist/api/db/query.d.ts.map +0 -1
  115. package/dist/api/db/query.js +0 -49
  116. package/dist/api/db/query.js.map +0 -1
  117. package/dist/api/db/tables.d.ts +0 -49
  118. package/dist/api/db/tables.d.ts.map +0 -1
  119. package/dist/api/db/tables.js +0 -59
  120. package/dist/api/db/tables.js.map +0 -1
  121. package/dist/api/db/util.d.ts +0 -31
  122. package/dist/api/db/util.d.ts.map +0 -1
  123. package/dist/api/db/util.js +0 -4
  124. package/dist/api/db/util.js.map +0 -1
  125. package/dist/api/eval/get.d.ts +0 -36
  126. package/dist/api/eval/get.d.ts.map +0 -1
  127. package/dist/api/eval/get.js +0 -23
  128. package/dist/api/eval/get.js.map +0 -1
  129. package/dist/api/eval/index.d.ts +0 -5
  130. package/dist/api/eval/index.d.ts.map +0 -1
  131. package/dist/api/eval/index.js +0 -5
  132. package/dist/api/eval/index.js.map +0 -1
  133. package/dist/api/eval/list.d.ts +0 -50
  134. package/dist/api/eval/list.d.ts.map +0 -1
  135. package/dist/api/eval/list.js +0 -32
  136. package/dist/api/eval/list.js.map +0 -1
  137. package/dist/api/eval/run-get.d.ts +0 -48
  138. package/dist/api/eval/run-get.d.ts.map +0 -1
  139. package/dist/api/eval/run-get.js +0 -29
  140. package/dist/api/eval/run-get.js.map +0 -1
  141. package/dist/api/eval/run-list.d.ts +0 -70
  142. package/dist/api/eval/run-list.d.ts.map +0 -1
  143. package/dist/api/eval/run-list.js +0 -42
  144. package/dist/api/eval/run-list.js.map +0 -1
  145. package/dist/api/machine/index.d.ts +0 -3
  146. package/dist/api/machine/index.d.ts.map +0 -1
  147. package/dist/api/machine/index.js +0 -3
  148. package/dist/api/machine/index.js.map +0 -1
  149. package/dist/api/machine/machine.d.ts +0 -192
  150. package/dist/api/machine/machine.d.ts.map +0 -1
  151. package/dist/api/machine/machine.js +0 -109
  152. package/dist/api/machine/machine.js.map +0 -1
  153. package/dist/api/machine/util.d.ts +0 -14
  154. package/dist/api/machine/util.d.ts.map +0 -1
  155. package/dist/api/machine/util.js +0 -3
  156. package/dist/api/machine/util.js.map +0 -1
  157. package/dist/api/org/index.d.ts +0 -7
  158. package/dist/api/org/index.d.ts.map +0 -1
  159. package/dist/api/org/index.js +0 -7
  160. package/dist/api/org/index.js.map +0 -1
  161. package/dist/api/org/list.d.ts +0 -27
  162. package/dist/api/org/list.d.ts.map +0 -1
  163. package/dist/api/org/list.js +0 -22
  164. package/dist/api/org/list.js.map +0 -1
  165. package/dist/api/org/resources.d.ts +0 -141
  166. package/dist/api/org/resources.d.ts.map +0 -1
  167. package/dist/api/org/resources.js +0 -92
  168. package/dist/api/org/resources.js.map +0 -1
  169. package/dist/api/org/util.d.ts +0 -45
  170. package/dist/api/org/util.d.ts.map +0 -1
  171. package/dist/api/org/util.js +0 -4
  172. package/dist/api/org/util.js.map +0 -1
  173. package/dist/api/project/agent.d.ts +0 -89
  174. package/dist/api/project/agent.d.ts.map +0 -1
  175. package/dist/api/project/agent.js +0 -60
  176. package/dist/api/project/agent.js.map +0 -1
  177. package/dist/api/project/create.d.ts +0 -37
  178. package/dist/api/project/create.d.ts.map +0 -1
  179. package/dist/api/project/create.js +0 -31
  180. package/dist/api/project/create.js.map +0 -1
  181. package/dist/api/project/delete.d.ts +0 -15
  182. package/dist/api/project/delete.d.ts.map +0 -1
  183. package/dist/api/project/delete.js +0 -13
  184. package/dist/api/project/delete.js.map +0 -1
  185. package/dist/api/project/deploy.d.ts +0 -490
  186. package/dist/api/project/deploy.d.ts.map +0 -1
  187. package/dist/api/project/deploy.js +0 -313
  188. package/dist/api/project/deploy.js.map +0 -1
  189. package/dist/api/project/deployment.d.ts +0 -237
  190. package/dist/api/project/deployment.d.ts.map +0 -1
  191. package/dist/api/project/deployment.js +0 -127
  192. package/dist/api/project/deployment.js.map +0 -1
  193. package/dist/api/project/env-delete.d.ts +0 -22
  194. package/dist/api/project/env-delete.d.ts.map +0 -1
  195. package/dist/api/project/env-delete.js +0 -29
  196. package/dist/api/project/env-delete.js.map +0 -1
  197. package/dist/api/project/env-update.d.ts +0 -31
  198. package/dist/api/project/env-update.d.ts.map +0 -1
  199. package/dist/api/project/env-update.js +0 -36
  200. package/dist/api/project/env-update.js.map +0 -1
  201. package/dist/api/project/exists.d.ts +0 -25
  202. package/dist/api/project/exists.d.ts.map +0 -1
  203. package/dist/api/project/exists.js +0 -45
  204. package/dist/api/project/exists.js.map +0 -1
  205. package/dist/api/project/hostname.d.ts +0 -25
  206. package/dist/api/project/hostname.d.ts.map +0 -1
  207. package/dist/api/project/hostname.js +0 -37
  208. package/dist/api/project/hostname.js.map +0 -1
  209. package/dist/api/project/index.d.ts +0 -14
  210. package/dist/api/project/index.d.ts.map +0 -1
  211. package/dist/api/project/index.js +0 -14
  212. package/dist/api/project/index.js.map +0 -1
  213. package/dist/api/project/update-region.d.ts +0 -27
  214. package/dist/api/project/update-region.d.ts.map +0 -1
  215. package/dist/api/project/update-region.js +0 -25
  216. package/dist/api/project/update-region.js.map +0 -1
  217. package/dist/api/project/util.d.ts +0 -62
  218. package/dist/api/project/util.d.ts.map +0 -1
  219. package/dist/api/project/util.js +0 -6
  220. package/dist/api/project/util.js.map +0 -1
  221. package/dist/api/queue/analytics.d.ts +0 -250
  222. package/dist/api/queue/analytics.d.ts.map +0 -1
  223. package/dist/api/queue/analytics.js +0 -233
  224. package/dist/api/queue/analytics.js.map +0 -1
  225. package/dist/api/queue/destinations.d.ts +0 -202
  226. package/dist/api/queue/destinations.d.ts.map +0 -1
  227. package/dist/api/queue/destinations.js +0 -168
  228. package/dist/api/queue/destinations.js.map +0 -1
  229. package/dist/api/queue/dlq.d.ts +0 -168
  230. package/dist/api/queue/dlq.d.ts.map +0 -1
  231. package/dist/api/queue/dlq.js +0 -166
  232. package/dist/api/queue/dlq.js.map +0 -1
  233. package/dist/api/queue/index.d.ts +0 -56
  234. package/dist/api/queue/index.d.ts.map +0 -1
  235. package/dist/api/queue/index.js +0 -90
  236. package/dist/api/queue/index.js.map +0 -1
  237. package/dist/api/queue/messages.d.ts +0 -503
  238. package/dist/api/queue/messages.d.ts.map +0 -1
  239. package/dist/api/queue/messages.js +0 -549
  240. package/dist/api/queue/messages.js.map +0 -1
  241. package/dist/api/queue/queues.d.ts +0 -226
  242. package/dist/api/queue/queues.d.ts.map +0 -1
  243. package/dist/api/queue/queues.js +0 -321
  244. package/dist/api/queue/queues.js.map +0 -1
  245. package/dist/api/queue/sources.d.ts +0 -202
  246. package/dist/api/queue/sources.d.ts.map +0 -1
  247. package/dist/api/queue/sources.js +0 -202
  248. package/dist/api/queue/sources.js.map +0 -1
  249. package/dist/api/queue/types.d.ts +0 -1218
  250. package/dist/api/queue/types.d.ts.map +0 -1
  251. package/dist/api/queue/types.js +0 -1002
  252. package/dist/api/queue/types.js.map +0 -1
  253. package/dist/api/queue/util.d.ts +0 -278
  254. package/dist/api/queue/util.d.ts.map +0 -1
  255. package/dist/api/queue/util.js +0 -235
  256. package/dist/api/queue/util.js.map +0 -1
  257. package/dist/api/queue/validation.d.ts +0 -247
  258. package/dist/api/queue/validation.d.ts.map +0 -1
  259. package/dist/api/queue/validation.js +0 -513
  260. package/dist/api/queue/validation.js.map +0 -1
  261. package/dist/api/queue/websocket.d.ts +0 -168
  262. package/dist/api/queue/websocket.d.ts.map +0 -1
  263. package/dist/api/queue/websocket.js +0 -394
  264. package/dist/api/queue/websocket.js.map +0 -1
  265. package/dist/api/region/delete.d.ts +0 -62
  266. package/dist/api/region/delete.d.ts.map +0 -1
  267. package/dist/api/region/delete.js +0 -37
  268. package/dist/api/region/delete.js.map +0 -1
  269. package/dist/api/region/index.d.ts +0 -5
  270. package/dist/api/region/index.d.ts.map +0 -1
  271. package/dist/api/region/index.js +0 -5
  272. package/dist/api/region/index.js.map +0 -1
  273. package/dist/api/region/list.d.ts +0 -27
  274. package/dist/api/region/list.d.ts.map +0 -1
  275. package/dist/api/region/list.js +0 -22
  276. package/dist/api/region/list.js.map +0 -1
  277. package/dist/api/region/resources.d.ts +0 -71
  278. package/dist/api/region/resources.d.ts.map +0 -1
  279. package/dist/api/region/resources.js +0 -53
  280. package/dist/api/region/resources.js.map +0 -1
  281. package/dist/api/region/util.d.ts +0 -23
  282. package/dist/api/region/util.d.ts.map +0 -1
  283. package/dist/api/region/util.js +0 -3
  284. package/dist/api/region/util.js.map +0 -1
  285. package/dist/api/sandbox/cli-list.d.ts +0 -114
  286. package/dist/api/sandbox/cli-list.d.ts.map +0 -1
  287. package/dist/api/sandbox/cli-list.js +0 -71
  288. package/dist/api/sandbox/cli-list.js.map +0 -1
  289. package/dist/api/sandbox/create.d.ts +0 -118
  290. package/dist/api/sandbox/create.d.ts.map +0 -1
  291. package/dist/api/sandbox/create.js +0 -211
  292. package/dist/api/sandbox/create.js.map +0 -1
  293. package/dist/api/sandbox/destroy.d.ts +0 -22
  294. package/dist/api/sandbox/destroy.d.ts.map +0 -1
  295. package/dist/api/sandbox/destroy.js +0 -25
  296. package/dist/api/sandbox/destroy.js.map +0 -1
  297. package/dist/api/sandbox/disk-checkpoint.d.ts +0 -103
  298. package/dist/api/sandbox/disk-checkpoint.d.ts.map +0 -1
  299. package/dist/api/sandbox/disk-checkpoint.js +0 -104
  300. package/dist/api/sandbox/disk-checkpoint.js.map +0 -1
  301. package/dist/api/sandbox/execute.d.ts +0 -69
  302. package/dist/api/sandbox/execute.d.ts.map +0 -1
  303. package/dist/api/sandbox/execute.js +0 -103
  304. package/dist/api/sandbox/execute.js.map +0 -1
  305. package/dist/api/sandbox/execution.d.ts +0 -169
  306. package/dist/api/sandbox/execution.d.ts.map +0 -1
  307. package/dist/api/sandbox/execution.js +0 -118
  308. package/dist/api/sandbox/execution.js.map +0 -1
  309. package/dist/api/sandbox/files.d.ts +0 -261
  310. package/dist/api/sandbox/files.d.ts.map +0 -1
  311. package/dist/api/sandbox/files.js +0 -386
  312. package/dist/api/sandbox/files.js.map +0 -1
  313. package/dist/api/sandbox/get.d.ts +0 -283
  314. package/dist/api/sandbox/get.d.ts.map +0 -1
  315. package/dist/api/sandbox/get.js +0 -215
  316. package/dist/api/sandbox/get.js.map +0 -1
  317. package/dist/api/sandbox/getStatus.d.ts +0 -16
  318. package/dist/api/sandbox/getStatus.d.ts.map +0 -1
  319. package/dist/api/sandbox/getStatus.js +0 -32
  320. package/dist/api/sandbox/getStatus.js.map +0 -1
  321. package/dist/api/sandbox/index.d.ts +0 -39
  322. package/dist/api/sandbox/index.d.ts.map +0 -1
  323. package/dist/api/sandbox/index.js +0 -20
  324. package/dist/api/sandbox/index.js.map +0 -1
  325. package/dist/api/sandbox/list.d.ts +0 -293
  326. package/dist/api/sandbox/list.d.ts.map +0 -1
  327. package/dist/api/sandbox/list.js +0 -191
  328. package/dist/api/sandbox/list.js.map +0 -1
  329. package/dist/api/sandbox/resolve.d.ts +0 -82
  330. package/dist/api/sandbox/resolve.d.ts.map +0 -1
  331. package/dist/api/sandbox/resolve.js +0 -71
  332. package/dist/api/sandbox/resolve.js.map +0 -1
  333. package/dist/api/sandbox/run.d.ts +0 -28
  334. package/dist/api/sandbox/run.d.ts.map +0 -1
  335. package/dist/api/sandbox/run.js +0 -342
  336. package/dist/api/sandbox/run.js.map +0 -1
  337. package/dist/api/sandbox/runtime.d.ts +0 -83
  338. package/dist/api/sandbox/runtime.d.ts.map +0 -1
  339. package/dist/api/sandbox/runtime.js +0 -78
  340. package/dist/api/sandbox/runtime.js.map +0 -1
  341. package/dist/api/sandbox/snapshot-build.d.ts +0 -48
  342. package/dist/api/sandbox/snapshot-build.d.ts.map +0 -1
  343. package/dist/api/sandbox/snapshot-build.js +0 -74
  344. package/dist/api/sandbox/snapshot-build.js.map +0 -1
  345. package/dist/api/sandbox/snapshot.d.ts +0 -595
  346. package/dist/api/sandbox/snapshot.d.ts.map +0 -1
  347. package/dist/api/sandbox/snapshot.js +0 -598
  348. package/dist/api/sandbox/snapshot.js.map +0 -1
  349. package/dist/api/services/index.d.ts +0 -2
  350. package/dist/api/services/index.d.ts.map +0 -1
  351. package/dist/api/services/index.js +0 -2
  352. package/dist/api/services/index.js.map +0 -1
  353. package/dist/api/services/stats.d.ts +0 -263
  354. package/dist/api/services/stats.d.ts.map +0 -1
  355. package/dist/api/services/stats.js +0 -144
  356. package/dist/api/services/stats.js.map +0 -1
  357. package/dist/api/session/get.d.ts +0 -169
  358. package/dist/api/session/get.d.ts.map +0 -1
  359. package/dist/api/session/get.js +0 -56
  360. package/dist/api/session/get.js.map +0 -1
  361. package/dist/api/session/index.d.ts +0 -4
  362. package/dist/api/session/index.d.ts.map +0 -1
  363. package/dist/api/session/index.js +0 -4
  364. package/dist/api/session/index.js.map +0 -1
  365. package/dist/api/session/list.d.ts +0 -143
  366. package/dist/api/session/list.d.ts.map +0 -1
  367. package/dist/api/session/list.js +0 -91
  368. package/dist/api/session/list.js.map +0 -1
  369. package/dist/api/session/logs.d.ts +0 -40
  370. package/dist/api/session/logs.d.ts.map +0 -1
  371. package/dist/api/session/logs.js +0 -28
  372. package/dist/api/session/logs.js.map +0 -1
  373. package/dist/api/session/util.d.ts +0 -23
  374. package/dist/api/session/util.d.ts.map +0 -1
  375. package/dist/api/session/util.js +0 -3
  376. package/dist/api/session/util.js.map +0 -1
  377. package/dist/api/storage/config.d.ts +0 -99
  378. package/dist/api/storage/config.d.ts.map +0 -1
  379. package/dist/api/storage/config.js +0 -61
  380. package/dist/api/storage/config.js.map +0 -1
  381. package/dist/api/storage/index.d.ts +0 -5
  382. package/dist/api/storage/index.d.ts.map +0 -1
  383. package/dist/api/storage/index.js +0 -5
  384. package/dist/api/storage/index.js.map +0 -1
  385. package/dist/api/storage/objects.d.ts +0 -155
  386. package/dist/api/storage/objects.d.ts.map +0 -1
  387. package/dist/api/storage/objects.js +0 -142
  388. package/dist/api/storage/objects.js.map +0 -1
  389. package/dist/api/storage/types.d.ts +0 -161
  390. package/dist/api/storage/types.d.ts.map +0 -1
  391. package/dist/api/storage/types.js +0 -101
  392. package/dist/api/storage/types.js.map +0 -1
  393. package/dist/api/storage/util.d.ts +0 -48
  394. package/dist/api/storage/util.d.ts.map +0 -1
  395. package/dist/api/storage/util.js +0 -8
  396. package/dist/api/storage/util.js.map +0 -1
  397. package/dist/api/stream/get.d.ts +0 -58
  398. package/dist/api/stream/get.d.ts.map +0 -1
  399. package/dist/api/stream/get.js +0 -40
  400. package/dist/api/stream/get.js.map +0 -1
  401. package/dist/api/stream/index.d.ts +0 -4
  402. package/dist/api/stream/index.d.ts.map +0 -1
  403. package/dist/api/stream/index.js +0 -4
  404. package/dist/api/stream/index.js.map +0 -1
  405. package/dist/api/stream/list.d.ts +0 -120
  406. package/dist/api/stream/list.d.ts.map +0 -1
  407. package/dist/api/stream/list.js +0 -77
  408. package/dist/api/stream/list.js.map +0 -1
  409. package/dist/api/stream/util.d.ts +0 -23
  410. package/dist/api/stream/util.d.ts.map +0 -1
  411. package/dist/api/stream/util.js +0 -3
  412. package/dist/api/stream/util.js.map +0 -1
  413. package/dist/api/thread/delete.d.ts +0 -23
  414. package/dist/api/thread/delete.d.ts.map +0 -1
  415. package/dist/api/thread/delete.js +0 -21
  416. package/dist/api/thread/delete.js.map +0 -1
  417. package/dist/api/thread/get.d.ts +0 -36
  418. package/dist/api/thread/get.d.ts.map +0 -1
  419. package/dist/api/thread/get.js +0 -23
  420. package/dist/api/thread/get.js.map +0 -1
  421. package/dist/api/thread/index.d.ts +0 -5
  422. package/dist/api/thread/index.d.ts.map +0 -1
  423. package/dist/api/thread/index.js +0 -5
  424. package/dist/api/thread/index.js.map +0 -1
  425. package/dist/api/thread/list.d.ts +0 -69
  426. package/dist/api/thread/list.d.ts.map +0 -1
  427. package/dist/api/thread/list.js +0 -51
  428. package/dist/api/thread/list.js.map +0 -1
  429. package/dist/api/thread/util.d.ts +0 -23
  430. package/dist/api/thread/util.d.ts.map +0 -1
  431. package/dist/api/thread/util.js +0 -3
  432. package/dist/api/thread/util.js.map +0 -1
  433. package/dist/api/user/index.d.ts +0 -2
  434. package/dist/api/user/index.d.ts.map +0 -1
  435. package/dist/api/user/index.js +0 -2
  436. package/dist/api/user/index.js.map +0 -1
  437. package/dist/api/user/util.d.ts +0 -23
  438. package/dist/api/user/util.d.ts.map +0 -1
  439. package/dist/api/user/util.js +0 -3
  440. package/dist/api/user/util.js.map +0 -1
  441. package/dist/api/webhook/deliveries.d.ts +0 -94
  442. package/dist/api/webhook/deliveries.d.ts.map +0 -1
  443. package/dist/api/webhook/deliveries.js +0 -79
  444. package/dist/api/webhook/deliveries.js.map +0 -1
  445. package/dist/api/webhook/destinations.d.ts +0 -136
  446. package/dist/api/webhook/destinations.d.ts.map +0 -1
  447. package/dist/api/webhook/destinations.js +0 -137
  448. package/dist/api/webhook/destinations.js.map +0 -1
  449. package/dist/api/webhook/index.d.ts +0 -41
  450. package/dist/api/webhook/index.d.ts.map +0 -1
  451. package/dist/api/webhook/index.js +0 -59
  452. package/dist/api/webhook/index.js.map +0 -1
  453. package/dist/api/webhook/receipts.d.ts +0 -77
  454. package/dist/api/webhook/receipts.d.ts.map +0 -1
  455. package/dist/api/webhook/receipts.js +0 -78
  456. package/dist/api/webhook/receipts.js.map +0 -1
  457. package/dist/api/webhook/types.d.ts +0 -249
  458. package/dist/api/webhook/types.d.ts.map +0 -1
  459. package/dist/api/webhook/types.js +0 -221
  460. package/dist/api/webhook/types.js.map +0 -1
  461. package/dist/api/webhook/util.d.ts +0 -202
  462. package/dist/api/webhook/util.d.ts.map +0 -1
  463. package/dist/api/webhook/util.js +0 -201
  464. package/dist/api/webhook/util.js.map +0 -1
  465. package/dist/api/webhook/webhooks.d.ts +0 -146
  466. package/dist/api/webhook/webhooks.d.ts.map +0 -1
  467. package/dist/api/webhook/webhooks.js +0 -165
  468. package/dist/api/webhook/webhooks.js.map +0 -1
  469. package/src/api/api-example.md +0 -164
  470. package/src/api/apikey/create.ts +0 -41
  471. package/src/api/apikey/delete.ts +0 -30
  472. package/src/api/apikey/get.ts +0 -48
  473. package/src/api/apikey/index.ts +0 -5
  474. package/src/api/apikey/list.ts +0 -64
  475. package/src/api/apikey/util.ts +0 -3
  476. package/src/api/db/index.ts +0 -27
  477. package/src/api/db/logs.ts +0 -75
  478. package/src/api/db/query.ts +0 -67
  479. package/src/api/db/tables.ts +0 -92
  480. package/src/api/db/util.ts +0 -9
  481. package/src/api/eval/get.ts +0 -33
  482. package/src/api/eval/index.ts +0 -28
  483. package/src/api/eval/list.ts +0 -49
  484. package/src/api/eval/run-get.ts +0 -39
  485. package/src/api/eval/run-list.ts +0 -59
  486. package/src/api/machine/index.ts +0 -2
  487. package/src/api/machine/machine.ts +0 -160
  488. package/src/api/machine/util.ts +0 -5
  489. package/src/api/org/index.ts +0 -6
  490. package/src/api/org/list.ts +0 -28
  491. package/src/api/org/resources.ts +0 -135
  492. package/src/api/org/util.ts +0 -4
  493. package/src/api/project/agent.ts +0 -86
  494. package/src/api/project/create.ts +0 -47
  495. package/src/api/project/delete.ts +0 -25
  496. package/src/api/project/deploy.ts +0 -458
  497. package/src/api/project/deployment.ts +0 -195
  498. package/src/api/project/env-delete.ts +0 -45
  499. package/src/api/project/env-update.ts +0 -55
  500. package/src/api/project/exists.ts +0 -58
  501. package/src/api/project/hostname.ts +0 -73
  502. package/src/api/project/index.ts +0 -13
  503. package/src/api/project/update-region.ts +0 -44
  504. package/src/api/project/util.ts +0 -8
  505. package/src/api/queue/analytics.ts +0 -311
  506. package/src/api/queue/destinations.ts +0 -259
  507. package/src/api/queue/dlq.ts +0 -243
  508. package/src/api/queue/index.ts +0 -308
  509. package/src/api/queue/messages.ts +0 -784
  510. package/src/api/queue/queues.ts +0 -460
  511. package/src/api/queue/sources.ts +0 -294
  512. package/src/api/queue/types.ts +0 -1325
  513. package/src/api/queue/util.ts +0 -278
  514. package/src/api/queue/validation.ts +0 -560
  515. package/src/api/queue/websocket.ts +0 -514
  516. package/src/api/region/delete.ts +0 -57
  517. package/src/api/region/index.ts +0 -4
  518. package/src/api/region/list.ts +0 -32
  519. package/src/api/region/resources.ts +0 -69
  520. package/src/api/region/util.ts +0 -3
  521. package/src/api/sandbox/cli-list.ts +0 -127
  522. package/src/api/sandbox/create.ts +0 -256
  523. package/src/api/sandbox/destroy.ts +0 -41
  524. package/src/api/sandbox/disk-checkpoint.ts +0 -179
  525. package/src/api/sandbox/execute.ts +0 -132
  526. package/src/api/sandbox/execution.ts +0 -183
  527. package/src/api/sandbox/files.ts +0 -596
  528. package/src/api/sandbox/get.ts +0 -249
  529. package/src/api/sandbox/getStatus.ts +0 -54
  530. package/src/api/sandbox/index.ts +0 -211
  531. package/src/api/sandbox/list.ts +0 -224
  532. package/src/api/sandbox/resolve.ts +0 -98
  533. package/src/api/sandbox/run.ts +0 -439
  534. package/src/api/sandbox/runtime.ts +0 -100
  535. package/src/api/sandbox/snapshot-build.ts +0 -98
  536. package/src/api/sandbox/snapshot.ts +0 -781
  537. package/src/api/services/index.ts +0 -1
  538. package/src/api/services/stats.ts +0 -213
  539. package/src/api/session/get.ts +0 -106
  540. package/src/api/session/index.ts +0 -3
  541. package/src/api/session/list.ts +0 -136
  542. package/src/api/session/logs.ts +0 -47
  543. package/src/api/session/util.ts +0 -3
  544. package/src/api/storage/config.ts +0 -103
  545. package/src/api/storage/index.ts +0 -4
  546. package/src/api/storage/objects.ts +0 -240
  547. package/src/api/storage/types.ts +0 -134
  548. package/src/api/storage/util.ts +0 -10
  549. package/src/api/stream/get.ts +0 -51
  550. package/src/api/stream/index.ts +0 -3
  551. package/src/api/stream/list.ts +0 -127
  552. package/src/api/stream/util.ts +0 -3
  553. package/src/api/thread/delete.ts +0 -31
  554. package/src/api/thread/get.ts +0 -34
  555. package/src/api/thread/index.ts +0 -4
  556. package/src/api/thread/list.ts +0 -76
  557. package/src/api/thread/util.ts +0 -3
  558. package/src/api/user/index.ts +0 -1
  559. package/src/api/user/util.ts +0 -3
  560. package/src/api/webhook/deliveries.ts +0 -129
  561. package/src/api/webhook/destinations.ts +0 -224
  562. package/src/api/webhook/index.ts +0 -133
  563. package/src/api/webhook/receipts.ts +0 -124
  564. package/src/api/webhook/types.ts +0 -309
  565. package/src/api/webhook/util.ts +0 -237
  566. package/src/api/webhook/webhooks.ts +0 -260
package/dist/api/api.js CHANGED
@@ -1,638 +1,2 @@
1
- /**
2
- * API Client for Agentuity Platform
3
- *
4
- * Handles HTTP requests to the API with automatic error parsing and User-Agent headers.
5
- */
6
- import { z } from 'zod';
7
- import { StructuredError } from '@agentuity/core';
8
- import pkg from '../../package.json' with { type: 'json' };
9
- // Cache the package data
10
- let cachedPackage = null;
11
- export function getPackage() {
12
- if (!cachedPackage) {
13
- cachedPackage = pkg;
14
- }
15
- return cachedPackage;
16
- }
17
- function getVersion() {
18
- return process.env.AGENTUITY_CLI_VERSION || getPackage().version || 'dev';
19
- }
20
- function getUserAgent() {
21
- return `Agentuity SDK/${getVersion()}`;
22
- }
23
- export const ZodIssuesSchema = z.array(z.object({
24
- code: z.string(),
25
- input: z.unknown().optional(),
26
- path: z.array(z.union([z.string(), z.number()])),
27
- message: z.string(),
28
- }));
29
- const toIssues = (issues) => {
30
- return issues.map((issue) => ({
31
- code: issue.code,
32
- input: issue.input,
33
- path: issue.path.map((x) => (typeof x === 'number' ? x : String(x))),
34
- message: issue.message,
35
- }));
36
- };
37
- export const APIErrorSchema = z.object({
38
- success: z.boolean(),
39
- code: z.string().optional(),
40
- message: z.string().optional(),
41
- error: z
42
- .union([
43
- z.string(),
44
- z.object({
45
- name: z.string().optional(),
46
- issues: ZodIssuesSchema.optional(),
47
- }),
48
- ])
49
- .optional(),
50
- details: z.record(z.string(), z.unknown()).optional(),
51
- });
52
- export const APIError = StructuredError('APIErrorResponse')();
53
- export const ValidationInputError = StructuredError('ValidationInputError', 'There was an error validating the API input data.')();
54
- export const ValidationOutputError = StructuredError('ValidationOutputError', 'There was an unexpected error validating the API response data.')();
55
- export const UpgradeRequiredError = StructuredError('UpgradeRequiredError', 'Upgrade required to continue. Please run `agentuity upgrade` or see https://agentuity.dev/Get-Started/installation to download the latest version.')();
56
- export const MaxRetriesError = StructuredError('MaxRetriesError', 'Max Retries attempted and continued failures exhausted.');
57
- export const MisdirectedRequestError = StructuredError('MisdirectedRequestError', 'The request was sent to the wrong regional server.')();
58
- export const PaymentRequiredError = StructuredError('PaymentRequiredError', 'This action requires a paid plan. Please upgrade your account to continue.')();
59
- export class APIClient {
60
- #baseUrl;
61
- #apiKey;
62
- #config;
63
- #logger;
64
- constructor(baseUrl, logger, apiKeyOrConfig, config) {
65
- this.#baseUrl = baseUrl;
66
- this.#logger = logger;
67
- // Detect if third parameter is apiKey (string) or config (object)
68
- if (typeof apiKeyOrConfig === 'string') {
69
- this.#apiKey = apiKeyOrConfig;
70
- this.#config = config;
71
- }
72
- else {
73
- this.#apiKey = undefined;
74
- this.#config = apiKeyOrConfig;
75
- }
76
- if (!this.#apiKey && process.env.AGENTUITY_SDK_KEY) {
77
- this.#apiKey = process.env.AGENTUITY_SDK_KEY;
78
- }
79
- }
80
- /**
81
- * GET request
82
- */
83
- async get(endpoint, responseSchema, signal, extraHeaders) {
84
- return this.request('GET', endpoint, responseSchema, undefined, undefined, signal, extraHeaders);
85
- }
86
- /**
87
- * POST request with optional body
88
- */
89
- async post(endpoint, body, responseSchema, bodySchema, signal, extraHeaders) {
90
- return this.request('POST', endpoint, responseSchema, body, bodySchema, signal, extraHeaders);
91
- }
92
- /**
93
- * PUT request with optional body
94
- */
95
- async put(endpoint, body, responseSchema, bodySchema, signal, extraHeaders) {
96
- return this.request('PUT', endpoint, responseSchema, body, bodySchema, signal, extraHeaders);
97
- }
98
- /**
99
- * DELETE request
100
- */
101
- async delete(endpoint, responseSchema, signal, extraHeaders) {
102
- return this.request('DELETE', endpoint, responseSchema, undefined, undefined, signal, extraHeaders);
103
- }
104
- /**
105
- * PATCH request with optional body
106
- */
107
- async patch(endpoint, body, responseSchema, bodySchema, signal, extraHeaders) {
108
- return this.request('PATCH', endpoint, responseSchema, body, bodySchema, signal, extraHeaders);
109
- }
110
- /**
111
- * Raw GET request that returns the Response object directly.
112
- * Useful for streaming responses where you need access to the body stream.
113
- */
114
- async rawGet(endpoint, signal, extraHeaders) {
115
- return this.#makeRequest('GET', endpoint, undefined, signal, undefined, extraHeaders);
116
- }
117
- /**
118
- * Raw POST request that returns the Response object directly.
119
- * Useful for binary uploads where you need to pass raw body data.
120
- */
121
- async rawPost(endpoint, body, contentType, signal) {
122
- return this.#makeRequest('POST', endpoint, body, signal, contentType);
123
- }
124
- /**
125
- * Raw PUT request that returns the Response object directly.
126
- * Useful for binary uploads where you need to pass raw body data.
127
- */
128
- async rawPut(endpoint, body, contentType, signal, extraHeaders) {
129
- return this.#makeRequest('PUT', endpoint, body, signal, contentType, extraHeaders);
130
- }
131
- /**
132
- * Generic request method (prefer HTTP verb methods: get, post, put, delete, patch)
133
- */
134
- async request(method, endpoint, responseSchema, body, bodySchema, signal, extraHeaders) {
135
- // Validate request body if schema provided
136
- if (body !== undefined && bodySchema) {
137
- const validationResult = bodySchema.safeParse(body);
138
- if (!validationResult.success) {
139
- throw new ValidationInputError({
140
- url: endpoint,
141
- issues: toIssues(validationResult.error.issues),
142
- });
143
- }
144
- }
145
- const response = await this.#makeRequest(method, endpoint, body, signal, undefined, extraHeaders);
146
- // Handle empty responses (204 or zero-length body)
147
- let data;
148
- if (response.status === 204 || response.headers.get('content-length') === '0') {
149
- data = null;
150
- }
151
- else {
152
- const text = await response.text();
153
- if (text === '') {
154
- data = null;
155
- }
156
- else {
157
- const contentType = response.headers.get('content-type');
158
- if (contentType?.includes('application/json')) {
159
- data = JSON.parse(text);
160
- }
161
- else {
162
- data = text;
163
- }
164
- }
165
- }
166
- if (responseSchema) {
167
- // Validate response
168
- const validationResult = responseSchema.safeParse(data);
169
- if (!validationResult.success) {
170
- throw new ValidationOutputError({
171
- url: endpoint,
172
- issues: toIssues(validationResult.error.issues),
173
- sessionId: response.headers.get('x-session-id'),
174
- });
175
- }
176
- return validationResult.data;
177
- }
178
- return undefined;
179
- }
180
- async #makeRequest(method, endpoint, body, signal, contentType, extraHeaders) {
181
- this.#logger.trace('sending %s to %s%s', method, this.#baseUrl, endpoint);
182
- const maxRetries = this.#config?.maxRetries ?? 3;
183
- const baseDelayMs = this.#config?.retryDelayMs ?? 100;
184
- const serviceUnavailableTimeoutMs = this.#config?.serviceUnavailableTimeoutMs ?? 30_000;
185
- // Track when we first see a 502/503 so we can retry for up to the timeout
186
- let serviceUnavailableStart = null;
187
- const url = `${this.#baseUrl}${endpoint}`;
188
- const headers = {
189
- 'Content-Type': contentType ?? 'application/json',
190
- };
191
- // Only set Accept header for JSON requests (not binary uploads)
192
- if (!contentType || contentType === 'application/json') {
193
- headers['Accept'] = 'application/json';
194
- }
195
- if (this.#config?.userAgent) {
196
- headers['User-Agent'] = this.#config.userAgent;
197
- }
198
- else {
199
- headers['User-Agent'] = getUserAgent();
200
- }
201
- if (this.#apiKey) {
202
- headers['Authorization'] = `Bearer ${this.#apiKey}`;
203
- }
204
- if (this.#config?.headers) {
205
- Object.keys(this.#config.headers).forEach((key) => {
206
- const value = this.#config?.headers?.[key];
207
- if (value !== undefined) {
208
- headers[key] = value;
209
- }
210
- });
211
- }
212
- // Apply per-request extra headers (e.g., x-agentuity-orgid for CLI auth)
213
- if (extraHeaders) {
214
- Object.keys(extraHeaders).forEach((key) => {
215
- const value = extraHeaders[key];
216
- if (value !== undefined) {
217
- headers[key] = value;
218
- }
219
- });
220
- }
221
- const canRetry = !(body instanceof ReadableStream); // we cannot safely retry a ReadableStream as body
222
- let attempt = 0;
223
- while (true) {
224
- try {
225
- let response;
226
- try {
227
- let requestBody;
228
- if (body !== undefined) {
229
- if (contentType && contentType !== 'application/json') {
230
- requestBody = body;
231
- }
232
- else {
233
- requestBody = JSON.stringify(body);
234
- }
235
- }
236
- response = await fetch(url, {
237
- method,
238
- headers,
239
- body: requestBody,
240
- signal,
241
- });
242
- }
243
- catch (ex) {
244
- this.#logger.debug('fetch returned an error trying to access: %s. %s', url, ex);
245
- const _ex = ex;
246
- let retryable = false;
247
- // Check for retryable network errors
248
- if (_ex.code === 'ConnectionRefused' || _ex.code === 'ECONNREFUSED') {
249
- retryable = true;
250
- }
251
- else if (_ex.name === 'TypeError' || ex instanceof TypeError) {
252
- // TypeError from fetch typically indicates network issues
253
- retryable = true;
254
- }
255
- if (retryable) {
256
- response = new Response(null, { status: 503 });
257
- }
258
- else {
259
- throw new APIError({
260
- url,
261
- status: 0,
262
- cause: ex,
263
- });
264
- }
265
- }
266
- const sessionId = response.headers.get('x-session-id');
267
- // Handle 421 Misdirected Request - the resource is in a different region
268
- // We need to retry against the correct regional Catalyst
269
- // Only handle this for Catalyst URLs (not the main API)
270
- if (response.status === 421 && this.#isCatalystUrl()) {
271
- const targetRegion = response.headers.get('x-agentuity-region');
272
- if (targetRegion && canRetry) {
273
- const regionalUrl = this.#buildRegionalUrl(targetRegion, endpoint);
274
- this.#logger.debug(`Got 421 Misdirected Request, resource is in region ${targetRegion}, retrying against ${regionalUrl} (sessionId: ${sessionId ?? null})`);
275
- // Retry the request against the correct regional Catalyst
276
- let requestBody;
277
- if (body !== undefined) {
278
- if (contentType && contentType !== 'application/json') {
279
- requestBody = body;
280
- }
281
- else {
282
- requestBody = JSON.stringify(body);
283
- }
284
- }
285
- const regionalResponse = await fetch(regionalUrl, {
286
- method,
287
- headers,
288
- body: requestBody,
289
- signal,
290
- });
291
- // If the regional request also fails with 421, throw MisdirectedRequestError
292
- if (regionalResponse.status === 421) {
293
- throw new MisdirectedRequestError({
294
- url: regionalUrl,
295
- region: targetRegion,
296
- sessionId: regionalResponse.headers.get('x-session-id'),
297
- });
298
- }
299
- // For all other responses (success or error), assign to response
300
- // and let the normal flow handle it (error handling, validation, etc.)
301
- response = regionalResponse;
302
- }
303
- else {
304
- // No region header or can't retry - throw error
305
- throw new MisdirectedRequestError({
306
- url,
307
- region: targetRegion ?? 'unknown',
308
- sessionId,
309
- });
310
- }
311
- }
312
- // 502/503 indicate the service is restarting (hot-swap) — retry
313
- // for up to serviceUnavailableTimeoutMs (default 30s) with a
314
- // slower backoff (1s base) so we survive typical restart windows.
315
- const isServiceUnavailable = response.status === 502 || response.status === 503;
316
- if (isServiceUnavailable && canRetry) {
317
- if (serviceUnavailableStart === null) {
318
- serviceUnavailableStart = Date.now();
319
- }
320
- const elapsed = Date.now() - serviceUnavailableStart;
321
- if (elapsed < serviceUnavailableTimeoutMs) {
322
- // Use 1s base delay with exponential backoff, capped at 5s
323
- const delayMs = Math.min(this.#getRetryDelay(attempt, 1000), 5000);
324
- this.#logger.debug(`Got ${response.status} sending to ${url}, service unavailable for ${Math.round(elapsed / 1000)}s, retrying (will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`);
325
- await this.#sleep(delayMs);
326
- attempt++;
327
- continue;
328
- }
329
- }
330
- // Check if we should retry on specific status codes (409, 501)
331
- const retryableStatuses = [409, 501];
332
- if (canRetry && retryableStatuses.includes(response.status) && attempt < maxRetries) {
333
- let delayMs = this.#getRetryDelay(attempt, baseDelayMs);
334
- // For 409, check for rate limit headers
335
- if (response.status === 409) {
336
- const rateLimitDelay = this.#getRateLimitDelay(response);
337
- if (rateLimitDelay !== null) {
338
- delayMs = rateLimitDelay;
339
- this.#logger.debug(`Got 409 sending to ${url} with rate limit headers, waiting ${delayMs}ms (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`);
340
- }
341
- else {
342
- this.#logger.debug(`Got 409 sending to ${url}, retrying with backoff ${delayMs}ms (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`);
343
- }
344
- }
345
- else {
346
- this.#logger.debug(`Got ${response.status} sending to ${url}, retrying (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`);
347
- }
348
- await this.#sleep(delayMs);
349
- this.#logger.debug(`after sleep for ${url}, sessionId: ${sessionId ?? null}`);
350
- attempt++;
351
- continue;
352
- }
353
- // Handle error responses
354
- if (!response.ok) {
355
- const responseBody = await response.text();
356
- const contentType = response.headers.get('content-type');
357
- let errorData;
358
- // Only attempt to parse as JSON if the content type indicates JSON
359
- const isJsonResponse = contentType?.includes('application/json') || contentType?.includes('+json');
360
- if (isJsonResponse) {
361
- try {
362
- errorData = APIErrorSchema.parse(JSON.parse(responseBody));
363
- }
364
- catch (parseEx) {
365
- // Log at debug level since this is a contract violation from the server
366
- this.#logger.debug('Failed to parse JSON error response from API: %s (url: %s, sessionId: %s)', parseEx, url, sessionId);
367
- }
368
- }
369
- else {
370
- // Non-JSON response (e.g., HTML error page), skip structured error parsing
371
- this.#logger.debug('Received non-JSON error response (content-type: %s), skipping structured error parsing (url: %s, sessionId: %s)', contentType ?? 'unknown', url, sessionId);
372
- }
373
- // Sanitize headers to avoid leaking API keys
374
- const sanitizedHeaders = { ...headers };
375
- for (const key in sanitizedHeaders) {
376
- const lk = key.toLowerCase();
377
- if (lk === 'authorization' ||
378
- lk === 'x-api-key' ||
379
- lk.includes('secret') ||
380
- lk.includes('key') ||
381
- lk.includes('token')) {
382
- sanitizedHeaders[key] = 'REDACTED';
383
- }
384
- }
385
- this.#logger.debug('API Error Details:');
386
- this.#logger.debug(' URL:', url);
387
- this.#logger.debug(' Method:', method);
388
- this.#logger.debug(' Status:', response.status, response.statusText);
389
- this.#logger.debug(' Headers:', JSON.stringify(sanitizedHeaders, null, 2));
390
- this.#logger.debug(' Response:', responseBody);
391
- // HTTP 426 always forces upgrade (cannot be skipped - emergency upgrade path)
392
- if (response.status === 426) {
393
- throw new UpgradeRequiredError({ sessionId });
394
- }
395
- // HTTP 402 Payment Required - user needs to upgrade their plan
396
- if (response.status === 402) {
397
- const upgradeUrl = response.headers.get('x-upgrade-url');
398
- throw new PaymentRequiredError({
399
- url,
400
- sessionId,
401
- upgradeUrl: upgradeUrl ?? undefined,
402
- });
403
- }
404
- // Check for UPGRADE_REQUIRED error
405
- if (errorData?.code === 'UPGRADE_REQUIRED') {
406
- // Skip version check if configured
407
- if (this.#config?.skipVersionCheck) {
408
- this.#logger.debug('Skipping version check (configured to skip)');
409
- // Request is still rejected, but throw UpgradeRequiredError so callers
410
- // can detect it and handle UI behavior (e.g., suppress banner) based on skip flag
411
- throw new UpgradeRequiredError({ sessionId });
412
- }
413
- throw new UpgradeRequiredError({ sessionId });
414
- }
415
- // Handle Zod validation errors from the API
416
- if (typeof errorData?.error === 'object' &&
417
- errorData?.error?.name === 'ZodError' &&
418
- errorData.error.issues) {
419
- throw new ValidationOutputError({
420
- url,
421
- issues: errorData.error.issues,
422
- sessionId,
423
- });
424
- }
425
- // Throw with message from API if available
426
- if (errorData?.message) {
427
- throw new APIError({
428
- url,
429
- status: response.status,
430
- message: typeof errorData.error === 'string'
431
- ? errorData.error
432
- : (errorData.message ??
433
- 'The API encountered an unexpected error attempting to reach the service.'),
434
- sessionId,
435
- });
436
- }
437
- // Provide status-aware fallback messages when no structured error data is available
438
- throw new APIError({
439
- message: this.#getStatusAwareErrorMessage(response.status, isJsonResponse ?? false),
440
- url: url,
441
- status: response.status,
442
- sessionId,
443
- });
444
- }
445
- this.#logger.debug('%s succeeded with status: %d', url, response.status);
446
- // Successful response; handle empty bodies (e.g., 204 No Content)
447
- if (response.status === 204 || response.headers.get('content-length') === '0') {
448
- return new Response(null, { status: 204 });
449
- }
450
- return response;
451
- }
452
- catch (error) {
453
- this.#logger.debug('error sending to %s: %s', url, error);
454
- // Check if it's a retryable connection error
455
- const isRetryable = this.#isRetryableError(error);
456
- if (isRetryable && attempt < maxRetries) {
457
- this.#logger.debug(`Connection error, retrying (attempt ${attempt + 1}/${maxRetries + 1}):`, error);
458
- await this.#sleep(this.#getRetryDelay(attempt, baseDelayMs));
459
- attempt++;
460
- continue;
461
- }
462
- throw error;
463
- }
464
- }
465
- }
466
- #isRetryableError(error) {
467
- if (error && typeof error === 'object') {
468
- const err = error;
469
- // Retryable connection errors
470
- return (err.code === 'ECONNRESET' ||
471
- err.code === 'ETIMEDOUT' ||
472
- err.code === 'ECONNREFUSED' ||
473
- err.code === 'ENOTFOUND');
474
- }
475
- return false;
476
- }
477
- #getRetryDelay(attempt, baseDelayMs) {
478
- // Exponential backoff with jitter: delay = base * 2^attempt * (0.5 + random(0, 0.5))
479
- const exponentialDelay = baseDelayMs * Math.pow(2, attempt);
480
- const jitter = 0.5 + Math.random() * 0.5;
481
- return Math.floor(exponentialDelay * jitter);
482
- }
483
- #sleep(ms) {
484
- return new Promise((resolve) => setTimeout(resolve, ms));
485
- }
486
- /**
487
- * Check if the base URL is a Catalyst URL.
488
- * We only handle 421 Misdirected Request for Catalyst URLs, not the main API.
489
- */
490
- #isCatalystUrl() {
491
- try {
492
- const url = new URL(this.#baseUrl);
493
- return url.hostname.includes('catalyst');
494
- }
495
- catch {
496
- return false;
497
- }
498
- }
499
- /**
500
- * Build a URL for a specific regional Catalyst instance.
501
- * Used when retrying requests that received 421 Misdirected Request.
502
- */
503
- #buildRegionalUrl(region, endpoint) {
504
- // Determine the domain suffix based on region
505
- const isLocal = region === 'local' || region === 'l';
506
- const domainSuffix = isLocal ? 'agentuity.io' : 'agentuity.cloud';
507
- // Build the regional Catalyst URL
508
- // For local: https://catalyst.agentuity.io
509
- // For production: https://catalyst-{region}.agentuity.cloud
510
- const baseUrl = isLocal
511
- ? `https://catalyst.${domainSuffix}`
512
- : `https://catalyst-${region}.${domainSuffix}`;
513
- return `${baseUrl}${endpoint}`;
514
- }
515
- #getRateLimitDelay(response) {
516
- // Check for Retry-After header (standard HTTP)
517
- const retryAfter = response.headers.get('Retry-After');
518
- if (retryAfter) {
519
- // Can be either seconds or HTTP date
520
- const seconds = parseInt(retryAfter, 10);
521
- if (!isNaN(seconds)) {
522
- return seconds * 1000; // Convert to milliseconds
523
- }
524
- // Try parsing as HTTP date
525
- const retryDate = new Date(retryAfter);
526
- if (!isNaN(retryDate.getTime())) {
527
- const delayMs = retryDate.getTime() - Date.now();
528
- return Math.max(0, delayMs);
529
- }
530
- }
531
- // Check for X-RateLimit-Reset (Unix timestamp in seconds)
532
- const rateLimitReset = response.headers.get('X-RateLimit-Reset');
533
- if (rateLimitReset) {
534
- const resetTime = parseInt(rateLimitReset, 10);
535
- if (!isNaN(resetTime)) {
536
- const delayMs = resetTime * 1000 - Date.now();
537
- return Math.max(0, delayMs);
538
- }
539
- }
540
- // Check for X-RateLimit-Retry-After (seconds)
541
- const rateLimitRetryAfter = response.headers.get('X-RateLimit-Retry-After');
542
- if (rateLimitRetryAfter) {
543
- const seconds = parseInt(rateLimitRetryAfter, 10);
544
- if (!isNaN(seconds)) {
545
- return seconds * 1000;
546
- }
547
- }
548
- return null;
549
- }
550
- #getStatusAwareErrorMessage(status, isJsonResponse) {
551
- // Provide helpful, status-specific error messages
552
- switch (status) {
553
- case 400:
554
- return 'The API request was invalid (HTTP 400). Please check your request parameters.';
555
- case 401:
556
- return 'Authentication failed (HTTP 401). Please check your credentials or try logging in again.';
557
- case 402:
558
- return 'This action requires a paid plan. Please upgrade your account at https://app.agentuity.com/billing to continue.';
559
- case 403:
560
- return 'Access denied (HTTP 403). You do not have permission to perform this action.';
561
- case 404:
562
- return isJsonResponse
563
- ? 'The requested resource was not found (HTTP 404).'
564
- : 'The API endpoint was not found (HTTP 404). Please verify your API URL configuration is correct.';
565
- case 409:
566
- return 'A conflict occurred (HTTP 409). The resource may already exist or be in use.';
567
- case 429:
568
- return 'Too many requests (HTTP 429). Please wait a moment and try again.';
569
- case 500:
570
- return 'The API server encountered an internal error (HTTP 500). Please try again later.';
571
- case 502:
572
- return 'The API service is temporarily unavailable (HTTP 502). Please try again later.';
573
- case 503:
574
- return 'The API service is currently unavailable (HTTP 503). Please try again later.';
575
- case 504:
576
- return 'The API request timed out (HTTP 504). Please try again later.';
577
- default:
578
- return `The API returned an unexpected error (HTTP ${status}).`;
579
- }
580
- }
581
- }
582
- export function getAPIBaseURL(region, overrides) {
583
- if (process.env.AGENTUITY_API_URL) {
584
- return process.env.AGENTUITY_API_URL;
585
- }
586
- if (overrides?.api_url) {
587
- return overrides.api_url;
588
- }
589
- if (region === 'local') {
590
- return 'https://api.agentuity.io';
591
- }
592
- return 'https://api.agentuity.com';
593
- }
594
- export function getAppBaseURL(region, overrides) {
595
- if (process.env.AGENTUITY_APP_URL) {
596
- return process.env.AGENTUITY_APP_URL;
597
- }
598
- if (overrides?.app_url) {
599
- return overrides.app_url;
600
- }
601
- if (region === 'local') {
602
- return 'https://app.agentuity.io';
603
- }
604
- return 'https://app.agentuity.com';
605
- }
606
- export const APIResponseSchema = (dataSchema) => z.discriminatedUnion('success', [
607
- z.object({
608
- success: z.literal(false),
609
- message: z.string().describe('the error message'),
610
- code: z.string().optional().describe('machine-readable error code'),
611
- }),
612
- z.object({
613
- success: z.literal(true),
614
- data: dataSchema,
615
- }),
616
- ]);
617
- export const APIResponseSchemaOptionalData = (dataSchema) => z.discriminatedUnion('success', [
618
- z.object({
619
- success: z.literal(false),
620
- message: z.string().describe('the error message'),
621
- code: z.string().optional().describe('machine-readable error code'),
622
- }),
623
- z.object({
624
- success: z.literal(true),
625
- data: dataSchema.optional(),
626
- }),
627
- ]);
628
- export const APIResponseSchemaNoData = () => z.discriminatedUnion('success', [
629
- z.object({
630
- success: z.literal(false),
631
- message: z.string().describe('the error message'),
632
- code: z.string().optional().describe('machine-readable error code'),
633
- }),
634
- z.object({
635
- success: z.literal(true),
636
- }),
637
- ]);
1
+ export * from '@agentuity/core';
638
2
  //# sourceMappingURL=api.js.map