@asframe/opencode-iflow-auth 1.0.0 → 1.0.1

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 CHANGED
@@ -16,6 +16,56 @@ OpenCode plugin for iFlow.cn providing access to Qwen, DeepSeek, Kimi, GLM, and
16
16
  - **Native thinking mode**: Support for GLM-4.x, GLM-5 and DeepSeek R1 models.
17
17
  - **Configurable timeout**: Request timeout and iteration limits to prevent hangs.
18
18
  - **Automatic port selection**: OAuth callback server port conflict avoidance.
19
+ - **Auto-install CLI**: Automatically install iflow CLI if not found.
20
+
21
+ ## Supported Models
22
+
23
+ ### API Key Mode (`iflow` provider)
24
+
25
+ Models available via OAuth 2.0 or API Key authentication:
26
+
27
+ | Model | Context | Output | Description |
28
+ |-------|---------|--------|-------------|
29
+ | `deepseek-v3` | 128K | 32K | DeepSeek V3 |
30
+ | `deepseek-v3.2` | 128K | 64K | DeepSeek V3.2 |
31
+ | `deepseek-r1` | 128K | 32K | DeepSeek R1 (Thinking) |
32
+ | `glm-4.6` | 200K | 128K | GLM-4.6 (Reasoning, Vision) |
33
+ | `glm-4.7` | 256K | 64K | GLM-4.7 (Latest, Reasoning, Vision) |
34
+ | `qwen3-max` | 256K | 32K | Qwen3 Max |
35
+ | `qwen3-max-preview` | 256K | 32K | Qwen3 Max Preview |
36
+ | `qwen3-coder-plus` | 1M | 64K | Qwen3 Coder Plus |
37
+ | `qwen3-vl-plus` | 256K | 32K | Qwen3 VL Plus (Vision) |
38
+ | `qwen3-32b` | 128K | 32K | Qwen3 32B |
39
+ | `qwen3-235b` | 256K | 64K | Qwen3 235B |
40
+ | `qwen3-235b-a22b-thinking-2507` | 256K | 64K | Qwen3 235B Thinking |
41
+ | `qwen3-235b-a22b-instruct` | 256K | 64K | Qwen3 235B Instruct |
42
+ | `kimi-k2` | 128K | 64K | Kimi K2 |
43
+ | `kimi-k2-0905` | 256K | 64K | Kimi K2 0905 |
44
+ | `iflow-rome-30ba3b` | 256K | 64K | iFlow ROME 30B |
45
+
46
+ ### CLI Proxy Mode (`iflow-proxy` provider)
47
+
48
+ **All models from API Key Mode** PLUS these exclusive models:
49
+
50
+ | Model | Context | Output | Description |
51
+ |-------|---------|--------|-------------|
52
+ | `glm-5` | 256K | 64K | GLM-5 - Flagship model (744B params, 40B active), best for reasoning & coding |
53
+ | `glm-5-free` | 256K | 64K | GLM-5 Free - Same capabilities as glm-5, free for limited time |
54
+ | `glm-5-thinking` | 256K | 64K | GLM-5 Thinking - Enhanced "System 2" deep reasoning capabilities |
55
+
56
+ **GLM-5 Model Family:**
57
+
58
+ | Model | Description |
59
+ |-------|-------------|
60
+ | `glm-5` | Latest flagship model from Zhipu AI. 744B parameters (40B active), 28.5T tokens. Best-in-class for reasoning, coding, and agentic tasks. |
61
+ | `glm-5-free` | Free access to GLM-5 during promotional period. Same capabilities, no cost. |
62
+ | `glm-5-thinking` | Enhanced deep reasoning mode. Excels at complex architectural problems and "System 2" thinking. |
63
+
64
+ **Summary:**
65
+ - **API Key Mode**: 16 models
66
+ - **CLI Proxy Mode**: 19 models (16 + 3 exclusive)
67
+
68
+ **Note**: CLI Proxy mode can also be used if you prefer CLI authentication over API Key for any model.
19
69
 
20
70
  ## Two Plugin Modes
21
71
 
@@ -29,7 +79,7 @@ Direct API calls to iFlow.cn for standard models.
29
79
  |----------|-------|
30
80
  | Provider | `iflow` |
31
81
  | baseURL | `https://apis.iflow.cn/v1` |
32
- | Models | deepseek-v3.2, glm-4.6, kimi-k2.5, qwen3-coder-plus, etc. |
82
+ | Auth | OAuth 2.0 / API Key |
33
83
 
34
84
  ### 2. `IFlowProxyPlugin` - CLI Proxy Mode
35
85
 
@@ -39,7 +89,7 @@ Routes requests through iflow CLI for GLM-5 support. The proxy server starts aut
39
89
  |----------|-------|
40
90
  | Provider | `iflow-proxy` |
41
91
  | Proxy Port | `127.0.0.1:19998` |
42
- | Models | glm-5, glm-5-free, glm-5-thinking |
92
+ | Auth | iflow CLI login |
43
93
 
44
94
  **How it works:**
45
95
  1. Plugin detects if model requires CLI (glm-5, glm-5-free, glm-5-thinking)
@@ -49,8 +99,18 @@ Routes requests through iflow CLI for GLM-5 support. The proxy server starts aut
49
99
 
50
100
  ## Installation
51
101
 
102
+ ### Quick Start
103
+
52
104
  Add the plugin to your `opencode.json` or `opencode.jsonc`:
53
105
 
106
+ ```json
107
+ {
108
+ "plugin": ["@asframe/opencode-iflow-auth"]
109
+ }
110
+ ```
111
+
112
+ ### Full Configuration
113
+
54
114
  ```json
55
115
  {
56
116
  "plugin": ["@asframe/opencode-iflow-auth"],
@@ -91,17 +151,17 @@ Add the plugin to your `opencode.json` or `opencode.jsonc`:
91
151
  "models": {
92
152
  "glm-5": {
93
153
  "name": "GLM-5 (via CLI Proxy)",
94
- "limit": { "context": 202000, "output": 64000 },
95
- "modalities": { "input": ["text"], "output": ["text"] }
154
+ "limit": { "context": 256000, "output": 64000 },
155
+ "modalities": { "input": ["text", "image"], "output": ["text"] }
96
156
  },
97
157
  "glm-5-free": {
98
158
  "name": "GLM-5 Free (via CLI Proxy)",
99
- "limit": { "context": 202000, "output": 64000 },
159
+ "limit": { "context": 256000, "output": 64000 },
100
160
  "modalities": { "input": ["text"], "output": ["text"] }
101
161
  },
102
162
  "glm-5-thinking": {
103
163
  "name": "GLM-5 Thinking (via CLI Proxy)",
104
- "limit": { "context": 202000, "output": 64000 },
164
+ "limit": { "context": 256000, "output": 64000 },
105
165
  "modalities": { "input": ["text"], "output": ["text"] }
106
166
  }
107
167
  }
@@ -174,26 +234,30 @@ Edit `~/.config/opencode/iflow.json`:
174
234
 
175
235
  ### Configuration Options
176
236
 
177
- - `default_auth_method`: Default authentication method (`oauth`, `apikey`)
178
- - `account_selection_strategy`: Account rotation strategy (`sticky`, `round-robin`)
179
- - `auth_server_port_start`: Starting port for OAuth callback server (1024-65535)
180
- - `auth_server_port_range`: Number of ports to try (1-100)
181
- - `max_request_iterations`: Maximum loop iterations to prevent hangs (10-1000)
182
- - `request_timeout_ms`: Request timeout in milliseconds (60000-600000ms)
183
- - `enable_log_api_request`: Enable API request/response logging (errors always logged)
237
+ | Option | Type | Default | Description |
238
+ |--------|------|---------|-------------|
239
+ | `default_auth_method` | string | `oauth` | Default authentication method (`oauth`, `apikey`) |
240
+ | `account_selection_strategy` | string | `sticky` | Account rotation strategy (`sticky`, `round-robin`) |
241
+ | `auth_server_port_start` | number | `8087` | Starting port for OAuth callback server (1024-65535) |
242
+ | `auth_server_port_range` | number | `10` | Number of ports to try (1-100) |
243
+ | `max_request_iterations` | number | `50` | Maximum loop iterations to prevent hangs (10-1000) |
244
+ | `request_timeout_ms` | number | `300000` | Request timeout in milliseconds (60000-600000ms) |
245
+ | `enable_log_api_request` | boolean | `false` | Enable API request/response logging |
184
246
 
185
247
  ### Environment Variables
186
248
 
187
- - `IFLOW_AUTH_DEBUG`: Enable debug logging for auth plugin (`true`/`false`)
188
- - `IFLOW_PROXY_DEBUG`: Enable debug logging for proxy plugin (`true`/`false`)
189
- - `IFLOW_AUTO_INSTALL_CLI`: Auto-install iflow CLI if not installed (`true`/`false`)
190
- - `IFLOW_DEFAULT_AUTH_METHOD`
191
- - `IFLOW_ACCOUNT_SELECTION_STRATEGY`
192
- - `IFLOW_AUTH_SERVER_PORT_START`
193
- - `IFLOW_AUTH_SERVER_PORT_RANGE`
194
- - `IFLOW_MAX_REQUEST_ITERATIONS`
195
- - `IFLOW_REQUEST_TIMEOUT_MS`
196
- - `IFLOW_ENABLE_LOG_API_REQUEST`
249
+ | Variable | Description |
250
+ |----------|-------------|
251
+ | `IFLOW_AUTH_DEBUG` | Enable debug logging for auth plugin (`true`/`false`) |
252
+ | `IFLOW_PROXY_DEBUG` | Enable debug logging for proxy plugin (`true`/`false`) |
253
+ | `IFLOW_AUTO_INSTALL_CLI` | Auto-install iflow CLI if not installed (`true`/`false`) |
254
+ | `IFLOW_DEFAULT_AUTH_METHOD` | Override default auth method |
255
+ | `IFLOW_ACCOUNT_SELECTION_STRATEGY` | Override account selection strategy |
256
+ | `IFLOW_AUTH_SERVER_PORT_START` | Override OAuth server port |
257
+ | `IFLOW_AUTH_SERVER_PORT_RANGE` | Override OAuth server port range |
258
+ | `IFLOW_MAX_REQUEST_ITERATIONS` | Override max iterations |
259
+ | `IFLOW_REQUEST_TIMEOUT_MS` | Override request timeout |
260
+ | `IFLOW_ENABLE_LOG_API_REQUEST` | Enable API logging |
197
261
 
198
262
  ## Storage
199
263
 
@@ -261,6 +325,58 @@ Get-Process -Id (Get-NetTCPConnection -LocalPort 19998).OwningProcess | Stop-Pro
261
325
  lsof -i :19998 | grep LISTEN | awk '{print $2}' | xargs kill -9
262
326
  ```
263
327
 
328
+ ### Authentication Issues
329
+
330
+ 1. **API Key not working:**
331
+ - Ensure your API key starts with `sk-`
332
+ - Check if the key is valid at [iFlow.cn](https://iflow.cn)
333
+
334
+ 2. **OAuth not working:**
335
+ - Clear browser cookies
336
+ - Try a different browser
337
+ - Check if the callback port is available
338
+
339
+ ## FAQ
340
+
341
+ ### Q: Why do I need CLI Proxy for GLM-5?
342
+
343
+ GLM-5 requires special authentication that is only available through the iflow CLI. The CLI Proxy mode bridges this gap by routing requests through the CLI.
344
+
345
+ ### Q: Can I use both modes at the same time?
346
+
347
+ Yes! You can configure both `iflow` and `iflow-proxy` providers and use them interchangeably.
348
+
349
+ ### Q: Is this plugin official?
350
+
351
+ No, this is an independent implementation and is not affiliated with, endorsed by, or supported by iFlow.cn.
352
+
353
+ ### Q: How do I get an API key?
354
+
355
+ 1. Visit [iFlow.cn](https://iflow.cn)
356
+ 2. Create an account or login
357
+ 3. Go to API settings
358
+ 4. Generate a new API key
359
+
360
+ ## Changelog
361
+
362
+ ### v1.0.0
363
+ - Initial release
364
+ - Dual authentication (OAuth 2.0 / API Key)
365
+ - CLI Proxy mode for GLM-5
366
+ - Auto-install CLI feature
367
+ - Multi-account rotation
368
+ - Thinking model support
369
+
370
+ ## Contributing
371
+
372
+ Contributions are welcome! Please feel free to submit a Pull Request.
373
+
374
+ 1. Fork the repository
375
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
376
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
377
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
378
+ 5. Open a Pull Request
379
+
264
380
  ## License
265
381
 
266
382
  MIT License - see [LICENSE](LICENSE) for details.
@@ -276,3 +392,4 @@ Feel free to open a PR to optimize this plugin further.
276
392
  - [GitHub Repository](https://github.com/asframe/opencode-iflow-auth)
277
393
  - [npm Package](https://www.npmjs.com/package/@asframe/opencode-iflow-auth)
278
394
  - [iFlow.cn](https://iflow.cn)
395
+ - [OpenCode](https://opencode.ai)
@@ -5,6 +5,14 @@ const IFLOW_PROXY_PORT = 19998;
5
5
  const IFLOW_PROXY_HOST = '127.0.0.1';
6
6
  const IFLOW_API_BASE = 'https://apis.iflow.cn';
7
7
  const CLI_REQUIRED_MODELS = ['glm-5', 'glm-5-free', 'glm-5-thinking'];
8
+ const IFLOW_CLI_SUPPORTED_MODELS = [
9
+ 'glm-5', 'glm-5-free', 'glm-5-thinking',
10
+ 'glm-4.6', 'glm-4.7',
11
+ 'qwen3-max', 'qwen3-max-preview', 'qwen3-coder-plus', 'qwen3-vl-plus', 'qwen3-32b', 'qwen3-235b', 'qwen3-235b-a22b-thinking-2507', 'qwen3-235b-a22b-instruct',
12
+ 'kimi-k2', 'kimi-k2-0905',
13
+ 'deepseek-v3', 'deepseek-v3.2', 'deepseek-r1',
14
+ 'iflow-rome-30ba3b'
15
+ ];
8
16
  const DEBUG = process.env.IFLOW_PROXY_DEBUG === 'true';
9
17
  const AUTO_INSTALL_CLI = process.env.IFLOW_AUTO_INSTALL_CLI === 'true';
10
18
  function log(...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asframe/opencode-iflow-auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "OpenCode plugin for iFlow.cn - Access Qwen, DeepSeek, Kimi, GLM-5 models with OAuth 2.0, API Key, and CLI Proxy support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",