@monoes/monomindcli 1.15.4 → 1.15.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/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +7 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/causal-infer.js +347 -0
- package/dist/src/mcp-tools/coherence/causal-infer.js.map +1 -0
- package/dist/src/mcp-tools/coherence/coherence-check.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/coherence-check.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/coherence-check.js +206 -0
- package/dist/src/mcp-tools/coherence/coherence-check.js.map +1 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.js +303 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.js.map +1 -0
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/memory-gate.js +266 -0
- package/dist/src/mcp-tools/coherence/memory-gate.js.map +1 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.js +406 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.js.map +1 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.js +293 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.js.map +1 -0
- package/dist/src/mcp-tools/coherence/types.d.ts +277 -0
- package/dist/src/mcp-tools/coherence/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/types.js +159 -0
- package/dist/src/mcp-tools/coherence/types.js.map +1 -0
- package/dist/src/mcp-tools/coherence-tools.d.ts +9 -0
- package/dist/src/mcp-tools/coherence-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence-tools.js +25 -0
- package/dist/src/mcp-tools/coherence-tools.js.map +1 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.d.ts +163 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.js +414 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.d.ts +128 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.js +375 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +161 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +423 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts +165 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.js +395 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.d.ts +165 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.js +508 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.d.ts +147 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.js +391 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.d.ts +147 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.js +422 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.d.ts +185 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.js +437 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.d.ts +166 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.js +410 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.d.ts +201 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.js +363 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.d.ts +166 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.js +394 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +129 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js +383 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.d.ts +171 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.js +476 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.d.ts +147 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.js +400 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts +145 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.js +328 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.d.ts +126 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.js +348 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.js.map +1 -0
- package/dist/src/mcp-tools/quality-tools.d.ts +9 -0
- package/dist/src/mcp-tools/quality-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality-tools.js +308 -0
- package/dist/src/mcp-tools/quality-tools.js.map +1 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -1
- package/dist/src/plugins/store/discovery.js +4 -124
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/publish-registry.ts +0 -2
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quantum Topology Tool - pr_quantum_topology
|
|
3
|
+
*
|
|
4
|
+
* Computes quantum topology features including Betti numbers and persistence diagrams.
|
|
5
|
+
* Analyzes topological features of point clouds and simplicial complexes.
|
|
6
|
+
*
|
|
7
|
+
* Uses QuantumEngine from prime-radiant-advanced-wasm
|
|
8
|
+
*/
|
|
9
|
+
import { TopologyInputSchema, successResult, errorResult, } from './types.js';
|
|
10
|
+
// Default logger
|
|
11
|
+
const defaultLogger = {
|
|
12
|
+
debug: (msg, meta) => console.debug(`[pr_quantum_topology] ${msg}`, meta),
|
|
13
|
+
info: (msg, meta) => console.info(`[pr_quantum_topology] ${msg}`, meta),
|
|
14
|
+
warn: (msg, meta) => console.warn(`[pr_quantum_topology] ${msg}`, meta),
|
|
15
|
+
error: (msg, meta) => console.error(`[pr_quantum_topology] ${msg}`, meta),
|
|
16
|
+
};
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Topology Helper Functions
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Compute Euclidean distance between two points
|
|
22
|
+
*/
|
|
23
|
+
function euclideanDistance(a, b) {
|
|
24
|
+
let sum = 0;
|
|
25
|
+
for (let i = 0; i < a.length; i++) {
|
|
26
|
+
const diff = a[i] - b[i];
|
|
27
|
+
sum += diff * diff;
|
|
28
|
+
}
|
|
29
|
+
return Math.sqrt(sum);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build distance matrix from vertices
|
|
33
|
+
*/
|
|
34
|
+
function buildDistanceMatrix(vertices) {
|
|
35
|
+
const n = vertices.length;
|
|
36
|
+
const matrix = [];
|
|
37
|
+
for (let i = 0; i < n; i++) {
|
|
38
|
+
matrix[i] = [];
|
|
39
|
+
for (let j = 0; j < n; j++) {
|
|
40
|
+
matrix[i][j] = euclideanDistance(vertices[i], vertices[j]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return matrix;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build Vietoris-Rips complex at given epsilon
|
|
47
|
+
* Returns list of simplices (vertex index arrays)
|
|
48
|
+
*/
|
|
49
|
+
function buildRipsComplex(distanceMatrix, epsilon, maxDimension) {
|
|
50
|
+
const n = distanceMatrix.length;
|
|
51
|
+
const simplices = [];
|
|
52
|
+
// Add 0-simplices (vertices)
|
|
53
|
+
for (let i = 0; i < n; i++) {
|
|
54
|
+
simplices.push([i]);
|
|
55
|
+
}
|
|
56
|
+
if (maxDimension < 1)
|
|
57
|
+
return simplices;
|
|
58
|
+
// Add 1-simplices (edges)
|
|
59
|
+
const edges = [];
|
|
60
|
+
for (let i = 0; i < n; i++) {
|
|
61
|
+
for (let j = i + 1; j < n; j++) {
|
|
62
|
+
if (distanceMatrix[i][j] <= epsilon) {
|
|
63
|
+
edges.push([i, j]);
|
|
64
|
+
simplices.push([i, j]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (maxDimension < 2)
|
|
69
|
+
return simplices;
|
|
70
|
+
// Add 2-simplices (triangles)
|
|
71
|
+
// A triangle exists if all three edges exist
|
|
72
|
+
const edgeSet = new Set(edges.map(e => `${e[0]}-${e[1]}`));
|
|
73
|
+
for (let i = 0; i < n; i++) {
|
|
74
|
+
for (let j = i + 1; j < n; j++) {
|
|
75
|
+
if (!edgeSet.has(`${i}-${j}`))
|
|
76
|
+
continue;
|
|
77
|
+
for (let k = j + 1; k < n; k++) {
|
|
78
|
+
if (edgeSet.has(`${i}-${k}`) && edgeSet.has(`${j}-${k}`)) {
|
|
79
|
+
simplices.push([i, j, k]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (maxDimension < 3)
|
|
85
|
+
return simplices;
|
|
86
|
+
// Add 3-simplices (tetrahedra)
|
|
87
|
+
// Simplified: only add if all faces exist
|
|
88
|
+
const triangleSet = new Set(simplices
|
|
89
|
+
.filter(s => s.length === 3)
|
|
90
|
+
.map(t => `${t[0]}-${t[1]}-${t[2]}`));
|
|
91
|
+
for (let i = 0; i < n; i++) {
|
|
92
|
+
for (let j = i + 1; j < n; j++) {
|
|
93
|
+
for (let k = j + 1; k < n; k++) {
|
|
94
|
+
for (let l = k + 1; l < n; l++) {
|
|
95
|
+
// Check all 4 triangular faces exist
|
|
96
|
+
const faces = [
|
|
97
|
+
`${i}-${j}-${k}`,
|
|
98
|
+
`${i}-${j}-${l}`,
|
|
99
|
+
`${i}-${k}-${l}`,
|
|
100
|
+
`${j}-${k}-${l}`,
|
|
101
|
+
];
|
|
102
|
+
if (faces.every(f => triangleSet.has(f))) {
|
|
103
|
+
simplices.push([i, j, k, l]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return simplices;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Compute Betti numbers from simplicial complex
|
|
113
|
+
* Uses simplified computation based on simplex counts
|
|
114
|
+
*
|
|
115
|
+
* Betti numbers:
|
|
116
|
+
* - b0: Number of connected components
|
|
117
|
+
* - b1: Number of loops/cycles
|
|
118
|
+
* - b2: Number of voids/cavities
|
|
119
|
+
*/
|
|
120
|
+
function computeBettiNumbers(vertices, simplices, maxDimension) {
|
|
121
|
+
const n = vertices.length;
|
|
122
|
+
const bettiNumbers = [];
|
|
123
|
+
// Count simplices by dimension
|
|
124
|
+
const simplexCounts = new Array(maxDimension + 1).fill(0);
|
|
125
|
+
for (const simplex of simplices) {
|
|
126
|
+
const dim = simplex.length - 1;
|
|
127
|
+
if (dim <= maxDimension) {
|
|
128
|
+
simplexCounts[dim]++;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// b0: Connected components (using union-find approximation)
|
|
132
|
+
const parent = new Array(n).fill(-1);
|
|
133
|
+
function find(x) {
|
|
134
|
+
if (parent[x] < 0)
|
|
135
|
+
return x;
|
|
136
|
+
parent[x] = find(parent[x]);
|
|
137
|
+
return parent[x];
|
|
138
|
+
}
|
|
139
|
+
function union(x, y) {
|
|
140
|
+
const px = find(x);
|
|
141
|
+
const py = find(y);
|
|
142
|
+
if (px !== py) {
|
|
143
|
+
parent[px] = py;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Connect vertices in edges
|
|
147
|
+
for (const simplex of simplices) {
|
|
148
|
+
if (simplex.length === 2) {
|
|
149
|
+
union(simplex[0], simplex[1]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Count components
|
|
153
|
+
let b0 = 0;
|
|
154
|
+
for (let i = 0; i < n; i++) {
|
|
155
|
+
if (parent[i] < 0)
|
|
156
|
+
b0++;
|
|
157
|
+
}
|
|
158
|
+
bettiNumbers.push(b0);
|
|
159
|
+
// b1: Approximate using Euler characteristic relationship
|
|
160
|
+
// For connected graphs: b1 = edges - vertices + components
|
|
161
|
+
if (maxDimension >= 1) {
|
|
162
|
+
const edges = simplexCounts[1] || 0;
|
|
163
|
+
const b1 = Math.max(0, edges - n + b0);
|
|
164
|
+
bettiNumbers.push(b1);
|
|
165
|
+
}
|
|
166
|
+
// b2: Approximate from triangle/tetrahedron relationship
|
|
167
|
+
if (maxDimension >= 2) {
|
|
168
|
+
const triangles = simplexCounts[2] || 0;
|
|
169
|
+
const tetrahedra = simplexCounts[3] || 0;
|
|
170
|
+
// Simplified: b2 related to enclosed voids
|
|
171
|
+
const b2 = Math.max(0, tetrahedra > 0 ? 1 : 0);
|
|
172
|
+
bettiNumbers.push(b2);
|
|
173
|
+
}
|
|
174
|
+
return bettiNumbers;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Compute persistence diagram using filtration
|
|
178
|
+
* Tracks birth and death of topological features
|
|
179
|
+
*/
|
|
180
|
+
function computePersistenceDiagram(distanceMatrix, maxDimension) {
|
|
181
|
+
const diagram = [];
|
|
182
|
+
// Get all unique distances (filtration values)
|
|
183
|
+
const distances = [];
|
|
184
|
+
const n = distanceMatrix.length;
|
|
185
|
+
for (let i = 0; i < n; i++) {
|
|
186
|
+
for (let j = i + 1; j < n; j++) {
|
|
187
|
+
distances.push(distanceMatrix[i][j]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
distances.sort((a, b) => a - b);
|
|
191
|
+
const uniqueDistances = [...new Set(distances)];
|
|
192
|
+
// Sample filtration values
|
|
193
|
+
const sampleCount = Math.min(10, uniqueDistances.length);
|
|
194
|
+
const sampleIndices = [];
|
|
195
|
+
for (let i = 0; i < sampleCount; i++) {
|
|
196
|
+
sampleIndices.push(Math.floor(i * uniqueDistances.length / sampleCount));
|
|
197
|
+
}
|
|
198
|
+
const filtrationValues = sampleIndices.map(i => uniqueDistances[i]);
|
|
199
|
+
if (filtrationValues.length === 0)
|
|
200
|
+
return diagram;
|
|
201
|
+
// Track Betti numbers at each filtration value
|
|
202
|
+
let prevBetti = [];
|
|
203
|
+
for (let f = 0; f < filtrationValues.length; f++) {
|
|
204
|
+
const epsilon = filtrationValues[f];
|
|
205
|
+
const simplices = buildRipsComplex(distanceMatrix, epsilon, maxDimension);
|
|
206
|
+
const currentBetti = computeBettiNumbers(new Array(n).fill([]).map((_, i) => [i]), simplices, maxDimension);
|
|
207
|
+
if (f > 0) {
|
|
208
|
+
// Detect births and deaths
|
|
209
|
+
for (let dim = 0; dim <= maxDimension && dim < currentBetti.length; dim++) {
|
|
210
|
+
const prevB = prevBetti[dim] || 0;
|
|
211
|
+
const currB = currentBetti[dim] || 0;
|
|
212
|
+
// New features born
|
|
213
|
+
if (currB > prevB) {
|
|
214
|
+
for (let i = 0; i < currB - prevB; i++) {
|
|
215
|
+
diagram.push({
|
|
216
|
+
birth: filtrationValues[f - 1],
|
|
217
|
+
death: Infinity, // Will be updated when feature dies
|
|
218
|
+
dimension: dim,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Features died
|
|
223
|
+
if (currB < prevB) {
|
|
224
|
+
// Find features to kill (those born earliest)
|
|
225
|
+
const toKill = prevB - currB;
|
|
226
|
+
let killed = 0;
|
|
227
|
+
for (let d = diagram.length - 1; d >= 0 && killed < toKill; d--) {
|
|
228
|
+
if (diagram[d].dimension === dim && diagram[d].death === Infinity) {
|
|
229
|
+
diagram[d].death = epsilon;
|
|
230
|
+
killed++;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Initial features (all vertices born at epsilon = 0)
|
|
238
|
+
for (let dim = 0; dim <= maxDimension && dim < currentBetti.length; dim++) {
|
|
239
|
+
for (let i = 0; i < currentBetti[dim]; i++) {
|
|
240
|
+
diagram.push({
|
|
241
|
+
birth: 0,
|
|
242
|
+
death: Infinity,
|
|
243
|
+
dimension: dim,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
prevBetti = currentBetti;
|
|
249
|
+
}
|
|
250
|
+
return diagram;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get interpretation of Betti numbers
|
|
254
|
+
*/
|
|
255
|
+
function interpretBettiNumbers(bettiNumbers) {
|
|
256
|
+
return {
|
|
257
|
+
b0: `${bettiNumbers[0] || 0} connected component(s)`,
|
|
258
|
+
b1: `${bettiNumbers[1] || 0} loop(s)/cycle(s)`,
|
|
259
|
+
b2: `${bettiNumbers[2] || 0} void(s)/cavit${(bettiNumbers[2] || 0) === 1 ? 'y' : 'ies'}`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Handler for pr_quantum_topology tool
|
|
264
|
+
*/
|
|
265
|
+
async function handler(input, context) {
|
|
266
|
+
const logger = context?.logger ?? defaultLogger;
|
|
267
|
+
const startTime = performance.now();
|
|
268
|
+
try {
|
|
269
|
+
// Validate input
|
|
270
|
+
const validationResult = TopologyInputSchema.safeParse(input);
|
|
271
|
+
if (!validationResult.success) {
|
|
272
|
+
logger.error('Input validation failed', { error: validationResult.error.message });
|
|
273
|
+
return errorResult(`Invalid input: ${validationResult.error.message}`);
|
|
274
|
+
}
|
|
275
|
+
const { complex } = validationResult.data;
|
|
276
|
+
const { vertices, maxDimension } = complex;
|
|
277
|
+
logger.debug('Processing quantum topology', {
|
|
278
|
+
vertexCount: vertices.length,
|
|
279
|
+
maxDimension,
|
|
280
|
+
});
|
|
281
|
+
if (vertices.length === 0) {
|
|
282
|
+
return errorResult('No vertices provided');
|
|
283
|
+
}
|
|
284
|
+
// Validate vertex dimensions are consistent
|
|
285
|
+
const firstDim = vertices[0].length;
|
|
286
|
+
for (let i = 1; i < vertices.length; i++) {
|
|
287
|
+
if (vertices[i].length !== firstDim) {
|
|
288
|
+
return errorResult(`Vertex dimension mismatch: vertex ${i} has ${vertices[i].length} dimensions, expected ${firstDim}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
let bettiNumbers;
|
|
292
|
+
let persistenceDiagram;
|
|
293
|
+
let homologyClasses;
|
|
294
|
+
// Try to use WASM bridge if available
|
|
295
|
+
if (context?.bridge?.initialized) {
|
|
296
|
+
try {
|
|
297
|
+
logger.debug('Using WASM bridge for topology computation');
|
|
298
|
+
const result = await context.bridge.computeTopology(complex);
|
|
299
|
+
bettiNumbers = result.bettiNumbers;
|
|
300
|
+
persistenceDiagram = result.persistenceDiagram.map(([birth, death], i) => ({
|
|
301
|
+
birth,
|
|
302
|
+
death,
|
|
303
|
+
dimension: Math.min(i % (maxDimension + 1), maxDimension),
|
|
304
|
+
}));
|
|
305
|
+
homologyClasses = result.homologyClasses;
|
|
306
|
+
}
|
|
307
|
+
catch (wasmError) {
|
|
308
|
+
logger.warn('WASM bridge failed, falling back to JS implementation', {
|
|
309
|
+
error: wasmError instanceof Error ? wasmError.message : String(wasmError),
|
|
310
|
+
});
|
|
311
|
+
// Use JavaScript implementation
|
|
312
|
+
const distanceMatrix = buildDistanceMatrix(vertices);
|
|
313
|
+
const maxDistance = Math.max(...distanceMatrix.flat().filter(d => d > 0));
|
|
314
|
+
const simplices = buildRipsComplex(distanceMatrix, maxDistance * 0.5, maxDimension);
|
|
315
|
+
bettiNumbers = computeBettiNumbers(vertices, simplices, maxDimension);
|
|
316
|
+
persistenceDiagram = computePersistenceDiagram(distanceMatrix, maxDimension);
|
|
317
|
+
homologyClasses = bettiNumbers.reduce((a, b) => a + b, 0);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// Pure JavaScript fallback
|
|
322
|
+
logger.debug('Using JavaScript fallback for topology computation');
|
|
323
|
+
const distanceMatrix = buildDistanceMatrix(vertices);
|
|
324
|
+
const maxDistance = Math.max(...distanceMatrix.flat().filter(d => d > 0));
|
|
325
|
+
const simplices = buildRipsComplex(distanceMatrix, maxDistance * 0.5, maxDimension);
|
|
326
|
+
bettiNumbers = computeBettiNumbers(vertices, simplices, maxDimension);
|
|
327
|
+
persistenceDiagram = computePersistenceDiagram(distanceMatrix, maxDimension);
|
|
328
|
+
homologyClasses = bettiNumbers.reduce((a, b) => a + b, 0);
|
|
329
|
+
}
|
|
330
|
+
const output = {
|
|
331
|
+
bettiNumbers,
|
|
332
|
+
persistenceDiagram,
|
|
333
|
+
details: {
|
|
334
|
+
homologyClasses,
|
|
335
|
+
interpretation: interpretBettiNumbers(bettiNumbers),
|
|
336
|
+
vertexCount: vertices.length,
|
|
337
|
+
maxDimension,
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
const duration = performance.now() - startTime;
|
|
341
|
+
logger.info('Quantum topology completed', {
|
|
342
|
+
bettiNumbers: bettiNumbers.join(', '),
|
|
343
|
+
persistencePoints: persistenceDiagram.length,
|
|
344
|
+
homologyClasses,
|
|
345
|
+
durationMs: duration.toFixed(2),
|
|
346
|
+
});
|
|
347
|
+
return successResult(output);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
const duration = performance.now() - startTime;
|
|
351
|
+
logger.error('Quantum topology failed', {
|
|
352
|
+
error: error instanceof Error ? error.message : String(error),
|
|
353
|
+
durationMs: duration.toFixed(2),
|
|
354
|
+
});
|
|
355
|
+
return errorResult(error instanceof Error ? error : new Error(String(error)));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* pr_quantum_topology MCP Tool Definition
|
|
360
|
+
*/
|
|
361
|
+
export const quantumTopologyTool = {
|
|
362
|
+
name: 'pr_quantum_topology',
|
|
363
|
+
description: 'Compute quantum topology features including Betti numbers and persistence diagrams. Analyzes topological features of point clouds. Uses QuantumEngine for persistent homology computation.',
|
|
364
|
+
category: 'topology',
|
|
365
|
+
version: '0.1.3',
|
|
366
|
+
tags: ['topology', 'betti-numbers', 'persistence', 'homology', 'ai-interpretability'],
|
|
367
|
+
cacheable: true,
|
|
368
|
+
cacheTTL: 120000, // 2 minute cache (expensive computation)
|
|
369
|
+
inputSchema: {
|
|
370
|
+
type: 'object',
|
|
371
|
+
properties: {
|
|
372
|
+
complex: {
|
|
373
|
+
type: 'object',
|
|
374
|
+
properties: {
|
|
375
|
+
vertices: {
|
|
376
|
+
type: 'array',
|
|
377
|
+
items: { type: 'array', items: { type: 'number' } },
|
|
378
|
+
description: 'Vertex coordinates (point cloud)',
|
|
379
|
+
},
|
|
380
|
+
simplices: {
|
|
381
|
+
type: 'array',
|
|
382
|
+
items: {
|
|
383
|
+
type: 'object',
|
|
384
|
+
properties: {
|
|
385
|
+
vertices: { type: 'array', items: { type: 'number' } },
|
|
386
|
+
dimension: { type: 'number' },
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
description: 'Explicit simplices (optional, computed from vertices if not provided)',
|
|
390
|
+
},
|
|
391
|
+
maxDimension: {
|
|
392
|
+
type: 'number',
|
|
393
|
+
default: 2,
|
|
394
|
+
description: 'Maximum homology dimension to compute (0-3)',
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
required: ['vertices'],
|
|
398
|
+
description: 'Simplicial complex for topological analysis',
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
required: ['complex'],
|
|
402
|
+
},
|
|
403
|
+
handler,
|
|
404
|
+
};
|
|
405
|
+
export default quantumTopologyTool;
|
|
406
|
+
//# sourceMappingURL=quantum-topology.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantum-topology.js","sourceRoot":"","sources":["../../../../src/mcp-tools/coherence/quantum-topology.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,iBAAiB;AACjB,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE,CAAC,GAAW,EAAE,IAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,EAAE,IAAI,CAAC;IAC3G,IAAI,EAAE,CAAC,GAAW,EAAE,IAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,GAAG,EAAE,EAAE,IAAI,CAAC;IACzG,IAAI,EAAE,CAAC,GAAW,EAAE,IAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,GAAG,EAAE,EAAE,IAAI,CAAC;IACzG,KAAK,EAAE,CAAC,GAAW,EAAE,IAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,EAAE,IAAI,CAAC;CAC5G,CAAC;AAEF,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;GAEG;AACH,SAAS,iBAAiB,CAAC,CAAW,EAAE,CAAW;IACjD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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
|
+
*
|
|
4
|
+
* Analyzes stability of systems using spectral graph theory.
|
|
5
|
+
* Computes eigenvalues, spectral gap, and stability metrics.
|
|
6
|
+
*
|
|
7
|
+
* Uses SpectralEngine from prime-radiant-advanced-wasm
|
|
8
|
+
*/
|
|
9
|
+
import type { MCPTool } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* pr_spectral_analyze MCP Tool Definition
|
|
12
|
+
*/
|
|
13
|
+
export declare const spectralAnalyzeTool: MCPTool;
|
|
14
|
+
export default spectralAnalyzeTool;
|
|
15
|
+
//# sourceMappingURL=spectral-analyze.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectral-analyze.d.ts","sourceRoot":"","sources":["../../../../src/mcp-tools/coherence/spectral-analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,YAAY,CAAC;AAqSpB;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,OA0BjC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|