Add Antigravity backend via agy CLI#3
Open
fatwang2 wants to merge 3 commits into
Open
Conversation
… Cursor. Drives Google's new agy CLI (Go-based replacement for Gemini CLI shipped 2026-05-19) in headless mode: agy -p <prompt> --output-format stream-json --yolo. Auth is handled by the CLI itself via Google Sign-In keyring or ANTIGRAVITY_API_KEY; session resume mirrors the existing --resume flow. Parses agy's stream-json event vocabulary (init/message/tool_use/ tool_result/error/result) and maps tool names to Claude Code's so the dispatcher's plan parser works unchanged. Same structure as cursor.ts. Co-authored-by: multica-agent <github@multica.ai>
agy v1.0.0 (verified via `agy --help`) does not support `--output-format`, `--yolo`, `--resume`, or `-m`. Calling with those flags caused `flags provided but not defined` and the process exited with code 2. Use the documented flags only: --print non-interactive single-prompt mode --dangerously-skip-permissions auto-approve tools (no TTY) --conversation <id> resume a previous conversation `agy --print` streams the final assistant response as plain text on stdout, so we accumulate stdout chunks and emit text AgentMessages directly rather than parsing a stream-json schema that does not exist yet. Surface stderr in the failure path so future flag mismatches are visible in the dispatcher log. Co-authored-by: multica-agent <github@multica.ai>
…rously-skip-permissions - Implement snapshotConversationIds() and detectNewConversationId() in the Antigravity backend to recover the generated/reused conversation ID from ~/.gemini/antigravity-cli/conversations/<uuid>.pb and pass it via AgentResult.sessionId so that future follow-up turns can resume the session. - Pin the Antigravity workspace using --add-dir pointing to the spawned process's working directory so that agy doesn't fall back to ~/.gemini/antigravity-cli/scratch and ignore the repo. - In claude-code.ts, map the bypassPermissions permission mode to pass the --dangerously-skip-permissions CLI flag instead of --permission-mode bypassPermissions. - Update README.md and README.zh-CN.md to document the correct agy invocation flags (--print --dangerously-skip-permissions --add-dir <cwd>), --conversation <id> for resuming, and the Claude Code bypass permissions mappings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/agents/antigravity.tsbackend that drives Google'sagyCLI (the Go-based replacement for Gemini CLI shipped 2026-05-19) in headless mode:agy -p <prompt> --output-format stream-json --yolo. Same structure ascursor.ts; only the event vocabulary differs (init/message/tool_use/tool_result/error/result).src/config.ts(ANTIGRAVITY_PATH,ANTIGRAVITY_MODELenv vars) and registered insrc/main.tsalongside the other backends.read_file→Read,run_shell_command→Bash, etc.) so the dispatcher's plan parser keeps working unchanged. Unknown names pass through verbatim.agycompletes Google Sign-In (cached in OS keyring), or setANTIGRAVITY_API_KEYfor scripted/CI use.--yoloauto-accepts tool execution since webhook flow has no TTY.--resume <session_id>pattern.DEFAULT_AGENTlist, dedicated Antigravity section, and the agent-resume mention now listsagy --resume.Why CLI and not the SDK
Same reasoning as Cursor — plain stdio keeps Bun out of the protocol critical path and matches the established backend pattern (
claude-codeandcursorare both CLI-driven). The CLI'sstream-jsonschema is documented in the Antigravity headless reference and covers session metadata, messages, tool calls, and final result stats, which is everything the dispatcher consumes today.Test plan
bun install && bun build src/main.ts— verified locally, bundles cleanlyagylocally (curl -fsSL https://antigravity.google/cli/install.sh | bash), complete Google Sign-In, run withDEFAULT_AGENT=antigravity, confirmdetectAvailable()listsantigravityagy --resume <session_id>read_file,run_shell_command, etc.) needs verification against a real agy stream-json event sample — the names inmapToolName()are best-effort since the headless reference doesn't enumerate them. Unknown names already pass through unchanged, so the mapping table is the only thing that may need tweaking after a live run.Closes WAN-141 (Multica:
db48f853-cc24-45ba-86c7-49be9576bd7e).