/** * Approval for the per-call `model` selector on task items, eval `agent()` and * `workpool()`. * * A model-facing selector may only pick a chat model the operator already * names: a configured chat role's value, the selected agent's own frontmatter * model (only when that agent is bundled or user-level), or the parent's live * model. Glob values route roles as usual but never grant. Grants come from * {@link Settings.grantAuthority}, which * leaves out project settings: a repository's files are writable by the agent, * so they and subagent-injected settings can only narrow the result (allowlist, * disabled agents). Catalog membership, credentials, built-in role defaults, * project agent frontmatter, other agents' frontmatter and saved transcripts * grant nothing. `task.perCallModelAllow`, when set, narrows the result to the * exact models it lists. */ import type { Api, Model } from "@oh-my-pi/pi-ai"; import type { AgentSource } from "@oh-my-pi/pi-tui/tools/task"; import type { ModelRegistry } from "../config/model-registry.js"; import { type ModelMatchPreferences } from "../config/model-resolver.js"; import type { Settings } from "../config/settings.js"; /** A per-call model request could not be dispatched or restored. */ export declare class PerCallModelError extends Error { constructor(message: string); } /** The per-call model is not an available chat model, so no grant applies. */ export declare class PerCallModelUnavailableError extends PerCallModelError { constructor(message: string); } /** * Inputs that grant per-call models; nothing here is persisted as a grant. `settings` is read live, * so configuration changes apply to the next request: its grant authority grants, while its own * merged view (project and subagent-injected layers included) can only narrow. Spawn snapshots the * agent, parent model and match preferences; cold revival snapshots the agent and preferences but * reads the live parent on each request. */ export interface PerCallModelGrants { settings: Settings; agentName: string; agentSource?: AgentSource; /** The selected agent's frontmatter `model`. */ agentModel?: string | string[]; /** The selected agent is no longer discovered (cold revival): its frontmatter grants nothing. */ agentRemoved?: boolean; /** The parent's model at spawn, or its live model on each cold-revival request, including any `@upstream` pin. */ parentModelPattern?: string; /** Spawn-time selector preferences; unrelated later model usage cannot change a grant. */ matchPreferences?: ModelMatchPreferences; } type ApprovalRegistry = Pick; /** A parent only grants a route that an exact selector can represent without discarding routing policy. */ export declare function parentModelGrantPattern(model: Model): string | undefined; /** Operator-owned grant selectors, with bare role values resolved to exact selectors when a registry is supplied. */ export interface PerCallModelAdvertisement { roles: { role: string; patterns: string[]; }[]; allowlist: string[]; /** * True when the caller's live model cannot be written as one selector, or a non-empty allowlist does not list it, * so the own-model clause would name a model dispatch refuses. */ parentModelWithheld: boolean; } /** * Prompt data: only operator-owned settings grant; they and the live (project or subagent-injected) * settings narrow the advertised selectors. Reused until the settings or catalog change. */ export declare function getPerCallModelAdvertisement(settings: Settings, parentModel?: Model, registry?: ApprovalRegistry): PerCallModelAdvertisement; /** Throw {@link PerCallModelError} unless `model` is an available chat model the configuration approves. */ export declare function assertPerCallModelApproved(model: Model, grants: PerCallModelGrants, registry: ApprovalRegistry): void; export {};