mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 19:27:42 +00:00
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>
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
|
|
import type { ProviderWrapStreamFnContext } from "openclaw/plugin-sdk/plugin-entry";
|
|
import {
|
|
createDeepSeekV4OpenAICompatibleThinkingWrapper,
|
|
createThinkingOnlyFinalTextWrapper,
|
|
} from "openclaw/plugin-sdk/provider-stream-shared";
|
|
import { isMiMoProviderId, isMiMoReasoningModelRef } from "./thinking.js";
|
|
|
|
const MIMO_REASONING_AS_VISIBLE_TEXT_MODEL_IDS = new Set(["mimo-v2-pro", "mimo-v2-omni"]);
|
|
|
|
function normalizeMiMoModelId(modelId: unknown): string | undefined {
|
|
if (typeof modelId !== "string") {
|
|
return undefined;
|
|
}
|
|
const normalized = modelId.trim().toLowerCase().split(":", 1)[0];
|
|
if (!normalized) {
|
|
return undefined;
|
|
}
|
|
const parts = normalized.split("/").filter(Boolean);
|
|
return parts[parts.length - 1] ?? normalized;
|
|
}
|
|
|
|
function shouldPromoteMiMoReasoningToVisibleText(model: Parameters<StreamFn>[0]): boolean {
|
|
return (
|
|
isMiMoProviderId(model.provider) &&
|
|
MIMO_REASONING_AS_VISIBLE_TEXT_MODEL_IDS.has(normalizeMiMoModelId(model.id) ?? "")
|
|
);
|
|
}
|
|
|
|
export function createMiMoThinkingWrapper(
|
|
baseStreamFn: ProviderWrapStreamFnContext["streamFn"],
|
|
thinkingLevel: ProviderWrapStreamFnContext["thinkingLevel"],
|
|
): ProviderWrapStreamFnContext["streamFn"] {
|
|
const wrapped = createDeepSeekV4OpenAICompatibleThinkingWrapper({
|
|
baseStreamFn,
|
|
thinkingLevel,
|
|
shouldPatchModel: isMiMoReasoningModelRef,
|
|
});
|
|
// Legacy MiMo V2 can put the final user-visible answer in reasoning_content.
|
|
// Only promote terminal thinking-only output; replay/tool-call reasoning stays untouched.
|
|
return createThinkingOnlyFinalTextWrapper({
|
|
baseStreamFn: wrapped,
|
|
shouldPatchModel: shouldPromoteMiMoReasoningToVisibleText,
|
|
});
|
|
}
|