@adecore/agents-react 0.20.1 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/chat/logic/generated-image.d.ts +27 -0
  2. package/dist/chat/logic/generated-image.js +32 -0
  3. package/dist/chat/logic/timeline-target.d.ts +13 -1
  4. package/dist/chat/logic/timeline-target.js +26 -0
  5. package/dist/chat/logic/timeline.js +16 -10
  6. package/dist/chat/subagent-conversation.d.ts +2 -1
  7. package/dist/chat/subagent-conversation.js +7 -1
  8. package/dist/chat/timeline-flash.d.ts +3 -1
  9. package/dist/chat/timeline-flash.js +2 -2
  10. package/dist/chat/ui/ImageView.d.ts +8 -2
  11. package/dist/chat/ui/ImageView.js +12 -6
  12. package/dist/chat/ui/SubagentTimeline.js +6 -2
  13. package/dist/chat/ui/Timeline.js +67 -7
  14. package/dist/chat/ui/intelligent-ui/UiBlockFrame.d.ts +23 -0
  15. package/dist/chat/ui/intelligent-ui/UiBlockFrame.js +103 -0
  16. package/dist/chat/ui/intelligent-ui/UiFallbackPart.d.ts +10 -0
  17. package/dist/chat/ui/intelligent-ui/UiFallbackPart.js +11 -0
  18. package/dist/chat/ui/intelligent-ui/UiReply.d.ts +15 -0
  19. package/dist/chat/ui/intelligent-ui/UiReply.js +329 -0
  20. package/dist/chat/ui/intelligent-ui/block-local.d.ts +11 -0
  21. package/dist/chat/ui/intelligent-ui/block-local.js +42 -0
  22. package/dist/chat/ui/intelligent-ui/chart-data.d.ts +16 -0
  23. package/dist/chat/ui/intelligent-ui/chart-data.js +46 -0
  24. package/dist/chat/ui/intelligent-ui/node-text.d.ts +15 -0
  25. package/dist/chat/ui/intelligent-ui/node-text.js +106 -0
  26. package/dist/chat/ui/intelligent-ui/registry.d.ts +2 -0
  27. package/dist/chat/ui/intelligent-ui/registry.js +51 -0
  28. package/dist/chat/ui/intelligent-ui/render-context.d.ts +53 -0
  29. package/dist/chat/ui/intelligent-ui/render-context.js +3 -0
  30. package/dist/chat/ui/intelligent-ui/renderers/chart.d.ts +3 -0
  31. package/dist/chat/ui/intelligent-ui/renderers/chart.js +123 -0
  32. package/dist/chat/ui/intelligent-ui/renderers/choices.d.ts +4 -0
  33. package/dist/chat/ui/intelligent-ui/renderers/choices.js +45 -0
  34. package/dist/chat/ui/intelligent-ui/renderers/content.d.ts +14 -0
  35. package/dist/chat/ui/intelligent-ui/renderers/content.js +59 -0
  36. package/dist/chat/ui/intelligent-ui/renderers/data.d.ts +7 -0
  37. package/dist/chat/ui/intelligent-ui/renderers/data.js +80 -0
  38. package/dist/chat/ui/intelligent-ui/renderers/inputs.d.ts +8 -0
  39. package/dist/chat/ui/intelligent-ui/renderers/inputs.js +72 -0
  40. package/dist/chat/ui/intelligent-ui/renderers/links.d.ts +10 -0
  41. package/dist/chat/ui/intelligent-ui/renderers/links.js +87 -0
  42. package/dist/chat/ui/intelligent-ui/renderers/structure.d.ts +6 -0
  43. package/dist/chat/ui/intelligent-ui/renderers/structure.js +32 -0
  44. package/dist/chat/ui/intelligent-ui/renderers/text.d.ts +8 -0
  45. package/dist/chat/ui/intelligent-ui/renderers/text.js +61 -0
  46. package/dist/chat/ui/intelligent-ui/reply-parts.d.ts +9 -0
  47. package/dist/chat/ui/intelligent-ui/reply-parts.js +18 -0
  48. package/dist/chat/ui/intelligent-ui/table-data.d.ts +31 -0
  49. package/dist/chat/ui/intelligent-ui/table-data.js +79 -0
  50. package/dist/chat/ui/intelligent-ui/tones.d.ts +7 -0
  51. package/dist/chat/ui/intelligent-ui/tones.js +31 -0
  52. package/dist/chat/ui/intelligent-ui/use-later.d.ts +1 -0
  53. package/dist/chat/ui/intelligent-ui/use-later.js +16 -0
  54. package/dist/chat/ui/intelligent-ui/use-ui-links.d.ts +9 -0
  55. package/dist/chat/ui/intelligent-ui/use-ui-links.js +126 -0
  56. package/dist/chat/ui/intelligent-ui/use-ui-queries.d.ts +21 -0
  57. package/dist/chat/ui/intelligent-ui/use-ui-queries.js +272 -0
  58. package/dist/chat/ui/reply-context.d.ts +8 -0
  59. package/dist/chat/ui/reply-context.js +1 -0
  60. package/dist/chat/ui/rows/GeneratedImageRow.d.ts +5 -0
  61. package/dist/chat/ui/rows/GeneratedImageRow.js +121 -0
  62. package/dist/chat/ui/rows/MessageRows.js +21 -4
  63. package/dist/chat/ui/rows/Rows.js +4 -2
  64. package/dist/chat/ui/rows/SubagentRow.js +5 -0
  65. package/dist/chat/ui/rows/WorkRows.d.ts +4 -1
  66. package/dist/chat/ui/rows/WorkRows.js +4 -3
  67. package/dist/host.d.ts +11 -1
  68. package/dist/locales/en/agent-chat.json +101 -0
  69. package/dist/locales/nl/agent-chat.json +101 -0
  70. package/dist/state/chats.js +13 -0
  71. package/dist/theme.css +19 -0
  72. package/package.json +128 -7
  73. package/src/chat/logic/generated-image.ts +48 -0
  74. package/src/chat/logic/timeline-target.ts +41 -1
  75. package/src/chat/logic/timeline.ts +19 -10
  76. package/src/chat/subagent-conversation.ts +13 -2
  77. package/src/chat/timeline-flash.ts +5 -3
  78. package/src/chat/ui/ImageView.tsx +51 -8
  79. package/src/chat/ui/SubagentTimeline.tsx +24 -1
  80. package/src/chat/ui/Timeline.tsx +97 -21
  81. package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +219 -0
  82. package/src/chat/ui/intelligent-ui/UiFallbackPart.tsx +21 -0
  83. package/src/chat/ui/intelligent-ui/UiReply.tsx +541 -0
  84. package/src/chat/ui/intelligent-ui/block-local.ts +51 -0
  85. package/src/chat/ui/intelligent-ui/chart-data.ts +67 -0
  86. package/src/chat/ui/intelligent-ui/node-text.ts +119 -0
  87. package/src/chat/ui/intelligent-ui/registry.ts +53 -0
  88. package/src/chat/ui/intelligent-ui/render-context.ts +84 -0
  89. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +319 -0
  90. package/src/chat/ui/intelligent-ui/renderers/choices.tsx +102 -0
  91. package/src/chat/ui/intelligent-ui/renderers/content.tsx +140 -0
  92. package/src/chat/ui/intelligent-ui/renderers/data.tsx +181 -0
  93. package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +144 -0
  94. package/src/chat/ui/intelligent-ui/renderers/links.tsx +158 -0
  95. package/src/chat/ui/intelligent-ui/renderers/structure.tsx +84 -0
  96. package/src/chat/ui/intelligent-ui/renderers/text.tsx +124 -0
  97. package/src/chat/ui/intelligent-ui/reply-parts.ts +22 -0
  98. package/src/chat/ui/intelligent-ui/table-data.ts +104 -0
  99. package/src/chat/ui/intelligent-ui/tones.ts +37 -0
  100. package/src/chat/ui/intelligent-ui/use-later.ts +17 -0
  101. package/src/chat/ui/intelligent-ui/use-ui-links.ts +143 -0
  102. package/src/chat/ui/intelligent-ui/use-ui-queries.ts +308 -0
  103. package/src/chat/ui/reply-context.ts +7 -0
  104. package/src/chat/ui/rows/GeneratedImageRow.tsx +244 -0
  105. package/src/chat/ui/rows/MessageRows.tsx +60 -4
  106. package/src/chat/ui/rows/Rows.tsx +4 -2
  107. package/src/chat/ui/rows/SubagentRow.tsx +5 -0
  108. package/src/chat/ui/rows/WorkRows.tsx +20 -5
  109. package/src/host.ts +27 -1
  110. package/src/locales/en/agent-chat.json +101 -0
  111. package/src/locales/nl/agent-chat.json +101 -0
  112. package/src/state/chats.ts +13 -0
  113. package/src/theme.css +19 -0
@@ -0,0 +1,51 @@
1
+ import { ChartRenderer } from './renderers/chart.js';
2
+ import { ChoiceRenderer, ChoicesRenderer } from './renderers/choices.js';
3
+ import { CodeBlockRenderer, ImageRenderer, SourceRenderer, SourcesRenderer } from './renderers/content.js';
4
+ import { EntityListRenderer, EntryRenderer, StatRenderer, StatsRenderer, TableRenderer } from './renderers/data.js';
5
+ import { ButtonRenderer, ChecklistRenderer, ItemRenderer, SegmentedRenderer, SliderRenderer, SwitchRenderer } from './renderers/inputs.js';
6
+ import { CommitRenderer, DiffRenderer, FileRenderer, NodeRenderer } from './renderers/links.js';
7
+ import { SectionRenderer, SectionsRenderer, TabRenderer, TabsRenderer } from './renderers/structure.js';
8
+ import { CalloutRenderer, ProgressRenderer, StepRenderer, StepsRenderer, SummaryRenderer, TagRenderer } from './renderers/text.js';
9
+ /*
10
+ * A renderer for every component of the catalog; a name missing here fails the typecheck. Null draws
11
+ * nothing for the node itself: the runtime resolves Show and Each before rendering, and Column and
12
+ * Option are metadata their parent reads from its node (a table its columns, Segmented its segments).
13
+ */
14
+ export const UI_RENDERERS = {
15
+ Summary: SummaryRenderer,
16
+ Callout: CalloutRenderer,
17
+ Tag: TagRenderer,
18
+ Progress: ProgressRenderer,
19
+ Steps: StepsRenderer,
20
+ Step: StepRenderer,
21
+ Stats: StatsRenderer,
22
+ Stat: StatRenderer,
23
+ EntityList: EntityListRenderer,
24
+ Entry: EntryRenderer,
25
+ Table: TableRenderer,
26
+ Column: null,
27
+ Chart: ChartRenderer,
28
+ Tabs: TabsRenderer,
29
+ Tab: TabRenderer,
30
+ Sections: SectionsRenderer,
31
+ Section: SectionRenderer,
32
+ CodeBlock: CodeBlockRenderer,
33
+ Image: ImageRenderer,
34
+ Sources: SourcesRenderer,
35
+ Source: SourceRenderer,
36
+ File: FileRenderer,
37
+ Diff: DiffRenderer,
38
+ Commit: CommitRenderer,
39
+ Node: NodeRenderer,
40
+ Checklist: ChecklistRenderer,
41
+ Item: ItemRenderer,
42
+ Switch: SwitchRenderer,
43
+ Slider: SliderRenderer,
44
+ Segmented: SegmentedRenderer,
45
+ Option: null,
46
+ Button: ButtonRenderer,
47
+ Show: null,
48
+ Each: null,
49
+ Choices: ChoicesRenderer,
50
+ Choice: ChoiceRenderer
51
+ };
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { UiComponentName, UiProps, UiViewNode } from '@adecore/intelligent-ui';
3
+ export type { UiLinkTarget } from '@adecore/intelligent-ui/links';
4
+ import type { UiLinkTarget } from '@adecore/intelligent-ui/links';
5
+ export interface UiLink {
6
+ state: 'chip' | 'plain';
7
+ label?: string;
8
+ reason?: string;
9
+ code?: string;
10
+ }
11
+ export interface UiAnswer {
12
+ choiceId: string;
13
+ state: 'sending' | 'sent' | 'queued';
14
+ }
15
+ export interface UiLiveStatus {
16
+ state: 'fresh' | 'reading' | 'failed' | 'refused';
17
+ sources: readonly string[];
18
+ readAt: number | null;
19
+ source?: string;
20
+ reason?: string;
21
+ code?: string;
22
+ }
23
+ export interface UiLiveValue {
24
+ previous?: unknown;
25
+ changed: boolean;
26
+ stale: boolean;
27
+ }
28
+ export interface UiRenderContext {
29
+ scopeId: string;
30
+ chatId: string;
31
+ itemId: string;
32
+ blockId: string;
33
+ phase: 'streaming' | 'final';
34
+ answer: UiAnswer | null;
35
+ failedChoiceId?: string | null;
36
+ live?: UiLiveStatus | null;
37
+ link?(target: UiLinkTarget): UiLink;
38
+ openLink?(target: UiLinkTarget): void;
39
+ openUrl?(url: string): void;
40
+ onChoose?(nodeId: string): void;
41
+ choiceReason?: string | null;
42
+ liveValue?(nodeId: string, prop: string, path?: readonly [row: number, key: string]): UiLiveValue | undefined;
43
+ }
44
+ export interface UiRendererProps<Props> {
45
+ node: UiViewNode<Props>;
46
+ children: ReactNode;
47
+ context: UiRenderContext;
48
+ }
49
+ export type UiRenderer<Props> = (props: UiRendererProps<Props>) => ReactNode;
50
+ export type UiRenderers = {
51
+ readonly [Name in UiComponentName]: UiRenderer<UiProps<Name>> | null;
52
+ };
53
+ export declare const UiHeadContext: import("react").Context<string | null | undefined>;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ /* The id of the Summary that heads the block. Undefined outside a frame, where every Summary heads. */
3
+ export const UiHeadContext = createContext(undefined);
@@ -0,0 +1,3 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare function ChartRenderer({ node }: UiRendererProps<UiProps<'Chart'>>): import("react").JSX.Element;
@@ -0,0 +1,123 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { SegmentBar, useMeasuredWidth } from '@adecore/ui';
6
+ import { formatRounded } from '@adecore/ui/format';
7
+ import { niceCeiling, UI_CHART_ROWS, uiChartData } from '../chart-data.js';
8
+ import { uiWithUnit } from '../node-text.js';
9
+ import { UiFallbackPart } from '../UiFallbackPart.js';
10
+ const HEIGHT = 160;
11
+ const HBAR_ROW = 24;
12
+ const STACKED_ROW = 28;
13
+ const AXIS_WIDTH = 44;
14
+ const PLOT_TOP = 8;
15
+ const LABEL_ROOM = 20;
16
+ /* The narrowest band a category label is written under; narrower bands skip labels. */
17
+ const LABEL_BAND = 56;
18
+ /* Points get a dot up to this many categories; more would crowd the line. */
19
+ const DOTS_UP_TO = 30;
20
+ const GROW = 'transition-[scale,opacity] duration-400 ease-out motion-reduce:transition-none';
21
+ function seriesColor(index) {
22
+ return `var(--chart-${index + 1})`;
23
+ }
24
+ function valueText(value, unit) {
25
+ return value === null ? '' : uiWithUnit(formatRounded(value, 2), unit);
26
+ }
27
+ /* The height a chart will take, which its place holds while the node streams. */
28
+ function chartHeight(kind, rows) {
29
+ const count = Math.max(1, Math.min(rows, UI_CHART_ROWS));
30
+ return kind === 'hbar' ? count * HBAR_ROW : kind === 'stacked' ? count * STACKED_ROW : HEIGHT;
31
+ }
32
+ /* One sentence with the main point, which a screen reader hears in place of the drawing. */
33
+ function chartSummary(chart, unit, t) {
34
+ let top = null;
35
+ for (const series of chart.series) {
36
+ for (let i = 0; i < series.values.length; i++) {
37
+ const value = series.values[i];
38
+ if (value !== null && value !== undefined && (top === null || value > top.value)) {
39
+ top = { label: chart.labels[i] ?? '', series: series.key, value };
40
+ }
41
+ }
42
+ }
43
+ if (top === null) {
44
+ return t('blocks.chart.values');
45
+ }
46
+ return chart.series.length > 1
47
+ ? t('blocks.chart.summarySeries', { count: chart.labels.length, series: top.series, label: top.label, value: valueText(top.value, unit) })
48
+ : t('blocks.chart.summary', { count: chart.labels.length, label: top.label, value: valueText(top.value, unit) });
49
+ }
50
+ function Legend({ chart }) {
51
+ return (_jsx("div", { "aria-hidden": true, className: "flex flex-wrap gap-x-3 gap-y-1 text-xs text-text-muted", children: chart.series.map((series, index) => (_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "size-2 rounded-sm", style: { backgroundColor: seriesColor(index) } }), series.key] }, series.key))) }));
52
+ }
53
+ /* The numbers behind the drawing, for a screen reader. */
54
+ function ValuesTable({ chart, unit }) {
55
+ const { t } = useTranslation('agent-chat');
56
+ return (_jsxs("table", { className: "sr-only", children: [_jsx("caption", { children: t('blocks.chart.values') }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", {}), chart.series.map((series) => (_jsx("th", { scope: "col", children: series.key }, series.key)))] }) }), _jsx("tbody", { children: chart.labels.map((label, index) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: label }), chart.series.map((series) => (_jsx("td", { children: valueText(series.values[index] ?? null, unit) }, series.key)))] }, index))) })] }));
57
+ }
58
+ /* The values of one category beside the pointer. */
59
+ function Readout({ chart, index, left, unit }) {
60
+ return (_jsxs("div", { "aria-hidden": true, className: "pointer-events-none absolute top-0 z-1 flex -translate-x-1/2 flex-col gap-0.5 rounded-md bg-surface-raised px-2 py-1 text-xs whitespace-nowrap shadow-raised", style: { left }, children: [_jsx("span", { className: "font-medium text-text", children: chart.labels[index] }), chart.series.map((series, at) => (_jsxs("span", { className: "flex items-center gap-1.5 text-text-muted tabular-nums", children: [_jsx("span", { className: "size-2 rounded-sm", style: { backgroundColor: seriesColor(at) } }), chart.series.length > 1 && _jsx("span", { children: series.key }), _jsx("span", { className: "text-text", children: valueText(series.values[index] ?? null, unit) })] }, series.key)))] }));
61
+ }
62
+ /* Bars and lines over a value axis, in SVG at the measured width. */
63
+ function VerticalChart({ chart, kind, unit, width }) {
64
+ const [hover, setHover] = useState(null);
65
+ const low = chart.min < 0 ? -niceCeiling(-chart.min) : 0;
66
+ const high = chart.max > 0 ? niceCeiling(chart.max) : low === 0 ? 1 : 0;
67
+ const plotWidth = Math.max(0, width - AXIS_WIDTH);
68
+ const plotHeight = HEIGHT - PLOT_TOP - LABEL_ROOM;
69
+ const band = plotWidth / chart.labels.length;
70
+ const y = (value) => Math.round(PLOT_TOP + ((high - value) / (high - low)) * plotHeight);
71
+ const baseline = y(0);
72
+ const ticks = low === 0 ? [0, high / 2, high] : [low, 0, high];
73
+ const labelEvery = Math.max(1, Math.ceil(LABEL_BAND / Math.max(1, band)));
74
+ const center = (index) => Math.round(AXIS_WIDTH + band * index + band / 2);
75
+ const gap = band * 0.2;
76
+ const barWidth = Math.max(1, (band - gap) / chart.series.length);
77
+ const segments = (values) => values
78
+ .map((value, index) => (value === null ? null : `${center(index)} ${y(value)}`))
79
+ .reduce((paths, point, index, all) => {
80
+ if (point !== null) {
81
+ paths.push(`${index === 0 || all[index - 1] === null ? 'M' : 'L'}${point}`);
82
+ }
83
+ return paths;
84
+ }, [])
85
+ .join(' ');
86
+ return (_jsxs(_Fragment, { children: [_jsxs("svg", { width: width, height: HEIGHT, "aria-hidden": true, className: "block overflow-visible", onPointerLeave: () => setHover(null), children: [hover !== null && (_jsx("rect", { x: Math.round(AXIS_WIDTH + band * hover), y: PLOT_TOP, width: Math.round(band), height: plotHeight, className: "fill-surface-hover" })), ticks.map((tick) => (_jsxs("g", { children: [_jsx("line", { x1: AXIS_WIDTH, x2: width, y1: y(tick), y2: y(tick), className: tick === 0 ? 'stroke-border' : 'stroke-border-soft', shapeRendering: "crispEdges" }), _jsx("text", { x: AXIS_WIDTH - 6, y: y(tick), dy: "0.32em", textAnchor: "end", className: "fill-text-faint text-xs tabular-nums", children: valueText(tick, unit) })] }, tick))), chart.labels.map((label, index) => index % labelEvery === 0 ? (_jsx("text", { x: center(index), y: HEIGHT - 4, textAnchor: "middle", className: "fill-text-faint text-xs", children: label }, index)) : null), kind === 'bar' ? (_jsx("g", { className: clsx(GROW, 'starting:scale-y-0'), style: { transformOrigin: `0px ${baseline}px` }, children: chart.series.map((series, at) => series.values.map((value, index) => value === null ? null : (_jsx("rect", { x: Math.round(AXIS_WIDTH + band * index + gap / 2 + barWidth * at), y: Math.min(y(value), baseline), width: Math.max(1, Math.round(barWidth) - 1), height: Math.abs(y(value) - baseline), rx: 2, style: { fill: seriesColor(at) } }, `${series.key}:${index}`)))) })) : (_jsx("g", { className: clsx(GROW, 'starting:opacity-0'), children: chart.series.map((series, at) => (_jsxs("g", { style: { color: seriesColor(at) }, children: [_jsx("path", { d: segments(series.values), fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinejoin: "round", strokeLinecap: "round" }), chart.labels.length <= DOTS_UP_TO &&
87
+ series.values.map((value, index) => value === null ? null : _jsx("circle", { cx: center(index), cy: y(value), r: 3, fill: "currentColor" }, index))] }, series.key))) })), chart.labels.map((_, index) => (_jsx("rect", { x: Math.round(AXIS_WIDTH + band * index), y: 0, width: Math.max(1, Math.round(band)), height: HEIGHT, fill: "transparent", onPointerEnter: () => setHover(index) }, index)))] }), hover !== null && _jsx(Readout, { chart: chart, index: hover, unit: unit, left: Math.min(Math.max(center(hover), 64), Math.max(64, width - 64)) })] }));
88
+ }
89
+ /* A row of 24px per category, its label beside the bars. */
90
+ function HorizontalChart({ chart, unit }) {
91
+ // Bars grow right from zero only, so a chart of only negative values has no length to share and keeps a unit scale.
92
+ const high = niceCeiling(chart.max) || 1;
93
+ const single = chart.series.length === 1;
94
+ return (_jsx("div", { "aria-hidden": true, className: "flex flex-col", children: chart.labels.map((label, index) => (_jsxs("div", { className: "flex h-6 items-center gap-2 text-xs", children: [_jsx("span", { className: "w-2/5 max-w-36 shrink-0 truncate text-text-muted", children: label }), _jsx("span", { className: "flex min-w-0 grow flex-col justify-center gap-px", children: chart.series.map((series, at) => (_jsx("span", { className: clsx(GROW, 'block origin-left rounded-sm starting:scale-x-0', single ? 'h-3' : 'h-1'), style: { width: `${(Math.max(0, series.values[index] ?? 0) / high) * 100}%`, backgroundColor: seriesColor(at) } }, series.key))) }), single && (_jsx("span", { className: "w-16 shrink-0 text-right text-text-faint tabular-nums", children: valueText(chart.series[0].values[index] ?? null, unit) }))] }, index))) }));
95
+ }
96
+ /* A bar per category split into its series, on one scale so the rows compare. */
97
+ function StackedChart({ chart, unit }) {
98
+ return (_jsx("div", { className: "flex flex-col gap-2", children: chart.labels.map((label, index) => (_jsxs("div", { className: "flex items-center gap-2 text-xs", children: [chart.labels.length > 1 && _jsx("span", { className: "w-2/5 max-w-36 shrink-0 truncate text-text-muted", children: label }), _jsx(SegmentBar, { size: "sm", className: "grow", label: label, range: [0, chart.max], parts: chart.series.map((series, at) => ({
99
+ value: Math.max(0, series.values[index] ?? 0),
100
+ color: seriesColor(at),
101
+ label: `${series.key} ${valueText(series.values[index] ?? 0, unit)}`
102
+ })) })] }, index))) }));
103
+ }
104
+ function DrawnChart({ chart, kind, unit }) {
105
+ const { t } = useTranslation('agent-chat');
106
+ const [measure, width] = useMeasuredWidth();
107
+ return (_jsxs("figure", { className: "flex flex-col gap-2 px-2", children: [chart.series.length > 1 && _jsx(Legend, { chart: chart }), _jsx("div", { ref: measure, role: "img", "aria-label": chartSummary(chart, unit, t), className: "relative", children: kind === 'hbar' ? (_jsx(HorizontalChart, { chart: chart, unit: unit })) : kind === 'stacked' ? (_jsx(StackedChart, { chart: chart, unit: unit })) : (_jsx("div", { style: { height: HEIGHT }, children: width > 0 && _jsx(VerticalChart, { chart: chart, kind: kind, unit: unit, width: width }) })) }), _jsx(ValuesTable, { chart: chart, unit: unit })] }));
108
+ }
109
+ /*
110
+ * Draws only once its node closed; until then a quiet surface of the height it will take holds its
111
+ * place. It grows in once, and not at all for a person who asked for less motion.
112
+ */
113
+ export function ChartRenderer({ node }) {
114
+ const { kind, data, unit } = node.props;
115
+ const chart = useMemo(() => (node.complete ? uiChartData(data, kind) : null), [node.complete, data, kind]);
116
+ if (!node.complete) {
117
+ return _jsx("div", { "aria-hidden": true, className: "mx-2 rounded-md bg-surface-hover", style: { height: chartHeight(kind, data.length) } });
118
+ }
119
+ if (chart === null) {
120
+ return _jsx(UiFallbackPart, { fallback: node.fallback, problem: { kind: 'failed' } });
121
+ }
122
+ return _jsx(DrawnChart, { chart: chart, kind: kind, unit: unit });
123
+ }
@@ -0,0 +1,4 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare function ChoicesRenderer({ children, context }: UiRendererProps<UiProps<'Choices'>>): import("react").JSX.Element;
4
+ export declare function ChoiceRenderer({ node, children, context }: UiRendererProps<UiProps<'Choice'>>): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useState } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { ArrowRight, Check } from 'lucide-react';
6
+ import { DisabledReason, Icon, Spinner, Tooltip } from '@adecore/ui';
7
+ import { useLater } from '../use-later.js';
8
+ /* A context this long may run past its two lines, so the row offers all of it in a tooltip. */
9
+ const LONG_CONTEXT = 120;
10
+ const SPINNER_AFTER_MS = 300;
11
+ /* Says once, politely, that the choices opened when the reply was done; never on a block that was already done. */
12
+ export function ChoicesRenderer({ children, context }) {
13
+ const { t } = useTranslation('agent-chat');
14
+ const [streamed] = useState(context.phase === 'streaming');
15
+ return (_jsxs("div", { role: "group", "aria-label": t('blocks.choices'), className: "chat-ui-nodes flex flex-col gap-1.5", children: [children, _jsx("span", { className: "sr-only", role: "status", children: streamed && context.phase === 'final' ? t('blocks.choice.ready') : '' })] }));
16
+ }
17
+ /*
18
+ * A row that shows what it sends: the label, and under it the context the agent receives. It stays
19
+ * closed while the reply streams, once the block is answered and without a host to send it, and
20
+ * remains focusable then so a screen reader hears why.
21
+ */
22
+ export function ChoiceRenderer({ node, children, context }) {
23
+ const { t } = useTranslation('agent-chat');
24
+ const descriptionId = useId();
25
+ const { context: detail, primary, disabled } = node.props;
26
+ const { answer, onChoose } = context;
27
+ const chosen = answer !== null && answer.choiceId === node.id;
28
+ const waiting = context.phase === 'streaming';
29
+ const unavailable = disabled === true || onChoose === undefined;
30
+ const failed = answer === null && context.failedChoiceId === node.id;
31
+ const closed = waiting || unavailable || answer !== null;
32
+ const slow = useLater(chosen && answer.state === 'sending', SPINNER_AFTER_MS);
33
+ const reason = waiting
34
+ ? t('blocks.choice.waiting')
35
+ : answer === null && unavailable
36
+ ? ((disabled === true ? null : context.choiceReason) ?? t('blocks.choice.unavailable'))
37
+ : null;
38
+ const described = detail !== undefined && detail !== '';
39
+ const row = (_jsxs("button", { type: "button", "aria-disabled": closed || undefined, "aria-describedby": described ? descriptionId : undefined, className: clsx('flex w-full items-start gap-2 rounded-md border px-2 py-1.5 text-left transition-[opacity,scale,background-color] duration-150 motion-reduce:transition-none', chosen ? 'border-accent bg-accent-soft' : failed ? 'border-status-error bg-surface-hover' : 'border-border bg-surface-hover', !closed && 'hover:bg-surface-active active:scale-99', waiting ? 'opacity-60' : closed && !chosen && 'opacity-50'), onClick: () => {
40
+ if (!closed) {
41
+ onChoose?.(node.id);
42
+ }
43
+ }, children: [_jsx(Icon, { icon: ArrowRight, size: 14, className: clsx('mt-1 shrink-0', primary === true ? 'text-accent' : 'text-text-faint') }), _jsxs("span", { className: "flex min-w-0 grow flex-col", children: [_jsx("span", { className: "text-sm font-semibold text-text", children: children }), described && (_jsx("span", { id: descriptionId, className: "line-clamp-2 text-xs text-text-muted", children: detail }))] }), chosen && (_jsxs("span", { className: "mt-0.5 flex shrink-0 items-center gap-1 text-xs text-accent", children: [slow ? _jsx(Spinner, { size: 12 }) : _jsx(Icon, { icon: Check, size: 12 }), answer.state === 'queued' ? t('blocks.choice.queued') : t('blocks.choice.sent')] }))] }));
44
+ return (_jsxs("div", { className: "flex flex-col gap-1", children: [reason !== null ? (_jsx(DisabledReason, { reason: reason, children: row })) : described && detail.length > LONG_CONTEXT ? (_jsx(Tooltip, { label: detail, children: row })) : (row), failed && (_jsx("p", { role: "alert", className: "px-2 text-xs text-status-error", children: t('blocks.choice.failed') }))] }));
45
+ }
@@ -0,0 +1,14 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare function CodeBlockRenderer({ node }: UiRendererProps<UiProps<'CodeBlock'>>): import("react").JSX.Element;
4
+ export declare function ImageRenderer({ node, children, context }: UiRendererProps<UiProps<'Image'>>): import("react").JSX.Element;
5
+ export declare function SourcesRenderer({ node, children }: UiRendererProps<UiProps<'Sources'>>): import("react").JSX.Element;
6
+ export interface UiSourceCitationProps {
7
+ number: number;
8
+ title: string;
9
+ url: string;
10
+ onReveal?: () => void;
11
+ className?: string;
12
+ }
13
+ export declare function UiSourceCitation({ number, title, url, onReveal, className }: UiSourceCitationProps): import("react").JSX.Element;
14
+ export declare function SourceRenderer({ node, context }: UiRendererProps<UiProps<'Source'>>): import("react").JSX.Element;
@@ -0,0 +1,59 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { createContext, useContext, useId } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { PreviewCard } from '@adecore/ui';
6
+ import { formatNumber } from '@adecore/ui/format';
7
+ import { chatHost } from '../../../../host.js';
8
+ import { CodeBlock } from '../../CodeBlock.js';
9
+ import { CodeStreamingContext } from '../../code-streaming.js';
10
+ import { ImageThumb } from '../../ImageView.js';
11
+ import { uiChildrenOf, uiNodeLabel, uiNodeText, uiUrlDomain } from '../node-text.js';
12
+ // The number of every source by its node id, which the list counts in its own order.
13
+ const SourceNumbers = createContext(new Map());
14
+ /* Plain text in the same measure until the node closes, so highlighting never makes it jump. */
15
+ export function CodeBlockRenderer({ node }) {
16
+ return (_jsx(CodeStreamingContext.Provider, { value: !node.complete, children: _jsx(CodeBlock, { code: uiNodeText(node).replace(/^\n|\n$/g, ''), lang: node.props.language ?? 'text' }) }));
17
+ }
18
+ /* Its own component, so the host's hook is only called for an image that names an attachment. */
19
+ function AttachedImage({ scopeId, chatId, attachmentId, alt }) {
20
+ const source = chatHost().attachments.useUrl(scopeId, chatId, attachmentId);
21
+ return _jsx(ImageThumb, { source: source, alt: alt, className: "max-h-70 max-w-full object-contain" });
22
+ }
23
+ /*
24
+ * An attachment of the chat, never a path or an address the model wrote. An image of the latest
25
+ * generation stays a quiet square until the daemon resolved it to an attachment.
26
+ */
27
+ export function ImageRenderer({ node, children, context }) {
28
+ const { t } = useTranslation('agent-chat');
29
+ const { attachment, alt } = node.props;
30
+ const caption = uiNodeLabel(node);
31
+ const name = alt ?? (caption === '' ? t('blocks.image.label') : caption);
32
+ return (_jsxs("figure", { className: "flex flex-col items-start gap-1.5", children: [attachment === undefined ? (_jsx(ImageThumb, { source: { url: null, failure: t('blocks.image.unavailable') }, alt: name })) : (_jsx(AttachedImage, { scopeId: context.scopeId, chatId: context.chatId, attachmentId: attachment, alt: name })), caption !== '' && _jsx("figcaption", { className: "px-2 text-xs text-text-muted", children: children })] }));
33
+ }
34
+ export function SourcesRenderer({ node, children }) {
35
+ const { t } = useTranslation('agent-chat');
36
+ const headingId = useId();
37
+ const numbers = new Map(uiChildrenOf(node, 'Source').map((source, index) => [source.id, index + 1]));
38
+ return (_jsx(SourceNumbers, { value: numbers, children: _jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col", children: [_jsx("span", { id: headingId, className: "px-2 pb-1 text-xs font-medium text-text-muted", children: t('blocks.sources') }), _jsx("ol", { className: "chat-ui-nodes flex flex-col", children: children })] }) }));
39
+ }
40
+ /*
41
+ * A source number in running text. Resting on it or focusing it shows the title and the domain, and
42
+ * a tap reveals the row in the list of sources; only that row opens the address, so nothing loads
43
+ * before a person asks for it.
44
+ */
45
+ export function UiSourceCitation({ number, title, url, onReveal, className }) {
46
+ const { t } = useTranslation('agent-chat');
47
+ return (_jsxs(PreviewCard.Root, { children: [_jsx(PreviewCard.Trigger, { delay: 300, closeDelay: 150, render: onReveal === undefined ? _jsx("span", {}) : _jsx("button", { type: "button" }), "aria-label": onReveal === undefined ? undefined : t('blocks.citation', { number: formatNumber(number), title }), className: clsx('inline-flex h-4 min-w-4.5 items-center justify-center rounded-sm bg-text/7 px-1 align-[1px] text-2xs leading-4 text-text-muted tabular-nums', onReveal !== undefined && 'cursor-pointer hover:bg-text/12 hover:text-text', className), onClick: onReveal, children: formatNumber(number) }), _jsxs(PreviewCard.Popup, { side: "top", align: "center", sideOffset: 4, className: "flex max-w-72 flex-col px-2.5 py-1.5 text-xs", children: [_jsx("span", { className: "line-clamp-2 text-text", children: title }), _jsx("span", { className: "truncate text-text-faint", children: uiUrlDomain(url) })] })] }));
48
+ }
49
+ /*
50
+ * Opens through the host and loads nothing before, not even an icon. The row itself takes focus
51
+ * when a citation reveals it, apart from the button that opens it.
52
+ */
53
+ export function SourceRenderer({ node, context }) {
54
+ const number = useContext(SourceNumbers).get(node.id);
55
+ const { title, url } = node.props;
56
+ const { openUrl } = context;
57
+ const face = (_jsxs(_Fragment, { children: [_jsx("span", { className: "w-5 shrink-0 text-right text-text-faint tabular-nums", children: number }), _jsx("span", { className: "min-w-0 truncate text-text", children: title }), _jsx("span", { className: "shrink-0 text-text-faint", children: uiUrlDomain(url) })] }));
58
+ return (_jsx("li", { "data-ui-source": node.id, tabIndex: -1, className: "chat-ui-source scroll-my-2 rounded-md", children: openUrl === undefined ? (_jsx("span", { className: "flex h-8 items-center gap-2 px-2 text-xs", children: face })) : (_jsx("button", { type: "button", className: "flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-xs hover:bg-surface-hover", onClick: () => openUrl(url), children: face })) }));
59
+ }
@@ -0,0 +1,7 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare function StatsRenderer({ children }: UiRendererProps<UiProps<'Stats'>>): import("react").JSX.Element;
4
+ export declare function StatRenderer({ node, context }: UiRendererProps<UiProps<'Stat'>>): import("react").JSX.Element;
5
+ export declare function EntityListRenderer({ node, children }: UiRendererProps<UiProps<'EntityList'>>): import("react").JSX.Element;
6
+ export declare function EntryRenderer({ node, children }: UiRendererProps<UiProps<'Entry'>>): import("react").JSX.Element;
7
+ export declare function TableRenderer({ node, context }: UiRendererProps<UiProps<'Table'>>): import("react").JSX.Element;
@@ -0,0 +1,80 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { ArrowDown, ArrowRight, ArrowUp } from 'lucide-react';
5
+ import { Button, Icon, KeyValueList, Pill } from '@adecore/ui';
6
+ import { formatBytes, formatDuration, formatMoment, formatNumber, formatPercent, formatRounded } from '@adecore/ui/format';
7
+ import { useBlockLocal } from '../block-local.js';
8
+ import { uiChildrenOf, uiWithUnit } from '../node-text.js';
9
+ import { isNumericColumn, UI_TABLE_ROWS, uiTableCell, uiTableColumns } from '../table-data.js';
10
+ import { UI_TONE_TEXT } from '../tones.js';
11
+ import { UiFallbackPart } from '../UiFallbackPart.js';
12
+ /* EntityList draws a hairline between its rows from this many on. */
13
+ const DIVIDED_FROM = 7;
14
+ /*
15
+ * A number that live readings keep up to date. Keyed by its text, so a value that changed mounts
16
+ * again and lights up once, even when it changes again before the last light settled.
17
+ */
18
+ function LiveFigure({ text, previous, live, className }) {
19
+ const lit = live !== undefined && live.changed && !live.stale && previous !== text;
20
+ return (_jsx("span", { className: clsx(live?.stale ? 'text-text-muted' : 'text-text', lit && 'chat-ui-changed', className), children: text }, text));
21
+ }
22
+ export function StatsRenderer({ children }) {
23
+ return _jsx("div", { className: "chat-ui-nodes grid grid-cols-[repeat(auto-fit,minmax(128px,1fr))] gap-2", children: children });
24
+ }
25
+ /* The arrow and the number say which way a value went; only a tone says whether that is good. */
26
+ export function StatRenderer({ node, context }) {
27
+ const { t } = useTranslation('agent-chat');
28
+ const { label, value, previous, unit, tone } = node.props;
29
+ const live = context.liveValue?.(node.id, 'value');
30
+ const change = previous === undefined ? null : value - previous;
31
+ const arrow = change === null || change === 0 ? ArrowRight : change > 0 ? ArrowUp : ArrowDown;
32
+ const from = previous === undefined ? '' : uiWithUnit(formatRounded(previous, 2), unit);
33
+ // A change from zero has no percentage.
34
+ const percent = change === null || previous === undefined || previous === 0 ? null : formatPercent(Math.abs((change / previous) * 100));
35
+ return (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5 rounded-md bg-surface-hover px-2 py-1.5", children: [_jsx("span", { className: "truncate text-xs text-text-muted", children: label }), _jsx(LiveFigure, { text: uiWithUnit(formatRounded(value, 2), unit), previous: typeof live?.previous === 'number' ? uiWithUnit(formatRounded(live.previous, 2), unit) : undefined, live: live, className: "text-lg font-semibold tabular-nums" }), change !== null && (_jsxs("span", { className: clsx('flex items-center gap-1 text-xs tabular-nums', tone === undefined ? 'text-text-faint' : UI_TONE_TEXT[tone]), children: [_jsx(Icon, { icon: arrow, size: 12, className: "shrink-0" }), _jsx("span", { className: "min-w-0 truncate", children: percent === null ? t('blocks.stat.from', { previous: from }) : t('blocks.stat.change', { change: percent, previous: from }) })] }))] }));
36
+ }
37
+ export function EntityListRenderer({ node, children }) {
38
+ return (_jsx(KeyValueList.Root, { divided: uiChildrenOf(node, 'Entry').length >= DIVIDED_FROM, className: "chat-ui-nodes px-2", children: children }));
39
+ }
40
+ export function EntryRenderer({ node, children }) {
41
+ return (_jsxs(KeyValueList.Item, { children: [_jsx(KeyValueList.Name, { children: node.props.label }), _jsx(KeyValueList.Value, { children: children })] }));
42
+ }
43
+ function numberText(cell, unit) {
44
+ return cell.as === 'bytes' ? formatBytes(cell.value) : cell.as === 'duration' ? formatDuration(cell.value) : uiWithUnit(formatRounded(cell.value, 2), unit);
45
+ }
46
+ function Cell({ value, column, live }) {
47
+ const cell = uiTableCell(value, column);
48
+ switch (cell.kind) {
49
+ case 'empty':
50
+ return null;
51
+ case 'text':
52
+ return _jsx(_Fragment, { children: cell.text });
53
+ case 'number': {
54
+ const before = live?.previous === undefined ? undefined : uiTableCell(live.previous, column);
55
+ return (_jsx(LiveFigure, { text: numberText(cell, column.unit), previous: before?.kind === 'number' ? numberText(before, column.unit) : undefined, live: live }));
56
+ }
57
+ case 'date':
58
+ return _jsx("time", { dateTime: new Date(cell.at).toISOString(), children: formatMoment(cell.at) });
59
+ case 'file':
60
+ // A cell is no link target the host checked, so its path stays text.
61
+ return _jsx("span", { className: "font-mono text-code break-all", children: cell.path });
62
+ case 'tag':
63
+ return (_jsx(Pill, { shape: "tag", size: "sm", children: cell.text }));
64
+ }
65
+ }
66
+ /*
67
+ * Rows under a sticky head, scrolling inside 320px and sideways when wider than the column. Rows
68
+ * arrive one by one while the block streams, without animation; past fifty a person asks for the rest.
69
+ */
70
+ export function TableRenderer({ node, context }) {
71
+ const { t } = useTranslation('agent-chat');
72
+ const [all, setAll] = useBlockLocal(context, node.id, () => false);
73
+ const columns = uiTableColumns(node);
74
+ if (columns.length === 0) {
75
+ return _jsx(UiFallbackPart, { fallback: node.fallback, problem: { kind: 'failed' } });
76
+ }
77
+ const { rows } = node.props;
78
+ const shown = all ? rows : rows.slice(0, UI_TABLE_ROWS);
79
+ return (_jsxs("div", { className: "flex flex-col items-start gap-1.5", children: [_jsx("div", { className: "max-h-80 w-full overflow-auto rounded-md border border-border-soft", children: _jsxs("table", { "aria-label": t('blocks.table.label', { columns: columns.map((column) => column.title).join(', ') }), className: "w-full border-collapse text-xs tabular-nums", children: [_jsx("thead", { className: "sticky top-0 z-1 bg-surface-hover", children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", className: clsx('h-8 px-2 font-medium whitespace-nowrap text-text-muted', isNumericColumn(column) ? 'text-right' : 'text-left'), children: column.title }, column.key))) }) }), _jsx("tbody", { children: shown.map((row, index) => (_jsx("tr", { className: "border-t border-border-soft", children: columns.map((column) => (_jsx("td", { className: clsx('h-8 px-2 text-text', isNumericColumn(column) ? 'text-right whitespace-nowrap' : 'text-left'), children: _jsx(Cell, { value: row[column.key], column: column, live: isNumericColumn(column) ? context.liveValue?.(node.id, 'rows', [index, column.key]) : undefined }) }, column.key))) }, index))) })] }) }), !all && rows.length > UI_TABLE_ROWS && (_jsx(Button, { size: "xs", variant: "secondary", onClick: () => setAll(true), children: t('blocks.table.showAll', { total: formatNumber(rows.length) }) }))] }));
80
+ }
@@ -0,0 +1,8 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare function ChecklistRenderer({ node, children, context }: UiRendererProps<UiProps<'Checklist'>>): import("react").JSX.Element;
4
+ export declare function ItemRenderer({ node, children }: UiRendererProps<UiProps<'Item'>>): import("react").JSX.Element;
5
+ export declare function SwitchRenderer({ node, children, context }: UiRendererProps<UiProps<'Switch'>>): import("react").JSX.Element;
6
+ export declare function SliderRenderer({ node, context }: UiRendererProps<UiProps<'Slider'>>): import("react").JSX.Element;
7
+ export declare function SegmentedRenderer({ node, context }: UiRendererProps<UiProps<'Segmented'>>): import("react").JSX.Element;
8
+ export declare function ButtonRenderer({ node, children, context }: UiRendererProps<UiProps<'Button'>>): import("react").JSX.Element;
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { Button, Checkbox, Segmented, Slider, Switch } from '@adecore/ui';
6
+ import { uiChildrenOf, uiNodeLabel, uiWithUnit } from '../node-text.js';
7
+ const ChecklistContext = createContext({ values: [], enabled: false, toggle: () => undefined });
8
+ /*
9
+ * The binding of an input, or null for a read-only node. An input works once its own node closed and
10
+ * only through its binding, so the value never leaves the block until a Choice carries it.
11
+ */
12
+ function bindingOf(node, context) {
13
+ const binding = node.bindings.value;
14
+ return binding === undefined || !node.complete || context.answer !== null ? null : binding;
15
+ }
16
+ /* An input whose node has not closed yet stands at 60% and takes no pointer. */
17
+ const PENDING = 'pointer-events-none opacity-60';
18
+ /* The rows of a checklist as one named group. */
19
+ function ChecklistGroup({ pending, children }) {
20
+ const { t } = useTranslation('agent-chat');
21
+ return (_jsx("div", { role: "group", "aria-label": t('blocks.checklist'), className: clsx('chat-ui-nodes flex flex-col', pending && PENDING), children: children }));
22
+ }
23
+ export function ChecklistRenderer({ node, children, context }) {
24
+ const binding = bindingOf(node, context);
25
+ const values = binding?.value ?? node.props.value;
26
+ const toggle = (value) => {
27
+ binding?.onValueChange(values.includes(value) ? values.filter((entry) => entry !== value) : [...values, value]);
28
+ };
29
+ return (_jsx(ChecklistContext, { value: { values, enabled: binding !== null, toggle }, children: _jsx(ChecklistGroup, { pending: !node.complete, children: children }) }));
30
+ }
31
+ /* The whole row is the label; a link inside it keeps its own click and checks nothing. */
32
+ export function ItemRenderer({ node, children }) {
33
+ const list = useContext(ChecklistContext);
34
+ const { value } = node.props;
35
+ const toggleRow = (event) => {
36
+ if (list.enabled && !event.target.closest('button, a')) {
37
+ list.toggle(value);
38
+ }
39
+ };
40
+ return (_jsxs("div", { className: clsx('flex min-h-8 items-center gap-2 rounded-md px-2 text-sm text-text', list.enabled && 'hover:bg-surface-hover'), onClick: toggleRow, children: [_jsx(Checkbox, { checked: list.values.includes(value), onCheckedChange: () => list.toggle(value), label: uiNodeLabel(node), disabled: !list.enabled }), _jsx("div", { className: "min-w-0 grow", children: children })] }));
41
+ }
42
+ export function SwitchRenderer({ node, children, context }) {
43
+ const binding = bindingOf(node, context);
44
+ return (_jsxs("div", { className: clsx('flex min-h-7 items-center justify-between gap-3 px-2 text-sm', !node.complete && PENDING), children: [_jsx("span", { className: "min-w-0 text-text", children: children }), _jsx(Switch, { checked: binding?.value ?? node.props.value, onCheckedChange: (next) => binding?.onValueChange(next), label: uiNodeLabel(node), disabled: binding === null })] }));
45
+ }
46
+ /* Its children are the label, read as text: the slider writes its own label line. */
47
+ export function SliderRenderer({ node, context }) {
48
+ const binding = bindingOf(node, context);
49
+ const { value, min, max, step, unit } = node.props;
50
+ return (_jsx(Slider, { value: binding?.value ?? value, onValueChange: (next) => binding?.onValueChange(next), min: min, max: max, step: step,
51
+ // The slider prints its unit right after the number, so the space a unit stands apart with comes from here.
52
+ unit: uiWithUnit('', unit), label: uiNodeLabel(node), disabled: binding === null, className: clsx('px-2', !node.complete && PENDING) }));
53
+ }
54
+ /* Left aligned, never the full width. Each Option is a segment by its place, since a value may be any scalar. */
55
+ export function SegmentedRenderer({ node, context }) {
56
+ const { t } = useTranslation('agent-chat');
57
+ const binding = bindingOf(node, context);
58
+ const current = binding?.value ?? node.props.value;
59
+ const options = uiChildrenOf(node, 'Option').map((option, index) => ({ id: String(index), label: uiNodeLabel(option), value: option.props.value }));
60
+ const picked = options.find((option) => option.value === current)?.id ?? '';
61
+ return (_jsx("div", { className: clsx('px-2', !node.complete && PENDING), children: _jsx(Segmented, { value: picked, options: options, label: t('blocks.options'), disabled: binding === null, onValueChange: (id) => {
62
+ const option = options[Number(id)];
63
+ if (option !== undefined) {
64
+ binding?.onValueChange(option.value);
65
+ }
66
+ } }) }));
67
+ }
68
+ /* Runs its local action once its own node closed; like an input, it closes once the block is answered. */
69
+ export function ButtonRenderer({ node, children, context }) {
70
+ const enabled = node.onAction !== undefined && node.complete && context.answer === null && node.props.disabled !== true;
71
+ return (_jsx("div", { className: clsx('px-2', !node.complete && PENDING), children: _jsx(Button, { variant: "secondary", size: "sm", disabled: !enabled, onClick: () => node.onAction?.(), children: children }) }));
72
+ }
@@ -0,0 +1,10 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiLinkTarget, UiRenderContext, UiRendererProps } from '../render-context.js';
3
+ export declare function UiLinkChip({ target, context }: {
4
+ target: UiLinkTarget;
5
+ context: UiRenderContext;
6
+ }): import("react").JSX.Element;
7
+ export declare function FileRenderer({ node, children, context }: UiRendererProps<UiProps<'File'>>): import("react").JSX.Element;
8
+ export declare function DiffRenderer({ node, children, context }: UiRendererProps<UiProps<'Diff'>>): import("react").JSX.Element;
9
+ export declare function CommitRenderer({ node, children, context }: UiRendererProps<UiProps<'Commit'>>): import("react").JSX.Element;
10
+ export declare function NodeRenderer({ node, children, context }: UiRendererProps<UiProps<'Node'>>): import("react").JSX.Element;