The Antigravity Ruby SDK is an unofficial, community project. It is not an official Google product.
๐ Antigravity Ruby SDK
An elegant, expressive Ruby SDK for building autonomous AI agents with Google Antigravity.
Gem:
antigravity-sdkon RubyGems Source:palladius/antigravity-ruby-sdkon GitHub
Inspired by RubyLLM and the Ruby philosophy of developer happiness: configure agents, stream responses, load skills from GitHub, analyze workspaces, and attach safety guards -- all with minimal boilerplate.
agent = Antigravity::Agent.new(
skills: ["./skills/code-quality-review"],
workspace: "."
)
agent.ask("Review this codebase for best practices") { |chunk| print chunk.content }โก Zero-Install Quickstart with rv
No gem install needed โ run directly with rv:
# Simple chat
rv run ruby examples/04_simple_llm_chat.rb
# Workspace analysis (indexes your project, asks about it)
rv run ruby examples/05_workspace_analysis.rb ~/git/my-app
# Code quality review with skills
rv run ruby examples/06_skill_security_audit.rb .
# Load SRE skills from GitHub and draft a post-mortem
rv run ruby examples/07_skill_sre_postmortem.rb .Or with just:
just rv-chat # Simple LLM chat
just rv-workspace # Workspace analysis
just rv-skill-audit # Code review with local + inline skills
just rv-skill-sre-postmortem # SRE post-mortem from GitHub skills๐ Agent Skills
Skills are reusable instruction sets (SKILL.md files) that teach agents new capabilities. Load them from local folders, GitHub repos, or define them inline:
agent = Antigravity::Agent.new(
# Mix local and remote skills in the constructor
skills: [
"./skills/code-quality-review", # Local
"https://github.com/gemini-cli-extensions/sre", # GitHub (auto-clones all 16 skills!)
]
)
# Add a specific skill from a GitHub repo
agent.add_skill("https://github.com/gemini-cli-extensions/sre", skill_name: "skills/postmortem-generator")
# Define a skill inline (no file needed)
agent.add_inline_skill(
name: "emoji-formatter",
description: "Formats output with emoji severity markers",
instructions: "Use: CRITICAL: ๐จ, HIGH: ๐ด, MEDIUM: ๐ก, LOW: ๐ต, PASSED: โ
"
)
# Discover skills in a folder
Agent.list_skills("~/git/skillume/sre-extension/")
# => ["/path/to/anomaly-detection", "/path/to/cloud-logging", ...]Here, for example, we are using an inline skill for custom severity emojis (severity-emoji) alongside a local code quality audit skill (code-quality-review):
๐ Workspace Analysis
Point an agent at a directory โ it indexes the files and uses built-in tools (list_dir, view_file, grep_search) to explore:
agent = Antigravity::Agent.new(workspace: "~/git/my-project")
agent.connect!
agent.ask("What tech stack does this project use?") { |c| print c.content }
agent.close!๐ชต Automagic Logging
Dual-output logging out of the box:
-
log/antigravity.jsonlโ structured telemetry (request/response sizes, tool calls) -
log/antigravity.logโ compact human-readable one-liners - Auto-attaches
Rails.loggerin Rails apps
agent = Antigravity::Agent.new # Logging just works!
# => ๐ชต Logging to log/antigravity.jsonl๐ก๏ธ Guards & Sidecars
agent = Antigravity::Agent.new do |a|
a.system_instruction = "You are a helpful Ruby assistant."
a.attach_sidecar(Antigravity::Sidecar::AuditLogger.new("log/audit.jsonl"))
a.before_tool_call(&Antigravity::Guards::FileProtection.new)
a.after_tool_call(&Antigravity::Guards::SecretMasker.new)
end๐ Declarative Policy DSL
Control what your agent can and can't do with a beautiful, Rails-like DSL:
agent = Antigravity::Agent.new(policy: :default) # Use a preset
agent = Antigravity::Agent.new(policy: :cautious) # Locked down for prod
agent = Antigravity::Agent.new(policy: :turbo) # Wide open for dev
agent = Antigravity::Agent.new(policy: :auto) # Picks from RAILS_ENV!Or define a custom policy:
policy = Antigravity::Policy.define do
deny_all
allow :view_file
allow :grep_search
allow :run_command, when: cmd('echo', 'git status', 'bundle exec rspec')
allow :write_to_file
deny :write_to_file, when: path('.env', '*.key', '*.pem')
deny :run_command, when: cmd('rm', 'git reset --hard')
end
agent = Antigravity::Agent.new(policy: policy)โ ๏ธ Order does NOT matter!
The DSL is declarative โ like SQL, not like a script. Rules are resolved by precedence, not by insertion order. These two policies behave identically:
# Order A # Order B
Policy.define do Policy.define do
allow :run_command deny :run_command, when: cmd('rm')
deny :run_command, allow :run_command
when: cmd('rm') end
endPrecedence (highest wins):
-
Tool specificity:
deny :run_commandbeatsdeny_all -
Condition specificity:
deny :run_command, when: cmd('rm')beatsdeny :run_command -
Restrictiveness:
denybeatsconfirmbeatsallow
๐ Presets
| Preset | Shell | Writes | rm |
git reset --hard |
Best for |
|---|---|---|---|---|---|
๐ :cautious
|
Safe only (echo, pwd) |
Confirm | โ Deny | โ Deny | Production |
โ๏ธ :default
|
Allow | Allow | โ ๏ธ Confirm | โ ๏ธ Confirm | Day-to-day dev |
๐ :turbo
|
Allow | Allow | Allow | โ ๏ธ Confirm | Rapid prototyping |
๐งช :test
|
Allow | Allow | โ ๏ธ Confirm | โ Deny | CI / test suites |
๐ฎ :auto
|
โ | โ | โ | โ | Reads RAILS_ENV
|
๐ Sandbox directories
scratch/ and out/ are always writable, even in :cautious / production.
Use them as throwaway output dirs:
# In production โ this works!
agent.hooks.run_pre_tool(:write_to_file, path: 'scratch/debug.log', content: '...')
# => { allowed: true }
# But this is blocked:
agent.hooks.run_pre_tool(:write_to_file, path: 'app.rb', content: '...')
# => { allowed: false, reason: "Denied by policy" }๐ฎ Auto-mapping from RAILS_ENV
policy: :auto reads ANTIGRAVITY_ENV โ RAILS_ENV โ RACK_ENV:
| Environment | Preset |
|---|---|
development / dev
|
๐ :turbo
|
test |
๐งช :test
|
staging |
โ๏ธ :default
|
production / prod
|
๐ :cautious
|
| (unset) | โ๏ธ :default
|
See lib/antigravity/policy.rb and lib/antigravity/policy/constants.rb for the full implementation.
๐ Feature Parity with Python SDK
Full matrix:
docs/FEATURE_PARITY.md| Epic: GHI #20
| Feature | Status | Notes |
|---|---|---|
Agent lifecycle (connect!, close!, block) |
โ | + auto-connect on first ask
|
| Streaming responses | โ | Token-by-token via block |
| Custom tools (declarative + dynamic) | โ |
Tool DSL + Tool::Dynamic
|
| Agent Skills (local + GitHub + inline) | โ | Ruby-only: GitHub auto-clone, inline skills |
| Workspace analysis | โ | Built-in file tools |
| Guards (FileProtection, SecretMasker) | โ | Ruby-only feature |
| Sidecars (AuditLogger, VulnScanner) | โ | Ruby-only feature |
| Hooks (pre/post prompt, tool) | โ | + generic event system |
| Logging (JSONL + .log) | โ | Auto-attach |
| Declarative Policies | โ | #21 โ DSL, 5 presets, sandbox dirs |
| MCP Servers (Stdio + HTTP) | โ | Planned P0 |
| Multimodal Input (Image, Audio, Doc) | โ | Planned P1 |
| Structured Output (JSON Schema) | โ | Planned P1 |
| Stateful ToolContext | โ | Planned P1 |
| Session Persistence (save/resume) | โ | Planned P1 |
| Multi-Agent / Subagents | โ | Planned P2 |
| Triggers (background tasks) | โ | Planned P2 |
| Vertex AI backend | โ | Planned P1 |
| Response Cancellation | โ | Planned P1 |
| Budget Limits | โ | Planned P1 |
| OpenTelemetry | โ | Planned P2 |
| LiteRT / Ollama backends | โ | Planned P3 |
Overall: ~40% parity | 10 Ruby-only features | Convergence plan
๐งช Development
just test # 76 unit specs (fast, no harness needed)
just integration # Integration tests (requires GEMINI_API_KEY)
just rv-examples # Run all rv examples๐ค Telegram Integration
Chat with your Antigravity agent on Telegram โ text and voice messages with automatic transcription!
- Create a bot with @BotFather
- Add these to your
.env:
TELEGRAM_BOT_TOKEN=your-token-from-botfather
TELEGRAM_CHAT_ID=your-chat-id # Optional: enables startup greeting
TELEGRAM_SKILLS=./skills/my-skill # Optional: comma-separated skill paths/URLs- Run:
just rv-skill-telegramCommands: /start /skills /stop โ supports voice messages with ๐ฎ๐น๐ฌ๐ง๐ช๐ธ language detection.
See .env.dist for all available options.
๐ฆ Publishing to gem.coop
This gem can be published to the co-op RubyGems alternative gem.coop.
To push a release, obtain an API key from gem.coop and pass it to the push/release commands:
# Push a specific gem file
GEM_HOST_API_KEY=your_api_key_here gem push antigravity-sdk-VERSION.gem --host https://gem.coop/@palladius
# Or use rake release to tag and push automatically
GEM_HOST_API_KEY=your_api_key_here RUBYGEMS_HOST=https://gem.coop/@palladius rake release๐ Related Projects
| Project | Language | Link |
|---|---|---|
| Antigravity Python SDK (official) | Python | google-antigravity/antigravity-sdk-python |
| Antigravity Java SDK (unofficial) | Java | glaforge/antigravity-java-sdk |
| Antigravity Ruby SDK (this repo) | Ruby | palladius/antigravity-ruby-sdk |
| antigravity-sdk gem | RubyGems | rubygems.org/gems/antigravity-sdk |
| antigravity-sdk gem (co-op) | gem.coop | gem.coop/@palladius/antigravity-sdk |
๐ License
Apache 2.0 - see LICENSE for details.
The Antigravity Ruby SDK is an unofficial, community project. It is not an official Google product.




