import{c as e,l as t}from"./errors-pXKbCKbL.js";import{l as n,o as r}from"./fsStore-BzLA1cBc.js";import{t as i}from"./base-xqced3zT.js";var a=class extends i{toolId=`codex`;async list(t){if(!this.validateScope(t))throw new e(t);let n=this.resolvePath(t),r=this.readConfig(n);return{type:`entries`,entries:this.#e(r),filePath:n}}resolvePath(e){switch(e){case`user`:return`~/.codex/config.toml`;default:throw Error(`Unsupported scope for Codex: ${e}`)}}validateScope(e){return e===`user`}async switchProfile(n,r,i){if(!this.validateScope(n))throw new e(n);let a=this.resolvePath(n),s=this.readConfig(a),c=s.profiles,l=o(c)?c:void 0;if(!l||!(r in l))throw new t(r);let u=l[r];if(!o(u))throw new t(r);let d=u,f={...s};for(let[e,t]of Object.entries(d))f[e]=t;return f.current_profile=r,this.writeConfig(a,f),{success:!0,message:`Switched to profile: ${r}`,filePath:a}}readConfig(e){return r(e)}writeConfig(e,t){n(e,t)}#e(e){let t=e.model_providers;return o(t)?t:{}}};const o=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date);export{a as t};