@rubytech/taskmaster 1.0.61 → 1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +3 -3
- package/dist/control-ui/assets/{index-Sm-M_hDk.js → index-CV7xcGIS.js} +18 -6
- package/dist/control-ui/assets/index-CV7xcGIS.js.map +1 -0
- package/dist/control-ui/assets/index-mweBpmCT.css +1 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/gateway/server-chat.js +9 -0
- package/dist/gateway/server-methods/chat.js +19 -0
- package/dist/gateway/server-restart-sentinel.js +6 -3
- package/dist/infra/restart-sentinel.js +8 -1
- package/package.json +1 -1
- package/taskmaster-docs/USER-GUIDE.md +4 -0
- package/dist/control-ui/assets/index-Sm-M_hDk.js.map +0 -1
- package/dist/control-ui/assets/index-wibL0JHX.css +0 -1
package/dist/build-info.json
CHANGED
|
@@ -5,9 +5,9 @@ var au=Object.defineProperty;var lu=(e,t,n)=>t in e?au(e,t,{enumerable:!0,config
|
|
|
5
5
|
`);const i=Qu(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
6
6
|
`):null}function Vu(e){if(!e||typeof e!="object")return yo(e);const t=e;if(zs.has(t))return zs.get(t)??null;const n=yo(e);return zs.set(t,n),n}function Qu(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
|
|
7
7
|
`)}return typeof t.text=="string"?t.text:null}function Yu(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
|
|
8
|
-
`):""}const Xu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Zu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Ju=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,ed=/^A new session was started via \/new or \/reset\./;function td(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&Xu.test(i)||n==="assistant"&&Zu.test(i)||n==="user"&&ed.test(i)||n==="assistant"&&Ju.test(i)):!1}function nd(e){return e.filter(t=>!td(t))}function Ja(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,r=Array.isArray(i)?i:null,o=Array.isArray(r)&&r.some(p=>{const h=String(p.type??"").toLowerCase();return h==="toolresult"||h==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||a)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:u}}function el(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function tl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function vo(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function sd(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function Vi(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),vo(t)}return vo(sd())}async function Me(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=nd(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function id(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function nl(e,t,n){if(
|
|
8
|
+
`):""}const Xu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Zu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Ju=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,ed=/^A new session was started via \/new or \/reset\./;function td(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&Xu.test(i)||n==="assistant"&&Zu.test(i)||n==="user"&&ed.test(i)||n==="assistant"&&Ju.test(i)):!1}function nd(e){return e.filter(t=>!td(t))}function Ja(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,r=Array.isArray(i)?i:null,o=Array.isArray(r)&&r.some(p=>{const h=String(p.type??"").toLowerCase();return h==="toolresult"||h==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||a)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:u}}function el(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function tl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function vo(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function sd(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function Vi(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),vo(t)}return vo(sd())}async function Me(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=nd(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function id(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function nl(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const r=Date.now(),o=(n??[]).filter(h=>!h.fileName),a=(n??[]).filter(h=>h.fileName),l=[],c=a.map(h=>h.fileName).filter(Boolean);if(c.length>0){const h=s?`${c.join(", ")}
|
|
9
9
|
|
|
10
|
-
${s}`:c.join(", ");l.push({type:"text",text:h})}else s&&l.push({type:"text",text:s});for(const h of o)l.push({type:"image",source:{type:"base64",media_type:h.mimeType,data:h.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:r}],e.chatSending=!0,e.lastError=null;const u=Vi();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=r;const p=[...o,...a],d=p.length>0?p.map(h=>{if(h.textContent)return{type:"document",mimeType:h.mimeType||"text/plain",fileName:h.fileName,content:btoa(unescape(encodeURIComponent(h.textContent)))};const b=id(h.dataUrl);return b?{type:h.fileName?"document":"image",mimeType:b.mimeType,fileName:h.fileName,content:b.content}:null}).filter(h=>h!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:d}),!0}catch(h){const b=String(h);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=b,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+b}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function sl(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function il(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="block"){const n=Zn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){const n=Zn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const rd=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:sl,handleChatEvent:il,loadChatHistory:Me,sendChatMessage:nl},Symbol.toStringTag,{value:"Module"}));async function Qi(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=Xn(e.sessionsFilterActive??"",0),s=Xn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Cn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Qi(e)}catch(i){e.sessionsError=String(i)}}const bo=50,od=80,ad=12e4;function ld(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
10
|
+
${s}`:c.join(", ");l.push({type:"text",text:h})}else s&&l.push({type:"text",text:s});for(const h of o)l.push({type:"image",source:{type:"base64",media_type:h.mimeType,data:h.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:r}],e.chatSending=!0,e.lastError=null;const u=Vi();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=r;const p=[...o,...a],d=p.length>0?p.map(h=>{if(h.textContent)return{type:"document",mimeType:h.mimeType||"text/plain",fileName:h.fileName,content:btoa(unescape(encodeURIComponent(h.textContent)))};const b=id(h.dataUrl);return b?{type:h.fileName?"document":"image",mimeType:b.mimeType,fileName:h.fileName,content:b.content}:null}).filter(h=>h!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:d}),!0}catch(h){const b=String(h);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=b,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+b}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function sl(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function il(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="block"){const n=Zn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestion=null;const n=Zn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const rd=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:sl,handleChatEvent:il,loadChatHistory:Me,sendChatMessage:nl},Symbol.toStringTag,{value:"Module"}));async function Qi(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=Xn(e.sessionsFilterActive??"",0),s=Xn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Cn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Qi(e)}catch(i){e.sessionsError=String(i)}}const bo=50,od=80,ad=12e4;function ld(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
11
11
|
`)}function wo(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=ld(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Xa(n,ad);return s.truncated?`${s.text}
|
|
12
12
|
|
|
13
13
|
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function cd(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function ud(e){if(e.toolStreamOrder.length<=bo)return;const t=e.toolStreamOrder.length-bo,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function dd(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function vi(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),dd(e)}function pd(e,t=!1){if(t){vi(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>vi(e),od))}function Yi(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],vi(e)}const hd=5e3;function fd(e,t){var i;const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:((i=e.compactionStatus)==null?void 0:i.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},hd))}function gd(e,t){if(!t)return;if(t.stream==="compaction"){fd(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const r=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",a=o==="start"?s.args:void 0,l=o==="update"?wo(s.partialResult):o==="result"?wo(s.result):void 0,c=Date.now();let u=e.toolStreamById.get(i);u?(u.name=r,a!==void 0&&(u.args=a),l!==void 0&&(u.output=l),u.updatedAt=c):(u={toolCallId:i,runId:t.runId,sessionKey:n,name:r,args:a,output:l,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=cd(u),ud(e),pd(e,o==="result")}function cn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const a=n();if(!a)return;const l=a.scrollHeight-a.scrollTop-a.clientHeight;(t||e.chatUserNearBottom||l<200)&&(a.scrollTop=a.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function rl(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function md(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function yd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function vd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function bd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function wd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
@@ -2005,6 +2005,18 @@ ${e.sidebarContent}
|
|
|
2005
2005
|
`:k}
|
|
2006
2006
|
</div>
|
|
2007
2007
|
|
|
2008
|
+
${e.suggestion?f`
|
|
2009
|
+
<div class="chat-suggestions">
|
|
2010
|
+
<button
|
|
2011
|
+
class="chat-suggestion-chip"
|
|
2012
|
+
type="button"
|
|
2013
|
+
@click=${()=>{var w;return(w=e.onSuggestionClick)==null?void 0:w.call(e,e.suggestion)}}
|
|
2014
|
+
>
|
|
2015
|
+
${e.suggestion}
|
|
2016
|
+
</button>
|
|
2017
|
+
</div>
|
|
2018
|
+
`:k}
|
|
2019
|
+
|
|
2008
2020
|
<div class="chat-compose">
|
|
2009
2021
|
${my(e)}
|
|
2010
2022
|
<div class="chat-compose__row">
|
|
@@ -2971,7 +2983,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2971
2983
|
</p>`:k}
|
|
2972
2984
|
</div>
|
|
2973
2985
|
</div>
|
|
2974
|
-
`}const Nr="taskmaster-access-session",Oc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Bc(){try{return localStorage.getItem(Nr)}catch{return null}}function Fc(e){try{localStorage.setItem(Nr,e)}catch{}}function nv(){try{localStorage.removeItem(Nr)}catch{}}async function Ra(e){if(e.client)try{const t=Bc(),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 sv(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?(Fc(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 iv(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?(Fc(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 rv(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 ov(e){const t=Bc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}nv(),e.accessState={...Oc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Wi(e){return(await e.request("apikeys.list")).providers??[]}async function Ia(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function av(e,t){await e.request("apikeys.remove",{provider:t})}class lv{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){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const s=document.getElementById("browser-screencast-canvas");s&&this.attach(s)}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,r=this.canvas.height/s.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*o),y:Math.round(n*r*a)}}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 di=null;function nn(){return di||(di=new lv),di}function Dr(e){return e instanceof Error?e.message:String(e)}async function cv(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Dr(t)}finally{e.browserLoading=!1}}async function uv(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Dr(t)}finally{e.browserLoading=!1}}}async function pi(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 hi(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!=null&&s.text?{text:s.text}:{},...s!=null&&s.code?{code:s.code}:{},...s!=null&&s.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function dv(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=Dr(t)}}function pv(e){e.browserInputMode=!e.browserInputMode}function hv(e){e.browserFullscreen=!e.browserFullscreen,nn().detach()}function fv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,nn().updateFrame(t.data,t.metadata)}function gv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function mv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function yv(e,t="admin"){var i;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t&&r.agentId!=="management")continue;const o=r.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 c=l.id??"";c&&s.push({phone:c,paired:((i=r.meta)==null?void 0:i.paired)===!0})}return s.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),s}function Uc(e,t,n="admin",s){const i=c=>c===n||c==="management",r=new Map,o=new Map;for(const c of e){if(!c||typeof c!="object"||!i(c.agentId))continue;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")continue;const d=u.peer;if(!d||typeof d!="object"||d.kind!=="dm")continue;const h=d.id??"";h&&(c.meta&&r.set(h,c.meta),u.accountId&&o.set(h,u.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!i(c.agentId))return!0;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")return!0;const d=u.peer;return!d||typeof d!="object"?!0:d.kind!=="dm"}),l=t.map(c=>{const u=s??o.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};u&&(p.accountId=u);const d={agentId:n,match:p},h=r.get(c.phone);return h?d.meta=h:c.paired&&(d.meta={paired:!0}),d});return[...a,...l]}async function xs(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=Ue(i??{}),e.adminPhones=yv(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function Wc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=[...e.adminPhones,{phone:r}],p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Kc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n,r=e.adminPhones.find(l=>l.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=e.adminPhones.filter(b=>b.phone!==t),p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const vv=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Wc,loadAdmins:xs,removeAdmin:Kc},Symbol.toStringTag,{value:"Module"}));async function ot(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 zc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!i){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:r,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await ot(e,s)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function jc(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 ot(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function Hc(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 ot(e,i)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function qc(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 ot(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const bv=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:zc,deleteCustomer:jc,deleteCustomerField:qc,loadCustomers:ot,setCustomerField:Hc},Symbol.toStringTag,{value:"Module"}));function qt(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function wv(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function kv(e){const t=ne(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return n==null?void 0:n.id}function Sv(e){const t=ne(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function xv(e){var n;const t=ne(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function Av(e){return e.selectedWorkspace??void 0}function ne(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const $v=/^data:/i,Ev=/^https?:\/\//i;function Tv(e){var a,l;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Va(e.sessionKey),s=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",i=t.find(c=>c.id===s),r=i==null?void 0:i.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return $v.test(o)||Ev.test(o)?o:r==null?void 0:r.avatarUrl}function Cv(e){var s;if(!e)return null;const t=(s=e.channelAccounts)==null?void 0:s.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 _v(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.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,r=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Mv(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(a=>{var l,c;return((l=a.match)==null?void 0:l.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!s)return null;const i=s.agentId;for(const a of e.workspaces)if(a.agents.some(l=>l.id===i))return a.name;if(i==="admin"||i==="public"){const a=e.workspaces.find(l=>l.isDefault);return(a==null?void 0:a.name)??null}const r=i.replace(/-(admin|public)$/,"");if(r!==i){const a=e.workspaces.find(l=>l.name===r);return(a==null?void 0:a.name)??null}return null}function Lv(e){var t,n,s,i,r,o,a;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Pa({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(c,u)=>{u!=null&&e.handlePinSubmit(c,u)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(c,u,p)=>e.handleChangePin(c,u,p)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Pa({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:c=>e.handleSetMasterPin(c)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Cv(e.channelsSnapshot),c=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],u=_v(e.channelsSnapshot),p=Mv(e);return Oh({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:d=>e.handleLicenseKeyChange(d),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:l,whatsappAccounts:c,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:d=>e.handleUninstallConfirmTextChange(d),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:d=>e.handleAuthSubmitCode(d),onAuthCodeChange:d=>e.handleAuthCodeChange(d),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async d=>{await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onWhatsAppReset:async d=>{await e.handleWhatsAppLogout(d),await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await q(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),q(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:d=>e.handleRemoveWhatsAppAccount(d),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:d=>{e.newWorkspacePin=d},onWorkspaceCreate:async(d,h)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(d,h),b.match(/^\d{4,6}$/)&&(await rv(e,d,b),e.newWorkspacePin="")},onWorkspaceRemove:d=>e.handleWorkspaceRemove(d),onSetAddingWorkspace:d=>{e.addingWorkspace=d},onSetNewWorkspaceName:d=>{e.newWorkspaceName=d},onSetNewWorkspacePath:d=>{e.newWorkspacePath=d},onSetWorkspaceRemoveConfirm:d=>{e.workspaceRemoveConfirm=d},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(d,h)=>e.handleWorkspaceRename(d,h),whatsappDmPolicy:(()=>{const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(w=>w.accountId===h):c[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var A;const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(E=>E.accountId===h):c[0];if(!b)return;const S=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",T=S==="open"?{dmPolicy:S,allowFrom:["*"]}:{dmPolicy:S};try{const E=await e.client.request("config.get"),C=E.config,R=(A=C==null?void 0:C.channels)==null?void 0:A.whatsapp,Q=((R==null?void 0:R.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(Q),baseHash:E.hash,note:`WhatsApp DM policy → ${S}`,skipRestart:!0}),await q(e,!1)}catch(E){console.error("DM toggle failed:",E)}},whatsappModel:(()=>{var A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(A=e.configSnapshot)==null?void 0:A.config,w=(E=b==null?void 0:b.agents)==null?void 0:E.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);if(!(S!=null&&S.model))return null;const T=typeof S.model=="string"?S.model:S.model.primary;return(T==null?void 0:T.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(R=>R.id===b.id);if(d)E>=0?A[E]={...A[E],model:d}:A.push({id:b.id,model:d});else if(E>=0){const{model:R,...U}=A[E];Object.keys(U).length<=1?A.splice(E,1):A[E]=U}const C=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:w.hash,note:`Public agent model → ${d||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Model change failed:",w)}},whatsappThinkingLevel:(()=>{var T,A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(T=e.configSnapshot)==null?void 0:T.config,w=(A=b==null?void 0:b.agents)==null?void 0:A.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);return((E=S==null?void 0:S.thinkingLevel)==null?void 0:E.trim())||null})(),onWhatsAppThinkingChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(U=>U.id===b.id),C=d==="off"?void 0:d;if(C)E>=0?A[E]={...A[E],thinkingLevel:C}:A.push({id:b.id,thinkingLevel:C});else if(E>=0){const{thinkingLevel:U,...Q}=A[E];Object.keys(Q).length<=1?A.splice(E,1):A[E]=Q}const R=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:w.hash,note:`Public agent thinking → ${C||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Thinking change failed:",w)}},whatsappGroupPolicy:(()=>{var E,C;const d=(E=e.configSnapshot)==null?void 0:E.config,h=(C=d==null?void 0:d.channels)==null?void 0:C.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0;return(T==null?void 0:T.groupPolicy)??(h==null?void 0:h.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var C,R;const d=(C=e.configSnapshot)==null?void 0:C.config,h=(R=d==null?void 0:d.channels)==null?void 0:R.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0,E=((T==null?void 0:T.groups)??(h==null?void 0:h.groups)??{})["*"];return(E==null?void 0:E.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const d=ne(e),h=d==null?void 0:d.whatsappAccountId;try{const w=await e.client.request("config.get"),S=w.config,T=((b=S==null?void 0:S.channels)==null?void 0:b.whatsapp)??{},A=T.accounts??{},E=h?A[h]:void 0,C=(E==null?void 0:E.groupPolicy)??T.groupPolicy??"allowlist",R=C==="disabled"||C==="allowlist",U=R?"open":"disabled",Q=R?{"*":{}}:void 0,ze={groupPolicy:U};Q&&(ze.groups=Q);const Lt=E?{channels:{whatsapp:{accounts:{[h]:ze}}}}:{channels:{whatsapp:ze}};await e.client.request("config.patch",{raw:JSON.stringify(Lt),baseHash:w.hash,note:`WhatsApp groups → ${U}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Group toggle failed:",w)}},onWhatsAppGroupMentionChange:async d=>{var w;const h=ne(e),b=h==null?void 0:h.whatsappAccountId;try{const S=await e.client.request("config.get"),T=S.config,E=(((w=T==null?void 0:T.channels)==null?void 0:w.whatsapp)??{}).accounts??{},C=b?E[b]:void 0,R={"*":{requireMention:d}},U=C?{channels:{whatsapp:{accounts:{[b]:{groups:R}}}}}:{channels:{whatsapp:{groups:R}}};await e.client.request("config.patch",{raw:JSON.stringify(U),baseHash:S.hash,note:`WhatsApp group mention → ${d?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(S){console.error("Group mention change failed:",S)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:u.configured,imessageRunning:u.running,imessageConnected:u.connected,imessageLastError:u.lastError,imessageSelfChatMode:u.selfChatMode,imessageCliPath:u.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:p,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(R=>{var U;return((U=R.match)==null?void 0:U.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],C=[...A,...E];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:C}),baseHash:d.hash,note:"Enable iMessage (self-chat) for "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await q(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,w=((h==null?void 0:h.bindings)??[]).filter(S=>{var T;return((T=S.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:w}),baseHash:d.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(C=>C.id.endsWith("-admin")||C.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(C=>{var R;return((R=C.match)==null?void 0:R.channel)!=="imessage"}),E=[{agentId:T,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:[...A,...E]}),baseHash:d.hash,note:"Reassign iMessage to "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:d=>{e.infoModalOpen=d},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(d,h)=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ia(e.client,d,h);const b=`${d} key saved`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}d==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async d=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await av(e.client,d);const h=`${d} key removed`;e.apiKeySuccess=h,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===h&&(e.apiKeySuccess=null)},2500)}catch(h){e.apiKeyError=h instanceof Error?h.message:"Failed to remove key",e.apiKeySavingProvider=null}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:d=>{e.authApiKeyInput=d},onAuthApiKeySubmit:async()=>{const d=e.authApiKeyInput.trim();if(d){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ia(e.client,"anthropic",d),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(h){e.authApiKeyError=h instanceof Error?h.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var h;const d=e.selectedWorkspace??((h=e.workspaces[0])==null?void 0:h.name);return d?e.accessState.accounts.some(b=>b.id===d):!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:(d,h)=>{var w;const b=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);b&&e.handleAccountPinSave(b,d,h)},wsProps:wv(e)})}if(e.filesPage){const l=xv(e);return Ah({connected:e.connected,wsProps:qt(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:()=>pn(e,l),onReindex:()=>Np(e,l),onSelectFile:c=>_p(e,c,l),onToggleSelectFile:c=>Mp(e,c,l),onToggleDir:c=>Dp(e,c),onUpload:(c,u)=>Rp(e,c,u,l),onDownload:c=>Il(e,c,l),onBulkDownload:()=>Lp(e,l),onDelete:c=>Ip(e,c,l),onMove:(c,u)=>Nl(e,c,u,l),onMoveToDir:(c,u)=>Pp(e,c,u,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:c=>{const u=e.filesSearchAgentId??l;Op(e,c,u)},onSearchAgentChange:c=>{e.filesSearchAgentId=c},onSearchClear:()=>{Bp(e)},onSearchQueryChange:c=>{e.filesSearchQuery=c}})}if(e.browserPage)return yh({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>cv(e),onStop:()=>uv(e),onToggleInput:()=>pv(e),onToggleFullscreen:()=>hv(e),onCompleteHandoff:()=>dv(e),onCanvasMouseDown:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mousePressed",d.x,d.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mouseReleased",d.x,d.y)},onCanvasMouseMove:l=>{const c=nn();if(c.shouldThrottleMouseMove())return;const p=l.target.getBoundingClientRect(),d=c.translateCoordinates(l.clientX-p.left,l.clientY-p.top);pi(e,"mouseMoved",d.x,d.y)},onCanvasKeyDown:l=>{let c=0;l.altKey&&(c|=1),l.ctrlKey&&(c|=2),l.metaKey&&(c|=4),l.shiftKey&&(c|=8),hi(e,"keyDown",l.key,{code:l.code,modifiers:c||void 0}),l.key.length===1&&hi(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{hi(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=kv(e),c=Sv(e);return Fh({connected:e.connected,wsProps:qt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>xs(e,l),onAdd:u=>{Wc(e,u,l,c).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:u=>Kc(e,u,l,c),onNewPhoneChange:u=>e.handleAdminsNewPhoneChange(u)})}if(e.customersPage){const l=Av(e);return zh({connected:e.connected,wsProps:qt(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:c=>e.customersSearchQuery=c,onSearchSubmit:()=>ot(e,l),onAdd:(c,u)=>zc(e,c,u,l),onDelete:c=>jc(e,c,l),onSetField:(c,u,p)=>Hc(e,c,u,p,l),onDeleteField:(c,u)=>qc(e,c,u,l),onToggleExpand:c=>{e.customersEditingId=e.customersEditingId===c?null:c},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:c=>e.handleCustomersNewPhoneChange(c),onNewRecordNameChange:c=>e.handleCustomersNewNameChange(c),onRefresh:()=>ot(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",c=Tv(e),u=e.chatAvatarUrl??c??null;return $y({connected:e.connected,wsProps:qt(e),sessionKey:e.sessionKey,onSessionKeyChange:p=>{e.sessionKey=p,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),Me(e),Ai(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:p=>{Cn(e,e.sessionKey,{model:p}).then(()=>{Me(e)})},onThinkingLevelChange:p=>{Cn(e,e.sessionKey,{thinkingLevel:p==="off"?null:p}).then(()=>{Me(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:p=>{Cn(e,e.sessionKey,{verboseLevel:p==="off"?null:p}).then(()=>{Me(e)})},onFillerChange:p=>{Cn(e,e.sessionKey,{fillerEnabled:p}).then(()=>{Me(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Me(e),Ai(e)])),onToggleFocusMode:()=>{},onChatScroll:p=>e.handleChatScroll(p),nearBottom:e.chatUserNearBottom,onDraftChange:p=>e.chatMessage=p,attachments:e.chatAttachments,onAttachmentsChange:p=>e.chatAttachments=p,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:p=>e.removeQueuedMessage(p),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:p=>e.handleOpenSidebar(p),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:p=>e.handleSplitRatioChange(p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?tv({connected:e.connected,wsProps:qt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&$t(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(i=(s=e.channelsSnapshot)==null?void 0:s.channelMeta)!=null&&i.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((r=e.channelsSnapshot)==null?void 0:r.channelOrder)??[],channelLabels:((o=e.channelsSnapshot)==null?void 0:o.channelLabels)??{},channelMeta:((a=e.channelsSnapshot)==null?void 0:a.channelMeta)??[],agentIds:(()=>{var c;const l=ne(e);return((c=l==null?void 0:l.agents)==null?void 0:c.map(u=>u.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,bi(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Cd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,c)=>_d(e,l,c),onRun:l=>Md(e,l),onRemove:l=>Ld(e,l),onLoadRuns:l=>bi(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>$t(e,{clearMessages:!0}),onToggle:(l,c)=>vp(e,l,c),onEdit:(l,c)=>yp(e,l,c),onSaveKey:l=>bp(e,l),onInstall:(l,c,u)=>wp(e,l,c,u)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?wt(e,{reset:!0}):Jt(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:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,c)=>{const u=e;u.sessionLogsTypeFilters={...u.sessionLogsTypeFilters,[l]:c}},onAgentToggle:(l,c)=>{const u=e;u.sessionLogsAgentFilters={...u.sessionLogsAgentFilters,[l]:c}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleFull:l=>{e.sessionLogsFull=l,wt(e,{reset:!0})},onRefresh:()=>{wt(e,{reset:!0})},onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleSessionLogsScroll(l)},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:l=>e.logsFilterText=l,onLevelToggle:(l,c)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:c}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Jt(e,{reset:!0}),onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),f``)}function Pv(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${s}`}function Na(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Rv(e,t,n){return f`
|
|
2986
|
+
`}const Nr="taskmaster-access-session",Oc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Bc(){try{return localStorage.getItem(Nr)}catch{return null}}function Fc(e){try{localStorage.setItem(Nr,e)}catch{}}function nv(){try{localStorage.removeItem(Nr)}catch{}}async function Ra(e){if(e.client)try{const t=Bc(),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 sv(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?(Fc(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 iv(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?(Fc(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 rv(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 ov(e){const t=Bc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}nv(),e.accessState={...Oc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Wi(e){return(await e.request("apikeys.list")).providers??[]}async function Ia(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function av(e,t){await e.request("apikeys.remove",{provider:t})}class lv{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){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const s=document.getElementById("browser-screencast-canvas");s&&this.attach(s)}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,r=this.canvas.height/s.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*o),y:Math.round(n*r*a)}}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 di=null;function nn(){return di||(di=new lv),di}function Dr(e){return e instanceof Error?e.message:String(e)}async function cv(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Dr(t)}finally{e.browserLoading=!1}}async function uv(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Dr(t)}finally{e.browserLoading=!1}}}async function pi(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 hi(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!=null&&s.text?{text:s.text}:{},...s!=null&&s.code?{code:s.code}:{},...s!=null&&s.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function dv(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=Dr(t)}}function pv(e){e.browserInputMode=!e.browserInputMode}function hv(e){e.browserFullscreen=!e.browserFullscreen,nn().detach()}function fv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,nn().updateFrame(t.data,t.metadata)}function gv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function mv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function yv(e,t="admin"){var i;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t&&r.agentId!=="management")continue;const o=r.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 c=l.id??"";c&&s.push({phone:c,paired:((i=r.meta)==null?void 0:i.paired)===!0})}return s.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),s}function Uc(e,t,n="admin",s){const i=c=>c===n||c==="management",r=new Map,o=new Map;for(const c of e){if(!c||typeof c!="object"||!i(c.agentId))continue;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")continue;const d=u.peer;if(!d||typeof d!="object"||d.kind!=="dm")continue;const h=d.id??"";h&&(c.meta&&r.set(h,c.meta),u.accountId&&o.set(h,u.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!i(c.agentId))return!0;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")return!0;const d=u.peer;return!d||typeof d!="object"?!0:d.kind!=="dm"}),l=t.map(c=>{const u=s??o.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};u&&(p.accountId=u);const d={agentId:n,match:p},h=r.get(c.phone);return h?d.meta=h:c.paired&&(d.meta={paired:!0}),d});return[...a,...l]}async function xs(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=Ue(i??{}),e.adminPhones=yv(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function Wc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=[...e.adminPhones,{phone:r}],p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Kc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n,r=e.adminPhones.find(l=>l.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=e.adminPhones.filter(b=>b.phone!==t),p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const vv=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Wc,loadAdmins:xs,removeAdmin:Kc},Symbol.toStringTag,{value:"Module"}));async function ot(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 zc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!i){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:r,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await ot(e,s)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function jc(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 ot(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function Hc(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 ot(e,i)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function qc(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 ot(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const bv=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:zc,deleteCustomer:jc,deleteCustomerField:qc,loadCustomers:ot,setCustomerField:Hc},Symbol.toStringTag,{value:"Module"}));function qt(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function wv(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function kv(e){const t=ne(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return n==null?void 0:n.id}function Sv(e){const t=ne(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function xv(e){var n;const t=ne(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function Av(e){return e.selectedWorkspace??void 0}function ne(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const $v=/^data:/i,Ev=/^https?:\/\//i;function Tv(e){var a,l;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Va(e.sessionKey),s=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",i=t.find(c=>c.id===s),r=i==null?void 0:i.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return $v.test(o)||Ev.test(o)?o:r==null?void 0:r.avatarUrl}function Cv(e){var s;if(!e)return null;const t=(s=e.channelAccounts)==null?void 0:s.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 _v(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.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,r=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Mv(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(a=>{var l,c;return((l=a.match)==null?void 0:l.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!s)return null;const i=s.agentId;for(const a of e.workspaces)if(a.agents.some(l=>l.id===i))return a.name;if(i==="admin"||i==="public"){const a=e.workspaces.find(l=>l.isDefault);return(a==null?void 0:a.name)??null}const r=i.replace(/-(admin|public)$/,"");if(r!==i){const a=e.workspaces.find(l=>l.name===r);return(a==null?void 0:a.name)??null}return null}function Lv(e){var t,n,s,i,r,o,a;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Pa({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(c,u)=>{u!=null&&e.handlePinSubmit(c,u)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(c,u,p)=>e.handleChangePin(c,u,p)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Pa({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:c=>e.handleSetMasterPin(c)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Cv(e.channelsSnapshot),c=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],u=_v(e.channelsSnapshot),p=Mv(e);return Oh({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:d=>e.handleLicenseKeyChange(d),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:l,whatsappAccounts:c,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:d=>e.handleUninstallConfirmTextChange(d),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:d=>e.handleAuthSubmitCode(d),onAuthCodeChange:d=>e.handleAuthCodeChange(d),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async d=>{await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onWhatsAppReset:async d=>{await e.handleWhatsAppLogout(d),await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await q(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),q(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:d=>e.handleRemoveWhatsAppAccount(d),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:d=>{e.newWorkspacePin=d},onWorkspaceCreate:async(d,h)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(d,h),b.match(/^\d{4,6}$/)&&(await rv(e,d,b),e.newWorkspacePin="")},onWorkspaceRemove:d=>e.handleWorkspaceRemove(d),onSetAddingWorkspace:d=>{e.addingWorkspace=d},onSetNewWorkspaceName:d=>{e.newWorkspaceName=d},onSetNewWorkspacePath:d=>{e.newWorkspacePath=d},onSetWorkspaceRemoveConfirm:d=>{e.workspaceRemoveConfirm=d},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(d,h)=>e.handleWorkspaceRename(d,h),whatsappDmPolicy:(()=>{const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(w=>w.accountId===h):c[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var A;const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(E=>E.accountId===h):c[0];if(!b)return;const S=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",T=S==="open"?{dmPolicy:S,allowFrom:["*"]}:{dmPolicy:S};try{const E=await e.client.request("config.get"),C=E.config,R=(A=C==null?void 0:C.channels)==null?void 0:A.whatsapp,Q=((R==null?void 0:R.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(Q),baseHash:E.hash,note:`WhatsApp DM policy → ${S}`,skipRestart:!0}),await q(e,!1)}catch(E){console.error("DM toggle failed:",E)}},whatsappModel:(()=>{var A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(A=e.configSnapshot)==null?void 0:A.config,w=(E=b==null?void 0:b.agents)==null?void 0:E.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);if(!(S!=null&&S.model))return null;const T=typeof S.model=="string"?S.model:S.model.primary;return(T==null?void 0:T.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(R=>R.id===b.id);if(d)E>=0?A[E]={...A[E],model:d}:A.push({id:b.id,model:d});else if(E>=0){const{model:R,...U}=A[E];Object.keys(U).length<=1?A.splice(E,1):A[E]=U}const C=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:w.hash,note:`Public agent model → ${d||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Model change failed:",w)}},whatsappThinkingLevel:(()=>{var T,A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(T=e.configSnapshot)==null?void 0:T.config,w=(A=b==null?void 0:b.agents)==null?void 0:A.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);return((E=S==null?void 0:S.thinkingLevel)==null?void 0:E.trim())||null})(),onWhatsAppThinkingChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(U=>U.id===b.id),C=d==="off"?void 0:d;if(C)E>=0?A[E]={...A[E],thinkingLevel:C}:A.push({id:b.id,thinkingLevel:C});else if(E>=0){const{thinkingLevel:U,...Q}=A[E];Object.keys(Q).length<=1?A.splice(E,1):A[E]=Q}const R=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:w.hash,note:`Public agent thinking → ${C||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Thinking change failed:",w)}},whatsappGroupPolicy:(()=>{var E,C;const d=(E=e.configSnapshot)==null?void 0:E.config,h=(C=d==null?void 0:d.channels)==null?void 0:C.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0;return(T==null?void 0:T.groupPolicy)??(h==null?void 0:h.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var C,R;const d=(C=e.configSnapshot)==null?void 0:C.config,h=(R=d==null?void 0:d.channels)==null?void 0:R.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0,E=((T==null?void 0:T.groups)??(h==null?void 0:h.groups)??{})["*"];return(E==null?void 0:E.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const d=ne(e),h=d==null?void 0:d.whatsappAccountId;try{const w=await e.client.request("config.get"),S=w.config,T=((b=S==null?void 0:S.channels)==null?void 0:b.whatsapp)??{},A=T.accounts??{},E=h?A[h]:void 0,C=(E==null?void 0:E.groupPolicy)??T.groupPolicy??"allowlist",R=C==="disabled"||C==="allowlist",U=R?"open":"disabled",Q=R?{"*":{}}:void 0,ze={groupPolicy:U};Q&&(ze.groups=Q);const Lt=E?{channels:{whatsapp:{accounts:{[h]:ze}}}}:{channels:{whatsapp:ze}};await e.client.request("config.patch",{raw:JSON.stringify(Lt),baseHash:w.hash,note:`WhatsApp groups → ${U}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Group toggle failed:",w)}},onWhatsAppGroupMentionChange:async d=>{var w;const h=ne(e),b=h==null?void 0:h.whatsappAccountId;try{const S=await e.client.request("config.get"),T=S.config,E=(((w=T==null?void 0:T.channels)==null?void 0:w.whatsapp)??{}).accounts??{},C=b?E[b]:void 0,R={"*":{requireMention:d}},U=C?{channels:{whatsapp:{accounts:{[b]:{groups:R}}}}}:{channels:{whatsapp:{groups:R}}};await e.client.request("config.patch",{raw:JSON.stringify(U),baseHash:S.hash,note:`WhatsApp group mention → ${d?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(S){console.error("Group mention change failed:",S)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:u.configured,imessageRunning:u.running,imessageConnected:u.connected,imessageLastError:u.lastError,imessageSelfChatMode:u.selfChatMode,imessageCliPath:u.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:p,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(R=>{var U;return((U=R.match)==null?void 0:U.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],C=[...A,...E];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:C}),baseHash:d.hash,note:"Enable iMessage (self-chat) for "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await q(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,w=((h==null?void 0:h.bindings)??[]).filter(S=>{var T;return((T=S.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:w}),baseHash:d.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(C=>C.id.endsWith("-admin")||C.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(C=>{var R;return((R=C.match)==null?void 0:R.channel)!=="imessage"}),E=[{agentId:T,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:[...A,...E]}),baseHash:d.hash,note:"Reassign iMessage to "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:d=>{e.infoModalOpen=d},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(d,h)=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ia(e.client,d,h);const b=`${d} key saved`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}d==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async d=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await av(e.client,d);const h=`${d} key removed`;e.apiKeySuccess=h,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===h&&(e.apiKeySuccess=null)},2500)}catch(h){e.apiKeyError=h instanceof Error?h.message:"Failed to remove key",e.apiKeySavingProvider=null}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:d=>{e.authApiKeyInput=d},onAuthApiKeySubmit:async()=>{const d=e.authApiKeyInput.trim();if(d){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ia(e.client,"anthropic",d),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(h){e.authApiKeyError=h instanceof Error?h.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var h;const d=e.selectedWorkspace??((h=e.workspaces[0])==null?void 0:h.name);return d?e.accessState.accounts.some(b=>b.id===d):!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:(d,h)=>{var w;const b=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);b&&e.handleAccountPinSave(b,d,h)},wsProps:wv(e)})}if(e.filesPage){const l=xv(e);return Ah({connected:e.connected,wsProps:qt(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:()=>pn(e,l),onReindex:()=>Np(e,l),onSelectFile:c=>_p(e,c,l),onToggleSelectFile:c=>Mp(e,c,l),onToggleDir:c=>Dp(e,c),onUpload:(c,u)=>Rp(e,c,u,l),onDownload:c=>Il(e,c,l),onBulkDownload:()=>Lp(e,l),onDelete:c=>Ip(e,c,l),onMove:(c,u)=>Nl(e,c,u,l),onMoveToDir:(c,u)=>Pp(e,c,u,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:c=>{const u=e.filesSearchAgentId??l;Op(e,c,u)},onSearchAgentChange:c=>{e.filesSearchAgentId=c},onSearchClear:()=>{Bp(e)},onSearchQueryChange:c=>{e.filesSearchQuery=c}})}if(e.browserPage)return yh({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>cv(e),onStop:()=>uv(e),onToggleInput:()=>pv(e),onToggleFullscreen:()=>hv(e),onCompleteHandoff:()=>dv(e),onCanvasMouseDown:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mousePressed",d.x,d.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mouseReleased",d.x,d.y)},onCanvasMouseMove:l=>{const c=nn();if(c.shouldThrottleMouseMove())return;const p=l.target.getBoundingClientRect(),d=c.translateCoordinates(l.clientX-p.left,l.clientY-p.top);pi(e,"mouseMoved",d.x,d.y)},onCanvasKeyDown:l=>{let c=0;l.altKey&&(c|=1),l.ctrlKey&&(c|=2),l.metaKey&&(c|=4),l.shiftKey&&(c|=8),hi(e,"keyDown",l.key,{code:l.code,modifiers:c||void 0}),l.key.length===1&&hi(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{hi(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=kv(e),c=Sv(e);return Fh({connected:e.connected,wsProps:qt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>xs(e,l),onAdd:u=>{Wc(e,u,l,c).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:u=>Kc(e,u,l,c),onNewPhoneChange:u=>e.handleAdminsNewPhoneChange(u)})}if(e.customersPage){const l=Av(e);return zh({connected:e.connected,wsProps:qt(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:c=>e.customersSearchQuery=c,onSearchSubmit:()=>ot(e,l),onAdd:(c,u)=>zc(e,c,u,l),onDelete:c=>jc(e,c,l),onSetField:(c,u,p)=>Hc(e,c,u,p,l),onDeleteField:(c,u)=>qc(e,c,u,l),onToggleExpand:c=>{e.customersEditingId=e.customersEditingId===c?null:c},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:c=>e.handleCustomersNewPhoneChange(c),onNewRecordNameChange:c=>e.handleCustomersNewNameChange(c),onRefresh:()=>ot(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",c=Tv(e),u=e.chatAvatarUrl??c??null;return $y({connected:e.connected,wsProps:qt(e),sessionKey:e.sessionKey,onSessionKeyChange:p=>{e.sessionKey=p,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),Me(e),Ai(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:p=>{Cn(e,e.sessionKey,{model:p}).then(()=>{Me(e)})},onThinkingLevelChange:p=>{Cn(e,e.sessionKey,{thinkingLevel:p==="off"?null:p}).then(()=>{Me(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:p=>{e.chatMessage=p,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:p=>{Cn(e,e.sessionKey,{verboseLevel:p==="off"?null:p}).then(()=>{Me(e)})},onFillerChange:p=>{Cn(e,e.sessionKey,{fillerEnabled:p}).then(()=>{Me(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Me(e),Ai(e)])),onToggleFocusMode:()=>{},onChatScroll:p=>e.handleChatScroll(p),nearBottom:e.chatUserNearBottom,onDraftChange:p=>e.chatMessage=p,attachments:e.chatAttachments,onAttachmentsChange:p=>e.chatAttachments=p,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:p=>e.removeQueuedMessage(p),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:p=>e.handleOpenSidebar(p),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:p=>e.handleSplitRatioChange(p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?tv({connected:e.connected,wsProps:qt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&$t(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(i=(s=e.channelsSnapshot)==null?void 0:s.channelMeta)!=null&&i.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((r=e.channelsSnapshot)==null?void 0:r.channelOrder)??[],channelLabels:((o=e.channelsSnapshot)==null?void 0:o.channelLabels)??{},channelMeta:((a=e.channelsSnapshot)==null?void 0:a.channelMeta)??[],agentIds:(()=>{var c;const l=ne(e);return((c=l==null?void 0:l.agents)==null?void 0:c.map(u=>u.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,bi(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Cd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,c)=>_d(e,l,c),onRun:l=>Md(e,l),onRemove:l=>Ld(e,l),onLoadRuns:l=>bi(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>$t(e,{clearMessages:!0}),onToggle:(l,c)=>vp(e,l,c),onEdit:(l,c)=>yp(e,l,c),onSaveKey:l=>bp(e,l),onInstall:(l,c,u)=>wp(e,l,c,u)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?wt(e,{reset:!0}):Jt(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:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,c)=>{const u=e;u.sessionLogsTypeFilters={...u.sessionLogsTypeFilters,[l]:c}},onAgentToggle:(l,c)=>{const u=e;u.sessionLogsAgentFilters={...u.sessionLogsAgentFilters,[l]:c}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleFull:l=>{e.sessionLogsFull=l,wt(e,{reset:!0})},onRefresh:()=>{wt(e,{reset:!0})},onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleSessionLogsScroll(l)},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:l=>e.logsFilterText=l,onLevelToggle:(l,c)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:c}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Jt(e,{reset:!0}),onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),f``)}function Pv(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${s}`}function Na(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Rv(e,t,n){return f`
|
|
2975
2987
|
<div class="audit-modal-overlay" @click=${i=>{i.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
2976
2988
|
<div class="audit-modal-card">
|
|
2977
2989
|
<div class="audit-modal-header">
|
|
@@ -3003,7 +3015,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
3003
3015
|
`}
|
|
3004
3016
|
</div>
|
|
3005
3017
|
</div>
|
|
3006
|
-
`}const Iv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Nv={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 Dv(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 fn(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 Ov(e,t){var s,i;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 r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(s=t.workspacePath)!=null&&s.trim()&&(a.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await fn(e),(i=t.onCreated)==null||i.call(t,l)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function Bv(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 fn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Fv(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 fn(e)}catch(s){e.workspacesError=String(s)}}}const Un=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Ov,loadWorkspaces:fn,removeWorkspace:Bv,renameWorkspace:Fv},Symbol.toStringTag,{value:"Module"})),Gc={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"},Da=Gc,Ki={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gc));new Set(Object.values(Ki));function Uv(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 Wv=4008;class Kv{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(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.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=>{var s,i;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(i=(s=this.opts).onClose)==null||i.call(s,{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(){var u;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,r=!1,o=this.opts.token;if(t){i=await lp();const p=(u=dp({deviceId:i.deviceId,role:s}))==null?void 0:u.token;o=p??this.opts.token,r=!!(p&&this.opts.token)}const a=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const p=Date.now(),d=this.connectNonce??void 0,h=Uv({deviceId:i.deviceId,clientId:this.opts.clientName??Da.CONTROL_UI,clientMode:this.opts.mode??Ki.WEBCHAT,role:s,scopes:n,signedAtMs:p,token:o??null,nonce:d}),b=await cp(i.privateKey,h);l={id:i.deviceId,publicKey:i.publicKey,signature:b,signedAt:p,nonce:d}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Da.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ki.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:a,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(p=>{var d,h,b;(d=p==null?void 0:p.auth)!=null&&d.deviceToken&&i&&pp({deviceId:i.deviceId,role:p.auth.role??s,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(b=(h=this.opts).onHello)==null||b.call(h,p)}).catch(()=>{var p;r&&i&&hp({deviceId:i.deviceId,role:s}),(p=this.ws)==null||p.close(Wv,"connect failed")})}handleMessage(t){var i,r,o,a,l;let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const c=n;if(c.event==="connect.challenge"){const p=c.payload,d=p&&typeof p.nonce=="string"?p.nonce:null;d&&(this.connectNonce=d,this.sendConnect());return}const u=typeof c.seq=="number"?c.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((r=(i=this.opts).onGap)==null||r.call(i,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);try{(a=(o=this.opts).onEvent)==null||a.call(o,c)}catch(p){console.error("[gateway] event handler error:",p)}return}if(s.type==="res"){const c=n,u=this.pending.get(c.id);if(!u)return;this.pending.delete(c.id),c.ok?u.resolve(c.payload):u.reject(new Error(((l=c.error)==null?void 0:l.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=Vi(),i={type:"req",id:s,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(s,{resolve:l=>o(l),reject:a})});return this.ws.send(JSON.stringify(i)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function zi(e){return typeof e=="object"&&e!==null}function zv(e){if(!zi(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!zi(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,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!r?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:r}}function jv(e){if(!zi(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 Vc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Hv(e,t){const n=Vc(e).filter(s=>s.id!==t.id);return n.push(t),n}function Oa(e,t){return Vc(e).filter(n=>n.id!==t)}async function Qc(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 r=yi(i);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}const us="taskmaster_update_pending";async function Yc(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("update.status",{});e.currentVersion=s.current,e.latestVersion=s.latest,e.updateAvailable=s.updateAvailable,e.updateMessage=s.updateAvailable?`v${s.latest} available`:"Up to date"}catch(s){e.updateMessage=`Check failed: ${String(s)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function qv(e){var t,n,s,i;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(us,String(Date.now())),localStorage.removeItem(Or)}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")sn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(s=e.requestUpdate)==null||s.call(e);else throw sn(),new Error(r.result.reason||"Update failed")}catch(r){sn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(i=e.requestUpdate)==null||i.call(e)}}}function Gv(e,t){var s,i,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,l=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${l})`;const c=e.updateProgressSteps.find(u=>u.index===a);c?(c.status="running",c.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:"running"}],(s=e.requestUpdate)==null||s.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,l=t.total,c=t.ok,u=t.durationMs,p=e.updateProgressSteps.find(h=>h.index===a);p?(p.status=c?"done":"failed",p.durationMs=u):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:c?"done":"failed",durationMs:u}];const d=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${o} done (${a+1}/${l})`:`Update step failed: ${o}${d}`,(i=e.requestUpdate)==null||i.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,sn()}(r=e.requestUpdate)==null||r.call(e)}}async function Vv(e){var n,s,i,r;if(!e.client||!e.connected)return;const t=Yv();sn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,l=Date.now()-o.result.ts<a;if(!t&&!l||Xv(o.result.ts))return;e.updateLastResult=o.result;const c=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,o.result.status==="ok"){const u=(s=o.result.before)==null?void 0:s.version,p=c??o.result.currentVersion;e.updateMessage=u?`Updated: v${u} → v${p}`:`Updated to v${p}`}else{const u=o.result.reason??((i=o.result.failedStep)==null?void 0:i.name)??"unknown error";e.updateMessage=`Update failed: ${u}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}const Or="taskmaster_update_dismissed";function Qv(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Or,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Yv(){try{const e=localStorage.getItem(us);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(us),!1):!0:!1}catch{return!1}}function sn(){try{localStorage.removeItem(us)}catch{}}function Xv(e){try{const t=localStorage.getItem(Or);return t?Number(t)>=e:!1}catch{return!1}}function fi(e,t){var a,l,c;const n=(e??"").trim(),s=(a=t.mainSessionKey)==null?void 0:a.trim();if(!s)return n;if(!n)return s;const i=((l=t.mainKey)==null?void 0:l.trim())||"main",r=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===i||r&&(n===`agent:${r}:main`||n===`agent:${r}:${i}`)?s:n}function Zv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fi(e.sessionKey,t),s=fi(e.settings.sessionKey,t),i=fi(e.settings.lastActiveSessionKey,t),r=n||s||e.sessionKey,o={...e.settings,sessionKey:s||r,lastActiveSessionKey:i||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&Be(e,o)}function _e(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.customersPage||e.advancedPage?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Kv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:n,mode:"webchat",onHello:i=>{e.connected=!0,e.lastError=null,e.hello=i,ss()&&(yr(),e.uninstallDone=!1),tb(e,i),e.handleAccessCheck(),Vv(e).then(()=>{Yc(e)}),Qc(e),Dv(e),(e.chatPage||e.setup)&&nb(e),rr(e,{quiet:!0}),ir(e,{quiet:!0}),fn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(xe(e),sb(e)),ts(e)},onClose:({code:i,reason:r})=>{e.connected=!1,i!==1012&&(e.lastError=`disconnected (${i}): ${r||"no reason"}`)},onEvent:i=>Jv(e,i),onGap:({expected:i,received:r})=>{console.warn(`[gateway] event gap: expected seq ${i}, got ${r}`),ts(e)}}),e.client.start()}function Jv(e,t){try{eb(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function eb(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;gd(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&Dl(e,n.sessionKey);const s=il(e,n);(s==="final"||s==="error"||s==="aborted")&&(Yi(e),oh(e)),s==="final"&&Me(e);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&fr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ir(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=zv(t.payload);if(n){e.execApprovalQueue=Hv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Oa(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){fv(e,t.payload);return}if(t.event==="browser.handoff"){gv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){mv(e);return}if(t.event==="exec.approval.resolved"){const n=jv(t.payload);n&&(e.execApprovalQueue=Oa(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){Gv(e,t.payload);return}}function tb(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&Zv(e,n.sessionDefaults)}async function nb(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function sb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Wi(e.client)}catch{}}function ib(e){e.basePath=Vp();const t=We();if(ph(t.accentColor),window.scrollTo(0,0),Wp(e),e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,zp(e),_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.customersPage){document.title=`${t.name} Customers`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Zp(e,!0),Qp(e),Yp(e),window.addEventListener("popstate",e.popStateHandler),Hp(e),_e(e),Fp(e),e.tab==="logs"&&(e.logsSubTab==="session"?ur(e):lr(e)),e.tab==="debug"&&pr(e)}function rb(e){Sd(e)}function ob(e){var t;window.removeEventListener("popstate",e.popStateHandler),Up(e),cr(e),dr(e),hr(e),Kp(e),jp(e),Xp(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function ab(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.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(r=>{e.channelsSnapshot=r,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;cn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&rl(e,t.has("tab")||t.has("logsAutoFollow"))}function lb(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function cb(e,t,n){await Xi(e,t,n),await q(e,!0)}async function ub(e,t){await ll(e,t),await q(e,!0)}async function db(e,t){await cl(e,t),await q(e,!0)}async function pb(e,t){await ul(e,t)}async function hb(e,t){await dl(e,t)}async function fb(e){await $d(e),await xe(e),await q(e,!0)}async function gb(e){await xe(e),await q(e,!0)}function mb(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 r=s.trim(),o=i.join(":").trim();r&&o&&(t[r]=o)}return t}function Xc(e){var n,s,i;return((i=(((s=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:s.nostr)??[])[0])==null?void 0:i.accountId)??e.nostrProfileAccountId??"default"}function Zc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function yb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=lb(n??void 0)}function vb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function bb(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function wb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function kb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Xc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Zc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const r=(i==null?void 0:i.error)??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:mb(i==null?void 0: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 q(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Sb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Xc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Zc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const l=(i==null?void 0:i.error)??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const r=i.merged??i.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},i.saved&&await q(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function xb(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 Ab(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 $b(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=""):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 Eb(e,t){e.authCodeInput=t}function Tb(e){e.setupStep="whatsapp"}async function Cb(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 _b(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 Mb(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 Lb(e,t){e.licenseKey=t}async function Pb(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("health",{probe:!0});e.gatewayHealthy=s.ok===!0,e.gatewayHealthMessage=s.ok?`Healthy${s.durationMs?` (${s.durationMs}ms)`:""}`:"Unhealthy"}catch(s){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(s)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Rb(e){var t,n,s;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(i.ok&&((n=i.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(i){e.gatewayHealthMessage=`Restart failed: ${String(i)}`,e.gatewayRestartBusy=!1,(s=e.requestUpdate)==null||s.call(e)}}}var Ib=Object.defineProperty,Nb=Object.getOwnPropertyDescriptor,m=(e,t,n,s)=>{for(var i=s>1?void 0:s?Nb(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Ib(t,n,i),i};const gi=Ou();function Db(){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 Ob(){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 Bb(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Fb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Ub(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Wb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function Kb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function zb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends kt{constructor(){super(...arguments),this.settings=Us(),this.password="",this.tab="chat",this.onboarding=Db(),this.setup=Ob(),this.filesPage=Bb(),this.browserPage=Fb(),this.adminsPage=Ub(),this.customersPage=Wb(),this.chatPage=Kb(),this.advancedPage=zb(),this.advancedTab="cron",this.connected=!1,this.accessState=Oc,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=gi.name,this.assistantAvatar=gi.avatar,this.assistantAgentId=gi.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=`{
|
|
3018
|
+
`}const Iv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Nv={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 Dv(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 fn(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 Ov(e,t){var s,i;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 r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(s=t.workspacePath)!=null&&s.trim()&&(a.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await fn(e),(i=t.onCreated)==null||i.call(t,l)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function Bv(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 fn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Fv(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 fn(e)}catch(s){e.workspacesError=String(s)}}}const Un=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Ov,loadWorkspaces:fn,removeWorkspace:Bv,renameWorkspace:Fv},Symbol.toStringTag,{value:"Module"})),Gc={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"},Da=Gc,Ki={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gc));new Set(Object.values(Ki));function Uv(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 Wv=4008;class Kv{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(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.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=>{var s,i;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(i=(s=this.opts).onClose)==null||i.call(s,{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(){var u;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,r=!1,o=this.opts.token;if(t){i=await lp();const p=(u=dp({deviceId:i.deviceId,role:s}))==null?void 0:u.token;o=p??this.opts.token,r=!!(p&&this.opts.token)}const a=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const p=Date.now(),d=this.connectNonce??void 0,h=Uv({deviceId:i.deviceId,clientId:this.opts.clientName??Da.CONTROL_UI,clientMode:this.opts.mode??Ki.WEBCHAT,role:s,scopes:n,signedAtMs:p,token:o??null,nonce:d}),b=await cp(i.privateKey,h);l={id:i.deviceId,publicKey:i.publicKey,signature:b,signedAt:p,nonce:d}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Da.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ki.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:a,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(p=>{var d,h,b;(d=p==null?void 0:p.auth)!=null&&d.deviceToken&&i&&pp({deviceId:i.deviceId,role:p.auth.role??s,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(b=(h=this.opts).onHello)==null||b.call(h,p)}).catch(()=>{var p;r&&i&&hp({deviceId:i.deviceId,role:s}),(p=this.ws)==null||p.close(Wv,"connect failed")})}handleMessage(t){var i,r,o,a,l;let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const c=n;if(c.event==="connect.challenge"){const p=c.payload,d=p&&typeof p.nonce=="string"?p.nonce:null;d&&(this.connectNonce=d,this.sendConnect());return}const u=typeof c.seq=="number"?c.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((r=(i=this.opts).onGap)==null||r.call(i,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);try{(a=(o=this.opts).onEvent)==null||a.call(o,c)}catch(p){console.error("[gateway] event handler error:",p)}return}if(s.type==="res"){const c=n,u=this.pending.get(c.id);if(!u)return;this.pending.delete(c.id),c.ok?u.resolve(c.payload):u.reject(new Error(((l=c.error)==null?void 0:l.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=Vi(),i={type:"req",id:s,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(s,{resolve:l=>o(l),reject:a})});return this.ws.send(JSON.stringify(i)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function zi(e){return typeof e=="object"&&e!==null}function zv(e){if(!zi(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!zi(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,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!r?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:r}}function jv(e){if(!zi(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 Vc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Hv(e,t){const n=Vc(e).filter(s=>s.id!==t.id);return n.push(t),n}function Oa(e,t){return Vc(e).filter(n=>n.id!==t)}async function Qc(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 r=yi(i);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}const us="taskmaster_update_pending";async function Yc(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("update.status",{});e.currentVersion=s.current,e.latestVersion=s.latest,e.updateAvailable=s.updateAvailable,e.updateMessage=s.updateAvailable?`v${s.latest} available`:"Up to date"}catch(s){e.updateMessage=`Check failed: ${String(s)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function qv(e){var t,n,s,i;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(us,String(Date.now())),localStorage.removeItem(Or)}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")sn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(s=e.requestUpdate)==null||s.call(e);else throw sn(),new Error(r.result.reason||"Update failed")}catch(r){sn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(i=e.requestUpdate)==null||i.call(e)}}}function Gv(e,t){var s,i,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,l=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${l})`;const c=e.updateProgressSteps.find(u=>u.index===a);c?(c.status="running",c.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:"running"}],(s=e.requestUpdate)==null||s.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,l=t.total,c=t.ok,u=t.durationMs,p=e.updateProgressSteps.find(h=>h.index===a);p?(p.status=c?"done":"failed",p.durationMs=u):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:c?"done":"failed",durationMs:u}];const d=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${o} done (${a+1}/${l})`:`Update step failed: ${o}${d}`,(i=e.requestUpdate)==null||i.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,sn()}(r=e.requestUpdate)==null||r.call(e)}}async function Vv(e){var n,s,i,r;if(!e.client||!e.connected)return;const t=Yv();sn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,l=Date.now()-o.result.ts<a;if(!t&&!l||Xv(o.result.ts))return;e.updateLastResult=o.result;const c=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,o.result.status==="ok"){const u=(s=o.result.before)==null?void 0:s.version,p=c??o.result.currentVersion;e.updateMessage=u?`Updated: v${u} → v${p}`:`Updated to v${p}`}else{const u=o.result.reason??((i=o.result.failedStep)==null?void 0:i.name)??"unknown error";e.updateMessage=`Update failed: ${u}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}const Or="taskmaster_update_dismissed";function Qv(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Or,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Yv(){try{const e=localStorage.getItem(us);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(us),!1):!0:!1}catch{return!1}}function sn(){try{localStorage.removeItem(us)}catch{}}function Xv(e){try{const t=localStorage.getItem(Or);return t?Number(t)>=e:!1}catch{return!1}}function fi(e,t){var a,l,c;const n=(e??"").trim(),s=(a=t.mainSessionKey)==null?void 0:a.trim();if(!s)return n;if(!n)return s;const i=((l=t.mainKey)==null?void 0:l.trim())||"main",r=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===i||r&&(n===`agent:${r}:main`||n===`agent:${r}:${i}`)?s:n}function Zv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fi(e.sessionKey,t),s=fi(e.settings.sessionKey,t),i=fi(e.settings.lastActiveSessionKey,t),r=n||s||e.sessionKey,o={...e.settings,sessionKey:s||r,lastActiveSessionKey:i||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&Be(e,o)}function _e(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.customersPage||e.advancedPage?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Kv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:n,mode:"webchat",onHello:i=>{e.connected=!0,e.lastError=null,e.hello=i,ss()&&(yr(),e.uninstallDone=!1),tb(e,i),e.handleAccessCheck(),Vv(e).then(()=>{Yc(e)}),Qc(e),Dv(e),(e.chatPage||e.setup)&&nb(e),rr(e,{quiet:!0}),ir(e,{quiet:!0}),fn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(xe(e),sb(e)),ts(e)},onClose:({code:i,reason:r})=>{e.connected=!1,i!==1012&&(e.lastError=`disconnected (${i}): ${r||"no reason"}`)},onEvent:i=>Jv(e,i),onGap:({expected:i,received:r})=>{console.warn(`[gateway] event gap: expected seq ${i}, got ${r}`),ts(e)}}),e.client.start()}function Jv(e,t){try{eb(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function eb(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;gd(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&Dl(e,n.sessionKey);const s=il(e,n);(s==="final"||s==="error"||s==="aborted")&&(Yi(e),oh(e)),s==="final"&&Me(e);return}if(t.event==="suggestions"){const n=t.payload;(n==null?void 0:n.sessionKey)===e.sessionKey&&Array.isArray(n.suggestions)&&n.suggestions.length>0&&(e.chatSuggestion=n.suggestions[0]);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&fr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ir(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=zv(t.payload);if(n){e.execApprovalQueue=Hv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Oa(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){fv(e,t.payload);return}if(t.event==="browser.handoff"){gv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){mv(e);return}if(t.event==="exec.approval.resolved"){const n=jv(t.payload);n&&(e.execApprovalQueue=Oa(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){Gv(e,t.payload);return}}function tb(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&Zv(e,n.sessionDefaults)}async function nb(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function sb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Wi(e.client)}catch{}}function ib(e){e.basePath=Vp();const t=We();if(ph(t.accentColor),window.scrollTo(0,0),Wp(e),e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,zp(e),_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.customersPage){document.title=`${t.name} Customers`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Zp(e,!0),Qp(e),Yp(e),window.addEventListener("popstate",e.popStateHandler),Hp(e),_e(e),Fp(e),e.tab==="logs"&&(e.logsSubTab==="session"?ur(e):lr(e)),e.tab==="debug"&&pr(e)}function rb(e){Sd(e)}function ob(e){var t;window.removeEventListener("popstate",e.popStateHandler),Up(e),cr(e),dr(e),hr(e),Kp(e),jp(e),Xp(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function ab(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.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(r=>{e.channelsSnapshot=r,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;cn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&rl(e,t.has("tab")||t.has("logsAutoFollow"))}function lb(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function cb(e,t,n){await Xi(e,t,n),await q(e,!0)}async function ub(e,t){await ll(e,t),await q(e,!0)}async function db(e,t){await cl(e,t),await q(e,!0)}async function pb(e,t){await ul(e,t)}async function hb(e,t){await dl(e,t)}async function fb(e){await $d(e),await xe(e),await q(e,!0)}async function gb(e){await xe(e),await q(e,!0)}function mb(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 r=s.trim(),o=i.join(":").trim();r&&o&&(t[r]=o)}return t}function Xc(e){var n,s,i;return((i=(((s=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:s.nostr)??[])[0])==null?void 0:i.accountId)??e.nostrProfileAccountId??"default"}function Zc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function yb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=lb(n??void 0)}function vb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function bb(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function wb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function kb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Xc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Zc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const r=(i==null?void 0:i.error)??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:mb(i==null?void 0: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 q(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Sb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Xc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Zc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const l=(i==null?void 0:i.error)??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const r=i.merged??i.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},i.saved&&await q(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function xb(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 Ab(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 $b(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=""):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 Eb(e,t){e.authCodeInput=t}function Tb(e){e.setupStep="whatsapp"}async function Cb(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 _b(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 Mb(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 Lb(e,t){e.licenseKey=t}async function Pb(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("health",{probe:!0});e.gatewayHealthy=s.ok===!0,e.gatewayHealthMessage=s.ok?`Healthy${s.durationMs?` (${s.durationMs}ms)`:""}`:"Unhealthy"}catch(s){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(s)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Rb(e){var t,n,s;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(i.ok&&((n=i.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(i){e.gatewayHealthMessage=`Restart failed: ${String(i)}`,e.gatewayRestartBusy=!1,(s=e.requestUpdate)==null||s.call(e)}}}var Ib=Object.defineProperty,Nb=Object.getOwnPropertyDescriptor,m=(e,t,n,s)=>{for(var i=s>1?void 0:s?Nb(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Ib(t,n,i),i};const gi=Ou();function Db(){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 Ob(){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 Bb(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Fb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Ub(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Wb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function Kb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function zb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends kt{constructor(){super(...arguments),this.settings=Us(),this.password="",this.tab="chat",this.onboarding=Db(),this.setup=Ob(),this.filesPage=Bb(),this.browserPage=Fb(),this.adminsPage=Ub(),this.customersPage=Wb(),this.chatPage=Kb(),this.advancedPage=zb(),this.advancedTab="cron",this.connected=!1,this.accessState=Oc,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=gi.name,this.assistantAvatar=gi.avatar,this.assistantAgentId=gi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatSuggestion=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=`{
|
|
3007
3019
|
}
|
|
3008
|
-
`,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={...Nv},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.browserFullscreen=!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.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,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.apiKeySavingProvider=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={...Iv},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.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Jp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),ib(this)}firstUpdated(){rb(this)}disconnectedCallback(){ob(this),super.disconnectedCallback()}updated(e){ab(this,e)}connect(){_e(this)}handleChatScroll(e){md(this,e)}handleLogsScroll(e){yd(this,e)}handleSessionLogsScroll(e){vd(this,e)}exportLogs(e,t){wd(e,t)}exportSessionLogs(e,t){kd(e,t)}resetToolStream(){Yi(this)}resetChatScroll(){bd(this)}async loadAssistantIdentity(){await Qc(this)}applySettings(e){Be(this,e)}setTab(e){qp(this,e)}setTheme(e,t){Gp(this,e,t)}async loadOverview(){await Fl(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await fr(this)}async handleAbortChat(){await Wl(this)}removeQueuedMessage(e){sh(this,e)}async handleSendChat(e,t){await ih(this,e,t)}async handleWhatsAppStart(e,t){await cb(this,e,t)}async handleWhatsAppWait(e){await ub(this,e)}async handleWhatsAppLogout(e){await db(this,e)}async handleAddWhatsAppAccount(e){await pb(this,e)}async handleRemoveWhatsAppAccount(e){await hb(this,e)}async handleAccessCheck(){await Ra(this)}async handlePinSubmit(e,t){await sv(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await iv(this,e)}async handleLogout(){await ov(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 Ra(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 Cb(this)}async handleLicenseActivate(){await _b(this)}async handleLicenseRemove(){await Mb(this)}handleLicenseKeyChange(e){Lb(this,e)}async handleAuthStatusCheck(){await xb(this)}async handleAuthStart(){await Ab(this)}async handleAuthSubmitCode(e){await $b(this,e)}handleAuthCodeChange(e){Eb(this,e)}handleSkipToWhatsApp(){Tb(this)}async handleGatewayHealthCheck(){await Pb(this)}async handleGatewayRestart(){await Rb(this)}async handleUpdateCheck(){await Yc(this)}async handleUpdateRun(){await qv(this)}handleUpdateDismissResult(){Qv(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 pe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Co);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){pe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Co);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Pl(this)}async clearAudit(){await Cp(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(s=>s.id))??void 0;const t=this.resolveFilesAgentId();pn(this,t),ar(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();pe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>vv);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.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())}pe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>rd);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await fb(this)}async handleChannelConfigReload(){await gb(this)}handleNostrProfileEdit(e,t){yb(this,e,t)}handleNostrProfileCancel(){vb(this)}handleNostrProfileFieldChange(e,t){bb(this,e,t)}async handleNostrProfileSave(){await kb(this)}async handleNostrProfileImport(){await Sb(this)}handleNostrProfileToggleAdvanced(){wb(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;pe(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>bv);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 pe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Un);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await pe(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Un);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await pe(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>Pd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const r=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await pe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Un);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await pe(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Un);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),go(e),this.settings=Us(),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.loadAuditEntries(),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){this.reloadCurrentPageData();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)}go(this.selectedWorkspace),this.settings=Us(),this.reloadCurrentPageData()}render(){return f`${Lv(this)}${this.auditModalOpen?Rv(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"customersPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"customersLoading",2);m([y()],g.prototype,"customersSaving",2);m([y()],g.prototype,"customersRecords",2);m([y()],g.prototype,"customersError",2);m([y()],g.prototype,"customersSearchQuery",2);m([y()],g.prototype,"customersEditingId",2);m([y()],g.prototype,"customersShowAddForm",2);m([y()],g.prototype,"customersNewPhone",2);m([y()],g.prototype,"customersNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsFull",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([qa("taskmaster-app")],g);
|
|
3009
|
-
//# sourceMappingURL=index-
|
|
3020
|
+
`,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={...Nv},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.browserFullscreen=!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.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,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.apiKeySavingProvider=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={...Iv},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.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Jp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),ib(this)}firstUpdated(){rb(this)}disconnectedCallback(){ob(this),super.disconnectedCallback()}updated(e){ab(this,e)}connect(){_e(this)}handleChatScroll(e){md(this,e)}handleLogsScroll(e){yd(this,e)}handleSessionLogsScroll(e){vd(this,e)}exportLogs(e,t){wd(e,t)}exportSessionLogs(e,t){kd(e,t)}resetToolStream(){Yi(this)}resetChatScroll(){bd(this)}async loadAssistantIdentity(){await Qc(this)}applySettings(e){Be(this,e)}setTab(e){qp(this,e)}setTheme(e,t){Gp(this,e,t)}async loadOverview(){await Fl(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await fr(this)}async handleAbortChat(){await Wl(this)}removeQueuedMessage(e){sh(this,e)}async handleSendChat(e,t){await ih(this,e,t)}async handleWhatsAppStart(e,t){await cb(this,e,t)}async handleWhatsAppWait(e){await ub(this,e)}async handleWhatsAppLogout(e){await db(this,e)}async handleAddWhatsAppAccount(e){await pb(this,e)}async handleRemoveWhatsAppAccount(e){await hb(this,e)}async handleAccessCheck(){await Ra(this)}async handlePinSubmit(e,t){await sv(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await iv(this,e)}async handleLogout(){await ov(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 Ra(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 Cb(this)}async handleLicenseActivate(){await _b(this)}async handleLicenseRemove(){await Mb(this)}handleLicenseKeyChange(e){Lb(this,e)}async handleAuthStatusCheck(){await xb(this)}async handleAuthStart(){await Ab(this)}async handleAuthSubmitCode(e){await $b(this,e)}handleAuthCodeChange(e){Eb(this,e)}handleSkipToWhatsApp(){Tb(this)}async handleGatewayHealthCheck(){await Pb(this)}async handleGatewayRestart(){await Rb(this)}async handleUpdateCheck(){await Yc(this)}async handleUpdateRun(){await qv(this)}handleUpdateDismissResult(){Qv(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 pe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Co);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){pe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Co);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Pl(this)}async clearAudit(){await Cp(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(s=>s.id))??void 0;const t=this.resolveFilesAgentId();pn(this,t),ar(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();pe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>vv);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.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.chatSuggestion=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}pe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>rd);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await fb(this)}async handleChannelConfigReload(){await gb(this)}handleNostrProfileEdit(e,t){yb(this,e,t)}handleNostrProfileCancel(){vb(this)}handleNostrProfileFieldChange(e,t){bb(this,e,t)}async handleNostrProfileSave(){await kb(this)}async handleNostrProfileImport(){await Sb(this)}handleNostrProfileToggleAdvanced(){wb(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;pe(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>bv);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 pe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Un);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await pe(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Un);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await pe(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>Pd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const r=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await pe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Un);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await pe(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Un);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),go(e),this.settings=Us(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatSuggestion=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.loadAuditEntries(),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){this.reloadCurrentPageData();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)}go(this.selectedWorkspace),this.settings=Us(),this.reloadCurrentPageData()}render(){return f`${Lv(this)}${this.auditModalOpen?Rv(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"customersPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"customersLoading",2);m([y()],g.prototype,"customersSaving",2);m([y()],g.prototype,"customersRecords",2);m([y()],g.prototype,"customersError",2);m([y()],g.prototype,"customersSearchQuery",2);m([y()],g.prototype,"customersEditingId",2);m([y()],g.prototype,"customersShowAddForm",2);m([y()],g.prototype,"customersNewPhone",2);m([y()],g.prototype,"customersNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsFull",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([qa("taskmaster-app")],g);
|
|
3021
|
+
//# sourceMappingURL=index-CV7xcGIS.js.map
|