qwen-opencode-provider 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/index.js +13 -59
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -40,29 +40,7 @@ const QWEN_MODELS = {
40
40
  'qwen-cogview': { name: 'Qwen CogView' }
41
41
  };
42
42
 
43
- function getProviderConfig(apiKey = null) {
44
- const options = {
45
- baseURL: 'https://qwen.aikit.club/v1',
46
- headers: {
47
- 'Authorization': `Bearer ${apiKey || ''}`
48
- }
49
- };
50
-
51
- if (apiKey) {
52
- options.apiKey = apiKey;
53
- }
54
-
55
- return {
56
- npm: '@ai-sdk/openai-compatible',
57
- name: 'Qwen AI',
58
- options,
59
- models: QWEN_MODELS
60
- };
61
- }
62
-
63
43
  export const QwenPlugin = async (ctx) => {
64
- let cachedApiKey = null;
65
-
66
44
  return {
67
45
  config: async (config) => {
68
46
  if (!config.provider) {
@@ -70,48 +48,24 @@ export const QwenPlugin = async (ctx) => {
70
48
  }
71
49
 
72
50
  if (!config.provider[QWEN_PROVIDER_ID]) {
73
- config.provider[QWEN_PROVIDER_ID] = getProviderConfig(cachedApiKey);
74
- }
75
- },
76
-
77
- 'installation.updated': async ({ installation }) => {
78
- // Try to get API key from auth config
79
- if (installation?.auth?.[QWEN_PROVIDER_ID]?.apiKey) {
80
- cachedApiKey = installation.auth[QWEN_PROVIDER_ID].apiKey;
81
-
82
- // Update config with API key
83
- try {
84
- const configPath = ctx.project?.id
85
- ? `${ctx.directory}/opencode.json`
86
- : `${process.env.HOME}/.config/opencode/opencode.json`;
87
-
88
- const { exists } = await import('fs');
89
- if (exists(configPath)) {
90
- const { readFile, writeFile } = await import('fs/promises');
91
- try {
92
- const configContent = await readFile(configPath, 'utf-8');
93
- const config = JSON.parse(configContent);
94
-
95
- if (config.provider && config.provider[QWEN_PROVIDER_ID]) {
96
- config.provider[QWEN_PROVIDER_ID].options.apiKey = cachedApiKey;
97
- await writeFile(configPath, JSON.stringify(config, null, 2));
98
- }
99
- } catch (e) {
100
- // Ignore config read/write errors
101
- }
102
- }
103
- } catch (e) {
104
- // Ignore errors
105
- }
51
+ config.provider[QWEN_PROVIDER_ID] = {
52
+ npm: '@ai-sdk/openai-compatible',
53
+ name: 'Qwen AI',
54
+ options: {
55
+ baseURL: 'https://qwen.aikit.club/v1'
56
+ },
57
+ models: QWEN_MODELS
58
+ };
106
59
  }
107
60
  },
108
61
 
109
62
  auth: {
110
63
  provider: QWEN_PROVIDER_ID,
111
- loader: async (auth, provider) => {
112
- const apiKey = auth?.apiKey || cachedApiKey || '';
113
- cachedApiKey = apiKey;
114
- return { apiKey };
64
+ loader: async (auth) => {
65
+ if (auth?.apiKey) {
66
+ return { apiKey: auth.apiKey };
67
+ }
68
+ return { apiKey: '' };
115
69
  },
116
70
  methods: [
117
71
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-opencode-provider",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "OpenCode plugin for Qwen API - auto adds provider with 28+ models",
5
5
  "main": "index.js",
6
6
  "type": "module",