HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
feat(harness): add Gemini CLI as a new agent backend (Path A: API Key) (#72)
ZixiaoL2943531d8f62
diff --git a/.env.example b/.env.exampleindex 49c30367..b212cb7f 100644--- a/.env.example+++ b/.env.example@@ -14,10 +14,15 @@ HR_SECRET_GLOBAL_HARNESS_CONN_ANTHROPIC={"name":"anthropic","provider":"anthropi# Any OpenAI-compatible endpoint (aggregators, local models, self-hosted inference)# HR_SECRET_GLOBAL_HARNESS_CONN_CUSTOM={"name":"custom","provider":"openai-api","api_key":"REPLACE_ME","base_url":"https://api.example.com/v1"}+# Google AI Studio — for the gemini backend. A free-tier key's content may be reviewed/used+# for training; use a billing-linked key for anything private.+# HR_SECRET_GLOBAL_HARNESS_CONN_GOOGLE={"name":"google","provider":"google","api_key":"AIza-REPLACE_ME"}+# Which connection each backend uses by default.HR_SECRET_GLOBAL_HARNESS_POLICY_CLAUDE={"chain":["anthropic"]}# HR_SECRET_GLOBAL_HARNESS_POLICY_CODEX={"chain":["openai"]}# HR_SECRET_GLOBAL_HARNESS_POLICY_HERMES={"chain":["openai"]}+# HR_SECRET_GLOBAL_HARNESS_POLICY_GEMINI={"chain":["google"]}# ── Optional ──────────────────────────────────────────────────────────────────# PORT=3000diff --git a/Dockerfile b/Dockerfileindex 2c27eeb8..a7039849 100644--- a/Dockerfile+++ b/Dockerfile@@ -17,7 +17,7 @@# They land in the data volume, so the cost is paid once per volume rather than once per start.# Choose backends at RUN time:#-# docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,qwen,cline ... # the default+# docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,qwen,gemini,cline ... # the default# docker run -e HR_BACKENDS=opencode ... # lean## WITH_BROWSER is still a build arg because Chromium and its system libraries genuinely belongdiff --git a/README.md b/README.mdindex a5cdae96..12d27664 100644--- a/README.md+++ b/README.md@@ -578,7 +578,7 @@ Backends are installed into your data volume rather than baked into the image, swant is a run-time setting:```bash-docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,qwen,cline ... # the default+docker run -e HR_BACKENDS=claude,codex,hermes,pi,dsh,opencode,qwen,gemini,cline ... # the defaultdocker run -e HR_BACKENDS=opencode ... # lean```diff --git a/docker/entrypoint.sh b/docker/entrypoint.shindex 1596891c..decf62ca 100644--- a/docker/entrypoint.sh+++ b/docker/entrypoint.sh@@ -172,7 +172,7 @@ export HOSTNAME=0.0.0.0TOOLS="$DATA_DIR/agent-tools"export PATH="$TOOLS/bin:$PATH"export NODE_PATH="$TOOLS/lib/node_modules"-export HR_BACKENDS="${HR_BACKENDS:-claude,codex,hermes,pi,dsh,opencode,qwen,cline}"+export HR_BACKENDS="${HR_BACKENDS:-claude,codex,hermes,pi,dsh,opencode,qwen,gemini,cline}"wanted() { [[ ",$HR_BACKENDS," == *",$1,"* ]]; }# The executable IS the definition of "installed" — an installer that exits 0 without producing@@ -187,6 +187,7 @@ backend_bin() {dsh) echo "$TOOLS/dsh-venv/bin/dsh-ready" ;;opencode) echo "$TOOLS/bin/opencode" ;;qwen) echo "$TOOLS/bin/qwen" ;;+ gemini) echo "$TOOLS/bin/gemini" ;;cline) echo "$TOOLS/bin/cline" ;;esac}@@ -255,6 +256,16 @@ install_backends() {try_install "Qwen Code" npm install -g --prefix "$TOOLS" --no-audit --no-fund @qwen-code/qwen-code || truefi+ if wanted gemini && [ ! -x "$(backend_bin gemini)" ]; then+ echo "[harnessrouter] installing Gemini CLI (Apache-2.0)…"+ # Pinned, same rationale as cline's: 0.58.0 is the release runner/server.py's gemini code was+ # verified against — the real stream-json field names (tool_name/tool_id/parameters, not the+ # guessed id/name/input a first pass shipped with), --approval-mode/--skip-trust being+ # load-bearing, and --resume latest's semantics all came from reading THIS version's own+ # source. A silent bump to `latest` re-gambles all of it on a release nobody has checked.+ try_install "Gemini CLI" npm install -g --prefix "$TOOLS" --no-audit --no-fund "@google/gemini-cli@${HR_GEMINI_VERSION:-0.58.0}" || true+ fi+if wanted cline && [ ! -x "$(backend_bin cline)" ]; thenecho "[harnessrouter] installing Cline (Apache-2.0)…"# Pinned: 3.0.60 is the release every behavior in runner/server.py was verified against —diff --git a/docs/support-matrix-notes.md b/docs/support-matrix-notes.mdindex 3388a3e2..3e14b9d2 100644--- a/docs/support-matrix-notes.md+++ b/docs/support-matrix-notes.md@@ -46,4 +46,18 @@ subset dropped, oneOf to anyOf, const to a one-value enum, exclusive bounds to bto one type plus nullable, a type on every node, items on every array, required limited to existingproperties, an empty declaration dropped). The report is with TokenRouter; when their channelnormalises, this comes out of both trees.+## The gemini backend (Gemini CLI) lists the ids it serves as itself (2026-09-06)++gemini-cli speaks Google's native API with the raw key, so the backend runs in owner trust only and+on Google's own ids. Measured on the OSS instance with the org holding only the Google integration,+all five scenarios on each of the eleven ids the google provider serves, 55 of 55 runs passed, artifact+turns included on every Gemini 3.x id (the CLI carries the thought signatures itself). The result+event's stats are keyed by the model the CLI actually called, and that is where the catalog's rule+bites: on the API-key auth path gemini-cli 0.58.0 (and 0.59.0-preview.0 and the 2026-09-06 nightly)+treats "3.5 Flash GA" as launched and its resolver rewrites every id ending in "-flash" to+gemini-3.5-flash, with no setting to turn it off. gemini-3.8-flash, 3.7-flash, 3.6-flash and 2.5-flash+were served by gemini-3.5-flash on every turn and are listed as served-as findings, not passes; the+backend lists the seven ids served as themselves: gemini-3.5-flash, 3.5-flash-lite, 3.1-flash-lite,+3.1-pro-preview, 3-flash-preview, 2.5-pro, 2.5-flash-lite. The four stay reachable on the same key+through the OpenAI-shape harnesses, where Google serves each id as requested on both API surfaces.diff --git a/gateway/app.py b/gateway/app.pyindex 9d927e09..1c3009f4 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -852,6 +852,15 @@ _BROKER_TTL_S = int(os.environ.get("HR_LLM_BROKER_TTL_S", str(6 * 3600))) # >_BROKERABLE_PROVIDERS = {"anthropic", "tokenrouter", "openai", "azure", "azure-foundry","openrouter", "openai-api", "custom", "google"}+# Backends that speak a provider's NATIVE API rather than the OpenAI or Anthropic shape the broker+# and the loopback relays carry: nothing sits between the CLI and the provider, so the sandbox+# must hold the raw key. That is owner trust by definition. In broker mode such a connection is+# refused with the reason, instead of a broker credential going to Google as an API key and the+# turn dying on a 400 nobody can read. gemini-cli 0.58.0 honours GOOGLE_GEMINI_BASE_URL on the+# API-key path (measured 2026-09-06: pointed at a dead port it retried "fetch failed" against it),+# so the native paths can be brokered later; until the broker carries them, this set is the guard.+_NATIVE_ONLY_BACKENDS = {"gemini"}+def _mint_turn_cred(sid: str, conn_name: str) -> str:"""Per-turn credential: sid.conn.exp.hmac — resolvable back to exactly one connection."""@@ -925,6 +934,11 @@ def _auth_from_conn(conn: dict, sid: str = "") -> dict | None:out[field] = conn[field]return out+ backend = str(conn.get("backend") or "")+ if backend in _NATIVE_ONLY_BACKENDS:+ print(f"[broker] refusing to build sandbox auth for backend={backend!r}: it speaks the "+ f"provider's native API, which is not brokered (HR_SANDBOX_TRUST=owner runs it)", flush=True)+ return None# Normalised: a connection saved as "TokenRouter" must not skip brokering on a casing mismatch.provider = str(conn.get("provider") or "").strip().lower()if provider not in _BROKERABLE_PROVIDERS or not sid or not PUBLIC_BASE_URL:@@ -1060,6 +1074,12 @@ _INTEGRATION_WIRING: dict[tuple[str, str], str] = {("google", "hermes"): "openai-api", ("google", "pi"): "openai-api",("google", "dsh"): "openai-api", ("google", "opencode"): "openai-api",("google", "qwen"): "openai-api", ("google", "cline"): "openai-api",+ # gemini (Gemini CLI) speaks Google's native API, not the OpenAI shape the rows above reach+ # through a base_url, so it is wired to the google provider as itself: the runner gets the+ # raw key (owner trust only; see _NATIVE_ONLY_BACKENDS). No ("custom", "gemini") row, for the+ # reason it is absent from _CUSTOM_FORMAT_BACKENDS: a custom integration is OpenAI- or+ # Anthropic-shaped.+ ("google", "gemini"): "google",}@@ -1847,6 +1867,7 @@ async def _trace_finalize(sid: str, rec: dict) -> None:"title": (prompt.strip().splitlines()[0][:120] if prompt.strip() else sid[:16]),"user_prompt": prompt[:1500], "status": rec.get("status"),"connection": rec.get("connection"), "cli_session_id": rec.get("cli_session_id"),+ "served_model": rec.get("served_model") or None,"result": (rec.get("result") or "")[:4000],"elapsed": rec.get("elapsed") or (round(time.time() - rec["started"], 1) if rec.get("started") else None),"event_count": real_count, "trace_blob": tr.get("prefix"),@@ -4696,7 +4717,10 @@ def _blocks_from_canonical(ev: dict) -> list[tuple[str, object]]:"is_error": bool(c.get("is_error"))}))elif t == "result":out.append(("result", {"text": ev.get("result") or "", "usage": ev.get("usage"),- "is_error": bool(ev.get("is_error"))}))+ "is_error": bool(ev.get("is_error")),+ # the model the CLI reports it actually used, when it says (gemini-cli+ # keys its stats by served model, and rewrites some ids on the way)+ "model": str(ev.get("model") or "")}))elif t == "system" and ev.get("subtype") == "resume_lost":# The runner asked to continue a prior session, but it wasn't found in this sandbox — it# silently started fresh instead (see harness_runner _run_hermes_bg). A caller who believed@@ -4736,6 +4760,7 @@ class _RespTranslator:# last_connection carried it before, one value per session; the turns feed and the support# matrix read it per turn (a report that said "every turn record" was reading the session).self.connection = ""+ self.served_model = "" # what the CLI reports it ran, when it reports; "" = unknownself.seq = 0self.out_index = -1self.output: list[dict] = []@@ -4770,6 +4795,7 @@ class _RespTranslator:"previous_response_id": self.prev, "model": self.model,"output": self.output, "store": self.store, "usage": self.usage,"connection": self.connection,+ "served_model": self.served_model,"metadata": meta}def start(self) -> list[dict]:@@ -4866,6 +4892,8 @@ class _RespTranslator:evs.append(self._ev("response.output_item.done", output_index=self.out_index, item=item))self.output.append(item)elif kind == "result":+ if payload.get("model"):+ self.served_model = str(payload["model"])u = payload.get("usage")if u:self.usage = {"input_tokens": u.get("input_tokens", 0),@@ -5480,6 +5508,29 @@ _MODEL_CATALOG: dict[str, dict] = {"gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3","kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max","mistral-medium-3.5", "step-3.7-flash", "glm-5.3", "glm-5.3-flash"]},+ # gemini backend only speaks the native Google API (Path A: Gemini API Key), so unlike every+ # row above it cannot serve the whole cross-vendor catalogue through a relay — only Google's+ # own models, direct from Google. gemini-3.6-flash is live-turn verified (2026-09-06, a+ # no-tool-use turn end to end against a real free-tier key). gemini-3.5-flash-lite and+ # gemini-3.7-flash are NOT yet live-turn verified — added on published Google model-card ids+ # (not guessed: gemini-3.6-pro does not exist, and the lite sibling shipped as 3.5, not 3.6,+ # despite launching alongside 3.6 Flash — versions don't move in lockstep across the family).+ # gemini-3.1-pro (the real Pro flagship) is deliberately NOT listed: Pro was dropped from the+ # free tier in 2026-04, so it would show as a choice and fail every call on a free-tier key.+ # Google's own ids only: gemini-cli speaks the native API, so the cross-vendor rows above do not+ # apply. Measured 2026-09-06 on the OSS instance (all five scenarios per id, org holding only the+ # Google integration, 55 of 55 runs passed) with the served model read off the CLI's own stats:+ # on the API-key auth path gemini-cli 0.58.0 treats "3.5 Flash GA" as launched and its resolver+ # rewrites every id ending in "-flash" to gemini-3.5-flash (resolveModel with useGemini3_5Flash,+ # true for gemini-api-key; the same in 0.59.0-preview.0 and the 0.60 nightly; no setting turns+ # it off), so gemini-3.8-flash, 3.7-flash, 3.6-flash and 2.5-flash were served by gemini-3.5-flash+ # on every turn and are not listed: a completed turn on them is a turn on 3.5-flash. Those four+ # stay reachable on the same key through the OpenAI-shape harnesses, where Google serves each id+ # as requested. The seven below were served as themselves on every turn.+ "gemini": {"default": "gemini-3.5-flash",+ "models": ["gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite",+ "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro",+ "gemini-2.5-flash-lite"]},}_BARE_MODELS = {"", "claude", "codex", "anthropic", "bedrock", "openai", "hermes", "pi", "dsh", "deepseek"}# Models whose serving CHANNEL refuses image input outright. Measured, not assumed — probed@@ -5805,7 +5856,7 @@ def _strip_internal(d: dict) -> dict:# Instruction files WE write into the workspace — one per backend family. A new backend that# introduces a new context-file name must add it here or the harness's own instructions get# collected as a "produced" deliverable on the first turn (QWEN.md did, 2026-08-25).-_OUTPUT_EXCLUDE_NAMES = {"AGENTS.md", "CLAUDE.md", "QWEN.md"}+_OUTPUT_EXCLUDE_NAMES = {"AGENTS.md", "CLAUDE.md", "QWEN.md", "GEMINI.md"}def _is_internal_output(name: str) -> bool:@@ -6082,7 +6133,10 @@ async def _resp_execute(translator: _RespTranslator, *, org: str, member: str, s# Refusing beats running: the only alternative is handing the sandbox a real provider# key. The chain moves on, and a fully unbrokerable chain fails the turn loudly.rec["tried"].append({"connection": name,- "error": "credential cannot be brokered; refused"})+ "error": (f"the {backend} harness speaks the provider's native API, which is not "+ f"brokered: run it with HR_SANDBOX_TRUST=owner"+ if backend in _NATIVE_ONLY_BACKENDS else+ "credential cannot be brokered; refused")})continuebody = {"backend": conn.get("backend", backend), "provider": conn.get("provider"),"model": (conn.get("model") if conn.get("_model_resolved") else _map_model(conn, model_req)),@@ -7300,6 +7354,8 @@ async def _session_turns_data(sid: str, limit: int = 0) -> dict:# the model the turn asked for (a served model other than it on the SAME turn is a# substitution; a switch turn asks for another model on purpose)"model": rec.get("model") or None,+ # the model the CLI reported it ran, when it reported one+ "served_model": rec.get("served_model") or None,# WHY an incomplete turn is incomplete ("max_steps" | "timeout" |# "interrupted"), so the console can say what actually happened instead of# one banner for every cause. Absent on records from before the field.@@ -12467,6 +12523,31 @@ _BASE_CATALOG: dict[str, dict] = {("todo_write", "Todo"), ("skill", "Skill"), ("agent", "Subagent")],"tool_enforcement": "instruction",},+ "gemini": {+ "label": "Gemini CLI", "backend": "gemini", "status": "ready",+ "system_prompt": ("You are Gemini CLI, an autonomous coding agent. You work on a real "+ "git workspace with shell and file access, reading and editing files "+ "and running commands to complete the task end to end."),+ # run_shell_command/write_file/activate_skill/update_topic are live-turn verified+ # (2026-09-06, three real captured turns across the slides/sheets/videos starter kits —+ # the same fix that corrected _gemini_to_claude's tool_use field names surfaced these+ # real names). The rest (read_file/replace/search_file_content/glob/web_fetch/+ # google_web_search/write_todos/save_memory) are still doc-sourced, not yet seen live —+ # confirm before relying on any of THOSE for enforcement, the same silent-no-op trap the+ # opencode/qwen comments warn about. Note "replace", not "edit" — gemini-cli's own name+ # for the edit tool. update_topic isn't in gemini-cli's own public tool docs at all (the+ # kits' skills invoke it constantly for a running strategic-intent summary); it may be a+ # newer addition than the docs snapshot this catalog was first built from.+ "tools": [("run_shell_command", "Shell"), ("read_file", "File Read"),+ ("write_file", "File Write"), ("replace", "Edit"),+ ("search_file_content", "Search"), ("glob", "Glob"),+ ("web_fetch", "Web Fetch"), ("google_web_search", "Web Search"),+ ("write_todos", "Todo"), ("save_memory", "Memory"),+ ("activate_skill", "Skill"), ("update_topic", "Topic")],+ # No confirmed hard per-tool kill switch in headless mode (only --allowed-mcp-server-names+ # gates MCP servers) — instruction tier until proven otherwise, same as qwen/cline/codex.+ "tool_enforcement": "instruction",+ },"cline": {"label": "Cline", "backend": "cline", "status": "ready","system_prompt": ("You are Cline, an autonomous coding agent. You work on a real git "diff --git a/gateway/tests/test_gemini_backend.py b/gateway/tests/test_gemini_backend.pynew file mode 100644index 00000000..45489b96--- /dev/null+++ b/gateway/tests/test_gemini_backend.py@@ -0,0 +1,38 @@+"""The gemini backend (Gemini CLI, Google's native API) on the gateway side: wired into the ONE google+provider, refused in broker mode with the reason, the served model kept on the record."""+import sys+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+import app as gw # noqa: E402+++def test_the_gemini_backend_is_wired_into_the_one_google_provider():+ assert gw._INTEGRATION_WIRING[("google", "gemini")] == "google"+ assert gw._PROVIDER_CATALOG["google"]["base_url"] == "https://generativelanguage.googleapis.com/v1beta/openai"+ assert set(gw._MODEL_CATALOG["gemini"]["models"]) <= set(gw._VENDOR_MODELS["google"])+ assert gw._MODEL_CATALOG["gemini"]["default"] in gw._MODEL_CATALOG["gemini"]["models"]+ assert gw._BASE_CATALOG["gemini"]["backend"] == "gemini"+++def test_a_native_api_backend_is_refused_in_broker_mode_and_served_raw_in_owner_trust(monkeypatch):+ conn = {"name": "integration:Google AI Studio", "backend": "gemini", "provider": "google", "api_key": "AIza-t"}+ monkeypatch.setattr(gw, "SANDBOX_TRUST", "broker")+ monkeypatch.setattr(gw, "PUBLIC_BASE_URL", "https://hr.example")+ assert gw._auth_from_conn(conn, "sid1") is None+ # the same connection brokers fine for an OpenAI-shape backend+ assert gw._auth_from_conn({**conn, "backend": "pi", "provider": "openai-api"}, "sid1") is not None+ monkeypatch.setattr(gw, "SANDBOX_TRUST", "owner")+ out = gw._auth_from_conn(conn, "sid1")+ assert out and out.get("api_key") == "AIza-t"+++def test_the_served_model_rides_the_result_onto_the_record():+ ev = {"type": "result", "result": "PONG", "usage": {"input_tokens": 1, "output_tokens": 1}, "model": "gemini-3.5-flash"}+ assert ("result", {"text": "PONG", "usage": ev["usage"], "is_error": False, "model": "gemini-3.5-flash"}) in gw._blocks_from_canonical(ev)+ plain = {"type": "result", "result": "ok", "usage": None}+ assert ("result", {"text": "ok", "usage": None, "is_error": False, "model": ""}) in gw._blocks_from_canonical(plain)+ tr = gw._RespTranslator("resp_1", "gemini-3.6-flash", None, True, 0.0)+ tr._handle("result", {"text": "PONG", "usage": {"input_tokens": 1, "output_tokens": 1}, "is_error": False, "model": "gemini-3.5-flash"})+ assert tr.served_model == "gemini-3.5-flash"+ assert tr.record()["served_model"] == "gemini-3.5-flash" if hasattr(tr, "record") else Truediff --git a/runner/server.py b/runner/server.pyindex 07f10dd9..f7b39438 100644--- a/runner/server.py+++ b/runner/server.py@@ -360,6 +360,7 @@ HERMES_DEFAULT_MODEL = os.environ.get("HERMES_DEFAULT_MODEL", "gpt-5.4")PI_DEFAULT_MODEL = os.environ.get("PI_DEFAULT_MODEL", "gpt-5.4")OPENCODE_DEFAULT_MODEL = os.environ.get("OPENCODE_DEFAULT_MODEL", "gpt-5.4")QWEN_DEFAULT_MODEL = os.environ.get("QWEN_DEFAULT_MODEL", "qwen3.7-max")+GEMINI_DEFAULT_MODEL = os.environ.get("GEMINI_DEFAULT_MODEL", "gemini-3.6-flash")CLINE_DEFAULT_MODEL = os.environ.get("CLINE_DEFAULT_MODEL", "gpt-5.4")DSH_DEFAULT_MODEL = os.environ.get("DSH_DEFAULT_MODEL", "deepseek-v4-pro")CODEX_REASONING_EFFORT = os.environ.get("CODEX_REASONING_EFFORT", "medium")@@ -651,6 +652,14 @@ def _write_skills(cwd: str, skills: list[dict], backend: str = "claude") -> list# ~/.qwen/skills under the redirected HOME — the dir the shipped 0.22.1 creates itself.rootrels = [".harness/home/.qwen/skills"]entryroot = ".harness/home/.qwen/skills"+ elif backend == "gemini":+ # ~/.gemini/skills under the redirected HOME — live-verified (2026-09-06, 0.58.0): the+ # slides/sheets/videos starter-kit skills all activated correctly from this path via the+ # real activate_skill tool ("Resources loaded from .../.gemini/skills/<name>"), same+ # directory-drop shape as qwen's despite gemini-cli's own settings.json also documenting a+ # separate skills.enabled/disabled key — that key toggles skills, it doesn't relocate them.+ rootrels = [".harness/home/.gemini/skills"]+ entryroot = ".harness/home/.gemini/skills"elif backend == "opencode":# opencode's `skills` config key takes ARBITRARY paths ("Additional paths or URLs to# discover skills from"), so there is no per-CLI home directory to guess here — we write@@ -783,6 +792,8 @@ def _agent_doc_path(cwd: str, backend: str) -> pathlib.Path:the name we chose simply never sees the harness's instructions."""if backend == "qwen":return pathlib.Path(cwd) / "QWEN.md" # qwen-code's own context file (bundle default)+ if backend == "gemini":+ return pathlib.Path(cwd) / "GEMINI.md" # gemini-cli's own context.fileName defaultreturn pathlib.Path(cwd) / ("AGENTS.md" if backend in ("codex", "hermes", "pi", "dsh", "opencode", "cline")else "CLAUDE.md")@@ -2937,6 +2948,95 @@ def _build_qwen(provider: str, auth: Auth, model: str, prompt: str, cwd: str, enreturn cmd+# Path A only (Gemini API Key / Google AI Studio). Unlike qwen, upstream gemini-cli speaks NO+# OpenAI-compatible mode at all (that is a qwen-fork-only addition — see QWEN_PROVIDERS above),+# so there is no loopback-relay trick that lets any generic OpenAI/Anthropic-shaped integration+# drive this backend. A Vertex AI provider (service account) belongs here too in principle — the+# runner-side env is the same GOOGLE_APPLICATION_CREDENTIALS/GOOGLE_CLOUD_PROJECT/+# GOOGLE_CLOUD_LOCATION triple _build_claude's vertex branch already writes — but it is left OUT+# of this set until the gateway side decides how (or whether) to broker it; see the gateway's+# _BROKERABLE_PROVIDERS comment for bedrock/vertex.+GEMINI_PROVIDERS = {"google"}+++def _gemini_settings(home: pathlib.Path, mcp_servers: list[dict] | None) -> None:+ """~/.gemini/settings.json under the redirected HOME.++ mcpServers uses gemini-cli's own schema (command/args/env for stdio, url/httpUrl/headers for+ remote) — the same shape _qwen_settings already writes, because qwen inherited it unchanged+ from this fork point (confirmed against gemini-cli's published configuration reference).++ security.auth.selectedType is written explicitly rather than left to gemini-cli's own+ GEMINI_API_KEY auto-detection: every other backend in this file pins its auth type+ explicitly instead of relying on env-var presence alone (see qwen's --auth-type openai,+ passed even though OPENAI_API_KEY being set would likely auto-select it too), and gemini-cli+ publishes no non-interactive CLI flag equivalent to qwen's --auth-type — settings.json is the+ only documented way to pin it outside the interactive /auth prompt."""+ gdir = home / ".gemini"+ gdir.mkdir(parents=True, exist_ok=True)+ servers: dict = {}+ for i, sv in enumerate(mcp_servers or []):+ if not isinstance(sv, dict):+ continue+ name = _skill_dir_name(sv.get("name") or sv.get("id") or f"server{i}")+ url = (sv.get("url") or "").strip()+ if url:+ entry: dict = {"httpUrl": url}+ hdrs = sv.get("headers")+ if isinstance(hdrs, dict) and hdrs:+ entry["headers"] = {str(k): str(v) for k, v in hdrs.items()}+ elif sv.get("command"):+ cmd = sv["command"]+ argv = cmd if isinstance(cmd, list) else [str(cmd)]+ entry = {"command": argv[0], "args": [str(x) for x in argv[1:]] + [str(x) for x in (sv.get("args") or [])]}+ envv = sv.get("env")+ if isinstance(envv, dict) and envv:+ entry["env"] = {str(k): str(v) for k, v in envv.items()}+ else:+ continue+ servers[name] = entry+ cfg: dict = {"security": {"auth": {"selectedType": "gemini-api-key"}}}+ if servers:+ cfg["mcpServers"] = servers+ (gdir / "settings.json").write_text(json.dumps(cfg, indent=2))+++def _build_gemini(provider: str, auth: Auth, model: str, prompt: str, cwd: str, env: dict,+ resume_session_id: str | None = None, mcp_servers: list[dict] | None = None) -> list[str]:+ pr = provider or "google"+ if pr not in GEMINI_PROVIDERS:+ raise HTTPException(400, f"unknown gemini provider '{pr}' (one of {sorted(GEMINI_PROVIDERS)})")+ if not auth.api_key:+ raise HTTPException(400, "gemini needs an api_key (none configured)")+ home = pathlib.Path(cwd) / ".harness" / "home"+ home.mkdir(parents=True, exist_ok=True)+ env["HOME"] = str(home) # sessions/skills/settings live INSIDE the workspace+ env["GEMINI_API_KEY"] = auth.api_key+ _gemini_settings(home, mcp_servers)+ cmd = ["gemini", "-p", prompt, "-o", "stream-json", "-m", model,+ # Load-bearing, same risk class as qwen's --yolo: gemini-cli gates tool use behind a+ # per-workspace "folder trust" prompt and an approval mode, neither of which can be+ # answered interactively in headless mode. --approval-mode=yolo is the current+ # (non-deprecated) form of the old --yolo/-y flag; --skip-trust bypasses the trust+ # prompt for a workspace that (like every turn here) has never been seen before. Both+ # confirmed live (2026-09-06, 0.58.0): without them a fresh workspace either hangs on+ # the trust prompt or the model has no shell/write tool at all, exactly qwen's failure+ # mode without --yolo; with them, real shell/write/skill-activation calls went through+ # across three starter-kit turns (slides, sheets, videos).+ "--approval-mode", "yolo", "--skip-trust"]+ if resume_session_id:+ # gemini-cli's --resume takes ONLY "latest" or a numeric index into this project's own+ # session list, never an arbitrary id (unlike claude/qwen's -r <uuid>) — so the id this+ # runner tracks per turn cannot be passed through directly. "latest" is still correct+ # here specifically because HOME is redirected into THIS workspace's own checkpoint+ # (same as qwen): there is exactly one project's session history under it, so "latest"+ # and "the session this resume call means" are the same session. Live-verified 2026-09-06:+ # a follow-up turn on an existing slides-kit session picked up its own prior context and+ # produced a real .pptx via the officecli skill, not a fresh unrelated session.+ cmd += ["--resume", "latest"]+ return cmd++CLINE_PROVIDERS = {"anthropic", "openai", "azure", "openai-api", "tokenrouter"}@@ -3458,6 +3558,95 @@ def _opencode_to_claude(obj: dict, state: dict) -> list[dict]:_opencode_to_claude.eof = _opencode_eof # type: ignore[attr-defined]+def _gemini_to_claude(obj: dict, state: dict) -> list[dict]:+ """Map ONE gemini-cli `--output-format stream-json` event to zero+ canonical claude+ stream-json events.++ Field names verified 2026-09 against the shipped 0.58.0 binary's own source (the bundle+ ships de-minified enough to grep: bundle/gemini-*.js, StreamJsonFormatter.emitEvent call+ sites) — not the public docs, which name the event TYPES but publish no field-level JSON+ example. The first version of this function guessed field names from the docs alone and+ every guess for tool_use/tool_result was wrong (id/name/input do not exist on the wire);+ it shipped, ran for real against a live key, and every tool call rendered as a content-free+ "Tool" row — caught from an actual failed turn (slides kit, 2026-09-06), not from re-reading+ the docs harder. Confirmed shapes, straight from the emitEvent() call sites:++ init: {type, timestamp, session_id, model}+ message: {type, timestamp, role: "user"|"assistant", content: str, delta?: bool}+ tool_use: {type, timestamp, tool_name, tool_id, parameters}+ tool_result: {type, timestamp, tool_id, status: "success"|"error", output?,+ error?: {type, message}}+ result: {type, timestamp, status: "success"|"error", stats,+ error?: {type, message}} — NO text field on success; the final answer+ only ever arrives via accumulated `message` deltas, same as the one-shot+ `--output-format json` mode's separate {response, stats, error} shape does+ NOT apply here.+ error: {type, timestamp, severity, message} — documented as "non-fatal", and+ every fatal path in the source emits its OWN terminal `result` event+ separately (verified: the max-turns-exceeded handler, tool fatal-error+ handler, and top-level catch all construct `type:"result", status:"error"`+ themselves) — so this type is informational, not a turn-ending signal, and+ must not be promoted into a synthetic result the way v1 of this function did.+ """+ t = obj.get("type")+ if t == "init":+ return [{"type": "system", "subtype": "init",+ "session_id": obj.get("session_id"),+ "model": obj.get("model") or state.get("model")}]+ if t == "message":+ role = obj.get("role") or "assistant"+ text = obj.get("content") or ""+ if not text:+ return []+ if role == "assistant":+ state["final"] = state.get("final", "") + text+ return [{"type": role, "message": {"content": [{"type": "text", "text": text}]}}]+ if t == "tool_use":+ tuid = obj.get("tool_id") or "tool"+ name = obj.get("tool_name") or "tool"+ return [{"type": "assistant", "message": {"content": [+ {"type": "tool_use", "id": tuid, "name": name, "input": obj.get("parameters") or {}}]}}]+ if t == "tool_result":+ tuid = obj.get("tool_id") or "tool"+ err = obj.get("error") if isinstance(obj.get("error"), dict) else None+ content = obj.get("output") or (err or {}).get("message") or ""+ return [{"type": "user", "message": {"content": [+ {"type": "tool_result", "tool_use_id": tuid,+ "is_error": obj.get("status") == "error", "content": content}]}}]+ if t == "error":+ return [] # non-fatal by contract; the fatal path always emits its own `result` too+ if t == "result":+ err = obj.get("error") if isinstance(obj.get("error"), dict) else None+ msg = err.get("message") if err else None+ stats = obj.get("stats") if isinstance(obj.get("stats"), dict) else {}+ # The stats are keyed by the model the CLI actually called (convertToStreamStats, 0.58.0),+ # and the CLI rewrites some requested ids on the way (every "-flash" id becomes+ # gemini-3.5-flash on the API-key auth path, measured 2026-09-06): the served model rides+ # the result so the gateway can record a substitution instead of believing the request.+ models = stats.get("models") if isinstance(stats.get("models"), dict) else {}+ served = ",".join(k for k in models if isinstance(k, str) and k)+ ev = {"type": "result", "subtype": "error" if err else "success", "is_error": bool(err),+ "result": msg or state.get("final", ""), "usage": _gemini_usage(stats)}+ if served:+ ev["model"] = served+ return [ev]+ return [obj]+++def _gemini_usage(stats: dict) -> dict:+ """gemini-cli's result stats in the runner's usage contract. Its `input_tokens` is the whole+ prompt INCLUDING the cached part and `cached` is that part (its own `input` is the fresh count+ and agrees), so the fresh input is the difference, the same subtraction the codex path makes;+ without it the cached prefix (8k tokens of system prompt on a one-word turn) would be billed+ at the full input rate."""+ u = _norm_token_usage(stats)+ if isinstance(stats, dict) and isinstance(stats.get("cached"), (int, float)) and stats["cached"] > 0:+ cached = int(stats["cached"])+ u["cache_read_tokens"] = cached+ u["input_tokens"] = max(int(u.get("input_tokens") or 0) - cached, 0)+ return u++# Registry — providers/default_model/normalize per backend. The cmd build + run loop is dispatched# in turn(): claude/codex run through _run_turn_bg over stdout JSONL; hermes has its own driver# (_run_hermes_bg — DB-polling, no stdout events), so it carries no normalizer.@@ -3479,6 +3668,10 @@ BACKENDS = {# names) — so its normalizer IS the claude passthrough."qwen": {"providers": sorted(QWEN_PROVIDERS), "default_model": QWEN_DEFAULT_MODEL,"normalize": _claude_passthrough},+ # gemini's native stream-json is its OWN schema, not claude's — see _gemini_to_claude's+ # docstring for why this cannot reuse the qwen row's passthrough despite the fork lineage.+ "gemini": {"providers": sorted(GEMINI_PROVIDERS), "default_model": GEMINI_DEFAULT_MODEL,+ "normalize": _gemini_to_claude},"cline": {"providers": sorted(CLINE_PROVIDERS), "default_model": CLINE_DEFAULT_MODEL,"normalize": _cline_to_claude},}@@ -4513,8 +4706,12 @@ def turn(req: TurnReq, identifier: str = "") -> dict:# complied, codex used the tool anyway. That is why the console calls it a request rather# than a block. Written here once rather than as two divergent branches — hermes previously# had neither, and silently ignored every disabled tool.+ # gemini — same tier, no confirmed per-tool switch in headless mode (see _BASE_CATALOG's+ # "gemini" entry). UHP §4.3 requires this be conveyed as a standing instruction rather than+ # silently dropped wherever it can't be a hard block, so it goes in this set rather than+ # being left out of it — the same class of gap this comment already names for hermes.agent_doc = req.agent_doc or ""- if backend in ("codex", "hermes", "dsh") and req.tools_disabled:+ if backend in ("codex", "hermes", "dsh", "gemini") and req.tools_disabled:_off = ", ".join(t for t in req.tools_disabled if t)if _off:agent_doc = ((agent_doc + "\n\n") if agent_doc.strip() else "") + \@@ -4589,6 +4786,10 @@ def turn(req: TurnReq, identifier: str = "") -> dict:model = model or QWEN_DEFAULT_MODELcmd = _build_qwen(req.provider, auth, model, req.prompt, cwd, env,resume_session_id=req.resume_session_id, mcp_servers=req.mcp_servers)+ elif backend == "gemini":+ model = model or GEMINI_DEFAULT_MODEL+ cmd = _build_gemini(req.provider, auth, model, req.prompt, cwd, env,+ resume_session_id=req.resume_session_id, mcp_servers=req.mcp_servers)elif backend == "cline":model = model or CLINE_DEFAULT_MODELcmd = _build_cline(req.provider, auth, model, req.prompt, cwd, env,diff --git a/runner/tests/test_gemini_build.py b/runner/tests/test_gemini_build.pynew file mode 100644index 00000000..df7913fe--- /dev/null+++ b/runner/tests/test_gemini_build.py@@ -0,0 +1,199 @@+"""The gemini backend (Path A: Gemini API Key only). The normalizer's event field names are+verified against the shipped 0.58.0 binary's own source (see _gemini_to_claude's docstring);+_build_gemini's CLI flags (--approval-mode, --skip-trust, --resume latest) are live-turn+verified end to end (2026-09-06) but not against every code path — see its docstring."""+import json+import pathlib+import sys+import tempfile++sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))+from server import (Auth, _agent_doc_path, _build_gemini, _gemini_to_claude, # noqa: E402+ _gemini_usage, _norm_token_usage, BACKENDS)+++def _argv(**kw):+ d = tempfile.mkdtemp()+ env: dict = {}+ cmd = _build_gemini("google", Auth(api_key="AIza-t"), "gemini-3.6-flash", "do it", d, env, **kw)+ return cmd, d, env+++def test_argv_is_headless_stream_json():+ cmd, _, _ = _argv()+ assert cmd[:3] == ["gemini", "-p", "do it"]+ assert ["-o", "stream-json"] == cmd[3:5]+ assert ["-m", "gemini-3.6-flash"] == cmd[5:7]+++def test_approval_and_trust_flags_present():+ """Both are load-bearing the same way qwen's --yolo is: without an approval mode headless+ runs cannot answer the tool-confirmation prompt, and without --skip-trust a never-before-seen+ workspace (every turn here is one) hits the folder-trust gate. Live-verified 2026-09-06."""+ cmd, _, _ = _argv()+ assert "--approval-mode" in cmd and "yolo" in cmd+ assert "--skip-trust" in cmd+++def test_resume_uses_latest_not_the_tracked_id():+ """gemini-cli's --resume only accepts "latest" or a numeric index, never an arbitrary id, so+ the turn's own resume_session_id cannot be passed through literally."""+ cmd, _, _ = _argv(resume_session_id="8e039a38-f91f")+ assert cmd[-2:] == ["--resume", "latest"]+ assert "8e039a38-f91f" not in cmd+++def test_no_resume_flag_on_a_fresh_turn():+ cmd, _, _ = _argv()+ assert "--resume" not in cmd+++def test_auth_is_environment_only_no_relay():+ """Unlike qwen, gemini has no OpenAI-compatible mode to ride a loopback relay through — the+ real key goes straight into GEMINI_API_KEY. (Whether/how this gets brokered in hosted mode is+ a gateway-side decision — see gateway's _BROKERABLE_PROVIDERS comment.)"""+ _, d, env = _argv()+ assert env["GEMINI_API_KEY"] == "AIza-t"+ st = pathlib.Path(d, ".harness", "home", ".gemini", "settings.json").read_text()+ assert "AIza-t" not in st+++def test_home_is_redirected_into_the_workspace():+ _, d, env = _argv()+ assert env["HOME"] == f"{d}/.harness/home"+++def test_settings_pin_the_auth_type_explicitly():+ """gemini-cli has no non-interactive CLI flag for auth type (unlike qwen's --auth-type), so+ settings.json is the only documented way to pin it instead of relying on GEMINI_API_KEY+ auto-detection."""+ _, d, _ = _argv()+ cfg = json.loads(pathlib.Path(d, ".harness", "home", ".gemini", "settings.json").read_text())+ assert cfg["security"]["auth"]["selectedType"] == "gemini-api-key"+++def test_unknown_provider_rejected():+ d = tempfile.mkdtemp()+ env: dict = {}+ try:+ _build_gemini("vertex", Auth(api_key="k"), "gemini-3.6-flash", "hi", d, env)+ assert False, "expected HTTPException"+ except Exception as e: # noqa: BLE001 — HTTPException import path differs by context+ assert "unknown gemini provider" in str(getattr(e, "detail", e))+++def test_missing_api_key_rejected():+ d = tempfile.mkdtemp()+ env: dict = {}+ try:+ _build_gemini("google", Auth(), "gemini-3.6-flash", "hi", d, env)+ assert False, "expected HTTPException"+ except Exception as e: # noqa: BLE001+ assert "api_key" in str(getattr(e, "detail", e))+++def test_mcp_settings_use_the_gemini_schema():+ d = tempfile.mkdtemp()+ env: dict = {}+ _build_gemini("google", Auth(api_key="k"), "gemini-3.6-flash", "hi", d, env,+ mcp_servers=[{"name": "docs", "url": "https://mcp.example/sse",+ "headers": {"Authorization": "Bearer t"}},+ {"name": "fs", "command": "npx", "args": ["-y", "server-fs"]}])+ cfg = json.loads(pathlib.Path(d, ".harness", "home", ".gemini", "settings.json").read_text())+ assert cfg["mcpServers"]["docs"] == {"httpUrl": "https://mcp.example/sse",+ "headers": {"Authorization": "Bearer t"}}+ assert cfg["mcpServers"]["fs"] == {"command": "npx", "args": ["-y", "server-fs"]}+++def test_normalizer_is_gemini_specific_not_the_claude_passthrough():+ """Unlike qwen, gemini's native stream-json is NOT claude's schema (different event type+ names — see _gemini_to_claude's docstring), so it needs its own normalizer registered."""+ assert BACKENDS["gemini"]["normalize"] is _gemini_to_claude+++def test_normalizer_maps_init_message_and_result():+ """Field names here are the shipped 0.58.0 binary's real ones (grepped from its own+ StreamJsonFormatter.emitEvent call sites), not guesses — see the module docstring."""+ state = {"model": "gemini-3.6-flash"}+ init = _gemini_to_claude({"type": "init", "session_id": "abc"}, state)+ assert init == [{"type": "system", "subtype": "init", "session_id": "abc",+ "model": "gemini-3.6-flash"}]+ msg = _gemini_to_claude({"type": "message", "role": "assistant", "content": "hi"}, state)+ assert msg == [{"type": "assistant", "message": {"content": [{"type": "text", "text": "hi"}]}}]+ # A real success `result` event carries NO text field at all (no `response` key) — the+ # final answer only ever arrives via accumulated `message` deltas, which is why state["final"]+ # (built from the "hi" message above) is what should come back here, not something read+ # off the result event itself.+ result = _gemini_to_claude({"type": "result", "status": "success", "stats": {}}, state)+ assert result == [{"type": "result", "subtype": "success", "is_error": False,+ "result": "hi", "usage": _norm_token_usage({})}]+++def test_normalizer_uses_the_real_tool_use_field_names():+ """Regression test for the bug an actual failed turn caught (slides kit, 2026-09-06): the+ first version of this function guessed id/name/input, which don't exist on the wire — every+ tool call rendered as a content-free generic "Tool" row. Real fields: tool_id/tool_name/+ parameters."""+ ev = _gemini_to_claude({"type": "tool_use", "tool_id": "call_1", "tool_name": "read_file",+ "parameters": {"path": "deck.json"}}, {})+ assert ev == [{"type": "assistant", "message": {"content": [+ {"type": "tool_use", "id": "call_1", "name": "read_file",+ "input": {"path": "deck.json"}}]}}]+++def test_normalizer_uses_the_real_tool_result_field_names():+ ok = _gemini_to_claude({"type": "tool_result", "tool_id": "call_1", "status": "success",+ "output": "file contents"}, {})+ assert ok == [{"type": "user", "message": {"content": [+ {"type": "tool_result", "tool_use_id": "call_1", "is_error": False,+ "content": "file contents"}]}}]+ err = _gemini_to_claude({"type": "tool_result", "tool_id": "call_2", "status": "error",+ "error": {"type": "ToolError", "message": "file not found"}}, {})+ assert err == [{"type": "user", "message": {"content": [+ {"type": "tool_result", "tool_use_id": "call_2", "is_error": True,+ "content": "file not found"}]}}]+++def test_normalizer_surfaces_the_real_error_message_on_a_failed_result():+ """Regression test for the other half of the same bug: a failed turn's `result` event has+ NO `response` field — the failure reason lives at error.message — but the old code fell back+ to state["final"], which is whatever assistant text happened to stream before the failure+ (in the real failed turn this caught, that was the FIRST sentence of a 5-minute task,+ rendered as if it were the error)."""+ state = {"final": "I will activate the slide-design skill to retrieve the schema."}+ result = _gemini_to_claude({"type": "result", "status": "error", "stats": {},+ "error": {"type": "FatalToolExecutionError",+ "message": "tool call exceeded the turn budget"}}, state)+ assert result == [{"type": "result", "subtype": "error", "is_error": True,+ "result": "tool call exceeded the turn budget",+ "usage": _norm_token_usage({})}]+++def test_normalizer_drops_non_fatal_error_events():+ """`error` is documented as non-fatal, and every fatal path in the source emits its own+ terminal `result` event separately — promoting `error` into a synthetic result (what v1 of+ this function did) risks ending a turn early on a warning the CLI itself would have+ continued past."""+ assert _gemini_to_claude({"type": "error", "severity": "warning", "message": "retrying"}, {}) == []+++def test_instruction_file_is_gemini_md():+ assert _agent_doc_path("/ws", "gemini").name == "GEMINI.md"+++def test_the_result_carries_the_served_model_and_the_fresh_input_beside_the_cached():+ """Measured on the pinned 0.58.0 (2026-09-06): `-m gemini-3.6-flash` answered with stats keyed+ "gemini-3.5-flash", because the CLI rewrites every "-flash" id on the API-key auth path. The+ gateway can only record that substitution if the result says which model ran. The stats'+ input_tokens include the cached prefix; the usage contract wants the fresh input and the cached+ part apart."""+ stats = {"total_tokens": 10835, "input_tokens": 10532, "output_tokens": 2, "cached": 8118,+ "input": 2414, "duration_ms": 2919, "tool_calls": 0,+ "models": {"gemini-3.5-flash": {"total_tokens": 10835, "input_tokens": 10532,+ "output_tokens": 2, "cached": 8118, "input": 2414}}}+ out = _gemini_to_claude({"type": "result", "status": "success", "stats": stats}, {"final": "PONG"})+ assert out == [{"type": "result", "subtype": "success", "is_error": False, "result": "PONG",+ "usage": {"input_tokens": 2414, "output_tokens": 2, "cache_read_tokens": 8118},+ "model": "gemini-3.5-flash"}]+ assert _gemini_usage({}) == _norm_token_usage({}) # the same shape as every other normalizer+ assert _gemini_usage({"input_tokens": 100, "output_tokens": 5})["input_tokens"] == 100diff --git a/ui/src/components/HarnessLogo.tsx b/ui/src/components/HarnessLogo.tsxindex 890972b0..1d412997 100644--- a/ui/src/components/HarnessLogo.tsx+++ b/ui/src/components/HarnessLogo.tsx@@ -13,6 +13,9 @@ const LOGO: Record<string, string> = {opencode: '/logos/opencode.png',qwen: '/logos/qwen.png',cline: '/logos/cline.png',+ // gemini: deliberately absent. No brand asset has been added to /public/logos yet — Google's+ // mark isn't ours to fetch and drop in without checking its usage terms, so this backend falls+ // back to the generic glyph below until a properly sourced asset lands.};export function HarnessLogo({ id, size = 26 }: { id: string; size?: number }) {diff --git a/ui/src/lib/conversation.ts b/ui/src/lib/conversation.tsindex 9ccc3163..c75c5288 100644--- a/ui/src/lib/conversation.ts+++ b/ui/src/lib/conversation.ts@@ -57,7 +57,7 @@ export interface AsstMsg { role: 'assistant'; blocks: Block[]; files: RespFile[]// (they surface installed skills to the agent). They are never user-facing outputs, so they must// never render as output file cards, including on older sessions that captured them before the// gateway started excluding them.-const _INTERNAL_OUT = new Set(['AGENTS.md', 'CLAUDE.md', 'QWEN.md']);+const _INTERNAL_OUT = new Set(['AGENTS.md', 'CLAUDE.md', 'QWEN.md', 'GEMINI.md']);export const isInternalOutput = (name?: string) =>!!name && (_INTERNAL_OUT.has(name) || name.startsWith('.harness/') || name.includes('/.harness/'));export type Msg = UserMsg | AsstMsg;diff --git a/ui/src/lib/harness.ts b/ui/src/lib/harness.tsindex 7c8cce68..bad557a0 100644--- a/ui/src/lib/harness.ts+++ b/ui/src/lib/harness.ts@@ -20,7 +20,7 @@ export interface OobHarness {defaultModel?: string; // the backend default, NOT necessarily models[0]moreModels?: number; // "+N" pillstatus: 'ready' | 'soon';- backend: 'claude' | 'codex' | 'hermes' | 'pi' | 'dsh' | 'opencode' | 'qwen' | 'cline' | null; // gateway backend; null = coming soon+ backend: 'claude' | 'codex' | 'hermes' | 'pi' | 'dsh' | 'opencode' | 'qwen' | 'gemini' | 'cline' | null; // gateway backend; null = coming soonsystemPrompt: string; // the harness's built-in system prompt (shown read-only)tools: string[]; // built-in tools (read-only)skills: string[]; // built-in skills (read-only)@@ -87,6 +87,16 @@ export const OOB: OobHarness[] = [models: ['qwen3.7-max', 'qwen3.8-max', 'gpt-5.4', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-5.5', 'gpt-5.4-mini', 'gpt-5.2', 'claude-opus-5', 'claude-fable-5', 'claude-opus-4.8', 'claude-sonnet-5', 'claude-opus-4.7', 'claude-sonnet-4.6', 'claude-haiku-4.5', 'gemini-3.6-flash', 'gemini-3.8-flash', 'gemini-3.7-flash', 'gemini-3.5-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview', 'gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'kimi-k2.7-code', 'mistral-medium-3.5', 'step-3.7-flash'], defaultModel: 'qwen3.7-max', moreModels: 0,systemPrompt: 'You are Qwen Code, an autonomous coding agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',tools: [], skills: [] },+ { id: 'gemini', name: 'Gemini CLI', version: 'v0.58.0', backend: 'gemini', status: 'ready',+ // Google's own native models only (Path A: Gemini API Key) — this backend has no relay+ // reach into the gpt/claude/deepseek/etc catalogs the way qwen/pi/opencode do, because it+ // speaks neither the OpenAI nor the Anthropic wire protocol. Placeholder until the gateway's+ // /v1/models catalog for this backend is populated (see gateway's _MODEL_CATALOG["gemini"]).+ // the seven ids gemini-cli 0.58.0 serves as themselves on the API-key path (it rewrites every id ending in+ // "-flash" to gemini-3.5-flash); measured 2026-09-06, all five scenarios per id through this backend+ models: ['gemini-3.5-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview', 'gemini-2.5-pro', 'gemini-2.5-flash-lite'], defaultModel: 'gemini-3.5-flash', moreModels: 0,+ systemPrompt: 'You are Gemini CLI, an autonomous coding agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',+ tools: [], skills: [] },{ id: 'cline', name: 'Cline', version: 'v3.0.60', backend: 'cline', status: 'ready',// Placeholder only, like every list above: the gateway's catalog wins once fetched. Every// row completed a live substitution-checked turn through the gateway (2026-08-30 sweep).