# Antigravity Integration

Connect Google Antigravity to Capsule Security for complete visibility into AI coding agent activity, including prompts, agent responses, tool execution, and session context.

## Overview

This integration uses Antigravity's hooks system. Capsule generates a `hooks.json` that registers a `capsule-security` hook on every agent lifecycle event; each hook posts the event to Capsule with an embedded authentication token scoped to your organization.

The configuration comes in a Mac/Linux variant (self-contained shell commands) and a Windows variant (each hook invokes a PowerShell companion script).

The following hooks are configured:

| Hook Event | Description |
|  --- | --- |
| **PreInvocation** | User prompts before they reach the model (evaluated against policy) |
| **PostInvocation** | Agent responses |
| **PreToolUse** | Tool calls before execution (evaluated against policy) |
| **PostToolUse** | Tool calls after execution, with their results |
| **Stop** | End of an agent turn |


## Prerequisites

Before you begin, ensure you have:

- **Antigravity** installed on target devices
- A **Capsule Security** account with admin access


## Step 1: Generate the Hooks Configuration

1. Log in to the **Capsule Security** portal
2. Navigate to **Integrations** and locate **Antigravity**
3. Click **Install** - Capsule generates the hooks configuration with an embedded authentication token scoped to your organization
4. Optionally open **Advanced settings** to set the token lifetime (1-365 days, default 365)
5. Select your platform to download:
  - **Mac / Linux**: a single `hooks.json`
  - **Windows**: `capsule-antigravity-windows.zip`, containing `hooks.json` and the `CapsuleAntigravityHook.ps1` companion script


## Step 2: Deploy the Configuration

Place `hooks.json` at the global path for the platform, or in a project when you only want a single repository covered:

| Scope | Path |
|  --- | --- |
| macOS / Linux | `~/.gemini/config/hooks.json` |
| Windows | `%USERPROFILE%\.gemini\config\hooks.json` |
| Project (any OS) | `<project_root>/.agents/hooks.json` |


On Windows, also extract `CapsuleAntigravityHook.ps1` to `C:\Program Files\Capsule\CapsuleAntigravityHook.ps1` - the generated hook commands invoke the script from that path. macOS and Linux hook commands are self-contained and need no companion file.

For fleet-wide rollout, distribute the same files through your MDM. See the platform guides for step-by-step instructions:

- [Microsoft Intune](/guides/mdm-intune)
- [Jamf Pro](/guides/mdm-jamf)
- [Kandji](/guides/mdm-kandji)
- [JumpCloud](/guides/mdm-jumpcloud)
- [Microsoft SCCM](/guides/mdm-sccm)
- [ManageEngine Endpoint Central](/guides/mdm-manageengine)
- [Tanium](/guides/mdm-tanium)


## Step 3: Restart Antigravity

Hooks are loaded at application start:

1. Close all Antigravity windows
2. Reopen your workspace in Antigravity


## Step 4: Verify the Installation

1. Run a simple agent task to generate activity, for example:

```
Create a new file called test.txt with the content "Hello World"
```
2. Log in to the **Capsule Security** portal
3. Navigate to **Inventory > Agents** and confirm the agent appears
4. Click on the agent and review the audit logs to verify events are captured:
  - User prompt
  - Tool invocations
  - Agent responses
5. To view the full conversation, navigate to **Observability** and filter by **Activity Type - Session**


### Troubleshooting

If events do not appear:

1. **Verify the file location** - `hooks.json` must be at the global path for the platform, or under `.agents/` in the project you are working in
2. **Windows: verify the companion script** - `CapsuleAntigravityHook.ps1` must exist at `C:\Program Files\Capsule\CapsuleAntigravityHook.ps1`, where the hook commands invoke it
3. **Confirm the application was fully restarted** after deployment - hooks only load at start
4. **Validate the JSON** - a malformed `hooks.json` is skipped silently
5. **Check token expiration** - tokens default to 365 days; an expired token requires regenerating the configuration from the portal
6. **Contact Capsule Security support** if issues persist


## Policy Enforcement

`PreInvocation` and `PreToolUse` are blocking hooks: Capsule evaluates the prompt or tool call server-side and returns an allow or deny decision before Antigravity proceeds. The remaining hooks are observation-only.

To enforce policies on Antigravity activity:

1. Navigate to **Policies** in the portal
2. Define or assign policies that target Antigravity agents
3. Violations surface under **Detections**


## Security Considerations

Hooks execute with the signed-in user's environment credentials. Before deploying the configuration:

1. **Review all hook commands** in the generated `hooks.json`
2. **Verify the endpoint URL** matches your organization's Capsule instance
3. **Protect the authentication token** embedded in the configuration - never commit `hooks.json` to version control
4. **Shorten the token lifetime** under **Advanced settings** if your security policy requires it; shorter TTLs require redeploying the configuration more often


## Support

For help with this integration:

- **Email**: support@capsule.security
- **Include**: your organization ID, the platform the configuration was deployed to, and any error messages


## References

- [Antigravity Hooks Documentation](https://antigravity.google/docs/hooks)
- [Capsule Policies](https://docs.capsulesecurity.io/guides/policy-testing)
- [Capsule Webhook Events](https://docs.capsulesecurity.io/guides/webhook-events)