@adecore/agents-react 0.38.0 → 0.39.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 (51) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +10 -0
  2. package/dist/agents/AgentModelLabel.js +97 -0
  3. package/dist/chat/ui/Composer.js +385 -360
  4. package/dist/chat/ui/Pickers.d.ts +2 -1
  5. package/dist/chat/ui/Pickers.js +126 -123
  6. package/dist/chat/ui/PromptEditor.d.ts +19 -0
  7. package/dist/chat/ui/PromptEditor.js +115 -0
  8. package/dist/chat/ui/Timeline.d.ts +2 -1
  9. package/dist/chat/ui/Timeline.js +13 -1
  10. package/dist/chat/ui/composer/ComposerControls.d.ts +3 -0
  11. package/dist/chat/ui/composer/ComposerControls.js +235 -38
  12. package/dist/chat/ui/composer/key-handler.d.ts +1 -1
  13. package/dist/chat/ui/composer/key-handler.js +3 -11
  14. package/dist/chat/ui/composer/prompt-picks.d.ts +4 -0
  15. package/dist/chat/ui/composer/prompt-picks.js +14 -0
  16. package/dist/chat/ui/composer/use-composer-menus.d.ts +4 -49
  17. package/dist/chat/ui/composer/use-composer-menus.js +65 -519
  18. package/dist/chat/ui/composer/use-prompt-menus.d.ts +73 -0
  19. package/dist/chat/ui/composer/use-prompt-menus.js +536 -0
  20. package/dist/chat/ui/index.d.ts +3 -0
  21. package/dist/chat/ui/index.js +2 -0
  22. package/dist/host-hooks.d.ts +2 -1
  23. package/dist/host-hooks.js +6 -0
  24. package/dist/host.d.ts +17 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/locales/en/agent-chat.d.ts +1 -0
  27. package/dist/locales/en/agent-chat.js +1 -0
  28. package/dist/locales/nl/agent-chat.d.ts +1 -0
  29. package/dist/locales/nl/agent-chat.js +1 -0
  30. package/dist/providers/index.d.ts +1 -0
  31. package/dist/providers/index.js +1 -0
  32. package/dist/theme.css +3 -0
  33. package/package.json +8 -8
  34. package/src/agents/AgentModelLabel.tsx +40 -0
  35. package/src/chat/ui/Composer.tsx +12 -3
  36. package/src/chat/ui/Pickers.tsx +4 -1
  37. package/src/chat/ui/PromptEditor.tsx +130 -0
  38. package/src/chat/ui/Timeline.tsx +22 -1
  39. package/src/chat/ui/composer/ComposerControls.tsx +65 -15
  40. package/src/chat/ui/composer/key-handler.ts +3 -9
  41. package/src/chat/ui/composer/prompt-picks.ts +17 -0
  42. package/src/chat/ui/composer/use-composer-menus.ts +18 -275
  43. package/src/chat/ui/composer/use-prompt-menus.ts +341 -0
  44. package/src/chat/ui/index.ts +3 -0
  45. package/src/host-hooks.ts +9 -1
  46. package/src/host.ts +27 -1
  47. package/src/index.ts +2 -0
  48. package/src/locales/en/agent-chat.ts +1 -0
  49. package/src/locales/nl/agent-chat.ts +1 -0
  50. package/src/providers/index.ts +1 -0
  51. package/src/theme.css +3 -0
package/src/host-hooks.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { ProviderPlatform } from '@adecore/agent-contracts';
9
9
  import { referablesOfChats, type Referables } from './chat/chat-references';
10
- import { useChatHost, type ChatHost, type CommandLook } from './host';
10
+ import { useChatHost, type ChatHost, type CommandLook, type ComposerSendAction } from './host';
11
11
 
12
12
  export function useHostCodeMode(): 'light' | 'dark' {
13
13
  return useChatHost().code.useMode();
@@ -101,6 +101,14 @@ export function useHostComposerPlaceholder(...args: Parameters<ChatHost['useComp
101
101
  return useChatHost().useComposerPlaceholder(...args);
102
102
  }
103
103
 
104
+ const NO_SEND_ACTIONS: readonly ComposerSendAction[] = [];
105
+ const noSendActions = (): readonly ComposerSendAction[] => NO_SEND_ACTIONS;
106
+
107
+ export function useHostComposerSendActions(scopeId: string, chatId: string): readonly ComposerSendAction[] {
108
+ const useSendActions = useChatHost().useComposerSendActions ?? noSendActions;
109
+ return useSendActions(scopeId, chatId);
110
+ }
111
+
104
112
  export function useHostThreadCards(...args: Parameters<ChatHost['useThreadCards']>): ReturnType<ChatHost['useThreadCards']> {
105
113
  return useChatHost().useThreadCards(...args);
106
114
  }
package/src/host.ts CHANGED
@@ -18,7 +18,9 @@ import type {
18
18
  ChatUiLinkPayload,
19
19
  ChatUiLinkReading,
20
20
  ChatVisual,
21
- ProviderPlatform
21
+ ModelSelection,
22
+ ProviderPlatform,
23
+ RuntimeMode
22
24
  } from '@adecore/agent-contracts';
23
25
  import { isApplePlatform } from '@adecore/ui';
24
26
  import type { Referables } from './chat/chat-references';
@@ -168,6 +170,28 @@ export interface ComposerSlotProps {
168
170
  insert(text: string): void;
169
171
  }
170
172
 
173
+ /* What a send action of the app's gets: the message as it stands when a person picks the action. */
174
+ export interface ComposerSendDraft {
175
+ scopeId: string;
176
+ chatId: string;
177
+ /* The draft as Send would send it, trimmed and with its quote; empty when nothing is written. */
178
+ text: string;
179
+ provider: AgentKind;
180
+ selection: ModelSelection;
181
+ runtimeMode: RuntimeMode;
182
+ }
183
+
184
+ /* An action of the app's own in the menu beside the composer's send button, such as sending the draft later. */
185
+ export interface ComposerSendAction {
186
+ /* Unique among the actions of one composer. */
187
+ id: string;
188
+ label: string;
189
+ icon?: LucideIcon;
190
+ disabled?: boolean;
191
+ /* Runs once a person picks it; the draft stays in the box, and the host shows a failure itself. */
192
+ run(draft: ComposerSendDraft): void;
193
+ }
194
+
171
195
  /* What an app's own chips for a chat's sub-agents get, in place of the one flyout over the composer. */
172
196
  export interface SubagentSlotProps {
173
197
  chatId: string;
@@ -453,6 +477,8 @@ export interface ChatHost {
453
477
  useComposerPlaceholder(scopeId: string, chatId: string): string | null;
454
478
  /* The app's own control in the composer's row, after the pickers; null draws none. */
455
479
  ComposerSlot: ComponentType<ComposerSlotProps> | null;
480
+ /* Actions of the app's own behind a chevron on the send button, in the order given; left out, or none, Send stands alone. */
481
+ useComposerSendActions?(scopeId: string, chatId: string): readonly ComposerSendAction[];
456
482
  /* The app's own chips for a chat's sub-agents over the composer; null draws the one flyout. */
457
483
  SubagentSlot: ComponentType<SubagentSlotProps> | null;
458
484
  /* 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
@@ -9,6 +9,8 @@ export {
9
9
  type TimelineFind,
10
10
  type ComposerDictationProps,
11
11
  type ComposerSlotProps,
12
+ type ComposerSendAction,
13
+ type ComposerSendDraft,
12
14
  type SubagentSlotProps,
13
15
  type ThreadCard,
14
16
  type VisualHost,
@@ -391,6 +391,7 @@ export default {
391
391
  continue: 'Continue',
392
392
  continueHint: 'Continue the stopped turn',
393
393
  send: 'Send',
394
+ sendActions: 'More send options',
394
395
  clear: {
395
396
  title: 'Clear thread?',
396
397
  description: 'A turn is running.',
@@ -391,6 +391,7 @@ export default {
391
391
  continue: 'Doorgaan',
392
392
  continueHint: 'Ga verder met de gestopte beurt',
393
393
  send: 'Versturen',
394
+ sendActions: 'Meer verzendopties',
394
395
  clear: {
395
396
  title: 'Thread wissen?',
396
397
  description: 'Er loopt een turn.',
@@ -1,6 +1,7 @@
1
1
  // Public API: exports.test.ts snapshots this list, so a name added or dropped here is an API change.
2
2
  export { AccountDot } from '../agents/AccountDot';
3
3
  export { AgentIcon } from '../agents/AgentIcon';
4
+ export { AgentModelLabel } from '../agents/AgentModelLabel';
4
5
  export { ModelOptionControl } from '../agents/ModelOptionControl';
5
6
  export { ProviderLogo } from '../agents/ProviderLogo';
6
7
  export { type AccountEntry, accountsOfKind, ACCOUNT_TONE_CLASSES, accountStatusLine, canContinueOn, type AccountTone } from '../agents/accounts';
package/src/theme.css CHANGED
@@ -288,6 +288,9 @@
288
288
  .composer-input .cm-editor .cm-scroller .cm-content { padding: 18px 14px 6px 20px; caret-color: var(--text); }
289
289
  .composer-input .cm-scroller .cm-content .cm-line { padding: 0; }
290
290
  .composer-input .cm-scroller .cm-content .cm-placeholder { color: var(--text-faint); }
291
+ /* The same editor as a form field (`PromptEditor`): the field's inset, and room for a few lines before it scrolls. */
292
+ .composer-input.prompt-editor .cm-editor { max-height: 240px; }
293
+ .composer-input.prompt-editor .cm-editor .cm-scroller .cm-content { min-height: 80px; padding: 6px 10px; }
291
294
  .composer-hints, .composer-hints-extra { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
292
295
  /* The joiner starts with its own comma, so it sits against the lead without the gap. */
293
296
  .composer-hints-extra { margin-left: -8px; }