opencode-gemini-business 1.0.0
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/CHANGELOG.md +58 -0
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/README.ru.md +311 -0
- package/bin/cli.js +18 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +306 -0
- package/dist/index.js.map +1 -0
- package/dist/src/account-manager.d.ts +58 -0
- package/dist/src/account-manager.d.ts.map +1 -0
- package/dist/src/account-manager.js +190 -0
- package/dist/src/account-manager.js.map +1 -0
- package/dist/src/gemini-business-api.d.ts +67 -0
- package/dist/src/gemini-business-api.d.ts.map +1 -0
- package/dist/src/gemini-business-api.js +302 -0
- package/dist/src/gemini-business-api.js.map +1 -0
- package/dist/src/types.d.ts +104 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +66 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-02-15
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Initial release of opencode-gemini-business plugin
|
|
14
|
+
- Multi-account management with automatic rotation
|
|
15
|
+
- Support for round-robin, least-used, and random rotation strategies
|
|
16
|
+
- Automatic JWT token refresh
|
|
17
|
+
- Account health monitoring and auto-disable on errors
|
|
18
|
+
- CLI commands for account management:
|
|
19
|
+
- `add-account` - Add new Gemini Business account
|
|
20
|
+
- `list-accounts` - List all configured accounts
|
|
21
|
+
- `remove-account` - Remove an account
|
|
22
|
+
- `test-account` - Test account credentials
|
|
23
|
+
- OpenCode integration for seamless model usage
|
|
24
|
+
- Automatic retry with account failover
|
|
25
|
+
- OpenAI-compatible API format
|
|
26
|
+
- Comprehensive documentation:
|
|
27
|
+
- Configuration guide
|
|
28
|
+
- Troubleshooting guide
|
|
29
|
+
- API reference
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
- 🔄 Multi-account rotation with configurable strategies
|
|
33
|
+
- 🛡️ Automatic error handling and account failover
|
|
34
|
+
- 🔐 JWT token management with auto-refresh
|
|
35
|
+
- 📊 Account monitoring (usage tracking, error counting)
|
|
36
|
+
- 🚀 OpenAI-compatible API
|
|
37
|
+
- 🔧 Flexible configuration options
|
|
38
|
+
- 📝 Extensive CLI for account management
|
|
39
|
+
|
|
40
|
+
### Technical Details
|
|
41
|
+
- TypeScript implementation
|
|
42
|
+
- Node.js 18+ support
|
|
43
|
+
- ESM module format
|
|
44
|
+
- Vitest for testing
|
|
45
|
+
- GitHub Actions CI/CD
|
|
46
|
+
|
|
47
|
+
## Architecture
|
|
48
|
+
|
|
49
|
+
Based on:
|
|
50
|
+
- [opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth)
|
|
51
|
+
- [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth)
|
|
52
|
+
- [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth)
|
|
53
|
+
|
|
54
|
+
Integrates:
|
|
55
|
+
- [business-gemini-pool](https://github.com/ddcat666/business-gemini-pool)
|
|
56
|
+
|
|
57
|
+
[Unreleased]: https://github.com/izzzzzi/opencode-gemini-business/compare/v1.0.0...HEAD
|
|
58
|
+
[1.0.0]: https://github.com/izzzzzi/opencode-gemini-business/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenCode Gemini Business Plugin Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# 🔄 opencode-gemini-business
|
|
2
|
+
|
|
3
|
+
[🇬🇧 **English**](README.md) | [🇷🇺 Русский](README.ru.md)
|
|
4
|
+
|
|
5
|
+
> Multi-account Gemini Business pool with intelligent rotation for OpenCode
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.npmjs.com/package/opencode-gemini-business)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📖 Overview
|
|
14
|
+
|
|
15
|
+
**opencode-gemini-business** is an OpenCode plugin that enables multi-account rotation for **Gemini Business API**, providing automatic failover and load balancing across multiple accounts. Pool multiple Gemini Business accounts with intelligent rotation strategies to overcome rate limits.
|
|
16
|
+
|
|
17
|
+
**⚠️ Important**: This plugin uses the **official Gemini Business API** (`business.gemini.google`), NOT Google AI Studio.
|
|
18
|
+
|
|
19
|
+
## ✨ Key Features
|
|
20
|
+
|
|
21
|
+
| Feature | Description |
|
|
22
|
+
|---------|-------------|
|
|
23
|
+
| 🔄 **Multi-Account Rotation** | Automatically rotate between multiple Gemini Business accounts |
|
|
24
|
+
| 🛡️ **Automatic Failover** | Retry failed requests with different accounts seamlessly |
|
|
25
|
+
| 🔐 **Session Management** | Built-in XSRF token and session lifecycle management |
|
|
26
|
+
| ⚙️ **Flexible Strategies** | Round-robin, least-used, or random rotation |
|
|
27
|
+
| 📊 **Health Monitoring** | Track usage statistics and error counts per account |
|
|
28
|
+
| 🚀 **OpenCode Compatible** | Works seamlessly with OpenCode's provider system |
|
|
29
|
+
| 💾 **Persistent Config** | Secure storage in `~/.config/opencode/gemini-business-accounts.json` |
|
|
30
|
+
|
|
31
|
+
## 🤖 Supported Models
|
|
32
|
+
|
|
33
|
+
The plugin supports all Gemini Business models:
|
|
34
|
+
|
|
35
|
+
| Model | Context Length | Max Output | Best For |
|
|
36
|
+
|-------|---------------|------------|----------|
|
|
37
|
+
| `gemini-2.5-pro` | 1M tokens | 32K tokens | Complex reasoning, long documents |
|
|
38
|
+
| `gemini-2.5-flash` | 1M tokens | 8K tokens | Fast responses, simple tasks |
|
|
39
|
+
| `gemini-2.0-pro` | 2M tokens | 32K tokens | Massive context, deep analysis |
|
|
40
|
+
| `gemini-1.5-pro` | 2M tokens | 8K tokens | Production workloads |
|
|
41
|
+
| `gemini-1.5-flash` | 1M tokens | 8K tokens | Cost-effective development |
|
|
42
|
+
|
|
43
|
+
## 🔧 Installation & Configuration
|
|
44
|
+
|
|
45
|
+
### 📦 Install the Plugin
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g opencode-gemini-business
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or use with npx:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx opencode-gemini-business@latest
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### ⚙️ Configure OpenCode
|
|
58
|
+
|
|
59
|
+
Add to `~/.config/opencode/opencode.json`:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"plugins": ["opencode-gemini-business"],
|
|
64
|
+
"models": {
|
|
65
|
+
"gemini-business": {
|
|
66
|
+
"provider": "gemini-business",
|
|
67
|
+
"model": "gemini-2.5-pro",
|
|
68
|
+
"rotation_strategy": "round-robin"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 🔑 Extract Credentials
|
|
75
|
+
|
|
76
|
+
#### Method 1: Using Browser Extension (RECOMMENDED) ⚡
|
|
77
|
+
|
|
78
|
+
**Use the "Get cookies.txt LOCALLY" extension** to export cookies including HttpOnly:
|
|
79
|
+
|
|
80
|
+
1. **Install Extension**:
|
|
81
|
+
- [Chrome Web Store: Get cookies.txt LOCALLY](https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
|
|
82
|
+
- This extension can export **all cookies** including HttpOnly (which JavaScript cannot access)
|
|
83
|
+
|
|
84
|
+
2. **Login** to [Gemini Business](https://business.gemini.google)
|
|
85
|
+
|
|
86
|
+
3. **Click extension icon** → Export cookies for `business.gemini.google`
|
|
87
|
+
|
|
88
|
+
4. **Find in exported file**:
|
|
89
|
+
- `__Secure-C_SES`: `CSE.xxx...`
|
|
90
|
+
- `__Host-C_OSES`: `COS.xxx...`
|
|
91
|
+
|
|
92
|
+
5. **Get csesidx from URL**:
|
|
93
|
+
- Look at your browser URL: `?csesidx=1370433092`
|
|
94
|
+
- Copy the number after `csesidx=`
|
|
95
|
+
|
|
96
|
+
6. **Get team_id from Network tab**:
|
|
97
|
+
- F12 → **Network** tab
|
|
98
|
+
- Send a message to Gemini
|
|
99
|
+
- Find request to `biz-discoveryengine.googleapis.com`
|
|
100
|
+
- Click request → **Headers** → find `X-Goog-Team-Id: team_xxxxx`
|
|
101
|
+
|
|
102
|
+
7. **Add account** (see below)
|
|
103
|
+
|
|
104
|
+
#### Method 2: Manual Extraction via DevTools
|
|
105
|
+
|
|
106
|
+
1. **Login** to [Gemini Business](https://business.gemini.google)
|
|
107
|
+
|
|
108
|
+
2. **Open DevTools** (F12) → **Network tab**
|
|
109
|
+
|
|
110
|
+
3. **Send a message** to Gemini or refresh the page
|
|
111
|
+
|
|
112
|
+
4. **Find any request** to `biz-discoveryengine.googleapis.com`
|
|
113
|
+
|
|
114
|
+
5. **Copy from request headers**:
|
|
115
|
+
- `X-Goog-Team-Id` → this is your `team_id`
|
|
116
|
+
- Cookie: `__Secure-c_ses` → copy the value
|
|
117
|
+
- Cookie: `__Host-c_oses` → copy the value
|
|
118
|
+
- Find `csesidx` in request payload or headers
|
|
119
|
+
|
|
120
|
+
6. **Add account**:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
opencode-gemini-business add-account \
|
|
124
|
+
"My Account" \
|
|
125
|
+
"team_abc123" \
|
|
126
|
+
"secure_ses_cookie_value" \
|
|
127
|
+
"host_oses_cookie_value" \
|
|
128
|
+
"csesidx_value"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Or use environment variables**:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
export GEMINI_ACCOUNT_NAME="My Account"
|
|
135
|
+
export GEMINI_TEAM_ID="team_abc123"
|
|
136
|
+
export GEMINI_SECURE_C_SES="secure_ses_value"
|
|
137
|
+
export GEMINI_HOST_C_OSES="host_oses_value"
|
|
138
|
+
export GEMINI_CSESIDX="csesidx_value"
|
|
139
|
+
|
|
140
|
+
opencode-gemini-business add-account
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## 🚀 Usage
|
|
144
|
+
|
|
145
|
+
### Basic Usage
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Use with specific model
|
|
149
|
+
opencode run "Write a hello world in Python" --model=gemini-business
|
|
150
|
+
|
|
151
|
+
# Set as default
|
|
152
|
+
export OPENCODE_MODEL=gemini-business
|
|
153
|
+
opencode run "Your task here"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Model-Specific Usage
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Use Pro model for complex tasks
|
|
160
|
+
opencode run "Analyze this codebase architecture" --model=gemini-pro
|
|
161
|
+
|
|
162
|
+
# Use Flash model for quick tasks
|
|
163
|
+
opencode run "Fix this syntax error" --model=gemini-flash
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 🛠️ Account Management
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# List all accounts
|
|
170
|
+
opencode-gemini-business list-accounts
|
|
171
|
+
|
|
172
|
+
# Test specific account
|
|
173
|
+
opencode-gemini-business test-account <account_id>
|
|
174
|
+
|
|
175
|
+
# Remove account
|
|
176
|
+
opencode-gemini-business remove-account <account_id>
|
|
177
|
+
|
|
178
|
+
# Show help
|
|
179
|
+
opencode-gemini-business help
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 🔄 Rotation Strategies
|
|
183
|
+
|
|
184
|
+
| Strategy | Behavior | Use Case |
|
|
185
|
+
|----------|----------|----------|
|
|
186
|
+
| `round-robin` | Cycles through accounts in order | Balanced usage across all accounts |
|
|
187
|
+
| `least-used` | Selects account with oldest last_used timestamp | Minimize individual account usage |
|
|
188
|
+
| `random` | Random probabilistic selection | Unpredictable load distribution |
|
|
189
|
+
|
|
190
|
+
**Configure strategy** in OpenCode config:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"models": {
|
|
195
|
+
"gemini-business": {
|
|
196
|
+
"provider": "gemini-business",
|
|
197
|
+
"model": "gemini-2.5-pro",
|
|
198
|
+
"rotation_strategy": "least-used" // ← Change here
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## ❓ FAQ
|
|
206
|
+
|
|
207
|
+
<details>
|
|
208
|
+
<summary><b>Q: How do I handle session expiration?</b></summary>
|
|
209
|
+
|
|
210
|
+
The plugin automatically refreshes sessions. Sessions are cached for 50 minutes and auto-refresh when needed. If you see "Session has expired" errors, the plugin will create a new session automatically.
|
|
211
|
+
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
<details>
|
|
215
|
+
<summary><b>Q: Which model should I use?</b></summary>
|
|
216
|
+
|
|
217
|
+
- **Complex tasks**: `gemini-2.5-pro` or `gemini-2.0-pro` for best reasoning
|
|
218
|
+
- **Quick tasks**: `gemini-2.5-flash` or `gemini-1.5-flash` for speed
|
|
219
|
+
- **Large contexts**: `gemini-2.0-pro` supports up to 2M tokens
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary><b>Q: How many accounts should I add?</b></summary>
|
|
225
|
+
|
|
226
|
+
Recommended: 2-5 accounts for optimal failover and load distribution. More accounts provide better redundancy but increase configuration complexity.
|
|
227
|
+
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary><b>Q: Is the credential extraction script safe?</b></summary>
|
|
232
|
+
|
|
233
|
+
**YES, 100% safe!** The script:
|
|
234
|
+
- ✅ Runs ONLY in your browser (locally)
|
|
235
|
+
- ✅ Does NOT send data to external servers
|
|
236
|
+
- ✅ Only reads cookies from business.gemini.google
|
|
237
|
+
- ✅ Open source - you can review the code
|
|
238
|
+
|
|
239
|
+
**Never** run scripts from untrusted sources. Only use from official repository.
|
|
240
|
+
|
|
241
|
+
</details>
|
|
242
|
+
|
|
243
|
+
<details>
|
|
244
|
+
<summary><b>Q: What's the difference from Google AI Studio?</b></summary>
|
|
245
|
+
|
|
246
|
+
This plugin uses **Gemini Business API** (`business.gemini.google`), which is:
|
|
247
|
+
- ✅ Enterprise/business accounts
|
|
248
|
+
- ✅ Higher rate limits
|
|
249
|
+
- ✅ Business-grade features
|
|
250
|
+
|
|
251
|
+
**NOT** Google AI Studio (`aistudio.google.com`), which is:
|
|
252
|
+
- ❌ Free/developer tier
|
|
253
|
+
- ❌ Lower rate limits
|
|
254
|
+
- ❌ Different API endpoints
|
|
255
|
+
|
|
256
|
+
</details>
|
|
257
|
+
|
|
258
|
+
## 🔒 Security Best Practices
|
|
259
|
+
|
|
260
|
+
### Credential Safety
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
⚠️ CRITICAL: Keep your credentials PRIVATE!
|
|
264
|
+
|
|
265
|
+
✅ DO:
|
|
266
|
+
- Store credentials only in ~/.config/opencode/gemini-business-accounts.json
|
|
267
|
+
- Use environment variables for temporary access
|
|
268
|
+
- Rotate credentials regularly
|
|
269
|
+
- Add *.json to .gitignore
|
|
270
|
+
|
|
271
|
+
❌ DON'T:
|
|
272
|
+
- Commit credentials to git repositories
|
|
273
|
+
- Share credentials with others
|
|
274
|
+
- Store credentials in plain text files
|
|
275
|
+
- Use credentials in public environments
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Cookie Extraction Script Safety
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
✅ The extraction script is SAFE because:
|
|
282
|
+
- Runs 100% locally in your browser
|
|
283
|
+
- NO external network requests
|
|
284
|
+
- NO data transmission to servers
|
|
285
|
+
- Open source and reviewable
|
|
286
|
+
|
|
287
|
+
⚠️ Security Tips:
|
|
288
|
+
- Only use from official repository
|
|
289
|
+
- Review code before running (it's short!)
|
|
290
|
+
- Never paste modified scripts
|
|
291
|
+
- Check browser console for any warnings
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 📄 License
|
|
295
|
+
|
|
296
|
+
MIT License - feel free to use this plugin!
|
|
297
|
+
|
|
298
|
+
## 💬 Need Help?
|
|
299
|
+
|
|
300
|
+
- Check the [FAQ](#-faq) above for common questions
|
|
301
|
+
- Test your accounts: `opencode-gemini-business test-account <account_id>`
|
|
302
|
+
- Report issues: [GitHub Issues](https://github.com/izzzzzi/opencode-gemini-business/issues)
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# 🔄 opencode-gemini-business
|
|
2
|
+
|
|
3
|
+
[🇬🇧 English](README.md) | [🇷🇺 **Русский**](README.ru.md)
|
|
4
|
+
|
|
5
|
+
> Мульти-аккаунтный пул Gemini Business с интеллектуальной ротацией для OpenCode
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.npmjs.com/package/opencode-gemini-business)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📖 Обзор
|
|
14
|
+
|
|
15
|
+
**opencode-gemini-business** — это плагин для OpenCode, который обеспечивает ротацию между несколькими аккаунтами **Gemini Business API**, предоставляя автоматическое переключение при ошибках и балансировку нагрузки.
|
|
16
|
+
|
|
17
|
+
**⚠️ Важно**: Этот плагин использует **официальный Gemini Business API** (`business.gemini.google`), НЕ Google AI Studio.
|
|
18
|
+
|
|
19
|
+
## ✨ Ключевые возможности
|
|
20
|
+
|
|
21
|
+
| Функция | Описание |
|
|
22
|
+
|---------|----------|
|
|
23
|
+
| 🔄 **Мульти-аккаунт ротация** | Автоматическое переключение между аккаунтами |
|
|
24
|
+
| 🛡️ **Автоматический Failover** | Повтор неудачных запросов с другими аккаунтами |
|
|
25
|
+
| 🔐 **Управление сессиями** | Встроенное управление XSRF токенами и сессиями |
|
|
26
|
+
| ⚙️ **Гибкие стратегии** | Round-robin, least-used или случайная ротация |
|
|
27
|
+
| 📊 **Мониторинг здоровья** | Отслеживание статистики и ошибок по аккаунтам |
|
|
28
|
+
| 🚀 **Совместимость с OpenCode** | Бесшовная работа с системой провайдеров OpenCode |
|
|
29
|
+
| 💾 **Постоянная конфигурация** | Безопасное хранение в `~/.config/opencode/gemini-business-accounts.json` |
|
|
30
|
+
|
|
31
|
+
## 🤖 Поддерживаемые модели
|
|
32
|
+
|
|
33
|
+
| Модель | Контекст | Макс. вывод | Лучше всего для |
|
|
34
|
+
|--------|----------|-------------|-----------------|
|
|
35
|
+
| `gemini-2.5-pro` | 1M токенов | 32K токенов | Сложные рассуждения, длинные документы |
|
|
36
|
+
| `gemini-2.5-flash` | 1M токенов | 8K токенов | Быстрые ответы, простые задачи |
|
|
37
|
+
| `gemini-2.0-pro` | 2M токенов | 32K токенов | Массивный контекст, глубокий анализ |
|
|
38
|
+
| `gemini-1.5-pro` | 2M токенов | 8K токенов | Производственные нагрузки |
|
|
39
|
+
| `gemini-1.5-flash` | 1M токенов | 8K токенов | Экономичная разработка |
|
|
40
|
+
|
|
41
|
+
## 🔧 Установка и настройка
|
|
42
|
+
|
|
43
|
+
### 📦 Установите плагин
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g opencode-gemini-business
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Или используйте с npx:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx opencode-gemini-business@latest
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### ⚙️ Настройте OpenCode
|
|
56
|
+
|
|
57
|
+
Добавьте в `~/.config/opencode/opencode.json`:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"plugins": ["opencode-gemini-business"],
|
|
62
|
+
"models": {
|
|
63
|
+
"gemini-business": {
|
|
64
|
+
"provider": "gemini-business",
|
|
65
|
+
"model": "gemini-2.5-pro",
|
|
66
|
+
"rotation_strategy": "round-robin"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 🔑 Извлечение учетных данных
|
|
73
|
+
|
|
74
|
+
#### Метод 1: Использование расширения браузера (РЕКОМЕНДУЕТСЯ) ⚡
|
|
75
|
+
|
|
76
|
+
**Используйте расширение "Get cookies.txt LOCALLY"** для экспорта cookies, включая HttpOnly:
|
|
77
|
+
|
|
78
|
+
1. **Установите расширение**:
|
|
79
|
+
- [Chrome Web Store: Get cookies.txt LOCALLY](https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
|
|
80
|
+
- Это расширение может экспортировать **все cookies**, включая HttpOnly (которые недоступны JavaScript)
|
|
81
|
+
|
|
82
|
+
2. **Войдите** в [Gemini Business](https://business.gemini.google)
|
|
83
|
+
|
|
84
|
+
3. **Нажмите на иконку расширения** → Экспортируйте cookies для `business.gemini.google`
|
|
85
|
+
|
|
86
|
+
4. **Найдите в экспортированном файле**:
|
|
87
|
+
- `__Secure-C_SES`: `CSE.xxx...`
|
|
88
|
+
- `__Host-C_OSES`: `COS.xxx...`
|
|
89
|
+
|
|
90
|
+
5. **Получите csesidx из URL**:
|
|
91
|
+
- Посмотрите на URL в браузере: `?csesidx=1370433092`
|
|
92
|
+
- Скопируйте число после `csesidx=`
|
|
93
|
+
|
|
94
|
+
6. **Получите team_id из вкладки Network**:
|
|
95
|
+
- F12 → вкладка **Network**
|
|
96
|
+
- Отправьте сообщение в Gemini
|
|
97
|
+
- Найдите запрос к `biz-discoveryengine.googleapis.com`
|
|
98
|
+
- Кликните на запрос → **Headers** → найдите `X-Goog-Team-Id: team_xxxxx`
|
|
99
|
+
|
|
100
|
+
7. **Добавьте аккаунт** (см. ниже)
|
|
101
|
+
|
|
102
|
+
#### Метод 2: Ручное извлечение через DevTools
|
|
103
|
+
|
|
104
|
+
1. **Войдите** в [Gemini Business](https://business.gemini.google)
|
|
105
|
+
|
|
106
|
+
2. **Откройте DevTools** (F12) → вкладка **Network**
|
|
107
|
+
|
|
108
|
+
3. **Отправьте сообщение** в Gemini или обновите страницу
|
|
109
|
+
|
|
110
|
+
4. **Найдите любой запрос** к `biz-discoveryengine.googleapis.com`
|
|
111
|
+
|
|
112
|
+
5. **Скопируйте из заголовков запроса**:
|
|
113
|
+
- `X-Goog-Team-Id` → это ваш `team_id`
|
|
114
|
+
- Cookie: `__Secure-c_ses` → скопируйте значение
|
|
115
|
+
- Cookie: `__Host-c_oses` → скопируйте значение
|
|
116
|
+
- Найдите `csesidx` в теле запроса или заголовках
|
|
117
|
+
|
|
118
|
+
6. **Добавьте аккаунт**:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
opencode-gemini-business add-account \
|
|
122
|
+
"Основной аккаунт" \
|
|
123
|
+
"team_abc123" \
|
|
124
|
+
"secure_ses_cookie_value" \
|
|
125
|
+
"host_oses_cookie_value" \
|
|
126
|
+
"csesidx_value"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 📝 Добавление аккаунта
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
opencode-gemini-business add-account \
|
|
133
|
+
"Основной аккаунт" \
|
|
134
|
+
"team_abc123" \
|
|
135
|
+
"secure_ses_cookie_value" \
|
|
136
|
+
"host_oses_cookie_value" \
|
|
137
|
+
"csesidx_value"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Или через переменные окружения**:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
export GEMINI_ACCOUNT_NAME="Основной аккаунт"
|
|
144
|
+
export GEMINI_TEAM_ID="team_abc123"
|
|
145
|
+
export GEMINI_SECURE_C_SES="secure_ses_value"
|
|
146
|
+
export GEMINI_HOST_C_OSES="host_oses_value"
|
|
147
|
+
export GEMINI_CSESIDX="csesidx_value"
|
|
148
|
+
|
|
149
|
+
opencode-gemini-business add-account
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 🚀 Использование
|
|
153
|
+
|
|
154
|
+
### Базовое использование
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Использовать с конкретной моделью
|
|
158
|
+
opencode run "Напиши hello world на Python" --model=gemini-business
|
|
159
|
+
|
|
160
|
+
# Установить по умолчанию
|
|
161
|
+
export OPENCODE_MODEL=gemini-business
|
|
162
|
+
opencode run "Ваша задача здесь"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Использование конкретных моделей
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Использовать Pro для сложных задач
|
|
169
|
+
opencode run "Проанализируй архитектуру этого проекта" --model=gemini-pro
|
|
170
|
+
|
|
171
|
+
# Использовать Flash для быстрых задач
|
|
172
|
+
opencode run "Исправь эту синтаксическую ошибку" --model=gemini-flash
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 🛠️ Управление аккаунтами
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Список всех аккаунтов
|
|
179
|
+
opencode-gemini-business list-accounts
|
|
180
|
+
|
|
181
|
+
# Тест конкретного аккаунта
|
|
182
|
+
opencode-gemini-business test-account <account_id>
|
|
183
|
+
|
|
184
|
+
# Удалить аккаунт
|
|
185
|
+
opencode-gemini-business remove-account <account_id>
|
|
186
|
+
|
|
187
|
+
# Помощь
|
|
188
|
+
opencode-gemini-business help
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 🔄 Стратегии ротации
|
|
192
|
+
|
|
193
|
+
| Стратегия | Поведение | Применение |
|
|
194
|
+
|-----------|-----------|------------|
|
|
195
|
+
| `round-robin` | Циклическое переключение по порядку | Сбалансированное использование всех аккаунтов |
|
|
196
|
+
| `least-used` | Выбор аккаунта с самой старой меткой last_used | Минимизация использования отдельных аккаунтов |
|
|
197
|
+
| `random` | Случайный вероятностный выбор | Непредсказуемое распределение нагрузки |
|
|
198
|
+
|
|
199
|
+
**Настройка стратегии** в конфиге OpenCode:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"models": {
|
|
204
|
+
"gemini-business": {
|
|
205
|
+
"provider": "gemini-business",
|
|
206
|
+
"model": "gemini-2.5-pro",
|
|
207
|
+
"rotation_strategy": "least-used" // ← Измените здесь
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
## ❓ Часто задаваемые вопросы
|
|
215
|
+
|
|
216
|
+
<details>
|
|
217
|
+
<summary><b>В: Как обработать истечение сессии?</b></summary>
|
|
218
|
+
|
|
219
|
+
Плагин автоматически обновляет сессии. Сессии кешируются на 50 минут и обновляются автоматически при необходимости. Если видите ошибки "Session has expired", плагин создаст новую сессию автоматически.
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary><b>В: Какую модель использовать?</b></summary>
|
|
225
|
+
|
|
226
|
+
- **Сложные задачи**: `gemini-2.5-pro` или `gemini-2.0-pro` для лучших рассуждений
|
|
227
|
+
- **Быстрые задачи**: `gemini-2.5-flash` или `gemini-1.5-flash` для скорости
|
|
228
|
+
- **Большой контекст**: `gemini-2.0-pro` поддерживает до 2M токенов
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
<details>
|
|
233
|
+
<summary><b>В: Сколько аккаунтов добавлять?</b></summary>
|
|
234
|
+
|
|
235
|
+
Рекомендуется: 2-5 аккаунтов для оптимального резервирования и распределения нагрузки. Больше аккаунтов обеспечивает лучшую избыточность, но усложняет конфигурацию.
|
|
236
|
+
|
|
237
|
+
</details>
|
|
238
|
+
|
|
239
|
+
<details>
|
|
240
|
+
<summary><b>В: Безопасен ли скрипт извлечения credentials?</b></summary>
|
|
241
|
+
|
|
242
|
+
**ДА, 100% безопасен!** Скрипт:
|
|
243
|
+
- ✅ Работает ТОЛЬКО в вашем браузере (локально)
|
|
244
|
+
- ✅ НЕ отправляет данные на внешние серверы
|
|
245
|
+
- ✅ Только читает cookies с business.gemini.google
|
|
246
|
+
- ✅ Открытый исходный код - можете проверить
|
|
247
|
+
|
|
248
|
+
**Никогда** не запускайте скрипты из ненадежных источников. Используйте только из официального репозитория.
|
|
249
|
+
|
|
250
|
+
</details>
|
|
251
|
+
|
|
252
|
+
<details>
|
|
253
|
+
<summary><b>В: В чём разница от Google AI Studio?</b></summary>
|
|
254
|
+
|
|
255
|
+
Этот плагин использует **Gemini Business API** (`business.gemini.google`):
|
|
256
|
+
- ✅ Корпоративные/бизнес аккаунты
|
|
257
|
+
- ✅ Более высокие лимиты
|
|
258
|
+
- ✅ Бизнес-функции
|
|
259
|
+
|
|
260
|
+
**НЕ** Google AI Studio (`aistudio.google.com`):
|
|
261
|
+
- ❌ Бесплатный/разработческий уровень
|
|
262
|
+
- ❌ Более низкие лимиты
|
|
263
|
+
- ❌ Другие эндпоинты API
|
|
264
|
+
|
|
265
|
+
</details>
|
|
266
|
+
|
|
267
|
+
## 🔒 Лучшие практики безопасности
|
|
268
|
+
|
|
269
|
+
### Безопасность учетных данных
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
⚠️ КРИТИЧНО: Держите учетные данные в СЕКРЕТЕ!
|
|
273
|
+
|
|
274
|
+
✅ ДЕЛАЙТЕ:
|
|
275
|
+
- Храните credentials только в ~/.config/opencode/gemini-business-accounts.json
|
|
276
|
+
- Используйте переменные окружения для временного доступа
|
|
277
|
+
- Регулярно меняйте учетные данные
|
|
278
|
+
- Добавьте *.json в .gitignore
|
|
279
|
+
|
|
280
|
+
❌ НЕ ДЕЛАЙТЕ:
|
|
281
|
+
- Не коммитьте credentials в git репозитории
|
|
282
|
+
- Не передавайте credentials другим
|
|
283
|
+
- Не храните credentials в открытых текстовых файлах
|
|
284
|
+
- Не используйте credentials в публичных окружениях
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Безопасность скрипта извлечения cookies
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
✅ Скрипт БЕЗОПАСЕН, потому что:
|
|
291
|
+
- Работает 100% локально в вашем браузере
|
|
292
|
+
- НЕ делает внешних сетевых запросов
|
|
293
|
+
- НЕ передает данные на серверы
|
|
294
|
+
- Открытый исходный код и проверяемый
|
|
295
|
+
|
|
296
|
+
⚠️ Советы по безопасности:
|
|
297
|
+
- Используйте только из официального репозитория
|
|
298
|
+
- Проверьте код перед запуском (он короткий!)
|
|
299
|
+
- Никогда не вставляйте модифицированные скрипты
|
|
300
|
+
- Проверяйте консоль браузера на предупреждения
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## 📄 Лицензия
|
|
304
|
+
|
|
305
|
+
Лицензия MIT - используйте плагин свободно!
|
|
306
|
+
|
|
307
|
+
## 💬 Нужна помощь?
|
|
308
|
+
|
|
309
|
+
- Проверьте [FAQ](#-часто-задаваемые-вопросы) для частых вопросов
|
|
310
|
+
- Тестируйте аккаунты: `opencode-gemini-business test-account <account_id>`
|
|
311
|
+
- Сообщайте о проблемах: [GitHub Issues](https://github.com/izzzzzi/opencode-gemini-business/issues)
|