@lvce-editor/chat-view 6.3.0 → 6.5.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.
@@ -54,6 +54,49 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
+ class AssertionError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'AssertionError';
61
+ }
62
+ }
63
+ const Object$1 = 1;
64
+ const Number$1 = 2;
65
+ const Array$1 = 3;
66
+ const String$1 = 4;
67
+ const Boolean$1 = 5;
68
+ const Function = 6;
69
+ const Null = 7;
70
+ const Unknown = 8;
71
+ const getType = value => {
72
+ switch (typeof value) {
73
+ case 'number':
74
+ return Number$1;
75
+ case 'function':
76
+ return Function;
77
+ case 'string':
78
+ return String$1;
79
+ case 'object':
80
+ if (value === null) {
81
+ return Null;
82
+ }
83
+ if (Array.isArray(value)) {
84
+ return Array$1;
85
+ }
86
+ return Object$1;
87
+ case 'boolean':
88
+ return Boolean$1;
89
+ default:
90
+ return Unknown;
91
+ }
92
+ };
93
+ const number = value => {
94
+ const type = getType(value);
95
+ if (type !== Number$1) {
96
+ throw new AssertionError('expected value to be of type number');
97
+ }
98
+ };
99
+
57
100
  const isMessagePort = value => {
58
101
  return value && value instanceof MessagePort;
59
102
  };
@@ -1152,6 +1195,8 @@ const Enter = 3;
1152
1195
 
1153
1196
  const Shift = 1 << 10 >>> 0;
1154
1197
 
1198
+ const Chat$1 = 97;
1199
+
1155
1200
  const Separator = 1;
1156
1201
  const None = 0;
1157
1202
  const RestoreFocus = 6;
@@ -1196,6 +1241,13 @@ const {
1196
1241
  invokeAndTransfer,
1197
1242
  set: set$2
1198
1243
  } = create$2(RendererWorker);
1244
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1245
+ number(uid);
1246
+ number(menuId);
1247
+ number(x);
1248
+ number(y);
1249
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1250
+ };
1199
1251
  const sendMessagePortToOpenerWorker$1 = async (port, rpcId) => {
1200
1252
  const command = 'HandleMessagePort.handleMessagePort';
1201
1253
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
@@ -2908,6 +2960,12 @@ const menuEntryCopyPath = {
2908
2960
  id: 'copyPath',
2909
2961
  label: copyPath()
2910
2962
  };
2963
+ const menuEntryCopyAsE2eTest = {
2964
+ command: 'Chat.copyAsE2eTest',
2965
+ flags: None,
2966
+ id: 'copyAsE2eTest',
2967
+ label: copyPath()
2968
+ };
2911
2969
  const menuEntryCopyRelativePath = {
2912
2970
  command: 'Explorer.copyRelativePath',
2913
2971
  flags: RestoreFocus,
@@ -2927,14 +2985,14 @@ const menuEntryDelete = {
2927
2985
  label: deleteItem()
2928
2986
  };
2929
2987
  const getMenuEntriesFile = () => {
2930
- return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2988
+ return [menuEntryCopyAsE2eTest, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2931
2989
  };
2932
2990
  const getMenuEntries = () => {
2933
2991
  return getMenuEntriesFile();
2934
2992
  };
2935
2993
 
2936
2994
  const getMenuEntryIds = () => {
2937
- return [];
2995
+ return [Chat$1];
2938
2996
  };
2939
2997
 
2940
2998
  const getQuickPickMenuEntries = () => {
@@ -3336,7 +3394,7 @@ const executeChatTool = async (name, rawArguments, options) => {
3336
3394
  const getReadFileTool = () => {
3337
3395
  return {
3338
3396
  function: {
3339
- description: 'Read UTF-8 text content from a file inside the currently open workspace folder. Only pass an absolute URI.',
3397
+ 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
3398
  name: 'read_file',
3341
3399
  parameters: {
3342
3400
  additionalProperties: false,
@@ -4042,6 +4100,25 @@ const getToolCallExecutionStatus = content => {
4042
4100
  status: 'error'
4043
4101
  };
4044
4102
  };
4103
+ const getToolCallResult = (name, content) => {
4104
+ if (name !== 'getWorkspaceUri') {
4105
+ return undefined;
4106
+ }
4107
+ let parsed;
4108
+ try {
4109
+ parsed = JSON.parse(content);
4110
+ } catch {
4111
+ return undefined;
4112
+ }
4113
+ if (!parsed || typeof parsed !== 'object') {
4114
+ return undefined;
4115
+ }
4116
+ const workspaceUri = Reflect.get(parsed, 'workspaceUri');
4117
+ if (typeof workspaceUri !== 'string' || !workspaceUri) {
4118
+ return undefined;
4119
+ }
4120
+ return workspaceUri;
4121
+ };
4045
4122
  const getResponseOutputText = parsed => {
4046
4123
  if (!parsed || typeof parsed !== 'object') {
4047
4124
  return '';
@@ -4645,6 +4722,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4645
4722
  useChatToolWorker
4646
4723
  });
4647
4724
  const executionStatus = getToolCallExecutionStatus(content);
4725
+ const toolCallResult = getToolCallResult(toolCall.name, content);
4648
4726
  executedToolCalls.push({
4649
4727
  arguments: toolCall.arguments,
4650
4728
  ...(executionStatus.errorStack ? {
@@ -4658,6 +4736,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4658
4736
  } : {}),
4659
4737
  id: toolCall.callId,
4660
4738
  name: toolCall.name,
4739
+ ...(toolCallResult ? {
4740
+ result: toolCallResult
4741
+ } : {}),
4661
4742
  ...(executionStatus.status ? {
4662
4743
  status: executionStatus.status
4663
4744
  } : {})
@@ -4790,6 +4871,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4790
4871
  useChatToolWorker
4791
4872
  });
4792
4873
  const executionStatus = getToolCallExecutionStatus(content);
4874
+ const toolCallResult = getToolCallResult(toolCall.name, content);
4793
4875
  executedToolCalls.push({
4794
4876
  arguments: toolCall.arguments,
4795
4877
  ...(executionStatus.errorStack ? {
@@ -4803,6 +4885,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4803
4885
  } : {}),
4804
4886
  id: toolCall.callId,
4805
4887
  name: toolCall.name,
4888
+ ...(toolCallResult ? {
4889
+ result: toolCallResult
4890
+ } : {}),
4806
4891
  ...(executionStatus.status ? {
4807
4892
  status: executionStatus.status
4808
4893
  } : {})
@@ -4863,6 +4948,7 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4863
4948
  }) : '{}';
4864
4949
  if (typeof name === 'string') {
4865
4950
  const executionStatus = getToolCallExecutionStatus(content);
4951
+ const toolCallResult = getToolCallResult(name, content);
4866
4952
  executedToolCalls.push({
4867
4953
  arguments: typeof rawArguments === 'string' ? rawArguments : '',
4868
4954
  ...(executionStatus.errorStack ? {
@@ -4876,6 +4962,9 @@ const getOpenApiAssistantText = async (messages, modelId, openApiApiKey, openApi
4876
4962
  } : {}),
4877
4963
  id,
4878
4964
  name,
4965
+ ...(toolCallResult ? {
4966
+ result: toolCallResult
4967
+ } : {}),
4879
4968
  ...(executionStatus.status ? {
4880
4969
  status: executionStatus.status
4881
4970
  } : {})
@@ -5756,7 +5845,14 @@ const isAlphaNumeric = value => {
5756
5845
  }
5757
5846
  return code >= 97 && code <= 122;
5758
5847
  };
5759
- const sanitizeUrl = url => {
5848
+ const sanitizeLinkUrl = url => {
5849
+ const normalized = url.trim().toLowerCase();
5850
+ if (normalized.startsWith('http://') || normalized.startsWith('https://') || normalized.startsWith('file://')) {
5851
+ return url;
5852
+ }
5853
+ return '#';
5854
+ };
5855
+ const sanitizeImageUrl = url => {
5760
5856
  const normalized = url.trim().toLowerCase();
5761
5857
  if (normalized.startsWith('http://') || normalized.startsWith('https://')) {
5762
5858
  return url;
@@ -5794,7 +5890,7 @@ const parseLinkToken = (value, start) => {
5794
5890
  return {
5795
5891
  length: index - start + 1,
5796
5892
  node: {
5797
- href: sanitizeUrl(href),
5893
+ href: sanitizeLinkUrl(href),
5798
5894
  text,
5799
5895
  type: 'link'
5800
5896
  }
@@ -5837,7 +5933,7 @@ const parseImageToken = (value, start) => {
5837
5933
  length: index - start + 1,
5838
5934
  node: {
5839
5935
  alt,
5840
- src: sanitizeUrl(src),
5936
+ src: sanitizeImageUrl(src),
5841
5937
  type: 'image'
5842
5938
  }
5843
5939
  };
@@ -7781,8 +7877,13 @@ const handleKeyDown = async (state, key, shiftKey) => {
7781
7877
  return handleSubmit(submitState);
7782
7878
  };
7783
7879
 
7784
- const handleMessagesContextMenu = async state => {
7785
- await invoke$1('ContextMenu.show', 1234);
7880
+ const handleMessagesContextMenu = async (state, button, x, y) => {
7881
+ const {
7882
+ uid
7883
+ } = state;
7884
+ await showContextMenu2(uid, Chat$1, x, y, {
7885
+ menuId: Chat$1
7886
+ });
7786
7887
  return state;
7787
7888
  };
7788
7889
 
@@ -8618,6 +8719,30 @@ const getCss = (composerHeight, listItemHeight, chatMessageFontSize, chatMessage
8618
8719
  .StrikeThrough {
8619
8720
  text-decoration: line-through;
8620
8721
  }
8722
+
8723
+ /* syntax highlight token colors */
8724
+ .TokenComment {
8725
+ color: var(--ColorSymbolIconColorForeground, #7f8794);
8726
+ }
8727
+
8728
+ .TokenString {
8729
+ color: var(--ColorChartsGreen, #a6d189);
8730
+ }
8731
+
8732
+ .TokenNumber,
8733
+ .TokenValue {
8734
+ color: var(--ColorChartsBlue, #8caaee);
8735
+ }
8736
+
8737
+ .TokenKeyword,
8738
+ .TokenTag {
8739
+ color: var(--ColorChartsPurple, #ca9ee6);
8740
+ }
8741
+
8742
+ .TokenAttribute,
8743
+ .TokenProperty {
8744
+ color: var(--ColorChartsOrange, #ef9f76);
8745
+ }
8621
8746
  `;
8622
8747
  if (!renderHtmlCss.trim()) {
8623
8748
  return baseCss;
@@ -8908,6 +9033,9 @@ const getImageAltText = alt => {
8908
9033
  }
8909
9034
  return `${alt} (image could not be loaded)`;
8910
9035
  };
9036
+ const isFileUri = href => {
9037
+ return href.trim().toLowerCase().startsWith('file://');
9038
+ };
8911
9039
  const getInlineNodeDom = (inlineNode, useChatMathWorker = false) => {
8912
9040
  if (inlineNode.type === 'text') {
8913
9041
  return [text(inlineNode.text)];
@@ -8953,6 +9081,17 @@ const getInlineNodeDom = (inlineNode, useChatMathWorker = false) => {
8953
9081
  if (inlineNode.type === 'math-inline-dom') {
8954
9082
  return inlineNode.dom;
8955
9083
  }
9084
+ if (isFileUri(inlineNode.href)) {
9085
+ return [{
9086
+ childCount: 1,
9087
+ className: ChatMessageLink,
9088
+ 'data-uri': inlineNode.href,
9089
+ href: '#',
9090
+ onClick: HandleClickReadFile,
9091
+ title: inlineNode.href,
9092
+ type: A
9093
+ }, text(inlineNode.text)];
9094
+ }
8956
9095
  return [{
8957
9096
  childCount: 1,
8958
9097
  className: ChatMessageLink,
@@ -9826,6 +9965,9 @@ const getToolCallDisplayName = name => {
9826
9965
  };
9827
9966
  const getToolCallLabel = toolCall => {
9828
9967
  const displayName = getToolCallDisplayName(toolCall.name);
9968
+ if (toolCall.name === 'getWorkspaceUri' && toolCall.result) {
9969
+ return `${displayName} ${toolCall.result}`;
9970
+ }
9829
9971
  const argumentPreview = getToolCallArgumentPreview(toolCall.arguments);
9830
9972
  const statusLabel = getToolCallStatusLabel(toolCall);
9831
9973
  if (argumentPreview === '{}') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-view",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "Chat View Worker",
5
5
  "repository": {
6
6
  "type": "git",