@gotza02/seq-thinking 1.1.5 → 1.1.6
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +8 -2
- 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
package/src/types/index.ts
DELETED
|
@@ -1,915 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Type Definitions for MCP Sequential Thinking System
|
|
3
|
-
* @module types
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Enumeration of thought types for classification and routing
|
|
9
|
-
*/
|
|
10
|
-
export enum ThoughtType {
|
|
11
|
-
/** Proposed explanation or theory */
|
|
12
|
-
HYPOTHESIS = 'hypothesis',
|
|
13
|
-
/** Breaking down complex information */
|
|
14
|
-
ANALYSIS = 'analysis',
|
|
15
|
-
/** Combining multiple thoughts */
|
|
16
|
-
SYNTHESIS = 'synthesis',
|
|
17
|
-
/** Final determination */
|
|
18
|
-
CONCLUSION = 'conclusion',
|
|
19
|
-
/** Thinking about the thinking process */
|
|
20
|
-
META_REASONING = 'meta_reasoning',
|
|
21
|
-
/** Identifying and fixing errors */
|
|
22
|
-
SELF_CORRECTION = 'self_correction',
|
|
23
|
-
/** Expressing doubt or unknowns */
|
|
24
|
-
UNCERTAINTY = 'uncertainty',
|
|
25
|
-
/** Inquiry to explore */
|
|
26
|
-
QUESTION = 'question',
|
|
27
|
-
/** Supporting information */
|
|
28
|
-
EVIDENCE = 'evidence',
|
|
29
|
-
/** Opposing viewpoint */
|
|
30
|
-
COUNTERARGUMENT = 'counterargument',
|
|
31
|
-
/** Base premise */
|
|
32
|
-
ASSUMPTION = 'assumption',
|
|
33
|
-
/** Where parallel paths diverge */
|
|
34
|
-
BRANCH_POINT = 'branch_point',
|
|
35
|
-
/** Where paths converge */
|
|
36
|
-
MERGE_POINT = 'merge_point',
|
|
37
|
-
/** Modified version of prior thought */
|
|
38
|
-
REVISION = 'revision'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Enumeration of agent types
|
|
43
|
-
*/
|
|
44
|
-
export enum AgentType {
|
|
45
|
-
/** Reasoning agent */
|
|
46
|
-
REASONER = 'reasoner',
|
|
47
|
-
/** Critic/Evaluation agent */
|
|
48
|
-
CRITIC = 'critic',
|
|
49
|
-
/** Synthesis agent */
|
|
50
|
-
SYNTHESIZER = 'synthesizer',
|
|
51
|
-
/** Domain specialist agent */
|
|
52
|
-
SPECIALIST = 'specialist',
|
|
53
|
-
/** Meta-reasoning agent */
|
|
54
|
-
META_REASONING = 'meta_reasoning',
|
|
55
|
-
/** Utility agent */
|
|
56
|
-
UTILITY = 'utility'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Enumeration of reasoning strategies
|
|
61
|
-
*/
|
|
62
|
-
export enum ReasoningStrategy {
|
|
63
|
-
/** Step-by-step reasoning */
|
|
64
|
-
CHAIN_OF_THOUGHT = 'chain_of_thought',
|
|
65
|
-
/** Explore multiple paths */
|
|
66
|
-
TREE_OF_THOUGHT = 'tree_of_thought',
|
|
67
|
-
/** Reason by analogy */
|
|
68
|
-
ANALOGICAL = 'analogical',
|
|
69
|
-
/** Inference to best explanation */
|
|
70
|
-
ABDUCTIVE = 'abductive'
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Enumeration of critic types
|
|
75
|
-
*/
|
|
76
|
-
export enum CriticType {
|
|
77
|
-
/** Check logical consistency */
|
|
78
|
-
LOGICAL = 'logical',
|
|
79
|
-
/** Verify factual accuracy */
|
|
80
|
-
FACTUAL = 'factual',
|
|
81
|
-
/** Detect cognitive biases */
|
|
82
|
-
BIAS = 'bias',
|
|
83
|
-
/** Check safety concerns */
|
|
84
|
-
SAFETY = 'safety'
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Enumeration of synthesizer types
|
|
89
|
-
*/
|
|
90
|
-
export enum SynthesizerType {
|
|
91
|
-
/** Build consensus */
|
|
92
|
-
CONSENSUS = 'consensus',
|
|
93
|
-
/** Creative combination */
|
|
94
|
-
CREATIVE = 'creative',
|
|
95
|
-
/** Resolve conflicts */
|
|
96
|
-
CONFLICT_RESOLUTION = 'conflict_resolution'
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Enumeration of message types
|
|
101
|
-
*/
|
|
102
|
-
export enum MessageType {
|
|
103
|
-
/** Task assignment message */
|
|
104
|
-
TASK_ASSIGNMENT = 'task_assignment',
|
|
105
|
-
/** Task result message */
|
|
106
|
-
TASK_RESULT = 'task_result',
|
|
107
|
-
/** Broadcast to all agents */
|
|
108
|
-
BROADCAST = 'broadcast',
|
|
109
|
-
/** Direct message to specific agent */
|
|
110
|
-
DIRECT = 'direct',
|
|
111
|
-
/** Request for consensus */
|
|
112
|
-
CONSENSUS_REQUEST = 'consensus_request',
|
|
113
|
-
/** Consensus vote */
|
|
114
|
-
CONSENSUS_VOTE = 'consensus_vote',
|
|
115
|
-
/** Conflict notification */
|
|
116
|
-
CONFLICT_NOTIFICATION = 'conflict_notification',
|
|
117
|
-
/** Heartbeat/ping */
|
|
118
|
-
HEARTBEAT = 'heartbeat'
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Enumeration of consensus algorithms
|
|
123
|
-
*/
|
|
124
|
-
export enum ConsensusAlgorithm {
|
|
125
|
-
/** Simple majority vote */
|
|
126
|
-
MAJORITY_VOTE = 'majority_vote',
|
|
127
|
-
/** Weighted by expertise/confidence */
|
|
128
|
-
WEIGHTED_VOTE = 'weighted_vote',
|
|
129
|
-
/** Borda count ranking */
|
|
130
|
-
BORDA_COUNT = 'borda_count',
|
|
131
|
-
/** Condorcet method */
|
|
132
|
-
CONDORCET = 'condorcet',
|
|
133
|
-
/** Iterative Delphi method */
|
|
134
|
-
DELPHI_METHOD = 'delphi_method',
|
|
135
|
-
/** Prediction market style */
|
|
136
|
-
PREDICTION_MARKET = 'prediction_market'
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Enumeration of conflict resolution strategies
|
|
141
|
-
*/
|
|
142
|
-
export enum ConflictResolutionStrategy {
|
|
143
|
-
/** Facilitated discussion */
|
|
144
|
-
MEDIATION = 'mediation',
|
|
145
|
-
/** Third-party decision */
|
|
146
|
-
ARBITRATION = 'arbitration',
|
|
147
|
-
/** Voting-based resolution */
|
|
148
|
-
VOTING = 'voting',
|
|
149
|
-
/** Escalate to expert */
|
|
150
|
-
EXPERT_ESCALATION = 'expert_escalation',
|
|
151
|
-
/** Find middle ground */
|
|
152
|
-
COMPROMISE = 'compromise',
|
|
153
|
-
/** Evidence-based resolution */
|
|
154
|
-
EVIDENCE_BASED = 'evidence_based'
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Enumeration of task statuses
|
|
159
|
-
*/
|
|
160
|
-
export enum TaskStatus {
|
|
161
|
-
/** Task is pending */
|
|
162
|
-
PENDING = 'pending',
|
|
163
|
-
/** Task is assigned to agent */
|
|
164
|
-
ASSIGNED = 'assigned',
|
|
165
|
-
/** Task is in progress */
|
|
166
|
-
IN_PROGRESS = 'in_progress',
|
|
167
|
-
/** Task is completed */
|
|
168
|
-
COMPLETED = 'completed',
|
|
169
|
-
/** Task failed */
|
|
170
|
-
FAILED = 'failed',
|
|
171
|
-
/** Task was cancelled */
|
|
172
|
-
CANCELLED = 'cancelled'
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Enumeration of agent statuses
|
|
177
|
-
*/
|
|
178
|
-
export enum AgentStatus {
|
|
179
|
-
/** Agent is idle */
|
|
180
|
-
IDLE = 'idle',
|
|
181
|
-
/** Agent is busy */
|
|
182
|
-
BUSY = 'busy',
|
|
183
|
-
/** Agent is offline */
|
|
184
|
-
OFFLINE = 'offline',
|
|
185
|
-
/** Agent is error state */
|
|
186
|
-
ERROR = 'error',
|
|
187
|
-
/** Agent is initializing */
|
|
188
|
-
INITIALIZING = 'initializing'
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Enumeration of branch statuses
|
|
193
|
-
*/
|
|
194
|
-
export enum BranchStatus {
|
|
195
|
-
/** Branch is active */
|
|
196
|
-
ACTIVE = 'active',
|
|
197
|
-
/** Branch is completed */
|
|
198
|
-
COMPLETED = 'completed',
|
|
199
|
-
/** Branch is merged */
|
|
200
|
-
MERGED = 'merged',
|
|
201
|
-
/** Branch is pruned */
|
|
202
|
-
PRUNED = 'pruned',
|
|
203
|
-
/** Branch is abandoned */
|
|
204
|
-
ABANDONED = 'abandoned'
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Enumeration of session statuses
|
|
209
|
-
*/
|
|
210
|
-
export enum SessionStatus {
|
|
211
|
-
/** Session is initializing */
|
|
212
|
-
INITIALIZING = 'initializing',
|
|
213
|
-
/** Session is active */
|
|
214
|
-
ACTIVE = 'active',
|
|
215
|
-
/** Session is paused */
|
|
216
|
-
PAUSED = 'paused',
|
|
217
|
-
/** Session is converging */
|
|
218
|
-
CONVERGING = 'converging',
|
|
219
|
-
/** Session is completed */
|
|
220
|
-
COMPLETED = 'completed',
|
|
221
|
-
/** Session is abandoned */
|
|
222
|
-
ABANDONED = 'abandoned'
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Enumeration of conflict statuses
|
|
227
|
-
*/
|
|
228
|
-
export enum ConflictStatus {
|
|
229
|
-
/** Conflict is detected */
|
|
230
|
-
DETECTED = 'detected',
|
|
231
|
-
/** Conflict is being analyzed */
|
|
232
|
-
ANALYZING = 'analyzing',
|
|
233
|
-
/** Conflict is being resolved */
|
|
234
|
-
RESOLVING = 'resolving',
|
|
235
|
-
/** Conflict is resolved */
|
|
236
|
-
RESOLVED = 'resolved',
|
|
237
|
-
/** Conflict resolution failed */
|
|
238
|
-
FAILED = 'failed'
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// ============================================================================
|
|
242
|
-
// Confidence and Scoring Interfaces
|
|
243
|
-
// ============================================================================
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Confidence score with calibration data
|
|
247
|
-
*/
|
|
248
|
-
export interface ConfidenceScore {
|
|
249
|
-
/** Primary score (0.0 - 1.0) */
|
|
250
|
-
overall: number;
|
|
251
|
-
/** Component scores */
|
|
252
|
-
components: {
|
|
253
|
-
/** Internal logic check */
|
|
254
|
-
logicalConsistency: number;
|
|
255
|
-
/** Factual accuracy */
|
|
256
|
-
factualAccuracy: number;
|
|
257
|
-
/** Quality of reasoning */
|
|
258
|
-
reasoningQuality: number;
|
|
259
|
-
/** Strength of evidence */
|
|
260
|
-
evidenceStrength: number;
|
|
261
|
-
};
|
|
262
|
-
/** Uncertainty bounds [lower, upper] */
|
|
263
|
-
uncertaintyBounds: [number, number];
|
|
264
|
-
/** Calibration history */
|
|
265
|
-
calibrationHistory: CalibrationPoint[];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Single calibration data point
|
|
270
|
-
*/
|
|
271
|
-
export interface CalibrationPoint {
|
|
272
|
-
/** Timestamp of calibration */
|
|
273
|
-
timestamp: Date;
|
|
274
|
-
/** Prior confidence value */
|
|
275
|
-
priorConfidence: number;
|
|
276
|
-
/** Outcome - was the thought correct? */
|
|
277
|
-
outcome: boolean;
|
|
278
|
-
/** Adjusted confidence after outcome */
|
|
279
|
-
adjustedConfidence: number;
|
|
280
|
-
/** Reason for adjustment */
|
|
281
|
-
reason: string;
|
|
282
|
-
/** Adjustment amount */
|
|
283
|
-
adjustment?: number;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// ============================================================================
|
|
287
|
-
// Thought and Branch Interfaces
|
|
288
|
-
// ============================================================================
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Core thought node structure
|
|
292
|
-
*/
|
|
293
|
-
export interface Thought {
|
|
294
|
-
/** Unique identifier */
|
|
295
|
-
id: string;
|
|
296
|
-
/** Session ID */
|
|
297
|
-
sessionId: string;
|
|
298
|
-
/** Thought content */
|
|
299
|
-
content: string;
|
|
300
|
-
/** Sequential position */
|
|
301
|
-
stepNumber: number;
|
|
302
|
-
/** Type of thought */
|
|
303
|
-
thoughtType: ThoughtType;
|
|
304
|
-
/** Confidence score */
|
|
305
|
-
confidence: ConfidenceScore;
|
|
306
|
-
/** Parent thought ID */
|
|
307
|
-
parentThoughtId: string | null;
|
|
308
|
-
/** Child thought IDs */
|
|
309
|
-
childThoughtIds: string[];
|
|
310
|
-
/** Branch ID */
|
|
311
|
-
branchId: string;
|
|
312
|
-
/** Original thought ID if this is a revision */
|
|
313
|
-
revisionOf: string | null;
|
|
314
|
-
/** Revision history */
|
|
315
|
-
revisionHistory: RevisionRecord[];
|
|
316
|
-
/** Metadata */
|
|
317
|
-
metadata: {
|
|
318
|
-
createdAt: Date;
|
|
319
|
-
modifiedAt: Date;
|
|
320
|
-
agentId?: string;
|
|
321
|
-
processingTimeMs: number;
|
|
322
|
-
tokensUsed: number;
|
|
323
|
-
};
|
|
324
|
-
/** Tags */
|
|
325
|
-
tags: string[];
|
|
326
|
-
/** Assumptions */
|
|
327
|
-
assumptions: string[];
|
|
328
|
-
/** Dependencies */
|
|
329
|
-
dependencies: string[];
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Revision record for tracking thought evolution
|
|
334
|
-
*/
|
|
335
|
-
export interface RevisionRecord {
|
|
336
|
-
/** Previous content */
|
|
337
|
-
previousContent: string;
|
|
338
|
-
/** Revision timestamp */
|
|
339
|
-
revisedAt: Date;
|
|
340
|
-
/** Reason for revision */
|
|
341
|
-
revisionReason: string;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Represents a reasoning branch (parallel hypothesis path)
|
|
346
|
-
*/
|
|
347
|
-
export interface ThoughtBranch {
|
|
348
|
-
/** Branch identifier */
|
|
349
|
-
id: string;
|
|
350
|
-
/** Session ID */
|
|
351
|
-
sessionId: string;
|
|
352
|
-
/** Branch name */
|
|
353
|
-
name: string;
|
|
354
|
-
/** Branch description */
|
|
355
|
-
description: string;
|
|
356
|
-
/** Root thought ID */
|
|
357
|
-
rootThoughtId: string;
|
|
358
|
-
/** All thought IDs in branch */
|
|
359
|
-
thoughtIds: string[];
|
|
360
|
-
/** Parent branch ID */
|
|
361
|
-
parentBranchId: string | null;
|
|
362
|
-
/** Child branch IDs */
|
|
363
|
-
childBranchIds: string[];
|
|
364
|
-
/** Branch status */
|
|
365
|
-
status: BranchStatus;
|
|
366
|
-
/** Aggregate confidence */
|
|
367
|
-
confidence: number;
|
|
368
|
-
/** Metadata */
|
|
369
|
-
metadata: {
|
|
370
|
-
createdAt: Date;
|
|
371
|
-
completedAt?: Date;
|
|
372
|
-
prunedAt?: Date;
|
|
373
|
-
pruneReason?: string;
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Meta-note: a thought about a thought
|
|
379
|
-
*/
|
|
380
|
-
export interface MetaNote {
|
|
381
|
-
/** Unique identifier */
|
|
382
|
-
id: string;
|
|
383
|
-
/** Target thought ID */
|
|
384
|
-
thoughtId: string;
|
|
385
|
-
/** Observation content */
|
|
386
|
-
content: string;
|
|
387
|
-
/** Type of observation */
|
|
388
|
-
observationType: 'pattern' | 'concern' | 'insight' | 'suggestion';
|
|
389
|
-
/** Timestamp */
|
|
390
|
-
timestamp: Date;
|
|
391
|
-
/** Actions triggered by this observation */
|
|
392
|
-
triggeredActions: string[];
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// ============================================================================
|
|
396
|
-
// Session Interfaces
|
|
397
|
-
// ============================================================================
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Session context
|
|
401
|
-
*/
|
|
402
|
-
export interface SessionContext {
|
|
403
|
-
/** Original problem statement */
|
|
404
|
-
originalProblem: string;
|
|
405
|
-
/** Constraints */
|
|
406
|
-
constraints: string[];
|
|
407
|
-
/** Relevant information */
|
|
408
|
-
relevantInformation: string[];
|
|
409
|
-
/** Working memory */
|
|
410
|
-
workingMemory: Map<string, unknown>;
|
|
411
|
-
/** Long-term references */
|
|
412
|
-
longTermReferences: string[];
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Session settings
|
|
417
|
-
*/
|
|
418
|
-
export interface SessionSettings {
|
|
419
|
-
/** Maximum number of branches */
|
|
420
|
-
maxBranches: number;
|
|
421
|
-
/** Maximum depth */
|
|
422
|
-
maxDepth: number;
|
|
423
|
-
/** Confidence threshold */
|
|
424
|
-
confidenceThreshold: number;
|
|
425
|
-
/** Enable self-correction */
|
|
426
|
-
enableSelfCorrection: boolean;
|
|
427
|
-
/** Enable meta-reasoning */
|
|
428
|
-
enableMetaReasoning: boolean;
|
|
429
|
-
/** Enable parallel hypotheses */
|
|
430
|
-
enableParallelHypotheses: boolean;
|
|
431
|
-
/** Enable adaptive granularity */
|
|
432
|
-
adaptiveGranularity: boolean;
|
|
433
|
-
/** Granularity settings */
|
|
434
|
-
granularitySettings: {
|
|
435
|
-
minStepDetail: number;
|
|
436
|
-
maxStepDetail: number;
|
|
437
|
-
complexityThreshold: number;
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Top-level session containing all thoughts for a reasoning task
|
|
443
|
-
*/
|
|
444
|
-
export interface ThinkingSession {
|
|
445
|
-
/** Session identifier */
|
|
446
|
-
id: string;
|
|
447
|
-
/** Topic/problem statement */
|
|
448
|
-
topic: string;
|
|
449
|
-
/** Session status */
|
|
450
|
-
status: SessionStatus;
|
|
451
|
-
/** Current branch ID */
|
|
452
|
-
currentBranchId: string;
|
|
453
|
-
/** Branches map */
|
|
454
|
-
branches: Map<string, ThoughtBranch>;
|
|
455
|
-
/** Thoughts map */
|
|
456
|
-
thoughts: Map<string, Thought>;
|
|
457
|
-
/** Meta notes map */
|
|
458
|
-
metaNotes: Map<string, MetaNote>;
|
|
459
|
-
/** Session context */
|
|
460
|
-
context: SessionContext;
|
|
461
|
-
/** Session settings */
|
|
462
|
-
settings: SessionSettings;
|
|
463
|
-
/** Metadata */
|
|
464
|
-
metadata: {
|
|
465
|
-
createdAt: Date;
|
|
466
|
-
lastActivityAt: Date;
|
|
467
|
-
completedAt?: Date;
|
|
468
|
-
totalThoughts: number;
|
|
469
|
-
totalBranches: number;
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// ============================================================================
|
|
474
|
-
// Agent Interfaces
|
|
475
|
-
// ============================================================================
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Agent capability
|
|
479
|
-
*/
|
|
480
|
-
export interface AgentCapability {
|
|
481
|
-
/** Capability name */
|
|
482
|
-
name: string;
|
|
483
|
-
/** Description */
|
|
484
|
-
description: string;
|
|
485
|
-
/** Confidence level (0-1) */
|
|
486
|
-
confidence: number;
|
|
487
|
-
/** Performance metrics */
|
|
488
|
-
performanceMetrics: {
|
|
489
|
-
tasksCompleted: number;
|
|
490
|
-
averageQuality: number;
|
|
491
|
-
averageTimeMs: number;
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Agent configuration
|
|
497
|
-
*/
|
|
498
|
-
export interface AgentConfig {
|
|
499
|
-
/** Agent ID */
|
|
500
|
-
id: string;
|
|
501
|
-
/** Agent name */
|
|
502
|
-
name: string;
|
|
503
|
-
/** Agent type */
|
|
504
|
-
type: AgentType;
|
|
505
|
-
/** Subtype (e.g., critic type) */
|
|
506
|
-
subtype?: string;
|
|
507
|
-
/** Capabilities */
|
|
508
|
-
capabilities: AgentCapability[];
|
|
509
|
-
/** Maximum concurrent tasks */
|
|
510
|
-
maxConcurrentTasks: number;
|
|
511
|
-
/** Confidence threshold */
|
|
512
|
-
confidenceThreshold: number;
|
|
513
|
-
/** Metadata */
|
|
514
|
-
metadata: {
|
|
515
|
-
createdAt: Date;
|
|
516
|
-
version: string;
|
|
517
|
-
config: Record<string, unknown>;
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Agent information
|
|
523
|
-
*/
|
|
524
|
-
export interface AgentInfo {
|
|
525
|
-
/** Agent configuration */
|
|
526
|
-
config: AgentConfig;
|
|
527
|
-
/** Current status */
|
|
528
|
-
status: AgentStatus;
|
|
529
|
-
/** Current task IDs */
|
|
530
|
-
currentTasks: string[];
|
|
531
|
-
/** Performance history */
|
|
532
|
-
performanceHistory: {
|
|
533
|
-
taskId: string;
|
|
534
|
-
quality: number;
|
|
535
|
-
timeMs: number;
|
|
536
|
-
timestamp: Date;
|
|
537
|
-
}[];
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Agent type (alias for AgentInfo)
|
|
542
|
-
*/
|
|
543
|
-
export type Agent = AgentInfo;
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Agent performance metrics
|
|
547
|
-
*/
|
|
548
|
-
export interface AgentMetrics {
|
|
549
|
-
/** Agent ID */
|
|
550
|
-
agentId: string;
|
|
551
|
-
/** Tasks completed */
|
|
552
|
-
tasksCompleted: number;
|
|
553
|
-
/** Average latency in ms */
|
|
554
|
-
averageLatency: number;
|
|
555
|
-
/** Success rate (0-1) */
|
|
556
|
-
successRate: number;
|
|
557
|
-
/** Current load */
|
|
558
|
-
currentLoad: number;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// ============================================================================
|
|
562
|
-
// Task Interfaces
|
|
563
|
-
// ============================================================================
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Task requirements
|
|
567
|
-
*/
|
|
568
|
-
export interface TaskRequirements {
|
|
569
|
-
/** Required capabilities */
|
|
570
|
-
requiredCapabilities: string[];
|
|
571
|
-
/** Minimum confidence */
|
|
572
|
-
minConfidence: number;
|
|
573
|
-
/** Maximum time in ms */
|
|
574
|
-
maxTimeMs: number;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Task context
|
|
579
|
-
*/
|
|
580
|
-
export interface TaskContext {
|
|
581
|
-
/** Task dependencies */
|
|
582
|
-
dependencies: string[];
|
|
583
|
-
/** Priority level */
|
|
584
|
-
priority?: number;
|
|
585
|
-
/** Deadline */
|
|
586
|
-
deadline?: Date;
|
|
587
|
-
/** Associated session ID */
|
|
588
|
-
sessionId?: string;
|
|
589
|
-
/** Parent task ID */
|
|
590
|
-
parentTaskId?: string;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Task definition
|
|
595
|
-
*/
|
|
596
|
-
export interface Task {
|
|
597
|
-
/** Unique ID */
|
|
598
|
-
id: string;
|
|
599
|
-
/** Task type */
|
|
600
|
-
type: string;
|
|
601
|
-
/** Task description */
|
|
602
|
-
description: string;
|
|
603
|
-
/** Task input */
|
|
604
|
-
input: unknown;
|
|
605
|
-
/** Task context */
|
|
606
|
-
context: TaskContext;
|
|
607
|
-
/** Task requirements */
|
|
608
|
-
requirements: TaskRequirements;
|
|
609
|
-
/** Required capabilities for this task */
|
|
610
|
-
requiredCapabilities?: string[];
|
|
611
|
-
/** Assigned agent ID */
|
|
612
|
-
assignedAgentId: string | null;
|
|
613
|
-
/** Task status */
|
|
614
|
-
status: TaskStatus;
|
|
615
|
-
/** Task result */
|
|
616
|
-
result: TaskResult | null;
|
|
617
|
-
/** Metadata */
|
|
618
|
-
metadata: {
|
|
619
|
-
createdAt: Date;
|
|
620
|
-
assignedAt?: Date;
|
|
621
|
-
startedAt?: Date;
|
|
622
|
-
completedAt?: Date;
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Task result
|
|
628
|
-
*/
|
|
629
|
-
export interface TaskResult {
|
|
630
|
-
/** Task ID */
|
|
631
|
-
taskId: string;
|
|
632
|
-
/** Agent ID */
|
|
633
|
-
agentId: string;
|
|
634
|
-
/** Success flag */
|
|
635
|
-
success: boolean;
|
|
636
|
-
/** Output data */
|
|
637
|
-
output: unknown;
|
|
638
|
-
/** Confidence level */
|
|
639
|
-
confidence: number;
|
|
640
|
-
/** Processing time in ms */
|
|
641
|
-
processingTimeMs: number;
|
|
642
|
-
/** Metadata */
|
|
643
|
-
metadata: {
|
|
644
|
-
tokensUsed: number;
|
|
645
|
-
reasoningSteps: number;
|
|
646
|
-
intermediateResults: unknown[];
|
|
647
|
-
error?: string;
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Task error
|
|
653
|
-
*/
|
|
654
|
-
export interface TaskError {
|
|
655
|
-
/** Error code */
|
|
656
|
-
code: string;
|
|
657
|
-
/** Error message */
|
|
658
|
-
message: string;
|
|
659
|
-
/** Error details */
|
|
660
|
-
details?: Record<string, unknown>;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// ============================================================================
|
|
664
|
-
// Message Interfaces
|
|
665
|
-
// ============================================================================
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Swarm message
|
|
669
|
-
*/
|
|
670
|
-
export interface SwarmMessage {
|
|
671
|
-
/** Message ID */
|
|
672
|
-
id: string;
|
|
673
|
-
/** Message type */
|
|
674
|
-
type: MessageType;
|
|
675
|
-
/** Sender ID */
|
|
676
|
-
senderId: string;
|
|
677
|
-
/** Recipient ID (null for broadcast) */
|
|
678
|
-
recipientId: string | null;
|
|
679
|
-
/** Message payload */
|
|
680
|
-
payload: unknown;
|
|
681
|
-
/** Message context */
|
|
682
|
-
context: Record<string, unknown>;
|
|
683
|
-
/** Metadata */
|
|
684
|
-
metadata: {
|
|
685
|
-
priority: number;
|
|
686
|
-
ttl: number;
|
|
687
|
-
retryCount: number;
|
|
688
|
-
};
|
|
689
|
-
/** Timestamp */
|
|
690
|
-
timestamp: Date;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// ============================================================================
|
|
694
|
-
// Consensus Interfaces
|
|
695
|
-
// ============================================================================
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Consensus vote
|
|
699
|
-
*/
|
|
700
|
-
export interface ConsensusVote {
|
|
701
|
-
/** Agent ID */
|
|
702
|
-
agentId: string;
|
|
703
|
-
/** Proposal ID */
|
|
704
|
-
proposalId: string;
|
|
705
|
-
/** Voted option */
|
|
706
|
-
vote: unknown;
|
|
707
|
-
/** Confidence in vote */
|
|
708
|
-
confidence: number;
|
|
709
|
-
/** Reasoning */
|
|
710
|
-
reasoning: string;
|
|
711
|
-
/** Timestamp */
|
|
712
|
-
timestamp: Date;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Consensus result
|
|
717
|
-
*/
|
|
718
|
-
export interface ConsensusResult {
|
|
719
|
-
/** Proposal ID */
|
|
720
|
-
proposalId: string;
|
|
721
|
-
/** Algorithm used */
|
|
722
|
-
algorithm: ConsensusAlgorithm;
|
|
723
|
-
/** Winning option */
|
|
724
|
-
winningOption: unknown;
|
|
725
|
-
/** Confidence level */
|
|
726
|
-
confidence: number;
|
|
727
|
-
/** All votes */
|
|
728
|
-
votes: ConsensusVote[];
|
|
729
|
-
/** Agreement ratio */
|
|
730
|
-
agreementRatio: number;
|
|
731
|
-
/** Dissenting opinions */
|
|
732
|
-
dissentingOpinions: {
|
|
733
|
-
agentId: string;
|
|
734
|
-
opinion: unknown;
|
|
735
|
-
reasoning: string;
|
|
736
|
-
}[];
|
|
737
|
-
/** Metadata */
|
|
738
|
-
metadata: {
|
|
739
|
-
rounds: number;
|
|
740
|
-
totalVotingTimeMs: number;
|
|
741
|
-
convergenceRate: number;
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// ============================================================================
|
|
746
|
-
// Conflict Interfaces
|
|
747
|
-
// ============================================================================
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Conflict position
|
|
751
|
-
*/
|
|
752
|
-
export interface ConflictPosition {
|
|
753
|
-
/** Agent ID */
|
|
754
|
-
agentId: string;
|
|
755
|
-
/** Position */
|
|
756
|
-
position: unknown;
|
|
757
|
-
/** Confidence */
|
|
758
|
-
confidence: number;
|
|
759
|
-
/** Reasoning */
|
|
760
|
-
reasoning?: string;
|
|
761
|
-
/** Supporting evidence */
|
|
762
|
-
evidence?: string[];
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Assignment strategies for task allocation
|
|
767
|
-
*/
|
|
768
|
-
export type AssignmentStrategy =
|
|
769
|
-
| 'round_robin'
|
|
770
|
-
| 'capability_based'
|
|
771
|
-
| 'load_balanced'
|
|
772
|
-
| 'performance_based'
|
|
773
|
-
| 'adaptive'
|
|
774
|
-
| 'cost_based'
|
|
775
|
-
| 'fastest_first';
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Conflict definition
|
|
779
|
-
*/
|
|
780
|
-
export interface Conflict {
|
|
781
|
-
/** Conflict ID */
|
|
782
|
-
id: string;
|
|
783
|
-
/** Conflict type */
|
|
784
|
-
type: string;
|
|
785
|
-
/** Description */
|
|
786
|
-
description: string;
|
|
787
|
-
/** Involved agent IDs */
|
|
788
|
-
involvedAgents: string[];
|
|
789
|
-
/** Conflicting positions */
|
|
790
|
-
conflictingPositions: ConflictPosition[];
|
|
791
|
-
/** Conflict status */
|
|
792
|
-
status: ConflictStatus;
|
|
793
|
-
/** Resolution */
|
|
794
|
-
resolution: ConflictResolution | null;
|
|
795
|
-
/** Metadata */
|
|
796
|
-
metadata: {
|
|
797
|
-
createdAt: Date;
|
|
798
|
-
resolvedAt?: Date;
|
|
799
|
-
resolutionStrategy?: ConflictResolutionStrategy;
|
|
800
|
-
resolverAgentId?: string;
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Conflict resolution
|
|
806
|
-
*/
|
|
807
|
-
export interface ConflictResolution {
|
|
808
|
-
/** Resolution strategy */
|
|
809
|
-
strategy: ConflictResolutionStrategy;
|
|
810
|
-
/** Resolution result */
|
|
811
|
-
result: unknown;
|
|
812
|
-
/** Confidence in resolution */
|
|
813
|
-
confidence: number;
|
|
814
|
-
/** Reasoning */
|
|
815
|
-
reasoning?: string;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
// ============================================================================
|
|
819
|
-
// Error Classes
|
|
820
|
-
// ============================================================================
|
|
821
|
-
|
|
822
|
-
/**
|
|
823
|
-
* Base error class for sequential thinking errors
|
|
824
|
-
*/
|
|
825
|
-
export class SequentialThinkingError extends Error {
|
|
826
|
-
constructor(message: string) {
|
|
827
|
-
super(message);
|
|
828
|
-
this.name = 'SequentialThinkingError';
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Validation error
|
|
834
|
-
*/
|
|
835
|
-
export class ValidationError extends SequentialThinkingError {
|
|
836
|
-
constructor(message: string) {
|
|
837
|
-
super(message);
|
|
838
|
-
this.name = 'ValidationError';
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* Not found error
|
|
844
|
-
*/
|
|
845
|
-
export class NotFoundError extends SequentialThinkingError {
|
|
846
|
-
constructor(message: string) {
|
|
847
|
-
super(message);
|
|
848
|
-
this.name = 'NotFoundError';
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Timeout error
|
|
854
|
-
*/
|
|
855
|
-
export class TimeoutError extends SequentialThinkingError {
|
|
856
|
-
constructor(message: string) {
|
|
857
|
-
super(message);
|
|
858
|
-
this.name = 'TimeoutError';
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// ============================================================================
|
|
863
|
-
// Utility Types
|
|
864
|
-
// ============================================================================
|
|
865
|
-
|
|
866
|
-
/** UUID string type */
|
|
867
|
-
export type UUID = string;
|
|
868
|
-
|
|
869
|
-
/** Timestamp type */
|
|
870
|
-
export type Timestamp = number;
|
|
871
|
-
|
|
872
|
-
/** JSON value type */
|
|
873
|
-
export type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
|
|
874
|
-
|
|
875
|
-
/** JSON object type */
|
|
876
|
-
export interface JSONObject {
|
|
877
|
-
[key: string]: JSONValue;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
/** JSON array type */
|
|
881
|
-
export interface JSONArray extends Array<JSONValue> {}
|
|
882
|
-
|
|
883
|
-
/** Nullable type */
|
|
884
|
-
export type Nullable<T> = T | null;
|
|
885
|
-
|
|
886
|
-
/** Optional type */
|
|
887
|
-
export type Optional<T> = T | undefined;
|
|
888
|
-
|
|
889
|
-
/** Deep partial type */
|
|
890
|
-
export type DeepPartial<T> = {
|
|
891
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
892
|
-
};
|
|
893
|
-
|
|
894
|
-
/** Deep readonly type */
|
|
895
|
-
export type DeepReadonly<T> = {
|
|
896
|
-
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
/** Result type */
|
|
900
|
-
export type Result<T, E = Error> = { success: true; data: T } | { success: false; error: E };
|
|
901
|
-
|
|
902
|
-
/** Async result type */
|
|
903
|
-
export type AsyncResult<T, E = Error> = Promise<Result<T, E>>;
|
|
904
|
-
|
|
905
|
-
/** Event handler type */
|
|
906
|
-
export type EventHandler<T = unknown> = (event: T) => void | Promise<void>;
|
|
907
|
-
|
|
908
|
-
/** Predicate type */
|
|
909
|
-
export type Predicate<T> = (item: T) => boolean;
|
|
910
|
-
|
|
911
|
-
/** Comparator type */
|
|
912
|
-
export type Comparator<T> = (a: T, b: T) => number;
|
|
913
|
-
|
|
914
|
-
/** Factory type */
|
|
915
|
-
export type Factory<T, Args extends unknown[] = []> = (...args: Args) => T;
|