@gotza02/seq-thinking 1.1.0
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/README.md +149 -0
- package/SYSTEM_INSTRUCTIONS.md +50 -0
- package/agents_test.log +15 -0
- package/dist/__tests__/agents.test.d.ts +2 -0
- package/dist/__tests__/agents.test.d.ts.map +1 -0
- package/dist/__tests__/agents.test.js +673 -0
- package/dist/__tests__/agents.test.js.map +1 -0
- package/dist/__tests__/mcp-server.test.d.ts +2 -0
- package/dist/__tests__/mcp-server.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-server.test.js +315 -0
- package/dist/__tests__/mcp-server.test.js.map +1 -0
- package/dist/__tests__/sequential-thinking.test.d.ts +2 -0
- package/dist/__tests__/sequential-thinking.test.d.ts.map +1 -0
- package/dist/__tests__/sequential-thinking.test.js +545 -0
- package/dist/__tests__/sequential-thinking.test.js.map +1 -0
- package/dist/__tests__/swarm-coordinator.test.d.ts +2 -0
- package/dist/__tests__/swarm-coordinator.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-coordinator.test.js +606 -0
- package/dist/__tests__/swarm-coordinator.test.js.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.js +741 -0
- package/dist/__tests__/types.test.js.map +1 -0
- package/dist/__tests__/utils.test.d.ts +2 -0
- package/dist/__tests__/utils.test.d.ts.map +1 -0
- package/dist/__tests__/utils.test.js +264 -0
- package/dist/__tests__/utils.test.js.map +1 -0
- package/dist/agents/base-agent.d.ts +126 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +214 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/critic-agent.d.ts +134 -0
- package/dist/agents/critic-agent.d.ts.map +1 -0
- package/dist/agents/critic-agent.js +484 -0
- package/dist/agents/critic-agent.js.map +1 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +11 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/meta-reasoning-agent.d.ts +143 -0
- package/dist/agents/meta-reasoning-agent.d.ts.map +1 -0
- package/dist/agents/meta-reasoning-agent.js +532 -0
- package/dist/agents/meta-reasoning-agent.js.map +1 -0
- package/dist/agents/reasoner-agent.d.ts +75 -0
- package/dist/agents/reasoner-agent.d.ts.map +1 -0
- package/dist/agents/reasoner-agent.js +226 -0
- package/dist/agents/reasoner-agent.js.map +1 -0
- package/dist/agents/synthesizer-agent.d.ts +174 -0
- package/dist/agents/synthesizer-agent.d.ts.map +1 -0
- package/dist/agents/synthesizer-agent.js +583 -0
- package/dist/agents/synthesizer-agent.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +823 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +377 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/sequential-thinking.d.ts +91 -0
- package/dist/sequential-thinking.d.ts.map +1 -0
- package/dist/sequential-thinking.js +540 -0
- package/dist/sequential-thinking.js.map +1 -0
- package/dist/swarm-coordinator.d.ts +188 -0
- package/dist/swarm-coordinator.d.ts.map +1 -0
- package/dist/swarm-coordinator.js +627 -0
- package/dist/swarm-coordinator.js.map +1 -0
- package/dist/types/index.d.ts +806 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +279 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +421 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +864 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/llm-adapter.d.ts +23 -0
- package/dist/utils/llm-adapter.d.ts.map +1 -0
- package/dist/utils/llm-adapter.js +68 -0
- package/dist/utils/llm-adapter.js.map +1 -0
- package/dist/utils/persistence.d.ts +33 -0
- package/dist/utils/persistence.d.ts.map +1 -0
- package/dist/utils/persistence.js +108 -0
- package/dist/utils/persistence.js.map +1 -0
- package/package.json +41 -0
- package/src/__tests__/agents.test.ts +858 -0
- package/src/__tests__/mcp-server.test.ts +380 -0
- package/src/__tests__/sequential-thinking.test.ts +687 -0
- package/src/__tests__/swarm-coordinator.test.ts +903 -0
- package/src/__tests__/types.test.ts +839 -0
- package/src/__tests__/utils.test.ts +322 -0
- package/src/agents/base-agent.ts +285 -0
- package/src/agents/critic-agent.ts +582 -0
- package/src/agents/index.ts +11 -0
- package/src/agents/meta-reasoning-agent.ts +672 -0
- package/src/agents/reasoner-agent.ts +312 -0
- package/src/agents/synthesizer-agent.ts +758 -0
- package/src/index.ts +118 -0
- package/src/mcp-server.ts +387 -0
- package/src/sequential-thinking.ts +560 -0
- package/src/swarm-coordinator.ts +744 -0
- package/src/types/index.ts +915 -0
- package/src/utils/index.ts +1004 -0
- package/src/utils/llm-adapter.ts +76 -0
- package/src/utils/persistence.ts +108 -0
- package/test_output.log +0 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta-Reasoning Agent Implementation
|
|
3
|
+
* @module agents/meta-reasoning-agent
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseAgent } from './base-agent.js';
|
|
7
|
+
import { AgentType, ThoughtType } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Meta-reasoning agent that reflects on thinking processes
|
|
10
|
+
*/
|
|
11
|
+
export class MetaReasoningAgent extends BaseAgent {
|
|
12
|
+
/** Observation history */
|
|
13
|
+
observationHistory = [];
|
|
14
|
+
/**
|
|
15
|
+
* Create a new meta-reasoning agent
|
|
16
|
+
* @param config - Agent configuration
|
|
17
|
+
*/
|
|
18
|
+
constructor(config) {
|
|
19
|
+
const defaultCapabilities = [
|
|
20
|
+
{
|
|
21
|
+
name: 'process_reflection',
|
|
22
|
+
description: 'Reflect on thinking processes',
|
|
23
|
+
confidence: 0.9,
|
|
24
|
+
performanceMetrics: { tasksCompleted: 0, averageQuality: 0, averageTimeMs: 0 }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'strategy_assessment',
|
|
28
|
+
description: 'Assess reasoning strategies',
|
|
29
|
+
confidence: 0.85,
|
|
30
|
+
performanceMetrics: { tasksCompleted: 0, averageQuality: 0, averageTimeMs: 0 }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'bias_detection',
|
|
34
|
+
description: 'Detect cognitive biases',
|
|
35
|
+
confidence: 0.8,
|
|
36
|
+
performanceMetrics: { tasksCompleted: 0, averageQuality: 0, averageTimeMs: 0 }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'pattern_analysis',
|
|
40
|
+
description: 'Analyze thinking patterns',
|
|
41
|
+
confidence: 0.85,
|
|
42
|
+
performanceMetrics: { tasksCompleted: 0, averageQuality: 0, averageTimeMs: 0 }
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
super({
|
|
46
|
+
name: config.name,
|
|
47
|
+
type: AgentType.META_REASONING,
|
|
48
|
+
capabilities: config.capabilities || defaultCapabilities,
|
|
49
|
+
maxConcurrentTasks: 5,
|
|
50
|
+
confidenceThreshold: 0.7
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get agent type
|
|
55
|
+
* @returns Agent type
|
|
56
|
+
*/
|
|
57
|
+
getType() {
|
|
58
|
+
return AgentType.META_REASONING;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get agent capabilities
|
|
62
|
+
* @returns Array of capabilities
|
|
63
|
+
*/
|
|
64
|
+
getCapabilities() {
|
|
65
|
+
return this.config.capabilities;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Process a task - perform meta-reasoning
|
|
69
|
+
* @param task - Task to process
|
|
70
|
+
* @returns Task result
|
|
71
|
+
*/
|
|
72
|
+
async process(task) {
|
|
73
|
+
const startTime = Date.now();
|
|
74
|
+
const input = task.input;
|
|
75
|
+
let result;
|
|
76
|
+
let confidence = 0.8;
|
|
77
|
+
switch (input.operation) {
|
|
78
|
+
case 'reflect':
|
|
79
|
+
result = this.reflect(input.session);
|
|
80
|
+
break;
|
|
81
|
+
case 'analyze_patterns':
|
|
82
|
+
result = this.analyzeThinkingPatterns(input.thoughts || []);
|
|
83
|
+
break;
|
|
84
|
+
case 'assess_strategy':
|
|
85
|
+
result = this.assessStrategy(input.session);
|
|
86
|
+
break;
|
|
87
|
+
case 'detect_bias':
|
|
88
|
+
result = this.detectBias(input.thoughts || []);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
result = this.reflect(input.session);
|
|
92
|
+
}
|
|
93
|
+
return this.createTaskResult(task.id, result, confidence, Date.now() - startTime, {
|
|
94
|
+
reasoningSteps: 1,
|
|
95
|
+
intermediateResults: []
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reflect on a thinking session
|
|
100
|
+
* @param session - Session to reflect on
|
|
101
|
+
* @returns Reflection result
|
|
102
|
+
*/
|
|
103
|
+
reflect(session) {
|
|
104
|
+
if (!session) {
|
|
105
|
+
return {
|
|
106
|
+
reflection: 'No session provided for reflection',
|
|
107
|
+
insights: [],
|
|
108
|
+
recommendations: [],
|
|
109
|
+
observations: []
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const thoughts = Array.from(session.thoughts.values());
|
|
113
|
+
const insights = [];
|
|
114
|
+
const recommendations = [];
|
|
115
|
+
const observations = [];
|
|
116
|
+
// Analyze thinking patterns
|
|
117
|
+
const patterns = this.analyzeThinkingPatterns(thoughts);
|
|
118
|
+
for (const pattern of patterns) {
|
|
119
|
+
if (pattern.impact === 'negative') {
|
|
120
|
+
observations.push({
|
|
121
|
+
type: 'concern',
|
|
122
|
+
description: pattern.pattern,
|
|
123
|
+
severity: pattern.frequency > 3 ? 'high' : 'medium',
|
|
124
|
+
recommendation: pattern.suggestion
|
|
125
|
+
});
|
|
126
|
+
recommendations.push(pattern.suggestion || 'Review and adjust thinking pattern');
|
|
127
|
+
}
|
|
128
|
+
else if (pattern.impact === 'positive') {
|
|
129
|
+
observations.push({
|
|
130
|
+
type: 'insight',
|
|
131
|
+
description: pattern.pattern
|
|
132
|
+
});
|
|
133
|
+
insights.push(pattern.pattern);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Check confidence trends
|
|
137
|
+
const confidenceTrend = this.analyzeConfidenceTrend(thoughts);
|
|
138
|
+
if (confidenceTrend.trend === 'declining') {
|
|
139
|
+
observations.push({
|
|
140
|
+
type: 'concern',
|
|
141
|
+
description: 'Confidence is declining over time',
|
|
142
|
+
severity: 'medium',
|
|
143
|
+
recommendation: 'Review assumptions and gather more evidence'
|
|
144
|
+
});
|
|
145
|
+
recommendations.push('Strengthen reasoning with additional evidence');
|
|
146
|
+
}
|
|
147
|
+
else if (confidenceTrend.trend === 'improving') {
|
|
148
|
+
insights.push('Confidence is improving, indicating solid reasoning progress');
|
|
149
|
+
}
|
|
150
|
+
// Check thought type distribution
|
|
151
|
+
const typeDistribution = this.analyzeThoughtTypeDistribution(thoughts);
|
|
152
|
+
const analysisCount = typeDistribution.get(ThoughtType.ANALYSIS) || 0;
|
|
153
|
+
const hypothesisCount = typeDistribution.get(ThoughtType.HYPOTHESIS) || 0;
|
|
154
|
+
if (analysisCount > hypothesisCount * 3) {
|
|
155
|
+
observations.push({
|
|
156
|
+
type: 'suggestion',
|
|
157
|
+
description: 'Heavy focus on analysis with limited hypothesis generation',
|
|
158
|
+
recommendation: 'Consider exploring more alternative hypotheses'
|
|
159
|
+
});
|
|
160
|
+
recommendations.push('Generate more diverse hypotheses');
|
|
161
|
+
}
|
|
162
|
+
// Check for meta-reasoning gaps
|
|
163
|
+
const metaThoughtCount = thoughts.filter(t => t.thoughtType === ThoughtType.META_REASONING).length;
|
|
164
|
+
if (metaThoughtCount < thoughts.length * 0.1) {
|
|
165
|
+
observations.push({
|
|
166
|
+
type: 'suggestion',
|
|
167
|
+
description: 'Limited meta-reasoning detected',
|
|
168
|
+
recommendation: 'Increase reflection on the thinking process itself'
|
|
169
|
+
});
|
|
170
|
+
recommendations.push('Add more meta-reasoning steps');
|
|
171
|
+
}
|
|
172
|
+
const reflection = `Analyzed ${thoughts.length} thoughts across ${session.branches.size} branches. ` +
|
|
173
|
+
`Found ${insights.length} positive insights and ${recommendations.length} areas for improvement.`;
|
|
174
|
+
return {
|
|
175
|
+
reflection,
|
|
176
|
+
insights,
|
|
177
|
+
recommendations,
|
|
178
|
+
observations
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Analyze thinking patterns
|
|
183
|
+
* @param thoughts - Thoughts to analyze
|
|
184
|
+
* @returns Array of patterns
|
|
185
|
+
*/
|
|
186
|
+
analyzeThinkingPatterns(thoughts) {
|
|
187
|
+
const patterns = [];
|
|
188
|
+
if (thoughts.length === 0)
|
|
189
|
+
return patterns;
|
|
190
|
+
// Pattern: Repetitive thinking
|
|
191
|
+
const contentSimilarities = this.findSimilarThoughts(thoughts);
|
|
192
|
+
if (contentSimilarities.length > thoughts.length * 0.3) {
|
|
193
|
+
patterns.push({
|
|
194
|
+
pattern: 'Repetitive thinking detected - similar thoughts being generated',
|
|
195
|
+
frequency: contentSimilarities.length,
|
|
196
|
+
impact: 'negative',
|
|
197
|
+
suggestion: 'Focus on generating novel insights rather than restating'
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// Pattern: Confidence progression
|
|
201
|
+
const confidenceValues = thoughts.map(t => t.confidence.overall);
|
|
202
|
+
const avgConfidence = confidenceValues.reduce((a, b) => a + b, 0) / confidenceValues.length;
|
|
203
|
+
if (avgConfidence < 0.5) {
|
|
204
|
+
patterns.push({
|
|
205
|
+
pattern: 'Low average confidence across thoughts',
|
|
206
|
+
frequency: thoughts.length,
|
|
207
|
+
impact: 'negative',
|
|
208
|
+
suggestion: 'Strengthen evidence and reasoning for key claims'
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
else if (avgConfidence > 0.8) {
|
|
212
|
+
patterns.push({
|
|
213
|
+
pattern: 'High confidence maintained throughout',
|
|
214
|
+
frequency: thoughts.length,
|
|
215
|
+
impact: 'positive'
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Pattern: Branch exploration
|
|
219
|
+
const branchIds = new Set(thoughts.map(t => t.branchId));
|
|
220
|
+
if (branchIds.size === 1 && thoughts.length > 5) {
|
|
221
|
+
patterns.push({
|
|
222
|
+
pattern: 'Single branch exploration - no parallel hypotheses',
|
|
223
|
+
frequency: 1,
|
|
224
|
+
impact: 'negative',
|
|
225
|
+
suggestion: 'Consider branching to explore alternative approaches'
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else if (branchIds.size > 2) {
|
|
229
|
+
patterns.push({
|
|
230
|
+
pattern: 'Active branch exploration with parallel hypotheses',
|
|
231
|
+
frequency: branchIds.size,
|
|
232
|
+
impact: 'positive'
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// Pattern: Assumption documentation
|
|
236
|
+
const thoughtsWithAssumptions = thoughts.filter(t => t.assumptions.length > 0).length;
|
|
237
|
+
if (thoughtsWithAssumptions < thoughts.length * 0.3) {
|
|
238
|
+
patterns.push({
|
|
239
|
+
pattern: 'Limited explicit assumption documentation',
|
|
240
|
+
frequency: thoughts.length - thoughtsWithAssumptions,
|
|
241
|
+
impact: 'negative',
|
|
242
|
+
suggestion: 'Document assumptions explicitly for each major claim'
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Pattern: Revision activity
|
|
246
|
+
const revisedThoughts = thoughts.filter(t => t.revisionHistory.length > 0).length;
|
|
247
|
+
if (revisedThoughts > thoughts.length * 0.5) {
|
|
248
|
+
patterns.push({
|
|
249
|
+
pattern: 'High revision rate - thoughts being frequently corrected',
|
|
250
|
+
frequency: revisedThoughts,
|
|
251
|
+
impact: 'neutral',
|
|
252
|
+
suggestion: 'Consider more careful initial analysis to reduce revisions'
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return patterns;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Assess reasoning strategy
|
|
259
|
+
* @param session - Session to assess
|
|
260
|
+
* @returns Strategy assessment
|
|
261
|
+
*/
|
|
262
|
+
assessStrategy(session) {
|
|
263
|
+
if (!session) {
|
|
264
|
+
return {
|
|
265
|
+
assessment: 'No session provided',
|
|
266
|
+
strengths: [],
|
|
267
|
+
weaknesses: [],
|
|
268
|
+
suggestions: []
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const thoughts = Array.from(session.thoughts.values());
|
|
272
|
+
const strengths = [];
|
|
273
|
+
const weaknesses = [];
|
|
274
|
+
const suggestions = [];
|
|
275
|
+
// Assess hypothesis generation
|
|
276
|
+
const hypothesisCount = thoughts.filter(t => t.thoughtType === ThoughtType.HYPOTHESIS).length;
|
|
277
|
+
if (hypothesisCount >= 3) {
|
|
278
|
+
strengths.push('Good hypothesis generation with multiple alternatives');
|
|
279
|
+
}
|
|
280
|
+
else if (hypothesisCount < 2 && thoughts.length > 5) {
|
|
281
|
+
weaknesses.push('Limited hypothesis generation');
|
|
282
|
+
suggestions.push('Generate at least 3 alternative hypotheses early in the process');
|
|
283
|
+
}
|
|
284
|
+
// Assess evidence gathering
|
|
285
|
+
const evidenceCount = thoughts.filter(t => t.thoughtType === ThoughtType.EVIDENCE).length;
|
|
286
|
+
if (evidenceCount >= thoughts.length * 0.2) {
|
|
287
|
+
strengths.push('Strong evidence-based reasoning');
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
weaknesses.push('Insufficient evidence gathering');
|
|
291
|
+
suggestions.push('Support claims with more evidence and citations');
|
|
292
|
+
}
|
|
293
|
+
// Assess counterargument consideration
|
|
294
|
+
const counterCount = thoughts.filter(t => t.thoughtType === ThoughtType.COUNTERARGUMENT).length;
|
|
295
|
+
if (counterCount >= 2) {
|
|
296
|
+
strengths.push('Good consideration of counterarguments');
|
|
297
|
+
}
|
|
298
|
+
else if (thoughts.length > 8) {
|
|
299
|
+
weaknesses.push('Limited counterargument analysis');
|
|
300
|
+
suggestions.push('Actively seek and address counterarguments');
|
|
301
|
+
}
|
|
302
|
+
// Assess synthesis
|
|
303
|
+
const synthesisCount = thoughts.filter(t => t.thoughtType === ThoughtType.SYNTHESIS).length;
|
|
304
|
+
if (synthesisCount >= 2) {
|
|
305
|
+
strengths.push('Regular synthesis of findings');
|
|
306
|
+
}
|
|
307
|
+
else if (thoughts.length > 10) {
|
|
308
|
+
suggestions.push('Periodically synthesize findings to maintain coherence');
|
|
309
|
+
}
|
|
310
|
+
// Assess self-correction
|
|
311
|
+
const correctionCount = thoughts.filter(t => t.thoughtType === ThoughtType.SELF_CORRECTION).length;
|
|
312
|
+
if (correctionCount >= 1) {
|
|
313
|
+
strengths.push('Active self-correction detected');
|
|
314
|
+
}
|
|
315
|
+
const assessment = strengths.length > weaknesses.length
|
|
316
|
+
? 'Overall effective reasoning strategy'
|
|
317
|
+
: weaknesses.length > strengths.length
|
|
318
|
+
? 'Strategy needs improvement'
|
|
319
|
+
: 'Balanced strategy with room for improvement';
|
|
320
|
+
return {
|
|
321
|
+
assessment,
|
|
322
|
+
strengths,
|
|
323
|
+
weaknesses,
|
|
324
|
+
suggestions
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Detect cognitive biases
|
|
329
|
+
* @param thoughts - Thoughts to analyze
|
|
330
|
+
* @returns Bias detection results
|
|
331
|
+
*/
|
|
332
|
+
detectBias(thoughts) {
|
|
333
|
+
const detectedBiases = [];
|
|
334
|
+
if (thoughts.length === 0) {
|
|
335
|
+
return { detectedBiases, overallRisk: 'low' };
|
|
336
|
+
}
|
|
337
|
+
// Check for confirmation bias
|
|
338
|
+
const confirmingThoughts = thoughts.filter(t => t.content.toLowerCase().includes('confirms') ||
|
|
339
|
+
t.content.toLowerCase().includes('proves') ||
|
|
340
|
+
t.content.toLowerCase().includes('supports')).length;
|
|
341
|
+
const disconfirmingThoughts = thoughts.filter(t => t.content.toLowerCase().includes('contradicts') ||
|
|
342
|
+
t.content.toLowerCase().includes('challenges') ||
|
|
343
|
+
t.content.toLowerCase().includes('refutes')).length;
|
|
344
|
+
if (confirmingThoughts > disconfirmingThoughts * 3 && confirmingThoughts > 2) {
|
|
345
|
+
detectedBiases.push({
|
|
346
|
+
bias: 'Confirmation Bias',
|
|
347
|
+
evidence: `${confirmingThoughts} confirming vs ${disconfirmingThoughts} disconfirming thoughts`,
|
|
348
|
+
severity: 'medium',
|
|
349
|
+
mitigation: 'Actively seek disconfirming evidence for each claim'
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// Check for anchoring bias
|
|
353
|
+
const firstThoughtConfidence = thoughts[0]?.confidence.overall || 0.5;
|
|
354
|
+
const confidenceVariance = this.calculateConfidenceVariance(thoughts);
|
|
355
|
+
if (confidenceVariance < 0.1 && thoughts.length > 5) {
|
|
356
|
+
detectedBiases.push({
|
|
357
|
+
bias: 'Anchoring Bias',
|
|
358
|
+
evidence: 'Low confidence variance suggests anchoring to initial estimates',
|
|
359
|
+
severity: 'low',
|
|
360
|
+
mitigation: 'Re-evaluate confidence independently for each thought'
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
// Check for availability bias
|
|
364
|
+
const recentThoughts = thoughts.slice(-3);
|
|
365
|
+
const recentReferences = recentThoughts.filter(t => t.dependencies.some(d => thoughts.slice(0, -3).some(pt => pt.id === d))).length;
|
|
366
|
+
if (recentReferences === 0 && thoughts.length > 5) {
|
|
367
|
+
detectedBiases.push({
|
|
368
|
+
bias: 'Availability Bias',
|
|
369
|
+
evidence: 'Recent thoughts do not reference earlier work',
|
|
370
|
+
severity: 'low',
|
|
371
|
+
mitigation: 'Actively reference and build upon earlier insights'
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
// Check for overconfidence
|
|
375
|
+
const highConfidenceCount = thoughts.filter(t => t.confidence.overall > 0.9).length;
|
|
376
|
+
if (highConfidenceCount > thoughts.length * 0.5) {
|
|
377
|
+
detectedBiases.push({
|
|
378
|
+
bias: 'Overconfidence Bias',
|
|
379
|
+
evidence: `${highConfidenceCount}/${thoughts.length} thoughts have >90% confidence`,
|
|
380
|
+
severity: 'medium',
|
|
381
|
+
mitigation: 'Calibrate confidence more conservatively'
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// Check for sunk cost fallacy
|
|
385
|
+
const revisionCount = thoughts.filter(t => t.revisionHistory.length > 0).length;
|
|
386
|
+
if (revisionCount > thoughts.length * 0.7 && thoughts.length > 5) {
|
|
387
|
+
detectedBiases.push({
|
|
388
|
+
bias: 'Sunk Cost Fallacy',
|
|
389
|
+
evidence: 'High revision rate may indicate reluctance to abandon initial approach',
|
|
390
|
+
severity: 'low',
|
|
391
|
+
mitigation: 'Be willing to start fresh if current approach is not working'
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
// Determine overall risk
|
|
395
|
+
const highSeverityCount = detectedBiases.filter(b => b.severity === 'high').length;
|
|
396
|
+
const mediumSeverityCount = detectedBiases.filter(b => b.severity === 'medium').length;
|
|
397
|
+
let overallRisk = 'low';
|
|
398
|
+
if (highSeverityCount > 0 || mediumSeverityCount > 2) {
|
|
399
|
+
overallRisk = 'high';
|
|
400
|
+
}
|
|
401
|
+
else if (mediumSeverityCount > 0) {
|
|
402
|
+
overallRisk = 'medium';
|
|
403
|
+
}
|
|
404
|
+
return { detectedBiases, overallRisk };
|
|
405
|
+
}
|
|
406
|
+
// ============================================================================
|
|
407
|
+
// Helper Methods
|
|
408
|
+
// ============================================================================
|
|
409
|
+
/**
|
|
410
|
+
* Find similar thoughts
|
|
411
|
+
* @param thoughts - Thoughts to compare
|
|
412
|
+
* @returns Array of similar thought pairs
|
|
413
|
+
*/
|
|
414
|
+
findSimilarThoughts(thoughts) {
|
|
415
|
+
const similar = [];
|
|
416
|
+
for (let i = 0; i < thoughts.length; i++) {
|
|
417
|
+
for (let j = i + 1; j < thoughts.length; j++) {
|
|
418
|
+
if (this.thoughtsAreSimilar(thoughts[i], thoughts[j])) {
|
|
419
|
+
similar.push([thoughts[i], thoughts[j]]);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return similar;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Check if two thoughts are similar
|
|
427
|
+
* @param a - First thought
|
|
428
|
+
* @param b - Second thought
|
|
429
|
+
* @returns True if similar
|
|
430
|
+
*/
|
|
431
|
+
thoughtsAreSimilar(a, b) {
|
|
432
|
+
const wordsA = new Set(a.content.toLowerCase().split(/\s+/));
|
|
433
|
+
const wordsB = new Set(b.content.toLowerCase().split(/\s+/));
|
|
434
|
+
const intersection = [...wordsA].filter(w => wordsB.has(w));
|
|
435
|
+
const union = new Set([...wordsA, ...wordsB]);
|
|
436
|
+
return union.size > 0 && intersection.length / union.size > 0.7;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Analyze confidence trend
|
|
440
|
+
* @param thoughts - Thoughts to analyze
|
|
441
|
+
* @returns Trend analysis
|
|
442
|
+
*/
|
|
443
|
+
analyzeConfidenceTrend(thoughts) {
|
|
444
|
+
if (thoughts.length < 3) {
|
|
445
|
+
return { trend: 'stable', initial: 0, final: 0 };
|
|
446
|
+
}
|
|
447
|
+
const sorted = [...thoughts].sort((a, b) => a.metadata.createdAt.getTime() - b.metadata.createdAt.getTime());
|
|
448
|
+
const firstThird = sorted.slice(0, Math.ceil(sorted.length / 3));
|
|
449
|
+
const lastThird = sorted.slice(-Math.ceil(sorted.length / 3));
|
|
450
|
+
const initial = firstThird.reduce((sum, t) => sum + t.confidence.overall, 0) / firstThird.length;
|
|
451
|
+
const final = lastThird.reduce((sum, t) => sum + t.confidence.overall, 0) / lastThird.length;
|
|
452
|
+
const diff = final - initial;
|
|
453
|
+
const threshold = 0.1;
|
|
454
|
+
let trend;
|
|
455
|
+
if (diff > threshold) {
|
|
456
|
+
trend = 'improving';
|
|
457
|
+
}
|
|
458
|
+
else if (diff < -threshold) {
|
|
459
|
+
trend = 'declining';
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
trend = 'stable';
|
|
463
|
+
}
|
|
464
|
+
return { trend, initial, final };
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Analyze thought type distribution
|
|
468
|
+
* @param thoughts - Thoughts to analyze
|
|
469
|
+
* @returns Type distribution map
|
|
470
|
+
*/
|
|
471
|
+
analyzeThoughtTypeDistribution(thoughts) {
|
|
472
|
+
const distribution = new Map();
|
|
473
|
+
for (const thought of thoughts) {
|
|
474
|
+
const count = distribution.get(thought.thoughtType) || 0;
|
|
475
|
+
distribution.set(thought.thoughtType, count + 1);
|
|
476
|
+
}
|
|
477
|
+
return distribution;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Calculate confidence variance
|
|
481
|
+
* @param thoughts - Thoughts to analyze
|
|
482
|
+
* @returns Variance
|
|
483
|
+
*/
|
|
484
|
+
calculateConfidenceVariance(thoughts) {
|
|
485
|
+
if (thoughts.length < 2)
|
|
486
|
+
return 0;
|
|
487
|
+
const values = thoughts.map(t => t.confidence.overall);
|
|
488
|
+
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
489
|
+
const squaredDiffs = values.map(v => Math.pow(v - mean, 2));
|
|
490
|
+
return squaredDiffs.reduce((a, b) => a + b, 0) / values.length;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Generate meta-observation for a thought
|
|
494
|
+
* @param thought - Thought to analyze
|
|
495
|
+
* @returns Meta-observation or null
|
|
496
|
+
*/
|
|
497
|
+
generateMetaObservation(thought) {
|
|
498
|
+
const observations = [];
|
|
499
|
+
const triggeredActions = [];
|
|
500
|
+
// Check for high uncertainty
|
|
501
|
+
const uncertaintyRange = thought.confidence.uncertaintyBounds[1] - thought.confidence.uncertaintyBounds[0];
|
|
502
|
+
if (uncertaintyRange > 0.4) {
|
|
503
|
+
observations.push('High uncertainty detected');
|
|
504
|
+
triggeredActions.push('gather_more_evidence');
|
|
505
|
+
}
|
|
506
|
+
// Check for low confidence
|
|
507
|
+
if (thought.confidence.overall < 0.4) {
|
|
508
|
+
observations.push('Low confidence in this thought');
|
|
509
|
+
triggeredActions.push('review_reasoning');
|
|
510
|
+
}
|
|
511
|
+
// Check for missing assumptions
|
|
512
|
+
if (thought.assumptions.length === 0) {
|
|
513
|
+
observations.push('No explicit assumptions documented');
|
|
514
|
+
triggeredActions.push('document_assumptions');
|
|
515
|
+
}
|
|
516
|
+
if (observations.length === 0)
|
|
517
|
+
return null;
|
|
518
|
+
return {
|
|
519
|
+
type: 'pattern',
|
|
520
|
+
description: observations.join('; '),
|
|
521
|
+
triggeredActions
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Get observation history
|
|
526
|
+
* @returns Observation history
|
|
527
|
+
*/
|
|
528
|
+
getObservationHistory() {
|
|
529
|
+
return [...this.observationHistory];
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
//# sourceMappingURL=meta-reasoning-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-reasoning-agent.js","sourceRoot":"","sources":["../../src/agents/meta-reasoning-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,WAAW,EAMZ,MAAM,mBAAmB,CAAC;AAuB3B;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,0BAA0B;IAClB,kBAAkB,GAAsB,EAAE,CAAC;IAEnD;;;OAGG;IACH,YAAY,MAGX;QACC,MAAM,mBAAmB,GAAsB;YAC7C;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EAAE,+BAA+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AC,oCAAoC,CAAC,CAAC;YACxD,gBAAgB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE3C,OAAO;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,gBAAgB;SACjB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,qBAAqB;QACnB,OAAO,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoner Agent Implementation
|
|
3
|
+
* @module agents/reasoner-agent
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseAgent } from './base-agent.js';
|
|
7
|
+
import { ReasoningStrategy, type Task, type TaskResult, type AgentCapability } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Reasoner agent that performs various reasoning strategies
|
|
10
|
+
*/
|
|
11
|
+
export declare class ReasonerAgent extends BaseAgent {
|
|
12
|
+
/** Reasoning strategy */
|
|
13
|
+
private strategy;
|
|
14
|
+
/** Maximum iterations */
|
|
15
|
+
private maxIterations;
|
|
16
|
+
/** Confidence threshold */
|
|
17
|
+
private confidenceThreshold;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new reasoner agent
|
|
20
|
+
* @param config - Agent configuration
|
|
21
|
+
*/
|
|
22
|
+
constructor(config: {
|
|
23
|
+
name: string;
|
|
24
|
+
strategy?: ReasoningStrategy;
|
|
25
|
+
maxIterations?: number;
|
|
26
|
+
confidenceThreshold?: number;
|
|
27
|
+
capabilities?: AgentCapability[];
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Get agent type
|
|
31
|
+
* @returns Agent type
|
|
32
|
+
*/
|
|
33
|
+
getType(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get agent capabilities
|
|
36
|
+
* @returns Array of capabilities
|
|
37
|
+
*/
|
|
38
|
+
getCapabilities(): AgentCapability[];
|
|
39
|
+
/**
|
|
40
|
+
* Process a task using the configured reasoning strategy
|
|
41
|
+
* @param task - Task to process
|
|
42
|
+
* @returns Task result
|
|
43
|
+
*/
|
|
44
|
+
process(task: Task): Promise<TaskResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Chain of thought reasoning
|
|
47
|
+
* @param task - Task to process
|
|
48
|
+
* @param startTime - Start time
|
|
49
|
+
* @returns Task result
|
|
50
|
+
*/
|
|
51
|
+
private chainOfThought;
|
|
52
|
+
/**
|
|
53
|
+
* Tree of thought reasoning
|
|
54
|
+
* @param task - Task to process
|
|
55
|
+
* @param startTime - Start time
|
|
56
|
+
* @returns Task result
|
|
57
|
+
*/
|
|
58
|
+
private treeOfThought;
|
|
59
|
+
/**
|
|
60
|
+
* Analogical reasoning
|
|
61
|
+
* @param task - Task to process
|
|
62
|
+
* @param startTime - Start time
|
|
63
|
+
* @returns Task result
|
|
64
|
+
*/
|
|
65
|
+
private analogicalReasoning;
|
|
66
|
+
/**
|
|
67
|
+
* Abductive reasoning
|
|
68
|
+
* @param task - Task to process
|
|
69
|
+
* @param startTime - Start time
|
|
70
|
+
* @returns Task result
|
|
71
|
+
*/
|
|
72
|
+
private abductiveReasoning;
|
|
73
|
+
private calculateStepConfidence;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=reasoner-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoner-agent.d.ts","sourceRoot":"","sources":["../../src/agents/reasoner-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,iBAAiB,EACjB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAa3B;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAoB;IAEpC,yBAAyB;IACzB,OAAO,CAAC,aAAa,CAAS;IAE9B,2BAA2B;IAC3B,OAAO,CAAC,mBAAmB,CAAS;IAEpC;;;OAGG;gBACS,MAAM,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,iBAAiB,CAAC;QAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC;IAgDD;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,eAAe,IAAI,eAAe,EAAE;IAIpC;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAiB9C;;;;;OAKG;YACW,cAAc;IA+D5B;;;;;OAKG;YACW,aAAa;IA2C3B;;;;;OAKG;YACW,mBAAmB;IAoBjC;;;;;OAKG;YACW,kBAAkB;IAoBhC,OAAO,CAAC,uBAAuB;CAMhC"}
|