test(providers): cover stream family plugin hooks

This commit is contained in:
Vincent Koc
2026-04-04 23:20:20 +09:00
parent fa34f3a9d5
commit a2e0a094c1
3 changed files with 172 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
import type { StreamFn } from "@mariozechner/pi-agent-core";
import type { Context, Model } from "@mariozechner/pi-ai";
import { describe, expect, it } from "vitest";
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
import plugin from "./index.js";
@@ -20,4 +22,40 @@ describe("moonshot provider plugin", () => {
validateAnthropicTurns: true,
});
});
it("wires moonshot-thinking stream hooks", async () => {
const provider = await registerSingleProviderPlugin(plugin);
let capturedPayload: Record<string, unknown> | undefined;
const baseStreamFn: StreamFn = (model, _context, options) => {
const payload = { config: { thinkingConfig: { thinkingBudget: -1 } } } as Record<
string,
unknown
>;
options?.onPayload?.(payload as never, model as never);
capturedPayload = payload;
return {} as never;
};
const wrapped = provider.wrapStreamFn?.({
provider: "moonshot",
modelId: "kimi-k2.5",
thinkingLevel: "off",
streamFn: baseStreamFn,
} as never);
void wrapped?.(
{
api: "openai-completions",
provider: "moonshot",
id: "kimi-k2.5",
} as Model<"openai-completions">,
{ messages: [] } as Context,
{},
);
expect(capturedPayload).toMatchObject({
config: { thinkingConfig: { thinkingBudget: -1 } },
thinking: { type: "disabled" },
});
});
});