mlola-ui 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ /** Types for Mlola Render's check (check.js). See docs/render.md. */
2
+
3
+ export type RenderPropKind = "text" | "boolean" | "number" | "integer" | "date" | "enum" | "children" | "action" | "options" | "columns" | "rows";
4
+
5
+ export interface RenderProp {
6
+ kind: RenderPropKind;
7
+ required?: boolean;
8
+ description?: string;
9
+ values?: string[];
10
+ excluded?: string[];
11
+ default?: string | number | boolean;
12
+ maxLength?: number;
13
+ minimum?: number;
14
+ maximum?: number;
15
+ minItems?: number;
16
+ literal?: boolean;
17
+ align?: { values: string[] };
18
+ }
19
+
20
+ export interface RenderComponent {
21
+ group: string;
22
+ description: string;
23
+ accepts?: string[];
24
+ parents?: string[];
25
+ mlola: { item?: string; export?: string; class?: string; element?: string };
26
+ props: Record<string, RenderProp>;
27
+ }
28
+
29
+ export interface RenderExample {
30
+ name: string;
31
+ title: string;
32
+ description: string;
33
+ messages: unknown[];
34
+ }
35
+
36
+ /** render-rules.json: mlola-ui/render/rules, or @mlola-ui/registry/render/rules. */
37
+ export interface RenderRules {
38
+ version: string;
39
+ catalogId: string;
40
+ title: string;
41
+ description: string;
42
+ protocolVersions: string[];
43
+ themes: string[];
44
+ defaultTheme: string;
45
+ modes: string[];
46
+ /** Each group's title, in the order the guide and the docs list them. */
47
+ groups: Record<string, string>;
48
+ limits: Record<
49
+ "messages" | "surfaces" | "components" | "depth" | "idLength" | "textLength" | "labelLength" | "options" | "columns" | "rows" | "contextKeys" | "pathLength" | "dataBytes" | "inputBytes",
50
+ number
51
+ >;
52
+ components: Record<string, RenderComponent>;
53
+ aliases: Record<string, string>;
54
+ /** What agents reach for from A2UI's basic catalog, and what to use instead: by component, and by prop, Component.prop or Component.prop=value. */
55
+ borrowed: { components: Record<string, string>; props: Record<string, string> };
56
+ examples: RenderExample[];
57
+ }
58
+
59
+ /** A2UI's error shape: an agent reads `path` (a JSON Pointer into the input) and `message`, and corrects the call. */
60
+ export interface RenderIssue {
61
+ code: "VALIDATION_FAILED" | "ADVICE";
62
+ surfaceId: string;
63
+ path: string;
64
+ message: string;
65
+ }
66
+
67
+ export interface RenderSurface {
68
+ surfaceId: string;
69
+ deleted: boolean;
70
+ theme: { name: string; mode: string };
71
+ components: number;
72
+ }
73
+
74
+ export interface RenderResult {
75
+ /** True when nothing stops the messages rendering. */
76
+ valid: boolean;
77
+ /** What stops them rendering. */
78
+ errors: RenderIssue[];
79
+ /** Advice that does not: a component outside the tree, two primary buttons, two fields with one label. */
80
+ advice: RenderIssue[];
81
+ surfaces: RenderSurface[];
82
+ }
83
+
84
+ export interface RenderState {
85
+ rules: RenderRules;
86
+ }
87
+
88
+ /** Checks A2UI messages (an object, an array, or their JSON or JSON Lines text) against the Mlola catalog. */
89
+ export function validateRender(input: unknown, rules: RenderRules): RenderResult;
90
+
91
+ /** Reads one message, an array of messages, or JSON Lines. */
92
+ export function parseRenderInput(source: unknown, limits?: RenderRules["limits"]): { messages: unknown; error: string | null };
93
+
94
+ /** For a stream: keep one state, apply each message as it arrives, then check the surfaces before drawing. */
95
+ export function createRenderState(rules: RenderRules): RenderState;
96
+ export function applyRenderMessages(state: RenderState, input: unknown): { errors: RenderIssue[]; advice: RenderIssue[] };
97
+ export function checkSurfaces(state: RenderState, issues?: { errors: RenderIssue[]; advice: RenderIssue[] }): { errors: RenderIssue[]; advice: RenderIssue[] };
98
+
99
+ /** One surface, checked whole: how it was created, every component it holds now and their tree. */
100
+ export function checkSurface(state: RenderState, surfaceId: string): { errors: RenderIssue[]; advice: RenderIssue[] };
101
+
102
+ /** The catalog as Markdown an agent reads before composing a surface. */
103
+ export function renderCatalogGuide(rules: RenderRules): string;
104
+
105
+ /** A result as lines for a terminal or a tool reply. */
106
+ export function formatRenderReport(result: RenderResult): string;