@adecore/agents-react 0.50.6 → 0.51.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.
@@ -22,6 +22,7 @@ export interface Referable {
22
22
  group: 'canvas' | 'views';
23
23
  trail?: readonly ReferenceStep[];
24
24
  section?: ReferenceSection;
25
+ read?(): Promise<string>;
25
26
  }
26
27
  export interface Referables {
27
28
  items: readonly Referable[];
@@ -455,7 +455,7 @@ function Diagram(t0) {
455
455
  return t4;
456
456
  }
457
457
  function MarkdownCode(t0) {
458
- const $ = _c(11);
458
+ const $ = _c(7);
459
459
  const {
460
460
  className,
461
461
  children,
@@ -463,61 +463,42 @@ function MarkdownCode(t0) {
463
463
  } = t0;
464
464
  const plain = t1 === undefined ? false : t1;
465
465
  const block = useContext(BlockCodeContext);
466
+ const {
467
+ renderCodeFence
468
+ } = useChatHost();
466
469
  const text = String(children ?? "");
467
470
  if (block) {
468
471
  let t2;
469
- if ($[0] !== className) {
470
- t2 = languageOf(className);
471
- $[0] = className;
472
- $[1] = t2;
473
- } else {
474
- t2 = $[1];
475
- }
476
- const lang = t2;
477
- let t3;
478
- if ($[2] !== text) {
479
- let t4;
480
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
481
- t4 = /\n$/;
482
- $[4] = t4;
483
- } else {
484
- t4 = $[4];
485
- }
486
- t3 = text.replace(t4, "");
487
- $[2] = text;
488
- $[3] = t3;
489
- } else {
490
- t3 = $[3];
491
- }
492
- const code = t3;
493
- let t4;
494
- if ($[5] !== code || $[6] !== lang) {
495
- t4 = lang === "mermaid" ? /*#__PURE__*/_jsx(Diagram, {
472
+ if ($[0] !== className || $[1] !== renderCodeFence || $[2] !== text) {
473
+ const lang = languageOf(className);
474
+ const code = text.replace(/\n$/, "");
475
+ t2 = renderCodeFence?.(lang, code) ?? (lang === "mermaid" ? /*#__PURE__*/_jsx(Diagram, {
496
476
  code: code
497
477
  }) : /*#__PURE__*/_jsx(CodeBlock, {
498
478
  code: code,
499
479
  lang: lang
500
- });
501
- $[5] = code;
502
- $[6] = lang;
503
- $[7] = t4;
480
+ }));
481
+ $[0] = className;
482
+ $[1] = renderCodeFence;
483
+ $[2] = text;
484
+ $[3] = t2;
504
485
  } else {
505
- t4 = $[7];
486
+ t2 = $[3];
506
487
  }
507
- return t4;
488
+ return t2;
508
489
  }
509
490
  let t2;
510
- if ($[8] !== plain || $[9] !== text) {
491
+ if ($[4] !== plain || $[5] !== text) {
511
492
  t2 = plain ? /*#__PURE__*/_jsx(PlainCode, {
512
493
  text: text
513
494
  }) : /*#__PURE__*/_jsx(InlineCode, {
514
495
  text: text
515
496
  });
516
- $[8] = plain;
517
- $[9] = text;
518
- $[10] = t2;
497
+ $[4] = plain;
498
+ $[5] = text;
499
+ $[6] = t2;
519
500
  } else {
520
- t2 = $[10];
501
+ t2 = $[6];
521
502
  }
522
503
  return t2;
523
504
  }
@@ -595,7 +576,7 @@ const replyComponents = {
595
576
  h6: replyHeading(6)
596
577
  };
597
578
  function ReplyCode(t0) {
598
- const $ = _c(22);
579
+ const $ = _c(21);
599
580
  const {
600
581
  className,
601
582
  children,
@@ -604,6 +585,7 @@ function ReplyCode(t0) {
604
585
  const reply = useContext(ShellCodeBlockReplyContext);
605
586
  const block = useContext(BlockCodeContext);
606
587
  const {
588
+ renderCodeFence,
607
589
  renderShellCodeBlock
608
590
  } = useChatHost();
609
591
  const properties = node?.properties;
@@ -611,7 +593,7 @@ function ReplyCode(t0) {
611
593
  const code = properties?.["data-shell-code"];
612
594
  let t1;
613
595
  let text;
614
- if ($[0] !== block || $[1] !== children || $[2] !== className || $[3] !== code || $[4] !== language || $[5] !== properties || $[6] !== renderShellCodeBlock || $[7] !== reply) {
596
+ if ($[0] !== block || $[1] !== children || $[2] !== className || $[3] !== code || $[4] !== language || $[5] !== properties || $[6] !== renderCodeFence || $[7] !== renderShellCodeBlock || $[8] !== reply) {
615
597
  t1 = Symbol.for("react.early_return_sentinel");
616
598
  bb0: {
617
599
  const shell = (language === "sh" || language === "bash" || language === "zsh") && typeof code === "string" ? {
@@ -620,62 +602,47 @@ function ReplyCode(t0) {
620
602
  closed: properties?.["data-shell-closed"] === true
621
603
  } : null;
622
604
  text = String(children ?? "");
623
- if (block && languageOf(className) === "mermaid") {
605
+ if (block) {
606
+ let body;
607
+ let lang;
624
608
  let t2;
625
- if ($[10] !== text) {
626
- let t3;
627
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
628
- t3 = /\n$/;
629
- $[12] = t3;
630
- } else {
631
- t3 = $[12];
632
- }
633
- t2 = text.replace(t3, "");
634
- $[10] = text;
635
- $[11] = t2;
609
+ if ($[11] !== className || $[12] !== renderCodeFence || $[13] !== text) {
610
+ lang = languageOf(className);
611
+ body = text.replace(/\n$/, "");
612
+ t2 = renderCodeFence?.(lang, body);
613
+ $[11] = className;
614
+ $[12] = renderCodeFence;
615
+ $[13] = text;
616
+ $[14] = body;
617
+ $[15] = lang;
618
+ $[16] = t2;
636
619
  } else {
637
- t2 = $[11];
620
+ body = $[14];
621
+ lang = $[15];
622
+ t2 = $[16];
638
623
  }
639
- let t3;
640
- if ($[13] !== t2) {
641
- t3 = /*#__PURE__*/_jsx(Diagram, {
642
- code: t2
643
- });
644
- $[13] = t2;
645
- $[14] = t3;
646
- } else {
647
- t3 = $[14];
624
+ const drawn = t2;
625
+ if (drawn !== undefined && drawn !== null) {
626
+ t1 = drawn;
627
+ break bb0;
648
628
  }
649
- t1 = t3;
650
- break bb0;
651
- }
652
- if (block) {
653
- let t2;
654
- if ($[15] !== text) {
629
+ if (lang === "mermaid") {
655
630
  let t3;
656
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
657
- t3 = /\n$/;
658
- $[17] = t3;
631
+ if ($[17] !== body) {
632
+ t3 = /*#__PURE__*/_jsx(Diagram, {
633
+ code: body
634
+ });
635
+ $[17] = body;
636
+ $[18] = t3;
659
637
  } else {
660
- t3 = $[17];
638
+ t3 = $[18];
661
639
  }
662
- t2 = text.replace(t3, "");
663
- $[15] = text;
664
- $[16] = t2;
665
- } else {
666
- t2 = $[16];
667
- }
668
- let t3;
669
- if ($[18] !== className) {
670
- t3 = languageOf(className);
671
- $[18] = className;
672
- $[19] = t3;
673
- } else {
674
- t3 = $[19];
640
+ t1 = t3;
641
+ break bb0;
675
642
  }
676
643
  t1 = /*#__PURE__*/_jsx(CodeBlock, {
677
- code: t2,
678
- lang: t3,
644
+ code: body,
645
+ lang: lang,
679
646
  actions: shellCodeBlockActions(reply, shell, renderShellCodeBlock)
680
647
  });
681
648
  break bb0;
@@ -687,26 +654,27 @@ function ReplyCode(t0) {
687
654
  $[3] = code;
688
655
  $[4] = language;
689
656
  $[5] = properties;
690
- $[6] = renderShellCodeBlock;
691
- $[7] = reply;
692
- $[8] = t1;
693
- $[9] = text;
657
+ $[6] = renderCodeFence;
658
+ $[7] = renderShellCodeBlock;
659
+ $[8] = reply;
660
+ $[9] = t1;
661
+ $[10] = text;
694
662
  } else {
695
- t1 = $[8];
696
- text = $[9];
663
+ t1 = $[9];
664
+ text = $[10];
697
665
  }
698
666
  if (t1 !== Symbol.for("react.early_return_sentinel")) {
699
667
  return t1;
700
668
  }
701
669
  let t2;
702
- if ($[20] !== text) {
670
+ if ($[19] !== text) {
703
671
  t2 = /*#__PURE__*/_jsx(InlineCode, {
704
672
  text: text
705
673
  });
706
- $[20] = text;
707
- $[21] = t2;
674
+ $[19] = text;
675
+ $[20] = t2;
708
676
  } else {
709
- t2 = $[21];
677
+ t2 = $[20];
710
678
  }
711
679
  return t2;
712
680
  }
@@ -966,57 +934,64 @@ const ReplyFence = memo(function ReplyFence(t0) {
966
934
  reply
967
935
  } = t0;
968
936
  const {
937
+ renderCodeFence,
969
938
  renderShellCodeBlock
970
939
  } = useChatHost();
971
940
  let t1;
972
- if ($[0] !== info) {
973
- let t2;
974
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
975
- t2 = /[ \t]/;
976
- $[2] = t2;
977
- } else {
978
- t2 = $[2];
941
+ let t2;
942
+ if ($[0] !== body || $[1] !== info || $[2] !== open || $[3] !== renderCodeFence || $[4] !== renderShellCodeBlock || $[5] !== reply || $[6] !== source) {
943
+ t2 = Symbol.for("react.early_return_sentinel");
944
+ bb0: {
945
+ let t3;
946
+ if ($[9] !== info) {
947
+ let t4;
948
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
949
+ t4 = /[ \t]/;
950
+ $[11] = t4;
951
+ } else {
952
+ t4 = $[11];
953
+ }
954
+ t3 = info.split(t4, 1);
955
+ $[9] = info;
956
+ $[10] = t3;
957
+ } else {
958
+ t3 = $[10];
959
+ }
960
+ const lang = languageOf(`language-${t3[0]}`);
961
+ const shell = reply === undefined ? null : shellFence(source);
962
+ const drawn = open ? null : renderCodeFence?.(lang, body);
963
+ if (drawn !== undefined && drawn !== null) {
964
+ t2 = drawn;
965
+ break bb0;
966
+ }
967
+ t1 = /*#__PURE__*/_jsx(CodeStreamingContext.Provider, {
968
+ value: open,
969
+ children: lang === "mermaid" ? /*#__PURE__*/_jsx(Diagram, {
970
+ code: body
971
+ }) : /*#__PURE__*/_jsx(CodeBlock, {
972
+ code: body,
973
+ lang: lang,
974
+ actions: shellCodeBlockActions(reply ?? null, shell, renderShellCodeBlock)
975
+ })
976
+ });
979
977
  }
980
- t1 = info.split(t2, 1);
981
- $[0] = info;
982
- $[1] = t1;
983
- } else {
984
- t1 = $[1];
985
- }
986
- const t2 = `language-${t1[0]}`;
987
- let t3;
988
- if ($[3] !== t2) {
989
- t3 = languageOf(t2);
990
- $[3] = t2;
991
- $[4] = t3;
978
+ $[0] = body;
979
+ $[1] = info;
980
+ $[2] = open;
981
+ $[3] = renderCodeFence;
982
+ $[4] = renderShellCodeBlock;
983
+ $[5] = reply;
984
+ $[6] = source;
985
+ $[7] = t1;
986
+ $[8] = t2;
992
987
  } else {
993
- t3 = $[4];
988
+ t1 = $[7];
989
+ t2 = $[8];
994
990
  }
995
- const lang = t3;
996
- let t4;
997
- if ($[5] !== body || $[6] !== lang || $[7] !== open || $[8] !== renderShellCodeBlock || $[9] !== reply || $[10] !== source) {
998
- const shell = reply === undefined ? null : shellFence(source);
999
- t4 = /*#__PURE__*/_jsx(CodeStreamingContext.Provider, {
1000
- value: open,
1001
- children: lang === "mermaid" ? /*#__PURE__*/_jsx(Diagram, {
1002
- code: body
1003
- }) : /*#__PURE__*/_jsx(CodeBlock, {
1004
- code: body,
1005
- lang: lang,
1006
- actions: shellCodeBlockActions(reply ?? null, shell, renderShellCodeBlock)
1007
- })
1008
- });
1009
- $[5] = body;
1010
- $[6] = lang;
1011
- $[7] = open;
1012
- $[8] = renderShellCodeBlock;
1013
- $[9] = reply;
1014
- $[10] = source;
1015
- $[11] = t4;
1016
- } else {
1017
- t4 = $[11];
991
+ if (t2 !== Symbol.for("react.early_return_sentinel")) {
992
+ return t2;
1018
993
  }
1019
- return t4;
994
+ return t1;
1020
995
  });
1021
996
  /*
1022
997
  * A reply in a chat thread, parsed a block at a time so a delta only parses the block that grows,
@@ -18,7 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  const COPIED_MS = 1500;
19
19
  /* Hidden actions keep their height, so hovering never forces the virtualizer to remeasure. */
20
20
  export function MessageActions(t0) {
21
- const $ = _c(59);
21
+ const $ = _c(66);
22
22
  const {
23
23
  chatId,
24
24
  row
@@ -189,81 +189,99 @@ export function MessageActions(t0) {
189
189
  t12 = $[38];
190
190
  }
191
191
  let t13;
192
- if ($[39] !== row.item.createdAt) {
193
- t13 = formatDateTime(row.item.createdAt, TIMESTAMP_FORMAT);
194
- $[39] = row.item.createdAt;
195
- $[40] = t13;
192
+ if ($[39] !== chatId || $[40] !== host || $[41] !== row.id || $[42] !== row.item.text || $[43] !== row.kind) {
193
+ t13 = host.renderMessageActions?.({
194
+ chatId,
195
+ id: row.id,
196
+ kind: row.kind,
197
+ text: row.item.text
198
+ });
199
+ $[39] = chatId;
200
+ $[40] = host;
201
+ $[41] = row.id;
202
+ $[42] = row.item.text;
203
+ $[43] = row.kind;
204
+ $[44] = t13;
196
205
  } else {
197
- t13 = $[40];
206
+ t13 = $[44];
198
207
  }
199
208
  let t14;
200
- if ($[41] !== row.item.createdAt) {
201
- t14 = new Date(row.item.createdAt).toISOString();
202
- $[41] = row.item.createdAt;
203
- $[42] = t14;
209
+ if ($[45] !== row.item.createdAt) {
210
+ t14 = formatDateTime(row.item.createdAt, TIMESTAMP_FORMAT);
211
+ $[45] = row.item.createdAt;
212
+ $[46] = t14;
204
213
  } else {
205
- t14 = $[42];
214
+ t14 = $[46];
206
215
  }
207
- const t15 = row.kind === "assistant" && "order-first";
208
- let t16;
209
- if ($[43] !== t15) {
210
- t16 = clsx("shrink-0 text-xs text-text-faint tabular-nums select-none", t15);
211
- $[43] = t15;
212
- $[44] = t16;
216
+ let t15;
217
+ if ($[47] !== row.item.createdAt) {
218
+ t15 = new Date(row.item.createdAt).toISOString();
219
+ $[47] = row.item.createdAt;
220
+ $[48] = t15;
213
221
  } else {
214
- t16 = $[44];
222
+ t15 = $[48];
215
223
  }
224
+ const t16 = row.kind === "assistant" && "order-first";
216
225
  let t17;
217
- if ($[45] !== row.item.createdAt) {
218
- t17 = formatClock(row.item.createdAt);
219
- $[45] = row.item.createdAt;
220
- $[46] = t17;
226
+ if ($[49] !== t16) {
227
+ t17 = clsx("shrink-0 text-xs text-text-faint tabular-nums select-none", t16);
228
+ $[49] = t16;
229
+ $[50] = t17;
221
230
  } else {
222
- t17 = $[46];
231
+ t17 = $[50];
223
232
  }
224
233
  let t18;
225
- if ($[47] !== t14 || $[48] !== t16 || $[49] !== t17) {
226
- t18 = /*#__PURE__*/_jsx("time", {
227
- dateTime: t14,
228
- className: t16,
229
- children: t17
230
- });
231
- $[47] = t14;
232
- $[48] = t16;
233
- $[49] = t17;
234
- $[50] = t18;
234
+ if ($[51] !== row.item.createdAt) {
235
+ t18 = formatClock(row.item.createdAt);
236
+ $[51] = row.item.createdAt;
237
+ $[52] = t18;
235
238
  } else {
236
- t18 = $[50];
239
+ t18 = $[52];
237
240
  }
238
241
  let t19;
239
- if ($[51] !== t13 || $[52] !== t18) {
240
- t19 = /*#__PURE__*/_jsx(Tooltip, {
241
- label: t13,
242
+ if ($[53] !== t15 || $[54] !== t17 || $[55] !== t18) {
243
+ t19 = /*#__PURE__*/_jsx("time", {
244
+ dateTime: t15,
245
+ className: t17,
242
246
  children: t18
243
247
  });
244
- $[51] = t13;
245
- $[52] = t18;
246
- $[53] = t19;
248
+ $[53] = t15;
249
+ $[54] = t17;
250
+ $[55] = t18;
251
+ $[56] = t19;
247
252
  } else {
248
- t19 = $[53];
253
+ t19 = $[56];
249
254
  }
250
255
  let t20;
251
- if ($[54] !== t11 || $[55] !== t12 || $[56] !== t19 || $[57] !== t9) {
252
- t20 = /*#__PURE__*/_jsxs("div", {
256
+ if ($[57] !== t14 || $[58] !== t19) {
257
+ t20 = /*#__PURE__*/_jsx(Tooltip, {
258
+ label: t14,
259
+ children: t19
260
+ });
261
+ $[57] = t14;
262
+ $[58] = t19;
263
+ $[59] = t20;
264
+ } else {
265
+ t20 = $[59];
266
+ }
267
+ let t21;
268
+ if ($[60] !== t11 || $[61] !== t12 || $[62] !== t13 || $[63] !== t20 || $[64] !== t9) {
269
+ t21 = /*#__PURE__*/_jsxs("div", {
253
270
  role: "toolbar",
254
271
  "aria-label": t9,
255
272
  className: t11,
256
- children: [t12, t19]
273
+ children: [t12, t13, t20]
257
274
  });
258
- $[54] = t11;
259
- $[55] = t12;
260
- $[56] = t19;
261
- $[57] = t9;
262
- $[58] = t20;
275
+ $[60] = t11;
276
+ $[61] = t12;
277
+ $[62] = t13;
278
+ $[63] = t20;
279
+ $[64] = t9;
280
+ $[65] = t21;
263
281
  } else {
264
- t20 = $[58];
282
+ t21 = $[65];
265
283
  }
266
- return t20;
284
+ return t21;
267
285
  }
268
286
  function _temp2(chat_0) {
269
287
  return chat_0?.info ?? null;
@@ -55,10 +55,13 @@ function showRowAtTop(virtualizer, followRef, index) {
55
55
  * and the folder it works in, so a first question can lean on all three.
56
56
  */
57
57
  function EmptyThread(t0) {
58
- const $ = _c(20);
58
+ const $ = _c(24);
59
59
  const {
60
60
  chatId
61
61
  } = t0;
62
+ const {
63
+ renderEmptyThread
64
+ } = useChatHost();
62
65
  const {
63
66
  t
64
67
  } = useTranslation("agent-chat");
@@ -102,8 +105,17 @@ function EmptyThread(t0) {
102
105
  t3 = $[8];
103
106
  }
104
107
  let t4;
105
- if ($[9] !== sources || $[10] !== t) {
106
- t4 = sources.length > 0 && /*#__PURE__*/_jsxs("div", {
108
+ if ($[9] !== chatId || $[10] !== renderEmptyThread) {
109
+ t4 = renderEmptyThread?.(chatId);
110
+ $[9] = chatId;
111
+ $[10] = renderEmptyThread;
112
+ $[11] = t4;
113
+ } else {
114
+ t4 = $[11];
115
+ }
116
+ let t5;
117
+ if ($[12] !== sources || $[13] !== t) {
118
+ t5 = sources.length > 0 && /*#__PURE__*/_jsxs("div", {
107
119
  className: "flex max-w-full flex-col items-center gap-1",
108
120
  children: [/*#__PURE__*/_jsx(SectionLabel, {
109
121
  children: t("timeline.empty.canRead")
@@ -112,15 +124,15 @@ function EmptyThread(t0) {
112
124
  children: sources.map(_temp2).join(", ")
113
125
  })]
114
126
  });
115
- $[9] = sources;
116
- $[10] = t;
117
- $[11] = t4;
127
+ $[12] = sources;
128
+ $[13] = t;
129
+ $[14] = t5;
118
130
  } else {
119
- t4 = $[11];
131
+ t5 = $[14];
120
132
  }
121
- let t5;
122
- if ($[12] !== hidesFolder || $[13] !== info || $[14] !== t) {
123
- t5 = info?.cwd && !hidesFolder && /*#__PURE__*/_jsxs("div", {
133
+ let t6;
134
+ if ($[15] !== hidesFolder || $[16] !== info || $[17] !== t) {
135
+ t6 = info?.cwd && !hidesFolder && /*#__PURE__*/_jsxs("div", {
124
136
  className: "flex max-w-full flex-col items-center gap-1",
125
137
  children: [/*#__PURE__*/_jsx(SectionLabel, {
126
138
  children: t("timeline.empty.worksIn")
@@ -129,30 +141,31 @@ function EmptyThread(t0) {
129
141
  children: info.cwd
130
142
  })]
131
143
  });
132
- $[12] = hidesFolder;
133
- $[13] = info;
134
- $[14] = t;
135
- $[15] = t5;
144
+ $[15] = hidesFolder;
145
+ $[16] = info;
146
+ $[17] = t;
147
+ $[18] = t6;
136
148
  } else {
137
- t5 = $[15];
149
+ t6 = $[18];
138
150
  }
139
- let t6;
140
- if ($[16] !== t3 || $[17] !== t4 || $[18] !== t5) {
141
- t6 = /*#__PURE__*/_jsx("div", {
151
+ let t7;
152
+ if ($[19] !== t3 || $[20] !== t4 || $[21] !== t5 || $[22] !== t6) {
153
+ t7 = /*#__PURE__*/_jsx("div", {
142
154
  className: "flex grow items-center justify-center",
143
155
  children: /*#__PURE__*/_jsxs("div", {
144
156
  className: "flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center",
145
- children: [t3, t4, t5]
157
+ children: [t3, t4, t5, t6]
146
158
  })
147
159
  });
148
- $[16] = t3;
149
- $[17] = t4;
150
- $[18] = t5;
151
- $[19] = t6;
160
+ $[19] = t3;
161
+ $[20] = t4;
162
+ $[21] = t5;
163
+ $[22] = t6;
164
+ $[23] = t7;
152
165
  } else {
153
- t6 = $[19];
166
+ t7 = $[23];
154
167
  }
155
- return t6;
168
+ return t7;
156
169
  }
157
170
  /*
158
171
  * A row of the thread behind the chapter line of its bookmark. A message, the only row that takes a
@@ -15,6 +15,7 @@ export interface ComposerCommand {
15
15
  name: string;
16
16
  hint: string;
17
17
  local: boolean;
18
+ expand?(args: string): Promise<string>;
18
19
  skill: boolean;
19
20
  }
20
21
  export interface PromptMenusInput<D extends PromptDraft> {