openclaw-plugin-model-fetch 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +280 -2
- package/dist/contract.d.ts +158 -0
- package/dist/contract.js +48 -0
- package/dist/control-ui/e7b2a8a372a676495b78ec52dbe12cb5154970f64d64c776a96aec3116b20a23/index.css +1 -0
- package/dist/control-ui/e7b2a8a372a676495b78ec52dbe12cb5154970f64d64c776a96aec3116b20a23/index.js +158 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -0
- package/dist/model-fetch.d.ts +88 -0
- package/dist/model-fetch.js +531 -0
- package/dist/operations.d.ts +33 -0
- package/dist/operations.js +353 -0
- package/dist/schemas.d.ts +192 -0
- package/dist/schemas.js +157 -0
- package/openclaw.plugin.json +74 -0
- package/package.json +71 -4
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
import { modelFetchContract } from "./contract.js";
|
|
4
|
+
import { fetchProviderModels, getProvider, mergeModels, resolveApiKey, resolveProviderFilter, resolveProviderTargetAgents, runModelFetch, selectFetchedModels, syncAgentModelEntries, syncConfiguredModelPolicyAllow, } from "./model-fetch.js";
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function errorMessage(error) {
|
|
9
|
+
return error instanceof Error ? error.message : String(error);
|
|
10
|
+
}
|
|
11
|
+
function toModelView(model) {
|
|
12
|
+
return {
|
|
13
|
+
id: model.id,
|
|
14
|
+
name: model.name || model.id,
|
|
15
|
+
...(typeof model.contextWindow === "number" && model.contextWindow > 0
|
|
16
|
+
? { contextWindow: Math.floor(model.contextWindow) }
|
|
17
|
+
: {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function normalizeFilter(filter) {
|
|
21
|
+
const normalized = {
|
|
22
|
+
manualIds: [
|
|
23
|
+
...new Set((filter.manualIds ?? []).map((id) => id.trim()).filter((id) => id.length > 0)),
|
|
24
|
+
],
|
|
25
|
+
replace: true,
|
|
26
|
+
};
|
|
27
|
+
if (typeof filter.includeRegex === "string")
|
|
28
|
+
normalized.includeRegex = filter.includeRegex;
|
|
29
|
+
if (typeof filter.excludeRegex === "string")
|
|
30
|
+
normalized.excludeRegex = filter.excludeRegex;
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
function normalizeTargetAgents(targetAgents) {
|
|
34
|
+
if (!targetAgents || targetAgents.length === 0)
|
|
35
|
+
return [];
|
|
36
|
+
return [...new Set(targetAgents.map((id) => id.trim()).filter((id) => id.length > 0))];
|
|
37
|
+
}
|
|
38
|
+
function configPath(providerId) {
|
|
39
|
+
return `models.providers.${providerId}.models`;
|
|
40
|
+
}
|
|
41
|
+
function planFingerprint(input) {
|
|
42
|
+
return createHash("sha256")
|
|
43
|
+
.update(JSON.stringify({
|
|
44
|
+
provider: input.providerId,
|
|
45
|
+
filter: input.filter,
|
|
46
|
+
fetched: input.fetchedIds,
|
|
47
|
+
existing: input.existingIds,
|
|
48
|
+
selected: input.selectedIds,
|
|
49
|
+
added: input.addedIds,
|
|
50
|
+
removed: input.removedIds,
|
|
51
|
+
}))
|
|
52
|
+
.digest("hex");
|
|
53
|
+
}
|
|
54
|
+
function sorted(ids) {
|
|
55
|
+
return [...ids].sort((left, right) => left.localeCompare(right));
|
|
56
|
+
}
|
|
57
|
+
function sameStringSets(left, right) {
|
|
58
|
+
const leftSorted = sorted(left);
|
|
59
|
+
const rightSorted = sorted(right);
|
|
60
|
+
return (leftSorted.length === rightSorted.length &&
|
|
61
|
+
leftSorted.every((value, index) => value === rightSorted[index]));
|
|
62
|
+
}
|
|
63
|
+
function ensurePluginEntry(draft, providerId, filter, targetAgents = []) {
|
|
64
|
+
draft.plugins ??= {};
|
|
65
|
+
draft.plugins.entries ??= {};
|
|
66
|
+
const existingEntry = draft.plugins.entries["model-fetch"];
|
|
67
|
+
const entry = isRecord(existingEntry) ? existingEntry : {};
|
|
68
|
+
const pluginConfig = isRecord(entry.config) ? entry.config : {};
|
|
69
|
+
const providers = isRecord(pluginConfig.providers) ? pluginConfig.providers : {};
|
|
70
|
+
const existingProvider = isRecord(providers[providerId]) ? providers[providerId] : {};
|
|
71
|
+
providers[providerId] = {
|
|
72
|
+
...existingProvider,
|
|
73
|
+
filter,
|
|
74
|
+
targetAgents: normalizeTargetAgents(targetAgents),
|
|
75
|
+
};
|
|
76
|
+
pluginConfig.providers = providers;
|
|
77
|
+
entry.config = pluginConfig;
|
|
78
|
+
draft.plugins.entries["model-fetch"] = entry;
|
|
79
|
+
}
|
|
80
|
+
export function createModelFetchOperations({ api, factoryConfig, fetchModels = fetchProviderModels, now = () => new Date(), }) {
|
|
81
|
+
const runtime = api.runtime;
|
|
82
|
+
function currentConfig() {
|
|
83
|
+
return runtime.config.current();
|
|
84
|
+
}
|
|
85
|
+
function savedFilter(providerId, config = currentConfig()) {
|
|
86
|
+
return normalizeFilter(resolveProviderFilter(providerId, config, factoryConfig));
|
|
87
|
+
}
|
|
88
|
+
function savedTargetAgents(providerId, config = currentConfig()) {
|
|
89
|
+
return normalizeTargetAgents(resolveProviderTargetAgents(providerId, config, factoryConfig));
|
|
90
|
+
}
|
|
91
|
+
async function fetchModelsForProvider(providerId) {
|
|
92
|
+
const config = currentConfig();
|
|
93
|
+
const provider = getProvider(config, providerId);
|
|
94
|
+
const apiKey = await resolveApiKey(api, providerId, provider, config);
|
|
95
|
+
const fetched = await fetchModels({
|
|
96
|
+
providerId,
|
|
97
|
+
provider,
|
|
98
|
+
apiKey,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
provider,
|
|
102
|
+
fetched,
|
|
103
|
+
fetchedAt: now().toISOString(),
|
|
104
|
+
config,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function computePlan(providerId) {
|
|
108
|
+
const { provider, fetched, fetchedAt } = await fetchModelsForProvider(providerId);
|
|
109
|
+
const filter = savedFilter(providerId);
|
|
110
|
+
selectFetchedModels(fetched, filter);
|
|
111
|
+
const existing = provider.models ?? [];
|
|
112
|
+
const selected = selectFetchedModels(fetched, filter);
|
|
113
|
+
const merge = mergeModels({ existing, selected, filter });
|
|
114
|
+
const existingIds = existing.map((model) => model.id);
|
|
115
|
+
const finalIds = new Set(merge.models.map((model) => model.id));
|
|
116
|
+
const existingSet = new Set(existingIds);
|
|
117
|
+
const removedIds = existingIds.filter((id) => !finalIds.has(id));
|
|
118
|
+
const addedIds = merge.models
|
|
119
|
+
.filter((model) => !existingSet.has(model.id))
|
|
120
|
+
.map((model) => model.id);
|
|
121
|
+
const models = fetched.map(toModelView);
|
|
122
|
+
const visibleIds = new Set(models.map((model) => model.id));
|
|
123
|
+
const manualIds = new Set(filter.manualIds ?? []);
|
|
124
|
+
for (const model of existing) {
|
|
125
|
+
if (manualIds.has(model.id) && !visibleIds.has(model.id)) {
|
|
126
|
+
models.push(toModelView(model));
|
|
127
|
+
visibleIds.add(model.id);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const fingerprint = planFingerprint({
|
|
131
|
+
providerId,
|
|
132
|
+
filter,
|
|
133
|
+
fetchedIds: fetched.map((model) => model.id),
|
|
134
|
+
existingIds,
|
|
135
|
+
selectedIds: merge.selectedIds,
|
|
136
|
+
addedIds,
|
|
137
|
+
removedIds,
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
providerId,
|
|
141
|
+
provider,
|
|
142
|
+
filter,
|
|
143
|
+
fetched,
|
|
144
|
+
fetchedAt,
|
|
145
|
+
existingIds,
|
|
146
|
+
addedIds,
|
|
147
|
+
removedIds,
|
|
148
|
+
selectedIds: merge.selectedIds,
|
|
149
|
+
unchangedCount: merge.unchanged,
|
|
150
|
+
models,
|
|
151
|
+
fingerprint,
|
|
152
|
+
finalModels: merge.models,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async function listProviders() {
|
|
156
|
+
const config = currentConfig();
|
|
157
|
+
const providers = config?.models?.providers ?? {};
|
|
158
|
+
const result = [];
|
|
159
|
+
const agentEntries = config?.agents?.entries ?? {};
|
|
160
|
+
const agents = Object.entries(agentEntries)
|
|
161
|
+
.filter(([agentId]) => typeof agentId === "string" && agentId.trim().length > 0)
|
|
162
|
+
.map(([agentId, entry]) => ({
|
|
163
|
+
id: agentId,
|
|
164
|
+
hasModelAllowlist: Array.isArray(entry?.modelPolicy?.allow) && entry.modelPolicy.allow.length > 0,
|
|
165
|
+
}))
|
|
166
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
167
|
+
for (const providerId of Object.keys(providers).sort((left, right) => left.localeCompare(right))) {
|
|
168
|
+
let provider;
|
|
169
|
+
try {
|
|
170
|
+
provider = getProvider(config, providerId);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
result.push({
|
|
176
|
+
id: providerId,
|
|
177
|
+
label: provider.name?.trim() || providerId,
|
|
178
|
+
api: provider.api?.trim() || "unknown",
|
|
179
|
+
baseUrl: provider.baseUrl,
|
|
180
|
+
configPath: configPath(providerId),
|
|
181
|
+
filter: savedFilter(providerId, config),
|
|
182
|
+
targetAgents: savedTargetAgents(providerId, config),
|
|
183
|
+
configuredModels: (provider.models ?? []).map(toModelView),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return { providers: result, agents };
|
|
187
|
+
}
|
|
188
|
+
async function fetchModelsForUi(providerId) {
|
|
189
|
+
const { fetched, fetchedAt } = await fetchModelsForProvider(providerId);
|
|
190
|
+
return {
|
|
191
|
+
provider: providerId,
|
|
192
|
+
fetchedAt,
|
|
193
|
+
models: fetched.map(toModelView),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async function saveStrategy({ provider, filter, targetAgents, }) {
|
|
197
|
+
const config = currentConfig();
|
|
198
|
+
getProvider(config, provider);
|
|
199
|
+
const nextFilter = normalizeFilter(filter);
|
|
200
|
+
selectFetchedModels([], nextFilter);
|
|
201
|
+
const nextTargetAgents = targetAgents === undefined
|
|
202
|
+
? savedTargetAgents(provider, config)
|
|
203
|
+
: normalizeTargetAgents(targetAgents);
|
|
204
|
+
const result = await runtime.config.mutateConfigFile({
|
|
205
|
+
base: "source",
|
|
206
|
+
afterWrite: { mode: "auto" },
|
|
207
|
+
mutate: (draft) => {
|
|
208
|
+
ensurePluginEntry(draft, provider, nextFilter, nextTargetAgents);
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
provider,
|
|
213
|
+
savedAt: now().toISOString(),
|
|
214
|
+
configPath: result.path,
|
|
215
|
+
filter: nextFilter,
|
|
216
|
+
targetAgents: nextTargetAgents,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async function previewApply(provider) {
|
|
220
|
+
const computed = await computePlan(provider);
|
|
221
|
+
const plan = {
|
|
222
|
+
fingerprint: computed.fingerprint,
|
|
223
|
+
fetchedAt: computed.fetchedAt,
|
|
224
|
+
fetchedCount: computed.fetched.length,
|
|
225
|
+
addedIds: computed.addedIds,
|
|
226
|
+
removedIds: computed.removedIds,
|
|
227
|
+
selectedIds: computed.selectedIds,
|
|
228
|
+
unchangedCount: computed.unchangedCount,
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
provider,
|
|
232
|
+
plan,
|
|
233
|
+
models: computed.models,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
async function applyStrategy({ provider, fingerprint, expectedRemovals, targetAgents, }) {
|
|
237
|
+
const computed = await computePlan(provider);
|
|
238
|
+
if (computed.fingerprint !== fingerprint) {
|
|
239
|
+
throw new Error("模型列表或筛选策略已变化,请重新预览后再确认应用。");
|
|
240
|
+
}
|
|
241
|
+
if (!sameStringSets(computed.removedIds, expectedRemovals)) {
|
|
242
|
+
throw new Error("待删除模型与确认列表不一致,已取消写入。请重新预览。");
|
|
243
|
+
}
|
|
244
|
+
const nextTargetAgents = normalizeTargetAgents(targetAgents ?? savedTargetAgents(provider));
|
|
245
|
+
let syncedAgents = [];
|
|
246
|
+
const result = await runtime.config.mutateConfigFile({
|
|
247
|
+
base: "source",
|
|
248
|
+
afterWrite: { mode: "auto" },
|
|
249
|
+
mutate: (draft) => {
|
|
250
|
+
const config = draft;
|
|
251
|
+
const target = getProvider(config, provider);
|
|
252
|
+
const currentExistingIds = (target.models ?? []).map((model) => model.id);
|
|
253
|
+
if (!sameStringSets(currentExistingIds, computed.existingIds)) {
|
|
254
|
+
throw new Error("Provider 配置在确认后发生变化,已取消写入。请重新预览。");
|
|
255
|
+
}
|
|
256
|
+
const currentFilter = normalizeFilter(resolveProviderFilter(provider, config, factoryConfig));
|
|
257
|
+
if (JSON.stringify(currentFilter) !== JSON.stringify(computed.filter)) {
|
|
258
|
+
throw new Error("Provider 筛选策略在确认后发生变化,已取消写入。请重新预览。");
|
|
259
|
+
}
|
|
260
|
+
target.models = computed.finalModels;
|
|
261
|
+
ensurePluginEntry(config, provider, computed.filter, nextTargetAgents);
|
|
262
|
+
const syncResult = syncConfiguredModelPolicyAllow(config, provider, computed.finalModels, {
|
|
263
|
+
targetAgents: nextTargetAgents,
|
|
264
|
+
});
|
|
265
|
+
syncedAgents = syncResult.syncedAgents;
|
|
266
|
+
syncAgentModelEntries(config, provider, computed.finalModels, {
|
|
267
|
+
targetAgents: syncedAgents,
|
|
268
|
+
});
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
provider,
|
|
273
|
+
persisted: true,
|
|
274
|
+
configPath: result.path,
|
|
275
|
+
fetchedAt: computed.fetchedAt,
|
|
276
|
+
fetchedCount: computed.fetched.length,
|
|
277
|
+
added: computed.addedIds.length,
|
|
278
|
+
unchanged: computed.unchangedCount,
|
|
279
|
+
removed: computed.removedIds.length,
|
|
280
|
+
selectedIds: computed.selectedIds,
|
|
281
|
+
targetAgents: nextTargetAgents,
|
|
282
|
+
syncedAgents,
|
|
283
|
+
models: computed.models,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async function refreshProvider(params) {
|
|
287
|
+
return runModelFetch({
|
|
288
|
+
api,
|
|
289
|
+
factoryConfig,
|
|
290
|
+
fetchModels,
|
|
291
|
+
params,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
listProviders,
|
|
296
|
+
fetchModels: fetchModelsForUi,
|
|
297
|
+
saveStrategy,
|
|
298
|
+
previewApply,
|
|
299
|
+
applyStrategy,
|
|
300
|
+
refreshProvider,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
export function registerModelFetchOperations(api, options = {}) {
|
|
304
|
+
const operations = createModelFetchOperations({ api, ...options });
|
|
305
|
+
const handlers = {
|
|
306
|
+
"providers.list": () => operations.listProviders(),
|
|
307
|
+
"models.fetch": (input) => operations.fetchModels(input.provider),
|
|
308
|
+
"strategy.save": (input) => operations.saveStrategy(input),
|
|
309
|
+
"strategy.preview": (input) => operations.previewApply(input.provider),
|
|
310
|
+
"strategy.apply": (input) => operations.applyStrategy(input),
|
|
311
|
+
"provider.refresh": (input) => operations.refreshProvider(input),
|
|
312
|
+
};
|
|
313
|
+
for (const [id, operation] of Object.entries(modelFetchContract.operations)) {
|
|
314
|
+
api.session.controls.registerSessionAction({
|
|
315
|
+
id,
|
|
316
|
+
description: operation.description,
|
|
317
|
+
schema: operation.input,
|
|
318
|
+
requiredScopes: [operation.kind === "query" ? "operator.read" : "operator.write"],
|
|
319
|
+
handler: async (context) => {
|
|
320
|
+
const payload = context.payload ?? {};
|
|
321
|
+
if (!Value.Check(operation.input, payload)) {
|
|
322
|
+
return {
|
|
323
|
+
ok: false,
|
|
324
|
+
error: `Invalid payload for ${id}.`,
|
|
325
|
+
code: "INVALID_INPUT",
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
const handler = handlers[id];
|
|
330
|
+
if (!handler) {
|
|
331
|
+
return {
|
|
332
|
+
ok: false,
|
|
333
|
+
error: `Missing handler for ${id}.`,
|
|
334
|
+
code: "OPERATION_FAILED",
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
ok: true,
|
|
339
|
+
result: (await handler(payload)),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
return {
|
|
344
|
+
ok: false,
|
|
345
|
+
error: errorMessage(error),
|
|
346
|
+
code: "OPERATION_FAILED",
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
return operations;
|
|
353
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
2
|
+
export declare const modelFetchFilterSchema: Type.TObject<{
|
|
3
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
4
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
5
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
6
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
7
|
+
}>;
|
|
8
|
+
export type ModelFilterConfig = Static<typeof modelFetchFilterSchema>;
|
|
9
|
+
export declare const modelFetchConfigSchema: Type.TObject<{
|
|
10
|
+
providers: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
|
|
11
|
+
filter: Type.TOptional<Type.TObject<{
|
|
12
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
13
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
14
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
15
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
16
|
+
}>>;
|
|
17
|
+
targetAgents: Type.TOptional<Type.TArray<Type.TString>>;
|
|
18
|
+
}>>>;
|
|
19
|
+
}>;
|
|
20
|
+
export type ModelFetchConfig = Static<typeof modelFetchConfigSchema>;
|
|
21
|
+
export declare const modelFetchParameters: Type.TObject<{
|
|
22
|
+
provider: Type.TString;
|
|
23
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
24
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
25
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
26
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
27
|
+
dryRun: Type.TOptional<Type.TBoolean>;
|
|
28
|
+
}>;
|
|
29
|
+
export type ModelFetchParams = Static<typeof modelFetchParameters>;
|
|
30
|
+
export declare const modelFetchResultSchema: Type.TObject<{
|
|
31
|
+
provider: Type.TString;
|
|
32
|
+
fetched: Type.TInteger;
|
|
33
|
+
selected: Type.TArray<Type.TString>;
|
|
34
|
+
added: Type.TInteger;
|
|
35
|
+
unchanged: Type.TInteger;
|
|
36
|
+
removed: Type.TInteger;
|
|
37
|
+
replace: Type.TBoolean;
|
|
38
|
+
dryRun: Type.TBoolean;
|
|
39
|
+
configPath: Type.TString;
|
|
40
|
+
persisted: Type.TBoolean;
|
|
41
|
+
}>;
|
|
42
|
+
export type ModelFetchToolResult = Static<typeof modelFetchResultSchema>;
|
|
43
|
+
export declare const modelViewSchema: Type.TObject<{
|
|
44
|
+
id: Type.TString;
|
|
45
|
+
name: Type.TString;
|
|
46
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
47
|
+
}>;
|
|
48
|
+
export type ModelView = Static<typeof modelViewSchema>;
|
|
49
|
+
export declare const providerSummarySchema: Type.TObject<{
|
|
50
|
+
id: Type.TString;
|
|
51
|
+
label: Type.TString;
|
|
52
|
+
api: Type.TString;
|
|
53
|
+
baseUrl: Type.TString;
|
|
54
|
+
configPath: Type.TString;
|
|
55
|
+
filter: Type.TObject<{
|
|
56
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
57
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
58
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
59
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
60
|
+
}>;
|
|
61
|
+
targetAgents: Type.TArray<Type.TString>;
|
|
62
|
+
configuredModels: Type.TArray<Type.TObject<{
|
|
63
|
+
id: Type.TString;
|
|
64
|
+
name: Type.TString;
|
|
65
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
66
|
+
}>>;
|
|
67
|
+
}>;
|
|
68
|
+
export type ProviderSummary = Static<typeof providerSummarySchema>;
|
|
69
|
+
export declare const agentSummarySchema: Type.TObject<{
|
|
70
|
+
id: Type.TString;
|
|
71
|
+
hasModelAllowlist: Type.TBoolean;
|
|
72
|
+
}>;
|
|
73
|
+
export type AgentSummary = Static<typeof agentSummarySchema>;
|
|
74
|
+
declare const emptyInputSchema: Type.TObject<{}>;
|
|
75
|
+
declare const providerInputSchema: Type.TObject<{
|
|
76
|
+
provider: Type.TString;
|
|
77
|
+
}>;
|
|
78
|
+
export declare const listProvidersOutputSchema: Type.TObject<{
|
|
79
|
+
providers: Type.TArray<Type.TObject<{
|
|
80
|
+
id: Type.TString;
|
|
81
|
+
label: Type.TString;
|
|
82
|
+
api: Type.TString;
|
|
83
|
+
baseUrl: Type.TString;
|
|
84
|
+
configPath: Type.TString;
|
|
85
|
+
filter: Type.TObject<{
|
|
86
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
87
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
88
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
89
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
90
|
+
}>;
|
|
91
|
+
targetAgents: Type.TArray<Type.TString>;
|
|
92
|
+
configuredModels: Type.TArray<Type.TObject<{
|
|
93
|
+
id: Type.TString;
|
|
94
|
+
name: Type.TString;
|
|
95
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
96
|
+
}>>;
|
|
97
|
+
}>>;
|
|
98
|
+
agents: Type.TArray<Type.TObject<{
|
|
99
|
+
id: Type.TString;
|
|
100
|
+
hasModelAllowlist: Type.TBoolean;
|
|
101
|
+
}>>;
|
|
102
|
+
}>;
|
|
103
|
+
export type ListProvidersOutput = Static<typeof listProvidersOutputSchema>;
|
|
104
|
+
export declare const fetchModelsOutputSchema: Type.TObject<{
|
|
105
|
+
provider: Type.TString;
|
|
106
|
+
fetchedAt: Type.TString;
|
|
107
|
+
models: Type.TArray<Type.TObject<{
|
|
108
|
+
id: Type.TString;
|
|
109
|
+
name: Type.TString;
|
|
110
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
111
|
+
}>>;
|
|
112
|
+
}>;
|
|
113
|
+
export type FetchModelsOutput = Static<typeof fetchModelsOutputSchema>;
|
|
114
|
+
export declare const saveStrategyOutputSchema: Type.TObject<{
|
|
115
|
+
provider: Type.TString;
|
|
116
|
+
savedAt: Type.TString;
|
|
117
|
+
configPath: Type.TString;
|
|
118
|
+
filter: Type.TObject<{
|
|
119
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
120
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
121
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
122
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
123
|
+
}>;
|
|
124
|
+
targetAgents: Type.TArray<Type.TString>;
|
|
125
|
+
}>;
|
|
126
|
+
export type SaveStrategyOutput = Static<typeof saveStrategyOutputSchema>;
|
|
127
|
+
export declare const saveStrategyInputSchema: Type.TObject<{
|
|
128
|
+
provider: Type.TString;
|
|
129
|
+
filter: Type.TObject<{
|
|
130
|
+
includeRegex: Type.TOptional<Type.TString>;
|
|
131
|
+
excludeRegex: Type.TOptional<Type.TString>;
|
|
132
|
+
manualIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
133
|
+
replace: Type.TOptional<Type.TBoolean>;
|
|
134
|
+
}>;
|
|
135
|
+
targetAgents: Type.TOptional<Type.TArray<Type.TString>>;
|
|
136
|
+
}>;
|
|
137
|
+
export type SaveStrategyInput = Static<typeof saveStrategyInputSchema>;
|
|
138
|
+
export declare const applyPlanSchema: Type.TObject<{
|
|
139
|
+
fingerprint: Type.TString;
|
|
140
|
+
fetchedAt: Type.TString;
|
|
141
|
+
fetchedCount: Type.TInteger;
|
|
142
|
+
addedIds: Type.TArray<Type.TString>;
|
|
143
|
+
removedIds: Type.TArray<Type.TString>;
|
|
144
|
+
selectedIds: Type.TArray<Type.TString>;
|
|
145
|
+
unchangedCount: Type.TInteger;
|
|
146
|
+
}>;
|
|
147
|
+
export type ApplyPlan = Static<typeof applyPlanSchema>;
|
|
148
|
+
export declare const previewApplyOutputSchema: Type.TObject<{
|
|
149
|
+
provider: Type.TString;
|
|
150
|
+
plan: Type.TObject<{
|
|
151
|
+
fingerprint: Type.TString;
|
|
152
|
+
fetchedAt: Type.TString;
|
|
153
|
+
fetchedCount: Type.TInteger;
|
|
154
|
+
addedIds: Type.TArray<Type.TString>;
|
|
155
|
+
removedIds: Type.TArray<Type.TString>;
|
|
156
|
+
selectedIds: Type.TArray<Type.TString>;
|
|
157
|
+
unchangedCount: Type.TInteger;
|
|
158
|
+
}>;
|
|
159
|
+
models: Type.TArray<Type.TObject<{
|
|
160
|
+
id: Type.TString;
|
|
161
|
+
name: Type.TString;
|
|
162
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
163
|
+
}>>;
|
|
164
|
+
}>;
|
|
165
|
+
export type PreviewApplyOutput = Static<typeof previewApplyOutputSchema>;
|
|
166
|
+
export declare const applyStrategyInputSchema: Type.TObject<{
|
|
167
|
+
provider: Type.TString;
|
|
168
|
+
fingerprint: Type.TString;
|
|
169
|
+
expectedRemovals: Type.TArray<Type.TString>;
|
|
170
|
+
targetAgents: Type.TOptional<Type.TArray<Type.TString>>;
|
|
171
|
+
}>;
|
|
172
|
+
export type ApplyStrategyInput = Static<typeof applyStrategyInputSchema>;
|
|
173
|
+
export declare const applyStrategyOutputSchema: Type.TObject<{
|
|
174
|
+
provider: Type.TString;
|
|
175
|
+
persisted: Type.TBoolean;
|
|
176
|
+
configPath: Type.TString;
|
|
177
|
+
fetchedAt: Type.TString;
|
|
178
|
+
fetchedCount: Type.TInteger;
|
|
179
|
+
added: Type.TInteger;
|
|
180
|
+
unchanged: Type.TInteger;
|
|
181
|
+
removed: Type.TInteger;
|
|
182
|
+
selectedIds: Type.TArray<Type.TString>;
|
|
183
|
+
targetAgents: Type.TArray<Type.TString>;
|
|
184
|
+
syncedAgents: Type.TArray<Type.TString>;
|
|
185
|
+
models: Type.TArray<Type.TObject<{
|
|
186
|
+
id: Type.TString;
|
|
187
|
+
name: Type.TString;
|
|
188
|
+
contextWindow: Type.TOptional<Type.TInteger>;
|
|
189
|
+
}>>;
|
|
190
|
+
}>;
|
|
191
|
+
export type ApplyStrategyOutput = Static<typeof applyStrategyOutputSchema>;
|
|
192
|
+
export { emptyInputSchema, providerInputSchema };
|