@lvce-editor/chat-tool-worker 8.0.0 → 8.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.
@@ -1127,6 +1127,10 @@ const create = rpcId => {
1127
1127
  };
1128
1128
  };
1129
1129
 
1130
+ const Directory = 3;
1131
+ const File = 7;
1132
+ const Symlink = 9;
1133
+
1130
1134
  const ChatStorageWorker = 6003;
1131
1135
  const FileSystemWorker = 209;
1132
1136
  const RendererWorker = 1;
@@ -1136,8 +1140,12 @@ const {
1136
1140
  } = create(ChatStorageWorker);
1137
1141
 
1138
1142
  const {
1143
+ invoke: invoke$1,
1139
1144
  set: set$1
1140
1145
  } = create(FileSystemWorker);
1146
+ const readDirWithFileTypes = async uri => {
1147
+ return invoke$1('FileSystem.readDirWithFileTypes', uri);
1148
+ };
1141
1149
 
1142
1150
  const {
1143
1151
  invoke,
@@ -1416,15 +1424,18 @@ const traverseDirectory = async (baseUri, currentPath, onEntry, visited = new Se
1416
1424
  }
1417
1425
  visited.add(uri);
1418
1426
  try {
1419
- const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
1427
+ const entries = await readDirWithFileTypes(uri);
1420
1428
  for (const entry of entries) {
1421
1429
  const entryPath = currentPath === '' ? entry.name : `${currentPath}/${entry.name}`;
1422
1430
  await onEntry(entryPath, entry);
1423
- if (entry.isDirectory() && !entry.isSymbolicLink() && !shouldExcludeDir(entry.name)) {
1431
+ if (entry.type === Directory && !shouldExcludeDir(entry.name)) {
1424
1432
  await traverseDirectory(baseUri, entryPath, onEntry, visited);
1425
1433
  }
1426
1434
  }
1427
- } catch {
1435
+ } catch (error) {
1436
+ if (currentPath === '') {
1437
+ throw error;
1438
+ }
1428
1439
  // Ignore unreadable directories and continue with other matches.
1429
1440
  }
1430
1441
  };
@@ -1495,7 +1506,7 @@ const executeGlobTool = async (args, _options) => {
1495
1506
  try {
1496
1507
  if (matchDirectories) {
1497
1508
  const dirUri = joinUri(baseUri, globPart);
1498
- const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1509
+ const entries = await readDirWithFileTypes(dirUri);
1499
1510
  for (const entry of entries) {
1500
1511
  matches.push(globPart ? `${globPart}/${entry.name}` : entry.name);
1501
1512
  }
@@ -1503,7 +1514,7 @@ const executeGlobTool = async (args, _options) => {
1503
1514
  const baseDirUri = joinUri(baseUri, baseDir);
1504
1515
  const visited = new Set();
1505
1516
  await traverseDirectory(baseDirUri, '', async (relativePath, entry) => {
1506
- if (!entry.isFile()) {
1517
+ if (entry.type !== File) {
1507
1518
  return;
1508
1519
  }
1509
1520
  const fullPath = baseDir ? `${baseDir}/${relativePath}` : relativePath;
@@ -1513,7 +1524,7 @@ const executeGlobTool = async (args, _options) => {
1513
1524
  }, visited);
1514
1525
  } else {
1515
1526
  const dirUri = joinUri(baseUri, baseDir);
1516
- const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1527
+ const entries = await readDirWithFileTypes(dirUri);
1517
1528
  for (const entry of entries) {
1518
1529
  const fullPath = baseDir ? `${baseDir}/${entry.name}` : entry.name;
1519
1530
  if (matchesGlobPattern(fullPath, normalizedPattern)) {
@@ -1745,6 +1756,22 @@ const executeGrepSearchTool = async (args, options) => {
1745
1756
  }
1746
1757
  };
1747
1758
 
1759
+ const getEntryType = type => {
1760
+ switch (type) {
1761
+ case Directory:
1762
+ return 'folder';
1763
+ case File:
1764
+ return 'file';
1765
+ case Symlink:
1766
+ return 'symlink';
1767
+ default:
1768
+ return 'unknown';
1769
+ }
1770
+ };
1771
+ const mapEntry = entry => ({
1772
+ name: entry.name,
1773
+ type: getEntryType(entry.type)
1774
+ });
1748
1775
  const executeListFilesTool = async (args, _options) => {
1749
1776
  const uri = typeof args.uri === 'string' ? args.uri : '';
1750
1777
  if (!uri || !isAbsoluteUri(uri)) {
@@ -1761,7 +1788,7 @@ const executeListFilesTool = async (args, _options) => {
1761
1788
  try {
1762
1789
  const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
1763
1790
  return {
1764
- entries,
1791
+ entries: entries.map(mapEntry),
1765
1792
  uri
1766
1793
  };
1767
1794
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-tool-worker",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "Chat Tool Worker",
5
5
  "repository": {
6
6
  "type": "git",