fix: decouple moonshot stream wrappers from provider runtime

This commit is contained in:
Peter Steinberger
2026-03-27 00:40:33 +00:00
parent 770c462c47
commit 89e6b91b89
2 changed files with 34 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { shouldApplyMoonshotPayloadCompat } from "./moonshot-stream-wrappers.js";
describe("moonshot stream wrappers", () => {
it("keeps Moonshot compatibility on the lightweight provider-id path", () => {
expect(
shouldApplyMoonshotPayloadCompat({
provider: "moonshot",
modelId: "kimi-k2.5",
}),
).toBe(true);
expect(
shouldApplyMoonshotPayloadCompat({
provider: "kimi-coding",
modelId: "kimi-code",
}),
).toBe(true);
expect(
shouldApplyMoonshotPayloadCompat({
provider: "ollama",
modelId: "kimi-k2.5:cloud",
}),
).toBe(true);
expect(
shouldApplyMoonshotPayloadCompat({
provider: "openai",
modelId: "gpt-5.4",
}),
).toBe(false);
});
});

View File

@@ -1,7 +1,7 @@
import type { StreamFn } from "@mariozechner/pi-agent-core";
import { streamSimple } from "@mariozechner/pi-ai";
import type { ThinkLevel } from "../../auto-reply/thinking.js";
import { usesMoonshotThinkingPayloadCompat } from "../provider-capabilities.js";
import { normalizeProviderId } from "../provider-id.js";
type MoonshotThinkingType = "enabled" | "disabled";
@@ -60,10 +60,10 @@ export function shouldApplyMoonshotPayloadCompat(params: {
provider: string;
modelId: string;
}): boolean {
const normalizedProvider = params.provider.trim().toLowerCase();
const normalizedProvider = normalizeProviderId(params.provider);
const normalizedModelId = params.modelId.trim().toLowerCase();
if (usesMoonshotThinkingPayloadCompat(normalizedProvider)) {
if (normalizedProvider === "moonshot" || normalizedProvider === "kimi") {
return true;
}