coderouter-cli 2.7.9__py3-none-any.whl → 2.7.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  """External coding-agent CLI adapter (``kind="agent_cli"``).
2
2
 
3
3
  This adapter invokes an external coding-agent CLI (Claude Code / Codex /
4
- Gemini / Grok) as a single one-shot ``exec`` and returns the agent's final
5
- answer as one ``prompt in → text out`` transformation. It is the in-core
6
- implementation of the external-agents-adapter design
4
+ Antigravity / Grok) as a single one-shot ``exec`` and returns the agent's
5
+ final answer as one ``prompt in → text out`` transformation. It is the
6
+ in-core implementation of the external-agents-adapter design
7
7
  (``docs/designs/external-agents-adapter.md``).
8
8
 
9
9
  Design in one paragraph
@@ -18,10 +18,10 @@ CodeRouter merely performs the one conversion. Following the
18
18
  ``openai_compat`` precedent, a *single* adapter class fronts *multiple*
19
19
  target agents, dispatched on the ``agent`` field.
20
20
 
21
- Implemented agents (Phase 1a + 1b + 1d)
22
- ========================================
21
+ Implemented agents (Phase 1 complete: 1a + 1b + 1c + 1d)
22
+ ==========================================================
23
23
 
24
- Three targets are implemented here:
24
+ Four targets are implemented here:
25
25
 
26
26
  * ``claude`` (Claude Code CLI, Phase 1a) — the most stable CLI, the most
27
27
  fine-grained safety controls, and the only one that emits
@@ -42,22 +42,44 @@ Three targets are implemented here:
42
42
  ``ProviderConfig.cost``, design §5.1.6). ``--no-memory`` is always passed
43
43
  so a user-level cross-session memory setting cannot leak state between
44
44
  requests.
45
-
46
- The remaining agent (gemini) is declared in the config schema so
47
- providers.yaml is forward-compatible, but constructing an adapter for it
48
- raises a clear ``AdapterError`` until its phase (1c) lands.
45
+ * ``antigravity`` (Antigravity CLI, command ``agy``, Phase 1c, in lieu of
46
+ ``gemini``) headless one-shot via ``agy -p <prompt> --mode ...``.
47
+ Google discontinued the legacy Gemini CLI's OAuth for individual
48
+ accounts in June 2026 (field-verified ``IneligibleTierError`` /
49
+ ``UNSUPPORTED_CLIENT``); its successor, the Antigravity CLI, is a
50
+ separate Go implementation (not a gemini-cli fork) fulfilling the design's
51
+ "gemini" slot. It has no stdin or ``--prompt-file`` channel — piped stdin
52
+ hangs the CLI (field-verified on agy 1.1.1) — so the prompt rides argv
53
+ (see the security note below). Output is plain text with no
54
+ ``--output-format`` flag, no token/cost figures, and no session id, so
55
+ usage is reported as zeros and meta is empty, mirroring grok's rationale.
56
+ It is also the only agent with a CLI-side self-termination flag
57
+ (``--print-timeout``), layered *underneath* the adapter's own
58
+ ``asyncio.wait_for`` + PGID SIGKILL rather than replacing it.
59
+
60
+ ``gemini`` itself is declared in the config schema for backward-compatible
61
+ config parsing, but constructing an adapter for it raises a clear
62
+ ``AdapterError`` with a migration pointer to ``agent="antigravity"``.
49
63
 
50
64
  Security (design §6, non-negotiable)
51
65
  ====================================
52
66
 
53
67
  * **allowlist argv only** — the child is launched with
54
68
  :func:`asyncio.create_subprocess_exec` and a list argv. ``shell=True`` is
55
- never used; the prompt is never subject to shell interpretation (claude
56
- and codex read it from stdin codex's argv carries a trailing ``-``
57
- sentinel making that explicit; grok reads it from a private ``0600``
58
- prompt file inside the resolved workdir its ``-p`` requires the prompt
59
- as an argv value, and argv would both hit Linux's ~128KiB
60
- ``MAX_ARG_STRLEN`` on huge prompts and leak the text into ``ps`` output).
69
+ never used. Prompt delivery is one of three mechanisms depending on the
70
+ agent: claude and codex read it from stdin (codex's argv carries a
71
+ trailing ``-`` sentinel making that explicit); grok reads it from a
72
+ private ``0600`` prompt file inside the resolved workdir (its ``-p``
73
+ requires the prompt as an argv value, and argv would both hit Linux's
74
+ ~128KiB ``MAX_ARG_STRLEN`` on huge prompts and leak the text into ``ps``
75
+ output); antigravity has neither a stdin nor a ``--prompt-file`` channel
76
+ (piped stdin hangs the CLI, field-verified), so its prompt is carried on
77
+ argv — accepting the same ``MAX_ARG_STRLEN`` cap and local ``ps``
78
+ visibility that grok's file delivery was specifically designed to avoid.
79
+ No shell is involved in any case (list argv, never shell text), and the
80
+ documented threat model (an isolated, single-operator workstation) treats
81
+ local ``ps`` visibility as an accepted, documented limitation for
82
+ antigravity rather than a defect.
61
83
  * **default read-only** — ``allow_file_writes=False`` /
62
84
  ``sandbox_mode="read_only"`` are the defaults, mapped to claude's
63
85
  ``--permission-mode plan``. Writes require explicit opt-in and the sandbox
@@ -82,6 +104,7 @@ import asyncio
82
104
  import contextlib
83
105
  import json
84
106
  import os
107
+ import re
85
108
  import shutil
86
109
  import signal
87
110
  import time
@@ -148,6 +171,29 @@ _CODEX_SANDBOX_ARGS = {
148
171
  "full_auto": ["-s", "workspace-write"],
149
172
  }
150
173
 
174
+ # sandbox_mode → antigravity ``--mode`` flags (design §5.4, Antigravity CLI
175
+ # 1.1.1, verified via facts-antigravity.md). ``agy --help`` only enumerates
176
+ # two ``--mode`` values (``plan`` / ``accept-edits``), so ``full_auto`` maps
177
+ # onto ``accept-edits`` plus the separate ``--dangerously-skip-permissions``
178
+ # flag (auto-approves all tool executions) rather than a third ``--mode``
179
+ # value. ``--sandbox`` is deliberately never used here: it has a known bypass
180
+ # bug when combined with ``--dangerously-skip-permissions`` (agy issue #36).
181
+ _ANTIGRAVITY_MODE_ARGS = {
182
+ "read_only": ["--mode", "plan"],
183
+ "edit": ["--mode", "accept-edits"],
184
+ "full_auto": ["--mode", "accept-edits", "--dangerously-skip-permissions"],
185
+ }
186
+
187
+ # Compiled ANSI escape sequence stripper for antigravity's plain-text output
188
+ # (design §5.1.6). Covers CSI sequences (``ESC [ ... final-byte``) plus bare
189
+ # OSC-style ``ESC ]`` sequences terminated by BEL or ``ESC \`` (kept simple —
190
+ # antigravity's TUI chrome is not fully specified, so this is a defensive
191
+ # best-effort strip, not a full ANSI parser).
192
+ _ANSI_RE = re.compile(
193
+ r"\x1b\[[0-9;?]*[ -/]*[@-~]" # CSI ... final byte
194
+ r"|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)" # OSC ... BEL or ST
195
+ )
196
+
151
197
 
152
198
  def _chunk_text(text: str, size: int = _STREAM_CHUNK_CHARS) -> Iterator[str]:
153
199
  """Split ``text`` into ``size``-char pieces for the pseudo-stream."""
@@ -156,20 +202,26 @@ def _chunk_text(text: str, size: int = _STREAM_CHUNK_CHARS) -> Iterator[str]:
156
202
 
157
203
 
158
204
  class AgentCliAdapter(BaseAdapter):
159
- """Invoke an external coding-agent CLI one-shot (claude + codex + grok).
205
+ """Invoke an external coding-agent CLI one-shot (claude + codex + grok +
206
+ antigravity).
160
207
 
161
208
  The ``agent`` field selects the argv builder / output parser via the
162
209
  dispatch tables built in :meth:`__init__`, mirroring how
163
210
  ``openai_compat`` fronts many HTTP backends from one class.
164
211
  """
165
212
 
213
+ _IMPLEMENTED_AGENTS = ("claude", "codex", "grok", "antigravity")
214
+
166
215
  def __init__(self, config: ProviderConfig) -> None:
167
216
  """Bind to a ``ProviderConfig`` and reject unsupported agents.
168
217
 
169
- Constructing an adapter for an agent other than ``claude`` /
170
- ``codex`` / ``grok`` raises a non-retryable :class:`AdapterError`
171
- the remaining target (gemini) is declared in the schema but not
172
- implemented until its phase (design §9).
218
+ ``gemini`` gets its own rejection message (non-retryable): Google
219
+ discontinued the Gemini CLI's OAuth for individual accounts in June
220
+ 2026, so this adapter points the operator at ``antigravity``
221
+ instead of a generic "not implemented" message. Any other
222
+ unimplemented value (future-proofing; currently none, since the
223
+ schema's ``Literal`` only allows the five known agents) falls back
224
+ to a generic message listing what IS implemented.
173
225
  """
174
226
  super().__init__(config)
175
227
  if config.agent_cli is None: # pragma: no cover - schema enforces this
@@ -179,34 +231,50 @@ class AgentCliAdapter(BaseAdapter):
179
231
  retryable=False,
180
232
  )
181
233
  self.acfg: AgentCliConfig = config.agent_cli
182
- if self.acfg.agent not in ("claude", "codex", "grok"):
234
+ if self.acfg.agent not in self._IMPLEMENTED_AGENTS:
235
+ if self.acfg.agent == "gemini":
236
+ raise AdapterError(
237
+ "agent 'gemini' is not supported: Google discontinued "
238
+ "the Gemini CLI for individual accounts (June 2026; "
239
+ "IneligibleTierError). Use agent='antigravity' "
240
+ "(Antigravity CLI, command 'agy') instead.",
241
+ provider=config.name,
242
+ retryable=False,
243
+ )
183
244
  raise AdapterError(
184
- f"agent {self.acfg.agent!r} is not implemented yet "
185
- f"(implemented: claude, codex, grok). Wait for Phase 1c.",
245
+ f"agent {self.acfg.agent!r} is not implemented "
246
+ f"(implemented: {', '.join(self._IMPLEMENTED_AGENTS)}).",
186
247
  provider=config.name,
187
248
  retryable=False,
188
249
  )
189
250
  # agent → argv builder / output parser dispatch tables. claude landed
190
- # in Phase 1a, codex in Phase 1b, grok in Phase 1d; Phase 1c adds
191
- # gemini.
251
+ # in Phase 1a, codex in Phase 1b, grok in Phase 1d, antigravity in
252
+ # Phase 1c — all four (design §9) are now implemented.
192
253
  self._builders = {
193
254
  "claude": self._build_claude_argv,
194
255
  "codex": self._build_codex_argv,
195
256
  "grok": self._build_grok_argv,
257
+ "antigravity": self._build_antigravity_argv,
196
258
  }
197
259
  self._parsers = {
198
260
  "claude": self._parse_claude,
199
261
  "codex": self._parse_codex,
200
262
  "grok": self._parse_grok,
263
+ "antigravity": self._parse_antigravity,
201
264
  }
202
- # Prompt delivery is per-agent: claude and codex read their prompt
203
- # from stdin (10MB cap; codex's argv carries a trailing "-" sentinel
204
- # making that explicit), which keeps argv free of the (potentially
205
- # huge) prompt text. grok's ``-p`` REQUIRES the prompt as its argv
206
- # value (piped stdin is only appended as extra context, verified on
207
- # v0.2.93), so grok gets the prompt via ``--prompt-file`` instead —
208
- # see ``_write_prompt_file`` for the rationale.
265
+ # Prompt delivery is per-agent, one of three mechanisms: claude and
266
+ # codex read their prompt from stdin (10MB cap; codex's argv carries
267
+ # a trailing "-" sentinel making that explicit), which keeps argv
268
+ # free of the (potentially huge) prompt text. grok's ``-p``
269
+ # REQUIRES the prompt as its argv value (piped stdin is only
270
+ # appended as extra context, verified on v0.2.93), so grok gets the
271
+ # prompt via ``--prompt-file`` instead — see ``_write_prompt_file``
272
+ # for the rationale. antigravity has NEITHER a stdin nor a
273
+ # ``--prompt-file`` channel — piped stdin hangs the CLI outright
274
+ # (field-verified on agy 1.1.1) — so its prompt rides argv instead;
275
+ # see ``_build_antigravity_argv`` for the tradeoff this accepts.
209
276
  self._uses_stdin = self.acfg.agent in ("claude", "codex")
277
+ self._uses_argv = self.acfg.agent == "antigravity"
210
278
 
211
279
  # ------------------------------------------------------------------
212
280
  # BaseAdapter contract
@@ -255,10 +323,16 @@ class AgentCliAdapter(BaseAdapter):
255
323
 
256
324
  # Agents that cannot take the prompt on stdin (grok) get it through a
257
325
  # private temp file inside the workdir; it is ALWAYS removed in the
258
- # ``finally`` below, including on timeout / exception paths.
259
- prompt_file = None if self._uses_stdin else self._write_prompt_file(prompt, workdir)
326
+ # ``finally`` below, including on timeout / exception paths. Argv
327
+ # agents (antigravity) get neither a file nor stdin bytes — the
328
+ # prompt text is handed straight to the builder instead.
329
+ prompt_file = (
330
+ None
331
+ if self._uses_stdin or self._uses_argv
332
+ else self._write_prompt_file(prompt, workdir)
333
+ )
260
334
  try:
261
- argv = self._builders[self.acfg.agent](workdir, prompt_file)
335
+ argv = self._builders[self.acfg.agent](workdir, prompt_file, prompt)
262
336
  # Resolve the executable to an absolute path so argv[0] is a
263
337
  # concrete binary independent of the child's minimal PATH
264
338
  # (design §6 allowlist).
@@ -297,6 +371,10 @@ class AgentCliAdapter(BaseAdapter):
297
371
  retryable=False,
298
372
  ) from exc
299
373
 
374
+ # Non-stdin agents (grok's file delivery, antigravity's argv
375
+ # delivery) get None here, so ``communicate()`` closes stdin
376
+ # immediately without writing to it — verified required for
377
+ # antigravity, whose CLI hangs if anything is piped to stdin.
300
378
  stdin_bytes = prompt.encode("utf-8") if self._uses_stdin else None
301
379
  try:
302
380
  stdout, stderr = await asyncio.wait_for(
@@ -366,7 +444,9 @@ class AgentCliAdapter(BaseAdapter):
366
444
  # claude argv builder + output parser
367
445
  # ------------------------------------------------------------------
368
446
 
369
- def _build_claude_argv(self, workdir: str, prompt_file: str | None = None) -> list[str]:
447
+ def _build_claude_argv(
448
+ self, workdir: str, prompt_file: str | None = None, prompt: str | None = None
449
+ ) -> list[str]:
370
450
  """Assemble the ``claude -p`` argv (design §5.1.5 / §5.4).
371
451
 
372
452
  Shape::
@@ -375,12 +455,13 @@ class AgentCliAdapter(BaseAdapter):
375
455
  --permission-mode <plan|acceptEdits> --add-dir <workdir>
376
456
 
377
457
  The prompt is fed on stdin (not argv), so it never appears here and
378
- ``prompt_file`` is ignored (it exists only to keep the builder
379
- signature uniform across agents). ``--bare`` is deliberately NOT
380
- added it would skip OAuth/keychain reads and break subscription
381
- auth (design §5.3.4).
458
+ both ``prompt_file`` and ``prompt`` are ignored (they exist only to
459
+ keep the builder signature uniform across agents see
460
+ ``_build_antigravity_argv`` for the one agent that needs ``prompt``).
461
+ ``--bare`` is deliberately NOT added — it would skip OAuth/keychain
462
+ reads and break subscription auth (design §5.3.4).
382
463
  """
383
- del prompt_file # claude takes the prompt on stdin, not from a file.
464
+ del prompt_file, prompt # claude takes the prompt on stdin.
384
465
  model = self.acfg.model or self.config.model
385
466
  argv = [self.acfg.command, "-p", "--output-format", "json", "--model", model]
386
467
  if self.acfg.max_turns is not None:
@@ -494,7 +575,9 @@ class AgentCliAdapter(BaseAdapter):
494
575
  # codex argv builder + output parser (Phase 1b)
495
576
  # ------------------------------------------------------------------
496
577
 
497
- def _build_codex_argv(self, workdir: str, prompt_file: str | None = None) -> list[str]:
578
+ def _build_codex_argv(
579
+ self, workdir: str, prompt_file: str | None = None, prompt: str | None = None
580
+ ) -> list[str]:
498
581
  """Assemble the ``codex exec`` argv (design §5.1.5 / §5.4, verified
499
582
  against codex-cli 0.144.1 — see ``_codex/facts-codex.md``).
500
583
 
@@ -504,19 +587,20 @@ class AgentCliAdapter(BaseAdapter):
504
587
  -m <model> -C <workdir> -s <read-only|workspace-write> -
505
588
 
506
589
  The prompt is fed on stdin (not argv), so it never appears here and
507
- ``prompt_file`` is ignored (it exists only to keep the builder
508
- signature uniform across agents) — the trailing ``-`` makes the
509
- stdin intent explicit to ``codex exec``, which otherwise treats a
510
- bare invocation with no PROMPT arg the same way but reads more
511
- ambiguously in a fixed argv list. ``--skip-git-repo-check`` is
512
- ALWAYS passed because the isolated workdir is not a git repository
513
- (without it the CLI exits 1). ``--ephemeral`` is ALWAYS passed so no
514
- session state persists to disk, matching the adapter's stateless
515
- one-shot ethos (the same rationale as grok's ``--no-memory``). codex
516
- has no ``--max-turns`` equivalent, so ``AgentCliConfig.max_turns`` is
517
- silently ignored here (documented in the schema).
590
+ both ``prompt_file`` and ``prompt`` are ignored (they exist only to
591
+ keep the builder signature uniform across agents) — the trailing
592
+ ``-`` makes the stdin intent explicit to ``codex exec``, which
593
+ otherwise treats a bare invocation with no PROMPT arg the same way
594
+ but reads more ambiguously in a fixed argv list. ``--skip-git-repo-
595
+ check`` is ALWAYS passed because the isolated workdir is not a git
596
+ repository (without it the CLI exits 1). ``--ephemeral`` is ALWAYS
597
+ passed so no session state persists to disk, matching the adapter's
598
+ stateless one-shot ethos (the same rationale as grok's
599
+ ``--no-memory``). codex has no ``--max-turns`` equivalent, so
600
+ ``AgentCliConfig.max_turns`` is silently ignored here (documented in
601
+ the schema).
518
602
  """
519
- del prompt_file # codex takes the prompt on stdin, not from a file.
603
+ del prompt_file, prompt # codex takes the prompt on stdin.
520
604
  model = self.acfg.model or self.config.model
521
605
  argv = [
522
606
  self.acfg.command,
@@ -666,7 +750,9 @@ class AgentCliAdapter(BaseAdapter):
666
750
  # grok argv builder + output parser (Phase 1d)
667
751
  # ------------------------------------------------------------------
668
752
 
669
- def _build_grok_argv(self, workdir: str, prompt_file: str | None = None) -> list[str]:
753
+ def _build_grok_argv(
754
+ self, workdir: str, prompt_file: str | None = None, prompt: str | None = None
755
+ ) -> list[str]:
670
756
  """Assemble the grok headless argv (design §5, grok CLI v0.2.93).
671
757
 
672
758
  Shape::
@@ -680,8 +766,11 @@ class AgentCliAdapter(BaseAdapter):
680
766
  would hit Linux's ~128KiB ``MAX_ARG_STRLEN`` on large prompts and
681
767
  leak the text into ``ps`` output. ``--no-memory`` is deliberate: it
682
768
  enforces the one-request-one-transformation statelessness even if
683
- the user's grok config enables cross-session memory.
769
+ the user's grok config enables cross-session memory. ``prompt`` is
770
+ ignored (it exists only to keep the builder signature uniform across
771
+ agents — grok never takes it on argv).
684
772
  """
773
+ del prompt
685
774
  if prompt_file is None: # pragma: no cover - generate() always supplies it
686
775
  raise AdapterError(
687
776
  "grok argv requires a prompt file",
@@ -774,6 +863,108 @@ class AgentCliAdapter(BaseAdapter):
774
863
  meta["coderouter_session_id"] = session_id
775
864
  return result, usage, meta
776
865
 
866
+ # ------------------------------------------------------------------
867
+ # antigravity argv builder + output parser (Phase 1c, in lieu of gemini)
868
+ # ------------------------------------------------------------------
869
+
870
+ def _build_antigravity_argv(
871
+ self, workdir: str, prompt_file: str | None = None, prompt: str | None = None
872
+ ) -> list[str]:
873
+ """Assemble the ``agy -p`` argv (design §5.1.5 / §5.4, verified
874
+ against Antigravity CLI 1.1.1 — see ``_codex/facts-antigravity.md``).
875
+
876
+ Shape::
877
+
878
+ agy -p <prompt> --model <m> --mode <plan|accept-edits>
879
+ [--dangerously-skip-permissions] --print-timeout <n>s
880
+
881
+ ``workdir`` is unused here — antigravity picks up its working
882
+ directory from the child process's ``cwd`` (set by ``generate()``),
883
+ and this adapter deliberately never passes ``--add-dir`` (design
884
+ keeps the argv minimal; only claude's multi-root model needs it).
885
+ ``prompt_file`` is unused (antigravity has no such flag).
886
+
887
+ Prompt-delivery tradeoff (read this before touching the ``-p``
888
+ line): agy has no stdin channel — piping content to stdin makes the
889
+ real CLI hang waiting for a response that never comes (field-
890
+ verified on 1.1.1) — and no ``--prompt-file`` equivalent either. The
891
+ prompt therefore rides argv as the ``-p`` value, which is the *only*
892
+ delivery mechanism the CLI offers. This caps practical prompt size
893
+ at Linux's ~128KiB ``MAX_ARG_STRLEN`` and exposes the prompt text to
894
+ ``ps`` on the local host — exactly the two costs grok's
895
+ ``--prompt-file`` delivery was built to avoid (see the module
896
+ docstring's security section). No shell is involved (list argv, not
897
+ shell text), and the adapter's threat model — an isolated,
898
+ single-operator workstation — accepts local ``ps`` visibility as a
899
+ documented limitation rather than a defect; there is no safer
900
+ channel to fall back to.
901
+
902
+ ``--print-timeout`` is antigravity's own self-termination clock,
903
+ derived from ``exec_timeout_s`` — it is the CLI's *first* wall
904
+ against a hung call; the adapter's outer ``asyncio.wait_for`` +
905
+ process-group ``SIGKILL`` remains the second, unconditional wall
906
+ (design §6). ``max_turns`` is never emitted: agy has no ``--max-
907
+ turns``-equivalent flag (like codex), so ``AgentCliConfig.max_turns``
908
+ is silently ignored here (documented in the schema). No ``--sandbox``
909
+ (known bypass bug alongside ``--dangerously-skip-permissions``,
910
+ agy issue #36) and no ``--add-dir`` are ever passed.
911
+ """
912
+ del prompt_file # antigravity has no prompt-file flag.
913
+ if prompt is None: # pragma: no cover - generate() always supplies it
914
+ raise AdapterError(
915
+ "antigravity argv requires the prompt text",
916
+ provider=self.name,
917
+ retryable=False,
918
+ )
919
+ model = self.acfg.model or self.config.model
920
+ argv = [self.acfg.command, "-p", prompt, "--model", model]
921
+ argv += self._antigravity_mode_args()
922
+ argv += ["--print-timeout", f"{int(self.acfg.exec_timeout_s)}s"]
923
+ return argv
924
+
925
+ def _antigravity_mode_args(self) -> list[str]:
926
+ """Map ``sandbox_mode`` → antigravity ``--mode`` flags, clamped.
927
+
928
+ Same clamp as claude/codex/grok (design §5.4): when
929
+ ``allow_file_writes`` is False the effective mode is forced to
930
+ ``read_only`` regardless of ``sandbox_mode``, so writes always
931
+ require the explicit opt-in.
932
+ """
933
+ mode = self.acfg.sandbox_mode if self.acfg.allow_file_writes else "read_only"
934
+ return list(_ANTIGRAVITY_MODE_ARGS[mode])
935
+
936
+ def _parse_antigravity(
937
+ self, stdout: bytes, stderr: bytes
938
+ ) -> tuple[str, dict[str, Any], dict[str, Any]]:
939
+ """Parse antigravity's plain-text ``-p`` output (verified agy 1.1.1).
940
+
941
+ There is no ``--output-format`` flag at all (agy's ``--help`` does
942
+ not list one) — output is whatever the model printed, decorated
943
+ with whatever terminal styling the CLI applied even in non-TTY runs.
944
+ Parsing is therefore: UTF-8 decode (defensively, replacing invalid
945
+ bytes) → strip ANSI escape sequences (``_ANSI_RE``, best-effort, see
946
+ its definition) → ``.strip()`` surrounding whitespace. Empty output
947
+ raises a retryable :class:`AdapterError` so the chain can fall
948
+ through. There is no token/cost figure and no session id anywhere
949
+ in agy's output, so ``usage`` is all-zeros (cost stays 0 unless the
950
+ operator sets ``ProviderConfig.cost``, same rationale as grok,
951
+ design §5.1.6) and ``meta`` is empty.
952
+ """
953
+ text = _ANSI_RE.sub("", stdout.decode("utf-8", "replace")).strip()
954
+ if not text:
955
+ raise AdapterError(
956
+ "antigravity produced no stdout",
957
+ provider=self.name,
958
+ retryable=True,
959
+ )
960
+ usage: dict[str, Any] = {
961
+ "prompt_tokens": 0,
962
+ "completion_tokens": 0,
963
+ "total_tokens": 0,
964
+ }
965
+ meta: dict[str, Any] = {}
966
+ return text, usage, meta
967
+
777
968
  # ------------------------------------------------------------------
778
969
  # helpers: prompt rendering, response shaping, env, workdir, kill
779
970
  # ------------------------------------------------------------------
@@ -168,13 +168,18 @@ class AgentCliConfig(BaseModel):
168
168
 
169
169
  Introduced by the external-agents-adapter design (Phase 1). One
170
170
  ``agent_cli`` sub-config drives the :class:`AgentCliAdapter`, which
171
- invokes an external coding-agent CLI (codex / gemini / grok / claude)
172
- in a single one-shot ``exec`` and returns the final answer as one
173
- ``prompt in → text out`` transformation. ``claude`` (Claude Code CLI,
174
- Phase 1a), ``codex`` (codex CLI, Phase 1b) and ``grok`` (grok CLI,
175
- Phase 1d) are implemented; ``gemini`` is declared at the schema level
176
- so configs are forward-compatible, but the adapter rejects it until its
177
- phase (1c) lands.
171
+ invokes an external coding-agent CLI (codex / gemini / grok / claude /
172
+ antigravity) in a single one-shot ``exec`` and returns the final answer
173
+ as one ``prompt in → text out`` transformation. ``claude`` (Claude Code
174
+ CLI, Phase 1a), ``codex`` (codex CLI, Phase 1b), ``grok`` (grok CLI,
175
+ Phase 1d) and ``antigravity`` (Antigravity CLI, Phase 1c, in lieu of
176
+ ``gemini``) are implemented. ``gemini`` is declared at the schema level
177
+ for backward-compatible config parsing, but the adapter rejects it with
178
+ a migration pointer: Google discontinued the (legacy) Gemini CLI's
179
+ OAuth for individual accounts in June 2026 (``IneligibleTierError`` /
180
+ ``UNSUPPORTED_CLIENT`` on the real client) and its successor is the
181
+ Antigravity CLI (command ``agy``, a separate Go implementation, not a
182
+ gemini-cli fork) — set ``agent: "antigravity"`` instead.
178
183
 
179
184
  Auth note (grok): the grok CLI uses OAuth credentials stored under
180
185
  ``~/.grok`` (``grok login``), which the adapter's HOME inheritance
@@ -190,25 +195,41 @@ class AgentCliConfig(BaseModel):
190
195
  ``CODEX_API_KEY`` (exec-only) or ``OPENAI_API_KEY`` (general) in
191
196
  ``passthrough_env``.
192
197
 
198
+ Auth note (antigravity): the Antigravity CLI uses a Google-account OAuth
199
+ login (free tier included), with credentials preferentially stored in
200
+ the OS keyring and mirrored under ``~/.gemini/antigravity-cli/``
201
+ (``credentials.enc`` / ``settings.json``) — the adapter's HOME (and, on
202
+ macOS, USER) inheritance already covers this, no extra config needed.
203
+ Any API-key environment variable for CI / non-interactive setups is
204
+ UNCONFIRMED (field reports disagree on the variable name) — this
205
+ docstring deliberately does not name one as authoritative; if you find
206
+ one that works, list it in ``passthrough_env``.
207
+
193
208
  Follows the ``extra="forbid"`` convention used across this module so a
194
209
  typo'd key fails at config-load rather than being silently ignored.
195
210
  """
196
211
 
197
212
  model_config = ConfigDict(extra="forbid")
198
213
 
199
- agent: Literal["codex", "gemini", "grok", "claude"] = Field(
214
+ agent: Literal["codex", "gemini", "grok", "claude", "antigravity"] = Field(
200
215
  ...,
201
216
  description=(
202
217
  "External coding-agent CLI to invoke. 'claude' (Phase 1a), "
203
- "'codex' (Phase 1b) and 'grok' (Phase 1d) are implemented; "
204
- "'gemini' (Phase 1c) pending."
218
+ "'codex' (Phase 1b), 'grok' (Phase 1d) and 'antigravity' "
219
+ "(Phase 1c, Google's Antigravity CLI, command 'agy') are "
220
+ "implemented. 'gemini' is rejected by the adapter — Google "
221
+ "discontinued the Gemini CLI for individual accounts in June "
222
+ "2026; use 'antigravity' instead."
205
223
  ),
206
224
  )
207
225
  command: str | None = Field(
208
226
  default=None,
209
227
  description=(
210
228
  "CLI executable name or absolute path (resolved via PATH). "
211
- "When unset, defaults to the ``agent`` name."
229
+ "When unset, defaults to the ``agent`` name — EXCEPT "
230
+ "'antigravity', whose binary is named ``agy`` (the product is "
231
+ "'Antigravity CLI' but the executable keeps the short, "
232
+ "pre-rename command name)."
212
233
  ),
213
234
  )
214
235
  workdir: str | None = Field(
@@ -291,9 +312,14 @@ class AgentCliConfig(BaseModel):
291
312
  ``sandbox_mode="read_only"`` is contradictory — the operator asked
292
313
  for writes while pinning a read-only sandbox. Fail fast at load,
293
314
  matching the module's other cross-field validators.
315
+
316
+ ``command`` defaults to the ``agent`` name for every agent EXCEPT
317
+ ``antigravity``, whose binary is ``agy`` — the product renamed from
318
+ Gemini CLI to Antigravity CLI, but the executable kept its short
319
+ pre-rename name.
294
320
  """
295
321
  if self.command is None:
296
- self.command = self.agent
322
+ self.command = "agy" if self.agent == "antigravity" else self.agent
297
323
  if self.allow_file_writes and self.sandbox_mode == "read_only":
298
324
  raise ValueError(
299
325
  "agent_cli: allow_file_writes=True conflicts with "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coderouter-cli
3
- Version: 2.7.9
3
+ Version: 2.7.10
4
4
  Summary: Local-first, free-first, fallback-built-in LLM router. Claude Code / OpenAI compatible.
5
5
  Project-URL: Homepage, https://github.com/zephel01/CodeRouter
6
6
  Project-URL: Repository, https://github.com/zephel01/CodeRouter
@@ -16,7 +16,7 @@ coderouter/output_filters.py,sha256=0ry_rPiS_kC-FnHgaNVP6v7e6Al2djxzu9vBzZ8kEkE,
16
16
  coderouter/token_estimation.py,sha256=iz22vZEEW2P7uKLB2pYvPNpIbZGbgXRO5MtfkS_-9Sk,7531
17
17
  coderouter/token_estimation_accurate.py,sha256=GTfzrBVnvAGjeVzmzAeUdOYZvWZKLAxcxPpFiJGlzjk,4609
18
18
  coderouter/adapters/__init__.py,sha256=7dIDSZ-FE_0iSqLSDc_lK1idRdLTKcM2hP9tCJipgPI,463
19
- coderouter/adapters/agent_cli.py,sha256=ChTheoyDz9SE86Htr-ZOwSW-M7XrbuUfed1daAlvXBI,42154
19
+ coderouter/adapters/agent_cli.py,sha256=0g0V92drEQLJACXq-Dn0hE-J6e3vmsuBr5UdnAkXJyk,52430
20
20
  coderouter/adapters/anthropic_native.py,sha256=CT9Hitun-c3z83YHT2zZXgwZpY3_t6eRnOfAmNud2aw,23610
21
21
  coderouter/adapters/base.py,sha256=ykKMaiIVVGr23oFFXilK2iP_YhI8-CtsEiJyFXaC9bE,10396
22
22
  coderouter/adapters/openai_compat.py,sha256=wcrd_UpV7N6ISpUyKvdFPGU-YjCrX5oMqGpjAFEeWfg,20356
@@ -25,7 +25,7 @@ coderouter/config/__init__.py,sha256=FODEn74fN-qZnt4INPSHswqhOlEgpL6-_onxsitSx8g
25
25
  coderouter/config/capability_registry.py,sha256=RZgzHF54dXy0CCDocRCz2ee21qXGbbgTSKTkRI9iLL4,16936
26
26
  coderouter/config/env_file.py,sha256=CoMK27fuAXm-NtoLzXb8yN2E-wDFjHQuFwiIlmgTBQw,10356
27
27
  coderouter/config/loader.py,sha256=FUEe8m4Tnmj_aul0vSctD8vKvNW-oLRoMRbTpSKqSmc,4077
28
- coderouter/config/schemas.py,sha256=fuqMuO9bafAhztUMtA6CwEBjSKNFyW-CIeen3Q0pRlg,87047
28
+ coderouter/config/schemas.py,sha256=sizuuxBgavGWaxBi7MtbLi0al-Ba72H7iVgI7CRYgMY,88835
29
29
  coderouter/data/__init__.py,sha256=uNyfD9jaCvTWsBAWtaw1Fr25OSxzv3psGMfBjT1z0Cc,328
30
30
  coderouter/data/model-capabilities.yaml,sha256=S9jt6SC6-3s2-icZ_n-a14iEMnc2yB1C2R6q-N_tZWQ,19309
31
31
  coderouter/guards/__init__.py,sha256=5qliYBqygvVPneej7nx0uSjxDKsz7t8VzvrDgVBJlvU,1170
@@ -69,8 +69,8 @@ coderouter/translation/__init__.py,sha256=PYXN7XVEwpG1uC8RLy6fvnGbzEZhhrEuUapH8I
69
69
  coderouter/translation/anthropic.py,sha256=aZkcYH4x82b0x7efJgJb9RWn9Hbyc9pEOthXe4vjUdU,11113
70
70
  coderouter/translation/convert.py,sha256=VV4kpu4dvLmGBmJfQnCLY5ryy_AnQcV2NuwjqRtaR8Q,52633
71
71
  coderouter/translation/tool_repair.py,sha256=DGOKArM53yfVbIfiAveoul1vGq9NEKmjagf43Qh4IkM,57630
72
- coderouter_cli-2.7.9.dist-info/METADATA,sha256=foZQpq3qpofluaktg5dWZBeLH9j7RUrD08n3wNS33p4,15546
73
- coderouter_cli-2.7.9.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
74
- coderouter_cli-2.7.9.dist-info/entry_points.txt,sha256=-dnLfD1YZ2WjH2zSdNCvlO65wYltM9bsHt9Fhg3yGss,51
75
- coderouter_cli-2.7.9.dist-info/licenses/LICENSE,sha256=wkEzoR86jFw33jvfOHjULqmkGEfxTFMgMaJnpR8mPRw,1065
76
- coderouter_cli-2.7.9.dist-info/RECORD,,
72
+ coderouter_cli-2.7.10.dist-info/METADATA,sha256=4AzX8XCERv5Hd1iywyybjR1gjsyfBh72bFF24YLH85U,15547
73
+ coderouter_cli-2.7.10.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
74
+ coderouter_cli-2.7.10.dist-info/entry_points.txt,sha256=-dnLfD1YZ2WjH2zSdNCvlO65wYltM9bsHt9Fhg3yGss,51
75
+ coderouter_cli-2.7.10.dist-info/licenses/LICENSE,sha256=wkEzoR86jFw33jvfOHjULqmkGEfxTFMgMaJnpR8mPRw,1065
76
+ coderouter_cli-2.7.10.dist-info/RECORD,,