@lvce-editor/chat-tool-worker 7.4.0 → 7.6.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 +103 -2
- package/package.json +1 -1
|
@@ -1123,6 +1123,59 @@ const executeRenderHtmlTool = async (args, _options) => {
|
|
|
1123
1123
|
};
|
|
1124
1124
|
};
|
|
1125
1125
|
|
|
1126
|
+
const getSearchOptions = args => {
|
|
1127
|
+
const {
|
|
1128
|
+
options
|
|
1129
|
+
} = args;
|
|
1130
|
+
if (!options || typeof options !== 'object') {
|
|
1131
|
+
return undefined;
|
|
1132
|
+
}
|
|
1133
|
+
const candidate = options;
|
|
1134
|
+
const {
|
|
1135
|
+
exclude,
|
|
1136
|
+
isRegex,
|
|
1137
|
+
machWholeWord,
|
|
1138
|
+
matchCase,
|
|
1139
|
+
value
|
|
1140
|
+
} = candidate;
|
|
1141
|
+
if (typeof value !== 'string' || typeof isRegex !== 'boolean' || typeof matchCase !== 'boolean' || typeof machWholeWord !== 'boolean') {
|
|
1142
|
+
return undefined;
|
|
1143
|
+
}
|
|
1144
|
+
if (!Array.isArray(exclude) || exclude.some(item => typeof item !== 'string')) {
|
|
1145
|
+
return undefined;
|
|
1146
|
+
}
|
|
1147
|
+
return {
|
|
1148
|
+
exclude,
|
|
1149
|
+
isRegex,
|
|
1150
|
+
machWholeWord,
|
|
1151
|
+
matchCase,
|
|
1152
|
+
value
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
const executeSearchTextTool = async (args, _options) => {
|
|
1156
|
+
const searchOptions = getSearchOptions(args);
|
|
1157
|
+
if (!searchOptions) {
|
|
1158
|
+
return {
|
|
1159
|
+
error: 'Invalid argument: options must include value (string), isRegex (boolean), matchCase (boolean), machWholeWord (boolean), and exclude (string[]).'
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
const results = [{
|
|
1163
|
+
column: 12,
|
|
1164
|
+
line: 5,
|
|
1165
|
+
text: `Mock match for "${searchOptions.value}" in src/main.ts`,
|
|
1166
|
+
uri: 'file:///workspace/src/main.ts'
|
|
1167
|
+
}, {
|
|
1168
|
+
column: 3,
|
|
1169
|
+
line: 18,
|
|
1170
|
+
text: `Mock match for "${searchOptions.value}" in src/utils/search.ts`,
|
|
1171
|
+
uri: 'file:///workspace/src/utils/search.ts'
|
|
1172
|
+
}];
|
|
1173
|
+
return {
|
|
1174
|
+
options: searchOptions,
|
|
1175
|
+
results
|
|
1176
|
+
};
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1126
1179
|
const executeWriteFileTool = async (args, _options) => {
|
|
1127
1180
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1128
1181
|
const content = typeof args.content === 'string' ? args.content : '';
|
|
@@ -1193,6 +1246,9 @@ const executeChatTool = async (name, rawArguments, options) => {
|
|
|
1193
1246
|
if (name === 'close_preview') {
|
|
1194
1247
|
return executeClosePreviewTool();
|
|
1195
1248
|
}
|
|
1249
|
+
if (name === 'search_text') {
|
|
1250
|
+
return executeSearchTextTool(args);
|
|
1251
|
+
}
|
|
1196
1252
|
return {
|
|
1197
1253
|
error: `Unknown tool: ${name}`
|
|
1198
1254
|
};
|
|
@@ -1358,8 +1414,49 @@ const getClosePreviewTool = () => {
|
|
|
1358
1414
|
type: 'function'
|
|
1359
1415
|
};
|
|
1360
1416
|
};
|
|
1417
|
+
const getSearchTextTool = () => {
|
|
1418
|
+
return {
|
|
1419
|
+
function: {
|
|
1420
|
+
description: 'Search text in workspace files using query options and return matching results.',
|
|
1421
|
+
name: 'search_text',
|
|
1422
|
+
parameters: {
|
|
1423
|
+
additionalProperties: false,
|
|
1424
|
+
properties: {
|
|
1425
|
+
options: {
|
|
1426
|
+
additionalProperties: false,
|
|
1427
|
+
properties: {
|
|
1428
|
+
exclude: {
|
|
1429
|
+
items: {
|
|
1430
|
+
type: 'string'
|
|
1431
|
+
},
|
|
1432
|
+
type: 'array'
|
|
1433
|
+
},
|
|
1434
|
+
isRegex: {
|
|
1435
|
+
type: 'boolean'
|
|
1436
|
+
},
|
|
1437
|
+
machWholeWord: {
|
|
1438
|
+
type: 'boolean'
|
|
1439
|
+
},
|
|
1440
|
+
matchCase: {
|
|
1441
|
+
type: 'boolean'
|
|
1442
|
+
},
|
|
1443
|
+
value: {
|
|
1444
|
+
type: 'string'
|
|
1445
|
+
}
|
|
1446
|
+
},
|
|
1447
|
+
required: ['value', 'isRegex', 'matchCase', 'machWholeWord', 'exclude'],
|
|
1448
|
+
type: 'object'
|
|
1449
|
+
}
|
|
1450
|
+
},
|
|
1451
|
+
required: ['options'],
|
|
1452
|
+
type: 'object'
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1455
|
+
type: 'function'
|
|
1456
|
+
};
|
|
1457
|
+
};
|
|
1361
1458
|
const getBasicChatTools = () => {
|
|
1362
|
-
return [getReadFileTool(), getWriteFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool()];
|
|
1459
|
+
return [getReadFileTool(), getWriteFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool()];
|
|
1363
1460
|
};
|
|
1364
1461
|
|
|
1365
1462
|
const handleMessagePort = async port => {
|
|
@@ -1375,13 +1472,17 @@ const commandMap = {
|
|
|
1375
1472
|
'HandleMessagePort.handleMessagePort': handleMessagePort
|
|
1376
1473
|
};
|
|
1377
1474
|
|
|
1378
|
-
const
|
|
1475
|
+
const initializeRendererWorker = async () => {
|
|
1379
1476
|
const rpc = await create$1({
|
|
1380
1477
|
commandMap: commandMap
|
|
1381
1478
|
});
|
|
1382
1479
|
set(rpc);
|
|
1383
1480
|
};
|
|
1384
1481
|
|
|
1482
|
+
const listen = async () => {
|
|
1483
|
+
await initializeRendererWorker();
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1385
1486
|
const main = async () => {
|
|
1386
1487
|
await listen();
|
|
1387
1488
|
};
|