@lvce-editor/chat-tool-worker 9.1.0 → 9.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 +38 -120
- package/package.json +1 -1
|
@@ -267,45 +267,6 @@ const readyMessage = 'ready';
|
|
|
267
267
|
const getData$2 = event => {
|
|
268
268
|
return event.data;
|
|
269
269
|
};
|
|
270
|
-
const listen$8 = ({
|
|
271
|
-
port
|
|
272
|
-
}) => {
|
|
273
|
-
return port;
|
|
274
|
-
};
|
|
275
|
-
const signal$9 = port => {
|
|
276
|
-
port.postMessage(readyMessage);
|
|
277
|
-
};
|
|
278
|
-
class IpcChildWithMessagePort extends Ipc {
|
|
279
|
-
getData(event) {
|
|
280
|
-
return getData$2(event);
|
|
281
|
-
}
|
|
282
|
-
send(message) {
|
|
283
|
-
this._rawIpc.postMessage(message);
|
|
284
|
-
}
|
|
285
|
-
sendAndTransfer(message) {
|
|
286
|
-
const transfer = getTransferrables(message);
|
|
287
|
-
this._rawIpc.postMessage(message, transfer);
|
|
288
|
-
}
|
|
289
|
-
dispose() {
|
|
290
|
-
// ignore
|
|
291
|
-
}
|
|
292
|
-
onClose(callback) {
|
|
293
|
-
// ignore
|
|
294
|
-
}
|
|
295
|
-
onMessage(callback) {
|
|
296
|
-
this._rawIpc.addEventListener('message', callback);
|
|
297
|
-
this._rawIpc.start();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const wrap$g = port => {
|
|
301
|
-
return new IpcChildWithMessagePort(port);
|
|
302
|
-
};
|
|
303
|
-
const IpcChildWithMessagePort$1 = {
|
|
304
|
-
__proto__: null,
|
|
305
|
-
listen: listen$8,
|
|
306
|
-
signal: signal$9,
|
|
307
|
-
wrap: wrap$g
|
|
308
|
-
};
|
|
309
270
|
const listen$7 = () => {
|
|
310
271
|
// @ts-ignore
|
|
311
272
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
@@ -342,70 +303,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
342
303
|
const wrap$f = global => {
|
|
343
304
|
return new IpcChildWithModuleWorker(global);
|
|
344
305
|
};
|
|
345
|
-
const
|
|
346
|
-
const {
|
|
347
|
-
promise,
|
|
348
|
-
resolve
|
|
349
|
-
} = Promise.withResolvers();
|
|
350
|
-
port.addEventListener('message', resolve, {
|
|
351
|
-
once: true
|
|
352
|
-
});
|
|
353
|
-
const event = await promise;
|
|
354
|
-
// @ts-ignore
|
|
355
|
-
return event.data;
|
|
356
|
-
};
|
|
357
|
-
const listen$6 = async () => {
|
|
358
|
-
const parentIpcRaw = listen$7();
|
|
359
|
-
signal$8(parentIpcRaw);
|
|
360
|
-
const parentIpc = wrap$f(parentIpcRaw);
|
|
361
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
362
|
-
if (firstMessage.method !== 'initialize') {
|
|
363
|
-
throw new IpcError('unexpected first message');
|
|
364
|
-
}
|
|
365
|
-
const type = firstMessage.params[0];
|
|
366
|
-
if (type === 'message-port') {
|
|
367
|
-
parentIpc.send({
|
|
368
|
-
id: firstMessage.id,
|
|
369
|
-
jsonrpc: '2.0',
|
|
370
|
-
result: null
|
|
371
|
-
});
|
|
372
|
-
parentIpc.dispose();
|
|
373
|
-
const port = firstMessage.params[1];
|
|
374
|
-
return port;
|
|
375
|
-
}
|
|
376
|
-
return globalThis;
|
|
377
|
-
};
|
|
378
|
-
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
379
|
-
getData(event) {
|
|
380
|
-
return getData$2(event);
|
|
381
|
-
}
|
|
382
|
-
send(message) {
|
|
383
|
-
this._rawIpc.postMessage(message);
|
|
384
|
-
}
|
|
385
|
-
sendAndTransfer(message) {
|
|
386
|
-
const transfer = getTransferrables(message);
|
|
387
|
-
this._rawIpc.postMessage(message, transfer);
|
|
388
|
-
}
|
|
389
|
-
dispose() {
|
|
390
|
-
if (this._rawIpc.close) {
|
|
391
|
-
this._rawIpc.close();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
onClose(callback) {
|
|
395
|
-
// ignore
|
|
396
|
-
}
|
|
397
|
-
onMessage(callback) {
|
|
398
|
-
this._rawIpc.addEventListener('message', callback);
|
|
399
|
-
this._rawIpc.start();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const wrap$e = port => {
|
|
403
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
404
|
-
};
|
|
405
|
-
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
306
|
+
const IpcChildWithModuleWorker$1 = {
|
|
406
307
|
__proto__: null,
|
|
407
|
-
listen: listen$
|
|
408
|
-
|
|
308
|
+
listen: listen$7,
|
|
309
|
+
signal: signal$8,
|
|
310
|
+
wrap: wrap$f
|
|
409
311
|
};
|
|
410
312
|
const Error$3 = 1;
|
|
411
313
|
const Open = 2;
|
|
@@ -1149,16 +1051,14 @@ const create$3 = async ({
|
|
|
1149
1051
|
|
|
1150
1052
|
const create$2 = async ({
|
|
1151
1053
|
commandMap,
|
|
1152
|
-
|
|
1054
|
+
type
|
|
1153
1055
|
}) => {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1056
|
+
return createSharedLazyRpc(() => {
|
|
1057
|
+
return create$3({
|
|
1058
|
+
commandMap,
|
|
1059
|
+
type
|
|
1060
|
+
});
|
|
1158
1061
|
});
|
|
1159
|
-
handleIpc(ipc);
|
|
1160
|
-
const rpc = createRpc(ipc);
|
|
1161
|
-
return rpc;
|
|
1162
1062
|
};
|
|
1163
1063
|
|
|
1164
1064
|
const create$1 = async ({
|
|
@@ -1166,7 +1066,7 @@ const create$1 = async ({
|
|
|
1166
1066
|
}) => {
|
|
1167
1067
|
// TODO create a commandMap per rpc instance
|
|
1168
1068
|
register(commandMap);
|
|
1169
|
-
const ipc = await listen$1(
|
|
1069
|
+
const ipc = await listen$1(IpcChildWithModuleWorker$1);
|
|
1170
1070
|
handleIpc(ipc);
|
|
1171
1071
|
const rpc = createRpc(ipc);
|
|
1172
1072
|
return rpc;
|
|
@@ -2189,13 +2089,17 @@ const getRunInTerminalOptions = args => {
|
|
|
2189
2089
|
const candidate = options;
|
|
2190
2090
|
const {
|
|
2191
2091
|
command,
|
|
2092
|
+
explanation,
|
|
2093
|
+
goal,
|
|
2192
2094
|
shell
|
|
2193
2095
|
} = candidate;
|
|
2194
|
-
if (typeof command !== 'string' || typeof shell !== 'string') {
|
|
2096
|
+
if (typeof command !== 'string' || typeof explanation !== 'string' || typeof goal !== 'string' || typeof shell !== 'string') {
|
|
2195
2097
|
return undefined;
|
|
2196
2098
|
}
|
|
2197
2099
|
return {
|
|
2198
2100
|
command,
|
|
2101
|
+
explanation,
|
|
2102
|
+
goal,
|
|
2199
2103
|
shell
|
|
2200
2104
|
};
|
|
2201
2105
|
};
|
|
@@ -2203,7 +2107,7 @@ const executeRunInTerminalTool = async (args, _options) => {
|
|
|
2203
2107
|
const runInTerminalOptions = getRunInTerminalOptions(args);
|
|
2204
2108
|
if (!runInTerminalOptions) {
|
|
2205
2109
|
return {
|
|
2206
|
-
error: 'Invalid argument: options must include shell (string) and
|
|
2110
|
+
error: 'Invalid argument: options must include shell (string), command (string), explanation (string), and goal (string).'
|
|
2207
2111
|
};
|
|
2208
2112
|
}
|
|
2209
2113
|
try {
|
|
@@ -2853,13 +2757,23 @@ const getRunInTerminalTool = () => {
|
|
|
2853
2757
|
additionalProperties: false,
|
|
2854
2758
|
properties: {
|
|
2855
2759
|
command: {
|
|
2760
|
+
description: 'The shell command to execute.',
|
|
2761
|
+
type: 'string'
|
|
2762
|
+
},
|
|
2763
|
+
explanation: {
|
|
2764
|
+
description: 'Why this terminal command is being run.',
|
|
2765
|
+
type: 'string'
|
|
2766
|
+
},
|
|
2767
|
+
goal: {
|
|
2768
|
+
description: 'The higher-level objective this terminal command is meant to achieve.',
|
|
2856
2769
|
type: 'string'
|
|
2857
2770
|
},
|
|
2858
2771
|
shell: {
|
|
2772
|
+
description: 'The shell executable that should run the command.',
|
|
2859
2773
|
type: 'string'
|
|
2860
2774
|
}
|
|
2861
2775
|
},
|
|
2862
|
-
required: ['shell', 'command'],
|
|
2776
|
+
required: ['shell', 'command', 'explanation', 'goal'],
|
|
2863
2777
|
type: 'object'
|
|
2864
2778
|
}
|
|
2865
2779
|
},
|
|
@@ -2984,11 +2898,15 @@ const getBasicChatTools = () => {
|
|
|
2984
2898
|
return [getReadFileTool(), getWriteFileTool(), getRenameTool(), getEditFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool(), getRgTool(), getGrepSearchTool(), getRunInTerminalTool(), getSpawnSubagentTool(), getCreateDirectoryTool(), getGlobTool(), getUpdateTodoTool()];
|
|
2985
2899
|
};
|
|
2986
2900
|
|
|
2987
|
-
const handleMessagePort = async port => {
|
|
2988
|
-
await create$
|
|
2901
|
+
const handleMessagePort = async (port, isRendererWorker = false) => {
|
|
2902
|
+
const rpc = await create$7({
|
|
2989
2903
|
commandMap: commandMap,
|
|
2904
|
+
isMessagePortOpen: true,
|
|
2990
2905
|
messagePort: port
|
|
2991
2906
|
});
|
|
2907
|
+
if (isRendererWorker) {
|
|
2908
|
+
set$1(rpc);
|
|
2909
|
+
}
|
|
2992
2910
|
};
|
|
2993
2911
|
|
|
2994
2912
|
const send$2 = async port => {
|
|
@@ -3002,7 +2920,7 @@ const initializeTerminalProcessElectron = async () => {
|
|
|
3002
2920
|
set(rpc);
|
|
3003
2921
|
};
|
|
3004
2922
|
const initializeTerminalProcessRemote = async () => {
|
|
3005
|
-
const rpc = await create$
|
|
2923
|
+
const rpc = await create$2({
|
|
3006
2924
|
commandMap: commandMap,
|
|
3007
2925
|
type: 'terminal-process'
|
|
3008
2926
|
});
|
|
@@ -3026,7 +2944,8 @@ const commandMap = {
|
|
|
3026
2944
|
'ChatTool.execute': executeChatTool,
|
|
3027
2945
|
'ChatTool.getTools': getBasicChatTools,
|
|
3028
2946
|
'ChatTool.initialize': initialize,
|
|
3029
|
-
'HandleMessagePort.handleMessagePort': handleMessagePort
|
|
2947
|
+
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
2948
|
+
initialize: (_, port) => handleMessagePort(port, true)
|
|
3030
2949
|
};
|
|
3031
2950
|
|
|
3032
2951
|
const send$1 = async port => {
|
|
@@ -3052,10 +2971,9 @@ const initializeFileSystemWorker = async () => {
|
|
|
3052
2971
|
};
|
|
3053
2972
|
|
|
3054
2973
|
const initializeRendererWorker = async () => {
|
|
3055
|
-
|
|
2974
|
+
await create$1({
|
|
3056
2975
|
commandMap: commandMap
|
|
3057
2976
|
});
|
|
3058
|
-
set$1(rpc);
|
|
3059
2977
|
};
|
|
3060
2978
|
|
|
3061
2979
|
const listen = async () => {
|