@lvce-editor/chat-tool-worker 7.1.0 → 7.2.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/chatToolWorkerMain.js +10 -59
- package/package.json +1 -1
|
@@ -1071,72 +1071,23 @@ const executeOpenPreviewTool = async (args, _options) => {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
};
|
|
1073
1073
|
|
|
1074
|
-
const WINDOWS_ABSOLUTE_PATH_REGEX = /^[a-zA-Z]:[\\/]/;
|
|
1075
|
-
const PATH_SEGMENT_SPLIT_REGEX$1 = /[\\/]/;
|
|
1076
|
-
const isPathTraversalAttempt = path => {
|
|
1077
|
-
if (!path) {
|
|
1078
|
-
return false;
|
|
1079
|
-
}
|
|
1080
|
-
if (path.startsWith('/') || path.startsWith('\\')) {
|
|
1081
|
-
return true;
|
|
1082
|
-
}
|
|
1083
|
-
if (path.startsWith('file://')) {
|
|
1084
|
-
return true;
|
|
1085
|
-
}
|
|
1086
|
-
if (WINDOWS_ABSOLUTE_PATH_REGEX.test(path)) {
|
|
1087
|
-
return true;
|
|
1088
|
-
}
|
|
1089
|
-
const segments = path.split(PATH_SEGMENT_SPLIT_REGEX$1);
|
|
1090
|
-
return segments.includes('..');
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
const PATH_SEGMENT_SPLIT_REGEX = /[\\/]/;
|
|
1094
|
-
const normalizeRelativePath = path => {
|
|
1095
|
-
const segments = path.split(PATH_SEGMENT_SPLIT_REGEX).filter(segment => segment && segment !== '.');
|
|
1096
|
-
if (segments.length === 0) {
|
|
1097
|
-
return '.';
|
|
1098
|
-
}
|
|
1099
|
-
return segments.join('/');
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
1074
|
const executeReadFileTool = async (args, _options) => {
|
|
1103
1075
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1104
|
-
if (uri) {
|
|
1105
|
-
if (!isAbsoluteUri(uri)) {
|
|
1106
|
-
return {
|
|
1107
|
-
error: 'Invalid argument: uri must be an absolute URI.'
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
try {
|
|
1111
|
-
const content = await readFile(uri);
|
|
1112
|
-
return {
|
|
1113
|
-
content,
|
|
1114
|
-
uri
|
|
1115
|
-
};
|
|
1116
|
-
} catch (error) {
|
|
1117
|
-
return {
|
|
1118
|
-
...getToolErrorPayload(error),
|
|
1119
|
-
uri
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
const filePath = typeof args.path === 'string' ? args.path : '';
|
|
1124
|
-
if (!filePath || isPathTraversalAttempt(filePath)) {
|
|
1076
|
+
if (!uri || !isAbsoluteUri(uri)) {
|
|
1125
1077
|
return {
|
|
1126
|
-
error: '
|
|
1078
|
+
error: 'Invalid argument: uri must be an absolute URI.'
|
|
1127
1079
|
};
|
|
1128
1080
|
}
|
|
1129
|
-
const normalizedPath = normalizeRelativePath(filePath);
|
|
1130
1081
|
try {
|
|
1131
|
-
const content = await readFile(
|
|
1082
|
+
const content = await readFile(uri);
|
|
1132
1083
|
return {
|
|
1133
1084
|
content,
|
|
1134
|
-
|
|
1085
|
+
uri
|
|
1135
1086
|
};
|
|
1136
1087
|
} catch (error) {
|
|
1137
1088
|
return {
|
|
1138
1089
|
...getToolErrorPayload(error),
|
|
1139
|
-
|
|
1090
|
+
uri
|
|
1140
1091
|
};
|
|
1141
1092
|
}
|
|
1142
1093
|
};
|
|
@@ -1248,7 +1199,7 @@ const getReadFileTool = () => {
|
|
|
1248
1199
|
additionalProperties: false,
|
|
1249
1200
|
properties: {
|
|
1250
1201
|
uri: {
|
|
1251
|
-
description: 'Absolute file URI
|
|
1202
|
+
description: 'Absolute file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
|
|
1252
1203
|
type: 'string'
|
|
1253
1204
|
}
|
|
1254
1205
|
},
|
|
@@ -1272,7 +1223,7 @@ const getWriteFileTool = () => {
|
|
|
1272
1223
|
type: 'string'
|
|
1273
1224
|
},
|
|
1274
1225
|
uri: {
|
|
1275
|
-
description: 'Absolute file URI
|
|
1226
|
+
description: 'Absolute file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
|
|
1276
1227
|
type: 'string'
|
|
1277
1228
|
}
|
|
1278
1229
|
},
|
|
@@ -1292,7 +1243,7 @@ const getListFilesTool = () => {
|
|
|
1292
1243
|
additionalProperties: false,
|
|
1293
1244
|
properties: {
|
|
1294
1245
|
uri: {
|
|
1295
|
-
description: 'Absolute folder URI
|
|
1246
|
+
description: 'Absolute folder URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
|
|
1296
1247
|
type: 'string'
|
|
1297
1248
|
}
|
|
1298
1249
|
},
|
|
@@ -1354,7 +1305,7 @@ const getOpenPreviewTool = () => {
|
|
|
1354
1305
|
additionalProperties: false,
|
|
1355
1306
|
properties: {
|
|
1356
1307
|
uri: {
|
|
1357
|
-
description: 'Absolute HTML file URI
|
|
1308
|
+
description: 'Absolute HTML file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
|
|
1358
1309
|
type: 'string'
|
|
1359
1310
|
}
|
|
1360
1311
|
},
|
|
@@ -1374,7 +1325,7 @@ const getOpenEditorTool = () => {
|
|
|
1374
1325
|
additionalProperties: false,
|
|
1375
1326
|
properties: {
|
|
1376
1327
|
uri: {
|
|
1377
|
-
description: 'Absolute file URI
|
|
1328
|
+
description: 'Absolute file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
|
|
1378
1329
|
type: 'string'
|
|
1379
1330
|
}
|
|
1380
1331
|
},
|