diff --git a/CHANGELOG.md b/CHANGELOG.md index a500739343b..5e6af0a3e99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). by plan weight instead of evenly. - New logo: a fox head in profile, white and silver on the black tile. +### Added + +- `deploy/t3code/agy-acp`: runs the standalone Antigravity CLI as T3 Code's Antigravity runtime, + so T3 Code shows the hub's whole Antigravity catalogue. Setup in `docs/t3code.md`. + ### Fixed - Two Mistral keys of one customer (a console key and a Vibe key) are recorded as one account, diff --git a/deploy/t3code/agy-acp b/deploy/t3code/agy-acp new file mode 100755 index 00000000000..5f78d160159 --- /dev/null +++ b/deploy/t3code/agy-acp @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +"""Run the standalone Antigravity CLI (`agy acp`) as T3 Code's Antigravity runtime. + +Why: the standalone CLI honours AGY_LLM_GATEWAY_URL, so its model list and requests come from +the home hub (t3code-proxy). T3 Code's bundled runtime ignores that setting. + +The only translation is the session mode names. T3 Code drives the runtime with the bundled +runtime's names; the standalone CLI uses different ones: + + T3 Code (bundled) standalone agy + default default + auto_edit accept-edits + yolo accept-edits (T3 Code answers permission requests itself in Full access) + +Everything else passes through byte for byte. To stop using this, clear the Antigravity +"Binary path" in T3 Code's provider settings. +""" +import json +import os +import subprocess +import sys +import threading + +TO_AGY = {"auto_edit": "accept-edits", "yolo": "accept-edits"} +FROM_AGY = {"accept-edits": "auto_edit"} +T3_MODES = [ + {"value": "default", "name": "Default", "id": "default"}, + {"value": "auto_edit", "name": "Accept edits", "id": "auto_edit"}, + {"value": "yolo", "name": "Full access", "id": "yolo"}, +] + + +def to_agent(message): + """Rewrite T3 Code's mode names in requests it sends to the CLI.""" + params = message.get("params") + if not isinstance(params, dict): + return message + method = message.get("method") + if method == "session/set_mode" and params.get("modeId") in TO_AGY: + params["modeId"] = TO_AGY[params["modeId"]] + elif method == "session/set_config_option" and params.get("configId") == "mode" and params.get("value") in TO_AGY: + params["value"] = TO_AGY[params["value"]] + return message + + +def fix_config_options(options): + if not isinstance(options, list): + return + for option in options: + if isinstance(option, dict) and (option.get("id") == "mode" or option.get("category") == "mode"): + option["options"] = [{"value": m["value"], "name": m["name"]} for m in T3_MODES] + option["currentValue"] = FROM_AGY.get(option.get("currentValue"), option.get("currentValue")) + + +def fix_modes(modes): + if not isinstance(modes, dict): + return + modes["availableModes"] = [{"id": m["id"], "name": m["name"]} for m in T3_MODES] + modes["currentModeId"] = FROM_AGY.get(modes.get("currentModeId"), modes.get("currentModeId")) + + +def to_client(message): + """Present the CLI's modes under the names T3 Code expects.""" + result = message.get("result") + if isinstance(result, dict): + fix_config_options(result.get("configOptions")) + fix_modes(result.get("modes")) + params = message.get("params") + if isinstance(params, dict): + update = params.get("update") + if isinstance(update, dict): + fix_config_options(update.get("configOptions")) + if update.get("currentModeId") in FROM_AGY: + update["currentModeId"] = FROM_AGY[update["currentModeId"]] + return message + + +def pump(source, sink, rewrite): + for raw in iter(source.readline, b""): + line = raw + stripped = raw.strip() + if stripped.startswith(b"{"): + try: + line = (json.dumps(rewrite(json.loads(stripped)), separators=(",", ":")) + "\n").encode() + except (ValueError, TypeError): + line = raw + sink.write(line) + sink.flush() + try: + sink.close() + except OSError: + pass + + +def main(): + agy = os.path.expanduser("~/.local/bin/agy") + child = subprocess.Popen([agy, "acp", *sys.argv[1:]], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + inbound = threading.Thread(target=pump, args=(sys.stdin.buffer, child.stdin, to_agent), daemon=True) + inbound.start() + pump(child.stdout, sys.stdout.buffer, to_client) + sys.exit(child.wait()) + + +if __name__ == "__main__": + main() diff --git a/docs/t3code.md b/docs/t3code.md index 1455649b879..b329fbd842c 100644 --- a/docs/t3code.md +++ b/docs/t3code.md @@ -41,21 +41,43 @@ signs in directly and does not go through the hub. ## Antigravity (Gemini) -T3 Code's Antigravity provider runs the Antigravity CLI (`agy`). Its enterprise model gateway -mode discovers models from the hub and sends requests through the hub's Antigravity accounts. -This needs a recent `agy` release with gateway support. +The hub can serve a Google account's whole Antigravity catalogue (Gemini, and the Claude and +GPT-OSS models Google offers) to T3 Code's Antigravity provider. Two pieces make that work. + +- **The Antigravity-only endpoint.** The Antigravity CLI's gateway mode takes its model list from + the endpoint it is pointed at. `https:///provider/antigravity` lists only the hub's + Antigravity accounts, so the CLI never offers your Claude or Codex subscription models. +- **The standalone CLI.** T3 Code's bundled Antigravity runtime ignores gateway mode and always + offers its own fixed Gemini list. The standalone `agy` CLI (1.5.9 or later) honours it. + [`deploy/t3code/agy-acp`](../deploy/t3code/agy-acp) starts `agy acp` for T3 Code and renames + the session modes between the two runtimes (`auto_edit` and `yolo` become `accept-edits`); + everything else passes through unchanged. + +Setup on the machine running T3 Code: + +1. Install the standalone CLI so `~/.local/bin/agy` exists. +2. Copy `deploy/t3code/agy-acp` to a folder of its own, for example `~/.local/share/t3-hub/`, + and link T3 Code's `localharness_external` next to it (T3 Code checks for it before it accepts + a custom runtime): + + ```sh + ln -s ~/.t3/tools/antigravity-acp//versions//localharness_external \ + ~/.local/share/t3-hub/localharness_external + ``` -1. Open **Settings → Providers → Antigravity**. -2. Set the sign-in method to **Gemini API key** and enter a hub access key. -3. Add these provider environment variables. Mark the access key as sensitive. +3. In **Settings → Providers → Antigravity**: sign-in method **Gemini API key** with a hub access + key, **Binary path** set to the copied `agy-acp`, and these environment variables (mark the + key as sensitive): ```text AGY_LLM_GATEWAY_URL=https:///provider/antigravity AGY_LLM_GATEWAY_API_KEY= + GOOGLE_GEMINI_BASE_URL=https:///provider/antigravity ``` -The model list comes from the hub and contains the models served by its Antigravity accounts. -The Google account sign-in method connects directly to Google. +4. Start one Antigravity thread. T3 Code fills the model picker from the first session. + +Clearing the binary path returns to T3 Code's bundled runtime and its fixed Gemini list. ## Mistral (OpenCode and Vibe)