@adecore/agents-react 0.50.7 → 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.
- package/dist/chat/ui/Markdown.js +97 -103
- package/package.json +8 -8
- package/src/chat/ui/Markdown.tsx +21 -7
package/dist/chat/ui/Markdown.js
CHANGED
|
@@ -576,7 +576,7 @@ const replyComponents = {
|
|
|
576
576
|
h6: replyHeading(6)
|
|
577
577
|
};
|
|
578
578
|
function ReplyCode(t0) {
|
|
579
|
-
const $ = _c(
|
|
579
|
+
const $ = _c(21);
|
|
580
580
|
const {
|
|
581
581
|
className,
|
|
582
582
|
children,
|
|
@@ -585,6 +585,7 @@ function ReplyCode(t0) {
|
|
|
585
585
|
const reply = useContext(ShellCodeBlockReplyContext);
|
|
586
586
|
const block = useContext(BlockCodeContext);
|
|
587
587
|
const {
|
|
588
|
+
renderCodeFence,
|
|
588
589
|
renderShellCodeBlock
|
|
589
590
|
} = useChatHost();
|
|
590
591
|
const properties = node?.properties;
|
|
@@ -592,7 +593,7 @@ function ReplyCode(t0) {
|
|
|
592
593
|
const code = properties?.["data-shell-code"];
|
|
593
594
|
let t1;
|
|
594
595
|
let text;
|
|
595
|
-
if ($[0] !== block || $[1] !== children || $[2] !== className || $[3] !== code || $[4] !== language || $[5] !== properties || $[6] !==
|
|
596
|
+
if ($[0] !== block || $[1] !== children || $[2] !== className || $[3] !== code || $[4] !== language || $[5] !== properties || $[6] !== renderCodeFence || $[7] !== renderShellCodeBlock || $[8] !== reply) {
|
|
596
597
|
t1 = Symbol.for("react.early_return_sentinel");
|
|
597
598
|
bb0: {
|
|
598
599
|
const shell = (language === "sh" || language === "bash" || language === "zsh") && typeof code === "string" ? {
|
|
@@ -601,62 +602,47 @@ function ReplyCode(t0) {
|
|
|
601
602
|
closed: properties?.["data-shell-closed"] === true
|
|
602
603
|
} : null;
|
|
603
604
|
text = String(children ?? "");
|
|
604
|
-
if (block
|
|
605
|
+
if (block) {
|
|
606
|
+
let body;
|
|
607
|
+
let lang;
|
|
605
608
|
let t2;
|
|
606
|
-
if ($[
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
$[
|
|
616
|
-
$[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;
|
|
617
619
|
} else {
|
|
618
|
-
|
|
620
|
+
body = $[14];
|
|
621
|
+
lang = $[15];
|
|
622
|
+
t2 = $[16];
|
|
619
623
|
}
|
|
620
|
-
|
|
621
|
-
if (
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
});
|
|
625
|
-
$[13] = t2;
|
|
626
|
-
$[14] = t3;
|
|
627
|
-
} else {
|
|
628
|
-
t3 = $[14];
|
|
624
|
+
const drawn = t2;
|
|
625
|
+
if (drawn !== undefined && drawn !== null) {
|
|
626
|
+
t1 = drawn;
|
|
627
|
+
break bb0;
|
|
629
628
|
}
|
|
630
|
-
|
|
631
|
-
break bb0;
|
|
632
|
-
}
|
|
633
|
-
if (block) {
|
|
634
|
-
let t2;
|
|
635
|
-
if ($[15] !== text) {
|
|
629
|
+
if (lang === "mermaid") {
|
|
636
630
|
let t3;
|
|
637
|
-
if ($[17]
|
|
638
|
-
t3 =
|
|
639
|
-
|
|
631
|
+
if ($[17] !== body) {
|
|
632
|
+
t3 = /*#__PURE__*/_jsx(Diagram, {
|
|
633
|
+
code: body
|
|
634
|
+
});
|
|
635
|
+
$[17] = body;
|
|
636
|
+
$[18] = t3;
|
|
640
637
|
} else {
|
|
641
|
-
t3 = $[
|
|
638
|
+
t3 = $[18];
|
|
642
639
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
$[16] = t2;
|
|
646
|
-
} else {
|
|
647
|
-
t2 = $[16];
|
|
648
|
-
}
|
|
649
|
-
let t3;
|
|
650
|
-
if ($[18] !== className) {
|
|
651
|
-
t3 = languageOf(className);
|
|
652
|
-
$[18] = className;
|
|
653
|
-
$[19] = t3;
|
|
654
|
-
} else {
|
|
655
|
-
t3 = $[19];
|
|
640
|
+
t1 = t3;
|
|
641
|
+
break bb0;
|
|
656
642
|
}
|
|
657
643
|
t1 = /*#__PURE__*/_jsx(CodeBlock, {
|
|
658
|
-
code:
|
|
659
|
-
lang:
|
|
644
|
+
code: body,
|
|
645
|
+
lang: lang,
|
|
660
646
|
actions: shellCodeBlockActions(reply, shell, renderShellCodeBlock)
|
|
661
647
|
});
|
|
662
648
|
break bb0;
|
|
@@ -668,26 +654,27 @@ function ReplyCode(t0) {
|
|
|
668
654
|
$[3] = code;
|
|
669
655
|
$[4] = language;
|
|
670
656
|
$[5] = properties;
|
|
671
|
-
$[6] =
|
|
672
|
-
$[7] =
|
|
673
|
-
$[8] =
|
|
674
|
-
$[9] =
|
|
657
|
+
$[6] = renderCodeFence;
|
|
658
|
+
$[7] = renderShellCodeBlock;
|
|
659
|
+
$[8] = reply;
|
|
660
|
+
$[9] = t1;
|
|
661
|
+
$[10] = text;
|
|
675
662
|
} else {
|
|
676
|
-
t1 = $[
|
|
677
|
-
text = $[
|
|
663
|
+
t1 = $[9];
|
|
664
|
+
text = $[10];
|
|
678
665
|
}
|
|
679
666
|
if (t1 !== Symbol.for("react.early_return_sentinel")) {
|
|
680
667
|
return t1;
|
|
681
668
|
}
|
|
682
669
|
let t2;
|
|
683
|
-
if ($[
|
|
670
|
+
if ($[19] !== text) {
|
|
684
671
|
t2 = /*#__PURE__*/_jsx(InlineCode, {
|
|
685
672
|
text: text
|
|
686
673
|
});
|
|
687
|
-
$[
|
|
688
|
-
$[
|
|
674
|
+
$[19] = text;
|
|
675
|
+
$[20] = t2;
|
|
689
676
|
} else {
|
|
690
|
-
t2 = $[
|
|
677
|
+
t2 = $[20];
|
|
691
678
|
}
|
|
692
679
|
return t2;
|
|
693
680
|
}
|
|
@@ -947,57 +934,64 @@ const ReplyFence = memo(function ReplyFence(t0) {
|
|
|
947
934
|
reply
|
|
948
935
|
} = t0;
|
|
949
936
|
const {
|
|
937
|
+
renderCodeFence,
|
|
950
938
|
renderShellCodeBlock
|
|
951
939
|
} = useChatHost();
|
|
952
940
|
let t1;
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
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
|
+
});
|
|
960
977
|
}
|
|
961
|
-
|
|
962
|
-
$[
|
|
963
|
-
$[
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
t3 = languageOf(t2);
|
|
971
|
-
$[3] = t2;
|
|
972
|
-
$[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;
|
|
973
987
|
} else {
|
|
974
|
-
|
|
988
|
+
t1 = $[7];
|
|
989
|
+
t2 = $[8];
|
|
975
990
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
if ($[5] !== body || $[6] !== lang || $[7] !== open || $[8] !== renderShellCodeBlock || $[9] !== reply || $[10] !== source) {
|
|
979
|
-
const shell = reply === undefined ? null : shellFence(source);
|
|
980
|
-
t4 = /*#__PURE__*/_jsx(CodeStreamingContext.Provider, {
|
|
981
|
-
value: open,
|
|
982
|
-
children: lang === "mermaid" ? /*#__PURE__*/_jsx(Diagram, {
|
|
983
|
-
code: body
|
|
984
|
-
}) : /*#__PURE__*/_jsx(CodeBlock, {
|
|
985
|
-
code: body,
|
|
986
|
-
lang: lang,
|
|
987
|
-
actions: shellCodeBlockActions(reply ?? null, shell, renderShellCodeBlock)
|
|
988
|
-
})
|
|
989
|
-
});
|
|
990
|
-
$[5] = body;
|
|
991
|
-
$[6] = lang;
|
|
992
|
-
$[7] = open;
|
|
993
|
-
$[8] = renderShellCodeBlock;
|
|
994
|
-
$[9] = reply;
|
|
995
|
-
$[10] = source;
|
|
996
|
-
$[11] = t4;
|
|
997
|
-
} else {
|
|
998
|
-
t4 = $[11];
|
|
991
|
+
if (t2 !== Symbol.for("react.early_return_sentinel")) {
|
|
992
|
+
return t2;
|
|
999
993
|
}
|
|
1000
|
-
return
|
|
994
|
+
return t1;
|
|
1001
995
|
});
|
|
1002
996
|
/*
|
|
1003
997
|
* A reply in a chat thread, parsed a block at a time so a delta only parses the block that grows,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.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.51.0",
|
|
76
|
+
"@adecore/editor": "0.51.0",
|
|
77
|
+
"@adecore/editor-react": "0.51.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.51.0",
|
|
79
|
+
"@adecore/merge": "0.51.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.51.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.51.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/ui/Markdown.tsx
CHANGED
|
@@ -321,7 +321,7 @@ const replyComponents = {
|
|
|
321
321
|
function ReplyCode({ className, children, node }: { className?: string; children?: ReactNode } & ExtraProps) {
|
|
322
322
|
const reply = useContext(ShellCodeBlockReplyContext);
|
|
323
323
|
const block = useContext(BlockCodeContext);
|
|
324
|
-
const { renderShellCodeBlock } = useChatHost();
|
|
324
|
+
const { renderCodeFence, renderShellCodeBlock } = useChatHost();
|
|
325
325
|
const properties = node?.properties;
|
|
326
326
|
const language = properties?.['data-shell-language'];
|
|
327
327
|
const code = properties?.['data-shell-code'];
|
|
@@ -333,12 +333,20 @@ function ReplyCode({ className, children, node }: { className?: string; children
|
|
|
333
333
|
|
|
334
334
|
const text = String(children ?? '');
|
|
335
335
|
|
|
336
|
-
if (block && languageOf(className) === 'mermaid') {
|
|
337
|
-
return <Diagram code={text.replace(/\n$/, '')} />;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
336
|
if (block) {
|
|
341
|
-
|
|
337
|
+
const lang = languageOf(className);
|
|
338
|
+
const body = text.replace(/\n$/, '');
|
|
339
|
+
const drawn = renderCodeFence?.(lang, body);
|
|
340
|
+
|
|
341
|
+
if (drawn !== undefined && drawn !== null) {
|
|
342
|
+
return drawn;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (lang === 'mermaid') {
|
|
346
|
+
return <Diagram code={body} />;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return <CodeBlock code={body} lang={lang} actions={shellCodeBlockActions(reply, shell, renderShellCodeBlock)} />;
|
|
342
350
|
}
|
|
343
351
|
|
|
344
352
|
return <InlineCode text={text} />;
|
|
@@ -437,10 +445,16 @@ const ReplyFence = memo(function ReplyFence({
|
|
|
437
445
|
open: boolean;
|
|
438
446
|
reply?: ShellCodeBlockReply;
|
|
439
447
|
}) {
|
|
440
|
-
const { renderShellCodeBlock } = useChatHost();
|
|
448
|
+
const { renderCodeFence, renderShellCodeBlock } = useChatHost();
|
|
441
449
|
// The class markdown gives the code, read back the way a parsed fence's is.
|
|
442
450
|
const lang = languageOf(`language-${info.split(/[ \t]/, 1)[0]}`);
|
|
443
451
|
const shell = reply === undefined ? null : shellFence(source);
|
|
452
|
+
// The host gets a fence only once it closed, so it never draws a body that is still being written.
|
|
453
|
+
const drawn = open ? null : renderCodeFence?.(lang, body);
|
|
454
|
+
|
|
455
|
+
if (drawn !== undefined && drawn !== null) {
|
|
456
|
+
return drawn;
|
|
457
|
+
}
|
|
444
458
|
|
|
445
459
|
return (
|
|
446
460
|
<CodeStreamingContext.Provider value={open}>
|