@adecore/agents-react 0.51.0 → 0.53.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 (59) hide show
  1. package/dist/agents/AgentIcon.js +25 -17
  2. package/dist/agents/ProviderLogo.js +26 -16
  3. package/dist/agents/agent-marks.d.ts +1 -0
  4. package/dist/agents/provider-paths.d.ts +2 -1
  5. package/dist/agents/provider-paths.js +11 -2
  6. package/dist/chat/index.d.ts +2 -1
  7. package/dist/chat/index.js +2 -1
  8. package/dist/chat/logic/command-looks.d.ts +17 -5
  9. package/dist/chat/logic/command-looks.js +35 -7
  10. package/dist/chat/logic/timeline.d.ts +6 -4
  11. package/dist/chat/logic/timeline.js +32 -25
  12. package/dist/chat/logic/tool-looks.d.ts +16 -0
  13. package/dist/chat/logic/tool-looks.js +188 -0
  14. package/dist/chat/logic/tools.d.ts +5 -0
  15. package/dist/chat/logic/tools.js +17 -2
  16. package/dist/chat/ui/ShellCommand.d.ts +2 -1
  17. package/dist/chat/ui/ShellCommand.js +73 -22
  18. package/dist/chat/ui/SubagentTimeline.js +5 -2
  19. package/dist/chat/ui/Timeline.js +2 -1
  20. package/dist/chat/ui/diff/EditorEditDiff.d.ts +3 -2
  21. package/dist/chat/ui/diff/EditorEditDiff.js +93 -79
  22. package/dist/chat/ui/diff/LegacyEditDiff.d.ts +1 -1
  23. package/dist/chat/ui/diff/LegacyEditDiff.js +64 -48
  24. package/dist/chat/ui/rows/RowContainer.js +26 -23
  25. package/dist/chat/ui/rows/WorkRows.d.ts +3 -4
  26. package/dist/chat/ui/rows/WorkRows.js +592 -519
  27. package/dist/chat/ui/rows/row-rhythm.d.ts +2 -2
  28. package/dist/chat/ui/rows/row-rhythm.js +9 -6
  29. package/dist/chat/ui/thread-references.d.ts +1 -0
  30. package/dist/chat/ui/thread-references.js +4 -3
  31. package/dist/host.d.ts +28 -0
  32. package/dist/index.d.ts +1 -1
  33. package/dist/locales/en/agent-chat.d.ts +4 -0
  34. package/dist/locales/en/agent-chat.js +4 -0
  35. package/dist/locales/nl/agent-chat.d.ts +4 -0
  36. package/dist/locales/nl/agent-chat.js +4 -0
  37. package/package.json +8 -8
  38. package/src/agents/AgentIcon.tsx +2 -1
  39. package/src/agents/ProviderLogo.tsx +2 -2
  40. package/src/agents/agent-marks.ts +2 -0
  41. package/src/agents/provider-paths.ts +15 -3
  42. package/src/chat/index.ts +2 -1
  43. package/src/chat/logic/command-looks.ts +51 -10
  44. package/src/chat/logic/timeline.ts +46 -27
  45. package/src/chat/logic/tool-looks.ts +228 -0
  46. package/src/chat/logic/tools.ts +13 -2
  47. package/src/chat/ui/ShellCommand.tsx +33 -6
  48. package/src/chat/ui/SubagentTimeline.tsx +3 -2
  49. package/src/chat/ui/Timeline.tsx +2 -1
  50. package/src/chat/ui/diff/EditorEditDiff.tsx +31 -5
  51. package/src/chat/ui/diff/LegacyEditDiff.tsx +5 -3
  52. package/src/chat/ui/rows/RowContainer.tsx +4 -2
  53. package/src/chat/ui/rows/WorkRows.tsx +46 -33
  54. package/src/chat/ui/rows/row-rhythm.ts +9 -6
  55. package/src/chat/ui/thread-references.ts +5 -1
  56. package/src/host.ts +51 -0
  57. package/src/index.ts +3 -0
  58. package/src/locales/en/agent-chat.ts +4 -0
  59. package/src/locales/nl/agent-chat.ts +4 -0
@@ -9,6 +9,11 @@ import { PROVIDER_PATHS } from './provider-paths.js';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  const BUILT_IN_MARKS = {
11
11
  claude: siClaude,
12
+ 'anthropic-claude-api': {
13
+ title: 'Claude API',
14
+ path: PROVIDER_PATHS['anthropic-claude-api'],
15
+ fillRule: 'evenodd'
16
+ },
12
17
  codex: {
13
18
  title: 'Codex',
14
19
  path: PROVIDER_PATHS.codex
@@ -21,7 +26,7 @@ const BUILT_IN_MARKS = {
21
26
  copilot: siGithubcopilot
22
27
  };
23
28
  export function AgentIcon(t0) {
24
- const $ = _c(15);
29
+ const $ = _c(16);
25
30
  const {
26
31
  kind,
27
32
  size: t1,
@@ -63,19 +68,22 @@ export function AgentIcon(t0) {
63
68
  } else {
64
69
  t5 = $[6];
65
70
  }
66
- let t6;
67
- if ($[7] !== mark.path) {
68
- t6 = /*#__PURE__*/_jsx("path", {
69
- d: mark.path
71
+ const t6 = mark.fillRule ?? "nonzero";
72
+ let t7;
73
+ if ($[7] !== mark.path || $[8] !== t6) {
74
+ t7 = /*#__PURE__*/_jsx("path", {
75
+ d: mark.path,
76
+ fillRule: t6
70
77
  });
71
78
  $[7] = mark.path;
72
79
  $[8] = t6;
80
+ $[9] = t7;
73
81
  } else {
74
- t6 = $[8];
82
+ t7 = $[9];
75
83
  }
76
- let t7;
77
- if ($[9] !== mark.title || $[10] !== size || $[11] !== t4 || $[12] !== t5 || $[13] !== t6) {
78
- t7 = /*#__PURE__*/_jsx("svg", {
84
+ let t8;
85
+ if ($[10] !== mark.title || $[11] !== size || $[12] !== t4 || $[13] !== t5 || $[14] !== t7) {
86
+ t8 = /*#__PURE__*/_jsx("svg", {
79
87
  role: "img",
80
88
  "aria-label": t3,
81
89
  viewBox: t4,
@@ -83,16 +91,16 @@ export function AgentIcon(t0) {
83
91
  height: size,
84
92
  fill: "currentColor",
85
93
  className: t5,
86
- children: t6
94
+ children: t7
87
95
  });
88
- $[9] = mark.title;
89
- $[10] = size;
90
- $[11] = t4;
91
- $[12] = t5;
92
- $[13] = t6;
96
+ $[10] = mark.title;
97
+ $[11] = size;
98
+ $[12] = t4;
99
+ $[13] = t5;
93
100
  $[14] = t7;
101
+ $[15] = t8;
94
102
  } else {
95
- t7 = $[14];
103
+ t8 = $[15];
96
104
  }
97
- return t7;
105
+ return t8;
98
106
  }
@@ -1,11 +1,11 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import clsx from 'clsx';
3
- import { PROVIDER_PATHS } from './provider-paths.js';
3
+ import { PROVIDER_PATHS, providerFillRule } from './provider-paths.js';
4
4
  /* The 24 by 24 box both marks are drawn in, so one size renders them at the same weight. */
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  const VIEW_BOX = '0 0 24 24';
7
7
  export function ProviderLogo(t0) {
8
- const $ = _c(8);
8
+ const $ = _c(11);
9
9
  const {
10
10
  provider,
11
11
  size: t1,
@@ -22,32 +22,42 @@ export function ProviderLogo(t0) {
22
22
  }
23
23
  const t3 = PROVIDER_PATHS[provider];
24
24
  let t4;
25
- if ($[2] !== t3) {
26
- t4 = /*#__PURE__*/_jsx("path", {
27
- d: t3
28
- });
29
- $[2] = t3;
25
+ if ($[2] !== provider) {
26
+ t4 = providerFillRule(provider);
27
+ $[2] = provider;
30
28
  $[3] = t4;
31
29
  } else {
32
30
  t4 = $[3];
33
31
  }
34
32
  let t5;
35
- if ($[4] !== size || $[5] !== t2 || $[6] !== t4) {
36
- t5 = /*#__PURE__*/_jsx("svg", {
33
+ if ($[4] !== t3 || $[5] !== t4) {
34
+ t5 = /*#__PURE__*/_jsx("path", {
35
+ d: t3,
36
+ fillRule: t4
37
+ });
38
+ $[4] = t3;
39
+ $[5] = t4;
40
+ $[6] = t5;
41
+ } else {
42
+ t5 = $[6];
43
+ }
44
+ let t6;
45
+ if ($[7] !== size || $[8] !== t2 || $[9] !== t5) {
46
+ t6 = /*#__PURE__*/_jsx("svg", {
37
47
  "aria-hidden": true,
38
48
  viewBox: VIEW_BOX,
39
49
  width: size,
40
50
  height: size,
41
51
  fill: "currentColor",
42
52
  className: t2,
43
- children: t4
53
+ children: t5
44
54
  });
45
- $[4] = size;
46
- $[5] = t2;
47
- $[6] = t4;
48
- $[7] = t5;
55
+ $[7] = size;
56
+ $[8] = t2;
57
+ $[9] = t5;
58
+ $[10] = t6;
49
59
  } else {
50
- t5 = $[7];
60
+ t6 = $[10];
51
61
  }
52
- return t5;
62
+ return t6;
53
63
  }
@@ -3,6 +3,7 @@ export interface AgentMark {
3
3
  title: string;
4
4
  path: string;
5
5
  viewBox?: string;
6
+ fillRule?: 'nonzero' | 'evenodd';
6
7
  }
7
8
  export declare function configureAgentMarks(marks: Readonly<Partial<Record<AgentKind, AgentMark>>>): void;
8
9
  export declare function hostAgentMark(kind: AgentKind): AgentMark | undefined;
@@ -1,3 +1,4 @@
1
1
  import type { AgentKind, UsageProvider } from '@adecore/agent-contracts';
2
2
  export declare const PROVIDER_PATHS: Record<UsageProvider, string>;
3
- export declare function hasProviderLogo(kind: AgentKind): kind is 'claude' | 'codex';
3
+ export declare function hasProviderLogo(kind: AgentKind): kind is 'claude' | 'codex' | 'anthropic-claude-api';
4
+ export declare function providerFillRule(provider: UsageProvider): 'evenodd' | 'nonzero';
@@ -4,9 +4,14 @@ import { siGithubcopilot } from 'simple-icons';
4
4
  * in `currentColor`, so a row decides how loud the logo is.
5
5
  */
6
6
  const CLAUDE_PATH = 'M4.709 15.955l4.72-2.647.079-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.377-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.048.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.607.212-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.914-1.316-.012.01z';
7
+ /*
8
+ * Claude Code on an API key: the Claude mark with its lower part cut away, over a label with "API" knocked out of it.
9
+ * Plain lines and curves, no text, so another platform can copy the `d` as it is. Its holes need the even-odd rule.
10
+ */
11
+ const CLAUDE_API_PATH = 'M0 11.79L0.05 11.43L0.56 11.11L9.14 11.78L9.5 11.78L9.52 11.77L9.56 11.62L9.26 11.38L4.97 8.51L3.81 7.71L3.45 7.44L3.42 7.43L3.33 7.35L2.96 7.09L2.93 7.08L2.89 7.04L2.34 6.67L1.99 6.22L1.84 5.21L2.48 4.5L2.51 4.49L3.41 4.56L3.61 4.62L6.38 6.77L6.51 6.85L9.24 8.9L9.29 8.89L9.36 8.83L9.39 8.82L9.42 8.74L5.8 2.48L5.54 1.16L6.28 0.14L6.59 0.03L6.73 0L7.68 0.13L8.11 0.5L9.13 2.81L9.15 2.83L9.23 3.03L10.16 4.98L11.39 7.38L11.41 7.4L11.43 7.46L11.75 8.07L12.07 9.13L12.09 9.16L12.24 9.16L12.25 8.8L12.91 1.75L13.28 0.86L13.47 0.72L14.02 0.36L14.1 0.38L14.46 0.55L14.48 0.57L14.54 0.59L14.64 0.65L15.1 1.32L13.83 8.46L14.01 8.46L14.19 8.31L14.44 8.01L15.31 6.86L16.79 5.01L17.98 3.66L18.59 3.04L18.62 3.03L19.04 2.69L20.06 2.69L20.12 2.75L20.84 3.82L20.78 3.99L20.5 4.97L18.78 7.17L17.61 8.73L17.23 9.27L16.5 10.54L16.57 10.64L22.99 9.42L23.83 9.81L23.92 10.22L23.6 11L23.58 11.02L15.89 12.77L15.84 12.8L15.89 12.87L18.1 13.05L19.81 13.05L22.72 13.27L22.91 13.39L22.49 13.31L22.2 13.3L9.43 13.3L9.5 13.07L9.44 12.96L9.41 12.95L9.14 12.95L3.06 12.72L1.2 12.62L0.53 12.48ZM2 14.5H22C23.1 14.5 24 15.4 24 16.5V22C24 23.1 23.1 24 22 24H2C0.9 24 0 23.1 0 22V16.5C0 15.4 0.9 14.5 2 14.5ZM5.91 22.05L7.56 16.45L9.06 16.45L10.71 22.05L9.11 22.05L8.83 21.1L7.79 21.1L7.51 22.05ZM8.31 19.33L8.55 20.15L8.07 20.15ZM11.61 22.05V16.45H13.86C14.82 16.45 15.59 17.22 15.59 18.18C15.59 19.13 14.82 19.9 13.86 19.9H13.21V22.05ZM13.21 17.6H13.81C14.13 17.6 14.39 17.86 14.39 18.17C14.39 18.49 14.13 18.75 13.81 18.75H13.21ZM16.49 16.45H18.09V22.05H16.49Z';
7
12
  export const PROVIDER_PATHS = {
8
13
  claude: CLAUDE_PATH,
9
- 'anthropic-claude-api': CLAUDE_PATH,
14
+ 'anthropic-claude-api': CLAUDE_API_PATH,
10
15
  codex: 'M21.55 10.004a5.416 5.416 0 00-.478-4.501c-1.217-2.09-3.662-3.166-6.05-2.66A5.59 5.59 0 0010.831 1C8.39.995 6.224 2.546 5.473 4.838A5.553 5.553 0 001.76 7.496a5.487 5.487 0 00.691 6.5 5.416 5.416 0 00.477 4.502c1.217 2.09 3.662 3.165 6.05 2.66A5.586 5.586 0 0013.168 23c2.443.006 4.61-1.546 5.361-3.84a5.554 5.554 0 003.715-2.66 5.488 5.488 0 00-.693-6.497v.001zm-8.381 11.558a4.199 4.199 0 01-2.675-.954c.034-.018.093-.05.132-.074l4.44-2.53a.71.71 0 00.364-.623v-6.176l1.877 1.069c.02.01.033.029.036.05v5.115c-.003 2.274-1.87 4.118-4.174 4.123zM4.192 17.78a4.059 4.059 0 01-.498-2.763c.032.019.09.055.131.078l4.44 2.53c.225.13.504.13.73 0l5.42-3.088v2.138a.068.068 0 01-.027.057L9.9 19.288c-1.999 1.136-4.552.46-5.707-1.51h-.001zM3.023 8.216A4.15 4.15 0 015.198 6.41l-.002.151v5.06a.711.711 0 00.364.624l5.42 3.087-1.876 1.07a.067.067 0 01-.063.005l-4.489-2.559c-1.995-1.14-2.679-3.658-1.53-5.63h.001zm15.417 3.54l-5.42-3.088L14.896 7.6a.067.067 0 01.063-.006l4.489 2.557c1.998 1.14 2.683 3.662 1.529 5.633a4.163 4.163 0 01-2.174 1.807V12.38a.71.71 0 00-.363-.623zm1.867-2.773a6.04 6.04 0 00-.132-.078l-4.44-2.53a.731.731 0 00-.729 0l-5.42 3.088V7.325a.068.068 0 01.027-.057L14.1 4.713c2-1.137 4.555-.46 5.707 1.513.487.833.664 1.809.499 2.757h.001zm-11.741 3.81l-1.877-1.068a.065.065 0 01-.036-.051V6.559c.001-2.277 1.873-4.122 4.181-4.12.976 0 1.92.338 2.671.954-.034.018-.092.05-.131.073l-4.44 2.53a.71.71 0 00-.365.623l-.003 6.173v.001zm1.02-2.168L12 9.25l2.414 1.375v2.75L12 14.75l-2.415-1.375v-2.75z',
11
16
  nanogpt: 'M5 20V4h2.6l8.8 11.2V4H19v16h-2.6L7.6 8.8V20z',
12
17
  grok: 'M6.469 8.776 16.512 23h-4.464L2.005 8.776H6.47Zm-.004 7.9 2.233 3.164L6.467 23H2l4.465-6.324ZM22 2.582V23h-3.659V7.764L22 2.582ZM22 1l-9.952 14.095-2.233-3.163L17.533 1H22Z',
@@ -14,5 +19,9 @@ export const PROVIDER_PATHS = {
14
19
  };
15
20
  /* The CLIs drawn with the logo of the usage page rather than their agent mark. */
16
21
  export function hasProviderLogo(kind) {
17
- return kind === 'claude' || kind === 'codex';
22
+ return kind === 'claude' || kind === 'codex' || kind === 'anthropic-claude-api';
23
+ }
24
+ /* The marks whose holes are subpaths inside the shape, which the default nonzero rule would fill. */
25
+ export function providerFillRule(provider) {
26
+ return provider === 'anthropic-claude-api' ? 'evenodd' : 'nonzero';
18
27
  }
@@ -9,7 +9,8 @@ export type { EffortStep } from './logic/effort.js';
9
9
  export { EMPTY_DRAFT, useDrafts, readDraft, writeDraft, offerDraft, type ChatDraft } from './drafts.js';
10
10
  export { stripAnsi } from './logic/ansi.js';
11
11
  export { FORKABLE_PROVIDERS, forkRefusal, summaryRefusal, lastSettledTurn, forkPointOf, forkPointLabel, type ForkShape, forkShapes, type ForkCliChoice, forkPayload, branchRefusal, type ForkPoint, type ForkWorktreeChoice } from './logic/fork.js';
12
- export { matchCommandLook, sentMessageOf, type CommandLookRun, type CommandLookWord } from './logic/command-looks.js';
12
+ export { matchCommandLook, lookRunOf, sentMessageOf, type Look, type LookRun, type CommandLookRun, type CommandLookWord } from './logic/command-looks.js';
13
+ export { mcpCallOf, matchToolLook, type McpCall, type ToolLookRun } from './logic/tool-looks.js';
13
14
  export { handbackReportOf } from './logic/handback.js';
14
15
  export { limitView, type LimitView } from './logic/limit.js';
15
16
  export type { TickKind, ScrubberTick } from './logic/scrubber.js';
@@ -8,7 +8,8 @@ export { stepEffortFromComposer } from './composer-effort.js';
8
8
  export { EMPTY_DRAFT, useDrafts, readDraft, writeDraft, offerDraft } from './drafts.js';
9
9
  export { stripAnsi } from './logic/ansi.js';
10
10
  export { FORKABLE_PROVIDERS, forkRefusal, summaryRefusal, lastSettledTurn, forkPointOf, forkPointLabel, forkShapes, forkPayload, branchRefusal } from './logic/fork.js';
11
- export { matchCommandLook, sentMessageOf } from './logic/command-looks.js';
11
+ export { matchCommandLook, lookRunOf, sentMessageOf } from './logic/command-looks.js';
12
+ export { mcpCallOf, matchToolLook } from './logic/tool-looks.js';
12
13
  export { handbackReportOf } from './logic/handback.js';
13
14
  export { limitView } from './logic/limit.js';
14
15
  export { withTimedRows, timedRowsOf } from './logic/thread-cards.js';
@@ -1,5 +1,5 @@
1
1
  import type { ChatToolItem } from '@adecore/agent-contracts';
2
- import type { CommandLook, CommandLookMatch, CommandLookSent } from '../../host.js';
2
+ import type { CommandLook, CommandLookMatch, CommandLookSent, ToolLook } from '../../host.js';
3
3
  import { type EmbeddedCode } from './embedded-code.js';
4
4
  export interface CommandLookWord {
5
5
  readonly start: number;
@@ -7,18 +7,30 @@ export interface CommandLookWord {
7
7
  readonly text: string;
8
8
  readonly option: string | null;
9
9
  }
10
- export interface CommandLookRun {
11
- readonly look: CommandLook;
12
- readonly match: CommandLookMatch;
10
+ export type Look = CommandLook | ToolLook;
11
+ export interface LookRun {
12
+ readonly look: Look;
13
+ readonly label: string;
14
+ readonly group?: {
15
+ key: string;
16
+ sentence(count: number): string;
17
+ };
13
18
  readonly detail: string;
19
+ readonly shell: boolean;
14
20
  readonly code: readonly EmbeddedCode[];
15
21
  readonly words: readonly CommandLookWord[];
16
22
  readonly others: readonly string[];
17
23
  readonly more: number;
18
24
  readonly heredoc: boolean;
25
+ }
26
+ export interface CommandLookRun extends LookRun {
27
+ readonly look: CommandLook;
28
+ readonly match: CommandLookMatch;
19
29
  readonly args: readonly string[];
20
30
  readonly heredocText: string | null;
21
31
  readonly expands: boolean;
22
32
  }
23
33
  export declare function matchCommandLook(command: string, looks: readonly CommandLook[] | undefined): CommandLookRun | null;
24
- export declare function sentMessageOf(tool: ChatToolItem, looks: readonly CommandLook[] | undefined): CommandLookSent | null;
34
+ export declare function lookRunOf(tool: ChatToolItem, commandLooks: readonly CommandLook[] | undefined, toolLooks: readonly ToolLook[] | undefined): LookRun | null;
35
+ export declare function lookKey(look: Look): string;
36
+ export declare function sentMessageOf(tool: ChatToolItem, looks: readonly CommandLook[] | undefined, toolLooks?: readonly ToolLook[]): CommandLookSent | null;
@@ -1,4 +1,5 @@
1
1
  import { EMBEDDED_CODE_LIMIT, shellCommands } from './embedded-code.js';
2
+ import { matchToolLook } from './tool-looks.js';
2
3
  import { shellCommand } from './tools.js';
3
4
  // A folded value keeps this many characters of what it says.
4
5
  const FOLD_LENGTH = 40;
@@ -160,6 +161,9 @@ function read(command, looks) {
160
161
  return {
161
162
  look: found.look,
162
163
  match: found.match,
164
+ label: found.match.label,
165
+ group: found.match.group,
166
+ shell: true,
163
167
  ...detailOf(command, found.command, found.match),
164
168
  others,
165
169
  more,
@@ -198,17 +202,41 @@ export function matchCommandLook(command, looks) {
198
202
  }
199
203
  return run;
200
204
  }
201
- /* The message a shell call sent, per its look: only for a line that is exactly that one call, whose words are all known. */
202
- export function sentMessageOf(tool, looks) {
205
+ /* The look a call runs under, a program of its shell line before an MCP server, or null for a call no look knows. */
206
+ export function lookRunOf(tool, commandLooks, toolLooks) {
207
+ const command = shellCommand(tool.name, tool.input);
208
+ return (command === null ? null : matchCommandLook(command, commandLooks)) ?? matchToolLook(tool, toolLooks);
209
+ }
210
+ /* What tells looks apart where two may share a group key: the program, or the server. */
211
+ export function lookKey(look) {
212
+ return 'program' in look ? `program:${look.program}` : `server:${look.server}`;
213
+ }
214
+ /*
215
+ * The message a call sent, per its look: for a shell line only when it is exactly that one call, whose
216
+ * words are all known; for an MCP call whenever its look reads one from it.
217
+ */
218
+ export function sentMessageOf(tool, looks, toolLooks) {
203
219
  const command = shellCommand(tool.name, tool.input);
204
220
  const run = command === null ? null : matchCommandLook(command, looks);
205
- if (run === null || run.look.sent === undefined || run.others.length > 0 || run.more > 0 || run.expands) {
221
+ if (run !== null) {
222
+ if (run.look.sent === undefined || run.others.length > 0 || run.more > 0 || run.expands) {
223
+ return null;
224
+ }
225
+ return run.look.sent({
226
+ args: run.args,
227
+ heredoc: run.heredocText,
228
+ state: tool.state,
229
+ output: tool.output
230
+ });
231
+ }
232
+ const called = matchToolLook(tool, toolLooks);
233
+ if (called === null || called.look.sent === undefined) {
206
234
  return null;
207
235
  }
208
- return run.look.sent({
209
- args: run.args,
210
- heredoc: run.heredocText,
236
+ return called.look.sent({
237
+ tool: called.call.tool,
238
+ input: called.call.input,
211
239
  state: tool.state,
212
- output: tool.output
240
+ output: called.call.output
213
241
  });
214
242
  }
@@ -1,5 +1,6 @@
1
1
  import type { ChatApprovalItem, ChatAssistantItem, ChatCheckpointDiff, ChatItem, ChatNoteMessage, ChatQuestionItem, ChatSubagentItem, ChatThinkingItem, ChatToolItem, ChatTurnItem, ChatUserItem, ChatVisual, ChatWorkflow } from '@adecore/agent-contracts';
2
- import type { CommandLook, CommandLookSent, ThreadCard } from '../../host.js';
2
+ import type { CommandLook, CommandLookSent, ThreadCard, ToolLook } from '../../host.js';
3
+ import { type Look } from './command-looks.js';
3
4
  export interface SubagentBranch {
4
5
  id: string;
5
6
  item: ChatSubagentItem;
@@ -38,7 +39,7 @@ export type TimelineRow = {
38
39
  tools: ChatToolItem[];
39
40
  summary: string;
40
41
  expanded: boolean;
41
- look?: CommandLook;
42
+ look?: Look;
42
43
  } | {
43
44
  kind: 'work-live';
44
45
  id: string;
@@ -127,11 +128,12 @@ interface TimelineOptions {
127
128
  activeTurnId: string | null;
128
129
  forkedTurns?: ReadonlySet<string>;
129
130
  commandLooks?: readonly CommandLook[];
131
+ toolLooks?: readonly ToolLook[];
130
132
  hideTools?: boolean;
131
133
  }
132
134
  export declare function isBlock(row: TimelineRow): boolean;
133
- export declare function summarizeGroup(tools: ChatToolItem[], looks?: readonly CommandLook[]): string;
134
- export declare function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly CommandLook[]): string[];
135
+ export declare function summarizeGroup(tools: ChatToolItem[], looks?: readonly CommandLook[], toolLooks?: readonly ToolLook[]): string;
136
+ export declare function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly CommandLook[], toolLooks?: readonly ToolLook[]): string[];
135
137
  export declare function agentTurnLabel(turn: ChatTurnItem): string;
136
138
  export declare function turnLabel(turn: ChatTurnItem, items?: readonly ChatItem[]): string;
137
139
  export declare function findSubagentBranch(rows: readonly TimelineRow[], toolUseId: string): {
@@ -1,11 +1,11 @@
1
1
  import i18next from 'i18next';
2
2
  import { abortedByMachine } from '@adecore/agent-contracts';
3
3
  import { formatElapsedShort } from '@adecore/ui/format';
4
- import { matchCommandLook, sentMessageOf } from './command-looks.js';
4
+ import { lookKey, lookRunOf, sentMessageOf } from './command-looks.js';
5
5
  import { isImageGeneration } from './generated-image.js';
6
6
  import { handbackReportOf } from './handback.js';
7
7
  import { toolEntry } from './tool-catalog.js';
8
- import { hasFileChanges, isFileChange, shellCommand } from './tools.js';
8
+ import { hasFileChanges, isFileChange } from './tools.js';
9
9
  const TOOL_KINDS = new Set(['work', 'work-group', 'work-live']);
10
10
  // A generated image is drawn as a tool call but reads as the turn's result, so it stays.
11
11
  function shownRows(rows, options) {
@@ -21,23 +21,22 @@ export function isBlock(row) {
21
21
  return BLOCK_KINDS.has(row.kind) || isImageRow(row);
22
22
  }
23
23
  /*
24
- * The sentence of a run of shell calls that are all runs of one look: its group's when they share a key,
25
- * else the look's own; null for any other run, which reads as shell calls.
24
+ * The sentence of a run of calls that are all runs of one look: its group's when they share a key,
25
+ * else the look's own; null for any other run, which reads as its calls.
26
26
  */
27
- function lookSummary(tools, looks) {
27
+ function lookSummary(tools, looks, toolLooks) {
28
28
  let look = null;
29
29
  let group;
30
30
  let sameKey = true;
31
31
  for (const tool of tools) {
32
- const command = shellCommand(tool.name, tool.input);
33
- const run = command === null ? null : matchCommandLook(command, looks);
32
+ const run = lookRunOf(tool, looks, toolLooks);
34
33
  if (run === null || look !== null && run.look !== look) {
35
34
  return null;
36
35
  }
37
36
  if (look === null) {
38
37
  look = run.look;
39
- group = run.match.group;
40
- } else if (run.match.group?.key !== group?.key) {
38
+ group = run.group;
39
+ } else if (run.group?.key !== group?.key) {
41
40
  sameKey = false;
42
41
  }
43
42
  }
@@ -56,8 +55,8 @@ function lookSummary(tools, looks) {
56
55
  };
57
56
  }
58
57
  /* "Read 4 files", "Ran 2 commands", "12 tool calls" when the run mixes kinds, or the sentence of a look all its calls are runs of. */
59
- export function summarizeGroup(tools, looks) {
60
- const looked = lookSummary(tools, looks);
58
+ export function summarizeGroup(tools, looks, toolLooks) {
59
+ const looked = lookSummary(tools, looks, toolLooks);
61
60
  if (looked !== null) {
62
61
  return looked.summary;
63
62
  }
@@ -98,7 +97,7 @@ function editedPath(tool) {
98
97
  * "Searched 2 patterns". Every file change reads as one sentence, and calls without a sentence of
99
98
  * their own are counted together at the end.
100
99
  */
101
- export function summarizeTurn(tools, looks) {
100
+ export function summarizeTurn(tools, looks, toolLooks) {
102
101
  // Keyed by the sentence, so its place is where the first call of that kind came.
103
102
  const counts = new Map();
104
103
  const add = (key, say, total) => {
@@ -115,10 +114,9 @@ export function summarizeTurn(tools, looks) {
115
114
  const edited = new Set();
116
115
  let other = 0;
117
116
  for (const tool of tools) {
118
- const command = shellCommand(tool.name, tool.input);
119
- const run = command === null ? null : matchCommandLook(command, looks);
120
- const group = run?.match.group;
121
- const sent = sentMessageOf(tool, looks);
117
+ const run = lookRunOf(tool, looks, toolLooks);
118
+ const group = run?.group;
119
+ const sent = sentMessageOf(tool, looks, toolLooks);
122
120
  if (sent !== null && sent.state !== 'failed') {
123
121
  add('agent-chat:group.sent', count => i18next.t('agent-chat:group.sent', {
124
122
  count
@@ -126,8 +124,8 @@ export function summarizeTurn(tools, looks) {
126
124
  } else if (sent !== null) {
127
125
  other += 1;
128
126
  } else if (run !== null && group !== undefined) {
129
- // Keyed by the program too, so two looks with a key in common keep their own sentences.
130
- add(`look:${run.look.program}:${group.key}`, group.sentence);
127
+ // Keyed by the look too, so two looks with a key in common keep their own sentences.
128
+ add(`look:${lookKey(run.look)}:${group.key}`, group.sentence);
131
129
  } else if (failedFileChange(tool)) {
132
130
  other += 1;
133
131
  } else if (isFileChange(tool.name)) {
@@ -176,9 +174,15 @@ export function agentTurnLabel(turn) {
176
174
  count: turn.messageFrom.length
177
175
  }));
178
176
  }
179
- return turn.label ? i18next.t('agent-chat:turn.subagentFinished', {
177
+ if (!turn.label) {
178
+ return i18next.t('agent-chat:turn.continued');
179
+ }
180
+ // The machine names the subagent row a wake is about; Claude Code also wakes the agent for a command, a monitor or a
181
+ // workflow it ran in the background, which has no such row.
182
+ const key = turn.taskToolUseId === undefined ? 'agent-chat:turn.backgroundFinished' : 'agent-chat:turn.subagentFinished';
183
+ return i18next.t(key, {
180
184
  label: turn.label
181
- }) : i18next.t('agent-chat:turn.continued');
185
+ });
182
186
  }
183
187
  /* The items of the turn tell a turn a person stopped from one the machine ended after a restart. */
184
188
  export function turnLabel(turn, items = []) {
@@ -267,7 +271,7 @@ function flushTools(buffer, rows, options) {
267
271
  const first = tools[0];
268
272
  const id = `group-${first.id}`;
269
273
  const expanded = options.expandedGroups.has(id);
270
- const looked = lookSummary(tools, options.commandLooks);
274
+ const looked = lookSummary(tools, options.commandLooks, options.toolLooks);
271
275
  rows.push(looked === null ? {
272
276
  kind: 'work-group',
273
277
  id,
@@ -304,7 +308,7 @@ function rowsForItems(items, options, children) {
304
308
  continue;
305
309
  }
306
310
  const report = handbackReportOf(item);
307
- const sent = item.kind === 'tool' ? sentMessageOf(item, options.commandLooks) : null;
311
+ const sent = item.kind === 'tool' ? sentMessageOf(item, options.commandLooks, options.toolLooks) : null;
308
312
  if (item.kind === 'tool' && sent !== null) {
309
313
  flushTools(tools, rows, options);
310
314
  rows.push({
@@ -605,11 +609,14 @@ export function deriveTimelineRows(items, options) {
605
609
  const rest = conversation.slice(lastUser + 1);
606
610
  const work = rowsForItems(rest, options, children);
607
611
  // The closing answer stays visible; the work after the last input folds behind the label.
608
- const finalAssistant = lastAssistantRow(work);
612
+ // A turn the machine ended mid-call has no closing answer, but what it last said is still the most a person can read of it.
613
+ const cutShort = turn.state === 'aborted' && abortedByMachine(turn, chunk.items);
614
+ const finalAssistant = lastAssistantRow(work) ?? (cutShort ? work.findLast(row => row.kind === 'assistant') ?? null : null);
609
615
  const closing = finalAssistant ? work.indexOf(finalAssistant) : work.length;
610
616
  const before = work.slice(0, closing);
611
617
  // Images remain a turn's visible result, and a workflow or a background subagent may still be running after its turn ends.
612
- const standing = before.filter(row => isImageRow(row) || row.kind === 'workflow' && row.tool.state === 'running' || row.kind === 'subagent' && row.item.status === 'running');
618
+ // A compaction is never folded away, so a turn that only compacted shows its divider and no fold.
619
+ const standing = before.filter(row => isImageRow(row) || row.kind === 'compaction' || row.kind === 'workflow' && row.tool.state === 'running' || row.kind === 'subagent' && row.item.status === 'running');
613
620
  const folded = before.length - standing.length;
614
621
  // With the tool lines left out, a turn that only ran tools has nothing behind its fold to open.
615
622
  const expandable = shownRows(before, options).some(row => !standing.includes(row));
@@ -621,7 +628,7 @@ export function deriveTimelineRows(items, options) {
621
628
  id: `fold-${turnId}`,
622
629
  turn,
623
630
  label: turnLabel(turn, chunk.items),
624
- work: summarizeTurn(tools, options.commandLooks),
631
+ work: summarizeTurn(tools, options.commandLooks, options.toolLooks),
625
632
  hiddenCount: folded,
626
633
  expanded,
627
634
  expandable
@@ -0,0 +1,16 @@
1
+ import type { ChatToolItem } from '@adecore/agent-contracts';
2
+ import type { ToolLook, ToolLookMatch } from '../../host.js';
3
+ import type { LookRun } from './command-looks.js';
4
+ export interface McpCall {
5
+ readonly server: string;
6
+ readonly tool: string;
7
+ readonly input: Readonly<Record<string, unknown>>;
8
+ readonly output: string | null;
9
+ }
10
+ export interface ToolLookRun extends LookRun {
11
+ readonly look: ToolLook;
12
+ readonly match: ToolLookMatch;
13
+ readonly call: McpCall;
14
+ }
15
+ export declare function mcpCallOf(item: Pick<ChatToolItem, 'name' | 'input' | 'output'>, servers: readonly string[]): McpCall | null;
16
+ export declare function matchToolLook(item: ChatToolItem, looks: readonly ToolLook[] | undefined): ToolLookRun | null;