import{Bx as J,Cx as c,Hq as Z,Jq as o,Ok as $,SN as e,Sk as r,eA as X,fA as h,gA as F,hA as f,jj as w,kN as N,kj as a,lN as T,mN as m,nN as O,qA as t,rA as s}from"./cli-0.5.12-zc0qwdy2.mjs";import"./cli-0.5.12-whfz3xsx.mjs";import"./cli-0.5.12-z100r543.mjs";import"./cli-0.5.12-bzab36pn.mjs";import"./cli-0.5.12-pp1549k7.mjs";import"./cli-0.5.12-9mq24qzr.mjs";import"./cli-0.5.12-7repzgzv.mjs";import"./cli-0.5.12-pdqnfqg3.mjs";import"./cli-0.5.12-c2yq69h9.mjs";import"./cli-0.5.12-kez9r81a.mjs";import"./cli-0.5.12-zbcr8cbk.mjs";import"./cli-0.5.12-2wf629mh.mjs";import"./cli-0.5.12-ghtxkxqx.mjs";import"./cli-0.5.12-xg7a0dy4.mjs";import"./cli-0.5.12-s0h788we.mjs";import"./cli-0.5.12-m22yxpb9.mjs";import"./cli-0.5.12-cw1qs4bg.mjs";import"./cli-0.5.12-yq8ds97a.mjs";import"./cli-0.5.12-qew4mzgp.mjs";import"./cli-0.5.12-gwg1e43k.mjs";import"./cli-0.5.12-36swspqa.mjs";import"./cli-0.5.12-4dn79vqp.mjs";import"./cli-0.5.12-f5pfjvdk.mjs";import{YX as p,_V as S,rX as I}from"./cli-0.5.12-fqp5s15p.mjs";import"./cli-0.5.12-rc1p9wk6.mjs";import"./cli-0.5.12-x479axrj.mjs";import"./cli-0.5.12-ysy6e9rz.mjs";import"./cli-0.5.12-cqv7z22w.mjs";import"./cli-0.5.12-7cn41yy7.mjs";import"./cli-0.5.12-34cd39ve.mjs";import"./cli-0.5.12-m2gh4ewc.mjs";import{AZ as P,BZ as H,CZ as R,DZ as E}from"./cli-0.5.12-c6whkxmz.mjs";import"./cli-0.5.12-w3hy6c60.mjs";import"./cli-0.5.12-5d3qcvf5.mjs";import"./cli-0.5.12-f141d2qa.mjs";import"./cli-0.5.12-khvy67r3.mjs";import"./cli-0.5.12-pycnjaeg.mjs";import"./cli-0.5.12-8v5w8znc.mjs";import"./cli-0.5.12-ctqkj6ve.mjs";import"./cli-0.5.12-cbevkwg4.mjs";import"./cli-0.5.12-w00qj83e.mjs";import"./cli-0.5.12-nbcjwzzn.mjs";import"./cli-0.5.12-3t06hwwh.mjs";import"./cli-0.5.12-057c2cp2.mjs";import"./cli-0.5.12-ecgx5n54.mjs";import{M$ as B,W$ as i}from"./cli-0.5.12-g4wb8mj2.mjs";import"./cli-0.5.12-vp5smcs1.mjs";import"./cli-0.5.12-y2kq7fe8.mjs";import"./cli-0.5.12-7vxpqr5a.mjs";import"./cli-0.5.12-hvtcdcev.mjs";import"./cli-0.5.12-asbn3d19.mjs";import"./cli-0.5.12-k1crwtdc.mjs";import{dfa as j,ffa as l}from"./cli-0.5.12-2jxq8gnm.mjs";import"./cli-0.5.12-p5ps8gf0.mjs";import"./cli-0.5.12-hp0508v9.mjs";import{Gga as n,uga as v,zga as U}from"./cli-0.5.12-tfdwzg37.mjs";import"./cli-0.5.12-60w1a0bs.mjs";import"./cli-0.5.12-c8f4daey.mjs";import"./cli-0.5.12-0qasc0ef.mjs";import"./cli-0.5.12-f8850v2j.mjs";import"./cli-0.5.12-495d826j.mjs";import"./cli-0.5.12-rt0k97yj.mjs";import"./cli-0.5.12-1vyz0tt9.mjs";import{Yna as u,Zna as g}from"./cli-0.5.12-xzeb7mtb.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();l();n();e();i();function b(){return B().defaultShell??"bash"}a();r();o();E();async function yq(L,q,V,A,K){let Y=w()&&b()==="powershell";j("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(P,{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 $(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 v){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(U(z))}</bash-stderr>`})],shouldQuery:!1}}finally{K(null)}}export{yq as processBashCommand};
