mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
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";
|
|
|
|
describe("moonshot provider plugin", () => {
|
|
it("owns replay policy for OpenAI-compatible Moonshot transports", async () => {
|
|
const provider = await registerSingleProviderPlugin(plugin);
|
|
|
|
expect(
|
|
provider.buildReplayPolicy?.({
|
|
provider: "moonshot",
|
|
modelApi: "openai-completions",
|
|
modelId: "kimi-k2.5",
|
|
} as never),
|
|
).toMatchObject({
|
|
sanitizeToolCallIds: true,
|
|
toolCallIdMode: "strict",
|
|
applyAssistantFirstOrderingFix: true,
|
|
validateGeminiTurns: true,
|
|
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" },
|
|
});
|
|
});
|
|
});
|