wherever-dev 0.12.0 → 0.13.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/drafts.d.ts +7 -0
- package/dist/drafts.d.ts.map +1 -1
- package/dist/drafts.js +10 -3
- package/dist/drafts.js.map +1 -1
- package/dist/index.js +199 -15
- package/dist/index.js.map +1 -1
- package/dist/session-pool.d.ts +23 -0
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +33 -1
- package/dist/session-pool.js.map +1 -1
- package/package.json +1 -1
- package/public/_app/immutable/chunks/{55QXfSWV.js → CyQq9q8L.js} +2 -2
- package/public/_app/immutable/chunks/{55QXfSWV.js.map → CyQq9q8L.js.map} +1 -1
- package/public/_app/immutable/chunks/DdFruy3e.js +2 -0
- package/public/_app/immutable/chunks/{CuGyzHtA.js.map → DdFruy3e.js.map} +1 -1
- package/public/_app/immutable/chunks/{sERBGsNa.js → vSWNc7VF.js} +2 -2
- package/public/_app/immutable/chunks/{sERBGsNa.js.map → vSWNc7VF.js.map} +1 -1
- package/public/_app/immutable/entry/{app.DN0r_HfQ.js → app.BzMua2z6.js} +3 -3
- package/public/_app/immutable/entry/{app.DN0r_HfQ.js.map → app.BzMua2z6.js.map} +1 -1
- package/public/_app/immutable/entry/start.B0ap2dTz.js +2 -0
- package/public/_app/immutable/entry/start.B0ap2dTz.js.map +1 -0
- package/public/_app/immutable/nodes/{0.BhHgt5Z6.js → 0.BDXduH3G.js} +2 -2
- package/public/_app/immutable/nodes/{0.BhHgt5Z6.js.map → 0.BDXduH3G.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.B9mDAaoD.js → 1.CqJo-807.js} +2 -2
- package/public/_app/immutable/nodes/{1.B9mDAaoD.js.map → 1.CqJo-807.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.BjlQDhkN.js → 2.C6-6KHYk.js} +2 -2
- package/public/_app/immutable/nodes/{2.BjlQDhkN.js.map → 2.C6-6KHYk.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/CuGyzHtA.js +0 -2
- package/public/_app/immutable/entry/start.CSyfkZFS.js +0 -2
- package/public/_app/immutable/entry/start.CSyfkZFS.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as co,a as h,c as hr,g as b,d as Dr,e as D,s as N,f as gr,t as Bn,h as Vs}from"../chunks/BeRKnBIj.js";import{as as Yn,b4 as Bs,am as qr,bg as I,aq as Ta,O as sc,aU as oc,ar as Co,d as mi,an as Ro,au as ac,n as ic,a1 as lc,u as cc,t as dc,a2 as uc,W as fc,X as pc,H as hc,b5 as Aa,C as Ca,z as Ra,aF as Ys,a3 as Er,ad as bc,aA as vc,a$ as gc,az as xi,bf as _i,bh as mc,bi as yr,aW as qo,aS as Ea,aR as Tr,aO as Ar,ag as rn,b8 as f,aj as t,a6 as xc,bj as H,$ as _c,bn as En,ai as $n,a9 as bn,aM as ys,b0 as p,Y as c,aX as l,aJ as dt,bb as F,aQ as Gn,bk as Dt,bl as yc,aL as wc,aV as kc,aK as Ia}from"../chunks/Cum3gQOV.js";import{i as y,s as Br,a as De,p as vr}from"../chunks/C8CBGqeA.js";import{a as Sc,b as Y,r as wt,c as yi,e as Rn,i as rr,d as wi}from"../chunks/sERBGsNa.js";import{_ as Tc,b as sr}from"../chunks/D5t5dKgW.js";import{v as Os}from"../chunks/CuGyzHtA.js";import{p as Ac}from"../chunks/55QXfSWV.js";function $a(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,d="";if(r){var v=n;Yn&&(i=Bs(qr(v)))}I(()=>{var g=sc;if(d===(d=e()??"")){Yn&&Ta();return}if(r&&!Yn){g.nodes=null,v.innerHTML=d,d!==""&&co(qr(v),v.lastChild);return}if(g.nodes!==null&&(oc(g.nodes.start,g.nodes.end),g.nodes=null),d!==""){if(Yn){Co.data;for(var m=Ta(),x=m;m!==null&&(m.nodeType!==mi||m.data!=="");)x=m,m=Ro(m);if(m===null)throw ac(),ic;co(Co,x),i=Bs(m);return}var k=s?cc:o?dc:void 0,M=lc(s?"svg":o?"math":"template",k);M.innerHTML=d;var O=s||o?M:M.content;if(co(qr(O),O.lastChild),s||o)for(;qr(O);)i.before(qr(O));else i.before(O)}})}function Cc(n,e){let r=null,s=Yn;var o;if(Yn){r=Co;for(var a=qr(document.head);a!==null&&(a.nodeType!==mi||a.data!==n);)a=Ro(a);if(a===null)Aa(!1);else{var i=Ro(a);a.remove(),Bs(i)}}Yn||(o=document.head.appendChild(uc()));try{fc(()=>{var d=pc(()=>e(o));d.f|=hc})}finally{s&&(Aa(!0),Bs(r))}}function ki(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=ki(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Rc(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=ki(n))&&(s&&(s+=" "),s+=e);return s}function Si(n){return typeof n=="object"?Rc(n):n??""}function Ec(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Ic(n,e){return n==null?null:String(n)}function cn(n,e,r,s,o,a){var i=n[Ca];if(Yn||i!==r||i===void 0){var d=Ec(r);(!Yn||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[Ca]=r}return a}function $c(n,e,r,s){var o=n[Ra];if(Yn||o!==e){var a=Ic(e);(!Yn||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Ra]=e}return s}function Ko(n,e,r=!1){if(n.multiple){if(e==null)return;if(!vc(e))return gc();for(var s of n.options)s.selected=e.includes(hs(s));return}for(s of n.options){var o=hs(s);if(xi(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Ti(n){var e=new MutationObserver(()=>{Ko(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),_i(()=>{e.disconnect()})}function xs(n,e,r=e){var s=new WeakSet,o=!0;Ys(n,"change",a=>{var i=a?"[selected]":":checked",d;if(n.multiple)d=[].map.call(n.querySelectorAll(i),hs);else{var v=n.querySelector(i)??n.querySelector("option:not([disabled])");d=v&&hs(v)}r(d),n.__value=d,Er!==null&&s.add(Er)}),bc(()=>{var a=e();if(n===document.activeElement){var i=Er;if(s.has(i))return}if(Ko(n,a,o),o&&a===void 0){var d=n.querySelector(":checked");d!==null&&(a=hs(d),r(a))}n.__value=a,o=!1}),Ti(n)}function hs(n){return"__value"in n?n.__value:n.value}function cr(n,e,r=e){var s=new WeakSet;Ys(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=fo(n)?po(a):a,r(a),Er!==null&&s.add(Er),await mc(),a!==(a=e())){var i=n.selectionStart,d=n.selectionEnd,v=n.value.length;if(n.value=a??"",d!==null){var g=n.value.length;i===d&&d===v&&g>v?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=i,n.selectionEnd=Math.min(d,g))}}}),(Yn&&n.defaultValue!==n.value||yr(e)==null&&n.value)&&(r(fo(n)?po(n.value):n.value),Er!==null&&s.add(Er)),qo(()=>{var o=e();if(n===document.activeElement){var a=Er;if(s.has(a))return}fo(n)&&o===po(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const uo=new Set;function Mr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let d=!1;if(e!==null)for(var v of e)i=i[v]??=[];i.push(r),Ys(r,"change",()=>{var g=r.__value;a&&(g=Ma(i,g,r.checked)),o(g)},()=>o(a?[]:null)),qo(()=>{var g=s();if(Yn&&r.defaultChecked!==r.checked){d=!0;return}a?(g=g||[],r.checked=g.includes(r.__value)):r.checked=xi(r.__value,g)}),_i(()=>{var g=i.indexOf(r);g!==-1&&i.splice(g,1)}),uo.has(i)||(uo.add(i),Ea(()=>{i.sort((g,m)=>g.compareDocumentPosition(m)===4?-1:1),uo.delete(i)})),Ea(()=>{if(d){var g;if(a)g=Ma(i,g,r.checked);else{var m=i.find(x=>x.checked);g=m?.__value}o(g)}})}function qn(n,e,r=e){Ys(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Yn&&n.defaultChecked!==n.checked||yr(e)==null)&&r(n.checked),qo(()=>{var s=e();n.checked=!!s})}function Ma(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 fo(n){var e=n.type;return e==="number"||e==="range"}function po(n){return n===""?null:+n}const Mc=!1,Dc=!0,lg=Object.freeze(Object.defineProperty({__proto__:null,prerender:Dc,ssr:Mc},Symbol.toStringTag,{value:"Module"})),ho="Wherever",Lc="Create & maintain apps from wherever with a beautiful remote workspace.",bo="https://localhost",Oc="#000000",Pc="black-translucent";function Vr(n,e){return Sc(n)}var Nc=b('<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 Fc(n,e){Tr(e,!0);const r=bo.endsWith("/")?bo.slice(0,-1):bo,s=r+"/preview.png";let o=H(()=>e.home||!1),a=H(()=>({type:e.type||"website",title:e.title||ho,description:e.description||Lc,image:e.image||s,url:`${r}${Ac.url.pathname}`}));Cc("13n5pl5",i=>{var d=Nc(),v=rn(d),g=f(v,2),m=f(g,2);{var x=Ye=>{var Ee=hr(),Ie=rn(Ee);y(Ie,Ot=>{}),h(Ye,Ee)};y(m,Ye=>{t(o)&&Ye(x)})}var k=f(m,2),M=f(k,2),O=f(M,2),z=f(O,2),Te=f(z,2),Q=f(Te,4),xe=f(Q,2),ke=f(xe,2),de=f(ke,2),Re=f(de,2),we=f(Re,2),Z=f(we,2),ut=f(Z,2),Ft=f(ut,2),Ve=f(Ft,4),at=f(Ve,4),ft=f(at,2),Kt=f(ft,2);I((Ye,Ee,Ie,Ot)=>{Y(v,"content",t(a).title),Y(g,"content",t(a).description),Y(k,"content",t(a).type),Y(M,"content",t(a).url),Y(O,"content",t(a).title),Y(z,"content",t(a).description),Y(Te,"content",t(a).image),Y(Q,"content",t(a).url),Y(xe,"content",t(a).title),Y(ke,"content",t(a).description),Y(de,"content",t(a).image),Y(Re,"href",Ye),Y(we,"href",Ee),Y(Z,"href",Ie),Y(ut,"href",Ot),Y(Ft,"content",Oc),Y(Ve,"content",ho),Y(at,"content",Pc),Y(ft,"content",ho),Y(Kt,"content",Os)},[()=>Vr("/pwa/favicon.png"),()=>Vr("/pwa/favicon.ico"),()=>Vr("/pwa/apple-touch-icon.png"),()=>Vr("/pwa/manifest.webmanifest")]),xc(()=>{_c.title=t(a).title??""}),h(i,d)}),Ar()}let ts=null;function Uc(){if(typeof window>"u")return null;try{if(!ts){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;ts=new n}return ts.state==="suspended"&&ts.resume().catch(()=>{}),ts}catch{return null}}function Da(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const d=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+d),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const La=new Map;function zc(n){if(typeof Audio>"u")return!1;try{let e=La.get(n);e||(e=new Audio(n),e.preload="auto",La.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 Ai(n){if(n&&n.trim()&&zc(n.trim()))return;const e=Uc();if(e)try{const r=e.currentTime;Da(e,1046.5,r,.16,.12),Da(e,1396.9,r+.13,.22,.12)}catch{}}function Vo(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function Rs(n){const e=Vo(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Ps(){}function Bc(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Hc(n,...e){if(n==null)return Ps;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function hn(n){let e;return Hc(n,r=>e=r)(),e}var Wr=[];function jc(n,e=Ps){let r;const s=new Set;function o(d){if(Bc(n,d)&&(n=d,r)){const v=!Wr.length;for(const g of s)g[1](),Wr.push(g,n);if(v){for(let g=0;g<Wr.length;g+=2)Wr[g][0](Wr[g+1]);Wr.length=0}}}function a(d){o(d(n))}function i(d,v=Ps){const g=[d,v];return s.add(g),s.size===1&&(r=e(o)||Ps),d(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}function Oa(){return`ck-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}const vo={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class ir{ws=null;config;clientKey;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;pendingLoadFile=null;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.clientKey=this.config.clientKey||Oa(),this.stateStore=jc({...vo,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(M=>r?{...M,connecting:!0,error:null}:{...vo,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&&a.push(`token=${encodeURIComponent(this.config.token)}`),a.push(`clientKey=${encodeURIComponent(this.clientKey)}`);const i=`${s}://${o}:${this.config.port}/ws?${a.join("&")}`,d=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!d){this.stateStore.update(M=>({...M,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const M=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=M?new d(i,M):new d(i)}catch(M){this.stateStore.update(O=>({...O,connecting:!1,error:`Failed to connect: ${M}`})),this.scheduleReconnect();return}const v=this.ws,g=()=>{if(this.ws!==v)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(Q=>({...Q,connected:!0,connecting:!1,error:null}));const M=hn(this.stateStore),O=this.resumeSessionFile??M.activeSessionFile,z=this.resumeSessionFile!=null?this.resumeCwd:M.activeCwd??void 0,Te=this.resumeSessionFile!=null?this.resumeModel:M.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,O?(this.stateStore.update(Q=>Q.resyncing?Q:{...Q,resyncing:!0}),this.pendingLoadFile=O,this.send({type:"session_load",sessionFile:O,cwd:z,model:Te}),this.armLoadWatchdog()):this.stateStore.update(Q=>Q.resyncing?{...Q,resyncing:!1}:Q)},m=M=>{if(this.ws===v){this.lastInboundAt=Date.now();try{const O=typeof M.data=="string"?M.data:M.data.toString(),z=JSON.parse(O);this.handleMessage(z)}catch(O){console.error("Failed to parse WebSocket message:",O)}}},x=()=>{this.ws===v&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(M=>({...M,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:M.activeSessionFile?!0:M.resyncing})),this.scheduleReconnect())},k=M=>{this.ws===v&&this.stateStore.update(O=>({...O,error:O.error||"Connection error occurred"}))};typeof v.addEventListener=="function"?(v.addEventListener("open",g),v.addEventListener("message",m),v.addEventListener("close",x),v.addEventListener("error",k)):typeof v.on=="function"&&(v.on("open",g),v.on("message",M=>m({data:M})),v.on("close",x),v.on("error",k))}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({...vo,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=hn(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=hn(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||hn(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,ir.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=hn(this.stateStore).isStreaming,a=o?ir.TURN_STALL_MS:ir.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(d=>({...d,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":d.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,ir.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=hn(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."})))},ir.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,hn(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."})))},ir.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>=ir.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=!!hn(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":{const r=hn(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,error:null}));break;case"connection_superseded":this.clientKey=Oa();try{this.config.onClientKeyChange?.(this.clientKey)}catch(s){console.error("onClientKeyChange failed:",s)}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_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(d=>d.role==="thinking"&&d.isStreaming);a&&(o=o.map(d=>d.id===a.id?{...d,isStreaming:!1}:d));const i=[...o].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(i)o=o.map(d=>d.id===i.id?{...d,content:e.content||d.content,isStreaming:!1}:d);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return hn(this.stateStore);const x=o.find(k=>k.role==="user"&&k.restoredFromQueue&&k.content===e.content);if(x)return{...s,messages:o.map(k=>k.id===x.id?{...k,restoredFromQueue:void 0}:k)}}const d=e.role==="user"?Rs(e.content):null;if(d){const m=[...o].reverse().find(x=>x.role==="user"&&Rs(x.content)===d);if(m)return m.content!==e.content&&(o=o.map(x=>x.id===m.id?{...x,content:e.content}:x)),{...s,messages:o}}const v=[...o].reverse().find(m=>m.role==="user");e.role==="user"&&v&&v.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,pendingSteering:[],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(v=>v.isStreaming&&(v.role==="assistant"||v.role==="thinking")?{...v,isStreaming:!1}:v),a=Date.now(),i=!!e.forceCommand;if(i){const v=o.find(g=>g.role==="tool"&&g.optimistic&&g.isStreaming);if(v)return{...s,messages:o.map(g=>g.id===v.id?{...g,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:g)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,d]}});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 co,a as h,c as hr,g as b,d as Dr,e as D,s as N,f as gr,t as Bn,h as Vs}from"../chunks/BeRKnBIj.js";import{as as Yn,b4 as Bs,am as qr,bg as I,aq as Ta,O as sc,aU as oc,ar as Co,d as mi,an as Ro,au as ac,n as ic,a1 as lc,u as cc,t as dc,a2 as uc,W as fc,X as pc,H as hc,b5 as Aa,C as Ca,z as Ra,aF as Ys,a3 as Er,ad as bc,aA as vc,a$ as gc,az as xi,bf as _i,bh as mc,bi as yr,aW as qo,aS as Ea,aR as Tr,aO as Ar,ag as rn,b8 as f,aj as t,a6 as xc,bj as H,$ as _c,bn as En,ai as $n,a9 as bn,aM as ys,b0 as p,Y as c,aX as l,aJ as dt,bb as F,aQ as Gn,bk as Dt,bl as yc,aL as wc,aV as kc,aK as Ia}from"../chunks/Cum3gQOV.js";import{i as y,s as Br,a as De,p as vr}from"../chunks/C8CBGqeA.js";import{a as Sc,b as Y,r as wt,c as yi,e as Rn,i as rr,d as wi}from"../chunks/vSWNc7VF.js";import{_ as Tc,b as sr}from"../chunks/D5t5dKgW.js";import{v as Os}from"../chunks/DdFruy3e.js";import{p as Ac}from"../chunks/CyQq9q8L.js";function $a(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,d="";if(r){var v=n;Yn&&(i=Bs(qr(v)))}I(()=>{var g=sc;if(d===(d=e()??"")){Yn&&Ta();return}if(r&&!Yn){g.nodes=null,v.innerHTML=d,d!==""&&co(qr(v),v.lastChild);return}if(g.nodes!==null&&(oc(g.nodes.start,g.nodes.end),g.nodes=null),d!==""){if(Yn){Co.data;for(var m=Ta(),x=m;m!==null&&(m.nodeType!==mi||m.data!=="");)x=m,m=Ro(m);if(m===null)throw ac(),ic;co(Co,x),i=Bs(m);return}var k=s?cc:o?dc:void 0,M=lc(s?"svg":o?"math":"template",k);M.innerHTML=d;var O=s||o?M:M.content;if(co(qr(O),O.lastChild),s||o)for(;qr(O);)i.before(qr(O));else i.before(O)}})}function Cc(n,e){let r=null,s=Yn;var o;if(Yn){r=Co;for(var a=qr(document.head);a!==null&&(a.nodeType!==mi||a.data!==n);)a=Ro(a);if(a===null)Aa(!1);else{var i=Ro(a);a.remove(),Bs(i)}}Yn||(o=document.head.appendChild(uc()));try{fc(()=>{var d=pc(()=>e(o));d.f|=hc})}finally{s&&(Aa(!0),Bs(r))}}function ki(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=ki(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Rc(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=ki(n))&&(s&&(s+=" "),s+=e);return s}function Si(n){return typeof n=="object"?Rc(n):n??""}function Ec(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Ic(n,e){return n==null?null:String(n)}function cn(n,e,r,s,o,a){var i=n[Ca];if(Yn||i!==r||i===void 0){var d=Ec(r);(!Yn||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[Ca]=r}return a}function $c(n,e,r,s){var o=n[Ra];if(Yn||o!==e){var a=Ic(e);(!Yn||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Ra]=e}return s}function Ko(n,e,r=!1){if(n.multiple){if(e==null)return;if(!vc(e))return gc();for(var s of n.options)s.selected=e.includes(hs(s));return}for(s of n.options){var o=hs(s);if(xi(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Ti(n){var e=new MutationObserver(()=>{Ko(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),_i(()=>{e.disconnect()})}function xs(n,e,r=e){var s=new WeakSet,o=!0;Ys(n,"change",a=>{var i=a?"[selected]":":checked",d;if(n.multiple)d=[].map.call(n.querySelectorAll(i),hs);else{var v=n.querySelector(i)??n.querySelector("option:not([disabled])");d=v&&hs(v)}r(d),n.__value=d,Er!==null&&s.add(Er)}),bc(()=>{var a=e();if(n===document.activeElement){var i=Er;if(s.has(i))return}if(Ko(n,a,o),o&&a===void 0){var d=n.querySelector(":checked");d!==null&&(a=hs(d),r(a))}n.__value=a,o=!1}),Ti(n)}function hs(n){return"__value"in n?n.__value:n.value}function cr(n,e,r=e){var s=new WeakSet;Ys(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=fo(n)?po(a):a,r(a),Er!==null&&s.add(Er),await mc(),a!==(a=e())){var i=n.selectionStart,d=n.selectionEnd,v=n.value.length;if(n.value=a??"",d!==null){var g=n.value.length;i===d&&d===v&&g>v?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=i,n.selectionEnd=Math.min(d,g))}}}),(Yn&&n.defaultValue!==n.value||yr(e)==null&&n.value)&&(r(fo(n)?po(n.value):n.value),Er!==null&&s.add(Er)),qo(()=>{var o=e();if(n===document.activeElement){var a=Er;if(s.has(a))return}fo(n)&&o===po(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const uo=new Set;function Mr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let d=!1;if(e!==null)for(var v of e)i=i[v]??=[];i.push(r),Ys(r,"change",()=>{var g=r.__value;a&&(g=Ma(i,g,r.checked)),o(g)},()=>o(a?[]:null)),qo(()=>{var g=s();if(Yn&&r.defaultChecked!==r.checked){d=!0;return}a?(g=g||[],r.checked=g.includes(r.__value)):r.checked=xi(r.__value,g)}),_i(()=>{var g=i.indexOf(r);g!==-1&&i.splice(g,1)}),uo.has(i)||(uo.add(i),Ea(()=>{i.sort((g,m)=>g.compareDocumentPosition(m)===4?-1:1),uo.delete(i)})),Ea(()=>{if(d){var g;if(a)g=Ma(i,g,r.checked);else{var m=i.find(x=>x.checked);g=m?.__value}o(g)}})}function qn(n,e,r=e){Ys(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Yn&&n.defaultChecked!==n.checked||yr(e)==null)&&r(n.checked),qo(()=>{var s=e();n.checked=!!s})}function Ma(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 fo(n){var e=n.type;return e==="number"||e==="range"}function po(n){return n===""?null:+n}const Mc=!1,Dc=!0,lg=Object.freeze(Object.defineProperty({__proto__:null,prerender:Dc,ssr:Mc},Symbol.toStringTag,{value:"Module"})),ho="Wherever",Lc="Create & maintain apps from wherever with a beautiful remote workspace.",bo="https://localhost",Oc="#000000",Pc="black-translucent";function Vr(n,e){return Sc(n)}var Nc=b('<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 Fc(n,e){Tr(e,!0);const r=bo.endsWith("/")?bo.slice(0,-1):bo,s=r+"/preview.png";let o=H(()=>e.home||!1),a=H(()=>({type:e.type||"website",title:e.title||ho,description:e.description||Lc,image:e.image||s,url:`${r}${Ac.url.pathname}`}));Cc("13n5pl5",i=>{var d=Nc(),v=rn(d),g=f(v,2),m=f(g,2);{var x=Ye=>{var Ee=hr(),Ie=rn(Ee);y(Ie,Ot=>{}),h(Ye,Ee)};y(m,Ye=>{t(o)&&Ye(x)})}var k=f(m,2),M=f(k,2),O=f(M,2),z=f(O,2),Te=f(z,2),Q=f(Te,4),xe=f(Q,2),ke=f(xe,2),de=f(ke,2),Re=f(de,2),we=f(Re,2),Z=f(we,2),ut=f(Z,2),Ft=f(ut,2),Ve=f(Ft,4),at=f(Ve,4),ft=f(at,2),Kt=f(ft,2);I((Ye,Ee,Ie,Ot)=>{Y(v,"content",t(a).title),Y(g,"content",t(a).description),Y(k,"content",t(a).type),Y(M,"content",t(a).url),Y(O,"content",t(a).title),Y(z,"content",t(a).description),Y(Te,"content",t(a).image),Y(Q,"content",t(a).url),Y(xe,"content",t(a).title),Y(ke,"content",t(a).description),Y(de,"content",t(a).image),Y(Re,"href",Ye),Y(we,"href",Ee),Y(Z,"href",Ie),Y(ut,"href",Ot),Y(Ft,"content",Oc),Y(Ve,"content",ho),Y(at,"content",Pc),Y(ft,"content",ho),Y(Kt,"content",Os)},[()=>Vr("/pwa/favicon.png"),()=>Vr("/pwa/favicon.ico"),()=>Vr("/pwa/apple-touch-icon.png"),()=>Vr("/pwa/manifest.webmanifest")]),xc(()=>{_c.title=t(a).title??""}),h(i,d)}),Ar()}let ts=null;function Uc(){if(typeof window>"u")return null;try{if(!ts){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;ts=new n}return ts.state==="suspended"&&ts.resume().catch(()=>{}),ts}catch{return null}}function Da(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const d=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+d),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const La=new Map;function zc(n){if(typeof Audio>"u")return!1;try{let e=La.get(n);e||(e=new Audio(n),e.preload="auto",La.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 Ai(n){if(n&&n.trim()&&zc(n.trim()))return;const e=Uc();if(e)try{const r=e.currentTime;Da(e,1046.5,r,.16,.12),Da(e,1396.9,r+.13,.22,.12)}catch{}}function Vo(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function Rs(n){const e=Vo(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Ps(){}function Bc(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Hc(n,...e){if(n==null)return Ps;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function hn(n){let e;return Hc(n,r=>e=r)(),e}var Wr=[];function jc(n,e=Ps){let r;const s=new Set;function o(d){if(Bc(n,d)&&(n=d,r)){const v=!Wr.length;for(const g of s)g[1](),Wr.push(g,n);if(v){for(let g=0;g<Wr.length;g+=2)Wr[g][0](Wr[g+1]);Wr.length=0}}}function a(d){o(d(n))}function i(d,v=Ps){const g=[d,v];return s.add(g),s.size===1&&(r=e(o)||Ps),d(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}function Oa(){return`ck-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}const vo={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class ir{ws=null;config;clientKey;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;pendingLoadFile=null;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.clientKey=this.config.clientKey||Oa(),this.stateStore=jc({...vo,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(M=>r?{...M,connecting:!0,error:null}:{...vo,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&&a.push(`token=${encodeURIComponent(this.config.token)}`),a.push(`clientKey=${encodeURIComponent(this.clientKey)}`);const i=`${s}://${o}:${this.config.port}/ws?${a.join("&")}`,d=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!d){this.stateStore.update(M=>({...M,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const M=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=M?new d(i,M):new d(i)}catch(M){this.stateStore.update(O=>({...O,connecting:!1,error:`Failed to connect: ${M}`})),this.scheduleReconnect();return}const v=this.ws,g=()=>{if(this.ws!==v)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(Q=>({...Q,connected:!0,connecting:!1,error:null}));const M=hn(this.stateStore),O=this.resumeSessionFile??M.activeSessionFile,z=this.resumeSessionFile!=null?this.resumeCwd:M.activeCwd??void 0,Te=this.resumeSessionFile!=null?this.resumeModel:M.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,O?(this.stateStore.update(Q=>Q.resyncing?Q:{...Q,resyncing:!0}),this.pendingLoadFile=O,this.send({type:"session_load",sessionFile:O,cwd:z,model:Te}),this.armLoadWatchdog()):this.stateStore.update(Q=>Q.resyncing?{...Q,resyncing:!1}:Q)},m=M=>{if(this.ws===v){this.lastInboundAt=Date.now();try{const O=typeof M.data=="string"?M.data:M.data.toString(),z=JSON.parse(O);this.handleMessage(z)}catch(O){console.error("Failed to parse WebSocket message:",O)}}},x=()=>{this.ws===v&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(M=>({...M,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:M.activeSessionFile?!0:M.resyncing})),this.scheduleReconnect())},k=M=>{this.ws===v&&this.stateStore.update(O=>({...O,error:O.error||"Connection error occurred"}))};typeof v.addEventListener=="function"?(v.addEventListener("open",g),v.addEventListener("message",m),v.addEventListener("close",x),v.addEventListener("error",k)):typeof v.on=="function"&&(v.on("open",g),v.on("message",M=>m({data:M})),v.on("close",x),v.on("error",k))}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({...vo,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=hn(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=hn(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||hn(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,ir.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=hn(this.stateStore).isStreaming,a=o?ir.TURN_STALL_MS:ir.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(d=>({...d,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":d.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,ir.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=hn(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."})))},ir.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,hn(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."})))},ir.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>=ir.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=!!hn(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":{const r=hn(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,error:null}));break;case"connection_superseded":this.clientKey=Oa();try{this.config.onClientKeyChange?.(this.clientKey)}catch(s){console.error("onClientKeyChange failed:",s)}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_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(d=>d.role==="thinking"&&d.isStreaming);a&&(o=o.map(d=>d.id===a.id?{...d,isStreaming:!1}:d));const i=[...o].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(i)o=o.map(d=>d.id===i.id?{...d,content:e.content||d.content,isStreaming:!1}:d);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return hn(this.stateStore);const x=o.find(k=>k.role==="user"&&k.restoredFromQueue&&k.content===e.content);if(x)return{...s,messages:o.map(k=>k.id===x.id?{...k,restoredFromQueue:void 0}:k)}}const d=e.role==="user"?Rs(e.content):null;if(d){const m=[...o].reverse().find(x=>x.role==="user"&&Rs(x.content)===d);if(m)return m.content!==e.content&&(o=o.map(x=>x.id===m.id?{...x,content:e.content}:x)),{...s,messages:o}}const v=[...o].reverse().find(m=>m.role==="user");e.role==="user"&&v&&v.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,pendingSteering:[],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(v=>v.isStreaming&&(v.role==="assistant"||v.role==="thinking")?{...v,isStreaming:!1}:v),a=Date.now(),i=!!e.forceCommand;if(i){const v=o.find(g=>g.role==="tool"&&g.optimistic&&g.isStreaming);if(v)return{...s,messages:o.map(g=>g.id===v.id?{...g,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:g)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,d]}});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(d=>{const v=d.messages.find(m=>m.role==="tool"&&m.toolName===e.toolName&&m.isStreaming)??[...d.messages].reverse().find(m=>m.role==="tool"&&m.toolName===e.toolName&&!m.content.startsWith("Tool error:")),g=Date.now();if(v){const m=a?"Error: ":"";return{...d,messages:d.messages.map(x=>x.id===v.id?{...x,content:`${m}${x.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...i?{images:i}:{},endedAt:g}:x)}}else{const m=a?`Tool error: ${e.toolName}
|
|
@@ -107,4 +107,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
107
107
|
${t(O)[t(Je)]?"▲":"▼"}`)),D("click",on,()=>t(O)[t(Je)]=!t(O)[t(Je)]),h(Be,kt)};y(Jt,Be=>{t(ct).length>0&&Be(fn)})}var An=f(Jt,2);{var Cn=Be=>{var kt=cv(),on=c(kt);l(kt),I(Mn=>{Y(kt,"title",Mn),N(on,`+${t(K).otherHits??""} more match${t(K).otherHits===1?"":"es"} in this
|
|
108
108
|
conversation`)},[()=>Vb(t(K).snippet)]),h(Be,kt)};y(An,Be=>{t(K).otherHits>0&&Be(Cn)})}l(zt),I((Be,kt)=>{N(dn,Be),N(sn,kt)},[()=>Yb(t(K).kind,t(K).tool),()=>gi(t(K).ts)]),h(X,zt)}),I(()=>N(q,`${t(x).hits.length??""} result${t(x).hits.length===1?"":"s"} `)),h(re,J)};y(it,re=>{t(Oe)?re(St):t(k)&&!t(x)?re(Pt,1):t(x)?.status==="not-indexed"?re(Ut,2):t(x)?.status==="unavailable"||t(x)?.status==="error"?re(ve,3):t(x)&&t(x).hits.length===0?re(pt,4):t(x)&&re(ue,5)})}l(gn),l(ft),I(()=>{Y(Ee,"placeholder",v()?"Search read-only conversations...":"Search all conversations..."),wi(Ee,t(m)),cn(Ot,1,Si(t(k)?"animate-pulse":""))}),gr("submit",Ye,ut),D("input",Ee,re=>we(re.currentTarget.value)),h(n,ft),Ar(),i()}Dr(["click","input"]);var hv=b(`<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
|
|
109
109
|
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 bv(n,e){Tr(e,!0);const r=()=>De(yl,"$sudoPrompt",s),[s,o]=Br();let a=H(r),i=F(""),d=F(null),v=F(null);Dt(()=>{const z=t(a)?.promptId??null;z!==t(v)&&(p(v,z,!0),p(i,""),z&&queueMicrotask(()=>t(d)?.focus()))});function g(){t(a)&&(pl(t(i)),p(i,""))}function m(){hl(),p(i,"")}function x(z){z.key==="Enter"?(z.preventDefault(),g()):z.key==="Escape"&&(z.preventDefault(),m())}var k=hr(),M=rn(k);{var O=z=>{var Te=hv(),Q=c(Te),xe=f(c(Q),4),ke=c(xe,!0);l(xe);var de=f(xe,2);wt(de),sr(de,ut=>p(d,ut),()=>t(d));var Re=f(de,2),we=c(Re),Z=f(we,2);l(Re),l(Q),l(Te),I(()=>N(ke,t(a).command)),D("keydown",de,x),cr(de,()=>t(i),ut=>p(i,ut)),D("click",we,m),D("click",Z,g),h(z,Te)};y(M,z=>{t(a)&&z(O)})}h(n,k),Ar(),o()}Dr(["keydown","click"]);function vv(n){return n.loading||n.resyncing||n.hasSessionHash}function gv(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!vv(n)}var mv=b('<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>'),xv=b('<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),_v=b('<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),yv=b('<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>'),wv=b('<span class="text-brand-text-muted/70"> </span>'),kv=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),Sv=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),Tv=b('<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>'),Av=b('<div class="mt-2 text-xs text-rose-400"> </div>'),Cv=b('<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="Search everything ever said in any session"><span>🔎</span> <span>Search conversations</span> <span class="ml-auto">→</span></button> <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>',1),Rv=b('<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 the session list"><span>←</span> <span> </span></button>'),Ev=b('<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> <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="Search the read-only conversations"><span>🔎</span> <span>Search these conversations</span> <span class="ml-auto">→</span></button>',1),Iv=b('<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"> <!></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),$v=b('<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>'),Mv=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Dv=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Lv=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Ov=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),Pv=b('<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>'),Nv=b("<option> </option>"),Fv=b('<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>'),Uv=b('<span class="truncate text-brand-text-muted"> </span>'),zv=b('<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>'),Bv=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Hv=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),jv=b('<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>'),Wv=b('<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>'),Gv=b('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),qv=b('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),Kv=b('<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>'),Vv=b('<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>'),Yv=b('<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>'),Xv=b('<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>'),Zv=b('<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>'),Qv=b("<!> <!>",1),Jv=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),eg=b('<!> <!> <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 cg(n,e){Tr(e,!0);const r=()=>De(Ss,"$isConnected",Q),s=()=>De(no,"$isResyncing",Q),o=()=>De(kl,"$isAgentPending",Q),a=()=>De(Ts,"$isLoadingSession",Q),i=()=>De(ml,"$isInterrupted",Q),d=()=>De(ia,"$sessionError",Q),v=()=>De(_l,"$sessionNotice",Q),g=()=>De(gl,"$folderConflict",Q),m=()=>De(to,"$isReadOnly",Q),x=()=>De(es,"$activeSessionInfo",Q),k=()=>De(vn,"$piState",Q),M=()=>De(Zr,"$availableModels",Q),O=()=>De(wl,"$isCreatingSession",Q),z=()=>De(Xo,"$searchFolderStore",Q),Te=()=>De(Mi,"$searchDefaultModelStore",Q),[Q,xe]=Br();let ke=F(!1),de=F("main"),Re=F(!1),we=F("");function Z(R,P=""){p(Re,R,!0),p(we,P,!0),p(de,"search")}let ut=F(!1),Ft;ys(()=>{setTimeout(()=>Ur(),200);const R=()=>{if(t(Ee)){const he=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";he&&he!==t(J)?ks(he):!he&&t(J)&&lr()}};window.addEventListener("hashchange",R);let P=null;const ae=8e3,le=()=>{if(document.visibilityState==="hidden"){if(el())return;P&&clearTimeout(P),P=setTimeout(()=>{P=null,document.visibilityState==="hidden"&&t(Ee)&&Qi()},ae)}else oa(),P&&(clearTimeout(P),P=null),t(Ee)||(Do()?Mo():Ur())},Pe=he=>{P&&(clearTimeout(P),P=null),document.visibilityState!=="hidden"&&!t(Ee)&&(Do()?Mo():Ur())};return document.addEventListener("visibilitychange",le),window.addEventListener("pageshow",Pe),()=>{window.removeEventListener("hashchange",R),document.removeEventListener("visibilitychange",le),window.removeEventListener("pageshow",Pe),P&&clearTimeout(P)}});function Ve(){Ur()}function at(){lr(),_s()}function ft(){_s(),setTimeout(()=>Ur(),100)}function Kt(){bs()}function Ye(){typeof window<"u"&&(window.location.hash=""),lr(),p(ke,!1)}let Ee=H(r),Ie=H(s),Ot=H(o),gn=H(a),it=H(i),St=H(d),Oe=H(v),Pt=H(g),Ut=H(m),ve=H(x),pt=H(k),ue=H(()=>M().models),re=F(!1),J=H(()=>t(ve).sessionId);Dt(()=>{typeof window<"u"&&t(Ee)&&(t(J)?(window.location.hash=encodeURIComponent(t(J)),p(re,!0)):t(re)&&(p(re,!1),window.location.hash&&(window.location.hash="")))});let Qe=null;Dt(()=>{if(!t(Ee)||typeof window>"u"||!window.location.hash)return;const R=decodeURIComponent(window.location.hash.slice(1));R&&(t(J)===R||t(gn)||t(Ie)||Qe||(Qe=setTimeout(()=>{Qe=null,!(t(J)===R||t(gn)||t(Ie))&&ol(R)},300)))}),Dt(()=>{t(Ee)||p(re,!1)}),Dt(()=>{(t(J)||t(gn)||t(Ie))&&p(ke,!1)});let je=H(O),q=H(z),rt=F(void 0),ee=H(()=>gv({connected:t(Ee),searchConfigured:!!t(q),hasSession:!!t(ve).sessionFile,loading:t(gn),resyncing:t(Ie),hasSessionHash:typeof window<"u"&&!!window.location.hash})),Xt=H(()=>t(ue).map(R=>({value:`${R.provider}:${R.modelId}`,label:`${R.label}${R.isDefault?" (default)":""}`}))),lt=H(Te),S=F("");Dt(()=>{if(t(Xt).length===0||t(Xt).some(le=>le.value===t(S)))return;const P=t(Xt).find(le=>le.value===t(lt)),ae=t(ue).find(le=>le.isDefault);p(S,P?P.value:ae?`${ae.provider}:${ae.modelId}`:t(Xt)[0].value,!0)});let X=F(!1);Dt(()=>{t(ee)&&!t(X)&&t(rt)&&(p(X,!0),t(rt).focusInput())});function K(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),lr(),t(rt)?.focusInput()}var fe=eg(),Je=rn(fe);Fc(Je,{title:"Wherever",description:"Create & maintain apps from wherever"});var bt=f(Je,2);{var ct=R=>{var P=mv();h(R,P)};y(bt,R=>{t(je)&&R(ct)})}var zt=f(bt,2),Wt=c(zt),Bt=c(Wt),dn=c(Bt),Gt=c(dn);{var sn=R=>{var P=xv(),ae=f(rn(P),2);D("click",ae,()=>p(ut,!1)),h(R,P)},Qt=R=>{var P=_v(),ae=rn(P),le=c(ae);dt(2),l(ae);var Pe=f(ae,2),he=c(Pe),ce=f(he,2);l(Pe),I($e=>Y(le,"src",$e),[()=>Vr("/logo.svg")]),D("click",ae,Ye),D("click",he,()=>p(ut,!0)),D("click",ce,()=>p(ke,!1)),h(R,P)};y(Gt,R=>{t(ut)?R(sn):R(Qt,-1)})}l(dn),l(Bt);var un=f(Bt,2);{var xn=R=>{var P=yv(),ae=c(P);{let Ne=H(()=>(t(pt).connected,"localhost"));Hd(ae,{get host(){return t(Ne)},port:31415,token:"",onConnected:Ve})}var le=f(ae,2),Pe=f(c(le),2),he=c(Pe),ce=f(he,2),$e=f(ce,2);l(Pe),l(le),l(P),D("click",he,Kt),D("click",ce,ft),D("click",$e,at),h(R,P)},Tn=R=>{var P=Iv(),ae=rn(P),le=c(ae),Pe=c(le),he=f(Pe,2),ce=c(he,!0);l(he);var $e=f(he,2),Ne=c($e),_t=f(Ne);{var Ht=T=>{var j=wv(),be=c(j);l(j),I(()=>N(be,` / srv ${t(pt).serverVersion??""}`)),h(T,j)};y(_t,T=>{t(pt).serverVersion&&T(Ht)})}l($e),l(le);var en=f(le,2);{var te=T=>{var j=Tv(),be=c(j);{var We=At=>{var $=kv(),u=c($);l($),I(_=>{Y($,"title",t(ve).cwd),N(u,`📁 ${_??""}`)},[()=>t(ve).cwd.split("/").pop()||t(ve).cwd]),h(At,$)};y(be,At=>{t(ve).cwd&&At(We)})}var mt=f(be,2);{var w=At=>{var $=Sv(),u=c($);l($),I(()=>{Y($,"title",t(ve).model),N(u,`🤖 ${t(ve).model??""}`)}),h(At,$)};y(mt,At=>{t(ve).model&&At(w)})}var Ue=f(mt,2),It=c(Ue);l(Ue),l(j),D("click",It,Ye),h(T,j)};y(en,T=>{t(ve).sessionFile&&T(te)})}var Ae=f(en,2);{var B=T=>{var j=Av(),be=c(j,!0);l(j),I(()=>N(be,t(pt).error)),h(T,j)};y(Ae,T=>{t(pt).error&&!t(Ee)&&T(B)})}l(ae);var ie=f(ae,2),Ce=c(ie);{var me=T=>{var j=Cv(),be=rn(j),We=f(be,2);D("click",be,()=>Z(!1)),D("click",We,()=>{p(de,"readonly"),Ei()}),h(T,j)},qe=T=>{var j=Rv(),be=f(c(j),2),We=c(be);l(be),l(j),I(()=>N(We,`Back to ${t(Re)?"read-only sessions":"sessions"}`)),D("click",j,()=>p(de,t(Re)?"readonly":"main",!0)),h(T,j)},vt=T=>{var j=Ev(),be=rn(j),We=f(be,2);D("click",be,()=>p(de,"main")),D("click",We,()=>Z(!0)),h(T,j)};y(Ce,T=>{t(de)==="main"?T(me):t(de)==="search"?T(qe,1):T(vt,-1)})}l(ie);var gt=f(ie,2),Vt=c(gt);{var an=T=>{pv(T,{get readOnly(){return t(Re)},get initialQuery(){return t(we)},onOpened:()=>p(ke,!1)})},Fn=T=>{vi(T,{readOnly:!0,onSearchAll:j=>Z(!0,j)})},E=T=>{vi(T,{onSearchAll:j=>Z(!1,j)})};y(Vt,T=>{t(de)==="search"?T(an):t(de)==="readonly"?T(Fn,1):T(E,-1)})}l(gt),I(()=>{cn(Pe,1,`h-2.5 w-2.5 rounded-full ${t(Ee)?"bg-emerald-500":"bg-rose-500"}`),cn(he,1,`text-sm ${t(Ee)?"text-emerald-400":"text-rose-400"}`),N(ce,t(Ee)?"Connected":"Disconnected"),Y($e,"title",t(pt).serverVersion?`App build ${Os} · server ${t(pt).serverVersion}`:`App build ${Os}`),N(Ne,`v${Os}`)}),h(R,P)};y(un,R=>{t(ut)?R(xn):R(Tn,-1)})}l(Wt);var mn=f(Wt,2),Jt=c(mn),fn=c(Jt),An=f(fn,2);{var Cn=R=>{var P=$v();D("click",P,K),h(R,P)};y(An,R=>{t(Ee)&&t(q)&&t(ve).sessionFile&&R(Cn)})}var Be=f(An,2);{var kt=R=>{var P=Ov(),ae=c(P);{var le=ce=>{var $e=Mv();h(ce,$e)},Pe=ce=>{var $e=Dv();h(ce,$e)},he=ce=>{var $e=Lv();h(ce,$e)};y(ae,ce=>{t(Ee)&&t(ee)?ce(le):t(Ee)?ce(Pe,1):ce(he,-1)})}l(P),h(R,P)};y(Be,R=>{(!t(Ee)||!t(ve).sessionFile)&&R(kt)})}var on=f(Be,2);{var Mn=R=>{var P=Bv(),ae=c(P);{var le=ce=>{var $e=Pv(),Ne=f(c($e),2),_t=c(Ne,!0);l(Ne),l($e),I(Ht=>{Y(Ne,"title",t(ve).cwd),N(_t,Ht)},[()=>t(ve).cwd.split("/").pop()||t(ve).cwd]),h(ce,$e)};y(ae,ce=>{t(ve).cwd&&ce(le)})}var Pe=f(ae,2);{var he=ce=>{var $e=zv(),Ne=c($e),_t=f(c(Ne),2);l(Ne);var Ht=f(Ne,2);{var en=Ae=>{var B=Fv();Rn(B,21,()=>t(ue),rr,(Ce,me)=>{var qe=Nv(),vt=c(qe,!0);l(qe);var gt={};I(()=>{N(vt,t(me).label),gt!==(gt=`${t(me).provider}:${t(me).modelId}`)&&(qe.value=qe.__value=`${t(me).provider}:${t(me).modelId}`)}),h(Ce,qe)}),l(B);var ie;Ti(B),I(()=>{ie!==(ie=t(ve).model)&&(B.value=(B.__value=t(ve).model)??"",Ko(B,t(ve).model))}),D("input",B,Ce=>bl(Ce.currentTarget.value)),h(Ae,B)},te=Ae=>{var B=Uv(),ie=c(B,!0);l(B),I(()=>{Y(B,"title",t(ve).model),N(ie,t(ve).model)}),h(Ae,B)};y(Ht,Ae=>{t(ue).length>0&&!t(Ut)?Ae(en):Ae(te,-1)})}l($e),I(()=>{cn(_t,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"}`),Y(_t,"title",t(pt).isStreaming?"Agent working...":"Ready")}),h(ce,$e)};y(Pe,ce=>{t(ve).model&&ce(he)})}l(P),h(R,P)};y(on,R=>{t(ve).sessionFile&&R(Mn)})}var Hn=f(on,2);{var A=R=>{var P=Hv();h(R,P)};y(Hn,R=>{t(Ut)&&R(A)})}l(Jt);var G=f(Jt,2);{var pe=R=>{var P=jv();h(R,P)};y(G,R=>{t(it)&&R(pe)})}var Xe=f(G,2);{var et=R=>{var P=Wv(),ae=c(P),le=c(ae,!0);l(ae);var Pe=f(ae,2);l(P),I(()=>{cn(P,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(Oe).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),N(le,t(Oe).message)}),D("click",Pe,()=>fl()),h(R,P)};y(Xe,R=>{t(Oe)&&R(et)})}var C=f(Xe,2);{var L=R=>{var P=qv(),ae=c(P),le=f(c(ae));{var Pe=Ne=>{var _t=Bn("You are both working in it — changes may conflict.");h(Ne,_t)},he=Ne=>{var _t=Bn("You are observing (read-only) to avoid clashing.");h(Ne,_t)};y(le,Ne=>{t(Pt).continued?Ne(Pe):Ne(he,-1)})}l(ae);var ce=f(ae,2);{var $e=Ne=>{var _t=Gv();D("click",_t,()=>cl()),h(Ne,_t)};y(ce,Ne=>{t(Pt).continued||Ne($e)})}l(P),h(R,P)};y(C,R=>{t(Pt)?.active&&R(L)})}var V=f(C,2);{var oe=R=>{var P=Kv(),ae=c(P),le=c(ae,!0);l(ae);var Pe=f(ae,2);l(P),I(()=>N(le,t(St))),D("click",Pe,()=>Ir()),h(R,P)};y(V,R=>{t(St)&&R(oe)})}var _e=f(V,2);{var Et=R=>{var P=Vv();h(R,P)};y(_e,R=>{t(Ut)&&!t(it)&&!(t(Pt)?.active&&!t(Pt).continued)&&R(Et)})}var Tt=f(_e,2);sr(xh(Tt,{onMessageSent:()=>{}}),R=>Ft=R,()=>Ft);var Zt=f(Tt,2);{var st=R=>{var P=Yv();h(R,P)},ht=R=>{var P=Qv(),ae=rn(P);{var le=ce=>{var $e=Xv();h(ce,$e)},Pe=ce=>{var $e=Zv();h(ce,$e)};y(ae,ce=>{t(ve).sessionFile&&(t(Ie)||!t(Ee))?ce(le):t(ve).sessionFile&&t(Ot)&&ce(Pe,1)})}var he=f(ae,2);{let ce=H(()=>!!t(q)),$e=H(()=>t(ee)?!t(Ee):!t(Ee)||t(Ut)||!t(ve).sessionFile||t(Ie)||t(Ot));sr(ab(he,{get searchMode(){return t(ee)},get searchConfigured(){return t(ce)},get searchModels(){return t(Xt)},onSubmit:(Ne,_t)=>il(Ne,t(S),_t),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t($e)},onSend:()=>Ft?.forceScrollToBottom(),get searchModel(){return t(S)},set searchModel(Ne){p(S,Ne,!0)}}),Ne=>p(rt,Ne,!0),()=>t(rt))}h(R,P)};y(Zt,R=>{t(Ut)&&t(ve).sessionFile?R(st):R(ht,-1)})}l(mn);var yn=f(mn,2);bv(yn,{});var Fe=f(yn,2);{var Se=R=>{var P=Jv();D("click",P,()=>p(ke,!1)),h(R,P)};y(Fe,R=>{t(ke)&&R(Se)})}l(zt),I(()=>cn(Wt,1,`app-chrome ${t(ke)?"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`)),D("click",fn,()=>p(ke,!t(ke))),h(n,fe),Ar(),xe()}Dr(["click","input"]);export{cg as component,lg as universal};
|
|
110
|
-
//# sourceMappingURL=2.
|
|
110
|
+
//# sourceMappingURL=2.C6-6KHYk.js.map
|