Commit Graph

12 Commits

Author SHA1 Message Date
9851e41182 fix(browser): robust fetch with incomplete-cache cleanup + retry + binary verification
Root cause: camoufox-js@0.11.0 fetch can exit 0 but silently fail
to download the browser binary when:
1. A partial/incomplete cache from a previous run exists
2. GitHub API rate-limits the unauthenticated release query
3. Network drops mid-download

Fix:
1. run_fetch() now DELETE incomplete cache (dir exists but no
   version.json) before fetching — prevents 'already cached' no-op
2. After fetch, VERIFY version.json exists — if missing, RETRY once
3. After retry, verify Camoufox.app/Contents/MacOS/camoufox exists
4. Log stdout and stderr in INFO traces for debugging
2026-06-13 08:17:38 +05:30
68f7629f6f fix(browser): auto-remove macOS Gatekeeper quarantine — prevent SIGKILL
Root cause: On Apple Silicon macOS, the Camoufox browser binary
inherits com.apple.quarantine from npm download. When camoufox-browser
launches it headlessly, Gatekeeper silently kills the process with
SIGKILL (exitCode=null, signal=SIGKILL) before it can run.

Fix:
1. remove_macos_quarantine() — runs 'xattr -dr com.apple.quarantine'
   on the Camoufox cache directory after every fetch and on every
   subsequent startup (in case cache was from a prior npx run)
2. check_known_errors() — detects 'sigkill' in daemon stderr and
   shows the exact fix command to the user
3. Runs quarantine removal in TWO places:
   - Immediately after camoufox-js fetch downloads the binary
   - Always, even when binary already exists in cache
2026-06-13 07:58:05 +05:30
b1f38da3d8 fix(browser): pin camoufox-js@0.11.0 and camoufox-browser@0.1.0 — no more @latest
Root cause: camoufox-browser@0.1.0 bundles camoufox-js@0.9.3 which downloads
a BROKEN alpha binary (v150.0.2-alpha.26, missing libmozglue.dylib) on macOS.
The newer camoufox-js@0.11.0 (Jun 4 2026) downloads STABLE builds.

Changes:
1. PINNED VERSIONS (constants at top of file):
   - CAMOUFOX_JS_VERSION = "0.11.0" — for fetching browser binary
   - CAMOUFOX_BROWSER_VERSION = "0.1.0" — for daemon IPC protocol
2. run_fetch() — uses 'npx --yes camoufox-js@0.11.0 fetch' instead of
   'camoufox-browser@latest install' (which called old camoufox-js)
3. Both packages share ~/Library/Caches/camoufox/ — fetch writes correct
   binary + version.json, daemon reads same cache
4. Removed Docker HTTP transport — no longer needed, daemon works on macOS
5. Removed reqwest dep from gyandoot-agent + gyandoot-browser
6. install.sh updated: uses camoufox-js@0.11.0 fetch + pinned npm package
7. install.sh verifies version.json exists, not just binary

Clean build: 0 errors, 0 warnings
No Docker dependency. No @latest. Pinned and stable.
2026-06-12 20:00:53 +05:30
71cf7c8830 fix(browser): dual transport — Unix socket + HTTP Docker + binary corruption detection
Root cause on macOS: camoufox-browser@0.1.0 downloads an alpha binary
(v150.0.2-alpha.26) from daijro/camoufox that has a broken macOS build
(missing libmozglue.dylib). Binary crashes with SIGABRT/SIGKILL.

Changes:
1. gyandoot-browser client now supports TWO transports:
   - Transport::UnixSocket (existing — daemon IPC)
   - Transport::Http (new — Docker REST API on port 9377)
2. init_browser() tries Docker HTTP first, falls back to npx daemon
3. HTTP transport maps browser actions to Docker REST endpoints
   (/navigate, /tabs, /health, etc.) with correct userId params
4. check_known_errors() detects libmozglue.dylib + SIGKILL patterns
5. Browser cache check works for both macOS and Linux paths
6. Error messages correctly say 'Use Docker' on corrupted binary
7. Added reqwest dep to gyandoot-agent for Docker health check

Clean build: 0 errors
2026-06-12 19:49:16 +05:30
495893c1de fix(browser): clean reimplementation — detect corrupted dl + Docker check
Clean build: 0 errors, 0 warnings
2026-06-12 19:17:13 +05:30
17f828f159 fix(browser): platform-aware error messages + corrupted download detection
Root cause on macOS: 'camoufox-browser install' downloaded v150.0.2-alpha.26
instead of the stable browser binary. This alpha version is missing
libmozglue.dylib, causing dyld to crash immediately.

Changes:
1. detect_os() — returns Mac/Linux/Wsl/Windows enum for platform-aware logic
2. check_known_errors() — parses daemon stderr for known failures (missing
   libmozglue.dylib on macOS, missing libgtk/libnss on Linux, code-signing)
3. platform_fix_instructions() — returns OS-specific recovery steps:
   - macOS: rm -rf ~/Library/Caches/camoufox, reinstall, or Docker fallback
   - WSL/Linux: correct apt-get install commands (with t64 package variants)
4. Browser cache detection now checks Camoufox.app on macOS, camoufox on Linux
5. All error messages use detect_os() — no more Linux apt-get on macOS
6. Corrupted download detected automatically, user told to clear cache + retry

Clean build: 0 errors, 0 warnings
2026-06-12 19:05:35 +05:30
ff2e6b45e1 fix(browser): auto-install camoufox browser binary + WSL system deps guide
Root cause: 'camoufox-browser tab_list' triggers daemon which immediately
crashes because the ~662MB Camoufox browser binary was never downloaded
('camoufox-browser install' was never run). Additionally, on fresh WSL,
Linux system libraries (libgtk-3, libnss3, libatk, etc.) are missing.

Changes:
1. Add is_browser_installed() check — looks for ~/.cache/camoufox/camoufox
2. Add run_install() — runs 'camoufox-browser install' before starting daemon
3. init_browser() now auto-runs install if browser binary is missing
4. WSL-specific error message shows exact apt-get command for missing deps
5. Daemon timeout message lists all 30+ required Linux packages
6. Manual 'npx camoufox-browser@latest tab_list' command shown for debugging

Clean build: 0 errors, 0 warnings
2026-06-12 18:17:08 +05:30
b5a5784707 fix(browser): platform-aware error messages with WSL detection
- Add is_wsl() detection via /proc/version
- Add example_npx_path() returning platform-appropriate example path
- Replace all hardcoded macOS paths in error messages with dynamic ones
- Add WSL-specific hints: Node.js must be installed inside WSL, not Windows
- WSL hint includes nvm install instructions
- Clean build: 0 errors, 0 warnings
2026-06-12 17:22:06 +05:30
07a14e2d7b fix(browser): surface actual camoufox-bridge error on daemon start failure
trigger_daemon_start now captures stdout/stderr and exit code instead
of silently redirecting to a log file. On failure it prints the actual
error, making it obvious what went wrong (npm install issue, node
version mismatch, etc.).
2026-06-12 16:32:45 +05:30
697c2c63b2 feat(browser): cross-platform node_path config for npx resolution
Adds [browser].node_path config option so camoufox-browser can use
an explicit npx path (essential for nvm/fnm/asdf users).

Resolution order (cross-platform):
1. config.browser.node_path — explicit user override
2. 'npx.cmd' on Windows, 'npx' on Linux/macOS — PATH lookup

Changes:
- BrowserSection config: added node_path: Option<String>
- AgentConfig: now carries browser section (was dropped in From<GyandootConfig>)
- browser_manager::init_browser(node_path): accepts optional path
- All call sites updated (run(), init_session(), subagents, tests)
- Error messages now hint at browser.node_path config
2026-06-12 16:08:37 +05:30
e06094c0a2 Option C: Rewrite gyandoot-browser for camoufox-browser@0.1.0 daemon IPC
Complete rewrite removing old HTTP REST client. The latest camoufox-browser
npm package (v0.1.0) uses Unix socket JSON-line IPC, not HTTP REST on :9377.

Changes:
- gyandoot-browser/client.rs: Full daemon IPC via Unix socket (~/.camoufox-browser/*.sock)
  - JSON-line protocol matching ensureDaemonRunning + daemon.js
  - Auto-launches browser on first command (daemon manages lifecycle)
  - Supports navigate, click, type, scroll, snapshot, search macros, tab management
  - Proper HeathResponse, NavigationResult, PageSnapshot types
- gyandoot-browser/lib.rs: Exports new client API (no SearchMacro enum, no SessionManager)
- gyandoot-browser/Cargo.toml: reqwest -> tokio Unix socket deps
- Removed: macros.rs, session.rs, snapshot.rs (all merged into client.rs)
- browser_manager.rs: Triggers daemon via npx, waits for Unix socket
- browser_tools.rs: Simplified API (no tab_id, no create_tab/close_tab)

Fix: camoufox-browser process exited with status 1 error on fresh install
2026-06-12 11:12:51 +05:30
f2d612bd28 🚀 Camoufox default web engine — auto-install + auto-start
Full integration:
- install.sh now installs camoufox-browser via npm (preferred) or Docker
- install.sh creates systemd/launchd auto-start service on Linux/macOS
- New browser_manager.rs — health-check, auto-start, wait-for-ready
- AgentLoop::run() auto-inits Camoufox and registers web_search/web_browse
- System prompt tells LLM to use web_search/web_browse as PRIMARY tools
- Graceful fallback: if Camoufox unavailable, logs warning, uses bash tools
- ToolExecutor is now Arc<Mutex<>> for runtime tool registration

GyanDoot v2 now: install → Camoufox auto-starts → web tools available →
"search NSE India" uses Camoufox with anti-detection 🎯
2026-06-11 23:12:57 +05:30