@lvce-editor/chat-tool-worker 7.11.0 → 7.13.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.
@@ -407,6 +407,100 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
407
407
  listen: listen$6,
408
408
  wrap: wrap$e
409
409
  };
410
+ const addListener = (emitter, type, callback) => {
411
+ if ('addEventListener' in emitter) {
412
+ emitter.addEventListener(type, callback);
413
+ } else {
414
+ emitter.on(type, callback);
415
+ }
416
+ };
417
+ const removeListener = (emitter, type, callback) => {
418
+ if ('removeEventListener' in emitter) {
419
+ emitter.removeEventListener(type, callback);
420
+ } else {
421
+ emitter.off(type, callback);
422
+ }
423
+ };
424
+ const getFirstEvent = (eventEmitter, eventMap) => {
425
+ const {
426
+ promise,
427
+ resolve
428
+ } = Promise.withResolvers();
429
+ const listenerMap = Object.create(null);
430
+ const cleanup = value => {
431
+ for (const event of Object.keys(eventMap)) {
432
+ removeListener(eventEmitter, event, listenerMap[event]);
433
+ }
434
+ resolve(value);
435
+ };
436
+ for (const [event, type] of Object.entries(eventMap)) {
437
+ const listener = event => {
438
+ cleanup({
439
+ event,
440
+ type
441
+ });
442
+ };
443
+ addListener(eventEmitter, event, listener);
444
+ listenerMap[event] = listener;
445
+ }
446
+ return promise;
447
+ };
448
+ const Message$1 = 3;
449
+ const create$5$1 = async ({
450
+ isMessagePortOpen,
451
+ messagePort
452
+ }) => {
453
+ if (!isMessagePort(messagePort)) {
454
+ throw new IpcError('port must be of type MessagePort');
455
+ }
456
+ if (isMessagePortOpen) {
457
+ return messagePort;
458
+ }
459
+ const eventPromise = getFirstEvent(messagePort, {
460
+ message: Message$1
461
+ });
462
+ messagePort.start();
463
+ const {
464
+ event,
465
+ type
466
+ } = await eventPromise;
467
+ if (type !== Message$1) {
468
+ throw new IpcError('Failed to wait for ipc message');
469
+ }
470
+ if (event.data !== readyMessage) {
471
+ throw new IpcError('unexpected first message');
472
+ }
473
+ return messagePort;
474
+ };
475
+ const signal$1 = messagePort => {
476
+ messagePort.start();
477
+ };
478
+ class IpcParentWithMessagePort extends Ipc {
479
+ getData = getData$2;
480
+ send(message) {
481
+ this._rawIpc.postMessage(message);
482
+ }
483
+ sendAndTransfer(message) {
484
+ const transfer = getTransferrables(message);
485
+ this._rawIpc.postMessage(message, transfer);
486
+ }
487
+ dispose() {
488
+ this._rawIpc.close();
489
+ }
490
+ onMessage(callback) {
491
+ this._rawIpc.addEventListener('message', callback);
492
+ }
493
+ onClose(callback) {}
494
+ }
495
+ const wrap$5 = messagePort => {
496
+ return new IpcParentWithMessagePort(messagePort);
497
+ };
498
+ const IpcParentWithMessagePort$1 = {
499
+ __proto__: null,
500
+ create: create$5$1,
501
+ signal: signal$1,
502
+ wrap: wrap$5
503
+ };
410
504
 
411
505
  class CommandNotFoundError extends Error {
412
506
  constructor(command) {
@@ -643,7 +737,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
643
737
  const errorProperty = getErrorProperty(error, prettyError);
644
738
  return create$1$1(id, errorProperty);
645
739
  };
646
- const create$6 = (message, result) => {
740
+ const create$9 = (message, result) => {
647
741
  return {
648
742
  id: message.id,
649
743
  jsonrpc: Two$1,
@@ -652,7 +746,7 @@ const create$6 = (message, result) => {
652
746
  };
653
747
  const getSuccessResponse = (message, result) => {
654
748
  const resultProperty = result ?? null;
655
- return create$6(message, resultProperty);
749
+ return create$9(message, resultProperty);
656
750
  };
657
751
  const getErrorResponseSimple = (id, error) => {
658
752
  return {
@@ -746,7 +840,7 @@ const handleJsonRpcMessage = async (...args) => {
746
840
 
747
841
  const Two = '2.0';
748
842
 
749
- const create$5 = (method, params) => {
843
+ const create$8 = (method, params) => {
750
844
  return {
751
845
  jsonrpc: Two,
752
846
  method,
@@ -754,7 +848,7 @@ const create$5 = (method, params) => {
754
848
  };
755
849
  };
756
850
 
757
- const create$4 = (id, method, params) => {
851
+ const create$7 = (id, method, params) => {
758
852
  const message = {
759
853
  id,
760
854
  jsonrpc: Two,
@@ -765,12 +859,12 @@ const create$4 = (id, method, params) => {
765
859
  };
766
860
 
767
861
  let id = 0;
768
- const create$3 = () => {
862
+ const create$6 = () => {
769
863
  return ++id;
770
864
  };
771
865
 
772
866
  const registerPromise = map => {
773
- const id = create$3();
867
+ const id = create$6();
774
868
  const {
775
869
  promise,
776
870
  resolve
@@ -787,7 +881,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
787
881
  id,
788
882
  promise
789
883
  } = registerPromise(callbacks);
790
- const message = create$4(id, method, params);
884
+ const message = create$7(id, method, params);
791
885
  if (useSendAndTransfer && ipc.sendAndTransfer) {
792
886
  ipc.sendAndTransfer(message);
793
887
  } else {
@@ -823,7 +917,7 @@ const createRpc = ipc => {
823
917
  * @deprecated
824
918
  */
825
919
  send(method, ...params) {
826
- const message = create$5(method, params);
920
+ const message = create$8(method, params);
827
921
  ipc.send(message);
828
922
  }
829
923
  };
@@ -863,6 +957,83 @@ const listen$1 = async (module, options) => {
863
957
  return ipc;
864
958
  };
865
959
 
960
+ const create$5 = async ({
961
+ commandMap,
962
+ isMessagePortOpen = true,
963
+ messagePort
964
+ }) => {
965
+ // TODO create a commandMap per rpc instance
966
+ register(commandMap);
967
+ const rawIpc = await IpcParentWithMessagePort$1.create({
968
+ isMessagePortOpen,
969
+ messagePort
970
+ });
971
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
972
+ handleIpc(ipc);
973
+ const rpc = createRpc(ipc);
974
+ messagePort.start();
975
+ return rpc;
976
+ };
977
+
978
+ const create$4 = async ({
979
+ commandMap,
980
+ isMessagePortOpen,
981
+ send
982
+ }) => {
983
+ const {
984
+ port1,
985
+ port2
986
+ } = new MessageChannel();
987
+ await send(port1);
988
+ return create$5({
989
+ commandMap,
990
+ isMessagePortOpen,
991
+ messagePort: port2
992
+ });
993
+ };
994
+
995
+ const createSharedLazyRpc = factory => {
996
+ let rpcPromise;
997
+ const getOrCreate = () => {
998
+ if (!rpcPromise) {
999
+ rpcPromise = factory();
1000
+ }
1001
+ return rpcPromise;
1002
+ };
1003
+ return {
1004
+ async dispose() {
1005
+ const rpc = await getOrCreate();
1006
+ await rpc.dispose();
1007
+ },
1008
+ async invoke(method, ...params) {
1009
+ const rpc = await getOrCreate();
1010
+ return rpc.invoke(method, ...params);
1011
+ },
1012
+ async invokeAndTransfer(method, ...params) {
1013
+ const rpc = await getOrCreate();
1014
+ return rpc.invokeAndTransfer(method, ...params);
1015
+ },
1016
+ async send(method, ...params) {
1017
+ const rpc = await getOrCreate();
1018
+ rpc.send(method, ...params);
1019
+ }
1020
+ };
1021
+ };
1022
+
1023
+ const create$3 = async ({
1024
+ commandMap,
1025
+ isMessagePortOpen,
1026
+ send
1027
+ }) => {
1028
+ return createSharedLazyRpc(() => {
1029
+ return create$4({
1030
+ commandMap,
1031
+ isMessagePortOpen,
1032
+ send
1033
+ });
1034
+ });
1035
+ };
1036
+
866
1037
  const create$2 = async ({
867
1038
  commandMap,
868
1039
  messagePort
@@ -909,7 +1080,7 @@ const createMockRpc = ({
909
1080
  };
910
1081
 
911
1082
  const rpcs = Object.create(null);
912
- const set$1 = (id, rpc) => {
1083
+ const set$3 = (id, rpc) => {
913
1084
  rpcs[id] = rpc;
914
1085
  };
915
1086
  const get = id => {
@@ -942,7 +1113,7 @@ const create = rpcId => {
942
1113
  const mockRpc = createMockRpc({
943
1114
  commandMap
944
1115
  });
945
- set$1(rpcId, mockRpc);
1116
+ set$3(rpcId, mockRpc);
946
1117
  // @ts-ignore
947
1118
  mockRpc[Symbol.dispose] = () => {
948
1119
  remove(rpcId);
@@ -951,20 +1122,38 @@ const create = rpcId => {
951
1122
  return mockRpc;
952
1123
  },
953
1124
  set(rpc) {
954
- set$1(rpcId, rpc);
1125
+ set$3(rpcId, rpc);
955
1126
  }
956
1127
  };
957
1128
  };
958
1129
 
1130
+ const ChatStorageWorker = 6003;
1131
+ const FileSystemWorker = 209;
959
1132
  const RendererWorker = 1;
960
1133
 
1134
+ const {
1135
+ set: set$2
1136
+ } = create(ChatStorageWorker);
1137
+
1138
+ const {
1139
+ set: set$1
1140
+ } = create(FileSystemWorker);
1141
+
961
1142
  const {
962
1143
  invoke,
1144
+ invokeAndTransfer,
963
1145
  set
964
1146
  } = create(RendererWorker);
1147
+ const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1148
+ const command = 'FileSystem.handleMessagePort';
1149
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1150
+ };
965
1151
  const readFile = async uri => {
966
1152
  return invoke('FileSystem.readFile', uri);
967
1153
  };
1154
+ const sendMessagePortToChatStorageWorker = async port => {
1155
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatStorageWorker', port, 'HandleMessagePort.handleMessagePort');
1156
+ };
968
1157
  const writeFile = async (uri, text) => {
969
1158
  await invoke('FileSystem.writeFile', uri, text);
970
1159
  };
@@ -1093,6 +1282,183 @@ const executeGetWorkspaceUriTool = async (_args, _options) => {
1093
1282
  }
1094
1283
  };
1095
1284
 
1285
+ /**
1286
+ * Matches a string against a glob pattern
1287
+ * Supported patterns:
1288
+ * - * matches any characters except /
1289
+ * - ? matches a single character except /
1290
+ * - ** matches any characters including /
1291
+ * - [abc] matches a, b, or c
1292
+ * - [!abc] matches any character except a, b, c
1293
+ * - [a-z] matches any character between a and z
1294
+ */
1295
+
1296
+ const REGEX_SPECIAL_CHARS_REGEX = /[.*+?^${}()|[\]\\]/g;
1297
+ const LEADING_DOT_SLASH_REGEX$1 = /^\.\//g;
1298
+ const MULTIPLE_SLASHES_REGEX$1 = /\/+/g;
1299
+ const escapeRegExp = str => {
1300
+ return str.replaceAll(REGEX_SPECIAL_CHARS_REGEX, '\\$&');
1301
+ };
1302
+
1303
+ /*
1304
+ * Convert a glob pattern to a regex, but only for segments between separators
1305
+ */
1306
+ const segmentToRegex = segment => {
1307
+ let regexStr = '';
1308
+ let i = 0;
1309
+ while (i < segment.length) {
1310
+ const char = segment[i];
1311
+ switch (char) {
1312
+ case '?':
1313
+ {
1314
+ regexStr += '[^/]';
1315
+ i++;
1316
+ break;
1317
+ }
1318
+ case '[':
1319
+ {
1320
+ let j = i + 1;
1321
+ let negated = false;
1322
+ if (j < segment.length && segment[j] === '!') {
1323
+ negated = true;
1324
+ j++;
1325
+ }
1326
+ let classStr = '';
1327
+ while (j < segment.length && segment[j] !== ']') {
1328
+ classStr += segment[j];
1329
+ j++;
1330
+ }
1331
+ if (j < segment.length) {
1332
+ if (negated) {
1333
+ regexStr += `[^${escapeRegExp(classStr)}]`;
1334
+ } else {
1335
+ regexStr += `[${classStr.replaceAll('\\', '\\\\')}]`;
1336
+ }
1337
+ i = j + 1;
1338
+ } else {
1339
+ regexStr += escapeRegExp(char);
1340
+ i++;
1341
+ }
1342
+ break;
1343
+ }
1344
+ case '*':
1345
+ {
1346
+ regexStr += '[^/]*';
1347
+ i++;
1348
+ break;
1349
+ }
1350
+ default:
1351
+ {
1352
+ regexStr += escapeRegExp(char);
1353
+ i++;
1354
+ }
1355
+ }
1356
+ }
1357
+ return new RegExp(`^${regexStr}$`);
1358
+ };
1359
+ const matchesGlobPattern = (path, pattern) => {
1360
+ const normalizedPath = path.replaceAll('\\', '/').replaceAll(LEADING_DOT_SLASH_REGEX$1, '');
1361
+ let normalizedPattern = pattern.replaceAll('\\', '/').replaceAll(LEADING_DOT_SLASH_REGEX$1, '').replaceAll(MULTIPLE_SLASHES_REGEX$1, '/');
1362
+ if (normalizedPattern.endsWith('/')) {
1363
+ normalizedPattern = normalizedPattern.slice(0, -1) + '/*';
1364
+ }
1365
+ const patternParts = normalizedPattern.split('/');
1366
+ const pathParts = normalizedPath.split('/');
1367
+ return matchesPatternParts(pathParts, patternParts, 0, 0);
1368
+ };
1369
+ const matchesPatternParts = (pathParts, patternParts, pathIdx, patternIdx) => {
1370
+ if (patternIdx === patternParts.length) {
1371
+ return pathIdx === pathParts.length;
1372
+ }
1373
+ if (pathIdx > pathParts.length) {
1374
+ return false;
1375
+ }
1376
+ const patternPart = patternParts[patternIdx];
1377
+ if (patternPart === undefined) {
1378
+ return false;
1379
+ }
1380
+ if (patternPart === '**') {
1381
+ for (let i = pathIdx; i <= pathParts.length; i++) {
1382
+ if (matchesPatternParts(pathParts, patternParts, i, patternIdx + 1)) {
1383
+ return true;
1384
+ }
1385
+ }
1386
+ return false;
1387
+ }
1388
+ if (pathIdx === pathParts.length) {
1389
+ return false;
1390
+ }
1391
+ if (patternPart.includes('**')) {
1392
+ const regex = segmentToRegex(patternPart.replace('**', ''));
1393
+ const pathPart = pathParts[pathIdx];
1394
+ if (pathPart !== undefined && regex.test(pathPart)) {
1395
+ return matchesPatternParts(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
1396
+ }
1397
+ return false;
1398
+ }
1399
+ const regex = segmentToRegex(patternPart);
1400
+ const pathPart = pathParts[pathIdx];
1401
+ if (pathPart !== undefined && regex.test(pathPart)) {
1402
+ return matchesPatternParts(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
1403
+ }
1404
+ return false;
1405
+ };
1406
+
1407
+ // cspell:ignore venv
1408
+ const DEFAULT_EXCLUDE_DIRS = new Set(['.git', 'node_modules', '.cache', '.venv', 'dist', 'build', '.next', '.nuxt']);
1409
+ const shouldExcludeDir = dirName => {
1410
+ return DEFAULT_EXCLUDE_DIRS.has(dirName);
1411
+ };
1412
+ const traverseDirectory = async (baseUri, currentPath, onEntry, visited = new Set()) => {
1413
+ const uri = currentPath === '' ? baseUri : `${baseUri}/${currentPath}`;
1414
+ if (visited.has(uri)) {
1415
+ return;
1416
+ }
1417
+ visited.add(uri);
1418
+ try {
1419
+ const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
1420
+ for (const entry of entries) {
1421
+ const entryPath = currentPath === '' ? entry.name : `${currentPath}/${entry.name}`;
1422
+ await onEntry(entryPath, entry);
1423
+ if (entry.isDirectory() && !entry.isSymbolicLink() && !shouldExcludeDir(entry.name)) {
1424
+ await traverseDirectory(baseUri, entryPath, onEntry, visited);
1425
+ }
1426
+ }
1427
+ } catch {
1428
+ // Ignore unreadable directories and continue with other matches.
1429
+ }
1430
+ };
1431
+
1432
+ const MULTIPLE_SLASHES_REGEX = /\/+/g;
1433
+ const LEADING_DOT_SLASH_REGEX = /^\.\//g;
1434
+ const hasGlobCharacters = part => {
1435
+ return part.includes('*') || part.includes('?') || part.includes('[');
1436
+ };
1437
+ const normalizeInputPattern = pattern => {
1438
+ return pattern.trim().replaceAll('\\', '/').replaceAll(LEADING_DOT_SLASH_REGEX, '').replaceAll(MULTIPLE_SLASHES_REGEX, '/');
1439
+ };
1440
+ const normalizePattern = pattern => {
1441
+ const normalized = normalizeInputPattern(pattern);
1442
+ const matchDirectories = normalized.endsWith('/');
1443
+ const patternToParse = matchDirectories ? normalized.slice(0, -1) : normalized;
1444
+ const parts = patternToParse.split('/');
1445
+ let firstGlobIndex = -1;
1446
+ for (let i = 0; i < parts.length; i++) {
1447
+ const part = parts[i];
1448
+ if (part && hasGlobCharacters(part)) {
1449
+ firstGlobIndex = i;
1450
+ break;
1451
+ }
1452
+ }
1453
+ const globPartIndex = firstGlobIndex === -1 ? Math.max(parts.length - 1, 0) : firstGlobIndex;
1454
+ const baseDir = parts.slice(0, globPartIndex).join('/');
1455
+ const globPart = parts.slice(globPartIndex).join('/');
1456
+ return {
1457
+ baseDir,
1458
+ globPart,
1459
+ matchDirectories
1460
+ };
1461
+ };
1096
1462
  const executeGlobTool = async (args, _options) => {
1097
1463
  const pattern = typeof args.pattern === 'string' ? args.pattern : '';
1098
1464
  if (!pattern) {
@@ -1100,11 +1466,206 @@ const executeGlobTool = async (args, _options) => {
1100
1466
  error: 'Invalid argument: pattern must be a non-empty string.'
1101
1467
  };
1102
1468
  }
1103
- const paths = ['./src/main.ts', './src/utils/search.ts', './test/Main.test.ts'];
1469
+ const normalizedPattern = normalizeInputPattern(pattern);
1470
+ const {
1471
+ baseDir,
1472
+ globPart,
1473
+ matchDirectories
1474
+ } = normalizePattern(pattern);
1475
+ const baseUri = 'file:///workspace';
1476
+ const matches = [];
1477
+ try {
1478
+ if (matchDirectories) {
1479
+ const dirUri = globPart ? `${baseUri}/${globPart}` : baseUri;
1480
+ const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1481
+ for (const entry of entries) {
1482
+ matches.push(globPart ? `${globPart}/${entry.name}` : entry.name);
1483
+ }
1484
+ } else if (globPart.includes('**')) {
1485
+ const baseDirUri = baseDir ? `${baseUri}/${baseDir}` : baseUri;
1486
+ const visited = new Set();
1487
+ await traverseDirectory(baseDirUri, '', async (relativePath, entry) => {
1488
+ if (!entry.isFile()) {
1489
+ return;
1490
+ }
1491
+ const fullPath = baseDir ? `${baseDir}/${relativePath}` : relativePath;
1492
+ if (matchesGlobPattern(fullPath, normalizedPattern)) {
1493
+ matches.push(fullPath);
1494
+ }
1495
+ }, visited);
1496
+ } else {
1497
+ const dirUri = baseDir ? `${baseUri}/${baseDir}` : baseUri;
1498
+ const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1499
+ for (const entry of entries) {
1500
+ const fullPath = baseDir ? `${baseDir}/${entry.name}` : entry.name;
1501
+ if (matchesGlobPattern(fullPath, normalizedPattern)) {
1502
+ matches.push(fullPath);
1503
+ }
1504
+ }
1505
+ }
1506
+ matches.sort();
1507
+ return {
1508
+ paths: matches,
1509
+ pattern
1510
+ };
1511
+ } catch (error) {
1512
+ return {
1513
+ error: `Failed to glob: ${error instanceof Error ? error.message : String(error)}`,
1514
+ pattern
1515
+ };
1516
+ }
1517
+ };
1518
+
1519
+ const formatSearchProcessResults = results => {
1520
+ if (!results || results.length === 0) {
1521
+ return 'No matches found.';
1522
+ }
1523
+ let currentFile = '';
1524
+ const lines = [];
1525
+ for (const result of results) {
1526
+ if (result.type === 1) {
1527
+ currentFile = result.text;
1528
+ continue;
1529
+ }
1530
+ if (result.type === 2) {
1531
+ if (currentFile) {
1532
+ lines.push(`${currentFile}:${result.lineNumber}:${result.text}`);
1533
+ } else {
1534
+ lines.push(`${result.lineNumber}:${result.text}`);
1535
+ }
1536
+ }
1537
+ }
1538
+ if (lines.length === 0) {
1539
+ return 'No matches found.';
1540
+ }
1541
+ return lines.join('\n');
1542
+ };
1543
+
1544
+ const windowsDrivePathRegex = /^[a-zA-Z]:[\\/]/;
1545
+ const isAbsoluteFileSystemPath = value => {
1546
+ return value.startsWith('/') || windowsDrivePathRegex.test(value);
1547
+ };
1548
+
1549
+ const isFileUri = value => {
1550
+ return value.startsWith('file://');
1551
+ };
1552
+
1553
+ const getRipGrepArgs = ({
1554
+ includeIgnoredFiles,
1555
+ includePattern,
1556
+ isRegexp,
1557
+ query
1558
+ }) => {
1559
+ const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', '1', '--ignore-case'];
1560
+ if (includeIgnoredFiles) {
1561
+ ripGrepArgs.push('--no-ignore');
1562
+ }
1563
+ if (includePattern && !isFileUri(includePattern) && !isAbsoluteFileSystemPath(includePattern)) {
1564
+ ripGrepArgs.push('--glob', includePattern);
1565
+ }
1566
+ if (isRegexp) {
1567
+ ripGrepArgs.push('--regexp', query);
1568
+ } else {
1569
+ ripGrepArgs.push('--fixed-strings', '--', query);
1570
+ }
1571
+ ripGrepArgs.push('.');
1572
+ return ripGrepArgs;
1573
+ };
1574
+
1575
+ const windowsPathWithLeadingSlashRegex = /^\/[a-zA-Z]:/;
1576
+ const getFilePathFromUri = uri => {
1577
+ const url = new URL(uri);
1578
+ const decodedPath = decodeURIComponent(url.pathname);
1579
+ if (windowsPathWithLeadingSlashRegex.test(decodedPath)) {
1580
+ return decodedPath.slice(1);
1581
+ }
1582
+ return decodedPath;
1583
+ };
1584
+
1585
+ const getScheme = uriOrPath => {
1586
+ if (!uriOrPath.includes('://')) {
1587
+ return '';
1588
+ }
1589
+ return new URL(uriOrPath).protocol.slice(0, -1);
1590
+ };
1591
+
1592
+ const getSearchDir = (workspaceUri, includePattern) => {
1593
+ if (!includePattern) {
1594
+ return getScheme(workspaceUri) === 'file' ? getFilePathFromUri(workspaceUri) : workspaceUri;
1595
+ }
1596
+ if (isFileUri(includePattern)) {
1597
+ return getFilePathFromUri(includePattern);
1598
+ }
1599
+ if (isAbsoluteFileSystemPath(includePattern)) {
1600
+ return includePattern;
1601
+ }
1602
+ return getScheme(workspaceUri) === 'file' ? getFilePathFromUri(workspaceUri) : workspaceUri;
1603
+ };
1604
+
1605
+ const executeFileGrepSearch = async (workspaceUri, grepSearchArgs) => {
1606
+ const result = await invoke('SearchProcess.invoke', 'TextSearch.search', {
1607
+ maxSearchResults: grepSearchArgs.maxResults,
1608
+ ripGrepArgs: getRipGrepArgs(grepSearchArgs),
1609
+ searchDir: getSearchDir(workspaceUri, grepSearchArgs.includePattern)
1610
+ });
1104
1611
  return {
1105
- paths,
1106
- pattern
1612
+ arguments: grepSearchArgs,
1613
+ result: formatSearchProcessResults(result.results),
1614
+ workspaceUri,
1615
+ ...(result.limitHit ? {
1616
+ warning: 'Search result limit reached.'
1617
+ } : {})
1618
+ };
1619
+ };
1620
+
1621
+ const formatLegacyMemorySearchResults = results => {
1622
+ const lines = [];
1623
+ for (const result of results) {
1624
+ const [path, matches] = result;
1625
+ for (const match of matches) {
1626
+ const preview = typeof match?.preview === 'string' ? match.preview : '';
1627
+ lines.push(preview ? `${path}: ${preview}` : path);
1628
+ }
1629
+ }
1630
+ if (lines.length === 0) {
1631
+ return 'No matches found.';
1632
+ }
1633
+ return lines.join('\n');
1634
+ };
1635
+
1636
+ const isLegacyMemorySearchResult = value => {
1637
+ return Array.isArray(value);
1638
+ };
1639
+
1640
+ const executeMemoryGrepSearch = async (workspaceUri, grepSearchArgs, options) => {
1641
+ const searchOptions = {
1642
+ exclude: '',
1643
+ include: grepSearchArgs.includePattern || '',
1644
+ isCaseSensitive: false,
1645
+ query: grepSearchArgs.query,
1646
+ root: workspaceUri,
1647
+ scheme: getScheme(workspaceUri),
1648
+ threads: 1,
1649
+ useRegularExpression: grepSearchArgs.isRegexp
1107
1650
  };
1651
+ try {
1652
+ const result = await invoke('ExtensionHostTextSearch.textSearchMemory2', searchOptions.scheme, workspaceUri, grepSearchArgs.query, searchOptions, options.assetDir);
1653
+ return {
1654
+ arguments: grepSearchArgs,
1655
+ result: formatLegacyMemorySearchResults(result.results || []),
1656
+ workspaceUri,
1657
+ ...(result.limitHit ? {
1658
+ warning: 'Search result limit reached.'
1659
+ } : {})
1660
+ };
1661
+ } catch {
1662
+ const legacyResults = await invoke('ExtensionHostTextSearch.textSearchMemory', searchOptions.scheme, workspaceUri, grepSearchArgs.query, searchOptions, options.assetDir);
1663
+ return {
1664
+ arguments: grepSearchArgs,
1665
+ result: isLegacyMemorySearchResult(legacyResults) ? formatLegacyMemorySearchResults(legacyResults) : 'No matches found.',
1666
+ workspaceUri
1667
+ };
1668
+ }
1108
1669
  };
1109
1670
 
1110
1671
  const getGrepSearchArgs = args => {
@@ -1141,17 +1702,29 @@ const getGrepSearchArgs = args => {
1141
1702
  query
1142
1703
  };
1143
1704
  };
1144
- const executeGrepSearchTool = async (args, _options) => {
1705
+
1706
+ const grepSearchArgumentError = 'Invalid argument: grep_search requires query (string), isRegexp (boolean), optional includePattern (string), optional maxResults (number), and optional includeIgnoredFiles (boolean).';
1707
+
1708
+ const executeGrepSearchTool = async (args, options) => {
1145
1709
  const grepSearchArgs = getGrepSearchArgs(args);
1146
1710
  if (!grepSearchArgs) {
1147
1711
  return {
1148
- error: 'Invalid argument: grep_search requires query (string), isRegexp (boolean), optional includePattern (string), optional maxResults (number), and optional includeIgnoredFiles (boolean).'
1712
+ error: grepSearchArgumentError
1713
+ };
1714
+ }
1715
+ try {
1716
+ const workspaceUri = await getWorkspacePath();
1717
+ const scheme = getScheme(workspaceUri);
1718
+ if (scheme === '' || scheme === 'file') {
1719
+ return executeFileGrepSearch(workspaceUri, grepSearchArgs);
1720
+ }
1721
+ return executeMemoryGrepSearch(workspaceUri, grepSearchArgs, options);
1722
+ } catch (error) {
1723
+ return {
1724
+ ...getToolErrorPayload(error),
1725
+ arguments: grepSearchArgs
1149
1726
  };
1150
1727
  }
1151
- return {
1152
- arguments: grepSearchArgs,
1153
- result: 'No matches found.'
1154
- };
1155
1728
  };
1156
1729
 
1157
1730
  const executeListFilesTool = async (args, _options) => {
@@ -1440,6 +2013,21 @@ const executeSearchTextTool = async (args, _options) => {
1440
2013
  };
1441
2014
  };
1442
2015
 
2016
+ const placeholderResponse = 'Hello From Sub agent - not yet implemented';
2017
+ const executeSpawnSubagentTool = async (args, _options) => {
2018
+ const prompt = typeof args.prompt === 'string' ? args.prompt : '';
2019
+ if (!prompt) {
2020
+ return {
2021
+ error: 'Missing required argument: prompt'
2022
+ };
2023
+ }
2024
+ return {
2025
+ ok: true,
2026
+ prompt,
2027
+ response: placeholderResponse
2028
+ };
2029
+ };
2030
+
1443
2031
  const todoDbName = 'chat-tool-worker';
1444
2032
  const todoStoreName = 'state';
1445
2033
  const todoKey = 'todoList';
@@ -1588,7 +2176,7 @@ const executeChatTool = async (name, rawArguments, options) => {
1588
2176
  case 'glob':
1589
2177
  return executeGlobTool(args);
1590
2178
  case 'grep_search':
1591
- return executeGrepSearchTool(args);
2179
+ return executeGrepSearchTool(args, options);
1592
2180
  case 'list_files':
1593
2181
  return executeListFilesTool(args);
1594
2182
  case 'open_preview':
@@ -1607,6 +2195,8 @@ const executeChatTool = async (name, rawArguments, options) => {
1607
2195
  return executeRunInTerminalTool(args);
1608
2196
  case 'search_text':
1609
2197
  return executeSearchTextTool(args);
2198
+ case 'spawn_subagent':
2199
+ return executeSpawnSubagentTool(args);
1610
2200
  case 'update_todo':
1611
2201
  return executeUpdateTodoTool(args);
1612
2202
  case 'write_file':
@@ -1618,79 +2208,47 @@ const executeChatTool = async (name, rawArguments, options) => {
1618
2208
  }
1619
2209
  };
1620
2210
 
1621
- const getReadFileTool = () => {
2211
+ const getClosePreviewTool = () => {
1622
2212
  return {
1623
2213
  function: {
1624
- description: 'Read UTF-8 text content from a file inside the currently open workspace folder. Only pass an absolute URI.',
1625
- name: 'read_file',
2214
+ description: 'Close the right-side preview if it is currently open.',
2215
+ name: 'close_preview',
1626
2216
  parameters: {
1627
2217
  additionalProperties: false,
1628
- properties: {
1629
- uri: {
1630
- description: 'Absolute file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
1631
- type: 'string'
1632
- }
1633
- },
1634
- required: ['uri'],
2218
+ properties: {},
1635
2219
  type: 'object'
1636
2220
  }
1637
2221
  },
1638
2222
  type: 'function'
1639
2223
  };
1640
2224
  };
1641
- const getWriteFileTool = () => {
2225
+
2226
+ const getCreateDirectoryTool = () => {
1642
2227
  return {
1643
2228
  function: {
1644
- description: 'Write UTF-8 text content to a file for an absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Do not pass a relative path and do not use a `path` argument.',
1645
- name: 'write_file',
2229
+ description: 'Create a new directory at the given absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Do not pass a relative path.',
2230
+ name: 'create_directory',
1646
2231
  parameters: {
1647
2232
  additionalProperties: false,
1648
2233
  properties: {
1649
- content: {
1650
- description: 'New UTF-8 text content to write to the file.',
1651
- type: 'string'
1652
- },
1653
2234
  uri: {
1654
- description: 'Absolute URI for the target file (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Relative paths are not allowed.',
2235
+ description: 'Absolute URI for the target directory (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Relative paths are not allowed.',
1655
2236
  type: 'string'
1656
2237
  }
1657
2238
  },
1658
- required: ['uri', 'content'],
2239
+ required: ['uri'],
1659
2240
  type: 'object'
1660
2241
  }
1661
2242
  },
1662
2243
  type: 'function'
1663
2244
  };
1664
2245
  };
1665
- const getRenameTool = () => {
2246
+
2247
+ const getEditFileTool = () => {
1666
2248
  return {
1667
2249
  function: {
1668
- description: 'Rename or move a file or folder from one absolute URI to another absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs).',
1669
- name: 'rename',
1670
- parameters: {
1671
- additionalProperties: false,
1672
- properties: {
1673
- newUri: {
1674
- description: 'Absolute target URI for the file or folder after renaming.',
1675
- type: 'string'
1676
- },
1677
- oldUri: {
1678
- description: 'Absolute source URI for the existing file or folder to rename.',
1679
- type: 'string'
1680
- }
1681
- },
1682
- required: ['oldUri', 'newUri'],
1683
- type: 'object'
1684
- }
1685
- },
1686
- type: 'function'
1687
- };
1688
- };
1689
- const getEditFileTool = () => {
1690
- return {
1691
- function: {
1692
- description: 'Apply a targeted text edit to an existing file by character offsets. This reads the current file, applies the edit, and writes the updated result. Use this for small changes instead of rewriting the full file.',
1693
- name: 'edit_file',
2250
+ description: 'Apply a targeted text edit to an existing file by character offsets. This reads the current file, applies the edit, and writes the updated result. Use this for small changes instead of rewriting the full file.',
2251
+ name: 'edit_file',
1694
2252
  parameters: {
1695
2253
  additionalProperties: false,
1696
2254
  properties: {
@@ -1718,78 +2276,90 @@ const getEditFileTool = () => {
1718
2276
  type: 'function'
1719
2277
  };
1720
2278
  };
1721
- const getListFilesTool = () => {
2279
+
2280
+ const getGetWorkspaceUriTool = () => {
1722
2281
  return {
1723
2282
  function: {
1724
- description: 'List direct children (files and folders) for a folder URI inside the currently open workspace folder. If you do not already have a real workspace URI, call getWorkspaceUri first and then use that returned URI. Do not use placeholder URIs like file:///workspace.',
1725
- name: 'list_files',
2283
+ description: 'Get the URI of the currently open workspace folder. Call this first before using list_files, read_file, write_file, edit_file, open_preview, or openEditor when you do not already have a concrete workspace URI.',
2284
+ name: 'getWorkspaceUri',
1726
2285
  parameters: {
1727
2286
  additionalProperties: false,
1728
- properties: {
1729
- uri: {
1730
- description: 'Absolute folder URI for a real path inside the currently open workspace folder. If unknown, call getWorkspaceUri first and pass the returned workspaceUri value. Do not use placeholder URIs.',
1731
- type: 'string'
1732
- }
1733
- },
1734
- required: ['uri'],
2287
+ properties: {},
1735
2288
  type: 'object'
1736
2289
  }
1737
2290
  },
1738
2291
  type: 'function'
1739
2292
  };
1740
2293
  };
1741
- const getGetWorkspaceUriTool = () => {
2294
+
2295
+ const getGlobTool = () => {
1742
2296
  return {
1743
2297
  function: {
1744
- description: 'Get the URI of the currently open workspace folder. Call this first before using list_files, read_file, write_file, edit_file, open_preview, or openEditor when you do not already have a concrete workspace URI.',
1745
- name: 'getWorkspaceUri',
2298
+ description: 'Find files by glob pattern and return matching relative paths.',
2299
+ name: 'glob',
1746
2300
  parameters: {
1747
2301
  additionalProperties: false,
1748
- properties: {},
2302
+ properties: {
2303
+ pattern: {
2304
+ description: 'Glob pattern to match files, for example `packages/e2e/src/*.ts`.',
2305
+ type: 'string'
2306
+ }
2307
+ },
2308
+ required: ['pattern'],
1749
2309
  type: 'object'
1750
2310
  }
1751
2311
  },
1752
2312
  type: 'function'
1753
2313
  };
1754
2314
  };
1755
- const getRenderHtmlTool = () => {
2315
+
2316
+ const getGrepSearchTool = () => {
1756
2317
  return {
1757
2318
  function: {
1758
- description: 'Render custom HTML and optional CSS directly in the chat tool call list using native chat UI rendering. Use this for structured cards, tables, and small dashboards. After calling this tool, do not repeat the same HTML, data table, or long content again as plain text unless the user explicitly asks for a text-only version.',
1759
- name: 'render_html',
2319
+ description: "Do a fast text search in the workspace. Use this tool when you want to search with an exact string or regex. If you are not sure what words will appear in the workspace, prefer using regex patterns with alternation (|) or character classes to search for multiple potential words at once instead of making separate searches. For example, use 'function|method|procedure' to look for all of those words at once. Use includePattern to search within files matching a specific pattern, or in a specific file, using a relative path. Use 'includeIgnoredFiles' to include files normally ignored by .gitignore, other ignore files, and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower, only set it when you want to search in ignored folders like node_modules or build outputs. Use this tool when you want to see an overview of a particular file, instead of using read_file many times to look for code within a file.\n\nIn a multi-root workspace, you can scope the search to a specific workspace folder by using the absolute path to the folder as the includePattern, e.g. /path/to/folder.",
2320
+ name: 'grep_search',
1760
2321
  parameters: {
1761
2322
  additionalProperties: false,
1762
2323
  properties: {
1763
- css: {
1764
- description: 'Optional CSS string applied inside the preview document.',
1765
- type: 'string'
2324
+ includeIgnoredFiles: {
2325
+ description: 'Whether to include files that would normally be ignored according to .gitignore, other ignore files and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower. Only set it when you want to search in ignored folders like node_modules or build outputs.',
2326
+ type: 'boolean'
1766
2327
  },
1767
- html: {
1768
- description: 'HTML string to render in the preview document.',
2328
+ includePattern: {
2329
+ description: 'Search files matching this glob pattern. Will be applied to the relative path of files within the workspace. To search recursively inside a folder, use a proper glob pattern like "src/folder/**". Do not use | in includePattern. Can also be an absolute path to a workspace folder to scope the search in a multi-root workspace.',
1769
2330
  type: 'string'
1770
2331
  },
1771
- title: {
1772
- description: 'Optional short title for the preview.',
2332
+ isRegexp: {
2333
+ description: 'Whether the pattern is a regex.',
2334
+ type: 'boolean'
2335
+ },
2336
+ maxResults: {
2337
+ description: "The maximum number of results to return. Do not use this unless necessary, it can slow things down. By default, only some matches are returned. If you use this and don't see what you're looking for, you can try again with a more specific query or a larger maxResults.",
2338
+ type: 'number'
2339
+ },
2340
+ query: {
2341
+ description: "The pattern to search for in files in the workspace. Use regex with alternation (e.g., 'word1|word2|word3') or character classes to find multiple potential words in a single search. Be sure to set the isRegexp property properly to declare whether it's a regex or plain text pattern. Is case-insensitive.",
1773
2342
  type: 'string'
1774
2343
  }
1775
2344
  },
1776
- required: ['html'],
2345
+ required: ['query', 'isRegexp'],
1777
2346
  type: 'object'
1778
2347
  }
1779
2348
  },
1780
2349
  type: 'function'
1781
2350
  };
1782
2351
  };
1783
- const getOpenPreviewTool = () => {
2352
+
2353
+ const getListFilesTool = () => {
1784
2354
  return {
1785
2355
  function: {
1786
- description: 'Open the right-side preview for an HTML file URI inside the currently open workspace folder.',
1787
- name: 'open_preview',
2356
+ description: 'List direct children (files and folders) for a folder URI inside the currently open workspace folder. If you do not already have a real workspace URI, call getWorkspaceUri first and then use that returned URI. Do not use placeholder URIs like file:///workspace.',
2357
+ name: 'list_files',
1788
2358
  parameters: {
1789
2359
  additionalProperties: false,
1790
2360
  properties: {
1791
2361
  uri: {
1792
- description: 'Absolute HTML file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
2362
+ description: 'Absolute folder URI for a real path inside the currently open workspace folder. If unknown, call getWorkspaceUri first and pass the returned workspaceUri value. Do not use placeholder URIs.',
1793
2363
  type: 'string'
1794
2364
  }
1795
2365
  },
@@ -1800,6 +2370,7 @@ const getOpenPreviewTool = () => {
1800
2370
  type: 'function'
1801
2371
  };
1802
2372
  };
2373
+
1803
2374
  const getOpenEditorTool = () => {
1804
2375
  return {
1805
2376
  function: {
@@ -1820,130 +2391,137 @@ const getOpenEditorTool = () => {
1820
2391
  type: 'function'
1821
2392
  };
1822
2393
  };
1823
- const getClosePreviewTool = () => {
2394
+
2395
+ const getOpenPreviewTool = () => {
1824
2396
  return {
1825
2397
  function: {
1826
- description: 'Close the right-side preview if it is currently open.',
1827
- name: 'close_preview',
2398
+ description: 'Open the right-side preview for an HTML file URI inside the currently open workspace folder.',
2399
+ name: 'open_preview',
1828
2400
  parameters: {
1829
2401
  additionalProperties: false,
1830
- properties: {},
2402
+ properties: {
2403
+ uri: {
2404
+ description: 'Absolute HTML file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
2405
+ type: 'string'
2406
+ }
2407
+ },
2408
+ required: ['uri'],
1831
2409
  type: 'object'
1832
2410
  }
1833
2411
  },
1834
2412
  type: 'function'
1835
2413
  };
1836
2414
  };
1837
- const getSearchTextTool = () => {
2415
+
2416
+ const getReadFileTool = () => {
1838
2417
  return {
1839
2418
  function: {
1840
- description: 'Search text in workspace files using query options and return matching results.',
1841
- name: 'search_text',
2419
+ description: 'Read UTF-8 text content from a file inside the currently open workspace folder. Only pass an absolute URI.',
2420
+ name: 'read_file',
1842
2421
  parameters: {
1843
2422
  additionalProperties: false,
1844
2423
  properties: {
1845
- options: {
1846
- additionalProperties: false,
1847
- properties: {
1848
- exclude: {
1849
- items: {
1850
- type: 'string'
1851
- },
1852
- type: 'array'
1853
- },
1854
- isRegex: {
1855
- type: 'boolean'
1856
- },
1857
- machWholeWord: {
1858
- type: 'boolean'
1859
- },
1860
- matchCase: {
1861
- type: 'boolean'
1862
- },
1863
- value: {
1864
- type: 'string'
1865
- }
1866
- },
1867
- required: ['value', 'isRegex', 'matchCase', 'machWholeWord', 'exclude'],
1868
- type: 'object'
2424
+ uri: {
2425
+ description: 'Absolute file URI for a real path inside the currently open workspace folder. Do not use placeholder URIs.',
2426
+ type: 'string'
1869
2427
  }
1870
2428
  },
1871
- required: ['options'],
2429
+ required: ['uri'],
1872
2430
  type: 'object'
1873
2431
  }
1874
2432
  },
1875
2433
  type: 'function'
1876
2434
  };
1877
2435
  };
1878
- const getRgTool = () => {
2436
+
2437
+ const getRenameTool = () => {
1879
2438
  return {
1880
2439
  function: {
1881
- description: 'Search text or regex in workspace files using ripgrep-style arguments and return matching results.',
1882
- name: 'rg',
2440
+ description: 'Rename or move a file or folder from one absolute URI to another absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs).',
2441
+ name: 'rename',
1883
2442
  parameters: {
1884
2443
  additionalProperties: false,
1885
2444
  properties: {
1886
- '-n': {
1887
- description: 'When true, include line numbers in the output.',
1888
- type: 'boolean'
2445
+ newUri: {
2446
+ description: 'Absolute target URI for the file or folder after renaming.',
2447
+ type: 'string'
1889
2448
  },
1890
- output_mode: {
1891
- description: 'Result format to return.',
1892
- enum: ['content', 'files_with_matches', 'count'],
2449
+ oldUri: {
2450
+ description: 'Absolute source URI for the existing file or folder to rename.',
2451
+ type: 'string'
2452
+ }
2453
+ },
2454
+ required: ['oldUri', 'newUri'],
2455
+ type: 'object'
2456
+ }
2457
+ },
2458
+ type: 'function'
2459
+ };
2460
+ };
2461
+
2462
+ const getRenderHtmlTool = () => {
2463
+ return {
2464
+ function: {
2465
+ description: 'Render custom HTML and optional CSS directly in the chat tool call list using native chat UI rendering. Use this for structured cards, tables, and small dashboards. After calling this tool, do not repeat the same HTML, data table, or long content again as plain text unless the user explicitly asks for a text-only version.',
2466
+ name: 'render_html',
2467
+ parameters: {
2468
+ additionalProperties: false,
2469
+ properties: {
2470
+ css: {
2471
+ description: 'Optional CSS string applied inside the preview document.',
1893
2472
  type: 'string'
1894
2473
  },
1895
- path: {
1896
- description: 'Optional file or directory path inside the current workspace to scope the search.',
2474
+ html: {
2475
+ description: 'HTML string to render in the preview document.',
1897
2476
  type: 'string'
1898
2477
  },
1899
- pattern: {
1900
- description: 'Text or regular expression pattern to search for.',
2478
+ title: {
2479
+ description: 'Optional short title for the preview.',
1901
2480
  type: 'string'
1902
2481
  }
1903
2482
  },
1904
- required: ['pattern'],
2483
+ required: ['html'],
1905
2484
  type: 'object'
1906
2485
  }
1907
2486
  },
1908
2487
  type: 'function'
1909
2488
  };
1910
2489
  };
1911
- const getGrepSearchTool = () => {
2490
+
2491
+ const getRgTool = () => {
1912
2492
  return {
1913
2493
  function: {
1914
- description: "Do a fast text search in the workspace. Use this tool when you want to search with an exact string or regex. If you are not sure what words will appear in the workspace, prefer using regex patterns with alternation (|) or character classes to search for multiple potential words at once instead of making separate searches. For example, use 'function|method|procedure' to look for all of those words at once. Use includePattern to search within files matching a specific pattern, or in a specific file, using a relative path. Use 'includeIgnoredFiles' to include files normally ignored by .gitignore, other ignore files, and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower, only set it when you want to search in ignored folders like node_modules or build outputs. Use this tool when you want to see an overview of a particular file, instead of using read_file many times to look for code within a file.\n\nIn a multi-root workspace, you can scope the search to a specific workspace folder by using the absolute path to the folder as the includePattern, e.g. /path/to/folder.",
1915
- name: 'grep_search',
2494
+ description: 'Search text or regex in workspace files using ripgrep-style arguments and return matching results.',
2495
+ name: 'rg',
1916
2496
  parameters: {
1917
2497
  additionalProperties: false,
1918
2498
  properties: {
1919
- includeIgnoredFiles: {
1920
- description: 'Whether to include files that would normally be ignored according to .gitignore, other ignore files and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower. Only set it when you want to search in ignored folders like node_modules or build outputs.',
2499
+ '-n': {
2500
+ description: 'When true, include line numbers in the output.',
1921
2501
  type: 'boolean'
1922
2502
  },
1923
- includePattern: {
1924
- description: 'Search files matching this glob pattern. Will be applied to the relative path of files within the workspace. To search recursively inside a folder, use a proper glob pattern like "src/folder/**". Do not use | in includePattern. Can also be an absolute path to a workspace folder to scope the search in a multi-root workspace.',
2503
+ output_mode: {
2504
+ description: 'Result format to return.',
2505
+ enum: ['content', 'files_with_matches', 'count'],
1925
2506
  type: 'string'
1926
2507
  },
1927
- isRegexp: {
1928
- description: 'Whether the pattern is a regex.',
1929
- type: 'boolean'
1930
- },
1931
- maxResults: {
1932
- description: "The maximum number of results to return. Do not use this unless necessary, it can slow things down. By default, only some matches are returned. If you use this and don't see what you're looking for, you can try again with a more specific query or a larger maxResults.",
1933
- type: 'number'
2508
+ path: {
2509
+ description: 'Optional file or directory path inside the current workspace to scope the search.',
2510
+ type: 'string'
1934
2511
  },
1935
- query: {
1936
- description: "The pattern to search for in files in the workspace. Use regex with alternation (e.g., 'word1|word2|word3') or character classes to find multiple potential words in a single search. Be sure to set the isRegexp property properly to declare whether it's a regex or plain text pattern. Is case-insensitive.",
2512
+ pattern: {
2513
+ description: 'Text or regular expression pattern to search for.',
1937
2514
  type: 'string'
1938
2515
  }
1939
2516
  },
1940
- required: ['query', 'isRegexp'],
2517
+ required: ['pattern'],
1941
2518
  type: 'object'
1942
2519
  }
1943
2520
  },
1944
2521
  type: 'function'
1945
2522
  };
1946
2523
  };
2524
+
1947
2525
  const getRunInTerminalTool = () => {
1948
2526
  return {
1949
2527
  function: {
@@ -1973,46 +2551,70 @@ const getRunInTerminalTool = () => {
1973
2551
  type: 'function'
1974
2552
  };
1975
2553
  };
1976
- const getCreateDirectoryTool = () => {
2554
+
2555
+ const getSearchTextTool = () => {
1977
2556
  return {
1978
2557
  function: {
1979
- description: 'Create a new directory at the given absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Do not pass a relative path.',
1980
- name: 'create_directory',
2558
+ description: 'Search text in workspace files using query options and return matching results.',
2559
+ name: 'search_text',
1981
2560
  parameters: {
1982
2561
  additionalProperties: false,
1983
2562
  properties: {
1984
- uri: {
1985
- description: 'Absolute URI for the target directory (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Relative paths are not allowed.',
1986
- type: 'string'
2563
+ options: {
2564
+ additionalProperties: false,
2565
+ properties: {
2566
+ exclude: {
2567
+ items: {
2568
+ type: 'string'
2569
+ },
2570
+ type: 'array'
2571
+ },
2572
+ isRegex: {
2573
+ type: 'boolean'
2574
+ },
2575
+ machWholeWord: {
2576
+ type: 'boolean'
2577
+ },
2578
+ matchCase: {
2579
+ type: 'boolean'
2580
+ },
2581
+ value: {
2582
+ type: 'string'
2583
+ }
2584
+ },
2585
+ required: ['value', 'isRegex', 'matchCase', 'machWholeWord', 'exclude'],
2586
+ type: 'object'
1987
2587
  }
1988
2588
  },
1989
- required: ['uri'],
2589
+ required: ['options'],
1990
2590
  type: 'object'
1991
2591
  }
1992
2592
  },
1993
2593
  type: 'function'
1994
2594
  };
1995
2595
  };
1996
- const getGlobTool = () => {
2596
+
2597
+ const getSpawnSubagentTool = () => {
1997
2598
  return {
1998
2599
  function: {
1999
- description: 'Find files by glob pattern and return matching relative paths.',
2000
- name: 'glob',
2600
+ description: 'Spawn a subagent for a focused subtask. For now this tool is a stub and returns a fixed placeholder response while the integration is being built.',
2601
+ name: 'spawn_subagent',
2001
2602
  parameters: {
2002
2603
  additionalProperties: false,
2003
2604
  properties: {
2004
- pattern: {
2005
- description: 'Glob pattern to match files, for example `packages/e2e/src/*.ts`.',
2605
+ prompt: {
2606
+ description: 'Short task prompt to send to the subagent.',
2006
2607
  type: 'string'
2007
2608
  }
2008
2609
  },
2009
- required: ['pattern'],
2610
+ required: ['prompt'],
2010
2611
  type: 'object'
2011
2612
  }
2012
2613
  },
2013
2614
  type: 'function'
2014
2615
  };
2015
2616
  };
2617
+
2016
2618
  const getUpdateTodoTool = () => {
2017
2619
  return {
2018
2620
  function: {
@@ -2033,8 +2635,34 @@ const getUpdateTodoTool = () => {
2033
2635
  type: 'function'
2034
2636
  };
2035
2637
  };
2638
+
2639
+ const getWriteFileTool = () => {
2640
+ return {
2641
+ function: {
2642
+ description: 'Write UTF-8 text content to a file for an absolute URI (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Do not pass a relative path and do not use a `path` argument.',
2643
+ name: 'write_file',
2644
+ parameters: {
2645
+ additionalProperties: false,
2646
+ properties: {
2647
+ content: {
2648
+ description: 'New UTF-8 text content to write to the file.',
2649
+ type: 'string'
2650
+ },
2651
+ uri: {
2652
+ description: 'Absolute URI for the target file (for example `file://...`, `memfs://...`, or extension-provided file system URIs). Relative paths are not allowed.',
2653
+ type: 'string'
2654
+ }
2655
+ },
2656
+ required: ['uri', 'content'],
2657
+ type: 'object'
2658
+ }
2659
+ },
2660
+ type: 'function'
2661
+ };
2662
+ };
2663
+
2036
2664
  const getBasicChatTools = () => {
2037
- return [getReadFileTool(), getWriteFileTool(), getRenameTool(), getEditFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool(), getRgTool(), getGrepSearchTool(), getRunInTerminalTool(), getCreateDirectoryTool(), getGlobTool(), getUpdateTodoTool()];
2665
+ return [getReadFileTool(), getWriteFileTool(), getRenameTool(), getEditFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool(), getRgTool(), getGrepSearchTool(), getRunInTerminalTool(), getSpawnSubagentTool(), getCreateDirectoryTool(), getGlobTool(), getUpdateTodoTool()];
2038
2666
  };
2039
2667
 
2040
2668
  const handleMessagePort = async port => {
@@ -2050,6 +2678,28 @@ const commandMap = {
2050
2678
  'HandleMessagePort.handleMessagePort': handleMessagePort
2051
2679
  };
2052
2680
 
2681
+ const send$1 = async port => {
2682
+ await sendMessagePortToChatStorageWorker(port);
2683
+ };
2684
+ const initializeChatStorageWorker = async () => {
2685
+ const rpc = await create$3({
2686
+ commandMap: commandMap,
2687
+ send: send$1
2688
+ });
2689
+ set$2(rpc);
2690
+ };
2691
+
2692
+ const send = async port => {
2693
+ await sendMessagePortToFileSystemWorker(port, 0);
2694
+ };
2695
+ const initializeFileSystemWorker = async () => {
2696
+ const rpc = await create$3({
2697
+ commandMap: commandMap,
2698
+ send: send
2699
+ });
2700
+ set$1(rpc);
2701
+ };
2702
+
2053
2703
  const initializeRendererWorker = async () => {
2054
2704
  const rpc = await create$1({
2055
2705
  commandMap: commandMap
@@ -2058,7 +2708,7 @@ const initializeRendererWorker = async () => {
2058
2708
  };
2059
2709
 
2060
2710
  const listen = async () => {
2061
- await initializeRendererWorker();
2711
+ await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeChatStorageWorker()]);
2062
2712
  };
2063
2713
 
2064
2714
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-tool-worker",
3
- "version": "7.11.0",
3
+ "version": "7.13.0",
4
4
  "description": "Chat Tool Worker",
5
5
  "repository": {
6
6
  "type": "git",