@sema-agent/core
Version:
Stateless, task-oriented AI agent core
23 lines (22 loc) • 1.71 kB
TypeScript
import type { ImageContent } from "../../internal/llm.js";
import type { ImageInput } from "../types.js";
/**
* Block obviously-internal hosts (loopback / private ranges / link-local incl. cloud metadata / CGNAT / IPv6
* ULA, site-local, unspecified, IPv4-mapped, NAT64). Classifies with `net.isIP` rather than a string-prefix
* regex — the old regex both UNDER-matched (IPv4-mapped `::ffff:`, NAT64, CGNAT 100.64/10, `::`) and
* OVER-matched (any DNS name starting `fc`/`fd`, e.g. `fdpartners.com`). Numeric IPv4 forms (decimal/octal/hex)
* are normalized to dotted-decimal by `URL` before this is called, so they're already covered.
* Note: this checks the LITERAL host; it does NOT resolve DNS, so a hostname resolving to a private IP is not
* caught here (documented limitation — a deployment needing that supplies its own resolve-and-pin guard).
*/
export declare function isPrivateHost(host: string): boolean;
/**
* Default SSRF guard for a remote image URL: https only, and no internal/reserved hosts (so an
* end-user-supplied `images[].url` can't make the server fetch `169.254.169.254` or a private box).
* Note: this checks the URL host literally — it does not resolve DNS, so a hostname that resolves to
* a private IP is not caught here; a deployment needing that should supply `RunnerDeps.allowImageUrl`
* (e.g. a CDN allowlist or a resolve-and-pin check). Throws on a disallowed URL.
*/
export declare function defaultImageUrlGuard(raw: string): void;
/** Resolve an {@link ImageInput} (inline base64 or a URL to fetch) into a vendored `ImageContent` block. */
export declare function toImageContent(img: ImageInput, allowUrl?: (url: string) => boolean): Promise<ImageContent>;