Files
openclaw/extensions/xiaomi/thinking.ts
NianJiu da5d1a6215 feat(xiaomi): add Token Plan provider support
Adds first-class Xiaomi Token Plan provider support with regional onboarding/configuration, token-plan key prefix validation, runtime pricing/catalog metadata, and docs/test coverage.

Keeps Token Plan model catalog discovery runtime-owned so region-specific base URLs are required and the provider cannot silently fall back to the static SGP manifest catalog.

Fixes #86169.

Verification:
- node scripts/run-vitest.mjs src/plugins/provider-discovery.runtime.test.ts extensions/xiaomi/index.test.ts src/plugins/manifest-model-catalog.test.ts src/model-catalog/manifest-planner.test.ts
- git diff --check
- autoreview --mode local: clean, no accepted/actionable findings
- CI run 26678998539: all relevant checks passed; check-prod-types failed on unrelated browser unused-function issue already present on origin/main

Co-authored-by: NianJiuZst <3235467914@qq.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-30 11:37:36 +02:00

46 lines
1.2 KiB
TypeScript

import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry";
import { XIAOMI_PROVIDER_ID, XIAOMI_TOKEN_PLAN_PROVIDER_ID } from "./provider-catalog.js";
const MIMO_REASONING_MODEL_IDS = new Set([
"mimo-v2-pro",
"mimo-v2-omni",
"mimo-v2.5",
"mimo-v2.5-pro",
"mimo-v2.6-pro",
]);
export function isMiMoReasoningModelId(modelId: string): boolean {
return MIMO_REASONING_MODEL_IDS.has(modelId.toLowerCase());
}
export function isMiMoProviderId(providerId: unknown): boolean {
return providerId === XIAOMI_PROVIDER_ID || providerId === XIAOMI_TOKEN_PLAN_PROVIDER_ID;
}
export function isMiMoReasoningModelRef(model: { provider?: string; id?: unknown }): boolean {
return (
isMiMoProviderId(model.provider) &&
typeof model.id === "string" &&
isMiMoReasoningModelId(model.id)
);
}
const MIMO_THINKING_LEVEL_IDS = [
"off",
"minimal",
"low",
"medium",
"high",
"xhigh",
"max",
] as const;
const MIMO_THINKING_PROFILE = {
levels: MIMO_THINKING_LEVEL_IDS.map((id) => ({ id })),
defaultLevel: "high",
} satisfies ProviderThinkingProfile;
export function resolveMiMoThinkingProfile(modelId: string): ProviderThinkingProfile | undefined {
return isMiMoReasoningModelId(modelId) ? MIMO_THINKING_PROFILE : undefined;
}