從 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>
298 lines
7.0 KiB
JavaScript
298 lines
7.0 KiB
JavaScript
/*
|
|
_ __ _ __
|
|
| | / /___ _(_) /____
|
|
| | /| / / __ `/ / / ___/
|
|
| |/ |/ / /_/ / / (__ )
|
|
|__/|__/\__,_/_/_/____/
|
|
The electron alternative for Go
|
|
(c) Lea Anthony 2019-present
|
|
*/
|
|
|
|
export function LogPrint(message) {
|
|
window.runtime.LogPrint(message);
|
|
}
|
|
|
|
export function LogTrace(message) {
|
|
window.runtime.LogTrace(message);
|
|
}
|
|
|
|
export function LogDebug(message) {
|
|
window.runtime.LogDebug(message);
|
|
}
|
|
|
|
export function LogInfo(message) {
|
|
window.runtime.LogInfo(message);
|
|
}
|
|
|
|
export function LogWarning(message) {
|
|
window.runtime.LogWarning(message);
|
|
}
|
|
|
|
export function LogError(message) {
|
|
window.runtime.LogError(message);
|
|
}
|
|
|
|
export function LogFatal(message) {
|
|
window.runtime.LogFatal(message);
|
|
}
|
|
|
|
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
|
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
|
|
}
|
|
|
|
export function EventsOn(eventName, callback) {
|
|
return EventsOnMultiple(eventName, callback, -1);
|
|
}
|
|
|
|
export function EventsOff(eventName, ...additionalEventNames) {
|
|
return window.runtime.EventsOff(eventName, ...additionalEventNames);
|
|
}
|
|
|
|
export function EventsOffAll() {
|
|
return window.runtime.EventsOffAll();
|
|
}
|
|
|
|
export function EventsOnce(eventName, callback) {
|
|
return EventsOnMultiple(eventName, callback, 1);
|
|
}
|
|
|
|
export function EventsEmit(eventName) {
|
|
let args = [eventName].slice.call(arguments);
|
|
return window.runtime.EventsEmit.apply(null, args);
|
|
}
|
|
|
|
export function WindowReload() {
|
|
window.runtime.WindowReload();
|
|
}
|
|
|
|
export function WindowReloadApp() {
|
|
window.runtime.WindowReloadApp();
|
|
}
|
|
|
|
export function WindowSetAlwaysOnTop(b) {
|
|
window.runtime.WindowSetAlwaysOnTop(b);
|
|
}
|
|
|
|
export function WindowSetSystemDefaultTheme() {
|
|
window.runtime.WindowSetSystemDefaultTheme();
|
|
}
|
|
|
|
export function WindowSetLightTheme() {
|
|
window.runtime.WindowSetLightTheme();
|
|
}
|
|
|
|
export function WindowSetDarkTheme() {
|
|
window.runtime.WindowSetDarkTheme();
|
|
}
|
|
|
|
export function WindowCenter() {
|
|
window.runtime.WindowCenter();
|
|
}
|
|
|
|
export function WindowSetTitle(title) {
|
|
window.runtime.WindowSetTitle(title);
|
|
}
|
|
|
|
export function WindowFullscreen() {
|
|
window.runtime.WindowFullscreen();
|
|
}
|
|
|
|
export function WindowUnfullscreen() {
|
|
window.runtime.WindowUnfullscreen();
|
|
}
|
|
|
|
export function WindowIsFullscreen() {
|
|
return window.runtime.WindowIsFullscreen();
|
|
}
|
|
|
|
export function WindowGetSize() {
|
|
return window.runtime.WindowGetSize();
|
|
}
|
|
|
|
export function WindowSetSize(width, height) {
|
|
window.runtime.WindowSetSize(width, height);
|
|
}
|
|
|
|
export function WindowSetMaxSize(width, height) {
|
|
window.runtime.WindowSetMaxSize(width, height);
|
|
}
|
|
|
|
export function WindowSetMinSize(width, height) {
|
|
window.runtime.WindowSetMinSize(width, height);
|
|
}
|
|
|
|
export function WindowSetPosition(x, y) {
|
|
window.runtime.WindowSetPosition(x, y);
|
|
}
|
|
|
|
export function WindowGetPosition() {
|
|
return window.runtime.WindowGetPosition();
|
|
}
|
|
|
|
export function WindowHide() {
|
|
window.runtime.WindowHide();
|
|
}
|
|
|
|
export function WindowShow() {
|
|
window.runtime.WindowShow();
|
|
}
|
|
|
|
export function WindowMaximise() {
|
|
window.runtime.WindowMaximise();
|
|
}
|
|
|
|
export function WindowToggleMaximise() {
|
|
window.runtime.WindowToggleMaximise();
|
|
}
|
|
|
|
export function WindowUnmaximise() {
|
|
window.runtime.WindowUnmaximise();
|
|
}
|
|
|
|
export function WindowIsMaximised() {
|
|
return window.runtime.WindowIsMaximised();
|
|
}
|
|
|
|
export function WindowMinimise() {
|
|
window.runtime.WindowMinimise();
|
|
}
|
|
|
|
export function WindowUnminimise() {
|
|
window.runtime.WindowUnminimise();
|
|
}
|
|
|
|
export function WindowSetBackgroundColour(R, G, B, A) {
|
|
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
|
}
|
|
|
|
export function ScreenGetAll() {
|
|
return window.runtime.ScreenGetAll();
|
|
}
|
|
|
|
export function WindowIsMinimised() {
|
|
return window.runtime.WindowIsMinimised();
|
|
}
|
|
|
|
export function WindowIsNormal() {
|
|
return window.runtime.WindowIsNormal();
|
|
}
|
|
|
|
export function BrowserOpenURL(url) {
|
|
window.runtime.BrowserOpenURL(url);
|
|
}
|
|
|
|
export function Environment() {
|
|
return window.runtime.Environment();
|
|
}
|
|
|
|
export function Quit() {
|
|
window.runtime.Quit();
|
|
}
|
|
|
|
export function Hide() {
|
|
window.runtime.Hide();
|
|
}
|
|
|
|
export function Show() {
|
|
window.runtime.Show();
|
|
}
|
|
|
|
export function ClipboardGetText() {
|
|
return window.runtime.ClipboardGetText();
|
|
}
|
|
|
|
export function ClipboardSetText(text) {
|
|
return window.runtime.ClipboardSetText(text);
|
|
}
|
|
|
|
/**
|
|
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
|
*
|
|
* @export
|
|
* @callback OnFileDropCallback
|
|
* @param {number} x - x coordinate of the drop
|
|
* @param {number} y - y coordinate of the drop
|
|
* @param {string[]} paths - A list of file paths.
|
|
*/
|
|
|
|
/**
|
|
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
|
*
|
|
* @export
|
|
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
|
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
|
|
*/
|
|
export function OnFileDrop(callback, useDropTarget) {
|
|
return window.runtime.OnFileDrop(callback, useDropTarget);
|
|
}
|
|
|
|
/**
|
|
* OnFileDropOff removes the drag and drop listeners and handlers.
|
|
*/
|
|
export function OnFileDropOff() {
|
|
return window.runtime.OnFileDropOff();
|
|
}
|
|
|
|
export function CanResolveFilePaths() {
|
|
return window.runtime.CanResolveFilePaths();
|
|
}
|
|
|
|
export function ResolveFilePaths(files) {
|
|
return window.runtime.ResolveFilePaths(files);
|
|
}
|
|
|
|
export function InitializeNotifications() {
|
|
return window.runtime.InitializeNotifications();
|
|
}
|
|
|
|
export function CleanupNotifications() {
|
|
return window.runtime.CleanupNotifications();
|
|
}
|
|
|
|
export function IsNotificationAvailable() {
|
|
return window.runtime.IsNotificationAvailable();
|
|
}
|
|
|
|
export function RequestNotificationAuthorization() {
|
|
return window.runtime.RequestNotificationAuthorization();
|
|
}
|
|
|
|
export function CheckNotificationAuthorization() {
|
|
return window.runtime.CheckNotificationAuthorization();
|
|
}
|
|
|
|
export function SendNotification(options) {
|
|
return window.runtime.SendNotification(options);
|
|
}
|
|
|
|
export function SendNotificationWithActions(options) {
|
|
return window.runtime.SendNotificationWithActions(options);
|
|
}
|
|
|
|
export function RegisterNotificationCategory(category) {
|
|
return window.runtime.RegisterNotificationCategory(category);
|
|
}
|
|
|
|
export function RemoveNotificationCategory(categoryId) {
|
|
return window.runtime.RemoveNotificationCategory(categoryId);
|
|
}
|
|
|
|
export function RemoveAllPendingNotifications() {
|
|
return window.runtime.RemoveAllPendingNotifications();
|
|
}
|
|
|
|
export function RemovePendingNotification(identifier) {
|
|
return window.runtime.RemovePendingNotification(identifier);
|
|
}
|
|
|
|
export function RemoveAllDeliveredNotifications() {
|
|
return window.runtime.RemoveAllDeliveredNotifications();
|
|
}
|
|
|
|
export function RemoveDeliveredNotification(identifier) {
|
|
return window.runtime.RemoveDeliveredNotification(identifier);
|
|
}
|
|
|
|
export function RemoveNotification(identifier) {
|
|
return window.runtime.RemoveNotification(identifier);
|
|
} |