agentgui 1.0.269 → 1.0.270

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 +84 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.269",
3
+ "version": "1.0.270",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -104,22 +104,100 @@ async function ensureModelsDownloaded() {
104
104
 
105
105
  if (!sttOk) {
106
106
  console.log('[MODELS] Downloading STT model...');
107
- broadcastModelProgress({ started: true, done: false, downloading: true, type: 'stt', completedFiles, totalFiles });
107
+ broadcastModelProgress({ started: true, done: false, downloading: true, type: 'stt', source: 'ipfs-fallback', completedFiles, totalFiles });
108
+
109
+ let sttDownloaded = false;
110
+
111
+ // Try IPFS first with fallback to HuggingFace
108
112
  try {
109
- await webtalkWhisper.ensureModel('onnx-community/whisper-base', config);
113
+ const ipfsCid = queries.getIpfsCidByModel('whisper-base', 'stt');
114
+ if (ipfsCid) {
115
+ console.log('[MODELS] Attempting IPFS download for STT model:', ipfsCid.cid);
116
+ const sttFile = path.join(sttDir, 'model.onnx');
117
+ fs.mkdirSync(sttDir, { recursive: true });
118
+ await IPFSDownloader.downloadWithProgress(
119
+ `https://ipfs.io/ipfs/${ipfsCid.cid}`,
120
+ sttFile,
121
+ (progress) => {
122
+ broadcastModelProgress({
123
+ started: true,
124
+ done: false,
125
+ downloading: true,
126
+ type: 'stt',
127
+ source: 'ipfs',
128
+ ...progress,
129
+ completedFiles,
130
+ totalFiles
131
+ });
132
+ }
133
+ );
134
+ sttDownloaded = true;
135
+ console.log('[MODELS] STT model downloaded via IPFS');
136
+ }
110
137
  } catch (err) {
111
- console.warn('[MODELS] STT download failed, falling back to HuggingFace:', err.message);
138
+ console.warn('[MODELS] IPFS STT download failed:', err.message);
139
+ }
140
+
141
+ // Fall back to webtalk/HuggingFace if IPFS didn't work
142
+ if (!sttDownloaded) {
143
+ try {
144
+ console.log('[MODELS] Falling back to HuggingFace for STT model');
145
+ broadcastModelProgress({ started: true, done: false, downloading: true, type: 'stt', source: 'huggingface', completedFiles, totalFiles });
146
+ await webtalkWhisper.ensureModel('onnx-community/whisper-base', config);
147
+ console.log('[MODELS] STT model downloaded via HuggingFace');
148
+ } catch (err) {
149
+ console.warn('[MODELS] HuggingFace STT download also failed:', err.message);
150
+ }
112
151
  }
113
152
  completedFiles += 10;
114
153
  }
115
154
 
116
155
  if (!ttsOk) {
117
156
  console.log('[MODELS] Downloading TTS models...');
118
- broadcastModelProgress({ started: true, done: false, downloading: true, type: 'tts', completedFiles, totalFiles });
157
+ broadcastModelProgress({ started: true, done: false, downloading: true, type: 'tts', source: 'ipfs-fallback', completedFiles, totalFiles });
158
+
159
+ let ttsDownloaded = false;
160
+
161
+ // Try IPFS first with fallback to HuggingFace
119
162
  try {
120
- await webtalkTTS.ensureTTSModels(config);
163
+ const ipfsCid = queries.getIpfsCidByModel('tts', 'voice');
164
+ if (ipfsCid) {
165
+ console.log('[MODELS] Attempting IPFS download for TTS models:', ipfsCid.cid);
166
+ const ttsFile = path.join(ttsDir, 'models.tar.gz');
167
+ fs.mkdirSync(ttsDir, { recursive: true });
168
+ await IPFSDownloader.downloadWithProgress(
169
+ `https://ipfs.io/ipfs/${ipfsCid.cid}`,
170
+ ttsFile,
171
+ (progress) => {
172
+ broadcastModelProgress({
173
+ started: true,
174
+ done: false,
175
+ downloading: true,
176
+ type: 'tts',
177
+ source: 'ipfs',
178
+ ...progress,
179
+ completedFiles,
180
+ totalFiles
181
+ });
182
+ }
183
+ );
184
+ ttsDownloaded = true;
185
+ console.log('[MODELS] TTS models downloaded via IPFS');
186
+ }
121
187
  } catch (err) {
122
- console.warn('[MODELS] TTS download failed, falling back to HuggingFace:', err.message);
188
+ console.warn('[MODELS] IPFS TTS download failed:', err.message);
189
+ }
190
+
191
+ // Fall back to webtalk/HuggingFace if IPFS didn't work
192
+ if (!ttsDownloaded) {
193
+ try {
194
+ console.log('[MODELS] Falling back to HuggingFace for TTS models');
195
+ broadcastModelProgress({ started: true, done: false, downloading: true, type: 'tts', source: 'huggingface', completedFiles, totalFiles });
196
+ await webtalkTTS.ensureTTSModels(config);
197
+ console.log('[MODELS] TTS models downloaded via HuggingFace');
198
+ } catch (err) {
199
+ console.warn('[MODELS] HuggingFace TTS download also failed:', err.message);
200
+ }
123
201
  }
124
202
  completedFiles += 6;
125
203
  }