import type { ModelInfo as AvailableModelInfo } from "../../shared/model-info.ts"; import type { Usage } from "../../shared/types.ts"; import { type ModelScopeConfig, type ModelScopeViolation, type ModelSource } from "./model-scope.ts"; export type { AvailableModelInfo }; interface ModelAttemptSummary { model: string; success: boolean; exitCode?: number | null; error?: string; usage?: Usage; } export declare function splitThinkingSuffix(model: string): { baseModel: string; thinkingSuffix: string; }; /** Sentinel model value requesting that a subagent inherit the parent session's model. */ export declare const INHERIT_MODEL = "inherit"; /** Minimal shape of the parent session's in-memory model (`ctx.model`). */ export interface ParentModel { provider: string; id: string; } export declare function normalizeParentModel(model: unknown): ParentModel | undefined; /** * Normalize a model id or provider segment for fuzzy comparison: case-fold, * treat dots/underscores as dashes (so `4.5` matches `4-5`), and collapse * repeated separators. Pure. */ export declare function normalizeModelSegment(segment: string): string; /** * Fuzzy-resolve a base model id (thinking suffix already stripped) against the * registry, tolerating separator, case, and optional date-stamp differences so * users do not have to spell provider/model exactly. A qualified `provider/id` * query only matches within the named provider — this never silently switches * providers for security/cost-sensitive configs. Returns the matched `fullId`, * or `undefined` when there is no match or the match is ambiguous across * providers (and no `preferredProvider` disambiguates). Pure. */ export declare function fuzzyResolveModel(baseModel: string, availableModels: AvailableModelInfo[], preferredProvider?: string): string | undefined; /** * Resolve a possibly-loose model id to a canonical `provider/id` (plus any * thinking suffix). Exact registry matches win; fuzzy normalization * (separator/case/date-stamp via {@link fuzzyResolveModel}) is a fallback so * spelling differences still resolve. Never switches providers for a qualified * query. Pure. */ export declare function resolveModelCandidate(model: string | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string): string | undefined; export interface ResolveSubagentModelOverrideOptions { /** When set with `enforce: true`, out-of-scope models are rejected. */ scope?: ModelScopeConfig; /** Origin of the requested model: explicit caller-supplied (hard error) vs inherited (warn). Defaults to `"inherited"`. */ source?: ModelSource; /** Called for warn-severity violations instead of `console.warn`. */ onWarn?: (violation: ModelScopeViolation) => void; } /** * Resolve the `--model` override passed to a spawned subagent. * * When no model is requested (`undefined`, `false`, empty, or the `"inherit"` * sentinel), the child must inherit the parent session's *in-memory* model * (`provider/id`) instead of being left to resolve its own model. Without an * explicit `provider/id`, the child falls back to the global * `~/.pi/agent/settings.json` default, which is shared across every open PI * session — so a different session that last changed its model in the TUI would * silently contaminate this session's subagents (see issue #266). Passing an * explicit `provider/id` keeps each session's children isolated to that * session's model. * * An explicitly requested model string is resolved via {@link resolveModelCandidate}. * When `options.scope.enforce` is on, an out-of-scope resolved model throws for * an explicit (`source: "explicit"`) request and warns for an inherited one. */ export declare function resolveSubagentModelOverride(requestedModel: string | boolean | undefined, parentModel: ParentModel | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string, options?: ResolveSubagentModelOverrideOptions): string | undefined; export declare function resolveEffectiveSubagentModel(explicitModel: string | boolean | undefined, agentModel: string | boolean | undefined, parentModel: ParentModel | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string, options?: Omit): string | undefined; export interface BuildModelCandidatesOptions { /** Fallback models are inherited agent config and warn, rather than error, when out of scope. */ scope?: ModelScopeConfig; onWarn?: (violation: ModelScopeViolation) => void; } export declare function buildModelCandidates(primaryModel: string | undefined, fallbackModels: string[] | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string, options?: BuildModelCandidatesOptions): string[]; export declare function isRetryableModelFailure(error: string | undefined): boolean; export declare function formatModelAttemptNote(attempt: ModelAttemptSummary, nextModel?: string): string; //# sourceMappingURL=model-fallback.d.ts.map