@gotza02/seq-thinking 1.1.5 → 1.1.7
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 +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +9 -3
- package/agents_test.log +0 -15
- package/data/agents/1770106504306-dljh9ef.json +0 -68
- package/data/agents/1770106504310-4oarrst.json +0 -58
- package/data/agents/1770106540588-pvitt55.json +0 -68
- package/data/agents/1770106540595-z2ya871.json +0 -58
- package/data/agents/1770106710890-0e2naq1.json +0 -68
- package/data/agents/1770106710893-r076yxx.json +0 -58
- package/data/agents/1770109212161-4ybd0i7.json +0 -68
- package/data/agents/1770109212166-gkhya8h.json +0 -58
- package/data/agents/1770117726716-lrnm415.json +0 -68
- package/data/agents/1770117726719-w6hsf3v.json +0 -58
- package/data/sessions/1770100622009-5afiuyv.json +0 -499
- package/data/sessions/1770106504312-75zk750.json +0 -107
- package/data/sessions/1770106540597-z8e8soo.json +0 -150
- package/data/sessions/1770106710894-0kxgy5x.json +0 -150
- package/data/sessions/1770109212169-zpddeb9.json +0 -150
- package/data/sessions/1770117726720-frcwj99.json +0 -150
- package/real_world_test.log +0 -200
- package/real_world_test_dynamic.log +0 -184
- package/real_world_test_real.log +0 -184
- package/src/__tests__/agents.test.ts +0 -858
- package/src/__tests__/mcp-server.test.ts +0 -380
- package/src/__tests__/sequential-thinking.test.ts +0 -687
- package/src/__tests__/swarm-coordinator.test.ts +0 -903
- package/src/__tests__/types.test.ts +0 -839
- package/src/__tests__/utils.test.ts +0 -322
- package/src/agents/base-agent.ts +0 -288
- package/src/agents/critic-agent.ts +0 -582
- package/src/agents/index.ts +0 -11
- package/src/agents/meta-reasoning-agent.ts +0 -314
- package/src/agents/reasoner-agent.ts +0 -312
- package/src/agents/synthesizer-agent.ts +0 -641
- package/src/index.ts +0 -118
- package/src/mcp-server.ts +0 -391
- package/src/real_world_test.ts +0 -89
- package/src/sequential-thinking.ts +0 -614
- package/src/swarm-coordinator.ts +0 -772
- package/src/types/index.ts +0 -915
- package/src/utils/index.ts +0 -1004
- package/src/utils/llm-adapter.ts +0 -110
- package/src/utils/logger.ts +0 -56
- package/src/utils/persistence.ts +0 -109
- package/test_output.log +0 -0
- package/tsconfig.json +0 -21
|
@@ -1,839 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types Test Suite
|
|
3
|
-
* Tests for type definitions, enums, and interfaces
|
|
4
|
-
*/
|
|
5
|
-
import { test, describe } from 'node:test';
|
|
6
|
-
import assert from 'node:assert';
|
|
7
|
-
import {
|
|
8
|
-
ThoughtType,
|
|
9
|
-
AgentType,
|
|
10
|
-
ReasoningStrategy,
|
|
11
|
-
CriticType,
|
|
12
|
-
SynthesizerType,
|
|
13
|
-
MessageType,
|
|
14
|
-
ConsensusAlgorithm,
|
|
15
|
-
ConflictResolutionStrategy,
|
|
16
|
-
AssignmentStrategy,
|
|
17
|
-
BranchStatus,
|
|
18
|
-
SessionStatus,
|
|
19
|
-
TaskStatus,
|
|
20
|
-
ConflictStatus,
|
|
21
|
-
AgentStatus,
|
|
22
|
-
type ConfidenceScore,
|
|
23
|
-
type Thought,
|
|
24
|
-
type ThoughtBranch,
|
|
25
|
-
type MetaNote,
|
|
26
|
-
type SessionContext,
|
|
27
|
-
type SessionSettings,
|
|
28
|
-
type ThinkingSession,
|
|
29
|
-
type AgentConfig,
|
|
30
|
-
type AgentCapability,
|
|
31
|
-
type Agent,
|
|
32
|
-
type SwarmMessage,
|
|
33
|
-
type Task,
|
|
34
|
-
type TaskResult,
|
|
35
|
-
type ConsensusVote,
|
|
36
|
-
type ConsensusResult,
|
|
37
|
-
type Conflict,
|
|
38
|
-
} from '../types/index.js';
|
|
39
|
-
|
|
40
|
-
describe('ThoughtType Enum', () => {
|
|
41
|
-
test('should have all expected values', () => {
|
|
42
|
-
assert.strictEqual(ThoughtType.HYPOTHESIS, 'hypothesis');
|
|
43
|
-
assert.strictEqual(ThoughtType.ANALYSIS, 'analysis');
|
|
44
|
-
assert.strictEqual(ThoughtType.SYNTHESIS, 'synthesis');
|
|
45
|
-
assert.strictEqual(ThoughtType.CONCLUSION, 'conclusion');
|
|
46
|
-
assert.strictEqual(ThoughtType.META_REASONING, 'meta_reasoning');
|
|
47
|
-
assert.strictEqual(ThoughtType.SELF_CORRECTION, 'self_correction');
|
|
48
|
-
assert.strictEqual(ThoughtType.UNCERTAINTY, 'uncertainty');
|
|
49
|
-
assert.strictEqual(ThoughtType.QUESTION, 'question');
|
|
50
|
-
assert.strictEqual(ThoughtType.EVIDENCE, 'evidence');
|
|
51
|
-
assert.strictEqual(ThoughtType.COUNTERARGUMENT, 'counterargument');
|
|
52
|
-
assert.strictEqual(ThoughtType.ASSUMPTION, 'assumption');
|
|
53
|
-
assert.strictEqual(ThoughtType.BRANCH_POINT, 'branch_point');
|
|
54
|
-
assert.strictEqual(ThoughtType.MERGE_POINT, 'merge_point');
|
|
55
|
-
assert.strictEqual(ThoughtType.REVISION, 'revision');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('should have exactly 14 values', () => {
|
|
59
|
-
const values = Object.values(ThoughtType);
|
|
60
|
-
assert.strictEqual(values.length, 14);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('all values should be strings', () => {
|
|
64
|
-
const values = Object.values(ThoughtType);
|
|
65
|
-
values.forEach(value => {
|
|
66
|
-
assert.strictEqual(typeof value, 'string');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('AgentType Enum', () => {
|
|
72
|
-
test('should have all expected values', () => {
|
|
73
|
-
assert.strictEqual(AgentType.REASONER, 'reasoner');
|
|
74
|
-
assert.strictEqual(AgentType.CRITIC, 'critic');
|
|
75
|
-
assert.strictEqual(AgentType.SYNTHESIZER, 'synthesizer');
|
|
76
|
-
assert.strictEqual(AgentType.SPECIALIST, 'specialist');
|
|
77
|
-
assert.strictEqual(AgentType.META_REASONING, 'meta_reasoning');
|
|
78
|
-
assert.strictEqual(AgentType.UTILITY, 'utility');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('should have exactly 6 values', () => {
|
|
82
|
-
const values = Object.values(AgentType);
|
|
83
|
-
assert.strictEqual(values.length, 6);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe('ReasoningStrategy Enum', () => {
|
|
88
|
-
test('should have all expected values', () => {
|
|
89
|
-
assert.strictEqual(ReasoningStrategy.CHAIN_OF_THOUGHT, 'chain_of_thought');
|
|
90
|
-
assert.strictEqual(ReasoningStrategy.TREE_OF_THOUGHT, 'tree_of_thought');
|
|
91
|
-
assert.strictEqual(ReasoningStrategy.ANALOGICAL, 'analogical');
|
|
92
|
-
assert.strictEqual(ReasoningStrategy.ABDUCTIVE, 'abductive');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('should have exactly 4 values', () => {
|
|
96
|
-
const values = Object.values(ReasoningStrategy);
|
|
97
|
-
assert.strictEqual(values.length, 4);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('CriticType Enum', () => {
|
|
102
|
-
test('should have all expected values', () => {
|
|
103
|
-
assert.strictEqual(CriticType.LOGICAL, 'logical');
|
|
104
|
-
assert.strictEqual(CriticType.FACTUAL, 'factual');
|
|
105
|
-
assert.strictEqual(CriticType.BIAS, 'bias');
|
|
106
|
-
assert.strictEqual(CriticType.SAFETY, 'safety');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('should have exactly 4 values', () => {
|
|
110
|
-
const values = Object.values(CriticType);
|
|
111
|
-
assert.strictEqual(values.length, 4);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('SynthesizerType Enum', () => {
|
|
116
|
-
test('should have all expected values', () => {
|
|
117
|
-
assert.strictEqual(SynthesizerType.CONSENSUS, 'consensus');
|
|
118
|
-
assert.strictEqual(SynthesizerType.CREATIVE, 'creative');
|
|
119
|
-
assert.strictEqual(SynthesizerType.CONFLICT_RESOLUTION, 'conflict_resolution');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('should have exactly 3 values', () => {
|
|
123
|
-
const values = Object.values(SynthesizerType);
|
|
124
|
-
assert.strictEqual(values.length, 3);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('MessageType Enum', () => {
|
|
129
|
-
test('should have all expected values', () => {
|
|
130
|
-
assert.strictEqual(MessageType.TASK_ASSIGNMENT, 'task_assignment');
|
|
131
|
-
assert.strictEqual(MessageType.TASK_RESULT, 'task_result');
|
|
132
|
-
assert.strictEqual(MessageType.BROADCAST, 'broadcast');
|
|
133
|
-
assert.strictEqual(MessageType.DIRECT, 'direct');
|
|
134
|
-
assert.strictEqual(MessageType.CONSENSUS_REQUEST, 'consensus_request');
|
|
135
|
-
assert.strictEqual(MessageType.CONSENSUS_VOTE, 'consensus_vote');
|
|
136
|
-
assert.strictEqual(MessageType.CONFLICT_NOTIFICATION, 'conflict_notification');
|
|
137
|
-
assert.strictEqual(MessageType.HEARTBEAT, 'heartbeat');
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test('should have exactly 8 values', () => {
|
|
141
|
-
const values = Object.values(MessageType);
|
|
142
|
-
assert.strictEqual(values.length, 8);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('ConsensusAlgorithm Enum', () => {
|
|
147
|
-
test('should have all expected values', () => {
|
|
148
|
-
assert.strictEqual(ConsensusAlgorithm.MAJORITY_VOTE, 'majority_vote');
|
|
149
|
-
assert.strictEqual(ConsensusAlgorithm.WEIGHTED_VOTE, 'weighted_vote');
|
|
150
|
-
assert.strictEqual(ConsensusAlgorithm.BORDA_COUNT, 'borda_count');
|
|
151
|
-
assert.strictEqual(ConsensusAlgorithm.CONDORCET, 'condorcet');
|
|
152
|
-
assert.strictEqual(ConsensusAlgorithm.DELPHI_METHOD, 'delphi_method');
|
|
153
|
-
assert.strictEqual(ConsensusAlgorithm.PREDICTION_MARKET, 'prediction_market');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
test('should have exactly 6 values', () => {
|
|
157
|
-
const values = Object.values(ConsensusAlgorithm);
|
|
158
|
-
assert.strictEqual(values.length, 6);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe('ConflictResolutionStrategy Enum', () => {
|
|
163
|
-
test('should have all expected values', () => {
|
|
164
|
-
assert.strictEqual(ConflictResolutionStrategy.MEDIATION, 'mediation');
|
|
165
|
-
assert.strictEqual(ConflictResolutionStrategy.ARBITRATION, 'arbitration');
|
|
166
|
-
assert.strictEqual(ConflictResolutionStrategy.VOTING, 'voting');
|
|
167
|
-
assert.strictEqual(ConflictResolutionStrategy.EXPERT_ESCALATION, 'expert_escalation');
|
|
168
|
-
assert.strictEqual(ConflictResolutionStrategy.COMPROMISE, 'compromise');
|
|
169
|
-
assert.strictEqual(ConflictResolutionStrategy.EVIDENCE_BASED, 'evidence_based');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test('should have exactly 6 values', () => {
|
|
173
|
-
const values = Object.values(ConflictResolutionStrategy);
|
|
174
|
-
assert.strictEqual(values.length, 6);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('AssignmentStrategy Type', () => {
|
|
179
|
-
test('should accept valid assignment strategies', () => {
|
|
180
|
-
const strategies: AssignmentStrategy[] = [
|
|
181
|
-
'round_robin',
|
|
182
|
-
'capability_based',
|
|
183
|
-
'load_balanced',
|
|
184
|
-
'performance_based',
|
|
185
|
-
'adaptive',
|
|
186
|
-
'cost_based',
|
|
187
|
-
'fastest_first',
|
|
188
|
-
];
|
|
189
|
-
assert.strictEqual(strategies.length, 7);
|
|
190
|
-
strategies.forEach(strategy => {
|
|
191
|
-
assert.strictEqual(typeof strategy, 'string');
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('ConfidenceScore Interface', () => {
|
|
197
|
-
test('should create valid ConfidenceScore object', () => {
|
|
198
|
-
const score: ConfidenceScore = {
|
|
199
|
-
overall: 0.85,
|
|
200
|
-
components: {
|
|
201
|
-
logicalConsistency: 0.9,
|
|
202
|
-
factualAccuracy: 0.8,
|
|
203
|
-
reasoningQuality: 0.85,
|
|
204
|
-
evidenceStrength: 0.85,
|
|
205
|
-
},
|
|
206
|
-
uncertaintyBounds: [0.7, 0.95],
|
|
207
|
-
calibrationHistory: [
|
|
208
|
-
{
|
|
209
|
-
timestamp: new Date(),
|
|
210
|
-
priorConfidence: 0.7,
|
|
211
|
-
outcome: true,
|
|
212
|
-
adjustedConfidence: 0.75,
|
|
213
|
-
reason: 'Correct prediction',
|
|
214
|
-
adjustment: 0.05,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
assert.strictEqual(typeof score.overall, 'number');
|
|
220
|
-
assert.strictEqual(score.overall, 0.85);
|
|
221
|
-
assert.ok(score.uncertaintyBounds[0] <= score.uncertaintyBounds[1]);
|
|
222
|
-
assert.ok(score.overall >= 0 && score.overall <= 1);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
test('should validate confidence bounds', () => {
|
|
226
|
-
const score: ConfidenceScore = {
|
|
227
|
-
overall: 0.5,
|
|
228
|
-
components: {
|
|
229
|
-
logicalConsistency: 0.5,
|
|
230
|
-
factualAccuracy: 0.5,
|
|
231
|
-
reasoningQuality: 0.5,
|
|
232
|
-
evidenceStrength: 0.5,
|
|
233
|
-
},
|
|
234
|
-
uncertaintyBounds: [0, 1],
|
|
235
|
-
calibrationHistory: [],
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// Overall should be within bounds
|
|
239
|
-
assert.ok(score.overall >= score.uncertaintyBounds[0]);
|
|
240
|
-
assert.ok(score.overall <= score.uncertaintyBounds[1]);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('Thought Interface', () => {
|
|
245
|
-
test('should create valid Thought object', () => {
|
|
246
|
-
const thought: Thought = {
|
|
247
|
-
id: 'thought-001',
|
|
248
|
-
sessionId: 'session-001',
|
|
249
|
-
content: 'This is a test thought',
|
|
250
|
-
stepNumber: 1,
|
|
251
|
-
thoughtType: ThoughtType.HYPOTHESIS,
|
|
252
|
-
confidence: {
|
|
253
|
-
overall: 0.8,
|
|
254
|
-
components: {
|
|
255
|
-
logicalConsistency: 0.85,
|
|
256
|
-
factualAccuracy: 0.75,
|
|
257
|
-
reasoningQuality: 0.8,
|
|
258
|
-
evidenceStrength: 0.8,
|
|
259
|
-
},
|
|
260
|
-
uncertaintyBounds: [0.6, 0.9],
|
|
261
|
-
calibrationHistory: [],
|
|
262
|
-
},
|
|
263
|
-
parentThoughtId: null,
|
|
264
|
-
childThoughtIds: [],
|
|
265
|
-
branchId: 'branch-001',
|
|
266
|
-
revisionOf: null,
|
|
267
|
-
revisionHistory: [],
|
|
268
|
-
metadata: {
|
|
269
|
-
createdAt: new Date(),
|
|
270
|
-
modifiedAt: new Date(),
|
|
271
|
-
agentId: 'agent-001',
|
|
272
|
-
processingTimeMs: 100,
|
|
273
|
-
tokensUsed: 50,
|
|
274
|
-
},
|
|
275
|
-
tags: ['test', 'hypothesis'],
|
|
276
|
-
assumptions: ['assumption-1'],
|
|
277
|
-
dependencies: [],
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
assert.strictEqual(thought.id, 'thought-001');
|
|
281
|
-
assert.strictEqual(thought.stepNumber, 1);
|
|
282
|
-
assert.ok(thought.metadata.createdAt instanceof Date);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
test('should handle revision history', () => {
|
|
286
|
-
const thought: Thought = {
|
|
287
|
-
id: 'thought-002',
|
|
288
|
-
sessionId: 'session-001',
|
|
289
|
-
content: 'Revised content',
|
|
290
|
-
stepNumber: 2,
|
|
291
|
-
thoughtType: ThoughtType.REVISION,
|
|
292
|
-
confidence: {
|
|
293
|
-
overall: 0.9,
|
|
294
|
-
components: {
|
|
295
|
-
logicalConsistency: 0.9,
|
|
296
|
-
factualAccuracy: 0.9,
|
|
297
|
-
reasoningQuality: 0.9,
|
|
298
|
-
evidenceStrength: 0.9,
|
|
299
|
-
},
|
|
300
|
-
uncertaintyBounds: [0.8, 1.0],
|
|
301
|
-
calibrationHistory: [],
|
|
302
|
-
},
|
|
303
|
-
parentThoughtId: 'thought-001',
|
|
304
|
-
childThoughtIds: [],
|
|
305
|
-
branchId: 'branch-001',
|
|
306
|
-
revisionOf: 'thought-001',
|
|
307
|
-
revisionHistory: [
|
|
308
|
-
{
|
|
309
|
-
previousContent: 'Original content',
|
|
310
|
-
revisedAt: new Date(),
|
|
311
|
-
revisionReason: 'Improved clarity',
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
|
-
metadata: {
|
|
315
|
-
createdAt: new Date(),
|
|
316
|
-
modifiedAt: new Date(),
|
|
317
|
-
processingTimeMs: 150,
|
|
318
|
-
tokensUsed: 75,
|
|
319
|
-
},
|
|
320
|
-
tags: [],
|
|
321
|
-
assumptions: [],
|
|
322
|
-
dependencies: ['thought-001'],
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
assert.strictEqual(thought.revisionOf, 'thought-001');
|
|
326
|
-
assert.strictEqual(thought.revisionHistory.length, 1);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
describe('ThoughtBranch Interface', () => {
|
|
331
|
-
test('should create valid ThoughtBranch object', () => {
|
|
332
|
-
const branch: ThoughtBranch = {
|
|
333
|
-
id: 'branch-001',
|
|
334
|
-
sessionId: 'session-001',
|
|
335
|
-
name: 'Main Branch',
|
|
336
|
-
description: 'Primary reasoning path',
|
|
337
|
-
rootThoughtId: 'thought-001',
|
|
338
|
-
thoughtIds: ['thought-001', 'thought-002'],
|
|
339
|
-
parentBranchId: null,
|
|
340
|
-
childBranchIds: [],
|
|
341
|
-
status: BranchStatus.ACTIVE,
|
|
342
|
-
confidence: 0.85,
|
|
343
|
-
metadata: {
|
|
344
|
-
createdAt: new Date(),
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
assert.strictEqual(branch.status, 'active');
|
|
349
|
-
assert.ok(['active', 'pruned', 'merged', 'completed'].includes(branch.status));
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
test('should handle pruned branch', () => {
|
|
353
|
-
const branch: ThoughtBranch = {
|
|
354
|
-
id: 'branch-002',
|
|
355
|
-
sessionId: 'session-001',
|
|
356
|
-
name: 'Alternative Path',
|
|
357
|
-
description: 'Discarded branch',
|
|
358
|
-
rootThoughtId: 'thought-003',
|
|
359
|
-
thoughtIds: ['thought-003'],
|
|
360
|
-
parentBranchId: 'branch-001',
|
|
361
|
-
childBranchIds: [],
|
|
362
|
-
status: BranchStatus.PRUNED,
|
|
363
|
-
confidence: 0.3,
|
|
364
|
-
metadata: {
|
|
365
|
-
createdAt: new Date(),
|
|
366
|
-
prunedAt: new Date(),
|
|
367
|
-
pruneReason: 'Low confidence',
|
|
368
|
-
},
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
assert.strictEqual(branch.status, 'pruned');
|
|
372
|
-
assert.ok(branch.metadata.prunedAt instanceof Date);
|
|
373
|
-
assert.strictEqual(branch.metadata.pruneReason, 'Low confidence');
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
describe('MetaNote Interface', () => {
|
|
378
|
-
test('should create valid MetaNote object', () => {
|
|
379
|
-
const metaNote: MetaNote = {
|
|
380
|
-
id: 'meta-001',
|
|
381
|
-
thoughtId: 'thought-001',
|
|
382
|
-
content: 'Pattern detected in reasoning',
|
|
383
|
-
observationType: 'pattern',
|
|
384
|
-
timestamp: new Date(),
|
|
385
|
-
triggeredActions: ['review', 'validate'],
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
assert.ok(['pattern', 'concern', 'strategy', 'bias', 'confidence', 'process'].includes(metaNote.observationType));
|
|
389
|
-
assert.strictEqual(metaNote.triggeredActions.length, 2);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe('SessionContext Interface', () => {
|
|
394
|
-
test('should create valid SessionContext object', () => {
|
|
395
|
-
const context: SessionContext = {
|
|
396
|
-
originalProblem: 'Solve this complex problem',
|
|
397
|
-
constraints: ['time < 1 hour', 'budget < $100'],
|
|
398
|
-
relevantInformation: ['info-1', 'info-2'],
|
|
399
|
-
workingMemory: new Map([['key', 'value']]),
|
|
400
|
-
longTermReferences: ['ref-1', 'ref-2'],
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
assert.strictEqual(context.originalProblem, 'Solve this complex problem');
|
|
404
|
-
assert.strictEqual(context.constraints.length, 2);
|
|
405
|
-
assert.ok(context.workingMemory instanceof Map);
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
test('should handle empty context', () => {
|
|
409
|
-
const context: SessionContext = {
|
|
410
|
-
originalProblem: '',
|
|
411
|
-
constraints: [],
|
|
412
|
-
relevantInformation: [],
|
|
413
|
-
workingMemory: new Map(),
|
|
414
|
-
longTermReferences: [],
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
assert.strictEqual(context.constraints.length, 0);
|
|
418
|
-
assert.strictEqual(context.workingMemory.size, 0);
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
describe('SessionSettings Interface', () => {
|
|
423
|
-
test('should create valid SessionSettings object', () => {
|
|
424
|
-
const settings: SessionSettings = {
|
|
425
|
-
maxBranches: 5,
|
|
426
|
-
maxDepth: 10,
|
|
427
|
-
confidenceThreshold: 0.7,
|
|
428
|
-
enableSelfCorrection: true,
|
|
429
|
-
enableMetaReasoning: true,
|
|
430
|
-
enableParallelHypotheses: true,
|
|
431
|
-
adaptiveGranularity: true,
|
|
432
|
-
granularitySettings: {
|
|
433
|
-
minStepDetail: 1,
|
|
434
|
-
maxStepDetail: 10,
|
|
435
|
-
complexityThreshold: 0.5,
|
|
436
|
-
},
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
assert.strictEqual(settings.maxBranches, 5);
|
|
440
|
-
assert.ok(settings.enableSelfCorrection);
|
|
441
|
-
assert.ok(settings.granularitySettings.minStepDetail < settings.granularitySettings.maxStepDetail);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
test('should validate confidence threshold range', () => {
|
|
445
|
-
const settings: SessionSettings = {
|
|
446
|
-
maxBranches: 3,
|
|
447
|
-
maxDepth: 5,
|
|
448
|
-
confidenceThreshold: 0.5,
|
|
449
|
-
enableSelfCorrection: false,
|
|
450
|
-
enableMetaReasoning: false,
|
|
451
|
-
enableParallelHypotheses: false,
|
|
452
|
-
adaptiveGranularity: false,
|
|
453
|
-
granularitySettings: {
|
|
454
|
-
minStepDetail: 1,
|
|
455
|
-
maxStepDetail: 5,
|
|
456
|
-
complexityThreshold: 0.3,
|
|
457
|
-
},
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
assert.ok(settings.confidenceThreshold >= 0 && settings.confidenceThreshold <= 1);
|
|
461
|
-
});
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
describe('ThinkingSession Interface', () => {
|
|
465
|
-
test('should create valid ThinkingSession object', () => {
|
|
466
|
-
const session: ThinkingSession = {
|
|
467
|
-
id: 'session-001',
|
|
468
|
-
topic: 'Test Topic',
|
|
469
|
-
status: SessionStatus.INITIALIZING,
|
|
470
|
-
currentBranchId: 'branch-001',
|
|
471
|
-
branches: new Map(),
|
|
472
|
-
thoughts: new Map(),
|
|
473
|
-
metaNotes: new Map(),
|
|
474
|
-
context: {
|
|
475
|
-
originalProblem: 'Test problem',
|
|
476
|
-
constraints: [],
|
|
477
|
-
relevantInformation: [],
|
|
478
|
-
workingMemory: new Map(),
|
|
479
|
-
longTermReferences: [],
|
|
480
|
-
},
|
|
481
|
-
settings: {
|
|
482
|
-
maxBranches: 3,
|
|
483
|
-
maxDepth: 5,
|
|
484
|
-
confidenceThreshold: 0.7,
|
|
485
|
-
enableSelfCorrection: true,
|
|
486
|
-
enableMetaReasoning: true,
|
|
487
|
-
enableParallelHypotheses: false,
|
|
488
|
-
adaptiveGranularity: true,
|
|
489
|
-
granularitySettings: {
|
|
490
|
-
minStepDetail: 1,
|
|
491
|
-
maxStepDetail: 5,
|
|
492
|
-
complexityThreshold: 0.5,
|
|
493
|
-
},
|
|
494
|
-
},
|
|
495
|
-
metadata: {
|
|
496
|
-
createdAt: new Date(),
|
|
497
|
-
lastActivityAt: new Date(),
|
|
498
|
-
totalThoughts: 0,
|
|
499
|
-
totalBranches: 1,
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
assert.ok(Object.values(SessionStatus).includes(session.status));
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
describe('AgentCapability Interface', () => {
|
|
508
|
-
test('should create valid AgentCapability object', () => {
|
|
509
|
-
const capability: AgentCapability = {
|
|
510
|
-
name: 'logical-reasoning',
|
|
511
|
-
description: 'Ability to perform logical reasoning',
|
|
512
|
-
confidence: 0.9,
|
|
513
|
-
performanceMetrics: {
|
|
514
|
-
tasksCompleted: 100,
|
|
515
|
-
averageQuality: 0.85,
|
|
516
|
-
averageTimeMs: 500,
|
|
517
|
-
},
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
assert.strictEqual(capability.name, 'logical-reasoning');
|
|
521
|
-
assert.ok(capability.confidence >= 0 && capability.confidence <= 1);
|
|
522
|
-
assert.ok(capability.performanceMetrics.averageQuality >= 0 && capability.performanceMetrics.averageQuality <= 1);
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
describe('AgentConfig Interface', () => {
|
|
527
|
-
test('should create valid AgentConfig object', () => {
|
|
528
|
-
const config: AgentConfig = {
|
|
529
|
-
id: 'agent-001',
|
|
530
|
-
name: 'Test Agent',
|
|
531
|
-
type: AgentType.REASONER,
|
|
532
|
-
subtype: 'chain-of-thought',
|
|
533
|
-
capabilities: [
|
|
534
|
-
{
|
|
535
|
-
name: 'reasoning',
|
|
536
|
-
description: 'Logical reasoning',
|
|
537
|
-
confidence: 0.9,
|
|
538
|
-
performanceMetrics: {
|
|
539
|
-
tasksCompleted: 50,
|
|
540
|
-
averageQuality: 0.85,
|
|
541
|
-
averageTimeMs: 300,
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
],
|
|
545
|
-
maxConcurrentTasks: 3,
|
|
546
|
-
confidenceThreshold: 0.7,
|
|
547
|
-
metadata: {
|
|
548
|
-
createdAt: new Date(),
|
|
549
|
-
version: '1.0.0',
|
|
550
|
-
config: {},
|
|
551
|
-
},
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
assert.strictEqual(config.type, AgentType.REASONER);
|
|
555
|
-
assert.ok(config.maxConcurrentTasks > 0);
|
|
556
|
-
});
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
describe('Agent Interface', () => {
|
|
560
|
-
test('should create valid Agent object', () => {
|
|
561
|
-
const agent: Agent = {
|
|
562
|
-
config: {
|
|
563
|
-
id: 'agent-001',
|
|
564
|
-
name: 'Test Agent',
|
|
565
|
-
type: AgentType.REASONER,
|
|
566
|
-
capabilities: [],
|
|
567
|
-
maxConcurrentTasks: 1,
|
|
568
|
-
confidenceThreshold: 0.5,
|
|
569
|
-
metadata: {
|
|
570
|
-
createdAt: new Date(),
|
|
571
|
-
version: '1.0.0',
|
|
572
|
-
config: {},
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
status: AgentStatus.IDLE,
|
|
576
|
-
currentTasks: [],
|
|
577
|
-
performanceHistory: [],
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
assert.ok(['idle', 'busy', 'offline'].includes(agent.status));
|
|
581
|
-
assert.strictEqual(agent.currentTasks.length, 0);
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
describe('SwarmMessage Interface', () => {
|
|
586
|
-
test('should create valid SwarmMessage object', () => {
|
|
587
|
-
const message: SwarmMessage = {
|
|
588
|
-
id: 'msg-001',
|
|
589
|
-
type: MessageType.TASK_ASSIGNMENT,
|
|
590
|
-
senderId: 'agent-001',
|
|
591
|
-
recipientId: 'agent-002',
|
|
592
|
-
timestamp: new Date(),
|
|
593
|
-
payload: { taskId: 'task-001' },
|
|
594
|
-
context: {
|
|
595
|
-
sessionId: 'session-001',
|
|
596
|
-
taskId: 'task-001',
|
|
597
|
-
correlationId: 'corr-001',
|
|
598
|
-
},
|
|
599
|
-
metadata: {
|
|
600
|
-
priority: 1,
|
|
601
|
-
ttl: 30000,
|
|
602
|
-
retryCount: 0,
|
|
603
|
-
},
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
assert.strictEqual(message.type, MessageType.TASK_ASSIGNMENT);
|
|
607
|
-
assert.ok(message.metadata.priority >= 0);
|
|
608
|
-
assert.ok(message.metadata.ttl > 0);
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
test('should handle broadcast message', () => {
|
|
612
|
-
const message: SwarmMessage = {
|
|
613
|
-
id: 'msg-002',
|
|
614
|
-
type: MessageType.BROADCAST,
|
|
615
|
-
senderId: 'agent-001',
|
|
616
|
-
recipientId: null,
|
|
617
|
-
timestamp: new Date(),
|
|
618
|
-
payload: { announcement: 'Hello all' },
|
|
619
|
-
context: {},
|
|
620
|
-
metadata: {
|
|
621
|
-
priority: 0,
|
|
622
|
-
ttl: 60000,
|
|
623
|
-
retryCount: 0,
|
|
624
|
-
},
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
assert.strictEqual(message.recipientId, null);
|
|
628
|
-
});
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
describe('Task Interface', () => {
|
|
632
|
-
test('should create valid Task object', () => {
|
|
633
|
-
const task: Task = {
|
|
634
|
-
id: 'task-001',
|
|
635
|
-
type: 'reasoning',
|
|
636
|
-
description: 'Perform reasoning task',
|
|
637
|
-
input: { problem: 'Solve X' },
|
|
638
|
-
context: {
|
|
639
|
-
sessionId: 'session-001',
|
|
640
|
-
dependencies: [],
|
|
641
|
-
},
|
|
642
|
-
requirements: {
|
|
643
|
-
requiredCapabilities: ['reasoning'],
|
|
644
|
-
minConfidence: 0.7,
|
|
645
|
-
maxTimeMs: 5000,
|
|
646
|
-
},
|
|
647
|
-
assignedAgentId: null,
|
|
648
|
-
status: TaskStatus.PENDING,
|
|
649
|
-
result: null,
|
|
650
|
-
metadata: {
|
|
651
|
-
createdAt: new Date(),
|
|
652
|
-
},
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
assert.ok(['pending', 'assigned', 'in_progress', 'completed', 'failed'].includes(task.status));
|
|
656
|
-
assert.ok(task.requirements.maxTimeMs > 0);
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
test('should handle completed task', () => {
|
|
660
|
-
const task: Task = {
|
|
661
|
-
id: 'task-002',
|
|
662
|
-
type: 'analysis',
|
|
663
|
-
description: 'Analyze data',
|
|
664
|
-
input: { data: [1, 2, 3] },
|
|
665
|
-
context: {
|
|
666
|
-
sessionId: 'session-001',
|
|
667
|
-
parentTaskId: 'task-001',
|
|
668
|
-
dependencies: ['task-001'],
|
|
669
|
-
},
|
|
670
|
-
requirements: {
|
|
671
|
-
requiredCapabilities: ['analysis'],
|
|
672
|
-
minConfidence: 0.8,
|
|
673
|
-
maxTimeMs: 10000,
|
|
674
|
-
},
|
|
675
|
-
assignedAgentId: 'agent-001',
|
|
676
|
-
status: TaskStatus.COMPLETED,
|
|
677
|
-
result: {
|
|
678
|
-
taskId: 'task-001',
|
|
679
|
-
agentId: 'agent-001',
|
|
680
|
-
success: true,
|
|
681
|
-
output: 'Analysis complete',
|
|
682
|
-
confidence: 0.9,
|
|
683
|
-
processingTimeMs: 1500,
|
|
684
|
-
metadata: {
|
|
685
|
-
tokensUsed: 500,
|
|
686
|
-
reasoningSteps: 5,
|
|
687
|
-
intermediateResults: [],
|
|
688
|
-
},
|
|
689
|
-
},
|
|
690
|
-
metadata: {
|
|
691
|
-
createdAt: new Date(),
|
|
692
|
-
assignedAt: new Date(),
|
|
693
|
-
startedAt: new Date(),
|
|
694
|
-
completedAt: new Date(),
|
|
695
|
-
},
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
assert.strictEqual(task.status, 'completed');
|
|
699
|
-
assert.ok(task.metadata.completedAt instanceof Date);
|
|
700
|
-
});
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
describe('TaskResult Interface', () => {
|
|
704
|
-
test('should create valid TaskResult object', () => {
|
|
705
|
-
const result: TaskResult = {
|
|
706
|
-
taskId: 'task-001',
|
|
707
|
-
agentId: 'agent-001',
|
|
708
|
-
success: true,
|
|
709
|
-
output: { answer: 42 },
|
|
710
|
-
confidence: 0.9,
|
|
711
|
-
processingTimeMs: 500,
|
|
712
|
-
metadata: {
|
|
713
|
-
tokensUsed: 100,
|
|
714
|
-
reasoningSteps: 5,
|
|
715
|
-
intermediateResults: [],
|
|
716
|
-
},
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
assert.strictEqual(result.success, true);
|
|
720
|
-
assert.ok(result.confidence >= 0 && result.confidence <= 1);
|
|
721
|
-
assert.ok(result.processingTimeMs >= 0);
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
test('should handle failed result', () => {
|
|
725
|
-
const result: TaskResult = {
|
|
726
|
-
taskId: 'task-002',
|
|
727
|
-
agentId: 'agent-001',
|
|
728
|
-
success: false,
|
|
729
|
-
output: null,
|
|
730
|
-
confidence: 0,
|
|
731
|
-
processingTimeMs: 100,
|
|
732
|
-
metadata: {
|
|
733
|
-
tokensUsed: 50,
|
|
734
|
-
reasoningSteps: 1,
|
|
735
|
-
intermediateResults: [],
|
|
736
|
-
error: 'Task failed due to timeout',
|
|
737
|
-
},
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
assert.strictEqual(result.success, false);
|
|
741
|
-
assert.ok(result.metadata.error);
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
describe('ConsensusVote Interface', () => {
|
|
746
|
-
test('should create valid ConsensusVote object', () => {
|
|
747
|
-
const vote: ConsensusVote = {
|
|
748
|
-
agentId: 'agent-001',
|
|
749
|
-
proposalId: 'proposal-001',
|
|
750
|
-
vote: 'option-a',
|
|
751
|
-
confidence: 0.8,
|
|
752
|
-
reasoning: 'This option is optimal',
|
|
753
|
-
timestamp: new Date(),
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
assert.strictEqual(vote.agentId, 'agent-001');
|
|
757
|
-
assert.ok(vote.confidence >= 0 && vote.confidence <= 1);
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
describe('ConsensusResult Interface', () => {
|
|
762
|
-
test('should create valid ConsensusResult object', () => {
|
|
763
|
-
const result: ConsensusResult = {
|
|
764
|
-
proposalId: 'proposal-001',
|
|
765
|
-
algorithm: ConsensusAlgorithm.MAJORITY_VOTE,
|
|
766
|
-
winningOption: 'option-a',
|
|
767
|
-
confidence: 0.75,
|
|
768
|
-
votes: [],
|
|
769
|
-
agreementRatio: 0.8,
|
|
770
|
-
dissentingOpinions: [],
|
|
771
|
-
metadata: {
|
|
772
|
-
rounds: 1,
|
|
773
|
-
totalVotingTimeMs: 1000,
|
|
774
|
-
convergenceRate: 0.9,
|
|
775
|
-
},
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
assert.ok(result.agreementRatio >= 0 && result.agreementRatio <= 1);
|
|
779
|
-
assert.ok(result.metadata.rounds > 0);
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
describe('Conflict Interface', () => {
|
|
784
|
-
test('should create valid Conflict object', () => {
|
|
785
|
-
const conflict: Conflict = {
|
|
786
|
-
id: 'conflict-001',
|
|
787
|
-
type: 'disagreement',
|
|
788
|
-
description: 'Agents disagree on approach',
|
|
789
|
-
involvedAgents: ['agent-001', 'agent-002'],
|
|
790
|
-
conflictingPositions: [
|
|
791
|
-
{
|
|
792
|
-
agentId: 'agent-001',
|
|
793
|
-
position: 'approach-a',
|
|
794
|
-
evidence: ['evidence-1'],
|
|
795
|
-
confidence: 0.8,
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
agentId: 'agent-002',
|
|
799
|
-
position: 'approach-b',
|
|
800
|
-
evidence: ['evidence-2'],
|
|
801
|
-
confidence: 0.75,
|
|
802
|
-
},
|
|
803
|
-
],
|
|
804
|
-
status: ConflictStatus.DETECTED,
|
|
805
|
-
resolution: null,
|
|
806
|
-
metadata: {
|
|
807
|
-
createdAt: new Date(),
|
|
808
|
-
},
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
assert.ok(Object.values(ConflictStatus).includes(conflict.status));
|
|
812
|
-
assert.strictEqual(conflict.involvedAgents.length, 2);
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
test('should handle resolved conflict', () => {
|
|
816
|
-
const conflict: Conflict = {
|
|
817
|
-
id: 'conflict-002',
|
|
818
|
-
type: 'resource-contention',
|
|
819
|
-
description: 'Resource allocation dispute',
|
|
820
|
-
involvedAgents: ['agent-001', 'agent-002'],
|
|
821
|
-
conflictingPositions: [],
|
|
822
|
-
status: ConflictStatus.RESOLVED,
|
|
823
|
-
resolution: {
|
|
824
|
-
strategy: ConflictResolutionStrategy.COMPROMISE,
|
|
825
|
-
result: 'compromise',
|
|
826
|
-
confidence: 0.8,
|
|
827
|
-
reasoning: 'Balanced approach',
|
|
828
|
-
},
|
|
829
|
-
metadata: {
|
|
830
|
-
createdAt: new Date(),
|
|
831
|
-
resolvedAt: new Date(),
|
|
832
|
-
resolutionStrategy: ConflictResolutionStrategy.COMPROMISE,
|
|
833
|
-
},
|
|
834
|
-
};
|
|
835
|
-
|
|
836
|
-
assert.strictEqual(conflict.status, 'resolved');
|
|
837
|
-
assert.ok(conflict.metadata.resolvedAt instanceof Date);
|
|
838
|
-
});
|
|
839
|
-
});
|