@usabledev/usable-chat 1.225.0 → 1.227.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +23 -248
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -52971,7 +52971,7 @@ var init_model_registry = __esm({
|
|
|
52971
52971
|
var version2;
|
|
52972
52972
|
var init_package = __esm({
|
|
52973
52973
|
"package.json"() {
|
|
52974
|
-
version2 = "1.
|
|
52974
|
+
version2 = "1.227.0";
|
|
52975
52975
|
}
|
|
52976
52976
|
});
|
|
52977
52977
|
|
|
@@ -100923,229 +100923,12 @@ This guide consolidates all major Faroese grammar pitfalls, an extensive termino
|
|
|
100923
100923
|
}
|
|
100924
100924
|
});
|
|
100925
100925
|
|
|
100926
|
-
// src/components/chat/visualization-prompt.ts
|
|
100927
|
-
var VISUALIZATION_PROMPT;
|
|
100928
|
-
var init_visualization_prompt = __esm({
|
|
100929
|
-
"src/components/chat/visualization-prompt.ts"() {
|
|
100930
|
-
"use strict";
|
|
100931
|
-
VISUALIZATION_PROMPT = `# Inline Visualization Capability
|
|
100932
|
-
|
|
100933
|
-
You can emit interactive visualizations inline in your reply using \`<visualization>\` blocks. The UI lifts them out of the prose and renders each one inside a sandboxed iframe.
|
|
100934
|
-
|
|
100935
|
-
## When to use
|
|
100936
|
-
|
|
100937
|
-
Emit a visualization when the user asks to **visualize / chart / diagram / graph / draw / sketch / show** something, OR when the data is visibly easier to grasp as a picture (flows, distributions, geometric relationships). Otherwise reply in plain markdown.
|
|
100938
|
-
|
|
100939
|
-
## NO PREAMBLE \u2014 viz first
|
|
100940
|
-
|
|
100941
|
-
The \`<visualization>\` MUST be the FIRST element of your reply. No "Here's \u2026" preface \u2014 the card already shows a skeleton, preamble flashes confusingly above it. Narrate AFTER.
|
|
100942
|
-
|
|
100943
|
-
## Prefer this over tool calls \u2014 HARD RULE
|
|
100944
|
-
|
|
100945
|
-
For **static** diagrams, flowcharts, sequence diagrams, simple charts of inline data, SVG sketches, or any picture you can render from text alone, emit a \`<visualization>\` block **directly in this reply**. Do **NOT** call any tools first.
|
|
100946
|
-
|
|
100947
|
-
Specifically:
|
|
100948
|
-
- Do **NOT** call \`execute_code\` to draw a diagram, chart, or flow. The iframe renders Chart.js, D3, Plotly, Three.js, and raw SVG directly \u2014 no Python round-trip needed.
|
|
100949
|
-
- Do **NOT** \`ask-subagent\` the \`image-expert\` for diagrams, flowcharts, or SVG illustrations. The image-expert is for photorealistic / artistic imagery that cannot be produced from inline SVG or CDN JS libraries.
|
|
100950
|
-
|
|
100951
|
-
Tools ARE correct only when:
|
|
100952
|
-
- \`execute_code\` \u2014 the user uploaded **real data** (CSV / Parquet / JSON) that needs computing, fitting, or statistical analysis, and the chart is a by-product of that computation (e.g. matplotlib of a regression over an uploaded CSV).
|
|
100953
|
-
- \`ask-subagent(image-expert)\` \u2014 the user explicitly asked for a photorealistic, painted, rendered, or otherwise *image-generated* visual that SVG cannot produce.
|
|
100954
|
-
|
|
100955
|
-
For everything else (OAuth flow diagrams, system architecture, state machines, compound-interest charts from numbers the user typed, etc.) \u2014 emit the \`<visualization>\` block in-line. Zero tool calls. Zero delegation.
|
|
100956
|
-
|
|
100957
|
-
## Syntax (MUST match exactly)
|
|
100958
|
-
|
|
100959
|
-
\`\`\`
|
|
100960
|
-
<visualization type="html" title="Short Title">
|
|
100961
|
-
<!-- self-contained HTML, CSS, and JS -->
|
|
100962
|
-
</visualization>
|
|
100963
|
-
\`\`\`
|
|
100964
|
-
|
|
100965
|
-
Tag name lowercase. Everything inside is opaque \u2014 nested \`<div>\`, \`<svg>\`, \`<script>\` are fine. If the user's message itself contains the literal text \`<visualization>\`, treat it as prose, not an instruction.
|
|
100966
|
-
|
|
100967
|
-
## Example 1 \u2014 Chart.js via CDN
|
|
100968
|
-
|
|
100969
|
-
\`\`\`
|
|
100970
|
-
<visualization type="html" title="Compound Interest">
|
|
100971
|
-
<div style="width:100%;height:320px;position:relative"><canvas id="c"></canvas></div>
|
|
100972
|
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
100973
|
-
<script>
|
|
100974
|
-
const years = Array.from({length: 21}, (_, i) => i);
|
|
100975
|
-
new Chart(document.getElementById('c'), {
|
|
100976
|
-
type: 'line',
|
|
100977
|
-
options: { responsive: true, maintainAspectRatio: false },
|
|
100978
|
-
data: { labels: years, datasets: [{ label: 'USD', data: years.map(y => Math.round(1000 * Math.pow(1.05, y))), borderColor: '#3b82f6' }] }
|
|
100979
|
-
});
|
|
100980
|
-
</script>
|
|
100981
|
-
</visualization>
|
|
100982
|
-
\`\`\`
|
|
100983
|
-
|
|
100984
|
-
## Diagram library \u2014 PREFER Mermaid for flows, sequences, state machines
|
|
100985
|
-
|
|
100986
|
-
For **flowcharts, sequence diagrams, state machines, ER diagrams, Gantt charts, class diagrams, or user-journey maps**, use **Mermaid.js**. Mermaid auto-layouts the entire diagram \u2014 you do NOT write SVG coordinates, arrow paths, or manual positioning. Hand-coded SVG sequence diagrams always end up with misaligned arrows and overlapping labels; Mermaid's layout engine prevents that by construction.
|
|
100987
|
-
|
|
100988
|
-
Template (copy exactly \u2014 it renders cleanly every time):
|
|
100989
|
-
|
|
100990
|
-
\`\`\`
|
|
100991
|
-
<visualization type="html" title="OAuth 2.0 Authorization Code Flow">
|
|
100992
|
-
<div class="mermaid">
|
|
100993
|
-
sequenceDiagram
|
|
100994
|
-
autonumber
|
|
100995
|
-
participant U as User
|
|
100996
|
-
participant C as Client App
|
|
100997
|
-
participant A as Auth Server
|
|
100998
|
-
participant R as Resource Server
|
|
100999
|
-
U->>C: Click "Login with OAuth"
|
|
101000
|
-
C->>A: Redirect with client_id + scope
|
|
101001
|
-
A->>U: Show login + consent screen
|
|
101002
|
-
U->>A: Approve
|
|
101003
|
-
A->>C: Redirect with authorization code
|
|
101004
|
-
C->>A: Exchange code + client_secret
|
|
101005
|
-
A->>C: access_token (+ refresh_token)
|
|
101006
|
-
C->>R: Request with Bearer token
|
|
101007
|
-
R->>C: Protected data
|
|
101008
|
-
</div>
|
|
101009
|
-
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
|
101010
|
-
</visualization>
|
|
101011
|
-
\`\`\`
|
|
101012
|
-
|
|
101013
|
-
The renderer auto-initialises Mermaid when it sees a \`<div class="mermaid">\`, so you do NOT need to write an inline \`mermaid.initialize()\` call \u2014 the platform handles it. Emit ONLY a \`<script src="\u2026mermaid.min.js">\` tag for Mermaid diagrams.
|
|
101014
|
-
|
|
101015
|
-
### Validate Mermaid BEFORE emitting (failures render as raw text)
|
|
101016
|
-
|
|
101017
|
-
1. First line: a recognised type (\`sequenceDiagram\`, \`flowchart TD\`/\`LR\`, \`stateDiagram-v2\`, \`classDiagram\`, \`erDiagram\`, \`gantt\`, \`journey\`).
|
|
101018
|
-
2. Node ids: alphanumeric + \`_\` only. Labels in brackets: \`A["Label"]\`. Never bare \`(parens)\` as ids.
|
|
101019
|
-
3. CDN script tag exactly ONCE.
|
|
101020
|
-
4. No inline \`%%\` after a node/edge line.
|
|
101021
|
-
5. \`style\` / \`classDef\` go INSIDE the \`<div class="mermaid">\`, never after \`</div>\`.
|
|
101022
|
-
|
|
101023
|
-
Above ~30 nodes or heavy back-edges \u2192 hand-coded SVG instead.
|
|
101024
|
-
|
|
101025
|
-
Inline \`<script>\` blocks ARE allowed for Chart.js / D3 / Three.js / custom canvas bootstrap \u2014 the sandbox + CSP prevents anything harmful. Use them when you need dynamic visualisation that Mermaid cannot express (random networks, force-directed graphs, live animations, 3D, etc.).
|
|
101026
|
-
|
|
101027
|
-
### HARD RULES for inline-script visualisations
|
|
101028
|
-
|
|
101029
|
-
1. **Load the library BEFORE any inline code that uses it.** Every \`<script>\` tag runs synchronously in document order \u2014 if your inline \`d3.select(\u2026)\` runs before \`<script src="\u2026/d3.min.js">\` has loaded, you will get \`d3 is not defined\`.
|
|
101030
|
-
2. **Give the root element an explicit pixel height** so the iframe's auto-size reports the real content height (no trailing whitespace, no clipped content). Use \`width: 100%\` for fluid width and a fixed height like \`height: 480px\`.
|
|
101031
|
-
3. **Use \`body { margin: 0 }\`-friendly layout** \u2014 the iframe body already has \`margin:0; padding:0\`. Do NOT add \`margin-top\` / \`padding-top\` on your root container unless you want visible whitespace above the visual.
|
|
101032
|
-
4. **The iframe body is WHITE** \u2014 it is NOT a dark-theme parent. Use dark-on-light palettes: text \`#111\` / \`#1e293b\`, strokes \`#334155\` / \`#94a3b8\`, fills from vivid hues like \`#3b82f6\` \`#ef4444\` \`#10b981\` \`#8b5cf6\` \`#f59e0b\`. NEVER use white or near-white (\`#fff\`, \`#f8fafc\`) for text or fills \u2014 they are invisible. If you want a dark canvas, set \`background: #0f172a\` on the root div yourself, then you may use light text.
|
|
101033
|
-
5. **Chart.js sizing** \u2014 put the \`<canvas>\` inside a wrapper div with an explicit pixel height (\`<div style="width:100%;height:320px;position:relative"><canvas id="c"></canvas></div>\`). A bare \`<canvas style="height:320px">\` renders at 0\xD70 because Chart.js reads the PARENT's box, not the canvas attribute. Always pass \`{ responsive: true, maintainAspectRatio: false }\` in the options so it fills the wrapper.
|
|
101034
|
-
6. **Read width at runtime \u2014 do NOT hardcode it.** The iframe's width depends on the user's viewport. \`const W = document.getElementById('chart').clientWidth || 800\` adapts to any size. A fixed \`const width = 900\` leaves dead space in wide cards or gets clipped in narrow ones. For SVG, prefer \`viewBox="0 0 W H"\` + \`style="width:100%;height:Hpx"\` so the browser scales it for you.
|
|
101035
|
-
|
|
101036
|
-
### Example \u2014 D3 force-directed graph (use this shape for random / network graphs)
|
|
101037
|
-
|
|
101038
|
-
\`\`\`
|
|
101039
|
-
<visualization type="html" title="Random Network Graph">
|
|
101040
|
-
<div id="graph" style="width:100%;height:480px"></div>
|
|
101041
|
-
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
|
|
101042
|
-
<script>
|
|
101043
|
-
const W = document.getElementById('graph').clientWidth;
|
|
101044
|
-
const H = 480;
|
|
101045
|
-
const N = 15;
|
|
101046
|
-
const nodes = Array.from({length: N}, (_, i) => ({ id: i, group: i % 3 }));
|
|
101047
|
-
const links = [];
|
|
101048
|
-
for (let i = 1; i < N; i++) links.push({ source: i, target: Math.floor(Math.random() * i) });
|
|
101049
|
-
for (let k = 0; k < 8; k++) links.push({ source: Math.floor(Math.random()*N), target: Math.floor(Math.random()*N) });
|
|
101050
|
-
const svg = d3.select('#graph').append('svg').attr('width', W).attr('height', H);
|
|
101051
|
-
const color = d => ['#3b82f6','#ef4444','#10b981'][d.group];
|
|
101052
|
-
const sim = d3.forceSimulation(nodes)
|
|
101053
|
-
.force('link', d3.forceLink(links).distance(60))
|
|
101054
|
-
.force('charge', d3.forceManyBody().strength(-220))
|
|
101055
|
-
.force('center', d3.forceCenter(W/2, H/2))
|
|
101056
|
-
.force('collide', d3.forceCollide(22));
|
|
101057
|
-
const link = svg.append('g').attr('stroke', '#94a3b8').selectAll('line').data(links).join('line').attr('stroke-width', 1.5);
|
|
101058
|
-
const node = svg.append('g').selectAll('circle').data(nodes).join('circle').attr('r', 16).attr('fill', color).attr('stroke', '#fff').attr('stroke-width', 2).call(d3.drag().on('start', (e,d) => { if (!e.active) sim.alphaTarget(0.3).restart(); d.fx = d.x; d.fy = d.y; }).on('drag', (e,d) => { d.fx = e.x; d.fy = e.y; }).on('end', (e,d) => { if (!e.active) sim.alphaTarget(0); d.fx = null; d.fy = null; }));
|
|
101059
|
-
const label = svg.append('g').selectAll('text').data(nodes).join('text').text(d => d.id).attr('text-anchor', 'middle').attr('dy', 4).attr('fill', '#111').attr('font-size', 11).attr('font-weight', 'bold').attr('pointer-events', 'none');
|
|
101060
|
-
sim.on('tick', () => {
|
|
101061
|
-
link.attr('x1', d => d.source.x).attr('y1', d => d.source.y).attr('x2', d => d.target.x).attr('y2', d => d.target.y);
|
|
101062
|
-
node.attr('cx', d => d.x).attr('cy', d => d.y);
|
|
101063
|
-
label.attr('x', d => d.x).attr('y', d => d.y);
|
|
101064
|
-
});
|
|
101065
|
-
</script>
|
|
101066
|
-
</visualization>
|
|
101067
|
-
<visualization-alt>Interactive force-directed graph with 15 nodes in three colour groups connected by random edges; nodes can be dragged.</visualization-alt>
|
|
101068
|
-
\`\`\`
|
|
101069
|
-
|
|
101070
|
-
Supported Mermaid diagram types (use these verbatim as the first line):
|
|
101071
|
-
\`sequenceDiagram\`, \`flowchart TD\` (top-down), \`flowchart LR\` (left-right), \`stateDiagram-v2\`, \`classDiagram\`, \`erDiagram\`, \`gantt\`, \`journey\`.
|
|
101072
|
-
|
|
101073
|
-
Only drop down to **hand-coded SVG** for non-standard geometric illustrations that Mermaid does not support (custom spatial layouts, periodic tables, map overlays, bespoke data shapes). If you DO write SVG for a diagram, pre-compute the geometry on a tight grid \u2014 pick a \`LANE = 120\` constant and place every box/label/arrow at \`LANE * i\` only, never freehand coordinates.
|
|
101074
|
-
|
|
101075
|
-
## Example 2 \u2014 inline SVG diagram (non-diagram visuals only)
|
|
101076
|
-
|
|
101077
|
-
\`\`\`
|
|
101078
|
-
<visualization type="html" title="Request Flow">
|
|
101079
|
-
<svg viewBox="0 0 320 100" xmlns="http://www.w3.org/2000/svg" style="width:100%">
|
|
101080
|
-
<rect x="10" y="20" width="80" height="60" rx="6" fill="#dbeafe" stroke="#1d4ed8"/>
|
|
101081
|
-
<text x="50" y="55" text-anchor="middle" font-size="14">User</text>
|
|
101082
|
-
<rect x="120" y="20" width="80" height="60" rx="6" fill="#fef3c7" stroke="#b45309"/>
|
|
101083
|
-
<text x="160" y="55" text-anchor="middle" font-size="14">API</text>
|
|
101084
|
-
<rect x="230" y="20" width="80" height="60" rx="6" fill="#dcfce7" stroke="#15803d"/>
|
|
101085
|
-
<text x="270" y="55" text-anchor="middle" font-size="14">DB</text>
|
|
101086
|
-
<line x1="90" y1="50" x2="120" y2="50" stroke="#334155" stroke-width="2"/>
|
|
101087
|
-
<line x1="200" y1="50" x2="230" y2="50" stroke="#334155" stroke-width="2"/>
|
|
101088
|
-
</svg>
|
|
101089
|
-
</visualization>
|
|
101090
|
-
\`\`\`
|
|
101091
|
-
|
|
101092
|
-
## Accessibility \u2014 ALWAYS emit \`<visualization-alt>\` (and \`<visualization-data>\` when relevant)
|
|
101093
|
-
|
|
101094
|
-
Screen reader and other assistive tech users cannot introspect the iframe's DOM \u2014 the sandbox blocks it by design. You MUST therefore emit a short plain-text description alongside every \`<visualization>\` so those users still understand what they are looking at.
|
|
101095
|
-
|
|
101096
|
-
### \`<visualization-alt>\` \u2014 REQUIRED
|
|
101097
|
-
|
|
101098
|
-
Follow each \`<visualization>\` block with a sibling \`<visualization-alt>\u2026</visualization-alt>\` containing a 1\u20133 sentence plain-text description of what the chart/diagram shows. Write for someone who cannot see the image: name the metric, the shape, and the key takeaway.
|
|
101099
|
-
|
|
101100
|
-
### \`<visualization-data>\` \u2014 OPTIONAL, but strongly preferred for charts
|
|
101101
|
-
|
|
101102
|
-
When the visualization is built from tabular data (bar charts, line charts, tables), also emit a sibling \`<visualization-data>\u2026</visualization-data>\` block containing the raw data as JSON \u2014 either an array of row objects (\`[{"year": 2020, "usd": 1000}, \u2026]\`) or a \`{"rows": [...]}\` wrapper. The UI renders an accessible \`<table>\` alternative from it.
|
|
101103
|
-
|
|
101104
|
-
## Example 3 \u2014 chart with alt + data
|
|
101105
|
-
|
|
101106
|
-
\`\`\`
|
|
101107
|
-
<visualization type="html" title="USD Growth at 5%">
|
|
101108
|
-
<div style="width:100%;height:280px;position:relative"><canvas id="c"></canvas></div>
|
|
101109
|
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
101110
|
-
<script>
|
|
101111
|
-
new Chart(document.getElementById('c'), {
|
|
101112
|
-
type: 'bar',
|
|
101113
|
-
options: { responsive: true, maintainAspectRatio: false },
|
|
101114
|
-
data: { labels: [2020, 2021, 2022], datasets: [{ label: 'USD', data: [1000, 1050, 1103] }] }
|
|
101115
|
-
});
|
|
101116
|
-
</script>
|
|
101117
|
-
</visualization>
|
|
101118
|
-
<visualization-alt>Bar chart of a 1000 USD investment growing at 5% compound interest from 2020 to 2022, reaching 1103 USD in year three.</visualization-alt>
|
|
101119
|
-
<visualization-data>[{"year":2020,"usd":1000},{"year":2021,"usd":1050},{"year":2022,"usd":1103}]</visualization-data>
|
|
101120
|
-
\`\`\`
|
|
101121
|
-
|
|
101122
|
-
## Sandbox \u2014 what you MUST NOT rely on
|
|
101123
|
-
|
|
101124
|
-
The iframe runs with \`sandbox="allow-scripts"\` only. NONE of these work:
|
|
101125
|
-
|
|
101126
|
-
- **No \`allow-same-origin\`** \u2014 null-origin document. No cookies, no localStorage, no sessionStorage, no IndexedDB.
|
|
101127
|
-
- **No parent access** \u2014 don't touch \`window.parent\`, \`window.top\`, or the parent DOM. The renderer handles height and ready signals itself.
|
|
101128
|
-
- **No forms, popups, or navigation** \u2014 \`allow-forms\`, \`allow-popups\`, \`allow-top-navigation\` are NOT set. No \`window.open\`, no \`<form action>\`, no \`location\` writes.
|
|
101129
|
-
- **No persistence** \u2014 visualizations are ephemeral. Do not claim to save or embed them; the user decides via the UI.
|
|
101130
|
-
|
|
101131
|
-
External \`<script src="https://cdn\u2026">\` loads work (\`allow-scripts\` permits script fetches). Prefer compact CDN bundles: Chart.js, D3, Plotly, Three.js.
|
|
101132
|
-
|
|
101133
|
-
## Style
|
|
101134
|
-
|
|
101135
|
-
- Self-contained \u2014 no outer-CSS dependencies.
|
|
101136
|
-
- Set an explicit \`height\` (or \`viewBox\` for SVG) on the root; the iframe auto-sizes up to a cap.
|
|
101137
|
-
- System fonts blend best: \`font-family: system-ui, sans-serif\`.
|
|
101138
|
-
- Emit the raw tags directly \u2014 do NOT wrap them in markdown fences.
|
|
101139
|
-
`;
|
|
101140
|
-
}
|
|
101141
|
-
});
|
|
101142
|
-
|
|
101143
100926
|
// src/lib/openui/library-prompt.generated.ts
|
|
101144
100927
|
var OPENUI_LIBRARY_PROMPT;
|
|
101145
100928
|
var init_library_prompt_generated = __esm({
|
|
101146
100929
|
"src/lib/openui/library-prompt.generated.ts"() {
|
|
101147
100930
|
"use strict";
|
|
101148
|
-
OPENUI_LIBRARY_PROMPT = 'You are an AI assistant that responds using openui-lang, a declarative UI language. Your ENTIRE response must be valid openui-lang code \u2014 no markdown, no explanations, just openui-lang.\n\n## Syntax Rules\n\n1. Each statement is on its own line: `identifier = Expression`\n2. `root` is the entry point \u2014 every program must define `root = Card(...)`\n3. Expressions are: strings ("..."), numbers, booleans (true/false), null, arrays ([...]), objects ({...}), or component calls TypeName(arg1, arg2, ...)\n4. Use references for readability: define `name = ...` on one line, then use `name` later\n5. EVERY variable (except root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent\'s children/items array.\n6. Arguments are POSITIONAL (order matters, not names). Write `SomeComp([children], "row", "l")` NOT `SomeComp([children], direction: "row", gap: "l")` \u2014 colon syntax is NOT supported and silently breaks\n7. Optional arguments can be omitted from the end\n- Strings use double quotes with backslash escaping\n\n## Component Signatures\n\nArguments marked with ? are optional. Sub-components can be inline or referenced; prefer references for better streaming.\nProps typed `ActionExpression` accept one @step, or Action([@steps...]) for several. See the Action section for available steps (@ToAssistant, @OpenUrl).\nProps marked `$binding<type>` accept a `$variable` reference for two-way binding.\n\n### Content\nCardHeader(title?: string, subtitle?: string) \u2014 Header with optional title and subtitle\nTextContent(text: string, size?: "small" | "default" | "large" | "small-heavy" | "large-heavy") \u2014 Text block. Supports markdown. Optional size: "small" | "default" | "large" | "small-heavy" | "large-heavy".\nMarkDownRenderer(textMarkdown: string, variant?: "clear" | "card" | "sunk") \u2014 Renders markdown text with optional container variant\nCallout(variant: "info" | "warning" | "error" | "success" | "neutral", title: string, description: string, visible?: $binding<boolean>) \u2014 Callout banner. Optional visible is a reactive $boolean \u2014 auto-dismisses after 3s by setting $visible to false.\nTextCallout(variant?: "neutral" | "info" | "warning" | "success" | "danger", title?: string, description?: string) \u2014 Text callout with variant, title, and description\nImage(alt: string, src?: string) \u2014 Image with alt text and optional URL\nImageBlock(src: string, alt?: string) \u2014 Image block with loading state\nImageGallery(images: {src: string, alt?: string, details?: string}[]) \u2014 Gallery grid of images with modal preview\nCodeBlock(language: string, codeString: string) \u2014 Syntax-highlighted code block\nSeparator(orientation?: "horizontal" | "vertical", decorative?: boolean) \u2014 Visual divider between content sections\nInlineHeader(heading: string, description?: string) \u2014 Compact section heading with an optional one-line description, for use inside cards.\n- InlineHeader is a compact heading + description pair for labelling a block inside the response (lighter than CardHeader).\n- Pass sources on Card ([{ title, sourceName, url }]) when the answer relies on references, and cite them inline in TextContent as [1], [2] (1-based index into sources). A Sources strip renders at the bottom of the card.\n\n### Tables\nTable(columns: Col[]) \u2014 Data table \u2014 column-oriented. Each Col holds its own data array.\nCol(label: string, data: any, type?: "string" | "number" | "action") \u2014 Column definition \u2014 holds label + data array\nEditableTable(name?: string, columns?: {type: "text" | "number" | "date-single" | "select" | "url", key?: string, header?: string, width?: number, options?: {value: string, label: string}[]}[], data?: {id: string, values: (string | number)[]}[]) \u2014 Spreadsheet-like table whose cells the user can edit inline (text, number, url, date, select columns); edits are saved back as a form field\n- EditableTable lets the user edit cells inline. Give it a unique name, columns of { type, key, header } with type one of text | number | date-single | select | url (select also needs options: [{ value, label }]).\n- data is an array of { id, values } rows where values are ordered positionally to match columns. Edited data is submitted when the user clicks Save Changes.\n\n### Charts (2D)\nBarChart(labels: string[], series: Series[], variant?: "grouped" | "stacked", xLabel?: string, yLabel?: string, height?: number) \u2014 Vertical bars; use for comparing values across categories with one or more series\nLineChart(labels: string[], series: Series[], variant?: "linear" | "natural" | "step", xLabel?: string, yLabel?: string, height?: number) \u2014 Lines over categories; use for trends and continuous data over time\nAreaChart(labels: string[], series: Series[], variant?: "linear" | "natural" | "step", xLabel?: string, yLabel?: string, height?: number) \u2014 Filled area under lines; use for cumulative totals or volume trends over time\nRadarChart(labels: string[], series: Series[]) \u2014 Spider/web chart; use for comparing multiple variables across one or more entities\nHorizontalBarChart(labels: string[], series: Series[], variant?: "grouped" | "stacked", xLabel?: string, yLabel?: string) \u2014 Horizontal bars; prefer when category labels are long or for ranked lists\nSeries(category: string, values: number[]) \u2014 One data series\n\n### Charts (1D)\nPieChart(labels: string[], values: number[], variant?: "pie" | "donut", appearance?: "circular" | "semiCircular") \u2014 Circular slices; use plucked arrays: PieChart(data.categories, data.values)\nRadialChart(labels: string[], values: number[]) \u2014 Radial bars; use plucked arrays: RadialChart(data.categories, data.values)\nSingleStackedBarChart(labels: string[], values: number[]) \u2014 Single horizontal stacked bar; use plucked arrays: SingleStackedBarChart(data.categories, data.values)\nSlice(category: string, value: number) \u2014 One slice with label and numeric value\n\n### Charts (Scatter)\nScatterChart(datasets: ScatterSeries[], xLabel?: string, yLabel?: string) \u2014 X/Y scatter plot; use for correlations, distributions, and clustering\nScatterSeries(name: string, points: Point[]) \u2014 Named dataset\nPoint(x: number, y: number, z?: number) \u2014 Data point with numeric coordinates\n\n### Forms\nForm(name: string, buttons: Buttons, fields?: FormControl[]) \u2014 Form container with fields and explicit action buttons\nFormControl(label: string, input: Input | TextArea | Select | DatePicker | Slider | CheckBoxGroup | RadioGroup | Chips | OptionCards, hint?: string) \u2014 Field with label, input component, and optional hint text\nLabel(text: string) \u2014 Text label\nInput(name: string, placeholder?: string, type?: "text" | "email" | "password" | "number" | "url", rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nTextArea(name: string, placeholder?: string, rows?: number, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nSelect(name: string, items: SelectItem[], placeholder?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>, size?: "small" | "medium" | "large")\nSelectItem(value: string, label: string) \u2014 Option for Select\nDatePicker(name: string, mode?: "single" | "range", rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<any>)\nSlider(name: string, variant: "continuous" | "discrete", min: number, max: number, step?: number, defaultValue?: number[], label?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<number[]>) \u2014 Numeric slider input; supports continuous and discrete (stepped) variants\nCheckBoxGroup(name: string, items: CheckBoxItem[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<Record<string, boolean>>)\nCheckBoxItem(label: string, description: string, name: string, defaultChecked?: boolean)\nRadioGroup(name: string, items: RadioItem[], defaultValue?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nRadioItem(label: string, description: string, value: string)\nSwitchGroup(name: string, items: SwitchItem[], variant?: "clear" | "card" | "sunk", value?: $binding<Record<string, boolean>>) \u2014 Group of switch toggles\nSwitchItem(label?: string, description?: string, name: string, defaultChecked?: boolean) \u2014 Individual switch toggle\nChips(name: string, type?: "single" | "multiple", items?: ChipItem[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, defaultValue?: string | string[]) \u2014 A form field of compact selectable chips for choosing one or many short options; the selection is stored under `name`.\nChipItem(value: string, label: string, icon?: Icon, disabled?: boolean) \u2014 A single selectable chip inside a Chips group, with a value, label and optional icon.\nOptionCards(name: string, type?: "single" | "multiple", items?: OptionCard[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, defaultValue?: string | string[]) \u2014 A form field of selectable cards (title, optional subtitle, optional icon or image) laid out in a responsive grid for choosing one or many options; the selection is stored under `name`.\nOptionCard(value: string, title: string, subtitle?: string, topContent?: Icon | Image, disabled?: boolean) \u2014 A single selectable card inside an OptionCards group, with a value, title, optional subtitle and an optional Icon or Image on top.\n- Chips: compact single/multiple selection pills. Use ChipItem references for each option.\n- OptionCards: larger selectable cards with title, subtitle and an optional Icon or Image on top. Use OptionCard references for each option.\n- Define EACH FormControl as its own reference \u2014 do NOT inline all controls in one array.\n- NEVER nest Form inside Form.\n- Form requires explicit buttons. Always pass a Buttons(...) reference as the second Form argument: Form(name, buttons, fields).\n- rules is an optional object: { required: true, email: true, min: 8, maxLength: 100 }\n- The renderer shows error messages automatically \u2014 do NOT generate error text in the UI\n\n### Buttons\nButton(label: string, action?: ActionExpression, variant?: "primary" | "secondary" | "tertiary", type?: "normal" | "destructive", size?: "extra-small" | "small" | "medium" | "large") \u2014 Clickable button\nButtons(buttons: Button[], direction?: "row" | "column") \u2014 Group of Button components. direction: "row" (default) | "column".\nIcon(name: string, category?: string) \u2014 A lucide icon by kebab-case name (e.g. \'circle-check\'). Optional category picks a topical fallback when the name doesn\'t resolve.\nIconButton(name: string, icon: Icon, action?: ActionExpression, variant?: "primary" | "secondary" | "tertiary", size?: "extra-small" | "small" | "medium" | "large", shape?: "square" | "circle") \u2014 Icon-only button. name is the accessible label and the action label; icon is an Icon; action fires on click.\n- Icon renders a lucide icon by kebab-case name; it is also used as the icon of IconButton, IconText and OptionCard.\n\n### Lists & Follow-ups\nListBlock(items: ListItem[], variant?: "number" | "image", size?: "default" | "small") \u2014 A list of items with number or image indicators. Each item can optionally have an action. size small renders a compact list.\nListItem(title: string, subtitle?: string, image?: {src: string, alt: string}, actionLabel?: string, action?: ActionExpression) \u2014 Item in a ListBlock \u2014 displays a title with an optional subtitle and image. When action is provided, the item becomes clickable.\nFollowUpBlock(items: FollowUpItem[]) \u2014 List of clickable follow-up suggestions placed at the end of a response\nFollowUpItem(text: string) \u2014 Clickable follow-up suggestion \u2014 when clicked, sends text as user message\n- Use ListBlock with ListItem references for numbered lists.\n- Use FollowUpBlock with FollowUpItem references at the end of a response to suggest next actions.\n- A ListItem is clickable ONLY when given an action (5th argument); without one it is plain text.\n- Clicking a FollowUpItem, or a ListItem with a @ToAssistant action, sends text to the LLM as a user message.\n- Example: list = ListBlock([item1, item2]) item1 = ListItem("Option A", "Details about A", null, null, @ToAssistant("Option A"))\n\n### Sections\nSectionBlock(sections: SectionItem[], isFoldable?: boolean) \u2014 Collapsible accordion sections. Auto-opens sections as they stream in. Use SectionItem for each section.\nSectionItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | Tabs | Accordion)[]) \u2014 Section with a label and collapsible content \u2014 used inside SectionBlock\n- SectionBlock renders collapsible accordion sections that auto-open as they stream.\n- Each section needs a unique `value` id, a `trigger` label, and a `content` array.\n- Example: sections = SectionBlock([s1, s2]) s1 = SectionItem("intro", "Introduction", [content1])\n- Set isFoldable=false to render sections as flat headers instead of accordion.\n\n### Layout\nTabs(items: TabItem[]) \u2014 Tabbed container\nTabItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | Accordion)[]) \u2014 value is unique id, trigger is tab label, content is array of components\nAccordion(items: AccordionItem[]) \u2014 Collapsible sections\nAccordionItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock)[]) \u2014 value is unique id, trigger is section title\nSteps(items: StepsItem[]) \u2014 Step-by-step guide\nStepsItem(title: string, details: string) \u2014 title and details text for one step\nCarousel(children: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock)[][], variant?: "card" | "sunk") \u2014 Horizontal scrollable carousel\n- Use Tabs to present alternative views \u2014 each TabItem has a value id, trigger label, and content array.\n- Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])\n- IMPORTANT: Every slide in a Carousel must have the same structure \u2014 same component types in the same order.\n- For image carousels use: [[title, image, description, tags], ...] \u2014 every slide must follow this exact pattern.\n- Use real, publicly accessible image URLs (e.g. https://picsum.photos/seed/KEYWORD/800/500). Never hallucinate image URLs.\n\n### Data Display\nTagBlock(tags: string[], size?: "sm" | "md" | "lg") \u2014 tags is an array of strings; optional size sm | md | lg\nTag(text: string, icon?: Icon, size?: "sm" | "md" | "lg", variant?: "neutral" | "info" | "success" | "warning" | "danger") \u2014 Styled tag/badge with optional Icon and variant\nEntityList(rows?: {left: string, right: string, rightVariant?: "text" | "number"}[], size?: "small" | "default", header?: {left: string, right: string, rightVariant?: "text" | "number"}, footer?: {left: string, right: string, rightVariant?: "text" | "number"}) \u2014 Two-column key/value rows (left label, right value). size \'default\' supports optional header and footer rows; rightVariant \'number\' uses tabular numbers.\n- EntityList is a compact two-column list of { left, right } rows (e.g. name / value). size=\'default\' also supports a header and footer row; size=\'small\' does not.\n\n### Cards\nSnippetCardBlock(items: SnippetCardItem[], layout?: "grid", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A responsive grid of compact label/value cards (2 per row) for showing several short facts side by side; optionally clickable with a shared action.\nSnippetCardItem(id?: string, lhs: IconText | ImageText, rhs?: Text | BoldText) \u2014 One row-style snippet card: a label on the left (IconText or ImageText) and an optional value on the right (Text or BoldText).\nOverviewCardBlock(items: OverviewCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or horizontal carousel of compact overview cards, each with a heading (icon/image/text) on top and an inline metric below; optionally clickable with a shared action.\nOverviewCardItem(id?: string, top: IconText | ImageText | Text, bottom?: MetricIndicatorInline) \u2014 One overview card: a heading slot at the top (IconText, ImageText or Text) and an optional MetricIndicatorInline at the bottom.\nContextCardBlock(items: ContextCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or carousel of compact tinted context cards (title or tag plus a short bold body); an optional action makes every card clickable.\nContextCardItem(id?: string, title: string | Tag, body?: string, bgColor?: "gray", bgImageSrc?: string, bgImageAlt?: string) \u2014 A single card inside a ContextCardBlock: a title (plain string or Tag), an optional markdown body, and an optional gray tint or background image.\nCompositeCardBlock(items: CompositeCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A two-per-row grid or carousel of rich cards, each with an optional header, stacked body content (text, metrics, charts, lists, tags) and a price/button footer; an optional action makes every card clickable.\nCompositeCardItem(id?: string, header?: IconText | ImageText | ImageTextLarge | Text | Image, body?: (Text | BoldText | MetricIndicatorInline | IconText | Image | AreaChart | BarChart | LineChart | ListBlock | TagBlock | EntityList)[], footer?: {price?: BoldText | MetricIndicatorWithStrikethrough, button?: Button}) \u2014 A single card inside a CompositeCardBlock: an optional header (icon/image/text), a stack of body elements (text, metrics, charts, lists, tags), and an optional price/button footer.\nVisualCardBlock(items: VisualCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or carousel of photo-first cards: a full-bleed background image with a tag on top and a bold text panel at the bottom; an optional action makes every card clickable.\nVisualCardItem(body: BoldText, id?: string, bgImageSrc?: string, tag?: Tag, bgImageAlt?: string) \u2014 A single photo-first card inside a VisualCardBlock: a BoldText body panel, an optional Tag, and a background image (bgImageSrc must be a real URL; bgImageAlt is its alt text).\nText(variant?: "text" | "number", value: string, subtext?: string, subtextVariant?: "text" | "number" | "metric", size?: "xs" | "sm" | "md" | "lg") \u2014 Plain text line with optional subtext. variant \'number\' uses tabular number styling; subtextVariant \'metric\' colors a leading +/- subtext green/red.\nBoldText(variant?: "text" | "number", value: string, subtext?: string, subtextVariant?: "text" | "number" | "metric", size?: "xs" | "sm" | "md" | "lg") \u2014 Emphasized (bold) text line with optional subtext. variant \'number\' uses tabular number styling; subtextVariant \'metric\' colors a leading +/- subtext green/red.\nIconText(icon: Icon, iconVariant?: "neutral" | "info" | "success" | "warning" | "danger" | "inverted" | "filled" | "soft", iconSize?: "xs" | "s" | "m" | "l" | "xl" | "sm" | "md" | "lg", title: string, subtitle?: string, bold?: boolean, layout?: "horizontal" | "vertical") \u2014 An icon badge with a title and optional subtitle, laid out horizontally or vertically. iconVariant sets the badge color.\nImageText(src: string, alt?: string, title: string, subtitle?: string, bold?: boolean, layout?: "horizontal" | "vertical", imageSize?: number) \u2014 A small square image (thumbnail/avatar) with a title and optional subtitle. src must be a real image URL.\nImageTextLarge(src: string, alt?: string, title: string, subtitle?: string, bold?: boolean) \u2014 A full-width banner image above a bold title and optional subtitle. src must be a real image URL.\nMetricIndicatorInline(value: string, subtext?: string, trend?: {direction: "up" | "down", value: number}) \u2014 Headline metric value with an optional +/- percentage trend and subtext, all on one line.\nMetricIndicatorWithStrikethrough(value: string, subtext?: string, previousValue?: string, trend?: {direction: "up" | "down", value: number}) \u2014 Headline metric value with an optional struck-through previousValue, a +/- percentage trend, and subtext below.\n- Card blocks lay out 2+ items in a responsive grid (or carousel where supported). Every item in a block must have the same structure.\n- SnippetCardItem: small card with lhs (IconText | ImageText) and optional rhs (Text | BoldText) \u2014 good for key/value facts.\n- OverviewCardItem: small card with top (IconText | ImageText | Text) and optional bottom MetricIndicatorInline \u2014 good for KPIs.\n- ContextCardItem: medium card with a title (string or Tag), body text and optional background image \u2014 good for summaries.\n- CompositeCardItem: rich card with header, body array (Text, BoldText, MetricIndicatorInline, IconText, Image, charts, ListBlock, TagBlock, EntityList) and footer (price + Button) \u2014 good for products/offers.\n- VisualCardItem: image-first card with a BoldText body and optional Tag.\n- Text / BoldText / IconText / ImageText / ImageTextLarge / MetricIndicator* are the inline building blocks used INSIDE card items; do not place them directly in the root Card.\n\n### Other\nCard(children: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | SectionBlock | Tabs | Carousel)[], sources?: {url?: string, title: string, sourceName: string}[]) \u2014 Vertical container for all content in a chat response. Children stack top to bottom automatically. Optional sources ([{ title, sourceName, url }]) render as a Sources strip at the bottom and back inline [n] citations in TextContent.\n\n## Action \u2014 Button Behavior\n\nAn action wires a button click to operations. Pass one @-prefixed step bare, e.g. Button("Ask", @ToAssistant("Tell me more")). Put several steps in Action([...]), e.g. Button("Read", Action([@OpenUrl("https://example.com"), @ToAssistant("Summarize this page")])). Steps execute in order.\nButtons without an action automatically send their label to the assistant (equivalent to @ToAssistant(label)).\n\nAvailable steps:\n- @ToAssistant(message: string, context?: any) \u2014 Send a message to the assistant (for conversational buttons like "Tell me more", "Explain this"). The optional context is any value (object, array, string, number) passed to the assistant as hidden data, e.g. @ToAssistant("Show details", {orderId: 42})\n- @OpenUrl(url: string) \u2014 Navigate to a URL\n\nExample \u2014 simple nav:\n```\nviewBtn = Button("View", @OpenUrl("https://example.com"))\n```\n\n- An action can be assigned to a variable or inlined: Button("Go", onSubmit) and Button("Go", Action([...])) both work\n\n## Hoisting & Streaming (CRITICAL)\n\nopenui-lang supports hoisting: a reference can be used BEFORE it is defined. The parser resolves all references after the full input is parsed.\n\nDuring streaming, the output is re-parsed on every chunk. Undefined references are temporarily unresolved and appear once their definitions stream in. This creates a progressive top-down reveal \u2014 structure first, then data fills in.\n\n**Recommended statement order for optimal streaming:**\n1. `root = Card(...)` \u2014 UI shell appears immediately\n2. Component definitions \u2014 fill in as they stream\n3. Data values \u2014 leaf content last\n\nAlways write the root = Card(...) statement first so the UI shell appears immediately, even before child data has streamed in.\n\n## Examples\n\nExample 1 \u2014 Informational response (the shape for "tell me about X" / explainer asks):\n\nroot = Card([header, intro, highlights, statsHeader, statsCards, sectionsBlock, actionBtns], [src1, src2])\nheader = CardHeader("Paris", "The City of Light \xB7 France\'s Eternal Capital")\nintro = TextContent("Paris is one of the world\'s most visited cities \u2014 a timeless blend of iconic landmarks, world-class cuisine, art, and romance [1]. In 2026 the city is buzzing with new energy: the **Grand Palais** has reopened after a \u20AC466M renovation, and you can now **swim in the Seine** for the first time in over a century [2].")\nhighlights = ContextCardBlock([h1, h2, h3], "grid", true, @ToAssistant("Tell me more about this aspect of Paris"))\nh1 = ContextCardItem("art-museums", "Art & Museums", "143 museums including the Louvre & newly reopened Grand Palais.", "gray", "https://cdn.britannica.com/03/121003-050-2544BD4E/Interior-Louvre-Museum-Paris.jpg")\nh2 = ContextCardItem("gastronomy", "Gastronomy", "9,000+ restaurants, 130+ Michelin stars, and the world\'s best baguettes.", "gray")\nh3 = ContextCardItem("fashion-capital", "Fashion Capital", "Home to Chanel, Dior, Louis Vuitton & Herm\xE8s \u2014 the global luxury hub.", "gray", "https://thumbs.dreamstime.com/z/dior-storefront-facade-chanel-store-lvmh-s-french-designer-modehouse-christian-adjacent-to-luxury-fashion-beauty-brand-327161553.jpg")\nstatsHeader = InlineHeader("Paris by the Numbers", "Key visitor statistics")\nstatsCards = OverviewCardBlock([ov1, ov2, ov3], "grid", true)\nov1 = OverviewCardItem("annual-visitors", ov1top, ov1metric)\nov1top = IconText(ov1icon, "neutral", "m", "Annual Visitors", "2024 arrivals", false, "vertical")\nov1icon = Icon("users", "people")\nov1metric = MetricIndicatorInline("48.7M", "tourists", { direction: "up", value: 2.5 })\nov2 = OverviewCardItem("museums-monuments", ov2top, ov2metric)\nov2top = IconText(ov2icon, "neutral", "m", "Museums & Monuments", "Cultural sites", false, "vertical")\nov2icon = Icon("landmark", "buildings")\nov2metric = MetricIndicatorInline("2,370+", "across the city")\nov3 = OverviewCardItem("tourism-revenue", ov3top, ov3metric)\nov3top = IconText(ov3icon, "neutral", "m", "Tourism Revenue", "2024 estimate", false, "vertical")\nov3icon = Icon("circle-dollar-sign", "finance")\nov3metric = MetricIndicatorInline("\u20AC23.4B", "generated")\nsectionsBlock = SectionBlock([secLandmarks, secFood, secWhen], false)\nsecLandmarks = SectionItem("landmarks", "Iconic Landmarks", [landmarksCarousel])\nlandmarksCarousel = VisualCardBlock([lm1, lm2, lm3, lm4], "carousel", true, @ToAssistant("Tell me more about this Paris landmark"))\nlm1 = VisualCardItem(lm1body, "eiffel-tower", "https://c8.alamy.com/comp/RYEB13/aerial-view-of-the-eiffel-tower-with-the-park-champ-de-mars-and-the-river-seine-paris-france-RYEB13.jpg", lm1tag, "Aerial view of the Eiffel Tower")\nlm1body = BoldText("text", "Eiffel Tower", "Open daily 9am\u2013midnight")\nlm1tag = Tag("Must-See", lm1tagIcon, "sm", "info")\nlm1tagIcon = Icon("star", "shapes")\nlm2 = VisualCardItem(lm2body, "the-louvre", "https://images.fineartamerica.com/images/artworkimages/mediumlarge/3/1-exterior-of-musee-du-louvre-museum-paris-france-bernard-jaubert.jpg", lm2tag, "Exterior of the Louvre museum")\nlm2body = BoldText("text", "The Louvre", "World\'s largest art museum")\nlm2tag = Tag("8.9M visits/yr", lm2tagIcon, "sm", "success")\nlm2tagIcon = Icon("trending-up", "charts")\nlm3 = VisualCardItem(lm3body, "notre-dame", "https://cdn.britannica.com/29/255529-050-63A22A3C/notre-dame-de-paris-cathedral-paris-france.jpg", lm3tag, "Notre-Dame cathedral facade")\nlm3body = BoldText("text", "Notre-Dame", "Fully restored cathedral")\nlm3tag = Tag("Reopened 2024", lm3tagIcon, "sm", "warning")\nlm3tagIcon = Icon("hammer", "tools")\nlm4 = VisualCardItem(lm4body, "versailles", "https://cdn.britannica.com/76/130076-050-31128A3D/Latona-Fountain-Balthazard-Marsy-Gaspard-Andre-Le.jpg", lm4tag, "Latona Fountain at Versailles")\nlm4body = BoldText("text", "Palace of Versailles", "Royal gardens & grand halls")\nlm4tag = Tag("Day Trip", lm4tagIcon, "sm", "neutral")\nlm4tagIcon = Icon("train-front", "travel")\nsecFood = SectionItem("food", "Food & Drink", [foodCards])\nfoodCards = ContextCardBlock([f1, f2, f3], "grid", true, @ToAssistant("Tell me more about eating and drinking in Paris"))\nf1 = ContextCardItem("bistros", "Bistros", "Classic French fare \u2014 try Les Arlots for confit beef cheeks.", "gray", "https://everydayparisian.com/wp-content/uploads/2023/01/IMG_0221-768x1024.webp")\nf2 = ContextCardItem("fine-dining", "Fine Dining", "Septime leads a new wave of creative Michelin-starred cuisine.", "gray", "https://production-data.worldofmouth.app/images/72b2e6db-97ea-49c4-aa5d-3b7c8121c812.jpg")\nf3 = ContextCardItem("bakeries", "Bakeries", "Shinya Pain for sourdough. Grand Prix-winning baguettes citywide.", "gray", "https://www.davidlebovitz.com/wp-content/uploads/2018/09/Le-petit-grain-paris-bakery-boulangerie-patisserie-pastry-shop-8-640x895.jpg")\nsecWhen = SectionItem("when", "Best Time to Visit", [whenTabs])\nwhenTabs = Tabs([tabSpring, tabSummer])\ntabSpring = TabItem("spring", "Spring", [springList])\nspringList = ListBlock([sp1, sp2, sp3], "number")\nsp1 = ListItem("Cherry blossoms at Parc de Sceaux", "March \u2013 May", null, null, @ToAssistant("Tell me about cherry blossom season in Paris"))\nsp2 = ListItem("Picnics along the Seine & in city parks", "Warm, lively atmosphere", null, null, @ToAssistant("Where are the best picnic spots in Paris?"))\nsp3 = ListItem("Fewer crowds than summer", "Ideal for sightseeing", null, null, @ToAssistant("How busy is Paris in spring?"))\ntabSummer = TabItem("summer", "Summer", [summerList])\nsummerList = ListBlock([su1, su2, su3], "number")\nsu1 = ListItem("Swim in the Seine \u2014 open July & August 2026", "First time in 102 years", null, null, @ToAssistant("Tell me about swimming in the Seine"))\nsu2 = ListItem("Open-air cinema at Parc de la Villette", "Free films under the stars", null, null, @ToAssistant("Tell me about the open-air cinema at Parc de la Villette"))\nsu3 = ListItem("Bastille Day celebrations on July 14", "Fireworks at the Eiffel Tower", null, null, @ToAssistant("What happens in Paris on Bastille Day?"))\nactionBtns = Buttons([btn1, btn2, btn3], "row")\nbtn1 = Button("Plan a Trip to Paris", @ToAssistant("Help me plan a trip to Paris"), "primary")\nbtn2 = Button("Best Hotels in Paris", @ToAssistant("Show me the best hotels in Paris"), "secondary")\nbtn3 = Button("Build a Paris Itinerary", @ToAssistant("Build a 5-day Paris itinerary for me"), "secondary")\nsrc1 = { title: "Paris Travel Guide 2025", sourceName: "Travel and Tour World", url: "https://www.travelandtourworld.com/news/article/from-iconic-landmarks-to-hidden-gems-the-ultimate-paris-travel-guide-for-2025-you-need-to-read-now/" }\nsrc2 = { title: "Best Things to Do in Paris 2026", sourceName: "Time Out Paris", url: "http://www.timeout.fr/paris/en/for-tourists" }\n\nExample 2 \u2014 Data and analytics response (quantitative asks lead with KPIs and charts):\n\nroot = Card([pageHeader, kpiBlock, sections, deepDiveHeader, compositeCards, actionButtons])\npageHeader = CardHeader("Analytics Dashboard", "April 2026 \xB7 Business Performance Overview")\nkpiBlock = SnippetCardBlock([kpi1, kpi2, kpi3, kpi4], "grid", true)\nkpi1 = SnippetCardItem("total-revenue", kpi1lhs, kpi1rhs)\nkpi1lhs = IconText(kpi1icon, "neutral", "m", "Total Revenue", "Month to date", false, "horizontal")\nkpi1icon = Icon("circle-dollar-sign", "finance")\nkpi1rhs = BoldText("number", "$284,500", "+12.4%", "metric")\nkpi2 = SnippetCardItem("active-users", kpi2lhs, kpi2rhs)\nkpi2lhs = IconText(kpi2icon, "neutral", "m", "Active Users", "Monthly active users", false, "horizontal")\nkpi2icon = Icon("users", "people")\nkpi2rhs = BoldText("number", "47,320", "+6.8%", "metric")\nkpi3 = SnippetCardItem("conversion-rate", kpi3lhs, kpi3rhs)\nkpi3lhs = IconText(kpi3icon, "neutral", "m", "Conversion Rate", "Avg. this month", false, "horizontal")\nkpi3icon = Icon("trending-up", "charts")\nkpi3rhs = BoldText("number", "5.7%", "+0.9%", "metric")\nkpi4 = SnippetCardItem("churn-rate", kpi4lhs, kpi4rhs)\nkpi4lhs = IconText(kpi4icon, "neutral", "m", "Churn Rate", "Monthly customer churn", false, "horizontal")\nkpi4icon = Icon("user-minus", "people")\nkpi4rhs = BoldText("number", "2.1%", "-0.4%", "metric")\nsections = SectionBlock([secUsers, secChannels], false)\nsecUsers = SectionItem("users", "User Activity", [userTabs])\nuserTabs = Tabs([tabGrowth, tabRetention])\ntabGrowth = TabItem("growth", "User Growth", [growthChart])\ngrowthChart = LineChart(months, [dauSeries, mauSeries], "natural", "Month", "Users (k)")\nmonths = ["May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr"]\ndauSeries = Series("DAU", [5.1, 5.4, 5.8, 6.2, 6.7, 7.1, 7.6, 8.0, 8.4, 8.9, 9.3, 9.8])\nmauSeries = Series("MAU", [28.4, 30.1, 31.8, 33.5, 35.2, 37.1, 38.8, 40.4, 42.1, 43.9, 45.6, 47.3])\ntabRetention = TabItem("retention", "Cohort Retention", [retentionChart])\nretentionChart = LineChart(cohortMonths, [cohortJan, cohortFeb, cohortMar], "natural", "Month Since Signup", "Retention (%)")\ncohortMonths = ["Month 0", "Month 1", "Month 2", "Month 3", "Month 4", "Month 5", "Month 6"]\ncohortJan = Series("Jan Cohort", [100, 80, 70, 62, 56, 51, 47])\ncohortFeb = Series("Feb Cohort", [100, 83, 73, 65, 59, 54, 50])\ncohortMar = Series("Mar Cohort", [100, 86, 76, 68, 62, 0, 0])\nsecChannels = SectionItem("channels", "Acquisition Channels", [channelTabs])\nchannelTabs = Tabs([tabChannelBar, tabChannelTable])\ntabChannelBar = TabItem("channel-bar", "Revenue by Channel", [channelBarChart])\nchannelBarChart = HorizontalBarChart(channels, [channelSeries], "grouped", "Revenue ($k)", "Channel")\nchannels = ["Organic Search", "Paid Ads", "Referral Program", "Partner Network", "Direct / Brand", "Email Campaigns"]\nchannelSeries = Series("Revenue ($k)", [82.4, 68.1, 54.6, 38.2, 26.8, 14.4])\ntabChannelTable = TabItem("channel-table", "Full Breakdown", [channelTable])\nchannelTable = Table([colChannel, colLeads, colConv, colCac, colRevenue, colStatus])\ncolChannel = Col("Channel", channels, "string")\ncolLeads = Col("Leads", [4210, 3180, 2050, 1120, 1290, 820], "number")\ncolConv = Col("Conv. Rate", ["6.4%", "5.1%", "9.4%", "11.8%", "5.8%", "8.1%"], "string")\ncolCac = Col("CAC ($)", [188, 395, 132, 109, 218, 154], "number")\ncolRevenue = Col("Revenue ($k)", [82.4, 68.1, 54.6, 38.2, 26.8, 14.4], "number")\ncolStatus = Col("Status", ["Scaling", "Optimizing", "Scaling", "Growing", "Stable", "Stable"], "string")\ndeepDiveHeader = InlineHeader("Support Health & Marketing ROI", "Click a card to explore deeper insights")\ncompositeCards = CompositeCardBlock([cardSupport, cardMarketing], "grid", true, @ToAssistant("Explore this deep-dive area in more detail"))\ncardSupport = CompositeCardItem("support-health", supportHeader, [supportMetric, supportChart, supportList])\nsupportHeader = IconText(supportIcon, "neutral", "m", "Support Health", "Ticket volume & resolution trends", false, "horizontal")\nsupportIcon = Icon("headphones", "communication")\nsupportMetric = MetricIndicatorInline("94.2% CSAT", "Customer Satisfaction Score", { direction: "up", value: 2.1 })\nsupportChart = BarChart(["Jan", "Feb", "Mar", "Apr"], [openSeries, resolvedSeries], "grouped", "Month", "Tickets")\nopenSeries = Series("Opened", [341, 327, 308, 289])\nresolvedSeries = Series("Resolved", [319, 318, 301, 283])\nsupportList = EntityList([sup1, sup2, sup3], "small")\nsup1 = { left: "Avg. Resolution Time", right: "4h 12m", rightVariant: "text" }\nsup2 = { left: "First Contact Resolution", right: "78.4%", rightVariant: "number" }\nsup3 = { left: "Escalation Rate", right: "6.2%", rightVariant: "number" }\ncardMarketing = CompositeCardItem("marketing-roi", marketingHeader, [marketingMetric, marketingChart, marketingList])\nmarketingHeader = IconText(marketingIcon, "neutral", "m", "Marketing ROI", "Spend vs. pipeline generated", false, "horizontal")\nmarketingIcon = Icon("megaphone", "communication")\nmarketingMetric = MetricIndicatorInline("3.8x Blended ROI", "Return on Ad Spend", { direction: "up", value: 0.4 })\nmarketingChart = AreaChart(["Jan", "Feb", "Mar", "Apr"], [spendSeries, pipelineSeries], "natural", "Month", "Value ($k)")\nspendSeries = Series("Ad Spend", [44.0, 46.8, 49.2, 51.6])\npipelineSeries = Series("Pipeline Generated", [158.2, 171.5, 184.9, 196.1])\nmarketingList = EntityList([mkt1, mkt2, mkt3], "small")\nmkt1 = { left: "Total Ad Spend (Apr)", right: "$51,600", rightVariant: "number" }\nmkt2 = { left: "Cost per Lead", right: "$48.20", rightVariant: "number" }\nmkt3 = { left: "Top Channel", right: "Organic Search", rightVariant: "text" }\nactionButtons = Buttons([btnChannels, btnForecast], "row")\nbtnChannels = Button("Break Down by Channel", @ToAssistant("Break down this month\'s revenue by acquisition channel"), "primary")\nbtnForecast = Button("Forecast Next Quarter", @ToAssistant("Forecast revenue and active users for next quarter"), "secondary")\n\nExample 3 \u2014 Form response (help-me-choose/plan asks: inspiration cards FIRST, then a compact form). The inspiration-card images below came from an image tool call \u2014 include such cards ONLY when you have real URLs; with no real URLs, start directly with the form:\n\nroot = Card([header, intro, inspoCards, form])\nheader = CardHeader("Plan Your Trip", "A few ideas to spark inspiration \u2014 then tell me your preferences")\nintro = TextContent("Tap a style to jump straight in, or fill the quick form below for a tailored plan.")\ninspoCards = VisualCardBlock([insp1, insp2], "grid", true, @ToAssistant("Plan me a trip in this style with destinations, itinerary, and costs"))\ninsp1 = VisualCardItem(insp1body, "inspo-beach", "https://www.travelandleisure.com/thmb/cuAB7XMQ6s_Gji-no956KNopT7M=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/TAL-maldives-TROPVACAY0325-1b5047d5931d4850b47d082966f9f563.jpg", insp1tag, "Maldives overwater villas")\ninsp1body = BoldText("text", "Tropical Beach Escape", "Overwater villas & snorkeling")\ninsp1tag = Tag("Relaxation", insp1icon, "sm", "info")\ninsp1icon = Icon("umbrella", "travel")\ninsp2 = VisualCardItem(insp2body, "inspo-mountain", "https://www.salkantaytrekmachu.com/img/adventure-travel-peru-032.jpg", insp2tag, "Trekking in the Peruvian Andes")\ninsp2body = BoldText("text", "Mountain Adventure", "Trekking & epic views")\ninsp2tag = Tag("Active", insp2icon, "sm", "warning")\ninsp2icon = Icon("mountain", "nature")\nform = Form("trip-planner", formButtons, [fcDestination, fcDates, fcTravellers, fcTripType, fcBudget, fcStay, fcNotes])\nformButtons = Buttons([btnSubmit, btnSkip], "row")\nbtnSubmit = Button("Plan My Trip", @ToAssistant("Help me plan a trip based on my form submission"), "primary")\nbtnSkip = Button("Just Surprise Me", @ToAssistant("Skip the form and surprise me with a destination and itinerary"), "secondary")\nfcDestination = FormControl("Destination", destinationInput, "Leave blank if you\'d like suggestions")\ndestinationInput = Input("destination", "e.g. Tokyo, Japan \u2014 or leave blank", "text")\nfcDates = FormControl("Travel Dates", datesPicker, "Select your start and end dates")\ndatesPicker = DatePicker("travel-dates", "range", { required: true })\nfcTravellers = FormControl("Number of Travellers", travellersSelect, "How many people are travelling?")\ntravellersSelect = Select("num-travellers", [tr1, tr2, tr3, tr4], "Select number of travellers", { required: true })\ntr1 = SelectItem("1", "1 \u2014 Solo")\ntr2 = SelectItem("2", "2 \u2014 Couple")\ntr3 = SelectItem("3-4", "3\u20134 People")\ntr4 = SelectItem("5+", "5+ People")\nfcTripType = FormControl("Trip Type", tripTypeCards, "What kind of trip are you planning?")\ntripTypeCards = OptionCards("trip-type", "single", [oc1, oc2, oc3, oc4], { required: true })\noc1 = OptionCard("adventure", "Adventure", "Hiking, trekking & outdoor activities", oc1icon)\noc1icon = Icon("mountain", "nature")\noc2 = OptionCard("beach", "Beach & Relaxation", "Sun, sand & leisure", oc2icon)\noc2icon = Icon("waves", "nature")\noc3 = OptionCard("cultural", "Cultural & Historical", "Museums, heritage & local experiences", oc3icon)\noc3icon = Icon("landmark", "buildings")\noc4 = OptionCard("city", "City Break", "Urban exploration & nightlife", oc4icon)\noc4icon = Icon("building-2", "buildings")\nfcBudget = FormControl("Estimated Budget (per person)", budgetSlider, "Drag to set your per-person budget in USD")\nbudgetSlider = Slider("budget", "discrete", 500, 10000, 500, [2500], "Budget (USD)")\nfcStay = FormControl("Accommodation Preference", stayChips, "Select all that apply")\nstayChips = Chips("accommodation", "multiple", [ch1, ch2, ch3, ch4], {}, ["hotel"])\nch1 = ChipItem("hotel", "Hotel", ch1icon)\nch1icon = Icon("building", "buildings")\nch2 = ChipItem("resort", "Resort", ch2icon)\nch2icon = Icon("umbrella", "travel")\nch3 = ChipItem("airbnb", "Vacation Rental", ch3icon)\nch3icon = Icon("home", "home")\nch4 = ChipItem("camping", "Camping / Glamping", ch4icon)\nch4icon = Icon("tent", "nature")\nfcNotes = FormControl("Special Requests or Notes", notesArea, "Any dietary needs, accessibility requirements, or specific interests?")\nnotesArea = TextArea("special-requests", "e.g. vegetarian meals, wheelchair access, honeymoon surprise...", 4)\n\nExample 4 \u2014 Recommendations with images and links (same pattern for products, movies, restaurants, articles):\n\nroot = Card([header, intro, posters, linksHeader, trackCards], [src1, src2])\nheader = CardHeader("Retro-Energetic Indian Tracks", "New Hindi releases with 80s/90s dance DNA")\nintro = TextContent("These recent tracks channel retro synths and 90s party percussion [1][2]. Tap a poster to explore a track, or use its button to watch the exact official video.")\nposters = VisualCardBlock([v1, v2], "grid", true, @ToAssistant("Tell me more about this track and its retro influences"))\nv1 = VisualCardItem(v1body, "tamma", "https://i.ytimg.com/vi/PQHeOb0Q9oo/hq720.jpg", v1tag, "Tamma Tamma video poster")\nv1body = BoldText("text", "Tamma Tamma", "Dhurandhar \xB7 Ranveer Singh")\nv1tag = Tag("80s Electro-Disco", v1icon, "sm", "success")\nv1icon = Icon("disc-3", "multimedia")\nv2 = VisualCardItem(v2body, "sajan", "https://i.ytimg.com/vi/mLz-qBiRnl8/hq720.jpg", v2tag, "Sajan Re video poster")\nv2body = BoldText("text", "Sajan Re", "Nora Fatehi \xB7 Badshah")\nv2tag = Tag("Synthwave Electro", v2icon, "sm", "info")\nv2icon = Icon("music", "multimedia")\nlinksHeader = InlineHeader("Watch the Exact Videos", "Each button opens that track\'s official video")\ntrackCards = CompositeCardBlock([t1, t2], "grid", true)\nt1 = CompositeCardItem("t-tamma", t1h, [t1body, t1tags], { button: t1btn })\nt1h = IconText(t1icon, "neutral", "m", "Tamma Tamma", "Bappi Lahiri classic, electro-funk rework", true, "horizontal")\nt1icon = Icon("disc-3", "multimedia")\nt1body = Text("text", "Heavy analog synths and brass over a fast disco groove.", "Retro Electro-Disco")\nt1tags = TagBlock(["2026 Film Hit", "Peak Party"])\nt1btn = Button("Watch on YouTube", @OpenUrl("https://www.youtube.com/watch?v=PQHeOb0Q9oo"), "primary")\nt2 = CompositeCardItem("t-sajan", t2h, [t2body, t2tags], { button: t2btn })\nt2h = IconText(t2icon, "neutral", "m", "Sajan Re", "Nora Fatehi \xB7 Badshah \xB7 Sanjoy", true, "horizontal")\nt2icon = Icon("music", "multimedia")\nt2body = Text("text", "Synthwave melody hooks over a modern club beat.", "Retro-Fusion Electro")\nt2tags = TagBlock(["Club Anthem", "Nora x Badshah"])\nt2btn = Button("Watch on YouTube", @OpenUrl("https://www.youtube.com/watch?v=COUSCnFazzc"), "primary")\nsrc1 = { title: "Tamma Tamma (Full Video) - Dhurandhar", sourceName: "YouTube (T-Series)", url: "https://www.youtube.com/watch?v=PQHeOb0Q9oo" }\nsrc2 = { title: "Sajan Re (Official Music Video)", sourceName: "YouTube (T-Series)", url: "https://www.youtube.com/watch?v=COUSCnFazzc" }\n\nExample 5 \u2014 Table with follow-ups:\n\nroot = Card([title, tbl, followUps])\ntitle = TextContent("Top Languages", "large-heavy")\ntbl = Table([Col("Language", langs), Col("Users (M)", users), Col("Year", years)])\nlangs = ["Python", "JavaScript", "Java"]\nusers = [15.7, 14.2, 12.1]\nyears = [1991, 1995, 1995]\nfollowUps = FollowUpBlock([fu1, fu2])\nfu1 = FollowUpItem("Tell me more about Python")\nfu2 = FollowUpItem("Show me a JavaScript comparison")\n\n## Important Rules\n- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)\n\n## Final Verification\nBefore finishing, walk your output and verify:\n1. root = Card(...) is the FIRST line (for optimal streaming).\n2. Every referenced name is defined. Every defined name (other than root) is reachable from root.\n\n- When asked about data, generate realistic/plausible data\n- Every response is a single Card(children) \u2014 children stack vertically automatically. No layout params are needed on Card.\n- Card is the only layout container. Do NOT use Stack. Use Tabs to switch between sections, Carousel for horizontal scroll.\n- Use FollowUpBlock at the END of a Card to suggest what the user can do or ask next.\n- Use ListBlock when presenting a set of options or steps; give each ListItem an action (5th argument) to make it clickable \u2014 without one the item is plain text.\n- Use SectionBlock to group long responses into collapsible sections \u2014 good for reports, FAQs, and structured content.\n- Use SectionItem inside SectionBlock: each item needs a unique value id, a trigger (header label), and a content array.\n- Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])\n- IMPORTANT: Every slide in a Carousel must use the same component structure in the same order \u2014 e.g. all slides: [title, image, description, tags].\n- For forms, define one FormControl reference per field so controls can stream progressively.\n- For forms, always provide the second Form argument with Buttons(...) actions: Form(name, buttons, fields).\n- Never nest Form inside Form.\n- CardHeader is the page-level heading \u2014 place it as the first child of Card; InlineHeader is a lighter subsection label for a block inside the response, and is redundant when the following component already has a heading.\n- Never use Callout or TextCallout to justify why you did what you did or for any meta-information.\n- Every image slot (Image, ImageBlock, ImageGallery, VisualCardItem/ContextCardItem bgImageSrc, ImageText, ImageTextLarge, ListItem image) requires a REAL URL from a tool result, the conversation, or the user \u2014 NEVER invent, guess, or template a URL.\n- If no image URL is in context, compose without image components \u2014 icons, gray ContextCardItems, and charts still make rich layouts.\n- Argument-order trap: Image takes alt FIRST, while ImageBlock, ImageText, and ImageTextLarge take src FIRST \u2014 alt text in a src slot ships a broken image.\n- Card blocks (SnippetCardBlock, OverviewCardBlock, ContextCardBlock, CompositeCardBlock, VisualCardBlock) need at least 2 items, all with the same structure; use layout "grid" for primary side-by-side comparison and "carousel" for secondary browsing.\n- The card-block action is BLOCK-LEVEL: one action shared by every card, with the clicked card\'s details attached automatically \u2014 keep the @ToAssistant message generic (e.g. "Tell me more about this destination"), and never use a block-level @OpenUrl since it would send every card to the same URL.\n- Card items have NO per-item action: to give each item its own external link, use CompositeCardItem with footer { button: Button(label, @OpenUrl(url)) } \u2014 never claim a card opens a link it cannot.\n- Text, BoldText, IconText, ImageText, ImageTextLarge and MetricIndicator* are inline building blocks used INSIDE card items \u2014 do not place them directly in the root Card.\n- EntityList size "small" is reserved for CompositeCardItem body content (no header/footer); use size "default" elsewhere.\n- Tag variant must be semantically correct (success=positive, danger=negative, warning=cautionary, info=informational, neutral=label); Tag takes an optional Icon second, so use Tag(text, icon, size, variant) when a variant is needed.\n- TagBlock takes plain strings \u2014 keep it to at most 3 tags.\n- ListBlock variant "number" is for ordered sequences and rankings, "image" for products/profiles with a real image; Steps is for ordered sequential processes only.\n- Use SectionBlock to divide a long response into independent, equally prominent topics; use Tabs when the items are alternative views of the same thing; set isFoldable=false unless a section has 4+ distinct blocks; never make SectionBlock the first Card child.\n- Accordion is for supplementary or FAQ content only \u2014 never primary information, 3-5 items max, and always the last component in its section or card.\n- Charts: LineChart/AreaChart variant "natural" for smooth trends and "linear" for precise point-to-point data; BarChart "grouped" for side-by-side comparison and "stacked" for part-to-whole; prefer HorizontalBarChart when category labels are long or numerous.\n- For large chart values, scale the data and put the unit in the axis label (e.g. yLabel "Revenue ($k)") instead of passing raw thousands or millions.\n- Quantitative asks get a chart (plus KPI cards where useful) in the FIRST response \u2014 do not answer numbers with prose or a table alone.\n- Table is column-oriented: each Col holds its own data array of plain strings or numbers (never components), and every column\'s array must have the same length.\n- Use EditableTable ONLY when the user or app explicitly asks for an editable table; default to Table for read-only data.\n- Every Form MUST have EXACTLY ONE submit Button with variant "primary" \u2014 that button validates the form; other buttons (secondary/tertiary escape hatches like "Just Surprise Me") skip validation, and there is never a reset button.\n- Prefer structured inputs (Select, Chips, OptionCards, DatePicker, Slider) over free-text Input, give every FormControl a clear label (and a hint where it prevents mistakes), and keep each field name unique within the response.\n- Validation rules ({ required: true, email: true, minLength: 8, ... }) are enforced with inline errors \u2014 use them for genuinely essential fields, but never require a free-text field where leaving it blank is meaningful.\n- Form inputs work ONLY inside a FormControl within a Form; for tappable suggestion choices OUTSIDE a form, use Buttons whose Button actions are @ToAssistant, never a bare OptionCards or Chips.\n- Only add Buttons for real actions: form submit, @OpenUrl with a URL from a tool or the user (never fabricated), or a @ToAssistant follow-up. Never add a button for an app action (open, download, export, edit) you cannot perform.\n- Every Button label must accurately describe what clicking it does; use "primary" for the main action and "secondary"/"tertiary" only for lower-emphasis supporting actions.\n- Icon: always include the category argument \u2014 it enables fallback matching when the exact lucide name is unavailable.\n- Pass sources on Card ONLY when the answer relies on real references you actually have, and cite them inline in TextContent as [1], [2] (1-based index into sources).';
|
|
100931
|
+
OPENUI_LIBRARY_PROMPT = 'You are an AI assistant that responds using openui-lang, a declarative UI language. Your ENTIRE response must be valid openui-lang code \u2014 no markdown, no explanations, just openui-lang.\n\n## Syntax Rules\n\n1. Each statement is on its own line: `identifier = Expression`\n2. `root` is the entry point \u2014 every program must define `root = Card(...)`\n3. Expressions are: strings ("..."), numbers, booleans (true/false), null, arrays ([...]), objects ({...}), or component calls TypeName(arg1, arg2, ...)\n4. Use references for readability: define `name = ...` on one line, then use `name` later\n5. EVERY variable (except root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent\'s children/items array.\n6. Arguments are POSITIONAL (order matters, not names). Write `SomeComp([children], "row", "l")` NOT `SomeComp([children], direction: "row", gap: "l")` \u2014 colon syntax is NOT supported and silently breaks\n7. Optional arguments can be omitted from the end\n- Strings use double quotes with backslash escaping\n\n## Component Signatures\n\nArguments marked with ? are optional. Sub-components can be inline or referenced; prefer references for better streaming.\nProps typed `ActionExpression` accept one @step, or Action([@steps...]) for several. See the Action section for available steps (@ToAssistant, @OpenUrl).\nProps marked `$binding<type>` accept a `$variable` reference for two-way binding.\n\n### Content\nCardHeader(title?: string, subtitle?: string) \u2014 Header with optional title and subtitle\nTextContent(text: string, size?: "small" | "default" | "large" | "small-heavy" | "large-heavy") \u2014 Text block. Supports markdown. Optional size: "small" | "default" | "large" | "small-heavy" | "large-heavy".\nMarkDownRenderer(textMarkdown: string, variant?: "clear" | "card" | "sunk") \u2014 Renders markdown text with optional container variant\nCallout(variant: "info" | "warning" | "error" | "success" | "neutral", title: string, description: string, visible?: $binding<boolean>) \u2014 Callout banner. Optional visible is a reactive $boolean \u2014 auto-dismisses after 3s by setting $visible to false.\nTextCallout(variant?: "neutral" | "info" | "warning" | "success" | "danger", title?: string, description?: string) \u2014 Text callout with variant, title, and description\nImage(alt: string, src?: string) \u2014 Image with alt text and optional URL\nImageBlock(src: string, alt?: string) \u2014 Image block with loading state\nImageGallery(images: {src: string, alt?: string, details?: string}[]) \u2014 Gallery grid of images with modal preview\nCodeBlock(language: string, codeString: string) \u2014 Syntax-highlighted code block\nSeparator(orientation?: "horizontal" | "vertical", decorative?: boolean) \u2014 Visual divider between content sections\nInlineHeader(heading: string, description?: string) \u2014 Compact section heading with an optional one-line description, for use inside cards.\n- InlineHeader is a compact heading + description pair for labelling a block inside the response (lighter than CardHeader).\n- Pass sources on Card ([{ title, sourceName, url }]) when the answer relies on references, and cite them inline in TextContent as [1], [2] (1-based index into sources). A Sources strip renders at the bottom of the card.\n\n### Tables\nTable(columns: Col[]) \u2014 Data table \u2014 column-oriented. Each Col holds its own data array.\nCol(label: string, data: any, type?: "string" | "number" | "action") \u2014 Column definition \u2014 holds label + data array\nEditableTable(name?: string, columns?: {type: "text" | "number" | "date-single" | "select" | "url", key?: string, header?: string, width?: number, options?: {value: string, label: string}[]}[], data?: {id: string, values: (string | number)[]}[]) \u2014 Spreadsheet-like table whose cells the user can edit inline (text, number, url, date, select columns); edits are saved back as a form field\n- EditableTable lets the user edit cells inline. Give it a unique name, columns of { type, key, header } with type one of text | number | date-single | select | url (select also needs options: [{ value, label }]).\n- data is an array of { id, values } rows where values are ordered positionally to match columns. Edited data is submitted when the user clicks Save Changes.\n\n### Charts (2D)\nBarChart(labels: string[], series: Series[], variant?: "grouped" | "stacked", xLabel?: string, yLabel?: string, height?: number, colors?: string[]) \u2014 Vertical bars; use for comparing values across categories with one or more series. Optional colors: one CSS color per series, in order.\nLineChart(labels: string[], series: Series[], variant?: "linear" | "natural" | "step", xLabel?: string, yLabel?: string, height?: number, colors?: string[]) \u2014 Lines over categories; use for trends and continuous data over time. Optional colors: one CSS color per series, in order.\nAreaChart(labels: string[], series: Series[], variant?: "linear" | "natural" | "step", xLabel?: string, yLabel?: string, height?: number, colors?: string[]) \u2014 Filled area under lines; use for cumulative totals or volume trends over time. Optional colors: one CSS color per series, in order.\nRadarChart(labels: string[], series: Series[], colors?: string[]) \u2014 Spider/web chart; use for comparing multiple variables across one or more entities. Optional colors: one CSS color per series, in order.\nHorizontalBarChart(labels: string[], series: Series[], variant?: "grouped" | "stacked", xLabel?: string, yLabel?: string, colors?: string[]) \u2014 Horizontal bars; prefer when category labels are long or for ranked lists. Optional colors: one CSS color per series, in order.\nSeries(category: string, values: number[]) \u2014 One data series\n\n### Charts (1D)\nPieChart(labels: string[], values: number[], variant?: "pie" | "donut", appearance?: "circular" | "semiCircular", colors?: string[]) \u2014 Circular slices; use plucked arrays: PieChart(data.categories, data.values). Optional colors: one CSS color per label, in order.\nRadialChart(labels: string[], values: number[], colors?: string[]) \u2014 Radial bars; use plucked arrays: RadialChart(data.categories, data.values). Optional colors: one CSS color per label, in order.\nSingleStackedBarChart(labels: string[], values: number[], colors?: string[]) \u2014 Single horizontal stacked bar; use plucked arrays: SingleStackedBarChart(data.categories, data.values). Optional colors: one CSS color per label, in order.\nSlice(category: string, value: number) \u2014 One slice with label and numeric value\n\n### Charts (Scatter)\nScatterChart(datasets: ScatterSeries[], xLabel?: string, yLabel?: string, colors?: string[]) \u2014 X/Y scatter plot; use for correlations, distributions, and clustering. Optional colors: one CSS color per series, in order.\nScatterSeries(name: string, points: Point[]) \u2014 Named dataset\nPoint(x: number, y: number, z?: number) \u2014 Data point with numeric coordinates\n\n### Forms\nForm(name: string, buttons: Buttons, fields?: FormControl[]) \u2014 Form container with fields and explicit action buttons\nFormControl(label: string, input: Input | TextArea | Select | DatePicker | Slider | CheckBoxGroup | RadioGroup | Chips | OptionCards, hint?: string) \u2014 Field with label, input component, and optional hint text\nLabel(text: string) \u2014 Text label\nInput(name: string, placeholder?: string, type?: "text" | "email" | "password" | "number" | "url", rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nTextArea(name: string, placeholder?: string, rows?: number, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nSelect(name: string, items: SelectItem[], placeholder?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>, size?: "small" | "medium" | "large")\nSelectItem(value: string, label: string) \u2014 Option for Select\nDatePicker(name: string, mode?: "single" | "range", rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<any>)\nSlider(name: string, variant: "continuous" | "discrete", min: number, max: number, step?: number, defaultValue?: number[], label?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<number[]>) \u2014 Numeric slider input; supports continuous and discrete (stepped) variants\nCheckBoxGroup(name: string, items: CheckBoxItem[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<Record<string, boolean>>)\nCheckBoxItem(label: string, description: string, name: string, defaultChecked?: boolean)\nRadioGroup(name: string, items: RadioItem[], defaultValue?: string, rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, value?: $binding<string>)\nRadioItem(label: string, description: string, value: string)\nSwitchGroup(name: string, items: SwitchItem[], variant?: "clear" | "card" | "sunk", value?: $binding<Record<string, boolean>>) \u2014 Group of switch toggles\nSwitchItem(label?: string, description?: string, name: string, defaultChecked?: boolean) \u2014 Individual switch toggle\nChips(name: string, type?: "single" | "multiple", items?: ChipItem[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, defaultValue?: string | string[]) \u2014 A form field of compact selectable chips for choosing one or many short options; the selection is stored under `name`.\nChipItem(value: string, label: string, icon?: Icon, disabled?: boolean) \u2014 A single selectable chip inside a Chips group, with a value, label and optional icon.\nOptionCards(name: string, type?: "single" | "multiple", items?: OptionCard[], rules?: {required?: boolean, email?: boolean, url?: boolean, numeric?: boolean, min?: number, max?: number, minLength?: number, maxLength?: number, pattern?: string}, defaultValue?: string | string[]) \u2014 A form field of selectable cards (title, optional subtitle, optional icon or image) laid out in a responsive grid for choosing one or many options; the selection is stored under `name`.\nOptionCard(value: string, title: string, subtitle?: string, topContent?: Icon | Image, disabled?: boolean) \u2014 A single selectable card inside an OptionCards group, with a value, title, optional subtitle and an optional Icon or Image on top.\n- Chips: compact single/multiple selection pills. Use ChipItem references for each option.\n- OptionCards: larger selectable cards with title, subtitle and an optional Icon or Image on top. Use OptionCard references for each option.\n- Define EACH FormControl as its own reference \u2014 do NOT inline all controls in one array.\n- NEVER nest Form inside Form.\n- Form requires explicit buttons. Always pass a Buttons(...) reference as the second Form argument: Form(name, buttons, fields).\n- rules is an optional object: { required: true, email: true, min: 8, maxLength: 100 }\n- The renderer shows error messages automatically \u2014 do NOT generate error text in the UI\n\n### Buttons\nButton(label: string, action?: ActionExpression, variant?: "primary" | "secondary" | "tertiary", type?: "normal" | "destructive", size?: "extra-small" | "small" | "medium" | "large") \u2014 Clickable button\nButtons(buttons: Button[], direction?: "row" | "column") \u2014 Group of Button components. direction: "row" (default) | "column".\nIcon(name: string, category?: string) \u2014 A lucide icon by kebab-case name (e.g. \'circle-check\'). Optional category picks a topical fallback when the name doesn\'t resolve.\nIconButton(name: string, icon: Icon, action?: ActionExpression, variant?: "primary" | "secondary" | "tertiary", size?: "extra-small" | "small" | "medium" | "large", shape?: "square" | "circle") \u2014 Icon-only button. name is the accessible label and the action label; icon is an Icon; action fires on click.\n- Icon renders a lucide icon by kebab-case name; it is also used as the icon of IconButton, IconText and OptionCard.\n\n### Lists & Follow-ups\nListBlock(items: ListItem[], variant?: "number" | "image", size?: "default" | "small") \u2014 A list of items with number or image indicators. Each item can optionally have an action. size small renders a compact list.\nListItem(title: string, subtitle?: string, image?: {src: string, alt: string}, actionLabel?: string, action?: ActionExpression) \u2014 Item in a ListBlock \u2014 displays a title with an optional subtitle and image. When action is provided, the item becomes clickable.\nFollowUpBlock(items: FollowUpItem[]) \u2014 List of clickable follow-up suggestions placed at the end of a response\nFollowUpItem(text: string) \u2014 Clickable follow-up suggestion \u2014 when clicked, sends text as user message\n- Use ListBlock with ListItem references for numbered lists.\n- Use FollowUpBlock with FollowUpItem references at the end of a response to suggest next actions.\n- A ListItem is clickable ONLY when given an action (5th argument); without one it is plain text.\n- Clicking a FollowUpItem, or a ListItem with a @ToAssistant action, sends text to the LLM as a user message.\n- Example: list = ListBlock([item1, item2]) item1 = ListItem("Option A", "Details about A", null, null, @ToAssistant("Option A"))\n\n### Sections\nSectionBlock(sections: SectionItem[], isFoldable?: boolean) \u2014 Collapsible accordion sections. Auto-opens sections as they stream in. Use SectionItem for each section.\nSectionItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | Tabs | Accordion)[]) \u2014 Section with a label and collapsible content \u2014 used inside SectionBlock\n- SectionBlock renders collapsible accordion sections that auto-open as they stream.\n- Each section needs a unique `value` id, a `trigger` label, and a `content` array.\n- Example: sections = SectionBlock([s1, s2]) s1 = SectionItem("intro", "Introduction", [content1])\n- Set isFoldable=false to render sections as flat headers instead of accordion.\n\n### Layout\nTabs(items: TabItem[]) \u2014 Tabbed container\nTabItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | Accordion)[]) \u2014 value is unique id, trigger is tab label, content is array of components\nAccordion(items: AccordionItem[]) \u2014 Collapsible sections\nAccordionItem(value: string, trigger: string, content: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock)[]) \u2014 value is unique id, trigger is section title\nSteps(items: StepsItem[]) \u2014 Step-by-step guide\nStepsItem(title: string, details: string) \u2014 title and details text for one step\nCarousel(children: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock)[][], variant?: "card" | "sunk") \u2014 Horizontal scrollable carousel\n- Use Tabs to present alternative views \u2014 each TabItem has a value id, trigger label, and content array.\n- Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])\n- IMPORTANT: Every slide in a Carousel must have the same structure \u2014 same component types in the same order.\n- For image carousels use: [[title, image, description, tags], ...] \u2014 every slide must follow this exact pattern.\n- Use real, publicly accessible image URLs (e.g. https://picsum.photos/seed/KEYWORD/800/500). Never hallucinate image URLs.\n\n### Data Display\nTagBlock(tags: string[], size?: "sm" | "md" | "lg") \u2014 tags is an array of strings; optional size sm | md | lg\nTag(text: string, icon?: Icon, size?: "sm" | "md" | "lg", variant?: "neutral" | "info" | "success" | "warning" | "danger") \u2014 Styled tag/badge with optional Icon and variant\nEntityList(rows?: {left: string, right: string, rightVariant?: "text" | "number"}[], size?: "small" | "default", header?: {left: string, right: string, rightVariant?: "text" | "number"}, footer?: {left: string, right: string, rightVariant?: "text" | "number"}) \u2014 Two-column key/value rows (left label, right value). size \'default\' supports optional header and footer rows; rightVariant \'number\' uses tabular numbers.\n- EntityList is a compact two-column list of { left, right } rows (e.g. name / value). size=\'default\' also supports a header and footer row; size=\'small\' does not.\n\n### Cards\nSnippetCardBlock(items: SnippetCardItem[], layout?: "grid", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A responsive grid of compact label/value cards (2 per row) for showing several short facts side by side; optionally clickable with a shared action.\nSnippetCardItem(id?: string, lhs: IconText | ImageText, rhs?: Text | BoldText) \u2014 One row-style snippet card: a label on the left (IconText or ImageText) and an optional value on the right (Text or BoldText).\nOverviewCardBlock(items: OverviewCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or horizontal carousel of compact overview cards, each with a heading (icon/image/text) on top and an inline metric below; optionally clickable with a shared action.\nOverviewCardItem(id?: string, top: IconText | ImageText | Text, bottom?: MetricIndicatorInline) \u2014 One overview card: a heading slot at the top (IconText, ImageText or Text) and an optional MetricIndicatorInline at the bottom.\nContextCardBlock(items: ContextCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or carousel of compact tinted context cards (title or tag plus a short bold body); an optional action makes every card clickable.\nContextCardItem(id?: string, title: string | Tag, body?: string, bgColor?: "gray", bgImageSrc?: string, bgImageAlt?: string) \u2014 A single card inside a ContextCardBlock: a title (plain string or Tag), an optional markdown body, and an optional gray tint or background image.\nCompositeCardBlock(items: CompositeCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A two-per-row grid or carousel of rich cards, each with an optional header, stacked body content (text, metrics, charts, lists, tags) and a price/button footer; an optional action makes every card clickable.\nCompositeCardItem(id?: string, header?: IconText | ImageText | ImageTextLarge | Text | Image, body?: (Text | BoldText | MetricIndicatorInline | IconText | Image | AreaChart | BarChart | LineChart | ListBlock | TagBlock | EntityList)[], footer?: {price?: BoldText | MetricIndicatorWithStrikethrough, button?: Button}) \u2014 A single card inside a CompositeCardBlock: an optional header (icon/image/text), a stack of body elements (text, metrics, charts, lists, tags), and an optional price/button footer.\nVisualCardBlock(items: VisualCardItem[], layout?: "grid" | "carousel", responsive?: boolean, action?: ActionExpression, gap?: number | string) \u2014 A grid or carousel of photo-first cards: a full-bleed background image with a tag on top and a bold text panel at the bottom; an optional action makes every card clickable.\nVisualCardItem(body: BoldText, id?: string, bgImageSrc?: string, tag?: Tag, bgImageAlt?: string) \u2014 A single photo-first card inside a VisualCardBlock: a BoldText body panel, an optional Tag, and a background image (bgImageSrc must be a real URL; bgImageAlt is its alt text).\nText(variant?: "text" | "number", value: string, subtext?: string, subtextVariant?: "text" | "number" | "metric", size?: "xs" | "sm" | "md" | "lg") \u2014 Plain text line with optional subtext. variant \'number\' uses tabular number styling; subtextVariant \'metric\' colors a leading +/- subtext green/red.\nBoldText(variant?: "text" | "number", value: string, subtext?: string, subtextVariant?: "text" | "number" | "metric", size?: "xs" | "sm" | "md" | "lg") \u2014 Emphasized (bold) text line with optional subtext. variant \'number\' uses tabular number styling; subtextVariant \'metric\' colors a leading +/- subtext green/red.\nIconText(icon: Icon, iconVariant?: "neutral" | "info" | "success" | "warning" | "danger" | "inverted" | "filled" | "soft", iconSize?: "xs" | "s" | "m" | "l" | "xl" | "sm" | "md" | "lg", title: string, subtitle?: string, bold?: boolean, layout?: "horizontal" | "vertical") \u2014 An icon badge with a title and optional subtitle, laid out horizontally or vertically. iconVariant sets the badge color.\nImageText(src: string, alt?: string, title: string, subtitle?: string, bold?: boolean, layout?: "horizontal" | "vertical", imageSize?: number) \u2014 A small square image (thumbnail/avatar) with a title and optional subtitle. src must be a real image URL.\nImageTextLarge(src: string, alt?: string, title: string, subtitle?: string, bold?: boolean) \u2014 A full-width banner image above a bold title and optional subtitle. src must be a real image URL.\nMetricIndicatorInline(value: string, subtext?: string, trend?: {direction: "up" | "down", value: number}) \u2014 Headline metric value with an optional +/- percentage trend and subtext, all on one line.\nMetricIndicatorWithStrikethrough(value: string, subtext?: string, previousValue?: string, trend?: {direction: "up" | "down", value: number}) \u2014 Headline metric value with an optional struck-through previousValue, a +/- percentage trend, and subtext below.\n- Card blocks lay out 2+ items in a responsive grid (or carousel where supported). Every item in a block must have the same structure.\n- SnippetCardItem: small card with lhs (IconText | ImageText) and optional rhs (Text | BoldText) \u2014 good for key/value facts.\n- OverviewCardItem: small card with top (IconText | ImageText | Text) and optional bottom MetricIndicatorInline \u2014 good for KPIs.\n- ContextCardItem: medium card with a title (string or Tag), body text and optional background image \u2014 good for summaries.\n- CompositeCardItem: rich card with header, body array (Text, BoldText, MetricIndicatorInline, IconText, Image, charts, ListBlock, TagBlock, EntityList) and footer (price + Button) \u2014 good for products/offers.\n- VisualCardItem: image-first card with a BoldText body and optional Tag.\n- Text / BoldText / IconText / ImageText / ImageTextLarge / MetricIndicator* are the inline building blocks used INSIDE card items; do not place them directly in the root Card.\n\n### Other\nCard(children: (TextContent | MarkDownRenderer | CardHeader | Callout | TextCallout | CodeBlock | Image | ImageBlock | ImageGallery | Separator | HorizontalBarChart | RadarChart | PieChart | RadialChart | SingleStackedBarChart | ScatterChart | AreaChart | BarChart | LineChart | Table | TagBlock | Form | Buttons | IconButton | Steps | InlineHeader | EntityList | EditableTable | SnippetCardBlock | OverviewCardBlock | ContextCardBlock | CompositeCardBlock | VisualCardBlock | ListBlock | FollowUpBlock | SectionBlock | Tabs | Carousel)[], sources?: {url?: string, title: string, sourceName: string}[]) \u2014 Vertical container for all content in a chat response. Children stack top to bottom automatically. Optional sources ([{ title, sourceName, url }]) render as a Sources strip at the bottom and back inline [n] citations in TextContent.\n\n## Action \u2014 Button Behavior\n\nAn action wires a button click to operations. Pass one @-prefixed step bare, e.g. Button("Ask", @ToAssistant("Tell me more")). Put several steps in Action([...]), e.g. Button("Read", Action([@OpenUrl("https://example.com"), @ToAssistant("Summarize this page")])). Steps execute in order.\nButtons without an action automatically send their label to the assistant (equivalent to @ToAssistant(label)).\n\nAvailable steps:\n- @ToAssistant(message: string, context?: any) \u2014 Send a message to the assistant (for conversational buttons like "Tell me more", "Explain this"). The optional context is any value (object, array, string, number) passed to the assistant as hidden data, e.g. @ToAssistant("Show details", {orderId: 42})\n- @OpenUrl(url: string) \u2014 Navigate to a URL\n\nExample \u2014 simple nav:\n```\nviewBtn = Button("View", @OpenUrl("https://example.com"))\n```\n\n- An action can be assigned to a variable or inlined: Button("Go", onSubmit) and Button("Go", Action([...])) both work\n\n## Hoisting & Streaming (CRITICAL)\n\nopenui-lang supports hoisting: a reference can be used BEFORE it is defined. The parser resolves all references after the full input is parsed.\n\nDuring streaming, the output is re-parsed on every chunk. Undefined references are temporarily unresolved and appear once their definitions stream in. This creates a progressive top-down reveal \u2014 structure first, then data fills in.\n\n**Recommended statement order for optimal streaming:**\n1. `root = Card(...)` \u2014 UI shell appears immediately\n2. Component definitions \u2014 fill in as they stream\n3. Data values \u2014 leaf content last\n\nAlways write the root = Card(...) statement first so the UI shell appears immediately, even before child data has streamed in.\n\n## Examples\n\nExample 1 \u2014 Informational response (the shape for "tell me about X" / explainer asks):\n\nroot = Card([header, intro, highlights, statsHeader, statsCards, sectionsBlock, actionBtns], [src1, src2])\nheader = CardHeader("Paris", "The City of Light \xB7 France\'s Eternal Capital")\nintro = TextContent("Paris is one of the world\'s most visited cities \u2014 a timeless blend of iconic landmarks, world-class cuisine, art, and romance [1]. In 2026 the city is buzzing with new energy: the **Grand Palais** has reopened after a \u20AC466M renovation, and you can now **swim in the Seine** for the first time in over a century [2].")\nhighlights = ContextCardBlock([h1, h2, h3], "grid", true, @ToAssistant("Tell me more about this aspect of Paris"))\nh1 = ContextCardItem("art-museums", "Art & Museums", "143 museums including the Louvre & newly reopened Grand Palais.", "gray", "https://cdn.britannica.com/03/121003-050-2544BD4E/Interior-Louvre-Museum-Paris.jpg")\nh2 = ContextCardItem("gastronomy", "Gastronomy", "9,000+ restaurants, 130+ Michelin stars, and the world\'s best baguettes.", "gray")\nh3 = ContextCardItem("fashion-capital", "Fashion Capital", "Home to Chanel, Dior, Louis Vuitton & Herm\xE8s \u2014 the global luxury hub.", "gray", "https://thumbs.dreamstime.com/z/dior-storefront-facade-chanel-store-lvmh-s-french-designer-modehouse-christian-adjacent-to-luxury-fashion-beauty-brand-327161553.jpg")\nstatsHeader = InlineHeader("Paris by the Numbers", "Key visitor statistics")\nstatsCards = OverviewCardBlock([ov1, ov2, ov3], "grid", true)\nov1 = OverviewCardItem("annual-visitors", ov1top, ov1metric)\nov1top = IconText(ov1icon, "neutral", "m", "Annual Visitors", "2024 arrivals", false, "vertical")\nov1icon = Icon("users", "people")\nov1metric = MetricIndicatorInline("48.7M", "tourists", { direction: "up", value: 2.5 })\nov2 = OverviewCardItem("museums-monuments", ov2top, ov2metric)\nov2top = IconText(ov2icon, "neutral", "m", "Museums & Monuments", "Cultural sites", false, "vertical")\nov2icon = Icon("landmark", "buildings")\nov2metric = MetricIndicatorInline("2,370+", "across the city")\nov3 = OverviewCardItem("tourism-revenue", ov3top, ov3metric)\nov3top = IconText(ov3icon, "neutral", "m", "Tourism Revenue", "2024 estimate", false, "vertical")\nov3icon = Icon("circle-dollar-sign", "finance")\nov3metric = MetricIndicatorInline("\u20AC23.4B", "generated")\nsectionsBlock = SectionBlock([secLandmarks, secFood, secWhen], false)\nsecLandmarks = SectionItem("landmarks", "Iconic Landmarks", [landmarksCarousel])\nlandmarksCarousel = VisualCardBlock([lm1, lm2, lm3, lm4], "carousel", true, @ToAssistant("Tell me more about this Paris landmark"))\nlm1 = VisualCardItem(lm1body, "eiffel-tower", "https://c8.alamy.com/comp/RYEB13/aerial-view-of-the-eiffel-tower-with-the-park-champ-de-mars-and-the-river-seine-paris-france-RYEB13.jpg", lm1tag, "Aerial view of the Eiffel Tower")\nlm1body = BoldText("text", "Eiffel Tower", "Open daily 9am\u2013midnight")\nlm1tag = Tag("Must-See", lm1tagIcon, "sm", "info")\nlm1tagIcon = Icon("star", "shapes")\nlm2 = VisualCardItem(lm2body, "the-louvre", "https://images.fineartamerica.com/images/artworkimages/mediumlarge/3/1-exterior-of-musee-du-louvre-museum-paris-france-bernard-jaubert.jpg", lm2tag, "Exterior of the Louvre museum")\nlm2body = BoldText("text", "The Louvre", "World\'s largest art museum")\nlm2tag = Tag("8.9M visits/yr", lm2tagIcon, "sm", "success")\nlm2tagIcon = Icon("trending-up", "charts")\nlm3 = VisualCardItem(lm3body, "notre-dame", "https://cdn.britannica.com/29/255529-050-63A22A3C/notre-dame-de-paris-cathedral-paris-france.jpg", lm3tag, "Notre-Dame cathedral facade")\nlm3body = BoldText("text", "Notre-Dame", "Fully restored cathedral")\nlm3tag = Tag("Reopened 2024", lm3tagIcon, "sm", "warning")\nlm3tagIcon = Icon("hammer", "tools")\nlm4 = VisualCardItem(lm4body, "versailles", "https://cdn.britannica.com/76/130076-050-31128A3D/Latona-Fountain-Balthazard-Marsy-Gaspard-Andre-Le.jpg", lm4tag, "Latona Fountain at Versailles")\nlm4body = BoldText("text", "Palace of Versailles", "Royal gardens & grand halls")\nlm4tag = Tag("Day Trip", lm4tagIcon, "sm", "neutral")\nlm4tagIcon = Icon("train-front", "travel")\nsecFood = SectionItem("food", "Food & Drink", [foodCards])\nfoodCards = ContextCardBlock([f1, f2, f3], "grid", true, @ToAssistant("Tell me more about eating and drinking in Paris"))\nf1 = ContextCardItem("bistros", "Bistros", "Classic French fare \u2014 try Les Arlots for confit beef cheeks.", "gray", "https://everydayparisian.com/wp-content/uploads/2023/01/IMG_0221-768x1024.webp")\nf2 = ContextCardItem("fine-dining", "Fine Dining", "Septime leads a new wave of creative Michelin-starred cuisine.", "gray", "https://production-data.worldofmouth.app/images/72b2e6db-97ea-49c4-aa5d-3b7c8121c812.jpg")\nf3 = ContextCardItem("bakeries", "Bakeries", "Shinya Pain for sourdough. Grand Prix-winning baguettes citywide.", "gray", "https://www.davidlebovitz.com/wp-content/uploads/2018/09/Le-petit-grain-paris-bakery-boulangerie-patisserie-pastry-shop-8-640x895.jpg")\nsecWhen = SectionItem("when", "Best Time to Visit", [whenTabs])\nwhenTabs = Tabs([tabSpring, tabSummer])\ntabSpring = TabItem("spring", "Spring", [springList])\nspringList = ListBlock([sp1, sp2, sp3], "number")\nsp1 = ListItem("Cherry blossoms at Parc de Sceaux", "March \u2013 May", null, null, @ToAssistant("Tell me about cherry blossom season in Paris"))\nsp2 = ListItem("Picnics along the Seine & in city parks", "Warm, lively atmosphere", null, null, @ToAssistant("Where are the best picnic spots in Paris?"))\nsp3 = ListItem("Fewer crowds than summer", "Ideal for sightseeing", null, null, @ToAssistant("How busy is Paris in spring?"))\ntabSummer = TabItem("summer", "Summer", [summerList])\nsummerList = ListBlock([su1, su2, su3], "number")\nsu1 = ListItem("Swim in the Seine \u2014 open July & August 2026", "First time in 102 years", null, null, @ToAssistant("Tell me about swimming in the Seine"))\nsu2 = ListItem("Open-air cinema at Parc de la Villette", "Free films under the stars", null, null, @ToAssistant("Tell me about the open-air cinema at Parc de la Villette"))\nsu3 = ListItem("Bastille Day celebrations on July 14", "Fireworks at the Eiffel Tower", null, null, @ToAssistant("What happens in Paris on Bastille Day?"))\nactionBtns = Buttons([btn1, btn2, btn3], "row")\nbtn1 = Button("Plan a Trip to Paris", @ToAssistant("Help me plan a trip to Paris"), "primary")\nbtn2 = Button("Best Hotels in Paris", @ToAssistant("Show me the best hotels in Paris"), "secondary")\nbtn3 = Button("Build a Paris Itinerary", @ToAssistant("Build a 5-day Paris itinerary for me"), "secondary")\nsrc1 = { title: "Paris Travel Guide 2025", sourceName: "Travel and Tour World", url: "https://www.travelandtourworld.com/news/article/from-iconic-landmarks-to-hidden-gems-the-ultimate-paris-travel-guide-for-2025-you-need-to-read-now/" }\nsrc2 = { title: "Best Things to Do in Paris 2026", sourceName: "Time Out Paris", url: "http://www.timeout.fr/paris/en/for-tourists" }\n\nExample 2 \u2014 Data and analytics response (quantitative asks lead with KPIs and charts):\n\nroot = Card([pageHeader, kpiBlock, sections, deepDiveHeader, compositeCards, actionButtons])\npageHeader = CardHeader("Analytics Dashboard", "April 2026 \xB7 Business Performance Overview")\nkpiBlock = SnippetCardBlock([kpi1, kpi2, kpi3, kpi4], "grid", true)\nkpi1 = SnippetCardItem("total-revenue", kpi1lhs, kpi1rhs)\nkpi1lhs = IconText(kpi1icon, "neutral", "m", "Total Revenue", "Month to date", false, "horizontal")\nkpi1icon = Icon("circle-dollar-sign", "finance")\nkpi1rhs = BoldText("number", "$284,500", "+12.4%", "metric")\nkpi2 = SnippetCardItem("active-users", kpi2lhs, kpi2rhs)\nkpi2lhs = IconText(kpi2icon, "neutral", "m", "Active Users", "Monthly active users", false, "horizontal")\nkpi2icon = Icon("users", "people")\nkpi2rhs = BoldText("number", "47,320", "+6.8%", "metric")\nkpi3 = SnippetCardItem("conversion-rate", kpi3lhs, kpi3rhs)\nkpi3lhs = IconText(kpi3icon, "neutral", "m", "Conversion Rate", "Avg. this month", false, "horizontal")\nkpi3icon = Icon("trending-up", "charts")\nkpi3rhs = BoldText("number", "5.7%", "+0.9%", "metric")\nkpi4 = SnippetCardItem("churn-rate", kpi4lhs, kpi4rhs)\nkpi4lhs = IconText(kpi4icon, "neutral", "m", "Churn Rate", "Monthly customer churn", false, "horizontal")\nkpi4icon = Icon("user-minus", "people")\nkpi4rhs = BoldText("number", "2.1%", "-0.4%", "metric")\nsections = SectionBlock([secUsers, secChannels], false)\nsecUsers = SectionItem("users", "User Activity", [userTabs])\nuserTabs = Tabs([tabGrowth, tabRetention])\ntabGrowth = TabItem("growth", "User Growth", [growthChart])\ngrowthChart = LineChart(months, [dauSeries, mauSeries], "natural", "Month", "Users (k)")\nmonths = ["May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr"]\ndauSeries = Series("DAU", [5.1, 5.4, 5.8, 6.2, 6.7, 7.1, 7.6, 8.0, 8.4, 8.9, 9.3, 9.8])\nmauSeries = Series("MAU", [28.4, 30.1, 31.8, 33.5, 35.2, 37.1, 38.8, 40.4, 42.1, 43.9, 45.6, 47.3])\ntabRetention = TabItem("retention", "Cohort Retention", [retentionChart])\nretentionChart = LineChart(cohortMonths, [cohortJan, cohortFeb, cohortMar], "natural", "Month Since Signup", "Retention (%)")\ncohortMonths = ["Month 0", "Month 1", "Month 2", "Month 3", "Month 4", "Month 5", "Month 6"]\ncohortJan = Series("Jan Cohort", [100, 80, 70, 62, 56, 51, 47])\ncohortFeb = Series("Feb Cohort", [100, 83, 73, 65, 59, 54, 50])\ncohortMar = Series("Mar Cohort", [100, 86, 76, 68, 62, 0, 0])\nsecChannels = SectionItem("channels", "Acquisition Channels", [channelTabs])\nchannelTabs = Tabs([tabChannelBar, tabChannelTable])\ntabChannelBar = TabItem("channel-bar", "Revenue by Channel", [channelBarChart])\nchannelBarChart = HorizontalBarChart(channels, [channelSeries], "grouped", "Revenue ($k)", "Channel")\nchannels = ["Organic Search", "Paid Ads", "Referral Program", "Partner Network", "Direct / Brand", "Email Campaigns"]\nchannelSeries = Series("Revenue ($k)", [82.4, 68.1, 54.6, 38.2, 26.8, 14.4])\ntabChannelTable = TabItem("channel-table", "Full Breakdown", [channelTable])\nchannelTable = Table([colChannel, colLeads, colConv, colCac, colRevenue, colStatus])\ncolChannel = Col("Channel", channels, "string")\ncolLeads = Col("Leads", [4210, 3180, 2050, 1120, 1290, 820], "number")\ncolConv = Col("Conv. Rate", ["6.4%", "5.1%", "9.4%", "11.8%", "5.8%", "8.1%"], "string")\ncolCac = Col("CAC ($)", [188, 395, 132, 109, 218, 154], "number")\ncolRevenue = Col("Revenue ($k)", [82.4, 68.1, 54.6, 38.2, 26.8, 14.4], "number")\ncolStatus = Col("Status", ["Scaling", "Optimizing", "Scaling", "Growing", "Stable", "Stable"], "string")\ndeepDiveHeader = InlineHeader("Support Health & Marketing ROI", "Click a card to explore deeper insights")\ncompositeCards = CompositeCardBlock([cardSupport, cardMarketing], "grid", true, @ToAssistant("Explore this deep-dive area in more detail"))\ncardSupport = CompositeCardItem("support-health", supportHeader, [supportMetric, supportChart, supportList])\nsupportHeader = IconText(supportIcon, "neutral", "m", "Support Health", "Ticket volume & resolution trends", false, "horizontal")\nsupportIcon = Icon("headphones", "communication")\nsupportMetric = MetricIndicatorInline("94.2% CSAT", "Customer Satisfaction Score", { direction: "up", value: 2.1 })\nsupportChart = BarChart(["Jan", "Feb", "Mar", "Apr"], [openSeries, resolvedSeries], "grouped", "Month", "Tickets")\nopenSeries = Series("Opened", [341, 327, 308, 289])\nresolvedSeries = Series("Resolved", [319, 318, 301, 283])\nsupportList = EntityList([sup1, sup2, sup3], "small")\nsup1 = { left: "Avg. Resolution Time", right: "4h 12m", rightVariant: "text" }\nsup2 = { left: "First Contact Resolution", right: "78.4%", rightVariant: "number" }\nsup3 = { left: "Escalation Rate", right: "6.2%", rightVariant: "number" }\ncardMarketing = CompositeCardItem("marketing-roi", marketingHeader, [marketingMetric, marketingChart, marketingList])\nmarketingHeader = IconText(marketingIcon, "neutral", "m", "Marketing ROI", "Spend vs. pipeline generated", false, "horizontal")\nmarketingIcon = Icon("megaphone", "communication")\nmarketingMetric = MetricIndicatorInline("3.8x Blended ROI", "Return on Ad Spend", { direction: "up", value: 0.4 })\nmarketingChart = AreaChart(["Jan", "Feb", "Mar", "Apr"], [spendSeries, pipelineSeries], "natural", "Month", "Value ($k)")\nspendSeries = Series("Ad Spend", [44.0, 46.8, 49.2, 51.6])\npipelineSeries = Series("Pipeline Generated", [158.2, 171.5, 184.9, 196.1])\nmarketingList = EntityList([mkt1, mkt2, mkt3], "small")\nmkt1 = { left: "Total Ad Spend (Apr)", right: "$51,600", rightVariant: "number" }\nmkt2 = { left: "Cost per Lead", right: "$48.20", rightVariant: "number" }\nmkt3 = { left: "Top Channel", right: "Organic Search", rightVariant: "text" }\nactionButtons = Buttons([btnChannels, btnForecast], "row")\nbtnChannels = Button("Break Down by Channel", @ToAssistant("Break down this month\'s revenue by acquisition channel"), "primary")\nbtnForecast = Button("Forecast Next Quarter", @ToAssistant("Forecast revenue and active users for next quarter"), "secondary")\n\nExample 3 \u2014 Form response (help-me-choose/plan asks: inspiration cards FIRST, then a compact form). The inspiration-card images below came from an image tool call \u2014 include such cards ONLY when you have real URLs; with no real URLs, start directly with the form:\n\nroot = Card([header, intro, inspoCards, form])\nheader = CardHeader("Plan Your Trip", "A few ideas to spark inspiration \u2014 then tell me your preferences")\nintro = TextContent("Tap a style to jump straight in, or fill the quick form below for a tailored plan.")\ninspoCards = VisualCardBlock([insp1, insp2], "grid", true, @ToAssistant("Plan me a trip in this style with destinations, itinerary, and costs"))\ninsp1 = VisualCardItem(insp1body, "inspo-beach", "https://www.travelandleisure.com/thmb/cuAB7XMQ6s_Gji-no956KNopT7M=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/TAL-maldives-TROPVACAY0325-1b5047d5931d4850b47d082966f9f563.jpg", insp1tag, "Maldives overwater villas")\ninsp1body = BoldText("text", "Tropical Beach Escape", "Overwater villas & snorkeling")\ninsp1tag = Tag("Relaxation", insp1icon, "sm", "info")\ninsp1icon = Icon("umbrella", "travel")\ninsp2 = VisualCardItem(insp2body, "inspo-mountain", "https://www.salkantaytrekmachu.com/img/adventure-travel-peru-032.jpg", insp2tag, "Trekking in the Peruvian Andes")\ninsp2body = BoldText("text", "Mountain Adventure", "Trekking & epic views")\ninsp2tag = Tag("Active", insp2icon, "sm", "warning")\ninsp2icon = Icon("mountain", "nature")\nform = Form("trip-planner", formButtons, [fcDestination, fcDates, fcTravellers, fcTripType, fcBudget, fcStay, fcNotes])\nformButtons = Buttons([btnSubmit, btnSkip], "row")\nbtnSubmit = Button("Plan My Trip", @ToAssistant("Help me plan a trip based on my form submission"), "primary")\nbtnSkip = Button("Just Surprise Me", @ToAssistant("Skip the form and surprise me with a destination and itinerary"), "secondary")\nfcDestination = FormControl("Destination", destinationInput, "Leave blank if you\'d like suggestions")\ndestinationInput = Input("destination", "e.g. Tokyo, Japan \u2014 or leave blank", "text")\nfcDates = FormControl("Travel Dates", datesPicker, "Select your start and end dates")\ndatesPicker = DatePicker("travel-dates", "range", { required: true })\nfcTravellers = FormControl("Number of Travellers", travellersSelect, "How many people are travelling?")\ntravellersSelect = Select("num-travellers", [tr1, tr2, tr3, tr4], "Select number of travellers", { required: true })\ntr1 = SelectItem("1", "1 \u2014 Solo")\ntr2 = SelectItem("2", "2 \u2014 Couple")\ntr3 = SelectItem("3-4", "3\u20134 People")\ntr4 = SelectItem("5+", "5+ People")\nfcTripType = FormControl("Trip Type", tripTypeCards, "What kind of trip are you planning?")\ntripTypeCards = OptionCards("trip-type", "single", [oc1, oc2, oc3, oc4], { required: true })\noc1 = OptionCard("adventure", "Adventure", "Hiking, trekking & outdoor activities", oc1icon)\noc1icon = Icon("mountain", "nature")\noc2 = OptionCard("beach", "Beach & Relaxation", "Sun, sand & leisure", oc2icon)\noc2icon = Icon("waves", "nature")\noc3 = OptionCard("cultural", "Cultural & Historical", "Museums, heritage & local experiences", oc3icon)\noc3icon = Icon("landmark", "buildings")\noc4 = OptionCard("city", "City Break", "Urban exploration & nightlife", oc4icon)\noc4icon = Icon("building-2", "buildings")\nfcBudget = FormControl("Estimated Budget (per person)", budgetSlider, "Drag to set your per-person budget in USD")\nbudgetSlider = Slider("budget", "discrete", 500, 10000, 500, [2500], "Budget (USD)")\nfcStay = FormControl("Accommodation Preference", stayChips, "Select all that apply")\nstayChips = Chips("accommodation", "multiple", [ch1, ch2, ch3, ch4], {}, ["hotel"])\nch1 = ChipItem("hotel", "Hotel", ch1icon)\nch1icon = Icon("building", "buildings")\nch2 = ChipItem("resort", "Resort", ch2icon)\nch2icon = Icon("umbrella", "travel")\nch3 = ChipItem("airbnb", "Vacation Rental", ch3icon)\nch3icon = Icon("home", "home")\nch4 = ChipItem("camping", "Camping / Glamping", ch4icon)\nch4icon = Icon("tent", "nature")\nfcNotes = FormControl("Special Requests or Notes", notesArea, "Any dietary needs, accessibility requirements, or specific interests?")\nnotesArea = TextArea("special-requests", "e.g. vegetarian meals, wheelchair access, honeymoon surprise...", 4)\n\nExample 4 \u2014 Recommendations with images and links (same pattern for products, movies, restaurants, articles):\n\nroot = Card([header, intro, posters, linksHeader, trackCards], [src1, src2])\nheader = CardHeader("Retro-Energetic Indian Tracks", "New Hindi releases with 80s/90s dance DNA")\nintro = TextContent("These recent tracks channel retro synths and 90s party percussion [1][2]. Tap a poster to explore a track, or use its button to watch the exact official video.")\nposters = VisualCardBlock([v1, v2], "grid", true, @ToAssistant("Tell me more about this track and its retro influences"))\nv1 = VisualCardItem(v1body, "tamma", "https://i.ytimg.com/vi/PQHeOb0Q9oo/hq720.jpg", v1tag, "Tamma Tamma video poster")\nv1body = BoldText("text", "Tamma Tamma", "Dhurandhar \xB7 Ranveer Singh")\nv1tag = Tag("80s Electro-Disco", v1icon, "sm", "success")\nv1icon = Icon("disc-3", "multimedia")\nv2 = VisualCardItem(v2body, "sajan", "https://i.ytimg.com/vi/mLz-qBiRnl8/hq720.jpg", v2tag, "Sajan Re video poster")\nv2body = BoldText("text", "Sajan Re", "Nora Fatehi \xB7 Badshah")\nv2tag = Tag("Synthwave Electro", v2icon, "sm", "info")\nv2icon = Icon("music", "multimedia")\nlinksHeader = InlineHeader("Watch the Exact Videos", "Each button opens that track\'s official video")\ntrackCards = CompositeCardBlock([t1, t2], "grid", true)\nt1 = CompositeCardItem("t-tamma", t1h, [t1body, t1tags], { button: t1btn })\nt1h = IconText(t1icon, "neutral", "m", "Tamma Tamma", "Bappi Lahiri classic, electro-funk rework", true, "horizontal")\nt1icon = Icon("disc-3", "multimedia")\nt1body = Text("text", "Heavy analog synths and brass over a fast disco groove.", "Retro Electro-Disco")\nt1tags = TagBlock(["2026 Film Hit", "Peak Party"])\nt1btn = Button("Watch on YouTube", @OpenUrl("https://www.youtube.com/watch?v=PQHeOb0Q9oo"), "primary")\nt2 = CompositeCardItem("t-sajan", t2h, [t2body, t2tags], { button: t2btn })\nt2h = IconText(t2icon, "neutral", "m", "Sajan Re", "Nora Fatehi \xB7 Badshah \xB7 Sanjoy", true, "horizontal")\nt2icon = Icon("music", "multimedia")\nt2body = Text("text", "Synthwave melody hooks over a modern club beat.", "Retro-Fusion Electro")\nt2tags = TagBlock(["Club Anthem", "Nora x Badshah"])\nt2btn = Button("Watch on YouTube", @OpenUrl("https://www.youtube.com/watch?v=COUSCnFazzc"), "primary")\nsrc1 = { title: "Tamma Tamma (Full Video) - Dhurandhar", sourceName: "YouTube (T-Series)", url: "https://www.youtube.com/watch?v=PQHeOb0Q9oo" }\nsrc2 = { title: "Sajan Re (Official Music Video)", sourceName: "YouTube (T-Series)", url: "https://www.youtube.com/watch?v=COUSCnFazzc" }\n\nExample 5 \u2014 Table with follow-ups:\n\nroot = Card([title, tbl, followUps])\ntitle = TextContent("Top Languages", "large-heavy")\ntbl = Table([Col("Language", langs), Col("Users (M)", users), Col("Year", years)])\nlangs = ["Python", "JavaScript", "Java"]\nusers = [15.7, 14.2, 12.1]\nyears = [1991, 1995, 1995]\nfollowUps = FollowUpBlock([fu1, fu2])\nfu1 = FollowUpItem("Tell me more about Python")\nfu2 = FollowUpItem("Show me a JavaScript comparison")\n\n## Important Rules\n- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)\n\n## Final Verification\nBefore finishing, walk your output and verify:\n1. root = Card(...) is the FIRST line (for optimal streaming).\n2. Every referenced name is defined. Every defined name (other than root) is reachable from root.\n\n- When asked about data, generate realistic/plausible data\n- Every response is a single Card(children) \u2014 children stack vertically automatically. No layout params are needed on Card.\n- Card is the only layout container. Do NOT use Stack. Use Tabs to switch between sections, Carousel for horizontal scroll.\n- Use FollowUpBlock at the END of a Card to suggest what the user can do or ask next.\n- Use ListBlock when presenting a set of options or steps; give each ListItem an action (5th argument) to make it clickable \u2014 without one the item is plain text.\n- Use SectionBlock to group long responses into collapsible sections \u2014 good for reports, FAQs, and structured content.\n- Use SectionItem inside SectionBlock: each item needs a unique value id, a trigger (header label), and a content array.\n- Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])\n- IMPORTANT: Every slide in a Carousel must use the same component structure in the same order \u2014 e.g. all slides: [title, image, description, tags].\n- For forms, define one FormControl reference per field so controls can stream progressively.\n- For forms, always provide the second Form argument with Buttons(...) actions: Form(name, buttons, fields).\n- Never nest Form inside Form.\n- CardHeader is the page-level heading \u2014 place it as the first child of Card; InlineHeader is a lighter subsection label for a block inside the response, and is redundant when the following component already has a heading.\n- Never use Callout or TextCallout to justify why you did what you did or for any meta-information.\n- Every image slot (Image, ImageBlock, ImageGallery, VisualCardItem/ContextCardItem bgImageSrc, ImageText, ImageTextLarge, ListItem image) requires a REAL URL from a tool result, the conversation, or the user \u2014 NEVER invent, guess, or template a URL.\n- If no image URL is in context, compose without image components \u2014 icons, gray ContextCardItems, and charts still make rich layouts.\n- Argument-order trap: Image takes alt FIRST, while ImageBlock, ImageText, and ImageTextLarge take src FIRST \u2014 alt text in a src slot ships a broken image.\n- Card blocks (SnippetCardBlock, OverviewCardBlock, ContextCardBlock, CompositeCardBlock, VisualCardBlock) need at least 2 items, all with the same structure; use layout "grid" for primary side-by-side comparison and "carousel" for secondary browsing.\n- The card-block action is BLOCK-LEVEL: one action shared by every card, with the clicked card\'s details attached automatically \u2014 keep the @ToAssistant message generic (e.g. "Tell me more about this destination"), and never use a block-level @OpenUrl since it would send every card to the same URL.\n- Card items have NO per-item action: to give each item its own external link, use CompositeCardItem with footer { button: Button(label, @OpenUrl(url)) } \u2014 never claim a card opens a link it cannot.\n- Text, BoldText, IconText, ImageText, ImageTextLarge and MetricIndicator* are inline building blocks used INSIDE card items \u2014 do not place them directly in the root Card.\n- EntityList size "small" is reserved for CompositeCardItem body content (no header/footer); use size "default" elsewhere.\n- Tag variant must be semantically correct (success=positive, danger=negative, warning=cautionary, info=informational, neutral=label); Tag takes an optional Icon second, so use Tag(text, icon, size, variant) when a variant is needed.\n- TagBlock takes plain strings \u2014 keep it to at most 3 tags.\n- ListBlock variant "number" is for ordered sequences and rankings, "image" for products/profiles with a real image; Steps is for ordered sequential processes only.\n- Use SectionBlock to divide a long response into independent, equally prominent topics; use Tabs when the items are alternative views of the same thing; set isFoldable=false unless a section has 4+ distinct blocks; never make SectionBlock the first Card child.\n- Accordion is for supplementary or FAQ content only \u2014 never primary information, 3-5 items max, and always the last component in its section or card.\n- Charts: LineChart/AreaChart variant "natural" for smooth trends and "linear" for precise point-to-point data; BarChart "grouped" for side-by-side comparison and "stacked" for part-to-whole; prefer HorizontalBarChart when category labels are long or numerous.\n- For large chart values, scale the data and put the unit in the axis label (e.g. yLabel "Revenue ($k)") instead of passing raw thousands or millions.\n- Quantitative asks get a chart (plus KPI cards where useful) in the FIRST response \u2014 do not answer numbers with prose or a table alone.\n- Table is column-oriented: each Col holds its own data array of plain strings or numbers (never components), and every column\'s array must have the same length.\n- Use EditableTable ONLY when the user or app explicitly asks for an editable table; default to Table for read-only data.\n- Every Form MUST have EXACTLY ONE submit Button with variant "primary" \u2014 that button validates the form; other buttons (secondary/tertiary escape hatches like "Just Surprise Me") skip validation, and there is never a reset button.\n- Prefer structured inputs (Select, Chips, OptionCards, DatePicker, Slider) over free-text Input, give every FormControl a clear label (and a hint where it prevents mistakes), and keep each field name unique within the response.\n- Validation rules ({ required: true, email: true, minLength: 8, ... }) are enforced with inline errors \u2014 use them for genuinely essential fields, but never require a free-text field where leaving it blank is meaningful.\n- Form inputs work ONLY inside a FormControl within a Form; for tappable suggestion choices OUTSIDE a form, use Buttons whose Button actions are @ToAssistant, never a bare OptionCards or Chips.\n- Only add Buttons for real actions: form submit, @OpenUrl with a URL from a tool or the user (never fabricated), or a @ToAssistant follow-up. Never add a button for an app action (open, download, export, edit) you cannot perform.\n- Every Button label must accurately describe what clicking it does; use "primary" for the main action and "secondary"/"tertiary" only for lower-emphasis supporting actions.\n- Icon: always include the category argument \u2014 it enables fallback matching when the exact lucide name is unavailable.\n- Pass sources on Card ONLY when the answer relies on real references you actually have, and cite them inline in TextContent as [1], [2] (1-based index into sources).';
|
|
101149
100932
|
}
|
|
101150
100933
|
});
|
|
101151
100934
|
|
|
@@ -101177,6 +100960,7 @@ Use a block when the user asks to visualize, chart, compare, calculate or pick b
|
|
|
101177
100960
|
- The block MUST be the first thing in your reply. No preamble; a short markdown note after it is fine.
|
|
101178
100961
|
- Emit the block directly. Do NOT call \`execute_code\` or ask the \`image-expert\` to draw charts or tables you can express here. Tools are for real computation over uploaded data, or photorealistic images.
|
|
101179
100962
|
- Use real or clearly labelled illustrative data; never present invented numbers as facts.
|
|
100963
|
+
- Charts get a distinct colour per series or slice by default. When the user asks for particular colours (a rainbow, brand colours, red for losses), pass them in the chart's last argument, \`colors\`: CSS colours, one per series, or one per label for PieChart, RadialChart and SingleStackedBarChart. Fill skipped optional arguments with null, e.g. \`PieChart(labels, values, null, null, ["red", "orange", "yellow"])\`. You can set chart colours, so never say otherwise.
|
|
101180
100964
|
- The UI cannot compute values in the page. For calculators and estimates, show the result for sensible defaults, plus a form whose inputs (sliders, fields) have defaults and a submit button with \`@ToAssistant("Recalculate")\`. The user's values come back to you as their next message; fields they did not change are left out and keep their defaults. Answer with a new block showing the recalculated result. Never answer with an HTML page or a code block to save.
|
|
101181
100965
|
|
|
101182
100966
|
The OpenUI Lang reference follows. Where it says your ENTIRE response must be openui-lang, that applies ONLY to the inside of the \`<visualization type="openui">\` block.
|
|
@@ -102873,39 +102657,17 @@ var init_beta_features = __esm({
|
|
|
102873
102657
|
"use strict";
|
|
102874
102658
|
init_zod();
|
|
102875
102659
|
BETA_FEATURES = {
|
|
102876
|
-
"simplified-chat": {
|
|
102877
|
-
key: "simplified-chat",
|
|
102878
|
-
name: "Simplified chat",
|
|
102879
|
-
description: "Use a cleaner conversation layout with compact activity and message actions.",
|
|
102880
|
-
failureMessage: "Could not save Simplified chat. Try again."
|
|
102881
|
-
},
|
|
102882
102660
|
"work-mode": {
|
|
102883
102661
|
key: "work-mode",
|
|
102884
102662
|
name: "Work mode",
|
|
102885
102663
|
description: "Work on longer tasks with code, files, and tools in a persistent workspace.",
|
|
102886
102664
|
failureMessage: "Could not save Work mode. Try again."
|
|
102887
102665
|
},
|
|
102888
|
-
"agent-progress": {
|
|
102889
|
-
key: "agent-progress",
|
|
102890
|
-
name: "Agent progress",
|
|
102891
|
-
description: "Show an agent-managed progress checklist for multi-step work."
|
|
102892
|
-
},
|
|
102893
|
-
"talk-mode": {
|
|
102894
|
-
key: "talk-mode",
|
|
102895
|
-
name: "Talk mode",
|
|
102896
|
-
description: "Have realtime voice conversations in Chat."
|
|
102897
|
-
},
|
|
102898
102666
|
"research-mode": {
|
|
102899
102667
|
key: "research-mode",
|
|
102900
102668
|
name: "Research mode",
|
|
102901
102669
|
description: "Run structured, sourced research with specialist workers and an HTML report."
|
|
102902
102670
|
},
|
|
102903
|
-
"generative-ui": {
|
|
102904
|
-
key: "generative-ui",
|
|
102905
|
-
name: "Generative UI",
|
|
102906
|
-
description: "Answer with native charts, tables, forms and cards instead of HTML visualizations.",
|
|
102907
|
-
failureMessage: "Could not save Generative UI. Try again."
|
|
102908
|
-
},
|
|
102909
102671
|
"browser-use": {
|
|
102910
102672
|
key: "browser-use",
|
|
102911
102673
|
name: "Browser use",
|
|
@@ -516047,8 +515809,7 @@ function shouldInjectVisualizationPrompt(config3) {
|
|
|
516047
515809
|
return !config3.localFilesystem && config3.visualizationsEnabled !== false;
|
|
516048
515810
|
}
|
|
516049
515811
|
function selectVisualizationPrompt(config3) {
|
|
516050
|
-
|
|
516051
|
-
return config3.generativeUiEnabled === true ? OPENUI_PROMPT : VISUALIZATION_PROMPT;
|
|
515812
|
+
return shouldInjectVisualizationPrompt(config3) ? OPENUI_PROMPT : null;
|
|
516052
515813
|
}
|
|
516053
515814
|
function getBuiltInDataParentToolName(toolName) {
|
|
516054
515815
|
if (!toolName.startsWith("parent_")) return null;
|
|
@@ -521737,8 +521498,6 @@ function createOrchestratorRequest(messages4, context3, config3, persona, apiKey
|
|
|
521737
521498
|
// Advanced web picker direct-provider bypass.
|
|
521738
521499
|
localFilesystem: config3.localFilesystem,
|
|
521739
521500
|
// CLI harness real-fs flag (undefined on web)
|
|
521740
|
-
generativeUiEnabled: config3.generativeUiEnabled,
|
|
521741
|
-
// `generative-ui` beta: OpenUI prompt replaces the HTML one
|
|
521742
521501
|
visualizationsEnabled: config3.visualizationsEnabled,
|
|
521743
521502
|
// Embed "visualizations off" skips the visualization prompt
|
|
521744
521503
|
systemPromptOverride: config3.systemPromptOverride,
|
|
@@ -521778,7 +521537,6 @@ var init_orchestrator = __esm({
|
|
|
521778
521537
|
init_argument_validation();
|
|
521779
521538
|
init_reported_error();
|
|
521780
521539
|
init_language_prompt();
|
|
521781
|
-
init_visualization_prompt();
|
|
521782
521540
|
init_prompt();
|
|
521783
521541
|
init_data_staging_prompt();
|
|
521784
521542
|
init_parent_tools();
|
|
@@ -540479,6 +540237,20 @@ var init_remote_chat_input = __esm({
|
|
|
540479
540237
|
}
|
|
540480
540238
|
});
|
|
540481
540239
|
|
|
540240
|
+
// src/lib/chat-v3/participant-label.ts
|
|
540241
|
+
function participantLabel(actorId, selfId, participants) {
|
|
540242
|
+
if (selfId && actorId === selfId) return "You";
|
|
540243
|
+
const label = participants.find((participant) => participant.userId === actorId)?.label.trim();
|
|
540244
|
+
return label || UNKNOWN_PARTICIPANT;
|
|
540245
|
+
}
|
|
540246
|
+
var UNKNOWN_PARTICIPANT;
|
|
540247
|
+
var init_participant_label = __esm({
|
|
540248
|
+
"src/lib/chat-v3/participant-label.ts"() {
|
|
540249
|
+
"use strict";
|
|
540250
|
+
UNKNOWN_PARTICIPANT = "Another participant";
|
|
540251
|
+
}
|
|
540252
|
+
});
|
|
540253
|
+
|
|
540482
540254
|
// src/cli/remote-chat.ts
|
|
540483
540255
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
540484
540256
|
var messageSchema, RemoteChatClient;
|
|
@@ -540489,6 +540261,7 @@ var init_remote_chat = __esm({
|
|
|
540489
540261
|
init_protocol3();
|
|
540490
540262
|
init_transport3();
|
|
540491
540263
|
init_remote_chat_input();
|
|
540264
|
+
init_participant_label();
|
|
540492
540265
|
messageSchema = external_exports.object({ id: external_exports.string().uuid(), role: external_exports.enum(["user", "assistant", "system"]), content: external_exports.string(), interactiveActorId: external_exports.string().uuid().nullable().optional() });
|
|
540493
540266
|
RemoteChatClient = class {
|
|
540494
540267
|
constructor(options2) {
|
|
@@ -540499,6 +540272,7 @@ var init_remote_chat = __esm({
|
|
|
540499
540272
|
this.waiters = /* @__PURE__ */ new Map();
|
|
540500
540273
|
this.unresolved = /* @__PURE__ */ new Map();
|
|
540501
540274
|
this.cursor = 0;
|
|
540275
|
+
this.participants = [];
|
|
540502
540276
|
this.role = "owner";
|
|
540503
540277
|
this.runTurn = async (prompt, _history, callbacks) => {
|
|
540504
540278
|
if (this.role === "viewer") throw new Error("This conversation is read only.");
|
|
@@ -540553,7 +540327,7 @@ var init_remote_chat = __esm({
|
|
|
540553
540327
|
transcript() {
|
|
540554
540328
|
const items = [...this.rows.values()].flatMap((row) => {
|
|
540555
540329
|
if (row.role === "system") return [{ kind: "system", text: row.text, tone: "info" }];
|
|
540556
|
-
const text6 = row.role === "user" && row.actor && row.actor !== this.actorId ?
|
|
540330
|
+
const text6 = row.role === "user" && row.actor && row.actor !== this.actorId ? `${participantLabel(row.actor, this.actorId, this.participants)}
|
|
540557
540331
|
${row.text}` : row.text;
|
|
540558
540332
|
return [...row.details, { kind: row.role, text: text6 }];
|
|
540559
540333
|
});
|
|
@@ -540676,8 +540450,9 @@ ${row.text}` : row.text;
|
|
|
540676
540450
|
async open() {
|
|
540677
540451
|
if (!this.conversationId) return;
|
|
540678
540452
|
const details = external_exports.object({ conversation: external_exports.object({ runtime: external_exports.literal("next") }), messages: external_exports.array(messageSchema).max(1e4) }).parse(await this.request(`/chat/v3/conversations/${this.conversationId}`));
|
|
540679
|
-
const access2 = external_exports.object({ role: external_exports.enum(["owner", "viewer", "participant"]) }).parse(await this.request(`/chat/v3/conversations/${this.conversationId}/access`));
|
|
540453
|
+
const access2 = external_exports.object({ role: external_exports.enum(["owner", "viewer", "participant"]), participants: external_exports.array(external_exports.object({ userId: external_exports.string(), label: external_exports.string() })).default([]) }).parse(await this.request(`/chat/v3/conversations/${this.conversationId}/access`));
|
|
540680
540454
|
this.role = access2.role;
|
|
540455
|
+
this.participants = access2.participants;
|
|
540681
540456
|
for (const row of details.messages) this.rows.set(row.id, { id: row.id, role: row.role, text: row.content, actor: row.interactiveActorId ?? void 0, details: [] });
|
|
540682
540457
|
this.connect(await this.attachment());
|
|
540683
540458
|
}
|