@adecore/agents-react 0.51.0 → 0.52.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.
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/index.js +2 -1
- package/dist/chat/logic/command-looks.d.ts +17 -5
- package/dist/chat/logic/command-looks.js +35 -7
- package/dist/chat/logic/timeline.d.ts +6 -4
- package/dist/chat/logic/timeline.js +19 -21
- package/dist/chat/logic/tool-looks.d.ts +16 -0
- package/dist/chat/logic/tool-looks.js +188 -0
- package/dist/chat/ui/ShellCommand.d.ts +2 -1
- package/dist/chat/ui/ShellCommand.js +73 -22
- package/dist/chat/ui/SubagentTimeline.js +5 -2
- package/dist/chat/ui/Timeline.js +2 -1
- package/dist/chat/ui/rows/RowContainer.js +26 -23
- package/dist/chat/ui/rows/WorkRows.d.ts +3 -4
- package/dist/chat/ui/rows/WorkRows.js +592 -519
- package/dist/chat/ui/rows/row-rhythm.d.ts +2 -2
- package/dist/chat/ui/rows/row-rhythm.js +9 -6
- package/dist/chat/ui/thread-references.d.ts +1 -0
- package/dist/chat/ui/thread-references.js +4 -3
- package/dist/host.d.ts +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +3 -0
- package/dist/locales/en/agent-chat.js +3 -0
- package/dist/locales/nl/agent-chat.d.ts +3 -0
- package/dist/locales/nl/agent-chat.js +3 -0
- package/package.json +8 -8
- package/src/chat/index.ts +2 -1
- package/src/chat/logic/command-looks.ts +51 -10
- package/src/chat/logic/timeline.ts +28 -24
- package/src/chat/logic/tool-looks.ts +228 -0
- package/src/chat/ui/ShellCommand.tsx +33 -6
- package/src/chat/ui/SubagentTimeline.tsx +3 -2
- package/src/chat/ui/Timeline.tsx +2 -1
- package/src/chat/ui/rows/RowContainer.tsx +4 -2
- package/src/chat/ui/rows/WorkRows.tsx +46 -33
- package/src/chat/ui/rows/row-rhythm.ts +9 -6
- package/src/chat/ui/thread-references.ts +5 -1
- package/src/host.ts +51 -0
- package/src/index.ts +3 -0
- package/src/locales/en/agent-chat.ts +3 -0
- package/src/locales/nl/agent-chat.ts +3 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
2
|
import { type TimelineRow } from '../../logic/timeline.js';
|
|
3
3
|
export declare const FOLLOW_THRESHOLD_PX = 40;
|
|
4
|
-
export declare function saidToChat(row: TimelineRow): boolean;
|
|
5
|
-
export declare function rowRhythm(row: TimelineRow, previous: TimelineRow | null): string;
|
|
4
|
+
export declare function saidToChat(row: TimelineRow, hostSpeaks?: boolean): boolean;
|
|
5
|
+
export declare function rowRhythm(row: TimelineRow, previous: TimelineRow | null, hostSpeaks?: boolean): string;
|
|
6
6
|
export declare function replyHeader(row: TimelineRow, previous: TimelineRow | null): {
|
|
7
7
|
at: number | null;
|
|
8
8
|
} | null;
|
|
@@ -7,14 +7,17 @@ export const FOLLOW_THRESHOLD_PX = 40;
|
|
|
7
7
|
* card, which have no margin of their own, and each end of a run of sent messages, which sit as tight as
|
|
8
8
|
* work lines so a fan-out reads as one stretch. A question and the answer after it never take a seam.
|
|
9
9
|
*/
|
|
10
|
-
/*
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/*
|
|
11
|
+
* A person's message, or one another node sent: both are said to the chat and drawn the same way. So is a note
|
|
12
|
+
* the host said, where `hostSpeaks` says the host draws it as a message (`ChatHost.saidBy`).
|
|
13
|
+
*/
|
|
14
|
+
export function saidToChat(row, hostSpeaks = false) {
|
|
15
|
+
return row.kind === 'user' || row.kind === 'message' || hostSpeaks && row.kind === 'note' && row.said === true;
|
|
13
16
|
}
|
|
14
|
-
export function rowRhythm(row, previous) {
|
|
15
|
-
const question = saidToChat(row);
|
|
17
|
+
export function rowRhythm(row, previous, hostSpeaks = false) {
|
|
18
|
+
const question = saidToChat(row, hostSpeaks);
|
|
16
19
|
const bare = previous?.kind === 'visual' || previous?.kind === 'app-card';
|
|
17
|
-
const seam = !question && previous !== null && !saidToChat(previous) && (isBlock(row) !== isBlock(previous) || bare || row.kind === 'sent' !== (previous.kind === 'sent'));
|
|
20
|
+
const seam = !question && previous !== null && !saidToChat(previous, hostSpeaks) && (isBlock(row) !== isBlock(previous) || bare || row.kind === 'sent' !== (previous.kind === 'sent'));
|
|
18
21
|
return clsx(question && 'pb-(--chat-answer-gap)', seam && 'pt-(--chat-block-gap)');
|
|
19
22
|
}
|
|
20
23
|
/*
|
|
@@ -2,3 +2,4 @@ import type { ChatItem } from '@adecore/agent-contracts';
|
|
|
2
2
|
import type { ReferenceLookup } from './reference-lookup.js';
|
|
3
3
|
export declare function threadReferencedKey(structure: Record<string, ChatItem> | undefined): string;
|
|
4
4
|
export declare function useReferenceLookup(chatId: string): ReferenceLookup;
|
|
5
|
+
export declare function useReferenceLookupIn(scopeId: string, chatId: string): ReferenceLookup;
|
|
@@ -31,10 +31,11 @@ export function threadReferencedKey(structure) {
|
|
|
31
31
|
}
|
|
32
32
|
/* What the views, nodes and chats of a thread stand for now, and how one opens, for the rows that draw chips. */
|
|
33
33
|
export function useReferenceLookup(chatId) {
|
|
34
|
+
return useReferenceLookupIn(useChatScope().id, chatId);
|
|
35
|
+
}
|
|
36
|
+
/* The same for a row that may stand outside a scope. */
|
|
37
|
+
export function useReferenceLookupIn(scopeId, chatId) {
|
|
34
38
|
const $ = _c(9);
|
|
35
|
-
const {
|
|
36
|
-
id: scopeId
|
|
37
|
-
} = useChatScope();
|
|
38
39
|
const {
|
|
39
40
|
openReference
|
|
40
41
|
} = useChatHost();
|
package/dist/host.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ export interface ReplyAuthor {
|
|
|
167
167
|
export interface CommandName {
|
|
168
168
|
name: string;
|
|
169
169
|
icon?: ReactNode;
|
|
170
|
+
reference?: string;
|
|
170
171
|
}
|
|
171
172
|
export interface CommandLookMatch {
|
|
172
173
|
label: string;
|
|
@@ -203,6 +204,32 @@ export interface CommandLook {
|
|
|
203
204
|
useNames?(scopeId: string, chatId: string): (word: string, option: string | null) => CommandName | null;
|
|
204
205
|
sent?(call: CommandLookCall): CommandLookSent | null;
|
|
205
206
|
}
|
|
207
|
+
export interface ToolLookMatch {
|
|
208
|
+
label: string;
|
|
209
|
+
lead?: string;
|
|
210
|
+
fields?: readonly string[];
|
|
211
|
+
group?: {
|
|
212
|
+
key: string;
|
|
213
|
+
sentence(count: number): string;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export interface ToolLookCall {
|
|
217
|
+
readonly tool: string;
|
|
218
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
219
|
+
readonly state: 'running' | 'done' | 'error';
|
|
220
|
+
readonly output: string | null;
|
|
221
|
+
}
|
|
222
|
+
export interface ToolLook {
|
|
223
|
+
server: string;
|
|
224
|
+
brand?: string;
|
|
225
|
+
Mark: ComponentType<{
|
|
226
|
+
size: number;
|
|
227
|
+
}>;
|
|
228
|
+
describe(tool: string, input: Readonly<Record<string, unknown>>): ToolLookMatch | null;
|
|
229
|
+
sentence?(count: number): string;
|
|
230
|
+
useNames?(scopeId: string, chatId: string): (word: string, option: string | null) => CommandName | null;
|
|
231
|
+
sent?(call: ToolLookCall): CommandLookSent | null;
|
|
232
|
+
}
|
|
206
233
|
export type UiMapSource = {
|
|
207
234
|
state: 'tiles';
|
|
208
235
|
styleUrl(theme: 'light' | 'dark'): string;
|
|
@@ -371,6 +398,7 @@ export interface ChatHost {
|
|
|
371
398
|
saidBy?: ReplyAuthor;
|
|
372
399
|
visuals: VisualHost | null;
|
|
373
400
|
commandLooks?: readonly CommandLook[];
|
|
401
|
+
toolLooks?: readonly ToolLook[];
|
|
374
402
|
}
|
|
375
403
|
export declare function ChatHostProvider({ host, children }: {
|
|
376
404
|
host: Partial<ChatHost>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type ComposerSendAction, type ComposerSendDraft, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
1
|
+
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type ComposerSendAction, type ComposerSendDraft, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
2
2
|
export { type ChatScope, ChatScopeContext, useChatScope } from './scope.js';
|
|
3
3
|
export { type ChatRequestMap, type ChatEventMap, type ChatTransportStatus, type ChatTransport, ChatTransportError, errorCode, isConnectionError } from './transport.js';
|
|
4
4
|
export { portTransport, type PortTransport } from './port-transport.js';
|
|
@@ -213,6 +213,7 @@ declare const _default: {
|
|
|
213
213
|
loadingDiff: string;
|
|
214
214
|
diffUnavailable: string;
|
|
215
215
|
runningFor: string;
|
|
216
|
+
failed: string;
|
|
216
217
|
awaitingApproval: string;
|
|
217
218
|
forksAfter_one: string;
|
|
218
219
|
forksAfter_other: string;
|
|
@@ -273,6 +274,8 @@ declare const _default: {
|
|
|
273
274
|
group: {
|
|
274
275
|
running_one: string;
|
|
275
276
|
running_other: string;
|
|
277
|
+
failed_one: string;
|
|
278
|
+
failed_other: string;
|
|
276
279
|
tools: {
|
|
277
280
|
Read_one: string;
|
|
278
281
|
Read_other: string;
|
|
@@ -213,6 +213,7 @@ export default {
|
|
|
213
213
|
loadingDiff: 'Loading diff',
|
|
214
214
|
diffUnavailable: 'Could not load this diff',
|
|
215
215
|
runningFor: 'running for {{elapsed}}',
|
|
216
|
+
failed: 'Failed',
|
|
216
217
|
awaitingApproval: 'waiting for you',
|
|
217
218
|
forksAfter_one: 'Forked after this turn',
|
|
218
219
|
forksAfter_other: '{{count}} forks after this turn',
|
|
@@ -273,6 +274,8 @@ export default {
|
|
|
273
274
|
group: {
|
|
274
275
|
running_one: '{{count}} running',
|
|
275
276
|
running_other: '{{count}} running',
|
|
277
|
+
failed_one: '{{count}} failed',
|
|
278
|
+
failed_other: '{{count}} failed',
|
|
276
279
|
tools: {
|
|
277
280
|
Read_one: 'Read {{count}} file',
|
|
278
281
|
Read_other: 'Read {{count}} files',
|
|
@@ -213,6 +213,7 @@ declare const _default: {
|
|
|
213
213
|
loadingDiff: string;
|
|
214
214
|
diffUnavailable: string;
|
|
215
215
|
runningFor: string;
|
|
216
|
+
failed: string;
|
|
216
217
|
awaitingApproval: string;
|
|
217
218
|
forksAfter_one: string;
|
|
218
219
|
forksAfter_other: string;
|
|
@@ -273,6 +274,8 @@ declare const _default: {
|
|
|
273
274
|
group: {
|
|
274
275
|
running_one: string;
|
|
275
276
|
running_other: string;
|
|
277
|
+
failed_one: string;
|
|
278
|
+
failed_other: string;
|
|
276
279
|
tools: {
|
|
277
280
|
Read_one: string;
|
|
278
281
|
Read_other: string;
|
|
@@ -213,6 +213,7 @@ export default {
|
|
|
213
213
|
loadingDiff: 'Diff laden',
|
|
214
214
|
diffUnavailable: 'Kon deze diff niet laden',
|
|
215
215
|
runningFor: 'loopt al {{elapsed}}',
|
|
216
|
+
failed: 'Mislukt',
|
|
216
217
|
awaitingApproval: 'wacht op jou',
|
|
217
218
|
forksAfter_one: 'Fork na deze turn',
|
|
218
219
|
forksAfter_other: '{{count}} forks na deze turn',
|
|
@@ -273,6 +274,8 @@ export default {
|
|
|
273
274
|
group: {
|
|
274
275
|
running_one: '{{count}} actief',
|
|
275
276
|
running_other: '{{count}} actief',
|
|
277
|
+
failed_one: '{{count}} mislukt',
|
|
278
|
+
failed_other: '{{count}} mislukt',
|
|
276
279
|
tools: {
|
|
277
280
|
Read_one: '{{count}} bestand gelezen',
|
|
278
281
|
Read_other: '{{count}} bestanden gelezen',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,11 +72,11 @@
|
|
|
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.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.52.0",
|
|
76
|
+
"@adecore/editor": "0.52.0",
|
|
77
|
+
"@adecore/editor-react": "0.52.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.52.0",
|
|
79
|
+
"@adecore/merge": "0.52.0",
|
|
80
80
|
"@codemirror/commands": "^6.11.1",
|
|
81
81
|
"@codemirror/language": "^6.13.1",
|
|
82
82
|
"@codemirror/state": "^6.7.6",
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"zustand": "^5.0.16"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@adecore/ui": "^0.
|
|
103
|
+
"@adecore/ui": "^0.52.0",
|
|
104
104
|
"i18next": "^26.4.2",
|
|
105
105
|
"react": "^19.3.0",
|
|
106
106
|
"react-dom": "^19.3.0",
|
|
107
107
|
"react-i18next": "^17.0.15"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@adecore/ui": "0.
|
|
110
|
+
"@adecore/ui": "0.52.0",
|
|
111
111
|
"@types/bun": "^1.4.4",
|
|
112
112
|
"@types/react": "^19.3.0",
|
|
113
113
|
"@types/react-dom": "^19.3.0",
|
package/src/chat/index.ts
CHANGED
|
@@ -26,7 +26,8 @@ export {
|
|
|
26
26
|
type ForkWorktreeChoice
|
|
27
27
|
} from './logic/fork';
|
|
28
28
|
|
|
29
|
-
export { matchCommandLook, sentMessageOf, type CommandLookRun, type CommandLookWord } from './logic/command-looks';
|
|
29
|
+
export { matchCommandLook, lookRunOf, sentMessageOf, type Look, type LookRun, type CommandLookRun, type CommandLookWord } from './logic/command-looks';
|
|
30
|
+
export { mcpCallOf, matchToolLook, type McpCall, type ToolLookRun } from './logic/tool-looks';
|
|
30
31
|
export { handbackReportOf } from './logic/handback';
|
|
31
32
|
export { limitView, type LimitView } from './logic/limit';
|
|
32
33
|
export type { TickKind, ScrubberTick } from './logic/scrubber';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ChatToolItem } from '@adecore/agent-contracts';
|
|
2
|
-
import type { CommandLook, CommandLookMatch, CommandLookSent } from '../../host';
|
|
2
|
+
import type { CommandLook, CommandLookMatch, CommandLookSent, ToolLook } from '../../host';
|
|
3
3
|
import { EMBEDDED_CODE_LIMIT, shellCommands, type EmbeddedCode, type ShellSimpleCommand, type ShellWord } from './embedded-code';
|
|
4
|
+
import { matchToolLook } from './tool-looks';
|
|
4
5
|
import { shellCommand } from './tools';
|
|
5
6
|
|
|
6
7
|
// A folded value keeps this many characters of what it says.
|
|
@@ -18,12 +19,18 @@ export interface CommandLookWord {
|
|
|
18
19
|
readonly option: string | null;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
/* A
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/* A look of the host's own: a program in a shell call, or an MCP server. */
|
|
23
|
+
export type Look = CommandLook | ToolLook;
|
|
24
|
+
|
|
25
|
+
/* A call read as a look's tool, as its row draws it, whether a shell line or an MCP call. */
|
|
26
|
+
export interface LookRun {
|
|
27
|
+
readonly look: Look;
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly group?: { key: string; sentence(count: number): string };
|
|
30
|
+
/* What follows the label: the source from the detail word on, or the fields of an MCP call, with long values shortened. */
|
|
26
31
|
readonly detail: string;
|
|
32
|
+
/* Whether the detail is shell source, drawn in the colors of the code theme. */
|
|
33
|
+
readonly shell: boolean;
|
|
27
34
|
/* The values the match names a language for, as offsets into the detail. */
|
|
28
35
|
readonly code: readonly EmbeddedCode[];
|
|
29
36
|
/* The words of the detail that are no option. */
|
|
@@ -34,6 +41,12 @@ export interface CommandLookRun {
|
|
|
34
41
|
readonly more: number;
|
|
35
42
|
/* Whether the command is fed a heredoc, which the detail leaves out. */
|
|
36
43
|
readonly heredoc: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* A shell call read as a tool of its own: the first command of the line a look knows. */
|
|
47
|
+
export interface CommandLookRun extends LookRun {
|
|
48
|
+
readonly look: CommandLook;
|
|
49
|
+
readonly match: CommandLookMatch;
|
|
37
50
|
/* The words after the program, quotes taken out. */
|
|
38
51
|
readonly args: readonly string[];
|
|
39
52
|
/* The lines of its one heredoc, or null without one, with more, or with one the shell fills in. */
|
|
@@ -190,6 +203,9 @@ function read(command: string, looks: readonly CommandLook[]): CommandLookRun |
|
|
|
190
203
|
return {
|
|
191
204
|
look: found.look,
|
|
192
205
|
match: found.match,
|
|
206
|
+
label: found.match.label,
|
|
207
|
+
group: found.match.group,
|
|
208
|
+
shell: true,
|
|
193
209
|
...detailOf(command, found.command, found.match),
|
|
194
210
|
others,
|
|
195
211
|
more,
|
|
@@ -233,14 +249,39 @@ export function matchCommandLook(command: string, looks: readonly CommandLook[]
|
|
|
233
249
|
return run;
|
|
234
250
|
}
|
|
235
251
|
|
|
236
|
-
/* The
|
|
237
|
-
export function
|
|
252
|
+
/* The look a call runs under, a program of its shell line before an MCP server, or null for a call no look knows. */
|
|
253
|
+
export function lookRunOf(tool: ChatToolItem, commandLooks: readonly CommandLook[] | undefined, toolLooks: readonly ToolLook[] | undefined): LookRun | null {
|
|
254
|
+
const command = shellCommand(tool.name, tool.input);
|
|
255
|
+
|
|
256
|
+
return (command === null ? null : matchCommandLook(command, commandLooks)) ?? matchToolLook(tool, toolLooks);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* What tells looks apart where two may share a group key: the program, or the server. */
|
|
260
|
+
export function lookKey(look: Look): string {
|
|
261
|
+
return 'program' in look ? `program:${look.program}` : `server:${look.server}`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/*
|
|
265
|
+
* The message a call sent, per its look: for a shell line only when it is exactly that one call, whose
|
|
266
|
+
* words are all known; for an MCP call whenever its look reads one from it.
|
|
267
|
+
*/
|
|
268
|
+
export function sentMessageOf(tool: ChatToolItem, looks: readonly CommandLook[] | undefined, toolLooks?: readonly ToolLook[]): CommandLookSent | null {
|
|
238
269
|
const command = shellCommand(tool.name, tool.input);
|
|
239
270
|
const run = command === null ? null : matchCommandLook(command, looks);
|
|
240
271
|
|
|
241
|
-
if (run
|
|
272
|
+
if (run !== null) {
|
|
273
|
+
if (run.look.sent === undefined || run.others.length > 0 || run.more > 0 || run.expands) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return run.look.sent({ args: run.args, heredoc: run.heredocText, state: tool.state, output: tool.output });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const called = matchToolLook(tool, toolLooks);
|
|
281
|
+
|
|
282
|
+
if (called === null || called.look.sent === undefined) {
|
|
242
283
|
return null;
|
|
243
284
|
}
|
|
244
285
|
|
|
245
|
-
return
|
|
286
|
+
return called.look.sent({ tool: called.call.tool, input: called.call.input, state: tool.state, output: called.call.output });
|
|
246
287
|
}
|
|
@@ -15,13 +15,13 @@ import type {
|
|
|
15
15
|
ChatWorkflow
|
|
16
16
|
} from '@adecore/agent-contracts';
|
|
17
17
|
import { abortedByMachine } from '@adecore/agent-contracts';
|
|
18
|
-
import type { CommandLook, CommandLookSent, ThreadCard } from '../../host';
|
|
18
|
+
import type { CommandLook, CommandLookSent, ThreadCard, ToolLook } from '../../host';
|
|
19
19
|
import { formatElapsedShort } from '@adecore/ui/format';
|
|
20
|
-
import {
|
|
20
|
+
import { lookKey, lookRunOf, sentMessageOf, type Look } from './command-looks';
|
|
21
21
|
import { isImageGeneration } from './generated-image';
|
|
22
22
|
import { handbackReportOf } from './handback';
|
|
23
23
|
import { toolEntry } from './tool-catalog';
|
|
24
|
-
import { hasFileChanges, isFileChange
|
|
24
|
+
import { hasFileChanges, isFileChange } from './tools';
|
|
25
25
|
|
|
26
26
|
/* A subagent's row: the work the thread kept of it, and the agents it opened in turn, each a row of its own under it. */
|
|
27
27
|
export interface SubagentBranch {
|
|
@@ -46,7 +46,7 @@ export type TimelineRow =
|
|
|
46
46
|
| { kind: 'thinking'; id: string; item: ChatThinkingItem }
|
|
47
47
|
| { kind: 'work'; id: string; tool: ChatToolItem }
|
|
48
48
|
// `look` is set when every call is a run of that look and the summary is its sentence.
|
|
49
|
-
| { kind: 'work-group'; id: string; tools: ChatToolItem[]; summary: string; expanded: boolean; look?:
|
|
49
|
+
| { kind: 'work-group'; id: string; tools: ChatToolItem[]; summary: string; expanded: boolean; look?: Look }
|
|
50
50
|
| { kind: 'work-live'; id: string; tool: ChatToolItem }
|
|
51
51
|
// The latest thought of a running turn, repeated over the call it led to; `at` is when that call began.
|
|
52
52
|
| { kind: 'live-thought'; id: string; item: ChatThinkingItem; at: number }
|
|
@@ -89,6 +89,8 @@ interface TimelineOptions {
|
|
|
89
89
|
forkedTurns?: ReadonlySet<string>;
|
|
90
90
|
/* The host's programs drawn as tools of their own, whose runs read as their own sentences. */
|
|
91
91
|
commandLooks?: readonly CommandLook[];
|
|
92
|
+
/* The host's MCP servers drawn as tools of their own, read the same way. */
|
|
93
|
+
toolLooks?: readonly ToolLook[];
|
|
92
94
|
/* Leaves out the tool lines and their groups, while a settled turn still says how long it worked. */
|
|
93
95
|
hideTools?: boolean;
|
|
94
96
|
}
|
|
@@ -112,17 +114,20 @@ export function isBlock(row: TimelineRow): boolean {
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/*
|
|
115
|
-
* The sentence of a run of
|
|
116
|
-
* else the look's own; null for any other run, which reads as
|
|
117
|
+
* The sentence of a run of calls that are all runs of one look: its group's when they share a key,
|
|
118
|
+
* else the look's own; null for any other run, which reads as its calls.
|
|
117
119
|
*/
|
|
118
|
-
function lookSummary(
|
|
119
|
-
|
|
120
|
+
function lookSummary(
|
|
121
|
+
tools: readonly ChatToolItem[],
|
|
122
|
+
looks: readonly CommandLook[] | undefined,
|
|
123
|
+
toolLooks: readonly ToolLook[] | undefined
|
|
124
|
+
): { look: Look; summary: string } | null {
|
|
125
|
+
let look: Look | null = null;
|
|
120
126
|
let group: { key: string; sentence(count: number): string } | undefined;
|
|
121
127
|
let sameKey = true;
|
|
122
128
|
|
|
123
129
|
for (const tool of tools) {
|
|
124
|
-
const
|
|
125
|
-
const run = command === null ? null : matchCommandLook(command, looks);
|
|
130
|
+
const run = lookRunOf(tool, looks, toolLooks);
|
|
126
131
|
|
|
127
132
|
if (run === null || (look !== null && run.look !== look)) {
|
|
128
133
|
return null;
|
|
@@ -130,8 +135,8 @@ function lookSummary(tools: readonly ChatToolItem[], looks: readonly CommandLook
|
|
|
130
135
|
|
|
131
136
|
if (look === null) {
|
|
132
137
|
look = run.look;
|
|
133
|
-
group = run.
|
|
134
|
-
} else if (run.
|
|
138
|
+
group = run.group;
|
|
139
|
+
} else if (run.group?.key !== group?.key) {
|
|
135
140
|
sameKey = false;
|
|
136
141
|
}
|
|
137
142
|
}
|
|
@@ -148,8 +153,8 @@ function lookSummary(tools: readonly ChatToolItem[], looks: readonly CommandLook
|
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
/* "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. */
|
|
151
|
-
export function summarizeGroup(tools: ChatToolItem[], looks?: readonly CommandLook[]): string {
|
|
152
|
-
const looked = lookSummary(tools, looks);
|
|
156
|
+
export function summarizeGroup(tools: ChatToolItem[], looks?: readonly CommandLook[], toolLooks?: readonly ToolLook[]): string {
|
|
157
|
+
const looked = lookSummary(tools, looks, toolLooks);
|
|
153
158
|
|
|
154
159
|
if (looked !== null) {
|
|
155
160
|
return looked.summary;
|
|
@@ -191,7 +196,7 @@ function editedPath(tool: ChatToolItem): string {
|
|
|
191
196
|
* "Searched 2 patterns". Every file change reads as one sentence, and calls without a sentence of
|
|
192
197
|
* their own are counted together at the end.
|
|
193
198
|
*/
|
|
194
|
-
export function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly CommandLook[]): string[] {
|
|
199
|
+
export function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly CommandLook[], toolLooks?: readonly ToolLook[]): string[] {
|
|
195
200
|
// Keyed by the sentence, so its place is where the first call of that kind came.
|
|
196
201
|
const counts = new Map<string, { count: number; say(count: number): string }>();
|
|
197
202
|
|
|
@@ -209,18 +214,17 @@ export function summarizeTurn(tools: readonly ChatToolItem[], looks?: readonly C
|
|
|
209
214
|
let other = 0;
|
|
210
215
|
|
|
211
216
|
for (const tool of tools) {
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
const sent = sentMessageOf(tool, looks);
|
|
217
|
+
const run = lookRunOf(tool, looks, toolLooks);
|
|
218
|
+
const group = run?.group;
|
|
219
|
+
const sent = sentMessageOf(tool, looks, toolLooks);
|
|
216
220
|
|
|
217
221
|
if (sent !== null && sent.state !== 'failed') {
|
|
218
222
|
add('agent-chat:group.sent', (count) => i18next.t('agent-chat:group.sent', { count }));
|
|
219
223
|
} else if (sent !== null) {
|
|
220
224
|
other += 1;
|
|
221
225
|
} else if (run !== null && group !== undefined) {
|
|
222
|
-
// Keyed by the
|
|
223
|
-
add(`look:${run.look
|
|
226
|
+
// Keyed by the look too, so two looks with a key in common keep their own sentences.
|
|
227
|
+
add(`look:${lookKey(run.look)}:${group.key}`, group.sentence);
|
|
224
228
|
} else if (failedFileChange(tool)) {
|
|
225
229
|
other += 1;
|
|
226
230
|
} else if (isFileChange(tool.name)) {
|
|
@@ -362,7 +366,7 @@ function flushTools(buffer: ChatToolItem[], rows: TimelineRow[], options: Timeli
|
|
|
362
366
|
const first = tools[0]!;
|
|
363
367
|
const id = `group-${first.id}`;
|
|
364
368
|
const expanded = options.expandedGroups.has(id);
|
|
365
|
-
const looked = lookSummary(tools, options.commandLooks);
|
|
369
|
+
const looked = lookSummary(tools, options.commandLooks, options.toolLooks);
|
|
366
370
|
|
|
367
371
|
rows.push(
|
|
368
372
|
looked === null
|
|
@@ -392,7 +396,7 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
|
|
|
392
396
|
}
|
|
393
397
|
|
|
394
398
|
const report = handbackReportOf(item);
|
|
395
|
-
const sent = item.kind === 'tool' ? sentMessageOf(item, options.commandLooks) : null;
|
|
399
|
+
const sent = item.kind === 'tool' ? sentMessageOf(item, options.commandLooks, options.toolLooks) : null;
|
|
396
400
|
|
|
397
401
|
if (item.kind === 'tool' && sent !== null) {
|
|
398
402
|
flushTools(tools, rows, options);
|
|
@@ -715,7 +719,7 @@ export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions):
|
|
|
715
719
|
id: `fold-${turnId}`,
|
|
716
720
|
turn,
|
|
717
721
|
label: turnLabel(turn, chunk.items),
|
|
718
|
-
work: summarizeTurn(tools, options.commandLooks),
|
|
722
|
+
work: summarizeTurn(tools, options.commandLooks, options.toolLooks),
|
|
719
723
|
hiddenCount: folded,
|
|
720
724
|
expanded,
|
|
721
725
|
expandable
|