import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./defineProperty-80gRi2ZW.js";import{r,t as i}from"./execFileNoThrow-azCkYhmF.js";import{a,i as o,t as s}from"./cliLaunch-Citfs01Q.js";import{spawnSync as c}from"child_process";var l;e((()=>{r(),o(),t(),l=class{constructor(){n(this,`name`,`tmux`),n(this,`supportsInteractiveInput`,!0)}async available(){let{code:e}=await i(`tmux`,[`-V`],{useCwd:!1});return e===0}async start(e){let t=s(e.args,{env:{...e.env,CLAUDE_CODE_SESSION_KIND:`bg`,CLAUDE_CODE_SESSION_NAME:e.sessionName,CLAUDE_CODE_SESSION_LOG:e.logPath,CLAUDE_CODE_TMUX_SESSION:e.sessionName}}),n=a(t);if(c(`tmux`,[`new-session`,`-d`,`-s`,e.sessionName,n],{stdio:`inherit`,env:t.env}).status!==0)throw Error(`Failed to create tmux session.`);return{pid:0,sessionName:e.sessionName,logPath:e.logPath,engineUsed:`tmux`}}async attach(e){if(!e.tmuxSessionName)throw Error(`Session ${e.sessionId} has no tmux session name.`);if(c(`tmux`,[`attach-session`,`-t`,e.tmuxSessionName],{stdio:`inherit`}).status!==0)throw Error(`Failed to attach to tmux session '${e.tmuxSessionName}'.`)}}}))();export{l as TmuxEngine};