@adecore/agents-react 0.46.2 → 0.47.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 (58) hide show
  1. package/dist/chat/index.d.ts +1 -0
  2. package/dist/chat/index.js +1 -0
  3. package/dist/chat/logic/scrubber.js +12 -0
  4. package/dist/chat/logic/timeline-copy.js +2 -0
  5. package/dist/chat/logic/timeline.d.ts +6 -1
  6. package/dist/chat/logic/timeline.js +36 -10
  7. package/dist/chat/ui/ChatActivity.d.ts +2 -1
  8. package/dist/chat/ui/ChatActivity.js +295 -61
  9. package/dist/chat/ui/Composer.d.ts +2 -1
  10. package/dist/chat/ui/Composer.js +492 -486
  11. package/dist/chat/ui/PromptEditor.js +4 -1
  12. package/dist/chat/ui/ReferenceChip.d.ts +2 -1
  13. package/dist/chat/ui/ReferenceChip.js +135 -100
  14. package/dist/chat/ui/composer/ComposerMenu.js +17 -11
  15. package/dist/chat/ui/composer/chips.d.ts +3 -0
  16. package/dist/chat/ui/composer/chips.js +14 -10
  17. package/dist/chat/ui/reference-icons.d.ts +3 -0
  18. package/dist/chat/ui/reference-icons.js +15 -2
  19. package/dist/chat/ui/rows/MessageRows.d.ts +6 -1
  20. package/dist/chat/ui/rows/MessageRows.js +166 -10
  21. package/dist/chat/ui/rows/RowContainer.js +21 -22
  22. package/dist/chat/ui/rows/Rows.js +37 -19
  23. package/dist/chat/ui/rows/WorkflowRow.d.ts +2 -1
  24. package/dist/chat/ui/rows/WorkflowRow.js +197 -191
  25. package/dist/chat/ui/rows/row-rhythm.d.ts +1 -0
  26. package/dist/chat/ui/rows/row-rhythm.js +12 -3
  27. package/dist/chat/workflow-list.d.ts +12 -0
  28. package/dist/chat/workflow-list.js +54 -0
  29. package/dist/host.d.ts +8 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/locales/en/agent-chat.d.ts +9 -0
  32. package/dist/locales/en/agent-chat.js +9 -0
  33. package/dist/locales/nl/agent-chat.d.ts +9 -0
  34. package/dist/locales/nl/agent-chat.js +9 -0
  35. package/dist/theme.css +4 -2
  36. package/package.json +8 -8
  37. package/src/chat/index.ts +1 -0
  38. package/src/chat/logic/scrubber.ts +5 -0
  39. package/src/chat/logic/timeline-copy.ts +2 -0
  40. package/src/chat/logic/timeline.ts +33 -2
  41. package/src/chat/ui/ChatActivity.tsx +52 -6
  42. package/src/chat/ui/Composer.tsx +19 -3
  43. package/src/chat/ui/PromptEditor.tsx +3 -1
  44. package/src/chat/ui/ReferenceChip.tsx +15 -5
  45. package/src/chat/ui/composer/ComposerMenu.tsx +4 -2
  46. package/src/chat/ui/composer/chips.ts +15 -9
  47. package/src/chat/ui/reference-icons.ts +13 -1
  48. package/src/chat/ui/rows/MessageRows.tsx +35 -0
  49. package/src/chat/ui/rows/RowContainer.tsx +2 -2
  50. package/src/chat/ui/rows/Rows.tsx +3 -0
  51. package/src/chat/ui/rows/WorkflowRow.tsx +9 -4
  52. package/src/chat/ui/rows/row-rhythm.ts +12 -3
  53. package/src/chat/workflow-list.ts +65 -0
  54. package/src/host.ts +15 -1
  55. package/src/index.ts +1 -0
  56. package/src/locales/en/agent-chat.ts +9 -0
  57. package/src/locales/nl/agent-chat.ts +9 -0
  58. package/src/theme.css +4 -2
@@ -1,6 +1,7 @@
1
1
  import { useLayoutEffect, useRef } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { Surface } from '@adecore/ui';
4
+ import { useChatHost } from '../../host.js';
4
5
  import { ComposerInput } from './ComposerInput.js';
5
6
  import { chipDecorations } from './composer/chips.js';
6
7
  import { ComposerMenu } from './composer/ComposerMenu.js';
@@ -26,6 +27,7 @@ export function PromptEditor({
26
27
  disabled = false,
27
28
  className
28
29
  }) {
30
+ const host = useChatHost();
29
31
  const inputRef = useRef(null);
30
32
  // A pick writes twice in one event (the text, then what it picked), and the second must build on the first.
31
33
  const latest = useRef(value);
@@ -63,7 +65,8 @@ export function PromptEditor({
63
65
  const extensions = chipDecorations({
64
66
  mentions: value.mentions,
65
67
  skills: value.skills,
66
- references: menus.referenceChips
68
+ references: menus.referenceChips,
69
+ referenceIcon: host.ReferenceIcon
67
70
  });
68
71
  const onKeyDown = e => {
69
72
  if (e.isComposing) {
@@ -9,7 +9,8 @@ interface TokenChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children
9
9
  onOpen?: () => void;
10
10
  }
11
11
  export declare function TokenChip({ kind, value, sigil, icon, label, tone, onOpen, className, ...rest }: TokenChipProps): import("react").JSX.Element;
12
- export declare function ReferenceChip({ id }: {
12
+ export declare function ReferenceChip({ id, lastName }: {
13
13
  id: string;
14
+ lastName?: string;
14
15
  }): import("react").JSX.Element;
15
16
  export {};
@@ -4,8 +4,9 @@ import clsx from 'clsx';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { CircleOff } from 'lucide-react';
6
6
  import { Icon } from '@adecore/ui';
7
+ import { useChatHost } from '../../host.js';
7
8
  import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_IN_MESSAGE } from './chips.js';
8
- import { REFERENCE_ICONS } from './reference-icons.js';
9
+ import { referenceGlyph } from './reference-icons.js';
9
10
  import { ReferenceLookupContext } from './reference-lookup.js';
10
11
  /*
11
12
  * One token in the transcript. One that opens is a span with a button's role rather than a button,
@@ -124,11 +125,15 @@ export function TokenChip(t0) {
124
125
  }
125
126
  return t9;
126
127
  }
127
- /* A view, node or chat a message points at, under the name it has now; one that went says so. */
128
+ /*
129
+ * A view, node or chat a message points at, under the name it has now. One that went says so, under
130
+ * `lastName` when the message knows what it was called.
131
+ */
128
132
  export function ReferenceChip(t0) {
129
- const $ = _c(26);
133
+ const $ = _c(37);
130
134
  const {
131
- id
135
+ id,
136
+ lastName
132
137
  } = t0;
133
138
  const {
134
139
  t
@@ -137,119 +142,149 @@ export function ReferenceChip(t0) {
137
142
  items,
138
143
  open
139
144
  } = useContext(ReferenceLookupContext);
145
+ const {
146
+ ReferenceIcon
147
+ } = useChatHost();
148
+ let T0;
149
+ let item;
140
150
  let t1;
141
- if ($[0] !== id || $[1] !== items) {
142
- let t2;
143
- if ($[3] !== id) {
144
- t2 = candidate => candidate.id === id;
145
- $[3] = id;
146
- $[4] = t2;
147
- } else {
148
- t2 = $[4];
149
- }
150
- t1 = items.find(t2);
151
- $[0] = id;
152
- $[1] = items;
153
- $[2] = t1;
154
- } else {
155
- t1 = $[2];
156
- }
157
- const item = t1;
158
- if (item === undefined) {
159
- let t2;
160
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
161
- t2 = /*#__PURE__*/_jsx(Icon, {
162
- icon: CircleOff,
151
+ let t2;
152
+ let t3;
153
+ let t4;
154
+ let t5;
155
+ if ($[0] !== ReferenceIcon || $[1] !== id || $[2] !== items || $[3] !== lastName || $[4] !== t) {
156
+ t5 = Symbol.for("react.early_return_sentinel");
157
+ bb0: {
158
+ let t6;
159
+ if ($[12] !== id) {
160
+ t6 = candidate => candidate.id === id;
161
+ $[12] = id;
162
+ $[13] = t6;
163
+ } else {
164
+ t6 = $[13];
165
+ }
166
+ item = items.find(t6);
167
+ if (item === undefined) {
168
+ let t7;
169
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
170
+ t7 = /*#__PURE__*/_jsx(Icon, {
171
+ icon: CircleOff,
172
+ size: 14,
173
+ className: TOKEN_ICON
174
+ });
175
+ $[14] = t7;
176
+ } else {
177
+ t7 = $[14];
178
+ }
179
+ let t8;
180
+ if ($[15] !== lastName || $[16] !== t) {
181
+ t8 = lastName || t("references.gone");
182
+ $[15] = lastName;
183
+ $[16] = t;
184
+ $[17] = t8;
185
+ } else {
186
+ t8 = $[17];
187
+ }
188
+ let t9;
189
+ if ($[18] !== t8) {
190
+ t9 = /*#__PURE__*/_jsx(TokenChip, {
191
+ kind: "gone",
192
+ icon: t7,
193
+ label: t8,
194
+ tone: REFERENCE_GONE_TONE
195
+ });
196
+ $[18] = t8;
197
+ $[19] = t9;
198
+ } else {
199
+ t9 = $[19];
200
+ }
201
+ t5 = t9;
202
+ break bb0;
203
+ }
204
+ T0 = TokenChip;
205
+ t1 = "reference";
206
+ t2 = item.id;
207
+ t3 = "#";
208
+ t4 = referenceGlyph(ReferenceIcon, {
209
+ id: item.id,
210
+ kind: item.kind,
163
211
  size: 14,
164
212
  className: TOKEN_ICON
165
213
  });
166
- $[5] = t2;
167
- } else {
168
- t2 = $[5];
169
- }
170
- let t3;
171
- if ($[6] !== t) {
172
- t3 = t("references.gone");
173
- $[6] = t;
174
- $[7] = t3;
175
- } else {
176
- t3 = $[7];
177
- }
178
- let t4;
179
- if ($[8] !== t3) {
180
- t4 = /*#__PURE__*/_jsx(TokenChip, {
181
- kind: "gone",
182
- icon: t2,
183
- label: t3,
184
- tone: REFERENCE_GONE_TONE
185
- });
186
- $[8] = t3;
187
- $[9] = t4;
188
- } else {
189
- t4 = $[9];
190
214
  }
191
- return t4;
192
- }
193
- const t2 = item.id;
194
- const t3 = REFERENCE_ICONS[item.kind];
195
- let t4;
196
- if ($[10] !== t3) {
197
- t4 = /*#__PURE__*/_jsx(Icon, {
198
- icon: t3,
199
- size: 14,
200
- className: TOKEN_ICON
201
- });
202
- $[10] = t3;
203
- $[11] = t4;
215
+ $[0] = ReferenceIcon;
216
+ $[1] = id;
217
+ $[2] = items;
218
+ $[3] = lastName;
219
+ $[4] = t;
220
+ $[5] = T0;
221
+ $[6] = item;
222
+ $[7] = t1;
223
+ $[8] = t2;
224
+ $[9] = t3;
225
+ $[10] = t4;
226
+ $[11] = t5;
204
227
  } else {
205
- t4 = $[11];
228
+ T0 = $[5];
229
+ item = $[6];
230
+ t1 = $[7];
231
+ t2 = $[8];
232
+ t3 = $[9];
233
+ t4 = $[10];
234
+ t5 = $[11];
206
235
  }
207
- let t5;
208
- if ($[12] !== item.name || $[13] !== t) {
209
- t5 = item.name || t("references.untitled");
210
- $[12] = item.name;
211
- $[13] = t;
212
- $[14] = t5;
213
- } else {
214
- t5 = $[14];
236
+ if (t5 !== Symbol.for("react.early_return_sentinel")) {
237
+ return t5;
215
238
  }
216
- const t6 = open !== null && "hover:bg-text/12";
217
- let t7;
218
- if ($[15] !== t6) {
219
- t7 = clsx(REFERENCE_TONE, t6);
220
- $[15] = t6;
221
- $[16] = t7;
239
+ let t6;
240
+ if ($[20] !== item.name || $[21] !== t) {
241
+ t6 = item.name || t("references.untitled");
242
+ $[20] = item.name;
243
+ $[21] = t;
244
+ $[22] = t6;
222
245
  } else {
223
- t7 = $[16];
246
+ t6 = $[22];
224
247
  }
248
+ const t7 = open !== null && "hover:bg-text/12";
225
249
  let t8;
226
- if ($[17] !== item.id || $[18] !== open) {
227
- t8 = open === null ? undefined : () => open(item.id);
228
- $[17] = item.id;
229
- $[18] = open;
230
- $[19] = t8;
250
+ if ($[23] !== t7) {
251
+ t8 = clsx(REFERENCE_TONE, t7);
252
+ $[23] = t7;
253
+ $[24] = t8;
231
254
  } else {
232
- t8 = $[19];
255
+ t8 = $[24];
233
256
  }
234
257
  let t9;
235
- if ($[20] !== item.id || $[21] !== t4 || $[22] !== t5 || $[23] !== t7 || $[24] !== t8) {
236
- t9 = /*#__PURE__*/_jsx(TokenChip, {
237
- kind: "reference",
258
+ if ($[25] !== item.id || $[26] !== open) {
259
+ t9 = open === null ? undefined : () => open(item.id);
260
+ $[25] = item.id;
261
+ $[26] = open;
262
+ $[27] = t9;
263
+ } else {
264
+ t9 = $[27];
265
+ }
266
+ let t10;
267
+ if ($[28] !== T0 || $[29] !== t1 || $[30] !== t2 || $[31] !== t3 || $[32] !== t4 || $[33] !== t6 || $[34] !== t8 || $[35] !== t9) {
268
+ t10 = /*#__PURE__*/_jsx(T0, {
269
+ kind: t1,
238
270
  value: t2,
239
- sigil: "#",
271
+ sigil: t3,
240
272
  icon: t4,
241
- label: t5,
242
- tone: t7,
243
- onOpen: t8
273
+ label: t6,
274
+ tone: t8,
275
+ onOpen: t9
244
276
  });
245
- $[20] = item.id;
246
- $[21] = t4;
247
- $[22] = t5;
248
- $[23] = t7;
249
- $[24] = t8;
250
- $[25] = t9;
277
+ $[28] = T0;
278
+ $[29] = t1;
279
+ $[30] = t2;
280
+ $[31] = t3;
281
+ $[32] = t4;
282
+ $[33] = t6;
283
+ $[34] = t8;
284
+ $[35] = t9;
285
+ $[36] = t10;
251
286
  } else {
252
- t9 = $[25];
287
+ t10 = $[36];
253
288
  }
254
- return t9;
289
+ return t10;
255
290
  }
@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next';
3
3
  import clsx from 'clsx';
4
4
  import { SquareSlash, Zap } from 'lucide-react';
5
5
  import { FileIcon, Icon, Menu, MiddleTruncate } from '@adecore/ui';
6
- import { REFERENCE_ICONS } from '../reference-icons.js';
6
+ import { useChatHost } from '../../../host.js';
7
+ import { referenceGlyph } from '../reference-icons.js';
7
8
  import { optionIdOf } from './menu-aria.js';
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  function splitPath(path) {
@@ -298,19 +299,22 @@ function MentionMenu(t0) {
298
299
  }
299
300
  /* The views, nodes and chats a `#` offers, what stands on this canvas first, each with its kind or what tells it apart. */
300
301
  function ReferenceMenu(t0) {
301
- const $ = _c(5);
302
+ const $ = _c(6);
302
303
  const {
303
304
  menus
304
305
  } = t0;
305
306
  const {
306
307
  t
307
308
  } = useTranslation("agent-chat");
309
+ const {
310
+ ReferenceIcon
311
+ } = useChatHost();
308
312
  const {
309
313
  listId,
310
314
  referenceMatches
311
315
  } = menus;
312
316
  let t1;
313
- if ($[0] !== listId || $[1] !== menus || $[2] !== referenceMatches || $[3] !== t) {
317
+ if ($[0] !== ReferenceIcon || $[1] !== listId || $[2] !== menus || $[3] !== referenceMatches || $[4] !== t) {
314
318
  const groups = ["canvas", "views"].map(group => ({
315
319
  group,
316
320
  items: referenceMatches.filter(item => item.group === group)
@@ -339,8 +343,9 @@ function ReferenceMenu(t0) {
339
343
  index: index,
340
344
  className: "items-center",
341
345
  onPick: () => menus.chooseReference(item_0),
342
- children: [/*#__PURE__*/_jsx(Icon, {
343
- icon: REFERENCE_ICONS[item_0.kind],
346
+ children: [referenceGlyph(ReferenceIcon, {
347
+ id: item_0.id,
348
+ kind: item_0.kind,
344
349
  size: 14,
345
350
  className: "shrink-0 text-text-faint"
346
351
  }), /*#__PURE__*/_jsx("span", {
@@ -359,13 +364,14 @@ function ReferenceMenu(t0) {
359
364
  children: t("composer.references.noMatch")
360
365
  })
361
366
  });
362
- $[0] = listId;
363
- $[1] = menus;
364
- $[2] = referenceMatches;
365
- $[3] = t;
366
- $[4] = t1;
367
+ $[0] = ReferenceIcon;
368
+ $[1] = listId;
369
+ $[2] = menus;
370
+ $[3] = referenceMatches;
371
+ $[4] = t;
372
+ $[5] = t1;
367
373
  } else {
368
- t1 = $[4];
374
+ t1 = $[5];
369
375
  }
370
376
  return t1;
371
377
  }
@@ -1,4 +1,6 @@
1
+ import type { ComponentType } from 'react';
1
2
  import { type Extension } from '@codemirror/state';
3
+ import type { ReferenceIconProps } from '../../../host.js';
2
4
  import type { ReferableKind } from '../../chat-references.js';
3
5
  import { type ReferenceToken } from '../../mentions.js';
4
6
  export interface ChipChoices {
@@ -7,5 +9,6 @@ export interface ChipChoices {
7
9
  references?: ReadonlyArray<ReferenceToken & {
8
10
  kind: ReferableKind | null;
9
11
  }>;
12
+ referenceIcon?: ComponentType<ReferenceIconProps> | null;
10
13
  }
11
14
  export declare function chipDecorations(value: ChipChoices): Extension;
@@ -1,12 +1,10 @@
1
- import { createElement } from 'react';
2
1
  import { createRoot } from 'react-dom/client';
3
2
  import { syntaxTree } from '@codemirror/language';
4
3
  import { Facet, StateField } from '@codemirror/state';
5
4
  import { Decoration, EditorView, WidgetType } from '@codemirror/view';
6
- import { Icon } from '@adecore/ui';
7
5
  import { chipRanges } from '../../mentions.js';
8
6
  import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips.js';
9
- import { REFERENCE_ICONS } from '../reference-icons.js';
7
+ import { referenceGlyph } from '../reference-icons.js';
10
8
  import { codeRanges } from './editor.js';
11
9
  const NO_CHOICES = {
12
10
  mentions: [],
@@ -27,22 +25,27 @@ const referenceMark = Decoration.mark({
27
25
  inclusiveStart: true
28
26
  });
29
27
  const roots = new WeakMap();
30
- /* The kind's mark in place of the `#`, the way a sent message draws it. */
28
+ /* The reference's mark in place of the `#`, the way a sent message draws it. */
31
29
  class ReferenceIcon extends WidgetType {
30
+ id;
32
31
  kind;
33
- constructor(kind) {
32
+ hostIcon;
33
+ constructor(id, kind, hostIcon) {
34
34
  super();
35
+ this.id = id;
35
36
  this.kind = kind;
37
+ this.hostIcon = hostIcon;
36
38
  }
37
39
  eq(other) {
38
- return other.kind === this.kind;
40
+ return other.id === this.id && other.kind === this.kind && other.hostIcon === this.hostIcon;
39
41
  }
40
42
  toDOM() {
41
43
  const holder = document.createElement('span');
42
44
  holder.className = TOKEN_ICON_IN_EDITOR;
43
45
  const root = createRoot(holder);
44
- root.render(createElement(Icon, {
45
- icon: REFERENCE_ICONS[this.kind],
46
+ root.render(referenceGlyph(this.hostIcon, {
47
+ id: this.id,
48
+ kind: this.kind,
46
49
  size: 12
47
50
  }));
48
51
  roots.set(holder, root);
@@ -59,7 +62,8 @@ function chipMarks(state) {
59
62
  const {
60
63
  mentions,
61
64
  skills,
62
- references = []
65
+ references = [],
66
+ referenceIcon = null
63
67
  } = state.facet(choices);
64
68
  const kinds = new Map(references.map(token => [token.id, token.kind]));
65
69
  const marks = [];
@@ -73,7 +77,7 @@ function chipMarks(state) {
73
77
  const kind = kinds.get(range.value);
74
78
  if (kind !== undefined && kind !== null) {
75
79
  marks.push(Decoration.replace({
76
- widget: new ReferenceIcon(kind)
80
+ widget: new ReferenceIcon(range.value, kind, referenceIcon)
77
81
  }).range(range.from, range.from + 1));
78
82
  }
79
83
  }
@@ -1,3 +1,6 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
1
2
  import { type LucideIcon } from 'lucide-react';
3
+ import type { ReferenceIconProps } from '../../host.js';
2
4
  import type { ReferableKind } from '../chat-references.js';
3
5
  export declare const REFERENCE_ICONS: Record<ReferableKind, LucideIcon>;
6
+ export declare function referenceGlyph(HostIcon: ComponentType<ReferenceIconProps> | null | undefined, props: ReferenceIconProps): ReactNode;
@@ -1,5 +1,7 @@
1
+ import { createElement } from 'react';
1
2
  import { Database, FileText, Frame, Globe, MessageSquare, PenTool, Smartphone, StickyNote, Terminal, Type, Workflow } from 'lucide-react';
2
- /* The mark of what a `#` points at, in the picker and on its chip. */
3
+ import { Icon } from '@adecore/ui';
4
+ /* The mark of what a `#` points at, in the picker and on its chip, when the host draws none of its own. */
3
5
  export const REFERENCE_ICONS = {
4
6
  canvas: Frame,
5
7
  chat: MessageSquare,
@@ -12,4 +14,15 @@ export const REFERENCE_ICONS = {
12
14
  device: Smartphone,
13
15
  file: FileText,
14
16
  database: Database
15
- };
17
+ };
18
+ /* The host's mark of a reference, or the mark of its kind. */
19
+ export function referenceGlyph(HostIcon, props) {
20
+ if (HostIcon) {
21
+ return createElement(HostIcon, props);
22
+ }
23
+ return createElement(Icon, {
24
+ icon: REFERENCE_ICONS[props.kind],
25
+ size: props.size,
26
+ className: props.className
27
+ });
28
+ }
@@ -1,8 +1,13 @@
1
- import type { ChatApprovalItem, ChatAssistantItem, ChatQuestionItem, ChatThinkingItem, ChatUserItem } from '@adecore/agent-contracts';
1
+ import type { ChatApprovalItem, ChatAssistantItem, ChatNoteMessage, ChatQuestionItem, ChatThinkingItem, ChatUserItem } from '@adecore/agent-contracts';
2
2
  export declare function UserRow({ chatId, item }: {
3
3
  chatId: string;
4
4
  item: ChatUserItem;
5
5
  }): import("react").JSX.Element;
6
+ export declare function SentMessageRow({ chatId, id, message }: {
7
+ chatId: string;
8
+ id: string;
9
+ message: ChatNoteMessage;
10
+ }): import("react").JSX.Element;
6
11
  export declare function ReportRow({ id, text }: {
7
12
  id: string;
8
13
  text: string;