From 0c9c590d8f9c49578515ccaf19bb11431cf4e721 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Tue, 3 Mar 2026 09:15:18 +0300 Subject: Enha (playwright): conditionaly install and use tools --- tools_playwright.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'tools_playwright.go') diff --git a/tools_playwright.go b/tools_playwright.go index a4917a9..74a8e41 100644 --- a/tools_playwright.go +++ b/tools_playwright.go @@ -74,23 +74,30 @@ Additional browser automation tools (Playwright): ` var ( - pw *playwright.Playwright - browser playwright.Browser - browserStarted bool - browserStartMu sync.Mutex - page playwright.Page - browserAvailable bool + pw *playwright.Playwright + browser playwright.Browser + browserStarted bool + browserStartMu sync.Mutex + page playwright.Page ) -func checkPlaywright() { +func installPW() error { + err := playwright.Install(&playwright.RunOptions{Verbose: false}) + if err != nil { + logger.Warn("playwright not available", "error", err) + return err + } + return nil +} + +func checkPlaywright() error { var err error pw, err = playwright.Run() if err != nil { logger.Warn("playwright not available", "error", err) - return + return err } - browserAvailable = true - logger.Info("playwright tools available") + return nil } func pwStart(args map[string]string) []byte { @@ -420,7 +427,3 @@ func pwDrag(args map[string]string) []byte { } return []byte(fmt.Sprintf(`{"success": true, "message": "Dragged from (%s,%s) to (%s,%s)"}`, x1, y1, x2, y2)) } - -func init() { - go checkPlaywright() -} -- cgit v1.2.3