@adecore/agents-react 0.50.3 → 0.50.5

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.
@@ -9,7 +9,7 @@ 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, type CommandLookRun, type CommandLookWord } from './logic/command-looks.js';
12
+ export { matchCommandLook, sentMessageOf, type CommandLookRun, type CommandLookWord } from './logic/command-looks.js';
13
13
  export { handbackReportOf } from './logic/handback.js';
14
14
  export { limitView, type LimitView } from './logic/limit.js';
15
15
  export type { TickKind, ScrubberTick } from './logic/scrubber.js';
@@ -8,7 +8,7 @@ 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 } from './logic/command-looks.js';
11
+ export { matchCommandLook, sentMessageOf } from './logic/command-looks.js';
12
12
  export { handbackReportOf } from './logic/handback.js';
13
13
  export { limitView } from './logic/limit.js';
14
14
  export { withTimedRows, timedRowsOf } from './logic/thread-cards.js';
@@ -1,4 +1,5 @@
1
- import type { CommandLook, CommandLookMatch } from '../../host.js';
1
+ import type { ChatToolItem } from '@adecore/agent-contracts';
2
+ import type { CommandLook, CommandLookMatch, CommandLookSent } from '../../host.js';
2
3
  import { type EmbeddedCode } from './embedded-code.js';
3
4
  export interface CommandLookWord {
4
5
  readonly start: number;
@@ -15,5 +16,9 @@ export interface CommandLookRun {
15
16
  readonly others: readonly string[];
16
17
  readonly more: number;
17
18
  readonly heredoc: boolean;
19
+ readonly args: readonly string[];
20
+ readonly heredocText: string | null;
21
+ readonly expands: boolean;
18
22
  }
19
23
  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;
@@ -1,4 +1,5 @@
1
1
  import { EMBEDDED_CODE_LIMIT, shellCommands } from './embedded-code.js';
2
+ import { shellCommand } from './tools.js';
2
3
  // A folded value keeps this many characters of what it says.
3
4
  const FOLD_LENGTH = 40;
4
5
  // Rows redraw often and a thread holds many commands, so each is read once per set of looks.
@@ -107,6 +108,35 @@ function detailOf(source, command, match) {
107
108
  words
108
109
  };
109
110
  }
111
+ /* Whether the shell would fill in a part of this source: a `$` or backtick outside single quotes and not escaped. */
112
+ function expandsInShell(source) {
113
+ let quote = null;
114
+ for (let i = 0; i < source.length; i++) {
115
+ const char = source[i];
116
+ if (quote === "'") {
117
+ quote = char === "'" ? null : quote;
118
+ } else if (char === '\\') {
119
+ i++;
120
+ } else if (char === '$' || char === '`') {
121
+ return true;
122
+ } else if (char === "'" && quote === null) {
123
+ quote = "'";
124
+ } else if (char === '"') {
125
+ quote = quote === null ? '"' : null;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+ /* The text of a command's only heredoc, as long as a quoted delimiter or plain text says the shell leaves it alone. */
131
+ function heredocTextOf(source, command) {
132
+ const heredoc = command.heredocs.length === 1 ? command.heredocs[0] : undefined;
133
+ if (heredoc === undefined) {
134
+ return null;
135
+ }
136
+ const text = source.slice(heredoc.body.start, heredoc.body.end);
137
+ const quoted = /['"\\]/.test(source.slice(heredoc.start, heredoc.end));
138
+ return quoted || !/[$`\\]/.test(text) ? text : null;
139
+ }
110
140
  function read(command, looks) {
111
141
  let found = null;
112
142
  let more = 0;
@@ -133,7 +163,12 @@ function read(command, looks) {
133
163
  ...detailOf(command, found.command, found.match),
134
164
  others,
135
165
  more,
136
- heredoc: found.command.heredocs.length > 0
166
+ heredoc: found.command.heredocs.length > 0,
167
+ args: found.command.words.slice(found.command.program.index + 1).map(({
168
+ text
169
+ }) => text),
170
+ heredocText: heredocTextOf(command, found.command),
171
+ expands: found.command.words.some(word => expandsInShell(command.slice(word.start, word.end)))
137
172
  };
138
173
  }
139
174
  /*
@@ -162,4 +197,18 @@ export function matchCommandLook(command, looks) {
162
197
  cache.delete(cache.keys().next().value);
163
198
  }
164
199
  return run;
200
+ }
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) {
203
+ const command = shellCommand(tool.name, tool.input);
204
+ 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) {
206
+ return null;
207
+ }
208
+ return run.look.sent({
209
+ args: run.args,
210
+ heredoc: run.heredocText,
211
+ state: tool.state,
212
+ output: tool.output
213
+ });
165
214
  }
@@ -37,6 +37,8 @@ export function messageTextOf(row) {
37
37
  return row.text;
38
38
  case 'message':
39
39
  return row.message.text || null;
40
+ case 'sent':
41
+ return row.sent.text || null;
40
42
  default:
41
43
  return null;
42
44
  }
@@ -1,5 +1,5 @@
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, ThreadCard } from '../../host.js';
2
+ import type { CommandLook, CommandLookSent, ThreadCard } from '../../host.js';
3
3
  export interface SubagentBranch {
4
4
  id: string;
5
5
  item: ChatSubagentItem;
@@ -75,6 +75,11 @@ export type TimelineRow = {
75
75
  id: string;
76
76
  message: ChatNoteMessage;
77
77
  createdAt: number;
78
+ } | {
79
+ kind: 'sent';
80
+ id: string;
81
+ tool: ChatToolItem;
82
+ sent: CommandLookSent;
78
83
  } | {
79
84
  kind: 'compaction';
80
85
  id: string;
@@ -1,7 +1,7 @@
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 } from './command-looks.js';
4
+ import { matchCommandLook, 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';
@@ -16,7 +16,7 @@ function shownRows(rows, options) {
16
16
  * against each other; prose and cards are blocks and need room around them. Where the two meet,
17
17
  * the block gap marks the seam, so an answer never looks glued to the call above it.
18
18
  */
19
- const BLOCK_KINDS = new Set(['assistant', 'report', 'thinking', 'changed-files', 'compaction', 'app-card', 'visual']);
19
+ const BLOCK_KINDS = new Set(['assistant', 'report', 'sent', 'thinking', 'changed-files', 'compaction', 'app-card', 'visual']);
20
20
  export function isBlock(row) {
21
21
  return BLOCK_KINDS.has(row.kind) || isImageRow(row);
22
22
  }
@@ -118,7 +118,14 @@ export function summarizeTurn(tools, looks) {
118
118
  const command = shellCommand(tool.name, tool.input);
119
119
  const run = command === null ? null : matchCommandLook(command, looks);
120
120
  const group = run?.match.group;
121
- if (run !== null && group !== undefined) {
121
+ const sent = sentMessageOf(tool, looks);
122
+ if (sent !== null && sent.state !== 'failed') {
123
+ add('agent-chat:group.sent', count => i18next.t('agent-chat:group.sent', {
124
+ count
125
+ }));
126
+ } else if (sent !== null) {
127
+ other += 1;
128
+ } else if (run !== null && group !== undefined) {
122
129
  // Keyed by the program too, so two looks with a key in common keep their own sentences.
123
130
  add(`look:${run.look.program}:${group.key}`, group.sentence);
124
131
  } else if (failedFileChange(tool)) {
@@ -297,6 +304,17 @@ function rowsForItems(items, options, children) {
297
304
  continue;
298
305
  }
299
306
  const report = handbackReportOf(item);
307
+ const sent = item.kind === 'tool' ? sentMessageOf(item, options.commandLooks) : null;
308
+ if (item.kind === 'tool' && sent !== null) {
309
+ flushTools(tools, rows, options);
310
+ rows.push({
311
+ kind: 'sent',
312
+ id: item.id,
313
+ tool: item,
314
+ sent
315
+ });
316
+ continue;
317
+ }
300
318
  if (item.kind === 'tool' && item.workflow !== undefined) {
301
319
  flushTools(tools, rows, options);
302
320
  rows.push({
@@ -9,8 +9,9 @@ interface TokenChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children
9
9
  onOpen?: () => void;
10
10
  }
11
11
  export declare function TokenChip({ kind, value, sigil, icon, label, tone, onOpen, className, ...rest }: TokenChipProps): import("react").JSX.Element;
12
- export declare function ReferenceChip({ id, lastName }: {
12
+ export declare function ReferenceChip({ id, lastName, goneHint }: {
13
13
  id: string;
14
14
  lastName?: string;
15
+ goneHint?: string;
15
16
  }): import("react").JSX.Element;
16
17
  export {};
@@ -3,7 +3,7 @@ import { useContext } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { CircleOff } from 'lucide-react';
6
- import { Icon } from '@adecore/ui';
6
+ import { Icon, Tooltip } from '@adecore/ui';
7
7
  import { useChatHost } from '../../host.js';
8
8
  import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_ICON_BOX, TOKEN_IN_MESSAGE } from './chips.js';
9
9
  import { referenceGlyph } from './reference-icons.js';
@@ -128,13 +128,14 @@ export function TokenChip(t0) {
128
128
  }
129
129
  /*
130
130
  * A view, node or chat a message points at, under the name it has now. One that went says so, under
131
- * `lastName` when the message knows what it was called.
131
+ * `lastName` when the message knows what it was called, with `goneHint` on its tooltip when there is one.
132
132
  */
133
133
  export function ReferenceChip(t0) {
134
- const $ = _c(41);
134
+ const $ = _c(45);
135
135
  const {
136
136
  id,
137
- lastName
137
+ lastName,
138
+ goneHint
138
139
  } = t0;
139
140
  const {
140
141
  t
@@ -154,53 +155,69 @@ export function ReferenceChip(t0) {
154
155
  let t4;
155
156
  let t5;
156
157
  let t6;
157
- if ($[0] !== ReferenceIcon || $[1] !== id || $[2] !== items || $[3] !== lastName || $[4] !== t) {
158
+ if ($[0] !== ReferenceIcon || $[1] !== goneHint || $[2] !== id || $[3] !== items || $[4] !== lastName || $[5] !== t) {
158
159
  t6 = Symbol.for("react.early_return_sentinel");
159
160
  bb0: {
160
161
  let t7;
161
- if ($[13] !== id) {
162
+ if ($[14] !== id) {
162
163
  t7 = candidate => candidate.id === id;
163
- $[13] = id;
164
- $[14] = t7;
164
+ $[14] = id;
165
+ $[15] = t7;
165
166
  } else {
166
- t7 = $[14];
167
+ t7 = $[15];
167
168
  }
168
169
  item = items.find(t7);
169
170
  if (item === undefined) {
170
171
  let t8;
171
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
172
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
172
173
  t8 = /*#__PURE__*/_jsx(Icon, {
173
174
  icon: CircleOff,
174
175
  size: 14,
175
176
  className: TOKEN_ICON
176
177
  });
177
- $[15] = t8;
178
+ $[16] = t8;
178
179
  } else {
179
- t8 = $[15];
180
+ t8 = $[16];
180
181
  }
181
182
  let t9;
182
- if ($[16] !== lastName || $[17] !== t) {
183
+ if ($[17] !== lastName || $[18] !== t) {
183
184
  t9 = lastName || t("references.gone");
184
- $[16] = lastName;
185
- $[17] = t;
186
- $[18] = t9;
185
+ $[17] = lastName;
186
+ $[18] = t;
187
+ $[19] = t9;
187
188
  } else {
188
- t9 = $[18];
189
+ t9 = $[19];
189
190
  }
190
191
  let t10;
191
- if ($[19] !== t9) {
192
+ if ($[20] !== t9) {
192
193
  t10 = /*#__PURE__*/_jsx(TokenChip, {
193
194
  kind: "gone",
194
195
  icon: t8,
195
196
  label: t9,
196
197
  tone: REFERENCE_GONE_TONE
197
198
  });
198
- $[19] = t9;
199
- $[20] = t10;
199
+ $[20] = t9;
200
+ $[21] = t10;
200
201
  } else {
201
- t10 = $[20];
202
+ t10 = $[21];
202
203
  }
203
- t6 = t10;
204
+ const chip = t10;
205
+ let t11;
206
+ if ($[22] !== chip || $[23] !== goneHint) {
207
+ t11 = goneHint === undefined ? chip : /*#__PURE__*/_jsx(Tooltip, {
208
+ label: goneHint,
209
+ children: /*#__PURE__*/_jsx("span", {
210
+ className: "inline-flex",
211
+ children: chip
212
+ })
213
+ });
214
+ $[22] = chip;
215
+ $[23] = goneHint;
216
+ $[24] = t11;
217
+ } else {
218
+ t11 = $[24];
219
+ }
220
+ t6 = t11;
204
221
  break bb0;
205
222
  }
206
223
  T0 = TokenChip;
@@ -221,71 +238,72 @@ export function ReferenceChip(t0) {
221
238
  });
222
239
  }
223
240
  $[0] = ReferenceIcon;
224
- $[1] = id;
225
- $[2] = items;
226
- $[3] = lastName;
227
- $[4] = t;
228
- $[5] = T0;
229
- $[6] = item;
230
- $[7] = t1;
231
- $[8] = t2;
232
- $[9] = t3;
233
- $[10] = t4;
234
- $[11] = t5;
235
- $[12] = t6;
241
+ $[1] = goneHint;
242
+ $[2] = id;
243
+ $[3] = items;
244
+ $[4] = lastName;
245
+ $[5] = t;
246
+ $[6] = T0;
247
+ $[7] = item;
248
+ $[8] = t1;
249
+ $[9] = t2;
250
+ $[10] = t3;
251
+ $[11] = t4;
252
+ $[12] = t5;
253
+ $[13] = t6;
236
254
  } else {
237
- T0 = $[5];
238
- item = $[6];
239
- t1 = $[7];
240
- t2 = $[8];
241
- t3 = $[9];
242
- t4 = $[10];
243
- t5 = $[11];
244
- t6 = $[12];
255
+ T0 = $[6];
256
+ item = $[7];
257
+ t1 = $[8];
258
+ t2 = $[9];
259
+ t3 = $[10];
260
+ t4 = $[11];
261
+ t5 = $[12];
262
+ t6 = $[13];
245
263
  }
246
264
  if (t6 !== Symbol.for("react.early_return_sentinel")) {
247
265
  return t6;
248
266
  }
249
267
  let t7;
250
- if ($[21] !== t1 || $[22] !== t2) {
268
+ if ($[25] !== t1 || $[26] !== t2) {
251
269
  t7 = /*#__PURE__*/_jsxs(_Fragment, {
252
270
  children: [t1, t2]
253
271
  });
254
- $[21] = t1;
255
- $[22] = t2;
256
- $[23] = t7;
272
+ $[25] = t1;
273
+ $[26] = t2;
274
+ $[27] = t7;
257
275
  } else {
258
- t7 = $[23];
276
+ t7 = $[27];
259
277
  }
260
278
  let t8;
261
- if ($[24] !== item.name || $[25] !== t) {
279
+ if ($[28] !== item.name || $[29] !== t) {
262
280
  t8 = item.name || t("references.untitled");
263
- $[24] = item.name;
264
- $[25] = t;
265
- $[26] = t8;
281
+ $[28] = item.name;
282
+ $[29] = t;
283
+ $[30] = t8;
266
284
  } else {
267
- t8 = $[26];
285
+ t8 = $[30];
268
286
  }
269
287
  const t9 = open !== null && "hover:bg-text/12";
270
288
  let t10;
271
- if ($[27] !== t9) {
289
+ if ($[31] !== t9) {
272
290
  t10 = clsx(REFERENCE_TONE, t9);
273
- $[27] = t9;
274
- $[28] = t10;
291
+ $[31] = t9;
292
+ $[32] = t10;
275
293
  } else {
276
- t10 = $[28];
294
+ t10 = $[32];
277
295
  }
278
296
  let t11;
279
- if ($[29] !== item.id || $[30] !== open) {
297
+ if ($[33] !== item.id || $[34] !== open) {
280
298
  t11 = open === null ? undefined : () => open(item.id);
281
- $[29] = item.id;
282
- $[30] = open;
283
- $[31] = t11;
299
+ $[33] = item.id;
300
+ $[34] = open;
301
+ $[35] = t11;
284
302
  } else {
285
- t11 = $[31];
303
+ t11 = $[35];
286
304
  }
287
305
  let t12;
288
- if ($[32] !== T0 || $[33] !== t10 || $[34] !== t11 || $[35] !== t3 || $[36] !== t4 || $[37] !== t5 || $[38] !== t7 || $[39] !== t8) {
306
+ if ($[36] !== T0 || $[37] !== t10 || $[38] !== t11 || $[39] !== t3 || $[40] !== t4 || $[41] !== t5 || $[42] !== t7 || $[43] !== t8) {
289
307
  t12 = /*#__PURE__*/_jsx(T0, {
290
308
  kind: t3,
291
309
  value: t4,
@@ -295,17 +313,17 @@ export function ReferenceChip(t0) {
295
313
  tone: t10,
296
314
  onOpen: t11
297
315
  });
298
- $[32] = T0;
299
- $[33] = t10;
300
- $[34] = t11;
301
- $[35] = t3;
302
- $[36] = t4;
303
- $[37] = t5;
304
- $[38] = t7;
305
- $[39] = t8;
306
- $[40] = t12;
316
+ $[36] = T0;
317
+ $[37] = t10;
318
+ $[38] = t11;
319
+ $[39] = t3;
320
+ $[40] = t4;
321
+ $[41] = t5;
322
+ $[42] = t7;
323
+ $[43] = t8;
324
+ $[44] = t12;
307
325
  } else {
308
- t12 = $[40];
326
+ t12 = $[44];
309
327
  }
310
328
  return t12;
311
329
  }
@@ -1,4 +1,5 @@
1
- import type { ChatApprovalItem, ChatAssistantItem, ChatNoteMessage, ChatQuestionItem, ChatThinkingItem, ChatUserItem } from '@adecore/agent-contracts';
1
+ import type { ChatApprovalItem, ChatAssistantItem, ChatNoteMessage, ChatQuestionItem, ChatThinkingItem, ChatToolItem, ChatUserItem } from '@adecore/agent-contracts';
2
+ import { type CommandLookSent } from '../../../host.js';
2
3
  export declare function UserRow({ chatId, item }: {
3
4
  chatId: string;
4
5
  item: ChatUserItem;
@@ -8,6 +9,12 @@ export declare function SentMessageRow({ chatId, id, message }: {
8
9
  id: string;
9
10
  message: ChatNoteMessage;
10
11
  }): import("react").JSX.Element;
12
+ export declare function SentByAgentRow({ chatId, id, tool, sent }: {
13
+ chatId: string;
14
+ id: string;
15
+ tool: ChatToolItem;
16
+ sent: CommandLookSent;
17
+ }): import("react").JSX.Element;
11
18
  export declare function ReportRow({ id, text }: {
12
19
  id: string;
13
20
  text: string;