jim800121chen 3f0175f1a9 feat(local-agent): Phase 0.5 visionA Agent — Wails 桌面 + tunnel client + 配對 UI
從 local-tool 複製出獨立的「visionA Agent」桌面應用(A3 純橋樑:
tunnel client + 配對 UI + 設定,不開 HTTP port、不做本機裝置/推論 UI)。
Bundle ID 與 local-tool 不同(com.innovedus.visiona-agent vs visiona-local),
雙 app 可共存。fork 後不主動 sync,需要時手動 cherry-pick。

Backend / Wails Go(AB1-AB13):
- internal/tunnel:6 狀態機(Idle/Connecting/Connected/Reconnecting/Failed/Stopped)
  + Pair/Unpair/Reconnect/Disconnect binding + ClientHooks event
- internal/auth:encrypted file token store(AES-GCM + scrypt + machineID
  fallback salt + 13 tests)
- internal/config:YAML validation + atomic write + 11 tests
- internal/log:ring buffer + ExportLog 升級 zip
- visionA-backend /api/pairing/exchange:SessionTokenStore + 17 new tests
- 三平台 build 驗證(macOS DMG 160 MB / Windows EXE / Linux AppImage)
- end-to-end 5 milestone 全綠(pairing → tunnel → forward → reuse 防護
  → tunnel drop failover)

Frontend / Next.js(AF1-AF7,沿用 visionA-frontend 基礎):
- AppShell + Header + TabNav(StatusView / PairView / SettingsView 三 tab)
- ConnectionStatusBadge 5 種狀態
- TokenInput regex 驗證 + 7 種錯誤 + 0.5s auto-switch 到狀態頁
- 設定頁 4 區塊(含重新配對 AlertDialog)
- agent-api.ts 封裝 Wails bindings(mock/real 雙實作)+ 90 tests

Phase 0.7 review-driven fix(Round 2):
- A1 Session fixation 防護(RotateSessionID)
- A3 mock pairing 預設改 false(必須明確 opt-in)+ startup log
- A4 Pair 失敗後 state 清理矩陣(exchange/Save/Start fail 各自終態)
- A5 Pair/Unpair/Reconnect lifecycleMu + 50 goroutine race test
- F1 重新配對次按鈕 / F2 PairView Esc cancel / F3 Wails BrowserOpenURL
  / F4 Settings draft 持久 + 未儲存 badge

驗證:agent backend go test -race -count=3 ./... 4 packages 全綠 /
agent frontend pnpm test 119 tests 全綠

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 11:22:01 +08:00

259 lines
8.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:
env:
GO_VERSION: '1.26'
NODE_VERSION: '22'
PNPM_VERSION: '9'
jobs:
# ────────────────────────────────────────────────────────────────
# macOS (Intel / x86_64)
# 使用 macos-13目前最後的 Intel Mac runner避免 macos-latest 被
# 切到 Apple Silicon 後產出 ARM binary。
# ────────────────────────────────────────────────────────────────
build-macos:
name: Build macOS (x86_64)
runs-on: macos-13
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install Wails CLI
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
echo "$HOME/go/bin" >> "$GITHUB_PATH"
- name: Cache vendor/
uses: actions/cache@v4
with:
path: vendor/
key: vendor-darwin-${{ hashFiles('Makefile') }}-${{ hashFiles('visiona-agent/wheels/macos/**') }}
restore-keys: |
vendor-darwin-${{ hashFiles('Makefile') }}-
vendor-darwin-
- name: vendor-sync (macOS deps)
run: make vendor-sync
- name: Build .dmg
run: make dmg
- name: Verify .dmg
run: |
ls -lh dist/visiona-agent.dmg
file dist/visiona-agent.dmg
hdiutil imageinfo dist/visiona-agent.dmg | head -20
- name: Upload .dmg artifact
uses: actions/upload-artifact@v4
with:
name: visiona-agent-macos-x64
path: dist/visiona-agent.dmg
retention-days: 30
if-no-files-found: error
# ────────────────────────────────────────────────────────────────
# Windows (x86_64)
# 使用 windows-2022。vendor-sync 的 macOS/Linux 部分會失敗,
# 因此只跑 *-windows 的 vendor targets。
# ────────────────────────────────────────────────────────────────
build-windows:
name: Build Windows (x86_64)
runs-on: windows-2022
timeout-minutes: 60
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install Wails CLI
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Install Inno Setup
run: choco install innosetup -y --no-progress
shell: pwsh
- name: Add Inno Setup to PATH
run: echo "/c/Program Files (x86)/Inno Setup 6" >> "$GITHUB_PATH"
- name: Cache vendor/
uses: actions/cache@v4
with:
path: vendor/
key: vendor-windows-${{ hashFiles('Makefile') }}-${{ hashFiles('visiona-agent/wheels/windows/**') }}
restore-keys: |
vendor-windows-${{ hashFiles('Makefile') }}-
vendor-windows-
- name: vendor-sync (Windows-only deps)
run: |
make vendor-python-windows \
vendor-wheels-windows \
vendor-ffmpeg-windows
- name: Build server.exe
env:
GOOS: windows
GOARCH: amd64
run: |
mkdir -p payload/windows/bin
cd server
go build -o ../payload/windows/bin/visiona-agent-server.exe .
ls -lh ../payload/windows/bin/visiona-agent-server.exe
- name: Build frontend (for go:embed)
run: make build-embed
- name: Build .exe installer
run: make exe
- name: Verify .exe
run: |
ls -lh dist/visiona-agent-*.exe || ls -lh dist/*.exe
file dist/visiona-agent-*.exe 2>/dev/null || true
- name: Upload .exe artifact
uses: actions/upload-artifact@v4
with:
name: visiona-agent-windows-x64
path: dist/visiona-agent-*.exe
retention-days: 30
if-no-files-found: error
# ────────────────────────────────────────────────────────────────
# Linux (x86_64)
# 使用 ubuntu-22.04glibc 2.35,相容性比 24.04 更好)。
# ────────────────────────────────────────────────────────────────
build-linux:
name: Build Linux (x86_64)
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libusb-1.0-0-dev \
fuse \
libfuse2 \
desktop-file-utils
- name: Install Wails CLI
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
echo "$HOME/go/bin" >> "$GITHUB_PATH"
- name: Install appimagetool
run: |
curl -fL -o /tmp/appimagetool \
"https://github.com/AppImage/AppImageKit/releases/latest/download/appimagetool-x86_64.AppImage"
chmod +x /tmp/appimagetool
sudo mv /tmp/appimagetool /usr/local/bin/appimagetool
appimagetool --version || true
- name: Cache vendor/
uses: actions/cache@v4
with:
path: vendor/
key: vendor-linux-${{ hashFiles('Makefile') }}-${{ hashFiles('visiona-agent/wheels/linux/**') }}
restore-keys: |
vendor-linux-${{ hashFiles('Makefile') }}-
vendor-linux-
- name: vendor-sync (Linux-only deps)
run: |
make vendor-python-linux \
vendor-wheels-linux \
vendor-ffmpeg-linux
- name: Build server (Linux)
run: |
mkdir -p payload/linux/bin
cd server
GOOS=linux GOARCH=amd64 go build -o ../payload/linux/bin/visiona-agent-server .
ls -lh ../payload/linux/bin/visiona-agent-server
- name: Build frontend (for go:embed)
run: make build-embed
- name: Build AppImage
run: make appimage
- name: Verify AppImage
run: |
ls -lh dist/visiona-agent-*.AppImage
file dist/visiona-agent-*.AppImage
- name: Upload AppImage artifact
uses: actions/upload-artifact@v4
with:
name: visiona-agent-linux-x64
path: dist/visiona-agent-*.AppImage
retention-days: 30
if-no-files-found: error