@openclaw/xiaomi-provider 2026.9.8 → 2026.10.1-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/index.js +9 -19
- package/dist/onboard.js +8 -29
- package/dist/speech-provider.js +24 -44
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -52,18 +52,14 @@ async function resolveXiaomiCatalog(params) {
|
|
|
52
52
|
profileId: auth.profileId
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
const normalized =
|
|
57
|
-
const expectedPrefix =
|
|
58
|
-
const kindLabel =
|
|
55
|
+
function assertCompatibleXiaomiKey(actualKey, expectedKind) {
|
|
56
|
+
const normalized = actualKey.trim().toLowerCase();
|
|
57
|
+
const expectedPrefix = expectedKind === "payg" ? "sk-" : "tp-";
|
|
58
|
+
const kindLabel = expectedKind === "payg" ? "pay-as-you-go" : "Token Plan";
|
|
59
59
|
if (normalized.startsWith(expectedPrefix)) return;
|
|
60
|
-
if (
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
function assertCompatibleXiaomiKey(params) {
|
|
65
|
-
const message = buildXiaomiKeyMismatchMessage(params);
|
|
66
|
-
if (message) throw new Error(message);
|
|
60
|
+
if (expectedKind === "payg" && normalized.startsWith("tp-")) throw new Error("This looks like a Xiaomi MiMo Token Plan key (tp-...). Re-run onboarding with one of: --auth-choice xiaomi-token-plan-cn, --auth-choice xiaomi-token-plan-sgp, or --auth-choice xiaomi-token-plan-ams.");
|
|
61
|
+
if (expectedKind === "token-plan" && normalized.startsWith("sk-")) throw new Error(`This looks like a Xiaomi MiMo pay-as-you-go key (sk-...). Re-run onboarding with --auth-choice xiaomi-api-key or pass ${PAYG_FLAG_NAME}.`);
|
|
62
|
+
throw new Error(`Xiaomi MiMo ${kindLabel} keys must start with "${expectedPrefix}". The entered key does not match the expected format.`);
|
|
67
63
|
}
|
|
68
64
|
async function runXiaomiApiKeyAuth(ctx, params) {
|
|
69
65
|
const profileId = `${params.providerId}:default`;
|
|
@@ -77,10 +73,7 @@ async function runXiaomiApiKeyAuth(ctx, params) {
|
|
|
77
73
|
promptMessage: params.promptMessage,
|
|
78
74
|
missingInputMessage: `Missing Xiaomi API key for provider "${params.providerId}".`
|
|
79
75
|
});
|
|
80
|
-
assertCompatibleXiaomiKey(
|
|
81
|
-
actualKey: apiKey,
|
|
82
|
-
expectedKind: params.expectedKind
|
|
83
|
-
});
|
|
76
|
+
assertCompatibleXiaomiKey(apiKey, params.expectedKind);
|
|
84
77
|
return {
|
|
85
78
|
profiles: [{
|
|
86
79
|
profileId,
|
|
@@ -98,10 +91,7 @@ async function runXiaomiApiKeyAuthNonInteractive(ctx, params) {
|
|
|
98
91
|
envVar: params.envVar
|
|
99
92
|
});
|
|
100
93
|
if (!resolved) return null;
|
|
101
|
-
assertCompatibleXiaomiKey(
|
|
102
|
-
actualKey: resolved.key,
|
|
103
|
-
expectedKind: params.expectedKind
|
|
104
|
-
});
|
|
94
|
+
assertCompatibleXiaomiKey(resolved.key, params.expectedKind);
|
|
105
95
|
const profileId = `${params.providerId}:default`;
|
|
106
96
|
if (!await persistProviderApiKey(ctx, profileId, {
|
|
107
97
|
provider: params.providerId,
|
package/dist/onboard.js
CHANGED
|
@@ -22,44 +22,23 @@ const xiaomiPreset = {
|
|
|
22
22
|
};
|
|
23
23
|
const { applyConfig: applyXiaomiConfig, applyProviderConfig: applyXiaomiProviderConfig } = createDefaultModelsPresetAppliers(xiaomiPreset);
|
|
24
24
|
const { applyConfig: applyXiaomiConnectionConfig } = createDefaultModelsConnectionPresetAppliers(xiaomiPreset);
|
|
25
|
-
const
|
|
25
|
+
const { applyConfig: applyXiaomiTokenPlanConfig } = createDefaultModelsPresetAppliers({
|
|
26
26
|
primaryModelRef: XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
27
|
-
resolveParams: (cfg) => {
|
|
27
|
+
resolveParams: (cfg, region) => {
|
|
28
28
|
const defaultProvider = buildXiaomiTokenPlanProvider();
|
|
29
|
+
const defaultModel = defaultProvider.models.find((model) => model.id === XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_ID);
|
|
29
30
|
return {
|
|
30
31
|
providerId: XIAOMI_TOKEN_PLAN_PROVIDER_ID,
|
|
31
32
|
api: defaultProvider.api ?? "openai-completions",
|
|
32
|
-
baseUrl:
|
|
33
|
+
baseUrl: resolveXiaomiTokenPlanBaseUrl(region),
|
|
33
34
|
defaultModels: cfg.models?.mode === "replace" ? defaultProvider.models ?? [] : [],
|
|
34
35
|
defaultModelId: XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_ID,
|
|
35
|
-
aliases:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
alias: defaultModel?.name ?? "Xiaomi MiMo V2.6 Pro"
|
|
40
|
-
}];
|
|
41
|
-
})()
|
|
36
|
+
aliases: [{
|
|
37
|
+
modelRef: XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_REF,
|
|
38
|
+
alias: defaultModel?.name ?? "Xiaomi MiMo V2.6 Pro"
|
|
39
|
+
}]
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
42
|
});
|
|
45
|
-
function withProviderBaseUrl(cfg, providerId, baseUrl) {
|
|
46
|
-
const providers = {
|
|
47
|
-
...cfg.models?.providers,
|
|
48
|
-
[providerId]: {
|
|
49
|
-
...cfg.models?.providers?.[providerId],
|
|
50
|
-
baseUrl
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
...cfg,
|
|
55
|
-
models: {
|
|
56
|
-
...cfg.models,
|
|
57
|
-
providers
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function applyXiaomiTokenPlanConfig(cfg, region) {
|
|
62
|
-
return withProviderBaseUrl(xiaomiTokenPlanPresetAppliers.applyConfig(cfg), XIAOMI_TOKEN_PLAN_PROVIDER_ID, resolveXiaomiTokenPlanBaseUrl(region));
|
|
63
|
-
}
|
|
64
43
|
//#endregion
|
|
65
44
|
export { XIAOMI_DEFAULT_MODEL_REF, XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_REF, applyXiaomiConfig, applyXiaomiConnectionConfig, applyXiaomiProviderConfig, applyXiaomiTokenPlanConfig };
|
package/dist/speech-provider.js
CHANGED
|
@@ -33,16 +33,17 @@ function resolveXiaomiTtsConfigRecord(rawConfig) {
|
|
|
33
33
|
}
|
|
34
34
|
function normalizeXiaomiTtsProviderConfig(rawConfig) {
|
|
35
35
|
const raw = resolveXiaomiTtsConfigRecord(rawConfig);
|
|
36
|
+
const options = readXiaomiTtsOptions(raw);
|
|
36
37
|
return {
|
|
37
38
|
apiKey: normalizeResolvedSecretInputString({
|
|
38
39
|
value: raw?.apiKey,
|
|
39
40
|
path: "tts.providers.xiaomi.apiKey"
|
|
40
41
|
}),
|
|
41
42
|
baseUrl: normalizeXiaomiTtsBaseUrl(normalizeOptionalString(raw?.baseUrl) ?? normalizeOptionalString(process.env.XIAOMI_BASE_URL)),
|
|
42
|
-
model:
|
|
43
|
-
voice:
|
|
44
|
-
format:
|
|
45
|
-
style:
|
|
43
|
+
model: options.model ?? normalizeOptionalString(process.env.XIAOMI_TTS_MODEL) ?? DEFAULT_XIAOMI_TTS_MODEL,
|
|
44
|
+
voice: options.voice ?? normalizeOptionalString(process.env.XIAOMI_TTS_VOICE) ?? DEFAULT_XIAOMI_TTS_VOICE,
|
|
45
|
+
format: options.format ?? normalizeXiaomiTtsFormat(process.env.XIAOMI_TTS_FORMAT) ?? DEFAULT_XIAOMI_TTS_FORMAT,
|
|
46
|
+
style: options.style
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
function resolveXiaomiTtsProviderConfig(config) {
|
|
@@ -53,13 +54,12 @@ function resolveXiaomiTtsProviderConfig(config) {
|
|
|
53
54
|
apiKey: resolvedKey
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
if (!overrides) return {};
|
|
57
|
+
function readXiaomiTtsOptions(options) {
|
|
58
58
|
return {
|
|
59
|
-
model: normalizeOptionalString(
|
|
60
|
-
voice: normalizeOptionalString(
|
|
61
|
-
format: normalizeXiaomiTtsFormat(
|
|
62
|
-
style: normalizeOptionalString(
|
|
59
|
+
model: normalizeOptionalString(options?.model) ?? normalizeOptionalString(options?.modelId),
|
|
60
|
+
voice: normalizeOptionalString(options?.speakerVoice) ?? normalizeOptionalString(options?.speakerVoiceId) ?? normalizeOptionalString(options?.voice) ?? normalizeOptionalString(options?.voiceId),
|
|
61
|
+
format: normalizeXiaomiTtsFormat(options?.format),
|
|
62
|
+
style: normalizeOptionalString(options?.style)
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
function parseDirectiveToken(ctx) {
|
|
@@ -107,29 +107,6 @@ function parseDirectiveToken(ctx) {
|
|
|
107
107
|
default: return { handled: false };
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function buildXiaomiTtsMessages(params) {
|
|
111
|
-
const style = normalizeOptionalString(params.style);
|
|
112
|
-
return [...style ? [{
|
|
113
|
-
role: "user",
|
|
114
|
-
content: style
|
|
115
|
-
}] : [], {
|
|
116
|
-
role: "assistant",
|
|
117
|
-
content: params.text
|
|
118
|
-
}];
|
|
119
|
-
}
|
|
120
|
-
function isXiaomiVoiceDesignModel(model) {
|
|
121
|
-
return model === XIAOMI_TTS_VOICE_DESIGN_MODEL;
|
|
122
|
-
}
|
|
123
|
-
function resolveXiaomiVoiceDesignStyle(style) {
|
|
124
|
-
return normalizeOptionalString(style) ?? DEFAULT_XIAOMI_TTS_VOICE_DESIGN_STYLE;
|
|
125
|
-
}
|
|
126
|
-
function buildXiaomiTtsAudio(params) {
|
|
127
|
-
if (isXiaomiVoiceDesignModel(params.model)) return { format: params.format };
|
|
128
|
-
return {
|
|
129
|
-
format: params.format,
|
|
130
|
-
voice: params.voice
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
110
|
async function xiaomiTTS(params) {
|
|
134
111
|
const { text, apiKey, baseUrl, model, voice, format, style, timeoutMs } = params;
|
|
135
112
|
const requestTimeoutMs = resolveTimerTimeoutMs(timeoutMs, 1);
|
|
@@ -138,7 +115,8 @@ async function xiaomiTTS(params) {
|
|
|
138
115
|
const { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedHostname } = await import("openclaw/plugin-sdk/ssrf-runtime");
|
|
139
116
|
const controller = new AbortController();
|
|
140
117
|
const timeout = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
141
|
-
const
|
|
118
|
+
const voiceDesign = model === XIAOMI_TTS_VOICE_DESIGN_MODEL;
|
|
119
|
+
const resolvedStyle = normalizeOptionalString(style) ?? (voiceDesign ? DEFAULT_XIAOMI_TTS_VOICE_DESIGN_STYLE : void 0);
|
|
142
120
|
try {
|
|
143
121
|
const { response, release } = await fetchWithSsrFGuard({
|
|
144
122
|
url: `${baseUrl}/chat/completions`,
|
|
@@ -150,15 +128,17 @@ async function xiaomiTTS(params) {
|
|
|
150
128
|
},
|
|
151
129
|
body: JSON.stringify({
|
|
152
130
|
model,
|
|
153
|
-
messages:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
131
|
+
messages: [...resolvedStyle ? [{
|
|
132
|
+
role: "user",
|
|
133
|
+
content: resolvedStyle
|
|
134
|
+
}] : [], {
|
|
135
|
+
role: "assistant",
|
|
136
|
+
content: text
|
|
137
|
+
}],
|
|
138
|
+
audio: voiceDesign ? { format } : {
|
|
139
|
+
format,
|
|
140
|
+
voice
|
|
141
|
+
}
|
|
162
142
|
}),
|
|
163
143
|
signal: controller.signal
|
|
164
144
|
},
|
|
@@ -204,7 +184,7 @@ function buildXiaomiSpeechProvider() {
|
|
|
204
184
|
isConfigured: ({ providerConfig }) => Boolean(resolveXiaomiTtsProviderConfig(providerConfig).apiKey),
|
|
205
185
|
synthesize: async (req) => {
|
|
206
186
|
const config = resolveXiaomiTtsProviderConfig(req.providerConfig);
|
|
207
|
-
const overrides =
|
|
187
|
+
const overrides = readXiaomiTtsOptions(req.providerOverrides);
|
|
208
188
|
if (!config.apiKey) throw new Error("Xiaomi API key missing");
|
|
209
189
|
const outputFormat = overrides.format ?? config.format;
|
|
210
190
|
const audioBuffer = await xiaomiTTS({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/xiaomi-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.10.1-beta.1",
|
|
4
4
|
"description": "OpenClaw Xiaomi provider plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.7.2"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.
|
|
21
|
+
"pluginApi": ">=2026.10.1-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.10.1-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.10.1-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|