visionA/local-agent
jim800121chen d0ab479a7f fix(local-agent): 影片上傳後推論卡「等待第一筆結果」— WS join 才開播 + late-join replay
時序競態:UploadVideo 回 200 即刻 pipeline.Start() 廣播推論結果,但瀏覽器
200 後才連結果 WS。WP-4 上傳改 localhost 直連(極快)、結果 WS 仍走慢 tunnel
→ 窗口放大;Hub 對無 client 的 room 廣播靜默丟棄 → 早期結果全丟、第一筆永遠等不到。

修法(A2 主修 + B 保險,結果面維持走 tunnel、不動 ADR-019 混合路徑):
- A2:UploadVideo 存檔即回 200,但 pipeline 建好不 Start;背景 gated-start
  等 WS join inference:<serial> room 後才 Start;15s 逾時降級照舊開跑(不永久卡)
- B:inference room 緩存最近 30 筆,client join 時先 replay 再收 live
  (順帶修 image 模式晚連 WS 丟結果的同類 bug)
- CameraHandler 加 startMu:gated goroutine 的 check-then-act(二次檢查 startCtx
  → Start)與 stop 的 cancel+Stop 原子化,消滅「stop 後 gated 又 Start 舊 pipeline」race

reviewer 通過(Major-1 修復複審 )。14 test -race 全過(含 3000 輪併發 atomicity
測試)、gosec 改的檔 0 新 finding。serial room key 兩端同形已查證排除。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-02 03:16:05 +08:00
..

visionA Agent

Phase 0 雛形 — 正在建置中

此專案於 2026-04-22 從 local-tool/ forkbaseline commitb71ff4cd3c72e879435f773ae15b23bf8b70841e

fork 後獨立演進,不主動與 local-tool 同步。 需要時手動 cherry-pick bug fix。

產品定位

visionA Agent 是 visionA 雲端版的 local 端代理程式:

它是什麼

  • 一個完整的 local server沿用 local-tool 的 KneronPLUS / camera / inference / device / model / Python runtime / ffmpeg 邏輯)
  • 加上 tunnel client,把自己 reverse-tunnel 到雲端 visionA-backend,讓雲端 web UI 可以透過 tunnel 操作使用者桌機上的 Kneron 裝置
  • 加上 3 頁極簡配置 UI(狀態 / 配對 / 設定給使用者看「Agent 是否在線」和「配對雲端帳號」用

它不是什麼

  • 不是 local-tool 的修改版local-tool 不動visionA Agent fork 後獨立演進)
  • 不保留 local-tool 原本的裝置 / 模型 / 推論 UI這些由雲端 web UI 負責;本機 UI 只管配對/設定)

目前進度Phase 0 雛形)

任務 狀態 說明
AB1 fork + 改名visiona-local → visiona-agent / bundle ID / Makefile 變數 78 處替換)
AB2+AB3 裁剪 Wails 業務 UI binding、刪除舊資料目錄遷移新增 pairing / connection / settings 的 stub binding回 ErrNotImplemented為 AB4-AB10 預留擴點
AB4 複製 tunnel client從 POCinternal/tunnel/
AB5 Agent config (YAML) 讀寫
AB6 Internal HTTP serverwrapper 綁 127.0.0.1:0
AB7 Pairing Exchanger呼叫雲端 /api/pairing/exchange
AB8 connstate broadcaster + Wails event 推送
AB9 autostart 三平台實作
AB10 logexport壓縮最近 7 天 log
AB11-12 Wails 整合 + 整合測試

架構圖(簡版)

[ Browser ] ── HTTPS ──► [ visionA-backend ]
                                │ (內部 HTTP forward
                                ▼
                         [ remote-proxy ]
                                │ WSS + yamux 出站長連線)
                                ▼
┌───────────────────────────────────────────────────────┐
│  visionA Agent使用者桌機Wails app                │
│                                                       │
│   [Tunnel client]            [3 頁配置 UI]             │
│         │                         │ Wails bindings    │
│         ▼                         ▼                   │
│   [Internal HTTP server 127.0.0.1:<random port>]      │
│   (沿用 local-tool 的 Gin handler裝置/模型/推論/... │
│                         │                             │
│                         ▼                             │
│   [Python runtime + KneronPLUS SDK + ffmpeg]          │
└───────────────────────────────────────────────────────┘
                                │
                                ▼
                       Kneron USB 裝置

文件

fork baseline

本專案於 2026-04-22 從 local-tool/commit b71ff4cd3c72e879435f773ae15b23bf8b70841e)一次性 fork 後獨立演進,不主動 syncADR-007

local-tool 原始 README 已封存於 docs/legacy-local-tool-readme.md,僅作 cherry-pick bug fix 時的歷史對照,不再代表 visionA Agent 的產品定位。

開發指令

# 下載第三方依賴到 vendor/
make vendor-sync

# 本機 build + 產出 macOS DMG
make dmg

# 列出所有 targets
make help

主要 targets沿用 local-tool 結構,但所有產物名稱已替換為 visiona-agent

Target 作用
vendor-sync 下載 python-build-standalone / wheels / ffmpeg
build-frontend pnpm build Next.js 靜態產物 → frontend/out/
wails-sync-frontend 同步 frontend/out/visiona-agent/frontend/Wails embed
wails-macos / wails-windows / wails-linux Wails build + ad-hoc codesignmacOS
dmg 產出 dist/visiona-agent.dmg(缺 create-dmg 時 fallback hdiutil
exe Inno Setup → dist/visiona-agent-*-windows-x64.exe(需 Windows runner
appimage dist/visiona-agent-*-x86_64.AppImage(需 Linux runner
dev-agent Wails dev mode
test-tunnel tunnel client 整合測試

三平台 build 細節與 local-tool 共存對照表:docs/BUILD-VERIFICATION.md