tmux-weblink 2.2.40 → 2.2.41

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.
@@ -1,8 +1,8 @@
1
- import{existsSync as P,readdirSync as me,statSync as T,unlinkSync as fe,writeFileSync as pe,mkdirSync as he,readFileSync as z}from"node:fs";import{readFile as ge}from"node:fs/promises";import{execSync as C,execFileSync as L}from"node:child_process";import{tmuxEnv as ye}from"./tmux-env.js";import g from"node:path";import{fileURLToPath as je}from"node:url";import{Hono as we}from"hono";import{listSessions as F}from"../sessions.js";import{createRequire as ke}from"node:module";import{renderLoginPage as ve,renderNotesIndex as qe,renderNotesPage as Se,renderSettings as be,renderThemeSettings as Te,renderHistoryIndex as Ae,renderQuickCommandsPage as xe,renderFilesIndex as Ce,renderShell as Ie}from"../frontend.js";import{renderFederationPage as _e}from"./pages/federation.js";import{createAgentToken as Ee,removeAgentToken as Oe,listAgentTokens as V}from"./agent-tokens.js";import{hashPassword as Ne,verifyPassword as Re,validatePassword as Pe}from"./auth.js";import{atomicWriteFileSync as Le}from"./atomicWrite.js";import{resolveFsPath as A,resolveFsRoots as Q,MAX_FILE_BYTES as K,walkRecursive as Fe,fsEntryCmp as X}from"./fs-access.js";import{captureSessionWindowsWithPath as De}from"./tmux-windows.js";import{audit as k}from"./auditLog.js";import{db as S}from"./db.js";import{getSessionAccessMap as He}from"./session-access.js";import{listWindowHistory as Me,clearWindowHistory as Ue}from"./window-history.js";import{saveSecurityConfig as We}from"./security-config.js";import{ImageUploadError as $e,saveUploadedImage as Be}from"./image-upload.js";import{readSettings as Z,writeSettings as Ge}from"./settings.js";import{setActiveThemeTemplate as Y}from"./theme-store.js";import{isThemeTemplateId as J,THEME_TEMPLATE_IDS as ze}from"./themes/index.js";import{pinView as Ve,unpinView as Qe,listPinnedViews as Ke}from"./pinned-views.js";import{getStoredWindows as Xe}from"./session-windows.js";import{buildSidebarSessions as Ze}from"./sessions-sidebar.js";import{upsertSessionState as ee,removeSessionState as D,renameSessionState as H,computeTombstones as Ye,getSessionState as Je}from"./session-state.js";import{createQuickCommand as et,deleteQuickCommand as tt,listQuickCommands as te,updateQuickCommand as rt}from"./quick-commands.js";import{getSystemStatus as nt,getTopProcesses as st,killProcess as ot}from"./system-monitor.js";import{newTmuxSession as re,renameSession as it,killSession as at,sessionExists as dt,TmuxWindowsError as ne}from"./tmux-windows.js";import{registerAgentTunnel as ut}from"./agent-tunnel.js";import{injectScopeScript as ct}from"./scope-script.js";const M="tmux-web-token",lt=365;function mt(x){return x==="127.0.0.1"||x==="::1"||x==="::ffff:127.0.0.1"}const ft=ke(import.meta.url),{version:pt}=ft("../../package.json");function Zt(x){const{mode:se,securityConfig:y,tokenStore:w,rateLimiter:_,settings:ht,terminalBufferConfig:E,getAgentId:U,state:l,federation:v,hub:p}=x,q=se==="agent";function I(e){if(y.security.trustProxy){const t=(e.req.header("x-forwarded-for")||"").split(",")[0].trim();if(t)return t}return e.env?.incoming?.socket?.remoteAddress||"unknown"}function O(e){const t=e.req.header("authorization");if(t?.startsWith("Bearer "))return t.slice(7);const r=e.req.header("cookie");if(!r)return null;const n=r.match(new RegExp(`(?:^|;\\s*)${M}=([^;]+)`));return n?decodeURIComponent(n[1]):null}function gt(e){const t=O(e);return t?w.validateToken(t):null}function W(e,t){const r=e.req.header("x-forwarded-proto")==="https"||e.req.url.startsWith("https:");e.header("Set-Cookie",`${M}=${encodeURIComponent(t)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${lt*86400}${r?"; Secure":""}`)}function oe(e){e.header("Set-Cookie",`${M}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`)}const i=()=>q?async(e,t)=>t():async(e,t)=>{const r=O(e);return!r||!w.validateToken(r)?(k("http_unauthorized",{ip:I(e)}),e.json({error:"unauthorized"},401)):t()},j=()=>q?async(e,t)=>t():async(e,t)=>{const r=O(e);if(!r||!w.validateToken(r)){const n=encodeURIComponent(e.req.url);return e.redirect(`/login?returnTo=${n}`,302)}return t()};function N(e){const t=F(),r=new Set(t.map(c=>c.name)),n=Ze(t,He(),Ke()),o=[],a=new Map,u=new Map;if(p)for(const c of p.agents.list()){const d=p.agents.get(c.agentId);a.set(c.agentId,new Set((d?d.sessions:[]).map(m=>m.name))),u.set(c.agentId,c.online),o.push({agentId:c.agentId,agentName:c.name,online:c.online,sessions:d?d.sessions:[]})}const h=Ye(r,a,u);return{...n,currentSession:e??null,agents:o,tombstones:h}}function $(e){const t=typeof e.sessionName=="string"?e.sessionName.trim():"";if(!t)return{error:"sessionName is required"};if(e.windowIndex===void 0)return{sessionName:t};const r=e.windowIndex;return typeof r!="number"||!Number.isInteger(r)||r<0?{error:"windowIndex must be a non-negative integer"}:{sessionName:t,windowIndex:r}}const s=new we;s.use("*",async(e,t)=>{await t(),(e.res.headers.get("content-type")||"").includes("text/html")&&e.header("Cache-Control","no-store"),e.header("X-Content-Type-Options","nosniff"),e.header("X-Frame-Options","DENY"),e.header("Content-Security-Policy",["default-src 'self'","script-src 'self' 'unsafe-inline'","style-src 'self' 'unsafe-inline' https://fonts.googleapis.com","connect-src 'self' ws: wss: http: https:","img-src 'self' data:","font-src 'self' https://fonts.gstatic.com","worker-src 'self' blob:"].join("; ")),e.header("Referrer-Policy","strict-origin-when-cross-origin")}),s.use("*",async(e,t)=>{const r=e.req.method;if(r==="GET"||r==="HEAD"||r==="OPTIONS")return t();const n=e.req.header("sec-fetch-site");return n&&n!=="same-origin"&&n!=="none"?e.text("cross-site request blocked",403):t()}),q||s.use("*",async(e,t)=>{if(await t(),e.req.method!=="GET"||e.req.path==="/login"||!(e.res.headers.get("content-type")??"").includes("text/html"))return;const n=await e.res.text();e.res=new Response(ct(n,{prefix:"",agentId:null}),e.res)});const B=g.dirname(je(import.meta.url)),ie=[g.join(B,"..","assets"),g.join(B,"assets"),g.join(process.cwd(),"dist","assets")];s.get("/assets/:file",async e=>{const t=e.req.param("file");if(!/^[a-zA-Z0-9._-]+$/.test(t))return e.notFound();for(const r of ie){const n=g.join(r,t);if(!P(n))continue;const o=await ge(n),a=g.extname(t),u={".css":"text/css; charset=utf-8",".js":"application/javascript; charset=utf-8",".map":"application/json; charset=utf-8"};return e.body(o,200,{"Content-Type":u[a]??"application/octet-stream","Cache-Control":a===".js"||a===".css"?"no-cache":"public, max-age=3600"})}return e.notFound()});const ae=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
1
+ import{existsSync as P,readdirSync as me,statSync as T,unlinkSync as fe,writeFileSync as pe,mkdirSync as he,readFileSync as z}from"node:fs";import{readFile as ge}from"node:fs/promises";import{execSync as C,execFileSync as L}from"node:child_process";import{tmuxEnv as ye}from"./tmux-env.js";import g from"node:path";import{fileURLToPath as je}from"node:url";import{Hono as we}from"hono";import{listSessions as F}from"../sessions.js";import{createRequire as ke}from"node:module";import{getBotManager as ve}from"./bots/manager.js";import{registerBotRoutes as qe}from"./bots/routes.js";import{renderLoginPage as Se,renderNotesIndex as be,renderNotesPage as Te,renderSettings as Ae,renderThemeSettings as xe,renderHistoryIndex as Ce,renderQuickCommandsPage as Ie,renderFilesIndex as _e,renderShell as Ee}from"../frontend.js";import{renderFederationPage as Oe}from"./pages/federation.js";import{createAgentToken as Ne,removeAgentToken as Re,listAgentTokens as V}from"./agent-tokens.js";import{hashPassword as Pe,verifyPassword as Le,validatePassword as Fe}from"./auth.js";import{atomicWriteFileSync as De}from"./atomicWrite.js";import{resolveFsPath as A,resolveFsRoots as Q,MAX_FILE_BYTES as K,walkRecursive as He,fsEntryCmp as X}from"./fs-access.js";import{captureSessionWindowsWithPath as Me}from"./tmux-windows.js";import{audit as v}from"./auditLog.js";import{db as S}from"./db.js";import{getSessionAccessMap as Ue}from"./session-access.js";import{listWindowHistory as We,clearWindowHistory as Be}from"./window-history.js";import{saveSecurityConfig as $e}from"./security-config.js";import{ImageUploadError as Ge,saveUploadedImage as ze}from"./image-upload.js";import{readSettings as Z,writeSettings as Ve}from"./settings.js";import{setActiveThemeTemplate as Y}from"./theme-store.js";import{isThemeTemplateId as J,THEME_TEMPLATE_IDS as Qe}from"./themes/index.js";import{pinView as Ke,unpinView as Xe,listPinnedViews as Ze}from"./pinned-views.js";import{getStoredWindows as Ye}from"./session-windows.js";import{buildSidebarSessions as Je}from"./sessions-sidebar.js";import{upsertSessionState as ee,removeSessionState as D,renameSessionState as H,computeTombstones as et,getSessionState as tt}from"./session-state.js";import{createQuickCommand as rt,deleteQuickCommand as nt,listQuickCommands as te,updateQuickCommand as ot}from"./quick-commands.js";import{getSystemStatus as st,getTopProcesses as it,killProcess as at}from"./system-monitor.js";import{newTmuxSession as re,renameSession as dt,killSession as ut,sessionExists as ct,TmuxWindowsError as ne}from"./tmux-windows.js";import{registerAgentTunnel as lt}from"./agent-tunnel.js";import{injectScopeScript as mt}from"./scope-script.js";const M="tmux-web-token",ft=365;function pt(x){return x==="127.0.0.1"||x==="::1"||x==="::ffff:127.0.0.1"}const ht=ke(import.meta.url),{version:gt}=ht("../../package.json");function tr(x){const{mode:oe,securityConfig:y,tokenStore:w,rateLimiter:_,settings:yt,terminalBufferConfig:E,getAgentId:U,state:l,federation:q,hub:p}=x,k=oe==="agent";function I(e){if(y.security.trustProxy){const t=(e.req.header("x-forwarded-for")||"").split(",")[0].trim();if(t)return t}return e.env?.incoming?.socket?.remoteAddress||"unknown"}function O(e){const t=e.req.header("authorization");if(t?.startsWith("Bearer "))return t.slice(7);const r=e.req.header("cookie");if(!r)return null;const n=r.match(new RegExp(`(?:^|;\\s*)${M}=([^;]+)`));return n?decodeURIComponent(n[1]):null}function jt(e){const t=O(e);return t?w.validateToken(t):null}function W(e,t){const r=e.req.header("x-forwarded-proto")==="https"||e.req.url.startsWith("https:");e.header("Set-Cookie",`${M}=${encodeURIComponent(t)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${ft*86400}${r?"; Secure":""}`)}function se(e){e.header("Set-Cookie",`${M}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`)}const s=()=>k?async(e,t)=>t():async(e,t)=>{const r=O(e);return!r||!w.validateToken(r)?(v("http_unauthorized",{ip:I(e)}),e.json({error:"unauthorized"},401)):t()},j=()=>k?async(e,t)=>t():async(e,t)=>{const r=O(e);if(!r||!w.validateToken(r)){const n=encodeURIComponent(e.req.url);return e.redirect(`/login?returnTo=${n}`,302)}return t()};function N(e){const t=F(),r=new Set(t.map(c=>c.name)),n=Je(t,Ue(),Ze()),i=[],a=new Map,u=new Map;if(p)for(const c of p.agents.list()){const d=p.agents.get(c.agentId);a.set(c.agentId,new Set((d?d.sessions:[]).map(m=>m.name))),u.set(c.agentId,c.online),i.push({agentId:c.agentId,agentName:c.name,online:c.online,sessions:d?d.sessions:[]})}const h=et(r,a,u);return{...n,currentSession:e??null,agents:i,tombstones:h}}function B(e){const t=typeof e.sessionName=="string"?e.sessionName.trim():"";if(!t)return{error:"sessionName is required"};if(e.windowIndex===void 0)return{sessionName:t};const r=e.windowIndex;return typeof r!="number"||!Number.isInteger(r)||r<0?{error:"windowIndex must be a non-negative integer"}:{sessionName:t,windowIndex:r}}const o=new we;o.use("*",async(e,t)=>{await t(),(e.res.headers.get("content-type")||"").includes("text/html")&&e.header("Cache-Control","no-store"),e.header("X-Content-Type-Options","nosniff"),e.header("X-Frame-Options","DENY"),e.header("Content-Security-Policy",["default-src 'self'","script-src 'self' 'unsafe-inline'","style-src 'self' 'unsafe-inline' https://fonts.googleapis.com","connect-src 'self' ws: wss: http: https:","img-src 'self' data:","font-src 'self' https://fonts.gstatic.com","worker-src 'self' blob:"].join("; ")),e.header("Referrer-Policy","strict-origin-when-cross-origin")}),o.use("*",async(e,t)=>{const r=e.req.method;if(r==="GET"||r==="HEAD"||r==="OPTIONS")return t();const n=e.req.header("sec-fetch-site");return n&&n!=="same-origin"&&n!=="none"?e.text("cross-site request blocked",403):t()}),k||o.use("*",async(e,t)=>{if(await t(),e.req.method!=="GET"||e.req.path==="/login"||!(e.res.headers.get("content-type")??"").includes("text/html"))return;const n=await e.res.text();e.res=new Response(mt(n,{prefix:"",agentId:null}),e.res)});const $=g.dirname(je(import.meta.url)),ie=[g.join($,"..","assets"),g.join($,"assets"),g.join(process.cwd(),"dist","assets")];o.get("/assets/:file",async e=>{const t=e.req.param("file");if(!/^[a-zA-Z0-9._-]+$/.test(t))return e.notFound();for(const r of ie){const n=g.join(r,t);if(!P(n))continue;const i=await ge(n),a=g.extname(t),u={".css":"text/css; charset=utf-8",".js":"application/javascript; charset=utf-8",".map":"application/json; charset=utf-8"};return e.body(i,200,{"Content-Type":u[a]??"application/octet-stream","Cache-Control":a===".js"||a===".css"?"no-cache":"public, max-age=3600"})}return e.notFound()});const ae=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
2
2
  <rect x="2.5" y="5.5" width="27" height="21" rx="4" fill="#0d1117" stroke="#7dd3fc" stroke-width="2"/>
3
3
  <path d="M8 13l4.2 3.1L8 19.2" fill="none" stroke="#7dd3fc" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
4
4
  <line x1="15.5" y1="19.6" x2="22.5" y2="19.6" stroke="#7dd3fc" stroke-width="2.2" stroke-linecap="round"/>
5
- </svg>`,G=e=>e.body(ae,200,{"Content-Type":"image/svg+xml; charset=utf-8","Cache-Control":"public, max-age=86400"});s.get("/favicon.svg",G),s.get("/favicon.ico",G);const de={name:"tmux-weblink",short_name:"tmux-web",description:"Access your tmux sessions from the browser",start_url:"/",display:"standalone",background_color:"#0d1117",theme_color:"#0d1117",icons:[{src:"/assets/icon-192.png",sizes:"192x192",type:"image/png"},{src:"/assets/icon-512.png",sizes:"512x512",type:"image/png"}]};s.get("/manifest.json",e=>e.json(de,200,{"Cache-Control":"public, max-age=3600"}));const ue=`// tmux-weblink Service Worker
5
+ </svg>`,G=e=>e.body(ae,200,{"Content-Type":"image/svg+xml; charset=utf-8","Cache-Control":"public, max-age=86400"});o.get("/favicon.svg",G),o.get("/favicon.ico",G);const de={name:"tmux-weblink",short_name:"tmux-web",description:"Access your tmux sessions from the browser",start_url:"/",display:"standalone",background_color:"#0d1117",theme_color:"#0d1117",icons:[{src:"/assets/icon-192.png",sizes:"192x192",type:"image/png"},{src:"/assets/icon-512.png",sizes:"512x512",type:"image/png"}]};o.get("/manifest.json",e=>e.json(de,200,{"Cache-Control":"public, max-age=3600"}));const ue=`// tmux-weblink Service Worker
6
6
  const CACHE = "tmux-weblink-v2";
7
7
  const ASSETS = ["/", "/favicon.svg"];
8
8
  self.addEventListener("install", (e) => {
@@ -18,7 +18,7 @@ self.addEventListener("activate", (e) => {
18
18
  self.addEventListener("fetch", (e) => {
19
19
  e.respondWith(fetch(e.request).catch(() => caches.match(e.request)));
20
20
  });
21
- `;s.get("/sw.js",e=>e.body(ue,200,{"Content-Type":"application/javascript; charset=utf-8"})),s.get("/login",e=>{const r=e.req.query("setup")==="1"?!0:!y.passwordHash,n=e.req.query("error");return e.html(ve({setupMode:r,error:n?decodeURIComponent(n):void 0,theme:l.activeTheme}))}),s.get("/",j(),e=>{const t=Q();return e.html(Ie({theme:l.activeTheme,version:pt,fsRoots:t,terminalCfg:E,scrollback:E.initialLines+2*E.historyChunk,wsBase:q&&U?.()?`/ws/a/${U()}`:void 0}))}),s.get("/notes",j(),e=>e.html(qe(S.data.notes,l.activeTheme))),s.get("/notes/:session",j(),e=>{const t=decodeURIComponent(e.req.param("session"));return e.html(Se(t,l.activeTheme))}),s.get("/history",j(),e=>{const t=F(),r=new Set(t.map(n=>n.name));return e.html(Ae(Me(),l.activeTheme,r))}),s.get("/quick-commands",j(),e=>e.html(xe(te(),l.activeTheme))),s.get("/files",j(),e=>{const t=Q();return e.html(Ce(l.activeTheme,t))}),s.post("/api/history/clear",i(),async e=>(await Ue(),e.json({ok:!0}))),s.get("/api/quick-commands",i(),e=>e.json(te())),s.post("/api/quick-commands",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=await et(t);return"error"in r?e.json({error:r.error},400):e.json(r,201)}),s.patch("/api/quick-commands/:id",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=await rt(e.req.param("id"),t);return"error"in r?e.json({error:r.error},r.status):e.json(r)}),s.delete("/api/quick-commands/:id",i(),e=>tt(e.req.param("id"))?e.json({ok:!0}):e.json({error:"not found"},404)),s.post("/api/auth/password",async e=>{if(q)return e.json({error:"hub only"},403);const t=I(e),r=_.check(t);if(!r.allowed)return k("rate_limited",{ip:t,retryAfterMs:r.retryAfterMs,permanentLock:r.permanentLock}),r.permanentLock?e.json({error:"Server locked after too many failed attempts",permanentLock:!0},403):e.json({error:"Too many attempts",retryAfterMs:r.retryAfterMs},429);let n;try{n=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const o=typeof n.password=="string"?n.password:"";if(!y.passwordHash){if(!y.security.allowRemoteSetup&&!mt(t))return k("setup_rejected_remote",{ip:t}),e.json({error:"First-run setup must be performed from localhost"},403);if(l.settingUpPassword)return e.json({error:"Password setup in progress"},409);const c=Pe(o);if(c)return e.json({error:c},400);l.settingUpPassword=!0;try{y.passwordHash=await Ne(o),We(y),k("password_set",{ip:t})}finally{l.settingUpPassword=!1}const{plaintext:d}=w.createAccessToken("setup",y.security.tokenTtlDays);return W(e,d),e.json({ok:!0,token:d,setupMode:!0})}if(!await Re(o,y.passwordHash)){const c=_.recordFailure(t);return k("auth_failed",{ip:t,method:"password",failures:c.failures,permanentLock:c.permanentLock}),c.permanentLock?(w.revokeAll(),k("permanent_lock",{ip:t,failures:c.failures}),e.json({error:"Server locked after too many failed attempts",permanentLock:!0},403)):c.allowed?e.json({error:"Incorrect password"},401):e.json({error:"Too many attempts",retryAfterMs:c.retryAfterMs},429)}_.recordSuccess(t);const u=`browser-${t}`,{plaintext:h}=w.createAccessToken(u,y.security.tokenTtlDays);return W(e,h),k("auth_success",{ip:t,method:"password",tokenName:u}),e.json({ok:!0,token:h})}),s.post("/api/auth/token",i(),async e=>{if(q)return e.json({error:"hub only"},403);const t=I(e);let r;try{r=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const n=typeof r.name=="string"?r.name:`api-${t}`,o=typeof r.ttlDays=="number"?r.ttlDays:y.security.tokenTtlDays,{stored:a,plaintext:u}=w.createAccessToken(n,o);return k("token_created",{ip:t,name:a.name,tokenId:a.id}),e.json({id:a.id,name:a.name,token:u,expiresAt:a.expiresAt})}),s.get("/api/auth/tokens",i(),e=>q?e.json({error:"hub only"},403):e.json(w.list().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt,lastUsedAt:t.lastUsedAt,expiresAt:t.expiresAt})))),s.delete("/api/auth/tokens/:id",i(),e=>q?e.json({error:"hub only"},403):w.revoke(e.req.param("id"))?(k("token_revoked",{ip:I(e),tokenId:e.req.param("id")}),e.json({ok:!0})):e.json({error:"not found"},404)),s.post("/api/auth/logout",i(),e=>(oe(e),e.json({ok:!0}))),s.get("/settings",j(),async e=>{const t=await Z();return e.html(be({settings:t,theme:l.activeTheme,saved:e.req.query("saved")==="1",error:e.req.query("error")?decodeURIComponent(e.req.query("error")):void 0}))}),s.post("/settings",i(),async e=>{let t;try{t=await e.req.parseBody()}catch{return e.redirect("/settings?error="+encodeURIComponent("invalid form body"),303)}const r=await Z(),n=t.defaultView==="recent"?"recent":"default";return await Ge({...r,defaultView:n}),e.redirect("/settings?saved=1",303)}),s.get("/settings/theme",j(),e=>e.html(Te({theme:l.activeTheme,saved:e.req.query("saved")==="1"}))),s.post("/settings/theme",i(),async e=>{let t;try{t=await e.req.parseBody()}catch{return e.redirect("/settings/theme?error=1",303)}const r=t.template;return typeof r!="string"||!J(r)?e.redirect("/settings/theme",303):(l.activeTheme=await Y(r),e.redirect("/settings/theme?saved=1",303))});const ce={vscode:"VS Code",ghostty:"Ghostty","warm-clay":"Warm Clay","dark-cove":"Dark Cove"};s.get("/api/theme",i(),e=>e.json({active:l.activeTheme.template,templates:ze.map(t=>({id:t,name:ce[t]}))})),s.post("/api/theme",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=t.template;return typeof r!="string"||!J(r)?e.json({error:"invalid theme template"},400):(l.activeTheme=await Y(r),e.json({ok:!0,active:l.activeTheme.template}))}),s.get("/api/system/status",i(),e=>e.json(nt())),s.get("/api/system/processes",i(),e=>e.json(st())),v&&(s.get("/settings/federation",j(),e=>e.redirect("/settings/machines",301)),s.get("/settings/machines",j(),async e=>e.html(_e({config:v.getConfig(),status:v.status(),tokens:V().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt})),hostname:v.hostname},l.activeTheme))),s.get("/api/machines",i(),e=>e.json({config:v.getConfig(),status:v.status()})),s.post("/api/machines",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.hub=="string"?t.hub.trim():"",n=typeof t.token=="string"?t.token.trim():"",o=typeof t.name=="string"?t.name.trim().slice(0,64):"",a=t.enabled===!0;if(a){if(!r)return e.json({error:"hub URL is required"},400);if(!/^wss?:\/\//i.test(r))return e.json({error:"hub URL must start with ws:// or wss://"},400);if(!n)return e.json({error:"registration token is required"},400)}const u={hub:r||void 0,token:n||void 0,name:o||void 0,enabled:a};return await v.setConfig(u),e.json({ok:!0,status:v.status()})}),s.get("/api/agent-tokens",i(),e=>e.json(V().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt})))),s.post("/api/agent-tokens",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.name=="string"?t.name.trim().slice(0,64):"";if(!r)return e.json({error:"name is required"},400);const{id:n,token:o}=Ee(r);return e.json({ok:!0,id:n,name:r,token:o})}),s.delete("/api/agent-tokens/:id",i(),e=>{const t=e.req.param("id");return Oe(t)?e.json({ok:!0}):e.json({error:"no such token"},404)})),s.post("/api/system/kill",i(),async e=>{const{pid:t}=await e.req.json();if(typeof t!="number"||!Number.isInteger(t)||t<=0)return e.json({error:"invalid pid"},400);const r=ot(t);return r.ok?e.json({ok:!0}):e.json({error:r.error},500)}),s.get("/api/agents",i(),e=>p?e.json(p.agents.list()):e.json([])),s.post("/api/sessions/new",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name is required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(r))return e.json({error:"name contains invalid characters"},400);const n=typeof t.dir=="string"&&t.dir.trim()?t.dir.trim():void 0;if(F().some(a=>a.name===r))return e.json({error:"session already exists"},409);try{return re(r,n),ee(r,{path:n}),e.json({ok:!0})}catch(a){const u=a instanceof ne?a.message:"failed to create session";return e.json({error:u},500)}}),s.post("/api/sessions/rename",i(),async e=>{try{const t=await e.req.json(),{oldName:r,newName:n}=t,o=typeof t.agentId=="string"?t.agentId:void 0;if(!r||!n)return e.json({error:"oldName and newName required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(n))return e.json({error:"invalid characters in name"},400);if(o){if(!p)return e.json({error:"not a hub"},400);const a=p.getChannel(o);return!a||!a.renameSession(r,n)?e.json({error:"agent offline"},409):(H(r,n,o),e.json({ok:!0,async:!0}))}return it(r,n),H(r,n),e.json({ok:!0})}catch{return e.json({error:"rename failed"},500)}}),s.post("/api/sessions/kill",i(),async e=>{try{const t=await e.req.json(),{name:r}=t,n=typeof t.agentId=="string"?t.agentId:void 0;if(!r)return e.json({error:"name required"},400);if(n){if(!p)return e.json({error:"not a hub"},400);const o=p.getChannel(n);return!o||!o.killSession(r)?e.json({error:"agent offline"},409):(D(r,n),e.json({ok:!0,async:!0}))}return at(r),D(r),e.json({ok:!0})}catch{return e.json({error:"kill failed"},500)}}),s.post("/api/sessions/rebuild",i(),async e=>{try{const t=await e.req.json(),r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name required"},400);const n=typeof t.agentId=="string"?t.agentId:void 0,a=Je().find(u=>u.name===r&&(u.agentId??null)===(n??null))?.path;if(n){if(!p)return e.json({error:"not a hub"},400);const u=p.getChannel(n);return u?u.rebuildSession(r,a)?e.json({ok:!0,async:!0}):e.json({error:"agent offline"},409):e.json({error:"agent offline"},409)}if(dt(r))return e.json({error:"session already exists"},409);try{re(r,a)}catch(u){const h=u instanceof ne?u.message:"rebuild failed";return e.json({error:h},500)}return ee(r,{path:a}),e.json({ok:!0})}catch{return e.json({error:"rebuild failed"},500)}}),s.post("/api/sessions/dismiss",i(),async e=>{try{const t=await e.req.json(),r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name required"},400);const n=typeof t.agentId=="string"?t.agentId:void 0;return D(r,n),e.json({ok:!0})}catch{return e.json({error:"dismiss failed"},500)}}),s.post("/api/sessions/rename-tombstone",i(),async e=>{try{const t=await e.req.json(),r=typeof t.oldName=="string"?t.oldName.trim():"",n=typeof t.newName=="string"?t.newName.trim():"";if(!r||!n)return e.json({error:"oldName and newName required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(n))return e.json({error:"invalid characters in name"},400);const o=typeof t.agentId=="string"?t.agentId:void 0;return H(r,n,o),e.json({ok:!0})}catch{return e.json({error:"rename failed"},500)}}),s.get("/api/session-program",i(),e=>{const t=e.req.query("session");if(!t)return e.json({program:null});try{const n=L("tmux",["display-message","-p","-t",t,"#{pane_current_command}"],{encoding:"utf-8",timeout:3e3,env:ye()}).trim()||null;return e.json({program:n})}catch{return e.json({program:null})}}),s.post("/api/session/:name/upload",i(),async e=>{try{const r=(await e.req.parseBody()).file;if(!(r instanceof File))return e.json({error:'expected a file field named "file"'},400);const n=Buffer.from(await r.arrayBuffer()),{path:o}=await Be(n,r.type,r.name);return e.json({path:o})}catch(t){return t instanceof $e?e.json({error:t.message},t.status):e.json({error:"upload failed"},500)}}),s.get("/api/fs/session-path",i(),e=>{const t=e.req.query("session");if(!t)return e.json({path:process.env.HOME??"/"});try{const r=De(t),o=r.find(a=>a.active)?.path??r[0]?.path??process.env.HOME??"/";return e.json({path:o})}catch{return e.json({path:process.env.HOME??"/"})}}),s.get("/api/fs/list",i(),e=>{const t=process.env.HOME??"/";let r=e.req.query("path")??t;r.startsWith("~")&&(r=t+r.slice(1)),r.startsWith("/")||(r=g.join(t,r));const n=e.req.query("recursive")==="true";let o=r,a="",u=r.endsWith("/");if(!u)try{u=T(r).isDirectory()}catch{}u||(o=g.dirname(r),a=g.basename(r).toLowerCase());try{const h=me(o),c=[],d=[];for(const m of h)if(!(a&&!m.toLowerCase().startsWith(a))){try{const f=g.join(o,m);T(f).isDirectory()?(c.push(f),n&&Fe(f,c,d,0)):d.push(f)}catch{}if(c.length+d.length>=5e3)break}return c.sort(X),d.sort(X),e.json({dirs:c,files:d})}catch{return e.json({dirs:[],files:[]})}});function le(e){const t={repoRoot:null,branch:null,files:[],linesAdded:0,linesRemoved:0};try{const r=C("git rev-parse --show-toplevel 2>/dev/null",{cwd:e,encoding:"utf-8",timeout:3e3}).trim();if(!r)return t;let n;try{n=C("git branch --show-current 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3}).trim()}catch{n=C("git rev-parse --short HEAD 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3}).trim()}n||(n="HEAD");let o="";try{o=C("git status --porcelain 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3})}catch{}const a=[];for(const d of o.split(`
21
+ `;o.get("/sw.js",e=>e.body(ue,200,{"Content-Type":"application/javascript; charset=utf-8"})),o.get("/login",e=>{const r=e.req.query("setup")==="1"?!0:!y.passwordHash,n=e.req.query("error");return e.html(Se({setupMode:r,error:n?decodeURIComponent(n):void 0,theme:l.activeTheme}))}),o.get("/",j(),e=>{const t=Q();return e.html(Ee({theme:l.activeTheme,version:gt,fsRoots:t,terminalCfg:E,scrollback:E.initialLines+2*E.historyChunk,wsBase:k&&U?.()?`/ws/a/${U()}`:void 0}))}),o.get("/notes",j(),e=>e.html(be(S.data.notes,l.activeTheme))),o.get("/notes/:session",j(),e=>{const t=decodeURIComponent(e.req.param("session"));return e.html(Te(t,l.activeTheme))}),o.get("/history",j(),e=>{const t=F(),r=new Set(t.map(n=>n.name));return e.html(Ce(We(),l.activeTheme,r))}),o.get("/quick-commands",j(),e=>e.html(Ie(te(),l.activeTheme))),o.get("/files",j(),e=>{const t=Q();return e.html(_e(l.activeTheme,t))}),o.post("/api/history/clear",s(),async e=>(await Be(),e.json({ok:!0}))),o.get("/api/quick-commands",s(),e=>e.json(te())),o.post("/api/quick-commands",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=await rt(t);return"error"in r?e.json({error:r.error},400):e.json(r,201)}),o.patch("/api/quick-commands/:id",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=await ot(e.req.param("id"),t);return"error"in r?e.json({error:r.error},r.status):e.json(r)}),o.delete("/api/quick-commands/:id",s(),e=>nt(e.req.param("id"))?e.json({ok:!0}):e.json({error:"not found"},404)),o.post("/api/auth/password",async e=>{if(k)return e.json({error:"hub only"},403);const t=I(e),r=_.check(t);if(!r.allowed)return v("rate_limited",{ip:t,retryAfterMs:r.retryAfterMs,permanentLock:r.permanentLock}),r.permanentLock?e.json({error:"Server locked after too many failed attempts",permanentLock:!0},403):e.json({error:"Too many attempts",retryAfterMs:r.retryAfterMs},429);let n;try{n=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const i=typeof n.password=="string"?n.password:"";if(!y.passwordHash){if(!y.security.allowRemoteSetup&&!pt(t))return v("setup_rejected_remote",{ip:t}),e.json({error:"First-run setup must be performed from localhost"},403);if(l.settingUpPassword)return e.json({error:"Password setup in progress"},409);const c=Fe(i);if(c)return e.json({error:c},400);l.settingUpPassword=!0;try{y.passwordHash=await Pe(i),$e(y),v("password_set",{ip:t})}finally{l.settingUpPassword=!1}const{plaintext:d}=w.createAccessToken("setup",y.security.tokenTtlDays);return W(e,d),e.json({ok:!0,token:d,setupMode:!0})}if(!await Le(i,y.passwordHash)){const c=_.recordFailure(t);return v("auth_failed",{ip:t,method:"password",failures:c.failures,permanentLock:c.permanentLock}),c.permanentLock?(w.revokeAll(),v("permanent_lock",{ip:t,failures:c.failures}),e.json({error:"Server locked after too many failed attempts",permanentLock:!0},403)):c.allowed?e.json({error:"Incorrect password"},401):e.json({error:"Too many attempts",retryAfterMs:c.retryAfterMs},429)}_.recordSuccess(t);const u=`browser-${t}`,{plaintext:h}=w.createAccessToken(u,y.security.tokenTtlDays);return W(e,h),v("auth_success",{ip:t,method:"password",tokenName:u}),e.json({ok:!0,token:h})}),o.post("/api/auth/token",s(),async e=>{if(k)return e.json({error:"hub only"},403);const t=I(e);let r;try{r=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const n=typeof r.name=="string"?r.name:`api-${t}`,i=typeof r.ttlDays=="number"?r.ttlDays:y.security.tokenTtlDays,{stored:a,plaintext:u}=w.createAccessToken(n,i);return v("token_created",{ip:t,name:a.name,tokenId:a.id}),e.json({id:a.id,name:a.name,token:u,expiresAt:a.expiresAt})}),o.get("/api/auth/tokens",s(),e=>k?e.json({error:"hub only"},403):e.json(w.list().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt,lastUsedAt:t.lastUsedAt,expiresAt:t.expiresAt})))),o.delete("/api/auth/tokens/:id",s(),e=>k?e.json({error:"hub only"},403):w.revoke(e.req.param("id"))?(v("token_revoked",{ip:I(e),tokenId:e.req.param("id")}),e.json({ok:!0})):e.json({error:"not found"},404)),o.post("/api/auth/logout",s(),e=>(se(e),e.json({ok:!0}))),o.get("/settings",j(),async e=>{const t=await Z();return e.html(Ae({settings:t,theme:l.activeTheme,saved:e.req.query("saved")==="1",error:e.req.query("error")?decodeURIComponent(e.req.query("error")):void 0}))}),o.post("/settings",s(),async e=>{let t;try{t=await e.req.parseBody()}catch{return e.redirect("/settings?error="+encodeURIComponent("invalid form body"),303)}const r=await Z(),n=t.defaultView==="recent"?"recent":"default";return await Ve({...r,defaultView:n}),e.redirect("/settings?saved=1",303)}),o.get("/settings/theme",j(),e=>e.html(xe({theme:l.activeTheme,saved:e.req.query("saved")==="1"}))),o.post("/settings/theme",s(),async e=>{let t;try{t=await e.req.parseBody()}catch{return e.redirect("/settings/theme?error=1",303)}const r=t.template;return typeof r!="string"||!J(r)?e.redirect("/settings/theme",303):(l.activeTheme=await Y(r),e.redirect("/settings/theme?saved=1",303))});const ce={vscode:"VS Code",ghostty:"Ghostty","warm-clay":"Warm Clay","dark-cove":"Dark Cove"};o.get("/api/theme",s(),e=>e.json({active:l.activeTheme.template,templates:Qe.map(t=>({id:t,name:ce[t]}))})),o.post("/api/theme",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=t.template;return typeof r!="string"||!J(r)?e.json({error:"invalid theme template"},400):(l.activeTheme=await Y(r),e.json({ok:!0,active:l.activeTheme.template}))}),o.get("/api/system/status",s(),e=>e.json(st())),o.get("/api/system/processes",s(),e=>e.json(it())),q&&(o.get("/settings/federation",j(),e=>e.redirect("/settings/machines",301)),o.get("/settings/machines",j(),async e=>e.html(Oe({config:q.getConfig(),status:q.status(),tokens:V().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt})),hostname:q.hostname},l.activeTheme))),o.get("/api/machines",s(),e=>e.json({config:q.getConfig(),status:q.status()})),o.post("/api/machines",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.hub=="string"?t.hub.trim():"",n=typeof t.token=="string"?t.token.trim():"",i=typeof t.name=="string"?t.name.trim().slice(0,64):"",a=t.enabled===!0;if(a){if(!r)return e.json({error:"hub URL is required"},400);if(!/^wss?:\/\//i.test(r))return e.json({error:"hub URL must start with ws:// or wss://"},400);if(!n)return e.json({error:"registration token is required"},400)}const u={hub:r||void 0,token:n||void 0,name:i||void 0,enabled:a};return await q.setConfig(u),e.json({ok:!0,status:q.status()})}),o.get("/api/agent-tokens",s(),e=>e.json(V().map(t=>({id:t.id,name:t.name,createdAt:t.createdAt})))),o.post("/api/agent-tokens",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.name=="string"?t.name.trim().slice(0,64):"";if(!r)return e.json({error:"name is required"},400);const{id:n,token:i}=Ne(r);return e.json({ok:!0,id:n,name:r,token:i})}),o.delete("/api/agent-tokens/:id",s(),e=>{const t=e.req.param("id");return Re(t)?e.json({ok:!0}):e.json({error:"no such token"},404)})),o.post("/api/system/kill",s(),async e=>{const{pid:t}=await e.req.json();if(typeof t!="number"||!Number.isInteger(t)||t<=0)return e.json({error:"invalid pid"},400);const r=at(t);return r.ok?e.json({ok:!0}):e.json({error:r.error},500)}),o.get("/api/agents",s(),e=>p?e.json(p.agents.list()):e.json([])),o.post("/api/sessions/new",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name is required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(r))return e.json({error:"name contains invalid characters"},400);const n=typeof t.dir=="string"&&t.dir.trim()?t.dir.trim():void 0;if(F().some(a=>a.name===r))return e.json({error:"session already exists"},409);try{return re(r,n),ee(r,{path:n}),e.json({ok:!0})}catch(a){const u=a instanceof ne?a.message:"failed to create session";return e.json({error:u},500)}}),o.post("/api/sessions/rename",s(),async e=>{try{const t=await e.req.json(),{oldName:r,newName:n}=t,i=typeof t.agentId=="string"?t.agentId:void 0;if(!r||!n)return e.json({error:"oldName and newName required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(n))return e.json({error:"invalid characters in name"},400);if(i){if(!p)return e.json({error:"not a hub"},400);const a=p.getChannel(i);return!a||!a.renameSession(r,n)?e.json({error:"agent offline"},409):(H(r,n,i),e.json({ok:!0,async:!0}))}return dt(r,n),H(r,n),e.json({ok:!0})}catch{return e.json({error:"rename failed"},500)}}),o.post("/api/sessions/kill",s(),async e=>{try{const t=await e.req.json(),{name:r}=t,n=typeof t.agentId=="string"?t.agentId:void 0;if(!r)return e.json({error:"name required"},400);if(n){if(!p)return e.json({error:"not a hub"},400);const i=p.getChannel(n);return!i||!i.killSession(r)?e.json({error:"agent offline"},409):(D(r,n),e.json({ok:!0,async:!0}))}return ut(r),D(r),e.json({ok:!0})}catch{return e.json({error:"kill failed"},500)}}),o.post("/api/sessions/rebuild",s(),async e=>{try{const t=await e.req.json(),r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name required"},400);const n=typeof t.agentId=="string"?t.agentId:void 0,a=tt().find(u=>u.name===r&&(u.agentId??null)===(n??null))?.path;if(n){if(!p)return e.json({error:"not a hub"},400);const u=p.getChannel(n);return u?u.rebuildSession(r,a)?e.json({ok:!0,async:!0}):e.json({error:"agent offline"},409):e.json({error:"agent offline"},409)}if(ct(r))return e.json({error:"session already exists"},409);try{re(r,a)}catch(u){const h=u instanceof ne?u.message:"rebuild failed";return e.json({error:h},500)}return ee(r,{path:a}),e.json({ok:!0})}catch{return e.json({error:"rebuild failed"},500)}}),o.post("/api/sessions/dismiss",s(),async e=>{try{const t=await e.req.json(),r=typeof t.name=="string"?t.name.trim():"";if(!r)return e.json({error:"name required"},400);const n=typeof t.agentId=="string"?t.agentId:void 0;return D(r,n),e.json({ok:!0})}catch{return e.json({error:"dismiss failed"},500)}}),o.post("/api/sessions/rename-tombstone",s(),async e=>{try{const t=await e.req.json(),r=typeof t.oldName=="string"?t.oldName.trim():"",n=typeof t.newName=="string"?t.newName.trim():"";if(!r||!n)return e.json({error:"oldName and newName required"},400);if(!/^[a-zA-Z0-9_\-. ]+$/.test(n))return e.json({error:"invalid characters in name"},400);const i=typeof t.agentId=="string"?t.agentId:void 0;return H(r,n,i),e.json({ok:!0})}catch{return e.json({error:"rename failed"},500)}}),o.get("/api/session-program",s(),e=>{const t=e.req.query("session");if(!t)return e.json({program:null});try{const n=L("tmux",["display-message","-p","-t",t,"#{pane_current_command}"],{encoding:"utf-8",timeout:3e3,env:ye()}).trim()||null;return e.json({program:n})}catch{return e.json({program:null})}}),o.post("/api/session/:name/upload",s(),async e=>{try{const r=(await e.req.parseBody()).file;if(!(r instanceof File))return e.json({error:'expected a file field named "file"'},400);const n=Buffer.from(await r.arrayBuffer()),{path:i}=await ze(n,r.type,r.name);return e.json({path:i})}catch(t){return t instanceof Ge?e.json({error:t.message},t.status):e.json({error:"upload failed"},500)}}),o.get("/api/fs/session-path",s(),e=>{const t=e.req.query("session");if(!t)return e.json({path:process.env.HOME??"/"});try{const r=Me(t),i=r.find(a=>a.active)?.path??r[0]?.path??process.env.HOME??"/";return e.json({path:i})}catch{return e.json({path:process.env.HOME??"/"})}}),o.get("/api/fs/list",s(),e=>{const t=process.env.HOME??"/";let r=e.req.query("path")??t;r.startsWith("~")&&(r=t+r.slice(1)),r.startsWith("/")||(r=g.join(t,r));const n=e.req.query("recursive")==="true";let i=r,a="",u=r.endsWith("/");if(!u)try{u=T(r).isDirectory()}catch{}u||(i=g.dirname(r),a=g.basename(r).toLowerCase());try{const h=me(i),c=[],d=[];for(const m of h)if(!(a&&!m.toLowerCase().startsWith(a))){try{const f=g.join(i,m);T(f).isDirectory()?(c.push(f),n&&He(f,c,d,0)):d.push(f)}catch{}if(c.length+d.length>=5e3)break}return c.sort(X),d.sort(X),e.json({dirs:c,files:d})}catch{return e.json({dirs:[],files:[]})}});function le(e){const t={repoRoot:null,branch:null,files:[],linesAdded:0,linesRemoved:0};try{const r=C("git rev-parse --show-toplevel 2>/dev/null",{cwd:e,encoding:"utf-8",timeout:3e3}).trim();if(!r)return t;let n;try{n=C("git branch --show-current 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3}).trim()}catch{n=C("git rev-parse --short HEAD 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3}).trim()}n||(n="HEAD");let i="";try{i=C("git status --porcelain 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3})}catch{}const a=[];for(const d of i.split(`
22
22
  `)){if(!d.trim())continue;const m=d[0],f=d[1],b=d.substring(3).trim(),R=f!==" "?f:m;a.push({path:b,status:R,staged:m,unstaged:f,additions:0,deletions:0})}const u=new Map;try{const d=C("git diff --numstat HEAD 2>/dev/null",{cwd:r,encoding:"utf-8",timeout:3e3});for(const m of d.split(`
23
23
  `)){if(!m.trim())continue;const f=m.split(" ");if(f.length>=3){const b=parseInt(f[0],10)||0,R=parseInt(f[1],10)||0;u.set(f[2],{added:b,deleted:R})}}}catch{}for(const d of a){const m=u.get(d.path);m&&(d.additions=m.added,d.deletions=m.deleted)}let h=0,c=0;for(const d of a)h+=d.additions,c+=d.deletions;for(const d of a)if(d.status==="?"&&d.additions===0)try{const m=g.join(r,d.path),b=z(m,"utf-8").split(`
24
- `).length;d.additions=b,h+=b}catch{}return{repoRoot:r,branch:n,files:a,linesAdded:h,linesRemoved:c}}catch{return t}}return s.get("/api/git/status",i(),e=>{const t=e.req.query("path");if(!t)return e.json({error:"path is required"},400);try{const r=A(t),n=le(r);return e.json(n)}catch(r){return r.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):r.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({repoRoot:null,branch:null,files:[],linesAdded:0,linesRemoved:0})}}),s.get("/api/git/diff",i(),e=>{const t=e.req.query("path"),r=e.req.query("file");if(!t||!r)return e.json({error:"path and file are required"},400);try{const n=A(t);if(!P(n)||!T(n).isDirectory())return e.json({error:"invalid repository path: "+n},400);try{const o=L("/usr/bin/git",["diff","HEAD","--",r],{cwd:n,encoding:"utf-8",timeout:5e3}),a=L("/usr/bin/git",["diff","--cached","--",r],{cwd:n,encoding:"utf-8",timeout:5e3});return e.json({diff:o,stagedDiff:a})}catch(o){throw console.error("[git/diff] execFileSync failed:",o?.code,o.message),o}}catch(n){return n.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):n.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):(console.error("[git/diff] exception:",n),e.json({error:String(n)},500))}}),s.get("/api/file",i(),e=>{try{const t=e.req.query("path");if(!t)return e.json({error:"path is required"},400);const r=A(t);if(!T(r).isFile())return e.json({error:"not a file"},400);const n=T(r).size;if(n>K)return e.json({error:"file too large",size:n,maxBytes:K},413);const o=z(r,"utf-8");return e.json({path:r,content:o,size:n})}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):t.code==="ENOENT"?e.json({error:"not found"},404):e.json({error:"internal error"},500)}}),s.put("/api/file",i(),async e=>{try{const t=await e.req.json();if(!t.path||typeof t.content!="string")return e.json({error:"path and content are required"},400);const r=A(t.path);return Le(r,t.content),e.json({ok:!0})}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"write failed"},500)}}),s.post("/api/file/delete",i(),async e=>{try{const t=await e.req.json();if(!t.path)return e.json({error:"path is required"},400);const r=A(t.path);return T(r).isFile()?(fe(r),e.json({ok:!0})):e.json({error:"not a file"},400)}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"delete failed"},500)}}),s.post("/api/file/touch",i(),async e=>{try{const t=await e.req.json();if(!t.path)return e.json({error:"path is required"},400);const r=A(t.path);return P(r)?e.json({error:"file already exists"},409):(he(g.dirname(r),{recursive:!0}),pe(r,"","utf-8"),e.json({ok:!0,path:r}))}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"touch failed"},500)}}),s.get("/api/sidebar/sessions",i(),e=>{const t=e.req.query("currentSession");return e.json(N(typeof t=="string"&&t?t:void 0))}),s.get("/api/sidebar/session-windows/:session",i(),e=>{const t=decodeURIComponent(e.req.param("session"));return e.json(Xe(t))}),s.post("/api/pinned-views",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=$(t);return"error"in r?e.json({error:r.error},400):(await Ve(r.sessionName,r.windowIndex),e.json(N()))}),s.delete("/api/pinned-views",i(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=$(t);return"error"in r?e.json({error:r.error},400):(await Qe(r.sessionName,r.windowIndex),e.json(N()))}),s.get("/api/notes",i(),e=>{const t=[...S.data.notes].sort((r,n)=>(n.updatedAt??0)-(r.updatedAt??0));return e.json(t)}),s.get("/api/notes/:scope",i(),e=>{const t=decodeURIComponent(e.req.param("scope")),r=S.data.notes.find(n=>n.scope===t);return r?e.json(r):e.json(null,404)}),s.put("/api/notes/:scope",i(),async e=>{const t=decodeURIComponent(e.req.param("scope"));let r;try{r=await e.req.json()}catch{return e.json({error:"invalid json"},400)}if(typeof r.content!="string")return e.json({error:"content must be string"},400);const n={scope:t,content:r.content,updatedAt:Date.now()},o=S.data.notes.findIndex(a=>a.scope===t);return o>=0?S.data.notes[o]=n:S.data.notes.push(n),await S.write(),e.json({ok:!0})}),p&&(s.use("/a/:agentId/*",i()),ut(s,{getChannel:p.getChannel})),s}export{Zt as buildApp};
24
+ `).length;d.additions=b,h+=b}catch{}return{repoRoot:r,branch:n,files:a,linesAdded:h,linesRemoved:c}}catch{return t}}if(o.get("/api/git/status",s(),e=>{const t=e.req.query("path");if(!t)return e.json({error:"path is required"},400);try{const r=A(t),n=le(r);return e.json(n)}catch(r){return r.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):r.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({repoRoot:null,branch:null,files:[],linesAdded:0,linesRemoved:0})}}),o.get("/api/git/diff",s(),e=>{const t=e.req.query("path"),r=e.req.query("file");if(!t||!r)return e.json({error:"path and file are required"},400);try{const n=A(t);if(!P(n)||!T(n).isDirectory())return e.json({error:"invalid repository path: "+n},400);try{const i=L("/usr/bin/git",["diff","HEAD","--",r],{cwd:n,encoding:"utf-8",timeout:5e3}),a=L("/usr/bin/git",["diff","--cached","--",r],{cwd:n,encoding:"utf-8",timeout:5e3});return e.json({diff:i,stagedDiff:a})}catch(i){throw console.error("[git/diff] execFileSync failed:",i?.code,i.message),i}}catch(n){return n.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):n.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):(console.error("[git/diff] exception:",n),e.json({error:String(n)},500))}}),o.get("/api/file",s(),e=>{try{const t=e.req.query("path");if(!t)return e.json({error:"path is required"},400);const r=A(t);if(!T(r).isFile())return e.json({error:"not a file"},400);const n=T(r).size;if(n>K)return e.json({error:"file too large",size:n,maxBytes:K},413);const i=z(r,"utf-8");return e.json({path:r,content:i,size:n})}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):t.code==="ENOENT"?e.json({error:"not found"},404):e.json({error:"internal error"},500)}}),o.put("/api/file",s(),async e=>{try{const t=await e.req.json();if(!t.path||typeof t.content!="string")return e.json({error:"path and content are required"},400);const r=A(t.path);return De(r,t.content),e.json({ok:!0})}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"write failed"},500)}}),o.post("/api/file/delete",s(),async e=>{try{const t=await e.req.json();if(!t.path)return e.json({error:"path is required"},400);const r=A(t.path);return T(r).isFile()?(fe(r),e.json({ok:!0})):e.json({error:"not a file"},400)}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"delete failed"},500)}}),o.post("/api/file/touch",s(),async e=>{try{const t=await e.req.json();if(!t.path)return e.json({error:"path is required"},400);const r=A(t.path);return P(r)?e.json({error:"file already exists"},409):(he(g.dirname(r),{recursive:!0}),pe(r,"","utf-8"),e.json({ok:!0,path:r}))}catch(t){return t.message==="FS_ROOTS_NOT_CONFIGURED"?e.json({error:"file access not configured"},403):t.message==="PATH_NOT_ALLOWED"?e.json({error:"path not allowed"},403):e.json({error:"touch failed"},500)}}),o.get("/api/sidebar/sessions",s(),e=>{const t=e.req.query("currentSession");return e.json(N(typeof t=="string"&&t?t:void 0))}),o.get("/api/sidebar/session-windows/:session",s(),e=>{const t=decodeURIComponent(e.req.param("session"));return e.json(Ye(t))}),o.post("/api/pinned-views",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=B(t);return"error"in r?e.json({error:r.error},400):(await Ke(r.sessionName,r.windowIndex),e.json(N()))}),o.delete("/api/pinned-views",s(),async e=>{let t;try{t=await e.req.json()}catch{return e.json({error:"invalid json"},400)}const r=B(t);return"error"in r?e.json({error:r.error},400):(await Xe(r.sessionName,r.windowIndex),e.json(N()))}),o.get("/api/notes",s(),e=>{const t=[...S.data.notes].sort((r,n)=>(n.updatedAt??0)-(r.updatedAt??0));return e.json(t)}),o.get("/api/notes/:scope",s(),e=>{const t=decodeURIComponent(e.req.param("scope")),r=S.data.notes.find(n=>n.scope===t);return r?e.json(r):e.json(null,404)}),o.put("/api/notes/:scope",s(),async e=>{const t=decodeURIComponent(e.req.param("scope"));let r;try{r=await e.req.json()}catch{return e.json({error:"invalid json"},400)}if(typeof r.content!="string")return e.json({error:"content must be string"},400);const n={scope:t,content:r.content,updatedAt:Date.now()},i=S.data.notes.findIndex(a=>a.scope===t);return i>=0?S.data.notes[i]=n:S.data.notes.push(n),await S.write(),e.json({ok:!0})}),p&&(o.use("/a/:agentId/*",s()),lt(o,{getChannel:p.getChannel})),!k)try{qe(o,{manager:ve(),userAuth:s})}catch(e){console.error("[bots] failed to register routes:",e)}return o}export{tr as buildApp};
@@ -1,4 +1,4 @@
1
- import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSessionModalHTML as g,newSessionModalScript as b,reducedMotion as x}from"../shared-layout.js";import{icon as n}from"../icons.js";function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function o(e="var(--panel-accent)"){return`box-shadow: 0 0 0 2px ${e}; outline: none;`}function k(e){const{theme:t,fsRoots:a,terminalCfg:r,scrollback:s,wsBase:l}=e,i=e.version?m(e.version):"",p=`
1
+ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSessionModalHTML as b,newSessionModalScript as x,reducedMotion as g}from"../shared-layout.js";import{icon as a}from"../icons.js";function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function o(e="var(--panel-accent)"){return`box-shadow: 0 0 0 2px ${e}; outline: none;`}function w(e){const{theme:t,fsRoots:r,terminalCfg:i,scrollback:l,wsBase:p}=e,n=e.version?m(e.version):"",s=`
2
2
  *, *::before, *::after { box-sizing: border-box; }
3
3
  html, body {
4
4
  background: var(--page-bg); color: var(--page-fg);
@@ -643,6 +643,84 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
643
643
  filter: brightness(0.85);
644
644
  }
645
645
 
646
+
647
+ /* \u2500\u2500 Bots channel \u2500\u2500 */
648
+ .bots-section { border-top: 1px solid var(--panel-border); margin-top: 8px; padding-top: 6px; }
649
+ .bots-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 10px 4px; }
650
+ .bots-title { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--panel-muted); display: inline-flex; align-items: center; gap: 6px; }
651
+ .bots-badge { background: #e0a23c; color: #1b1b1b; border-radius: 9px; padding: 0 6px; font-size: 10px; line-height: 15px; }
652
+ .bots-head-actions { display: inline-flex; gap: 4px; }
653
+ .bots-icon-btn { background: transparent; border: 1px solid var(--panel-border); color: var(--panel-muted); border-radius: 6px; width: 22px; height: 22px; line-height: 1; cursor: pointer; font-size: 13px; }
654
+ .bots-icon-btn:hover { color: var(--panel-accent); border-color: var(--panel-accent); }
655
+ .bots-list { display: flex; flex-direction: column; gap: 2px; padding: 0 6px 6px; }
656
+ .bots-empty { color: var(--panel-muted); font-size: 11px; padding: 6px 10px; opacity: 0.7; }
657
+ .bots-group-label { font-size: 10px; color: var(--panel-muted); opacity: 0.8; padding: 6px 8px 2px; font-family: var(--font-mono); }
658
+ .bots-row { display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 12px; }
659
+ .bots-row:hover { background: color-mix(in srgb, var(--panel-accent) 8%, transparent); }
660
+ .bots-row.active { background: color-mix(in srgb, var(--panel-accent) 14%, transparent); }
661
+ .bots-row-child { margin-left: 14px; opacity: 0.9; }
662
+ .bots-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--panel-muted); }
663
+ .bots-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
664
+ .bots-meta { font-size: 10px; color: var(--panel-muted); }
665
+
666
+ .bots-view { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--page-bg); z-index: 6; }
667
+ .bots-view[hidden] { display: none; }
668
+ .bots-view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; }
669
+ .bv-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
670
+ .bv-title-text { font-family: var(--font-mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
671
+ .bv-status { font-size: 11px; color: var(--panel-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
672
+ .bv-actions { display: flex; gap: 6px; flex-shrink: 0; }
673
+ .bv-actions .btn { padding: 4px 10px; font-size: 11px; }
674
+
675
+ .bots-messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
676
+ .bv-msg { max-width: min(860px, 100%); font-size: 13px; line-height: 1.55; }
677
+ .bv-user { align-self: flex-end; background: color-mix(in srgb, var(--panel-accent) 16%, transparent); border: 1px solid color-mix(in srgb, var(--panel-accent) 30%, transparent); padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; }
678
+ .bv-assistant { align-self: flex-start; }
679
+ .bv-text { white-space: pre-wrap; word-break: break-word; }
680
+ .bv-thinking { margin-bottom: 6px; color: var(--panel-muted); font-size: 12px; }
681
+ .bv-thinking summary { cursor: pointer; opacity: 0.8; }
682
+ .bv-thinking div { white-space: pre-wrap; border-left: 2px solid var(--panel-border); padding-left: 8px; margin-top: 4px; }
683
+
684
+ .bv-tool { border: 1px solid var(--panel-border); border-radius: 8px; background: color-mix(in srgb, var(--page-bg), var(--panel-bg) 45%); font-family: var(--font-mono); font-size: 11.5px; }
685
+ .bv-tool > summary { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
686
+ .bv-tool-name { color: var(--panel-accent); }
687
+ .bv-tool-phase { color: var(--panel-muted); font-size: 10px; }
688
+ .bv-tool-error { color: var(--panel-danger, #e5534b); font-size: 10px; }
689
+ .bv-tool-meta { margin-left: auto; color: var(--panel-muted); font-size: 10px; }
690
+ .bv-pre { margin: 0; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; border-top: 1px solid var(--panel-border); color: var(--panel-muted); }
691
+ .bv-output { color: var(--page-fg); }
692
+
693
+ .bv-approval { border: 1px solid #e0a23c; border-radius: 8px; padding: 10px 12px; background: color-mix(in srgb, #e0a23c 8%, transparent); display: flex; flex-direction: column; gap: 8px; }
694
+ .bv-approval-title { font-size: 12.5px; font-weight: 600; }
695
+ .bv-approval-actions { display: flex; gap: 6px; align-items: center; }
696
+ .bv-approval-decided { font-size: 11px; color: var(--panel-muted); }
697
+ .bv-reason { flex: 1; min-width: 120px; background: var(--page-bg); color: var(--page-fg); border: 1px solid var(--panel-border); border-radius: 6px; padding: 4px 8px; font-size: 11px; }
698
+
699
+ .bv-notice { font-size: 11.5px; color: var(--panel-muted); }
700
+ .bv-notice-warn { color: #e0a23c; }
701
+ .bv-notice-error { color: var(--panel-danger, #e5534b); }
702
+
703
+ .bots-composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--panel-border); flex-shrink: 0; align-items: flex-end; }
704
+ .bots-composer textarea { flex: 1; resize: none; min-height: 38px; max-height: 160px; background: color-mix(in srgb, var(--page-bg), var(--panel-bg) 50%); color: var(--page-fg); border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.45; outline: none; }
705
+ .bots-composer textarea:focus { border-color: var(--panel-accent); }
706
+
707
+ .bots-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 40; }
708
+ .bots-modal[hidden] { display: none; }
709
+ .bots-modal-card { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px; width: min(760px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
710
+ .bots-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--panel-border); font-size: 13px; }
711
+ .bots-modal-body { padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
712
+ .bv-field { display: flex; flex-direction: column; gap: 4px; }
713
+ .bv-label { font-size: 11px; color: var(--panel-muted); text-transform: uppercase; letter-spacing: 0.05em; }
714
+ .bv-input { background: var(--page-bg); color: var(--page-fg); border: 1px solid var(--panel-border); border-radius: 7px; padding: 7px 9px; font-size: 12px; font-family: var(--font-mono); }
715
+ .bv-textarea { background: var(--page-bg); color: var(--page-fg); border: 1px solid var(--panel-border); border-radius: 7px; padding: 8px 10px; font-size: 12px; font-family: var(--font-mono); resize: vertical; }
716
+ .bv-check-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; }
717
+ .bv-check { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; }
718
+ .bv-template-list { display: flex; flex-direction: column; gap: 6px; }
719
+ .bv-template-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 8px; }
720
+ .bv-template-name { font-family: var(--font-mono); font-size: 12.5px; }
721
+ .bv-template-desc { flex: 1; color: var(--panel-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
722
+ .bv-template-actions { display: flex; gap: 4px; }
723
+
646
724
  /* \u2500\u2500 File list view (when no root selected) \u2500\u2500 */
647
725
  .file-roots-list { list-style: none; padding: 0; margin: 16px; }
648
726
  .file-roots-list li {
@@ -655,7 +733,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
655
733
  .file-roots-list li:hover { border-color: var(--panel-accent); }
656
734
  .file-roots-list li svg { width: 20px; height: 20px; flex-shrink: 0; fill: var(--panel-accent); }
657
735
 
658
- ${x()}
736
+ ${g()}
659
737
  ${f()}
660
738
  @media (max-width: 640px) {
661
739
  .app-layout { flex-direction: column; }
@@ -688,12 +766,12 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
688
766
  display: flex; flex-wrap: nowrap; gap: 4px;
689
767
  overflow-x: auto; overscroll-behavior-x: contain;
690
768
  }
691
- `,h=JSON.stringify(t.terminal).replace(/</g,"\\u003c"),d=JSON.stringify({terminal:r,scrollback:s,theme:t.terminal,fsRoots:a,wsBase:l||""}).replace(/</g,"\\u003c");return`<!DOCTYPE html>
769
+ `,v=JSON.stringify(t.terminal).replace(/</g,"\\u003c"),d=JSON.stringify({terminal:i,scrollback:l,theme:t.terminal,fsRoots:r,wsBase:p||""}).replace(/</g,"\\u003c");return`<!DOCTYPE html>
692
770
  <html lang="en">
693
771
  <head>
694
772
  <meta charset="UTF-8" />
695
773
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
696
- <meta name="tw-build" content="${i}" />
774
+ <meta name="tw-build" content="${n}" />
697
775
  <meta name="apple-mobile-web-app-capable" content="yes" />
698
776
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
699
777
  <meta name="apple-mobile-web-app-title" content="tmux-web" />
@@ -703,7 +781,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
703
781
  <title>tmux-weblink</title>
704
782
  <style>
705
783
  ${c(t.shell)}
706
- ${p}
784
+ ${s}
707
785
  </style>
708
786
  </head>
709
787
  <body>
@@ -737,9 +815,9 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
737
815
  <aside class="sidebar">
738
816
  <div class="sidebar-content" id="sidebar-content"></div>
739
817
  <div class="sidebar-footer">
740
- <button class="mode-btn active" id="mode-sessions" title="Sessions">${n("sessions",'width="20" height="20"')}</button>
741
- <button class="mode-btn" id="mode-files" title="Files">${n("folder",'width="20" height="20"')}</button>
742
- <button class="mode-btn" id="mode-settings" title="Settings">${n("settings",'width="20" height="20"')}</button>
818
+ <button class="mode-btn active" id="mode-sessions" title="Sessions">${a("sessions",'width="20" height="20"')}</button>
819
+ <button class="mode-btn" id="mode-files" title="Files">${a("folder",'width="20" height="20"')}</button>
820
+ <button class="mode-btn" id="mode-settings" title="Settings">${a("settings",'width="20" height="20"')}</button>
743
821
  </div>
744
822
  </aside>
745
823
 
@@ -800,7 +878,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
800
878
  <!-- Settings popover -->
801
879
  <div class="popover-backdrop" id="settings-backdrop"></div>
802
880
  <div class="settings-popover" id="settings-popover">
803
- <div style="padding:1px 2px 6px;font-size:10px;color:var(--panel-muted);opacity:.8;font-family:var(--font-mono)">tmux-weblink v${i}</div>
881
+ <div style="padding:1px 2px 6px;font-size:10px;color:var(--panel-muted);opacity:.8;font-family:var(--font-mono)">tmux-weblink v${n}</div>
804
882
  <div style="padding:4px 0">
805
883
  <button class="theme-option" data-theme="vscode" title="VS Code"><span class="theme-dot" style="background:#007acc"></span>VS Code${t.template==="vscode"?'<span class="theme-check">\u2713</span>':""}</button>
806
884
  <button class="theme-option" data-theme="ghostty" title="Ghostty"><span class="theme-dot" style="background:#ff5f00"></span>Ghostty${t.template==="ghostty"?'<span class="theme-check">\u2713</span>':""}</button>
@@ -850,7 +928,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as f,newSes
850
928
  })();
851
929
  </script>
852
930
 
853
- ${g()}
931
+ ${b()}
854
932
 
855
933
  <script>
856
934
  window.__TMUX_WEB_SHELL__ = ${d};
@@ -862,7 +940,7 @@ window.__onSessionCreated = async function(name, agentId) {
862
940
  await window.__refreshSidebar();
863
941
  window.__openSession(name, agentId || undefined);
864
942
  };
865
- ${b("__onSessionCreated")}
943
+ ${x("__onSessionCreated")}
866
944
  </script>
867
945
  <script>
868
946
  // Sync app-layout height to visual viewport so mobile keyboard doesn't overlap
@@ -938,4 +1016,4 @@ if ('serviceWorker' in navigator) {
938
1016
  }
939
1017
  </script>
940
1018
  </body>
941
- </html>`}export{k as renderShell};
1019
+ </html>`}export{w as renderShell};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmux-weblink",
3
- "version": "2.2.40",
3
+ "version": "2.2.41",
4
4
  "description": "Access your tmux sessions from the browser. A continuation of tmux-web and persalink.",
5
5
  "type": "module",
6
6
  "bin": {