UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

66 lines • 3.72 kB
/** A provider refused (or could not be reached for) a delivery. `status` is its HTTP status, if any. */ export declare class ChannelDeliveryError extends Error { readonly channel: string; readonly status: number | null; constructor(channel: string, status: number | null, message: string); /** * The provider answered and said no (400, 403, 404, 422): the message was certainly not delivered, * so sending something else in its place cannot duplicate it. */ get definite(): boolean; } /** A file was larger than the attachment limit; it was not (fully) downloaded. */ export declare class ChannelMediaTooLargeError extends Error { readonly maxBytes: number; constructor(maxBytes: number); } /** * GET a file, refusing one past `maxBytes` — by its `content-length` before reading, and by what * actually arrives while reading. Throws a {@link ChannelDeliveryError} on a non-2xx. */ export declare function fetchBytes(channel: string, fetcher: ChannelFetch, url: string, headers: Record<string, string>, timeoutMs: number, maxBytes: number): Promise<{ data: Buffer; contentType: string | undefined; }>; /** Bytes of a base64 string, refusing past `maxBytes` before decoding. */ export declare function decodeBase64(base64: string, maxBytes: number): Buffer; /** A positive number out of a webhook field that may be a number, a numeric string or a Long object. */ export declare function sizeOf(value: unknown): number | undefined; /** Compare two secrets in constant time (over their hashes, so lengths leak nothing either). */ export declare function safeEqual(supplied: string | undefined | null, expected: string): boolean; /** The `fetch` adapters use — `globalThis.fetch` unless a test (or a proxy) hands one in. */ export type ChannelFetch = typeof fetch; /** * POST a JSON body. Resolves with the parsed JSON answer (`null` when it is not JSON); throws a * {@link ChannelDeliveryError} on a non-2xx or a network failure. The provider's error body is never * put in the error — it can echo the message text or credentials. */ export declare function postJson(channel: string, fetcher: ChannelFetch, url: string, headers: Record<string, string>, body: unknown, timeoutMs: number): Promise<unknown>; /** * POST a `multipart/form-data` body (a file upload). Same answers and errors as {@link postJson}. * A `Buffer` field is sent as a file part: `{ data, contentType, filename }`. */ export declare function postForm(channel: string, fetcher: ChannelFetch, url: string, headers: Record<string, string>, fields: Record<string, string | { data: Buffer; contentType: string; filename: string; }>, timeoutMs: number): Promise<unknown>; /** A file's name when it has none: `image.png`, `document.pdf`. */ export declare function mediaFilename(media: { kind: string; contentType?: string | undefined; filename?: string | undefined; }): string; /** A query-string parameter of a request's url. */ export declare function queryParam(url: string, name: string): string | undefined; /** `value` when it is a plain object, else `undefined` — for reading untyped webhook bodies. */ export declare function record(value: unknown): Record<string, unknown> | undefined; /** `value` when it is a non-empty string. */ export declare function str(value: unknown): string | undefined; /** * A provider's send timestamp as epoch milliseconds: Unix seconds (WhatsApp, Telegram) or * milliseconds, as a number, a numeric string, or a protobuf `Long` (`{ low, high }`, what Baileys can * forward). `undefined` for anything else. */ export declare function providerSentAt(value: unknown): number | undefined; //# sourceMappingURL=http.d.ts.map