@adecore/agents-react 0.65.2 → 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 (114) 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/package.json +9 -9
  65. package/src/chat/activity.ts +19 -6
  66. package/src/chat/forks.ts +3 -3
  67. package/src/chat/logic/bookmarks.ts +3 -2
  68. package/src/chat/logic/continue-after-stop.ts +3 -2
  69. package/src/chat/logic/fork.ts +8 -7
  70. package/src/chat/logic/goal.ts +13 -4
  71. package/src/chat/logic/handback.ts +2 -3
  72. package/src/chat/logic/limit.ts +7 -2
  73. package/src/chat/logic/resume-compaction.ts +7 -6
  74. package/src/chat/logic/scrubber.ts +4 -3
  75. package/src/chat/logic/timeline-target.ts +4 -3
  76. package/src/chat/logic/timeline.ts +22 -16
  77. package/src/chat/pending-prompts.ts +3 -2
  78. package/src/chat/recent-messages.ts +5 -6
  79. package/src/chat/runtime-modes.ts +7 -2
  80. package/src/chat/subagent-conversation.ts +12 -9
  81. package/src/chat/subagent-list.ts +4 -3
  82. package/src/chat/subagent-view.ts +4 -3
  83. package/src/chat/ui/ChatActivity.tsx +11 -7
  84. package/src/chat/ui/Composer.tsx +3 -2
  85. package/src/chat/ui/GoalDock.tsx +6 -5
  86. package/src/chat/ui/LimitState.tsx +5 -5
  87. package/src/chat/ui/RunSettings.tsx +17 -9
  88. package/src/chat/ui/composer/ComposerControls.tsx +3 -2
  89. package/src/chat/ui/composer/use-chat-controls.ts +3 -2
  90. package/src/chat/ui/composer/use-compaction-offer.ts +4 -3
  91. package/src/chat/ui/composer/use-composer-menus.ts +3 -2
  92. package/src/chat/ui/composer/use-continuable-turn.ts +3 -3
  93. package/src/chat/ui/composer/use-effort-stepper.ts +3 -2
  94. package/src/chat/ui/reply-context.ts +2 -2
  95. package/src/chat/ui/rows/MessageRows.tsx +17 -1
  96. package/src/chat/ui/rows/Rows.tsx +3 -0
  97. package/src/chat/ui/rows/SubagentRow.tsx +5 -4
  98. package/src/chat/ui/rows/WorkRows.tsx +3 -2
  99. package/src/chat/ui/thread-references.ts +3 -3
  100. package/src/chat/waiting-on.ts +8 -7
  101. package/src/chat/workflow-list.ts +3 -2
  102. package/src/chat-client.ts +3 -2
  103. package/src/chat-sink.ts +21 -9
  104. package/src/host/host-hooks.ts +9 -1
  105. package/src/host/host.ts +13 -2
  106. package/src/host/timeline-row.ts +7 -5
  107. package/src/index.ts +2 -1
  108. package/src/locales/en/agent-chat.ts +17 -1
  109. package/src/locales/nl/agent-chat.ts +17 -1
  110. package/src/port-transport.ts +20 -3
  111. package/src/state/chats.ts +34 -35
  112. package/src/state/index.ts +1 -1
  113. package/src/state/usage.ts +45 -5
  114. package/src/transport.ts +4 -2
@@ -60,7 +60,8 @@ export default {
60
60
  blocked: 'Goal blocked',
61
61
  'usage-limited': 'Goal stopped on a usage limit',
62
62
  'budget-limited': 'Goal used up its token budget',
63
- complete: 'Goal met'
63
+ complete: 'Goal met',
64
+ unknown: 'Goal in a state this version does not know'
64
65
  },
65
66
  pill: 'Goal',
66
67
  checks_one: '{{count}} check not met yet',
@@ -74,6 +75,10 @@ export default {
74
75
  failed: 'Could not change goal'
75
76
  },
76
77
  limit: {
78
+ other: {
79
+ pill: 'Stopped',
80
+ title: 'Stopped on a limit'
81
+ },
77
82
  usage: {
78
83
  pill: 'Limited',
79
84
  pillUntil: 'Limited until {{time}}',
@@ -154,6 +159,10 @@ export default {
154
159
  thoughtFor: 'Thought for {{duration}}',
155
160
  thought: 'Thought'
156
161
  },
162
+ unknown: {
163
+ item: 'Update the app to see this.',
164
+ request: 'Answer this on the machine, or update the app to answer here.'
165
+ },
157
166
  note: {
158
167
  hide: 'Hide',
159
168
  show: 'Show',
@@ -480,6 +489,9 @@ export default {
480
489
  },
481
490
  shell: 'Shell',
482
491
  monitor: 'Monitor',
492
+ other: 'Background task',
493
+ others_one: '{{count}} background task',
494
+ others_other: '{{count}} background tasks',
483
495
  stop: 'Stop',
484
496
  stopFailed: 'Could not stop task'
485
497
  },
@@ -534,6 +546,10 @@ export default {
534
546
  label: 'Full access',
535
547
  hint: 'Never asks for approval',
536
548
  short: 'Full access'
549
+ },
550
+ unknown: {
551
+ label: 'Set on the machine',
552
+ short: 'On the machine'
537
553
  }
538
554
  },
539
555
  pickers: {
@@ -61,6 +61,7 @@ declare const _default: {
61
61
  'usage-limited': string;
62
62
  'budget-limited': string;
63
63
  complete: string;
64
+ unknown: string;
64
65
  };
65
66
  pill: string;
66
67
  checks_one: string;
@@ -74,6 +75,10 @@ declare const _default: {
74
75
  failed: string;
75
76
  };
76
77
  limit: {
78
+ other: {
79
+ pill: string;
80
+ title: string;
81
+ };
77
82
  usage: {
78
83
  pill: string;
79
84
  pillUntil: string;
@@ -154,6 +159,10 @@ declare const _default: {
154
159
  thoughtFor: string;
155
160
  thought: string;
156
161
  };
162
+ unknown: {
163
+ item: string;
164
+ request: string;
165
+ };
157
166
  note: {
158
167
  hide: string;
159
168
  show: string;
@@ -480,6 +489,9 @@ declare const _default: {
480
489
  };
481
490
  shell: string;
482
491
  monitor: string;
492
+ other: string;
493
+ others_one: string;
494
+ others_other: string;
483
495
  stop: string;
484
496
  stopFailed: string;
485
497
  };
@@ -535,6 +547,10 @@ declare const _default: {
535
547
  hint: string;
536
548
  short: string;
537
549
  };
550
+ unknown: {
551
+ label: string;
552
+ short: string;
553
+ };
538
554
  };
539
555
  pickers: {
540
556
  settings: {
@@ -60,7 +60,8 @@ export default {
60
60
  blocked: 'Doel geblokkeerd',
61
61
  'usage-limited': 'Doel gestopt op een verbruikslimiet',
62
62
  'budget-limited': 'Doel heeft zijn tokenbudget op',
63
- complete: 'Doel bereikt'
63
+ complete: 'Doel bereikt',
64
+ unknown: 'Doel in een toestand die deze versie niet kent'
64
65
  },
65
66
  pill: 'Doel',
66
67
  checks_one: '{{count}} controle nog niet gehaald',
@@ -74,6 +75,10 @@ export default {
74
75
  failed: 'Kon het doel niet wijzigen'
75
76
  },
76
77
  limit: {
78
+ other: {
79
+ pill: 'Gestopt',
80
+ title: 'Gestopt op een limiet'
81
+ },
77
82
  usage: {
78
83
  pill: 'Limiet bereikt',
79
84
  pillUntil: 'Limiet tot {{time}}',
@@ -154,6 +159,10 @@ export default {
154
159
  thoughtFor: 'Nagedacht, {{duration}}',
155
160
  thought: 'Gedachte'
156
161
  },
162
+ unknown: {
163
+ item: 'Werk de app bij om dit te zien.',
164
+ request: 'Beantwoord dit op de machine, of werk de app bij om hier te antwoorden.'
165
+ },
157
166
  note: {
158
167
  hide: 'Verbergen',
159
168
  show: 'Tonen',
@@ -480,6 +489,9 @@ export default {
480
489
  },
481
490
  shell: 'Shell',
482
491
  monitor: 'Monitor',
492
+ other: 'Achtergrondtaak',
493
+ others_one: '{{count}} achtergrondtaak',
494
+ others_other: '{{count}} achtergrondtaken',
483
495
  stop: 'Stoppen',
484
496
  stopFailed: 'Kon de taak niet stoppen'
485
497
  },
@@ -534,6 +546,10 @@ export default {
534
546
  label: 'Volledige toegang',
535
547
  hint: 'Vraagt nooit om goedkeuring',
536
548
  short: 'Volledig'
549
+ },
550
+ unknown: {
551
+ label: 'Ingesteld op de machine',
552
+ short: 'Op de machine'
537
553
  }
538
554
  },
539
555
  pickers: {
@@ -1,6 +1,15 @@
1
1
  import type { FramePort } from '@adecore/agent-contracts/port';
2
+ import { type AgentEventType, type AgentRequestType } from '@adecore/agent-contracts/protocol';
3
+ import { type WireDegradation } from '@adecore/agent-contracts/tolerance';
2
4
  import { type ChatTransport } from './transport.js';
3
5
  export interface PortTransport extends ChatTransport {
4
6
  close(): void;
5
7
  }
6
- export declare function portTransport(port: FramePort): PortTransport;
8
+ export interface PortTransportOptions {
9
+ onDegraded?(source: {
10
+ readonly request: AgentRequestType;
11
+ } | {
12
+ readonly event: AgentEventType;
13
+ }, degraded: readonly WireDegradation[]): void;
14
+ }
15
+ export declare function portTransport(port: FramePort, options?: PortTransportOptions): PortTransport;
@@ -1,5 +1,6 @@
1
1
  import { parseServerFrame } from '@adecore/agent-contracts/envelope';
2
2
  import { AGENT_EVENT_SCHEMAS, AGENT_REQUEST_SCHEMAS } from '@adecore/agent-contracts/protocol';
3
+ import { readTolerant } from '@adecore/agent-contracts/tolerance';
3
4
  import i18next from 'i18next';
4
5
  import { ChatTransportError } from './transport.js';
5
6
  function isEventType(event) {
@@ -11,7 +12,7 @@ function isEventType(event) {
11
12
  * until `close`. Frames are checked where they arrive, and a frame that does not hold up is dropped
12
13
  * with a warning, the way the socket transport of an app drops one.
13
14
  */
14
- export function portTransport(port) {
15
+ export function portTransport(port, options = {}) {
15
16
  let status = 'open';
16
17
  let nextId = 1;
17
18
  const pending = new Map();
@@ -27,13 +28,18 @@ export function portTransport(port) {
27
28
  entry.reject(new ChatTransportError(frame.error.code, frame.error.message));
28
29
  return;
29
30
  }
30
- const result = AGENT_REQUEST_SCHEMAS[entry.type].result.safeParse(frame.result);
31
+ const result = readTolerant(AGENT_REQUEST_SCHEMAS[entry.type].result, frame.result);
31
32
  if (!result.success) {
32
33
  entry.reject(new ChatTransportError('bad-reply', i18next.t('agent-chat:transport.badReply', {
33
34
  type: entry.type
34
35
  })));
35
36
  return;
36
37
  }
38
+ if (result.degraded.length > 0) {
39
+ options.onDegraded?.({
40
+ request: entry.type
41
+ }, result.degraded);
42
+ }
37
43
  entry.resolve(result.data);
38
44
  };
39
45
  const dispatch = (event, payload) => {
@@ -41,11 +47,16 @@ export function portTransport(port) {
41
47
  console.warn('Dropped an unknown event', event);
42
48
  return;
43
49
  }
44
- const parsed = AGENT_EVENT_SCHEMAS[event].safeParse(payload);
50
+ const parsed = readTolerant(AGENT_EVENT_SCHEMAS[event], payload);
45
51
  if (!parsed.success) {
46
52
  console.warn(`Dropped a malformed ${event} event`);
47
53
  return;
48
54
  }
55
+ if (parsed.degraded.length > 0) {
56
+ options.onDegraded?.({
57
+ event
58
+ }, parsed.degraded);
59
+ }
49
60
  // A copy, so a handler that unsubscribes while it runs does not change the set being walked.
50
61
  for (const handler of [...(eventHandlers.get(event) ?? [])]) {
51
62
  handler(parsed.data);
@@ -1,16 +1,17 @@
1
- import type { AgentKind, ChatApprovalItem, ChatBookmark, ChatEvent, ChatHistoryResult, ChatInfo, ChatItem, ChatQuestionItem, ChatVisual } from '@adecore/agent-contracts';
2
- import type { ChatHistoryPage, ChatPage, ChatSink } from '../chat-sink.js';
1
+ import type { AgentKind, ChatApprovalItem, ChatBookmark, ChatHistoryResult, ChatQuestionItem, ChatUnknownItem, ChatVisual } from '@adecore/agent-contracts';
2
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
3
+ import type { ChatHistoryPage, ChatPage, ChatSink, ChatThreadEvent, ChatThreadInfo, ChatThreadItem } from '../chat-sink.js';
3
4
  export interface ChatState {
4
- info: ChatInfo;
5
+ info: ChatThreadInfo;
5
6
  historyPending?: boolean;
6
- items: Record<string, ChatItem>;
7
- structure: Record<string, ChatItem>;
7
+ items: Record<string, ChatThreadItem>;
8
+ structure: Record<string, ChatThreadItem>;
8
9
  order: string[];
9
10
  history?: ChatHistoryPage;
10
11
  waitingBefore?: string[];
11
12
  subagentsBefore?: string[];
12
13
  workflowsBefore?: string[];
13
- outlineBefore?: ChatItem[];
14
+ outlineBefore?: ChatThreadItem[];
14
15
  bookmarks?: ChatBookmark[];
15
16
  visuals?: ChatVisual[];
16
17
  }
@@ -19,25 +20,26 @@ export type ChatStatuses = Record<string, Pick<ChatState, 'info'>>;
19
20
  interface ChatsStore {
20
21
  byKey: ChatsById;
21
22
  statusByKey: ChatStatuses;
22
- reset(key: string, info: ChatInfo, items: ChatItem[], page?: ChatPage): void;
23
- prepend(key: string, cursor: string, page: ChatHistoryResult): void;
24
- apply(key: string, event: ChatEvent): void;
25
- replay(key: string, events: readonly ChatEvent[]): void;
26
- status(key: string, info: ChatInfo): void;
23
+ reset(key: string, info: ChatThreadInfo, items: ChatThreadItem[], page?: ChatPage): void;
24
+ prepend(key: string, cursor: string, page: Tolerant<ChatHistoryResult>): void;
25
+ apply(key: string, event: ChatThreadEvent): void;
26
+ replay(key: string, events: readonly ChatThreadEvent[]): void;
27
+ status(key: string, info: ChatThreadInfo): void;
27
28
  bookmarks(key: string, bookmarks: ChatBookmark[]): void;
28
29
  visuals(key: string, visuals: ChatVisual[]): void;
29
30
  forget(key: string): void;
30
31
  forgetWhere(matches: (key: string) => boolean): void;
31
32
  }
32
- export declare function isWaiting(item: ChatItem | undefined): item is ChatApprovalItem | ChatQuestionItem;
33
- export declare function prependPage(state: ChatState, cursor: string, page: ChatHistoryResult): ChatState;
33
+ export declare function isWaiting(item: ChatThreadItem | undefined): item is ChatApprovalItem | ChatQuestionItem;
34
+ export declare function waitsOnTheHost(item: ChatUnknownItem): boolean;
35
+ export declare function prependPage(state: ChatState, cursor: string, page: Tolerant<ChatHistoryResult>): ChatState;
34
36
  export declare function waitingRequestsOf(chat: Pick<ChatState, 'structure' | 'order' | 'waitingBefore'> | undefined): Array<ChatApprovalItem | ChatQuestionItem>;
35
- export declare function applyEvent(state: ChatState, event: ChatEvent): ChatState;
37
+ export declare function applyEvent(state: ChatState, event: ChatThreadEvent): ChatState;
36
38
  export declare const useChats: import("zustand").UseBoundStore<import("zustand").StoreApi<ChatsStore>>;
37
39
  export declare function chatSink(keyOf: (chatId: string) => string): ChatSink;
38
40
  export declare function useChatRow<T>(chatId: string, select: (row: ChatState | undefined) => T): T;
39
41
  export declare function useReportedModels(provider: AgentKind): ReadonlySet<string>;
40
42
  export declare function useReportedModelsByProvider(): (provider: AgentKind) => ReadonlySet<string>;
41
43
  export declare function useAwaitsApproval(chatId: string, toolUseId: string): boolean;
42
- export declare function useCurrentItem<T extends ChatItem>(chatId: string, derived: T): T;
44
+ export declare function useCurrentItem<T extends ChatThreadItem>(chatId: string, derived: T): T;
43
45
  export {};
@@ -6,6 +6,10 @@ import { ChatScopeContext, useChatScope } from '../scope.js';
6
6
  export function isWaiting(item) {
7
7
  return item?.kind === 'approval' && item.decision === 'pending' || item?.kind === 'question' && item.state === 'pending';
8
8
  }
9
+ /* An approval or question of a newer host that still waits; this version never answers it, so its row says where to. */
10
+ export function waitsOnTheHost(item) {
11
+ return item.raw.kind === 'approval' && item.raw.decision === 'pending' || item.raw.kind === 'question' && item.raw.state === 'pending';
12
+ }
9
13
  function stateOf(info, items, page) {
10
14
  const byId = Object.fromEntries(items.map(item => [item.id, item]));
11
15
  const order = items.map(item => item.id);
@@ -255,6 +259,9 @@ function applyUpdate(state, event, write) {
255
259
  };
256
260
  case 'reset':
257
261
  return stateOf(event.info, event.items);
262
+ // A newer host's event; guessing what it does could only leave the thread wrong.
263
+ case 'unknown':
264
+ return state;
258
265
  }
259
266
  }
260
267
  /* Fields of a held chat that are not part of its thread; a chat this client does not hold stays as it is. */
@@ -1,5 +1,5 @@
1
1
  export { type ChatState, type ChatsById, type ChatStatuses, waitingRequestsOf, applyEvent, useChats, chatSink, useChatRow } from './chats.js';
2
- export type { ChatHistoryPage, ChatSink } from '../chat-sink.js';
2
+ export type { ChatHistoryPage, ChatSink, ChatThreadEvent, ChatThreadInfo, ChatThreadItem, ChatThreadTurn } from '../chat-sink.js';
3
3
  export { useProviderAccountsStore, useProviderAccounts, providerAccountsOf, knownAccounts, watchProviderAccounts } from './provider-accounts.js';
4
4
  export { useProvidersStore, useProviders, providersOf, providerSinkFor, type ProvidersRow } from './providers.js';
5
5
  export { type UsageMetric, USAGE_PREFERENCES_KEY, dayOf, windowFor, reloadUsagePreferences, useUsageStore, type UsagePeriod } from './usage.js';
@@ -1,4 +1,5 @@
1
1
  import { type UsageLimitsSnapshot, type UsageRate, type UsageSummaryPayload, type UsageSummaryResult } from '@adecore/agent-contracts';
2
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
2
3
  export type UsageCurrency = 'USD' | 'EUR';
3
4
  export type UsagePeriod = 'today' | '7d' | '30d' | '90d';
4
5
  export type UsageMetric = 'cost' | 'tokens';
@@ -32,9 +33,9 @@ interface UsageStore extends Preferences {
32
33
  setMetric(metric: UsageMetric): void;
33
34
  setCurrency(currency: UsageCurrency): void;
34
35
  setLoading(scopeId: string, loading: boolean): void;
35
- receive(scopeId: string, asked: string, summary: UsageSummaryResult): void;
36
+ receive(scopeId: string, asked: string, summary: Tolerant<UsageSummaryResult>): void;
36
37
  fail(scopeId: string): void;
37
- setLimits(scopeId: string, limits: UsageLimitsSnapshot): void;
38
+ setLimits(scopeId: string, limits: Tolerant<UsageLimitsSnapshot>): void;
38
39
  forget(scopeId: string): void;
39
40
  }
40
41
  export declare function reloadUsagePreferences(): void;
@@ -1,5 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { UsageRateSchema } from '@adecore/agent-contracts';
2
+ import { UsageProviderSchema, UsageRateSchema } from '@adecore/agent-contracts';
3
3
  import { localTimeZone } from '@adecore/ui/format';
4
4
  import { persistedJson } from '../persisted-json.js';
5
5
  import { useChatScope } from '../scope.js';
@@ -81,6 +81,36 @@ export function summaryPayload(period, account, now = new Date()) {
81
81
  export function askedKey(payload) {
82
82
  return `${payload.from}\0${payload.to}\0${payload.resolution}\0${payload.timeZone}\0${payload.accounts?.join(',') ?? ''}`;
83
83
  }
84
+ /* A row of a provider a newer host reads is left off: this version has no name, color or price basis for it. */
85
+ function isUsageProvider(word) {
86
+ return UsageProviderSchema.options.includes(word);
87
+ }
88
+ function knownProvider(row) {
89
+ return isUsageProvider(row.provider);
90
+ }
91
+ function knownKind(row) {
92
+ return isUsageProvider(row.kind);
93
+ }
94
+ function knownSummary(summary) {
95
+ const {
96
+ accounts,
97
+ ...rest
98
+ } = summary;
99
+ return {
100
+ ...rest,
101
+ buckets: summary.buckets.filter(knownProvider),
102
+ models: summary.models.filter(knownProvider),
103
+ roots: summary.roots.filter(knownProvider),
104
+ ...(accounts === undefined ? {} : {
105
+ accounts: accounts.filter(knownKind)
106
+ })
107
+ };
108
+ }
109
+ function knownLimits(limits) {
110
+ return {
111
+ providers: limits.providers.filter(knownKind)
112
+ };
113
+ }
84
114
  /* One object for a host nothing was read from yet, so a selector gets a stable snapshot. */
85
115
  const EMPTY = {
86
116
  asked: null,
@@ -141,7 +171,8 @@ export const useUsageStore = createChatStore((set, get) => {
141
171
  loading
142
172
  });
143
173
  },
144
- receive(scopeId, asked, summary) {
174
+ receive(scopeId, asked, read) {
175
+ const summary = knownSummary(read);
145
176
  patchRow(scopeId, {
146
177
  asked,
147
178
  summary,
@@ -162,7 +193,7 @@ export const useUsageStore = createChatStore((set, get) => {
162
193
  },
163
194
  setLimits(scopeId, limits) {
164
195
  patchRow(scopeId, {
165
- limits
196
+ limits: knownLimits(limits)
166
197
  });
167
198
  },
168
199
  forget(scopeId) {
@@ -1,13 +1,14 @@
1
1
  import type { AGENT_EVENT_SCHEMAS, AGENT_REQUEST_SCHEMAS, AgentEventType, AgentRequestType } from '@adecore/agent-contracts/protocol';
2
+ import type { Tolerant } from '@adecore/agent-contracts/tolerance';
2
3
  import type { z } from 'zod';
3
4
  export type ChatRequestMap = {
4
5
  [T in AgentRequestType]: {
5
6
  payload: z.infer<(typeof AGENT_REQUEST_SCHEMAS)[T]['payload']>;
6
- result: z.infer<(typeof AGENT_REQUEST_SCHEMAS)[T]['result']>;
7
+ result: Tolerant<z.infer<(typeof AGENT_REQUEST_SCHEMAS)[T]['result']>>;
7
8
  };
8
9
  };
9
10
  export type ChatEventMap = {
10
- [E in AgentEventType]: z.infer<(typeof AGENT_EVENT_SCHEMAS)[E]>;
11
+ [E in AgentEventType]: Tolerant<z.infer<(typeof AGENT_EVENT_SCHEMAS)[E]>>;
11
12
  };
12
13
  export type ChatTransportStatus = 'connecting' | 'open' | 'closed';
13
14
  export interface ChatTransport {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.65.2",
3
+ "version": "0.66.0",
4
4
  "description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -72,12 +72,12 @@
72
72
  "test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
73
73
  },
74
74
  "dependencies": {
75
- "@adecore/agent-contracts": "0.65.2",
76
- "@adecore/editor": "0.65.2",
77
- "@adecore/editor-react": "0.65.2",
78
- "@adecore/intelligent-ui": "0.65.2",
79
- "@adecore/merge": "0.65.2",
80
- "@adecore/utils": "0.65.2",
75
+ "@adecore/agent-contracts": "0.66.0",
76
+ "@adecore/editor": "0.66.0",
77
+ "@adecore/editor-react": "0.66.0",
78
+ "@adecore/intelligent-ui": "0.66.0",
79
+ "@adecore/merge": "0.66.0",
80
+ "@adecore/utils": "0.66.0",
81
81
  "@codemirror/commands": "^6.11.1",
82
82
  "@codemirror/language": "^6.13.1",
83
83
  "@codemirror/state": "^6.7.6",
@@ -101,14 +101,14 @@
101
101
  "zustand": "^5.0.16"
102
102
  },
103
103
  "peerDependencies": {
104
- "@adecore/ui": "^0.65.2",
104
+ "@adecore/ui": "^0.66.0",
105
105
  "i18next": "^26.4.2",
106
106
  "react": "^19.3.0",
107
107
  "react-dom": "^19.3.0",
108
108
  "react-i18next": "^17.0.15"
109
109
  },
110
110
  "devDependencies": {
111
- "@adecore/ui": "0.65.2",
111
+ "@adecore/ui": "0.66.0",
112
112
  "@types/bun": "^1.4.4",
113
113
  "@types/react": "^19.3.0",
114
114
  "@types/react-dom": "^19.3.0",
@@ -1,8 +1,21 @@
1
- import type { ChatBackgroundTask } from '@adecore/agent-contracts';
1
+ import i18next from 'i18next';
2
+ import type { ChatThreadInfo } from '../chat-sink';
2
3
 
3
- export function backgroundCounts(tasks: readonly ChatBackgroundTask[]): { shells: number; monitors: number } {
4
- return {
5
- shells: tasks.filter((task) => task.kind === 'shell').length,
6
- monitors: tasks.filter((task) => task.kind === 'monitor').length
7
- };
4
+ /* A command or monitor as a client holds it; a newer host may run a kind this version does not know. */
5
+ export type ChatThreadBackgroundTask = NonNullable<ChatThreadInfo['background']>[number];
6
+
7
+ /* What a person reads for a task: what it does, else the command, else its kind. */
8
+ export function backgroundTaskName(task: ChatThreadBackgroundTask): string {
9
+ if (task.description || task.command) {
10
+ return task.description || task.command || '';
11
+ }
12
+
13
+ return task.kind === 'shell' || task.kind === 'monitor' ? i18next.t(`agent-chat:activity.${task.kind}`) : i18next.t('agent-chat:activity.other');
14
+ }
15
+
16
+ export function backgroundCounts(tasks: readonly ChatThreadBackgroundTask[]): { shells: number; monitors: number; others: number } {
17
+ const shells = tasks.filter((task) => task.kind === 'shell').length;
18
+ const monitors = tasks.filter((task) => task.kind === 'monitor').length;
19
+
20
+ return { shells, monitors, others: tasks.length - shells - monitors };
8
21
  }
package/src/chat/forks.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { ChatInfo } from '@adecore/agent-contracts';
1
+ import type { ChatThreadInfo } from '../chat-sink';
2
2
  import { useChatScope } from '../scope';
3
3
  import { useChats, type ChatStatuses } from '../state/chats';
4
4
  import { forkIdsAfter, forkedTurnIds } from './logic/fork';
5
5
 
6
- function* forkInfosOn(statuses: ChatStatuses, owns: (key: string) => boolean): Generator<ChatInfo> {
6
+ function* forkInfosOn(statuses: ChatStatuses, owns: (key: string) => boolean): Generator<ChatThreadInfo> {
7
7
  for (const [key, state] of Object.entries(statuses)) {
8
8
  if (state.info.forkOf !== undefined && owns(key)) {
9
9
  yield state.info;
@@ -18,7 +18,7 @@ function* forkInfosOn(statuses: ChatStatuses, owns: (key: string) => boolean): G
18
18
  */
19
19
  function joinedForks(
20
20
  owns: (key: string) => boolean,
21
- collect: (infos: Iterable<ChatInfo>) => Iterable<string>
21
+ collect: (infos: Iterable<ChatThreadInfo>) => Iterable<string>
22
22
  ): (state: { statusByKey: ChatStatuses }) => string {
23
23
  let statuses: ChatStatuses | null = null;
24
24
  let joined = '';
@@ -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
 
4
5
  /* What a list calls a bookmark: its name, else the start of the message. */
@@ -23,7 +24,7 @@ export function bookmarksInThreadOrder(bookmarks: readonly ChatBookmark[], order
23
24
  export function bookmarkRows(
24
25
  rows: readonly TimelineRow[],
25
26
  bookmarks: readonly ChatBookmark[],
26
- items: Readonly<Record<string, ChatItem>>
27
+ items: Readonly<Record<string, ChatThreadItem>>
27
28
  ): Map<string, ChatBookmark> {
28
29
  const rowIds = new Set(rows.map((row) => row.id));
29
30
  const folds = new Map<string, string>();
@@ -1,4 +1,5 @@
1
- import { abortedByEnd, abortedByMachine, type ChatInfo, type ChatItem } from '@adecore/agent-contracts';
1
+ import { abortedByEnd, abortedByMachine } from '@adecore/agent-contracts';
2
+ import type { ChatThreadInfo, ChatThreadItem } from '../../chat-sink';
2
3
 
3
4
  /* English like the other prompts the CLI gets, and it reaches the thread as the person's own message, which it is. */
4
5
  export const CONTINUE_PROMPT = 'Continue.';
@@ -8,7 +9,7 @@ export const CONTINUE_PROMPT = 'Continue.';
8
9
  * A paused queue, a limit and a paused goal have their own way out, a turn the machine ended has its own resume,
9
10
  * and a request that waits on a person comes first.
10
11
  */
11
- export function continuableTurn(info: ChatInfo, items: readonly ChatItem[]): string | null {
12
+ export function continuableTurn(info: ChatThreadInfo, items: readonly ChatThreadItem[]): string | null {
12
13
  if (
13
14
  info.activeTurnId !== null ||
14
15
  info.status === 'needs-you' ||
@@ -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';