@mcoda/mswarm 0.1.56 → 0.1.60

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 +20 -1
  2. package/dist/codali-executor.d.ts +266 -0
  3. package/dist/codali-executor.d.ts.map +1 -0
  4. package/dist/codali-executor.js +227 -0
  5. package/dist/codali-executor.js.map +1 -0
  6. package/dist/runtime.d.ts +47 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +248 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +83 -3
  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 +113 -0
  137. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
  138. package/dist/vendor/codali/docdex/DocdexClient.js +524 -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 +183 -0
  191. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
  192. package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -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 +263 -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 +32 -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 +453 -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,287 @@
1
+ export type AgentNeed = {
2
+ type: "docdex.search";
3
+ query: string;
4
+ limit?: number;
5
+ } | {
6
+ type: "docdex.open";
7
+ path: string;
8
+ start_line?: number;
9
+ end_line?: number;
10
+ head?: number;
11
+ clamp?: boolean;
12
+ } | {
13
+ type: "docdex.snippet";
14
+ doc_id: string;
15
+ window?: number;
16
+ } | {
17
+ type: "docdex.symbols";
18
+ file: string;
19
+ } | {
20
+ type: "docdex.ast";
21
+ file: string;
22
+ max_nodes?: number;
23
+ } | {
24
+ type: "docdex.web";
25
+ query: string;
26
+ force_web?: boolean;
27
+ } | {
28
+ type: "docdex.impact";
29
+ file: string;
30
+ } | {
31
+ type: "docdex.impact_diagnostics";
32
+ file?: string;
33
+ limit?: number;
34
+ offset?: number;
35
+ } | {
36
+ type: "docdex.tree";
37
+ path?: string;
38
+ max_depth?: number;
39
+ dirs_only?: boolean;
40
+ include_hidden?: boolean;
41
+ } | {
42
+ type: "docdex.dag_export";
43
+ session_id?: string;
44
+ format?: "json" | "text" | "dot";
45
+ max_nodes?: number;
46
+ } | {
47
+ type: "file.read";
48
+ path: string;
49
+ } | {
50
+ type: "file.list";
51
+ root: string;
52
+ pattern?: string;
53
+ } | {
54
+ type: "file.diff";
55
+ paths?: string[];
56
+ } | {
57
+ type: "agent.delegate";
58
+ role?: "explorer" | "reviewer" | "worker" | "verifier" | "custom";
59
+ goal: string;
60
+ tools?: string[];
61
+ allowed_paths?: string[];
62
+ write_paths?: string[];
63
+ read_only?: boolean;
64
+ max_steps?: number;
65
+ max_tool_calls?: number;
66
+ timeout_ms?: number;
67
+ };
68
+ export type AgentRequest = {
69
+ version: "v1";
70
+ role: string;
71
+ request_id: string;
72
+ needs: AgentNeed[];
73
+ context?: {
74
+ summary?: string;
75
+ };
76
+ };
77
+ export type ParseAgentRequestOptions = {
78
+ defaultRequestId?: string;
79
+ };
80
+ export type CodaliResponseResult = {
81
+ type: "docdex.search";
82
+ query: string;
83
+ hits: unknown[];
84
+ } | {
85
+ type: "docdex.open";
86
+ path: string;
87
+ content: string;
88
+ } | {
89
+ type: "docdex.snippet";
90
+ doc_id: string;
91
+ content: string;
92
+ } | {
93
+ type: "docdex.symbols";
94
+ file: string;
95
+ symbols: unknown;
96
+ } | {
97
+ type: "docdex.ast";
98
+ file: string;
99
+ nodes: unknown;
100
+ } | {
101
+ type: "docdex.web";
102
+ query: string;
103
+ results: unknown[];
104
+ } | {
105
+ type: "docdex.impact";
106
+ file: string;
107
+ inbound: unknown[];
108
+ outbound: unknown[];
109
+ } | {
110
+ type: "docdex.impact_diagnostics";
111
+ file?: string;
112
+ diagnostics: unknown;
113
+ } | {
114
+ type: "docdex.tree";
115
+ tree: string;
116
+ } | {
117
+ type: "docdex.dag_export";
118
+ session_id: string;
119
+ format?: "json" | "text" | "dot";
120
+ content: unknown;
121
+ } | {
122
+ type: "file.read";
123
+ path: string;
124
+ content: string;
125
+ } | {
126
+ type: "file.list";
127
+ root: string;
128
+ files: string[];
129
+ } | {
130
+ type: "file.diff";
131
+ paths?: string[];
132
+ diff: string;
133
+ } | {
134
+ type: "agent.delegate";
135
+ role: string;
136
+ goal: string;
137
+ results: unknown[];
138
+ } | {
139
+ type: "patch.apply_failure";
140
+ error: string;
141
+ patches: string[];
142
+ rollback: {
143
+ attempted: boolean;
144
+ ok: boolean;
145
+ error?: string;
146
+ };
147
+ } | {
148
+ type: "critic.result";
149
+ status: "PASS" | "FAIL";
150
+ reasons: string[];
151
+ suggested_fixes?: string[];
152
+ touched_files?: string[];
153
+ plan_targets?: string[];
154
+ guardrail?: {
155
+ disposition: "retryable" | "non_retryable";
156
+ reason_code: string;
157
+ };
158
+ high_confidence?: boolean;
159
+ verification?: {
160
+ schema_version: 1;
161
+ outcome: "verified_passed" | "verified_failed" | "unverified_with_reason";
162
+ reason_codes: string[];
163
+ policy: {
164
+ policy_name: string;
165
+ minimum_checks: number;
166
+ enforce_high_confidence: boolean;
167
+ };
168
+ checks: unknown[];
169
+ totals: {
170
+ configured: number;
171
+ runnable: number;
172
+ attempted: number;
173
+ passed: number;
174
+ failed: number;
175
+ unverified: number;
176
+ };
177
+ touched_files?: string[];
178
+ language_signals?: string[];
179
+ };
180
+ };
181
+ export type CodaliResponse = {
182
+ version: "v1";
183
+ request_id: string;
184
+ results: CodaliResponseResult[];
185
+ meta?: {
186
+ repo_root?: string;
187
+ warnings?: string[];
188
+ };
189
+ };
190
+ export type NormalizedNeed = {
191
+ tool: "docdex.search";
192
+ params: {
193
+ query: string;
194
+ limit?: number;
195
+ };
196
+ } | {
197
+ tool: "docdex.open";
198
+ params: {
199
+ path: string;
200
+ start_line?: number;
201
+ end_line?: number;
202
+ head?: number;
203
+ clamp?: boolean;
204
+ };
205
+ } | {
206
+ tool: "docdex.snippet";
207
+ params: {
208
+ doc_id: string;
209
+ window?: number;
210
+ };
211
+ } | {
212
+ tool: "docdex.symbols";
213
+ params: {
214
+ file: string;
215
+ };
216
+ } | {
217
+ tool: "docdex.ast";
218
+ params: {
219
+ file: string;
220
+ max_nodes?: number;
221
+ };
222
+ } | {
223
+ tool: "docdex.web";
224
+ params: {
225
+ query: string;
226
+ force_web?: boolean;
227
+ };
228
+ } | {
229
+ tool: "docdex.impact";
230
+ params: {
231
+ file: string;
232
+ };
233
+ } | {
234
+ tool: "docdex.impact_diagnostics";
235
+ params: {
236
+ file?: string;
237
+ limit?: number;
238
+ offset?: number;
239
+ };
240
+ } | {
241
+ tool: "docdex.tree";
242
+ params: {
243
+ path?: string;
244
+ max_depth?: number;
245
+ dirs_only?: boolean;
246
+ include_hidden?: boolean;
247
+ };
248
+ } | {
249
+ tool: "docdex.dag_export";
250
+ params: {
251
+ session_id?: string;
252
+ format?: "json" | "text" | "dot";
253
+ max_nodes?: number;
254
+ };
255
+ } | {
256
+ tool: "file.read";
257
+ params: {
258
+ path: string;
259
+ };
260
+ } | {
261
+ tool: "file.list";
262
+ params: {
263
+ root: string;
264
+ pattern?: string;
265
+ };
266
+ } | {
267
+ tool: "file.diff";
268
+ params: {
269
+ paths?: string[];
270
+ };
271
+ } | {
272
+ tool: "agent.delegate";
273
+ params: {
274
+ role: "explorer" | "reviewer" | "worker" | "verifier" | "custom";
275
+ goal: string;
276
+ tools?: string[];
277
+ allowed_paths?: string[];
278
+ write_paths?: string[];
279
+ read_only?: boolean;
280
+ max_steps?: number;
281
+ max_tool_calls?: number;
282
+ timeout_ms?: number;
283
+ };
284
+ };
285
+ export declare const parseAgentRequest: (input: string, options?: ParseAgentRequestOptions) => AgentRequest;
286
+ export declare const normalizeAgentRequest: (request: AgentRequest) => NormalizedNeed[];
287
+ //# sourceMappingURL=AgentProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentProtocol.d.ts","sourceRoot":"","sources":["../../src/agents/AgentProtocol.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7G;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,2BAA2B,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,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C;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvF,GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,GACnD;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE;QACN,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;QACjE,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAqKN,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,UAAS,wBAA6B,KAAG,YA0HzF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,YAAY,KAAG,cAAc,EA8ExE,CAAC"}
@@ -0,0 +1,365 @@
1
+ const parseQuotedValue = (value) => {
2
+ const trimmed = value.trim();
3
+ if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
4
+ (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
5
+ return trimmed.slice(1, -1);
6
+ }
7
+ return trimmed;
8
+ };
9
+ const parseYamlKeyValue = (line) => {
10
+ const idx = line.indexOf(":");
11
+ if (idx === -1)
12
+ return null;
13
+ const key = line.slice(0, idx).trim();
14
+ const value = line.slice(idx + 1).trim();
15
+ if (!key)
16
+ return null;
17
+ return { key, value };
18
+ };
19
+ const parseOptionalNumber = (value) => {
20
+ if (!value)
21
+ return undefined;
22
+ const parsed = Number(value);
23
+ return Number.isFinite(parsed) ? parsed : undefined;
24
+ };
25
+ const parseOptionalBoolean = (value) => {
26
+ if (value === undefined)
27
+ return undefined;
28
+ return value.trim().toLowerCase() === "true";
29
+ };
30
+ const parseOptionalStringList = (value) => {
31
+ if (!value)
32
+ return undefined;
33
+ const normalized = value.trim().replace(/^\[/, "").replace(/\]$/, "");
34
+ const parsed = normalized
35
+ .split(",")
36
+ .map((entry) => parseQuotedValue(entry.trim()))
37
+ .filter(Boolean);
38
+ return parsed.length ? parsed : undefined;
39
+ };
40
+ const coerceNeed = (need) => {
41
+ const type = need.type?.trim();
42
+ if (!type) {
43
+ throw new Error("Agent request need missing type");
44
+ }
45
+ if (type === "docdex.search") {
46
+ const query = need.query?.trim();
47
+ if (!query)
48
+ throw new Error("docdex.search requires query");
49
+ const limit = parseOptionalNumber(need.limit);
50
+ return { type, query, limit };
51
+ }
52
+ if (type === "docdex.open") {
53
+ const path = need.path?.trim();
54
+ if (!path)
55
+ throw new Error("docdex.open requires path");
56
+ const start_line = parseOptionalNumber(need.start_line);
57
+ const end_line = parseOptionalNumber(need.end_line);
58
+ const head = parseOptionalNumber(need.head);
59
+ const clamp = parseOptionalBoolean(need.clamp);
60
+ return { type, path, start_line, end_line, head, clamp };
61
+ }
62
+ if (type === "docdex.snippet") {
63
+ const doc_id = need.doc_id?.trim();
64
+ if (!doc_id)
65
+ throw new Error("docdex.snippet requires doc_id");
66
+ const window = parseOptionalNumber(need.window);
67
+ return { type, doc_id, window };
68
+ }
69
+ if (type === "docdex.symbols") {
70
+ const file = need.file?.trim();
71
+ if (!file)
72
+ throw new Error("docdex.symbols requires file");
73
+ return { type, file };
74
+ }
75
+ if (type === "docdex.ast") {
76
+ const file = need.file?.trim();
77
+ if (!file)
78
+ throw new Error("docdex.ast requires file");
79
+ const max_nodes = parseOptionalNumber(need.max_nodes);
80
+ return { type, file, max_nodes };
81
+ }
82
+ if (type === "docdex.web") {
83
+ const query = need.query?.trim();
84
+ if (!query)
85
+ throw new Error("docdex.web requires query");
86
+ const force_web = parseOptionalBoolean(need.force_web);
87
+ return { type, query, force_web };
88
+ }
89
+ if (type === "docdex.impact") {
90
+ const file = need.file?.trim();
91
+ if (!file)
92
+ throw new Error("docdex.impact requires file");
93
+ return { type, file };
94
+ }
95
+ if (type === "docdex.impact_diagnostics") {
96
+ const file = need.file?.trim();
97
+ const limit = parseOptionalNumber(need.limit);
98
+ const offset = parseOptionalNumber(need.offset);
99
+ return { type, file: file || undefined, limit, offset };
100
+ }
101
+ if (type === "docdex.tree") {
102
+ const path = need.path?.trim();
103
+ const max_depth = parseOptionalNumber(need.max_depth);
104
+ const dirs_only = parseOptionalBoolean(need.dirs_only);
105
+ const include_hidden = parseOptionalBoolean(need.include_hidden);
106
+ return { type, path: path || undefined, max_depth, dirs_only, include_hidden };
107
+ }
108
+ if (type === "docdex.dag_export") {
109
+ const session_id = need.session_id?.trim();
110
+ const formatValue = need.format?.trim();
111
+ const format = formatValue && ["json", "text", "dot"].includes(formatValue)
112
+ ? formatValue
113
+ : undefined;
114
+ if (formatValue && !format) {
115
+ throw new Error("docdex.dag_export format must be json, text, or dot");
116
+ }
117
+ const max_nodes = parseOptionalNumber(need.max_nodes);
118
+ return { type, session_id: session_id || undefined, format, max_nodes };
119
+ }
120
+ if (type === "file.read") {
121
+ const path = need.path?.trim();
122
+ if (!path)
123
+ throw new Error("file.read requires path");
124
+ return { type, path };
125
+ }
126
+ if (type === "file.list") {
127
+ const root = need.root?.trim();
128
+ if (!root)
129
+ throw new Error("file.list requires root");
130
+ const pattern = need.pattern?.trim();
131
+ return { type, root, pattern: pattern || undefined };
132
+ }
133
+ if (type === "file.diff") {
134
+ const rawPaths = need.paths?.trim();
135
+ const paths = rawPaths
136
+ ? rawPaths
137
+ .split(",")
138
+ .map((entry) => entry.trim())
139
+ .filter(Boolean)
140
+ : undefined;
141
+ return { type, paths };
142
+ }
143
+ if (type === "agent.delegate") {
144
+ const goal = need.goal?.trim();
145
+ if (!goal)
146
+ throw new Error("agent.delegate requires goal");
147
+ const roleValue = need.role?.trim();
148
+ const role = roleValue && ["explorer", "reviewer", "worker", "verifier", "custom"].includes(roleValue)
149
+ ? roleValue
150
+ : undefined;
151
+ if (roleValue && !role) {
152
+ throw new Error("agent.delegate role must be explorer, reviewer, worker, verifier, or custom");
153
+ }
154
+ return {
155
+ type,
156
+ role,
157
+ goal,
158
+ tools: parseOptionalStringList(need.tools),
159
+ allowed_paths: parseOptionalStringList(need.allowed_paths),
160
+ write_paths: parseOptionalStringList(need.write_paths),
161
+ read_only: parseOptionalBoolean(need.read_only),
162
+ max_steps: parseOptionalNumber(need.max_steps),
163
+ max_tool_calls: parseOptionalNumber(need.max_tool_calls),
164
+ timeout_ms: parseOptionalNumber(need.timeout_ms),
165
+ };
166
+ }
167
+ throw new Error(`Unsupported need type: ${type}`);
168
+ };
169
+ export const parseAgentRequest = (input, options = {}) => {
170
+ const trimmed = input.trim();
171
+ if (!trimmed) {
172
+ throw new Error("Agent request is empty");
173
+ }
174
+ if (trimmed.startsWith("{")) {
175
+ const parsed = JSON.parse(trimmed);
176
+ if (!parsed.request_id && !options.defaultRequestId)
177
+ throw new Error("Agent request missing request_id");
178
+ if (!parsed.needs || !Array.isArray(parsed.needs) || parsed.needs.length === 0) {
179
+ throw new Error("Agent request needs must be a non-empty array");
180
+ }
181
+ return {
182
+ version: "v1",
183
+ role: parsed.role ?? "unknown",
184
+ request_id: parsed.request_id ?? options.defaultRequestId,
185
+ needs: parsed.needs,
186
+ context: parsed.context,
187
+ };
188
+ }
189
+ const lines = trimmed.split(/\r?\n/);
190
+ const header = lines.shift()?.trim();
191
+ if (!header || !/^AGENT_REQUEST\s+v1$/i.test(header)) {
192
+ throw new Error("Agent request missing AGENT_REQUEST v1 header");
193
+ }
194
+ let role = "unknown";
195
+ let request_id = "";
196
+ const needs = [];
197
+ let contextSummary;
198
+ let mode = "none";
199
+ let currentNeed = null;
200
+ for (const rawLine of lines) {
201
+ const line = rawLine.trimEnd();
202
+ if (!line.trim())
203
+ continue;
204
+ const trimmedLine = line.trim();
205
+ const isTopLevel = !/^\s/.test(rawLine);
206
+ if (trimmedLine.startsWith("needs:")) {
207
+ mode = "needs";
208
+ continue;
209
+ }
210
+ if (trimmedLine.startsWith("context:")) {
211
+ if (currentNeed) {
212
+ needs.push(coerceNeed(currentNeed));
213
+ currentNeed = null;
214
+ }
215
+ mode = "context";
216
+ continue;
217
+ }
218
+ if (isTopLevel) {
219
+ const kv = parseYamlKeyValue(trimmedLine);
220
+ if (kv && (kv.key === "role" || kv.key === "request_id")) {
221
+ if (currentNeed) {
222
+ needs.push(coerceNeed(currentNeed));
223
+ currentNeed = null;
224
+ }
225
+ if (kv.key === "role")
226
+ role = parseQuotedValue(kv.value);
227
+ if (kv.key === "request_id")
228
+ request_id = parseQuotedValue(kv.value);
229
+ continue;
230
+ }
231
+ }
232
+ if (mode === "needs") {
233
+ if (trimmedLine.startsWith("-")) {
234
+ if (currentNeed) {
235
+ needs.push(coerceNeed(currentNeed));
236
+ }
237
+ currentNeed = {};
238
+ const rest = line.replace(/^\s*-\s*/, "");
239
+ if (rest) {
240
+ const kv = parseYamlKeyValue(rest);
241
+ if (kv) {
242
+ currentNeed[kv.key] = parseQuotedValue(kv.value);
243
+ }
244
+ }
245
+ continue;
246
+ }
247
+ if (currentNeed) {
248
+ const kv = parseYamlKeyValue(trimmedLine);
249
+ if (kv) {
250
+ currentNeed[kv.key] = parseQuotedValue(kv.value);
251
+ }
252
+ continue;
253
+ }
254
+ }
255
+ if (mode === "context") {
256
+ const kv = parseYamlKeyValue(trimmedLine);
257
+ if (kv && kv.key === "summary") {
258
+ contextSummary = parseQuotedValue(kv.value);
259
+ }
260
+ continue;
261
+ }
262
+ const kv = parseYamlKeyValue(trimmedLine);
263
+ if (!kv)
264
+ continue;
265
+ if (kv.key === "role")
266
+ role = parseQuotedValue(kv.value);
267
+ if (kv.key === "request_id")
268
+ request_id = parseQuotedValue(kv.value);
269
+ }
270
+ if (currentNeed) {
271
+ needs.push(coerceNeed(currentNeed));
272
+ }
273
+ if (!request_id) {
274
+ if (!options.defaultRequestId)
275
+ throw new Error("Agent request missing request_id");
276
+ request_id = options.defaultRequestId;
277
+ }
278
+ if (needs.length === 0)
279
+ throw new Error("Agent request needs must be a non-empty array");
280
+ return {
281
+ version: "v1",
282
+ role,
283
+ request_id,
284
+ needs,
285
+ context: contextSummary ? { summary: contextSummary } : undefined,
286
+ };
287
+ };
288
+ export const normalizeAgentRequest = (request) => request.needs.map((need) => {
289
+ if (need.type === "docdex.search") {
290
+ return { tool: "docdex.search", params: { query: need.query, limit: need.limit } };
291
+ }
292
+ if (need.type === "docdex.open") {
293
+ return {
294
+ tool: "docdex.open",
295
+ params: {
296
+ path: need.path,
297
+ start_line: need.start_line,
298
+ end_line: need.end_line,
299
+ head: need.head,
300
+ clamp: need.clamp,
301
+ },
302
+ };
303
+ }
304
+ if (need.type === "docdex.snippet") {
305
+ return { tool: "docdex.snippet", params: { doc_id: need.doc_id, window: need.window } };
306
+ }
307
+ if (need.type === "docdex.symbols") {
308
+ return { tool: "docdex.symbols", params: { file: need.file } };
309
+ }
310
+ if (need.type === "docdex.ast") {
311
+ return { tool: "docdex.ast", params: { file: need.file, max_nodes: need.max_nodes } };
312
+ }
313
+ if (need.type === "docdex.web") {
314
+ return { tool: "docdex.web", params: { query: need.query, force_web: need.force_web } };
315
+ }
316
+ if (need.type === "docdex.impact") {
317
+ return { tool: "docdex.impact", params: { file: need.file } };
318
+ }
319
+ if (need.type === "docdex.impact_diagnostics") {
320
+ return {
321
+ tool: "docdex.impact_diagnostics",
322
+ params: { file: need.file, limit: need.limit, offset: need.offset },
323
+ };
324
+ }
325
+ if (need.type === "docdex.tree") {
326
+ return {
327
+ tool: "docdex.tree",
328
+ params: {
329
+ path: need.path,
330
+ max_depth: need.max_depth,
331
+ dirs_only: need.dirs_only,
332
+ include_hidden: need.include_hidden,
333
+ },
334
+ };
335
+ }
336
+ if (need.type === "docdex.dag_export") {
337
+ return {
338
+ tool: "docdex.dag_export",
339
+ params: { session_id: need.session_id, format: need.format, max_nodes: need.max_nodes },
340
+ };
341
+ }
342
+ if (need.type === "file.list") {
343
+ return { tool: "file.list", params: { root: need.root, pattern: need.pattern } };
344
+ }
345
+ if (need.type === "file.diff") {
346
+ return { tool: "file.diff", params: { paths: need.paths } };
347
+ }
348
+ if (need.type === "agent.delegate") {
349
+ return {
350
+ tool: "agent.delegate",
351
+ params: {
352
+ role: need.role ?? "explorer",
353
+ goal: need.goal,
354
+ tools: need.tools,
355
+ allowed_paths: need.allowed_paths,
356
+ write_paths: need.write_paths,
357
+ read_only: need.read_only,
358
+ max_steps: need.max_steps,
359
+ max_tool_calls: need.max_tool_calls,
360
+ timeout_ms: need.timeout_ms,
361
+ },
362
+ };
363
+ }
364
+ return { tool: "file.read", params: { path: need.path } };
365
+ });
@@ -0,0 +1,23 @@
1
+ import { GlobalRepository } from "@mcoda/db";
2
+ import { type Agent } from "@mcoda/shared";
3
+ export interface AgentResolutionOverrides {
4
+ provider?: string;
5
+ model?: string;
6
+ baseUrl?: string;
7
+ apiKey?: string;
8
+ }
9
+ export interface ResolvedAgentConfig {
10
+ agent: Agent;
11
+ provider: string;
12
+ model: string;
13
+ baseUrl?: string;
14
+ apiKey?: string;
15
+ requiresApiKey: boolean;
16
+ }
17
+ export declare const resolveProviderFromAdapter: (adapter: string, explicitProvider?: string) => {
18
+ provider: string;
19
+ requiresApiKey: boolean;
20
+ };
21
+ export declare const resolveAgentConfigFromRecord: (agent: Agent, repo: GlobalRepository, overrides?: AgentResolutionOverrides) => Promise<ResolvedAgentConfig>;
22
+ export declare const resolveAgentConfig: (agentRef: string, overrides?: AgentResolutionOverrides) => Promise<ResolvedAgentConfig>;
23
+ //# sourceMappingURL=AgentResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentResolver.d.ts","sourceRoot":"","sources":["../../src/agents/AgentResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CACzB;AAoBD,eAAO,MAAM,0BAA0B,GACrC,SAAS,MAAM,EACf,mBAAmB,MAAM,KACxB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAwB7C,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,OAAO,KAAK,EACZ,MAAM,gBAAgB,EACtB,YAAW,wBAA6B,KACvC,OAAO,CAAC,mBAAmB,CAsC7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,YAAW,wBAA6B,KACvC,OAAO,CAAC,mBAAmB,CAY7B,CAAC"}