@openclaw/qwen-provider 2026.9.5 → 2026.9.7

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/assets/icon.png CHANGED
Binary file
@@ -0,0 +1,12 @@
1
+ //#region extensions/qwen/failover.ts
2
+ /** DashScope uses the same quota code for temporary limits and exhausted free credits. */
3
+ const classifyQwenFailoverReason = (context) => {
4
+ if (context.status !== 429) return;
5
+ const codes = [context.code, context.errorType].map((code) => code?.trim().toLowerCase());
6
+ if (codes.some((code) => code === "prepaidbilloverdue" || code === "postpaidbilloverdue")) return "billing";
7
+ if (!codes.some((code) => code === "insufficient_quota" || code === "throttling.allocationquota")) return;
8
+ if (/\bfree allocated quota exceeded\b/i.test(context.errorMessage)) return "billing";
9
+ if (/\ballocated quota exceeded, please increase your quota limit\b/i.test(context.errorMessage) || /\byou exceeded your current quota, please check your plan and billing details\b/i.test(context.errorMessage)) return "rate_limit";
10
+ };
11
+ //#endregion
12
+ export { classifyQwenFailoverReason };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { classifyQwenFailoverReason } from "./failover.js";
1
2
  import { B as isQwen38ModelId, D as QWEN_TOKEN_PLAN_LEGACY_PROVIDER_ID, H as isQwenStandardOnlyModelId, J as supportsQwenTokenPlanGlmMaxThinking, K as isQwenTokenPlanThinkingOnlyModelId, T as QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF, U as isQwenTokenPlanDeepSeekV4ModelId, V as isQwenCodingPlanBaseUrl, W as isQwenTokenPlanGlmModelId, k as QWEN_TOKEN_PLAN_PROVIDER_ID, v as QWEN_DEFAULT_MODEL_REF } from "./.setup/models-DIZ7f-Lx.mjs";
2
3
  import { buildQwenMediaUnderstandingProvider } from "./media-understanding-provider.js";
3
4
  import { buildQwenProvider, buildQwenTokenPlanProvider } from "./provider-catalog.js";
@@ -21,24 +22,44 @@ const QWEN_TOKEN_PLAN_THINKING_LEVEL_IDS = [
21
22
  "max"
22
23
  ];
23
24
  const QWEN_TOKEN_PLAN_GLM_NO_MAX_THINKING_LEVEL_IDS = QWEN_TOKEN_PLAN_THINKING_LEVEL_IDS.filter((id) => id !== "max");
24
- function resolveConfiguredQwenBaseUrl(config) {
25
- const providers = config?.models?.providers;
26
- if (!providers) return;
27
- for (const [providerId, provider] of Object.entries(providers)) {
28
- const normalized = normalizeLowercaseStringOrEmpty(providerId);
29
- if (normalized !== PROVIDER_ID && normalized !== LEGACY_PROVIDER_ID) continue;
25
+ function resolveConfiguredQwenBaseUrl(config, providerIds) {
26
+ for (const [providerId, provider] of Object.entries(config?.models?.providers ?? {})) {
27
+ if (!providerIds.includes(normalizeLowercaseStringOrEmpty(providerId))) continue;
30
28
  const baseUrl = provider?.baseUrl?.trim();
31
29
  if (baseUrl) return baseUrl;
32
30
  }
33
31
  }
34
- function resolveConfiguredQwenTokenPlanBaseUrl(config) {
35
- const providers = config?.models?.providers;
36
- if (!providers) return;
37
- for (const [providerId, provider] of Object.entries(providers)) {
38
- if (normalizeLowercaseStringOrEmpty(providerId) !== "qwen-token-plan") continue;
39
- const baseUrl = provider?.baseUrl?.trim();
40
- if (baseUrl) return baseUrl;
41
- }
32
+ function createQwenAuthMethod(plan, region) {
33
+ const isStandard = plan === "standard";
34
+ const isCn = region === "cn";
35
+ const regionLabel = isCn ? "China" : "Global/Intl";
36
+ const planLabel = isStandard ? "Standard" : "Coding Plan";
37
+ const host = isStandard ? isCn ? "dashscope.aliyuncs.com" : "dashscope-intl.aliyuncs.com" : isCn ? "coding.dashscope.aliyuncs.com" : "coding-intl.dashscope.aliyuncs.com";
38
+ const standardKey = isStandard ? "Standard" : "";
39
+ const standardFlag = isStandard ? "standard-" : "";
40
+ return {
41
+ methodId: `${standardFlag}api-key${isCn ? "-cn" : ""}`,
42
+ label: `${planLabel} API Key for ${regionLabel} (${isStandard ? "pay-as-you-go" : "subscription"})`,
43
+ hint: `Endpoint: ${host}`,
44
+ optionKey: `modelstudio${standardKey}ApiKey${isCn ? "Cn" : ""}`,
45
+ flagName: `--modelstudio-${standardFlag}api-key${isCn ? "-cn" : ""}`,
46
+ envVar: "QWEN_API_KEY",
47
+ promptMessage: isStandard ? `Enter Qwen Cloud API key (${regionLabel} standard endpoint)` : `Enter Qwen Cloud Coding Plan API key (${regionLabel})`,
48
+ defaultModel: QWEN_DEFAULT_MODEL_REF,
49
+ applyConfig: isStandard ? isCn ? applyQwenStandardConfigCn : applyQwenStandardConfig : isCn ? applyQwenConfigCn : applyQwenConfig,
50
+ noteMessage: [
51
+ "Manage API keys: https://home.qwencloud.com/api-keys",
52
+ "Docs: https://docs.qwencloud.com/",
53
+ `Endpoint: ${host}${isStandard ? "/compatible-mode/v1" : ""}`,
54
+ isStandard ? "Models: qwen3.8-max, qwen3.8-flash, qwen3.7-plus, and other discovered models." : "Models: qwen3.5-plus, glm-5, kimi-k2.5, MiniMax-M2.5, etc."
55
+ ].join("\n"),
56
+ noteTitle: `Qwen Cloud ${planLabel} (${regionLabel})`,
57
+ wizard: {
58
+ choiceHint: `Endpoint: ${host}`,
59
+ groupLabel: "Qwen Cloud",
60
+ groupHint: "Standard / Coding Plan (CN / Global) + multimodal roadmap"
61
+ }
62
+ };
42
63
  }
43
64
  function createQwenTokenPlanAuthMethod(region) {
44
65
  const isCn = region === "cn";
@@ -105,104 +126,16 @@ var qwen_default = defineSingleProviderPluginEntry({
105
126
  docsPath: "/providers/qwen",
106
127
  aliases: ["modelstudio", "qwencloud"],
107
128
  auth: [
108
- {
109
- methodId: "standard-api-key-cn",
110
- label: "Standard API Key for China (pay-as-you-go)",
111
- hint: "Endpoint: dashscope.aliyuncs.com",
112
- optionKey: "modelstudioStandardApiKeyCn",
113
- flagName: "--modelstudio-standard-api-key-cn",
114
- envVar: "QWEN_API_KEY",
115
- promptMessage: "Enter Qwen Cloud API key (China standard endpoint)",
116
- defaultModel: QWEN_DEFAULT_MODEL_REF,
117
- applyConfig: (cfg) => applyQwenStandardConfigCn(cfg),
118
- noteMessage: [
119
- "Manage API keys: https://home.qwencloud.com/api-keys",
120
- "Docs: https://docs.qwencloud.com/",
121
- "Endpoint: dashscope.aliyuncs.com/compatible-mode/v1",
122
- "Models: qwen3.8-max, qwen3.8-flash, qwen3.7-plus, and other discovered models."
123
- ].join("\n"),
124
- noteTitle: "Qwen Cloud Standard (China)",
125
- wizard: {
126
- choiceHint: "Endpoint: dashscope.aliyuncs.com",
127
- groupLabel: "Qwen Cloud",
128
- groupHint: "Standard / Coding Plan (CN / Global) + multimodal roadmap"
129
- }
130
- },
131
- {
132
- methodId: "standard-api-key",
133
- label: "Standard API Key for Global/Intl (pay-as-you-go)",
134
- hint: "Endpoint: dashscope-intl.aliyuncs.com",
135
- optionKey: "modelstudioStandardApiKey",
136
- flagName: "--modelstudio-standard-api-key",
137
- envVar: "QWEN_API_KEY",
138
- promptMessage: "Enter Qwen Cloud API key (Global/Intl standard endpoint)",
139
- defaultModel: QWEN_DEFAULT_MODEL_REF,
140
- applyConfig: (cfg) => applyQwenStandardConfig(cfg),
141
- noteMessage: [
142
- "Manage API keys: https://home.qwencloud.com/api-keys",
143
- "Docs: https://docs.qwencloud.com/",
144
- "Endpoint: dashscope-intl.aliyuncs.com/compatible-mode/v1",
145
- "Models: qwen3.8-max, qwen3.8-flash, qwen3.7-plus, and other discovered models."
146
- ].join("\n"),
147
- noteTitle: "Qwen Cloud Standard (Global/Intl)",
148
- wizard: {
149
- choiceHint: "Endpoint: dashscope-intl.aliyuncs.com",
150
- groupLabel: "Qwen Cloud",
151
- groupHint: "Standard / Coding Plan (CN / Global) + multimodal roadmap"
152
- }
153
- },
154
- {
155
- methodId: "api-key-cn",
156
- label: "Coding Plan API Key for China (subscription)",
157
- hint: "Endpoint: coding.dashscope.aliyuncs.com",
158
- optionKey: "modelstudioApiKeyCn",
159
- flagName: "--modelstudio-api-key-cn",
160
- envVar: "QWEN_API_KEY",
161
- promptMessage: "Enter Qwen Cloud Coding Plan API key (China)",
162
- defaultModel: QWEN_DEFAULT_MODEL_REF,
163
- applyConfig: (cfg) => applyQwenConfigCn(cfg),
164
- noteMessage: [
165
- "Manage API keys: https://home.qwencloud.com/api-keys",
166
- "Docs: https://docs.qwencloud.com/",
167
- "Endpoint: coding.dashscope.aliyuncs.com",
168
- "Models: qwen3.5-plus, glm-5, kimi-k2.5, MiniMax-M2.5, etc."
169
- ].join("\n"),
170
- noteTitle: "Qwen Cloud Coding Plan (China)",
171
- wizard: {
172
- choiceHint: "Endpoint: coding.dashscope.aliyuncs.com",
173
- groupLabel: "Qwen Cloud",
174
- groupHint: "Standard / Coding Plan (CN / Global) + multimodal roadmap"
175
- }
176
- },
177
- {
178
- methodId: "api-key",
179
- label: "Coding Plan API Key for Global/Intl (subscription)",
180
- hint: "Endpoint: coding-intl.dashscope.aliyuncs.com",
181
- optionKey: "modelstudioApiKey",
182
- flagName: "--modelstudio-api-key",
183
- envVar: "QWEN_API_KEY",
184
- promptMessage: "Enter Qwen Cloud Coding Plan API key (Global/Intl)",
185
- defaultModel: QWEN_DEFAULT_MODEL_REF,
186
- applyConfig: (cfg) => applyQwenConfig(cfg),
187
- noteMessage: [
188
- "Manage API keys: https://home.qwencloud.com/api-keys",
189
- "Docs: https://docs.qwencloud.com/",
190
- "Endpoint: coding-intl.dashscope.aliyuncs.com",
191
- "Models: qwen3.5-plus, glm-5, kimi-k2.5, MiniMax-M2.5, etc."
192
- ].join("\n"),
193
- noteTitle: "Qwen Cloud Coding Plan (Global/Intl)",
194
- wizard: {
195
- choiceHint: "Endpoint: coding-intl.dashscope.aliyuncs.com",
196
- groupLabel: "Qwen Cloud",
197
- groupHint: "Standard / Coding Plan (CN / Global) + multimodal roadmap"
198
- }
199
- }
129
+ createQwenAuthMethod("standard", "cn"),
130
+ createQwenAuthMethod("standard", "global"),
131
+ createQwenAuthMethod("coding", "cn"),
132
+ createQwenAuthMethod("coding", "global")
200
133
  ],
201
134
  catalog: {
202
135
  run: async (ctx) => {
203
136
  const auth = ctx.resolveProviderApiKey(PROVIDER_ID);
204
137
  if (!auth.apiKey) return null;
205
- const baseUrl = resolveConfiguredQwenBaseUrl(ctx.config) ?? "https://coding-intl.dashscope.aliyuncs.com/v1";
138
+ const baseUrl = resolveConfiguredQwenBaseUrl(ctx.config, [PROVIDER_ID, LEGACY_PROVIDER_ID]) ?? "https://coding-intl.dashscope.aliyuncs.com/v1";
206
139
  return await buildOpenAICompatibleLiveProviderCatalog({
207
140
  discoveryMode: "strict",
208
141
  providerId: PROVIDER_ID,
@@ -216,6 +149,7 @@ var qwen_default = defineSingleProviderPluginEntry({
216
149
  },
217
150
  wrapStreamFn: wrapQwenProviderStream,
218
151
  wrapSimpleCompletionStreamFn: wrapQwenProviderStream,
152
+ classifyFailoverReason: classifyQwenFailoverReason,
219
153
  resolveThinkingProfile: ({ modelId }) => resolveQwenThinkingProfile(modelId),
220
154
  normalizeConfig: ({ providerConfig }) => {
221
155
  if (!isQwenCodingPlanBaseUrl(providerConfig.baseUrl)) return;
@@ -238,7 +172,7 @@ var qwen_default = defineSingleProviderPluginEntry({
238
172
  run: async (ctx) => {
239
173
  const auth = ctx.resolveProviderApiKey(QWEN_TOKEN_PLAN_PROVIDER_ID);
240
174
  if (!auth.apiKey) return null;
241
- const baseUrl = resolveConfiguredQwenTokenPlanBaseUrl(ctx.config);
175
+ const baseUrl = resolveConfiguredQwenBaseUrl(ctx.config, [QWEN_TOKEN_PLAN_PROVIDER_ID]);
242
176
  return await buildOpenAICompatibleLiveProviderCatalog({
243
177
  discoveryMode: "strict",
244
178
  providerId: QWEN_TOKEN_PLAN_PROVIDER_ID,
@@ -255,6 +189,7 @@ var qwen_default = defineSingleProviderPluginEntry({
255
189
  },
256
190
  wrapStreamFn: wrapQwenProviderStream,
257
191
  wrapSimpleCompletionStreamFn: wrapQwenProviderStream,
192
+ classifyFailoverReason: classifyQwenFailoverReason,
258
193
  resolveThinkingProfile: ({ modelId }) => resolveQwenTokenPlanThinkingProfile(modelId)
259
194
  });
260
195
  api.registerProvider({
@@ -263,7 +198,8 @@ var qwen_default = defineSingleProviderPluginEntry({
263
198
  docsPath: "/providers/qwen",
264
199
  auth: [],
265
200
  wrapStreamFn: wrapQwenProviderStream,
266
- wrapSimpleCompletionStreamFn: wrapQwenProviderStream
201
+ wrapSimpleCompletionStreamFn: wrapQwenProviderStream,
202
+ classifyFailoverReason: classifyQwenFailoverReason
267
203
  });
268
204
  api.registerMediaUnderstandingProvider(buildQwenMediaUnderstandingProvider());
269
205
  api.registerVideoGenerationProvider(qwenVideoGenerationProvider);
package/dist/stream.js CHANGED
@@ -104,11 +104,6 @@ function enforceQwenPayloadAfterCaller(payload, tokenPlanContract, forceThinking
104
104
  delete payload.reasoningEffort;
105
105
  delete payload.reasoning;
106
106
  }
107
- function finalizeQwenPayloadAfterCaller(value, fallbackPayload, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel) {
108
- const finalPayload = asOptionalRecord(value) ?? fallbackPayload;
109
- if (finalPayload) enforceQwenPayloadAfterCaller(finalPayload, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel);
110
- return value;
111
- }
112
107
  function createQwenConstraintWrapper(baseStreamFn, tokenPlanContract, forceThinking, thinkingLevel, sourceApi) {
113
108
  const underlying = baseStreamFn ?? streamSimple;
114
109
  return (model, context, options) => {
@@ -123,9 +118,14 @@ function createQwenConstraintWrapper(baseStreamFn, tokenPlanContract, forceThink
123
118
  ...options,
124
119
  onPayload(payload, payloadModel) {
125
120
  const payloadObj = asOptionalRecord(payload);
121
+ const finalizePayload = (value) => {
122
+ const finalPayload = asOptionalRecord(value) ?? payloadObj;
123
+ if (finalPayload) enforceQwenPayloadAfterCaller(finalPayload, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel);
124
+ return value;
125
+ };
126
126
  const result = originalOnPayload?.(payload, payloadModel);
127
- if (result && typeof result.then === "function") return Promise.resolve(result).then((resolved) => finalizeQwenPayloadAfterCaller(resolved, payloadObj, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel));
128
- return finalizeQwenPayloadAfterCaller(result, payloadObj, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel);
127
+ if (result && typeof result.then === "function") return Promise.resolve(result).then(finalizePayload);
128
+ return finalizePayload(result);
129
129
  }
130
130
  });
131
131
  };
@@ -411,10 +411,21 @@
411
411
  "qwen-token-plan": "refreshable"
412
412
  }
413
413
  },
414
+ "modelPricing": {
415
+ "providers": {
416
+ "qwen": { "modelsDev": { "provider": "alibaba" } },
417
+ "qwen-token-plan": { "modelsDev": { "provider": "alibaba" } }
418
+ }
419
+ },
414
420
  "contracts": {
415
421
  "mediaUnderstandingProviders": ["qwen"],
416
422
  "videoGenerationProviders": ["qwen"]
417
423
  },
424
+ "videoGenerationProviderMetadata": {
425
+ "qwen": {
426
+ "authSignals": [{ "provider": "qwen" }]
427
+ }
428
+ },
418
429
  "mediaUnderstandingProviderMetadata": {
419
430
  "qwen": {
420
431
  "capabilities": ["image", "video"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/qwen-provider",
3
- "version": "2026.9.5",
3
+ "version": "2026.9.7",
4
4
  "description": "OpenClaw Qwen Cloud provider plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.8"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.5"
21
+ "pluginApi": ">=2026.9.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.5",
24
+ "openclawVersion": "2026.9.7",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.9.5"
43
+ "openclaw": ">=2026.9.7"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {