@lvce-editor/chat-tool-worker 9.3.0 → 9.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.
@@ -1189,8 +1189,8 @@ const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1189
1189
  const readFile = async uri => {
1190
1190
  return invoke$1('FileSystem.readFile', uri);
1191
1191
  };
1192
- const sendMessagePortToChatStorageWorker = async port => {
1193
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatStorageWorker', port, 'HandleMessagePort.handleMessagePort');
1192
+ const sendMessagePortToChatStorageWorker = async (port, rpcId) => {
1193
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatStorageWorker', port, 'HandleMessagePort.handleMessagePort', rpcId);
1194
1194
  };
1195
1195
  const writeFile = async (uri, text) => {
1196
1196
  await invoke$1('FileSystem.writeFile', uri, text);
@@ -1248,14 +1248,16 @@ const isAbsoluteUri = value => {
1248
1248
  return ABSOLUTE_URI_REGEX.test(value);
1249
1249
  };
1250
1250
 
1251
+ const isValidUri = value => {
1252
+ return URL.canParse(value);
1253
+ };
1254
+
1251
1255
  const executeCreateDirectoryTool = async (args, _options) => {
1252
1256
  const uri = typeof args.uri === 'string' ? args.uri : '';
1253
1257
  if (!uri || !isAbsoluteUri(uri)) {
1254
1258
  return getInvalidUriErrorPayload('uri');
1255
1259
  }
1256
- try {
1257
- new URL(uri);
1258
- } catch {
1260
+ if (!isValidUri(uri)) {
1259
1261
  return getInvalidUrlErrorPayload();
1260
1262
  }
1261
1263
  try {
@@ -1287,9 +1289,7 @@ const executeEditFileTool = async (args, _options) => {
1287
1289
  if (!uri || !isAbsoluteUri(uri)) {
1288
1290
  return getInvalidUriErrorPayload('uri');
1289
1291
  }
1290
- try {
1291
- new URL(uri);
1292
- } catch {
1292
+ if (!isValidUri(uri)) {
1293
1293
  return getInvalidUrlErrorPayload();
1294
1294
  }
1295
1295
  if (!Number.isInteger(start) || start < 0) {
@@ -1312,8 +1312,7 @@ const executeEditFileTool = async (args, _options) => {
1312
1312
  const nextContent = applyTextEdit(content, start, end, text);
1313
1313
  await writeFile(uri, nextContent);
1314
1314
  return {
1315
- ok: true,
1316
- uri
1315
+ ok: true
1317
1316
  };
1318
1317
  } catch (error) {
1319
1318
  return {
@@ -1337,6 +1336,7 @@ const normalizeWorkspaceUri = workspacePathOrUri => {
1337
1336
  url.pathname = windowsDrivePathRegex.test(workspacePathOrUri) ? `/${workspacePathOrUri.replaceAll('\\', '/')}` : workspacePathOrUri;
1338
1337
  return url.href;
1339
1338
  };
1339
+
1340
1340
  const executeGetWorkspaceUriTool = async (_args, _options) => {
1341
1341
  try {
1342
1342
  const workspacePathOrUri = await getWorkspacePath();
@@ -2000,7 +2000,7 @@ const executeRenameTool = async (args, _options) => {
2000
2000
  if (!newUri || !isAbsoluteUri(newUri)) {
2001
2001
  return getInvalidUriErrorPayload('newUri');
2002
2002
  }
2003
- if (!URL.canParse(oldUri) || !URL.canParse(newUri)) {
2003
+ if (!isValidUri(oldUri) || !isValidUri(newUri)) {
2004
2004
  return getInvalidUrlErrorPayload();
2005
2005
  }
2006
2006
  const oldUrl = new URL(oldUri);
@@ -2340,9 +2340,7 @@ const executeWriteFileTool = async (args, _options) => {
2340
2340
  if (!uri || !isAbsoluteUri(uri)) {
2341
2341
  return getInvalidUriErrorPayload('uri');
2342
2342
  }
2343
- try {
2344
- new URL(uri);
2345
- } catch {
2343
+ if (!isValidUri(uri)) {
2346
2344
  return getInvalidUrlErrorPayload();
2347
2345
  }
2348
2346
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-tool-worker",
3
- "version": "9.3.0",
3
+ "version": "9.5.0",
4
4
  "description": "Chat Tool Worker",
5
5
  "repository": {
6
6
  "type": "git",