/** * @fileoverview Bounds a `withRetry` ladder against a single wall-clock budget and * normalizes what an exhausted budget looks like to the caller. Shared by the * catalog and text services so the caller-cancel passthrough rule is written once. * @module services/upstream-deadline */ import type { Context } from '@cyanheads/mcp-ts-core'; /** How an exhausted ladder is reported to the client. */ export interface UpstreamDeadlineOptions { /** Wall-clock ceiling for the whole ladder, in milliseconds. */ budgetMs: number; /** * Client-facing message. Must name the upstream or the record in domain terms — * never a resolved request URL or a configured base URL, both of which are * operator-owned and overridable to a self-hosted instance. */ message: string; /** Contract reason the calling tools declare for this upstream's outage. */ reason: string; } /** * Runs an upstream ladder under a shared deadline and normalizes its failure. * * `RetryOptions` has carried its own `deadlineMs` since framework 0.13.4, so the * budget alone is no longer what this helper is for: it also composes the budget * with `ctx.signal` into the one signal the ladder and the fetch share, and * normalizes an exhausted ladder onto the calling tool's declared contract * reason. The signal handed to `run` must be passed to **both** * `withRetry({ signal })` and `fetchWithTimeout(..., { signal })`, or the * deadline expires while the request it was meant to cancel keeps running. * * A caller cancel is rethrown unchanged: it is not an upstream outage, and * relabelling it would advertise a retry that cannot help. */ export declare function withUpstreamDeadline(ctx: Context, { budgetMs, message, reason }: UpstreamDeadlineOptions, run: (signal: AbortSignal) => Promise): Promise; //# sourceMappingURL=upstream-deadline.d.ts.map