@xapp/chat-widget 1.92.0 → 1.93.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/index.css +1 -1
- package/dist/index.es.js +34 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/dist/store/ChatAction.d.ts +0 -0
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +2 -2
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3635,6 +3635,7 @@ var MCPChat = /** @class */ (function () {
|
|
|
3635
3635
|
toolCallId: params.toolCallId,
|
|
3636
3636
|
displayName: params.displayName,
|
|
3637
3637
|
label: params.label,
|
|
3638
|
+
toolInput: params.toolInput,
|
|
3638
3639
|
hidden: params.hidden,
|
|
3639
3640
|
toolResult: params.toolResult,
|
|
3640
3641
|
toolError: params.toolError,
|
|
@@ -4164,6 +4165,7 @@ var MCPChat = /** @class */ (function () {
|
|
|
4164
4165
|
displayName: data.displayName,
|
|
4165
4166
|
label: data.label,
|
|
4166
4167
|
hidden: data.hidden,
|
|
4168
|
+
toolInput: data.toolInput,
|
|
4167
4169
|
toolResult: data.toolResult,
|
|
4168
4170
|
toolError: data.toolError,
|
|
4169
4171
|
});
|
|
@@ -11620,14 +11622,14 @@ var ToolCallDisplay = function (_a) {
|
|
|
11620
11622
|
};
|
|
11621
11623
|
|
|
11622
11624
|
/**
|
|
11623
|
-
* Escape &, <,
|
|
11624
|
-
* Not suitable for attribute values.
|
|
11625
|
+
* Escape &, <, >, and " for safe insertion into HTML text nodes and attribute values.
|
|
11625
11626
|
*/
|
|
11626
11627
|
function escapeHtml(text) {
|
|
11627
11628
|
return text
|
|
11628
11629
|
.replace(/&/g, "&")
|
|
11629
11630
|
.replace(/</g, "<")
|
|
11630
|
-
.replace(/>/g, ">")
|
|
11631
|
+
.replace(/>/g, ">")
|
|
11632
|
+
.replace(/"/g, """);
|
|
11631
11633
|
}
|
|
11632
11634
|
function parseInlineMarkdown(text) {
|
|
11633
11635
|
return escapeHtml(text)
|
|
@@ -11664,13 +11666,27 @@ function tableToHtml(headerLine, separatorLine, bodyBlock) {
|
|
|
11664
11666
|
function parseMarkdown(text) {
|
|
11665
11667
|
if (!text)
|
|
11666
11668
|
return "";
|
|
11667
|
-
// Extract
|
|
11669
|
+
// Extract fenced code blocks first, replace with placeholders
|
|
11670
|
+
var codeBlocks = [];
|
|
11671
|
+
var processed = text.replace(/```([^\s`]*)\r?\n([\s\S]*?)```/g, function (_match, lang, code) {
|
|
11672
|
+
var escaped = escapeHtml(code.replace(/\n$/, ""));
|
|
11673
|
+
var langAttr = lang ? " data-language=\"".concat(escapeHtml(lang), "\"") : "";
|
|
11674
|
+
codeBlocks.push("<pre><code".concat(langAttr, ">").concat(escaped, "</code></pre>"));
|
|
11675
|
+
return "%%CODEBLOCK".concat(codeBlocks.length - 1, "%%");
|
|
11676
|
+
});
|
|
11677
|
+
// Extract tables, replace with placeholders
|
|
11668
11678
|
var tables = [];
|
|
11669
|
-
|
|
11679
|
+
processed = processed.replace(/(?:^|\n)(\|.+\|)\n(\|[\s:|-]+\|)\n((?:\|.+\|\n?)+)/g, function (_match, headerLine, separatorLine, bodyBlock) {
|
|
11670
11680
|
tables.push(tableToHtml(headerLine, separatorLine, bodyBlock));
|
|
11671
11681
|
return "\n%%TABLE".concat(tables.length - 1, "%%\n");
|
|
11672
11682
|
});
|
|
11673
|
-
//
|
|
11683
|
+
// Extract inline code, replace with placeholders
|
|
11684
|
+
var inlineCodes = [];
|
|
11685
|
+
processed = processed.replace(/`([^`\n]+)`/g, function (_match, code) {
|
|
11686
|
+
inlineCodes.push("<code>".concat(escapeHtml(code), "</code>"));
|
|
11687
|
+
return "%%INLINECODE".concat(inlineCodes.length - 1, "%%");
|
|
11688
|
+
});
|
|
11689
|
+
// Now safely escape and parse markdown on the non-table/code text
|
|
11674
11690
|
processed = processed
|
|
11675
11691
|
.replace(/&/g, "&")
|
|
11676
11692
|
.replace(/</g, "<")
|
|
@@ -11699,8 +11715,17 @@ function parseMarkdown(text) {
|
|
|
11699
11715
|
return match.replace(/<br>/g, "");
|
|
11700
11716
|
});
|
|
11701
11717
|
// Restore table placeholders (strip adjacent <br> tags)
|
|
11718
|
+
// Use function replacer to avoid $ special-sequence interpretation in replacement strings
|
|
11702
11719
|
tables.forEach(function (tableHtml, i) {
|
|
11703
|
-
processed = processed.replace(new RegExp("(?:<br>)?%%TABLE".concat(i, "%%(?:<br>)?")), tableHtml);
|
|
11720
|
+
processed = processed.replace(new RegExp("(?:<br>)?%%TABLE".concat(i, "%%(?:<br>)?")), function () { return tableHtml; });
|
|
11721
|
+
});
|
|
11722
|
+
// Restore code block placeholders (strip adjacent <br> tags)
|
|
11723
|
+
codeBlocks.forEach(function (codeHtml, i) {
|
|
11724
|
+
processed = processed.replace(new RegExp("(?:<br>)?%%CODEBLOCK".concat(i, "%%(?:<br>)?")), function () { return codeHtml; });
|
|
11725
|
+
});
|
|
11726
|
+
// Restore inline code placeholders
|
|
11727
|
+
inlineCodes.forEach(function (codeHtml, i) {
|
|
11728
|
+
processed = processed.replace("%%INLINECODE".concat(i, "%%"), function () { return codeHtml; });
|
|
11704
11729
|
});
|
|
11705
11730
|
return processed;
|
|
11706
11731
|
}
|
|
@@ -36622,13 +36647,13 @@ function update(state, action) {
|
|
|
36622
36647
|
var _a;
|
|
36623
36648
|
if (index === streamingIndex_3 && isChatMsgDetail(chat)) {
|
|
36624
36649
|
var toolCalls = (_a = chat.toolCalls) === null || _a === void 0 ? void 0 : _a.map(function (tc) {
|
|
36625
|
-
var _a;
|
|
36650
|
+
var _a, _b;
|
|
36626
36651
|
// Match by toolCallId if available, otherwise fall back to name + isExecuting
|
|
36627
36652
|
var isMatch = toolEndDetail_1.toolCallId
|
|
36628
36653
|
? tc.toolCallId === toolEndDetail_1.toolCallId
|
|
36629
36654
|
: tc.name === toolEndDetail_1.toolName && tc.isExecuting;
|
|
36630
36655
|
if (isMatch) {
|
|
36631
|
-
return __assign(__assign({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
|
|
36656
|
+
return __assign(__assign({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, input: (_b = toolEndDetail_1.toolInput) !== null && _b !== void 0 ? _b : tc.input, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
|
|
36632
36657
|
}
|
|
36633
36658
|
return tc;
|
|
36634
36659
|
});
|