@lvce-editor/chat-view 6.3.0 → 6.4.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/chatViewWorkerMain.js +83 -4
- package/package.json +1 -1
|
@@ -3336,7 +3336,7 @@ const executeChatTool = async (name, rawArguments, options) => {
|
|
|
3336
3336
|
const getReadFileTool = () => {
|
|
3337
3337
|
return {
|
|
3338
3338
|
function: {
|
|
3339
|
-
description: 'Read UTF-8 text content from a file inside the currently open workspace folder. Only pass an absolute URI.',
|
|
3339
|
+
description: 'Read UTF-8 text content from a file inside the currently open workspace folder. Only pass an absolute URI. When you reference files in your response, use markdown links like [index.ts](file:///workspace/src/index.ts).',
|
|
3340
3340
|
name: 'read_file',
|
|
3341
3341
|
parameters: {
|
|
3342
3342
|
additionalProperties: false,
|
|
@@ -4042,6 +4042,25 @@ const getToolCallExecutionStatus = content => {
|
|
|
4042
4042
|
status: 'error'
|
|
4043
4043
|
};
|
|
4044
4044
|
};
|
|
4045
|
+
const getToolCallResult = (name, content) => {
|
|
4046
|
+
if (name !== 'getWorkspaceUri') {
|
|
4047
|
+
return undefined;
|
|
4048
|
+
}
|
|
4049
|
+
let parsed;
|
|
4050
|
+
try {
|
|
4051
|
+
parsed = JSON.parse(content);
|
|
4052
|
+
} catch {
|
|
4053
|
+
return undefined;
|
|
4054
|
+
}
|
|
4055
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
4056
|
+
return undefined;
|
|
4057
|
+
}
|
|
4058
|
+
const workspaceUri = Reflect.get(parsed, 'workspaceUri');
|
|
4059
|
+
if (typeof workspaceUri !== 'string' || !workspaceUri) {
|
|
4060
|
+
return undefined;
|
|
4061
|
+
}
|
|
4062
|
+
return workspaceUri;
|
|
4063
|
+
};
|
|
4045
4064
|
const getResponseOutputText = parsed => {
|
|
4046
4065
|
if (!parsed || typeof parsed !== 'object') {
|
|
4047
4066
|
return '';
|
|
@@ -4645,6 +4664,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4645
4664
|
useChatToolWorker
|
|
4646
4665
|
});
|
|
4647
4666
|
const executionStatus = getToolCallExecutionStatus(content);
|
|
4667
|
+
const toolCallResult = getToolCallResult(toolCall.name, content);
|
|
4648
4668
|
executedToolCalls.push({
|
|
4649
4669
|
arguments: toolCall.arguments,
|
|
4650
4670
|
...(executionStatus.errorStack ? {
|
|
@@ -4658,6 +4678,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4658
4678
|
} : {}),
|
|
4659
4679
|
id: toolCall.callId,
|
|
4660
4680
|
name: toolCall.name,
|
|
4681
|
+
...(toolCallResult ? {
|
|
4682
|
+
result: toolCallResult
|
|
4683
|
+
} : {}),
|
|
4661
4684
|
...(executionStatus.status ? {
|
|
4662
4685
|
status: executionStatus.status
|
|
4663
4686
|
} : {})
|
|
@@ -4790,6 +4813,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4790
4813
|
useChatToolWorker
|
|
4791
4814
|
});
|
|
4792
4815
|
const executionStatus = getToolCallExecutionStatus(content);
|
|
4816
|
+
const toolCallResult = getToolCallResult(toolCall.name, content);
|
|
4793
4817
|
executedToolCalls.push({
|
|
4794
4818
|
arguments: toolCall.arguments,
|
|
4795
4819
|
...(executionStatus.errorStack ? {
|
|
@@ -4803,6 +4827,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4803
4827
|
} : {}),
|
|
4804
4828
|
id: toolCall.callId,
|
|
4805
4829
|
name: toolCall.name,
|
|
4830
|
+
...(toolCallResult ? {
|
|
4831
|
+
result: toolCallResult
|
|
4832
|
+
} : {}),
|
|
4806
4833
|
...(executionStatus.status ? {
|
|
4807
4834
|
status: executionStatus.status
|
|
4808
4835
|
} : {})
|
|
@@ -4863,6 +4890,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4863
4890
|
}) : '{}';
|
|
4864
4891
|
if (typeof name === 'string') {
|
|
4865
4892
|
const executionStatus = getToolCallExecutionStatus(content);
|
|
4893
|
+
const toolCallResult = getToolCallResult(name, content);
|
|
4866
4894
|
executedToolCalls.push({
|
|
4867
4895
|
arguments: typeof rawArguments === 'string' ? rawArguments : '',
|
|
4868
4896
|
...(executionStatus.errorStack ? {
|
|
@@ -4876,6 +4904,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
|
|
|
4876
4904
|
} : {}),
|
|
4877
4905
|
id,
|
|
4878
4906
|
name,
|
|
4907
|
+
...(toolCallResult ? {
|
|
4908
|
+
result: toolCallResult
|
|
4909
|
+
} : {}),
|
|
4879
4910
|
...(executionStatus.status ? {
|
|
4880
4911
|
status: executionStatus.status
|
|
4881
4912
|
} : {})
|
|
@@ -5756,7 +5787,14 @@ const isAlphaNumeric = value => {
|
|
|
5756
5787
|
}
|
|
5757
5788
|
return code >= 97 && code <= 122;
|
|
5758
5789
|
};
|
|
5759
|
-
const
|
|
5790
|
+
const sanitizeLinkUrl = url => {
|
|
5791
|
+
const normalized = url.trim().toLowerCase();
|
|
5792
|
+
if (normalized.startsWith('http://') || normalized.startsWith('https://') || normalized.startsWith('file://')) {
|
|
5793
|
+
return url;
|
|
5794
|
+
}
|
|
5795
|
+
return '#';
|
|
5796
|
+
};
|
|
5797
|
+
const sanitizeImageUrl = url => {
|
|
5760
5798
|
const normalized = url.trim().toLowerCase();
|
|
5761
5799
|
if (normalized.startsWith('http://') || normalized.startsWith('https://')) {
|
|
5762
5800
|
return url;
|
|
@@ -5794,7 +5832,7 @@ const parseLinkToken = (value, start) => {
|
|
|
5794
5832
|
return {
|
|
5795
5833
|
length: index - start + 1,
|
|
5796
5834
|
node: {
|
|
5797
|
-
href:
|
|
5835
|
+
href: sanitizeLinkUrl(href),
|
|
5798
5836
|
text,
|
|
5799
5837
|
type: 'link'
|
|
5800
5838
|
}
|
|
@@ -5837,7 +5875,7 @@ const parseImageToken = (value, start) => {
|
|
|
5837
5875
|
length: index - start + 1,
|
|
5838
5876
|
node: {
|
|
5839
5877
|
alt,
|
|
5840
|
-
src:
|
|
5878
|
+
src: sanitizeImageUrl(src),
|
|
5841
5879
|
type: 'image'
|
|
5842
5880
|
}
|
|
5843
5881
|
};
|
|
@@ -8618,6 +8656,30 @@ const getCss = (composerHeight, listItemHeight, chatMessageFontSize, chatMessage
|
|
|
8618
8656
|
.StrikeThrough {
|
|
8619
8657
|
text-decoration: line-through;
|
|
8620
8658
|
}
|
|
8659
|
+
|
|
8660
|
+
/* syntax highlight token colors */
|
|
8661
|
+
.TokenComment {
|
|
8662
|
+
color: var(--ColorSymbolIconColorForeground, #7f8794);
|
|
8663
|
+
}
|
|
8664
|
+
|
|
8665
|
+
.TokenString {
|
|
8666
|
+
color: var(--ColorChartsGreen, #a6d189);
|
|
8667
|
+
}
|
|
8668
|
+
|
|
8669
|
+
.TokenNumber,
|
|
8670
|
+
.TokenValue {
|
|
8671
|
+
color: var(--ColorChartsBlue, #8caaee);
|
|
8672
|
+
}
|
|
8673
|
+
|
|
8674
|
+
.TokenKeyword,
|
|
8675
|
+
.TokenTag {
|
|
8676
|
+
color: var(--ColorChartsPurple, #ca9ee6);
|
|
8677
|
+
}
|
|
8678
|
+
|
|
8679
|
+
.TokenAttribute,
|
|
8680
|
+
.TokenProperty {
|
|
8681
|
+
color: var(--ColorChartsOrange, #ef9f76);
|
|
8682
|
+
}
|
|
8621
8683
|
`;
|
|
8622
8684
|
if (!renderHtmlCss.trim()) {
|
|
8623
8685
|
return baseCss;
|
|
@@ -8908,6 +8970,9 @@ const getImageAltText = alt => {
|
|
|
8908
8970
|
}
|
|
8909
8971
|
return `${alt} (image could not be loaded)`;
|
|
8910
8972
|
};
|
|
8973
|
+
const isFileUri = href => {
|
|
8974
|
+
return href.trim().toLowerCase().startsWith('file://');
|
|
8975
|
+
};
|
|
8911
8976
|
const getInlineNodeDom = (inlineNode, useChatMathWorker = false) => {
|
|
8912
8977
|
if (inlineNode.type === 'text') {
|
|
8913
8978
|
return [text(inlineNode.text)];
|
|
@@ -8953,6 +9018,17 @@ const getInlineNodeDom = (inlineNode, useChatMathWorker = false) => {
|
|
|
8953
9018
|
if (inlineNode.type === 'math-inline-dom') {
|
|
8954
9019
|
return inlineNode.dom;
|
|
8955
9020
|
}
|
|
9021
|
+
if (isFileUri(inlineNode.href)) {
|
|
9022
|
+
return [{
|
|
9023
|
+
childCount: 1,
|
|
9024
|
+
className: ChatMessageLink,
|
|
9025
|
+
'data-uri': inlineNode.href,
|
|
9026
|
+
href: '#',
|
|
9027
|
+
onClick: HandleClickReadFile,
|
|
9028
|
+
title: inlineNode.href,
|
|
9029
|
+
type: A
|
|
9030
|
+
}, text(inlineNode.text)];
|
|
9031
|
+
}
|
|
8956
9032
|
return [{
|
|
8957
9033
|
childCount: 1,
|
|
8958
9034
|
className: ChatMessageLink,
|
|
@@ -9826,6 +9902,9 @@ const getToolCallDisplayName = name => {
|
|
|
9826
9902
|
};
|
|
9827
9903
|
const getToolCallLabel = toolCall => {
|
|
9828
9904
|
const displayName = getToolCallDisplayName(toolCall.name);
|
|
9905
|
+
if (toolCall.name === 'getWorkspaceUri' && toolCall.result) {
|
|
9906
|
+
return `${displayName} ${toolCall.result}`;
|
|
9907
|
+
}
|
|
9829
9908
|
const argumentPreview = getToolCallArgumentPreview(toolCall.arguments);
|
|
9830
9909
|
const statusLabel = getToolCallStatusLabel(toolCall);
|
|
9831
9910
|
if (argumentPreview === '{}') {
|