@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,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Agent Class
|
|
3
|
+
* @module agents/base-agent
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { AgentType, AgentStatus } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base class for all agents
|
|
9
|
+
*/
|
|
10
|
+
export class BaseAgent {
|
|
11
|
+
/** Agent ID */
|
|
12
|
+
id;
|
|
13
|
+
/** Agent configuration */
|
|
14
|
+
config;
|
|
15
|
+
/** Current status */
|
|
16
|
+
status = AgentStatus.IDLE;
|
|
17
|
+
/** Current task IDs */
|
|
18
|
+
currentTasks = new Set();
|
|
19
|
+
/** Performance history */
|
|
20
|
+
performanceHistory = [];
|
|
21
|
+
/** Message handlers */
|
|
22
|
+
messageHandlers = [];
|
|
23
|
+
/**
|
|
24
|
+
* Create a new base agent
|
|
25
|
+
* @param config - Agent configuration
|
|
26
|
+
*/
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.id = config.id || `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
29
|
+
this.config = {
|
|
30
|
+
id: this.id,
|
|
31
|
+
name: config.name,
|
|
32
|
+
type: config.type || AgentType.UTILITY,
|
|
33
|
+
subtype: config.subtype,
|
|
34
|
+
capabilities: config.capabilities || [],
|
|
35
|
+
maxConcurrentTasks: config.maxConcurrentTasks || 3,
|
|
36
|
+
confidenceThreshold: config.confidenceThreshold || 0.7,
|
|
37
|
+
metadata: {
|
|
38
|
+
createdAt: new Date(),
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
config: config.metadata?.config || {}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Execute a task
|
|
46
|
+
* @param task - Task to execute
|
|
47
|
+
* @returns Task result
|
|
48
|
+
*/
|
|
49
|
+
async execute(task) {
|
|
50
|
+
const startTime = Date.now();
|
|
51
|
+
this.status = AgentStatus.BUSY;
|
|
52
|
+
this.currentTasks.add(task.id);
|
|
53
|
+
try {
|
|
54
|
+
const result = await this.process(task);
|
|
55
|
+
const processingTime = Date.now() - startTime;
|
|
56
|
+
this.performanceHistory.push({
|
|
57
|
+
taskId: task.id,
|
|
58
|
+
quality: result.confidence,
|
|
59
|
+
timeMs: processingTime,
|
|
60
|
+
timestamp: new Date()
|
|
61
|
+
});
|
|
62
|
+
this.currentTasks.delete(task.id);
|
|
63
|
+
this.status = this.currentTasks.size === 0 ? AgentStatus.IDLE : AgentStatus.BUSY;
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
this.currentTasks.delete(task.id);
|
|
68
|
+
this.status = this.currentTasks.size === 0 ? AgentStatus.IDLE : AgentStatus.BUSY;
|
|
69
|
+
return {
|
|
70
|
+
taskId: task.id,
|
|
71
|
+
agentId: this.id,
|
|
72
|
+
success: false,
|
|
73
|
+
output: null,
|
|
74
|
+
confidence: 0,
|
|
75
|
+
processingTimeMs: Date.now() - startTime,
|
|
76
|
+
metadata: {
|
|
77
|
+
tokensUsed: 0,
|
|
78
|
+
reasoningSteps: 0,
|
|
79
|
+
intermediateResults: [],
|
|
80
|
+
error: error instanceof Error ? error.message : String(error)
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Register a message handler
|
|
87
|
+
* @param handler - Message handler function
|
|
88
|
+
* @returns Unsubscribe function
|
|
89
|
+
*/
|
|
90
|
+
onMessage(handler) {
|
|
91
|
+
this.messageHandlers.push(handler);
|
|
92
|
+
return () => {
|
|
93
|
+
const index = this.messageHandlers.indexOf(handler);
|
|
94
|
+
if (index > -1) {
|
|
95
|
+
this.messageHandlers.splice(index, 1);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Receive a message
|
|
101
|
+
* @param message - Message to receive
|
|
102
|
+
*/
|
|
103
|
+
receiveMessage(message) {
|
|
104
|
+
for (const handler of this.messageHandlers) {
|
|
105
|
+
try {
|
|
106
|
+
const result = handler(message);
|
|
107
|
+
if (result instanceof Promise) {
|
|
108
|
+
result.catch(error => {
|
|
109
|
+
console.error(`Error in message handler for agent ${this.id}:`, error);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.error(`Error in message handler for agent ${this.id}:`, error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get agent status
|
|
120
|
+
* @returns Current status
|
|
121
|
+
*/
|
|
122
|
+
getStatus() {
|
|
123
|
+
return this.status;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Set agent status
|
|
127
|
+
* @param status - New status
|
|
128
|
+
*/
|
|
129
|
+
setStatus(status) {
|
|
130
|
+
this.status = status;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get current task IDs
|
|
134
|
+
* @returns Array of task IDs
|
|
135
|
+
*/
|
|
136
|
+
getCurrentTasks() {
|
|
137
|
+
return Array.from(this.currentTasks);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get performance metrics
|
|
141
|
+
* @returns Performance metrics
|
|
142
|
+
*/
|
|
143
|
+
getPerformanceMetrics() {
|
|
144
|
+
if (this.performanceHistory.length === 0) {
|
|
145
|
+
return {
|
|
146
|
+
tasksCompleted: 0,
|
|
147
|
+
averageQuality: 0,
|
|
148
|
+
averageTimeMs: 0,
|
|
149
|
+
successRate: 0
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const completed = this.performanceHistory.length;
|
|
153
|
+
const avgQuality = this.performanceHistory.reduce((sum, p) => sum + p.quality, 0) / completed;
|
|
154
|
+
const avgTime = this.performanceHistory.reduce((sum, p) => sum + p.timeMs, 0) / completed;
|
|
155
|
+
const successRate = this.performanceHistory.filter(p => p.quality > 0.5).length / completed;
|
|
156
|
+
return {
|
|
157
|
+
tasksCompleted: completed,
|
|
158
|
+
averageQuality: avgQuality,
|
|
159
|
+
averageTimeMs: avgTime,
|
|
160
|
+
successRate
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Check if agent has a capability
|
|
165
|
+
* @param capabilityName - Capability name
|
|
166
|
+
* @returns True if agent has capability
|
|
167
|
+
*/
|
|
168
|
+
hasCapability(capabilityName) {
|
|
169
|
+
return this.getCapabilities().some(c => c.name === capabilityName);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get capability confidence
|
|
173
|
+
* @param capabilityName - Capability name
|
|
174
|
+
* @returns Confidence level (0-1)
|
|
175
|
+
*/
|
|
176
|
+
getCapabilityConfidence(capabilityName) {
|
|
177
|
+
const cap = this.getCapabilities().find(c => c.name === capabilityName);
|
|
178
|
+
return cap?.confidence || 0;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Check if agent can handle a task
|
|
182
|
+
* @param task - Task to check
|
|
183
|
+
* @returns True if agent can handle task
|
|
184
|
+
*/
|
|
185
|
+
canHandleTask(task) {
|
|
186
|
+
const requiredCaps = task.requirements.requiredCapabilities;
|
|
187
|
+
return requiredCaps.every(cap => this.hasCapability(cap));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create a task result
|
|
191
|
+
* @param taskId - Task ID
|
|
192
|
+
* @param output - Output data
|
|
193
|
+
* @param confidence - Confidence level
|
|
194
|
+
* @param processingTimeMs - Processing time in ms
|
|
195
|
+
* @param metadata - Additional metadata
|
|
196
|
+
* @returns Task result
|
|
197
|
+
*/
|
|
198
|
+
createTaskResult(taskId, output, confidence, processingTimeMs, metadata = {}) {
|
|
199
|
+
return {
|
|
200
|
+
taskId,
|
|
201
|
+
agentId: this.id,
|
|
202
|
+
success: confidence > 0.5,
|
|
203
|
+
output,
|
|
204
|
+
confidence,
|
|
205
|
+
processingTimeMs,
|
|
206
|
+
metadata: {
|
|
207
|
+
tokensUsed: metadata.tokensUsed || 0,
|
|
208
|
+
reasoningSteps: metadata.reasoningSteps || 1,
|
|
209
|
+
intermediateResults: metadata.intermediateResults || []
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=base-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.js","sourceRoot":"","sources":["../../src/agents/base-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EAMZ,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,OAAgB,SAAS;IAC7B,eAAe;IACN,EAAE,CAAS;IAEpB,0BAA0B;IAC1B,MAAM,CAAc;IAEpB,qBAAqB;IACX,MAAM,GAAgB,WAAW,CAAC,IAAI,CAAC;I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G,EAAE,UAAU,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,IAAU;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC;QAC5D,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;OAQG;IACO,gBAAgB,CACxB,MAAc,EACd,MAAe,EACf,UAAkB,EAClB,gBAAwB,EACxB,WAII,EAAE;QAEN,OAAO;YACL,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,OAAO,EAAE,UAAU,GAAG,GAAG;YACzB,MAAM;YACN,UAAU;YACV,gBAAgB;YAChB,QAAQ,EAAE;gBACR,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,CAAC;gBACpC,cAAc,EAAE,QAAQ,CAAC,cAAc,IAAI,CAAC;gBAC5C,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,IAAI,EAAE;aACxD;SACF,CAAC;IACJ,CAAC;CAaF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Critic Agent Implementation
|
|
3
|
+
* @module agents/critic-agent
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseAgent } from './base-agent.js';
|
|
7
|
+
import { CriticType, type Task, type TaskResult, type AgentCapability } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Critic agent that evaluates outputs from other agents
|
|
10
|
+
*/
|
|
11
|
+
export declare class CriticAgent extends BaseAgent {
|
|
12
|
+
/** Critic type */
|
|
13
|
+
private criticType;
|
|
14
|
+
/** Severity threshold */
|
|
15
|
+
private severityThreshold;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new critic agent
|
|
18
|
+
* @param config - Agent configuration
|
|
19
|
+
*/
|
|
20
|
+
constructor(config: {
|
|
21
|
+
name: string;
|
|
22
|
+
criticType?: CriticType;
|
|
23
|
+
severityThreshold?: number;
|
|
24
|
+
capabilities?: AgentCapability[];
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Get agent type
|
|
28
|
+
* @returns Agent type
|
|
29
|
+
*/
|
|
30
|
+
getType(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get agent capabilities
|
|
33
|
+
* @returns Array of capabilities
|
|
34
|
+
*/
|
|
35
|
+
getCapabilities(): AgentCapability[];
|
|
36
|
+
/**
|
|
37
|
+
* Process a task - evaluate the target
|
|
38
|
+
* @param task - Task to process
|
|
39
|
+
* @returns Task result
|
|
40
|
+
*/
|
|
41
|
+
process(task: Task): Promise<TaskResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Check logical consistency
|
|
44
|
+
* @param target - Target to evaluate
|
|
45
|
+
* @returns Evaluation result
|
|
46
|
+
*/
|
|
47
|
+
private checkLogicalConsistency;
|
|
48
|
+
/**
|
|
49
|
+
* Check factual accuracy
|
|
50
|
+
* @param target - Target to evaluate
|
|
51
|
+
* @returns Evaluation result
|
|
52
|
+
*/
|
|
53
|
+
private checkFactualAccuracy;
|
|
54
|
+
/**
|
|
55
|
+
* Check for bias
|
|
56
|
+
* @param target - Target to evaluate
|
|
57
|
+
* @returns Evaluation result
|
|
58
|
+
*/
|
|
59
|
+
private checkForBias;
|
|
60
|
+
/**
|
|
61
|
+
* Check safety
|
|
62
|
+
* @param target - Target to evaluate
|
|
63
|
+
* @returns Evaluation result
|
|
64
|
+
*/
|
|
65
|
+
private checkSafety;
|
|
66
|
+
/**
|
|
67
|
+
* General evaluation
|
|
68
|
+
* @param target - Target to evaluate
|
|
69
|
+
* @returns Evaluation result
|
|
70
|
+
*/
|
|
71
|
+
private generalEvaluation;
|
|
72
|
+
/**
|
|
73
|
+
* Extract content from target
|
|
74
|
+
* @param target - Target to extract content from
|
|
75
|
+
* @returns Extracted content string
|
|
76
|
+
*/
|
|
77
|
+
private extractContent;
|
|
78
|
+
/**
|
|
79
|
+
* Detect logical fallacies
|
|
80
|
+
* @param content - Content to analyze
|
|
81
|
+
* @returns Array of issues
|
|
82
|
+
*/
|
|
83
|
+
private detectLogicalFallacies;
|
|
84
|
+
/**
|
|
85
|
+
* Detect contradictions
|
|
86
|
+
* @param content - Content to analyze
|
|
87
|
+
* @returns Array of issues
|
|
88
|
+
*/
|
|
89
|
+
private detectContradictions;
|
|
90
|
+
/**
|
|
91
|
+
* Detect unsupported claims
|
|
92
|
+
* @param content - Content to analyze
|
|
93
|
+
* @returns Array of issues
|
|
94
|
+
*/
|
|
95
|
+
private detectUnsupportedClaims;
|
|
96
|
+
/**
|
|
97
|
+
* Extract factual claims
|
|
98
|
+
* @param content - Content to analyze
|
|
99
|
+
* @returns Array of claims
|
|
100
|
+
*/
|
|
101
|
+
private extractFactualClaims;
|
|
102
|
+
/**
|
|
103
|
+
* Assess claim accuracy
|
|
104
|
+
* @param claim - Claim to assess
|
|
105
|
+
* @returns Accuracy score (0-1)
|
|
106
|
+
*/
|
|
107
|
+
private assessClaimAccuracy;
|
|
108
|
+
/**
|
|
109
|
+
* Check for source citations
|
|
110
|
+
* @param content - Content to check
|
|
111
|
+
* @returns True if has citations
|
|
112
|
+
*/
|
|
113
|
+
private hasSourceCitations;
|
|
114
|
+
/**
|
|
115
|
+
* Count perspectives
|
|
116
|
+
* @param content - Content to analyze
|
|
117
|
+
* @returns Number of perspectives
|
|
118
|
+
*/
|
|
119
|
+
private countPerspectives;
|
|
120
|
+
/**
|
|
121
|
+
* Detect confirmation bias
|
|
122
|
+
* @param content - Content to analyze
|
|
123
|
+
* @returns Array of issues
|
|
124
|
+
*/
|
|
125
|
+
private detectConfirmationBias;
|
|
126
|
+
/**
|
|
127
|
+
* Generate logical assessment
|
|
128
|
+
* @param score - Score
|
|
129
|
+
* @param issueCount - Number of issues
|
|
130
|
+
* @returns Assessment string
|
|
131
|
+
*/
|
|
132
|
+
private generateLogicalAssessment;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=critic-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"critic-agent.d.ts","sourceRoot":"","sources":["../../src/agents/critic-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,UAAU,EACV,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAwB3B;;GAEG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,kBAAkB;IAClB,OAAO,CAAC,UAAU,CAAa;IAE/B,yBAAyB;IACzB,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;gBACS,MAAM,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC;IAyCD;;;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;IAoC9C;;;;OAIG;YACW,uBAAuB;IAiBrC;;;;OAIG;YACW,oBAAoB;IAiBlC;;;;OAIG;YACW,YAAY;IAuE1B;;;;OAIG;YACW,WAAW;IAmBzB;;;;OAIG;YACW,iBAAiB;IAgB/B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAwBtB;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAyC9B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAmB/B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;;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