agentgui 1.0.318 → 1.0.319
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/.prd +267 -0
- package/package.json +2 -1
package/.prd
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
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 (Depends on Wave 1)
|
|
48
|
+
4. Obtain Pinata API keys (if available) OR document blocking status
|
|
49
|
+
- Blocked by: Wave 1 item 3 (dry-run test)
|
|
50
|
+
- Blocks: Real IPFS publishing
|
|
51
|
+
|
|
52
|
+
5. Design server.js integration strategy
|
|
53
|
+
- Blocked by: Wave 1 item 1 (implementation verification)
|
|
54
|
+
- Blocks: Actual integration
|
|
55
|
+
|
|
56
|
+
### Wave 3 (Depends on Wave 2)
|
|
57
|
+
6. Execute publish-models-to-ipfs.js to get real CIDs (if keys available)
|
|
58
|
+
- Blocked by: Wave 2 item 4 (API keys)
|
|
59
|
+
- Blocks: Database CID update
|
|
60
|
+
|
|
61
|
+
7. Add model-downloader import to server.js
|
|
62
|
+
- Blocked by: Wave 2 item 5 (integration strategy)
|
|
63
|
+
- Blocks: Integration implementation
|
|
64
|
+
|
|
65
|
+
### Wave 4 (Depends on Wave 3)
|
|
66
|
+
8. Update database.js with real IPFS CIDs
|
|
67
|
+
- Blocked by: Wave 3 item 6 (real CIDs obtained)
|
|
68
|
+
- Blocks: IPFS layer activation
|
|
69
|
+
|
|
70
|
+
9. Replace ensureModelsDownloaded implementation
|
|
71
|
+
- Blocked by: Wave 3 item 7 (import added)
|
|
72
|
+
- Blocks: End-to-end testing
|
|
73
|
+
|
|
74
|
+
### Wave 5 (Depends on Wave 4, final verification)
|
|
75
|
+
10. Test fallback chain with fresh cache (delete ~/.gmgui/models, verify IPFS layer 1)
|
|
76
|
+
- Blocked by: Wave 4 items 8, 9
|
|
77
|
+
- Blocks: Nothing (end-to-end test)
|
|
78
|
+
|
|
79
|
+
11. Test fallback to HuggingFace (simulate IPFS failure)
|
|
80
|
+
- Blocked by: Wave 4 items 8, 9
|
|
81
|
+
- Blocks: Nothing (end-to-end test)
|
|
82
|
+
|
|
83
|
+
12. Verify metrics collection after real downloads
|
|
84
|
+
- Blocked by: Wave 4 items 8, 9
|
|
85
|
+
- Blocks: Nothing (validation)
|
|
86
|
+
|
|
87
|
+
## UNKNOWNS TO RESOLVE
|
|
88
|
+
|
|
89
|
+
### Code Implementation Unknowns (Wave 1 RESOLVED)
|
|
90
|
+
✓ downloadWithFallback IPFS gateway list: YES - cycles all 4 gateways (Cloudflare, dweb.link, Pinata, ipfs.io) × 2 retries = 8 attempts
|
|
91
|
+
✓ downloadWithFallback error handling: YES - properly catches and continues on gateway failure
|
|
92
|
+
✓ downloadWithFallback progress reporting: YES - onProgress receives correct status for each layer
|
|
93
|
+
✓ Manifest integration: YES - downloadWithFallback correctly validates against manifest SHA-256
|
|
94
|
+
✓ File path construction: Direct iteration over manifest.files object, each key is relative path
|
|
95
|
+
|
|
96
|
+
### Integration Unknowns (Wave 2 IN PROGRESS)
|
|
97
|
+
- Current ensureModelsDownloaded flow: what does webtalk/ipfs-downloader.ensureModels do? (TO INVESTIGATE)
|
|
98
|
+
- Backward compatibility: can we replace ensureModels without breaking existing installs? (TO INVESTIGATE)
|
|
99
|
+
- Progress broadcasting: how to integrate downloadWithFallback progress with broadcastModelProgress? (TO DESIGN)
|
|
100
|
+
- Error handling: what happens if all 3 layers fail? (TO DESIGN - already throws error, need UI integration)
|
|
101
|
+
- Concurrent download handling: does model-downloader handle multiple simultaneous downloads? (TO INVESTIGATE)
|
|
102
|
+
|
|
103
|
+
### Environment Unknowns
|
|
104
|
+
- Pinata API keys: are they available? (blocks real IPFS publishing)
|
|
105
|
+
- IPFS gateway reachability: can we access Cloudflare/dweb.link/Pinata from this environment?
|
|
106
|
+
- Network constraints: timeouts sufficient for 280MB + 198MB downloads?
|
|
107
|
+
|
|
108
|
+
### Database Unknowns
|
|
109
|
+
- CID format: are placeholder CIDs correct format (bafybei...)?
|
|
110
|
+
- Gateway URL: should database store per-gateway URLs or single gateway?
|
|
111
|
+
- Download tracking: is recordDownloadStart properly integrated?
|
|
112
|
+
|
|
113
|
+
## EDGE CASES & CORNER CASES
|
|
114
|
+
|
|
115
|
+
### Network Scenarios
|
|
116
|
+
- All IPFS gateways unreachable → fallback to HuggingFace
|
|
117
|
+
- HuggingFace rate limiting → retry logic sufficient?
|
|
118
|
+
- Partial download (connection drop mid-file) → temp file cleanup?
|
|
119
|
+
- Network switching during download → resume or restart?
|
|
120
|
+
- Firewall blocking IPFS ports → fallback working?
|
|
121
|
+
|
|
122
|
+
### File System Scenarios
|
|
123
|
+
- Disk full during download → cleanup and error reporting?
|
|
124
|
+
- Permission denied on ~/.gmgui/models → fallback directory?
|
|
125
|
+
- Corrupted manifest file → regenerate or error?
|
|
126
|
+
- Partial manifest (missing sha256 for some files) → skip validation?
|
|
127
|
+
- Concurrent writes to same file → locking mechanism?
|
|
128
|
+
|
|
129
|
+
### Cache Scenarios
|
|
130
|
+
- Cache hit but file corrupted → detect and re-download
|
|
131
|
+
- Cache hit but wrong version → version check mechanism?
|
|
132
|
+
- Stale cache (90+ days old) → serve stale or force refresh?
|
|
133
|
+
- Manifest mismatch with actual files → which is source of truth?
|
|
134
|
+
|
|
135
|
+
### IPFS Publishing Scenarios
|
|
136
|
+
- Pinata upload timeout (slow upload) → retry with backoff?
|
|
137
|
+
- Pinata quota exceeded → alternative publishing method?
|
|
138
|
+
- CID changes on re-publish → database migration path?
|
|
139
|
+
- Partial upload (some files missing) → validation before CID storage?
|
|
140
|
+
|
|
141
|
+
### Integration Scenarios
|
|
142
|
+
- Old webtalk code still called by other modules → identify dependencies
|
|
143
|
+
- Config object mismatch between old/new systems → adapter needed?
|
|
144
|
+
- Progress event format incompatibility → transform events?
|
|
145
|
+
- Multiple conversations triggering download simultaneously → download once, notify all?
|
|
146
|
+
|
|
147
|
+
### Metrics Scenarios
|
|
148
|
+
- Metrics file corrupted → reset or recover?
|
|
149
|
+
- Metrics file too large (>1GB) → rotation working?
|
|
150
|
+
- Concurrent metric writes → locking or append-only safe?
|
|
151
|
+
- Metric timestamp drift → clock synchronization issue?
|
|
152
|
+
|
|
153
|
+
## ACCEPTANCE CRITERIA (GATE CONDITIONS)
|
|
154
|
+
|
|
155
|
+
### Implementation Completeness
|
|
156
|
+
- downloadWithFallback cycles through all 3 IPFS gateways before HuggingFace fallback
|
|
157
|
+
- SHA-256 verification occurs for every downloaded file against manifest
|
|
158
|
+
- Size validation (minBytes) occurs before SHA-256 check
|
|
159
|
+
- Progress events emitted for each layer attempt
|
|
160
|
+
- Metrics recorded for cache hit, each gateway attempt, HuggingFace attempt, all failures
|
|
161
|
+
- Temp files (.tmp) cleaned up on failure
|
|
162
|
+
- Backup files (.bak) created on corrupted cache detection
|
|
163
|
+
|
|
164
|
+
### Integration Correctness
|
|
165
|
+
- model-downloader.js imported in server.js
|
|
166
|
+
- ensureModelsDownloaded calls downloadWithFallback for each file in manifest
|
|
167
|
+
- Progress broadcasting compatible with existing WebSocket protocol
|
|
168
|
+
- Error messages surfaced to UI via existing error broadcast mechanism
|
|
169
|
+
- Concurrent download requests handled (single download, multiple waiters)
|
|
170
|
+
- No regression in existing model download behavior
|
|
171
|
+
|
|
172
|
+
### Database Accuracy
|
|
173
|
+
- Real IPFS CIDs stored in database.js (not placeholders)
|
|
174
|
+
- getIpfsCidByModel returns correct CID for whisper-base and tts-models
|
|
175
|
+
- Download records created in ipfs_downloads table
|
|
176
|
+
- Last accessed timestamp updated on CID retrieval
|
|
177
|
+
|
|
178
|
+
### End-to-End Verification
|
|
179
|
+
- Fresh install (empty ~/.gmgui/models) downloads all models successfully
|
|
180
|
+
- IPFS layer succeeds (witnessed download from Cloudflare/dweb.link/Pinata gateway)
|
|
181
|
+
- HuggingFace fallback works (simulate IPFS failure, verify HF download)
|
|
182
|
+
- Cache layer works (second download instant, metrics show cache hit)
|
|
183
|
+
- Corrupted cache detected and re-downloaded
|
|
184
|
+
- Metrics populated with real download data
|
|
185
|
+
- All 4 metrics endpoints return valid data
|
|
186
|
+
|
|
187
|
+
### Performance & Reliability
|
|
188
|
+
- 280MB whisper-base downloads in <5 minutes on 10Mbps connection
|
|
189
|
+
- 198MB tts-models downloads in <4 minutes on 10Mbps connection
|
|
190
|
+
- Gateway failover occurs within 30 seconds of timeout
|
|
191
|
+
- No memory leaks during large file downloads
|
|
192
|
+
- Progress updates at least every 5 seconds during active download
|
|
193
|
+
|
|
194
|
+
### Code Quality
|
|
195
|
+
- No duplicate code between old webtalk and new model-downloader
|
|
196
|
+
- All functions under 200 lines
|
|
197
|
+
- No hardcoded values (gateways, timeouts, paths configurable)
|
|
198
|
+
- Error messages descriptive (include layer, gateway, error type)
|
|
199
|
+
- No console.log for normal operations (use debug hooks or proper logging)
|
|
200
|
+
|
|
201
|
+
## REMAINING WORK BREAKDOWN
|
|
202
|
+
|
|
203
|
+
### Code Exploration (EXECUTE state, plugin:gm:dev) - Wave 2
|
|
204
|
+
4. Read webtalk/ipfs-downloader.js ensureModels to understand replacement
|
|
205
|
+
5. Read webtalk/whisper-models.js to understand file structure
|
|
206
|
+
6. Read webtalk/tts-models.js to understand file structure
|
|
207
|
+
7. Trace broadcastModelProgress usage in server.js
|
|
208
|
+
|
|
209
|
+
### Integration Design (EXECUTE state, plugin:gm:dev)
|
|
210
|
+
8. Map manifest files to downloadWithFallback calls
|
|
211
|
+
9. Design progress event transformation (downloadWithFallback → broadcastModelProgress)
|
|
212
|
+
10. Design error handling flow (all layers fail → user notification)
|
|
213
|
+
11. Design concurrent request handling (lock/queue mechanism)
|
|
214
|
+
12. Design backward compatibility (keep webtalk as fallback?)
|
|
215
|
+
|
|
216
|
+
### Implementation (EMIT state, after all unknowns resolved)
|
|
217
|
+
13. Add import statement for downloadWithFallback, getMetrics, etc.
|
|
218
|
+
14. Rewrite ensureModelsDownloaded function body
|
|
219
|
+
15. Test new implementation with existing cache
|
|
220
|
+
16. Delete old webtalk calls if confirmed unused elsewhere
|
|
221
|
+
|
|
222
|
+
### IPFS Publishing (EXECUTE state, conditional on API keys)
|
|
223
|
+
17. Check for PINATA_API_KEY environment variable
|
|
224
|
+
18. If keys available: execute scripts/publish-models-to-ipfs.js
|
|
225
|
+
19. If keys unavailable: document blocking status for user
|
|
226
|
+
20. Capture real CIDs from script output
|
|
227
|
+
21. Update database.js lines 389-390 with real CIDs
|
|
228
|
+
|
|
229
|
+
### Verification (VERIFY state, real execution)
|
|
230
|
+
22. Delete ~/.gmgui/models directory
|
|
231
|
+
23. Start server, trigger model download
|
|
232
|
+
24. Witness IPFS gateway download (check logs for gateway URLs)
|
|
233
|
+
25. Check metrics via GET /api/metrics/downloads
|
|
234
|
+
26. Verify all files present with correct SHA-256
|
|
235
|
+
27. Restart server, verify instant cache hit
|
|
236
|
+
28. Simulate IPFS failure (block gateway URLs), verify HuggingFace fallback
|
|
237
|
+
29. Check metrics show both IPFS and HuggingFace attempts
|
|
238
|
+
|
|
239
|
+
## OPEN QUESTIONS FOR USER
|
|
240
|
+
|
|
241
|
+
1. Pinata API keys: Are PINATA_API_KEY and PINATA_SECRET_KEY available? (blocks real IPFS publishing)
|
|
242
|
+
2. Gateway preference: Should IPFS be preferred over HuggingFace, or configurable?
|
|
243
|
+
3. Old webtalk code: Can we fully replace webtalk/ipfs-downloader, or keep as fallback?
|
|
244
|
+
4. Metrics retention: Is 24-hour metrics retention sufficient, or longer?
|
|
245
|
+
5. Error handling: Should download failure block server startup, or degrade gracefully?
|
|
246
|
+
|
|
247
|
+
## ESTIMATED COMPLETION
|
|
248
|
+
|
|
249
|
+
- Code exploration: 30 minutes (7 files to read and trace)
|
|
250
|
+
- Integration design: 45 minutes (map files, design flows)
|
|
251
|
+
- Implementation: 60 minutes (rewrite ensureModelsDownloaded, test)
|
|
252
|
+
- IPFS publishing: 15 minutes (if keys available) or 0 minutes (if blocked)
|
|
253
|
+
- Verification: 30 minutes (delete cache, test both layers, check metrics)
|
|
254
|
+
|
|
255
|
+
Total: 3 hours (if keys available) or 2.75 hours (if blocked on publishing)
|
|
256
|
+
|
|
257
|
+
## SUCCESS CRITERIA
|
|
258
|
+
|
|
259
|
+
Work is complete when:
|
|
260
|
+
- All 26 items above marked done (3 Wave 1 items removed as complete)
|
|
261
|
+
- Fresh ~/.gmgui/models download succeeds via IPFS layer 1
|
|
262
|
+
- Corrupted cache triggers re-download
|
|
263
|
+
- HuggingFace fallback proven working (simulated IPFS failure)
|
|
264
|
+
- Metrics show real download data for both layers
|
|
265
|
+
- No regressions in existing functionality
|
|
266
|
+
- Real IPFS CIDs in database (if keys available) OR documented blocking status
|
|
267
|
+
- User can verify system working via metrics endpoints
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentgui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.319",
|
|
4
4
|
"description": "Multi-agent ACP client with real-time communication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "server.js",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"better-sqlite3": "^12.6.2",
|
|
27
27
|
"busboy": "^1.6.0",
|
|
28
28
|
"express": "^5.2.1",
|
|
29
|
+
"form-data": "^4.0.5",
|
|
29
30
|
"fsbrowse": "^0.2.18",
|
|
30
31
|
"google-auth-library": "^10.5.0",
|
|
31
32
|
"onnxruntime-node": "^1.24.1",
|