vg-coder-cli 2.0.57 → 2.0.59
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/INTEGRATION.md +26 -0
- package/bugs/bug1.md +140 -51
- package/dist/vg-coder-bundle.js +1 -1
- package/package.json +1 -1
- package/src/server/views/js/features/task-worker.js +4 -2
package/INTEGRATION.md
CHANGED
|
@@ -66,6 +66,32 @@ Mỗi Google account muốn dùng → 1 Chrome profile riêng:
|
|
|
66
66
|
> curl -s http://127.0.0.1:6868/api/workers | jq
|
|
67
67
|
> ```
|
|
68
68
|
|
|
69
|
+
### Deploy AIChat scripts (Firebase RTDB)
|
|
70
|
+
|
|
71
|
+
⚠️ **Quan trọng cho dev sửa code AIChat**: file
|
|
72
|
+
`vetgo-auto/scripts/aistudio.google.com/main.js` (định nghĩa `window.AIChat` —
|
|
73
|
+
core scraping logic: model selection, file upload, send prompt, copy markdown)
|
|
74
|
+
**KHÔNG** bundle vào npm package. Extension fetch script tại runtime từ
|
|
75
|
+
**Firebase Realtime Database** (`vetgo-chrome-default-rtdb`, path
|
|
76
|
+
`ENV/VGCODER`).
|
|
77
|
+
|
|
78
|
+
Hệ quả:
|
|
79
|
+
- Bump `vg-coder-cli` version + `npm publish` **KHÔNG** đẩy code AIChat mới.
|
|
80
|
+
- Phải chạy `cd vetgo-auto && node deploy-scripts.js` để PUT script lên Firebase.
|
|
81
|
+
- Test fix nhanh: deploy Firebase + restart Chromium (extension re-fetch script
|
|
82
|
+
lúc init). Không cần rebuild image / restart container.
|
|
83
|
+
- CI publish workflow (v2.0.58+) đã add step `npm run deploy-scripts` → bump
|
|
84
|
+
version trên git sẽ auto-deploy Firebase.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Deploy local (dev) — sửa main.js xong:
|
|
88
|
+
cd vetgo-auto && node deploy-scripts.js
|
|
89
|
+
# → PUT https://...firebaseio.../ENV/VGCODER.json
|
|
90
|
+
|
|
91
|
+
# Restart chromium ở target server để re-fetch:
|
|
92
|
+
ssh ... "docker exec chrome-mcp-vgcoder supervisorctl restart chromium"
|
|
93
|
+
```
|
|
94
|
+
|
|
69
95
|
## REST API
|
|
70
96
|
|
|
71
97
|
### POST `/api/tasks` — submit task
|
package/bugs/bug1.md
CHANGED
|
@@ -8,32 +8,49 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
## Status: 🟢 RESOLVED (2026-05-10, v2.0.
|
|
11
|
+
## Status: 🟢 RESOLVED (2026-05-10, v2.0.57)
|
|
12
12
|
|
|
13
|
-
**
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
**Real root cause** (xác định cuối cùng sau 5 round debug):
|
|
14
|
+
|
|
15
|
+
`vetgo-auto/scripts/aistudio.google.com/main.js` hardcode
|
|
16
|
+
`VG_DEFAULT_MODEL='gemini-3-flash-preview'`. `task-worker.js:handleTaskExecute`
|
|
17
|
+
gọi `startNewChat()` ở đầu mỗi task → navigate
|
|
18
|
+
`/prompts/new_chat?model=gemini-3-flash-preview` (drop `?model=` của caller pin).
|
|
19
|
+
Task chạy trên Flash bất kể caller request gì.
|
|
20
|
+
|
|
21
|
+
**Bằng chứng** (verified server2 ULTRA, 2026-05-10):
|
|
22
|
+
- Trước v2.0.57: pin `gemini-3.1-pro-preview` → quan sát qua noVNC: tab navigate
|
|
23
|
+
Pro → reload thành Flash → `actualModel: gemini-3-flash-preview`
|
|
24
|
+
- Sau v2.0.57: pin `gemini-3.1-pro-preview` → tab giữ Pro → `actualModel:
|
|
25
|
+
gemini-3.1-pro-preview` ✅
|
|
16
26
|
|
|
17
27
|
**Fix shipped**:
|
|
18
28
|
- v2.0.52: `open-tab` response thêm `requested_model` / `actual_model` /
|
|
19
|
-
`fallback_occurred` (URL-based
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
`fallback_occurred` (URL-based, partial detection)
|
|
30
|
+
- v2.0.53: `task.result.actualModel` — worker scrape DOM `<ms-model-selector>`
|
|
31
|
+
sau task done (detection accurate)
|
|
32
|
+
- v2.0.55: `_pinnedModelByEmail` Map — `_recycleWorkerTab` reopen với pinned
|
|
33
|
+
model (giữ pin qua nhiều task)
|
|
34
|
+
- **v2.0.57: REAL FIX** — `getTargetModel()` đọc model từ URL hiện tại +
|
|
35
|
+
sessionStorage cache, thay tất cả hardcode `VG_DEFAULT_MODEL`. `startNewChat`
|
|
36
|
+
+ `pinPromptModel` không còn override pin của caller.
|
|
37
|
+
|
|
38
|
+
**Client pattern recommend**:
|
|
39
|
+
1. Pin model qua `POST /api/launcher/open-tab` body `{model: "..."}`
|
|
40
|
+
2. Submit task → check `task.result.actualModel === expectedModel`
|
|
41
|
+
3. Nếu khác → AI Studio fallback (account không có access). Decide retry /
|
|
42
|
+
fail-fast / accept tùy use-case.
|
|
29
43
|
|
|
30
44
|
**Code refs**:
|
|
31
|
-
- `vetgo-auto/
|
|
32
|
-
|
|
33
|
-
- `src/server/views/js/features/task-worker.js:
|
|
34
|
-
scrape DOM
|
|
35
|
-
- `src/server/task-queue.js:
|
|
36
|
-
|
|
45
|
+
- `vetgo-auto/scripts/aistudio.google.com/main.js:20-37` — `getTargetModel()`
|
|
46
|
+
(real fix — primary)
|
|
47
|
+
- `src/server/views/js/features/task-worker.js:210-236` — `readActualModel()`
|
|
48
|
+
scrape DOM (verification layer)
|
|
49
|
+
- `src/server/task-queue.js:42-44, 491-494` — `_pinnedModelByEmail` persist
|
|
50
|
+
qua recycle (secondary fix)
|
|
51
|
+
- `vetgo-auto/chrome/src/launcher.ts` — open-tab handler URL-based detection
|
|
52
|
+
(legacy — không reliable với AI Studio versions mới)
|
|
53
|
+
- `INTEGRATION.md "Verify model thực"` — client docs với recommend pattern
|
|
37
54
|
|
|
38
55
|
---
|
|
39
56
|
|
|
@@ -371,34 +388,106 @@ For the AI agent fixing this bug:
|
|
|
371
388
|
|
|
372
389
|
---
|
|
373
390
|
|
|
374
|
-
##
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
- `
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
391
|
+
## Debug timeline (2026-05-10)
|
|
392
|
+
|
|
393
|
+
Bug fix mất 5 round vì đoán sai root cause vài lần. Lưu lại để tránh lặp:
|
|
394
|
+
|
|
395
|
+
### Round 1 (v2.0.52) — URL-based detection ❌
|
|
396
|
+
Hypothesis: AI Studio redirect URL khi fallback. Add `requested_model` /
|
|
397
|
+
`actual_model` từ URL ở open-tab response.
|
|
398
|
+
**Sai vì**: AI Studio versions hiện tại **không** redirect URL (từng làm trong
|
|
399
|
+
quá khứ?). URL giữ nguyên dù fallback.
|
|
400
|
+
|
|
401
|
+
### Round 2 (v2.0.53) — DOM scrape sau task ✅ partial
|
|
402
|
+
Worker `readActualModel()` scrape `<ms-model-selector>` sau task done. Verified
|
|
403
|
+
work với account free tier (request fake model → DOM trả model thực).
|
|
404
|
+
|
|
405
|
+
### Round 3 — Test với account ULTRA, vẫn Flash
|
|
406
|
+
Hypothesis: pin model bị mất sau `_recycleWorkerTab` (close+reopen với default).
|
|
407
|
+
v2.0.55 add `_pinnedModelByEmail` Map.
|
|
408
|
+
**Đúng 1 phần**: pin persist qua recycle. Nhưng test vẫn Flash.
|
|
409
|
+
|
|
410
|
+
### Round 4 — Hypothesis "AI Studio strip ?model="
|
|
411
|
+
Quan sát: URL during task = `/prompts/new_chat` (no query). Đoán AI Studio
|
|
412
|
+
auto-clean URL sau prompt submit.
|
|
413
|
+
**Sai vì**: chính code vg-coder navigate URL (không phải AI Studio).
|
|
414
|
+
|
|
415
|
+
### Round 5 (v2.0.57) — REAL ROOT CAUSE ✅
|
|
416
|
+
User quan sát qua noVNC: tab navigate đúng Pro → reload thành Flash trước khi
|
|
417
|
+
chat. Grep code → tìm thấy `vetgo-auto/scripts/aistudio.google.com/main.js`
|
|
418
|
+
hardcode `VG_DEFAULT_MODEL='gemini-3-flash-preview'`. `startNewChat()` ở đầu
|
|
419
|
+
mỗi task navigate `/prompts/new_chat?model=Flash` → override pin caller.
|
|
420
|
+
Fix: `getTargetModel()` dynamic từ URL + sessionStorage. **Verified work.**
|
|
421
|
+
|
|
422
|
+
### Round 6 — CI miss step (real-real fix)
|
|
423
|
+
|
|
424
|
+
Sau v2.0.57 deployed, test server3 vẫn fail. Verify bundle trên server:
|
|
425
|
+
- `grep getTargetModel /usr/local/lib/node_modules/vg-coder-cli/dist/vg-coder-bundle.js` → 0 match
|
|
426
|
+
- v2.0.57 publish thành công nhưng code mới **không có** trong bundle
|
|
427
|
+
|
|
428
|
+
**Cause**: `vetgo-auto/scripts/aistudio.google.com/main.js` deploy qua Firebase
|
|
429
|
+
RTDB (`ENV/VGCODER`), KHÔNG bundle vào npm package. Extension fetch script tại
|
|
430
|
+
runtime từ Firebase. CI `publish.yml` chỉ chạy `build:extension` + `build:copy`
|
|
431
|
+
+ `build:inject` — bỏ qua `deploy-scripts`. Phải chạy thủ công
|
|
432
|
+
`cd vetgo-auto && node deploy-scripts.js` từ máy local để push code mới.
|
|
433
|
+
|
|
434
|
+
**Fix CI**: add `npm run deploy-scripts` step vào `publish.yml` (commit
|
|
435
|
+
83186ba). Lần sau bump version → CI tự push Firebase.
|
|
436
|
+
|
|
437
|
+
### Round 7 — File upload race (server4 Windows-specific)
|
|
438
|
+
|
|
439
|
+
Sau bug1 fix work cả 3 server cho text-only task, test multimodal:
|
|
440
|
+
- server2/3 (Linux native): image + PDF Pro work ✅
|
|
441
|
+
- server4 (Docker Desktop Windows): cả image + PDF → model trả "chưa upload
|
|
442
|
+
file" mặc dù chip hiển thị file đã attach trong UI.
|
|
443
|
+
|
|
444
|
+
User screenshot 2 lần show:
|
|
445
|
+
1. Chip "feline-xray-chest7.jpg Loading..." — file đang upload
|
|
446
|
+
2. Chip "feline-xray-chest7.jpg 1,101 tokens" — upload xong, nhưng textarea
|
|
447
|
+
vẫn trống, worker chưa paste prompt
|
|
448
|
+
|
|
449
|
+
DOM inspect tìm thấy chip element là `<ms-prompt-media>` /
|
|
450
|
+
`[data-test-id="prompt-media-container"]` — KHÔNG match selector cũ
|
|
451
|
+
`ms-prompt-chip-file, ms-file-chip, ms-attachment-chip`. Wait loop pass với
|
|
452
|
+
`chips=0`, fall through 30s timeout → submit Run trước khi tokenize xong → AI
|
|
453
|
+
Studio drop file silent.
|
|
454
|
+
|
|
455
|
+
**Cause cụ thể**: 2 vấn đề chồng nhau:
|
|
456
|
+
1. Selector outdated (AI Studio đã rename element 2026)
|
|
457
|
+
2. Không có check token-count finalize (chip hiện ngay sau drop, tokenize 5-15s
|
|
458
|
+
sau đặc biệt trên Windows fs latency)
|
|
459
|
+
|
|
460
|
+
**Fix v2.0.58**:
|
|
461
|
+
- Update CHIP_SELECTORS thêm `ms-prompt-media`, `[data-test-id="prompt-media-container"]`
|
|
462
|
+
- Add wait loop: chip text phải match `/[\d,]+ tokens/` (support comma) VÀ
|
|
463
|
+
KHÔNG có `Calculating|Processing|Uploading|Loading`
|
|
464
|
+
- Timeout 60s → proceed anyway
|
|
465
|
+
|
|
466
|
+
**Result**: server4 image task 105s → 23s sau fix selector + regex chuẩn. Cả 3
|
|
467
|
+
server multimodal Pro work end-to-end.
|
|
468
|
+
|
|
469
|
+
### Lesson learned
|
|
470
|
+
|
|
471
|
+
- **Quan sát visual (noVNC) > eval DOM async**: User report "tab reload trước
|
|
472
|
+
khi chat" + screenshot chip "Loading..." → "1,101 tokens" textarea trống là
|
|
473
|
+
clue quyết định. Eval DOM tại các thời điểm khác nhau cho data rời rạc khó
|
|
474
|
+
ráp — visual real-time mới thấy state transitions.
|
|
475
|
+
- **Grep hardcode constant trước khi đoán external behavior**: 4 round đầu đoán
|
|
476
|
+
AI Studio làm gì đó (redirect, strip query). Round 5 tìm thấy hardcode
|
|
477
|
+
`VG_DEFAULT_MODEL` trong chính code mình.
|
|
478
|
+
- **Verify deploy artifact trên target server**: Round 6 chỉ ra version bump
|
|
479
|
+
KHÔNG đảm bảo code mới chạy nếu deploy pipeline có gap. Sau mỗi fix, grep
|
|
480
|
+
symbol mới trong file production thực — không tin "CI passed = code chạy".
|
|
481
|
+
- **Selector update qua thời gian (round 7)**: AI Studio Angular rename
|
|
482
|
+
tag/class qua mỗi version. Match cả new + legacy selector trong array. Khi
|
|
483
|
+
wait loop pass với count=0 (warning ignored) → có thể selector đã chết.
|
|
484
|
+
- **Multi-issue stacking**: Round 7 có 2 cause chồng nhau (selector outdated
|
|
485
|
+
AND tokenize race). Fix 1 cause không đủ — verify fully E2E sau mỗi fix.
|
|
486
|
+
- **Multiple layer detection có giá trị**: `actualModel` (DOM scrape) là
|
|
487
|
+
source-of-truth đúng đắn ngay từ v2.0.53 — confirm bug có thật, định nghĩa
|
|
488
|
+
expected behavior cho fix, không phụ thuộc fix nào fail.
|
|
489
|
+
- **Firebase deploy không đồng bộ với npm publish**: code AIChat ở
|
|
490
|
+
`vetgo-auto/scripts/aistudio.google.com/*.js` deploy qua Firebase RTDB
|
|
491
|
+
riêng. Bump npm package version KHÔNG đẩy code này (trước v2.0.58 CI fix).
|
|
492
|
+
Test fix nhanh: `cd vetgo-auto && node deploy-scripts.js` + restart Chromium
|
|
493
|
+
— KHÔNG cần rebuild image hay update package.
|