Main entry point: - create-hooks.ts, create-tools.ts, create-managers.ts - plugin-interface.ts: plugin interface types - plugin/ directory: plugin lifecycle modules Config handler: - agent-config-handler.ts, command-config-handler.ts - tool-config-handler.ts, mcp-config-handler.ts - provider-config-handler.ts, category-config-resolver.ts - agent-priority-order.ts, prometheus-agent-config-builder.ts - plugin-components-loader.ts
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { ModelCacheState } from "../plugin-state";
|
|
|
|
type ProviderConfig = {
|
|
options?: { headers?: Record<string, string> };
|
|
models?: Record<string, { limit?: { context?: number } }>;
|
|
};
|
|
|
|
export function applyProviderConfig(params: {
|
|
config: Record<string, unknown>;
|
|
modelCacheState: ModelCacheState;
|
|
}): void {
|
|
const providers = params.config.provider as
|
|
| Record<string, ProviderConfig>
|
|
| undefined;
|
|
|
|
const anthropicBeta = providers?.anthropic?.options?.headers?.["anthropic-beta"];
|
|
params.modelCacheState.anthropicContext1MEnabled =
|
|
anthropicBeta?.includes("context-1m") ?? false;
|
|
|
|
if (!providers) return;
|
|
|
|
for (const [providerID, providerConfig] of Object.entries(providers)) {
|
|
const models = providerConfig?.models;
|
|
if (!models) continue;
|
|
|
|
for (const [modelID, modelConfig] of Object.entries(models)) {
|
|
const contextLimit = modelConfig?.limit?.context;
|
|
if (!contextLimit) continue;
|
|
|
|
params.modelCacheState.modelContextLimitsCache.set(
|
|
`${providerID}/${modelID}`,
|
|
contextLimit,
|
|
);
|
|
}
|
|
}
|
|
}
|