@adecore/agents-react 0.65.1 → 0.66.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 (122) 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/en/agent-usage.d.ts +0 -2
  55. package/dist/locales/en/agent-usage.js +0 -2
  56. package/dist/locales/nl/agent-chat.d.ts +16 -0
  57. package/dist/locales/nl/agent-chat.js +17 -1
  58. package/dist/locales/nl/agent-usage.d.ts +0 -2
  59. package/dist/locales/nl/agent-usage.js +0 -2
  60. package/dist/port-transport.d.ts +10 -1
  61. package/dist/port-transport.js +14 -3
  62. package/dist/state/chats.d.ts +17 -15
  63. package/dist/state/chats.js +7 -0
  64. package/dist/state/index.d.ts +1 -1
  65. package/dist/state/usage.d.ts +3 -2
  66. package/dist/state/usage.js +34 -3
  67. package/dist/transport.d.ts +3 -2
  68. package/dist/usage/limit-groups.js +2 -4
  69. package/package.json +9 -9
  70. package/src/chat/activity.ts +19 -6
  71. package/src/chat/forks.ts +3 -3
  72. package/src/chat/logic/bookmarks.ts +3 -2
  73. package/src/chat/logic/continue-after-stop.ts +3 -2
  74. package/src/chat/logic/fork.ts +8 -7
  75. package/src/chat/logic/goal.ts +13 -4
  76. package/src/chat/logic/handback.ts +2 -3
  77. package/src/chat/logic/limit.ts +7 -2
  78. package/src/chat/logic/resume-compaction.ts +7 -6
  79. package/src/chat/logic/scrubber.ts +4 -3
  80. package/src/chat/logic/timeline-target.ts +4 -3
  81. package/src/chat/logic/timeline.ts +22 -16
  82. package/src/chat/pending-prompts.ts +3 -2
  83. package/src/chat/recent-messages.ts +5 -6
  84. package/src/chat/runtime-modes.ts +7 -2
  85. package/src/chat/subagent-conversation.ts +12 -9
  86. package/src/chat/subagent-list.ts +4 -3
  87. package/src/chat/subagent-view.ts +4 -3
  88. package/src/chat/ui/ChatActivity.tsx +11 -7
  89. package/src/chat/ui/Composer.tsx +3 -2
  90. package/src/chat/ui/GoalDock.tsx +6 -5
  91. package/src/chat/ui/LimitState.tsx +5 -5
  92. package/src/chat/ui/RunSettings.tsx +17 -9
  93. package/src/chat/ui/composer/ComposerControls.tsx +3 -2
  94. package/src/chat/ui/composer/use-chat-controls.ts +3 -2
  95. package/src/chat/ui/composer/use-compaction-offer.ts +4 -3
  96. package/src/chat/ui/composer/use-composer-menus.ts +3 -2
  97. package/src/chat/ui/composer/use-continuable-turn.ts +3 -3
  98. package/src/chat/ui/composer/use-effort-stepper.ts +3 -2
  99. package/src/chat/ui/reply-context.ts +2 -2
  100. package/src/chat/ui/rows/MessageRows.tsx +17 -1
  101. package/src/chat/ui/rows/Rows.tsx +3 -0
  102. package/src/chat/ui/rows/SubagentRow.tsx +5 -4
  103. package/src/chat/ui/rows/WorkRows.tsx +3 -2
  104. package/src/chat/ui/thread-references.ts +3 -3
  105. package/src/chat/waiting-on.ts +8 -7
  106. package/src/chat/workflow-list.ts +3 -2
  107. package/src/chat-client.ts +3 -2
  108. package/src/chat-sink.ts +21 -9
  109. package/src/host/host-hooks.ts +9 -1
  110. package/src/host/host.ts +13 -2
  111. package/src/host/timeline-row.ts +7 -5
  112. package/src/index.ts +2 -1
  113. package/src/locales/en/agent-chat.ts +17 -1
  114. package/src/locales/en/agent-usage.ts +0 -2
  115. package/src/locales/nl/agent-chat.ts +17 -1
  116. package/src/locales/nl/agent-usage.ts +0 -2
  117. package/src/port-transport.ts +20 -3
  118. package/src/state/chats.ts +34 -35
  119. package/src/state/index.ts +1 -1
  120. package/src/state/usage.ts +45 -5
  121. package/src/transport.ts +4 -2
  122. package/src/usage/limit-groups.ts +2 -2
@@ -1,5 +1,6 @@
1
- import type { AgentKind, ChatForkPayload, ChatInfo, ChatItem, ChatTurnItem, ModelSelection, ProviderInfo } from '@adecore/agent-contracts';
1
+ import type { AgentKind, ChatForkPayload, ModelSelection, ProviderInfo } from '@adecore/agent-contracts';
2
2
  import i18next from 'i18next';
3
+ import type { ChatThreadInfo, ChatThreadItem, ChatThreadTurn } from '../../chat-sink';
3
4
  import type { TimelineRow } from '../../host/timeline-row';
4
5
 
5
6
  interface HostProviders {
@@ -24,7 +25,7 @@ interface ForkPoint {
24
25
  prompt: string | null;
25
26
  }
26
27
 
27
- function turnsOf(items: Record<string, ChatItem>, order: readonly string[]): ChatTurnItem[] {
28
+ function turnsOf(items: Record<string, ChatThreadItem>, order: readonly string[]): ChatThreadTurn[] {
28
29
  return order.flatMap((id) => {
29
30
  const item = items[id];
30
31
 
@@ -37,7 +38,7 @@ function turnsOf(items: Record<string, ChatItem>, order: readonly string[]): Cha
37
38
  * or any turn in the chat, is a transcript that grows while it would be copied. Until the host named its
38
39
  * CLIs, no CLI is known to fork.
39
40
  */
40
- export function forkRefusal(info: ChatInfo | null, turn: ChatItem | undefined, host: HostProviders): string | null {
41
+ export function forkRefusal(info: ChatThreadInfo | null, turn: ChatThreadItem | undefined, host: HostProviders): string | null {
41
42
  if (info === null || turn?.kind !== 'turn') {
42
43
  return i18next.t('agent-chat:fork.refusal.notInConversation');
43
44
  }
@@ -75,7 +76,7 @@ export function summaryRefusal(state: { busy: boolean; originalPresent: boolean
75
76
  return null;
76
77
  }
77
78
 
78
- export function forkIdsAfter(infos: Iterable<ChatInfo>, chatId: string, turnId: string): string[] {
79
+ export function forkIdsAfter(infos: Iterable<ChatThreadInfo>, chatId: string, turnId: string): string[] {
79
80
  const ids: string[] = [];
80
81
 
81
82
  for (const info of infos) {
@@ -87,7 +88,7 @@ export function forkIdsAfter(infos: Iterable<ChatInfo>, chatId: string, turnId:
87
88
  return ids;
88
89
  }
89
90
 
90
- export function forkedTurnIds(infos: Iterable<ChatInfo>, chatId: string): Set<string> {
91
+ export function forkedTurnIds(infos: Iterable<ChatThreadInfo>, chatId: string): Set<string> {
91
92
  const turns = new Set<string>();
92
93
 
93
94
  for (const info of infos) {
@@ -100,11 +101,11 @@ export function forkedTurnIds(infos: Iterable<ChatInfo>, chatId: string): Set<st
100
101
  }
101
102
 
102
103
  /* The last turn that ended, which is where a fork from the node's menu goes on after. */
103
- export function lastSettledTurn(items: Record<string, ChatItem>, order: readonly string[]): string | null {
104
+ export function lastSettledTurn(items: Record<string, ChatThreadItem>, order: readonly string[]): string | null {
104
105
  return turnsOf(items, order).findLast((turn) => turn.state !== 'running')?.id ?? null;
105
106
  }
106
107
 
107
- export function forkPointOf(items: Record<string, ChatItem>, order: readonly string[], turnId: string, whole: boolean): ForkPoint | null {
108
+ export function forkPointOf(items: Record<string, ChatThreadItem>, order: readonly string[], turnId: string, whole: boolean): ForkPoint | null {
108
109
  const turns = turnsOf(items, order);
109
110
  const index = turns.findIndex((turn) => turn.id === turnId);
110
111
  const turn = turns[index];
@@ -1,7 +1,15 @@
1
- import type { ChatGoal, ChatGoalAction, ChatInfo, ProviderCapabilities } from '@adecore/agent-contracts';
1
+ import { ChatGoalStatusSchema, type ChatGoalAction, type ChatGoalStatus, type ProviderCapabilities } from '@adecore/agent-contracts';
2
+ import type { ChatThreadInfo } from '../../chat-sink';
3
+
4
+ type Goal = NonNullable<ChatThreadInfo['goal']>;
5
+
6
+ /* Whether this version knows the goal's state, so it can word it and say what may be done to it. */
7
+ export function knownGoalStatus(goal: Goal): goal is Goal & { status: ChatGoalStatus } {
8
+ return (ChatGoalStatusSchema.options as readonly string[]).includes(goal.status);
9
+ }
2
10
 
3
11
  interface GoalView {
4
- goal: ChatGoal;
12
+ goal: Goal;
5
13
  // What a person may do to it from the row; empty where the CLI or the host offers nothing.
6
14
  actions: ChatGoalAction[];
7
15
  }
@@ -11,7 +19,7 @@ interface GoalView {
11
19
  * clears it at any time; one that only reads `/goal` clears it with a turn of its own, so only between
12
20
  * turns, and a goal it already met clears itself.
13
21
  */
14
- export function goalView(info: Pick<ChatInfo, 'goal' | 'activeTurnId'>, goals: ProviderCapabilities['goals'], canAct: boolean): GoalView | null {
22
+ export function goalView(info: Pick<ChatThreadInfo, 'goal' | 'activeTurnId'>, goals: ProviderCapabilities['goals'], canAct: boolean): GoalView | null {
15
23
  const goal = info.goal;
16
24
 
17
25
  if (goal === undefined) {
@@ -28,9 +36,10 @@ export function goalView(info: Pick<ChatInfo, 'goal' | 'activeTurnId'>, goals: P
28
36
 
29
37
  const actions: ChatGoalAction[] = [];
30
38
 
39
+ // A state of a newer host may mean either, so only a clear is offered for it.
31
40
  if (goal.status === 'active') {
32
41
  actions.push('pause');
33
- } else if (goal.status !== 'complete') {
42
+ } else if (knownGoalStatus(goal) && goal.status !== 'complete') {
34
43
  actions.push('resume');
35
44
  }
36
45
 
@@ -1,7 +1,5 @@
1
- import type { ChatItem } from '@adecore/agent-contracts';
2
-
3
1
  /* The report a `SubagentHandback` call carries in `input.message` (Claude Code 2.1.273), or null for any other item. */
4
- export function handbackReportOf(item: ChatItem): string | null {
2
+ export function handbackReportOf(item: ChatThreadItem): string | null {
5
3
  if (item.kind !== 'tool' || item.name !== 'SubagentHandback' || typeof item.input !== 'object' || item.input === null) {
6
4
  return null;
7
5
  }
@@ -10,3 +8,4 @@ export function handbackReportOf(item: ChatItem): string | null {
10
8
 
11
9
  return typeof message === 'string' && message.trim() !== '' ? message : null;
12
10
  }
11
+ import type { ChatThreadItem } from '../../chat-sink';
@@ -1,6 +1,6 @@
1
- import type { ChatInfo } from '@adecore/agent-contracts';
2
1
  import { formatMoment } from '@adecore/ui/format';
3
2
  import i18next from 'i18next';
3
+ import type { ChatThreadInfo } from '../../chat-sink';
4
4
 
5
5
  interface LimitView {
6
6
  /* The state in a word or two with its time, for a pill in a header. */
@@ -14,7 +14,7 @@ interface LimitView {
14
14
  * What a chat that stopped on a limit says about it, from its info alone, so a header that never holds
15
15
  * the thread says the same as the chat. Null while the last turn stopped on nothing, or a turn runs.
16
16
  */
17
- export function limitView(info: Pick<ChatInfo, 'limit' | 'resumeAt' | 'activeTurnId'>, now: number): LimitView | null {
17
+ export function limitView(info: Pick<ChatThreadInfo, 'limit' | 'resumeAt' | 'activeTurnId'>, now: number): LimitView | null {
18
18
  const limit = info.limit;
19
19
 
20
20
  if (limit === undefined || info.activeTurnId !== null) {
@@ -31,6 +31,11 @@ export function limitView(info: Pick<ChatInfo, 'limit' | 'resumeAt' | 'activeTur
31
31
  };
32
32
  }
33
33
 
34
+ // A kind of a newer host says only that the turn stopped, never which limit it was.
35
+ if (limit.kind !== 'usage') {
36
+ return { pill: i18next.t('agent-chat:limit.other.pill'), title: i18next.t('agent-chat:limit.other.title'), detail: null };
37
+ }
38
+
34
39
  const title = i18next.t('agent-chat:limit.usage.title');
35
40
 
36
41
  if (resumes !== null) {
@@ -1,4 +1,5 @@
1
- import type { ChatInfo, ChatItem, ProviderCapabilities } from '@adecore/agent-contracts';
1
+ import type { ProviderCapabilities } from '@adecore/agent-contracts';
2
+ import type { ChatThreadInfo, ChatThreadItem } from '../../chat-sink';
2
3
 
3
4
  /*
4
5
  * An absolute count, not a share of the window: reading a thread again costs per token, so 100k in a
@@ -19,18 +20,18 @@ export interface ResumeCompactionOffer {
19
20
  reason: ResumeCompactionReason;
20
21
  }
21
22
 
22
- type Turn = Extract<ChatItem, { kind: 'turn' }>;
23
+ type Turn = Extract<ChatThreadItem, { kind: 'turn' }>;
23
24
 
24
25
  interface OfferInput {
25
- info: ChatInfo;
26
+ info: ChatThreadInfo;
26
27
  /* Absent until the host answered `provider.list`. */
27
28
  compaction: ProviderCapabilities['compaction'] | undefined;
28
- items: readonly ChatItem[];
29
+ items: readonly ChatThreadItem[];
29
30
  dismissedTurnId: string | null;
30
31
  }
31
32
 
32
33
  /* The newest turn by when it started, so a thread that arrives out of order still names the turn that ran last. */
33
- function lastTurn(items: readonly ChatItem[]): Turn | null {
34
+ function lastTurn(items: readonly ChatThreadItem[]): Turn | null {
34
35
  let last: Turn | null = null;
35
36
 
36
37
  for (const item of items) {
@@ -72,7 +73,7 @@ function offerableTurn({ info, compaction, items, dismissedTurnId }: OfferInput)
72
73
  }
73
74
 
74
75
  /* A silence longer than any cache lives stands in for an expiry from a CLI that names none. */
75
- function dueAtOf(info: ChatInfo, endedAt: number): number {
76
+ function dueAtOf(info: ChatThreadInfo, endedAt: number): number {
76
77
  return info.usage.cacheExpiresAt ?? endedAt + RESUME_COMPACTION_IDLE_MS;
77
78
  }
78
79
 
@@ -1,4 +1,5 @@
1
- import type { ChatBookmark, ChatItem } from '@adecore/agent-contracts';
1
+ import type { ChatBookmark } from '@adecore/agent-contracts';
2
+ import type { ChatThreadItem } from '../../chat-sink';
2
3
  import { type TimelineRow } from '../../host/timeline-row';
3
4
  import { DEFAULT_READING_WIDTH, readingMeasure } from '../reading-width';
4
5
  import { agentTurnLabel } from './timeline';
@@ -46,7 +47,7 @@ const WIDTH_WAKE_PX = 5;
46
47
  export const EARLIER_ROW = -1;
47
48
 
48
49
  /* A message before the rows this client holds, as the outline (`outlineItems`) has it; its row id is the one the thread will draw it with. */
49
- function earlierTick(item: ChatItem, bookmarks: ReadonlyMap<string, ChatBookmark>): ScrubberTick | null {
50
+ function earlierTick(item: ChatThreadItem, bookmarks: ReadonlyMap<string, ChatBookmark>): ScrubberTick | null {
50
51
  const bookmark = bookmarks.get(item.id) ?? null;
51
52
  const rowIndex = EARLIER_ROW;
52
53
 
@@ -74,7 +75,7 @@ function earlierTick(item: ChatItem, bookmarks: ReadonlyMap<string, ChatBookmark
74
75
  export function ticksOf(
75
76
  rows: readonly TimelineRow[],
76
77
  marks: ReadonlyMap<string, ChatBookmark> = new Map(),
77
- earlier: readonly ChatItem[] = [],
78
+ earlier: readonly ChatThreadItem[] = [],
78
79
  bookmarks: readonly ChatBookmark[] = []
79
80
  ): ScrubberTick[] {
80
81
  const byItem = new Map(bookmarks.map((bookmark) => [bookmark.itemId, bookmark]));
@@ -1,5 +1,6 @@
1
- import type { ChatItem, ChatUiChoiceOrigin } from '@adecore/agent-contracts';
1
+ import type { ChatUiChoiceOrigin } from '@adecore/agent-contracts';
2
2
  import { selectionWithin } from '@adecore/ui';
3
+ import type { ChatThreadItem } from '../../chat-sink';
3
4
  import type { FileRef } from '../../host/host';
4
5
  import type { TimelineRow } from '../../host/timeline-row';
5
6
 
@@ -22,7 +23,7 @@ export const EMPTY_TARGET: TimelineTarget = { selection: '', row: null, code: nu
22
23
  * The rows with the text a reply or a thought holds now. Rows are derived from the structure of a
23
24
  * thread, which a delta leaves alone, so a row still carries the text it was derived with.
24
25
  */
25
- export function withCurrentText(rows: TimelineRow[], items: Record<string, ChatItem> | undefined): TimelineRow[] {
26
+ export function withCurrentText(rows: TimelineRow[], items: Record<string, ChatThreadItem> | undefined): TimelineRow[] {
26
27
  if (!items) {
27
28
  return rows;
28
29
  }
@@ -85,7 +86,7 @@ type UiReplyJump = { kind: 'missing' | 'earlier' } | { kind: 'turn'; turnId: str
85
86
  export function uiReplyJump(
86
87
  target: UiReplyTarget,
87
88
  rows: readonly TimelineRow[],
88
- items: Record<string, ChatItem> | undefined,
89
+ items: Record<string, ChatThreadItem> | undefined,
89
90
  expandedTurns: ReadonlySet<string>,
90
91
  hasEarlier: boolean
91
92
  ): UiReplyJump {
@@ -1,9 +1,11 @@
1
- import type { ChatItem, ChatSubagentItem, ChatToolItem, ChatTurnItem, ModelSelection } from '@adecore/agent-contracts';
1
+ import type { ChatSubagentItem, ChatToolItem, ModelSelection } from '@adecore/agent-contracts';
2
2
  import { abortedByMachine } from '@adecore/agent-contracts';
3
3
  import { formatElapsedShort } from '@adecore/ui/format';
4
4
  import i18next from 'i18next';
5
+ import type { ChatThreadItem, ChatThreadTurn } from '../../chat-sink';
5
6
  import type { CommandLook, ToolLook } from '../../host/host';
6
7
  import type { Look, SubagentBranch, TimelineRow } from '../../host/timeline-row';
8
+ import { waitsOnTheHost } from '../../state/chats';
7
9
  import { lookKey, lookRunOf, sentMessageOf } from './command-looks';
8
10
  import { isImageGeneration } from './generated-image';
9
11
  import { handbackReportOf } from './handback';
@@ -192,7 +194,7 @@ export function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly C
192
194
  * What a turn nobody asked for is about. The CLI wakes the agent when a background subagent settles
193
195
  * and hands over its summary; without one all that is known is that the agent went on by itself.
194
196
  */
195
- export function agentTurnLabel(turn: ChatTurnItem): string {
197
+ export function agentTurnLabel(turn: ChatThreadTurn): string {
196
198
  const about = (what: string): string => (turn.label ? i18next.t('agent-chat:turn.about', { what, label: turn.label }) : what);
197
199
 
198
200
  // A turn the machine opened with the results of tasks this chat gave; the label is their titles.
@@ -217,7 +219,7 @@ export function agentTurnLabel(turn: ChatTurnItem): string {
217
219
  }
218
220
 
219
221
  /* The items of the turn tell a turn a person stopped from one the machine ended after a restart. */
220
- export function turnLabel(turn: ChatTurnItem, items: readonly ChatItem[] = []): string {
222
+ export function turnLabel(turn: ChatThreadTurn, items: readonly ChatThreadItem[] = []): string {
221
223
  const duration = formatElapsedShort((turn.endedAt ?? turn.createdAt) - turn.createdAt);
222
224
 
223
225
  switch (turn.state) {
@@ -231,14 +233,14 @@ export function turnLabel(turn: ChatTurnItem, items: readonly ChatItem[] = []):
231
233
  }
232
234
 
233
235
  // A subagent's own work, and an agent it opened, belong to its row, not to the thread; an old record has no row for it.
234
- function parentOf(item: ChatItem): string | null {
236
+ function parentOf(item: ChatThreadItem): string | null {
235
237
  return item.kind === 'tool' || item.kind === 'assistant' || item.kind === 'subagent' ? (item.parentToolUseId ?? null) : null;
236
238
  }
237
239
 
238
240
  // Deeper than the CLI forwards any call; it also ends a chain of rows that would name each other.
239
241
  const MAX_NESTING = 8;
240
242
 
241
- function branchOf(item: ChatSubagentItem, options: TimelineOptions, children: Map<string, ChatItem[]>, depth = 0): SubagentBranch {
243
+ function branchOf(item: ChatSubagentItem, options: TimelineOptions, children: Map<string, ChatThreadItem[]>, depth = 0): SubagentBranch {
242
244
  const own = children.get(item.toolUseId) ?? [];
243
245
 
244
246
  return {
@@ -284,8 +286,8 @@ export function findSubagentBranch(rows: readonly TimelineRow[], toolUseId: stri
284
286
  }
285
287
 
286
288
  /* What each subagent did, keyed by the call that spawned it, in the order it happened. */
287
- function groupChildren(items: ChatItem[]): Map<string, ChatItem[]> {
288
- const children = new Map<string, ChatItem[]>();
289
+ function groupChildren(items: ChatThreadItem[]): Map<string, ChatThreadItem[]> {
290
+ const children = new Map<string, ChatThreadItem[]>();
289
291
 
290
292
  for (const item of items) {
291
293
  const parent = parentOf(item);
@@ -334,7 +336,7 @@ function isImageRow(row: TimelineRow): boolean {
334
336
  return (row.kind === 'work' || row.kind === 'work-live') && isImageGeneration(row.tool);
335
337
  }
336
338
 
337
- function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map<string, ChatItem[]>): TimelineRow[] {
339
+ function rowsForItems(items: ChatThreadItem[], options: TimelineOptions, children: Map<string, ChatThreadItem[]>): TimelineRow[] {
338
340
  const rows: TimelineRow[] = [];
339
341
  const tools: ChatToolItem[] = [];
340
342
 
@@ -437,6 +439,10 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
437
439
  ...(item.postTokens === undefined ? {} : { postTokens: item.postTokens })
438
440
  });
439
441
 
442
+ break;
443
+ case 'unknown':
444
+ rows.push({ kind: 'unknown', id: item.id, item, waits: waitsOnTheHost(item) });
445
+
440
446
  break;
441
447
  case 'turn':
442
448
  break;
@@ -449,7 +455,7 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
449
455
  }
450
456
 
451
457
  /* The card of a settled turn: the checkpoint diff when the host took one, else what the tool calls carry. */
452
- function changedFilesRow(turn: ChatTurnItem, items: ChatItem[]): TimelineRow | null {
458
+ function changedFilesRow(turn: ChatThreadTurn, items: ChatThreadItem[]): TimelineRow | null {
453
459
  const edits = items.filter(
454
460
  (item): item is ChatToolItem => item.kind === 'tool' && item.state === 'done' && isFileChange(item.name) && hasFileChanges(item)
455
461
  );
@@ -516,7 +522,7 @@ function lastAssistantRow(rows: TimelineRow[]): TimelineRow | null {
516
522
  * the thought's own row and that call, since the thought still shows there, or when a newer thought
517
523
  * came after the call.
518
524
  */
519
- function withLiveThought(rows: TimelineRow[], items: readonly ChatItem[]): TimelineRow[] {
525
+ function withLiveThought(rows: TimelineRow[], items: readonly ChatThreadItem[]): TimelineRow[] {
520
526
  const thoughtAt = items.findLastIndex((item) => item.kind === 'thinking' && parentOf(item) === null);
521
527
  const thought = items[thoughtAt];
522
528
 
@@ -540,13 +546,13 @@ function withLiveThought(rows: TimelineRow[], items: readonly ChatItem[]): Timel
540
546
 
541
547
  interface TurnChunk {
542
548
  turnId: string | null;
543
- items: ChatItem[];
549
+ items: ChatThreadItem[];
544
550
  }
545
551
 
546
552
  /* Items grouped by turn, in order of first appearance; runs of turnless items keep their place. */
547
- function chunksByTurn(items: ChatItem[]): TurnChunk[] {
553
+ function chunksByTurn(items: ChatThreadItem[]): TurnChunk[] {
548
554
  const chunks: TurnChunk[] = [];
549
- const byTurn = new Map<string, ChatItem[]>();
555
+ const byTurn = new Map<string, ChatThreadItem[]>();
550
556
 
551
557
  for (const item of items) {
552
558
  if (item.turnId === null) {
@@ -575,7 +581,7 @@ function chunksByTurn(items: ChatItem[]): TurnChunk[] {
575
581
  return chunks;
576
582
  }
577
583
 
578
- function opensUnderItsMessages(turn: ChatTurnItem, rows: readonly TimelineRow[]): boolean {
584
+ function opensUnderItsMessages(turn: ChatThreadTurn, rows: readonly TimelineRow[]): boolean {
579
585
  const from = turn.messageFrom ?? [];
580
586
 
581
587
  if (from.length === 0) {
@@ -598,7 +604,7 @@ function opensUnderItsMessages(turn: ChatTurnItem, rows: readonly TimelineRow[])
598
604
  }
599
605
 
600
606
  /* The whole thread as rows; items without a turn (older records) are shown as they are. */
601
- export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions): TimelineRow[] {
607
+ export function deriveTimelineRows(items: ChatThreadItem[], options: TimelineOptions): TimelineRow[] {
602
608
  const rows: TimelineRow[] = [];
603
609
  const children = groupChildren(items);
604
610
  let selection: ModelSelection | null = null;
@@ -611,7 +617,7 @@ export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions):
611
617
  }
612
618
 
613
619
  const turnId = chunk.turnId;
614
- const turn = chunk.items.find((item): item is ChatTurnItem => item.kind === 'turn');
620
+ const turn = chunk.items.find((item): item is ChatThreadTurn => item.kind === 'turn');
615
621
  const conversation = chunk.items.filter((item) => item.kind !== 'turn');
616
622
 
617
623
  // A turn without a selection (older ones, or one the CLI started on its own) compares the next with the one before it.
@@ -1,4 +1,5 @@
1
- import { CHAT_REQUEST_LIMITS, type ChatInfo } from '@adecore/agent-contracts';
1
+ import { CHAT_REQUEST_LIMITS } from '@adecore/agent-contracts';
2
+ import type { ChatThreadInfo } from '../chat-sink';
2
3
  import type { PendingPrompt } from '../host/prompts';
3
4
  import type { PromptSubject } from '../host/prompts';
4
5
  import type { ChatScope } from '../scope';
@@ -7,7 +8,7 @@ import { subagentTitle } from './subagent-list';
7
8
 
8
9
  type ChatPromptSubject = Extract<PromptSubject, { kind: 'chat' }>;
9
10
 
10
- function stillWaiting(item: PendingPrompt, info: ChatInfo): boolean {
11
+ function stillWaiting(item: PendingPrompt, info: ChatThreadInfo): boolean {
11
12
  return (
12
13
  info.status === 'needs-you' &&
13
14
  (info.requests === undefined ||
@@ -1,5 +1,3 @@
1
- import type { ChatItem } from '@adecore/agent-contracts';
2
-
3
1
  interface RecentChatMessage {
4
2
  role: 'user' | 'assistant';
5
3
  text: string;
@@ -18,9 +16,9 @@ function clipped(text: string): { text: string; truncated: boolean } {
18
16
  return text.length <= MAX_MESSAGE_CHARACTERS ? { text, truncated: false } : { text: `${text.slice(0, MAX_MESSAGE_CHARACTERS - 1)}…`, truncated: true };
19
17
  }
20
18
 
21
- type MessageItem = Extract<ChatItem, { kind: 'user' | 'assistant' }>;
19
+ type MessageItem = Extract<ChatThreadItem, { kind: 'user' | 'assistant' }>;
22
20
 
23
- function isMessage(item: ChatItem | undefined): item is MessageItem {
21
+ function isMessage(item: ChatThreadItem | undefined): item is MessageItem {
24
22
  return item !== undefined && (item.kind === 'user' || item.kind === 'assistant') && item.text.trim() !== '';
25
23
  }
26
24
 
@@ -51,7 +49,7 @@ function recentMessages(eligible: readonly MessageItem[], limit: number): Recent
51
49
  }
52
50
 
53
51
  /* A sub-agent's replies sit in the thread too, and belong to its own conversation rather than the chat's. */
54
- export function recentChatMessages(items: Record<string, ChatItem>, order: readonly string[], limit: number): RecentChatMessages {
52
+ export function recentChatMessages(items: Record<string, ChatThreadItem>, order: readonly string[], limit: number): RecentChatMessages {
55
53
  return recentMessages(
56
54
  order.map((id) => items[id]).filter((item): item is MessageItem => isMessage(item) && !(item.kind === 'assistant' && item.parentToolUseId)),
57
55
  limit
@@ -59,6 +57,7 @@ export function recentChatMessages(items: Record<string, ChatItem>, order: reado
59
57
  }
60
58
 
61
59
  /* Everything in a sub-agent's conversation is its own, so nothing is left out for being nested. */
62
- export function recentSubagentMessages(items: readonly ChatItem[], limit: number): RecentChatMessages {
60
+ export function recentSubagentMessages(items: readonly ChatThreadItem[], limit: number): RecentChatMessages {
63
61
  return recentMessages(items.filter(isMessage), limit);
64
62
  }
63
+ import type { ChatThreadItem } from '../chat-sink';
@@ -7,8 +7,13 @@ import i18next from 'i18next';
7
7
  */
8
8
  export const RUNTIME_MODES: readonly RuntimeMode[] = RuntimeModeSchema.options;
9
9
 
10
- export function runtimeModeLabel(mode: RuntimeMode): string {
11
- return i18next.t(`agent-chat:modes.${mode}.label`);
10
+ /* Whether this version knows a mode a host reports; a newer host's mode is shown as set there and never sent back as another. */
11
+ export function isKnownRuntimeMode(mode: string): mode is RuntimeMode {
12
+ return (RUNTIME_MODES as readonly string[]).includes(mode);
13
+ }
14
+
15
+ export function runtimeModeLabel(mode: string): string {
16
+ return isKnownRuntimeMode(mode) ? i18next.t(`agent-chat:modes.${mode}.label`) : i18next.t('agent-chat:modes.unknown.label');
12
17
  }
13
18
 
14
19
  export function runtimeModeHint(mode: RuntimeMode): string {
@@ -1,5 +1,7 @@
1
- import type { ChatApprovalItem, ChatItem, ChatQuestionItem, ChatSubagentResult } from '@adecore/agent-contracts';
1
+ import type { ChatApprovalItem, ChatQuestionItem, ChatSubagentResult } from '@adecore/agent-contracts';
2
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
2
3
  import i18next from 'i18next';
4
+ import type { ChatThreadItem } from '../chat-sink';
3
5
  import { isWaiting } from '../state/chats';
4
6
  import { errorCode, isConnectionError, type ChatTransport } from '../transport';
5
7
 
@@ -8,7 +10,7 @@ const SUBAGENT_PAGE = 60;
8
10
 
9
11
  export interface SubagentConversationState {
10
12
  status: 'loading' | 'ready' | 'failed';
11
- items: ChatItem[];
13
+ items: ChatThreadItem[];
12
14
  pending: Array<ChatApprovalItem | ChatQuestionItem>;
13
15
  source: ChatSubagentResult['source'] | null;
14
16
  context: NonNullable<ChatSubagentResult['context']> | null;
@@ -41,11 +43,11 @@ export const INITIAL_CONVERSATION: SubagentConversationState = {
41
43
  * happened than one page holds, so what is held is dropped for it rather than shown with a hole.
42
44
  */
43
45
  export function mergeNewest(
44
- current: ChatItem[],
46
+ current: ChatThreadItem[],
45
47
  currentCursor: string | null,
46
- page: ChatItem[],
48
+ page: ChatThreadItem[],
47
49
  pageCursor: string | null
48
- ): { items: ChatItem[]; cursor: string | null } {
50
+ ): { items: ChatThreadItem[]; cursor: string | null } {
49
51
  const known = new Map(current.map((item, index) => [item.id, index]));
50
52
 
51
53
  if (current.length > 0 && page.length > 0 && !page.some((item) => known.has(item.id))) {
@@ -67,7 +69,7 @@ export function mergeNewest(
67
69
  return { items, cursor: current.length === 0 ? pageCursor : currentCursor };
68
70
  }
69
71
 
70
- function pendingOf(items: readonly ChatItem[]): Array<ChatApprovalItem | ChatQuestionItem> {
72
+ function pendingOf(items: readonly ChatThreadItem[]): Array<ChatApprovalItem | ChatQuestionItem> {
71
73
  return items.filter(isWaiting);
72
74
  }
73
75
 
@@ -151,7 +153,7 @@ export class SubagentConversation {
151
153
  try {
152
154
  const page = await this.ask({ cursor, limit: SUBAGENT_PAGE });
153
155
  const items = [...page.items, ...this.state.items];
154
- this.set({ items, pending: page.pending ?? pendingOf(items), cursor: page.history.cursor, live: page.live, loadingEarlier: false });
156
+ this.set({ items, pending: pendingOf(page.pending ?? items), cursor: page.history.cursor, live: page.live, loadingEarlier: false });
155
157
  } catch (error) {
156
158
  if (errorCode(error) === 'history-expired') {
157
159
  // The record was written again under this panel; what it holds now is the only truth.
@@ -194,7 +196,8 @@ export class SubagentConversation {
194
196
  this.set({
195
197
  status: 'ready',
196
198
  items: merged.items,
197
- pending: page.pending ?? pendingOf(merged.items),
199
+ // A request this version cannot read is never answered from here; its row in the thread says where to.
200
+ pending: pendingOf(page.pending ?? merged.items),
198
201
  cursor: merged.cursor,
199
202
  live: page.live,
200
203
  source: page.source,
@@ -212,7 +215,7 @@ export class SubagentConversation {
212
215
  }
213
216
  }
214
217
 
215
- private ask(extra: { cursor?: string; limit: number; watch?: boolean }): Promise<ChatSubagentResult> {
218
+ private ask(extra: { cursor?: string; limit: number; watch?: boolean }): Promise<Tolerant<ChatSubagentResult>> {
216
219
  return this.transport.request('chat.subagent', { chatId: this.chatId, toolUseId: this.toolUseId, ...extra });
217
220
  }
218
221
 
@@ -1,7 +1,8 @@
1
- import { activeSubagents, HOST_TASK_ORIGIN, type ChatInfo, type ChatItem, type ChatSubagentItem } from '@adecore/agent-contracts';
1
+ import { activeSubagents, HOST_TASK_ORIGIN, type ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  import { formatMoment, formatElapsedShort } from '@adecore/ui/format';
3
3
  import i18next from 'i18next';
4
4
  import type { StatusWord } from '../agents/status-look';
5
+ import type { ChatThreadInfo, ChatThreadItem } from '../chat-sink';
5
6
  import type { SubagentTask } from '../host/host';
6
7
 
7
8
  export function subagentTitle(item: ChatSubagentItem): string {
@@ -24,7 +25,7 @@ export function statusWordOf(item: ChatSubagentItem, task: SubagentTask | null):
24
25
  /* What a task's row says its agent is doing: the task's own state, or that the agent waits on a person while the task runs. */
25
26
  export type TaskRowState = StatusWord | 'waiting';
26
27
 
27
- export function taskRowStateOf(item: ChatSubagentItem, task: SubagentTask | null, child: ChatInfo | undefined): TaskRowState {
28
+ export function taskRowStateOf(item: ChatSubagentItem, task: SubagentTask | null, child: ChatThreadInfo | undefined): TaskRowState {
28
29
  const word = statusWordOf(item, task);
29
30
 
30
31
  if (word === 'running' && (child?.status === 'needs-you' || (child?.requests?.length ?? 0) > 0)) {
@@ -45,7 +46,7 @@ export function progressOf(states: readonly TaskRowState[]): { done: number; tot
45
46
  }
46
47
 
47
48
  /* What the flyout over the composer lists (`activeSubagents`); `order` puts the rows from before the page first. */
48
- export function flyoutSubagents(order: readonly string[], structure: Readonly<Record<string, ChatItem>>): ChatSubagentItem[] {
49
+ export function flyoutSubagents(order: readonly string[], structure: Readonly<Record<string, ChatThreadItem>>): ChatSubagentItem[] {
49
50
  return activeSubagents(
50
51
  order.flatMap((id) => {
51
52
  const item = structure[id];
@@ -1,6 +1,7 @@
1
- import type { ChatItem, ChatSubagentItem } from '@adecore/agent-contracts';
1
+ import type { ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  import i18next from 'i18next';
3
3
  import { create } from 'zustand';
4
+ import type { ChatThreadItem } from '../chat-sink';
4
5
  import { useChatScope } from '../scope';
5
6
  import { useChatRow } from '../state/chats';
6
7
  import { useSubagentSupport } from './subagent-support';
@@ -69,11 +70,11 @@ export function canOpenSubagent(item: ChatSubagentItem, machineRefused: boolean)
69
70
  }
70
71
 
71
72
  /* The row of the call that opened a conversation, a nested one included, since its row is in the thread too. */
72
- export function subagentOf(structure: Readonly<Record<string, ChatItem>>, toolUseId: string): ChatSubagentItem | null {
73
+ export function subagentOf(structure: Readonly<Record<string, ChatThreadItem>>, toolUseId: string): ChatSubagentItem | null {
73
74
  return Object.values(structure).find((item): item is ChatSubagentItem => item.kind === 'subagent' && item.toolUseId === toolUseId) ?? null;
74
75
  }
75
76
 
76
- export function openableSubagents(order: readonly string[], structure: Record<string, ChatItem>, machineRefused: boolean): ChatSubagentItem[] {
77
+ export function openableSubagents(order: readonly string[], structure: Record<string, ChatThreadItem>, machineRefused: boolean): ChatSubagentItem[] {
77
78
  return order.flatMap((id) => {
78
79
  const item = structure[id];
79
80
 
@@ -1,4 +1,4 @@
1
- import { taskIdOfRow, type ChatBackgroundTask, type ChatSubagentItem } from '@adecore/agent-contracts';
1
+ import { taskIdOfRow, type ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  import { Icon, IconButton, Popover, ScrollArea, Surface, useNow } from '@adecore/ui';
3
3
  import { formatElapsedShort } from '@adecore/ui/format';
4
4
  import clsx from 'clsx';
@@ -12,7 +12,7 @@ import { useHostTask, useHostTasks } from '../../host/host-hooks';
12
12
  import { useChatScope } from '../../scope';
13
13
  import { useChatRow, useChats } from '../../state/chats';
14
14
  import { useChatActions } from '../actions';
15
- import { backgroundCounts } from '../activity';
15
+ import { backgroundCounts, backgroundTaskName, type ChatThreadBackgroundTask } from '../activity';
16
16
  import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskRowStateOf } from '../subagent-list';
17
17
  import { useSubagentSupport } from '../subagent-support';
18
18
  import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail, type SubagentStep } from '../subagent-view';
@@ -20,7 +20,7 @@ import { flyoutWorkflows, workflowPillOf, type WorkflowCall, type WorkflowWord }
20
20
  import { WorkflowRow } from './rows/WorkflowRow';
21
21
  import { SubagentStopButton } from './SubagentStopButton';
22
22
 
23
- const NO_TASKS: readonly ChatBackgroundTask[] = [];
23
+ const NO_TASKS: readonly ChatThreadBackgroundTask[] = [];
24
24
 
25
25
  const NO_ITEMS: readonly string[] = [];
26
26
 
@@ -64,7 +64,7 @@ export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { cha
64
64
  return null;
65
65
  }
66
66
 
67
- const { shells, monitors } = backgroundCounts(background);
67
+ const { shells, monitors, others } = backgroundCounts(background);
68
68
  const Slot = host.SubagentSlot;
69
69
  const counting = progress.active > 0 && progress.total > 1;
70
70
 
@@ -98,7 +98,11 @@ export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { cha
98
98
  {background.length > 0 && (
99
99
  <Flyout
100
100
  icon={<Icon icon={shells > 0 ? SquareTerminal : Activity} size={14} />}
101
- label={[shells > 0 && t('activity.shells', { count: shells }), monitors > 0 && t('activity.monitors', { count: monitors })]
101
+ label={[
102
+ shells > 0 && t('activity.shells', { count: shells }),
103
+ monitors > 0 && t('activity.monitors', { count: monitors }),
104
+ others > 0 && t('activity.others', { count: others })
105
+ ]
102
106
  .filter(Boolean)
103
107
  .join(' · ')}
104
108
  >
@@ -253,7 +257,7 @@ function SubagentEntry({ chatId, item, now }: { chatId: string; item: ChatSubage
253
257
  }
254
258
 
255
259
  /* Only drawn while the flyout is open, so the clock ticks for nobody otherwise. */
256
- function BackgroundTaskRows({ chatId, tasks }: { chatId: string; tasks: readonly ChatBackgroundTask[] }) {
260
+ function BackgroundTaskRows({ chatId, tasks }: { chatId: string; tasks: readonly ChatThreadBackgroundTask[] }) {
257
261
  const host = useChatHost();
258
262
  const { t } = useTranslation('agent-chat');
259
263
  const now = useNow(1000);
@@ -270,7 +274,7 @@ function BackgroundTaskRows({ chatId, tasks }: { chatId: string; tasks: readonly
270
274
  <ActivityRow
271
275
  key={task.id}
272
276
  icon={<Icon icon={task.kind === 'shell' ? SquareTerminal : Activity} size={14} className="shrink-0 text-text-faint" />}
273
- title={task.description || task.command || t(`activity.${task.kind}`)}
277
+ title={backgroundTaskName(task)}
274
278
  detail={task.description ? task.command : null}
275
279
  time={formatElapsedShort(now - task.startedAt)}
276
280
  >
@@ -1,4 +1,4 @@
1
- import type { AgentKind, ChatInfo, ModelSelection } from '@adecore/agent-contracts';
1
+ import type { AgentKind, ModelSelection } from '@adecore/agent-contracts';
2
2
  import { Icon, PromptDialog, Surface, Tooltip } from '@adecore/ui';
3
3
  import { formatNumber } from '@adecore/ui/format';
4
4
  import clsx from 'clsx';
@@ -6,6 +6,7 @@ import { ChevronDown } from 'lucide-react';
6
6
  import { useEffect, useRef, useState, useSyncExternalStore, type MouseEvent, type PointerEvent } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import type { ChatSendExtras } from '../../chat-client';
9
+ import type { ChatThreadInfo } from '../../chat-sink';
9
10
  import { useChatHost } from '../../host/host';
10
11
  import { useHostComposerStatus, useHostExtraPrompts, useHostSendDelivery } from '../../host/host-hooks';
11
12
  import { useChatScope } from '../../scope';
@@ -49,7 +50,7 @@ import { ResumeCompactionDock } from './ResumeCompactionDock';
49
50
 
50
51
  interface ComposerProps {
51
52
  chatId: string;
52
- info: ChatInfo;
53
+ info: ChatThreadInfo;
53
54
  focused: boolean;
54
55
  /*
55
56
  * Set where the chat's prompts are answered somewhere else, such as a stack over a canvas: the