@adecore/agents-react 0.70.1 → 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 (82) hide show
  1. package/dist/chat/ui/CodeBlock.d.ts +6 -1
  2. package/dist/chat/ui/CodeBlock.js +39 -23
  3. package/dist/chat/ui/intelligent-ui/UiReply.js +11 -2
  4. package/dist/chat/ui/intelligent-ui/key-caps.d.ts +1 -0
  5. package/dist/chat/ui/intelligent-ui/key-caps.js +45 -0
  6. package/dist/chat/ui/intelligent-ui/link-action.d.ts +9 -0
  7. package/dist/chat/ui/intelligent-ui/link-action.js +32 -0
  8. package/dist/chat/ui/intelligent-ui/node-text.js +1 -1
  9. package/dist/chat/ui/intelligent-ui/patch-clip.d.ts +4 -0
  10. package/dist/chat/ui/intelligent-ui/patch-clip.js +64 -0
  11. package/dist/chat/ui/intelligent-ui/registry.js +31 -5
  12. package/dist/chat/ui/intelligent-ui/render-context.d.ts +13 -0
  13. package/dist/chat/ui/intelligent-ui/renderers/alternatives.d.ts +6 -0
  14. package/dist/chat/ui/intelligent-ui/renderers/alternatives.js +296 -0
  15. package/dist/chat/ui/intelligent-ui/renderers/changes.d.ts +4 -0
  16. package/dist/chat/ui/intelligent-ui/renderers/changes.js +266 -0
  17. package/dist/chat/ui/intelligent-ui/renderers/chart.js +522 -371
  18. package/dist/chat/ui/intelligent-ui/renderers/content.d.ts +1 -1
  19. package/dist/chat/ui/intelligent-ui/renderers/content.js +94 -43
  20. package/dist/chat/ui/intelligent-ui/renderers/data.js +478 -245
  21. package/dist/chat/ui/intelligent-ui/renderers/diff.d.ts +4 -0
  22. package/dist/chat/ui/intelligent-ui/renderers/diff.js +427 -0
  23. package/dist/chat/ui/intelligent-ui/renderers/inputs.d.ts +1 -0
  24. package/dist/chat/ui/intelligent-ui/renderers/inputs.js +354 -110
  25. package/dist/chat/ui/intelligent-ui/renderers/keys.d.ts +3 -0
  26. package/dist/chat/ui/intelligent-ui/renderers/keys.js +60 -0
  27. package/dist/chat/ui/intelligent-ui/renderers/links.d.ts +13 -2
  28. package/dist/chat/ui/intelligent-ui/renderers/links.js +65 -85
  29. package/dist/chat/ui/intelligent-ui/renderers/meter.d.ts +4 -0
  30. package/dist/chat/ui/intelligent-ui/renderers/meter.js +371 -0
  31. package/dist/chat/ui/intelligent-ui/renderers/quote.d.ts +3 -0
  32. package/dist/chat/ui/intelligent-ui/renderers/quote.js +123 -0
  33. package/dist/chat/ui/intelligent-ui/renderers/radio.d.ts +3 -0
  34. package/dist/chat/ui/intelligent-ui/renderers/radio.js +205 -0
  35. package/dist/chat/ui/intelligent-ui/renderers/structure.d.ts +2 -0
  36. package/dist/chat/ui/intelligent-ui/renderers/structure.js +156 -45
  37. package/dist/chat/ui/intelligent-ui/renderers/text.js +365 -215
  38. package/dist/chat/ui/intelligent-ui/renderers/tree.d.ts +5 -0
  39. package/dist/chat/ui/intelligent-ui/renderers/tree.js +284 -0
  40. package/dist/chat/ui/intelligent-ui/table-data.d.ts +9 -2
  41. package/dist/chat/ui/intelligent-ui/table-data.js +68 -3
  42. package/dist/chat/ui/intelligent-ui/tones.d.ts +1 -1
  43. package/dist/chat/ui/intelligent-ui/tones.js +7 -7
  44. package/dist/chat/ui/intelligent-ui/use-ui-diffs.d.ts +4 -0
  45. package/dist/chat/ui/intelligent-ui/use-ui-diffs.js +201 -0
  46. package/dist/host/host.d.ts +2 -1
  47. package/dist/locales/en/agent-chat.d.ts +56 -0
  48. package/dist/locales/en/agent-chat.js +57 -1
  49. package/dist/locales/nl/agent-chat.d.ts +56 -0
  50. package/dist/locales/nl/agent-chat.js +57 -1
  51. package/dist/theme.css +6 -0
  52. package/package.json +9 -9
  53. package/src/chat/ui/CodeBlock.tsx +38 -18
  54. package/src/chat/ui/intelligent-ui/UiReply.tsx +13 -2
  55. package/src/chat/ui/intelligent-ui/key-caps.ts +51 -0
  56. package/src/chat/ui/intelligent-ui/link-action.ts +32 -0
  57. package/src/chat/ui/intelligent-ui/node-text.ts +1 -0
  58. package/src/chat/ui/intelligent-ui/patch-clip.ts +83 -0
  59. package/src/chat/ui/intelligent-ui/registry.ts +31 -4
  60. package/src/chat/ui/intelligent-ui/render-context.ts +21 -0
  61. package/src/chat/ui/intelligent-ui/renderers/alternatives.tsx +76 -0
  62. package/src/chat/ui/intelligent-ui/renderers/changes.tsx +97 -0
  63. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +122 -46
  64. package/src/chat/ui/intelligent-ui/renderers/content.tsx +27 -7
  65. package/src/chat/ui/intelligent-ui/renderers/data.tsx +165 -52
  66. package/src/chat/ui/intelligent-ui/renderers/diff.tsx +144 -0
  67. package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +111 -19
  68. package/src/chat/ui/intelligent-ui/renderers/keys.tsx +26 -0
  69. package/src/chat/ui/intelligent-ui/renderers/links.tsx +40 -24
  70. package/src/chat/ui/intelligent-ui/renderers/meter.tsx +105 -0
  71. package/src/chat/ui/intelligent-ui/renderers/quote.tsx +29 -0
  72. package/src/chat/ui/intelligent-ui/renderers/radio.tsx +130 -0
  73. package/src/chat/ui/intelligent-ui/renderers/structure.tsx +54 -7
  74. package/src/chat/ui/intelligent-ui/renderers/text.tsx +70 -36
  75. package/src/chat/ui/intelligent-ui/renderers/tree.tsx +85 -0
  76. package/src/chat/ui/intelligent-ui/table-data.ts +84 -6
  77. package/src/chat/ui/intelligent-ui/tones.ts +7 -7
  78. package/src/chat/ui/intelligent-ui/use-ui-diffs.ts +119 -0
  79. package/src/host/host.ts +4 -0
  80. package/src/locales/en/agent-chat.ts +57 -1
  81. package/src/locales/nl/agent-chat.ts +57 -1
  82. package/src/theme.css +6 -0
@@ -0,0 +1,4 @@
1
+ import type { UiProps } from '@adecore/intelligent-ui';
2
+ import type { UiRendererProps } from '../render-context.js';
3
+ export declare const UI_DIFF_LINES = 200;
4
+ export declare function DiffRenderer({ node, children, context }: UiRendererProps<UiProps<'Diff'>>): import("react").JSX.Element;
@@ -0,0 +1,427 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Button, LazyBoundary, lazyNamed, Spinner } from '@adecore/ui';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { uiReasonText } from '../node-text.js';
5
+ import { uiClipPatch } from '../patch-clip.js';
6
+ import { LinkRow, UiLinkChip } from './links.js';
7
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ const UnifiedDiff = lazyNamed(() => import('../../UnifiedDiff.js'), 'default');
9
+ /* The lines of change and context an open Diff shows in its block; the whole change opens in the host's own diff. */
10
+ export const UI_DIFF_LINES = 200;
11
+ /* The tallest the patch stands in its tile, in pixels, past which it scrolls. */
12
+ const DIFF_HEIGHT = 320;
13
+ function changeKind(patch) {
14
+ return /^new file mode /m.test(patch) ? 'add' : /^deleted file mode /m.test(patch) ? 'delete' : 'update';
15
+ }
16
+ /* The chip of the file and what the agent says about it, with whatever the state adds between them. */
17
+ function DiffHead(t0) {
18
+ const $ = _c(8);
19
+ const {
20
+ chip,
21
+ described,
22
+ children
23
+ } = t0;
24
+ let t1;
25
+ if ($[0] !== chip) {
26
+ t1 = /*#__PURE__*/_jsx("span", {
27
+ className: "flex max-w-full min-w-0 items-center gap-1.5",
28
+ children: chip
29
+ });
30
+ $[0] = chip;
31
+ $[1] = t1;
32
+ } else {
33
+ t1 = $[1];
34
+ }
35
+ let t2;
36
+ if ($[2] !== children || $[3] !== described) {
37
+ t2 = described && /*#__PURE__*/_jsx("span", {
38
+ className: "min-w-0 wrap-break-word text-text-muted",
39
+ children: children
40
+ });
41
+ $[2] = children;
42
+ $[3] = described;
43
+ $[4] = t2;
44
+ } else {
45
+ t2 = $[4];
46
+ }
47
+ let t3;
48
+ if ($[5] !== t1 || $[6] !== t2) {
49
+ t3 = /*#__PURE__*/_jsxs("div", {
50
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-xs",
51
+ children: [t1, t2]
52
+ });
53
+ $[5] = t1;
54
+ $[6] = t2;
55
+ $[7] = t3;
56
+ } else {
57
+ t3 = $[7];
58
+ }
59
+ return t3;
60
+ }
61
+ /*
62
+ * The change of one file as the host read it from git, in a tile headed by the chip a closed Diff is. The
63
+ * block shows the first `UI_DIFF_LINES` lines; past them, or where the host cut the patch itself, a button
64
+ * opens the whole change as the chip does.
65
+ */
66
+ function OpenDiff(t0) {
67
+ const $ = _c(41);
68
+ const {
69
+ target,
70
+ diff,
71
+ hideWhitespace,
72
+ described,
73
+ context,
74
+ children
75
+ } = t0;
76
+ const {
77
+ t
78
+ } = useTranslation("agent-chat");
79
+ let openLink;
80
+ let openable;
81
+ let partial;
82
+ let t1;
83
+ let t2;
84
+ let t3;
85
+ let t4;
86
+ if ($[0] !== children || $[1] !== context || $[2] !== described || $[3] !== diff.patch || $[4] !== diff.truncated || $[5] !== hideWhitespace || $[6] !== t || $[7] !== target) {
87
+ const {
88
+ patch,
89
+ clipped
90
+ } = uiClipPatch(diff.patch, UI_DIFF_LINES);
91
+ partial = clipped || diff.truncated;
92
+ ({
93
+ openLink
94
+ } = context);
95
+ let t5;
96
+ if ($[15] !== context || $[16] !== openLink || $[17] !== target) {
97
+ t5 = openLink !== undefined && context.link?.(target).state === "chip";
98
+ $[15] = context;
99
+ $[16] = openLink;
100
+ $[17] = target;
101
+ $[18] = t5;
102
+ } else {
103
+ t5 = $[18];
104
+ }
105
+ openable = t5;
106
+ if ($[19] !== t || $[20] !== target.path) {
107
+ t1 = t("blocks.diff.label", {
108
+ path: target.path
109
+ });
110
+ $[19] = t;
111
+ $[20] = target.path;
112
+ $[21] = t1;
113
+ } else {
114
+ t1 = $[21];
115
+ }
116
+ t2 = "flex min-w-0 flex-col gap-2 rounded-xl bg-ui-tile p-2";
117
+ let t6;
118
+ if ($[22] !== context || $[23] !== target) {
119
+ t6 = /*#__PURE__*/_jsx(UiLinkChip, {
120
+ target: target,
121
+ context: context
122
+ });
123
+ $[22] = context;
124
+ $[23] = target;
125
+ $[24] = t6;
126
+ } else {
127
+ t6 = $[24];
128
+ }
129
+ if ($[25] !== children || $[26] !== described || $[27] !== t6) {
130
+ t3 = /*#__PURE__*/_jsx("figcaption", {
131
+ className: "px-1 pt-0.5",
132
+ children: /*#__PURE__*/_jsx(DiffHead, {
133
+ chip: t6,
134
+ described: described,
135
+ children: children
136
+ })
137
+ });
138
+ $[25] = children;
139
+ $[26] = described;
140
+ $[27] = t6;
141
+ $[28] = t3;
142
+ } else {
143
+ t3 = $[28];
144
+ }
145
+ t4 = patch.trim() === "" ? /*#__PURE__*/_jsx("p", {
146
+ className: "px-1 pb-0.5 text-xs text-text-muted",
147
+ children: t("blocks.diff.unchanged")
148
+ }) : /*#__PURE__*/_jsx("div", {
149
+ className: "overflow-hidden rounded-lg bg-ui-inset",
150
+ children: /*#__PURE__*/_jsx(LazyBoundary, {
151
+ fallback: /*#__PURE__*/_jsx("div", {
152
+ className: "px-3 py-2 text-xs text-text-faint",
153
+ children: t("work.loadingDiff")
154
+ }),
155
+ children: /*#__PURE__*/_jsx(UnifiedDiff, {
156
+ change: {
157
+ path: target.path,
158
+ kind: changeKind(patch),
159
+ diff: patch
160
+ },
161
+ ignoreWhitespace: hideWhitespace,
162
+ maxHeight: DIFF_HEIGHT
163
+ })
164
+ })
165
+ });
166
+ $[0] = children;
167
+ $[1] = context;
168
+ $[2] = described;
169
+ $[3] = diff.patch;
170
+ $[4] = diff.truncated;
171
+ $[5] = hideWhitespace;
172
+ $[6] = t;
173
+ $[7] = target;
174
+ $[8] = openLink;
175
+ $[9] = openable;
176
+ $[10] = partial;
177
+ $[11] = t1;
178
+ $[12] = t2;
179
+ $[13] = t3;
180
+ $[14] = t4;
181
+ } else {
182
+ openLink = $[8];
183
+ openable = $[9];
184
+ partial = $[10];
185
+ t1 = $[11];
186
+ t2 = $[12];
187
+ t3 = $[13];
188
+ t4 = $[14];
189
+ }
190
+ let t5;
191
+ if ($[29] !== openLink || $[30] !== openable || $[31] !== partial || $[32] !== t || $[33] !== target) {
192
+ t5 = partial && /*#__PURE__*/_jsxs("div", {
193
+ className: "flex flex-wrap items-center gap-2 px-1 pb-0.5 text-2xs text-text-muted",
194
+ children: [/*#__PURE__*/_jsx("span", {
195
+ children: t("blocks.diff.partial")
196
+ }), openable && /*#__PURE__*/_jsx(Button, {
197
+ size: "xs",
198
+ variant: "secondary",
199
+ onClick: () => openLink(target),
200
+ children: t("blocks.diff.showAll")
201
+ })]
202
+ });
203
+ $[29] = openLink;
204
+ $[30] = openable;
205
+ $[31] = partial;
206
+ $[32] = t;
207
+ $[33] = target;
208
+ $[34] = t5;
209
+ } else {
210
+ t5 = $[34];
211
+ }
212
+ let t6;
213
+ if ($[35] !== t1 || $[36] !== t2 || $[37] !== t3 || $[38] !== t4 || $[39] !== t5) {
214
+ t6 = /*#__PURE__*/_jsxs("figure", {
215
+ "aria-label": t1,
216
+ className: t2,
217
+ children: [t3, t4, t5]
218
+ });
219
+ $[35] = t1;
220
+ $[36] = t2;
221
+ $[37] = t3;
222
+ $[38] = t4;
223
+ $[39] = t5;
224
+ $[40] = t6;
225
+ } else {
226
+ t6 = $[40];
227
+ }
228
+ return t6;
229
+ }
230
+ /*
231
+ * A changed file as a chip. With `open` it shows the change itself once the host read it: the chip waits
232
+ * quietly until then, and stays text with the reason where the host would not read it. A host that reads no
233
+ * diffs, a block that still streams and a Diff past the few a block may open leave the chip as it is.
234
+ */
235
+ export function DiffRenderer(t0) {
236
+ const $ = _c(45);
237
+ const {
238
+ node,
239
+ children,
240
+ context
241
+ } = t0;
242
+ const {
243
+ t
244
+ } = useTranslation("agent-chat");
245
+ const {
246
+ path,
247
+ open,
248
+ whitespace
249
+ } = node.props;
250
+ let t1;
251
+ if ($[0] !== path) {
252
+ t1 = {
253
+ type: "Diff",
254
+ path
255
+ };
256
+ $[0] = path;
257
+ $[1] = t1;
258
+ } else {
259
+ t1 = $[1];
260
+ }
261
+ const target = t1;
262
+ const described = node.children.length > 0;
263
+ let T0;
264
+ let T1;
265
+ let t2;
266
+ let t3;
267
+ let t4;
268
+ let t5;
269
+ if ($[2] !== children || $[3] !== context || $[4] !== described || $[5] !== node.id || $[6] !== open || $[7] !== t || $[8] !== target || $[9] !== whitespace) {
270
+ t5 = Symbol.for("react.early_return_sentinel");
271
+ bb0: {
272
+ const diff = open === true ? context.diff?.(node.id) : undefined;
273
+ if (diff === undefined) {
274
+ let t6;
275
+ if ($[16] !== children || $[17] !== context || $[18] !== described || $[19] !== target) {
276
+ t6 = /*#__PURE__*/_jsx(LinkRow, {
277
+ target: target,
278
+ context: context,
279
+ described: described,
280
+ children: children
281
+ });
282
+ $[16] = children;
283
+ $[17] = context;
284
+ $[18] = described;
285
+ $[19] = target;
286
+ $[20] = t6;
287
+ } else {
288
+ t6 = $[20];
289
+ }
290
+ t5 = t6;
291
+ break bb0;
292
+ }
293
+ if (diff.state === "patch") {
294
+ t5 = /*#__PURE__*/_jsx(OpenDiff, {
295
+ target: target,
296
+ diff: diff,
297
+ hideWhitespace: whitespace === "hide",
298
+ described: described,
299
+ context: context,
300
+ children: children
301
+ });
302
+ break bb0;
303
+ }
304
+ if (diff.state === "reading") {
305
+ let t6;
306
+ if ($[21] !== context || $[22] !== target) {
307
+ t6 = /*#__PURE__*/_jsx(UiLinkChip, {
308
+ target: target,
309
+ context: context
310
+ });
311
+ $[21] = context;
312
+ $[22] = target;
313
+ $[23] = t6;
314
+ } else {
315
+ t6 = $[23];
316
+ }
317
+ let t7;
318
+ if ($[24] !== t) {
319
+ t7 = t("work.loadingDiff");
320
+ $[24] = t;
321
+ $[25] = t7;
322
+ } else {
323
+ t7 = $[25];
324
+ }
325
+ let t8;
326
+ if ($[26] !== t7) {
327
+ t8 = /*#__PURE__*/_jsx(Spinner, {
328
+ size: 12,
329
+ label: t7,
330
+ className: "shrink-0 text-text-faint"
331
+ });
332
+ $[26] = t7;
333
+ $[27] = t8;
334
+ } else {
335
+ t8 = $[27];
336
+ }
337
+ let t9;
338
+ if ($[28] !== t6 || $[29] !== t8) {
339
+ t9 = /*#__PURE__*/_jsxs(_Fragment, {
340
+ children: [t6, t8]
341
+ });
342
+ $[28] = t6;
343
+ $[29] = t8;
344
+ $[30] = t9;
345
+ } else {
346
+ t9 = $[30];
347
+ }
348
+ let t10;
349
+ if ($[31] !== children || $[32] !== described || $[33] !== t9) {
350
+ t10 = /*#__PURE__*/_jsx(DiffHead, {
351
+ chip: t9,
352
+ described: described,
353
+ children: children
354
+ });
355
+ $[31] = children;
356
+ $[32] = described;
357
+ $[33] = t9;
358
+ $[34] = t10;
359
+ } else {
360
+ t10 = $[34];
361
+ }
362
+ t5 = t10;
363
+ break bb0;
364
+ }
365
+ T1 = DiffHead;
366
+ T0 = UiLinkChip;
367
+ t2 = target;
368
+ t3 = context;
369
+ t4 = uiReasonText(t, diff.code, diff.reason) ?? t("blocks.diff.unavailable");
370
+ }
371
+ $[2] = children;
372
+ $[3] = context;
373
+ $[4] = described;
374
+ $[5] = node.id;
375
+ $[6] = open;
376
+ $[7] = t;
377
+ $[8] = target;
378
+ $[9] = whitespace;
379
+ $[10] = T0;
380
+ $[11] = T1;
381
+ $[12] = t2;
382
+ $[13] = t3;
383
+ $[14] = t4;
384
+ $[15] = t5;
385
+ } else {
386
+ T0 = $[10];
387
+ T1 = $[11];
388
+ t2 = $[12];
389
+ t3 = $[13];
390
+ t4 = $[14];
391
+ t5 = $[15];
392
+ }
393
+ if (t5 !== Symbol.for("react.early_return_sentinel")) {
394
+ return t5;
395
+ }
396
+ let t6;
397
+ if ($[35] !== T0 || $[36] !== t2 || $[37] !== t3 || $[38] !== t4) {
398
+ t6 = /*#__PURE__*/_jsx(T0, {
399
+ target: t2,
400
+ context: t3,
401
+ refused: t4
402
+ });
403
+ $[35] = T0;
404
+ $[36] = t2;
405
+ $[37] = t3;
406
+ $[38] = t4;
407
+ $[39] = t6;
408
+ } else {
409
+ t6 = $[39];
410
+ }
411
+ let t7;
412
+ if ($[40] !== T1 || $[41] !== children || $[42] !== described || $[43] !== t6) {
413
+ t7 = /*#__PURE__*/_jsx(T1, {
414
+ chip: t6,
415
+ described: described,
416
+ children: children
417
+ });
418
+ $[40] = T1;
419
+ $[41] = children;
420
+ $[42] = described;
421
+ $[43] = t6;
422
+ $[44] = t7;
423
+ } else {
424
+ t7 = $[44];
425
+ }
426
+ return t7;
427
+ }
@@ -6,5 +6,6 @@ export declare function SwitchRenderer({ node, children, context }: UiRendererPr
6
6
  export declare function SliderRenderer({ node, context }: UiRendererProps<UiProps<'Slider'>>): import("react").JSX.Element;
7
7
  export declare function SegmentedRenderer({ node, context }: UiRendererProps<UiProps<'Segmented'>>): import("react").JSX.Element;
8
8
  export declare function TextFieldRenderer({ node, children, context }: UiRendererProps<UiProps<'TextField'>>): import("react").JSX.Element;
9
+ export declare function NumberFieldRenderer({ node, children, context }: UiRendererProps<UiProps<'NumberField'>>): import("react").JSX.Element;
9
10
  export declare function SelectRenderer({ node, context }: UiRendererProps<UiProps<'Select'>>): import("react").JSX.Element;
10
11
  export declare function ButtonRenderer({ node, children, context }: UiRendererProps<UiProps<'Button'>>): import("react").JSX.Element;