agentgui 1.0.322 → 1.0.324

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.
@@ -6,11 +6,11 @@ import { verifyFileIntegrity } from './file-verification.js';
6
6
 
7
7
  const require = createRequire(import.meta.url);
8
8
 
9
- // TEMPORARILY MODIFIED FOR TESTING - FORCE IPFS FAILURE
10
9
  const GATEWAYS = [
11
- 'http://invalid-gateway-1.local/ipfs/',
12
- 'http://invalid-gateway-2.local/ipfs/',
13
- 'http://invalid-gateway-3.local/ipfs/'
10
+ 'https://cloudflare-ipfs.com/ipfs/',
11
+ 'https://dweb.link/ipfs/',
12
+ 'https://gateway.pinata.cloud/ipfs/',
13
+ 'https://ipfs.io/ipfs/'
14
14
  ];
15
15
 
16
16
  async function downloadFromIPFS(cid, destPath, manifest, onProgress) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.322",
3
+ "version": "1.0.324",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/.prd DELETED
@@ -1,254 +0,0 @@
1
- # Model Download Fallback System - Integration PRD
2
-
3
- ## CURRENT STATE VERIFIED
4
-
5
- ### Phase 1-7 Status (CLAIMED DONE)
6
- ✓ lib/model-downloader.js exists (289 lines, 8247 bytes)
7
- - Exports: downloadWithFallback, getMetrics, getMetricsSummary, resetMetrics
8
- - Implements 3-layer fallback: IPFS → HuggingFace → cache
9
- - Parameters: ipfsCid, huggingfaceUrl, destPath, manifest, minBytes, preferredLayer
10
- - Verification: SHA-256 hash + size check + ONNX format validation
11
-
12
- ✓ scripts/publish-models-to-ipfs.js exists (173 lines, 5655 bytes)
13
- - Requires: PINATA_API_KEY, PINATA_SECRET_KEY
14
- - Uploads to Pinata, returns CIDs for whisper-base and tts-models
15
- - Not yet executed (no real CIDs)
16
-
17
- ✓ database.js IPFS infrastructure exists
18
- - Tables: ipfs_cids, ipfs_downloads
19
- - Query: getIpfsCidByModel(modelName, modelType)
20
- - Initialization: Lines 385-415 with PLACEHOLDER CIDs
21
- - WHISPER_CID = 'bafybeidyw252ecy4vs46bbmezrtw325gl2ymdltosmzqgx4edjsc3fbofy' (PLACEHOLDER)
22
- - TTS_CID = 'bafybeidyw252ecy4vs46bbmezrtw325gl2ymdltosmzqgx4edjsc3fbofy' (PLACEHOLDER)
23
-
24
- ✓ Metrics API endpoints exist in server.js (lines 2552-2606)
25
- - GET /api/metrics/downloads
26
- - GET /api/metrics/downloads/summary
27
- - GET /api/metrics/downloads/health
28
- - POST /api/metrics/downloads/reset
29
-
30
- ✓ Manifest exists at ~/.gmgui/models/.manifests.json
31
- - whisper-base: 7 files, 293.76 MB total, SHA-256 hashes present
32
- - tts-models: 6 files, 198.60 MB total, SHA-256 hashes present
33
- - Generated: 2026-02-21T03:49:32.766Z
34
-
35
- ✓ Metrics file exists at ~/.gmgui/models/.metrics.json
36
-
37
- ### Phase 8-10 Status (TODO)
38
- ✗ lib/model-downloader.js NOT imported in server.js
39
- ✗ server.js ensureModelsDownloaded() uses old webtalk/ipfs-downloader (lines 66-125)
40
- ✗ Real IPFS CIDs not obtained (Pinata script not executed)
41
- ✗ database.js still has placeholder CIDs
42
-
43
- ## DEPENDENCIES & BLOCKING RELATIONSHIPS
44
-
45
- ### Wave 1 (COMPLETE - all items removed from work breakdown)
46
-
47
- ### Wave 2 (COMPLETE)
48
- ✓ Pinata API keys: BLOCKED - not available, user needs to sign up at https://www.pinata.cloud/
49
- ✓ Integration strategy designed - 150-200 line implementation, backward compatible, per-file iteration
50
-
51
- ### Wave 3-4 (COMPLETE)
52
- ✓ Integration already implemented in server.js (lines 67-157)
53
- ✓ Refactored model-downloader.js from 289→191 lines (created download-metrics.js, file-verification.js)
54
- ✓ All files now < 200 lines (CHARTER 5 compliant)
55
- ✓ Imports verified working, no functionality changes
56
- ✓ Item 6 BLOCKED on Pinata API keys (will skip for now)
57
-
58
- ### Wave 5 (Depends on Wave 4, final verification)
59
- 10. Test fallback chain with fresh cache (delete ~/.gmgui/models, verify IPFS layer 1)
60
- - Blocked by: Wave 4 items 8, 9
61
- - Blocks: Nothing (end-to-end test)
62
-
63
- 11. Test fallback to HuggingFace (simulate IPFS failure)
64
- - Blocked by: Wave 4 items 8, 9
65
- - Blocks: Nothing (end-to-end test)
66
-
67
- 12. Verify metrics collection after real downloads
68
- - Blocked by: Wave 4 items 8, 9
69
- - Blocks: Nothing (validation)
70
-
71
- ## UNKNOWNS TO RESOLVE
72
-
73
- ### Code Implementation Unknowns (Wave 1 RESOLVED)
74
- ✓ downloadWithFallback IPFS gateway list: YES - cycles all 4 gateways (Cloudflare, dweb.link, Pinata, ipfs.io) × 2 retries = 8 attempts
75
- ✓ downloadWithFallback error handling: YES - properly catches and continues on gateway failure
76
- ✓ downloadWithFallback progress reporting: YES - onProgress receives correct status for each layer
77
- ✓ Manifest integration: YES - downloadWithFallback correctly validates against manifest SHA-256
78
- ✓ File path construction: Direct iteration over manifest.files object, each key is relative path
79
-
80
- ### Integration Unknowns (Waves 2-4 RESOLVED)
81
- ✓ Current ensureModelsDownloaded flow: webtalk is npm package with ensureModels, checkTTSModelExists, checkWhisperModelExists
82
- ✓ Backward compatibility: full replacement possible, webtalk no longer called (still imported for downloadWithProgress elsewhere)
83
- ✓ Progress broadcasting: transformation implemented (layer→source, status→downloading, progress percentage calculated)
84
- ✓ Error handling: throws error with message, caught in try/catch, broadcast error event with modelDownloadState.error
85
- ✓ Concurrent download handling: modelDownloadState.downloading flag prevents concurrent downloads (lines 67-72 wait loop)
86
-
87
- ### Environment Unknowns
88
- - Pinata API keys: are they available? (blocks real IPFS publishing)
89
- - IPFS gateway reachability: can we access Cloudflare/dweb.link/Pinata from this environment?
90
- - Network constraints: timeouts sufficient for 280MB + 198MB downloads?
91
-
92
- ### Database Unknowns
93
- - CID format: are placeholder CIDs correct format (bafybei...)?
94
- - Gateway URL: should database store per-gateway URLs or single gateway?
95
- - Download tracking: is recordDownloadStart properly integrated?
96
-
97
- ## EDGE CASES & CORNER CASES
98
-
99
- ### Network Scenarios
100
- - All IPFS gateways unreachable → fallback to HuggingFace
101
- - HuggingFace rate limiting → retry logic sufficient?
102
- - Partial download (connection drop mid-file) → temp file cleanup?
103
- - Network switching during download → resume or restart?
104
- - Firewall blocking IPFS ports → fallback working?
105
-
106
- ### File System Scenarios
107
- - Disk full during download → cleanup and error reporting?
108
- - Permission denied on ~/.gmgui/models → fallback directory?
109
- - Corrupted manifest file → regenerate or error?
110
- - Partial manifest (missing sha256 for some files) → skip validation?
111
- - Concurrent writes to same file → locking mechanism?
112
-
113
- ### Cache Scenarios
114
- - Cache hit but file corrupted → detect and re-download
115
- - Cache hit but wrong version → version check mechanism?
116
- - Stale cache (90+ days old) → serve stale or force refresh?
117
- - Manifest mismatch with actual files → which is source of truth?
118
-
119
- ### IPFS Publishing Scenarios
120
- - Pinata upload timeout (slow upload) → retry with backoff?
121
- - Pinata quota exceeded → alternative publishing method?
122
- - CID changes on re-publish → database migration path?
123
- - Partial upload (some files missing) → validation before CID storage?
124
-
125
- ### Integration Scenarios
126
- - Old webtalk code still called by other modules → identify dependencies
127
- - Config object mismatch between old/new systems → adapter needed?
128
- - Progress event format incompatibility → transform events?
129
- - Multiple conversations triggering download simultaneously → download once, notify all?
130
-
131
- ### Metrics Scenarios
132
- - Metrics file corrupted → reset or recover?
133
- - Metrics file too large (>1GB) → rotation working?
134
- - Concurrent metric writes → locking or append-only safe?
135
- - Metric timestamp drift → clock synchronization issue?
136
-
137
- ## ACCEPTANCE CRITERIA (GATE CONDITIONS)
138
-
139
- ### Implementation Completeness
140
- - downloadWithFallback cycles through all 3 IPFS gateways before HuggingFace fallback
141
- - SHA-256 verification occurs for every downloaded file against manifest
142
- - Size validation (minBytes) occurs before SHA-256 check
143
- - Progress events emitted for each layer attempt
144
- - Metrics recorded for cache hit, each gateway attempt, HuggingFace attempt, all failures
145
- - Temp files (.tmp) cleaned up on failure
146
- - Backup files (.bak) created on corrupted cache detection
147
-
148
- ### Integration Correctness
149
- - model-downloader.js imported in server.js
150
- - ensureModelsDownloaded calls downloadWithFallback for each file in manifest
151
- - Progress broadcasting compatible with existing WebSocket protocol
152
- - Error messages surfaced to UI via existing error broadcast mechanism
153
- - Concurrent download requests handled (single download, multiple waiters)
154
- - No regression in existing model download behavior
155
-
156
- ### Database Accuracy
157
- - Real IPFS CIDs stored in database.js (not placeholders)
158
- - getIpfsCidByModel returns correct CID for whisper-base and tts-models
159
- - Download records created in ipfs_downloads table
160
- - Last accessed timestamp updated on CID retrieval
161
-
162
- ### End-to-End Verification
163
- - Fresh install (empty ~/.gmgui/models) downloads all models successfully
164
- - IPFS layer succeeds (witnessed download from Cloudflare/dweb.link/Pinata gateway)
165
- - HuggingFace fallback works (simulate IPFS failure, verify HF download)
166
- - Cache layer works (second download instant, metrics show cache hit)
167
- - Corrupted cache detected and re-downloaded
168
- - Metrics populated with real download data
169
- - All 4 metrics endpoints return valid data
170
-
171
- ### Performance & Reliability
172
- - 280MB whisper-base downloads in <5 minutes on 10Mbps connection
173
- - 198MB tts-models downloads in <4 minutes on 10Mbps connection
174
- - Gateway failover occurs within 30 seconds of timeout
175
- - No memory leaks during large file downloads
176
- - Progress updates at least every 5 seconds during active download
177
-
178
- ### Code Quality
179
- - No duplicate code between old webtalk and new model-downloader
180
- - All functions under 200 lines
181
- - No hardcoded values (gateways, timeouts, paths configurable)
182
- - Error messages descriptive (include layer, gateway, error type)
183
- - No console.log for normal operations (use debug hooks or proper logging)
184
-
185
- ## REMAINING WORK BREAKDOWN
186
-
187
- ### Waves 2-4 (COMPLETE)
188
- ✓ Code Exploration: webtalk is npm package (external), no local files
189
- ✓ Integration Design: manifest iteration, progress transformation, concurrent handling (existing flag)
190
- ✓ Implementation: Import added, ensureModelsDownloaded rewritten with downloadWithFallback
191
- ✓ Testing: Cache hits (13/13 files, 4ms), missing file re-download (59KB verified), metrics recorded
192
-
193
- ### IPFS Publishing (BLOCKED - No API Keys Available)
194
- ✓ 17. Checked PINATA_API_KEY: NOT SET
195
- ✓ 18. Checked PINATA_SECRET_KEY: NOT SET
196
- ✓ 19. Blocking status documented below
197
- ✗ 20. Cannot obtain real CIDs (BLOCKED on keys)
198
- ✗ 21. Cannot update database.js (BLOCKED on keys)
199
-
200
- **BLOCKING STATUS**: Pinata API keys not available in environment.
201
- **USER ACTION REQUIRED**:
202
- 1. Sign up at https://www.pinata.cloud/
203
- 2. Get API key and secret
204
- 3. Set environment variables:
205
- ```bash
206
- export PINATA_API_KEY=your_jwt_token
207
- export PINATA_SECRET_KEY=your_secret
208
- ```
209
- 4. Run: `node scripts/publish-models-to-ipfs.js`
210
- 5. Update database.js lines 389-390 with real CIDs from output
211
-
212
- ### Verification (VERIFY state - COMPLETE)
213
- ✓ 22. All 13 model files exist with correct sizes (whisper: 7, tts: 6)
214
- ✓ 23. Server integration verified (ensureModelsDownloaded uses downloadWithFallback)
215
- ~ 24. IPFS layer attempted but failed with HTTP 404 (expected - placeholder CIDs)
216
- ✓ 25. Metrics API endpoints functional (1 entry in .metrics.json)
217
- ✓ 26. SHA-256 verification PASSED for all 13 files
218
- ✓ 27. Cache hit mechanism implemented (size check before download)
219
- ~ 28. HuggingFace fallback exists but not tested (would require deleting cache)
220
- ~ 29. Metrics collection working (1 IPFS error recorded)
221
-
222
- ## OPEN QUESTIONS FOR USER
223
-
224
- 1. Pinata API keys: Are PINATA_API_KEY and PINATA_SECRET_KEY available? (blocks real IPFS publishing)
225
- 2. Gateway preference: Should IPFS be preferred over HuggingFace, or configurable?
226
- 3. Old webtalk code: Can we fully replace webtalk/ipfs-downloader, or keep as fallback?
227
- 4. Metrics retention: Is 24-hour metrics retention sufficient, or longer?
228
- 5. Error handling: Should download failure block server startup, or degrade gracefully?
229
-
230
- ## ESTIMATED COMPLETION
231
-
232
- - Code exploration: 30 minutes (7 files to read and trace)
233
- - Integration design: 45 minutes (map files, design flows)
234
- - Implementation: 60 minutes (rewrite ensureModelsDownloaded, test)
235
- - IPFS publishing: 15 minutes (if keys available) or 0 minutes (if blocked)
236
- - Verification: 30 minutes (delete cache, test both layers, check metrics)
237
-
238
- Total: 3 hours (if keys available) or 2.75 hours (if blocked on publishing)
239
-
240
- ## SUCCESS CRITERIA - CURRENT STATUS
241
-
242
- ✓ COMPLETE: Integration implemented (downloadWithFallback in server.js)
243
- ✓ COMPLETE: All model files downloaded and SHA-256 verified
244
- ✓ COMPLETE: Metrics API endpoints functional
245
- ✓ COMPLETE: Manifest exists with correct hashes
246
- ✓ COMPLETE: Concurrent download handling via modelDownloadState lock
247
- ✓ COMPLETE: Progress broadcasting compatible with WebSocket protocol
248
- ✗ BLOCKED: Real IPFS CIDs (requires Pinata API keys)
249
- ✗ PENDING: Full end-to-end test (delete cache, witness HuggingFace fallback)
250
- ✗ PENDING: Git commit and push
251
-
252
- **GATE CONDITION STATUS**: 8/11 criteria met
253
- **BLOCKER**: Pinata API keys not available
254
- **REMAINING**: Git commit + push, optional full integration test