@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
65 lines • 3.28 kB
TypeScript
import type { StandardSchemaV1 } from '@standard-schema/spec';
import { type Catalog, type CatalogOptions, type ComponentDefinition } from './catalog.js';
import { type JsonSchema } from './schema.js';
/** Plain, durable data. Renderer functions and binary attachments never enter a UI frame. */
export interface ComponentPresentation<P = Record<string, unknown>> {
component: string;
props: P;
version: number;
fallbackText: string;
}
export interface ComponentFactory<Input, Output = Input> {
(props: Input): Promise<ComponentPresentation<Output>>;
readonly definition: ComponentDefinition<Output>;
}
/** Reject values JSON would silently discard/coerce, and detach from caller-owned objects. */
export declare function snapshotComponentPresentation<T>(value: T): T;
export declare function createComponent<S extends StandardSchemaV1>(definition: Omit<ComponentDefinition<StandardSchemaV1.InferOutput<S>>, 'props'> & {
props: S;
}, options?: CatalogOptions): ComponentFactory<StandardSchemaV1.InferInput<S>, StandardSchemaV1.InferOutput<S>>;
export declare function createComponent<P = Record<string, unknown>>(definition: ComponentDefinition<P>, options?: CatalogOptions): ComponentFactory<P>;
export type ComponentRenderer<P = Record<string, unknown>, Context = unknown> = (props: P, context?: Context) => unknown | Promise<unknown>;
export interface ComponentManifest {
name: string;
title: string;
description: string;
version: number;
props?: JsonSchema;
}
export interface ComponentRegistry<Context = unknown> {
readonly catalog: Catalog;
readonly manifest: readonly ComponentManifest[];
register<P>(definition: ComponentDefinition<P>, renderers: Record<string, ComponentRenderer<P, Context>>): this;
/** Revalidate against the app's authoritative definition and regenerate trusted fallback text. */
prepare(presentation: ComponentPresentation): Promise<ComponentPresentation>;
render(presentation: ComponentPresentation, channel: string, context?: Context): Promise<unknown>;
}
/** A registry is owned by one app/tenant; registering never mutates a shared singleton. */
export declare function createComponentRegistry<Context = unknown>(options?: CatalogOptions): ComponentRegistry<Context>;
export type TableCell = string | number | boolean | null;
export interface TableProps {
title?: string;
columns: {
key: string;
label: string;
align?: 'left' | 'right' | 'center';
format?: 'text' | 'number' | 'currency' | 'percent' | 'date' | 'link';
}[];
rows: Record<string, TableCell>[];
}
export interface ChartProps {
type: 'bar' | 'line';
title?: string;
xKey: string;
series: {
key: string;
label?: string;
}[];
data: Record<string, TableCell>[];
unit?: string;
}
export declare const table: ComponentFactory<TableProps, TableProps>;
export declare const chart: ComponentFactory<ChartProps, ChartProps>;
/** Prepare all JSON emissions before any sink receives a partial batch. Factories validate schemas. */
export declare function validatePresentationBatch(presentations: ComponentPresentation<object> | readonly ComponentPresentation<object>[]): ComponentPresentation[];
//# sourceMappingURL=registry.d.ts.map