@bogyie/opencode-kiro-plugin 0.2.5 → 0.2.6
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/plugin.js +20 -12
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -30,6 +30,19 @@ function modelRecord(value) {
|
|
|
30
30
|
return {};
|
|
31
31
|
return Object.fromEntries(Object.entries(value).filter((entry) => Boolean(entry[0]) && Boolean(entry[1]) && typeof entry[1] === "object" && !Array.isArray(entry[1])));
|
|
32
32
|
}
|
|
33
|
+
function visibleProviderModels(cache, configuredModels, hiddenModels, disabledModels) {
|
|
34
|
+
const discovered = discoveredProviderModels(cache);
|
|
35
|
+
const modelIDs = new Set([...Object.keys(discovered), ...Object.keys(configuredModels), ...Object.keys(hiddenModels)]);
|
|
36
|
+
return Object.fromEntries([...modelIDs]
|
|
37
|
+
.filter((id) => !disabledModels.has(normalizeModelName(id)))
|
|
38
|
+
.map((id) => [
|
|
39
|
+
id,
|
|
40
|
+
{
|
|
41
|
+
...(discovered[id] ?? {}),
|
|
42
|
+
...(configuredModels[id] ?? {}),
|
|
43
|
+
},
|
|
44
|
+
]));
|
|
45
|
+
}
|
|
33
46
|
function bearerToken(init) {
|
|
34
47
|
const header = new Headers(init?.headers).get("authorization");
|
|
35
48
|
const match = header?.match(/^Bearer\s+(.+)$/i);
|
|
@@ -80,6 +93,7 @@ export function createKiroPlugin() {
|
|
|
80
93
|
const modelCache = new ModelCache(options.modelCacheTtlSeconds);
|
|
81
94
|
let localServer;
|
|
82
95
|
let configuredModels = { ...options.extraModels };
|
|
96
|
+
let userModelOverrides;
|
|
83
97
|
const disabledModels = new Set(options.disabledModels.map(normalizeModelName));
|
|
84
98
|
if (Object.keys(options.extraModels).length > 0) {
|
|
85
99
|
modelCache.update(Object.keys(options.extraModels).map((id) => ({ id: normalizeModelName(id) })));
|
|
@@ -131,15 +145,16 @@ export function createKiroPlugin() {
|
|
|
131
145
|
config.provider[options.providerID] ??= {};
|
|
132
146
|
const provider = config.provider[options.providerID];
|
|
133
147
|
const server = await ensureLocalServer();
|
|
148
|
+
userModelOverrides ??= modelRecord(provider.models);
|
|
134
149
|
configuredModels = {
|
|
135
150
|
...options.extraModels,
|
|
136
|
-
...
|
|
151
|
+
...userModelOverrides,
|
|
137
152
|
};
|
|
138
153
|
provider.name ??= "Kiro";
|
|
139
154
|
provider.npm = "@ai-sdk/openai-compatible";
|
|
140
155
|
provider.api = server.baseURL;
|
|
141
156
|
provider.options ??= {};
|
|
142
|
-
provider.models = configuredModels;
|
|
157
|
+
provider.models = visibleProviderModels(modelCache, configuredModels, options.hiddenModels, disabledModels);
|
|
143
158
|
},
|
|
144
159
|
auth: {
|
|
145
160
|
provider: options.providerID,
|
|
@@ -206,20 +221,13 @@ export function createKiroPlugin() {
|
|
|
206
221
|
id: options.providerID,
|
|
207
222
|
models: async (provider) => {
|
|
208
223
|
await discoverIfStale();
|
|
209
|
-
const discovered = discoveredProviderModels(modelCache);
|
|
210
224
|
const existing = modelRecord(provider.models);
|
|
211
|
-
const
|
|
212
|
-
...Object.keys(discovered),
|
|
213
|
-
...Object.keys(configuredModels),
|
|
214
|
-
...Object.keys(options.hiddenModels),
|
|
215
|
-
]);
|
|
225
|
+
const visibleModels = visibleProviderModels(modelCache, configuredModels, options.hiddenModels, disabledModels);
|
|
216
226
|
const server = await ensureLocalServer();
|
|
217
|
-
return Object.fromEntries(
|
|
218
|
-
.filter((id) => !disabledModels.has(normalizeModelName(id)))
|
|
227
|
+
return Object.fromEntries(Object.keys(visibleModels)
|
|
219
228
|
.map((id) => {
|
|
220
229
|
const model = {
|
|
221
|
-
...(
|
|
222
|
-
...(configuredModels[id] ?? {}),
|
|
230
|
+
...(visibleModels[id] ?? {}),
|
|
223
231
|
...(existing[id] ?? {}),
|
|
224
232
|
};
|
|
225
233
|
return [
|