erosolar-cli 2.0.5 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/erosolar-security.rules.json +147 -0
- package/dist/capabilities/enhancedAnalysisCapability.d.ts +13 -0
- package/dist/capabilities/enhancedAnalysisCapability.d.ts.map +1 -0
- package/dist/capabilities/enhancedAnalysisCapability.js +20 -0
- package/dist/capabilities/enhancedAnalysisCapability.js.map +1 -0
- package/dist/capabilities/offsecOpsCapability.d.ts +6 -0
- package/dist/capabilities/offsecOpsCapability.d.ts.map +1 -0
- package/dist/capabilities/offsecOpsCapability.js +20 -0
- package/dist/capabilities/offsecOpsCapability.js.map +1 -0
- package/dist/capabilities/offsecSearchCapability.d.ts +12 -0
- package/dist/capabilities/offsecSearchCapability.d.ts.map +1 -0
- package/dist/capabilities/offsecSearchCapability.js +27 -0
- package/dist/capabilities/offsecSearchCapability.js.map +1 -0
- package/dist/capabilities/taoCapability.d.ts +6 -0
- package/dist/capabilities/taoCapability.d.ts.map +1 -0
- package/dist/capabilities/taoCapability.js +20 -0
- package/dist/capabilities/taoCapability.js.map +1 -0
- package/dist/capabilities/toolRegistry.d.ts +2 -1
- package/dist/capabilities/toolRegistry.d.ts.map +1 -1
- package/dist/capabilities/toolRegistry.js +6 -1
- package/dist/capabilities/toolRegistry.js.map +1 -1
- package/dist/contracts/agent-schemas.json +18 -19
- package/dist/contracts/tools.schema.json +38 -8
- package/dist/core/contextManager.d.ts +8 -2
- package/dist/core/contextManager.d.ts.map +1 -1
- package/dist/core/contextManager.js +15 -2
- package/dist/core/contextManager.js.map +1 -1
- package/dist/core/deepBugAnalyzer.d.ts +128 -0
- package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
- package/dist/core/deepBugAnalyzer.js +406 -0
- package/dist/core/deepBugAnalyzer.js.map +1 -0
- package/dist/core/hypothesisEngine.d.ts +113 -0
- package/dist/core/hypothesisEngine.d.ts.map +1 -0
- package/dist/core/hypothesisEngine.js +264 -0
- package/dist/core/hypothesisEngine.js.map +1 -0
- package/dist/core/intelligentSummarizer.d.ts +79 -0
- package/dist/core/intelligentSummarizer.d.ts.map +1 -0
- package/dist/core/intelligentSummarizer.js +273 -0
- package/dist/core/intelligentSummarizer.js.map +1 -0
- package/dist/core/offsecAlphaZero.d.ts +3 -0
- package/dist/core/offsecAlphaZero.d.ts.map +1 -1
- package/dist/core/offsecAlphaZero.js +166 -5
- package/dist/core/offsecAlphaZero.js.map +1 -1
- package/dist/core/productTestHarness.d.ts +113 -0
- package/dist/core/productTestHarness.d.ts.map +1 -0
- package/dist/core/productTestHarness.js +345 -0
- package/dist/core/productTestHarness.js.map +1 -0
- package/dist/core/toolPatternAnalyzer.d.ts +87 -0
- package/dist/core/toolPatternAnalyzer.d.ts.map +1 -0
- package/dist/core/toolPatternAnalyzer.js +272 -0
- package/dist/core/toolPatternAnalyzer.js.map +1 -0
- package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts +3 -0
- package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js +14 -0
- package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js.map +1 -0
- package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts +3 -0
- package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts.map +1 -0
- package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js +12 -0
- package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js.map +1 -0
- package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts +3 -0
- package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js +12 -0
- package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js.map +1 -0
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +12 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/plugins/tools/offsec/offsecOpsPlugin.d.ts +3 -0
- package/dist/plugins/tools/offsec/offsecOpsPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/offsec/offsecOpsPlugin.js +10 -0
- package/dist/plugins/tools/offsec/offsecOpsPlugin.js.map +1 -0
- package/dist/plugins/tools/offsec/offsecSearchPlugin.d.ts +3 -0
- package/dist/plugins/tools/offsec/offsecSearchPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/offsec/offsecSearchPlugin.js +12 -0
- package/dist/plugins/tools/offsec/offsecSearchPlugin.js.map +1 -0
- package/dist/plugins/tools/tao/taoPlugin.d.ts +3 -0
- package/dist/plugins/tools/tao/taoPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/tao/taoPlugin.js +10 -0
- package/dist/plugins/tools/tao/taoPlugin.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +6 -0
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +50 -15
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/shellApp.js +1 -1
- package/dist/shell/shellApp.js.map +1 -1
- package/dist/shell/systemPrompt.d.ts.map +1 -1
- package/dist/shell/systemPrompt.js +3 -0
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/tools/enhancedAnalysisTools.d.ts +9 -0
- package/dist/tools/enhancedAnalysisTools.d.ts.map +1 -0
- package/dist/tools/enhancedAnalysisTools.js +382 -0
- package/dist/tools/enhancedAnalysisTools.js.map +1 -0
- package/dist/tools/enhancedCodeIntelligenceTools.d.ts +1 -21
- package/dist/tools/enhancedCodeIntelligenceTools.d.ts.map +1 -1
- package/dist/tools/enhancedCodeIntelligenceTools.js +378 -256
- package/dist/tools/enhancedCodeIntelligenceTools.js.map +1 -1
- package/dist/tools/enhancedDevWorkflowTools.d.ts +2 -10
- package/dist/tools/enhancedDevWorkflowTools.d.ts.map +1 -1
- package/dist/tools/enhancedDevWorkflowTools.js +293 -165
- package/dist/tools/enhancedDevWorkflowTools.js.map +1 -1
- package/dist/tools/interactionTools.d.ts.map +1 -1
- package/dist/tools/interactionTools.js +55 -0
- package/dist/tools/interactionTools.js.map +1 -1
- package/dist/tools/offsec/offsecOperationsTools.d.ts +3 -0
- package/dist/tools/offsec/offsecOperationsTools.d.ts.map +1 -0
- package/dist/tools/offsec/offsecOperationsTools.js +333 -0
- package/dist/tools/offsec/offsecOperationsTools.js.map +1 -0
- package/dist/tools/offsecSearchTools.d.ts +3 -0
- package/dist/tools/offsecSearchTools.d.ts.map +1 -0
- package/dist/tools/offsecSearchTools.js +330 -0
- package/dist/tools/offsecSearchTools.js.map +1 -0
- package/dist/tools/taoOperations.d.ts +7 -0
- package/dist/tools/taoOperations.d.ts.map +1 -0
- package/dist/tools/taoOperations.js +744 -0
- package/dist/tools/taoOperations.js.map +1 -0
- package/dist/ui/ShellUIAdapter.d.ts +10 -6
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +68 -66
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/globalWriteLock.d.ts.map +1 -1
- package/dist/ui/globalWriteLock.js +6 -0
- package/dist/ui/globalWriteLock.js.map +1 -1
- package/dist/ui/streamingFormatter.d.ts +11 -0
- package/dist/ui/streamingFormatter.d.ts.map +1 -1
- package/dist/ui/streamingFormatter.js +27 -1
- package/dist/ui/streamingFormatter.js.map +1 -1
- package/package.json +4 -13
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced AI Reasoning Engine with Hypothesis Testing
|
|
3
|
+
*
|
|
4
|
+
* This module provides multi-hypothesis reasoning capabilities to ensure
|
|
5
|
+
* correct AI operations by testing multiple approaches before settling on
|
|
6
|
+
* a solution.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Engine for generating, testing, and validating hypotheses
|
|
10
|
+
*/
|
|
11
|
+
export class HypothesisEngine {
|
|
12
|
+
hypotheses = new Map();
|
|
13
|
+
maxHypotheses;
|
|
14
|
+
constructor(maxHypotheses = 5) {
|
|
15
|
+
this.maxHypotheses = maxHypotheses;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate a new hypothesis
|
|
19
|
+
*/
|
|
20
|
+
generateHypothesis(description, initialEvidence = []) {
|
|
21
|
+
const id = this.generateId();
|
|
22
|
+
const hypothesis = {
|
|
23
|
+
id,
|
|
24
|
+
description,
|
|
25
|
+
confidence: this.calculateInitialConfidence(initialEvidence),
|
|
26
|
+
evidence: initialEvidence,
|
|
27
|
+
status: 'pending',
|
|
28
|
+
};
|
|
29
|
+
this.hypotheses.set(id, hypothesis);
|
|
30
|
+
this.pruneHypotheses();
|
|
31
|
+
return hypothesis;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Add evidence to a hypothesis and update confidence
|
|
35
|
+
*/
|
|
36
|
+
addEvidence(hypothesisId, evidence) {
|
|
37
|
+
const hypothesis = this.hypotheses.get(hypothesisId);
|
|
38
|
+
if (!hypothesis) {
|
|
39
|
+
throw new Error(`Hypothesis ${hypothesisId} not found`);
|
|
40
|
+
}
|
|
41
|
+
hypothesis.evidence.push(evidence);
|
|
42
|
+
hypothesis.confidence = this.recalculateConfidence(hypothesis);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Test a hypothesis with a set of tests
|
|
46
|
+
*/
|
|
47
|
+
async testHypothesis(hypothesisId, tests) {
|
|
48
|
+
const hypothesis = this.hypotheses.get(hypothesisId);
|
|
49
|
+
if (!hypothesis) {
|
|
50
|
+
throw new Error(`Hypothesis ${hypothesisId} not found`);
|
|
51
|
+
}
|
|
52
|
+
hypothesis.status = 'testing';
|
|
53
|
+
const testResults = [];
|
|
54
|
+
for (const test of tests) {
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
try {
|
|
57
|
+
const passed = await test.execute();
|
|
58
|
+
const duration = Date.now() - startTime;
|
|
59
|
+
const result = {
|
|
60
|
+
testName: test.name,
|
|
61
|
+
passed,
|
|
62
|
+
output: passed ? 'Test passed' : 'Test failed',
|
|
63
|
+
duration,
|
|
64
|
+
timestamp: new Date(),
|
|
65
|
+
};
|
|
66
|
+
testResults.push(result);
|
|
67
|
+
// Update hypothesis with test result as evidence
|
|
68
|
+
this.addEvidence(hypothesisId, {
|
|
69
|
+
type: 'test_result',
|
|
70
|
+
content: `${test.description}: ${passed ? 'PASS' : 'FAIL'}`,
|
|
71
|
+
weight: passed ? 0.8 : -0.8,
|
|
72
|
+
timestamp: new Date(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const duration = Date.now() - startTime;
|
|
77
|
+
const result = {
|
|
78
|
+
testName: test.name,
|
|
79
|
+
passed: false,
|
|
80
|
+
output: error instanceof Error ? error.message : String(error),
|
|
81
|
+
duration,
|
|
82
|
+
timestamp: new Date(),
|
|
83
|
+
};
|
|
84
|
+
testResults.push(result);
|
|
85
|
+
this.addEvidence(hypothesisId, {
|
|
86
|
+
type: 'test_result',
|
|
87
|
+
content: `${test.description}: ERROR - ${error instanceof Error ? error.message : String(error)}`,
|
|
88
|
+
weight: -0.9,
|
|
89
|
+
timestamp: new Date(),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
hypothesis.testResults = testResults;
|
|
94
|
+
// Update status based on test results
|
|
95
|
+
const allPassed = testResults.every(r => r.passed);
|
|
96
|
+
hypothesis.status = allPassed ? 'validated' : 'rejected';
|
|
97
|
+
return testResults;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the most promising hypothesis based on confidence
|
|
101
|
+
*/
|
|
102
|
+
getBestHypothesis() {
|
|
103
|
+
let best = null;
|
|
104
|
+
let highestConfidence = -Infinity;
|
|
105
|
+
for (const hypothesis of this.hypotheses.values()) {
|
|
106
|
+
if (hypothesis.status !== 'rejected' && hypothesis.confidence > highestConfidence) {
|
|
107
|
+
highestConfidence = hypothesis.confidence;
|
|
108
|
+
best = hypothesis;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return best;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get all hypotheses sorted by confidence
|
|
115
|
+
*/
|
|
116
|
+
getAllHypotheses() {
|
|
117
|
+
return Array.from(this.hypotheses.values())
|
|
118
|
+
.sort((a, b) => b.confidence - a.confidence);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get hypothesis by ID
|
|
122
|
+
*/
|
|
123
|
+
getHypothesis(id) {
|
|
124
|
+
return this.hypotheses.get(id);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Clear all hypotheses
|
|
128
|
+
*/
|
|
129
|
+
clear() {
|
|
130
|
+
this.hypotheses.clear();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Calculate initial confidence based on evidence
|
|
134
|
+
*/
|
|
135
|
+
calculateInitialConfidence(evidence) {
|
|
136
|
+
if (evidence.length === 0)
|
|
137
|
+
return 0.5; // Neutral confidence
|
|
138
|
+
const totalWeight = evidence.reduce((sum, e) => sum + Math.abs(e.weight), 0);
|
|
139
|
+
if (totalWeight === 0)
|
|
140
|
+
return 0.5;
|
|
141
|
+
const weightedSum = evidence.reduce((sum, e) => sum + e.weight, 0);
|
|
142
|
+
// Normalize to 0-1 range
|
|
143
|
+
return Math.max(0, Math.min(1, 0.5 + (weightedSum / totalWeight) * 0.5));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Recalculate confidence based on all evidence
|
|
147
|
+
*/
|
|
148
|
+
recalculateConfidence(hypothesis) {
|
|
149
|
+
return this.calculateInitialConfidence(hypothesis.evidence);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Prune low-confidence hypotheses if we exceed max
|
|
153
|
+
*/
|
|
154
|
+
pruneHypotheses() {
|
|
155
|
+
if (this.hypotheses.size <= this.maxHypotheses)
|
|
156
|
+
return;
|
|
157
|
+
const sorted = Array.from(this.hypotheses.entries())
|
|
158
|
+
.sort(([, a], [, b]) => a.confidence - b.confidence);
|
|
159
|
+
// Remove the lowest confidence hypothesis
|
|
160
|
+
const lowest = sorted[0];
|
|
161
|
+
if (lowest) {
|
|
162
|
+
const [idToRemove] = lowest;
|
|
163
|
+
this.hypotheses.delete(idToRemove);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Generate unique ID for hypothesis
|
|
168
|
+
*/
|
|
169
|
+
generateId() {
|
|
170
|
+
return `hyp_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Multi-hypothesis bug analyzer
|
|
175
|
+
*/
|
|
176
|
+
export class BugHypothesisAnalyzer {
|
|
177
|
+
engine;
|
|
178
|
+
constructor() {
|
|
179
|
+
this.engine = new HypothesisEngine(10); // Allow more hypotheses for bug analysis
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Analyze a bug by generating and testing multiple hypotheses
|
|
183
|
+
*/
|
|
184
|
+
async analyzeBug(bugDescription, observations, testFunction) {
|
|
185
|
+
// Generate hypotheses based on observations
|
|
186
|
+
const hypotheses = this.generateBugHypotheses(bugDescription, observations);
|
|
187
|
+
// Test each hypothesis
|
|
188
|
+
for (const hypothesis of hypotheses) {
|
|
189
|
+
const tests = await testFunction(hypothesis);
|
|
190
|
+
await this.engine.testHypothesis(hypothesis.id, tests);
|
|
191
|
+
}
|
|
192
|
+
const mostLikely = this.engine.getBestHypothesis();
|
|
193
|
+
const allHypotheses = this.engine.getAllHypotheses();
|
|
194
|
+
const recommendation = this.generateRecommendation(mostLikely, allHypotheses);
|
|
195
|
+
return {
|
|
196
|
+
mostLikely,
|
|
197
|
+
allHypotheses,
|
|
198
|
+
recommendation,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Generate multiple hypotheses for a bug
|
|
203
|
+
*/
|
|
204
|
+
generateBugHypotheses(bugDescription, observations) {
|
|
205
|
+
const hypotheses = [];
|
|
206
|
+
// Common bug hypothesis patterns
|
|
207
|
+
const patterns = [
|
|
208
|
+
'Logic error in implementation',
|
|
209
|
+
'Type mismatch or type coercion issue',
|
|
210
|
+
'Async/timing issue',
|
|
211
|
+
'State management problem',
|
|
212
|
+
'Configuration or environment issue',
|
|
213
|
+
'Dependency version conflict',
|
|
214
|
+
'Edge case not handled',
|
|
215
|
+
'Memory leak or resource management',
|
|
216
|
+
'Concurrency or race condition',
|
|
217
|
+
'Input validation failure',
|
|
218
|
+
];
|
|
219
|
+
for (const pattern of patterns) {
|
|
220
|
+
const evidence = observations.map(obs => ({
|
|
221
|
+
type: 'observation',
|
|
222
|
+
content: obs,
|
|
223
|
+
weight: 0.3,
|
|
224
|
+
timestamp: new Date(),
|
|
225
|
+
}));
|
|
226
|
+
const hypothesis = this.engine.generateHypothesis(`${pattern}: ${bugDescription}`, evidence);
|
|
227
|
+
hypotheses.push(hypothesis);
|
|
228
|
+
}
|
|
229
|
+
return hypotheses;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Generate recommendation based on hypothesis analysis
|
|
233
|
+
*/
|
|
234
|
+
generateRecommendation(mostLikely, allHypotheses) {
|
|
235
|
+
if (!mostLikely) {
|
|
236
|
+
return 'Unable to determine root cause. More investigation needed.';
|
|
237
|
+
}
|
|
238
|
+
const validated = allHypotheses.filter(h => h.status === 'validated');
|
|
239
|
+
const rejected = allHypotheses.filter(h => h.status === 'rejected');
|
|
240
|
+
let recommendation = `Most likely cause: ${mostLikely.description}\n`;
|
|
241
|
+
recommendation += `Confidence: ${(mostLikely.confidence * 100).toFixed(1)}%\n\n`;
|
|
242
|
+
if (validated.length > 1) {
|
|
243
|
+
recommendation += `Multiple hypotheses validated:\n`;
|
|
244
|
+
validated.forEach((h, i) => {
|
|
245
|
+
recommendation += `${i + 1}. ${h.description} (${(h.confidence * 100).toFixed(1)}%)\n`;
|
|
246
|
+
});
|
|
247
|
+
recommendation += '\nConsider addressing all validated causes.\n';
|
|
248
|
+
}
|
|
249
|
+
if (rejected.length > 0) {
|
|
250
|
+
recommendation += `\nRejected hypotheses:\n`;
|
|
251
|
+
rejected.slice(0, 3).forEach(h => {
|
|
252
|
+
recommendation += `- ${h.description}\n`;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return recommendation;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Clear analysis state
|
|
259
|
+
*/
|
|
260
|
+
clear() {
|
|
261
|
+
this.engine.clear();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=hypothesisEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hypothesisEngine.js","sourceRoot":"","sources":["../../src/core/hypothesisEngine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,UAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;IACvC,aAAa,CAAS;IAEvC,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,WAAmB,EAAE,kBAA8B,EAAE;QACtE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAe;YAC7B,EAAE;YACF,WAAW;YACX,UAAU,EAAE,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC;YAC5D,QAAQ,EAAE,eAAe;YACzB,MAAM,EAAE,SAAS;SAClB,CAAC;QAEF,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,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EAAE,EAAE;gBACzB,cAAc,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;YACzF,CAAC,CAAC,CAAC;YACH,cAAc,IAAI,+CAA+C,CAAC;QACpE,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,cAAc,IAAI,0BAA0B,CAAC;YAC7C,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBAC/B,cAAc,IAAI,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC;YAC3C,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligent Tool Output Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Critical for Claude Code operations: prevents context window overload while
|
|
5
|
+
* maintaining essential information. Based on analysis of real Claude Code behavior.
|
|
6
|
+
*/
|
|
7
|
+
export interface SummarizationContext {
|
|
8
|
+
toolName: string;
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
output: string;
|
|
11
|
+
outputSize: number;
|
|
12
|
+
previousToolCalls: string[];
|
|
13
|
+
sessionDuration: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SummarizedOutput {
|
|
16
|
+
summary: string;
|
|
17
|
+
wasSummarized: boolean;
|
|
18
|
+
originalSize: number;
|
|
19
|
+
summarySize: number;
|
|
20
|
+
compressionRatio: number;
|
|
21
|
+
retainedKeyInfo: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Intelligent summarizer that understands tool semantics
|
|
25
|
+
* and extracts only what the AI needs to continue effectively
|
|
26
|
+
*/
|
|
27
|
+
export declare class IntelligentToolSummarizer {
|
|
28
|
+
private readonly ALWAYS_SUMMARIZE_THRESHOLD;
|
|
29
|
+
private readonly CONTEXT_AWARE_THRESHOLD;
|
|
30
|
+
/**
|
|
31
|
+
* Summarize tool output intelligently based on tool type and context
|
|
32
|
+
*/
|
|
33
|
+
summarize(context: SummarizationContext): SummarizedOutput;
|
|
34
|
+
/**
|
|
35
|
+
* Determine if output should be summarized based on size and context
|
|
36
|
+
*/
|
|
37
|
+
private shouldSummarize;
|
|
38
|
+
/**
|
|
39
|
+
* Apply tool-specific summarization strategies
|
|
40
|
+
*/
|
|
41
|
+
private summarizeByToolType;
|
|
42
|
+
/**
|
|
43
|
+
* Summarize file content - show structure and important sections
|
|
44
|
+
*/
|
|
45
|
+
private summarizeFileContent;
|
|
46
|
+
/**
|
|
47
|
+
* Extract code structure (imports, classes, functions)
|
|
48
|
+
*/
|
|
49
|
+
private extractCodeStructure;
|
|
50
|
+
/**
|
|
51
|
+
* Summarize search results - show count and samples
|
|
52
|
+
*/
|
|
53
|
+
private summarizeSearchResults;
|
|
54
|
+
/**
|
|
55
|
+
* Summarize path lists - show count and samples
|
|
56
|
+
*/
|
|
57
|
+
private summarizePathList;
|
|
58
|
+
/**
|
|
59
|
+
* Summarize test/build output - focus on failures
|
|
60
|
+
*/
|
|
61
|
+
private summarizeTestOutput;
|
|
62
|
+
/**
|
|
63
|
+
* Summarize bash command output - keep errors and key info
|
|
64
|
+
*/
|
|
65
|
+
private summarizeBashOutput;
|
|
66
|
+
/**
|
|
67
|
+
* Default summarization for unknown tool types
|
|
68
|
+
*/
|
|
69
|
+
private defaultSummarization;
|
|
70
|
+
/**
|
|
71
|
+
* Extract key information from output for tracking
|
|
72
|
+
*/
|
|
73
|
+
private extractKeyInfo;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Global singleton instance
|
|
77
|
+
*/
|
|
78
|
+
export declare const intelligentSummarizer: IntelligentToolSummarizer;
|
|
79
|
+
//# sourceMappingURL=intelligentSummarizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intelligentSummarizer.d.ts","sourceRoot":"","sources":["../../src/core/intelligentSummarizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,qBAAa,yBAAyB;IAEpC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAS;IACpD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAQ;IAEhD;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB;IA0C1D;;OAEG;IACH,OAAO,CAAC,eAAe;IAmBvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAqC3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAmB9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA4BzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAwB3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAqB3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAsBvB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,2BAAkC,CAAC"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligent Tool Output Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Critical for Claude Code operations: prevents context window overload while
|
|
5
|
+
* maintaining essential information. Based on analysis of real Claude Code behavior.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Intelligent summarizer that understands tool semantics
|
|
9
|
+
* and extracts only what the AI needs to continue effectively
|
|
10
|
+
*/
|
|
11
|
+
export class IntelligentToolSummarizer {
|
|
12
|
+
// Thresholds for when to summarize (in characters)
|
|
13
|
+
ALWAYS_SUMMARIZE_THRESHOLD = 15000;
|
|
14
|
+
CONTEXT_AWARE_THRESHOLD = 8000;
|
|
15
|
+
/**
|
|
16
|
+
* Summarize tool output intelligently based on tool type and context
|
|
17
|
+
*/
|
|
18
|
+
summarize(context) {
|
|
19
|
+
const { toolName, output, outputSize } = context;
|
|
20
|
+
// Never summarize if output is already small
|
|
21
|
+
if (outputSize < 1000) {
|
|
22
|
+
return {
|
|
23
|
+
summary: output,
|
|
24
|
+
wasSummarized: false,
|
|
25
|
+
originalSize: outputSize,
|
|
26
|
+
summarySize: outputSize,
|
|
27
|
+
compressionRatio: 1.0,
|
|
28
|
+
retainedKeyInfo: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Determine if we should summarize based on context
|
|
32
|
+
const shouldSummarize = this.shouldSummarize(context);
|
|
33
|
+
if (!shouldSummarize) {
|
|
34
|
+
return {
|
|
35
|
+
summary: output,
|
|
36
|
+
wasSummarized: false,
|
|
37
|
+
originalSize: outputSize,
|
|
38
|
+
summarySize: outputSize,
|
|
39
|
+
compressionRatio: 1.0,
|
|
40
|
+
retainedKeyInfo: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Apply tool-specific summarization
|
|
44
|
+
const summary = this.summarizeByToolType(toolName, output, context);
|
|
45
|
+
return {
|
|
46
|
+
summary,
|
|
47
|
+
wasSummarized: true,
|
|
48
|
+
originalSize: outputSize,
|
|
49
|
+
summarySize: summary.length,
|
|
50
|
+
compressionRatio: summary.length / outputSize,
|
|
51
|
+
retainedKeyInfo: this.extractKeyInfo(toolName, output),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Determine if output should be summarized based on size and context
|
|
56
|
+
*/
|
|
57
|
+
shouldSummarize(context) {
|
|
58
|
+
const { outputSize, sessionDuration, previousToolCalls } = context;
|
|
59
|
+
// Always summarize huge outputs
|
|
60
|
+
if (outputSize > this.ALWAYS_SUMMARIZE_THRESHOLD) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
// Be more aggressive if session is long or many tools have been called
|
|
64
|
+
const isLongSession = sessionDuration > 300000; // 5 minutes
|
|
65
|
+
const manyToolCalls = previousToolCalls.length > 20;
|
|
66
|
+
if ((isLongSession || manyToolCalls) && outputSize > this.CONTEXT_AWARE_THRESHOLD) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Apply tool-specific summarization strategies
|
|
73
|
+
*/
|
|
74
|
+
summarizeByToolType(toolName, output, context) {
|
|
75
|
+
const lowerTool = toolName.toLowerCase();
|
|
76
|
+
// Read/file operations - show structure and key snippets
|
|
77
|
+
if (lowerTool.includes('read') || lowerTool.includes('file')) {
|
|
78
|
+
return this.summarizeFileContent(output, context);
|
|
79
|
+
}
|
|
80
|
+
// Search/grep operations - show match count and samples
|
|
81
|
+
if (lowerTool.includes('search') || lowerTool.includes('grep') || lowerTool.includes('find')) {
|
|
82
|
+
return this.summarizeSearchResults(output, context);
|
|
83
|
+
}
|
|
84
|
+
// Glob/list operations - show count and sample paths
|
|
85
|
+
if (lowerTool.includes('glob') || lowerTool.includes('list')) {
|
|
86
|
+
return this.summarizePathList(output);
|
|
87
|
+
}
|
|
88
|
+
// Test/build operations - show summary and failures
|
|
89
|
+
if (lowerTool.includes('test') || lowerTool.includes('build') || lowerTool.includes('validate')) {
|
|
90
|
+
return this.summarizeTestOutput(output);
|
|
91
|
+
}
|
|
92
|
+
// Bash/command execution - show key output and errors
|
|
93
|
+
if (lowerTool.includes('bash') || lowerTool.includes('exec') || lowerTool.includes('command')) {
|
|
94
|
+
return this.summarizeBashOutput(output);
|
|
95
|
+
}
|
|
96
|
+
// Analysis tools - keep full output for new tools
|
|
97
|
+
if (lowerTool.includes('analyze') || lowerTool.includes('hypothesis') || lowerTool.includes('bug')) {
|
|
98
|
+
return output; // Don't summarize our new analysis tools
|
|
99
|
+
}
|
|
100
|
+
// Default: intelligent truncation with key info extraction
|
|
101
|
+
return this.defaultSummarization(output);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Summarize file content - show structure and important sections
|
|
105
|
+
*/
|
|
106
|
+
summarizeFileContent(output, context) {
|
|
107
|
+
const lines = output.split('\n');
|
|
108
|
+
const totalLines = lines.length;
|
|
109
|
+
// For code files, extract structure (imports, exports, function/class definitions)
|
|
110
|
+
const filePath = context.args['file_path'] || context.args['path'];
|
|
111
|
+
const isCodeFile = typeof filePath === 'string' && /\.(ts|js|tsx|jsx|py|java|cpp|rs)$/.test(filePath);
|
|
112
|
+
if (isCodeFile) {
|
|
113
|
+
const structure = this.extractCodeStructure(lines);
|
|
114
|
+
const filePathStr = typeof filePath === 'string' ? filePath : 'unknown';
|
|
115
|
+
return `File: ${filePathStr}\nLines: ${totalLines}\n\nStructure:\n${structure}\n\n[Content summarized - ${totalLines} lines total]`;
|
|
116
|
+
}
|
|
117
|
+
// For other files, show beginning and end
|
|
118
|
+
const preview = lines.slice(0, 30).join('\n');
|
|
119
|
+
const epilogue = totalLines > 50 ? `\n...\n[${totalLines - 30} more lines omitted]` : '';
|
|
120
|
+
return `${preview}${epilogue}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Extract code structure (imports, classes, functions)
|
|
124
|
+
*/
|
|
125
|
+
extractCodeStructure(lines) {
|
|
126
|
+
const structure = [];
|
|
127
|
+
for (const line of lines) {
|
|
128
|
+
const trimmed = line.trim();
|
|
129
|
+
// Imports/requires
|
|
130
|
+
if (trimmed.startsWith('import ') || trimmed.startsWith('from ') ||
|
|
131
|
+
trimmed.startsWith('require(') || trimmed.startsWith('const ') && trimmed.includes('require(')) {
|
|
132
|
+
structure.push(trimmed);
|
|
133
|
+
}
|
|
134
|
+
// Class/interface/type definitions
|
|
135
|
+
else if (/^(export\s+)?(class|interface|type|enum)\s+\w+/.test(trimmed)) {
|
|
136
|
+
structure.push(trimmed.replace(/\{.*/, '{...}'));
|
|
137
|
+
}
|
|
138
|
+
// Function definitions
|
|
139
|
+
else if (/^(export\s+)?(async\s+)?function\s+\w+/.test(trimmed) ||
|
|
140
|
+
/^(export\s+)?const\s+\w+\s*=\s*(async\s*)?\(/.test(trimmed)) {
|
|
141
|
+
structure.push((trimmed.split('{')[0] ?? trimmed).trim() + ' {...}');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return structure.slice(0, 50).join('\n') || '[No significant structure found]';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Summarize search results - show count and samples
|
|
148
|
+
*/
|
|
149
|
+
summarizeSearchResults(output, context) {
|
|
150
|
+
const lines = output.split('\n').filter(l => l.trim());
|
|
151
|
+
const totalMatches = lines.length;
|
|
152
|
+
if (totalMatches === 0) {
|
|
153
|
+
return 'No matches found';
|
|
154
|
+
}
|
|
155
|
+
// Show first few matches and last few
|
|
156
|
+
const sampleSize = 10;
|
|
157
|
+
const firstSamples = lines.slice(0, sampleSize).join('\n');
|
|
158
|
+
const lastSamples = totalMatches > sampleSize * 2
|
|
159
|
+
? '\n...\n' + lines.slice(-5).join('\n')
|
|
160
|
+
: '';
|
|
161
|
+
const pattern = context.args['pattern'] || context.args['query'];
|
|
162
|
+
return `Found ${totalMatches} matches for "${pattern}"\n\n${firstSamples}${lastSamples}`;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Summarize path lists - show count and samples
|
|
166
|
+
*/
|
|
167
|
+
summarizePathList(output) {
|
|
168
|
+
const paths = output.split('\n').filter(p => p.trim());
|
|
169
|
+
const total = paths.length;
|
|
170
|
+
if (total === 0) {
|
|
171
|
+
return 'No files found';
|
|
172
|
+
}
|
|
173
|
+
// Group by directory for better overview
|
|
174
|
+
const byDir = new Map();
|
|
175
|
+
for (const path of paths) {
|
|
176
|
+
const dir = path.substring(0, path.lastIndexOf('/')) || '.';
|
|
177
|
+
if (!byDir.has(dir))
|
|
178
|
+
byDir.set(dir, []);
|
|
179
|
+
const dirFiles = byDir.get(dir);
|
|
180
|
+
if (dirFiles)
|
|
181
|
+
dirFiles.push(path);
|
|
182
|
+
}
|
|
183
|
+
const dirSummary = Array.from(byDir.entries())
|
|
184
|
+
.slice(0, 15)
|
|
185
|
+
.map(([dir, files]) => `${dir}/ (${files.length} files)`)
|
|
186
|
+
.join('\n');
|
|
187
|
+
const samplePaths = paths.slice(0, 20).join('\n');
|
|
188
|
+
const remaining = total > 20 ? `\n... and ${total - 20} more files` : '';
|
|
189
|
+
return `Found ${total} files\n\nDirectory summary:\n${dirSummary}\n\nSample paths:\n${samplePaths}${remaining}`;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Summarize test/build output - focus on failures
|
|
193
|
+
*/
|
|
194
|
+
summarizeTestOutput(output) {
|
|
195
|
+
const lines = output.split('\n');
|
|
196
|
+
// Extract key test info
|
|
197
|
+
const passed = (output.match(/(\d+) passed/i) || [])[1];
|
|
198
|
+
const failed = (output.match(/(\d+) failed/i) || [])[1];
|
|
199
|
+
const errors = lines.filter(l => /error|fail|✗|✕|×/i.test(l) && !l.includes('0 errors'));
|
|
200
|
+
let summary = 'Test Results:\n';
|
|
201
|
+
if (passed)
|
|
202
|
+
summary += `✓ ${passed} passed\n`;
|
|
203
|
+
if (failed)
|
|
204
|
+
summary += `✗ ${failed} failed\n`;
|
|
205
|
+
if (errors.length > 0) {
|
|
206
|
+
summary += '\nFailures:\n' + errors.slice(0, 20).join('\n');
|
|
207
|
+
if (errors.length > 20) {
|
|
208
|
+
summary += `\n... and ${errors.length - 20} more errors`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return summary;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Summarize bash command output - keep errors and key info
|
|
215
|
+
*/
|
|
216
|
+
summarizeBashOutput(output) {
|
|
217
|
+
const lines = output.split('\n');
|
|
218
|
+
// If output has errors, prioritize those
|
|
219
|
+
const errorLines = lines.filter(l => /error|fail|fatal|exception|warning/i.test(l));
|
|
220
|
+
if (errorLines.length > 0) {
|
|
221
|
+
return `Command output (${lines.length} lines):\n\nKey messages:\n${errorLines.slice(0, 30).join('\n')}`;
|
|
222
|
+
}
|
|
223
|
+
// Otherwise show beginning and end
|
|
224
|
+
const preview = lines.slice(0, 20).join('\n');
|
|
225
|
+
const epilogue = lines.length > 40
|
|
226
|
+
? '\n...\n' + lines.slice(-10).join('\n')
|
|
227
|
+
: lines.slice(20, 40).join('\n');
|
|
228
|
+
return `${preview}${epilogue}`;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Default summarization for unknown tool types
|
|
232
|
+
*/
|
|
233
|
+
defaultSummarization(output) {
|
|
234
|
+
const lines = output.split('\n');
|
|
235
|
+
const total = lines.length;
|
|
236
|
+
const preview = lines.slice(0, 50).join('\n');
|
|
237
|
+
const epilogue = total > 100
|
|
238
|
+
? `\n...\n${lines.slice(-20).join('\n')}\n\n[${total - 70} lines omitted]`
|
|
239
|
+
: total > 50
|
|
240
|
+
? `\n...\n${lines.slice(-10).join('\n')}`
|
|
241
|
+
: '';
|
|
242
|
+
return `${preview}${epilogue}`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Extract key information from output for tracking
|
|
246
|
+
*/
|
|
247
|
+
extractKeyInfo(toolName, output) {
|
|
248
|
+
const info = [];
|
|
249
|
+
const lowerTool = toolName.toLowerCase();
|
|
250
|
+
// For file operations, extract file paths
|
|
251
|
+
if (lowerTool.includes('read') || lowerTool.includes('write') || lowerTool.includes('edit')) {
|
|
252
|
+
const pathMatches = output.match(/(?:file|path):\s*([^\s\n]+)/gi);
|
|
253
|
+
if (pathMatches)
|
|
254
|
+
info.push(...pathMatches.slice(0, 5));
|
|
255
|
+
}
|
|
256
|
+
// For search, extract match counts
|
|
257
|
+
if (lowerTool.includes('search') || lowerTool.includes('grep')) {
|
|
258
|
+
const countMatch = output.match(/(\d+)\s+(matches|results|found)/i);
|
|
259
|
+
if (countMatch)
|
|
260
|
+
info.push(countMatch[0]);
|
|
261
|
+
}
|
|
262
|
+
// Extract error messages
|
|
263
|
+
const errors = output.match(/error:.*$/gim);
|
|
264
|
+
if (errors)
|
|
265
|
+
info.push(...errors.slice(0, 3));
|
|
266
|
+
return info;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Global singleton instance
|
|
271
|
+
*/
|
|
272
|
+
export const intelligentSummarizer = new IntelligentToolSummarizer();
|
|
273
|
+
//# sourceMappingURL=intelligentSummarizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intelligentSummarizer.js","sourceRoot":"","sources":["../../src/core/intelligentSummarizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IACpC,mDAAmD;IAClC,0BAA0B,GAAG,KAAK,CAAC;IACnC,uBAAuB,GAAG,IAAI,CAAC;IAEhD;;OAEG;IACH,SAAS,CAAC,OAA6B;QACrC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAEjD,6CAA6C;QAC7C,IAAI,UAAU,GAAG,IAAI,EA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