import{Dq as Z,Fq as o,SM as N,TM as T,UM as m,VM as O,Wj as P,_j as a,aA as X,bA as h,cA as F,dA as f,mA as t,nA as s,tn as $,un as r,yN as e,yx as J,zx as c}from"./cli-0.5.3-jbzr8k4s.mjs";import"./cli-0.5.3-me9jkw92.mjs";import"./cli-0.5.3-bqmztzjc.mjs";import"./cli-0.5.3-ytqxzjff.mjs";import"./cli-0.5.3-h6n812td.mjs";import"./cli-0.5.3-hg8c6qbh.mjs";import"./cli-0.5.3-39jr2yrx.mjs";import"./cli-0.5.3-42e2paz8.mjs";import"./cli-0.5.3-mn45xfck.mjs";import"./cli-0.5.3-m884a3pk.mjs";import"./cli-0.5.3-4f9xxrem.mjs";import"./cli-0.5.3-gr8nsa2k.mjs";import"./cli-0.5.3-yj9nbd9d.mjs";import"./cli-0.5.3-55kd38ff.mjs";import"./cli-0.5.3-e6bjcfwg.mjs";import"./cli-0.5.3-4dbxtwh3.mjs";import"./cli-0.5.3-m0kfmb79.mjs";import"./cli-0.5.3-8zq9vdtg.mjs";import"./cli-0.5.3-vmx7agj7.mjs";import"./cli-0.5.3-h8xs2818.mjs";import"./cli-0.5.3-wcx7cnw5.mjs";import"./cli-0.5.3-9zbakvbf.mjs";import"./cli-0.5.3-hx550gz2.mjs";import{IW as I,nX as p,pV as S}from"./cli-0.5.3-842pf3t4.mjs";import"./cli-0.5.3-wxead1ct.mjs";import"./cli-0.5.3-s1hz35ye.mjs";import"./cli-0.5.3-g0svn6bx.mjs";import"./cli-0.5.3-sfdh3pkx.mjs";import"./cli-0.5.3-d8tjnxcj.mjs";import"./cli-0.5.3-6zfw1732.mjs";import"./cli-0.5.3-ptjdgcsy.mjs";import"./cli-0.5.3-tp3jye12.mjs";import{MY as w,NY as H,OY as R,PY as E}from"./cli-0.5.3-vqmxwet2.mjs";import"./cli-0.5.3-rch86nhn.mjs";import"./cli-0.5.3-zg2apr51.mjs";import"./cli-0.5.3-ngnshpb7.mjs";import"./cli-0.5.3-e58xste9.mjs";import"./cli-0.5.3-6163zevg.mjs";import"./cli-0.5.3-jmkkd5ph.mjs";import"./cli-0.5.3-1vt6twff.mjs";import"./cli-0.5.3-7017ez65.mjs";import"./cli-0.5.3-ea94acj4.mjs";import"./cli-0.5.3-3k22nqvy.mjs";import"./cli-0.5.3-63q4g3zt.mjs";import"./cli-0.5.3-dyhbm5kp.mjs";import"./cli-0.5.3-vpcrbd8n.mjs";import"./cli-0.5.3-jdw3ajfv.mjs";import"./cli-0.5.3-qg4a557t.mjs";import{H$ as B,R$ as i}from"./cli-0.5.3-t65dek0m.mjs";import"./cli-0.5.3-kavpx97n.mjs";import"./cli-0.5.3-9bdwhdys.mjs";import"./cli-0.5.3-ttc72eq3.mjs";import"./cli-0.5.3-g75gdzrp.mjs";import"./cli-0.5.3-1rg2r7n7.mjs";import"./cli-0.5.3-6j2jk6dt.mjs";import"./cli-0.5.3-66650sba.mjs";import{Lea as U,Nea as n}from"./cli-0.5.3-9vh3vpap.mjs";import"./cli-0.5.3-n3cxyxpg.mjs";import"./cli-0.5.3-kbvzmaax.mjs";import"./cli-0.5.3-7wdgps7z.mjs";import{Ega as v,Lga as l,zga as j}from"./cli-0.5.3-c8bcrqa4.mjs";import"./cli-0.5.3-qrvd6cmy.mjs";import"./cli-0.5.3-2dk1sk8w.mjs";import{Tma as u,Uma as g}from"./cli-0.5.3-0df3r78b.mjs";import{randomUUID as qq}from"crypto";p();f();c();h();E();var C=u(S(),1);function k(L){let q=C.c(8),{input:V,progress:A,verbose:K}=L,Y=`<bash-input>${V}</bash-input>`,G;if(q[0]!==Y)G=H(J,{addMargin:!1,param:{text:Y,type:"text"}}),q[0]=Y,q[1]=G;else G=q[1];let z;if(q[2]!==A||q[3]!==K)z=A?H(X,{fullOutput:A.fullOutput,output:A.output,elapsedTimeSeconds:A.elapsedTimeSeconds,totalLines:A.totalLines,verbose:K}):F.renderToolUseProgressMessage?.([],{verbose:K,tools:[],terminalSize:void 0}),q[2]=A,q[3]=K,q[4]=z;else z=q[4];let Q;if(q[5]!==G||q[6]!==z)Q=R(I,{flexDirection:"column",marginTop:1,children:[G,z]}),q[5]=G,q[6]=z,q[7]=Q;else Q=q[7];return Q}f();n();l();e();i();function b(){return B().defaultShell??"bash"}r();a();o();E();async function yq(L,q,V,A,K){let Y=$()&&b()==="powershell";U("tengu_input_bash",{powershell:Y});let G=N({content:T({inputString:`<bash-input>${L}</bash-input>`,precedingInputBlocks:q})}),H;K({jsx:H(k,{input:L,progress:null,verbose:A.options.verbose}),shouldHidePromptInput:!1});try{let z={...A,setToolJSX:(_)=>{H=_?.jsx}},Q=(_)=>{K({jsx:R(w,{children:[H(k,{input:L,progress:_.data,verbose:A.options.verbose}),H]}),shouldHidePromptInput:!1,showSpinner:!1})},D=null;if(Y)D=(s(),g(t)).PowerShellTool;let x=D??F,W=(D?await D.call({command:L,dangerouslyDisableSandbox:!0,_dangerouslyDisableSandboxApproved:!0},z,void 0,void 0,Q):await F.call({command:L,dangerouslyDisableSandbox:!0,_dangerouslyDisableSandboxApproved:!0},z,void 0,void 0,Q)).data;if(!W)throw Error("No result received from shell command");let d=W.stderr,y=await P(x,{...W,stderr:""},qq()),M=typeof y.content==="string"?y.content:Z(W.stdout);return{messages:[O(),G,...V,N({content:`<bash-stdout>${M}</bash-stdout><bash-stderr>${Z(d)}</bash-stderr>`})],shouldQuery:!1}}catch(z){if(z instanceof j){if(z.interrupted)return{messages:[O(),G,m({toolUse:!1}),...V],shouldQuery:!1};return{messages:[O(),G,...V,N({content:`<bash-stdout>${Z(z.stdout)}</bash-stdout><bash-stderr>${Z(z.stderr)}</bash-stderr>`})],shouldQuery:!1}}return{messages:[O(),G,...V,N({content:`<bash-stderr>Command failed: ${Z(v(z))}</bash-stderr>`})],shouldQuery:!1}}finally{K(null)}}export{yq as processBashCommand};
