/** * Rejects attachment URLs that a model provider can never fetch. * * An attachment reaches the provider as a URL, not as bytes: the OpenAI- * compatible converter emits `{ type: "image_url", image_url: { url } }` * (`src/provider/runtime-loader.ts:213`) and the provider's own servers * dereference it. So the URL has to be reachable from the public internet, * and some URLs provably never are. * * The chat upload handler mints exactly such a URL by default. When the * configured storage backend returns no external URL of its own, `POST` falls * back to this app's own origin (`src/chat/upload-handler.ts:426`): * * {"id":"blob_1","url":"http://localhost:3000/api/chat/upload?id=blob_1", ...} * * The upload succeeds, the composer sends that URL back as a `file` part, and * the provider resolves `localhost` to *itself*. What comes back is a bare 400 * with no indication that an attachment was the problem — the turn dies and * nothing in the log names the file. * * Deciding this here, at the last point before the wire, is the only place with * the whole picture: the upload handler cannot know whether its origin is * publicly reachable, and the provider client sees a URL with no attachment * context left to name. * * Only hosts that are unreachable *by construction* are rejected — loopback, * link-local, and the private ranges, in both IPv4 (RFC 1918) and IPv6 * (`fc00::/7`, `fe80::/10`) — plus schemes a provider cannot dereference at * all. A public hostname that merely happens to be firewalled is not something * this can detect, and guessing would break working setups. `data:` URLs carry * their own bytes and are always allowed. * * This judges reachability *from the public internet*, so it applies to a * remote provider. A server-local runtime fetches from the server itself, where * a loopback URL resolves fine; the caller decides which case it is (see * `text-generation-runtime-message-converter.ts`). * * @module */ /** An attachment whose URL the provider could never have fetched. */ export declare class UnreachableAttachmentError extends Error { readonly filename: string; readonly attachmentUrl: string; readonly reason: string; constructor(options: { filename: string; attachmentUrl: string; reason: string; }); } /** * Why a provider could never fetch `url`, or `undefined` when it might. * * Errs towards allowing: an unparseable or unknown-shaped URL is left alone so * the provider stays the authority on what it accepts. */ export declare function describeUnreachableAttachmentUrl(url: string): string | undefined; /** * Throw if `url` is one no provider can fetch, naming the attachment. * * Replaces the provider's opaque 400 with a message that says which file and * why, at the point where both are still known. */ export declare function assertProviderReachableAttachment(options: { url: string; filename: string | undefined; mediaType: string; }): void; //# sourceMappingURL=attachment-reachability.d.ts.map