/** * `createThrottle` — serialized min-interval scheduler. * * Hoisted verbatim from musicbrainz-mcp (`src/throttle.ts`), where it enforces * MusicBrainz's one-request-per-second rule proactively rather than reacting to * 503s: every upstream call is funnelled through a single serialized queue that * guarantees a minimum spacing between request *starts*. Concurrent tool calls * therefore can't burst — they line up and fire one-per-interval. */ /** Options for {@link createThrottle}. */ export interface ThrottleOptions { /** Minimum milliseconds between the start of consecutive scheduled calls. */ minIntervalMs: number; /** Injectable clock (defaults to `Date.now`) — for tests. */ now?: () => number; /** Injectable sleep (defaults to `setTimeout`) — for tests. */ sleep?: (ms: number) => Promise; } /** A scheduler returned by {@link createThrottle}: wrap any async task to serialize + space it. */ export type Throttle = (fn: () => Promise) => Promise; /** * Build a serialized, rate-spacing scheduler. Tasks run strictly in submission * order, each starting no sooner than `minIntervalMs` after the previous one * started. A task that throws does not stall the queue — the next task is * scheduled regardless of the prior outcome. */ export declare function createThrottle(opts: ThrottleOptions): Throttle; //# sourceMappingURL=throttle.d.ts.map