@anthonyhaussman/opencode-agy-auth 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # OpenCode Antigravity CLI Auth Plugin
2
+
3
+ An [OpenCode](https://opencode.ai/) authentication plugin that enables seamless interaction with the Antigravity CLI (`agy`) by hooking into its authentication, quota retrieval, and dynamic model fetching layers.
4
+
5
+ ## Features
6
+
7
+ - **OAuth 2.0 Integration**: Uses Antigravity's OAuth flows for authentication.
8
+ - **Dynamic Model Retrieval**: Fetches available models based on user tier and current allocations.
9
+ - **Quota Tracking**: Injects the `agy_quota` tool into OpenCode to check usage limits directly.
10
+ - **Traffic Simulation**: Maintains background heartbeat with `agy` servers.
11
+
12
+ ## Installation
13
+
14
+ Install the plugin from npm (or directly using local file configurations if developing):
15
+
16
+ ```bash
17
+ npm install @anthonyhaussman/opencode-agy-auth
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ 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.
23
+
24
+ ```json
25
+ {
26
+ "$schema": "https://opencode.ai/config.json",
27
+ "plugin": ["@anthonyhaussman/opencode-agy-auth"],
28
+ "provider": {
29
+ "google-agy": {
30
+ "options": {
31
+ "projectId": "your-google-cloud-project-id"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ By default, the plugin registers a specialized provider ID to interface with `agy`.
39
+ You can switch your active OpenCode provider to `agy` or let the plugin inject authentication into your existing sessions.
40
+
41
+ ### Environment Variables
42
+
43
+ If you are running OpenCode in environments with specific requirements for Antigravity, you can use the following environment variables:
44
+
45
+ - `OPENCODE_AGY_PROJECT_ID`: Specify your Google Cloud Project ID manually.
46
+ - `OPENCODE_AGY_AUTH_PROXY`: Define a proxy if accessing authentication endpoints behind a corporate firewall.
47
+ - `OPENCODE_AGY_ENDPOINT`: Override the default internal `daily-cloudcode-pa.googleapis.com` API endpoint.
48
+ - `OPENCODE_AGY_VERBOSE_LOGS`: Set to `"1"` to enable verbose diagnostic logs for API calls and responses.
49
+
50
+ ## Usage
51
+
52
+ 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.
53
+
54
+ Additionally, you can quickly check your quota using the `/agyquota` slash command directly in your OpenCode prompt, or simply by asking:
55
+ > "What is my current agy quota?"
56
+
57
+ This calls the injected `agy_quota` tool to give you a real-time table of your current usage, tokens remaining, and reset times.
58
+
59
+ ## Local Testing
60
+
61
+ To test and develop the plugin locally with OpenCode before publishing:
62
+
63
+ 1. **Build the plugin locally**:
64
+ Clone the repository, install dependencies, and build the source code:
65
+ ```bash
66
+ npm install
67
+ npm run build
68
+ ```
69
+
70
+ 2. **Configure OpenCode to use the local build**:
71
+ 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:
72
+ ```json
73
+ {
74
+ "$schema": "https://opencode.ai/config.json",
75
+ "plugin": ["/absolute/path/to/opencode-agy-auth"]
76
+ }
77
+ ```
78
+ *Note: OpenCode also supports dropping plugin files directly into the `.opencode/plugins/` folder in your project.*
79
+
80
+ 3. **Verify the plugin**:
81
+ 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.
@@ -0,0 +1,16 @@
1
+ import { OpencodeClient } from '@opencode-ai/sdk';
2
+ import { Hooks } from '@opencode-ai/plugin';
3
+
4
+ type PluginClient = OpencodeClient;
5
+ interface PluginContext {
6
+ client: PluginClient;
7
+ }
8
+ type PluginResult = Hooks;
9
+
10
+ /**
11
+ * 为 Opencode 注册 Agy OAuth 提供者。
12
+ */
13
+ declare const AgyCLIOAuthPlugin: ({ client }: PluginContext) => Promise<PluginResult>;
14
+ declare const GoogleOAuthPlugin: ({ client }: PluginContext) => Promise<PluginResult>;
15
+
16
+ export { AgyCLIOAuthPlugin, GoogleOAuthPlugin, AgyCLIOAuthPlugin as default };