opencode-qwen-oauth 1.1.0 → 2.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
@@ -14,6 +14,10 @@ Qwen OAuth authentication plugin for [OpenCode](https://opencode.ai) - authentic
14
14
  - 📝 **File Logging** - All OAuth activity logged to `~/.config/opencode/logs/qwen-oauth.log`
15
15
  - 🐛 **Debug Mode** - Enable verbose output with `QWEN_OAUTH_DEBUG=true`
16
16
  - 🚀 **Easy Install** - One-command installation with CLI tool
17
+ - 🎯 **Custom Headers** - Automatically adds Qwen-specific headers to API requests
18
+ - ⚙️ **Optimized Parameters** - Pre-configured temperature and topP settings for Qwen models
19
+ - 🌍 **Environment Variables** - Exposes Qwen credentials to shell environments
20
+ - 📊 **Event Monitoring** - Tracks authentication and session events for debugging
17
21
 
18
22
  ## Quick Start
19
23
 
@@ -139,6 +143,25 @@ Use the CLI directly:
139
143
  opencode auth login qwen
140
144
  ```
141
145
 
146
+ ### Browser doesn't open automatically (Linux)
147
+ The plugin tries multiple methods to open your browser:
148
+ 1. First tries `xdg-open` (standard Linux)
149
+ 2. Falls back to: `google-chrome`, `firefox`, `chromium`, `brave-browser`, `microsoft-edge`
150
+
151
+ If none work, manually copy the URL shown in the terminal and open it in your browser.
152
+
153
+ To ensure browser opening works, install `xdg-utils`:
154
+ ```bash
155
+ # Ubuntu/Debian
156
+ sudo apt install xdg-utils
157
+
158
+ # Fedora/RHEL
159
+ sudo dnf install xdg-utils
160
+
161
+ # Arch Linux
162
+ sudo pacman -S xdg-utils
163
+ ```
164
+
142
165
  ### Check logs
143
166
  ```bash
144
167
  cat ~/.config/opencode/logs/qwen-oauth.log
@@ -181,12 +204,47 @@ cd /path/to/project
181
204
  opencode-qwen-oauth install
182
205
  ```
183
206
 
207
+ ## Plugin Architecture
208
+
209
+ This plugin implements multiple OpenCode plugin hooks:
210
+
211
+ ### Hooks Implemented
212
+
213
+ #### `auth` Hook
214
+ Provides OAuth device flow authentication with automatic browser opening and token polling.
215
+
216
+ #### `config` Hook
217
+ Dynamically registers the Qwen provider and available models with OpenCode.
218
+
219
+ #### `event` Hook
220
+ Monitors session events (creation, errors) for debugging and logging.
221
+
222
+ #### `chat.headers` Hook
223
+ Injects custom headers for Qwen API requests:
224
+ - `X-Qwen-Client: OpenCode`
225
+ - `X-Qwen-Plugin-Version: 1.1.0`
226
+
227
+ #### `chat.params` Hook
228
+ Optimizes model parameters for Qwen:
229
+ - Temperature: `0.7` (default)
230
+ - Top P: `0.95` (default)
231
+
232
+ #### `shell.env` Hook
233
+ Exposes environment variables to shell commands:
234
+ - `QWEN_API_BASE_URL` - Qwen API endpoint
235
+ - `QWEN_PROVIDER` - Provider identifier
236
+
184
237
  ## Project Structure
185
238
 
186
239
  ```
187
240
  opencode-qwen-oauth/
188
241
  ├── src/ # TypeScript source files
189
- └── index.ts # Main plugin implementation
242
+ ├── index.ts # Main plugin with hooks
243
+ │ ├── oauth.ts # OAuth device flow logic
244
+ │ ├── pkce.ts # PKCE implementation
245
+ │ ├── browser.ts # Browser opening utility
246
+ │ ├── logger.ts # Logging utilities
247
+ │ └── constants.ts # API constants
190
248
  ├── bin/ # CLI scripts
191
249
  │ └── install.js # Installer script
192
250
  ├── dist/ # Compiled JavaScript (generated)
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  /**
2
2
  * Browser utilities for opening URLs
3
3
  */
4
+ /**
5
+ * Opens a URL in the default browser
6
+ * Supports macOS, Windows, and Linux with fallback mechanisms
7
+ * Debounced to prevent multiple rapid calls
8
+ */
4
9
  export declare function openBrowser(url: string): void;
5
10
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAmB7C"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE7C"}
package/dist/browser.js CHANGED
@@ -2,23 +2,86 @@
2
2
  * Browser utilities for opening URLs
3
3
  */
4
4
  import { spawn } from "node:child_process";
5
+ import { Debouncer } from "./mutex.js";
6
+ // Debouncer to prevent multiple rapid browser opens
7
+ const browserDebouncer = new Debouncer();
8
+ /**
9
+ * Opens a URL in the default browser
10
+ * Supports macOS, Windows, and Linux with fallback mechanisms
11
+ * Debounced to prevent multiple rapid calls
12
+ */
5
13
  export function openBrowser(url) {
14
+ openBrowserDebounced(url);
15
+ }
16
+ /**
17
+ * Internal debounced browser opening function
18
+ */
19
+ const openBrowserDebounced = browserDebouncer.debounce(async (url) => {
20
+ openBrowserInternal(url);
21
+ }, 1000);
22
+ /**
23
+ * Internal function that actually opens the browser
24
+ */
25
+ function openBrowserInternal(url) {
6
26
  try {
7
27
  const platform = process.platform;
8
- const command = platform === "darwin"
9
- ? "open"
10
- : platform === "win32"
11
- ? "rundll32"
12
- : "xdg-open";
13
- const args = platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
28
+ let command;
29
+ let args;
30
+ if (platform === "darwin") {
31
+ // macOS
32
+ command = "open";
33
+ args = [url];
34
+ }
35
+ else if (platform === "win32") {
36
+ // Windows
37
+ command = "rundll32";
38
+ args = ["url.dll,FileProtocolHandler", url];
39
+ }
40
+ else {
41
+ // Linux and other Unix-like systems
42
+ // Try xdg-open first, with fallbacks
43
+ command = "xdg-open";
44
+ args = [url];
45
+ // Check if xdg-open exists, if not try common browsers
46
+ const child = spawn(command, args, {
47
+ stdio: "ignore",
48
+ detached: true,
49
+ });
50
+ child.on("error", (error) => {
51
+ // xdg-open failed, try common Linux browsers
52
+ const browsers = [
53
+ "google-chrome",
54
+ "firefox",
55
+ "chromium",
56
+ "brave-browser",
57
+ "microsoft-edge",
58
+ ];
59
+ for (const browser of browsers) {
60
+ try {
61
+ const browserChild = spawn(browser, [url], {
62
+ stdio: "ignore",
63
+ detached: true,
64
+ });
65
+ browserChild.unref?.();
66
+ return; // Success, exit
67
+ }
68
+ catch {
69
+ // Try next browser
70
+ continue;
71
+ }
72
+ }
73
+ });
74
+ child.unref?.();
75
+ return;
76
+ }
14
77
  const child = spawn(command, args, {
15
78
  stdio: "ignore",
16
79
  detached: true,
17
80
  });
18
81
  child.unref?.();
19
82
  }
20
- catch {
21
- // Ignore errors
83
+ catch (error) {
84
+ // Silently fail - user can manually open the URL
22
85
  }
23
86
  }
24
87
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,MAAM,OAAO,GACX,QAAQ,KAAK,QAAQ;YACnB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,QAAQ,KAAK,OAAO;gBACpB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU,CAAC;QACnB,MAAM,IAAI,GACR,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACtE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,gBAAgB;IAClB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":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CAAC,KAAK,EAAE,EAAE;gBAC1B,6CAA6C;gBAC7C,MAAM,QAAQ,GAAG;oBACf,eAAe;oBACf,SAAS;oBACT,UAAU;oBACV,eAAe;oBACf,gBAAgB;iBACjB,CAAC;gBAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;oBAC/B,IAAI,CAAC;wBACH,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE;4BACzC,KAAK,EAAE,QAAQ;4BACf,QAAQ,EAAE,IAAI;yBACf,CAAC,CAAC;wBACH,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC;wBACvB,OAAO,CAAC,gBAAgB;oBAC1B,CAAC;oBAAC,MAAM,CAAC;wBACP,mBAAmB;wBACnB,SAAS;oBACX,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iDAAiD;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Configuration system for Qwen OAuth Plugin
3
+ */
4
+ export interface QwenConfig {
5
+ /** Request timeout in milliseconds */
6
+ timeout: number;
7
+ /** Maximum number of retries for failed requests */
8
+ maxRetries: number;
9
+ /** Time before token expiry to trigger refresh (milliseconds) */
10
+ refreshThreshold: number;
11
+ /** Logging level */
12
+ logLevel: "debug" | "info" | "warn" | "error";
13
+ /** Base delay for exponential backoff (milliseconds) */
14
+ baseRetryDelay: number;
15
+ /** Maximum delay for exponential backoff (milliseconds) */
16
+ maxRetryDelay: number;
17
+ }
18
+ export declare const defaultConfig: QwenConfig;
19
+ /**
20
+ * Get configuration with environment variable overrides
21
+ */
22
+ export declare function getConfig(): QwenConfig;
23
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC9C,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,UAO3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,IAAI,UAAU,CAStC"}
package/dist/config.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Configuration system for Qwen OAuth Plugin
3
+ */
4
+ export const defaultConfig = {
5
+ timeout: 30000, // 30 seconds
6
+ maxRetries: 3,
7
+ refreshThreshold: 300000, // 5 minutes
8
+ logLevel: process.env.QWEN_OAUTH_DEBUG === "true" ? "debug" : "info",
9
+ baseRetryDelay: 1000, // 1 second
10
+ maxRetryDelay: 30000, // 30 seconds
11
+ };
12
+ /**
13
+ * Get configuration with environment variable overrides
14
+ */
15
+ export function getConfig() {
16
+ return {
17
+ timeout: parseInt(process.env.QWEN_OAUTH_TIMEOUT || String(defaultConfig.timeout)),
18
+ maxRetries: parseInt(process.env.QWEN_OAUTH_MAX_RETRIES || String(defaultConfig.maxRetries)),
19
+ refreshThreshold: parseInt(process.env.QWEN_OAUTH_REFRESH_THRESHOLD || String(defaultConfig.refreshThreshold)),
20
+ logLevel: process.env.QWEN_OAUTH_LOG_LEVEL || defaultConfig.logLevel,
21
+ baseRetryDelay: defaultConfig.baseRetryDelay,
22
+ maxRetryDelay: defaultConfig.maxRetryDelay,
23
+ };
24
+ }
25
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH,MAAM,CAAC,MAAM,aAAa,GAAe;IACvC,OAAO,EAAE,KAAK,EAAE,aAAa;IAC7B,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,MAAM,EAAE,YAAY;IACtC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;IACpE,cAAc,EAAE,IAAI,EAAE,WAAW;IACjC,aAAa,EAAE,KAAK,EAAE,aAAa;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAClF,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC5F,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAC9G,QAAQ,EAAG,OAAO,CAAC,GAAG,CAAC,oBAA4B,IAAI,aAAa,CAAC,QAAQ;QAC7E,cAAc,EAAE,aAAa,CAAC,cAAc;QAC5C,aAAa,EAAE,aAAa,CAAC,aAAa;KAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Custom error types for Qwen OAuth Plugin
3
+ */
4
+ export declare class QwenAuthError extends Error {
5
+ code: string;
6
+ recoverable: boolean;
7
+ userMessage?: string | undefined;
8
+ constructor(message: string, code: string, recoverable?: boolean, userMessage?: string | undefined);
9
+ }
10
+ export declare class NetworkError extends QwenAuthError {
11
+ constructor(message: string, userMessage?: string);
12
+ }
13
+ export declare class TokenExpiredError extends QwenAuthError {
14
+ constructor(message?: string);
15
+ }
16
+ export declare class RateLimitError extends QwenAuthError {
17
+ constructor(message: string, waitTimeMs?: number);
18
+ }
19
+ export declare class AuthorizationError extends QwenAuthError {
20
+ constructor(message: string);
21
+ }
22
+ export declare class ValidationError extends QwenAuthError {
23
+ constructor(message: string, field?: string);
24
+ }
25
+ export declare class DeviceFlowError extends QwenAuthError {
26
+ errorType?: string | undefined;
27
+ constructor(message: string, errorType?: string | undefined);
28
+ }
29
+ /**
30
+ * Type guard to check if error is recoverable
31
+ */
32
+ export declare function isRecoverableError(error: unknown): boolean;
33
+ /**
34
+ * Get user-friendly error message
35
+ */
36
+ export declare function getUserMessage(error: unknown): string;
37
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,aAAc,SAAQ,KAAK;IAG7B,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,OAAO;IACpB,WAAW,CAAC,EAAE,MAAM;gBAH3B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,OAAc,EAC3B,WAAW,CAAC,EAAE,MAAM,YAAA;CAM9B;AAED,qBAAa,YAAa,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CASlD;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,GAAE,MAA4B;CASlD;AAED,qBAAa,cAAe,SAAQ,aAAa;gBACnC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAOjD;AAED,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,OAAO,EAAE,MAAM;CAS5B;AAED,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAS5C;AAED,qBAAa,eAAgB,SAAQ,aAAa;IACZ,SAAS,CAAC,EAAE,MAAM;gBAA1C,OAAO,EAAE,MAAM,EAAS,SAAS,CAAC,EAAE,MAAM,YAAA;CAIvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQrD"}
package/dist/errors.js ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Custom error types for Qwen OAuth Plugin
3
+ */
4
+ export class QwenAuthError extends Error {
5
+ code;
6
+ recoverable;
7
+ userMessage;
8
+ constructor(message, code, recoverable = true, userMessage) {
9
+ super(message);
10
+ this.code = code;
11
+ this.recoverable = recoverable;
12
+ this.userMessage = userMessage;
13
+ this.name = "QwenAuthError";
14
+ Error.captureStackTrace(this, this.constructor);
15
+ }
16
+ }
17
+ export class NetworkError extends QwenAuthError {
18
+ constructor(message, userMessage) {
19
+ super(message, "NETWORK_ERROR", true, userMessage || "Network request failed. Please check your connection.");
20
+ this.name = "NetworkError";
21
+ }
22
+ }
23
+ export class TokenExpiredError extends QwenAuthError {
24
+ constructor(message = "Token has expired") {
25
+ super(message, "TOKEN_EXPIRED", true, "Your authentication token has expired. Please re-authenticate.");
26
+ this.name = "TokenExpiredError";
27
+ }
28
+ }
29
+ export class RateLimitError extends QwenAuthError {
30
+ constructor(message, waitTimeMs) {
31
+ const userMsg = waitTimeMs
32
+ ? `Rate limit exceeded. Please wait ${Math.ceil(waitTimeMs / 1000)} seconds.`
33
+ : "Rate limit exceeded. Please try again later.";
34
+ super(message, "RATE_LIMIT_EXCEEDED", true, userMsg);
35
+ this.name = "RateLimitError";
36
+ }
37
+ }
38
+ export class AuthorizationError extends QwenAuthError {
39
+ constructor(message) {
40
+ super(message, "AUTHORIZATION_ERROR", false, "Authorization failed. Please check your credentials.");
41
+ this.name = "AuthorizationError";
42
+ }
43
+ }
44
+ export class ValidationError extends QwenAuthError {
45
+ constructor(message, field) {
46
+ super(message, "VALIDATION_ERROR", false, field ? `Invalid ${field}: ${message}` : message);
47
+ this.name = "ValidationError";
48
+ }
49
+ }
50
+ export class DeviceFlowError extends QwenAuthError {
51
+ errorType;
52
+ constructor(message, errorType) {
53
+ super(message, "DEVICE_FLOW_ERROR", true, message);
54
+ this.errorType = errorType;
55
+ this.name = "DeviceFlowError";
56
+ }
57
+ }
58
+ /**
59
+ * Type guard to check if error is recoverable
60
+ */
61
+ export function isRecoverableError(error) {
62
+ if (error instanceof QwenAuthError) {
63
+ return error.recoverable;
64
+ }
65
+ return false;
66
+ }
67
+ /**
68
+ * Get user-friendly error message
69
+ */
70
+ export function getUserMessage(error) {
71
+ if (error instanceof QwenAuthError && error.userMessage) {
72
+ return error.userMessage;
73
+ }
74
+ if (error instanceof Error) {
75
+ return error.message;
76
+ }
77
+ return "An unexpected error occurred";
78
+ }
79
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAG7B;IACA;IACA;IAJT,YACE,OAAe,EACR,IAAY,EACZ,cAAuB,IAAI,EAC3B,WAAoB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAgB;QAC3B,gBAAW,GAAX,WAAW,CAAS;QAG3B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAED,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O,eAAgB,SAAQ,aAAa;IACZ;IAApC,YAAY,OAAe,EAAS,SAAkB;QACpD,KAAK,CAAC,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QADjB,cAAS,GAAT,SAAS,CAAS;QAEpD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,8BAA8B,CAAC;AACxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAM/D,eAAO,MAAM,eAAe,EAAE,MAiG7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAU/D,eAAO,MAAM,eAAe,EAAE,MA4K7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -5,9 +5,12 @@
5
5
  * @packageDocumentation
6
6
  */
7
7
  import { QWEN_API_BASE_URL } from "./constants.js";
8
- import { debugLog } from "./logger.js";
8
+ import { debugLog, warnLog } from "./logger.js";
9
9
  import { openBrowser } from "./browser.js";
10
10
  import { authorizeDevice, pollForToken } from "./oauth.js";
11
+ import { Mutex } from "./mutex.js";
12
+ // Mutex to prevent multiple concurrent authorization flows
13
+ const authorizationMutex = new Mutex();
11
14
  export const QwenOAuthPlugin = async ({ project, client, $, directory, worktree, }) => {
12
15
  debugLog("Plugin initialized", {
13
16
  directory,
@@ -22,40 +25,47 @@ export const QwenOAuthPlugin = async ({ project, client, $, directory, worktree,
22
25
  type: "oauth",
23
26
  label: "Qwen Code (qwen.ai OAuth)",
24
27
  authorize: async () => {
25
- debugLog("Starting Qwen OAuth device flow...");
26
- const device = await authorizeDevice();
27
- const url = device.verification_uri_complete || device.verification_uri;
28
- // Try to open browser automatically
29
- openBrowser(url);
30
- debugLog("Device authorization received", {
31
- user_code: device.user_code,
32
- verification_uri: device.verification_uri,
33
- expires_in: device.expires_in,
34
- interval: device.interval,
35
- });
36
- return {
37
- url,
38
- instructions: `Enter code: ${device.user_code}`,
39
- method: "auto",
40
- callback: async () => {
41
- debugLog("Polling for OAuth token...");
42
- const result = await pollForToken(device.device_code, device.verifier, device.interval, device.expires_in);
43
- if (result.success) {
44
- debugLog("Qwen authentication successful!", {
45
- expires_in: result.expires_in,
46
- has_refresh: !!result.refresh_token,
47
- });
48
- return {
49
- type: "success",
50
- access: result.access_token,
51
- refresh: result.refresh_token,
52
- expires: Date.now() + result.expires_in * 1000,
53
- };
54
- }
55
- debugLog(`Authentication failed: ${result.error}`);
56
- return { type: "failed", error: result.error };
57
- },
58
- };
28
+ // Check if authorization is already in progress
29
+ if (authorizationMutex.isLocked()) {
30
+ warnLog("Authorization already in progress");
31
+ throw new Error("Authorization already in progress. Please wait for the current flow to complete.");
32
+ }
33
+ return authorizationMutex.runExclusive(async () => {
34
+ debugLog("Starting Qwen OAuth device flow...");
35
+ const device = await authorizeDevice();
36
+ const url = device.verification_uri_complete || device.verification_uri;
37
+ // Try to open browser automatically
38
+ openBrowser(url);
39
+ debugLog("Device authorization received", {
40
+ user_code: device.user_code,
41
+ verification_uri: device.verification_uri,
42
+ expires_in: device.expires_in,
43
+ interval: device.interval,
44
+ });
45
+ return {
46
+ url,
47
+ instructions: `Enter code: ${device.user_code}`,
48
+ method: "auto",
49
+ callback: async () => {
50
+ debugLog("Polling for OAuth token...");
51
+ const result = await pollForToken(device.device_code, device.verifier, device.interval, device.expires_in);
52
+ if (result.success) {
53
+ debugLog("Qwen authentication successful!", {
54
+ expires_in: result.expires_in,
55
+ has_refresh: !!result.refresh_token,
56
+ });
57
+ return {
58
+ type: "success",
59
+ access: result.access_token,
60
+ refresh: result.refresh_token,
61
+ expires: Date.now() + result.expires_in * 1000,
62
+ };
63
+ }
64
+ debugLog(`Authentication failed: ${result.error}`);
65
+ return { type: "failed", error: result.error };
66
+ },
67
+ };
68
+ }); // End runExclusive
59
69
  },
60
70
  },
61
71
  ],
@@ -82,6 +92,63 @@ export const QwenOAuthPlugin = async ({ project, client, $, directory, worktree,
82
92
  },
83
93
  };
84
94
  },
95
+ // Event monitoring hook
96
+ event: async ({ event }) => {
97
+ // Log important events for debugging
98
+ if (event.type === "session.error") {
99
+ debugLog("Session error occurred", {
100
+ type: event.type,
101
+ timestamp: new Date().toISOString(),
102
+ });
103
+ }
104
+ if (event.type === "session.created") {
105
+ debugLog("New session created", {
106
+ type: event.type,
107
+ timestamp: new Date().toISOString(),
108
+ });
109
+ }
110
+ },
111
+ // Inject custom headers for Qwen API requests
112
+ "chat.headers": async (input, output) => {
113
+ // Only add headers for Qwen provider
114
+ if (input.provider.info.id === "qwen") {
115
+ debugLog("Adding custom headers for Qwen request", {
116
+ model: input.model.id,
117
+ session: input.sessionID,
118
+ });
119
+ // Add any custom headers needed for Qwen
120
+ // OpenCode will automatically handle the Authorization header
121
+ output.headers["X-Qwen-Client"] = "OpenCode";
122
+ output.headers["X-Qwen-Plugin-Version"] = "1.1.0";
123
+ }
124
+ },
125
+ // Customize model parameters for Qwen
126
+ "chat.params": async (input, output) => {
127
+ if (input.provider.info.id === "qwen") {
128
+ debugLog("Customizing parameters for Qwen model", {
129
+ model: input.model.id,
130
+ current_temp: output.temperature,
131
+ });
132
+ // Qwen models work well with these defaults
133
+ // Users can override these in their config
134
+ if (output.temperature === undefined) {
135
+ output.temperature = 0.7;
136
+ }
137
+ if (output.topP === undefined) {
138
+ output.topP = 0.95;
139
+ }
140
+ }
141
+ },
142
+ // Expose Qwen credentials as environment variables if needed
143
+ "shell.env": async (input, output) => {
144
+ debugLog("Setting up shell environment", {
145
+ cwd: input.cwd,
146
+ hasSession: !!input.sessionID,
147
+ });
148
+ // Add Qwen-specific environment variables
149
+ output.env.QWEN_API_BASE_URL = QWEN_API_BASE_URL;
150
+ output.env.QWEN_PROVIDER = "qwen";
151
+ },
85
152
  };
86
153
  };
87
154
  export default QwenOAuthPlugin;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,CAAC,MAAM,eAAe,GAAW,KAAK,EAAE,EAC5C,OAAO,EACP,MAAM,EACN,CAAC,EACD,SAAS,EACT,QAAQ,GACI,EAAE,EAAE;IAChB,QAAQ,CAAC,oBAAoB,EAAE;QAC7B,SAAS;QACT,QAAQ;QACR,OAAO,EAAG,OAAe,EAAE,IAAI,IAAI,KAAK;KACzC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,OAAO;oBACb,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M,EAAE,CAAC;gBACtC,QAAQ,CAAC,uCAAuC,EAAE;oBAChD,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;oBACrB,YAAY,EAAE,MAAM,CAAC,WAAW;iBACjC,CAAC,CAAC;gBAEH,4CAA4C;gBAC5C,2CAA2C;gBAC3C,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;oBACrC,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC;gBAC3B,CAAC;gBACD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QAED,6DAA6D;QAC7D,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACnC,QAAQ,CAAC,8BAA8B,EAAE;gBACvC,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS;aAC9B,CAAC,CAAC;YAEH,0CAA0C;YAC1C,MAAM,CAAC,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;YACjD,MAAM,CAAC,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/logger.d.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  /**
2
2
  * Logging utilities for Qwen OAuth Plugin
3
3
  */
4
+ export declare enum LogLevel {
5
+ DEBUG = 0,
6
+ INFO = 1,
7
+ WARN = 2,
8
+ ERROR = 3
9
+ }
4
10
  export declare const DEBUG: boolean;
5
11
  export declare function debugLog(message: string, data?: Record<string, unknown>): void;
12
+ export declare function infoLog(message: string, data?: Record<string, unknown>): void;
13
+ export declare function warnLog(message: string, data?: Record<string, unknown>): void;
14
+ export declare function errorLog(message: string, data?: Record<string, unknown>): void;
6
15
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiCH,eAAO,MAAM,KAAK,SAEoB,CAAC;AAEvC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAG9E"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AA2DD,eAAO,MAAM,KAAK,SAEoB,CAAC;AAEvC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE9E;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE7E;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE7E;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE9E"}