@polka-codes/core 0.8.1 → 0.8.2

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.
package/dist/index.js CHANGED
@@ -905,6 +905,7 @@ __export(allTools_exports, {
905
905
  renameFile: () => renameFile_default,
906
906
  replaceInFile: () => replaceInFile_default,
907
907
  searchFiles: () => searchFiles_default,
908
+ updateKnowledge: () => updateKnowledge_default,
908
909
  writeToFile: () => writeToFile_default
909
910
  });
910
911
 
@@ -1471,11 +1472,15 @@ var handler7 = async (provider, args) => {
1471
1472
  const resp = [];
1472
1473
  for (const path of paths) {
1473
1474
  const fileContent = await provider.readFile(path);
1474
- const isEmpty = fileContent.trim().length === 0;
1475
- if (isEmpty) {
1476
- resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
1475
+ if (!fileContent) {
1476
+ resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
1477
1477
  } else {
1478
- resp.push(`<read_file_file_conten path="${path}">${fileContent}</read_file_file_content>`);
1478
+ const isEmpty = fileContent.trim().length === 0;
1479
+ if (isEmpty) {
1480
+ resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
1481
+ } else {
1482
+ resp.push(`<read_file_file_conten path="${path}">${fileContent}</read_file_file_content>`);
1483
+ }
1479
1484
  }
1480
1485
  }
1481
1486
  return {
@@ -1588,6 +1593,12 @@ var handler8 = async (provider, args) => {
1588
1593
  const path = getString(args, "path");
1589
1594
  const diff = getString(args, "diff");
1590
1595
  const fileContent = await provider.readFile(path);
1596
+ if (fileContent == null) {
1597
+ return {
1598
+ type: "Error" /* Error */,
1599
+ message: `<error><replace_in_file_path>${path}</replace_in_file_path><error_message>File not found</error_message></error>`
1600
+ };
1601
+ }
1591
1602
  const result = await replaceInFile(fileContent, diff);
1592
1603
  await provider.writeFile(path, result);
1593
1604
  return {
@@ -1680,10 +1691,268 @@ var searchFiles_default = {
1680
1691
  isAvailable: isAvailable9
1681
1692
  };
1682
1693
 
1683
- // src/tools/writeToFile.ts
1694
+ // src/tools/updateKnowledge.ts
1695
+ import { join } from "node:path";
1696
+ import YAML from "yaml";
1684
1697
  var toolInfo10 = {
1698
+ name: "update_knowledge",
1699
+ 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.",
1700
+ parameters: [
1701
+ {
1702
+ name: "path",
1703
+ description: "Directory containing (or where to create) the knowledge.ai.yml file",
1704
+ required: true,
1705
+ usageValue: "Directory path here"
1706
+ },
1707
+ {
1708
+ name: "knowledge",
1709
+ description: "YAML content to merge into the knowledge file",
1710
+ required: true,
1711
+ usageValue: "YAML content with knowledge to update"
1712
+ }
1713
+ ],
1714
+ examples: [
1715
+ {
1716
+ description: "Add a new file entry",
1717
+ parameters: [
1718
+ { name: "path", value: "src/utils" },
1719
+ {
1720
+ name: "knowledge",
1721
+ value: `files:
1722
+ "newFile.ts":
1723
+ description: "A new utility file"
1724
+ api:
1725
+ functions:
1726
+ 1:
1727
+ name: "processData"
1728
+ params:
1729
+ 1: { name: "data", type: "object" }
1730
+ returns: "object"`
1731
+ }
1732
+ ]
1733
+ },
1734
+ {
1735
+ description: "Update an existing file description",
1736
+ parameters: [
1737
+ { name: "path", value: "src/utils" },
1738
+ {
1739
+ name: "knowledge",
1740
+ value: `files:
1741
+ "existingFile.ts":
1742
+ description: "Updated description for the file"`
1743
+ }
1744
+ ]
1745
+ },
1746
+ {
1747
+ description: "Add a new rule",
1748
+ parameters: [
1749
+ { name: "path", value: "src" },
1750
+ {
1751
+ name: "knowledge",
1752
+ value: `rules:
1753
+ 10: "New rule to follow"`
1754
+ }
1755
+ ]
1756
+ },
1757
+ {
1758
+ description: "Remove a rule",
1759
+ parameters: [
1760
+ { name: "path", value: "src" },
1761
+ {
1762
+ name: "knowledge",
1763
+ value: `rules:
1764
+ 5: null`
1765
+ }
1766
+ ]
1767
+ },
1768
+ {
1769
+ description: "Update nested properties using dot notation",
1770
+ parameters: [
1771
+ { name: "path", value: "src/components" },
1772
+ {
1773
+ name: "knowledge",
1774
+ value: `files.Button.tsx.api.functions.1.description: "Updated function description"`
1775
+ }
1776
+ ]
1777
+ }
1778
+ ],
1779
+ permissionLevel: 2 /* Write */
1780
+ };
1781
+ function getNextKey(obj) {
1782
+ if (!obj || typeof obj !== "object") return 1;
1783
+ const numericKeys = Object.keys(obj).filter((key) => !Number.isNaN(Number(key))).map((key) => Number(key));
1784
+ if (numericKeys.length === 0) return 1;
1785
+ return Math.max(...numericKeys) + 1;
1786
+ }
1787
+ function arrayToNumberedDict(arr) {
1788
+ const result = {};
1789
+ arr.forEach((item, index) => {
1790
+ result[(index + 1).toString()] = item;
1791
+ });
1792
+ return result;
1793
+ }
1794
+ function deepMerge(target, source) {
1795
+ if (source && typeof source === "object") {
1796
+ if (Array.isArray(target)) {
1797
+ target = arrayToNumberedDict(target);
1798
+ }
1799
+ if (Array.isArray(source)) {
1800
+ source = arrayToNumberedDict(source);
1801
+ }
1802
+ if (typeof target === "object" && !Array.isArray(target) && "$merge" in source) {
1803
+ const result = { ...target };
1804
+ const itemsToMerge = Array.isArray(source.$merge) ? source.$merge : [source.$merge];
1805
+ for (const item of itemsToMerge) {
1806
+ if (typeof item === "object" && item !== null && "path" in item) {
1807
+ let found = false;
1808
+ for (const key in result) {
1809
+ if (typeof result[key] === "object" && result[key] !== null && "path" in result[key] && result[key].path === item.path) {
1810
+ result[key] = deepMerge(result[key], item);
1811
+ found = true;
1812
+ break;
1813
+ }
1814
+ }
1815
+ if (!found) {
1816
+ const nextKey = getNextKey(result).toString();
1817
+ result[nextKey] = item;
1818
+ }
1819
+ } else {
1820
+ const nextKey = getNextKey(result).toString();
1821
+ result[nextKey] = item;
1822
+ }
1823
+ }
1824
+ return result;
1825
+ }
1826
+ if (typeof target === "object" && !Array.isArray(target) && "$remove" in source) {
1827
+ const result = { ...target };
1828
+ const itemsToRemove = Array.isArray(source.$remove) ? source.$remove : [source.$remove];
1829
+ for (const item of itemsToRemove) {
1830
+ if (typeof item === "string" && !Number.isNaN(Number(item))) {
1831
+ delete result[item];
1832
+ } else if (typeof item === "object" && item !== null && "path" in item) {
1833
+ for (const key in result) {
1834
+ if (typeof result[key] === "object" && result[key] !== null && "path" in result[key] && result[key].path === item.path) {
1835
+ delete result[key];
1836
+ break;
1837
+ }
1838
+ }
1839
+ } else {
1840
+ for (const key in result) {
1841
+ if (result[key] === item) {
1842
+ delete result[key];
1843
+ break;
1844
+ }
1845
+ }
1846
+ }
1847
+ }
1848
+ return result;
1849
+ }
1850
+ if (typeof target === "object" && !Array.isArray(target) && "$replace" in source) {
1851
+ const replacements = Array.isArray(source.$replace) ? source.$replace : [source.$replace];
1852
+ return arrayToNumberedDict(replacements);
1853
+ }
1854
+ }
1855
+ if (!source || typeof source !== "object") {
1856
+ return source;
1857
+ }
1858
+ if (!target || typeof target !== "object") {
1859
+ if (Array.isArray(source)) {
1860
+ return arrayToNumberedDict(source);
1861
+ }
1862
+ return { ...source };
1863
+ }
1864
+ const output = { ...target };
1865
+ for (const key in source) {
1866
+ if (key.startsWith("$")) continue;
1867
+ output[key] = deepMerge(target[key], source[key]);
1868
+ }
1869
+ return output;
1870
+ }
1871
+ var handler10 = async (provider, args) => {
1872
+ if (!provider.readFile || !provider.writeFile) {
1873
+ return {
1874
+ type: "Error" /* Error */,
1875
+ message: "File operations not available. Cannot update knowledge file."
1876
+ };
1877
+ }
1878
+ const dirPath = getString(args, "path");
1879
+ const knowledgeContent = getString(args, "knowledge");
1880
+ const filePath = join(dirPath, "knowledge.ai.yml");
1881
+ try {
1882
+ let newKnowledge;
1883
+ try {
1884
+ newKnowledge = YAML.parse(knowledgeContent);
1885
+ } catch (error) {
1886
+ return {
1887
+ type: "Error" /* Error */,
1888
+ message: `Invalid YAML content: ${error.message}`
1889
+ };
1890
+ }
1891
+ const dotNotationUpdates = {};
1892
+ const regularUpdates = {};
1893
+ for (const key in newKnowledge) {
1894
+ if (key.includes(".")) {
1895
+ dotNotationUpdates[key] = newKnowledge[key];
1896
+ } else {
1897
+ regularUpdates[key] = newKnowledge[key];
1898
+ }
1899
+ }
1900
+ const existingContent = await provider.readFile(filePath);
1901
+ let existingKnowledge = {};
1902
+ if (existingContent) {
1903
+ try {
1904
+ existingKnowledge = YAML.parse(existingContent);
1905
+ } catch (error) {
1906
+ return {
1907
+ type: "Error" /* Error */,
1908
+ message: `Error parsing existing knowledge file: ${error.message}`
1909
+ };
1910
+ }
1911
+ }
1912
+ let updatedKnowledge = existingKnowledge;
1913
+ updatedKnowledge = deepMerge(updatedKnowledge, regularUpdates);
1914
+ if (Object.keys(dotNotationUpdates).length > 0) {
1915
+ const nestedUpdates = {};
1916
+ for (const path in dotNotationUpdates) {
1917
+ const parts = path.split(".");
1918
+ let current = nestedUpdates;
1919
+ for (let i = 0; i < parts.length - 1; i++) {
1920
+ const part = parts[i];
1921
+ if (!(part in current)) {
1922
+ current[part] = {};
1923
+ }
1924
+ current = current[part];
1925
+ }
1926
+ current[parts[parts.length - 1]] = dotNotationUpdates[path];
1927
+ }
1928
+ updatedKnowledge = deepMerge(updatedKnowledge, nestedUpdates);
1929
+ }
1930
+ const updatedContent = YAML.stringify(updatedKnowledge);
1931
+ await provider.writeFile(filePath, updatedContent);
1932
+ return {
1933
+ type: "Reply" /* Reply */,
1934
+ message: `<update_knowledge_path>${filePath}</update_knowledge_path><status>Success</status>`
1935
+ };
1936
+ } catch (error) {
1937
+ return {
1938
+ type: "Error" /* Error */,
1939
+ message: `Error updating knowledge file: ${error.message}`
1940
+ };
1941
+ }
1942
+ };
1943
+ var isAvailable10 = (provider) => {
1944
+ return !!provider.readFile && !!provider.writeFile;
1945
+ };
1946
+ var updateKnowledge_default = {
1947
+ ...toolInfo10,
1948
+ handler: handler10,
1949
+ isAvailable: isAvailable10
1950
+ };
1951
+
1952
+ // src/tools/writeToFile.ts
1953
+ var toolInfo11 = {
1685
1954
  name: "write_to_file",
1686
- 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.",
1955
+ 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;`.",
1687
1956
  parameters: [
1688
1957
  {
1689
1958
  name: "path",
@@ -1726,7 +1995,7 @@ export default App;
1726
1995
  ],
1727
1996
  permissionLevel: 2 /* Write */
1728
1997
  };
1729
- var handler10 = async (provider, args) => {
1998
+ var handler11 = async (provider, args) => {
1730
1999
  if (!provider.writeFile) {
1731
2000
  return {
1732
2001
  type: "Error" /* Error */,
@@ -1741,17 +2010,17 @@ var handler10 = async (provider, args) => {
1741
2010
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
1742
2011
  };
1743
2012
  };
1744
- var isAvailable10 = (provider) => {
2013
+ var isAvailable11 = (provider) => {
1745
2014
  return !!provider.writeFile;
1746
2015
  };
1747
2016
  var writeToFile_default = {
1748
- ...toolInfo10,
1749
- handler: handler10,
1750
- isAvailable: isAvailable10
2017
+ ...toolInfo11,
2018
+ handler: handler11,
2019
+ isAvailable: isAvailable11
1751
2020
  };
1752
2021
 
1753
2022
  // src/tools/handOver.ts
1754
- var toolInfo11 = {
2023
+ var toolInfo12 = {
1755
2024
  name: "hand_over",
1756
2025
  description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
1757
2026
  parameters: [
@@ -1805,7 +2074,7 @@ var toolInfo11 = {
1805
2074
  ],
1806
2075
  permissionLevel: 0 /* None */
1807
2076
  };
1808
- var handler11 = async (_provider, args) => {
2077
+ var handler12 = async (_provider, args) => {
1809
2078
  const agentName = getString(args, "agent_name");
1810
2079
  const task = getString(args, "task");
1811
2080
  const context = getString(args, "context", void 0);
@@ -1819,17 +2088,17 @@ var handler11 = async (_provider, args) => {
1819
2088
  // originalTask will be set by AgentBase
1820
2089
  };
1821
2090
  };
1822
- var isAvailable11 = (_provider) => {
2091
+ var isAvailable12 = (_provider) => {
1823
2092
  return true;
1824
2093
  };
1825
2094
  var handOver_default = {
1826
- ...toolInfo11,
1827
- handler: handler11,
1828
- isAvailable: isAvailable11
2095
+ ...toolInfo12,
2096
+ handler: handler12,
2097
+ isAvailable: isAvailable12
1829
2098
  };
1830
2099
 
1831
2100
  // src/tools/removeFile.ts
1832
- var toolInfo12 = {
2101
+ var toolInfo13 = {
1833
2102
  name: "remove_file",
1834
2103
  description: "Request to remove a file at the specified path.",
1835
2104
  parameters: [
@@ -1853,7 +2122,7 @@ var toolInfo12 = {
1853
2122
  ],
1854
2123
  permissionLevel: 2 /* Write */
1855
2124
  };
1856
- var handler12 = async (provider, args) => {
2125
+ var handler13 = async (provider, args) => {
1857
2126
  if (!provider.removeFile) {
1858
2127
  return {
1859
2128
  type: "Error" /* Error */,
@@ -1867,17 +2136,17 @@ var handler12 = async (provider, args) => {
1867
2136
  message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
1868
2137
  };
1869
2138
  };
1870
- var isAvailable12 = (provider) => {
2139
+ var isAvailable13 = (provider) => {
1871
2140
  return !!provider.removeFile;
1872
2141
  };
1873
2142
  var removeFile_default = {
1874
- ...toolInfo12,
1875
- handler: handler12,
1876
- isAvailable: isAvailable12
2143
+ ...toolInfo13,
2144
+ handler: handler13,
2145
+ isAvailable: isAvailable13
1877
2146
  };
1878
2147
 
1879
2148
  // src/tools/renameFile.ts
1880
- var toolInfo13 = {
2149
+ var toolInfo14 = {
1881
2150
  name: "rename_file",
1882
2151
  description: "Request to rename a file from source path to target path.",
1883
2152
  parameters: [
@@ -1911,7 +2180,7 @@ var toolInfo13 = {
1911
2180
  ],
1912
2181
  permissionLevel: 2 /* Write */
1913
2182
  };
1914
- var handler13 = async (provider, args) => {
2183
+ var handler14 = async (provider, args) => {
1915
2184
  if (!provider.renameFile) {
1916
2185
  return {
1917
2186
  type: "Error" /* Error */,
@@ -1926,13 +2195,13 @@ var handler13 = async (provider, args) => {
1926
2195
  message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
1927
2196
  };
1928
2197
  };
1929
- var isAvailable13 = (provider) => {
2198
+ var isAvailable14 = (provider) => {
1930
2199
  return !!provider.renameFile;
1931
2200
  };
1932
2201
  var renameFile_default = {
1933
- ...toolInfo13,
1934
- handler: handler13,
1935
- isAvailable: isAvailable13
2202
+ ...toolInfo14,
2203
+ handler: handler14,
2204
+ isAvailable: isAvailable14
1936
2205
  };
1937
2206
 
1938
2207
  // src/getAvailableTools.ts
@@ -2213,6 +2482,7 @@ var AgentBase = class {
2213
2482
  handlers;
2214
2483
  #messages = [];
2215
2484
  #originalTask;
2485
+ #policies;
2216
2486
  constructor(name, ai, config) {
2217
2487
  this.ai = ai;
2218
2488
  if (config.agents && config.agents.length > 0) {
@@ -2220,12 +2490,29 @@ var AgentBase = class {
2220
2490
  config.systemPrompt += `
2221
2491
  ${agents}`;
2222
2492
  }
2223
- this.config = config;
2224
2493
  const handlers = {};
2225
2494
  for (const tool of config.tools) {
2226
2495
  handlers[tool.name] = tool;
2227
2496
  }
2497
+ const policies = [];
2498
+ for (const policy of config.policies) {
2499
+ const instance = policy(handlers);
2500
+ if (instance) {
2501
+ policies.push(instance);
2502
+ if (instance.prompt) {
2503
+ config.systemPrompt += `
2504
+ ${instance.prompt}`;
2505
+ }
2506
+ if (instance.tools) {
2507
+ for (const tool of instance.tools) {
2508
+ handlers[tool.name] = tool;
2509
+ }
2510
+ }
2511
+ }
2512
+ }
2228
2513
  this.handlers = handlers;
2514
+ this.config = config;
2515
+ this.#policies = policies;
2229
2516
  }
2230
2517
  get messages() {
2231
2518
  return this.#messages;
@@ -2236,16 +2523,16 @@ ${agents}`;
2236
2523
  async #callback(event) {
2237
2524
  await this.config.callback?.(event);
2238
2525
  }
2239
- async start(prompt5) {
2240
- this.#originalTask = prompt5;
2526
+ async start(prompt6) {
2527
+ this.#originalTask = prompt6;
2241
2528
  this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
2242
- return await this.#processLoop(prompt5);
2529
+ return await this.#processLoop(prompt6);
2243
2530
  }
2244
- async step(prompt5) {
2531
+ async step(prompt6) {
2245
2532
  if (this.#messages.length === 0) {
2246
2533
  this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
2247
2534
  }
2248
- return await this.#request(prompt5);
2535
+ return await this.#request(prompt6);
2249
2536
  }
2250
2537
  async handleStepResponse(response) {
2251
2538
  return this.#handleResponse(response);
@@ -2318,9 +2605,15 @@ ${agents}`;
2318
2605
  return ret;
2319
2606
  }
2320
2607
  async #handleResponse(response) {
2321
- const toolReponses = [];
2608
+ const toolResponses = [];
2322
2609
  let hasPause = false;
2323
- outer: for (const content of response) {
2610
+ let updatedResponse = response;
2611
+ for (const hook of this.#policies) {
2612
+ if (hook.updateResponse) {
2613
+ updatedResponse = await hook.updateResponse(updatedResponse);
2614
+ }
2615
+ }
2616
+ outer: for (const content of updatedResponse) {
2324
2617
  switch (content.type) {
2325
2618
  case "text":
2326
2619
  break;
@@ -2330,26 +2623,26 @@ ${agents}`;
2330
2623
  switch (toolResp.type) {
2331
2624
  case "Reply" /* Reply */:
2332
2625
  await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
2333
- toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
2626
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
2334
2627
  break;
2335
2628
  case "Exit" /* Exit */:
2336
- if (toolReponses.length > 0) {
2629
+ if (toolResponses.length > 0) {
2337
2630
  break outer;
2338
2631
  }
2339
2632
  return { type: "exit", reason: toolResp };
2340
2633
  case "Invalid" /* Invalid */:
2341
2634
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
2342
- toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
2635
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
2343
2636
  break outer;
2344
2637
  case "Error" /* Error */:
2345
2638
  await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
2346
- toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
2639
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
2347
2640
  break outer;
2348
2641
  case "Interrupted" /* Interrupted */:
2349
2642
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
2350
2643
  return { type: "exit", reason: toolResp };
2351
2644
  case "HandOver" /* HandOver */: {
2352
- if (toolReponses.length > 0) {
2645
+ if (toolResponses.length > 0) {
2353
2646
  break outer;
2354
2647
  }
2355
2648
  const handOverResp = {
@@ -2369,7 +2662,7 @@ ${agents}`;
2369
2662
  return { type: "exit", reason: handOverResp };
2370
2663
  }
2371
2664
  case "Delegate" /* Delegate */: {
2372
- if (toolReponses.length > 0) {
2665
+ if (toolResponses.length > 0) {
2373
2666
  continue;
2374
2667
  }
2375
2668
  const delegateResp = {
@@ -2390,7 +2683,7 @@ ${agents}`;
2390
2683
  }
2391
2684
  case "Pause" /* Pause */: {
2392
2685
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
2393
- toolReponses.push({ type: "pause", tool: content.name, object: toolResp.object });
2686
+ toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
2394
2687
  hasPause = true;
2395
2688
  }
2396
2689
  }
@@ -2399,29 +2692,37 @@ ${agents}`;
2399
2692
  }
2400
2693
  }
2401
2694
  if (hasPause) {
2402
- return { type: "exit", reason: { type: "Pause", responses: toolReponses } };
2695
+ return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
2403
2696
  }
2404
- if (toolReponses.length === 0) {
2697
+ if (toolResponses.length === 0) {
2405
2698
  return { type: "reply", message: responsePrompts.requireUseTool };
2406
2699
  }
2407
- const finalResp = toolReponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join("\n\n");
2700
+ const finalResp = toolResponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join("\n\n");
2408
2701
  return { type: "reply", message: finalResp };
2409
2702
  }
2410
2703
  async #invokeTool(name, args) {
2411
2704
  try {
2412
- const handler14 = this.handlers[name]?.handler;
2413
- if (!handler14) {
2705
+ const handler15 = this.handlers[name]?.handler;
2706
+ if (!handler15) {
2414
2707
  return {
2415
2708
  type: "Error" /* Error */,
2416
2709
  message: responsePrompts.errorInvokeTool(name, "Tool not found"),
2417
2710
  canRetry: false
2418
2711
  };
2419
2712
  }
2713
+ for (const instance of this.#policies) {
2714
+ if (instance.onBeforeInvokeTool) {
2715
+ const resp2 = await instance.onBeforeInvokeTool(name, args);
2716
+ if (resp2) {
2717
+ return resp2;
2718
+ }
2719
+ }
2720
+ }
2420
2721
  const resp = await this.onBeforeInvokeTool(this.handlers[name].name, args);
2421
2722
  if (resp) {
2422
2723
  return resp;
2423
2724
  }
2424
- return await handler14(this.config.provider, args);
2725
+ return await handler15(this.config.provider, args);
2425
2726
  } catch (error) {
2426
2727
  return {
2427
2728
  type: "Error" /* Error */,
@@ -2496,7 +2797,8 @@ var AnalyzerAgent = class extends AgentBase {
2496
2797
  interactive: options.interactive,
2497
2798
  agents: options.agents,
2498
2799
  scripts: options.scripts,
2499
- callback: options.callback
2800
+ callback: options.callback,
2801
+ policies: options.policies
2500
2802
  });
2501
2803
  }
2502
2804
  onBeforeInvokeTool() {
@@ -2520,47 +2822,43 @@ var fullSystemPrompt2 = (info, tools, toolNamePrefix, instructions, scripts) =>
2520
2822
 
2521
2823
  ## Role
2522
2824
  You are the **Architect** agent, responsible for:
2523
- 1. **Task Analysis** \u2013 Understand requirements.
2524
- 2. **File Identification** \u2013 Find and select relevant files.
2525
- 3. **File Reading** \u2013 Use the provided tools to gather information from these files.
2526
- 4. **Implementation Plan** \u2013 Draft a concise plan detailing steps, resources, and dependencies.
2527
- 5. **Review & Improve** \u2013 Evaluate and refine the plan.
2528
- 6. **Handover/Delegate** \u2013 Provide the final plan, context, and files to the **Coder** agent.
2825
+ 1. **Task Analysis** - Understand requirements.
2826
+ 2. **File Identification** - Find and select relevant files.
2827
+ 3. **File Reading** - Use the provided tools to gather information from these files.
2828
+ 4. **Implementation Plan** - Draft a detailed, unambiguous, *code-free* plan (pseudocode or interface stubs allowed).
2829
+ 5. **Review & Improve** - Evaluate and refine the plan.
2830
+ 6. **Handover/Delegate** - Provide the final plan, context, and files to the **Coder** agent.
2529
2831
 
2530
- > **Note**: The **Architect** agent must not make any direct modifications. Your role is limited to creating the implementation plan and handing it over to the **Coder** agent, who will perform any actual changes.
2832
+ > **Note**: The **Architect** agent must **never** modify project files directly. Your sole deliverable is the implementation plan; the **Coder** agent will perform all code changes.
2531
2833
 
2532
2834
  ## Rules
2533
- 1. **Consistency**: Maintain alignment with the user\u2019s instructions and the system\u2019s objectives at all times.
2534
- 2. **Relevance**: Only read and use files directly related to the task. Avoid unnecessary or tangential information.
2535
- 3. **Conciseness**: Keep all communications and plans succinct, avoiding superfluous or repetitive details.
2536
- 4. **Accuracy**: Ensure the information you gather and any conclusions you draw are correct and verifiable.
2537
- 5. **Clarity**: Present the final plan and any supporting details in a structured and easily understandable format.
2538
- 6. **Minimal Queries**: Ask clarifying questions only when essential, and avoid repeated questioning that does not add value.
2835
+ 1. **Consistency** - Always align with the user's instructions and project objectives.
2836
+ 2. **Relevance** - Consult only files essential to the task.
2837
+ 3. **Conciseness** - Communicate succinctly; avoid repetition.
2838
+ 4. **Accuracy** - Ensure findings and conclusions are correct and verifiable.
2839
+ 5. **Clarity** - Present information in a structured, easy-to-follow format.
2840
+ 6. **Minimal Queries** - Ask clarifying questions only when essential; avoid redundant questioning.
2539
2841
 
2540
2842
  ## Steps
2541
2843
  1. **Analyze Task**
2542
- - Gather and understand the user\u2019s requirements.
2543
- - Note any potential constraints or objectives that may influence the plan.
2844
+ - Capture requirements, constraints, and objectives.
2544
2845
 
2545
2846
  2. **Identify Relevant Files**
2546
- - Determine which files or documents are necessary.
2547
- - Justify why these files are relevant.
2847
+ - List the specific files needed and justify each selection.
2548
2848
 
2549
2849
  3. **Read Files via Tools**
2550
- - Utilize the provided tools to access and extract information from the identified files.
2551
- - Summarize key insights or data for the solution.
2850
+ - Extract key information with provided tools and summarize insights.
2552
2851
 
2553
2852
  4. **Create Implementation Plan**
2554
- - Outline tasks, define milestones, and detail resources or dependencies.
2555
- - Provide clear, concise instructions for each step.
2556
- - Each step should be appropriate sized and self-contained.
2853
+ - Produce a **detailed, step-by-step plan** that:
2854
+ - Describes tasks, resources, and dependencies.
2855
+ - Uses pseudocode or interface declarations *only*\u2014no concrete code.
2856
+ - Is explicit enough for the **Coder** agent to implement without further clarification.
2557
2857
 
2558
2858
  5. **Handover/Delegate**
2559
- - Evaluate the number of steps required.
2560
- - Handleover to the **Coder** agent if only one step is required.
2561
- - If multiple steps are required, delegate each step to the **Coder** agent.
2562
- - Deliver the final implementation plan, context, and relevant files to the **Coder** agent.
2563
- - Provide any additional instructions or clarifications needed for successful implementation.
2859
+ - If the plan consists of a single self-contained step, hand it over as one task.
2860
+ - If multiple steps are required, break them into numbered tasks for the **Coder** agent.
2861
+ - Provide all necessary context, file references, and clarifications for successful execution.
2564
2862
 
2565
2863
  ${toolUsePrompt(tools, toolNamePrefix)}
2566
2864
  ${capabilities(toolNamePrefix)}
@@ -2598,7 +2896,8 @@ var ArchitectAgent = class extends AgentBase {
2598
2896
  interactive: options.interactive,
2599
2897
  agents: options.agents,
2600
2898
  scripts: options.scripts,
2601
- callback: options.callback
2899
+ callback: options.callback,
2900
+ policies: options.policies
2602
2901
  });
2603
2902
  }
2604
2903
  onBeforeInvokeTool() {
@@ -2723,7 +3022,8 @@ var CodeFixerAgent = class extends AgentBase {
2723
3022
  interactive: options.interactive,
2724
3023
  agents: options.agents,
2725
3024
  scripts: options.scripts,
2726
- callback: options.callback
3025
+ callback: options.callback,
3026
+ policies: options.policies
2727
3027
  });
2728
3028
  this.#maxRetries = options.maxRetries ?? 5;
2729
3029
  }
@@ -2924,7 +3224,8 @@ var CoderAgent = class extends AgentBase {
2924
3224
  interactive: options.interactive,
2925
3225
  agents: options.agents,
2926
3226
  scripts: options.scripts,
2927
- callback: options.callback
3227
+ callback: options.callback,
3228
+ policies: options.policies
2928
3229
  });
2929
3230
  }
2930
3231
  async onBeforeInvokeTool(name, args) {
@@ -2997,24 +3298,24 @@ var MultiAgent = class {
2997
3298
  switch (exitReason.type) {
2998
3299
  case "HandOver" /* HandOver */: {
2999
3300
  this.#agents.pop();
3000
- const prompt5 = await this.#config.getPrompt?.(
3301
+ const prompt6 = await this.#config.getPrompt?.(
3001
3302
  exitReason.agentName,
3002
3303
  exitReason.task,
3003
3304
  exitReason.context,
3004
3305
  exitReason.files,
3005
3306
  exitReason.originalTask
3006
3307
  ) ?? exitReason.task;
3007
- return await this.#startTask(exitReason.agentName, prompt5);
3308
+ return await this.#startTask(exitReason.agentName, prompt6);
3008
3309
  }
3009
3310
  case "Delegate" /* Delegate */: {
3010
- const prompt5 = await this.#config.getPrompt?.(
3311
+ const prompt6 = await this.#config.getPrompt?.(
3011
3312
  exitReason.agentName,
3012
3313
  exitReason.task,
3013
3314
  exitReason.context,
3014
3315
  exitReason.files,
3015
3316
  exitReason.originalTask
3016
3317
  ) ?? exitReason.task;
3017
- const delegateResult = await this.#startTask(exitReason.agentName, prompt5);
3318
+ const delegateResult = await this.#startTask(exitReason.agentName, prompt6);
3018
3319
  switch (delegateResult.type) {
3019
3320
  case "HandOver" /* HandOver */:
3020
3321
  case "Delegate" /* Delegate */:
@@ -3059,11 +3360,222 @@ var MultiAgent = class {
3059
3360
  }
3060
3361
  };
3061
3362
 
3363
+ // src/Agent/policies/KnowledgeManagement.ts
3364
+ import { dirname, join as join2 } from "node:path";
3365
+
3366
+ // src/config.ts
3367
+ import { z } from "zod";
3368
+ var providerModelSchema = z.object({
3369
+ provider: z.string().optional(),
3370
+ model: z.string().optional(),
3371
+ parameters: z.record(z.string(), z.any()).optional()
3372
+ });
3373
+ var agentSchema = providerModelSchema.extend({
3374
+ initialContext: z.object({
3375
+ maxFileCount: z.number().int().positive().optional(),
3376
+ excludes: z.array(z.string()).optional()
3377
+ }).optional()
3378
+ });
3379
+ var configSchema = z.object({
3380
+ agent: z.string().optional(),
3381
+ prices: z.record(
3382
+ z.string(),
3383
+ // provider
3384
+ z.record(
3385
+ z.string(),
3386
+ // model
3387
+ z.object({
3388
+ inputPrice: z.number().optional(),
3389
+ outputPrice: z.number().optional(),
3390
+ cacheWritesPrice: z.number().optional(),
3391
+ cacheReadsPrice: z.number().optional()
3392
+ })
3393
+ )
3394
+ ).optional(),
3395
+ providers: z.record(
3396
+ z.string(),
3397
+ z.object({
3398
+ apiKey: z.string().optional(),
3399
+ defaultModel: z.string().optional(),
3400
+ defaultParameters: z.record(z.string(), z.any()).optional()
3401
+ })
3402
+ ).optional(),
3403
+ defaultProvider: z.string().optional(),
3404
+ defaultModel: z.string().optional(),
3405
+ defaultParameters: z.record(z.string(), z.any()).optional(),
3406
+ maxMessageCount: z.number().int().positive().optional(),
3407
+ budget: z.number().positive().optional(),
3408
+ scripts: z.record(
3409
+ z.string(),
3410
+ z.string().or(
3411
+ z.object({
3412
+ command: z.string(),
3413
+ description: z.string()
3414
+ })
3415
+ )
3416
+ ).optional(),
3417
+ agents: z.record(z.string(), agentSchema).optional(),
3418
+ commands: z.object({
3419
+ default: providerModelSchema.optional()
3420
+ }).catchall(providerModelSchema).optional(),
3421
+ rules: z.array(z.string()).optional().or(z.string()).optional(),
3422
+ excludeFiles: z.array(z.string()).optional(),
3423
+ policies: z.array(z.string()).optional()
3424
+ }).strict();
3425
+ var Policies = /* @__PURE__ */ ((Policies2) => {
3426
+ Policies2["KnowledgeManagement"] = "knowledgemanagement";
3427
+ return Policies2;
3428
+ })(Policies || {});
3429
+
3430
+ // src/Agent/policies/KnowledgeManagement.ts
3431
+ var prompt = `
3432
+ ====
3433
+
3434
+ # Knowledge Extraction & Maintenance
3435
+
3436
+ You are equipped with **Knowledge Management** capabilities:
3437
+
3438
+ 1. **What to capture**
3439
+ \u2022 Public API of each file (public classes, functions, methods, parameters, return types).
3440
+ \u2022 High-level description of each file's purpose.
3441
+ \u2022 Invariants and assumptions that must always hold.
3442
+ \u2022 Project or directory-specific coding patterns, styles, and architectural conventions.
3443
+ \u2022 Rules (commenting, testing, documentation, security, etc.).
3444
+ \u2022 Any other insight that a future contributor would find crucial.
3445
+
3446
+ 2. **Where to store it**
3447
+ \u2022 Save knowledge in a YAML file named \`knowledge.ai.yml\`.
3448
+ \u2022 **Create the file in the repository root if it does not yet exist.**
3449
+ \u2022 One file per directory.
3450
+ - The repository root file records knowledge that applies project-wide (e.g., service responsibilities, global patterns).
3451
+ - Each sub-directory keeps only the knowledge relevant to that directory or package.
3452
+ \u2022 Use clear top-level keys such as \`description\`, \`files\`, \`rules\`.
3453
+
3454
+ 3. **When to update**
3455
+ \u2022 **Default behaviour:** only create / update knowledge for the files you actively read, create, or modify during the current task.
3456
+ - Operate on other files **only if the user explicitly requests it**.
3457
+ \u2022 **While working**: after reading, analysing, creating, or modifying code, immediately record any new or changed knowledge.
3458
+ \u2022 **On refactor / deletion**: locate and delete or amend obsolete entries so that knowledge never drifts from the codebase.
3459
+ \u2022 **Granularity**: update only the affected directory's \`knowledge.ai.yml\`, except when the change has global impact.
3460
+
3461
+ 4. **How to format (illustrative)**
3462
+ \`\`\`yaml
3463
+ description: "description of the directory"
3464
+ files:
3465
+ "math.ts":
3466
+ description: "Numeric helpers for currency calculations"
3467
+ api:
3468
+ functions:
3469
+ 1:
3470
+ name: "add"
3471
+ params:
3472
+ 1: { name: "a", type: "number" }
3473
+ 2: { name: "b", type: "number" }
3474
+ returns: "number"
3475
+ rules:
3476
+ 1: "rules that apply to all files in this directory"
3477
+ \`\`\`
3478
+
3479
+ 5. **Source of truth**
3480
+ \u2022 **Never invent knowledge.** Everything you record must be *directly derived* from existing code, comments, commit messages, or explicit user instructions.
3481
+ \u2022 If a section has no confirmed content, omit it rather than guessing.
3482
+
3483
+ 6. **Automatic context**
3484
+ When you are asked to read or modify a file, the orchestration layer will supply any existing knowledge for that path automatically. Use it, refine it, and keep it accurate.
3485
+
3486
+ 7. **Using the updateKnowledge tool**
3487
+ You can use the \`updateKnowledge\` tool to efficiently update knowledge files with smart merging capabilities.
3488
+
3489
+ 8. **Dictionary-First Format**
3490
+ \u2022 **Always prefer dictionaries** for structured data.
3491
+ \u2022 The **\`files\` section must be a dictionary keyed by file path** (e.g., \`"math.ts": {...}\`).
3492
+ \u2022 For other lists (rules, functions, etc.), use numbered dictionaries.
3493
+ \u2022 Arrays are allowed only when strict ordering is essential and dictionaries cannot express it.
3494
+ \u2022 When removing items, refer to them by their numeric key or index; gaps are fine.
3495
+
3496
+ Your workflow **must**:
3497
+ 1. Detect knowledge deltas.
3498
+ 2. Create \`knowledge.ai.yml\` if missing and write edits to the correct file.
3499
+ 3. Remove stale facts.
3500
+ 4. Use provided tools to update the knowledge files.
3501
+ 5. Record only evidence-based information; do not hallucinate.
3502
+ 6. Use dictionaries throughout, with numbered dictionaries for ordered data and path-keyed dictionaries for the \`files\` section.
3503
+ `;
3504
+ var KnowledgeManagementPolicy = (tools) => {
3505
+ if (!tools[readFile_default.name]) {
3506
+ return void 0;
3507
+ }
3508
+ const readFiles = /* @__PURE__ */ new Set();
3509
+ return {
3510
+ name: "knowledgemanagement" /* KnowledgeManagement */,
3511
+ tools: tools[writeToFile_default.name] ? [tools[updateKnowledge_default.name]] : [],
3512
+ prompt: tools[writeToFile_default.name] || tools[updateKnowledge_default.name] ? prompt : void 0,
3513
+ async getKnowledgeFilePaths(inputFiles) {
3514
+ const paths = /* @__PURE__ */ new Set();
3515
+ for (const file of inputFiles) {
3516
+ let dir = dirname(file);
3517
+ paths.add(dir);
3518
+ while (dir !== ".") {
3519
+ paths.add(dir);
3520
+ dir = dirname(dir);
3521
+ }
3522
+ }
3523
+ const allFullPaths = [];
3524
+ for (const path of paths) {
3525
+ if (path === ".") {
3526
+ continue;
3527
+ }
3528
+ const fullpath = join2(path, "knowledge.ai.yml");
3529
+ if (!readFiles.has(fullpath)) {
3530
+ allFullPaths.push(fullpath);
3531
+ readFiles.add(fullpath);
3532
+ }
3533
+ }
3534
+ return allFullPaths;
3535
+ },
3536
+ async updateResponse(response) {
3537
+ const files = /* @__PURE__ */ new Set();
3538
+ for (const content of response) {
3539
+ if (content.type === "tool_use") {
3540
+ switch (content.name) {
3541
+ case readFile_default.name: {
3542
+ const paths = getStringArray(content.params, "path");
3543
+ for (const path of paths) {
3544
+ files.add(path);
3545
+ }
3546
+ break;
3547
+ }
3548
+ case listFiles_default.name: {
3549
+ const path = getString(content.params, "path");
3550
+ files.add(path);
3551
+ break;
3552
+ }
3553
+ }
3554
+ }
3555
+ }
3556
+ const allFullPaths = await this.getKnowledgeFilePaths(Array.from(files));
3557
+ if (allFullPaths.length === 0) {
3558
+ return response;
3559
+ }
3560
+ return [
3561
+ ...response,
3562
+ {
3563
+ type: "tool_use",
3564
+ name: readFile_default.name,
3565
+ params: {
3566
+ path: allFullPaths.join(",")
3567
+ }
3568
+ }
3569
+ ];
3570
+ }
3571
+ };
3572
+ };
3573
+
3062
3574
  // src/Agent/index.ts
3063
3575
  var allAgents = [architectAgentInfo, coderAgentInfo, analyzerAgentInfo, codeFixerAgentInfo];
3064
3576
 
3065
3577
  // src/AiTool/createNewProject.ts
3066
- var prompt = `You are an AiTool designed to assist users in creating new projects. Follow these guidelines:
3578
+ var prompt2 = `You are an AiTool designed to assist users in creating new projects. Follow these guidelines:
3067
3579
 
3068
3580
  1. **Gather Information:**
3069
3581
  - Begin by asking the user for essential project details, including:
@@ -3148,7 +3660,7 @@ var prompt = `You are an AiTool designed to assist users in creating new project
3148
3660
  var createNewProject_default = {
3149
3661
  name: "createNewProject",
3150
3662
  description: "Creates a new project",
3151
- prompt,
3663
+ prompt: prompt2,
3152
3664
  formatInput: (params) => {
3153
3665
  return `<project_name>${params}</project_name>`;
3154
3666
  },
@@ -3159,7 +3671,7 @@ var createNewProject_default = {
3159
3671
  };
3160
3672
 
3161
3673
  // src/AiTool/generateGitCommitMessage.ts
3162
- var prompt2 = `
3674
+ var prompt3 = `
3163
3675
  You are an advanced assistant specialized in creating concise and accurate Git commit messages. When you receive:
3164
3676
  - A Git diff inside the <tool_input> tag.
3165
3677
  - Additional user-supplied context inside the <tool_input_context> tag (if any).
@@ -3190,7 +3702,7 @@ Follow the same structure for any new input. Never repeat questions; focus on ge
3190
3702
  var generateGitCommitMessage_default = {
3191
3703
  name: "generateGitCommitMessage",
3192
3704
  description: "Generates git commit messages from git diff output",
3193
- prompt: prompt2,
3705
+ prompt: prompt3,
3194
3706
  formatInput: (params) => {
3195
3707
  let ret = `<tool_input>
3196
3708
  ${params.diff}
@@ -3215,7 +3727,7 @@ ${output}`);
3215
3727
  };
3216
3728
 
3217
3729
  // src/AiTool/generateGithubPullRequestDetails.ts
3218
- var prompt3 = `
3730
+ var prompt4 = `
3219
3731
  # Generate Github Pull Request Details
3220
3732
 
3221
3733
  You are given:
@@ -3299,7 +3811,7 @@ Use the above format whenever you receive <tool_input> that may include a branch
3299
3811
  var generateGithubPullRequestDetails_default = {
3300
3812
  name: "generateGithubPullRequestDetails",
3301
3813
  description: "Generates a GitHub pull request title and description from git commits",
3302
- prompt: prompt3,
3814
+ prompt: prompt4,
3303
3815
  formatInput: (params) => {
3304
3816
  return `<tool_input>
3305
3817
  <tool_input_branch_name>${params.branchName}</tool_input_branch_name>${params.context ? `
@@ -3332,7 +3844,7 @@ ${output}`);
3332
3844
  };
3333
3845
 
3334
3846
  // src/AiTool/generateProjectConfig.ts
3335
- var prompt4 = `You are an analyzer agent responsible for examining project files and generating appropriate polkacodes configuration. Your task is to:
3847
+ var prompt5 = `You are an analyzer agent responsible for examining project files and generating appropriate polkacodes configuration. Your task is to:
3336
3848
 
3337
3849
  1. Read and analyze the provided files using tool_read_file to understand:
3338
3850
  - Build tools and package manager (e.g., bun, npm)
@@ -3394,7 +3906,7 @@ The configuration should accurately reflect the project's structure, tools, and
3394
3906
  var generateProjectConfig_default = {
3395
3907
  name: "generateProjectConfig",
3396
3908
  description: "Analyzes project files to generate polkacodes config sections",
3397
- prompt: prompt4,
3909
+ prompt: prompt5,
3398
3910
  formatInput: () => {
3399
3911
  return "";
3400
3912
  },
@@ -3442,65 +3954,6 @@ var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
3442
3954
  var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
3443
3955
  var generateProjectConfig = makeAgentTool(generateProjectConfig_default);
3444
3956
  var createNewProject = makeAgentTool(createNewProject_default);
3445
-
3446
- // src/config.ts
3447
- import { z } from "zod";
3448
- var providerModelSchema = z.object({
3449
- provider: z.string().optional(),
3450
- model: z.string().optional(),
3451
- parameters: z.record(z.string(), z.any()).optional()
3452
- });
3453
- var agentSchema = providerModelSchema.extend({
3454
- initialContext: z.object({
3455
- maxFileCount: z.number().int().positive().optional(),
3456
- excludes: z.array(z.string()).optional()
3457
- }).optional()
3458
- });
3459
- var configSchema = z.object({
3460
- agent: z.string().optional(),
3461
- prices: z.record(
3462
- z.string(),
3463
- // provider
3464
- z.record(
3465
- z.string(),
3466
- // model
3467
- z.object({
3468
- inputPrice: z.number().optional(),
3469
- outputPrice: z.number().optional(),
3470
- cacheWritesPrice: z.number().optional(),
3471
- cacheReadsPrice: z.number().optional()
3472
- })
3473
- )
3474
- ).optional(),
3475
- providers: z.record(
3476
- z.string(),
3477
- z.object({
3478
- apiKey: z.string().optional(),
3479
- defaultModel: z.string().optional(),
3480
- defaultParameters: z.record(z.string(), z.any()).optional()
3481
- })
3482
- ).optional(),
3483
- defaultProvider: z.string().optional(),
3484
- defaultModel: z.string().optional(),
3485
- defaultParameters: z.record(z.string(), z.any()).optional(),
3486
- maxMessageCount: z.number().int().positive().optional(),
3487
- budget: z.number().positive().optional(),
3488
- scripts: z.record(
3489
- z.string(),
3490
- z.string().or(
3491
- z.object({
3492
- command: z.string(),
3493
- description: z.string()
3494
- })
3495
- )
3496
- ).optional(),
3497
- agents: z.record(z.string(), agentSchema).optional(),
3498
- commands: z.object({
3499
- default: providerModelSchema.optional()
3500
- }).catchall(providerModelSchema).optional(),
3501
- rules: z.array(z.string()).optional().or(z.string()).optional(),
3502
- excludeFiles: z.array(z.string()).optional()
3503
- }).strict();
3504
3957
  export {
3505
3958
  AgentBase,
3506
3959
  AiServiceBase,
@@ -3509,9 +3962,11 @@ export {
3509
3962
  ArchitectAgent,
3510
3963
  CodeFixerAgent,
3511
3964
  CoderAgent,
3965
+ KnowledgeManagementPolicy,
3512
3966
  MockProvider,
3513
3967
  MultiAgent,
3514
3968
  PermissionLevel,
3969
+ Policies,
3515
3970
  TaskEventKind,
3516
3971
  ToolResponseType,
3517
3972
  UsageMeter,
@@ -3564,5 +4019,6 @@ export {
3564
4019
  searchFiles_default as searchFiles,
3565
4020
  systemInformation,
3566
4021
  toolUsePrompt,
4022
+ updateKnowledge_default as updateKnowledge,
3567
4023
  writeToFile_default as writeToFile
3568
4024
  };