@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
30 lines • 1.65 kB
TypeScript
import { type LookupAddress } from 'node:dns';
import type { FetchLike } from './util.js';
/**
* `fetch` for URLs a Company gave (section 3): HTTPS only, and never to a loopback, private or
* link-local address. The address is checked in the socket's own `lookup`, so what was checked is
* what gets connected to, with no window for DNS rebinding, and each request opens its own
* connection. Every redirect hop goes through the same check.
*/
export type LookupFn = (hostname: string, options: {
all: true;
}, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void) => void;
export interface SafeFetchOptions {
/** Name resolution, for tests. Default: `dns.lookup`. */
lookup?: LookupFn | undefined;
/** Address policy, for tests. Default: {@link isBlockedAddress}. */
isBlocked?: ((address: string) => boolean) | undefined;
connectTimeoutMs?: number | undefined;
}
/** Whether this client must not connect to `ip`. Anything that isn't an IP counts as blocked. */
export declare function isBlockedAddress(ip: string): boolean;
/** A `fetch` that refuses internal addresses (section 3). */
export declare function createSafeFetch(opts?: SafeFetchOptions): FetchLike;
/** The default `fetch` of this client, unless `insecureDev` asked for the plain one. */
export declare const safeFetch: FetchLike;
/**
* The `fetch` for a Company's URLs. `insecureDev` is the explicit opt-in that reaches local servers.
* A caller that injects its own `fetch` takes over this check.
*/
export declare function companyFetch(insecureDev: boolean | undefined): FetchLike;
//# sourceMappingURL=safe_fetch.d.ts.map