From 02f8a86e5c129c179e3d69b85a2c68f762e5486e Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 22 Mar 2026 19:17:54 -0700 Subject: [PATCH] refactor(kilocode): route shared model constants through core seam --- extensions/kilocode/shared.ts | 48 ++++++----------------- src/agents/kilocode-models.ts | 2 +- src/plugin-sdk/provider-models.ts | 5 ++- src/plugins/provider-auth-storage.ts | 2 +- src/plugins/provider-model-definitions.ts | 2 +- src/plugins/provider-model-kilocode.ts | 37 +++++++++++++++++ 6 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 src/plugins/provider-model-kilocode.ts diff --git a/extensions/kilocode/shared.ts b/extensions/kilocode/shared.ts index 0be37e44622..9ed4dbbf307 100644 --- a/extensions/kilocode/shared.ts +++ b/extensions/kilocode/shared.ts @@ -1,36 +1,12 @@ -export const KILOCODE_BASE_URL = "https://api.kilo.ai/api/gateway/"; -export const KILOCODE_DEFAULT_MODEL_ID = "kilo/auto"; -export const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`; -export const KILOCODE_DEFAULT_MODEL_NAME = "Kilo Auto"; -export type KilocodeModelCatalogEntry = { - id: string; - name: string; - reasoning: boolean; - input: Array<"text" | "image">; - contextWindow?: number; - maxTokens?: number; -}; -/** - * Static fallback catalog — used by the sync setup path and as a - * fallback when dynamic model discovery from the gateway API fails. - * The full model list is fetched dynamically by {@link discoverKilocodeModels} - * in `src/agents/kilocode-models.ts`. - */ -export const KILOCODE_MODEL_CATALOG: KilocodeModelCatalogEntry[] = [ - { - id: KILOCODE_DEFAULT_MODEL_ID, - name: KILOCODE_DEFAULT_MODEL_NAME, - reasoning: true, - input: ["text", "image"], - contextWindow: 1000000, - maxTokens: 128000, - }, -]; -export const KILOCODE_DEFAULT_CONTEXT_WINDOW = 1000000; -export const KILOCODE_DEFAULT_MAX_TOKENS = 128000; -export const KILOCODE_DEFAULT_COST = { - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, -} as const; +export { + KILOCODE_BASE_URL, + KILOCODE_DEFAULT_CONTEXT_WINDOW, + KILOCODE_DEFAULT_COST, + KILOCODE_DEFAULT_MAX_TOKENS, + KILOCODE_DEFAULT_MODEL_ID, + KILOCODE_DEFAULT_MODEL_NAME, + KILOCODE_DEFAULT_MODEL_REF, + KILOCODE_MODEL_CATALOG, +} from "openclaw/plugin-sdk/provider-models"; + +export type { KilocodeModelCatalogEntry } from "openclaw/plugin-sdk/provider-models"; diff --git a/src/agents/kilocode-models.ts b/src/agents/kilocode-models.ts index 457f45ccdce..480c15ee8fd 100644 --- a/src/agents/kilocode-models.ts +++ b/src/agents/kilocode-models.ts @@ -6,7 +6,7 @@ import { KILOCODE_DEFAULT_COST, KILOCODE_DEFAULT_MAX_TOKENS, KILOCODE_MODEL_CATALOG, -} from "../../extensions/kilocode/shared.js"; +} from "../plugins/provider-model-kilocode.js"; const log = createSubsystemLogger("kilocode-models"); diff --git a/src/plugin-sdk/provider-models.ts b/src/plugin-sdk/provider-models.ts index e6eb15d5938..95de0adc384 100644 --- a/src/plugin-sdk/provider-models.ts +++ b/src/plugin-sdk/provider-models.ts @@ -7,11 +7,12 @@ import { KILOCODE_DEFAULT_MAX_TOKENS, KILOCODE_DEFAULT_MODEL_ID, KILOCODE_DEFAULT_MODEL_NAME, -} from "../../extensions/kilocode/shared.js"; +} from "../plugins/provider-model-kilocode.js"; export type { ModelApi, ModelProviderConfig } from "../config/types.models.js"; export type { ModelDefinitionConfig } from "../config/types.models.js"; export type { ProviderPlugin } from "../plugins/types.js"; +export type { KilocodeModelCatalogEntry } from "../plugins/provider-model-kilocode.js"; export { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js"; export { @@ -111,7 +112,7 @@ export { KILOCODE_DEFAULT_MODEL_ID, KILOCODE_DEFAULT_MODEL_NAME, KILOCODE_MODEL_CATALOG, -} from "../../extensions/kilocode/shared.js"; +} from "../plugins/provider-model-kilocode.js"; export { discoverVercelAiGatewayModels, VERCEL_AI_GATEWAY_BASE_URL, diff --git a/src/plugins/provider-auth-storage.ts b/src/plugins/provider-auth-storage.ts index 59f20513431..1c533124500 100644 --- a/src/plugins/provider-auth-storage.ts +++ b/src/plugins/provider-auth-storage.ts @@ -1,7 +1,7 @@ import { resolveOpenClawAgentDir } from "../agents/agent-paths.js"; import { upsertAuthProfile } from "../agents/auth-profiles.js"; import type { SecretInput } from "../config/types.secrets.js"; -import { KILOCODE_DEFAULT_MODEL_REF } from "../../extensions/kilocode/shared.js"; +import { KILOCODE_DEFAULT_MODEL_REF } from "./provider-model-kilocode.js"; import { buildApiKeyCredential, type ApiKeyStorageOptions, diff --git a/src/plugins/provider-model-definitions.ts b/src/plugins/provider-model-definitions.ts index 2d790de9d43..967aefaaf27 100644 --- a/src/plugins/provider-model-definitions.ts +++ b/src/plugins/provider-model-definitions.ts @@ -5,7 +5,7 @@ import { KILOCODE_DEFAULT_MAX_TOKENS, KILOCODE_DEFAULT_MODEL_ID, KILOCODE_DEFAULT_MODEL_NAME, -} from "../../extensions/kilocode/shared.js"; +} from "./provider-model-kilocode.js"; const KIMI_CODING_BASE_URL = "https://api.kimi.com/coding/"; const KIMI_CODING_MODEL_ID = "kimi-code"; diff --git a/src/plugins/provider-model-kilocode.ts b/src/plugins/provider-model-kilocode.ts new file mode 100644 index 00000000000..f87e0921e7d --- /dev/null +++ b/src/plugins/provider-model-kilocode.ts @@ -0,0 +1,37 @@ +export const KILOCODE_BASE_URL = "https://api.kilo.ai/api/gateway/"; +export const KILOCODE_DEFAULT_MODEL_ID = "kilo/auto"; +export const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`; +export const KILOCODE_DEFAULT_MODEL_NAME = "Kilo Auto"; + +export type KilocodeModelCatalogEntry = { + id: string; + name: string; + reasoning: boolean; + input: Array<"text" | "image">; + contextWindow?: number; + maxTokens?: number; +}; + +/** + * Static fallback catalog used by synchronous config surfaces and as the + * discovery fallback when the gateway model endpoint is unavailable. + */ +export const KILOCODE_MODEL_CATALOG: KilocodeModelCatalogEntry[] = [ + { + id: KILOCODE_DEFAULT_MODEL_ID, + name: KILOCODE_DEFAULT_MODEL_NAME, + reasoning: true, + input: ["text", "image"], + contextWindow: 1000000, + maxTokens: 128000, + }, +]; + +export const KILOCODE_DEFAULT_CONTEXT_WINDOW = 1000000; +export const KILOCODE_DEFAULT_MAX_TOKENS = 128000; +export const KILOCODE_DEFAULT_COST = { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, +} as const;