@openclaw/kilocode-provider 2026.9.8 → 2026.10.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/provider-models-CplaZ4OM.mjs +179 -0
- package/dist/api.js +2 -2
- package/dist/index.js +2 -2
- package/dist/onboard.js +6 -6
- package/dist/provider-catalog.js +17 -1
- package/dist/provider-models.js +1 -123
- package/dist/stream.js +8 -33
- package/package.json +4 -4
- package/dist/.setup/provider-catalog-CL9OybJF.mjs +0 -79
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
2
|
+
import { buildLiveModelProviderConfig, readLiveModelCatalogStringField } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
3
|
+
import { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
4
|
+
import { asPositiveSafeInteger, isRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
//#region extensions/kilocode/openclaw.plugin.json
|
|
6
|
+
var openclaw_plugin_default = {
|
|
7
|
+
id: "kilocode",
|
|
8
|
+
categories: ["models"],
|
|
9
|
+
activation: { "onStartup": false },
|
|
10
|
+
enabledByDefault: true,
|
|
11
|
+
providers: ["kilocode"],
|
|
12
|
+
modelPricing: { "providers": { "kilocode": {
|
|
13
|
+
"modelsDev": { "passthroughProviderModel": true },
|
|
14
|
+
"openRouter": { "passthroughProviderModel": true },
|
|
15
|
+
"liteLLM": { "passthroughProviderModel": true }
|
|
16
|
+
} } },
|
|
17
|
+
setup: { "providers": [{
|
|
18
|
+
"id": "kilocode",
|
|
19
|
+
"envVars": ["KILOCODE_API_KEY"]
|
|
20
|
+
}] },
|
|
21
|
+
providerAuthChoices: [{
|
|
22
|
+
"provider": "kilocode",
|
|
23
|
+
"method": "api-key",
|
|
24
|
+
"choiceId": "kilocode-api-key",
|
|
25
|
+
"appGuidedSecret": true,
|
|
26
|
+
"choiceLabel": "Kilo Gateway API key",
|
|
27
|
+
"choiceHint": "API key (OpenRouter-compatible)",
|
|
28
|
+
"groupId": "kilocode",
|
|
29
|
+
"groupLabel": "Kilo Gateway",
|
|
30
|
+
"groupHint": "API key (OpenRouter-compatible)",
|
|
31
|
+
"optionKey": "kilocodeApiKey",
|
|
32
|
+
"cliFlag": "--kilocode-api-key",
|
|
33
|
+
"cliOption": "--kilocode-api-key <key>",
|
|
34
|
+
"cliDescription": "Kilo Gateway API key"
|
|
35
|
+
}],
|
|
36
|
+
configSchema: {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"additionalProperties": false,
|
|
39
|
+
"properties": {}
|
|
40
|
+
},
|
|
41
|
+
modelCatalog: {
|
|
42
|
+
"modelsDev": { "kilocode": "kilo" },
|
|
43
|
+
"providers": { "kilocode": {
|
|
44
|
+
"baseUrl": "https://api.kilo.ai/api/gateway/",
|
|
45
|
+
"api": "openai-completions",
|
|
46
|
+
"models": [{
|
|
47
|
+
"id": "kilo-auto/balanced",
|
|
48
|
+
"name": "Auto Balanced",
|
|
49
|
+
"reasoning": true,
|
|
50
|
+
"input": ["text", "image"],
|
|
51
|
+
"cost": {
|
|
52
|
+
"input": .325,
|
|
53
|
+
"output": 1.95,
|
|
54
|
+
"cacheRead": .0325,
|
|
55
|
+
"cacheWrite": .40625
|
|
56
|
+
},
|
|
57
|
+
"contextWindow": 1e6,
|
|
58
|
+
"maxTokens": 65536
|
|
59
|
+
}]
|
|
60
|
+
} },
|
|
61
|
+
"discovery": { "kilocode": "refreshable" }
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region extensions/kilocode/provider-models.ts
|
|
66
|
+
const KILOCODE_MANIFEST_CATALOG = openclaw_plugin_default.modelCatalog.providers.kilocode;
|
|
67
|
+
const KILOCODE_DEFAULT_MODEL = buildManifestModelProviderConfig({
|
|
68
|
+
providerId: "kilocode",
|
|
69
|
+
catalog: KILOCODE_MANIFEST_CATALOG
|
|
70
|
+
}).models[0];
|
|
71
|
+
const KILOCODE_BASE_URL = KILOCODE_MANIFEST_CATALOG.baseUrl;
|
|
72
|
+
const KILOCODE_DEFAULT_MODEL_ID = KILOCODE_DEFAULT_MODEL.id;
|
|
73
|
+
const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`;
|
|
74
|
+
const KILOCODE_DEFAULT_MODEL_NAME = KILOCODE_DEFAULT_MODEL.name;
|
|
75
|
+
const KILOCODE_MODEL_CATALOG = [{
|
|
76
|
+
id: KILOCODE_DEFAULT_MODEL_ID,
|
|
77
|
+
name: KILOCODE_DEFAULT_MODEL_NAME,
|
|
78
|
+
input: ["text", "image"],
|
|
79
|
+
reasoning: true
|
|
80
|
+
}];
|
|
81
|
+
const KILOCODE_DEFAULT_CONTEXT_WINDOW = KILOCODE_DEFAULT_MODEL.contextWindow;
|
|
82
|
+
const KILOCODE_DEFAULT_MAX_TOKENS = KILOCODE_DEFAULT_MODEL.maxTokens;
|
|
83
|
+
const KILOCODE_DEFAULT_COST = KILOCODE_DEFAULT_MODEL.cost;
|
|
84
|
+
const KILOCODE_MODELS_URL = `${KILOCODE_BASE_URL}models`;
|
|
85
|
+
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
86
|
+
function toPricePerMillion(perToken, fallback = 0) {
|
|
87
|
+
const num = Number(perToken);
|
|
88
|
+
return Number.isFinite(num) && num >= 0 ? num * 1e6 : fallback;
|
|
89
|
+
}
|
|
90
|
+
function parseModality(entry) {
|
|
91
|
+
const modalities = entry.architecture?.input_modalities;
|
|
92
|
+
if (!Array.isArray(modalities)) return ["text"];
|
|
93
|
+
return modalities.some((m) => typeof m === "string" && normalizeLowercaseStringOrEmpty(m) === "image") ? ["text", "image"] : ["text"];
|
|
94
|
+
}
|
|
95
|
+
function parseReasoning(entry) {
|
|
96
|
+
const params = entry.supported_parameters;
|
|
97
|
+
if (!Array.isArray(params)) return false;
|
|
98
|
+
return params.includes("reasoning") || params.includes("include_reasoning");
|
|
99
|
+
}
|
|
100
|
+
function toModelDefinition(entry) {
|
|
101
|
+
const fallbackCost = entry.id === KILOCODE_DEFAULT_MODEL_ID ? KILOCODE_DEFAULT_COST : void 0;
|
|
102
|
+
return {
|
|
103
|
+
id: entry.id,
|
|
104
|
+
name: entry.name || entry.id,
|
|
105
|
+
reasoning: parseReasoning(entry),
|
|
106
|
+
input: parseModality(entry),
|
|
107
|
+
cost: {
|
|
108
|
+
input: toPricePerMillion(entry.pricing.prompt, fallbackCost?.input),
|
|
109
|
+
output: toPricePerMillion(entry.pricing.completion, fallbackCost?.output),
|
|
110
|
+
cacheRead: toPricePerMillion(entry.pricing.input_cache_read),
|
|
111
|
+
cacheWrite: toPricePerMillion(entry.pricing.input_cache_write)
|
|
112
|
+
},
|
|
113
|
+
contextWindow: asPositiveSafeInteger(entry.top_provider?.context_length) ?? asPositiveSafeInteger(entry.context_length) ?? KILOCODE_DEFAULT_CONTEXT_WINDOW,
|
|
114
|
+
maxTokens: asPositiveSafeInteger(entry.top_provider?.max_completion_tokens) ?? KILOCODE_DEFAULT_MAX_TOKENS
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function buildStaticCatalog() {
|
|
118
|
+
return KILOCODE_MODEL_CATALOG.map((model) => ({
|
|
119
|
+
id: model.id,
|
|
120
|
+
name: model.name,
|
|
121
|
+
reasoning: model.reasoning,
|
|
122
|
+
input: model.input,
|
|
123
|
+
cost: KILOCODE_DEFAULT_COST,
|
|
124
|
+
contextWindow: model.contextWindow ?? KILOCODE_DEFAULT_CONTEXT_WINDOW,
|
|
125
|
+
maxTokens: model.maxTokens ?? KILOCODE_DEFAULT_MAX_TOKENS
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
function asGatewayModelEntry(value) {
|
|
129
|
+
if (!isRecord(value)) throw new Error("Kilocode model list: malformed JSON response");
|
|
130
|
+
const entry = value;
|
|
131
|
+
if (typeof entry.id !== "string" || !isRecord(entry.pricing)) throw new Error("Kilocode model list: malformed JSON response");
|
|
132
|
+
return entry;
|
|
133
|
+
}
|
|
134
|
+
function readGatewayModelRows(body) {
|
|
135
|
+
const data = body?.data;
|
|
136
|
+
if (!Array.isArray(data)) throw new Error("Kilocode model list: malformed JSON response");
|
|
137
|
+
return data;
|
|
138
|
+
}
|
|
139
|
+
function projectKilocodeModels(rows) {
|
|
140
|
+
const models = [];
|
|
141
|
+
const discoveredIds = /* @__PURE__ */ new Set();
|
|
142
|
+
for (const rawEntry of rows) {
|
|
143
|
+
const id = readLiveModelCatalogStringField(rawEntry, "id");
|
|
144
|
+
try {
|
|
145
|
+
const entry = asGatewayModelEntry(rawEntry);
|
|
146
|
+
if (!id || discoveredIds.has(id) || entry.architecture?.output_modalities?.includes("image")) continue;
|
|
147
|
+
models.push(toModelDefinition(entry));
|
|
148
|
+
discoveredIds.add(id);
|
|
149
|
+
} catch {}
|
|
150
|
+
}
|
|
151
|
+
for (const staticModel of models.length > 0 ? buildStaticCatalog() : []) if (!discoveredIds.has(staticModel.id)) models.unshift(staticModel);
|
|
152
|
+
return models;
|
|
153
|
+
}
|
|
154
|
+
async function discoverKilocodeModels(options = {}) {
|
|
155
|
+
return (await buildLiveModelProviderConfig({
|
|
156
|
+
...options,
|
|
157
|
+
providerId: "kilocode",
|
|
158
|
+
endpoint: KILOCODE_MODELS_URL,
|
|
159
|
+
providerConfig: {
|
|
160
|
+
baseUrl: KILOCODE_BASE_URL,
|
|
161
|
+
api: "openai-completions"
|
|
162
|
+
},
|
|
163
|
+
models: buildStaticCatalog(),
|
|
164
|
+
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
165
|
+
ttlMs: 0,
|
|
166
|
+
readRows: readGatewayModelRows,
|
|
167
|
+
policy: ssrfPolicyFromHttpBaseUrlAllowedHostname(KILOCODE_BASE_URL),
|
|
168
|
+
auditContext: "kilocode.model_discovery",
|
|
169
|
+
projectRows: projectKilocodeModels
|
|
170
|
+
})).models;
|
|
171
|
+
}
|
|
172
|
+
function buildKilocodeModelDefinition() {
|
|
173
|
+
return {
|
|
174
|
+
...KILOCODE_DEFAULT_MODEL,
|
|
175
|
+
input: [...KILOCODE_DEFAULT_MODEL.input]
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { KILOCODE_DEFAULT_MODEL_ID as a, KILOCODE_MODELS_URL as c, discoverKilocodeModels as d, openclaw_plugin_default as f, KILOCODE_DEFAULT_MAX_TOKENS as i, KILOCODE_MODEL_CATALOG as l, KILOCODE_DEFAULT_CONTEXT_WINDOW as n, KILOCODE_DEFAULT_MODEL_NAME as o, KILOCODE_DEFAULT_COST as r, KILOCODE_DEFAULT_MODEL_REF as s, KILOCODE_BASE_URL as t, buildKilocodeModelDefinition as u };
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
1
|
+
import { a as KILOCODE_DEFAULT_MODEL_ID, c as KILOCODE_MODELS_URL, d as discoverKilocodeModels, i as KILOCODE_DEFAULT_MAX_TOKENS, l as KILOCODE_MODEL_CATALOG, n as KILOCODE_DEFAULT_CONTEXT_WINDOW, o as KILOCODE_DEFAULT_MODEL_NAME, r as KILOCODE_DEFAULT_COST, s as KILOCODE_DEFAULT_MODEL_REF, t as KILOCODE_BASE_URL, u as buildKilocodeModelDefinition } from "./.setup/provider-models-CplaZ4OM.mjs";
|
|
2
|
+
import { buildKilocodeProvider, buildKilocodeProviderWithDiscovery } from "./provider-catalog.js";
|
|
3
3
|
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_MODELS_URL, KILOCODE_MODEL_CATALOG, buildKilocodeModelDefinition, buildKilocodeProvider, buildKilocodeProviderWithDiscovery, discoverKilocodeModels };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { f as openclaw_plugin_default, s as KILOCODE_DEFAULT_MODEL_REF } from "./.setup/provider-models-CplaZ4OM.mjs";
|
|
2
|
+
import { buildKilocodeProvider, buildKilocodeProviderWithDiscovery } from "./provider-catalog.js";
|
|
3
3
|
import { applyKilocodeConfig } from "./onboard.js";
|
|
4
4
|
import { wrapKilocodeProviderStream } from "./stream.js";
|
|
5
5
|
import { readConfiguredProviderCatalogEntries } from "openclaw/plugin-sdk/provider-catalog-shared";
|
package/dist/onboard.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { s as KILOCODE_DEFAULT_MODEL_REF, t as KILOCODE_BASE_URL } from "./.setup/provider-models-CplaZ4OM.mjs";
|
|
2
|
+
import { buildKilocodeProvider } from "./provider-catalog.js";
|
|
3
|
+
import { createProviderConnectionPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
4
4
|
//#region extensions/kilocode/onboard.ts
|
|
5
|
-
const { applyConfig: applyKilocodeConfig } =
|
|
5
|
+
const { applyConfig: applyKilocodeConfig } = createProviderConnectionPresetAppliers({
|
|
6
6
|
primaryModelRef: KILOCODE_DEFAULT_MODEL_REF,
|
|
7
|
-
resolveParams: (
|
|
7
|
+
resolveParams: () => ({
|
|
8
8
|
providerId: "kilocode",
|
|
9
9
|
api: "openai-completions",
|
|
10
10
|
baseUrl: KILOCODE_BASE_URL,
|
|
11
|
-
catalogModels:
|
|
11
|
+
catalogModels: () => buildKilocodeProvider().models,
|
|
12
12
|
aliases: [{
|
|
13
13
|
modelRef: KILOCODE_DEFAULT_MODEL_REF,
|
|
14
14
|
alias: "Kilo Gateway"
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as discoverKilocodeModels, f as openclaw_plugin_default, t as KILOCODE_BASE_URL } from "./.setup/provider-models-CplaZ4OM.mjs";
|
|
2
|
+
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
|
+
//#region extensions/kilocode/provider-catalog.ts
|
|
4
|
+
function buildKilocodeProvider() {
|
|
5
|
+
return buildManifestModelProviderConfig({
|
|
6
|
+
providerId: "kilocode",
|
|
7
|
+
catalog: openclaw_plugin_default.modelCatalog.providers.kilocode
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async function buildKilocodeProviderWithDiscovery(options = {}) {
|
|
11
|
+
return {
|
|
12
|
+
baseUrl: KILOCODE_BASE_URL,
|
|
13
|
+
api: "openai-completions",
|
|
14
|
+
models: await discoverKilocodeModels(options)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
2
18
|
export { buildKilocodeProvider, buildKilocodeProviderWithDiscovery };
|
package/dist/provider-models.js
CHANGED
|
@@ -1,124 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
3
|
-
import { asPositiveSafeInteger, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
//#region extensions/kilocode/provider-models.ts
|
|
5
|
-
const KILOCODE_BASE_URL = "https://api.kilo.ai/api/gateway/";
|
|
6
|
-
const KILOCODE_DEFAULT_MODEL_ID = "kilo-auto/balanced";
|
|
7
|
-
const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`;
|
|
8
|
-
const KILOCODE_DEFAULT_MODEL_NAME = "Auto Balanced";
|
|
9
|
-
const KILOCODE_MODEL_CATALOG = [{
|
|
10
|
-
id: KILOCODE_DEFAULT_MODEL_ID,
|
|
11
|
-
name: KILOCODE_DEFAULT_MODEL_NAME,
|
|
12
|
-
input: ["text", "image"],
|
|
13
|
-
reasoning: true
|
|
14
|
-
}];
|
|
15
|
-
const KILOCODE_DEFAULT_CONTEXT_WINDOW = 1e6;
|
|
16
|
-
const KILOCODE_DEFAULT_MAX_TOKENS = 65536;
|
|
17
|
-
const KILOCODE_DEFAULT_COST = {
|
|
18
|
-
input: .325,
|
|
19
|
-
output: 1.95,
|
|
20
|
-
cacheRead: .0325,
|
|
21
|
-
cacheWrite: .40625
|
|
22
|
-
};
|
|
23
|
-
const KILOCODE_MODELS_URL = `${KILOCODE_BASE_URL}models`;
|
|
24
|
-
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
25
|
-
function toPricePerMillion(perToken, fallback = 0) {
|
|
26
|
-
const num = Number(perToken);
|
|
27
|
-
return Number.isFinite(num) && num >= 0 ? num * 1e6 : fallback;
|
|
28
|
-
}
|
|
29
|
-
function parseModality(entry) {
|
|
30
|
-
const modalities = entry.architecture?.input_modalities;
|
|
31
|
-
if (!Array.isArray(modalities)) return ["text"];
|
|
32
|
-
return modalities.some((m) => typeof m === "string" && normalizeLowercaseStringOrEmpty(m) === "image") ? ["text", "image"] : ["text"];
|
|
33
|
-
}
|
|
34
|
-
function parseReasoning(entry) {
|
|
35
|
-
const params = entry.supported_parameters;
|
|
36
|
-
if (!Array.isArray(params)) return false;
|
|
37
|
-
return params.includes("reasoning") || params.includes("include_reasoning");
|
|
38
|
-
}
|
|
39
|
-
function toModelDefinition(entry) {
|
|
40
|
-
const fallbackCost = entry.id === "kilo-auto/balanced" ? KILOCODE_DEFAULT_COST : void 0;
|
|
41
|
-
return {
|
|
42
|
-
id: entry.id,
|
|
43
|
-
name: entry.name || entry.id,
|
|
44
|
-
reasoning: parseReasoning(entry),
|
|
45
|
-
input: parseModality(entry),
|
|
46
|
-
cost: {
|
|
47
|
-
input: toPricePerMillion(entry.pricing.prompt, fallbackCost?.input),
|
|
48
|
-
output: toPricePerMillion(entry.pricing.completion, fallbackCost?.output),
|
|
49
|
-
cacheRead: toPricePerMillion(entry.pricing.input_cache_read),
|
|
50
|
-
cacheWrite: toPricePerMillion(entry.pricing.input_cache_write)
|
|
51
|
-
},
|
|
52
|
-
contextWindow: asPositiveSafeInteger(entry.top_provider?.context_length) ?? asPositiveSafeInteger(entry.context_length) ?? 1e6,
|
|
53
|
-
maxTokens: asPositiveSafeInteger(entry.top_provider?.max_completion_tokens) ?? 65536
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function buildStaticCatalog() {
|
|
57
|
-
return KILOCODE_MODEL_CATALOG.map((model) => ({
|
|
58
|
-
id: model.id,
|
|
59
|
-
name: model.name,
|
|
60
|
-
reasoning: model.reasoning,
|
|
61
|
-
input: model.input,
|
|
62
|
-
cost: KILOCODE_DEFAULT_COST,
|
|
63
|
-
contextWindow: model.contextWindow ?? 1e6,
|
|
64
|
-
maxTokens: model.maxTokens ?? 65536
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
function asGatewayModelEntry(value) {
|
|
68
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("Kilocode model list: malformed JSON response");
|
|
69
|
-
const entry = value;
|
|
70
|
-
if (typeof entry.id !== "string" || typeof entry.pricing !== "object" || entry.pricing === null || Array.isArray(entry.pricing)) throw new Error("Kilocode model list: malformed JSON response");
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
function readGatewayModelRows(body) {
|
|
74
|
-
const data = body?.data;
|
|
75
|
-
if (!Array.isArray(data)) throw new Error("Kilocode model list: malformed JSON response");
|
|
76
|
-
return data;
|
|
77
|
-
}
|
|
78
|
-
function projectKilocodeModels(rows) {
|
|
79
|
-
const models = [];
|
|
80
|
-
const discoveredIds = /* @__PURE__ */ new Set();
|
|
81
|
-
for (const rawEntry of rows) {
|
|
82
|
-
const id = readLiveModelCatalogStringField(rawEntry, "id");
|
|
83
|
-
try {
|
|
84
|
-
const entry = asGatewayModelEntry(rawEntry);
|
|
85
|
-
if (!id || discoveredIds.has(id) || entry.architecture?.output_modalities?.includes("image")) continue;
|
|
86
|
-
models.push(toModelDefinition(entry));
|
|
87
|
-
discoveredIds.add(id);
|
|
88
|
-
} catch {}
|
|
89
|
-
}
|
|
90
|
-
for (const staticModel of models.length > 0 ? buildStaticCatalog() : []) if (!discoveredIds.has(staticModel.id)) models.unshift(staticModel);
|
|
91
|
-
return models;
|
|
92
|
-
}
|
|
93
|
-
async function discoverKilocodeModels(options = {}) {
|
|
94
|
-
return (await buildLiveModelProviderConfig({
|
|
95
|
-
...options,
|
|
96
|
-
providerId: "kilocode",
|
|
97
|
-
endpoint: KILOCODE_MODELS_URL,
|
|
98
|
-
providerConfig: {
|
|
99
|
-
baseUrl: KILOCODE_BASE_URL,
|
|
100
|
-
api: "openai-completions"
|
|
101
|
-
},
|
|
102
|
-
models: buildStaticCatalog(),
|
|
103
|
-
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
104
|
-
ttlMs: 0,
|
|
105
|
-
readRows: readGatewayModelRows,
|
|
106
|
-
buildRequestHeaders: () => ({ Accept: "application/json" }),
|
|
107
|
-
policy: ssrfPolicyFromHttpBaseUrlAllowedHostname(KILOCODE_BASE_URL),
|
|
108
|
-
auditContext: "kilocode.model_discovery",
|
|
109
|
-
projectRows: projectKilocodeModels
|
|
110
|
-
})).models;
|
|
111
|
-
}
|
|
112
|
-
function buildKilocodeModelDefinition() {
|
|
113
|
-
return {
|
|
114
|
-
id: KILOCODE_DEFAULT_MODEL_ID,
|
|
115
|
-
name: KILOCODE_DEFAULT_MODEL_NAME,
|
|
116
|
-
reasoning: true,
|
|
117
|
-
input: ["text", "image"],
|
|
118
|
-
cost: KILOCODE_DEFAULT_COST,
|
|
119
|
-
contextWindow: KILOCODE_DEFAULT_CONTEXT_WINDOW,
|
|
120
|
-
maxTokens: KILOCODE_DEFAULT_MAX_TOKENS
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
1
|
+
import { a as KILOCODE_DEFAULT_MODEL_ID, c as KILOCODE_MODELS_URL, d as discoverKilocodeModels, i as KILOCODE_DEFAULT_MAX_TOKENS, l as KILOCODE_MODEL_CATALOG, n as KILOCODE_DEFAULT_CONTEXT_WINDOW, o as KILOCODE_DEFAULT_MODEL_NAME, r as KILOCODE_DEFAULT_COST, s as KILOCODE_DEFAULT_MODEL_REF, t as KILOCODE_BASE_URL, u as buildKilocodeModelDefinition } from "./.setup/provider-models-CplaZ4OM.mjs";
|
|
124
2
|
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_MODELS_URL, KILOCODE_MODEL_CATALOG, buildKilocodeModelDefinition, discoverKilocodeModels };
|
package/dist/stream.js
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
+
import { isProxyReasoningUnsupportedModelHint } from "openclaw/plugin-sdk/provider-model-shared";
|
|
1
2
|
import { asOptionalRecord, normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
3
|
import { resolveProviderRequestHeaders } from "openclaw/plugin-sdk/provider-http";
|
|
3
4
|
import { normalizeOpenAICompatibleReasoningPayload } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
4
5
|
//#region extensions/kilocode/stream.ts
|
|
5
|
-
const KILOCODE_FEATURE_HEADER = "X-KILOCODE-FEATURE";
|
|
6
|
-
const KILOCODE_FEATURE_DEFAULT = "openclaw";
|
|
7
|
-
const KILOCODE_FEATURE_ENV_VAR = "KILOCODE_FEATURE";
|
|
8
|
-
function resolveKilocodeAppHeaders() {
|
|
9
|
-
const feature = process.env[KILOCODE_FEATURE_ENV_VAR]?.trim() || KILOCODE_FEATURE_DEFAULT;
|
|
10
|
-
return { [KILOCODE_FEATURE_HEADER]: feature };
|
|
11
|
-
}
|
|
12
|
-
function normalizeKilocodeStopPayload(payloadObj) {
|
|
13
|
-
if (typeof payloadObj.stop === "string") payloadObj.stop = [payloadObj.stop];
|
|
14
|
-
}
|
|
15
6
|
function normalizeKilocodeStopAfterCaller(value, fallbackPayload) {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
normalizeKilocodeStopPayload(replacementPayload);
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
if (fallbackPayload) normalizeKilocodeStopPayload(fallbackPayload);
|
|
7
|
+
const payload = asOptionalRecord(value) ?? fallbackPayload;
|
|
8
|
+
if (typeof payload?.stop === "string") payload.stop = [payload.stop];
|
|
22
9
|
return value;
|
|
23
10
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
function resolveKilocodeThinkingLevel(ctx) {
|
|
30
|
-
if (ctx.modelId === "kilo-auto/balanced" || isProxyReasoningUnsupported(ctx.modelId)) return;
|
|
31
|
-
return ctx.thinkingLevel;
|
|
32
|
-
}
|
|
33
|
-
function createKilocodeStreamWrapper(baseStreamFn, thinkingLevel) {
|
|
34
|
-
if (!baseStreamFn) return;
|
|
35
|
-
const underlying = baseStreamFn;
|
|
11
|
+
function wrapKilocodeProviderStream(ctx) {
|
|
12
|
+
if (normalizeOptionalLowercaseString(ctx.provider) !== "kilocode" || !ctx.streamFn) return;
|
|
13
|
+
const underlying = ctx.streamFn;
|
|
14
|
+
const thinkingLevel = ctx.modelId === "kilo-auto/balanced" || isProxyReasoningUnsupportedModelHint(ctx.modelId) ? void 0 : ctx.thinkingLevel;
|
|
36
15
|
return (model, context, options) => {
|
|
37
16
|
const originalOnPayload = options?.onPayload;
|
|
38
17
|
const headers = resolveProviderRequestHeaders({
|
|
@@ -42,7 +21,7 @@ function createKilocodeStreamWrapper(baseStreamFn, thinkingLevel) {
|
|
|
42
21
|
capability: "llm",
|
|
43
22
|
transport: "stream",
|
|
44
23
|
callerHeaders: options?.headers,
|
|
45
|
-
defaultHeaders:
|
|
24
|
+
defaultHeaders: { "X-KILOCODE-FEATURE": process.env.KILOCODE_FEATURE?.trim() || "openclaw" },
|
|
46
25
|
precedence: "defaults-win"
|
|
47
26
|
});
|
|
48
27
|
return underlying(model, context, {
|
|
@@ -58,9 +37,5 @@ function createKilocodeStreamWrapper(baseStreamFn, thinkingLevel) {
|
|
|
58
37
|
});
|
|
59
38
|
};
|
|
60
39
|
}
|
|
61
|
-
function wrapKilocodeProviderStream(ctx) {
|
|
62
|
-
if (normalizeOptionalLowercaseString(ctx.provider) !== "kilocode") return;
|
|
63
|
-
return createKilocodeStreamWrapper(ctx.streamFn, resolveKilocodeThinkingLevel(ctx));
|
|
64
|
-
}
|
|
65
40
|
//#endregion
|
|
66
41
|
export { wrapKilocodeProviderStream };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/kilocode-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.10.1-beta.1",
|
|
4
4
|
"description": "OpenClaw Kilo Gateway provider plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.6.8"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.
|
|
21
|
+
"pluginApi": ">=2026.10.1-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.10.1-beta.1",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.
|
|
43
|
+
"openclaw": ">=2026.10.1-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { KILOCODE_BASE_URL, discoverKilocodeModels } from "../provider-models.js";
|
|
2
|
-
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
|
-
//#region extensions/kilocode/openclaw.plugin.json
|
|
4
|
-
var openclaw_plugin_default = {
|
|
5
|
-
id: "kilocode",
|
|
6
|
-
categories: ["models"],
|
|
7
|
-
activation: { "onStartup": false },
|
|
8
|
-
enabledByDefault: true,
|
|
9
|
-
providers: ["kilocode"],
|
|
10
|
-
modelPricing: { "providers": { "kilocode": {
|
|
11
|
-
"modelsDev": { "passthroughProviderModel": true },
|
|
12
|
-
"openRouter": { "passthroughProviderModel": true },
|
|
13
|
-
"liteLLM": { "passthroughProviderModel": true }
|
|
14
|
-
} } },
|
|
15
|
-
setup: { "providers": [{
|
|
16
|
-
"id": "kilocode",
|
|
17
|
-
"envVars": ["KILOCODE_API_KEY"]
|
|
18
|
-
}] },
|
|
19
|
-
providerAuthChoices: [{
|
|
20
|
-
"provider": "kilocode",
|
|
21
|
-
"method": "api-key",
|
|
22
|
-
"choiceId": "kilocode-api-key",
|
|
23
|
-
"appGuidedSecret": true,
|
|
24
|
-
"choiceLabel": "Kilo Gateway API key",
|
|
25
|
-
"choiceHint": "API key (OpenRouter-compatible)",
|
|
26
|
-
"groupId": "kilocode",
|
|
27
|
-
"groupLabel": "Kilo Gateway",
|
|
28
|
-
"groupHint": "API key (OpenRouter-compatible)",
|
|
29
|
-
"optionKey": "kilocodeApiKey",
|
|
30
|
-
"cliFlag": "--kilocode-api-key",
|
|
31
|
-
"cliOption": "--kilocode-api-key <key>",
|
|
32
|
-
"cliDescription": "Kilo Gateway API key"
|
|
33
|
-
}],
|
|
34
|
-
configSchema: {
|
|
35
|
-
"type": "object",
|
|
36
|
-
"additionalProperties": false,
|
|
37
|
-
"properties": {}
|
|
38
|
-
},
|
|
39
|
-
modelCatalog: {
|
|
40
|
-
"modelsDev": { "kilocode": "kilo" },
|
|
41
|
-
"providers": { "kilocode": {
|
|
42
|
-
"baseUrl": "https://api.kilo.ai/api/gateway/",
|
|
43
|
-
"api": "openai-completions",
|
|
44
|
-
"models": [{
|
|
45
|
-
"id": "kilo-auto/balanced",
|
|
46
|
-
"name": "Auto Balanced",
|
|
47
|
-
"reasoning": true,
|
|
48
|
-
"input": ["text", "image"],
|
|
49
|
-
"cost": {
|
|
50
|
-
"input": .325,
|
|
51
|
-
"output": 1.95,
|
|
52
|
-
"cacheRead": .0325,
|
|
53
|
-
"cacheWrite": .40625
|
|
54
|
-
},
|
|
55
|
-
"contextWindow": 1e6,
|
|
56
|
-
"maxTokens": 65536
|
|
57
|
-
}]
|
|
58
|
-
} },
|
|
59
|
-
"discovery": { "kilocode": "refreshable" }
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region extensions/kilocode/provider-catalog.ts
|
|
64
|
-
function buildKilocodeProvider() {
|
|
65
|
-
return buildManifestModelProviderConfig({
|
|
66
|
-
providerId: "kilocode",
|
|
67
|
-
catalog: openclaw_plugin_default.modelCatalog.providers.kilocode
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
async function buildKilocodeProviderWithDiscovery(options = {}) {
|
|
71
|
-
const models = await discoverKilocodeModels(options);
|
|
72
|
-
return {
|
|
73
|
-
baseUrl: KILOCODE_BASE_URL,
|
|
74
|
-
api: "openai-completions",
|
|
75
|
-
models
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
//#endregion
|
|
79
|
-
export { buildKilocodeProviderWithDiscovery as n, openclaw_plugin_default as r, buildKilocodeProvider as t };
|