fix(minimax): share provider hook bundle

This commit is contained in:
Vincent Koc
2026-04-14 16:41:46 +01:00
parent 36f4913e30
commit 25efa8cf81
2 changed files with 21 additions and 10 deletions

View File

@@ -147,6 +147,20 @@ describe("minimax provider hooks", () => {
expect(resolvedPortalModelId).toBe("MiniMax-M2.7-highspeed");
});
it("shares the provider hook bundle across MiniMax variants", async () => {
const { providers } = await registerProviderPlugin({
plugin: minimaxProviderPlugin,
id: "minimax",
name: "MiniMax Provider",
});
const apiProvider = requireRegisteredProvider(providers, "minimax");
const portalProvider = requireRegisteredProvider(providers, "minimax-portal");
expect(apiProvider.buildReplayPolicy).toBe(portalProvider.buildReplayPolicy);
expect(apiProvider.wrapStreamFn).toBe(portalProvider.wrapStreamFn);
expect(apiProvider.resolveReasoningOutputMode).toBe(portalProvider.resolveReasoningOutputMode);
});
it("registers the bundled MiniMax web search provider", () => {
const webSearchProviders: unknown[] = [];

View File

@@ -38,10 +38,11 @@ const HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS = buildProviderReplayFamilyHooks({
anthropicModelDropThinkingBlocks: true,
});
const MINIMAX_FAST_MODE_STREAM_HOOKS = buildProviderStreamFamilyHooks("minimax-fast-mode");
function resolveMinimaxReasoningOutputMode(): "native" {
return "native";
}
const MINIMAX_PROVIDER_HOOKS = {
...HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS,
...MINIMAX_FAST_MODE_STREAM_HOOKS,
resolveReasoningOutputMode: () => "native" as const,
};
function getDefaultBaseUrl(region: MiniMaxRegion): string {
return region === "cn" ? DEFAULT_BASE_URL_CN : DEFAULT_BASE_URL_GLOBAL;
@@ -240,9 +241,7 @@ export function registerMinimaxProviders(api: OpenClawPluginApi) {
});
return apiKey ? { token: apiKey } : null;
},
...HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS,
...MINIMAX_FAST_MODE_STREAM_HOOKS,
resolveReasoningOutputMode: () => resolveMinimaxReasoningOutputMode(),
...MINIMAX_PROVIDER_HOOKS,
isModernModelRef: ({ modelId }) => isMiniMaxModernModelId(modelId),
fetchUsageSnapshot: async (ctx) =>
await fetchMinimaxUsage(ctx.token, ctx.timeoutMs, ctx.fetchFn),
@@ -289,9 +288,7 @@ export function registerMinimaxProviders(api: OpenClawPluginApi) {
run: createOAuthHandler("cn"),
},
],
...HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS,
...MINIMAX_FAST_MODE_STREAM_HOOKS,
resolveReasoningOutputMode: () => resolveMinimaxReasoningOutputMode(),
...MINIMAX_PROVIDER_HOOKS,
isModernModelRef: ({ modelId }) => isMiniMaxModernModelId(modelId),
});
}