@openclaw/qwen-provider 2026.10.10 → 2026.11.5-beta.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/dist/.source-module-urls/1fb20072dbb35697afbceabb168bd62709e8953b9a19d97525528b9c0aedf35b.json +1 -0
- package/dist/index.js +58 -6
- package/dist/stream.js +74 -77
- package/package.json +4 -4
- package/dist/.source-module-urls/428a35a4cd0c121bd04d29d3c8fe5458ed7a88f101db64bb3ad78d8d20834a73.json +0 -1
- package/dist/media-understanding-provider.js +0 -30
- package/dist/onboard.js +0 -52
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/qwen/api.ts"},{"output":"failover.js","source":"extensions/qwen/failover.ts"},{"output":"index.js","source":"extensions/qwen/index.ts"},{"output":"models.js","source":"extensions/qwen/models.ts"},{"output":"provider-catalog.js","source":"extensions/qwen/provider-catalog.ts"},{"output":"stream.js","source":"extensions/qwen/stream.ts"},{"output":"video-generation-provider.js","source":"extensions/qwen/video-generation-provider.ts"}],"chunks":[{"output":".setup/models-BHyvoc6Y.mjs","sha256":"57a2483c0c066601ef9d2f5285c311cee40b20b14fc516c70d65461fc2c5cd58","facadeSource":null,"sources":["extensions/qwen/models.ts","extensions/qwen/openclaw.plugin.json"]},{"output":"api.js","sha256":"5139a6af6eadfd3207c7e8bdf8f2d8556042454154b3f9312dafa938d86aad3d","facadeSource":"extensions/qwen/api.ts","sources":[]},{"output":"failover.js","sha256":"7124cb636da55379349a47fa7d9df6f963faf09953e9b00772b52d435719053e","facadeSource":"extensions/qwen/failover.ts","sources":["extensions/qwen/failover.ts"]},{"output":"index.js","sha256":"b3068a0eacd114475518407fb1be4e75d7cf2ab1ce837c2978150abd8156800e","facadeSource":"extensions/qwen/index.ts","sources":["extensions/qwen/index.ts"]},{"output":"models.js","sha256":"913b8b215a159d16c8f0079d12d0f2ddf4fffee884207285edbabc7bf663551a","facadeSource":"extensions/qwen/models.ts","sources":[]},{"output":"provider-catalog.js","sha256":"580c87b069627873a86702aa39429bd10a14890f6967a748f051d310a1822985","facadeSource":"extensions/qwen/provider-catalog.ts","sources":["extensions/qwen/provider-catalog.ts"]},{"output":"stream.js","sha256":"86f2508baedf698603636efe249602c698b9af1b2279da7bed49d42a4094aaa8","facadeSource":"extensions/qwen/stream.ts","sources":["extensions/qwen/stream.ts"]},{"output":"video-generation-provider.js","sha256":"671843d3ee585d8c4d48bfc1260b1163f12f56a0c36729c5ecfc755cefdd08a0","facadeSource":"extensions/qwen/video-generation-provider.ts","sources":["extensions/qwen/video-generation-provider.ts"]}],"unrenderedSources":["extensions/qwen/api.ts"]}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { classifyQwenFailoverReason } from "./failover.js";
|
|
2
|
-
import { B as isQwenStandardOnlyModelId, D as QWEN_TOKEN_PLAN_LEGACY_PROVIDER_ID, H as isQwenTokenPlanGlmModelId, K as supportsQwenTokenPlanGlmMaxThinking, R as isQwen38ModelId, T as QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF, V as isQwenTokenPlanDeepSeekV4ModelId, W as isQwenTokenPlanThinkingOnlyModelId, k as QWEN_TOKEN_PLAN_PROVIDER_ID, v as QWEN_DEFAULT_MODEL_REF, z as isQwenCodingPlanBaseUrl } from "./.setup/models-BHyvoc6Y.mjs";
|
|
3
|
-
import { buildQwenMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
2
|
+
import { B as isQwenStandardOnlyModelId, D as QWEN_TOKEN_PLAN_LEGACY_PROVIDER_ID, G as resolveQwenTokenPlanBaseUrl, H as isQwenTokenPlanGlmModelId, K as supportsQwenTokenPlanGlmMaxThinking, R as isQwen38ModelId, S as QWEN_STANDARD_GLOBAL_BASE_URL, T as QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF, V as isQwenTokenPlanDeepSeekV4ModelId, W as isQwenTokenPlanThinkingOnlyModelId, h as QWEN_CN_BASE_URL, k as QWEN_TOKEN_PLAN_PROVIDER_ID, v as QWEN_DEFAULT_MODEL_REF, x as QWEN_STANDARD_CN_BASE_URL, y as QWEN_GLOBAL_BASE_URL, z as isQwenCodingPlanBaseUrl } from "./.setup/models-BHyvoc6Y.mjs";
|
|
4
3
|
import { buildQwenProvider, buildQwenTokenPlanProvider } from "./provider-catalog.js";
|
|
5
|
-
import { applyQwenConfig, applyQwenConfigCn, applyQwenStandardConfig, applyQwenStandardConfigCn, applyQwenTokenPlanConfig } from "./onboard.js";
|
|
6
4
|
import { wrapQwenProviderStream } from "./stream.js";
|
|
7
5
|
import { qwenVideoGenerationProvider } from "./video-generation-provider.js";
|
|
6
|
+
import { describeOpenAiCompatibleVideo } from "openclaw/plugin-sdk/media-understanding";
|
|
8
7
|
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
|
9
8
|
import { buildOpenAICompatibleLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
10
9
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
10
|
+
import { createProviderConnectionPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
11
11
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
12
|
// extensions/qwen/index.ts
|
|
13
13
|
const PROVIDER_ID = "qwen";
|
|
14
14
|
const LEGACY_PROVIDER_ID = "modelstudio";
|
|
15
|
+
const DEFAULT_QWEN_MEDIA_MODEL = "qwen3.6-plus";
|
|
16
|
+
const DEFAULT_QWEN_VIDEO_PROMPT = "Describe the video in detail.";
|
|
15
17
|
const QWEN_TOKEN_PLAN_THINKING_LEVEL_IDS = [
|
|
16
18
|
"off",
|
|
17
19
|
"minimal",
|
|
@@ -22,6 +24,38 @@ const QWEN_TOKEN_PLAN_THINKING_LEVEL_IDS = [
|
|
|
22
24
|
"max"
|
|
23
25
|
];
|
|
24
26
|
const QWEN_TOKEN_PLAN_GLM_NO_MAX_THINKING_LEVEL_IDS = QWEN_TOKEN_PLAN_THINKING_LEVEL_IDS.filter((id) => id !== "max");
|
|
27
|
+
const qwenPresetAppliers = createProviderConnectionPresetAppliers({
|
|
28
|
+
primaryModelRef: QWEN_DEFAULT_MODEL_REF,
|
|
29
|
+
resolveParams: (_cfg, baseUrl) => {
|
|
30
|
+
const provider = buildQwenProvider({ baseUrl });
|
|
31
|
+
return {
|
|
32
|
+
providerId: "qwen",
|
|
33
|
+
api: provider.api ?? "openai-completions",
|
|
34
|
+
baseUrl,
|
|
35
|
+
catalogModels: provider.models,
|
|
36
|
+
aliases: [...provider.models.flatMap((model) => [`qwen/${model.id}`, `modelstudio/${model.id}`]), {
|
|
37
|
+
modelRef: QWEN_DEFAULT_MODEL_REF,
|
|
38
|
+
alias: "Qwen"
|
|
39
|
+
}]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const qwenTokenPlanPresetAppliers = createProviderConnectionPresetAppliers({
|
|
44
|
+
primaryModelRef: QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
45
|
+
resolveParams: (_cfg, baseUrl) => {
|
|
46
|
+
const provider = buildQwenTokenPlanProvider({ baseUrl });
|
|
47
|
+
return {
|
|
48
|
+
providerId: QWEN_TOKEN_PLAN_PROVIDER_ID,
|
|
49
|
+
api: provider.api ?? "openai-completions",
|
|
50
|
+
baseUrl,
|
|
51
|
+
catalogModels: provider.models,
|
|
52
|
+
aliases: [...provider.models.map((model) => `${QWEN_TOKEN_PLAN_PROVIDER_ID}/${model.id}`), {
|
|
53
|
+
modelRef: QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
54
|
+
alias: "Qwen Token Plan"
|
|
55
|
+
}]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
25
59
|
function resolveConfiguredQwenBaseUrl(config, providerIds) {
|
|
26
60
|
for (const [providerId, provider] of Object.entries(config?.models?.providers ?? {})) {
|
|
27
61
|
if (!providerIds.includes(normalizeLowercaseStringOrEmpty(providerId))) continue;
|
|
@@ -59,7 +93,7 @@ function createQwenAuthMethod(plan, region) {
|
|
|
59
93
|
envVar: "QWEN_API_KEY",
|
|
60
94
|
promptMessage: isStandard ? `Enter Qwen Cloud API key (${regionLabel} standard endpoint)` : `Enter Qwen Cloud Coding Plan API key (${regionLabel})`,
|
|
61
95
|
defaultModel: QWEN_DEFAULT_MODEL_REF,
|
|
62
|
-
applyConfig: isStandard ? isCn ?
|
|
96
|
+
applyConfig: (cfg) => qwenPresetAppliers.applyConfig(cfg, isStandard ? isCn ? QWEN_STANDARD_CN_BASE_URL : QWEN_STANDARD_GLOBAL_BASE_URL : isCn ? QWEN_CN_BASE_URL : QWEN_GLOBAL_BASE_URL),
|
|
63
97
|
noteMessage: [
|
|
64
98
|
"Manage API keys: https://home.qwencloud.com/api-keys",
|
|
65
99
|
"Docs: https://docs.qwencloud.com/",
|
|
@@ -88,7 +122,7 @@ function createQwenTokenPlanAuthMethod(region) {
|
|
|
88
122
|
envVar: "QWEN_TOKEN_PLAN_API_KEY",
|
|
89
123
|
promptMessage: `Enter Alibaba Qwen Token Plan API key (${regionLabel}, sk-sp-...)`,
|
|
90
124
|
defaultModel: QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
91
|
-
applyConfig: (cfg) =>
|
|
125
|
+
applyConfig: (cfg) => qwenTokenPlanPresetAppliers.applyConfig(cfg, resolveQwenTokenPlanBaseUrl(region)),
|
|
92
126
|
wizard: {
|
|
93
127
|
choiceId: isCn ? "qwen-token-plan-cn" : "qwen-token-plan",
|
|
94
128
|
choiceLabel: `Qwen Token Plan (${regionLabel})`,
|
|
@@ -191,7 +225,25 @@ var qwen_default = defineSingleProviderPluginEntry({
|
|
|
191
225
|
wrapSimpleCompletionStreamFn: wrapQwenProviderStream,
|
|
192
226
|
classifyFailoverReason: classifyQwenFailoverReason
|
|
193
227
|
});
|
|
194
|
-
api.registerMediaUnderstandingProvider(
|
|
228
|
+
api.registerMediaUnderstandingProvider({
|
|
229
|
+
id: "qwen",
|
|
230
|
+
capabilities: ["image", "video"],
|
|
231
|
+
defaultModels: {
|
|
232
|
+
image: DEFAULT_QWEN_MEDIA_MODEL,
|
|
233
|
+
video: DEFAULT_QWEN_MEDIA_MODEL
|
|
234
|
+
},
|
|
235
|
+
autoPriority: { video: 15 },
|
|
236
|
+
describeImage: void 0,
|
|
237
|
+
describeImages: void 0,
|
|
238
|
+
describeVideo: (params) => describeOpenAiCompatibleVideo({
|
|
239
|
+
...params,
|
|
240
|
+
defaultBaseUrl: QWEN_STANDARD_GLOBAL_BASE_URL,
|
|
241
|
+
defaultModel: DEFAULT_QWEN_MEDIA_MODEL,
|
|
242
|
+
defaultPrompt: DEFAULT_QWEN_VIDEO_PROMPT,
|
|
243
|
+
provider: "qwen",
|
|
244
|
+
providerLabel: "Qwen"
|
|
245
|
+
})
|
|
246
|
+
});
|
|
195
247
|
api.registerVideoGenerationProvider(qwenVideoGenerationProvider);
|
|
196
248
|
}
|
|
197
249
|
});
|
package/dist/stream.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { H as isQwenTokenPlanGlmModelId, K as supportsQwenTokenPlanGlmMaxThinking, R as isQwen38ModelId, U as isQwenTokenPlanKimiModelId, V as isQwenTokenPlanDeepSeekV4ModelId, W as isQwenTokenPlanThinkingOnlyModelId } from "./.setup/models-BHyvoc6Y.mjs";
|
|
1
|
+
import { H as isQwenTokenPlanGlmModelId, K as supportsQwenTokenPlanGlmMaxThinking, R as isQwen38ModelId, U as isQwenTokenPlanKimiModelId, V as isQwenTokenPlanDeepSeekV4ModelId, W as isQwenTokenPlanThinkingOnlyModelId, k as QWEN_TOKEN_PLAN_PROVIDER_ID } from "./.setup/models-BHyvoc6Y.mjs";
|
|
2
2
|
import { asOptionalObjectRecord, asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
4
|
-
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
5
|
-
import { createPayloadPatchStreamWrapper, isOpenAICompatibleThinkingEnabled, normalizeOpenAICompatibleReasoningReplay, setQwenChatTemplateThinking } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
4
|
+
import { normalizeProviderId, resolveProviderEndpoint } from "openclaw/plugin-sdk/provider-model-shared";
|
|
5
|
+
import { createPayloadPatchStreamWrapper, isOpenAICompatibleThinkingEnabled, normalizeOpenAICompatibleReasoningReplay, setQwenChatTemplateThinking, wrapProviderPayloadHook } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
6
6
|
// extensions/qwen/stream.ts
|
|
7
7
|
function resolveQwenThinkingLevel(thinkingLevel, options) {
|
|
8
8
|
const runtimeOptions = options ?? {};
|
|
@@ -31,6 +31,12 @@ function isQwenTokenPlanProviderId(providerId) {
|
|
|
31
31
|
const normalized = normalizeProviderId(providerId);
|
|
32
32
|
return normalized === "qwen-token-plan" || normalized === "bailian-token-plan";
|
|
33
33
|
}
|
|
34
|
+
function resolveQwenStreamProviderId(ctx) {
|
|
35
|
+
if (isQwenProviderId(ctx.provider)) return ctx.provider;
|
|
36
|
+
const endpoint = resolveProviderEndpoint(ctx.model?.baseUrl);
|
|
37
|
+
if (endpoint.endpointClass !== "modelstudio-native") return;
|
|
38
|
+
return endpoint.hostname === new URL("https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1").hostname || endpoint.hostname === new URL("https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1").hostname ? QWEN_TOKEN_PLAN_PROVIDER_ID : "qwen";
|
|
39
|
+
}
|
|
34
40
|
function resolveQwenThinkingContract(providerId, modelId) {
|
|
35
41
|
if (isQwen38ModelId(modelId)) return { family: "qwen-3.8" };
|
|
36
42
|
if (!isQwenTokenPlanProviderId(providerId)) return;
|
|
@@ -63,76 +69,6 @@ function patchTokenPlanKimiPayload(payload, enableThinking) {
|
|
|
63
69
|
shouldBackfillAssistantMessage: (message) => Array.isArray(message.tool_calls) && message.tool_calls.length > 0
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
|
-
function normalizeTokenPlanThinkingToolChoice(payload, enableThinking, forceThinking) {
|
|
67
|
-
if (!enableThinking) return false;
|
|
68
|
-
const toolChoice = payload.tool_choice;
|
|
69
|
-
const toolChoiceType = asOptionalRecord(toolChoice)?.type;
|
|
70
|
-
if (toolChoiceType === "auto" || toolChoiceType === "none") {
|
|
71
|
-
payload.tool_choice = toolChoiceType;
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (toolChoice == null || toolChoice === "auto" || toolChoice === "none") return true;
|
|
75
|
-
if (!forceThinking && (toolChoiceType === "tool" || toolChoiceType === "function")) {
|
|
76
|
-
payload.enable_thinking = false;
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
payload.tool_choice = "auto";
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
function enforceQwenPayloadAfterCaller(payload, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel) {
|
|
83
|
-
const hasPayloadThinking = typeof payload.enable_thinking === "boolean";
|
|
84
|
-
let enableThinking = forceThinking || (hasPayloadThinking ? payload.enable_thinking !== false : requestedEnableThinking);
|
|
85
|
-
const rawThinkingLevel = typeof payload.reasoning_effort === "string" ? payload.reasoning_effort : hasPayloadThinking ? void 0 : requestedThinkingLevel;
|
|
86
|
-
if (!forceThinking && (rawThinkingLevel === "off" || tokenPlanContract?.family === "qwen-3.8" && rawThinkingLevel === "none")) enableThinking = false;
|
|
87
|
-
payload.enable_thinking = enableThinking;
|
|
88
|
-
enableThinking = normalizeTokenPlanThinkingToolChoice(payload, enableThinking, forceThinking);
|
|
89
|
-
if (tokenPlanContract?.family === "qwen-3.8") patchQwen38Payload(payload, normalizeQwenThinkingLevel(rawThinkingLevel), enableThinking);
|
|
90
|
-
else if (tokenPlanContract?.family === "deepseek-v4") patchTokenPlanDeepSeekV4Payload(payload, rawThinkingLevel === "xhigh" || rawThinkingLevel === "max" ? "max" : "high", enableThinking);
|
|
91
|
-
else if (tokenPlanContract?.family === "kimi") patchTokenPlanKimiPayload(payload, enableThinking);
|
|
92
|
-
else if (tokenPlanContract?.family === "glm") {
|
|
93
|
-
if (Array.isArray(payload.tools) && payload.tools.length > 0) payload.tool_stream = true;
|
|
94
|
-
if (rawThinkingLevel === "none" && enableThinking) delete payload.thinking;
|
|
95
|
-
else patchTokenPlanGlmPayload(payload, normalizeQwenThinkingLevel(rawThinkingLevel), enableThinking, tokenPlanContract.supportsMax);
|
|
96
|
-
} else {
|
|
97
|
-
delete payload.thinking;
|
|
98
|
-
delete payload.reasoning_effort;
|
|
99
|
-
}
|
|
100
|
-
delete payload.reasoningEffort;
|
|
101
|
-
delete payload.reasoning;
|
|
102
|
-
}
|
|
103
|
-
function createQwenConstraintWrapper(baseStreamFn, tokenPlanContract, forceThinking, thinkingLevel, sourceApi) {
|
|
104
|
-
const underlying = baseStreamFn ?? streamSimple;
|
|
105
|
-
const patchPayload = createQwenThinkingPayloadPatch(thinkingLevel, void 0, forceThinking, tokenPlanContract, sourceApi);
|
|
106
|
-
return (model, context, options) => {
|
|
107
|
-
if ((sourceApi ?? model.api) !== "openai-completions" || !model.reasoning && !forceThinking) return underlying(model, context, options);
|
|
108
|
-
const requestedThinkingLevel = resolveQwenThinkingLevel(thinkingLevel, options);
|
|
109
|
-
const requestedEnableThinking = forceThinking || isOpenAICompatibleThinkingEnabled({
|
|
110
|
-
thinkingLevel,
|
|
111
|
-
options
|
|
112
|
-
});
|
|
113
|
-
const originalOnPayload = options?.onPayload;
|
|
114
|
-
return underlying(model, context, {
|
|
115
|
-
...options,
|
|
116
|
-
onPayload(payload, payloadModel) {
|
|
117
|
-
const payloadObj = asOptionalRecord(payload);
|
|
118
|
-
if (payloadObj) patchPayload({
|
|
119
|
-
payload: payloadObj,
|
|
120
|
-
model,
|
|
121
|
-
context,
|
|
122
|
-
options
|
|
123
|
-
});
|
|
124
|
-
const finalizePayload = (value) => {
|
|
125
|
-
const finalPayload = asOptionalRecord(value) ?? payloadObj;
|
|
126
|
-
if (finalPayload) enforceQwenPayloadAfterCaller(finalPayload, tokenPlanContract, forceThinking, requestedEnableThinking, requestedThinkingLevel);
|
|
127
|
-
return value;
|
|
128
|
-
};
|
|
129
|
-
const result = originalOnPayload?.(payload, payloadModel);
|
|
130
|
-
if (result && typeof result.then === "function") return Promise.resolve(result).then(finalizePayload);
|
|
131
|
-
return finalizePayload(result);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
72
|
function patchTokenPlanGlmPayload(payload, thinkingLevel, enableThinking, supportsMax) {
|
|
137
73
|
delete payload.thinking;
|
|
138
74
|
if (!enableThinking) {
|
|
@@ -184,14 +120,75 @@ function createQwenThinkingWrapper(baseStreamFn, thinkingLevel, thinkingFormat,
|
|
|
184
120
|
}
|
|
185
121
|
function wrapQwenProviderStream(ctx) {
|
|
186
122
|
const sourceApi = ctx.sourceApi ?? ctx.model?.api;
|
|
187
|
-
if (
|
|
123
|
+
if (sourceApi && sourceApi !== "openai-completions") return;
|
|
124
|
+
const streamProviderId = resolveQwenStreamProviderId(ctx);
|
|
125
|
+
if (!streamProviderId) return;
|
|
188
126
|
const thinkingFormat = ctx.model ? readQwenThinkingFormatFromModel(ctx.model, sourceApi) : void 0;
|
|
189
127
|
const explicitLegacyThinkingFormat = normalizeProviderId(ctx.provider) === "bailian-token-plan" && thinkingFormat !== void 0;
|
|
190
128
|
if (explicitLegacyThinkingFormat && thinkingFormat !== "qwen-chat-template") return ctx.streamFn;
|
|
191
|
-
const tokenPlanContract = explicitLegacyThinkingFormat ? void 0 : resolveQwenThinkingContract(
|
|
192
|
-
const useWireConstraints = (isQwenTokenPlanProviderId(
|
|
129
|
+
const tokenPlanContract = explicitLegacyThinkingFormat ? void 0 : resolveQwenThinkingContract(streamProviderId, ctx.modelId);
|
|
130
|
+
const useWireConstraints = (isQwenTokenPlanProviderId(streamProviderId) || tokenPlanContract?.family === "qwen-3.8") && !explicitLegacyThinkingFormat && thinkingFormat === void 0;
|
|
193
131
|
const forceThinking = useWireConstraints && isQwenTokenPlanThinkingOnlyModelId(ctx.modelId);
|
|
194
|
-
if (useWireConstraints)
|
|
132
|
+
if (useWireConstraints) {
|
|
133
|
+
const underlying = ctx.streamFn ?? streamSimple;
|
|
134
|
+
const thinkingLevel = ctx.thinkingLevel;
|
|
135
|
+
const wireSourceApi = ctx.sourceApi;
|
|
136
|
+
const patchPayload = createQwenThinkingPayloadPatch(thinkingLevel, void 0, forceThinking, tokenPlanContract, wireSourceApi);
|
|
137
|
+
return (model, context, options) => {
|
|
138
|
+
if ((wireSourceApi ?? model.api) !== "openai-completions" || !model.reasoning && !forceThinking) return underlying(model, context, options);
|
|
139
|
+
const requestedThinkingLevel = resolveQwenThinkingLevel(thinkingLevel, options);
|
|
140
|
+
const requestedEnableThinking = forceThinking || isOpenAICompatibleThinkingEnabled({
|
|
141
|
+
thinkingLevel,
|
|
142
|
+
options
|
|
143
|
+
});
|
|
144
|
+
return underlying(model, context, {
|
|
145
|
+
...options,
|
|
146
|
+
onPayload: wrapProviderPayloadHook(options?.onPayload, (originalPayload, value) => {
|
|
147
|
+
const payload = asOptionalRecord(value) ?? asOptionalRecord(originalPayload);
|
|
148
|
+
if (payload) {
|
|
149
|
+
const hasPayloadThinking = typeof payload.enable_thinking === "boolean";
|
|
150
|
+
let enableThinking = forceThinking || (hasPayloadThinking ? payload.enable_thinking !== false : requestedEnableThinking);
|
|
151
|
+
const rawThinkingLevel = typeof payload.reasoning_effort === "string" ? payload.reasoning_effort : hasPayloadThinking ? void 0 : requestedThinkingLevel;
|
|
152
|
+
if (!forceThinking && (rawThinkingLevel === "off" || tokenPlanContract?.family === "qwen-3.8" && rawThinkingLevel === "none")) enableThinking = false;
|
|
153
|
+
payload.enable_thinking = enableThinking;
|
|
154
|
+
if (enableThinking) {
|
|
155
|
+
const toolChoice = payload.tool_choice;
|
|
156
|
+
const toolChoiceType = asOptionalRecord(toolChoice)?.type;
|
|
157
|
+
if (toolChoiceType === "auto" || toolChoiceType === "none") payload.tool_choice = toolChoiceType;
|
|
158
|
+
else if (!(toolChoice == null || toolChoice === "auto" || toolChoice === "none")) {
|
|
159
|
+
if (!forceThinking && (toolChoiceType === "tool" || toolChoiceType === "function")) {
|
|
160
|
+
payload.enable_thinking = false;
|
|
161
|
+
enableThinking = false;
|
|
162
|
+
} else payload.tool_choice = "auto";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (tokenPlanContract?.family === "qwen-3.8") patchQwen38Payload(payload, normalizeQwenThinkingLevel(rawThinkingLevel), enableThinking);
|
|
166
|
+
else if (tokenPlanContract?.family === "deepseek-v4") patchTokenPlanDeepSeekV4Payload(payload, rawThinkingLevel === "xhigh" || rawThinkingLevel === "max" ? "max" : "high", enableThinking);
|
|
167
|
+
else if (tokenPlanContract?.family === "kimi") patchTokenPlanKimiPayload(payload, enableThinking);
|
|
168
|
+
else if (tokenPlanContract?.family === "glm") {
|
|
169
|
+
if (Array.isArray(payload.tools) && payload.tools.length > 0) payload.tool_stream = true;
|
|
170
|
+
if (rawThinkingLevel === "none" && enableThinking) delete payload.thinking;
|
|
171
|
+
else patchTokenPlanGlmPayload(payload, normalizeQwenThinkingLevel(rawThinkingLevel), enableThinking, tokenPlanContract.supportsMax);
|
|
172
|
+
} else {
|
|
173
|
+
delete payload.thinking;
|
|
174
|
+
delete payload.reasoning_effort;
|
|
175
|
+
}
|
|
176
|
+
delete payload.reasoningEffort;
|
|
177
|
+
delete payload.reasoning;
|
|
178
|
+
}
|
|
179
|
+
return value;
|
|
180
|
+
}, (payload) => {
|
|
181
|
+
const payloadObj = asOptionalRecord(payload);
|
|
182
|
+
if (payloadObj) patchPayload({
|
|
183
|
+
payload: payloadObj,
|
|
184
|
+
model,
|
|
185
|
+
context,
|
|
186
|
+
options
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
}
|
|
195
192
|
return createQwenThinkingWrapper(ctx.streamFn, ctx.thinkingLevel, thinkingFormat, forceThinking, tokenPlanContract, ctx.sourceApi);
|
|
196
193
|
}
|
|
197
194
|
export { createQwenThinkingWrapper, wrapQwenProviderStream };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/qwen-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.5-beta.1",
|
|
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.
|
|
21
|
+
"pluginApi": ">=2026.11.5-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.11.5-beta.1",
|
|
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.
|
|
43
|
+
"openclaw": ">=2026.11.5-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"api.js","source":"extensions/qwen/api.ts"},{"output":"failover.js","source":"extensions/qwen/failover.ts"},{"output":"index.js","source":"extensions/qwen/index.ts"},{"output":"media-understanding-provider.js","source":"extensions/qwen/media-understanding-provider.ts"},{"output":"models.js","source":"extensions/qwen/models.ts"},{"output":"onboard.js","source":"extensions/qwen/onboard.ts"},{"output":"provider-catalog.js","source":"extensions/qwen/provider-catalog.ts"},{"output":"stream.js","source":"extensions/qwen/stream.ts"},{"output":"video-generation-provider.js","source":"extensions/qwen/video-generation-provider.ts"}],"chunks":[{"output":".setup/models-BHyvoc6Y.mjs","sha256":"57a2483c0c066601ef9d2f5285c311cee40b20b14fc516c70d65461fc2c5cd58","facadeSource":null,"sources":["extensions/qwen/models.ts","extensions/qwen/openclaw.plugin.json"]},{"output":"api.js","sha256":"5139a6af6eadfd3207c7e8bdf8f2d8556042454154b3f9312dafa938d86aad3d","facadeSource":"extensions/qwen/api.ts","sources":[]},{"output":"failover.js","sha256":"7124cb636da55379349a47fa7d9df6f963faf09953e9b00772b52d435719053e","facadeSource":"extensions/qwen/failover.ts","sources":["extensions/qwen/failover.ts"]},{"output":"index.js","sha256":"276b1bd6f0c7ad03a0a343d4284f468c219f22e9bd8db29692af3dcfef418983","facadeSource":"extensions/qwen/index.ts","sources":["extensions/qwen/index.ts"]},{"output":"media-understanding-provider.js","sha256":"20c8f3bc80fc3d4b878e775939c5efe32045e899f6d3adb834ad23ca101a278d","facadeSource":"extensions/qwen/media-understanding-provider.ts","sources":["extensions/qwen/media-understanding-provider.ts"]},{"output":"models.js","sha256":"913b8b215a159d16c8f0079d12d0f2ddf4fffee884207285edbabc7bf663551a","facadeSource":"extensions/qwen/models.ts","sources":[]},{"output":"onboard.js","sha256":"9d9b2247435473503a77b20d0c2b31d3b1e8249ff24fceefb248ac891dff7079","facadeSource":"extensions/qwen/onboard.ts","sources":["extensions/qwen/onboard.ts"]},{"output":"provider-catalog.js","sha256":"580c87b069627873a86702aa39429bd10a14890f6967a748f051d310a1822985","facadeSource":"extensions/qwen/provider-catalog.ts","sources":["extensions/qwen/provider-catalog.ts"]},{"output":"stream.js","sha256":"4bd55af80bc93658543f6f1e9a06ce6f63135cd21d71635a30242cb14823b882","facadeSource":"extensions/qwen/stream.ts","sources":["extensions/qwen/stream.ts"]},{"output":"video-generation-provider.js","sha256":"671843d3ee585d8c4d48bfc1260b1163f12f56a0c36729c5ecfc755cefdd08a0","facadeSource":"extensions/qwen/video-generation-provider.ts","sources":["extensions/qwen/video-generation-provider.ts"]}],"unrenderedSources":["extensions/qwen/api.ts"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { S as QWEN_STANDARD_GLOBAL_BASE_URL } from "./.setup/models-BHyvoc6Y.mjs";
|
|
2
|
-
import { describeOpenAiCompatibleVideo } from "openclaw/plugin-sdk/media-understanding";
|
|
3
|
-
// extensions/qwen/media-understanding-provider.ts
|
|
4
|
-
const DEFAULT_QWEN_MEDIA_MODEL = "qwen3.6-plus";
|
|
5
|
-
const DEFAULT_QWEN_VIDEO_PROMPT = "Describe the video in detail.";
|
|
6
|
-
function describeQwenVideo(params) {
|
|
7
|
-
return describeOpenAiCompatibleVideo({
|
|
8
|
-
...params,
|
|
9
|
-
defaultBaseUrl: QWEN_STANDARD_GLOBAL_BASE_URL,
|
|
10
|
-
defaultModel: DEFAULT_QWEN_MEDIA_MODEL,
|
|
11
|
-
defaultPrompt: DEFAULT_QWEN_VIDEO_PROMPT,
|
|
12
|
-
provider: "qwen",
|
|
13
|
-
providerLabel: "Qwen"
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
function buildQwenMediaUnderstandingProvider() {
|
|
17
|
-
return {
|
|
18
|
-
id: "qwen",
|
|
19
|
-
capabilities: ["image", "video"],
|
|
20
|
-
defaultModels: {
|
|
21
|
-
image: DEFAULT_QWEN_MEDIA_MODEL,
|
|
22
|
-
video: DEFAULT_QWEN_MEDIA_MODEL
|
|
23
|
-
},
|
|
24
|
-
autoPriority: { video: 15 },
|
|
25
|
-
describeImage: void 0,
|
|
26
|
-
describeImages: void 0,
|
|
27
|
-
describeVideo: describeQwenVideo
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export { buildQwenMediaUnderstandingProvider };
|
package/dist/onboard.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { G as resolveQwenTokenPlanBaseUrl, S as QWEN_STANDARD_GLOBAL_BASE_URL, T as QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF, h as QWEN_CN_BASE_URL, k as QWEN_TOKEN_PLAN_PROVIDER_ID, v as QWEN_DEFAULT_MODEL_REF, x as QWEN_STANDARD_CN_BASE_URL, y as QWEN_GLOBAL_BASE_URL } from "./.setup/models-BHyvoc6Y.mjs";
|
|
2
|
-
import { buildQwenProvider, buildQwenTokenPlanProvider } from "./provider-catalog.js";
|
|
3
|
-
import { createProviderConnectionPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
4
|
-
// extensions/qwen/onboard.ts
|
|
5
|
-
const qwenPresetAppliers = createProviderConnectionPresetAppliers({
|
|
6
|
-
primaryModelRef: QWEN_DEFAULT_MODEL_REF,
|
|
7
|
-
resolveParams: (_cfg, baseUrl) => {
|
|
8
|
-
const provider = buildQwenProvider({ baseUrl });
|
|
9
|
-
return {
|
|
10
|
-
providerId: "qwen",
|
|
11
|
-
api: provider.api ?? "openai-completions",
|
|
12
|
-
baseUrl,
|
|
13
|
-
catalogModels: provider.models,
|
|
14
|
-
aliases: [...provider.models.flatMap((model) => [`qwen/${model.id}`, `modelstudio/${model.id}`]), {
|
|
15
|
-
modelRef: QWEN_DEFAULT_MODEL_REF,
|
|
16
|
-
alias: "Qwen"
|
|
17
|
-
}]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
const qwenTokenPlanPresetAppliers = createProviderConnectionPresetAppliers({
|
|
22
|
-
primaryModelRef: QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
23
|
-
resolveParams: (_cfg, baseUrl) => {
|
|
24
|
-
const provider = buildQwenTokenPlanProvider({ baseUrl });
|
|
25
|
-
return {
|
|
26
|
-
providerId: QWEN_TOKEN_PLAN_PROVIDER_ID,
|
|
27
|
-
api: provider.api ?? "openai-completions",
|
|
28
|
-
baseUrl,
|
|
29
|
-
catalogModels: provider.models,
|
|
30
|
-
aliases: [...provider.models.map((model) => `${QWEN_TOKEN_PLAN_PROVIDER_ID}/${model.id}`), {
|
|
31
|
-
modelRef: QWEN_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
32
|
-
alias: "Qwen Token Plan"
|
|
33
|
-
}]
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
function applyQwenConfig(cfg) {
|
|
38
|
-
return qwenPresetAppliers.applyConfig(cfg, QWEN_GLOBAL_BASE_URL);
|
|
39
|
-
}
|
|
40
|
-
function applyQwenConfigCn(cfg) {
|
|
41
|
-
return qwenPresetAppliers.applyConfig(cfg, QWEN_CN_BASE_URL);
|
|
42
|
-
}
|
|
43
|
-
function applyQwenStandardConfig(cfg) {
|
|
44
|
-
return qwenPresetAppliers.applyConfig(cfg, QWEN_STANDARD_GLOBAL_BASE_URL);
|
|
45
|
-
}
|
|
46
|
-
function applyQwenStandardConfigCn(cfg) {
|
|
47
|
-
return qwenPresetAppliers.applyConfig(cfg, QWEN_STANDARD_CN_BASE_URL);
|
|
48
|
-
}
|
|
49
|
-
function applyQwenTokenPlanConfig(cfg, region) {
|
|
50
|
-
return qwenTokenPlanPresetAppliers.applyConfig(cfg, resolveQwenTokenPlanBaseUrl(region));
|
|
51
|
-
}
|
|
52
|
-
export { applyQwenConfig, applyQwenConfigCn, applyQwenStandardConfig, applyQwenStandardConfigCn, applyQwenTokenPlanConfig };
|