@dudousxd/nestjs-agent-core 0.41.0 → 0.42.1
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.
- package/dist/ag-ui/index.cjs +66 -12
- package/dist/ag-ui/index.cjs.map +1 -1
- package/dist/ag-ui/index.d.cts +52 -11
- package/dist/ag-ui/index.d.ts +52 -11
- package/dist/ag-ui/index.js +64 -12
- package/dist/ag-ui/index.js.map +1 -1
- package/dist/{catalog-BKS3Yxo6.d.cts → catalog-G8usJpx5.d.cts} +11 -2
- package/dist/{catalog-BKS3Yxo6.d.ts → catalog-G8usJpx5.d.ts} +11 -2
- package/dist/genui/builtins.cjs +41 -10
- package/dist/genui/builtins.cjs.map +1 -1
- package/dist/genui/builtins.d.cts +1 -1
- package/dist/genui/builtins.d.ts +1 -1
- package/dist/genui/builtins.js +41 -10
- package/dist/genui/builtins.js.map +1 -1
- package/dist/genui/index.cjs +71 -34
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +8 -6
- package/dist/genui/index.d.ts +8 -6
- package/dist/genui/index.js +70 -34
- package/dist/genui/index.js.map +1 -1
- package/dist/guardrails/index.d.cts +3 -3
- package/dist/guardrails/index.d.ts +3 -3
- package/dist/index.cjs +56 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +56 -23
- package/dist/index.js.map +1 -1
- package/dist/{processors-BXM-MNga.d.cts → processors-BANqZT3O.d.cts} +1 -1
- package/dist/{processors-ByDr5POu.d.ts → processors-C9mor-73.d.ts} +1 -1
- package/dist/{stream-events-BGKLD6RX.d.ts → stream-events-BfxJAckJ.d.cts} +21 -2
- package/dist/{stream-events-CF-6-Y6L.d.cts → stream-events-DFa2Do42.d.ts} +21 -2
- package/package.json +1 -1
|
@@ -89,7 +89,9 @@ interface ComponentDefinition<P = Record<string, unknown>> {
|
|
|
89
89
|
outputProps?: PropsSchema;
|
|
90
90
|
/**
|
|
91
91
|
* The component takes nested elements (a layout: `Stack`, `Card`). Only meaningful in tree mode,
|
|
92
|
-
* where a node's `children` are validated against the catalog too.
|
|
92
|
+
* where a node's `children` are validated against the catalog too. Such a component gets no
|
|
93
|
+
* `ui__show_*` tool and is not offered by the show tool ({@link flatComponents}), and when its
|
|
94
|
+
* {@link fallbackText} comes out empty it writes no text of its own (its children still do).
|
|
93
95
|
*/
|
|
94
96
|
children?: boolean;
|
|
95
97
|
/**
|
|
@@ -136,6 +138,13 @@ interface Catalog {
|
|
|
136
138
|
/** A new catalog with these components added (a later definition replaces an earlier one of the same name). */
|
|
137
139
|
extend(components: readonly ComponentDefinition<any>[]): Catalog;
|
|
138
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* The model components a FLAT tool can offer — one whose input is the component's props alone
|
|
143
|
+
* (`ui__show_<name>`, the generic show tool). A layout component (`children: true`) is left out:
|
|
144
|
+
* those tools have no way to pass it children, so it would only ever draw an empty box. Tree mode
|
|
145
|
+
* offers every model component.
|
|
146
|
+
*/
|
|
147
|
+
declare function flatComponents(catalog: Catalog): ComponentDefinition<any>[];
|
|
139
148
|
/**
|
|
140
149
|
* Collect component definitions into a {@link Catalog}. Names must be unique; to override a
|
|
141
150
|
* definition (e.g. a builtin), use {@link Catalog.extend}.
|
|
@@ -146,4 +155,4 @@ declare function toSnakeCase(name: string): string;
|
|
|
146
155
|
/** The per-component tool name: `ui__show_data_table` with the default prefix. */
|
|
147
156
|
declare function toolNameFor(component: string, prefix?: string): string;
|
|
148
157
|
|
|
149
|
-
export { type AjvLike as A, type ComponentDefinition as C, type GenuiValidation as G, type JsonSchema as J, type PropsSchema as P, type Catalog as a, type GenuiIssue as b, COMPONENT_NAME as c, type CatalogOptions as d, type JsonSchemaValidator as e, ajvValidator as f, builtinJsonSchemaValidator as g, defineCatalog as h, defineComponent as i,
|
|
158
|
+
export { type AjvLike as A, type ComponentDefinition as C, type GenuiValidation as G, type JsonSchema as J, type PropsSchema as P, type Catalog as a, type GenuiIssue as b, COMPONENT_NAME as c, type CatalogOptions as d, type JsonSchemaValidator as e, ajvValidator as f, builtinJsonSchemaValidator as g, defineCatalog as h, defineComponent as i, flatComponents as j, formatIssues as k, isStandardSchema as l, toSnakeCase as m, toolNameFor as n, validatePropsSync as o, toJsonSchema as t, validateProps as v };
|
package/dist/genui/builtins.cjs
CHANGED
|
@@ -243,18 +243,49 @@ var Chart = defineComponent({
|
|
|
243
243
|
"series",
|
|
244
244
|
"data"
|
|
245
245
|
]),
|
|
246
|
-
fallbackText: /* @__PURE__ */ __name((props) =>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
fallbackText: /* @__PURE__ */ __name((props) => chartText(props), "fallbackText")
|
|
247
|
+
});
|
|
248
|
+
function chartText(props) {
|
|
249
|
+
const series = (props.series ?? []).filter((each) => typeof each?.key === "string");
|
|
250
|
+
const data = props.data ?? [];
|
|
251
|
+
const unit = props.unit ? ` ${s(props.unit)}` : "";
|
|
252
|
+
const labelOf = /* @__PURE__ */ __name((each) => s(each.label) || each.key, "labelOf");
|
|
253
|
+
if (props.type === "line") {
|
|
254
|
+
const columns = [
|
|
255
|
+
{
|
|
256
|
+
key: s(props.xKey),
|
|
257
|
+
label: s(props.xKey)
|
|
258
|
+
},
|
|
259
|
+
...series.map((each) => ({
|
|
260
|
+
key: each.key,
|
|
261
|
+
label: `${labelOf(each)}${unit}`
|
|
262
|
+
}))
|
|
263
|
+
];
|
|
264
|
+
return `${heading(props)}${textTable(columns, data, 20)}`;
|
|
265
|
+
}
|
|
266
|
+
const max = Math.max(0, ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))));
|
|
267
|
+
const shown = data.slice(0, 20);
|
|
268
|
+
const lines = [];
|
|
269
|
+
if (series.length <= 1) {
|
|
270
|
+
const key = series[0]?.key ?? "";
|
|
271
|
+
for (const point of shown) {
|
|
272
|
+
lines.push(`${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`);
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));
|
|
276
|
+
for (const point of shown) {
|
|
277
|
+
lines.push(s(point[props.xKey]).slice(0, 18));
|
|
278
|
+
for (const each of series) {
|
|
279
|
+
lines.push(` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (data.length > shown.length) lines.push(`\u2026 ${data.length - shown.length} more points`);
|
|
284
|
+
return `${heading(props)}\`\`\`
|
|
254
285
|
${lines.join("\n")}
|
|
255
286
|
\`\`\``;
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
}
|
|
288
|
+
__name(chartText, "chartText");
|
|
258
289
|
var KpiCards = defineComponent({
|
|
259
290
|
name: "KpiCards",
|
|
260
291
|
title: "KPI cards",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/genui/builtins.ts","../../src/genui/catalog.ts"],"sourcesContent":["/**\n * Optional builtin component DEFINITIONS — names, props schemas, model descriptions and plain-text\n * fallbacks for the components most chat apps want. No visuals: an app renders each with its own\n * look, keyed by name. Use them as-is, pick some, or extend them:\n *\n * ```ts\n * const catalog = defineCatalog([...BUILTIN_COMPONENTS, ...LAYOUT_COMPONENTS, myDealCard]);\n * ```\n */\nimport { type ComponentDefinition, defineComponent } from './catalog.js';\nimport type { JsonSchema } from './schema.js';\n\ntype Props = Record<string, any>;\n\nconst str = (description?: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n ...(description !== undefined ? { description } : {}),\n ...extra,\n});\nconst obj = (properties: Record<string, JsonSchema>, required: string[] = []): JsonSchema => ({\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n});\nconst arr = (items: JsonSchema, extra: JsonSchema = {}): JsonSchema => ({\n type: 'array',\n items,\n ...extra,\n});\nconst cell: JsonSchema = { type: ['string', 'number', 'boolean', 'null'] };\nconst row: JsonSchema = { type: 'object', additionalProperties: cell };\n\nconst s = (value: unknown): string => (value === null || value === undefined ? '' : String(value));\nconst heading = (props: Props): string => (props.title ? `*${s(props.title)}*\\n` : '');\n\n/** A fixed-width text table in a code block, at most `max` rows. */\nexport function textTable(\n columns: readonly { key: string; label: string }[],\n rows: readonly Props[],\n max = 15,\n): string {\n const shown = rows.slice(0, max);\n const widths = columns.map((column) =>\n Math.min(28, Math.max(column.label.length, ...shown.map((r) => s(r[column.key]).length))),\n );\n const format = (values: string[]) =>\n values\n .map((value, index) => value.slice(0, widths[index]).padEnd(widths[index] ?? 0))\n .join(' ');\n const lines = [\n format(columns.map((column) => column.label)),\n widths.map((width) => '-'.repeat(width)).join(' '),\n ...shown.map((r) => format(columns.map((column) => s(r[column.key])))),\n ];\n if (rows.length > max) lines.push(`… ${rows.length - max} more rows`);\n return `\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport interface DiffLine {\n op: 'same' | 'add' | 'del';\n text: string;\n}\n\n/** Line diff (LCS) — good enough for snippets up to a few hundred lines. */\nexport function lineDiff(before: string, after: string): DiffLine[] {\n const a = before.split('\\n');\n const b = after.split('\\n');\n if (a.length * b.length > 250_000) {\n return [\n ...a.map((text) => ({ op: 'del' as const, text })),\n ...b.map((text) => ({ op: 'add' as const, text })),\n ];\n }\n const dp: number[][] = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n );\n const at = (i: number, j: number): number => dp[i]?.[j] ?? 0;\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n (dp[i] as number[])[j] =\n a[i] === b[j] ? at(i + 1, j + 1) + 1 : Math.max(at(i + 1, j), at(i, j + 1));\n }\n }\n const out: DiffLine[] = [];\n let i = 0;\n let j = 0;\n while (i < a.length && j < b.length) {\n if (a[i] === b[j]) {\n out.push({ op: 'same', text: a[i] as string });\n i++;\n j++;\n } else if (at(i + 1, j) >= at(i, j + 1)) {\n out.push({ op: 'del', text: a[i++] as string });\n } else {\n out.push({ op: 'add', text: b[j++] as string });\n }\n }\n while (i < a.length) out.push({ op: 'del', text: a[i++] as string });\n while (j < b.length) out.push({ op: 'add', text: b[j++] as string });\n return out;\n}\n\nfunction bar(value: number, max: number, width = 20): string {\n const n = max > 0 ? Math.round((Math.abs(value) / max) * width) : 0;\n return '█'.repeat(n) || '▏';\n}\n\nexport const DataTable = defineComponent<Props>({\n name: 'DataTable',\n title: 'Data table',\n description:\n 'Tabular data (records with the same fields) as a sortable table. Prefer it over markdown tables for more than 3 rows.',\n props: obj(\n {\n title: str('Short caption'),\n columns: arr(\n obj(\n {\n key: str('Field name in each row'),\n label: str('Column header'),\n align: str(undefined, { enum: ['left', 'right', 'center'] }),\n format: str('How to format values', {\n enum: ['text', 'number', 'currency', 'percent', 'date', 'link'],\n }),\n },\n ['key', 'label'],\n ),\n { minItems: 1, maxItems: 12 },\n ),\n rows: arr(row, { maxItems: 500 }),\n },\n ['columns', 'rows'],\n ),\n fallbackText: (props) => `${heading(props)}${textTable(props.columns ?? [], props.rows ?? [])}`,\n});\n\nexport const Chart = defineComponent<Props>({\n name: 'Chart',\n title: 'Chart',\n description:\n '`bar` to compare categories, `line` for a trend over time. `data` is a list of points; `xKey` names the category/time field and each series names a numeric field.',\n props: obj(\n {\n type: str('Chart type', { enum: ['bar', 'line'] }),\n title: str(),\n xKey: str('Field of each point used for the x axis'),\n series: arr(obj({ key: str('Numeric field'), label: str() }, ['key']), {\n minItems: 1,\n maxItems: 6,\n }),\n data: arr(row, { minItems: 1, maxItems: 200 }),\n unit: str('Unit shown after values, e.g. `KB` or `%`'),\n },\n ['type', 'xKey', 'series', 'data'],\n ),\n fallbackText: (props) => {\n const series: { key: string }[] = props.series ?? [];\n const data: Props[] = props.data ?? [];\n const first = series[0]?.key ?? '';\n const max = Math.max(0, ...data.map((point) => Math.abs(Number(point[first]) || 0)));\n const unit = props.unit ? ` ${s(props.unit)}` : '';\n const lines = data\n .slice(0, 20)\n .map(\n (point) =>\n `${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[first]) || 0, max)} ${s(point[first])}${unit}`,\n );\n return `${heading(props)}\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n },\n});\n\nexport const KpiCards = defineComponent<Props>({\n name: 'KpiCards',\n title: 'KPI cards',\n description: 'A few key numbers (metrics, totals, counts) as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj(\n {\n label: str(),\n value: { type: ['string', 'number'] },\n delta: str('Change, e.g. `+12%`'),\n trend: str(undefined, { enum: ['up', 'down', 'flat'] }),\n hint: str(),\n },\n ['label', 'value'],\n ),\n { minItems: 1, maxItems: 8 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• *${s(item.label)}:* ${s(item.value)}${item.delta ? ` (${s(item.delta)})` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const SourceCards = defineComponent<Props>({\n name: 'SourceCards',\n title: 'Sources',\n description: 'The documents, pages or links an answer is based on, as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj({ title: str(), url: str(), snippet: str(), source: str('e.g. Wiki, GitHub') }, [\n 'title',\n ]),\n { minItems: 1, maxItems: 12 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• ${item.url ? `<${s(item.url)}|${s(item.title)}>` : s(item.title)}${item.source ? ` — ${s(item.source)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Checklist = defineComponent<Props>({\n name: 'Checklist',\n title: 'Checklist',\n description: 'Steps or a to-do list with done/not-done state.',\n props: obj(\n {\n title: str(),\n items: arr(obj({ label: str(), done: { type: 'boolean' }, note: str() }, ['label']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `${item.done ? '☑' : '☐'} ${s(item.label)}${item.note ? ` — _${s(item.note)}_` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Timeline = defineComponent<Props>({\n name: 'Timeline',\n title: 'Timeline',\n description: 'Events in chronological order (the history of a project, an incident, a deal).',\n props: obj(\n {\n title: str(),\n events: arr(obj({ date: str(), title: str(), description: str() }, ['title']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['events'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.events ?? [])\n .map(\n (event: Props) =>\n `• ${event.date ? `*${s(event.date)}* ` : ''}${s(event.title)}${event.description ? ` — ${s(event.description)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const CodeBlock = defineComponent<Props>({\n name: 'CodeBlock',\n title: 'Code',\n description: 'A code snippet or file excerpt with syntax highlighting.',\n props: obj({ title: str(), language: str(), code: str() }, ['code']),\n fallbackText: (props) => `${heading(props)}\\`\\`\\`\\n${s(props.code)}\\n\\`\\`\\``,\n});\n\nexport const Diff = defineComponent<Props>({\n name: 'Diff',\n title: 'Diff',\n description: 'A before/after change to a text or code file, as a line diff.',\n props: obj({ title: str(), language: str(), before: str(), after: str() }, ['before', 'after']),\n fallbackText: (props) =>\n `${heading(props)}\\`\\`\\`\\n${lineDiff(s(props.before), s(props.after))\n .map((line) => `${line.op === 'add' ? '+' : line.op === 'del' ? '-' : ' '} ${line.text}`)\n .join('\\n')}\\n\\`\\`\\``,\n});\n\nexport const Callout = defineComponent<Props>({\n name: 'Callout',\n title: 'Callout',\n description: 'A short note, warning or success message, emphasized.',\n props: obj(\n {\n tone: str(undefined, { enum: ['info', 'success', 'warning', 'danger'] }),\n title: str(),\n text: str(),\n },\n ['text'],\n ),\n fallbackText: (props) =>\n `${props.tone === 'warning' || props.tone === 'danger' ? ':warning: ' : ':information_source: '}${heading(props)}${s(props.text)}`,\n});\n\nexport const Stack = defineComponent<Props>({\n name: 'Stack',\n title: 'Stack',\n description: 'Lays its children out vertically (or horizontally with direction=row).',\n props: obj({ direction: str(undefined, { enum: ['column', 'row'] }), gap: { type: 'number' } }),\n children: true,\n fallbackText: () => '',\n});\n\nexport const Card = defineComponent<Props>({\n name: 'Card',\n title: 'Card',\n description: 'A box with an optional title around its children.',\n props: obj({ title: str(), subtitle: str() }),\n children: true,\n fallbackText: (props) =>\n props.title ? `*${s(props.title)}*${props.subtitle ? ` — ${s(props.subtitle)}` : ''}` : '',\n});\n\nexport const Heading = defineComponent<Props>({\n name: 'Heading',\n title: 'Heading',\n description: 'A heading.',\n props: obj({ text: str() }, ['text']),\n fallbackText: (props) => `*${s(props.text)}*`,\n});\n\nexport const Text = defineComponent<Props>({\n name: 'Text',\n title: 'Text',\n description: 'A paragraph of plain text (no markdown).',\n props: obj({ text: str(), muted: { type: 'boolean' } }, ['text']),\n fallbackText: (props) => s(props.text),\n});\n\nexport const Badge = defineComponent<Props>({\n name: 'Badge',\n title: 'Badge',\n description: 'A small label.',\n props: obj(\n {\n text: str(),\n tone: str(undefined, { enum: ['neutral', 'brand', 'success', 'warning', 'danger'] }),\n },\n ['text'],\n ),\n fallbackText: (props) => `[${s(props.text)}]`,\n});\n\nexport const Link = defineComponent<Props>({\n name: 'Link',\n title: 'Link',\n description: 'A link to an http(s) URL.',\n props: obj({ text: str(), url: str(undefined, { pattern: '^https?://' }) }, ['text', 'url']),\n fallbackText: (props) => `<${s(props.url)}|${s(props.text || props.url)}>`,\n});\n\nexport const Image = defineComponent<Props>({\n name: 'Image',\n title: 'Image',\n description: 'An image from an https URL.',\n props: obj({ url: str(undefined, { pattern: '^https://' }), alt: str() }, ['url']),\n fallbackText: (props) => s(props.url),\n});\n\n/** Content components: data a model shows. */\nexport const BUILTIN_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n DataTable,\n Chart,\n KpiCards,\n SourceCards,\n Checklist,\n Timeline,\n CodeBlock,\n Diff,\n Callout,\n];\n\n/** Layout and text primitives, mostly for composing trees (`Stack`, `Card` take children). */\nexport const LAYOUT_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n Stack,\n Card,\n Heading,\n Text,\n Badge,\n Link,\n Image,\n];\n","import {\n type GenuiValidation,\n type JsonSchema,\n type JsonSchemaValidator,\n type PropsSchema,\n builtinJsonSchemaValidator,\n toJsonSchema,\n validateProps,\n validatePropsSync,\n} from './schema.js';\n\n/**\n * One component a server may push into a conversation. Data only — how it LOOKS is each app's own\n * renderer, looked up by {@link name}. The same definition serves the model (description + props\n * schema), the server (validation), text-only channels ({@link fallbackText}) and the client\n * (validation before rendering).\n */\nexport interface ComponentDefinition<P = Record<string, unknown>> {\n /** Registry key, e.g. `DataTable`. What a `ui` frame's `component` names. */\n name: string;\n /** Human label: \"Data table\". */\n title: string;\n /** Shown to the model: what the component is for and when to use it. */\n description: string;\n /** The props schema: a Standard Schema (Zod, Valibot, ArkType) or a JSON Schema object. */\n props: PropsSchema;\n /** Portable normalized props schema. Required when input transformations are not idempotent. */\n outputProps?: PropsSchema;\n /**\n * The component takes nested elements (a layout: `Stack`, `Card`). Only meaningful in tree mode,\n * where a node's `children` are validated against the catalog too.\n */\n children?: boolean;\n /**\n * Plain text / Slack mrkdwn rendering of these props, for a channel that cannot draw the\n * component. Absent → {@link componentToText} prints the props as JSON.\n */\n fallbackText?: (props: P) => string;\n /**\n * Pushed by the server (e.g. an approval card), never offered to the model. Excluded from\n * {@link catalogToModelText} and from the tool factories.\n */\n internal?: boolean;\n /**\n * Schema version of {@link props}. Stamped on every `ui` frame the component is pushed with, so a\n * client can keep rendering messages persisted under an older shape.\n */\n version?: number;\n}\n\n/** Component names: an identifier a registry key, a tool name and a snake_case slug can all be derived from. */\nexport const COMPONENT_NAME = /^[A-Za-z][A-Za-z0-9]{0,63}$/;\n\n/** Declare a component. Validates the name and returns the definition unchanged (typed). */\nexport function defineComponent<P = Record<string, unknown>>(\n definition: ComponentDefinition<P>,\n): ComponentDefinition<P> {\n if (!COMPONENT_NAME.test(definition.name)) {\n throw new Error(\n `genui: component name \"${definition.name}\" must be letters and digits, starting with a letter (e.g. DataTable)`,\n );\n }\n if (\n definition.version !== undefined &&\n (!Number.isSafeInteger(definition.version) || definition.version <= 0)\n )\n throw new RangeError('genui: component version must be a positive safe integer');\n if (definition.fallbackText !== undefined && typeof definition.fallbackText !== 'function')\n throw new TypeError('genui: fallbackText must be a function');\n return definition;\n}\n\nexport interface CatalogOptions {\n /** How JSON Schema props are checked. Default: {@link builtinJsonSchemaValidator}; pass `ajvValidator(new Ajv())` for full JSON Schema. */\n jsonSchemaValidator?: JsonSchemaValidator;\n}\n\n/** An immutable set of component definitions, looked up by name. */\nexport interface Catalog {\n readonly components: readonly ComponentDefinition<any>[];\n readonly validator: JsonSchemaValidator;\n get(name: string): ComponentDefinition<any> | undefined;\n has(name: string): boolean;\n /** The components a model may be offered (every non-`internal` one). */\n modelComponents(): ComponentDefinition<any>[];\n /** Validate `props` for `component`. An unknown component is a validation failure, not a throw. */\n validate(component: string, props: unknown): Promise<GenuiValidation<Record<string, unknown>>>;\n /**\n * {@link validate} without waiting — `undefined` only when the component's Standard Schema\n * validates asynchronously. An unknown component is a failure, as in `validate`.\n */\n validateSync(\n component: string,\n props: unknown,\n ): GenuiValidation<Record<string, unknown>> | undefined;\n /** The component's props as JSON Schema, when it can be derived (see {@link toJsonSchema}). */\n jsonSchemaFor(component: string): JsonSchema | undefined;\n /** A new catalog with these components added (a later definition replaces an earlier one of the same name). */\n extend(components: readonly ComponentDefinition<any>[]): Catalog;\n}\n\n/**\n * Collect component definitions into a {@link Catalog}. Names must be unique; to override a\n * definition (e.g. a builtin), use {@link Catalog.extend}.\n */\nexport function defineCatalog(\n components: readonly ComponentDefinition<any>[],\n options: CatalogOptions = {},\n): Catalog {\n const byName = new Map<string, ComponentDefinition<any>>();\n for (const component of components) {\n defineComponent(component);\n if (byName.has(component.name)) {\n throw new Error(`genui: component \"${component.name}\" is defined twice in one catalog`);\n }\n byName.set(component.name, component);\n }\n return buildCatalog(byName, options.jsonSchemaValidator ?? builtinJsonSchemaValidator);\n}\n\nfunction buildCatalog(\n byName: Map<string, ComponentDefinition<any>>,\n validator: JsonSchemaValidator,\n): Catalog {\n const list = Object.freeze([...byName.values()]);\n return {\n components: list,\n validator,\n get: (name) => byName.get(name),\n has: (name) => byName.has(name),\n modelComponents: () => list.filter((component) => component.internal !== true),\n async validate(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n const result = await validateProps(\n definition.outputProps ?? definition.props,\n props,\n validator,\n );\n return result as GenuiValidation<Record<string, unknown>>;\n },\n validateSync(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n return validatePropsSync(definition.outputProps ?? definition.props, props, validator) as\n | GenuiValidation<Record<string, unknown>>\n | undefined;\n },\n jsonSchemaFor(component) {\n const definition = byName.get(component);\n return definition === undefined\n ? undefined\n : toJsonSchema(definition.outputProps ?? definition.props);\n },\n extend(more) {\n const next = new Map(byName);\n for (const component of more) {\n defineComponent(component);\n next.set(component.name, component);\n }\n return buildCatalog(next, validator);\n },\n };\n}\n\n/** `DataTable` → `data_table`, `KPICards` → `kpi_cards`. */\nexport function toSnakeCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase();\n}\n\n/** The per-component tool name: `ui__show_data_table` with the default prefix. */\nexport function toolNameFor(component: string, prefix = 'ui__show_'): string {\n return `${prefix}${toSnakeCase(component)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;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IAAIJ,EAAEI,MAAMgC,IAAI,CAAA,KAA3B;AAChB,CAAA;AAEO,IAAM+D,OAAOhD,gBAAuB;EACzCC,MAAM;EACN/C,OAAO;EACPjB,aAAa;EACbgB,OAAOZ,IAAI;IAAE4C,MAAMjD,IAAAA;IAAOqF,KAAKrF,IAAII,QAAW;MAAE6G,SAAS;IAAa,CAAA;EAAG,GAAG;IAAC;IAAQ;GAAM;EAC3F3C,cAAc,wBAACrD,UAAU,IAAIJ,EAAEI,MAAMoE,GAAG,CAAA,IAAKxE,EAAEI,MAAMgC,QAAQhC,MAAMoE,GAAG,CAAA,KAAxD;AAChB,CAAA;AAEO,IAAM6B,QAAQlD,gBAAuB;EAC1CC,MAAM;EACN/C,OAAO;EACPjB,aAAa;EACbgB,OAAOZ,IAAI;IAAEgF,KAAKrF,IAAII,QAAW;MAAE6G,SAAS;IAAY,CAAA;IAAIE,KAAKnH,IAAAA;EAAM,GAAG;IAAC;GAAM;EACjFsE,cAAc,wBAACrD,UAAUJ,EAAEI,MAAMoE,GAAG,GAAtB;AAChB,CAAA;AAGO,IAAM+B,qBAA4D;EACvErD;EACAQ;EACAQ;EACAK;EACAI;EACAG;EACAI;EACAG;EACAE;;AAIK,IAAMiB,oBAA2D;EACtEf;EACAI;EACAE;EACAC;EACAE;EACAC;EACAE;;","names":["COMPONENT_NAME","defineComponent","definition","test","name","Error","version","undefined","Number","isSafeInteger","RangeError","fallbackText","TypeError","str","description","extra","type","undefined","obj","properties","required","additionalProperties","arr","items","cell","row","s","value","String","heading","props","title","textTable","columns","rows","max","shown","slice","widths","map","column","Math","min","label","length","r","key","format","values","index","padEnd","join","lines","width","repeat","push","lineDiff","before","after","a","split","b","text","op","dp","Array","from","fill","at","i","j","out","bar","n","round","abs","DataTable","defineComponent","name","align","enum","minItems","maxItems","fallbackText","Chart","xKey","series","data","unit","first","point","Number","KpiCards","delta","trend","hint","item","SourceCards","url","snippet","source","Checklist","done","note","Timeline","events","date","event","CodeBlock","language","code","Diff","line","Callout","tone","Stack","direction","gap","children","Card","subtitle","Heading","Text","muted","Badge","Link","pattern","Image","alt","BUILTIN_COMPONENTS","LAYOUT_COMPONENTS"]}
|
|
1
|
+
{"version":3,"sources":["../../src/genui/builtins.ts","../../src/genui/catalog.ts"],"sourcesContent":["/**\n * Optional builtin component DEFINITIONS — names, props schemas, model descriptions and plain-text\n * fallbacks for the components most chat apps want. No visuals: an app renders each with its own\n * look, keyed by name. Use them as-is, pick some, or extend them:\n *\n * ```ts\n * const catalog = defineCatalog([...BUILTIN_COMPONENTS, ...LAYOUT_COMPONENTS, myDealCard]);\n * ```\n */\nimport { type ComponentDefinition, defineComponent } from './catalog.js';\nimport type { JsonSchema } from './schema.js';\n\ntype Props = Record<string, any>;\n\nconst str = (description?: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n ...(description !== undefined ? { description } : {}),\n ...extra,\n});\nconst obj = (properties: Record<string, JsonSchema>, required: string[] = []): JsonSchema => ({\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n});\nconst arr = (items: JsonSchema, extra: JsonSchema = {}): JsonSchema => ({\n type: 'array',\n items,\n ...extra,\n});\nconst cell: JsonSchema = { type: ['string', 'number', 'boolean', 'null'] };\nconst row: JsonSchema = { type: 'object', additionalProperties: cell };\n\nconst s = (value: unknown): string => (value === null || value === undefined ? '' : String(value));\nconst heading = (props: Props): string => (props.title ? `*${s(props.title)}*\\n` : '');\n\n/** A fixed-width text table in a code block, at most `max` rows. */\nexport function textTable(\n columns: readonly { key: string; label: string }[],\n rows: readonly Props[],\n max = 15,\n): string {\n const shown = rows.slice(0, max);\n const widths = columns.map((column) =>\n Math.min(28, Math.max(column.label.length, ...shown.map((r) => s(r[column.key]).length))),\n );\n const format = (values: string[]) =>\n values\n .map((value, index) => value.slice(0, widths[index]).padEnd(widths[index] ?? 0))\n .join(' ');\n const lines = [\n format(columns.map((column) => column.label)),\n widths.map((width) => '-'.repeat(width)).join(' '),\n ...shown.map((r) => format(columns.map((column) => s(r[column.key])))),\n ];\n if (rows.length > max) lines.push(`… ${rows.length - max} more rows`);\n return `\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport interface DiffLine {\n op: 'same' | 'add' | 'del';\n text: string;\n}\n\n/** Line diff (LCS) — good enough for snippets up to a few hundred lines. */\nexport function lineDiff(before: string, after: string): DiffLine[] {\n const a = before.split('\\n');\n const b = after.split('\\n');\n if (a.length * b.length > 250_000) {\n return [\n ...a.map((text) => ({ op: 'del' as const, text })),\n ...b.map((text) => ({ op: 'add' as const, text })),\n ];\n }\n const dp: number[][] = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n );\n const at = (i: number, j: number): number => dp[i]?.[j] ?? 0;\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n (dp[i] as number[])[j] =\n a[i] === b[j] ? at(i + 1, j + 1) + 1 : Math.max(at(i + 1, j), at(i, j + 1));\n }\n }\n const out: DiffLine[] = [];\n let i = 0;\n let j = 0;\n while (i < a.length && j < b.length) {\n if (a[i] === b[j]) {\n out.push({ op: 'same', text: a[i] as string });\n i++;\n j++;\n } else if (at(i + 1, j) >= at(i, j + 1)) {\n out.push({ op: 'del', text: a[i++] as string });\n } else {\n out.push({ op: 'add', text: b[j++] as string });\n }\n }\n while (i < a.length) out.push({ op: 'del', text: a[i++] as string });\n while (j < b.length) out.push({ op: 'add', text: b[j++] as string });\n return out;\n}\n\nfunction bar(value: number, max: number, width = 20): string {\n const n = max > 0 ? Math.round((Math.abs(value) / max) * width) : 0;\n return '█'.repeat(n) || '▏';\n}\n\nexport const DataTable = defineComponent<Props>({\n name: 'DataTable',\n title: 'Data table',\n description:\n 'Tabular data (records with the same fields) as a sortable table. Prefer it over markdown tables for more than 3 rows.',\n props: obj(\n {\n title: str('Short caption'),\n columns: arr(\n obj(\n {\n key: str('Field name in each row'),\n label: str('Column header'),\n align: str(undefined, { enum: ['left', 'right', 'center'] }),\n format: str('How to format values', {\n enum: ['text', 'number', 'currency', 'percent', 'date', 'link'],\n }),\n },\n ['key', 'label'],\n ),\n { minItems: 1, maxItems: 12 },\n ),\n rows: arr(row, { maxItems: 500 }),\n },\n ['columns', 'rows'],\n ),\n fallbackText: (props) => `${heading(props)}${textTable(props.columns ?? [], props.rows ?? [])}`,\n});\n\nexport const Chart = defineComponent<Props>({\n name: 'Chart',\n title: 'Chart',\n description:\n '`bar` to compare categories, `line` for a trend over time. `data` is a list of points; `xKey` names the category/time field and each series names a numeric field.',\n props: obj(\n {\n type: str('Chart type', { enum: ['bar', 'line'] }),\n title: str(),\n xKey: str('Field of each point used for the x axis'),\n series: arr(obj({ key: str('Numeric field'), label: str() }, ['key']), {\n minItems: 1,\n maxItems: 6,\n }),\n data: arr(row, { minItems: 1, maxItems: 200 }),\n unit: str('Unit shown after values, e.g. `KB` or `%`'),\n },\n ['type', 'xKey', 'series', 'data'],\n ),\n fallbackText: (props) => chartText(props),\n});\n\n/**\n * A chart as text. `line` → a table (x, then one column per series), which keeps every value\n * readable; `bar` → one bar per point, and per series when there are several, all on one scale so\n * bars of different series compare.\n */\nfunction chartText(props: Props): string {\n const series: { key: string; label?: string }[] = (props.series ?? []).filter(\n (each: unknown) => typeof (each as { key?: unknown })?.key === 'string',\n );\n const data: Props[] = props.data ?? [];\n const unit = props.unit ? ` ${s(props.unit)}` : '';\n const labelOf = (each: { key: string; label?: string }) => s(each.label) || each.key;\n if (props.type === 'line') {\n const columns = [\n { key: s(props.xKey), label: s(props.xKey) },\n ...series.map((each) => ({ key: each.key, label: `${labelOf(each)}${unit}` })),\n ];\n return `${heading(props)}${textTable(columns, data, 20)}`;\n }\n const max = Math.max(\n 0,\n ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))),\n );\n const shown = data.slice(0, 20);\n const lines: string[] = [];\n if (series.length <= 1) {\n const key = series[0]?.key ?? '';\n for (const point of shown) {\n lines.push(\n `${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`,\n );\n }\n } else {\n const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));\n for (const point of shown) {\n lines.push(s(point[props.xKey]).slice(0, 18));\n for (const each of series) {\n lines.push(\n ` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`,\n );\n }\n }\n }\n if (data.length > shown.length) lines.push(`… ${data.length - shown.length} more points`);\n return `${heading(props)}\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport const KpiCards = defineComponent<Props>({\n name: 'KpiCards',\n title: 'KPI cards',\n description: 'A few key numbers (metrics, totals, counts) as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj(\n {\n label: str(),\n value: { type: ['string', 'number'] },\n delta: str('Change, e.g. `+12%`'),\n trend: str(undefined, { enum: ['up', 'down', 'flat'] }),\n hint: str(),\n },\n ['label', 'value'],\n ),\n { minItems: 1, maxItems: 8 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• *${s(item.label)}:* ${s(item.value)}${item.delta ? ` (${s(item.delta)})` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const SourceCards = defineComponent<Props>({\n name: 'SourceCards',\n title: 'Sources',\n description: 'The documents, pages or links an answer is based on, as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj({ title: str(), url: str(), snippet: str(), source: str('e.g. Wiki, GitHub') }, [\n 'title',\n ]),\n { minItems: 1, maxItems: 12 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• ${item.url ? `<${s(item.url)}|${s(item.title)}>` : s(item.title)}${item.source ? ` — ${s(item.source)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Checklist = defineComponent<Props>({\n name: 'Checklist',\n title: 'Checklist',\n description: 'Steps or a to-do list with done/not-done state.',\n props: obj(\n {\n title: str(),\n items: arr(obj({ label: str(), done: { type: 'boolean' }, note: str() }, ['label']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `${item.done ? '☑' : '☐'} ${s(item.label)}${item.note ? ` — _${s(item.note)}_` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Timeline = defineComponent<Props>({\n name: 'Timeline',\n title: 'Timeline',\n description: 'Events in chronological order (the history of a project, an incident, a deal).',\n props: obj(\n {\n title: str(),\n events: arr(obj({ date: str(), title: str(), description: str() }, ['title']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['events'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.events ?? [])\n .map(\n (event: Props) =>\n `• ${event.date ? `*${s(event.date)}* ` : ''}${s(event.title)}${event.description ? ` — ${s(event.description)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const CodeBlock = defineComponent<Props>({\n name: 'CodeBlock',\n title: 'Code',\n description: 'A code snippet or file excerpt with syntax highlighting.',\n props: obj({ title: str(), language: str(), code: str() }, ['code']),\n fallbackText: (props) => `${heading(props)}\\`\\`\\`\\n${s(props.code)}\\n\\`\\`\\``,\n});\n\nexport const Diff = defineComponent<Props>({\n name: 'Diff',\n title: 'Diff',\n description: 'A before/after change to a text or code file, as a line diff.',\n props: obj({ title: str(), language: str(), before: str(), after: str() }, ['before', 'after']),\n fallbackText: (props) =>\n `${heading(props)}\\`\\`\\`\\n${lineDiff(s(props.before), s(props.after))\n .map((line) => `${line.op === 'add' ? '+' : line.op === 'del' ? '-' : ' '} ${line.text}`)\n .join('\\n')}\\n\\`\\`\\``,\n});\n\nexport const Callout = defineComponent<Props>({\n name: 'Callout',\n title: 'Callout',\n description: 'A short note, warning or success message, emphasized.',\n props: obj(\n {\n tone: str(undefined, { enum: ['info', 'success', 'warning', 'danger'] }),\n title: str(),\n text: str(),\n },\n ['text'],\n ),\n fallbackText: (props) =>\n `${props.tone === 'warning' || props.tone === 'danger' ? ':warning: ' : ':information_source: '}${heading(props)}${s(props.text)}`,\n});\n\nexport const Stack = defineComponent<Props>({\n name: 'Stack',\n title: 'Stack',\n description: 'Lays its children out vertically (or horizontally with direction=row).',\n props: obj({ direction: str(undefined, { enum: ['column', 'row'] }), gap: { type: 'number' } }),\n children: true,\n fallbackText: () => '',\n});\n\nexport const Card = defineComponent<Props>({\n name: 'Card',\n title: 'Card',\n description: 'A box with an optional title around its children.',\n props: obj({ title: str(), subtitle: str() }),\n children: true,\n fallbackText: (props) =>\n props.title ? `*${s(props.title)}*${props.subtitle ? ` — ${s(props.subtitle)}` : ''}` : '',\n});\n\nexport const Heading = defineComponent<Props>({\n name: 'Heading',\n title: 'Heading',\n description: 'A heading.',\n props: obj({ text: str() }, ['text']),\n fallbackText: (props) => `*${s(props.text)}*`,\n});\n\nexport const Text = defineComponent<Props>({\n name: 'Text',\n title: 'Text',\n description: 'A paragraph of plain text (no markdown).',\n props: obj({ text: str(), muted: { type: 'boolean' } }, ['text']),\n fallbackText: (props) => s(props.text),\n});\n\nexport const Badge = defineComponent<Props>({\n name: 'Badge',\n title: 'Badge',\n description: 'A small label.',\n props: obj(\n {\n text: str(),\n tone: str(undefined, { enum: ['neutral', 'brand', 'success', 'warning', 'danger'] }),\n },\n ['text'],\n ),\n fallbackText: (props) => `[${s(props.text)}]`,\n});\n\nexport const Link = defineComponent<Props>({\n name: 'Link',\n title: 'Link',\n description: 'A link to an http(s) URL.',\n props: obj({ text: str(), url: str(undefined, { pattern: '^https?://' }) }, ['text', 'url']),\n fallbackText: (props) => `<${s(props.url)}|${s(props.text || props.url)}>`,\n});\n\nexport const Image = defineComponent<Props>({\n name: 'Image',\n title: 'Image',\n description: 'An image from an https URL.',\n props: obj({ url: str(undefined, { pattern: '^https://' }), alt: str() }, ['url']),\n fallbackText: (props) => s(props.url),\n});\n\n/** Content components: data a model shows. */\nexport const BUILTIN_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n DataTable,\n Chart,\n KpiCards,\n SourceCards,\n Checklist,\n Timeline,\n CodeBlock,\n Diff,\n Callout,\n];\n\n/** Layout and text primitives, mostly for composing trees (`Stack`, `Card` take children). */\nexport const LAYOUT_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n Stack,\n Card,\n Heading,\n Text,\n Badge,\n Link,\n Image,\n];\n","import {\n type GenuiValidation,\n type JsonSchema,\n type JsonSchemaValidator,\n type PropsSchema,\n builtinJsonSchemaValidator,\n toJsonSchema,\n validateProps,\n validatePropsSync,\n} from './schema.js';\n\n/**\n * One component a server may push into a conversation. Data only — how it LOOKS is each app's own\n * renderer, looked up by {@link name}. The same definition serves the model (description + props\n * schema), the server (validation), text-only channels ({@link fallbackText}) and the client\n * (validation before rendering).\n */\nexport interface ComponentDefinition<P = Record<string, unknown>> {\n /** Registry key, e.g. `DataTable`. What a `ui` frame's `component` names. */\n name: string;\n /** Human label: \"Data table\". */\n title: string;\n /** Shown to the model: what the component is for and when to use it. */\n description: string;\n /** The props schema: a Standard Schema (Zod, Valibot, ArkType) or a JSON Schema object. */\n props: PropsSchema;\n /** Portable normalized props schema. Required when input transformations are not idempotent. */\n outputProps?: PropsSchema;\n /**\n * The component takes nested elements (a layout: `Stack`, `Card`). Only meaningful in tree mode,\n * where a node's `children` are validated against the catalog too. Such a component gets no\n * `ui__show_*` tool and is not offered by the show tool ({@link flatComponents}), and when its\n * {@link fallbackText} comes out empty it writes no text of its own (its children still do).\n */\n children?: boolean;\n /**\n * Plain text / Slack mrkdwn rendering of these props, for a channel that cannot draw the\n * component. Absent → {@link componentToText} prints the props as JSON.\n */\n fallbackText?: (props: P) => string;\n /**\n * Pushed by the server (e.g. an approval card), never offered to the model. Excluded from\n * {@link catalogToModelText} and from the tool factories.\n */\n internal?: boolean;\n /**\n * Schema version of {@link props}. Stamped on every `ui` frame the component is pushed with, so a\n * client can keep rendering messages persisted under an older shape.\n */\n version?: number;\n}\n\n/** Component names: an identifier a registry key, a tool name and a snake_case slug can all be derived from. */\nexport const COMPONENT_NAME = /^[A-Za-z][A-Za-z0-9]{0,63}$/;\n\n/** Declare a component. Validates the name and returns the definition unchanged (typed). */\nexport function defineComponent<P = Record<string, unknown>>(\n definition: ComponentDefinition<P>,\n): ComponentDefinition<P> {\n if (!COMPONENT_NAME.test(definition.name)) {\n throw new Error(\n `genui: component name \"${definition.name}\" must be letters and digits, starting with a letter (e.g. DataTable)`,\n );\n }\n if (\n definition.version !== undefined &&\n (!Number.isSafeInteger(definition.version) || definition.version <= 0)\n )\n throw new RangeError('genui: component version must be a positive safe integer');\n if (definition.fallbackText !== undefined && typeof definition.fallbackText !== 'function')\n throw new TypeError('genui: fallbackText must be a function');\n return definition;\n}\n\nexport interface CatalogOptions {\n /** How JSON Schema props are checked. Default: {@link builtinJsonSchemaValidator}; pass `ajvValidator(new Ajv())` for full JSON Schema. */\n jsonSchemaValidator?: JsonSchemaValidator;\n}\n\n/** An immutable set of component definitions, looked up by name. */\nexport interface Catalog {\n readonly components: readonly ComponentDefinition<any>[];\n readonly validator: JsonSchemaValidator;\n get(name: string): ComponentDefinition<any> | undefined;\n has(name: string): boolean;\n /** The components a model may be offered (every non-`internal` one). */\n modelComponents(): ComponentDefinition<any>[];\n /** Validate `props` for `component`. An unknown component is a validation failure, not a throw. */\n validate(component: string, props: unknown): Promise<GenuiValidation<Record<string, unknown>>>;\n /**\n * {@link validate} without waiting — `undefined` only when the component's Standard Schema\n * validates asynchronously. An unknown component is a failure, as in `validate`.\n */\n validateSync(\n component: string,\n props: unknown,\n ): GenuiValidation<Record<string, unknown>> | undefined;\n /** The component's props as JSON Schema, when it can be derived (see {@link toJsonSchema}). */\n jsonSchemaFor(component: string): JsonSchema | undefined;\n /** A new catalog with these components added (a later definition replaces an earlier one of the same name). */\n extend(components: readonly ComponentDefinition<any>[]): Catalog;\n}\n\n/**\n * The model components a FLAT tool can offer — one whose input is the component's props alone\n * (`ui__show_<name>`, the generic show tool). A layout component (`children: true`) is left out:\n * those tools have no way to pass it children, so it would only ever draw an empty box. Tree mode\n * offers every model component.\n */\nexport function flatComponents(catalog: Catalog): ComponentDefinition<any>[] {\n return catalog.modelComponents().filter((component) => component.children !== true);\n}\n\n/**\n * Collect component definitions into a {@link Catalog}. Names must be unique; to override a\n * definition (e.g. a builtin), use {@link Catalog.extend}.\n */\nexport function defineCatalog(\n components: readonly ComponentDefinition<any>[],\n options: CatalogOptions = {},\n): Catalog {\n const byName = new Map<string, ComponentDefinition<any>>();\n for (const component of components) {\n defineComponent(component);\n if (byName.has(component.name)) {\n throw new Error(`genui: component \"${component.name}\" is defined twice in one catalog`);\n }\n byName.set(component.name, component);\n }\n return buildCatalog(byName, options.jsonSchemaValidator ?? builtinJsonSchemaValidator);\n}\n\nfunction buildCatalog(\n byName: Map<string, ComponentDefinition<any>>,\n validator: JsonSchemaValidator,\n): Catalog {\n const list = Object.freeze([...byName.values()]);\n return {\n components: list,\n validator,\n get: (name) => byName.get(name),\n has: (name) => byName.has(name),\n modelComponents: () => list.filter((component) => component.internal !== true),\n async validate(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n const result = await validateProps(\n definition.outputProps ?? definition.props,\n props,\n validator,\n );\n return result as GenuiValidation<Record<string, unknown>>;\n },\n validateSync(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n return validatePropsSync(definition.outputProps ?? definition.props, props, validator) as\n | GenuiValidation<Record<string, unknown>>\n | undefined;\n },\n jsonSchemaFor(component) {\n const definition = byName.get(component);\n return definition === undefined\n ? undefined\n : toJsonSchema(definition.outputProps ?? definition.props);\n },\n extend(more) {\n const next = new Map(byName);\n for (const component of more) {\n defineComponent(component);\n next.set(component.name, component);\n }\n return buildCatalog(next, validator);\n },\n };\n}\n\n/** `DataTable` → `data_table`, `KPICards` → `kpi_cards`. */\nexport function toSnakeCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase();\n}\n\n/** The per-component tool name: `ui__show_data_table` with the default prefix. */\nexport function toolNameFor(component: string, prefix = 'ui__show_'): string {\n return `${prefix}${toSnakeCase(component)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;ACqDO,IAAMA,iBAAiB;AAGvB,SAASC,gBACdC,YAAkC;AAElC,MAAI,CAACF,eAAeG,KAAKD,WAAWE,IAAI,GAAG;AACzC,UAAM,IAAIC,MACR,0BAA0BH,WAAWE,IAAI,uEAAuE;EAEpH;AACA,MACEF,WAAWI,YAAYC,WACtB,CAACC,OAAOC,cAAcP,WAAWI,OAAO,KAAKJ,WAAWI,WAAW,GAEpE,OAAM,IAAII,WAAW,0DAAA;AACvB,MAAIR,WAAWS,iBAAiBJ,UAAa,OAAOL,WAAWS,iBAAiB,WAC9E,OAAM,IAAIC,UAAU,wCAAA;AACtB,SAAOV;AACT;AAhBgBD;;;AD1ChB,IAAMY,MAAM,wBAACC,aAAsBC,QAAoB,CAAC,OAAmB;EACzEC,MAAM;EACN,GAAIF,gBAAgBG,SAAY;IAAEH;EAAY,IAAI,CAAC;EACnD,GAAGC;AACL,IAJY;AAKZ,IAAMG,MAAM,wBAACC,YAAwCC,WAAqB,CAAA,OAAoB;EAC5FJ,MAAM;EACNG;EACAC;EACAC,sBAAsB;AACxB,IALY;AAMZ,IAAMC,MAAM,wBAACC,OAAmBR,QAAoB,CAAC,OAAmB;EACtEC,MAAM;EACNO;EACA,GAAGR;AACL,IAJY;AAKZ,IAAMS,OAAmB;EAAER,MAAM;IAAC;IAAU;IAAU;IAAW;;AAAQ;AACzE,IAAMS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AQ;EACAY;EACAK;EACAI;EACAG;EACAI;EACAG;EACAE;;AAIK,IAAMiB,oBAA2D;EACtEf;EACAI;EACAE;EACAC;EACAE;EACAC;EACAE;;","names":["COMPONENT_NAME","defineComponent","definition","test","name","Error","version","undefined","Number","isSafeInteger","RangeError","fallbackText","TypeError","str","description","extra","type","undefined","obj","properties","required","additionalProperties","arr","items","cell","row","s","value","String","heading","props","title","textTable","columns","rows","max","shown","slice","widths","map","column","Math","min","label","length","r","key","format","values","index","padEnd","join","lines","width","repeat","push","lineDiff","before","after","a","split","b","text","op","dp","Array","from","fill","at","i","j","out","bar","n","round","abs","DataTable","defineComponent","name","align","enum","minItems","maxItems","fallbackText","Chart","xKey","series","data","unit","chartText","filter","each","labelOf","flatMap","point","Number","KpiCards","delta","trend","hint","item","SourceCards","url","snippet","source","Checklist","done","note","Timeline","events","date","event","CodeBlock","language","code","Diff","line","Callout","tone","Stack","direction","gap","children","Card","subtitle","Heading","Text","muted","Badge","Link","pattern","Image","alt","BUILTIN_COMPONENTS","LAYOUT_COMPONENTS"]}
|
package/dist/genui/builtins.d.ts
CHANGED
package/dist/genui/builtins.js
CHANGED
|
@@ -200,18 +200,49 @@ var Chart = defineComponent({
|
|
|
200
200
|
"series",
|
|
201
201
|
"data"
|
|
202
202
|
]),
|
|
203
|
-
fallbackText: /* @__PURE__ */ __name((props) =>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
fallbackText: /* @__PURE__ */ __name((props) => chartText(props), "fallbackText")
|
|
204
|
+
});
|
|
205
|
+
function chartText(props) {
|
|
206
|
+
const series = (props.series ?? []).filter((each) => typeof each?.key === "string");
|
|
207
|
+
const data = props.data ?? [];
|
|
208
|
+
const unit = props.unit ? ` ${s(props.unit)}` : "";
|
|
209
|
+
const labelOf = /* @__PURE__ */ __name((each) => s(each.label) || each.key, "labelOf");
|
|
210
|
+
if (props.type === "line") {
|
|
211
|
+
const columns = [
|
|
212
|
+
{
|
|
213
|
+
key: s(props.xKey),
|
|
214
|
+
label: s(props.xKey)
|
|
215
|
+
},
|
|
216
|
+
...series.map((each) => ({
|
|
217
|
+
key: each.key,
|
|
218
|
+
label: `${labelOf(each)}${unit}`
|
|
219
|
+
}))
|
|
220
|
+
];
|
|
221
|
+
return `${heading(props)}${textTable(columns, data, 20)}`;
|
|
222
|
+
}
|
|
223
|
+
const max = Math.max(0, ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))));
|
|
224
|
+
const shown = data.slice(0, 20);
|
|
225
|
+
const lines = [];
|
|
226
|
+
if (series.length <= 1) {
|
|
227
|
+
const key = series[0]?.key ?? "";
|
|
228
|
+
for (const point of shown) {
|
|
229
|
+
lines.push(`${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`);
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));
|
|
233
|
+
for (const point of shown) {
|
|
234
|
+
lines.push(s(point[props.xKey]).slice(0, 18));
|
|
235
|
+
for (const each of series) {
|
|
236
|
+
lines.push(` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (data.length > shown.length) lines.push(`\u2026 ${data.length - shown.length} more points`);
|
|
241
|
+
return `${heading(props)}\`\`\`
|
|
211
242
|
${lines.join("\n")}
|
|
212
243
|
\`\`\``;
|
|
213
|
-
|
|
214
|
-
|
|
244
|
+
}
|
|
245
|
+
__name(chartText, "chartText");
|
|
215
246
|
var KpiCards = defineComponent({
|
|
216
247
|
name: "KpiCards",
|
|
217
248
|
title: "KPI cards",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/genui/catalog.ts","../../src/genui/builtins.ts"],"sourcesContent":["import {\n type GenuiValidation,\n type JsonSchema,\n type JsonSchemaValidator,\n type PropsSchema,\n builtinJsonSchemaValidator,\n toJsonSchema,\n validateProps,\n validatePropsSync,\n} from './schema.js';\n\n/**\n * One component a server may push into a conversation. Data only — how it LOOKS is each app's own\n * renderer, looked up by {@link name}. The same definition serves the model (description + props\n * schema), the server (validation), text-only channels ({@link fallbackText}) and the client\n * (validation before rendering).\n */\nexport interface ComponentDefinition<P = Record<string, unknown>> {\n /** Registry key, e.g. `DataTable`. What a `ui` frame's `component` names. */\n name: string;\n /** Human label: \"Data table\". */\n title: string;\n /** Shown to the model: what the component is for and when to use it. */\n description: string;\n /** The props schema: a Standard Schema (Zod, Valibot, ArkType) or a JSON Schema object. */\n props: PropsSchema;\n /** Portable normalized props schema. Required when input transformations are not idempotent. */\n outputProps?: PropsSchema;\n /**\n * The component takes nested elements (a layout: `Stack`, `Card`). Only meaningful in tree mode,\n * where a node's `children` are validated against the catalog too.\n */\n children?: boolean;\n /**\n * Plain text / Slack mrkdwn rendering of these props, for a channel that cannot draw the\n * component. Absent → {@link componentToText} prints the props as JSON.\n */\n fallbackText?: (props: P) => string;\n /**\n * Pushed by the server (e.g. an approval card), never offered to the model. Excluded from\n * {@link catalogToModelText} and from the tool factories.\n */\n internal?: boolean;\n /**\n * Schema version of {@link props}. Stamped on every `ui` frame the component is pushed with, so a\n * client can keep rendering messages persisted under an older shape.\n */\n version?: number;\n}\n\n/** Component names: an identifier a registry key, a tool name and a snake_case slug can all be derived from. */\nexport const COMPONENT_NAME = /^[A-Za-z][A-Za-z0-9]{0,63}$/;\n\n/** Declare a component. Validates the name and returns the definition unchanged (typed). */\nexport function defineComponent<P = Record<string, unknown>>(\n definition: ComponentDefinition<P>,\n): ComponentDefinition<P> {\n if (!COMPONENT_NAME.test(definition.name)) {\n throw new Error(\n `genui: component name \"${definition.name}\" must be letters and digits, starting with a letter (e.g. DataTable)`,\n );\n }\n if (\n definition.version !== undefined &&\n (!Number.isSafeInteger(definition.version) || definition.version <= 0)\n )\n throw new RangeError('genui: component version must be a positive safe integer');\n if (definition.fallbackText !== undefined && typeof definition.fallbackText !== 'function')\n throw new TypeError('genui: fallbackText must be a function');\n return definition;\n}\n\nexport interface CatalogOptions {\n /** How JSON Schema props are checked. Default: {@link builtinJsonSchemaValidator}; pass `ajvValidator(new Ajv())` for full JSON Schema. */\n jsonSchemaValidator?: JsonSchemaValidator;\n}\n\n/** An immutable set of component definitions, looked up by name. */\nexport interface Catalog {\n readonly components: readonly ComponentDefinition<any>[];\n readonly validator: JsonSchemaValidator;\n get(name: string): ComponentDefinition<any> | undefined;\n has(name: string): boolean;\n /** The components a model may be offered (every non-`internal` one). */\n modelComponents(): ComponentDefinition<any>[];\n /** Validate `props` for `component`. An unknown component is a validation failure, not a throw. */\n validate(component: string, props: unknown): Promise<GenuiValidation<Record<string, unknown>>>;\n /**\n * {@link validate} without waiting — `undefined` only when the component's Standard Schema\n * validates asynchronously. An unknown component is a failure, as in `validate`.\n */\n validateSync(\n component: string,\n props: unknown,\n ): GenuiValidation<Record<string, unknown>> | undefined;\n /** The component's props as JSON Schema, when it can be derived (see {@link toJsonSchema}). */\n jsonSchemaFor(component: string): JsonSchema | undefined;\n /** A new catalog with these components added (a later definition replaces an earlier one of the same name). */\n extend(components: readonly ComponentDefinition<any>[]): Catalog;\n}\n\n/**\n * Collect component definitions into a {@link Catalog}. Names must be unique; to override a\n * definition (e.g. a builtin), use {@link Catalog.extend}.\n */\nexport function defineCatalog(\n components: readonly ComponentDefinition<any>[],\n options: CatalogOptions = {},\n): Catalog {\n const byName = new Map<string, ComponentDefinition<any>>();\n for (const component of components) {\n defineComponent(component);\n if (byName.has(component.name)) {\n throw new Error(`genui: component \"${component.name}\" is defined twice in one catalog`);\n }\n byName.set(component.name, component);\n }\n return buildCatalog(byName, options.jsonSchemaValidator ?? builtinJsonSchemaValidator);\n}\n\nfunction buildCatalog(\n byName: Map<string, ComponentDefinition<any>>,\n validator: JsonSchemaValidator,\n): Catalog {\n const list = Object.freeze([...byName.values()]);\n return {\n components: list,\n validator,\n get: (name) => byName.get(name),\n has: (name) => byName.has(name),\n modelComponents: () => list.filter((component) => component.internal !== true),\n async validate(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n const result = await validateProps(\n definition.outputProps ?? definition.props,\n props,\n validator,\n );\n return result as GenuiValidation<Record<string, unknown>>;\n },\n validateSync(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n return validatePropsSync(definition.outputProps ?? definition.props, props, validator) as\n | GenuiValidation<Record<string, unknown>>\n | undefined;\n },\n jsonSchemaFor(component) {\n const definition = byName.get(component);\n return definition === undefined\n ? undefined\n : toJsonSchema(definition.outputProps ?? definition.props);\n },\n extend(more) {\n const next = new Map(byName);\n for (const component of more) {\n defineComponent(component);\n next.set(component.name, component);\n }\n return buildCatalog(next, validator);\n },\n };\n}\n\n/** `DataTable` → `data_table`, `KPICards` → `kpi_cards`. */\nexport function toSnakeCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase();\n}\n\n/** The per-component tool name: `ui__show_data_table` with the default prefix. */\nexport function toolNameFor(component: string, prefix = 'ui__show_'): string {\n return `${prefix}${toSnakeCase(component)}`;\n}\n","/**\n * Optional builtin component DEFINITIONS — names, props schemas, model descriptions and plain-text\n * fallbacks for the components most chat apps want. No visuals: an app renders each with its own\n * look, keyed by name. Use them as-is, pick some, or extend them:\n *\n * ```ts\n * const catalog = defineCatalog([...BUILTIN_COMPONENTS, ...LAYOUT_COMPONENTS, myDealCard]);\n * ```\n */\nimport { type ComponentDefinition, defineComponent } from './catalog.js';\nimport type { JsonSchema } from './schema.js';\n\ntype Props = Record<string, any>;\n\nconst str = (description?: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n ...(description !== undefined ? { description } : {}),\n ...extra,\n});\nconst obj = (properties: Record<string, JsonSchema>, required: string[] = []): JsonSchema => ({\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n});\nconst arr = (items: JsonSchema, extra: JsonSchema = {}): JsonSchema => ({\n type: 'array',\n items,\n ...extra,\n});\nconst cell: JsonSchema = { type: ['string', 'number', 'boolean', 'null'] };\nconst row: JsonSchema = { type: 'object', additionalProperties: cell };\n\nconst s = (value: unknown): string => (value === null || value === undefined ? '' : String(value));\nconst heading = (props: Props): string => (props.title ? `*${s(props.title)}*\\n` : '');\n\n/** A fixed-width text table in a code block, at most `max` rows. */\nexport function textTable(\n columns: readonly { key: string; label: string }[],\n rows: readonly Props[],\n max = 15,\n): string {\n const shown = rows.slice(0, max);\n const widths = columns.map((column) =>\n Math.min(28, Math.max(column.label.length, ...shown.map((r) => s(r[column.key]).length))),\n );\n const format = (values: string[]) =>\n values\n .map((value, index) => value.slice(0, widths[index]).padEnd(widths[index] ?? 0))\n .join(' ');\n const lines = [\n format(columns.map((column) => column.label)),\n widths.map((width) => '-'.repeat(width)).join(' '),\n ...shown.map((r) => format(columns.map((column) => s(r[column.key])))),\n ];\n if (rows.length > max) lines.push(`… ${rows.length - max} more rows`);\n return `\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport interface DiffLine {\n op: 'same' | 'add' | 'del';\n text: string;\n}\n\n/** Line diff (LCS) — good enough for snippets up to a few hundred lines. */\nexport function lineDiff(before: string, after: string): DiffLine[] {\n const a = before.split('\\n');\n const b = after.split('\\n');\n if (a.length * b.length > 250_000) {\n return [\n ...a.map((text) => ({ op: 'del' as const, text })),\n ...b.map((text) => ({ op: 'add' as const, text })),\n ];\n }\n const dp: number[][] = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n );\n const at = (i: number, j: number): number => dp[i]?.[j] ?? 0;\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n (dp[i] as number[])[j] =\n a[i] === b[j] ? at(i + 1, j + 1) + 1 : Math.max(at(i + 1, j), at(i, j + 1));\n }\n }\n const out: DiffLine[] = [];\n let i = 0;\n let j = 0;\n while (i < a.length && j < b.length) {\n if (a[i] === b[j]) {\n out.push({ op: 'same', text: a[i] as string });\n i++;\n j++;\n } else if (at(i + 1, j) >= at(i, j + 1)) {\n out.push({ op: 'del', text: a[i++] as string });\n } else {\n out.push({ op: 'add', text: b[j++] as string });\n }\n }\n while (i < a.length) out.push({ op: 'del', text: a[i++] as string });\n while (j < b.length) out.push({ op: 'add', text: b[j++] as string });\n return out;\n}\n\nfunction bar(value: number, max: number, width = 20): string {\n const n = max > 0 ? Math.round((Math.abs(value) / max) * width) : 0;\n return '█'.repeat(n) || '▏';\n}\n\nexport const DataTable = defineComponent<Props>({\n name: 'DataTable',\n title: 'Data table',\n description:\n 'Tabular data (records with the same fields) as a sortable table. Prefer it over markdown tables for more than 3 rows.',\n props: obj(\n {\n title: str('Short caption'),\n columns: arr(\n obj(\n {\n key: str('Field name in each row'),\n label: str('Column header'),\n align: str(undefined, { enum: ['left', 'right', 'center'] }),\n format: str('How to format values', {\n enum: ['text', 'number', 'currency', 'percent', 'date', 'link'],\n }),\n },\n ['key', 'label'],\n ),\n { minItems: 1, maxItems: 12 },\n ),\n rows: arr(row, { maxItems: 500 }),\n },\n ['columns', 'rows'],\n ),\n fallbackText: (props) => `${heading(props)}${textTable(props.columns ?? [], props.rows ?? [])}`,\n});\n\nexport const Chart = defineComponent<Props>({\n name: 'Chart',\n title: 'Chart',\n description:\n '`bar` to compare categories, `line` for a trend over time. `data` is a list of points; `xKey` names the category/time field and each series names a numeric field.',\n props: obj(\n {\n type: str('Chart type', { enum: ['bar', 'line'] }),\n title: str(),\n xKey: str('Field of each point used for the x axis'),\n series: arr(obj({ key: str('Numeric field'), label: str() }, ['key']), {\n minItems: 1,\n maxItems: 6,\n }),\n data: arr(row, { minItems: 1, maxItems: 200 }),\n unit: str('Unit shown after values, e.g. `KB` or `%`'),\n },\n ['type', 'xKey', 'series', 'data'],\n ),\n fallbackText: (props) => {\n const series: { key: string }[] = props.series ?? [];\n const data: Props[] = props.data ?? [];\n const first = series[0]?.key ?? '';\n const max = Math.max(0, ...data.map((point) => Math.abs(Number(point[first]) || 0)));\n const unit = props.unit ? ` ${s(props.unit)}` : '';\n const lines = data\n .slice(0, 20)\n .map(\n (point) =>\n `${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[first]) || 0, max)} ${s(point[first])}${unit}`,\n );\n return `${heading(props)}\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n },\n});\n\nexport const KpiCards = defineComponent<Props>({\n name: 'KpiCards',\n title: 'KPI cards',\n description: 'A few key numbers (metrics, totals, counts) as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj(\n {\n label: str(),\n value: { type: ['string', 'number'] },\n delta: str('Change, e.g. `+12%`'),\n trend: str(undefined, { enum: ['up', 'down', 'flat'] }),\n hint: str(),\n },\n ['label', 'value'],\n ),\n { minItems: 1, maxItems: 8 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• *${s(item.label)}:* ${s(item.value)}${item.delta ? ` (${s(item.delta)})` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const SourceCards = defineComponent<Props>({\n name: 'SourceCards',\n title: 'Sources',\n description: 'The documents, pages or links an answer is based on, as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj({ title: str(), url: str(), snippet: str(), source: str('e.g. Wiki, GitHub') }, [\n 'title',\n ]),\n { minItems: 1, maxItems: 12 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• ${item.url ? `<${s(item.url)}|${s(item.title)}>` : s(item.title)}${item.source ? ` — ${s(item.source)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Checklist = defineComponent<Props>({\n name: 'Checklist',\n title: 'Checklist',\n description: 'Steps or a to-do list with done/not-done state.',\n props: obj(\n {\n title: str(),\n items: arr(obj({ label: str(), done: { type: 'boolean' }, note: str() }, ['label']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `${item.done ? '☑' : '☐'} ${s(item.label)}${item.note ? ` — _${s(item.note)}_` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Timeline = defineComponent<Props>({\n name: 'Timeline',\n title: 'Timeline',\n description: 'Events in chronological order (the history of a project, an incident, a deal).',\n props: obj(\n {\n title: str(),\n events: arr(obj({ date: str(), title: str(), description: str() }, ['title']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['events'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.events ?? [])\n .map(\n (event: Props) =>\n `• ${event.date ? `*${s(event.date)}* ` : ''}${s(event.title)}${event.description ? ` — ${s(event.description)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const CodeBlock = defineComponent<Props>({\n name: 'CodeBlock',\n title: 'Code',\n description: 'A code snippet or file excerpt with syntax highlighting.',\n props: obj({ title: str(), language: str(), code: str() }, ['code']),\n fallbackText: (props) => `${heading(props)}\\`\\`\\`\\n${s(props.code)}\\n\\`\\`\\``,\n});\n\nexport const Diff = defineComponent<Props>({\n name: 'Diff',\n title: 'Diff',\n description: 'A before/after change to a text or code file, as a line diff.',\n props: obj({ title: str(), language: str(), before: str(), after: str() }, ['before', 'after']),\n fallbackText: (props) =>\n `${heading(props)}\\`\\`\\`\\n${lineDiff(s(props.before), s(props.after))\n .map((line) => `${line.op === 'add' ? '+' : line.op === 'del' ? '-' : ' '} ${line.text}`)\n .join('\\n')}\\n\\`\\`\\``,\n});\n\nexport const Callout = defineComponent<Props>({\n name: 'Callout',\n title: 'Callout',\n description: 'A short note, warning or success message, emphasized.',\n props: obj(\n {\n tone: str(undefined, { enum: ['info', 'success', 'warning', 'danger'] }),\n title: str(),\n text: str(),\n },\n ['text'],\n ),\n fallbackText: (props) =>\n `${props.tone === 'warning' || props.tone === 'danger' ? ':warning: ' : ':information_source: '}${heading(props)}${s(props.text)}`,\n});\n\nexport const Stack = defineComponent<Props>({\n name: 'Stack',\n title: 'Stack',\n description: 'Lays its children out vertically (or horizontally with direction=row).',\n props: obj({ direction: str(undefined, { enum: ['column', 'row'] }), gap: { type: 'number' } }),\n children: true,\n fallbackText: () => '',\n});\n\nexport const Card = defineComponent<Props>({\n name: 'Card',\n title: 'Card',\n description: 'A box with an optional title around its children.',\n props: obj({ title: str(), subtitle: str() }),\n children: true,\n fallbackText: (props) =>\n props.title ? `*${s(props.title)}*${props.subtitle ? ` — ${s(props.subtitle)}` : ''}` : '',\n});\n\nexport const Heading = defineComponent<Props>({\n name: 'Heading',\n title: 'Heading',\n description: 'A heading.',\n props: obj({ text: str() }, ['text']),\n fallbackText: (props) => `*${s(props.text)}*`,\n});\n\nexport const Text = defineComponent<Props>({\n name: 'Text',\n title: 'Text',\n description: 'A paragraph of plain text (no markdown).',\n props: obj({ text: str(), muted: { type: 'boolean' } }, ['text']),\n fallbackText: (props) => s(props.text),\n});\n\nexport const Badge = defineComponent<Props>({\n name: 'Badge',\n title: 'Badge',\n description: 'A small label.',\n props: obj(\n {\n text: str(),\n tone: str(undefined, { enum: ['neutral', 'brand', 'success', 'warning', 'danger'] }),\n },\n ['text'],\n ),\n fallbackText: (props) => `[${s(props.text)}]`,\n});\n\nexport const Link = defineComponent<Props>({\n name: 'Link',\n title: 'Link',\n description: 'A link to an http(s) URL.',\n props: obj({ text: str(), url: str(undefined, { pattern: '^https?://' }) }, ['text', 'url']),\n fallbackText: (props) => `<${s(props.url)}|${s(props.text || props.url)}>`,\n});\n\nexport const Image = defineComponent<Props>({\n name: 'Image',\n title: 'Image',\n description: 'An image from an https URL.',\n props: obj({ url: str(undefined, { pattern: '^https://' }), alt: str() }, ['url']),\n fallbackText: (props) => s(props.url),\n});\n\n/** Content components: data a model shows. */\nexport const BUILTIN_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n DataTable,\n Chart,\n KpiCards,\n SourceCards,\n Checklist,\n Timeline,\n CodeBlock,\n Diff,\n Callout,\n];\n\n/** Layout and text primitives, mostly for composing trees (`Stack`, `Card` take children). */\nexport const LAYOUT_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n Stack,\n Card,\n Heading,\n Text,\n Badge,\n Link,\n Image,\n];\n"],"mappings":";;;;AAmDO,IAAMA,iBAAiB;AAGvB,SAASC,gBACdC,YAAkC;AAElC,MAAI,CAACF,eAAeG,KAAKD,WAAWE,IAAI,GAAG;AACzC,UAAM,IAAIC,MACR,0BAA0BH,WAAWE,IAAI,uEAAuE;EAEpH;AACA,MACEF,WAAWI,YAAYC,WACtB,CAACC,OAAOC,cAAcP,WAAWI,OAAO,KAAKJ,WAAWI,WAAW,GAEpE,OAAM,IAAII,WAAW,0DAAA;AACvB,MAAIR,WAAWS,iBAAiBJ,UAAa,OAAOL,WAAWS,iBAAiB,WAC9E,OAAM,IAAIC,UAAU,wCAAA;AACtB,SAAOV;AACT;AAhBgBD;;;ACxChB,IAAMY,MAAM,wBAACC,aAAsBC,QAAoB,CAAC,OAAmB;EACzEC,MAAM;EACN,GAAIF,gBAAgBG,SAAY;IAAEH;EAAY,IAAI,CAAC;EACnD,GAAGC;AACL,IAJY;AAKZ,IAAMG,MAAM,wBAACC,YAAwCC,WAAqB,CAAA,OAAoB;EAC5FJ,MAAM;EACNG;EACAC;EACAC,sBAAsB;AACxB,IALY;AAMZ,IAAMC,MAAM,wBAACC,OAAmBR,QAAoB,CAAC,OAAmB;EACtEC,MAAM;EACNO;EACA,GAAGR;AACL,IAJY;AAKZ,IAAMS,OAAmB;EAAER,MAAM;IAAC;I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;EACAE;;","names":["COMPONENT_NAME","defineComponent","definition","test","name","Error","version","undefined","Number","isSafeInteger","RangeError","fallbackText","TypeError","str","description","extra","type","undefined","obj","properties","required","additionalProperties","arr","items","cell","row","s","value","String","heading","props","title","textTable","columns","rows","max","shown","slice","widths","map","column","Math","min","label","length","r","key","format","values","index","padEnd","join","lines","width","repeat","push","lineDiff","before","after","a","split","b","text","op","dp","Array","from","fill","at","i","j","out","bar","n","round","abs","DataTable","defineComponent","name","align","enum","minItems","maxItems","fallbackText","Chart","xKey","series","data","unit","first","point","Number","KpiCards","delta","trend","hint","item","SourceCards","url","snippet","source","Checklist","done","note","Timeline","events","date","event","CodeBlock","language","code","Diff","line","Callout","tone","Stack","direction","gap","children","Card","subtitle","Heading","Text","muted","Badge","Link","pattern","Image","alt","BUILTIN_COMPONENTS","LAYOUT_COMPONENTS"]}
|
|
1
|
+
{"version":3,"sources":["../../src/genui/catalog.ts","../../src/genui/builtins.ts"],"sourcesContent":["import {\n type GenuiValidation,\n type JsonSchema,\n type JsonSchemaValidator,\n type PropsSchema,\n builtinJsonSchemaValidator,\n toJsonSchema,\n validateProps,\n validatePropsSync,\n} from './schema.js';\n\n/**\n * One component a server may push into a conversation. Data only — how it LOOKS is each app's own\n * renderer, looked up by {@link name}. The same definition serves the model (description + props\n * schema), the server (validation), text-only channels ({@link fallbackText}) and the client\n * (validation before rendering).\n */\nexport interface ComponentDefinition<P = Record<string, unknown>> {\n /** Registry key, e.g. `DataTable`. What a `ui` frame's `component` names. */\n name: string;\n /** Human label: \"Data table\". */\n title: string;\n /** Shown to the model: what the component is for and when to use it. */\n description: string;\n /** The props schema: a Standard Schema (Zod, Valibot, ArkType) or a JSON Schema object. */\n props: PropsSchema;\n /** Portable normalized props schema. Required when input transformations are not idempotent. */\n outputProps?: PropsSchema;\n /**\n * The component takes nested elements (a layout: `Stack`, `Card`). Only meaningful in tree mode,\n * where a node's `children` are validated against the catalog too. Such a component gets no\n * `ui__show_*` tool and is not offered by the show tool ({@link flatComponents}), and when its\n * {@link fallbackText} comes out empty it writes no text of its own (its children still do).\n */\n children?: boolean;\n /**\n * Plain text / Slack mrkdwn rendering of these props, for a channel that cannot draw the\n * component. Absent → {@link componentToText} prints the props as JSON.\n */\n fallbackText?: (props: P) => string;\n /**\n * Pushed by the server (e.g. an approval card), never offered to the model. Excluded from\n * {@link catalogToModelText} and from the tool factories.\n */\n internal?: boolean;\n /**\n * Schema version of {@link props}. Stamped on every `ui` frame the component is pushed with, so a\n * client can keep rendering messages persisted under an older shape.\n */\n version?: number;\n}\n\n/** Component names: an identifier a registry key, a tool name and a snake_case slug can all be derived from. */\nexport const COMPONENT_NAME = /^[A-Za-z][A-Za-z0-9]{0,63}$/;\n\n/** Declare a component. Validates the name and returns the definition unchanged (typed). */\nexport function defineComponent<P = Record<string, unknown>>(\n definition: ComponentDefinition<P>,\n): ComponentDefinition<P> {\n if (!COMPONENT_NAME.test(definition.name)) {\n throw new Error(\n `genui: component name \"${definition.name}\" must be letters and digits, starting with a letter (e.g. DataTable)`,\n );\n }\n if (\n definition.version !== undefined &&\n (!Number.isSafeInteger(definition.version) || definition.version <= 0)\n )\n throw new RangeError('genui: component version must be a positive safe integer');\n if (definition.fallbackText !== undefined && typeof definition.fallbackText !== 'function')\n throw new TypeError('genui: fallbackText must be a function');\n return definition;\n}\n\nexport interface CatalogOptions {\n /** How JSON Schema props are checked. Default: {@link builtinJsonSchemaValidator}; pass `ajvValidator(new Ajv())` for full JSON Schema. */\n jsonSchemaValidator?: JsonSchemaValidator;\n}\n\n/** An immutable set of component definitions, looked up by name. */\nexport interface Catalog {\n readonly components: readonly ComponentDefinition<any>[];\n readonly validator: JsonSchemaValidator;\n get(name: string): ComponentDefinition<any> | undefined;\n has(name: string): boolean;\n /** The components a model may be offered (every non-`internal` one). */\n modelComponents(): ComponentDefinition<any>[];\n /** Validate `props` for `component`. An unknown component is a validation failure, not a throw. */\n validate(component: string, props: unknown): Promise<GenuiValidation<Record<string, unknown>>>;\n /**\n * {@link validate} without waiting — `undefined` only when the component's Standard Schema\n * validates asynchronously. An unknown component is a failure, as in `validate`.\n */\n validateSync(\n component: string,\n props: unknown,\n ): GenuiValidation<Record<string, unknown>> | undefined;\n /** The component's props as JSON Schema, when it can be derived (see {@link toJsonSchema}). */\n jsonSchemaFor(component: string): JsonSchema | undefined;\n /** A new catalog with these components added (a later definition replaces an earlier one of the same name). */\n extend(components: readonly ComponentDefinition<any>[]): Catalog;\n}\n\n/**\n * The model components a FLAT tool can offer — one whose input is the component's props alone\n * (`ui__show_<name>`, the generic show tool). A layout component (`children: true`) is left out:\n * those tools have no way to pass it children, so it would only ever draw an empty box. Tree mode\n * offers every model component.\n */\nexport function flatComponents(catalog: Catalog): ComponentDefinition<any>[] {\n return catalog.modelComponents().filter((component) => component.children !== true);\n}\n\n/**\n * Collect component definitions into a {@link Catalog}. Names must be unique; to override a\n * definition (e.g. a builtin), use {@link Catalog.extend}.\n */\nexport function defineCatalog(\n components: readonly ComponentDefinition<any>[],\n options: CatalogOptions = {},\n): Catalog {\n const byName = new Map<string, ComponentDefinition<any>>();\n for (const component of components) {\n defineComponent(component);\n if (byName.has(component.name)) {\n throw new Error(`genui: component \"${component.name}\" is defined twice in one catalog`);\n }\n byName.set(component.name, component);\n }\n return buildCatalog(byName, options.jsonSchemaValidator ?? builtinJsonSchemaValidator);\n}\n\nfunction buildCatalog(\n byName: Map<string, ComponentDefinition<any>>,\n validator: JsonSchemaValidator,\n): Catalog {\n const list = Object.freeze([...byName.values()]);\n return {\n components: list,\n validator,\n get: (name) => byName.get(name),\n has: (name) => byName.has(name),\n modelComponents: () => list.filter((component) => component.internal !== true),\n async validate(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n const result = await validateProps(\n definition.outputProps ?? definition.props,\n props,\n validator,\n );\n return result as GenuiValidation<Record<string, unknown>>;\n },\n validateSync(component, props) {\n const definition = byName.get(component);\n if (definition === undefined) {\n return {\n ok: false,\n issues: [{ path: [], message: `unknown component \"${component}\"` }],\n };\n }\n return validatePropsSync(definition.outputProps ?? definition.props, props, validator) as\n | GenuiValidation<Record<string, unknown>>\n | undefined;\n },\n jsonSchemaFor(component) {\n const definition = byName.get(component);\n return definition === undefined\n ? undefined\n : toJsonSchema(definition.outputProps ?? definition.props);\n },\n extend(more) {\n const next = new Map(byName);\n for (const component of more) {\n defineComponent(component);\n next.set(component.name, component);\n }\n return buildCatalog(next, validator);\n },\n };\n}\n\n/** `DataTable` → `data_table`, `KPICards` → `kpi_cards`. */\nexport function toSnakeCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase();\n}\n\n/** The per-component tool name: `ui__show_data_table` with the default prefix. */\nexport function toolNameFor(component: string, prefix = 'ui__show_'): string {\n return `${prefix}${toSnakeCase(component)}`;\n}\n","/**\n * Optional builtin component DEFINITIONS — names, props schemas, model descriptions and plain-text\n * fallbacks for the components most chat apps want. No visuals: an app renders each with its own\n * look, keyed by name. Use them as-is, pick some, or extend them:\n *\n * ```ts\n * const catalog = defineCatalog([...BUILTIN_COMPONENTS, ...LAYOUT_COMPONENTS, myDealCard]);\n * ```\n */\nimport { type ComponentDefinition, defineComponent } from './catalog.js';\nimport type { JsonSchema } from './schema.js';\n\ntype Props = Record<string, any>;\n\nconst str = (description?: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n ...(description !== undefined ? { description } : {}),\n ...extra,\n});\nconst obj = (properties: Record<string, JsonSchema>, required: string[] = []): JsonSchema => ({\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n});\nconst arr = (items: JsonSchema, extra: JsonSchema = {}): JsonSchema => ({\n type: 'array',\n items,\n ...extra,\n});\nconst cell: JsonSchema = { type: ['string', 'number', 'boolean', 'null'] };\nconst row: JsonSchema = { type: 'object', additionalProperties: cell };\n\nconst s = (value: unknown): string => (value === null || value === undefined ? '' : String(value));\nconst heading = (props: Props): string => (props.title ? `*${s(props.title)}*\\n` : '');\n\n/** A fixed-width text table in a code block, at most `max` rows. */\nexport function textTable(\n columns: readonly { key: string; label: string }[],\n rows: readonly Props[],\n max = 15,\n): string {\n const shown = rows.slice(0, max);\n const widths = columns.map((column) =>\n Math.min(28, Math.max(column.label.length, ...shown.map((r) => s(r[column.key]).length))),\n );\n const format = (values: string[]) =>\n values\n .map((value, index) => value.slice(0, widths[index]).padEnd(widths[index] ?? 0))\n .join(' ');\n const lines = [\n format(columns.map((column) => column.label)),\n widths.map((width) => '-'.repeat(width)).join(' '),\n ...shown.map((r) => format(columns.map((column) => s(r[column.key])))),\n ];\n if (rows.length > max) lines.push(`… ${rows.length - max} more rows`);\n return `\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport interface DiffLine {\n op: 'same' | 'add' | 'del';\n text: string;\n}\n\n/** Line diff (LCS) — good enough for snippets up to a few hundred lines. */\nexport function lineDiff(before: string, after: string): DiffLine[] {\n const a = before.split('\\n');\n const b = after.split('\\n');\n if (a.length * b.length > 250_000) {\n return [\n ...a.map((text) => ({ op: 'del' as const, text })),\n ...b.map((text) => ({ op: 'add' as const, text })),\n ];\n }\n const dp: number[][] = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n );\n const at = (i: number, j: number): number => dp[i]?.[j] ?? 0;\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n (dp[i] as number[])[j] =\n a[i] === b[j] ? at(i + 1, j + 1) + 1 : Math.max(at(i + 1, j), at(i, j + 1));\n }\n }\n const out: DiffLine[] = [];\n let i = 0;\n let j = 0;\n while (i < a.length && j < b.length) {\n if (a[i] === b[j]) {\n out.push({ op: 'same', text: a[i] as string });\n i++;\n j++;\n } else if (at(i + 1, j) >= at(i, j + 1)) {\n out.push({ op: 'del', text: a[i++] as string });\n } else {\n out.push({ op: 'add', text: b[j++] as string });\n }\n }\n while (i < a.length) out.push({ op: 'del', text: a[i++] as string });\n while (j < b.length) out.push({ op: 'add', text: b[j++] as string });\n return out;\n}\n\nfunction bar(value: number, max: number, width = 20): string {\n const n = max > 0 ? Math.round((Math.abs(value) / max) * width) : 0;\n return '█'.repeat(n) || '▏';\n}\n\nexport const DataTable = defineComponent<Props>({\n name: 'DataTable',\n title: 'Data table',\n description:\n 'Tabular data (records with the same fields) as a sortable table. Prefer it over markdown tables for more than 3 rows.',\n props: obj(\n {\n title: str('Short caption'),\n columns: arr(\n obj(\n {\n key: str('Field name in each row'),\n label: str('Column header'),\n align: str(undefined, { enum: ['left', 'right', 'center'] }),\n format: str('How to format values', {\n enum: ['text', 'number', 'currency', 'percent', 'date', 'link'],\n }),\n },\n ['key', 'label'],\n ),\n { minItems: 1, maxItems: 12 },\n ),\n rows: arr(row, { maxItems: 500 }),\n },\n ['columns', 'rows'],\n ),\n fallbackText: (props) => `${heading(props)}${textTable(props.columns ?? [], props.rows ?? [])}`,\n});\n\nexport const Chart = defineComponent<Props>({\n name: 'Chart',\n title: 'Chart',\n description:\n '`bar` to compare categories, `line` for a trend over time. `data` is a list of points; `xKey` names the category/time field and each series names a numeric field.',\n props: obj(\n {\n type: str('Chart type', { enum: ['bar', 'line'] }),\n title: str(),\n xKey: str('Field of each point used for the x axis'),\n series: arr(obj({ key: str('Numeric field'), label: str() }, ['key']), {\n minItems: 1,\n maxItems: 6,\n }),\n data: arr(row, { minItems: 1, maxItems: 200 }),\n unit: str('Unit shown after values, e.g. `KB` or `%`'),\n },\n ['type', 'xKey', 'series', 'data'],\n ),\n fallbackText: (props) => chartText(props),\n});\n\n/**\n * A chart as text. `line` → a table (x, then one column per series), which keeps every value\n * readable; `bar` → one bar per point, and per series when there are several, all on one scale so\n * bars of different series compare.\n */\nfunction chartText(props: Props): string {\n const series: { key: string; label?: string }[] = (props.series ?? []).filter(\n (each: unknown) => typeof (each as { key?: unknown })?.key === 'string',\n );\n const data: Props[] = props.data ?? [];\n const unit = props.unit ? ` ${s(props.unit)}` : '';\n const labelOf = (each: { key: string; label?: string }) => s(each.label) || each.key;\n if (props.type === 'line') {\n const columns = [\n { key: s(props.xKey), label: s(props.xKey) },\n ...series.map((each) => ({ key: each.key, label: `${labelOf(each)}${unit}` })),\n ];\n return `${heading(props)}${textTable(columns, data, 20)}`;\n }\n const max = Math.max(\n 0,\n ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))),\n );\n const shown = data.slice(0, 20);\n const lines: string[] = [];\n if (series.length <= 1) {\n const key = series[0]?.key ?? '';\n for (const point of shown) {\n lines.push(\n `${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`,\n );\n }\n } else {\n const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));\n for (const point of shown) {\n lines.push(s(point[props.xKey]).slice(0, 18));\n for (const each of series) {\n lines.push(\n ` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`,\n );\n }\n }\n }\n if (data.length > shown.length) lines.push(`… ${data.length - shown.length} more points`);\n return `${heading(props)}\\`\\`\\`\\n${lines.join('\\n')}\\n\\`\\`\\``;\n}\n\nexport const KpiCards = defineComponent<Props>({\n name: 'KpiCards',\n title: 'KPI cards',\n description: 'A few key numbers (metrics, totals, counts) as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj(\n {\n label: str(),\n value: { type: ['string', 'number'] },\n delta: str('Change, e.g. `+12%`'),\n trend: str(undefined, { enum: ['up', 'down', 'flat'] }),\n hint: str(),\n },\n ['label', 'value'],\n ),\n { minItems: 1, maxItems: 8 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• *${s(item.label)}:* ${s(item.value)}${item.delta ? ` (${s(item.delta)})` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const SourceCards = defineComponent<Props>({\n name: 'SourceCards',\n title: 'Sources',\n description: 'The documents, pages or links an answer is based on, as cards.',\n props: obj(\n {\n title: str(),\n items: arr(\n obj({ title: str(), url: str(), snippet: str(), source: str('e.g. Wiki, GitHub') }, [\n 'title',\n ]),\n { minItems: 1, maxItems: 12 },\n ),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `• ${item.url ? `<${s(item.url)}|${s(item.title)}>` : s(item.title)}${item.source ? ` — ${s(item.source)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Checklist = defineComponent<Props>({\n name: 'Checklist',\n title: 'Checklist',\n description: 'Steps or a to-do list with done/not-done state.',\n props: obj(\n {\n title: str(),\n items: arr(obj({ label: str(), done: { type: 'boolean' }, note: str() }, ['label']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['items'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.items ?? [])\n .map(\n (item: Props) =>\n `${item.done ? '☑' : '☐'} ${s(item.label)}${item.note ? ` — _${s(item.note)}_` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const Timeline = defineComponent<Props>({\n name: 'Timeline',\n title: 'Timeline',\n description: 'Events in chronological order (the history of a project, an incident, a deal).',\n props: obj(\n {\n title: str(),\n events: arr(obj({ date: str(), title: str(), description: str() }, ['title']), {\n minItems: 1,\n maxItems: 50,\n }),\n },\n ['events'],\n ),\n fallbackText: (props) =>\n `${heading(props)}${(props.events ?? [])\n .map(\n (event: Props) =>\n `• ${event.date ? `*${s(event.date)}* ` : ''}${s(event.title)}${event.description ? ` — ${s(event.description)}` : ''}`,\n )\n .join('\\n')}`,\n});\n\nexport const CodeBlock = defineComponent<Props>({\n name: 'CodeBlock',\n title: 'Code',\n description: 'A code snippet or file excerpt with syntax highlighting.',\n props: obj({ title: str(), language: str(), code: str() }, ['code']),\n fallbackText: (props) => `${heading(props)}\\`\\`\\`\\n${s(props.code)}\\n\\`\\`\\``,\n});\n\nexport const Diff = defineComponent<Props>({\n name: 'Diff',\n title: 'Diff',\n description: 'A before/after change to a text or code file, as a line diff.',\n props: obj({ title: str(), language: str(), before: str(), after: str() }, ['before', 'after']),\n fallbackText: (props) =>\n `${heading(props)}\\`\\`\\`\\n${lineDiff(s(props.before), s(props.after))\n .map((line) => `${line.op === 'add' ? '+' : line.op === 'del' ? '-' : ' '} ${line.text}`)\n .join('\\n')}\\n\\`\\`\\``,\n});\n\nexport const Callout = defineComponent<Props>({\n name: 'Callout',\n title: 'Callout',\n description: 'A short note, warning or success message, emphasized.',\n props: obj(\n {\n tone: str(undefined, { enum: ['info', 'success', 'warning', 'danger'] }),\n title: str(),\n text: str(),\n },\n ['text'],\n ),\n fallbackText: (props) =>\n `${props.tone === 'warning' || props.tone === 'danger' ? ':warning: ' : ':information_source: '}${heading(props)}${s(props.text)}`,\n});\n\nexport const Stack = defineComponent<Props>({\n name: 'Stack',\n title: 'Stack',\n description: 'Lays its children out vertically (or horizontally with direction=row).',\n props: obj({ direction: str(undefined, { enum: ['column', 'row'] }), gap: { type: 'number' } }),\n children: true,\n fallbackText: () => '',\n});\n\nexport const Card = defineComponent<Props>({\n name: 'Card',\n title: 'Card',\n description: 'A box with an optional title around its children.',\n props: obj({ title: str(), subtitle: str() }),\n children: true,\n fallbackText: (props) =>\n props.title ? `*${s(props.title)}*${props.subtitle ? ` — ${s(props.subtitle)}` : ''}` : '',\n});\n\nexport const Heading = defineComponent<Props>({\n name: 'Heading',\n title: 'Heading',\n description: 'A heading.',\n props: obj({ text: str() }, ['text']),\n fallbackText: (props) => `*${s(props.text)}*`,\n});\n\nexport const Text = defineComponent<Props>({\n name: 'Text',\n title: 'Text',\n description: 'A paragraph of plain text (no markdown).',\n props: obj({ text: str(), muted: { type: 'boolean' } }, ['text']),\n fallbackText: (props) => s(props.text),\n});\n\nexport const Badge = defineComponent<Props>({\n name: 'Badge',\n title: 'Badge',\n description: 'A small label.',\n props: obj(\n {\n text: str(),\n tone: str(undefined, { enum: ['neutral', 'brand', 'success', 'warning', 'danger'] }),\n },\n ['text'],\n ),\n fallbackText: (props) => `[${s(props.text)}]`,\n});\n\nexport const Link = defineComponent<Props>({\n name: 'Link',\n title: 'Link',\n description: 'A link to an http(s) URL.',\n props: obj({ text: str(), url: str(undefined, { pattern: '^https?://' }) }, ['text', 'url']),\n fallbackText: (props) => `<${s(props.url)}|${s(props.text || props.url)}>`,\n});\n\nexport const Image = defineComponent<Props>({\n name: 'Image',\n title: 'Image',\n description: 'An image from an https URL.',\n props: obj({ url: str(undefined, { pattern: '^https://' }), alt: str() }, ['url']),\n fallbackText: (props) => s(props.url),\n});\n\n/** Content components: data a model shows. */\nexport const BUILTIN_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n DataTable,\n Chart,\n KpiCards,\n SourceCards,\n Checklist,\n Timeline,\n CodeBlock,\n Diff,\n Callout,\n];\n\n/** Layout and text primitives, mostly for composing trees (`Stack`, `Card` take children). */\nexport const LAYOUT_COMPONENTS: readonly ComponentDefinition<Props>[] = [\n Stack,\n Card,\n Heading,\n Text,\n Badge,\n Link,\n Image,\n];\n"],"mappings":";;;;AAqDO,IAAMA,iBAAiB;AAGvB,SAASC,gBACdC,YAAkC;AAElC,MAAI,CAACF,eAAeG,KAAKD,WAAWE,IAAI,GAAG;AACzC,UAAM,IAAIC,MACR,0BAA0BH,WAAWE,IAAI,uEAAuE;EAEpH;AACA,MACEF,WAAWI,YAAYC,WACtB,CAACC,OAAOC,cAAcP,WAAWI,OAAO,KAAKJ,WAAWI,WAAW,GAEpE,OAAM,IAAII,WAAW,0DAAA;AACvB,MAAIR,WAAWS,iBAAiBJ,UAAa,OAAOL,WAAWS,iBAAiB,WAC9E,OAAM,IAAIC,UAAU,wCAAA;AACtB,SAAOV;AACT;AAhBgBD;;;AC1ChB,IAAMY,MAAM,wBAACC,aAAsBC,QAAoB,CAAC,OAAmB;EACzEC,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5E,EAAEI,MAAMgC,QAAQhC,MAAMwE,GAAG,CAAA,KAAxD;AAChB,CAAA;AAEO,IAAM6B,QAAQtD,gBAAuB;EAC1CC,MAAM;EACN/C,OAAO;EACPjB,aAAa;EACbgB,OAAOZ,IAAI;IAAEoF,KAAKzF,IAAII,QAAW;MAAEiH,SAAS;IAAY,CAAA;IAAIE,KAAKvH,IAAAA;EAAM,GAAG;IAAC;GAAM;EACjFsE,cAAc,wBAACrD,UAAUJ,EAAEI,MAAMwE,GAAG,GAAtB;AAChB,CAAA;AAGO,IAAM+B,qBAA4D;EACvEzD;EACAQ;EACAY;EACAK;EACAI;EACAG;EACAI;EACAG;EACAE;;AAIK,IAAMiB,oBAA2D;EACtEf;EACAI;EACAE;EACAC;EACAE;EACAC;EACAE;;","names":["COMPONENT_NAME","defineComponent","definition","test","name","Error","version","undefined","Number","isSafeInteger","RangeError","fallbackText","TypeError","str","description","extra","type","undefined","obj","properties","required","additionalProperties","arr","items","cell","row","s","value","String","heading","props","title","textTable","columns","rows","max","shown","slice","widths","map","column","Math","min","label","length","r","key","format","values","index","padEnd","join","lines","width","repeat","push","lineDiff","before","after","a","split","b","text","op","dp","Array","from","fill","at","i","j","out","bar","n","round","abs","DataTable","defineComponent","name","align","enum","minItems","maxItems","fallbackText","Chart","xKey","series","data","unit","chartText","filter","each","labelOf","flatMap","point","Number","KpiCards","delta","trend","hint","item","SourceCards","url","snippet","source","Checklist","done","note","Timeline","events","date","event","CodeBlock","language","code","Diff","line","Callout","tone","Stack","direction","gap","children","Card","subtitle","Heading","Text","muted","Badge","Link","pattern","Image","alt","BUILTIN_COMPONENTS","LAYOUT_COMPONENTS"]}
|