magector 1.3.2 → 1.3.3
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/package.json +5 -5
- package/src/mcp-server.js +24 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Semantic code search for Magento 2 — index, search, MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/mcp-server.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"ruvector": "^0.1.96"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@magector/cli-darwin-arm64": "1.3.
|
|
37
|
-
"@magector/cli-linux-x64": "1.3.
|
|
38
|
-
"@magector/cli-linux-arm64": "1.3.
|
|
39
|
-
"@magector/cli-win32-x64": "1.3.
|
|
36
|
+
"@magector/cli-darwin-arm64": "1.3.3",
|
|
37
|
+
"@magector/cli-linux-x64": "1.3.3",
|
|
38
|
+
"@magector/cli-linux-arm64": "1.3.3",
|
|
39
|
+
"@magector/cli-win32-x64": "1.3.3"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -72,8 +72,11 @@ let serveReady = false;
|
|
|
72
72
|
let servePending = new Map();
|
|
73
73
|
let serveNextId = 1;
|
|
74
74
|
let serveReadline = null;
|
|
75
|
+
let serveReadyPromise = null;
|
|
76
|
+
let serveReadyResolve = null;
|
|
75
77
|
|
|
76
78
|
function startServeProcess() {
|
|
79
|
+
serveReadyPromise = new Promise((resolve) => { serveReadyResolve = resolve; });
|
|
77
80
|
try {
|
|
78
81
|
const args = [
|
|
79
82
|
'serve',
|
|
@@ -87,8 +90,8 @@ function startServeProcess() {
|
|
|
87
90
|
const proc = spawn(config.rustBinary, args,
|
|
88
91
|
{ stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
|
|
89
92
|
|
|
90
|
-
proc.on('error', () => { serveProcess = null; serveReady = false; });
|
|
91
|
-
proc.on('exit', () => { serveProcess = null; serveReady = false; });
|
|
93
|
+
proc.on('error', () => { serveProcess = null; serveReady = false; if (serveReadyResolve) { serveReadyResolve(false); serveReadyResolve = null; } });
|
|
94
|
+
proc.on('exit', () => { serveProcess = null; serveReady = false; if (serveReadyResolve) { serveReadyResolve(false); serveReadyResolve = null; } });
|
|
92
95
|
proc.stderr.on('data', () => {}); // drain stderr
|
|
93
96
|
|
|
94
97
|
serveReadline = createInterface({ input: proc.stdout });
|
|
@@ -99,6 +102,7 @@ function startServeProcess() {
|
|
|
99
102
|
// First line is ready signal
|
|
100
103
|
if (parsed.ready) {
|
|
101
104
|
serveReady = true;
|
|
105
|
+
if (serveReadyResolve) { serveReadyResolve(true); serveReadyResolve = null; }
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -114,6 +118,7 @@ function startServeProcess() {
|
|
|
114
118
|
} catch {
|
|
115
119
|
serveProcess = null;
|
|
116
120
|
serveReady = false;
|
|
121
|
+
if (serveReadyResolve) { serveReadyResolve(false); serveReadyResolve = null; }
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
@@ -138,6 +143,11 @@ async function rustSearchAsync(query, limit = 10) {
|
|
|
138
143
|
return searchCache.get(cacheKey);
|
|
139
144
|
}
|
|
140
145
|
|
|
146
|
+
// Wait for serve process if it's starting up but not yet ready
|
|
147
|
+
if (serveProcess && !serveReady && serveReadyPromise) {
|
|
148
|
+
await Promise.race([serveReadyPromise, new Promise(r => setTimeout(() => r(false), 10000))]);
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
// Try persistent serve process first
|
|
142
152
|
if (serveProcess && serveReady) {
|
|
143
153
|
try {
|
|
@@ -1176,8 +1186,18 @@ async function main() {
|
|
|
1176
1186
|
// Try to start persistent Rust serve process for fast queries
|
|
1177
1187
|
try {
|
|
1178
1188
|
startServeProcess();
|
|
1179
|
-
//
|
|
1180
|
-
|
|
1189
|
+
// Wait for the serve process to load ONNX model + HNSW index (up to 15s)
|
|
1190
|
+
if (serveReadyPromise) {
|
|
1191
|
+
const ready = await Promise.race([
|
|
1192
|
+
serveReadyPromise,
|
|
1193
|
+
new Promise(r => setTimeout(() => r(false), 15000))
|
|
1194
|
+
]);
|
|
1195
|
+
if (ready) {
|
|
1196
|
+
console.error('Serve process ready (persistent mode)');
|
|
1197
|
+
} else {
|
|
1198
|
+
console.error('Serve process not ready in time, will use fallback');
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1181
1201
|
} catch {
|
|
1182
1202
|
// Non-fatal: falls back to execFileSync per query
|
|
1183
1203
|
}
|