agentgui 1.0.348 → 1.0.350

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +47 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.348",
3
+ "version": "1.0.350",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -62,6 +62,35 @@ function broadcastModelProgress(progress) {
62
62
  broadcastSync(broadcastData);
63
63
  }
64
64
 
65
+ async function validateAndCleanupModels(modelsDir) {
66
+ try {
67
+ const manifestPath = path.join(modelsDir, '.manifests.json');
68
+ if (fs.existsSync(manifestPath)) {
69
+ try {
70
+ const content = fs.readFileSync(manifestPath, 'utf8');
71
+ JSON.parse(content);
72
+ } catch (e) {
73
+ console.error('[MODELS] Manifest corrupted, removing:', e.message);
74
+ fs.unlinkSync(manifestPath);
75
+ }
76
+ }
77
+
78
+ const files = fs.readdirSync(modelsDir);
79
+ for (const file of files) {
80
+ if (file.endsWith('.tmp')) {
81
+ try {
82
+ fs.unlinkSync(path.join(modelsDir, file));
83
+ console.log('[MODELS] Cleaned up temp file:', file);
84
+ } catch (e) {
85
+ console.warn('[MODELS] Failed to clean:', file);
86
+ }
87
+ }
88
+ }
89
+ } catch (e) {
90
+ console.warn('[MODELS] Cleanup check failed:', e.message);
91
+ }
92
+ }
93
+
65
94
  async function ensureModelsDownloaded() {
66
95
  if (modelDownloadState.downloading) {
67
96
  while (modelDownloadState.downloading) {
@@ -83,6 +112,8 @@ async function ensureModelsDownloaded() {
83
112
  ? (fs.existsSync(path.join(process.env.PORTABLE_EXE_DIR, 'models', 'onnx-community')) ? path.join(process.env.PORTABLE_EXE_DIR, 'models') : gmguiModels)
84
113
  : gmguiModels;
85
114
 
115
+ await validateAndCleanupModels(modelsBase);
116
+
86
117
  const config = createConfig({
87
118
  modelsDir: modelsBase,
88
119
  ttsModelsDir: path.join(modelsBase, 'tts'),
@@ -2449,8 +2480,22 @@ const server = http.createServer(async (req, res) => {
2449
2480
  sendJSON(req, res, 200, { text: finalText });
2450
2481
  } catch (err) {
2451
2482
  debugLog('[STT] Error: ' + err.message);
2452
- broadcastSync({ type: 'stt_progress', status: 'failed', percentComplete: 0, error: err.message });
2453
- if (!res.headersSent) sendJSON(req, res, 500, { error: err.message || 'STT failed' });
2483
+ let errorMsg = err.message || 'STT failed';
2484
+ if (errorMsg.includes('VERS_1.21') || errorMsg.includes('onnxruntime')) {
2485
+ errorMsg = 'STT model load failed: onnxruntime version mismatch. Try: npm install or npm ci';
2486
+ } else if (errorMsg.includes('not valid JSON') || errorMsg.includes('Unexpected token')) {
2487
+ errorMsg = 'STT model load failed: corrupted cache. Clearing... try again.';
2488
+ const modelsDir = path.join(os.homedir(), '.gmgui', 'models');
2489
+ try {
2490
+ const manifestPath = path.join(modelsDir, '.manifests.json');
2491
+ if (fs.existsSync(manifestPath)) fs.unlinkSync(manifestPath);
2492
+ console.log('[STT] Cleared corrupted manifest');
2493
+ } catch (e) {
2494
+ console.warn('[STT] Failed to clear manifest:', e.message);
2495
+ }
2496
+ }
2497
+ broadcastSync({ type: 'stt_progress', status: 'failed', percentComplete: 0, error: errorMsg });
2498
+ if (!res.headersSent) sendJSON(req, res, 500, { error: errorMsg });
2454
2499
  }
2455
2500
  return;
2456
2501
  }