refactor(providers): share kilocode stream family

This commit is contained in:
Vincent Koc
2026-04-04 21:05:15 +09:00
parent dd030fb761
commit 486505a54e
4 changed files with 37 additions and 13 deletions

View File

@@ -105,6 +105,27 @@ describe("buildProviderStreamFamilyHooks", () => {
);
expect(capturedModelId).toBe("MiniMax-M2.7-highspeed");
const kilocodeHooks = buildProviderStreamFamilyHooks("kilocode-thinking");
kilocodeHooks.wrapStreamFn?.({
streamFn: baseStreamFn,
thinkingLevel: "high",
modelId: "openai/gpt-5.4",
} as never)({ provider: "kilocode", id: "openai/gpt-5.4" } as never, {} as never, {});
expect(capturedPayload).toMatchObject({
config: { thinkingConfig: { thinkingBudget: -1 } },
reasoning: { effort: "high" },
});
kilocodeHooks.wrapStreamFn?.({
streamFn: baseStreamFn,
thinkingLevel: "high",
modelId: "kilo/auto",
} as never)({ provider: "kilocode", id: "kilo/auto" } as never, {} as never, {});
expect(capturedPayload).toMatchObject({
config: { thinkingConfig: { thinkingBudget: -1 } },
});
expect(capturedPayload).not.toHaveProperty("reasoning");
const moonshotHooks = buildProviderStreamFamilyHooks("moonshot-thinking");
void requireStreamFn(
requireWrapStreamFn(moonshotHooks.wrapStreamFn)({

View File

@@ -48,6 +48,7 @@ export function composeProviderStreamWrappers(
export type ProviderStreamFamily =
| "google-thinking"
| "kilocode-thinking"
| "moonshot-thinking"
| "minimax-fast-mode"
| "openai-responses-defaults"
@@ -75,6 +76,16 @@ export function buildProviderStreamFamilyHooks(
return createMoonshotThinkingWrapper(ctx.streamFn, thinkingType);
},
};
case "kilocode-thinking":
return {
wrapStreamFn: (ctx: ProviderWrapStreamFnContext) => {
const thinkingLevel =
ctx.modelId === "kilo/auto" || isProxyReasoningUnsupported(ctx.modelId)
? undefined
: ctx.thinkingLevel;
return createKilocodeWrapper(ctx.streamFn, thinkingLevel);
},
};
case "minimax-fast-mode":
return {
wrapStreamFn: (ctx: ProviderWrapStreamFnContext) =>