@adecore/agents-react 0.70.0 → 0.71.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.
Files changed (95) hide show
  1. package/dist/chat/logic/fork.js +1 -0
  2. package/dist/chat/logic/thread-cards.js +1 -0
  3. package/dist/chat/logic/timeline.js +7 -0
  4. package/dist/chat/ui/CodeBlock.d.ts +6 -1
  5. package/dist/chat/ui/CodeBlock.js +39 -23
  6. package/dist/chat/ui/intelligent-ui/UiReply.js +11 -2
  7. package/dist/chat/ui/intelligent-ui/key-caps.d.ts +1 -0
  8. package/dist/chat/ui/intelligent-ui/key-caps.js +45 -0
  9. package/dist/chat/ui/intelligent-ui/link-action.d.ts +9 -0
  10. package/dist/chat/ui/intelligent-ui/link-action.js +32 -0
  11. package/dist/chat/ui/intelligent-ui/node-text.js +1 -1
  12. package/dist/chat/ui/intelligent-ui/patch-clip.d.ts +4 -0
  13. package/dist/chat/ui/intelligent-ui/patch-clip.js +64 -0
  14. package/dist/chat/ui/intelligent-ui/registry.js +31 -5
  15. package/dist/chat/ui/intelligent-ui/render-context.d.ts +13 -0
  16. package/dist/chat/ui/intelligent-ui/renderers/alternatives.d.ts +6 -0
  17. package/dist/chat/ui/intelligent-ui/renderers/alternatives.js +296 -0
  18. package/dist/chat/ui/intelligent-ui/renderers/changes.d.ts +4 -0
  19. package/dist/chat/ui/intelligent-ui/renderers/changes.js +266 -0
  20. package/dist/chat/ui/intelligent-ui/renderers/chart.js +522 -371
  21. package/dist/chat/ui/intelligent-ui/renderers/content.d.ts +1 -1
  22. package/dist/chat/ui/intelligent-ui/renderers/content.js +94 -43
  23. package/dist/chat/ui/intelligent-ui/renderers/data.js +478 -245
  24. package/dist/chat/ui/intelligent-ui/renderers/diff.d.ts +4 -0
  25. package/dist/chat/ui/intelligent-ui/renderers/diff.js +427 -0
  26. package/dist/chat/ui/intelligent-ui/renderers/inputs.d.ts +1 -0
  27. package/dist/chat/ui/intelligent-ui/renderers/inputs.js +354 -110
  28. package/dist/chat/ui/intelligent-ui/renderers/keys.d.ts +3 -0
  29. package/dist/chat/ui/intelligent-ui/renderers/keys.js +60 -0
  30. package/dist/chat/ui/intelligent-ui/renderers/links.d.ts +13 -2
  31. package/dist/chat/ui/intelligent-ui/renderers/links.js +65 -85
  32. package/dist/chat/ui/intelligent-ui/renderers/meter.d.ts +4 -0
  33. package/dist/chat/ui/intelligent-ui/renderers/meter.js +371 -0
  34. package/dist/chat/ui/intelligent-ui/renderers/quote.d.ts +3 -0
  35. package/dist/chat/ui/intelligent-ui/renderers/quote.js +123 -0
  36. package/dist/chat/ui/intelligent-ui/renderers/radio.d.ts +3 -0
  37. package/dist/chat/ui/intelligent-ui/renderers/radio.js +205 -0
  38. package/dist/chat/ui/intelligent-ui/renderers/structure.d.ts +2 -0
  39. package/dist/chat/ui/intelligent-ui/renderers/structure.js +156 -45
  40. package/dist/chat/ui/intelligent-ui/renderers/text.js +365 -215
  41. package/dist/chat/ui/intelligent-ui/renderers/tree.d.ts +5 -0
  42. package/dist/chat/ui/intelligent-ui/renderers/tree.js +284 -0
  43. package/dist/chat/ui/intelligent-ui/table-data.d.ts +9 -2
  44. package/dist/chat/ui/intelligent-ui/table-data.js +68 -3
  45. package/dist/chat/ui/intelligent-ui/tones.d.ts +1 -1
  46. package/dist/chat/ui/intelligent-ui/tones.js +7 -7
  47. package/dist/chat/ui/intelligent-ui/use-ui-diffs.d.ts +4 -0
  48. package/dist/chat/ui/intelligent-ui/use-ui-diffs.js +201 -0
  49. package/dist/chat/ui/rows/MessageRows.d.ts +4 -1
  50. package/dist/chat/ui/rows/MessageRows.js +92 -1
  51. package/dist/chat/ui/rows/Rows.js +45 -31
  52. package/dist/host/host.d.ts +2 -1
  53. package/dist/host/timeline-row.d.ts +5 -1
  54. package/dist/locales/en/agent-chat.d.ts +62 -0
  55. package/dist/locales/en/agent-chat.js +63 -1
  56. package/dist/locales/nl/agent-chat.d.ts +62 -0
  57. package/dist/locales/nl/agent-chat.js +63 -1
  58. package/dist/theme.css +6 -0
  59. package/package.json +9 -9
  60. package/src/chat/logic/fork.ts +1 -0
  61. package/src/chat/logic/thread-cards.ts +1 -0
  62. package/src/chat/logic/timeline.ts +4 -0
  63. package/src/chat/ui/CodeBlock.tsx +38 -18
  64. package/src/chat/ui/intelligent-ui/UiReply.tsx +13 -2
  65. package/src/chat/ui/intelligent-ui/key-caps.ts +51 -0
  66. package/src/chat/ui/intelligent-ui/link-action.ts +32 -0
  67. package/src/chat/ui/intelligent-ui/node-text.ts +1 -0
  68. package/src/chat/ui/intelligent-ui/patch-clip.ts +83 -0
  69. package/src/chat/ui/intelligent-ui/registry.ts +31 -4
  70. package/src/chat/ui/intelligent-ui/render-context.ts +21 -0
  71. package/src/chat/ui/intelligent-ui/renderers/alternatives.tsx +76 -0
  72. package/src/chat/ui/intelligent-ui/renderers/changes.tsx +97 -0
  73. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +122 -46
  74. package/src/chat/ui/intelligent-ui/renderers/content.tsx +27 -7
  75. package/src/chat/ui/intelligent-ui/renderers/data.tsx +165 -52
  76. package/src/chat/ui/intelligent-ui/renderers/diff.tsx +144 -0
  77. package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +111 -19
  78. package/src/chat/ui/intelligent-ui/renderers/keys.tsx +26 -0
  79. package/src/chat/ui/intelligent-ui/renderers/links.tsx +40 -24
  80. package/src/chat/ui/intelligent-ui/renderers/meter.tsx +105 -0
  81. package/src/chat/ui/intelligent-ui/renderers/quote.tsx +29 -0
  82. package/src/chat/ui/intelligent-ui/renderers/radio.tsx +130 -0
  83. package/src/chat/ui/intelligent-ui/renderers/structure.tsx +54 -7
  84. package/src/chat/ui/intelligent-ui/renderers/text.tsx +70 -36
  85. package/src/chat/ui/intelligent-ui/renderers/tree.tsx +85 -0
  86. package/src/chat/ui/intelligent-ui/table-data.ts +84 -6
  87. package/src/chat/ui/intelligent-ui/tones.ts +7 -7
  88. package/src/chat/ui/intelligent-ui/use-ui-diffs.ts +119 -0
  89. package/src/chat/ui/rows/MessageRows.tsx +23 -0
  90. package/src/chat/ui/rows/Rows.tsx +3 -0
  91. package/src/host/host.ts +4 -0
  92. package/src/host/timeline-row.ts +3 -0
  93. package/src/locales/en/agent-chat.ts +63 -1
  94. package/src/locales/nl/agent-chat.ts +63 -1
  95. package/src/theme.css +6 -0
@@ -6,9 +6,9 @@ import { ArrowDown, ArrowRight, ArrowUp } from 'lucide-react';
6
6
  import { createContext, useContext } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { useBlockLocal } from '../block-local.js';
9
- import { uiChildrenOf, uiWithUnit } from '../node-text.js';
10
- import { isNumericColumn, UI_TABLE_ROWS, uiTableCell, uiTableColumns } from '../table-data.js';
11
- import { UI_TONE_PILL } from '../tones.js';
9
+ import { uiChildrenOf, uiNodeLabel, uiWithUnit } from '../node-text.js';
10
+ import { isNumericColumn, UI_TABLE_ROWS, uiTableCell, uiTableColumns, uiTableOrder, uiTableSort } from '../table-data.js';
11
+ import { UI_TONE_PILL, UI_TONE_TEXT } from '../tones.js';
12
12
  import { UiFallbackPart } from '../UiFallbackPart.js';
13
13
  /* EntityList draws a hairline between its rows from this many on. */
14
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -74,9 +74,95 @@ export function StatsRenderer(t0) {
74
74
  }
75
75
  return t1;
76
76
  }
77
- /* The arrow and the number say which way a value went; only a tone says whether that is good. The tag says the change, its tooltip from what. */
77
+ const TREND_WIDTH = 100;
78
+ const TREND_HEIGHT = 24;
79
+ /* Room above and below the line, so its round ends are not cut at the highest and the lowest point. */
80
+ const TREND_PAD = 2;
81
+ /* The course of a value as one line over the width of its tile, on a scale of its own; a course that never moves is a level line. */
82
+ function TrendLine(t0) {
83
+ const $ = _c(16);
84
+ const {
85
+ points,
86
+ label,
87
+ className
88
+ } = t0;
89
+ const low = Math.min(...points);
90
+ const span = Math.max(...points) - low;
91
+ let t1;
92
+ if ($[0] !== low || $[1] !== points || $[2] !== span) {
93
+ let t2;
94
+ if ($[4] !== low || $[5] !== points.length || $[6] !== span) {
95
+ t2 = (point, index) => {
96
+ const x = index / (points.length - 1) * TREND_WIDTH;
97
+ const y = span === 0 ? TREND_HEIGHT / 2 : TREND_PAD + (1 - (point - low) / span) * (TREND_HEIGHT - 2 * TREND_PAD);
98
+ return `${index === 0 ? "M" : "L"}${Math.round(x * 100) / 100},${Math.round(y * 100) / 100}`;
99
+ };
100
+ $[4] = low;
101
+ $[5] = points.length;
102
+ $[6] = span;
103
+ $[7] = t2;
104
+ } else {
105
+ t2 = $[7];
106
+ }
107
+ t1 = points.map(t2).join(" ");
108
+ $[0] = low;
109
+ $[1] = points;
110
+ $[2] = span;
111
+ $[3] = t1;
112
+ } else {
113
+ t1 = $[3];
114
+ }
115
+ const path = t1;
116
+ let t2;
117
+ if ($[8] !== className) {
118
+ t2 = clsx("h-6 w-full", className);
119
+ $[8] = className;
120
+ $[9] = t2;
121
+ } else {
122
+ t2 = $[9];
123
+ }
124
+ let t3;
125
+ if ($[10] !== path) {
126
+ t3 = /*#__PURE__*/_jsx("path", {
127
+ d: path,
128
+ fill: "none",
129
+ stroke: "currentColor",
130
+ strokeWidth: 2,
131
+ strokeLinecap: "round",
132
+ strokeLinejoin: "round",
133
+ vectorEffect: "non-scaling-stroke"
134
+ });
135
+ $[10] = path;
136
+ $[11] = t3;
137
+ } else {
138
+ t3 = $[11];
139
+ }
140
+ let t4;
141
+ if ($[12] !== label || $[13] !== t2 || $[14] !== t3) {
142
+ t4 = /*#__PURE__*/_jsx("svg", {
143
+ role: "img",
144
+ "aria-label": label,
145
+ viewBox: `0 0 ${TREND_WIDTH} ${TREND_HEIGHT}`,
146
+ preserveAspectRatio: "none",
147
+ className: t2,
148
+ children: t3
149
+ });
150
+ $[12] = label;
151
+ $[13] = t2;
152
+ $[14] = t3;
153
+ $[15] = t4;
154
+ } else {
155
+ t4 = $[15];
156
+ }
157
+ return t4;
158
+ }
159
+ /*
160
+ * The arrow and the sign say which way a value went; only a tone says whether that is good. The change
161
+ * stands at the end of the value's line, with what it changed from in its tooltip. A value in words
162
+ * stands as written and compares with nothing.
163
+ */
78
164
  export function StatRenderer(t0) {
79
- const $ = _c(47);
165
+ const $ = _c(70);
80
166
  const {
81
167
  node,
82
168
  context
@@ -89,67 +175,94 @@ export function StatRenderer(t0) {
89
175
  value,
90
176
  previous,
91
177
  unit,
92
- tone
178
+ tone,
179
+ trend
93
180
  } = node.props;
94
181
  let T0;
182
+ let apart;
95
183
  let arrow;
96
184
  let change;
97
185
  let from;
98
186
  let live;
99
187
  let percent;
100
188
  let said;
189
+ let sign;
101
190
  let t1;
102
191
  let t2;
103
192
  let t3;
104
193
  let t4;
194
+ let t5;
195
+ let withUnit;
105
196
  if ($[0] !== context || $[1] !== label || $[2] !== node.id || $[3] !== previous || $[4] !== t || $[5] !== unit || $[6] !== value) {
106
197
  live = context.liveValue?.(node.id, "value");
107
- change = previous === undefined ? null : value - previous;
198
+ apart = typeof value === "number" && unit !== undefined && unit !== "" && unit !== "%";
199
+ let t6;
200
+ if ($[22] !== unit) {
201
+ t6 = number => uiWithUnit(formatRounded(number, 2), unit);
202
+ $[22] = unit;
203
+ $[23] = t6;
204
+ } else {
205
+ t6 = $[23];
206
+ }
207
+ withUnit = t6;
208
+ let t7;
209
+ if ($[24] !== apart || $[25] !== withUnit) {
210
+ t7 = number_0 => apart ? formatRounded(number_0, 2) : withUnit(number_0);
211
+ $[24] = apart;
212
+ $[25] = withUnit;
213
+ $[26] = t7;
214
+ } else {
215
+ t7 = $[26];
216
+ }
217
+ const figureOf = t7;
218
+ change = previous === undefined || typeof value !== "number" ? null : value - previous;
108
219
  arrow = change === null || change === 0 ? ArrowRight : change > 0 ? ArrowUp : ArrowDown;
109
- let t5;
110
- if ($[18] !== change || $[19] !== previous || $[20] !== t || $[21] !== unit) {
111
- from = previous === undefined ? "" : uiWithUnit(formatRounded(previous, 2), unit);
220
+ let t8;
221
+ if ($[27] !== change || $[28] !== previous || $[29] !== t || $[30] !== withUnit) {
222
+ from = previous === undefined ? "" : withUnit(previous);
112
223
  percent = change === null || previous === undefined || previous === 0 ? null : formatPercent(Math.abs(change / previous * 100));
113
- t5 = percent === null ? t("blocks.stat.from", {
224
+ t8 = percent === null ? t("blocks.stat.from", {
114
225
  previous: from
115
226
  }) : t("blocks.stat.change", {
116
227
  change: percent,
117
228
  previous: from
118
229
  });
119
- $[18] = change;
120
- $[19] = previous;
121
- $[20] = t;
122
- $[21] = unit;
123
- $[22] = from;
124
- $[23] = percent;
125
- $[24] = t5;
230
+ $[27] = change;
231
+ $[28] = previous;
232
+ $[29] = t;
233
+ $[30] = withUnit;
234
+ $[31] = from;
235
+ $[32] = percent;
236
+ $[33] = t8;
126
237
  } else {
127
- from = $[22];
128
- percent = $[23];
129
- t5 = $[24];
238
+ from = $[31];
239
+ percent = $[32];
240
+ t8 = $[33];
130
241
  }
131
- said = t5;
132
- t3 = "flex min-w-0 flex-col items-start gap-1.5 rounded-xl bg-ui-tile p-3";
133
- if ($[25] !== label) {
134
- t4 = /*#__PURE__*/_jsx("span", {
242
+ said = t8;
243
+ sign = change === null || change === 0 ? "" : change > 0 ? "+" : "-";
244
+ t4 = "flex min-w-0 flex-col gap-1.5 rounded-xl bg-ui-tile p-3";
245
+ if ($[34] !== label) {
246
+ t5 = /*#__PURE__*/_jsx("span", {
135
247
  className: "max-w-full truncate text-2xs text-text-muted",
136
248
  children: label
137
249
  });
138
- $[25] = label;
139
- $[26] = t4;
250
+ $[34] = label;
251
+ $[35] = t5;
140
252
  } else {
141
- t4 = $[26];
253
+ t5 = $[35];
142
254
  }
255
+ t3 = "flex min-w-0 items-baseline gap-1.5";
143
256
  T0 = LiveFigure;
144
- if ($[27] !== unit || $[28] !== value) {
145
- t1 = uiWithUnit(formatRounded(value, 2), unit);
146
- $[27] = unit;
147
- $[28] = value;
148
- $[29] = t1;
257
+ if ($[36] !== figureOf || $[37] !== value) {
258
+ t1 = typeof value === "number" ? figureOf(value) : value;
259
+ $[36] = figureOf;
260
+ $[37] = value;
261
+ $[38] = t1;
149
262
  } else {
150
- t1 = $[29];
263
+ t1 = $[38];
151
264
  }
152
- t2 = typeof live?.previous === "number" ? uiWithUnit(formatRounded(live.previous, 2), unit) : undefined;
265
+ t2 = typeof live?.previous === "number" ? figureOf(live.previous) : undefined;
153
266
  $[0] = context;
154
267
  $[1] = label;
155
268
  $[2] = node.id;
@@ -158,98 +271,145 @@ export function StatRenderer(t0) {
158
271
  $[5] = unit;
159
272
  $[6] = value;
160
273
  $[7] = T0;
161
- $[8] = arrow;
162
- $[9] = change;
163
- $[10] = from;
164
- $[11] = live;
165
- $[12] = percent;
166
- $[13] = said;
167
- $[14] = t1;
168
- $[15] = t2;
169
- $[16] = t3;
170
- $[17] = t4;
274
+ $[8] = apart;
275
+ $[9] = arrow;
276
+ $[10] = change;
277
+ $[11] = from;
278
+ $[12] = live;
279
+ $[13] = percent;
280
+ $[14] = said;
281
+ $[15] = sign;
282
+ $[16] = t1;
283
+ $[17] = t2;
284
+ $[18] = t3;
285
+ $[19] = t4;
286
+ $[20] = t5;
287
+ $[21] = withUnit;
171
288
  } else {
172
289
  T0 = $[7];
173
- arrow = $[8];
174
- change = $[9];
175
- from = $[10];
176
- live = $[11];
177
- percent = $[12];
178
- said = $[13];
179
- t1 = $[14];
180
- t2 = $[15];
181
- t3 = $[16];
182
- t4 = $[17];
290
+ apart = $[8];
291
+ arrow = $[9];
292
+ change = $[10];
293
+ from = $[11];
294
+ live = $[12];
295
+ percent = $[13];
296
+ said = $[14];
297
+ sign = $[15];
298
+ t1 = $[16];
299
+ t2 = $[17];
300
+ t3 = $[18];
301
+ t4 = $[19];
302
+ t5 = $[20];
303
+ withUnit = $[21];
183
304
  }
184
- let t5;
185
- if ($[30] !== T0 || $[31] !== live || $[32] !== t1 || $[33] !== t2) {
186
- t5 = /*#__PURE__*/_jsx(T0, {
305
+ let t6;
306
+ if ($[39] !== T0 || $[40] !== live || $[41] !== t1 || $[42] !== t2) {
307
+ t6 = /*#__PURE__*/_jsx(T0, {
187
308
  text: t1,
188
309
  previous: t2,
189
310
  live: live,
190
- className: "max-w-full truncate text-lg font-semibold text-text tabular-nums"
311
+ className: "min-w-0 truncate text-lg font-semibold text-text tabular-nums"
191
312
  });
192
- $[30] = T0;
193
- $[31] = live;
194
- $[32] = t1;
195
- $[33] = t2;
196
- $[34] = t5;
313
+ $[39] = T0;
314
+ $[40] = live;
315
+ $[41] = t1;
316
+ $[42] = t2;
317
+ $[43] = t6;
197
318
  } else {
198
- t5 = $[34];
319
+ t6 = $[43];
199
320
  }
200
- let t6;
201
- if ($[35] !== arrow || $[36] !== change || $[37] !== from || $[38] !== percent || $[39] !== said || $[40] !== tone) {
202
- t6 = change !== null && /*#__PURE__*/_jsx(Tooltip, {
321
+ let t7;
322
+ if ($[44] !== apart || $[45] !== unit) {
323
+ t7 = apart && /*#__PURE__*/_jsx("span", {
324
+ className: "max-w-1/2 shrink-0 truncate text-xs text-text-muted",
325
+ children: unit
326
+ });
327
+ $[44] = apart;
328
+ $[45] = unit;
329
+ $[46] = t7;
330
+ } else {
331
+ t7 = $[46];
332
+ }
333
+ let t8;
334
+ if ($[47] !== arrow || $[48] !== change || $[49] !== from || $[50] !== percent || $[51] !== said || $[52] !== sign || $[53] !== tone) {
335
+ t8 = change !== null && /*#__PURE__*/_jsx(Tooltip, {
203
336
  label: said,
204
- children: /*#__PURE__*/_jsx("span", {
337
+ children: /*#__PURE__*/_jsxs("span", {
205
338
  tabIndex: 0,
206
- className: "max-w-full rounded-md",
207
- children: /*#__PURE__*/_jsxs(Pill, {
208
- shape: "tag",
209
- size: "sm",
210
- tone: tone === undefined ? "muted" : UI_TONE_PILL[tone],
211
- icon: /*#__PURE__*/_jsx(Icon, {
212
- icon: arrow,
213
- size: 12,
214
- className: "shrink-0"
215
- }),
216
- children: [/*#__PURE__*/_jsx("span", {
217
- "aria-hidden": true,
218
- className: "tabular-nums",
219
- children: percent ?? from
220
- }), /*#__PURE__*/_jsx("span", {
221
- className: "sr-only",
222
- children: said
223
- })]
224
- })
339
+ className: clsx("ml-auto flex shrink-0 items-center gap-0.5 rounded-sm text-2xs font-semibold tabular-nums", UI_TONE_TEXT[tone ?? "neutral"]),
340
+ children: [/*#__PURE__*/_jsx(Icon, {
341
+ icon: arrow,
342
+ size: 12,
343
+ className: "shrink-0"
344
+ }), /*#__PURE__*/_jsx("span", {
345
+ "aria-hidden": true,
346
+ children: percent === null ? from : `${sign}${percent}`
347
+ }), /*#__PURE__*/_jsx("span", {
348
+ className: "sr-only",
349
+ children: said
350
+ })]
225
351
  })
226
352
  });
227
- $[35] = arrow;
228
- $[36] = change;
229
- $[37] = from;
230
- $[38] = percent;
231
- $[39] = said;
232
- $[40] = tone;
233
- $[41] = t6;
353
+ $[47] = arrow;
354
+ $[48] = change;
355
+ $[49] = from;
356
+ $[50] = percent;
357
+ $[51] = said;
358
+ $[52] = sign;
359
+ $[53] = tone;
360
+ $[54] = t8;
234
361
  } else {
235
- t6 = $[41];
362
+ t8 = $[54];
236
363
  }
237
- let t7;
238
- if ($[42] !== t3 || $[43] !== t4 || $[44] !== t5 || $[45] !== t6) {
239
- t7 = /*#__PURE__*/_jsxs("div", {
364
+ let t9;
365
+ if ($[55] !== t3 || $[56] !== t6 || $[57] !== t7 || $[58] !== t8) {
366
+ t9 = /*#__PURE__*/_jsxs("div", {
240
367
  className: t3,
241
- children: [t4, t5, t6]
368
+ children: [t6, t7, t8]
242
369
  });
243
- $[42] = t3;
244
- $[43] = t4;
245
- $[44] = t5;
246
- $[45] = t6;
247
- $[46] = t7;
370
+ $[55] = t3;
371
+ $[56] = t6;
372
+ $[57] = t7;
373
+ $[58] = t8;
374
+ $[59] = t9;
248
375
  } else {
249
- t7 = $[46];
376
+ t9 = $[59];
377
+ }
378
+ let t10;
379
+ if ($[60] !== t || $[61] !== tone || $[62] !== trend || $[63] !== withUnit) {
380
+ t10 = trend !== undefined && /*#__PURE__*/_jsx(TrendLine, {
381
+ points: trend,
382
+ label: t("blocks.stat.trend", {
383
+ first: withUnit(trend[0]),
384
+ last: withUnit(trend.at(-1))
385
+ }),
386
+ className: UI_TONE_TEXT[tone ?? "neutral"]
387
+ });
388
+ $[60] = t;
389
+ $[61] = tone;
390
+ $[62] = trend;
391
+ $[63] = withUnit;
392
+ $[64] = t10;
393
+ } else {
394
+ t10 = $[64];
250
395
  }
251
- return t7;
396
+ let t11;
397
+ if ($[65] !== t10 || $[66] !== t4 || $[67] !== t5 || $[68] !== t9) {
398
+ t11 = /*#__PURE__*/_jsxs("div", {
399
+ className: t4,
400
+ children: [t5, t9, t10]
401
+ });
402
+ $[65] = t10;
403
+ $[66] = t4;
404
+ $[67] = t5;
405
+ $[68] = t9;
406
+ $[69] = t11;
407
+ } else {
408
+ t11 = $[69];
409
+ }
410
+ return t11;
252
411
  }
412
+ /* Tiles up to four entries and a list from five, unless `layout` says which. */
253
413
  export function EntityListRenderer(t0) {
254
414
  const $ = _c(7);
255
415
  const {
@@ -265,7 +425,10 @@ export function EntityListRenderer(t0) {
265
425
  t1 = $[1];
266
426
  }
267
427
  const count = t1.length;
268
- if (count <= TILED_UP_TO) {
428
+ const {
429
+ layout
430
+ } = node.props;
431
+ if (layout === undefined ? count <= TILED_UP_TO : layout === "tiles") {
269
432
  let t2;
270
433
  if ($[2] !== children) {
271
434
  t2 = /*#__PURE__*/_jsx(EntityTiles, {
@@ -299,84 +462,103 @@ export function EntityListRenderer(t0) {
299
462
  return t3;
300
463
  }
301
464
  export function EntryRenderer(t0) {
302
- const $ = _c(14);
465
+ const $ = _c(17);
303
466
  const {
304
467
  node,
305
468
  children
306
469
  } = t0;
307
470
  const tiled = useContext(EntityTiles);
471
+ let t1;
472
+ if ($[0] !== children || $[1] !== node) {
473
+ t1 = entryValue(node.props, uiNodeLabel(node)) ?? children;
474
+ $[0] = children;
475
+ $[1] = node;
476
+ $[2] = t1;
477
+ } else {
478
+ t1 = $[2];
479
+ }
480
+ const value = t1;
308
481
  if (tiled) {
309
- let t1;
310
- if ($[0] !== node.props.label) {
311
- t1 = /*#__PURE__*/_jsx("span", {
482
+ let t2;
483
+ if ($[3] !== node.props.label) {
484
+ t2 = /*#__PURE__*/_jsx("span", {
312
485
  className: "truncate text-2xs text-text-muted",
313
486
  children: node.props.label
314
487
  });
315
- $[0] = node.props.label;
316
- $[1] = t1;
488
+ $[3] = node.props.label;
489
+ $[4] = t2;
317
490
  } else {
318
- t1 = $[1];
491
+ t2 = $[4];
319
492
  }
320
- let t2;
321
- if ($[2] !== children) {
322
- t2 = /*#__PURE__*/_jsx("span", {
493
+ let t3;
494
+ if ($[5] !== value) {
495
+ t3 = /*#__PURE__*/_jsx("span", {
323
496
  className: "text-2xs font-semibold wrap-break-word text-text",
324
- children: children
497
+ children: value
325
498
  });
326
- $[2] = children;
327
- $[3] = t2;
499
+ $[5] = value;
500
+ $[6] = t3;
328
501
  } else {
329
- t2 = $[3];
502
+ t3 = $[6];
330
503
  }
331
- let t3;
332
- if ($[4] !== t1 || $[5] !== t2) {
333
- t3 = /*#__PURE__*/_jsxs("div", {
504
+ let t4;
505
+ if ($[7] !== t2 || $[8] !== t3) {
506
+ t4 = /*#__PURE__*/_jsxs("div", {
334
507
  className: "flex min-w-0 flex-col gap-0.5 rounded-xl bg-ui-tile px-3 py-2",
335
- children: [t1, t2]
508
+ children: [t2, t3]
336
509
  });
337
- $[4] = t1;
338
- $[5] = t2;
339
- $[6] = t3;
510
+ $[7] = t2;
511
+ $[8] = t3;
512
+ $[9] = t4;
340
513
  } else {
341
- t3 = $[6];
514
+ t4 = $[9];
342
515
  }
343
- return t3;
344
- }
345
- let t1;
346
- if ($[7] !== node.props.label) {
347
- t1 = /*#__PURE__*/_jsx(KeyValueList.Name, {
348
- children: node.props.label
349
- });
350
- $[7] = node.props.label;
351
- $[8] = t1;
352
- } else {
353
- t1 = $[8];
516
+ return t4;
354
517
  }
355
518
  let t2;
356
- if ($[9] !== children) {
357
- t2 = /*#__PURE__*/_jsx(KeyValueList.Value, {
358
- children: children
519
+ if ($[10] !== node.props.label) {
520
+ t2 = /*#__PURE__*/_jsx(KeyValueList.Name, {
521
+ children: node.props.label
359
522
  });
360
- $[9] = children;
361
- $[10] = t2;
523
+ $[10] = node.props.label;
524
+ $[11] = t2;
362
525
  } else {
363
- t2 = $[10];
526
+ t2 = $[11];
364
527
  }
365
528
  let t3;
366
- if ($[11] !== t1 || $[12] !== t2) {
367
- t3 = /*#__PURE__*/_jsxs(KeyValueList.Item, {
368
- children: [t1, t2]
529
+ if ($[12] !== value) {
530
+ t3 = /*#__PURE__*/_jsx(KeyValueList.Value, {
531
+ children: value
369
532
  });
370
- $[11] = t1;
371
- $[12] = t2;
533
+ $[12] = value;
372
534
  $[13] = t3;
373
535
  } else {
374
536
  t3 = $[13];
375
537
  }
376
- return t3;
538
+ let t4;
539
+ if ($[14] !== t2 || $[15] !== t3) {
540
+ t4 = /*#__PURE__*/_jsxs(KeyValueList.Item, {
541
+ children: [t2, t3]
542
+ });
543
+ $[14] = t2;
544
+ $[15] = t3;
545
+ $[16] = t4;
546
+ } else {
547
+ t4 = $[16];
548
+ }
549
+ return t4;
377
550
  }
378
551
  function numberText(cell, unit) {
379
- return cell.as === 'bytes' ? formatBytes(cell.value) : cell.as === 'duration' ? formatDuration(cell.value) : uiWithUnit(formatRounded(cell.value, 2), unit);
552
+ switch (cell.as) {
553
+ case 'bytes':
554
+ return formatBytes(cell.value);
555
+ case 'duration':
556
+ return formatDuration(cell.value);
557
+ case 'percent':
558
+ return formatPercent(cell.value);
559
+ case 'number':
560
+ return uiWithUnit(formatRounded(cell.value, 2), unit);
561
+ }
380
562
  }
381
563
  /* What a cell reads as, so two readings that draw the same do not light up. */
382
564
  function cellText(cell, column) {
@@ -394,6 +576,10 @@ function cellText(cell, column) {
394
576
  return cell.path;
395
577
  }
396
578
  }
579
+ /* The tone a column gives a tag by its text; a text the column does not name stays quiet. */
580
+ function tagTone(text, column) {
581
+ return column.tones !== undefined && Object.hasOwn(column.tones, text) ? column.tones[text] : undefined;
582
+ }
397
583
  function cellContent(cell, column) {
398
584
  switch (cell.kind) {
399
585
  case 'text':
@@ -412,13 +598,34 @@ function cellContent(cell, column) {
412
598
  children: cell.path
413
599
  });
414
600
  case 'tag':
415
- return /*#__PURE__*/_jsx(Pill, {
416
- shape: "tag",
417
- size: "sm",
418
- children: cell.text
419
- });
601
+ {
602
+ const tone = tagTone(cell.text, column);
603
+ return /*#__PURE__*/_jsx(Pill, {
604
+ shape: "tag",
605
+ size: "sm",
606
+ tone: tone === undefined ? 'muted' : UI_TONE_PILL[tone],
607
+ children: cell.text
608
+ });
609
+ }
420
610
  }
421
611
  }
612
+ /* The value of an Entry drawn as a table cell of its kind, or null where it stands as written: without a kind, and for text the kind cannot read. */
613
+ function entryValue({
614
+ label,
615
+ as
616
+ }, written) {
617
+ if (as === undefined || as === 'text') {
618
+ return null;
619
+ }
620
+ const column = {
621
+ key: 'value',
622
+ title: label,
623
+ as
624
+ };
625
+ // A date in milliseconds arrives here as its digits, which a table would get as a number.
626
+ const cell = uiTableCell(as === 'date' && /^\d+$/.test(written) ? Number(written) : written, column);
627
+ return cell.kind === 'empty' || cell.kind === 'text' ? null : cellContent(cell, column);
628
+ }
422
629
  function Cell(t0) {
423
630
  const $ = _c(18);
424
631
  const {
@@ -499,9 +706,10 @@ function Cell(t0) {
499
706
  /*
500
707
  * Rows under a sticky head, scrolling inside 320px and sideways when wider than the column. Rows
501
708
  * arrive one by one while the block streams, without animation; past fifty a person asks for the rest.
709
+ * A head sorts by its column, from the order `sort` asked for until a person picks one.
502
710
  */
503
711
  export function TableRenderer(t0) {
504
- const $ = _c(41);
712
+ const $ = _c(43);
505
713
  const {
506
714
  node,
507
715
  context
@@ -510,6 +718,7 @@ export function TableRenderer(t0) {
510
718
  t
511
719
  } = useTranslation("agent-chat");
512
720
  const [all, setAll] = useBlockLocal(context, node.id, _temp);
721
+ const [picked, setPicked] = useBlockLocal(context, `${node.id}:sort`, _temp2);
513
722
  let T0;
514
723
  let rows;
515
724
  let t1;
@@ -521,30 +730,30 @@ export function TableRenderer(t0) {
521
730
  let t7;
522
731
  let t8;
523
732
  let t9;
524
- if ($[0] !== all || $[1] !== context || $[2] !== node || $[3] !== t) {
733
+ if ($[0] !== all || $[1] !== context || $[2] !== node || $[3] !== picked || $[4] !== setPicked || $[5] !== t) {
525
734
  t9 = Symbol.for("react.early_return_sentinel");
526
735
  bb0: {
527
736
  const columns = uiTableColumns(node);
528
737
  if (columns.length === 0) {
529
738
  let t10;
530
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
739
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
531
740
  t10 = {
532
741
  kind: "failed"
533
742
  };
534
- $[15] = t10;
743
+ $[17] = t10;
535
744
  } else {
536
- t10 = $[15];
745
+ t10 = $[17];
537
746
  }
538
747
  let t11;
539
- if ($[16] !== node.fallback) {
748
+ if ($[18] !== node.fallback) {
540
749
  t11 = /*#__PURE__*/_jsx(UiFallbackPart, {
541
750
  fallback: node.fallback,
542
751
  problem: t10
543
752
  });
544
- $[16] = node.fallback;
545
- $[17] = t11;
753
+ $[18] = node.fallback;
754
+ $[19] = t11;
546
755
  } else {
547
- t11 = $[17];
756
+ t11 = $[19];
548
757
  }
549
758
  t9 = t11;
550
759
  break bb0;
@@ -552,113 +761,138 @@ export function TableRenderer(t0) {
552
761
  ({
553
762
  rows
554
763
  } = node.props);
555
- const shown = all ? rows : rows.slice(0, UI_TABLE_ROWS);
764
+ const sort = picked !== null && columns.some(column => column.key === picked.key) ? picked : uiTableSort(node.props.sort, columns);
765
+ const sorted = columns.find(column_0 => column_0.key === sort?.key);
766
+ const order = sorted === undefined || sort === null ? rows.map(_temp3) : uiTableOrder(rows, sorted, sort.descending);
767
+ const shown = all ? order : order.slice(0, UI_TABLE_ROWS);
556
768
  t8 = "flex flex-col items-start gap-1.5";
557
769
  T0 = ScrollArea;
558
770
  t5 = "both";
559
771
  t6 = "chat-ui-flat max-h-80 w-full rounded-xl bg-ui-tile";
560
772
  t7 = "chat-ui-flat px-1.5 pb-1.5";
561
773
  t2 = t("blocks.table.label", {
562
- columns: columns.map(_temp2).join(", ")
774
+ columns: columns.map(_temp4).join(", ")
563
775
  });
564
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
776
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
565
777
  t3 = clsx("w-full border-separate border-spacing-0 text-xs tabular-nums", "[&_tbody_tr:first-child_td:first-child]:rounded-tl-lg [&_tbody_tr:first-child_td:last-child]:rounded-tr-lg", "[&_tbody_tr:last-child_td:first-child]:rounded-bl-lg [&_tbody_tr:last-child_td:last-child]:rounded-br-lg");
566
- $[18] = t3;
778
+ $[20] = t3;
567
779
  } else {
568
- t3 = $[18];
780
+ t3 = $[20];
569
781
  }
570
782
  t4 = /*#__PURE__*/_jsx("thead", {
571
783
  className: "sticky top-0 z-1 bg-ui-tile",
572
784
  children: /*#__PURE__*/_jsx("tr", {
573
- children: columns.map(_temp3)
785
+ children: columns.map(column_2 => {
786
+ const descending = sort?.key === column_2.key ? sort.descending : null;
787
+ return /*#__PURE__*/_jsx("th", {
788
+ scope: "col",
789
+ "aria-sort": descending === null ? undefined : descending ? "descending" : "ascending",
790
+ className: clsx("h-8 px-2 text-2xs font-medium whitespace-nowrap", isNumericColumn(column_2) ? "text-right" : "text-left"),
791
+ children: /*#__PURE__*/_jsxs("button", {
792
+ type: "button",
793
+ className: clsx("inline-flex items-center gap-1 rounded-sm text-left hover:text-text", descending === null ? "text-text-muted" : "text-text", isNumericColumn(column_2) && "flex-row-reverse"),
794
+ onClick: () => setPicked({
795
+ key: column_2.key,
796
+ descending: descending === false
797
+ }),
798
+ children: [column_2.title, descending !== null && /*#__PURE__*/_jsx(Icon, {
799
+ icon: descending ? ArrowDown : ArrowUp,
800
+ size: 12,
801
+ className: "shrink-0"
802
+ })]
803
+ })
804
+ }, column_2.key);
805
+ })
574
806
  })
575
807
  });
576
- t1 = shown.map((row, index) => /*#__PURE__*/_jsx("tr", {
577
- children: columns.map((column_1, at) => /*#__PURE__*/_jsx("td", {
578
- className: clsx("h-9 bg-ui-inset px-2 text-text", index > 0 && "border-t border-border-soft", at === 0 && "font-medium", isNumericColumn(column_1) ? "text-right whitespace-nowrap" : "text-left"),
808
+ t1 = shown.map((index_0, place) => /*#__PURE__*/_jsx("tr", {
809
+ children: columns.map((column_3, at) => /*#__PURE__*/_jsx("td", {
810
+ className: clsx("h-9 bg-ui-inset px-2 text-text", place > 0 && "border-t border-border-soft", at === 0 && "font-medium", isNumericColumn(column_3) ? "text-right whitespace-nowrap" : "text-left"),
579
811
  children: /*#__PURE__*/_jsx(Cell, {
580
- value: row[column_1.key],
581
- column: column_1,
582
- live: context.liveValue?.(node.id, "rows", [index, column_1.key])
812
+ value: rows[index_0][column_3.key],
813
+ column: column_3,
814
+ live: context.liveValue?.(node.id, "rows", [index_0, column_3.key])
583
815
  })
584
- }, column_1.key))
585
- }, index));
816
+ }, column_3.key))
817
+ }, index_0));
586
818
  }
587
819
  $[0] = all;
588
820
  $[1] = context;
589
821
  $[2] = node;
590
- $[3] = t;
591
- $[4] = T0;
592
- $[5] = rows;
593
- $[6] = t1;
594
- $[7] = t2;
595
- $[8] = t3;
596
- $[9] = t4;
597
- $[10] = t5;
598
- $[11] = t6;
599
- $[12] = t7;
600
- $[13] = t8;
601
- $[14] = t9;
822
+ $[3] = picked;
823
+ $[4] = setPicked;
824
+ $[5] = t;
825
+ $[6] = T0;
826
+ $[7] = rows;
827
+ $[8] = t1;
828
+ $[9] = t2;
829
+ $[10] = t3;
830
+ $[11] = t4;
831
+ $[12] = t5;
832
+ $[13] = t6;
833
+ $[14] = t7;
834
+ $[15] = t8;
835
+ $[16] = t9;
602
836
  } else {
603
- T0 = $[4];
604
- rows = $[5];
605
- t1 = $[6];
606
- t2 = $[7];
607
- t3 = $[8];
608
- t4 = $[9];
609
- t5 = $[10];
610
- t6 = $[11];
611
- t7 = $[12];
612
- t8 = $[13];
613
- t9 = $[14];
837
+ T0 = $[6];
838
+ rows = $[7];
839
+ t1 = $[8];
840
+ t2 = $[9];
841
+ t3 = $[10];
842
+ t4 = $[11];
843
+ t5 = $[12];
844
+ t6 = $[13];
845
+ t7 = $[14];
846
+ t8 = $[15];
847
+ t9 = $[16];
614
848
  }
615
849
  if (t9 !== Symbol.for("react.early_return_sentinel")) {
616
850
  return t9;
617
851
  }
618
852
  let t10;
619
- if ($[19] !== t1) {
853
+ if ($[21] !== t1) {
620
854
  t10 = /*#__PURE__*/_jsx("tbody", {
621
855
  children: t1
622
856
  });
623
- $[19] = t1;
624
- $[20] = t10;
857
+ $[21] = t1;
858
+ $[22] = t10;
625
859
  } else {
626
- t10 = $[20];
860
+ t10 = $[22];
627
861
  }
628
862
  let t11;
629
- if ($[21] !== t10 || $[22] !== t2 || $[23] !== t3 || $[24] !== t4) {
863
+ if ($[23] !== t10 || $[24] !== t2 || $[25] !== t3 || $[26] !== t4) {
630
864
  t11 = /*#__PURE__*/_jsxs("table", {
631
865
  "aria-label": t2,
632
866
  className: t3,
633
867
  children: [t4, t10]
634
868
  });
635
- $[21] = t10;
636
- $[22] = t2;
637
- $[23] = t3;
638
- $[24] = t4;
639
- $[25] = t11;
869
+ $[23] = t10;
870
+ $[24] = t2;
871
+ $[25] = t3;
872
+ $[26] = t4;
873
+ $[27] = t11;
640
874
  } else {
641
- t11 = $[25];
875
+ t11 = $[27];
642
876
  }
643
877
  let t12;
644
- if ($[26] !== T0 || $[27] !== t11 || $[28] !== t5 || $[29] !== t6 || $[30] !== t7) {
878
+ if ($[28] !== T0 || $[29] !== t11 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7) {
645
879
  t12 = /*#__PURE__*/_jsx(T0, {
646
880
  axis: t5,
647
881
  className: t6,
648
882
  viewportClassName: t7,
649
883
  children: t11
650
884
  });
651
- $[26] = T0;
652
- $[27] = t11;
653
- $[28] = t5;
654
- $[29] = t6;
655
- $[30] = t7;
656
- $[31] = t12;
885
+ $[28] = T0;
886
+ $[29] = t11;
887
+ $[30] = t5;
888
+ $[31] = t6;
889
+ $[32] = t7;
890
+ $[33] = t12;
657
891
  } else {
658
- t12 = $[31];
892
+ t12 = $[33];
659
893
  }
660
894
  let t13;
661
- if ($[32] !== all || $[33] !== rows || $[34] !== setAll || $[35] !== t) {
895
+ if ($[34] !== all || $[35] !== rows || $[36] !== setAll || $[37] !== t) {
662
896
  t13 = !all && rows.length > UI_TABLE_ROWS && /*#__PURE__*/_jsx(Button, {
663
897
  size: "xs",
664
898
  variant: "secondary",
@@ -667,38 +901,37 @@ export function TableRenderer(t0) {
667
901
  total: formatNumber(rows.length)
668
902
  })
669
903
  });
670
- $[32] = all;
671
- $[33] = rows;
672
- $[34] = setAll;
673
- $[35] = t;
674
- $[36] = t13;
904
+ $[34] = all;
905
+ $[35] = rows;
906
+ $[36] = setAll;
907
+ $[37] = t;
908
+ $[38] = t13;
675
909
  } else {
676
- t13 = $[36];
910
+ t13 = $[38];
677
911
  }
678
912
  let t14;
679
- if ($[37] !== t12 || $[38] !== t13 || $[39] !== t8) {
913
+ if ($[39] !== t12 || $[40] !== t13 || $[41] !== t8) {
680
914
  t14 = /*#__PURE__*/_jsxs("div", {
681
915
  className: t8,
682
916
  children: [t12, t13]
683
917
  });
684
- $[37] = t12;
685
- $[38] = t13;
686
- $[39] = t8;
687
- $[40] = t14;
918
+ $[39] = t12;
919
+ $[40] = t13;
920
+ $[41] = t8;
921
+ $[42] = t14;
688
922
  } else {
689
- t14 = $[40];
923
+ t14 = $[42];
690
924
  }
691
925
  return t14;
692
926
  }
693
- function _temp3(column_0) {
694
- return /*#__PURE__*/_jsx("th", {
695
- scope: "col",
696
- className: clsx("h-8 px-2 text-2xs font-medium whitespace-nowrap text-text-muted", isNumericColumn(column_0) ? "text-right" : "text-left"),
697
- children: column_0.title
698
- }, column_0.key);
927
+ function _temp4(column_1) {
928
+ return column_1.title;
929
+ }
930
+ function _temp3(_, index) {
931
+ return index;
699
932
  }
700
- function _temp2(column) {
701
- return column.title;
933
+ function _temp2() {
934
+ return null;
702
935
  }
703
936
  function _temp() {
704
937
  return false;