import type { FsPort } from "../platform/fs"; import type { UiPort } from "../platform/ports"; export const CONFIG_DIR_NAME = ".pi"; export type Scope = "global" | "project"; export interface ModelParts { provider: string; modelId: string; } export interface ProbePolicy { earlyDiscriminationProbe: boolean; mode: "fixed"; intervalMin: number; maxProbes: number; silent: boolean; resetMarginSec: number; outageIntervalMin: number; maxOutageProbes: number; } export interface ReviewPolicy { flagShellActivity: boolean; } export interface EffectivePolicy { probe: ProbePolicy; review: ReviewPolicy; } export type PolicyPatch = { probe?: Partial; review?: Partial }; /** OD-1 canonical config value: an ordered list of tier-1 substitutes plus at most one tier-2 assistant. */ export interface CandidateSet { readonly substitutes: readonly string[]; readonly assistant?: string; } /** OD-1 accepted input sugar: a bare string or a bare array normalize to a substitutes-only set; the * object form is canonical. Sugar is normalized exactly once, inside `validateSource`. */ export type CandidateSetInput = string | readonly string[] | { readonly substitutes?: readonly string[]; readonly assistant?: string }; export interface ConfigSnapshot { readonly version: 1; readonly fallbacks: Readonly>; readonly policy: EffectivePolicy; } export interface ValidatedSource { fallbacks: Record; policy: PolicyPatch; } export interface ConfigPaths { global: string; project: string; } export interface ConfigError { scope: Scope; path: string; message: string; } export interface LoadOptions { cwd: string; homeDir?: string; fs: FsPort; ui?: Pick; } export interface LoadResult { config: ConfigSnapshot; errors: readonly ConfigError[]; paths: ConfigPaths; } export interface WriteResult { ok: boolean; config: ConfigSnapshot; error?: string; }