@adecore/agents-react 0.54.16 → 0.55.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 (91) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +5 -0
  2. package/dist/agents/AgentModelLabel.js +32 -7
  3. package/dist/chat/account-choice.d.ts +1 -0
  4. package/dist/chat/account-choice.js +13 -4
  5. package/dist/chat/mentions.d.ts +24 -2
  6. package/dist/chat/mentions.js +84 -10
  7. package/dist/chat/subagent-list.d.ts +0 -1
  8. package/dist/chat/subagent-list.js +1 -9
  9. package/dist/chat/tag-suggestions.d.ts +22 -0
  10. package/dist/chat/tag-suggestions.js +71 -0
  11. package/dist/chat/ui/Composer.js +489 -447
  12. package/dist/chat/ui/ComposerInput.d.ts +1 -0
  13. package/dist/chat/ui/ComposerInput.js +9 -1
  14. package/dist/chat/ui/Markdown.js +41 -25
  15. package/dist/chat/ui/NamedChip.d.ts +5 -0
  16. package/dist/chat/ui/NamedChip.js +118 -0
  17. package/dist/chat/ui/Pickers.d.ts +0 -4
  18. package/dist/chat/ui/Pickers.js +1 -141
  19. package/dist/chat/ui/PromptEditor.js +2 -1
  20. package/dist/chat/ui/ReferenceChip.d.ts +3 -2
  21. package/dist/chat/ui/ReferenceChip.js +58 -36
  22. package/dist/chat/ui/RunSettings.d.ts +3 -2
  23. package/dist/chat/ui/RunSettings.js +386 -361
  24. package/dist/chat/ui/SubagentInfo.js +98 -114
  25. package/dist/chat/ui/SubagentTimeline.js +65 -43
  26. package/dist/chat/ui/Timeline.js +14 -8
  27. package/dist/chat/ui/chip-clipboard.js +10 -0
  28. package/dist/chat/ui/composer/ComposerControls.d.ts +6 -1
  29. package/dist/chat/ui/composer/ComposerControls.js +171 -158
  30. package/dist/chat/ui/composer/ComposerMenu.js +184 -55
  31. package/dist/chat/ui/composer/ComposerPlusMenu.d.ts +18 -0
  32. package/dist/chat/ui/composer/ComposerPlusMenu.js +400 -0
  33. package/dist/chat/ui/composer/ComposerStatusLine.d.ts +4 -0
  34. package/dist/chat/ui/composer/ComposerStatusLine.js +239 -0
  35. package/dist/chat/ui/composer/chips.d.ts +2 -0
  36. package/dist/chat/ui/composer/chips.js +66 -5
  37. package/dist/chat/ui/composer/insert.d.ts +1 -0
  38. package/dist/chat/ui/composer/insert.js +24 -0
  39. package/dist/chat/ui/composer/use-composer-menus.js +34 -17
  40. package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -2
  41. package/dist/chat/ui/composer/use-prompt-menus.js +290 -202
  42. package/dist/chat/ui/covered-bottom.d.ts +1 -0
  43. package/dist/chat/ui/covered-bottom.js +6 -0
  44. package/dist/chat/ui/named-chip-look.d.ts +14 -0
  45. package/dist/chat/ui/named-chip-look.js +72 -0
  46. package/dist/chat/ui/rehype-chips.js +13 -2
  47. package/dist/host-hooks.d.ts +2 -1
  48. package/dist/host-hooks.js +6 -0
  49. package/dist/host.d.ts +17 -0
  50. package/dist/index.d.ts +1 -1
  51. package/dist/locales/en/agent-chat.d.ts +14 -2
  52. package/dist/locales/en/agent-chat.js +16 -4
  53. package/dist/locales/nl/agent-chat.d.ts +14 -2
  54. package/dist/locales/nl/agent-chat.js +16 -4
  55. package/dist/state/chats.d.ts +1 -0
  56. package/dist/state/chats.js +45 -0
  57. package/package.json +9 -9
  58. package/src/agents/AgentModelLabel.tsx +10 -1
  59. package/src/chat/account-choice.ts +8 -0
  60. package/src/chat/mentions.ts +110 -13
  61. package/src/chat/subagent-list.ts +1 -14
  62. package/src/chat/tag-suggestions.ts +121 -0
  63. package/src/chat/ui/Composer.tsx +24 -12
  64. package/src/chat/ui/ComposerInput.tsx +13 -1
  65. package/src/chat/ui/Markdown.tsx +5 -0
  66. package/src/chat/ui/NamedChip.tsx +34 -0
  67. package/src/chat/ui/Pickers.tsx +1 -51
  68. package/src/chat/ui/PromptEditor.tsx +7 -1
  69. package/src/chat/ui/ReferenceChip.tsx +15 -4
  70. package/src/chat/ui/RunSettings.tsx +51 -29
  71. package/src/chat/ui/SubagentInfo.tsx +17 -17
  72. package/src/chat/ui/SubagentTimeline.tsx +7 -2
  73. package/src/chat/ui/Timeline.tsx +11 -5
  74. package/src/chat/ui/chip-clipboard.ts +8 -1
  75. package/src/chat/ui/composer/ComposerControls.tsx +24 -17
  76. package/src/chat/ui/composer/ComposerMenu.tsx +82 -15
  77. package/src/chat/ui/composer/ComposerPlusMenu.tsx +158 -0
  78. package/src/chat/ui/composer/ComposerStatusLine.tsx +94 -0
  79. package/src/chat/ui/composer/chips.ts +78 -7
  80. package/src/chat/ui/composer/insert.ts +12 -0
  81. package/src/chat/ui/composer/use-composer-menus.ts +5 -2
  82. package/src/chat/ui/composer/use-prompt-menus.ts +55 -10
  83. package/src/chat/ui/covered-bottom.ts +7 -0
  84. package/src/chat/ui/named-chip-look.ts +64 -0
  85. package/src/chat/ui/rehype-chips.ts +17 -2
  86. package/src/host-hooks.ts +11 -1
  87. package/src/host.ts +29 -0
  88. package/src/index.ts +2 -0
  89. package/src/locales/en/agent-chat.ts +16 -4
  90. package/src/locales/nl/agent-chat.ts +16 -4
  91. package/src/state/chats.ts +26 -0
@@ -36,9 +36,16 @@ function valueOf(segment: Exclude<ChipSegment, { kind: 'text' }>): string {
36
36
  return segment.path;
37
37
  }
38
38
 
39
+ if (segment.kind === 'model' || segment.kind === 'account') {
40
+ return `${segment.cli}/${segment.id}`;
41
+ }
42
+
39
43
  return segment.kind === 'skill' ? segment.name : segment.id;
40
44
  }
41
45
 
46
+ // What every named chip starts with, so a text without one skips the walk.
47
+ const NAMED_CHIP_HINT = /@(model|account):/;
48
+
42
49
  // Inline code overrules a chip: `@a.ts` between backticks is code, not a mention.
43
50
  const SKIPPED = new Set(['code', 'pre']);
44
51
 
@@ -55,6 +62,14 @@ function chipElement(segment: Exclude<ChipSegment, { kind: 'text' }>): HastEleme
55
62
  };
56
63
  }
57
64
 
65
+ function textOf(node: HastParent | HastNode): string {
66
+ if ('children' in node) {
67
+ return node.children.map(textOf).join('');
68
+ }
69
+
70
+ return node.type === 'text' ? node.value : '';
71
+ }
72
+
58
73
  function split(parent: HastParent, tokenize: (text: string) => ChipSegment[], skipped: ReadonlySet<string>): void {
59
74
  parent.children = parent.children.flatMap((child): HastNode[] => {
60
75
  if (child.type === 'text') {
@@ -69,10 +84,10 @@ function split(parent: HastParent, tokenize: (text: string) => ChipSegment[], sk
69
84
  });
70
85
  }
71
86
 
72
- /* The `@path`, `$name` and `#name` tokens a person picked in the composer, cut out of the text as chips. */
87
+ /* The `@path`, `$name` and `#name` tokens a person picked in the composer, and every model and account it spells, cut out of the text as chips. */
73
88
  export function rehypeChips({ mentions = [], skills = [], references = [] }: ChipOptions = {}) {
74
89
  return (tree: HastParent) => {
75
- if (mentions.length === 0 && skills.length === 0 && references.length === 0) {
90
+ if (mentions.length === 0 && skills.length === 0 && references.length === 0 && !NAMED_CHIP_HINT.test(textOf(tree))) {
76
91
  return;
77
92
  }
78
93
 
package/src/host-hooks.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  import type { ProviderPlatform } from '@adecore/agent-contracts';
7
7
  import type { AccountRule } from './agents/accounts';
8
8
  import { referablesOfChats, type Referables } from './chat/chat-references';
9
- import { useChatHost, type ChatHost, type CommandLook, type ComposerSendAction } from './host';
9
+ import { useChatHost, type ChatHost, type CommandLook, type ComposerSendAction, type ComposerStatusItem } from './host';
10
10
 
11
11
  export function useHostCodeMode(): 'light' | 'dark' {
12
12
  return useChatHost().code.useMode();
@@ -126,6 +126,16 @@ export function useHostComposerSendActions(scopeId: string, chatId: string): rea
126
126
  return useSendActions(scopeId, chatId);
127
127
  }
128
128
 
129
+ const NO_STATUS: readonly ComposerStatusItem[] = [];
130
+
131
+ const noStatus = (): readonly ComposerStatusItem[] => NO_STATUS;
132
+
133
+ export function useHostComposerStatus(scopeId: string, chatId: string): readonly ComposerStatusItem[] {
134
+ const useStatus = useChatHost().useComposerStatus ?? noStatus;
135
+
136
+ return useStatus(scopeId, chatId);
137
+ }
138
+
129
139
  export function useHostThreadCards(...args: Parameters<ChatHost['useThreadCards']>): ReturnType<ChatHost['useThreadCards']> {
130
140
  return useChatHost().useThreadCards(...args);
131
141
  }
package/src/host.ts CHANGED
@@ -222,6 +222,33 @@ export interface ComposerSendAction {
222
222
  run(draft: ComposerSendDraft): void;
223
223
  }
224
224
 
225
+ /* A row in the popover a status item opens. */
226
+ export interface ComposerStatusDetail {
227
+ icon: LucideIcon;
228
+ label: string;
229
+ /* A second line under the label, such as a path. */
230
+ detail?: string;
231
+ /* A word at the end of the row, such as what the label is. */
232
+ hint?: string;
233
+ /* Sets the label in the code font, for a name such as a branch. */
234
+ mono?: boolean;
235
+ /* Draws the row faint, for one that is listed but asks for no attention. */
236
+ muted?: boolean;
237
+ }
238
+
239
+ /* One item in the line under the composer's card, such as the branch a chat works on. */
240
+ export interface ComposerStatusItem {
241
+ /* Unique among the items of one composer. */
242
+ id: string;
243
+ icon: LucideIcon;
244
+ label: string;
245
+ tooltip?: string;
246
+ /* Where on the line it stands; left out, at the start. */
247
+ side?: 'start' | 'end';
248
+ /* Rows a click on the item opens; left out, the item is no button. */
249
+ details?: readonly ComposerStatusDetail[];
250
+ }
251
+
225
252
  /* What an app's own chips for a chat's sub-agents get, in place of the one flyout over the composer. */
226
253
  export interface SubagentSlotProps {
227
254
  chatId: string;
@@ -622,6 +649,8 @@ export interface ChatHost {
622
649
  ComposerHeaderSlot?: ComponentType<ComposerHeaderSlotProps> | null;
623
650
  /* Actions of the app's own behind a chevron on the send button, in the order given; left out, or none, Send stands alone. */
624
651
  useComposerSendActions?(scopeId: string, chatId: string): readonly ComposerSendAction[];
652
+ /* Items of the app's own on a line under the composer's card, such as where the chat works; left out, or none, draws no line. */
653
+ useComposerStatus?(scopeId: string, chatId: string): readonly ComposerStatusItem[];
625
654
  /* The app's own chips for a chat's sub-agents over the composer; null draws the one flyout. */
626
655
  SubagentSlot: ComponentType<SubagentSlotProps> | null;
627
656
  /* Cards of the app's own in a thread, in any order. Hand back the same array while none changed, or the thread lays out its rows again on every render. */
package/src/index.ts CHANGED
@@ -13,6 +13,8 @@ export {
13
13
  type ReferenceIconProps,
14
14
  type ComposerSendAction,
15
15
  type ComposerSendDraft,
16
+ type ComposerStatusDetail,
17
+ type ComposerStatusItem,
16
18
  type SubagentSlotProps,
17
19
  type ThreadCard,
18
20
  type VisualHost,
@@ -385,7 +385,9 @@ export default {
385
385
  here: 'Files in this folder',
386
386
  files: 'Files',
387
387
  noMatch: 'No files match',
388
- empty: 'No files here'
388
+ empty: 'No files here',
389
+ models: 'Models',
390
+ accounts: 'Accounts'
389
391
  },
390
392
  references: {
391
393
  canvas: 'On this canvas',
@@ -420,7 +422,18 @@ export default {
420
422
  goToSource: 'Go to reply'
421
423
  },
422
424
  removeAttachment: 'Remove {{name}}',
423
- attach: 'Attach files',
425
+ plus: {
426
+ label: 'Add to the message',
427
+ attach: 'Attach files…',
428
+ stash: 'Stash this prompt',
429
+ mention: 'Mention a file',
430
+ reference: 'Reference a view or node',
431
+ skill: 'Use a skill',
432
+ commands: 'Commands'
433
+ },
434
+ status: {
435
+ label: 'Where this chat works'
436
+ },
424
437
  tooLong: 'characters, too long to send',
425
438
  stop: 'Stop. Shift-click stops sub-agents too',
426
439
  queueButton: 'Queue',
@@ -479,8 +492,7 @@ export default {
479
492
  noAnswer: 'The machine did not answer',
480
493
  stopFailed: 'Could not stop sub-agent',
481
494
  info: {
482
- label: 'About this sub-agent',
483
- tokens: '{{tokens}} tokens'
495
+ label: 'About this sub-agent'
484
496
  }
485
497
  },
486
498
  modes: {
@@ -385,7 +385,9 @@ export default {
385
385
  here: 'Bestanden in deze map',
386
386
  files: 'Bestanden',
387
387
  noMatch: 'Geen bestanden gevonden',
388
- empty: 'Hier staan geen bestanden'
388
+ empty: 'Hier staan geen bestanden',
389
+ models: 'Modellen',
390
+ accounts: 'Accounts'
389
391
  },
390
392
  references: {
391
393
  canvas: 'Op dit canvas',
@@ -420,7 +422,18 @@ export default {
420
422
  goToSource: 'Naar het antwoord'
421
423
  },
422
424
  removeAttachment: '{{name}} verwijderen',
423
- attach: 'Bestanden toevoegen',
425
+ plus: {
426
+ label: 'Toevoegen aan het bericht',
427
+ attach: 'Bestanden toevoegen…',
428
+ stash: 'Deze prompt stashen',
429
+ mention: 'Een bestand noemen',
430
+ reference: 'Naar een weergave of node verwijzen',
431
+ skill: 'Een skill gebruiken',
432
+ commands: "Commando's"
433
+ },
434
+ status: {
435
+ label: 'Waar deze chat werkt'
436
+ },
424
437
  tooLong: 'tekens, te lang om te versturen',
425
438
  stop: 'Stoppen. Shift-klik stopt ook de sub-agents',
426
439
  queueButton: 'In de wachtrij zetten',
@@ -479,8 +492,7 @@ export default {
479
492
  noAnswer: 'De machine antwoordde niet',
480
493
  stopFailed: 'Kon de sub-agent niet stoppen',
481
494
  info: {
482
- label: 'Over deze sub-agent',
483
- tokens: '{{tokens}} tokens'
495
+ label: 'Over deze sub-agent'
484
496
  }
485
497
  },
486
498
  modes: {
@@ -471,6 +471,32 @@ export function useReportedModels(provider: AgentKind): ReadonlySet<string> {
471
471
  return new Set(joined === '' ? [] : joined.split('\n'));
472
472
  }
473
473
 
474
+ /* `useReportedModels` for every provider at once, as a lookup by provider. */
475
+ export function useReportedModelsByProvider(): (provider: AgentKind) => ReadonlySet<string> {
476
+ const scope = useContext(ChatScopeContext);
477
+
478
+ const joined = useChats((s) => {
479
+ const names = new Set<string>();
480
+
481
+ for (const [key, state] of Object.entries(s.statusByKey)) {
482
+ if (scope?.owns(key) === true && state.info.model !== null) {
483
+ names.add(`${state.info.provider}\t${state.info.model}`);
484
+ }
485
+ }
486
+
487
+ return [...names].sort().join('\n');
488
+ });
489
+
490
+ const byProvider = new Map<string, Set<string>>();
491
+
492
+ for (const line of joined === '' ? [] : joined.split('\n')) {
493
+ const [provider = '', model = ''] = line.split('\t');
494
+ byProvider.set(provider, (byProvider.get(provider) ?? new Set()).add(model));
495
+ }
496
+
497
+ return (provider) => byProvider.get(provider) ?? new Set();
498
+ }
499
+
474
500
  /* Whether a call still waits on the person's answer to an approval of it, when its clock is not running yet. */
475
501
  export function useAwaitsApproval(chatId: string, toolUseId: string): boolean {
476
502
  return useChatRow(chatId, (row) => waitingRequestsOf(row).some((request) => request.kind === 'approval' && request.toolUseId === toolUseId));