@openclaw/xiaomi-provider 2026.9.8 → 2026.10.1-beta.2

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 CHANGED
@@ -52,18 +52,14 @@ async function resolveXiaomiCatalog(params) {
52
52
  profileId: auth.profileId
53
53
  });
54
54
  }
55
- function buildXiaomiKeyMismatchMessage(params) {
56
- const normalized = params.actualKey.trim().toLowerCase();
57
- const expectedPrefix = params.expectedKind === "payg" ? "sk-" : "tp-";
58
- const kindLabel = params.expectedKind === "payg" ? "pay-as-you-go" : "Token Plan";
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 (params.expectedKind === "payg" && normalized.startsWith("tp-")) return "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 (params.expectedKind === "token-plan" && normalized.startsWith("sk-")) return `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
- return `Xiaomi MiMo ${kindLabel} keys must start with "${expectedPrefix}". The entered key does not match the expected format.`;
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 xiaomiTokenPlanPresetAppliers = createDefaultModelsPresetAppliers({
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: defaultProvider.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
- const defaultModel = defaultProvider.models?.find((m) => m.id === XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_ID);
37
- return [{
38
- modelRef: XIAOMI_TOKEN_PLAN_DEFAULT_MODEL_REF,
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 };
@@ -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: normalizeOptionalString(raw?.model) ?? normalizeOptionalString(raw?.modelId) ?? normalizeOptionalString(process.env.XIAOMI_TTS_MODEL) ?? DEFAULT_XIAOMI_TTS_MODEL,
43
- voice: normalizeOptionalString(raw?.speakerVoice) ?? normalizeOptionalString(raw?.speakerVoiceId) ?? normalizeOptionalString(raw?.voice) ?? normalizeOptionalString(raw?.voiceId) ?? normalizeOptionalString(process.env.XIAOMI_TTS_VOICE) ?? DEFAULT_XIAOMI_TTS_VOICE,
44
- format: normalizeXiaomiTtsFormat(raw?.format) ?? normalizeXiaomiTtsFormat(process.env.XIAOMI_TTS_FORMAT) ?? DEFAULT_XIAOMI_TTS_FORMAT,
45
- style: normalizeOptionalString(raw?.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 readXiaomiTtsOverrides(overrides) {
57
- if (!overrides) return {};
57
+ function readXiaomiTtsOptions(options) {
58
58
  return {
59
- model: normalizeOptionalString(overrides.model) ?? normalizeOptionalString(overrides.modelId),
60
- voice: normalizeOptionalString(overrides.speakerVoice) ?? normalizeOptionalString(overrides.speakerVoiceId) ?? normalizeOptionalString(overrides.voice) ?? normalizeOptionalString(overrides.voiceId),
61
- format: normalizeXiaomiTtsFormat(overrides.format),
62
- style: normalizeOptionalString(overrides.style)
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 resolvedStyle = isXiaomiVoiceDesignModel(model) ? resolveXiaomiVoiceDesignStyle(style) : style;
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: buildXiaomiTtsMessages({
154
- text,
155
- style: resolvedStyle
156
- }),
157
- audio: buildXiaomiTtsAudio({
158
- model,
159
- voice,
160
- format
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 = readXiaomiTtsOverrides(req.providerOverrides);
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.9.8",
3
+ "version": "2026.10.1-beta.2",
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.9.8"
21
+ "pluginApi": ">=2026.10.1-beta.2"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.8",
24
+ "openclawVersion": "2026.10.1-beta.2",
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.8"
43
+ "openclaw": ">=2026.10.1-beta.2"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {