import{w5 as L,x5 as H}from"./chunks/cli-0.5.4-jsjj39yb.mjs";import{$ba as $,Xba as _,aca as j,eca as B,hca as q,kca as G,nca as C}from"./chunks/cli-0.5.4-cbq01zg3.mjs";import"./chunks/cli-0.5.4-37v5fhf1.mjs";import"./chunks/cli-0.5.4-7grzwf6q.mjs";import"./chunks/cli-0.5.4-9qmek5dq.mjs";import"./chunks/cli-0.5.4-9c6r1fjg.mjs";import"./chunks/cli-0.5.4-2dw33ms6.mjs";import"./chunks/cli-0.5.4-x1fzfxmm.mjs";import"./chunks/cli-0.5.4-e822fzaq.mjs";import"./chunks/cli-0.5.4-09dvrzcr.mjs";import"./chunks/cli-0.5.4-end8wj9r.mjs";import"./chunks/cli-0.5.4-4x206j04.mjs";import{ega as Z,mga as F}from"./chunks/cli-0.5.4-yd3rd9qt.mjs";import"./chunks/cli-0.5.4-sgcaw17t.mjs";import"./chunks/cli-0.5.4-jmc3bzbn.mjs";import"./chunks/cli-0.5.4-959vxhhb.mjs";import{_ma as J}from"./chunks/cli-0.5.4-aacw1src.mjs";C();q();F();H();var V=["ghp_","gho_","ghs_","ghr_","github_pat_"];function W(A,K="copilot"){if(V.some((w)=>A.startsWith(w))){if(K==="copilot")return"expired";return"valid"}let D=A.match(/exp=(\d+)/);if(D){let w=Number(D[1]);if(!Number.isNaN(w))return Date.now()>=w*1000?"expired":"valid"}let O=A.split(".");if(O.length===3&&O.every((w)=>/^[A-Za-z0-9_-]+$/.test(w)))try{let w=O[1].replace(/-/g,"+").replace(/_/g,"/"),N=w+"=".repeat((4-w.length%4)%4),U=Buffer.from(N,"base64").toString("utf8"),R=JSON.parse(U);if(R&&typeof R==="object"&&R.exp)return Date.now()>=R.exp*1000?"expired":"valid"}catch{return"invalid_format"}return"valid"}async function b(A,K){let D=G();if(!D)return null;if(D.transport==="gemini"){if((await(K?.resolveGeminiCredential??L)(process.env)).kind==="none")return"Configure Gemini auth via /provider — pick API key, access token, or rely on Google ADC.";return null}if(D.transport==="github_copilot"){let Q=D.extras?.githubToken?.trim()||D.apiKey?.trim()||"";if(!Q)return`GitHub Copilot authentication required.
Run /provider and choose GitHub Copilot.`;let w=$(D.baseUrl),N=W(Q,w);if(N==="expired")return`GitHub Copilot token has expired.
Run /provider and choose GitHub Copilot.`;if(N==="invalid_format")return`GitHub Copilot token is invalid or corrupted.
Run /provider and choose GitHub Copilot.`;return null}if(D.transport!=="openai_compat"&&D.transport!=="codex_responses")return null;let O=j({model:D.model,baseUrl:D.baseUrl});if(D.apiKey==="SUA_CHAVE")return"Invalid API key: placeholder value SUA_CHAVE detected. Set a real key in /provider, or leave blank for local providers.";if(O.transport==="codex_responses"){let Q=B();if(!Q.apiKey){let w=Z()?"":", choose Codex OAuth in /provider",N=Q.authPath?`${w} or put auth.json at ${Q.authPath}`:w;return`Codex auth is required for ${O.requestedModel}. Configure it via /provider${N}.`}if(!Q.accountId)return"Codex auth is missing chatgpt_account_id. Re-login with Codex OAuth via /provider, or import an auth.json with chatgpt_account_id.";return null}if(!D.apiKey&&!_(O.baseUrl))return"API key required for the active /provider profile. Run /provider to set it.";return null}function I(A={}){let K=A.args??process.argv.slice(2);if(!(A.stdoutIsTTY??process.stdout.isTTY))return!0;return K.includes("-p")||K.includes("--print")||K.includes("--init-only")||K.some((O)=>O.startsWith("--sdk-url"))}async function z(A=process.env,K){let D=await b(A);if(!D)return;if(I(K))console.error(D),process.exit(1);console.error(`Warning: provider configuration is incomplete.
${D}
Claudio will continue starting so you can run /provider and repair the saved provider settings.`)}if(typeof globalThis.File>"u")try{let{File:A}=J("node:buffer");globalThis.File=A}catch{globalThis.File=class extends Blob{name;lastModified;constructor(K,D,O){super(K,O);this.name=D,this.lastModified=O?.lastModified??Date.now()}}}if(typeof Promise.withResolvers!=="function")Promise.withResolvers=function(){let K=()=>{},D=()=>{};return{promise:new Promise((Q,w)=>{K=Q,D=w}),resolve:K,reject:D}};{let A=J("node:util");if(typeof A.markAsUncloneable!=="function")A.markAsUncloneable=()=>{}}process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS??="true";process.env.CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING??="1";process.env.COREPACK_ENABLE_AUTO_PIN="0";if(process.env.CLAUDE_CODE_REMOTE==="true"){let A=process.env.NODE_OPTIONS||"";process.env.NODE_OPTIONS=A?`${A} --max-old-space-size=8192`:"--max-old-space-size=8192"}async function P(){let A=process.argv.slice(2);if(A.length===1&&(A[0]==="--version"||A[0]==="-v"||A[0]==="-V")){console.log("0.5.4 (Claudio)");return}if(A.includes("--provider"))console.error('The --provider CLI flag was removed. Run "claudio" and use /provider to choose a profile.'),process.exit(1);{let{enableConfigs:w}=await import("./chunks/config-0.5.4-xpmr28j4.mjs");w()}{let{applySafeConfigEnvironmentVariables:w}=await import("./chunks/managedEnv-0.5.4-49q9ar1e.mjs");w()}(async()=>{let{runStartupUpdateCheck:w}=await import("./chunks/startupUpdateCheck-0.5.4-x1gcw215.mjs");await w(A)})();{let{hydrateGithubModelsTokenFromSecureStorage:w,refreshGithubModelsTokenIfNeeded:N}=await import("./chunks/githubModelsCredentials-0.5.4-1nr586ra.mjs");await N(),w()}await z();let{tryGetActiveProvider:K}=await import("./chunks/activeProvider-0.5.4-rtxteb40.mjs");if(K()&&process.stdout.isTTY&&process.env.CLAUDIO_CLEAR_ON_START==="1"){let{clearTerminal:w}=await import("./chunks/clearTerminal-0.5.4-q2kd7xes.mjs");process.stdout.write(w)}let{profileCheckpoint:D}=await import("./chunks/startupProfiler-0.5.4-ctegmvbt.mjs");if(D("cli_entry"),A[0]==="--dump-system-prompt"){D("cli_dump_system_prompt_path");let{enableConfigs:w}=await import("./chunks/config-0.5.4-xpmr28j4.mjs");w();let{getMainLoopModel:N}=await import("./chunks/model-0.5.4-ehf5bg0a.mjs"),U=A.indexOf("--model"),R=U!==-1&&A[U+1]||N(),{getSystemPrompt:X}=await import("./chunks/prompts-0.5.4-sryw017m.mjs"),Y=await X([],R);console.log(Y.join(`
`));return}if(!1)switch(A[0]){case"ps":case"logs":case"attach":case"kill":default:}if((A.includes("--tmux")||A.includes("--tmux=classic"))&&(A.includes("-w")||A.includes("--worktree")||A.some((w)=>w.startsWith("--worktree=")))){D("cli_tmux_worktree_fast_path");let{enableConfigs:w}=await import("./chunks/config-0.5.4-xpmr28j4.mjs");w();let{isWorktreeModeEnabled:N}=await import("./chunks/worktreeModeEnabled-0.5.4-gvxty20d.mjs");if(N()){let{execIntoTmuxWorktree:U}=await import("./chunks/worktree-0.5.4-t28e8t53.mjs"),R=await U(A);if(R.handled)return;if(R.error){let{exitWithError:X}=await import("./chunks/process-0.5.4-tn8nvh06.mjs");X(R.error)}}}if(A.length===1&&(A[0]==="--update"||A[0]==="--upgrade"))process.argv=[process.argv[0],process.argv[1],"update"];if(A.includes("--bare"))process.env.CLAUDE_CODE_SIMPLE="1";if(process.env.CLAUDIO_DISABLE_EARLY_INPUT!=="1"){let{startCapturingEarlyInput:w}=await import("./chunks/earlyInput-0.5.4-q3y1fv9b.mjs");w()}D("cli_before_main_import");let{main:Q}=await import("./chunks/main-0.5.4-k6xm0aqm.mjs");D("cli_after_main_import"),await Q(),D("cli_after_main_complete")}P();
