Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions assets/antigravity.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"type": "boolean",
"description": "Suppress most toast notifications (rate limit, account switching). Recovery toasts always shown. Env: OPENCODE_ANTIGRAVITY_QUIET=1"
},
"toast_scope": {
"default": "root_only",
"type": "string",
"enum": [
"root_only",
"all"
]
},
"debug": {
"default": false,
"type": "boolean",
Expand Down Expand Up @@ -133,8 +141,7 @@
},
"cli_first": {
"default": false,
"type": "boolean",
"description": "Prefer gemini-cli routing before Antigravity for Gemini models. When false (default), Antigravity is tried first and gemini-cli is fallback."
"type": "boolean"
},
"account_selection_strategy": {
"default": "hybrid",
Expand All @@ -153,6 +160,27 @@
"default": true,
"type": "boolean"
},
"scheduling_mode": {
"default": "cache_first",
"type": "string",
"enum": [
"cache_first",
"balance",
"performance_first"
]
},
"max_cache_first_wait_seconds": {
"default": 60,
"type": "number",
"minimum": 5,
"maximum": 300
},
"failure_ttl_seconds": {
"default": 3600,
"type": "number",
"minimum": 60,
"maximum": 7200
},
"default_retry_after_seconds": {
"default": 60,
"type": "number",
Expand All @@ -165,6 +193,38 @@
"minimum": 5,
"maximum": 300
},
"request_jitter_max_ms": {
"default": 0,
"type": "number",
"minimum": 0,
"maximum": 5000
},
"soft_quota_threshold_percent": {
"default": 90,
"type": "number",
"minimum": 1,
"maximum": 100
},
"quota_refresh_interval_minutes": {
"default": 15,
"type": "number",
"minimum": 0,
"maximum": 60
},
"soft_quota_cache_ttl_minutes": {
"default": "auto",
"anyOf": [
{
"type": "string",
"const": "auto"
},
{
"type": "number",
"minimum": 1,
"maximum": 120
}
]
},
"health_score": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -255,6 +315,22 @@
"default": true,
"type": "boolean",
"description": "Enable automatic plugin updates. Env: OPENCODE_ANTIGRAVITY_AUTO_UPDATE=1"
},
"notify_on_account_error": {
"default": true,
"type": "boolean"
},
"telegram_bot_token": {
"type": "string"
},
"telegram_chat_id": {
"type": "string"
},
Comment on lines +319 to +328
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n 'telegram_bot_token|TELEGRAM_BOT_TOKEN' --type=ts -C3

Repository: NoeFabris/opencode-antigravity-auth

Length of output: 3107


🏁 Script executed:

# Look at the config schema to understand how env-vars are handled
fd -e ts config | head -20

Repository: NoeFabris/opencode-antigravity-auth

Length of output: 95


🏁 Script executed:

# Search for how env-vars are processed in config loading
rg -n 'OPENCODE_ANTIGRAVITY|process.env' --type=ts src/plugin/config -A2 -B2

Repository: NoeFabris/opencode-antigravity-auth

Length of output: 8458


🏁 Script executed:

sed -n '116,250p' src/plugin/config/loader.ts

Repository: NoeFabris/opencode-antigravity-auth

Length of output: 3913


Environment variable override for telegram_bot_token is documented but not implemented.

telegram_bot_token is a secret credential. The schema (line 446 in src/plugin/config/schema.ts) documents an env-var override OPENCODE_ANTIGRAVITY_TELEGRAM_BOT_TOKEN, but the applyEnvOverrides() function in src/plugin/config/loader.ts does not actually implement this override. The token is currently loaded only from config files, forcing users to store it in plaintext on disk.

Implement the env-var override in applyEnvOverrides() to allow users to set the token via environment variable (consistent with other config fields like quiet_mode, debug, log_dir, etc.), or remove the false documentation from the schema.

🤖 Prompt for AI Agents
In `@assets/antigravity.schema.json` around lines 319 - 328, The schema documents
an environment override OPENCODE_ANTIGRAVITY_TELEGRAM_BOT_TOKEN for the secret
field telegram_bot_token but applyEnvOverrides() in src/plugin/config/loader.ts
never reads that env var; update applyEnvOverrides() to check
process.env.OPENCODE_ANTIGRAVITY_TELEGRAM_BOT_TOKEN and, if present, set
config.telegram_bot_token to that value (mirroring how other flags like
quiet_mode/debug/log_dir are handled), ensuring the override takes precedence
over file values; alternatively, remove the env-var mention from the schema if
you prefer not to support runtime overrides.

"notification_cooldown_seconds": {
"default": 60,
"type": "number",
"minimum": 0,
"maximum": 300
}
},
"additionalProperties": false
Expand Down
76 changes: 76 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,86 @@ OPENCODE_ANTIGRAVITY_LOG_DIR=/path # log_dir
OPENCODE_ANTIGRAVITY_KEEP_THINKING=1 # keep_thinking
OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY=round-robin
OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1
OPENCODE_ANTIGRAVITY_TELEGRAM_BOT_TOKEN="your-bot-token" # Telegram notifications
OPENCODE_ANTIGRAVITY_TELEGRAM_CHAT_ID="your-chat-id" # Telegram chat ID
```

---

## Error Notifications

Get alerts when accounts encounter errors. Session continues with next account instead of stopping.

| Option | Default | Description |
|--------|---------|-------------|
| `notify_on_account_error` | `true` | Enable notifications when accounts fail |
| `telegram_bot_token` | - | Telegram bot token for remote notifications |
| `telegram_chat_id` | - | Your Telegram chat ID |
| `notification_cooldown_seconds` | `60` | Cooldown between notifications (prevents spam) |

### Telegram Setup (Optional)

Receive account error notifications directly to Telegram - useful for monitoring long-running agents.

**Step 1: Create a Telegram Bot**

1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
2. Send `/newbot` and follow the prompts
3. BotFather will give you a token like `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`

**Step 2: Get Your Chat ID**

1. Search for [@userinfobot](https://t.me/userinfobot) on Telegram
2. Send any message to it
3. It will reply with your chat ID (e.g., `123456789`)

**Step 3: Configure the Plugin**

Add to your `antigravity.json`:

```json
{
"$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json",
"telegram_bot_token": "123456789:ABCdefGHIjklMNOpqrsTUVwxyz",
"telegram_chat_id": "123456789"
}
```

Or via environment variables:

```bash
export OPENCODE_ANTIGRAVITY_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OPENCODE_ANTIGRAVITY_TELEGRAM_CHAT_ID="123456789"
```

**Step 4: Start Your Bot**

> ⚠️ You must send at least one message to your bot before it can message you.

1. Open your new bot in Telegram (use the link BotFather gave you)
2. Send any message (e.g., `/start`)
3. Now the plugin can send notifications to you!

### What You'll Receive

When an account encounters an error, you'll get a Telegram message like:

```
⚠️ Account Error
━━━━━━━━━━━━━━━━━━━━━━━━
📧 Account: user@gmail.com
❌ Error: invalid_grant
💬 Message: Token revoked - run `opencode auth login`
📊 Status: 401
🤖 Model: claude-sonnet-4-20250514
📋 Remaining: 2 account(s)
🕐 Time: 2025-02-08T10:30:00.000Z
```
Comment on lines +252 to +262
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language identifier to the fenced code block.

The static analysis tool (markdownlint MD040) flags this code block for missing a language specifier. Since this is a plain-text notification example, use text as the language.

Proposed fix
-```
+```text
 ⚠️ Account Error
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
⚠️ Account Error
━━━━━━━━━━━━━━━━━━━━━━━━
📧 Account: user@gmail.com
❌ Error: invalid_grant
💬 Message: Token revoked - run `opencode auth login`
📊 Status: 401
🤖 Model: claude-sonnet-4-20250514
📋 Remaining: 2 account(s)
🕐 Time: 2025-02-08T10:30:00.000Z
```
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)

[warning] 252-252: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In `@docs/CONFIGURATION.md` around lines 252 - 262, The fenced code block example
is missing a language identifier (triggering markdownlint MD040); update the
triple-backtick fence for that notification example to include the text language
specifier (change ``` to ```text) so the block is treated as plain text and the
linter warning is resolved.


The session will automatically continue with the next available account.

---

## Advanced Settings

> These settings are for edge cases. Most users don't need to change them.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"test:coverage": "vitest run --coverage",
"prepublishOnly": "npm run build",
"test:e2e:models": "npx tsx script/test-models.ts",
"test:e2e:regression": "npx tsx script/test-regression.ts"
"test:e2e:regression": "npx tsx script/test-regression.ts",
"prepare": "npm run build"
},
"peerDependencies": {
"typescript": "^5"
Expand Down
Loading