import{AN as e,Ax as J,Bx as c,Fq as Z,Hq as o,UM as N,VM as T,WM as m,XM as O,Yj as P,ak as a,cA as X,dA as h,eA as F,fA as f,oA as t,pA as s,vn as $,wn as r}from"./cli-0.5.4-k5fz4zd3.mjs";import"./cli-0.5.4-wbqf44ym.mjs";import"./cli-0.5.4-9ewg9gfs.mjs";import"./cli-0.5.4-we3mspgg.mjs";import"./cli-0.5.4-jzhazry0.mjs";import"./cli-0.5.4-82sw3hrw.mjs";import"./cli-0.5.4-31v143kt.mjs";import"./cli-0.5.4-1cy7wd6s.mjs";import"./cli-0.5.4-5e0pk96f.mjs";import"./cli-0.5.4-z154a7bp.mjs";import"./cli-0.5.4-ng5p0zjs.mjs";import"./cli-0.5.4-5hp7ks3t.mjs";import"./cli-0.5.4-8hdwp78f.mjs";import"./cli-0.5.4-mr9aznxx.mjs";import"./cli-0.5.4-jevfk5q7.mjs";import"./cli-0.5.4-27dzbzdy.mjs";import"./cli-0.5.4-a5bkdqqb.mjs";import"./cli-0.5.4-j2hnw539.mjs";import"./cli-0.5.4-9w59nnw4.mjs";import"./cli-0.5.4-z5d3q8kh.mjs";import"./cli-0.5.4-c0r12dqp.mjs";import"./cli-0.5.4-kqh172jk.mjs";import"./cli-0.5.4-vv4jbgkc.mjs";import{KW as I,pX as p,rV as S}from"./cli-0.5.4-s7k1f0wc.mjs";import"./cli-0.5.4-0h0yz2k5.mjs";import"./cli-0.5.4-942dm5q1.mjs";import"./cli-0.5.4-rcmp5h4y.mjs";import"./cli-0.5.4-xdcww3x8.mjs";import"./cli-0.5.4-fq32ny1h.mjs";import"./cli-0.5.4-h1m67ngp.mjs";import"./cli-0.5.4-49erze3e.mjs";import"./cli-0.5.4-jytjks37.mjs";import{OY as w,PY as H,QY as R,RY as E}from"./cli-0.5.4-mn22gk7g.mjs";import"./cli-0.5.4-5t3jj85n.mjs";import"./cli-0.5.4-5shjmmkz.mjs";import"./cli-0.5.4-zb412kkm.mjs";import"./cli-0.5.4-prfn3sxd.mjs";import"./cli-0.5.4-6xmgebmk.mjs";import"./cli-0.5.4-vjgejcrz.mjs";import"./cli-0.5.4-jqt00ywx.mjs";import"./cli-0.5.4-9e7rkd8e.mjs";import"./cli-0.5.4-jp4wtw87.mjs";import"./cli-0.5.4-hambpq58.mjs";import"./cli-0.5.4-syvgmg9g.mjs";import"./cli-0.5.4-w8ttefr5.mjs";import"./cli-0.5.4-j7kkqxv6.mjs";import"./cli-0.5.4-qrwczx7j.mjs";import"./cli-0.5.4-v2z6p9td.mjs";import{J$ as B,T$ as i}from"./cli-0.5.4-cbq01zg3.mjs";import"./cli-0.5.4-37v5fhf1.mjs";import"./cli-0.5.4-7grzwf6q.mjs";import"./cli-0.5.4-9qmek5dq.mjs";import"./cli-0.5.4-9c6r1fjg.mjs";import"./cli-0.5.4-2dw33ms6.mjs";import"./cli-0.5.4-x1fzfxmm.mjs";import"./cli-0.5.4-e822fzaq.mjs";import{Nea as U,Pea as n}from"./cli-0.5.4-09dvrzcr.mjs";import"./cli-0.5.4-end8wj9r.mjs";import"./cli-0.5.4-4x206j04.mjs";import"./cli-0.5.4-yd3rd9qt.mjs";import{Bga as j,Gga as v,Nga as l}from"./cli-0.5.4-sgcaw17t.mjs";import"./cli-0.5.4-jmc3bzbn.mjs";import"./cli-0.5.4-959vxhhb.mjs";import{Vma as u,Wma as g}from"./cli-0.5.4-aacw1src.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};
