opencode-gemini-business 2.1.0 → 2.2.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.2.0](https://github.com/izzzzzi/opencode-gemini-business/compare/v2.1.0...v2.2.0) (2026-03-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * browser-based account login, update model list, swap README lang ([d0eb82f](https://github.com/izzzzzi/opencode-gemini-business/commit/d0eb82fabf337004f330646fb1ec1af38cb87d96))
7
+
1
8
  # [2.1.0](https://github.com/izzzzzi/opencode-gemini-business/compare/v2.0.5...v2.1.0) (2026-02-15)
2
9
 
3
10
 
package/README.en.md ADDED
@@ -0,0 +1,278 @@
1
+ <div align="center">
2
+
3
+ # 🔄 opencode-gemini-business
4
+
5
+ **Multi-account Gemini Business pool with intelligent rotation for OpenCode**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/opencode-gemini-business.svg?style=flat&colorA=18181B&colorB=28CF8D)](https://www.npmjs.com/package/opencode-gemini-business)
8
+ [![npm downloads](https://img.shields.io/npm/dm/opencode-gemini-business.svg?style=flat&colorA=18181B&colorB=28CF8D)](https://www.npmjs.com/package/opencode-gemini-business)
9
+ [![GitHub release](https://img.shields.io/github/v/release/izzzzzi/opencode-gemini-business?style=flat&colorA=18181B&colorB=28CF8D)](https://github.com/izzzzzi/opencode-gemini-business/releases)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat&colorA=18181B&colorB=28CF8D)](LICENSE)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat&colorA=18181B&colorB=3178C6)](https://www.typescriptlang.org/)
12
+ [![Node.js](https://img.shields.io/badge/Node.js-ESM-green?style=flat&colorA=18181B&colorB=339933)](https://nodejs.org/)
13
+
14
+ [🇷🇺 Русский](README.md) | **🇬🇧 English**
15
+
16
+ <br />
17
+
18
+ *Auth plugin for [OpenCode](https://github.com/anomalyco/opencode) — pool multiple Gemini Business accounts with automatic rotation, failover, and load balancing.*
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## 📖 Overview
25
+
26
+ **opencode-gemini-business** is an OpenCode plugin that enables multi-account rotation for **Gemini Business API** (`business.gemini.google`), providing automatic failover and load balancing across multiple accounts.
27
+
28
+ > **Important**: This plugin uses the **Gemini Business / Enterprise API**, NOT Google AI Studio.
29
+
30
+ ---
31
+
32
+ ## ✨ Features
33
+
34
+ | Feature | Description |
35
+ |---------|-------------|
36
+ | 🔄 **Multi-Account Rotation** | Automatically rotate between multiple Gemini Business accounts |
37
+ | 🛡️ **Automatic Failover** | Retry failed requests with different accounts seamlessly |
38
+ | 🔐 **JWT Authentication** | Built-in XSRF token retrieval and JWT (HS256) signing |
39
+ | 📡 **Streaming Support** | Full SSE streaming, JSON-lines, and fallback parsing |
40
+ | ⚙️ **Flexible Strategies** | Round-robin, least-used, or random rotation |
41
+ | 🔑 **Auto Auth Setup** | `add-account` automatically creates OpenCode auth record |
42
+
43
+ ---
44
+
45
+ ## 🤖 Supported Models
46
+
47
+ | Model | Internal API ID | Best For |
48
+ |-------|:---------------:|---------|
49
+ | `gemini-2.5-flash` | `gemini-2.5-flash` | Everyday tasks, fast responses |
50
+ | `gemini-2.5-pro` | `gemini-2.5-pro` | Complex reasoning |
51
+ | `gemini-3-flash` | `gemini-3-flash-preview` | Next-gen fast model |
52
+ | `gemini-3.1-pro` | `gemini-3.1-pro-preview` | Advanced reasoning (preview) |
53
+ | `auto` | *(empty)* | Gemini auto-selects the best model |
54
+
55
+ ---
56
+
57
+ ## 🚀 Quick Start
58
+
59
+ ### Step 1: Configure OpenCode
60
+
61
+ Add to `~/.config/opencode/opencode.json`:
62
+
63
+ ```json
64
+ {
65
+ "$schema": "https://opencode.ai/config.json",
66
+ "plugin": ["opencode-gemini-business@latest"],
67
+ "provider": {
68
+ "gemini-business": {
69
+ "name": "Gemini Business",
70
+ "options": {
71
+ "baseURL": "https://business.gemini.google/v1",
72
+ "apiKey": "unused"
73
+ },
74
+ "models": {
75
+ "gemini-2.5-flash": { "name": "Gemini 2.5 Flash" },
76
+ "gemini-2.5-pro": { "name": "Gemini 2.5 Pro" },
77
+ "gemini-3-flash": { "name": "Gemini 3 Flash" },
78
+ "gemini-3.1-pro": { "name": "Gemini 3.1 Pro" },
79
+ "auto": { "name": "Auto Select" }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Step 2: Add Gemini Business account
87
+
88
+ Install the CLI tool:
89
+
90
+ ```bash
91
+ npm install -g opencode-gemini-business
92
+ ```
93
+
94
+ Then add your account (requires Google Chrome or Chromium):
95
+
96
+ ```bash
97
+ opencode-gemini-business add-account
98
+ ```
99
+
100
+ A Chrome window will open — sign in to your Gemini Business account and send any message in the chat. Cookies and credentials are captured automatically. That's it!
101
+
102
+ > **Note:** `add-account` automatically creates the auth record in `~/.local/share/opencode/auth.json`, so you don't need to run `opencode auth login`.
103
+
104
+ <details>
105
+ <summary>Manual mode (advanced)</summary>
106
+
107
+ If you prefer to provide credentials manually or don't have Chrome installed:
108
+
109
+ ```bash
110
+ opencode-gemini-business add-account --manual \
111
+ "My Account" \
112
+ "e1f353e7-0291-44cf-9085-e0b6efd20e41" \
113
+ "CSE.AXUaAj_MKeqeFLr_..." \
114
+ "COS.AfQtEyCcW1aLwKb3..." \
115
+ "1370433092"
116
+ ```
117
+
118
+ | # | Argument | Description |
119
+ |:-:|----------|-------------|
120
+ | 1 | Account name | Display name for the account |
121
+ | 2 | `team_id` | UUID from URL `/cid/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/` |
122
+ | 3 | `__Secure-C_SES` | Cookie value (starts with `CSE.`) |
123
+ | 4 | `__Host-C_OSES` | Cookie value (starts with `COS.`) |
124
+ | 5 | `csesidx` | Number from URL `?csesidx=...` |
125
+
126
+ Or use environment variables:
127
+
128
+ ```bash
129
+ export GEMINI_ACCOUNT_NAME="My Account"
130
+ export GEMINI_TEAM_ID="e1f353e7-0291-44cf-9085-e0b6efd20e41"
131
+ export GEMINI_SECURE_C_SES="CSE.AXUaAj_MKeqeFLr_..."
132
+ export GEMINI_HOST_C_OSES="COS.AfQtEyCcW1aLwKb3..."
133
+ export GEMINI_CSESIDX="1370433092"
134
+
135
+ opencode-gemini-business add-account --manual
136
+ ```
137
+
138
+ </details>
139
+
140
+ ### Step 3: Use it
141
+
142
+ ```bash
143
+ # Flash model (fast)
144
+ opencode run --model=gemini-business/gemini-2.5-flash "Fix this bug"
145
+
146
+ # Pro model (best quality)
147
+ opencode run --model=gemini-business/gemini-2.5-pro "Design architecture"
148
+
149
+ # Next-gen models
150
+ opencode run --model=gemini-business/gemini-3-flash "Quick task"
151
+ opencode run --model=gemini-business/gemini-3.1-pro "Advanced reasoning"
152
+ opencode run --model=gemini-business/auto "Let Gemini choose"
153
+ ```
154
+
155
+ Set as default model in `opencode.json`:
156
+
157
+ ```json
158
+ {
159
+ "model": "gemini-business/gemini-2.5-flash"
160
+ }
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 🔍 Extracting Credentials
166
+
167
+ ### Where to find each value
168
+
169
+ Login to [business.gemini.google](https://business.gemini.google) and look at the URL:
170
+
171
+ ```
172
+ https://business.gemini.google/home/cid/e1f353e7-0291-44cf-9085-e0b6efd20e41/r/session/123?csesidx=1370433092
173
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^
174
+ team_id (UUID after /cid/) csesidx
175
+ ```
176
+
177
+ ### Cookies
178
+
179
+ **Method 1: Browser Extension (Recommended)**
180
+
181
+ 1. Install [Get cookies.txt LOCALLY](https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
182
+ 2. Open `business.gemini.google` and export cookies
183
+ 3. Find `__Secure-C_SES` (starts with `CSE.`) and `__Host-C_OSES` (starts with `COS.`)
184
+
185
+ **Method 2: DevTools**
186
+
187
+ 1. Open DevTools (F12) → **Application** → **Cookies** → `https://business.gemini.google`
188
+ 2. Copy `__Secure-C_SES` and `__Host-C_OSES` values
189
+
190
+ ---
191
+
192
+ ## 🔧 Account Management
193
+
194
+ ```bash
195
+ # List all accounts
196
+ opencode-gemini-business list-accounts
197
+
198
+ # Test account connectivity
199
+ opencode-gemini-business test-account <account_id>
200
+
201
+ # Remove account
202
+ opencode-gemini-business remove-account <account_id>
203
+
204
+ # Help
205
+ opencode-gemini-business help
206
+ ```
207
+
208
+ ---
209
+
210
+ ## ⚙️ Rotation Strategies
211
+
212
+ | Strategy | Behavior |
213
+ |----------|----------|
214
+ | `round-robin` (default) | Cycles through accounts in order |
215
+ | `least-used` | Selects least recently used account |
216
+ | `random` | Random selection |
217
+
218
+ Configure in `~/.config/opencode/gemini-business-accounts.json` (auto-created on first `add-account`).
219
+
220
+ ---
221
+
222
+ ## 🛠️ How It Works
223
+
224
+ 1. Plugin registers as an OpenCode auth provider for `gemini-business`
225
+ 2. When a request comes in, `loader()` returns a custom `fetch()` function
226
+ 3. Custom `fetch()` intercepts the request from `@ai-sdk/openai-compatible`
227
+ 4. Instead of calling `baseURL/chat/completions`, it:
228
+ - Picks an account via rotation strategy
229
+ - Gets XSRF token and creates JWT (HS256)
230
+ - Creates a session via `widgetCreateSession`
231
+ - Sends the actual request to `widgetStreamAssist`
232
+ - Converts the response back to OpenAI-compatible format
233
+ 5. Supports both streaming (SSE) and non-streaming responses
234
+
235
+ ---
236
+
237
+ ## ❓ FAQ
238
+
239
+ <details>
240
+ <summary><b>Q: Where do I find team_id?</b></summary>
241
+
242
+ Look at the URL in your browser: `https://business.gemini.google/home/cid/e1f353e7-0291-44cf-9085-e0b6efd20e41/...`
243
+
244
+ The UUID after `/cid/` is your `team_id`.
245
+ </details>
246
+
247
+ <details>
248
+ <summary><b>Q: Do I need to run `opencode auth login`?</b></summary>
249
+
250
+ No. The `add-account` command automatically creates the auth record in `~/.local/share/opencode/auth.json`. If for some reason it wasn't created, you can run `opencode auth login`, select **gemini-business**, and enter any key (e.g. `unused`).
251
+ </details>
252
+
253
+ <details>
254
+ <summary><b>Q: Session expired errors?</b></summary>
255
+
256
+ The plugin automatically refreshes sessions (cached for 50 minutes). If you see persistent errors, your cookies may have expired — re-extract them from the browser.
257
+ </details>
258
+
259
+ <details>
260
+ <summary><b>Q: Difference from Google AI Studio?</b></summary>
261
+
262
+ This plugin uses **Gemini Business API** (`business.gemini.google`) — enterprise accounts with higher rate limits. NOT Google AI Studio (`aistudio.google.com`).
263
+ </details>
264
+
265
+ ---
266
+
267
+ ## 🔒 Security
268
+
269
+ - Credentials are stored locally in `~/.config/opencode/gemini-business-accounts.json`
270
+ - Never commit credentials to git
271
+ - Rotate cookies regularly
272
+ - The plugin does not send credentials to any third-party services
273
+
274
+ ---
275
+
276
+ ## 📄 License
277
+
278
+ [MIT](LICENSE) © opencode-gemini-business contributors
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # 🔄 opencode-gemini-business
4
4
 
5
- **Multi-account Gemini Business pool with intelligent rotation for OpenCode**
5
+ **Мульти-аккаунтный пул Gemini Business с интеллектуальной ротацией для OpenCode**
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/opencode-gemini-business.svg?style=flat&colorA=18181B&colorB=28CF8D)](https://www.npmjs.com/package/opencode-gemini-business)
8
8
  [![npm downloads](https://img.shields.io/npm/dm/opencode-gemini-business.svg?style=flat&colorA=18181B&colorB=28CF8D)](https://www.npmjs.com/package/opencode-gemini-business)
@@ -11,53 +11,54 @@
11
11
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat&colorA=18181B&colorB=3178C6)](https://www.typescriptlang.org/)
12
12
  [![Node.js](https://img.shields.io/badge/Node.js-ESM-green?style=flat&colorA=18181B&colorB=339933)](https://nodejs.org/)
13
13
 
14
- [🇷🇺 Русский](README.ru.md) | **🇬🇧 English**
14
+ **🇷🇺 Русский** | [🇬🇧 English](README.en.md)
15
15
 
16
16
  <br />
17
17
 
18
- *Auth plugin for [OpenCode](https://github.com/anomalyco/opencode) — pool multiple Gemini Business accounts with automatic rotation, failover, and load balancing.*
18
+ *Auth-плагин для [OpenCode](https://github.com/anomalyco/opencode) — пул из нескольких аккаунтов Gemini Business с автоматической ротацией, фейловером и балансировкой нагрузки.*
19
19
 
20
20
  </div>
21
21
 
22
22
  ---
23
23
 
24
- ## 📖 Overview
24
+ ## 📖 Обзор
25
25
 
26
- **opencode-gemini-business** is an OpenCode plugin that enables multi-account rotation for **Gemini Business API** (`business.gemini.google`), providing automatic failover and load balancing across multiple accounts.
26
+ **opencode-gemini-business** плагин для OpenCode, который обеспечивает ротацию между несколькими аккаунтами **Gemini Business API** (`business.gemini.google`), предоставляя автоматическое переключение при ошибках и балансировку нагрузки.
27
27
 
28
- > **Important**: This plugin uses the **Gemini Business / Enterprise API**, NOT Google AI Studio.
28
+ > **Важно**: Плагин использует **Gemini Business / Enterprise API**, НЕ Google AI Studio.
29
29
 
30
30
  ---
31
31
 
32
- ## ✨ Features
32
+ ## ✨ Возможности
33
33
 
34
- | Feature | Description |
35
- |---------|-------------|
36
- | 🔄 **Multi-Account Rotation** | Automatically rotate between multiple Gemini Business accounts |
37
- | 🛡️ **Automatic Failover** | Retry failed requests with different accounts seamlessly |
38
- | 🔐 **JWT Authentication** | Built-in XSRF token retrieval and JWT (HS256) signing |
39
- | 📡 **Streaming Support** | Full SSE streaming, JSON-lines, and fallback parsing |
40
- | ⚙️ **Flexible Strategies** | Round-robin, least-used, or random rotation |
41
- | 🔑 **Auto Auth Setup** | `add-account` automatically creates OpenCode auth record |
34
+ | Возможность | Описание |
35
+ |-------------|----------|
36
+ | 🔄 **Ротация аккаунтов** | Автоматическое переключение между несколькими аккаунтами Gemini Business |
37
+ | 🛡️ **Автоматический фейловер** | Повторные запросы с другим аккаунтом при ошибках |
38
+ | 🔐 **JWT-аутентификация** | Встроенное получение XSRF-токена и подписание JWT (HS256) |
39
+ | 📡 **Поддержка стриминга** | Полная поддержка SSE, JSON-lines и fallback-парсинга |
40
+ | ⚙️ **Гибкие стратегии** | Round-robin, least-used или случайный выбор |
41
+ | 🔑 **Автонастройка auth** | `add-account` автоматически создаёт auth-запись OpenCode |
42
42
 
43
43
  ---
44
44
 
45
- ## 🤖 Supported Models
45
+ ## 🤖 Поддерживаемые модели
46
46
 
47
- | Model | Internal API ID | Best For |
48
- |-------|:---------------:|---------|
49
- | `gemini-2.5-flash` | `gemini-2.5-flash` | Everyday tasks, fast responses |
50
- | `gemini-2.5-pro` | `gemini-2.5-pro` | Complex reasoning |
51
- | `gemini-3-flash` | `gemini-3-flash-preview` | Next-gen fast model |
52
- | `gemini-3-pro` | `gemini-3-pro-preview` | Next-gen reasoning |
47
+ | Модель | Internal API ID | Для чего |
48
+ |--------|:---------------:|----------|
49
+ | `gemini-2.5-flash` | `gemini-2.5-flash` | Повседневные задачи, быстрые ответы |
50
+ | `gemini-2.5-pro` | `gemini-2.5-pro` | Сложные рассуждения |
51
+ | `gemini-3-flash` | `gemini-3-flash-preview` | Новое поколение, быстрая |
52
+ | `gemini-3.1-pro` | `gemini-3.1-pro-preview` | Продвинутые рассуждения (preview) |
53
+ | `auto` | *(пусто)* | Gemini автоматически выберет лучшую модель |
53
54
 
54
55
  ---
55
56
 
56
- ## 🚀 Quick Start
57
+ ## 🚀 Быстрый старт
57
58
 
58
- ### Step 1: Configure OpenCode
59
+ ### Шаг 1: Настроить OpenCode
59
60
 
60
- Add to `~/.config/opencode/opencode.json`:
61
+ Добавьте в `~/.config/opencode/opencode.json`:
61
62
 
62
63
  ```json
63
64
  {
@@ -74,71 +75,84 @@ Add to `~/.config/opencode/opencode.json`:
74
75
  "gemini-2.5-flash": { "name": "Gemini 2.5 Flash" },
75
76
  "gemini-2.5-pro": { "name": "Gemini 2.5 Pro" },
76
77
  "gemini-3-flash": { "name": "Gemini 3 Flash" },
77
- "gemini-3-pro": { "name": "Gemini 3 Pro" }
78
+ "gemini-3.1-pro": { "name": "Gemini 3.1 Pro" },
79
+ "auto": { "name": "Авто-выбор" }
78
80
  }
79
81
  }
80
82
  }
81
83
  }
82
84
  ```
83
85
 
84
- ### Step 2: Add Gemini Business account
86
+ ### Шаг 2: Добавить аккаунт Gemini Business
85
87
 
86
- Install the CLI tool:
88
+ Установите CLI-инструмент:
87
89
 
88
90
  ```bash
89
91
  npm install -g opencode-gemini-business
90
92
  ```
91
93
 
92
- Then add your account:
94
+ Добавьте аккаунт (нужен Google Chrome или Chromium):
93
95
 
94
96
  ```bash
95
- opencode-gemini-business add-account \
96
- "My Account" \
97
+ opencode-gemini-business add-account
98
+ ```
99
+
100
+ Откроется окно Chrome — войдите в аккаунт Gemini Business и отправьте любое сообщение в чат. Куки и учётные данные будут захвачены автоматически. Готово!
101
+
102
+ > **Примечание:** `add-account` автоматически создаёт auth-запись в `~/.local/share/opencode/auth.json`, поэтому запускать `opencode auth login` не нужно.
103
+
104
+ <details>
105
+ <summary>Ручной режим (для продвинутых)</summary>
106
+
107
+ Если хотите указать данные вручную или Chrome не установлен:
108
+
109
+ ```bash
110
+ opencode-gemini-business add-account --manual \
111
+ "Мой аккаунт" \
97
112
  "e1f353e7-0291-44cf-9085-e0b6efd20e41" \
98
113
  "CSE.AXUaAj_MKeqeFLr_..." \
99
114
  "COS.AfQtEyCcW1aLwKb3..." \
100
115
  "1370433092"
101
116
  ```
102
117
 
103
- Arguments:
118
+ | # | Аргумент | Описание |
119
+ |:-:|----------|----------|
120
+ | 1 | Имя аккаунта | Отображаемое имя аккаунта |
121
+ | 2 | `team_id` | UUID из URL `/cid/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/` |
122
+ | 3 | `__Secure-C_SES` | Значение cookie (начинается с `CSE.`) |
123
+ | 4 | `__Host-C_OSES` | Значение cookie (начинается с `COS.`) |
124
+ | 5 | `csesidx` | Число из URL `?csesidx=...` |
104
125
 
105
- | # | Argument | Description |
106
- |:-:|----------|-------------|
107
- | 1 | Account name | Display name for the account |
108
- | 2 | `team_id` | UUID from URL `/cid/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/` |
109
- | 3 | `__Secure-C_SES` | Cookie value (starts with `CSE.`) |
110
- | 4 | `__Host-C_OSES` | Cookie value (starts with `COS.`) |
111
- | 5 | `csesidx` | Number from URL `?csesidx=...` |
112
-
113
- Or use environment variables:
126
+ Или через переменные окружения:
114
127
 
115
128
  ```bash
116
- export GEMINI_ACCOUNT_NAME="My Account"
129
+ export GEMINI_ACCOUNT_NAME="Мой аккаунт"
117
130
  export GEMINI_TEAM_ID="e1f353e7-0291-44cf-9085-e0b6efd20e41"
118
131
  export GEMINI_SECURE_C_SES="CSE.AXUaAj_MKeqeFLr_..."
119
132
  export GEMINI_HOST_C_OSES="COS.AfQtEyCcW1aLwKb3..."
120
133
  export GEMINI_CSESIDX="1370433092"
121
134
 
122
- opencode-gemini-business add-account
135
+ opencode-gemini-business add-account --manual
123
136
  ```
124
137
 
125
- > **Note:** `add-account` automatically creates the auth record in `~/.local/share/opencode/auth.json`, so you don't need to run `opencode auth login`.
138
+ </details>
126
139
 
127
- ### Step 3: Use it
140
+ ### Шаг 3: Использовать
128
141
 
129
142
  ```bash
130
- # Flash model (fast)
131
- opencode run --model=gemini-business/gemini-2.5-flash "Fix this bug"
143
+ # Flash (быстрая)
144
+ opencode run --model=gemini-business/gemini-2.5-flash "Исправь баг"
132
145
 
133
- # Pro model (best quality)
134
- opencode run --model=gemini-business/gemini-2.5-pro "Design architecture"
146
+ # Pro (лучшее качество)
147
+ opencode run --model=gemini-business/gemini-2.5-pro "Спроектируй архитектуру"
135
148
 
136
- # Next-gen models
137
- opencode run --model=gemini-business/gemini-3-flash "Quick task"
138
- opencode run --model=gemini-business/gemini-3-pro "Complex reasoning"
149
+ # Модели нового поколения
150
+ opencode run --model=gemini-business/gemini-3-flash "Быстрая задача"
151
+ opencode run --model=gemini-business/gemini-3.1-pro "Продвинутые рассуждения"
152
+ opencode run --model=gemini-business/auto "Gemini выберет сам"
139
153
  ```
140
154
 
141
- Set as default model in `opencode.json`:
155
+ Установить модель по умолчанию в `opencode.json`:
142
156
 
143
157
  ```json
144
158
  {
@@ -148,117 +162,117 @@ Set as default model in `opencode.json`:
148
162
 
149
163
  ---
150
164
 
151
- ## 🔍 Extracting Credentials
165
+ ## 🔍 Извлечение учётных данных
152
166
 
153
- ### Where to find each value
167
+ ### Где найти каждое значение
154
168
 
155
- Login to [business.gemini.google](https://business.gemini.google) and look at the URL:
169
+ Войдите в [business.gemini.google](https://business.gemini.google) и посмотрите URL:
156
170
 
157
171
  ```
158
172
  https://business.gemini.google/home/cid/e1f353e7-0291-44cf-9085-e0b6efd20e41/r/session/123?csesidx=1370433092
159
173
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^
160
- team_id (UUID after /cid/) csesidx
174
+ team_id (UUID после /cid/) csesidx
161
175
  ```
162
176
 
163
177
  ### Cookies
164
178
 
165
- **Method 1: Browser Extension (Recommended)**
179
+ **Способ 1: Расширение браузера (рекомендуется)**
166
180
 
167
- 1. Install [Get cookies.txt LOCALLY](https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
168
- 2. Open `business.gemini.google` and export cookies
169
- 3. Find `__Secure-C_SES` (starts with `CSE.`) and `__Host-C_OSES` (starts with `COS.`)
181
+ 1. Установите [Get cookies.txt LOCALLY](https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)
182
+ 2. Откройте `business.gemini.google` и экспортируйте cookies
183
+ 3. Найдите `__Secure-C_SES` (начинается с `CSE.`) и `__Host-C_OSES` (начинается с `COS.`)
170
184
 
171
- **Method 2: DevTools**
185
+ **Способ 2: DevTools**
172
186
 
173
- 1. Open DevTools (F12) → **Application** → **Cookies** → `https://business.gemini.google`
174
- 2. Copy `__Secure-C_SES` and `__Host-C_OSES` values
187
+ 1. Откройте DevTools (F12) → **Application** → **Cookies** → `https://business.gemini.google`
188
+ 2. Скопируйте значения `__Secure-C_SES` и `__Host-C_OSES`
175
189
 
176
190
  ---
177
191
 
178
- ## 🔧 Account Management
192
+ ## 🔧 Управление аккаунтами
179
193
 
180
194
  ```bash
181
- # List all accounts
195
+ # Список аккаунтов
182
196
  opencode-gemini-business list-accounts
183
197
 
184
- # Test account connectivity
198
+ # Тест подключения
185
199
  opencode-gemini-business test-account <account_id>
186
200
 
187
- # Remove account
201
+ # Удалить аккаунт
188
202
  opencode-gemini-business remove-account <account_id>
189
203
 
190
- # Help
204
+ # Помощь
191
205
  opencode-gemini-business help
192
206
  ```
193
207
 
194
208
  ---
195
209
 
196
- ## ⚙️ Rotation Strategies
210
+ ## ⚙️ Стратегии ротации
197
211
 
198
- | Strategy | Behavior |
199
- |----------|----------|
200
- | `round-robin` (default) | Cycles through accounts in order |
201
- | `least-used` | Selects least recently used account |
202
- | `random` | Random selection |
212
+ | Стратегия | Поведение |
213
+ |-----------|-----------|
214
+ | `round-robin` (по умолчанию) | Циклический обход аккаунтов по порядку |
215
+ | `least-used` | Выбор наименее недавно использованного |
216
+ | `random` | Случайный выбор |
203
217
 
204
- Configure in `~/.config/opencode/gemini-business-accounts.json` (auto-created on first `add-account`).
218
+ Настраивается в `~/.config/opencode/gemini-business-accounts.json` (создаётся автоматически при первом `add-account`).
205
219
 
206
220
  ---
207
221
 
208
- ## 🛠️ How It Works
222
+ ## 🛠️ Как это работает
209
223
 
210
- 1. Plugin registers as an OpenCode auth provider for `gemini-business`
211
- 2. When a request comes in, `loader()` returns a custom `fetch()` function
212
- 3. Custom `fetch()` intercepts the request from `@ai-sdk/openai-compatible`
213
- 4. Instead of calling `baseURL/chat/completions`, it:
214
- - Picks an account via rotation strategy
215
- - Gets XSRF token and creates JWT (HS256)
216
- - Creates a session via `widgetCreateSession`
217
- - Sends the actual request to `widgetStreamAssist`
218
- - Converts the response back to OpenAI-compatible format
219
- 5. Supports both streaming (SSE) and non-streaming responses
224
+ 1. Плагин регистрируется как auth-провайдер `gemini-business` в OpenCode
225
+ 2. При запросе `loader()` возвращает кастомную функцию `fetch()`
226
+ 3. Кастомный `fetch()` перехватывает запрос от `@ai-sdk/openai-compatible`
227
+ 4. Вместо вызова `baseURL/chat/completions` он:
228
+ - Выбирает аккаунт по стратегии ротации
229
+ - Получает XSRF-токен и создаёт JWT (HS256)
230
+ - Создаёт сессию через `widgetCreateSession`
231
+ - Отправляет запрос на `widgetStreamAssist`
232
+ - Конвертирует ответ в OpenAI-совместимый формат
233
+ 5. Поддерживает стриминг (SSE) и обычные ответы
220
234
 
221
235
  ---
222
236
 
223
237
  ## ❓ FAQ
224
238
 
225
239
  <details>
226
- <summary><b>Q: Where do I find team_id?</b></summary>
240
+ <summary><b>В: Где найти team_id?</b></summary>
227
241
 
228
- Look at the URL in your browser: `https://business.gemini.google/home/cid/e1f353e7-0291-44cf-9085-e0b6efd20e41/...`
242
+ Посмотрите URL в браузере: `https://business.gemini.google/home/cid/e1f353e7-0291-44cf-9085-e0b6efd20e41/...`
229
243
 
230
- The UUID after `/cid/` is your `team_id`.
244
+ UUID после `/cid/` это ваш `team_id`.
231
245
  </details>
232
246
 
233
247
  <details>
234
- <summary><b>Q: Do I need to run `opencode auth login`?</b></summary>
248
+ <summary><b>В: Нужно ли запускать `opencode auth login`?</b></summary>
235
249
 
236
- No. The `add-account` command automatically creates the auth record in `~/.local/share/opencode/auth.json`. If for some reason it wasn't created, you can run `opencode auth login`, select **gemini-business**, and enter any key (e.g. `unused`).
250
+ Нет. Команда `add-account` автоматически создаёт auth-запись в `~/.local/share/opencode/auth.json`. Если по какой-то причине запись не создалась, запустите `opencode auth login`, выберите **gemini-business** и введите любой ключ (например `unused`).
237
251
  </details>
238
252
 
239
253
  <details>
240
- <summary><b>Q: Session expired errors?</b></summary>
254
+ <summary><b>В: Ошибки истечения сессии?</b></summary>
241
255
 
242
- The plugin automatically refreshes sessions (cached for 50 minutes). If you see persistent errors, your cookies may have expired re-extract them from the browser.
256
+ Плагин автоматически обновляет сессии (кешируются на 50 минут). Если ошибки не проходят cookies могли истечь, извлеките их заново из браузера.
243
257
  </details>
244
258
 
245
259
  <details>
246
- <summary><b>Q: Difference from Google AI Studio?</b></summary>
260
+ <summary><b>В: Чем отличается от Google AI Studio?</b></summary>
247
261
 
248
- This plugin uses **Gemini Business API** (`business.gemini.google`) — enterprise accounts with higher rate limits. NOT Google AI Studio (`aistudio.google.com`).
262
+ Плагин использует **Gemini Business API** (`business.gemini.google`) — корпоративные аккаунты с высокими лимитами. НЕ Google AI Studio (`aistudio.google.com`).
249
263
  </details>
250
264
 
251
265
  ---
252
266
 
253
- ## 🔒 Security
267
+ ## 🔒 Безопасность
254
268
 
255
- - Credentials are stored locally in `~/.config/opencode/gemini-business-accounts.json`
256
- - Never commit credentials to git
257
- - Rotate cookies regularly
258
- - The plugin does not send credentials to any third-party services
269
+ - Учётные данные хранятся локально в `~/.config/opencode/gemini-business-accounts.json`
270
+ - Не коммитьте credentials в git
271
+ - Регулярно обновляйте cookies
272
+ - Плагин не отправляет данные третьим сторонам
259
273
 
260
274
  ---
261
275
 
262
- ## 📄 License
276
+ ## 📄 Лицензия
263
277
 
264
278
  [MIT](LICENSE) © opencode-gemini-business contributors