@lvce-editor/chat-tool-worker 7.0.0 → 7.1.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 +45 -1
- package/package.json +1 -1
|
@@ -1029,6 +1029,27 @@ const executeListFilesTool = async (args, _options) => {
|
|
|
1029
1029
|
}
|
|
1030
1030
|
};
|
|
1031
1031
|
|
|
1032
|
+
const executeOpenEditorTool = async (args, _options) => {
|
|
1033
|
+
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1034
|
+
if (!uri || !isAbsoluteUri(uri)) {
|
|
1035
|
+
return {
|
|
1036
|
+
error: 'Invalid argument: uri must be an absolute URI.'
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
try {
|
|
1040
|
+
await invoke('Main.openUri', uri);
|
|
1041
|
+
return {
|
|
1042
|
+
ok: true,
|
|
1043
|
+
uri
|
|
1044
|
+
};
|
|
1045
|
+
} catch (error) {
|
|
1046
|
+
return {
|
|
1047
|
+
...getToolErrorPayload(error),
|
|
1048
|
+
uri
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1032
1053
|
const executeOpenPreviewTool = async (args, _options) => {
|
|
1033
1054
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1034
1055
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
@@ -1207,6 +1228,9 @@ const executeChatTool = async (name, rawArguments, options) => {
|
|
|
1207
1228
|
if (name === 'open_preview') {
|
|
1208
1229
|
return executeOpenPreviewTool(args);
|
|
1209
1230
|
}
|
|
1231
|
+
if (name === 'openEditor') {
|
|
1232
|
+
return executeOpenEditorTool(args);
|
|
1233
|
+
}
|
|
1210
1234
|
if (name === 'close_preview') {
|
|
1211
1235
|
return executeClosePreviewTool();
|
|
1212
1236
|
}
|
|
@@ -1341,6 +1365,26 @@ const getOpenPreviewTool = () => {
|
|
|
1341
1365
|
type: 'function'
|
|
1342
1366
|
};
|
|
1343
1367
|
};
|
|
1368
|
+
const getOpenEditorTool = () => {
|
|
1369
|
+
return {
|
|
1370
|
+
function: {
|
|
1371
|
+
description: 'Open a file URI in the editor.',
|
|
1372
|
+
name: 'openEditor',
|
|
1373
|
+
parameters: {
|
|
1374
|
+
additionalProperties: false,
|
|
1375
|
+
properties: {
|
|
1376
|
+
uri: {
|
|
1377
|
+
description: 'Absolute file URI to open in the editor (for example: file:///workspace/src/index.ts).',
|
|
1378
|
+
type: 'string'
|
|
1379
|
+
}
|
|
1380
|
+
},
|
|
1381
|
+
required: ['uri'],
|
|
1382
|
+
type: 'object'
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
type: 'function'
|
|
1386
|
+
};
|
|
1387
|
+
};
|
|
1344
1388
|
const getClosePreviewTool = () => {
|
|
1345
1389
|
return {
|
|
1346
1390
|
function: {
|
|
@@ -1356,7 +1400,7 @@ const getClosePreviewTool = () => {
|
|
|
1356
1400
|
};
|
|
1357
1401
|
};
|
|
1358
1402
|
const getBasicChatTools = () => {
|
|
1359
|
-
return [getReadFileTool(), getWriteFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getClosePreviewTool()];
|
|
1403
|
+
return [getReadFileTool(), getWriteFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool()];
|
|
1360
1404
|
};
|
|
1361
1405
|
|
|
1362
1406
|
const handleMessagePort = async port => {
|