Skip to content

feat(aistudio): add AI Studio provider (network-first GenerateContent parsing + DOM fallback)#41

Open
w-winter wants to merge 1 commit intonicobailon:mainfrom
w-winter:aistudio-client
Open

feat(aistudio): add AI Studio provider (network-first GenerateContent parsing + DOM fallback)#41
w-winter wants to merge 1 commit intonicobailon:mainfrom
w-winter:aistudio-client

Conversation

@w-winter
Copy link

This adds an AI Studio (aistudio.google.com) provider so surf aistudio "<prompt>" can drive the Playground UI via the existing Chrome extension + native host bridge, returning the model’s final answer directly in the terminal. The motivation for adding this (over the existing Gemini provider) is that, when accessed via AI Studio, the Gemini models are not as nerfed as they are from the consumer-facing Gemini experience. For Gemini 3 Pro the difference can be very meaningful with certain prompts. The downside is aggressive per-day rate limiting for the Gemini 3 Pro and Gemini 3 Flash models when accessed this way.

Response extraction is network-first by parsing the MakerSuiteService/GenerateContent RPC payload from captured network entries, with a DOM-based fallback (waitForResponse) to keep the provider working when network capture or RPC parsing fails. The host log redaction is also hardened to avoid writing prompts/model outputs and large payloads to disk.

Summary of changes:

  • add native/aistudio-client.cjs CDP-driven client: open new chat, best-effort model selection, enable Raw Markdown view, type + submit prompts, network-first GenerateContent parsing (final-response only) with DOM fallback
  • extension/service-worker: support richer network entry export for AI Studio polling and return the most recent entries in the READ_NETWORK_REQUESTS full path (plus urlPattern filtering)
  • native host: route AISTUDIO_QUERY, optionally prepend page context (--with-page), filter network polling to GenerateContent via urlPattern, and harden redactForLog to omit/summarize high-volume sensitive fields (request/response bodies, page text, screenshots, network dumps)
  • CLI: register surf aistudio command/help, make --json always emit valid JSON via a shared formatter
  • docs: update README.md + skills/surf/SKILL.md with AI Studio examples, default model behavior, and rate-limit caution
  • tests: add minimal unit coverage for JSON output formatting (test/unit/cli-json-output.test.ts)

```bash
surf scroll.bottom
surf scroll.top
surf scroll.top
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the stray whitespace deletions here and there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant