aicodeman 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/orchestrator-loop.d.ts +124 -0
- package/dist/orchestrator-loop.d.ts.map +1 -0
- package/dist/orchestrator-loop.js +853 -0
- package/dist/orchestrator-loop.js.map +1 -0
- package/dist/orchestrator-planner.d.ts +58 -0
- package/dist/orchestrator-planner.d.ts.map +1 -0
- package/dist/orchestrator-planner.js +342 -0
- package/dist/orchestrator-planner.js.map +1 -0
- package/dist/orchestrator-verifier.d.ts +52 -0
- package/dist/orchestrator-verifier.d.ts.map +1 -0
- package/dist/orchestrator-verifier.js +234 -0
- package/dist/orchestrator-verifier.js.map +1 -0
- package/dist/prompts/index.d.ts +1 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +1 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/orchestrator.d.ts +65 -0
- package/dist/prompts/orchestrator.d.ts.map +1 -0
- package/dist/prompts/orchestrator.js +112 -0
- package/dist/prompts/orchestrator.js.map +1 -0
- package/dist/state-store.d.ts +6 -0
- package/dist/state-store.d.ts.map +1 -1
- package/dist/state-store.js +21 -0
- package/dist/state-store.js.map +1 -1
- package/dist/types/app-state.d.ts +2 -0
- package/dist/types/app-state.d.ts.map +1 -1
- package/dist/types/app-state.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/orchestrator.d.ts +211 -0
- package/dist/types/orchestrator.d.ts.map +1 -0
- package/dist/types/orchestrator.js +58 -0
- package/dist/types/orchestrator.js.map +1 -0
- package/dist/web/ports/index.d.ts +1 -0
- package/dist/web/ports/index.d.ts.map +1 -1
- package/dist/web/ports/orchestrator-port.d.ts +10 -0
- package/dist/web/ports/orchestrator-port.d.ts.map +1 -0
- package/dist/web/ports/orchestrator-port.js +6 -0
- package/dist/web/ports/orchestrator-port.js.map +1 -0
- package/dist/web/public/api-client.3adebdc2.js.gz +0 -0
- package/dist/web/public/app.cbf6e9e8.js +26 -0
- package/dist/web/public/app.cbf6e9e8.js.br +0 -0
- package/dist/web/public/app.cbf6e9e8.js.gz +0 -0
- package/dist/web/public/{constants.cd61abbc.js → constants.64161167.js} +14 -0
- package/dist/web/public/constants.64161167.js.br +0 -0
- package/dist/web/public/constants.64161167.js.gz +0 -0
- package/dist/web/public/index.html +23 -9
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.92544c51.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.9fb81db6.js.gz +0 -0
- package/dist/web/public/{mobile-handlers.65e5638d.js → mobile-handlers.1e2a8ef8.js} +86 -22
- package/dist/web/public/mobile-handlers.1e2a8ef8.js.br +0 -0
- package/dist/web/public/mobile-handlers.1e2a8ef8.js.gz +0 -0
- package/dist/web/public/mobile.fdd28a54.css +1 -0
- package/dist/web/public/mobile.fdd28a54.css.br +0 -0
- package/dist/web/public/mobile.fdd28a54.css.gz +0 -0
- package/dist/web/public/notification-manager.2d5ea8ec.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js +475 -0
- package/dist/web/public/orchestrator-panel.js.br +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/{panels-ui.d7f6be08.js → panels-ui.3dd2e29b.js} +25 -25
- package/dist/web/public/panels-ui.3dd2e29b.js.br +0 -0
- package/dist/web/public/panels-ui.3dd2e29b.js.gz +0 -0
- package/dist/web/public/ralph-panel.7b014f16.js.gz +0 -0
- package/dist/web/public/ralph-wizard.f31ab90e.js.gz +0 -0
- package/dist/web/public/respawn-ui.372c6ea7.js.gz +0 -0
- package/dist/web/public/session-ui.0a07c3b7.js.gz +0 -0
- package/dist/web/public/settings-ui.94c57184.js.gz +0 -0
- package/dist/web/public/styles.8e110d27.css +1 -0
- package/dist/web/public/styles.8e110d27.css.br +0 -0
- package/dist/web/public/styles.8e110d27.css.gz +0 -0
- package/dist/web/public/subagent-windows.a366a4ad.js.gz +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/terminal-ui.9b40798a.js +3 -0
- package/dist/web/public/terminal-ui.9b40798a.js.br +0 -0
- package/dist/web/public/terminal-ui.9b40798a.js.gz +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
- package/dist/web/routes/index.d.ts +1 -0
- package/dist/web/routes/index.d.ts.map +1 -1
- package/dist/web/routes/index.js +1 -0
- package/dist/web/routes/index.js.map +1 -1
- package/dist/web/routes/orchestrator-routes.d.ts +21 -0
- package/dist/web/routes/orchestrator-routes.d.ts.map +1 -0
- package/dist/web/routes/orchestrator-routes.js +230 -0
- package/dist/web/routes/orchestrator-routes.js.map +1 -0
- package/dist/web/routes/session-routes.d.ts.map +1 -1
- package/dist/web/routes/session-routes.js +62 -9
- package/dist/web/routes/session-routes.js.map +1 -1
- package/dist/web/schemas.d.ts +25 -0
- package/dist/web/schemas.d.ts.map +1 -1
- package/dist/web/schemas.js +22 -0
- package/dist/web/schemas.js.map +1 -1
- package/dist/web/server.d.ts +2 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +23 -1
- package/dist/web/server.js.map +1 -1
- package/dist/web/sse-events.d.ts +37 -1
- package/dist/web/sse-events.d.ts.map +1 -1
- package/dist/web/sse-events.js +39 -1
- package/dist/web/sse-events.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/public/app.9dab4ee2.js +0 -26
- package/dist/web/public/app.9dab4ee2.js.br +0 -0
- package/dist/web/public/app.9dab4ee2.js.gz +0 -0
- package/dist/web/public/constants.cd61abbc.js.br +0 -0
- package/dist/web/public/constants.cd61abbc.js.gz +0 -0
- package/dist/web/public/mobile-handlers.65e5638d.js.br +0 -0
- package/dist/web/public/mobile-handlers.65e5638d.js.gz +0 -0
- package/dist/web/public/mobile.b09497a4.css +0 -1
- package/dist/web/public/mobile.b09497a4.css.br +0 -0
- package/dist/web/public/mobile.b09497a4.css.gz +0 -0
- package/dist/web/public/panels-ui.d7f6be08.js.br +0 -0
- package/dist/web/public/panels-ui.d7f6be08.js.gz +0 -0
- package/dist/web/public/styles.b8ec2f5a.css +0 -1
- package/dist/web/public/styles.b8ec2f5a.css.br +0 -0
- package/dist/web/public/styles.b8ec2f5a.css.gz +0 -0
- package/dist/web/public/terminal-ui.e4565c7b.js +0 -3
- package/dist/web/public/terminal-ui.e4565c7b.js.br +0 -0
- package/dist/web/public/terminal-ui.e4565c7b.js.gz +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";Object.assign(CodemanApp.prototype,{initTerminal(){const e=parseInt(localStorage.getItem("codeman-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:e,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");if(this.terminal.open(i),this.terminal.attachCustomKeyEventHandler(t=>!(t.isComposing||t.keyCode===229)),this._webglAddon=null,!(MobileDetection.getDeviceType()!=="desktop")&&!new URLSearchParams(location.search).has("nowebgl"))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)}if(this._localEchoOverlay=new LocalEchoOverlay(this.terminal),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:t=>{this.activeSessionId&&this._sendInputAsync(this.activeSessionId,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 c=Math.round(t.deltaY/25)||(t.deltaY>0?1:-1);this.terminal.scrollLines(c)},{passive:!1}),!(MobileDetection.isTouchDevice()&&window.innerWidth<1024)){let t=0,c=0,l=0,h=0,f=null,m=!1;const p=i.querySelector(".xterm-viewport"),g=_=>{if(!p)return;const y=h?(_-h)/16.67:1;h=_,m?(c!==0&&(p.scrollTop+=c,c=0),f=requestAnimationFrame(g)):Math.abs(l)>.1?(p.scrollTop+=l*y,l*=.94,f=requestAnimationFrame(g)):(f=null,l=0)};i.addEventListener("touchstart",_=>{_.touches.length===1&&(t=_.touches[0].clientY,c=0,l=0,m=!0,h=0,f||(f=requestAnimationFrame(g)))},{passive:!0}),i.addEventListener("touchmove",_=>{if(_.touches.length===1&&m){const y=_.touches[0].clientY,b=t-y;c+=b,l=b*1.2,t=y}},{passive:!0}),i.addEventListener("touchend",()=>{m=!1},{passive:!0}),i.addEventListener("touchcancel",()=>{m=!1,l=0},{passive:!0})}this.showWelcome(),this._resizeTimeout=null,this._lastResizeDims=null;const d=40,r=10,a=()=>{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=this.activeSessionId?this.sessions.get(this.activeSessionId):null;t&&t.mode!=="shell"&&!t._ended&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J");const c=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible;if(this.activeSessionId&&!c){const l=this.fitAddon.proposeDimensions(),h=l?Math.max(l.cols,d):d,f=l?Math.max(l.rows,r):r;(!this._lastResizeDims||h!==this._lastResizeDims.cols||f!==this._lastResizeDims.rows)&&(this._lastResizeDims={cols:h,rows:f},fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:h,rows:f})}).catch(()=>{}))}this.updateConnectionLines(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender()},300)};window.addEventListener("resize",a),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(a),this.terminalResizeObserver.observe(i),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const s=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const t=this._pendingInput,c=this.activeSessionId;this._pendingInput="",this._sendInputAsync(c,t)}};this.terminal.onData(t=>{if(!(window.cjkActive||document.activeElement?.id==="cjkInput")&&this.activeSessionId){if(/^\x1b\[[\?>=]?[\d;]*[cnR]$/.test(t))return;if(this._localEchoEnabled){if(t==="\x7F"){if(this._localEchoOverlay?.removeChar()==="flushed"){const{count:h,text:f}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(h===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,h),this._flushedTexts?.set(this.activeSessionId,f))),this._pendingInput+=t,s()}return}if(/^[\r\n]+$/.test(t)){const l=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),l&&(this._pendingInput+=l,s()),setTimeout(()=>{this._pendingInput+="\r",s()},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,s();return}if(this._restoringFlushedState){this._pendingInput+=t,s();return}if(t===" "){const h=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),h&&(this._pendingInput+=h),this._pendingInput+=t,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let f="";try{const p=this._localEchoOverlay?.findPrompt?.();if(p){const g=this.terminal.buffer.active,_=g.getLine(g.viewportY+p.row);_&&(f=_.translateToString(!0).slice(p.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=f,s(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const m=this;this._tabCompletionFallback=setTimeout(()=>{if(m._tabCompletionFallback=null,!m._tabCompletionSessionId||m._tabCompletionSessionId!==m.activeSessionId)return;const p=m._localEchoOverlay;!p||p.pendingText||m.terminal.write("",()=>{if(!m._tabCompletionSessionId)return;p.resetBufferDetection();const g=p.detectBufferText();g&&g!==m._tabCompletionBaseText&&(m._tabCompletionSessionId=null,m._tabCompletionRetries=0,m._tabCompletionBaseText=null,p.rerender())})},300);return}const l=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),l&&(this._pendingInput+=l),this._pendingInput+=t,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),s();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),s();return}const c=performance.now();c-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=c,s()):(this._lastKeystrokeTime=c,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(s,0)))}})},registerFilePathLinkProvider(){const e=this;let i=-1;this.terminal.registerLinkProvider({provideLinks(o,n){o!==i&&(i=o,console.debug("[LinkProvider] Checking line:",o));const d=e.terminal.buffer.active.getLine(o);if(!d){n(void 0);return}const r=d.translateToString(!0);if(!r||!r.includes("/")){n(void 0);return}const a=[],s=/(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]*\s+)*(\/[^\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,c=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,l=(f,m)=>{const p=r.indexOf(f,m);p!==-1&&(a.some(g=>g.range.start.x===p+1)||a.push({text:f,range:{start:{x:p+1,y:o},end:{x:p+f.length+1,y:o}},decorations:{pointerCursor:!0,underline:!0},activate(g,_){e.openLogViewerWindow(_,e.activeSessionId)}}))};let h;for(s.lastIndex=0;(h=s.exec(r))!==null;)l(h[2],h.index);for(t.lastIndex=0;(h=t.exec(r))!==null;)l(h[1],h.index);for(c.lastIndex=0;(h=c.exec(r))!==null;)l(h[1],h.index);a.length>0&&console.debug("[LinkProvider] Found links:",a.map(f=>f.text)),n(a.length>0?a: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 i=document.getElementById("welcomeQr");i&&(clearTimeout(this._welcomeQrShrinkTimer),i.classList.remove("expanded"))},async _fetchHistorySessions(e=12){const n=(await(await fetch("/api/history/sessions")).json()).sessions||[];if(n.length===0)return[];const u=new Map;for(const r of n)u.has(r.workingDir)||u.set(r.workingDir,[]),u.get(r.workingDir).push(r);const d=[];for(const[,r]of u)d.push(...r.slice(0,2));return d.sort((r,a)=>new Date(a.lastModified)-new Date(r.lastModified)),d.slice(0,e)},async loadHistorySessions(){const e=document.getElementById("historySessions"),i=document.getElementById("historyList");if(!(!e||!i))try{const o=await this._fetchHistorySessions(12);if(o.length===0){e.style.display="none";return}i.replaceChildren();for(const n of o){const u=n.sizeBytes<1024?`${n.sizeBytes}B`:n.sizeBytes<1048576?`${(n.sizeBytes/1024).toFixed(0)}K`:`${(n.sizeBytes/1048576).toFixed(1)}M`,d=new Date(n.lastModified),r=d.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+d.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1}),a=n.workingDir.replace(/^\/home\/[^/]+\//,"~/"),s=document.createElement("div");s.className="history-item",s.title=n.workingDir,s.addEventListener("click",()=>this.resumeHistorySession(n.sessionId,n.workingDir));const t=document.createElement("span");t.className="history-item-dir",t.textContent=a;const c=document.createElement("span");c.className="history-item-meta",c.textContent=r;const l=document.createElement("span");l.className="history-item-size",l.textContent=u,s.append(t,c,l),i.appendChild(s)}e.style.display=""}catch(o){console.error("[loadHistorySessions]",o),e.style.display="none"}},async resumeHistorySession(e,i){document.getElementById("runModeMenu")?.classList.remove("active");try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${e.slice(0,8)}...\x1B[0m`);const o=i.split("/").pop()||"session";let n=1;for(const[,s]of this.sessions){const t=s.name&&s.name.match(/^w(\d+)-/);if(t){const c=parseInt(t[1]);c>=n&&(n=c+1)}}const u=`w${n}-${o}`,r=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:i,name:u,resumeSessionId:e})})).json();if(!r.success)throw new Error(r.error);const a=r.session.id;await fetch(`/api/sessions/${a}/interactive`,{method:"POST"}),this.terminal.writeln(`\x1B[90m Session ${u} ready\x1B[0m`),await this.selectSession(a),this.terminal.focus()}catch(o){this.terminal.writeln(`\x1B[1;31m Error: ${o.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,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.writeFrameScheduled||(this.writeFrameScheduled=!0,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})))},_updateLocalEchoState(){const e=this.loadAppSettingsFromStorage(),i=this.activeSessionId?this.sessions.get(this.activeSessionId):null,n=!!((e.localEchoEnabled??MobileDetection.isTouchDevice())&&i);this._localEchoEnabled&&!n&&this._localEchoOverlay?.clear(),this._localEchoEnabled=n,this._localEchoOverlay&&i&&(i.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:u=>{try{const d=u.buffer.active,r=d.cursorY,a=d.getLine(d.viewportY+r);if(!a)return null;const t=a.translateToString(!0).indexOf("\u2503");return t>=0?{row:r,col:t}:null}catch{return null}}}):i.mode==="shell"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"character",char:"\u276F",offset:2}))},flushPendingWrites(){if(this.pendingWrites.length===0||!this.terminal)return;const e=performance.now(),i=this.pendingWrites.join("");this.pendingWrites=[];const o=i.length;o>16384&&_crashDiag.log(`FLUSH: ${(o/1024).toFixed(0)}KB`);const n=65536;let u=!1;o<=n?this.terminal.write(i):(this.terminal.write(i.slice(0,n)),this.pendingWrites.push(i.slice(n)),u=!0,this.writeFrameScheduled||(this.writeFrameScheduled=!0,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})));const d=u?n:o,r=performance.now()-e;if((r>100||u)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${r.toFixed(0)}ms, ${(d/1024).toFixed(0)}KB written${u?", rest deferred":""} (total ${(o/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 a=this._localEchoOverlay,s=this;this.terminal.write("",()=>{if(!s._tabCompletionSessionId)return;a.resetBufferDetection();const t=a.detectBufferText();t?t===s._tabCompletionBaseText?(a.undoDetection(),s._tabCompletionRetries=(s._tabCompletionRetries||0)+1,s._tabCompletionRetries>60&&(s._tabCompletionSessionId=null,s._tabCompletionRetries=0)):(s._tabCompletionSessionId=null,s._tabCompletionRetries=0,s._tabCompletionBaseText=null,s._tabCompletionFallback&&(clearTimeout(s._tabCompletionFallback),s._tabCompletionFallback=null),a.rerender()):(s._tabCompletionRetries=(s._tabCompletionRetries||0)+1,s._tabCompletionRetries>60&&(s._tabCompletionSessionId=null,s._tabCompletionRetries=0))})}},chunkedTerminalWrite(e,i=TERMINAL_CHUNK_SIZE){return new Promise(o=>{if(!e||e.length===0){this._finishBufferLoad(),o();return}this._isLoadingBuffer=!0,this._loadBufferQueue=[];const n=e.replace(DEC_SYNC_STRIP_RE,""),u=()=>{this._finishBufferLoad(),o()};if(n.length<=i){this.terminal.write(n),u();return}let d=0;const r=performance.now();let a=0;const s=()=>{if(d>=n.length){const h=performance.now()-r;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${n.length} bytes in ${a} chunks, ${h.toFixed(0)}ms total`),requestAnimationFrame(u);return}const t=performance.now(),c=n.slice(d,d+i);this.terminal.write(c);const l=performance.now()-t;a++,l>50&&console.warn(`[CRASH-DIAG] chunk #${a} write took ${l.toFixed(0)}ms (${c.length} bytes at offset ${d})`),d+=i,requestAnimationFrame(s)};requestAnimationFrame(s)})},_finishBufferLoad(){const e=this._loadBufferQueue;if(this._isLoadingBuffer=!1,this._loadBufferQueue=null,e&&e.length>0)for(const i of e)this.batchTerminalWrite(i)},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),await fetch(`/api/sessions/${this.activeSessionId}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:"\f"})}),this.showToast(`Terminal restored to ${e.cols}x${e.rows}`,"success")}catch(i){console.error("Failed to restore terminal size:",i),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(e){!this.pendingCtrlL||!this.pendingCtrlL.has(e)||(this.pendingCtrlL.delete(e),e===this.activeSessionId&&this.sendResize(e).then(()=>{fetch(`/api/sessions/${e}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:"\f"})})}))},async copyTerminal(){try{const e=this.terminal.buffer.active;let i="";for(let o=0;o<e.length;o++){const n=e.getLine(o);n&&(i+=n.translateToString(!0)+`
|
|
2
|
-
`)}await navigator.clipboard.writeText(i.replace(/\n+$/,`
|
|
3
|
-
`)),this.showToast("Copied to clipboard","success")}catch{this.showToast("Failed to copy","error")}},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 i=parseInt(e,10);i>=10&&i<=24&&(this.terminal.options.fontSize=i,document.getElementById("fontSizeDisplay").textContent=i)}},getTerminalDimensions(){const o=this.fitAddon?.proposeDimensions();return o?{cols:Math.max(o.cols,40),rows:Math.max(o.rows,10)}:null},async sendResize(e){const i=this.getTerminalDimensions();if(i){if(this._wsReady&&this._wsSessionId===e)try{this._ws.send(JSON.stringify({t:"z",c:i.cols,r:i.rows}));return}catch{}await fetch(`/api/sessions/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}},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,i=document.getElementById("dirInput");i.classList.contains("hidden")&&(i.classList.remove("hidden"),e.style.display="none",i.focus())},hideDirInput(){const e=document.querySelector("#dirDisplay").parentElement,i=document.getElementById("dirInput");setTimeout(()=>{i.classList.add("hidden"),e.style.display="";const o=i.value.trim();document.getElementById("dirDisplay").textContent=o||"No directory"},100)}});
|
|
Binary file
|
|
Binary file
|