mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
82 lines
2.4 KiB
TypeScript
82 lines
2.4 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("kilocode provider plugin", () => {
|
|
it("owns passthrough-gemini replay policy for Gemini-backed models", async () => {
|
|
const provider = await registerSingleProviderPlugin(plugin);
|
|
|
|
expect(
|
|
provider.buildReplayPolicy?.({
|
|
provider: "kilocode",
|
|
modelApi: "openai-completions",
|
|
modelId: "gemini-2.5-pro",
|
|
} as never),
|
|
).toMatchObject({
|
|
applyAssistantFirstOrderingFix: false,
|
|
validateGeminiTurns: false,
|
|
validateAnthropicTurns: false,
|
|
sanitizeThoughtSignatures: {
|
|
allowBase64Only: true,
|
|
includeCamelCase: true,
|
|
},
|
|
});
|
|
});
|
|
|
|
it("wires kilocode-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 wrappedReasoning = provider.wrapStreamFn?.({
|
|
provider: "kilocode",
|
|
modelId: "openai/gpt-5.4",
|
|
thinkingLevel: "high",
|
|
streamFn: baseStreamFn,
|
|
} as never);
|
|
|
|
void wrappedReasoning?.(
|
|
{
|
|
api: "openai-completions",
|
|
provider: "kilocode",
|
|
id: "openai/gpt-5.4",
|
|
} as Model<"openai-completions">,
|
|
{ messages: [] } as Context,
|
|
{},
|
|
);
|
|
|
|
expect(capturedPayload).toMatchObject({
|
|
reasoning: { effort: "high" },
|
|
});
|
|
|
|
const wrappedAuto = provider.wrapStreamFn?.({
|
|
provider: "kilocode",
|
|
modelId: "kilo/auto",
|
|
thinkingLevel: "high",
|
|
streamFn: baseStreamFn,
|
|
} as never);
|
|
|
|
void wrappedAuto?.(
|
|
{
|
|
api: "openai-completions",
|
|
provider: "kilocode",
|
|
id: "kilo/auto",
|
|
} as Model<"openai-completions">,
|
|
{ messages: [] } as Context,
|
|
{},
|
|
);
|
|
|
|
expect(capturedPayload).not.toHaveProperty("reasoning");
|
|
});
|
|
});
|