@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
63 lines • 3.5 kB
TypeScript
import type { AuthServerMetadata, PoppyDocument } from './types.js';
import { type FetchLike, type SecurityOptions } from './util.js';
/** Before 1.0 each `major.minor` can break the last, so these are exact versions (3.1). */
export declare const SUPPORTED_PROTOCOL_VERSIONS: string[];
export declare const WELL_KNOWN_POPPY_PATH = "/.well-known/poppy.json";
export interface DiscoveryOptions extends SecurityOptions {
fetch?: FetchLike | undefined;
/** Shared cache honoring `Cache-Control: max-age` (3, 3.2: SHOULD cache). */
cache?: HttpJsonCache | undefined;
}
export interface Discovered {
/** The host that served the document, after any redirects (with a port only in dev). */
domain: string;
wellKnownUrl: string;
document: PoppyDocument;
/** The Company's identifier (3.2): its issuer, or `https://{domain}` without one. */
identifier: string;
/** Absent when the Company has no issuer: it offers only signed-out Sessions. */
metadata?: AuthServerMetadata | undefined;
/**
* How discovery established there is no issuer. Only `metadata` says so explicitly, which is what
* lets an agent that knew an issuer accept its removal (3.2).
*/
noIssuer?: 'not_found' | 'metadata' | undefined;
}
/** In-memory cache of JSON documents by URL, by `Cache-Control: max-age`. */
export declare class HttpJsonCache {
private readonly entries;
get(url: string): FetchedJson | undefined;
set(url: string, value: FetchedJson, cacheControl: string | null): void;
}
/**
* Turns user input into the well-known URL. `example.com` → `https://example.com/...`.
* With `insecureDev`, an explicit `http://host:port` is kept, and a bare loopback host
* (`localhost:3333`) defaults to `http:`.
*/
interface FetchedJson {
json: unknown;
finalUrl: URL;
}
export declare function wellKnownUrlFor(input: string, sec?: SecurityOptions): URL;
/** Validates `poppy.json` against 3.1. Unknown fields are ignored, never rejected. */
export declare function validatePoppyDocument(json: unknown, servedHost: string, sec?: SecurityOptions): PoppyDocument;
/** RFC 9728 section 3.1: the well-known suffix goes between the host and the resource's path. */
export declare function protectedResourceMetadataUrl(resource: string | URL): URL;
/**
* Validates the domain's protected resource metadata (3.2) and answers the issuer the Personal
* Agent uses, or `undefined` when valid metadata names none.
*/
export declare function validateProtectedResourceMetadata(json: unknown, doc: PoppyDocument, domainUrl: string, sec?: SecurityOptions): string | undefined;
/** RFC 8414 section 3: the well-known suffix goes between the host and the issuer's path. */
export declare function authServerMetadataUrl(issuer: string): URL;
/** Validates the issuer metadata against 3.2. */
export declare function validateMetadata(json: unknown, issuer: string, domainUrl: string, sec?: SecurityOptions): AuthServerMetadata;
/**
* Discovery (section 3): fetches `/.well-known/poppy.json`, which must end at that exact path after
* HTTPS-only redirects, then finds the issuer from the domain's protected resource metadata and
* checks both directions of the link. A timeout, another error status or invalid metadata throws:
* only a 404 or valid metadata without servers means there is no issuer (3.2).
*/
export declare function discover(input: string, opts?: DiscoveryOptions): Promise<Discovered>;
export {};
//# sourceMappingURL=discovery.d.ts.map