@dudousxd/nestjs-agent-core 0.40.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/ag-ui/index.cjs +46 -10
- package/dist/ag-ui/index.cjs.map +1 -1
- package/dist/ag-ui/index.d.cts +9 -3
- package/dist/ag-ui/index.d.ts +9 -3
- package/dist/ag-ui/index.js +46 -10
- package/dist/ag-ui/index.js.map +1 -1
- package/dist/{catalog-CrzetM3_.d.cts → catalog-BKS3Yxo6.d.cts} +2 -0
- package/dist/{catalog-CrzetM3_.d.ts → catalog-BKS3Yxo6.d.ts} +2 -0
- 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.map +1 -1
- package/dist/genui/index.cjs +660 -68
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +5 -5
- package/dist/genui/index.d.ts +5 -5
- package/dist/genui/index.js +654 -68
- package/dist/genui/index.js.map +1 -1
- package/dist/guardrails/index.cjs +3 -1
- package/dist/guardrails/index.cjs.map +1 -1
- package/dist/guardrails/index.d.cts +5 -4
- package/dist/guardrails/index.d.ts +5 -4
- package/dist/guardrails/index.js +3 -1
- package/dist/guardrails/index.js.map +1 -1
- package/dist/index.cjs +1164 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -13
- package/dist/index.d.ts +124 -13
- package/dist/index.js +1156 -421
- package/dist/index.js.map +1 -1
- package/dist/{processors-BR3nICcp.d.ts → processors-BKILjME5.d.ts} +1 -1
- package/dist/{processors-B7nfbU6E.d.cts → processors-DpHBqRuE.d.cts} +1 -1
- package/dist/{stream-events-M0jc7lSW.d.cts → stream-events-C-pj3bVY.d.cts} +92 -4
- package/dist/{stream-events-DAmes2Of.d.ts → stream-events-D92SgfRk.d.ts} +92 -4
- package/package.json +1 -1
|
@@ -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 /**\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(definition.props, props, validator);\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.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 ? undefined : toJsonSchema(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;;;;;;;;;;;;;;;;;;;;;;;;;;ACiDO,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;;;ADtChB,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;IA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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) => {\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;;;;;;;;;;;;;;;;;;;;;;;;;;ACmDO,IAAMA,iBAAiB;AAGvB,SAASC,gBACdC,YAAkC;AAElC,MAAI,CAACF,eAAeG,KAAKD,WAAWE,IAAI,GAAG;AACzC,UAAM,IAAIC,MACR,0BAA0BH,WAAWE,IAAI,uEAAu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AAMjD,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"]}
|
package/dist/genui/builtins.d.ts
CHANGED
|
@@ -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 /**\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(definition.props, props, validator);\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.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 ? undefined : toJsonSchema(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":";;;;AAiDO,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;;;ACtChB,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,MAAkB;EAAET,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","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.\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,IAA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Ac,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"]}
|