mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-20 14:30:57 +00:00
69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import { definePluginEntry } from "openclaw/plugin-sdk/core";
|
|
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth";
|
|
import { buildSingleProviderApiKeyCatalog } from "openclaw/plugin-sdk/provider-catalog";
|
|
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";
|
|
|
|
export default definePluginEntry({
|
|
id: PROVIDER_ID,
|
|
name: "Kilo Gateway Provider",
|
|
description: "Bundled Kilo Gateway provider plugin",
|
|
register(api) {
|
|
api.registerProvider({
|
|
id: PROVIDER_ID,
|
|
label: "Kilo Gateway",
|
|
docsPath: "/providers/kilocode",
|
|
envVars: ["KILOCODE_API_KEY"],
|
|
auth: [
|
|
createProviderApiKeyAuthMethod({
|
|
providerId: PROVIDER_ID,
|
|
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,
|
|
expectedProviders: ["kilocode"],
|
|
applyConfig: (cfg) => applyKilocodeConfig(cfg),
|
|
wizard: {
|
|
choiceId: "kilocode-api-key",
|
|
choiceLabel: "Kilo Gateway API key",
|
|
groupId: "kilocode",
|
|
groupLabel: "Kilo Gateway",
|
|
groupHint: "API key (OpenRouter-compatible)",
|
|
},
|
|
}),
|
|
],
|
|
catalog: {
|
|
order: "simple",
|
|
run: (ctx) =>
|
|
buildSingleProviderApiKeyCatalog({
|
|
ctx,
|
|
providerId: PROVIDER_ID,
|
|
buildProvider: buildKilocodeProviderWithDiscovery,
|
|
}),
|
|
},
|
|
capabilities: {
|
|
geminiThoughtSignatureSanitization: true,
|
|
geminiThoughtSignatureModelHints: ["gemini"],
|
|
},
|
|
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/"),
|
|
});
|
|
},
|
|
});
|