@mcoda/mswarm 0.1.57 → 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 +19 -0
  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 +36 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +219 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +54 -0
  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 @@
1
+ {"version":3,"file":"RunHistoryIndexer.d.ts","sourceRoot":"","sources":["../../src/cognitive/RunHistoryIndexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA8GD,qBAAa,iBAAiB;IAChB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAwB3E"}
@@ -0,0 +1,125 @@
1
+ import { adaptRunSummaryForReport } from "../eval/ReportInputAdapter.js";
2
+ const asString = (value) => {
3
+ if (typeof value !== "string")
4
+ return undefined;
5
+ const trimmed = value.trim();
6
+ return trimmed.length > 0 ? trimmed : undefined;
7
+ };
8
+ const asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
9
+ const asRecord = (value) => {
10
+ if (!value || typeof value !== "object" || Array.isArray(value))
11
+ return undefined;
12
+ return value;
13
+ };
14
+ const extractTextFromHit = (hit) => {
15
+ const direct = asString(hit.text) ?? asString(hit.summary);
16
+ if (direct)
17
+ return direct;
18
+ if (typeof hit.snippet === "string")
19
+ return hit.snippet;
20
+ if (hit.snippet && typeof hit.snippet === "object") {
21
+ const text = asString(hit.snippet.text);
22
+ if (text)
23
+ return text;
24
+ }
25
+ return "";
26
+ };
27
+ const extractIntentFromText = (text) => {
28
+ const requestMatch = text.match(/"request"\s*:\s*"([^"]+)"/i);
29
+ if (requestMatch?.[1])
30
+ return requestMatch[1].trim();
31
+ const userRequestMatch = text.match(/USER REQUEST:\s*([^\n]+)/i);
32
+ if (userRequestMatch?.[1])
33
+ return userRequestMatch[1].trim();
34
+ return undefined;
35
+ };
36
+ const extractPlanFromText = (text) => {
37
+ const planBlock = text.match(/PLAN:\s*\n([\s\S]{1,1200}?)(?:\n(?:TARGETS|RISK|VERIFY|END OF CONTEXT):|\Z)/i);
38
+ if (planBlock?.[1])
39
+ return planBlock[1].trim();
40
+ const stepsBlock = text.match(/"steps"\s*:\s*\[([\s\S]{1,1200}?)\]/i);
41
+ if (stepsBlock?.[1])
42
+ return stepsBlock[1].trim();
43
+ return undefined;
44
+ };
45
+ const extractDiffFromText = (text) => {
46
+ const diffMatch = text.match(/(?:diff|patch)\s*[:=]\s*([\s\S]{1,1200})/i);
47
+ if (diffMatch?.[1])
48
+ return diffMatch[1].trim();
49
+ return undefined;
50
+ };
51
+ const extractHistoryHit = (entry) => {
52
+ const path = asString(entry.path);
53
+ if (!path || !/(^|\/)logs\//.test(path))
54
+ return undefined;
55
+ const score = asNumber(entry.score) ?? 0.5;
56
+ const text = extractTextFromHit(entry);
57
+ const dataRecord = asRecord(entry.data);
58
+ const runSummaryRecord = asRecord(entry.run_summary) ?? asRecord(dataRecord?.run_summary);
59
+ const normalizedRun = runSummaryRecord
60
+ ? adaptRunSummaryForReport({ runSummary: runSummaryRecord })
61
+ : undefined;
62
+ const intent = asString(entry.intent) ??
63
+ asString(entry.request) ??
64
+ extractIntentFromText(text) ??
65
+ (normalizedRun?.task_id ? `task ${normalizedRun.task_id}` : undefined) ??
66
+ (normalizedRun?.run_id ? `run ${normalizedRun.run_id}` : undefined);
67
+ const planFromNormalized = normalizedRun
68
+ ? [
69
+ `plan=${normalizedRun.phase_outcomes.find((entry) => entry.phase === "plan")?.status ?? "missing"}`,
70
+ `retrieve=${normalizedRun.phase_outcomes.find((entry) => entry.phase === "retrieve")?.status ?? "missing"}`,
71
+ `act=${normalizedRun.phase_outcomes.find((entry) => entry.phase === "act")?.status ?? "missing"}`,
72
+ `verify=${normalizedRun.phase_outcomes.find((entry) => entry.phase === "verify")?.status ?? "missing"}`,
73
+ ].join(";")
74
+ : undefined;
75
+ const diffFromNormalized = normalizedRun
76
+ ? [
77
+ `status=${normalizedRun.final_status}`,
78
+ `failure_class=${normalizedRun.failure_class ?? "none"}`,
79
+ `verification=${normalizedRun.verification_outcome ?? "none"}`,
80
+ `missing=${normalizedRun.missing_data_markers.join("|") || "none"}`,
81
+ ].join(";")
82
+ : undefined;
83
+ const plan = asString(entry.plan) ?? extractPlanFromText(text) ?? planFromNormalized ?? "";
84
+ const diff = asString(entry.diff) ?? extractDiffFromText(text) ?? diffFromNormalized ?? "";
85
+ if (!intent)
86
+ return undefined;
87
+ if (!plan && !diff)
88
+ return undefined;
89
+ return {
90
+ intent,
91
+ plan: plan || "inferred_from_log",
92
+ diff: diff || "inferred_from_log",
93
+ score,
94
+ };
95
+ };
96
+ export class RunHistoryIndexer {
97
+ constructor(client) {
98
+ this.client = client;
99
+ }
100
+ async findSimilarRuns(intent, limit = 3) {
101
+ try {
102
+ const query = `path:logs/codali ${intent}`;
103
+ const searchResult = await this.client.search(query, { limit: limit * 3 });
104
+ const entries = searchResult.hits ?? [];
105
+ const hits = [];
106
+ const seen = new Set();
107
+ for (const entry of entries) {
108
+ const parsed = extractHistoryHit(entry);
109
+ if (!parsed)
110
+ continue;
111
+ const dedupeKey = `${parsed.intent}::${parsed.plan}::${parsed.diff}`;
112
+ if (seen.has(dedupeKey))
113
+ continue;
114
+ seen.add(dedupeKey);
115
+ hits.push(parsed);
116
+ }
117
+ return hits
118
+ .sort((a, b) => b.score - a.score)
119
+ .slice(0, limit);
120
+ }
121
+ catch {
122
+ return [];
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,92 @@
1
+ import type { AgentEvent } from "../providers/ProviderTypes.js";
2
+ import type { ContextBundle, ContextResearchEvidence, ContextResearchToolUsage, EvidenceGateAssessment, Plan, CriticResult, LaneScope, ContextRefreshTerminationReason, RuntimePhase, VerificationReport } from "./Types.js";
3
+ import { ContextAssembler, type ResearchToolExecution } from "./ContextAssembler.js";
4
+ import { type DeepInvestigationBudgetConfig, type DeepInvestigationEvidenceConfig, type DeepInvestigationToolQuotaConfig } from "../config/Config.js";
5
+ import { ArchitectPlanner } from "./ArchitectPlanner.js";
6
+ import { BuilderRunner, type BuilderRunResult } from "./BuilderRunner.js";
7
+ import { CriticEvaluator } from "./CriticEvaluator.js";
8
+ import { MemoryWriteback } from "./MemoryWriteback.js";
9
+ import type { RunLogger } from "../runtime/RunLogger.js";
10
+ import type { ContextManager } from "./ContextManager.js";
11
+ export interface PhaseProviderFailureContext {
12
+ phase: "librarian" | "architect" | "builder" | "critic" | "interpreter";
13
+ attempt: number;
14
+ error: Error;
15
+ }
16
+ export type PhaseProviderFailureResult = boolean | {
17
+ switched: boolean;
18
+ note?: string;
19
+ };
20
+ export interface SmartPipelineOptions {
21
+ contextAssembler: ContextAssembler;
22
+ architectPlanner: ArchitectPlanner;
23
+ builderRunner: BuilderRunner;
24
+ criticEvaluator: CriticEvaluator;
25
+ memoryWriteback: MemoryWriteback;
26
+ maxRetries: number;
27
+ maxContextRefreshes?: number;
28
+ maxContextRefreshMs?: number;
29
+ initialContext?: ContextBundle;
30
+ fastPath?: (request: string) => boolean;
31
+ deepMode?: boolean;
32
+ deepScanPreset?: boolean;
33
+ deepInvestigation?: {
34
+ toolQuota?: DeepInvestigationToolQuotaConfig;
35
+ investigationBudget?: DeepInvestigationBudgetConfig;
36
+ evidenceGate?: DeepInvestigationEvidenceConfig;
37
+ };
38
+ getTouchedFiles?: () => string[];
39
+ logger?: RunLogger;
40
+ contextManager?: ContextManager;
41
+ laneScope?: Omit<LaneScope, "role" | "ephemeral">;
42
+ verificationPolicyName?: string;
43
+ minimumVerificationChecks?: number;
44
+ enforceVerificationHighConfidence?: boolean;
45
+ onEvent?: (event: AgentEvent) => void;
46
+ onPhaseProviderFailure?: (context: PhaseProviderFailureContext) => Promise<PhaseProviderFailureResult> | PhaseProviderFailureResult;
47
+ }
48
+ export interface ResearchPhaseResult {
49
+ status: "skipped" | "completed";
50
+ startedAt?: number;
51
+ endedAt?: number;
52
+ durationMs?: number;
53
+ cycles?: number;
54
+ budget?: {
55
+ status: "met" | "unmet";
56
+ minCycles: number;
57
+ minSeconds: number;
58
+ maxCycles: number;
59
+ elapsedMs: number;
60
+ cycles: number;
61
+ };
62
+ warnings: string[];
63
+ notes?: string[];
64
+ toolRuns: ResearchToolExecution["toolRuns"];
65
+ outputs?: ResearchToolExecution["outputs"];
66
+ evidence?: ContextResearchEvidence;
67
+ toolUsage?: ContextResearchToolUsage;
68
+ evidenceGate?: EvidenceGateAssessment;
69
+ }
70
+ export interface SmartPipelineResult {
71
+ context: ContextBundle;
72
+ research?: ResearchPhaseResult;
73
+ plan: Plan;
74
+ builderResult: BuilderRunResult;
75
+ criticResult: CriticResult;
76
+ verification?: VerificationReport;
77
+ attempts: number;
78
+ contextRefreshTerminationReason?: ContextRefreshTerminationReason;
79
+ phaseTrace: RuntimePhase[];
80
+ }
81
+ export declare class SmartPipeline {
82
+ private options;
83
+ private phaseTracker;
84
+ constructor(options: SmartPipelineOptions);
85
+ private resetPhaseTracker;
86
+ private transitionPhase;
87
+ run(request: string): Promise<SmartPipelineResult>;
88
+ private runPhase;
89
+ private emitStatus;
90
+ private phaseStatus;
91
+ }
92
+ //# sourceMappingURL=SmartPipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmartPipeline.d.ts","sourceRoot":"","sources":["../../src/cognitive/SmartPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EAEvB,wBAAwB,EACxB,sBAAsB,EACtB,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,+BAA+B,EAG/B,YAAY,EAEZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAIL,KAAK,6BAA6B,EAClC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACtC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAWjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,KAAK,gBAAgB,EAGtB,MAAM,oBAAoB,CAAC;A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