purplemux 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +32 -32
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/routes-manifest.json +20 -14
- package/.next/standalone/.next/server/chunks/[externals]__0l1mhe5._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__06an6au._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__09q4wzd._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0hls3o-._.js +20 -20
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0j.vqs2._.js +20 -20
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__10o5i.7._.js +3 -0
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_pages-api_0ulrm.8.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_status-manager_ts_003hlhy._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0-xx2s1._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0.fa33p._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0camkxl._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0i209pm._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0sfa_96._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_components_features_mobile_mobile-terminal-page_tsx_02chzch._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_components_features_terminal_terminal-page_tsx_0o~2bsa._.js +1 -1
- package/.next/standalone/.next/server/functions-config-manifest.json +2 -2
- package/.next/standalone/.next/server/middleware-build-manifest.js +32 -32
- package/.next/standalone/.next/server/middleware.js +1 -1
- package/.next/standalone/.next/server/pages/_app/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/_app/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/agents/[agentId]/chat/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/agents/[agentId]/chat/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/agents/[agentId]/memory/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/agents/[agentId]/memory/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/agents/[agentId]/workspace/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/agents/[agentId]/workspace/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/agents/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/agents/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/api/health/pages-manifest.json +3 -0
- package/.next/standalone/.next/server/pages/api/health.js +5 -0
- package/.next/standalone/.next/server/pages/api/health.js.map +5 -0
- package/.next/standalone/.next/server/pages/api/health.js.nft.json +1 -0
- package/.next/standalone/.next/server/pages/api/stats/daily-report/cache.js +1 -1
- package/.next/standalone/.next/server/pages/api/stats/daily-report/generate.js +1 -1
- package/.next/standalone/.next/server/pages/api/stats/sessions.js +2 -2
- package/.next/standalone/.next/server/pages/de/404.html +1 -1
- package/.next/standalone/.next/server/pages/de/500.html +1 -1
- package/.next/standalone/.next/server/pages/en/404.html +1 -1
- package/.next/standalone/.next/server/pages/en/500.html +1 -1
- package/.next/standalone/.next/server/pages/es/404.html +1 -1
- package/.next/standalone/.next/server/pages/es/500.html +1 -1
- package/.next/standalone/.next/server/pages/fr/404.html +1 -1
- package/.next/standalone/.next/server/pages/fr/500.html +1 -1
- package/.next/standalone/.next/server/pages/index/build-manifest.json +4 -4
- package/.next/standalone/.next/server/pages/index/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/index/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/pages/ja/404.html +1 -1
- package/.next/standalone/.next/server/pages/ja/500.html +1 -1
- package/.next/standalone/.next/server/pages/ko/404.html +1 -1
- package/.next/standalone/.next/server/pages/ko/500.html +1 -1
- package/.next/standalone/.next/server/pages/pt-BR/404.html +1 -1
- package/.next/standalone/.next/server/pages/pt-BR/500.html +1 -1
- package/.next/standalone/.next/server/pages/reports/build-manifest.json +4 -4
- package/.next/standalone/.next/server/pages/reports/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/ru/404.html +1 -1
- package/.next/standalone/.next/server/pages/ru/500.html +1 -1
- package/.next/standalone/.next/server/pages/stats/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/stats/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/tr/404.html +1 -1
- package/.next/standalone/.next/server/pages/tr/500.html +1 -1
- package/.next/standalone/.next/server/pages/webview/build-manifest.json +3 -3
- package/.next/standalone/.next/server/pages/webview/client-build-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/zh-CN/404.html +1 -1
- package/.next/standalone/.next/server/pages/zh-CN/500.html +1 -1
- package/.next/standalone/.next/server/pages/zh-TW/404.html +1 -1
- package/.next/standalone/.next/server/pages/zh-TW/500.html +1 -1
- package/.next/standalone/.next/server/pages-manifest.json +1 -0
- package/.next/standalone/.next/static/{IGLfY98cOpT_s-m_8zv8r → cUc-iVh9yPvV5U6zlJnRI}/_buildManifest.js +9 -8
- package/.next/standalone/.next/static/{IGLfY98cOpT_s-m_8zv8r → cUc-iVh9yPvV5U6zlJnRI}/_clientMiddlewareManifest.js +2 -2
- package/.next/standalone/.next/static/chunks/{0sg17g3rw3j79.js → 0.emlk-pyrq15.js} +3 -3
- package/.next/standalone/.next/static/chunks/{0ebzi~xd5kbf6.js → 04~5g0kns0w-3.js} +3 -3
- package/.next/standalone/.next/static/chunks/{0modp.voz0yb8.js → 05~-~kex871hu.js} +3 -3
- package/.next/standalone/.next/static/chunks/09.nvq4m4q6nw.js +1 -0
- package/.next/standalone/.next/static/chunks/{1749j145r0f24.js → 0bu_7.oshhrhc.js} +3 -3
- package/.next/standalone/.next/static/chunks/{0~4_p.wm8.z1b.js → 0c3fuwgxh-35e.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0s7-~f7~nxsvv.js → 0cacobjih1-zm.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0y3i2gt468lcz.js → 0e7eht~s9maij.js} +4 -4
- package/.next/standalone/.next/static/chunks/0g65_p2-lr~2p.js +1 -0
- package/.next/standalone/.next/static/chunks/0g7dnwyslqeva.css +1 -0
- package/.next/standalone/.next/static/chunks/{0vnqr1g65cq~a.js → 0pitqn2--9ly-.js} +3 -3
- package/.next/standalone/.next/static/chunks/0rr4-5v-_uawq.js +1 -0
- package/.next/standalone/.next/static/chunks/0rtjgrowjz8n3.js +1 -0
- package/.next/standalone/.next/static/chunks/{0-ltvzwc~iee..js → 0uv~o_jk4b1cj.js} +1 -1
- package/.next/standalone/.next/static/chunks/0wbv3pd2oyilv.js +1 -0
- package/.next/standalone/.next/static/chunks/{07tmc1fd581-v.js → 11oe_y_tnk5rs.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0fot2fshtz0xb.js → 12p51x0jwo~g0.js} +4 -4
- package/.next/standalone/.next/static/chunks/{00t4cxw76sr6_.js → 13zscswif89xn.js} +3 -3
- package/.next/standalone/.next/static/chunks/17rm0jup5m3lg.js +1 -0
- package/.next/standalone/.next/static/chunks/{0uvj8zvtnbzk..js → 18eatd5x-6wn7.js} +3 -3
- package/.next/standalone/.next/static/chunks/{turbopack-02sp76-9vzd-3.js → turbopack-0g9hcqkf8--nt.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0scaqrnmscmk5.js → turbopack-0kc~8bc2j~nm5.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0-_7t3yzrv2o0.js → turbopack-0kxgmh4de86.c.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0gcm0ao7ar0vo.js → turbopack-0pbs5o5-yw7zn.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0.efilbq57kj~.js → turbopack-0qzp5t.v8o4yd.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0jbxqfqs~bhnb.js → turbopack-0v2s_rrv-4zo_.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0xl824.ut7kv5.js → turbopack-0vg_jegb9r64~.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0g..zdci5n6yt.js → turbopack-0z94ziwry23f8.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-102tph-sy46xp.js → turbopack-0zo4s0e54r18i.js} +1 -1
- package/.next/standalone/package.json +2 -1
- package/.next/standalone/server.js +1 -1
- package/bin/purplemux.js +6 -0
- package/dist/server.js +220 -85
- package/package.json +2 -1
- package/.next/standalone/.next/server/chunks/[externals]__13k.c.~._.js +0 -3
- package/.next/standalone/.next/static/chunks/078ug0z94g-5f.css +0 -1
- package/.next/standalone/.next/static/chunks/09ic8khns87py.js +0 -1
- package/.next/standalone/.next/static/chunks/0_24.ba0w6i58.js +0 -1
- package/.next/standalone/.next/static/chunks/0a0i6iubp4z.k.js +0 -1
- package/.next/standalone/.next/static/chunks/0zv-py60g55wn.js +0 -1
- package/.next/standalone/.next/static/chunks/0~qmpv1k~~-.r.js +0 -1
- package/.next/standalone/.next/static/chunks/13h_qiv748a8c.js +0 -1
- /package/.next/standalone/.next/static/{IGLfY98cOpT_s-m_8zv8r → cUc-iVh9yPvV5U6zlJnRI}/_ssgManifest.js +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module.exports=[522734,(e,t,a)=>{t.exports=e.x("fs",()=>require("fs"))},270406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},814747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},446786,(e,t,a)=>{t.exports=e.x("os",()=>require("os"))},924868,(e,t,a)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},130146,(e,t,a)=>{t.exports=e.x("pino-28069d5257187539",()=>require("pino-28069d5257187539"))},666680,(e,t,a)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},224361,(e,t,a)=>{t.exports=e.x("util",()=>require("util"))},233405,(e,t,a)=>{t.exports=e.x("child_process",()=>require("child_process"))},25146,e=>{"use strict";var t=e.i(130146),a=e.i(814747),n=e.i(446786);let s=a.default.join(n.default.homedir(),".purplemux","logs"),r=process.env.LOG_LEVEL||"info",i=(e=>{if(!e)return{};let t={};for(let a of e.split(",")){let[e,n]=a.split("=").map(e=>e.trim());e&&n&&(t[e]=n)}return t})(process.env.LOG_LEVELS),l=["trace","debug","info","warn","error","fatal"],o=globalThis;if(!o.__ptRootLogger){let e=[r,...Object.values(i)].reduce((e,t)=>l.indexOf(t)<l.indexOf(e)?t:e,"fatal");o.__ptRootLogger=(0,t.default)({level:e,transport:{targets:[{target:"pino-roll",level:e,options:{file:a.default.join(s,"purplemux"),frequency:"daily",dateFormat:"yyyy-MM-dd",limit:{count:7},mkdir:!0}},{target:"pino-pretty",level:e,options:{colorize:!0,ignore:"pid,hostname,module",translateTime:"HH:MM:ss",messageFormat:"[{module}] {msg}"}}]}})}let u=o.__ptRootLogger;e.s(["createLogger",0,e=>{let t=u.child({module:e});return t.level=i[e]??r,t}])},44014,e=>{"use strict";let t,a;var n=e.i(666680);e.s(["nanoid",0,function(e=21){var s;s=e|=0,!t||t.length<s?(t=Buffer.allocUnsafe(128*s),n.webcrypto.getRandomValues(t),a=0):a+s>t.length&&(n.webcrypto.getRandomValues(t),a=0),a+=s;let r="";for(let n=a-e;n<a;n++)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[n]];return r}],44014)},459015,544538,e=>{"use strict";var t=e.i(233405),a=e.i(924868),n=e.i(224361),s=e.i(814747),r=e.i(44014),i=e.i(25146);process.platform;let l="linux"===process.platform;e.s(["isLinux",0,l],544538);let o=(0,i.createLogger)("terminal"),u=(0,n.promisify)(t.execFile),c="purple",d=s.default.join(process.env.__PMUX_APP_DIR_UNPACKED||process.env.__PMUX_APP_DIR||process.cwd(),"src","config","tmux.conf"),m=new Set(["AUTH_PASSWORD","NEXTAUTH_SECRET"]),p=()=>Object.fromEntries(Object.entries(process.env).filter(([e])=>!e.startsWith("npm_")&&!e.startsWith("NODE_")&&!m.has(e))),f=async()=>{try{let{stdout:e}=await u("tmux",["-L",c,"ls","-F","#{session_name}"],{timeout:5e3});return e.trim().split("\n").map(e=>e.trim()).filter(e=>e.startsWith("pt-"))}catch{return[]}},h=async(e,t,a,n)=>{let s=process.env.SHELL||"/bin/zsh";await u("tmux",["-u","-L",c,"-f",d,"new-session","-d","-s",e,"-x",String(t),"-y",String(a)],{timeout:5e3,env:{...p(),SHELL:s,TERM:"xterm-256color",COLORTERM:"truecolor"},cwd:n||process.env.HOME||"/"}),await b(),o.debug(`tmux session created: ${e} (cols: ${t}, rows: ${a})`)},g=e=>new Promise(t=>setTimeout(t,e)),y=async e=>{if(!await w(e))return;o.debug(`killSession start: ${e}`);let t=await L(e);if(t)try{o.debug(`SIGTERM → process group ${t}: ${e}`),process.kill(-t,"SIGTERM")}catch{}try{await u("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<5;t++){if(!await w(e))return void o.debug(`killSession done (SIGTERM): ${e}`);await g(200)}if(o.warn(`session survived SIGTERM, escalating to SIGKILL: ${e}`),t)try{o.debug(`SIGKILL → process group ${t}: ${e}`),process.kill(-t,"SIGKILL")}catch{}try{await u("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<3;t++){if(!await w(e))return void o.debug(`killSession done (SIGKILL): ${e}`);await g(200)}o.warn(`tmux session still alive after kill: ${e}`)},w=async e=>{try{return await u("tmux",["-L",c,"has-session","-t",e],{timeout:5e3}),!0}catch{return!1}},S=async()=>{},x=async()=>{await S();let e=await f();e.length>0&&e.forEach(e=>{o.debug(`existing tmux session found: ${e}`)})},C=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path}"],{timeout:5e3});return t.trim()||null}catch{return null}},L=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_pid}"],{timeout:5e3}),a=parseInt(t.trim(),10);return Number.isNaN(a)?null:a}catch{return null}},b=async()=>{try{await u("tmux",["-L",c,"source-file",d],{timeout:5e3})}catch{}},_=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"list-panes","-t",e,"-F","#{pane_current_command}"],{timeout:5e3});return t.trim()||null}catch{return null}},v=async()=>{try{let{stdout:e}=await u("tmux",["-L",c,"list-panes","-a","-F","#{session_name} #{pane_current_command} #{pane_current_path} #{pane_pid} #{window_activity}"],{timeout:5e3}),t=new Map;for(let a of e.trim().split("\n")){if(!a)continue;let[e,n,s,r,i]=a.split(" ");if(e&&n){let a=parseInt(r,10),l=parseInt(i,10);t.set(e,{command:n,path:s||"",pid:Number.isNaN(a)?0:a,windowActivity:Number.isNaN(l)?0:l})}}return t}catch{return new Map}},T=new Set(["bash","zsh","fish","sh","dash"]),k=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_title}"],{timeout:5e3});return t.trim()||null}catch{return null}},I=async e=>{await u("tmux",["-L",c,"copy-mode","-q","-t",e],{timeout:5e3}).catch(()=>{})},D=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,t,"Enter"],{timeout:5e3})},E=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,t],{timeout:5e3})},R=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,"-l",`\x1b[200~${t}\x1b[201~`],{timeout:5e3}),await u("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3}),await new Promise(e=>setTimeout(e,600)),await u("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3})},$=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path} #{pane_current_command} #{pane_pid} #{pane_width} #{pane_height} #{session_created}"],{timeout:5e3}),[a,n,s,r,i,l]=t.trim().split(" ");return{cwd:a||null,command:n||null,pid:s&&parseInt(s,10)||null,width:r&&parseInt(r,10)||null,height:i&&parseInt(i,10)||null,sessionCreated:l&&parseInt(l,10)||null}}catch{return{cwd:null,command:null,pid:null,width:null,height:null,sessionCreated:null}}},j=new Set(["node","python","python3","ruby","perl","deno","bun"]),P=async()=>{try{await u("tmux",["-L",c,"kill-server"],{timeout:5e3}),o.debug("tmux server killed")}catch{}},A=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"capture-pane","-p","-t",e],{timeout:5e3});return t}catch{return null}},M=async(e,t)=>{try{let{stdout:a}=await u("tmux",["-L",c,"capture-pane","-p","-S",`-${t}`,"-t",e],{timeout:5e3});return a}catch{return null}},N=async e=>{if(l){let t=[];return await Promise.all(e.map(async e=>{try{for(let n of(await a.default.readFile(`/proc/${e}/task/${e}/children`,"utf-8")).trim().split(/\s+/)){let e=parseInt(n,10);Number.isNaN(e)||t.push(e)}}catch{}})),t}try{let{stdout:t}=await u("pgrep",["-P",e.join(",")],{timeout:5e3});return t.trim().split("\n").map(e=>parseInt(e,10)).filter(e=>!Number.isNaN(e))}catch{return[]}},O=async e=>{let t=[],a=[e];for(;a.length>0;){let e=await N(a);if(0===e.length)break;t.push(...e),a=e}return t},F=async e=>{try{let t=new Set(e),{stdout:a}=await u("ss",["-tlnp"],{timeout:5e3}),n=new Set;for(let e of a.split("\n")){let a=e.match(/pid=(\d+)/g);if(!a||!a.some(e=>t.has(parseInt(e.replace("pid=",""),10))))continue;let s=e.match(/:(\d+)\s/);s&&n.add(parseInt(s[1],10))}return[...n].sort((e,t)=>e-t)}catch{return[]}},H=async e=>{let t=await O(e);if(0===t.length)return[];if(l)return F(t);try{let{stdout:e}=await u("lsof",["-a","-p",t.join(","),"-i","-sTCP:LISTEN","-P","-Fn"],{timeout:5e3}),a=new Set;for(let t of e.split("\n"))if(t.startsWith("n")){let e=t.match(/:(\d+)$/);e&&a.add(parseInt(e[1],10))}return[...a].sort((e,t)=>e-t)}catch{return[]}},W=async e=>{let t=await L(e);if(!t)return null;try{let{stdout:e}=await u("pgrep",["-n","-P",String(t)],{timeout:5e3}),a=e.trim();if(!a)return null;let{stdout:n}=await u("ps",["-o","args=","-p",a],{timeout:5e3}),r=n.trim();if(!r)return null;let i=r.split(/\s+/);if(0===i.length)return r;if(i[0]=s.default.basename(i[0]),j.has(i[0])&&i.length>1){let e=s.default.basename(i[1]).replace(/\.(c|m)?js$/,"");i.splice(0,2,e)}return i.join(" ")}catch{return null}};e.s(["SAFE_SHELLS",0,T,"applyConfig",0,b,"capturePaneContent",0,A,"capturePaneContentWithHistory",0,M,"createSession",0,h,"defaultSessionName",0,()=>`pt-${(0,r.nanoid)(6)}-${(0,r.nanoid)(6)}-${(0,r.nanoid)(6)}`,"exitCopyMode",0,I,"getAllPanesInfo",0,v,"getLastCommand",0,W,"getListeningPorts",0,H,"getPaneCurrentCommand",0,_,"getPaneDetailInfo",0,$,"getPaneTitle",0,k,"getSessionCwd",0,C,"getSessionPanePid",0,L,"hasSession",0,w,"killServer",0,P,"killSession",0,y,"listSessions",0,f,"sanitizedEnv",0,p,"scanSessions",0,x,"sendBracketedPaste",0,R,"sendKeys",0,D,"sendRawKeys",0,E,"workspaceSessionName",0,(e,t,a)=>`pt-${e}-${t}-${a}`],459015)},713915,e=>{"use strict";var t=e.i(233405),a=e.i(924868),n=e.i(446786),s=e.i(814747),r=e.i(224361),i=e.i(459015);let l=(0,r.promisify)(t.execFile),o=null,u=null,c=async()=>{let e=n.default.userInfo().shell||process.env.SHELL||"/bin/bash";try{let{stdout:t}=await l(e,["-ilc",'echo -n "$PATH"'],{timeout:5e3,env:{...(0,i.sanitizedEnv)(),SHELL:e,DISABLE_AUTO_UPDATE:"true",ZSH_TMUX_AUTOSTARTED:"true",TERM:"xterm-256color",COLORTERM:"truecolor"}});return t.toString().trim()}catch{return process.env.PATH||""}},d=async()=>o||(u||(u=c().then(e=>(o=e,u=null,e))),u),m=async(e,t,a)=>{try{let n=await d(),{stdout:s}=await l(e,t,{timeout:5e3,env:{...process.env,PATH:n}});return{installed:!0,version:a(s)}}catch{return{installed:!1,version:null}}},p=e=>e.trim().match(/(\d+\.\d+[\d.]*)/)?.[1]??null,f=[s.default.join(n.default.homedir(),".local","bin")],h=async()=>{for(let e of f)try{return await (0,a.access)(s.default.join(e,"claude")),e}catch{}return null},g=e=>e.installed&&null!==e.version&&parseFloat(e.version)>=2.9,y=async()=>{o=await c();let[e,t,r]=await Promise.all([m("tmux",["-V"],p),m("git",["--version"],p),m("claude",["--version"],p)]),i=(g(e)&&t.installed&&r.installed,r.installed?null:await h()),l=!1;if(r.installed||i)try{await (0,a.access)(s.default.join(n.default.homedir(),".claude")),l=!0}catch{}return{tmux:{...e,compatible:g(e)},git:t,claude:{...r,binaryPath:i,loggedIn:l}}},w=null,S=null,x=async()=>{o=await c();let[e,t,a]=await Promise.all([m("tmux",["-V"],p),m("git",["--version"],p),m("claude",["--version"],p)]);return{tmux:{...e,compatible:g(e)},git:t,claude:a}},C=async()=>w&&Date.now()-w.checkedAt<3e4?w.result:S||(S=x().then(e=>(w={result:e,checkedAt:Date.now()},S=null,e)).catch(e=>{throw S=null,e}));e.s(["getCachedRuntimePreflight",0,C,"getPreflightStatus",0,y,"getShellPath",0,d,"invalidateRuntimeCache",0,()=>{w=null,S=null}])},319668,(e,t,a)=>{t.exports=e.x("readline",()=>require("readline"))},177579,e=>{"use strict";var t=e.i(924868),a=e.i(522734),n=e.i(814747),s=e.i(446786),r=e.i(319668),i=e.i(990294);let l=n.default.join(s.default.homedir(),".purplemux","stats"),o=n.default.join(l,"cache.json"),u=n.default.join(s.default.homedir(),".claude","projects"),c=async()=>{let e=[];try{for(let a of(await t.default.readdir(u))){let s=n.default.join(u,a),r=await t.default.stat(s).catch(()=>null);if(r?.isDirectory())for(let a of(await t.default.readdir(s).catch(()=>[])))a.endsWith(".jsonl")&&!/^agent-/.test(a)&&e.push(n.default.join(s,a))}}catch{}return e},d=async(e,t)=>{let n=new Map,s=new Map;try{let i=(0,a.createReadStream)(e,{encoding:"utf-8"});for await(let e of r.default.createInterface({input:i,crlfDelay:1/0}))if(e.trim())try{let a=JSON.parse(e),r=String(a.timestamp??"");if(!r)continue;let i=r.slice(0,10);if(!t.has(i))continue;let l=String(a.type??"");if("user"!==l&&"assistant"!==l)continue;let o=String(a.sessionId??""),u=String(new Date(r).getHours()),c=n.get(i);c||(c={messageCount:0,sessionCount:0,toolCallCount:0,hourCounts:{},modelTokens:{},sessions:[]},n.set(i,c),s.set(i,new Map));let d=s.get(i);if("user"===l&&(c.messageCount++,c.hourCounts[u]=(c.hourCounts[u]??0)+1,o)){let e=d.get(o);e?(e.messages++,r>e.end&&(e.end=r),r<e.start&&(e.start=r)):d.set(o,{start:r,end:r,messages:1})}if("assistant"===l){let e=a.message;if(!e)continue;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length;c.toolCallCount+=e}let n=String(e.model??""),s=e.usage;if(n&&!n.startsWith("<")&&s){c.modelTokens[n]||(c.modelTokens[n]={input:0,output:0,cacheRead:0,cacheCreation:0});let e=c.modelTokens[n];e.input+=Number(s.input_tokens??0),e.output+=Number(s.output_tokens??0),e.cacheRead+=Number(s.cache_read_input_tokens??0),e.cacheCreation+=Number(s.cache_creation_input_tokens??0)}if(o){let e=d.get(o);e?(r>e.end&&(e.end=r),r<e.start&&(e.start=r)):d.set(o,{start:r,end:r,messages:0})}}}catch{}}catch{}for(let[e,t]of s){let a=n.get(e);a&&(a.sessionCount=t.size,a.sessions=Array.from(t.entries()).map(([e,t])=>({id:e,start:t.start,end:t.end,messages:t.messages})))}return n},m=async(e,t)=>{let a=[],n=0,s=async()=>{for(;n<e.length;){let t=n++;a[t]=await e[t]()}},r=Array.from({length:Math.min(t,e.length)},()=>s());return await Promise.all(r),a},p=(e,t)=>{for(let[a,n]of(e.messageCount+=t.messageCount,e.toolCallCount+=t.toolCallCount,Object.entries(t.hourCounts)))e.hourCounts[a]=(e.hourCounts[a]??0)+n;for(let[a,n]of Object.entries(t.modelTokens)){e.modelTokens[a]||(e.modelTokens[a]={input:0,output:0,cacheRead:0,cacheCreation:0});let t=e.modelTokens[a];t.input+=n.input,t.output+=n.output,t.cacheRead+=n.cacheRead,t.cacheCreation+=n.cacheCreation}let a=new Set(e.sessions.map(e=>e.id));for(let n of t.sessions)if(a.has(n.id)){let t=e.sessions.find(e=>e.id===n.id);t.messages+=n.messages,n.start<t.start&&(t.start=n.start),n.end>t.end&&(t.end=n.end)}else e.sessions.push(n);e.sessionCount=e.sessions.length},f=async()=>{try{let e=await t.default.readFile(o,"utf-8"),a=JSON.parse(e);if(1!==a.version)return null;return a}catch{return null}},h=async e=>{await t.default.mkdir(l,{recursive:!0}),await t.default.writeFile(o,JSON.stringify(e),"utf-8")},g=null,y=async e=>{try{let t=(0,a.createReadStream)(e,{encoding:"utf-8"});for await(let e of r.default.createInterface({input:t,crlfDelay:1/0}))if(e.trim())try{let t=JSON.parse(e),a=String(t.timestamp??"");if(a)return a.slice(0,10)}catch{}}catch{}return null},w=async()=>{let e=await c();if(0===e.length)return null;let t=e.map(e=>()=>y(e)),a=(await m(t,10)).filter(e=>null!==e);return 0===a.length?null:(a.sort(),a[0])},S=async e=>{if(0===e.size)return new Map;let t=(await c()).map(t=>()=>d(t,e)),a=await m(t,10),n=new Map;for(let e of a)for(let[t,a]of e){let e=n.get(t);e?p(e,a):n.set(t,a)}return n},x=async()=>{if(g&&Date.now()<g.expiresAt)return g.data;let e=(0,i.default)().subtract(1,"day").format("YYYY-MM-DD"),t=(0,i.default)().format("YYYY-MM-DD"),a=await f(),n=new Set;if(n.add(t),a){if(a.lastComputedDate<e){let t=(0,i.default)(a.lastComputedDate).add(1,"day"),s=(0,i.default)(e);for(;t.isBefore(s)||t.isSame(s);){let e=t.format("YYYY-MM-DD");a.days[e]||n.add(e),t=t.add(1,"day")}}}else{a={version:1,lastComputedDate:"",days:{}};let s=await w();if(!s)return C(a,t);let r=(0,i.default)(s),l=(0,i.default)(e);for(;r.isBefore(l)||r.isSame(l);)n.add(r.format("YYYY-MM-DD")),r=r.add(1,"day")}let s=await S(n);for(let[e,n]of s)e!==t&&(a.days[e]=n);a.lastComputedDate=e,await h(a);let r=s.get(t)??null,l=C(a,t,r);return g={data:l,expiresAt:Date.now()+3e5},l},C=(e,t,a)=>{let n=[],s=[],r={},i={},l={},o=0,u=0,c="",d={sessionId:"",duration:0,messageCount:0,timestamp:""},m=Object.entries(e.days);for(let[e,p]of(a&&m.push([t,a]),m.sort((e,t)=>e[0].localeCompare(t[0])),m)){!c&&p.messageCount>0&&(c=e),n.push({date:e,messageCount:p.messageCount,sessionCount:p.sessionCount,toolCallCount:p.toolCallCount});let t={};for(let[e,a]of Object.entries(p.modelTokens)){t[e]={input:a.input,output:a.output,cacheRead:a.cacheRead,cacheCreation:a.cacheCreation},r[e]||(r[e]={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,webSearchRequests:0,costUSD:0,contextWindow:0,maxOutputTokens:0});let n=r[e];n.inputTokens+=a.input,n.outputTokens+=a.output,n.cacheReadInputTokens+=a.cacheRead,n.cacheCreationInputTokens+=a.cacheCreation}s.push({date:e,tokensByModel:t});let a=new Date(e).getDay();for(let[e,t]of Object.entries(p.hourCounts)){i[e]=(i[e]??0)+t;let n=`${a}-${e}`;l[n]=(l[n]??0)+t}for(let e of(o+=p.sessionCount,u+=p.messageCount,p.sessions)){let t=new Date(e.end).getTime()-new Date(e.start).getTime();t>d.duration&&(d={sessionId:e.id,duration:t,messageCount:e.messages,timestamp:e.start})}}return{version:1,lastComputedDate:t,dailyActivity:n,dailyModelTokens:s,modelUsage:r,totalSessions:o,totalMessages:u,longestSession:d,firstSessionDate:c,hourCounts:i,dayHourCounts:l,totalSpeculationTimeSavedMs:0}};e.s(["collectJsonlFiles",0,c,"getStatsCache",0,x])},7991,e=>{"use strict";var t=e.i(924868),a=e.i(814747),n=e.i(446786),s=e.i(522734),r=e.i(319668),i=e.i(233405),l=e.i(713915),o=e.i(177579);let u=a.default.join(n.default.homedir(),".purplemux","stats","daily-reports"),c=async()=>{let e={};try{for(let n of(await t.default.readdir(u)))if(n.endsWith(".json"))try{let s=await t.default.readFile(a.default.join(u,n),"utf-8"),r=JSON.parse(s);r.date&&r.brief&&(e[r.date]=r)}catch{}}catch{}return e},d=async e=>{await t.default.mkdir(u,{recursive:!0}),await t.default.writeFile(a.default.join(u,`${e.date}.json`),JSON.stringify(e,null,2),"utf-8")},m=e=>{let t=n.default.homedir();return(e.startsWith(t)?e.slice(t.length+1):e).replace(/^Workspace\/github\.com\//g,"").replace(/^Workspace\/gitlab\.kolonfnc\.com\//g,"gitlab/").replace(/^Documents\//g,"docs/").replace(/^Downloads/g,"Downloads")},p=async e=>{let t=await (0,o.collectJsonlFiles)(),n=[];for(let i of t){let t=[],l=[],o=0,u="";try{let a=(0,s.createReadStream)(i,{encoding:"utf-8"});for await(let n of r.default.createInterface({input:a,crlfDelay:1/0}))if(n.trim())try{let a=JSON.parse(n),s=String(a.timestamp??"");if(!s.startsWith(e))continue;l.push(s);let r=String(a.type??"");if(u||"string"!=typeof a.cwd||(u=a.cwd),"user"===r){let e=a.message;if(!e)continue;let n=e.content,r="";if("string"==typeof n)r=n.slice(0,300);else if(Array.isArray(n)){let e=[];for(let t of n)"object"==typeof t&&null!==t&&"text"===t.type&&e.push(String(t.text??"").slice(0,300));r=e.join(" | ")}if(r.includes("<command-message>")){let e=r.match(/<command-name>\/([^<]+)<\/command-name>/);r=`[Command: ${e?e[1]:"unknown"}]`}if(r.includes("<local-command-caveat>")||r.includes("<task-notification>"))continue;r.trim()&&t.push({time:s.slice(11,16),text:r.slice(0,200)})}if("assistant"===r){let e=a.message;if(!e)continue;let t=e.content;Array.isArray(t)&&(o+=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length)}}catch{}}catch{}if(l.length>0&&t.length>0){let e=u?m(u):a.default.basename(a.default.dirname(i));n.push({project:e,start:Math.min(...l.map(e=>new Date(e).getTime())).toString(),msgCount:t.length,toolCount:o,firstMessage:t[0].text})}}return n.sort((e,t)=>Number(e.start)-Number(t.start)),n},f=async(e,t)=>{let a=await (0,l.getShellPath)();return new Promise((n,s)=>{let r=(0,i.execFile)("claude",["-p"],{timeout:12e4,maxBuffer:1048576,env:{...process.env,PATH:a}},(e,t)=>{e?s(Error(`claude -p failed: ${e.message}`)):n(t.trim())});r.stdin?.write(`${t}
|
|
1
|
+
module.exports=[522734,(e,t,a)=>{t.exports=e.x("fs",()=>require("fs"))},270406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},814747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},446786,(e,t,a)=>{t.exports=e.x("os",()=>require("os"))},924868,(e,t,a)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},130146,(e,t,a)=>{t.exports=e.x("pino-28069d5257187539",()=>require("pino-28069d5257187539"))},666680,(e,t,a)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},224361,(e,t,a)=>{t.exports=e.x("util",()=>require("util"))},233405,(e,t,a)=>{t.exports=e.x("child_process",()=>require("child_process"))},25146,e=>{"use strict";var t=e.i(130146),a=e.i(814747),n=e.i(446786);let s=a.default.join(n.default.homedir(),".purplemux","logs"),r=process.env.LOG_LEVEL||"info",i=(e=>{if(!e)return{};let t={};for(let a of e.split(",")){let[e,n]=a.split("=").map(e=>e.trim());e&&n&&(t[e]=n)}return t})(process.env.LOG_LEVELS),l=["trace","debug","info","warn","error","fatal"],o=globalThis;if(!o.__ptRootLogger){let e=[r,...Object.values(i)].reduce((e,t)=>l.indexOf(t)<l.indexOf(e)?t:e,"fatal");o.__ptRootLogger=(0,t.default)({level:e,transport:{targets:[{target:"pino-roll",level:e,options:{file:a.default.join(s,"purplemux"),frequency:"daily",dateFormat:"yyyy-MM-dd",limit:{count:7},mkdir:!0}},{target:"pino-pretty",level:e,options:{colorize:!0,ignore:"pid,hostname,module",translateTime:"HH:MM:ss",messageFormat:"[{module}] {msg}"}}]}})}let u=o.__ptRootLogger;e.s(["createLogger",0,e=>{let t=u.child({module:e});return t.level=i[e]??r,t}])},44014,e=>{"use strict";let t,a;var n=e.i(666680);e.s(["nanoid",0,function(e=21){var s;s=e|=0,!t||t.length<s?(t=Buffer.allocUnsafe(128*s),n.webcrypto.getRandomValues(t),a=0):a+s>t.length&&(n.webcrypto.getRandomValues(t),a=0),a+=s;let r="";for(let n=a-e;n<a;n++)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[n]];return r}],44014)},459015,544538,e=>{"use strict";var t=e.i(233405),a=e.i(924868),n=e.i(224361),s=e.i(814747),r=e.i(44014),i=e.i(25146);process.platform;let l="linux"===process.platform;e.s(["isLinux",0,l],544538);let o=(0,i.createLogger)("terminal"),u=(0,n.promisify)(t.execFile),c="purple",d=s.default.join(process.env.__PMUX_APP_DIR_UNPACKED||process.env.__PMUX_APP_DIR||process.cwd(),"src","config","tmux.conf"),m=new Set(["AUTH_PASSWORD","NEXTAUTH_SECRET"]),p=()=>Object.fromEntries(Object.entries(process.env).filter(([e])=>!e.startsWith("npm_")&&!e.startsWith("NODE_")&&!m.has(e))),f=async()=>{try{let{stdout:e}=await u("tmux",["-L",c,"ls","-F","#{session_name}"],{timeout:5e3});return e.trim().split("\n").map(e=>e.trim()).filter(e=>e.startsWith("pt-"))}catch{return[]}},h=async(e,t,a,n)=>{let s=process.env.SHELL||"/bin/zsh";await u("tmux",["-u","-L",c,"-f",d,"new-session","-d","-s",e,"-x",String(t),"-y",String(a)],{timeout:5e3,env:{...p(),SHELL:s,TERM:"xterm-256color",COLORTERM:"truecolor"},cwd:n||process.env.HOME||"/"}),await L(),o.debug(`tmux session created: ${e} (cols: ${t}, rows: ${a})`)},g=e=>new Promise(t=>setTimeout(t,e)),y=async e=>{if(!await w(e))return;o.debug(`killSession start: ${e}`);let t=await T(e);if(t)try{o.debug(`SIGTERM → process group ${t}: ${e}`),process.kill(-t,"SIGTERM")}catch{}try{await u("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<5;t++){if(!await w(e))return void o.debug(`killSession done (SIGTERM): ${e}`);await g(200)}if(o.warn(`session survived SIGTERM, escalating to SIGKILL: ${e}`),t)try{o.debug(`SIGKILL → process group ${t}: ${e}`),process.kill(-t,"SIGKILL")}catch{}try{await u("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<3;t++){if(!await w(e))return void o.debug(`killSession done (SIGKILL): ${e}`);await g(200)}o.warn(`tmux session still alive after kill: ${e}`)},w=async e=>{try{return await u("tmux",["-L",c,"has-session","-t",e],{timeout:5e3}),!0}catch{return!1}},S=async()=>{},x=async()=>{await S();let e=await f();e.length>0&&e.forEach(e=>{o.debug(`existing tmux session found: ${e}`)})},C=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path}"],{timeout:5e3});return t.trim()||null}catch{return null}},T=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_pid}"],{timeout:5e3}),a=parseInt(t.trim(),10);return Number.isNaN(a)?null:a}catch{return null}},L=async()=>{try{await u("tmux",["-L",c,"source-file",d],{timeout:5e3})}catch{}},b=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"list-panes","-t",e,"-F","#{pane_current_command}"],{timeout:5e3});return t.trim()||null}catch{return null}},k=async()=>{try{let{stdout:e}=await u("tmux",["-L",c,"list-panes","-a","-F","#{session_name} #{pane_current_command} #{pane_current_path} #{pane_pid} #{window_activity}"],{timeout:5e3}),t=new Map;for(let a of e.trim().split("\n")){if(!a)continue;let[e,n,s,r,i]=a.split(" ");if(e&&n){let a=parseInt(r,10),l=parseInt(i,10);t.set(e,{command:n,path:s||"",pid:Number.isNaN(a)?0:a,windowActivity:Number.isNaN(l)?0:l})}}return t}catch{return new Map}},v=new Set(["bash","zsh","fish","sh","dash"]),_=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_title}"],{timeout:5e3});return t.trim()||null}catch{return null}},I=async e=>{await u("tmux",["-L",c,"copy-mode","-q","-t",e],{timeout:5e3}).catch(()=>{})},D=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,t,"Enter"],{timeout:5e3})},E=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,t],{timeout:5e3})},A=async(e,t)=>{await I(e),await u("tmux",["-L",c,"send-keys","-t",e,"-l",`\x1b[200~${t}\x1b[201~`],{timeout:5e3}),await u("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3}),await new Promise(e=>setTimeout(e,600)),await u("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3})},R=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path} #{pane_current_command} #{pane_pid} #{pane_width} #{pane_height} #{session_created}"],{timeout:5e3}),[a,n,s,r,i,l]=t.trim().split(" ");return{cwd:a||null,command:n||null,pid:s&&parseInt(s,10)||null,width:r&&parseInt(r,10)||null,height:i&&parseInt(i,10)||null,sessionCreated:l&&parseInt(l,10)||null}}catch{return{cwd:null,command:null,pid:null,width:null,height:null,sessionCreated:null}}},P=new Set(["node","python","python3","ruby","perl","deno","bun"]),j=async()=>{try{await u("tmux",["-L",c,"kill-server"],{timeout:5e3}),o.debug("tmux server killed")}catch{}},N=async e=>{try{let{stdout:t}=await u("tmux",["-L",c,"capture-pane","-p","-t",e],{timeout:5e3});return t}catch{return null}},$=async(e,t)=>{try{let{stdout:a}=await u("tmux",["-L",c,"capture-pane","-p","-S",`-${t}`,"-t",e],{timeout:5e3});return a}catch{return null}},M=async e=>{if(l){let t=[];return await Promise.all(e.map(async e=>{try{for(let n of(await a.default.readFile(`/proc/${e}/task/${e}/children`,"utf-8")).trim().split(/\s+/)){let e=parseInt(n,10);Number.isNaN(e)||t.push(e)}}catch{}})),t}try{let{stdout:t}=await u("pgrep",["-P",e.join(",")],{timeout:5e3});return t.trim().split("\n").map(e=>parseInt(e,10)).filter(e=>!Number.isNaN(e))}catch{return[]}},O=async e=>{let t=[],a=[e];for(;a.length>0;){let e=await M(a);if(0===e.length)break;t.push(...e),a=e}return t},F=async e=>{try{let t=new Set(e),{stdout:a}=await u("ss",["-tlnp"],{timeout:5e3}),n=new Set;for(let e of a.split("\n")){let a=e.match(/pid=(\d+)/g);if(!a||!a.some(e=>t.has(parseInt(e.replace("pid=",""),10))))continue;let s=e.match(/:(\d+)\s/);s&&n.add(parseInt(s[1],10))}return[...n].sort((e,t)=>e-t)}catch{return[]}},H=async e=>{let t=await O(e);if(0===t.length)return[];if(l)return F(t);try{let{stdout:e}=await u("lsof",["-a","-p",t.join(","),"-i","-sTCP:LISTEN","-P","-Fn"],{timeout:5e3}),a=new Set;for(let t of e.split("\n"))if(t.startsWith("n")){let e=t.match(/:(\d+)$/);e&&a.add(parseInt(e[1],10))}return[...a].sort((e,t)=>e-t)}catch{return[]}},W=async e=>{let t=await T(e);if(!t)return null;try{let{stdout:e}=await u("pgrep",["-n","-P",String(t)],{timeout:5e3}),a=e.trim();if(!a)return null;let{stdout:n}=await u("ps",["-o","args=","-p",a],{timeout:5e3}),r=n.trim();if(!r)return null;let i=r.split(/\s+/);if(0===i.length)return r;if(i[0]=s.default.basename(i[0]),P.has(i[0])&&i.length>1){let e=s.default.basename(i[1]).replace(/\.(c|m)?js$/,"");i.splice(0,2,e)}return i.join(" ")}catch{return null}};e.s(["SAFE_SHELLS",0,v,"applyConfig",0,L,"capturePaneContent",0,N,"capturePaneContentWithHistory",0,$,"createSession",0,h,"defaultSessionName",0,()=>`pt-${(0,r.nanoid)(6)}-${(0,r.nanoid)(6)}-${(0,r.nanoid)(6)}`,"exitCopyMode",0,I,"getAllPanesInfo",0,k,"getLastCommand",0,W,"getListeningPorts",0,H,"getPaneCurrentCommand",0,b,"getPaneDetailInfo",0,R,"getPaneTitle",0,_,"getSessionCwd",0,C,"getSessionPanePid",0,T,"hasSession",0,w,"killServer",0,j,"killSession",0,y,"listSessions",0,f,"sanitizedEnv",0,p,"scanSessions",0,x,"sendBracketedPaste",0,A,"sendKeys",0,D,"sendRawKeys",0,E,"workspaceSessionName",0,(e,t,a)=>`pt-${e}-${t}-${a}`],459015)},713915,e=>{"use strict";var t=e.i(233405),a=e.i(924868),n=e.i(446786),s=e.i(814747),r=e.i(224361),i=e.i(459015);let l=(0,r.promisify)(t.execFile),o=null,u=null,c=async()=>{let e=n.default.userInfo().shell||process.env.SHELL||"/bin/bash";try{let{stdout:t}=await l(e,["-ilc",'echo -n "$PATH"'],{timeout:5e3,env:{...(0,i.sanitizedEnv)(),SHELL:e,DISABLE_AUTO_UPDATE:"true",ZSH_TMUX_AUTOSTARTED:"true",TERM:"xterm-256color",COLORTERM:"truecolor"}});return t.toString().trim()}catch{return process.env.PATH||""}},d=async()=>o||(u||(u=c().then(e=>(o=e,u=null,e))),u),m=async(e,t,a)=>{try{let n=await d(),{stdout:s}=await l(e,t,{timeout:5e3,env:{...process.env,PATH:n}});return{installed:!0,version:a(s)}}catch{return{installed:!1,version:null}}},p=e=>e.trim().match(/(\d+\.\d+[\d.]*)/)?.[1]??null,f=[s.default.join(n.default.homedir(),".local","bin")],h=async()=>{for(let e of f)try{return await (0,a.access)(s.default.join(e,"claude")),e}catch{}return null},g=e=>e.installed&&null!==e.version&&parseFloat(e.version)>=2.9,y=async()=>{o=await c();let[e,t,r]=await Promise.all([m("tmux",["-V"],p),m("git",["--version"],p),m("claude",["--version"],p)]),i=(g(e)&&t.installed&&r.installed,r.installed?null:await h()),l=!1;if(r.installed||i)try{await (0,a.access)(s.default.join(n.default.homedir(),".claude")),l=!0}catch{}return{tmux:{...e,compatible:g(e)},git:t,claude:{...r,binaryPath:i,loggedIn:l}}},w=null,S=null,x=async()=>{o=await c();let[e,t,a]=await Promise.all([m("tmux",["-V"],p),m("git",["--version"],p),m("claude",["--version"],p)]);return{tmux:{...e,compatible:g(e)},git:t,claude:a}},C=async()=>w&&Date.now()-w.checkedAt<3e4?w.result:S||(S=x().then(e=>(w={result:e,checkedAt:Date.now()},S=null,e)).catch(e=>{throw S=null,e}));e.s(["getCachedRuntimePreflight",0,C,"getPreflightStatus",0,y,"getShellPath",0,d,"invalidateRuntimeCache",0,()=>{w=null,S=null}])},319668,(e,t,a)=>{t.exports=e.x("readline",()=>require("readline"))},177579,e=>{"use strict";var t=e.i(924868),a=e.i(522734),n=e.i(814747),s=e.i(446786),r=e.i(319668),i=e.i(990294);let l=n.default.join(s.default.homedir(),".purplemux","stats"),o=n.default.join(l,"cache.json"),u=n.default.join(s.default.homedir(),".claude","projects"),c=async()=>{let e=[];try{for(let a of(await t.default.readdir(u))){let s=n.default.join(u,a),r=await t.default.stat(s).catch(()=>null);if(r?.isDirectory())for(let a of(await t.default.readdir(s).catch(()=>[])))a.endsWith(".jsonl")&&!/^agent-/.test(a)&&e.push(n.default.join(s,a))}}catch{}return e},d=async(e,t)=>{let n=new Map,s=new Map;try{let i=(0,a.createReadStream)(e,{encoding:"utf-8"});for await(let e of r.default.createInterface({input:i,crlfDelay:1/0}))if(e.trim())try{let a=JSON.parse(e),r=String(a.timestamp??"");if(!r)continue;let i=r.slice(0,10);if(!t.has(i))continue;let l=String(a.type??"");if("user"!==l&&"assistant"!==l)continue;let o=String(a.sessionId??""),u=String(new Date(r).getHours()),c=n.get(i);c||(c={messageCount:0,sessionCount:0,toolCallCount:0,hourCounts:{},modelTokens:{},sessions:[]},n.set(i,c),s.set(i,new Map));let d=s.get(i);if("user"===l&&(c.messageCount++,c.hourCounts[u]=(c.hourCounts[u]??0)+1,o)){let e=d.get(o);e?(e.messages++,r>e.end&&(e.end=r),r<e.start&&(e.start=r)):d.set(o,{start:r,end:r,messages:1})}if("assistant"===l){let e=a.message;if(!e)continue;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length;c.toolCallCount+=e}let n=String(e.model??""),s=e.usage;if(n&&!n.startsWith("<")&&s){c.modelTokens[n]||(c.modelTokens[n]={input:0,output:0,cacheRead:0,cacheCreation:0});let e=c.modelTokens[n];e.input+=Number(s.input_tokens??0),e.output+=Number(s.output_tokens??0),e.cacheRead+=Number(s.cache_read_input_tokens??0),e.cacheCreation+=Number(s.cache_creation_input_tokens??0)}if(o){let e=d.get(o);e?(r>e.end&&(e.end=r),r<e.start&&(e.start=r)):d.set(o,{start:r,end:r,messages:0})}}}catch{}}catch{}for(let[e,t]of s){let a=n.get(e);a&&(a.sessionCount=t.size,a.sessions=Array.from(t.entries()).map(([e,t])=>({id:e,start:t.start,end:t.end,messages:t.messages})))}return n},m=async(e,t)=>{let a=[],n=0,s=async()=>{for(;n<e.length;){let t=n++;a[t]=await e[t]()}},r=Array.from({length:Math.min(t,e.length)},()=>s());return await Promise.all(r),a},p=(e,t)=>{for(let[a,n]of(e.messageCount+=t.messageCount,e.toolCallCount+=t.toolCallCount,Object.entries(t.hourCounts)))e.hourCounts[a]=(e.hourCounts[a]??0)+n;for(let[a,n]of Object.entries(t.modelTokens)){e.modelTokens[a]||(e.modelTokens[a]={input:0,output:0,cacheRead:0,cacheCreation:0});let t=e.modelTokens[a];t.input+=n.input,t.output+=n.output,t.cacheRead+=n.cacheRead,t.cacheCreation+=n.cacheCreation}let a=new Set(e.sessions.map(e=>e.id));for(let n of t.sessions)if(a.has(n.id)){let t=e.sessions.find(e=>e.id===n.id);t.messages+=n.messages,n.start<t.start&&(t.start=n.start),n.end>t.end&&(t.end=n.end)}else e.sessions.push(n);e.sessionCount=e.sessions.length},f=async()=>{try{let e=await t.default.readFile(o,"utf-8"),a=JSON.parse(e);if(1!==a.version)return null;return a}catch{return null}},h=async e=>{await t.default.mkdir(l,{recursive:!0}),await t.default.writeFile(o,JSON.stringify(e),"utf-8")},g=null,y=async e=>{try{let t=(0,a.createReadStream)(e,{encoding:"utf-8"});for await(let e of r.default.createInterface({input:t,crlfDelay:1/0}))if(e.trim())try{let t=JSON.parse(e),a=String(t.timestamp??"");if(a)return a.slice(0,10)}catch{}}catch{}return null},w=async()=>{let e=await c();if(0===e.length)return null;let t=e.map(e=>()=>y(e)),a=(await m(t,10)).filter(e=>null!==e);return 0===a.length?null:(a.sort(),a[0])},S=async e=>{if(0===e.size)return new Map;let t=(await c()).map(t=>()=>d(t,e)),a=await m(t,10),n=new Map;for(let e of a)for(let[t,a]of e){let e=n.get(t);e?p(e,a):n.set(t,a)}return n},x=async()=>{if(g&&Date.now()<g.expiresAt)return g.data;let e=(0,i.default)().subtract(1,"day").format("YYYY-MM-DD"),t=(0,i.default)().format("YYYY-MM-DD"),a=await f(),n=new Set;if(n.add(t),a){if(a.lastComputedDate<e){let t=(0,i.default)(a.lastComputedDate).add(1,"day"),s=(0,i.default)(e);for(;t.isBefore(s)||t.isSame(s);){let e=t.format("YYYY-MM-DD");a.days[e]||n.add(e),t=t.add(1,"day")}}}else{a={version:1,lastComputedDate:"",days:{}};let s=await w();if(!s)return C(a,t);let r=(0,i.default)(s),l=(0,i.default)(e);for(;r.isBefore(l)||r.isSame(l);)n.add(r.format("YYYY-MM-DD")),r=r.add(1,"day")}let s=await S(n);for(let[e,n]of s)e!==t&&(a.days[e]=n);a.lastComputedDate=e,await h(a);let r=s.get(t)??null,l=C(a,t,r);return g={data:l,expiresAt:Date.now()+3e5},l},C=(e,t,a)=>{let n=[],s=[],r={},i={},l={},o=0,u=0,c="",d={sessionId:"",duration:0,messageCount:0,timestamp:""},m=Object.entries(e.days);for(let[e,p]of(a&&m.push([t,a]),m.sort((e,t)=>e[0].localeCompare(t[0])),m)){!c&&p.messageCount>0&&(c=e),n.push({date:e,messageCount:p.messageCount,sessionCount:p.sessionCount,toolCallCount:p.toolCallCount});let t={};for(let[e,a]of Object.entries(p.modelTokens)){t[e]={input:a.input,output:a.output,cacheRead:a.cacheRead,cacheCreation:a.cacheCreation},r[e]||(r[e]={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,webSearchRequests:0,costUSD:0,contextWindow:0,maxOutputTokens:0});let n=r[e];n.inputTokens+=a.input,n.outputTokens+=a.output,n.cacheReadInputTokens+=a.cacheRead,n.cacheCreationInputTokens+=a.cacheCreation}s.push({date:e,tokensByModel:t});let a=new Date(e).getDay();for(let[e,t]of Object.entries(p.hourCounts)){i[e]=(i[e]??0)+t;let n=`${a}-${e}`;l[n]=(l[n]??0)+t}for(let e of(o+=p.sessionCount,u+=p.messageCount,p.sessions)){let t=new Date(e.end).getTime()-new Date(e.start).getTime();t>d.duration&&(d={sessionId:e.id,duration:t,messageCount:e.messages,timestamp:e.start})}}return{version:1,lastComputedDate:t,dailyActivity:n,dailyModelTokens:s,modelUsage:r,totalSessions:o,totalMessages:u,longestSession:d,firstSessionDate:c,hourCounts:i,dayHourCounts:l,totalSpeculationTimeSavedMs:0}};e.s(["collectJsonlFiles",0,c,"getStatsCache",0,x])},7991,e=>{"use strict";var t=e.i(924868),a=e.i(814747),n=e.i(446786),s=e.i(522734),r=e.i(319668),i=e.i(233405),l=e.i(713915),o=e.i(177579);let u=a.default.join(n.default.homedir(),".purplemux","stats","daily-reports"),c=async()=>{let e={};try{for(let n of(await t.default.readdir(u)))if(n.endsWith(".json"))try{let s=await t.default.readFile(a.default.join(u,n),"utf-8"),r=JSON.parse(s);r.date&&r.brief&&(e[r.date]=r)}catch{}}catch{}return e},d=async e=>{await t.default.mkdir(u,{recursive:!0}),await t.default.writeFile(a.default.join(u,`${e.date}.json`),JSON.stringify(e,null,2),"utf-8")},m=e=>{let t=n.default.homedir();return(e.startsWith(t)?e.slice(t.length+1):e).replace(/^Workspace\/github\.com\//g,"").replace(/^Workspace\/gitlab\.kolonfnc\.com\//g,"gitlab/").replace(/^Documents\//g,"docs/").replace(/^Downloads/g,"Downloads")},p=async e=>{let t=await (0,o.collectJsonlFiles)(),n=[];for(let i of t){let t=[],l=[],o=0,u="";try{let a=(0,s.createReadStream)(i,{encoding:"utf-8"});for await(let n of r.default.createInterface({input:a,crlfDelay:1/0}))if(n.trim())try{let a=JSON.parse(n),s=String(a.timestamp??"");if(!s.startsWith(e))continue;l.push(s);let r=String(a.type??"");if(u||"string"!=typeof a.cwd||(u=a.cwd),"user"===r){let e=a.message;if(!e)continue;let n=e.content,r="";if("string"==typeof n)r=n.slice(0,300);else if(Array.isArray(n)){let e=[];for(let t of n)"object"==typeof t&&null!==t&&"text"===t.type&&e.push(String(t.text??"").slice(0,300));r=e.join(" | ")}if(r.includes("<command-message>")){let e=r.match(/<command-name>\/([^<]+)<\/command-name>/);r=`[Command: ${e?e[1]:"unknown"}]`}if(r.includes("<local-command-caveat>")||r.includes("<task-notification>"))continue;r.trim()&&t.push({time:s.slice(11,16),text:r.slice(0,200)})}if("assistant"===r){let e=a.message;if(!e)continue;let t=e.content;Array.isArray(t)&&(o+=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length)}}catch{}}catch{}if(l.length>0&&t.length>0){let e=u?m(u):a.default.basename(a.default.dirname(i));n.push({project:e,start:Math.min(...l.map(e=>new Date(e).getTime())).toString(),msgCount:t.length,toolCount:o,firstMessage:t[0].text})}}return n.sort((e,t)=>Number(e.start)-Number(t.start)),n},f=async(e,t)=>{let a=await (0,l.getShellPath)();return new Promise((n,s)=>{let r=(0,i.execFile)("claude",["-p"],{timeout:12e4,maxBuffer:1048576,env:{...process.env,PATH:a}},(e,t)=>{e?s(Error(`claude -p failed: ${e.message}`)):n(t.trim())});r.stdin?.write(`${t}
|
|
2
2
|
|
|
3
|
-
${e}`),r.stdin?.end()})},h=async(e,t=!1)=>{var
|
|
3
|
+
${e}`),r.stdin?.end()})},h={en:"English",ko:"Korean (한국어)",ja:"Japanese (日本語)","zh-CN":"Simplified Chinese (简体中文)","zh-TW":"Traditional Chinese (繁體中文)",de:"German (Deutsch)",es:"Spanish (Español)",fr:"French (Français)","pt-BR":"Brazilian Portuguese (Português do Brasil)",ru:"Russian (Русский)",tr:"Turkish (Türkçe)"},g=async(e,t=!1,a="en")=>{var n,s;let r,i,l;if(!t){let t=await y(e);if(t&&t.locale===a)return t}let o=await p(e);if(0===o.length){let t={date:e,brief:"No activity recorded.",detail:"",generatedAt:new Date().toISOString(),locale:a};return await d(t),t}let u=o.map(e=>{let t=new Date(Number(e.start)).toTimeString().slice(0,5);return`[${t}] [${e.project}] msgs=${e.msgCount}, tools=${e.toolCount} | ${e.firstMessage}`}).join("\n"),{brief:c,detail:m}=(i=(s=await f(u,(n=e,r=h[a]??h.en,`Summarize the Claude session history for ${n}.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Output format (use exactly this structure):
|
|
6
6
|
|
|
7
7
|
[BRIEF]
|
|
8
|
-
|
|
8
|
+
A 2-3 line summary of the entire day. Use terse noun-form phrases. Plain text only. No markdown headings (#) or separators (---).
|
|
9
9
|
|
|
10
10
|
[DETAIL]
|
|
11
|
-
##
|
|
12
|
-
###
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
###
|
|
16
|
-
-
|
|
11
|
+
## Project Name
|
|
12
|
+
### Major Feature / Area
|
|
13
|
+
- One-line task summary
|
|
14
|
+
- One-line task summary
|
|
15
|
+
### Another Feature / Area
|
|
16
|
+
- One-line task summary
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- [BRIEF]
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- WHAT
|
|
25
|
-
-
|
|
26
|
-
-
|
|
18
|
+
Rules:
|
|
19
|
+
- The [BRIEF] and [DETAIL] tags must each appear exactly once, at the start of a line.
|
|
20
|
+
- Do not insert meta text outside the tags (separators, numbering, explanations).
|
|
21
|
+
- Always include the "## Project Name" heading, even when there is only one project.
|
|
22
|
+
- Each item is a single line — no filenames, no code snippets.
|
|
23
|
+
- Use terse noun-form phrases (e.g. "Fix login logic", "Improve mobile layout"). Avoid finished-sentence / past-tense forms.
|
|
24
|
+
- Focus on WHAT, not HOW.
|
|
25
|
+
- Skip trivial chatter (greetings, one-off questions, commit commands).
|
|
26
|
+
- IMPORTANT: Write ALL brief and detail content in ${r}. Keep the [BRIEF] / [DETAIL] tags and markdown syntax (##, ###, -) as-is in English.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Data:`))).match(/\[BRIEF\]\s*\n([\s\S]*?)(?=\[DETAIL\])/),l=s.match(/\[DETAIL\]\s*\n([\s\S]*?)$/),{brief:i?i[1].replace(/[\s#\-]*$/,"").trim():s.slice(0,500),detail:l?l[1].trim():""}),g={date:e,brief:c,detail:m,generatedAt:new Date().toISOString(),locale:a};return await d(g),g},y=async e=>{try{let n=await t.default.readFile(a.default.join(u,`${e}.json`),"utf-8"),s=JSON.parse(n);return s.date&&s.brief?s:null}catch{return null}};e.s(["generateDailyReport",0,g,"readAllCachedReports",0,c,"shortenCwd",0,m])}];
|
|
29
29
|
|
|
30
30
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0hls3o-._.js.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module.exports=[522734,(t,e,n)=>{e.exports=t.x("fs",()=>require("fs"))},270406,(t,e,n)=>{e.exports=t.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},814747,(t,e,n)=>{e.exports=t.x("path",()=>require("path"))},446786,(t,e,n)=>{e.exports=t.x("os",()=>require("os"))},924868,(t,e,n)=>{e.exports=t.x("fs/promises",()=>require("fs/promises"))},130146,(t,e,n)=>{e.exports=t.x("pino-28069d5257187539",()=>require("pino-28069d5257187539"))},666680,(t,e,n)=>{e.exports=t.x("node:crypto",()=>require("node:crypto"))},224361,(t,e,n)=>{e.exports=t.x("util",()=>require("util"))},233405,(t,e,n)=>{e.exports=t.x("child_process",()=>require("child_process"))},25146,t=>{"use strict";var e=t.i(130146),n=t.i(814747),a=t.i(446786);let r=n.default.join(a.default.homedir(),".purplemux","logs"),s=process.env.LOG_LEVEL||"info",i=(t=>{if(!t)return{};let e={};for(let n of t.split(",")){let[t,a]=n.split("=").map(t=>t.trim());t&&a&&(e[t]=a)}return e})(process.env.LOG_LEVELS),u=["trace","debug","info","warn","error","fatal"],o=globalThis;if(!o.__ptRootLogger){let t=[s,...Object.values(i)].reduce((t,e)=>u.indexOf(e)<u.indexOf(t)?e:t,"fatal");o.__ptRootLogger=(0,e.default)({level:t,transport:{targets:[{target:"pino-roll",level:t,options:{file:n.default.join(r,"purplemux"),frequency:"daily",dateFormat:"yyyy-MM-dd",limit:{count:7},mkdir:!0}},{target:"pino-pretty",level:t,options:{colorize:!0,ignore:"pid,hostname,module",translateTime:"HH:MM:ss",messageFormat:"[{module}] {msg}"}}]}})}let l=o.__ptRootLogger;t.s(["createLogger",0,t=>{let e=l.child({module:t});return e.level=i[t]??s,e}])},44014,t=>{"use strict";let e,n;var a=t.i(666680);t.s(["nanoid",0,function(t=21){var r;r=t|=0,!e||e.length<r?(e=Buffer.allocUnsafe(128*r),a.webcrypto.getRandomValues(e),n=0):n+r>e.length&&(a.webcrypto.getRandomValues(e),n=0),n+=r;let s="";for(let a=n-t;a<n;a++)s+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&e[a]];return s}],44014)},459015,544538,t=>{"use strict";var e=t.i(233405),n=t.i(924868),a=t.i(224361),r=t.i(814747),s=t.i(44014),i=t.i(25146);process.platform;let u="linux"===process.platform;t.s(["isLinux",0,u],544538);let o=(0,i.createLogger)("terminal"),l=(0,a.promisify)(e.execFile),c="purple",d=r.default.join(process.env.__PMUX_APP_DIR_UNPACKED||process.env.__PMUX_APP_DIR||process.cwd(),"src","config","tmux.conf"),f=new Set(["AUTH_PASSWORD","NEXTAUTH_SECRET"]),m=()=>Object.fromEntries(Object.entries(process.env).filter(([t])=>!t.startsWith("npm_")&&!t.startsWith("NODE_")&&!f.has(t))),h=async()=>{try{let{stdout:t}=await l("tmux",["-L",c,"ls","-F","#{session_name}"],{timeout:5e3});return t.trim().split("\n").map(t=>t.trim()).filter(t=>t.startsWith("pt-"))}catch{return[]}},p=async(t,e,n,a)=>{let r=process.env.SHELL||"/bin/zsh";await l("tmux",["-u","-L",c,"-f",d,"new-session","-d","-s",t,"-x",String(e),"-y",String(n)],{timeout:5e3,env:{...m(),SHELL:r,TERM:"xterm-256color",COLORTERM:"truecolor"},cwd:a||process.env.HOME||"/"}),await D(),o.debug(`tmux session created: ${t} (cols: ${e}, rows: ${n})`)},y=t=>new Promise(e=>setTimeout(e,t)),g=async t=>{if(!await w(t))return;o.debug(`killSession start: ${t}`);let e=await x(t);if(e)try{o.debug(`SIGTERM → process group ${e}: ${t}`),process.kill(-e,"SIGTERM")}catch{}try{await l("tmux",["-L",c,"kill-session","-t",t],{timeout:5e3})}catch{}for(let e=0;e<5;e++){if(!await w(t))return void o.debug(`killSession done (SIGTERM): ${t}`);await y(200)}if(o.warn(`session survived SIGTERM, escalating to SIGKILL: ${t}`),e)try{o.debug(`SIGKILL → process group ${e}: ${t}`),process.kill(-e,"SIGKILL")}catch{}try{await l("tmux",["-L",c,"kill-session","-t",t],{timeout:5e3})}catch{}for(let e=0;e<3;e++){if(!await w(t))return void o.debug(`killSession done (SIGKILL): ${t}`);await y(200)}o.warn(`tmux session still alive after kill: ${t}`)},w=async t=>{try{return await l("tmux",["-L",c,"has-session","-t",t],{timeout:5e3}),!0}catch{return!1}},$=async()=>{},S=async()=>{await $();let t=await h();t.length>0&&t.forEach(t=>{o.debug(`existing tmux session found: ${t}`)})},v=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"display-message","-p","-t",t,"#{pane_current_path}"],{timeout:5e3});return e.trim()||null}catch{return null}},x=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"display-message","-p","-t",t,"#{pane_pid}"],{timeout:5e3}),n=parseInt(e.trim(),10);return Number.isNaN(n)?null:n}catch{return null}},D=async()=>{try{await l("tmux",["-L",c,"source-file",d],{timeout:5e3})}catch{}},C=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"list-panes","-t",t,"-F","#{pane_current_command}"],{timeout:5e3});return e.trim()||null}catch{return null}},M=async()=>{try{let{stdout:t}=await l("tmux",["-L",c,"list-panes","-a","-F","#{session_name} #{pane_current_command} #{pane_current_path} #{pane_pid} #{window_activity}"],{timeout:5e3}),e=new Map;for(let n of t.trim().split("\n")){if(!n)continue;let[t,a,r,s,i]=n.split(" ");if(t&&a){let n=parseInt(s,10),u=parseInt(i,10);e.set(t,{command:a,path:r||"",pid:Number.isNaN(n)?0:n,windowActivity:Number.isNaN(u)?0:u})}}return e}catch{return new Map}},b=new Set(["bash","zsh","fish","sh","dash"]),_=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"display-message","-p","-t",t,"#{pane_title}"],{timeout:5e3});return e.trim()||null}catch{return null}},L=async t=>{await l("tmux",["-L",c,"copy-mode","-q","-t",t],{timeout:5e3}).catch(()=>{})},T=async(t,e)=>{await L(t),await l("tmux",["-L",c,"send-keys","-t",t,e,"Enter"],{timeout:5e3})},k=async(t,e)=>{await L(t),await l("tmux",["-L",c,"send-keys","-t",t,e],{timeout:5e3})},I=async(t,e)=>{await L(t),await l("tmux",["-L",c,"send-keys","-t",t,"-l",`\x1b[200~${e}\x1b[201~`],{timeout:5e3}),await l("tmux",["-L",c,"send-keys","-t",t,"Enter"],{timeout:5e3}),await new Promise(t=>setTimeout(t,600)),await l("tmux",["-L",c,"send-keys","-t",t,"Enter"],{timeout:5e3})},O=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"display-message","-p","-t",t,"#{pane_current_path} #{pane_current_command} #{pane_pid} #{pane_width} #{pane_height} #{session_created}"],{timeout:5e3}),[n,a,r,s,i,u]=e.trim().split(" ");return{cwd:n||null,command:a||null,pid:r&&parseInt(r,10)||null,width:s&&parseInt(s,10)||null,height:i&&parseInt(i,10)||null,sessionCreated:u&&parseInt(u,10)||null}}catch{return{cwd:null,command:null,pid:null,width:null,height:null,sessionCreated:null}}},A=new Set(["node","python","python3","ruby","perl","deno","bun"]),j=async()=>{try{await l("tmux",["-L",c,"kill-server"],{timeout:5e3}),o.debug("tmux server killed")}catch{}},E=async t=>{try{let{stdout:e}=await l("tmux",["-L",c,"capture-pane","-p","-t",t],{timeout:5e3});return e}catch{return null}},N=async(t,e)=>{try{let{stdout:n}=await l("tmux",["-L",c,"capture-pane","-p","-S",`-${e}`,"-t",t],{timeout:5e3});return n}catch{return null}},R=async t=>{if(u){let e=[];return await Promise.all(t.map(async t=>{try{for(let a of(await n.default.readFile(`/proc/${t}/task/${t}/children`,"utf-8")).trim().split(/\s+/)){let t=parseInt(a,10);Number.isNaN(t)||e.push(t)}}catch{}})),e}try{let{stdout:e}=await l("pgrep",["-P",t.join(",")],{timeout:5e3});return e.trim().split("\n").map(t=>parseInt(t,10)).filter(t=>!Number.isNaN(t))}catch{return[]}},P=async t=>{let e=[],n=[t];for(;n.length>0;){let t=await R(n);if(0===t.length)break;e.push(...t),n=t}return e},H=async t=>{try{let e=new Set(t),{stdout:n}=await l("ss",["-tlnp"],{timeout:5e3}),a=new Set;for(let t of n.split("\n")){let n=t.match(/pid=(\d+)/g);if(!n||!n.some(t=>e.has(parseInt(t.replace("pid=",""),10))))continue;let r=t.match(/:(\d+)\s/);r&&a.add(parseInt(r[1],10))}return[...a].sort((t,e)=>t-e)}catch{return[]}},Y=async t=>{let e=await P(t);if(0===e.length)return[];if(u)return H(e);try{let{stdout:t}=await l("lsof",["-a","-p",e.join(","),"-i","-sTCP:LISTEN","-P","-Fn"],{timeout:5e3}),n=new Set;for(let e of t.split("\n"))if(e.startsWith("n")){let t=e.match(/:(\d+)$/);t&&n.add(parseInt(t[1],10))}return[...n].sort((t,e)=>t-e)}catch{return[]}},F=async t=>{let e=await x(t);if(!e)return null;try{let{stdout:t}=await l("pgrep",["-n","-P",String(e)],{timeout:5e3}),n=t.trim();if(!n)return null;let{stdout:a}=await l("ps",["-o","args=","-p",n],{timeout:5e3}),s=a.trim();if(!s)return null;let i=s.split(/\s+/);if(0===i.length)return s;if(i[0]=r.default.basename(i[0]),A.has(i[0])&&i.length>1){let t=r.default.basename(i[1]).replace(/\.(c|m)?js$/,"");i.splice(0,2,t)}return i.join(" ")}catch{return null}};t.s(["SAFE_SHELLS",0,b,"applyConfig",0,D,"capturePaneContent",0,E,"capturePaneContentWithHistory",0,N,"createSession",0,p,"defaultSessionName",0,()=>`pt-${(0,s.nanoid)(6)}-${(0,s.nanoid)(6)}-${(0,s.nanoid)(6)}`,"exitCopyMode",0,L,"getAllPanesInfo",0,M,"getLastCommand",0,F,"getListeningPorts",0,Y,"getPaneCurrentCommand",0,C,"getPaneDetailInfo",0,O,"getPaneTitle",0,_,"getSessionCwd",0,v,"getSessionPanePid",0,x,"hasSession",0,w,"killServer",0,j,"killSession",0,g,"listSessions",0,h,"sanitizedEnv",0,m,"scanSessions",0,S,"sendBracketedPaste",0,I,"sendKeys",0,T,"sendRawKeys",0,k,"workspaceSessionName",0,(t,e,n)=>`pt-${t}-${e}-${n}`],459015)},713915,t=>{"use strict";var e=t.i(233405),n=t.i(924868),a=t.i(446786),r=t.i(814747),s=t.i(224361),i=t.i(459015);let u=(0,s.promisify)(e.execFile),o=null,l=null,c=async()=>{let t=a.default.userInfo().shell||process.env.SHELL||"/bin/bash";try{let{stdout:e}=await u(t,["-ilc",'echo -n "$PATH"'],{timeout:5e3,env:{...(0,i.sanitizedEnv)(),SHELL:t,DISABLE_AUTO_UPDATE:"true",ZSH_TMUX_AUTOSTARTED:"true",TERM:"xterm-256color",COLORTERM:"truecolor"}});return e.toString().trim()}catch{return process.env.PATH||""}},d=async()=>o||(l||(l=c().then(t=>(o=t,l=null,t))),l),f=async(t,e,n)=>{try{let a=await d(),{stdout:r}=await u(t,e,{timeout:5e3,env:{...process.env,PATH:a}});return{installed:!0,version:n(r)}}catch{return{installed:!1,version:null}}},m=t=>t.trim().match(/(\d+\.\d+[\d.]*)/)?.[1]??null,h=[r.default.join(a.default.homedir(),".local","bin")],p=async()=>{for(let t of h)try{return await (0,n.access)(r.default.join(t,"claude")),t}catch{}return null},y=t=>t.installed&&null!==t.version&&parseFloat(t.version)>=2.9,g=async()=>{o=await c();let[t,e,s]=await Promise.all([f("tmux",["-V"],m),f("git",["--version"],m),f("claude",["--version"],m)]),i=(y(t)&&e.installed&&s.installed,s.installed?null:await p()),u=!1;if(s.installed||i)try{await (0,n.access)(r.default.join(a.default.homedir(),".claude")),u=!0}catch{}return{tmux:{...t,compatible:y(t)},git:e,claude:{...s,binaryPath:i,loggedIn:u}}},w=null,$=null,S=async()=>{o=await c();let[t,e,n]=await Promise.all([f("tmux",["-V"],m),f("git",["--version"],m),f("claude",["--version"],m)]);return{tmux:{...t,compatible:y(t)},git:e,claude:n}},v=async()=>w&&Date.now()-w.checkedAt<3e4?w.result:$||($=S().then(t=>(w={result:t,checkedAt:Date.now()},$=null,t)).catch(t=>{throw $=null,t}));t.s(["getCachedRuntimePreflight",0,v,"getPreflightStatus",0,g,"getShellPath",0,d,"invalidateRuntimeCache",0,()=>{w=null,$=null}])},319668,(t,e,n)=>{e.exports=t.x("readline",()=>require("readline"))},990294,(t,e,n)=>{t.e,e.exports=function(){"use strict";var t="millisecond",e="second",n="minute",a="hour",r="week",s="month",i="quarter",u="year",o="date",l="Invalid Date",c=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=function(t,e,n){var a=String(t);return!a||a.length>=e?t:""+Array(e+1-a.length).join(n)+t},m="en",h={};h[m]={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}};var p="$isDayjsObject",y=function(t){return t instanceof S||!(!t||!t[p])},g=function t(e,n,a){var r;if(!e)return m;if("string"==typeof e){var s=e.toLowerCase();h[s]&&(r=s),n&&(h[s]=n,r=s);var i=e.split("-");if(!r&&i.length>1)return t(i[0])}else{var u=e.name;h[u]=e,r=u}return!a&&r&&(m=r),r||!a&&m},w=function(t,e){if(y(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new S(n)},$={s:f,z:function(t){var e=-t.utcOffset(),n=Math.abs(e);return(e<=0?"+":"-")+f(Math.floor(n/60),2,"0")+":"+f(n%60,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var a=12*(n.year()-e.year())+(n.month()-e.month()),r=e.clone().add(a,s),i=n-r<0,u=e.clone().add(a+(i?-1:1),s);return+(-(a+(n-r)/(i?r-u:u-r))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(l){return({M:s,y:u,w:r,d:"day",D:o,h:a,m:n,s:e,ms:t,Q:i})[l]||String(l||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}};$.l=g,$.i=y,$.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var S=function(){function f(t){this.$L=g(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=f.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if($.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var a=e.match(c);if(a){var r=a[2]-1||0,s=(a[7]||"0").substring(0,3);return n?new Date(Date.UTC(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,s)):new Date(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return $},m.isValid=function(){return this.$d.toString()!==l},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return $.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,i){var l=this,c=!!$.u(i)||i,d=$.p(t),f=function(t,e){var n=$.w(l.$u?Date.UTC(l.$y,e,t):new Date(l.$y,e,t),l);return c?n:n.endOf("day")},m=function(t,e){return $.w(l.toDate()[t].apply(l.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),l)},h=this.$W,p=this.$M,y=this.$D,g="set"+(this.$u?"UTC":"");switch(d){case u:return c?f(1,0):f(31,11);case s:return c?f(1,p):f(0,p+1);case r:var w=this.$locale().weekStart||0,S=(h<w?h+7:h)-w;return f(c?y-S:y+(6-S),p);case"day":case o:return m(g+"Hours",0);case a:return m(g+"Minutes",1);case n:return m(g+"Seconds",2);case e:return m(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(r,i){var l,c=$.p(r),d="set"+(this.$u?"UTC":""),f=((l={}).day=d+"Date",l[o]=d+"Date",l[s]=d+"Month",l[u]=d+"FullYear",l[a]=d+"Hours",l[n]=d+"Minutes",l[e]=d+"Seconds",l[t]=d+"Milliseconds",l)[c],m="day"===c?this.$D+(i-this.$W):i;if(c===s||c===u){var h=this.clone().set(o,1);h.$d[f](m),h.init(),this.$d=h.set(o,Math.min(this.$D,h.daysInMonth())).$d}else f&&this.$d[f](m);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[$.p(t)]()},m.add=function(t,i){var o,l=this;t=Number(t);var c=$.p(i),d=function(e){var n=w(l);return $.w(n.date(n.date()+Math.round(e*t)),l)};if(c===s)return this.set(s,this.$M+t);if(c===u)return this.set(u,this.$y+t);if("day"===c)return d(1);if(c===r)return d(7);var f=((o={})[n]=6e4,o[a]=36e5,o[e]=1e3,o)[c]||1,m=this.$d.getTime()+t*f;return $.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var a=t||"YYYY-MM-DDTHH:mm:ssZ",r=$.z(this),s=this.$H,i=this.$m,u=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,m=function(t,n,r,s){return t&&(t[n]||t(e,a))||r[n].slice(0,s)},h=function(t){return $.s(s%12||12,t,"0")},p=f||function(t,e,n){var a=t<12?"AM":"PM";return n?a.toLowerCase():a};return a.replace(d,function(t,a){return a||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return $.s(e.$y,4,"0");case"M":return u+1;case"MM":return $.s(u+1,2,"0");case"MMM":return m(n.monthsShort,u,c,3);case"MMMM":return m(c,u);case"D":return e.$D;case"DD":return $.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return m(n.weekdaysMin,e.$W,o,2);case"ddd":return m(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return $.s(s,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return p(s,i,!0);case"A":return p(s,i,!1);case"m":return String(i);case"mm":return $.s(i,2,"0");case"s":return String(e.$s);case"ss":return $.s(e.$s,2,"0");case"SSS":return $.s(e.$ms,3,"0");case"Z":return r}return null}(t)||r.replace(":","")})},m.utcOffset=function(){return-(15*Math.round(this.$d.getTimezoneOffset()/15))},m.diff=function(t,o,l){var c,d=this,f=$.p(o),m=w(t),h=(m.utcOffset()-this.utcOffset())*6e4,p=this-m,y=function(){return $.m(d,m)};switch(f){case u:c=y()/12;break;case s:c=y();break;case i:c=y()/3;break;case r:c=(p-h)/6048e5;break;case"day":c=(p-h)/864e5;break;case a:c=p/36e5;break;case n:c=p/6e4;break;case e:c=p/1e3;break;default:c=p}return l?c:$.a(c)},m.daysInMonth=function(){return this.endOf(s).$D},m.$locale=function(){return h[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),a=g(t,e,!0);return a&&(n.$L=a),n},m.clone=function(){return $.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},f}(),v=S.prototype;return w.prototype=v,[["$ms",t],["$s",e],["$m",n],["$H",a],["$W","day"],["$M",s],["$y",u],["$D",o]].forEach(function(t){v[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),w.extend=function(t,e){return t.$i||(t(e,S,w),t.$i=!0),w},w.locale=g,w.isDayjs=y,w.unix=function(t){return w(1e3*t)},w.en=h[m],w.Ls=h,w.p={},w}()},177579,t=>{"use strict";var e=t.i(924868),n=t.i(522734),a=t.i(814747),r=t.i(446786),s=t.i(319668),i=t.i(990294);let u=a.default.join(r.default.homedir(),".purplemux","stats"),o=a.default.join(u,"cache.json"),l=a.default.join(r.default.homedir(),".claude","projects"),c=async()=>{let t=[];try{for(let n of(await e.default.readdir(l))){let r=a.default.join(l,n),s=await e.default.stat(r).catch(()=>null);if(s?.isDirectory())for(let n of(await e.default.readdir(r).catch(()=>[])))n.endsWith(".jsonl")&&!/^agent-/.test(n)&&t.push(a.default.join(r,n))}}catch{}return t},d=async(t,e)=>{let a=new Map,r=new Map;try{let i=(0,n.createReadStream)(t,{encoding:"utf-8"});for await(let t of s.default.createInterface({input:i,crlfDelay:1/0}))if(t.trim())try{let n=JSON.parse(t),s=String(n.timestamp??"");if(!s)continue;let i=s.slice(0,10);if(!e.has(i))continue;let u=String(n.type??"");if("user"!==u&&"assistant"!==u)continue;let o=String(n.sessionId??""),l=String(new Date(s).getHours()),c=a.get(i);c||(c={messageCount:0,sessionCount:0,toolCallCount:0,hourCounts:{},modelTokens:{},sessions:[]},a.set(i,c),r.set(i,new Map));let d=r.get(i);if("user"===u&&(c.messageCount++,c.hourCounts[l]=(c.hourCounts[l]??0)+1,o)){let t=d.get(o);t?(t.messages++,s>t.end&&(t.end=s),s<t.start&&(t.start=s)):d.set(o,{start:s,end:s,messages:1})}if("assistant"===u){let t=n.message;if(!t)continue;let e=t.content;if(Array.isArray(e)){let t=e.filter(t=>"object"==typeof t&&null!==t&&"tool_use"===t.type).length;c.toolCallCount+=t}let a=String(t.model??""),r=t.usage;if(a&&!a.startsWith("<")&&r){c.modelTokens[a]||(c.modelTokens[a]={input:0,output:0,cacheRead:0,cacheCreation:0});let t=c.modelTokens[a];t.input+=Number(r.input_tokens??0),t.output+=Number(r.output_tokens??0),t.cacheRead+=Number(r.cache_read_input_tokens??0),t.cacheCreation+=Number(r.cache_creation_input_tokens??0)}if(o){let t=d.get(o);t?(s>t.end&&(t.end=s),s<t.start&&(t.start=s)):d.set(o,{start:s,end:s,messages:0})}}}catch{}}catch{}for(let[t,e]of r){let n=a.get(t);n&&(n.sessionCount=e.size,n.sessions=Array.from(e.entries()).map(([t,e])=>({id:t,start:e.start,end:e.end,messages:e.messages})))}return a},f=async(t,e)=>{let n=[],a=0,r=async()=>{for(;a<t.length;){let e=a++;n[e]=await t[e]()}},s=Array.from({length:Math.min(e,t.length)},()=>r());return await Promise.all(s),n},m=(t,e)=>{for(let[n,a]of(t.messageCount+=e.messageCount,t.toolCallCount+=e.toolCallCount,Object.entries(e.hourCounts)))t.hourCounts[n]=(t.hourCounts[n]??0)+a;for(let[n,a]of Object.entries(e.modelTokens)){t.modelTokens[n]||(t.modelTokens[n]={input:0,output:0,cacheRead:0,cacheCreation:0});let e=t.modelTokens[n];e.input+=a.input,e.output+=a.output,e.cacheRead+=a.cacheRead,e.cacheCreation+=a.cacheCreation}let n=new Set(t.sessions.map(t=>t.id));for(let a of e.sessions)if(n.has(a.id)){let e=t.sessions.find(t=>t.id===a.id);e.messages+=a.messages,a.start<e.start&&(e.start=a.start),a.end>e.end&&(e.end=a.end)}else t.sessions.push(a);t.sessionCount=t.sessions.length},h=async()=>{try{let t=await e.default.readFile(o,"utf-8"),n=JSON.parse(t);if(1!==n.version)return null;return n}catch{return null}},p=async t=>{await e.default.mkdir(u,{recursive:!0}),await e.default.writeFile(o,JSON.stringify(t),"utf-8")},y=null,g=async t=>{try{let e=(0,n.createReadStream)(t,{encoding:"utf-8"});for await(let t of s.default.createInterface({input:e,crlfDelay:1/0}))if(t.trim())try{let e=JSON.parse(t),n=String(e.timestamp??"");if(n)return n.slice(0,10)}catch{}}catch{}return null},w=async()=>{let t=await c();if(0===t.length)return null;let e=t.map(t=>()=>g(t)),n=(await f(e,10)).filter(t=>null!==t);return 0===n.length?null:(n.sort(),n[0])},$=async t=>{if(0===t.size)return new Map;let e=(await c()).map(e=>()=>d(e,t)),n=await f(e,10),a=new Map;for(let t of n)for(let[e,n]of t){let t=a.get(e);t?m(t,n):a.set(e,n)}return a},S=async()=>{if(y&&Date.now()<y.expiresAt)return y.data;let t=(0,i.default)().subtract(1,"day").format("YYYY-MM-DD"),e=(0,i.default)().format("YYYY-MM-DD"),n=await h(),a=new Set;if(a.add(e),n){if(n.lastComputedDate<t){let e=(0,i.default)(n.lastComputedDate).add(1,"day"),r=(0,i.default)(t);for(;e.isBefore(r)||e.isSame(r);){let t=e.format("YYYY-MM-DD");n.days[t]||a.add(t),e=e.add(1,"day")}}}else{n={version:1,lastComputedDate:"",days:{}};let r=await w();if(!r)return v(n,e);let s=(0,i.default)(r),u=(0,i.default)(t);for(;s.isBefore(u)||s.isSame(u);)a.add(s.format("YYYY-MM-DD")),s=s.add(1,"day")}let r=await $(a);for(let[t,a]of r)t!==e&&(n.days[t]=a);n.lastComputedDate=t,await p(n);let s=r.get(e)??null,u=v(n,e,s);return y={data:u,expiresAt:Date.now()+3e5},u},v=(t,e,n)=>{let a=[],r=[],s={},i={},u={},o=0,l=0,c="",d={sessionId:"",duration:0,messageCount:0,timestamp:""},f=Object.entries(t.days);for(let[t,m]of(n&&f.push([e,n]),f.sort((t,e)=>t[0].localeCompare(e[0])),f)){!c&&m.messageCount>0&&(c=t),a.push({date:t,messageCount:m.messageCount,sessionCount:m.sessionCount,toolCallCount:m.toolCallCount});let e={};for(let[t,n]of Object.entries(m.modelTokens)){e[t]={input:n.input,output:n.output,cacheRead:n.cacheRead,cacheCreation:n.cacheCreation},s[t]||(s[t]={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,webSearchRequests:0,costUSD:0,contextWindow:0,maxOutputTokens:0});let a=s[t];a.inputTokens+=n.input,a.outputTokens+=n.output,a.cacheReadInputTokens+=n.cacheRead,a.cacheCreationInputTokens+=n.cacheCreation}r.push({date:t,tokensByModel:e});let n=new Date(t).getDay();for(let[t,e]of Object.entries(m.hourCounts)){i[t]=(i[t]??0)+e;let a=`${n}-${t}`;u[a]=(u[a]??0)+e}for(let t of(o+=m.sessionCount,l+=m.messageCount,m.sessions)){let e=new Date(t.end).getTime()-new Date(t.start).getTime();e>d.duration&&(d={sessionId:t.id,duration:e,messageCount:t.messages,timestamp:t.start})}}return{version:1,lastComputedDate:e,dailyActivity:a,dailyModelTokens:r,modelUsage:s,totalSessions:o,totalMessages:l,longestSession:d,firstSessionDate:c,hourCounts:i,dayHourCounts:u,totalSpeculationTimeSavedMs:0}};t.s(["collectJsonlFiles",0,c,"getStatsCache",0,S])},7991,t=>{"use strict";var e=t.i(924868),n=t.i(814747),a=t.i(446786),r=t.i(522734),s=t.i(319668),i=t.i(233405),u=t.i(713915),o=t.i(177579);let l=n.default.join(a.default.homedir(),".purplemux","stats","daily-reports"),c=async()=>{let t={};try{for(let a of(await e.default.readdir(l)))if(a.endsWith(".json"))try{let r=await e.default.readFile(n.default.join(l,a),"utf-8"),s=JSON.parse(r);s.date&&s.brief&&(t[s.date]=s)}catch{}}catch{}return t},d=async t=>{await e.default.mkdir(l,{recursive:!0}),await e.default.writeFile(n.default.join(l,`${t.date}.json`),JSON.stringify(t,null,2),"utf-8")},f=t=>{let e=a.default.homedir();return(t.startsWith(e)?t.slice(e.length+1):t).replace(/^Workspace\/github\.com\//g,"").replace(/^Workspace\/gitlab\.kolonfnc\.com\//g,"gitlab/").replace(/^Documents\//g,"docs/").replace(/^Downloads/g,"Downloads")},m=async t=>{let e=await (0,o.collectJsonlFiles)(),a=[];for(let i of e){let e=[],u=[],o=0,l="";try{let n=(0,r.createReadStream)(i,{encoding:"utf-8"});for await(let a of s.default.createInterface({input:n,crlfDelay:1/0}))if(a.trim())try{let n=JSON.parse(a),r=String(n.timestamp??"");if(!r.startsWith(t))continue;u.push(r);let s=String(n.type??"");if(l||"string"!=typeof n.cwd||(l=n.cwd),"user"===s){let t=n.message;if(!t)continue;let a=t.content,s="";if("string"==typeof a)s=a.slice(0,300);else if(Array.isArray(a)){let t=[];for(let e of a)"object"==typeof e&&null!==e&&"text"===e.type&&t.push(String(e.text??"").slice(0,300));s=t.join(" | ")}if(s.includes("<command-message>")){let t=s.match(/<command-name>\/([^<]+)<\/command-name>/);s=`[Command: ${t?t[1]:"unknown"}]`}if(s.includes("<local-command-caveat>")||s.includes("<task-notification>"))continue;s.trim()&&e.push({time:r.slice(11,16),text:s.slice(0,200)})}if("assistant"===s){let t=n.message;if(!t)continue;let e=t.content;Array.isArray(e)&&(o+=e.filter(t=>"object"==typeof t&&null!==t&&"tool_use"===t.type).length)}}catch{}}catch{}if(u.length>0&&e.length>0){let t=l?f(l):n.default.basename(n.default.dirname(i));a.push({project:t,start:Math.min(...u.map(t=>new Date(t).getTime())).toString(),msgCount:e.length,toolCount:o,firstMessage:e[0].text})}}return a.sort((t,e)=>Number(t.start)-Number(e.start)),a},h=async(t,e)=>{let n=await (0,u.getShellPath)();return new Promise((a,r)=>{let s=(0,i.execFile)("claude",["-p"],{timeout:12e4,maxBuffer:1048576,env:{...process.env,PATH:n}},(t,e)=>{t?r(Error(`claude -p failed: ${t.message}`)):a(e.trim())});s.stdin?.write(`${e}
|
|
1
|
+
module.exports=[522734,(e,t,n)=>{t.exports=e.x("fs",()=>require("fs"))},270406,(e,t,n)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},814747,(e,t,n)=>{t.exports=e.x("path",()=>require("path"))},446786,(e,t,n)=>{t.exports=e.x("os",()=>require("os"))},924868,(e,t,n)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},130146,(e,t,n)=>{t.exports=e.x("pino-28069d5257187539",()=>require("pino-28069d5257187539"))},666680,(e,t,n)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},224361,(e,t,n)=>{t.exports=e.x("util",()=>require("util"))},233405,(e,t,n)=>{t.exports=e.x("child_process",()=>require("child_process"))},25146,e=>{"use strict";var t=e.i(130146),n=e.i(814747),a=e.i(446786);let r=n.default.join(a.default.homedir(),".purplemux","logs"),s=process.env.LOG_LEVEL||"info",i=(e=>{if(!e)return{};let t={};for(let n of e.split(",")){let[e,a]=n.split("=").map(e=>e.trim());e&&a&&(t[e]=a)}return t})(process.env.LOG_LEVELS),o=["trace","debug","info","warn","error","fatal"],u=globalThis;if(!u.__ptRootLogger){let e=[s,...Object.values(i)].reduce((e,t)=>o.indexOf(t)<o.indexOf(e)?t:e,"fatal");u.__ptRootLogger=(0,t.default)({level:e,transport:{targets:[{target:"pino-roll",level:e,options:{file:n.default.join(r,"purplemux"),frequency:"daily",dateFormat:"yyyy-MM-dd",limit:{count:7},mkdir:!0}},{target:"pino-pretty",level:e,options:{colorize:!0,ignore:"pid,hostname,module",translateTime:"HH:MM:ss",messageFormat:"[{module}] {msg}"}}]}})}let l=u.__ptRootLogger;e.s(["createLogger",0,e=>{let t=l.child({module:e});return t.level=i[e]??s,t}])},44014,e=>{"use strict";let t,n;var a=e.i(666680);e.s(["nanoid",0,function(e=21){var r;r=e|=0,!t||t.length<r?(t=Buffer.allocUnsafe(128*r),a.webcrypto.getRandomValues(t),n=0):n+r>t.length&&(a.webcrypto.getRandomValues(t),n=0),n+=r;let s="";for(let a=n-e;a<n;a++)s+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return s}],44014)},459015,544538,e=>{"use strict";var t=e.i(233405),n=e.i(924868),a=e.i(224361),r=e.i(814747),s=e.i(44014),i=e.i(25146);process.platform;let o="linux"===process.platform;e.s(["isLinux",0,o],544538);let u=(0,i.createLogger)("terminal"),l=(0,a.promisify)(t.execFile),c="purple",d=r.default.join(process.env.__PMUX_APP_DIR_UNPACKED||process.env.__PMUX_APP_DIR||process.cwd(),"src","config","tmux.conf"),f=new Set(["AUTH_PASSWORD","NEXTAUTH_SECRET"]),m=()=>Object.fromEntries(Object.entries(process.env).filter(([e])=>!e.startsWith("npm_")&&!e.startsWith("NODE_")&&!f.has(e))),h=async()=>{try{let{stdout:e}=await l("tmux",["-L",c,"ls","-F","#{session_name}"],{timeout:5e3});return e.trim().split("\n").map(e=>e.trim()).filter(e=>e.startsWith("pt-"))}catch{return[]}},p=async(e,t,n,a)=>{let r=process.env.SHELL||"/bin/zsh";await l("tmux",["-u","-L",c,"-f",d,"new-session","-d","-s",e,"-x",String(t),"-y",String(n)],{timeout:5e3,env:{...m(),SHELL:r,TERM:"xterm-256color",COLORTERM:"truecolor"},cwd:a||process.env.HOME||"/"}),await D(),u.debug(`tmux session created: ${e} (cols: ${t}, rows: ${n})`)},y=e=>new Promise(t=>setTimeout(t,e)),g=async e=>{if(!await w(e))return;u.debug(`killSession start: ${e}`);let t=await x(e);if(t)try{u.debug(`SIGTERM → process group ${t}: ${e}`),process.kill(-t,"SIGTERM")}catch{}try{await l("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<5;t++){if(!await w(e))return void u.debug(`killSession done (SIGTERM): ${e}`);await y(200)}if(u.warn(`session survived SIGTERM, escalating to SIGKILL: ${e}`),t)try{u.debug(`SIGKILL → process group ${t}: ${e}`),process.kill(-t,"SIGKILL")}catch{}try{await l("tmux",["-L",c,"kill-session","-t",e],{timeout:5e3})}catch{}for(let t=0;t<3;t++){if(!await w(e))return void u.debug(`killSession done (SIGKILL): ${e}`);await y(200)}u.warn(`tmux session still alive after kill: ${e}`)},w=async e=>{try{return await l("tmux",["-L",c,"has-session","-t",e],{timeout:5e3}),!0}catch{return!1}},S=async()=>{},$=async()=>{await S();let e=await h();e.length>0&&e.forEach(e=>{u.debug(`existing tmux session found: ${e}`)})},v=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path}"],{timeout:5e3});return t.trim()||null}catch{return null}},x=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_pid}"],{timeout:5e3}),n=parseInt(t.trim(),10);return Number.isNaN(n)?null:n}catch{return null}},D=async()=>{try{await l("tmux",["-L",c,"source-file",d],{timeout:5e3})}catch{}},C=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"list-panes","-t",e,"-F","#{pane_current_command}"],{timeout:5e3});return t.trim()||null}catch{return null}},b=async()=>{try{let{stdout:e}=await l("tmux",["-L",c,"list-panes","-a","-F","#{session_name} #{pane_current_command} #{pane_current_path} #{pane_pid} #{window_activity}"],{timeout:5e3}),t=new Map;for(let n of e.trim().split("\n")){if(!n)continue;let[e,a,r,s,i]=n.split(" ");if(e&&a){let n=parseInt(s,10),o=parseInt(i,10);t.set(e,{command:a,path:r||"",pid:Number.isNaN(n)?0:n,windowActivity:Number.isNaN(o)?0:o})}}return t}catch{return new Map}},M=new Set(["bash","zsh","fish","sh","dash"]),_=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_title}"],{timeout:5e3});return t.trim()||null}catch{return null}},T=async e=>{await l("tmux",["-L",c,"copy-mode","-q","-t",e],{timeout:5e3}).catch(()=>{})},k=async(e,t)=>{await T(e),await l("tmux",["-L",c,"send-keys","-t",e,t,"Enter"],{timeout:5e3})},L=async(e,t)=>{await T(e),await l("tmux",["-L",c,"send-keys","-t",e,t],{timeout:5e3})},I=async(e,t)=>{await T(e),await l("tmux",["-L",c,"send-keys","-t",e,"-l",`\x1b[200~${t}\x1b[201~`],{timeout:5e3}),await l("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3}),await new Promise(e=>setTimeout(e,600)),await l("tmux",["-L",c,"send-keys","-t",e,"Enter"],{timeout:5e3})},O=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"display-message","-p","-t",e,"#{pane_current_path} #{pane_current_command} #{pane_pid} #{pane_width} #{pane_height} #{session_created}"],{timeout:5e3}),[n,a,r,s,i,o]=t.trim().split(" ");return{cwd:n||null,command:a||null,pid:r&&parseInt(r,10)||null,width:s&&parseInt(s,10)||null,height:i&&parseInt(i,10)||null,sessionCreated:o&&parseInt(o,10)||null}}catch{return{cwd:null,command:null,pid:null,width:null,height:null,sessionCreated:null}}},A=new Set(["node","python","python3","ruby","perl","deno","bun"]),E=async()=>{try{await l("tmux",["-L",c,"kill-server"],{timeout:5e3}),u.debug("tmux server killed")}catch{}},j=async e=>{try{let{stdout:t}=await l("tmux",["-L",c,"capture-pane","-p","-t",e],{timeout:5e3});return t}catch{return null}},N=async(e,t)=>{try{let{stdout:n}=await l("tmux",["-L",c,"capture-pane","-p","-S",`-${t}`,"-t",e],{timeout:5e3});return n}catch{return null}},R=async e=>{if(o){let t=[];return await Promise.all(e.map(async e=>{try{for(let a of(await n.default.readFile(`/proc/${e}/task/${e}/children`,"utf-8")).trim().split(/\s+/)){let e=parseInt(a,10);Number.isNaN(e)||t.push(e)}}catch{}})),t}try{let{stdout:t}=await l("pgrep",["-P",e.join(",")],{timeout:5e3});return t.trim().split("\n").map(e=>parseInt(e,10)).filter(e=>!Number.isNaN(e))}catch{return[]}},P=async e=>{let t=[],n=[e];for(;n.length>0;){let e=await R(n);if(0===e.length)break;t.push(...e),n=e}return t},F=async e=>{try{let t=new Set(e),{stdout:n}=await l("ss",["-tlnp"],{timeout:5e3}),a=new Set;for(let e of n.split("\n")){let n=e.match(/pid=(\d+)/g);if(!n||!n.some(e=>t.has(parseInt(e.replace("pid=",""),10))))continue;let r=e.match(/:(\d+)\s/);r&&a.add(parseInt(r[1],10))}return[...a].sort((e,t)=>e-t)}catch{return[]}},H=async e=>{let t=await P(e);if(0===t.length)return[];if(o)return F(t);try{let{stdout:e}=await l("lsof",["-a","-p",t.join(","),"-i","-sTCP:LISTEN","-P","-Fn"],{timeout:5e3}),n=new Set;for(let t of e.split("\n"))if(t.startsWith("n")){let e=t.match(/:(\d+)$/);e&&n.add(parseInt(e[1],10))}return[...n].sort((e,t)=>e-t)}catch{return[]}},Y=async e=>{let t=await x(e);if(!t)return null;try{let{stdout:e}=await l("pgrep",["-n","-P",String(t)],{timeout:5e3}),n=e.trim();if(!n)return null;let{stdout:a}=await l("ps",["-o","args=","-p",n],{timeout:5e3}),s=a.trim();if(!s)return null;let i=s.split(/\s+/);if(0===i.length)return s;if(i[0]=r.default.basename(i[0]),A.has(i[0])&&i.length>1){let e=r.default.basename(i[1]).replace(/\.(c|m)?js$/,"");i.splice(0,2,e)}return i.join(" ")}catch{return null}};e.s(["SAFE_SHELLS",0,M,"applyConfig",0,D,"capturePaneContent",0,j,"capturePaneContentWithHistory",0,N,"createSession",0,p,"defaultSessionName",0,()=>`pt-${(0,s.nanoid)(6)}-${(0,s.nanoid)(6)}-${(0,s.nanoid)(6)}`,"exitCopyMode",0,T,"getAllPanesInfo",0,b,"getLastCommand",0,Y,"getListeningPorts",0,H,"getPaneCurrentCommand",0,C,"getPaneDetailInfo",0,O,"getPaneTitle",0,_,"getSessionCwd",0,v,"getSessionPanePid",0,x,"hasSession",0,w,"killServer",0,E,"killSession",0,g,"listSessions",0,h,"sanitizedEnv",0,m,"scanSessions",0,$,"sendBracketedPaste",0,I,"sendKeys",0,k,"sendRawKeys",0,L,"workspaceSessionName",0,(e,t,n)=>`pt-${e}-${t}-${n}`],459015)},713915,e=>{"use strict";var t=e.i(233405),n=e.i(924868),a=e.i(446786),r=e.i(814747),s=e.i(224361),i=e.i(459015);let o=(0,s.promisify)(t.execFile),u=null,l=null,c=async()=>{let e=a.default.userInfo().shell||process.env.SHELL||"/bin/bash";try{let{stdout:t}=await o(e,["-ilc",'echo -n "$PATH"'],{timeout:5e3,env:{...(0,i.sanitizedEnv)(),SHELL:e,DISABLE_AUTO_UPDATE:"true",ZSH_TMUX_AUTOSTARTED:"true",TERM:"xterm-256color",COLORTERM:"truecolor"}});return t.toString().trim()}catch{return process.env.PATH||""}},d=async()=>u||(l||(l=c().then(e=>(u=e,l=null,e))),l),f=async(e,t,n)=>{try{let a=await d(),{stdout:r}=await o(e,t,{timeout:5e3,env:{...process.env,PATH:a}});return{installed:!0,version:n(r)}}catch{return{installed:!1,version:null}}},m=e=>e.trim().match(/(\d+\.\d+[\d.]*)/)?.[1]??null,h=[r.default.join(a.default.homedir(),".local","bin")],p=async()=>{for(let e of h)try{return await (0,n.access)(r.default.join(e,"claude")),e}catch{}return null},y=e=>e.installed&&null!==e.version&&parseFloat(e.version)>=2.9,g=async()=>{u=await c();let[e,t,s]=await Promise.all([f("tmux",["-V"],m),f("git",["--version"],m),f("claude",["--version"],m)]),i=(y(e)&&t.installed&&s.installed,s.installed?null:await p()),o=!1;if(s.installed||i)try{await (0,n.access)(r.default.join(a.default.homedir(),".claude")),o=!0}catch{}return{tmux:{...e,compatible:y(e)},git:t,claude:{...s,binaryPath:i,loggedIn:o}}},w=null,S=null,$=async()=>{u=await c();let[e,t,n]=await Promise.all([f("tmux",["-V"],m),f("git",["--version"],m),f("claude",["--version"],m)]);return{tmux:{...e,compatible:y(e)},git:t,claude:n}},v=async()=>w&&Date.now()-w.checkedAt<3e4?w.result:S||(S=$().then(e=>(w={result:e,checkedAt:Date.now()},S=null,e)).catch(e=>{throw S=null,e}));e.s(["getCachedRuntimePreflight",0,v,"getPreflightStatus",0,g,"getShellPath",0,d,"invalidateRuntimeCache",0,()=>{w=null,S=null}])},319668,(e,t,n)=>{t.exports=e.x("readline",()=>require("readline"))},990294,(e,t,n)=>{e.e,t.exports=function(){"use strict";var e="millisecond",t="second",n="minute",a="hour",r="week",s="month",i="quarter",o="year",u="date",l="Invalid Date",c=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=function(e,t,n){var a=String(e);return!a||a.length>=t?e:""+Array(t+1-a.length).join(n)+e},m="en",h={};h[m]={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};var p="$isDayjsObject",y=function(e){return e instanceof $||!(!e||!e[p])},g=function e(t,n,a){var r;if(!t)return m;if("string"==typeof t){var s=t.toLowerCase();h[s]&&(r=s),n&&(h[s]=n,r=s);var i=t.split("-");if(!r&&i.length>1)return e(i[0])}else{var o=t.name;h[o]=t,r=o}return!a&&r&&(m=r),r||!a&&m},w=function(e,t){if(y(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new $(n)},S={s:f,z:function(e){var t=-e.utcOffset(),n=Math.abs(t);return(t<=0?"+":"-")+f(Math.floor(n/60),2,"0")+":"+f(n%60,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var a=12*(n.year()-t.year())+(n.month()-t.month()),r=t.clone().add(a,s),i=n-r<0,o=t.clone().add(a+(i?-1:1),s);return+(-(a+(n-r)/(i?r-o:o-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(l){return({M:s,y:o,w:r,d:"day",D:u,h:a,m:n,s:t,ms:e,Q:i})[l]||String(l||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}};S.l=g,S.i=y,S.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var $=function(){function f(e){this.$L=g(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[p]=!0}var m=f.prototype;return m.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(S.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var a=t.match(c);if(a){var r=a[2]-1||0,s=(a[7]||"0").substring(0,3);return n?new Date(Date.UTC(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,s)):new Date(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,s)}}return new Date(t)}(e),this.init()},m.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},m.$utils=function(){return S},m.isValid=function(){return this.$d.toString()!==l},m.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},m.isAfter=function(e,t){return w(e)<this.startOf(t)},m.isBefore=function(e,t){return this.endOf(t)<w(e)},m.$g=function(e,t,n){return S.u(e)?this[t]:this.set(n,e)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(e,i){var l=this,c=!!S.u(i)||i,d=S.p(e),f=function(e,t){var n=S.w(l.$u?Date.UTC(l.$y,t,e):new Date(l.$y,t,e),l);return c?n:n.endOf("day")},m=function(e,t){return S.w(l.toDate()[e].apply(l.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),l)},h=this.$W,p=this.$M,y=this.$D,g="set"+(this.$u?"UTC":"");switch(d){case o:return c?f(1,0):f(31,11);case s:return c?f(1,p):f(0,p+1);case r:var w=this.$locale().weekStart||0,$=(h<w?h+7:h)-w;return f(c?y-$:y+(6-$),p);case"day":case u:return m(g+"Hours",0);case a:return m(g+"Minutes",1);case n:return m(g+"Seconds",2);case t:return m(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(e){return this.startOf(e,!1)},m.$set=function(r,i){var l,c=S.p(r),d="set"+(this.$u?"UTC":""),f=((l={}).day=d+"Date",l[u]=d+"Date",l[s]=d+"Month",l[o]=d+"FullYear",l[a]=d+"Hours",l[n]=d+"Minutes",l[t]=d+"Seconds",l[e]=d+"Milliseconds",l)[c],m="day"===c?this.$D+(i-this.$W):i;if(c===s||c===o){var h=this.clone().set(u,1);h.$d[f](m),h.init(),this.$d=h.set(u,Math.min(this.$D,h.daysInMonth())).$d}else f&&this.$d[f](m);return this.init(),this},m.set=function(e,t){return this.clone().$set(e,t)},m.get=function(e){return this[S.p(e)]()},m.add=function(e,i){var u,l=this;e=Number(e);var c=S.p(i),d=function(t){var n=w(l);return S.w(n.date(n.date()+Math.round(t*e)),l)};if(c===s)return this.set(s,this.$M+e);if(c===o)return this.set(o,this.$y+e);if("day"===c)return d(1);if(c===r)return d(7);var f=((u={})[n]=6e4,u[a]=36e5,u[t]=1e3,u)[c]||1,m=this.$d.getTime()+e*f;return S.w(m,this)},m.subtract=function(e,t){return this.add(-1*e,t)},m.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var a=e||"YYYY-MM-DDTHH:mm:ssZ",r=S.z(this),s=this.$H,i=this.$m,o=this.$M,u=n.weekdays,c=n.months,f=n.meridiem,m=function(e,n,r,s){return e&&(e[n]||e(t,a))||r[n].slice(0,s)},h=function(e){return S.s(s%12||12,e,"0")},p=f||function(e,t,n){var a=e<12?"AM":"PM";return n?a.toLowerCase():a};return a.replace(d,function(e,a){return a||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return S.s(t.$y,4,"0");case"M":return o+1;case"MM":return S.s(o+1,2,"0");case"MMM":return m(n.monthsShort,o,c,3);case"MMMM":return m(c,o);case"D":return t.$D;case"DD":return S.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return m(n.weekdaysMin,t.$W,u,2);case"ddd":return m(n.weekdaysShort,t.$W,u,3);case"dddd":return u[t.$W];case"H":return String(s);case"HH":return S.s(s,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return p(s,i,!0);case"A":return p(s,i,!1);case"m":return String(i);case"mm":return S.s(i,2,"0");case"s":return String(t.$s);case"ss":return S.s(t.$s,2,"0");case"SSS":return S.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},m.utcOffset=function(){return-(15*Math.round(this.$d.getTimezoneOffset()/15))},m.diff=function(e,u,l){var c,d=this,f=S.p(u),m=w(e),h=(m.utcOffset()-this.utcOffset())*6e4,p=this-m,y=function(){return S.m(d,m)};switch(f){case o:c=y()/12;break;case s:c=y();break;case i:c=y()/3;break;case r:c=(p-h)/6048e5;break;case"day":c=(p-h)/864e5;break;case a:c=p/36e5;break;case n:c=p/6e4;break;case t:c=p/1e3;break;default:c=p}return l?c:S.a(c)},m.daysInMonth=function(){return this.endOf(s).$D},m.$locale=function(){return h[this.$L]},m.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),a=g(e,t,!0);return a&&(n.$L=a),n},m.clone=function(){return S.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},f}(),v=$.prototype;return w.prototype=v,[["$ms",e],["$s",t],["$m",n],["$H",a],["$W","day"],["$M",s],["$y",o],["$D",u]].forEach(function(e){v[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),w.extend=function(e,t){return e.$i||(e(t,$,w),e.$i=!0),w},w.locale=g,w.isDayjs=y,w.unix=function(e){return w(1e3*e)},w.en=h[m],w.Ls=h,w.p={},w}()},177579,e=>{"use strict";var t=e.i(924868),n=e.i(522734),a=e.i(814747),r=e.i(446786),s=e.i(319668),i=e.i(990294);let o=a.default.join(r.default.homedir(),".purplemux","stats"),u=a.default.join(o,"cache.json"),l=a.default.join(r.default.homedir(),".claude","projects"),c=async()=>{let e=[];try{for(let n of(await t.default.readdir(l))){let r=a.default.join(l,n),s=await t.default.stat(r).catch(()=>null);if(s?.isDirectory())for(let n of(await t.default.readdir(r).catch(()=>[])))n.endsWith(".jsonl")&&!/^agent-/.test(n)&&e.push(a.default.join(r,n))}}catch{}return e},d=async(e,t)=>{let a=new Map,r=new Map;try{let i=(0,n.createReadStream)(e,{encoding:"utf-8"});for await(let e of s.default.createInterface({input:i,crlfDelay:1/0}))if(e.trim())try{let n=JSON.parse(e),s=String(n.timestamp??"");if(!s)continue;let i=s.slice(0,10);if(!t.has(i))continue;let o=String(n.type??"");if("user"!==o&&"assistant"!==o)continue;let u=String(n.sessionId??""),l=String(new Date(s).getHours()),c=a.get(i);c||(c={messageCount:0,sessionCount:0,toolCallCount:0,hourCounts:{},modelTokens:{},sessions:[]},a.set(i,c),r.set(i,new Map));let d=r.get(i);if("user"===o&&(c.messageCount++,c.hourCounts[l]=(c.hourCounts[l]??0)+1,u)){let e=d.get(u);e?(e.messages++,s>e.end&&(e.end=s),s<e.start&&(e.start=s)):d.set(u,{start:s,end:s,messages:1})}if("assistant"===o){let e=n.message;if(!e)continue;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length;c.toolCallCount+=e}let a=String(e.model??""),r=e.usage;if(a&&!a.startsWith("<")&&r){c.modelTokens[a]||(c.modelTokens[a]={input:0,output:0,cacheRead:0,cacheCreation:0});let e=c.modelTokens[a];e.input+=Number(r.input_tokens??0),e.output+=Number(r.output_tokens??0),e.cacheRead+=Number(r.cache_read_input_tokens??0),e.cacheCreation+=Number(r.cache_creation_input_tokens??0)}if(u){let e=d.get(u);e?(s>e.end&&(e.end=s),s<e.start&&(e.start=s)):d.set(u,{start:s,end:s,messages:0})}}}catch{}}catch{}for(let[e,t]of r){let n=a.get(e);n&&(n.sessionCount=t.size,n.sessions=Array.from(t.entries()).map(([e,t])=>({id:e,start:t.start,end:t.end,messages:t.messages})))}return a},f=async(e,t)=>{let n=[],a=0,r=async()=>{for(;a<e.length;){let t=a++;n[t]=await e[t]()}},s=Array.from({length:Math.min(t,e.length)},()=>r());return await Promise.all(s),n},m=(e,t)=>{for(let[n,a]of(e.messageCount+=t.messageCount,e.toolCallCount+=t.toolCallCount,Object.entries(t.hourCounts)))e.hourCounts[n]=(e.hourCounts[n]??0)+a;for(let[n,a]of Object.entries(t.modelTokens)){e.modelTokens[n]||(e.modelTokens[n]={input:0,output:0,cacheRead:0,cacheCreation:0});let t=e.modelTokens[n];t.input+=a.input,t.output+=a.output,t.cacheRead+=a.cacheRead,t.cacheCreation+=a.cacheCreation}let n=new Set(e.sessions.map(e=>e.id));for(let a of t.sessions)if(n.has(a.id)){let t=e.sessions.find(e=>e.id===a.id);t.messages+=a.messages,a.start<t.start&&(t.start=a.start),a.end>t.end&&(t.end=a.end)}else e.sessions.push(a);e.sessionCount=e.sessions.length},h=async()=>{try{let e=await t.default.readFile(u,"utf-8"),n=JSON.parse(e);if(1!==n.version)return null;return n}catch{return null}},p=async e=>{await t.default.mkdir(o,{recursive:!0}),await t.default.writeFile(u,JSON.stringify(e),"utf-8")},y=null,g=async e=>{try{let t=(0,n.createReadStream)(e,{encoding:"utf-8"});for await(let e of s.default.createInterface({input:t,crlfDelay:1/0}))if(e.trim())try{let t=JSON.parse(e),n=String(t.timestamp??"");if(n)return n.slice(0,10)}catch{}}catch{}return null},w=async()=>{let e=await c();if(0===e.length)return null;let t=e.map(e=>()=>g(e)),n=(await f(t,10)).filter(e=>null!==e);return 0===n.length?null:(n.sort(),n[0])},S=async e=>{if(0===e.size)return new Map;let t=(await c()).map(t=>()=>d(t,e)),n=await f(t,10),a=new Map;for(let e of n)for(let[t,n]of e){let e=a.get(t);e?m(e,n):a.set(t,n)}return a},$=async()=>{if(y&&Date.now()<y.expiresAt)return y.data;let e=(0,i.default)().subtract(1,"day").format("YYYY-MM-DD"),t=(0,i.default)().format("YYYY-MM-DD"),n=await h(),a=new Set;if(a.add(t),n){if(n.lastComputedDate<e){let t=(0,i.default)(n.lastComputedDate).add(1,"day"),r=(0,i.default)(e);for(;t.isBefore(r)||t.isSame(r);){let e=t.format("YYYY-MM-DD");n.days[e]||a.add(e),t=t.add(1,"day")}}}else{n={version:1,lastComputedDate:"",days:{}};let r=await w();if(!r)return v(n,t);let s=(0,i.default)(r),o=(0,i.default)(e);for(;s.isBefore(o)||s.isSame(o);)a.add(s.format("YYYY-MM-DD")),s=s.add(1,"day")}let r=await S(a);for(let[e,a]of r)e!==t&&(n.days[e]=a);n.lastComputedDate=e,await p(n);let s=r.get(t)??null,o=v(n,t,s);return y={data:o,expiresAt:Date.now()+3e5},o},v=(e,t,n)=>{let a=[],r=[],s={},i={},o={},u=0,l=0,c="",d={sessionId:"",duration:0,messageCount:0,timestamp:""},f=Object.entries(e.days);for(let[e,m]of(n&&f.push([t,n]),f.sort((e,t)=>e[0].localeCompare(t[0])),f)){!c&&m.messageCount>0&&(c=e),a.push({date:e,messageCount:m.messageCount,sessionCount:m.sessionCount,toolCallCount:m.toolCallCount});let t={};for(let[e,n]of Object.entries(m.modelTokens)){t[e]={input:n.input,output:n.output,cacheRead:n.cacheRead,cacheCreation:n.cacheCreation},s[e]||(s[e]={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,webSearchRequests:0,costUSD:0,contextWindow:0,maxOutputTokens:0});let a=s[e];a.inputTokens+=n.input,a.outputTokens+=n.output,a.cacheReadInputTokens+=n.cacheRead,a.cacheCreationInputTokens+=n.cacheCreation}r.push({date:e,tokensByModel:t});let n=new Date(e).getDay();for(let[e,t]of Object.entries(m.hourCounts)){i[e]=(i[e]??0)+t;let a=`${n}-${e}`;o[a]=(o[a]??0)+t}for(let e of(u+=m.sessionCount,l+=m.messageCount,m.sessions)){let t=new Date(e.end).getTime()-new Date(e.start).getTime();t>d.duration&&(d={sessionId:e.id,duration:t,messageCount:e.messages,timestamp:e.start})}}return{version:1,lastComputedDate:t,dailyActivity:a,dailyModelTokens:r,modelUsage:s,totalSessions:u,totalMessages:l,longestSession:d,firstSessionDate:c,hourCounts:i,dayHourCounts:o,totalSpeculationTimeSavedMs:0}};e.s(["collectJsonlFiles",0,c,"getStatsCache",0,$])},7991,e=>{"use strict";var t=e.i(924868),n=e.i(814747),a=e.i(446786),r=e.i(522734),s=e.i(319668),i=e.i(233405),o=e.i(713915),u=e.i(177579);let l=n.default.join(a.default.homedir(),".purplemux","stats","daily-reports"),c=async()=>{let e={};try{for(let a of(await t.default.readdir(l)))if(a.endsWith(".json"))try{let r=await t.default.readFile(n.default.join(l,a),"utf-8"),s=JSON.parse(r);s.date&&s.brief&&(e[s.date]=s)}catch{}}catch{}return e},d=async e=>{await t.default.mkdir(l,{recursive:!0}),await t.default.writeFile(n.default.join(l,`${e.date}.json`),JSON.stringify(e,null,2),"utf-8")},f=e=>{let t=a.default.homedir();return(e.startsWith(t)?e.slice(t.length+1):e).replace(/^Workspace\/github\.com\//g,"").replace(/^Workspace\/gitlab\.kolonfnc\.com\//g,"gitlab/").replace(/^Documents\//g,"docs/").replace(/^Downloads/g,"Downloads")},m=async e=>{let t=await (0,u.collectJsonlFiles)(),a=[];for(let i of t){let t=[],o=[],u=0,l="";try{let n=(0,r.createReadStream)(i,{encoding:"utf-8"});for await(let a of s.default.createInterface({input:n,crlfDelay:1/0}))if(a.trim())try{let n=JSON.parse(a),r=String(n.timestamp??"");if(!r.startsWith(e))continue;o.push(r);let s=String(n.type??"");if(l||"string"!=typeof n.cwd||(l=n.cwd),"user"===s){let e=n.message;if(!e)continue;let a=e.content,s="";if("string"==typeof a)s=a.slice(0,300);else if(Array.isArray(a)){let e=[];for(let t of a)"object"==typeof t&&null!==t&&"text"===t.type&&e.push(String(t.text??"").slice(0,300));s=e.join(" | ")}if(s.includes("<command-message>")){let e=s.match(/<command-name>\/([^<]+)<\/command-name>/);s=`[Command: ${e?e[1]:"unknown"}]`}if(s.includes("<local-command-caveat>")||s.includes("<task-notification>"))continue;s.trim()&&t.push({time:r.slice(11,16),text:s.slice(0,200)})}if("assistant"===s){let e=n.message;if(!e)continue;let t=e.content;Array.isArray(t)&&(u+=t.filter(e=>"object"==typeof e&&null!==e&&"tool_use"===e.type).length)}}catch{}}catch{}if(o.length>0&&t.length>0){let e=l?f(l):n.default.basename(n.default.dirname(i));a.push({project:e,start:Math.min(...o.map(e=>new Date(e).getTime())).toString(),msgCount:t.length,toolCount:u,firstMessage:t[0].text})}}return a.sort((e,t)=>Number(e.start)-Number(t.start)),a},h=async(e,t)=>{let n=await (0,o.getShellPath)();return new Promise((a,r)=>{let s=(0,i.execFile)("claude",["-p"],{timeout:12e4,maxBuffer:1048576,env:{...process.env,PATH:n}},(e,t)=>{e?r(Error(`claude -p failed: ${e.message}`)):a(t.trim())});s.stdin?.write(`${t}
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${e}`),s.stdin?.end()})},p={en:"English",ko:"Korean (한국어)",ja:"Japanese (日本語)","zh-CN":"Simplified Chinese (简体中文)","zh-TW":"Traditional Chinese (繁體中文)",de:"German (Deutsch)",es:"Spanish (Español)",fr:"French (Français)","pt-BR":"Brazilian Portuguese (Português do Brasil)",ru:"Russian (Русский)",tr:"Turkish (Türkçe)"},y=async(e,t=!1,n="en")=>{var a,r;let s,i,o;if(!t){let t=await g(e);if(t&&t.locale===n)return t}let u=await m(e);if(0===u.length){let t={date:e,brief:"No activity recorded.",detail:"",generatedAt:new Date().toISOString(),locale:n};return await d(t),t}let l=u.map(e=>{let t=new Date(Number(e.start)).toTimeString().slice(0,5);return`[${t}] [${e.project}] msgs=${e.msgCount}, tools=${e.toolCount} | ${e.firstMessage}`}).join("\n"),{brief:c,detail:f}=(i=(r=await h(l,(a=e,s=p[n]??p.en,`Summarize the Claude session history for ${a}.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Output format (use exactly this structure):
|
|
6
6
|
|
|
7
7
|
[BRIEF]
|
|
8
|
-
|
|
8
|
+
A 2-3 line summary of the entire day. Use terse noun-form phrases. Plain text only. No markdown headings (#) or separators (---).
|
|
9
9
|
|
|
10
10
|
[DETAIL]
|
|
11
|
-
##
|
|
12
|
-
###
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
###
|
|
16
|
-
-
|
|
11
|
+
## Project Name
|
|
12
|
+
### Major Feature / Area
|
|
13
|
+
- One-line task summary
|
|
14
|
+
- One-line task summary
|
|
15
|
+
### Another Feature / Area
|
|
16
|
+
- One-line task summary
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- [BRIEF]
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- WHAT
|
|
25
|
-
-
|
|
26
|
-
-
|
|
18
|
+
Rules:
|
|
19
|
+
- The [BRIEF] and [DETAIL] tags must each appear exactly once, at the start of a line.
|
|
20
|
+
- Do not insert meta text outside the tags (separators, numbering, explanations).
|
|
21
|
+
- Always include the "## Project Name" heading, even when there is only one project.
|
|
22
|
+
- Each item is a single line — no filenames, no code snippets.
|
|
23
|
+
- Use terse noun-form phrases (e.g. "Fix login logic", "Improve mobile layout"). Avoid finished-sentence / past-tense forms.
|
|
24
|
+
- Focus on WHAT, not HOW.
|
|
25
|
+
- Skip trivial chatter (greetings, one-off questions, commit commands).
|
|
26
|
+
- IMPORTANT: Write ALL brief and detail content in ${s}. Keep the [BRIEF] / [DETAIL] tags and markdown syntax (##, ###, -) as-is in English.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Data:`))).match(/\[BRIEF\]\s*\n([\s\S]*?)(?=\[DETAIL\])/),o=r.match(/\[DETAIL\]\s*\n([\s\S]*?)$/),{brief:i?i[1].replace(/[\s#\-]*$/,"").trim():r.slice(0,500),detail:o?o[1].trim():""}),y={date:e,brief:c,detail:f,generatedAt:new Date().toISOString(),locale:n};return await d(y),y},g=async e=>{try{let a=await t.default.readFile(n.default.join(l,`${e}.json`),"utf-8"),r=JSON.parse(a);return r.date&&r.brief?r:null}catch{return null}};e.s(["generateDailyReport",0,y,"readAllCachedReports",0,c,"shortenCwd",0,f])}];
|
|
29
29
|
|
|
30
30
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0j.vqs2._.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
module.exports=[270406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},326866,e=>{"use strict";var t=e.i(926747),a=e.i(190406),r=e.i(244898),i=e.i(262950);e.s(["default",0,(e,t)=>{t.json({app:"purplemux"})}],806947);var n=e.i(806947),s=e.i(7031),l=e.i(181927),o=e.i(846432);let p=(0,i.hoist)(n,"default"),d=(0,i.hoist)(n,"config"),u=new r.PagesAPIRouteModule({definition:{kind:a.RouteKind.PAGES_API,page:"/api/health",pathname:"/api/health",bundlePath:"",filename:""},userland:n,distDir:".next",relativeProjectDir:""});async function h(e,a,r){r.requestMeta&&(0,o.setRequestMeta)(e,r.requestMeta),u.isDev&&(0,o.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let i="/api/health";i=i.replace(/\/index$/,"")||"/";let n=await u.prepare(e,a,{srcPage:i});if(!n){a.statusCode=400,a.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve());return}let{query:p,params:d,prerenderManifest:h,routerServerContext:c}=n;try{let t,r=e.method||"GET",n=(0,s.getTracer)(),o=n.getActiveScopeSpan(),v=!!(null==c?void 0:c.isWrappedByNextServer),m=u.instrumentationOnRequestError.bind(u),x=async s=>u.render(e,a,{query:{...p,...d},params:d,allowedRevalidateHeaderKeys:[],multiZoneDraftMode:!1,trustHostHeader:!1,previewProps:h.preview,propagateError:!1,dev:u.isDev,page:"/api/health",internalRevalidate:null==c?void 0:c.revalidate,onError:(...t)=>m(e,...t)}).finally(()=>{if(!s)return;s.setAttributes({"http.status_code":a.statusCode,"next.rsc":!1});let e=n.getRootSpanAttributes();if(!e)return;if(e.get("next.span_type")!==l.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${e.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let o=e.get("next.route");if(o){let e=`${r} ${o}`;s.setAttributes({"next.route":o,"http.route":o,"next.span_name":e}),s.updateName(e),t&&t!==s&&(t.setAttribute("http.route",o),t.updateName(e))}else s.updateName(`${r} ${i}`)});v&&o?await x(o):(t=n.getActiveScopeSpan(),await n.withPropagatedContext(e.headers,()=>n.trace(l.BaseServerSpan.handleRequest,{spanName:`${r} ${i}`,kind:s.SpanKind.SERVER,attributes:{"http.method":r,"http.target":e.url}},x),void 0,!v))}catch(e){if(u.isDev)throw e;(0,t.sendError)(a,500,"Internal Server Error")}finally{null==r.waitUntil||r.waitUntil.call(r,Promise.resolve())}}e.s(["config",0,d,"default",0,p,"handler",0,h],326866)}];
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=%5Broot-of-the-server%5D__10o5i.7._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[843866,e=>{"use strict";var t=e.i(926747),r=e.i(190406),a=e.i(244898),n=e.i(262950),i=e.i(7991);let s=async(e,t)=>{if("POST"!==e.method)return t.setHeader("Allow","POST"),t.status(405).json({error:"method-not-allowed"});let{date:r,force:a}=e.body;if(!r||!/^\d{4}-\d{2}-\d{2}$/.test(r))return t.status(400).json({error:"invalid-date",message:"date must be YYYY-MM-DD"});try{let e=await (0,i.generateDailyReport)(r,!!a);return t.status(200).json(e)}catch(r){let e=r instanceof Error?r.message:"unknown error";return t.status(500).json({error:"generation-failed",message:e})}};e.s(["default",0,s],806436);var o=e.i(806436),l=e.i(7031),d=e.i(181927),u=e.i(846432);let p=(0,n.hoist)(o,"default"),c=(0,n.hoist)(o,"config"),
|
|
1
|
+
module.exports=[843866,e=>{"use strict";var t=e.i(926747),r=e.i(190406),a=e.i(244898),n=e.i(262950),i=e.i(7991);let s=async(e,t)=>{if("POST"!==e.method)return t.setHeader("Allow","POST"),t.status(405).json({error:"method-not-allowed"});let{date:r,force:a,locale:n}=e.body;if(!r||!/^\d{4}-\d{2}-\d{2}$/.test(r))return t.status(400).json({error:"invalid-date",message:"date must be YYYY-MM-DD"});let s="string"==typeof n&&n.trim()?n:"en";try{let e=await (0,i.generateDailyReport)(r,!!a,s);return t.status(200).json(e)}catch(r){let e=r instanceof Error?r.message:"unknown error";return t.status(500).json({error:"generation-failed",message:e})}};e.s(["default",0,s],806436);var o=e.i(806436),l=e.i(7031),d=e.i(181927),u=e.i(846432);let p=(0,n.hoist)(o,"default"),c=(0,n.hoist)(o,"config"),g=new a.PagesAPIRouteModule({definition:{kind:r.RouteKind.PAGES_API,page:"/api/stats/daily-report/generate",pathname:"/api/stats/daily-report/generate",bundlePath:"",filename:""},userland:o,distDir:".next",relativeProjectDir:""});async function v(e,r,a){a.requestMeta&&(0,u.setRequestMeta)(e,a.requestMeta),g.isDev&&(0,u.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let n="/api/stats/daily-report/generate";n=n.replace(/\/index$/,"")||"/";let i=await g.prepare(e,r,{srcPage:n});if(!i){r.statusCode=400,r.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve());return}let{query:s,params:o,prerenderManifest:p,routerServerContext:c}=i;try{let t,a=e.method||"GET",i=(0,l.getTracer)(),u=i.getActiveScopeSpan(),v=!!(null==c?void 0:c.isWrappedByNextServer),h=g.instrumentationOnRequestError.bind(g),m=async l=>g.render(e,r,{query:{...s,...o},params:o,allowedRevalidateHeaderKeys:[],multiZoneDraftMode:!1,trustHostHeader:!1,previewProps:p.preview,propagateError:!1,dev:g.isDev,page:"/api/stats/daily-report/generate",internalRevalidate:null==c?void 0:c.revalidate,onError:(...t)=>h(e,...t)}).finally(()=>{if(!l)return;l.setAttributes({"http.status_code":r.statusCode,"next.rsc":!1});let e=i.getRootSpanAttributes();if(!e)return;if(e.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${e.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=e.get("next.route");if(s){let e=`${a} ${s}`;l.setAttributes({"next.route":s,"http.route":s,"next.span_name":e}),l.updateName(e),t&&t!==l&&(t.setAttribute("http.route",s),t.updateName(e))}else l.updateName(`${a} ${n}`)});v&&u?await m(u):(t=i.getActiveScopeSpan(),await i.withPropagatedContext(e.headers,()=>i.trace(d.BaseServerSpan.handleRequest,{spanName:`${a} ${n}`,kind:l.SpanKind.SERVER,attributes:{"http.method":a,"http.target":e.url}},m),void 0,!v))}catch(e){if(g.isDev)throw e;(0,t.sendError)(r,500,"Internal Server Error")}finally{null==a.waitUntil||a.waitUntil.call(a,Promise.resolve())}}e.s(["config",0,c,"default",0,p,"handler",0,v],843866)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=node_modules_next_dist_esm_build_templates_pages-api_0ulrm.8.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[964759,t=>{"use strict";t.i(478319);var e=t.i(220951),s=t.i(322429),a=t.i(825265),i=t.i(804767),n=t.i(459015),l=t.i(143511),r=t.i(746514);let o={bash:"",zsh:"",fish:"",sh:"",dash:"",tcsh:"",nu:"",nvim:"",vim:"",vi:"",nano:"",emacs:"",hx:"",code:"",git:"",gitui:"",tig:"",gh:"",lazygit:"",jj:"",lazyjj:"",node:"",deno:"",bun:"",python:"",python3:"",go:"",ruby:"",java:"",rust:"",rustc:"",cargo:"",swift:"",dart:"",elixir:"",perl:"",php:"",R:"",julia:"",scala:"",zig:"",npm:"",pnpm:"",yarn:"",pip:"",pip3:"",brew:"",apt:"",dnf:"",pacman:"",yay:"",paru:"",make:"",cmake:"",gradle:"",maven:"",webpack:"",tsc:"",docker:"",lazydocker:"",kubectl:"",k9s:"",helm:"",minikube:"",aws:"",gcloud:"",terraform:"",ansible:"",vagrant:"",ssh:"",scp:"",curl:"",wget:"",rsync:"",ping:"",htop:"",btop:"",top:"",btm:"",glances:"",mactop:"",ranger:"",yazi:"",lf:"",lfcd:"",mysql:"",psql:"",mongo:"",redis:"",sqlite:"",tmux:"",screen:"",sudo:"",bat:"",gpg:"",openssl:"",zip:"",unzip:"",jest:"",claude:"",codex:""},c=new Set(["node","python","python3","ruby","perl","deno","bun"]),u=new Set(["zsh","bash","fish","sh","-zsh","-bash","-fish","-sh"]),d=t=>{if("~"===t||"/"===t)return t;let e=t.replace(/\/$/,"").split("/");return e[e.length-1]||t},p=t=>{let e=t.trim();if(!e)return"";let s=(t=>{let e=t.trim();if(!e)return null;let s=e.indexOf("|");return s>0?e.slice(0,s):null})(t);if(null!==s){let t=e.slice(e.indexOf("|")+1);return u.has(s)?d(t):s}let a=e.match(/@[^:]+:\s*(.*)/);if(a)return d(a[1].trim());if(e.startsWith("/")||e.startsWith("~"))return d(e);let i=e.split(/\s+/)[0];return u.has(i)?"":i||""};var h=t.i(840665),m=t.i(522734),y=t.i(924868),g=t.i(25146),f=t.i(796902);let S=(0,g.createLogger)("rate-limits");var w=t.i(971780),b=t.i(443571),T=t.i(814747),A=t.i(446786);let v=(0,g.createLogger)("session-history"),k=T.default.join(A.default.homedir(),".purplemux"),P=T.default.join(k,"session-history.json"),M=globalThis;M.__purplemuxSessionHistoryLock||(M.__purplemuxSessionHistoryLock=Promise.resolve());let I=async t=>{let e,s=new Promise(t=>{e=t}),a=M.__purplemuxSessionHistoryLock;M.__purplemuxSessionHistoryLock=s,await a;try{return await t()}finally{e()}},j=()=>({version:1,entries:[]}),U=async()=>{let t;try{t=await y.default.readFile(P,"utf-8")}catch{return j()}try{return JSON.parse(t)}catch{v.warn("Failed to parse session-history.json, starting empty");try{await y.default.copyFile(P,P.replace(/\.json$/,".json.bak"))}catch{}return j()}},W=async t=>{let e=JSON.stringify(t.entries);if(M.__purplemuxSessionHistoryContentCache===e)return;let s=P+".tmp";try{await y.default.writeFile(s,JSON.stringify(t,null,2),{mode:384}),await y.default.rename(s,P)}catch(t){throw await y.default.unlink(s).catch(()=>{}),t}M.__purplemuxSessionHistoryContentCache=e},E=async t=>{await I(async()=>{let e=await U();e.entries.unshift(t),e.entries.length>200&&(e.entries=e.entries.slice(0,200)),await W(e)})},L=async(t,e)=>await I(async()=>{let s=await U(),a=s.entries.find(e=>e.tabId===t&&null===e.dismissedAt);return a?(a.dismissedAt=e,await W(s),a):null});var R=t.i(157469),x=t.i(75874),_=t.i(228448),N=t.i(44014);let C=(0,g.createLogger)("status"),F=(0,g.createLogger)("hooks"),J=t=>t?T.default.basename(t,".jsonl"):null,z=new Set(["permission_prompt","worker_permission_prompt"]),D=new Map,q=t=>{let e=t.name??"Tool",s=t.input??{};return{toolName:e,summary:(0,h.summarizeToolCall)(e,s)}},O=t=>{let e=!1;for(let s=t.length-1;s>=0;s--)try{let a=JSON.parse(t[s]);if(a.isSidechain)continue;if("user"===a.type){let t=a.message?.content;Array.isArray(t)&&t.some(t=>"tool_result"===t.type)||(e=!0);continue}if("assistant"!==a.type||!a.message?.content)continue;if(e)return{lastAssistantSnippet:null,currentAction:null,reset:!0};let i=a.message.content;if(!Array.isArray(i))continue;let n=null,l=null;for(let t=i.length-1;t>=0;t--){let e=i[t];if("tool_use"===e.type){l=q(e);break}if("text"===e.type&&e.text?.trim()){let t=e.text.trim();l={toolName:null,summary:t.length>200?t.slice(0,200)+"…":t};break}}for(let t=i.length-1;t>=0;t--)if("text"===i[t].type&&i[t].text?.trim()){let e=i[t].text.trim();n=e.length>200?e.slice(0,200)+"…":e;break}return{lastAssistantSnippet:n,currentAction:l,reset:!1}}catch{continue}return{lastAssistantSnippet:null,currentAction:null,reset:!1}},$=(t,e)=>{for(let s=t.length-1;s>=0;s--)try{let a=JSON.parse(t[s]);if(a.isSidechain)continue;let i=a.timestamp?new Date(a.timestamp).getTime():null;if("system"===a.type&&("stop_hook_summary"===a.subtype||"turn_duration"===a.subtype))return{matched:!0,idle:!0,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i};if("assistant"===a.type){let t=a.message?.stop_reason;if(!t){let t=e>2e4;return{matched:!0,idle:t,stale:!0,needsStaleRecheck:!t,staleMs:2e4,lastEntryTs:i}}return{matched:!0,idle:"tool_use"!==t,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i}}if("user"===a.type){let t=a.message?.content;if(Array.isArray(t)&&1===t.length&&"string"==typeof t[0]?.text&&t[0].text.startsWith(h.INTERRUPT_PREFIX))return{matched:!0,idle:!0,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i};let s=e>9e4;return{matched:!0,idle:s,stale:!0,needsStaleRecheck:!s,staleMs:9e4,lastEntryTs:i}}}catch{continue}return{matched:!1,idle:e>9e4,stale:!0,needsStaleRecheck:e<=9e4,staleMs:9e4,lastEntryTs:null}},H=async t=>{try{let e=await y.default.stat(t);if(0===e.size)return{idle:!0,stale:!1,lastAssistantSnippet:null,currentAction:null,reset:!1,lastEntryTs:null,staleMs:0};let s=D.get(t);if(s&&s.mtimeMs===e.mtimeMs){if(D.delete(t),D.set(t,s),s.idle)return{idle:!0,stale:s.stale,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs};if(s.needsStaleRecheck)return{idle:Date.now()-e.mtimeMs>s.staleMs,stale:!0,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs};return{idle:!1,stale:!1,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs}}let a=await y.default.open(t,"r");try{let s=Date.now()-e.mtimeMs,i=Math.min(e.size,8192),n=Buffer.alloc(i);await a.read(n,0,i,e.size-i);let l=n.toString("utf-8").split("\n").filter(t=>t.trim()),r=$(l,s),o=O(l);if(!r.matched&&e.size>8192){let t=Math.min(e.size,131072),i=Buffer.alloc(t);await a.read(i,0,t,e.size-t);let n=i.toString("utf-8").split("\n").filter(t=>t.trim());r=$(n,s),o.lastAssistantSnippet||o.currentAction||(o=O(n))}return D.size>=256&&D.delete(D.keys().next().value),D.set(t,{mtimeMs:e.mtimeMs,idle:r.idle,stale:r.stale,needsStaleRecheck:r.needsStaleRecheck,staleMs:r.staleMs,lastAssistantSnippet:o.lastAssistantSnippet,currentAction:o.currentAction,reset:o.reset,lastEntryTs:r.lastEntryTs}),{idle:r.idle,stale:r.stale,lastAssistantSnippet:o.lastAssistantSnippet,currentAction:o.currentAction,reset:o.reset,lastEntryTs:r.lastEntryTs,staleMs:r.staleMs}}finally{await a.close()}}catch{return{idle:!1,stale:!1,lastAssistantSnippet:null,currentAction:null,reset:!1,lastEntryTs:null,staleMs:0}}},B=async t=>{let e={toolUsage:{},touchedFiles:[],lastAssistantText:null,lastUserText:null,firstUserTs:null,lastAssistantTs:null,turnDurationMs:null};try{let s=await y.default.stat(t);if(0===s.size)return e;let a=await y.default.open(t,"r");try{let t=Math.min(s.size,131072),e=Buffer.alloc(t);await a.read(e,0,t,s.size-t);let i=e.toString("utf-8").split("\n").filter(t=>t.trim()),n={},l=new Set,r=null,o=null,c=null,u=null,d=null;for(let t=i.length-1;t>=0;t--)try{let e=JSON.parse(i[t]);if("file-history-snapshot"===e.type)break;if(e.isSidechain)continue;"system"!==e.type||"turn_duration"!==e.subtype||"number"!=typeof e.durationMs||d||(d=e.durationMs);let s=e.timestamp?new Date(e.timestamp).getTime():null;if("user"===e.type&&(s&&(u=s),!o&&Array.isArray(e.message?.content))){for(let t of e.message.content)if("text"===t.type&&t.text){o=t.text;break}}if("assistant"===e.type&&(s&&!c&&(c=s),Array.isArray(e.message?.content))){let t=null;for(let s of e.message.content)"tool_use"===s.type&&s.name&&(n[s.name]=(n[s.name]??0)+1,("Edit"===s.name||"Write"===s.name)&&s.input?.file_path&&l.add(String(s.input.file_path))),"text"===s.type&&s.text&&(t=s.text);!r&&t&&(r=t)}}catch{continue}return{toolUsage:n,touchedFiles:[...l],lastAssistantText:r,lastUserText:o,firstUserTs:u,lastAssistantTs:c,turnDurationMs:d}}finally{await a.close()}}catch{return e}},K=/^[✳⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠐⠈]\s+/,V=t=>t&&K.test(t)&&t.replace(K,"").trim()||null,X=globalThis;class G{tabs=new Map;pollingTimer=null;currentInterval=0;clients=new Set;initialized=!1;rateLimitsWatcher=null;lastRateLimits=null;jsonlWatchers=new Map;compactStaleTimers=new Map;async init(){if(!this.initialized){var t;let e,s,a,i,n,l;this.initialized=!0,await this.scanAll(),this.startPolling(),this.rateLimitsWatcher=(t=t=>{this.lastRateLimits=t,this.broadcast({type:"rate-limits:update",data:t})},e=null,s=null,a=0,i=async()=>{try{let e=await y.default.readFile(f.RATE_LIMITS_FILE,"utf-8"),s=JSON.parse(e);s.ts&&s.ts!==a&&(a=s.ts,t(s))}catch{}},n=()=>{i();try{(e=m.default.watch(f.RATE_LIMITS_FILE,()=>{s&&clearTimeout(s),s=setTimeout(i,500)})).on("error",()=>{S.debug("rate-limits.json watch error, retrying..."),l(),setTimeout(n,5e3)})}catch{S.debug("rate-limits.json not found yet, retrying..."),setTimeout(n,5e3)}},{start:n,stop:l=()=>{s&&(clearTimeout(s),s=null),e&&(e.close(),e=null)}}),this.rateLimitsWatcher.start()}}async resolveCurrentProcess(t,e){if(!e||!(e&&c.has(e)))return e;let s=await (0,n.getLastCommand)(t);if(!s)return e;let a=s.split(/\s+/)[0];return a&&a&&a in o?a:e}async scanAll(){let{workspaces:t}=await (0,s.getWorkspaces)(),e=await (0,n.getAllPanesInfo)();for(let t of[...this.jsonlWatchers.keys()])this.stopJsonlWatch(t);for(let s of(this.tabs.clear(),t)){let t=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(s.id));if(t)for(let a of(0,i.collectAllTabs)(t.root)){let t=e.get(a.sessionName),i=await this.readTabMetadata(t),n=a.cliState??"idle",l="busy"===n?"unknown":n,{terminalStatus:r,listeningPorts:o}="claude-code"===a.panelType?{terminalStatus:"idle",listeningPorts:[]}:await this.detectTerminalStatus(t),c=await this.resolveCurrentProcess(a.sessionName,t?.command),u=t?`${c??t.command}|${t.path}`:void 0,d="needs-input"===l?{name:"notification",at:Date.now(),seq:0}:null;this.tabs.set(a.id,{cliState:l,workspaceId:s.id,tabName:a.name||(u?p(u):""),currentProcess:c,paneTitle:u,tmuxSession:a.sessionName,panelType:a.panelType,terminalStatus:r,listeningPorts:o,claudeSummary:a.claudeSummary,lastUserMessage:a.lastUserMessage,lastAssistantMessage:i.lastAssistantSnippet,currentAction:i.currentAction,readyForReviewAt:"ready-for-review"===l?Date.now():null,busySince:null,dismissedAt:a.dismissedAt??null,claudeSessionId:J(i.jsonlPath)??a.claudeSessionId??null,jsonlPath:i.jsonlPath,lastEvent:d,eventSeq:0}),("needs-input"===l||"unknown"===l)&&i.jsonlPath&&this.startJsonlWatch(a.id,i.jsonlPath),"unknown"===l&&this.resolveUnknown(a.id).catch(t=>C.warn("resolveUnknown failed: %s",t))}}}async resolveUnknown(t){let e=this.tabs.get(t);if(!e||"unknown"!==e.cliState)return;let s=(await (0,n.getAllPanesInfo)()).get(e.tmuxSession),a=s?.pid?await (0,l.getChildPids)(s.pid):[];if(!(s?.pid&&await (0,l.isClaudeRunning)(s.pid,a))){this.applyCliState(t,e,"idle",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e);return}if(e.jsonlPath){let{idle:s,stale:a,lastAssistantSnippet:i}=await H(e.jsonlPath);if(s&&!a&&i){this.applyCliState(t,e,"ready-for-review",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e);return}}}async readTabMetadata(t){let e={lastAssistantSnippet:null,currentAction:null,jsonlPath:null};if(!t||!t.pid)return e;let s=await (0,l.getChildPids)(t.pid);if(!await (0,l.isClaudeRunning)(t.pid,s))return e;let a=await (0,l.detectActiveSession)(t.pid,s);if("running"!==a.status||!a.jsonlPath)return{lastAssistantSnippet:null,currentAction:null,jsonlPath:a.jsonlPath??null};let{lastAssistantSnippet:i,currentAction:n}=await H(a.jsonlPath);return{lastAssistantSnippet:i,currentAction:n,jsonlPath:a.jsonlPath}}async detectTerminalStatus(t){if(!t||!t.pid)return{terminalStatus:"idle",listeningPorts:[]};let e=await (0,n.getListeningPorts)(t.pid);return e.length>0?{terminalStatus:"server",listeningPorts:e}:{terminalStatus:n.SAFE_SHELLS.has(t.command)?"idle":"running",listeningPorts:[]}}getPollingInterval(){let t=this.tabs.size;return t>=21?6e4:t>=11?45e3:3e4}async rescan(){await this.scanAll()}startPolling(){this.stopPolling(),this.currentInterval=this.getPollingInterval(),this.pollingTimer=setInterval(()=>{this.poll().catch(t=>{C.error({err:t},"Polling error")})},this.currentInterval)}stopPolling(){this.pollingTimer&&(clearInterval(this.pollingTimer),this.pollingTimer=null,this.currentInterval=0)}async poll(){let{workspaces:t}=await (0,s.getWorkspaces)(),e=await (0,n.getAllPanesInfo)(),r=new Set,o=new Set(this.tabs.keys()),c=Date.now();for(let s of t){let t=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(s.id));if(t)for(let o of(0,i.collectAllTabs)(t.root)){r.add(o.id);let t=this.tabs.get(o.id),i=e.get(o.sessionName),{terminalStatus:u,listeningPorts:d}="claude-code"===o.panelType?{terminalStatus:"idle",listeningPorts:[]}:await this.detectTerminalStatus(i),h=await this.resolveCurrentProcess(o.sessionName,i?.command),m=i?`${h??i.command}|${i.path}`:void 0;if(!t){let t=o.cliState??"idle",e="busy"===t?"unknown":t,a=await this.readTabMetadata(i),n="needs-input"===e?{name:"notification",at:Date.now(),seq:0}:null,l={cliState:e,workspaceId:s.id,tabName:o.name||(m?p(m):""),currentProcess:h,paneTitle:m,tmuxSession:o.sessionName,panelType:o.panelType,terminalStatus:u,listeningPorts:d,claudeSummary:o.claudeSummary,lastUserMessage:o.lastUserMessage,lastAssistantMessage:a.lastAssistantSnippet,currentAction:a.currentAction,claudeSessionId:J(a.jsonlPath)??o.claudeSessionId??null,jsonlPath:a.jsonlPath,lastEvent:n,eventSeq:0};this.tabs.set(o.id,l),this.persistToLayout(l),this.broadcastUpdate(o.id,l),"unknown"===e&&this.resolveUnknown(o.id).catch(t=>C.warn("resolveUnknown failed: %s",t));continue}let y=t.currentProcess!==h,g=t.lastUserMessage!==o.lastUserMessage,f=t.panelType!==o.panelType,S=await this.readTabMetadata(i);t.tabName=o.name||(m?p(m):""),t.currentProcess=h,t.paneTitle=m,t.workspaceId=s.id,t.panelType=o.panelType,t.claudeSessionId=J(S.jsonlPath)??o.claudeSessionId??null,t.jsonlPath=S.jsonlPath??t.jsonlPath,t.lastUserMessage=o.lastUserMessage,y&&(t.processRetries=3);let w=!y&&(t.processRetries??0)>0;w&&(t.processRetries=t.processRetries-1);let b=t.listeningPorts,T=b?.length!==d.length||d.some((t,e)=>b[e]!==t),A=t.terminalStatus!==u||T;A&&(t.terminalStatus=u,t.listeningPorts=d);let v=!1;if("busy"===t.cliState||"needs-input"===t.cliState){let e=V(await (0,n.getPaneTitle)(o.sessionName));e&&e!==t.claudeSummary&&(t.claudeSummary=e,v=!0,(0,a.updateTabClaudeSummary)(o.sessionName,e).catch(()=>{}))}else t.claudeSummary!==o.claudeSummary&&(t.claudeSummary=o.claudeSummary,v=!0);if("busy"===t.cliState&&t.lastEvent&&c-t.lastEvent.at>6e5){let e=i?.pid?await (0,l.getChildPids)(i.pid):[];if(!(i?.pid&&await (0,l.isClaudeRunning)(i.pid,e))){C.info({tabId:o.id},"busy stuck — Claude process gone, forcing idle"),this.applyCliState(o.id,t,"idle",{silent:!0}),this.persistToLayout(t),this.broadcastUpdate(o.id,t);continue}}(A||y||w||g||f||v)&&this.broadcastUpdate(o.id,t)}}for(let t of o)!r.has(t)&&this.tabs.has(t)&&(this.stopJsonlWatch(t),this.tabs.delete(t),this.broadcastRemove(t));let u=this.getPollingInterval();this.pollingTimer&&u!==this.currentInterval&&this.startPolling()}getAllForClient(){let t={};for(let[e,s]of this.tabs)t[e]={cliState:s.cliState,workspaceId:s.workspaceId,tabName:s.tabName,currentProcess:s.currentProcess,paneTitle:s.paneTitle,panelType:s.panelType,terminalStatus:s.terminalStatus,listeningPorts:s.listeningPorts,claudeSummary:s.claudeSummary,lastUserMessage:s.lastUserMessage,lastAssistantMessage:s.lastAssistantMessage,currentAction:s.currentAction,readyForReviewAt:s.readyForReviewAt,busySince:s.busySince,dismissedAt:s.dismissedAt,claudeSessionId:s.claudeSessionId,lastEvent:s.lastEvent,eventSeq:s.eventSeq};return t}applyCliState(t,e,s,a={}){if(e.cliState===s)return;let i=e.busySince;e.cliState=s,e.readyForReviewAt="ready-for-review"===s?Date.now():null,e.busySince="busy"===s?Date.now():null,"busy"===s&&(e.dismissedAt=null),"ready-for-review"===s&&e.jsonlPath&&new Promise(t=>setTimeout(t,500)).then(()=>this.saveSessionHistory(t,e,i,!1)).catch(t=>{C.warn("Failed to save session history: %s",t)}),"ready-for-review"!==s||a.silent||this.sendWebPush(t,e,"review").catch(t=>{C.warn("Web push failed: %s",t)}),"needs-input"!==s||a.silent||this.sendWebPush(t,e,"needs-input").catch(t=>{C.warn("Web push failed: %s",t)});let n=("busy"===s||"needs-input"===s)&&e.jsonlPath,l="ready-for-review"===s&&this.jsonlWatchers.has(t);n&&!this.jsonlWatchers.has(t)?this.startJsonlWatch(t,e.jsonlPath):!n&&!l&&this.jsonlWatchers.has(t)&&this.stopJsonlWatch(t)}async saveSessionHistory(t,e,a,i){if(!e.lastUserMessage)return;let n=e.jsonlPath?await B(e.jsonlPath):null,{workspaces:l}=await (0,s.getWorkspaces)(),r=l.find(t=>t.id===e.workspaceId),o=Date.now(),c=n?.firstUserTs??a??o,u=i?o:n?.lastAssistantTs??o,d=i?u-c:n?.turnDurationMs??u-c,p={id:(0,N.nanoid)(),workspaceId:e.workspaceId,workspaceName:r?.name??e.workspaceId,workspaceDir:r?.directories[0]??null,tabId:t,claudeSessionId:e.claudeSessionId??null,prompt:n?.lastUserText??e.lastUserMessage,result:n?.lastAssistantText??null,startedAt:c,completedAt:u,duration:d,dismissedAt:u,toolUsage:n?.toolUsage??{},touchedFiles:n?.touchedFiles??[],...i?{cancelled:!0}:{}};await E(p),this.broadcast({type:"session-history:update",entry:p})}dismissTab(t,e){let s=this.tabs.get(t);if(!s||"ready-for-review"!==s.cliState)return;let a=Date.now();this.applyCliState(t,s,"idle",{silent:!0}),s.dismissedAt=a,this.persistToLayout(s),this.broadcastUpdate(t,s,e),L(t,a).then(t=>{t&&this.broadcast({type:"session-history:update",entry:t})}).catch(t=>{C.warn("Failed to update session history dismissedAt: %s",t)})}ackNotificationInput(t,e){let s=this.tabs.get(t);s&&"needs-input"===s.cliState&&s.lastEvent?.name==="notification"&&s.lastEvent.seq===e&&(F.debug({tabId:t,seq:e},"ack: needs-input→busy"),this.applyCliState(t,s,"busy"),this.persistToLayout(s),this.broadcastUpdate(t,s))}async recoverUnknownIfPending(t){let e=this.tabs.get(t);if(!e)return{recovered:!1,reason:"no-entry"};if("unknown"!==e.cliState)return{recovered:!1,reason:"not-unknown"};let s=await (0,w.capturePaneAtWidth)(e.tmuxSession,120,50).catch(t=>(C.warn("recoverUnknownIfPending capture failed: %s",t),null));if(!s)return{recovered:!1,reason:"capture-failed"};let{options:a}=(0,b.parsePermissionOptions)(s);if(0===a.length)return{recovered:!1,reason:"no-options"};let i=Date.now(),n=(e.eventSeq??0)+1;return e.eventSeq=n,e.lastEvent={name:"notification",at:i,seq:n},F.debug({tabId:t,seq:n,options:a.length},"recover unknown→needs-input from pane capture"),this.applyCliState(t,e,"needs-input",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e),{recovered:!0}}findTabIdBySession(t){for(let[e,s]of this.tabs)if(s.tmuxSession===t)return e}updateTabFromHook(t,e,s){let a=this.findTabIdBySession(t);if(!a)return void F.debug({tmuxSession:t,event:e,notificationType:s},"no tabId for session");let i=this.tabs.get(a);if(!i)return void F.debug({tabId:a,event:e,notificationType:s},"no entry for tab");if("pre-compact"===e||"post-compact"===e){F.debug({tabId:a,event:e},"compact hook"),this.setCompacting(a,i,"pre-compact"===e?Date.now():null);return}if("session-start"!==e&&"prompt-submit"!==e&&"notification"!==e&&"stop"!==e)return void F.debug({tabId:a,event:e,notificationType:s},"unknown event, ignoring");if("notification"===e&&s&&!z.has(s))return void F.debug({tabId:a,event:e,notificationType:s},"non-input notification, skipping state transition");let n=Date.now(),l=(i.eventSeq??0)+1;i.eventSeq=l,i.lastEvent={name:e,at:n,seq:l},this.broadcast({type:"status:hook-event",tabId:a,event:i.lastEvent});let r=i.cliState,o="cancelled"===r?r:((t,e)=>{if(!t)return e;switch(t.name){case"session-start":return"idle";case"prompt-submit":return"busy";case"notification":return"needs-input";case"stop":return"ready-for-review"}})(i.lastEvent,r);if(F.debug({tabId:a,event:e,notificationType:s,seq:l,prevState:r,newState:o,transition:r!==o},`processed ${e}${s?`(${s})`:""} ${r}→${o}`),r!==o&&(this.applyCliState(a,i,o),this.persistToLayout(i),this.broadcastUpdate(a,i)),"busy"!==o&&"needs-input"!==o||i.jsonlPath||this.resolveAndWatchJsonl(a,t).catch(()=>{}),"stop"===e&&i.jsonlPath){let t=()=>{H(i.jsonlPath).then(({currentAction:t,lastAssistantSnippet:e,reset:s})=>{let n=!1;s?(null!==i.currentAction&&(i.currentAction=null,n=!0),null!==i.lastAssistantMessage&&(i.lastAssistantMessage=null,n=!0)):(null!==t&&t.summary!==i.currentAction?.summary&&(i.currentAction=t,n=!0),null!==e&&i.lastAssistantMessage!==e&&(i.lastAssistantMessage=e,n=!0)),n&&this.broadcastUpdate(a,i)}).catch(()=>{})};t(),setTimeout(()=>{D.delete(i.jsonlPath),t()},500)}}setCompacting(t,e,s){let a=this.compactStaleTimers.get(t);if(a&&(clearTimeout(a),this.compactStaleTimers.delete(t)),(e.compactingSince??null)!==s&&(e.compactingSince=s,this.broadcastUpdate(t,e),null!==s)){let e=setTimeout(()=>{this.compactStaleTimers.delete(t);let e=this.tabs.get(t);e&&e.compactingSince===s&&(e.compactingSince=null,F.debug({tabId:t},"compact stale, auto-cleared"),this.broadcastUpdate(t,e))},6e4);this.compactStaleTimers.set(t,e)}}removeTab(t){let e=this.tabs.get(t);e&&("busy"===e.cliState||"needs-input"===e.cliState)&&e.lastUserMessage&&this.saveSessionHistory(t,e,e.busySince,!0).catch(t=>{C.warn("Failed to save cancelled session history: %s",t)}),this.stopJsonlWatch(t);let s=this.compactStaleTimers.get(t);s&&(clearTimeout(s),this.compactStaleTimers.delete(t)),this.tabs.delete(t),this.broadcastRemove(t)}reconcileWorkspaceTabs(t,e){let s=new Set(e);for(let[e,a]of this.tabs)a.workspaceId!==t||s.has(e)||this.removeTab(e)}removeWorkspaceTabs(t){for(let[e,s]of this.tabs)s.workspaceId===t&&this.removeTab(e)}registerTab(t,e){this.tabs.set(t,e),this.broadcastUpdate(t,e)}addClient(t){this.clients.add(t),this.lastRateLimits&&t.readyState===e.WebSocket.OPEN&&t.send(JSON.stringify({type:"rate-limits:update",data:this.lastRateLimits}))}removeClient(t){this.clients.delete(t)}persistToLayout(t){(0,a.updateTabCliStatus)(t.tmuxSession,t.cliState,t.dismissedAt).catch(()=>{})}broadcastUpdate(t,e,s){let a={type:"status:update",tabId:t,cliState:e.cliState,workspaceId:e.workspaceId,tabName:e.tabName,currentProcess:e.currentProcess,paneTitle:e.paneTitle,panelType:e.panelType,terminalStatus:e.terminalStatus,listeningPorts:e.listeningPorts,claudeSummary:e.claudeSummary,lastUserMessage:e.lastUserMessage,lastAssistantMessage:e.lastAssistantMessage,currentAction:e.currentAction,readyForReviewAt:e.readyForReviewAt,busySince:e.busySince,dismissedAt:e.dismissedAt,claudeSessionId:e.claudeSessionId,compactingSince:e.compactingSince,lastEvent:e.lastEvent,eventSeq:e.eventSeq};this.broadcast(a,s)}broadcastRemove(t){this.broadcast({type:"status:update",tabId:t,cliState:null,workspaceId:"",tabName:""})}static BACKPRESSURE_LIMIT=1048576;broadcast(t,s){let a=JSON.stringify(t);for(let t of this.clients)t!==s&&t.readyState===e.WebSocket.OPEN&&t.bufferedAmount<G.BACKPRESSURE_LIMIT&&t.send(a)}async resolveAndWatchJsonl(t,e){let s=this.tabs.get(t);if(!s||s.jsonlPath)return;let o=null,c=(0,a.parseSessionName)(e);if(c){let l=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(c.wsId));if(l){let a=(0,i.collectAllTabs)(l.root).find(t=>t.sessionName===e);if(a?.claudeSessionId){let t=await (0,n.getSessionCwd)(e);if(t){let e=`${(0,r.cwdToProjectPath)(t)}/${a.claudeSessionId}.jsonl`;try{await y.default.access(e),o=e}catch{}}}a?.lastUserMessage&&s.lastUserMessage!==a.lastUserMessage&&(s.lastUserMessage=a.lastUserMessage,this.broadcastUpdate(t,s))}}if(!o){let t=await (0,n.getSessionPanePid)(e);t&&(o=(await (0,l.detectActiveSession)(t)).jsonlPath)}o&&(s.jsonlPath=o,"busy"!==s.cliState&&"needs-input"!==s.cliState||this.jsonlWatchers.has(t)||this.startJsonlWatch(t,o))}startJsonlWatch(t,e){let s=this.jsonlWatchers.get(t);if(s?.jsonlPath!==e){s&&this.stopJsonlWatch(t),C.debug("startJsonlWatch tabId=%s path=%s",t,e);try{let s=(0,m.watch)(e,()=>{let s=this.jsonlWatchers.get(t);s&&(s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout(()=>{this.onJsonlFileChange(t,e).catch(()=>{})},100))});s.on("error",()=>{this.stopJsonlWatch(t)}),this.jsonlWatchers.set(t,{watcher:s,jsonlPath:e,debounceTimer:null})}catch{}}}stopJsonlWatch(t){let e=this.jsonlWatchers.get(t);if(e){C.debug("stopJsonlWatch tabId=%s",t),e.debounceTimer&&clearTimeout(e.debounceTimer);try{e.watcher.close()}catch{}this.jsonlWatchers.delete(t)}}async onJsonlFileChange(t,e){let s=this.tabs.get(t);if(!s||"busy"!==s.cliState&&"needs-input"!==s.cliState&&"unknown"!==s.cliState&&"ready-for-review"!==s.cliState)return void this.stopJsonlWatch(t);let{currentAction:a,lastAssistantSnippet:i,reset:n}=await H(e),l=!1;n?(null!==s.currentAction&&(s.currentAction=null,l=!0),null!==s.lastAssistantMessage&&(s.lastAssistantMessage=null,l=!0)):(null!==a&&a.summary!==s.currentAction?.summary&&(s.currentAction=a,l=!0),null!==i&&s.lastAssistantMessage!==i&&(s.lastAssistantMessage=i,l=!0)),l&&this.broadcastUpdate(t,s)}shutdown(){for(let t of(this.stopPolling(),this.rateLimitsWatcher?.stop(),[...this.jsonlWatchers.keys()]))this.stopJsonlWatch(t);for(let t of this.clients)t.readyState===e.WebSocket.OPEN&&t.close(1001,"Server shutting down");this.clients.clear()}notifyLastUserMessage(t,e){let s=(0,a.parseSessionName)(t);if(!s)return;let i=this.tabs.get(s.tabId);i&&i.lastUserMessage!==e&&(i.lastUserMessage=e,this.broadcastUpdate(s.tabId,i))}async sendWebPush(t,e,a){let i=await (0,x.getSubscriptions)();if(0===i.length)return;let n=await (0,_.getVAPIDKeys)();R.default.setVapidDetails("mailto:noreply@purplemux.app",n.publicKey,n.privateKey);let l=e.lastUserMessage?.slice(0,100)||e.tabName||t,r=(await (0,s.getWorkspaces)()).workspaces.find(t=>t.id===e.workspaceId),o=JSON.stringify({title:"needs-input"===a?"Input Required":"Task Complete",body:l,tabId:t,workspaceId:e.workspaceId,claudeSessionId:e.claudeSessionId??null,workspaceName:r?.name??"",workspaceDir:r?.directories[0]??null});if(!(0,x.isAnyDeviceVisible)())for(let t of i)try{await R.default.sendNotification(t,o)}catch(s){let e=s.statusCode;(410===e||404===e)&&await (0,x.removeSubscription)(t.endpoint),C.warn("Web push send error: %s",e)}}}t.s(["getStatusManager",0,()=>{if(!X.__ptStatusManager){let t=new G;X.__ptStatusManager=t,(0,a.setLayoutReconciler)({reconcileWorkspaceTabs:(e,s)=>t.reconcileWorkspaceTabs(e,s),removeWorkspaceTabs:e=>t.removeWorkspaceTabs(e)})}return X.__ptStatusManager}],964759)}];
|
|
1
|
+
module.exports=[964759,t=>{"use strict";t.i(478319);var e=t.i(220951),s=t.i(322429),a=t.i(825265),i=t.i(804767),n=t.i(459015),l=t.i(143511),r=t.i(746514);let o={bash:"",zsh:"",fish:"",sh:"",dash:"",tcsh:"",nu:"",nvim:"",vim:"",vi:"",nano:"",emacs:"",hx:"",code:"",git:"",gitui:"",tig:"",gh:"",lazygit:"",jj:"",lazyjj:"",node:"",deno:"",bun:"",python:"",python3:"",go:"",ruby:"",java:"",rust:"",rustc:"",cargo:"",swift:"",dart:"",elixir:"",perl:"",php:"",R:"",julia:"",scala:"",zig:"",npm:"",pnpm:"",yarn:"",pip:"",pip3:"",brew:"",apt:"",dnf:"",pacman:"",yay:"",paru:"",make:"",cmake:"",gradle:"",maven:"",webpack:"",tsc:"",docker:"",lazydocker:"",kubectl:"",k9s:"",helm:"",minikube:"",aws:"",gcloud:"",terraform:"",ansible:"",vagrant:"",ssh:"",scp:"",curl:"",wget:"",rsync:"",ping:"",htop:"",btop:"",top:"",btm:"",glances:"",mactop:"",ranger:"",yazi:"",lf:"",lfcd:"",mysql:"",psql:"",mongo:"",redis:"",sqlite:"",tmux:"",screen:"",sudo:"",bat:"",gpg:"",openssl:"",zip:"",unzip:"",jest:"",claude:"",codex:""},c=new Set(["node","python","python3","ruby","perl","deno","bun"]),u=new Set(["zsh","bash","fish","sh","-zsh","-bash","-fish","-sh"]),d=t=>{if("~"===t||"/"===t)return t;let e=t.replace(/\/$/,"").split("/");return e[e.length-1]||t},p=t=>{let e=t.trim();if(!e)return"";let s=(t=>{let e=t.trim();if(!e)return null;let s=e.indexOf("|");return s>0?e.slice(0,s):null})(t);if(null!==s){let t=e.slice(e.indexOf("|")+1);return u.has(s)?d(t):s}let a=e.match(/@[^:]+:\s*(.*)/);if(a)return d(a[1].trim());if(e.startsWith("/")||e.startsWith("~"))return d(e);let i=e.split(/\s+/)[0];return u.has(i)?"":i||""};var h=t.i(840665),m=t.i(522734),y=t.i(924868),g=t.i(25146),f=t.i(796902);let S=(0,g.createLogger)("rate-limits");var b=t.i(971780),w=t.i(443571),T=t.i(814747),A=t.i(446786);let v=(0,g.createLogger)("session-history"),k=T.default.join(A.default.homedir(),".purplemux"),P=T.default.join(k,"session-history.json"),M=globalThis;M.__purplemuxSessionHistoryLock||(M.__purplemuxSessionHistoryLock=Promise.resolve());let I=async t=>{let e,s=new Promise(t=>{e=t}),a=M.__purplemuxSessionHistoryLock;M.__purplemuxSessionHistoryLock=s,await a;try{return await t()}finally{e()}},j=()=>({version:1,entries:[]}),U=async()=>{let t;try{t=await y.default.readFile(P,"utf-8")}catch{return j()}try{return JSON.parse(t)}catch{v.warn("Failed to parse session-history.json, starting empty");try{await y.default.copyFile(P,P.replace(/\.json$/,".json.bak"))}catch{}return j()}},W=async t=>{let e=JSON.stringify(t.entries);if(M.__purplemuxSessionHistoryContentCache===e)return;let s=P+".tmp";try{await y.default.writeFile(s,JSON.stringify(t,null,2),{mode:384}),await y.default.rename(s,P)}catch(t){throw await y.default.unlink(s).catch(()=>{}),t}M.__purplemuxSessionHistoryContentCache=e},E=async t=>{await I(async()=>{let e=await U();e.entries.unshift(t),e.entries.length>200&&(e.entries=e.entries.slice(0,200)),await W(e)})},L=async(t,e)=>await I(async()=>{let s=await U(),a=s.entries.find(e=>e.tabId===t&&null===e.dismissedAt);return a?(a.dismissedAt=e,await W(s),a):null});var x=t.i(157469),R=t.i(75874),N=t.i(228448),_=t.i(44014);let C=(0,g.createLogger)("status"),F=(0,g.createLogger)("hooks"),J=t=>t?T.default.basename(t,".jsonl"):null,z=new Set(["permission_prompt","worker_permission_prompt"]),D=new Map,q=t=>{let e=t.name??"Tool",s=t.input??{};return{toolName:e,summary:(0,h.summarizeToolCall)(e,s)}},O=t=>{let e=!1;for(let s=t.length-1;s>=0;s--)try{let a=JSON.parse(t[s]);if(a.isSidechain)continue;if("user"===a.type){let t=a.message?.content;Array.isArray(t)&&t.some(t=>"tool_result"===t.type)||(e=!0);continue}if("assistant"!==a.type||!a.message?.content)continue;if(e)return{lastAssistantSnippet:null,currentAction:null,reset:!0};let i=a.message.content;if(!Array.isArray(i))continue;let n=null,l=null;for(let t=i.length-1;t>=0;t--){let e=i[t];if("tool_use"===e.type){l=q(e);break}if("text"===e.type&&e.text?.trim()){let t=e.text.trim();l={toolName:null,summary:t.length>200?t.slice(0,200)+"…":t};break}}for(let t=i.length-1;t>=0;t--)if("text"===i[t].type&&i[t].text?.trim()){let e=i[t].text.trim();n=e.length>200?e.slice(0,200)+"…":e;break}return{lastAssistantSnippet:n,currentAction:l,reset:!1}}catch{continue}return{lastAssistantSnippet:null,currentAction:null,reset:!1}},$=(t,e)=>{for(let s=t.length-1;s>=0;s--)try{let a=JSON.parse(t[s]);if(a.isSidechain)continue;let i=a.timestamp?new Date(a.timestamp).getTime():null;if("system"===a.type&&("stop_hook_summary"===a.subtype||"turn_duration"===a.subtype))return{matched:!0,idle:!0,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i,interrupted:!1};if("assistant"===a.type){let t=a.message?.stop_reason;if(!t){let t=e>2e4;return{matched:!0,idle:t,stale:!0,needsStaleRecheck:!t,staleMs:2e4,lastEntryTs:i,interrupted:!1}}return{matched:!0,idle:"tool_use"!==t,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i,interrupted:!1}}if("user"===a.type){let t=a.message?.content;if(Array.isArray(t)&&1===t.length&&"string"==typeof t[0]?.text&&t[0].text.startsWith(h.INTERRUPT_PREFIX))return{matched:!0,idle:!0,stale:!1,needsStaleRecheck:!1,staleMs:0,lastEntryTs:i,interrupted:!0};let s=e>9e4;return{matched:!0,idle:s,stale:!0,needsStaleRecheck:!s,staleMs:9e4,lastEntryTs:i,interrupted:!1}}}catch{continue}return{matched:!1,idle:e>9e4,stale:!0,needsStaleRecheck:e<=9e4,staleMs:9e4,lastEntryTs:null,interrupted:!1}},H=async t=>{try{let e=await y.default.stat(t);if(0===e.size)return{idle:!0,stale:!1,lastAssistantSnippet:null,currentAction:null,reset:!1,lastEntryTs:null,staleMs:0,interrupted:!1};let s=D.get(t);if(s&&s.mtimeMs===e.mtimeMs){if(D.delete(t),D.set(t,s),s.idle)return{idle:!0,stale:s.stale,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs,interrupted:s.interrupted};if(s.needsStaleRecheck)return{idle:Date.now()-e.mtimeMs>s.staleMs,stale:!0,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs,interrupted:s.interrupted};return{idle:!1,stale:!1,lastAssistantSnippet:s.lastAssistantSnippet,currentAction:s.currentAction,reset:s.reset,lastEntryTs:s.lastEntryTs,staleMs:s.staleMs,interrupted:s.interrupted}}let a=await y.default.open(t,"r");try{let s=Date.now()-e.mtimeMs,i=Math.min(e.size,8192),n=Buffer.alloc(i);await a.read(n,0,i,e.size-i);let l=n.toString("utf-8").split("\n").filter(t=>t.trim()),r=$(l,s),o=O(l);if(!r.matched&&e.size>8192){let t=Math.min(e.size,131072),i=Buffer.alloc(t);await a.read(i,0,t,e.size-t);let n=i.toString("utf-8").split("\n").filter(t=>t.trim());r=$(n,s),o.lastAssistantSnippet||o.currentAction||(o=O(n))}return D.size>=256&&D.delete(D.keys().next().value),D.set(t,{mtimeMs:e.mtimeMs,idle:r.idle,stale:r.stale,needsStaleRecheck:r.needsStaleRecheck,staleMs:r.staleMs,lastAssistantSnippet:o.lastAssistantSnippet,currentAction:o.currentAction,reset:o.reset,lastEntryTs:r.lastEntryTs,interrupted:r.interrupted}),{idle:r.idle,stale:r.stale,lastAssistantSnippet:o.lastAssistantSnippet,currentAction:o.currentAction,reset:o.reset,lastEntryTs:r.lastEntryTs,staleMs:r.staleMs,interrupted:r.interrupted}}finally{await a.close()}}catch{return{idle:!1,stale:!1,lastAssistantSnippet:null,currentAction:null,reset:!1,lastEntryTs:null,staleMs:0,interrupted:!1}}},B=async t=>{let e={toolUsage:{},touchedFiles:[],lastAssistantText:null,lastUserText:null,firstUserTs:null,lastAssistantTs:null,turnDurationMs:null};try{let s=await y.default.stat(t);if(0===s.size)return e;let a=await y.default.open(t,"r");try{let t=Math.min(s.size,131072),e=Buffer.alloc(t);await a.read(e,0,t,s.size-t);let i=e.toString("utf-8").split("\n").filter(t=>t.trim()),n={},l=new Set,r=null,o=null,c=null,u=null,d=null;for(let t=i.length-1;t>=0;t--)try{let e=JSON.parse(i[t]);if("file-history-snapshot"===e.type)break;if(e.isSidechain)continue;"system"!==e.type||"turn_duration"!==e.subtype||"number"!=typeof e.durationMs||d||(d=e.durationMs);let s=e.timestamp?new Date(e.timestamp).getTime():null;if("user"===e.type&&(s&&(u=s),!o&&Array.isArray(e.message?.content))){for(let t of e.message.content)if("text"===t.type&&t.text){o=t.text;break}}if("assistant"===e.type&&(s&&!c&&(c=s),Array.isArray(e.message?.content))){let t=null;for(let s of e.message.content)"tool_use"===s.type&&s.name&&(n[s.name]=(n[s.name]??0)+1,("Edit"===s.name||"Write"===s.name)&&s.input?.file_path&&l.add(String(s.input.file_path))),"text"===s.type&&s.text&&(t=s.text);!r&&t&&(r=t)}}catch{continue}return{toolUsage:n,touchedFiles:[...l],lastAssistantText:r,lastUserText:o,firstUserTs:u,lastAssistantTs:c,turnDurationMs:d}}finally{await a.close()}}catch{return e}},K=/^[✳⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠐⠈]\s+/,V=t=>t&&K.test(t)&&t.replace(K,"").trim()||null,X=globalThis;class G{tabs=new Map;pollingTimer=null;currentInterval=0;clients=new Set;initialized=!1;rateLimitsWatcher=null;lastRateLimits=null;jsonlWatchers=new Map;compactStaleTimers=new Map;async init(){if(!this.initialized){var t;let e,s,a,i,n,l;this.initialized=!0,await this.scanAll(),this.startPolling(),this.rateLimitsWatcher=(t=t=>{this.lastRateLimits=t,this.broadcast({type:"rate-limits:update",data:t})},e=null,s=null,a=0,i=async()=>{try{let e=await y.default.readFile(f.RATE_LIMITS_FILE,"utf-8"),s=JSON.parse(e);s.ts&&s.ts!==a&&(a=s.ts,t(s))}catch{}},n=()=>{i();try{(e=m.default.watch(f.RATE_LIMITS_FILE,()=>{s&&clearTimeout(s),s=setTimeout(i,500)})).on("error",()=>{S.debug("rate-limits.json watch error, retrying..."),l(),setTimeout(n,5e3)})}catch{S.debug("rate-limits.json not found yet, retrying..."),setTimeout(n,5e3)}},{start:n,stop:l=()=>{s&&(clearTimeout(s),s=null),e&&(e.close(),e=null)}}),this.rateLimitsWatcher.start()}}async resolveCurrentProcess(t,e){if(!e||!(e&&c.has(e)))return e;let s=await (0,n.getLastCommand)(t);if(!s)return e;let a=s.split(/\s+/)[0];return a&&a&&a in o?a:e}async scanAll(){let{workspaces:t}=await (0,s.getWorkspaces)(),e=await (0,n.getAllPanesInfo)();for(let t of[...this.jsonlWatchers.keys()])this.stopJsonlWatch(t);for(let s of(this.tabs.clear(),t)){let t=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(s.id));if(t)for(let a of(0,i.collectAllTabs)(t.root)){let t=e.get(a.sessionName),i=await this.readTabMetadata(t),n=a.cliState??"idle",l="busy"===n?"unknown":n,{terminalStatus:r,listeningPorts:o}="claude-code"===a.panelType?{terminalStatus:"idle",listeningPorts:[]}:await this.detectTerminalStatus(t),c=await this.resolveCurrentProcess(a.sessionName,t?.command),u=t?`${c??t.command}|${t.path}`:void 0,d="needs-input"===l?{name:"notification",at:Date.now(),seq:0}:null;this.tabs.set(a.id,{cliState:l,workspaceId:s.id,tabName:a.name||(u?p(u):""),currentProcess:c,paneTitle:u,tmuxSession:a.sessionName,panelType:a.panelType,terminalStatus:r,listeningPorts:o,claudeSummary:a.claudeSummary,lastUserMessage:a.lastUserMessage,lastAssistantMessage:i.lastAssistantSnippet,currentAction:i.currentAction,readyForReviewAt:"ready-for-review"===l?Date.now():null,busySince:null,dismissedAt:a.dismissedAt??null,claudeSessionId:J(i.jsonlPath)??a.claudeSessionId??null,jsonlPath:i.jsonlPath,lastEvent:d,eventSeq:0}),("needs-input"===l||"unknown"===l)&&i.jsonlPath&&this.startJsonlWatch(a.id,i.jsonlPath),"unknown"===l&&this.resolveUnknown(a.id).catch(t=>C.warn("resolveUnknown failed: %s",t))}}}async resolveUnknown(t){let e=this.tabs.get(t);if(!e||"unknown"!==e.cliState)return;let s=(await (0,n.getAllPanesInfo)()).get(e.tmuxSession),a=s?.pid?await (0,l.getChildPids)(s.pid):[];if(!(s?.pid&&await (0,l.isClaudeRunning)(s.pid,a))){this.applyCliState(t,e,"idle",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e);return}if(e.jsonlPath){let{idle:s,stale:a,lastAssistantSnippet:i}=await H(e.jsonlPath);if(s&&!a&&i){this.applyCliState(t,e,"ready-for-review",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e);return}}}async readTabMetadata(t){let e={lastAssistantSnippet:null,currentAction:null,jsonlPath:null};if(!t||!t.pid)return e;let s=await (0,l.getChildPids)(t.pid);if(!await (0,l.isClaudeRunning)(t.pid,s))return e;let a=await (0,l.detectActiveSession)(t.pid,s);if("running"!==a.status||!a.jsonlPath)return{lastAssistantSnippet:null,currentAction:null,jsonlPath:a.jsonlPath??null};let{lastAssistantSnippet:i,currentAction:n}=await H(a.jsonlPath);return{lastAssistantSnippet:i,currentAction:n,jsonlPath:a.jsonlPath}}async detectTerminalStatus(t){if(!t||!t.pid)return{terminalStatus:"idle",listeningPorts:[]};let e=await (0,n.getListeningPorts)(t.pid);return e.length>0?{terminalStatus:"server",listeningPorts:e}:{terminalStatus:n.SAFE_SHELLS.has(t.command)?"idle":"running",listeningPorts:[]}}getPollingInterval(){let t=this.tabs.size;return t>=21?6e4:t>=11?45e3:3e4}async rescan(){await this.scanAll()}startPolling(){this.stopPolling(),this.currentInterval=this.getPollingInterval(),this.pollingTimer=setInterval(()=>{this.poll().catch(t=>{C.error({err:t},"Polling error")})},this.currentInterval)}stopPolling(){this.pollingTimer&&(clearInterval(this.pollingTimer),this.pollingTimer=null,this.currentInterval=0)}async poll(){let{workspaces:t}=await (0,s.getWorkspaces)(),e=await (0,n.getAllPanesInfo)(),r=new Set,o=new Set(this.tabs.keys()),c=Date.now();for(let s of t){let t=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(s.id));if(t)for(let o of(0,i.collectAllTabs)(t.root)){r.add(o.id);let t=this.tabs.get(o.id),i=e.get(o.sessionName),{terminalStatus:u,listeningPorts:d}="claude-code"===o.panelType?{terminalStatus:"idle",listeningPorts:[]}:await this.detectTerminalStatus(i),h=await this.resolveCurrentProcess(o.sessionName,i?.command),m=i?`${h??i.command}|${i.path}`:void 0;if(!t){let t=o.cliState??"idle",e="busy"===t?"unknown":t,a=await this.readTabMetadata(i),n="needs-input"===e?{name:"notification",at:Date.now(),seq:0}:null,l={cliState:e,workspaceId:s.id,tabName:o.name||(m?p(m):""),currentProcess:h,paneTitle:m,tmuxSession:o.sessionName,panelType:o.panelType,terminalStatus:u,listeningPorts:d,claudeSummary:o.claudeSummary,lastUserMessage:o.lastUserMessage,lastAssistantMessage:a.lastAssistantSnippet,currentAction:a.currentAction,claudeSessionId:J(a.jsonlPath)??o.claudeSessionId??null,jsonlPath:a.jsonlPath,lastEvent:n,eventSeq:0};this.tabs.set(o.id,l),this.persistToLayout(l),this.broadcastUpdate(o.id,l),"unknown"===e&&this.resolveUnknown(o.id).catch(t=>C.warn("resolveUnknown failed: %s",t));continue}let y=t.currentProcess!==h,g=t.lastUserMessage!==o.lastUserMessage,f=t.panelType!==o.panelType,S=await this.readTabMetadata(i);t.tabName=o.name||(m?p(m):""),t.currentProcess=h,t.paneTitle=m,t.workspaceId=s.id,t.panelType=o.panelType,t.claudeSessionId=J(S.jsonlPath)??o.claudeSessionId??null,t.jsonlPath=S.jsonlPath??t.jsonlPath,t.lastUserMessage=o.lastUserMessage,y&&(t.processRetries=3);let b=!y&&(t.processRetries??0)>0;b&&(t.processRetries=t.processRetries-1);let w=t.listeningPorts,T=w?.length!==d.length||d.some((t,e)=>w[e]!==t),A=t.terminalStatus!==u||T;A&&(t.terminalStatus=u,t.listeningPorts=d);let v=!1;if("busy"===t.cliState||"needs-input"===t.cliState){let e=V(await (0,n.getPaneTitle)(o.sessionName));e&&e!==t.claudeSummary&&(t.claudeSummary=e,v=!0,(0,a.updateTabClaudeSummary)(o.sessionName,e).catch(()=>{}))}else t.claudeSummary!==o.claudeSummary&&(t.claudeSummary=o.claudeSummary,v=!0);if("busy"===t.cliState&&t.lastEvent&&c-t.lastEvent.at>6e5){let e=i?.pid?await (0,l.getChildPids)(i.pid):[];if(!(i?.pid&&await (0,l.isClaudeRunning)(i.pid,e))){C.info({tabId:o.id},"busy stuck — Claude process gone, forcing idle"),this.applyCliState(o.id,t,"idle",{silent:!0}),this.persistToLayout(t),this.broadcastUpdate(o.id,t);continue}}(A||y||b||g||f||v)&&this.broadcastUpdate(o.id,t)}}for(let t of o)!r.has(t)&&this.tabs.has(t)&&(this.stopJsonlWatch(t),this.tabs.delete(t),this.broadcastRemove(t));let u=this.getPollingInterval();this.pollingTimer&&u!==this.currentInterval&&this.startPolling()}getAllForClient(){let t={};for(let[e,s]of this.tabs)t[e]={cliState:s.cliState,workspaceId:s.workspaceId,tabName:s.tabName,currentProcess:s.currentProcess,paneTitle:s.paneTitle,panelType:s.panelType,terminalStatus:s.terminalStatus,listeningPorts:s.listeningPorts,claudeSummary:s.claudeSummary,lastUserMessage:s.lastUserMessage,lastAssistantMessage:s.lastAssistantMessage,currentAction:s.currentAction,readyForReviewAt:s.readyForReviewAt,busySince:s.busySince,dismissedAt:s.dismissedAt,claudeSessionId:s.claudeSessionId,lastEvent:s.lastEvent,eventSeq:s.eventSeq};return t}applyCliState(t,e,s,a={}){if(e.cliState===s)return;let i=e.busySince;e.cliState=s,e.readyForReviewAt="ready-for-review"===s?Date.now():null,e.busySince="busy"===s?Date.now():null,"busy"===s&&(e.dismissedAt=null),"ready-for-review"===s&&e.jsonlPath&&new Promise(t=>setTimeout(t,500)).then(()=>this.saveSessionHistory(t,e,i,!1)).catch(t=>{C.warn("Failed to save session history: %s",t)}),"ready-for-review"!==s||a.silent||this.sendWebPush(t,e,"review").catch(t=>{C.warn("Web push failed: %s",t)}),"needs-input"!==s||a.silent||this.sendWebPush(t,e,"needs-input").catch(t=>{C.warn("Web push failed: %s",t)});let n=("busy"===s||"needs-input"===s)&&e.jsonlPath,l="ready-for-review"===s&&this.jsonlWatchers.has(t);n&&!this.jsonlWatchers.has(t)?this.startJsonlWatch(t,e.jsonlPath):!n&&!l&&this.jsonlWatchers.has(t)&&this.stopJsonlWatch(t)}async saveSessionHistory(t,e,a,i){if(!e.lastUserMessage)return;let n=e.jsonlPath?await B(e.jsonlPath):null,{workspaces:l}=await (0,s.getWorkspaces)(),r=l.find(t=>t.id===e.workspaceId),o=Date.now(),c=n?.firstUserTs??a??o,u=i?o:n?.lastAssistantTs??o,d=i?u-c:n?.turnDurationMs??u-c,p={id:(0,_.nanoid)(),workspaceId:e.workspaceId,workspaceName:r?.name??e.workspaceId,workspaceDir:r?.directories[0]??null,tabId:t,claudeSessionId:e.claudeSessionId??null,prompt:n?.lastUserText??e.lastUserMessage,result:n?.lastAssistantText??null,startedAt:c,completedAt:u,duration:d,dismissedAt:u,toolUsage:n?.toolUsage??{},touchedFiles:n?.touchedFiles??[],...i?{cancelled:!0}:{}};await E(p),this.broadcast({type:"session-history:update",entry:p})}dismissTab(t,e){let s=this.tabs.get(t);if(!s||"ready-for-review"!==s.cliState)return;let a=Date.now();this.applyCliState(t,s,"idle",{silent:!0}),s.dismissedAt=a,this.persistToLayout(s),this.broadcastUpdate(t,s,e),L(t,a).then(t=>{t&&this.broadcast({type:"session-history:update",entry:t})}).catch(t=>{C.warn("Failed to update session history dismissedAt: %s",t)})}ackNotificationInput(t,e){let s=this.tabs.get(t);s&&"needs-input"===s.cliState&&s.lastEvent?.name==="notification"&&s.lastEvent.seq===e&&(F.debug({tabId:t,seq:e},"ack: needs-input→busy"),this.applyCliState(t,s,"busy"),this.persistToLayout(s),this.broadcastUpdate(t,s))}async recoverUnknownIfPending(t){let e=this.tabs.get(t);if(!e)return{recovered:!1,reason:"no-entry"};if("unknown"!==e.cliState)return{recovered:!1,reason:"not-unknown"};let s=await (0,b.capturePaneAtWidth)(e.tmuxSession,120,50).catch(t=>(C.warn("recoverUnknownIfPending capture failed: %s",t),null));if(!s)return{recovered:!1,reason:"capture-failed"};let{options:a}=(0,w.parsePermissionOptions)(s);if(0===a.length)return{recovered:!1,reason:"no-options"};let i=Date.now(),n=(e.eventSeq??0)+1;return e.eventSeq=n,e.lastEvent={name:"notification",at:i,seq:n},F.debug({tabId:t,seq:n,options:a.length},"recover unknown→needs-input from pane capture"),this.applyCliState(t,e,"needs-input",{silent:!0}),this.persistToLayout(e),this.broadcastUpdate(t,e),{recovered:!0}}findTabIdBySession(t){for(let[e,s]of this.tabs)if(s.tmuxSession===t)return e}updateTabFromHook(t,e,s){let a=this.findTabIdBySession(t);if(!a)return void F.debug({tmuxSession:t,event:e,notificationType:s},"no tabId for session");let i=this.tabs.get(a);if(!i)return void F.debug({tabId:a,event:e,notificationType:s},"no entry for tab");if("pre-compact"===e||"post-compact"===e){F.debug({tabId:a,event:e},"compact hook"),this.setCompacting(a,i,"pre-compact"===e?Date.now():null);return}if("session-start"!==e&&"prompt-submit"!==e&&"notification"!==e&&"stop"!==e&&"interrupt"!==e)return void F.debug({tabId:a,event:e,notificationType:s},"unknown event, ignoring");if("notification"===e&&s&&!z.has(s))return void F.debug({tabId:a,event:e,notificationType:s},"non-input notification, skipping state transition");let n=Date.now(),l=(i.eventSeq??0)+1;i.eventSeq=l,i.lastEvent={name:e,at:n,seq:l},this.broadcast({type:"status:hook-event",tabId:a,event:i.lastEvent});let r=i.cliState,o="cancelled"===r?r:((t,e)=>{if(!t)return e;switch(t.name){case"session-start":case"interrupt":return"idle";case"prompt-submit":return"busy";case"notification":return"needs-input";case"stop":return"ready-for-review"}})(i.lastEvent,r);if(F.debug({tabId:a,event:e,notificationType:s,seq:l,prevState:r,newState:o,transition:r!==o},`processed ${e}${s?`(${s})`:""} ${r}→${o}`),r!==o&&(this.applyCliState(a,i,o),this.persistToLayout(i),this.broadcastUpdate(a,i)),"busy"!==o&&"needs-input"!==o||i.jsonlPath||this.resolveAndWatchJsonl(a,t).catch(()=>{}),"stop"===e&&i.jsonlPath){let t=()=>{H(i.jsonlPath).then(({currentAction:t,lastAssistantSnippet:e,reset:s})=>{let n=!1;s?(null!==i.currentAction&&(i.currentAction=null,n=!0),null!==i.lastAssistantMessage&&(i.lastAssistantMessage=null,n=!0)):(null!==t&&t.summary!==i.currentAction?.summary&&(i.currentAction=t,n=!0),null!==e&&i.lastAssistantMessage!==e&&(i.lastAssistantMessage=e,n=!0)),n&&this.broadcastUpdate(a,i)}).catch(()=>{})};t(),setTimeout(()=>{D.delete(i.jsonlPath),t()},500)}}setCompacting(t,e,s){let a=this.compactStaleTimers.get(t);if(a&&(clearTimeout(a),this.compactStaleTimers.delete(t)),(e.compactingSince??null)!==s&&(e.compactingSince=s,this.broadcastUpdate(t,e),null!==s)){let e=setTimeout(()=>{this.compactStaleTimers.delete(t);let e=this.tabs.get(t);e&&e.compactingSince===s&&(e.compactingSince=null,F.debug({tabId:t},"compact stale, auto-cleared"),this.broadcastUpdate(t,e))},6e4);this.compactStaleTimers.set(t,e)}}removeTab(t){let e=this.tabs.get(t);e&&("busy"===e.cliState||"needs-input"===e.cliState)&&e.lastUserMessage&&this.saveSessionHistory(t,e,e.busySince,!0).catch(t=>{C.warn("Failed to save cancelled session history: %s",t)}),this.stopJsonlWatch(t);let s=this.compactStaleTimers.get(t);s&&(clearTimeout(s),this.compactStaleTimers.delete(t)),this.tabs.delete(t),this.broadcastRemove(t)}reconcileWorkspaceTabs(t,e){let s=new Set(e);for(let[e,a]of this.tabs)a.workspaceId!==t||s.has(e)||this.removeTab(e)}removeWorkspaceTabs(t){for(let[e,s]of this.tabs)s.workspaceId===t&&this.removeTab(e)}registerTab(t,e){this.tabs.set(t,e),this.broadcastUpdate(t,e)}addClient(t){this.clients.add(t),this.lastRateLimits&&t.readyState===e.WebSocket.OPEN&&t.send(JSON.stringify({type:"rate-limits:update",data:this.lastRateLimits}))}removeClient(t){this.clients.delete(t)}persistToLayout(t){(0,a.updateTabCliStatus)(t.tmuxSession,t.cliState,t.dismissedAt).catch(()=>{})}broadcastUpdate(t,e,s){let a={type:"status:update",tabId:t,cliState:e.cliState,workspaceId:e.workspaceId,tabName:e.tabName,currentProcess:e.currentProcess,paneTitle:e.paneTitle,panelType:e.panelType,terminalStatus:e.terminalStatus,listeningPorts:e.listeningPorts,claudeSummary:e.claudeSummary,lastUserMessage:e.lastUserMessage,lastAssistantMessage:e.lastAssistantMessage,currentAction:e.currentAction,readyForReviewAt:e.readyForReviewAt,busySince:e.busySince,dismissedAt:e.dismissedAt,claudeSessionId:e.claudeSessionId,compactingSince:e.compactingSince,lastEvent:e.lastEvent,eventSeq:e.eventSeq};this.broadcast(a,s)}broadcastRemove(t){this.broadcast({type:"status:update",tabId:t,cliState:null,workspaceId:"",tabName:""})}static BACKPRESSURE_LIMIT=1048576;broadcast(t,s){let a=JSON.stringify(t);for(let t of this.clients)t!==s&&t.readyState===e.WebSocket.OPEN&&t.bufferedAmount<G.BACKPRESSURE_LIMIT&&t.send(a)}async resolveAndWatchJsonl(t,e){let s=this.tabs.get(t);if(!s||s.jsonlPath)return;let o=null,c=(0,a.parseSessionName)(e);if(c){let l=await (0,a.readLayoutFile)((0,a.resolveLayoutFile)(c.wsId));if(l){let a=(0,i.collectAllTabs)(l.root).find(t=>t.sessionName===e);if(a?.claudeSessionId){let t=await (0,n.getSessionCwd)(e);if(t){let e=`${(0,r.cwdToProjectPath)(t)}/${a.claudeSessionId}.jsonl`;try{await y.default.access(e),o=e}catch{}}}a?.lastUserMessage&&s.lastUserMessage!==a.lastUserMessage&&(s.lastUserMessage=a.lastUserMessage,this.broadcastUpdate(t,s))}}if(!o){let t=await (0,n.getSessionPanePid)(e);t&&(o=(await (0,l.detectActiveSession)(t)).jsonlPath)}o&&(s.jsonlPath=o,"busy"!==s.cliState&&"needs-input"!==s.cliState||this.jsonlWatchers.has(t)||this.startJsonlWatch(t,o))}startJsonlWatch(t,e){let s=this.jsonlWatchers.get(t);if(s?.jsonlPath!==e){s&&this.stopJsonlWatch(t),C.debug("startJsonlWatch tabId=%s path=%s",t,e);try{let s=(0,m.watch)(e,()=>{let s=this.jsonlWatchers.get(t);s&&(s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout(()=>{this.onJsonlFileChange(t,e).catch(()=>{})},100))});s.on("error",()=>{this.stopJsonlWatch(t)}),this.jsonlWatchers.set(t,{watcher:s,jsonlPath:e,debounceTimer:null})}catch{}}}stopJsonlWatch(t){let e=this.jsonlWatchers.get(t);if(e){C.debug("stopJsonlWatch tabId=%s",t),e.debounceTimer&&clearTimeout(e.debounceTimer);try{e.watcher.close()}catch{}this.jsonlWatchers.delete(t)}}async onJsonlFileChange(t,e){let s=this.tabs.get(t);if(!s||"busy"!==s.cliState&&"needs-input"!==s.cliState&&"unknown"!==s.cliState&&"ready-for-review"!==s.cliState)return void this.stopJsonlWatch(t);let{currentAction:a,lastAssistantSnippet:i,reset:n,interrupted:l,lastEntryTs:r}=await H(e);l&&"busy"===s.cliState&&null!==r&&r>(s.lastInterruptTs??0)&&r>(s.lastEvent?.at??0)&&(s.lastInterruptTs=r,F.debug({tabId:t,lastEntryTs:r},"synthetic interrupt from JSONL"),this.updateTabFromHook(s.tmuxSession,"interrupt"));let o=!1;n?(null!==s.currentAction&&(s.currentAction=null,o=!0),null!==s.lastAssistantMessage&&(s.lastAssistantMessage=null,o=!0)):(null!==a&&a.summary!==s.currentAction?.summary&&(s.currentAction=a,o=!0),null!==i&&s.lastAssistantMessage!==i&&(s.lastAssistantMessage=i,o=!0)),o&&this.broadcastUpdate(t,s)}shutdown(){for(let t of(this.stopPolling(),this.rateLimitsWatcher?.stop(),[...this.jsonlWatchers.keys()]))this.stopJsonlWatch(t);for(let t of this.clients)t.readyState===e.WebSocket.OPEN&&t.close(1001,"Server shutting down");this.clients.clear()}notifyLastUserMessage(t,e){let s=(0,a.parseSessionName)(t);if(!s)return;let i=this.tabs.get(s.tabId);i&&i.lastUserMessage!==e&&(i.lastUserMessage=e,this.broadcastUpdate(s.tabId,i))}async sendWebPush(t,e,a){let i=await (0,R.getSubscriptions)();if(0===i.length)return;let n=await (0,N.getVAPIDKeys)();x.default.setVapidDetails("mailto:noreply@purplemux.app",n.publicKey,n.privateKey);let l=e.lastUserMessage?.slice(0,100)||e.tabName||t,r=(await (0,s.getWorkspaces)()).workspaces.find(t=>t.id===e.workspaceId),o=JSON.stringify({title:"needs-input"===a?"Input Required":"Task Complete",body:l,tabId:t,workspaceId:e.workspaceId,claudeSessionId:e.claudeSessionId??null,workspaceName:r?.name??"",workspaceDir:r?.directories[0]??null});if(!(0,R.isAnyDeviceVisible)())for(let t of i)try{await x.default.sendNotification(t,o)}catch(s){let e=s.statusCode;(410===e||404===e)&&await (0,R.removeSubscription)(t.endpoint),C.warn("Web push send error: %s",e)}}}t.s(["getStatusManager",0,()=>{if(!X.__ptStatusManager){let t=new G;X.__ptStatusManager=t,(0,a.setLayoutReconciler)({reconcileWorkspaceTabs:(e,s)=>t.reconcileWorkspaceTabs(e,s),removeWorkspaceTabs:e=>t.removeWorkspaceTabs(e)})}return X.__ptStatusManager}],964759)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_lib_status-manager_ts_003hlhy._.js.map
|