@aexhq/sdk 0.46.4-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
package/dist/retry.d.ts DELETED
@@ -1,70 +0,0 @@
1
- /**
2
- * Built-in transport resilience for the aex SDK.
3
- *
4
- * There is ONE retry policy in this repo and it lives in `@aexhq/contracts`
5
- * (`HTTP_RETRY_POLICY` / `withHttpRetry` in `http.ts`), shared verbatim by the
6
- * SDK, the `aex` CLI, and the direct-to-storage asset uploader. This module is
7
- * the SDK's naming of that policy plus the provider-fault decoding that has no
8
- * home in the transport.
9
- *
10
- * The policy: an eligible request that fails with an HTTP 429 (rate limited), a
11
- * 500/502/503/504 (server hiccup), a 529 (upstream overloaded), or a network
12
- * error is retried with BOUNDED exponential backoff + full jitter, honoring the
13
- * server's `Retry-After` header when present, inside a wall-clock budget.
14
- * Non-retryable 4xx responses (400/401/403/404/…) fail fast.
15
- *
16
- * Safe reads (GET/HEAD/OPTIONS) are eligible directly. Any mutation is eligible
17
- * only when it carries a stable `Idempotency-Key`; all other mutations get
18
- * exactly one transport attempt.
19
- *
20
- * When retries are exhausted on a rate-limit / overloaded status the wrapper
21
- * surfaces an {@link AexRateLimitError} — a structured, non-leaky throttle error
22
- * carrying the parsed `retryAfterMs`, the attempt count, and (when the runtime
23
- * supplies it) an upstream {@link ProviderFault}. All other exhausted retries
24
- * fall through to the transport's usual `AexApiError` / network rejection.
25
- */
26
- import { isRateLimited, resolveHttpRetryPolicy, withHttpRetry, type ProviderFault } from "./_contracts/index.js";
27
- export { isRateLimited };
28
- export { AexRateLimitError } from "./_contracts/index.js";
29
- export type { ProviderFault } from "./_contracts/index.js";
30
- /**
31
- * `RETRYABLE_STATUS` — statuses that are transient and worth retrying for an
32
- * eligible request. `RATE_LIMIT_STATUS` — the subset the platform / upstream
33
- * provider uses to say "slow down" (429 rate-limit, 503 unavailable, 529
34
- * overloaded); when retries for one of these run out the wrapper raises an
35
- * `AexRateLimitError`. Both are `retry-core.ts`'s sets under the SDK's names.
36
- */
37
- export { RATE_LIMIT_HTTP_STATUS as RATE_LIMIT_STATUS, RETRYABLE_HTTP_STATUS as RETRYABLE_STATUS } from "./_contracts/internal.js";
38
- /**
39
- * Tunes the built-in retry loop. All fields are optional; omit the whole
40
- * `retry` option (or pass `retry: false` on the client) to accept the defaults
41
- * or turn the loop off entirely. The SDK's name for the repo-wide
42
- * `HttpRetryOptions`.
43
- */
44
- export type { HttpRetryOptions as RetryOptions } from "./_contracts/index.js";
45
- /** Resolve caller options over the one shared policy, clamping to sane bounds. */
46
- export declare const resolveRetryConfig: typeof resolveHttpRetryPolicy;
47
- /**
48
- * Wrap a `FetchLike` with the one shared bounded-retry loop. `retry === false`
49
- * disables the layer entirely.
50
- */
51
- export declare const withRetry: typeof withHttpRetry;
52
- export type { HttpRetryDeps as RetryDeps } from "./_contracts/index.js";
53
- export { computeRetryBackoffDelayMs as computeBackoffDelayMs, isRateLimitHttpStatus as isRateLimitStatus, isRetryableHttpStatus as isRetryableStatus, tryParseRetryAfterMs as parseRetryAfterMs } from "./_contracts/internal.js";
54
- /** True when a {@link ProviderFault} represents a "back off and retry" signal. */
55
- export declare function isThrottleFault(fault: ProviderFault): boolean;
56
- /**
57
- * Best-effort compatibility parse of an unknown provider error. Canonical
58
- * Session and RUN_ERROR fields are validated by `@aexhq/contracts`; this helper
59
- * remains tolerant only for callers decoding documented historical raw-provider
60
- * shapes:
61
- *
62
- * 1. The canonical `{ provider?, kind, status?, retryAfterMs?, message? }`
63
- * (optionally nested under a `providerFault` key), OR
64
- * 2. A raw upstream error `{ type: "rate_limit_error" | "overloaded_error"
65
- * | ..., message?, retry_after? | retryAfter? }` — `type` maps to `kind`
66
- * and `retry_after` (seconds) maps to `retryAfterMs`.
67
- *
68
- * Returns `undefined` when the value carries no recognizable fault.
69
- */
70
- export declare function parseProviderFault(value: unknown): ProviderFault | undefined;
package/dist/retry.js DELETED
@@ -1,155 +0,0 @@
1
- /**
2
- * Built-in transport resilience for the aex SDK.
3
- *
4
- * There is ONE retry policy in this repo and it lives in `@aexhq/contracts`
5
- * (`HTTP_RETRY_POLICY` / `withHttpRetry` in `http.ts`), shared verbatim by the
6
- * SDK, the `aex` CLI, and the direct-to-storage asset uploader. This module is
7
- * the SDK's naming of that policy plus the provider-fault decoding that has no
8
- * home in the transport.
9
- *
10
- * The policy: an eligible request that fails with an HTTP 429 (rate limited), a
11
- * 500/502/503/504 (server hiccup), a 529 (upstream overloaded), or a network
12
- * error is retried with BOUNDED exponential backoff + full jitter, honoring the
13
- * server's `Retry-After` header when present, inside a wall-clock budget.
14
- * Non-retryable 4xx responses (400/401/403/404/…) fail fast.
15
- *
16
- * Safe reads (GET/HEAD/OPTIONS) are eligible directly. Any mutation is eligible
17
- * only when it carries a stable `Idempotency-Key`; all other mutations get
18
- * exactly one transport attempt.
19
- *
20
- * When retries are exhausted on a rate-limit / overloaded status the wrapper
21
- * surfaces an {@link AexRateLimitError} — a structured, non-leaky throttle error
22
- * carrying the parsed `retryAfterMs`, the attempt count, and (when the runtime
23
- * supplies it) an upstream {@link ProviderFault}. All other exhausted retries
24
- * fall through to the transport's usual `AexApiError` / network rejection.
25
- */
26
- import { isRateLimited, parseProviderFault as parseCanonicalProviderFault, resolveHttpRetryPolicy, withHttpRetry } from "./_contracts/index.js";
27
- // The rate-limit guard AND the rate-limit error are SINGLE-SOURCED in
28
- // `@aexhq/contracts`, so the wire→exception factory (`apiErrorFromResponse`) and
29
- // the retry policy raise the SAME class recognised by the SAME `isRateLimited` —
30
- // no split-brain, no subclass mirror.
31
- export { isRateLimited };
32
- export { AexRateLimitError } from "./_contracts/index.js";
33
- /**
34
- * `RETRYABLE_STATUS` — statuses that are transient and worth retrying for an
35
- * eligible request. `RATE_LIMIT_STATUS` — the subset the platform / upstream
36
- * provider uses to say "slow down" (429 rate-limit, 503 unavailable, 529
37
- * overloaded); when retries for one of these run out the wrapper raises an
38
- * `AexRateLimitError`. Both are `retry-core.ts`'s sets under the SDK's names.
39
- */
40
- export { RATE_LIMIT_HTTP_STATUS as RATE_LIMIT_STATUS, RETRYABLE_HTTP_STATUS as RETRYABLE_STATUS } from "./_contracts/internal.js";
41
- /** Resolve caller options over the one shared policy, clamping to sane bounds. */
42
- export const resolveRetryConfig = resolveHttpRetryPolicy;
43
- /**
44
- * Wrap a `FetchLike` with the one shared bounded-retry loop. `retry === false`
45
- * disables the layer entirely.
46
- */
47
- export const withRetry = withHttpRetry;
48
- // The retryable/rate-limit status predicates, the RFC 7231 `Retry-After` parse
49
- // (integer seconds OR HTTP-date), and the AWS-style full-jitter exponential
50
- // backoff are all `retry-core.ts`'s. Re-exported under the SDK's names — never
51
- // re-implemented, which is how the CLI and the SDK drifted in the first place.
52
- export { computeRetryBackoffDelayMs as computeBackoffDelayMs, isRateLimitHttpStatus as isRateLimitStatus, isRetryableHttpStatus as isRetryableStatus, tryParseRetryAfterMs as parseRetryAfterMs } from "./_contracts/internal.js";
53
- const THROTTLE_KINDS = new Set([
54
- "rate_limit",
55
- "overloaded",
56
- "quota_exceeded",
57
- "unavailable"
58
- ]);
59
- /** True when a {@link ProviderFault} represents a "back off and retry" signal. */
60
- export function isThrottleFault(fault) {
61
- return THROTTLE_KINDS.has(fault.kind);
62
- }
63
- /**
64
- * Best-effort compatibility parse of an unknown provider error. Canonical
65
- * Session and RUN_ERROR fields are validated by `@aexhq/contracts`; this helper
66
- * remains tolerant only for callers decoding documented historical raw-provider
67
- * shapes:
68
- *
69
- * 1. The canonical `{ provider?, kind, status?, retryAfterMs?, message? }`
70
- * (optionally nested under a `providerFault` key), OR
71
- * 2. A raw upstream error `{ type: "rate_limit_error" | "overloaded_error"
72
- * | ..., message?, retry_after? | retryAfter? }` — `type` maps to `kind`
73
- * and `retry_after` (seconds) maps to `retryAfterMs`.
74
- *
75
- * Returns `undefined` when the value carries no recognizable fault.
76
- */
77
- export function parseProviderFault(value) {
78
- if (value === null || typeof value !== "object")
79
- return undefined;
80
- const record = value;
81
- const nested = record.providerFault ?? record.provider_fault;
82
- if (nested !== undefined && nested !== value) {
83
- const fromNested = parseProviderFault(nested);
84
- if (fromNested)
85
- return fromNested;
86
- }
87
- try {
88
- return parseCanonicalProviderFault(record);
89
- }
90
- catch {
91
- // Continue into the deliberately narrow historical raw-provider decoder.
92
- }
93
- const kind = legacyFaultKind(record.kind ?? record.type ?? record.code);
94
- if (kind === undefined)
95
- return undefined;
96
- const provider = typeof record.provider === "string" ? record.provider : undefined;
97
- const status = coerceStatus(record.status ?? record.statusCode ?? record.httpStatus);
98
- const retryAfterMs = record.retryAfterMs !== undefined
99
- ? coerceRetryDelay(record.retryAfterMs, 1)
100
- : record.retry_after_ms !== undefined
101
- ? coerceRetryDelay(record.retry_after_ms, 1)
102
- : record.retryAfter !== undefined
103
- ? coerceRetryDelay(record.retryAfter, 1000)
104
- : coerceRetryDelay(record.retry_after, 1000);
105
- const message = typeof record.message === "string" ? record.message : undefined;
106
- return {
107
- kind,
108
- ...(provider !== undefined ? { provider } : {}),
109
- ...(status !== undefined ? { status } : {}),
110
- ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
111
- ...(message !== undefined ? { message } : {})
112
- };
113
- }
114
- const LEGACY_FAULT_KINDS = {
115
- rate_limit: "rate_limit",
116
- rate_limit_error: "rate_limit",
117
- overloaded: "overloaded",
118
- overloaded_error: "overloaded",
119
- quota_exceeded: "quota_exceeded",
120
- quota_exceeded_error: "quota_exceeded",
121
- insufficient_quota: "quota_exceeded",
122
- unavailable: "unavailable",
123
- api_error: "unavailable",
124
- timeout_error: "unavailable",
125
- provider_error: "provider_error",
126
- authentication_error: "provider_error",
127
- invalid_request_error: "provider_error",
128
- "429": "rate_limit",
129
- "529": "overloaded"
130
- };
131
- function legacyFaultKind(raw) {
132
- if (typeof raw !== "string")
133
- return undefined;
134
- return LEGACY_FAULT_KINDS[raw.trim().toLowerCase()];
135
- }
136
- function coerceStatus(raw) {
137
- if (typeof raw === "number" && Number.isFinite(raw))
138
- return raw;
139
- if (typeof raw === "string" && /^\d+$/.test(raw.trim()))
140
- return Number(raw.trim());
141
- return undefined;
142
- }
143
- /** Coerce a numeric delay using the unit declared by its field name. */
144
- function coerceRetryDelay(raw, multiplier) {
145
- const value = typeof raw === "number" && Number.isFinite(raw)
146
- ? raw
147
- : typeof raw === "string" && /^\d+$/.test(raw.trim())
148
- ? Number(raw.trim())
149
- : undefined;
150
- if (value === undefined || value < 0)
151
- return undefined;
152
- const milliseconds = value * multiplier;
153
- return Number.isSafeInteger(milliseconds) ? milliseconds : undefined;
154
- }
155
- //# sourceMappingURL=retry.js.map
package/dist/retry.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,IAAI,2BAA2B,EACjD,sBAAsB,EACtB,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAE1B,sEAAsE;AACtE,iFAAiF;AACjF,iFAAiF;AACjF,sCAAsC;AACtC,OAAO,EAAE,aAAa,EAAE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S,CAAC;AACnB,CAAC;AAED,wEAAwE;AACxE,SAAS,gBAAgB,CAAC,GAAY,EAAE,UAAoB;IAC1D,MAAM,KAAK,GACT,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC7C,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACnD,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC,CAAC,SAAS,CAAC;IAClB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACvD,MAAM,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC;IACxC,OAAO,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC"}
package/dist/secret.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import { SecretString } from "./_contracts/index.js";
2
- /**
3
- * Non-secret wire shape for one `secretEnv` entry. A workspace ref carries the
4
- * handle (hashable, resolved server-side); an ephemeral secret carries only a
5
- * value-free placeholder — the value is split into the vaulted secrets channel
6
- * and excluded from the idempotency hash.
7
- */
8
- export type SecretEnvSubmissionEntry = {
9
- readonly ref: string;
10
- } | {
11
- readonly ephemeral: true;
12
- };
13
- /**
14
- * A secret with the SAME lifecycle semantic as `File` / `Instructions`:
15
- * EPHEMERAL per-session by default, or a reference to a persisted workspace
16
- * secret created explicitly through `aex.workspace.secrets.set(...)`.
17
- *
18
- * - `Secret.value(v)` — EPHEMERAL per-session: the value is vaulted when the session is created and
19
- * excluded from the idempotency hash; only a `{ ephemeral: true }`
20
- * placeholder rides the (hashed) submission. Deleted when the session finishes.
21
- * Clean, no workspace dependency. ≙ `File.fromBytes(...)` (a draft).
22
- * - `Secret.ref(handle)` — WORKSPACE: only the handle rides the submission;
23
- * the value is resolved server-side from the workspace secret store. No
24
- * value ever travels.
25
- *
26
- * The SDK splits each `Secret` BEFORE the wire payload is built (exactly how
27
- * `McpServer` splits `headers` into `secrets.mcpServers`): the env-var name keys
28
- * `submission.secretEnv[name] = toSubmissionEntry()`, and for ephemeral values
29
- * `secrets.envSecrets[name] = toSecretValue()`.
30
- */
31
- export declare class Secret {
32
- #private;
33
- readonly kind: "value" | "ref";
34
- /** Workspace handle (ref kind only); `undefined` for ephemeral values. */
35
- readonly handle: string | undefined;
36
- /** Internal constructor. Use `Secret.value(...)` or `Secret.ref(...)`. */
37
- private constructor();
38
- /** Ephemeral per-session value. Vaulted when the session is created; never in the spec/hash; gone at terminal. */
39
- static value(value: string | SecretString): Secret;
40
- /** Reference a workspace secret by handle; resolved server-side when the session is created. */
41
- static ref(handle: string): Secret;
42
- /** Non-secret wire entry for `submission.secretEnv[<envName>]`. */
43
- toSubmissionEntry(): SecretEnvSubmissionEntry;
44
- /** Raw value for the vaulted `secrets.envSecrets[<envName>]` (ephemeral only); `undefined` for refs. */
45
- toSecretValue(): string | undefined;
46
- /** Redacted — never prints the value. */
47
- toString(): string;
48
- /** Redacted — never serialises the value. */
49
- toJSON(): unknown;
50
- }
51
- /**
52
- * Split `secretEnv: Record<envName, Secret>` into the value-free declarations
53
- * (`submission.secretEnv`) and the per-session vaulted values
54
- * (`secrets.envSecrets`). Secret declarations ride
55
- * the hashed submission, ephemeral values ride the secrets channel
56
- * (hash-excluded). Refs contribute only a declaration.
57
- *
58
- * Throws on a non-`Secret` value or an env var name that won't match the
59
- * platform's `SECRET_ENV_NAME_PATTERN`, so the caller gets a precise error at
60
- * the call site instead of an HTTP 400 a round-trip later.
61
- */
62
- export declare function splitSecretEnv(secretEnv: Readonly<Record<string, Secret>> | undefined): {
63
- declarations: Record<string, SecretEnvSubmissionEntry>;
64
- values: Record<string, string>;
65
- };
package/dist/secret.js DELETED
@@ -1,110 +0,0 @@
1
- import { SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SecretString } from "./_contracts/index.js";
2
- /**
3
- * A secret with the SAME lifecycle semantic as `File` / `Instructions`:
4
- * EPHEMERAL per-session by default, or a reference to a persisted workspace
5
- * secret created explicitly through `aex.workspace.secrets.set(...)`.
6
- *
7
- * - `Secret.value(v)` — EPHEMERAL per-session: the value is vaulted when the session is created and
8
- * excluded from the idempotency hash; only a `{ ephemeral: true }`
9
- * placeholder rides the (hashed) submission. Deleted when the session finishes.
10
- * Clean, no workspace dependency. ≙ `File.fromBytes(...)` (a draft).
11
- * - `Secret.ref(handle)` — WORKSPACE: only the handle rides the submission;
12
- * the value is resolved server-side from the workspace secret store. No
13
- * value ever travels.
14
- *
15
- * The SDK splits each `Secret` BEFORE the wire payload is built (exactly how
16
- * `McpServer` splits `headers` into `secrets.mcpServers`): the env-var name keys
17
- * `submission.secretEnv[name] = toSubmissionEntry()`, and for ephemeral values
18
- * `secrets.envSecrets[name] = toSecretValue()`.
19
- */
20
- export class Secret {
21
- kind;
22
- /** Workspace handle (ref kind only); `undefined` for ephemeral values. */
23
- handle;
24
- #value;
25
- /** Internal constructor. Use `Secret.value(...)` or `Secret.ref(...)`. */
26
- constructor(args) {
27
- if (!args || typeof args !== "object") {
28
- throw new Error("Secret: args is required");
29
- }
30
- if (args.kind === "ref") {
31
- if (typeof args.handle !== "string" || !SECRET_HANDLE_PATTERN.test(args.handle)) {
32
- throw new Error(`Secret.ref: handle must match ${SECRET_HANDLE_PATTERN.source}`);
33
- }
34
- this.kind = "ref";
35
- this.handle = args.handle;
36
- this.#value = undefined;
37
- return;
38
- }
39
- this.kind = "value";
40
- this.handle = undefined;
41
- this.#value = args.value;
42
- }
43
- /** Ephemeral per-session value. Vaulted when the session is created; never in the spec/hash; gone at terminal. */
44
- static value(value) {
45
- const wrapped = value instanceof SecretString ? value : new SecretString(value, "secret");
46
- if (!wrapped.unwrap()) {
47
- throw new Error("Secret.value: value must be a non-empty string");
48
- }
49
- return new Secret({ kind: "value", value: wrapped });
50
- }
51
- /** Reference a workspace secret by handle; resolved server-side when the session is created. */
52
- static ref(handle) {
53
- return new Secret({ kind: "ref", handle });
54
- }
55
- /** Non-secret wire entry for `submission.secretEnv[<envName>]`. */
56
- toSubmissionEntry() {
57
- if (this.kind === "ref") {
58
- return { ref: this.handle };
59
- }
60
- return { ephemeral: true };
61
- }
62
- /** Raw value for the vaulted `secrets.envSecrets[<envName>]` (ephemeral only); `undefined` for refs. */
63
- toSecretValue() {
64
- if (this.kind === "ref") {
65
- return undefined;
66
- }
67
- return this.#value?.unwrap();
68
- }
69
- /** Redacted — never prints the value. */
70
- toString() {
71
- return this.kind === "ref" ? `Secret.ref(${this.handle})` : "Secret.value([REDACTED])";
72
- }
73
- /** Redacted — never serialises the value. */
74
- toJSON() {
75
- return this.kind === "ref" ? { kind: "ref", handle: this.handle } : { kind: "value", value: "[REDACTED]" };
76
- }
77
- }
78
- /**
79
- * Split `secretEnv: Record<envName, Secret>` into the value-free declarations
80
- * (`submission.secretEnv`) and the per-session vaulted values
81
- * (`secrets.envSecrets`). Secret declarations ride
82
- * the hashed submission, ephemeral values ride the secrets channel
83
- * (hash-excluded). Refs contribute only a declaration.
84
- *
85
- * Throws on a non-`Secret` value or an env var name that won't match the
86
- * platform's `SECRET_ENV_NAME_PATTERN`, so the caller gets a precise error at
87
- * the call site instead of an HTTP 400 a round-trip later.
88
- */
89
- export function splitSecretEnv(secretEnv) {
90
- const declarations = {};
91
- const values = {};
92
- if (!secretEnv) {
93
- return { declarations, values };
94
- }
95
- for (const [envName, secret] of Object.entries(secretEnv)) {
96
- if (!(secret instanceof Secret)) {
97
- throw new TypeError(`secretEnv[${envName}] must be a Secret built via Secret.value(...) or Secret.ref(...)`);
98
- }
99
- if (!SECRET_ENV_NAME_PATTERN.test(envName)) {
100
- throw new Error(`secretEnv key ${JSON.stringify(envName)} must be a valid env var name matching ${SECRET_ENV_NAME_PATTERN.source}`);
101
- }
102
- declarations[envName] = secret.toSubmissionEntry();
103
- const value = secret.toSecretValue();
104
- if (value !== undefined) {
105
- values[envName] = value;
106
- }
107
- }
108
- return { declarations, values };
109
- }
110
- //# sourceMappingURL=secret.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secret.js","sourceRoot":"","sources":["../src/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhG;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,MAAM;IACR,IAAI,CAAkB;IAC/B,0EAA0E;IACjE,MAAM,CAAqB;IAC3B,MAAM,CAA2B;IAE1C,0EAA0E;IAC1E,YAAoB,IAAkH;QACpI,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChF,MAAM,IAAI,KAAK,CAAC,iCAAiC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC;YACnF,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;YAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YACxB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,kHAAkH;IAClH,MAAM,CAAC,KAAK,CAAC,KAA4B;QACvC,MAAM,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AAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAC7G,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,SAAuD;IAIpF,MAAM,YAAY,GAA6C,EAAE,CAAC;IAClE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IACD,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CACjB,aAAa,OAAO,mEAAmE,CACxF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,0CAA0C,uBAAuB,CAAC,MAAM,EAAE,CACnH,CAAC;QACJ,CAAC;QACD,YAAY,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC"}
@@ -1,100 +0,0 @@
1
- import { SessionConfigValidationError, type ApprovalGate, type PlatformNetworking, type PlatformPackageInput, type ResponseFormat, type SessionRuntime, type SubmissionAssets, type WorkspaceFileRecord, type WorkspaceInstructionRecord, type WorkspaceSkillRecord, type WorkspaceToolRecord } from "./_contracts/index.js";
2
- import type { SessionCreateOptions, SessionEnvironmentOptions, SessionInput, SessionOverrides, SessionSendOptions, SessionStartOptions, StartSessionOptions } from "./client-types.js";
3
- type ExactKeys<Shape, Keys extends PropertyKey> = [
4
- Exclude<keyof Shape, Keys>
5
- ] extends [never] ? [Exclude<Keys, keyof Shape>] extends [never] ? true : false : false;
6
- /** Package-private compile-time proof that a runtime tuple's key set equals the public shape. */
7
- export type ExactKeySet<Shape, Keys extends readonly PropertyKey[]> = ExactKeys<Shape, Keys[number]>;
8
- type Assert<T extends true> = T;
9
- declare const SESSION_CREATE_KEYS: readonly ["model", "system", "assets", "mcpServers", "fileCapture", "builtinTools", "outputMode", "responseFormat", "approvalGate", "metadata", "idempotencyKey", "environment", "runtime", "overrides", "webhook"];
10
- type SessionCreateKeysAreExact = Assert<ExactKeySet<SessionCreateOptions, typeof SESSION_CREATE_KEYS>>;
11
- declare const SESSION_START_KEYS: readonly ["model", "system", "assets", "mcpServers", "fileCapture", "builtinTools", "outputMode", "responseFormat", "approvalGate", "metadata", "idempotencyKey", "environment", "runtime", "overrides", "webhook", "message", "deleteAfter", "messageIdempotencyKey", "stream"];
12
- type SessionStartKeysAreExact = Assert<ExactKeySet<SessionStartOptions, typeof SESSION_START_KEYS>>;
13
- declare const START_CONTROL_KEYS: readonly ["timeoutMs", "webSocketFactory", "idleTimeoutMs", "pingIntervalMs", "throwOnFailure"];
14
- type StartControlKeysAreExact = Assert<ExactKeySet<StartSessionOptions, typeof START_CONTROL_KEYS>>;
15
- declare const SESSION_SEND_KEYS: readonly ["webSocketFactory", "idleTimeoutMs", "pingIntervalMs", "idempotencyKey"];
16
- type SessionSendKeysAreExact = Assert<ExactKeySet<SessionSendOptions, typeof SESSION_SEND_KEYS>>;
17
- type SessionStreamOptions = Omit<SessionSendOptions, "idempotencyKey">;
18
- declare const SESSION_STREAM_KEYS: readonly ["webSocketFactory", "idleTimeoutMs", "pingIntervalMs"];
19
- type SessionStreamKeysAreExact = Assert<ExactKeySet<SessionStreamOptions, typeof SESSION_STREAM_KEYS>>;
20
- declare const SESSION_OVERRIDE_KEYS: readonly ["idleTtl", "timeout", "maxSpendUsd", "maxTurns"];
21
- type SessionOverrideKeysAreExact = Assert<ExactKeySet<SessionOverrides, typeof SESSION_OVERRIDE_KEYS>>;
22
- declare const SESSION_RUNTIME_KEYS: readonly ["kind", "size"];
23
- type SessionRuntimeKeysAreExact = Assert<ExactKeySet<SessionRuntime, typeof SESSION_RUNTIME_KEYS>>;
24
- type FileCaptureOptions = NonNullable<SessionCreateOptions["fileCapture"]>;
25
- declare const FILE_CAPTURE_KEYS: readonly ["allowedDirs", "deniedDirs", "captureTimeoutMs", "maxFileBytes", "maxTotalBytes", "maxFiles"];
26
- type FileCaptureKeysAreExact = Assert<ExactKeySet<FileCaptureOptions, typeof FILE_CAPTURE_KEYS>>;
27
- type SessionWebhookOptions = NonNullable<SessionCreateOptions["webhook"]>;
28
- declare const SESSION_WEBHOOK_KEYS: readonly ["url"];
29
- type SessionWebhookKeysAreExact = Assert<ExactKeySet<SessionWebhookOptions, typeof SESSION_WEBHOOK_KEYS>>;
30
- declare const SESSION_ENVIRONMENT_KEYS: readonly ["networking", "packages", "variables", "secrets"];
31
- type SessionEnvironmentKeysAreExact = Assert<ExactKeySet<SessionEnvironmentOptions, typeof SESSION_ENVIRONMENT_KEYS>>;
32
- declare const PLATFORM_NETWORKING_KEYS: readonly ["mode", "allowedHosts"];
33
- type PlatformNetworkingKeysAreExact = Assert<ExactKeySet<PlatformNetworking, typeof PLATFORM_NETWORKING_KEYS>>;
34
- declare const PLATFORM_PACKAGE_INPUT_KEYS: readonly ["name", "version"];
35
- type PlatformPackageInputKeysAreExact = Assert<ExactKeySet<PlatformPackageInput, typeof PLATFORM_PACKAGE_INPUT_KEYS>>;
36
- type TextResponseFormat = Extract<ResponseFormat, {
37
- readonly kind: "text";
38
- }>;
39
- declare const TEXT_RESPONSE_FORMAT_KEYS: readonly ["kind"];
40
- type TextResponseFormatKeysAreExact = Assert<ExactKeySet<TextResponseFormat, typeof TEXT_RESPONSE_FORMAT_KEYS>>;
41
- type JsonSchemaResponseFormat = Extract<ResponseFormat, {
42
- readonly kind: "json_schema";
43
- }>;
44
- declare const JSON_SCHEMA_RESPONSE_FORMAT_KEYS: readonly ["kind", "schema", "strict", "name"];
45
- type JsonSchemaResponseFormatKeysAreExact = Assert<ExactKeySet<JsonSchemaResponseFormat, typeof JSON_SCHEMA_RESPONSE_FORMAT_KEYS>>;
46
- declare const APPROVAL_GATE_KEYS: readonly ["tools"];
47
- type ApprovalGateKeysAreExact = Assert<ExactKeySet<ApprovalGate, typeof APPROVAL_GATE_KEYS>>;
48
- declare const ASSET_CATEGORY_KEYS: readonly ["files", "skills", "tools", "instructions"];
49
- type AssetCategoryKeysAreExact = Assert<ExactKeySet<SubmissionAssets, typeof ASSET_CATEGORY_KEYS>>;
50
- declare const ASSET_ITEM_KEYS: {
51
- readonly files: readonly ["kind", "resourceId", "version", "assetId", "contentHash", "createdAt", "updatedAt", "sizeBytes", "contentType", "name", "mountPath"];
52
- readonly skills: readonly ["kind", "resourceId", "version", "assetId", "contentHash", "createdAt", "updatedAt", "sizeBytes", "contentType", "name", "description"];
53
- readonly tools: readonly ["kind", "resourceId", "version", "assetId", "contentHash", "createdAt", "updatedAt", "sizeBytes", "contentType", "name", "description", "input_schema", "entry"];
54
- readonly instructions: readonly ["kind", "resourceId", "version", "assetId", "contentHash", "createdAt", "updatedAt", "sizeBytes", "contentType", "name"];
55
- };
56
- type AssetFileKeysAreExact = Assert<ExactKeySet<WorkspaceFileRecord, typeof ASSET_ITEM_KEYS.files>>;
57
- type AssetSkillKeysAreExact = Assert<ExactKeySet<WorkspaceSkillRecord, typeof ASSET_ITEM_KEYS.skills>>;
58
- type AssetToolKeysAreExact = Assert<ExactKeySet<WorkspaceToolRecord, typeof ASSET_ITEM_KEYS.tools>>;
59
- type AssetInstructionKeysAreExact = Assert<ExactKeySet<WorkspaceInstructionRecord, typeof ASSET_ITEM_KEYS.instructions>>;
60
- export type SessionOptionKeyAssertions = readonly [
61
- SessionCreateKeysAreExact,
62
- SessionStartKeysAreExact,
63
- StartControlKeysAreExact,
64
- SessionSendKeysAreExact,
65
- SessionStreamKeysAreExact,
66
- SessionOverrideKeysAreExact,
67
- SessionRuntimeKeysAreExact,
68
- FileCaptureKeysAreExact,
69
- SessionWebhookKeysAreExact,
70
- SessionEnvironmentKeysAreExact,
71
- PlatformNetworkingKeysAreExact,
72
- PlatformPackageInputKeysAreExact,
73
- TextResponseFormatKeysAreExact,
74
- JsonSchemaResponseFormatKeysAreExact,
75
- ApprovalGateKeysAreExact,
76
- AssetCategoryKeysAreExact,
77
- AssetFileKeysAreExact,
78
- AssetSkillKeysAreExact,
79
- AssetToolKeysAreExact,
80
- AssetInstructionKeysAreExact
81
- ];
82
- export type SessionConfigDiagnosticPolicy = {
83
- readonly kind: "scalar";
84
- readonly rejectedValues: readonly unknown[];
85
- } | {
86
- readonly kind: "redacted";
87
- };
88
- /** Package-private catch-and-translate owner for canonical session validators. */
89
- export declare function validatedSessionConfig<T>(surface: string, field: string, message: string, validate: () => T, policy: SessionConfigDiagnosticPolicy): T;
90
- /**
91
- * Package-private factory for SDK validation errors. `details.field` is the only
92
- * stable machine-readable payload; messages are human guidance and may change.
93
- */
94
- export declare function configError(surface: string, field: string, message: string, cause?: Error): SessionConfigValidationError;
95
- export declare function normaliseSessionInput(input: SessionInput, surface: string, field: string): SessionInput;
96
- export declare function assertSupportedSessionFields(options: SessionCreateOptions, surface: string, allowStartFields: boolean): void;
97
- export declare function assertSupportedSessionSendOptions(options: unknown, surface: string, allowIdempotencyKey?: boolean): void;
98
- export declare function assertStartSessionOptions(options: unknown, surface: string): void;
99
- export declare function assertAllowedObjectFields(value: unknown, surface: string, field: string, allowed: readonly string[]): Record<string, unknown> | undefined;
100
- export {};