wherever-dev 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/install.d.ts +15 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +408 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/index.js +46 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/_app/immutable/chunks/{1b86Y8Q5.js → CknLe1TD.js} +2 -2
- package/public/_app/immutable/chunks/{1b86Y8Q5.js.map → CknLe1TD.js.map} +1 -1
- package/public/_app/immutable/chunks/DCwWdFrO.js +2 -0
- package/public/_app/immutable/chunks/{C-2x_D2r.js.map → DCwWdFrO.js.map} +1 -1
- package/public/_app/immutable/chunks/{BHw0aQqy.js → Og-aeqCF.js} +2 -2
- package/public/_app/immutable/chunks/{BHw0aQqy.js.map → Og-aeqCF.js.map} +1 -1
- package/public/_app/immutable/entry/{app.jio5QHd-.js → app.C6EOUirZ.js} +3 -3
- package/public/_app/immutable/entry/{app.jio5QHd-.js.map → app.C6EOUirZ.js.map} +1 -1
- package/public/_app/immutable/entry/start.CSQpAATl.js +2 -0
- package/public/_app/immutable/entry/start.CSQpAATl.js.map +1 -0
- package/public/_app/immutable/nodes/{0.Cd64tYxm.js → 0.P3FLhJCy.js} +2 -2
- package/public/_app/immutable/nodes/{0.Cd64tYxm.js.map → 0.P3FLhJCy.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.9ATbmG_V.js → 1.BQc6rQUU.js} +2 -2
- package/public/_app/immutable/nodes/{1.9ATbmG_V.js.map → 1.BQc6rQUU.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.BOzG3qzK.js → 2.Do9j-h4_.js} +2 -2
- package/public/_app/immutable/nodes/{2.BOzG3qzK.js.map → 2.Do9j-h4_.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/chunks/C-2x_D2r.js +0 -2
- package/public/_app/immutable/entry/start.Bpsf189h.js +0 -2
- package/public/_app/immutable/entry/start.Bpsf189h.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ns,a as h,c as dr,g as m,d as tr,e as B,f as qn,s as re,t as _n}from"../chunks/vMsF8lo6.js";import{ar as yn,b2 as Wr,al as ir,be as H,ap as eo,M as Ua,aS as za,aq as bs,d as Oo,am as vs,at as Ba,n as Ha,a0 as Wa,u as Ga,t as ja,a1 as qa,V as Va,W as Ka,H as Ya,b3 as to,C as no,aE as Kr,a2 as Wn,ac as Za,az as Xa,aZ as Qa,ay as Do,bd as Lo,bf as Ja,bg as $s,aU as Ms,aQ as ro,aP as Vn,aM as Kn,af as Zt,b6 as f,ai as t,a5 as ei,bh as Q,$ as ti,bl as An,ah as Fn,a8 as jt,aK as Mr,a_ as p,X as u,aV as d,aI as dt,b9 as V,aO as wn,bi as Lt,bj as ni,aT as ri}from"../chunks/CEg8tgYI.js";import{i as E,s as pr,a as Ue,p as Xn}from"../chunks/MtE7VtNZ.js";import{a as si,b as Fe,r as it,c as Po,e as gn,i as Sn,d as oi}from"../chunks/BHw0aQqy.js";import{_ as ai,b as Nn}from"../chunks/ylfInSZr.js";import{v as No}from"../chunks/C-2x_D2r.js";import{p as ii}from"../chunks/1b86Y8Q5.js";function li(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,c="";if(r){var _=n;yn&&(i=Wr(ir(_)))}H(()=>{var b=Ua;if(c===(c=e()??"")){yn&&eo();return}if(r&&!yn){b.nodes=null,_.innerHTML=c,c!==""&&ns(ir(_),_.lastChild);return}if(b.nodes!==null&&(za(b.nodes.start,b.nodes.end),b.nodes=null),c!==""){if(yn){bs.data;for(var v=eo(),A=v;v!==null&&(v.nodeType!==Oo||v.data!=="");)A=v,v=vs(v);if(v===null)throw Ba(),Ha;ns(bs,A),i=Wr(v);return}var $=s?Ga:o?ja:void 0,O=Wa(s?"svg":o?"math":"template",$);O.innerHTML=c;var k=s||o?O:O.content;if(ns(ir(k),k.lastChild),s||o)for(;ir(k);)i.before(ir(k));else i.before(k)}})}function ci(n,e){let r=null,s=yn;var o;if(yn){r=bs;for(var a=ir(document.head);a!==null&&(a.nodeType!==Oo||a.data!==n);)a=vs(a);if(a===null)to(!1);else{var i=vs(a);a.remove(),Wr(i)}}yn||(o=document.head.appendChild(qa()));try{Va(()=>{var c=Ka(()=>e(o));c.f|=Ya})}finally{s&&(to(!0),Wr(r))}}function Fo(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=Fo(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function di(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=Fo(n))&&(s&&(s+=" "),s+=e);return s}function ui(n){return typeof n=="object"?di(n):n??""}function fi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Yt(n,e,r,s,o,a){var i=n[no];if(yn||i!==r||i===void 0){var c=fi(r);(!yn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[no]=r}return a}function Os(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Xa(e))return Qa();for(var s of n.options)s.selected=e.includes(Ar(s));return}for(s of n.options){var o=Ar(s);if(Do(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Uo(n){var e=new MutationObserver(()=>{Os(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Lo(()=>{e.disconnect()})}function Ir(n,e,r=e){var s=new WeakSet,o=!0;Kr(n,"change",a=>{var i=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),Ar);else{var _=n.querySelector(i)??n.querySelector("option:not([disabled])");c=_&&Ar(_)}r(c),n.__value=c,Wn!==null&&s.add(Wn)}),Za(()=>{var a=e();if(n===document.activeElement){var i=Wn;if(s.has(i))return}if(Os(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Ar(c),r(a))}n.__value=a,o=!1}),Uo(n)}function Ar(n){return"__value"in n?n.__value:n.value}function On(n,e,r=e){var s=new WeakSet;Kr(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=ss(n)?os(a):a,r(a),Wn!==null&&s.add(Wn),await Ja(),a!==(a=e())){var i=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var b=n.value.length;i===c&&c===_&&b>_?(n.selectionStart=b,n.selectionEnd=b):(n.selectionStart=i,n.selectionEnd=Math.min(c,b))}}}),(yn&&n.defaultValue!==n.value||$s(e)==null&&n.value)&&(r(ss(n)?os(n.value):n.value),Wn!==null&&s.add(Wn)),Ms(()=>{var o=e();if(n===document.activeElement){var a=Wn;if(s.has(a))return}ss(n)&&o===os(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const rs=new Set;function jn(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var _ of e)i=i[_]??=[];i.push(r),Kr(r,"change",()=>{var b=r.__value;a&&(b=so(i,b,r.checked)),o(b)},()=>o(a?[]:null)),Ms(()=>{var b=s();if(yn&&r.defaultChecked!==r.checked){c=!0;return}a?(b=b||[],r.checked=b.includes(r.__value)):r.checked=Do(r.__value,b)}),Lo(()=>{var b=i.indexOf(r);b!==-1&&i.splice(b,1)}),rs.has(i)||(rs.add(i),ro(()=>{i.sort((b,v)=>b.compareDocumentPosition(v)===4?-1:1),rs.delete(i)})),ro(()=>{if(c){var b;if(a)b=so(i,b,r.checked);else{var v=i.find(A=>A.checked);b=v?.__value}o(b)}})}function Tn(n,e,r=e){Kr(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(yn&&n.defaultChecked!==n.checked||$s(e)==null)&&r(n.checked),Ms(()=>{var s=e();n.checked=!!s})}function so(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 ss(n){var e=n.type;return e==="number"||e==="range"}function os(n){return n===""?null:+n}const pi=!1,hi=!0,xf=Object.freeze(Object.defineProperty({__proto__:null,prerender:hi,ssr:pi},Symbol.toStringTag,{value:"Module"})),as="Wherever",bi="Create & maintain apps from wherever with a beautiful remote workspace.",is="https://localhost",vi="#000000",gi="black-translucent";function cr(n,e){return si(n)}var mi=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 xi(n,e){Vn(e,!0);const r=is.endsWith("/")?is.slice(0,-1):is,s=r+"/preview.png";let o=Q(()=>e.home||!1),a=Q(()=>({type:e.type||"website",title:e.title||as,description:e.description||bi,image:e.image||s,url:`${r}${ii.url.pathname}`}));ci("13n5pl5",i=>{var c=mi(),_=Zt(c),b=f(_,2),v=f(b,2);{var A=ot=>{var Je=dr(),et=Zt(Je);E(et,Mt=>{}),h(ot,Je)};E(v,ot=>{t(o)&&ot(A)})}var $=f(v,2),O=f($,2),k=f(O,2),ae=f(k,2),se=f(ae,2),he=f(se,4),ie=f(he,2),rt=f(ie,2),Me=f(rt,2),Ge=f(Me,2),le=f(Ge,2),Pe=f(le,2),st=f(Pe,2),Ct=f(st,2),at=f(Ct,4),be=f(at,4),je=f(be,2),_t=f(je,2);H((ot,Je,et,Mt)=>{Fe(_,"content",t(a).title),Fe(b,"content",t(a).description),Fe($,"content",t(a).type),Fe(O,"content",t(a).url),Fe(k,"content",t(a).title),Fe(ae,"content",t(a).description),Fe(se,"content",t(a).image),Fe(he,"content",t(a).url),Fe(ie,"content",t(a).title),Fe(rt,"content",t(a).description),Fe(Me,"content",t(a).image),Fe(Ge,"href",ot),Fe(le,"href",Je),Fe(Pe,"href",et),Fe(st,"href",Mt),Fe(Ct,"content",vi),Fe(at,"content",as),Fe(be,"content",gi),Fe(je,"content",as),Fe(_t,"content",No)},[()=>cr("/pwa/favicon.png"),()=>cr("/pwa/favicon.ico"),()=>cr("/pwa/apple-touch-icon.png"),()=>cr("/pwa/manifest.webmanifest")]),ei(()=>{ti.title=t(a).title??""}),h(i,c)}),Kn()}let br=null;function _i(){if(typeof window>"u")return null;try{if(!br){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;br=new n}return br.state==="suspended"&&br.resume().catch(()=>{}),br}catch{return null}}function oo(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+c),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const ao=new Map;function yi(n){if(typeof Audio>"u")return!1;try{let e=ao.get(n);e||(e=new Audio(n),e.preload="auto",ao.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 zo(n){if(n&&n.trim()&&yi(n.trim()))return;const e=_i();if(e)try{const r=e.currentTime;oo(e,1046.5,r,.16,.12),oo(e,1396.9,r+.13,.22,.12)}catch{}}function zr(){}function wi(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function ki(n,...e){if(n==null)return zr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Jt(n){let e;return ki(n,r=>e=r)(),e}var or=[];function Si(n,e=zr){let r;const s=new Set;function o(c){if(wi(n,c)&&(n=c,r)){const _=!or.length;for(const b of s)b[1](),or.push(b,n);if(_){for(let b=0;b<or.length;b+=2)or[b][0](or[b+1]);or.length=0}}}function a(c){o(c(n))}function i(c,_=zr){const b=[c,_];return s.add(b),s.size===1&&(r=e(o)||zr),c(n),()=>{s.delete(b),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}const ls={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,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;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=Si({...ls,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}:{...ls,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)}`:"",i=`${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(i,O):new c(i)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,b=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(he=>({...he,connected:!0,connecting:!1,error:null}));const O=Jt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,ae=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,se=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(he=>he.resyncing?he:{...he,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:ae,model:se}),this.armLoadWatchdog()):this.stateStore.update(he=>he.resyncing?{...he,resyncing:!1}:he)},v=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),ae=JSON.parse(k);this.handleMessage(ae)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},A=()=>{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())},$=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",b),_.addEventListener("message",v),_.addEventListener("close",A),_.addEventListener("error",$)):typeof _.on=="function"&&(_.on("open",b),_.on("message",O=>v({data:O})),_.on("close",A),_.on("error",$))}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){try{typeof this.ws.removeAllListeners=="function"&&this.ws.removeAllListeners(),this.ws.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...ls,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=Jt(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=Jt(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||Jt(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=Jt(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 i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.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=Jt(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,Jt(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(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!Jt(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 i=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)o=o.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Jt(this.stateStore);const c=[...o].reverse().find(b=>b.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(),i={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a};return{...s,messages:[...o,i]}});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 ns,a as h,c as dr,g as m,d as tr,e as B,f as qn,s as re,t as _n}from"../chunks/vMsF8lo6.js";import{ar as yn,b2 as Wr,al as ir,be as H,ap as eo,M as Ua,aS as za,aq as bs,d as Oo,am as vs,at as Ba,n as Ha,a0 as Wa,u as Ga,t as ja,a1 as qa,V as Va,W as Ka,H as Ya,b3 as to,C as no,aE as Kr,a2 as Wn,ac as Za,az as Xa,aZ as Qa,ay as Do,bd as Lo,bf as Ja,bg as $s,aU as Ms,aQ as ro,aP as Vn,aM as Kn,af as Zt,b6 as f,ai as t,a5 as ei,bh as Q,$ as ti,bl as An,ah as Fn,a8 as jt,aK as Mr,a_ as p,X as u,aV as d,aI as dt,b9 as V,aO as wn,bi as Lt,bj as ni,aT as ri}from"../chunks/CEg8tgYI.js";import{i as E,s as pr,a as Ue,p as Xn}from"../chunks/MtE7VtNZ.js";import{a as si,b as Fe,r as it,c as Po,e as gn,i as Sn,d as oi}from"../chunks/Og-aeqCF.js";import{_ as ai,b as Nn}from"../chunks/ylfInSZr.js";import{v as No}from"../chunks/DCwWdFrO.js";import{p as ii}from"../chunks/CknLe1TD.js";function li(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,c="";if(r){var _=n;yn&&(i=Wr(ir(_)))}H(()=>{var b=Ua;if(c===(c=e()??"")){yn&&eo();return}if(r&&!yn){b.nodes=null,_.innerHTML=c,c!==""&&ns(ir(_),_.lastChild);return}if(b.nodes!==null&&(za(b.nodes.start,b.nodes.end),b.nodes=null),c!==""){if(yn){bs.data;for(var v=eo(),A=v;v!==null&&(v.nodeType!==Oo||v.data!=="");)A=v,v=vs(v);if(v===null)throw Ba(),Ha;ns(bs,A),i=Wr(v);return}var $=s?Ga:o?ja:void 0,O=Wa(s?"svg":o?"math":"template",$);O.innerHTML=c;var k=s||o?O:O.content;if(ns(ir(k),k.lastChild),s||o)for(;ir(k);)i.before(ir(k));else i.before(k)}})}function ci(n,e){let r=null,s=yn;var o;if(yn){r=bs;for(var a=ir(document.head);a!==null&&(a.nodeType!==Oo||a.data!==n);)a=vs(a);if(a===null)to(!1);else{var i=vs(a);a.remove(),Wr(i)}}yn||(o=document.head.appendChild(qa()));try{Va(()=>{var c=Ka(()=>e(o));c.f|=Ya})}finally{s&&(to(!0),Wr(r))}}function Fo(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=Fo(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function di(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=Fo(n))&&(s&&(s+=" "),s+=e);return s}function ui(n){return typeof n=="object"?di(n):n??""}function fi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Yt(n,e,r,s,o,a){var i=n[no];if(yn||i!==r||i===void 0){var c=fi(r);(!yn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[no]=r}return a}function Os(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Xa(e))return Qa();for(var s of n.options)s.selected=e.includes(Ar(s));return}for(s of n.options){var o=Ar(s);if(Do(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Uo(n){var e=new MutationObserver(()=>{Os(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Lo(()=>{e.disconnect()})}function Ir(n,e,r=e){var s=new WeakSet,o=!0;Kr(n,"change",a=>{var i=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),Ar);else{var _=n.querySelector(i)??n.querySelector("option:not([disabled])");c=_&&Ar(_)}r(c),n.__value=c,Wn!==null&&s.add(Wn)}),Za(()=>{var a=e();if(n===document.activeElement){var i=Wn;if(s.has(i))return}if(Os(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Ar(c),r(a))}n.__value=a,o=!1}),Uo(n)}function Ar(n){return"__value"in n?n.__value:n.value}function On(n,e,r=e){var s=new WeakSet;Kr(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=ss(n)?os(a):a,r(a),Wn!==null&&s.add(Wn),await Ja(),a!==(a=e())){var i=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var b=n.value.length;i===c&&c===_&&b>_?(n.selectionStart=b,n.selectionEnd=b):(n.selectionStart=i,n.selectionEnd=Math.min(c,b))}}}),(yn&&n.defaultValue!==n.value||$s(e)==null&&n.value)&&(r(ss(n)?os(n.value):n.value),Wn!==null&&s.add(Wn)),Ms(()=>{var o=e();if(n===document.activeElement){var a=Wn;if(s.has(a))return}ss(n)&&o===os(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const rs=new Set;function jn(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var _ of e)i=i[_]??=[];i.push(r),Kr(r,"change",()=>{var b=r.__value;a&&(b=so(i,b,r.checked)),o(b)},()=>o(a?[]:null)),Ms(()=>{var b=s();if(yn&&r.defaultChecked!==r.checked){c=!0;return}a?(b=b||[],r.checked=b.includes(r.__value)):r.checked=Do(r.__value,b)}),Lo(()=>{var b=i.indexOf(r);b!==-1&&i.splice(b,1)}),rs.has(i)||(rs.add(i),ro(()=>{i.sort((b,v)=>b.compareDocumentPosition(v)===4?-1:1),rs.delete(i)})),ro(()=>{if(c){var b;if(a)b=so(i,b,r.checked);else{var v=i.find(A=>A.checked);b=v?.__value}o(b)}})}function Tn(n,e,r=e){Kr(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(yn&&n.defaultChecked!==n.checked||$s(e)==null)&&r(n.checked),Ms(()=>{var s=e();n.checked=!!s})}function so(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 ss(n){var e=n.type;return e==="number"||e==="range"}function os(n){return n===""?null:+n}const pi=!1,hi=!0,xf=Object.freeze(Object.defineProperty({__proto__:null,prerender:hi,ssr:pi},Symbol.toStringTag,{value:"Module"})),as="Wherever",bi="Create & maintain apps from wherever with a beautiful remote workspace.",is="https://localhost",vi="#000000",gi="black-translucent";function cr(n,e){return si(n)}var mi=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 xi(n,e){Vn(e,!0);const r=is.endsWith("/")?is.slice(0,-1):is,s=r+"/preview.png";let o=Q(()=>e.home||!1),a=Q(()=>({type:e.type||"website",title:e.title||as,description:e.description||bi,image:e.image||s,url:`${r}${ii.url.pathname}`}));ci("13n5pl5",i=>{var c=mi(),_=Zt(c),b=f(_,2),v=f(b,2);{var A=ot=>{var Je=dr(),et=Zt(Je);E(et,Mt=>{}),h(ot,Je)};E(v,ot=>{t(o)&&ot(A)})}var $=f(v,2),O=f($,2),k=f(O,2),ae=f(k,2),se=f(ae,2),he=f(se,4),ie=f(he,2),rt=f(ie,2),Me=f(rt,2),Ge=f(Me,2),le=f(Ge,2),Pe=f(le,2),st=f(Pe,2),Ct=f(st,2),at=f(Ct,4),be=f(at,4),je=f(be,2),_t=f(je,2);H((ot,Je,et,Mt)=>{Fe(_,"content",t(a).title),Fe(b,"content",t(a).description),Fe($,"content",t(a).type),Fe(O,"content",t(a).url),Fe(k,"content",t(a).title),Fe(ae,"content",t(a).description),Fe(se,"content",t(a).image),Fe(he,"content",t(a).url),Fe(ie,"content",t(a).title),Fe(rt,"content",t(a).description),Fe(Me,"content",t(a).image),Fe(Ge,"href",ot),Fe(le,"href",Je),Fe(Pe,"href",et),Fe(st,"href",Mt),Fe(Ct,"content",vi),Fe(at,"content",as),Fe(be,"content",gi),Fe(je,"content",as),Fe(_t,"content",No)},[()=>cr("/pwa/favicon.png"),()=>cr("/pwa/favicon.ico"),()=>cr("/pwa/apple-touch-icon.png"),()=>cr("/pwa/manifest.webmanifest")]),ei(()=>{ti.title=t(a).title??""}),h(i,c)}),Kn()}let br=null;function _i(){if(typeof window>"u")return null;try{if(!br){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;br=new n}return br.state==="suspended"&&br.resume().catch(()=>{}),br}catch{return null}}function oo(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+c),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const ao=new Map;function yi(n){if(typeof Audio>"u")return!1;try{let e=ao.get(n);e||(e=new Audio(n),e.preload="auto",ao.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 zo(n){if(n&&n.trim()&&yi(n.trim()))return;const e=_i();if(e)try{const r=e.currentTime;oo(e,1046.5,r,.16,.12),oo(e,1396.9,r+.13,.22,.12)}catch{}}function zr(){}function wi(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function ki(n,...e){if(n==null)return zr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Jt(n){let e;return ki(n,r=>e=r)(),e}var or=[];function Si(n,e=zr){let r;const s=new Set;function o(c){if(wi(n,c)&&(n=c,r)){const _=!or.length;for(const b of s)b[1](),or.push(b,n);if(_){for(let b=0;b<or.length;b+=2)or[b][0](or[b+1]);or.length=0}}}function a(c){o(c(n))}function i(c,_=zr){const b=[c,_];return s.add(b),s.size===1&&(r=e(o)||zr),c(n),()=>{s.delete(b),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}const ls={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,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;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=Si({...ls,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}:{...ls,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)}`:"",i=`${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(i,O):new c(i)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,b=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(he=>({...he,connected:!0,connecting:!1,error:null}));const O=Jt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,ae=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,se=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(he=>he.resyncing?he:{...he,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:ae,model:se}),this.armLoadWatchdog()):this.stateStore.update(he=>he.resyncing?{...he,resyncing:!1}:he)},v=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),ae=JSON.parse(k);this.handleMessage(ae)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},A=()=>{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())},$=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",b),_.addEventListener("message",v),_.addEventListener("close",A),_.addEventListener("error",$)):typeof _.on=="function"&&(_.on("open",b),_.on("message",O=>v({data:O})),_.on("close",A),_.on("error",$))}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){try{typeof this.ws.removeAllListeners=="function"&&this.ws.removeAllListeners(),this.ws.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...ls,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=Jt(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=Jt(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||Jt(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=Jt(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 i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.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=Jt(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,Jt(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(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!Jt(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 i=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)o=o.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Jt(this.stateStore);const c=[...o].reverse().find(b=>b.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(),i={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a};return{...s,messages:[...o,i]}});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,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(c=>{const _=c.messages.find(v=>v.role==="tool"&&v.toolName===e.toolName&&v.isStreaming)??[...c.messages].reverse().find(v=>v.role==="tool"&&v.toolName===e.toolName&&!v.content.startsWith("Tool error:")),b=Date.now();if(_){const v=a?"Error: ":"";return{...c,messages:c.messages.map(A=>A.id===_.id?{...A,content:`${v}${A.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...i?{images:i}:{},endedAt:b}:A)}}else{const v=a?`Tool error: ${e.toolName}
|
|
@@ -84,4 +84,4 @@ ${ee}`}}if(j.startsWith("/")&&t(ie).length===0){const T=j.toLowerCase();if(T==="
|
|
|
84
84
|
msgs`)},[()=>encodeURIComponent(t(ce).id),()=>t(ce).name||Ut(t(ce).firstMessage)||"Empty session",()=>Ce(t(ce).modified)]),B("click",F,Z=>{Z.button===0&&!Z.ctrlKey&&!Z.metaKey&&!Z.altKey&&!Z.shiftKey&&(Z.preventDefault(),Rt(t(ce).path))}),h(w,P)}),d(L),h(y,L)},x=Q(()=>ot(t(ke).path));E(G,y=>{t(x)&&y(xe)})}d(Ot),H(y=>{Yt(Dt,1,`text-xs text-brand-text-muted transition-transform ${y??""}`),re(D,t(ke).name),re(Oe,t(ke).path),re(ze,t(ke).sessions.length)},[()=>ot(t(ke).path)?"rotate-90":""]),B("click",Et,()=>Je(t(ke).path)),h(Y,Ot)}),h(I,W)};E(Re,I=>{t(se)&&t(je).length===0?I(bt):t(je).length===0?I(Ht,1):I(St,-1)})}d(Bt),d(an);var vt=f(an,2);{var Kt=I=>{var W=_u(),K=u(W),Y=f(u(K),2),ke=f(u(Y),2),Ot=u(ke,!0);d(ke),d(Y);var Et=f(Y,2),Dt=f(u(Et),2);{var At=Ne=>{var ze=mu();gn(ze,21,()=>t(le),Sn,(G,xe)=>{var x=gu(),y=u(x);d(x);var L={};H(()=>{re(y,`${t(xe).label??""}${t(xe).isDefault?" (default)":""}`),L!==(L=`${t(xe).provider}:${t(xe).modelId}`)&&(x.value=x.__value=`${t(xe).provider}:${t(xe).modelId}`)}),h(G,x)}),d(ze),Ir(ze,()=>t(Ve).selected,G=>t(Ve).selected=G),h(Ne,ze)},C=Ne=>{var ze=xu();it(ze),On(ze,()=>t(Ve).selected,G=>t(Ve).selected=G),h(Ne,ze)};E(Dt,Ne=>{t(le).length>0?Ne(At):Ne(C,-1)})}d(Et);var D=f(Et,2),de=u(D),Oe=f(de,2);d(D),d(K),d(W),H(()=>re(Ot,t(Ve).folderPath)),B("click",W,Tt),B("click",K,Ne=>Ne.stopPropagation()),B("click",de,Tt),B("click",Oe,Ye),h(I,W)};E(vt,I=>{t(Ve).open&&I(Kt)})}var tn=f(vt,2);{var un=I=>{var W=yu(),K=u(W),Y=u(K,!0);d(K);var ke=f(K,2);d(W),H(()=>re(Y,v())),B("click",ke,()=>Jn()),h(I,W)};E(tn,I=>{v()&&I(un)})}var bn=f(tn,2);{var En=I=>{var W=Au(),K=u(W),Y=f(u(K),2),ke=f(u(Y)),Ot=u(ke,!0);d(ke),dt(),d(Y);var Et=f(Y,2),Dt=u(Et),At=u(Dt);it(At);var C=f(At,2),D=f(u(C));{var de=y=>{var L=wu();h(y,L)},Oe=y=>{var L=ku();h(y,L)};E(D,y=>{t(T).isGit?y(de):y(Oe,-1)})}d(C),d(Dt);var Ne=f(Dt,2);{var ze=y=>{var L=Tu(),z=u(L),fe=u(z);it(fe);var X=f(fe,2),w=u(X);d(X),d(z);var ce=f(z,2);{var P=F=>{var Te=Su(),ne=f(u(Te),2),Se=u(ne);it(Se),Se.value=Se.__value="private",dt(),d(ne);var _e=f(ne,2),De=u(_e);it(De),De.value=De.__value="public",dt(),d(_e),d(Te),jn(O,[],Se,()=>t(ge),gt=>p(ge,gt)),jn(O,[],De,()=>t(ge),gt=>p(ge,gt)),h(F,Te)};E(ce,F=>{t(j)&&F(P)})}d(L),H(()=>re(w,`Create remote ${t(T).matchingRule.provider??""} repository`)),Tn(fe,()=>t(j),F=>p(j,F)),h(y,L)};E(Ne,y=>{t(T).matchingRule&&y(ze)})}d(Et);var G=f(Et,2),xe=u(G),x=f(xe,2);d(G),d(K),d(W),H(()=>{re(Ot,t(pt)),At.disabled=t(T).isGit}),Tn(At,()=>t(lt),y=>p(lt,y)),B("click",xe,()=>p(S,!1)),B("click",x,Ze),h(I,W)};E(bn,I=>{t(S)&&I(En)})}H(()=>{oi(wt,t(be)),Yt(Xt,1,ui(t(se)?"animate-spin":""))}),B("input",wt,I=>p(be,I.currentTarget.value,!0)),B("click",kt,()=>he()),h(n,zt),Kn(),$()}tr(["input","click","keydown","change"]);var Cu=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">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <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">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
|
|
85
85
|
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
86
86
|
and gain control.</p></div></div>`);function Ru(n,e){Vn(e,!0);const r=()=>Ue(da,"$conflict",s),[s,o]=pr();let a=Q(r);var i=dr(),c=Zt(i);{var _=b=>{var v=Cu(),A=u(v),$=f(u(A),2),O=f(u($)),k=u(O,!0);d(O),dt(),d($);var ae=f($,2),se=u(ae),he=f(se,2);d(ae),dt(2),d(A),d(v),H(()=>re(k,t(a).conflictingCwd)),B("click",se,()=>ks("read_only")),B("click",he,()=>ks("take_over")),h(b,v)};E(c,b=>{t(a)&&b(_)})}h(n,i),Kn(),o()}tr(["click"]);function Iu(n){return n.loading||n.resyncing||n.hasSessionHash}function $u(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!Iu(n)}var Mu=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>'),Ou=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),Du=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),Lu=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>'),Pu=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Nu=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Fu=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>'),Uu=m('<div class="mt-2 text-xs text-rose-400"> </div>'),zu=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>'),Bu=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>'),Hu=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),Wu=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>'),Gu=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),ju=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),qu=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Vu=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),Ku=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>'),Yu=m("<option> </option>"),Zu=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>'),Xu=m('<span class="truncate text-brand-text-muted"> </span>'),Qu=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>'),Ju=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),ef=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),tf=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>'),nf=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>'),rf=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>'),sf=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>'),of=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>'),af=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>'),lf=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>'),cf=m("<!> <!>",1),df=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),uf=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 _f(n,e){Vn(e,!0);const r=()=>Ue(Dr,"$isConnected",se),s=()=>Ue(Gs,"$isResyncing",se),o=()=>Ue(ha,"$isAgentPending",se),a=()=>Ue(Qr,"$isLoadingSession",se),i=()=>Ue(ua,"$isInterrupted",se),c=()=>Ue(Ws,"$sessionError",se),_=()=>Ue(fa,"$sessionNotice",se),b=()=>Ue(Xr,"$isReadOnly",se),v=()=>Ue(Lr,"$activeSessionInfo",se),A=()=>Ue(Nt,"$piState",se),$=()=>Ue(fr,"$availableModels",se),O=()=>Ue(pa,"$isCreatingSession",se),k=()=>Ue(Ls,"$searchFolderStore",se),ae=()=>Ue(Go,"$searchDefaultModelStore",se),[se,he]=pr();let ie=V(!1),rt=V("main"),Me=V(!1),Ge;Mr(()=>{setTimeout(()=>Qn(),200);const C=()=>{if(t(be)){const ze=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ze&&ze!==t(ye)?Bs(ze):!ze&&t(ye)&&kn()}};window.addEventListener("hashchange",C);let D=null;const de=8e3,Oe=()=>{if(document.visibilityState==="hidden"){if(Qo())return;D&&clearTimeout(D),D=setTimeout(()=>{D=null,document.visibilityState==="hidden"&&t(be)&&Zo()},de)}else zs(),D&&(clearTimeout(D),D=null),t(be)||(ys()?_s():Qn())},Ne=ze=>{D&&(clearTimeout(D),D=null),document.visibilityState!=="hidden"&&!t(be)&&(ys()?_s():Qn())};return document.addEventListener("visibilitychange",Oe),window.addEventListener("pageshow",Ne),()=>{window.removeEventListener("hashchange",C),document.removeEventListener("visibilitychange",Oe),window.removeEventListener("pageshow",Ne),D&&clearTimeout(D)}});function le(){Qn()}function Pe(){kn(),$r()}function st(){$r(),setTimeout(()=>Qn(),100)}function Ct(){Er()}function at(){typeof window<"u"&&(window.location.hash=""),kn(),p(ie,!1)}let be=Q(r),je=Q(s),_t=Q(o),ot=Q(a),Je=Q(i),et=Q(c),Mt=Q(_),Rt=Q(b),ve=Q(v),pt=Q(A),te=Q(()=>$().models),Ft=V(!1),ye=Q(()=>t(ve).sessionId);Lt(()=>{typeof window<"u"&&t(be)&&(t(ye)?(window.location.hash=encodeURIComponent(t(ye)),p(Ft,!0)):t(Ft)&&(p(Ft,!1),window.location.hash&&(window.location.hash="")))});let ht=null;Lt(()=>{if(!t(be)||typeof window>"u"||!window.location.hash)return;const C=decodeURIComponent(window.location.hash.slice(1));C&&(t(ye)===C||t(ot)||t(je)||ht||(ht=setTimeout(()=>{ht=null,!(t(ye)===C||t(ot)||t(je))&&na(C)},300)))}),Lt(()=>{t(be)||p(Ft,!1)}),Lt(()=>{(t(ye)||t(ot)||t(je))&&p(ie,!1)});let hn=Q(O),Ee=Q(k),lt=V(void 0),Vt=Q(()=>$u({connected:t(be),searchConfigured:!!t(Ee),hasSession:!!t(ve).sessionFile,loading:t(ot),resyncing:t(je),hasSessionHash:typeof window<"u"&&!!window.location.hash})),j=Q(()=>t(te).map(C=>({value:`${C.provider}:${C.modelId}`,label:`${C.label}${C.isDefault?" (default)":""}`}))),ge=Q(ae),S=V("");Lt(()=>{if(t(j).length===0||t(j).some(Oe=>Oe.value===t(S)))return;const D=t(j).find(Oe=>Oe.value===t(ge)),de=t(te).find(Oe=>Oe.isDefault);p(S,D?D.value:de?`${de.provider}:${de.modelId}`:t(j)[0].value,!0)});let J=V(!1);Lt(()=>{t(Vt)&&!t(J)&&t(lt)&&(p(J,!0),t(lt).focusInput())});function T(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),kn(),t(lt)?.focusInput()}var ee=uf(),U=Zt(ee);xi(U,{title:"Wherever",description:"Create & maintain apps from wherever"});var we=f(U,2);{var me=C=>{var D=Mu();h(C,D)};E(we,C=>{t(hn)&&C(me)})}var Ze=f(we,2),Ve=u(Ze),yt=u(Ve),Tt=u(yt),Ye=u(Tt);{var Ce=C=>{var D=Ou(),de=f(Zt(D),2);B("click",de,()=>p(Me,!1)),h(C,D)},Ut=C=>{var D=Du(),de=Zt(D),Oe=u(de);dt(2),d(de);var Ne=f(de,2),ze=u(Ne),G=f(ze,2);d(Ne),H(xe=>Fe(Oe,"src",xe),[()=>cr("/logo.svg")]),B("click",de,at),B("click",ze,()=>p(Me,!0)),B("click",G,()=>p(ie,!1)),h(C,D)};E(Ye,C=>{t(Me)?C(Ce):C(Ut,-1)})}d(Tt),d(yt);var zt=f(yt,2);{var an=C=>{var D=Lu(),de=u(D);{let x=Q(()=>(t(pt).connected,"localhost"));Vi(de,{get host(){return t(x)},port:31415,token:"",onConnected:le})}var Oe=f(de,2),Ne=f(u(Oe),2),ze=u(Ne),G=f(ze,2),xe=f(G,2);d(Ne),d(Oe),d(D),B("click",ze,Ct),B("click",G,st),B("click",xe,Pe),h(C,D)},cn=C=>{var D=Hu(),de=Zt(D),Oe=u(de),Ne=u(Oe),ze=f(Ne,2),G=u(ze,!0);d(ze);var xe=f(ze,2),x=u(xe);d(xe),d(Oe);var y=f(Oe,2);{var L=_e=>{var De=Fu(),gt=u(De);{var Be=Ie=>{var Z=Pu(),oe=u(Z);d(Z),H(N=>{Fe(Z,"title",t(ve).cwd),re(oe,`📁 ${N??""}`)},[()=>t(ve).cwd.split("/").pop()||t(ve).cwd]),h(Ie,Z)};E(gt,Ie=>{t(ve).cwd&&Ie(Be)})}var Ke=f(gt,2);{var He=Ie=>{var Z=Nu(),oe=u(Z);d(Z),H(()=>{Fe(Z,"title",t(ve).model),re(oe,`🤖 ${t(ve).model??""}`)}),h(Ie,Z)};E(Ke,Ie=>{t(ve).model&&Ie(He)})}var qe=f(Ke,2),mt=u(qe);d(qe),d(De),B("click",mt,at),h(_e,De)};E(y,_e=>{t(ve).sessionFile&&_e(L)})}var z=f(y,2);{var fe=_e=>{var De=Uu(),gt=u(De,!0);d(De),H(()=>re(gt,t(pt).error)),h(_e,De)};E(z,_e=>{t(pt).error&&!t(be)&&_e(fe)})}d(de);var X=f(de,2),w=u(X);{var ce=_e=>{var De=zu();B("click",De,()=>{p(rt,"readonly"),Bo()}),h(_e,De)},P=_e=>{var De=Bu();B("click",De,()=>p(rt,"main")),h(_e,De)};E(w,_e=>{t(rt)==="main"?_e(ce):_e(P,-1)})}d(X);var F=f(X,2),Te=u(F);{var ne=_e=>{Mo(_e,{readOnly:!0})},Se=_e=>{Mo(_e,{})};E(Te,_e=>{t(rt)==="readonly"?_e(ne):_e(Se,-1)})}d(F),H(()=>{Yt(Ne,1,`h-2.5 w-2.5 rounded-full ${t(be)?"bg-emerald-500":"bg-rose-500"}`),Yt(ze,1,`text-sm ${t(be)?"text-emerald-400":"text-rose-400"}`),re(G,t(be)?"Connected":"Disconnected"),re(x,`v${No}`)}),h(C,D)};E(zt,C=>{t(Me)?C(an):C(cn,-1)})}d(Ve);var tt=f(Ve,2),wt=u(tt),kt=u(wt),Xt=f(kt,2);{var Bt=C=>{var D=Wu();B("click",D,T),h(C,D)};E(Xt,C=>{t(be)&&t(Ee)&&t(ve).sessionFile&&C(Bt)})}var Qt=f(Xt,2);{var dn=C=>{var D=Vu(),de=u(D);{var Oe=G=>{var xe=Gu();h(G,xe)},Ne=G=>{var xe=ju();h(G,xe)},ze=G=>{var xe=qu();h(G,xe)};E(de,G=>{t(be)&&t(Vt)?G(Oe):t(be)?G(Ne,1):G(ze,-1)})}d(D),h(C,D)};E(Qt,C=>{(!t(be)||!t(ve).sessionFile)&&C(dn)})}var Re=f(Qt,2);{var bt=C=>{var D=Ju(),de=u(D);{var Oe=G=>{var xe=Ku(),x=f(u(xe),2),y=u(x,!0);d(x),d(xe),H(L=>{Fe(x,"title",t(ve).cwd),re(y,L)},[()=>t(ve).cwd.split("/").pop()||t(ve).cwd]),h(G,xe)};E(de,G=>{t(ve).cwd&&G(Oe)})}var Ne=f(de,2);{var ze=G=>{var xe=Qu(),x=u(xe),y=f(u(x),2);d(x);var L=f(x,2);{var z=X=>{var w=Zu();gn(w,21,()=>t(te),Sn,(P,F)=>{var Te=Yu(),ne=u(Te,!0);d(Te);var Se={};H(()=>{re(ne,t(F).label),Se!==(Se=`${t(F).provider}:${t(F).modelId}`)&&(Te.value=Te.__value=`${t(F).provider}:${t(F).modelId}`)}),h(P,Te)}),d(w);var ce;Uo(w),H(()=>{ce!==(ce=t(ve).model)&&(w.value=(w.__value=t(ve).model)??"",Os(w,t(ve).model))}),B("input",w,P=>la(P.currentTarget.value)),h(X,w)},fe=X=>{var w=Xu(),ce=u(w,!0);d(w),H(()=>{Fe(w,"title",t(ve).model),re(ce,t(ve).model)}),h(X,w)};E(L,X=>{t(te).length>0&&!t(Rt)?X(z):X(fe,-1)})}d(xe),H(()=>{Yt(y,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(pt).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),Fe(y,"title",t(pt).isStreaming?"Agent working...":"Ready")}),h(G,xe)};E(Ne,G=>{t(ve).model&&G(ze)})}d(D),h(C,D)};E(Re,C=>{t(ve).sessionFile&&C(bt)})}var Ht=f(Re,2);{var St=C=>{var D=ef();h(C,D)};E(Ht,C=>{t(Rt)&&C(St)})}d(wt);var vt=f(wt,2);{var Kt=C=>{var D=tf();h(C,D)};E(vt,C=>{t(Je)&&C(Kt)})}var tn=f(vt,2);{var un=C=>{var D=nf(),de=u(D),Oe=u(de,!0);d(de);var Ne=f(de,2);d(D),H(()=>{Yt(D,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(Mt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),re(Oe,t(Mt).message)}),B("click",Ne,()=>ia()),h(C,D)};E(tn,C=>{t(Mt)&&C(un)})}var bn=f(tn,2);{var En=C=>{var D=rf(),de=u(D),Oe=u(de,!0);d(de);var Ne=f(de,2);d(D),H(()=>re(Oe,t(et))),B("click",Ne,()=>Jn()),h(C,D)};E(bn,C=>{t(et)&&C(En)})}var I=f(bn,2);{var W=C=>{var D=sf();h(C,D)};E(I,C=>{t(Rt)&&!t(Je)&&C(W)})}var K=f(I,2);Nn(xd(K,{onMessageSent:()=>{}}),C=>Ge=C,()=>Ge);var Y=f(K,2);{var ke=C=>{var D=of();h(C,D)},Ot=C=>{var D=cf(),de=Zt(D);{var Oe=G=>{var xe=af();h(G,xe)},Ne=G=>{var xe=lf();h(G,xe)};E(de,G=>{t(ve).sessionFile&&(t(je)||!t(be))?G(Oe):t(ve).sessionFile&&t(_t)&&G(Ne,1)})}var ze=f(de,2);{let G=Q(()=>!!t(Ee)),xe=Q(()=>t(Vt)?!t(be):!t(be)||t(Rt)||!t(ve).sessionFile||t(je)||t(_t));Nn(Gd(ze,{get searchMode(){return t(Vt)},get searchConfigured(){return t(G)},get searchModels(){return t(j)},onSubmit:x=>ra(x,t(S)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(xe)},onSend:()=>Ge?.forceScrollToBottom(),get searchModel(){return t(S)},set searchModel(x){p(S,x,!0)}}),x=>p(lt,x,!0),()=>t(lt))}h(C,D)};E(Y,C=>{t(Rt)&&t(ve).sessionFile?C(ke):C(Ot,-1)})}d(tt);var Et=f(tt,2);Ru(Et,{});var Dt=f(Et,2);{var At=C=>{var D=df();B("click",D,()=>p(ie,!1)),h(C,D)};E(Dt,C=>{t(ie)&&C(At)})}d(Ze),H(()=>Yt(Ve,1,`app-chrome ${t(ie)?"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`)),B("click",kt,()=>p(ie,!t(ie))),h(n,ee),Kn(),he()}tr(["click","input"]);export{_f as component,xf as universal};
|
|
87
|
-
//# sourceMappingURL=2.
|
|
87
|
+
//# sourceMappingURL=2.Do9j-h4_.js.map
|