wherever-dev 0.9.0 → 0.9.1
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/package.json +3 -3
- package/public/_app/immutable/chunks/{D6hR9Kco.js → -xFihj9P.js} +2 -2
- package/public/_app/immutable/chunks/{D6hR9Kco.js.map → -xFihj9P.js.map} +1 -1
- package/public/_app/immutable/chunks/{BDScRLia.js → 88FtHtY_.js} +2 -2
- package/public/_app/immutable/chunks/{BDScRLia.js.map → 88FtHtY_.js.map} +1 -1
- package/public/_app/immutable/chunks/{CL5QpF5Q.js → DwXE0xae.js} +2 -2
- package/public/_app/immutable/chunks/{CL5QpF5Q.js.map → DwXE0xae.js.map} +1 -1
- package/public/_app/immutable/entry/{app.DeLAGEKb.js → app.DvvZgm5h.js} +3 -3
- package/public/_app/immutable/entry/{app.DeLAGEKb.js.map → app.DvvZgm5h.js.map} +1 -1
- package/public/_app/immutable/entry/start.DgTAbv12.js +2 -0
- package/public/_app/immutable/entry/start.DgTAbv12.js.map +1 -0
- package/public/_app/immutable/nodes/{0.CnfgGkkx.js → 0.COFe6BkI.js} +2 -2
- package/public/_app/immutable/nodes/{0.CnfgGkkx.js.map → 0.COFe6BkI.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.BXHAt3FG.js → 1.BLK2L9bz.js} +2 -2
- package/public/_app/immutable/nodes/{1.BXHAt3FG.js.map → 1.BLK2L9bz.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.BgbWxE1g.js → 2.anOtZjZq.js} +2 -2
- package/public/_app/immutable/nodes/{2.BgbWxE1g.js.map → 2.anOtZjZq.js.map} +1 -1
- package/public/_app/version.json +1 -1
- package/public/index.html +10 -10
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/entry/start.s2u3_iKS.js +0 -2
- package/public/_app/immutable/entry/start.s2u3_iKS.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ms,a as h,c as Zn,g as m,d as xr,e as W,s as Q,f as ir,t as xn}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as kr,be as H,ap as _o,M as mi,aS as gi,aq as Ms,d as ea,am as Ds,at as xi,n as _i,a0 as yi,u as wi,t as ki,a1 as Si,V as Ti,W as Ai,H as Ei,b3 as yo,C as wo,aE as ls,a2 as sr,ac as Ci,az as Ii,aZ as Ri,ay as ta,bd as na,bf as $i,bg as Vs,aU as Ks,aQ as ko,aP as lr,aM as cr,af as Wt,b6 as f,ai as t,a5 as Mi,bh as V,$ as Di,bl as Nn,ah as Vn,a8 as Gt,aK as qr,a_ as p,X as u,aV as d,aI as lt,b9 as G,aO as Mn,bi as Pt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as Cr,a as $e,p as br}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as ge,r as nt,c as ra,e as _n,i as Pn,d as Ni}from"../chunks/CL5QpF5Q.js";import{_ as Fi,b as qn}from"../chunks/ylfInSZr.js";import{v as sa}from"../chunks/D6hR9Kco.js";import{p as Ui}from"../chunks/BDScRLia.js";function So(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(kr(_)))}H(()=>{var g=mi;if(c===(c=e()??"")){En&&_o();return}if(r&&!En){g.nodes=null,_.innerHTML=c,c!==""&&ms(kr(_),_.lastChild);return}if(g.nodes!==null&&(gi(g.nodes.start,g.nodes.end),g.nodes=null),c!==""){if(En){Ms.data;for(var x=_o(),R=x;x!==null&&(x.nodeType!==ea||x.data!=="");)R=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,R),l=rs(x);return}var O=s?wi:o?ki:void 0,N=yi(s?"svg":o?"math":"template",O);N.innerHTML=c;var S=s||o?N:N.content;if(ms(kr(S),S.lastChild),s||o)for(;kr(S);)l.before(kr(S));else l.before(S)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=kr(document.head);a!==null&&(a.nodeType!==ea||a.data!==n);)a=Ds(a);if(a===null)yo(!1);else{var l=Ds(a);a.remove(),rs(l)}}En||(o=document.head.appendChild(Si()));try{Ti(()=>{var c=Ai(()=>e(o));c.f|=Ei})}finally{s&&(yo(!0),rs(r))}}function oa(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=oa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Bi(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=oa(n))&&(s&&(s+=" "),s+=e);return s}function Hi(n){return typeof n=="object"?Bi(n):n??""}function Wi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rn(n,e,r,s,o,a){var l=n[wo];if(En||l!==r||l===void 0){var c=Wi(r);(!En||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[wo]=r}return a}function Ys(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Ii(e))return Ri();for(var s of n.options)s.selected=e.includes(zr(s));return}for(s of n.options){var o=zr(s);if(ta(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function aa(n){var e=new MutationObserver(()=>{Ys(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),na(()=>{e.disconnect()})}function Gr(n,e,r=e){var s=new WeakSet,o=!0;ls(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),zr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");c=_&&zr(_)}r(c),n.__value=c,sr!==null&&s.add(sr)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=sr;if(s.has(l))return}if(Ys(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),aa(n)}function zr(n){return"__value"in n?n.__value:n.value}function Ln(n,e,r=e){var s=new WeakSet;ls(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=xs(n)?_s(a):a,r(a),sr!==null&&s.add(sr),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var g=n.value.length;l===c&&c===_&&g>_?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=l,n.selectionEnd=Math.min(c,g))}}}),(En&&n.defaultValue!==n.value||Vs(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),sr!==null&&s.add(sr)),Ks(()=>{var o=e();if(n===document.activeElement){var a=sr;if(s.has(a))return}xs(n)&&o===_s(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const gs=new Set;function ar(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),ls(r,"change",()=>{var g=r.__value;a&&(g=To(l,g,r.checked)),o(g)},()=>o(a?[]:null)),Ks(()=>{var g=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(g=g||[],r.checked=g.includes(r.__value)):r.checked=ta(r.__value,g)}),na(()=>{var g=l.indexOf(r);g!==-1&&l.splice(g,1)}),gs.has(l)||(gs.add(l),ko(()=>{l.sort((g,x)=>g.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),ko(()=>{if(c){var g;if(a)g=To(l,g,r.checked);else{var x=l.find(R=>R.checked);g=x?.__value}o(g)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Vs(e)==null)&&r(n.checked),Ks(()=>{var s=e();n.checked=!!s})}function To(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function xs(n){var e=n.type;return e==="number"||e==="range"}function _s(n){return n===""?null:+n}const Gi=!1,ji=!0,fp=Object.freeze(Object.defineProperty({__proto__:null,prerender:ji,ssr:Gi},Symbol.toStringTag,{value:"Module"})),ys="Wherever",qi="Create & maintain apps from wherever with a beautiful remote workspace.",ws="https://localhost",Vi="#000000",Ki="black-translucent";function Tr(n,e){return Oi(n)}var Yi=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function Zi(n,e){lr(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({type:e.type||"website",title:e.title||ys,description:e.description||qi,image:e.image||s,url:`${r}${Ui.url.pathname}`}));zi("13n5pl5",l=>{var c=Yi(),_=Wt(c),g=f(_,2),x=f(g,2);{var R=qe=>{var Xe=Zn(),yt=Wt(Xe);E(yt,rt=>{}),h(qe,Xe)};E(x,qe=>{t(o)&&qe(R)})}var O=f(x,2),N=f(O,2),S=f(N,2),Y=f(S,2),ke=f(Y,2),J=f(ke,4),ue=f(J,2),Le=f(ue,2),_e=f(Le,2),Ce=f(_e,2),fe=f(Ce,2),Me=f(fe,2),Ie=f(Me,2),St=f(Ie,2),ut=f(St,4),Ge=f(ut,4),we=f(Ge,2),Tt=f(we,2);H((qe,Xe,yt,rt)=>{ge(_,"content",t(a).title),ge(g,"content",t(a).description),ge(O,"content",t(a).type),ge(N,"content",t(a).url),ge(S,"content",t(a).title),ge(Y,"content",t(a).description),ge(ke,"content",t(a).image),ge(J,"content",t(a).url),ge(ue,"content",t(a).title),ge(Le,"content",t(a).description),ge(_e,"content",t(a).image),ge(Ce,"href",qe),ge(fe,"href",Xe),ge(Me,"href",yt),ge(Ie,"href",rt),ge(St,"content",Vi),ge(ut,"content",ys),ge(Ge,"content",Ki),ge(we,"content",ys),ge(Tt,"content",sa)},[()=>Tr("/pwa/favicon.png"),()=>Tr("/pwa/favicon.ico"),()=>Tr("/pwa/apple-touch-icon.png"),()=>Tr("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),cr()}let Ir=null;function Xi(){if(typeof window>"u")return null;try{if(!Ir){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Ir=new n}return Ir.state==="suspended"&&Ir.resume().catch(()=>{}),Ir}catch{return null}}function Ao(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Eo=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Eo.get(n);e||(e=new Audio(n),e.preload="auto",Eo.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function ia(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Ao(e,1046.5,r,.16,.12),Ao(e,1396.9,r+.13,.22,.12)}catch{}}function es(){}function Ji(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function el(n,...e){if(n==null)return es;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Qt(n){let e;return el(n,r=>e=r)(),e}var yr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!yr.length;for(const g of s)g[1](),yr.push(g,n);if(_){for(let g=0;g<yr.length;g+=2)yr[g][0](yr[g+1]);yr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const g=[c,_];return s.add(g),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const ks={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class $n{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=tl({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(N=>r?{...N,connecting:!0,error:null}:{...ks,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(N=>({...N,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const N=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=N?new c(l,N):new c(l)}catch(N){this.stateStore.update(S=>({...S,connecting:!1,error:`Failed to connect: ${N}`})),this.scheduleReconnect();return}const _=this.ws,g=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(J=>({...J,connected:!0,connecting:!1,error:null}));const N=Qt(this.stateStore),S=this.resumeSessionFile??N.activeSessionFile,Y=this.resumeSessionFile!=null?this.resumeCwd:N.activeCwd??void 0,ke=this.resumeSessionFile!=null?this.resumeModel:N.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,S?(this.stateStore.update(J=>J.resyncing?J:{...J,resyncing:!0}),this.send({type:"session_load",sessionFile:S,cwd:Y,model:ke}),this.armLoadWatchdog()):this.stateStore.update(J=>J.resyncing?{...J,resyncing:!1}:J)},x=N=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const S=typeof N.data=="string"?N.data:N.data.toString(),Y=JSON.parse(S);this.handleMessage(Y)}catch(S){console.error("Failed to parse WebSocket message:",S)}}},R=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(N=>({...N,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:N.activeSessionFile?!0:N.resyncing})),this.scheduleReconnect())},O=N=>{this.ws===_&&this.stateStore.update(S=>({...S,error:S.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",g),_.addEventListener("message",x),_.addEventListener("close",R),_.addEventListener("error",O)):typeof _.on=="function"&&(_.on("open",g),_.on("message",N=>x({data:N})),_.on("close",R),_.on("error",O))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Qt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Qt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Qt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,$n.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Qt(this.stateStore).isStreaming,a=o?$n.TURN_STALL_MS:$n.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,$n.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Qt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},$n.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Qt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},$n.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=$n.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Qt(this.stateStore);const c=[...o].reverse().find(g=>g.role==="user");e.role==="user"&&c&&c.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
|
|
1
|
+
import{b as ms,a as h,c as Zn,g as m,d as xr,e as W,s as Q,f as ir,t as xn}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as kr,be as H,ap as _o,M as mi,aS as gi,aq as Ms,d as ea,am as Ds,at as xi,n as _i,a0 as yi,u as wi,t as ki,a1 as Si,V as Ti,W as Ai,H as Ei,b3 as yo,C as wo,aE as ls,a2 as sr,ac as Ci,az as Ii,aZ as Ri,ay as ta,bd as na,bf as $i,bg as Vs,aU as Ks,aQ as ko,aP as lr,aM as cr,af as Wt,b6 as f,ai as t,a5 as Mi,bh as V,$ as Di,bl as Nn,ah as Vn,a8 as Gt,aK as qr,a_ as p,X as u,aV as d,aI as lt,b9 as G,aO as Mn,bi as Pt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as Cr,a as $e,p as br}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as ge,r as nt,c as ra,e as _n,i as Pn,d as Ni}from"../chunks/DwXE0xae.js";import{_ as Fi,b as qn}from"../chunks/ylfInSZr.js";import{v as sa}from"../chunks/-xFihj9P.js";import{p as Ui}from"../chunks/88FtHtY_.js";function So(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(kr(_)))}H(()=>{var g=mi;if(c===(c=e()??"")){En&&_o();return}if(r&&!En){g.nodes=null,_.innerHTML=c,c!==""&&ms(kr(_),_.lastChild);return}if(g.nodes!==null&&(gi(g.nodes.start,g.nodes.end),g.nodes=null),c!==""){if(En){Ms.data;for(var x=_o(),R=x;x!==null&&(x.nodeType!==ea||x.data!=="");)R=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,R),l=rs(x);return}var O=s?wi:o?ki:void 0,N=yi(s?"svg":o?"math":"template",O);N.innerHTML=c;var S=s||o?N:N.content;if(ms(kr(S),S.lastChild),s||o)for(;kr(S);)l.before(kr(S));else l.before(S)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=kr(document.head);a!==null&&(a.nodeType!==ea||a.data!==n);)a=Ds(a);if(a===null)yo(!1);else{var l=Ds(a);a.remove(),rs(l)}}En||(o=document.head.appendChild(Si()));try{Ti(()=>{var c=Ai(()=>e(o));c.f|=Ei})}finally{s&&(yo(!0),rs(r))}}function oa(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=oa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Bi(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=oa(n))&&(s&&(s+=" "),s+=e);return s}function Hi(n){return typeof n=="object"?Bi(n):n??""}function Wi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rn(n,e,r,s,o,a){var l=n[wo];if(En||l!==r||l===void 0){var c=Wi(r);(!En||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[wo]=r}return a}function Ys(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Ii(e))return Ri();for(var s of n.options)s.selected=e.includes(zr(s));return}for(s of n.options){var o=zr(s);if(ta(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function aa(n){var e=new MutationObserver(()=>{Ys(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),na(()=>{e.disconnect()})}function Gr(n,e,r=e){var s=new WeakSet,o=!0;ls(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),zr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");c=_&&zr(_)}r(c),n.__value=c,sr!==null&&s.add(sr)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=sr;if(s.has(l))return}if(Ys(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),aa(n)}function zr(n){return"__value"in n?n.__value:n.value}function Ln(n,e,r=e){var s=new WeakSet;ls(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=xs(n)?_s(a):a,r(a),sr!==null&&s.add(sr),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var g=n.value.length;l===c&&c===_&&g>_?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=l,n.selectionEnd=Math.min(c,g))}}}),(En&&n.defaultValue!==n.value||Vs(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),sr!==null&&s.add(sr)),Ks(()=>{var o=e();if(n===document.activeElement){var a=sr;if(s.has(a))return}xs(n)&&o===_s(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const gs=new Set;function ar(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),ls(r,"change",()=>{var g=r.__value;a&&(g=To(l,g,r.checked)),o(g)},()=>o(a?[]:null)),Ks(()=>{var g=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(g=g||[],r.checked=g.includes(r.__value)):r.checked=ta(r.__value,g)}),na(()=>{var g=l.indexOf(r);g!==-1&&l.splice(g,1)}),gs.has(l)||(gs.add(l),ko(()=>{l.sort((g,x)=>g.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),ko(()=>{if(c){var g;if(a)g=To(l,g,r.checked);else{var x=l.find(R=>R.checked);g=x?.__value}o(g)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Vs(e)==null)&&r(n.checked),Ks(()=>{var s=e();n.checked=!!s})}function To(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function xs(n){var e=n.type;return e==="number"||e==="range"}function _s(n){return n===""?null:+n}const Gi=!1,ji=!0,fp=Object.freeze(Object.defineProperty({__proto__:null,prerender:ji,ssr:Gi},Symbol.toStringTag,{value:"Module"})),ys="Wherever",qi="Create & maintain apps from wherever with a beautiful remote workspace.",ws="https://localhost",Vi="#000000",Ki="black-translucent";function Tr(n,e){return Oi(n)}var Yi=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function Zi(n,e){lr(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({type:e.type||"website",title:e.title||ys,description:e.description||qi,image:e.image||s,url:`${r}${Ui.url.pathname}`}));zi("13n5pl5",l=>{var c=Yi(),_=Wt(c),g=f(_,2),x=f(g,2);{var R=qe=>{var Xe=Zn(),yt=Wt(Xe);E(yt,rt=>{}),h(qe,Xe)};E(x,qe=>{t(o)&&qe(R)})}var O=f(x,2),N=f(O,2),S=f(N,2),Y=f(S,2),ke=f(Y,2),J=f(ke,4),ue=f(J,2),Le=f(ue,2),_e=f(Le,2),Ce=f(_e,2),fe=f(Ce,2),Me=f(fe,2),Ie=f(Me,2),St=f(Ie,2),ut=f(St,4),Ge=f(ut,4),we=f(Ge,2),Tt=f(we,2);H((qe,Xe,yt,rt)=>{ge(_,"content",t(a).title),ge(g,"content",t(a).description),ge(O,"content",t(a).type),ge(N,"content",t(a).url),ge(S,"content",t(a).title),ge(Y,"content",t(a).description),ge(ke,"content",t(a).image),ge(J,"content",t(a).url),ge(ue,"content",t(a).title),ge(Le,"content",t(a).description),ge(_e,"content",t(a).image),ge(Ce,"href",qe),ge(fe,"href",Xe),ge(Me,"href",yt),ge(Ie,"href",rt),ge(St,"content",Vi),ge(ut,"content",ys),ge(Ge,"content",Ki),ge(we,"content",ys),ge(Tt,"content",sa)},[()=>Tr("/pwa/favicon.png"),()=>Tr("/pwa/favicon.ico"),()=>Tr("/pwa/apple-touch-icon.png"),()=>Tr("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),cr()}let Ir=null;function Xi(){if(typeof window>"u")return null;try{if(!Ir){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Ir=new n}return Ir.state==="suspended"&&Ir.resume().catch(()=>{}),Ir}catch{return null}}function Ao(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Eo=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Eo.get(n);e||(e=new Audio(n),e.preload="auto",Eo.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function ia(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Ao(e,1046.5,r,.16,.12),Ao(e,1396.9,r+.13,.22,.12)}catch{}}function es(){}function Ji(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function el(n,...e){if(n==null)return es;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Qt(n){let e;return el(n,r=>e=r)(),e}var yr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!yr.length;for(const g of s)g[1](),yr.push(g,n);if(_){for(let g=0;g<yr.length;g+=2)yr[g][0](yr[g+1]);yr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const g=[c,_];return s.add(g),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const ks={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class $n{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=tl({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(N=>r?{...N,connecting:!0,error:null}:{...ks,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(N=>({...N,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const N=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=N?new c(l,N):new c(l)}catch(N){this.stateStore.update(S=>({...S,connecting:!1,error:`Failed to connect: ${N}`})),this.scheduleReconnect();return}const _=this.ws,g=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(J=>({...J,connected:!0,connecting:!1,error:null}));const N=Qt(this.stateStore),S=this.resumeSessionFile??N.activeSessionFile,Y=this.resumeSessionFile!=null?this.resumeCwd:N.activeCwd??void 0,ke=this.resumeSessionFile!=null?this.resumeModel:N.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,S?(this.stateStore.update(J=>J.resyncing?J:{...J,resyncing:!0}),this.send({type:"session_load",sessionFile:S,cwd:Y,model:ke}),this.armLoadWatchdog()):this.stateStore.update(J=>J.resyncing?{...J,resyncing:!1}:J)},x=N=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const S=typeof N.data=="string"?N.data:N.data.toString(),Y=JSON.parse(S);this.handleMessage(Y)}catch(S){console.error("Failed to parse WebSocket message:",S)}}},R=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(N=>({...N,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:N.activeSessionFile?!0:N.resyncing})),this.scheduleReconnect())},O=N=>{this.ws===_&&this.stateStore.update(S=>({...S,error:S.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",g),_.addEventListener("message",x),_.addEventListener("close",R),_.addEventListener("error",O)):typeof _.on=="function"&&(_.on("open",g),_.on("message",N=>x({data:N})),_.on("close",R),_.on("error",O))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Qt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Qt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Qt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,$n.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Qt(this.stateStore).isStreaming,a=o?$n.TURN_STALL_MS:$n.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,$n.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Qt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},$n.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Qt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},$n.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=$n.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Qt(this.stateStore);const c=[...o].reverse().find(g=>g.role==="user");e.role==="user"&&c&&c.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
|
|
2
2
|
`)?a.content+e.delta:`${a.content}
|
|
3
3
|
${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,l=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(c=>{const _=c.messages.find(x=>x.role==="tool"&&x.toolName===e.toolName&&x.isStreaming)??[...c.messages].reverse().find(x=>x.role==="tool"&&x.toolName===e.toolName&&!x.content.startsWith("Tool error:")),g=Date.now();if(_){const x=a?"Error: ":"";return{...c,messages:c.messages.map(R=>R.id===_.id?{...R,content:`${x}${R.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:g}:R)}}else{const x=a?`Tool error: ${e.toolName}
|
|
@@ -84,4 +84,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
84
84
|
${oe}`}}if(ee.startsWith("/")&&t(ue).length===0){const T=ee.toLowerCase();if(T==="/new"||T==="/reset"){if(t(Ce).cwd){jn(t(Ce).cwd,t(Ce).model||void 0),p(S,"");return}}else if(T==="/clear"){Ea(),p(S,"");return}else if(T==="/leave"||T==="/exit"){Dn(),p(S,"");return}}const A=uu({streaming:t(Le),connected:t(fe),agentPending:t(Me).agentPending,readOnly:t(_e),hasSession:!!t(Ce).sessionId});if(A.action!=="send"){(A.reason==="disconnected"||A.reason==="agent-pending")&&Us(ce);return}Us(ce)&&(p(S,""),p(ue,[],!0),e.onSend?.())}function st(ee){ee.key==="Enter"&&(t(Y)?ee.shiftKey||(ee.preventDefault(),wt()):ee.shiftKey&&(ee.preventDefault(),wt()))}var te={focusInput:Xe},xt=Pu(),Ee=u(xt);{var ot=ee=>{var ce=yu(),A=u(ce);{var U=z=>{var me=gu();lt(2),h(z,me)},T=z=>{var me=xu(),be=f(Wt(me),2),ze=u(be,!0);d(be),H(()=>Q(ze,t(Me).error)),h(z,me)},oe=z=>{var me=_u();lt(2),h(z,me)};E(A,z=>{t(Me).connecting?z(U):t(Me).error?z(T,1):t(fe)||z(oe,2)})}d(ce),h(ee,ce)};E(Ee,ee=>{(!t(fe)||t(Me).connecting||t(Me).error)&&ee(ot)})}var At=f(Ee,2);{var vt=ee=>{var ce=wu(),A=u(ce),U=u(A),T=u(U),oe=u(T,!0);d(T);var z=f(T,2),me=u(z);{var be=Ne=>{var Oe=xn();H(()=>Q(Oe,e.placeholder??"Search the web...")),h(Ne,Oe)},ze=Ne=>{var Oe=xn("Agent is working, tap to Steer...");h(Ne,Oe)},Ue=Ne=>{var Oe=xn("Read-only mode");h(Ne,Oe)},at=Ne=>{var Oe=xn("Select a session first...");h(Ne,Oe)},pt=Ne=>{var Oe=xn("Tap to type a message...");h(Ne,Oe)};E(me,Ne=>{x()?Ne(be):t(Le)?Ne(ze,1):t(_e)?Ne(Ue,2):t(Ce).sessionId?Ne(pt,-1):Ne(at,3)})}d(z),d(U),lt(2),d(A),d(ce),H(()=>Q(oe,x()?"🔍":"💬")),W("click",A,()=>{p(ke,!1),setTimeout(()=>t(Ge)?.focus(),50)}),h(ee,ce)},Te=ee=>{var ce=Du(),A=Wt(ce);{var U=ie=>{var it=Cu();_n(it,21,()=>t(ue),Pn,(Ot,kt,mt)=>{var nn=Eu(),Yt=u(nn),yn=u(Yt,!0);d(Yt);var wn=f(Yt,2);{var Cn=Z=>{var xe=ku();h(Z,xe)},M=Z=>{var xe=Tu(),qt=u(xe),Ct=u(qt);d(qt);var Ut=f(qt,2);{var It=Nt=>{var Ft=Su();H(()=>ge(Ft,"href",t(kt).url)),h(Nt,Ft)};E(Ut,Nt=>{t(kt).url&&Nt(It)})}d(xe),H(()=>{ge(xe,"title",t(kt).error),Q(Ct,`⚠️ ${t(kt).error??""}`)}),h(Z,xe)},q=Z=>{var xe=Au();h(Z,xe)};E(wn,Z=>{t(kt).uploading?Z(Cn):t(kt).error?Z(M,1):Z(q,-1)})}var K=f(wn,2);d(nn),H(()=>{ge(Yt,"title",t(kt).name),Q(yn,t(kt).name)}),W("click",K,()=>ft(mt)),h(Ot,nn)}),d(it),h(ie,it)};E(A,ie=>{t(ue).length>0&&ie(U)})}var T=f(A,2);{var oe=ie=>{var it=Ru(),Ot=f(u(it),2);_n(Ot,21,O,Pn,(kt,mt)=>{var nn=Iu(),Yt=u(nn,!0);d(nn);var yn={};H(()=>{Q(Yt,t(mt).label),yn!==(yn=t(mt).value)&&(nn.value=(nn.__value=t(mt).value)??"")}),h(kt,nn)}),d(Ot),d(it),H(()=>Ot.disabled=t(Ie)),Gr(Ot,N),h(ie,it)};E(T,ie=>{x()&&O().length>0&&ie(oe)})}var z=f(T,2),me=u(z),be=u(me);Li(be),ge(be,"rows",1),qn(be,ie=>p(Ge,ie),()=>t(Ge)),d(me);var ze=f(me,2),Ue=u(ze);{var at=ie=>{var it=$u(),Ot=Wt(it),kt=f(Ot,2);qn(kt,mt=>p(J,mt),()=>t(J)),H(()=>Ot.disabled=t(Ie)),W("click",Ot,()=>{ga(),t(J)?.click()}),W("change",kt,rt),h(ie,it)};E(Ue,ie=>{g()&&!x()&&ie(at)})}var pt=f(Ue,2),Ne=u(pt);mu(Ne,{get disabled(){return t(Ie)},onSend:wt,get text(){return t(S)},set text(ie){p(S,ie,!0)}}),d(pt);var Oe=f(pt,2),jt=u(Oe);{var Vt=ie=>{var it=xn();H(()=>Q(it,e.submitLabel??"Search")),h(ie,it)},hn=ie=>{var it=xn("Steer");h(ie,it)},bn=ie=>{var it=xn("Send");h(ie,it)};E(jt,ie=>{x()?ie(Vt):t(Le)?ie(hn,1):ie(bn,-1)})}d(Oe),d(ze),d(z);var Dt=f(z,2),Et=u(Dt),Ke=u(Et);nt(Ke),lt(2),d(Et);var en=f(Et,2),Kt=u(en),tn=f(Kt,2);{var Tn=ie=>{var it=Mu();h(ie,it)};E(tn,ie=>{t(Y)||ie(Tn)})}d(en),d(Dt),H(()=>{be.disabled=t(Ie),ge(be,"placeholder",x()?e.placeholder??"Search the web...":t(fe)?t(Le)?"Agent is working, Steer to interrupt...":t(_e)?"Read-only mode":t(Ce).sessionId?"Type a message...":"Select a session first...":t(Me).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Oe.disabled=!t(ut),ge(Oe,"title",!x()&&t(Le)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ra(Ke,t(Y))}),ir("submit",z,ie=>{ie.preventDefault(),wt()}),W("keydown",be,st),Ln(be,()=>t(S),ie=>p(S,ie)),W("change",Ke,yt),W("click",Kt,()=>p(ke,!0)),h(ee,ce)};E(At,ee=>{t(ke)?ee(vt):ee(Te,-1)})}d(xt),h(n,xt);var an=cr(te);return _(),an}xr(["click","keydown","change"]);var Ou=m('<button type="button" class="block w-full px-2.5 py-1 text-left text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Nu=m('<div class="absolute right-0 left-0 z-50 mt-1 max-h-40 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Fu=m('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Uu=m('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),zu=m("<option> </option>"),Bu=m('<select id="sidebar-model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Hu=m('<input id="sidebar-model" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),Wu=m('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),Gu=m('<div class="space-y-1 py-0.5"><div class="flex items-center gap-1.5"><input id="sidebar-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),ju=m('<div class="flex items-center gap-1.5 py-0.5"><input id="sidebar-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-git-init" class="cursor-pointer text-xs text-brand-text select-none">Initialize Git repository</label></div>'),qu=m('<form class="space-y-2.5 border-t border-brand-border/30 bg-brand-surface/30 p-3"><div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-folder">Folder Path</label> <div class="relative"><input id="sidebar-folder" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-model">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50">Create Session</button></form>'),Vu=m('<div class="border-b border-brand-border/50 bg-brand-surface/10"><button class="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/30"><span> </span></button> <!></div>'),Ku=m('<div class="p-4 text-center text-brand-text-muted"><div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent"></div> <span class="ml-2 text-sm">Loading sessions...</span></div>'),Yu=m('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Zu=m('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete All">Delete All?</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Xu=m('<button class="rounded px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-rose-400 focus:outline-none" title="Delete all sessions in this folder">Delete All</button>'),Qu=m('<div class="mb-1.5 flex items-center justify-between"><button class="rounded px-2 py-1 text-left text-xs text-brand-blue transition-colors hover:bg-brand-surface-3/50 hover:opacity-90">+ New Session Here</button> <div class="flex-shrink-0"><!></div></div>'),Ju=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),ef=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),tf=m('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),nf=m('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete">❓</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),rf=m('<button class="p-1 text-xs text-brand-text-muted transition-opacity hover:text-rose-400 focus:outline-none md:opacity-0 md:group-hover:opacity-100" title="Delete session">✕</button>'),sf=m('<div class="flex-shrink-0"><!></div>'),of=m('<div><a class="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"><!> <div class="min-w-0 flex-1"><div class="truncate text-xs text-brand-text"> </div> <div class="text-xs text-brand-text-muted"> </div></div> <!></a> <!></div>'),af=m('<div class="px-3 pb-2"><!> <!></div>'),lf=m('<div class="border-b border-brand-border/50"><button class="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50"><span>▶</span> <div class="min-w-0 flex-1"><div class="truncate text-sm font-medium text-brand-text"> </div> <div class="truncate text-[10px] text-brand-text-muted"> </div></div> <span class="text-xs text-brand-text-muted"> </span></button> <!></div>'),cf=m("<option> </option>"),df=m('<select id="model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"></select>'),uf=m('<input id="model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted"/>'),ff=m('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60" role="presentation"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-6" role="dialog" tabindex="-1"><h3 class="mb-4 text-sm font-bold text-brand-text">New Session</h3> <div class="mb-4"><span class="mb-1 block text-xs text-brand-text-muted">Folder</span> <div class="truncate rounded bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"> </div></div> <div class="mb-4"><label class="mb-1 block text-xs text-brand-text-muted" for="model-select">Model</label> <!></div> <div class="flex justify-end gap-2"><button class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Create</button></div></div></div>'),pf=m('<div class="absolute right-0 bottom-0 left-0 flex items-center justify-between border-t border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-rose-400"><span class="truncate"> </span> <button class="ml-2 flex-shrink-0 text-rose-300 hover:text-rose-200">✕</button></div>'),hf=m('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),bf=m('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),vf=m('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),mf=m('<div class="space-y-1"><div class="flex items-center gap-1.5"><input id="sidebar-modal-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="sidebar-modal-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),gf=m('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><h3 class="mb-2 text-sm font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-3 text-xs text-brand-text-muted">The folder <span class="font-mono text-[11px] break-all text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-4 flex flex-col gap-3"><div class="flex items-center gap-1.5"><input id="sidebar-modal-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="sidebar-modal-git-init" class="cursor-pointer text-xs text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2"><button type="button" class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),xf=m('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function Jo(n,e){lr(e,!0);const r=()=>$e(Nr,"$readOnlySessionFolders",R),s=()=>$e(Ar,"$sessionFolders",R),o=()=>$e(Yr,"$activeSessionInfo",R),a=()=>$e(Kr,"$isConnected",R),l=()=>$e(fs,"$isLoadingSession",R),c=()=>$e(ao,"$isResyncing",R),_=()=>$e(Er,"$availableModels",R),g=()=>$e(Zs,"$gitInitDefaultStore",R),x=()=>$e(oo,"$sessionError",R),[R,O]=Cr(),N=[];let S=br(e,"readOnly",3,!1),Y=V(()=>S()?r().folders:s().folders),ke=V(()=>S()?r().loading:s().loading);function J(){S()?la():Br()}let ue=V(()=>o().sessionFile),Le=V(a),_e=V(l),Ce=V(c),fe=V(()=>_().models),Me=Mn({}),Ie=G(Mn({})),St=G(null),ut=G(null),Ge=G(""),we=G(Mn([]));Pt(()=>{t(Le)&&(J(),S()||(sl(),al()))});function Tt(M,q,K){if(!K)return!0;const Z=K.toLowerCase();return(M.name||"").toLowerCase().includes(Z)||M.firstMessage.toLowerCase().includes(Z)||q.toLowerCase().includes(Z)}Pt(()=>{const M=t(Ge),q=t(Y);M?p(we,q.map(K=>({...K,sessions:K.sessions.filter(Z=>Tt(Z,K.name,M))})).filter(K=>K.sessions.length>0),!0):(p(we,q,!0),p(Ie,{},!0))});function qe(M){return t(Ge)?t(Ie)[M]!==void 0?t(Ie)[M]:!0:!!Me[M]}function Xe(M){t(Ge)?t(Ie)[M]=!qe(M):Me[M]=!qe(M)}async function yt(M){try{t(ue)===M&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Bs(M),t(St)===M&&p(St,null),Br()}catch(q){console.error("Failed to delete session:",q)}}async function rt(M){try{const q=M.sessions.map(K=>K.path);t(ue)&&q.includes(t(ue))&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Promise.all(M.sessions.map(K=>Bs(K.path))),t(ut)===M.path&&p(ut,null),Br()}catch(q){console.error("Failed to delete all sessions of folder:",q)}}function ft(M){t(ue)===M&&!t(_e)&&!t(Ce)||(mr(),ro(M))}let wt=G(!1),st=G(""),te=G(Mn([])),xt=G(!1),Ee=G(null),ot=G(null),At="",vt=G(""),Te=G(!1),an=G(null),ee=G(!0),ce=G("private"),A=G(!1),U=V(g);Pt(()=>{t(an)===null&&p(Te,t(U),!0)});let T=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),oe=V(()=>t(T).exists!==!0&&t(T).matchingRule&&t(ee)),z=null;async function me(M,q=!1){if(z&&clearTimeout(z),M===At&&!q)return;if(At=M,!M.trim()){p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Z=async()=>{const xe=await ss("");p(te,xe||[],!0)};q?await Z():z=setTimeout(Z,300);return}const K=async()=>{const[Z,xe]=await Promise.all([fa(M),ss(M)]);p(te,xe||[],!0),Z?(p(T,{exists:Z.exists,isGit:Z.isGit,resolvedPath:Z.resolvedPath,matchingRule:Z.matchingRule||null},!0),Z.exists||(p(Te,t(an)!==null?t(an):t(U),!0),p(ee,!0),Z.matchingRule&&p(ce,Z.matchingRule.visibility,!0))):p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};q?await K():z=setTimeout(K,300)}Pt(()=>{const M=t(st);me(M,!1)}),Pt(()=>{if(t(fe).length>0&&!t(vt)){const M=t(fe).find(q=>q.isDefault);M?p(vt,`${M.provider}:${M.modelId}`):p(vt,`${t(fe)[0].provider}:${t(fe)[0].modelId}`)}});function be(){if(t(st).trim())if(t(T).exists===!0)p(Te,!1),p(ee,!1),t(T).matchingRule&&p(ce,t(T).matchingRule.visibility,!0),p(A,!0);else{mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}}function ze(){p(A,!1),mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}let Ue=G(Mn({open:!1,folderPath:"",selected:""}));function at(M){const q=t(fe).find(K=>K.isDefault);p(Ue,{open:!0,folderPath:M,selected:q?`${q.provider}:${q.modelId}`:""},!0)}function pt(){t(Ue).open=!1}function Ne(){if(!t(Ue).open)return;mr();const M=t(Ue).folderPath,q=t(Ue).selected||void 0;pt(),t(ue)?(Dn(),setTimeout(()=>{jn(M,q)},100)):jn(M,q)}function Oe(M){const q=Date.now()-new Date(M).getTime(),K=Math.floor(q/6e4);if(K<1)return"just now";if(K<60)return`${K}m ago`;const Z=Math.floor(K/60);return Z<24?`${Z}h ago`:`${Math.floor(Z/24)}d ago`}function jt(M,q=40){return M.length>q?M.slice(0,q)+"...":M}var Vt=xf(),hn=Wt(Vt),bn=u(hn),Dt=u(bn),Et=u(Dt);nt(Et);var Ke=f(Et,2),en=u(Ke);d(Ke),d(Dt),d(bn);var Kt=f(bn,2),tn=u(Kt);{var Tn=M=>{var q=Vu(),K=u(q),Z=u(K),xe=u(Z,!0);d(Z),d(K);var qt=f(K,2);{var Ct=Ut=>{var It=qu(),Nt=u(It),Ft=f(u(Nt),2),zt=u(Ft);nt(zt),qn(zt,pe=>p(Ee,pe),()=>t(Ee));var ln=f(zt,2);{var $=pe=>{var se=Nu();_n(se,21,()=>t(te),Pn,(Se,v)=>{var w=Ou(),D=u(w,!0);d(w),H(()=>Q(D,t(v))),W("click",w,()=>{p(st,t(v),!0),me(t(v),!0),t(Ee)?.focus()}),h(Se,w)}),d(se),h(pe,se)};E(ln,pe=>{t(xt)&&t(te).length>0&&pe($)})}d(Ft),qn(Ft,pe=>p(ot,pe),()=>t(ot));var L=f(Ft,2);{var B=pe=>{var se=Uu(),Se=f(u(se));{var v=w=>{var D=Fu();h(w,D)};E(Se,w=>{t(T).isGit&&w(v)})}d(se),h(pe,se)};E(L,pe=>{t(T).exists===!0&&pe(B)})}d(Nt);var le=f(Nt,2),De=f(u(le),2);{var ve=pe=>{var se=Bu();_n(se,21,()=>t(fe),Pn,(Se,v)=>{var w=zu(),D=u(w);d(w);var P={};H(()=>{Q(D,`${t(v).label??""}${t(v).isDefault?" (default)":""}`),P!==(P=`${t(v).provider}:${t(v).modelId}`)&&(w.value=w.__value=`${t(v).provider}:${t(v).modelId}`)}),h(Se,w)}),d(se),Gr(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)},ae=pe=>{var se=Hu();nt(se),Ln(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)};E(De,pe=>{t(fe).length>0?pe(ve):pe(ae,-1)})}d(le);var Re=f(le,2);{var Pe=pe=>{var se=Gu(),Se=u(se),v=u(Se);nt(v);var w=f(v,2),D=u(w);d(w),d(Se);var P=f(Se,2);{var re=X=>{var k=Wu(),de=f(u(k),2),ye=u(de);nt(ye),ye.value=ye.__value="private",lt(),d(de);var Be=f(de,2),et=u(Be);nt(et),et.value=et.__value="public",lt(),d(Be),d(k),ar(N,[],ye,()=>t(ce),he=>p(ce,he)),ar(N,[],et,()=>t(ce),he=>p(ce,he)),h(X,k)};E(P,X=>{t(ee)&&X(re)})}d(se),H(()=>Q(D,`Create remote ${t(T).matchingRule.provider??""} repository`)),On(v,()=>t(ee),X=>p(ee,X)),h(pe,se)};E(Re,pe=>{t(T).exists!==!0&&t(T).matchingRule&&pe(Pe)})}var _t=f(Re,2);{var Bt=pe=>{var se=ju(),Se=u(se);nt(Se),lt(2),d(se),W("change",Se,v=>{p(an,v.currentTarget.checked,!0)}),On(Se,()=>t(Te),v=>p(Te,v)),h(pe,se)};E(_t,pe=>{t(T).exists!==!0&&(!t(T).matchingRule||!t(ee))&&pe(Bt)})}var bt=f(_t,2);d(It),H(pe=>{rn(zt,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(oe)?"border-emerald-500/80 bg-emerald-500/10 focus:border-emerald-400 focus:ring-1 focus:ring-emerald-400/30":"border-brand-border bg-brand-dark/60 focus:border-brand-blue"}`),bt.disabled=pe},[()=>!t(st).trim()]),ir("submit",It,pe=>{pe.preventDefault(),be()}),ir("focus",zt,()=>{p(xt,!0),me(t(st),!0)}),ir("blur",zt,pe=>{t(ot)&&t(ot).contains(pe.relatedTarget)||p(xt,!1)}),W("keydown",zt,pe=>{pe.key==="Escape"&&p(xt,!1)}),Ln(zt,()=>t(st),pe=>p(st,pe)),h(Ut,It)};E(qt,Ut=>{t(wt)&&Ut(Ct)})}d(q),H(()=>Q(xe,t(wt)?"▼ Close Create Session":"✚ Create New Session")),W("click",K,()=>p(wt,!t(wt))),h(M,q)};E(tn,M=>{S()||M(Tn)})}var ie=f(tn,2);{var it=M=>{var q=Ku();h(M,q)},Ot=M=>{var q=Yu(),K=u(q,!0);d(q),H(()=>Q(K,t(Ge)?"No sessions match your filter":"No sessions found")),h(M,q)},kt=M=>{var q=Zn(),K=Wt(q);_n(K,17,()=>t(we),Z=>Z.path,(Z,xe)=>{var qt=lf(),Ct=u(qt),Ut=u(Ct),It=f(Ut,2),Nt=u(It),Ft=u(Nt,!0);d(Nt);var zt=f(Nt,2),ln=u(zt,!0);d(zt),d(It);var $=f(It,2),L=u($,!0);d($),d(Ct);var B=f(Ct,2);{var le=ve=>{var ae=af(),Re=u(ae);{var Pe=Bt=>{var bt=Qu(),pe=u(bt),se=f(pe,2),Se=u(se);{var v=D=>{var P=Zu(),re=u(P),X=f(re,2);d(P),W("click",re,k=>{k.stopPropagation(),rt(t(xe))}),W("click",X,k=>{k.stopPropagation(),p(ut,null)}),h(D,P)},w=D=>{var P=Xu();W("click",P,re=>{re.stopPropagation(),p(ut,t(xe).path,!0)}),h(D,P)};E(Se,D=>{t(ut)===t(xe).path?D(v):D(w,-1)})}d(se),d(bt),W("click",pe,()=>at(t(xe).path)),h(Bt,bt)};E(Re,Bt=>{S()||Bt(Pe)})}var _t=f(Re,2);_n(_t,17,()=>t(xe).sessions,Bt=>Bt.path,(Bt,bt)=>{var pe=of(),se=u(pe),Se=u(se);{var v=he=>{var He=Ju();h(he,He)},w=he=>{var He=ef();h(he,He)};E(Se,he=>{t(bt).isActive?he(v):he(w,-1)})}var D=f(Se,2),P=u(D),re=u(P,!0);d(P);var X=f(P,2),k=u(X);d(X),d(D);var de=f(D,2);{var ye=he=>{var He=tf(),Zt=u(He,!0);d(He),H(()=>Q(Zt,t(bt).clientCount)),h(he,He)};E(de,he=>{t(bt).clientCount>0&&he(ye)})}d(se);var Be=f(se,2);{var et=he=>{var He=sf(),Zt=u(He);{var Xt=We=>{var Ye=nf(),Ve=u(Ye),gt=f(Ve,2);d(Ye),W("click",Ve,Rt=>{Rt.stopPropagation(),yt(t(bt).path)}),W("click",gt,Rt=>{Rt.stopPropagation(),p(St,null)}),h(We,Ye)},Ht=We=>{var Ye=rf();W("click",Ye,Ve=>{Ve.stopPropagation(),p(St,t(bt).path,!0)}),h(We,Ye)};E(Zt,We=>{t(St)===t(bt).path?We(Xt):We(Ht,-1)})}d(He),h(he,He)};E(Be,he=>{S()||he(et)})}d(pe),H((he,He,Zt)=>{rn(pe,1,`group flex w-full items-center gap-2 rounded px-2 py-1.5 text-left transition-colors hover:bg-brand-surface-3/30 ${t(ue)===t(bt).path?"bg-brand-surface-3":""}`),ge(se,"href",`#${he??""}`),Q(re,He),Q(k,`${Zt??""} · ${t(bt).messageCount??""}
|
|
85
85
|
msgs`)},[()=>encodeURIComponent(t(bt).id),()=>t(bt).name||jt(t(bt).firstMessage)||"Empty session",()=>Oe(t(bt).modified)]),W("click",se,he=>{he.button===0&&!he.ctrlKey&&!he.metaKey&&!he.altKey&&!he.shiftKey&&(he.preventDefault(),ft(t(bt).path))}),h(Bt,pe)}),d(ae),h(ve,ae)},De=V(()=>qe(t(xe).path));E(B,ve=>{t(De)&&ve(le)})}d(qt),H(ve=>{rn(Ut,1,`text-xs text-brand-text-muted transition-transform ${ve??""}`),Q(Ft,t(xe).name),Q(ln,t(xe).path),Q(L,t(xe).sessions.length)},[()=>qe(t(xe).path)?"rotate-90":""]),W("click",Ct,()=>Xe(t(xe).path)),h(Z,qt)}),h(M,q)};E(ie,M=>{t(ke)&&t(we).length===0?M(it):t(we).length===0?M(Ot,1):M(kt,-1)})}d(Kt),d(hn);var mt=f(hn,2);{var nn=M=>{var q=ff(),K=u(q),Z=f(u(K),2),xe=f(u(Z),2),qt=u(xe,!0);d(xe),d(Z);var Ct=f(Z,2),Ut=f(u(Ct),2);{var It=$=>{var L=df();_n(L,21,()=>t(fe),Pn,(B,le)=>{var De=cf(),ve=u(De);d(De);var ae={};H(()=>{Q(ve,`${t(le).label??""}${t(le).isDefault?" (default)":""}`),ae!==(ae=`${t(le).provider}:${t(le).modelId}`)&&(De.value=De.__value=`${t(le).provider}:${t(le).modelId}`)}),h(B,De)}),d(L),Gr(L,()=>t(Ue).selected,B=>t(Ue).selected=B),h($,L)},Nt=$=>{var L=uf();nt(L),Ln(L,()=>t(Ue).selected,B=>t(Ue).selected=B),h($,L)};E(Ut,$=>{t(fe).length>0?$(It):$(Nt,-1)})}d(Ct);var Ft=f(Ct,2),zt=u(Ft),ln=f(zt,2);d(Ft),d(K),d(q),H(()=>Q(qt,t(Ue).folderPath)),W("click",q,pt),W("click",K,$=>$.stopPropagation()),W("click",zt,pt),W("click",ln,Ne),h(M,q)};E(mt,M=>{t(Ue).open&&M(nn)})}var Yt=f(mt,2);{var yn=M=>{var q=pf(),K=u(q),Z=u(K,!0);d(K);var xe=f(K,2);d(q),H(()=>Q(Z,x())),W("click",xe,()=>mr()),h(M,q)};E(Yt,M=>{x()&&M(yn)})}var wn=f(Yt,2);{var Cn=M=>{var q=gf(),K=u(q),Z=f(u(K),2),xe=f(u(Z)),qt=u(xe,!0);d(xe),lt(),d(Z);var Ct=f(Z,2),Ut=u(Ct),It=u(Ut);nt(It);var Nt=f(It,2),Ft=f(u(Nt));{var zt=ve=>{var ae=hf();h(ve,ae)},ln=ve=>{var ae=bf();h(ve,ae)};E(Ft,ve=>{t(T).isGit?ve(zt):ve(ln,-1)})}d(Nt),d(Ut);var $=f(Ut,2);{var L=ve=>{var ae=mf(),Re=u(ae),Pe=u(Re);nt(Pe);var _t=f(Pe,2),Bt=u(_t);d(_t),d(Re);var bt=f(Re,2);{var pe=se=>{var Se=vf(),v=f(u(Se),2),w=u(v);nt(w),w.value=w.__value="private",lt(),d(v);var D=f(v,2),P=u(D);nt(P),P.value=P.__value="public",lt(),d(D),d(Se),ar(N,[],w,()=>t(ce),re=>p(ce,re)),ar(N,[],P,()=>t(ce),re=>p(ce,re)),h(se,Se)};E(bt,se=>{t(ee)&&se(pe)})}d(ae),H(()=>Q(Bt,`Create remote ${t(T).matchingRule.provider??""} repository`)),On(Pe,()=>t(ee),se=>p(ee,se)),h(ve,ae)};E($,ve=>{t(T).matchingRule&&ve(L)})}d(Ct);var B=f(Ct,2),le=u(B),De=f(le,2);d(B),d(K),d(q),H(()=>{Q(qt,t(st)),It.disabled=t(T).isGit}),On(It,()=>t(Te),ve=>p(Te,ve)),W("click",le,()=>p(A,!1)),W("click",De,ze),h(M,q)};E(wn,M=>{t(A)&&M(Cn)})}H(()=>{Ni(Et,t(Ge)),rn(en,1,Hi(t(ke)?"animate-spin":""))}),W("input",Et,M=>p(Ge,M.currentTarget.value,!0)),W("click",Ke,()=>J()),h(n,Vt),cr(),O()}xr(["input","click","keydown","change"]);var _f=m(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
|
|
86
86
|
stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function yf(n,e){lr(e,!0);const r=()=>$e(Na,"$sudoPrompt",s),[s,o]=Cr();let a=V(r),l=G(""),c=G(null),_=G(null);Pt(()=>{const Y=t(a)?.promptId??null;Y!==t(_)&&(p(_,Y,!0),p(l,""),Y&&queueMicrotask(()=>t(c)?.focus()))});function g(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function R(Y){Y.key==="Enter"?(Y.preventDefault(),g()):Y.key==="Escape"&&(Y.preventDefault(),x())}var O=Zn(),N=Wt(O);{var S=Y=>{var ke=_f(),J=u(ke),ue=f(u(J),4),Le=u(ue,!0);d(ue);var _e=f(ue,2);nt(_e),qn(_e,Ie=>p(c,Ie),()=>t(c));var Ce=f(_e,2),fe=u(Ce),Me=f(fe,2);d(Ce),d(J),d(ke),H(()=>Q(Le,t(a).command)),W("keydown",_e,R),Ln(_e,()=>t(l),Ie=>p(l,Ie)),W("click",fe,x),W("click",Me,g),h(Y,ke)};E(N,Y=>{t(a)&&Y(S)})}h(n,O),cr(),o()}xr(["keydown","click"]);function wf(n){return n.loading||n.resyncing||n.hasSessionHash}function kf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!wf(n)}var Sf=m('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),Tf=m('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),Af=m('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),Ef=m('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),Cf=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),If=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Rf=m('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),$f=m('<div class="mt-2 text-xs text-rose-400"> </div>'),Mf=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="View read-only sessions (e.g. autonomous agent fleets)"><span>👁️</span> <span>Read-only sessions</span> <span class="ml-auto">→</span></button>'),Df=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button>'),Pf=m('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted" title="App build version"> </span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Lf=m('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),Of=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Nf=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Ff=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Uf=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),zf=m('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),Bf=m("<option> </option>"),Hf=m('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Wf=m('<span class="truncate text-brand-text-muted"> </span>'),Gf=m('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),jf=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),qf=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Vf=m('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Kf=m('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),Yf=m('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Zf=m('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),Xf=m('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),Qf=m('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),Jf=m('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),ep=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),tp=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Preparing the session agent...</span></div>'),np=m("<!> <!>",1),rp=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),sp=m('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!></div> <!> <!></div>',1);function pp(n,e){lr(e,!0);const r=()=>$e(Kr,"$isConnected",J),s=()=>$e(ao,"$isResyncing",J),o=()=>$e(Ua,"$isAgentPending",J),a=()=>$e(fs,"$isLoadingSession",J),l=()=>$e(La,"$isInterrupted",J),c=()=>$e(oo,"$sessionError",J),_=()=>$e(Oa,"$sessionNotice",J),g=()=>$e(Pa,"$folderConflict",J),x=()=>$e(us,"$isReadOnly",J),R=()=>$e(Yr,"$activeSessionInfo",J),O=()=>$e(Lt,"$piState",J),N=()=>$e(Er,"$availableModels",J),S=()=>$e(Fa,"$isCreatingSession",J),Y=()=>$e(Xs,"$searchFolderStore",J),ke=()=>$e(ua,"$searchDefaultModelStore",J),[J,ue]=Cr();let Le=G(!1),_e=G("main"),Ce=G(!1),fe;qr(()=>{setTimeout(()=>vr(),200);const $=()=>{if(t(we)){const ve=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ve&&ve!==t(At)?ro(ve):!ve&&t(At)&&Dn()}};window.addEventListener("hashchange",$);let L=null;const B=8e3,le=()=>{if(document.visibilityState==="hidden"){if(xa())return;L&&clearTimeout(L),L=setTimeout(()=>{L=null,document.visibilityState==="hidden"&&t(we)&&ma()},B)}else no(),L&&(clearTimeout(L),L=null),t(we)||(Fs()?Ns():vr())},De=ve=>{L&&(clearTimeout(L),L=null),document.visibilityState!=="hidden"&&!t(we)&&(Fs()?Ns():vr())};return document.addEventListener("visibilitychange",le),window.addEventListener("pageshow",De),()=>{window.removeEventListener("hashchange",$),document.removeEventListener("visibilitychange",le),window.removeEventListener("pageshow",De),L&&clearTimeout(L)}});function Me(){vr()}function Ie(){Dn(),jr()}function St(){jr(),setTimeout(()=>vr(),100)}function ut(){Br()}function Ge(){typeof window<"u"&&(window.location.hash=""),Dn(),p(Le,!1)}let we=V(r),Tt=V(s),qe=V(o),Xe=V(a),yt=V(l),rt=V(c),ft=V(_),wt=V(g),st=V(x),te=V(R),xt=V(O),Ee=V(()=>N().models),ot=G(!1),At=V(()=>t(te).sessionId);Pt(()=>{typeof window<"u"&&t(we)&&(t(At)?(window.location.hash=encodeURIComponent(t(At)),p(ot,!0)):t(ot)&&(p(ot,!1),window.location.hash&&(window.location.hash="")))});let vt=null;Pt(()=>{if(!t(we)||typeof window>"u"||!window.location.hash)return;const $=decodeURIComponent(window.location.hash.slice(1));$&&(t(At)===$||t(Xe)||t(Tt)||vt||(vt=setTimeout(()=>{vt=null,!(t(At)===$||t(Xe)||t(Tt))&&ka($)},300)))}),Pt(()=>{t(we)||p(ot,!1)}),Pt(()=>{(t(At)||t(Xe)||t(Tt))&&p(Le,!1)});let Te=V(S),an=V(Y),ee=G(void 0),ce=V(()=>kf({connected:t(we),searchConfigured:!!t(an),hasSession:!!t(te).sessionFile,loading:t(Xe),resyncing:t(Tt),hasSessionHash:typeof window<"u"&&!!window.location.hash})),A=V(()=>t(Ee).map($=>({value:`${$.provider}:${$.modelId}`,label:`${$.label}${$.isDefault?" (default)":""}`}))),U=V(ke),T=G("");Pt(()=>{if(t(A).length===0||t(A).some(le=>le.value===t(T)))return;const L=t(A).find(le=>le.value===t(U)),B=t(Ee).find(le=>le.isDefault);p(T,L?L.value:B?`${B.provider}:${B.modelId}`:t(A)[0].value,!0)});let oe=G(!1);Pt(()=>{t(ce)&&!t(oe)&&t(ee)&&(p(oe,!0),t(ee).focusInput())});function z(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Dn(),t(ee)?.focusInput()}var me=sp(),be=Wt(me);Zi(be,{title:"Wherever",description:"Create & maintain apps from wherever"});var ze=f(be,2);{var Ue=$=>{var L=Sf();h($,L)};E(ze,$=>{t(Te)&&$(Ue)})}var at=f(ze,2),pt=u(at),Ne=u(pt),Oe=u(Ne),jt=u(Oe);{var Vt=$=>{var L=Tf(),B=f(Wt(L),2);W("click",B,()=>p(Ce,!1)),h($,L)},hn=$=>{var L=Af(),B=Wt(L),le=u(B);lt(2),d(B);var De=f(B,2),ve=u(De),ae=f(ve,2);d(De),H(Re=>ge(le,"src",Re),[()=>Tr("/logo.svg")]),W("click",B,Ge),W("click",ve,()=>p(Ce,!0)),W("click",ae,()=>p(Le,!1)),h($,L)};E(jt,$=>{t(Ce)?$(Vt):$(hn,-1)})}d(Oe),d(Ne);var bn=f(Ne,2);{var Dt=$=>{var L=Ef(),B=u(L);{let Pe=V(()=>(t(xt).connected,"localhost"));Tl(B,{get host(){return t(Pe)},port:31415,token:"",onConnected:Me})}var le=f(B,2),De=f(u(le),2),ve=u(De),ae=f(ve,2),Re=f(ae,2);d(De),d(le),d(L),W("click",ve,ut),W("click",ae,St),W("click",Re,Ie),h($,L)},Et=$=>{var L=Pf(),B=Wt(L),le=u(B),De=u(le),ve=f(De,2),ae=u(ve,!0);d(ve);var Re=f(ve,2),Pe=u(Re);d(Re),d(le);var _t=f(le,2);{var Bt=k=>{var de=Rf(),ye=u(de);{var Be=Xt=>{var Ht=Cf(),We=u(Ht);d(Ht),H(Ye=>{ge(Ht,"title",t(te).cwd),Q(We,`📁 ${Ye??""}`)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(Xt,Ht)};E(ye,Xt=>{t(te).cwd&&Xt(Be)})}var et=f(ye,2);{var he=Xt=>{var Ht=If(),We=u(Ht);d(Ht),H(()=>{ge(Ht,"title",t(te).model),Q(We,`🤖 ${t(te).model??""}`)}),h(Xt,Ht)};E(et,Xt=>{t(te).model&&Xt(he)})}var He=f(et,2),Zt=u(He);d(He),d(de),W("click",Zt,Ge),h(k,de)};E(_t,k=>{t(te).sessionFile&&k(Bt)})}var bt=f(_t,2);{var pe=k=>{var de=$f(),ye=u(de,!0);d(de),H(()=>Q(ye,t(xt).error)),h(k,de)};E(bt,k=>{t(xt).error&&!t(we)&&k(pe)})}d(B);var se=f(B,2),Se=u(se);{var v=k=>{var de=Mf();W("click",de,()=>{p(_e,"readonly"),la()}),h(k,de)},w=k=>{var de=Df();W("click",de,()=>p(_e,"main")),h(k,de)};E(Se,k=>{t(_e)==="main"?k(v):k(w,-1)})}d(se);var D=f(se,2),P=u(D);{var re=k=>{Jo(k,{readOnly:!0})},X=k=>{Jo(k,{})};E(P,k=>{t(_e)==="readonly"?k(re):k(X,-1)})}d(D),H(()=>{rn(De,1,`h-2.5 w-2.5 rounded-full ${t(we)?"bg-emerald-500":"bg-rose-500"}`),rn(ve,1,`text-sm ${t(we)?"text-emerald-400":"text-rose-400"}`),Q(ae,t(we)?"Connected":"Disconnected"),Q(Pe,`v${sa}`)}),h($,L)};E(bn,$=>{t(Ce)?$(Dt):$(Et,-1)})}d(pt);var Ke=f(pt,2),en=u(Ke),Kt=u(en),tn=f(Kt,2);{var Tn=$=>{var L=Lf();W("click",L,z),h($,L)};E(tn,$=>{t(we)&&t(an)&&t(te).sessionFile&&$(Tn)})}var ie=f(tn,2);{var it=$=>{var L=Uf(),B=u(L);{var le=ae=>{var Re=Of();h(ae,Re)},De=ae=>{var Re=Nf();h(ae,Re)},ve=ae=>{var Re=Ff();h(ae,Re)};E(B,ae=>{t(we)&&t(ce)?ae(le):t(we)?ae(De,1):ae(ve,-1)})}d(L),h($,L)};E(ie,$=>{(!t(we)||!t(te).sessionFile)&&$(it)})}var Ot=f(ie,2);{var kt=$=>{var L=jf(),B=u(L);{var le=ae=>{var Re=zf(),Pe=f(u(Re),2),_t=u(Pe,!0);d(Pe),d(Re),H(Bt=>{ge(Pe,"title",t(te).cwd),Q(_t,Bt)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(ae,Re)};E(B,ae=>{t(te).cwd&&ae(le)})}var De=f(B,2);{var ve=ae=>{var Re=Gf(),Pe=u(Re),_t=f(u(Pe),2);d(Pe);var Bt=f(Pe,2);{var bt=se=>{var Se=Hf();_n(Se,21,()=>t(Ee),Pn,(w,D)=>{var P=Bf(),re=u(P,!0);d(P);var X={};H(()=>{Q(re,t(D).label),X!==(X=`${t(D).provider}:${t(D).modelId}`)&&(P.value=P.__value=`${t(D).provider}:${t(D).modelId}`)}),h(w,P)}),d(Se);var v;aa(Se),H(()=>{v!==(v=t(te).model)&&(Se.value=(Se.__value=t(te).model)??"",Ys(Se,t(te).model))}),W("input",Se,w=>Ma(w.currentTarget.value)),h(se,Se)},pe=se=>{var Se=Wf(),v=u(Se,!0);d(Se),H(()=>{ge(Se,"title",t(te).model),Q(v,t(te).model)}),h(se,Se)};E(Bt,se=>{t(Ee).length>0&&!t(st)?se(bt):se(pe,-1)})}d(Re),H(()=>{rn(_t,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(xt).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),ge(_t,"title",t(xt).isStreaming?"Agent working...":"Ready")}),h(ae,Re)};E(De,ae=>{t(te).model&&ae(ve)})}d(L),h($,L)};E(Ot,$=>{t(te).sessionFile&&$(kt)})}var mt=f(Ot,2);{var nn=$=>{var L=qf();h($,L)};E(mt,$=>{t(st)&&$(nn)})}d(en);var Yt=f(en,2);{var yn=$=>{var L=Vf();h($,L)};E(Yt,$=>{t(yt)&&$(yn)})}var wn=f(Yt,2);{var Cn=$=>{var L=Kf(),B=u(L),le=u(B,!0);d(B);var De=f(B,2);d(L),H(()=>{rn(L,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(ft).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),Q(le,t(ft).message)}),W("click",De,()=>Ia()),h($,L)};E(wn,$=>{t(ft)&&$(Cn)})}var M=f(wn,2);{var q=$=>{var L=Zf(),B=u(L),le=f(u(B));{var De=Pe=>{var _t=xn("You are both working in it — changes may conflict.");h(Pe,_t)},ve=Pe=>{var _t=xn("You are observing (read-only) to avoid clashing.");h(Pe,_t)};E(le,Pe=>{t(wt).continued?Pe(De):Pe(ve,-1)})}d(B);var ae=f(B,2);{var Re=Pe=>{var _t=Yf();W("click",_t,()=>Aa()),h(Pe,_t)};E(ae,Pe=>{t(wt).continued||Pe(Re)})}d(L),h($,L)};E(M,$=>{t(wt)?.active&&$(q)})}var K=f(M,2);{var Z=$=>{var L=Xf(),B=u(L),le=u(B,!0);d(B);var De=f(B,2);d(L),H(()=>Q(le,t(rt))),W("click",De,()=>mr()),h($,L)};E(K,$=>{t(rt)&&$(Z)})}var xe=f(K,2);{var qt=$=>{var L=Qf();h($,L)};E(xe,$=>{t(st)&&!t(yt)&&$(qt)})}var Ct=f(xe,2);qn(du(Ct,{onMessageSent:()=>{}}),$=>fe=$,()=>fe);var Ut=f(Ct,2);{var It=$=>{var L=Jf();h($,L)},Nt=$=>{var L=np(),B=Wt(L);{var le=ae=>{var Re=ep();h(ae,Re)},De=ae=>{var Re=tp();h(ae,Re)};E(B,ae=>{t(te).sessionFile&&(t(Tt)||!t(we))?ae(le):t(te).sessionFile&&t(qe)&&ae(De,1)})}var ve=f(B,2);{let ae=V(()=>!!t(an)),Re=V(()=>t(ce)?!t(we):!t(we)||t(st)||!t(te).sessionFile||t(Tt)||t(qe));qn(Lu(ve,{get searchMode(){return t(ce)},get searchConfigured(){return t(ae)},get searchModels(){return t(A)},onSubmit:Pe=>Sa(Pe,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Re)},onSend:()=>fe?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Pe){p(T,Pe,!0)}}),Pe=>p(ee,Pe,!0),()=>t(ee))}h($,L)};E(Ut,$=>{t(st)&&t(te).sessionFile?$(It):$(Nt,-1)})}d(Ke);var Ft=f(Ke,2);yf(Ft,{});var zt=f(Ft,2);{var ln=$=>{var L=rp();W("click",L,()=>p(Le,!1)),h($,L)};E(zt,$=>{t(Le)&&$(ln)})}d(at),H(()=>rn(pt,1,`app-chrome ${t(Le)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),W("click",Kt,()=>p(Le,!t(Le))),h(n,me),cr(),ue()}xr(["click","input"]);export{pp as component,fp as universal};
|
|
87
|
-
//# sourceMappingURL=2.
|
|
87
|
+
//# sourceMappingURL=2.anOtZjZq.js.map
|