@anthropic-ai/aws-sdk
Advanced tools
| /** | ||
| * Chain an external {@link AbortSignal} into a local {@link AbortController}: | ||
| * the controller aborts whenever `external` aborts (synchronously if it is | ||
| * already aborted). | ||
| * | ||
| * Returns a cleanup function that detaches the listener. Callers MUST invoke it | ||
| * on their normal teardown path — `{ once: true }` only removes the listener if | ||
| * abort actually fires, so a long-lived `external` signal (e.g. a daemon-wide | ||
| * signal reused across many short-lived controllers) would otherwise leak one | ||
| * listener per controller. | ||
| */ | ||
| export declare function linkAbort(external: AbortSignal | null | undefined, controller: AbortController): () => void; | ||
| //# sourceMappingURL=abort.d.mts.map |
| {"version":3,"file":"abort.d.mts","sourceRoot":"","sources":["../../src/internal/utils/abort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,eAAe,GAAG,MAAM,IAAI,CAS3G"} |
| /** | ||
| * Chain an external {@link AbortSignal} into a local {@link AbortController}: | ||
| * the controller aborts whenever `external` aborts (synchronously if it is | ||
| * already aborted). | ||
| * | ||
| * Returns a cleanup function that detaches the listener. Callers MUST invoke it | ||
| * on their normal teardown path — `{ once: true }` only removes the listener if | ||
| * abort actually fires, so a long-lived `external` signal (e.g. a daemon-wide | ||
| * signal reused across many short-lived controllers) would otherwise leak one | ||
| * listener per controller. | ||
| */ | ||
| export declare function linkAbort(external: AbortSignal | null | undefined, controller: AbortController): () => void; | ||
| //# sourceMappingURL=abort.d.ts.map |
| {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../src/internal/utils/abort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,eAAe,GAAG,MAAM,IAAI,CAS3G"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.linkAbort = linkAbort; | ||
| /** | ||
| * Chain an external {@link AbortSignal} into a local {@link AbortController}: | ||
| * the controller aborts whenever `external` aborts (synchronously if it is | ||
| * already aborted). | ||
| * | ||
| * Returns a cleanup function that detaches the listener. Callers MUST invoke it | ||
| * on their normal teardown path — `{ once: true }` only removes the listener if | ||
| * abort actually fires, so a long-lived `external` signal (e.g. a daemon-wide | ||
| * signal reused across many short-lived controllers) would otherwise leak one | ||
| * listener per controller. | ||
| */ | ||
| function linkAbort(external, controller) { | ||
| if (!external) | ||
| return () => { }; | ||
| if (external.aborted) { | ||
| controller.abort(); | ||
| return () => { }; | ||
| } | ||
| const onAbort = () => controller.abort(); | ||
| external.addEventListener('abort', onAbort); | ||
| return () => external.removeEventListener('abort', onAbort); | ||
| } | ||
| //# sourceMappingURL=abort.js.map |
| {"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/internal/utils/abort.ts"],"names":[],"mappings":";;AAWA,8BASC;AApBD;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CAAC,QAAwC,EAAE,UAA2B;IAC7F,IAAI,CAAC,QAAQ;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC/B,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC"} |
| /** | ||
| * Chain an external {@link AbortSignal} into a local {@link AbortController}: | ||
| * the controller aborts whenever `external` aborts (synchronously if it is | ||
| * already aborted). | ||
| * | ||
| * Returns a cleanup function that detaches the listener. Callers MUST invoke it | ||
| * on their normal teardown path — `{ once: true }` only removes the listener if | ||
| * abort actually fires, so a long-lived `external` signal (e.g. a daemon-wide | ||
| * signal reused across many short-lived controllers) would otherwise leak one | ||
| * listener per controller. | ||
| */ | ||
| export function linkAbort(external, controller) { | ||
| if (!external) | ||
| return () => { }; | ||
| if (external.aborted) { | ||
| controller.abort(); | ||
| return () => { }; | ||
| } | ||
| const onAbort = () => controller.abort(); | ||
| external.addEventListener('abort', onAbort); | ||
| return () => external.removeEventListener('abort', onAbort); | ||
| } | ||
| //# sourceMappingURL=abort.mjs.map |
| {"version":3,"file":"abort.mjs","sourceRoot":"","sources":["../../src/internal/utils/abort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,QAAwC,EAAE,UAA2B;IAC7F,IAAI,CAAC,QAAQ;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC/B,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC"} |
| export type AsyncQueueResult<T> = { | ||
| done: false; | ||
| value: T; | ||
| } | { | ||
| done: true; | ||
| value: undefined; | ||
| }; | ||
| /** | ||
| * Single-consumer async queue that bridges background producers to an | ||
| * `AsyncIterator`-style reader. Producers `push()` items; the consumer awaits | ||
| * `next()`. `close()` is idempotent and wakes any pending `next()` with | ||
| * `done: true`. `tryShift()` synchronously drains remaining items after | ||
| * iteration has been signalled to stop. | ||
| */ | ||
| export declare class AsyncQueue<T> { | ||
| #private; | ||
| /** Enqueue an item, or hand it directly to a waiting reader. Returns `false` once closed. */ | ||
| push(item: T): boolean; | ||
| /** Mark the queue done. Idempotent; wakes every pending reader with `done: true`. */ | ||
| close(): void; | ||
| /** | ||
| * Resolve with the next item, or `done: true` once the queue is closed and | ||
| * drained. When `signal` is supplied, aborting it resolves a pending read | ||
| * with `done: true` (cancellation is pushed down here rather than handled by | ||
| * an outer `Promise.race`). | ||
| */ | ||
| next(signal?: AbortSignal): Promise<AsyncQueueResult<T>>; | ||
| /** Synchronously remove and return the next buffered item, or `undefined` if empty. */ | ||
| tryShift(): T | undefined; | ||
| } | ||
| //# sourceMappingURL=async-queue.d.mts.map |
| {"version":3,"file":"async-queue.d.mts","sourceRoot":"","sources":["../../src/internal/utils/async-queue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/F;;;;;;GAMG;AACH,qBAAa,UAAU,CAAC,CAAC;;IAKvB,6FAA6F;IAC7F,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAQtB,qFAAqF;IACrF,KAAK,IAAI,IAAI;IASb;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAsBxD,uFAAuF;IACvF,QAAQ,IAAI,CAAC,GAAG,SAAS;CAG1B"} |
| export type AsyncQueueResult<T> = { | ||
| done: false; | ||
| value: T; | ||
| } | { | ||
| done: true; | ||
| value: undefined; | ||
| }; | ||
| /** | ||
| * Single-consumer async queue that bridges background producers to an | ||
| * `AsyncIterator`-style reader. Producers `push()` items; the consumer awaits | ||
| * `next()`. `close()` is idempotent and wakes any pending `next()` with | ||
| * `done: true`. `tryShift()` synchronously drains remaining items after | ||
| * iteration has been signalled to stop. | ||
| */ | ||
| export declare class AsyncQueue<T> { | ||
| #private; | ||
| /** Enqueue an item, or hand it directly to a waiting reader. Returns `false` once closed. */ | ||
| push(item: T): boolean; | ||
| /** Mark the queue done. Idempotent; wakes every pending reader with `done: true`. */ | ||
| close(): void; | ||
| /** | ||
| * Resolve with the next item, or `done: true` once the queue is closed and | ||
| * drained. When `signal` is supplied, aborting it resolves a pending read | ||
| * with `done: true` (cancellation is pushed down here rather than handled by | ||
| * an outer `Promise.race`). | ||
| */ | ||
| next(signal?: AbortSignal): Promise<AsyncQueueResult<T>>; | ||
| /** Synchronously remove and return the next buffered item, or `undefined` if empty. */ | ||
| tryShift(): T | undefined; | ||
| } | ||
| //# sourceMappingURL=async-queue.d.ts.map |
| {"version":3,"file":"async-queue.d.ts","sourceRoot":"","sources":["../../src/internal/utils/async-queue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/F;;;;;;GAMG;AACH,qBAAa,UAAU,CAAC,CAAC;;IAKvB,6FAA6F;IAC7F,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAQtB,qFAAqF;IACrF,KAAK,IAAI,IAAI;IASb;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAsBxD,uFAAuF;IACvF,QAAQ,IAAI,CAAC,GAAG,SAAS;CAG1B"} |
| "use strict"; | ||
| var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
| return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
| }; | ||
| var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
| if (kind === "m") throw new TypeError("Private method is not writable"); | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
| return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
| }; | ||
| var _AsyncQueue_items, _AsyncQueue_waiters, _AsyncQueue_closed; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AsyncQueue = void 0; | ||
| /** | ||
| * Single-consumer async queue that bridges background producers to an | ||
| * `AsyncIterator`-style reader. Producers `push()` items; the consumer awaits | ||
| * `next()`. `close()` is idempotent and wakes any pending `next()` with | ||
| * `done: true`. `tryShift()` synchronously drains remaining items after | ||
| * iteration has been signalled to stop. | ||
| */ | ||
| class AsyncQueue { | ||
| constructor() { | ||
| _AsyncQueue_items.set(this, []); | ||
| _AsyncQueue_waiters.set(this, []); | ||
| _AsyncQueue_closed.set(this, false); | ||
| } | ||
| /** Enqueue an item, or hand it directly to a waiting reader. Returns `false` once closed. */ | ||
| push(item) { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f")) | ||
| return false; | ||
| const w = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").shift(); | ||
| if (w) | ||
| w({ done: false, value: item }); | ||
| else | ||
| __classPrivateFieldGet(this, _AsyncQueue_items, "f").push(item); | ||
| return true; | ||
| } | ||
| /** Mark the queue done. Idempotent; wakes every pending reader with `done: true`. */ | ||
| close() { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f")) | ||
| return; | ||
| __classPrivateFieldSet(this, _AsyncQueue_closed, true, "f"); | ||
| while (__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").length > 0) { | ||
| const w = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").shift(); | ||
| w({ done: true, value: undefined }); | ||
| } | ||
| } | ||
| /** | ||
| * Resolve with the next item, or `done: true` once the queue is closed and | ||
| * drained. When `signal` is supplied, aborting it resolves a pending read | ||
| * with `done: true` (cancellation is pushed down here rather than handled by | ||
| * an outer `Promise.race`). | ||
| */ | ||
| next(signal) { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_items, "f").length > 0) { | ||
| return Promise.resolve({ done: false, value: __classPrivateFieldGet(this, _AsyncQueue_items, "f").shift() }); | ||
| } | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f") || signal?.aborted) { | ||
| return Promise.resolve({ done: true, value: undefined }); | ||
| } | ||
| return new Promise((resolve) => { | ||
| const waiter = (r) => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(r); | ||
| }; | ||
| const onAbort = () => { | ||
| const idx = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").indexOf(waiter); | ||
| if (idx >= 0) | ||
| __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").splice(idx, 1); | ||
| resolve({ done: true, value: undefined }); | ||
| }; | ||
| __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").push(waiter); | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); | ||
| } | ||
| /** Synchronously remove and return the next buffered item, or `undefined` if empty. */ | ||
| tryShift() { | ||
| return __classPrivateFieldGet(this, _AsyncQueue_items, "f").shift(); | ||
| } | ||
| } | ||
| exports.AsyncQueue = AsyncQueue; | ||
| _AsyncQueue_items = new WeakMap(), _AsyncQueue_waiters = new WeakMap(), _AsyncQueue_closed = new WeakMap(); | ||
| //# sourceMappingURL=async-queue.js.map |
| {"version":3,"file":"async-queue.js","sourceRoot":"","sources":["../../src/internal/utils/async-queue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA;;;;;;GAMG;AACH,MAAa,UAAU;IAAvB;QACE,4BAAc,EAAE,EAAC;QACjB,8BAAoD,EAAE,EAAC;QACvD,6BAAU,KAAK,EAAC;IAqDlB,CAAC;IAnDC,6FAA6F;IAC7F,IAAI,CAAC,IAAO;QACV,IAAI,uBAAA,IAAI,0BAAQ;YAAE,OAAO,KAAK,CAAC;QAC/B,MAAM,CAAC,GAAG,uBAAA,IAAI,2BAAS,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC;YAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;YAClC,uBAAA,IAAI,yBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qFAAqF;IACrF,KAAK;QACH,IAAI,uBAAA,IAAI,0BAAQ;YAAE,OAAO;QACzB,uBAAA,IAAI,sBAAW,IAAI,MAAA,CAAC;QACpB,OAAO,uBAAA,IAAI,2BAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,GAAG,uBAAA,IAAI,2BAAS,CAAC,KAAK,EAAG,CAAC;YACjC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAoB;QACvB,IAAI,uBAAA,IAAI,yBAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,uBAAA,IAAI,yBAAO,CAAC,KAAK,EAAG,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,uBAAA,IAAI,0BAAQ,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,EAAE;YAClD,MAAM,MAAM,GAAG,CAAC,CAAsB,EAAE,EAAE;gBACxC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC9C,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC;YACF,MAAM,OAAO,GAAG,GAAG,EAAE;gBACnB,MAAM,GAAG,GAAG,uBAAA,IAAI,2BAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC1C,IAAI,GAAG,IAAI,CAAC;oBAAE,uBAAA,IAAI,2BAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,uBAAA,IAAI,2BAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uFAAuF;IACvF,QAAQ;QACN,OAAO,uBAAA,IAAI,yBAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF;AAxDD,gCAwDC"} |
| var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
| return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
| }; | ||
| var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
| if (kind === "m") throw new TypeError("Private method is not writable"); | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
| return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
| }; | ||
| var _AsyncQueue_items, _AsyncQueue_waiters, _AsyncQueue_closed; | ||
| /** | ||
| * Single-consumer async queue that bridges background producers to an | ||
| * `AsyncIterator`-style reader. Producers `push()` items; the consumer awaits | ||
| * `next()`. `close()` is idempotent and wakes any pending `next()` with | ||
| * `done: true`. `tryShift()` synchronously drains remaining items after | ||
| * iteration has been signalled to stop. | ||
| */ | ||
| export class AsyncQueue { | ||
| constructor() { | ||
| _AsyncQueue_items.set(this, []); | ||
| _AsyncQueue_waiters.set(this, []); | ||
| _AsyncQueue_closed.set(this, false); | ||
| } | ||
| /** Enqueue an item, or hand it directly to a waiting reader. Returns `false` once closed. */ | ||
| push(item) { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f")) | ||
| return false; | ||
| const w = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").shift(); | ||
| if (w) | ||
| w({ done: false, value: item }); | ||
| else | ||
| __classPrivateFieldGet(this, _AsyncQueue_items, "f").push(item); | ||
| return true; | ||
| } | ||
| /** Mark the queue done. Idempotent; wakes every pending reader with `done: true`. */ | ||
| close() { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f")) | ||
| return; | ||
| __classPrivateFieldSet(this, _AsyncQueue_closed, true, "f"); | ||
| while (__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").length > 0) { | ||
| const w = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").shift(); | ||
| w({ done: true, value: undefined }); | ||
| } | ||
| } | ||
| /** | ||
| * Resolve with the next item, or `done: true` once the queue is closed and | ||
| * drained. When `signal` is supplied, aborting it resolves a pending read | ||
| * with `done: true` (cancellation is pushed down here rather than handled by | ||
| * an outer `Promise.race`). | ||
| */ | ||
| next(signal) { | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_items, "f").length > 0) { | ||
| return Promise.resolve({ done: false, value: __classPrivateFieldGet(this, _AsyncQueue_items, "f").shift() }); | ||
| } | ||
| if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f") || signal?.aborted) { | ||
| return Promise.resolve({ done: true, value: undefined }); | ||
| } | ||
| return new Promise((resolve) => { | ||
| const waiter = (r) => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(r); | ||
| }; | ||
| const onAbort = () => { | ||
| const idx = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").indexOf(waiter); | ||
| if (idx >= 0) | ||
| __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").splice(idx, 1); | ||
| resolve({ done: true, value: undefined }); | ||
| }; | ||
| __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").push(waiter); | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); | ||
| } | ||
| /** Synchronously remove and return the next buffered item, or `undefined` if empty. */ | ||
| tryShift() { | ||
| return __classPrivateFieldGet(this, _AsyncQueue_items, "f").shift(); | ||
| } | ||
| } | ||
| _AsyncQueue_items = new WeakMap(), _AsyncQueue_waiters = new WeakMap(), _AsyncQueue_closed = new WeakMap(); | ||
| //# sourceMappingURL=async-queue.mjs.map |
| {"version":3,"file":"async-queue.mjs","sourceRoot":"","sources":["../../src/internal/utils/async-queue.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAAvB;QACE,4BAAc,EAAE,EAAC;QACjB,8BAAoD,EAAE,EAAC;QACvD,6BAAU,KAAK,EAAC;IAqDlB,CAAC;IAnDC,6FAA6F;IAC7F,IAAI,CAAC,IAAO;QACV,IAAI,uBAAA,IAAI,0BAAQ;YAAE,OAAO,KAAK,CAAC;QAC/B,MAAM,CAAC,GAAG,uBAAA,IAAI,2BAAS,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC;YAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;YAClC,uBAAA,IAAI,yBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qFAAqF;IACrF,KAAK;QACH,IAAI,uBAAA,IAAI,0BAAQ;YAAE,OAAO;QACzB,uBAAA,IAAI,sBAAW,IAAI,MAAA,CAAC;QACpB,OAAO,uBAAA,IAAI,2BAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,GAAG,uBAAA,IAAI,2BAAS,CAAC,KAAK,EAAG,CAAC;YACjC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAoB;QACvB,IAAI,uBAAA,IAAI,yBAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,uBAAA,IAAI,yBAAO,CAAC,KAAK,EAAG,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,uBAAA,IAAI,0BAAQ,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,EAAE;YAClD,MAAM,MAAM,GAAG,CAAC,CAAsB,EAAE,EAAE;gBACxC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC9C,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC;YACF,MAAM,OAAO,GAAG,GAAG,EAAE;gBACnB,MAAM,GAAG,GAAG,uBAAA,IAAI,2BAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC1C,IAAI,GAAG,IAAI,CAAC;oBAAE,uBAAA,IAAI,2BAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,uBAAA,IAAI,2BAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uFAAuF;IACvF,QAAQ;QACN,OAAO,uBAAA,IAAI,yBAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF"} |
| /** True when `e` is an {@link APIError} whose HTTP status equals `code`. */ | ||
| export declare function isStatus(e: unknown, code: number): boolean; | ||
| /** True when `e` is an {@link APIError} with a 4xx status. */ | ||
| export declare function is4xx(e: unknown): boolean; | ||
| /** | ||
| * True for a 4xx that the core client's retry policy would *not* retry, i.e. a | ||
| * permanent client error. 408 (request timeout), 409 (lock timeout) and 429 | ||
| * (rate limit) are retryable for the base client (`Anthropic.shouldRetry`), so | ||
| * they are not treated as fatal here — keeping helper retry behaviour aligned | ||
| * with the rest of the SDK. | ||
| */ | ||
| export declare function isFatal4xx(e: unknown): boolean; | ||
| /** Exponential backoff: `baseMs * 2 ** attempt`, clamped to `capMs`. */ | ||
| export declare function backoff(attempt: number, baseMs: number, capMs: number): number; | ||
| /** Uniform random delay in the half-open interval `[lowMs, highMs)`. */ | ||
| export declare function jitter(lowMs: number, highMs: number): number; | ||
| /** | ||
| * Trim up to 25% off `ms` at random so a fleet of clients backing off after a | ||
| * shared outage does not retry in lockstep — mirrors the jitter the core client | ||
| * applies to its own retry timeout. | ||
| */ | ||
| export declare function applyJitter(ms: number): number; | ||
| //# sourceMappingURL=backoff.d.mts.map |
| {"version":3,"file":"backoff.d.mts","sourceRoot":"","sources":["../../src/internal/utils/backoff.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,8DAA8D;AAC9D,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C"} |
| /** True when `e` is an {@link APIError} whose HTTP status equals `code`. */ | ||
| export declare function isStatus(e: unknown, code: number): boolean; | ||
| /** True when `e` is an {@link APIError} with a 4xx status. */ | ||
| export declare function is4xx(e: unknown): boolean; | ||
| /** | ||
| * True for a 4xx that the core client's retry policy would *not* retry, i.e. a | ||
| * permanent client error. 408 (request timeout), 409 (lock timeout) and 429 | ||
| * (rate limit) are retryable for the base client (`Anthropic.shouldRetry`), so | ||
| * they are not treated as fatal here — keeping helper retry behaviour aligned | ||
| * with the rest of the SDK. | ||
| */ | ||
| export declare function isFatal4xx(e: unknown): boolean; | ||
| /** Exponential backoff: `baseMs * 2 ** attempt`, clamped to `capMs`. */ | ||
| export declare function backoff(attempt: number, baseMs: number, capMs: number): number; | ||
| /** Uniform random delay in the half-open interval `[lowMs, highMs)`. */ | ||
| export declare function jitter(lowMs: number, highMs: number): number; | ||
| /** | ||
| * Trim up to 25% off `ms` at random so a fleet of clients backing off after a | ||
| * shared outage does not retry in lockstep — mirrors the jitter the core client | ||
| * applies to its own retry timeout. | ||
| */ | ||
| export declare function applyJitter(ms: number): number; | ||
| //# sourceMappingURL=backoff.d.ts.map |
| {"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../src/internal/utils/backoff.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,8DAA8D;AAC9D,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.isStatus = isStatus; | ||
| exports.is4xx = is4xx; | ||
| exports.isFatal4xx = isFatal4xx; | ||
| exports.backoff = backoff; | ||
| exports.jitter = jitter; | ||
| exports.applyJitter = applyJitter; | ||
| const error_1 = require("../../core/error.js"); | ||
| /** True when `e` is an {@link APIError} whose HTTP status equals `code`. */ | ||
| function isStatus(e, code) { | ||
| return e instanceof error_1.APIError && e.status === code; | ||
| } | ||
| /** True when `e` is an {@link APIError} with a 4xx status. */ | ||
| function is4xx(e) { | ||
| return e instanceof error_1.APIError && typeof e.status === 'number' && e.status >= 400 && e.status < 500; | ||
| } | ||
| /** | ||
| * True for a 4xx that the core client's retry policy would *not* retry, i.e. a | ||
| * permanent client error. 408 (request timeout), 409 (lock timeout) and 429 | ||
| * (rate limit) are retryable for the base client (`Anthropic.shouldRetry`), so | ||
| * they are not treated as fatal here — keeping helper retry behaviour aligned | ||
| * with the rest of the SDK. | ||
| */ | ||
| function isFatal4xx(e) { | ||
| return is4xx(e) && !isStatus(e, 408) && !isStatus(e, 409) && !isStatus(e, 429); | ||
| } | ||
| /** Exponential backoff: `baseMs * 2 ** attempt`, clamped to `capMs`. */ | ||
| function backoff(attempt, baseMs, capMs) { | ||
| return Math.min(baseMs * 2 ** attempt, capMs); | ||
| } | ||
| /** Uniform random delay in the half-open interval `[lowMs, highMs)`. */ | ||
| function jitter(lowMs, highMs) { | ||
| return lowMs + Math.random() * (highMs - lowMs); | ||
| } | ||
| /** | ||
| * Trim up to 25% off `ms` at random so a fleet of clients backing off after a | ||
| * shared outage does not retry in lockstep — mirrors the jitter the core client | ||
| * applies to its own retry timeout. | ||
| */ | ||
| function applyJitter(ms) { | ||
| return ms * (1 - Math.random() * 0.25); | ||
| } | ||
| //# sourceMappingURL=backoff.js.map |
| {"version":3,"file":"backoff.js","sourceRoot":"","sources":["../../src/internal/utils/backoff.ts"],"names":[],"mappings":";;AAGA,4BAEC;AAGD,sBAEC;AASD,gCAEC;AAGD,0BAEC;AAGD,wBAEC;AAOD,kCAEC;AAxCD,+CAA4C;AAE5C,4EAA4E;AAC5E,SAAgB,QAAQ,CAAC,CAAU,EAAE,IAAY;IAC/C,OAAO,CAAC,YAAY,gBAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,8DAA8D;AAC9D,SAAgB,KAAK,CAAC,CAAU;IAC9B,OAAO,CAAC,YAAY,gBAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACpG,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,CAAU;IACnC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACjF,CAAC;AAED,wEAAwE;AACxE,SAAgB,OAAO,CAAC,OAAe,EAAE,MAAc,EAAE,KAAa;IACpE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,wEAAwE;AACxE,SAAgB,MAAM,CAAC,KAAa,EAAE,MAAc;IAClD,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,EAAU;IACpC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;AACzC,CAAC"} |
| import { APIError } from "../../core/error.mjs"; | ||
| /** True when `e` is an {@link APIError} whose HTTP status equals `code`. */ | ||
| export function isStatus(e, code) { | ||
| return e instanceof APIError && e.status === code; | ||
| } | ||
| /** True when `e` is an {@link APIError} with a 4xx status. */ | ||
| export function is4xx(e) { | ||
| return e instanceof APIError && typeof e.status === 'number' && e.status >= 400 && e.status < 500; | ||
| } | ||
| /** | ||
| * True for a 4xx that the core client's retry policy would *not* retry, i.e. a | ||
| * permanent client error. 408 (request timeout), 409 (lock timeout) and 429 | ||
| * (rate limit) are retryable for the base client (`Anthropic.shouldRetry`), so | ||
| * they are not treated as fatal here — keeping helper retry behaviour aligned | ||
| * with the rest of the SDK. | ||
| */ | ||
| export function isFatal4xx(e) { | ||
| return is4xx(e) && !isStatus(e, 408) && !isStatus(e, 409) && !isStatus(e, 429); | ||
| } | ||
| /** Exponential backoff: `baseMs * 2 ** attempt`, clamped to `capMs`. */ | ||
| export function backoff(attempt, baseMs, capMs) { | ||
| return Math.min(baseMs * 2 ** attempt, capMs); | ||
| } | ||
| /** Uniform random delay in the half-open interval `[lowMs, highMs)`. */ | ||
| export function jitter(lowMs, highMs) { | ||
| return lowMs + Math.random() * (highMs - lowMs); | ||
| } | ||
| /** | ||
| * Trim up to 25% off `ms` at random so a fleet of clients backing off after a | ||
| * shared outage does not retry in lockstep — mirrors the jitter the core client | ||
| * applies to its own retry timeout. | ||
| */ | ||
| export function applyJitter(ms) { | ||
| return ms * (1 - Math.random() * 0.25); | ||
| } | ||
| //# sourceMappingURL=backoff.mjs.map |
| {"version":3,"file":"backoff.mjs","sourceRoot":"","sources":["../../src/internal/utils/backoff.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,EAAE;AAEnB,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,CAAU,EAAE,IAAY;IAC/C,OAAO,CAAC,YAAY,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,KAAK,CAAC,CAAU;IAC9B,OAAO,CAAC,YAAY,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACpG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,CAAU;IACnC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACjF,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,MAAc,EAAE,KAAa;IACpE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,MAAc;IAClD,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;AACzC,CAAC"} |
| /** | ||
| * A deferred: a `Promise` together with its `resolve` / `reject` functions. | ||
| * This is `Promise.withResolvers()`, which is not available in all supported | ||
| * runtimes. | ||
| */ | ||
| export declare function promiseWithResolvers<T>(): { | ||
| promise: Promise<T>; | ||
| resolve: (value: T | PromiseLike<T>) => void; | ||
| reject: (reason?: unknown) => void; | ||
| }; | ||
| //# sourceMappingURL=promise.d.mts.map |
| {"version":3,"file":"promise.d.mts","sourceRoot":"","sources":["../../src/internal/utils/promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,KAAK;IACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAQA"} |
| /** | ||
| * A deferred: a `Promise` together with its `resolve` / `reject` functions. | ||
| * This is `Promise.withResolvers()`, which is not available in all supported | ||
| * runtimes. | ||
| */ | ||
| export declare function promiseWithResolvers<T>(): { | ||
| promise: Promise<T>; | ||
| resolve: (value: T | PromiseLike<T>) => void; | ||
| reject: (reason?: unknown) => void; | ||
| }; | ||
| //# sourceMappingURL=promise.d.ts.map |
| {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/internal/utils/promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,KAAK;IACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAQA"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.promiseWithResolvers = promiseWithResolvers; | ||
| /** | ||
| * A deferred: a `Promise` together with its `resolve` / `reject` functions. | ||
| * This is `Promise.withResolvers()`, which is not available in all supported | ||
| * runtimes. | ||
| */ | ||
| function promiseWithResolvers() { | ||
| let resolve; | ||
| let reject; | ||
| const promise = new Promise((res, rej) => { | ||
| resolve = res; | ||
| reject = rej; | ||
| }); | ||
| return { promise, resolve, reject }; | ||
| } | ||
| //# sourceMappingURL=promise.js.map |
| {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../src/internal/utils/promise.ts"],"names":[],"mappings":";;AAKA,oDAYC;AAjBD;;;;GAIG;AACH,SAAgB,oBAAoB;IAKlC,IAAI,OAA6C,CAAC;IAClD,IAAI,MAAmC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"} |
| /** | ||
| * A deferred: a `Promise` together with its `resolve` / `reject` functions. | ||
| * This is `Promise.withResolvers()`, which is not available in all supported | ||
| * runtimes. | ||
| */ | ||
| export function promiseWithResolvers() { | ||
| let resolve; | ||
| let reject; | ||
| const promise = new Promise((res, rej) => { | ||
| resolve = res; | ||
| reject = rej; | ||
| }); | ||
| return { promise, resolve, reject }; | ||
| } | ||
| //# sourceMappingURL=promise.mjs.map |
| {"version":3,"file":"promise.mjs","sourceRoot":"","sources":["../../src/internal/utils/promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA6C,CAAC;IAClD,IAAI,MAAmC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"} |
| /** | ||
| * Chain an external {@link AbortSignal} into a local {@link AbortController}: | ||
| * the controller aborts whenever `external` aborts (synchronously if it is | ||
| * already aborted). | ||
| * | ||
| * Returns a cleanup function that detaches the listener. Callers MUST invoke it | ||
| * on their normal teardown path — `{ once: true }` only removes the listener if | ||
| * abort actually fires, so a long-lived `external` signal (e.g. a daemon-wide | ||
| * signal reused across many short-lived controllers) would otherwise leak one | ||
| * listener per controller. | ||
| */ | ||
| export function linkAbort(external: AbortSignal | null | undefined, controller: AbortController): () => void { | ||
| if (!external) return () => {}; | ||
| if (external.aborted) { | ||
| controller.abort(); | ||
| return () => {}; | ||
| } | ||
| const onAbort = () => controller.abort(); | ||
| external.addEventListener('abort', onAbort); | ||
| return () => external.removeEventListener('abort', onAbort); | ||
| } |
| export type AsyncQueueResult<T> = { done: false; value: T } | { done: true; value: undefined }; | ||
| /** | ||
| * Single-consumer async queue that bridges background producers to an | ||
| * `AsyncIterator`-style reader. Producers `push()` items; the consumer awaits | ||
| * `next()`. `close()` is idempotent and wakes any pending `next()` with | ||
| * `done: true`. `tryShift()` synchronously drains remaining items after | ||
| * iteration has been signalled to stop. | ||
| */ | ||
| export class AsyncQueue<T> { | ||
| #items: T[] = []; | ||
| #waiters: Array<(r: AsyncQueueResult<T>) => void> = []; | ||
| #closed = false; | ||
| /** Enqueue an item, or hand it directly to a waiting reader. Returns `false` once closed. */ | ||
| push(item: T): boolean { | ||
| if (this.#closed) return false; | ||
| const w = this.#waiters.shift(); | ||
| if (w) w({ done: false, value: item }); | ||
| else this.#items.push(item); | ||
| return true; | ||
| } | ||
| /** Mark the queue done. Idempotent; wakes every pending reader with `done: true`. */ | ||
| close(): void { | ||
| if (this.#closed) return; | ||
| this.#closed = true; | ||
| while (this.#waiters.length > 0) { | ||
| const w = this.#waiters.shift()!; | ||
| w({ done: true, value: undefined }); | ||
| } | ||
| } | ||
| /** | ||
| * Resolve with the next item, or `done: true` once the queue is closed and | ||
| * drained. When `signal` is supplied, aborting it resolves a pending read | ||
| * with `done: true` (cancellation is pushed down here rather than handled by | ||
| * an outer `Promise.race`). | ||
| */ | ||
| next(signal?: AbortSignal): Promise<AsyncQueueResult<T>> { | ||
| if (this.#items.length > 0) { | ||
| return Promise.resolve({ done: false, value: this.#items.shift()! }); | ||
| } | ||
| if (this.#closed || signal?.aborted) { | ||
| return Promise.resolve({ done: true, value: undefined }); | ||
| } | ||
| return new Promise<AsyncQueueResult<T>>((resolve) => { | ||
| const waiter = (r: AsyncQueueResult<T>) => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(r); | ||
| }; | ||
| const onAbort = () => { | ||
| const idx = this.#waiters.indexOf(waiter); | ||
| if (idx >= 0) this.#waiters.splice(idx, 1); | ||
| resolve({ done: true, value: undefined }); | ||
| }; | ||
| this.#waiters.push(waiter); | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); | ||
| } | ||
| /** Synchronously remove and return the next buffered item, or `undefined` if empty. */ | ||
| tryShift(): T | undefined { | ||
| return this.#items.shift(); | ||
| } | ||
| } |
| import { APIError } from '../../core/error'; | ||
| /** True when `e` is an {@link APIError} whose HTTP status equals `code`. */ | ||
| export function isStatus(e: unknown, code: number): boolean { | ||
| return e instanceof APIError && e.status === code; | ||
| } | ||
| /** True when `e` is an {@link APIError} with a 4xx status. */ | ||
| export function is4xx(e: unknown): boolean { | ||
| return e instanceof APIError && typeof e.status === 'number' && e.status >= 400 && e.status < 500; | ||
| } | ||
| /** | ||
| * True for a 4xx that the core client's retry policy would *not* retry, i.e. a | ||
| * permanent client error. 408 (request timeout), 409 (lock timeout) and 429 | ||
| * (rate limit) are retryable for the base client (`Anthropic.shouldRetry`), so | ||
| * they are not treated as fatal here — keeping helper retry behaviour aligned | ||
| * with the rest of the SDK. | ||
| */ | ||
| export function isFatal4xx(e: unknown): boolean { | ||
| return is4xx(e) && !isStatus(e, 408) && !isStatus(e, 409) && !isStatus(e, 429); | ||
| } | ||
| /** Exponential backoff: `baseMs * 2 ** attempt`, clamped to `capMs`. */ | ||
| export function backoff(attempt: number, baseMs: number, capMs: number): number { | ||
| return Math.min(baseMs * 2 ** attempt, capMs); | ||
| } | ||
| /** Uniform random delay in the half-open interval `[lowMs, highMs)`. */ | ||
| export function jitter(lowMs: number, highMs: number): number { | ||
| return lowMs + Math.random() * (highMs - lowMs); | ||
| } | ||
| /** | ||
| * Trim up to 25% off `ms` at random so a fleet of clients backing off after a | ||
| * shared outage does not retry in lockstep — mirrors the jitter the core client | ||
| * applies to its own retry timeout. | ||
| */ | ||
| export function applyJitter(ms: number): number { | ||
| return ms * (1 - Math.random() * 0.25); | ||
| } |
| /** | ||
| * A deferred: a `Promise` together with its `resolve` / `reject` functions. | ||
| * This is `Promise.withResolvers()`, which is not available in all supported | ||
| * runtimes. | ||
| */ | ||
| export function promiseWithResolvers<T>(): { | ||
| promise: Promise<T>; | ||
| resolve: (value: T | PromiseLike<T>) => void; | ||
| reject: (reason?: unknown) => void; | ||
| } { | ||
| let resolve!: (value: T | PromiseLike<T>) => void; | ||
| let reject!: (reason?: unknown) => void; | ||
| const promise = new Promise<T>((res, rej) => { | ||
| resolve = res; | ||
| reject = rej; | ||
| }); | ||
| return { promise, resolve, reject }; | ||
| } |
+8
-0
| # Changelog | ||
| ## 0.3.1 (2026-05-29) | ||
| Full Changelog: [aws-sdk-v0.3.0...aws-sdk-v0.3.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/aws-sdk-v0.3.0...aws-sdk-v0.3.1) | ||
| ### Chores | ||
| * **client:** update lockfiles to have proper dependencies on standardwebhooks ([5e9b523](https://github.com/anthropics/anthropic-sdk-typescript/commit/5e9b5237e53aefda65637bd11eb0d07f50bbc952)) | ||
| ## 0.3.0 (2026-05-11) | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,10 @@ | ||
| export declare const sleep: (ms: number) => Promise<void>; | ||
| /** | ||
| * Resolve after `ms`, or immediately when `signal` aborts. | ||
| * | ||
| * When a `signal` is passed the abort listener is always removed so repeated | ||
| * calls do not accumulate listeners on a long-lived signal. Resolves (rather | ||
| * than rejects) on abort — callers treat abort as "wake up early," not as a | ||
| * failure; callers that want to unwind should check the signal themselves. | ||
| */ | ||
| export declare const sleep: (ms: number, signal?: AbortSignal) => Promise<void>; | ||
| //# sourceMappingURL=sleep.d.mts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sleep.d.mts","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,kBAA4D,CAAC"} | ||
| {"version":3,"file":"sleep.d.mts","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAiBjE,CAAC"} |
@@ -1,2 +0,10 @@ | ||
| export declare const sleep: (ms: number) => Promise<void>; | ||
| /** | ||
| * Resolve after `ms`, or immediately when `signal` aborts. | ||
| * | ||
| * When a `signal` is passed the abort listener is always removed so repeated | ||
| * calls do not accumulate listeners on a long-lived signal. Resolves (rather | ||
| * than rejects) on abort — callers treat abort as "wake up early," not as a | ||
| * failure; callers that want to unwind should check the signal themselves. | ||
| */ | ||
| export declare const sleep: (ms: number, signal?: AbortSignal) => Promise<void>; | ||
| //# sourceMappingURL=sleep.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,kBAA4D,CAAC"} | ||
| {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAiBjE,CAAC"} |
| "use strict"; | ||
| // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.sleep = void 0; | ||
| const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
| /** | ||
| * Resolve after `ms`, or immediately when `signal` aborts. | ||
| * | ||
| * When a `signal` is passed the abort listener is always removed so repeated | ||
| * calls do not accumulate listeners on a long-lived signal. Resolves (rather | ||
| * than rejects) on abort — callers treat abort as "wake up early," not as a | ||
| * failure; callers that want to unwind should check the signal themselves. | ||
| */ | ||
| const sleep = (ms, signal) => new Promise((resolve) => { | ||
| if (signal?.aborted) | ||
| return resolve(); | ||
| const onAbort = () => { | ||
| clearTimeout(timer); | ||
| resolve(); | ||
| }; | ||
| const timer = setTimeout(() => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(); | ||
| }, ms); | ||
| // `{ once: true }` auto-removes the listener if abort fires first, | ||
| // so we only need an explicit remove on the timer-wins path above. | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); | ||
| exports.sleep = sleep; | ||
| //# sourceMappingURL=sleep.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAE/E,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAAhF,QAAA,KAAK,SAA2E"} | ||
| {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,MAAoB,EAAiB,EAAE,CACvE,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;IAC5B,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,OAAO,EAAE,CAAC;IAEtC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,mEAAmE;IACnE,mEAAmE;IACnE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAjBQ,QAAA,KAAK,SAiBb"} |
@@ -1,3 +0,24 @@ | ||
| // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
| export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
| /** | ||
| * Resolve after `ms`, or immediately when `signal` aborts. | ||
| * | ||
| * When a `signal` is passed the abort listener is always removed so repeated | ||
| * calls do not accumulate listeners on a long-lived signal. Resolves (rather | ||
| * than rejects) on abort — callers treat abort as "wake up early," not as a | ||
| * failure; callers that want to unwind should check the signal themselves. | ||
| */ | ||
| export const sleep = (ms, signal) => new Promise((resolve) => { | ||
| if (signal?.aborted) | ||
| return resolve(); | ||
| const onAbort = () => { | ||
| clearTimeout(timer); | ||
| resolve(); | ||
| }; | ||
| const timer = setTimeout(() => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(); | ||
| }, ms); | ||
| // `{ once: true }` auto-removes the listener if abort fires first, | ||
| // so we only need an explicit remove on the timer-wins path above. | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); | ||
| //# sourceMappingURL=sleep.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sleep.mjs","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC"} | ||
| {"version":3,"file":"sleep.mjs","sourceRoot":"","sources":["../../src/internal/utils/sleep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,MAAoB,EAAiB,EAAE,CACvE,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;IAC5B,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,OAAO,EAAE,CAAC;IAEtC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,mEAAmE;IACnE,mEAAmE;IACnE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC"} |
+1
-1
| { | ||
| "name": "@anthropic-ai/aws-sdk", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "description": "The official TypeScript library for the Anthropic AWS API", | ||
@@ -5,0 +5,0 @@ "author": "Anthropic <support@anthropic.com>", |
@@ -1,3 +0,26 @@ | ||
| // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
| /** | ||
| * Resolve after `ms`, or immediately when `signal` aborts. | ||
| * | ||
| * When a `signal` is passed the abort listener is always removed so repeated | ||
| * calls do not accumulate listeners on a long-lived signal. Resolves (rather | ||
| * than rejects) on abort — callers treat abort as "wake up early," not as a | ||
| * failure; callers that want to unwind should check the signal themselves. | ||
| */ | ||
| export const sleep = (ms: number, signal?: AbortSignal): Promise<void> => | ||
| new Promise<void>((resolve) => { | ||
| if (signal?.aborted) return resolve(); | ||
| export const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)); | ||
| const onAbort = () => { | ||
| clearTimeout(timer); | ||
| resolve(); | ||
| }; | ||
| const timer = setTimeout(() => { | ||
| signal?.removeEventListener('abort', onAbort); | ||
| resolve(); | ||
| }, ms); | ||
| // `{ once: true }` auto-removes the listener if abort fires first, | ||
| // so we only need an explicit remove on the timer-wins path above. | ||
| signal?.addEventListener('abort', onAbort, { once: true }); | ||
| }); |
576961
8.2%370
10.78%7929
8.19%