wherever-dev 0.8.3 → 0.8.4
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/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/_app/immutable/chunks/{CFZwc5OM.js → Bs6e_yNr.js} +2 -2
- package/public/_app/immutable/chunks/{CFZwc5OM.js.map → Bs6e_yNr.js.map} +1 -1
- package/public/_app/immutable/chunks/{Ddnp1HFv.js → C3dty8_c.js} +2 -2
- package/public/_app/immutable/chunks/{Ddnp1HFv.js.map → C3dty8_c.js.map} +1 -1
- package/public/_app/immutable/chunks/{BpNdwm2g.js → Dpm8IW62.js} +2 -2
- package/public/_app/immutable/chunks/{BpNdwm2g.js.map → Dpm8IW62.js.map} +1 -1
- package/public/_app/immutable/entry/{app.B0UlJ8C-.js → app.CfEYnTXR.js} +3 -3
- package/public/_app/immutable/entry/{app.B0UlJ8C-.js.map → app.CfEYnTXR.js.map} +1 -1
- package/public/_app/immutable/entry/start.DeP-d0TI.js +2 -0
- package/public/_app/immutable/entry/start.DeP-d0TI.js.map +1 -0
- package/public/_app/immutable/nodes/{0.Cvg2hYtP.js → 0.BvSvDXrg.js} +2 -2
- package/public/_app/immutable/nodes/{0.Cvg2hYtP.js.map → 0.BvSvDXrg.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.DLtAtyAb.js → 1.CWEPdQEw.js} +2 -2
- package/public/_app/immutable/nodes/{1.DLtAtyAb.js.map → 1.CWEPdQEw.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.riO6dO81.js → 2.D-h8cHh0.js} +2 -2
- package/public/_app/immutable/nodes/{2.riO6dO81.js.map → 2.D-h8cHh0.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.CmL4cMnM.js +0 -2
- package/public/_app/immutable/entry/start.CmL4cMnM.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ms,a as h,c as jn,g,d as dr,e as H,s as Z,f as cr,t as An}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as Sr,be as B,ap as yo,M as mi,aS as gi,aq as Ms,d as ta,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 wo,C as ko,aE as ls,a2 as ar,ac as Ci,az as Ii,aZ as Ri,ay as na,bd as ra,bf as $i,bg as Ks,aU as Ys,aQ as So,aP as er,aM as tr,af as Nt,b6 as f,ai as t,a5 as Mi,bh as K,$ as Di,bl as Nn,ah as Kn,a8 as zt,aK as qr,a_ as p,X as u,aV as d,aI as et,b9 as G,aO as Mn,bi as Dt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as _r,a as Me,p as vr}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as me,r as at,c as sa,e as gn,i as Pn,d as Ni}from"../chunks/Ddnp1HFv.js";import{_ as Fi,b as Vn}from"../chunks/ylfInSZr.js";import{v as oa}from"../chunks/BpNdwm2g.js";import{p as Ui}from"../chunks/CFZwc5OM.js";function To(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(Sr(_)))}B(()=>{var m=mi;if(c===(c=e()??"")){En&&yo();return}if(r&&!En){m.nodes=null,_.innerHTML=c,c!==""&&ms(Sr(_),_.lastChild);return}if(m.nodes!==null&&(gi(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(En){Ms.data;for(var x=yo(),I=x;x!==null&&(x.nodeType!==ta||x.data!=="");)I=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,I),l=rs(x);return}var P=s?wi:o?ki:void 0,O=yi(s?"svg":o?"math":"template",P);O.innerHTML=c;var k=s||o?O:O.content;if(ms(Sr(k),k.lastChild),s||o)for(;Sr(k);)l.before(Sr(k));else l.before(k)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=Sr(document.head);a!==null&&(a.nodeType!==ta||a.data!==n);)a=Ds(a);if(a===null)wo(!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&&(wo(!0),rs(r))}}function aa(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=aa(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=aa(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 Jt(n,e,r,s,o,a){var l=n[ko];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[ko]=r}return a}function Zs(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(na(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function ia(n){var e=new MutationObserver(()=>{Zs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ra(()=>{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,ar!==null&&s.add(ar)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=ar;if(s.has(l))return}if(Zs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),ia(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),ar!==null&&s.add(ar),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;l===c&&c===_&&m>_?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=l,n.selectionEnd=Math.min(c,m))}}}),(En&&n.defaultValue!==n.value||Ks(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),ar!==null&&s.add(ar)),Ys(()=>{var o=e();if(n===document.activeElement){var a=ar;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 lr(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 m=r.__value;a&&(m=Ao(l,m,r.checked)),o(m)},()=>o(a?[]:null)),Ys(()=>{var m=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=na(r.__value,m)}),ra(()=>{var m=l.indexOf(r);m!==-1&&l.splice(m,1)}),gs.has(l)||(gs.add(l),So(()=>{l.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),So(()=>{if(c){var m;if(a)m=Ao(l,m,r.checked);else{var x=l.find(I=>I.checked);m=x?.__value}o(m)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Ks(e)==null)&&r(n.checked),Ys(()=>{var s=e();n.checked=!!s})}function Ao(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 Ar(n,e){return Oi(n)}var Yi=g('<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){er(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=K(()=>e.home||!1),a=K(()=>({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(),_=Nt(c),m=f(_,2),x=f(m,2);{var I=He=>{var lt=jn(),kt=Nt(lt);E(kt,tt=>{}),h(He,lt)};E(x,He=>{t(o)&&He(I)})}var P=f(x,2),O=f(P,2),k=f(O,2),q=f(k,2),te=f(q,2),de=f(te,4),re=f(de,2),je=f(re,2),_e=f(je,2),$e=f(_e,2),fe=f($e,2),Le=f(fe,2),Ee=f(Le,2),Et=f(Ee,2),it=f(Et,4),ue=f(it,4),Ve=f(ue,2),Bt=f(Ve,2);B((He,lt,kt,tt)=>{me(_,"content",t(a).title),me(m,"content",t(a).description),me(P,"content",t(a).type),me(O,"content",t(a).url),me(k,"content",t(a).title),me(q,"content",t(a).description),me(te,"content",t(a).image),me(de,"content",t(a).url),me(re,"content",t(a).title),me(je,"content",t(a).description),me(_e,"content",t(a).image),me($e,"href",He),me(fe,"href",lt),me(Le,"href",kt),me(Ee,"href",tt),me(Et,"content",Vi),me(it,"content",ys),me(ue,"content",Ki),me(Ve,"content",ys),me(Bt,"content",oa)},[()=>Ar("/pwa/favicon.png"),()=>Ar("/pwa/favicon.ico"),()=>Ar("/pwa/apple-touch-icon.png"),()=>Ar("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),tr()}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 Eo(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 Co=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Co.get(n);e||(e=new Audio(n),e.preload="auto",Co.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 la(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Eo(e,1046.5,r,.16,.12),Eo(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 Vt(n){let e;return el(n,r=>e=r)(),e}var wr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!wr.length;for(const m of s)m[1](),wr.push(m,n);if(_){for(let m=0;m<wr.length;m+=2)wr[m][0](wr[m+1]);wr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const m=[c,_];return s.add(m),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(m),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,conflict: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(O=>r?{...O,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(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,m=()=>{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(de=>({...de,connected:!0,connecting:!1,error:null}));const O=Vt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,te=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(de=>de.resyncing?de:{...de,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:q,model:te}),this.armLoadWatchdog()):this.stateStore.update(de=>de.resyncing?{...de,resyncing:!1}:de)},x=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),q=JSON.parse(k);this.handleMessage(q)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},I=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},P=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",m),_.addEventListener("message",x),_.addEventListener("close",I),_.addEventListener("error",P)):typeof _.on=="function"&&(_.on("open",m),_.on("message",O=>x({data:O})),_.on("close",I),_.on("error",P))}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=Vt(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=Vt(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||Vt(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=Vt(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=Vt(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,Vt(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=!!Vt(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_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":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 Vt(this.stateStore);const c=[...o].reverse().find(m=>m.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 jn,g,d as dr,e as H,s as Z,f as cr,t as An}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as Sr,be as B,ap as yo,M as mi,aS as gi,aq as Ms,d as ta,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 wo,C as ko,aE as ls,a2 as ar,ac as Ci,az as Ii,aZ as Ri,ay as na,bd as ra,bf as $i,bg as Ks,aU as Ys,aQ as So,aP as er,aM as tr,af as Nt,b6 as f,ai as t,a5 as Mi,bh as K,$ as Di,bl as Nn,ah as Kn,a8 as zt,aK as qr,a_ as p,X as u,aV as d,aI as et,b9 as G,aO as Mn,bi as Dt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as _r,a as Me,p as vr}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as me,r as at,c as sa,e as gn,i as Pn,d as Ni}from"../chunks/C3dty8_c.js";import{_ as Fi,b as Vn}from"../chunks/ylfInSZr.js";import{v as oa}from"../chunks/Dpm8IW62.js";import{p as Ui}from"../chunks/Bs6e_yNr.js";function To(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(Sr(_)))}B(()=>{var m=mi;if(c===(c=e()??"")){En&&yo();return}if(r&&!En){m.nodes=null,_.innerHTML=c,c!==""&&ms(Sr(_),_.lastChild);return}if(m.nodes!==null&&(gi(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(En){Ms.data;for(var x=yo(),I=x;x!==null&&(x.nodeType!==ta||x.data!=="");)I=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,I),l=rs(x);return}var P=s?wi:o?ki:void 0,O=yi(s?"svg":o?"math":"template",P);O.innerHTML=c;var k=s||o?O:O.content;if(ms(Sr(k),k.lastChild),s||o)for(;Sr(k);)l.before(Sr(k));else l.before(k)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=Sr(document.head);a!==null&&(a.nodeType!==ta||a.data!==n);)a=Ds(a);if(a===null)wo(!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&&(wo(!0),rs(r))}}function aa(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=aa(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=aa(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 Jt(n,e,r,s,o,a){var l=n[ko];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[ko]=r}return a}function Zs(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(na(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function ia(n){var e=new MutationObserver(()=>{Zs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ra(()=>{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,ar!==null&&s.add(ar)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=ar;if(s.has(l))return}if(Zs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),ia(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),ar!==null&&s.add(ar),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;l===c&&c===_&&m>_?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=l,n.selectionEnd=Math.min(c,m))}}}),(En&&n.defaultValue!==n.value||Ks(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),ar!==null&&s.add(ar)),Ys(()=>{var o=e();if(n===document.activeElement){var a=ar;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 lr(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 m=r.__value;a&&(m=Ao(l,m,r.checked)),o(m)},()=>o(a?[]:null)),Ys(()=>{var m=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=na(r.__value,m)}),ra(()=>{var m=l.indexOf(r);m!==-1&&l.splice(m,1)}),gs.has(l)||(gs.add(l),So(()=>{l.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),So(()=>{if(c){var m;if(a)m=Ao(l,m,r.checked);else{var x=l.find(I=>I.checked);m=x?.__value}o(m)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Ks(e)==null)&&r(n.checked),Ys(()=>{var s=e();n.checked=!!s})}function Ao(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 Ar(n,e){return Oi(n)}var Yi=g('<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){er(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=K(()=>e.home||!1),a=K(()=>({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(),_=Nt(c),m=f(_,2),x=f(m,2);{var I=He=>{var lt=jn(),kt=Nt(lt);E(kt,tt=>{}),h(He,lt)};E(x,He=>{t(o)&&He(I)})}var P=f(x,2),O=f(P,2),k=f(O,2),q=f(k,2),te=f(q,2),de=f(te,4),re=f(de,2),je=f(re,2),_e=f(je,2),$e=f(_e,2),fe=f($e,2),Le=f(fe,2),Ee=f(Le,2),Et=f(Ee,2),it=f(Et,4),ue=f(it,4),Ve=f(ue,2),Bt=f(Ve,2);B((He,lt,kt,tt)=>{me(_,"content",t(a).title),me(m,"content",t(a).description),me(P,"content",t(a).type),me(O,"content",t(a).url),me(k,"content",t(a).title),me(q,"content",t(a).description),me(te,"content",t(a).image),me(de,"content",t(a).url),me(re,"content",t(a).title),me(je,"content",t(a).description),me(_e,"content",t(a).image),me($e,"href",He),me(fe,"href",lt),me(Le,"href",kt),me(Ee,"href",tt),me(Et,"content",Vi),me(it,"content",ys),me(ue,"content",Ki),me(Ve,"content",ys),me(Bt,"content",oa)},[()=>Ar("/pwa/favicon.png"),()=>Ar("/pwa/favicon.ico"),()=>Ar("/pwa/apple-touch-icon.png"),()=>Ar("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),tr()}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 Eo(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 Co=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Co.get(n);e||(e=new Audio(n),e.preload="auto",Co.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 la(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Eo(e,1046.5,r,.16,.12),Eo(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 Vt(n){let e;return el(n,r=>e=r)(),e}var wr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!wr.length;for(const m of s)m[1](),wr.push(m,n);if(_){for(let m=0;m<wr.length;m+=2)wr[m][0](wr[m+1]);wr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const m=[c,_];return s.add(m),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(m),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,conflict: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(O=>r?{...O,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(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,m=()=>{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(de=>({...de,connected:!0,connecting:!1,error:null}));const O=Vt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,te=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(de=>de.resyncing?de:{...de,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:q,model:te}),this.armLoadWatchdog()):this.stateStore.update(de=>de.resyncing?{...de,resyncing:!1}:de)},x=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),q=JSON.parse(k);this.handleMessage(q)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},I=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},P=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",m),_.addEventListener("message",x),_.addEventListener("close",I),_.addEventListener("error",P)):typeof _.on=="function"&&(_.on("open",m),_.on("message",O=>x({data:O})),_.on("close",I),_.on("error",P))}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=Vt(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=Vt(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||Vt(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=Vt(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=Vt(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,Vt(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=!!Vt(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_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":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 Vt(this.stateStore);const c=[...o].reverse().find(m=>m.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:")),m=Date.now();if(_){const x=a?"Error: ":"";return{...c,messages:c.messages.map(I=>I.id===_.id?{...I,content:`${x}${I.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:m}:I)}}else{const x=a?`Tool error: ${e.toolName}
|
|
@@ -86,4 +86,4 @@ ${ae}`}}if(J.startsWith("/")&&t(re).length===0){const A=J.toLowerCase();if(A==="
|
|
|
86
86
|
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
87
87
|
and gain control.</p></div></div>`);function yf(n,e){er(e,!0);const r=()=>Me(Pa,"$conflict",s),[s,o]=_r();let a=K(r);var l=jn(),c=Nt(l);{var _=m=>{var x=_f(),I=u(x),P=f(u(I),2),O=f(u(P)),k=u(O,!0);d(O),et(),d(P);var q=f(P,2),te=u(q),de=f(te,2);d(q),et(2),d(I),d(x),B(()=>Z(k,t(a).conflictingCwd)),H("click",te,()=>zs("read_only")),H("click",de,()=>zs("take_over")),h(m,x)};E(c,m=>{t(a)&&m(_)})}h(n,l),tr(),o()}dr(["click"]);var wf=g(`<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
|
|
88
88
|
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 kf(n,e){er(e,!0);const r=()=>Me(Na,"$sudoPrompt",s),[s,o]=_r();let a=K(r),l=G(""),c=G(null),_=G(null);Dt(()=>{const q=t(a)?.promptId??null;q!==t(_)&&(p(_,q,!0),p(l,""),q&&queueMicrotask(()=>t(c)?.focus()))});function m(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function I(q){q.key==="Enter"?(q.preventDefault(),m()):q.key==="Escape"&&(q.preventDefault(),x())}var P=jn(),O=Nt(P);{var k=q=>{var te=wf(),de=u(te),re=f(u(de),4),je=u(re,!0);d(re);var _e=f(re,2);at(_e),Vn(_e,Ee=>p(c,Ee),()=>t(c));var $e=f(_e,2),fe=u($e),Le=f(fe,2);d($e),d(de),d(te),B(()=>Z(je,t(a).command)),H("keydown",_e,I),Ln(_e,()=>t(l),Ee=>p(l,Ee)),H("click",fe,x),H("click",Le,m),h(q,te)};E(O,q=>{t(a)&&q(k)})}h(n,P),tr(),o()}dr(["keydown","click"]);function Sf(n){return n.loading||n.resyncing||n.hasSessionHash}function Tf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!Sf(n)}var Af=g('<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>'),Ef=g('<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),Cf=g('<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),If=g('<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>'),Rf=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),$f=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),Mf=g('<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>'),Df=g('<div class="mt-2 text-xs text-rose-400"> </div>'),Pf=g('<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>'),Lf=g('<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>'),Of=g('<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),Nf=g('<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>'),Ff=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Uf=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),zf=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),Bf=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),Hf=g('<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>'),Wf=g("<option> </option>"),Gf=g('<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>'),jf=g('<span class="truncate text-brand-text-muted"> </span>'),qf=g('<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>'),Vf=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Kf=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Yf=g('<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>'),Zf=g('<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>'),Xf=g('<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=g('<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=g('<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=g('<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=g('<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=g("<!> <!>",1),rp=g('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),sp=g('<!> <!> <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){er(e,!0);const r=()=>Me(Kr,"$isConnected",te),s=()=>Me(io,"$isResyncing",te),o=()=>Me(Ua,"$isAgentPending",te),a=()=>Me(fs,"$isLoadingSession",te),l=()=>Me(La,"$isInterrupted",te),c=()=>Me(ao,"$sessionError",te),_=()=>Me(Oa,"$sessionNotice",te),m=()=>Me(us,"$isReadOnly",te),x=()=>Me(Yr,"$activeSessionInfo",te),I=()=>Me(Pt,"$piState",te),P=()=>Me(Cr,"$availableModels",te),O=()=>Me(Fa,"$isCreatingSession",te),k=()=>Me(Qs,"$searchFolderStore",te),q=()=>Me(fa,"$searchDefaultModelStore",te),[te,de]=_r();let re=G(!1),je=G("main"),_e=G(!1),$e;qr(()=>{setTimeout(()=>mr(),200);const M=()=>{if(t(ue)){const ne=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ne&&ne!==t(we)?so(ne):!ne&&t(we)&&Dn()}};window.addEventListener("hashchange",M);let N=null;const ve=8e3,ke=()=>{if(document.visibilityState==="hidden"){if(_a())return;N&&clearTimeout(N),N=setTimeout(()=>{N=null,document.visibilityState==="hidden"&&t(ue)&&ga()},ve)}else ro(),N&&(clearTimeout(N),N=null),t(ue)||(Fs()?Ns():mr())},Pe=ne=>{N&&(clearTimeout(N),N=null),document.visibilityState!=="hidden"&&!t(ue)&&(Fs()?Ns():mr())};return document.addEventListener("visibilitychange",ke),window.addEventListener("pageshow",Pe),()=>{window.removeEventListener("hashchange",M),document.removeEventListener("visibilitychange",ke),window.removeEventListener("pageshow",Pe),N&&clearTimeout(N)}});function fe(){mr()}function Le(){Dn(),jr()}function Ee(){jr(),setTimeout(()=>mr(),100)}function Et(){Br()}function it(){typeof window<"u"&&(window.location.hash=""),Dn(),p(re,!1)}let ue=K(r),Ve=K(s),Bt=K(o),He=K(a),lt=K(l),kt=K(c),tt=K(_),nt=K(m),ge=K(x),ct=K(I),De=K(()=>P().models),St=G(!1),we=K(()=>t(ge).sessionId);Dt(()=>{typeof window<"u"&&t(ue)&&(t(we)?(window.location.hash=encodeURIComponent(t(we)),p(St,!0)):t(St)&&(p(St,!1),window.location.hash&&(window.location.hash="")))});let ht=null;Dt(()=>{if(!t(ue)||typeof window>"u"||!window.location.hash)return;const M=decodeURIComponent(window.location.hash.slice(1));M&&(t(we)===M||t(He)||t(Ve)||ht||(ht=setTimeout(()=>{ht=null,!(t(we)===M||t(He)||t(Ve))&&Sa(M)},300)))}),Dt(()=>{t(ue)||p(St,!1)}),Dt(()=>{(t(we)||t(He)||t(Ve))&&p(re,!1)});let Yt=K(O),gt=K(k),xe=G(void 0),en=K(()=>Tf({connected:t(ue),searchConfigured:!!t(gt),hasSession:!!t(ge).sessionFile,loading:t(He),resyncing:t(Ve),hasSessionHash:typeof window<"u"&&!!window.location.hash})),J=K(()=>t(De).map(M=>({value:`${M.provider}:${M.modelId}`,label:`${M.label}${M.isDefault?" (default)":""}`}))),pe=K(q),T=G("");Dt(()=>{if(t(J).length===0||t(J).some(ke=>ke.value===t(T)))return;const N=t(J).find(ke=>ke.value===t(pe)),ve=t(De).find(ke=>ke.isDefault);p(T,N?N.value:ve?`${ve.provider}:${ve.modelId}`:t(J)[0].value,!0)});let F=G(!1);Dt(()=>{t(en)&&!t(F)&&t(xe)&&(p(F,!0),t(xe).focusInput())});function A(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Dn(),t(xe)?.focusInput()}var ae=sp(),z=Nt(ae);Zi(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var be=f(z,2);{var he=M=>{var N=Af();h(M,N)};E(be,M=>{t(Yt)&&M(he)})}var We=f(be,2),Oe=u(We),rt=u(Oe),xt=u(rt),Ge=u(xt);{var Ue=M=>{var N=Ef(),ve=f(Nt(N),2);H("click",ve,()=>p(_e,!1)),h(M,N)},Ht=M=>{var N=Cf(),ve=Nt(N),ke=u(ve);et(2),d(ve);var Pe=f(ve,2),ne=u(Pe),se=f(ne,2);d(Pe),B(Ce=>me(ke,"src",Ce),[()=>Ar("/logo.svg")]),H("click",ve,it),H("click",ne,()=>p(_e,!0)),H("click",se,()=>p(re,!1)),h(M,N)};E(Ge,M=>{t(_e)?M(Ue):M(Ht,-1)})}d(xt),d(rt);var Gt=f(rt,2);{var fn=M=>{var N=If(),ve=u(N);{let Se=K(()=>(t(ct).connected,"localhost"));Tl(ve,{get host(){return t(Se)},port:31415,token:"",onConnected:fe})}var ke=f(ve,2),Pe=f(u(ke),2),ne=u(Pe),se=f(ne,2),Ce=f(se,2);d(Pe),d(ke),d(N),H("click",ne,Et),H("click",se,Ee),H("click",Ce,Le),h(M,N)},pn=M=>{var N=Of(),ve=Nt(N),ke=u(ve),Pe=u(ke),ne=f(Pe,2),se=u(ne,!0);d(ne);var Ce=f(ne,2),Se=u(Ce);d(Ce),d(ke);var bt=f(ke,2);{var qt=$=>{var W=Mf(),Q=u(W);{var S=oe=>{var Re=Rf(),Ut=u(Re);d(Re),B(vn=>{me(Re,"title",t(ge).cwd),Z(Ut,`📁 ${vn??""}`)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(oe,Re)};E(Q,oe=>{t(ge).cwd&&oe(S)})}var Ie=f(Q,2);{var Te=oe=>{var Re=$f(),Ut=u(Re);d(Re),B(()=>{me(Re,"title",t(ge).model),Z(Ut,`🤖 ${t(ge).model??""}`)}),h(oe,Re)};E(Ie,oe=>{t(ge).model&&oe(Te)})}var Be=f(Ie,2),ut=u(Be);d(Be),d(W),H("click",ut,it),h($,W)};E(bt,$=>{t(ge).sessionFile&&$(qt)})}var cn=f(bt,2);{var dn=$=>{var W=Df(),Q=u(W,!0);d(W),B(()=>Z(Q,t(ct).error)),h($,W)};E(cn,$=>{t(ct).error&&!t(ue)&&$(dn)})}d(ve);var wt=f(ve,2),Ne=u(wt);{var ie=$=>{var W=Pf();H("click",W,()=>{p(je,"readonly"),ca()}),h($,W)},ce=$=>{var W=Lf();H("click",W,()=>p(je,"main")),h($,W)};E(Ne,$=>{t(je)==="main"?$(ie):$(ce,-1)})}d(wt);var Fe=f(wt,2),b=u(Fe);{var w=$=>{ea($,{readOnly:!0})},L=$=>{ea($,{})};E(b,$=>{t(je)==="readonly"?$(w):$(L,-1)})}d(Fe),B(()=>{Jt(Pe,1,`h-2.5 w-2.5 rounded-full ${t(ue)?"bg-emerald-500":"bg-rose-500"}`),Jt(ne,1,`text-sm ${t(ue)?"text-emerald-400":"text-rose-400"}`),Z(se,t(ue)?"Connected":"Disconnected"),Z(Se,`v${oa}`)}),h(M,N)};E(Gt,M=>{t(_e)?M(fn):M(pn,-1)})}d(Oe);var Tt=f(Oe,2),yt=u(Tt),Ze=u(yt),tn=f(Ze,2);{var Zt=M=>{var N=Nf();H("click",N,A),h(M,N)};E(tn,M=>{t(ue)&&t(gt)&&t(ge).sessionFile&&M(Zt)})}var Xt=f(tn,2);{var kn=M=>{var N=Bf(),ve=u(N);{var ke=se=>{var Ce=Ff();h(se,Ce)},Pe=se=>{var Ce=Uf();h(se,Ce)},ne=se=>{var Ce=zf();h(se,Ce)};E(ve,se=>{t(ue)&&t(en)?se(ke):t(ue)?se(Pe,1):se(ne,-1)})}d(N),h(M,N)};E(Xt,M=>{(!t(ue)||!t(ge).sessionFile)&&M(kn)})}var le=f(Xt,2);{var dt=M=>{var N=Vf(),ve=u(N);{var ke=se=>{var Ce=Hf(),Se=f(u(Ce),2),bt=u(Se,!0);d(Se),d(Ce),B(qt=>{me(Se,"title",t(ge).cwd),Z(bt,qt)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(se,Ce)};E(ve,se=>{t(ge).cwd&&se(ke)})}var Pe=f(ve,2);{var ne=se=>{var Ce=qf(),Se=u(Ce),bt=f(u(Se),2);d(Se);var qt=f(Se,2);{var cn=wt=>{var Ne=Gf();gn(Ne,21,()=>t(De),Pn,(ce,Fe)=>{var b=Wf(),w=u(b,!0);d(b);var L={};B(()=>{Z(w,t(Fe).label),L!==(L=`${t(Fe).provider}:${t(Fe).modelId}`)&&(b.value=b.__value=`${t(Fe).provider}:${t(Fe).modelId}`)}),h(ce,b)}),d(Ne);var ie;ia(Ne),B(()=>{ie!==(ie=t(ge).model)&&(Ne.value=(Ne.__value=t(ge).model)??"",Zs(Ne,t(ge).model))}),H("input",Ne,ce=>Ma(ce.currentTarget.value)),h(wt,Ne)},dn=wt=>{var Ne=jf(),ie=u(Ne,!0);d(Ne),B(()=>{me(Ne,"title",t(ge).model),Z(ie,t(ge).model)}),h(wt,Ne)};E(qt,wt=>{t(De).length>0&&!t(nt)?wt(cn):wt(dn,-1)})}d(Ce),B(()=>{Jt(bt,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ct).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),me(bt,"title",t(ct).isStreaming?"Agent working...":"Ready")}),h(se,Ce)};E(Pe,se=>{t(ge).model&&se(ne)})}d(N),h(M,N)};E(le,M=>{t(ge).sessionFile&&M(dt)})}var Ft=f(le,2);{var At=M=>{var N=Kf();h(M,N)};E(Ft,M=>{t(nt)&&M(At)})}d(yt);var mt=f(yt,2);{var Qt=M=>{var N=Yf();h(M,N)};E(mt,M=>{t(lt)&&M(Qt)})}var jt=f(mt,2);{var xn=M=>{var N=Zf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>{Jt(N,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(tt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),Z(ke,t(tt).message)}),H("click",Pe,()=>Ia()),h(M,N)};E(jt,M=>{t(tt)&&M(xn)})}var _n=f(jt,2);{var Cn=M=>{var N=Xf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>Z(ke,t(kt))),H("click",Pe,()=>gr()),h(M,N)};E(_n,M=>{t(kt)&&M(Cn)})}var D=f(_n,2);{var V=M=>{var N=Qf();h(M,N)};E(D,M=>{t(nt)&&!t(lt)&&M(V)})}var Y=f(D,2);Vn(du(Y,{onMessageSent:()=>{}}),M=>$e=M,()=>$e);var X=f(Y,2);{var ye=M=>{var N=Jf();h(M,N)},Wt=M=>{var N=np(),ve=Nt(N);{var ke=se=>{var Ce=ep();h(se,Ce)},Pe=se=>{var Ce=tp();h(se,Ce)};E(ve,se=>{t(ge).sessionFile&&(t(Ve)||!t(ue))?se(ke):t(ge).sessionFile&&t(Bt)&&se(Pe,1)})}var ne=f(ve,2);{let se=K(()=>!!t(gt)),Ce=K(()=>t(en)?!t(ue):!t(ue)||t(nt)||!t(ge).sessionFile||t(Ve)||t(Bt));Vn(Lu(ne,{get searchMode(){return t(en)},get searchConfigured(){return t(se)},get searchModels(){return t(J)},onSubmit:Se=>Ta(Se,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Ce)},onSend:()=>$e?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Se){p(T,Se,!0)}}),Se=>p(xe,Se,!0),()=>t(xe))}h(M,N)};E(X,M=>{t(nt)&&t(ge).sessionFile?M(ye):M(Wt,-1)})}d(Tt);var Ct=f(Tt,2);yf(Ct,{});var Lt=f(Ct,2);kf(Lt,{});var It=f(Lt,2);{var Ot=M=>{var N=rp();H("click",N,()=>p(re,!1)),h(M,N)};E(It,M=>{t(re)&&M(Ot)})}d(We),B(()=>Jt(Oe,1,`app-chrome ${t(re)?"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`)),H("click",Ze,()=>p(re,!t(re))),h(n,ae),tr(),de()}dr(["click","input"]);export{pp as component,fp as universal};
|
|
89
|
-
//# sourceMappingURL=2.
|
|
89
|
+
//# sourceMappingURL=2.D-h8cHh0.js.map
|