@aexhq/sdk 0.33.1 → 0.35.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 (81) hide show
  1. package/README.md +19 -27
  2. package/dist/_contracts/operations.d.ts +2 -54
  3. package/dist/_contracts/operations.js +2 -87
  4. package/dist/_contracts/run-config.d.ts +19 -13
  5. package/dist/_contracts/run-config.js +6 -33
  6. package/dist/_contracts/run-unit.d.ts +1 -33
  7. package/dist/_contracts/run-unit.js +2 -21
  8. package/dist/_contracts/runtime-sizes.d.ts +2 -2
  9. package/dist/_contracts/runtime-sizes.js +2 -2
  10. package/dist/_contracts/status.d.ts +2 -2
  11. package/dist/_contracts/status.js +3 -0
  12. package/dist/_contracts/submission.d.ts +80 -41
  13. package/dist/_contracts/submission.js +114 -52
  14. package/dist/agents-md.d.ts +5 -5
  15. package/dist/agents-md.js +7 -7
  16. package/dist/agents-md.js.map +1 -1
  17. package/dist/asset-upload.d.ts +4 -4
  18. package/dist/asset-upload.js +4 -4
  19. package/dist/bundle.d.ts +2 -2
  20. package/dist/bundle.js +2 -2
  21. package/dist/cli.mjs +369 -12918
  22. package/dist/cli.mjs.sha256 +1 -1
  23. package/dist/client.d.ts +234 -383
  24. package/dist/client.js +436 -648
  25. package/dist/client.js.map +1 -1
  26. package/dist/data-tools.d.ts +25 -22
  27. package/dist/data-tools.js +75 -62
  28. package/dist/data-tools.js.map +1 -1
  29. package/dist/fetch-archive.js +16 -16
  30. package/dist/fetch-archive.js.map +1 -1
  31. package/dist/file.d.ts +5 -5
  32. package/dist/file.js +7 -7
  33. package/dist/file.js.map +1 -1
  34. package/dist/index.d.ts +11 -9
  35. package/dist/index.js +20 -13
  36. package/dist/index.js.map +1 -1
  37. package/dist/mcp-server.d.ts +4 -4
  38. package/dist/mcp-server.js +4 -4
  39. package/dist/proxy-endpoint.d.ts +4 -4
  40. package/dist/proxy-endpoint.js +1 -1
  41. package/dist/retry.d.ts +162 -0
  42. package/dist/retry.js +320 -0
  43. package/dist/retry.js.map +1 -0
  44. package/dist/secret.d.ts +8 -8
  45. package/dist/secret.js +8 -8
  46. package/dist/secret.js.map +1 -1
  47. package/dist/skill-tool.d.ts +102 -0
  48. package/dist/skill-tool.js +190 -0
  49. package/dist/skill-tool.js.map +1 -0
  50. package/dist/tool.d.ts +1 -1
  51. package/dist/tool.js +3 -3
  52. package/dist/tool.js.map +1 -1
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/docs/cleanup.md +3 -3
  56. package/docs/concepts/agent-tools.md +6 -25
  57. package/docs/concepts/composition.md +15 -12
  58. package/docs/concepts/providers-and-runtimes.md +3 -3
  59. package/docs/concepts/runs.md +27 -22
  60. package/docs/credentials.md +52 -84
  61. package/docs/defaults.md +6 -6
  62. package/docs/events.md +65 -44
  63. package/docs/limits-and-quotas.md +3 -4
  64. package/docs/mcp.md +3 -3
  65. package/docs/networking.md +8 -8
  66. package/docs/outputs.md +44 -40
  67. package/docs/provider-runtime-capabilities.md +1 -1
  68. package/docs/public-surface.json +2 -2
  69. package/docs/quickstart.md +20 -10
  70. package/docs/retries.md +129 -0
  71. package/docs/run-config.md +12 -14
  72. package/docs/run-record.md +8 -8
  73. package/docs/secrets.md +16 -26
  74. package/docs/skills.md +55 -110
  75. package/docs/vision-skills.md +29 -40
  76. package/examples/chat-corpus.ts +8 -9
  77. package/examples/feature-tour.ts +301 -0
  78. package/package.json +1 -1
  79. package/dist/skill.d.ts +0 -149
  80. package/dist/skill.js +0 -198
  81. package/dist/skill.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Built-in transport resilience for the aex SDK.
3
+ *
4
+ * Every BFF-bound request the SDK makes goes through one {@link FetchLike}. This
5
+ * module wraps that fetch so a transient failure — an HTTP 429 (rate limited),
6
+ * a 500/502/503/504 (server hiccup), a 529 (upstream overloaded), or a network
7
+ * error — is retried with BOUNDED exponential backoff + full jitter, honoring
8
+ * the server's `Retry-After` header when present. Non-retryable 4xx responses
9
+ * (400/401/403/404/…) fail fast — retrying them only wastes the caller's time.
10
+ *
11
+ * Retries are SAFE to enable by default because the billable submits
12
+ * (`createSession` / `sendSessionMessage`) carry a stable `Idempotency-Key`
13
+ * header: re-sending the identical request de-duplicates server-side, so a retry
14
+ * never creates a duplicate billable turn.
15
+ *
16
+ * When retries are exhausted on a rate-limit / overloaded status the wrapper
17
+ * surfaces an {@link AexRateLimitError} — a structured, non-leaky throttle error
18
+ * carrying the parsed `retryAfterMs`, the attempt count, and (when the runtime
19
+ * supplies it) an upstream {@link ProviderFault}. All other exhausted retries
20
+ * fall through to the transport's usual `AexApiError` / network rejection.
21
+ */
22
+ import { AexApiError, type FetchLike } from "./_contracts/index.js";
23
+ /**
24
+ * HTTP statuses that are transient and worth retrying. The billable submits
25
+ * carry an idempotency key, so re-issuing them is safe. Everything not in this
26
+ * set (400/401/403/404/409/422/…) is a definitive client error and fails fast.
27
+ */
28
+ export declare const RETRYABLE_STATUS: readonly number[];
29
+ /**
30
+ * The subset of {@link RETRYABLE_STATUS} the platform / upstream provider uses to
31
+ * say "slow down": 429 rate-limit, 503 unavailable, 529 overloaded. When retries
32
+ * for one of these run out, the wrapper raises an {@link AexRateLimitError}.
33
+ */
34
+ export declare const RATE_LIMIT_STATUS: readonly number[];
35
+ /**
36
+ * Tunes the built-in retry loop. All fields are optional; omit the whole
37
+ * `retry` option (or pass `retry: false` on the client) to accept the defaults
38
+ * or turn the loop off entirely.
39
+ */
40
+ export interface RetryOptions {
41
+ /**
42
+ * Maximum attempts INCLUDING the first try. Default `4` (one try + three
43
+ * retries). `1` performs a single attempt with no retries (but still maps a
44
+ * final rate-limit status to {@link AexRateLimitError}).
45
+ */
46
+ readonly maxAttempts?: number;
47
+ /**
48
+ * Base delay (ms) for the exponential backoff — the nominal wait before the
49
+ * first retry, doubling each subsequent retry. Default `500`.
50
+ */
51
+ readonly initialDelayMs?: number;
52
+ /** Upper bound (ms) on any single backoff wait. Default `20_000`. */
53
+ readonly maxDelayMs?: number;
54
+ /**
55
+ * Overall wall-clock budget (ms) across all attempts. Once the next backoff
56
+ * would push past this, the loop stops and surfaces the last error. Default
57
+ * `120_000`.
58
+ */
59
+ readonly maxElapsedMs?: number;
60
+ }
61
+ interface ResolvedRetryConfig {
62
+ readonly maxAttempts: number;
63
+ readonly initialDelayMs: number;
64
+ readonly maxDelayMs: number;
65
+ readonly maxElapsedMs: number;
66
+ }
67
+ /** Resolve caller options over the defaults, clamping to sane bounds. */
68
+ export declare function resolveRetryConfig(options: RetryOptions | undefined): ResolvedRetryConfig;
69
+ export declare function isRetryableStatus(status: number): boolean;
70
+ export declare function isRateLimitStatus(status: number): boolean;
71
+ /**
72
+ * Parse an HTTP `Retry-After` header into milliseconds. Per RFC 7231 the value
73
+ * is either a non-negative integer number of seconds or an HTTP-date; both are
74
+ * handled. Returns `undefined` for a missing or unparseable value.
75
+ */
76
+ export declare function parseRetryAfterMs(headerValue: string | null | undefined, now?: number): number | undefined;
77
+ /**
78
+ * Full-jitter exponential backoff (AWS-style): the nominal wait doubles per
79
+ * retry up to `maxDelayMs`, and the actual wait is a uniform sample in
80
+ * `[0, nominal]` to de-correlate concurrent clients. `attemptNumber` is the
81
+ * 1-based number of the attempt that just failed.
82
+ */
83
+ export declare function computeBackoffDelayMs(config: ResolvedRetryConfig, attemptNumber: number, random: () => number): number;
84
+ /**
85
+ * A structured, redaction-safe description of an UPSTREAM provider fault the aex
86
+ * runtime surfaces on a failed turn (a rate limit, an overloaded provider, a
87
+ * quota exhaustion, or a generic provider error). It is a sibling of the
88
+ * API-plane throttle: the container/runtime emits this shape on the terminal
89
+ * error and the SDK re-exposes it on {@link AexRateLimitError.providerFault} so
90
+ * callers get one place to read "the model provider throttled us".
91
+ */
92
+ export interface ProviderFault {
93
+ /** Upstream provider id, e.g. `"anthropic"`, when the runtime reports one. */
94
+ readonly provider?: string;
95
+ /** Coarse fault class. */
96
+ readonly kind: "rate_limit" | "overloaded" | "quota_exceeded" | "provider_error";
97
+ /** Upstream HTTP status when the provider surfaced one (e.g. `429`, `529`). */
98
+ readonly status?: number;
99
+ /** Milliseconds the upstream asked the caller to wait, when it supplied one. */
100
+ readonly retryAfterMs?: number;
101
+ /** Short, already-redacted upstream message. */
102
+ readonly message?: string;
103
+ }
104
+ /** True when a {@link ProviderFault} represents a "back off and retry" signal. */
105
+ export declare function isThrottleFault(fault: ProviderFault): boolean;
106
+ /**
107
+ * Structured throttle error. Extends {@link AexApiError} so existing
108
+ * `catch (err instanceof AexApiError)` sites keep working, while callers that
109
+ * want the details narrow with {@link isRateLimited} and read `retryAfterMs`,
110
+ * `attempts`, `source`, and `providerFault`. The `message` is a fixed,
111
+ * non-leaky summary — it never echoes the raw error body (which is still
112
+ * available, redacted, on `.body`).
113
+ */
114
+ export declare class AexRateLimitError extends AexApiError {
115
+ /** Milliseconds the server/provider asked us to wait, when known. */
116
+ readonly retryAfterMs?: number;
117
+ /** How many attempts were made before giving up. */
118
+ readonly attempts: number;
119
+ /** Whether the throttle came from the aex API plane or the upstream provider. */
120
+ readonly source: "api" | "provider";
121
+ /** The upstream provider fault, when the throttle originated there. */
122
+ readonly providerFault?: ProviderFault;
123
+ constructor(args: {
124
+ readonly status: number;
125
+ readonly attempts: number;
126
+ readonly retryAfterMs?: number;
127
+ readonly source?: "api" | "provider";
128
+ readonly providerFault?: ProviderFault;
129
+ readonly body?: unknown;
130
+ readonly message?: string;
131
+ });
132
+ }
133
+ /** Type guard for {@link AexRateLimitError}. */
134
+ export declare function isRateLimited(err: unknown): err is AexRateLimitError;
135
+ /**
136
+ * Best-effort parse of an unknown value into a {@link ProviderFault}. Tolerant
137
+ * of two shapes so the SDK consumes the runtime fault the moment it starts
138
+ * emitting one, without a contracts change:
139
+ *
140
+ * 1. The canonical `{ provider?, kind, status?, retryAfterMs?, message? }`
141
+ * (optionally nested under a `providerFault` key), OR
142
+ * 2. A raw upstream error `{ type: "rate_limit_error" | "overloaded_error"
143
+ * | ..., message?, retry_after? | retryAfter? }` — `type` maps to `kind`
144
+ * and `retry_after` (seconds) maps to `retryAfterMs`.
145
+ *
146
+ * Returns `undefined` when the value carries no recognizable fault.
147
+ */
148
+ export declare function parseProviderFault(value: unknown): ProviderFault | undefined;
149
+ /** Hooks the retry loop needs, injectable so tests run without real timers. */
150
+ export interface RetryDeps {
151
+ readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
152
+ readonly random?: () => number;
153
+ readonly now?: () => number;
154
+ }
155
+ /**
156
+ * Wrap a {@link FetchLike} with the bounded-retry loop. `retry === false`
157
+ * disables the layer entirely (the input fetch is returned unchanged). Otherwise
158
+ * the returned fetch retries transient failures per {@link RetryOptions} and, on
159
+ * an exhausted rate-limit/overloaded status, throws {@link AexRateLimitError}.
160
+ */
161
+ export declare function withRetry(fetchImpl: FetchLike, retry: RetryOptions | false | undefined, deps?: RetryDeps): FetchLike;
162
+ export {};
package/dist/retry.js ADDED
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Built-in transport resilience for the aex SDK.
3
+ *
4
+ * Every BFF-bound request the SDK makes goes through one {@link FetchLike}. This
5
+ * module wraps that fetch so a transient failure — an HTTP 429 (rate limited),
6
+ * a 500/502/503/504 (server hiccup), a 529 (upstream overloaded), or a network
7
+ * error — is retried with BOUNDED exponential backoff + full jitter, honoring
8
+ * the server's `Retry-After` header when present. Non-retryable 4xx responses
9
+ * (400/401/403/404/…) fail fast — retrying them only wastes the caller's time.
10
+ *
11
+ * Retries are SAFE to enable by default because the billable submits
12
+ * (`createSession` / `sendSessionMessage`) carry a stable `Idempotency-Key`
13
+ * header: re-sending the identical request de-duplicates server-side, so a retry
14
+ * never creates a duplicate billable turn.
15
+ *
16
+ * When retries are exhausted on a rate-limit / overloaded status the wrapper
17
+ * surfaces an {@link AexRateLimitError} — a structured, non-leaky throttle error
18
+ * carrying the parsed `retryAfterMs`, the attempt count, and (when the runtime
19
+ * supplies it) an upstream {@link ProviderFault}. All other exhausted retries
20
+ * fall through to the transport's usual `AexApiError` / network rejection.
21
+ */
22
+ import { AexApiError } from "./_contracts/index.js";
23
+ /**
24
+ * HTTP statuses that are transient and worth retrying. The billable submits
25
+ * carry an idempotency key, so re-issuing them is safe. Everything not in this
26
+ * set (400/401/403/404/409/422/…) is a definitive client error and fails fast.
27
+ */
28
+ export const RETRYABLE_STATUS = [429, 500, 502, 503, 504, 529];
29
+ /**
30
+ * The subset of {@link RETRYABLE_STATUS} the platform / upstream provider uses to
31
+ * say "slow down": 429 rate-limit, 503 unavailable, 529 overloaded. When retries
32
+ * for one of these run out, the wrapper raises an {@link AexRateLimitError}.
33
+ */
34
+ export const RATE_LIMIT_STATUS = [429, 503, 529];
35
+ const DEFAULT_RETRY = {
36
+ maxAttempts: 4,
37
+ initialDelayMs: 500,
38
+ maxDelayMs: 20_000,
39
+ maxElapsedMs: 120_000
40
+ };
41
+ /** Resolve caller options over the defaults, clamping to sane bounds. */
42
+ export function resolveRetryConfig(options) {
43
+ const maxAttempts = Math.max(1, Math.floor(options?.maxAttempts ?? DEFAULT_RETRY.maxAttempts));
44
+ const initialDelayMs = Math.max(0, options?.initialDelayMs ?? DEFAULT_RETRY.initialDelayMs);
45
+ const maxDelayMs = Math.max(initialDelayMs, options?.maxDelayMs ?? DEFAULT_RETRY.maxDelayMs);
46
+ const maxElapsedMs = Math.max(0, options?.maxElapsedMs ?? DEFAULT_RETRY.maxElapsedMs);
47
+ return { maxAttempts, initialDelayMs, maxDelayMs, maxElapsedMs };
48
+ }
49
+ export function isRetryableStatus(status) {
50
+ return RETRYABLE_STATUS.includes(status);
51
+ }
52
+ export function isRateLimitStatus(status) {
53
+ return RATE_LIMIT_STATUS.includes(status);
54
+ }
55
+ /**
56
+ * Parse an HTTP `Retry-After` header into milliseconds. Per RFC 7231 the value
57
+ * is either a non-negative integer number of seconds or an HTTP-date; both are
58
+ * handled. Returns `undefined` for a missing or unparseable value.
59
+ */
60
+ export function parseRetryAfterMs(headerValue, now = Date.now()) {
61
+ if (headerValue === null || headerValue === undefined)
62
+ return undefined;
63
+ const trimmed = headerValue.trim();
64
+ if (trimmed.length === 0)
65
+ return undefined;
66
+ if (/^\d+$/.test(trimmed)) {
67
+ return Number(trimmed) * 1000;
68
+ }
69
+ const dateMs = Date.parse(trimmed);
70
+ if (!Number.isNaN(dateMs)) {
71
+ return Math.max(0, dateMs - now);
72
+ }
73
+ return undefined;
74
+ }
75
+ /**
76
+ * Full-jitter exponential backoff (AWS-style): the nominal wait doubles per
77
+ * retry up to `maxDelayMs`, and the actual wait is a uniform sample in
78
+ * `[0, nominal]` to de-correlate concurrent clients. `attemptNumber` is the
79
+ * 1-based number of the attempt that just failed.
80
+ */
81
+ export function computeBackoffDelayMs(config, attemptNumber, random) {
82
+ const exponent = Math.max(0, attemptNumber - 1);
83
+ const nominal = Math.min(config.maxDelayMs, config.initialDelayMs * 2 ** exponent);
84
+ return Math.round(random() * nominal);
85
+ }
86
+ /** Combine the server's `Retry-After` (a floor) with our jittered backoff. */
87
+ function nextDelayMs(config, attemptNumber, random, retryAfterMs) {
88
+ const backoff = computeBackoffDelayMs(config, attemptNumber, random);
89
+ return retryAfterMs === undefined ? backoff : Math.max(retryAfterMs, backoff);
90
+ }
91
+ const THROTTLE_KINDS = new Set(["rate_limit", "overloaded", "quota_exceeded"]);
92
+ /** True when a {@link ProviderFault} represents a "back off and retry" signal. */
93
+ export function isThrottleFault(fault) {
94
+ return THROTTLE_KINDS.has(fault.kind);
95
+ }
96
+ /**
97
+ * Structured throttle error. Extends {@link AexApiError} so existing
98
+ * `catch (err instanceof AexApiError)` sites keep working, while callers that
99
+ * want the details narrow with {@link isRateLimited} and read `retryAfterMs`,
100
+ * `attempts`, `source`, and `providerFault`. The `message` is a fixed,
101
+ * non-leaky summary — it never echoes the raw error body (which is still
102
+ * available, redacted, on `.body`).
103
+ */
104
+ export class AexRateLimitError extends AexApiError {
105
+ /** Milliseconds the server/provider asked us to wait, when known. */
106
+ retryAfterMs;
107
+ /** How many attempts were made before giving up. */
108
+ attempts;
109
+ /** Whether the throttle came from the aex API plane or the upstream provider. */
110
+ source;
111
+ /** The upstream provider fault, when the throttle originated there. */
112
+ providerFault;
113
+ constructor(args) {
114
+ super(args.status, args.message ?? defaultThrottleMessage(args), args.body);
115
+ this.attempts = args.attempts;
116
+ this.source = args.source ?? "api";
117
+ if (args.retryAfterMs !== undefined)
118
+ this.retryAfterMs = args.retryAfterMs;
119
+ if (args.providerFault !== undefined)
120
+ this.providerFault = args.providerFault;
121
+ }
122
+ }
123
+ /** Type guard for {@link AexRateLimitError}. */
124
+ export function isRateLimited(err) {
125
+ return err instanceof AexRateLimitError;
126
+ }
127
+ function defaultThrottleMessage(args) {
128
+ const who = args.source === "provider" ? "upstream provider" : "aex API";
129
+ const label = args.status === 529 ? "overloaded" : "rate limit reached";
130
+ const attempts = `${args.attempts} attempt${args.attempts === 1 ? "" : "s"}`;
131
+ const wait = args.retryAfterMs !== undefined
132
+ ? `; retry after ~${Math.ceil(args.retryAfterMs / 1000)}s`
133
+ : "";
134
+ return `${who} ${label} (HTTP ${args.status}) after ${attempts}${wait}`;
135
+ }
136
+ /**
137
+ * Best-effort parse of an unknown value into a {@link ProviderFault}. Tolerant
138
+ * of two shapes so the SDK consumes the runtime fault the moment it starts
139
+ * emitting one, without a contracts change:
140
+ *
141
+ * 1. The canonical `{ provider?, kind, status?, retryAfterMs?, message? }`
142
+ * (optionally nested under a `providerFault` key), OR
143
+ * 2. A raw upstream error `{ type: "rate_limit_error" | "overloaded_error"
144
+ * | ..., message?, retry_after? | retryAfter? }` — `type` maps to `kind`
145
+ * and `retry_after` (seconds) maps to `retryAfterMs`.
146
+ *
147
+ * Returns `undefined` when the value carries no recognizable fault.
148
+ */
149
+ export function parseProviderFault(value) {
150
+ if (value === null || typeof value !== "object")
151
+ return undefined;
152
+ const record = value;
153
+ const nested = record.providerFault ?? record.provider_fault;
154
+ if (nested !== undefined && nested !== value) {
155
+ const fromNested = parseProviderFault(nested);
156
+ if (fromNested)
157
+ return fromNested;
158
+ }
159
+ const kind = coerceFaultKind(record.kind ?? record.type ?? record.code);
160
+ if (kind === undefined)
161
+ return undefined;
162
+ const provider = typeof record.provider === "string" ? record.provider : undefined;
163
+ const status = coerceStatus(record.status ?? record.statusCode ?? record.httpStatus);
164
+ const retryAfterMs = coerceRetryAfterMs(record.retryAfterMs ?? record.retry_after_ms ?? record.retryAfter ?? record.retry_after);
165
+ const message = typeof record.message === "string" ? record.message : undefined;
166
+ return {
167
+ kind,
168
+ ...(provider !== undefined ? { provider } : {}),
169
+ ...(status !== undefined ? { status } : {}),
170
+ ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
171
+ ...(message !== undefined ? { message } : {})
172
+ };
173
+ }
174
+ function coerceFaultKind(raw) {
175
+ if (typeof raw !== "string")
176
+ return undefined;
177
+ const value = raw.toLowerCase();
178
+ if (value.includes("rate_limit") || value.includes("rate limit") || value === "429")
179
+ return "rate_limit";
180
+ if (value.includes("overload") || value === "529")
181
+ return "overloaded";
182
+ if (value.includes("quota") || value.includes("insufficient"))
183
+ return "quota_exceeded";
184
+ if (value.includes("provider_error") || value.includes("provider error") || value.includes("api_error")) {
185
+ return "provider_error";
186
+ }
187
+ return undefined;
188
+ }
189
+ function coerceStatus(raw) {
190
+ if (typeof raw === "number" && Number.isFinite(raw))
191
+ return raw;
192
+ if (typeof raw === "string" && /^\d+$/.test(raw.trim()))
193
+ return Number(raw.trim());
194
+ return undefined;
195
+ }
196
+ /** Accept a ms number, a `<digits>` string, or seconds under a `retry_after` alias. */
197
+ function coerceRetryAfterMs(raw) {
198
+ if (typeof raw === "number" && Number.isFinite(raw)) {
199
+ // Heuristic: small integers are seconds (the upstream convention), large
200
+ // ones are already milliseconds.
201
+ return raw > 0 && raw < 1000 ? raw * 1000 : raw;
202
+ }
203
+ if (typeof raw === "string" && /^\d+$/.test(raw.trim())) {
204
+ const n = Number(raw.trim());
205
+ return n > 0 && n < 1000 ? n * 1000 : n;
206
+ }
207
+ return undefined;
208
+ }
209
+ const defaultSleep = (ms, signal) => new Promise((resolve, reject) => {
210
+ if (signal?.aborted) {
211
+ reject(signal.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError"));
212
+ return;
213
+ }
214
+ const timer = setTimeout(() => {
215
+ signal?.removeEventListener("abort", onAbort);
216
+ resolve();
217
+ }, ms);
218
+ const onAbort = () => {
219
+ clearTimeout(timer);
220
+ reject(signal?.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError"));
221
+ };
222
+ signal?.addEventListener("abort", onAbort, { once: true });
223
+ });
224
+ function isAbortError(err) {
225
+ return err instanceof Error && err.name === "AbortError";
226
+ }
227
+ async function drain(response) {
228
+ try {
229
+ if (response.body && typeof response.body.cancel === "function") {
230
+ await response.body.cancel();
231
+ return;
232
+ }
233
+ await response.text();
234
+ }
235
+ catch {
236
+ // Draining is best-effort; a discarded retryable response never surfaces.
237
+ }
238
+ }
239
+ async function readBodyForError(response) {
240
+ try {
241
+ const text = await response.text();
242
+ if (text.length === 0)
243
+ return {};
244
+ try {
245
+ return JSON.parse(text);
246
+ }
247
+ catch {
248
+ return { raw: text };
249
+ }
250
+ }
251
+ catch {
252
+ return {};
253
+ }
254
+ }
255
+ /**
256
+ * Wrap a {@link FetchLike} with the bounded-retry loop. `retry === false`
257
+ * disables the layer entirely (the input fetch is returned unchanged). Otherwise
258
+ * the returned fetch retries transient failures per {@link RetryOptions} and, on
259
+ * an exhausted rate-limit/overloaded status, throws {@link AexRateLimitError}.
260
+ */
261
+ export function withRetry(fetchImpl, retry, deps = {}) {
262
+ if (retry === false)
263
+ return fetchImpl;
264
+ const config = resolveRetryConfig(retry);
265
+ const sleep = deps.sleep ?? defaultSleep;
266
+ const random = deps.random ?? Math.random;
267
+ const now = deps.now ?? Date.now;
268
+ return async (input, init) => {
269
+ const startedAt = now();
270
+ const signal = init?.signal ?? undefined;
271
+ let attempt = 0;
272
+ for (;;) {
273
+ attempt += 1;
274
+ let response;
275
+ try {
276
+ response = await fetchImpl(input, init);
277
+ }
278
+ catch (err) {
279
+ // A caller-initiated abort is terminal, never transient.
280
+ if (isAbortError(err))
281
+ throw err;
282
+ if (attempt >= config.maxAttempts)
283
+ throw err;
284
+ const delay = computeBackoffDelayMs(config, attempt, random);
285
+ if (now() - startedAt + delay > config.maxElapsedMs)
286
+ throw err;
287
+ await sleep(delay, signal ?? undefined);
288
+ continue;
289
+ }
290
+ // Success or a definitive (non-retryable) response — hand straight back so
291
+ // the transport reads/throws exactly as it does without the retry layer.
292
+ if (!isRetryableStatus(response.status)) {
293
+ return response;
294
+ }
295
+ const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after"), now());
296
+ const willRetry = attempt < config.maxAttempts &&
297
+ now() - startedAt + nextDelayMs(config, attempt, random, retryAfterMs) <= config.maxElapsedMs;
298
+ if (willRetry) {
299
+ await drain(response);
300
+ await sleep(nextDelayMs(config, attempt, random, retryAfterMs), signal ?? undefined);
301
+ continue;
302
+ }
303
+ // Retries exhausted (or budget spent). A rate-limit/overloaded status
304
+ // becomes a structured throttle error; any other transient status falls
305
+ // through to the transport's normal AexApiError.
306
+ if (isRateLimitStatus(response.status)) {
307
+ const body = await readBodyForError(response);
308
+ throw new AexRateLimitError({
309
+ status: response.status,
310
+ attempts: attempt,
311
+ source: "api",
312
+ ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
313
+ body
314
+ });
315
+ }
316
+ return response;
317
+ }
318
+ };
319
+ }
320
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAElF;;;;GAIG;AACH,MA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E,iDAAiD;YACjD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;gBAC9C,MAAM,IAAI,iBAAiB,CAAC;oBAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,QAAQ,EAAE,OAAO;oBACjB,MAAM,EAAE,KAAK;oBACb,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvD,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/dist/secret.d.ts CHANGED
@@ -26,19 +26,19 @@ export interface SecretUploader {
26
26
  }>;
27
27
  }
28
28
  /**
29
- * A secret with the SAME lifecycle semantic as `Skill` / `File` / `AgentsMd`:
29
+ * A secret with the SAME lifecycle semantic as `File` / `AgentsMd`:
30
30
  * EPHEMERAL per-run by default, PROMOTABLE to a persisted, name-searchable
31
31
  * workspace secret you can reference and reuse.
32
32
  *
33
- * - `Secret.value(v)` — EPHEMERAL per-run: the value is vaulted at submit and
33
+ * - `Secret.value(v)` — EPHEMERAL per-run: the value is vaulted when the session is created and
34
34
  * excluded from the idempotency hash; only a `{ ephemeral: true }`
35
35
  * placeholder rides the (hashed) submission. Deleted when the run finishes.
36
- * Clean, no workspace dependency. ≙ `Skill.fromFiles(...)` (a draft).
36
+ * Clean, no workspace dependency. ≙ `File.fromBytes(...)` (a draft).
37
37
  * - `secret.upload(client, { name })` — PROMOTE that value into the workspace
38
- * secret store under `name`; resolves to a `Secret.ref`. ≙ `skill.upload(client)`.
38
+ * secret store under `name`; resolves to a `Secret.ref`.
39
39
  * - `Secret.ref(handle)` — WORKSPACE: only the handle rides the submission;
40
40
  * the value is resolved server-side from the workspace secret store. No
41
- * value ever travels. ≙ `Skill.fromCatalog(record)`.
41
+ * value ever travels.
42
42
  *
43
43
  * The SDK splits each `Secret` BEFORE the wire payload is built (exactly how
44
44
  * `McpServer` splits `headers` into `secrets.mcpServers`): the env-var name keys
@@ -58,9 +58,9 @@ export declare class Secret {
58
58
  readonly kind: "ref";
59
59
  readonly handle: string;
60
60
  });
61
- /** Ephemeral per-run value. Vaulted at submit; never in the spec/hash; gone at terminal. */
61
+ /** Ephemeral per-run value. Vaulted when the session is created; never in the spec/hash; gone at terminal. */
62
62
  static value(value: string | SecretString): Secret;
63
- /** Reference a workspace secret by handle; resolved server-side at submit. */
63
+ /** Reference a workspace secret by handle; resolved server-side when the session is created. */
64
64
  static ref(handle: string): Secret;
65
65
  /** True once this ephemeral secret has been promoted via `upload`. */
66
66
  get isConsumed(): boolean;
@@ -68,7 +68,7 @@ export declare class Secret {
68
68
  * Promote this EPHEMERAL secret into the workspace secret store under `name`
69
69
  * and return a `Secret.ref(name)` for reuse across runs. Blocking: the store
70
70
  * write completes before this resolves. Consumes this instance (an ephemeral
71
- * value is promoted exactly once), mirroring `Skill.upload`.
71
+ * value is promoted exactly once).
72
72
  *
73
73
  * Only valid on a `Secret.value(...)`; a `Secret.ref(...)` is already
74
74
  * persisted.
package/dist/secret.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SecretString } from "./_contracts/index.js";
2
2
  /**
3
- * A secret with the SAME lifecycle semantic as `Skill` / `File` / `AgentsMd`:
3
+ * A secret with the SAME lifecycle semantic as `File` / `AgentsMd`:
4
4
  * EPHEMERAL per-run by default, PROMOTABLE to a persisted, name-searchable
5
5
  * workspace secret you can reference and reuse.
6
6
  *
7
- * - `Secret.value(v)` — EPHEMERAL per-run: the value is vaulted at submit and
7
+ * - `Secret.value(v)` — EPHEMERAL per-run: the value is vaulted when the session is created and
8
8
  * excluded from the idempotency hash; only a `{ ephemeral: true }`
9
9
  * placeholder rides the (hashed) submission. Deleted when the run finishes.
10
- * Clean, no workspace dependency. ≙ `Skill.fromFiles(...)` (a draft).
10
+ * Clean, no workspace dependency. ≙ `File.fromBytes(...)` (a draft).
11
11
  * - `secret.upload(client, { name })` — PROMOTE that value into the workspace
12
- * secret store under `name`; resolves to a `Secret.ref`. ≙ `skill.upload(client)`.
12
+ * secret store under `name`; resolves to a `Secret.ref`.
13
13
  * - `Secret.ref(handle)` — WORKSPACE: only the handle rides the submission;
14
14
  * the value is resolved server-side from the workspace secret store. No
15
- * value ever travels. ≙ `Skill.fromCatalog(record)`.
15
+ * value ever travels.
16
16
  *
17
17
  * The SDK splits each `Secret` BEFORE the wire payload is built (exactly how
18
18
  * `McpServer` splits `headers` into `secrets.mcpServers`): the env-var name keys
@@ -44,7 +44,7 @@ export class Secret {
44
44
  this.handle = undefined;
45
45
  this.#value = args.value;
46
46
  }
47
- /** Ephemeral per-run value. Vaulted at submit; never in the spec/hash; gone at terminal. */
47
+ /** Ephemeral per-run value. Vaulted when the session is created; never in the spec/hash; gone at terminal. */
48
48
  static value(value) {
49
49
  const wrapped = value instanceof SecretString ? value : new SecretString(value, "secret");
50
50
  if (!wrapped.unwrap()) {
@@ -52,7 +52,7 @@ export class Secret {
52
52
  }
53
53
  return new Secret({ kind: "value", value: wrapped });
54
54
  }
55
- /** Reference a workspace secret by handle; resolved server-side at submit. */
55
+ /** Reference a workspace secret by handle; resolved server-side when the session is created. */
56
56
  static ref(handle) {
57
57
  return new Secret({ kind: "ref", handle });
58
58
  }
@@ -64,7 +64,7 @@ export class Secret {
64
64
  * Promote this EPHEMERAL secret into the workspace secret store under `name`
65
65
  * and return a `Secret.ref(name)` for reuse across runs. Blocking: the store
66
66
  * write completes before this resolves. Consumes this instance (an ephemeral
67
- * value is promoted exactly once), mirroring `Skill.upload`.
67
+ * value is promoted exactly once).
68
68
  *
69
69
  * Only valid on a `Secret.value(...)`; a `Secret.ref(...)` is already
70
70
  * persisted.
@@ -1 +1 @@
1
- {"version":3,"file":"secret.js","sour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