Files
openclaw/extensions/kilocode/index.ts
Josh Lehman 799c6f40aa refactor: move provider replay runtime ownership into plugins (#60126)
* refactor: move provider replay runtime ownership into plugins

* fix(provider-runtime): address review followups

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-04-03 23:14:37 +09:00

58 lines
1.8 KiB
TypeScript

import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
import {
createKilocodeWrapper,
isProxyReasoningUnsupported,
} from "openclaw/plugin-sdk/provider-stream";
import { applyKilocodeConfig, KILOCODE_DEFAULT_MODEL_REF } from "./onboard.js";
import { buildKilocodeProviderWithDiscovery } from "./provider-catalog.js";
const PROVIDER_ID = "kilocode";
function buildKilocodeReplayPolicy(modelId?: string) {
const normalizedModelId = modelId?.toLowerCase() ?? "";
if (!normalizedModelId.includes("gemini")) {
return {};
}
return {
sanitizeThoughtSignatures: {
allowBase64Only: true,
includeCamelCase: true,
},
};
}
export default defineSingleProviderPluginEntry({
id: PROVIDER_ID,
name: "Kilo Gateway Provider",
description: "Bundled Kilo Gateway provider plugin",
provider: {
label: "Kilo Gateway",
docsPath: "/providers/kilocode",
auth: [
{
methodId: "api-key",
label: "Kilo Gateway API key",
hint: "API key (OpenRouter-compatible)",
optionKey: "kilocodeApiKey",
flagName: "--kilocode-api-key",
envVar: "KILOCODE_API_KEY",
promptMessage: "Enter Kilo Gateway API key",
defaultModel: KILOCODE_DEFAULT_MODEL_REF,
applyConfig: (cfg) => applyKilocodeConfig(cfg),
},
],
catalog: {
buildProvider: buildKilocodeProviderWithDiscovery,
},
buildReplayPolicy: ({ modelId }) => buildKilocodeReplayPolicy(modelId),
wrapStreamFn: (ctx) => {
const thinkingLevel =
ctx.modelId === "kilo/auto" || isProxyReasoningUnsupported(ctx.modelId)
? undefined
: ctx.thinkingLevel;
return createKilocodeWrapper(ctx.streamFn, thinkingLevel);
},
isCacheTtlEligible: (ctx) => ctx.modelId.startsWith("anthropic/"),
},
});