@polka-codes/core 0.8.9 → 0.8.11

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.
@@ -80,6 +80,7 @@ declare type AgentPolicyInstance = {
80
80
  prompt?: string;
81
81
  updateResponse?: (response: AssistantMessageContent[]) => Promise<AssistantMessageContent[]>;
82
82
  onBeforeInvokeTool?: (name: string, args: Record<string, string>) => Promise<ToolResponse | undefined>;
83
+ onBeforeRequest?: (agent: AgentBase) => Promise<void>;
83
84
  };
84
85
  export { AgentPolicyInstance }
85
86
  export { AgentPolicyInstance as AgentPolicyInstance_alias_1 }
@@ -165,16 +166,15 @@ export declare namespace allTools {
165
166
  _default_2 as attemptCompletion,
166
167
  _default_3 as delegate,
167
168
  _default_4 as executeCommand,
168
- _default_5 as listCodeDefinitionNames,
169
- _default_6 as listFiles,
170
- _default_7 as readFile,
171
- _default_8 as replaceInFile,
172
- _default_9 as searchFiles,
173
- _default_10 as updateKnowledge,
174
- _default_11 as writeToFile,
175
- _default_12 as handOver,
176
- _default_13 as removeFile,
177
- _default_14 as renameFile
169
+ _default_5 as listFiles,
170
+ _default_6 as readFile,
171
+ _default_7 as replaceInFile,
172
+ _default_8 as searchFiles,
173
+ _default_9 as updateKnowledge,
174
+ _default_10 as writeToFile,
175
+ _default_11 as handOver,
176
+ _default_12 as removeFile,
177
+ _default_13 as renameFile
178
178
  }
179
179
  }
180
180
 
@@ -902,136 +902,6 @@ export { _default as askFollowupQuestion_alias_2 }
902
902
  export { _default as default_alias_4 }
903
903
 
904
904
  declare const _default_10: {
905
- handler: ToolHandler<{
906
- readonly name: "update_knowledge";
907
- 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.";
908
- readonly parameters: [{
909
- readonly name: "path";
910
- readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
911
- readonly required: true;
912
- readonly usageValue: "Directory path here";
913
- }, {
914
- readonly name: "knowledge";
915
- readonly description: "YAML content to merge into the knowledge file";
916
- readonly required: true;
917
- readonly usageValue: "YAML content with knowledge to update";
918
- }];
919
- readonly examples: [{
920
- readonly description: "Add a new file entry";
921
- readonly parameters: [{
922
- readonly name: "path";
923
- readonly value: "src/utils";
924
- }, {
925
- readonly name: "knowledge";
926
- 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\"";
927
- }];
928
- }, {
929
- readonly description: "Update an existing file description";
930
- readonly parameters: [{
931
- readonly name: "path";
932
- readonly value: "src/utils";
933
- }, {
934
- readonly name: "knowledge";
935
- readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
936
- }];
937
- }, {
938
- readonly description: "Add a new rule";
939
- readonly parameters: [{
940
- readonly name: "path";
941
- readonly value: "src";
942
- }, {
943
- readonly name: "knowledge";
944
- readonly value: "rules:\n 10: \"New rule to follow\"";
945
- }];
946
- }, {
947
- readonly description: "Remove a rule";
948
- readonly parameters: [{
949
- readonly name: "path";
950
- readonly value: "src";
951
- }, {
952
- readonly name: "knowledge";
953
- readonly value: "rules:\n 5: null";
954
- }];
955
- }, {
956
- readonly description: "Update nested properties using dot notation";
957
- readonly parameters: [{
958
- readonly name: "path";
959
- readonly value: "src/components";
960
- }, {
961
- readonly name: "knowledge";
962
- readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
963
- }];
964
- }];
965
- readonly permissionLevel: PermissionLevel.Write;
966
- }, FilesystemProvider>;
967
- isAvailable: (provider: FilesystemProvider) => boolean;
968
- name: "update_knowledge";
969
- 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.";
970
- parameters: [{
971
- readonly name: "path";
972
- readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
973
- readonly required: true;
974
- readonly usageValue: "Directory path here";
975
- }, {
976
- readonly name: "knowledge";
977
- readonly description: "YAML content to merge into the knowledge file";
978
- readonly required: true;
979
- readonly usageValue: "YAML content with knowledge to update";
980
- }];
981
- examples: [{
982
- readonly description: "Add a new file entry";
983
- readonly parameters: [{
984
- readonly name: "path";
985
- readonly value: "src/utils";
986
- }, {
987
- readonly name: "knowledge";
988
- 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\"";
989
- }];
990
- }, {
991
- readonly description: "Update an existing file description";
992
- readonly parameters: [{
993
- readonly name: "path";
994
- readonly value: "src/utils";
995
- }, {
996
- readonly name: "knowledge";
997
- readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
998
- }];
999
- }, {
1000
- readonly description: "Add a new rule";
1001
- readonly parameters: [{
1002
- readonly name: "path";
1003
- readonly value: "src";
1004
- }, {
1005
- readonly name: "knowledge";
1006
- readonly value: "rules:\n 10: \"New rule to follow\"";
1007
- }];
1008
- }, {
1009
- readonly description: "Remove a rule";
1010
- readonly parameters: [{
1011
- readonly name: "path";
1012
- readonly value: "src";
1013
- }, {
1014
- readonly name: "knowledge";
1015
- readonly value: "rules:\n 5: null";
1016
- }];
1017
- }, {
1018
- readonly description: "Update nested properties using dot notation";
1019
- readonly parameters: [{
1020
- readonly name: "path";
1021
- readonly value: "src/components";
1022
- }, {
1023
- readonly name: "knowledge";
1024
- readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1025
- }];
1026
- }];
1027
- permissionLevel: PermissionLevel.Write;
1028
- };
1029
- export { _default_10 as default_alias_16 }
1030
- export { _default_10 as updateKnowledge }
1031
- export { _default_10 as updateKnowledge_alias_1 }
1032
- export { _default_10 as updateKnowledge_alias_2 }
1033
-
1034
- declare const _default_11: {
1035
905
  handler: ToolHandler<{
1036
906
  readonly name: "write_to_file";
1037
907
  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;`.";
@@ -1084,12 +954,12 @@ declare const _default_11: {
1084
954
  }];
1085
955
  permissionLevel: PermissionLevel.Write;
1086
956
  };
1087
- export { _default_11 as default_alias_17 }
1088
- export { _default_11 as writeToFile }
1089
- export { _default_11 as writeToFile_alias_1 }
1090
- export { _default_11 as writeToFile_alias_2 }
957
+ export { _default_10 as default_alias_16 }
958
+ export { _default_10 as writeToFile }
959
+ export { _default_10 as writeToFile_alias_1 }
960
+ export { _default_10 as writeToFile_alias_2 }
1091
961
 
1092
- declare const _default_12: {
962
+ declare const _default_11: {
1093
963
  handler: ToolHandler<{
1094
964
  readonly name: "hand_over";
1095
965
  readonly description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.";
@@ -1174,12 +1044,12 @@ declare const _default_12: {
1174
1044
  }];
1175
1045
  permissionLevel: PermissionLevel.None;
1176
1046
  };
1177
- export { _default_12 as default_alias_8 }
1178
- export { _default_12 as handOver }
1179
- export { _default_12 as handOver_alias_1 }
1180
- export { _default_12 as handOver_alias_2 }
1047
+ export { _default_11 as default_alias_8 }
1048
+ export { _default_11 as handOver }
1049
+ export { _default_11 as handOver_alias_1 }
1050
+ export { _default_11 as handOver_alias_2 }
1181
1051
 
1182
- declare const _default_13: {
1052
+ declare const _default_12: {
1183
1053
  handler: ToolHandler<{
1184
1054
  readonly name: "remove_file";
1185
1055
  readonly description: "Request to remove a file at the specified path.";
@@ -1216,12 +1086,12 @@ declare const _default_13: {
1216
1086
  }];
1217
1087
  permissionLevel: PermissionLevel.Write;
1218
1088
  };
1219
- export { _default_13 as default_alias_12 }
1220
- export { _default_13 as removeFile }
1221
- export { _default_13 as removeFile_alias_1 }
1222
- export { _default_13 as removeFile_alias_2 }
1089
+ export { _default_12 as default_alias_11 }
1090
+ export { _default_12 as removeFile }
1091
+ export { _default_12 as removeFile_alias_1 }
1092
+ export { _default_12 as removeFile_alias_2 }
1223
1093
 
1224
- declare const _default_14: {
1094
+ declare const _default_13: {
1225
1095
  handler: ToolHandler<{
1226
1096
  readonly name: "rename_file";
1227
1097
  readonly description: "Request to rename a file from source path to target path.";
@@ -1274,10 +1144,10 @@ declare const _default_14: {
1274
1144
  }];
1275
1145
  permissionLevel: PermissionLevel.Write;
1276
1146
  };
1277
- export { _default_14 as default_alias_13 }
1278
- export { _default_14 as renameFile }
1279
- export { _default_14 as renameFile_alias_1 }
1280
- export { _default_14 as renameFile_alias_2 }
1147
+ export { _default_13 as default_alias_12 }
1148
+ export { _default_13 as renameFile }
1149
+ export { _default_13 as renameFile_alias_1 }
1150
+ export { _default_13 as renameFile_alias_2 }
1281
1151
 
1282
1152
  declare const _default_2: {
1283
1153
  handler: ToolHandler<{
@@ -1470,48 +1340,6 @@ export { _default_4 as executeCommand_alias_1 }
1470
1340
  export { _default_4 as executeCommand_alias_2 }
1471
1341
 
1472
1342
  declare const _default_5: {
1473
- handler: ToolHandler<{
1474
- readonly name: "list_code_definition_names";
1475
- readonly description: "Request to list definition names (classes, functions, methods, etc.) used for all files in a directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.";
1476
- readonly parameters: [{
1477
- readonly name: "path";
1478
- readonly description: "The path of a code file to list top level source code definitions for.";
1479
- readonly required: true;
1480
- readonly usageValue: "Directory path here";
1481
- }];
1482
- readonly examples: [{
1483
- readonly description: "Request to list code definition names in a directory";
1484
- readonly parameters: [{
1485
- readonly name: "path";
1486
- readonly value: "src/utils";
1487
- }];
1488
- }];
1489
- readonly permissionLevel: PermissionLevel.Read;
1490
- }, FilesystemProvider>;
1491
- isAvailable: (provider: FilesystemProvider) => boolean;
1492
- name: "list_code_definition_names";
1493
- description: "Request to list definition names (classes, functions, methods, etc.) used for all files in a directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.";
1494
- parameters: [{
1495
- readonly name: "path";
1496
- readonly description: "The path of a code file to list top level source code definitions for.";
1497
- readonly required: true;
1498
- readonly usageValue: "Directory path here";
1499
- }];
1500
- examples: [{
1501
- readonly description: "Request to list code definition names in a directory";
1502
- readonly parameters: [{
1503
- readonly name: "path";
1504
- readonly value: "src/utils";
1505
- }];
1506
- }];
1507
- permissionLevel: PermissionLevel.Read;
1508
- };
1509
- export { _default_5 as default_alias_9 }
1510
- export { _default_5 as listCodeDefinitionNames }
1511
- export { _default_5 as listCodeDefinitionNames_alias_1 }
1512
- export { _default_5 as listCodeDefinitionNames_alias_2 }
1513
-
1514
- declare const _default_6: {
1515
1343
  handler: ToolHandler<{
1516
1344
  readonly name: "list_files";
1517
1345
  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.";
@@ -1574,12 +1402,12 @@ declare const _default_6: {
1574
1402
  }];
1575
1403
  permissionLevel: PermissionLevel.Read;
1576
1404
  };
1577
- export { _default_6 as default_alias_10 }
1578
- export { _default_6 as listFiles }
1579
- export { _default_6 as listFiles_alias_1 }
1580
- export { _default_6 as listFiles_alias_2 }
1405
+ export { _default_5 as default_alias_9 }
1406
+ export { _default_5 as listFiles }
1407
+ export { _default_5 as listFiles_alias_1 }
1408
+ export { _default_5 as listFiles_alias_2 }
1581
1409
 
1582
- declare const _default_7: {
1410
+ declare const _default_6: {
1583
1411
  handler: ToolHandler<{
1584
1412
  readonly name: "read_file";
1585
1413
  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.";
@@ -1628,12 +1456,12 @@ declare const _default_7: {
1628
1456
  }];
1629
1457
  permissionLevel: PermissionLevel.Read;
1630
1458
  };
1631
- export { _default_7 as default_alias_11 }
1632
- export { _default_7 as readFile }
1633
- export { _default_7 as readFile_alias_1 }
1634
- export { _default_7 as readFile_alias_2 }
1459
+ export { _default_6 as default_alias_10 }
1460
+ export { _default_6 as readFile }
1461
+ export { _default_6 as readFile_alias_1 }
1462
+ export { _default_6 as readFile_alias_2 }
1635
1463
 
1636
- declare const _default_8: {
1464
+ declare const _default_7: {
1637
1465
  handler: ToolHandler<{
1638
1466
  readonly name: "replace_in_file";
1639
1467
  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.";
@@ -1686,12 +1514,12 @@ declare const _default_8: {
1686
1514
  }];
1687
1515
  permissionLevel: PermissionLevel.Write;
1688
1516
  };
1689
- export { _default_8 as default_alias_14 }
1690
- export { _default_8 as replaceInFile }
1691
- export { _default_8 as replaceInFile_alias_1 }
1692
- export { _default_8 as replaceInFile_alias_2 }
1517
+ export { _default_7 as default_alias_13 }
1518
+ export { _default_7 as replaceInFile }
1519
+ export { _default_7 as replaceInFile_alias_1 }
1520
+ export { _default_7 as replaceInFile_alias_2 }
1693
1521
 
1694
- declare const _default_9: {
1522
+ declare const _default_8: {
1695
1523
  handler: ToolHandler<{
1696
1524
  readonly name: "search_files";
1697
1525
  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.";
@@ -1760,10 +1588,140 @@ declare const _default_9: {
1760
1588
  }];
1761
1589
  permissionLevel: PermissionLevel.Read;
1762
1590
  };
1591
+ export { _default_8 as default_alias_14 }
1592
+ export { _default_8 as searchFiles }
1593
+ export { _default_8 as searchFiles_alias_1 }
1594
+ export { _default_8 as searchFiles_alias_2 }
1595
+
1596
+ declare const _default_9: {
1597
+ handler: ToolHandler<{
1598
+ readonly name: "update_knowledge";
1599
+ 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.";
1600
+ readonly parameters: [{
1601
+ readonly name: "path";
1602
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
1603
+ readonly required: true;
1604
+ readonly usageValue: "Directory path here";
1605
+ }, {
1606
+ readonly name: "knowledge";
1607
+ readonly description: "YAML content to merge into the knowledge file";
1608
+ readonly required: true;
1609
+ readonly usageValue: "YAML content with knowledge to update";
1610
+ }];
1611
+ readonly examples: [{
1612
+ readonly description: "Add a new file entry";
1613
+ readonly parameters: [{
1614
+ readonly name: "path";
1615
+ readonly value: "src/utils";
1616
+ }, {
1617
+ readonly name: "knowledge";
1618
+ 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\"";
1619
+ }];
1620
+ }, {
1621
+ readonly description: "Update an existing file description";
1622
+ readonly parameters: [{
1623
+ readonly name: "path";
1624
+ readonly value: "src/utils";
1625
+ }, {
1626
+ readonly name: "knowledge";
1627
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
1628
+ }];
1629
+ }, {
1630
+ readonly description: "Add a new rule";
1631
+ readonly parameters: [{
1632
+ readonly name: "path";
1633
+ readonly value: "src";
1634
+ }, {
1635
+ readonly name: "knowledge";
1636
+ readonly value: "rules:\n 10: \"New rule to follow\"";
1637
+ }];
1638
+ }, {
1639
+ readonly description: "Remove a rule";
1640
+ readonly parameters: [{
1641
+ readonly name: "path";
1642
+ readonly value: "src";
1643
+ }, {
1644
+ readonly name: "knowledge";
1645
+ readonly value: "rules:\n 5: null";
1646
+ }];
1647
+ }, {
1648
+ readonly description: "Update nested properties using dot notation";
1649
+ readonly parameters: [{
1650
+ readonly name: "path";
1651
+ readonly value: "src/components";
1652
+ }, {
1653
+ readonly name: "knowledge";
1654
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1655
+ }];
1656
+ }];
1657
+ readonly permissionLevel: PermissionLevel.Write;
1658
+ }, FilesystemProvider>;
1659
+ isAvailable: (provider: FilesystemProvider) => boolean;
1660
+ name: "update_knowledge";
1661
+ 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.";
1662
+ parameters: [{
1663
+ readonly name: "path";
1664
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
1665
+ readonly required: true;
1666
+ readonly usageValue: "Directory path here";
1667
+ }, {
1668
+ readonly name: "knowledge";
1669
+ readonly description: "YAML content to merge into the knowledge file";
1670
+ readonly required: true;
1671
+ readonly usageValue: "YAML content with knowledge to update";
1672
+ }];
1673
+ examples: [{
1674
+ readonly description: "Add a new file entry";
1675
+ readonly parameters: [{
1676
+ readonly name: "path";
1677
+ readonly value: "src/utils";
1678
+ }, {
1679
+ readonly name: "knowledge";
1680
+ 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\"";
1681
+ }];
1682
+ }, {
1683
+ readonly description: "Update an existing file description";
1684
+ readonly parameters: [{
1685
+ readonly name: "path";
1686
+ readonly value: "src/utils";
1687
+ }, {
1688
+ readonly name: "knowledge";
1689
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
1690
+ }];
1691
+ }, {
1692
+ readonly description: "Add a new rule";
1693
+ readonly parameters: [{
1694
+ readonly name: "path";
1695
+ readonly value: "src";
1696
+ }, {
1697
+ readonly name: "knowledge";
1698
+ readonly value: "rules:\n 10: \"New rule to follow\"";
1699
+ }];
1700
+ }, {
1701
+ readonly description: "Remove a rule";
1702
+ readonly parameters: [{
1703
+ readonly name: "path";
1704
+ readonly value: "src";
1705
+ }, {
1706
+ readonly name: "knowledge";
1707
+ readonly value: "rules:\n 5: null";
1708
+ }];
1709
+ }, {
1710
+ readonly description: "Update nested properties using dot notation";
1711
+ readonly parameters: [{
1712
+ readonly name: "path";
1713
+ readonly value: "src/components";
1714
+ }, {
1715
+ readonly name: "knowledge";
1716
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
1717
+ }];
1718
+ }];
1719
+ permissionLevel: PermissionLevel.Write;
1720
+ };
1763
1721
  export { _default_9 as default_alias_15 }
1764
- export { _default_9 as searchFiles }
1765
- export { _default_9 as searchFiles_alias_1 }
1766
- export { _default_9 as searchFiles_alias_2 }
1722
+ export { _default_9 as updateKnowledge }
1723
+ export { _default_9 as updateKnowledge_alias_1 }
1724
+ export { _default_9 as updateKnowledge_alias_2 }
1767
1725
 
1768
1726
  /**
1769
1727
  * AI tool for creating new projects based on user specifications.
@@ -1851,7 +1809,6 @@ declare type FilesystemProvider = {
1851
1809
  renameFile?: (sourcePath: string, targetPath: string) => Promise<void>;
1852
1810
  listFiles?: (path: string, recursive: boolean, maxCount: number) => Promise<[string[], boolean]>;
1853
1811
  searchFiles?: (path: string, regex: string, filePattern: string) => Promise<string[]>;
1854
- listCodeDefinitionNames?: (path: string) => Promise<string>;
1855
1812
  };
1856
1813
  export { FilesystemProvider }
1857
1814
  export { FilesystemProvider as FilesystemProvider_alias_1 }
@@ -1985,8 +1942,6 @@ export declare const handler_alias_11: ToolHandler<typeof toolInfo_alias_11, Fil
1985
1942
 
1986
1943
  export declare const handler_alias_12: ToolHandler<typeof toolInfo_alias_12, FilesystemProvider>;
1987
1944
 
1988
- export declare const handler_alias_13: ToolHandler<typeof toolInfo_alias_13, FilesystemProvider>;
1989
-
1990
1945
  export declare const handler_alias_2: ToolHandler<typeof toolInfo_alias_2, any>;
1991
1946
 
1992
1947
  export declare const handler_alias_3: ToolHandler<typeof toolInfo_alias_3, CommandProvider>;
@@ -2028,8 +1983,6 @@ export declare const isAvailable_alias_11: (provider: FilesystemProvider) => boo
2028
1983
 
2029
1984
  export declare const isAvailable_alias_12: (provider: FilesystemProvider) => boolean;
2030
1985
 
2031
- export declare const isAvailable_alias_13: (provider: FilesystemProvider) => boolean;
2032
-
2033
1986
  export declare const isAvailable_alias_2: (_provider: any) => boolean;
2034
1987
 
2035
1988
  export declare const isAvailable_alias_3: (provider: CommandProvider) => boolean;
@@ -2048,7 +2001,131 @@ export declare const isAvailable_alias_9: (provider: FilesystemProvider) => bool
2048
2001
 
2049
2002
  declare const KnowledgeManagementPolicy: (tools: Parameters<AgentPolicy>[0]) => {
2050
2003
  name: Policies;
2051
- tools: FullToolInfo[];
2004
+ tools: {
2005
+ handler: ToolHandler< {
2006
+ readonly name: "update_knowledge";
2007
+ 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.";
2008
+ readonly parameters: [{
2009
+ readonly name: "path";
2010
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
2011
+ readonly required: true;
2012
+ readonly usageValue: "Directory path here";
2013
+ }, {
2014
+ readonly name: "knowledge";
2015
+ readonly description: "YAML content to merge into the knowledge file";
2016
+ readonly required: true;
2017
+ readonly usageValue: "YAML content with knowledge to update";
2018
+ }];
2019
+ readonly examples: [{
2020
+ readonly description: "Add a new file entry";
2021
+ readonly parameters: [{
2022
+ readonly name: "path";
2023
+ readonly value: "src/utils";
2024
+ }, {
2025
+ readonly name: "knowledge";
2026
+ 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\"";
2027
+ }];
2028
+ }, {
2029
+ readonly description: "Update an existing file description";
2030
+ readonly parameters: [{
2031
+ readonly name: "path";
2032
+ readonly value: "src/utils";
2033
+ }, {
2034
+ readonly name: "knowledge";
2035
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
2036
+ }];
2037
+ }, {
2038
+ readonly description: "Add a new rule";
2039
+ readonly parameters: [{
2040
+ readonly name: "path";
2041
+ readonly value: "src";
2042
+ }, {
2043
+ readonly name: "knowledge";
2044
+ readonly value: "rules:\n 10: \"New rule to follow\"";
2045
+ }];
2046
+ }, {
2047
+ readonly description: "Remove a rule";
2048
+ readonly parameters: [{
2049
+ readonly name: "path";
2050
+ readonly value: "src";
2051
+ }, {
2052
+ readonly name: "knowledge";
2053
+ readonly value: "rules:\n 5: null";
2054
+ }];
2055
+ }, {
2056
+ readonly description: "Update nested properties using dot notation";
2057
+ readonly parameters: [{
2058
+ readonly name: "path";
2059
+ readonly value: "src/components";
2060
+ }, {
2061
+ readonly name: "knowledge";
2062
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
2063
+ }];
2064
+ }];
2065
+ readonly permissionLevel: import("../..").PermissionLevel.Write;
2066
+ }, FilesystemProvider>;
2067
+ isAvailable: (provider: FilesystemProvider) => boolean;
2068
+ name: "update_knowledge";
2069
+ 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.";
2070
+ parameters: [{
2071
+ readonly name: "path";
2072
+ readonly description: "Directory containing (or where to create) the knowledge.ai.yml file";
2073
+ readonly required: true;
2074
+ readonly usageValue: "Directory path here";
2075
+ }, {
2076
+ readonly name: "knowledge";
2077
+ readonly description: "YAML content to merge into the knowledge file";
2078
+ readonly required: true;
2079
+ readonly usageValue: "YAML content with knowledge to update";
2080
+ }];
2081
+ examples: [{
2082
+ readonly description: "Add a new file entry";
2083
+ readonly parameters: [{
2084
+ readonly name: "path";
2085
+ readonly value: "src/utils";
2086
+ }, {
2087
+ readonly name: "knowledge";
2088
+ 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\"";
2089
+ }];
2090
+ }, {
2091
+ readonly description: "Update an existing file description";
2092
+ readonly parameters: [{
2093
+ readonly name: "path";
2094
+ readonly value: "src/utils";
2095
+ }, {
2096
+ readonly name: "knowledge";
2097
+ readonly value: "files:\n \"existingFile.ts\":\n description: \"Updated description for the file\"";
2098
+ }];
2099
+ }, {
2100
+ readonly description: "Add a new rule";
2101
+ readonly parameters: [{
2102
+ readonly name: "path";
2103
+ readonly value: "src";
2104
+ }, {
2105
+ readonly name: "knowledge";
2106
+ readonly value: "rules:\n 10: \"New rule to follow\"";
2107
+ }];
2108
+ }, {
2109
+ readonly description: "Remove a rule";
2110
+ readonly parameters: [{
2111
+ readonly name: "path";
2112
+ readonly value: "src";
2113
+ }, {
2114
+ readonly name: "knowledge";
2115
+ readonly value: "rules:\n 5: null";
2116
+ }];
2117
+ }, {
2118
+ readonly description: "Update nested properties using dot notation";
2119
+ readonly parameters: [{
2120
+ readonly name: "path";
2121
+ readonly value: "src/components";
2122
+ }, {
2123
+ readonly name: "knowledge";
2124
+ readonly value: "files.Button.tsx.api.functions.1.description: \"Updated function description\"";
2125
+ }];
2126
+ }];
2127
+ permissionLevel: import("../..").PermissionLevel.Write;
2128
+ }[];
2052
2129
  prompt: string | undefined;
2053
2130
  getKnowledgeFilePaths(inputFiles: string[]): Promise<string[]>;
2054
2131
  updateResponse(response: AssistantMessageContent[]): Promise<(TextContent | ToolUse | {
@@ -2089,7 +2166,6 @@ declare class MockProvider implements ToolProvider {
2089
2166
  renameFile(sourcePath: string, targetPath: string): Promise<void>;
2090
2167
  listFiles(path: string, recursive: boolean, maxCount: number): Promise<[string[], boolean]>;
2091
2168
  searchFiles(path: string, regex: string, filePattern: string): Promise<string[]>;
2092
- listCodeDefinitionNames(path: string): Promise<string>;
2093
2169
  executeCommand(command: string, needApprove: boolean): Promise<{
2094
2170
  stdout: string;
2095
2171
  stderr: string;
@@ -2663,33 +2739,6 @@ export declare const toolInfo_alias_1: {
2663
2739
  };
2664
2740
 
2665
2741
  export declare const toolInfo_alias_10: {
2666
- readonly name: "replace_in_file";
2667
- 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.";
2668
- readonly parameters: [{
2669
- readonly name: "path";
2670
- readonly description: "The path of the file to modify";
2671
- readonly required: true;
2672
- readonly usageValue: "File path here";
2673
- }, {
2674
- readonly name: "diff";
2675
- 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 ```\n Critical rules:\n 1. 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.\n 2. 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.\n 3. 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.\n 4. 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";
2676
- readonly required: true;
2677
- readonly usageValue: "Search and replace blocks here";
2678
- }];
2679
- readonly examples: [{
2680
- readonly description: "Request to replace sections of content in a file";
2681
- readonly parameters: [{
2682
- readonly name: "path";
2683
- readonly value: "src/main.js";
2684
- }, {
2685
- readonly name: "diff";
2686
- 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";
2687
- }];
2688
- }];
2689
- readonly permissionLevel: PermissionLevel.Write;
2690
- };
2691
-
2692
- export declare const toolInfo_alias_11: {
2693
2742
  readonly name: "search_files";
2694
2743
  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.";
2695
2744
  readonly parameters: [{
@@ -2724,7 +2773,7 @@ export declare const toolInfo_alias_11: {
2724
2773
  readonly permissionLevel: PermissionLevel.Read;
2725
2774
  };
2726
2775
 
2727
- export declare const toolInfo_alias_12: {
2776
+ export declare const toolInfo_alias_11: {
2728
2777
  readonly name: "update_knowledge";
2729
2778
  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.";
2730
2779
  readonly parameters: [{
@@ -2787,7 +2836,7 @@ export declare const toolInfo_alias_12: {
2787
2836
  readonly permissionLevel: PermissionLevel.Write;
2788
2837
  };
2789
2838
 
2790
- export declare const toolInfo_alias_13: {
2839
+ export declare const toolInfo_alias_12: {
2791
2840
  readonly name: "write_to_file";
2792
2841
  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;`.";
2793
2842
  readonly parameters: [{
@@ -2928,25 +2977,6 @@ export declare const toolInfo_alias_4: {
2928
2977
  };
2929
2978
 
2930
2979
  export declare const toolInfo_alias_5: {
2931
- readonly name: "list_code_definition_names";
2932
- readonly description: "Request to list definition names (classes, functions, methods, etc.) used for all files in a directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.";
2933
- readonly parameters: [{
2934
- readonly name: "path";
2935
- readonly description: "The path of a code file to list top level source code definitions for.";
2936
- readonly required: true;
2937
- readonly usageValue: "Directory path here";
2938
- }];
2939
- readonly examples: [{
2940
- readonly description: "Request to list code definition names in a directory";
2941
- readonly parameters: [{
2942
- readonly name: "path";
2943
- readonly value: "src/utils";
2944
- }];
2945
- }];
2946
- readonly permissionLevel: PermissionLevel.Read;
2947
- };
2948
-
2949
- export declare const toolInfo_alias_6: {
2950
2980
  readonly name: "list_files";
2951
2981
  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.";
2952
2982
  readonly parameters: [{
@@ -2978,7 +3008,7 @@ export declare const toolInfo_alias_6: {
2978
3008
  readonly permissionLevel: PermissionLevel.Read;
2979
3009
  };
2980
3010
 
2981
- export declare const toolInfo_alias_7: {
3011
+ export declare const toolInfo_alias_6: {
2982
3012
  readonly name: "read_file";
2983
3013
  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.";
2984
3014
  readonly parameters: [{
@@ -3003,7 +3033,7 @@ export declare const toolInfo_alias_7: {
3003
3033
  readonly permissionLevel: PermissionLevel.Read;
3004
3034
  };
3005
3035
 
3006
- export declare const toolInfo_alias_8: {
3036
+ export declare const toolInfo_alias_7: {
3007
3037
  readonly name: "remove_file";
3008
3038
  readonly description: "Request to remove a file at the specified path.";
3009
3039
  readonly parameters: [{
@@ -3022,7 +3052,7 @@ export declare const toolInfo_alias_8: {
3022
3052
  readonly permissionLevel: PermissionLevel.Write;
3023
3053
  };
3024
3054
 
3025
- export declare const toolInfo_alias_9: {
3055
+ export declare const toolInfo_alias_8: {
3026
3056
  readonly name: "rename_file";
3027
3057
  readonly description: "Request to rename a file from source path to target path.";
3028
3058
  readonly parameters: [{
@@ -3049,6 +3079,33 @@ export declare const toolInfo_alias_9: {
3049
3079
  readonly permissionLevel: PermissionLevel.Write;
3050
3080
  };
3051
3081
 
3082
+ export declare const toolInfo_alias_9: {
3083
+ readonly name: "replace_in_file";
3084
+ 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.";
3085
+ readonly parameters: [{
3086
+ readonly name: "path";
3087
+ readonly description: "The path of the file to modify";
3088
+ readonly required: true;
3089
+ readonly usageValue: "File path here";
3090
+ }, {
3091
+ readonly name: "diff";
3092
+ 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 ```\n Critical rules:\n 1. 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.\n 2. 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.\n 3. 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.\n 4. 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";
3093
+ readonly required: true;
3094
+ readonly usageValue: "Search and replace blocks here";
3095
+ }];
3096
+ readonly examples: [{
3097
+ readonly description: "Request to replace sections of content in a file";
3098
+ readonly parameters: [{
3099
+ readonly name: "path";
3100
+ readonly value: "src/main.js";
3101
+ }, {
3102
+ readonly name: "diff";
3103
+ 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";
3104
+ }];
3105
+ }];
3106
+ readonly permissionLevel: PermissionLevel.Write;
3107
+ };
3108
+
3052
3109
  declare type ToolParameter = {
3053
3110
  name: string;
3054
3111
  description: string;
package/dist/index.d.ts CHANGED
@@ -70,7 +70,6 @@ export { askFollowupQuestion } from './_tsup-dts-rollup.js';
70
70
  export { attemptCompletion } from './_tsup-dts-rollup.js';
71
71
  export { delegate } from './_tsup-dts-rollup.js';
72
72
  export { executeCommand } from './_tsup-dts-rollup.js';
73
- export { listCodeDefinitionNames } from './_tsup-dts-rollup.js';
74
73
  export { listFiles } from './_tsup-dts-rollup.js';
75
74
  export { readFile } from './_tsup-dts-rollup.js';
76
75
  export { replaceInFile } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -876,9 +876,6 @@ var MockProvider = class {
876
876
  async searchFiles(path, regex, filePattern) {
877
877
  return ["mock-file.txt"];
878
878
  }
879
- async listCodeDefinitionNames(path) {
880
- return "mockDefinition";
881
- }
882
879
  async executeCommand(command, needApprove) {
883
880
  return { stdout: "mock output", stderr: "", exitCode: 0 };
884
881
  }
@@ -898,7 +895,6 @@ __export(allTools_exports, {
898
895
  delegate: () => delegate_default,
899
896
  executeCommand: () => executeCommand_default,
900
897
  handOver: () => handOver_default,
901
- listCodeDefinitionNames: () => listCodeDefinitionNames_default,
902
898
  listFiles: () => listFiles_default,
903
899
  readFile: () => readFile_default,
904
900
  removeFile: () => removeFile_default,
@@ -1387,59 +1383,8 @@ var executeCommand_default = {
1387
1383
  isAvailable: isAvailable4
1388
1384
  };
1389
1385
 
1390
- // src/tools/listCodeDefinitionNames.ts
1391
- var toolInfo5 = {
1392
- name: "list_code_definition_names",
1393
- description: "Request to list definition names (classes, functions, methods, etc.) used for all files in a directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.",
1394
- parameters: [
1395
- {
1396
- name: "path",
1397
- description: "The path of a code file to list top level source code definitions for.",
1398
- required: true,
1399
- usageValue: "Directory path here"
1400
- }
1401
- ],
1402
- examples: [
1403
- {
1404
- description: "Request to list code definition names in a directory",
1405
- parameters: [
1406
- {
1407
- name: "path",
1408
- value: "src/utils"
1409
- }
1410
- ]
1411
- }
1412
- ],
1413
- permissionLevel: 1 /* Read */
1414
- };
1415
- var handler5 = async (provider, args) => {
1416
- if (!provider.listCodeDefinitionNames) {
1417
- return {
1418
- type: "Error" /* Error */,
1419
- message: "Not possible to list code definition names. Abort."
1420
- };
1421
- }
1422
- const path = getString(args, "path");
1423
- const result = await provider.listCodeDefinitionNames(path);
1424
- return {
1425
- type: "Reply" /* Reply */,
1426
- message: `<list_code_definition_names_path>${path}</list_code_definition_names_path>
1427
- <list_code_definition_names_result>
1428
- ${result}
1429
- </list_code_definition_names_result>`
1430
- };
1431
- };
1432
- var isAvailable5 = (provider) => {
1433
- return !!provider.listCodeDefinitionNames;
1434
- };
1435
- var listCodeDefinitionNames_default = {
1436
- ...toolInfo5,
1437
- handler: handler5,
1438
- isAvailable: isAvailable5
1439
- };
1440
-
1441
1386
  // src/tools/listFiles.ts
1442
- var toolInfo6 = {
1387
+ var toolInfo5 = {
1443
1388
  name: "list_files",
1444
1389
  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.",
1445
1390
  parameters: [
@@ -1479,7 +1424,7 @@ var toolInfo6 = {
1479
1424
  ],
1480
1425
  permissionLevel: 1 /* Read */
1481
1426
  };
1482
- var handler6 = async (provider, args) => {
1427
+ var handler5 = async (provider, args) => {
1483
1428
  if (!provider.listFiles) {
1484
1429
  return {
1485
1430
  type: "Error" /* Error */,
@@ -1499,17 +1444,17 @@ ${files.join("\n")}
1499
1444
  <list_files_truncated>${limitReached}</list_files_truncated>`
1500
1445
  };
1501
1446
  };
1502
- var isAvailable6 = (provider) => {
1447
+ var isAvailable5 = (provider) => {
1503
1448
  return !!provider.listFiles;
1504
1449
  };
1505
1450
  var listFiles_default = {
1506
- ...toolInfo6,
1507
- handler: handler6,
1508
- isAvailable: isAvailable6
1451
+ ...toolInfo5,
1452
+ handler: handler5,
1453
+ isAvailable: isAvailable5
1509
1454
  };
1510
1455
 
1511
1456
  // src/tools/readFile.ts
1512
- var toolInfo7 = {
1457
+ var toolInfo6 = {
1513
1458
  name: "read_file",
1514
1459
  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.",
1515
1460
  parameters: [
@@ -1542,7 +1487,7 @@ var toolInfo7 = {
1542
1487
  ],
1543
1488
  permissionLevel: 1 /* Read */
1544
1489
  };
1545
- var handler7 = async (provider, args) => {
1490
+ var handler6 = async (provider, args) => {
1546
1491
  if (!provider.readFile) {
1547
1492
  return {
1548
1493
  type: "Error" /* Error */,
@@ -1569,17 +1514,17 @@ var handler7 = async (provider, args) => {
1569
1514
  message: resp.join("\n")
1570
1515
  };
1571
1516
  };
1572
- var isAvailable7 = (provider) => {
1517
+ var isAvailable6 = (provider) => {
1573
1518
  return !!provider.readFile;
1574
1519
  };
1575
1520
  var readFile_default = {
1576
- ...toolInfo7,
1577
- handler: handler7,
1578
- isAvailable: isAvailable7
1521
+ ...toolInfo6,
1522
+ handler: handler6,
1523
+ isAvailable: isAvailable6
1579
1524
  };
1580
1525
 
1581
1526
  // src/tools/replaceInFile.ts
1582
- var toolInfo8 = {
1527
+ var toolInfo7 = {
1583
1528
  name: "replace_in_file",
1584
1529
  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.",
1585
1530
  parameters: [
@@ -1664,7 +1609,7 @@ return (
1664
1609
  ],
1665
1610
  permissionLevel: 2 /* Write */
1666
1611
  };
1667
- var handler8 = async (provider, args) => {
1612
+ var handler7 = async (provider, args) => {
1668
1613
  if (!provider.readFile || !provider.writeFile) {
1669
1614
  return {
1670
1615
  type: "Error" /* Error */,
@@ -1687,17 +1632,17 @@ var handler8 = async (provider, args) => {
1687
1632
  message: `<replace_in_file_path>${path}</replace_in_file_path>`
1688
1633
  };
1689
1634
  };
1690
- var isAvailable8 = (provider) => {
1635
+ var isAvailable7 = (provider) => {
1691
1636
  return !!provider.readFile && !!provider.writeFile;
1692
1637
  };
1693
1638
  var replaceInFile_default = {
1694
- ...toolInfo8,
1695
- handler: handler8,
1696
- isAvailable: isAvailable8
1639
+ ...toolInfo7,
1640
+ handler: handler7,
1641
+ isAvailable: isAvailable7
1697
1642
  };
1698
1643
 
1699
1644
  // src/tools/searchFiles.ts
1700
- var toolInfo9 = {
1645
+ var toolInfo8 = {
1701
1646
  name: "search_files",
1702
1647
  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
1648
  parameters: [
@@ -1741,7 +1686,7 @@ var toolInfo9 = {
1741
1686
  ],
1742
1687
  permissionLevel: 1 /* Read */
1743
1688
  };
1744
- var handler9 = async (provider, args) => {
1689
+ var handler8 = async (provider, args) => {
1745
1690
  if (!provider.searchFiles) {
1746
1691
  return {
1747
1692
  type: "Error" /* Error */,
@@ -1763,19 +1708,19 @@ ${files.join("\n")}
1763
1708
  `
1764
1709
  };
1765
1710
  };
1766
- var isAvailable9 = (provider) => {
1711
+ var isAvailable8 = (provider) => {
1767
1712
  return !!provider.searchFiles;
1768
1713
  };
1769
1714
  var searchFiles_default = {
1770
- ...toolInfo9,
1771
- handler: handler9,
1772
- isAvailable: isAvailable9
1715
+ ...toolInfo8,
1716
+ handler: handler8,
1717
+ isAvailable: isAvailable8
1773
1718
  };
1774
1719
 
1775
1720
  // src/tools/updateKnowledge.ts
1776
1721
  import { join } from "node:path";
1777
1722
  import YAML from "yaml";
1778
- var toolInfo10 = {
1723
+ var toolInfo9 = {
1779
1724
  name: "update_knowledge",
1780
1725
  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
1726
  parameters: [
@@ -1949,7 +1894,7 @@ function deepMerge(target, source) {
1949
1894
  }
1950
1895
  return output;
1951
1896
  }
1952
- var handler10 = async (provider, args) => {
1897
+ var handler9 = async (provider, args) => {
1953
1898
  if (!provider.readFile || !provider.writeFile) {
1954
1899
  return {
1955
1900
  type: "Error" /* Error */,
@@ -2021,17 +1966,17 @@ var handler10 = async (provider, args) => {
2021
1966
  };
2022
1967
  }
2023
1968
  };
2024
- var isAvailable10 = (provider) => {
1969
+ var isAvailable9 = (provider) => {
2025
1970
  return !!provider.readFile && !!provider.writeFile;
2026
1971
  };
2027
1972
  var updateKnowledge_default = {
2028
- ...toolInfo10,
2029
- handler: handler10,
2030
- isAvailable: isAvailable10
1973
+ ...toolInfo9,
1974
+ handler: handler9,
1975
+ isAvailable: isAvailable9
2031
1976
  };
2032
1977
 
2033
1978
  // src/tools/writeToFile.ts
2034
- var toolInfo11 = {
1979
+ var toolInfo10 = {
2035
1980
  name: "write_to_file",
2036
1981
  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
1982
  parameters: [
@@ -2076,7 +2021,7 @@ export default App;
2076
2021
  ],
2077
2022
  permissionLevel: 2 /* Write */
2078
2023
  };
2079
- var handler11 = async (provider, args) => {
2024
+ var handler10 = async (provider, args) => {
2080
2025
  if (!provider.writeFile) {
2081
2026
  return {
2082
2027
  type: "Error" /* Error */,
@@ -2091,17 +2036,17 @@ var handler11 = async (provider, args) => {
2091
2036
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
2092
2037
  };
2093
2038
  };
2094
- var isAvailable11 = (provider) => {
2039
+ var isAvailable10 = (provider) => {
2095
2040
  return !!provider.writeFile;
2096
2041
  };
2097
2042
  var writeToFile_default = {
2098
- ...toolInfo11,
2099
- handler: handler11,
2100
- isAvailable: isAvailable11
2043
+ ...toolInfo10,
2044
+ handler: handler10,
2045
+ isAvailable: isAvailable10
2101
2046
  };
2102
2047
 
2103
2048
  // src/tools/handOver.ts
2104
- var toolInfo12 = {
2049
+ var toolInfo11 = {
2105
2050
  name: "hand_over",
2106
2051
  description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
2107
2052
  parameters: [
@@ -2155,7 +2100,7 @@ var toolInfo12 = {
2155
2100
  ],
2156
2101
  permissionLevel: 0 /* None */
2157
2102
  };
2158
- var handler12 = async (_provider, args) => {
2103
+ var handler11 = async (_provider, args) => {
2159
2104
  const agentName = getString(args, "agent_name");
2160
2105
  const task = getString(args, "task");
2161
2106
  const context = getString(args, "context", void 0);
@@ -2169,17 +2114,17 @@ var handler12 = async (_provider, args) => {
2169
2114
  // originalTask will be set by AgentBase
2170
2115
  };
2171
2116
  };
2172
- var isAvailable12 = (_provider) => {
2117
+ var isAvailable11 = (_provider) => {
2173
2118
  return true;
2174
2119
  };
2175
2120
  var handOver_default = {
2176
- ...toolInfo12,
2177
- handler: handler12,
2178
- isAvailable: isAvailable12
2121
+ ...toolInfo11,
2122
+ handler: handler11,
2123
+ isAvailable: isAvailable11
2179
2124
  };
2180
2125
 
2181
2126
  // src/tools/removeFile.ts
2182
- var toolInfo13 = {
2127
+ var toolInfo12 = {
2183
2128
  name: "remove_file",
2184
2129
  description: "Request to remove a file at the specified path.",
2185
2130
  parameters: [
@@ -2203,7 +2148,7 @@ var toolInfo13 = {
2203
2148
  ],
2204
2149
  permissionLevel: 2 /* Write */
2205
2150
  };
2206
- var handler13 = async (provider, args) => {
2151
+ var handler12 = async (provider, args) => {
2207
2152
  if (!provider.removeFile) {
2208
2153
  return {
2209
2154
  type: "Error" /* Error */,
@@ -2217,17 +2162,17 @@ var handler13 = async (provider, args) => {
2217
2162
  message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
2218
2163
  };
2219
2164
  };
2220
- var isAvailable13 = (provider) => {
2165
+ var isAvailable12 = (provider) => {
2221
2166
  return !!provider.removeFile;
2222
2167
  };
2223
2168
  var removeFile_default = {
2224
- ...toolInfo13,
2225
- handler: handler13,
2226
- isAvailable: isAvailable13
2169
+ ...toolInfo12,
2170
+ handler: handler12,
2171
+ isAvailable: isAvailable12
2227
2172
  };
2228
2173
 
2229
2174
  // src/tools/renameFile.ts
2230
- var toolInfo14 = {
2175
+ var toolInfo13 = {
2231
2176
  name: "rename_file",
2232
2177
  description: "Request to rename a file from source path to target path.",
2233
2178
  parameters: [
@@ -2261,7 +2206,7 @@ var toolInfo14 = {
2261
2206
  ],
2262
2207
  permissionLevel: 2 /* Write */
2263
2208
  };
2264
- var handler14 = async (provider, args) => {
2209
+ var handler13 = async (provider, args) => {
2265
2210
  if (!provider.renameFile) {
2266
2211
  return {
2267
2212
  type: "Error" /* Error */,
@@ -2276,13 +2221,13 @@ var handler14 = async (provider, args) => {
2276
2221
  message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
2277
2222
  };
2278
2223
  };
2279
- var isAvailable14 = (provider) => {
2224
+ var isAvailable13 = (provider) => {
2280
2225
  return !!provider.renameFile;
2281
2226
  };
2282
2227
  var renameFile_default = {
2283
- ...toolInfo14,
2284
- handler: handler14,
2285
- isAvailable: isAvailable14
2228
+ ...toolInfo13,
2229
+ handler: handler13,
2230
+ isAvailable: isAvailable13
2286
2231
  };
2287
2232
 
2288
2233
  // src/getAvailableTools.ts
@@ -2764,6 +2709,11 @@ ${instance.prompt}`;
2764
2709
  role: "user",
2765
2710
  content: userMessage
2766
2711
  });
2712
+ for (const instance of this.#policies) {
2713
+ if (instance.onBeforeRequest) {
2714
+ await instance.onBeforeRequest(this);
2715
+ }
2716
+ }
2767
2717
  let currentAssistantMessage = "";
2768
2718
  const retryCount = 5;
2769
2719
  for (let i = 0; i < retryCount; i++) {
@@ -2862,7 +2812,7 @@ ${instance.prompt}`;
2862
2812
  }
2863
2813
  case "Delegate" /* Delegate */: {
2864
2814
  if (toolResponses.length > 0) {
2865
- continue;
2815
+ break outer;
2866
2816
  }
2867
2817
  const delegateResp = {
2868
2818
  ...toolResp,
@@ -2901,8 +2851,8 @@ ${instance.prompt}`;
2901
2851
  }
2902
2852
  async #invokeTool(name, args) {
2903
2853
  try {
2904
- const handler15 = this.handlers[name]?.handler;
2905
- if (!handler15) {
2854
+ const handler14 = this.handlers[name]?.handler;
2855
+ if (!handler14) {
2906
2856
  return {
2907
2857
  type: "Error" /* Error */,
2908
2858
  message: responsePrompts.errorInvokeTool(name, "Tool not found"),
@@ -2921,7 +2871,7 @@ ${instance.prompt}`;
2921
2871
  if (resp) {
2922
2872
  return resp;
2923
2873
  }
2924
- return await handler15(this.config.provider, args);
2874
+ return await handler14(this.config.provider, args);
2925
2875
  } catch (error) {
2926
2876
  return {
2927
2877
  type: "Error" /* Error */,
@@ -3698,7 +3648,7 @@ var KnowledgeManagementPolicy = (tools) => {
3698
3648
  const readFiles = /* @__PURE__ */ new Set();
3699
3649
  return {
3700
3650
  name: "knowledgemanagement" /* KnowledgeManagement */,
3701
- tools: tools[writeToFile_default.name] ? [tools[updateKnowledge_default.name]] : [],
3651
+ tools: tools[writeToFile_default.name] ? [updateKnowledge_default] : [],
3702
3652
  prompt: tools[writeToFile_default.name] || tools[updateKnowledge_default.name] ? prompt : void 0,
3703
3653
  async getKnowledgeFilePaths(inputFiles) {
3704
3654
  const paths = /* @__PURE__ */ new Set();
@@ -4194,7 +4144,6 @@ export {
4194
4144
  getString,
4195
4145
  getStringArray,
4196
4146
  handOver_default as handOver,
4197
- listCodeDefinitionNames_default as listCodeDefinitionNames,
4198
4147
  listFiles_default as listFiles,
4199
4148
  makeAgentTool,
4200
4149
  makeTool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.8.9",
3
+ "version": "0.8.11",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",