fix: reject executable pi configuration

This commit is contained in:
2026-08-05 04:49:19 +02:00
parent 6b828288e3
commit 2703864572
9 changed files with 479 additions and 56 deletions
+10
View File
@@ -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