@anthonyhaussman/opencode-agy-auth

中文文档
1.5.1发布于 2026/11/05MITTypeScriptES Module构建来源已验证近 30 天下载 6618
原始使用文档
文档目录11 节
  1. Features
  2. Installation
  3. Configuration
  4. Environment Variables
  5. Usage
  6. Companion Plugin: opencode-quota
  7. Disk Persistence
  8. Local Testing
  9. OpenCode Runtime Compatibility
  10. Pre-release Channel
  11. Star History & Support

OpenCode Antigravity CLI Auth Plugin

npm version npm downloads CI License GitHub stars

An OpenCode authentication plugin that enables seamless interaction with the Antigravity CLI (agy) by hooking into its authentication, quota retrieval, and dynamic model fetching layers.

Features

  • OAuth 2.0 Integration: Uses Antigravity's OAuth flows for authentication.
  • Dynamic Model Retrieval: Fetches available models based on user tier and current allocations.
  • Quota Tracking: Injects the agy_quota tool into OpenCode to check usage limits directly.
  • Traffic Simulation: Maintains background heartbeat with agy servers.
  • Dual OpenCode Compatibility: Natively supports both OpenCode v1 (>= 1.18.29) and OpenCode v2 out of the box without breaking changes.

Installation

Install the plugin from npm (or directly using local file configurations if developing):

npm install @anthonyhaussman/opencode-agy-auth

Configuration

Update your OpenCode configuration file (typically opencode.json at the root of your project or globally at ~/.config/opencode/opencode.json) to register the plugin and specify your Google Cloud Project ID.

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@anthonyhaussman/opencode-agy-auth"],
  "provider": {
    "google-agy": {
      "options": {
        "projectId": "your-google-cloud-project-id"
      }
    }
  }
}

By default, the plugin registers a specialized provider ID to interface with agy. You can switch your active OpenCode provider to agy or let the plugin inject authentication into your existing sessions.

Environment Variables

If you are running OpenCode in environments with specific requirements for Antigravity, you can use the following environment variables:

  • OPENCODE_AGY_PROJECT_ID: Specify your Google Cloud Project ID manually.
  • OPENCODE_AGY_AUTH_PROXY: Define a proxy if accessing authentication endpoints behind a corporate firewall.
  • OPENCODE_AGY_ENDPOINT: Override the default internal daily-cloudcode-pa.googleapis.com API endpoint.
  • OPENCODE_AGY_VERBOSE_LOGS: Set to "1" to enable verbose diagnostic logs for API calls and responses.

Usage

Once installed and configured, OpenCode will automatically authenticate against Antigravity CLI when interacting with eligible models. If no active session exists, you will be prompted to complete an OAuth login.

Additionally, you can check your quota using slash commands directly in your OpenCode prompt:

  • /agyquota - Per-model detail view. Shows remaining tokens, progress bars, and reset timers for every model variant. Use when you need the full breakdown of individual buckets.
  • /agyquotasummary - High-level grouped view. Shows weekly and 5-hour limits aggregated by model family. Use when you want a quick overview of your allowance across all models.

You can also ask naturally:

"What is my current agy quota?" "Show me my quota summary"

Companion Plugin: opencode-quota

This repository is compatible with opencode-quota, an OpenCode plugin for displaying quota information directly in your status bar or interface.

Follow the Google AGY Quick Setup Guide to set them up together.

To use both plugins side by side, register them in your opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "@anthonyhaussman/opencode-agy-auth",
    "opencode-quota"
  ],
  "provider": {
    "google-agy": {
      "options": {
        "projectId": "your-google-cloud-project-id"
      }
    }
  }
}

When used together, opencode-quota seamlessly visualizes rate limits and quotas for models authenticated through google-agy.

Disk Persistence

The plugin persists turn-state and retry-cooldown data to disk so that it survives OpenCode restarts. Files are stored under ~/.config/opencode/ (or %APPDATA%\opencode\ on Windows):

  • antigravity-turn-states.json - tracks thinking/reasoning state across request turns, with a 24-hour TTL and 5-second throttled writes using atomic tmp+rename.
  • Retry cooldowns are persisted via CooldownStore with the same atomic-write pattern.

Both stores initialize lazily at runtime - no filesystem reads occur at import time.

diskEnabled Parameter

TurnStateTracker accepts a diskEnabled constructor parameter (defaults to true):

import { TurnStateTracker } from "@anthonyhaussman/opencode-agy-auth/sdk/request/turn-state-tracker";

// Disk persistence enabled (default)
const tracker = new TurnStateTracker(true);

// Memory-only mode - no filesystem reads or writes
const tracker = new TurnStateTracker(false);

When diskEnabled is false, the tracker operates entirely in memory. All state is lost when the process exits. This is useful in restricted environments (containers, read-only filesystems) where disk access is unavailable or undesirable.

If disk initialization fails at runtime (permission error, corrupt file, etc.), the plugin automatically falls back to memory-only mode and logs a warning. No configuration is needed for normal use - disk persistence works out of the box.

Local Testing

To test and develop the plugin locally with OpenCode before publishing:

  1. Build the plugin locally: Clone the repository, install dependencies, and build the source code:

    npm install
    npm run build
    
  2. Configure OpenCode to use the local build: In the target project where you want to test the plugin, open your opencode.json (or ~/.config/opencode/opencode.json for global testing) and add the absolute local path to the plugin:

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["/absolute/path/to/opencode-agy-auth"]
    }
    

    Note: OpenCode also supports dropping plugin files directly into the .opencode/plugins/ folder in your project.

  3. Verify the plugin: Launch OpenCode in your target project. OpenCode will automatically resolve and load your local plugin directory. You can test your changes by running npm run build in the plugin directory and restarting your OpenCode session.

OpenCode Runtime Compatibility

The plugin natively supports both OpenCode v1 (>= 1.18.29) and OpenCode v2 out of the box through a dual-compatibility architecture:

  • OpenCode v1: Loaded via the server(options) hook with custom OAuth flow and provider setup.
  • OpenCode v2: Loaded via Plugin.define / setup(ctx) with native catalog transformations, AI SDK hooks, session interception, and PKCE OAuth integration.

No special flags or configurations are required - the plugin detects runtime automatically.

Pre-release Channel

To test bleeding-edge features or upcoming changes before official releases, configure the @alpha distribution tag:

npm install @anthonyhaussman/opencode-agy-auth@alpha

Or configure it directly in your opencode.json:

{
  "plugin": ["@anthonyhaussman/opencode-agy-auth@alpha"]
}

[!WARNING] Instability Warning: The @alpha release contains experimental features and active development builds. It may be unstable or cause disruptions in session authentication and model requests. Use only for testing and development. For day-to-day work, use the stable release.

Star History & Support

If this plugin saved you time or made using Antigravity models in OpenCode smoother, consider giving the repository a star on GitHub - it helps others discover the project.

版本与发布记录

@anthonyhaussman/opencode-agy-auth 共发布 209 个版本,首次发布于 2026/06/11;过去 12 个月发布了 209 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.5.1latest2026/11/05今天
1.5.1-alpha.0alpha2026/11/05今天
1.5.0-alpha.02026/11/042 天前
1.4.122026/11/015 天前
1.4.12-alpha.02026/11/015 天前
1.4.11-alpha.12026/10/307 天前

关于 @anthonyhaussman/opencode-agy-auth 的常见问题

@anthonyhaussman/opencode-agy-auth 是什么?

[](https://www.npmjs.com/

如何安装 @anthonyhaussman/opencode-agy-auth?

在项目目录运行 npm install @anthonyhaussman/opencode-agy-auth,或使用 pnpm add / yarn add / bun add。

@anthonyhaussman/opencode-agy-auth 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anthonyhaussman/opencode-agy-auth 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@anthonyhaussman/opencode-agy-auth 可以商用吗?

@anthonyhaussman/opencode-agy-auth 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@anthonyhaussman/opencode-agy-auth 的下载量有多少?

根据 npm 官方下载统计,@anthonyhaussman/opencode-agy-auth 在 2026/10/06 – 2026/11/04 这 30 天内被下载 6,618 次,日均约 221 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anthonyhaussman/opencode-agy-auth 还在维护吗?

最新版本 1.5.1 发布于 2026/11/05(今天);至今共发布 209 个版本,其中过去 12 个月发布了 209 个;首次发布于 2026/06/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。