/** User image controls are execution constraints, separate from the planning model. */ export type AgentImageParameters = { aspectRatio?: string; imageSize?: string; imageCount?: number; n?: number; quality?: "auto" | "low" | "medium" | "high"; size?: string; negativePrompt?: string; promptExtend?: boolean; watermark?: boolean; seed?: number; }; export type AgentImagePreferences = { modelId?: string; parameters?: AgentImageParameters }; export function applyAgentImagePreferences>( input: T, preferences?: AgentImagePreferences, ): T & AgentImageParameters & { modelId?: string } { const parameters = Object.fromEntries(Object.entries(preferences?.parameters || {}) .filter(([, value]) => value !== undefined)); const count = preferences?.parameters?.imageCount ?? preferences?.parameters?.n; return { ...input, ...parameters, ...(count !== undefined ? { imageCount: count } : {}), ...(preferences?.modelId ? { modelId: preferences.modelId } : {}), }; } export function agentProviderImageParameters(parameters: AgentImageParameters) { return Object.fromEntries(["quality", "size", "watermark", "seed"].flatMap(key => { const value = parameters[key as keyof AgentImageParameters]; return value !== undefined ? [[key, value]] : []; })); }