feature/gemini-web-provider #1

Merged
daniel.w merged 16 commits from feature/gemini-web-provider into master 2026-04-02 18:36:51 +00:00
Owner
No description provided.
daniel.w added 16 commits 2026-04-02 18:36:37 +00:00
33a0e53709 feat: Add GeminiWeb provider foundation
- Add Provider interface and factory pattern
- Create apitypes package for shared types
- Implement GeminiWeb provider with:
  - Browser automation using Rod
  - Session pool management
  - Cookie persistence
  - DOM interaction for Gemini web interface
- Add gemini-login command for session setup
- Add CURSOR_BRIDGE_PROVIDER env variable

Remaining: Integration with chat.go handlers
df22640d6a feat: Add Gemini provider env vars to Makefile and CLI options
- Add PROVIDER, GEMINI_ACCOUNT_DIR, GEMINI_BROWSER_VISIBLE, GEMINI_MAX_SESSIONS to Makefile
- Update gemini-login command to support --visible flag
- Add help text showing env vars and usage examples
- Display session save location and browser visibility on startup
f33353897c feat: Add provider display in startup logs and OpenCode gemini-web config
- Add provider name display in LogServerStart (cursor/gemini-web)
- Show gemini-dir and max-sess when using gemini-web provider
- Update Makefile to include gemini-web provider in opencode.json
- Update opencode-models to sync models for both cursor and gemini-web
- Add Gemini Web Provider examples in help text
19985dd476 feat: Route chat completions to Gemini Web provider when configured
- Add HandleGeminiChatCompletions for Gemini Web provider requests
- Update router to route requests based on cfg.Provider
- Support both streaming and non-streaming modes for Gemini
- Map stream chunks to OpenAI-compatible SSE format
69df57555d fix: Improve Gemini Web DOM selectors and add debug output
- Make model selector optional (skip if not found, use current model)
- Add multiple fallback selectors for input field and send button
- Add debug logging to trace execution flow
- Improve error messages to suggest running gemini-login
9f41d3b5b5 feat: Allow using Gemini Web without login
- Remove requirement to login before using Gemini Web
- If logged in (cookies exist), use the account
- If not logged in, continue without login (browser opens)
- When browser is visible, prompt user they can login or continue without
- Save cookies only if user actually logs in
24459ffcfe fix: Don't wait for user input during login flow
- Remove blocking 'Press Enter' prompt
- Continue without waiting when no session exists
- Save cookies asynchronously if user logs in during session
- Add debug output for finding input field and send button
- Try Enter key as fallback for sending message
32673c028e refactor: Complete rewrite of GeminiWeb provider
Based on project-golem implementation:

Phase 1: Browser Persistence
- Add BrowserManager singleton to manage browser lifecycle
- Use launchPersistentContext with UserDataDir
- Auto-save cookies and session state
- Clean Chrome lock files on startup
- Single browser instance reused across requests

Phase 2: Improved DOM Interaction
- Use correct input selectors (ProseMirror first)
- Implement 'Physical Enter' send method
- Trigger input/change/keyup events properly
- Check for 'Stop' button to detect busy state

Phase 3: Session Management
- No manual cookie saving/loading needed
- Session pool just manages userDataDir paths
- Default session directory structure

Breaking changes:
- Remove manual cookie management
- Browser stays open between requests
- Simpler session management
3d5f2d91c0 feat: Switch to playwright-go for better DOM automation
Major refactor using Playwright (pure Go):
- Add playwright-go dependency (v0.5700.1)
- Create PlaywrightProvider with auto-wait for elements
- Use LaunchPersistentContext for session persistence
- Implement Locator-based element finding (auto-wait)
- Fill input using Playwright's built-in methods
- Add fallback selectors for input fields
- Better error messages with page URL and title

Key improvements over Rod:
- Auto-wait for elements (solves 'input field not found')
- More mature browser automation library
- Better documentation and examples
- Based on project-golem's proven strategies

Installation:
- Playwright driver and Chromium downloaded to ~/Library/Caches/ms-playwright/
- ~160MB download (one-time setup)
104e55d613 fix: Add proper page ready check before finding input
Key improvements:
- Wait for page to fully load (SPA needs time)
- Wait for input field to be visible before typing
- Check login status only after page is ready
- Add fallback wait (3 seconds) if first attempt fails
- Properly handle error messages

Based on project-golem's PageInteractor.waitForReady()
bef521504e feat: Add debug mode with screenshot and page analysis
Features:
- Wait for user ENTER in visible mode (GEMINI_BROWSER_VISIBLE=true)
- Save screenshot to /tmp/gemini-debug.png
- Save HTML to /tmp/gemini-debug.html
- JavaScript-based element detection
- Multi-strategy wait (A: selectors, B: time, C: JS, D: debug)
- Detailed logging of each strategy attempt
- Page structure dump in debug mode

This helps identify why input field is not found
3fec6e55eb fix: Always save diagnostics on any error
- Add saveDiagnostics method
- Use defer in Generate to catch all errors
- Simplify typeInput error handling
- Automatic screenshot and HTML dump on failure
4517b07f33 feat: Implement Gemini Web provider with model selection
- Fix handler to use PlaywrightProvider instead of old Provider
- Add model selection for Gemini Web (fast/thinking/pro)
- Improve response extraction to remove 'Gemini said' prefix
- Add progress logging for headless mode
- Fix navigation to use Domcontentloaded instead of Networkidle
- Add proper input field selectors (.ql-editor)
- Improve response completion detection with stability check
daniel.w merged commit 85f695250e into master 2026-04-02 18:36:51 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: daniel.w/opencode-cursor-agent#1
No description provided.