import{Zs as e,c as t,nc as n,pu as r,r as i,v as a}from"./model-selection-p21GBPS6.js";import{F as o,r as s}from"./agent-scope-DW6ZDCxj.js";import{c}from"./session-key-D3P0tf5P.js";import{t as l}from"./command-format-BbDT1tlm.js";import{n as u}from"./issue-format-Cxp4tDjR.js";const d=e=>{if(e.json&&e.plain)throw Error(`Choose either --json or --plain, not both.`)},f=e=>!e||!Number.isFinite(e)?`-`:e<1024?`${Math.round(e)}`:`${Math.round(e/1024)}k`,p=e=>e==null||!Number.isFinite(e)?`-`:e<1e3?`${Math.round(e)}ms`:`${Math.round(e/100)/10}s`,m=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`::1`||t.endsWith(`.local`)}catch{return!1}};async function h(){let t=await e();if(!t.valid){let e=u(t.issues,`-`).join(`
`);throw Error(`Invalid config at ${t.path}\n${e}`)}return t.config}async function g(e){let t=e(await h());return await n(t),t}function _(e){let t=i({cfg:e.cfg,defaultProvider:r}),n=a({raw:e.raw,defaultProvider:r,aliasIndex:t});if(!n)throw Error(`Invalid model reference: ${e.raw}`);return n.ref}function v(e){let n=i({cfg:e.cfg,defaultProvider:r});return e.entries.map(e=>a({raw:e,defaultProvider:r,aliasIndex:n})).filter(e=>!!e).map(e=>t(e.ref.provider,e.ref.model))}function y(e){let t=e.trim();if(!t)throw Error(`Alias cannot be empty.`);if(!/^[A-Za-z0-9_.:-]+$/.test(t))throw Error(`Alias must use letters, numbers, dots, underscores, colons, or dashes.`);return t}function b(e){let t=e.rawAgentId?.trim();if(!t)return;let n=c(t);if(!s(e.cfg).includes(n))throw Error(`Unknown agent id "${t}". Use "${l(`openclaw agents list`)}" to see configured agents.`);return n}function x(e,t){let n={...e&&typeof e==`object`?e:void 0};return t.primary!==void 0&&(n.primary=t.primary),t.fallbacks!==void 0&&(n.fallbacks=t.fallbacks),n}function S(e){let t=_({raw:e.modelRaw,cfg:e.cfg}),n=`${t.provider}/${t.model}`,r={...e.cfg.agents?.defaults?.models};r[n]||(r[n]={});let i=e.cfg.agents?.defaults??{},a=o(i[e.field]);return{...e.cfg,agents:{...e.cfg.agents,defaults:{...i,[e.field]:x(a,{primary:n}),models:r}}}}const C=`openai-codex/gpt-5.4`;function w(e){let t=e?.trim();if(!t)return!0;let n=t.toLowerCase();return n.startsWith(`openai-codex/`)?!1:n.startsWith(`openai/`)?!0:n===`gpt`||n===`gpt-mini`}function T(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.primary==`string`)return e.primary}function E(e){return w(T(e.agents?.defaults?.model))?{next:{...e,agents:{...e.agents,defaults:{...e.agents?.defaults,model:e.agents?.defaults?.model&&typeof e.agents.defaults.model==`object`?{...e.agents.defaults.model,primary:C}:{primary:C}}}},changed:!0}:{next:e,changed:!1}}export{p as a,h as c,b as d,v as f,d as i,x as l,g as m,E as n,f as o,_ as p,S as r,m as s,C as t,y as u};
