fix: reject executable pi configuration
This commit is contained in:
@@ -6,6 +6,10 @@ import {
|
||||
loadPiEnabledModels,
|
||||
type PiEnabledModelsResult,
|
||||
} from "./enabled-models.js";
|
||||
import {
|
||||
readConfiguredPiAgentFile,
|
||||
validateDeclarativePiConfig,
|
||||
} from "./managed-config.js";
|
||||
|
||||
export interface PiModel {
|
||||
provider: string;
|
||||
@@ -23,6 +27,7 @@ interface Opts {
|
||||
ttlMs?: number;
|
||||
nowMs?: () => number;
|
||||
loadEnabledModels?: () => PiEnabledModelsResult;
|
||||
readModelsStore?: () => string | undefined;
|
||||
warn?: (message: string) => void;
|
||||
}
|
||||
|
||||
@@ -39,6 +44,11 @@ export function createPiModelLister(cfg: AppConfig, opts: Opts = {}): () => Prom
|
||||
let cache: { at: number; models: PiModel[] } | null = null;
|
||||
|
||||
return async function listModels(): Promise<PiModel[]> {
|
||||
const managedModels = opts.readModelsStore
|
||||
? opts.readModelsStore()
|
||||
: readConfiguredPiAgentFile("models.json", true);
|
||||
if (managedModels !== undefined) validateDeclarativePiConfig(managedModels);
|
||||
|
||||
if (cache && now() - cache.at < ttlMs) return cache.models;
|
||||
|
||||
const enabled = (opts.loadEnabledModels
|
||||
|
||||
Reference in New Issue
Block a user