@rubytech/taskmaster 1.0.34 → 1.0.36

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.34",
3
- "commit": "9d9f0a075ff62bb27bc61f36fb5a253ea6d3be13",
4
- "builtAt": "2026-02-16T10:24:26.564Z"
2
+ "version": "1.0.36",
3
+ "commit": "ac42e03b14c6894ebc92dd1ab16bd5aaecf9f127",
4
+ "builtAt": "2026-02-16T10:28:36.178Z"
5
5
  }
@@ -1355,13 +1355,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1355
1355
  If the npm package was not removed automatically, run:
1356
1356
  </p>
1357
1357
  <code style="display: block; font-size: 12px; background: rgba(255,255,255,0.06); padding: 8px 12px; border-radius: 4px; margin: 0 0 16px 0;">sudo npm uninstall -g @rubytech/taskmaster</code>
1358
- <button
1359
- class="setup-button secondary"
1360
- style="font-size: 12px;"
1361
- @click=${e.onUninstallDismiss}
1362
- >
1363
- Dismiss
1364
- </button>
1358
+ <p style="font-size: 12px; color: var(--tasker-text-grey); margin: 0;">You can close this tab.</p>
1365
1359
  </div>
1366
1360
  </div>
1367
1361
  `;if(!t){const o=e.updateRunning;return d`
@@ -2859,4 +2853,4 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2859
2853
  `}const Eo="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function vc(){try{return localStorage.getItem(Eo)}catch{return null}}function bc(e){try{localStorage.setItem(Eo,e)}catch{}}function $y(){try{localStorage.removeItem(Eo)}catch{}}async function va(e){if(e.client)try{const t=vc(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function Ey(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(bc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Ty(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(bc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function Cy(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function _y(e){const t=vc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}$y(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Li(e){return(await e.request("apikeys.list")).providers??[]}async function ba(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function My(e,t){await e.request("apikeys.remove",{provider:t})}class Ly{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){n?.deviceWidth&&(this.deviceWidth=n.deviceWidth),n?.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,o=this.canvas.height/s.height,r=this.deviceWidth/this.canvas.width,l=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*r),y:Math.round(n*o*l)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let ti=null;function Bn(){return ti||(ti=new Ly),ti}function To(e){return e instanceof Error?e.message:String(e)}async function Py(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserError=null;try{(await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720}))?.ok&&(e.browserScreencastActive=!0)}catch(t){e.browserError=To(t)}finally{e.browserLoading=!1}}}async function Ry(e){if(!(!e.client||!e.connected)){e.browserLoading=!0;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=To(t)}finally{e.browserLoading=!1}}}async function ni(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function si(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s?.text?{text:s.text}:{},...s?.code?{code:s.code}:{},...s?.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function Iy(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=To(t)}}function Ny(e){e.browserInputMode=!e.browserInputMode}function Dy(e,t){if(!t?.data)return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function Oy(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function By(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function Fe(e){return e instanceof Error?e.message:String(e)}let Ln=null;function sn(e,t){Ln&&clearTimeout(Ln),e.filesMessage={kind:"success",text:t},Ln=setTimeout(()=>{e.filesMessage=null,Ln=null},3e3)}async function on(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const s=await e.client.request("files.tree",n);s?.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Fe(n)}finally{e.filesLoading=!1}}}}async function Fy(e,t,n){e.filesSelectedPaths=new Set([t]),await wc(e,t,n)}async function Uy(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await wc(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Wy(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const o of n)try{await kc(e,o,t),s++}catch(r){i=Fe(r)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:sn(e,`${s} file${s!==1?"s":""} downloaded`)}async function Ky(e,t,n,s){const i=t.split("/").pop()??t,o=n==="."?i:`${n}/${i}`;o!==t&&await Sc(e,t,o,s)}async function wc(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=i?.content??null,e.filesPreviewBinary=i?.binary??!1,e.filesPreviewSize=i?.size??null}catch(s){e.filesError=Fe(s)}finally{e.filesPreviewLoading=!1}}}async function kc(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!i?.base64){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),r=new Blob([o]),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=i.name??t.split("/").pop()??"download",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}async function zy(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,o="";for(const r of n)try{const l=await r.arrayBuffer(),a=btoa(new Uint8Array(l).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:r.name,data:a};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(l){o=Fe(l)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${o}`:o}:sn(e,`${i} file${i!==1?"s":""} uploaded`),await on(e,s)}async function jy(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),sn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await on(e,n)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}}async function Sc(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),sn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await on(e,s)}catch(i){e.filesMessage={kind:"error",text:Fe(i)}}}}async function xc(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s?.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function Hy(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const s=await e.client.request("memory.reindex",n),i=s?.files??0,o=s?.chunks??0;sn(e,`Re-indexed: ${i} files, ${o} chunks`),await xc(e,t)}catch(n){e.filesMessage={kind:"error",text:Fe(n)}}finally{e.filesReindexBusy=!1}}}function qy(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}function Gy(e,t="admin"){if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const i of n){if(!i||typeof i!="object"||i.agentId!==t)continue;const o=i.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const a=l.id??"";a&&s.push({phone:a,paired:i.meta?.paired===!0})}return s.sort((i,o)=>i.paired&&!o.paired?-1:!i.paired&&o.paired?1:0),s}function Ac(e,t,n="admin",s){const i=new Map,o=new Map;for(const a of e){if(!a||typeof a!="object"||a.agentId!==n)continue;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")continue;const p=c.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const m=p.id??"";m&&(a.meta&&i.set(m,a.meta),c.accountId&&o.set(m,c.accountId))}const r=e.filter(a=>{if(!a||typeof a!="object"||a.agentId!==n)return!0;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")return!0;const p=c.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(a=>{const c=s??o.get(a.phone),u={channel:"whatsapp",peer:{kind:"dm",id:a.phone}};c&&(u.accountId=c);const p={agentId:n,match:u},m=i.get(a.phone);return m?p.meta=m:a.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function fs(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=De(i??{}),e.adminPhones=Gy(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function $c(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let o=t.trim();if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number format. Use E.164 format (e.g., +14155552671)";return}if(e.adminPhones.some(r=>r.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const r=De(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=[...e.adminPhones,{phone:o}],c=Ac(l,a,i,s);za(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Ye(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}async function Ec(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;if(e.adminPhones.find(r=>r.phone===t)?.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const r=De(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=e.adminPhones.filter(m=>m.phone!==t),c=Ac(l,a,i,s);za(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Ye(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}const Vy=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:$c,loadAdmins:fs,removeAdmin:Ec},Symbol.toStringTag,{value:"Module"}));async function et(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function Tc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.trim();const o=n.trim();if(!i){e.customersError="Phone number is required";return}if(!o){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number format. Use E.164 (e.g. +447490553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:o,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await et(e,s)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}async function Cc(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await et(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function _c(e,t,n,s,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:s}),await et(e,i)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}}async function Mc(e,t,n,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await et(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const Yy=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:Tc,deleteCustomer:Cc,deleteCustomerField:Mc,loadCustomers:et,setCustomerField:_c},Symbol.toStringTag,{value:"Module"}));function Ut(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function Qy(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),onAddAccount:()=>{e.addingWorkspace=!0},hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function Xy(e){const t=J(e);return t?t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin")?.id:void 0}function Zy(e){return J(e)?.whatsappAccountId??void 0}function Jy(e){const t=J(e);if(t)return t.agents[0]?.id}function ev(e){return e.selectedWorkspace??void 0}function J(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const tv=/^data:/i,nv=/^https?:\/\//i;function sv(e){const t=e.agentsList?.agents??[],s=La(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",o=t.find(l=>l.id===s)?.identity,r=o?.avatarUrl??o?.avatar;if(r)return tv.test(r)||nv.test(r)?r:o?.avatarUrl}function iv(e){if(!e)return null;const t=e.channelAccounts?.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function ov(e){if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=e.channelAccounts?.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],s=n.running??!1,i=n.probe,o=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function rv(e){const t=e.configSnapshot?.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(r=>r.match?.channel==="imessage"&&r.meta?.imessageOwner);if(!s)return null;const i=s.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===i))return r.name;if(i==="admin"||i==="public")return e.workspaces.find(l=>l.isDefault)?.name??null;const o=i.replace(/-(admin|public)$/,"");return o!==i?e.workspaces.find(l=>l.name===o)?.name??null:null}function av(e){if(e.connected&&e.accessState.checked){const{accessState:t}=e;if(t.hasPins&&!t.authenticated)return ya({show:!0,isFirstTime:!1,accounts:t.accounts,error:t.error,busy:t.busy,onSubmit:(n,s)=>{s!=null&&e.handlePinSubmit(n,s)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(n,s,i)=>e.handleChangePin(n,s,i)});if(!t.hasMasterPin&&!t.authenticated&&e.setup)return ya({show:!0,isFirstTime:!0,accounts:[],error:t.error,busy:t.busy,onSubmit:n=>e.handleSetMasterPin(n)});if(!t.hasMasterPin&&!t.authenticated&&!e.setup)return window.location.href="/setup",b}if(e.setup){const t=iv(e.channelsSnapshot),n=e.channelsSnapshot?.channelAccounts?.whatsapp??[],s=ov(e.channelsSnapshot),i=rv(e);return ah({connected:e.connected,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:o=>e.handleLicenseKeyChange(o),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:t,whatsappAccounts:n,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:o=>e.handleUninstallConfirmTextChange(o),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:o=>e.handleAuthSubmitCode(o),onAuthCodeChange:o=>e.handleAuthCodeChange(o),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async o=>{await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onWhatsAppReset:async o=>{await e.handleWhatsAppLogout(o),await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await z(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:o=>e.handleRemoveWhatsAppAccount(o),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:o=>{e.newWorkspacePin=o},onWorkspaceCreate:async(o,r)=>{const l=e.newWorkspacePin;await e.handleWorkspaceCreate(o,r),l.match(/^\d{4,6}$/)&&(await Cy(e,o,l),e.newWorkspacePin="")},onWorkspaceRemove:o=>e.handleWorkspaceRemove(o),onSetAddingWorkspace:o=>{e.addingWorkspace=o},onSetNewWorkspaceName:o=>{e.newWorkspaceName=o},onSetNewWorkspacePath:o=>{e.newWorkspacePath=o},onSetWorkspaceRemoveConfirm:o=>{e.workspaceRemoveConfirm=o},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(o,r)=>e.handleWorkspaceRename(o,r),whatsappDmPolicy:(()=>{const r=J(e)?.whatsappAccountId;return(r?n.find(a=>a.accountId===r):n[0])?.dmPolicy??null})(),onWhatsAppDmToggle:async()=>{const r=J(e)?.whatsappAccountId,l=r?n.find(p=>p.accountId===r):n[0];if(!l)return;const c=l.dmPolicy!=null&&l.dmPolicy!=="disabled"?"disabled":"open",u=c==="open"?{dmPolicy:c,allowFrom:["*"]}:{dmPolicy:c};try{const p=await e.client.request("config.get"),A=(p.config?.channels?.whatsapp?.accounts??{})[l.accountId]?{channels:{whatsapp:{accounts:{[l.accountId]:u}}}}:{channels:{whatsapp:u}};await e.client.request("config.patch",{raw:JSON.stringify(A),baseHash:p.hash,note:`WhatsApp DM policy → ${c}`,skipRestart:!0}),await z(e,!1)}catch(p){console.error("DM toggle failed:",p)}},whatsappModel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(p=>p.id.endsWith("-public")||p.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;if(!Array.isArray(a))return null;const c=a.find(p=>p.id===r.id);return c?.model&&(typeof c.model=="string"?c.model:c.model.primary)?.trim()||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(w=>w.id===l.id);if(o)m>=0?p[m]={...p[m],model:o}:p.push({id:l.id,model:o});else if(m>=0){const{model:w,...A}=p[m];Object.keys(A).length<=1?p.splice(m,1):p[m]=A}const v=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(v),baseHash:a.hash,note:`Public agent model → ${o||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Model change failed:",a)}},whatsappThinkingLevel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(u=>u.id.endsWith("-public")||u.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;return Array.isArray(a)&&a.find(u=>u.id===r.id)?.thinkingLevel?.trim()||null})(),onWhatsAppThinkingChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(A=>A.id===l.id),v=o==="off"?void 0:o;if(v)m>=0?p[m]={...p[m],thinkingLevel:v}:p.push({id:l.id,thinkingLevel:v});else if(m>=0){const{thinkingLevel:A,..._}=p[m];Object.keys(_).length<=1?p.splice(m,1):p[m]=_}const w=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`Public agent thinking → ${v||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Thinking change failed:",a)}},whatsappGroupPolicy:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return(a?c[a]:void 0)?.groupPolicy??r?.groupPolicy??"allowlist"})(),whatsappGroupRequireMention:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return((a?c[a]:void 0)?.groups??r?.groups??{})["*"]?.requireMention!==!1})(),onWhatsAppGroupToggle:async()=>{const r=J(e)?.whatsappAccountId;try{const l=await e.client.request("config.get"),c=l.config?.channels?.whatsapp??{},u=c.accounts??{},p=r?u[r]:void 0,m=p?.groupPolicy??c.groupPolicy??"allowlist",v=m==="disabled"||m==="allowlist",w=v?"open":"disabled",A=v?{"*":{}}:void 0,_={groupPolicy:w};A&&(_.groups=A);const j=p?{channels:{whatsapp:{accounts:{[r]:_}}}}:{channels:{whatsapp:_}};await e.client.request("config.patch",{raw:JSON.stringify(j),baseHash:l.hash,note:`WhatsApp groups → ${w}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(l){console.error("Group toggle failed:",l)}},onWhatsAppGroupMentionChange:async o=>{const l=J(e)?.whatsappAccountId;try{const a=await e.client.request("config.get"),p=(a.config?.channels?.whatsapp??{}).accounts??{},m=l?p[l]:void 0,v={"*":{requireMention:o}},w=m?{channels:{whatsapp:{accounts:{[l]:{groups:v}}}}}:{channels:{whatsapp:{groups:v}}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`WhatsApp group mention → ${o?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Group mention change failed:",a)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:s.configured,imessageRunning:s.running,imessageConnected:s.connected,imessageLastError:s.lastError,imessageSelfChatMode:s.selfChatMode,imessageCliPath:s.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:i,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(w=>w.id.endsWith("-admin")||w.id==="admin")?.id??"admin",p=l.filter(w=>w.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],v=[...p,...m];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:v}),baseHash:o.hash,note:"Enable iMessage (self-chat) for "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),ke(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),a=(o.config?.bindings??[]).filter(c=>c.match?.channel!=="imessage");await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:a}),baseHash:o.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),ke(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(v=>v.id.endsWith("-admin")||v.id==="admin")?.id??"admin",p=l.filter(v=>v.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...p,...m]}),baseHash:o.hash,note:"Reassign iMessage to "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),ke(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:o=>{e.infoModalOpen=o},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeySave:async(o,r)=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ba(e.client,o,r),e.apiKeySuccess=`${o} key saved`;try{e.apiKeyProviders=await Li(e.client)}catch{}o==="anthropic"&&await e.handleAuthStatusCheck()}catch(l){e.apiKeyError=l instanceof Error?l.message:"Failed to save key"}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async o=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await My(e.client,o),e.apiKeySuccess=`${o} key removed`;try{e.apiKeyProviders=await Li(e.client)}catch{}}catch(r){e.apiKeyError=r instanceof Error?r.message:"Failed to remove key"}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:o=>{e.authApiKeyInput=o},onAuthApiKeySubmit:async()=>{const o=e.authApiKeyInput.trim();if(o){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await ba(e.client,"anthropic",o),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(r){e.authApiKeyError=r instanceof Error?r.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{const o=e.selectedWorkspace??e.workspaces[0]?.name;return o?e.accessState.accounts.some(r=>r.id===o):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(o,r)=>{const l=e.selectedWorkspace??e.workspaces[0]?.name;l&&e.handleAccountPinSave(l,o,r)},wsProps:Qy(e)})}if(e.filesPage){const t=Jy(e);return Hp({connected:e.connected,wsProps:Ut(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>on(e,t),onReindex:()=>Hy(e,t),onSelectFile:n=>Fy(e,n,t),onToggleSelectFile:n=>Uy(e,n,t),onToggleDir:n=>qy(e,n),onUpload:(n,s)=>zy(e,n,s,t),onDownload:n=>kc(e,n,t),onBulkDownload:()=>Wy(e,t),onDelete:n=>jy(e,n,t),onMove:(n,s)=>Sc(e,n,s,t),onMoveToDir:(n,s)=>Ky(e,n,s,t)})}if(e.browserPage)return Up({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Py(e),onStop:()=>Ry(e),onToggleInput:()=>Ny(e),onCompleteHandoff:()=>Iy(e),onCanvasMouseDown:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mousePressed",o.x,o.y,t.button===2?"right":t.button===1?"middle":"left")},onCanvasMouseUp:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mouseReleased",o.x,o.y)},onCanvasMouseMove:t=>{const n=Bn();if(n.shouldThrottleMouseMove())return;const i=t.target.getBoundingClientRect(),o=n.translateCoordinates(t.clientX-i.left,t.clientY-i.top);ni(e,"mouseMoved",o.x,o.y)},onCanvasKeyDown:t=>{let n=0;t.altKey&&(n|=1),t.ctrlKey&&(n|=2),t.metaKey&&(n|=4),t.shiftKey&&(n|=8),si(e,"keyDown",t.key,{code:t.code,modifiers:n||void 0}),t.key.length===1&&si(e,"char",t.key,{text:t.key})},onCanvasKeyUp:t=>{si(e,"keyUp",t.key,{code:t.code})}});if(e.adminsPage){const t=Xy(e),n=Zy(e);return ch({connected:e.connected,wsProps:Ut(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>fs(e,t),onAdd:s=>{$c(e,s,t,n).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:s=>Ec(e,s,t,n),onNewPhoneChange:s=>e.handleAdminsNewPhoneChange(s)})}if(e.customersPage){const t=ev(e);return hh({connected:e.connected,wsProps:Ut(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:n=>e.customersSearchQuery=n,onSearchSubmit:()=>et(e,t),onAdd:(n,s)=>Tc(e,n,s,t),onDelete:n=>Cc(e,n,t),onSetField:(n,s,i)=>_c(e,n,s,i,t),onDeleteField:(n,s)=>Mc(e,n,s,t),onToggleExpand:n=>{e.customersEditingId=e.customersEditingId===n?null:n},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:n=>e.handleCustomersNewPhoneChange(n),onNewRecordNameChange:n=>e.handleCustomersNewNameChange(n),onRefresh:()=>et(e,t)})}if(e.chatPage){const t=e.connected?null:"Disconnected from gateway.",n=sv(e),s=e.chatAvatarUrl??n??null;return Ym({connected:e.connected,wsProps:Ut(e),sessionKey:e.sessionKey,onSessionKeyChange:i=>{e.sessionKey=i,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:i,lastActiveSessionKey:i}),e.loadAssistantIdentity(),Ce(e),fi(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:i=>{wn(e,e.sessionKey,{model:i}).then(()=>{Ce(e)})},onThinkingLevelChange:i=>{wn(e,e.sessionKey,{thinkingLevel:i==="off"?null:i}).then(()=>{Ce(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:i=>{wn(e,e.sessionKey,{verboseLevel:i==="off"?null:i}).then(()=>{Ce(e)})},onFillerChange:i=>{wn(e,e.sessionKey,{fillerEnabled:i}).then(()=>{Ce(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:s,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:t,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Ce(e),fi(e)])),onToggleFocusMode:()=>{},onChatScroll:i=>e.handleChatScroll(i),nearBottom:e.chatUserNearBottom,onDraftChange:i=>e.chatMessage=i,attachments:e.chatAttachments,onAttachmentsChange:i=>e.chatAttachments=i,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:i=>e.removeQueuedMessage(i),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:i=>e.handleOpenSidebar(i),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:i=>e.handleSplitRatioChange(i),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Ay({connected:e.connected,wsProps:Ut(e),activeTab:e.advancedTab,onTabChange:t=>{e.advancedTab=t,t==="cron"&&e.loadCron(),t==="skills"&&wt(e,{clearMessages:!0}),t==="logs"&&(e.logsSubTab==="session"?gt(e,{reset:!0}):qt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(t=>t.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],agentIds:J(e)?.agents?.map(n=>n.id)??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:t=>{e.cronDetailJobId=t.id,ci(e,t.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:t=>e.cronForm={...e.cronForm,...t},onRefresh:()=>e.loadCron(),onAdd:()=>{hd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(t,n)=>fd(e,t,n),onRun:t=>gd(e,t),onRemove:t=>md(e,t),onLoadRuns:t=>ci(e,t)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:t=>e.skillsFilter=t,onRefresh:()=>wt(e,{clearMessages:!0}),onToggle:(t,n)=>sp(e,t,n),onEdit:(t,n)=>np(e,t,n),onSaveKey:t=>ip(e,t),onInstall:(t,n,s)=>op(e,t,n,s)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:t=>{e.logsSubTab=t,t==="session"?gt(e,{reset:!0}):qt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,full:e.sessionLogsFull,onFilterTextChange:t=>e.sessionLogsFilterText=t,onTypeToggle:(t,n)=>{const s=e;s.sessionLogsTypeFilters={...s.sessionLogsTypeFilters,[t]:n}},onAgentToggle:(t,n)=>{const s=e;s.sessionLogsAgentFilters={...s.sessionLogsAgentFilters,[t]:n}},onToggleAutoFollow:t=>e.sessionLogsAutoFollow=t,onToggleFull:t=>{e.sessionLogsFull=t,gt(e,{reset:!0})},onRefresh:()=>{gt(e,{reset:!0})},onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleSessionLogsScroll(t)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:t=>e.logsFilterText=t,onLevelToggle:(t,n)=>{e.logsLevelFilters={...e.logsLevelFilters,[t]:n}},onToggleAutoFollow:t=>e.logsAutoFollow=t,onRefresh:()=>qt(e,{reset:!0}),onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleLogsScroll(t)}}):(window.location.replace("/chat"),d``)}const lv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},cv={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function uv(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function rn(e){if(!(!e.client||!e.connected)&&!e.workspacesLoading){e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});e.workspaces=t.workspaces}catch(t){e.workspacesError=String(t)}finally{e.workspacesLoading=!1}}}async function dv(e,t){if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}const o={name:n,baseHash:i,whatsappAccountName:n};t.workspacePath?.trim()&&(o.workspaceDir=t.workspacePath.trim());const r=await e.client.request("workspaces.create",o);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await rn(e),t.onCreated?.(r)}catch(s){e.workspacesError=String(s)}finally{e.workspaceSaving=!1}}async function pv(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await rn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function hv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await rn(e)}catch(s){e.workspacesError=String(s)}}}const Pn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:dv,loadWorkspaces:rn,removeWorkspace:pv,renameWorkspace:hv},Symbol.toStringTag,{value:"Module"})),Lc={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe"},wa=Lc,Pi={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Lc));new Set(Object.values(Pi));function fv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const gv=4008;class mv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,o=!1,r=this.opts.token;if(t){i=await Gd();const u=Qd({deviceId:i.deviceId,role:s})?.token;r=u??this.opts.token,o=!!(u&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let a;if(t&&i){const u=Date.now(),p=this.connectNonce??void 0,m=fv({deviceId:i.deviceId,clientId:this.opts.clientName??wa.CONTROL_UI,clientMode:this.opts.mode??Pi.WEBCHAT,role:s,scopes:n,signedAtMs:u,token:r??null,nonce:p}),v=await Vd(i.privateKey,m);a={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:u,nonce:p}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??wa.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Pi.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:a,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(u=>{u?.auth?.deviceToken&&i&&Xd({deviceId:i.deviceId,role:u.auth.role??s,token:u.auth.deviceToken,scopes:u.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(u)}).catch(()=>{o&&i&&Zd({deviceId:i.deviceId,role:s}),this.ws?.close(gv,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const r=i.payload,l=r&&typeof r.nonce=="string"?r.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const o=typeof i.seq=="number"?i.seq:null;o!==null&&(this.lastSeq!==null&&o>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:o}),this.lastSeq=o);try{this.opts.onEvent?.(i)}catch(r){console.error("[gateway] event handler error:",r)}return}if(s.type==="res"){const i=n,o=this.pending.get(i.id);if(!o)return;this.pending.delete(i.id),i.ok?o.resolve(i.payload):o.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Ui(),i={type:"req",id:s,method:t,params:n},o=new Promise((r,l)=>{this.pending.set(s,{resolve:a=>r(a),reject:l})});return this.ws.send(JSON.stringify(i)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ri(e){return typeof e=="object"&&e!==null}function yv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ri(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!o?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:o}}function vv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Pc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function bv(e,t){const n=Pc(e).filter(s=>s.id!==t.id);return n.push(t),n}function ka(e,t){return Pc(e).filter(n=>n.id!==t)}async function Rc(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const o=ai(i);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}const es="taskmaster_update_pending";async function Ic(e){if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,e.requestUpdate?.();try{const t=await e.client.request("update.status",{});e.currentVersion=t.current,e.latestVersion=t.latest,e.updateAvailable=t.updateAvailable,e.updateMessage=t.updateAvailable?`v${t.latest} available`:"Up to date"}catch(t){e.updateMessage=`Check failed: ${String(t)}`,e.updateAvailable=null}finally{e.updateChecking=!1,e.requestUpdate?.()}}}async function wv(e){if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,e.requestUpdate?.();try{localStorage.setItem(es,String(Date.now()))}catch{}try{const t=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(t.ok&&t.result.status==="ok")e.updateMessage="Updated — restarting gateway...",e.requestUpdate?.();else if(t.ok&&t.result.status==="skipped")Yt(),e.updateMessage=t.result.reason||"Update skipped",e.updateRunning=!1,e.requestUpdate?.();else throw Yt(),new Error(t.result.reason||"Update failed")}catch(t){Yt(),e.updateMessage=`Update failed: ${String(t)}`,e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}}function kv(e,t){const n=t.phase;if(n==="step-start"){const s=t.name,i=t.index,o=t.total;e.updateMessage=`Updating: ${s} (${i+1}/${o})`;const r=e.updateProgressSteps.find(l=>l.index===i);r?(r.status="running",r.name=s):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:"running"}],e.requestUpdate?.()}else if(n==="step-done"){const s=t.name,i=t.index,o=t.total,r=t.ok,l=t.durationMs,a=e.updateProgressSteps.find(c=>c.index===i);a?(a.status=r?"done":"failed",a.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:r?"done":"failed",durationMs:l}],e.updateMessage=r?`Updating: ${s} done (${i+1}/${o})`:`Update step failed: ${s}`,e.requestUpdate?.()}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const i=t.reason;e.updateMessage=i?`Update failed: ${i}`:"Update failed",e.updateRunning=!1,Yt()}e.requestUpdate?.()}}async function Sv(e){if(!e.client||!e.connected)return;const t=Av();Yt();try{const n=await e.client.request("update.lastResult",{});if(!n.ok||!n.result)return;const s=5*6e4,i=Date.now()-n.result.ts<s;if(!t&&!i)return;e.updateLastResult=n.result;const o=n.result.after?.version;if(n.result.status==="ok"&&o&&(e.currentVersion=o),e.updateAvailable=!1,n.result.status==="ok"){const r=n.result.before?.version,l=o??n.result.currentVersion;e.updateMessage=r?`Updated: v${r} → v${l}`:`Updated to v${l}`}else{const r=n.result.reason??n.result.failedStep?.name??"unknown error";e.updateMessage=`Update failed: ${r}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}function xv(e){e.updateLastResult=null,e.requestUpdate?.()}function Av(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Yt(){try{localStorage.removeItem(es)}catch{}}function ii(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",o=t.defaultAgentId?.trim();return n==="main"||n===i||o&&(n===`agent:${o}:main`||n===`agent:${o}:${i}`)?s:n}function $v(e,t){if(!t?.mainSessionKey)return;const n=ii(e.sessionKey,t),s=ii(e.settings.sessionKey,t),i=ii(e.settings.lastActiveSessionKey,t),o=n||s||e.sessionKey,r={...e.settings,sessionKey:s||o,lastActiveSessionKey:i||o},l=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),l&&Ie(e,r)}function Te(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=e.setup||e.filesPage||e.browserPage?"setup-ui":"taskmaster-control-ui";e.client?.stop(),e.client=new mv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:t,mode:"webchat",onHello:n=>{e.connected=!0,e.lastError=null,e.hello=n,Cv(e,n),e.handleAccessCheck(),Sv(e).then(()=>{Ic(e)}),Rc(e),uv(e),(e.chatPage||e.setup)&&_v(e),Xi(e,{quiet:!0}),Qi(e,{quiet:!0}),rn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(ke(e),Mv(e)),oo(e)},onClose:({code:n,reason:s})=>{e.connected=!1,n!==1012&&(e.lastError=`disconnected (${n}): ${s||"no reason"}`)},onEvent:n=>Ev(e,n),onGap:({expected:n,received:s})=>{e.lastError=`event gap detected (expected seq ${n}, got ${s}); refresh recommended`}}),e.client.start()}function Ev(e,t){try{Tv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Tv(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;ed(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&gl(e,n.sessionKey);const s=Wa(e,n);(s==="final"||s==="error"||s==="aborted")&&(Ki(e),Mp(e)),s==="final"&&Ce(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&ro(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Qi(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=yv(t.payload);if(n){e.execApprovalQueue=bv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=ka(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){Dy(e,t.payload);return}if(t.event==="browser.handoff"){Oy(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){By(e);return}if(t.event==="exec.approval.resolved"){const n=vv(t.payload);n&&(e.execApprovalQueue=ka(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){kv(e,t.payload);return}}function Cv(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&$v(e,n.sessionDefaults)}async function _v(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t?.models)&&(e.chatModelCatalog=t.models)}catch{}}async function Mv(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Li(e.client)}catch{}}function Lv(e){e.basePath=vp();const t=Oe();if(Dp(t.accentColor),window.scrollTo(0,0),e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.customersPage){document.title=`${t.name} Customers`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}Sp(e,!0),bp(e),wp(e),window.addEventListener("popstate",e.popStateHandler),gp(e),Te(e),hp(e),e.tab==="logs"&&(e.logsSubTab==="session"?to(e):Ji(e)),e.tab==="debug"&&so(e)}function Pv(e){ad(e)}function Rv(e){window.removeEventListener("popstate",e.popStateHandler),fp(e),eo(e),no(e),io(e),kp(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Iv(e,t){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&(e.authConnected===!0?e.setupStep="whatsapp":e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck()),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(i=>{e.channelsSnapshot=i,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;en(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Ka(e,t.has("tab")||t.has("logsAutoFollow"))}function Nv(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}async function Dv(e,t,n){await zi(e,t,n),await z(e,!0)}async function Ov(e,t){await Ha(e,t),await z(e,!0)}async function Bv(e,t){await qa(e,t),await z(e,!0)}async function Fv(e,t){await Ga(e,t)}async function Uv(e,t){await Va(e,t)}async function Wv(e){await ud(e),await ke(e),await z(e,!0)}async function Kv(e){await ke(e),await z(e,!0)}function zv(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const o=s.trim(),r=i.join(":").trim();o&&r&&(t[o]=r)}return t}function Nc(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Dc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function jv(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Nv(n??void 0)}function Hv(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function qv(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function Gv(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Vv(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Nc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Dc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const o=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:zv(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await z(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Yv(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Nc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Dc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:a,success:null};return}const o=i.merged??i.imported??null,r=o?{...t.values,...o}:t.values,l=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:l},i.saved&&await z(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function Qv(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function Xv(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function Zv(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput="",setTimeout(()=>{e.setupStep="whatsapp"},1500)):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function Jv(e,t){e.authCodeInput=t}function eb(e){e.setupStep="whatsapp"}async function tb(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function nb(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function sb(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function ib(e,t){e.licenseKey=t}async function ob(e){if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,e.requestUpdate?.();try{const t=await e.client.request("health",{probe:!0});e.gatewayHealthy=t.ok===!0,e.gatewayHealthMessage=t.ok?`Healthy${t.durationMs?` (${t.durationMs}ms)`:""}`:"Unhealthy"}catch(t){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(t)}`}finally{e.gatewayHealthLoading=!1,e.requestUpdate?.()}}}async function rb(e){if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",e.requestUpdate?.();try{const t=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(t.ok&&t.restart?.ok)e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(t){e.gatewayHealthMessage=`Restart failed: ${String(t)}`,e.gatewayRestartBusy=!1,e.requestUpdate?.()}}}var ab=Object.defineProperty,lb=Object.getOwnPropertyDescriptor,f=(e,t,n,s)=>{for(var i=s>1?void 0:s?lb(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(i=(s?r(t,n,i):r(i))||i);return s&&i&&ab(t,n,i),i};const oi=Su();function cb(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function ub(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function db(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function pb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function hb(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function fb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function gb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function mb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let h=class extends mt{constructor(){super(...arguments),this.settings=Ms(),this.password="",this.tab="chat",this.onboarding=cb(),this.setup=ub(),this.filesPage=db(),this.browserPage=pb(),this.adminsPage=hb(),this.customersPage=fb(),this.chatPage=gb(),this.advancedPage=mb(),this.advancedTab="cron",this.connected=!1,this.accessState=yc,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=oi.name,this.assistantAvatar=oi.avatar,this.assistantAgentId=oi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
2860
2854
  }
2861
2855
  `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...cv},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...lv},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsFull=!1,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>xp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Lv(this)}firstUpdated(){Pv(this)}disconnectedCallback(){Rv(this),super.disconnectedCallback()}updated(e){Iv(this,e)}connect(){Te(this)}handleChatScroll(e){td(this,e)}handleLogsScroll(e){nd(this,e)}handleSessionLogsScroll(e){sd(this,e)}exportLogs(e,t){od(e,t)}exportSessionLogs(e,t){rd(e,t)}resetToolStream(){Ki(this)}resetChatScroll(){id(this)}async loadAssistantIdentity(){await Rc(this)}applySettings(e){Ie(this,e)}setTab(e){mp(this,e)}setTheme(e,t){yp(this,e,t)}async loadOverview(){await vl(this)}async loadCron(){const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=e?.agents?.map(t=>t.id)??void 0,this.cronForm={...this.cronForm,accountId:e?.whatsappAccountId??void 0},await ro(this)}async handleAbortChat(){await wl(this)}removeQueuedMessage(e){Tp(this,e)}async handleSendChat(e,t){await Cp(this,e,t)}async handleWhatsAppStart(e,t){await Dv(this,e,t)}async handleWhatsAppWait(e){await Ov(this,e)}async handleWhatsAppLogout(e){await Bv(this,e)}async handleAddWhatsAppAccount(e){await Fv(this,e)}async handleRemoveWhatsAppAccount(e){await Uv(this,e)}async handleAccessCheck(){await va(this)}async handlePinSubmit(e,t){await Ey(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Ty(this,e)}async handleLogout(){await _y(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await va(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await tb(this)}async handleLicenseActivate(){await nb(this)}async handleLicenseRemove(){await sb(this)}handleLicenseKeyChange(e){ib(this,e)}async handleAuthStatusCheck(){await Qv(this)}async handleAuthStart(){await Xv(this)}async handleAuthSubmitCode(e){await Zv(this,e)}handleAuthCodeChange(e){Jv(this,e)}handleSkipToWhatsApp(){eb(this)}async handleGatewayHealthCheck(){await ob(this)}async handleGatewayRestart(){await rb(this)}async handleUpdateCheck(){await Ic(this)}async handleUpdateRun(){await wv(this)}handleUpdateDismissResult(){xv(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await de(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>yr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){de(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>yr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}handleFilesLoad(){const e=this.resolveFilesAgentId();on(this,e),xc(this,e)}handleAdminsLoad(){const e=this.resolveAdminAgentId();de(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Vy);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();return e?e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin")?.id:void 0}resolveFilesAgentId(){const e=this.getSelectedWorkspaceInfo();if(e)return e.agents[0]?.id}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}de(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>ju);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await Wv(this)}async handleChannelConfigReload(){await Kv(this)}handleNostrProfileEdit(e,t){jv(this,e,t)}handleNostrProfileCancel(){Hv(this)}handleNostrProfileFieldChange(e,t){qv(this,e,t)}async handleNostrProfileSave(){await Vv(this)}async handleNostrProfileImport(){await Yv(this)}handleNostrProfileToggleAdvanced(){Gv(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;de(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>Yy);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await de(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Pn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await de(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Pn);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await de(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>yd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const o=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await de(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Pn);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=e?.displayName??e?.name??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await de(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Pn);return{renameWorkspace:s}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),ir(e),this.settings=Ms(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.adminsPage?this.handleAdminsLoad():this.customersPage?this.handleCustomersLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0)return;const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}ir(this.selectedWorkspace),this.settings=Ms(),this.reloadCurrentPageData()}render(){return av(this)}};f([g()],h.prototype,"settings",2);f([g()],h.prototype,"password",2);f([g()],h.prototype,"tab",2);f([g()],h.prototype,"onboarding",2);f([g()],h.prototype,"setup",2);f([g()],h.prototype,"filesPage",2);f([g()],h.prototype,"browserPage",2);f([g()],h.prototype,"adminsPage",2);f([g()],h.prototype,"customersPage",2);f([g()],h.prototype,"chatPage",2);f([g()],h.prototype,"advancedPage",2);f([g()],h.prototype,"advancedTab",2);f([g()],h.prototype,"connected",2);f([g()],h.prototype,"accessState",2);f([g()],h.prototype,"theme",2);f([g()],h.prototype,"themeResolved",2);f([g()],h.prototype,"hello",2);f([g()],h.prototype,"lastError",2);f([g()],h.prototype,"eventLog",2);f([g()],h.prototype,"assistantName",2);f([g()],h.prototype,"assistantAvatar",2);f([g()],h.prototype,"assistantAgentId",2);f([g()],h.prototype,"sessionKey",2);f([g()],h.prototype,"chatLoading",2);f([g()],h.prototype,"chatSending",2);f([g()],h.prototype,"chatMessage",2);f([g()],h.prototype,"chatMessages",2);f([g()],h.prototype,"chatToolMessages",2);f([g()],h.prototype,"chatStream",2);f([g()],h.prototype,"chatStreamStartedAt",2);f([g()],h.prototype,"chatRunId",2);f([g()],h.prototype,"compactionStatus",2);f([g()],h.prototype,"chatAvatarUrl",2);f([g()],h.prototype,"chatThinkingLevel",2);f([g()],h.prototype,"chatModelProvider",2);f([g()],h.prototype,"chatModel",2);f([g()],h.prototype,"chatModelCatalog",2);f([g()],h.prototype,"chatVerboseLevel",2);f([g()],h.prototype,"chatFillerEnabled",2);f([g()],h.prototype,"chatQueue",2);f([g()],h.prototype,"chatAttachments",2);f([g()],h.prototype,"sidebarOpen",2);f([g()],h.prototype,"sidebarContent",2);f([g()],h.prototype,"sidebarError",2);f([g()],h.prototype,"splitRatio",2);f([g()],h.prototype,"nodesLoading",2);f([g()],h.prototype,"nodes",2);f([g()],h.prototype,"devicesLoading",2);f([g()],h.prototype,"devicesError",2);f([g()],h.prototype,"devicesList",2);f([g()],h.prototype,"execApprovalsLoading",2);f([g()],h.prototype,"execApprovalsSaving",2);f([g()],h.prototype,"execApprovalsDirty",2);f([g()],h.prototype,"execApprovalsSnapshot",2);f([g()],h.prototype,"execApprovalsForm",2);f([g()],h.prototype,"execApprovalsSelectedAgent",2);f([g()],h.prototype,"execApprovalsTarget",2);f([g()],h.prototype,"execApprovalsTargetNodeId",2);f([g()],h.prototype,"execApprovalQueue",2);f([g()],h.prototype,"execApprovalBusy",2);f([g()],h.prototype,"execApprovalError",2);f([g()],h.prototype,"configLoading",2);f([g()],h.prototype,"configRaw",2);f([g()],h.prototype,"configRawOriginal",2);f([g()],h.prototype,"configValid",2);f([g()],h.prototype,"configIssues",2);f([g()],h.prototype,"configSaving",2);f([g()],h.prototype,"configApplying",2);f([g()],h.prototype,"updateRunning",2);f([g()],h.prototype,"applySessionKey",2);f([g()],h.prototype,"configSnapshot",2);f([g()],h.prototype,"configSchema",2);f([g()],h.prototype,"configSchemaVersion",2);f([g()],h.prototype,"configSchemaLoading",2);f([g()],h.prototype,"configUiHints",2);f([g()],h.prototype,"configForm",2);f([g()],h.prototype,"configFormOriginal",2);f([g()],h.prototype,"configFormDirty",2);f([g()],h.prototype,"configFormMode",2);f([g()],h.prototype,"configSearchQuery",2);f([g()],h.prototype,"configActiveSection",2);f([g()],h.prototype,"configActiveSubsection",2);f([g()],h.prototype,"channelsLoading",2);f([g()],h.prototype,"channelsSnapshot",2);f([g()],h.prototype,"channelsError",2);f([g()],h.prototype,"channelsLastSuccess",2);f([g()],h.prototype,"whatsappLoginMessage",2);f([g()],h.prototype,"whatsappLoginQrDataUrl",2);f([g()],h.prototype,"whatsappLoginConnected",2);f([g()],h.prototype,"whatsappBusy",2);f([g()],h.prototype,"whatsappActiveQrAccountId",2);f([g()],h.prototype,"whatsappPairedPhone",2);f([g()],h.prototype,"addingWhatsAppAccount",2);f([g()],h.prototype,"newWhatsAppAccountName",2);f([g()],h.prototype,"whatsappAccountError",2);f([g()],h.prototype,"whatsappAccountSaving",2);f([g()],h.prototype,"whatsappSettingsOpen",2);f([g()],h.prototype,"licenseKey",2);f([g()],h.prototype,"licenseBusy",2);f([g()],h.prototype,"licenseValid",2);f([g()],h.prototype,"licenseMessage",2);f([g()],h.prototype,"licenseTier",2);f([g()],h.prototype,"licenseDeviceId",2);f([g()],h.prototype,"licenseStoredKey",2);f([g()],h.prototype,"licenseRemoveConfirm",2);f([g()],h.prototype,"authConnected",2);f([g()],h.prototype,"authBusy",2);f([g()],h.prototype,"authMessage",2);f([g()],h.prototype,"authUrl",2);f([g()],h.prototype,"authCodeInput",2);f([g()],h.prototype,"authExpiresIn",2);f([g()],h.prototype,"setupStep",2);f([g()],h.prototype,"gatewayHealthy",2);f([g()],h.prototype,"gatewayHealthLoading",2);f([g()],h.prototype,"gatewayHealthMessage",2);f([g()],h.prototype,"gatewayRestartBusy",2);f([g()],h.prototype,"updateAvailable",2);f([g()],h.prototype,"currentVersion",2);f([g()],h.prototype,"latestVersion",2);f([g()],h.prototype,"updateChecking",2);f([g()],h.prototype,"updateMessage",2);f([g()],h.prototype,"updateProgressSteps",2);f([g()],h.prototype,"updateLastResult",2);f([g()],h.prototype,"uninstallConfirm",2);f([g()],h.prototype,"uninstallBusy",2);f([g()],h.prototype,"uninstallDone",2);f([g()],h.prototype,"uninstallError",2);f([g()],h.prototype,"uninstallConfirmText",2);f([g()],h.prototype,"nostrProfileFormState",2);f([g()],h.prototype,"nostrProfileAccountId",2);f([g()],h.prototype,"presenceLoading",2);f([g()],h.prototype,"presenceEntries",2);f([g()],h.prototype,"presenceError",2);f([g()],h.prototype,"presenceStatus",2);f([g()],h.prototype,"agentsLoading",2);f([g()],h.prototype,"agentsList",2);f([g()],h.prototype,"agentsError",2);f([g()],h.prototype,"sessionsLoading",2);f([g()],h.prototype,"sessionsResult",2);f([g()],h.prototype,"sessionsError",2);f([g()],h.prototype,"cronLoading",2);f([g()],h.prototype,"cronJobs",2);f([g()],h.prototype,"cronStatus",2);f([g()],h.prototype,"cronError",2);f([g()],h.prototype,"cronForm",2);f([g()],h.prototype,"cronRunsJobId",2);f([g()],h.prototype,"cronRuns",2);f([g()],h.prototype,"cronBusy",2);f([g()],h.prototype,"cronNewEventModal",2);f([g()],h.prototype,"cronDetailJobId",2);f([g()],h.prototype,"browserScreencastActive",2);f([g()],h.prototype,"browserScreencastFrame",2);f([g()],h.prototype,"browserScreencastMetadata",2);f([g()],h.prototype,"browserHandoffPending",2);f([g()],h.prototype,"browserHandoffReason",2);f([g()],h.prototype,"browserHandoffId",2);f([g()],h.prototype,"browserInputMode",2);f([g()],h.prototype,"browserLoading",2);f([g()],h.prototype,"browserError",2);f([g()],h.prototype,"filesLoading",2);f([g()],h.prototype,"filesTree",2);f([g()],h.prototype,"filesRoot",2);f([g()],h.prototype,"filesError",2);f([g()],h.prototype,"filesSelectedPath",2);f([g()],h.prototype,"filesSelectedPaths",2);f([g()],h.prototype,"filesPreviewContent",2);f([g()],h.prototype,"filesPreviewLoading",2);f([g()],h.prototype,"filesPreviewBinary",2);f([g()],h.prototype,"filesPreviewSize",2);f([g()],h.prototype,"filesExpandedDirs",2);f([g()],h.prototype,"filesMessage",2);f([g()],h.prototype,"filesUploadBusy",2);f([g()],h.prototype,"filesReindexBusy",2);f([g()],h.prototype,"filesMemoryStatus",2);f([g()],h.prototype,"skillsLoading",2);f([g()],h.prototype,"skillsReport",2);f([g()],h.prototype,"skillsError",2);f([g()],h.prototype,"skillsFilter",2);f([g()],h.prototype,"skillEdits",2);f([g()],h.prototype,"skillsBusyKey",2);f([g()],h.prototype,"skillMessages",2);f([g()],h.prototype,"adminsLoading",2);f([g()],h.prototype,"adminPhones",2);f([g()],h.prototype,"adminsError",2);f([g()],h.prototype,"adminsSaving",2);f([g()],h.prototype,"adminsNewPhone",2);f([g()],h.prototype,"customersLoading",2);f([g()],h.prototype,"customersSaving",2);f([g()],h.prototype,"customersRecords",2);f([g()],h.prototype,"customersError",2);f([g()],h.prototype,"customersSearchQuery",2);f([g()],h.prototype,"customersEditingId",2);f([g()],h.prototype,"customersShowAddForm",2);f([g()],h.prototype,"customersNewPhone",2);f([g()],h.prototype,"customersNewName",2);f([g()],h.prototype,"imessageEnableConfirm",2);f([g()],h.prototype,"imessageEnabling",2);f([g()],h.prototype,"infoModalOpen",2);f([g()],h.prototype,"workspaces",2);f([g()],h.prototype,"workspacesLoading",2);f([g()],h.prototype,"workspacesError",2);f([g()],h.prototype,"selectedWorkspace",2);f([g()],h.prototype,"addingWorkspace",2);f([g()],h.prototype,"newWorkspaceName",2);f([g()],h.prototype,"newWorkspacePath",2);f([g()],h.prototype,"newWorkspacePin",2);f([g()],h.prototype,"accountPinModalOpen",2);f([g()],h.prototype,"accountPinBusy",2);f([g()],h.prototype,"accountPinError",2);f([g()],h.prototype,"accountPinSuccess",2);f([g()],h.prototype,"apiKeyProviders",2);f([g()],h.prototype,"apiKeyModalOpen",2);f([g()],h.prototype,"apiKeyBusy",2);f([g()],h.prototype,"apiKeyError",2);f([g()],h.prototype,"apiKeySuccess",2);f([g()],h.prototype,"authApiKeyMode",2);f([g()],h.prototype,"authApiKeyInput",2);f([g()],h.prototype,"authApiKeyBusy",2);f([g()],h.prototype,"authApiKeyError",2);f([g()],h.prototype,"pinChanging",2);f([g()],h.prototype,"pinChangeBusy",2);f([g()],h.prototype,"pinChangeError",2);f([g()],h.prototype,"loginChangePinMode",2);f([g()],h.prototype,"changePinBusy",2);f([g()],h.prototype,"changePinError",2);f([g()],h.prototype,"changePinSuccess",2);f([g()],h.prototype,"workspaceSaving",2);f([g()],h.prototype,"workspaceRemoveConfirm",2);f([g()],h.prototype,"renamingWorkspace",2);f([g()],h.prototype,"renameWorkspaceName",2);f([g()],h.prototype,"debugLoading",2);f([g()],h.prototype,"debugStatus",2);f([g()],h.prototype,"debugHealth",2);f([g()],h.prototype,"debugModels",2);f([g()],h.prototype,"debugHeartbeat",2);f([g()],h.prototype,"debugCallMethod",2);f([g()],h.prototype,"debugCallParams",2);f([g()],h.prototype,"debugCallResult",2);f([g()],h.prototype,"debugCallError",2);f([g()],h.prototype,"logsLoading",2);f([g()],h.prototype,"logsError",2);f([g()],h.prototype,"logsFile",2);f([g()],h.prototype,"logsEntries",2);f([g()],h.prototype,"logsFilterText",2);f([g()],h.prototype,"logsLevelFilters",2);f([g()],h.prototype,"logsAutoFollow",2);f([g()],h.prototype,"logsTruncated",2);f([g()],h.prototype,"logsCursor",2);f([g()],h.prototype,"logsLastFetchAt",2);f([g()],h.prototype,"logsLimit",2);f([g()],h.prototype,"logsMaxBytes",2);f([g()],h.prototype,"logsAtBottom",2);f([g()],h.prototype,"logsSubTab",2);f([g()],h.prototype,"sessionLogsLoading",2);f([g()],h.prototype,"sessionLogsError",2);f([g()],h.prototype,"sessionLogsEntries",2);f([g()],h.prototype,"sessionLogsFilterText",2);f([g()],h.prototype,"sessionLogsTypeFilters",2);f([g()],h.prototype,"sessionLogsAgentFilters",2);f([g()],h.prototype,"sessionLogsAgents",2);f([g()],h.prototype,"sessionLogsAutoFollow",2);f([g()],h.prototype,"sessionLogsFull",2);f([g()],h.prototype,"sessionLogsCursors",2);f([g()],h.prototype,"sessionLogsLastFetchAt",2);f([g()],h.prototype,"sessionLogsAtBottom",2);f([g()],h.prototype,"chatUserNearBottom",2);h=f([_a("taskmaster-app")],h);
2862
- //# sourceMappingURL=index-D9HCutTJ.js.map
2856
+ //# sourceMappingURL=index-DgT0m3bj.js.map