@mcoda/mswarm 0.1.57 → 0.1.61

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/README.md +19 -0
  2. package/dist/codali-executor.d.ts +278 -0
  3. package/dist/codali-executor.d.ts.map +1 -0
  4. package/dist/codali-executor.js +243 -0
  5. package/dist/codali-executor.js.map +1 -0
  6. package/dist/runtime.d.ts +46 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +298 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +66 -1
  12. package/dist/server.js.map +1 -1
  13. package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
  14. package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
  15. package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
  16. package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
  17. package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
  18. package/dist/vendor/codali/agents/AgentResolver.js +77 -0
  19. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
  20. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
  21. package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
  22. package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
  23. package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
  24. package/dist/vendor/codali/cli/EvalCommand.js +333 -0
  25. package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
  26. package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
  27. package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
  28. package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
  29. package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
  30. package/dist/vendor/codali/cli/RunCommand.js +2261 -0
  31. package/dist/vendor/codali/cli.d.ts +3 -0
  32. package/dist/vendor/codali/cli.d.ts.map +1 -0
  33. package/dist/vendor/codali/cli.js +109 -0
  34. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
  35. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
  36. package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
  37. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
  38. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
  39. package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
  40. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
  41. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
  42. package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
  43. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
  44. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
  45. package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
  46. package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
  47. package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
  48. package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
  49. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
  50. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
  51. package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
  52. package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
  53. package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
  54. package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
  55. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
  56. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
  57. package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
  58. package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
  59. package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
  60. package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
  61. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
  62. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
  63. package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
  64. package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
  65. package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
  66. package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
  67. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
  68. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
  69. package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
  70. package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
  71. package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
  72. package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
  73. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
  74. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
  75. package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
  76. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
  77. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
  78. package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
  79. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
  80. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
  81. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
  82. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
  83. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
  84. package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
  85. package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
  86. package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
  87. package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
  88. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
  89. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
  90. package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
  91. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
  92. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
  93. package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
  94. package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
  95. package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
  96. package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
  97. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
  98. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
  99. package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
  100. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
  101. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
  102. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
  103. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
  104. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
  105. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
  106. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
  107. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
  108. package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
  109. package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
  110. package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
  111. package/dist/vendor/codali/cognitive/Prompts.js +326 -0
  112. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
  113. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
  114. package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
  115. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
  116. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
  117. package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
  118. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
  119. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
  120. package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
  121. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
  122. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
  123. package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
  124. package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
  125. package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
  126. package/dist/vendor/codali/cognitive/Types.js +7 -0
  127. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
  128. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
  129. package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
  130. package/dist/vendor/codali/config/Config.d.ts +249 -0
  131. package/dist/vendor/codali/config/Config.d.ts.map +1 -0
  132. package/dist/vendor/codali/config/Config.js +200 -0
  133. package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
  134. package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
  135. package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
  136. package/dist/vendor/codali/docdex/DocdexClient.d.ts +158 -0
  137. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
  138. package/dist/vendor/codali/docdex/DocdexClient.js +785 -0
  139. package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
  140. package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
  141. package/dist/vendor/codali/eval/EvalRunner.js +38 -0
  142. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
  143. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
  144. package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
  145. package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
  146. package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
  147. package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
  148. package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
  149. package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
  150. package/dist/vendor/codali/eval/MetricTypes.js +1 -0
  151. package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
  152. package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
  153. package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
  154. package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
  155. package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
  156. package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
  157. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
  158. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
  159. package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
  160. package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
  161. package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
  162. package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
  163. package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
  164. package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
  165. package/dist/vendor/codali/eval/ReportStore.js +96 -0
  166. package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
  167. package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
  168. package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
  169. package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
  170. package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
  171. package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
  172. package/dist/vendor/codali/index.d.ts +11 -0
  173. package/dist/vendor/codali/index.d.ts.map +1 -0
  174. package/dist/vendor/codali/index.js +5 -0
  175. package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
  176. package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
  177. package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
  178. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
  179. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
  180. package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
  181. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
  182. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
  183. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
  184. package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
  185. package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
  186. package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
  187. package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
  188. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
  189. package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
  190. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +189 -0
  191. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
  192. package/dist/vendor/codali/runtime/CodaliRuntime.js +1435 -0
  193. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
  194. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
  195. package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
  196. package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
  197. package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
  198. package/dist/vendor/codali/runtime/RunContext.js +51 -0
  199. package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
  200. package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
  201. package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
  202. package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
  203. package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
  204. package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
  205. package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
  206. package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
  207. package/dist/vendor/codali/runtime/RunLogger.js +100 -0
  208. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
  209. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
  210. package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
  211. package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
  212. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
  213. package/dist/vendor/codali/runtime/Runner.js +215 -0
  214. package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
  215. package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
  216. package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
  217. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
  218. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
  219. package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
  220. package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
  221. package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
  222. package/dist/vendor/codali/session/InstructionLoader.js +107 -0
  223. package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
  224. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
  225. package/dist/vendor/codali/session/SessionStore.js +244 -0
  226. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
  227. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
  228. package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
  229. package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
  230. package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
  231. package/dist/vendor/codali/tools/ToolRegistry.js +293 -0
  232. package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
  233. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
  234. package/dist/vendor/codali/tools/ToolTypes.js +40 -0
  235. package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
  236. package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
  237. package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
  238. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
  239. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
  240. package/dist/vendor/codali/tools/docdex/DocdexTools.js +490 -0
  241. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
  242. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
  243. package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
  244. package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
  245. package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
  246. package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
  247. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
  248. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
  249. package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
  250. package/package.json +5 -3
@@ -0,0 +1,490 @@
1
+ const toOutput = (payload) => ({
2
+ output: typeof payload === "string" ? payload : JSON.stringify(payload, null, 2),
3
+ data: payload,
4
+ });
5
+ export const createDocdexTools = (client) => [
6
+ {
7
+ name: "docdex_health",
8
+ description: "Check docdex healthz endpoint.",
9
+ inputSchema: { type: "object", properties: {} },
10
+ handler: async () => {
11
+ const ok = await client.healthCheck();
12
+ return toOutput({ ok });
13
+ },
14
+ },
15
+ {
16
+ name: "docdex_initialize",
17
+ description: "Initialize docdex repo binding.",
18
+ inputSchema: {
19
+ type: "object",
20
+ required: ["rootUri"],
21
+ properties: {
22
+ rootUri: { type: "string" },
23
+ },
24
+ },
25
+ handler: async (args) => {
26
+ const { rootUri } = args;
27
+ const result = await client.initialize(rootUri);
28
+ return toOutput(result);
29
+ },
30
+ },
31
+ {
32
+ name: "docdex_search",
33
+ description: "Search docdex index.",
34
+ inputSchema: {
35
+ type: "object",
36
+ required: ["query"],
37
+ properties: {
38
+ query: { type: "string" },
39
+ limit: { type: "number" },
40
+ },
41
+ },
42
+ handler: async (args) => {
43
+ const { query, limit } = args;
44
+ const result = await client.search(query, { limit });
45
+ return toOutput(result);
46
+ },
47
+ },
48
+ {
49
+ name: "docdex_open",
50
+ description: "Open a file by path or fetch a snippet by doc id.",
51
+ inputSchema: {
52
+ type: "object",
53
+ properties: {
54
+ docId: { type: "string" },
55
+ path: { type: "string" },
56
+ window: { type: "number" },
57
+ textOnly: { type: "boolean" },
58
+ startLine: { type: "number" },
59
+ endLine: { type: "number" },
60
+ head: { type: "number" },
61
+ clamp: { type: "boolean" },
62
+ },
63
+ },
64
+ handler: async (args) => {
65
+ const { docId, path, window, textOnly, startLine, endLine, head, clamp } = args;
66
+ if (path) {
67
+ const result = await client.openFile(path, { startLine, endLine, head, clamp });
68
+ return toOutput(result);
69
+ }
70
+ if (!docId) {
71
+ throw new Error("docdex_open requires either docId or path");
72
+ }
73
+ const result = await client.openSnippet(docId, { window, textOnly });
74
+ return toOutput(result);
75
+ },
76
+ },
77
+ {
78
+ name: "docdex_symbols",
79
+ description: "Fetch docdex symbols for a file.",
80
+ inputSchema: {
81
+ type: "object",
82
+ required: ["path"],
83
+ properties: {
84
+ path: { type: "string" },
85
+ },
86
+ },
87
+ handler: async (args) => {
88
+ const { path } = args;
89
+ const result = await client.symbols(path);
90
+ return toOutput(result);
91
+ },
92
+ },
93
+ {
94
+ name: "docdex_ast",
95
+ description: "Fetch docdex AST nodes for a file.",
96
+ inputSchema: {
97
+ type: "object",
98
+ required: ["path"],
99
+ properties: {
100
+ path: { type: "string" },
101
+ maxNodes: { type: "number" },
102
+ },
103
+ },
104
+ handler: async (args) => {
105
+ const { path, maxNodes } = args;
106
+ const result = await client.ast(path, maxNodes);
107
+ return toOutput(result);
108
+ },
109
+ },
110
+ {
111
+ name: "docdex_impact_graph",
112
+ description: "Fetch docdex impact graph for a file.",
113
+ inputSchema: {
114
+ type: "object",
115
+ required: ["file"],
116
+ properties: {
117
+ file: { type: "string" },
118
+ maxDepth: { type: "number" },
119
+ maxEdges: { type: "number" },
120
+ edgeTypes: { type: "array", items: { type: "string" } },
121
+ },
122
+ },
123
+ handler: async (args) => {
124
+ const { file, maxDepth, maxEdges, edgeTypes } = args;
125
+ const result = await client.impactGraph(file, { maxDepth, maxEdges, edgeTypes });
126
+ return toOutput(result);
127
+ },
128
+ },
129
+ {
130
+ name: "docdex_impact_diagnostics",
131
+ description: "Fetch docdex impact diagnostics (dynamic imports).",
132
+ inputSchema: {
133
+ type: "object",
134
+ properties: {
135
+ file: { type: "string" },
136
+ limit: { type: "number" },
137
+ offset: { type: "number" },
138
+ },
139
+ },
140
+ handler: async (args) => {
141
+ const { file, limit, offset } = args;
142
+ const result = await client.impactDiagnostics({ file, limit, offset });
143
+ return toOutput(result);
144
+ },
145
+ },
146
+ {
147
+ name: "docdex_dag_export",
148
+ description: "Export docdex DAG for a session.",
149
+ inputSchema: {
150
+ type: "object",
151
+ required: ["sessionId"],
152
+ properties: {
153
+ sessionId: { type: "string" },
154
+ format: { type: "string" },
155
+ maxNodes: { type: "number" },
156
+ },
157
+ },
158
+ handler: async (args) => {
159
+ const { sessionId, format, maxNodes } = args;
160
+ const result = await client.dagExport(sessionId, { format, maxNodes });
161
+ return toOutput(result);
162
+ },
163
+ },
164
+ {
165
+ name: "docdex_tree",
166
+ description: "Render a folder tree from docdex.",
167
+ inputSchema: {
168
+ type: "object",
169
+ properties: {
170
+ path: { type: "string" },
171
+ maxDepth: { type: "number" },
172
+ dirsOnly: { type: "boolean" },
173
+ includeHidden: { type: "boolean" },
174
+ extraExcludes: { type: "array", items: { type: "string" } },
175
+ },
176
+ },
177
+ handler: async (args) => {
178
+ const { path, maxDepth, dirsOnly, includeHidden, extraExcludes } = args;
179
+ const result = await client.tree({ path, maxDepth, dirsOnly, includeHidden, extraExcludes });
180
+ return toOutput(result);
181
+ },
182
+ },
183
+ {
184
+ name: "docdex_open_file",
185
+ description: "Open a file by path via docdex (MCP).",
186
+ inputSchema: {
187
+ type: "object",
188
+ required: ["path"],
189
+ properties: {
190
+ path: { type: "string" },
191
+ startLine: { type: "number" },
192
+ endLine: { type: "number" },
193
+ head: { type: "number" },
194
+ clamp: { type: "boolean" },
195
+ },
196
+ },
197
+ handler: async (args) => {
198
+ const { path, startLine, endLine, head, clamp } = args;
199
+ const result = await client.openFile(path, { startLine, endLine, head, clamp });
200
+ return toOutput(result);
201
+ },
202
+ },
203
+ {
204
+ name: "docdex_memory_save",
205
+ description: "Store repo memory in docdex.",
206
+ inputSchema: {
207
+ type: "object",
208
+ required: ["text"],
209
+ properties: {
210
+ text: { type: "string" },
211
+ },
212
+ },
213
+ handler: async (args) => {
214
+ const { text } = args;
215
+ const result = await client.memorySave(text);
216
+ return toOutput(result);
217
+ },
218
+ },
219
+ {
220
+ name: "docdex_get_profile",
221
+ description: "Fetch docdex profile preferences.",
222
+ inputSchema: {
223
+ type: "object",
224
+ properties: {
225
+ agentId: { type: "string" },
226
+ },
227
+ },
228
+ handler: async (args) => {
229
+ const { agentId } = args;
230
+ const result = await client.getProfile(agentId);
231
+ return toOutput(result);
232
+ },
233
+ },
234
+ {
235
+ name: "docdex_save_preference",
236
+ description: "Save a docdex profile preference.",
237
+ inputSchema: {
238
+ type: "object",
239
+ required: ["agentId", "category", "content"],
240
+ properties: {
241
+ agentId: { type: "string" },
242
+ category: { type: "string" },
243
+ content: { type: "string" },
244
+ },
245
+ },
246
+ handler: async (args) => {
247
+ const { agentId, category, content } = args;
248
+ const result = await client.savePreference(agentId, category, content);
249
+ return toOutput(result);
250
+ },
251
+ },
252
+ {
253
+ name: "docdex_memory_recall",
254
+ description: "Recall repo memory from docdex.",
255
+ inputSchema: {
256
+ type: "object",
257
+ required: ["query"],
258
+ properties: {
259
+ query: { type: "string" },
260
+ topK: { type: "number" },
261
+ },
262
+ },
263
+ handler: async (args) => {
264
+ const { query, topK } = args;
265
+ const result = await client.memoryRecall(query, topK);
266
+ return toOutput(result);
267
+ },
268
+ },
269
+ {
270
+ name: "docdex_web_research",
271
+ description: "Run docdex web research (requires DOCDEX_WEB_ENABLED=1).",
272
+ inputSchema: {
273
+ type: "object",
274
+ required: ["query"],
275
+ properties: {
276
+ query: { type: "string" },
277
+ forceWeb: { type: "boolean" },
278
+ skipLocalSearch: { type: "boolean" },
279
+ webLimit: { type: "number" },
280
+ noCache: { type: "boolean" },
281
+ },
282
+ },
283
+ handler: async (args) => {
284
+ const { query, forceWeb, skipLocalSearch, webLimit, noCache } = args;
285
+ const result = await client.webResearch(query, { forceWeb, skipLocalSearch, webLimit, noCache });
286
+ return toOutput(result);
287
+ },
288
+ },
289
+ {
290
+ name: "docdex_chat_context",
291
+ description: "Ask docdex OpenAI-compatible chat with repo/profile/wake-up context.",
292
+ inputSchema: {
293
+ type: "object",
294
+ required: ["messages"],
295
+ properties: {
296
+ messages: {
297
+ type: "array",
298
+ items: {
299
+ type: "object",
300
+ required: ["role", "content"],
301
+ properties: {
302
+ role: { type: "string" },
303
+ content: {
304
+ anyOf: [
305
+ { type: "string" },
306
+ { type: "array", items: { type: "object" } },
307
+ ],
308
+ },
309
+ name: { type: "string" },
310
+ tool_call_id: { type: "string" },
311
+ },
312
+ },
313
+ },
314
+ model: { type: "string" },
315
+ maxTokens: { type: "number" },
316
+ temperature: { type: "number" },
317
+ docdex: { type: "object" },
318
+ },
319
+ },
320
+ handler: async (args) => {
321
+ const { messages, model, maxTokens, temperature, docdex } = args;
322
+ const result = await client.chatContext(messages, { model, maxTokens, temperature, docdex });
323
+ return toOutput(result);
324
+ },
325
+ },
326
+ {
327
+ name: "docdex_rerank",
328
+ description: "Rerank candidate hits using docdex optional rerank flow.",
329
+ inputSchema: {
330
+ type: "object",
331
+ required: ["query", "candidates"],
332
+ properties: {
333
+ query: { type: "string" },
334
+ candidates: { type: "array", items: { type: "object" } },
335
+ limit: { type: "number" },
336
+ },
337
+ },
338
+ handler: async (args) => {
339
+ const { query, candidates, limit } = args;
340
+ const result = await client.rerank(query, candidates, limit);
341
+ return toOutput(result);
342
+ },
343
+ },
344
+ {
345
+ name: "docdex_batch_search",
346
+ description: "Run batched docdex search queries via optional batch endpoint/tool.",
347
+ inputSchema: {
348
+ type: "object",
349
+ required: ["queries"],
350
+ properties: {
351
+ queries: { type: "array", items: { type: "string" } },
352
+ limit: { type: "number" },
353
+ includeLibs: { type: "boolean" },
354
+ },
355
+ },
356
+ handler: async (args) => {
357
+ const { queries, limit, includeLibs } = args;
358
+ const result = await client.batchSearch(queries, { limit, includeLibs });
359
+ return toOutput(result);
360
+ },
361
+ },
362
+ {
363
+ name: "docdex_capabilities",
364
+ description: "Probe optional docdex retrieval capability support and cache per run.",
365
+ inputSchema: {
366
+ type: "object",
367
+ properties: {
368
+ forceRefresh: { type: "boolean" },
369
+ },
370
+ },
371
+ handler: async (args) => {
372
+ const { forceRefresh } = args ?? {};
373
+ const result = await client.getCapabilities(forceRefresh ?? false);
374
+ return toOutput(result);
375
+ },
376
+ },
377
+ {
378
+ name: "docdex_stats",
379
+ description: "Fetch docdex index stats.",
380
+ inputSchema: { type: "object", properties: {} },
381
+ handler: async () => {
382
+ const result = await client.stats();
383
+ return toOutput(result);
384
+ },
385
+ },
386
+ {
387
+ name: "docdex_files",
388
+ description: "List docdex indexed files.",
389
+ inputSchema: {
390
+ type: "object",
391
+ properties: {
392
+ limit: { type: "number" },
393
+ offset: { type: "number" },
394
+ },
395
+ },
396
+ handler: async (args) => {
397
+ const { limit, offset } = args ?? {};
398
+ const result = await client.files(limit, offset);
399
+ return toOutput(result);
400
+ },
401
+ },
402
+ {
403
+ name: "docdex_repo_inspect",
404
+ description: "Inspect docdex repo mapping.",
405
+ inputSchema: { type: "object", properties: {} },
406
+ handler: async () => {
407
+ const result = await client.repoInspect();
408
+ return toOutput(result);
409
+ },
410
+ },
411
+ {
412
+ name: "docdex_index_rebuild",
413
+ description: "Rebuild docdex index.",
414
+ inputSchema: {
415
+ type: "object",
416
+ properties: {
417
+ libsSources: { type: "string" },
418
+ },
419
+ },
420
+ handler: async (args) => {
421
+ const { libsSources } = args;
422
+ const result = await client.indexRebuild(libsSources);
423
+ return toOutput(result);
424
+ },
425
+ },
426
+ {
427
+ name: "docdex_index_ingest",
428
+ description: "Ingest a single file into the docdex index.",
429
+ inputSchema: {
430
+ type: "object",
431
+ required: ["file"],
432
+ properties: {
433
+ file: { type: "string" },
434
+ },
435
+ },
436
+ handler: async (args) => {
437
+ const { file } = args;
438
+ const result = await client.indexIngest(file);
439
+ return toOutput(result);
440
+ },
441
+ },
442
+ {
443
+ name: "docdex_delegate",
444
+ description: "Run a local completion via docdex delegation.",
445
+ inputSchema: {
446
+ type: "object",
447
+ required: ["taskType", "instruction", "context"],
448
+ properties: {
449
+ taskType: { type: "string" },
450
+ instruction: { type: "string" },
451
+ context: { type: "string" },
452
+ agent: { type: "string" },
453
+ maxTokens: { type: "number" },
454
+ timeoutMs: { type: "number" },
455
+ mode: { type: "string" },
456
+ maxContextChars: { type: "number" },
457
+ },
458
+ },
459
+ handler: async (args) => {
460
+ const { taskType, instruction, context, agent, maxTokens, timeoutMs, mode, maxContextChars, } = args;
461
+ const result = await client.delegate({
462
+ task_type: taskType,
463
+ instruction,
464
+ context,
465
+ agent,
466
+ max_tokens: maxTokens,
467
+ timeout_ms: timeoutMs,
468
+ mode,
469
+ max_context_chars: maxContextChars,
470
+ });
471
+ return toOutput(result);
472
+ },
473
+ },
474
+ {
475
+ name: "docdex_hooks_validate",
476
+ description: "Run docdex validation hooks for a list of files.",
477
+ inputSchema: {
478
+ type: "object",
479
+ required: ["files"],
480
+ properties: {
481
+ files: { type: "array", items: { type: "string" } },
482
+ },
483
+ },
484
+ handler: async (args) => {
485
+ const { files } = args;
486
+ const result = await client.hooksValidate(files);
487
+ return toOutput(result);
488
+ },
489
+ },
490
+ ];
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from "../ToolTypes.js";
2
+ export declare const createFileTools: () => ToolDefinition[];
3
+ //# sourceMappingURL=FileTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAgEnE,eAAO,MAAM,eAAe,QAAO,cAAc,EAwFhD,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ const resolveWorkspacePath = (context, targetPath) => {
4
+ const resolved = path.resolve(context.workspaceRoot, targetPath);
5
+ if (context.allowOutsideWorkspace) {
6
+ return resolved;
7
+ }
8
+ const relative = path.relative(context.workspaceRoot, resolved);
9
+ if (relative.startsWith("..") || path.isAbsolute(relative)) {
10
+ throw new Error("Path is outside the workspace root");
11
+ }
12
+ return resolved;
13
+ };
14
+ const toRelative = (context, targetPath) => {
15
+ return path.relative(context.workspaceRoot, targetPath) || ".";
16
+ };
17
+ const normalizeScope = (value) => {
18
+ const normalized = path.posix.normalize(value.replace(/\\/g, "/")).replace(/^\/+/, "");
19
+ if (!normalized || normalized === ".")
20
+ return ".";
21
+ if (normalized === ".." || normalized.startsWith("../")) {
22
+ throw new Error("Path scope is outside the workspace root");
23
+ }
24
+ return normalized;
25
+ };
26
+ const isWithinScope = (relativePath, scope) => {
27
+ if (scope === ".")
28
+ return true;
29
+ return relativePath === scope || relativePath.startsWith(`${scope}/`);
30
+ };
31
+ const assertPathScope = (context, resolvedPath, scopes, action) => {
32
+ if (!scopes?.length)
33
+ return;
34
+ const relativePath = normalizeScope(toRelative(context, resolvedPath));
35
+ const normalizedScopes = scopes.map(normalizeScope);
36
+ if (!normalizedScopes.some((scope) => isWithinScope(relativePath, scope))) {
37
+ throw new Error(`Path is outside allowed ${action} scopes`);
38
+ }
39
+ };
40
+ const listFilesRecursive = async (basePath, maxDepth, currentDepth = 0, entries = []) => {
41
+ if (currentDepth > maxDepth)
42
+ return entries;
43
+ const dirEntries = await fs.readdir(basePath, { withFileTypes: true });
44
+ for (const entry of dirEntries) {
45
+ const fullPath = path.join(basePath, entry.name);
46
+ entries.push(fullPath);
47
+ if (entry.isDirectory()) {
48
+ await listFilesRecursive(fullPath, maxDepth, currentDepth + 1, entries);
49
+ }
50
+ }
51
+ return entries;
52
+ };
53
+ export const createFileTools = () => {
54
+ return [
55
+ {
56
+ name: "read_file",
57
+ description: "Read a text file from the workspace.",
58
+ inputSchema: {
59
+ type: "object",
60
+ required: ["path"],
61
+ properties: {
62
+ path: { type: "string" },
63
+ },
64
+ },
65
+ handler: async (args, context) => {
66
+ const { path: target } = args;
67
+ const resolved = resolveWorkspacePath(context, target);
68
+ assertPathScope(context, resolved, context.allowedReadPaths, "read");
69
+ const content = await fs.readFile(resolved, "utf8");
70
+ return { output: content };
71
+ },
72
+ },
73
+ {
74
+ name: "write_file",
75
+ description: "Write content to a file inside the workspace.",
76
+ inputSchema: {
77
+ type: "object",
78
+ required: ["path", "content"],
79
+ properties: {
80
+ path: { type: "string" },
81
+ content: { type: "string" },
82
+ },
83
+ },
84
+ handler: async (args, context) => {
85
+ const { path: target, content } = args;
86
+ const resolved = resolveWorkspacePath(context, target);
87
+ assertPathScope(context, resolved, context.allowedWritePaths, "write");
88
+ await fs.mkdir(path.dirname(resolved), { recursive: true });
89
+ await fs.writeFile(resolved, content, "utf8");
90
+ if (context.recordTouchedFile) {
91
+ context.recordTouchedFile(toRelative(context, resolved));
92
+ }
93
+ return { output: `Wrote ${toRelative(context, resolved)}` };
94
+ },
95
+ },
96
+ {
97
+ name: "list_files",
98
+ description: "List files under a directory within the workspace.",
99
+ inputSchema: {
100
+ type: "object",
101
+ properties: {
102
+ path: { type: "string" },
103
+ maxDepth: { type: "number" },
104
+ },
105
+ },
106
+ handler: async (args, context) => {
107
+ const { path: target = ".", maxDepth = 2 } = args ?? {};
108
+ const resolved = resolveWorkspacePath(context, target);
109
+ assertPathScope(context, resolved, context.allowedReadPaths, "read");
110
+ const entries = await listFilesRecursive(resolved, maxDepth);
111
+ const relativeEntries = entries.map((entry) => toRelative(context, entry));
112
+ return { output: relativeEntries.join("\n"), data: { entries: relativeEntries } };
113
+ },
114
+ },
115
+ {
116
+ name: "stat_path",
117
+ description: "Get stat info for a file or directory.",
118
+ inputSchema: {
119
+ type: "object",
120
+ required: ["path"],
121
+ properties: {
122
+ path: { type: "string" },
123
+ },
124
+ },
125
+ handler: async (args, context) => {
126
+ const { path: target } = args;
127
+ const resolved = resolveWorkspacePath(context, target);
128
+ assertPathScope(context, resolved, context.allowedReadPaths, "read");
129
+ const stats = await fs.stat(resolved);
130
+ const info = {
131
+ path: toRelative(context, resolved),
132
+ isFile: stats.isFile(),
133
+ isDirectory: stats.isDirectory(),
134
+ size: stats.size,
135
+ mtimeMs: stats.mtimeMs,
136
+ };
137
+ return { output: JSON.stringify(info, null, 2), data: info };
138
+ },
139
+ },
140
+ ];
141
+ };
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from "../ToolTypes.js";
2
+ export declare const createSearchTool: () => ToolDefinition;
3
+ //# sourceMappingURL=SearchTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchTool.d.ts","sourceRoot":"","sources":["../../../src/tools/search/SearchTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA0BnE,eAAO,MAAM,gBAAgB,QAAO,cAwBlC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { spawnSync } from "node:child_process";
2
+ const runCommand = (cmd, args, cwd) => {
3
+ const result = spawnSync(cmd, args, { cwd, encoding: "utf8" });
4
+ if (result.error) {
5
+ return { ok: false, output: "", error: result.error.message };
6
+ }
7
+ if (result.status !== 0 && result.status !== 1) {
8
+ return { ok: false, output: result.stdout ?? "", error: result.stderr ?? "" };
9
+ }
10
+ return { ok: true, output: result.stdout ?? "" };
11
+ };
12
+ const runRipgrep = (query, glob, cwd) => {
13
+ const args = ["--line-number", "--column", "--no-heading", "--color", "never"];
14
+ if (glob) {
15
+ args.push("--glob", glob);
16
+ }
17
+ args.push(query, ".");
18
+ return runCommand("rg", args, cwd);
19
+ };
20
+ const runGrepFallback = (query, cwd) => {
21
+ return runCommand("grep", ["-R", "-n", query, "."], cwd);
22
+ };
23
+ export const createSearchTool = () => ({
24
+ name: "search_repo",
25
+ description: "Search for text in the workspace using rg when available.",
26
+ inputSchema: {
27
+ type: "object",
28
+ required: ["query"],
29
+ properties: {
30
+ query: { type: "string" },
31
+ glob: { type: "string" },
32
+ },
33
+ },
34
+ handler: async (args, context) => {
35
+ const { query, glob } = args;
36
+ let result = runRipgrep(query, glob, context.workspaceRoot);
37
+ if (!result.ok) {
38
+ const fallback = runGrepFallback(query, context.workspaceRoot);
39
+ if (fallback.ok) {
40
+ result = fallback;
41
+ }
42
+ }
43
+ const lines = result.output.split("\n").filter(Boolean).slice(0, 200);
44
+ return { output: lines.join("\n"), data: { count: lines.length } };
45
+ },
46
+ });