aicodeman 0.9.13 → 1.0.0

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.
Files changed (149) hide show
  1. package/README.md +6 -5
  2. package/README.zh-CN.md +1 -0
  3. package/dist/attachment-magic.d.ts +5 -0
  4. package/dist/attachment-magic.d.ts.map +1 -0
  5. package/dist/attachment-magic.js +34 -0
  6. package/dist/attachment-magic.js.map +1 -0
  7. package/dist/attachment-registry.d.ts +72 -0
  8. package/dist/attachment-registry.d.ts.map +1 -0
  9. package/dist/attachment-registry.js +166 -0
  10. package/dist/attachment-registry.js.map +1 -0
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +85 -0
  13. package/dist/cli.js.map +1 -1
  14. package/dist/config/attachment-guard.d.ts +71 -0
  15. package/dist/config/attachment-guard.d.ts.map +1 -0
  16. package/dist/config/attachment-guard.js +118 -0
  17. package/dist/config/attachment-guard.js.map +1 -0
  18. package/dist/config/hook-secret.d.ts +28 -0
  19. package/dist/config/hook-secret.d.ts.map +1 -0
  20. package/dist/config/hook-secret.js +63 -0
  21. package/dist/config/hook-secret.js.map +1 -0
  22. package/dist/hooks-config.d.ts +3 -2
  23. package/dist/hooks-config.d.ts.map +1 -1
  24. package/dist/hooks-config.js +10 -2
  25. package/dist/hooks-config.js.map +1 -1
  26. package/dist/image-watcher.d.ts +6 -1
  27. package/dist/image-watcher.d.ts.map +1 -1
  28. package/dist/image-watcher.js +56 -7
  29. package/dist/image-watcher.js.map +1 -1
  30. package/dist/session-cli-builder.d.ts.map +1 -1
  31. package/dist/session-cli-builder.js +5 -0
  32. package/dist/session-cli-builder.js.map +1 -1
  33. package/dist/session.d.ts +2 -0
  34. package/dist/session.d.ts.map +1 -1
  35. package/dist/session.js +63 -0
  36. package/dist/session.js.map +1 -1
  37. package/dist/tmux-manager.d.ts.map +1 -1
  38. package/dist/tmux-manager.js +9 -1
  39. package/dist/tmux-manager.js.map +1 -1
  40. package/dist/types/tools.d.ts +35 -1
  41. package/dist/types/tools.d.ts.map +1 -1
  42. package/dist/types/tools.js +2 -1
  43. package/dist/types/tools.js.map +1 -1
  44. package/dist/web/middleware/auth.d.ts +9 -1
  45. package/dist/web/middleware/auth.d.ts.map +1 -1
  46. package/dist/web/middleware/auth.js +58 -8
  47. package/dist/web/middleware/auth.js.map +1 -1
  48. package/dist/web/network-auth-policy.d.ts +6 -0
  49. package/dist/web/network-auth-policy.d.ts.map +1 -1
  50. package/dist/web/network-auth-policy.js +10 -0
  51. package/dist/web/network-auth-policy.js.map +1 -1
  52. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  53. package/dist/web/public/app.95e6e231.js +35 -0
  54. package/dist/web/public/app.95e6e231.js.br +0 -0
  55. package/dist/web/public/app.95e6e231.js.gz +0 -0
  56. package/dist/web/public/{constants.8fa1a65f.js → constants.aa510a4d.js} +1 -0
  57. package/dist/web/public/constants.aa510a4d.js.br +0 -0
  58. package/dist/web/public/constants.aa510a4d.js.gz +0 -0
  59. package/dist/web/public/fonts/jetbrains-mono-variable.woff2 +0 -0
  60. package/dist/web/public/fonts/manrope-variable.woff2 +0 -0
  61. package/dist/web/public/image-input.0ea86695.js.gz +0 -0
  62. package/dist/web/public/index.html +53 -31
  63. package/dist/web/public/index.html.br +0 -0
  64. package/dist/web/public/index.html.gz +0 -0
  65. package/dist/web/public/input-cjk.b8686b5e.js.gz +0 -0
  66. package/dist/web/public/keyboard-accessory.bc753cc7.js.gz +0 -0
  67. package/dist/web/public/mobile-handlers.763a7439.js.gz +0 -0
  68. package/dist/web/public/mobile.c7513aed.css +1 -0
  69. package/dist/web/public/mobile.c7513aed.css.br +0 -0
  70. package/dist/web/public/mobile.c7513aed.css.gz +0 -0
  71. package/dist/web/public/notification-manager.9c984ac2.js.gz +0 -0
  72. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  73. package/dist/web/public/{panels-ui.6bb3169f.js → panels-ui.ba0b0f1a.js} +1 -1
  74. package/dist/web/public/panels-ui.ba0b0f1a.js.br +0 -0
  75. package/dist/web/public/panels-ui.ba0b0f1a.js.gz +0 -0
  76. package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
  77. package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
  78. package/dist/web/public/respawn-ui.2d249da9.js.gz +0 -0
  79. package/dist/web/public/session-ui.34f25fdf.js.gz +0 -0
  80. package/dist/web/public/settings-ui.bf79c4c0.js +55 -0
  81. package/dist/web/public/settings-ui.bf79c4c0.js.br +0 -0
  82. package/dist/web/public/settings-ui.bf79c4c0.js.gz +0 -0
  83. package/dist/web/public/styles.f3cc9833.css +1 -0
  84. package/dist/web/public/styles.f3cc9833.css.br +0 -0
  85. package/dist/web/public/styles.f3cc9833.css.gz +0 -0
  86. package/dist/web/public/subagent-windows.a366a4ad.js.gz +0 -0
  87. package/dist/web/public/sw.js.gz +0 -0
  88. package/dist/web/public/terminal-ui.5bf97f7e.js +3 -0
  89. package/dist/web/public/terminal-ui.5bf97f7e.js.br +0 -0
  90. package/dist/web/public/terminal-ui.5bf97f7e.js.gz +0 -0
  91. package/dist/web/public/upload.html.gz +0 -0
  92. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  93. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  94. package/dist/web/public/vendor/xterm-addon-serialize.min.js +2 -0
  95. package/dist/web/public/vendor/xterm-addon-serialize.min.js.br +0 -0
  96. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  97. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  98. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  99. package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
  100. package/dist/web/public/vendor/xterm.css.gz +0 -0
  101. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  102. package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
  103. package/dist/web/routes/file-routes.d.ts +2 -2
  104. package/dist/web/routes/file-routes.d.ts.map +1 -1
  105. package/dist/web/routes/file-routes.js +160 -17
  106. package/dist/web/routes/file-routes.js.map +1 -1
  107. package/dist/web/routes/session-routes.d.ts.map +1 -1
  108. package/dist/web/routes/session-routes.js +50 -2
  109. package/dist/web/routes/session-routes.js.map +1 -1
  110. package/dist/web/routes/system-routes.d.ts.map +1 -1
  111. package/dist/web/routes/system-routes.js +19 -0
  112. package/dist/web/routes/system-routes.js.map +1 -1
  113. package/dist/web/sensitive-path.d.ts +24 -0
  114. package/dist/web/sensitive-path.d.ts.map +1 -0
  115. package/dist/web/sensitive-path.js +39 -0
  116. package/dist/web/sensitive-path.js.map +1 -0
  117. package/dist/web/server.d.ts +14 -0
  118. package/dist/web/server.d.ts.map +1 -1
  119. package/dist/web/server.js +40 -1
  120. package/dist/web/server.js.map +1 -1
  121. package/dist/web/session-listener-wiring.d.ts +5 -1
  122. package/dist/web/session-listener-wiring.d.ts.map +1 -1
  123. package/dist/web/session-listener-wiring.js +9 -1
  124. package/dist/web/session-listener-wiring.js.map +1 -1
  125. package/dist/web/sse-events.d.ts +3 -0
  126. package/dist/web/sse-events.d.ts.map +1 -1
  127. package/dist/web/sse-events.js +3 -0
  128. package/dist/web/sse-events.js.map +1 -1
  129. package/package.json +2 -1
  130. package/scripts/postinstall.js +3 -0
  131. package/dist/web/public/app.a23f8bf6.js +0 -35
  132. package/dist/web/public/app.a23f8bf6.js.br +0 -0
  133. package/dist/web/public/app.a23f8bf6.js.gz +0 -0
  134. package/dist/web/public/constants.8fa1a65f.js.br +0 -0
  135. package/dist/web/public/constants.8fa1a65f.js.gz +0 -0
  136. package/dist/web/public/mobile.da662a7b.css +0 -1
  137. package/dist/web/public/mobile.da662a7b.css.br +0 -0
  138. package/dist/web/public/mobile.da662a7b.css.gz +0 -0
  139. package/dist/web/public/panels-ui.6bb3169f.js.br +0 -0
  140. package/dist/web/public/panels-ui.6bb3169f.js.gz +0 -0
  141. package/dist/web/public/settings-ui.de9ba1ae.js +0 -55
  142. package/dist/web/public/settings-ui.de9ba1ae.js.br +0 -0
  143. package/dist/web/public/settings-ui.de9ba1ae.js.gz +0 -0
  144. package/dist/web/public/styles.3db29e83.css +0 -1
  145. package/dist/web/public/styles.3db29e83.css.br +0 -0
  146. package/dist/web/public/styles.3db29e83.css.gz +0 -0
  147. package/dist/web/public/terminal-ui.0e930cb3.js +0 -3
  148. package/dist/web/public/terminal-ui.0e930cb3.js.br +0 -0
  149. package/dist/web/public/terminal-ui.0e930cb3.js.gz +0 -0
@@ -1,3 +0,0 @@
1
- "use strict";(function(e){const s=/^\x1b\[[\?>=]?[\d;]*[cnR]$/,i=/^\x1b\][\d;]*[^\x07\x1b]*(?:\x07|\x1b\\)$/;function n(o){return s.test(o)||i.test(o)}function l(o){return n(o)}e.CodemanTerminalInput={isTerminalQueryResponse:n,shouldSuppressTerminalQueryResponse:l}})(window),Object.assign(CodemanApp.prototype,{initTerminal(){const e=parseInt(localStorage.getItem("codeman-scrollback")),s=Number.isFinite(e)&&e>0?Math.max(e,DEFAULT_SCROLLBACK):DEFAULT_SCROLLBACK;if(this.terminal=new Terminal({theme:{background:"#0d0d0d",foreground:"#e0e0e0",cursor:"#e0e0e0",cursorAccent:"#0d0d0d",selection:"rgba(255, 255, 255, 0.3)",black:"#0d0d0d",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#339af0",magenta:"#cc5de8",cyan:"#22b8cf",white:"#e0e0e0",brightBlack:"#495057",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#5c7cfa",brightMagenta:"#da77f2",brightCyan:"#66d9e8",brightWhite:"#ffffff"},fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "SF Mono", Monaco, monospace',fontSize:MobileDetection.getDeviceType()==="mobile"?10:14,lineHeight:1.2,cursorBlink:!1,cursorStyle:"block",scrollback:s,allowTransparency:!0,allowProposedApi:!0}),this.fitAddon=new FitAddon.FitAddon,this.terminal.loadAddon(this.fitAddon),typeof Unicode11Addon<"u")try{const t=new Unicode11Addon.Unicode11Addon;this.terminal.loadAddon(t),this.terminal.unicode.activeVersion="11"}catch{}const i=document.getElementById("terminalContainer");this.terminal.open(i),this.terminal.attachCustomKeyEventHandler(t=>{if(t.isComposing||t.keyCode===229||t.altKey&&t.key>="0"&&t.key<="9")return!1;if((t.ctrlKey||t.metaKey)&&t.key==="v"&&t.type==="keydown")return this.activeSessionId&&this._handleImagePaste&&this._handleImagePaste(),!1;if(t.key==="Enter"&&(t.shiftKey||t.ctrlKey)&&t.type==="keydown"){if(this.activeSessionId)if(this._localEchoEnabled){const d=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),d&&(this._pendingInput+=d,y()),setTimeout(()=>{fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t.ctrlKey?"C-Enter":"S-Enter"})})},d?80:0)}else fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t.ctrlKey?"C-Enter":"S-Enter"})});return!1}return!0});{const t=i.querySelector(".xterm-helper-textarea");if(t&&MobileDetection.isTouchDevice()){let d=!1,f=0;t.addEventListener("compositionstart",()=>{d=!0}),t.addEventListener("compositionend",()=>{d=!1}),t.addEventListener("keydown",c=>{!c.isComposing&&c.keyCode!==229&&(f=Date.now())}),t.addEventListener("input",c=>{if(d||c.isComposing||c.inputType!=="insertText"||!c.data||Date.now()-f<50)return;const h=c.data,p=this._localEchoOverlay?.pendingText||"";Promise.resolve().then(()=>{if(this._lastTerminalData?.data===h&&performance.now()-this._lastTerminalData.time<100){t.value="";return}const _=this._localEchoOverlay?.pendingText||"";if(this._localEchoEnabled&&_.length>p.length&&_.endsWith(h)){t.value="";return}const g=t.value;!g||g.trim()===""&&h!==" "||(this.terminal._core.coreService.triggerDataEvent(h,!0),t.value="")})})}}this._webglAddon=null;const n=new URLSearchParams(location.search);if(n.get("webgl")==="force")try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const l=(()=>{try{const t=localStorage.getItem("codeman-webgl-disabled");if(!t)return!1;const{at:d}=JSON.parse(t);return Date.now()-d>WEBGL_FALLBACK.STICKY_EXPIRY_MS?(localStorage.removeItem("codeman-webgl-disabled"),!1):!0}catch{return!1}})(),o=MobileDetection.getDeviceType()!=="desktop"||n.has("nowebgl")||l;if(l&&console.log("[CRASH-DIAG] WebGL sticky-disabled from prior stalls \u2014 DOM renderer in use. Re-enable: ?webgl=force"),!o)if(typeof WebglAddon<"u")this._initWebGL();else{const t=document.createElement("script");t.src="vendor/xterm-addon-webgl.min.js",t.onload=()=>this._initWebGL(),t.onerror=()=>console.warn("[CRASH-DIAG] Failed to load WebGL addon \u2014 using canvas renderer"),document.head.appendChild(t)}this._localEchoOverlay=new LocalEchoOverlay(this.terminal),MobileDetection.isTouchDevice()&&(this.terminal.onCursorMove(()=>this._syncMobileHelperTextareaToCursor()),this.terminal.onRender(()=>this._syncMobileHelperTextareaToCursor())),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:t=>{this._handleCjkInput(t)}})),MobileDetection.getDeviceType()==="mobile"&&document.body.classList.contains("safari-browser")?requestAnimationFrame(()=>{this.fitAddon.fit(),requestAnimationFrame(()=>this.fitAddon.fit())}):this.fitAddon.fit(),this.registerFilePathLinkProvider(),i.addEventListener("wheel",t=>{t.preventDefault();const d=Math.round(t.deltaY/25)||(t.deltaY>0?1:-1);this.terminal.scrollLines(d)},{passive:!1});{const t=()=>this.terminal._core?._renderService?.dimensions?.css?.cell?.height||13;let d=0,f=0,c=0,h=null,p=!1;const _=b=>{const E=c?(b-c)/16.67:1;if(c=b,!p&&Math.abs(f)>.3){const T=Math.round(f/t());T!==0&&this.terminal.scrollLines(T),f*=.92,h=requestAnimationFrame(_)}else p?h=requestAnimationFrame(_):(h=null,f=0)};let g=0,v=!1;i.addEventListener("touchstart",b=>{b.touches.length===1&&(d=b.touches[0].clientY,f=0,g=0,p=!0,v=!1,c=0,h&&(cancelAnimationFrame(h),h=null))},{passive:!0}),i.addEventListener("touchmove",b=>{if(b.touches.length===1&&p){b.preventDefault(),v=!0;const E=b.touches[0].clientY,T=d-E;g+=T,f=T*1.2,d=E;const x=t(),S=Math.trunc(g/x);S!==0&&(this.terminal.scrollLines(S),g-=S*x)}},{passive:!1}),i.addEventListener("touchend",()=>{if(p=!1,!h&&Math.abs(f)>.3&&(h=requestAnimationFrame(_)),!v&&this.terminal){const b=document.getElementById("cjkInput");b?.classList.contains("cjk-input-visible")?b.focus():(this._syncMobileHelperTextareaToCursor(),this.terminal.focus())}},{passive:!0}),i.addEventListener("touchcancel",()=>{p=!1,f=0,g=0},{passive:!0})}this.showWelcome(),this.initImageInput(),this._chunkedWriteGen=0,this._bufferLoadSeq=0,this._bufferLoadOwner=null,this._resizeTimeout=null,this._lastResizeDims=null;const u=40,a=10,m=()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._resizeTimeout=null,this.fitAddon&&this.fitAddon.fit(),this.flickerFilterBuffer&&(this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flushFlickerBuffer());const t=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible;if(this.activeSessionId&&!t){const d=this.fitAddon.proposeDimensions(),f=d?Math.max(d.cols,u):u,c=d?Math.max(d.rows,a):a;if(!this._lastResizeDims||f!==this._lastResizeDims.cols||c!==this._lastResizeDims.rows){const h=this.activeSessionId?this.sessions.get(this.activeSessionId):null;h&&h.mode!=="shell"&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J"),this._lastResizeDims={cols:f,rows:c};const p=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():"desktop";let _=!1;if(this._wsReady&&this._wsSessionId===this.activeSessionId)try{this._ws.send(JSON.stringify({t:"z",c:f,r:c,v:p})),_=!0}catch{}_||fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:f,rows:c,viewportType:p})}).catch(()=>{})}}this.updateConnectionLines(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender()},300)};window.addEventListener("resize",m),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(m),this.terminalResizeObserver.observe(i),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const y=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const t=this._pendingInput,d=this.activeSessionId;this._pendingInput="",this._sendInputAsync(d,t)}};this.terminal.onData(t=>{if(!(window.cjkActive||document.activeElement?.id==="cjkInput")&&this.activeSessionId){if(window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(t))return;if(this._lastTerminalData={data:t,time:performance.now()},this._localEchoEnabled){if(t==="\x7F"){if(this._localEchoOverlay?.removeChar()==="flushed"){const{count:c,text:h}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(c===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,c),this._flushedTexts?.set(this.activeSessionId,h))),this._pendingInput+=t,y()}return}if(/^[\r\n]+$/.test(t)){const f=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),f&&(this._pendingInput+=f,y()),setTimeout(()=>{this._pendingInput+="\r",y()},80);return}if(t.length>1&&t.charCodeAt(0)>=32){this._localEchoOverlay?.appendText(t);return}if(t.charCodeAt(0)<32){if(t.length>1&&t.charCodeAt(0)===27){this._pendingInput+=t,y();return}if(this._restoringFlushedState){this._pendingInput+=t,y();return}if(t===" "){const c=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),c&&(this._pendingInput+=c),this._pendingInput+=t,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let h="";try{const _=this._localEchoOverlay?.findPrompt?.();if(_){const g=this.terminal.buffer.active,v=g.getLine(g.viewportY+_.row);v&&(h=v.translateToString(!0).slice(_.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=h,y(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const p=this;this._tabCompletionFallback=setTimeout(()=>{if(p._tabCompletionFallback=null,!p._tabCompletionSessionId||p._tabCompletionSessionId!==p.activeSessionId)return;const _=p._localEchoOverlay;!_||_.pendingText||p.terminal.write("",()=>{if(!p._tabCompletionSessionId)return;_.resetBufferDetection();const g=_.detectBufferText();g&&g!==p._tabCompletionBaseText&&(p._tabCompletionSessionId=null,p._tabCompletionRetries=0,p._tabCompletionBaseText=null,_.rerender())})},300);return}const f=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),f&&(this._pendingInput+=f),this._pendingInput+=t,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),y();return}if(t.length===1&&t.charCodeAt(0)>=32){this._localEchoOverlay?.addChar(t);return}}if(this._pendingInput+=t,t.charCodeAt(0)<32||t.length>1){this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),y();return}const d=performance.now();d-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=d,y()):(this._lastKeystrokeTime=d,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(y,0)))}})},registerFilePathLinkProvider(){const e=this;let s=-1;this.terminal.registerLinkProvider({provideLinks(i,n){i!==s&&(s=i,console.debug("[LinkProvider] Checking line:",i));const o=e.terminal.buffer.active.getLine(i-1);if(!o){n(void 0);return}const r=o.translateToString(!0);if(!r||!r.includes("/")){n(void 0);return}const u=[],a=/https?:\/\/[^\s"'<>|;&)\]\x00-\x1f]+/g,m=(h,p)=>{const _=h.replace(/[.,;:!?)]+$/,""),g=r.indexOf(_,p);g!==-1&&(u.some(v=>v.range.start.x===g+1)||u.push({text:_,range:{start:{x:g+1,y:i},end:{x:g+_.length+1,y:i}},decorations:{pointerCursor:!0,underline:!0},activate(v,b){window.open(b,"_blank","noopener,noreferrer")}}))},y=/\b(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]+\s+){0,4}(\/[^\s"'<>|;&\n\x00-\x1f]+)/g,t=/(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\n\x00-\x1f]*\.(?:log|txt|json|md|yaml|yml|csv|xml|sh|py|ts|js))\b/g,d=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,f=(h,p)=>{const _=r.indexOf(h,p);_!==-1&&(u.some(g=>g.range.start.x===_+1)||u.push({text:h,range:{start:{x:_+1,y:i},end:{x:_+h.length+1,y:i}},decorations:{pointerCursor:!0,underline:!0},activate(g,v){e.openLogViewerWindow(v,e.activeSessionId)}}))};let c;for(a.lastIndex=0;(c=a.exec(r))!==null;)m(c[0],c.index);for(y.lastIndex=0;(c=y.exec(r))!==null;)f(c[2],c.index);for(t.lastIndex=0;(c=t.exec(r))!==null;)f(c[1],c.index);for(d.lastIndex=0;(c=d.exec(r))!==null;)f(c[1],c.index);u.length>0&&console.debug("[LinkProvider] Found links:",u.map(h=>h.text)),n(u.length>0?u:void 0)}}),console.log("[LinkProvider] File path link provider registered")},showWelcome(){const e=document.getElementById("welcomeOverlay");e&&(e.classList.add("visible"),this.loadTunnelStatus(),this.loadHistorySessions())},hideWelcome(){const e=document.getElementById("welcomeOverlay");e&&e.classList.remove("visible");const s=document.getElementById("welcomeQr");s&&(clearTimeout(this._welcomeQrShrinkTimer),s.classList.remove("expanded"))},async _fetchHistorySessions(){const i=(await(await fetch("/api/history/sessions")).json()).data?.sessions||[];if(i.length===0)return[];const n=new Map;for(const o of i){const r=o.projectKey||o.workingDir;n.has(r)||n.set(r,[]),n.get(r).push(o)}const l=[];for(const[,o]of n)l.push(...o.slice(0,3));return l.sort((o,r)=>new Date(r.lastModified)-new Date(o.lastModified)),l},_resolveCaseLabel(e,s){if(!e)return"";let i=null;for(const n of s||[])if(!(!n||!n.path)){if(e===n.path)return`#${n.name}`;if(e.startsWith(n.path+"/")){const l=n.path.length;(!i||l>i.len)&&(i={name:n.name,suffix:e.slice(l),len:l})}}return i?`#${i.name}${i.suffix}`:e.split("/").pop()||e},_shortenHomePath(e){return(e||"").replace(/^\/home\/[^/]+\//,"~/").replace(/^\/Users\/[^/]+\//,"~/")},_buildHistoryItem(e,s,i){const n=i?.showViewAll!==!1,l=e.sizeBytes<1024?`${e.sizeBytes}B`:e.sizeBytes<1048576?`${(e.sizeBytes/1024).toFixed(0)}K`:`${(e.sizeBytes/1048576).toFixed(1)}M`,o=new Date(e.lastModified),r=o.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+o.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1}),u=this._shortenHomePath(e.workingDir),a=this._resolveCaseLabel(e.workingDir,s),m=document.createElement("div");m.className="history-item",m.title=e.workingDir;const y=document.createElement("div");y.className="history-item-main",y.addEventListener("click",()=>this.resumeHistorySession(e.sessionId,e.workingDir));const t=document.createElement("div");t.className="history-item-text";const d=document.createElement("span");d.className="history-item-title",d.textContent=e.firstPrompt||u;const f=document.createElement("span");f.className="history-item-subtitle",a.startsWith("#")&&f.classList.add("is-case"),f.textContent=a,t.append(d,f);const c=document.createElement("span");c.className="history-item-meta",c.textContent=r;const h=document.createElement("button");h.className="history-item-expand",h.type="button",h.setAttribute("aria-label","Show details"),h.setAttribute("aria-expanded","false"),h.textContent="\u22EF",y.append(t,c,h);const p=document.createElement("div");p.className="history-item-detail",p.hidden=!0;const _=document.createElement("div");_.className="history-detail-row";const g=document.createElement("span");g.className="history-detail-label",g.textContent="Prompt";const v=document.createElement("span");v.className="history-detail-value history-detail-prompt",v.textContent=e.firstPrompt||"(no prompt captured)",_.append(g,v);const b=document.createElement("div");b.className="history-detail-row";const E=document.createElement("span");E.className="history-detail-label",E.textContent="Path";const T=document.createElement("span");T.className="history-detail-value history-detail-path",T.textContent=u,b.append(E,T);const x=document.createElement("div");if(x.className="history-detail-row history-detail-meta",x.textContent=`${r} \xB7 ${l} \xB7 ${e.sessionId.slice(0,8)}`,p.append(_,b,x),n&&e.projectKey){const S=document.createElement("div");S.className="history-detail-row history-detail-actions";const w=document.createElement("button");w.type="button",w.className="history-view-all-btn",w.textContent="View all in this folder",w.addEventListener("click",I=>{I.stopPropagation(),this.openFolderHistoryModal(e.projectKey,e.workingDir,s)}),S.appendChild(w),p.appendChild(S)}return h.addEventListener("click",S=>{S.stopPropagation();const w=m.classList.toggle("expanded");p.hidden=!w,h.setAttribute("aria-expanded",w?"true":"false")}),m.append(y,p),m},_HISTORY_INITIAL_COUNT:4,async loadHistorySessions(){const e=document.getElementById("historySessions"),s=document.getElementById("historyList");if(!(!e||!s))try{const i=Array.isArray(this.cases)&&this.cases.length>0?Promise.resolve(this.cases):fetch("/api/cases").then(r=>r.ok?r.json():null).then(r=>r?.data||[]).catch(()=>[]),[n,l]=await Promise.all([this._fetchHistorySessions(30),i]);if(n.length===0){e.style.display="none";return}s.replaceChildren();const o=this._HISTORY_INITIAL_COUNT;for(let r=0;r<Math.min(o,n.length);r++)s.appendChild(this._buildHistoryItem(n[r],l));if(n.length>o){const r=document.createElement("button");r.className="history-show-more",r.textContent=`Show ${n.length-o} more`,r.addEventListener("click",()=>{for(let u=o;u<n.length;u++)s.insertBefore(this._buildHistoryItem(n[u],l),r);r.remove()}),s.appendChild(r)}e.style.display=""}catch(i){console.error("[loadHistorySessions]",i),e.style.display="none"}},_FOLDER_HISTORY_PAGE_SIZE:20,openFolderHistoryModal(e,s,i){this._closeFolderHistoryModal();const n=document.createElement("div");n.className="modal active folder-history-modal",n.id="folderHistoryModal";const l=document.createElement("div");l.className="modal-backdrop",l.addEventListener("click",()=>this._closeFolderHistoryModal());const o=document.createElement("div");o.className="modal-content modal-lg";const r=document.createElement("div");r.className="modal-header";const u=document.createElement("h3");u.textContent="Folder History";const a=document.createElement("div");a.className="folder-history-subtitle",a.textContent=this._shortenHomePath(s);const m=document.createElement("button");m.className="modal-close",m.setAttribute("aria-label","Close"),m.innerHTML="&times;",m.addEventListener("click",()=>this._closeFolderHistoryModal()),r.append(u,m);const y=document.createElement("div");y.className="modal-body";const t=document.createElement("div");t.className="folder-history-list",t.setAttribute("data-loading","true"),t.textContent="Loading...",y.append(a,t),o.append(r,y),n.append(l,o),document.body.appendChild(n),this._folderHistoryState={projectKey:e,workingDir:s,cases:i||[],offset:0,total:null,list:t},this._folderHistoryEscHandler=d=>{d.key==="Escape"&&this._closeFolderHistoryModal()},document.addEventListener("keydown",this._folderHistoryEscHandler),this._loadFolderHistoryPage()},async _loadFolderHistoryPage(){const e=this._folderHistoryState;if(!e)return;const{projectKey:s,cases:i,list:n}=e,l=this._FOLDER_HISTORY_PAGE_SIZE,o=e.offset,r=n.querySelector(".folder-history-more");r&&r.remove(),o===0&&(n.replaceChildren(),n.removeAttribute("data-loading"));try{const u=`/api/history/sessions?projectKey=${encodeURIComponent(s)}&offset=${o}&limit=${l}`,m=await(await fetch(u)).json(),y=m.data?.sessions||[];if(e.total=typeof m.data?.total=="number"?m.data.total:y.length+o,o===0&&y.length===0){const t=document.createElement("div");t.className="folder-history-empty",t.textContent="No conversations found in this folder.",n.appendChild(t);return}for(const t of y)n.appendChild(this._buildHistoryItem(t,i,{showViewAll:!1}));if(e.offset=o+y.length,e.offset<e.total){const t=e.total-e.offset,d=document.createElement("button");d.className="history-show-more folder-history-more",d.textContent=`Show ${Math.min(l,t)} more (${t} remaining)`,d.addEventListener("click",()=>this._loadFolderHistoryPage()),n.appendChild(d)}}catch(u){console.error("[loadFolderHistoryPage]",u);const a=document.createElement("div");a.className="folder-history-empty",a.textContent="Failed to load folder history.",n.appendChild(a)}},_closeFolderHistoryModal(){const e=document.getElementById("folderHistoryModal");e&&e.remove(),this._folderHistoryEscHandler&&(document.removeEventListener("keydown",this._folderHistoryEscHandler),this._folderHistoryEscHandler=null),this._folderHistoryState=null},async resumeHistorySession(e,s){document.getElementById("runModeMenu")?.classList.remove("active"),this._closeFolderHistoryModal();try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${e.slice(0,8)}...\x1B[0m`);const i=s.split("/").pop()||"session";let n=1;for(const[,f]of this.sessions){const c=f.name&&f.name.match(/^w(\d+)-/);if(c){const h=parseInt(c[1]);h>=n&&(n=h+1)}}const l=`w${n}-${i}`,r=(this.cases||[]).find(f=>f.path===s)?.name||s.split("/").pop()||"",u=this.loadAppSettingsFromStorage(),a=this.buildEnvOverrides(this.getCaseSettings(r),u),m=this.getEffortSetting(u),t=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:s,name:l,resumeSessionId:e,...Object.keys(a).length>0?{envOverrides:a}:{},...m?{effort:m}:{}})})).json();if(!t.success)throw new Error(t.error);const d=t.data.session.id;await fetch(`/api/sessions/${d}/interactive`,{method:"POST"}),this.terminal.writeln(`\x1B[90m Session ${l} ready\x1B[0m`),await this.selectSession(d),this.terminal.focus()}catch(i){this.terminal.writeln(`\x1B[1;31m Error: ${i.message}\x1B[0m`)}},isTerminalAtBottom(){if(!this.terminal)return!0;const e=this.terminal.buffer.active;return e.viewportY>=e.baseY-2},batchTerminalWrite(e){if(this._isLoadingBuffer){this._loadBufferQueue&&this._loadBufferQueue.push(e);return}if(this.writeFrameScheduled||(this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()),(this.activeSessionId?this.sessions.get(this.activeSessionId):null)?.flickerFilterEnabled??!1){if(e.includes("\x1B[2J")||e.includes("\x1B[H\x1B[J")||e.includes("\x1B[H")&&e.includes("\x1B[?25l")){this.flickerFilterActive=!0,this.flickerFilterBuffer+=e,this.flickerFilterTimeout&&clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=setTimeout(()=>{this.flickerFilterTimeout=null,this.flushFlickerBuffer()},SYNC_WAIT_TIMEOUT_MS);return}if(this.flickerFilterActive){this.flickerFilterBuffer+=e;return}}this.pendingWrites.push(e),this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})))},_updateLocalEchoState(){const e=this.loadAppSettingsFromStorage(),s=this.activeSessionId?this.sessions.get(this.activeSessionId):null,n=!!((e.localEchoEnabled??MobileDetection.isTouchDevice())&&s);this._localEchoEnabled&&!n&&this._localEchoOverlay?.clear(),this._localEchoEnabled=n,this._localEchoOverlay&&s&&(s.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:l=>{try{const o=l.buffer.active,r=o.cursorY,u=o.getLine(o.viewportY+r);if(!u)return null;const m=u.translateToString(!0).indexOf("\u2503");return m>=0?{row:r,col:m}:null}catch{return null}}}):s.mode==="shell"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"custom",offset:0,find:l=>{try{const o=l.buffer.active;for(let r=l.rows-1;r>=0;r--){const u=o.getLine(o.viewportY+r);if(!u)continue;const m=u.translateToString(!0).lastIndexOf("\u276F");if(m>=0)return{row:r,col:m+2}}return{row:Math.max(0,Math.min(l.rows-1,o.cursorY)),col:Math.max(0,Math.min(l.cols-1,o.cursorX))}}catch{return null}}}))},_handleCjkInput(e){if(!this.activeSessionId)return;const s=this.activeSessionId,i=this.sessions.get(s);if(!!!(this._localEchoEnabled&&this._localEchoOverlay&&i?.mode!=="shell")){this._sendInputAsync(s,e);return}if(e==="\x7F"){if(this._localEchoOverlay.removeChar()==="flushed"){const{count:o,text:r}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(s)&&(o===0?(this._flushedOffsets.delete(s),this._flushedTexts?.delete(s)):(this._flushedOffsets.set(s,o),this._flushedTexts?.set(s,r))),this._sendInputAsync(s,e)}return}if(/[\r\n]+$/.test(e)){const l=e.replace(/[\r\n]+$/g,"");l&&this._localEchoOverlay.appendText(l);const o=this._localEchoOverlay.pendingText||"";this._localEchoOverlay.clear(),this._localEchoOverlay.suppressBufferDetection(),this._flushedOffsets?.delete(s),this._flushedTexts?.delete(s),o&&this._sendInputAsync(s,o),setTimeout(()=>this._sendInputAsync(s,"\r"),o?80:0);return}if(e.length>1&&e.charCodeAt(0)===27){this._sendInputAsync(s,e);return}if(e.length===1&&e.charCodeAt(0)<32){const l=this._localEchoOverlay.pendingText||"";this._localEchoOverlay.clear(),this._localEchoOverlay.suppressBufferDetection(),this._flushedOffsets?.delete(s),this._flushedTexts?.delete(s),l&&this._sendInputAsync(s,l),this._sendInputAsync(s,e);return}this._localEchoOverlay.appendText(e)},flushPendingWrites(){if(this.pendingWrites.length===0||!this.terminal)return;const e=performance.now(),s=this.pendingWrites.join("");this.pendingWrites=[];const i=s.length;i>16384&&_crashDiag.log(`FLUSH: ${(i/1024).toFixed(0)}KB`);const n=65536;let l=!1;i<=n?this.terminal.write(s):(this.terminal.write(s.slice(0,n)),this.pendingWrites.push(s.slice(n)),l=!0,this.writeFrameScheduled||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})));const o=l?n:i,r=performance.now()-e;if((r>100||l)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${r.toFixed(0)}ms, ${(o/1024).toFixed(0)}KB written${l?", rest deferred":""} (total ${(i/1024).toFixed(0)}KB)`),this._wasAtBottomBeforeWrite&&this.terminal.scrollToBottom(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender(),this._tabCompletionSessionId&&this._tabCompletionSessionId===this.activeSessionId&&this._localEchoOverlay&&!this._localEchoOverlay.pendingText){const u=this._localEchoOverlay,a=this;this.terminal.write("",()=>{if(!a._tabCompletionSessionId)return;u.resetBufferDetection();const m=u.detectBufferText();m?m===a._tabCompletionBaseText?(u.undoDetection(),a._tabCompletionRetries=(a._tabCompletionRetries||0)+1,a._tabCompletionRetries>60&&(a._tabCompletionSessionId=null,a._tabCompletionRetries=0)):(a._tabCompletionSessionId=null,a._tabCompletionRetries=0,a._tabCompletionBaseText=null,a._tabCompletionFallback&&(clearTimeout(a._tabCompletionFallback),a._tabCompletionFallback=null),u.rerender()):(a._tabCompletionRetries=(a._tabCompletionRetries||0)+1,a._tabCompletionRetries>60&&(a._tabCompletionSessionId=null,a._tabCompletionRetries=0))})}},_safeYield(e){let s=!1;const i=()=>{s||(s=!0,e())};requestAnimationFrame(i),setTimeout(i,50),this._workerYield(i)},_workerYield(e){try{if(this._yieldWorker===void 0){const s="onmessage=()=>setTimeout(()=>postMessage(0),0);",i=new Blob([s],{type:"application/javascript"}),n=URL.createObjectURL(i);this._yieldWorker=new Worker(n),URL.revokeObjectURL(n),this._yieldQueue=[],this._yieldWorker.onmessage=()=>{const l=this._yieldQueue.shift();l&&l()}}if(!this._yieldWorker)return;this._yieldQueue.push(e),this._yieldWorker.postMessage(0)}catch{this._yieldWorker=null}},scrollToLastNonEmptyLine(){if(!this.terminal?.buffer?.active){this.terminal?.scrollToBottom?.();return}const e=this.terminal.buffer.active,s=e.baseY+e.length;let i=-1;for(let n=s-1;n>=0;n--)if(e.getLine(n)?.translateToString(!0).trim()){i=n;break}if(i>=0&&typeof this.terminal.scrollToLine=="function"){let n=Math.max(0,i-this.terminal.rows+2);const l=Math.max(0,i);for(;n<l&&!e.getLine(n)?.translateToString(!0).trim();)n++;this.terminal.scrollToLine(n)}else this.terminal.scrollToBottom()},chunkedTerminalWrite(e,s=TERMINAL_CHUNK_SIZE,i){const n=++this._chunkedWriteGen,l=this._beginBufferLoad(i);return new Promise(o=>{if(!e||e.length===0){this._finishBufferLoad(l),o();return}const r=e.replace(DEC_SYNC_STRIP_RE,""),u=()=>{this._chunkedWriteGen===n&&this._finishBufferLoad(l),o()};if(r.length<=s){this.terminal.write(r,u);return}let a=0;const m=performance.now();let y=0;const t=()=>{if(this._chunkedWriteGen!==n){o();return}if(a>=r.length){const h=performance.now()-m;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${r.length} bytes in ${y} chunks, ${h.toFixed(0)}ms total`),this._safeYield(u);return}const d=performance.now(),f=r.slice(a,a+s);this.terminal.write(f);const c=performance.now()-d;y++,c>50&&console.warn(`[CRASH-DIAG] chunk #${y} write took ${c.toFixed(0)}ms (${f.length} bytes at offset ${a})`),a+=s,this._safeYield(t)};this._safeYield(t)})},_beginBufferLoad(e){this._bufferLoadSeq===void 0&&(this._bufferLoadSeq=0);const s=e===void 0?`buffer-${++this._bufferLoadSeq}`:e;return this._bufferLoadOwner=s,this._isLoadingBuffer=!0,this._loadBufferQueue=[],s},_finishBufferLoad(e){return e!==void 0&&this._bufferLoadOwner!==e?!1:(this._isLoadingBuffer=!1,this._loadBufferQueue=null,this._bufferLoadOwner=null,!0)},clearTerminal(){this.terminal.clear()},async restoreTerminalSize(){if(!this.activeSessionId){this.showToast("No active session","warning");return}const e=this.getTerminalDimensions();if(!e){this.showToast("Could not determine terminal size","error");return}try{await this.sendResize(this.activeSessionId),this.showToast(`Terminal restored to ${e.cols}x${e.rows}`,"success")}catch(s){console.error("Failed to restore terminal size:",s),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(e){},async copyTerminal(){try{const e=this.terminal.buffer.active;let s="";for(let i=0;i<e.length;i++){const n=e.getLine(i);n&&(s+=n.translateToString(!0)+`
2
- `)}await navigator.clipboard.writeText(s.replace(/\n+$/,`
3
- `)),this.showToast("Copied to clipboard","success")}catch{this.showToast("Failed to copy","error")}},_syncMobileHelperTextareaToCursor(){if(!(!MobileDetection.isTouchDevice()||!this.terminal?.element))try{const e=this.terminal.element,s=this.terminal.element.querySelector(".xterm-cursor"),i=this.terminal.element.querySelector(".xterm-screen");if(!(e instanceof HTMLElement)||!(s instanceof HTMLElement)||!(i instanceof HTMLElement))return;const n=s.getBoundingClientRect(),l=i.getBoundingClientRect();if(!n.width&&!n.height)return;const o=Math.max(0,Math.round(n.left-l.left)),r=Math.max(0,Math.round(n.top-l.top));e.style.setProperty("--xterm-helper-left",`${o}px`),e.style.setProperty("--xterm-helper-top",`${r}px`)}catch{}},increaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.min(e+2,24))},decreaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.max(e-2,10))},setFontSize(e){this.terminal.options.fontSize=e,document.getElementById("fontSizeDisplay").textContent=e,this.fitAddon.fit(),localStorage.setItem("codeman-font-size",e),this._localEchoOverlay?.refreshFont()},loadFontSize(){const e=localStorage.getItem("codeman-font-size");if(e){const s=parseInt(e,10);s>=10&&s<=24&&(this.terminal.options.fontSize=s,document.getElementById("fontSizeDisplay").textContent=s)}},getTerminalDimensions(){const i=this.fitAddon?.proposeDimensions();return i?{cols:Math.max(i.cols,40),rows:Math.max(i.rows,10)}:null},async sendResize(e,s={}){this.fitAddon&&this.fitAddon.fit();const i=this.getTerminalDimensions();if(!i)return!1;const n=this._lastResizeDims,l=!n||n.cols!==i.cols||n.rows!==i.rows;this._lastResizeDims={cols:i.cols,rows:i.rows};const o=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():window.innerWidth<430?"mobile":window.innerWidth<768?"tablet":"desktop";if(!s.forceHttp&&this._wsReady&&this._wsSessionId===e)try{return this._ws.send(JSON.stringify({t:"z",c:i.cols,r:i.rows,v:o})),l}catch{}return await fetch(`/api/sessions/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,viewportType:o})}),l},async sendInput(e){this.activeSessionId&&await fetch(`/api/sessions/${this.activeSessionId}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:e,useMux:!0})})},toggleDirInput(){const e=document.querySelector("#dirDisplay").parentElement,s=document.getElementById("dirInput");s.classList.contains("hidden")&&(s.classList.remove("hidden"),e.style.display="none",s.focus())},hideDirInput(){const e=document.querySelector("#dirDisplay").parentElement,s=document.getElementById("dirInput");setTimeout(()=>{s.classList.add("hidden"),e.style.display="";const i=s.value.trim();document.getElementById("dirDisplay").textContent=i||"No directory"},100)}});