refactor(search): remove the Gemini search backend

The user asked to drop it: nobody had the Gemini CLI login or a key set up,
and Exa then Wikipedia cover the voice use. webSearch is now live Chrome,
Exa, Brave (opt-in), Wikipedia. Removes the CLI/REST backends, the
GEMINI_* settings, the Docker login mount and checks, and updates the specs
and docs/llm_contexts.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-18 09:24:11 +09:00
parent 59c3f33c2c
commit af1276cf6b
26 changed files with 66 additions and 504 deletions

View File

@@ -134,24 +134,7 @@ The `brain` and `app` roles are backward-compatible additions to `full`/`browser
- Install the NVIDIA driver on Windows and enable GPU in Docker Desktop
(Settings → Resources → WSL Integration). Use the `gpu-windows.yml` override.
- Paths: named volumes are cross-platform. The Gemini OAuth login (for
`GEMINI_AUTH=oauth`) is bind-mounted from the project-local `./docker/gemini-oauth`
into the container's `~/.gemini`. A project-relative path is used so it resolves
the same on Windows Docker Desktop and Linux (`${HOME}` is often unset when
compose runs from PowerShell/cmd). Seed it once from a machine with a browser and
the logged-in Gemini CLI (`npm i -g @google/gemini-cli`, then `gemini` ->
"Sign in with Google"), copying the login state:
(Note: as of 2026-06 Google blocks personal Google accounts on this CLI login
with "This client is no longer supported for Gemini Code Assist for
individuals". Workspace/org accounts may still work; personal accounts should
use `GEMINI_AUTH=apikey` with a key from https://aistudio.google.com/app/apikey
instead. Real-time search fail-opens to DDG/Brave/Wikipedia either way.)
`cp -r ~/.gemini/. docker/gemini-oauth/`. The essential file is `oauth_creds.json`
(it holds the refresh token; `GOOGLE_GENAI_USE_GCA=true` forces OAuth, so that is
the file the startup readiness check looks for) - copying the whole dir simply also
carries the cached account/settings. To reuse an existing host login without
copying, set `GEMINI_OAUTH_DIR=~/.gemini` in `.env`. If unseeded, real-time search
fail-opens to DDG/Brave and the container logs a `🔑` warning on startup.
- Paths: named volumes are cross-platform.
## Known limitation

View File

@@ -183,10 +183,7 @@ Every distinct LLM call in Jarvis, what feeds it, what consumes it, and how it i
- **Weather** ([src/jarvis/tools/builtin/weather.py](src/jarvis/tools/builtin/weather.py), ~line 60) — `ollama_chat_model`, parses location/time/unit from the query.
- **Chat delete consent** ([src/jarvis/tools/builtin/chat_channels.py](src/jarvis/tools/builtin/chat_channels.py), `_user_agrees`, v2 only) — resolution chain `tool_router_model → intent_judge_model → ollama_chat_model`, temperature 0, timeout `llm_tools_timeout_sec`. Runs only when `chatChannels delete confirm=true` arrives in the turn right after the delete was asked. Input: the pending message ID and channel name (in the system prompt) and the person's own message of this turn (fenced); a message over 600 chars is not sent and counts as no. Output: one word, YES means delete that message. Fail-closed. Eval: `evals/test_chat_delete_consent.py`.
- **Nutrition log_meal** ([src/jarvis/tools/builtin/nutrition/log_meal.py](src/jarvis/tools/builtin/nutrition/log_meal.py), lines 48 & 136) — `ollama_chat_model`, extracts nutrients, confirms logging.
- **Gemini real-time search** ([src/jarvis/tools/builtin/realtime_search.py](src/jarvis/tools/builtin/realtime_search.py)) — **external Gemini model**, NOT Ollama. Used on the `webSearch` route only after Exa found nothing, and only when it can work: `oauth` with a Gemini CLI login present (`gemini_oauth_ready()`), or `apikey` with a key. While the broadcast is live the on-screen Chrome path goes first ([web_search.spec.md](src/jarvis/tools/builtin/web_search.spec.md)). Sub-mode is `cfg.gemini_auth` (env `GEMINI_AUTH`, default `oauth`):
- `oauth` (default) `gemini_cli_search()` — shells out to the Gemini CLI (`gemini -p <query> -o json --skip-trust`, default approval mode) authenticated by the user's Google-account login (`GEMINI_API_KEY`/`GOOGLE_API_KEY` stripped from the child env, `GOOGLE_GENAI_USE_GCA=true` set to select OAuth); model is whatever the CLI/account defaults to. Uses the CLI's built-in web-search grounding. Bounded by a 30s subprocess timeout. The login lives in `~/.gemini`; in Docker that is the project-local `docker/gemini-oauth` bind mount (override `GEMINI_OAUTH_DIR`), which the operator seeds once. `gemini_oauth_ready()` checks `~/.gemini/oauth_creds.json`; without it the CLI is not started (it cost about 2 s per search for nothing, live 2026-11-18).
- `apikey` `gemini_search()` — one REST `generateContent` call (`gemini_model`, default `gemini-2.0-flash`) with the `google_search` grounding tool; keyed by `GEMINI_API_KEY`.
Both return the fenced UNTRUSTED-WEB-EXTRACT envelope consumed by the main loop (#1). Fail-open: CLI missing / login expired / quota 429 / timeout / errors / missing key all fall through to Brave (opt-in) and Wikipedia. The `STREAM_BROWSER=true` route (`browser_search()`) makes NO LLM call — it drives Chrome and scrapes Google results.
- **Real-time search, no LLM**: webSearch makes no LLM call. The Gemini search backend (CLI or REST) was removed 2026-11-18 at the user's request; the `STREAM_BROWSER=true` route (`browser_search()`) drives Chrome and scrapes Google results.
## 15. Voice call judgements (v2 voice worker)

View File

@@ -11,15 +11,13 @@ screen-share state then decides the search backend per turn:
- While the broadcast is **live**: drive the on-screen Chrome (CDP at
`CDP_PORT`, default 9222) to Google-search / play YouTube / read the page —
visible on the Go-Live stream (VNC display `:1`).
- While the broadcast is **off**: the normal webSearch chain (Exa, then Gemini, then
- While the broadcast is **off**: the normal webSearch chain (Exa, then
Brave and Wikipedia; `src/jarvis/tools/builtin/web_search.spec.md`), no screen needed.
- The user can toggle the broadcast on/off by voice ("방송 켜줘" / "방송 꺼줘"),
routed through an LLM tool (no hardcoded phrase matching).
- **`STREAM_BROWSER=false`**: broadcasting is disabled entirely. Any `/stream`
or "start broadcast" request is refused, and real-time search always uses
the normal webSearch chain. Gemini's auth sub-mode there is `GEMINI_AUTH`:
- `oauth` (default): the Gemini CLI with a Google-account login (no API key).
- `apikey`: the REST API keyed by `GEMINI_API_KEY`.
the normal webSearch chain.
The brain receives the live broadcast state per request (`ToolContext.broadcasting`,
threaded from the bot via the bridge); `None` means "no signal" (evals, text
@@ -32,9 +30,7 @@ entry) and falls back to the master flag so behaviour is unchanged.
| Mode flag (bot) | `bot/src/config.ts` `screenBrowser`, enforced in `selfbot.ts` | done |
| Browser search core (Node/CDP) | `bot/scripts/stream-test/browse-search.mjs` | this change |
| Brain mode read | `src/jarvis/config.py` `stream_browser` from env | TODO |
| Gemini auth mode | `GEMINI_AUTH` (oauth/apikey), `GEMINI_API_KEY`, `GEMINI_MODEL` (.env) + `config.py` | done |
| `browseAndSearch` tool (true) | `src/jarvis/tools/builtin/browse_and_search.py` -> subprocess the Node core | TODO |
| Gemini search (false) | `realtime_search.py` `gemini_cli_search()` (oauth, CLI) / `gemini_search()` (apikey, REST) | done |
| Search routing by live broadcast | `web_search.py` uses `ToolContext.broadcasting` + master flag | done |
| Live broadcast state in tool ctx | `tools/base.py` `ToolContext.broadcasting` from `turn_state` | done |
| Per-turn state channel | `reply/turn_state.py` (thread-local: broadcasting in, directive out) | done |
@@ -51,30 +47,8 @@ entry) and falls back to the master flag so behaviour is unchanged.
(`broadcast-helper.mjs`, `selfbot.ts`), so the brain shells out to
`node browse-search.mjs <query>` and wraps the JSON result in the engine's
`UNTRUSTED WEB EXTRACT` envelope. Keeps the 39k-line Python brain dep-free.
- Gemini has two auth sub-modes (`GEMINI_AUTH`):
- `oauth` (default): shell out to the Gemini CLI (`gemini -p <query> -o json
--skip-trust`, default approval mode — read-only tools like web search run
headless, but write/shell tools are never auto-approved) authenticated by
the user's Google account login. `GEMINI_API_KEY`/`GOOGLE_API_KEY` are stripped from the child
env, and `GOOGLE_GENAI_USE_GCA=true` is set, so the CLI uses the account
login (not API-key auth) and fails fast when no login exists rather than
erroring on "no auth method". The CLI is resolved from `PATH` or
`~/.local/bin/gemini`; install with `npm i -g @google/gemini-cli` and sign
in once via interactive `gemini` ("Sign in with Google"). In Docker the login
can't be done interactively in the headless container: seed it instead by
copying a logged-in `~/.gemini` into the project-local `docker/gemini-oauth`
bind mount (or set `GEMINI_OAUTH_DIR`); the container reads/refreshes the
token there. `gemini_oauth_ready()` gates an actionable log hint, and the
entrypoint warns on startup, when oauth is selected but no login is seeded.
- `apikey`: the REST endpoint (`generativelanguage.googleapis.com`) via stdlib
`urllib` with the `google_search` grounding tool - no SDK dependency.
- Both Gemini paths and the browser path return the same
`ToolExecutionResult(success, reply_text)` envelope, and are fail-open: any
failure returns `None` and the caller goes on down the webSearch chain.
## Notes / verification
- Grounded Gemini search needs real quota. On a free tier the grounded call can
return HTTP 429 `RESOURCE_EXHAUSTED` (free-tier limit 0); the OAuth login must
be a Google account with usable Gemini quota, otherwise the path 429s and
fail-opens to Brave/Wikipedia. The 30s subprocess timeout bounds the CLI's retry/backoff.
- Behaviour covered by `tests/test_realtime_gemini_cli.py`.
- The browser path returns the same `UNTRUSTED WEB EXTRACT` envelope as webSearch
and is fail-open: any failure returns `None` and the caller goes on down the
webSearch chain.
- The Gemini search backend (CLI with a Google login, or REST with a key) was
removed 2026-11-18 at the user's request.