@adecore/agents-react 0.65.2 → 0.66.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 (116) hide show
  1. package/dist/chat/activity.d.ts +5 -2
  2. package/dist/chat/activity.js +13 -2
  3. package/dist/chat/logic/bookmarks.d.ts +3 -2
  4. package/dist/chat/logic/continue-after-stop.d.ts +2 -2
  5. package/dist/chat/logic/fork.d.ts +7 -6
  6. package/dist/chat/logic/goal.d.ts +8 -3
  7. package/dist/chat/logic/goal.js +7 -1
  8. package/dist/chat/logic/handback.d.ts +2 -2
  9. package/dist/chat/logic/limit.d.ts +2 -2
  10. package/dist/chat/logic/limit.js +8 -0
  11. package/dist/chat/logic/resume-compaction.d.ts +4 -3
  12. package/dist/chat/logic/scrubber.d.ts +3 -2
  13. package/dist/chat/logic/timeline-target.d.ts +4 -3
  14. package/dist/chat/logic/timeline.d.ts +5 -4
  15. package/dist/chat/logic/timeline.js +9 -0
  16. package/dist/chat/recent-messages.d.ts +3 -3
  17. package/dist/chat/runtime-modes.d.ts +2 -1
  18. package/dist/chat/runtime-modes.js +5 -1
  19. package/dist/chat/subagent-conversation.d.ts +5 -4
  20. package/dist/chat/subagent-conversation.js +3 -2
  21. package/dist/chat/subagent-list.d.ts +4 -3
  22. package/dist/chat/subagent-view.d.ts +4 -3
  23. package/dist/chat/ui/ChatActivity.js +19 -15
  24. package/dist/chat/ui/Composer.d.ts +3 -2
  25. package/dist/chat/ui/GoalDock.d.ts +3 -2
  26. package/dist/chat/ui/GoalDock.js +19 -28
  27. package/dist/chat/ui/LimitState.d.ts +2 -2
  28. package/dist/chat/ui/RunSettings.d.ts +3 -2
  29. package/dist/chat/ui/RunSettings.js +318 -298
  30. package/dist/chat/ui/composer/ComposerControls.d.ts +2 -2
  31. package/dist/chat/ui/composer/use-chat-controls.d.ts +3 -2
  32. package/dist/chat/ui/composer/use-compaction-offer.d.ts +3 -2
  33. package/dist/chat/ui/composer/use-composer-menus.d.ts +3 -2
  34. package/dist/chat/ui/composer/use-continuable-turn.d.ts +2 -2
  35. package/dist/chat/ui/composer/use-effort-stepper.d.ts +3 -2
  36. package/dist/chat/ui/reply-context.d.ts +2 -2
  37. package/dist/chat/ui/rows/MessageRows.d.ts +4 -0
  38. package/dist/chat/ui/rows/MessageRows.js +61 -1
  39. package/dist/chat/ui/rows/Rows.js +42 -26
  40. package/dist/chat/ui/rows/SubagentRow.d.ts +3 -2
  41. package/dist/chat/ui/rows/WorkRows.d.ts +3 -2
  42. package/dist/chat/waiting-on.d.ts +5 -4
  43. package/dist/chat/waiting-on.js +2 -1
  44. package/dist/chat/workflow-list.d.ts +3 -2
  45. package/dist/chat-client.d.ts +2 -1
  46. package/dist/chat-sink.d.ts +16 -9
  47. package/dist/host/host-hooks.d.ts +2 -1
  48. package/dist/host/host-hooks.js +5 -0
  49. package/dist/host/host.d.ts +8 -2
  50. package/dist/host/timeline-row.d.ts +10 -4
  51. package/dist/index.d.ts +2 -2
  52. package/dist/locales/en/agent-chat.d.ts +16 -0
  53. package/dist/locales/en/agent-chat.js +17 -1
  54. package/dist/locales/nl/agent-chat.d.ts +16 -0
  55. package/dist/locales/nl/agent-chat.js +17 -1
  56. package/dist/port-transport.d.ts +10 -1
  57. package/dist/port-transport.js +14 -3
  58. package/dist/state/chats.d.ts +17 -15
  59. package/dist/state/chats.js +7 -0
  60. package/dist/state/index.d.ts +1 -1
  61. package/dist/state/usage.d.ts +3 -2
  62. package/dist/state/usage.js +34 -3
  63. package/dist/transport.d.ts +3 -2
  64. package/dist/usage/limit-groups.js +1 -1
  65. package/package.json +9 -9
  66. package/src/chat/activity.ts +19 -6
  67. package/src/chat/forks.ts +3 -3
  68. package/src/chat/logic/bookmarks.ts +3 -2
  69. package/src/chat/logic/continue-after-stop.ts +3 -2
  70. package/src/chat/logic/fork.ts +8 -7
  71. package/src/chat/logic/goal.ts +13 -4
  72. package/src/chat/logic/handback.ts +2 -3
  73. package/src/chat/logic/limit.ts +7 -2
  74. package/src/chat/logic/resume-compaction.ts +7 -6
  75. package/src/chat/logic/scrubber.ts +4 -3
  76. package/src/chat/logic/timeline-target.ts +4 -3
  77. package/src/chat/logic/timeline.ts +22 -16
  78. package/src/chat/pending-prompts.ts +3 -2
  79. package/src/chat/recent-messages.ts +5 -6
  80. package/src/chat/runtime-modes.ts +7 -2
  81. package/src/chat/subagent-conversation.ts +12 -9
  82. package/src/chat/subagent-list.ts +4 -3
  83. package/src/chat/subagent-view.ts +4 -3
  84. package/src/chat/ui/ChatActivity.tsx +11 -7
  85. package/src/chat/ui/Composer.tsx +3 -2
  86. package/src/chat/ui/GoalDock.tsx +6 -5
  87. package/src/chat/ui/LimitState.tsx +5 -5
  88. package/src/chat/ui/RunSettings.tsx +17 -9
  89. package/src/chat/ui/composer/ComposerControls.tsx +3 -2
  90. package/src/chat/ui/composer/use-chat-controls.ts +3 -2
  91. package/src/chat/ui/composer/use-compaction-offer.ts +4 -3
  92. package/src/chat/ui/composer/use-composer-menus.ts +3 -2
  93. package/src/chat/ui/composer/use-continuable-turn.ts +3 -3
  94. package/src/chat/ui/composer/use-effort-stepper.ts +3 -2
  95. package/src/chat/ui/reply-context.ts +2 -2
  96. package/src/chat/ui/rows/MessageRows.tsx +17 -1
  97. package/src/chat/ui/rows/Rows.tsx +3 -0
  98. package/src/chat/ui/rows/SubagentRow.tsx +5 -4
  99. package/src/chat/ui/rows/WorkRows.tsx +3 -2
  100. package/src/chat/ui/thread-references.ts +3 -3
  101. package/src/chat/waiting-on.ts +8 -7
  102. package/src/chat/workflow-list.ts +3 -2
  103. package/src/chat-client.ts +3 -2
  104. package/src/chat-sink.ts +21 -9
  105. package/src/host/host-hooks.ts +9 -1
  106. package/src/host/host.ts +13 -2
  107. package/src/host/timeline-row.ts +7 -5
  108. package/src/index.ts +2 -1
  109. package/src/locales/en/agent-chat.ts +17 -1
  110. package/src/locales/nl/agent-chat.ts +17 -1
  111. package/src/port-transport.ts +20 -3
  112. package/src/state/chats.ts +34 -35
  113. package/src/state/index.ts +1 -1
  114. package/src/state/usage.ts +45 -5
  115. package/src/transport.ts +4 -2
  116. package/src/usage/limit-groups.ts +1 -1
@@ -26,6 +26,7 @@ import {
26
26
  Settings,
27
27
  Shield,
28
28
  ShieldAlert,
29
+ ShieldQuestionMark,
29
30
  SlidersHorizontal,
30
31
  Star,
31
32
  type LucideIcon
@@ -38,6 +39,7 @@ import { accountColor, canContinueOn } from '../../agents/accounts';
38
39
  import { AgentIcon } from '../../agents/AgentIcon';
39
40
  import { modelName } from '../../agents/model-name';
40
41
  import { localizedOption } from '../../agents/option-words';
42
+ import type { ChatThreadInfo } from '../../chat-sink';
41
43
  import { useChatHost } from '../../host/host';
42
44
  import { PROVIDER_COLORS } from '../../usage/format';
43
45
  import { useUsageLimits } from '../../usage/limits';
@@ -46,7 +48,7 @@ import { CONTEXT_OPTION, contextFraction, contextSegments, orderOptions, type Co
46
48
  import { EFFORT_OPTION } from '../logic/effort';
47
49
  import { favoritesFirst, searchModels, shortlistOf, wantsModelSearch } from '../logic/picker-entries';
48
50
  import { favoriteModelsOf, toggleFavoriteModel, useChatPreferences } from '../preferences';
49
- import { RUNTIME_MODES } from '../runtime-modes';
51
+ import { isKnownRuntimeMode, RUNTIME_MODES } from '../runtime-modes';
50
52
  import { ModelMarks } from './ModelMarks';
51
53
  import { SessionLine } from './SessionLine';
52
54
 
@@ -59,6 +61,10 @@ const MODE_ICONS: Record<RuntimeMode, LucideIcon> = {
59
61
  'full-access': ShieldAlert
60
62
  };
61
63
 
64
+ function modeIcon(mode: string): LucideIcon {
65
+ return isKnownRuntimeMode(mode) ? MODE_ICONS[mode] : ShieldQuestionMark;
66
+ }
67
+
62
68
  // More choices than this do not fit beside the label, so they go in a submenu of their own.
63
69
  const INLINE_CHOICES = 3;
64
70
 
@@ -79,8 +85,9 @@ interface RunSettingsProps {
79
85
  provider: AgentKind;
80
86
  selection: ModelSelection;
81
87
  model: ModelInfo | undefined;
82
- runtimeMode: RuntimeMode;
83
- effectiveRuntimeMode?: RuntimeMode;
88
+ /* As the host reports it, so possibly a mode of a newer host that this version shows as set there. */
89
+ runtimeMode: ChatThreadInfo['runtimeMode'];
90
+ effectiveRuntimeMode?: ChatThreadInfo['effectiveRuntimeMode'];
84
91
  permissionMode?: string;
85
92
  /* Controlled, so `/model` in the composer can open the same menu a click on the pill does. */
86
93
  open: boolean;
@@ -199,8 +206,9 @@ export function RunSettings({
199
206
  const shownMode = effectiveRuntimeMode ?? runtimeMode;
200
207
  const fullAccess = shownMode === 'full-access';
201
208
  const permissionFallback = permissionMode !== undefined && effectiveRuntimeMode !== runtimeMode;
202
- const effectiveLabel = effectiveRuntimeMode === undefined ? permissionMode : t(`modes.${effectiveRuntimeMode}.label`);
203
- const permissionHint = permissionFallback ? t('pickers.mode.effective', { effective: effectiveLabel, requested: t(`modes.${runtimeMode}.label`) }) : null;
209
+ const modeWord = (mode: string, form: 'label' | 'short'): string => (isKnownRuntimeMode(mode) ? t(`modes.${mode}.${form}`) : t(`modes.unknown.${form}`));
210
+ const effectiveLabel = effectiveRuntimeMode === undefined ? permissionMode : modeWord(effectiveRuntimeMode, 'label');
211
+ const permissionHint = permissionFallback ? t('pickers.mode.effective', { effective: effectiveLabel, requested: modeWord(runtimeMode, 'label') }) : null;
204
212
 
205
213
  const chooseModel = (value: string): void => {
206
214
  const slash = value.indexOf('/');
@@ -393,9 +401,9 @@ export function RunSettings({
393
401
  )}
394
402
  <span className="shrink-0 text-text-faint">·</span>
395
403
  <span className={clsx('flex shrink-0 items-center gap-1', fullAccess && 'text-status-needs-you')}>
396
- <Icon icon={MODE_ICONS[shownMode]} size={12} className="shrink-0" />
404
+ <Icon icon={modeIcon(shownMode)} size={12} className="shrink-0" />
397
405
  <span className="@max-xl/composer:hidden">
398
- {effectiveRuntimeMode === undefined && permissionMode !== undefined ? permissionMode : t(`modes.${shownMode}.short`)}
406
+ {effectiveRuntimeMode === undefined && permissionMode !== undefined ? permissionMode : modeWord(shownMode, 'short')}
399
407
  </span>
400
408
  {permissionFallback && <Icon icon={TriangleAlert} size={12} className="shrink-0 text-status-needs-you" />}
401
409
  </span>
@@ -464,12 +472,12 @@ export function RunSettings({
464
472
  <Menu.SubmenuRoot>
465
473
  <Menu.SubmenuTrigger className="text-text-muted">
466
474
  <Icon
467
- icon={MODE_ICONS[runtimeMode]}
475
+ icon={modeIcon(runtimeMode)}
468
476
  size={14}
469
477
  className={clsx('shrink-0', fullAccess ? 'text-status-needs-you' : 'text-text-faint')}
470
478
  />
471
479
  <span className="min-w-0 grow truncate">{t('pickers.mode.label')}</span>
472
- <Menu.Hint className="truncate">{t(`modes.${runtimeMode}.label`)}</Menu.Hint>
480
+ <Menu.Hint className="truncate">{modeWord(runtimeMode, 'label')}</Menu.Hint>
473
481
  </Menu.SubmenuTrigger>
474
482
  <Menu.Popup className="w-72">
475
483
  {permissionHint !== null && <p className="px-2.5 py-2 text-xs text-text-muted">{permissionHint}</p>}
@@ -1,8 +1,9 @@
1
- import { holdsConversation, type ChatInfo } from '@adecore/agent-contracts';
1
+ import { holdsConversation } from '@adecore/agent-contracts';
2
2
  import { Button, ErrorBoundary, Icon, Tooltip, type Shortcut } from '@adecore/ui';
3
3
  import { ArrowUp, Play, Square } from 'lucide-react';
4
4
  import { useRef, type Ref } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
+ import type { ChatThreadInfo } from '../../../chat-sink';
6
7
  import { useChatHost } from '../../../host/host';
7
8
  import { useChatScope } from '../../../scope';
8
9
  import { useProviders } from '../../../state/providers';
@@ -40,7 +41,7 @@ function SendButton({ send }: { send: SendProps }) {
40
41
 
41
42
  interface ComposerControlsProps {
42
43
  chatId: string;
43
- info: ChatInfo;
44
+ info: ChatThreadInfo;
44
45
  providerFixed: boolean;
45
46
  writable: boolean;
46
47
  attachable: boolean;
@@ -1,6 +1,7 @@
1
- import type { AgentKind, ChatInfo, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
1
+ import type { AgentKind, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
2
2
  import { useRef, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
+ import type { ChatThreadInfo } from '../../../chat-sink';
4
5
  import { useChatHost } from '../../../host/host';
5
6
  import { useHostCanReorderAccounts } from '../../../host/host-hooks';
6
7
  import { useChatScope } from '../../../scope';
@@ -12,7 +13,7 @@ import type { ComposerNotice } from './use-notice';
12
13
 
13
14
  interface ControlsInput {
14
15
  chatId: string;
15
- info: ChatInfo;
16
+ info: ChatThreadInfo;
16
17
  notice: ComposerNotice;
17
18
  onRetarget(provider: AgentKind, selection: ModelSelection): Promise<void>;
18
19
  }
@@ -1,5 +1,6 @@
1
- import type { ChatInfo, ChatItem, ProviderCapabilities } from '@adecore/agent-contracts';
1
+ import type { ProviderCapabilities } from '@adecore/agent-contracts';
2
2
  import { useEffect, useState } from 'react';
3
+ import type { ChatThreadInfo, ChatThreadItem } from '../../../chat-sink';
3
4
  import { useChatRow } from '../../../state/chats';
4
5
  import { RESUME_COMPACTION_TOKENS, resumeCompactionDueAt, resumeCompactionOffer, watchDueAt, type DueClock } from '../../logic/resume-compaction';
5
6
  import { useResumeCompactionDismissal } from '../../resume-compaction-dismissals';
@@ -24,14 +25,14 @@ const PAGE_CLOCK: DueClock = {
24
25
  };
25
26
 
26
27
  /* The offer to fold a long context before a chat whose cache went cold goes on, or null when there is none. */
27
- export function useCompactionOffer(chatId: string, info: ChatInfo, compaction: ProviderCapabilities['compaction'] | undefined) {
28
+ export function useCompactionOffer(chatId: string, info: ChatThreadInfo, compaction: ProviderCapabilities['compaction'] | undefined) {
28
29
  const order = useChatRow(chatId, (row) => row?.order);
29
30
  const structure = useChatRow(chatId, (row) => row?.structure);
30
31
  const dismissedTurnId = useResumeCompactionDismissal(chatId);
31
32
  const [now, setNow] = useState(Date.now);
32
33
  // The cheap half of the offer, so a chat that can never make one walks no thread.
33
34
  const couldOffer = compaction !== undefined && compaction !== 'none' && info.usage.contextTokens >= RESUME_COMPACTION_TOKENS;
34
- const items = couldOffer ? (order ?? []).map((id) => structure?.[id]).filter((item): item is ChatItem => item !== undefined) : [];
35
+ const items = couldOffer ? (order ?? []).map((id) => structure?.[id]).filter((item): item is ChatThreadItem => item !== undefined) : [];
35
36
  const input = { info, compaction, items, dismissedTurnId };
36
37
  const dueAt = couldOffer ? resumeCompactionDueAt(input) : null;
37
38
 
@@ -1,6 +1,7 @@
1
- import type { ChatInfo, ChatSkill, ProviderCapabilities } from '@adecore/agent-contracts';
1
+ import type { ChatSkill, ProviderCapabilities } from '@adecore/agent-contracts';
2
2
  import { useEffect, useState, type RefObject } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
+ import type { ChatThreadInfo } from '../../../chat-sink';
4
5
  import { useHostAccountRule, useHostReferables } from '../../../host/host-hooks';
5
6
  import { useChatScope } from '../../../scope';
6
7
  import type { ComposerInputHandle } from '../ComposerInput';
@@ -14,7 +15,7 @@ const LOCAL_COMMANDS = ['model', 'compact', 'clear'];
14
15
 
15
16
  interface MenusInput {
16
17
  chatId: string;
17
- info: ChatInfo;
18
+ info: ChatThreadInfo;
18
19
  capabilities: ProviderCapabilities | undefined;
19
20
  providerName: string | undefined;
20
21
  draft: ComposerDraft;
@@ -1,11 +1,11 @@
1
- import type { ChatInfo, ChatItem } from '@adecore/agent-contracts';
1
+ import type { ChatThreadInfo, ChatThreadItem } from '../../../chat-sink';
2
2
  import { useChatRow } from '../../../state/chats';
3
3
  import { continuableTurn } from '../../logic/continue-after-stop';
4
4
 
5
- export function useContinuableTurn(chatId: string, info: ChatInfo): string | null {
5
+ export function useContinuableTurn(chatId: string, info: ChatThreadInfo): string | null {
6
6
  const order = useChatRow(chatId, (row) => row?.order);
7
7
  const structure = useChatRow(chatId, (row) => row?.structure);
8
- const items = (order ?? []).map((id) => structure?.[id]).filter((item): item is ChatItem => item !== undefined);
8
+ const items = (order ?? []).map((id) => structure?.[id]).filter((item): item is ChatThreadItem => item !== undefined);
9
9
 
10
10
  return continuableTurn(info, items);
11
11
  }
@@ -1,7 +1,8 @@
1
- import type { ChatInfo, ModelInfo } from '@adecore/agent-contracts';
1
+ import type { ModelInfo } from '@adecore/agent-contracts';
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { choiceWord } from '../../../agents/option-words';
5
+ import type { ChatThreadInfo } from '../../../chat-sink';
5
6
  import { useChatScope } from '../../../scope';
6
7
  import { registerEffortStepper } from '../../composer-effort';
7
8
  import { EFFORT_OPTION, stepEffort, type EffortStep } from '../../logic/effort';
@@ -10,7 +11,7 @@ import type { ComposerNotice } from './use-notice';
10
11
 
11
12
  interface EffortStepperInput {
12
13
  chatId: string;
13
- info: ChatInfo;
14
+ info: ChatThreadInfo;
14
15
  model: ModelInfo | undefined;
15
16
  writable: boolean;
16
17
  controls: ChatControls;
@@ -1,8 +1,8 @@
1
- import type { ChatInfo } from '@adecore/agent-contracts';
2
1
  import { createContext } from 'react';
2
+ import type { ChatThreadInfo } from '../../chat-sink';
3
3
  import type { UiReplyTarget } from '../logic/timeline-target';
4
4
 
5
- export const ReplyContext = createContext<{ provider: ChatInfo['provider']; chatId?: string } | null>(null);
5
+ export const ReplyContext = createContext<{ provider: ChatThreadInfo['provider']; chatId?: string } | null>(null);
6
6
 
7
7
  export const UiReplyNavigationContext = createContext<{
8
8
  chatId: string;
@@ -32,7 +32,7 @@ import {
32
32
  import { useContext, useState, type ReactNode } from 'react';
33
33
  import { useTranslation } from 'react-i18next';
34
34
  import { useChatHost, type CommandLookSent, type ReplyAuthor } from '../../../host/host';
35
- import { useHostAttachmentUrl, useHostChatPlace, useHostReplyAuthor, useHostStreaming } from '../../../host/host-hooks';
35
+ import { useHostAttachmentUrl, useHostChatPlace, useHostReplyAuthor, useHostStreaming, useHostUnknownItemWords } from '../../../host/host-hooks';
36
36
  import { useChatScope } from '../../../scope';
37
37
  import { useChatRow, useCurrentItem } from '../../../state/chats';
38
38
  import { useProviders } from '../../../state/providers';
@@ -664,6 +664,22 @@ export function NoteRow({ id, level, text, from, said }: { id: string; level: 'i
664
664
  return <NoteLine id={id} level={level} text={text} from={from} />;
665
665
  }
666
666
 
667
+ /* An item of a newer host this version cannot read: one muted line in its place, with nothing on it to act on. */
668
+ export function UnknownRow({ id, waits }: { id: string; waits: boolean }) {
669
+ const { t } = useTranslation('agent-chat');
670
+ const words = useHostUnknownItemWords();
671
+ const text = waits ? (words?.request ?? t('rows.unknown.request')) : (words?.item ?? t('rows.unknown.item'));
672
+
673
+ return (
674
+ <div data-find-item={id} className="-mx-1 mb-0.5 flex min-h-7 items-start gap-2 px-1 py-1 text-xs text-text-faint">
675
+ <span className={ROW_GUTTER}>{NOTE_ICON.info}</span>
676
+ <span data-find-field="summary" className="min-w-0 flex-1 select-text">
677
+ {text}
678
+ </span>
679
+ </div>
680
+ );
681
+ }
682
+
667
683
  function NoteLine({ id, level, text, from }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }) {
668
684
  const { t } = useTranslation('agent-chat');
669
685
  const [open, setOpen] = useState(false);
@@ -19,6 +19,7 @@ import {
19
19
  SentByAgentRow,
20
20
  SentMessageRow,
21
21
  ThinkingRow,
22
+ UnknownRow,
22
23
  UserRow
23
24
  } from './MessageRows';
24
25
  import { SubagentBranchRow } from './SubagentRow';
@@ -117,6 +118,8 @@ export function Row({ row, chatId, toggleGroup, toggleTurn, toggleSubagent, open
117
118
  return <SentByAgentRow chatId={chatId} id={row.id} tool={row.tool} sent={row.sent} />;
118
119
  case 'compaction':
119
120
  return <CompactionRow preTokens={row.preTokens} postTokens={row.postTokens} />;
121
+ case 'unknown':
122
+ return <UnknownRow id={row.id} waits={row.waits} />;
120
123
  case 'selection-switch':
121
124
  return <SelectionSwitchRow chatId={chatId} from={row.from} to={row.to} />;
122
125
  case 'working':
@@ -1,10 +1,11 @@
1
- import { HOST_TASK_ORIGIN, taskIdOfRow, type ChatAssistantItem, type ChatItem, type ChatSubagentItem } from '@adecore/agent-contracts';
1
+ import { HOST_TASK_ORIGIN, taskIdOfRow, type ChatAssistantItem, type ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  import { Icon, ScrollArea, useNow } from '@adecore/ui';
3
3
  import { formatElapsedShort } from '@adecore/ui/format';
4
4
  import clsx from 'clsx';
5
5
  import { Bot, ChevronDown } from 'lucide-react';
6
6
  import { useLayoutEffect, useRef, useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
+ import type { ChatThreadItem } from '../../../chat-sink';
8
9
  import { type SubagentTask } from '../../../host/host';
9
10
  import { useHostHidesToolCalls, useHostTask } from '../../../host/host-hooks';
10
11
  import type { SubagentBranch } from '../../../host/timeline-row';
@@ -28,7 +29,7 @@ const CHILDREN_MAX_PX = 320;
28
29
  * but off a timeline it has already grouped and folded, and it writes an answer at the size of a
29
30
  * message; here every step is a line and the text is the aside under it.
30
31
  */
31
- function ChildRow({ chatId, item }: { chatId: string; item: ChatItem }) {
32
+ function ChildRow({ chatId, item }: { chatId: string; item: ChatThreadItem }) {
32
33
  if (item.kind === 'tool') {
33
34
  if (isImageGeneration(item)) {
34
35
  return <GeneratedImageRow chatId={chatId} tool={item} />;
@@ -78,7 +79,7 @@ function StatusPill({ item, task }: { item: ChatSubagentItem; task: SubagentTask
78
79
  );
79
80
  }
80
81
 
81
- function SubagentWork({ chatId, item, work }: { chatId: string; item: ChatSubagentItem; work: ChatItem[] }) {
82
+ function SubagentWork({ chatId, item, work }: { chatId: string; item: ChatSubagentItem; work: ChatThreadItem[] }) {
82
83
  const { t } = useTranslation('agent-chat');
83
84
  const { id } = useChatScope();
84
85
  const hideTools = useHostHidesToolCalls(id, chatId);
@@ -150,7 +151,7 @@ export function SubagentRow({
150
151
  }: {
151
152
  chatId: string;
152
153
  item: ChatSubagentItem;
153
- work: ChatItem[];
154
+ work: ChatThreadItem[];
154
155
  expanded: boolean;
155
156
  onToggle(): void;
156
157
  /* Opens everything it did in the thread's place, for a view that has somewhere to open it. */
@@ -1,4 +1,4 @@
1
- import type { ChatCheckpointDiff, ChatCheckpointFile, ChatFileChange, ChatToolItem, ChatTurnItem } from '@adecore/agent-contracts';
1
+ import type { ChatCheckpointDiff, ChatCheckpointFile, ChatFileChange, ChatToolItem } from '@adecore/agent-contracts';
2
2
  import { Button, Icon, LazyBoundary, MiddleTruncate, ScrollArea, Spinner, lazyNamed, useTickingText } from '@adecore/ui';
3
3
  import { formatClockDuration, formatElapsedShort } from '@adecore/ui/format';
4
4
  import clsx from 'clsx';
@@ -6,6 +6,7 @@ import i18next from 'i18next';
6
6
  import { ChevronRight, FileDiff, X } from 'lucide-react';
7
7
  import { Fragment, useContext, useEffect, useState, type Dispatch, type ReactNode, type SetStateAction } from 'react';
8
8
  import { useTranslation } from 'react-i18next';
9
+ import type { ChatThreadTurn } from '../../../chat-sink';
9
10
  import { useChatHost, type CommandLook, type ToolLook } from '../../../host/host';
10
11
  import { useCommandNames } from '../../../host/host-hooks';
11
12
  import { type Look } from '../../../host/timeline-row';
@@ -614,7 +615,7 @@ export function TurnFoldRow({
614
615
  expandable,
615
616
  onToggle
616
617
  }: {
617
- turn: ChatTurnItem;
618
+ turn: ChatThreadTurn;
618
619
  label: string;
619
620
  work: readonly string[];
620
621
  expanded: boolean;
@@ -1,18 +1,18 @@
1
- import type { ChatItem } from '@adecore/agent-contracts';
1
+ import type { ChatThreadItem } from '../../chat-sink';
2
2
  import { useChatHost } from '../../host/host';
3
3
  import { useHostReferables } from '../../host/host-hooks';
4
4
  import { useChatScope } from '../../scope';
5
5
  import { useChatRow } from '../../state/chats';
6
6
  import type { ReferenceLookup } from './reference-lookup';
7
7
 
8
- const referencedOf = new WeakMap<Record<string, ChatItem>, string>();
8
+ const referencedOf = new WeakMap<Record<string, ChatThreadItem>, string>();
9
9
 
10
10
  /*
11
11
  * The ids a person pointed at with `#` in a thread, one per line. A string, so the selector that reads
12
12
  * it answers the same value until a message with another one comes; the structure a streamed word
13
13
  * leaves alone is what it is cached on.
14
14
  */
15
- function threadReferencedKey(structure: Record<string, ChatItem> | undefined): string {
15
+ function threadReferencedKey(structure: Record<string, ChatThreadItem> | undefined): string {
16
16
  if (structure === undefined) {
17
17
  return '';
18
18
  }
@@ -1,21 +1,22 @@
1
- import type { ChatBackgroundTask, ChatInfo } from '@adecore/agent-contracts';
2
1
  import { formatElapsedShort, formatMoment } from '@adecore/ui/format';
3
2
  import i18next from 'i18next';
3
+ import type { ChatThreadInfo } from '../chat-sink';
4
+ import { backgroundTaskName, type ChatThreadBackgroundTask } from './activity';
4
5
 
5
6
  /* An open task the chat delegated: whether its child waits out a limit, and that child's info where the client has it. */
6
7
  export interface WaitingChild {
7
8
  paused?: { until?: number };
8
- child?: Pick<ChatInfo, 'status' | 'requests'>;
9
+ child?: Pick<ChatThreadInfo, 'status' | 'requests'>;
9
10
  }
10
11
 
11
12
  /* What a chat has that it may be waiting on, as every client already holds it. */
12
13
  export interface WaitingOnInput {
13
14
  children?: readonly WaitingChild[];
14
- background?: readonly ChatBackgroundTask[];
15
+ background?: readonly ChatThreadBackgroundTask[];
15
16
  /* Background subagents and workflows of the CLI's own, counted where the thread is loaded. */
16
17
  subagents?: number;
17
18
  workflows?: number;
18
- /* `ChatInfo.delegating`, for a client that has only the info and so no counts. */
19
+ /* `ChatThreadInfo.delegating`, for a client that has only the info and so no counts. */
19
20
  delegating?: boolean;
20
21
  /* The status line of the plan the chat works on. */
21
22
  planStatus?: string;
@@ -24,7 +25,7 @@ export interface WaitingOnInput {
24
25
  export type WaitingOn =
25
26
  | { kind: 'needs-you'; count: number }
26
27
  | { kind: 'paused'; until?: number }
27
- | { kind: 'command'; task: ChatBackgroundTask }
28
+ | { kind: 'command'; task: ChatThreadBackgroundTask }
28
29
  | { kind: 'background'; subagents: number; workflows: number }
29
30
  | { kind: 'plan'; text: string };
30
31
 
@@ -49,7 +50,7 @@ export function waitingOnOf(input: WaitingOnInput): WaitingOn | null {
49
50
  return times.length === 0 ? { kind: 'paused' } : { kind: 'paused', until: Math.min(...times) };
50
51
  }
51
52
 
52
- const oldest = (input.background ?? []).reduce<ChatBackgroundTask | null>(
53
+ const oldest = (input.background ?? []).reduce<ChatThreadBackgroundTask | null>(
53
54
  (found, task) => (found === null || task.startedAt < found.startedAt ? task : found),
54
55
  null
55
56
  );
@@ -81,7 +82,7 @@ export function waitingOnLabel(waiting: WaitingOn, now: number): string {
81
82
  return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', { time: formatMoment(waiting.until, now) });
82
83
  case 'command':
83
84
  return t('waitingOn.command', {
84
- command: waiting.task.description || waiting.task.command || t(`activity.${waiting.task.kind}`),
85
+ command: backgroundTaskName(waiting.task),
85
86
  age: formatElapsedShort(Math.max(0, now - waiting.task.startedAt))
86
87
  });
87
88
  case 'background':
@@ -1,5 +1,6 @@
1
- import { activeWorkflows, type ChatItem, type ChatToolItem, type ChatWorkflow } from '@adecore/agent-contracts';
1
+ import { activeWorkflows, type ChatToolItem, type ChatWorkflow } from '@adecore/agent-contracts';
2
2
  import i18next from 'i18next';
3
+ import type { ChatThreadItem } from '../chat-sink';
3
4
  import { workflowCounts, workflowPhases } from './logic/workflow';
4
5
 
5
6
  /* A Workflow call that reported what it runs, which is every one `activeWorkflows` keeps. */
@@ -14,7 +15,7 @@ interface WorkflowPill {
14
15
  }
15
16
 
16
17
  /* What the workflow pill over the composer lists (`activeWorkflows`); `order` puts the calls from before the page first. */
17
- export function flyoutWorkflows(order: readonly string[], structure: Readonly<Record<string, ChatItem>>): WorkflowCall[] {
18
+ export function flyoutWorkflows(order: readonly string[], structure: Readonly<Record<string, ChatThreadItem>>): WorkflowCall[] {
18
19
  return activeWorkflows(
19
20
  order.flatMap((id) => {
20
21
  const item = structure[id];
@@ -11,6 +11,7 @@ import type {
11
11
  ProviderInfo,
12
12
  RuntimeMode
13
13
  } from '@adecore/agent-contracts';
14
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
14
15
  import type { ChatSink } from './chat-sink';
15
16
  import { MountedRegistry, type MountedEntry } from './mounted-registry';
16
17
  import { errorCode, isConnectionError, type ChatTransport, type ChatTransportStatus } from './transport';
@@ -70,7 +71,7 @@ export class ChatClient {
70
71
  private readonly unsubscribe: Array<() => void> = [];
71
72
  private readonly earlier = new Map<string, Promise<void>>();
72
73
  private readonly observers = new Map<string, number>();
73
- private readonly inspections = new Map<string, Promise<ChatAttachResult>>();
74
+ private readonly inspections = new Map<string, Promise<Tolerant<ChatAttachResult>>>();
74
75
  private preferences: ChatPreferencesPayload | null = null;
75
76
  private checkpoints = new WeakMap<object, number>();
76
77
 
@@ -101,7 +102,7 @@ export class ChatClient {
101
102
  }
102
103
  }
103
104
 
104
- inspect(chatId: string): Promise<ChatAttachResult> {
105
+ inspect(chatId: string): Promise<Tolerant<ChatAttachResult>> {
105
106
  const pending = this.inspections.get(chatId);
106
107
 
107
108
  if (pending) {
package/src/chat-sink.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import type { ChatBookmark, ChatEvent, ChatHistoryResult, ChatInfo, ChatItem, ChatSubagentItem, ChatToolItem, ChatVisual } from '@adecore/agent-contracts';
2
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
3
+
4
+ /* An item as a client holds it: one of a newer host that this version cannot read stays in its place as `unknown`. */
5
+ export type ChatThreadItem = Tolerant<ChatItem>;
6
+
7
+ export type ChatThreadTurn = Extract<ChatThreadItem, { kind: 'turn' }>;
8
+
9
+ /* A chat's info as a client holds it: a state word of a newer host is kept as it came. */
10
+ export type ChatThreadInfo = Tolerant<ChatInfo>;
11
+
12
+ /* An event as a client applies it; one of a type this version cannot read changes nothing. */
13
+ export type ChatThreadEvent = Tolerant<ChatEvent>;
2
14
 
3
15
  export type ChatHistoryPage = ChatHistoryResult['history'];
4
16
 
@@ -6,13 +18,13 @@ export type ChatHistoryPage = ChatHistoryResult['history'];
6
18
  export interface ChatPage {
7
19
  history: ChatHistoryPage;
8
20
  /* Every request of the chat that still waits, wherever in the thread it is. */
9
- pending: ChatItem[];
21
+ pending: ChatThreadItem[];
10
22
  /* The active sub-agents from before the page; absent from a host that sends none. */
11
- subagents?: ChatSubagentItem[];
23
+ subagents?: Tolerant<ChatSubagentItem>[];
12
24
  /* The active Workflow calls from before the page; absent from a host that sends none. */
13
- workflows?: ChatToolItem[];
25
+ workflows?: Tolerant<ChatToolItem>[];
14
26
  /* The outline of the thread before the page; absent from a host that sends none. */
15
- outline?: ChatItem[];
27
+ outline?: ChatThreadItem[];
16
28
  }
17
29
 
18
30
  /* What a chat client writes. It owns one host's link, so it speaks in chat ids alone. */
@@ -23,14 +35,14 @@ export interface ChatSink {
23
35
  */
24
36
  historyIdentity?(chatId: string): object | undefined;
25
37
  /* Without a page the items are the whole thread. */
26
- reset(chatId: string, info: ChatInfo, items: ChatItem[], page?: ChatPage): void;
38
+ reset(chatId: string, info: ChatThreadInfo, items: ChatThreadItem[], page?: ChatPage): void;
27
39
  /* The page before the one the chat holds, read with `cursor`. */
28
- prepend(chatId: string, cursor: string, page: ChatHistoryResult): void;
29
- apply(chatId: string, event: ChatEvent): void;
40
+ prepend(chatId: string, cursor: string, page: Tolerant<ChatHistoryResult>): void;
41
+ apply(chatId: string, event: ChatThreadEvent): void;
30
42
  /* A reconnect can publish its complete replay at once; absent sinks receive each event through apply. */
31
- replay?(chatId: string, events: readonly ChatEvent[]): void;
43
+ replay?(chatId: string, events: readonly ChatThreadEvent[]): void;
32
44
  /* What a chat is doing, for a thread nobody in this window has open. */
33
- status(chatId: string, info: ChatInfo): void;
45
+ status(chatId: string, info: ChatThreadInfo): void;
34
46
  bookmarks(chatId: string, bookmarks: ChatBookmark[]): void;
35
47
  visuals(chatId: string, visuals: ChatVisual[]): void;
36
48
  forget(chatId: string): void;
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { ProviderPlatform } from '@adecore/agent-contracts';
7
7
  import type { AccountRule } from './host';
8
- import { useChatHost, type ChatHost, type CommandLook, type ComposerStatusItem } from './host';
8
+ import { useChatHost, type ChatHost, type CommandLook, type ComposerStatusItem, type UnknownItemWords } from './host';
9
9
  import { referablesOfChats, type Referables } from './references';
10
10
 
11
11
  export function useHostCodeMode(): 'light' | 'dark' {
@@ -32,6 +32,14 @@ export function useHostExtraPrompts(...args: Parameters<ChatHost['prompts']['use
32
32
  return useChatHost().prompts.useExtra(...args);
33
33
  }
34
34
 
35
+ const useNoUnknownItemWords = (): UnknownItemWords | null => null;
36
+
37
+ export function useHostUnknownItemWords(): UnknownItemWords | null {
38
+ const useWords = useChatHost().useUnknownItemWords ?? useNoUnknownItemWords;
39
+
40
+ return useWords();
41
+ }
42
+
35
43
  export function useHostStreaming(): ReturnType<ChatHost['useStreaming']> {
36
44
  return useChatHost().useStreaming();
37
45
  }
package/src/host/host.ts CHANGED
@@ -4,7 +4,6 @@ import type {
4
4
  ChatCheckpointDiff,
5
5
  ChatConfigurePayload,
6
6
  ChatGoalAction,
7
- ChatItem,
8
7
  ChatSubagentItem,
9
8
  ChatUiChoicePayload,
10
9
  ChatUiQueryPayload,
@@ -32,6 +31,7 @@ import {
32
31
  type RefObject
33
32
  } from 'react';
34
33
  import type { Highlighter, ThemeRegistration } from 'shiki';
34
+ import type { ChatThreadItem } from '../chat-sink';
35
35
  import { PlainTextarea } from './PlainTextarea';
36
36
  import type { HostPrompt, PromptAction, PromptViewProps } from './prompts';
37
37
  import type { ReferableKind, Referables } from './references';
@@ -140,7 +140,7 @@ export interface TimelineFindOptions {
140
140
  scroller: RefObject<HTMLDivElement | null>;
141
141
  enabled: boolean;
142
142
  rows: readonly TimelineRow[];
143
- structure: Readonly<Record<string, ChatItem>> | undefined;
143
+ structure: Readonly<Record<string, ChatThreadItem>> | undefined;
144
144
  order: readonly string[] | undefined;
145
145
  /* The first row on screen, where a new search starts looking. */
146
146
  firstRowInView(): number;
@@ -464,6 +464,15 @@ export interface AgentMark {
464
464
  fillRule?: 'nonzero' | 'evenodd';
465
465
  }
466
466
 
467
+ /* The words of the row an item of a newer host gets, such as naming the app a person updates. */
468
+ export interface UnknownItemWords {
469
+ /* For an item that only shows something. */
470
+ readonly item: string;
471
+
472
+ /* For an approval or question that still waits, which this version never answers. */
473
+ readonly request: string;
474
+ }
475
+
467
476
  export interface ChatHost {
468
477
  /*
469
478
  * The marks of the kinds the app adds, and any it draws differently. Every place the shared UI draws an agent's
@@ -663,6 +672,8 @@ export interface ChatHost {
663
672
  useResumeAtReset(scopeId: string): boolean;
664
673
  /* The words an empty composer opens with, before the keys it hints at; null keeps the chat's own. */
665
674
  useComposerPlaceholder(scopeId: string, chatId: string): string | null;
675
+ /* What the row of an item this version cannot read says, in the app's words; left out, or null, the shared ones. */
676
+ useUnknownItemWords?(): UnknownItemWords | null;
666
677
  /* The app's own control in the composer's row, after the pickers; null draws none. */
667
678
  ComposerSlot: ComponentType<ComposerSlotProps> | null;
668
679
  /* The app's own bar at the top of the composer, inside its card, such as a switch between chats of one thing; left out, or a slot that renders nothing, draws none. */
@@ -2,18 +2,18 @@ import type {
2
2
  ChatApprovalItem,
3
3
  ChatAssistantItem,
4
4
  ChatCheckpointDiff,
5
- ChatItem,
6
5
  ChatNoteMessage,
7
6
  ChatQuestionItem,
8
7
  ChatSubagentItem,
9
8
  ChatThinkingItem,
10
9
  ChatToolItem,
11
- ChatTurnItem,
10
+ ChatUnknownItem,
12
11
  ChatUserItem,
13
12
  ChatVisual,
14
13
  ChatWorkflow,
15
14
  ModelSelection
16
15
  } from '@adecore/agent-contracts';
16
+ import type { ChatThreadItem, ChatThreadTurn } from '../chat-sink';
17
17
  import type { CommandLook, CommandLookSent, ThreadCard, ToolLook } from './host';
18
18
 
19
19
  /* A look of the host's own: a program in a shell call, or an MCP server. */
@@ -23,7 +23,7 @@ export type Look = CommandLook | ToolLook;
23
23
  export interface SubagentBranch {
24
24
  id: string;
25
25
  item: ChatSubagentItem;
26
- children: ChatItem[];
26
+ children: ChatThreadItem[];
27
27
  nested: SubagentBranch[];
28
28
  expanded: boolean;
29
29
  }
@@ -41,7 +41,7 @@ export interface BaseMoved {
41
41
  */
42
42
  export type TimelineRow =
43
43
  | { kind: 'user'; id: string; item: ChatUserItem }
44
- | { kind: 'turn-start'; id: string; turn: ChatTurnItem; label: string }
44
+ | { kind: 'turn-start'; id: string; turn: ChatThreadTurn; label: string }
45
45
  | { kind: 'assistant'; id: string; item: ChatAssistantItem }
46
46
  // A subagent's `SubagentHandback` call, drawn as the report it carries rather than as a tool call.
47
47
  | { kind: 'report'; id: string; text: string }
@@ -63,6 +63,8 @@ export type TimelineRow =
63
63
  // A message this chat's agent sent another node with a command of a look, drawn as said instead of as its call.
64
64
  | { kind: 'sent'; id: string; tool: ChatToolItem; sent: CommandLookSent }
65
65
  | { kind: 'compaction'; id: string; preTokens: number | null; postTokens?: number }
66
+ // An item of a newer host this version cannot read, one muted line with nothing to act on; `waits` for a request that still does.
67
+ | { kind: 'unknown'; id: string; item: ChatUnknownItem; waits: boolean }
66
68
  // The turn below ran on another model or effort than the turn before it.
67
69
  | { kind: 'selection-switch'; id: string; from: ModelSelection; to: ModelSelection }
68
70
  | {
@@ -76,7 +78,7 @@ export type TimelineRow =
76
78
  // Set when `diff` holds back the diffs past its first few, which the host answers whole.
77
79
  heldBack?: boolean;
78
80
  }
79
- | { kind: 'turn-fold'; id: string; turn: ChatTurnItem; label: string; work: string[]; hiddenCount: number; expanded: boolean; expandable: boolean }
81
+ | { kind: 'turn-fold'; id: string; turn: ChatThreadTurn; label: string; work: string[]; hiddenCount: number; expanded: boolean; expandable: boolean }
80
82
  | { kind: 'forks'; id: string; turnId: string }
81
83
  | { kind: 'working'; id: string; startedAt: number; tool?: ChatToolItem }
82
84
  // A card of the app's own (`thread-cards.ts`), never derived from an item.