@polka-codes/core 0.8.21 → 0.8.23

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.
@@ -168,15 +168,16 @@ export declare namespace allTools {
168
168
  _default_2 as attemptCompletion,
169
169
  _default_3 as delegate,
170
170
  _default_4 as executeCommand,
171
- _default_5 as listFiles,
172
- _default_6 as readFile,
173
- _default_7 as replaceInFile,
174
- _default_8 as searchFiles,
175
- _default_9 as updateKnowledge,
176
- _default_10 as writeToFile,
177
- _default_11 as handOver,
178
- _default_12 as removeFile,
179
- _default_13 as renameFile
171
+ _default_5 as fetchUrl,
172
+ _default_6 as listFiles,
173
+ _default_7 as readFile,
174
+ _default_8 as replaceInFile,
175
+ _default_9 as searchFiles,
176
+ _default_10 as updateKnowledge,
177
+ _default_11 as writeToFile,
178
+ _default_12 as handOver,
179
+ _default_13 as removeFile,
180
+ _default_14 as renameFile
180
181
  }
181
182
  }
182
183
 
@@ -928,6 +929,136 @@ export { _default as askFollowupQuestion_alias_2 }
928
929
  export { _default as default_alias_4 }
929
930
 
930
931
  declare const _default_10: {
932
+ handler: ToolHandler<{
933
+ readonly name: "update_knowledge";
934
+ readonly description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.";
935
+ readonly parameters: [{
936
+ readonly name: "path";
937
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
938
+ readonly required: true;
939
+ readonly usageValue: "Directory path here";
940
+ }, {
941
+ readonly name: "knowledge";
942
+ readonly description: "YAML content to merge into the knowledge file";
943
+ readonly required: true;
944
+ readonly usageValue: "YAML content with knowledge to update";
945
+ }];
946
+ readonly examples: [{
947
+ readonly description: "Add a new file entry";
948
+ readonly parameters: [{
949
+ readonly name: "path";
950
+ readonly value: "src/utils";
951
+ }, {
952
+ readonly name: "knowledge";
953
+ readonly value: "files:\n \"newFile.ts\":\n description: \"A new utility file\"\n api:\n functions:\n 1:\n name: \"processData\"\n params:\n 1: { name: \"data\", type: \"object\" }\n returns: \"object\"";
954
+ }];
955
+ }, {
956
+ readonly description: "Update an existing file description";
957
+ readonly parameters: [{
958
+ readonly name: "path";
959
+ readonly value: "src/utils";
960
+ }, {
961
+ readonly name: "knowledge";
962
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
963
+ }];
964
+ }, {
965
+ readonly description: "Add a new rule";
966
+ readonly parameters: [{
967
+ readonly name: "path";
968
+ readonly value: "src";
969
+ }, {
970
+ readonly name: "knowledge";
971
+ readonly value: "rules:\n 10: \"New rule to follow\"";
972
+ }];
973
+ }, {
974
+ readonly description: "Remove a rule";
975
+ readonly parameters: [{
976
+ readonly name: "path";
977
+ readonly value: "src";
978
+ }, {
979
+ readonly name: "knowledge";
980
+ readonly value: "rules:\n 5: null";
981
+ }];
982
+ }, {
983
+ readonly description: "Update nested properties using dot notation";
984
+ readonly parameters: [{
985
+ readonly name: "path";
986
+ readonly value: "src/components";
987
+ }, {
988
+ readonly name: "knowledge";
989
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
990
+ }];
991
+ }];
992
+ readonly permissionLevel: PermissionLevel.Write;
993
+ }, FilesystemProvider>;
994
+ isAvailable: (provider: FilesystemProvider) => boolean;
995
+ name: "update_knowledge";
996
+ description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.";
997
+ parameters: [{
998
+ readonly name: "path";
999
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
1000
+ readonly required: true;
1001
+ readonly usageValue: "Directory path here";
1002
+ }, {
1003
+ readonly name: "knowledge";
1004
+ readonly description: "YAML content to merge into the knowledge file";
1005
+ readonly required: true;
1006
+ readonly usageValue: "YAML content with knowledge to update";
1007
+ }];
1008
+ examples: [{
1009
+ readonly description: "Add a new file entry";
1010
+ readonly parameters: [{
1011
+ readonly name: "path";
1012
+ readonly value: "src/utils";
1013
+ }, {
1014
+ readonly name: "knowledge";
1015
+ readonly value: "files:\n \"newFile.ts\":\n description: \"A new utility file\"\n api:\n functions:\n 1:\n name: \"processData\"\n params:\n 1: { name: \"data\", type: \"object\" }\n returns: \"object\"";
1016
+ }];
1017
+ }, {
1018
+ readonly description: "Update an existing file description";
1019
+ readonly parameters: [{
1020
+ readonly name: "path";
1021
+ readonly value: "src/utils";
1022
+ }, {
1023
+ readonly name: "knowledge";
1024
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
1025
+ }];
1026
+ }, {
1027
+ readonly description: "Add a new rule";
1028
+ readonly parameters: [{
1029
+ readonly name: "path";
1030
+ readonly value: "src";
1031
+ }, {
1032
+ readonly name: "knowledge";
1033
+ readonly value: "rules:\n 10: \"New rule to follow\"";
1034
+ }];
1035
+ }, {
1036
+ readonly description: "Remove a rule";
1037
+ readonly parameters: [{
1038
+ readonly name: "path";
1039
+ readonly value: "src";
1040
+ }, {
1041
+ readonly name: "knowledge";
1042
+ readonly value: "rules:\n 5: null";
1043
+ }];
1044
+ }, {
1045
+ readonly description: "Update nested properties using dot notation";
1046
+ readonly parameters: [{
1047
+ readonly name: "path";
1048
+ readonly value: "src/components";
1049
+ }, {
1050
+ readonly name: "knowledge";
1051
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1052
+ }];
1053
+ }];
1054
+ permissionLevel: PermissionLevel.Write;
1055
+ };
1056
+ export { _default_10 as default_alias_16 }
1057
+ export { _default_10 as updateKnowledge }
1058
+ export { _default_10 as updateKnowledge_alias_1 }
1059
+ export { _default_10 as updateKnowledge_alias_2 }
1060
+
1061
+ declare const _default_11: {
931
1062
  handler: ToolHandler<{
932
1063
  readonly name: "write_to_file";
933
1064
  readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;` and `&gt;`.";
@@ -980,12 +1111,12 @@ declare const _default_10: {
980
1111
  }];
981
1112
  permissionLevel: PermissionLevel.Write;
982
1113
  };
983
- export { _default_10 as default_alias_16 }
984
- export { _default_10 as writeToFile }
985
- export { _default_10 as writeToFile_alias_1 }
986
- export { _default_10 as writeToFile_alias_2 }
1114
+ export { _default_11 as default_alias_17 }
1115
+ export { _default_11 as writeToFile }
1116
+ export { _default_11 as writeToFile_alias_1 }
1117
+ export { _default_11 as writeToFile_alias_2 }
987
1118
 
988
- declare const _default_11: {
1119
+ declare const _default_12: {
989
1120
  handler: ToolHandler<{
990
1121
  readonly name: "hand_over";
991
1122
  readonly description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.";
@@ -1070,12 +1201,12 @@ declare const _default_11: {
1070
1201
  }];
1071
1202
  permissionLevel: PermissionLevel.None;
1072
1203
  };
1073
- export { _default_11 as default_alias_8 }
1074
- export { _default_11 as handOver }
1075
- export { _default_11 as handOver_alias_1 }
1076
- export { _default_11 as handOver_alias_2 }
1204
+ export { _default_12 as default_alias_9 }
1205
+ export { _default_12 as handOver }
1206
+ export { _default_12 as handOver_alias_1 }
1207
+ export { _default_12 as handOver_alias_2 }
1077
1208
 
1078
- declare const _default_12: {
1209
+ declare const _default_13: {
1079
1210
  handler: ToolHandler<{
1080
1211
  readonly name: "remove_file";
1081
1212
  readonly description: "Request to remove a file at the specified path.";
@@ -1112,12 +1243,12 @@ declare const _default_12: {
1112
1243
  }];
1113
1244
  permissionLevel: PermissionLevel.Write;
1114
1245
  };
1115
- export { _default_12 as default_alias_11 }
1116
- export { _default_12 as removeFile }
1117
- export { _default_12 as removeFile_alias_1 }
1118
- export { _default_12 as removeFile_alias_2 }
1246
+ export { _default_13 as default_alias_12 }
1247
+ export { _default_13 as removeFile }
1248
+ export { _default_13 as removeFile_alias_1 }
1249
+ export { _default_13 as removeFile_alias_2 }
1119
1250
 
1120
- declare const _default_13: {
1251
+ declare const _default_14: {
1121
1252
  handler: ToolHandler<{
1122
1253
  readonly name: "rename_file";
1123
1254
  readonly description: "Request to rename a file from source path to target path.";
@@ -1170,10 +1301,10 @@ declare const _default_13: {
1170
1301
  }];
1171
1302
  permissionLevel: PermissionLevel.Write;
1172
1303
  };
1173
- export { _default_13 as default_alias_12 }
1174
- export { _default_13 as renameFile }
1175
- export { _default_13 as renameFile_alias_1 }
1176
- export { _default_13 as renameFile_alias_2 }
1304
+ export { _default_14 as default_alias_13 }
1305
+ export { _default_14 as renameFile }
1306
+ export { _default_14 as renameFile_alias_1 }
1307
+ export { _default_14 as renameFile_alias_2 }
1177
1308
 
1178
1309
  declare const _default_2: {
1179
1310
  handler: ToolHandler<{
@@ -1366,6 +1497,70 @@ export { _default_4 as executeCommand_alias_1 }
1366
1497
  export { _default_4 as executeCommand_alias_2 }
1367
1498
 
1368
1499
  declare const _default_5: {
1500
+ handler: ToolHandler<{
1501
+ readonly name: "fetch_url";
1502
+ readonly description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.";
1503
+ readonly parameters: [{
1504
+ readonly name: "url";
1505
+ readonly description: "One or more URLs to fetch, separated by commas if multiple.";
1506
+ readonly required: true;
1507
+ }];
1508
+ readonly examples: [{
1509
+ readonly description: "Fetch a single webpage";
1510
+ readonly parameters: [{
1511
+ readonly name: "url";
1512
+ readonly value: "https://example.com";
1513
+ }];
1514
+ }, {
1515
+ readonly description: "Fetch multiple webpages";
1516
+ readonly parameters: [{
1517
+ readonly name: "url";
1518
+ readonly value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP";
1519
+ }];
1520
+ }, {
1521
+ readonly description: "Fetch a raw file from GitHub";
1522
+ readonly parameters: [{
1523
+ readonly name: "url";
1524
+ readonly value: "https://raw.githubusercontent.com/user/repo/main/README.md";
1525
+ }];
1526
+ }];
1527
+ readonly permissionLevel: PermissionLevel.Read;
1528
+ }, WebProvider>;
1529
+ isAvailable: (provider: WebProvider) => boolean;
1530
+ name: "fetch_url";
1531
+ description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.";
1532
+ parameters: [{
1533
+ readonly name: "url";
1534
+ readonly description: "One or more URLs to fetch, separated by commas if multiple.";
1535
+ readonly required: true;
1536
+ }];
1537
+ examples: [{
1538
+ readonly description: "Fetch a single webpage";
1539
+ readonly parameters: [{
1540
+ readonly name: "url";
1541
+ readonly value: "https://example.com";
1542
+ }];
1543
+ }, {
1544
+ readonly description: "Fetch multiple webpages";
1545
+ readonly parameters: [{
1546
+ readonly name: "url";
1547
+ readonly value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP";
1548
+ }];
1549
+ }, {
1550
+ readonly description: "Fetch a raw file from GitHub";
1551
+ readonly parameters: [{
1552
+ readonly name: "url";
1553
+ readonly value: "https://raw.githubusercontent.com/user/repo/main/README.md";
1554
+ }];
1555
+ }];
1556
+ permissionLevel: PermissionLevel.Read;
1557
+ };
1558
+ export { _default_5 as default_alias_8 }
1559
+ export { _default_5 as fetchUrl }
1560
+ export { _default_5 as fetchUrl_alias_1 }
1561
+ export { _default_5 as fetchUrl_alias_2 }
1562
+
1563
+ declare const _default_6: {
1369
1564
  handler: ToolHandler<{
1370
1565
  readonly name: "list_files";
1371
1566
  readonly description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.";
@@ -1428,12 +1623,12 @@ declare const _default_5: {
1428
1623
  }];
1429
1624
  permissionLevel: PermissionLevel.Read;
1430
1625
  };
1431
- export { _default_5 as default_alias_9 }
1432
- export { _default_5 as listFiles }
1433
- export { _default_5 as listFiles_alias_1 }
1434
- export { _default_5 as listFiles_alias_2 }
1626
+ export { _default_6 as default_alias_10 }
1627
+ export { _default_6 as listFiles }
1628
+ export { _default_6 as listFiles_alias_1 }
1629
+ export { _default_6 as listFiles_alias_2 }
1435
1630
 
1436
- declare const _default_6: {
1631
+ declare const _default_7: {
1437
1632
  handler: ToolHandler<{
1438
1633
  readonly name: "read_file";
1439
1634
  readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
@@ -1482,12 +1677,12 @@ declare const _default_6: {
1482
1677
  }];
1483
1678
  permissionLevel: PermissionLevel.Read;
1484
1679
  };
1485
- export { _default_6 as default_alias_10 }
1486
- export { _default_6 as readFile }
1487
- export { _default_6 as readFile_alias_1 }
1488
- export { _default_6 as readFile_alias_2 }
1680
+ export { _default_7 as default_alias_11 }
1681
+ export { _default_7 as readFile }
1682
+ export { _default_7 as readFile_alias_1 }
1683
+ export { _default_7 as readFile_alias_2 }
1489
1684
 
1490
- declare const _default_7: {
1685
+ declare const _default_8: {
1491
1686
  handler: ToolHandler<{
1492
1687
  readonly name: "replace_in_file";
1493
1688
  readonly description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.";
@@ -1594,12 +1789,12 @@ declare const _default_7: {
1594
1789
  }];
1595
1790
  permissionLevel: PermissionLevel.Write;
1596
1791
  };
1597
- export { _default_7 as default_alias_13 }
1598
- export { _default_7 as replaceInFile }
1599
- export { _default_7 as replaceInFile_alias_1 }
1600
- export { _default_7 as replaceInFile_alias_2 }
1792
+ export { _default_8 as default_alias_14 }
1793
+ export { _default_8 as replaceInFile }
1794
+ export { _default_8 as replaceInFile_alias_1 }
1795
+ export { _default_8 as replaceInFile_alias_2 }
1601
1796
 
1602
- declare const _default_8: {
1797
+ declare const _default_9: {
1603
1798
  handler: ToolHandler<{
1604
1799
  readonly name: "search_files";
1605
1800
  readonly description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.";
@@ -1668,140 +1863,10 @@ declare const _default_8: {
1668
1863
  }];
1669
1864
  permissionLevel: PermissionLevel.Read;
1670
1865
  };
1671
- export { _default_8 as default_alias_14 }
1672
- export { _default_8 as searchFiles }
1673
- export { _default_8 as searchFiles_alias_1 }
1674
- export { _default_8 as searchFiles_alias_2 }
1675
-
1676
- declare const _default_9: {
1677
- handler: ToolHandler<{
1678
- readonly name: "update_knowledge";
1679
- readonly description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.";
1680
- readonly parameters: [{
1681
- readonly name: "path";
1682
- readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
1683
- readonly required: true;
1684
- readonly usageValue: "Directory path here";
1685
- }, {
1686
- readonly name: "knowledge";
1687
- readonly description: "YAML content to merge into the knowledge file";
1688
- readonly required: true;
1689
- readonly usageValue: "YAML content with knowledge to update";
1690
- }];
1691
- readonly examples: [{
1692
- readonly description: "Add a new file entry";
1693
- readonly parameters: [{
1694
- readonly name: "path";
1695
- readonly value: "src/utils";
1696
- }, {
1697
- readonly name: "knowledge";
1698
- readonly value: "files:\n \"newFile.ts\":\n description: \"A new utility file\"\n api:\n functions:\n 1:\n name: \"processData\"\n params:\n 1: { name: \"data\", type: \"object\" }\n returns: \"object\"";
1699
- }];
1700
- }, {
1701
- readonly description: "Update an existing file description";
1702
- readonly parameters: [{
1703
- readonly name: "path";
1704
- readonly value: "src/utils";
1705
- }, {
1706
- readonly name: "knowledge";
1707
- readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
1708
- }];
1709
- }, {
1710
- readonly description: "Add a new rule";
1711
- readonly parameters: [{
1712
- readonly name: "path";
1713
- readonly value: "src";
1714
- }, {
1715
- readonly name: "knowledge";
1716
- readonly value: "rules:\n 10: \"New rule to follow\"";
1717
- }];
1718
- }, {
1719
- readonly description: "Remove a rule";
1720
- readonly parameters: [{
1721
- readonly name: "path";
1722
- readonly value: "src";
1723
- }, {
1724
- readonly name: "knowledge";
1725
- readonly value: "rules:\n 5: null";
1726
- }];
1727
- }, {
1728
- readonly description: "Update nested properties using dot notation";
1729
- readonly parameters: [{
1730
- readonly name: "path";
1731
- readonly value: "src/components";
1732
- }, {
1733
- readonly name: "knowledge";
1734
- readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1735
- }];
1736
- }];
1737
- readonly permissionLevel: PermissionLevel.Write;
1738
- }, FilesystemProvider>;
1739
- isAvailable: (provider: FilesystemProvider) => boolean;
1740
- name: "update_knowledge";
1741
- description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.";
1742
- parameters: [{
1743
- readonly name: "path";
1744
- readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
1745
- readonly required: true;
1746
- readonly usageValue: "Directory path here";
1747
- }, {
1748
- readonly name: "knowledge";
1749
- readonly description: "YAML content to merge into the knowledge file";
1750
- readonly required: true;
1751
- readonly usageValue: "YAML content with knowledge to update";
1752
- }];
1753
- examples: [{
1754
- readonly description: "Add a new file entry";
1755
- readonly parameters: [{
1756
- readonly name: "path";
1757
- readonly value: "src/utils";
1758
- }, {
1759
- readonly name: "knowledge";
1760
- readonly value: "files:\n \"newFile.ts\":\n description: \"A new utility file\"\n api:\n functions:\n 1:\n name: \"processData\"\n params:\n 1: { name: \"data\", type: \"object\" }\n returns: \"object\"";
1761
- }];
1762
- }, {
1763
- readonly description: "Update an existing file description";
1764
- readonly parameters: [{
1765
- readonly name: "path";
1766
- readonly value: "src/utils";
1767
- }, {
1768
- readonly name: "knowledge";
1769
- readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
1770
- }];
1771
- }, {
1772
- readonly description: "Add a new rule";
1773
- readonly parameters: [{
1774
- readonly name: "path";
1775
- readonly value: "src";
1776
- }, {
1777
- readonly name: "knowledge";
1778
- readonly value: "rules:\n 10: \"New rule to follow\"";
1779
- }];
1780
- }, {
1781
- readonly description: "Remove a rule";
1782
- readonly parameters: [{
1783
- readonly name: "path";
1784
- readonly value: "src";
1785
- }, {
1786
- readonly name: "knowledge";
1787
- readonly value: "rules:\n 5: null";
1788
- }];
1789
- }, {
1790
- readonly description: "Update nested properties using dot notation";
1791
- readonly parameters: [{
1792
- readonly name: "path";
1793
- readonly value: "src/components";
1794
- }, {
1795
- readonly name: "knowledge";
1796
- readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1797
- }];
1798
- }];
1799
- permissionLevel: PermissionLevel.Write;
1800
- };
1801
1866
  export { _default_9 as default_alias_15 }
1802
- export { _default_9 as updateKnowledge }
1803
- export { _default_9 as updateKnowledge_alias_1 }
1804
- export { _default_9 as updateKnowledge_alias_2 }
1867
+ export { _default_9 as searchFiles }
1868
+ export { _default_9 as searchFiles_alias_1 }
1869
+ export { _default_9 as searchFiles_alias_2 }
1805
1870
 
1806
1871
  /**
1807
1872
  * AI tool for creating new projects based on user specifications.
@@ -1857,6 +1922,12 @@ declare const defaultModels: {
1857
1922
  export { defaultModels }
1858
1923
  export { defaultModels as defaultModels_alias_1 }
1859
1924
 
1925
+ /**
1926
+ * Returns the directory portion of a path string.
1927
+ * Strips trailing slashes, then takes everything up to the last slash.
1928
+ */
1929
+ export declare function dirname(path: string): string;
1930
+
1860
1931
  export declare const editingFilesPrompt: (toolNamePrefix: string) => string;
1861
1932
 
1862
1933
  declare const executeAgentTool: <T extends AiToolDefinition<any, any>>(definition: T, agent: MultiAgent, params: GetInput<T>) => Promise<GetOutput<T>>;
@@ -2022,13 +2093,15 @@ export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, Fil
2022
2093
 
2023
2094
  export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
2024
2095
 
2096
+ export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, FilesystemProvider>;
2097
+
2025
2098
  export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, any>;
2026
2099
 
2027
2100
  export declare const handler_alias_3: ToolHandler<typeof toolInfo_alias_3, CommandProvider>;
2028
2101
 
2029
- export declare const handler_alias_4: ToolHandler<typeof toolInfo_alias_4, any>;
2102
+ export declare const handler_alias_4: ToolHandler<typeof toolInfo_alias_4, WebProvider>;
2030
2103
 
2031
- export declare const handler_alias_5: ToolHandler<typeof toolInfo_alias_5, FilesystemProvider>;
2104
+ export declare const handler_alias_5: ToolHandler<typeof toolInfo_alias_5, any>;
2032
2105
 
2033
2106
  export declare const handler_alias_6: ToolHandler<typeof toolInfo_alias_6, FilesystemProvider>;
2034
2107
 
@@ -2063,13 +2136,15 @@ export declare const isAvailable_alias_11: (provider: FilesystemProvider) => boo
2063
2136
 
2064
2137
  export declare const isAvailable_alias_12: (provider: FilesystemProvider) => boolean;
2065
2138
 
2139
+ export declare const isAvailable_alias_13: (provider: FilesystemProvider) => boolean;
2140
+
2066
2141
  export declare const isAvailable_alias_2: (_provider: any) => boolean;
2067
2142
 
2068
2143
  export declare const isAvailable_alias_3: (provider: CommandProvider) => boolean;
2069
2144
 
2070
- export declare const isAvailable_alias_4: (_provider: any) => boolean;
2145
+ export declare const isAvailable_alias_4: (provider: WebProvider) => boolean;
2071
2146
 
2072
- export declare const isAvailable_alias_5: (provider: FilesystemProvider) => boolean;
2147
+ export declare const isAvailable_alias_5: (_provider: any) => boolean;
2073
2148
 
2074
2149
  export declare const isAvailable_alias_6: (provider: FilesystemProvider) => boolean;
2075
2150
 
@@ -2079,6 +2154,11 @@ export declare const isAvailable_alias_8: (provider: FilesystemProvider) => bool
2079
2154
 
2080
2155
  export declare const isAvailable_alias_9: (provider: FilesystemProvider) => boolean;
2081
2156
 
2157
+ /**
2158
+ * Joins all given path segments, then normalizes the result.
2159
+ */
2160
+ export declare function join(...parts: string[]): string;
2161
+
2082
2162
  declare const KnowledgeManagementPolicy: (tools: Parameters<AgentPolicy>[0]) => {
2083
2163
  name: Policies;
2084
2164
  tools: {
@@ -2532,7 +2612,7 @@ export { replaceInFile_2 as replaceInFile_alias_4 }
2532
2612
 
2533
2613
  declare const responsePrompts: {
2534
2614
  readonly errorInvokeTool: (tool: string, error: unknown) => string;
2535
- readonly requireUseTool: "Error: You MUST use a tool before proceeding using XCM tags. e.g. <tool_tool_name>tool_name</tool_tool_name>";
2615
+ readonly requireUseTool: "Error: No tool use detected. You MUST use a tool before proceeding.\ne.g. <tool_tool_name>tool_name</tool_tool_name>\n\nEnsure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.\nAvoid unnecessary text or symbols before or after the tool use.\nAvoid unnecessary escape characters or special characters.\n";
2536
2616
  readonly toolResults: (tool: string, result: string) => string;
2537
2617
  readonly commandResult: (command: string, exitCode: number, stdout: string, stderr: string) => string;
2538
2618
  };
@@ -2844,6 +2924,60 @@ export declare const toolInfo_alias_1: {
2844
2924
  };
2845
2925
 
2846
2926
  export declare const toolInfo_alias_10: {
2927
+ readonly name: "replace_in_file";
2928
+ readonly description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.";
2929
+ readonly parameters: [{
2930
+ readonly name: "path";
2931
+ readonly description: "The path of the file to modify";
2932
+ readonly required: true;
2933
+ readonly usageValue: "File path here";
2934
+ }, {
2935
+ readonly name: "diff";
2936
+ readonly description: "One or more SEARCH/REPLACE blocks following this exact format:\n```\n<<<<<<< SEARCH\n[exact content to find]\n=======\n[new content to replace with]\n>>>>>>> REPLACE\n```\nCritical rules:\n1. SEARCH content must match the associated file section to find EXACTLY:\n * Match character-for-character including whitespace, indentation, line endings\n * Include all comments, docstrings, etc.\n2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.\n * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.\n * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.\n * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.\n3. Keep SEARCH/REPLACE blocks concise:\n * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.\n * Include just the changing lines, and a few surrounding lines if needed for uniqueness.\n * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.\n * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.\n4. Special operations:\n * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)\n * To delete code: Use empty REPLACE section";
2937
+ readonly required: true;
2938
+ readonly usageValue: "Search and replace blocks here";
2939
+ }];
2940
+ readonly examples: [{
2941
+ readonly description: "Request to replace sections of content in a file";
2942
+ readonly parameters: [{
2943
+ readonly name: "path";
2944
+ readonly value: "src/main.js";
2945
+ }, {
2946
+ readonly name: "diff";
2947
+ readonly value: "\n<<<<<<< SEARCH\nimport React from 'react';\n=======\nimport React, { useState } from 'react';\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\n=======\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nreturn (\n <div>\n=======\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\nreturn (\n <div>\n>>>>>>> REPLACE\n";
2948
+ }];
2949
+ }, {
2950
+ readonly description: "Request to perform a simple, single-line replacement";
2951
+ readonly parameters: [{
2952
+ readonly name: "path";
2953
+ readonly value: "src/config.js";
2954
+ }, {
2955
+ readonly name: "diff";
2956
+ readonly value: "\n<<<<<<< SEARCH\nconst API_URL = 'https://api.example.com';\n=======\nconst API_URL = 'https://api.staging.example.com';\n>>>>>>> REPLACE\n";
2957
+ }];
2958
+ }, {
2959
+ readonly description: "Request to add a new function to a file";
2960
+ readonly parameters: [{
2961
+ readonly name: "path";
2962
+ readonly value: "src/utils.js";
2963
+ }, {
2964
+ readonly name: "diff";
2965
+ readonly value: "\n<<<<<<< SEARCH\nfunction helperA() {\n // ...\n}\n=======\nfunction helperA() {\n // ...\n}\n\nfunction newHelper() {\n // implementation\n}\n>>>>>>> REPLACE\n";
2966
+ }];
2967
+ }, {
2968
+ readonly description: "Request to delete a block of code from a file";
2969
+ readonly parameters: [{
2970
+ readonly name: "path";
2971
+ readonly value: "src/app.js";
2972
+ }, {
2973
+ readonly name: "diff";
2974
+ readonly value: "\n<<<<<<< SEARCH\nfunction oldFeature() {\n // This is no longer needed\n}\n\n=======\n>>>>>>> REPLACE\n";
2975
+ }];
2976
+ }];
2977
+ readonly permissionLevel: PermissionLevel.Write;
2978
+ };
2979
+
2980
+ export declare const toolInfo_alias_11: {
2847
2981
  readonly name: "search_files";
2848
2982
  readonly description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.";
2849
2983
  readonly parameters: [{
@@ -2878,7 +3012,7 @@ export declare const toolInfo_alias_10: {
2878
3012
  readonly permissionLevel: PermissionLevel.Read;
2879
3013
  };
2880
3014
 
2881
- export declare const toolInfo_alias_11: {
3015
+ export declare const toolInfo_alias_12: {
2882
3016
  readonly name: "update_knowledge";
2883
3017
  readonly description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.";
2884
3018
  readonly parameters: [{
@@ -2941,7 +3075,7 @@ export declare const toolInfo_alias_11: {
2941
3075
  readonly permissionLevel: PermissionLevel.Write;
2942
3076
  };
2943
3077
 
2944
- export declare const toolInfo_alias_12: {
3078
+ export declare const toolInfo_alias_13: {
2945
3079
  readonly name: "write_to_file";
2946
3080
  readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;` and `&gt;`.";
2947
3081
  readonly parameters: [{
@@ -3039,6 +3173,36 @@ export declare const toolInfo_alias_3: {
3039
3173
  };
3040
3174
 
3041
3175
  export declare const toolInfo_alias_4: {
3176
+ readonly name: "fetch_url";
3177
+ readonly description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.";
3178
+ readonly parameters: [{
3179
+ readonly name: "url";
3180
+ readonly description: "One or more URLs to fetch, separated by commas if multiple.";
3181
+ readonly required: true;
3182
+ }];
3183
+ readonly examples: [{
3184
+ readonly description: "Fetch a single webpage";
3185
+ readonly parameters: [{
3186
+ readonly name: "url";
3187
+ readonly value: "https://example.com";
3188
+ }];
3189
+ }, {
3190
+ readonly description: "Fetch multiple webpages";
3191
+ readonly parameters: [{
3192
+ readonly name: "url";
3193
+ readonly value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP";
3194
+ }];
3195
+ }, {
3196
+ readonly description: "Fetch a raw file from GitHub";
3197
+ readonly parameters: [{
3198
+ readonly name: "url";
3199
+ readonly value: "https://raw.githubusercontent.com/user/repo/main/README.md";
3200
+ }];
3201
+ }];
3202
+ readonly permissionLevel: PermissionLevel.Read;
3203
+ };
3204
+
3205
+ export declare const toolInfo_alias_5: {
3042
3206
  readonly name: "hand_over";
3043
3207
  readonly description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.";
3044
3208
  readonly parameters: [{
@@ -3081,7 +3245,7 @@ export declare const toolInfo_alias_4: {
3081
3245
  readonly permissionLevel: PermissionLevel.None;
3082
3246
  };
3083
3247
 
3084
- export declare const toolInfo_alias_5: {
3248
+ export declare const toolInfo_alias_6: {
3085
3249
  readonly name: "list_files";
3086
3250
  readonly description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.";
3087
3251
  readonly parameters: [{
@@ -3113,7 +3277,7 @@ export declare const toolInfo_alias_5: {
3113
3277
  readonly permissionLevel: PermissionLevel.Read;
3114
3278
  };
3115
3279
 
3116
- export declare const toolInfo_alias_6: {
3280
+ export declare const toolInfo_alias_7: {
3117
3281
  readonly name: "read_file";
3118
3282
  readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.";
3119
3283
  readonly parameters: [{
@@ -3138,7 +3302,7 @@ export declare const toolInfo_alias_6: {
3138
3302
  readonly permissionLevel: PermissionLevel.Read;
3139
3303
  };
3140
3304
 
3141
- export declare const toolInfo_alias_7: {
3305
+ export declare const toolInfo_alias_8: {
3142
3306
  readonly name: "remove_file";
3143
3307
  readonly description: "Request to remove a file at the specified path.";
3144
3308
  readonly parameters: [{
@@ -3157,7 +3321,7 @@ export declare const toolInfo_alias_7: {
3157
3321
  readonly permissionLevel: PermissionLevel.Write;
3158
3322
  };
3159
3323
 
3160
- export declare const toolInfo_alias_8: {
3324
+ export declare const toolInfo_alias_9: {
3161
3325
  readonly name: "rename_file";
3162
3326
  readonly description: "Request to rename a file from source path to target path.";
3163
3327
  readonly parameters: [{
@@ -3184,60 +3348,6 @@ export declare const toolInfo_alias_8: {
3184
3348
  readonly permissionLevel: PermissionLevel.Write;
3185
3349
  };
3186
3350
 
3187
- export declare const toolInfo_alias_9: {
3188
- readonly name: "replace_in_file";
3189
- readonly description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.";
3190
- readonly parameters: [{
3191
- readonly name: "path";
3192
- readonly description: "The path of the file to modify";
3193
- readonly required: true;
3194
- readonly usageValue: "File path here";
3195
- }, {
3196
- readonly name: "diff";
3197
- readonly description: "One or more SEARCH/REPLACE blocks following this exact format:\n```\n<<<<<<< SEARCH\n[exact content to find]\n=======\n[new content to replace with]\n>>>>>>> REPLACE\n```\nCritical rules:\n1. SEARCH content must match the associated file section to find EXACTLY:\n * Match character-for-character including whitespace, indentation, line endings\n * Include all comments, docstrings, etc.\n2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.\n * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.\n * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.\n * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.\n3. Keep SEARCH/REPLACE blocks concise:\n * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.\n * Include just the changing lines, and a few surrounding lines if needed for uniqueness.\n * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.\n * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.\n4. Special operations:\n * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)\n * To delete code: Use empty REPLACE section";
3198
- readonly required: true;
3199
- readonly usageValue: "Search and replace blocks here";
3200
- }];
3201
- readonly examples: [{
3202
- readonly description: "Request to replace sections of content in a file";
3203
- readonly parameters: [{
3204
- readonly name: "path";
3205
- readonly value: "src/main.js";
3206
- }, {
3207
- readonly name: "diff";
3208
- readonly value: "\n<<<<<<< SEARCH\nimport React from 'react';\n=======\nimport React, { useState } from 'react';\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\n=======\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nreturn (\n <div>\n=======\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\nreturn (\n <div>\n>>>>>>> REPLACE\n";
3209
- }];
3210
- }, {
3211
- readonly description: "Request to perform a simple, single-line replacement";
3212
- readonly parameters: [{
3213
- readonly name: "path";
3214
- readonly value: "src/config.js";
3215
- }, {
3216
- readonly name: "diff";
3217
- readonly value: "\n<<<<<<< SEARCH\nconst API_URL = 'https://api.example.com';\n=======\nconst API_URL = 'https://api.staging.example.com';\n>>>>>>> REPLACE\n";
3218
- }];
3219
- }, {
3220
- readonly description: "Request to add a new function to a file";
3221
- readonly parameters: [{
3222
- readonly name: "path";
3223
- readonly value: "src/utils.js";
3224
- }, {
3225
- readonly name: "diff";
3226
- readonly value: "\n<<<<<<< SEARCH\nfunction helperA() {\n // ...\n}\n=======\nfunction helperA() {\n // ...\n}\n\nfunction newHelper() {\n // implementation\n}\n>>>>>>> REPLACE\n";
3227
- }];
3228
- }, {
3229
- readonly description: "Request to delete a block of code from a file";
3230
- readonly parameters: [{
3231
- readonly name: "path";
3232
- readonly value: "src/app.js";
3233
- }, {
3234
- readonly name: "diff";
3235
- readonly value: "\n<<<<<<< SEARCH\nfunction oldFeature() {\n // This is no longer needed\n}\n\n=======\n>>>>>>> REPLACE\n";
3236
- }];
3237
- }];
3238
- readonly permissionLevel: PermissionLevel.Write;
3239
- };
3240
-
3241
3351
  declare type ToolParameter = {
3242
3352
  name: string;
3243
3353
  description: string;
@@ -3255,7 +3365,7 @@ declare type ToolParameterValue = string | {
3255
3365
  export { ToolParameterValue }
3256
3366
  export { ToolParameterValue as ToolParameterValue_alias_1 }
3257
3367
 
3258
- declare type ToolProvider = FilesystemProvider & CommandProvider & InteractionProvider;
3368
+ declare type ToolProvider = FilesystemProvider & CommandProvider & InteractionProvider & WebProvider;
3259
3369
  export { ToolProvider }
3260
3370
  export { ToolProvider as ToolProvider_alias_1 }
3261
3371
  export { ToolProvider as ToolProvider_alias_2 }
@@ -3420,4 +3530,11 @@ export { UsageMeter }
3420
3530
  export { UsageMeter as UsageMeter_alias_1 }
3421
3531
  export { UsageMeter as UsageMeter_alias_2 }
3422
3532
 
3533
+ declare type WebProvider = {
3534
+ fetchUrl?: (url: string) => Promise<string>;
3535
+ };
3536
+ export { WebProvider }
3537
+ export { WebProvider as WebProvider_alias_1 }
3538
+ export { WebProvider as WebProvider_alias_2 }
3539
+
3423
3540
  export { }
package/dist/index.d.ts CHANGED
@@ -65,12 +65,14 @@ export { allTools } from './_tsup-dts-rollup.js';
65
65
  export { FilesystemProvider } from './_tsup-dts-rollup.js';
66
66
  export { CommandProvider } from './_tsup-dts-rollup.js';
67
67
  export { InteractionProvider } from './_tsup-dts-rollup.js';
68
+ export { WebProvider } from './_tsup-dts-rollup.js';
68
69
  export { ToolProvider } from './_tsup-dts-rollup.js';
69
70
  export { MockProvider } from './_tsup-dts-rollup.js';
70
71
  export { askFollowupQuestion } from './_tsup-dts-rollup.js';
71
72
  export { attemptCompletion } from './_tsup-dts-rollup.js';
72
73
  export { delegate } from './_tsup-dts-rollup.js';
73
74
  export { executeCommand } from './_tsup-dts-rollup.js';
75
+ export { fetchUrl } from './_tsup-dts-rollup.js';
74
76
  export { listFiles } from './_tsup-dts-rollup.js';
75
77
  export { readFile } from './_tsup-dts-rollup.js';
76
78
  export { replaceInFile } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -883,6 +883,7 @@ __export(allTools_exports, {
883
883
  attemptCompletion: () => attemptCompletion_default,
884
884
  delegate: () => delegate_default,
885
885
  executeCommand: () => executeCommand_default,
886
+ fetchUrl: () => fetchUrl_default,
886
887
  handOver: () => handOver_default,
887
888
  listFiles: () => listFiles_default,
888
889
  readFile: () => readFile_default,
@@ -1371,8 +1372,89 @@ var executeCommand_default = {
1371
1372
  isAvailable: isAvailable4
1372
1373
  };
1373
1374
 
1374
- // src/tools/listFiles.ts
1375
+ // src/tools/fetchUrl.ts
1375
1376
  var toolInfo5 = {
1377
+ name: "fetch_url",
1378
+ description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
1379
+ parameters: [
1380
+ {
1381
+ name: "url",
1382
+ description: "One or more URLs to fetch, separated by commas if multiple.",
1383
+ required: true
1384
+ }
1385
+ ],
1386
+ examples: [
1387
+ {
1388
+ description: "Fetch a single webpage",
1389
+ parameters: [
1390
+ {
1391
+ name: "url",
1392
+ value: "https://example.com"
1393
+ }
1394
+ ]
1395
+ },
1396
+ {
1397
+ description: "Fetch multiple webpages",
1398
+ parameters: [
1399
+ {
1400
+ name: "url",
1401
+ value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
1402
+ }
1403
+ ]
1404
+ },
1405
+ {
1406
+ description: "Fetch a raw file from GitHub",
1407
+ parameters: [
1408
+ {
1409
+ name: "url",
1410
+ value: "https://raw.githubusercontent.com/user/repo/main/README.md"
1411
+ }
1412
+ ]
1413
+ }
1414
+ ],
1415
+ permissionLevel: 1 /* Read */
1416
+ };
1417
+ var handler5 = async (provider, args) => {
1418
+ if (!provider.fetchUrl) {
1419
+ return {
1420
+ type: "Error" /* Error */,
1421
+ message: "Not possible to fetch url. Abort."
1422
+ };
1423
+ }
1424
+ const urls = getStringArray(args, "url");
1425
+ if (urls.length === 0) {
1426
+ return {
1427
+ type: "Error" /* Error */,
1428
+ message: "No URLs provided. Please provide at least one URL to fetch."
1429
+ };
1430
+ }
1431
+ const results = [];
1432
+ for (const url of urls) {
1433
+ try {
1434
+ const content = provider.fetchUrl(url).then((res) => `<fetch_url_content url="${url}">${res}</fetch_url_content>`);
1435
+ results.push(content);
1436
+ } catch (error) {
1437
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
1438
+ results.push(Promise.resolve(`<fetch_url_error url="${url}">${errorMessage}</fetch_url_error>`));
1439
+ }
1440
+ }
1441
+ const resolvedResults = await Promise.all(results);
1442
+ return {
1443
+ type: "Reply" /* Reply */,
1444
+ message: resolvedResults.join("\n")
1445
+ };
1446
+ };
1447
+ var isAvailable5 = (provider) => {
1448
+ return typeof provider.fetchUrl === "function";
1449
+ };
1450
+ var fetchUrl_default = {
1451
+ ...toolInfo5,
1452
+ handler: handler5,
1453
+ isAvailable: isAvailable5
1454
+ };
1455
+
1456
+ // src/tools/listFiles.ts
1457
+ var toolInfo6 = {
1376
1458
  name: "list_files",
1377
1459
  description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
1378
1460
  parameters: [
@@ -1412,7 +1494,7 @@ var toolInfo5 = {
1412
1494
  ],
1413
1495
  permissionLevel: 1 /* Read */
1414
1496
  };
1415
- var handler5 = async (provider, args) => {
1497
+ var handler6 = async (provider, args) => {
1416
1498
  if (!provider.listFiles) {
1417
1499
  return {
1418
1500
  type: "Error" /* Error */,
@@ -1432,17 +1514,17 @@ ${files.join("\n")}
1432
1514
  <list_files_truncated>${limitReached}</list_files_truncated>`
1433
1515
  };
1434
1516
  };
1435
- var isAvailable5 = (provider) => {
1517
+ var isAvailable6 = (provider) => {
1436
1518
  return !!provider.listFiles;
1437
1519
  };
1438
1520
  var listFiles_default = {
1439
- ...toolInfo5,
1440
- handler: handler5,
1441
- isAvailable: isAvailable5
1521
+ ...toolInfo6,
1522
+ handler: handler6,
1523
+ isAvailable: isAvailable6
1442
1524
  };
1443
1525
 
1444
1526
  // src/tools/readFile.ts
1445
- var toolInfo6 = {
1527
+ var toolInfo7 = {
1446
1528
  name: "read_file",
1447
1529
  description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
1448
1530
  parameters: [
@@ -1475,7 +1557,7 @@ var toolInfo6 = {
1475
1557
  ],
1476
1558
  permissionLevel: 1 /* Read */
1477
1559
  };
1478
- var handler6 = async (provider, args) => {
1560
+ var handler7 = async (provider, args) => {
1479
1561
  if (!provider.readFile) {
1480
1562
  return {
1481
1563
  type: "Error" /* Error */,
@@ -1502,17 +1584,17 @@ var handler6 = async (provider, args) => {
1502
1584
  message: resp.join("\n")
1503
1585
  };
1504
1586
  };
1505
- var isAvailable6 = (provider) => {
1587
+ var isAvailable7 = (provider) => {
1506
1588
  return !!provider.readFile;
1507
1589
  };
1508
1590
  var readFile_default = {
1509
- ...toolInfo6,
1510
- handler: handler6,
1511
- isAvailable: isAvailable6
1591
+ ...toolInfo7,
1592
+ handler: handler7,
1593
+ isAvailable: isAvailable7
1512
1594
  };
1513
1595
 
1514
1596
  // src/tools/replaceInFile.ts
1515
- var toolInfo7 = {
1597
+ var toolInfo8 = {
1516
1598
  name: "replace_in_file",
1517
1599
  description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.",
1518
1600
  parameters: [
@@ -1664,7 +1746,7 @@ function oldFeature() {
1664
1746
  ],
1665
1747
  permissionLevel: 2 /* Write */
1666
1748
  };
1667
- var handler7 = async (provider, args) => {
1749
+ var handler8 = async (provider, args) => {
1668
1750
  if (!provider.readFile || !provider.writeFile) {
1669
1751
  return {
1670
1752
  type: "Error" /* Error */,
@@ -1687,17 +1769,17 @@ var handler7 = async (provider, args) => {
1687
1769
  message: `<replace_in_file_path>${path}</replace_in_file_path>`
1688
1770
  };
1689
1771
  };
1690
- var isAvailable7 = (provider) => {
1772
+ var isAvailable8 = (provider) => {
1691
1773
  return !!provider.readFile && !!provider.writeFile;
1692
1774
  };
1693
1775
  var replaceInFile_default = {
1694
- ...toolInfo7,
1695
- handler: handler7,
1696
- isAvailable: isAvailable7
1776
+ ...toolInfo8,
1777
+ handler: handler8,
1778
+ isAvailable: isAvailable8
1697
1779
  };
1698
1780
 
1699
1781
  // src/tools/searchFiles.ts
1700
- var toolInfo8 = {
1782
+ var toolInfo9 = {
1701
1783
  name: "search_files",
1702
1784
  description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
1703
1785
  parameters: [
@@ -1741,7 +1823,7 @@ var toolInfo8 = {
1741
1823
  ],
1742
1824
  permissionLevel: 1 /* Read */
1743
1825
  };
1744
- var handler8 = async (provider, args) => {
1826
+ var handler9 = async (provider, args) => {
1745
1827
  if (!provider.searchFiles) {
1746
1828
  return {
1747
1829
  type: "Error" /* Error */,
@@ -1763,19 +1845,70 @@ ${files.join("\n")}
1763
1845
  `
1764
1846
  };
1765
1847
  };
1766
- var isAvailable8 = (provider) => {
1848
+ var isAvailable9 = (provider) => {
1767
1849
  return !!provider.searchFiles;
1768
1850
  };
1769
1851
  var searchFiles_default = {
1770
- ...toolInfo8,
1771
- handler: handler8,
1772
- isAvailable: isAvailable8
1852
+ ...toolInfo9,
1853
+ handler: handler9,
1854
+ isAvailable: isAvailable9
1773
1855
  };
1774
1856
 
1775
1857
  // src/tools/updateKnowledge.ts
1776
- import { join } from "node:path";
1777
1858
  import YAML from "yaml";
1778
- var toolInfo9 = {
1859
+
1860
+ // src/path.ts
1861
+ function dirname(path) {
1862
+ if (path.length === 0) return ".";
1863
+ const isRooted = path[0] === "/";
1864
+ let end = path.length - 1;
1865
+ while (end > 0 && path[end] === "/") end--;
1866
+ const idx = path.lastIndexOf("/", end);
1867
+ if (idx < 0) {
1868
+ return isRooted ? "/" : ".";
1869
+ }
1870
+ if (isRooted && idx === 0) {
1871
+ return "/";
1872
+ }
1873
+ return path.slice(0, idx);
1874
+ }
1875
+ function normalize(path) {
1876
+ const isAbsolute = path.startsWith("/");
1877
+ const segments = path.split("/").filter(Boolean);
1878
+ const stack = [];
1879
+ for (const seg of segments) {
1880
+ if (seg === ".") continue;
1881
+ if (seg === "..") {
1882
+ if (stack.length && stack[stack.length - 1] !== "..") {
1883
+ stack.pop();
1884
+ } else if (!isAbsolute) {
1885
+ stack.push("..");
1886
+ }
1887
+ } else {
1888
+ stack.push(seg);
1889
+ }
1890
+ }
1891
+ let result = stack.join("/");
1892
+ if (!result && !isAbsolute) return ".";
1893
+ if (result && path.endsWith("/")) result += "/";
1894
+ return (isAbsolute ? "/" : "") + result;
1895
+ }
1896
+ function join(...parts) {
1897
+ if (parts.length === 0) return ".";
1898
+ let combined = "";
1899
+ for (const p of parts) {
1900
+ if (typeof p !== "string") {
1901
+ throw new TypeError("Arguments to join must be strings");
1902
+ }
1903
+ if (p) {
1904
+ combined = combined ? `${combined}/${p}` : p;
1905
+ }
1906
+ }
1907
+ return normalize(combined);
1908
+ }
1909
+
1910
+ // src/tools/updateKnowledge.ts
1911
+ var toolInfo10 = {
1779
1912
  name: "update_knowledge",
1780
1913
  description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.",
1781
1914
  parameters: [
@@ -1949,7 +2082,7 @@ function deepMerge(target, source) {
1949
2082
  }
1950
2083
  return output;
1951
2084
  }
1952
- var handler9 = async (provider, args) => {
2085
+ var handler10 = async (provider, args) => {
1953
2086
  if (!provider.readFile || !provider.writeFile) {
1954
2087
  return {
1955
2088
  type: "Error" /* Error */,
@@ -2021,17 +2154,17 @@ var handler9 = async (provider, args) => {
2021
2154
  };
2022
2155
  }
2023
2156
  };
2024
- var isAvailable9 = (provider) => {
2157
+ var isAvailable10 = (provider) => {
2025
2158
  return !!provider.readFile && !!provider.writeFile;
2026
2159
  };
2027
2160
  var updateKnowledge_default = {
2028
- ...toolInfo9,
2029
- handler: handler9,
2030
- isAvailable: isAvailable9
2161
+ ...toolInfo10,
2162
+ handler: handler10,
2163
+ isAvailable: isAvailable10
2031
2164
  };
2032
2165
 
2033
2166
  // src/tools/writeToFile.ts
2034
- var toolInfo10 = {
2167
+ var toolInfo11 = {
2035
2168
  name: "write_to_file",
2036
2169
  description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;` and `&gt;`.",
2037
2170
  parameters: [
@@ -2076,7 +2209,7 @@ export default App;
2076
2209
  ],
2077
2210
  permissionLevel: 2 /* Write */
2078
2211
  };
2079
- var handler10 = async (provider, args) => {
2212
+ var handler11 = async (provider, args) => {
2080
2213
  if (!provider.writeFile) {
2081
2214
  return {
2082
2215
  type: "Error" /* Error */,
@@ -2091,17 +2224,17 @@ var handler10 = async (provider, args) => {
2091
2224
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
2092
2225
  };
2093
2226
  };
2094
- var isAvailable10 = (provider) => {
2227
+ var isAvailable11 = (provider) => {
2095
2228
  return !!provider.writeFile;
2096
2229
  };
2097
2230
  var writeToFile_default = {
2098
- ...toolInfo10,
2099
- handler: handler10,
2100
- isAvailable: isAvailable10
2231
+ ...toolInfo11,
2232
+ handler: handler11,
2233
+ isAvailable: isAvailable11
2101
2234
  };
2102
2235
 
2103
2236
  // src/tools/handOver.ts
2104
- var toolInfo11 = {
2237
+ var toolInfo12 = {
2105
2238
  name: "hand_over",
2106
2239
  description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
2107
2240
  parameters: [
@@ -2155,7 +2288,7 @@ var toolInfo11 = {
2155
2288
  ],
2156
2289
  permissionLevel: 0 /* None */
2157
2290
  };
2158
- var handler11 = async (_provider, args) => {
2291
+ var handler12 = async (_provider, args) => {
2159
2292
  const agentName = getString(args, "agent_name");
2160
2293
  const task = getString(args, "task");
2161
2294
  const context = getString(args, "context", void 0);
@@ -2168,17 +2301,17 @@ var handler11 = async (_provider, args) => {
2168
2301
  files
2169
2302
  };
2170
2303
  };
2171
- var isAvailable11 = (_provider) => {
2304
+ var isAvailable12 = (_provider) => {
2172
2305
  return true;
2173
2306
  };
2174
2307
  var handOver_default = {
2175
- ...toolInfo11,
2176
- handler: handler11,
2177
- isAvailable: isAvailable11
2308
+ ...toolInfo12,
2309
+ handler: handler12,
2310
+ isAvailable: isAvailable12
2178
2311
  };
2179
2312
 
2180
2313
  // src/tools/removeFile.ts
2181
- var toolInfo12 = {
2314
+ var toolInfo13 = {
2182
2315
  name: "remove_file",
2183
2316
  description: "Request to remove a file at the specified path.",
2184
2317
  parameters: [
@@ -2202,7 +2335,7 @@ var toolInfo12 = {
2202
2335
  ],
2203
2336
  permissionLevel: 2 /* Write */
2204
2337
  };
2205
- var handler12 = async (provider, args) => {
2338
+ var handler13 = async (provider, args) => {
2206
2339
  if (!provider.removeFile) {
2207
2340
  return {
2208
2341
  type: "Error" /* Error */,
@@ -2216,17 +2349,17 @@ var handler12 = async (provider, args) => {
2216
2349
  message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
2217
2350
  };
2218
2351
  };
2219
- var isAvailable12 = (provider) => {
2352
+ var isAvailable13 = (provider) => {
2220
2353
  return !!provider.removeFile;
2221
2354
  };
2222
2355
  var removeFile_default = {
2223
- ...toolInfo12,
2224
- handler: handler12,
2225
- isAvailable: isAvailable12
2356
+ ...toolInfo13,
2357
+ handler: handler13,
2358
+ isAvailable: isAvailable13
2226
2359
  };
2227
2360
 
2228
2361
  // src/tools/renameFile.ts
2229
- var toolInfo13 = {
2362
+ var toolInfo14 = {
2230
2363
  name: "rename_file",
2231
2364
  description: "Request to rename a file from source path to target path.",
2232
2365
  parameters: [
@@ -2260,7 +2393,7 @@ var toolInfo13 = {
2260
2393
  ],
2261
2394
  permissionLevel: 2 /* Write */
2262
2395
  };
2263
- var handler13 = async (provider, args) => {
2396
+ var handler14 = async (provider, args) => {
2264
2397
  if (!provider.renameFile) {
2265
2398
  return {
2266
2399
  type: "Error" /* Error */,
@@ -2275,13 +2408,13 @@ var handler13 = async (provider, args) => {
2275
2408
  message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
2276
2409
  };
2277
2410
  };
2278
- var isAvailable13 = (provider) => {
2411
+ var isAvailable14 = (provider) => {
2279
2412
  return !!provider.renameFile;
2280
2413
  };
2281
2414
  var renameFile_default = {
2282
- ...toolInfo13,
2283
- handler: handler13,
2284
- isAvailable: isAvailable13
2415
+ ...toolInfo14,
2416
+ handler: handler14,
2417
+ isAvailable: isAvailable14
2285
2418
  };
2286
2419
 
2287
2420
  // src/getAvailableTools.ts
@@ -2633,7 +2766,13 @@ ${joined}`;
2633
2766
  };
2634
2767
  var responsePrompts = {
2635
2768
  errorInvokeTool: (tool, error) => `An error occurred while invoking the tool "${tool}": ${error}`,
2636
- requireUseTool: "Error: You MUST use a tool before proceeding using XCM tags. e.g. <tool_tool_name>tool_name</tool_tool_name>",
2769
+ requireUseTool: `Error: No tool use detected. You MUST use a tool before proceeding.
2770
+ e.g. <tool_tool_name>tool_name</tool_tool_name>
2771
+
2772
+ Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
2773
+ Avoid unnecessary text or symbols before or after the tool use.
2774
+ Avoid unnecessary escape characters or special characters.
2775
+ `,
2637
2776
  toolResults: (tool, result) => `<tool_response>
2638
2777
  <tool_name>${tool}</tool_name>
2639
2778
  <tool_result>
@@ -2892,8 +3031,8 @@ ${instance.prompt}`;
2892
3031
  }
2893
3032
  async #invokeTool(name, args) {
2894
3033
  try {
2895
- const handler14 = this.handlers[name]?.handler;
2896
- if (!handler14) {
3034
+ const handler15 = this.handlers[name]?.handler;
3035
+ if (!handler15) {
2897
3036
  return {
2898
3037
  type: "Error" /* Error */,
2899
3038
  message: responsePrompts.errorInvokeTool(name, "Tool not found"),
@@ -2912,7 +3051,7 @@ ${instance.prompt}`;
2912
3051
  if (resp) {
2913
3052
  return resp;
2914
3053
  }
2915
- return await handler14(this.config.provider, args);
3054
+ return await handler15(this.config.provider, args);
2916
3055
  } catch (error) {
2917
3056
  return {
2918
3057
  type: "Error" /* Error */,
@@ -3545,9 +3684,6 @@ var MultiAgent = class {
3545
3684
  }
3546
3685
  };
3547
3686
 
3548
- // src/Agent/policies/KnowledgeManagement.ts
3549
- import { dirname, join as join2 } from "node:path";
3550
-
3551
3687
  // src/config.ts
3552
3688
  import { z } from "zod";
3553
3689
  var providerModelSchema = z.object({
@@ -3711,7 +3847,7 @@ var KnowledgeManagementPolicy = (tools) => {
3711
3847
  if (path === ".") {
3712
3848
  continue;
3713
3849
  }
3714
- const fullpath = join2(path, "knowledge.ai.yml");
3850
+ const fullpath = join(path, "knowledge.ai.yml");
3715
3851
  if (!readFiles.has(fullpath)) {
3716
3852
  allFullPaths.push(fullpath);
3717
3853
  readFiles.add(fullpath);
@@ -4242,6 +4378,7 @@ export {
4242
4378
  executeAgentTool,
4243
4379
  executeCommand_default as executeCommand,
4244
4380
  executeTool,
4381
+ fetchUrl_default as fetchUrl,
4245
4382
  generateGitCommitMessage,
4246
4383
  generateGithubPullRequestDetails,
4247
4384
  generateProjectConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.8.21",
3
+ "version": "0.8.23",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",