@polka-codes/core 0.10.11 → 0.10.16

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.
Files changed (250) hide show
  1. package/dist/Agent/backoff.d.ts +7 -0
  2. package/dist/Agent/backoff.js +21 -0
  3. package/dist/Agent/backoff.js.map +1 -0
  4. package/dist/Agent/index.d.ts +2 -0
  5. package/dist/Agent/index.js +3 -0
  6. package/dist/Agent/index.js.map +1 -0
  7. package/dist/Agent/parseJsonFromMarkdown.d.ts +8 -0
  8. package/dist/Agent/parseJsonFromMarkdown.js +34 -0
  9. package/dist/Agent/parseJsonFromMarkdown.js.map +1 -0
  10. package/dist/Agent/parseJsonFromMarkdown.test.d.ts +1 -0
  11. package/dist/Agent/parseJsonFromMarkdown.test.js +70 -0
  12. package/dist/Agent/parseJsonFromMarkdown.test.js.map +1 -0
  13. package/dist/Agent/prompts.d.ts +9 -0
  14. package/dist/Agent/prompts.js +107 -0
  15. package/dist/Agent/prompts.js.map +1 -0
  16. package/dist/UsageMeter.d.ts +101 -0
  17. package/dist/UsageMeter.js +299 -0
  18. package/dist/UsageMeter.js.map +1 -0
  19. package/dist/UsageMeter.test.d.ts +4 -0
  20. package/dist/UsageMeter.test.js +556 -0
  21. package/dist/UsageMeter.test.js.map +1 -0
  22. package/dist/config/base.d.ts +68 -0
  23. package/dist/config/base.js +56 -0
  24. package/dist/config/base.js.map +1 -0
  25. package/dist/config/memory.d.ts +24 -0
  26. package/dist/config/memory.js +36 -0
  27. package/dist/config/memory.js.map +1 -0
  28. package/dist/config.d.ts +236 -0
  29. package/dist/config.js +184 -0
  30. package/dist/config.js.map +1 -0
  31. package/dist/errors/base.d.ts +31 -0
  32. package/dist/errors/base.js +60 -0
  33. package/dist/errors/base.js.map +1 -0
  34. package/dist/errors/index.d.ts +1 -0
  35. package/dist/errors/index.js +3 -0
  36. package/dist/errors/index.js.map +1 -0
  37. package/dist/fs/index.d.ts +2 -0
  38. package/dist/fs/index.js +3 -0
  39. package/dist/fs/index.js.map +1 -0
  40. package/dist/fs/node-provider.d.ts +16 -0
  41. package/dist/fs/node-provider.js +47 -0
  42. package/dist/fs/node-provider.js.map +1 -0
  43. package/dist/fs/provider.d.ts +61 -0
  44. package/dist/fs/provider.js +3 -0
  45. package/dist/fs/provider.js.map +1 -0
  46. package/dist/index.d.ts +20 -191
  47. package/dist/index.js +21 -4123
  48. package/dist/index.js.map +1 -0
  49. package/dist/memory/index.d.ts +1 -0
  50. package/dist/memory/index.js +2 -0
  51. package/dist/memory/index.js.map +1 -0
  52. package/dist/memory/types.d.ts +136 -0
  53. package/dist/memory/types.js +2 -0
  54. package/dist/memory/types.js.map +1 -0
  55. package/dist/path.d.ts +9 -0
  56. package/dist/path.js +68 -0
  57. package/dist/path.js.map +1 -0
  58. package/dist/path.test.d.ts +1 -0
  59. package/dist/path.test.js +82 -0
  60. package/dist/path.test.js.map +1 -0
  61. package/dist/pricing/converter.d.ts +6 -0
  62. package/dist/pricing/converter.js +13 -0
  63. package/dist/pricing/converter.js.map +1 -0
  64. package/dist/pricing/converter.test.d.ts +1 -0
  65. package/dist/pricing/converter.test.js +54 -0
  66. package/dist/pricing/converter.test.js.map +1 -0
  67. package/dist/pricing/index.d.ts +2 -0
  68. package/dist/pricing/index.js +2 -0
  69. package/dist/pricing/index.js.map +1 -0
  70. package/dist/pricing/portkey-client.d.ts +2 -0
  71. package/dist/pricing/portkey-client.js +57 -0
  72. package/dist/pricing/portkey-client.js.map +1 -0
  73. package/dist/pricing/pricing-service.d.ts +6 -0
  74. package/dist/pricing/pricing-service.js +125 -0
  75. package/dist/pricing/pricing-service.js.map +1 -0
  76. package/dist/pricing/pricing-service.test.d.ts +1 -0
  77. package/dist/pricing/pricing-service.test.js +141 -0
  78. package/dist/pricing/pricing-service.test.js.map +1 -0
  79. package/dist/pricing/types.d.ts +24 -0
  80. package/dist/pricing/types.js +2 -0
  81. package/dist/pricing/types.js.map +1 -0
  82. package/dist/skills/__tests__/discovery.test.d.ts +1 -0
  83. package/dist/skills/__tests__/discovery.test.js +254 -0
  84. package/dist/skills/__tests__/discovery.test.js.map +1 -0
  85. package/dist/skills/__tests__/validation.test.d.ts +1 -0
  86. package/dist/skills/__tests__/validation.test.js +221 -0
  87. package/dist/skills/__tests__/validation.test.js.map +1 -0
  88. package/dist/skills/constants.d.ts +32 -0
  89. package/dist/skills/constants.js +50 -0
  90. package/dist/skills/constants.js.map +1 -0
  91. package/dist/skills/discovery.d.ts +56 -0
  92. package/dist/skills/discovery.js +392 -0
  93. package/dist/skills/discovery.js.map +1 -0
  94. package/dist/skills/index.d.ts +4 -0
  95. package/dist/skills/index.js +6 -0
  96. package/dist/skills/index.js.map +1 -0
  97. package/dist/skills/tools/index.d.ts +3 -0
  98. package/dist/skills/tools/index.js +5 -0
  99. package/dist/skills/tools/index.js.map +1 -0
  100. package/dist/skills/tools/listSkills.d.ts +54 -0
  101. package/dist/skills/tools/listSkills.js +52 -0
  102. package/dist/skills/tools/listSkills.js.map +1 -0
  103. package/dist/skills/tools/loadSkill.d.ts +52 -0
  104. package/dist/skills/tools/loadSkill.js +86 -0
  105. package/dist/skills/tools/loadSkill.js.map +1 -0
  106. package/dist/skills/tools/readSkillFile.d.ts +43 -0
  107. package/dist/skills/tools/readSkillFile.js +68 -0
  108. package/dist/skills/tools/readSkillFile.js.map +1 -0
  109. package/dist/skills/types.d.ts +83 -0
  110. package/dist/skills/types.js +42 -0
  111. package/dist/skills/types.js.map +1 -0
  112. package/dist/skills/validation.d.ts +30 -0
  113. package/dist/skills/validation.js +133 -0
  114. package/dist/skills/validation.js.map +1 -0
  115. package/dist/tool.d.ts +51 -0
  116. package/dist/tool.js +2 -0
  117. package/dist/tool.js.map +1 -0
  118. package/dist/tools/askFollowupQuestion.d.ts +35 -0
  119. package/dist/tools/askFollowupQuestion.js +105 -0
  120. package/dist/tools/askFollowupQuestion.js.map +1 -0
  121. package/dist/tools/askFollowupQuestion.test.d.ts +1 -0
  122. package/dist/tools/askFollowupQuestion.test.js +80 -0
  123. package/dist/tools/askFollowupQuestion.test.js.map +1 -0
  124. package/dist/tools/executeCommand.d.ts +29 -0
  125. package/dist/tools/executeCommand.js +82 -0
  126. package/dist/tools/executeCommand.js.map +1 -0
  127. package/dist/tools/executeCommand.test.d.ts +1 -0
  128. package/dist/tools/executeCommand.test.js +60 -0
  129. package/dist/tools/executeCommand.test.js.map +1 -0
  130. package/dist/tools/fetchUrl.d.ts +26 -0
  131. package/dist/tools/fetchUrl.js +85 -0
  132. package/dist/tools/fetchUrl.js.map +1 -0
  133. package/dist/tools/index.d.ts +15 -0
  134. package/dist/tools/index.js +17 -0
  135. package/dist/tools/index.js.map +1 -0
  136. package/dist/tools/listFiles.d.ts +35 -0
  137. package/dist/tools/listFiles.js +61 -0
  138. package/dist/tools/listFiles.js.map +1 -0
  139. package/dist/tools/listFiles.test.d.ts +1 -0
  140. package/dist/tools/listFiles.test.js +59 -0
  141. package/dist/tools/listFiles.test.js.map +1 -0
  142. package/dist/tools/provider.d.ts +76 -0
  143. package/dist/tools/provider.js +60 -0
  144. package/dist/tools/provider.js.map +1 -0
  145. package/dist/tools/readBinaryFile.d.ts +26 -0
  146. package/dist/tools/readBinaryFile.js +52 -0
  147. package/dist/tools/readBinaryFile.js.map +1 -0
  148. package/dist/tools/readFile.d.ts +35 -0
  149. package/dist/tools/readFile.js +128 -0
  150. package/dist/tools/readFile.js.map +1 -0
  151. package/dist/tools/readFile.test.d.ts +1 -0
  152. package/dist/tools/readFile.test.js +37 -0
  153. package/dist/tools/readFile.test.js.map +1 -0
  154. package/dist/tools/removeFile.d.ts +26 -0
  155. package/dist/tools/removeFile.js +49 -0
  156. package/dist/tools/removeFile.js.map +1 -0
  157. package/dist/tools/removeFile.test.d.ts +1 -0
  158. package/dist/tools/removeFile.test.js +32 -0
  159. package/dist/tools/removeFile.test.js.map +1 -0
  160. package/dist/tools/renameFile.d.ts +29 -0
  161. package/dist/tools/renameFile.js +48 -0
  162. package/dist/tools/renameFile.js.map +1 -0
  163. package/dist/tools/renameFile.test.d.ts +1 -0
  164. package/dist/tools/renameFile.test.js +53 -0
  165. package/dist/tools/renameFile.test.js.map +1 -0
  166. package/dist/tools/replaceInFile.d.ts +29 -0
  167. package/dist/tools/replaceInFile.js +233 -0
  168. package/dist/tools/replaceInFile.js.map +1 -0
  169. package/dist/tools/replaceInFile.test.d.ts +1 -0
  170. package/dist/tools/replaceInFile.test.js +79 -0
  171. package/dist/tools/replaceInFile.test.js.map +1 -0
  172. package/dist/tools/response-builders.d.ts +64 -0
  173. package/dist/tools/response-builders.js +88 -0
  174. package/dist/tools/response-builders.js.map +1 -0
  175. package/dist/tools/search.d.ts +26 -0
  176. package/dist/tools/search.js +56 -0
  177. package/dist/tools/search.js.map +1 -0
  178. package/dist/tools/search.test.d.ts +1 -0
  179. package/dist/tools/search.test.js +22 -0
  180. package/dist/tools/search.test.js.map +1 -0
  181. package/dist/tools/searchFiles.d.ts +32 -0
  182. package/dist/tools/searchFiles.js +86 -0
  183. package/dist/tools/searchFiles.js.map +1 -0
  184. package/dist/tools/todo.d.ts +37 -0
  185. package/dist/tools/todo.js +41 -0
  186. package/dist/tools/todo.js.map +1 -0
  187. package/dist/tools/utils/index.d.ts +1 -0
  188. package/dist/tools/utils/index.js +2 -0
  189. package/dist/tools/utils/index.js.map +1 -0
  190. package/dist/tools/utils/replaceInFile.d.ts +7 -0
  191. package/dist/tools/utils/replaceInFile.js +133 -0
  192. package/dist/tools/utils/replaceInFile.js.map +1 -0
  193. package/dist/tools/utils/replaceInFile.test.d.ts +1 -0
  194. package/dist/tools/utils/replaceInFile.test.js +308 -0
  195. package/dist/tools/utils/replaceInFile.test.js.map +1 -0
  196. package/dist/tools/utils.d.ts +10 -0
  197. package/dist/tools/utils.js +27 -0
  198. package/dist/tools/utils.js.map +1 -0
  199. package/dist/tools/writeToFile.d.ts +29 -0
  200. package/dist/tools/writeToFile.js +85 -0
  201. package/dist/tools/writeToFile.js.map +1 -0
  202. package/dist/tools/writeToFile.test.d.ts +1 -0
  203. package/dist/tools/writeToFile.test.js +46 -0
  204. package/dist/tools/writeToFile.test.js.map +1 -0
  205. package/dist/utils/index.d.ts +1 -0
  206. package/dist/utils/index.js +3 -0
  207. package/dist/utils/index.js.map +1 -0
  208. package/dist/utils/merge.d.ts +26 -0
  209. package/dist/utils/merge.js +45 -0
  210. package/dist/utils/merge.js.map +1 -0
  211. package/dist/workflow/agent.workflow.d.ts +39 -0
  212. package/dist/workflow/agent.workflow.js +166 -0
  213. package/dist/workflow/agent.workflow.js.map +1 -0
  214. package/dist/workflow/agent.workflow.test.d.ts +1 -0
  215. package/dist/workflow/agent.workflow.test.js +175 -0
  216. package/dist/workflow/agent.workflow.test.js.map +1 -0
  217. package/dist/workflow/control-flow.test.d.ts +1 -0
  218. package/dist/workflow/control-flow.test.js +323 -0
  219. package/dist/workflow/control-flow.test.js.map +1 -0
  220. package/dist/workflow/dynamic-edge-cases.test.d.ts +1 -0
  221. package/dist/workflow/dynamic-edge-cases.test.js +486 -0
  222. package/dist/workflow/dynamic-edge-cases.test.js.map +1 -0
  223. package/dist/workflow/dynamic-types.d.ts +124 -0
  224. package/dist/workflow/dynamic-types.js +105 -0
  225. package/dist/workflow/dynamic-types.js.map +1 -0
  226. package/dist/workflow/dynamic.d.ts +118 -0
  227. package/dist/workflow/dynamic.js +999 -0
  228. package/dist/workflow/dynamic.js.map +1 -0
  229. package/dist/workflow/index.d.ts +6 -0
  230. package/dist/workflow/index.js +8 -0
  231. package/dist/workflow/index.js.map +1 -0
  232. package/dist/workflow/json-ai-types.d.ts +122 -0
  233. package/dist/workflow/json-ai-types.js +144 -0
  234. package/dist/workflow/json-ai-types.js.map +1 -0
  235. package/dist/workflow/json-schema-conversion.test.d.ts +1 -0
  236. package/dist/workflow/json-schema-conversion.test.js +371 -0
  237. package/dist/workflow/json-schema-conversion.test.js.map +1 -0
  238. package/dist/workflow/try-catch.test.d.ts +1 -0
  239. package/dist/workflow/try-catch.test.js +443 -0
  240. package/dist/workflow/try-catch.test.js.map +1 -0
  241. package/dist/workflow/types.d.ts +103 -0
  242. package/dist/workflow/types.js +17 -0
  243. package/dist/workflow/types.js.map +1 -0
  244. package/dist/workflow/workflow.d.ts +29 -0
  245. package/dist/workflow/workflow.js +57 -0
  246. package/dist/workflow/workflow.js.map +1 -0
  247. package/dist/workflow/workflow.test.d.ts +1 -0
  248. package/dist/workflow/workflow.test.js +189 -0
  249. package/dist/workflow/workflow.test.js.map +1 -0
  250. package/package.json +9 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listFiles.js","sourceRoot":"","sources":["../../src/tools/listFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,4XAA4X;IAC9X,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,CAAC,4FAA4F,CAAC;aACtG,IAAI,CAAC,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;QAC9C,QAAQ,EAAE,CAAC,CAAC,MAAM;aACf,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,OAAO,CAAC,IAAI,CAAC;aACb,QAAQ,CAAC,sDAAsD,CAAC;aAChE,IAAI,CAAC,EAAE,UAAU,EAAE,4CAA4C,EAAE,CAAC;QACrE,SAAS,EAAE,CAAC;aACT,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACnE,QAAQ,CAAC,sGAAsG,CAAC;aAChH,IAAI,CAAC,EAAE,UAAU,EAAE,0BAA0B,EAAE,CAAC;QACnD,cAAc,EAAE,CAAC;aACd,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aACpE,QAAQ,CAAC,oFAAoF,CAAC;aAC9F,IAAI,CAAC,EAAE,UAAU,EAAE,0BAA0B,EAAE,CAAC;KACpD,CAAC;SACD,IAAI,CAAC;QACJ,QAAQ,EAAE;YACR;gBACE,WAAW,EAAE,uBAAuB;gBACpC,KAAK,EAAE;oBACL,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,KAAK;iBAChB;aACF;SACF;KACF,CAAC;CACuB,CAAA;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAqD,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAChG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxB,OAAO,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACrF,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IAEjG,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,oBAAoB,IAAI;;EAEnC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;wBAEM,YAAY,yBAAyB;SACxD;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,GAAG,QAAQ;IACX,OAAO;CACe,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it, spyOn } from 'bun:test';
2
+ import listFiles from './listFiles';
3
+ import { MockProvider } from './provider';
4
+ describe('listFiles', () => {
5
+ it('should return file list', async () => {
6
+ const mockProvider = new MockProvider();
7
+ spyOn(mockProvider, 'listFiles').mockResolvedValue([['file1.ts', 'file2.ts'], false]);
8
+ const result = await listFiles.handler(mockProvider, {
9
+ path: 'src',
10
+ maxCount: '10',
11
+ includeIgnored: 'false',
12
+ });
13
+ expect(result).toMatchSnapshot();
14
+ expect(mockProvider.listFiles).toHaveBeenCalledWith('src', true, 10, false);
15
+ });
16
+ it('should handle non recursive listing', async () => {
17
+ const mockProvider = new MockProvider();
18
+ spyOn(mockProvider, 'listFiles').mockResolvedValue([['file1.ts', 'file2.ts'], false]);
19
+ const result = await listFiles.handler(mockProvider, {
20
+ path: 'src',
21
+ recursive: 'false',
22
+ includeIgnored: 'false',
23
+ });
24
+ expect(result).toMatchSnapshot();
25
+ expect(mockProvider.listFiles).toHaveBeenCalledWith('src', false, 2000, false);
26
+ });
27
+ it('should handle empty directory', async () => {
28
+ const mockProvider = new MockProvider();
29
+ spyOn(mockProvider, 'listFiles').mockResolvedValue([[], true]);
30
+ const result = await listFiles.handler(mockProvider, {
31
+ path: 'empty-dir',
32
+ includeIgnored: 'false',
33
+ });
34
+ expect(result).toMatchSnapshot();
35
+ expect(mockProvider.listFiles).toHaveBeenCalledWith('empty-dir', true, 2000, false);
36
+ });
37
+ it('should handle max count with truncation', async () => {
38
+ const mockProvider = new MockProvider();
39
+ spyOn(mockProvider, 'listFiles').mockResolvedValue([['file1.ts', 'file2.ts'], true]);
40
+ const result = await listFiles.handler(mockProvider, {
41
+ path: 'src',
42
+ maxCount: '1',
43
+ includeIgnored: 'false',
44
+ });
45
+ expect(result).toMatchSnapshot();
46
+ expect(mockProvider.listFiles).toHaveBeenCalledWith('src', true, 1, false);
47
+ });
48
+ it('should handle errors', async () => {
49
+ const mockProvider = new MockProvider();
50
+ spyOn(mockProvider, 'listFiles').mockRejectedValue(new Error('Directory not found'));
51
+ const result = listFiles.handler(mockProvider, {
52
+ path: 'invalid-path',
53
+ includeIgnored: 'false',
54
+ });
55
+ await expect(result).rejects.toMatchSnapshot();
56
+ expect(mockProvider.listFiles).toHaveBeenCalledWith('invalid-path', true, 2000, false);
57
+ });
58
+ });
59
+ //# sourceMappingURL=listFiles.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listFiles.test.js","sourceRoot":"","sources":["../../src/tools/listFiles.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACvC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;QAErF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE;YACnD,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,IAAI;YACd,cAAc,EAAE,OAAO;SACxB,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAA;QAChC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;IAC7E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACvC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,K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AQ,EAAE,GAAG;YACb,cAAc,EAAE,OAAO;SACxB,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAA;QAChC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACvC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAA;QAEpF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE;YAC7C,IAAI,EAAE,cAAc;YACpB,cAAc,EAAE,OAAO;SACxB,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,CAAA;QAC9C,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,76 @@
1
+ import type { TodoItem, UpdateTodoItemInput, UpdateTodoItemOutput } from './todo';
2
+ export type FilesystemProvider = {
3
+ readFile?: (path: string, includeIgnored: boolean) => Promise<string | undefined>;
4
+ writeFile?: (path: string, content: string) => Promise<void>;
5
+ fileExists?: (path: string) => Promise<boolean>;
6
+ removeFile?: (path: string) => Promise<void>;
7
+ renameFile?: (sourcePath: string, targetPath: string) => Promise<void>;
8
+ listFiles?: (path: string, recursive: boolean, maxCount: number, includeIgnored: boolean) => Promise<[string[], boolean]>;
9
+ searchFiles?: (path: string, regex: string, filePattern: string) => Promise<string[]>;
10
+ readBinaryFile?: (url: string) => Promise<{
11
+ base64Data: string;
12
+ mediaType: string;
13
+ }>;
14
+ };
15
+ export type CommandProvider = {
16
+ executeCommand?: (command: string, needApprove: boolean) => Promise<{
17
+ stdout: string;
18
+ stderr: string;
19
+ exitCode: number;
20
+ summary?: string;
21
+ }>;
22
+ };
23
+ export type InteractionProvider = {
24
+ askFollowupQuestion?: (question: string, options: string[]) => Promise<string>;
25
+ };
26
+ export type WebProvider = {
27
+ fetchUrl?: (url: string) => Promise<string>;
28
+ search?: (query: string) => Promise<string>;
29
+ };
30
+ export interface MemoryProvider {
31
+ listMemoryTopics: () => Promise<string[]>;
32
+ readMemory: (topic?: string) => Promise<string | undefined>;
33
+ updateMemory: (operation: 'append' | 'replace' | 'remove', topic: string | undefined, content: string | undefined) => Promise<void>;
34
+ }
35
+ export type ListTodoItemsOutput = TodoItem[];
36
+ export type GetTodoItemOutput = TodoItem & {
37
+ subItems: {
38
+ id: string;
39
+ title: string;
40
+ }[];
41
+ };
42
+ export type TodoProvider = {
43
+ listTodoItems: (id?: string | null, status?: string | null) => Promise<ListTodoItemsOutput>;
44
+ getTodoItem: (id: string) => Promise<GetTodoItemOutput | undefined>;
45
+ updateTodoItem: (input: UpdateTodoItemInput) => Promise<UpdateTodoItemOutput>;
46
+ };
47
+ export type ToolProvider = FilesystemProvider & CommandProvider & InteractionProvider & WebProvider & Partial<MemoryProvider> & Partial<TodoProvider>;
48
+ export declare class MockProvider implements ToolProvider {
49
+ listTodoItems(id?: string | null, _status?: string | null): Promise<{
50
+ id: string;
51
+ title: string;
52
+ status: "open";
53
+ description: string;
54
+ }[]>;
55
+ getTodoItem(id: string): Promise<GetTodoItemOutput | undefined>;
56
+ updateTodoItem(input: UpdateTodoItemInput): Promise<{
57
+ id: string;
58
+ }>;
59
+ readFile(_path: string, _includeIgnored?: boolean): Promise<string>;
60
+ writeFile(_path: string, _content: string): Promise<void>;
61
+ removeFile(_path: string): Promise<void>;
62
+ renameFile(_sourcePath: string, _targetPath: string): Promise<void>;
63
+ listFiles(_path: string, _recursive: boolean, _maxCount: number, _includeIgnored?: boolean): Promise<[string[], boolean]>;
64
+ searchFiles(_path: string, _regex: string, _filePattern: string): Promise<string[]>;
65
+ executeCommand(_command: string, _needApprove: boolean): Promise<{
66
+ stdout: string;
67
+ stderr: string;
68
+ exitCode: number;
69
+ summary?: string;
70
+ }>;
71
+ askFollowupQuestion(_question: string, _options?: string[]): Promise<string>;
72
+ search(_query: string): Promise<string>;
73
+ listMemoryTopics(): Promise<string[]>;
74
+ readMemory(_topic?: string): Promise<string | undefined>;
75
+ updateMemory(_operation: 'append' | 'replace' | 'remove', _topic?: string, _content?: string): Promise<void>;
76
+ }
@@ -0,0 +1,60 @@
1
+ export class MockProvider {
2
+ async listTodoItems(id, _status) {
3
+ if (id) {
4
+ return [{ id: `${id}-1`, title: 'mock sub item', status: 'open', description: '' }];
5
+ }
6
+ return [{ id: '1', title: 'mock item', status: 'open', description: '' }];
7
+ }
8
+ async getTodoItem(id) {
9
+ return {
10
+ id,
11
+ title: 'mock item',
12
+ description: 'mock desc',
13
+ status: 'open',
14
+ subItems: [],
15
+ };
16
+ }
17
+ async updateTodoItem(input) {
18
+ if (input.operation === 'add') {
19
+ return { id: '2' };
20
+ }
21
+ return { id: input.id };
22
+ }
23
+ async readFile(_path, _includeIgnored) {
24
+ return 'mock content';
25
+ }
26
+ async writeFile(_path, _content) {
27
+ return;
28
+ }
29
+ async removeFile(_path) {
30
+ return;
31
+ }
32
+ async renameFile(_sourcePath, _targetPath) {
33
+ return;
34
+ }
35
+ async listFiles(_path, _recursive, _maxCount, _includeIgnored) {
36
+ return [['mock-file.txt'], false];
37
+ }
38
+ async searchFiles(_path, _regex, _filePattern) {
39
+ return ['mock-file.txt'];
40
+ }
41
+ async executeCommand(_command, _needApprove) {
42
+ return { stdout: 'mock output', stderr: '', exitCode: 0 };
43
+ }
44
+ async askFollowupQuestion(_question, _options) {
45
+ return 'mock answer';
46
+ }
47
+ async search(_query) {
48
+ return 'mock search result';
49
+ }
50
+ async listMemoryTopics() {
51
+ return ['default'];
52
+ }
53
+ async readMemory(_topic) {
54
+ return 'mock memory content';
55
+ }
56
+ async updateMemory(_operation, _topic, _content) {
57
+ return;
58
+ }
59
+ }
60
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/tools/provider.ts"],"names":[],"mappings":"AA4DA,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,aAAa,CAAC,EAAkB,EAAE,OAAuB;QAC7D,IAAI,EAAE,EAAE,CAAC;YACP,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAe,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;QAC9F,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAe,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAU;QAC1B,OAAO;YACL,EAAE;YACF,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,WAAW;YACxB,MAAM,EAAE,MAAe;YACvB,QAAQ,EAAE,EAAE;SACb,CAAA;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;YAC9B,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAA;QACpB,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAY,EAAE,CAAA;IACnC,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,eAAyB;QACrD,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,QAAgB;QAC7C,OAAM;IACR,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,OAAM;IACR,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,WAAmB;QACvD,OAAM;IACR,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,UAAmB,EAAE,SAAiB,EAAE,eAAyB;QAC9F,OAAO,CAAC,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,CAAA;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,MAAc,EAAE,YAAoB;QACnE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,YAAqB;QAErB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,SAAiB,EAAE,QAAmB;QAC9D,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAe;QAC9B,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,UAA2C,EAAE,MAAe,EAAE,QAAiB;QAChG,OAAM;IACR,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import type { ToolHandler } from '../tool';
3
+ import type { FilesystemProvider } from './provider';
4
+ export declare const toolInfo: {
5
+ readonly name: "readBinaryFile";
6
+ readonly description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.";
7
+ readonly parameters: z.ZodObject<{
8
+ url: z.ZodString;
9
+ }, z.core.$strip>;
10
+ };
11
+ export declare const handler: ToolHandler<typeof toolInfo, FilesystemProvider>;
12
+ declare const _default: {
13
+ handler: ToolHandler<{
14
+ readonly name: "readBinaryFile";
15
+ readonly description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.";
16
+ readonly parameters: z.ZodObject<{
17
+ url: z.ZodString;
18
+ }, z.core.$strip>;
19
+ }, FilesystemProvider>;
20
+ name: "readBinaryFile";
21
+ description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.";
22
+ parameters: z.ZodObject<{
23
+ url: z.ZodString;
24
+ }, z.core.$strip>;
25
+ };
26
+ export default _default;
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ export const toolInfo = {
3
+ name: 'readBinaryFile',
4
+ description: 'Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.',
5
+ parameters: z.object({
6
+ url: z.string().describe('The URL or local path of the file to read.'),
7
+ }),
8
+ };
9
+ export const handler = async (provider, args) => {
10
+ if (!provider.readBinaryFile) {
11
+ return {
12
+ success: false,
13
+ message: {
14
+ type: 'error-text',
15
+ value: 'Not possible to fetch files. Abort.',
16
+ },
17
+ };
18
+ }
19
+ const { url } = toolInfo.parameters.parse(args);
20
+ try {
21
+ const filePart = await provider.readBinaryFile(url);
22
+ return {
23
+ success: true,
24
+ message: {
25
+ type: 'content',
26
+ value: [
27
+ {
28
+ type: 'media',
29
+ url,
30
+ data: filePart.base64Data,
31
+ mediaType: filePart.mediaType,
32
+ },
33
+ ],
34
+ },
35
+ };
36
+ }
37
+ catch (error) {
38
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
39
+ return {
40
+ success: false,
41
+ message: {
42
+ type: 'error-text',
43
+ value: `Error fetching file from ${url}: ${errorMessage}`,
44
+ },
45
+ };
46
+ }
47
+ };
48
+ export default {
49
+ ...toolInfo,
50
+ handler,
51
+ };
52
+ //# sourceMappingURL=readBinaryFile.js.map
@@ -0,0 +1 @@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KAAK;YACd,OAAO,EAAE;gBACP,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,4BAA4B,GAAG,KAAK,YAAY,EAAE;aAC1D;SACF,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,eAAe;IACb,GAAG,QAAQ;IACX,OAAO;CACe,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import type { ToolHandler } from '../tool';
3
+ import type { FilesystemProvider } from './provider';
4
+ export declare const toolInfo: {
5
+ readonly name: "readFile";
6
+ readonly description: "Request to read the contents of one or multiple files at the specified paths.\n\nWhen to use:\n- Examining file contents you don't know\n- Analyzing code, reviewing text files, extracting configuration info\n- Reading multiple files at once (use comma-separated paths)\n- Understanding file structure before editing\n\nWhen NOT to use:\n- For file existence checks: Use listFiles instead\n- For searching within files: Use grep instead\n- For file name searches: Use searchFiles instead\n- Prefer this tool over executeCommand with cat/head/tail\n\nFeatures:\n- Supports comma-separated paths for multiple files\n- Line numbers included for easy reference\n- Optional offset/limit for partial file reading\n- Automatically handles different file types\n\nIMPORTANT:\n- Line numbers are included for easy reference\n- Use offset/limit for large files to read specific sections";
7
+ readonly parameters: z.ZodObject<{
8
+ path: z.ZodPipe<z.ZodTransform<any[], unknown>, z.ZodArray<z.ZodString>>;
9
+ offset: z.ZodOptional<z.ZodNumber>;
10
+ limit: z.ZodOptional<z.ZodNumber>;
11
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
12
+ }, z.core.$strip>;
13
+ };
14
+ export declare const handler: ToolHandler<typeof toolInfo, FilesystemProvider>;
15
+ declare const _default: {
16
+ handler: ToolHandler<{
17
+ readonly name: "readFile";
18
+ readonly description: "Request to read the contents of one or multiple files at the specified paths.\n\nWhen to use:\n- Examining file contents you don't know\n- Analyzing code, reviewing text files, extracting configuration info\n- Reading multiple files at once (use comma-separated paths)\n- Understanding file structure before editing\n\nWhen NOT to use:\n- For file existence checks: Use listFiles instead\n- For searching within files: Use grep instead\n- For file name searches: Use searchFiles instead\n- Prefer this tool over executeCommand with cat/head/tail\n\nFeatures:\n- Supports comma-separated paths for multiple files\n- Line numbers included for easy reference\n- Optional offset/limit for partial file reading\n- Automatically handles different file types\n\nIMPORTANT:\n- Line numbers are included for easy reference\n- Use offset/limit for large files to read specific sections";
19
+ readonly parameters: z.ZodObject<{
20
+ path: z.ZodPipe<z.ZodTransform<any[], unknown>, z.ZodArray<z.ZodString>>;
21
+ offset: z.ZodOptional<z.ZodNumber>;
22
+ limit: z.ZodOptional<z.ZodNumber>;
23
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
24
+ }, z.core.$strip>;
25
+ }, FilesystemProvider>;
26
+ name: "readFile";
27
+ description: "Request to read the contents of one or multiple files at the specified paths.\n\nWhen to use:\n- Examining file contents you don't know\n- Analyzing code, reviewing text files, extracting configuration info\n- Reading multiple files at once (use comma-separated paths)\n- Understanding file structure before editing\n\nWhen NOT to use:\n- For file existence checks: Use listFiles instead\n- For searching within files: Use grep instead\n- For file name searches: Use searchFiles instead\n- Prefer this tool over executeCommand with cat/head/tail\n\nFeatures:\n- Supports comma-separated paths for multiple files\n- Line numbers included for easy reference\n- Optional offset/limit for partial file reading\n- Automatically handles different file types\n\nIMPORTANT:\n- Line numbers are included for easy reference\n- Use offset/limit for large files to read specific sections";
28
+ parameters: z.ZodObject<{
29
+ path: z.ZodPipe<z.ZodTransform<any[], unknown>, z.ZodArray<z.ZodString>>;
30
+ offset: z.ZodOptional<z.ZodNumber>;
31
+ limit: z.ZodOptional<z.ZodNumber>;
32
+ includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>>;
33
+ }, z.core.$strip>;
34
+ };
35
+ export default _default;
@@ -0,0 +1,128 @@
1
+ import { z } from 'zod';
2
+ import { createFileElement, createProviderError, preprocessBoolean } from './utils';
3
+ export const toolInfo = {
4
+ name: 'readFile',
5
+ description: `Request to read the contents of one or multiple files at the specified paths.
6
+
7
+ When to use:
8
+ - Examining file contents you don't know
9
+ - Analyzing code, reviewing text files, extracting configuration info
10
+ - Reading multiple files at once (use comma-separated paths)
11
+ - Understanding file structure before editing
12
+
13
+ When NOT to use:
14
+ - For file existence checks: Use listFiles instead
15
+ - For searching within files: Use grep instead
16
+ - For file name searches: Use searchFiles instead
17
+ - Prefer this tool over executeCommand with cat/head/tail
18
+
19
+ Features:
20
+ - Supports comma-separated paths for multiple files
21
+ - Line numbers included for easy reference
22
+ - Optional offset/limit for partial file reading
23
+ - Automatically handles different file types
24
+
25
+ IMPORTANT:
26
+ - Line numbers are included for easy reference
27
+ - Use offset/limit for large files to read specific sections`,
28
+ parameters: z
29
+ .object({
30
+ path: z
31
+ .preprocess((val) => {
32
+ if (!val)
33
+ return [];
34
+ // Only split by comma if the input is a string
35
+ // If it's already an array, use it as-is to support files with commas in names
36
+ if (Array.isArray(val)) {
37
+ return val.filter((s) => typeof s === 'string' && s.length > 0);
38
+ }
39
+ // Single string input - split by comma for multiple files
40
+ return val.split(',').filter((s) => s.length > 0);
41
+ }, z.array(z.string()))
42
+ .describe('The path of the file to read')
43
+ .meta({ usageValue: 'Comma separated paths here' }),
44
+ offset: z.number().optional().describe('Skip first N lines (for partial file reading)').meta({ usageValue: '100' }),
45
+ limit: z.number().optional().describe('Read at most N lines (for partial file reading)').meta({ usageValue: '50' }),
46
+ includeIgnored: z
47
+ .preprocess(preprocessBoolean, z.boolean().nullish().default(false))
48
+ .describe('Whether to include ignored files. Use true to include files ignored by .gitignore.')
49
+ .meta({ usageValue: 'true or false (optional)' }),
50
+ })
51
+ .meta({
52
+ examples: [
53
+ {
54
+ description: 'Request to read the contents of a file',
55
+ input: {
56
+ path: 'src/main.js',
57
+ },
58
+ },
59
+ {
60
+ description: 'Request to read multiple files',
61
+ input: {
62
+ path: 'src/main.js,src/index.js',
63
+ },
64
+ },
65
+ {
66
+ description: 'Read partial file (lines 100-150)',
67
+ input: {
68
+ path: 'src/large-file.ts',
69
+ offset: 100,
70
+ limit: 50,
71
+ },
72
+ },
73
+ ],
74
+ }),
75
+ };
76
+ export const handler = async (provider, args) => {
77
+ if (!provider.readFile) {
78
+ return createProviderError('read file');
79
+ }
80
+ const parsed = toolInfo.parameters.safeParse(args);
81
+ if (!parsed.success) {
82
+ return {
83
+ success: false,
84
+ message: {
85
+ type: 'error-text',
86
+ value: `Invalid arguments for readFile: ${parsed.error.message}`,
87
+ },
88
+ };
89
+ }
90
+ const { path: paths, offset, limit, includeIgnored } = parsed.data;
91
+ const resp = [];
92
+ for (const path of paths) {
93
+ const fileContent = await provider.readFile(path, includeIgnored ?? false);
94
+ if (!fileContent) {
95
+ resp.push(createFileElement('read_file_file_content', path, undefined, { file_not_found: 'true' }));
96
+ continue;
97
+ }
98
+ // Apply offset/limit if specified
99
+ let lines = fileContent.split('\n');
100
+ const start = offset ?? 0;
101
+ const end = limit ? start + limit : lines.length;
102
+ if (offset !== undefined || limit !== undefined) {
103
+ lines = lines.slice(start, end);
104
+ }
105
+ // Add line numbers
106
+ const lineOffset = offset ?? 0;
107
+ const numberedContent = lines
108
+ .map((line, i) => {
109
+ const lineNumber = lineOffset + i + 1;
110
+ const paddedNumber = String(lineNumber).padStart(6, ' ');
111
+ return `${paddedNumber}→${line}`;
112
+ })
113
+ .join('\n');
114
+ resp.push(createFileElement('read_file_file_content', path, numberedContent));
115
+ }
116
+ return {
117
+ success: true,
118
+ message: {
119
+ type: 'text',
120
+ value: resp.join('\n'),
121
+ },
122
+ };
123
+ };
124
+ export default {
125
+ ...toolInfo,
126
+ handler,
127
+ };
128
+ //# sourceMappingURL=readFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFile.js","sourceRoot":"","sources":["../../src/tools/readFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,K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AC/E,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACvB;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,GAAG,QAAQ;IACX,OAAO;CACe,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { describe, expect, it, spyOn } from 'bun:test';
2
+ import { MockProvider } from './provider';
3
+ import readFile from './readFile';
4
+ describe('readFile', () => {
5
+ it('should read single file', async () => {
6
+ const mockProvider = new MockProvider();
7
+ spyOn(mockProvider, 'readFile').mockResolvedValue('file content');
8
+ const result = await readFile.handler(mockProvider, {
9
+ path: 'file.txt',
10
+ includeIgnored: 'false',
11
+ });
12
+ expect(result).toMatchSnapshot();
13
+ expect(mockProvider.readFile).toHaveBeenCalledWith('file.txt', false);
14
+ });
15
+ it('should read multiple files', async () => {
16
+ const mockProvider = new MockProvider();
17
+ spyOn(mockProvider, 'readFile').mockResolvedValueOnce('file1 content').mockResolvedValueOnce('file2 content');
18
+ const result = await readFile.handler(mockProvider, {
19
+ path: 'file1.txt,file2.txt',
20
+ includeIgnored: 'false',
21
+ });
22
+ expect(result).toMatchSnapshot();
23
+ expect(mockProvider.readFile).toHaveBeenCalledWith('file1.txt', false);
24
+ expect(mockProvider.readFile).toHaveBeenCalledWith('file2.txt', false);
25
+ });
26
+ it('should handle file not found', async () => {
27
+ const mockProvider = new MockProvider();
28
+ spyOn(mockProvider, 'readFile').mockRejectedValue(new Error('File not found'));
29
+ const result = readFile.handler(mockProvider, {
30
+ path: 'missing.txt',
31
+ includeIgnored: 'false',
32
+ });
33
+ await expect(result).rejects.toMatchSnapshot();
34
+ expect(mockProvider.readFile).toHaveBeenCalledWith('missing.txt', false);
35
+ });
36
+ });
37
+ //# sourceMappingURL=readFile.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readF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,EAAE,KAAK,CAAC,CAAA;QACtE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACvC,KAAK,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAE9E,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE;YAC5C,IAAI,EAAE,aAAa;YACnB,cAAc,EAAE,OAAO;SACxB,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,CAAA;QAC9C,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;IAC1E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import type { ToolHandler } from '../tool';
3
+ import type { FilesystemProvider } from './provider';
4
+ export declare const toolInfo: {
5
+ readonly name: "removeFile";
6
+ readonly description: "Request to remove a file at the specified path.";
7
+ readonly parameters: z.ZodObject<{
8
+ path: z.ZodString;
9
+ }, z.core.$strip>;
10
+ };
11
+ export declare const handler: ToolHandler<typeof toolInfo, FilesystemProvider>;
12
+ declare const _default: {
13
+ handler: ToolHandler<{
14
+ readonly name: "removeFile";
15
+ readonly description: "Request to remove a file at the specified path.";
16
+ readonly parameters: z.ZodObject<{
17
+ path: z.ZodString;
18
+ }, z.core.$strip>;
19
+ }, FilesystemProvider>;
20
+ name: "removeFile";
21
+ description: "Request to remove a file at the specified path.";
22
+ parameters: z.ZodObject<{
23
+ path: z.ZodString;
24
+ }, z.core.$strip>;
25
+ };
26
+ export default _default;
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ import { createProviderError } from './utils';
3
+ export const toolInfo = {
4
+ name: 'removeFile',
5
+ description: 'Request to remove a file at the specified path.',
6
+ parameters: z
7
+ .object({
8
+ path: z.string().describe('The path of the file to remove').meta({ usageValue: 'File path here' }),
9
+ })
10
+ .meta({
11
+ examples: [
12
+ {
13
+ description: 'Request to remove a file',
14
+ input: {
15
+ path: 'src/main.js',
16
+ },
17
+ },
18
+ ],
19
+ }),
20
+ };
21
+ export const handler = async (provider, args) => {
22
+ if (!provider.removeFile) {
23
+ return createProviderError('remove file');
24
+ }
25
+ const parsed = toolInfo.parameters.safeParse(args);
26
+ if (!parsed.success) {
27
+ return {
28
+ success: false,
29
+ message: {
30
+ type: 'error-text',
31
+ value: `Invalid arguments for removeFile: ${parsed.error.message}`,
32
+ },
33
+ };
34
+ }
35
+ const { path } = parsed.data;
36
+ await provider.removeFile(path);
37
+ return {
38
+ success: true,
39
+ message: {
40
+ type: 'text',
41
+ value: `<remove_file_path>${path}</remove_file_path><status>Success</status>`,
42
+ },
43
+ };
44
+ };
45
+ export default {
46
+ ...toolInfo,
47
+ handler,
48
+ };
49
+ //# sourceMappingURL=removeFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFile.js","sourceRoot":"","sources":["../../src/tools/removeFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,iDAAiD;IAC9D,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;KACnG,CAAC;SACD,IAAI,CAAC;QACJ,QAAQ,EAAE;YACR;gBACE,WAAW,EAAE,0BAA0B;gBACvC,KAAK,EAAE;oBACL,IAAI,EAAE,aAAa;iBACpB;aACF;SACF;KACF,CAAC;CACuB,CAAA;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAqD,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAChG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAClD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,qCAAqC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;aACnE;SACF,CAAA;IACH,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAA;IAE5B,MAAM,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAE/B,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,qBAAqB,IAAI,6CAA6C;SAC9E;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,GAAG,QAAQ;IACX,OAAO;CACe,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it, spyOn } from 'bun:test';
2
+ import { MockProvider } from './provider';
3
+ import removeFile from './removeFile';
4
+ describe('removeFile', () => {
5
+ it('should remove file successfully', async () => {
6
+ const mockProvider = new MockProvider();
7
+ spyOn(mockProvider, 'removeFile').mockResolvedValue();
8
+ const result = await removeFile.handler(mockProvider, {
9
+ path: 'test.txt',
10
+ });
11
+ // Verify successful removal
12
+ expect(result).toEqual({
13
+ success: true,
14
+ message: {
15
+ type: 'text',
16
+ value: '<remove_file_path>test.txt</remove_file_path><status>Success</status>',
17
+ },
18
+ });
19
+ expect(mockProvider.removeFile).toHaveBeenCalledWith('test.txt');
20
+ });
21
+ it('should handle remove errors', async () => {
22
+ const mockProvider = new MockProvider();
23
+ spyOn(mockProvider, 'removeFile').mockRejectedValue(new Error('Remove error'));
24
+ const result = removeFile.handler(mockProvider, {
25
+ path: 'error.txt',
26
+ });
27
+ // Verify error is propagated
28
+ await expect(result).rejects.toThrow('Remove error');
29
+ expect(mockProvider.removeFile).toHaveBeenCalledWith('error.txt');
30
+ });
31
+ });
32
+ //# sourceMappingURL=removeFile.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFile.test.js","sourceRoot":"","sources":["../../src/tools/removeFile.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACvC,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,iBAAiB,EAAE,CAAA;QAErD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE;YACpD,IAAI,EAAE,UAAU;SACjB,CAAC,CAAA;QAEF,4BAA4B;QAC5B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,uEAAuE;aAC/E;SACF,CAAC,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