@aexhq/sdk 0.46.5-canary → 0.50.0

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 (337) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +38 -0
  3. package/README.md +23 -31
  4. package/dist/client/aex.d.ts +33 -0
  5. package/dist/client/aex.js +98 -0
  6. package/dist/client/aex.js.map +1 -0
  7. package/dist/client/credentials.d.ts +25 -0
  8. package/dist/client/credentials.js +97 -0
  9. package/dist/client/credentials.js.map +1 -0
  10. package/dist/client/routing.d.ts +7 -0
  11. package/dist/client/routing.js +29 -0
  12. package/dist/client/routing.js.map +1 -0
  13. package/dist/downloads/download.d.ts +25 -0
  14. package/dist/downloads/download.js +53 -0
  15. package/dist/downloads/download.js.map +1 -0
  16. package/dist/generated/errors.d.ts +12 -0
  17. package/dist/generated/errors.js +81 -0
  18. package/dist/generated/errors.js.map +1 -0
  19. package/dist/generated/resources.d.ts +730 -0
  20. package/dist/generated/resources.js +606 -0
  21. package/dist/generated/resources.js.map +1 -0
  22. package/dist/generated/routes.d.ts +42 -0
  23. package/dist/generated/routes.js +2101 -0
  24. package/dist/generated/routes.js.map +1 -0
  25. package/dist/index.d.ts +20 -50
  26. package/dist/index.js +11 -62
  27. package/dist/index.js.map +1 -1
  28. package/dist/observations/stream.d.ts +1 -0
  29. package/dist/observations/stream.js +18 -0
  30. package/dist/observations/stream.js.map +1 -0
  31. package/dist/transport/errors.d.ts +60 -0
  32. package/dist/transport/errors.js +107 -0
  33. package/dist/transport/errors.js.map +1 -0
  34. package/dist/transport/pagination.d.ts +8 -0
  35. package/dist/transport/pagination.js +34 -0
  36. package/dist/transport/pagination.js.map +1 -0
  37. package/dist/transport/retry.d.ts +21 -0
  38. package/dist/transport/retry.js +37 -0
  39. package/dist/transport/retry.js.map +1 -0
  40. package/dist/transport/transport.d.ts +25 -0
  41. package/dist/transport/transport.js +28 -0
  42. package/dist/transport/transport.js.map +1 -0
  43. package/package.json +63 -30
  44. package/dist/_contracts/account-operations.d.ts +0 -101
  45. package/dist/_contracts/account-operations.js +0 -242
  46. package/dist/_contracts/account-types.d.ts +0 -461
  47. package/dist/_contracts/account-types.js +0 -1
  48. package/dist/_contracts/api-key.d.ts +0 -61
  49. package/dist/_contracts/api-key.js +0 -101
  50. package/dist/_contracts/api-routes.d.ts +0 -20
  51. package/dist/_contracts/api-routes.js +0 -109
  52. package/dist/_contracts/archive-limits.d.ts +0 -3
  53. package/dist/_contracts/archive-limits.js +0 -23
  54. package/dist/_contracts/asset-authoring.d.ts +0 -22
  55. package/dist/_contracts/asset-authoring.js +0 -106
  56. package/dist/_contracts/asset-bundle.d.ts +0 -64
  57. package/dist/_contracts/asset-bundle.js +0 -263
  58. package/dist/_contracts/asset-upload-helper.d.ts +0 -31
  59. package/dist/_contracts/asset-upload-helper.js +0 -84
  60. package/dist/_contracts/billing-admission.d.ts +0 -29
  61. package/dist/_contracts/billing-admission.js +0 -28
  62. package/dist/_contracts/bundle-manifest.d.ts +0 -89
  63. package/dist/_contracts/bundle-manifest.js +0 -158
  64. package/dist/_contracts/canonical-sha256.d.ts +0 -8
  65. package/dist/_contracts/canonical-sha256.js +0 -8
  66. package/dist/_contracts/connection-ticket.d.ts +0 -22
  67. package/dist/_contracts/connection-ticket.js +0 -54
  68. package/dist/_contracts/continuation-event.d.ts +0 -31
  69. package/dist/_contracts/continuation-event.js +0 -6
  70. package/dist/_contracts/contract-parse-error.d.ts +0 -12
  71. package/dist/_contracts/contract-parse-error.js +0 -51
  72. package/dist/_contracts/error-codes.d.ts +0 -26
  73. package/dist/_contracts/error-codes.js +0 -116
  74. package/dist/_contracts/error-factory.d.ts +0 -32
  75. package/dist/_contracts/error-factory.js +0 -174
  76. package/dist/_contracts/event-envelope.d.ts +0 -471
  77. package/dist/_contracts/event-envelope.js +0 -501
  78. package/dist/_contracts/event-stream-client.d.ts +0 -122
  79. package/dist/_contracts/event-stream-client.js +0 -445
  80. package/dist/_contracts/event-view.d.ts +0 -44
  81. package/dist/_contracts/event-view.js +0 -69
  82. package/dist/_contracts/failure-class.d.ts +0 -29
  83. package/dist/_contracts/failure-class.js +0 -73
  84. package/dist/_contracts/http.d.ts +0 -135
  85. package/dist/_contracts/http.js +0 -434
  86. package/dist/_contracts/ids.d.ts +0 -66
  87. package/dist/_contracts/ids.js +0 -119
  88. package/dist/_contracts/index.d.ts +0 -42
  89. package/dist/_contracts/index.js +0 -52
  90. package/dist/_contracts/internal.d.ts +0 -55
  91. package/dist/_contracts/internal.js +0 -113
  92. package/dist/_contracts/models.d.ts +0 -30
  93. package/dist/_contracts/models.js +0 -28
  94. package/dist/_contracts/operation-core.d.ts +0 -36
  95. package/dist/_contracts/operation-core.js +0 -70
  96. package/dist/_contracts/operations.d.ts +0 -218
  97. package/dist/_contracts/operations.js +0 -1496
  98. package/dist/_contracts/otlp-projection.d.ts +0 -78
  99. package/dist/_contracts/otlp-projection.js +0 -171
  100. package/dist/_contracts/post-hook.d.ts +0 -31
  101. package/dist/_contracts/post-hook.js +0 -61
  102. package/dist/_contracts/provider-fault.d.ts +0 -34
  103. package/dist/_contracts/provider-fault.js +0 -68
  104. package/dist/_contracts/retry-core.d.ts +0 -29
  105. package/dist/_contracts/retry-core.js +0 -79
  106. package/dist/_contracts/runner-event.d.ts +0 -117
  107. package/dist/_contracts/runner-event.js +0 -172
  108. package/dist/_contracts/runtime-kind.d.ts +0 -60
  109. package/dist/_contracts/runtime-kind.js +0 -70
  110. package/dist/_contracts/runtime-manifest.d.ts +0 -121
  111. package/dist/_contracts/runtime-manifest.js +0 -83
  112. package/dist/_contracts/runtime-security-profile.d.ts +0 -26
  113. package/dist/_contracts/runtime-security-profile.js +0 -73
  114. package/dist/_contracts/runtime-sizes.d.ts +0 -104
  115. package/dist/_contracts/runtime-sizes.js +0 -111
  116. package/dist/_contracts/runtime-types.d.ts +0 -618
  117. package/dist/_contracts/runtime-types.js +0 -58
  118. package/dist/_contracts/schemas/asset-bundle.d.ts +0 -70
  119. package/dist/_contracts/schemas/asset-bundle.js +0 -107
  120. package/dist/_contracts/schemas/asset-ref.d.ts +0 -61
  121. package/dist/_contracts/schemas/asset-ref.js +0 -118
  122. package/dist/_contracts/schemas/bundle-manifest.d.ts +0 -66
  123. package/dist/_contracts/schemas/bundle-manifest.js +0 -77
  124. package/dist/_contracts/schemas/index.d.ts +0 -32
  125. package/dist/_contracts/schemas/index.js +0 -30
  126. package/dist/_contracts/schemas/mcp-server.d.ts +0 -99
  127. package/dist/_contracts/schemas/mcp-server.js +0 -209
  128. package/dist/_contracts/schemas/models.d.ts +0 -29
  129. package/dist/_contracts/schemas/models.js +0 -51
  130. package/dist/_contracts/schemas/numeric.d.ts +0 -18
  131. package/dist/_contracts/schemas/numeric.js +0 -28
  132. package/dist/_contracts/schemas/post-hook.d.ts +0 -45
  133. package/dist/_contracts/schemas/post-hook.js +0 -68
  134. package/dist/_contracts/schemas/response-assets.d.ts +0 -75
  135. package/dist/_contracts/schemas/response-assets.js +0 -81
  136. package/dist/_contracts/schemas/response-billing.d.ts +0 -208
  137. package/dist/_contracts/schemas/response-billing.js +0 -139
  138. package/dist/_contracts/schemas/response-common.d.ts +0 -132
  139. package/dist/_contracts/schemas/response-common.js +0 -162
  140. package/dist/_contracts/schemas/response-identity.d.ts +0 -648
  141. package/dist/_contracts/schemas/response-identity.js +0 -131
  142. package/dist/_contracts/schemas/response-mcp-servers.d.ts +0 -51
  143. package/dist/_contracts/schemas/response-mcp-servers.js +0 -32
  144. package/dist/_contracts/schemas/response-secrets.d.ts +0 -50
  145. package/dist/_contracts/schemas/response-secrets.js +0 -32
  146. package/dist/_contracts/schemas/response-sessions-internal.d.ts +0 -200
  147. package/dist/_contracts/schemas/response-sessions-internal.js +0 -142
  148. package/dist/_contracts/schemas/response-sessions.d.ts +0 -1598
  149. package/dist/_contracts/schemas/response-sessions.js +0 -377
  150. package/dist/_contracts/schemas/response-webhooks.d.ts +0 -76
  151. package/dist/_contracts/schemas/response-webhooks.js +0 -42
  152. package/dist/_contracts/schemas/response-workspace.d.ts +0 -225
  153. package/dist/_contracts/schemas/response-workspace.js +0 -99
  154. package/dist/_contracts/schemas/runtime-kind.d.ts +0 -31
  155. package/dist/_contracts/schemas/runtime-kind.js +0 -29
  156. package/dist/_contracts/schemas/runtime-security-profile.d.ts +0 -28
  157. package/dist/_contracts/schemas/runtime-security-profile.js +0 -26
  158. package/dist/_contracts/schemas/runtime-sizes.d.ts +0 -70
  159. package/dist/_contracts/schemas/runtime-sizes.js +0 -127
  160. package/dist/_contracts/schemas/session-limits.d.ts +0 -34
  161. package/dist/_contracts/schemas/session-limits.js +0 -39
  162. package/dist/_contracts/schemas/session-machine.d.ts +0 -23
  163. package/dist/_contracts/schemas/session-machine.js +0 -24
  164. package/dist/_contracts/schemas/session-request-config.d.ts +0 -58
  165. package/dist/_contracts/schemas/session-request-config.js +0 -134
  166. package/dist/_contracts/schemas/session-webhook.d.ts +0 -11
  167. package/dist/_contracts/schemas/session-webhook.js +0 -38
  168. package/dist/_contracts/schemas/side-effect-audit.d.ts +0 -98
  169. package/dist/_contracts/schemas/side-effect-audit.js +0 -102
  170. package/dist/_contracts/schemas/submission-assets.d.ts +0 -117
  171. package/dist/_contracts/schemas/submission-assets.js +0 -147
  172. package/dist/_contracts/schemas/submission-body.d.ts +0 -251
  173. package/dist/_contracts/schemas/submission-body.js +0 -378
  174. package/dist/_contracts/schemas/submission-environment.d.ts +0 -79
  175. package/dist/_contracts/schemas/submission-environment.js +0 -179
  176. package/dist/_contracts/schemas/submission-request.d.ts +0 -158
  177. package/dist/_contracts/schemas/submission-request.js +0 -49
  178. package/dist/_contracts/schemas/submission-secrets.d.ts +0 -47
  179. package/dist/_contracts/schemas/submission-secrets.js +0 -108
  180. package/dist/_contracts/schemas/wire.d.ts +0 -118
  181. package/dist/_contracts/schemas/wire.js +0 -171
  182. package/dist/_contracts/schemas/workspace-resources.d.ts +0 -50
  183. package/dist/_contracts/schemas/workspace-resources.js +0 -87
  184. package/dist/_contracts/sdk-errors.d.ts +0 -212
  185. package/dist/_contracts/sdk-errors.js +0 -313
  186. package/dist/_contracts/sdk-secrets.d.ts +0 -67
  187. package/dist/_contracts/sdk-secrets.js +0 -427
  188. package/dist/_contracts/session-archive.d.ts +0 -16
  189. package/dist/_contracts/session-archive.js +0 -92
  190. package/dist/_contracts/session-artifacts.d.ts +0 -189
  191. package/dist/_contracts/session-artifacts.js +0 -264
  192. package/dist/_contracts/session-config.d.ts +0 -373
  193. package/dist/_contracts/session-config.js +0 -562
  194. package/dist/_contracts/session-cost-types.d.ts +0 -211
  195. package/dist/_contracts/session-cost-types.js +0 -69
  196. package/dist/_contracts/session-cost.d.ts +0 -8
  197. package/dist/_contracts/session-cost.js +0 -582
  198. package/dist/_contracts/session-custody.d.ts +0 -165
  199. package/dist/_contracts/session-custody.js +0 -345
  200. package/dist/_contracts/session-file-query.d.ts +0 -14
  201. package/dist/_contracts/session-file-query.js +0 -178
  202. package/dist/_contracts/session-record.d.ts +0 -112
  203. package/dist/_contracts/session-record.js +0 -165
  204. package/dist/_contracts/session-retention.d.ts +0 -201
  205. package/dist/_contracts/session-retention.js +0 -450
  206. package/dist/_contracts/side-effect-audit.d.ts +0 -126
  207. package/dist/_contracts/side-effect-audit.js +0 -520
  208. package/dist/_contracts/sse.d.ts +0 -74
  209. package/dist/_contracts/sse.js +0 -227
  210. package/dist/_contracts/stable.d.ts +0 -45
  211. package/dist/_contracts/stable.js +0 -62
  212. package/dist/_contracts/status.d.ts +0 -25
  213. package/dist/_contracts/status.js +0 -57
  214. package/dist/_contracts/submission-limits.d.ts +0 -61
  215. package/dist/_contracts/submission-limits.js +0 -60
  216. package/dist/_contracts/submission.d.ts +0 -547
  217. package/dist/_contracts/submission.js +0 -812
  218. package/dist/_contracts/suggest.d.ts +0 -15
  219. package/dist/_contracts/suggest.js +0 -53
  220. package/dist/_contracts/testing/response-bindings.d.ts +0 -45
  221. package/dist/_contracts/testing/response-bindings.js +0 -256
  222. package/dist/_contracts/testing/wire-conformance-entry.d.ts +0 -10
  223. package/dist/_contracts/testing/wire-conformance-entry.js +0 -8
  224. package/dist/_contracts/testing/wire-conformance.d.ts +0 -169
  225. package/dist/_contracts/testing/wire-conformance.js +0 -276
  226. package/dist/_contracts/turn-trace.d.ts +0 -28
  227. package/dist/_contracts/turn-trace.js +0 -1
  228. package/dist/_contracts/unknown-field-error.d.ts +0 -13
  229. package/dist/_contracts/unknown-field-error.js +0 -21
  230. package/dist/_contracts/value-guards.d.ts +0 -20
  231. package/dist/_contracts/value-guards.js +0 -34
  232. package/dist/_contracts/webhook-verify.d.ts +0 -34
  233. package/dist/_contracts/webhook-verify.js +0 -93
  234. package/dist/_contracts/wire-observer.d.ts +0 -49
  235. package/dist/_contracts/wire-observer.js +0 -34
  236. package/dist/_contracts/workflow-status.d.ts +0 -7
  237. package/dist/_contracts/workflow-status.js +0 -43
  238. package/dist/_contracts/workspace-resources.d.ts +0 -98
  239. package/dist/_contracts/workspace-resources.js +0 -39
  240. package/dist/archive-limits.d.ts +0 -1
  241. package/dist/archive-limits.js +0 -2
  242. package/dist/archive-limits.js.map +0 -1
  243. package/dist/asset-upload.d.ts +0 -47
  244. package/dist/asset-upload.js +0 -269
  245. package/dist/asset-upload.js.map +0 -1
  246. package/dist/bundle.d.ts +0 -9
  247. package/dist/bundle.js +0 -20
  248. package/dist/bundle.js.map +0 -1
  249. package/dist/canonical-zip.d.ts +0 -68
  250. package/dist/canonical-zip.js +0 -355
  251. package/dist/canonical-zip.js.map +0 -1
  252. package/dist/cli.mjs +0 -12048
  253. package/dist/cli.mjs.sha256 +0 -1
  254. package/dist/client-types.d.ts +0 -192
  255. package/dist/client-types.js +0 -2
  256. package/dist/client-types.js.map +0 -1
  257. package/dist/client.d.ts +0 -464
  258. package/dist/client.js +0 -1207
  259. package/dist/client.js.map +0 -1
  260. package/dist/event-projection.d.ts +0 -22
  261. package/dist/event-projection.js +0 -380
  262. package/dist/event-projection.js.map +0 -1
  263. package/dist/fetch-archive.d.ts +0 -16
  264. package/dist/fetch-archive.js +0 -252
  265. package/dist/fetch-archive.js.map +0 -1
  266. package/dist/file.d.ts +0 -96
  267. package/dist/file.js +0 -272
  268. package/dist/file.js.map +0 -1
  269. package/dist/instructions.d.ts +0 -20
  270. package/dist/instructions.js +0 -40
  271. package/dist/instructions.js.map +0 -1
  272. package/dist/legacy-session-provider-fault.d.ts +0 -7
  273. package/dist/legacy-session-provider-fault.js +0 -38
  274. package/dist/legacy-session-provider-fault.js.map +0 -1
  275. package/dist/mcp-server.d.ts +0 -84
  276. package/dist/mcp-server.js +0 -117
  277. package/dist/mcp-server.js.map +0 -1
  278. package/dist/node-fs.d.ts +0 -29
  279. package/dist/node-fs.js +0 -19
  280. package/dist/node-fs.js.map +0 -1
  281. package/dist/node-walk.d.ts +0 -69
  282. package/dist/node-walk.js +0 -151
  283. package/dist/node-walk.js.map +0 -1
  284. package/dist/path-basename.d.ts +0 -5
  285. package/dist/path-basename.js +0 -9
  286. package/dist/path-basename.js.map +0 -1
  287. package/dist/retry.d.ts +0 -70
  288. package/dist/retry.js +0 -155
  289. package/dist/retry.js.map +0 -1
  290. package/dist/secret.d.ts +0 -65
  291. package/dist/secret.js +0 -110
  292. package/dist/secret.js.map +0 -1
  293. package/dist/session-validate.d.ts +0 -100
  294. package/dist/session-validate.js +0 -303
  295. package/dist/session-validate.js.map +0 -1
  296. package/dist/skill.d.ts +0 -99
  297. package/dist/skill.js +0 -169
  298. package/dist/skill.js.map +0 -1
  299. package/dist/submission-wire.d.ts +0 -13
  300. package/dist/submission-wire.js +0 -69
  301. package/dist/submission-wire.js.map +0 -1
  302. package/dist/tool.d.ts +0 -41
  303. package/dist/tool.js +0 -76
  304. package/dist/tool.js.map +0 -1
  305. package/dist/version.d.ts +0 -9
  306. package/dist/version.js +0 -10
  307. package/dist/version.js.map +0 -1
  308. package/docs/authentication.md +0 -125
  309. package/docs/billing.md +0 -164
  310. package/docs/cleanup.md +0 -27
  311. package/docs/concepts/agent-tools.md +0 -47
  312. package/docs/concepts/composition.md +0 -60
  313. package/docs/concepts/providers-and-runtimes.md +0 -121
  314. package/docs/concepts/sessions.md +0 -51
  315. package/docs/concepts/subagents.md +0 -35
  316. package/docs/credentials.md +0 -116
  317. package/docs/defaults.md +0 -51
  318. package/docs/errors.md +0 -258
  319. package/docs/events.md +0 -143
  320. package/docs/files.md +0 -130
  321. package/docs/limits-and-quotas.md +0 -114
  322. package/docs/limits.md +0 -51
  323. package/docs/mcp.md +0 -47
  324. package/docs/networking.md +0 -114
  325. package/docs/provider-runtime-capabilities.md +0 -32
  326. package/docs/public-surface.json +0 -73
  327. package/docs/quickstart.md +0 -135
  328. package/docs/release.md +0 -44
  329. package/docs/retries.md +0 -108
  330. package/docs/secrets.md +0 -141
  331. package/docs/session-config.md +0 -51
  332. package/docs/session-record.md +0 -58
  333. package/docs/skills.md +0 -65
  334. package/docs/telemetry.md +0 -66
  335. package/docs/testing.md +0 -35
  336. package/docs/vision-skills.md +0 -94
  337. package/docs/webhooks.md +0 -143
@@ -1,116 +0,0 @@
1
- /**
2
- * SSoT for the platform's STABLE API error codes.
3
- *
4
- * The server (platform `api.ts`) imports this table instead of keeping its
5
- * own private copy, so a route emitting a code absent from the union fails to
6
- * compile and adding a code without a message is caught. The SDK error factory
7
- * ({@link import("./error-factory.js").apiErrorFromResponse}) dispatches on the
8
- * code to a typed subclass; the CLI maps it to a human remedy.
9
- *
10
- * The code is the stable, machine-branchable identity of a failure — distinct
11
- * from the human `message`. `idempotency_conflict` and `insufficient_scope`
12
- * (previously message-less bare 409/403 bodies) are first-class here.
13
- */
14
- export const AEX_API_ERROR_CODES = [
15
- "unauthorized",
16
- "forbidden",
17
- "insufficient_scope",
18
- "token_invalid",
19
- "token_revoked",
20
- "token_expired",
21
- "malformed_token",
22
- "not_found",
23
- "idempotency_conflict",
24
- "session_busy",
25
- "checkpoint_not_available",
26
- "session_not_terminal",
27
- "session_terminal",
28
- "event_archive_too_large",
29
- "event_archive_deadline_exceeded",
30
- "unknown_workspace",
31
- "workspace_inactive",
32
- "workspace_concurrency_exceeded",
33
- "workspace_submit_rate_exceeded",
34
- "workspace_spend_cap_exceeded",
35
- "workspace_cap_exceeded",
36
- "insufficient_credits",
37
- "account_blocked",
38
- "quota_exhausted",
39
- "depth_exceeded",
40
- "rate_limited",
41
- "out_of_memory",
42
- "disk_full",
43
- "content_deleted",
44
- "upstream_error",
45
- "internal_error"
46
- ];
47
- /**
48
- * Human message per stable code. A `Record` (not `Partial`) so a code added to
49
- * {@link AEX_API_ERROR_CODES} without a message is a COMPILE error. These are
50
- * the fallback messages the factory uses when the server sends a BARE code with
51
- * no `message` detail.
52
- */
53
- export const AEX_API_ERROR_MESSAGES = {
54
- unauthorized: "The request was not authenticated.",
55
- forbidden: "The API key is not permitted to perform this action.",
56
- insufficient_scope: "The API key is missing a scope this endpoint requires.",
57
- token_invalid: "The API key is not valid.",
58
- token_revoked: "The API key has been revoked.",
59
- token_expired: "The API key has expired.",
60
- malformed_token: "The API key is malformed.",
61
- not_found: "The requested resource was not found.",
62
- idempotency_conflict: "This idempotency key was already used with a different request body.",
63
- session_busy: "The session is busy handling another turn.",
64
- checkpoint_not_available: "The session does not have a committed checkpoint available yet.",
65
- session_not_terminal: "The session has not reached a terminal state yet.",
66
- session_terminal: "The session has ended and cannot perform this action.",
67
- event_archive_too_large: "The session event history is too large for synchronous bulk export.",
68
- event_archive_deadline_exceeded: "The synchronous session event export exceeded its deadline.",
69
- unknown_workspace: "The workspace could not be resolved from the API key.",
70
- workspace_inactive: "The workspace no longer accepts new session work.",
71
- workspace_concurrency_exceeded: "The workspace has reached its concurrent-run limit.",
72
- workspace_submit_rate_exceeded: "The workspace submit-rate limit was exceeded.",
73
- workspace_spend_cap_exceeded: "The workspace monthly spend cap was reached.",
74
- workspace_cap_exceeded: "The organization has reached its workspace limit.",
75
- insufficient_credits: "The free monthly allowance and the prepaid credit balance are both exhausted.",
76
- account_blocked: "The organization is blocked and cannot start new work.",
77
- quota_exhausted: "The request exceeds the workspace's remaining usage grant and there is no billable path for the overage.",
78
- depth_exceeded: "The request would create a subagent deeper than the lineage depth ceiling.",
79
- rate_limited: "Too many requests — retry after a short backoff.",
80
- out_of_memory: "The runtime was killed for exceeding its memory allocation.",
81
- disk_full: "A write failed because the runtime's filesystem was full.",
82
- content_deleted: "The session's content was deleted after its retention window; only metadata remains.",
83
- upstream_error: "An upstream provider returned an error.",
84
- internal_error: "The aex API encountered an internal error."
85
- };
86
- /** Optional per-code fix hint the CLI surfaces alongside the error message. */
87
- export const AEX_API_ERROR_REMEDIES = {
88
- insufficient_scope: "Mint an API key that includes the scope this endpoint requires.",
89
- idempotency_conflict: "Use a fresh idempotency key, or resubmit the byte-identical request body to replay the original result.",
90
- token_invalid: "Check the API key value and that its plane matches your baseUrl.",
91
- token_expired: "Mint a new API key.",
92
- token_revoked: "Mint a new API key.",
93
- session_terminal: "Create or open an active session before retrying this action.",
94
- checkpoint_not_available: "Wait for the current run to finish before reading checkpoint-backed session files.",
95
- event_archive_too_large: "Traverse the event history with session.events.iterate().",
96
- event_archive_deadline_exceeded: "Traverse the event history with session.events.iterate().",
97
- workspace_inactive: "Use an active workspace; a workspace being deleted cannot accept new session work.",
98
- workspace_spend_cap_exceeded: "Raise the workspace spend cap or wait for the next billing cycle.",
99
- insufficient_credits: "Top up the prepaid balance, or add a payment method if the organization has none saved.",
100
- // Deliberately NOT a top-up prompt: credit does not lift a block, so sending a
101
- // blocked customer to the payment form takes their money and changes nothing.
102
- account_blocked: "Adding credit does not lift the block — contact support to resolve it.",
103
- workspace_concurrency_exceeded: "Wait for in-flight sessions to finish or raise the concurrency limit.",
104
- workspace_submit_rate_exceeded: "Slow the submit rate or raise the workspace submit-rate limit.",
105
- workspace_cap_exceeded: "Delete an unused workspace, or contact support to raise the organization's workspace limit.",
106
- quota_exhausted: "Top up the prepaid balance so usage beyond the free monthly allowance has somewhere to bill.",
107
- depth_exceeded: "Spawn the subagent from a shallower session, or flatten the lineage.",
108
- out_of_memory: "Re-run on a larger runtimeSize, or reduce the memory the session holds at once.",
109
- disk_full: "Re-run on a larger runtimeSize, or write fewer/smaller files inside the session.",
110
- content_deleted: "The session content is gone after its retention window; read the session record's metadata, or start a new session."
111
- };
112
- const API_ERROR_CODE_SET = new Set(AEX_API_ERROR_CODES);
113
- /** Narrow an arbitrary value to a known {@link AexApiErrorCode}. */
114
- export function isAexApiErrorCode(value) {
115
- return typeof value === "string" && API_ERROR_CODE_SET.has(value);
116
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * The SINGLE wire→exception mapping. `apiErrorFromResponse` reads a non-2xx
3
- * body's stable `error` code, attaches it (typed) as `apiCode` plus the
4
- * `requestId`, and dispatches to the right {@link AexApiError} subclass. Both
5
- * `HttpClient.request` and `HttpClient.download` construct errors ONLY through
6
- * here, so the wire→exception mapping lives in one place — no inline
7
- * `new AexApiError(...)` with a hardcoded coarse code.
8
- */
9
- import { AexApiError } from "./sdk-errors.js";
10
- import { type AexApiErrorCode } from "./error-codes.js";
11
- export interface ApiErrorFromResponseInput {
12
- readonly status: number;
13
- readonly body: unknown;
14
- /**
15
- * Precomputed human message (e.g. `HttpClient`'s `extractErrorMessage`). When
16
- * absent the factory derives one from the stable code table.
17
- */
18
- readonly message?: string;
19
- readonly requestId?: string;
20
- readonly cause?: unknown;
21
- }
22
- type ApiErrorKind = "auth" | "idempotency" | "not_found" | "rate_limit" | "content_deleted" | "generic";
23
- /**
24
- * EXHAUSTIVE stable-code → subclass-kind map. There is NO `default`: adding a
25
- * code to {@link AEX_API_ERROR_CODES} without a case here fails to compile
26
- * (the function would fall through and return `undefined`, which the
27
- * `ApiErrorKind` return type forbids). This is the whole-class guard that a new
28
- * server code can never silently collapse to the base error.
29
- */
30
- export declare function apiErrorKindForCode(code: AexApiErrorCode): ApiErrorKind;
31
- export declare function apiErrorFromResponse(input: ApiErrorFromResponseInput): AexApiError;
32
- export {};
@@ -1,174 +0,0 @@
1
- /**
2
- * The SINGLE wire→exception mapping. `apiErrorFromResponse` reads a non-2xx
3
- * body's stable `error` code, attaches it (typed) as `apiCode` plus the
4
- * `requestId`, and dispatches to the right {@link AexApiError} subclass. Both
5
- * `HttpClient.request` and `HttpClient.download` construct errors ONLY through
6
- * here, so the wire→exception mapping lives in one place — no inline
7
- * `new AexApiError(...)` with a hardcoded coarse code.
8
- */
9
- import { AexApiError, AexAuthError, AexIdempotencyConflictError, AexNotFoundError, AexRateLimitError, ContentDeletedError } from "./sdk-errors.js";
10
- import { AEX_API_ERROR_MESSAGES, isAexApiErrorCode } from "./error-codes.js";
11
- /**
12
- * EXHAUSTIVE stable-code → subclass-kind map. There is NO `default`: adding a
13
- * code to {@link AEX_API_ERROR_CODES} without a case here fails to compile
14
- * (the function would fall through and return `undefined`, which the
15
- * `ApiErrorKind` return type forbids). This is the whole-class guard that a new
16
- * server code can never silently collapse to the base error.
17
- */
18
- export function apiErrorKindForCode(code) {
19
- switch (code) {
20
- case "unauthorized":
21
- case "forbidden":
22
- case "insufficient_scope":
23
- case "token_invalid":
24
- case "token_revoked":
25
- case "token_expired":
26
- case "malformed_token":
27
- return "auth";
28
- case "idempotency_conflict":
29
- return "idempotency";
30
- case "not_found":
31
- return "not_found";
32
- case "rate_limited":
33
- case "workspace_concurrency_exceeded":
34
- case "workspace_submit_rate_exceeded":
35
- return "rate_limit";
36
- case "content_deleted":
37
- return "content_deleted";
38
- case "session_busy":
39
- case "checkpoint_not_available":
40
- case "session_not_terminal":
41
- case "session_terminal":
42
- case "event_archive_too_large":
43
- case "event_archive_deadline_exceeded":
44
- case "unknown_workspace":
45
- case "workspace_inactive":
46
- case "workspace_spend_cap_exceeded":
47
- case "workspace_cap_exceeded":
48
- // Both 402s stay on the base class. They carry OPPOSITE remedies (buy credit
49
- // / do not buy credit), so a shared subclass would invite exactly the
50
- // conflation the two codes exist to prevent — branch on `apiCode`.
51
- case "insufficient_credits":
52
- case "account_blocked":
53
- case "quota_exhausted":
54
- case "depth_exceeded":
55
- case "out_of_memory":
56
- case "disk_full":
57
- case "upstream_error":
58
- case "internal_error":
59
- return "generic";
60
- }
61
- }
62
- function kindForStatus(status) {
63
- if (status === 401 || status === 403)
64
- return "auth";
65
- if (status === 404)
66
- return "not_found";
67
- if (status === 429)
68
- return "rate_limit";
69
- return "generic";
70
- }
71
- export function apiErrorFromResponse(input) {
72
- const apiCode = apiCodeFromBody(input.body);
73
- const requestId = input.requestId ?? requestIdFromBody(input.body);
74
- const message = input.message ?? fallbackMessage(apiCode, input.body);
75
- const kind = apiCode !== undefined ? apiErrorKindForCode(apiCode) : kindForStatus(input.status);
76
- const init = {
77
- status: input.status,
78
- message,
79
- body: input.body,
80
- apiCode,
81
- requestId,
82
- cause: input.cause
83
- };
84
- switch (kind) {
85
- case "auth":
86
- return new AexAuthError({ ...init, requiredScope: requiredScopeFromBody(input.body) });
87
- case "idempotency":
88
- return new AexIdempotencyConflictError(init);
89
- case "not_found":
90
- return new AexNotFoundError(init);
91
- case "rate_limit":
92
- return new AexRateLimitError({ ...init, retryAfterMs: retryAfterMsFromBody(input.body) });
93
- case "content_deleted":
94
- return new ContentDeletedError({
95
- ...init,
96
- sessionId: sessionIdFromBody(input.body),
97
- purgedAt: purgedAtFromBody(input.body),
98
- deletedBy: deletedByFromBody(input.body)
99
- });
100
- case "generic":
101
- return new AexApiError(input.status, message, input.body, {
102
- apiCode,
103
- requestId,
104
- ...(input.cause !== undefined ? { cause: input.cause } : {})
105
- });
106
- }
107
- }
108
- function asRecord(body) {
109
- return body !== null && typeof body === "object" && !Array.isArray(body)
110
- ? body
111
- : undefined;
112
- }
113
- function apiCodeFromBody(body) {
114
- const record = asRecord(body);
115
- if (!record)
116
- return undefined;
117
- if (isAexApiErrorCode(record.error))
118
- return record.error;
119
- if (isAexApiErrorCode(record.code))
120
- return record.code;
121
- return undefined;
122
- }
123
- function requestIdFromBody(body) {
124
- const record = asRecord(body);
125
- const value = record?.requestId;
126
- return typeof value === "string" && value.trim().length > 0 ? value : undefined;
127
- }
128
- function requiredScopeFromBody(body) {
129
- const record = asRecord(body);
130
- if (!record)
131
- return undefined;
132
- for (const key of ["requiredScope", "required_scope", "scope"]) {
133
- const value = record[key];
134
- if (typeof value === "string" && value.length > 0)
135
- return value;
136
- }
137
- return undefined;
138
- }
139
- function sessionIdFromBody(body) {
140
- const value = asRecord(body)?.sessionId;
141
- return typeof value === "string" && value.length > 0 ? value : undefined;
142
- }
143
- function purgedAtFromBody(body) {
144
- const value = asRecord(body)?.purgedAt;
145
- return typeof value === "string" && value.length > 0 ? value : undefined;
146
- }
147
- function deletedByFromBody(body) {
148
- const value = asRecord(body)?.deletedBy;
149
- return value === "retention" || value === "user" ? value : undefined;
150
- }
151
- function retryAfterMsFromBody(body) {
152
- const record = asRecord(body);
153
- if (!record)
154
- return undefined;
155
- if (typeof record.retryAfterMs === "number" && Number.isFinite(record.retryAfterMs)) {
156
- return record.retryAfterMs;
157
- }
158
- if (typeof record.retryAfter === "number" && Number.isFinite(record.retryAfter)) {
159
- return record.retryAfter * 1000;
160
- }
161
- return undefined;
162
- }
163
- function fallbackMessage(apiCode, body) {
164
- if (apiCode !== undefined)
165
- return AEX_API_ERROR_MESSAGES[apiCode];
166
- const record = asRecord(body);
167
- const message = record?.message;
168
- if (typeof message === "string" && message.length > 0)
169
- return message;
170
- const error = record?.error;
171
- if (typeof error === "string" && error.length > 0)
172
- return error;
173
- return "aex API request failed";
174
- }