@claude-flow/plugin-cognitive-kernel 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -0
- package/dist/bridges/cognitive-bridge.d.ts +137 -0
- package/dist/bridges/cognitive-bridge.d.ts.map +1 -0
- package/dist/bridges/cognitive-bridge.js +355 -0
- package/dist/bridges/cognitive-bridge.js.map +1 -0
- package/dist/bridges/index.d.ts +8 -0
- package/dist/bridges/index.d.ts.map +1 -0
- package/dist/bridges/index.js +8 -0
- package/dist/bridges/index.js.map +1 -0
- package/dist/bridges/sona-bridge.d.ts +162 -0
- package/dist/bridges/sona-bridge.d.ts.map +1 -0
- package/dist/bridges/sona-bridge.js +358 -0
- package/dist/bridges/sona-bridge.js.map +1 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-tools.d.ts +22 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +945 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/types.d.ts +561 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +230 -0
- package/dist/types.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SONA Bridge
|
|
3
|
+
*
|
|
4
|
+
* Bridge to SONA (Self-Optimizing Neural Architecture) for continuous
|
|
5
|
+
* learning with LoRA fine-tuning and EWC++ memory preservation.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_CONFIG = {
|
|
11
|
+
mode: 'balanced',
|
|
12
|
+
loraRank: 4,
|
|
13
|
+
learningRate: 0.001,
|
|
14
|
+
ewcLambda: 100,
|
|
15
|
+
batchSize: 32,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* SONA Bridge implementation
|
|
19
|
+
*/
|
|
20
|
+
export class SonaBridge {
|
|
21
|
+
name = 'sona';
|
|
22
|
+
version = '0.1.0';
|
|
23
|
+
_status = 'unloaded';
|
|
24
|
+
_module = null;
|
|
25
|
+
config;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
28
|
+
}
|
|
29
|
+
get status() {
|
|
30
|
+
return this._status;
|
|
31
|
+
}
|
|
32
|
+
get initialized() {
|
|
33
|
+
return this._status === 'ready';
|
|
34
|
+
}
|
|
35
|
+
async init() {
|
|
36
|
+
if (this._status === 'ready')
|
|
37
|
+
return;
|
|
38
|
+
if (this._status === 'loading')
|
|
39
|
+
return;
|
|
40
|
+
this._status = 'loading';
|
|
41
|
+
try {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
const wasmModule = await import('@ruvector/sona').catch(() => null);
|
|
44
|
+
if (wasmModule) {
|
|
45
|
+
this._module = wasmModule;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this._module = this.createMockModule();
|
|
49
|
+
}
|
|
50
|
+
this._module.setMode(this.config.mode);
|
|
51
|
+
this._status = 'ready';
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this._status = 'error';
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async destroy() {
|
|
59
|
+
this._module = null;
|
|
60
|
+
this._status = 'unloaded';
|
|
61
|
+
}
|
|
62
|
+
isReady() {
|
|
63
|
+
return this._status === 'ready';
|
|
64
|
+
}
|
|
65
|
+
getModule() {
|
|
66
|
+
return this._module;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Learn from trajectories
|
|
70
|
+
* Returns improvement score (0-1)
|
|
71
|
+
*/
|
|
72
|
+
learn(trajectories, config) {
|
|
73
|
+
if (!this._module)
|
|
74
|
+
throw new Error('SONA module not initialized');
|
|
75
|
+
const mergedConfig = { ...this.config, ...config };
|
|
76
|
+
return this._module.learn(trajectories, mergedConfig);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Predict next action
|
|
80
|
+
*/
|
|
81
|
+
predict(state) {
|
|
82
|
+
if (!this._module)
|
|
83
|
+
throw new Error('SONA module not initialized');
|
|
84
|
+
return this._module.predict(state);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Store a pattern
|
|
88
|
+
*/
|
|
89
|
+
storePattern(pattern) {
|
|
90
|
+
if (!this._module)
|
|
91
|
+
throw new Error('SONA module not initialized');
|
|
92
|
+
this._module.storePattern(pattern);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Find similar patterns
|
|
96
|
+
*/
|
|
97
|
+
findPatterns(query, k) {
|
|
98
|
+
if (!this._module)
|
|
99
|
+
throw new Error('SONA module not initialized');
|
|
100
|
+
return this._module.findPatterns(query, k);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Update pattern success rate
|
|
104
|
+
*/
|
|
105
|
+
updatePatternSuccess(patternId, success) {
|
|
106
|
+
if (!this._module)
|
|
107
|
+
throw new Error('SONA module not initialized');
|
|
108
|
+
this._module.updatePatternSuccess(patternId, success);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Apply LoRA transformation
|
|
112
|
+
*/
|
|
113
|
+
applyLoRA(input, weights) {
|
|
114
|
+
if (!this._module)
|
|
115
|
+
throw new Error('SONA module not initialized');
|
|
116
|
+
return this._module.applyLoRA(input, weights);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Update LoRA weights from gradients
|
|
120
|
+
*/
|
|
121
|
+
updateLoRA(gradients, config) {
|
|
122
|
+
if (!this._module)
|
|
123
|
+
throw new Error('SONA module not initialized');
|
|
124
|
+
const mergedConfig = { ...this.config, ...config };
|
|
125
|
+
return this._module.updateLoRA(gradients, mergedConfig);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Compute Fisher information matrix
|
|
129
|
+
*/
|
|
130
|
+
computeFisher(trajectories) {
|
|
131
|
+
if (!this._module)
|
|
132
|
+
throw new Error('SONA module not initialized');
|
|
133
|
+
return this._module.computeFisher(trajectories);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Consolidate memory with EWC++
|
|
137
|
+
*/
|
|
138
|
+
consolidate(ewcState) {
|
|
139
|
+
if (!this._module)
|
|
140
|
+
throw new Error('SONA module not initialized');
|
|
141
|
+
this._module.consolidate(ewcState);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Set operating mode
|
|
145
|
+
*/
|
|
146
|
+
setMode(mode) {
|
|
147
|
+
if (!this._module)
|
|
148
|
+
throw new Error('SONA module not initialized');
|
|
149
|
+
this._module.setMode(mode);
|
|
150
|
+
this.config.mode = mode;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get current mode
|
|
154
|
+
*/
|
|
155
|
+
getMode() {
|
|
156
|
+
return this._module?.getMode() ?? this.config.mode;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Create mock module for development
|
|
160
|
+
*/
|
|
161
|
+
createMockModule() {
|
|
162
|
+
const patterns = new Map();
|
|
163
|
+
let currentMode = 'balanced';
|
|
164
|
+
let loraWeights = {
|
|
165
|
+
A: new Map(),
|
|
166
|
+
B: new Map(),
|
|
167
|
+
rank: 4,
|
|
168
|
+
alpha: 0.1,
|
|
169
|
+
};
|
|
170
|
+
const self = this;
|
|
171
|
+
return {
|
|
172
|
+
learn(trajectories, config) {
|
|
173
|
+
if (trajectories.length === 0)
|
|
174
|
+
return 0;
|
|
175
|
+
const goodTrajectories = trajectories.filter(t => t.qualityScore >= 0.5);
|
|
176
|
+
if (goodTrajectories.length === 0)
|
|
177
|
+
return 0;
|
|
178
|
+
// Extract patterns from good trajectories
|
|
179
|
+
for (const trajectory of goodTrajectories) {
|
|
180
|
+
if (trajectory.steps.length > 0) {
|
|
181
|
+
const lastStep = trajectory.steps[trajectory.steps.length - 1];
|
|
182
|
+
if (lastStep) {
|
|
183
|
+
const patternId = `pattern_${patterns.size}_${Date.now()}`;
|
|
184
|
+
patterns.set(patternId, {
|
|
185
|
+
id: patternId,
|
|
186
|
+
embedding: new Float32Array(lastStep.stateAfter),
|
|
187
|
+
successRate: trajectory.qualityScore,
|
|
188
|
+
usageCount: 1,
|
|
189
|
+
domain: trajectory.domain,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const avgQuality = goodTrajectories.reduce((s, t) => s + t.qualityScore, 0) / goodTrajectories.length;
|
|
195
|
+
return Math.max(0, avgQuality - 0.5);
|
|
196
|
+
},
|
|
197
|
+
predict(state) {
|
|
198
|
+
// Find most similar pattern
|
|
199
|
+
let bestPattern = null;
|
|
200
|
+
let bestSim = -1;
|
|
201
|
+
const alternatives = [];
|
|
202
|
+
for (const pattern of patterns.values()) {
|
|
203
|
+
const sim = cosineSimilarity(state, pattern.embedding);
|
|
204
|
+
if (sim > bestSim) {
|
|
205
|
+
if (bestPattern) {
|
|
206
|
+
alternatives.push({
|
|
207
|
+
action: bestPattern.domain,
|
|
208
|
+
confidence: bestSim * bestPattern.successRate,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
bestSim = sim;
|
|
212
|
+
bestPattern = pattern;
|
|
213
|
+
}
|
|
214
|
+
else if (sim > 0.3) {
|
|
215
|
+
alternatives.push({
|
|
216
|
+
action: pattern.domain,
|
|
217
|
+
confidence: sim * pattern.successRate,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Sort alternatives by confidence
|
|
222
|
+
alternatives.sort((a, b) => b.confidence - a.confidence);
|
|
223
|
+
if (bestPattern && bestSim > 0.5) {
|
|
224
|
+
return {
|
|
225
|
+
action: bestPattern.domain,
|
|
226
|
+
confidence: bestSim * bestPattern.successRate,
|
|
227
|
+
alternativeActions: alternatives.slice(0, 3),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
action: 'explore',
|
|
232
|
+
confidence: 0.3,
|
|
233
|
+
alternativeActions: alternatives.slice(0, 3),
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
storePattern(pattern) {
|
|
237
|
+
patterns.set(pattern.id, pattern);
|
|
238
|
+
},
|
|
239
|
+
findPatterns(query, k) {
|
|
240
|
+
const results = [];
|
|
241
|
+
for (const pattern of patterns.values()) {
|
|
242
|
+
const sim = cosineSimilarity(query, pattern.embedding);
|
|
243
|
+
results.push({ pattern, sim });
|
|
244
|
+
}
|
|
245
|
+
results.sort((a, b) => b.sim - a.sim);
|
|
246
|
+
return results.slice(0, k).map(r => r.pattern);
|
|
247
|
+
},
|
|
248
|
+
updatePatternSuccess(patternId, success) {
|
|
249
|
+
const pattern = patterns.get(patternId);
|
|
250
|
+
if (pattern) {
|
|
251
|
+
pattern.usageCount++;
|
|
252
|
+
const alpha = 1 / pattern.usageCount;
|
|
253
|
+
pattern.successRate = pattern.successRate * (1 - alpha) + (success ? 1 : 0) * alpha;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
applyLoRA(input, weights) {
|
|
257
|
+
const output = new Float32Array(input.length);
|
|
258
|
+
output.set(input);
|
|
259
|
+
// Apply LoRA: output = input + alpha * B @ A @ input
|
|
260
|
+
for (const [module, A] of weights.A) {
|
|
261
|
+
const B = weights.B.get(module);
|
|
262
|
+
if (!B)
|
|
263
|
+
continue;
|
|
264
|
+
// Simplified LoRA application
|
|
265
|
+
let intermediate = 0;
|
|
266
|
+
for (let i = 0; i < Math.min(input.length, A.length); i++) {
|
|
267
|
+
intermediate += (A[i] ?? 0) * (input[i] ?? 0);
|
|
268
|
+
}
|
|
269
|
+
for (let i = 0; i < Math.min(output.length, B.length); i++) {
|
|
270
|
+
output[i] = (output[i] ?? 0) + weights.alpha * (B[i] ?? 0) * intermediate;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return output;
|
|
274
|
+
},
|
|
275
|
+
updateLoRA(gradients, config) {
|
|
276
|
+
const dim = gradients.length;
|
|
277
|
+
const rank = config.loraRank;
|
|
278
|
+
const A = new Float32Array(rank * dim);
|
|
279
|
+
const B = new Float32Array(dim * rank);
|
|
280
|
+
// Initialize with small random values scaled by gradients
|
|
281
|
+
for (let i = 0; i < A.length; i++) {
|
|
282
|
+
A[i] = (Math.random() - 0.5) * 0.01 * ((gradients[i % dim] ?? 0) || 1);
|
|
283
|
+
}
|
|
284
|
+
for (let i = 0; i < B.length; i++) {
|
|
285
|
+
B[i] = (Math.random() - 0.5) * 0.01 * ((gradients[i % dim] ?? 0) || 1);
|
|
286
|
+
}
|
|
287
|
+
loraWeights.A.set('default', A);
|
|
288
|
+
loraWeights.B.set('default', B);
|
|
289
|
+
loraWeights.rank = rank;
|
|
290
|
+
return loraWeights;
|
|
291
|
+
},
|
|
292
|
+
computeFisher(trajectories) {
|
|
293
|
+
const fisher = new Map();
|
|
294
|
+
for (const trajectory of trajectories) {
|
|
295
|
+
for (const step of trajectory.steps) {
|
|
296
|
+
const key = trajectory.domain;
|
|
297
|
+
let f = fisher.get(key);
|
|
298
|
+
if (!f) {
|
|
299
|
+
f = new Float32Array(step.stateAfter.length);
|
|
300
|
+
fisher.set(key, f);
|
|
301
|
+
}
|
|
302
|
+
// Approximate Fisher information
|
|
303
|
+
for (let i = 0; i < step.stateAfter.length; i++) {
|
|
304
|
+
const grad = (step.stateAfter[i] ?? 0) * step.reward;
|
|
305
|
+
f[i] = (f[i] ?? 0) + grad * grad;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Normalize
|
|
310
|
+
for (const f of fisher.values()) {
|
|
311
|
+
const sum = f.reduce((s, v) => s + v, 0);
|
|
312
|
+
if (sum > 0) {
|
|
313
|
+
for (let i = 0; i < f.length; i++) {
|
|
314
|
+
f[i] = (f[i] ?? 0) / sum;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return fisher;
|
|
319
|
+
},
|
|
320
|
+
consolidate(ewcState) {
|
|
321
|
+
// Apply EWC penalty to prevent catastrophic forgetting
|
|
322
|
+
// Store current state as reference for future updates
|
|
323
|
+
// This is a placeholder - actual implementation would modify learning gradients
|
|
324
|
+
},
|
|
325
|
+
setMode(mode) {
|
|
326
|
+
currentMode = mode;
|
|
327
|
+
},
|
|
328
|
+
getMode() {
|
|
329
|
+
return currentMode;
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Cosine similarity helper
|
|
336
|
+
*/
|
|
337
|
+
function cosineSimilarity(a, b) {
|
|
338
|
+
if (a.length !== b.length)
|
|
339
|
+
return 0;
|
|
340
|
+
let dot = 0;
|
|
341
|
+
let normA = 0;
|
|
342
|
+
let normB = 0;
|
|
343
|
+
for (let i = 0; i < a.length; i++) {
|
|
344
|
+
dot += (a[i] ?? 0) * (b[i] ?? 0);
|
|
345
|
+
normA += (a[i] ?? 0) * (a[i] ?? 0);
|
|
346
|
+
normB += (b[i] ?? 0) * (b[i] ?? 0);
|
|
347
|
+
}
|
|
348
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
349
|
+
return denom > 0 ? dot / denom : 0;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Create a new SONA bridge
|
|
353
|
+
*/
|
|
354
|
+
export function createSonaBridge(config) {
|
|
355
|
+
return new SonaBridge(config);
|
|
356
|
+
}
|
|
357
|
+
export default SonaBridge;
|
|
358
|
+
//# sourceMappingURL=sona-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sona-bridge.js","sourceRoot":"","sources":["../../src/bridges/sona-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;GAEG;AACH,MAAM,cAAc,GAAe;IACjC,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,C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AAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA4B;IAC3D,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,eAAe,UAAU,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Kernel Plugin
|
|
3
|
+
*
|
|
4
|
+
* Cognitive augmentation for LLM reasoning with working memory,
|
|
5
|
+
* attention control, meta-cognition, scaffolding, and cognitive load management.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Working memory slot management (Miller's 7 +/- 2)
|
|
9
|
+
* - Attention control (focus, diffuse, selective, divided, sustained)
|
|
10
|
+
* - Meta-cognitive monitoring and reflection
|
|
11
|
+
* - Cognitive scaffolding (decomposition, analogy, Socratic, etc.)
|
|
12
|
+
* - Cognitive load theory optimization
|
|
13
|
+
* - SONA integration for continuous learning
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
export * from './types.js';
|
|
18
|
+
export { workingMemoryTool, attentionControlTool, metaMonitorTool, scaffoldTool, cognitiveLoadTool, cognitiveKernelTools, toolHandlers, getTool, getToolNames, } from './mcp-tools.js';
|
|
19
|
+
export { CognitiveBridge, createCognitiveBridge, SonaBridge, createSonaBridge, } from './bridges/index.js';
|
|
20
|
+
export type { CognitiveConfig, AttentionState, } from './bridges/cognitive-bridge.js';
|
|
21
|
+
export type { SonaConfig, SonaTrajectory, SonaStep, LoRAWeights, EWCState, SonaPrediction, } from './bridges/sona-bridge.js';
|
|
22
|
+
import type { MCPTool } from './types.js';
|
|
23
|
+
import { CognitiveBridge } from './bridges/cognitive-bridge.js';
|
|
24
|
+
import { SonaBridge } from './bridges/sona-bridge.js';
|
|
25
|
+
/**
|
|
26
|
+
* Cognitive Kernel Plugin metadata
|
|
27
|
+
*/
|
|
28
|
+
export declare const PLUGIN_METADATA: {
|
|
29
|
+
readonly name: "@claude-flow/plugin-cognitive-kernel";
|
|
30
|
+
readonly version: "3.0.0-alpha.1";
|
|
31
|
+
readonly description: "Cognitive kernel plugin for LLM augmentation";
|
|
32
|
+
readonly author: "Claude Flow Team";
|
|
33
|
+
readonly keywords: readonly ["cognitive-kernel", "working-memory", "attention", "meta-cognition", "scaffolding", "sona", "cognitum"];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Plugin state
|
|
37
|
+
*/
|
|
38
|
+
export interface CognitiveKernelPluginState {
|
|
39
|
+
initialized: boolean;
|
|
40
|
+
cognitiveBridge: CognitiveBridge | null;
|
|
41
|
+
sonaBridge: SonaBridge | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initialize the cognitive kernel plugin
|
|
45
|
+
*/
|
|
46
|
+
export declare function initializePlugin(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Shutdown the cognitive kernel plugin
|
|
49
|
+
*/
|
|
50
|
+
export declare function shutdownPlugin(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Get plugin state
|
|
53
|
+
*/
|
|
54
|
+
export declare function getPluginState(): CognitiveKernelPluginState;
|
|
55
|
+
/**
|
|
56
|
+
* Get all MCP tools provided by this plugin
|
|
57
|
+
*/
|
|
58
|
+
export declare function getMCPTools(): MCPTool[];
|
|
59
|
+
/**
|
|
60
|
+
* Plugin interface for registration with Claude Flow
|
|
61
|
+
*/
|
|
62
|
+
export declare const cognitiveKernelPlugin: {
|
|
63
|
+
metadata: {
|
|
64
|
+
readonly name: "@claude-flow/plugin-cognitive-kernel";
|
|
65
|
+
readonly version: "3.0.0-alpha.1";
|
|
66
|
+
readonly description: "Cognitive kernel plugin for LLM augmentation";
|
|
67
|
+
readonly author: "Claude Flow Team";
|
|
68
|
+
readonly keywords: readonly ["cognitive-kernel", "working-memory", "attention", "meta-cognition", "scaffolding", "sona", "cognitum"];
|
|
69
|
+
};
|
|
70
|
+
state: "uninitialized" | "initializing" | "ready" | "error";
|
|
71
|
+
initialize(): Promise<void>;
|
|
72
|
+
shutdown(): Promise<void>;
|
|
73
|
+
getMCPTools(): MCPTool[];
|
|
74
|
+
getAgentTypes(): string[];
|
|
75
|
+
};
|
|
76
|
+
export default cognitiveKernelPlugin;
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,OAAO,EACP,YAAY,GACb,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,eAAe,EACf,cAAc,GACf,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACV,UAAU,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,cAAc,GACf,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAyB,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;CAclB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;CAC/B;AAQD;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAatD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAapD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,0BAA0B,CAE3D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,EAAE,CAEvC;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;WAEN,eAAe,GAAG,cAAc,GAAG,OAAO,GAAG,OAAO;kBAE1D,OAAO,CAAC,IAAI,CAAC;gBAWf,OAAO,CAAC,IAAI,CAAC;mBAKhB,OAAO,EAAE;qBAIP,MAAM,EAAE;CAU1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Kernel Plugin
|
|
3
|
+
*
|
|
4
|
+
* Cognitive augmentation for LLM reasoning with working memory,
|
|
5
|
+
* attention control, meta-cognition, scaffolding, and cognitive load management.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Working memory slot management (Miller's 7 +/- 2)
|
|
9
|
+
* - Attention control (focus, diffuse, selective, divided, sustained)
|
|
10
|
+
* - Meta-cognitive monitoring and reflection
|
|
11
|
+
* - Cognitive scaffolding (decomposition, analogy, Socratic, etc.)
|
|
12
|
+
* - Cognitive load theory optimization
|
|
13
|
+
* - SONA integration for continuous learning
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
// Export types
|
|
18
|
+
export * from './types.js';
|
|
19
|
+
// Export MCP tools
|
|
20
|
+
export { workingMemoryTool, attentionControlTool, metaMonitorTool, scaffoldTool, cognitiveLoadTool, cognitiveKernelTools, toolHandlers, getTool, getToolNames, } from './mcp-tools.js';
|
|
21
|
+
// Export bridges
|
|
22
|
+
export { CognitiveBridge, createCognitiveBridge, SonaBridge, createSonaBridge, } from './bridges/index.js';
|
|
23
|
+
import { cognitiveKernelTools } from './mcp-tools.js';
|
|
24
|
+
import { createCognitiveBridge } from './bridges/cognitive-bridge.js';
|
|
25
|
+
import { createSonaBridge } from './bridges/sona-bridge.js';
|
|
26
|
+
/**
|
|
27
|
+
* Cognitive Kernel Plugin metadata
|
|
28
|
+
*/
|
|
29
|
+
export const PLUGIN_METADATA = {
|
|
30
|
+
name: '@claude-flow/plugin-cognitive-kernel',
|
|
31
|
+
version: '3.0.0-alpha.1',
|
|
32
|
+
description: 'Cognitive kernel plugin for LLM augmentation',
|
|
33
|
+
author: 'Claude Flow Team',
|
|
34
|
+
keywords: [
|
|
35
|
+
'cognitive-kernel',
|
|
36
|
+
'working-memory',
|
|
37
|
+
'attention',
|
|
38
|
+
'meta-cognition',
|
|
39
|
+
'scaffolding',
|
|
40
|
+
'sona',
|
|
41
|
+
'cognitum',
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
let pluginState = {
|
|
45
|
+
initialized: false,
|
|
46
|
+
cognitiveBridge: null,
|
|
47
|
+
sonaBridge: null,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the cognitive kernel plugin
|
|
51
|
+
*/
|
|
52
|
+
export async function initializePlugin() {
|
|
53
|
+
if (pluginState.initialized)
|
|
54
|
+
return;
|
|
55
|
+
// Initialize bridges
|
|
56
|
+
pluginState.cognitiveBridge = createCognitiveBridge();
|
|
57
|
+
pluginState.sonaBridge = createSonaBridge();
|
|
58
|
+
await Promise.all([
|
|
59
|
+
pluginState.cognitiveBridge.init(),
|
|
60
|
+
pluginState.sonaBridge.init(),
|
|
61
|
+
]);
|
|
62
|
+
pluginState.initialized = true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Shutdown the cognitive kernel plugin
|
|
66
|
+
*/
|
|
67
|
+
export async function shutdownPlugin() {
|
|
68
|
+
if (!pluginState.initialized)
|
|
69
|
+
return;
|
|
70
|
+
await Promise.all([
|
|
71
|
+
pluginState.cognitiveBridge?.destroy(),
|
|
72
|
+
pluginState.sonaBridge?.destroy(),
|
|
73
|
+
]);
|
|
74
|
+
pluginState = {
|
|
75
|
+
initialized: false,
|
|
76
|
+
cognitiveBridge: null,
|
|
77
|
+
sonaBridge: null,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get plugin state
|
|
82
|
+
*/
|
|
83
|
+
export function getPluginState() {
|
|
84
|
+
return { ...pluginState };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get all MCP tools provided by this plugin
|
|
88
|
+
*/
|
|
89
|
+
export function getMCPTools() {
|
|
90
|
+
return cognitiveKernelTools;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Plugin interface for registration with Claude Flow
|
|
94
|
+
*/
|
|
95
|
+
export const cognitiveKernelPlugin = {
|
|
96
|
+
metadata: PLUGIN_METADATA,
|
|
97
|
+
state: 'uninitialized',
|
|
98
|
+
async initialize() {
|
|
99
|
+
this.state = 'initializing';
|
|
100
|
+
try {
|
|
101
|
+
await initializePlugin();
|
|
102
|
+
this.state = 'ready';
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
this.state = 'error';
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
async shutdown() {
|
|
110
|
+
await shutdownPlugin();
|
|
111
|
+
this.state = 'uninitialized';
|
|
112
|
+
},
|
|
113
|
+
getMCPTools() {
|
|
114
|
+
return cognitiveKernelTools;
|
|
115
|
+
},
|
|
116
|
+
getAgentTypes() {
|
|
117
|
+
return [
|
|
118
|
+
'cognitive-controller',
|
|
119
|
+
'working-memory-manager',
|
|
120
|
+
'attention-director',
|
|
121
|
+
'meta-cognitive-monitor',
|
|
122
|
+
'scaffold-generator',
|
|
123
|
+
'cognitive-load-optimizer',
|
|
124
|
+
];
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
export default cognitiveKernelPlugin;
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAe;AACf,cAAc,YAAY,CAAC;AAE3B,mBAAmB;AACnB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,OAAO,EACP,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,iBAAiB;AACjB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAmB,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAc,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,sCAAsC;IAC5C,OAAO,E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,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,eAAuE;IAE9E,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,gBAAgB,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;YACrB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,eAAe,CAAC;IAC/B,CAAC;IAED,WAAW;QACT,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,aAAa;QACX,OAAO;YACL,sBAAsB;YACtB,wBAAwB;YACxB,oBAAoB;YACpB,wBAAwB;YACxB,oBAAoB;YACpB,0BAA0B;SAC3B,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Kernel MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* 5 MCP tools for cognitive augmentation:
|
|
5
|
+
* - cognition/working-memory: Working memory slot management
|
|
6
|
+
* - cognition/attention-control: Cognitive attention control
|
|
7
|
+
* - cognition/meta-monitor: Meta-cognitive monitoring
|
|
8
|
+
* - cognition/scaffold: Cognitive scaffolding
|
|
9
|
+
* - cognition/cognitive-load: Cognitive load management
|
|
10
|
+
*/
|
|
11
|
+
import type { MCPTool, MCPToolResult, ToolContext } from './types.js';
|
|
12
|
+
export declare const workingMemoryTool: MCPTool;
|
|
13
|
+
export declare const attentionControlTool: MCPTool;
|
|
14
|
+
export declare const metaMonitorTool: MCPTool;
|
|
15
|
+
export declare const scaffoldTool: MCPTool;
|
|
16
|
+
export declare const cognitiveLoadTool: MCPTool;
|
|
17
|
+
export declare const cognitiveKernelTools: MCPTool[];
|
|
18
|
+
export declare const toolHandlers: Map<string, (input: Record<string, unknown>, context?: ToolContext) => Promise<MCPToolResult>>;
|
|
19
|
+
export declare function getTool(name: string): MCPTool | undefined;
|
|
20
|
+
export declare function getToolNames(): string[];
|
|
21
|
+
export default cognitiveKernelTools;
|
|
22
|
+
//# sourceMappingURL=mcp-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools.d.ts","sourceRoot":"","sources":["../src/mcp-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,WAAW,EAeZ,MAAM,YAAY,CAAC;AAkTpB,eAAO,MAAM,iBAAiB,EAAE,OAgC/B,CAAC;AAoIF,eAAO,MAAM,oBAAoB,EAAE,OAqClC,CAAC;AAkKF,eAAO,MAAM,eAAe,EAAE,OA4B7B,CAAC;AAwIF,eAAO,MAAM,YAAY,EAAE,OAkC1B,CAAC;AAqIF,eAAO,MAAM,iBAAiB,EAAE,OA2B/B,CAAC;AAMF,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAMzC,CAAC;AAEF,eAAO,MAAM,YAAY,gGAMvB,CAAC;AAEH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEzD;AAED,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED,eAAe,oBAAoB,CAAC"}
|