@absolutejs/ai 0.0.40 → 0.0.42

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.
@@ -3,10 +3,10 @@
3
3
  "sources": ["../src/ai/ui/uiCards.ts", "../src/ai/ui/catalog.ts", "../src/ai/ui/svg.ts"],
4
4
  "sourcesContent": [
5
5
  "import type { AIToolMap } from \"../../../types/ai\";\n\n/**\n * UI cards — the generative-UI primitive extracted from onSpark's chat.\n *\n * A \"card\" is a schema-only tool: the model calls it with a structured payload,\n * the handler only ACKNOWLEDGES (steering the model's continuation), and the\n * host watches the executed tool calls to render the payload as a real,\n * host-styled component (a chart, a table, an approval card, a deep link…).\n * No model-written code ever executes: the payload is validated by the card's\n * `parse` before anything renders, so a malformed call simply drops.\n */\nexport type UiCardDefinition<T = unknown> = {\n /** Tool name the model calls, e.g. \"render_chart\". */\n name: string;\n /** Tool description — steer WHEN the model should render this card. */\n description: string;\n /** JSON schema for the tool input. */\n inputSchema: Record<string, unknown>;\n /** Tool-result text fed back to the model (e.g. \"(chart rendered — don't\n * repeat its numbers in text)\"). */\n ack: string;\n /** Validate + narrow the raw model input to the card payload. Return null\n * to reject the call (the card is dropped, the ack still steered). */\n parse: (input: unknown) => T | null;\n};\n\nexport type UiCardEvent = {\n /** The card's tool name. */\n card: string;\n /** The parsed, validated payload. */\n data: unknown;\n};\n\nexport type UiCards = {\n /** AIToolMap entries (ack handlers) — spread into the tools you hand to\n * streamAIWithTools / generateAIWithTools. */\n tools: AIToolMap;\n /** Pull validated card events out of a turn's tool calls, in call order.\n * Invalid payloads and non-card tools are skipped. */\n collect: (\n calls: readonly { name: string; input: unknown }[],\n ) => UiCardEvent[];\n /** Is this tool name one of the registered cards? */\n has: (name: string) => boolean;\n};\n\n/** Build the tool map + collector for a set of UI cards. */\nexport const createUiCards = (\n definitions: readonly UiCardDefinition[],\n): UiCards => {\n const byName = new Map(\n definitions.map((definition) => [definition.name, definition]),\n );\n\n const tools: AIToolMap = Object.fromEntries(\n definitions.map((definition) => [\n definition.name,\n {\n description: definition.description,\n handler: () => definition.ack,\n input: definition.inputSchema,\n },\n ]),\n );\n\n const collect = (calls: readonly { name: string; input: unknown }[]) => {\n const events: UiCardEvent[] = [];\n for (const call of calls) {\n const definition = byName.get(call.name);\n if (!definition) continue;\n const data = definition.parse(call.input);\n if (data !== null) events.push({ card: definition.name, data });\n }\n\n return events;\n };\n\n return { collect, has: (name: string) => byName.has(name), tools };\n};\n",
6
- "import type { UiCardDefinition } from \"./uiCards\";\n\n/**\n * Built-in UI card catalog: chart, table, stat tiles. Declarative specs the\n * model authors and the host renders — see svg.ts for the dependency-free\n * default renderer. Caps are hard product guards (a model can't render a\n * 400-row table into a chat bubble).\n */\n\nexport const CHART_TYPES = [\"bar\", \"line\", \"donut\"] as const;\nexport type ChartType = (typeof CHART_TYPES)[number];\n\nexport type ChartSeries = { name: string; values: number[] };\n\nexport type ChartSpec = {\n type: ChartType;\n title: string;\n /** Category labels: x-axis (bar/line) or slice names (donut). */\n labels: string[];\n /** ≤ 8 series (fixed hue order). Donut charts use exactly one series. */\n series: ChartSeries[];\n /** Value formatting, e.g. \"$\" / \"%\". */\n unitPrefix?: string;\n unitSuffix?: string;\n /** Optional action buttons rendered under the card (≤ 3). */\n actions?: UiAction[];\n};\n\nexport type TableSpec = {\n title?: string;\n columns: string[];\n rows: string[][];\n /** Optional action buttons rendered under the card (≤ 3). */\n actions?: UiAction[];\n};\n\nexport type StatTile = {\n label: string;\n value: string;\n /** Optional change annotation, e.g. \"+12% vs last month\". */\n delta?: string;\n deltaDirection?: \"up\" | \"down\" | \"flat\";\n};\n\nexport type StatTilesSpec = { tiles: StatTile[]; actions?: UiAction[] };\n\n/**\n * An action binding on a UI card: a button the host renders under the card\n * that, on click, invokes one of the HOST'S OWN tools with a model-authored\n * input. The host decides which tools are click-invokable (approval-gated\n * tools should queue their normal approval flow, and anything like \"approve a\n * pending action\" should be refused outright) and validates the input against\n * the tool exactly as if the model had called it.\n */\nexport type UiAction = {\n /** Button label, e.g. \"Create follow-up task\". */\n label: string;\n /** The host tool to invoke, e.g. \"create_task\". */\n tool: string;\n /** The tool input, fully resolved by the model (real ids, not placeholders). */\n input: Record<string, unknown>;\n};\n\nexport const FORM_FIELD_TYPES = [\n \"text\",\n \"textarea\",\n \"number\",\n \"select\",\n \"date\",\n \"checkbox\",\n \"password\",\n] as const;\nexport type FormFieldType = (typeof FORM_FIELD_TYPES)[number];\n\nexport type FormField = {\n /** Key the value is submitted under — a valid tool-input property name. */\n name: string;\n label: string;\n /**\n * \"password\" marks a sensitive field: hosts MUST render it masked (an\n * `<input type=\"password\">`-equivalent) and SHOULD route the submitted\n * value outside the model loop entirely (e.g. straight to the host's own\n * secret store) so it never enters the transcript. Password fields never\n * carry a prefill `value` — parseFormSpec drops it.\n */\n type: FormFieldType;\n placeholder?: string;\n required?: boolean;\n /** Choices — select fields only. */\n options?: string[];\n /** Prefill (checkbox: \"true\"/\"false\"; never present on password fields). */\n value?: string;\n};\n\n/**\n * An inline form the model renders when it needs several structured inputs\n * from the member before running a tool. On submit the host merges the field\n * values into `submit.input` under their field names and invokes `submit.tool`\n * exactly like a clicked UiAction.\n */\nexport type FormSpec = {\n title: string;\n description?: string;\n fields: FormField[];\n submit: UiAction;\n};\n\n// Hard caps — chat-bubble scale, and the fixed 8-slot categorical order.\nexport const CHART_MAX_SERIES = 8;\nexport const CHART_MAX_POINTS = 24;\nexport const TABLE_MAX_COLUMNS = 8;\nexport const TABLE_MAX_ROWS = 30;\nexport const STAT_TILES_MAX = 6;\nexport const UI_ACTIONS_MAX = 3;\nexport const FORM_MAX_FIELDS = 8;\nexport const FORM_SELECT_MAX_OPTIONS = 12;\nconst LABEL_MAX_CHARS = 80;\nconst TITLE_MAX_CHARS = 120;\nconst CELL_MAX_CHARS = 160;\nconst UNIT_MAX_CHARS = 8;\nconst ACTION_LABEL_MAX_CHARS = 40;\nconst DESCRIPTION_MAX_CHARS = 280;\n// Tool names are host identifiers, not prose.\nconst ACTION_TOOL_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;\n// Field names become tool-input property keys.\nconst FIELD_NAME_PATTERN = /^[a-z][a-zA-Z0-9_]{0,63}$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst cleanString = (value: unknown, maxChars: number) =>\n typeof value === \"string\" && value.trim().length > 0\n ? value.trim().slice(0, maxChars)\n : null;\n\nconst cleanStringArray = (\n value: unknown,\n maxItems: number,\n maxChars: number,\n) => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const cleaned: string[] = [];\n for (const entry of value.slice(0, maxItems)) {\n const text = cleanString(entry, maxChars);\n cleaned.push(text ?? \"\");\n }\n\n return cleaned;\n};\n\nconst cleanNumberArray = (value: unknown, maxItems: number) => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const cleaned: number[] = [];\n for (const entry of value.slice(0, maxItems)) {\n if (typeof entry !== \"number\" || !Number.isFinite(entry)) return null;\n cleaned.push(entry);\n }\n\n return cleaned;\n};\n\n/** Validate a spec's optional action bindings; undefined when none/invalid.\n * Malformed entries drop individually — a bad button never sinks the card. */\nexport const parseUiActions = (value: unknown): UiAction[] | undefined => {\n if (!Array.isArray(value) || value.length === 0) return undefined;\n const actions: UiAction[] = [];\n for (const raw of value.slice(0, UI_ACTIONS_MAX)) {\n if (!isRecord(raw)) continue;\n const label = cleanString(raw.label, ACTION_LABEL_MAX_CHARS);\n const tool =\n typeof raw.tool === \"string\" && ACTION_TOOL_PATTERN.test(raw.tool)\n ? raw.tool\n : null;\n if (!label || !tool || !isRecord(raw.input)) continue;\n actions.push({ input: raw.input, label, tool });\n }\n\n return actions.length > 0 ? actions : undefined;\n};\n\nconst ACTIONS_SCHEMA = {\n description:\n \"Optional action buttons under the card (max 3): each invokes one of YOUR tools with a fully-resolved input when the member clicks it. Use real ids you looked up — never placeholders. Approval-gated tools queue their normal approval card.\",\n items: {\n properties: {\n input: {\n description: \"The exact tool input to send on click\",\n type: \"object\",\n },\n label: {\n description: 'Short button label, e.g. \"Create follow-up task\"',\n type: \"string\",\n },\n tool: { description: \"The tool name to invoke\", type: \"string\" },\n },\n required: [\"label\", \"tool\", \"input\"],\n type: \"object\",\n },\n type: \"array\",\n};\n\nexport const parseChartSpec = (input: unknown): ChartSpec | null => {\n if (!isRecord(input)) return null;\n const type = CHART_TYPES.find((entry) => entry === input.type);\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const labels = cleanStringArray(\n input.labels,\n CHART_MAX_POINTS,\n LABEL_MAX_CHARS,\n );\n if (!type || !title || !labels) return null;\n\n if (!Array.isArray(input.series) || input.series.length === 0) return null;\n const series: ChartSeries[] = [];\n for (const raw of input.series.slice(0, CHART_MAX_SERIES)) {\n if (!isRecord(raw)) return null;\n const name = cleanString(raw.name, LABEL_MAX_CHARS);\n const values = cleanNumberArray(raw.values, CHART_MAX_POINTS);\n if (!name || !values) return null;\n // Every series aligns with the label axis; pad/trim mismatches drop.\n if (values.length !== labels.length) return null;\n series.push({ name, values });\n }\n // Donut: one series, non-negative slices.\n if (type === \"donut\") {\n const [only] = series;\n if (series.length !== 1 || !only) return null;\n if (only.values.some((value) => value < 0)) return null;\n }\n\n const spec: ChartSpec = { labels, series, title, type };\n const unitPrefix = cleanString(input.unitPrefix, UNIT_MAX_CHARS);\n const unitSuffix = cleanString(input.unitSuffix, UNIT_MAX_CHARS);\n if (unitPrefix) spec.unitPrefix = unitPrefix;\n if (unitSuffix) spec.unitSuffix = unitSuffix;\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n\n return spec;\n};\n\nexport const parseTableSpec = (input: unknown): TableSpec | null => {\n if (!isRecord(input)) return null;\n const columns = cleanStringArray(\n input.columns,\n TABLE_MAX_COLUMNS,\n LABEL_MAX_CHARS,\n );\n if (!columns) return null;\n if (!Array.isArray(input.rows) || input.rows.length === 0) return null;\n const rows: string[][] = [];\n for (const raw of input.rows.slice(0, TABLE_MAX_ROWS)) {\n const cells = cleanStringArray(raw, TABLE_MAX_COLUMNS, CELL_MAX_CHARS);\n if (!cells) return null;\n // Normalize ragged rows to the header width.\n while (cells.length < columns.length) cells.push(\"\");\n rows.push(cells.slice(0, columns.length));\n }\n\n const spec: TableSpec = { columns, rows };\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n if (title) spec.title = title;\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n\n return spec;\n};\n\nexport const parseStatTilesSpec = (input: unknown): StatTilesSpec | null => {\n if (!isRecord(input)) return null;\n if (!Array.isArray(input.tiles) || input.tiles.length === 0) return null;\n const tiles: StatTile[] = [];\n for (const raw of input.tiles.slice(0, STAT_TILES_MAX)) {\n if (!isRecord(raw)) return null;\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n const value = cleanString(raw.value, LABEL_MAX_CHARS);\n if (!label || !value) return null;\n const tile: StatTile = { label, value };\n const delta = cleanString(raw.delta, LABEL_MAX_CHARS);\n if (delta) tile.delta = delta;\n if (\n raw.deltaDirection === \"up\" ||\n raw.deltaDirection === \"down\" ||\n raw.deltaDirection === \"flat\"\n ) {\n tile.deltaDirection = raw.deltaDirection;\n }\n tiles.push(tile);\n }\n\n const spec: StatTilesSpec = { tiles };\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n\n return spec;\n};\n\nconst parseFormField = (raw: unknown): FormField | null => {\n if (!isRecord(raw)) return null;\n const name =\n typeof raw.name === \"string\" && FIELD_NAME_PATTERN.test(raw.name)\n ? raw.name\n : null;\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n const type = FORM_FIELD_TYPES.find((entry) => entry === raw.type);\n if (!name || !label || !type) return null;\n\n const field: FormField = { label, name, type };\n const placeholder = cleanString(raw.placeholder, LABEL_MAX_CHARS);\n if (placeholder) field.placeholder = placeholder;\n if (raw.required === true) field.required = true;\n // A password prefill would put a secret in the model transcript — drop it.\n const value =\n type === \"password\" ? null : cleanString(raw.value, CELL_MAX_CHARS);\n if (value) field.value = value;\n const options = cleanStringArray(\n raw.options,\n FORM_SELECT_MAX_OPTIONS,\n LABEL_MAX_CHARS,\n );\n if (options) field.options = options;\n // A select without choices can never be filled in.\n if (type === \"select\" && !options) return null;\n\n return field;\n};\n\nconst parseFormFields = (value: unknown): FormField[] | null => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const fields: FormField[] = [];\n const seen = new Set<string>();\n for (const raw of value.slice(0, FORM_MAX_FIELDS)) {\n const field = parseFormField(raw);\n // One malformed or duplicate field sinks the form — a partial form would\n // submit a payload the bound tool never expected.\n if (!field || seen.has(field.name)) return null;\n seen.add(field.name);\n fields.push(field);\n }\n\n return fields;\n};\n\nexport const parseFormSpec = (input: unknown): FormSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const fields = parseFormFields(input.fields);\n const [submit] = parseUiActions([input.submit]) ?? [];\n if (!title || !fields || !submit) return null;\n\n const spec: FormSpec = { fields, submit, title };\n const description = cleanString(input.description, DESCRIPTION_MAX_CHARS);\n if (description) spec.description = description;\n\n return spec;\n};\n\nconst SERIES_SCHEMA = {\n properties: {\n name: { description: \"Series name (shown in the legend)\", type: \"string\" },\n values: {\n description: \"One number per label, same order as labels\",\n items: { type: \"number\" },\n type: \"array\",\n },\n },\n required: [\"name\", \"values\"],\n type: \"object\",\n};\n\n/** render_chart — bar / line / donut from data you already have. */\nexport const chartCard: UiCardDefinition<ChartSpec> = {\n ack: \"(chart rendered inline — do not repeat its numbers as text; add at most a 1-2 line takeaway)\",\n description:\n \"Render a real chart inline in the chat from data you have (tool results, the conversation). Use whenever numbers COMPARE or TREND: revenue by partner (bar), pipeline over time (line), share of a whole (donut). Rules: bar/line take up to 8 series aligned to the same labels; donut takes exactly ONE series of non-negative values (one slice per label). Prefer a chart over a wall of numbers, but never invent data for it.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n labels: {\n description:\n \"Category labels — x-axis for bar/line, slice names for donut (max 24)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n series: {\n description: \"Data series (max 8; donut exactly 1)\",\n items: SERIES_SCHEMA,\n type: \"array\",\n },\n title: { description: \"Short chart title\", type: \"string\" },\n type: { enum: [...CHART_TYPES], type: \"string\" },\n unitPrefix: {\n description: 'Prepended to values, e.g. \"$\"',\n type: \"string\",\n },\n unitSuffix: {\n description: 'Appended to values, e.g. \"%\"',\n type: \"string\",\n },\n },\n required: [\"type\", \"title\", \"labels\", \"series\"],\n type: \"object\",\n },\n name: \"render_chart\",\n parse: parseChartSpec,\n};\n\n/** render_table — a compact data table. */\nexport const tableCard: UiCardDefinition<TableSpec> = {\n ack: \"(table rendered inline — do not repeat its rows as text)\",\n description:\n \"Render a compact data table inline in the chat (max 8 columns × 30 rows). Use for structured comparisons the member will scan — matches side by side, deal terms, task lists with dates. All cells are strings; format numbers yourself.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n columns: {\n description: \"Column headers (max 8)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n rows: {\n description: \"Rows of cells, each aligned to columns (max 30)\",\n items: { items: { type: \"string\" }, type: \"array\" },\n type: \"array\",\n },\n title: { description: \"Optional table title\", type: \"string\" },\n },\n required: [\"columns\", \"rows\"],\n type: \"object\",\n },\n name: \"render_table\",\n parse: parseTableSpec,\n};\n\n/** render_stat_tiles — a row of headline numbers. */\nexport const statTilesCard: UiCardDefinition<StatTilesSpec> = {\n ack: \"(stat tiles rendered inline — do not repeat the numbers as text)\",\n description:\n \"Render a row of headline stat tiles inline in the chat (max 6): a label, a big value, and an optional delta with direction. Use for the 2-4 numbers that ARE the answer — total attributed revenue, pipeline value, credits remaining — instead of burying them in prose.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n tiles: {\n description: \"The tiles (max 6)\",\n items: {\n properties: {\n delta: {\n description: 'Optional change note, e.g. \"+12% vs last month\"',\n type: \"string\",\n },\n deltaDirection: { enum: [\"up\", \"down\", \"flat\"], type: \"string\" },\n label: { description: \"What the number is\", type: \"string\" },\n value: {\n description: 'The formatted headline value, e.g. \"$42,300\"',\n type: \"string\",\n },\n },\n required: [\"label\", \"value\"],\n type: \"object\",\n },\n type: \"array\",\n },\n },\n required: [\"tiles\"],\n type: \"object\",\n },\n name: \"render_stat_tiles\",\n parse: parseStatTilesSpec,\n};\n\n/** render_form — collect structured inputs, then run a bound tool on submit. */\nexport const formCard: UiCardDefinition<FormSpec> = {\n ack: \"(form rendered inline — the member fills and submits it, which runs the bound tool with their values. Do NOT re-ask for these values in text; wait for the submission)\",\n description:\n \"Render an inline form when you need SEVERAL structured inputs from the member before running a tool (task details, scheduling constraints, outreach parameters) — one form beats asking field-by-field in prose. Bind submit to one of YOUR tools with any values you already know pre-filled in submit.input; on submit the member's field values are merged into submit.input under each field's name and the tool runs exactly like a clicked action button. Field names must therefore be the tool's actual input property names. Never use it for values you could look up yourself. Use type \\\"password\\\" for sensitive values (API keys, secrets, credentials) — the host renders it masked and never pre-fill a value for it.\",\n inputSchema: {\n properties: {\n description: {\n description: \"Optional one-line helper text under the title\",\n type: \"string\",\n },\n fields: {\n description:\n \"The inputs to collect (max 8). Each field's name must be a real input property of the submit tool.\",\n items: {\n properties: {\n label: { description: \"Human label for the field\", type: \"string\" },\n name: {\n description:\n 'Tool-input property name the value submits under, e.g. \"title\"',\n type: \"string\",\n },\n options: {\n description: \"Choices — required for select fields (max 12)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n placeholder: { type: \"string\" },\n required: { type: \"boolean\" },\n type: { enum: [...FORM_FIELD_TYPES], type: \"string\" },\n value: {\n description: 'Prefill value (checkbox: \"true\"/\"false\")',\n type: \"string\",\n },\n },\n required: [\"name\", \"label\", \"type\"],\n type: \"object\",\n },\n type: \"array\",\n },\n submit: {\n description:\n \"The submit binding: label for the button, the tool to run, and any input values you already resolved (real ids, never placeholders)\",\n properties: {\n input: {\n description:\n \"Pre-resolved input values; field values are merged in on top under their field names\",\n type: \"object\",\n },\n label: {\n description: 'Button label, e.g. \"Create task\"',\n type: \"string\",\n },\n tool: { description: \"The tool name to invoke\", type: \"string\" },\n },\n required: [\"label\", \"tool\", \"input\"],\n type: \"object\",\n },\n title: { description: \"Short form title\", type: \"string\" },\n },\n required: [\"title\", \"fields\", \"submit\"],\n type: \"object\",\n },\n name: \"render_form\",\n parse: parseFormSpec,\n};\n\n/** The built-in catalog, ready for createUiCards. */\nexport const BUILTIN_UI_CARDS = [\n chartCard,\n tableCard,\n statTilesCard,\n formCard,\n] as const;\n",
6
+ "import type { UiCardDefinition } from \"./uiCards\";\n\n/**\n * Built-in UI card catalog: chart, table, stat tiles, form, choice, confirm,\n * diff, plan, and credential-request cards. Declarative specs the model\n * authors and the host renders — see svg.ts for the dependency-free default\n * chart renderer. Caps are hard product guards (a model can't render a\n * 400-row table into a chat bubble).\n *\n * Card identity: every spec carries an optional `cardId`. When a host\n * receives a card whose cardId it has already rendered in the conversation,\n * it MUST replace that earlier render in place instead of appending a new\n * card. This is a pure host rendering contract — no loop-side state — and it\n * is how planCard progresses: the model re-emits the same cardId with\n * updated step statuses. The field lives here, in the shared spec layer, so\n * every host implements the same semantics.\n */\n\nexport const CHART_TYPES = [\"bar\", \"line\", \"donut\"] as const;\nexport type ChartType = (typeof CHART_TYPES)[number];\n\nexport type ChartSeries = { name: string; values: number[] };\n\nexport type ChartSpec = {\n type: ChartType;\n title: string;\n /** Category labels: x-axis (bar/line) or slice names (donut). */\n labels: string[];\n /** ≤ 8 series (fixed hue order). Donut charts use exactly one series. */\n series: ChartSeries[];\n /** Value formatting, e.g. \"$\" / \"%\". */\n unitPrefix?: string;\n unitSuffix?: string;\n /** Optional action buttons rendered under the card (≤ 3). */\n actions?: UiAction[];\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport type TableSpec = {\n title?: string;\n columns: string[];\n rows: string[][];\n /** Optional action buttons rendered under the card (≤ 3). */\n actions?: UiAction[];\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport type StatTile = {\n label: string;\n value: string;\n /** Optional change annotation, e.g. \"+12% vs last month\". */\n delta?: string;\n deltaDirection?: \"up\" | \"down\" | \"flat\";\n};\n\nexport type StatTilesSpec = {\n tiles: StatTile[];\n actions?: UiAction[];\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\n/**\n * An action binding on a UI card: a button the host renders under the card\n * that, on click, invokes one of the HOST'S OWN tools with a model-authored\n * input. The host decides which tools are click-invokable (approval-gated\n * tools should queue their normal approval flow, and anything like \"approve a\n * pending action\" should be refused outright) and validates the input against\n * the tool exactly as if the model had called it.\n */\nexport type UiAction = {\n /** Button label, e.g. \"Create follow-up task\". */\n label: string;\n /** The host tool to invoke, e.g. \"create_task\". */\n tool: string;\n /** The tool input, fully resolved by the model (real ids, not placeholders). */\n input: Record<string, unknown>;\n};\n\nexport const FORM_FIELD_TYPES = [\n \"text\",\n \"textarea\",\n \"number\",\n \"select\",\n \"date\",\n \"checkbox\",\n \"password\",\n] as const;\nexport type FormFieldType = (typeof FORM_FIELD_TYPES)[number];\n\nexport type FormField = {\n /** Key the value is submitted under — a valid tool-input property name. */\n name: string;\n label: string;\n /**\n * \"password\" marks a sensitive field: hosts MUST render it masked (an\n * `<input type=\"password\">`-equivalent) and SHOULD route the submitted\n * value outside the model loop entirely (e.g. straight to the host's own\n * secret store) so it never enters the transcript. Password fields never\n * carry a prefill `value` — parseFormSpec drops it.\n */\n type: FormFieldType;\n placeholder?: string;\n required?: boolean;\n /** Choices — select fields only. */\n options?: string[];\n /** Prefill (checkbox: \"true\"/\"false\"; never present on password fields). */\n value?: string;\n};\n\n/**\n * An inline form the model renders when it needs several structured inputs\n * from the member before running a tool. On submit the host merges the field\n * values into `submit.input` under their field names and invokes `submit.tool`\n * exactly like a clicked UiAction.\n */\nexport type FormSpec = {\n title: string;\n description?: string;\n fields: FormField[];\n submit: UiAction;\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport type ChoiceOption = {\n /** Stable option id — merged into submit.input on selection. */\n id: string;\n label: string;\n description?: string;\n /** Tiny annotation rendered beside the label, e.g. \"recommended\". */\n badge?: string;\n};\n\n/**\n * A structured decision card: the member picks one option (or several when\n * `multi`) and the host merges `{ choice: id }` — or `{ choices: id[] }` —\n * into `submit.input`, then invokes `submit.tool` exactly like a clicked\n * UiAction. Same through-loop flow as FormSpec: a choice between\n * model-authored options is non-secret by definition, so loop-visible\n * submission is correct here.\n */\nexport type ChoiceSpec = {\n title: string;\n description?: string;\n /** ≤ 8 options. */\n options: ChoiceOption[];\n /** Allow selecting several options (`{ choices: id[] }` on submit). */\n multi?: boolean;\n submit: UiAction;\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\n/**\n * An explicit-consent card for destructive or irreversible actions.\n *\n * TRUST CONTRACT: the host must invoke `confirm` ONLY on a real user click\n * of the confirm button — never programmatically, and never because the\n * model claims consent was given. Hosts SHOULD mint an unforgeable\n * server-side confirmation token at click time and require it on the\n * downstream action, so a model can never fabricate a confirmation: the\n * token exists only if the click happened.\n */\nexport type ConfirmSpec = {\n title: string;\n /** What will happen, in plain language (≤ 500 chars). */\n consequence: string;\n confirmLabel: string;\n cancelLabel?: string;\n confirm: UiAction;\n /** Render destructive styling (e.g. a red confirm button). */\n danger?: boolean;\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport type DiffFile = {\n path: string;\n /** Unified diff text — DISPLAY data only (the host renders the +/-\n * coloring); nothing is ever executed or applied from the text itself. */\n diff: string;\n /** The shown diff was cut to fit the display caps. */\n truncated?: boolean;\n};\n\n/**\n * Proposed file changes for review. Diffs are display data; the actual\n * change happens through `apply` — a normal UiAction against a host tool\n * with fully-resolved input. Applying files is destructive, so hosts SHOULD\n * route `apply` through a click-minted server-side token exactly like\n * ConfirmSpec. Oversized diffs are truncated by the parser, never rejected:\n * files beyond 6 drop, and diff bodies are cut to a 400-line total budget\n * with `truncated: true` set on every file that was cut.\n */\nexport type DiffSpec = {\n title: string;\n /** ≤ 6 files, ≤ 400 diff lines total across them. */\n files: DiffFile[];\n apply: UiAction;\n reject?: UiAction;\n note?: string;\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport const PLAN_STEP_STATUSES = [\n \"pending\",\n \"active\",\n \"done\",\n \"error\",\n] as const;\nexport type PlanStepStatus = (typeof PLAN_STEP_STATUSES)[number];\n\nexport type PlanStep = {\n /** Stable step id — keep it identical across re-emits of the same plan. */\n id: string;\n label: string;\n status: PlanStepStatus;\n /** One-line progress or error note under the label. */\n detail?: string;\n};\n\n/**\n * A live multi-step plan. Display-only — no submit action. Progress works\n * through the card-identity contract: the model re-emits the SAME cardId\n * with updated step statuses and the host replaces the earlier render in\n * place, so the member sees one live plan instead of a stack of copies.\n */\nexport type PlanSpec = {\n title: string;\n /** ≤ 12 steps. */\n steps: PlanStep[];\n note?: string;\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\nexport type CredentialKey = {\n /** Environment variable name, e.g. \"STRIPE_SECRET_KEY\". */\n key: string;\n /** Human label, e.g. \"Stripe secret key\". */\n label?: string;\n /** Where to obtain the credential (provider dashboard URL). */\n docsUrl?: string;\n /** Mask and never echo. Defaults to TRUE — parseCredentialSpec normalizes\n * it to an explicit boolean so hosts never have to guess. */\n secret?: boolean;\n /** Already configured on the host — render as set, offer replace. */\n isSet?: boolean;\n};\n\n/**\n * A credential-request card. Deliberately has NO submit UiAction — the type\n * makes through-loop submission impossible. The host UI collects the values\n * and stores them OUTSIDE the model loop (its own .env or secret store),\n * then sends a names-only continuation message (\"STRIPE_SECRET_KEY was\n * set\") so the model can proceed. Values never enter the transcript in\n * either direction: parseCredentialSpec drops any value-like field a model\n * attaches (the password-prefill-drop precedent), and hosts never echo\n * stored values back.\n */\nexport type CredentialSpec = {\n title: string;\n /** ≤ 8 keys. */\n keys: CredentialKey[];\n /** Stable card identity — see the card-identity contract in module docs. */\n cardId?: string;\n};\n\n// Hard caps — chat-bubble scale, and the fixed 8-slot categorical order.\nexport const CHART_MAX_SERIES = 8;\nexport const CHART_MAX_POINTS = 24;\nexport const TABLE_MAX_COLUMNS = 8;\nexport const TABLE_MAX_ROWS = 30;\nexport const STAT_TILES_MAX = 6;\nexport const UI_ACTIONS_MAX = 3;\nexport const FORM_MAX_FIELDS = 8;\nexport const FORM_SELECT_MAX_OPTIONS = 12;\nexport const CHOICE_MAX_OPTIONS = 8;\nexport const CONFIRM_CONSEQUENCE_MAX_CHARS = 500;\nexport const DIFF_MAX_FILES = 6;\nexport const DIFF_MAX_LINES = 400;\nexport const PLAN_MAX_STEPS = 12;\nexport const CREDENTIAL_MAX_KEYS = 8;\nexport const CARD_ID_MAX_CHARS = 64;\nconst LABEL_MAX_CHARS = 80;\nconst TITLE_MAX_CHARS = 120;\nconst CELL_MAX_CHARS = 160;\nconst UNIT_MAX_CHARS = 8;\nconst ACTION_LABEL_MAX_CHARS = 40;\nconst DESCRIPTION_MAX_CHARS = 280;\nconst BADGE_MAX_CHARS = 24;\nconst DIFF_PATH_MAX_CHARS = 260;\nconst DIFF_LINE_MAX_CHARS = 300;\nconst DOCS_URL_MAX_CHARS = 300;\n// Tool names are host identifiers, not prose.\nconst ACTION_TOOL_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;\n// Field names become tool-input property keys.\nconst FIELD_NAME_PATTERN = /^[a-z][a-zA-Z0-9_]{0,63}$/;\n// Card / option / step ids: opaque identity tokens, not prose.\nconst CARD_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;\n// Credential keys are environment variable names.\nconst ENV_KEY_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;\nconst DOCS_URL_PATTERN = /^https?:\\/\\//;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst cleanString = (value: unknown, maxChars: number) =>\n typeof value === \"string\" && value.trim().length > 0\n ? value.trim().slice(0, maxChars)\n : null;\n\nconst cleanStringArray = (\n value: unknown,\n maxItems: number,\n maxChars: number,\n) => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const cleaned: string[] = [];\n for (const entry of value.slice(0, maxItems)) {\n const text = cleanString(entry, maxChars);\n cleaned.push(text ?? \"\");\n }\n\n return cleaned;\n};\n\nconst cleanNumberArray = (value: unknown, maxItems: number) => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const cleaned: number[] = [];\n for (const entry of value.slice(0, maxItems)) {\n if (typeof entry !== \"number\" || !Number.isFinite(entry)) return null;\n cleaned.push(entry);\n }\n\n return cleaned;\n};\n\n/** Trim, cap at 64 chars, then require the id charset; null when invalid. */\nconst cleanId = (value: unknown) => {\n if (typeof value !== \"string\") return null;\n const trimmed = value.trim().slice(0, CARD_ID_MAX_CHARS);\n\n return CARD_ID_PATTERN.test(trimmed) ? trimmed : null;\n};\n\n/** Attach a validated cardId to a spec; invalid ids drop silently — identity\n * is an enhancement, never a reason to sink a card. */\nconst applyCardId = (spec: { cardId?: string }, raw: unknown) => {\n const cardId = cleanId(raw);\n if (cardId) spec.cardId = cardId;\n};\n\n/** Validate a spec's optional action bindings; undefined when none/invalid.\n * Malformed entries drop individually — a bad button never sinks the card. */\nexport const parseUiActions = (value: unknown): UiAction[] | undefined => {\n if (!Array.isArray(value) || value.length === 0) return undefined;\n const actions: UiAction[] = [];\n for (const raw of value.slice(0, UI_ACTIONS_MAX)) {\n if (!isRecord(raw)) continue;\n const label = cleanString(raw.label, ACTION_LABEL_MAX_CHARS);\n const tool =\n typeof raw.tool === \"string\" && ACTION_TOOL_PATTERN.test(raw.tool)\n ? raw.tool\n : null;\n if (!label || !tool || !isRecord(raw.input)) continue;\n actions.push({ input: raw.input, label, tool });\n }\n\n return actions.length > 0 ? actions : undefined;\n};\n\nconst ACTIONS_SCHEMA = {\n description:\n \"Optional action buttons under the card (max 3): each invokes one of YOUR tools with a fully-resolved input when the member clicks it. Use real ids you looked up — never placeholders. Approval-gated tools queue their normal approval card.\",\n items: {\n properties: {\n input: {\n description: \"The exact tool input to send on click\",\n type: \"object\",\n },\n label: {\n description: 'Short button label, e.g. \"Create follow-up task\"',\n type: \"string\",\n },\n tool: { description: \"The tool name to invoke\", type: \"string\" },\n },\n required: [\"label\", \"tool\", \"input\"],\n type: \"object\",\n },\n type: \"array\",\n};\n\nconst CARD_ID_SCHEMA = {\n description:\n \"Optional stable card identity (letters/digits/_/-, max 64 chars). Re-emit a card with the SAME cardId to update the earlier render in place instead of adding a new card.\",\n type: \"string\",\n};\n\n// Reusable single-action binding schema (choice submit, confirm, diff apply).\nconst ACTION_BINDING_SCHEMA = {\n properties: {\n input: {\n description:\n \"The exact tool input to send (real ids you looked up, never placeholders)\",\n type: \"object\",\n },\n label: { description: \"Button label\", type: \"string\" },\n tool: { description: \"The tool name to invoke\", type: \"string\" },\n },\n required: [\"label\", \"tool\", \"input\"],\n type: \"object\",\n};\n\nexport const parseChartSpec = (input: unknown): ChartSpec | null => {\n if (!isRecord(input)) return null;\n const type = CHART_TYPES.find((entry) => entry === input.type);\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const labels = cleanStringArray(\n input.labels,\n CHART_MAX_POINTS,\n LABEL_MAX_CHARS,\n );\n if (!type || !title || !labels) return null;\n\n if (!Array.isArray(input.series) || input.series.length === 0) return null;\n const series: ChartSeries[] = [];\n for (const raw of input.series.slice(0, CHART_MAX_SERIES)) {\n if (!isRecord(raw)) return null;\n const name = cleanString(raw.name, LABEL_MAX_CHARS);\n const values = cleanNumberArray(raw.values, CHART_MAX_POINTS);\n if (!name || !values) return null;\n // Every series aligns with the label axis; pad/trim mismatches drop.\n if (values.length !== labels.length) return null;\n series.push({ name, values });\n }\n // Donut: one series, non-negative slices.\n if (type === \"donut\") {\n const [only] = series;\n if (series.length !== 1 || !only) return null;\n if (only.values.some((value) => value < 0)) return null;\n }\n\n const spec: ChartSpec = { labels, series, title, type };\n const unitPrefix = cleanString(input.unitPrefix, UNIT_MAX_CHARS);\n const unitSuffix = cleanString(input.unitSuffix, UNIT_MAX_CHARS);\n if (unitPrefix) spec.unitPrefix = unitPrefix;\n if (unitSuffix) spec.unitSuffix = unitSuffix;\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nexport const parseTableSpec = (input: unknown): TableSpec | null => {\n if (!isRecord(input)) return null;\n const columns = cleanStringArray(\n input.columns,\n TABLE_MAX_COLUMNS,\n LABEL_MAX_CHARS,\n );\n if (!columns) return null;\n if (!Array.isArray(input.rows) || input.rows.length === 0) return null;\n const rows: string[][] = [];\n for (const raw of input.rows.slice(0, TABLE_MAX_ROWS)) {\n const cells = cleanStringArray(raw, TABLE_MAX_COLUMNS, CELL_MAX_CHARS);\n if (!cells) return null;\n // Normalize ragged rows to the header width.\n while (cells.length < columns.length) cells.push(\"\");\n rows.push(cells.slice(0, columns.length));\n }\n\n const spec: TableSpec = { columns, rows };\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n if (title) spec.title = title;\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nexport const parseStatTilesSpec = (input: unknown): StatTilesSpec | null => {\n if (!isRecord(input)) return null;\n if (!Array.isArray(input.tiles) || input.tiles.length === 0) return null;\n const tiles: StatTile[] = [];\n for (const raw of input.tiles.slice(0, STAT_TILES_MAX)) {\n if (!isRecord(raw)) return null;\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n const value = cleanString(raw.value, LABEL_MAX_CHARS);\n if (!label || !value) return null;\n const tile: StatTile = { label, value };\n const delta = cleanString(raw.delta, LABEL_MAX_CHARS);\n if (delta) tile.delta = delta;\n if (\n raw.deltaDirection === \"up\" ||\n raw.deltaDirection === \"down\" ||\n raw.deltaDirection === \"flat\"\n ) {\n tile.deltaDirection = raw.deltaDirection;\n }\n tiles.push(tile);\n }\n\n const spec: StatTilesSpec = { tiles };\n const actions = parseUiActions(input.actions);\n if (actions) spec.actions = actions;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nconst parseFormField = (raw: unknown): FormField | null => {\n if (!isRecord(raw)) return null;\n const name =\n typeof raw.name === \"string\" && FIELD_NAME_PATTERN.test(raw.name)\n ? raw.name\n : null;\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n const type = FORM_FIELD_TYPES.find((entry) => entry === raw.type);\n if (!name || !label || !type) return null;\n\n const field: FormField = { label, name, type };\n const placeholder = cleanString(raw.placeholder, LABEL_MAX_CHARS);\n if (placeholder) field.placeholder = placeholder;\n if (raw.required === true) field.required = true;\n // A password prefill would put a secret in the model transcript — drop it.\n const value =\n type === \"password\" ? null : cleanString(raw.value, CELL_MAX_CHARS);\n if (value) field.value = value;\n const options = cleanStringArray(\n raw.options,\n FORM_SELECT_MAX_OPTIONS,\n LABEL_MAX_CHARS,\n );\n if (options) field.options = options;\n // A select without choices can never be filled in.\n if (type === \"select\" && !options) return null;\n\n return field;\n};\n\nconst parseFormFields = (value: unknown): FormField[] | null => {\n if (!Array.isArray(value) || value.length === 0) return null;\n const fields: FormField[] = [];\n const seen = new Set<string>();\n for (const raw of value.slice(0, FORM_MAX_FIELDS)) {\n const field = parseFormField(raw);\n // One malformed or duplicate field sinks the form — a partial form would\n // submit a payload the bound tool never expected.\n if (!field || seen.has(field.name)) return null;\n seen.add(field.name);\n fields.push(field);\n }\n\n return fields;\n};\n\nexport const parseFormSpec = (input: unknown): FormSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const fields = parseFormFields(input.fields);\n const [submit] = parseUiActions([input.submit]) ?? [];\n if (!title || !fields || !submit) return null;\n\n const spec: FormSpec = { fields, submit, title };\n const description = cleanString(input.description, DESCRIPTION_MAX_CHARS);\n if (description) spec.description = description;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nconst parseChoiceOption = (raw: unknown): ChoiceOption | null => {\n if (!isRecord(raw)) return null;\n const id = cleanId(raw.id);\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n if (!id || !label) return null;\n\n const option: ChoiceOption = { id, label };\n const description = cleanString(raw.description, DESCRIPTION_MAX_CHARS);\n if (description) option.description = description;\n const badge = cleanString(raw.badge, BADGE_MAX_CHARS);\n if (badge) option.badge = badge;\n\n return option;\n};\n\nexport const parseChoiceSpec = (input: unknown): ChoiceSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const [submit] = parseUiActions([input.submit]) ?? [];\n if (!title || !submit) return null;\n if (!Array.isArray(input.options) || input.options.length === 0) return null;\n const options: ChoiceOption[] = [];\n const seen = new Set<string>();\n for (const raw of input.options.slice(0, CHOICE_MAX_OPTIONS)) {\n const option = parseChoiceOption(raw);\n // One malformed or duplicate option sinks the card — a partial option\n // set misrepresents the decision.\n if (!option || seen.has(option.id)) return null;\n seen.add(option.id);\n options.push(option);\n }\n\n const spec: ChoiceSpec = { options, submit, title };\n const description = cleanString(input.description, DESCRIPTION_MAX_CHARS);\n if (description) spec.description = description;\n if (input.multi === true) spec.multi = true;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nexport const parseConfirmSpec = (input: unknown): ConfirmSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const consequence = cleanString(\n input.consequence,\n CONFIRM_CONSEQUENCE_MAX_CHARS,\n );\n const confirmLabel = cleanString(input.confirmLabel, ACTION_LABEL_MAX_CHARS);\n const [confirm] = parseUiActions([input.confirm]) ?? [];\n if (!title || !consequence || !confirmLabel || !confirm) return null;\n\n const spec: ConfirmSpec = { confirm, confirmLabel, consequence, title };\n const cancelLabel = cleanString(input.cancelLabel, ACTION_LABEL_MAX_CHARS);\n if (cancelLabel) spec.cancelLabel = cancelLabel;\n if (input.danger === true) spec.danger = true;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\n/** Shared line budget across a diff card's files — mutated as files parse. */\ntype DiffBudget = { remaining: number };\n\nconst parseDiffFile = (raw: unknown, budget: DiffBudget): DiffFile | null => {\n if (!isRecord(raw)) return null;\n const path = cleanString(raw.path, DIFF_PATH_MAX_CHARS);\n if (!path || typeof raw.diff !== \"string\" || raw.diff.trim().length === 0) {\n return null;\n }\n const lines = raw.diff\n .split(/\\r?\\n/)\n .map((line) => line.slice(0, DIFF_LINE_MAX_CHARS));\n const kept = lines.slice(0, Math.max(budget.remaining, 0));\n budget.remaining -= kept.length;\n\n const file: DiffFile = { diff: kept.join(\"\\n\"), path };\n // Size never rejects: over-budget diffs are cut and flagged instead.\n if (raw.truncated === true || kept.length < lines.length) {\n file.truncated = true;\n }\n\n return file;\n};\n\nexport const parseDiffSpec = (input: unknown): DiffSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n const [apply] = parseUiActions([input.apply]) ?? [];\n if (!title || !apply) return null;\n if (!Array.isArray(input.files) || input.files.length === 0) return null;\n const budget: DiffBudget = { remaining: DIFF_MAX_LINES };\n const files: DiffFile[] = [];\n for (const raw of input.files.slice(0, DIFF_MAX_FILES)) {\n const file = parseDiffFile(raw, budget);\n // A malformed file sinks the card — the member would otherwise review\n // (and apply) a change set they can't actually see in full.\n if (!file) return null;\n files.push(file);\n }\n\n const spec: DiffSpec = { apply, files, title };\n const [reject] = parseUiActions([input.reject]) ?? [];\n if (reject) spec.reject = reject;\n const note = cleanString(input.note, DESCRIPTION_MAX_CHARS);\n if (note) spec.note = note;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nconst parsePlanStep = (raw: unknown): PlanStep | null => {\n if (!isRecord(raw)) return null;\n const id = cleanId(raw.id);\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n const status = PLAN_STEP_STATUSES.find((entry) => entry === raw.status);\n if (!id || !label || !status) return null;\n\n const step: PlanStep = { id, label, status };\n const detail = cleanString(raw.detail, CELL_MAX_CHARS);\n if (detail) step.detail = detail;\n\n return step;\n};\n\nexport const parsePlanSpec = (input: unknown): PlanSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n if (!title) return null;\n if (!Array.isArray(input.steps) || input.steps.length === 0) return null;\n const steps: PlanStep[] = [];\n const seen = new Set<string>();\n for (const raw of input.steps.slice(0, PLAN_MAX_STEPS)) {\n const step = parsePlanStep(raw);\n // Malformed or duplicate step ids sink the card — stable ids are what\n // lets an in-place update line up with the previous render.\n if (!step || seen.has(step.id)) return null;\n seen.add(step.id);\n steps.push(step);\n }\n\n const spec: PlanSpec = { steps, title };\n const note = cleanString(input.note, DESCRIPTION_MAX_CHARS);\n if (note) spec.note = note;\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nconst parseCredentialKey = (raw: unknown): CredentialKey | null => {\n if (!isRecord(raw)) return null;\n const key =\n typeof raw.key === \"string\" && ENV_KEY_PATTERN.test(raw.key)\n ? raw.key\n : null;\n if (!key) return null;\n\n // Only the known display fields survive: any value-like field a model\n // attaches (value, prefill, default…) is dropped here, mirroring the\n // password-prefill drop in parseFormField. Values NEVER ride this card.\n // secret defaults to TRUE — it is normalized explicit so hosts never guess.\n const entry: CredentialKey = { key, secret: raw.secret !== false };\n const label = cleanString(raw.label, LABEL_MAX_CHARS);\n if (label) entry.label = label;\n const docsUrl = cleanString(raw.docsUrl, DOCS_URL_MAX_CHARS);\n if (docsUrl && DOCS_URL_PATTERN.test(docsUrl)) entry.docsUrl = docsUrl;\n if (typeof raw.isSet === \"boolean\") entry.isSet = raw.isSet;\n\n return entry;\n};\n\nexport const parseCredentialSpec = (input: unknown): CredentialSpec | null => {\n if (!isRecord(input)) return null;\n const title = cleanString(input.title, TITLE_MAX_CHARS);\n if (!title) return null;\n if (!Array.isArray(input.keys) || input.keys.length === 0) return null;\n const keys: CredentialKey[] = [];\n const seen = new Set<string>();\n for (const raw of input.keys.slice(0, CREDENTIAL_MAX_KEYS)) {\n const entry = parseCredentialKey(raw);\n // A malformed or duplicate key sinks the card — a partial credential\n // request would leave setup silently incomplete.\n if (!entry || seen.has(entry.key)) return null;\n seen.add(entry.key);\n keys.push(entry);\n }\n\n const spec: CredentialSpec = { keys, title };\n applyCardId(spec, input.cardId);\n\n return spec;\n};\n\nconst SERIES_SCHEMA = {\n properties: {\n name: { description: \"Series name (shown in the legend)\", type: \"string\" },\n values: {\n description: \"One number per label, same order as labels\",\n items: { type: \"number\" },\n type: \"array\",\n },\n },\n required: [\"name\", \"values\"],\n type: \"object\",\n};\n\n/** render_chart — bar / line / donut from data you already have. */\nexport const chartCard: UiCardDefinition<ChartSpec> = {\n ack: \"(chart rendered inline — do not repeat its numbers as text; add at most a 1-2 line takeaway)\",\n description:\n \"Render a real chart inline in the chat from data you have (tool results, the conversation). Use whenever numbers COMPARE or TREND: revenue by partner (bar), pipeline over time (line), share of a whole (donut). Rules: bar/line take up to 8 series aligned to the same labels; donut takes exactly ONE series of non-negative values (one slice per label). Prefer a chart over a wall of numbers, but never invent data for it.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n cardId: CARD_ID_SCHEMA,\n labels: {\n description:\n \"Category labels — x-axis for bar/line, slice names for donut (max 24)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n series: {\n description: \"Data series (max 8; donut exactly 1)\",\n items: SERIES_SCHEMA,\n type: \"array\",\n },\n title: { description: \"Short chart title\", type: \"string\" },\n type: { enum: [...CHART_TYPES], type: \"string\" },\n unitPrefix: {\n description: 'Prepended to values, e.g. \"$\"',\n type: \"string\",\n },\n unitSuffix: {\n description: 'Appended to values, e.g. \"%\"',\n type: \"string\",\n },\n },\n required: [\"type\", \"title\", \"labels\", \"series\"],\n type: \"object\",\n },\n name: \"render_chart\",\n parse: parseChartSpec,\n};\n\n/** render_table — a compact data table. */\nexport const tableCard: UiCardDefinition<TableSpec> = {\n ack: \"(table rendered inline — do not repeat its rows as text)\",\n description:\n \"Render a compact data table inline in the chat (max 8 columns × 30 rows). Use for structured comparisons the member will scan — matches side by side, deal terms, task lists with dates. All cells are strings; format numbers yourself.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n cardId: CARD_ID_SCHEMA,\n columns: {\n description: \"Column headers (max 8)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n rows: {\n description: \"Rows of cells, each aligned to columns (max 30)\",\n items: { items: { type: \"string\" }, type: \"array\" },\n type: \"array\",\n },\n title: { description: \"Optional table title\", type: \"string\" },\n },\n required: [\"columns\", \"rows\"],\n type: \"object\",\n },\n name: \"render_table\",\n parse: parseTableSpec,\n};\n\n/** render_stat_tiles — a row of headline numbers. */\nexport const statTilesCard: UiCardDefinition<StatTilesSpec> = {\n ack: \"(stat tiles rendered inline — do not repeat the numbers as text)\",\n description:\n \"Render a row of headline stat tiles inline in the chat (max 6): a label, a big value, and an optional delta with direction. Use for the 2-4 numbers that ARE the answer — total attributed revenue, pipeline value, credits remaining — instead of burying them in prose.\",\n inputSchema: {\n properties: {\n actions: ACTIONS_SCHEMA,\n cardId: CARD_ID_SCHEMA,\n tiles: {\n description: \"The tiles (max 6)\",\n items: {\n properties: {\n delta: {\n description: 'Optional change note, e.g. \"+12% vs last month\"',\n type: \"string\",\n },\n deltaDirection: { enum: [\"up\", \"down\", \"flat\"], type: \"string\" },\n label: { description: \"What the number is\", type: \"string\" },\n value: {\n description: 'The formatted headline value, e.g. \"$42,300\"',\n type: \"string\",\n },\n },\n required: [\"label\", \"value\"],\n type: \"object\",\n },\n type: \"array\",\n },\n },\n required: [\"tiles\"],\n type: \"object\",\n },\n name: \"render_stat_tiles\",\n parse: parseStatTilesSpec,\n};\n\n/** render_form — collect structured inputs, then run a bound tool on submit. */\nexport const formCard: UiCardDefinition<FormSpec> = {\n ack: \"(form rendered inline — the member fills and submits it, which runs the bound tool with their values. Do NOT re-ask for these values in text; wait for the submission)\",\n description:\n \"Render an inline form when you need SEVERAL structured inputs from the member before running a tool (task details, scheduling constraints, outreach parameters) — one form beats asking field-by-field in prose. Bind submit to one of YOUR tools with any values you already know pre-filled in submit.input; on submit the member's field values are merged into submit.input under each field's name and the tool runs exactly like a clicked action button. Field names must therefore be the tool's actual input property names. Never use it for values you could look up yourself. Use type \\\"password\\\" for sensitive values (API keys, secrets, credentials) — the host renders it masked and never pre-fill a value for it.\",\n inputSchema: {\n properties: {\n cardId: CARD_ID_SCHEMA,\n description: {\n description: \"Optional one-line helper text under the title\",\n type: \"string\",\n },\n fields: {\n description:\n \"The inputs to collect (max 8). Each field's name must be a real input property of the submit tool.\",\n items: {\n properties: {\n label: { description: \"Human label for the field\", type: \"string\" },\n name: {\n description:\n 'Tool-input property name the value submits under, e.g. \"title\"',\n type: \"string\",\n },\n options: {\n description: \"Choices — required for select fields (max 12)\",\n items: { type: \"string\" },\n type: \"array\",\n },\n placeholder: { type: \"string\" },\n required: { type: \"boolean\" },\n type: { enum: [...FORM_FIELD_TYPES], type: \"string\" },\n value: {\n description: 'Prefill value (checkbox: \"true\"/\"false\")',\n type: \"string\",\n },\n },\n required: [\"name\", \"label\", \"type\"],\n type: \"object\",\n },\n type: \"array\",\n },\n submit: {\n description:\n \"The submit binding: label for the button, the tool to run, and any input values you already resolved (real ids, never placeholders)\",\n properties: {\n input: {\n description:\n \"Pre-resolved input values; field values are merged in on top under their field names\",\n type: \"object\",\n },\n label: {\n description: 'Button label, e.g. \"Create task\"',\n type: \"string\",\n },\n tool: { description: \"The tool name to invoke\", type: \"string\" },\n },\n required: [\"label\", \"tool\", \"input\"],\n type: \"object\",\n },\n title: { description: \"Short form title\", type: \"string\" },\n },\n required: [\"title\", \"fields\", \"submit\"],\n type: \"object\",\n },\n name: \"render_form\",\n parse: parseFormSpec,\n};\n\n/** render_choice — a structured decision instead of \"reply 1 or 2\". */\nexport const choiceCard: UiCardDefinition<ChoiceSpec> = {\n ack: \"(choice card rendered inline — the member picks an option, which runs the bound tool with their selection merged in. Do not re-ask in text; wait for the selection)\",\n description:\n \"Render a structured choice card whenever the member must pick between concrete options (which plan, which duplicate record to keep, which time slot) — never ask them to 'reply 1 or 2' in prose. Give every option a stable id; on selection the host merges { choice: id } (or { choices: [ids] } when multi is true) into submit.input and invokes submit.tool exactly like a clicked action button, so put everything you already resolved into submit.input. Max 8 options.\",\n inputSchema: {\n properties: {\n cardId: CARD_ID_SCHEMA,\n description: {\n description: \"Optional one-line helper text under the title\",\n type: \"string\",\n },\n multi: {\n description:\n \"Allow selecting several options — submits { choices: [ids] } instead of { choice: id }\",\n type: \"boolean\",\n },\n options: {\n description: \"The options to choose between (max 8)\",\n items: {\n properties: {\n badge: {\n description:\n 'Tiny annotation beside the label, e.g. \"recommended\"',\n type: \"string\",\n },\n description: {\n description: \"One-line explanation of the option\",\n type: \"string\",\n },\n id: {\n description:\n \"Stable option id merged into submit.input on selection (letters/digits/_/-)\",\n type: \"string\",\n },\n label: { description: \"What the member sees\", type: \"string\" },\n },\n required: [\"id\", \"label\"],\n type: \"object\",\n },\n type: \"array\",\n },\n submit: {\n ...ACTION_BINDING_SCHEMA,\n description:\n \"The submit binding: the tool to run once a choice is made. The selection is merged into input as { choice: id } (or { choices: [ids] })\",\n },\n title: { description: \"The decision being made\", type: \"string\" },\n },\n required: [\"title\", \"options\", \"submit\"],\n type: \"object\",\n },\n name: \"render_choice\",\n parse: parseChoiceSpec,\n};\n\n/** render_confirm — explicit consent for destructive/irreversible actions. */\nexport const confirmCard: UiCardDefinition<ConfirmSpec> = {\n ack: \"(confirmation card rendered inline — NOTHING has run yet; the action only runs if the member clicks confirm. Do not claim or assume it happened; wait for the outcome)\",\n description:\n \"Render an explicit confirmation card before any destructive or irreversible action (deleting data, sending money or bulk email, cancelling a subscription). State the consequence in plain language — exactly what will happen. TRUST CONTRACT: the host invokes confirm ONLY on a real member click, never on your say-so; hosts SHOULD mint an unforgeable server-side confirmation token at click time and require it on the downstream action, so a confirmation can never be fabricated in text. Set danger: true for destructive styling. Rendering this card is never itself consent.\",\n inputSchema: {\n properties: {\n cancelLabel: {\n description: 'Optional dismiss label, e.g. \"Keep project\"',\n type: \"string\",\n },\n cardId: CARD_ID_SCHEMA,\n confirm: {\n ...ACTION_BINDING_SCHEMA,\n description:\n \"The action to run ONLY when the member clicks confirm (fully-resolved input, real ids)\",\n },\n confirmLabel: {\n description: 'The confirm button label, e.g. \"Delete project\"',\n type: \"string\",\n },\n consequence: {\n description:\n \"What will happen if confirmed, in plain language (max 500 chars)\",\n type: \"string\",\n },\n danger: {\n description: \"Render destructive (red) styling\",\n type: \"boolean\",\n },\n title: { description: \"Short question being confirmed\", type: \"string\" },\n },\n required: [\"title\", \"consequence\", \"confirmLabel\", \"confirm\"],\n type: \"object\",\n },\n name: \"render_confirm\",\n parse: parseConfirmSpec,\n};\n\n/** render_diff — proposed file changes for review before applying. */\nexport const diffCard: UiCardDefinition<DiffSpec> = {\n ack: \"(diff card rendered inline — the member reviews the changes and clicks apply or reject. Do not restate the diff in text and do not assume it was applied; wait for their decision)\",\n description:\n \"Render proposed file changes as reviewable unified diffs before applying them (max 6 files and 400 diff lines total — oversized diffs are truncated for display with truncated: true, never rejected). The diffs are DISPLAY data: the host renders the +/- coloring and nothing executes from the text. Bind apply (and optionally reject) to YOUR tools with fully-resolved input; hosts SHOULD route apply through a click-minted server-side token exactly like a confirmation card, because applying changes is destructive.\",\n inputSchema: {\n properties: {\n apply: {\n ...ACTION_BINDING_SCHEMA,\n description:\n \"The action that applies the changes when the member clicks it\",\n },\n cardId: CARD_ID_SCHEMA,\n files: {\n description: \"The changed files (max 6, 400 diff lines total)\",\n items: {\n properties: {\n diff: {\n description: \"Unified diff text for this file (display only)\",\n type: \"string\",\n },\n path: { description: \"File path being changed\", type: \"string\" },\n truncated: {\n description: \"Set true if you already cut the diff for size\",\n type: \"boolean\",\n },\n },\n required: [\"path\", \"diff\"],\n type: \"object\",\n },\n type: \"array\",\n },\n note: {\n description: \"Optional one-line note under the diffs\",\n type: \"string\",\n },\n reject: {\n ...ACTION_BINDING_SCHEMA,\n description: \"Optional action to run when the member rejects\",\n },\n title: { description: \"What the change set does\", type: \"string\" },\n },\n required: [\"title\", \"files\", \"apply\"],\n type: \"object\",\n },\n name: \"render_diff\",\n parse: parseDiffSpec,\n};\n\n/** render_plan — a live multi-step plan, updated in place via cardId. */\nexport const planCard: UiCardDefinition<PlanSpec> = {\n ack: \"(plan rendered inline — as you work, re-emit render_plan with the SAME cardId and updated step statuses instead of narrating progress; do not restate the steps as text)\",\n description:\n \"Render a live multi-step plan card (max 12 steps) when you start multi-step work. Display-only — it has no buttons. Set a cardId and give every step a stable id, then as you progress RE-EMIT this card with the SAME cardId and updated step statuses (pending / active / done / error): the host replaces the earlier render in place, so the member sees one live plan instead of a stack of copies.\",\n inputSchema: {\n properties: {\n cardId: CARD_ID_SCHEMA,\n note: {\n description: \"Optional one-line note under the steps\",\n type: \"string\",\n },\n steps: {\n description: \"The plan steps in order (max 12)\",\n items: {\n properties: {\n detail: {\n description: \"One-line progress or error note under the label\",\n type: \"string\",\n },\n id: {\n description:\n \"Stable step id — keep it identical across re-emits (letters/digits/_/-)\",\n type: \"string\",\n },\n label: { description: \"What this step does\", type: \"string\" },\n status: { enum: [...PLAN_STEP_STATUSES], type: \"string\" },\n },\n required: [\"id\", \"label\", \"status\"],\n type: \"object\",\n },\n type: \"array\",\n },\n title: { description: \"What the plan accomplishes\", type: \"string\" },\n },\n required: [\"title\", \"steps\"],\n type: \"object\",\n },\n name: \"render_plan\",\n parse: parsePlanSpec,\n};\n\n/** request_credentials — ask for env values WITHOUT a through-loop submit. */\nexport const credentialCard: UiCardDefinition<CredentialSpec> = {\n ack: \"(credential request rendered inline — the member enters the values in the host UI and they are stored outside this conversation; you will receive a message naming which keys were set, never the values. Do not ask for the values in text)\",\n description:\n \"Render a credential-request card when setup needs environment values from the member (API keys, secrets, connection strings) — max 8 keys, each an ENV_STYLE name with an optional label and docs link. This card deliberately has NO submit binding and collects NOTHING through you: the host UI gathers the values and stores them outside the model loop (its own .env or secret store), then sends a continuation message naming WHICH keys were set — never the values. Never ask for secret values in plain text, and never attach values to this card (any value-like field is dropped).\",\n inputSchema: {\n properties: {\n cardId: CARD_ID_SCHEMA,\n keys: {\n description: \"The environment keys to request (max 8)\",\n items: {\n properties: {\n docsUrl: {\n description:\n \"Where to obtain the credential (provider dashboard URL)\",\n type: \"string\",\n },\n isSet: {\n description:\n \"Already configured on the host — rendered as set, with a replace affordance\",\n type: \"boolean\",\n },\n key: {\n description:\n 'Environment variable name, e.g. \"STRIPE_SECRET_KEY\"',\n type: \"string\",\n },\n label: {\n description: 'Human label, e.g. \"Stripe secret key\"',\n type: \"string\",\n },\n secret: {\n description:\n \"Mask and never echo (default true — only set false for genuinely public values)\",\n type: \"boolean\",\n },\n },\n required: [\"key\"],\n type: \"object\",\n },\n type: \"array\",\n },\n title: {\n description: 'What the credentials unlock, e.g. \"Connect Stripe\"',\n type: \"string\",\n },\n },\n required: [\"title\", \"keys\"],\n type: \"object\",\n },\n name: \"request_credentials\",\n parse: parseCredentialSpec,\n};\n\n/** The built-in catalog, ready for createUiCards. */\nexport const BUILTIN_UI_CARDS = [\n chartCard,\n tableCard,\n statTilesCard,\n formCard,\n choiceCard,\n confirmCard,\n diffCard,\n planCard,\n credentialCard,\n] as const;\n",
7
7
  "import type { ChartSpec } from \"./catalog\";\n\n/**\n * Dependency-free default chart renderer: a validated ChartSpec in, a\n * self-contained SVG string out. Pure — no DOM — so it runs server-side or in\n * any framework component (call it client-side with the viewer's mode so dark\n * themes get the dark-stepped palette, not an automatic flip).\n *\n * Design method: thin marks with rounded data-ends, 2px surface gaps between\n * adjacent fills, recessive horizontal grid, a legend for ≥2 series plus\n * direct labels, all text in text tokens (never series colors), native <title>\n * hover tooltips per mark. The default palette is the validated reference set\n * (worst adjacent CVD ΔE 24.2 light / 10.3 dark) — override `palette` with\n * your brand's VALIDATED hues, in their fixed slot order.\n */\n\nexport type UiSvgTheme = {\n /** Categorical hues in fixed slot order (series 1..n). */\n palette: string[];\n surface: string;\n textPrimary: string;\n textSecondary: string;\n grid: string;\n};\n\nexport const LIGHT_UI_THEME: UiSvgTheme = {\n grid: \"#e4e4e0\",\n palette: [\n \"#2a78d6\",\n \"#1baf7a\",\n \"#eda100\",\n \"#008300\",\n \"#4a3aa7\",\n \"#e34948\",\n \"#e87ba4\",\n \"#eb6834\",\n ],\n surface: \"#fcfcfb\",\n textPrimary: \"#0b0b0b\",\n textSecondary: \"#52514e\",\n};\n\nexport const DARK_UI_THEME: UiSvgTheme = {\n grid: \"#333331\",\n palette: [\n \"#3987e5\",\n \"#199e70\",\n \"#c98500\",\n \"#008300\",\n \"#9085e9\",\n \"#e66767\",\n \"#d55181\",\n \"#d95926\",\n ],\n surface: \"#1a1a19\",\n textPrimary: \"#ffffff\",\n textSecondary: \"#c3c2b7\",\n};\n\nexport type RenderChartSvgOptions = {\n mode?: \"light\" | \"dark\";\n /** Override any theme slot (e.g. your brand palette / chat-bubble surface). */\n theme?: Partial<UiSvgTheme>;\n width?: number;\n height?: number;\n};\n\nconst WIDTH = 640;\nconst HEIGHT = 340;\nconst MARGIN = { bottom: 42, left: 56, right: 16, top: 64 };\nconst BAR_END_RADIUS = 4;\nconst MARK_GAP = 2;\nconst LINE_WIDTH = 2;\nconst MAX_DIRECT_LABELED_SERIES = 4;\nconst TICK_TARGET = 4;\nconst FONT =\n \"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n\nconst escapeXml = (value: string) =>\n value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\");\n\nconst formatValue = (value: number, spec: ChartSpec) => {\n // Sign leads the unit (\"-$4k\", not \"$-4000\").\n const sign = value < 0 ? \"-\" : \"\";\n const abs = Math.abs(value);\n const compact =\n abs >= 1_000_000\n ? `${(abs / 1_000_000).toFixed(1).replace(/\\.0$/, \"\")}M`\n : abs >= 10_000\n ? `${(abs / 1_000).toFixed(1).replace(/\\.0$/, \"\")}k`\n : abs >= 1_000\n ? abs.toLocaleString(\"en-US\")\n : `${Number.isInteger(abs) ? abs : abs.toFixed(1)}`;\n\n return `${sign}${spec.unitPrefix ?? \"\"}${compact}${spec.unitSuffix ?? \"\"}`;\n};\n\n// \"Nice\" tick step: 1/2/5 × 10^n covering the domain in ~TICK_TARGET steps.\nconst niceTicks = (min: number, max: number) => {\n const span = max - min || 1;\n const rough = span / TICK_TARGET;\n const power = Math.pow(10, Math.floor(Math.log10(rough)));\n const candidates = [1, 2, 5, 10].map((step) => step * power);\n const step =\n candidates.find((candidate) => candidate >= rough) ??\n candidates[candidates.length - 1] ??\n rough;\n const start = Math.floor(min / step) * step;\n const ticks: number[] = [];\n for (let tick = start; tick <= max + step / 2; tick += step) {\n ticks.push(Math.abs(tick) < step / 1e6 ? 0 : tick);\n }\n\n return ticks;\n};\n\ntype Frame = {\n theme: UiSvgTheme;\n plotLeft: number;\n plotRight: number;\n plotTop: number;\n plotBottom: number;\n};\n\nconst headerSvg = (spec: ChartSpec, frame: Frame) => {\n const { theme } = frame;\n const parts = [\n `<text x=\"${frame.plotLeft}\" y=\"24\" fill=\"${theme.textPrimary}\" font-size=\"15\" font-weight=\"600\">${escapeXml(spec.title)}</text>`,\n ];\n // Legend only when identity needs it: 2+ series (a single series is named\n // by the title). Swatch + name in text ink, never colored text.\n if (spec.series.length > 1) {\n let x = frame.plotLeft;\n const swatches = spec.series.map((series, index) => {\n const color = theme.palette[index % theme.palette.length];\n const label = escapeXml(series.name);\n const item = `<rect x=\"${x}\" y=\"38\" width=\"10\" height=\"10\" rx=\"2\" fill=\"${color}\"/><text x=\"${x + 14}\" y=\"47\" fill=\"${theme.textSecondary}\" font-size=\"11\">${label}</text>`;\n x += 14 + series.name.length * 6 + 18;\n\n return item;\n });\n parts.push(...swatches);\n }\n\n return parts.join(\"\");\n};\n\nconst gridSvg = (\n ticks: number[],\n yFor: (value: number) => number,\n spec: ChartSpec,\n frame: Frame,\n) =>\n ticks\n .map((tick) => {\n const y = yFor(tick);\n const isZero = tick === 0;\n\n return `<line x1=\"${frame.plotLeft}\" y1=\"${y}\" x2=\"${frame.plotRight}\" y2=\"${y}\" stroke=\"${isZero ? frame.theme.textSecondary : frame.theme.grid}\" stroke-width=\"1\"/><text x=\"${frame.plotLeft - 8}\" y=\"${y + 3.5}\" fill=\"${frame.theme.textSecondary}\" font-size=\"10\" text-anchor=\"end\">${escapeXml(formatValue(tick, spec))}</text>`;\n })\n .join(\"\");\n\nconst xLabelsSvg = (\n spec: ChartSpec,\n xCenter: (index: number) => number,\n frame: Frame,\n) => {\n // Thin out crowded label axes instead of colliding.\n const every = Math.ceil(spec.labels.length / 12);\n\n return spec.labels\n .map((label, index) => {\n if (index % every !== 0) return \"\";\n const short = label.length > 12 ? `${label.slice(0, 11)}…` : label;\n\n return `<text x=\"${xCenter(index)}\" y=\"${frame.plotBottom + 18}\" fill=\"${frame.theme.textSecondary}\" font-size=\"10\" text-anchor=\"middle\">${escapeXml(short)}</text>`;\n })\n .join(\"\");\n};\n\n// Bar with a rounded TOP data-end anchored to the baseline (flipped when the\n// value is negative). Radius collapses on very short bars.\nconst barPath = (\n x: number,\n yValue: number,\n yBase: number,\n width: number,\n): string => {\n const up = yValue <= yBase;\n const top = Math.min(yValue, yBase);\n const bottom = Math.max(yValue, yBase);\n const radius = Math.min(BAR_END_RADIUS, width / 2, bottom - top);\n if (radius <= 0) return \"\";\n if (up) {\n return `M${x},${bottom} L${x},${top + radius} Q${x},${top} ${x + radius},${top} L${x + width - radius},${top} Q${x + width},${top} ${x + width},${top + radius} L${x + width},${bottom} Z`;\n }\n\n return `M${x},${top} L${x},${bottom - radius} Q${x},${bottom} ${x + radius},${bottom} L${x + width - radius},${bottom} Q${x + width},${bottom} ${x + width},${bottom - radius} L${x + width},${top} Z`;\n};\n\nconst valueDomain = (spec: ChartSpec) => {\n const all = spec.series.flatMap((series) => series.values);\n const min = Math.min(0, ...all);\n const max = Math.max(0, ...all);\n\n return max === min ? { max: min + 1, min } : { max, min };\n};\n\nconst cartesianSvg = (spec: ChartSpec, frame: Frame) => {\n const { theme } = frame;\n const domain = valueDomain(spec);\n const ticks = niceTicks(domain.min, domain.max);\n const lo = Math.min(domain.min, ticks[0] ?? domain.min);\n const hi = Math.max(domain.max, ticks[ticks.length - 1] ?? domain.max);\n const yFor = (value: number) =>\n frame.plotBottom -\n ((value - lo) / (hi - lo)) * (frame.plotBottom - frame.plotTop);\n const slot = (frame.plotRight - frame.plotLeft) / spec.labels.length;\n const xCenter = (index: number) => frame.plotLeft + slot * (index + 0.5);\n\n const parts: string[] = [gridSvg(ticks, yFor, spec, frame)];\n\n if (spec.type === \"bar\") {\n const group = Math.min(slot * 0.72, 64);\n const barWidth = Math.max(\n 2,\n (group - MARK_GAP * (spec.series.length - 1)) / spec.series.length,\n );\n const yBase = yFor(Math.max(lo, Math.min(hi, 0)));\n spec.series.forEach((series, seriesIndex) => {\n const color = theme.palette[seriesIndex % theme.palette.length];\n series.values.forEach((value, index) => {\n const x =\n xCenter(index) - group / 2 + seriesIndex * (barWidth + MARK_GAP);\n const tooltip = `${escapeXml(series.name)} · ${escapeXml(spec.labels[index] ?? \"\")}: ${escapeXml(formatValue(value, spec))}`;\n\n parts.push(\n `<path d=\"${barPath(x, yFor(value), yBase, barWidth)}\" fill=\"${color}\"><title>${tooltip}</title></path>`,\n );\n });\n });\n // Selective direct labels: single series with few bars gets its values.\n const [only] = spec.series;\n if (spec.series.length === 1 && only && spec.labels.length <= 8) {\n only.values.forEach((value, index) => {\n const above = value >= 0;\n parts.push(\n `<text x=\"${xCenter(index)}\" y=\"${yFor(value) + (above ? -6 : 14)}\" fill=\"${theme.textSecondary}\" font-size=\"10\" text-anchor=\"middle\">${escapeXml(formatValue(value, spec))}</text>`,\n );\n });\n }\n } else {\n spec.series.forEach((series, seriesIndex) => {\n const color = theme.palette[seriesIndex % theme.palette.length];\n const points = series.values.map(\n (value, index) => `${xCenter(index)},${yFor(value)}`,\n );\n parts.push(\n `<polyline points=\"${points.join(\" \")}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"${LINE_WIDTH}\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>`,\n );\n series.values.forEach((value, index) => {\n const tooltip = `${escapeXml(series.name)} · ${escapeXml(spec.labels[index] ?? \"\")}: ${escapeXml(formatValue(value, spec))}`;\n // ≥8px hover targets with a 2px surface ring where marks may overlap.\n parts.push(\n `<circle cx=\"${xCenter(index)}\" cy=\"${yFor(value)}\" r=\"4\" fill=\"${color}\" stroke=\"${theme.surface}\" stroke-width=\"2\"><title>${tooltip}</title></circle>`,\n );\n });\n // Direct series label at the line's end for small multiples.\n const last = series.values[series.values.length - 1];\n if (\n spec.series.length <= MAX_DIRECT_LABELED_SERIES &&\n last !== undefined\n ) {\n parts.push(\n `<text x=\"${frame.plotRight + 4}\" y=\"${yFor(last) + 3.5}\" fill=\"${theme.textSecondary}\" font-size=\"10\">${escapeXml(series.name)}</text>`,\n );\n }\n });\n }\n parts.push(xLabelsSvg(spec, xCenter, frame));\n\n return parts.join(\"\");\n};\n\nconst donutSvg = (spec: ChartSpec, frame: Frame) => {\n const { theme } = frame;\n const [series] = spec.series;\n if (!series) return \"\";\n const total = series.values.reduce((sum, value) => sum + value, 0);\n if (total <= 0) return \"\";\n const cx = (frame.plotLeft + frame.plotRight) / 2;\n const cy = (frame.plotTop + frame.plotBottom) / 2 + 4;\n const radius = Math.min(\n (frame.plotBottom - frame.plotTop) / 2 - 4,\n (frame.plotRight - frame.plotLeft) / 4,\n );\n const ring = Math.max(14, radius * 0.34);\n const mid = radius - ring / 2;\n // 2px surface gap between segments, expressed as an angle at mid-radius.\n const gapAngle = MARK_GAP / mid;\n\n const parts: string[] = [];\n let angle = -Math.PI / 2;\n series.values.forEach((value, index) => {\n const sweep = (value / total) * Math.PI * 2;\n const start = angle + gapAngle / 2;\n const end = angle + sweep - gapAngle / 2;\n angle += sweep;\n if (end <= start) return;\n const large = end - start > Math.PI ? 1 : 0;\n const x1 = cx + mid * Math.cos(start);\n const y1 = cy + mid * Math.sin(start);\n const x2 = cx + mid * Math.cos(end);\n const y2 = cy + mid * Math.sin(end);\n const color = theme.palette[index % theme.palette.length];\n const share = `${Math.round((value / total) * 100)}%`;\n const tooltip = `${escapeXml(spec.labels[index] ?? \"\")}: ${escapeXml(formatValue(value, spec))} (${share})`;\n parts.push(\n `<path d=\"M${x1},${y1} A${mid},${mid} 0 ${large} 1 ${x2},${y2}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"${ring}\"><title>${tooltip}</title></path>`,\n );\n });\n parts.push(\n `<text x=\"${cx}\" y=\"${cy + 5}\" fill=\"${theme.textPrimary}\" font-size=\"16\" font-weight=\"600\" text-anchor=\"middle\">${escapeXml(formatValue(total, spec))}</text>`,\n );\n // Slice identity lives in the legend row for donuts.\n let x = frame.plotLeft;\n spec.labels.forEach((label, index) => {\n const color = theme.palette[index % theme.palette.length];\n parts.push(\n `<rect x=\"${x}\" y=\"38\" width=\"10\" height=\"10\" rx=\"2\" fill=\"${color}\"/><text x=\"${x + 14}\" y=\"47\" fill=\"${theme.textSecondary}\" font-size=\"11\">${escapeXml(label)}</text>`,\n );\n x += 14 + label.length * 6 + 18;\n });\n\n return parts.join(\"\");\n};\n\n/** Render a validated ChartSpec to a self-contained SVG string. */\nexport const renderChartSvg = (\n spec: ChartSpec,\n options: RenderChartSvgOptions = {},\n) => {\n const base = options.mode === \"dark\" ? DARK_UI_THEME : LIGHT_UI_THEME;\n const theme: UiSvgTheme = { ...base, ...options.theme };\n const width = options.width ?? WIDTH;\n const height = options.height ?? HEIGHT;\n const frame: Frame = {\n plotBottom: height - MARGIN.bottom,\n plotLeft: MARGIN.left,\n plotRight:\n width -\n MARGIN.right -\n // Room for end-of-line direct labels.\n (spec.type === \"line\" ? 64 : 0),\n plotTop: MARGIN.top,\n theme,\n };\n\n const body =\n spec.type === \"donut\" ? donutSvg(spec, frame) : cartesianSvg(spec, frame);\n\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" role=\"img\" aria-label=\"${escapeXml(spec.title)}\" font-family=\"${FONT}\"><rect width=\"${width}\" height=\"${height}\" fill=\"${theme.surface}\" rx=\"12\"/>${spec.type === \"donut\" ? headerSvg({ ...spec, series: [] }, frame) : headerSvg(spec, frame)}${body}</svg>`;\n};\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,IAAM,gBAAgB,CAC3B,gBACY;AAAA,EACZ,MAAM,SAAS,IAAI,IACjB,YAAY,IAAI,CAAC,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CAC/D;AAAA,EAEA,MAAM,QAAmB,OAAO,YAC9B,YAAY,IAAI,CAAC,eAAe;AAAA,IAC9B,WAAW;AAAA,IACX;AAAA,MACE,aAAa,WAAW;AAAA,MACxB,SAAS,MAAM,WAAW;AAAA,MAC1B,OAAO,WAAW;AAAA,IACpB;AAAA,EACF,CAAC,CACH;AAAA,EAEA,MAAM,UAAU,CAAC,UAAuD;AAAA,IACtE,MAAM,SAAwB,CAAC;AAAA,IAC/B,WAAW,QAAQ,OAAO;AAAA,MACxB,MAAM,aAAa,OAAO,IAAI,KAAK,IAAI;AAAA,MACvC,IAAI,CAAC;AAAA,QAAY;AAAA,MACjB,MAAM,OAAO,WAAW,MAAM,KAAK,KAAK;AAAA,MACxC,IAAI,SAAS;AAAA,QAAM,OAAO,KAAK,EAAE,MAAM,WAAW,MAAM,KAAK,CAAC;AAAA,IAChE;AAAA,IAEA,OAAO;AAAA;AAAA,EAGT,OAAO,EAAE,SAAS,KAAK,CAAC,SAAiB,OAAO,IAAI,IAAI,GAAG,MAAM;AAAA;;ACrE5D,IAAM,cAAc,CAAC,OAAO,QAAQ,OAAO;AAsD3C,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAqCO,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAA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QAAQ,SAAS;AAAA,EAC/B,MAAM,SAAS,QAAQ,UAAU;AAAA,EACjC,MAAM,QAAe;AAAA,IACnB,YAAY,SAAS,OAAO;AAAA,IAC5B,UAAU,OAAO;AAAA,IACjB,WACE,QACA,OAAO,SAEN,KAAK,SAAS,SAAS,KAAK;AAAA,IAC/B,SAAS,OAAO;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,MAAM,OACJ,KAAK,SAAS,UAAU,SAAS,MAAM,KAAK,IAAI,aAAa,MAAM,KAAK;AAAA,EAE1E,OAAO,wDAAwD,SAAS,kCAAkC,UAAU,KAAK,KAAK,mBAAmB,sBAAsB,kBAAkB,iBAAiB,MAAM,qBAAqB,KAAK,SAAS,UAAU,UAAU,KAAK,MAAM,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,UAAU,MAAM,KAAK,IAAI;AAAA;",
10
+ "debugId": "59E12D813D37D12064756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -2,6 +2,8 @@ export { aiChat } from "../plugins/aiChat";
2
2
  export { streamAI } from "./streamAI";
3
3
  export { streamAIToSSE } from "./streamAIToSSE";
4
4
  export { streamAIWithTools } from "./streamAIWithTools";
5
+ export { createProviderProxyResponse, parseProviderProxyParams, remoteProvider, } from "./providerProxy";
6
+ export type { ProviderProxyResponseOptions, ProviderProxyStreamParams, RemoteProviderConfig, } from "./providerProxy";
5
7
  export type { StreamAIWithToolsEvent, StreamAIWithToolsOptions, StreamAIWithToolsSummary, } from "./streamAIWithTools";
6
8
  export * from "./ui";
7
9
  export { generateAI, generateAIWithTools, generateObjectAI, } from "./generateAI";
@@ -0,0 +1,16 @@
1
+ import type { AIProviderConfig, AIProviderStreamParams } from "../../types/ai";
2
+ export type ProviderProxyStreamParams = Omit<AIProviderStreamParams, "onSpan" | "onUsage" | "signal">;
3
+ export type RemoteProviderConfig = {
4
+ fetch?: typeof fetch;
5
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
6
+ url: string;
7
+ };
8
+ export type ProviderProxyResponseOptions = {
9
+ headers?: HeadersInit;
10
+ heartbeatMs?: number;
11
+ onError?: (error: unknown) => void | Promise<void>;
12
+ signal?: AbortSignal;
13
+ };
14
+ export declare const parseProviderProxyParams: (value: unknown) => ProviderProxyStreamParams | null;
15
+ export declare const createProviderProxyResponse: (provider: AIProviderConfig, value: unknown, options?: ProviderProxyResponseOptions) => Promise<Response>;
16
+ export declare const remoteProvider: (config: RemoteProviderConfig) => AIProviderConfig;
@@ -1,9 +1,18 @@
1
1
  import type { UiCardDefinition } from "./uiCards";
2
2
  /**
3
- * Built-in UI card catalog: chart, table, stat tiles. Declarative specs the
4
- * model authors and the host renders see svg.ts for the dependency-free
5
- * default renderer. Caps are hard product guards (a model can't render a
3
+ * Built-in UI card catalog: chart, table, stat tiles, form, choice, confirm,
4
+ * diff, plan, and credential-request cards. Declarative specs the model
5
+ * authors and the host renders see svg.ts for the dependency-free default
6
+ * chart renderer. Caps are hard product guards (a model can't render a
6
7
  * 400-row table into a chat bubble).
8
+ *
9
+ * Card identity: every spec carries an optional `cardId`. When a host
10
+ * receives a card whose cardId it has already rendered in the conversation,
11
+ * it MUST replace that earlier render in place instead of appending a new
12
+ * card. This is a pure host rendering contract — no loop-side state — and it
13
+ * is how planCard progresses: the model re-emits the same cardId with
14
+ * updated step statuses. The field lives here, in the shared spec layer, so
15
+ * every host implements the same semantics.
7
16
  */
8
17
  export declare const CHART_TYPES: readonly ["bar", "line", "donut"];
9
18
  export type ChartType = (typeof CHART_TYPES)[number];
@@ -23,6 +32,8 @@ export type ChartSpec = {
23
32
  unitSuffix?: string;
24
33
  /** Optional action buttons rendered under the card (≤ 3). */
25
34
  actions?: UiAction[];
35
+ /** Stable card identity — see the card-identity contract in module docs. */
36
+ cardId?: string;
26
37
  };
27
38
  export type TableSpec = {
28
39
  title?: string;
@@ -30,6 +41,8 @@ export type TableSpec = {
30
41
  rows: string[][];
31
42
  /** Optional action buttons rendered under the card (≤ 3). */
32
43
  actions?: UiAction[];
44
+ /** Stable card identity — see the card-identity contract in module docs. */
45
+ cardId?: string;
33
46
  };
34
47
  export type StatTile = {
35
48
  label: string;
@@ -41,6 +54,8 @@ export type StatTile = {
41
54
  export type StatTilesSpec = {
42
55
  tiles: StatTile[];
43
56
  actions?: UiAction[];
57
+ /** Stable card identity — see the card-identity contract in module docs. */
58
+ cardId?: string;
44
59
  };
45
60
  /**
46
61
  * An action binding on a UI card: a button the host renders under the card
@@ -90,6 +105,138 @@ export type FormSpec = {
90
105
  description?: string;
91
106
  fields: FormField[];
92
107
  submit: UiAction;
108
+ /** Stable card identity — see the card-identity contract in module docs. */
109
+ cardId?: string;
110
+ };
111
+ export type ChoiceOption = {
112
+ /** Stable option id — merged into submit.input on selection. */
113
+ id: string;
114
+ label: string;
115
+ description?: string;
116
+ /** Tiny annotation rendered beside the label, e.g. "recommended". */
117
+ badge?: string;
118
+ };
119
+ /**
120
+ * A structured decision card: the member picks one option (or several when
121
+ * `multi`) and the host merges `{ choice: id }` — or `{ choices: id[] }` —
122
+ * into `submit.input`, then invokes `submit.tool` exactly like a clicked
123
+ * UiAction. Same through-loop flow as FormSpec: a choice between
124
+ * model-authored options is non-secret by definition, so loop-visible
125
+ * submission is correct here.
126
+ */
127
+ export type ChoiceSpec = {
128
+ title: string;
129
+ description?: string;
130
+ /** ≤ 8 options. */
131
+ options: ChoiceOption[];
132
+ /** Allow selecting several options (`{ choices: id[] }` on submit). */
133
+ multi?: boolean;
134
+ submit: UiAction;
135
+ /** Stable card identity — see the card-identity contract in module docs. */
136
+ cardId?: string;
137
+ };
138
+ /**
139
+ * An explicit-consent card for destructive or irreversible actions.
140
+ *
141
+ * TRUST CONTRACT: the host must invoke `confirm` ONLY on a real user click
142
+ * of the confirm button — never programmatically, and never because the
143
+ * model claims consent was given. Hosts SHOULD mint an unforgeable
144
+ * server-side confirmation token at click time and require it on the
145
+ * downstream action, so a model can never fabricate a confirmation: the
146
+ * token exists only if the click happened.
147
+ */
148
+ export type ConfirmSpec = {
149
+ title: string;
150
+ /** What will happen, in plain language (≤ 500 chars). */
151
+ consequence: string;
152
+ confirmLabel: string;
153
+ cancelLabel?: string;
154
+ confirm: UiAction;
155
+ /** Render destructive styling (e.g. a red confirm button). */
156
+ danger?: boolean;
157
+ /** Stable card identity — see the card-identity contract in module docs. */
158
+ cardId?: string;
159
+ };
160
+ export type DiffFile = {
161
+ path: string;
162
+ /** Unified diff text — DISPLAY data only (the host renders the +/-
163
+ * coloring); nothing is ever executed or applied from the text itself. */
164
+ diff: string;
165
+ /** The shown diff was cut to fit the display caps. */
166
+ truncated?: boolean;
167
+ };
168
+ /**
169
+ * Proposed file changes for review. Diffs are display data; the actual
170
+ * change happens through `apply` — a normal UiAction against a host tool
171
+ * with fully-resolved input. Applying files is destructive, so hosts SHOULD
172
+ * route `apply` through a click-minted server-side token exactly like
173
+ * ConfirmSpec. Oversized diffs are truncated by the parser, never rejected:
174
+ * files beyond 6 drop, and diff bodies are cut to a 400-line total budget
175
+ * with `truncated: true` set on every file that was cut.
176
+ */
177
+ export type DiffSpec = {
178
+ title: string;
179
+ /** ≤ 6 files, ≤ 400 diff lines total across them. */
180
+ files: DiffFile[];
181
+ apply: UiAction;
182
+ reject?: UiAction;
183
+ note?: string;
184
+ /** Stable card identity — see the card-identity contract in module docs. */
185
+ cardId?: string;
186
+ };
187
+ export declare const PLAN_STEP_STATUSES: readonly ["pending", "active", "done", "error"];
188
+ export type PlanStepStatus = (typeof PLAN_STEP_STATUSES)[number];
189
+ export type PlanStep = {
190
+ /** Stable step id — keep it identical across re-emits of the same plan. */
191
+ id: string;
192
+ label: string;
193
+ status: PlanStepStatus;
194
+ /** One-line progress or error note under the label. */
195
+ detail?: string;
196
+ };
197
+ /**
198
+ * A live multi-step plan. Display-only — no submit action. Progress works
199
+ * through the card-identity contract: the model re-emits the SAME cardId
200
+ * with updated step statuses and the host replaces the earlier render in
201
+ * place, so the member sees one live plan instead of a stack of copies.
202
+ */
203
+ export type PlanSpec = {
204
+ title: string;
205
+ /** ≤ 12 steps. */
206
+ steps: PlanStep[];
207
+ note?: string;
208
+ /** Stable card identity — see the card-identity contract in module docs. */
209
+ cardId?: string;
210
+ };
211
+ export type CredentialKey = {
212
+ /** Environment variable name, e.g. "STRIPE_SECRET_KEY". */
213
+ key: string;
214
+ /** Human label, e.g. "Stripe secret key". */
215
+ label?: string;
216
+ /** Where to obtain the credential (provider dashboard URL). */
217
+ docsUrl?: string;
218
+ /** Mask and never echo. Defaults to TRUE — parseCredentialSpec normalizes
219
+ * it to an explicit boolean so hosts never have to guess. */
220
+ secret?: boolean;
221
+ /** Already configured on the host — render as set, offer replace. */
222
+ isSet?: boolean;
223
+ };
224
+ /**
225
+ * A credential-request card. Deliberately has NO submit UiAction — the type
226
+ * makes through-loop submission impossible. The host UI collects the values
227
+ * and stores them OUTSIDE the model loop (its own .env or secret store),
228
+ * then sends a names-only continuation message ("STRIPE_SECRET_KEY was
229
+ * set") so the model can proceed. Values never enter the transcript in
230
+ * either direction: parseCredentialSpec drops any value-like field a model
231
+ * attaches (the password-prefill-drop precedent), and hosts never echo
232
+ * stored values back.
233
+ */
234
+ export type CredentialSpec = {
235
+ title: string;
236
+ /** ≤ 8 keys. */
237
+ keys: CredentialKey[];
238
+ /** Stable card identity — see the card-identity contract in module docs. */
239
+ cardId?: string;
93
240
  };
94
241
  export declare const CHART_MAX_SERIES = 8;
95
242
  export declare const CHART_MAX_POINTS = 24;
@@ -99,6 +246,13 @@ export declare const STAT_TILES_MAX = 6;
99
246
  export declare const UI_ACTIONS_MAX = 3;
100
247
  export declare const FORM_MAX_FIELDS = 8;
101
248
  export declare const FORM_SELECT_MAX_OPTIONS = 12;
249
+ export declare const CHOICE_MAX_OPTIONS = 8;
250
+ export declare const CONFIRM_CONSEQUENCE_MAX_CHARS = 500;
251
+ export declare const DIFF_MAX_FILES = 6;
252
+ export declare const DIFF_MAX_LINES = 400;
253
+ export declare const PLAN_MAX_STEPS = 12;
254
+ export declare const CREDENTIAL_MAX_KEYS = 8;
255
+ export declare const CARD_ID_MAX_CHARS = 64;
102
256
  /** Validate a spec's optional action bindings; undefined when none/invalid.
103
257
  * Malformed entries drop individually — a bad button never sinks the card. */
104
258
  export declare const parseUiActions: (value: unknown) => UiAction[] | undefined;
@@ -106,6 +260,11 @@ export declare const parseChartSpec: (input: unknown) => ChartSpec | null;
106
260
  export declare const parseTableSpec: (input: unknown) => TableSpec | null;
107
261
  export declare const parseStatTilesSpec: (input: unknown) => StatTilesSpec | null;
108
262
  export declare const parseFormSpec: (input: unknown) => FormSpec | null;
263
+ export declare const parseChoiceSpec: (input: unknown) => ChoiceSpec | null;
264
+ export declare const parseConfirmSpec: (input: unknown) => ConfirmSpec | null;
265
+ export declare const parseDiffSpec: (input: unknown) => DiffSpec | null;
266
+ export declare const parsePlanSpec: (input: unknown) => PlanSpec | null;
267
+ export declare const parseCredentialSpec: (input: unknown) => CredentialSpec | null;
109
268
  /** render_chart — bar / line / donut from data you already have. */
110
269
  export declare const chartCard: UiCardDefinition<ChartSpec>;
111
270
  /** render_table — a compact data table. */
@@ -114,5 +273,15 @@ export declare const tableCard: UiCardDefinition<TableSpec>;
114
273
  export declare const statTilesCard: UiCardDefinition<StatTilesSpec>;
115
274
  /** render_form — collect structured inputs, then run a bound tool on submit. */
116
275
  export declare const formCard: UiCardDefinition<FormSpec>;
276
+ /** render_choice — a structured decision instead of "reply 1 or 2". */
277
+ export declare const choiceCard: UiCardDefinition<ChoiceSpec>;
278
+ /** render_confirm — explicit consent for destructive/irreversible actions. */
279
+ export declare const confirmCard: UiCardDefinition<ConfirmSpec>;
280
+ /** render_diff — proposed file changes for review before applying. */
281
+ export declare const diffCard: UiCardDefinition<DiffSpec>;
282
+ /** render_plan — a live multi-step plan, updated in place via cardId. */
283
+ export declare const planCard: UiCardDefinition<PlanSpec>;
284
+ /** request_credentials — ask for env values WITHOUT a through-loop submit. */
285
+ export declare const credentialCard: UiCardDefinition<CredentialSpec>;
117
286
  /** The built-in catalog, ready for createUiCards. */
118
- export declare const BUILTIN_UI_CARDS: readonly [UiCardDefinition<ChartSpec>, UiCardDefinition<TableSpec>, UiCardDefinition<StatTilesSpec>, UiCardDefinition<FormSpec>];
287
+ export declare const BUILTIN_UI_CARDS: readonly [UiCardDefinition<ChartSpec>, UiCardDefinition<TableSpec>, UiCardDefinition<StatTilesSpec>, UiCardDefinition<FormSpec>, UiCardDefinition<ChoiceSpec>, UiCardDefinition<ConfirmSpec>, UiCardDefinition<DiffSpec>, UiCardDefinition<PlanSpec>, UiCardDefinition<CredentialSpec>];
@@ -4,10 +4,13 @@
4
4
  * A UI card is a schema-only tool: the model calls it with a structured spec,
5
5
  * the loop feeds back a steering ack, and the HOST renders the validated spec
6
6
  * with real components. {@link createUiCards} builds the tool map + collector
7
- * for any card set; {@link BUILTIN_UI_CARDS} ships chart / table / stat-tile
8
- * cards with hard caps, and {@link renderChartSvg} is a dependency-free
9
- * default chart renderer (pure string server or client, light/dark).
7
+ * for any card set; {@link BUILTIN_UI_CARDS} ships chart / table / stat-tile /
8
+ * form / choice / confirm / diff / plan / credential-request cards with hard
9
+ * caps, and {@link renderChartSvg} is a dependency-free default chart renderer
10
+ * (pure string — server or client, light/dark). Every spec carries an optional
11
+ * `cardId`: re-emitting a card with the same cardId tells the host to replace
12
+ * the earlier render in place (how planCard progresses).
10
13
  */
11
14
  export { createUiCards, type UiCardDefinition, type UiCardEvent, type UiCards, } from "./uiCards";
12
- export { BUILTIN_UI_CARDS, chartCard, CHART_MAX_POINTS, CHART_MAX_SERIES, CHART_TYPES, FORM_FIELD_TYPES, FORM_MAX_FIELDS, FORM_SELECT_MAX_OPTIONS, formCard, parseChartSpec, parseFormSpec, parseStatTilesSpec, parseTableSpec, parseUiActions, STAT_TILES_MAX, statTilesCard, TABLE_MAX_COLUMNS, TABLE_MAX_ROWS, tableCard, UI_ACTIONS_MAX, type ChartSeries, type ChartSpec, type ChartType, type FormField, type FormFieldType, type FormSpec, type StatTile, type StatTilesSpec, type TableSpec, type UiAction, } from "./catalog";
15
+ export { BUILTIN_UI_CARDS, CARD_ID_MAX_CHARS, chartCard, CHART_MAX_POINTS, CHART_MAX_SERIES, CHART_TYPES, CHOICE_MAX_OPTIONS, choiceCard, CONFIRM_CONSEQUENCE_MAX_CHARS, confirmCard, CREDENTIAL_MAX_KEYS, credentialCard, DIFF_MAX_FILES, DIFF_MAX_LINES, diffCard, FORM_FIELD_TYPES, FORM_MAX_FIELDS, FORM_SELECT_MAX_OPTIONS, formCard, parseChartSpec, parseChoiceSpec, parseConfirmSpec, parseCredentialSpec, parseDiffSpec, parseFormSpec, parsePlanSpec, parseStatTilesSpec, parseTableSpec, parseUiActions, PLAN_MAX_STEPS, PLAN_STEP_STATUSES, planCard, STAT_TILES_MAX, statTilesCard, TABLE_MAX_COLUMNS, TABLE_MAX_ROWS, tableCard, UI_ACTIONS_MAX, type ChartSeries, type ChartSpec, type ChartType, type ChoiceOption, type ChoiceSpec, type ConfirmSpec, type CredentialKey, type CredentialSpec, type DiffFile, type DiffSpec, type FormField, type FormFieldType, type FormSpec, type PlanSpec, type PlanStep, type PlanStepStatus, type StatTile, type StatTilesSpec, type TableSpec, type UiAction, } from "./catalog";
13
16
  export { DARK_UI_THEME, LIGHT_UI_THEME, renderChartSvg, type RenderChartSvgOptions, type UiSvgTheme, } from "./svg";
@@ -1,6 +1,8 @@
1
1
  export type AnthropicConfig = {
2
2
  apiKey: string;
3
3
  baseUrl?: string;
4
+ /** Injectable transport for policy, tracing, testing, and private egress. */
5
+ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
4
6
  maxTokens?: number;
5
7
  /**
6
8
  * Enable Anthropic prompt caching breakpoints (tools + system + rolling