@godmode-team/godmode 1.8.2 → 1.8.3
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/README.md +33 -12
- package/dist/godmode-ui/assets/{brain-tab-B1CYwAJ7.js → brain-tab-C2AbYrWP.js} +35 -23
- package/dist/godmode-ui/assets/{connections-tab-Cuv4eW0d.js → connections-tab-CwdK_wkL.js} +3 -3
- package/dist/godmode-ui/assets/ctrl-settings-nG144v_G.js +5 -0
- package/dist/godmode-ui/assets/{dashboards-tab-7hHXzWPp.js → dashboards-tab-CIED6Kpa.js} +1 -1
- package/dist/godmode-ui/assets/index-Btlae9Mn.css +1 -0
- package/dist/godmode-ui/assets/{index-DcYipcbm.js → index-DzcGsUUC.js} +287 -273
- package/dist/godmode-ui/assets/{second-brain-tab-DkFatLwl.js → second-brain-tab-BK7ARED2.js} +56 -48
- package/dist/godmode-ui/assets/{team-tab-Q3icI_Q-.js → team-tab-Dpl4pwK6.js} +1 -1
- package/dist/godmode-ui/assets/{today-tab-C6lIMzgY.js → today-tab-ReKlJGhF.js} +1 -1
- package/dist/godmode-ui/assets/{views-settings-B2UFEtoi.js → views-settings-TQFJxfo9.js} +1 -1
- package/dist/godmode-ui/assets/work-tab-BJF_wapn.js +1 -0
- package/dist/godmode-ui/assets/{workspaces-vzpIVgdl.js → workspaces-C4ZyofCq.js} +49 -49
- package/dist/godmode-ui/index.html +4 -4
- package/dist/index.js +407 -404
- package/dist/mcp-entry.js +256 -255
- package/dist/standalone.js +395 -392
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skill-cards/screenpipe.md +23 -15
- package/dist/godmode-ui/assets/ctrl-settings-COfcdhha.js +0 -5
- package/dist/godmode-ui/assets/index-DmEmOd0w.css +0 -1
- package/dist/godmode-ui/assets/work-tab-DwU559Bx.js +0 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./work-tab-
|
|
2
|
-
import{s as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./work-tab-BJF_wapn.js","./lit-core-CTInmNPB.js","./workspaces-C4ZyofCq.js","./ctrl-settings-nG144v_G.js","./views-settings-TQFJxfo9.js","./markdown-i_gIkIP3.js","./today-tab-ReKlJGhF.js","./team-tab-Dpl4pwK6.js","./brain-tab-C2AbYrWP.js","./second-brain-tab-BK7ARED2.js","./dashboards-tab-CIED6Kpa.js","./connections-tab-CwdK_wkL.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as Ii,l as V,w as Ri,e as Ei,g as rt,h as oe,t as Di,i as Ge,j as Oi,k as Ki,m as Ni,n as Fi,o as Ui,p as Bi,q as Ne,r as Fe,u as K,_,v as se,x as kt,y as Ue,z as $t,A as Jn,B as Wi,C as lt,D as Xn,E as ct,F as Zn,G as qi,H as es,I as ji,J as Qe,K as Hi,L as Vi,M as zi,N as Gi,O as Qi,P as Yi,Q as Ji,R as Xi,S as Zi,T as ea,U as ta,V as na,W as sa,X as ia,Y as aa,Z as oa,$ as ra,a0 as ke,a1 as en,a2 as la,a3 as tn,a4 as ca,a5 as da,a6 as ua,a7 as ha,a8 as pa,a9 as ma,aa as fa}from"./ctrl-settings-nG144v_G.js";import{n as ga,b as d,A as v,o as re,c as Be,i as ya,a as We,d as ts,t as ns,e as va,f as ba,r as m}from"./lit-core-CTInmNPB.js";import{c as wa,t as Z,a as q,i as $,e as Sa,g as _a,u as Ta,r as Aa,b as ss,n as is,d as ka,f as as,h as nn,p as Ct,E as $a,j as os,l as Ca,k as xa,T as Pa,P as La,s as Ma,m as Ia,o as Ra,q as Ea,v as Da,w as Oa,x as Ka,y as Na,z as Fa,A as Ua,B as Ba,C as Wa,D as qa,F as ja}from"./views-settings-TQFJxfo9.js";import"./markdown-i_gIkIP3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const Ha=ga(Symbol("app-context")),$e=()=>{},Va=()=>Promise.resolve(void 0);function za(){return{connected:!1,reconnecting:!1,sessionKey:"main",assistantName:"Assistant",assistantAvatar:null,userName:"",userAvatar:null,theme:"system",themeResolved:"dark",settings:{gatewayUrl:"",token:"",sessionKey:"main",lastActiveSessionKey:"",theme:"system",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{},openTabs:[],tabLastViewed:{},userName:"",userAvatar:"",chatParallelView:!1,parallelLanes:[null,null,null,null]},basePath:"",gateway:null,send:Va,setTab:$e,addToast:$e,openSidebar:$e,closeSidebar:$e}}class Ga{constructor(){this.listeners=new Map}on(t,n){this.listeners.has(t)||this.listeners.set(t,new Set);const s=this.listeners.get(t);return s.add(n),()=>{s.delete(n)}}emit(t,...n){const s=this.listeners.get(t);if(!s)return;const i=n[0];for(const a of s)try{a(i)}catch(o){console.error(`[event-bus] Error in handler for "${t}":`,o)}}clear(){this.listeners.clear()}}const H=new Ga;async function Qa(e,t){await Ii(e,t),await V(e,!0)}async function Ya(e){await Ri(e),await V(e,!0)}async function Ja(e){await Ei(e),await V(e,!0)}async function Xa(e){await rt(e),await oe(e),await V(e,!0)}async function Za(e){await oe(e),await V(e,!0)}function eo(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 a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function rs(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function ls(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function to(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=wa(n??void 0)}function no(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function so(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function io(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function ao(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=rs(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(ls(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:eo(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 V(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function oo(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=rs(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(ls(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const c=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:c,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,l=!!(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:l},i.saved&&await V(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}function cs(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}function dt(e){const t=(e??"").trim();if(!t)return!1;if(t==="main")return!0;const n=t.toLowerCase();return!!(n==="agent:main:main"||n.endsWith(":main"))}function ut(e){const t=(e??"").trim();return t?!!(dt(t)||t.toLowerCase().startsWith("agent:main:")):!1}function ds(e,t){return!!(e===t||ut(e)&&ut(t)&&(dt(e)||dt(t)))}const ro=80;function ge(e){const t=e.querySelector(".chat-thread");if(t){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||t.scrollHeight-t.clientHeight>1)return t}return null}function Ce(e,t){e.chatIsAutoScrolling=!0,t.scrollTop=t.scrollHeight,e.chatNewMessagesBelow=!1,requestAnimationFrame(()=>{e.chatIsAutoScrolling=!1})}let sn=0;function F(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=t?++sn:0;e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=ge(e);if(!s){if(t){let o=0;const l=()=>{const c=ge(e);c?Ce(e,c):++o<4&&setTimeout(l,80*o)};requestAnimationFrame(l)}else requestAnimationFrame(()=>{const o=ge(e);o&&(o.scrollTop=o.scrollHeight)});return}if(!(t||e.chatUserNearBottom)){e.chatNewMessagesBelow=!0;return}t&&(e.chatHasAutoScrolled=!0),Ce(e,s);const a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const o=ge(e);!o||!(t||e.chatUserNearBottom)||Ce(e,o)},a)})}),t&&setTimeout(()=>{if(n!==sn)return;const s=ge(e);s&&Ce(e,s)},400)}function xt(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function us(e,t){const n=t.currentTarget;if(!n||e.chatIsAutoScrolling)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;s<2?(e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1):s<ro?e.chatUserNearBottom=!0:e.chatUserNearBottom=!1}function hs(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Te(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1}function ps(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
3
3
|
`)}
|
|
4
|
-
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`godmode-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function
|
|
5
|
-
`),i=s.length,a=t.length;if(["read","files_read"].includes(n))return`${a.toLocaleString()} chars${i>1?`, ${i} lines`:""}`;if(n==="exec")return i>1?`${i} lines`:R(s[0],50);if(["web_search","memory_search","honcho_query"].includes(n))try{const o=JSON.parse(t),l=o.results?.length??o.count??0;return`${l} result${l!==1?"s":""}`}catch{return R(t,40)}return n==="browser"?t.includes("snapshot")?"snapshot captured":t.includes("success")?"success":R(t,40):a>100?`${a.toLocaleString()} chars`:R(t,50)}function
|
|
6
|
-
`)}function
|
|
4
|
+
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`godmode-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function ms(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}const lo=Object.freeze(Object.defineProperty({__proto__:null,exportLogs:ps,handleChatScroll:us,handleLogsScroll:hs,observeTopbar:ms,resetChatScroll:Te,scheduleChatScroll:F,scheduleLogsScroll:xt},Symbol.toStringTag,{value:"Module"})),O="main";function co(e){const t=[`viewing ${Z(e.tab)} tab`];return e.tab==="dashboards"&&e.activeDashboard&&t.push(`dashboard: ${e.activeDashboard.title}`),e.tab==="workspaces"&&e.selectedWorkspace&&t.push(`workspace: ${e.selectedWorkspace.name}`),e.sidebarOpen&&e.sidebarFilePath&&t.push(`viewing file: ${e.sidebarFilePath}`),`[GodMode Context: ${t.join(", ")}]`}const an=50,uo=80,ho=12e4;function R(e,t){if(!e)return"";const n=e.trim().replace(/\n/g," ");return n.length<=t?n:n.slice(0,t-1)+"…"}function I(e){return typeof e=="string"?e:e==null?"":JSON.stringify(e)}function on(e,t){if(!t||typeof t!="object")return"";const n=t;switch(e.toLowerCase()){case"exec":return n.command?`\`${R(I(n.command),60)}\``:"";case"read":return n.path||n.file_path?`\`${R(I(n.path||n.file_path),50)}\``:"";case"write":return n.path||n.file_path?`→ \`${R(I(n.path||n.file_path),50)}\``:"";case"edit":return n.path||n.file_path?`\`${R(I(n.path||n.file_path),50)}\``:"";case"web_search":return n.query?`"${R(I(n.query),45)}"`:"";case"web_fetch":try{const f=new URL(I(n.url));return f.hostname+(f.pathname!=="/"?f.pathname.slice(0,30):"")}catch{return R(I(n.url||""),50)}case"memory_search":case"honcho_query":return n.query||n.question?`"${R(I(n.query||n.question),45)}"`:"";case"browser":const s=I(n.action),i=n.ref?` #${I(n.ref)}`:"",a=n.targetUrl?` ${R(I(n.targetUrl),30)}`:"";return`${s}${i}${a}`;case"message":return n.action?`${I(n.action)}${n.target?` → ${R(I(n.target),25)}`:""}`:"";case"sessions_spawn":return n.task?`"${R(I(n.task),40)}"`:"";case"cron":return n.action?I(n.action):"";case"files_read":return n.fileId?`file:${R(I(n.fileId),20)}`:"";case"image":return n.image?R(I(n.image),40):"";default:const o=Object.keys(n).filter(f=>!["timeout","timeoutMs"].includes(f));if(o.length===0)return"";const l=o[0],c=n[l];return typeof c=="string"?`${l}: ${R(c,35)}`:""}}function rn(e,t){if(!t)return"";const n=e.toLowerCase(),s=t.split(`
|
|
5
|
+
`),i=s.length,a=t.length;if(["read","files_read"].includes(n))return`${a.toLocaleString()} chars${i>1?`, ${i} lines`:""}`;if(n==="exec")return i>1?`${i} lines`:R(s[0],50);if(["web_search","memory_search","honcho_query"].includes(n))try{const o=JSON.parse(t),l=o.results?.length??o.count??0;return`${l} result${l!==1?"s":""}`}catch{return R(t,40)}return n==="browser"?t.includes("snapshot")?"snapshot captured":t.includes("success")?"success":R(t,40):a>100?`${a.toLocaleString()} chars`:R(t,50)}function ln(e){if(!e)return!0;const t=e.toLowerCase();return!(t.includes("error:")||t.includes("failed")||t.includes("exception")||t.includes("not found"))}function po(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 a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
6
|
+
`)}function cn(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=po(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=typeof e=="object"?"[object]":String(e)}const s=Di(n,ho);return s.truncated?`${s.text}
|
|
7
7
|
|
|
8
|
-
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function
|
|
9
|
-
`,i),o=a===-1?e.length:a,l=e.slice(i,o),c=l.trimStart(),
|
|
10
|
-
`;)r++;r<e.length&&(s.length===0||s[s.length-1]!==r)&&s.push(r)}i=a===-1?e.length:a+1}return s.length<2?-1:s[s.length-2]}const
|
|
8
|
+
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function mo(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 fo(e){if(e.toolStreamOrder.length<=an)return;const t=e.toolStreamOrder.length-an,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function go(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function ht(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),go(e)}function yo(e,t=!1){if(t){ht(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>ht(e),uo))}function Pt(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],e.currentToolName=null,e.currentToolInfo=null;const t=e;t.compactionStatus&&(t.compactionStatus=null),t.compactionClearTimer!=null&&(window.clearTimeout(t.compactionClearTimer),t.compactionClearTimer=null),ht(e)}const vo=5e3;function bo(e,t){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:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},vo))}function wo(e,t){if(!t)return;if(t.stream==="compaction"){bo(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)return;if(!e.chatRunId)if(n===e.sessionKey&&t.runId)e.chatRunId=t.runId;else return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const a=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",l=o==="start"?s.args:void 0,c=o==="update"?cn(s.partialResult):o==="result"?cn(s.result):void 0,f=Date.now();let r=e.toolStreamById.get(i);r?(r.name=a,l!==void 0&&(r.args=l,r.displayArgs=on(a,l)),c!==void 0&&(r.output=c,r.resultSummary=rn(a,c),r.success=ln(c)),r.updatedAt=f):(r={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:l,output:c,startedAt:typeof t.ts=="number"?t.ts:f,updatedAt:f,message:{},displayArgs:l?on(a,l):void 0},e.toolStreamById.set(i,r),e.toolStreamOrder.push(i)),o==="start"?(e.currentToolName=a,e.currentToolInfo={name:a,details:r.displayArgs||void 0,startedAt:r.startedAt}):o==="result"&&(e.currentToolName=null,e.currentToolInfo=null,r.completedAt=f,r.resultSummary=rn(a,r.output),r.success=ln(r.output)),r.message=mo(r),fo(e),yo(e,o==="result")}const So=500,pt=new Map,_o="__default__";function fs(e,t){const n=e.trim();if(!n)return"";const s=_o;if(n.length<So)return q(n);const i=To(n);if(i<0)return q(n);const a=n.slice(0,i),o=n.slice(i);let l=pt.get(s);if(l||(l={prefixText:"",prefixHtml:""},pt.set(s,l)),a===l.prefixText)return l.prefixHtml+q(o);if(a.startsWith(l.prefixText)&&l.prefixText.length>0){const c=a.slice(l.prefixText.length);return l.prefixHtml=l.prefixHtml+q(c),l.prefixText=a,l.prefixHtml+q(o)}return l.prefixHtml=q(a),l.prefixText=a,l.prefixHtml+q(o)}function gs(e){pt.clear()}function To(e){let t=!1,n="";const s=[];let i=0;for(;i<e.length;){const a=e.indexOf(`
|
|
9
|
+
`,i),o=a===-1?e.length:a,l=e.slice(i,o),c=l.trimStart(),f=c.match(/^(`{3,}|~{3,})/);if(f){const r=f[1];t?r.charAt(0)===n.charAt(0)&&r.length>=n.length&&c.slice(r.length).trim()===""&&(t=!1,n=""):(t=!0,n=r)}if(!t&&l.trim()===""){let r=o+1;for(;r<e.length&&e[r]===`
|
|
10
|
+
`;)r++;r<e.length&&(s.length===0||s[s.length-1]!==r)&&s.push(r)}i=a===-1?e.length:a+1}return s.length<2?-1:s[s.length-2]}const Ao=1500,ko=2e3,ys="Copy as markdown",$o="Copied",Co="Copy failed";async function xo(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function xe(e,t){e.title=t,e.setAttribute("aria-label",t)}function Po(e){const t=e.label??ys;return d`
|
|
11
11
|
<button
|
|
12
12
|
class="chat-copy-btn"
|
|
13
13
|
type="button"
|
|
14
14
|
title=${t}
|
|
15
15
|
aria-label=${t}
|
|
16
|
-
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await
|
|
16
|
+
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await xo(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",xe(s,Co),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,xe(s,t))},ko);return}s.dataset.copied="1",xe(s,$o),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,xe(s,t))},Ao)}}}
|
|
17
17
|
>
|
|
18
18
|
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
19
19
|
<span class="chat-copy-btn__icon-copy">${$.copy}</span>
|
|
20
20
|
<span class="chat-copy-btn__icon-check">${$.check}</span>
|
|
21
21
|
</span>
|
|
22
22
|
</button>
|
|
23
|
-
`}function
|
|
24
|
-
`)}function
|
|
25
|
-
`),o=n==="assistant"?
|
|
26
|
-
`);const i=
|
|
27
|
-
`):null}function
|
|
28
|
-
`)}return typeof t.text=="string"?t.text:null}function
|
|
29
|
-
`):""}const Yo=Object.freeze(Object.defineProperty({__proto__:null,extractRawText:Dt,extractText:me,extractTextCached:Et,extractThinking:yt,extractThinkingCached:Ts,formatApiError:Rt,formatReasoningMarkdown:As,stripEnvelope:Ie},Symbol.toStringTag,{value:"Module"}));function Ot(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,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(p=>{const g=p,y=(typeof g.type=="string"?g.type:"").toLowerCase();return y==="toolresult"||y==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||l)&&(n="toolResult");let c=[];typeof t.content=="string"?c=[{type:"text",text:t.content}]:Array.isArray(t.content)?c=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(c=[{type:"text",text:t.text}]);const m=typeof t.timestamp=="number"?t.timestamp:Date.now(),r=typeof t.id=="string"?t.id:void 0;return{role:n,content:c,timestamp:m,id:r}}function je(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 $s(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}const gn={pdf:"📕",doc:"📘",docx:"📘",txt:"📄",rtf:"📄",xls:"📗",xlsx:"📗",csv:"📊",ppt:"📙",pptx:"📙",jpg:"🖼️",jpeg:"🖼️",png:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",mp3:"🎵",wav:"🎵",m4a:"🎵",mp4:"🎬",mov:"🎬",avi:"🎬",zip:"📦",rar:"📦","7z":"📦",tar:"📦",gz:"📦",js:"📜",ts:"📜",py:"📜",json:"📜",html:"📜",css:"📜",md:"📜",default:"📎"};function Cs(e){const t=e.split(".").pop()?.toLowerCase()||"";return gn[t]??gn.default}function xs(e,t){const n=t.split(".").pop()?.toLowerCase()||"";return{pdf:"PDF Document",doc:"Word Document",docx:"Word Document",xls:"Excel Spreadsheet",xlsx:"Excel Spreadsheet",csv:"CSV File",ppt:"PowerPoint",pptx:"PowerPoint",txt:"Text File",md:"Markdown",json:"JSON File",zip:"ZIP Archive",png:"PNG Image",jpg:"JPEG Image",jpeg:"JPEG Image",gif:"GIF Image",mp3:"Audio File",mp4:"Video File",html:"HTML Document",css:"Stylesheet",js:"JavaScript",ts:"TypeScript",py:"Python"}[n]||e.split("/")[1]?.toUpperCase()||"File"}const Jo={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Xo={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},proof_editor:{icon:"fileText",title:"Proof Editor",actions:{create:{label:"create",detailKeys:["title"]},write:{label:"write",detailKeys:["slug"]},read:{label:"read",detailKeys:["slug"]},comment:{label:"comment",detailKeys:["slug"]},suggest:{label:"suggest",detailKeys:["slug"]},open:{label:"open",detailKeys:["slug"]},share:{label:"share",detailKeys:["slug"]},export_gdrive:{label:"drive",detailKeys:["slug"]},list:{label:"list"}}},queue_steer:{icon:"messageSquare",title:"Queue Steer",detailKeys:["itemId","instruction"]},browser:{icon:"globe",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},Zo={fallback:Jo,tools:Xo},Ps=Zo,yn=Ps.fallback??{icon:"puzzle"},er=Ps.tools??{};function tr(e){return(e??"tool").trim()}function nr(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function sr(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function Ls(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>Ls(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function ir(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function ar(e,t){for(const n of t){const s=ir(e,n),i=Ls(s);if(i)return i}}function or(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function rr(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function lr(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function cr(e){const t=tr(e.name),n=t.toLowerCase(),s=er[n],i=s?.icon??yn.icon??"puzzle",a=s?.title??nr(t),o=s?.label??t,l=e.args&&typeof e.args=="object"?e.args.action:void 0,c=typeof l=="string"?l.trim():void 0,m=lr(s,c),r=sr(m?.label??c);let p;n==="read"&&(p=or(e.args)),!p&&(n==="write"||n==="edit"||n==="attach")&&(p=rr(e.args));const g=m?.detailKeys??s?.detailKeys??yn.detailKeys??[];return!p&&g.length>0&&(p=ar(e.args,g)),!p&&e.meta&&(p=e.meta),p&&(p=ur(p)),{name:t,icon:i,title:a,label:o,verb:r,detail:p}}function dr(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function ur(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const pr=80,hr=2,vn=100,fr=3;function bn(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function mr(e){const t=e.split(`
|
|
30
|
-
`),n=t.slice(0,
|
|
31
|
-
`);return s.length>
|
|
23
|
+
`}function Lo(e){return Po({text:()=>e,label:ys})}const dn="NO_REPLY",Mo=/<(?:system|godmode)-context\b[^>]*>[\s\S]*?<\/(?:system|godmode)-context>/gi,Io=/<document>\s*<source>[^<]*<\/source>\s*<mime_type>[^<]*<\/mime_type>\s*<content\s+encoding="base64">\s*[\s\S]*?<\/content>\s*<\/document>/gi,Ro=["internal system context injected by godmode","treat it as invisible background instructions only","persistence protocol (non-negotiable)","you must follow these operating instructions. do not echo or quote this block","meta goal: earn trust through competence. search before asking","asking the user for info you could look up is a failure mode"];function Ye(e){let t=e.replace(Mo,"").replace(Io,"").trim();const n=t.toLowerCase();for(const s of Ro){const i=n.indexOf(s);if(i!==-1){const a=i+s.length,o=t.slice(a),l=o.search(/\n\n(?=[A-Z])/);l!==-1?t=o.slice(l).trim():t="";break}}return t}const Eo=/^\s*\{[^{}]*"type"\s*:\s*"error"[^{}]*"error"\s*:\s*\{/,Do=/^\s*(\d{3})\s+\{/;function Lt(e){const t=e.trim(),n=t.match(Do);if(n){const s=Number(n[1]);if(s===529||s===503)return"*Switching models — Claude is temporarily overloaded.*";if(s===400&&t.includes("Unsupported value"))return null}if(t.startsWith("Unsupported value:")||t.includes("is not supported with the")||!Eo.test(t))return null;try{const s=JSON.parse(t);if(s?.type==="error"&&s?.error?.message)return(s.error.type??"")==="overloaded_error"?"*Switching models — Claude is temporarily overloaded.*":`*API error: ${s.error.message}*`}catch{}return null}const Oo=/\{"type":"error","error":\{[^}]*"type":"[^"]*"[^}]*\}[^}]*"request_id":"[^"]*"\}/g,Ko=/\d{3}\s+\{"type":"error"[^\n]*\}\n?(?:https?:\/\/[^\n]*\n?)?/g,No=/\{"type":"error","error":\{"details":[^}]*"type":"overloaded_error"[^}]*\}[^}]*"request_id":"[^"]*"\}\n?/g;function Fo(e){return e.replace(Ko,"").replace(Oo,"").replace(No,"").trim()}const Uo=/^\[([^\]]+)\]\s*/,Bo=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Je=new WeakMap,Xe=new WeakMap;function Wo(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Bo.some(t=>e.startsWith(`${t} `))}function Me(e){const t=e.match(Uo);if(!t)return e;const n=t[1]??"";return Wo(n)?e.slice(t[0].length):e}function Ze(e){const t=e.trim();return t===dn||t.startsWith(`${dn}
|
|
24
|
+
`)}function fe(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string"){const i=Ye(s);if(!i)return null;const a=Lt(i);if(a)return a;const o=n==="assistant"?Fo(i):i;if(n==="assistant"&&!o)return null;const l=n==="assistant"?Ge(o):Me(i);return Ze(l)?null:l}if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?Ye(o.text):null}).filter(a=>typeof a=="string"&&a.length>0);if(i.length>0){const a=i.join(`
|
|
25
|
+
`),o=n==="assistant"?Ge(a):Me(a);return Ze(o)?null:o}}if(typeof t.text=="string"){const i=Ye(t.text);if(!i)return null;const a=n==="assistant"?Ge(i):Me(i);return Ze(a)?null:a}return null}function Mt(e){if(!e||typeof e!="object")return fe(e);const t=e;if(Je.has(t))return Je.get(t)??null;const n=fe(e);return Je.set(t,n),n}function mt(e){const n=e.content,s=[];if(Array.isArray(n))for(const l of n){const c=l;if(c.type==="thinking"&&typeof c.thinking=="string"){const f=c.thinking.trim();f&&s.push(f)}}if(s.length>0)return s.join(`
|
|
26
|
+
`);const i=It(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(l=>(l[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
27
|
+
`):null}function vs(e){if(!e||typeof e!="object")return mt(e);const t=e;if(Xe.has(t))return Xe.get(t)??null;const n=mt(e);return Xe.set(t,n),n}function It(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
|
|
28
|
+
`)}return typeof t.text=="string"?t.text:null}function bs(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(`
|
|
29
|
+
`):""}const qo=Object.freeze(Object.defineProperty({__proto__:null,extractRawText:It,extractText:fe,extractTextCached:Mt,extractThinking:mt,extractThinkingCached:vs,formatApiError:Lt,formatReasoningMarkdown:bs,stripEnvelope:Me},Symbol.toStringTag,{value:"Module"}));function Rt(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,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(p=>{const g=p,y=(typeof g.type=="string"?g.type:"").toLowerCase();return y==="toolresult"||y==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||l)&&(n="toolResult");let c=[];typeof t.content=="string"?c=[{type:"text",text:t.content}]:Array.isArray(t.content)?c=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(c=[{type:"text",text:t.text}]);const f=typeof t.timestamp=="number"?t.timestamp:Date.now(),r=typeof t.id=="string"?t.id:void 0;return{role:n,content:c,timestamp:f,id:r}}function qe(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 ws(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}const un={pdf:"📕",doc:"📘",docx:"📘",txt:"📄",rtf:"📄",xls:"📗",xlsx:"📗",csv:"📊",ppt:"📙",pptx:"📙",jpg:"🖼️",jpeg:"🖼️",png:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",mp3:"🎵",wav:"🎵",m4a:"🎵",mp4:"🎬",mov:"🎬",avi:"🎬",zip:"📦",rar:"📦","7z":"📦",tar:"📦",gz:"📦",js:"📜",ts:"📜",py:"📜",json:"📜",html:"📜",css:"📜",md:"📜",default:"📎"};function Ss(e){const t=e.split(".").pop()?.toLowerCase()||"";return un[t]??un.default}function _s(e,t){const n=t.split(".").pop()?.toLowerCase()||"";return{pdf:"PDF Document",doc:"Word Document",docx:"Word Document",xls:"Excel Spreadsheet",xlsx:"Excel Spreadsheet",csv:"CSV File",ppt:"PowerPoint",pptx:"PowerPoint",txt:"Text File",md:"Markdown",json:"JSON File",zip:"ZIP Archive",png:"PNG Image",jpg:"JPEG Image",jpeg:"JPEG Image",gif:"GIF Image",mp3:"Audio File",mp4:"Video File",html:"HTML Document",css:"Stylesheet",js:"JavaScript",ts:"TypeScript",py:"Python"}[n]||e.split("/")[1]?.toUpperCase()||"File"}const jo={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Ho={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},proof_editor:{icon:"fileText",title:"Proof Editor",actions:{create:{label:"create",detailKeys:["title"]},write:{label:"write",detailKeys:["slug"]},read:{label:"read",detailKeys:["slug"]},comment:{label:"comment",detailKeys:["slug"]},suggest:{label:"suggest",detailKeys:["slug"]},open:{label:"open",detailKeys:["slug"]},share:{label:"share",detailKeys:["slug"]},export_gdrive:{label:"drive",detailKeys:["slug"]},list:{label:"list"}}},queue_steer:{icon:"messageSquare",title:"Queue Steer",detailKeys:["itemId","instruction"]},browser:{icon:"globe",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},Vo={fallback:jo,tools:Ho},Ts=Vo,hn=Ts.fallback??{icon:"puzzle"},zo=Ts.tools??{};function Go(e){return(e??"tool").trim()}function Qo(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function Yo(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function As(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>As(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function Jo(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function Xo(e,t){for(const n of t){const s=Jo(e,n),i=As(s);if(i)return i}}function Zo(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function er(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function tr(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function nr(e){const t=Go(e.name),n=t.toLowerCase(),s=zo[n],i=s?.icon??hn.icon??"puzzle",a=s?.title??Qo(t),o=s?.label??t,l=e.args&&typeof e.args=="object"?e.args.action:void 0,c=typeof l=="string"?l.trim():void 0,f=tr(s,c),r=Yo(f?.label??c);let p;n==="read"&&(p=Zo(e.args)),!p&&(n==="write"||n==="edit"||n==="attach")&&(p=er(e.args));const g=f?.detailKeys??s?.detailKeys??hn.detailKeys??[];return!p&&g.length>0&&(p=Xo(e.args,g)),!p&&e.meta&&(p=e.meta),p&&(p=ir(p)),{name:t,icon:i,title:a,label:o,verb:r,detail:p}}function sr(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function ir(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const ar=80,or=2,pn=100,rr=3;function mn(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function lr(e){const t=e.split(`
|
|
30
|
+
`),n=t.slice(0,or),s=n.join(`
|
|
31
|
+
`);return s.length>pn?s.slice(0,pn)+"…":n.length<t.length?s+"…":s}function cr(e){const t=e,n=pr(t.content),s=[];for(const i of n){const a=(typeof i.type=="string"?i.type:"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(a)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:mr(i.arguments??i.args)})}for(const i of n){const a=(typeof i.type=="string"?i.type:"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=fr(i);if(gn(o))continue;const l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:o})}if(ws(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",a=Mt(e)??void 0;gn(a)||s.push({kind:"result",name:i,text:a})}return s}const dr=new Set(["write","read","edit","attach"]);function ur(e){if(!e||typeof e!="object")return null;const t=e,n=t.path??t.file_path??t.filePath;return typeof n=="string"&&n.trim()?n.trim():null}function hr(e){if(!e)return null;const t=e.match(/(?:\/(?:Users|home|tmp|var)\/\S+|~\/\S+)/);return t?t[0].replace(/[.,;:!?)'"]+$/,""):null}function fn(e,t,n,s,i){const a=nr({name:e.name,args:e.args}),o=sr(a),l=!!e.text?.trim(),c=gr(e.text);if(c?.type==="proof"&&c.slug)return d`
|
|
32
32
|
<div class="chat-artifact-card">
|
|
33
33
|
<div class="chat-artifact-card__icon">${$.fileText}</div>
|
|
34
34
|
<div class="chat-artifact-card__info">
|
|
@@ -40,24 +40,24 @@ import{s as Fi,l as H,w as Ui,e as Wi,g as dt,h as oe,t as qi,i as Ye,j as Bi,k
|
|
|
40
40
|
${c.filePath&&i?d`<button class="chat-artifact-card__btn chat-artifact-card__btn--drive" @click=${C=>{C.stopPropagation(),i(c.filePath)}}>Drive</button>`:v}
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
|
-
`;const
|
|
43
|
+
`;const f=dr.has(e.name.toLowerCase())?ur(e.args)??hr(e.text):null;if(f&&e.kind==="result"){const C=f.split("/").pop()||f,D=C.split(".").pop()?.toLowerCase()||"",Y=Ss(C),w=_s(D,C);return d`
|
|
44
44
|
<div class="chat-artifact-card">
|
|
45
|
-
<div class="chat-artifact-card__icon">${
|
|
45
|
+
<div class="chat-artifact-card__icon">${Y}</div>
|
|
46
46
|
<div class="chat-artifact-card__info">
|
|
47
|
-
<span class="chat-artifact-card__name" title=${
|
|
47
|
+
<span class="chat-artifact-card__name" title=${f}>${C}</span>
|
|
48
48
|
<span class="chat-artifact-card__type">${w}</span>
|
|
49
49
|
</div>
|
|
50
50
|
<div class="chat-artifact-card__actions">
|
|
51
|
-
${n?d`<button class="chat-artifact-card__btn" @click=${
|
|
52
|
-
${i?d`<button class="chat-artifact-card__btn chat-artifact-card__btn--drive" @click=${
|
|
51
|
+
${n?d`<button class="chat-artifact-card__btn" @click=${T=>{T.stopPropagation(),n(f,e.text??void 0)}}>Open</button>`:t&&l?d`<button class="chat-artifact-card__btn" @click=${T=>{T.stopPropagation(),t(mn(e.text))}}>View</button>`:v}
|
|
52
|
+
${i?d`<button class="chat-artifact-card__btn chat-artifact-card__btn--drive" @click=${T=>{T.stopPropagation(),i(f)}}>Drive</button>`:v}
|
|
53
53
|
</div>
|
|
54
54
|
</div>
|
|
55
|
-
`}const r=!!t||!!(n&&
|
|
55
|
+
`}const r=!!t||!!(n&&f),p=r?C=>{if(C.stopPropagation(),n&&f){n(f,e.text??void 0);return}if(t&&l){t(mn(e.text));return}if(t){const D=`## ${a.label}
|
|
56
56
|
|
|
57
57
|
${o?`**Command:** \`${o}\`
|
|
58
58
|
|
|
59
59
|
`:""}*No output — tool completed successfully.*`;t(D)}}:void 0,g=e.text?e.text.split(`
|
|
60
|
-
`).length:0,y=l&&(e.text?.length??0)<=
|
|
60
|
+
`).length:0,y=l&&(e.text?.length??0)<=ar,b=l&&!y&&g>rr,k=l&&!b,P=!l,U=e.kind==="call"?"chat-tool-card--call":"chat-tool-card--result";return d`
|
|
61
61
|
<div
|
|
62
62
|
class="chat-tool-card ${U} ${r?"chat-tool-card--clickable":""}"
|
|
63
63
|
@click=${p}
|
|
@@ -78,38 +78,38 @@ ${o?`**Command:** \`${o}\`
|
|
|
78
78
|
<div class="chat-tool-card__status-text muted">Completed</div>
|
|
79
79
|
`:v}
|
|
80
80
|
${b?d`<details class="chat-tool-card__expandable" @click=${C=>C.stopPropagation()}>
|
|
81
|
-
<summary class="chat-tool-card__preview mono">${
|
|
81
|
+
<summary class="chat-tool-card__preview mono">${lr(e.text)}</summary>
|
|
82
82
|
<div class="chat-tool-card__full-output mono">${e.text}</div>
|
|
83
83
|
</details>`:v}
|
|
84
|
-
${
|
|
84
|
+
${k?d`<div class="chat-tool-card__inline mono">${e.text}</div>`:v}
|
|
85
85
|
</div>
|
|
86
|
-
`}function
|
|
86
|
+
`}function pr(e){return Array.isArray(e)?e.filter(Boolean):[]}function mr(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function fr(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function gr(e){if(!e)return null;try{const t=JSON.parse(e);return t._sidebarAction?{type:t._sidebarAction.type,slug:t._sidebarAction.slug,title:t.title,filePath:t.filePath}:null}catch{return null}}function gn(e){if(!e)return!1;const t=e.toLowerCase();return t.includes("process exited")?!1:t.includes("(no new output)")&&t.includes("still running")}function yr(e,t){if(!t)return;const n=e.target,s=n instanceof Element?n:n instanceof Node?n.parentElement:null;if(!s)return;const i=s.closest("a");if(!i)return;const a=i.getAttribute("href");if(a){if(a.startsWith("file://")){e.preventDefault(),e.stopPropagation();let o=a.slice(7);o.startsWith("/~/")&&(o="~"+o.slice(2));try{o=decodeURIComponent(o)}catch{}t(o);return}if(a.startsWith("godmode-file://")){e.preventDefault(),e.stopPropagation();let o=a.slice(15);try{o=decodeURIComponent(o)}catch{}t(o);return}if(a.startsWith("~/")||a.startsWith("/Users/")||a.startsWith("/home/")||a.startsWith("/tmp/")||a.startsWith("/godmode/")){e.preventDefault(),e.stopPropagation();let o=a;try{o=decodeURIComponent(o)}catch{}t(o);return}}}function vr(e){const t=e.target,n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return;const s=n.closest(".chat-expand-btn");if(!s)return;const i=s.closest(".chat-expand-marker");if(!i)return;const a=i.dataset.expandId;if(!a)return;e.preventDefault(),e.stopPropagation();const o=Sa(a);if(!o)return;const l=i.closest(".chat-text");l&&(l.innerHTML=o)}const yn={exec:["Executing","Running","Conjuring","Manifesting","Brewing"],read:["Reading","Perusing","Absorbing","Scanning","Devouring"],write:["Writing","Scribbling","Crafting","Inscribing","Authoring"],edit:["Editing","Refining","Polishing","Tweaking","Sculpting"],browser:["Browsing","Surfing","Exploring","Navigating","Spelunking"],web_search:["Searching","Hunting","Investigating","Sleuthing","Scouring"],web_fetch:["Fetching","Grabbing","Retrieving","Summoning","Acquiring"],memory_search:["Remembering","Recalling","Pondering","Reflecting"],honcho_query:["Remembering","Recalling","Pondering","Reflecting"],image:["Analyzing","Examining","Scrutinizing","Inspecting","Beholding"],default:["Working on","Processing","Handling","Tinkering with","Wrangling"]};function Ee(e){const t=e.toLowerCase().replace(/[^a-z_]/g,""),n=yn[t]??yn.default,s=Math.floor(Date.now()/2e3)%n.length;return n[s]}function br(e){const t=e.match(/\[Files uploaded:\s*([^\]]+)\]/);if(!t)return null;const n=t[1],s=[],i=/([^(,]+?)\s*\(fileId:\s*([^,]+),\s*size:\s*([^,]+),\s*type:\s*([^)]+)\)/g;let a;for(;(a=i.exec(n))!==null;)s.push({fileName:a[1].trim(),fileId:a[2].trim(),size:a[3].trim(),mimeType:a[4].trim()});return s.length>0?s:null}function wr(e){return d`
|
|
87
87
|
<div class="chat-file-uploads">
|
|
88
88
|
${e.map(t=>d`
|
|
89
89
|
<div class="chat-file-upload-card">
|
|
90
|
-
<span class="chat-file-upload-card__icon">${
|
|
90
|
+
<span class="chat-file-upload-card__icon">${Ss(t.fileName)}</span>
|
|
91
91
|
<div class="chat-file-upload-card__info">
|
|
92
92
|
<span class="chat-file-upload-card__name" title="${t.fileName}">${t.fileName}</span>
|
|
93
|
-
<span class="chat-file-upload-card__meta">${t.size} • ${
|
|
93
|
+
<span class="chat-file-upload-card__meta">${t.size} • ${_s(t.mimeType,t.fileName)}</span>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
`)}
|
|
97
97
|
</div>
|
|
98
|
-
`}function
|
|
98
|
+
`}function Sr(e){return e.replace(/\[Files uploaded:[^\]]+\]\s*/g,"").trim()}const vn=/<document>\s*<source>([^<]*)<\/source>\s*<mime_type>([^<]*)<\/mime_type>\s*<content\s+encoding="base64">\s*[\s\S]*?<\/content>\s*<\/document>/gi;function _r(e){const t=[];let n;for(;(n=vn.exec(e))!==null;){const s=n[1]?.trim()||"file",i=n[2]?.trim()||"application/octet-stream";t.push({fileName:s,fileId:"",size:"",mimeType:i})}return vn.lastIndex=0,t.length>0?t:null}const Tr=/<document>\s*<source>[^<]*<\/source>\s*<mime_type>[^<]*<\/mime_type>\s*<content\s+encoding="base64">\s*[\s\S]*?<\/content>\s*<\/document>/gi;function Ar(e){return e.replace(Tr,"").trim()}function kr(e){if(!e)return e;if(e.startsWith("System:")||e.startsWith("GatewayRestart:")||e.startsWith("Sender (untrusted metadata)")){const a=e.indexOf(`
|
|
99
99
|
|
|
100
100
|
`);return a!==-1?e.slice(a+2).trim():""}let i=e.split(`
|
|
101
101
|
`).filter(a=>{const o=a.trim();return!o.startsWith("System:")&&!o.startsWith("GatewayRestart:")}).join(`
|
|
102
102
|
`);for(;i.startsWith(`
|
|
103
|
-
`);)i=i.slice(1);return i.trim()}function
|
|
103
|
+
`);)i=i.slice(1);return i.trim()}function $r(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`}function ft(e){const t=e,n=t.content,s=[];if(Array.isArray(n))for(const a of n){if(typeof a!="object"||a===null)continue;const o=a;if(o.type==="image"){const l=o.source;if(l?.type==="base64"&&typeof l.data=="string"){const c=l.data,f=l.media_type||"image/png",r=c.startsWith("data:")?c:`data:${f};base64,${c}`;s.push({url:r})}else if(typeof o.data=="string"&&typeof o.mimeType=="string"){const c=o.data.startsWith("data:")?o.data:`data:${o.mimeType};base64,${o.data}`;s.push({url:c})}else typeof o.url=="string"?s.push({url:o.url}):o.omitted===!0&&s.push({omitted:!0,bytes:typeof o.bytes=="number"?o.bytes:void 0,mimeType:typeof o.mimeType=="string"?o.mimeType:void 0,alt:typeof o.fileName=="string"?o.fileName:void 0})}else if(o.type==="image_url"){const l=o.image_url;typeof l?.url=="string"&&s.push({url:l.url})}else o.type==="attachment"&&typeof o.content=="string"&&(o.mimeType||"").startsWith("image/")&&s.push({url:o.content,alt:o.fileName||void 0});if(o.type==="text"&&typeof o.text=="string"){const l=/data:image\/[^;]+;base64,[A-Za-z0-9+/=]+/g,c=o.text.match(l);if(c)for(const f of c)s.push({url:f})}if(Array.isArray(o.content))for(const l of o.content){if(typeof l!="object"||l===null)continue;const c=l;if(c.type==="image"){const f=c.source;if(f?.type==="base64"&&typeof f.data=="string"){const r=f.media_type||"image/png",p=f.data.startsWith("data:")?f.data:`data:${r};base64,${f.data}`;s.push({url:p})}else if(typeof c.data=="string"&&typeof c.mimeType=="string"){const r=c.data.startsWith("data:")?c.data:`data:${c.mimeType};base64,${c.data}`;s.push({url:r})}else c.omitted===!0&&s.push({omitted:!0,bytes:typeof c.bytes=="number"?c.bytes:void 0,mimeType:typeof c.mimeType=="string"?c.mimeType:void 0,alt:typeof c.fileName=="string"?c.fileName:void 0})}}}const i=t.attachments;if(Array.isArray(i))for(const a of i){if(typeof a!="object"||a===null)continue;const o=a;if(o.type==="image"&&typeof o.content=="string"){const l=o.mimeType||"image/png",c=o.content.startsWith("data:")?o.content:`data:${l};base64,${o.content}`;s.push({url:c,alt:o.fileName||void 0})}else o.type==="image"&&o.omitted===!0&&s.push({omitted:!0,bytes:typeof o.bytes=="number"?o.bytes:void 0,mimeType:typeof o.mimeType=="string"?o.mimeType:void 0,alt:typeof o.fileName=="string"?o.fileName:void 0})}return s}function Cr(e){const t=e,n=t.content,s=[];if(Array.isArray(n))for(const a of n){if(typeof a!="object"||a===null)continue;const o=a;if(o.type==="attachment"&&typeof o.content=="string"){const l=o.mimeType||"application/octet-stream";l.startsWith("image/")||s.push({fileName:o.fileName||"file",mimeType:l,content:o.content})}}const i=t.attachments;if(Array.isArray(i))for(const a of i){if(typeof a!="object"||a===null)continue;const o=a;o.type==="file"&&typeof o.content=="string"&&s.push({fileName:o.fileName||"file",mimeType:o.mimeType||"application/octet-stream",content:o.content})}return s}function xr(e,t){return d`
|
|
104
104
|
<div class="chat-group assistant">
|
|
105
|
-
${
|
|
105
|
+
${Et("assistant",{assistantName:e?.name,assistantAvatar:e?.avatar})}
|
|
106
106
|
<div class="chat-group-messages">
|
|
107
107
|
${t?d`
|
|
108
|
-
<div class="chat-working-indicator" role="status" aria-label="${
|
|
108
|
+
<div class="chat-working-indicator" role="status" aria-label="${Ee(t.name)} ${t.name}">
|
|
109
109
|
<div class="chat-working-indicator__row">
|
|
110
110
|
<span class="chat-working-indicator__icon">⚙</span>
|
|
111
111
|
<span class="chat-working-indicator__text">
|
|
112
|
-
<span class="chat-working-indicator__verb">${
|
|
112
|
+
<span class="chat-working-indicator__verb">${Ee(t.name)}</span>
|
|
113
113
|
<strong>${t.name}</strong>
|
|
114
114
|
</span>
|
|
115
115
|
</div>
|
|
@@ -126,51 +126,51 @@ ${o?`**Command:** \`${o}\`
|
|
|
126
126
|
</div>
|
|
127
127
|
</div>
|
|
128
128
|
</div>
|
|
129
|
-
`}function
|
|
129
|
+
`}function Pr(e,t,n,s,i){const a=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),o=s?.name??"Assistant";return d`
|
|
130
130
|
<div class="chat-group assistant">
|
|
131
|
-
${
|
|
131
|
+
${Et("assistant",{assistantName:s?.name,assistantAvatar:s?.avatar})}
|
|
132
132
|
<div class="chat-group-messages">
|
|
133
133
|
${i?d`
|
|
134
|
-
<div class="chat-working-indicator" role="status" aria-label="${
|
|
134
|
+
<div class="chat-working-indicator" role="status" aria-label="${Ee(i.name)} ${i.name}">
|
|
135
135
|
<div class="chat-working-indicator__row">
|
|
136
136
|
<span class="chat-working-indicator__icon">⚙</span>
|
|
137
137
|
<span class="chat-working-indicator__text">
|
|
138
|
-
<span class="chat-working-indicator__verb">${
|
|
138
|
+
<span class="chat-working-indicator__verb">${Ee(i.name)}</span>
|
|
139
139
|
<strong>${i.name}</strong>
|
|
140
140
|
</span>
|
|
141
141
|
</div>
|
|
142
142
|
${i.details?d`<span class="chat-working-indicator__details">${i.details}</span>`:v}
|
|
143
143
|
</div>
|
|
144
144
|
`:v}
|
|
145
|
-
${
|
|
145
|
+
${ks({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
|
|
146
146
|
<div class="chat-group-footer">
|
|
147
147
|
<span class="chat-sender-name">${o}</span>
|
|
148
148
|
<span class="chat-group-timestamp">${a}</span>
|
|
149
149
|
</div>
|
|
150
150
|
</div>
|
|
151
151
|
</div>
|
|
152
|
-
`}function
|
|
152
|
+
`}function Lr(e,t){const n=qe(e.role),s=t.assistantName??"Assistant",i=t.userName??"You",a=n==="user"?i:n==="assistant"?s:n,o=n==="user"?"user":n==="assistant"?"assistant":"other",l=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return d`
|
|
153
153
|
<div class="chat-group ${o}">
|
|
154
|
-
${
|
|
154
|
+
${Et(e.role,{assistantName:s,assistantAvatar:t.assistantAvatar??null,userName:i,userAvatar:t.userAvatar??null})}
|
|
155
155
|
<div class="chat-group-messages">
|
|
156
|
-
${e.messages.map((c,
|
|
156
|
+
${e.messages.map((c,f)=>ks(c.message,{isStreaming:e.isStreaming&&f===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar,t.onOpenFile,t.onOpenProof,t.onImageClick,t.resolveImageUrl,t.onPushToDrive))}
|
|
157
157
|
<div class="chat-group-footer">
|
|
158
158
|
<span class="chat-sender-name">${a}</span>
|
|
159
159
|
<span class="chat-group-timestamp">${l}</span>
|
|
160
160
|
</div>
|
|
161
161
|
</div>
|
|
162
162
|
</div>
|
|
163
|
-
`}function
|
|
163
|
+
`}function Et(e,t){const n=qe(e),s=t?.assistantName?.trim()||"Assistant",i=typeof t?.assistantAvatar=="string"?t.assistantAvatar.trim():"",a=t?.userName?.trim()||"You",o=typeof t?.userAvatar=="string"?t.userAvatar.trim():"",l=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return n==="user"?o&&bn(o)?d`<img
|
|
164
164
|
class="chat-avatar ${l}"
|
|
165
165
|
src="${o}"
|
|
166
166
|
alt="${a}"
|
|
167
|
-
/>`:o?d`<div class="chat-avatar ${l}">${o}</div>`:d`<div class="chat-avatar ${l}">${a.charAt(0).toUpperCase()||"C"}</div>`:n==="assistant"?i&&
|
|
167
|
+
/>`:o?d`<div class="chat-avatar ${l}">${o}</div>`:d`<div class="chat-avatar ${l}">${a.charAt(0).toUpperCase()||"C"}</div>`:n==="assistant"?i&&bn(i)?d`<img
|
|
168
168
|
class="chat-avatar ${l}"
|
|
169
169
|
src="${i}"
|
|
170
170
|
alt="${s}"
|
|
171
|
-
/>`:i?d`<div class="chat-avatar ${l}" style="color: var(--accent);">${i}</div>`:d`<div class="chat-avatar ${l}" style="color: var(--accent);">⚛️</div>`:n==="tool"?d`<div class="chat-avatar ${l}">⚙</div>`:d`<div class="chat-avatar ${l}">?</div>`}function
|
|
171
|
+
/>`:i?d`<div class="chat-avatar ${l}" style="color: var(--accent);">${i}</div>`:d`<div class="chat-avatar ${l}" style="color: var(--accent);">⚛️</div>`:n==="tool"?d`<div class="chat-avatar ${l}">⚙</div>`:d`<div class="chat-avatar ${l}">?</div>`}function bn(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||e.startsWith("/")}function wn(e,t,n){if(e.length===0)return v;const s=e.map((a,o)=>{if((a.omitted||!a.url)&&n){const l=n(o);if(l)return{...a,resolvedUrl:l}}return a}),i=s.filter(a=>(a.resolvedUrl||a.url)&&!a.omitted||a.resolvedUrl).map(a=>({url:a.resolvedUrl||a.url,alt:a.alt}));return d`
|
|
172
172
|
<div class="chat-message-images">
|
|
173
|
-
${s.map(a=>{const o=a.resolvedUrl||a.url;if(!o){const c
|
|
173
|
+
${s.map(a=>{const o=a.resolvedUrl||a.url;if(!o){const c=$r(a.bytes),r=[a.mimeType?a.mimeType.replace("image/","").toUpperCase():null,c].filter(Boolean).join(" · ");return d`
|
|
174
174
|
<div
|
|
175
175
|
class="chat-message-image chat-message-image--omitted"
|
|
176
176
|
title=${a.alt??"Sent image"}
|
|
@@ -184,12 +184,12 @@ ${o?`**Command:** \`${o}\`
|
|
|
184
184
|
src=${o}
|
|
185
185
|
alt=${a.alt??"Attached image"}
|
|
186
186
|
class="chat-message-image"
|
|
187
|
-
@error=${c=>{const
|
|
187
|
+
@error=${c=>{const f=c.target;f.style.display="none"}}
|
|
188
188
|
@click=${()=>{t&&t(o,i,Math.max(0,l))}}
|
|
189
189
|
/>
|
|
190
190
|
`})}
|
|
191
191
|
</div>
|
|
192
|
-
`}function
|
|
192
|
+
`}function Mr(e){return e.length===0?v:d`
|
|
193
193
|
<div class="chat-message-files">
|
|
194
194
|
${e.map(t=>{const n=t.fileName.length>30?t.fileName.slice(0,27)+"...":t.fileName;return d`
|
|
195
195
|
<a
|
|
@@ -202,37 +202,37 @@ ${o?`**Command:** \`${o}\`
|
|
|
202
202
|
</a>
|
|
203
203
|
`})}
|
|
204
204
|
</div>
|
|
205
|
-
`}function
|
|
205
|
+
`}function ks(e,t,n,s,i,a,o,l){try{return Ir(e,t,n,s,i,a,o,l)}catch(c){return console.error("[chat] message render error:",c),d`
|
|
206
206
|
<div class="chat-bubble">
|
|
207
207
|
<div class="chat-text"><em>Message failed to render</em></div>
|
|
208
208
|
</div>
|
|
209
|
-
`}}function
|
|
210
|
-
${b?
|
|
211
|
-
${p.map(E=>
|
|
212
|
-
`;if(!ue&&!g&&!b&&!C&&!S&&!M){const E=typeof c.errorMessage=="string"?c.errorMessage:null;if(c.stopReason==="error"&&E){let
|
|
209
|
+
`}}function Ir(e,t,n,s,i,a,o,l){const c=e,f=typeof c.role=="string"?c.role:"unknown",r=ws(e)||f.toLowerCase()==="toolresult"||f.toLowerCase()==="tool_result"||typeof c.toolCallId=="string"||typeof c.tool_call_id=="string",p=cr(e),g=p.length>0,y=ft(e),b=y.length>0,k=typeof c._chatIdx=="number"?c._chatIdx:-1,P=o&&k>=0?E=>o(k,E):void 0,U=Cr(e),C=U.length>0,D=Mt(e),Y=t.showReasoning&&f==="assistant"?vs(e):null,w=f==="user"&&D?br(D):null,T=f==="user"?It(e):null,A=T?_r(T):null,x=[...w??[],...A??[]],S=x.length>0;let L=D;if(f==="user"&&L&&(L=kr(L),L=Ar(L)),L&&(L=L.replace(/<(?:system|godmode)-context\b[^>]*>[\s\S]*?<\/(?:system|godmode)-context>/gi,"").trim()||null),L){const E=Lt(L);E&&(L=E)}S&&L&&(L=Sr(L));const ne=L?.trim()?L:null,M=Y?bs(Y):null,ue=ne,Zt=f==="assistant"&&!!ue?.trim(),Pi=["chat-bubble",Zt?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");if(g&&r)return d`
|
|
210
|
+
${b?wn(y,a,P):v}
|
|
211
|
+
${p.map(E=>fn(E,n,s,i,l))}
|
|
212
|
+
`;if(!ue&&!g&&!b&&!C&&!S&&!M){const E=typeof c.errorMessage=="string"?c.errorMessage:null;if(c.stopReason==="error"&&E){let B=E;const he=E.match(/(\d+)\s*tokens?\s*>\s*(\d+)/);if(he){const Li=parseInt(he[1]).toLocaleString(),Mi=parseInt(he[2]).toLocaleString();B=`Context overflow: ${Li} tokens exceeded the ${Mi} token limit. The conversation needs to be compacted.`}else E.includes("prompt is too long")&&(B="Context overflow: The conversation is too long for the model.");return d`
|
|
213
213
|
<div class="chat-bubble chat-bubble--error fade-in">
|
|
214
|
-
<div class="chat-text">${
|
|
214
|
+
<div class="chat-text">${B}</div>
|
|
215
215
|
</div>
|
|
216
|
-
`}if(
|
|
216
|
+
`}if(f==="user"&&D?.trim()){let B=D.replace(/<(?:system|godmode)-context\b[^>]*>[\s\S]*?<\/(?:system|godmode)-context>/gi,"").trim();if(B.startsWith("System:")||B.startsWith("GatewayRestart:")||B.startsWith("Sender (untrusted metadata)")){const he=B.indexOf(`
|
|
217
217
|
|
|
218
|
-
`);
|
|
218
|
+
`);B=he!==-1?B.slice(he+2).trim():""}if(B)return d`
|
|
219
219
|
<div class="chat-bubble fade-in">
|
|
220
|
-
<div class="chat-text">${
|
|
220
|
+
<div class="chat-text">${B}</div>
|
|
221
221
|
</div>
|
|
222
222
|
`}return v}return d`
|
|
223
|
-
<div class="${
|
|
224
|
-
${
|
|
225
|
-
${S?
|
|
226
|
-
${
|
|
227
|
-
${
|
|
223
|
+
<div class="${Pi}">
|
|
224
|
+
${Zt?Lo(ue):v}
|
|
225
|
+
${S?wr(x):v}
|
|
226
|
+
${wn(y,a,P)}
|
|
227
|
+
${Mr(U)}
|
|
228
228
|
${M?d`<details class="chat-thinking-details">
|
|
229
229
|
<summary class="chat-thinking-summary">Thinking...</summary>
|
|
230
|
-
<div class="chat-thinking">${re(
|
|
230
|
+
<div class="chat-thinking">${re(q(M))}</div>
|
|
231
231
|
</details>`:v}
|
|
232
|
-
${ue?d`<div class="chat-text" @click=${E=>{
|
|
233
|
-
${p.map(E=>
|
|
232
|
+
${ue?d`<div class="chat-text" @click=${E=>{yr(E,s),vr(E)}}>${re(t.isStreaming?fs(ue):q(ue))}</div>`:v}
|
|
233
|
+
${p.map(E=>fn(E,n,s,i,l))}
|
|
234
234
|
</div>
|
|
235
|
-
`}function
|
|
235
|
+
`}function Rr(e){const t=e,n=typeof t.content=="string"?t.content:"",s=typeof t.keptMessages=="number"?t.keptMessages:null,i=typeof t.timestamp=="number"?new Date(t.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):"";return d`
|
|
236
236
|
<div class="chat-compaction-summary">
|
|
237
237
|
<div class="chat-compaction-summary__header">
|
|
238
238
|
<span class="chat-compaction-summary__icon">📋</span>
|
|
@@ -240,68 +240,68 @@ ${o?`**Command:** \`${o}\`
|
|
|
240
240
|
${s!==null?d`<span class="chat-compaction-summary__kept">${s} messages kept</span>`:v}
|
|
241
241
|
</div>
|
|
242
242
|
<div class="chat-compaction-summary__content">
|
|
243
|
-
${re(
|
|
243
|
+
${re(q(n))}
|
|
244
244
|
</div>
|
|
245
245
|
${i?d`<div class="chat-compaction-summary__timestamp">${i}</div>`:v}
|
|
246
246
|
</div>
|
|
247
|
-
`}function
|
|
247
|
+
`}function Er(e){return e.isCompactionSummary===!0}const $s=50,Cs=200,Dr="Assistant";function De(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function gt(e){const t=De(e?.name,$s)??Dr,n=De(e?.avatar??void 0,Cs)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Or(){return gt(typeof window>"u"?{}:{name:window.__OPENCLAW_ASSISTANT_NAME__||window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__OPENCLAW_ASSISTANT_AVATAR__||window.__CLAWDBOT_ASSISTANT_AVATAR__})}const Kr="You";function Sn(e){const t=De(e?.name,$s)??Kr,n=De(e?.avatar??void 0,Cs)??null;return{name:t,avatar:n}}function Nr(){return Sn(typeof window>"u"?{}:{name:window.__OPENCLAW_USER_NAME__||window.__CLAWDBOT_USER_NAME__,avatar:window.__OPENCLAW_USER_AVATAR__||window.__CLAWDBOT_USER_AVATAR__})}async function xs(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 a=gt(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}let _n=!1;function Tn(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 Fr(){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 Ur(){_n||(_n=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function je(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),Tn(t)}return Ur(),Tn(Fr())}let Ie=null;function Ps(){return Ie}const Ls=new Map,ee=new Map;function yt(e,t){const n=t.filter(s=>s?.role==="user").length;Ls.set(e,n)}async function Ms(e,t){try{const n=await e.request("chat.history",{sessionKey:t,limit:200}),s=Array.isArray(n.messages)?n.messages:[];return ee.set(t,s),yt(t,s),s}catch{return ee.get(t)??[]}}let ye=0;async function N(e){if(!e.client||!e.connected)return;const t=e.sessionKey,n=++ye;e.chatLoading=!0,e.lastError=null;try{const s=await e.client.request("chat.history",{sessionKey:t,limit:200});if(n!==ye||e.sessionKey!==t)return;e.chatMessages=Array.isArray(s.messages)?s.messages:[],e.chatThinkingLevel=s.thinkingLevel??null,yt(t,e.chatMessages),ee.set(t,e.chatMessages)}catch{if(n!==ye||e.sessionKey!==t)return;try{const s=await e.client.request("chat.history",{sessionKey:t,limit:200});if(n!==ye||e.sessionKey!==t)return;e.chatMessages=Array.isArray(s.messages)?s.messages:[],e.chatThinkingLevel=s.thinkingLevel??null,yt(t,e.chatMessages),ee.set(t,e.chatMessages)}catch(s){if(n!==ye||e.sessionKey!==t)return;e.lastError=String(s)}}finally{e.chatLoading=!1}}async function Is(e,t){const n=[...e.chatMessages],s=n.length;await N(e),!t?.allowShrink&&s>0&&(e.chatMessages.length<s||Br(n,e.chatMessages))?(e.chatMessages=n,setTimeout(()=>{N(e).then(()=>{e.chatStream=null})},2e3)):e.chatStream=null}function Br(e,t){const n=Wr(e,a=>a?.role==="user");if(n===-1)return!1;const i=e[n].timestamp;return typeof i!="number"?!1:!t.some(a=>a?.role==="user"&&a?.timestamp===i)}function Wr(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}function qr(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Rs(e,t,n,s){if(!e.client||!e.connected)return!1;let i=t.trim();const a=n&&n.length>0;if(!i&&!a)return!1;!i&&a&&(i="[attached]");const o=Date.now();if(!s?.skipOptimisticUpdate){const f=[];if(i&&f.push({type:"text",text:i}),a)for(const r of n)r.mimeType.startsWith("image/")?f.push({type:"image",source:{type:"base64",media_type:r.mimeType,data:r.dataUrl}}):f.push({type:"attachment",mimeType:r.mimeType,fileName:r.fileName,content:r.dataUrl});e.chatMessages=[...e.chatMessages,{role:"user",content:f,timestamp:o}]}e.chatSending=!0,e.chatSendingSessionKey=e.sessionKey,e.lastError=null;const l=je();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;let c;if(a){const f=[],r=[];for(const p of n){const g=qr(p.dataUrl);if(g)if(g.mimeType.startsWith("image/"))f.push({type:"image",mimeType:g.mimeType,content:g.content,fileName:p.fileName});else{const y=p.fileName||"file";r.push(`<document>
|
|
248
248
|
<source>${y}</source>
|
|
249
249
|
<mime_type>${g.mimeType}</mime_type>
|
|
250
250
|
<content encoding="base64">
|
|
251
251
|
${g.content}
|
|
252
252
|
</content>
|
|
253
|
-
</document>`)}}if(
|
|
253
|
+
</document>`)}}if(f.length>0&&(c=f),r.length>0&&(i=`${r.join(`
|
|
254
254
|
|
|
255
255
|
`)}
|
|
256
256
|
|
|
257
|
-
${i}`),m.length>0){const p=e.chatMessages.length-1,g=e.sessionKey,y=e.client.request("images.cache",{images:m.map(b=>({data:b.content,mimeType:b.mimeType,fileName:b.fileName})),sessionKey:g}).then(b=>{if(b?.cached&&b.cached.length>0){const A=b.cached.map((P,U)=>({messageIndex:p,imageIndex:U,hash:P.hash,mimeType:P.mimeType,bytes:P.bytes,role:"user",timestamp:o}));return e.client.request("images.updateIndex",{sessionKey:g,images:A}).catch(()=>{})}}).catch(()=>{});Re=y,y.finally(()=>{Re===y&&(Re=null)})}}try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:c}),!0}catch(m){const r=String(m);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=r,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+r}],timestamp:Date.now()}],!1}finally{e.chatSending=!1,e.chatSendingSessionKey=null}}async function Nt(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 Us(e,t){if(!t||!gs(t.sessionKey,e.sessionKey))return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?e.chatStream!==null?(e.refreshSessionsAfterChat=!0,null):"final":null;if(t.state!=="delta"&&_s(),t.state==="delta"){!e.chatRunId&&t.runId&&(e.chatRunId=t.runId,e.chatStreamStartedAt??=Date.now());const n=me(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else if(t.state==="final")e.chatRunId=null,e.chatStreamStartedAt=null;else if(t.state==="aborted")e.chatStream&&e.chatStream.trim().length>0&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:e.chatStream}],timestamp:e.chatStreamStartedAt??Date.now(),isAborted:!0}]),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null;else if(t.state==="error"){e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null;const n=t.errorMessage??"chat error";e.lastError=n;let s=n;if(n.includes("prompt is too long")||n.includes("tokens >")){const a=n.match(/(\d+)\s*tokens?\s*>\s*(\d+)/);if(a){const o=parseInt(a[1]).toLocaleString(),l=parseInt(a[2]).toLocaleString();s=`⚠️ Context overflow: ${o} tokens exceeds ${l} limit. Use /compact to free up space.`}else s="⚠️ Context overflow: The conversation is too long. Use /compact to free up space."}e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s}],timestamp:Date.now(),isError:!0}]}return t.state}const fe=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:Nt,getPendingImageCache:Ds,handleChatEvent:Us,laneMessageCache:Z,loadChatHistory:N,loadChatHistoryAfterFinal:Ns,loadLaneHistory:Ks,sendChatMessage:Fs,sessionTurnCounts:Os},Symbol.toStringTag,{value:"Module"}));function St(e){return typeof e=="object"&&e!==null}function Jr(e){if(!St(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!St(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,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?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:a}}function Xr(e){if(!St(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 Ws(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Zr(e,t){const n=Ws(e).filter(s=>s.id!==t.id);return n.push(t),n}function Pn(e,t){return Ws(e).filter(n=>n.id!==t)}const el=14400*1e3;function qs(e){return{openclawVersion:e.openclaw.version,openclawLatest:e.openclaw.latest,openclawUpdateAvailable:e.openclaw.updateAvailable,openclawInstallKind:e.openclaw.installKind,openclawChannel:e.openclaw.channel,pluginVersion:e.plugin.version,pluginLatest:e.plugin.latest,pluginUpdateAvailable:e.plugin.updateAvailable,pendingDeploy:e.pendingDeploy??null,fetchOk:e.fetchOk}}function Bs(e){const t=typeof e.behind=="number"?e.behind:null;return{openclawVersion:String(e.version??"unknown"),openclawLatest:null,openclawUpdateAvailable:(t??0)>0,openclawInstallKind:"unknown",openclawChannel:null,pluginVersion:"unknown",pluginLatest:null,pluginUpdateAvailable:!1,pendingDeploy:null,fetchOk:e.fetchOk}}async function js(e){if(!(!e.client||!e.connected)){e.updateLoading=!0,e.updateError=null;try{const t=await e.client.request("godmode.update.check",{});e.updateStatus=qs(t),e.updateLastChecked=Date.now()}catch{try{const t=await e.client.request("system.checkUpdates",{fetch:!0});t.error&&(e.updateError=String(t.error)),e.updateStatus=Bs(t),e.updateLastChecked=Date.now()}catch(t){e.updateError=String(t)}}finally{e.updateLoading=!1}}}async function Ln(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("godmode.update.check",{});e.updateStatus=qs(t),e.updateLastChecked=Date.now()}catch{try{const t=await e.client.request("system.checkUpdates",{fetch:!0});e.updateStatus=Bs(t),e.updateLastChecked=Date.now()}catch{}}}function Hs(e){e.updatePollInterval==null&&(Ln(e),e.updatePollInterval=window.setInterval(()=>{Ln(e)},el))}function zs(e){const t=e;t.updatePollInterval!=null&&(clearInterval(t.updatePollInterval),t.updatePollInterval=null)}async function Vs(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("godmode.update.postStatus",{});if(!t)return;const n=t.overallStatus,s=t.summary;if(!s)return;const i=n==="healthy"?"success":n==="degraded"?"error":"warning";typeof e.showToast=="function"&&e.showToast(s,i),js(e)}catch{}}const tl=Object.freeze(Object.defineProperty({__proto__:null,checkForUpdates:js,checkPostUpdateStatus:Vs,startUpdatePolling:Hs,stopUpdatePolling:zs},Symbol.toStringTag,{value:"Module"})),Gs={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"openclaw-control-ui",GODMODE_WEBCHAT:"godmode-webchat",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"openclaw-macos",IOS_APP:"openclaw-ios",ANDROID_APP:"openclaw-android",MOLTBOT_MACOS:"moltbot-macos",MOLTBOT_IOS:"moltbot-ios",MOLTBOT_ANDROID:"moltbot-android",MOLTBOT_PROBE:"moltbot-probe",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"openclaw-probe"},Mn=Gs,_t={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gs));new Set(Object.values(_t));function nl(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 sl=4008;class il{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.addEventListener("open",()=>this.queueConnect()),this.ws.addEventListener("message",t=>this.handleMessage(String(t.data??""))),this.ws.addEventListener("close",t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{}))}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.read","operator.write","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await Bi();const r=ji({deviceId:i.deviceId,role:s})?.token;o=r??this.opts.token,a=!!(r&&this.opts.token)}const l=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let c;if(t&&i){const r=Date.now(),p=this.connectNonce??void 0,g=nl({deviceId:i.deviceId,clientId:this.opts.clientName??Mn.CONTROL_UI,clientMode:this.opts.mode??_t.WEBCHAT,role:s,scopes:n,signedAtMs:r,token:o??null,nonce:p}),y=await Hi(i.privateKey,g);c={id:i.deviceId,publicKey:i.publicKey,signature:y,signedAt:r,nonce:p}}const m={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Mn.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??_t.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:c,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",m).then(r=>{r?.auth?.deviceToken&&i&&zi({deviceId:i.deviceId,role:r.auth.role??s,token:r.auth.deviceToken,scopes:r.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(r)}).catch(()=>{a&&i&&Vi({deviceId:i.deviceId,role:s}),this.ws?.close(sl,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,l=o&&typeof o.nonce=="string"?o.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n,s=1e4){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=He(),a={type:"req",id:i,method:t,params:n};let o=null;const l=new Promise((m,r)=>{this.pending.set(i,{resolve:p=>{o&&clearTimeout(o),m(p)},reject:p=>{o&&clearTimeout(o),r(p)}})});this.ws.send(JSON.stringify(a));const c=new Promise((m,r)=>{o=setTimeout(()=>{this.pending.delete(i),r(new Error(`RPC timeout: ${t} (${s}ms)`))},s)});return Promise.race([l,c])}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}const Qs={displayName:"label",sessionKey:"conversationId"},Ys={};for(const[e,t]of Object.entries(Qs))Ys[t]=e;const al={"sessions.autoTitle":["sessions.patch"],"sessions.rename":["sessions.patch"]},le=new Map;function ol(){try{const e=sessionStorage.getItem("godmode:healing-cache");if(e){const t=JSON.parse(e);for(const[n,s]of Object.entries(t))le.set(n,s)}}catch{}}function In(){try{const e={};for(const[t,n]of le)e[t]=n;sessionStorage.setItem("godmode:healing-cache",JSON.stringify(e))}catch{}}ol();function rl(e,t){const n=le.get(e);if(!n)return{method:e,params:t};const s=n.resolvedMethod;if(t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(n.fieldRenames).length>0){const i={...t};for(const[a,o]of Object.entries(n.fieldRenames))a in i&&!(o in i)&&(i[o]=i[a],delete i[a]);return{method:s,params:i}}return{method:s,params:t}}function ll(e,t,n){const s=n.toLowerCase(),i=n.match(/unexpected property[:\s]*['"]?(\w+)['"]?/i);if(i){const a=i[1],o=Qs[a];if(o&&t&&typeof t=="object"){const l={...t};if(a in l)return l[o]=l[a],delete l[a],console.log(`[safe-request] Self-heal: ${e} — rewrote "${a}" → "${o}"`),{method:e,params:l,renames:{[a]:o}}}}if(s.includes("unknown method")||s.includes("method not found")){const a=al[e];if(a&&a.length>0){const o=a[0];return console.log(`[safe-request] Self-heal: ${e} not found — falling back to ${o}`),{method:o,params:t,renames:{}}}}if((s.includes("unexpected property")||s.includes("unknown field"))&&t&&typeof t=="object"){const a={...t};let o=!1;const l={};for(const[c,m]of Object.entries(Ys))c in a&&(a[m]=a[c],delete a[c],l[c]=m,o=!0,console.log(`[safe-request] Self-heal: ${e} — reverse alias "${c}" → "${m}"`));if(o)return{method:e,params:a,renames:l}}return null}async function cl(e,t,n,s){const i=s?.timeout??3e4;let{method:a,params:o}=s?.raw?{method:t,params:n}:rl(t,n);const l=async(c,m)=>Promise.race([e.request(c,m),new Promise((r,p)=>setTimeout(()=>p(new Error(`Request timeout (${i}ms): ${c}`)),i))]);try{return{ok:!0,data:await l(a,o),method:a,healed:a!==t}}catch(c){const m=String(c instanceof Error?c.message:c);if(s?.raw)return{ok:!1,error:m,method:t};const r=ll(a,o,m);if(r)try{const p=await l(r.method,r.params);return le.set(t,{resolvedMethod:r.method,fieldRenames:r.renames,ts:Date.now()}),In(),{ok:!0,data:p,method:r.method,healed:!0}}catch(p){return{ok:!1,error:String(p instanceof Error?p.message:p),method:r.method,healed:!0}}if(s?.fallbacks)for(const p of s.fallbacks)try{const g=await l(p,o);return le.set(t,{resolvedMethod:p,fieldRenames:{},ts:Date.now()}),In(),{ok:!0,data:g,method:p,healed:!0}}catch{continue}return{ok:!1,error:m,method:a}}}function Js(){le.clear();try{sessionStorage.removeItem("godmode:healing-cache")}catch{}}function dl(){const e={};for(const[t,n]of le)e[t]=n;return e}const _u=Object.freeze(Object.defineProperty({__proto__:null,clearHealingCache:Js,getHealingEntries:dl,safeRequest:cl},Symbol.toStringTag,{value:"Module"}));let G=null;function ul(e,t){Js();const n=String(e.version??e.serverVersion??e.gatewayVersion??"unknown"),s=typeof e.protocol=="number"?e.protocol:void 0;G={hostVersion:n,protocolVersion:s,methods:{},initializedAt:Date.now(),probing:!0};try{const i=sessionStorage.getItem("godmode:host-compat");if(i){const a=JSON.parse(i);if(a.hostVersion===n&&a.methods)return G.methods=a.methods,G.probing=!1,G}}catch{}return pl(t).catch(()=>{}),G}async function pl(e){if(!G)return;const t=[{method:"sessions.list",params:{limit:1}},{method:"sessions.patch",params:{key:"__compat_probe__"}},{method:"sessions.autoTitle",params:{sessionKey:"__compat_probe__"}},{method:"config.get",params:{}}];for(const n of t){const s={available:!1,testedAt:Date.now()};try{await e.request(n.method,n.params),s.available=!0}catch(i){const a=String(i instanceof Error?i.message:i),o=a.toLowerCase(),l=o.includes("unknown method")||o.includes("not found")&&o.includes("method");s.available=!l,l&&(s.error="method not available");const c=a.match(/(?:expected|valid|accepted) (?:fields?|properties?)[:\s]*\[([^\]]+)\]/i);c&&(s.fields=c[1].split(",").map(m=>m.trim().replace(/['"]/g,"")))}G.methods[n.method]=s}G.probing=!1;try{sessionStorage.setItem("godmode:host-compat",JSON.stringify(G))}catch{}}const kt=new Map;let Rn=null,nt=!1;function Xs(e,t,n){return kt.get(`${e}:${t}:${n}`)??null}async function Zs(e){if(!e.client||!e.chatMessages?.length)return;const t=e.sessionKey,n=[];for(let s=0;s<e.chatMessages.length;s++){const i=e.chatMessages[s],a=vt(i);for(let o=0;o<a.length;o++)if(a[o].url&&!a[o].omitted){const l=/^data:([^;]+);base64,(.+)$/.exec(a[o].url);l&&n.push({data:l[2],mimeType:l[1],messageIndex:s,imageIndex:o,role:i.role||"unknown",timestamp:typeof i.timestamp=="number"?i.timestamp:void 0})}}if(n.length>0)try{const s=await e.client.request("images.cache",{images:n.map(i=>({data:i.data,mimeType:i.mimeType})),sessionKey:t});if(s?.cached){const i=n.map((a,o)=>({messageIndex:a.messageIndex,imageIndex:a.imageIndex,hash:s.cached[o]?.hash,mimeType:a.mimeType,bytes:s.cached[o]?.bytes??0,role:a.role,timestamp:a.timestamp})).filter(a=>!!a.hash);i.length>0&&await e.client.request("images.updateIndex",{sessionKey:t,images:i})}}catch{}if(!nt){nt=!0;try{const s=Ds();s&&await s.catch(()=>{});const i=async()=>{const o=await e.client.request("images.resolve",{sessionKey:t});if(o?.images&&Object.keys(o.images).length>0){Rn!==t&&kt.clear();for(const[l,c]of Object.entries(o.images))kt.set(`${t}:${l}`,c);return Rn=t,e.chatMessages=[...e.chatMessages],!0}return!1};if(!await i()&&e.chatMessages?.some(o=>vt(o).some(c=>c.omitted||!c.url))){for(const o of[500,1500,3e3])if(await new Promise(l=>setTimeout(l,o)),await i()||e.sessionKey!==t)break}}catch{}finally{nt=!1}}}let En=null;function hl(e){if(!e.chatMessages?.length)return;const t=e.chatMessages.slice(-5);for(const n of t){const s=n,i=Array.isArray(s.content)?s.content:[];for(const a of i){const o=a,l=typeof o.text=="string"?o.text:typeof o.content=="string"?o.content:null;if(l)try{const c=JSON.parse(l);if(c._sidebarAction?.type==="proof"&&c._sidebarAction.slug){const m=c._sidebarAction.slug;if(m===En)return;En=m,e.handleOpenProofDoc(m);return}}catch{}}}}function _e(e){Zs(e)}const we=[];function ei(){return[...we]}let Y=null;const fl=10,ml=1e3,j=new Map;function st(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function gl(e,t){if(!t?.mainSessionKey)return;const n="main",s=r=>(r??"").trim()===n||(r??"").trim()==="",i=s(e.sessionKey)?e.sessionKey:st(e.sessionKey,t),a=s(e.settings.sessionKey)?e.settings.sessionKey:st(e.settings.sessionKey,t),o=s(e.settings.lastActiveSessionKey)?e.settings.lastActiveSessionKey:st(e.settings.lastActiveSessionKey,t),l=i||a||e.sessionKey,c={...e.settings,sessionKey:a||l,lastActiveSessionKey:o||l},m=c.sessionKey!==e.settings.sessionKey||c.lastActiveSessionKey!==e.settings.lastActiveSessionKey;l!==e.sessionKey&&(e.sessionKey=l),m&&te(e,c)}function yl(e){Y&&(clearTimeout(Y),Y=null);const t=(e.reconnectAttempt??0)+1;e.reconnectAttempt=t,e.reconnecting=!0;const n=t<=fl?Math.min(ml*Math.pow(2,t-1),3e4):6e4;Y=setTimeout(()=>{Y=null,e.connected||ze(e)},n)}async function vl(e){if(!e.client)return;const t=e;try{if(t.setupQuickDone){t.workspaceNeedsSetup=!1;return}try{if((await e.client.request("onboarding.status",{}))?.identity?.name){t.workspaceNeedsSetup=!1;return}}catch{}const n=await e.client.request("projects.list",{});t.workspaceNeedsSetup=!n?.projects||n.projects.length===0}catch{}}async function bl(e){if(!e.client)return;if(e.workspaceNeedsSetup===!1){try{const n=await e.client.request("onboarding.status",{});n&&!n.completedAt&&await e.client.request("onboarding.complete",{summary:null})}catch{}return}try{const n=await e.client.request("onboarding.status",{}),s=e;if(n&&!n.completedAt){s.onboardingActive=!0,s.onboardingPhase=n.phase??0,s.onboardingData=n;const i=e;i.showSetupTab=!0;try{const a=await e.client.request("onboarding.setupProgress",{});e.setupProgress=a}catch{}if(n.identity?.name){i.setupQuickDone=!0;const a=e;a.settings.userName||(a.userName=n.identity.name,a.applySettings({...a.settings,userName:n.identity.name}))}}else if(s.onboardingActive=!1,s.onboardingData=n??null,n?.identity?.name){const i=e;i.settings.userName||(i.userName=n.identity.name,i.applySettings({...i.settings,userName:n.identity.name}))}}catch{}}function wl(e,t){if(!e.sessionsResult?.sessions)return;const n=e.sessionsResult.sessions.map(s=>s.key===t?{...s,updatedAt:Date.now()}:s);e.sessionsResult={...e.sessionsResult,sessions:n}}const ti=new Set;function ni(){ti.clear()}async function Sl(e,t){}function ze(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,ni();const t=e;"sessionsLoading"in t&&(t.sessionsLoading=!1),"agentsLoading"in t&&(t.agentsLoading=!1),"nodesLoading"in t&&(t.nodesLoading=!1),"devicesLoading"in t&&(t.devicesLoading=!1),"channelsLoading"in t&&(t.channelsLoading=!1),"configLoading"in t&&(t.configLoading=!1),"presenceLoading"in t&&(t.presenceLoading=!1),"cronLoading"in t&&(t.cronLoading=!1),"skillsLoading"in t&&(t.skillsLoading=!1),"debugLoading"in t&&(t.debugLoading=!1),"logsLoading"in t&&(t.logsLoading=!1),Y&&(clearTimeout(Y),Y=null),e.client?.stop(),e.client=new il({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"openclaw-control-ui",mode:"webchat",onHello:async n=>{const s=e.reconnecting;if(e.connected=!0,e.lastError=null,e.hello=n,e.reconnecting=!1,e.reconnectAttempt=0,s){const i=e;let a="Gateway reconnected";try{const o=await e.client.request("godmode.health",{});o?.crashRecovery&&(a=`Recovered from crash (${Math.round((o.crashRecovery.downtimeMs??0)/1e3)}s downtime). Everything is back online.`)}catch{}typeof i.showToast=="function"&&i.showToast(a,"success",6e3),e.lastError="✓ Reconnected",setTimeout(()=>{e.lastError==="✓ Reconnected"&&(e.lastError=null)},3e3),e.chatRunId=null,e.workingSessions.clear(),e.requestUpdate?.();for(const o of j.values())clearTimeout(o);j.clear()}document.title="GodMode",ul(n,e.client),ri(e,n),Es(e),Tl(e),Gi(e),Fe(e,{quiet:!0}),Ue(e,{quiet:!0}),K(e),Ge(e),vl(e).then(()=>bl(e)),Hs(e),Vs(e),$l(e),li(e)},onClose:({code:n,reason:s})=>{e.connected=!1,zs(e);const i=e;"chatSending"in i&&(i.chatSending=!1),"chatSendingSessionKey"in i&&(i.chatSendingSessionKey=null),"chatRunId"in i&&(i.chatRunId=null);const a=e;"sessionsLoading"in a&&(a.sessionsLoading=!1),"agentsLoading"in a&&(a.agentsLoading=!1),"nodesLoading"in a&&(a.nodesLoading=!1),"devicesLoading"in a&&(a.devicesLoading=!1),"channelsLoading"in a&&(a.channelsLoading=!1),"presenceLoading"in a&&(a.presenceLoading=!1),n!==1012&&(e.lastError=`disconnected (${n}): ${s||"no reason"}`),yl(e)},onEvent:n=>si(e,n),onGap:({expected:n,received:s})=>{e.lastError=`event gap detected (expected seq ${n}, got ${s}); refresh recommended`}}),e.client.start()}function Dn(e,t){if(!e.chatMessages)return;const n=t.outputPreview?`
|
|
257
|
+
${i}`),f.length>0){const p=e.chatMessages.length-1,g=e.sessionKey,y=e.client.request("images.cache",{images:f.map(b=>({data:b.content,mimeType:b.mimeType,fileName:b.fileName})),sessionKey:g}).then(b=>{if(b?.cached&&b.cached.length>0){const k=b.cached.map((P,U)=>({messageIndex:p,imageIndex:U,hash:P.hash,mimeType:P.mimeType,bytes:P.bytes,role:"user",timestamp:o}));return e.client.request("images.updateIndex",{sessionKey:g,images:k}).catch(()=>{})}}).catch(()=>{});Ie=y,y.finally(()=>{Ie===y&&(Ie=null)})}}try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:c}),!0}catch(f){const r=String(f);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=r,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+r}],timestamp:Date.now()}],!1}finally{e.chatSending=!1,e.chatSendingSessionKey=null}}async function Dt(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 Es(e,t){if(!t||!ds(t.sessionKey,e.sessionKey))return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?e.chatStream!==null?(e.refreshSessionsAfterChat=!0,null):"final":null;if(t.state!=="delta"&&gs(),t.state==="delta"){!e.chatRunId&&t.runId&&(e.chatRunId=t.runId,e.chatStreamStartedAt??=Date.now());const n=fe(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else if(t.state==="final")e.chatRunId=null,e.chatStreamStartedAt=null;else if(t.state==="aborted")e.chatStream&&e.chatStream.trim().length>0&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:e.chatStream}],timestamp:e.chatStreamStartedAt??Date.now(),isAborted:!0}]),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null;else if(t.state==="error"){e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null;const n=t.errorMessage??"chat error";e.lastError=n;let s=n;if(n.includes("prompt is too long")||n.includes("tokens >")){const a=n.match(/(\d+)\s*tokens?\s*>\s*(\d+)/);if(a){const o=parseInt(a[1]).toLocaleString(),l=parseInt(a[2]).toLocaleString();s=`⚠️ Context overflow: ${o} tokens exceeds ${l} limit. Use /compact to free up space.`}else s="⚠️ Context overflow: The conversation is too long. Use /compact to free up space."}e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s}],timestamp:Date.now(),isError:!0}]}return t.state}const me=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:Dt,getPendingImageCache:Ps,handleChatEvent:Es,laneMessageCache:ee,loadChatHistory:N,loadChatHistoryAfterFinal:Is,loadLaneHistory:Ms,sendChatMessage:Rs,sessionTurnCounts:Ls},Symbol.toStringTag,{value:"Module"}));function vt(e){return typeof e=="object"&&e!==null}function jr(e){if(!vt(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!vt(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,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?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:a}}function Hr(e){if(!vt(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 Ds(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Vr(e,t){const n=Ds(e).filter(s=>s.id!==t.id);return n.push(t),n}function An(e,t){return Ds(e).filter(n=>n.id!==t)}const zr=14400*1e3;function Os(e){return{openclawVersion:e.openclaw.version,openclawLatest:e.openclaw.latest,openclawUpdateAvailable:e.openclaw.updateAvailable,openclawInstallKind:e.openclaw.installKind,openclawChannel:e.openclaw.channel,pluginVersion:e.plugin.version,pluginLatest:e.plugin.latest,pluginUpdateAvailable:e.plugin.updateAvailable,pendingDeploy:e.pendingDeploy??null,fetchOk:e.fetchOk}}function Ks(e){const t=typeof e.behind=="number"?e.behind:null;return{openclawVersion:String(e.version??"unknown"),openclawLatest:null,openclawUpdateAvailable:(t??0)>0,openclawInstallKind:"unknown",openclawChannel:null,pluginVersion:"unknown",pluginLatest:null,pluginUpdateAvailable:!1,pendingDeploy:null,fetchOk:e.fetchOk}}async function Ns(e){if(!(!e.client||!e.connected)){e.updateLoading=!0,e.updateError=null;try{const t=await e.client.request("godmode.update.check",{});e.updateStatus=Os(t),e.updateLastChecked=Date.now()}catch{try{const t=await e.client.request("system.checkUpdates",{fetch:!0});t.error&&(e.updateError=String(t.error)),e.updateStatus=Ks(t),e.updateLastChecked=Date.now()}catch(t){e.updateError=String(t)}}finally{e.updateLoading=!1}}}async function kn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("godmode.update.check",{});e.updateStatus=Os(t),e.updateLastChecked=Date.now()}catch{try{const t=await e.client.request("system.checkUpdates",{fetch:!0});e.updateStatus=Ks(t),e.updateLastChecked=Date.now()}catch{}}}function Fs(e){e.updatePollInterval==null&&(kn(e),e.updatePollInterval=window.setInterval(()=>{kn(e)},zr))}function Us(e){const t=e;t.updatePollInterval!=null&&(clearInterval(t.updatePollInterval),t.updatePollInterval=null)}async function Bs(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("godmode.update.postStatus",{});if(!t)return;const n=t.overallStatus,s=t.summary;if(!s)return;const i=n==="healthy"?"success":n==="degraded"?"error":"warning";typeof e.showToast=="function"&&e.showToast(s,i),Ns(e)}catch{}}const Gr=Object.freeze(Object.defineProperty({__proto__:null,checkForUpdates:Ns,checkPostUpdateStatus:Bs,startUpdatePolling:Fs,stopUpdatePolling:Us},Symbol.toStringTag,{value:"Module"})),Ws={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"openclaw-control-ui",GODMODE_WEBCHAT:"godmode-webchat",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"openclaw-macos",IOS_APP:"openclaw-ios",ANDROID_APP:"openclaw-android",MOLTBOT_MACOS:"moltbot-macos",MOLTBOT_IOS:"moltbot-ios",MOLTBOT_ANDROID:"moltbot-android",MOLTBOT_PROBE:"moltbot-probe",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"openclaw-probe"},$n=Ws,bt={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Ws));new Set(Object.values(bt));function Qr(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 Yr=4008;class Jr{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.addEventListener("open",()=>this.queueConnect()),this.ws.addEventListener("message",t=>this.handleMessage(String(t.data??""))),this.ws.addEventListener("close",t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{}))}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.read","operator.write","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await Oi();const r=Ki({deviceId:i.deviceId,role:s})?.token;o=r??this.opts.token,a=!!(r&&this.opts.token)}const l=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let c;if(t&&i){const r=Date.now(),p=this.connectNonce??void 0,g=Qr({deviceId:i.deviceId,clientId:this.opts.clientName??$n.CONTROL_UI,clientMode:this.opts.mode??bt.WEBCHAT,role:s,scopes:n,signedAtMs:r,token:o??null,nonce:p}),y=await Ni(i.privateKey,g);c={id:i.deviceId,publicKey:i.publicKey,signature:y,signedAt:r,nonce:p}}const f={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??$n.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??bt.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:c,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",f).then(r=>{r?.auth?.deviceToken&&i&&Fi({deviceId:i.deviceId,role:r.auth.role??s,token:r.auth.deviceToken,scopes:r.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(r)}).catch(()=>{a&&i&&Ui({deviceId:i.deviceId,role:s}),this.ws?.close(Yr,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,l=o&&typeof o.nonce=="string"?o.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n,s=1e4){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=je(),a={type:"req",id:i,method:t,params:n};let o=null;const l=new Promise((f,r)=>{this.pending.set(i,{resolve:p=>{o&&clearTimeout(o),f(p)},reject:p=>{o&&clearTimeout(o),r(p)}})});this.ws.send(JSON.stringify(a));const c=new Promise((f,r)=>{o=setTimeout(()=>{this.pending.delete(i),r(new Error(`RPC timeout: ${t} (${s}ms)`))},s)});return Promise.race([l,c])}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}const qs={displayName:"label",sessionKey:"conversationId"},js={};for(const[e,t]of Object.entries(qs))js[t]=e;const Xr={"sessions.autoTitle":["sessions.patch"],"sessions.rename":["sessions.patch"]},le=new Map;function Zr(){try{const e=sessionStorage.getItem("godmode:healing-cache");if(e){const t=JSON.parse(e);for(const[n,s]of Object.entries(t))le.set(n,s)}}catch{}}function Cn(){try{const e={};for(const[t,n]of le)e[t]=n;sessionStorage.setItem("godmode:healing-cache",JSON.stringify(e))}catch{}}Zr();function el(e,t){const n=le.get(e);if(!n)return{method:e,params:t};const s=n.resolvedMethod;if(t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(n.fieldRenames).length>0){const i={...t};for(const[a,o]of Object.entries(n.fieldRenames))a in i&&!(o in i)&&(i[o]=i[a],delete i[a]);return{method:s,params:i}}return{method:s,params:t}}function tl(e,t,n){const s=n.toLowerCase(),i=n.match(/unexpected property[:\s]*['"]?(\w+)['"]?/i);if(i){const a=i[1],o=qs[a];if(o&&t&&typeof t=="object"){const l={...t};if(a in l)return l[o]=l[a],delete l[a],console.log(`[safe-request] Self-heal: ${e} — rewrote "${a}" → "${o}"`),{method:e,params:l,renames:{[a]:o}}}}if(s.includes("unknown method")||s.includes("method not found")){const a=Xr[e];if(a&&a.length>0){const o=a[0];return console.log(`[safe-request] Self-heal: ${e} not found — falling back to ${o}`),{method:o,params:t,renames:{}}}}if((s.includes("unexpected property")||s.includes("unknown field"))&&t&&typeof t=="object"){const a={...t};let o=!1;const l={};for(const[c,f]of Object.entries(js))c in a&&(a[f]=a[c],delete a[c],l[c]=f,o=!0,console.log(`[safe-request] Self-heal: ${e} — reverse alias "${c}" → "${f}"`));if(o)return{method:e,params:a,renames:l}}return null}async function nl(e,t,n,s){const i=s?.timeout??3e4;let{method:a,params:o}=s?.raw?{method:t,params:n}:el(t,n);const l=async(c,f)=>Promise.race([e.request(c,f),new Promise((r,p)=>setTimeout(()=>p(new Error(`Request timeout (${i}ms): ${c}`)),i))]);try{return{ok:!0,data:await l(a,o),method:a,healed:a!==t}}catch(c){const f=String(c instanceof Error?c.message:c);if(s?.raw)return{ok:!1,error:f,method:t};const r=tl(a,o,f);if(r)try{const p=await l(r.method,r.params);return le.set(t,{resolvedMethod:r.method,fieldRenames:r.renames,ts:Date.now()}),Cn(),{ok:!0,data:p,method:r.method,healed:!0}}catch(p){return{ok:!1,error:String(p instanceof Error?p.message:p),method:r.method,healed:!0}}if(s?.fallbacks)for(const p of s.fallbacks)try{const g=await l(p,o);return le.set(t,{resolvedMethod:p,fieldRenames:{},ts:Date.now()}),Cn(),{ok:!0,data:g,method:p,healed:!0}}catch{continue}return{ok:!1,error:f,method:a}}}function Hs(){le.clear();try{sessionStorage.removeItem("godmode:healing-cache")}catch{}}function sl(){const e={};for(const[t,n]of le)e[t]=n;return e}const du=Object.freeze(Object.defineProperty({__proto__:null,clearHealingCache:Hs,getHealingEntries:sl,safeRequest:nl},Symbol.toStringTag,{value:"Module"}));let G=null;function il(e,t){Hs();const n=String(e.version??e.serverVersion??e.gatewayVersion??"unknown"),s=typeof e.protocol=="number"?e.protocol:void 0;G={hostVersion:n,protocolVersion:s,methods:{},initializedAt:Date.now(),probing:!0};try{const i=sessionStorage.getItem("godmode:host-compat");if(i){const a=JSON.parse(i);if(a.hostVersion===n&&a.methods)return G.methods=a.methods,G.probing=!1,G}}catch{}return al(t).catch(()=>{}),G}async function al(e){if(!G)return;const t=[{method:"sessions.list",params:{limit:1}},{method:"sessions.patch",params:{key:"__compat_probe__"}},{method:"sessions.autoTitle",params:{sessionKey:"__compat_probe__"}},{method:"config.get",params:{}}];for(const n of t){const s={available:!1,testedAt:Date.now()};try{await e.request(n.method,n.params),s.available=!0}catch(i){const a=String(i instanceof Error?i.message:i),o=a.toLowerCase(),l=o.includes("unknown method")||o.includes("not found")&&o.includes("method");s.available=!l,l&&(s.error="method not available");const c=a.match(/(?:expected|valid|accepted) (?:fields?|properties?)[:\s]*\[([^\]]+)\]/i);c&&(s.fields=c[1].split(",").map(f=>f.trim().replace(/['"]/g,"")))}G.methods[n.method]=s}G.probing=!1;try{sessionStorage.setItem("godmode:host-compat",JSON.stringify(G))}catch{}}const wt=new Map;let xn=null,et=!1;function Vs(e,t,n){return wt.get(`${e}:${t}:${n}`)??null}async function zs(e){if(!e.client||!e.chatMessages?.length)return;const t=e.sessionKey,n=[];for(let s=0;s<e.chatMessages.length;s++){const i=e.chatMessages[s],a=ft(i);for(let o=0;o<a.length;o++)if(a[o].url&&!a[o].omitted){const l=/^data:([^;]+);base64,(.+)$/.exec(a[o].url);l&&n.push({data:l[2],mimeType:l[1],messageIndex:s,imageIndex:o,role:i.role||"unknown",timestamp:typeof i.timestamp=="number"?i.timestamp:void 0})}}if(n.length>0)try{const s=await e.client.request("images.cache",{images:n.map(i=>({data:i.data,mimeType:i.mimeType})),sessionKey:t});if(s?.cached){const i=n.map((a,o)=>({messageIndex:a.messageIndex,imageIndex:a.imageIndex,hash:s.cached[o]?.hash,mimeType:a.mimeType,bytes:s.cached[o]?.bytes??0,role:a.role,timestamp:a.timestamp})).filter(a=>!!a.hash);i.length>0&&await e.client.request("images.updateIndex",{sessionKey:t,images:i})}}catch{}if(!et){et=!0;try{const s=Ps();s&&await s.catch(()=>{});const i=async()=>{const o=await e.client.request("images.resolve",{sessionKey:t});if(o?.images&&Object.keys(o.images).length>0){xn!==t&&wt.clear();for(const[l,c]of Object.entries(o.images))wt.set(`${t}:${l}`,c);return xn=t,e.chatMessages=[...e.chatMessages],!0}return!1};if(!await i()&&e.chatMessages?.some(o=>ft(o).some(c=>c.omitted||!c.url))){for(const o of[500,1500,3e3])if(await new Promise(l=>setTimeout(l,o)),await i()||e.sessionKey!==t)break}}catch{}finally{et=!1}}}let Pn=null;function ol(e){if(!e.chatMessages?.length)return;const t=e.chatMessages.slice(-5);for(const n of t){const s=n,i=Array.isArray(s.content)?s.content:[];for(const a of i){const o=a,l=typeof o.text=="string"?o.text:typeof o.content=="string"?o.content:null;if(l)try{const c=JSON.parse(l);if(c._sidebarAction?.type==="proof"&&c._sidebarAction.slug){const f=c._sidebarAction.slug;if(f===Pn)return;Pn=f,e.handleOpenProofDoc(f);return}}catch{}}}}function _e(e){zs(e)}const we=[];function Gs(){return[...we]}let J=null;const rl=10,ll=1e3,j=new Map;function tt(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function cl(e,t){if(!t?.mainSessionKey)return;const n="main",s=r=>(r??"").trim()===n||(r??"").trim()==="",i=s(e.sessionKey)?e.sessionKey:tt(e.sessionKey,t),a=s(e.settings.sessionKey)?e.settings.sessionKey:tt(e.settings.sessionKey,t),o=s(e.settings.lastActiveSessionKey)?e.settings.lastActiveSessionKey:tt(e.settings.lastActiveSessionKey,t),l=i||a||e.sessionKey,c={...e.settings,sessionKey:a||l,lastActiveSessionKey:o||l},f=c.sessionKey!==e.settings.sessionKey||c.lastActiveSessionKey!==e.settings.lastActiveSessionKey;l!==e.sessionKey&&(e.sessionKey=l),f&&Q(e,c)}function dl(e){J&&(clearTimeout(J),J=null);const t=(e.reconnectAttempt??0)+1;e.reconnectAttempt=t,e.reconnecting=!0;const n=t<=rl?Math.min(ll*Math.pow(2,t-1),3e4):6e4;J=setTimeout(()=>{J=null,e.connected||He(e)},n)}async function ul(e){if(!e.client)return;const t=e;try{if(t.setupQuickDone){t.workspaceNeedsSetup=!1;return}try{if((await e.client.request("onboarding.status",{}))?.identity?.name){t.workspaceNeedsSetup=!1;return}}catch{}const n=await e.client.request("projects.list",{});t.workspaceNeedsSetup=!n?.projects||n.projects.length===0}catch{}}async function hl(e){if(!e.client)return;if(e.workspaceNeedsSetup===!1){try{const n=await e.client.request("onboarding.status",{});n&&!n.completedAt&&await e.client.request("onboarding.complete",{summary:null})}catch{}return}try{const n=await e.client.request("onboarding.status",{}),s=e;if(n&&!n.completedAt){s.onboardingActive=!0,s.onboardingPhase=n.phase??0,s.onboardingData=n;const i=e;i.showSetupTab=!0;try{const a=await e.client.request("onboarding.setupProgress",{});e.setupProgress=a}catch{}if(n.identity?.name){i.setupQuickDone=!0;const a=e;a.settings.userName||(a.userName=n.identity.name,a.applySettings({...a.settings,userName:n.identity.name}))}}else if(s.onboardingActive=!1,s.onboardingData=n??null,n?.identity?.name){const i=e;i.settings.userName||(i.userName=n.identity.name,i.applySettings({...i.settings,userName:n.identity.name}))}}catch{}}function pl(e,t){if(!e.sessionsResult?.sessions)return;const n=e.sessionsResult.sessions.map(s=>s.key===t?{...s,updatedAt:Date.now()}:s);e.sessionsResult={...e.sessionsResult,sessions:n}}const Qs=new Set;function Ys(){Qs.clear()}async function ml(e,t){}function He(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,Ys();const t=e;"sessionsLoading"in t&&(t.sessionsLoading=!1),"agentsLoading"in t&&(t.agentsLoading=!1),"nodesLoading"in t&&(t.nodesLoading=!1),"devicesLoading"in t&&(t.devicesLoading=!1),"channelsLoading"in t&&(t.channelsLoading=!1),"configLoading"in t&&(t.configLoading=!1),"presenceLoading"in t&&(t.presenceLoading=!1),"cronLoading"in t&&(t.cronLoading=!1),"skillsLoading"in t&&(t.skillsLoading=!1),"debugLoading"in t&&(t.debugLoading=!1),"logsLoading"in t&&(t.logsLoading=!1),J&&(clearTimeout(J),J=null),e.client?.stop(),e.client=new Jr({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"openclaw-control-ui",mode:"webchat",onHello:async n=>{const s=e.reconnecting;if(e.connected=!0,e.lastError=null,e.hello=n,e.reconnecting=!1,e.reconnectAttempt=0,s){const a=e;let o="Gateway reconnected";try{const l=await e.client.request("godmode.health",{});l?.crashRecovery&&(o=`Recovered from crash (${Math.round((l.crashRecovery.downtimeMs??0)/1e3)}s downtime). Everything is back online.`)}catch{}typeof a.showToast=="function"&&a.showToast(o,"success",6e3),e.lastError="✓ Reconnected",setTimeout(()=>{e.lastError==="✓ Reconnected"&&(e.lastError=null)},3e3),e.chatRunId=null,e.workingSessions.clear(),e.requestUpdate?.();for(const l of j.values())clearTimeout(l);j.clear()}const i=n.features;document.title=i?.hermes?"Hermes - GodMode":"GodMode",il(n,e.client),ti(e,n),xs(e),yl(e),Bi(e),Ne(e,{quiet:!0}),Fe(e,{quiet:!0}),K(e),Ve(e),ul(e).then(()=>hl(e)),Fs(e),Bs(e),bl(e),ni(e)},onClose:({code:n,reason:s})=>{e.connected=!1,Us(e);const i=e;"chatSending"in i&&(i.chatSending=!1),"chatSendingSessionKey"in i&&(i.chatSendingSessionKey=null),"chatRunId"in i&&(i.chatRunId=null);const a=e;"sessionsLoading"in a&&(a.sessionsLoading=!1),"agentsLoading"in a&&(a.agentsLoading=!1),"nodesLoading"in a&&(a.nodesLoading=!1),"devicesLoading"in a&&(a.devicesLoading=!1),"channelsLoading"in a&&(a.channelsLoading=!1),"presenceLoading"in a&&(a.presenceLoading=!1),n!==1012&&(e.lastError=`disconnected (${n}): ${s||"no reason"}`),dl(e)},onEvent:n=>Js(e,n),onGap:({expected:n,received:s})=>{e.lastError=`event gap detected (expected seq ${n}, got ${s}); refresh recommended`}}),e.client.start()}function Ln(e,t){if(!e.chatMessages)return;const n=t.outputPreview?`
|
|
258
258
|
|
|
259
259
|
${t.outputPreview.slice(0,800)}${t.outputPreview.length>800?"…":""}`:"",s=t.outputPath?`
|
|
260
260
|
|
|
261
261
|
Full output: \`${t.outputPath}\``:"";e.chatMessages=[...e.chatMessages,{role:"assistant",content:`**Agent completed: "${t.title||"Queue item"}"**${n}${s}
|
|
262
262
|
|
|
263
|
-
_Reply to review, approve, or ask follow-up questions._`,timestamp:Date.now(),isNotification:!0}],e.requestUpdate?.()}function si(e,t){try{_l(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function _l(e,t){if(we.unshift({ts:Date.now(),event:t.event,payload:t.payload}),we.length>250&&(we.length=250),e.tab==="debug"&&(e.eventLog=[...we]),t.event==="agent"){if(e.onboarding)return;const n=t.payload,s=n?.sessionKey;s&&n?.stream==="tool"&&n.data?.phase==="start"&&(e.workingSessions.has(s)||(e.workingSessions.add(s),e.requestUpdate?.())),Co(e,n);return}if(t.event==="chat"){const n=t.payload;if(n?.sessionKey){if(mi(e,n.sessionKey),n.state==="delta"){const a=j.get(n.sessionKey);a&&(clearTimeout(a),j.delete(n.sessionKey)),e.workingSessions.has(n.sessionKey)||(e.workingSessions.add(n.sessionKey),e.requestUpdate?.());const o=`safety:${n.sessionKey}`,l=j.get(o);l&&clearTimeout(l),j.set(o,setTimeout(()=>{j.delete(o),e.workingSessions.has(n.sessionKey)&&e.workingSessions.delete(n.sessionKey);const c=e;gs(n.sessionKey,c.sessionKey)&&c.chatStream!==null&&c.chatRunId===null&&(c.chatStream=null,c.chatStreamStartedAt=null),c.requestUpdate?.()},9e4))}else if((n.state==="final"||n.state==="error"||n.state==="aborted")&&e.workingSessions.has(n.sessionKey)){const a=j.get(n.sessionKey);a&&(clearTimeout(a),j.delete(n.sessionKey));const o=`safety:${n.sessionKey}`,l=j.get(o);l&&(clearTimeout(l),j.delete(o)),e.workingSessions.delete(n.sessionKey),e.requestUpdate?.()}}n.state==="final"&&wl(e,n.sessionKey);const s=Us(e,n),i=ft(n?.sessionKey);if(n&&i){const a=e,o=e.tab==="chat"&&e.sessionKey===O;if(n.state==="delta"){const l=me(n.message);if(!o){if(typeof l=="string"){const c=a.allyStream??"";(!c||l.length>=c.length)&&(a.allyStream=l)}a.allyWorking=!0,a.requestUpdate?.()}}else if(n.state==="final"){a.allyStream=null,a.allyWorking=!1,!a.allyPanelOpen&&e.tab!=="chat"&&(a.allyUnread=(a.allyUnread??0)+1);const l=e;l._loadAllyHistory().then(()=>{a.allyPanelOpen&&l._scrollAllyToBottom(),a.requestUpdate?.()})}else if(n.state==="error"||n.state==="aborted"){const l=me(n.message),c=n.state==="aborted"?"Response was stopped.":l||"Something went wrong — try again.";a.allyMessages=[...a.allyMessages??[],{role:"assistant",content:`*${c}*`,timestamp:Date.now()}],a.allyStream=null,a.allyWorking=!1,a.requestUpdate?.()}}if(n.state==="final"&&(async()=>{await Sl(e,n.sessionKey);try{await K(e,{activeMinutes:0})}catch{}})(),(s==="final"||s==="error"||s==="aborted")&&(It(e),ki(e),s==="final"&&e.compactionStatus?.active&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus.startedAt??null,completedAt:Date.now()},e.showToast?.("Compaction complete","info",2e3)),(s==="error"||s==="aborted")&&e.compactionStatus?.active&&(e.compactionStatus=null),e.refreshSessionsAfterChat=!1),s==="final"){const a=!!e.compactionStatus?.completedAt;Ns(e,{allowShrink:a}).then(()=>{F(e,!0),Zs(e),e.loadSessionResources?.(),hl(e)}),e.tab==="dashboards"&&z.emit("refresh-requested",{target:"dashboards",sessionKey:n.sessionKey})}return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&Gt(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Ue(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Jr(t.payload);if(n){e.execApprovalQueue=Zr(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Pn(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.process.completed"){const n=t.payload;if(n?.sessionId){const s=n.exitSignal?`signal ${n.exitSignal}`:`exit ${n.exitCode??0}`,i=n.status==="completed"?"✓":"✗",a=n.status==="completed"?"success":"warning",o=n.sessionId.slice(0,8),l=e;typeof l.showToast=="function"&&l.showToast(`${i} Process ${o} ${n.status} (${s})`,a,5e3)}return}if(t.event==="exec.approval.resolved"){const n=Xr(t.payload);n&&(e.execApprovalQueue=Pn(e.execApprovalQueue,n.id))}if(t.event==="daily-brief:update"){z.emit("refresh-requested",{target:"today"});return}if(t.event==="ui.slot.update"){const n=t.payload;if(n?.tabId){const s=n.mode??"replace";if(n.html)s==="append"?e.dynamicSlots={...e.dynamicSlots,[n.tabId]:(e.dynamicSlots[n.tabId]??"")+n.html}:e.dynamicSlots={...e.dynamicSlots,[n.tabId]:n.html};else{const a={...e.dynamicSlots};delete a[n.tabId],e.dynamicSlots=a}e.requestUpdate?.()}return}if(t.event==="guardrails:update"){const n=e;typeof n.handleGuardrailsLoad=="function"&&n.handleGuardrailsLoad();return}if(t.event==="fathom:meeting-processed"){const n=t.payload;if(n?.title){const s=e;typeof s.showToast=="function"&&s.showToast(`Meeting processed: ${n.title}`,"success",6e3);const i=n.message??`Meeting "${n.title}" has been processed.`;s.allyMessages=[...s.allyMessages??[],{role:"assistant",content:i,timestamp:Date.now()}],!s.allyPanelOpen&&s.tab!=="chat"&&(s.allyUnread=(s.allyUnread??0)+1),s.sessionKey===O&&s.chatMessages&&(s.chatMessages=[...s.chatMessages,{role:"assistant",content:i,timestamp:Date.now()}]),s.requestUpdate?.()}return}if(t.event==="onboarding:update"){const n=t.payload;if(n){const s=e;if(typeof n.phase=="number"&&(s.onboardingPhase=n.phase),s.onboardingData=n,n.completedAt&&(s.onboardingActive=!1),n.identity?.name){const i=e;(!i.userName||!i.settings.userName)&&(i.userName=n.identity.name,i.applySettings({...i.settings,userName:n.identity.name}))}s.requestUpdate?.()}return}if(t.event==="inbox:update"){z.emit("refresh-requested",{target:"today"});return}if(t.event==="hitl:checkpoint"){const n=t.payload;if(n?.id){const s=e;s.hitlCheckpoints=[...s.hitlCheckpoints??[],n],s.requestUpdate?.();const i=e,a={role:"assistant",content:n.summary||`Agent checkpoint: ${n.agentName??"Agent"} is awaiting approval.`,timestamp:Date.now(),isNotification:!0,hitlCheckpoint:n,actions:[{label:"Review",action:"navigate",target:"today"}]};i.allyMessages=[...i.allyMessages??[],a],!i.allyPanelOpen&&e.tab!=="chat"&&(i.allyUnread=(i.allyUnread??0)+1)}z.emit("refresh-requested",{target:"today"});return}if(t.event==="queue:update"){const n=t.payload;n?.status==="processing"&&n.proofDocSlug&&e.handleOpenProofDoc?.(n.proofDocSlug).catch(()=>{}),z.emit("refresh-requested",{target:"today"});return}if(t.event==="ally:notification"){const n=t.payload;if(n){const s=e,i={role:"assistant",content:n.summary||n.message||"Notification received.",timestamp:Date.now(),isNotification:!0,actions:n.actions??[]};s.allyMessages=[...s.allyMessages??[],i],!s.allyPanelOpen&&e.tab!=="chat"&&(s.allyUnread=(s.allyUnread??0)+1);const a=["queue-complete","queue-needs-review","queue-failed","cron-result","paperclip-completion"];n.type&&a.includes(n.type)&&z.emit("refresh-requested",{target:"today"});const o=["queue-complete","queue-needs-review","paperclip-completion"];if(n.type&&o.includes(n.type)){const l=n,c=e;i.content=l.message||i.content,l.sessionKey&&c.sessionKey===l.sessionKey?Dn(c,l):l.sessionKey||Dn(c,l)}s.requestUpdate?.()}return}if(t.event==="sessions:updated"){const n=t.payload;n?.sessionKey&&n?.title&&(e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.map(s=>s.key===n.sessionKey||s.key?.endsWith(`:${n.sessionKey?.split(":").pop()}`)||n.sessionKey?.endsWith(`:${s.key?.split(":").pop()}`)?{...s,displayName:n.title,label:n.title}:s)}),se.set(n.sessionKey,n.title),ti.add(n.sessionKey),e.requestUpdate?.());return}if(t.event==="session:auto-compact"){const n=t.payload;if(n?.sessionKey){const s=e;n.sessionKey===s.sessionKey&&!s.compactionStatus?.active&&s.connected&&(s.showToast?.("Context near limit — auto-compacting...","info",3e3),s.handleCompactChat?.())}return}}const kl=300*1e3;async function Tl(e){if(!e.client)return;const t=e;if(!(t.availableModels.length>0&&Date.now()-t.modelCacheTs<kl))try{const n=await e.client.request("godmode.config.model",{});n?.primary&&(t.currentModel=n.primary),Array.isArray(n?.available)&&(t.availableModels=n.available),t.modelCacheTs=Date.now()}catch{}}async function Al(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.model.set",{primary:t}),n.currentModel=t,n.modelPickerOpen=!1,e.modelCacheTs=0}catch(s){console.error("[model-switch]",s)}}async function $l(e){if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("openTask");if(!n||!e.client)return;t.delete("openTask");const s=t.toString()?`${window.location.pathname}?${t.toString()}`:window.location.pathname;window.history.replaceState({},"",s);try{const i=await e.client.request("tasks.openSession",{taskId:n});if(i?.sessionKey){e.sessionKey=i.sessionKey,e.tab="chat";const{loadChatHistory:a}=await _(async()=>{const{loadChatHistory:o}=await Promise.resolve().then(()=>fe);return{loadChatHistory:o}},void 0,import.meta.url);await a(e,i.sessionKey)}}catch(i){console.error("[GodMode] Failed to open task session:",i)}}async function ii(e){if(!e.client)return;const t=e;t.secretsLoading=!0;try{const n=await e.client.request("godmode.secrets.list",{});t.secrets=n?.keys??[]}catch{t.secrets=[]}finally{t.secretsLoading=!1}}async function ai(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.webfetch.set",{provider:t}),n.webFetchProvider=t}catch(s){console.error("[webfetch-set]",s)}}async function oi(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.search.set",{defaultProvider:t}),n.searchProvider=t}catch(s){console.error("[search-set]",s)}}function ri(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&gl(e,n.sessionDefaults)}async function li(e){if(e.client)try{const n=(await e.client.request("customTabs.list",{}))?.tabs??[];for(const s of Pa())La(s);for(const s of n)Ma(s.slug);e.customTabs=n}catch{e.customTabs=[]}}async function ci(e,t){if(!e.client)return;e.customTabLoading=!0,e.customTabErrors={};const n={},s={};for(const i of t.dataSources)try{if(i.type==="static")n[i.id]=i.data;else if(i.type==="rpc"&&i.method){const a=await e.client.request(i.method,i.params??{});n[i.id]=a}}catch(a){s[i.id]=a instanceof Error?a.message:String(a)}e.customTabData=n,e.customTabErrors=s,e.customTabLoading=!1}const di=Object.freeze(Object.defineProperty({__proto__:null,applySnapshot:ri,connectGateway:ze,fetchCustomTabData:ci,getEventLogSnapshot:ei,getResolvedImageUrl:Xs,handleGatewayEvent:si,loadCustomTabs:li,loadSecrets:ii,resetAutoTitleState:ni,setSearchProvider:oi,setWebFetchProvider:ai,switchModelFromChat:Al,triggerImageResolve:_e},Symbol.toStringTag,{value:"Module"}));function Ft(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Fe(e,{quiet:!0})},5e3))}function Ut(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Wt(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&xt(e,{quiet:!0})},2e3))}function qt(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Bt(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&We(e)},3e3))}function jt(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ve(e,t=Date.now()){if(typeof e=="number"&&Number.isFinite(e))return new Date(e);if(typeof e=="string"){const n=Date.parse(e);if(Number.isFinite(n))return new Date(n)}return new Date(t)}function Ht(e){return{id:e.id,name:e.name,emoji:e.emoji||"📁",type:e.type,path:e.path,artifactCount:e.artifactCount??0,sessionCount:e.sessionCount??0,connectionCount:e.connectionCount??0,feedCount:e.feedCount??0,lastUpdated:Ve(e.lastUpdated,e.lastScanned)}}function it(e){return{path:e.path,name:e.name,type:e.type,size:e.size,modified:Ve(e.modified),isDirectory:e.isDirectory,searchText:e.searchText}}function On(e){return{id:e.id,key:e.key,title:e.title,created:Ve(e.created),status:e.status,workspaceSubfolder:e.workspaceSubfolder}}function Te(e){return{id:e.id,title:e.title,status:e.status,project:e.project,dueDate:e.dueDate,priority:e.priority,createdAt:e.createdAt,completedAt:e.completedAt}}function ui(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,fileType:t.fileType,size:t.size,modified:t.modified?Ve(t.modified):void 0,children:t.children?ui(t.children):void 0}))}function Cl(e,t){return{...t,id:e.id,name:e.name,emoji:e.emoji,type:e.type,path:e.path,artifactCount:e.artifactCount,sessionCount:e.sessionCount,lastUpdated:e.lastUpdated}}async function xl(e){if(!e.client||!e.connected){e.workspaces?.length||(e.workspaces=[],e.workspacesError="Connect to gateway to see workspaces"),e.workspacesLoading=!1;return}e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});if(e.workspaces=(t.workspaces??[]).map(Ht),e.selectedWorkspace){const n=e.workspaces.find(s=>s.id===e.selectedWorkspace?.id);n&&(e.selectedWorkspace=Cl(n,e.selectedWorkspace))}}catch(t){console.error("[Workspaces] load failed:",t),e.workspacesError=t instanceof Error?t.message:"Failed to load workspaces",e.workspaces?.length||(e.workspaces=[])}finally{e.workspacesLoading=!1}}async function zt(e,t){if(!e.client||!e.connected)return null;try{const n=await e.client.request("workspaces.get",{id:t});if(!n.workspace)return null;const s={...Ht(n.workspace),pinned:(n.pinned??[]).map(it),pinnedSessions:(n.pinnedSessions??[]).map(On),outputs:(n.outputs??[]).map(it),folderTree:n.folderTree?ui(n.folderTree):void 0,sessions:(n.sessions??[]).map(On),tasks:(n.tasks??[]).map(Te),memory:(n.memory??[]).map(it)};try{const[i,a]=await Promise.all([Ll(e,t).catch(()=>[]),Ml(e,t).catch(()=>[])]);s.feedEntries=i,s.connections=a,s.feedCount=i.length,s.connectionCount=a.length}catch{}return s}catch(n){return console.error("[Workspaces] get failed:",n),null}}async function ku(e,t,n){if(!e.client||!e.connected)return null;try{const s=await e.client.request("workspaces.readFile",n?{workspaceId:n,filePath:t}:{path:t});return s.content?{content:s.content,mime:s.contentType??s.mime??"text/plain"}:(s.error&&console.warn("[Workspaces] readFile failed:",s.error),null)}catch(s){return console.error("[Workspaces] readFile error:",s),null}}async function Tu(e,t){if(!t){e.selectedWorkspace=null;return}const n=await zt(e,t.id);e.selectedWorkspace=n||{...t,pinned:[],pinnedSessions:[],outputs:[],sessions:[],tasks:[]}}async function Au(e,t,n,s){if(!e.client||!e.connected)return!1;try{if(await e.client.request(s?"workspaces.unpin":"workspaces.pin",{workspaceId:t,filePath:n}),e.selectedWorkspace?.id===t){const i=await zt(e,t);i&&(e.selectedWorkspace=i)}return!0}catch(i){return console.error("[Workspaces] pin toggle failed:",i),!1}}async function $u(e,t,n,s){if(!e.client||!e.connected)return!1;try{if(await e.client.request(s?"workspaces.unpinSession":"workspaces.pinSession",{workspaceId:t,sessionKey:n}),e.selectedWorkspace?.id===t){const i=await zt(e,t);i&&(e.selectedWorkspace=i)}return!0}catch(i){return console.error("[Workspaces] session pin toggle failed:",i),!1}}async function Cu(e,t){if(!e.client||!e.connected)return null;const n=String(t.name??"").trim();if(!n)return e.workspacesError="Workspace name is required",null;const s=t.type??"project",i=String(t.path??"").trim();try{const a=await e.client.request("workspaces.create",{name:n,type:s,...i?{path:i}:{}});if(!a.workspace)return e.workspacesError="Workspace creation returned no workspace",null;const o=Ht(a.workspace),l=e.workspaces??[],c=new Map(l.map(m=>[m.id,m]));return c.set(o.id,o),e.workspaces=Array.from(c.values()).toSorted((m,r)=>r.lastUpdated.getTime()-m.lastUpdated.getTime()),e.workspacesError=null,o}catch(a){return console.error("[Workspaces] create failed:",a),e.workspacesError=a instanceof Error?a.message:"Failed to create workspace",null}}async function xu(e,t){if(!e.client||!e.connected)return!1;try{return await e.client.request("workspaces.delete",{id:t}),e.workspaces=(e.workspaces??[]).filter(n=>n.id!==t),e.selectedWorkspace?.id===t&&(e.selectedWorkspace=null),e.workspacesError=null,!0}catch(n){return console.error("[Workspaces] delete failed:",n),e.workspacesError=n instanceof Error?n.message:"Failed to delete workspace",!1}}function Pu(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}const Pl={coding:"Builder",research:"Researcher",analysis:"Analyst",creative:"Creative",review:"Reviewer",ops:"Ops",task:"Agent",url:"Reader",idea:"Explorer"};async function Lu(e){if(!e.client||!e.connected)return[];try{const[t,n]=await Promise.all([e.client.request("tasks.list",{}),e.client.request("queue.list",{limit:100}).catch(()=>({items:[]}))]),s=new Map;for(const i of n.items)i.sourceTaskId&&(i.status==="processing"||i.status==="review"||i.status==="needs-review"||i.status==="failed")&&s.set(i.sourceTaskId,{status:i.status==="needs-review"?"review":i.status,type:i.type,roleName:Pl[i.type]??i.type,queueItemId:i.id});return(t.tasks??[]).map(i=>({...Te(i),queueStatus:s.get(i.id)??null}))}catch(t){return console.error("[Workspaces] loadAllTasksWithQueueStatus failed:",t),[]}}async function Mu(e,t,n){if(!e.client||!e.connected)return null;const s=n==="complete"?"pending":"complete";try{const i=await e.client.request("tasks.update",{id:t,status:s});return Te(i)}catch(i){return console.error("[Workspaces] toggleTaskComplete failed:",i),null}}async function Iu(e,t,n){if(!e.client||!e.connected)return null;try{const s=await e.client.request("tasks.update",{id:t,...n});return Te(s)}catch(s){return console.error("[Workspaces] updateTask failed:",s),null}}async function Ru(e,t){if(!e.client||!e.connected)return null;try{return await e.client.request("tasks.openSession",{taskId:t})}catch(n){return console.error("[Workspaces] startTask failed:",n),null}}async function Eu(e,t,n){if(!e.client||!e.connected)return null;try{const s=await e.client.request("tasks.create",{title:t,project:n,source:"chat"});return Te(s)}catch(s){return console.error("[Workspaces] createTask failed:",s),null}}async function Du(e,t,n){if(!e.client||!e.connected)return null;try{return await e.client.request("workspaces.browseFolder",{workspaceId:t,folderPath:n})}catch(s){return console.error("[Workspaces] browseFolder failed:",s),null}}async function Ou(e,t,n,s=50){if(!e.client||!e.connected)return[];try{return(await e.client.request("workspaces.search",{workspaceId:t,query:n,limit:s})).results??[]}catch(i){return console.error("[Workspaces] search failed:",i),[]}}async function Ku(e,t,n){if(!e.client||!e.connected)return!1;try{return await e.client.request("workspaces.createFolder",{workspaceId:t,folderPath:n}),!0}catch(s){return console.error("[Workspaces] createFolder failed:",s),!1}}async function Ll(e,t,n=50,s){if(!e.client||!e.connected)return[];try{return(await e.client.request("workspace.feed.read",{workspaceId:t,limit:n,before:s})).entries??[]}catch(i){return console.error("[Workspaces] loadFeed failed:",i),[]}}async function Nu(e,t,n,s="update"){if(!e.client||!e.connected)return null;try{return(await e.client.request("workspace.feed.post",{workspaceId:t,text:n,type:s,author:"user"})).entry??null}catch(i){return console.error("[Workspaces] postToFeed failed:",i),null}}async function Ml(e,t){if(!e.client||!e.connected)return[];try{return(await e.client.request("workspace.connections.list",{workspaceId:t})).connections??[]}catch(n){return console.error("[Workspaces] loadConnections failed:",n),[]}}async function Fu(e,t,n){if(!e.client||!e.connected)return{ok:!1,error:"Not connected"};try{return await e.client.request("workspace.connections.test",{workspaceId:t,connectionId:n})}catch(s){return console.error("[Workspaces] testConnection failed:",s),{ok:!1,error:s instanceof Error?s.message:"Failed"}}}async function Uu(e,t,n){if(!e.client||!e.connected)return!1;try{return await e.client.request("workspace.connections.remove",{workspaceId:t,connectionId:n}),!0}catch(s){return console.error("[Workspaces] removeConnection failed:",s),!1}}const pi="godmode.ui.settings.v1";function Il(){const e=new URLSearchParams(location.search),t=(()=>{const i=e.get("gatewayUrl");return i||(typeof window.__GODMODE_DEV__<"u"?"/ws":`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`)})(),n=e.get("token")||"",s={gatewayUrl:t,token:n,sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{System:!0,__missionControl__:!1},openTabs:[],tabLastViewed:{},userName:"",userAvatar:"",chatParallelView:!1,parallelLanes:[null,null,null,null]};try{const i=localStorage.getItem(pi);if(!i)return s;const a=JSON.parse(i);return{gatewayUrl:e.get("gatewayUrl")||(typeof window.__GODMODE_DEV__<"u"?"/ws":typeof a.gatewayUrl=="string"&&a.gatewayUrl.trim()?a.gatewayUrl.trim():s.gatewayUrl),token:n||(typeof a.token=="string"?a.token:""),sessionKey:typeof a.sessionKey=="string"&&a.sessionKey.trim()?a.sessionKey.trim():s.sessionKey,lastActiveSessionKey:typeof a.lastActiveSessionKey=="string"&&a.lastActiveSessionKey.trim()?a.lastActiveSessionKey.trim():typeof a.sessionKey=="string"&&a.sessionKey.trim()||s.lastActiveSessionKey,theme:a.theme==="light"||a.theme==="dark"||a.theme==="system"||a.theme==="lifetrack"?a.theme:s.theme,chatFocusMode:typeof a.chatFocusMode=="boolean"?a.chatFocusMode:s.chatFocusMode,chatShowThinking:typeof a.chatShowThinking=="boolean"?a.chatShowThinking:s.chatShowThinking,splitRatio:typeof a.splitRatio=="number"&&a.splitRatio>=.4&&a.splitRatio<=.7?a.splitRatio:s.splitRatio,navCollapsed:typeof a.navCollapsed=="boolean"?a.navCollapsed:s.navCollapsed,navGroupsCollapsed:typeof a.navGroupsCollapsed=="object"&&a.navGroupsCollapsed!==null?a.navGroupsCollapsed:s.navGroupsCollapsed,openTabs:Array.isArray(a.openTabs)&&a.openTabs.every(o=>typeof o=="string")?a.openTabs:s.openTabs,tabLastViewed:typeof a.tabLastViewed=="object"&&a.tabLastViewed!==null?a.tabLastViewed:s.tabLastViewed,userName:typeof a.userName=="string"?a.userName.trim().slice(0,50):s.userName,userAvatar:typeof a.userAvatar=="string"?a.userAvatar.trim():s.userAvatar,chatParallelView:typeof a.chatParallelView=="boolean"?a.chatParallelView:s.chatParallelView,parallelLanes:Array.isArray(a.parallelLanes)&&a.parallelLanes.length===4?a.parallelLanes.map(o=>typeof o=="string"?o:null):s.parallelLanes}}catch{return s}}function Rl(e){localStorage.setItem(pi,JSON.stringify(e))}const El=56,Dl="quantum-particles",Ol="quantum-particle";let J=null,Se=null;function q(e,t){return Math.random()*(t-e)+e}function hi(){if(fi(),typeof document>"u")return;const e=document.querySelector(".shell");if(!e){Se=requestAnimationFrame(()=>{Se=null,hi()});return}J=document.createElement("div"),J.className=Dl,Object.assign(J.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"1",overflow:"hidden"});for(let t=0;t<El;t++){const n=document.createElement("div");n.className=Ol;const s=q(2,5),i=q(.3,.65),a=q(15,35),o=q(0,12),l=q(5,95),c=q(5,95),m=q(-150,150),r=q(-200,200),p=q(-250,250),g=q(-350,350),y=q(.8,1.5);Object.assign(n.style,{position:"absolute",left:`${l}%`,top:`${c}%`,width:`${s}px`,height:`${s}px`,borderRadius:"50%",background:`rgba(235, 158, 15, ${q(.7,1)})`,boxShadow:`0 0 ${s*3}px rgba(235, 158, 15, ${i*.7})`,opacity:"0",willChange:"transform, opacity",animation:`quantum-float ${a}s ${o}s ease-in-out infinite`}),n.style.setProperty("--particle-opacity",String(i)),n.style.setProperty("--drift-x",`${m}px`),n.style.setProperty("--drift-y",`${r}px`),n.style.setProperty("--drift-end-x",`${p}px`),n.style.setProperty("--drift-end-y",`${g}px`),n.style.setProperty("--particle-scale-mid",String(y)),J.appendChild(n)}e.prepend(J)}function fi(){Se!==null&&(cancelAnimationFrame(Se),Se=null),J&&(J.remove(),J=null)}function Kl(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"lifetrack"}function Vt(e){return e==="system"?Kl():e==="light"?"lifetrack":e}const Le=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Nl=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ve=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Fl=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,l=Nl();if(!!o.startViewTransition&&!l){let m=.5,r=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")m=Le(n.pointerClientX/window.innerWidth),r=Le(n.pointerClientY/window.innerHeight);else if(n?.element){const g=n.element.getBoundingClientRect();g.width>0&&g.height>0&&typeof window<"u"&&(m=Le((g.left+g.width/2)/window.innerWidth),r=Le((g.top+g.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${m*100}%`),a.style.setProperty("--theme-switch-y",`${r*100}%`),a.classList.add("theme-transition");const p=setTimeout(()=>{ve(a)},1e3);try{const g=o.startViewTransition?.(()=>{t()});g?.finished?g.finished.finally(()=>{clearTimeout(p),ve(a)}):(clearTimeout(p),ve(a))}catch{clearTimeout(p),ve(a),t()}return}t(),ve(a)};function Ul(e,t){const n=Array.isArray(e)?[...new Set(e.map(s=>s.trim()).filter(s=>s.length>0))]:[];if(n.length===0&&t){const s=t.toLowerCase();s==="main"||s==="agent:main:main"||s.endsWith(":main")||n.push(t)}return n}function Wl(e){const t={};if(!e||typeof e!="object")return t;for(const[n,s]of Object.entries(e)){const i=n.trim();!i||typeof s!="number"||!Number.isFinite(s)||(t[i]=Math.max(t[i]??0,s))}return t}function te(e,t){const n=t.sessionKey.trim()||"main",s=Ul(t.openTabs,n),i=Wl(t.tabLastViewed),a={...t,sessionKey:n,openTabs:s,tabLastViewed:i,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||n};e.settings=a,Rl(a),a.theme!==e.theme&&(e.theme=a.theme,Qe(e,Vt(a.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function mi(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&te(e,{...e.settings,lastActiveSessionKey:n})}function ql(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const c=n.trim();c&&c!==e.settings.token&&te(e,{...e.settings,token:c}),t.delete("token"),o=!0}if(s!=null){const c=s.trim();c&&(e.password=c),t.delete("password"),o=!0}if(i!=null){const c=i.trim();if(c){e.sessionKey=c;const m=c.toLowerCase(),p=m==="main"||m==="agent:main:main"||m.endsWith(":main")||e.settings.openTabs.includes(c)?e.settings.openTabs:[...e.settings.openTabs,c];te(e,{...e.settings,sessionKey:c,lastActiveSessionKey:c,openTabs:p})}}if(a!=null){const c=a.trim();c&&c!==e.settings.gatewayUrl&&(e.pendingGatewayUrl=c),t.delete("gatewayUrl"),o=!0}if(!o)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function Bl(e,t){const n=e.tab;if(n!==t&&(e.tab=t),n==="chat"&&t!=="chat"&&e.sessionKey===O&&e._loadAllyHistory?.(),n==="dashboards"&&t!=="dashboards"){const s=e;if(s.dashboardPreviousSessionKey&&s.activeDashboardId){const i=s.dashboardPreviousSessionKey;s.dashboardPreviousSessionKey=null,s.activeDashboardId=null,s.activeDashboardManifest=null,s.activeDashboardHtml=null,s.dashboardChatOpen=!1,e.sessionKey=i}}t==="chat"&&(e.chatHasAutoScrolled=!1),t==="nodes"?Ft(e):Ut(e),t==="logs"?Wt(e):qt(e),t==="debug"?Bt(e):jt(e),Ge(e),yi(e,t,!1)}function jl(e,t,n){Fl({nextTheme:t,applyTheme:()=>{e.theme=t,te(e,{...e.settings,theme:t}),Qe(e,Vt(t))},context:n,currentTheme:e.theme})}async function Ge(e){if(e.tab==="overview"&&await vi(e),(e.tab==="today"||e.tab==="my-day")&&z.emit("refresh-requested",{target:"today"}),e.tab==="workspaces"&&await xl(e),e.tab==="channels"&&await Yl(e),e.tab==="instances"&&await Pt(e),e.tab==="sessions"&&(await K(e),await ut(e)),e.tab==="cron"&&await Gt(e),e.tab==="skills"&&(await is(e),await pt(e)),e.tab==="agents"){const{loadRoster:t}=await _(async()=>{const{loadRoster:n}=await import("./ctrl-settings-COfcdhha.js").then(s=>s.ac);return{loadRoster:n}},[],import.meta.url);await t(e)}if(e.tab==="nodes"&&(await Fe(e),await Ue(e),await oe(e),await as(e)),e.tab==="chat"&&(await Jt(e),F(e,!e.chatHasAutoScrolled),e.loadSessionResources?.()),e.tab==="trust"){const t=e,n=[];typeof t.handleTrustLoad=="function"&&n.push(t.handleTrustLoad()),n.push(Yi(t)),n.push(K(t)),await Promise.all(n)}if(e.tab==="guardrails"){const t=e;typeof t.handleGuardrailsLoad=="function"&&await t.handleGuardrailsLoad()}if(e.tab==="setup"){const t=e;typeof t.handleLoadCapabilities=="function"&&t.handleLoadCapabilities()}if(e.tab==="dashboards"){const t=e;typeof t.handleDashboardsRefresh=="function"&&await t.handleDashboardsRefresh()}if(e.tab==="memory"||e.tab==="second-brain"){const t=e;typeof t.handleSecondBrainRefresh=="function"&&await t.handleSecondBrainRefresh()}if(e.tab==="config"&&(await os(e),await oe(e)),e.tab==="debug"&&(await We(e),e.eventLog=ei()),e.tab==="logs"&&(e.logsAtBottom=!0,await xt(e,{reset:!0}),Mt(e,!0)),us(e.tab)){const t=e,n=(t.customTabs??[]).find(s=>s.slug===e.tab);if(n){const{fetchCustomTabData:s}=await _(async()=>{const{fetchCustomTabData:i}=await Promise.resolve().then(()=>di);return{fetchCustomTabData:i}},void 0,import.meta.url);await s(t,n)}}}function Hl(){if(typeof window>"u")return"";const e=window.__OPENCLAW_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ds(e):Ia(window.location.pathname)}function zl(e){e.theme=e.settings.theme??"system",Qe(e,Vt(e.theme))}function Qe(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t==="dark"?"dark":"light",t==="lifetrack"?hi():fi()}function Vl(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&Qe(e,n.matches?"dark":"lifetrack")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Gl(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function Kn(e,t){if(typeof window>"u")return;const n=cs(window.location.pathname,e.basePath)??"chat";gi(e,n),yi(e,n,t)}function Ql(e){if(typeof window>"u")return;const t=cs(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();if(s){e.sessionKey=s;const i=e.settings.openTabs.includes(s)?e.settings.openTabs:[...e.settings.openTabs,s];te(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s,openTabs:i})}gi(e,t)}function gi(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="nodes"?Ft(e):Ut(e),t==="logs"?Wt(e):qt(e),t==="debug"?Bt(e):jt(e),e.connected&&Ge(e)}function yi(e,t,n){if(typeof window>"u")return;const s=ln(Lt(t,e.basePath)),i=ln(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function V(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function vi(e){await Promise.all([H(e,!1),Pt(e),K(e),ss(e),We(e)])}async function Yl(e){await Promise.all([H(e,!0),os(e),oe(e)])}async function Gt(e){await Promise.all([H(e,!1),ss(e),Qi(e)])}function Ke(e){return e.chatSending||!!e.chatRunId}function ee(e,t){const n=t??e.sessionKey,s=e.chatMessage.trim();if(s)e.chatDrafts={...e.chatDrafts,[n]:s};else{const{[n]:i,...a}=e.chatDrafts;e.chatDrafts=a}}function ie(e,t){const n=t??e.sessionKey;e.chatMessage=e.chatDrafts[n]??""}function bi(e,t){const n=e.sessionKey,{[n]:s,...i}=e.chatDrafts;e.chatDrafts=i,n===e.sessionKey&&(e.chatMessage="")}function wi(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}function Jl(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/new"||n==="/reset"?!0:n.startsWith("/new ")||n.startsWith("/reset ")}async function Qt(e){e.connected&&(e.chatMessage="",await Nt(e))}function Xl(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);if(!s&&!i)return;const a=Date.now();e.chatQueue=[...e.chatQueue,{id:He(),text:s,createdAt:a,attachments:i?n?.map(l=>({...l})):void 0}];const o=[];if(s&&o.push({type:"text",text:s}),i&&n)for(const l of n)o.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],F(e,!0)}async function Tt(e,t,n){It(e);const s=e;s.sessionKey&&s.workingSessions&&(s.workingSessions=new Set([...s.workingSessions,s.sessionKey])),n?.skipOptimisticUpdate||queueMicrotask(()=>{F(e,!0)});const i=await Fs(e,t,n?.attachments,{skipOptimisticUpdate:n?.skipOptimisticUpdate});return!i&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!i&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),i&&(mi(e,e.sessionKey),e.chatAttachments=[]),i&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),i&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),F(e,!0),i&&!e.chatRunId&&Yt(e),i&&n?.refreshSessions&&(e.refreshSessionsAfterChat=!0),i}async function Yt(e){if(!e.connected||Ke(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Tt(e,t.text,{attachments:t.attachments,skipOptimisticUpdate:!0})||(e.chatQueue=[t,...e.chatQueue])}function Si(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function _i(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],l=o.length>0;if(!i&&!l)return;if(wi(i)){await Qt(e);return}const c=Jl(i);if(t==null&&(e.chatMessage="",bi(e)),n?.queue){Xl(e,i,o),Ke(e)||await Yt(e);return}if(Ke(e)){await Nt(e),await new Promise(m=>setTimeout(m,50)),await Tt(e,i,{attachments:l?o:void 0,refreshSessions:c});return}await Tt(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft),refreshSessions:c})}async function Jt(e){await Promise.all([N(e),K(e,{activeMinutes:0}),Ne(e)]),F(e,!0)}const ki=Yt;function Zl(e){const t=ms(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function ec(e,t){const n=ds(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ne(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Zl(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=ec(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const tc=Object.freeze(Object.defineProperty({__proto__:null,clearDraft:bi,flushChatQueueForEvent:ki,handleAbortChat:Qt,handleSendChat:_i,isChatBusy:Ke,isChatStopCommand:wi,refreshChat:Jt,refreshChatAvatar:Ne,removeQueuedMessage:Si,restoreDraft:ie,saveDraft:ee},Symbol.toStringTag,{value:"Module"})),nc={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},sc={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:""};function Ti(e){return new Date(e).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ic(e,t){const n=Ot(e),s=je(n.role);if(s==="system")return null;if(s==="tool"){const l=[];for(const c of n.content)if(c.name&&l.push(`**Tool:** ${c.name}`),c.text){const m=c.text.length>2e3?c.text.slice(0,2e3)+`
|
|
263
|
+
_Reply to review, approve, or ask follow-up questions._`,timestamp:Date.now(),isNotification:!0}],e.requestUpdate?.()}function Js(e,t){try{fl(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function fl(e,t){if(we.unshift({ts:Date.now(),event:t.event,payload:t.payload}),we.length>250&&(we.length=250),e.tab==="debug"&&(e.eventLog=[...we]),t.event==="agent"){if(e.onboarding)return;const n=t.payload,s=n?.sessionKey;s&&n?.stream==="tool"&&n.data?.phase==="start"&&(e.workingSessions.has(s)||(e.workingSessions.add(s),e.requestUpdate?.())),wo(e,n);return}if(t.event==="chat"){const n=t.payload;if(n?.sessionKey){if(li(e,n.sessionKey),n.state==="delta"){const a=j.get(n.sessionKey);a&&(clearTimeout(a),j.delete(n.sessionKey)),e.workingSessions.has(n.sessionKey)||(e.workingSessions.add(n.sessionKey),e.requestUpdate?.());const o=`safety:${n.sessionKey}`,l=j.get(o);l&&clearTimeout(l),j.set(o,setTimeout(()=>{j.delete(o),e.workingSessions.has(n.sessionKey)&&e.workingSessions.delete(n.sessionKey);const c=e;ds(n.sessionKey,c.sessionKey)&&c.chatStream!==null&&c.chatRunId===null&&(c.chatStream=null,c.chatStreamStartedAt=null),c.requestUpdate?.()},9e4))}else if((n.state==="final"||n.state==="error"||n.state==="aborted")&&e.workingSessions.has(n.sessionKey)){const a=j.get(n.sessionKey);a&&(clearTimeout(a),j.delete(n.sessionKey));const o=`safety:${n.sessionKey}`,l=j.get(o);l&&(clearTimeout(l),j.delete(o)),e.workingSessions.delete(n.sessionKey),e.requestUpdate?.()}}n.state==="final"&&pl(e,n.sessionKey);const s=Es(e,n),i=ut(n?.sessionKey);if(n&&i){const a=e,o=e.tab==="chat"&&e.sessionKey===O;if(n.state==="delta"){const l=fe(n.message);if(!o){if(typeof l=="string"){const c=a.allyStream??"";(!c||l.length>=c.length)&&(a.allyStream=l)}a.allyWorking=!0,a.requestUpdate?.()}}else if(n.state==="final"){a.allyStream=null,a.allyWorking=!1,!a.allyPanelOpen&&e.tab!=="chat"&&(a.allyUnread=(a.allyUnread??0)+1);const l=e;l._loadAllyHistory().then(()=>{a.allyPanelOpen&&l._scrollAllyToBottom(),a.requestUpdate?.()})}else if(n.state==="error"||n.state==="aborted"){const l=fe(n.message),c=n.state==="aborted"?"Response was stopped.":l||"Something went wrong — try again.";a.allyMessages=[...a.allyMessages??[],{role:"assistant",content:`*${c}*`,timestamp:Date.now()}],a.allyStream=null,a.allyWorking=!1,a.requestUpdate?.()}}if(n.state==="final"&&(async()=>{await ml(e,n.sessionKey);try{await K(e,{activeMinutes:0})}catch{}})(),(s==="final"||s==="error"||s==="aborted")&&(Pt(e),gi(e),s==="final"&&e.compactionStatus?.active&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus.startedAt??null,completedAt:Date.now()},e.showToast?.("Compaction complete","info",2e3)),(s==="error"||s==="aborted")&&e.compactionStatus?.active&&(e.compactionStatus=null),e.refreshSessionsAfterChat=!1),s==="final"){const a=!!e.compactionStatus?.completedAt;Is(e,{allowShrink:a}).then(()=>{F(e,!0),zs(e),e.loadSessionResources?.(),ol(e)}),e.tab==="dashboards"&&H.emit("refresh-requested",{target:"dashboards",sessionKey:n.sessionKey})}return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&qt(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Fe(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=jr(t.payload);if(n){e.execApprovalQueue=Vr(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=An(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.process.completed"){const n=t.payload;if(n?.sessionId){const s=n.exitSignal?`signal ${n.exitSignal}`:`exit ${n.exitCode??0}`,i=n.status==="completed"?"✓":"✗",a=n.status==="completed"?"success":"warning",o=n.sessionId.slice(0,8),l=e;typeof l.showToast=="function"&&l.showToast(`${i} Process ${o} ${n.status} (${s})`,a,5e3)}return}if(t.event==="exec.approval.resolved"){const n=Hr(t.payload);n&&(e.execApprovalQueue=An(e.execApprovalQueue,n.id))}if(t.event==="daily-brief:update"){H.emit("refresh-requested",{target:"today"});return}if(t.event==="ui.slot.update"){const n=t.payload;if(n?.tabId){const s=n.mode??"replace";if(n.html)s==="append"?e.dynamicSlots={...e.dynamicSlots,[n.tabId]:(e.dynamicSlots[n.tabId]??"")+n.html}:e.dynamicSlots={...e.dynamicSlots,[n.tabId]:n.html};else{const a={...e.dynamicSlots};delete a[n.tabId],e.dynamicSlots=a}e.requestUpdate?.()}return}if(t.event==="guardrails:update"){const n=e;typeof n.handleGuardrailsLoad=="function"&&n.handleGuardrailsLoad();return}if(t.event==="fathom:meeting-processed"){const n=t.payload;if(n?.title){const s=e;typeof s.showToast=="function"&&s.showToast(`Meeting processed: ${n.title}`,"success",6e3);const i=n.message??`Meeting "${n.title}" has been processed.`;s.allyMessages=[...s.allyMessages??[],{role:"assistant",content:i,timestamp:Date.now()}],!s.allyPanelOpen&&s.tab!=="chat"&&(s.allyUnread=(s.allyUnread??0)+1),s.sessionKey===O&&s.chatMessages&&(s.chatMessages=[...s.chatMessages,{role:"assistant",content:i,timestamp:Date.now()}]),s.requestUpdate?.()}return}if(t.event==="onboarding:update"){const n=t.payload;if(n){const s=e;if(typeof n.phase=="number"&&(s.onboardingPhase=n.phase),s.onboardingData=n,n.completedAt&&(s.onboardingActive=!1),n.identity?.name){const i=e;(!i.userName||!i.settings.userName)&&(i.userName=n.identity.name,i.applySettings({...i.settings,userName:n.identity.name}))}s.requestUpdate?.()}return}if(t.event==="inbox:update"){H.emit("refresh-requested",{target:"today"});return}if(t.event==="hitl:checkpoint"){const n=t.payload;if(n?.id){const s=e;s.hitlCheckpoints=[...s.hitlCheckpoints??[],n],s.requestUpdate?.();const i=e,a={role:"assistant",content:n.summary||`Agent checkpoint: ${n.agentName??"Agent"} is awaiting approval.`,timestamp:Date.now(),isNotification:!0,hitlCheckpoint:n,actions:[{label:"Review",action:"navigate",target:"today"}]};i.allyMessages=[...i.allyMessages??[],a],!i.allyPanelOpen&&e.tab!=="chat"&&(i.allyUnread=(i.allyUnread??0)+1)}H.emit("refresh-requested",{target:"today"});return}if(t.event==="queue:update"){const n=t.payload;n?.status==="processing"&&n.proofDocSlug&&e.handleOpenProofDoc?.(n.proofDocSlug).catch(()=>{}),H.emit("refresh-requested",{target:"today"});return}if(t.event==="ally:notification"){const n=t.payload;if(n){const s=e,i={role:"assistant",content:n.summary||n.message||"Notification received.",timestamp:Date.now(),isNotification:!0,actions:n.actions??[]};s.allyMessages=[...s.allyMessages??[],i],!s.allyPanelOpen&&e.tab!=="chat"&&(s.allyUnread=(s.allyUnread??0)+1);const a=["queue-complete","queue-needs-review","queue-failed","cron-result","paperclip-completion"];n.type&&a.includes(n.type)&&H.emit("refresh-requested",{target:"today"});const o=["queue-complete","queue-needs-review","paperclip-completion"];if(n.type&&o.includes(n.type)){const l=n,c=e;i.content=l.message||i.content,l.sessionKey&&c.sessionKey===l.sessionKey?Ln(c,l):l.sessionKey||Ln(c,l)}s.requestUpdate?.()}return}if(t.event==="sessions:updated"){const n=t.payload;n?.sessionKey&&n?.title&&(e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.map(s=>s.key===n.sessionKey||s.key?.endsWith(`:${n.sessionKey?.split(":").pop()}`)||n.sessionKey?.endsWith(`:${s.key?.split(":").pop()}`)?{...s,displayName:n.title,label:n.title}:s)}),se.set(n.sessionKey,n.title),Qs.add(n.sessionKey),e.requestUpdate?.());return}if(t.event==="session:auto-compact"){const n=t.payload;if(n?.sessionKey){const s=e;n.sessionKey===s.sessionKey&&!s.compactionStatus?.active&&s.connected&&(s.showToast?.("Context near limit — auto-compacting...","info",3e3),s.handleCompactChat?.())}return}}const gl=300*1e3;async function yl(e){if(!e.client)return;const t=e;if(!(t.availableModels.length>0&&Date.now()-t.modelCacheTs<gl))try{const n=await e.client.request("godmode.config.model",{});n?.primary&&(t.currentModel=n.primary),Array.isArray(n?.available)&&(t.availableModels=n.available),t.modelCacheTs=Date.now()}catch{}}async function vl(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.model.set",{primary:t,sessionKey:e.sessionKey}),n.currentModel=t,n.modelPickerOpen=!1,n.modelCacheTs=0}catch(s){console.error("[model-switch]",s)}}async function bl(e){if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("openTask");if(!n||!e.client)return;t.delete("openTask");const s=t.toString()?`${window.location.pathname}?${t.toString()}`:window.location.pathname;window.history.replaceState({},"",s);try{const i=await e.client.request("tasks.openSession",{taskId:n});if(i?.sessionKey){const a=i.sessionKey;e.sessionKey=a,e.tab="chat";const o=a.toLowerCase();!(o==="main"||o==="agent:main:main"||o.endsWith(":main"))&&!e.settings.openTabs.includes(a)&&Q(e,{...e.settings,openTabs:[...e.settings.openTabs,a],sessionKey:a,lastActiveSessionKey:a,tabLastViewed:{...e.settings.tabLastViewed,[a]:Date.now()}});const{loadChatHistory:c}=await _(async()=>{const{loadChatHistory:f}=await Promise.resolve().then(()=>me);return{loadChatHistory:f}},void 0,import.meta.url);await c(e,a)}}catch(i){console.error("[GodMode] Failed to open task session:",i)}}async function Xs(e){if(!e.client)return;const t=e;t.secretsLoading=!0;try{const n=await e.client.request("godmode.secrets.list",{});t.secrets=n?.keys??[]}catch{t.secrets=[]}finally{t.secretsLoading=!1}}async function Zs(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.webfetch.set",{provider:t}),n.webFetchProvider=t}catch(s){console.error("[webfetch-set]",s)}}async function ei(e,t){if(!e.client)return;const n=e;try{await e.client.request("godmode.config.search.set",{defaultProvider:t}),n.searchProvider=t}catch(s){console.error("[search-set]",s)}}function ti(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&cl(e,n.sessionDefaults)}async function ni(e){if(e.client)try{const n=(await e.client.request("customTabs.list",{}))?.tabs??[];for(const s of _a())Ta(s);for(const s of n)Aa(s.slug);e.customTabs=n}catch{e.customTabs=[]}}async function si(e,t){if(!e.client)return;e.customTabLoading=!0,e.customTabErrors={};const n={},s={};for(const i of t.dataSources)try{if(i.type==="static")n[i.id]=i.data;else if(i.type==="rpc"&&i.method){const a=await e.client.request(i.method,i.params??{});n[i.id]=a}}catch(a){s[i.id]=a instanceof Error?a.message:String(a)}e.customTabData=n,e.customTabErrors=s,e.customTabLoading=!1}const ii=Object.freeze(Object.defineProperty({__proto__:null,applySnapshot:ti,connectGateway:He,fetchCustomTabData:si,getEventLogSnapshot:Gs,getResolvedImageUrl:Vs,handleGatewayEvent:Js,loadCustomTabs:ni,loadSecrets:Xs,resetAutoTitleState:Ys,setSearchProvider:ei,setWebFetchProvider:Zs,switchModelFromChat:vl,triggerImageResolve:_e},Symbol.toStringTag,{value:"Module"}));function Ot(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Ne(e,{quiet:!0})},5e3))}function Kt(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Nt(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&kt(e,{quiet:!0})},2e3))}function Ft(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Ut(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Ue(e)},3e3))}function Bt(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}const ai="godmode.ui.settings.v1";function wl(){const e=new URLSearchParams(location.search),t=(()=>{const i=e.get("gatewayUrl");return i||(typeof window.__GODMODE_DEV__<"u"?"/ws":`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`)})(),n=e.get("token")||"",s={gatewayUrl:t,token:n,sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{System:!0,__missionControl__:!1},openTabs:[],tabLastViewed:{},userName:"",userAvatar:"",chatParallelView:!1,parallelLanes:[null,null,null,null]};try{const i=localStorage.getItem(ai);if(!i)return s;const a=JSON.parse(i);return{gatewayUrl:e.get("gatewayUrl")||(typeof window.__GODMODE_DEV__<"u"?"/ws":typeof a.gatewayUrl=="string"&&a.gatewayUrl.trim()?a.gatewayUrl.trim():s.gatewayUrl),token:n||(typeof a.token=="string"?a.token:""),sessionKey:typeof a.sessionKey=="string"&&a.sessionKey.trim()?a.sessionKey.trim():s.sessionKey,lastActiveSessionKey:typeof a.lastActiveSessionKey=="string"&&a.lastActiveSessionKey.trim()?a.lastActiveSessionKey.trim():typeof a.sessionKey=="string"&&a.sessionKey.trim()||s.lastActiveSessionKey,theme:a.theme==="light"||a.theme==="dark"||a.theme==="system"||a.theme==="lifetrack"?a.theme:s.theme,chatFocusMode:typeof a.chatFocusMode=="boolean"?a.chatFocusMode:s.chatFocusMode,chatShowThinking:typeof a.chatShowThinking=="boolean"?a.chatShowThinking:s.chatShowThinking,splitRatio:typeof a.splitRatio=="number"&&a.splitRatio>=.4&&a.splitRatio<=.7?a.splitRatio:s.splitRatio,navCollapsed:typeof a.navCollapsed=="boolean"?a.navCollapsed:s.navCollapsed,navGroupsCollapsed:typeof a.navGroupsCollapsed=="object"&&a.navGroupsCollapsed!==null?a.navGroupsCollapsed:s.navGroupsCollapsed,openTabs:Array.isArray(a.openTabs)&&a.openTabs.every(o=>typeof o=="string")?a.openTabs:s.openTabs,tabLastViewed:typeof a.tabLastViewed=="object"&&a.tabLastViewed!==null?a.tabLastViewed:s.tabLastViewed,userName:typeof a.userName=="string"?a.userName.trim().slice(0,50):s.userName,userAvatar:typeof a.userAvatar=="string"?a.userAvatar.trim():s.userAvatar,chatParallelView:typeof a.chatParallelView=="boolean"?a.chatParallelView:s.chatParallelView,parallelLanes:Array.isArray(a.parallelLanes)&&a.parallelLanes.length===4?a.parallelLanes.map(o=>typeof o=="string"?o:null):s.parallelLanes}}catch{return s}}function Sl(e){localStorage.setItem(ai,JSON.stringify(e))}const _l=56,Tl="quantum-particles",Al="quantum-particle";let X=null,Se=null;function W(e,t){return Math.random()*(t-e)+e}function oi(){if(ri(),typeof document>"u")return;const e=document.querySelector(".shell");if(!e){Se=requestAnimationFrame(()=>{Se=null,oi()});return}X=document.createElement("div"),X.className=Tl,Object.assign(X.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"1",overflow:"hidden"});for(let t=0;t<_l;t++){const n=document.createElement("div");n.className=Al;const s=W(2,5),i=W(.3,.65),a=W(15,35),o=W(0,12),l=W(5,95),c=W(5,95),f=W(-150,150),r=W(-200,200),p=W(-250,250),g=W(-350,350),y=W(.8,1.5);Object.assign(n.style,{position:"absolute",left:`${l}%`,top:`${c}%`,width:`${s}px`,height:`${s}px`,borderRadius:"50%",background:`rgba(235, 158, 15, ${W(.7,1)})`,boxShadow:`0 0 ${s*3}px rgba(235, 158, 15, ${i*.7})`,opacity:"0",willChange:"transform, opacity",animation:`quantum-float ${a}s ${o}s ease-in-out infinite`}),n.style.setProperty("--particle-opacity",String(i)),n.style.setProperty("--drift-x",`${f}px`),n.style.setProperty("--drift-y",`${r}px`),n.style.setProperty("--drift-end-x",`${p}px`),n.style.setProperty("--drift-end-y",`${g}px`),n.style.setProperty("--particle-scale-mid",String(y)),X.appendChild(n)}e.prepend(X)}function ri(){Se!==null&&(cancelAnimationFrame(Se),Se=null),X&&(X.remove(),X=null)}function kl(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"lifetrack"}function Wt(e){return e==="system"?kl():e==="light"?"lifetrack":e}const Pe=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,$l=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ve=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Cl=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,l=$l();if(!!o.startViewTransition&&!l){let f=.5,r=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")f=Pe(n.pointerClientX/window.innerWidth),r=Pe(n.pointerClientY/window.innerHeight);else if(n?.element){const g=n.element.getBoundingClientRect();g.width>0&&g.height>0&&typeof window<"u"&&(f=Pe((g.left+g.width/2)/window.innerWidth),r=Pe((g.top+g.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${f*100}%`),a.style.setProperty("--theme-switch-y",`${r*100}%`),a.classList.add("theme-transition");const p=setTimeout(()=>{ve(a)},1e3);try{const g=o.startViewTransition?.(()=>{t()});g?.finished?g.finished.finally(()=>{clearTimeout(p),ve(a)}):(clearTimeout(p),ve(a))}catch{clearTimeout(p),ve(a),t()}return}t(),ve(a)};function xl(e,t){const n=Array.isArray(e)?[...new Set(e.map(s=>s.trim()).filter(s=>s.length>0))]:[];if(n.length===0&&t){const s=t.toLowerCase();s==="main"||s==="agent:main:main"||s.endsWith(":main")||n.push(t)}return n}function Pl(e){const t={};if(!e||typeof e!="object")return t;for(const[n,s]of Object.entries(e)){const i=n.trim();!i||typeof s!="number"||!Number.isFinite(s)||(t[i]=Math.max(t[i]??0,s))}return t}function Q(e,t){const n=t.sessionKey.trim()||"main",s=xl(t.openTabs,n),i=Pl(t.tabLastViewed),a={...t,sessionKey:n,openTabs:s,tabLastViewed:i,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||n};e.settings=a,Sl(a),a.theme!==e.theme&&(e.theme=a.theme,ze(e,Wt(a.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function li(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Q(e,{...e.settings,lastActiveSessionKey:n})}function Ll(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const c=n.trim();c&&c!==e.settings.token&&Q(e,{...e.settings,token:c}),t.delete("token"),o=!0}if(s!=null){const c=s.trim();c&&(e.password=c),t.delete("password"),o=!0}if(i!=null){const c=i.trim();if(c){e.sessionKey=c;const f=c.toLowerCase(),p=f==="main"||f==="agent:main:main"||f.endsWith(":main")||e.settings.openTabs.includes(c)?e.settings.openTabs:[...e.settings.openTabs,c];Q(e,{...e.settings,sessionKey:c,lastActiveSessionKey:c,openTabs:p})}}if(a!=null){const c=a.trim();c&&c!==e.settings.gatewayUrl&&(e.pendingGatewayUrl=c),t.delete("gatewayUrl"),o=!0}if(!o)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function Ml(e,t){const n=e.tab;if(n!==t&&(e.tab=t),n==="chat"&&t!=="chat"&&e.sessionKey===O&&e._loadAllyHistory?.(),n==="dashboards"&&t!=="dashboards"){const s=e;if(s.dashboardPreviousSessionKey&&s.activeDashboardId){const i=s.dashboardPreviousSessionKey;s.dashboardPreviousSessionKey=null,s.activeDashboardId=null,s.activeDashboardManifest=null,s.activeDashboardHtml=null,s.dashboardChatOpen=!1,e.sessionKey=i}}t==="chat"&&(e.chatHasAutoScrolled=!1),t==="nodes"?Ot(e):Kt(e),t==="logs"?Nt(e):Ft(e),t==="debug"?Ut(e):Bt(e),Ve(e),di(e,t,!1)}function Il(e,t,n){Cl({nextTheme:t,applyTheme:()=>{e.theme=t,Q(e,{...e.settings,theme:t}),ze(e,Wt(t))},context:n,currentTheme:e.theme})}async function Ve(e){if(e.tab==="overview"&&await ui(e),(e.tab==="today"||e.tab==="my-day")&&H.emit("refresh-requested",{target:"today"}),e.tab==="workspaces"&&H.emit("refresh-requested",{target:"workspaces"}),e.tab==="channels"&&await Nl(e),e.tab==="instances"&&await $t(e),e.tab==="sessions"&&(await K(e),await lt(e)),e.tab==="cron"&&await qt(e),e.tab==="skills"&&(await Xn(e),await ct(e)),e.tab==="agents"){const{loadRoster:t}=await _(async()=>{const{loadRoster:n}=await import("./ctrl-settings-nG144v_G.js").then(s=>s.ac);return{loadRoster:n}},[],import.meta.url);await t(e)}if(e.tab==="nodes"&&(await Ne(e),await Fe(e),await oe(e),await Zn(e)),e.tab==="chat"&&(await Vt(e),F(e,!e.chatHasAutoScrolled),e.loadSessionResources?.()),e.tab==="trust"){const t=e,n=[];typeof t.handleTrustLoad=="function"&&n.push(t.handleTrustLoad()),n.push(qi(t)),n.push(K(t)),await Promise.all(n)}if(e.tab==="guardrails"){const t=e;typeof t.handleGuardrailsLoad=="function"&&await t.handleGuardrailsLoad()}if(e.tab==="setup"){const t=e;typeof t.handleLoadCapabilities=="function"&&t.handleLoadCapabilities()}if(e.tab==="dashboards"){const t=e;typeof t.handleDashboardsRefresh=="function"&&await t.handleDashboardsRefresh()}if(e.tab==="memory"||e.tab==="second-brain"){const t=e;typeof t.handleSecondBrainRefresh=="function"&&await t.handleSecondBrainRefresh()}if(e.tab==="config"&&(await es(e),await oe(e)),e.tab==="debug"&&(await Ue(e),e.eventLog=Gs()),e.tab==="logs"&&(e.logsAtBottom=!0,await kt(e,{reset:!0}),xt(e,!0)),as(e.tab)){const t=e,n=(t.customTabs??[]).find(s=>s.slug===e.tab);if(n){const{fetchCustomTabData:s}=await _(async()=>{const{fetchCustomTabData:i}=await Promise.resolve().then(()=>ii);return{fetchCustomTabData:i}},void 0,import.meta.url);await s(t,n)}}}function Rl(){if(typeof window>"u")return"";const e=window.__OPENCLAW_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?is(e):ka(window.location.pathname)}function El(e){e.theme=e.settings.theme??"system",ze(e,Wt(e.theme))}function ze(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t==="dark"?"dark":"light",t==="lifetrack"?oi():ri()}function Dl(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&ze(e,n.matches?"dark":"lifetrack")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Ol(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function Mn(e,t){if(typeof window>"u")return;const n=ss(window.location.pathname,e.basePath)??"chat";ci(e,n),di(e,n,t)}function Kl(e){if(typeof window>"u")return;const t=ss(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();if(s){e.sessionKey=s;const i=e.settings.openTabs.includes(s)?e.settings.openTabs:[...e.settings.openTabs,s];Q(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s,openTabs:i})}ci(e,t)}function ci(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="nodes"?Ot(e):Kt(e),t==="logs"?Nt(e):Ft(e),t==="debug"?Ut(e):Bt(e),e.connected&&Ve(e)}function di(e,t,n){if(typeof window>"u")return;const s=nn(Ct(t,e.basePath)),i=nn(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function z(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function ui(e){await Promise.all([V(e,!1),$t(e),K(e),Jn(e),Ue(e)])}async function Nl(e){await Promise.all([V(e,!0),es(e),oe(e)])}async function qt(e){await Promise.all([V(e,!1),Jn(e),Wi(e)])}function Oe(e){return e.chatSending||!!e.chatRunId}function te(e,t){const n=t??e.sessionKey,s=e.chatMessage.trim();if(s)e.chatDrafts={...e.chatDrafts,[n]:s};else{const{[n]:i,...a}=e.chatDrafts;e.chatDrafts=a}}function ie(e,t){const n=t??e.sessionKey;e.chatMessage=e.chatDrafts[n]??""}function hi(e,t){const n=e.sessionKey,{[n]:s,...i}=e.chatDrafts;e.chatDrafts=i,n===e.sessionKey&&(e.chatMessage="")}function pi(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}function Fl(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/new"||n==="/reset"?!0:n.startsWith("/new ")||n.startsWith("/reset ")}async function jt(e){e.connected&&(e.chatMessage="",await Dt(e))}function Ul(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);if(!s&&!i)return;const a=Date.now();e.chatQueue=[...e.chatQueue,{id:je(),text:s,createdAt:a,attachments:i?n?.map(l=>({...l})):void 0}];const o=[];if(s&&o.push({type:"text",text:s}),i&&n)for(const l of n)o.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],F(e,!0)}async function St(e,t,n){Pt(e);const s=e;s.sessionKey&&s.workingSessions&&(s.workingSessions=new Set([...s.workingSessions,s.sessionKey])),n?.skipOptimisticUpdate||queueMicrotask(()=>{F(e,!0)});const i=await Rs(e,t,n?.attachments,{skipOptimisticUpdate:n?.skipOptimisticUpdate});return!i&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!i&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),i&&(li(e,e.sessionKey),e.chatAttachments=[]),i&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),i&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),F(e,!0),i&&!e.chatRunId&&Ht(e),i&&n?.refreshSessions&&(e.refreshSessionsAfterChat=!0),i}async function Ht(e){if(!e.connected||Oe(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await St(e,t.text,{attachments:t.attachments,skipOptimisticUpdate:!0})||(e.chatQueue=[t,...e.chatQueue])}function mi(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function fi(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],l=o.length>0;if(!i&&!l)return;if(pi(i)){await jt(e);return}const c=Fl(i);if(t==null&&(e.chatMessage="",hi(e)),n?.queue){Ul(e,i,o),Oe(e)||await Ht(e);return}if(Oe(e)){await Dt(e),await new Promise(f=>setTimeout(f,50)),await St(e,i,{attachments:l?o:void 0,refreshSessions:c});return}await St(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft),refreshSessions:c})}async function Vt(e){await Promise.all([N(e),K(e,{activeMinutes:0}),Ke(e)]),F(e,!0)}const gi=Ht;function Bl(e){const t=cs(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Wl(e,t){const n=is(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ke(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Bl(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Wl(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const ql=Object.freeze(Object.defineProperty({__proto__:null,clearDraft:hi,flushChatQueueForEvent:gi,handleAbortChat:jt,handleSendChat:fi,isChatBusy:Oe,isChatStopCommand:pi,refreshChat:Vt,refreshChatAvatar:Ke,removeQueuedMessage:mi,restoreDraft:ie,saveDraft:te},Symbol.toStringTag,{value:"Module"})),jl={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Hl={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:""};function yi(e){return new Date(e).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Vl(e,t){const n=Rt(e),s=qe(n.role);if(s==="system")return null;if(s==="tool"){const l=[];for(const c of n.content)if(c.name&&l.push(`**Tool:** ${c.name}`),c.text){const f=c.text.length>2e3?c.text.slice(0,2e3)+`
|
|
264
264
|
|
|
265
|
-
... (truncated)`:c.text;l.push(
|
|
265
|
+
... (truncated)`:c.text;l.push(f)}return l.length===0?null:`<details>
|
|
266
266
|
<summary>Tool result</summary>
|
|
267
267
|
|
|
268
268
|
${l.join(`
|
|
269
269
|
|
|
270
270
|
`)}
|
|
271
271
|
|
|
272
|
-
</details>`}const i=s==="user"||n.role==="User"?"User":t,a=[];for(const l of n.content)if(l.type==="text"&&l.text)a.push(l.text);else if(l.type==="tool_call"&&l.name){const c=l.args?`\`${JSON.stringify(l.args).slice(0,200)}\``:"";a.push(`> **Called tool:** \`${l.name}\` ${c}`)}if(a.length===0)return null;const o=
|
|
272
|
+
</details>`}const i=s==="user"||n.role==="User"?"User":t,a=[];for(const l of n.content)if(l.type==="text"&&l.text)a.push(l.text);else if(l.type==="tool_call"&&l.name){const c=l.args?`\`${JSON.stringify(l.args).slice(0,200)}\``:"";a.push(`> **Called tool:** \`${l.name}\` ${c}`)}if(a.length===0)return null;const o=yi(n.timestamp);return`## ${i}
|
|
273
273
|
_${o}_
|
|
274
274
|
|
|
275
275
|
${a.join(`
|
|
276
276
|
|
|
277
|
-
`)}`}function
|
|
277
|
+
`)}`}function zl(){const e=new Date,t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function Gl(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").replace(/-+/g,"-").slice(0,60)}function Ql(e,t,n){if(!e||e.length===0)return;const s=n||"Assistant",i=[];i.push("# Conversation Export"),i.push(`**Session:** \`${t}\` `),i.push(`**Exported:** ${yi(Date.now())} `),i.push(`**Assistant:** ${s}`),i.push("---");for(const f of e){const r=Vl(f,s);r&&i.push(r)}const a=i.join(`
|
|
278
278
|
|
|
279
279
|
`)+`
|
|
280
|
-
`,o=new Blob([a],{type:"text/markdown;charset=utf-8"}),l=URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=`session-${
|
|
280
|
+
`,o=new Blob([a],{type:"text/markdown;charset=utf-8"}),l=URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=`session-${Gl(t)}-${zl()}.md`,document.body.appendChild(c),c.click(),requestAnimationFrame(()=>{document.body.removeChild(c),URL.revokeObjectURL(l)})}function zt(){requestAnimationFrame(()=>{document.querySelector(".session-tab--active")?.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})})}function Yl(){requestAnimationFrame(()=>{document.querySelector(".chat-compose__textarea")?.focus()})}function Gt(e){te(e);const n=`agent:main:webchat-${je().slice(0,8)}`;e.applySettings({...e.settings,openTabs:[...e.settings.openTabs,n],sessionKey:n,lastActiveSessionKey:n,tabLastViewed:{...e.settings.tabLastViewed,[n]:Date.now()}}),e.sessionKey=n,e.chatMessage="",e.chatMessages=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,gs(),e.resetToolStream(),e.resetChatScroll(),e.loadAssistantIdentity(),z(e,n),N(e),zt(),Yl()}function _t(e,t){if($a.has(t))return Jl(e,t);const n=Ct(t,e.basePath);return d`
|
|
281
281
|
<a
|
|
282
282
|
href=${n}
|
|
283
283
|
class="nav-item ${e.tab===t?"active":""}"
|
|
284
284
|
role="tab"
|
|
285
285
|
aria-selected=${e.tab===t?"true":"false"}
|
|
286
|
-
aria-label=${
|
|
286
|
+
aria-label=${Z(t)}
|
|
287
287
|
@click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t),e.closeNavDrawer())}}
|
|
288
|
-
title=${
|
|
288
|
+
title=${Z(t)}
|
|
289
289
|
>
|
|
290
|
-
<span class="nav-item__emoji" aria-hidden="true">${
|
|
291
|
-
<span class="nav-item__text">${
|
|
290
|
+
<span class="nav-item__emoji" aria-hidden="true">${os(t)}</span>
|
|
291
|
+
<span class="nav-item__text">${Z(t)}</span>
|
|
292
292
|
</a>
|
|
293
|
-
`}function
|
|
293
|
+
`}function Jl(e,t){return d`
|
|
294
294
|
<a
|
|
295
295
|
href="#"
|
|
296
296
|
class="nav-item nav-item--external"
|
|
297
297
|
@click=${async n=>{if(n.preventDefault(),e.closeNavDrawer(),t==="team")try{const s=await e.client?.request("paperclip.dashboardUrl",{});s?.ready&&s.url?window.open(s.url,"_blank","noopener"):window.alert("Paperclip is not configured yet. Set PAPERCLIP_URL in your .env file to connect your AI team.")}catch{window.alert("Could not reach Paperclip. Check your connection and PAPERCLIP_URL setting.")}}}
|
|
298
|
-
title="${
|
|
298
|
+
title="${Z(t)} (opens in new tab)"
|
|
299
299
|
>
|
|
300
|
-
<span class="nav-item__emoji" aria-hidden="true">${
|
|
301
|
-
<span class="nav-item__text">${
|
|
300
|
+
<span class="nav-item__emoji" aria-hidden="true">${os(t)}</span>
|
|
301
|
+
<span class="nav-item__text">${Z(t)}</span>
|
|
302
302
|
<span class="nav-item__external-icon" aria-hidden="true">\u2197\uFE0F</span>
|
|
303
303
|
</a>
|
|
304
|
-
`}function
|
|
304
|
+
`}function vi(e){const t=e.onboarding,n=e.onboarding,s=e.onboarding?!1:e.settings.chatShowThinking,i=e.onboarding?!0:e.settings.chatFocusMode,a=d`
|
|
305
305
|
<svg
|
|
306
306
|
width="18"
|
|
307
307
|
height="18"
|
|
@@ -365,7 +365,7 @@ ${a.join(`
|
|
|
365
365
|
<!-- New session button -->
|
|
366
366
|
<button
|
|
367
367
|
class="chat-toolbar__btn"
|
|
368
|
-
@click=${()=>
|
|
368
|
+
@click=${()=>Gt(e)}
|
|
369
369
|
title="Start a new session (⌘⇧P)"
|
|
370
370
|
aria-label="New session"
|
|
371
371
|
>
|
|
@@ -375,34 +375,34 @@ ${a.join(`
|
|
|
375
375
|
<div class="session-picker-container">
|
|
376
376
|
<button
|
|
377
377
|
class="chat-toolbar__btn ${e.sessionPickerOpen?"active":""}"
|
|
378
|
-
@click=${
|
|
378
|
+
@click=${f=>{const p=f.currentTarget.getBoundingClientRect();e.sessionPickerPosition={top:p.bottom+8,right:window.innerWidth-p.right},e.sessionPickerOpen||K(e),e.handleToggleSessionPicker()}}
|
|
379
379
|
title="Open sessions"
|
|
380
380
|
aria-label="Open sessions"
|
|
381
381
|
aria-expanded=${e.sessionPickerOpen}
|
|
382
382
|
>
|
|
383
383
|
${$.folderOpen}
|
|
384
384
|
</button>
|
|
385
|
-
${e.sessionPickerOpen?
|
|
385
|
+
${e.sessionPickerOpen?ec(e):v}
|
|
386
386
|
</div>
|
|
387
387
|
<!-- Session search -->
|
|
388
388
|
<div class="session-search-container">
|
|
389
389
|
<button
|
|
390
390
|
class="chat-toolbar__btn ${e.sessionSearchOpen?"active":""}"
|
|
391
|
-
@click=${
|
|
391
|
+
@click=${f=>e.handleToggleSessionSearch(f)}
|
|
392
392
|
title="Search sessions"
|
|
393
393
|
aria-label="Search session contents"
|
|
394
394
|
aria-expanded=${e.sessionSearchOpen}
|
|
395
395
|
>
|
|
396
396
|
${c}
|
|
397
397
|
</button>
|
|
398
|
-
${e.sessionSearchOpen?
|
|
398
|
+
${e.sessionSearchOpen?Zl(e):v}
|
|
399
399
|
</div>
|
|
400
400
|
<span class="chat-toolbar__separator"></span>
|
|
401
401
|
<!-- Refresh button -->
|
|
402
402
|
<button
|
|
403
403
|
class="chat-toolbar__btn"
|
|
404
404
|
?disabled=${e.chatLoading||!e.connected}
|
|
405
|
-
@click=${()=>{e.resetToolStream(),
|
|
405
|
+
@click=${()=>{e.resetToolStream(),Vt(e)}}
|
|
406
406
|
title="Refresh chat data"
|
|
407
407
|
aria-label="Refresh chat data"
|
|
408
408
|
>
|
|
@@ -460,7 +460,7 @@ Click any file reference in the chat to open it here.`,{title:"Sidebar",mimeType
|
|
|
460
460
|
<button
|
|
461
461
|
class="chat-toolbar__btn"
|
|
462
462
|
?disabled=${!e.chatMessages||e.chatMessages.length===0}
|
|
463
|
-
@click=${()=>{
|
|
463
|
+
@click=${()=>{Ql(e.chatMessages,e.sessionKey,e.assistantName)}}
|
|
464
464
|
title="Export conversation as markdown"
|
|
465
465
|
aria-label="Export conversation as markdown"
|
|
466
466
|
>
|
|
@@ -471,7 +471,7 @@ Click any file reference in the chat to open it here.`,{title:"Sidebar",mimeType
|
|
|
471
471
|
</svg>
|
|
472
472
|
</button>
|
|
473
473
|
</div>
|
|
474
|
-
`}function
|
|
474
|
+
`}function Xl(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),s=new Date(n.getTime()-864e5);return{today:e.filter(i=>i.updatedAt&&new Date(i.updatedAt)>=n),yesterday:e.filter(i=>i.updatedAt&&new Date(i.updatedAt)>=s&&new Date(i.updatedAt)<n),older:e.filter(i=>!i.updatedAt||new Date(i.updatedAt)<s)}}let nt=null;function Zl(e){if(!e.client||!e.connected)return d`
|
|
475
475
|
<div
|
|
476
476
|
class="session-search-dropdown"
|
|
477
477
|
style="top: ${e.sessionSearchPosition?.top??0}px; right: ${e.sessionSearchPosition?.right??0}px;"
|
|
@@ -480,7 +480,7 @@ Click any file reference in the chat to open it here.`,{title:"Sidebar",mimeType
|
|
|
480
480
|
<div class="session-search-empty">Not connected</div>
|
|
481
481
|
</div>
|
|
482
482
|
</div>
|
|
483
|
-
`;const t=i=>{const a=i.target.value;e.sessionSearchQuery=a,
|
|
483
|
+
`;const t=i=>{const a=i.target.value;e.sessionSearchQuery=a,nt&&clearTimeout(nt),nt=setTimeout(()=>{e.handleSessionSearchQuery(a)},300)},n=i=>{e.sessionSearchOpen=!1,e.sessionSearchQuery="",e.sessionSearchResults=[],te(e),e.settings.openTabs.includes(i)?(e.sessionKey=i,e.applySettings({...e.settings,sessionKey:i,lastActiveSessionKey:i,tabLastViewed:{...e.settings.tabLastViewed,[i]:Date.now()}})):(e.applySettings({...e.settings,openTabs:[...e.settings.openTabs,i],sessionKey:i,lastActiveSessionKey:i,tabLastViewed:{...e.settings.tabLastViewed,[i]:Date.now()}}),e.sessionKey=i),ie(e,i),e.chatLoading=!0,e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.loadAssistantIdentity(),z(e,i),N(e).then(()=>{Te(e),F(e,!0)})},s=i=>{const a=i.label??i.displayName??i.key,o=i.matches.length>0;return d`
|
|
484
484
|
<div class="session-search-result" @click=${()=>n(i.key)}>
|
|
485
485
|
<div class="session-search-result__header">
|
|
486
486
|
<span class="session-search-result__name">${a}</span>
|
|
@@ -522,7 +522,7 @@ Click any file reference in the chat to open it here.`,{title:"Sidebar",mimeType
|
|
|
522
522
|
`:e.sessionSearchResults.map(s)}
|
|
523
523
|
</div>
|
|
524
524
|
</div>
|
|
525
|
-
`}function
|
|
525
|
+
`}function ec(e){const t=(e.sessionPickerSearch??"").toLowerCase().trim();if(!e.client||!e.connected)return d`
|
|
526
526
|
<div
|
|
527
527
|
class="session-picker-dropdown"
|
|
528
528
|
style="top: ${e.sessionPickerPosition?.top??0}px; right: ${e.sessionPickerPosition?.right??0}px;"
|
|
@@ -540,16 +540,16 @@ Click any file reference in the chat to open it here.`,{title:"Sidebar",mimeType
|
|
|
540
540
|
<div class="session-picker-empty">Loading sessions...</div>
|
|
541
541
|
</div>
|
|
542
542
|
</div>
|
|
543
|
-
`;let n=(e.sessionsResult?.sessions??[]).filter(g=>!e.settings.openTabs.includes(g.key));t&&(n=n.filter(g=>[g.label,g.displayName,g.key].filter(Boolean).some(b=>b.toLowerCase().includes(t))));const s=50,i=n.length,a=n.slice(0,s),o=
|
|
543
|
+
`;let n=(e.sessionsResult?.sessions??[]).filter(g=>!e.settings.openTabs.includes(g.key));t&&(n=n.filter(g=>[g.label,g.displayName,g.key].filter(Boolean).some(b=>b.toLowerCase().includes(t))));const s=50,i=n.length,a=n.slice(0,s),o=Xl(a),l=g=>{e.sessionPickerOpen=!1,e.sessionPickerSearch="",te(e),e.settings.openTabs.includes(g)?(e.sessionKey=g,e.applySettings({...e.settings,sessionKey:g,lastActiveSessionKey:g,tabLastViewed:{...e.settings.tabLastViewed,[g]:Date.now()}})):(e.applySettings({...e.settings,openTabs:[...e.settings.openTabs,g],sessionKey:g,lastActiveSessionKey:g,tabLastViewed:{...e.settings.tabLastViewed,[g]:Date.now()}}),e.sessionKey=g),ie(e,g),e.chatLoading=!0,e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.loadAssistantIdentity(),z(e,g),N(e).then(()=>{Te(e),F(e,!0)})},c=async(g,y)=>{if(g.stopPropagation(),!!window.confirm(`Delete session "${y}"?
|
|
544
544
|
|
|
545
|
-
Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.filter(
|
|
545
|
+
Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.filter(k=>k.key!==y)}),e.client&&e.connected))try{await e.client.request("sessions.delete",{key:y,deleteTranscript:!0}),K(e)}catch(k){console.error("Failed to delete session:",k),K(e)}},f=g=>d`
|
|
546
546
|
<div class="session-picker-item" @click=${()=>l(g.key)}>
|
|
547
547
|
<span class="session-picker-item__status ${g.isActive?"active":""}"></span>
|
|
548
548
|
<div class="session-picker-item__content">
|
|
549
549
|
<div class="session-picker-item__name">${g.label??g.displayName??se.get(g.key)??g.key}</div>
|
|
550
550
|
</div>
|
|
551
551
|
<div class="session-picker-item__actions">
|
|
552
|
-
${g.updatedAt?d`<span class="session-picker-item__time">${
|
|
552
|
+
${g.updatedAt?d`<span class="session-picker-item__time">${ji(g.updatedAt)}</span>`:v}
|
|
553
553
|
<button
|
|
554
554
|
class="session-picker-item__close"
|
|
555
555
|
@click=${y=>c(y,g.key)}
|
|
@@ -566,7 +566,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
566
566
|
`,r=(g,y)=>y.length===0?v:d`
|
|
567
567
|
<div class="session-picker-group">
|
|
568
568
|
<div class="session-picker-group__header">${g}</div>
|
|
569
|
-
${
|
|
569
|
+
${Be(y,b=>b.key,f)}
|
|
570
570
|
</div>
|
|
571
571
|
`,p=o.today.length+o.yesterday.length+o.older.length;return d`
|
|
572
572
|
<div
|
|
@@ -596,7 +596,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
596
596
|
`}
|
|
597
597
|
</div>
|
|
598
598
|
</div>
|
|
599
|
-
`}const
|
|
599
|
+
`}const tc=["system","light","dark","lifetrack"];function bi(e){const t=Math.max(0,tc.indexOf(e.theme)),n=s=>i=>{const o={element:i.currentTarget};(i.clientX||i.clientY)&&(o.pointerClientX=i.clientX,o.pointerClientY=i.clientY),e.setTheme(s,o)};return d`
|
|
600
600
|
<div class="theme-toggle" style="--theme-index: ${t};">
|
|
601
601
|
<div class="theme-toggle__track" role="group" aria-label="Theme">
|
|
602
602
|
<span class="theme-toggle__indicator"></span>
|
|
@@ -607,7 +607,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
607
607
|
aria-label="System theme"
|
|
608
608
|
title="System"
|
|
609
609
|
>
|
|
610
|
-
${
|
|
610
|
+
${ic()}
|
|
611
611
|
</button>
|
|
612
612
|
<button
|
|
613
613
|
class="theme-toggle__button ${e.theme==="light"?"active":""}"
|
|
@@ -616,7 +616,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
616
616
|
aria-label="Light theme"
|
|
617
617
|
title="Light"
|
|
618
618
|
>
|
|
619
|
-
${
|
|
619
|
+
${nc()}
|
|
620
620
|
</button>
|
|
621
621
|
<button
|
|
622
622
|
class="theme-toggle__button ${e.theme==="dark"?"active":""}"
|
|
@@ -625,7 +625,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
625
625
|
aria-label="Dark theme"
|
|
626
626
|
title="Dark"
|
|
627
627
|
>
|
|
628
|
-
${
|
|
628
|
+
${sc()}
|
|
629
629
|
</button>
|
|
630
630
|
<button
|
|
631
631
|
class="theme-toggle__button ${e.theme==="lifetrack"?"active":""}"
|
|
@@ -634,11 +634,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
634
634
|
aria-label="Lifetrack theme"
|
|
635
635
|
title="Lifetrack"
|
|
636
636
|
>
|
|
637
|
-
${
|
|
637
|
+
${ac()}
|
|
638
638
|
</button>
|
|
639
639
|
</div>
|
|
640
640
|
</div>
|
|
641
|
-
`}function
|
|
641
|
+
`}function nc(){return d`
|
|
642
642
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
643
643
|
<circle cx="12" cy="12" r="4"></circle>
|
|
644
644
|
<path d="M12 2v2"></path>
|
|
@@ -650,26 +650,26 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
650
650
|
<path d="m6.34 17.66-1.41 1.41"></path>
|
|
651
651
|
<path d="m19.07 4.93-1.41 1.41"></path>
|
|
652
652
|
</svg>
|
|
653
|
-
`}function
|
|
653
|
+
`}function sc(){return d`
|
|
654
654
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
655
655
|
<path
|
|
656
656
|
d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"
|
|
657
657
|
></path>
|
|
658
658
|
</svg>
|
|
659
|
-
`}function
|
|
659
|
+
`}function ic(){return d`
|
|
660
660
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
661
661
|
<rect width="20" height="14" x="2" y="3" rx="2"></rect>
|
|
662
662
|
<line x1="8" x2="16" y1="21" y2="21"></line>
|
|
663
663
|
<line x1="12" x2="12" y1="17" y2="21"></line>
|
|
664
664
|
</svg>
|
|
665
|
-
`}function
|
|
665
|
+
`}function ac(){return d`
|
|
666
666
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
667
667
|
<path d="M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"></path>
|
|
668
668
|
<path d="M19 15l.67 2.33L22 18l-2.33.67L19 21l-.67-2.33L16 18l2.33-.67L19 15z"></path>
|
|
669
669
|
</svg>
|
|
670
|
-
`}const
|
|
670
|
+
`}const st=Object.freeze(Object.defineProperty({__proto__:null,createNewSession:Gt,renderChatControls:vi,renderTab:_t,renderThemeToggle:bi,scrollActiveTabIntoView:zt},Symbol.toStringTag,{value:"Module"})),it=new Set;function In(e){if(!(!e.connected||!e.client||!e.settings.chatParallelView))for(const t of e.settings.parallelLanes){const n=t?.trim();if(!n)continue;const i=ae(e.sessionsResult?.sessions,n)?.key??n;if(ee.has(n)||ee.has(i)||it.has(i))continue;it.add(i);const o=e.client;Ms(o,i).then(l=>{i!==n&&l.length>0&&ee.set(n,l)}).finally(()=>{it.delete(i),e.applySettings({...e.settings})})}}function oc(e){e.basePath=Rl(),e._urlSettingsApplied||(Ll(e),e._urlSettingsApplied=!0),Mn(e,!0),El(e),Dl(e),window.addEventListener("popstate",e.popStateHandler),e.keydownHandler=t=>{if(t.altKey&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey){const a=parseInt(t.key,10);if(a>=1&&a<=6){const l=["chat","today","team","workspaces","memory","dashboards"][a-1];l&&e.tab!==l&&(t.preventDefault(),e.tab=l,Mn(e,!0));return}}if(e.tab!=="chat")return;if((t.metaKey||t.ctrlKey)&&t.shiftKey&&t.key.toLowerCase()==="p"){t.preventDefault(),Gt(e);return}if(!t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.key<"1"||t.key>"9")return;const n=parseInt(t.key,10)-1,s=e.settings.openTabs;if(n>=s.length)return;const i=s[n];i!==e.sessionKey&&(t.preventDefault(),te(e),e.sessionKey=i,ie(e,i),e.chatLoading=!0,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:i,lastActiveSessionKey:i,tabLastViewed:{...e.settings.tabLastViewed,[i]:Date.now()}}),e.loadAssistantIdentity(),z(e,i),N(e).then(()=>{_e(e)}))},window.addEventListener("keydown",e.keydownHandler),He(e),e.tab==="nodes"&&Ot(e),e.tab==="logs"&&Nt(e),e.tab==="debug"&&Ut(e)}function rc(e){ms(e)}function lc(e){window.removeEventListener("popstate",e.popStateHandler),window.removeEventListener("keydown",e.keydownHandler),e.sessionPickerClickOutsideHandler&&(document.removeEventListener("click",e.sessionPickerClickOutsideHandler,!0),e.sessionPickerClickOutsideHandler=null),e.sessionSearchClickOutsideHandler&&(document.removeEventListener("click",e.sessionSearchClickOutsideHandler,!0),e.sessionSearchClickOutsideHandler=null),Kt(e),Ft(e),Bt(e),Ol(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function ae(e,t){if(!e||!t)return;const n=e.find(o=>o.key===t);if(n)return n;const s=t.split(":"),i=s[s.length-1];if(i&&i.length>=4){const o=e.find(l=>l.key===i||l.key.endsWith(`:${i}`));if(o)return o}const a=t.replace(/^webchat:/,"");if(a!==t){const o=e.find(l=>l.key.endsWith(a)||l.key.endsWith(`:${a}`));if(o)return o}}function cc(e,t){if(!t||t.length===0)return;const n=c=>{const f=c.toLowerCase();return f==="main"||f==="agent:main:main"||f.endsWith(":main")},s=(c,f)=>{const r=c?.sessionId?.trim();if(r)return`session:${r}`;if(c){const g=[c.kind,c.surface,c.subject,c.room,c.space,c.label,c.displayName].map(y=>String(y??"").trim().toLowerCase()).join("|");if(g.replace(/\|/g,"").length>0)return`meta:${g}`}return`key:${f}`};let i=!1;const a=new Map,o=[];for(const c of e.settings.openTabs){const f=c.trim();if(!f){i=!0;continue}if(n(f)){i=!0;continue}const r=ae(t,f),p=r?.key??f;p!==c&&(i=!0);const g=s(r,p);if(a.has(g)){i=!0;continue}a.set(g,p),o.push(p)}const l=o.length!==e.settings.openTabs.length;if(i||l){const c={};for(const[b,k]of Object.entries(e.settings.tabLastViewed)){const P=b.trim();if(!P||typeof k!="number"||!Number.isFinite(k))continue;const U=ae(t,P),C=s(U,U?.key??P),D=a.get(C)??U?.key??P;c[D]=Math.max(c[D]??0,k)}const f=ae(t,e.sessionKey),r=s(f,f?.key??e.sessionKey.trim()),p=a.get(r)??f?.key??(e.sessionKey.trim()||o[0]||"main"),y=p==="main"||p.endsWith(":main")||o.includes(p)?p:o[0]||"main";e.applySettings({...e.settings,openTabs:o,sessionKey:y,lastActiveSessionKey:y,tabLastViewed:c}),e.sessionKey!==y&&(e.sessionKey=y)}}function dc(e,t){if((t.has("sessionsResult")||t.has("settings"))&&e.sessionsResult?.sessions&&cc(e,e.sessionsResult.sessions),t.has("connected")&&t.get("connected")===!1&&e.connected&&e.settings.chatParallelView&&In(e),t.has("settings")&&e.connected&&e.settings.chatParallelView){const n=t.get("settings"),s=n?!n.chatParallelView:!0,i=!n||n.parallelLanes.some((a,o)=>a!==e.settings.parallelLanes[o]);(s||i)&&In(e)}if(t.has("sessionPickerOpen")&&(e.sessionPickerOpen?setTimeout(()=>{e.sessionPickerOpen&&(e.sessionPickerClickOutsideHandler=n=>{const s=n.target,i=s.closest(".session-picker-container"),a=s.closest(".session-picker-dropdown");!i&&!a&&(e.sessionPickerOpen=!1)},document.addEventListener("click",e.sessionPickerClickOutsideHandler,!0))},0):e.sessionPickerClickOutsideHandler&&(document.removeEventListener("click",e.sessionPickerClickOutsideHandler,!0),e.sessionPickerClickOutsideHandler=null)),t.has("sessionSearchOpen")&&(e.sessionSearchOpen?setTimeout(()=>{e.sessionSearchOpen&&(e.sessionSearchClickOutsideHandler=n=>{const s=n.target,i=s.closest(".session-search-container"),a=s.closest(".session-search-dropdown");!i&&!a&&(e.sessionSearchOpen=!1)},document.addEventListener("click",e.sessionSearchClickOutsideHandler,!0))},0):e.sessionSearchClickOutsideHandler&&(document.removeEventListener("click",e.sessionSearchClickOutsideHandler,!0),e.sessionSearchClickOutsideHandler=null)),t.has("connected")&&t.get("connected")===!1&&e.connected&&e.tab==="chat"&&!e.chatLoading&&setTimeout(()=>{const n=e;n.tab==="chat"&&!n.chatLoading&&N(n).then(()=>{_e(e)})},500),t.has("connected")&&t.get("connected")===!1&&e.connected&&e.tab!=="chat"&&Ve(e),e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("sessionKey")||t.has("tab"))){const n=t.has("tab"),s=t.has("sessionKey"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&!e.chatLoading;let a=!1;if(t.has("chatMessages")){const o=e.chatMessages;o[o.length-1]?.role==="user"&&(a=!0)}t.has("chatStream")&&(a=!1),(n||s||i)&&Te(e),F(e,n||s||i||a||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&xt(e,t.has("tab")||t.has("logsAutoFollow"))}function Rn(e,t){const n=t.split(".");let s=e;for(const i of n){if(s==null||typeof s!="object")return;s=s[i]}return s}function ce(e,t){if(typeof e!="string")return e;const n=/^\{\{([^}]+)\}\}$/.exec(e);return n?Rn(t,n[1].trim()):e.replace(/\{\{([^}]+)\}\}/g,(s,i)=>{const a=Rn(t,i.trim());return a==null?"":String(a)})}function Qt(e,t){const n={};for(const[s,i]of Object.entries(e))typeof i=="string"?n[s]=ce(i,t):i&&typeof i=="object"&&!Array.isArray(i)?n[s]=Qt(i,t):n[s]=i;return n}function uc(e,t){if(e==null)return"—";if(t==="currency"){const n=Number(e);return isNaN(n)?String(e):`$${n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}if(t==="number"){const n=Number(e);return isNaN(n)?String(e):n.toLocaleString()}if(t==="percent"){const n=Number(e);return isNaN(n)?String(e):`${(n*100).toFixed(1)}%`}return String(e)}function hc(e,t){const n=e.columns??3,s=ce(e.items,t),i=Array.isArray(s)?s:[],a=e.itemTemplate;return i.length===0?d`<div class="custom-tab__empty">No data to display.</div>`:d`
|
|
671
671
|
<div class="custom-tab__cards" style="grid-template-columns: repeat(${n}, 1fr);">
|
|
672
|
-
${i.map(o=>{const l={...t,item:o},c=a?
|
|
672
|
+
${i.map(o=>{const l={...t,item:o},c=a?Qt(a,l):o;return d`
|
|
673
673
|
<div class="custom-tab__card">
|
|
674
674
|
${c.title?d`<div class="custom-tab__card-title">${c.title}</div>`:v}
|
|
675
675
|
${c.subtitle?d`<div class="custom-tab__card-subtitle">${c.subtitle}</div>`:v}
|
|
@@ -678,7 +678,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
678
678
|
</div>
|
|
679
679
|
`})}
|
|
680
680
|
</div>
|
|
681
|
-
`}function
|
|
681
|
+
`}function pc(e,t){const n=ce(e.items,t),s=Array.isArray(n)?n:[];if(s.length===0)return d`<div class="custom-tab__empty">No data to display.</div>`;const i=s[0],a=Object.keys(i);return d`
|
|
682
682
|
<div class="custom-tab__table-wrapper">
|
|
683
683
|
<table class="custom-tab__table">
|
|
684
684
|
<thead>
|
|
@@ -695,34 +695,34 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
695
695
|
</tbody>
|
|
696
696
|
</table>
|
|
697
697
|
</div>
|
|
698
|
-
`}function
|
|
698
|
+
`}function mc(e,t){const n=ce(e.items,t),s=Array.isArray(n)?n:[],i=e.itemTemplate;return s.length===0?d`<div class="custom-tab__empty">No data to display.</div>`:d`
|
|
699
699
|
<div class="custom-tab__list">
|
|
700
|
-
${s.map(a=>{const o={...t,item:a},l=i?
|
|
700
|
+
${s.map(a=>{const o={...t,item:a},l=i?Qt(i,o):a;return d`
|
|
701
701
|
<div class="custom-tab__list-item">
|
|
702
702
|
${l.title?d`<div class="custom-tab__list-title">${l.title}</div>`:v}
|
|
703
703
|
${l.subtitle?d`<div class="custom-tab__list-subtitle">${l.subtitle}</div>`:v}
|
|
704
704
|
</div>
|
|
705
705
|
`})}
|
|
706
706
|
</div>
|
|
707
|
-
`}function
|
|
707
|
+
`}function fc(e,t){const n=e.columns??3,s=e.items,i=Array.isArray(s)?s:[];return i.length===0?d`<div class="custom-tab__empty">No stats to display.</div>`:d`
|
|
708
708
|
<div class="custom-tab__stat-grid" style="grid-template-columns: repeat(${n}, 1fr);">
|
|
709
|
-
${i.map(a=>{const o=a,l=ce(o.label,t),c=ce(o.value,t),
|
|
709
|
+
${i.map(a=>{const o=a,l=ce(o.label,t),c=ce(o.value,t),f=typeof o.format=="string"?o.format:void 0;return d`
|
|
710
710
|
<div class="custom-tab__stat">
|
|
711
|
-
<div class="custom-tab__stat-value">${
|
|
711
|
+
<div class="custom-tab__stat-value">${uc(c,f)}</div>
|
|
712
712
|
<div class="custom-tab__stat-label">${l??""}</div>
|
|
713
713
|
</div>
|
|
714
714
|
`})}
|
|
715
715
|
</div>
|
|
716
|
-
`}function
|
|
716
|
+
`}function gc(e,t){const n=ce(e.items,t),s=typeof n=="string"?n:"";if(!s)return d`<div class="custom-tab__empty">No content to display.</div>`;const i=s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\n/g,"<br>");return d`
|
|
717
717
|
<div class="custom-tab__markdown">
|
|
718
718
|
${re(i)}
|
|
719
719
|
</div>
|
|
720
|
-
`}function
|
|
720
|
+
`}function yc(){return d`
|
|
721
721
|
<div class="custom-tab__empty">
|
|
722
722
|
<p>Iframe layout support coming soon.</p>
|
|
723
723
|
<p style="opacity: 0.6; font-size: 13px;">Sandboxed iframe rendering will be available in a future update.</p>
|
|
724
724
|
</div>
|
|
725
|
-
`}function
|
|
725
|
+
`}function vc(e){const t=Object.entries(e);return t.length===0?d``:d`
|
|
726
726
|
<div class="custom-tab__errors">
|
|
727
727
|
${t.map(([n,s])=>d`
|
|
728
728
|
<div class="custom-tab__error">
|
|
@@ -730,7 +730,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
730
730
|
</div>
|
|
731
731
|
`)}
|
|
732
732
|
</div>
|
|
733
|
-
`}function
|
|
733
|
+
`}function bc(e){const{manifest:t,data:n,loading:s,errors:i}=e;if(s)return d`
|
|
734
734
|
<div class="tab-view custom-tab">
|
|
735
735
|
<header class="tab-header">
|
|
736
736
|
<h2>${t.title}</h2>
|
|
@@ -738,7 +738,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
738
738
|
</header>
|
|
739
739
|
<div class="custom-tab__loading">Loading data...</div>
|
|
740
740
|
</div>
|
|
741
|
-
`;const a={...n};let o;switch(t.layout.type){case"cards":o=
|
|
741
|
+
`;const a={...n};let o;switch(t.layout.type){case"cards":o=hc(t.layout,a);break;case"table":o=pc(t.layout,a);break;case"list":o=mc(t.layout,a);break;case"stat-grid":o=fc(t.layout,a);break;case"markdown":o=gc(t.layout,a);break;case"iframe":o=yc();break;default:o=d`
|
|
742
742
|
<div class="custom-tab__empty">
|
|
743
743
|
Unsupported layout type: "${t.layout.type}". This tab may require a newer version of GodMode.
|
|
744
744
|
</div>
|
|
@@ -748,23 +748,23 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
748
748
|
<h2>${t.title}</h2>
|
|
749
749
|
${t.subtitle?d`<p class="tab-subtitle">${t.subtitle}</p>`:v}
|
|
750
750
|
</header>
|
|
751
|
-
${
|
|
751
|
+
${vc(i)}
|
|
752
752
|
${o}
|
|
753
753
|
</div>
|
|
754
|
-
`}function
|
|
755
|
-
`):""}const
|
|
754
|
+
`}function wc(e){return typeof e.content=="string"?e.content:typeof e.text=="string"?e.text:Array.isArray(e.content)?e.content.map(t=>typeof t.text=="string"?t.text:"").join(`
|
|
755
|
+
`):""}const Sc=["persistence protocol","core principles:","core behaviors","your role as ","be diligent first time","exhaust reasonable options","assume capability exists","elite executive assistant","consciousness context","working context","enforcement:","internal system context injected by godmode"];function _c(e){const t=typeof e.role=="string"?e.role.toLowerCase():"";if(t!=="user"&&t!=="system")return!1;const n=wc(e).trim();if(!n)return!1;let s=n;if((n.includes("<system-context")||n.includes("<godmode-context"))&&(s=n.replace(/<system-context[\s\S]*?<\/system-context>/gi,"").replace(/<godmode-context[\s\S]*?<\/godmode-context>/gi,"").trim(),!s)||s.startsWith("Read HEARTBEAT.md")||s.startsWith("Read CONSCIOUSNESS.md")||s.startsWith("Pre-compaction memory flush")||s.startsWith("pre-compaction memory flush")||/^System:\s*\[\d{4}-\d{2}-\d{2}/.test(s)||s==="NO_REPLY"||s.startsWith(`NO_REPLY
|
|
756
756
|
`)||/^#\s*(?:🧠|\w+ Consciousness)/i.test(s)||s.startsWith("# WORKING.md")||s.startsWith("# MISTAKES.md")||/(?:VERIFIED|FIXED|NEW):\s/.test(s)&&/✅|🟡|☑/.test(s)&&s.length>300||/^###\s*(?:Onboarding Philosophy|Self-Surgery Problem|Open Architecture)/i.test(s)||/^\[GodMode Context:[^\]]*\]\s*$/.test(s)||/^You are resourceful and thorough\.\s*Your job is to GET THE JOB DONE/i.test(s)||/^##?\s*Persistence Protocol/i.test(s)||/^##?\s*Core (?:Behaviors|Principles)/i.test(s)||/^##?\s*Your Role as \w+/i.test(s)||/^##\s*Your Team\s*\(Agent Roster\)/i.test(s)&&s.indexOf(`
|
|
757
757
|
|
|
758
|
-
## `)===-1||/^\w+\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(s)&&s.length>200||/^(?:ID\s+START\s+END\s+SUMMARY)/i.test(s))return!0;const i=s.toLowerCase();return
|
|
758
|
+
## `)===-1||/^\w+\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(s)&&s.length>200||/^(?:ID\s+START\s+END\s+SUMMARY)/i.test(s))return!0;const i=s.toLowerCase();return Sc.filter(a=>i.includes(a)).length>=2}const En=25*1024*1024,Dn=50*1024*1024,On=20;function at(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Yt(e,t=0){const n=[],s=[];let i=t;const a=Array.from(e);for(const o of a){if(n.length>=On){s.push(`Maximum ${On} files allowed per upload`);break}if(o.size>En){s.push(`"${o.name}" is too large (${at(o.size)}). Max ${at(En)}. For larger files, mention the file path instead.`);continue}if(i+o.size>Dn){s.push(`Total upload size exceeds ${at(Dn)} limit`);break}i+=o.size,n.push(o)}return{validFiles:n,errors:s}}const Tc=new Set(["md","markdown","mdx"]),Ac=new Set(["htm","html"]),kc=new Set(["avif","bmp","gif","heic","heif","jpeg","jpg","png","svg","svgz","webp"]);function wi(e){const t=e.replaceAll("\\","/").trim();if(!t)return e;const n=t.split("/");return n[n.length-1]||t}function $c(e){if(!e)return null;const n=e.trim().toLowerCase().split(".").pop()??"";return n?Tc.has(n)?"text/markdown":Ac.has(n)?"text/html":kc.has(n)?n==="svg"||n==="svgz"?"image/svg+xml":n==="jpg"?"image/jpeg":`image/${n}`:n==="pdf"?"application/pdf":n==="json"||n==="json5"?"application/json":n==="txt"||n==="text"||n==="log"?"text/plain":null:null}function Si(e){const t=e.mimeType?.split(";")[0]?.trim().toLowerCase()??"";if(t)return t;const n=e.content?.trim()??"";if(n.startsWith("data:image/")){const s=/^data:(image\/[^;]+);/i.exec(n);return s?.[1]?s[1].toLowerCase():"image/*"}return $c(e.filePath??null)??"text/markdown"}function Cc(e){if(!e.startsWith("file://"))return null;let t=e.slice(7);return t.startsWith("/~/")&&(t="~"+t.slice(2)),decodeURIComponent(t)}function xc(e,t){if(!t)return;const s=e.target.closest("a");if(!s)return;const i=s.getAttribute("href");if(!i)return;const a=Cc(i);a&&(e.preventDefault(),e.stopPropagation(),t(a))}function Pc(e){if(e.error)return d`
|
|
759
759
|
<div class="callout danger">${e.error}</div>
|
|
760
760
|
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
|
|
761
761
|
View Raw Text
|
|
762
762
|
</button>
|
|
763
763
|
`;if(!e.content)return d`
|
|
764
764
|
<div class="muted">No content available</div>
|
|
765
|
-
`;const t=
|
|
765
|
+
`;const t=Si(e),n=e.content,s=n.trim();if(t.startsWith("image/"))return s.startsWith("data:image/")?d`
|
|
766
766
|
<div class="sidebar-image">
|
|
767
|
-
<img src=${s} alt=${
|
|
767
|
+
<img src=${s} alt=${wi(e.filePath??"Image preview")} />
|
|
768
768
|
</div>
|
|
769
769
|
`:d`
|
|
770
770
|
<div class="callout">
|
|
@@ -786,10 +786,10 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
786
786
|
.srcdoc=${n}
|
|
787
787
|
sandbox="allow-same-origin allow-top-navigation-by-user-activation allow-popups"
|
|
788
788
|
@load=${i=>{const a=i.target;try{const o=a.contentDocument?.documentElement?.scrollHeight;o&&(a.style.height=`${o}px`)}catch{}}}
|
|
789
|
-
></iframe>`;if(t==="text/markdown"||t==="text/x-markdown"){const i=
|
|
789
|
+
></iframe>`;if(t==="text/markdown"||t==="text/x-markdown"){const i=Ca(n);return d`<div
|
|
790
790
|
class="sidebar-markdown"
|
|
791
|
-
@click=${a=>
|
|
792
|
-
>${re(
|
|
791
|
+
@click=${a=>xc(a,e.onOpenFile)}
|
|
792
|
+
>${re(q(i))}</div>`}return d`<pre class="sidebar-plain">${n}</pre>`}function Lc(e){const t=Si(e);return t==="text/html"||t==="application/xhtml+xml"}function Mc(e){const t=new Blob([e],{type:"text/html"}),n=URL.createObjectURL(t);window.open(n,"_blank","noopener,noreferrer")}function Tt(e){const t=e.title?.trim()||"Tool Output",n=Lc(e)&&e.content;return d`
|
|
793
793
|
<div class="sidebar-panel">
|
|
794
794
|
<div class="sidebar-header">
|
|
795
795
|
<div class="sidebar-title-wrap">
|
|
@@ -820,17 +820,17 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
820
820
|
${n?d`<button
|
|
821
821
|
class="btn sidebar-open-browser-btn"
|
|
822
822
|
title="Open in browser tab"
|
|
823
|
-
@click=${()=>
|
|
823
|
+
@click=${()=>Mc(e.content)}
|
|
824
824
|
>Open in Browser</button>`:v}
|
|
825
825
|
<button @click=${e.onClose} class="btn" title="Close sidebar">
|
|
826
826
|
${$.x}
|
|
827
827
|
</button>
|
|
828
828
|
</div>
|
|
829
829
|
</div>
|
|
830
|
-
${
|
|
831
|
-
<div class="sidebar-content">${
|
|
830
|
+
${Ic(e)}
|
|
831
|
+
<div class="sidebar-content">${Pc(e)}</div>
|
|
832
832
|
</div>
|
|
833
|
-
`}function
|
|
833
|
+
`}function Ic(e){if(e.resource)return d`
|
|
834
834
|
<div class="sidebar-resource-bar">
|
|
835
835
|
<span class="resource-type-badge">${e.resource.type.replace("_"," ")}</span>
|
|
836
836
|
<span style="flex: 1;">${e.resource.title}</span>
|
|
@@ -840,14 +840,14 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
840
840
|
@click=${()=>e.onToggleResourcePin?.(e.resource.id,!e.resource.pinned)}
|
|
841
841
|
>${e.resource.pinned?"★":"☆"}</button>
|
|
842
842
|
</div>
|
|
843
|
-
`;if(e.filePath&&e.onSaveAsResource){const t=e.title?.trim()||
|
|
843
|
+
`;if(e.filePath&&e.onSaveAsResource){const t=e.title?.trim()||wi(e.filePath);return d`
|
|
844
844
|
<div class="sidebar-resource-bar">
|
|
845
845
|
<button
|
|
846
846
|
class="sidebar-save-resource-btn"
|
|
847
847
|
@click=${()=>e.onSaveAsResource(e.filePath,t)}
|
|
848
848
|
>Save as Resource</button>
|
|
849
849
|
</div>
|
|
850
|
-
`}return v}function
|
|
850
|
+
`}return v}function Rc(e){return e.charAt(0).toUpperCase()||"A"}function Kn(e){if(!e)return"";const t=new Date(e),n=t.getHours(),s=t.getMinutes().toString().padStart(2,"0"),i=n>=12?"PM":"AM";return`${n%12||12}:${s} ${i}`}function Ec(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,120)}px`}function _i(e,t=80){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ti(e){const t=e.querySelector(".ally-panel__messages");t&&(t.scrollTop=t.scrollHeight)}const Nn=new WeakMap;function Dc(e){requestAnimationFrame(()=>{const t=document.querySelector(".ally-panel, .ally-inline");if(!t)return;const n=t.querySelector(".ally-panel__messages");if(!n)return;const s=Nn.get(n),i=s??{lastMsgCount:0,lastStreamLen:0},a=e.messages.length,o=e.stream?.length??0,l=a!==i.lastMsgCount||o>i.lastStreamLen;Nn.set(n,{lastMsgCount:a,lastStreamLen:o}),l&&(!s||_i(n,120))&&Ti(t)})}function Oc(e){const t=e.currentTarget,n=t.querySelector(".ally-jump-bottom");n&&n.classList.toggle("ally-jump-bottom--visible",!_i(t))}function Kc(e,t){return e.allyAvatar?d`<img class=${"ally-panel__header-avatar"} src=${e.allyAvatar} alt=${e.allyName} />`:d`<span class="ally-panel__header-initial">${Rc(e.allyName)}</span>`}function Fn(e){if(e.role==="assistant"&&e.content){const t=q(e.content);return d`<div class="ally-msg__content chat-text">${re(t)}</div>`}return d`<span class="ally-msg__content">${e.content}</span>`}function Nc(e,t){return!e.actions||e.actions.length===0?v:d`
|
|
851
851
|
<div class="ally-msg__actions">
|
|
852
852
|
${e.actions.map(n=>d`
|
|
853
853
|
<button
|
|
@@ -859,7 +859,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
859
859
|
</button>
|
|
860
860
|
`)}
|
|
861
861
|
</div>
|
|
862
|
-
`}function
|
|
862
|
+
`}function Fc(e,t){return d`
|
|
863
863
|
<div class="hitl-card">
|
|
864
864
|
<div class="hitl-card__header">Checkpoint: ${e.agentName}</div>
|
|
865
865
|
<div class="hitl-card__summary">${e.summary}</div>
|
|
@@ -875,28 +875,28 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
875
875
|
`)}
|
|
876
876
|
</div>
|
|
877
877
|
</div>
|
|
878
|
-
`}function
|
|
878
|
+
`}function Uc(e,t,n,s){if(e.isNotification)return d`
|
|
879
879
|
<div class="ally-msg ally-msg--notification" data-idx=${t}>
|
|
880
|
-
${e.hitlCheckpoint?
|
|
881
|
-
${e.hitlCheckpoint?v:
|
|
882
|
-
${e.timestamp?d`<div class="ally-msg__time">${
|
|
880
|
+
${e.hitlCheckpoint?Fc(e.hitlCheckpoint,s):Fn(e)}
|
|
881
|
+
${e.hitlCheckpoint?v:Nc(e,n)}
|
|
882
|
+
${e.timestamp?d`<div class="ally-msg__time">${Kn(e.timestamp)}</div>`:v}
|
|
883
883
|
</div>
|
|
884
884
|
`;const i=e.role==="user"?"ally-msg--user":"ally-msg--assistant";return d`
|
|
885
885
|
<div class="ally-msg ${i}" data-idx=${t}>
|
|
886
|
-
${
|
|
887
|
-
${e.timestamp?d`<div class="ally-msg__time">${
|
|
886
|
+
${Fn(e)}
|
|
887
|
+
${e.timestamp?d`<div class="ally-msg__time">${Kn(e.timestamp)}</div>`:v}
|
|
888
888
|
</div>
|
|
889
|
-
`}function
|
|
889
|
+
`}function Bc(e){if(!e)return v;const t=fs(e);return d`
|
|
890
890
|
<div class="ally-msg ally-msg--streaming">
|
|
891
891
|
<div class="ally-msg__content chat-text">${re(t)}</div>
|
|
892
892
|
</div>
|
|
893
|
-
`}function
|
|
893
|
+
`}function Wc(e){return e.connected?v:d`<div class="ally-panel__status ally-panel__status--disconnected">Disconnected</div>`}function qc(){return d`
|
|
894
894
|
<div class="ally-msg ally-msg--assistant ally-msg--reading-indicator">
|
|
895
895
|
<span class="chat-reading-indicator__dots">
|
|
896
896
|
<span></span><span></span><span></span>
|
|
897
897
|
</span>
|
|
898
898
|
</div>
|
|
899
|
-
`}function
|
|
899
|
+
`}function jc(e,t){const n=e.clipboardData?.items;if(!n)return;const s=[];for(const i of Array.from(n)){if(!i.type.startsWith("image/"))continue;const a=i.getAsFile();if(!a)continue;e.preventDefault();const o=new FileReader,l=`paste-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;o.onload=()=>{const c=o.result;t.onAttachmentsChange([...t.attachments,{id:l,dataUrl:c,mimeType:a.type,fileName:a.name||"screenshot.png",status:"ready"}])},o.readAsDataURL(a),s.push({id:l,dataUrl:"",mimeType:a.type,fileName:a.name,status:"reading"})}s.length>0&&t.onAttachmentsChange([...t.attachments,...s])}function Hc(e){return e.attachments.length===0?v:d`
|
|
900
900
|
<div class="ally-panel__attachments">
|
|
901
901
|
${e.attachments.map(t=>d`
|
|
902
902
|
<div class="ally-panel__attachment">
|
|
@@ -910,8 +910,8 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
910
910
|
</div>
|
|
911
911
|
`)}
|
|
912
912
|
</div>
|
|
913
|
-
`}function
|
|
914
|
-
${
|
|
913
|
+
`}function Vc(e){const t=e.connected?`Message ${e.allyName}...`:"Reconnecting...",n=e.draft.trim()||e.attachments.length>0;return d`
|
|
914
|
+
${Hc(e)}
|
|
915
915
|
<div class="ally-panel__input">
|
|
916
916
|
<textarea
|
|
917
917
|
class="ally-panel__textarea"
|
|
@@ -919,8 +919,8 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
919
919
|
?disabled=${!e.connected||e.sending}
|
|
920
920
|
placeholder=${t}
|
|
921
921
|
rows="1"
|
|
922
|
-
@input=${s=>{const i=s.target;
|
|
923
|
-
@paste=${s=>
|
|
922
|
+
@input=${s=>{const i=s.target;Ec(i),e.onDraftChange(i.value)}}
|
|
923
|
+
@paste=${s=>jc(s,e)}
|
|
924
924
|
@keydown=${s=>{s.key==="Enter"&&(s.isComposing||s.keyCode===229||s.shiftKey||e.connected&&(s.preventDefault(),e.onSend()))}}
|
|
925
925
|
></textarea>
|
|
926
926
|
<button
|
|
@@ -933,10 +933,10 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
933
933
|
${$.arrowUp}
|
|
934
934
|
</button>
|
|
935
935
|
</div>
|
|
936
|
-
`}function
|
|
936
|
+
`}function zc(e){return Dc(e),d`
|
|
937
937
|
<div class="ally-panel__header">
|
|
938
938
|
<div class="ally-panel__header-left">
|
|
939
|
-
${
|
|
939
|
+
${Kc(e)}
|
|
940
940
|
<span class="ally-panel__header-name">${e.allyName}</span>
|
|
941
941
|
</div>
|
|
942
942
|
<div class="ally-panel__header-actions">
|
|
@@ -960,29 +960,29 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
960
960
|
</div>
|
|
961
961
|
</div>
|
|
962
962
|
|
|
963
|
-
${
|
|
963
|
+
${Wc(e)}
|
|
964
964
|
|
|
965
|
-
<div class="ally-panel__messages" @scroll=${
|
|
965
|
+
<div class="ally-panel__messages" @scroll=${Oc}>
|
|
966
966
|
${e.messages.length===0&&!e.stream?d`<div class="ally-panel__empty">
|
|
967
967
|
Start a conversation with ${e.allyName}
|
|
968
968
|
</div>`:v}
|
|
969
|
-
${e.messages.map((t,n)=>
|
|
970
|
-
${e.stream?
|
|
971
|
-
${(e.isWorking||e.sending)&&!e.stream?
|
|
969
|
+
${e.messages.map((t,n)=>Uc(t,n,e.onAction,e.onHitlAction))}
|
|
970
|
+
${e.stream?Bc(e.stream):v}
|
|
971
|
+
${(e.isWorking||e.sending)&&!e.stream?qc():v}
|
|
972
972
|
<button
|
|
973
973
|
type="button"
|
|
974
974
|
class="ally-jump-bottom"
|
|
975
975
|
title="Jump to latest"
|
|
976
|
-
@click=${t=>{const n=t.currentTarget.closest(".ally-panel, .ally-inline");n&&
|
|
976
|
+
@click=${t=>{const n=t.currentTarget.closest(".ally-panel, .ally-inline");n&&Ti(n)}}
|
|
977
977
|
>${$.chevronDown}</button>
|
|
978
978
|
</div>
|
|
979
979
|
|
|
980
|
-
${
|
|
981
|
-
`}function
|
|
980
|
+
${Vc(e)}
|
|
981
|
+
`}function Gc(e){return e.open?d`
|
|
982
982
|
<div class="ally-inline">
|
|
983
|
-
${
|
|
983
|
+
${zc(e)}
|
|
984
984
|
</div>
|
|
985
|
-
`:v}const
|
|
985
|
+
`:v}const Un={image:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>`,video:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m10 9 5 3-5 3z"/></svg>`,audio:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>`,markdown:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M7 8v8l3-3 3 3V8"/><path d="m17 12-2-2v4"/></svg>`,html:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="m7 8-4 4 4 4"/><path d="m17 8 4 4-4 4"/><path d="m14 4-4 16"/></svg>`,pdf:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M10 13h4"/><path d="M10 17h4"/></svg>`,csv:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/></svg>`,json:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5a2 2 0 0 0 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5a2 2 0 0 0 2 2 2 2 0 0 0-2 2v5a2 2 0 0 1-2 2h-1"/></svg>`,code:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="m7 8-4 4 4 4"/><path d="m17 8 4 4-4 4"/></svg>`,text:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/><path d="M10 9H8"/></svg>`,svg:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="12" cy="12" r="4"/><path d="M3 12h4M17 12h4M12 3v4M12 17v4"/></svg>`,unknown:d`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>`};function Ai(e,t){const n=e.toLowerCase(),s=(t??"").toLowerCase();return n==="image"||s.startsWith("image/")?"image":n==="video"||s.startsWith("video/")?"video":n==="audio"||s.startsWith("audio/")?"audio":n==="html"||s==="text/html"?"html":n==="markdown"||n==="md"||s==="text/markdown"?"markdown":n==="pdf"||s==="application/pdf"?"pdf":n==="csv"||n==="data"||s==="text/csv"?"csv":n==="json"||s==="application/json"?"json":n==="code"||n==="script"||n==="source"?"code":n==="doc"||n==="document"||n==="text"?"text":"unknown"}function ki(e){const t=Ai(e.type,e.mimeType);return t==="image"||t==="svg"?"images":t==="video"?"video":t==="html"?"html":t==="code"||t==="json"||t==="csv"?"code":"docs"}function Qc(e,t){return t==="all"?e:e.filter(n=>ki(n)===t)}function Yc(e){const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return"just now";const s=Math.floor(n/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Jc(e,t=20){if(e.length<=t)return e;const n=e.lastIndexOf(".");if(n>0&&e.length-n<8){const s=e.slice(0,n),i=e.slice(n),a=t-i.length-2;return s.slice(0,a)+"…"+i}return e.slice(0,t-1)+"…"}const Xc={all:"All",images:"Images",code:"Code",docs:"Docs",html:"HTML",video:"Video"};function Zc(e,t){const n=["all","images","code","docs","html","video"],s=e.filter??"all";return d`
|
|
986
986
|
<div class="rs-filter-tabs" role="tablist" aria-label="Resource filter">
|
|
987
987
|
${n.map(i=>{const a=t[i]??0;return i!=="all"&&a===0?v:d`
|
|
988
988
|
<button
|
|
@@ -990,10 +990,10 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
990
990
|
role="tab"
|
|
991
991
|
aria-selected=${s===i}
|
|
992
992
|
@click=${()=>e.onFilterChange?.(i)}
|
|
993
|
-
>${
|
|
993
|
+
>${Xc[i]}${i!=="all"&&a>0?d`<span class="rs-filter-count">${a}</span>`:v}</button>
|
|
994
994
|
`})}
|
|
995
995
|
</div>
|
|
996
|
-
`}function
|
|
996
|
+
`}function ed(e,t,n){const s=Ai(e.type,e.mimeType),i=Un[s]??Un.unknown,a=Jc(e.title),o=e.createdAt?Yc(e.createdAt):null,l=s==="image"||s==="svg";let c=v;l&&e.url?c=d`<img class="rs-chip__thumb" src=${e.url} alt=${e.title} loading="lazy" />`:l&&e.path?c=d`<div class="rs-chip__icon rs-chip__icon--image">${i}</div>`:c=d`<div class="rs-chip__icon rs-chip__icon--${s}">${i}</div>`;const r={image:"IMG",video:"VID",html:"HTML",markdown:"MD",code:"CODE",doc:"DOC",data:"CSV",json:"JSON",pdf:"PDF",audio:"AUD"}[e.type?.toLowerCase()]??e.type?.toUpperCase()?.slice(0,4)??"FILE";return d`
|
|
997
997
|
<div
|
|
998
998
|
class="rs-chip ${t?"rs-chip--active":""} ${e.pinned?"rs-chip--pinned":""}"
|
|
999
999
|
role="button"
|
|
@@ -1003,7 +1003,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1003
1003
|
draggable="true"
|
|
1004
1004
|
@click=${()=>n.onOpen(e)}
|
|
1005
1005
|
@keydown=${p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),n.onOpen(e))}}
|
|
1006
|
-
@contextmenu=${p=>{p.preventDefault(),
|
|
1006
|
+
@contextmenu=${p=>{p.preventDefault(),td(p,e,n)}}
|
|
1007
1007
|
>
|
|
1008
1008
|
<div class="rs-chip__preview">
|
|
1009
1009
|
${c}
|
|
@@ -1017,7 +1017,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1017
1017
|
</span>
|
|
1018
1018
|
</div>
|
|
1019
1019
|
</div>
|
|
1020
|
-
`}let be=null;function
|
|
1020
|
+
`}let be=null;function td(e,t,n){be?.remove(),be=null;const s=document.createElement("div");s.className="rs-context-menu",s.style.left=`${e.clientX}px`,s.style.top=`${e.clientY}px`;const i=[{label:"Open",icon:"↗",action:()=>n.onOpen(t)},...n.onTogglePin?[{label:t.pinned?"Unpin":"Pin",icon:t.pinned?"☆":"★",action:()=>n.onTogglePin(t)}]:[],...n.onDownload?[{label:"Download",icon:"↓",action:()=>n.onDownload(t)}]:[],...t.path&&n.onCopyPath?[{label:"Copy Path",icon:"⎘",action:()=>n.onCopyPath(t)}]:[],...n.onDelete?[{label:"Delete",icon:"✕",danger:!0,action:()=>n.onDelete(t)}]:[]];for(const o of i){const l=document.createElement("button");l.className=`rs-context-menu__item${o.danger?" rs-context-menu__item--danger":""}`,l.innerHTML=`<span class="rs-context-menu__icon">${o.icon}</span><span>${o.label}</span>`,l.addEventListener("click",()=>{o.action(),s.remove(),be=null}),s.appendChild(l)}document.body.appendChild(s),be=s,requestAnimationFrame(()=>{const o=s.getBoundingClientRect();o.right>window.innerWidth&&(s.style.left=`${e.clientX-o.width}px`),o.bottom>window.innerHeight&&(s.style.top=`${e.clientY-o.height}px`)});const a=o=>{s.contains(o.target)||(s.remove(),be=null,document.removeEventListener("click",a))};setTimeout(()=>document.addEventListener("click",a),0)}function nd(){return d`
|
|
1021
1021
|
<div class="rs-empty">
|
|
1022
1022
|
<div class="rs-empty__icon">
|
|
1023
1023
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
@@ -1028,7 +1028,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1028
1028
|
</div>
|
|
1029
1029
|
<span class="rs-empty__text">Your resources will appear here</span>
|
|
1030
1030
|
</div>
|
|
1031
|
-
`}function
|
|
1031
|
+
`}function sd(e){const{resources:t=[],collapsed:n=!1,activeId:s}=e,i=e.filter??"all",a={all:t.length,images:0,code:0,docs:0,html:0,video:0};for(const c of t){const f=ki(c);a[f]=(a[f]??0)+1}const l=[...Qc(t,i)].sort((c,f)=>c.pinned&&!f.pinned?-1:!c.pinned&&f.pinned?1:(f.createdAt??0)-(c.createdAt??0));return d`
|
|
1032
1032
|
<div class="resource-strip ${n?"resource-strip--collapsed":""}">
|
|
1033
1033
|
<div
|
|
1034
1034
|
class="resource-strip__header"
|
|
@@ -1059,13 +1059,13 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1059
1059
|
</div>
|
|
1060
1060
|
|
|
1061
1061
|
${n?v:d`
|
|
1062
|
-
${t.length>0?
|
|
1062
|
+
${t.length>0?Zc(e,a):v}
|
|
1063
1063
|
<div class="resource-strip__scroll" role="list">
|
|
1064
|
-
${l.length>0?l.map(c=>
|
|
1064
|
+
${l.length>0?l.map(c=>ed(c,c.id===s,e)):nd()}
|
|
1065
1065
|
</div>
|
|
1066
1066
|
`}
|
|
1067
1067
|
</div>
|
|
1068
|
-
`}var
|
|
1068
|
+
`}var id=Object.defineProperty,ad=Object.getOwnPropertyDescriptor,Ae=(e,t,n,s)=>{for(var i=s>1?void 0:s?ad(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&id(t,n,i),i};let de=class extends ts{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.direction="horizontal",this.isDragging=!1,this.startPos=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startPos=this.direction==="vertical"?e.clientY:e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=this.direction==="vertical",s=n?t.getBoundingClientRect().height:t.getBoundingClientRect().width,o=((n?e.clientY:e.clientX)-this.startPos)/s;let l=this.startRatio+o;l=Math.max(this.minRatio,Math.min(this.maxRatio,l)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:l},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return d``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};de.styles=ya`
|
|
1069
1069
|
:host {
|
|
1070
1070
|
flex-shrink: 0;
|
|
1071
1071
|
position: relative;
|
|
@@ -1111,11 +1111,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1111
1111
|
:host(.dragging) {
|
|
1112
1112
|
background: var(--accent, #007bff);
|
|
1113
1113
|
}
|
|
1114
|
-
`;Ae([
|
|
1114
|
+
`;Ae([We({type:Number})],de.prototype,"splitRatio",2);Ae([We({type:Number})],de.prototype,"minRatio",2);Ae([We({type:Number})],de.prototype,"maxRatio",2);Ae([We({type:String})],de.prototype,"direction",2);de=Ae([ns("resizable-divider")],de);function od(e){const t=e.includes("/")?e.split("/").pop():e,n=t.match(/claude-(\w+)-(\d+)-(\d+)/);return n?`${n[1].charAt(0).toUpperCase()+n[1].slice(1)} ${n[2]}.${n[3]}`:t.replace(/^claude-/,"").replace(/-/g," ")}const rd=5e3;function Bn(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function ld(e){const t=e.sessions?.sessions?.find(i=>i.key===e.sessionKey);if(!t)return null;const n=t.totalTokens??0,s=t.contextTokens??e.sessions?.defaults?.contextTokens??2e5;return s<=0?null:n/s}function cd(e){const t=ld(e);if(t===null)return v;const n=Math.round(t*100),s=n>=90?"danger":n>=70?"warn":"ok",i=e.sessions?.sessions?.find(r=>r.key===e.sessionKey),a=i?.totalTokens??0,o=i?.contextTokens??e.sessions?.defaults?.contextTokens??2e5,l=n>=90?"Soul + identity only":n>=70?"P0 + P1 active":"Full context",c=n>=90?d`<span class="chat-context-badge__tier-note chat-context-badge__tier-note--danger">
|
|
1115
1115
|
Schedule, tasks, skill cards trimmed
|
|
1116
1116
|
</span>`:n>=70?d`<span class="chat-context-badge__tier-note chat-context-badge__tier-note--warn">
|
|
1117
1117
|
Meetings, cron, queue review trimmed
|
|
1118
|
-
</span>`:v,
|
|
1118
|
+
</span>`:v,f=d`
|
|
1119
1119
|
<span class="chat-context-badge__tier ${n<70?"active":"trimmed"}">P3 Safety nudges, onboarding</span>
|
|
1120
1120
|
<span class="chat-context-badge__tier ${n<70?"active":"trimmed"}">P2 Meetings, cron, queue review</span>
|
|
1121
1121
|
<span class="chat-context-badge__tier ${n<90?"active":"trimmed"}">P1 Schedule, tasks, skill cards</span>
|
|
@@ -1138,21 +1138,21 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1138
1138
|
${a.toLocaleString()} / ${o.toLocaleString()} tokens
|
|
1139
1139
|
</span>
|
|
1140
1140
|
${c}
|
|
1141
|
-
<span class="chat-context-badge__tier-list">${
|
|
1141
|
+
<span class="chat-context-badge__tier-list">${f}</span>
|
|
1142
1142
|
<span class="chat-context-badge__tooltip-action">Click to compact</span>
|
|
1143
1143
|
</span>
|
|
1144
1144
|
</button>
|
|
1145
|
-
`}function
|
|
1145
|
+
`}function dd(e){return e?e.active?d`
|
|
1146
1146
|
<div class="compaction-bar compaction-bar--active" role="status" aria-label="Optimizing context">
|
|
1147
1147
|
<span class="compaction-bar__icon">${$.loader}</span>
|
|
1148
1148
|
<span class="compaction-bar__text">Optimizing context...</span>
|
|
1149
1149
|
</div>
|
|
1150
|
-
`:e.completedAt&&Date.now()-e.completedAt<
|
|
1150
|
+
`:e.completedAt&&Date.now()-e.completedAt<rd?d`
|
|
1151
1151
|
<div class="compaction-bar compaction-bar--complete" role="status" aria-label="Context optimized">
|
|
1152
1152
|
<span class="compaction-bar__icon">${$.check}</span>
|
|
1153
1153
|
<span class="compaction-bar__text">Context optimized</span>
|
|
1154
1154
|
</div>
|
|
1155
|
-
`:v:v}function
|
|
1155
|
+
`:v:v}function Jt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ud(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")}function hd(e,t){e.preventDefault(),e.stopPropagation(),t.classList.add("chat--drag-over")}function pd(e,t){e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();(e.clientX<=n.left||e.clientX>=n.right||e.clientY<=n.top||e.clientY>=n.bottom)&&t.classList.remove("chat--drag-over")}function md(e,t){e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("chat--drag-over");const s=e.dataTransfer?.files;if(!s||s.length===0||!t.onAttachmentsChange)return;const i=t.attachments??[],a=i.reduce((r,p)=>r+(p.dataUrl?.length??0)*.75,0),{validFiles:o,errors:l}=Yt(s,a);for(const r of l)t.showToast?.(r,"error");if(o.length===0)return;const c=[];let f=o.length;for(const r of o){const p=new FileReader;p.addEventListener("load",()=>{const g=p.result;c.push({id:Jt(),dataUrl:g,mimeType:r.type||"application/octet-stream",fileName:r.name}),f--,f===0&&t.onAttachmentsChange?.([...i,...c])}),p.addEventListener("error",()=>{t.showToast?.(`Failed to read "${r.name}"`,"error"),f--,f===0&&c.length>0&&t.onAttachmentsChange?.([...i,...c])}),p.readAsDataURL(r)}}function fd(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let r=0;r<n.length;r++){const p=n[r];if(p.type.startsWith("image/")){const g=p.getAsFile();g&&s.push(g)}}if(s.length===0)return;e.preventDefault();const i=t.attachments??[],a=i.reduce((r,p)=>r+(p.dataUrl?.length??0)*.75,0),{validFiles:o,errors:l}=Yt(s,a);for(const r of l)t.showToast?.(r,"error");if(o.length===0)return;const c=[];let f=o.length;for(const r of o){const p=new FileReader;p.addEventListener("load",()=>{const g=p.result;c.push({id:Jt(),dataUrl:g,mimeType:r.type,fileName:r.name||"pasted-image"}),f--,f===0&&t.onAttachmentsChange?.([...i,...c])}),p.addEventListener("error",()=>{t.showToast?.("Failed to read pasted image","error"),f--,f===0&&c.length>0&&t.onAttachmentsChange?.([...i,...c])}),p.readAsDataURL(r)}}function gd(e,t){const n=e.target,s=n.files;if(!s||!t.onAttachmentsChange)return;const i=t.attachments??[],a=i.reduce((r,p)=>r+(p.dataUrl?.length??0)*.75,0),{validFiles:o,errors:l}=Yt(s,a);for(const r of l)t.showToast?.(r,"error");if(o.length===0){n.value="";return}const c=[];let f=o.length;for(const r of o){const p=new FileReader;p.addEventListener("load",()=>{const g=p.result;c.push({id:Jt(),dataUrl:g,mimeType:r.type||"application/octet-stream",fileName:r.name}),f--,f===0&&t.onAttachmentsChange?.([...i,...c])}),p.addEventListener("error",()=>{t.showToast?.(`Failed to read "${r.name}"`,"error"),f--,f===0&&c.length>0&&t.onAttachmentsChange?.([...i,...c])}),p.readAsDataURL(r)}n.value=""}function yd(e){const t=e.attachments??[];return t.length===0?v:d`
|
|
1156
1156
|
<div class="chat-attachments">
|
|
1157
1157
|
${t.map(n=>{const s=n.mimeType.startsWith("image/"),i=n.fileName||"file",a=i.length>40?i.slice(0,37)+"...":i;return d`
|
|
1158
1158
|
<div class="chat-attachment ${s?"":"chat-attachment--file"}">
|
|
@@ -1171,27 +1171,27 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1171
1171
|
</div>
|
|
1172
1172
|
`})}
|
|
1173
1173
|
</div>
|
|
1174
|
-
`}function
|
|
1175
|
-
`)?null:t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../")||/^[a-z]:[\\/]/i.test(t)||/^[^:\s]+\/[^\s]+$/.test(t)&&/\.[a-z0-9]{1,12}$/i.test(t)||/^[^\s/\\:*?"<>|]+\.[a-z0-9]{1,12}$/i.test(t)&&t.length<=100?t:null}async function
|
|
1174
|
+
`}function vd(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function bd(e){const t=e.href;if(t){if(e.target==="_blank"){window.open(t,"_blank","noopener,noreferrer");return}window.location.assign(t)}}function wd(e){const t=e.trim();return!t||t.includes(`
|
|
1175
|
+
`)?null:t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../")||/^[a-z]:[\\/]/i.test(t)||/^[^:\s]+\/[^\s]+$/.test(t)&&/\.[a-z0-9]{1,12}$/i.test(t)||/^[^\s/\\:*?"<>|]+\.[a-z0-9]{1,12}$/i.test(t)&&t.length<=100?t:null}async function Sd(e,t){const n=e.target,s=n instanceof Element?n:n instanceof Node?n.parentElement:null;if(!s||!t.onMessageLinkClick||!vd(e))return;const i=s.closest("a");if(i instanceof HTMLAnchorElement){if(i.hasAttribute("download"))return;const c=i.getAttribute("href");if(!c)return;if(t.onOpenProof)try{const r=c.match(/(?:proofeditor\.ai|127\.0\.0\.1:\d+|localhost:\d+)\/d\/([a-zA-Z0-9_-]+)/);if(r){e.preventDefault(),t.onOpenProof(r[1]);return}}catch{}try{const r=new URL(c,window.location.href);if(/^https?:$/.test(r.protocol)&&r.origin!==window.location.origin){e.preventDefault(),window.open(r.href,"_blank","noopener,noreferrer");return}}catch{}e.preventDefault(),e.stopPropagation(),await t.onMessageLinkClick(c)||bd(i);return}const a=s.closest("code");if(!(a instanceof HTMLElement))return;const o=(a.textContent??"").trim();if(/^https?:\/\/\S+$/i.test(o)){e.preventDefault(),window.open(o,"_blank","noopener,noreferrer");return}if(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*\.[a-z]{2,}(\/\S*)?$/i.test(o)){e.preventDefault(),window.open(`https://${o}`,"_blank","noopener,noreferrer");return}const l=wd(o);l&&(e.preventDefault(),e.stopPropagation(),await t.onMessageLinkClick(l))}function _d(e){const t=e.sessionResources;if(!t||t.length===0)return v;const n=t.map(s=>({id:s.id,title:s.title,type:s.type,path:s.path,url:s.url}));return sd({resources:n,collapsed:e.sessionResourcesCollapsed,onOpen:s=>e.onSessionResourceClick?.({path:s.path,url:s.url}),onToggleCollapse:()=>e.onToggleSessionResources?.(),onViewAll:()=>e.onViewAllResources?.()})}function Td(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(y=>y.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",l={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},c=(e.attachments?.length??0)>0,f=e.connected?c?"Add a message or paste more images...":"Message (↩ to send, ⌘↩ to queue, Shift+↩ for line breaks)":"Connect to the gateway to start chatting…",r=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),g=d`
|
|
1176
1176
|
<div
|
|
1177
1177
|
class="chat-thread"
|
|
1178
1178
|
role="log"
|
|
1179
1179
|
aria-live="polite"
|
|
1180
1180
|
@scroll=${e.onChatScroll}
|
|
1181
|
-
@click=${y=>{
|
|
1181
|
+
@click=${y=>{Sd(y,e)}}
|
|
1182
1182
|
>
|
|
1183
1183
|
${e.loading?d`
|
|
1184
1184
|
<div class="muted">Loading chat…</div>
|
|
1185
1185
|
`:v}
|
|
1186
|
-
${
|
|
1186
|
+
${Be(Cd(e),y=>y.key,y=>{try{if(y.kind==="reading-indicator")return xr(l,e.currentToolInfo);if(y.kind==="stream")return Pr(y.text,y.startedAt,e.onOpenSidebar,l,e.currentToolInfo);if(y.kind==="compaction-summary")return Rr(y.message);if(y.kind==="group"){const b=e.resolveImageUrl?(k,P)=>e.resolveImageUrl(k,P):void 0;return Lr(y,{onOpenSidebar:e.onOpenSidebar,onOpenFile:e.onOpenFile,onOpenProof:e.onOpenProof,onPushToDrive:e.onPushToDrive,onImageClick:e.onImageClick,resolveImageUrl:b,showReasoning:o,assistantName:e.assistantName,assistantAvatar:l.avatar,userName:e.userName,userAvatar:e.userAvatar})}return v}catch(b){return console.error("[chat] item render error:",b,y.key),v}})}
|
|
1187
1187
|
</div>
|
|
1188
1188
|
`;return d`
|
|
1189
1189
|
<section
|
|
1190
1190
|
class="card chat"
|
|
1191
|
-
@dragover=${
|
|
1192
|
-
@dragenter=${y=>
|
|
1193
|
-
@dragleave=${y=>
|
|
1194
|
-
@drop=${y
|
|
1191
|
+
@dragover=${ud}
|
|
1192
|
+
@dragenter=${y=>hd(y,y.currentTarget)}
|
|
1193
|
+
@dragleave=${y=>pd(y,y.currentTarget)}
|
|
1194
|
+
@drop=${y=>md(y,e)}
|
|
1195
1195
|
>
|
|
1196
1196
|
${e.privateMode?d`<div class="callout callout--private" aria-live="polite">
|
|
1197
1197
|
<span style="margin-right:6px">🔒</span>
|
|
@@ -1202,7 +1202,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1202
1202
|
|
|
1203
1203
|
${e.error?d`<div class="callout danger">${e.error}</div>`:v}
|
|
1204
1204
|
|
|
1205
|
-
${
|
|
1205
|
+
${dd(e.compactionStatus)}
|
|
1206
1206
|
|
|
1207
1207
|
${e.focusMode?d`
|
|
1208
1208
|
<button
|
|
@@ -1249,7 +1249,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1249
1249
|
${e.allyPanelOpen&&e.allyProps?d`
|
|
1250
1250
|
<div class="chat-sidebar chat-sidebar--split">
|
|
1251
1251
|
<div class="chat-sidebar-top">
|
|
1252
|
-
${
|
|
1252
|
+
${Tt({content:e.sidebarContent??null,error:e.sidebarError??null,mimeType:e.sidebarMimeType??null,filePath:e.sidebarFilePath??null,title:e.sidebarTitle??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(e.sidebarContent,{mimeType:"text/plain",filePath:e.sidebarFilePath??null,title:e.sidebarTitle??null})},onOpenFile:e.onOpenFile,onPushToDrive:e.onPushToDrive,driveAccounts:e.driveAccounts,showDrivePicker:e.showDrivePicker,driveUploading:e.driveUploading,onToggleDrivePicker:e.onToggleDrivePicker})}
|
|
1253
1253
|
</div>
|
|
1254
1254
|
<resizable-divider
|
|
1255
1255
|
direction="vertical"
|
|
@@ -1258,12 +1258,12 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1258
1258
|
.maxRatio=${.8}
|
|
1259
1259
|
></resizable-divider>
|
|
1260
1260
|
<div class="chat-sidebar-bottom">
|
|
1261
|
-
${
|
|
1261
|
+
${Gc(e.allyProps)}
|
|
1262
1262
|
</div>
|
|
1263
1263
|
</div>
|
|
1264
1264
|
`:d`
|
|
1265
1265
|
<div class="chat-sidebar">
|
|
1266
|
-
${
|
|
1266
|
+
${Tt({content:e.sidebarContent??null,error:e.sidebarError??null,mimeType:e.sidebarMimeType??null,filePath:e.sidebarFilePath??null,title:e.sidebarTitle??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(e.sidebarContent,{mimeType:"text/plain",filePath:e.sidebarFilePath??null,title:e.sidebarTitle??null})},onOpenFile:e.onOpenFile,onPushToDrive:e.onPushToDrive,driveAccounts:e.driveAccounts,showDrivePicker:e.showDrivePicker,driveUploading:e.driveUploading,onToggleDrivePicker:e.onToggleDrivePicker})}
|
|
1267
1267
|
</div>
|
|
1268
1268
|
`}
|
|
1269
1269
|
`:v}
|
|
@@ -1292,7 +1292,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1292
1292
|
</div>
|
|
1293
1293
|
`:v}
|
|
1294
1294
|
|
|
1295
|
-
${
|
|
1295
|
+
${_d(e)}
|
|
1296
1296
|
|
|
1297
1297
|
<div class="chat-compose">
|
|
1298
1298
|
<div class="chat-compose__wrapper">
|
|
@@ -1301,21 +1301,21 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1301
1301
|
id="chat-file-input"
|
|
1302
1302
|
multiple
|
|
1303
1303
|
style="display: none"
|
|
1304
|
-
@change=${y=>
|
|
1304
|
+
@change=${y=>gd(y,e)}
|
|
1305
1305
|
/>
|
|
1306
|
-
${
|
|
1306
|
+
${yd(e)}
|
|
1307
1307
|
|
|
1308
1308
|
<div class="chat-compose__input-area">
|
|
1309
1309
|
<textarea
|
|
1310
1310
|
class="chat-compose__textarea"
|
|
1311
1311
|
aria-label="Chat message"
|
|
1312
|
-
${
|
|
1312
|
+
${va(y=>y&&Bn(y))}
|
|
1313
1313
|
.value=${e.draft}
|
|
1314
1314
|
?disabled=${!e.connected}
|
|
1315
1315
|
@keydown=${y=>{if(y.key!=="Enter"||y.isComposing||y.keyCode===229||y.shiftKey||!e.connected)return;y.preventDefault();const b=y.ctrlKey||y.metaKey;t&&e.onSend(b)}}
|
|
1316
|
-
@input=${y=>{const b=y.target;
|
|
1317
|
-
@paste=${y=>
|
|
1318
|
-
placeholder=${
|
|
1316
|
+
@input=${y=>{const b=y.target;Bn(b),e.onDraftChange(b.value)}}
|
|
1317
|
+
@paste=${y=>fd(y,e)}
|
|
1318
|
+
placeholder=${f}
|
|
1319
1319
|
></textarea>
|
|
1320
1320
|
|
|
1321
1321
|
<div class="chat-compose__actions">
|
|
@@ -1327,7 +1327,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1327
1327
|
title="Switch model"
|
|
1328
1328
|
aria-label="Switch model"
|
|
1329
1329
|
aria-expanded=${e.modelPickerOpen??!1}
|
|
1330
|
-
>${
|
|
1330
|
+
>${od(e.currentModel)} ▾</button>
|
|
1331
1331
|
${e.modelPickerOpen&&(e.availableModels?.length??0)>0?d`
|
|
1332
1332
|
<div class="model-picker-dropdown">
|
|
1333
1333
|
${e.availableModels.map(y=>d`
|
|
@@ -1344,7 +1344,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1344
1344
|
`:v}
|
|
1345
1345
|
</div>
|
|
1346
1346
|
`:v}
|
|
1347
|
-
${
|
|
1347
|
+
${cd(e)}
|
|
1348
1348
|
|
|
1349
1349
|
<button
|
|
1350
1350
|
class="chat-compose__toolbar-btn"
|
|
@@ -1384,7 +1384,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1384
1384
|
</div>
|
|
1385
1385
|
</div>
|
|
1386
1386
|
</section>
|
|
1387
|
-
`}const
|
|
1387
|
+
`}const Wn=200;function Ad(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=Rt(s.message),a=qe(i.role),o=i.timestamp||Date.now();!n||n.role!==a?(n&&t.push(n),n={kind:"group",key:`group:${a}:${s.key}`,role:a,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function kd(e){const n=e.content;if(!Array.isArray(n))return!1;for(const s of n){if(typeof s!="object"||s===null)continue;const i=s;if(i.type==="image")return!0;if(Array.isArray(i.content)){for(const a of i.content)if(!(typeof a!="object"||a===null)&&a.type==="image")return!0}}return!1}function $d(e){const n=e.content;if(!Array.isArray(n)||n.length===0)return!1;for(const s of n){if(typeof s!="object"||s===null)continue;const i=s,a=typeof i.type=="string"?i.type:"";if(a!=="toolCall"&&a!=="tool_use"&&a!=="thinking")return!1}return!0}function Cd(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Wn);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Wn} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a];if(o._chatIdx=a,Er(o)){t.push({kind:"compaction-summary",key:`compaction:${a}`,message:o});continue}if(_c(o))continue;const l=Rt(o);!e.showThinking&&l.role.toLowerCase()==="toolresult"&&!kd(o)||!e.showThinking&&l.role.toLowerCase()==="assistant"&&$d(o)||t.push({kind:"message",key:qn(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:qn(s[a],a+n.length),message:s[a]});if(e.stream!==null){let a=!1;if(e.stream.trim().length>0&&n.length>0){const o=n[n.length-1];if(typeof o.role=="string"&&o.role.toLowerCase()==="assistant"){const l=o.content;let c="";typeof l=="string"?c=l:Array.isArray(l)&&(c=l.filter(f=>f.type==="text"&&typeof f.text=="string").map(f=>f.text).join("")),c.length>0&&c.length>=e.stream.trim().length&&(a=!0)}}if(!a){const o=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:o,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:o})}}else if(e.isWorking){const a=`working:${e.sessionKey}`;t.push({kind:"reading-indicator",key:a})}else if(e.sending||e.canAbort){const a=`sending:${e.sessionKey}`;t.push({kind:"reading-indicator",key:a})}return Ad(t)}function qn(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const a=typeof n.messageId=="string"?n.messageId:"";if(a)return`msg:${a}`;const o=typeof n.timestamp=="number"?n.timestamp:null,l=typeof n.role=="string"?n.role:"unknown";if(o!=null){const c=typeof n.content=="string"?n.content.slice(0,32):"";return`msg:${l}:${o}:${c||t}`}return`msg:${l}:${t}`}function xd(e){const{pendingGatewayUrl:t}=e;return t?d`
|
|
1388
1388
|
<div class="exec-approval-overlay" role="dialog" aria-modal="true" aria-live="polite">
|
|
1389
1389
|
<div class="exec-approval-card">
|
|
1390
1390
|
<div class="exec-approval-header">
|
|
@@ -1413,7 +1413,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1413
1413
|
</div>
|
|
1414
1414
|
</div>
|
|
1415
1415
|
</div>
|
|
1416
|
-
`:v}function
|
|
1416
|
+
`:v}function Pd(e){if(!e.gatewayRestartPending)return v;const t=e.sessionsResult?.sessions?.length??0,n=t===1?"1 active session":`${t} active sessions`;return d`
|
|
1417
1417
|
<div class="exec-approval-overlay" role="dialog" aria-modal="true" aria-live="polite">
|
|
1418
1418
|
<div class="exec-approval-card">
|
|
1419
1419
|
<div class="exec-approval-header">
|
|
@@ -1443,7 +1443,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1443
1443
|
</div>
|
|
1444
1444
|
</div>
|
|
1445
1445
|
</div>
|
|
1446
|
-
`}function
|
|
1446
|
+
`}function $i(){return{open:!1,images:[],currentIndex:0}}function Ld(e,t,n){return{open:!0,images:t,currentIndex:n}}function Md(){return $i()}function Id(e,t){const n=e.currentIndex+t;return n<0||n>=e.images.length?e:{...e,currentIndex:n}}const Rd=d`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`,Ed=d`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`,Dd=d`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 6 15 12 9 18"/></svg>`;function Od(e,t){if(!e.open||e.images.length===0)return v;const n=e.images[e.currentIndex];if(!n)return v;const s=e.images.length>1,i=e.currentIndex>0,a=e.currentIndex<e.images.length-1;return d`
|
|
1447
1447
|
<div
|
|
1448
1448
|
class="lightbox-overlay"
|
|
1449
1449
|
@click=${o=>{o.target.classList.contains("lightbox-overlay")&&t.onClose()}}
|
|
@@ -1451,10 +1451,10 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1451
1451
|
tabindex="0"
|
|
1452
1452
|
>
|
|
1453
1453
|
<button class="lightbox-close" @click=${t.onClose} aria-label="Close image viewer">
|
|
1454
|
-
${
|
|
1454
|
+
${Rd}
|
|
1455
1455
|
</button>
|
|
1456
1456
|
|
|
1457
|
-
${s&&i?d`<button class="lightbox-nav lightbox-nav--prev" @click=${()=>t.onNav(-1)} aria-label="Previous image">${
|
|
1457
|
+
${s&&i?d`<button class="lightbox-nav lightbox-nav--prev" @click=${()=>t.onNav(-1)} aria-label="Previous image">${Ed}</button>`:v}
|
|
1458
1458
|
|
|
1459
1459
|
<img
|
|
1460
1460
|
class="lightbox-image"
|
|
@@ -1464,11 +1464,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1464
1464
|
@error=${o=>{o.target.classList.add("lightbox-image--broken")}}
|
|
1465
1465
|
/>
|
|
1466
1466
|
|
|
1467
|
-
${s&&a?d`<button class="lightbox-nav lightbox-nav--next" @click=${()=>t.onNav(1)} aria-label="Next image">${
|
|
1467
|
+
${s&&a?d`<button class="lightbox-nav lightbox-nav--next" @click=${()=>t.onNav(1)} aria-label="Next image">${Dd}</button>`:v}
|
|
1468
1468
|
|
|
1469
1469
|
${s?d`<div class="lightbox-counter">${e.currentIndex+1} / ${e.images.length}</div>`:v}
|
|
1470
1470
|
</div>
|
|
1471
|
-
`}const
|
|
1471
|
+
`}const Kd=e=>{switch(e){case"success":return d`
|
|
1472
1472
|
<svg
|
|
1473
1473
|
width="16"
|
|
1474
1474
|
height="16"
|
|
@@ -1524,11 +1524,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1524
1524
|
<circle cx="8" cy="8" r="7" />
|
|
1525
1525
|
<path d="M8 11V8M8 5h.01" />
|
|
1526
1526
|
</svg>
|
|
1527
|
-
`}};function
|
|
1527
|
+
`}};function Nd({toasts:e,onDismiss:t}){return e.length===0?null:d`
|
|
1528
1528
|
<div class="toast-container">
|
|
1529
|
-
${
|
|
1529
|
+
${Be(e,n=>n.id,n=>d`
|
|
1530
1530
|
<div class="toast toast--${n.type}">
|
|
1531
|
-
<div class="toast__icon">${
|
|
1531
|
+
<div class="toast__icon">${Kd(n.type)}</div>
|
|
1532
1532
|
<div class="toast__body">
|
|
1533
1533
|
<div class="toast__message">${n.message}</div>
|
|
1534
1534
|
${n.action?d`${n.action.url?d`<a
|
|
@@ -1553,7 +1553,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1553
1553
|
</div>
|
|
1554
1554
|
`)}
|
|
1555
1555
|
</div>
|
|
1556
|
-
`}function
|
|
1556
|
+
`}function Fd(e){const{connected:t,updateStatus:n,updateLoading:s,updateRunning:i,pluginUpdateRunning:a,updateError:o,onCheckUpdates:l,onUpdateOpenclaw:c,onUpdatePlugin:f}=e,r=i||a;return d`
|
|
1557
1557
|
<section class="tab-body" style="max-width: 600px; margin: 0 auto;">
|
|
1558
1558
|
<!-- Gateway connection -->
|
|
1559
1559
|
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 24px;">
|
|
@@ -1572,7 +1572,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1572
1572
|
<span>v${n.openclawVersion}</span>
|
|
1573
1573
|
${n.openclawUpdateAvailable&&n.openclawLatest?d`
|
|
1574
1574
|
<span style="color: var(--text-muted, #888);">\u2192 v${n.openclawLatest}</span>
|
|
1575
|
-
<button
|
|
1575
|
+
<button
|
|
1576
|
+
class="btn btn--primary btn--sm"
|
|
1577
|
+
?disabled=${r}
|
|
1578
|
+
@click=${c}
|
|
1579
|
+
>${i?"Updating…":"Update"}</button>
|
|
1576
1580
|
`:d`<span style="color: var(--text-muted, #888); font-size: 0.85rem;">up to date</span>`}
|
|
1577
1581
|
</div>
|
|
1578
1582
|
|
|
@@ -1582,7 +1586,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1582
1586
|
<span>v${n.pluginVersion}</span>
|
|
1583
1587
|
${n.pluginUpdateAvailable&&n.pluginLatest?d`
|
|
1584
1588
|
<span style="color: var(--text-muted, #888);">\u2192 v${n.pluginLatest}</span>
|
|
1585
|
-
<button
|
|
1589
|
+
<button
|
|
1590
|
+
class="btn btn--primary btn--sm"
|
|
1591
|
+
?disabled=${r}
|
|
1592
|
+
@click=${f}
|
|
1593
|
+
>${a?"Updating…":"Update"}</button>
|
|
1586
1594
|
`:d`<span style="color: var(--text-muted, #888); font-size: 0.85rem;">up to date</span>`}
|
|
1587
1595
|
</div>
|
|
1588
1596
|
|
|
@@ -1593,18 +1601,24 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1593
1601
|
`:v}
|
|
1594
1602
|
`:d`<div style="color: var(--text-muted, #888); margin-bottom: 12px;">No version data yet.</div>`}
|
|
1595
1603
|
|
|
1604
|
+
${o?d`
|
|
1605
|
+
<div style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; background: var(--color-error-bg, rgba(239, 68, 68, 0.1)); color: var(--color-error, #ef4444); font-size: 0.85rem;">
|
|
1606
|
+
${o}
|
|
1607
|
+
</div>
|
|
1608
|
+
`:v}
|
|
1609
|
+
|
|
1596
1610
|
<!-- Check for updates -->
|
|
1597
1611
|
<div style="margin-top: 20px;">
|
|
1598
1612
|
<button
|
|
1599
1613
|
class="btn btn--secondary"
|
|
1600
|
-
?disabled=${s||!t}
|
|
1601
|
-
@click=${
|
|
1614
|
+
?disabled=${s||r||!t}
|
|
1615
|
+
@click=${l}
|
|
1602
1616
|
>
|
|
1603
1617
|
${s?"Checking…":"Check for Updates"}
|
|
1604
1618
|
</button>
|
|
1605
1619
|
</div>
|
|
1606
1620
|
</section>
|
|
1607
|
-
`}const
|
|
1621
|
+
`}const Ud={"gm-work":()=>_(()=>import("./work-tab-BJF_wapn.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),"gm-today":()=>_(()=>import("./today-tab-ReKlJGhF.js"),__vite__mapDeps([6,1,3,4,5,2]),import.meta.url),"gm-team":()=>_(()=>import("./team-tab-Dpl4pwK6.js"),__vite__mapDeps([7,1,3,4,5]),import.meta.url),"gm-brain":()=>_(()=>import("./brain-tab-C2AbYrWP.js"),__vite__mapDeps([8,1,4,3,5]),import.meta.url),"gm-second-brain":()=>_(()=>import("./second-brain-tab-BK7ARED2.js"),__vite__mapDeps([9,1,4,3,5]),import.meta.url),"gm-dashboards":()=>_(()=>import("./dashboards-tab-CIED6Kpa.js"),__vite__mapDeps([10,1,4,3,5]),import.meta.url),"gm-connections":()=>_(()=>import("./connections-tab-CwdK_wkL.js"),__vite__mapDeps([11,1,3,4,5]),import.meta.url)},jn=new Set;function pe(e){jn.has(e)||(jn.add(e),Ud[e]?.())}const Bd=/^data:/i,Wd=/^https?:\/\//i;function qd(e){const t=e.agentsList?.agents??[],s=cs(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(l=>l.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Bd.test(o)||Wd.test(o)?o:a?.avatarUrl}function Hn(e){const t=e.trim();if(!t)return t;const n=t.split(/\s+/);if(n.length>=2&&n.length%2===0){const l=n.length/2,c=n.slice(0,l).join(" "),f=n.slice(l).join(" ");if(c.toLowerCase()===f.toLowerCase())return c}const s=t.replace(/\s+/g," ").toLowerCase(),i=Math.floor(s.length/2),a=s.slice(0,i).trim(),o=s.slice(i).trim();return a&&a===o?t.slice(0,Math.ceil(t.length/2)).trim():t}function At(e,t){const n=t?.sessionId?.trim();return n?`session:${n}`:`key:${e.trim().toLowerCase()}`}function Vn(e){if(e===O)return!0;const t=e.toLowerCase();return!!(t==="agent:main:main"||t.endsWith(":main"))}function jd(e){const t=e.sessionsResult?.sessions,n=[...new Set(e.settings.openTabs.map(l=>l.trim()).filter(Boolean))].filter(l=>!Vn(l)),s=ae(t,e.sessionKey),i=At(e.sessionKey,s),a=new Map;for(const l of n){const c=ae(t,l),f=At(l,c);if(!a.has(f)){a.set(f,l);continue}l===e.sessionKey&&a.set(f,l)}const o=[...a.values()];if(o.length===0){const l=e.sessionKey.trim()||"main";Vn(l)||o.push(l)}return{tabKeys:o,activeIdentity:i}}function Hd(e){if(e.wizardActive&&e.wizardState)return xa(e.wizardState,{onStepChange:r=>{e.handleWizardStepChange?.(r)},onAnswerChange:(r,p)=>{e.handleWizardAnswerChange?.(r,p)},onPreview:()=>{e.handleWizardPreview?.()},onGenerate:()=>{e.handleWizardGenerate?.()},onClose:()=>{e.handleWizardClose?.()},onFileToggle:(r,p)=>{e.handleWizardFileToggle?.(r,p)},onConfigToggle:(r,p)=>{e.handleWizardConfigToggle?.(r,p)}});e.presenceEntries.length;const t=e.sessionsResult?.count??null;e.cronStatus?.nextWakeAtMs;const n=e.connected?null:"Disconnected from gateway.",s=e.tab==="chat",i=s&&(e.settings.chatFocusMode||e.onboarding),a=e.onboarding?!1:e.settings.chatShowThinking,o=qd(e),l=e.chatAvatarUrl??o??null,{tabKeys:c,activeIdentity:f}=jd(e);return d`
|
|
1608
1622
|
<div class="shell ${s?"shell--chat":""} ${i?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""} ${window.innerWidth<=600?"shell--nav-drawer":""} ${e.navDrawerOpen?"shell--nav-drawer-open":""}">
|
|
1609
1623
|
<div
|
|
1610
1624
|
class="nav-drawer-backdrop ${e.navDrawerOpen?"nav-drawer-backdrop--visible":""}"
|
|
@@ -1664,7 +1678,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1664
1678
|
<span>Gateway</span>
|
|
1665
1679
|
<span class="mono">${e.reconnecting?`Reconnecting${e.reconnectAttempt>1?` (${e.reconnectAttempt})`:""}...`:e.connected?"Connected":"Offline"}</span>
|
|
1666
1680
|
</div>
|
|
1667
|
-
${
|
|
1681
|
+
${bi(e)}
|
|
1668
1682
|
</div>
|
|
1669
1683
|
</header>
|
|
1670
1684
|
${e.deployPanelOpen&&e.updateStatus?.pendingDeploy?(()=>{const r=e.updateStatus.pendingDeploy,p=Date.now()-r.ts,g=Math.floor(p/6e4),y=g<1?"just now":g<60?`${g}m ago`:`${Math.floor(g/60)}h ago`;return d`
|
|
@@ -1693,7 +1707,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1693
1707
|
</div>`})():v}
|
|
1694
1708
|
<aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
|
|
1695
1709
|
|
|
1696
|
-
${
|
|
1710
|
+
${Pa.map(r=>{const p=e.settings.navGroupsCollapsed[r.label]??!1,g=r.tabs.some(b=>b===e.tab),y=!r.label||r.tabs.length===1&&Z(r.tabs[0])===r.label;return d`
|
|
1697
1711
|
<div class="nav-group ${p&&!g?"nav-group--collapsed":""} ${y?"nav-group--no-header":""}">
|
|
1698
1712
|
${y?v:d`
|
|
1699
1713
|
<button
|
|
@@ -1707,7 +1721,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1707
1721
|
`}
|
|
1708
1722
|
<div class="nav-group__items">
|
|
1709
1723
|
${v}
|
|
1710
|
-
${r.tabs.map(b=>
|
|
1724
|
+
${r.tabs.map(b=>_t(e,b))}
|
|
1711
1725
|
</div>
|
|
1712
1726
|
</div>
|
|
1713
1727
|
`})}
|
|
@@ -1722,11 +1736,11 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1722
1736
|
<span class="nav-label__chevron">${p?"+":"−"}</span>
|
|
1723
1737
|
</button>
|
|
1724
1738
|
<div class="nav-group__items">
|
|
1725
|
-
${r.map(y=>{const b=e.tab===y.slug,
|
|
1739
|
+
${r.map(y=>{const b=e.tab===y.slug,k=Ct(y.slug,e.basePath);return d`
|
|
1726
1740
|
<a
|
|
1727
|
-
href=${
|
|
1741
|
+
href=${k}
|
|
1728
1742
|
class="nav-item ${b?"nav-item--active":""}"
|
|
1729
|
-
@click=${P=>{P.preventDefault(),e.setTab(y.slug),
|
|
1743
|
+
@click=${P=>{P.preventDefault(),e.setTab(y.slug),si(e,y)}}
|
|
1730
1744
|
>
|
|
1731
1745
|
<span class="nav-item__icon">${$[y.icon]??$.folder}</span>
|
|
1732
1746
|
<span class="nav-item__label">${y.title}</span>
|
|
@@ -1735,7 +1749,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1735
1749
|
</div>
|
|
1736
1750
|
</div>
|
|
1737
1751
|
`})():v}
|
|
1738
|
-
${
|
|
1752
|
+
${La.map(r=>{const p=e.settings.navGroupsCollapsed[r.label]??!0,g=r.tabs.some(y=>y===e.tab);return d`
|
|
1739
1753
|
<div class="nav-group ${p&&!g?"nav-group--collapsed":""}">
|
|
1740
1754
|
<button
|
|
1741
1755
|
class="nav-label"
|
|
@@ -1746,7 +1760,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1746
1760
|
<span class="nav-label__chevron">${p?"+":"−"}</span>
|
|
1747
1761
|
</button>
|
|
1748
1762
|
<div class="nav-group__items">
|
|
1749
|
-
${r.tabs.map(y=>
|
|
1763
|
+
${r.tabs.map(y=>_t(e,y))}
|
|
1750
1764
|
</div>
|
|
1751
1765
|
</div>
|
|
1752
1766
|
`})}
|
|
@@ -1782,23 +1796,23 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1782
1796
|
<section class="content-header">
|
|
1783
1797
|
<div>
|
|
1784
1798
|
${e.tab!=="chat"&&e.tab!=="onboarding"&&e.tab!=="team"?d`
|
|
1785
|
-
<div class="page-title">${
|
|
1786
|
-
<div class="page-sub">${
|
|
1799
|
+
<div class="page-title">${Z(e.tab)}</div>
|
|
1800
|
+
<div class="page-sub">${Ma(e.tab)}</div>
|
|
1787
1801
|
`:e.tab==="chat"?d`
|
|
1788
1802
|
<div class="session-tabs">
|
|
1789
|
-
${
|
|
1803
|
+
${Be(c,r=>r,(r,p)=>{const g=ae(e.sessionsResult?.sessions,r),y=At(r,g)===f,k=(()=>{if(g?.label||g?.displayName)return Hn(g.label??g.displayName);const w=se.get(r);if(w)return Hn(w);if(r==="agent:main:support")return"Support";if(r.includes("webchat")){const A=r.match(/webchat[:-](\d+)/);return A?`Chat ${A[1]}`:"Chat"}if(r.includes("main"))return"MAIN";const T=r.split(/[:-]/);return T[T.length-1]||r})(),P=e.workingSessions.has(r),U=e.settings.tabLastViewed[r]??0,C=g?.updatedAt??0,D=!y&&!P&&C>U,Y=e.editingTabKey===r;return d`
|
|
1790
1804
|
<div
|
|
1791
|
-
class="session-tab ${y?"session-tab--active":""} ${P?"session-tab--working":""} ${D?"session-tab--ready":""} ${
|
|
1805
|
+
class="session-tab ${y?"session-tab--active":""} ${P?"session-tab--working":""} ${D?"session-tab--ready":""} ${Y?"session-tab--editing":""}"
|
|
1792
1806
|
draggable="true"
|
|
1793
1807
|
@dragstart=${w=>{if(e.editingTabKey===r){w.preventDefault();return}w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/session-key",r),w.dataTransfer.setData("text/plain",p.toString()),w.target.classList.add("dragging")}}
|
|
1794
|
-
@click=${()=>{if(!
|
|
1808
|
+
@click=${()=>{if(!Y){if(y){e.applySettings({...e.settings,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}});return}te(e),e.sessionKey=r,ie(e,r),e.chatLoading=!0,e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:r,lastActiveSessionKey:r,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}}),e.loadAssistantIdentity(),z(e,r),N(e).then(()=>{e.resetChatScroll(),F(e,!0)}),e.loadSessionResources(),K(e),zt()}}}
|
|
1795
1809
|
@dragend=${w=>{w.target.classList.remove("dragging")}}
|
|
1796
|
-
@dragover=${w=>{w.preventDefault(),w.dataTransfer.dropEffect="move";const
|
|
1810
|
+
@dragover=${w=>{w.preventDefault(),w.dataTransfer.dropEffect="move";const T=w.currentTarget,A=T.getBoundingClientRect(),x=A.left+A.width/2;w.clientX<x?(T.classList.add("drop-left"),T.classList.remove("drop-right")):(T.classList.add("drop-right"),T.classList.remove("drop-left"))}}
|
|
1797
1811
|
@dragleave=${w=>{w.currentTarget.classList.remove("drop-left","drop-right")}}
|
|
1798
|
-
@drop=${w=>{w.preventDefault();const
|
|
1799
|
-
title=${
|
|
1812
|
+
@drop=${w=>{w.preventDefault();const T=parseInt(w.dataTransfer.getData("text/plain")),A=p;if(T===A)return;const x=e.settings.openTabs.slice(),[S]=x.splice(T,1);x.splice(A,0,S),e.applySettings({...e.settings,openTabs:x}),w.currentTarget.classList.remove("drop-left","drop-right")}}
|
|
1813
|
+
title=${k}
|
|
1800
1814
|
>
|
|
1801
|
-
${
|
|
1815
|
+
${Y?d`
|
|
1802
1816
|
<input
|
|
1803
1817
|
type="text"
|
|
1804
1818
|
draggable="false"
|
|
@@ -1806,18 +1820,18 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1806
1820
|
.value=${g?.label??g?.displayName??""}
|
|
1807
1821
|
@click=${w=>w.stopPropagation()}
|
|
1808
1822
|
@dblclick=${w=>w.stopPropagation()}
|
|
1809
|
-
@blur=${async w=>{const
|
|
1810
|
-
@keydown=${async w=>{if(w.key==="Enter"){w.preventDefault();const
|
|
1823
|
+
@blur=${async w=>{const T=w.target;if(T._committedByEnter)return;const A=T.value.trim();e.editingTabKey=null;const x=g?.label??g?.displayName??"";if(A!==x){A?se.set(r,A):se.delete(r),e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.map(M=>M.key===r?{...M,label:A||void 0,displayName:A||void 0}:M)});const S=await Qe(e,r,{label:A||null,displayName:A||null});K(e);const L=S.ok&&S.canonicalKey!==r?S.canonicalKey:r,ne=r===e.sessionKey;e.applySettings({...e.settings,...S.ok&&S.canonicalKey!==r&&e.settings.openTabs.includes(r)?{openTabs:e.settings.openTabs.map(M=>M===r?S.canonicalKey:M)}:{},tabLastViewed:{...e.settings.tabLastViewed,[L]:Date.now()},...ne&&S.ok&&S.canonicalKey!==r?{sessionKey:S.canonicalKey,lastActiveSessionKey:S.canonicalKey}:{}}),ne&&S.ok&&S.canonicalKey!==r&&(e.sessionKey=S.canonicalKey,z(e,S.canonicalKey))}else e.applySettings({...e.settings,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}})}}
|
|
1824
|
+
@keydown=${async w=>{if(w.key==="Enter"){w.preventDefault();const T=w.target;T._committedByEnter=!0;const A=T.value.trim();e.editingTabKey=null;const x=g?.label??g?.displayName??"";if(A!==x){A?se.set(r,A):se.delete(r),e.sessionsResult?.sessions&&(e.sessionsResult={...e.sessionsResult,sessions:e.sessionsResult.sessions.map(M=>M.key===r?{...M,label:A||void 0,displayName:A||void 0}:M)});const S=await Qe(e,r,{label:A||null,displayName:A||null});K(e);const L=S.ok&&S.canonicalKey!==r?S.canonicalKey:r,ne=r===e.sessionKey;e.applySettings({...e.settings,...S.ok&&S.canonicalKey!==r&&e.settings.openTabs.includes(r)?{openTabs:e.settings.openTabs.map(M=>M===r?S.canonicalKey:M)}:{},tabLastViewed:{...e.settings.tabLastViewed,[L]:Date.now()},...ne&&S.ok&&S.canonicalKey!==r?{sessionKey:S.canonicalKey,lastActiveSessionKey:S.canonicalKey}:{}}),ne&&S.ok&&S.canonicalKey!==r&&(e.sessionKey=S.canonicalKey,z(e,S.canonicalKey))}else e.applySettings({...e.settings,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}})}else w.key==="Escape"&&(w.preventDefault(),e.editingTabKey=null)}}
|
|
1811
1825
|
/>
|
|
1812
1826
|
`:(()=>{let w=null;return d`
|
|
1813
1827
|
<span
|
|
1814
1828
|
class="session-tab__name"
|
|
1815
1829
|
draggable="false"
|
|
1816
|
-
@click=${
|
|
1817
|
-
@dblclick=${
|
|
1818
|
-
>${
|
|
1830
|
+
@click=${T=>{T.stopPropagation(),w&&clearTimeout(w),w=setTimeout(()=>{w=null,e.editingTabKey!==r&&(r===e.sessionKey?e.applySettings({...e.settings,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}}):(te(e),e.sessionKey=r,e.chatPrivateMode=!!e.privateSessions?.has(r),ie(e,r),e.chatLoading=!0,e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:r,lastActiveSessionKey:r,tabLastViewed:{...e.settings.tabLastViewed,[r]:Date.now()}}),e.loadAssistantIdentity(),z(e,r),N(e).then(()=>{e.resetChatScroll(),F(e,!0)}),e.loadSessionResources(),K(e)))},250)}}
|
|
1831
|
+
@dblclick=${T=>{T.preventDefault(),T.stopPropagation(),w&&(clearTimeout(w),w=null),e.editingTabKey=r;const A=T.target.closest(".session-tab"),x=S=>{const L=S.target;A&&!A.contains(L)&&(e.editingTabKey=null,document.removeEventListener("mousedown",x,!0))};document.addEventListener("mousedown",x,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const S=A?.querySelector(".session-tab__name-input");S&&(S.focus(),S.select())})})}}
|
|
1832
|
+
>${k}</span>
|
|
1819
1833
|
`})()}
|
|
1820
|
-
${e.privateSessions?.has(r)?(()=>{const w=e.privateSessions.get(r),
|
|
1834
|
+
${e.privateSessions?.has(r)?(()=>{const w=e.privateSessions.get(r),T=Math.max(0,w-Date.now()),A=Math.floor(T/36e5),x=Math.floor(T%36e5/6e4),S=A>0?`${A}h ${x}m`:`${x}m`;return d`
|
|
1821
1835
|
<span class="session-tab__private" title="Private session — expires in ${S}" style="font-size: 9px; margin-left: 3px; color: #f59e0b; white-space: nowrap;"
|
|
1822
1836
|
>🔒 ${S}</span
|
|
1823
1837
|
>
|
|
@@ -1831,7 +1845,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1831
1845
|
${d`
|
|
1832
1846
|
<button
|
|
1833
1847
|
class="session-tab__close"
|
|
1834
|
-
@click=${w=>{if(w.stopPropagation(),e.privateSessions?.has(r)){e._destroyPrivateSession(r);return}const
|
|
1848
|
+
@click=${w=>{if(w.stopPropagation(),e.privateSessions?.has(r)){e._destroyPrivateSession(r);return}const T=e.settings.openTabs.filter(S=>S!==r),A=r===e.sessionKey,x=T[0]||O;e.applySettings({...e.settings,openTabs:T,...A?{sessionKey:x,lastActiveSessionKey:x}:{}}),A&&(e.sessionKey=x,e.sessionResources=[],z(e,x),N(e).then(()=>{e.resetChatScroll(),F(e,!0)}),e.loadSessionResources())}}
|
|
1835
1849
|
title=${e.privateSessions?.has(r)?"Destroy private session":"Close tab"}
|
|
1836
1850
|
>×</button>
|
|
1837
1851
|
`}
|
|
@@ -1847,7 +1861,7 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1847
1861
|
<span class="reconnect-spinner"></span>
|
|
1848
1862
|
Reconnecting${e.reconnectAttempt>1?` (attempt ${e.reconnectAttempt})`:""}...
|
|
1849
1863
|
</div>`:e.lastError?d`<div class="pill ${e.lastError.startsWith("✓")?"success":"danger"}">${e.lastError}</div>`:v}
|
|
1850
|
-
${s?
|
|
1864
|
+
${s?vi(e):v}
|
|
1851
1865
|
${v}
|
|
1852
1866
|
</div>
|
|
1853
1867
|
</section>
|
|
@@ -1873,30 +1887,30 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1873
1887
|
</div>
|
|
1874
1888
|
</div>`:v}
|
|
1875
1889
|
|
|
1876
|
-
${e.tab==="workspaces"?(
|
|
1890
|
+
${e.tab==="workspaces"?(pe("gm-work"),d`<gm-work></gm-work>`):v}
|
|
1877
1891
|
|
|
1878
|
-
${e.tab==="team"?(
|
|
1892
|
+
${e.tab==="team"?(pe("gm-team"),d`<gm-team .host=${e}></gm-team>`):v}
|
|
1879
1893
|
|
|
1880
|
-
${e.tab==="today"||e.tab==="my-day"?(
|
|
1894
|
+
${e.tab==="today"||e.tab==="my-day"?(pe("gm-today"),d`<gm-today
|
|
1881
1895
|
@today-open-file=${r=>{e.handleOpenFile(r.detail.path)}}
|
|
1882
1896
|
@today-decision-open-chat=${r=>{const p=r.detail.item;e.setTab("chat");const g=p?.title??r.detail.id;e.setChatMessage(`Let's discuss the agent result for: "${g}". What are your thoughts on the output?`)}}
|
|
1883
|
-
@today-inbox-open-chat=${r=>{const p=r.detail.item;if(p?.coworkSessionId)
|
|
1897
|
+
@today-inbox-open-chat=${r=>{const p=r.detail.item;if(p?.coworkSessionId)H.emit("chat-navigate",{sessionKey:`agent:ally:${p.coworkSessionId}`,tab:"chat"});else if(p?.sessionId)H.emit("chat-navigate",{sessionKey:p.sessionId,tab:"chat"});else{e.setTab("chat");const g=p?.title??r.detail.itemId;e.setChatMessage(`Let's review the inbox item: "${g}". Can you summarize the key points and what actions I should take?`)}}}
|
|
1884
1898
|
@today-open-proof=${r=>{e.handleOpenProofDoc(r.detail.slug)}}
|
|
1885
1899
|
></gm-today>`):v}
|
|
1886
1900
|
|
|
1887
|
-
${e.tab==="channels"?
|
|
1901
|
+
${e.tab==="channels"?Ia({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:r=>V(e,r),onWhatsAppStart:r=>e.handleWhatsAppStart(r),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(r,p)=>ke(e,r,p),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(r,p)=>e.handleNostrProfileEdit(r,p),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(r,p)=>e.handleNostrProfileFieldChange(r,p),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):v}
|
|
1888
1902
|
|
|
1889
|
-
${e.tab==="instances"?
|
|
1903
|
+
${e.tab==="instances"?Ra({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>$t(e)}):v}
|
|
1890
1904
|
|
|
1891
|
-
${e.tab==="sessions"?
|
|
1905
|
+
${e.tab==="sessions"?Ea({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,archivedSessions:e.archivedSessions,archivedSessionsLoading:e.archivedSessionsLoading,archivedSessionsExpanded:e.archivedSessionsExpanded,onFiltersChange:r=>{e.sessionsFilterActive=r.activeMinutes,e.sessionsFilterLimit=r.limit,e.sessionsIncludeGlobal=r.includeGlobal,e.sessionsIncludeUnknown=r.includeUnknown},onRefresh:()=>{K(e),lt(e)},onPatch:async(r,p)=>{const g=await Qe(e,r,p);if(g.ok&&g.canonicalKey!==r&&e.settings.openTabs.includes(r)){const y=e.settings.openTabs.map(k=>k===r?g.canonicalKey:k),b=r===e.sessionKey;e.applySettings({...e.settings,openTabs:y,tabLastViewed:{...e.settings.tabLastViewed,[g.canonicalKey]:e.settings.tabLastViewed[r]??Date.now()},...b?{sessionKey:g.canonicalKey,lastActiveSessionKey:g.canonicalKey}:{}}),b&&(e.sessionKey=g.canonicalKey,z(e,g.canonicalKey))}},onDelete:r=>Gi(e,r),onArchive:r=>zi(e,r),onUnarchive:r=>Vi(e,r),onToggleArchived:()=>{e.archivedSessionsExpanded=!e.archivedSessionsExpanded,e.archivedSessionsExpanded&&e.archivedSessions.length===0&<(e)},onAutoArchive:()=>Hi(e)}):v}
|
|
1892
1906
|
|
|
1893
|
-
${e.tab==="cron"?
|
|
1907
|
+
${e.tab==="cron"?Da({loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(r=>r.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,onFormChange:r=>e.cronForm={...e.cronForm,...r},onRefresh:()=>e.loadCron(),onAdd:()=>Zi(e),onToggle:(r,p)=>Xi(e,r,p),onRun:r=>Ji(e,r),onRemove:r=>Yi(e,r),onLoadRuns:r=>Qi(e,r)}):v}
|
|
1894
1908
|
|
|
1895
|
-
${e.tab==="skills"?
|
|
1909
|
+
${e.tab==="skills"?Oa({loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,subTab:e.skillsSubTab,godmodeSkills:e.godmodeSkills??null,godmodeSkillsLoading:e.godmodeSkillsLoading??!1,expandedSkills:e.expandedSkills??new Set,onFilterChange:r=>e.skillsFilter=r,onRefresh:()=>{Xn(e,{clearMessages:!0}),ct(e)},onToggle:(r,p)=>sa(e,r,p),onEdit:(r,p)=>na(e,r,p),onSaveKey:r=>ta(e,r),onInstall:(r,p,g)=>ea(e,r,p,g),onSubTabChange:r=>{e.skillsSubTab=r,r==="godmode"&&!e.godmodeSkills&&ct(e)},onToggleExpand:r=>{const p=new Set(e.expandedSkills);p.has(r)?p.delete(r):p.add(r),e.expandedSkills=p}}):v}
|
|
1896
1910
|
|
|
1897
|
-
${e.tab==="agents"?
|
|
1911
|
+
${e.tab==="agents"?Ka({loading:e.rosterLoading,error:e.rosterError,roster:e.rosterData??[],filter:e.rosterFilter??"",expandedAgents:e.expandedAgents??new Set,onFilterChange:r=>e.rosterFilter=r,onRefresh:()=>ia(e),onToggleExpand:r=>{const p=new Set(e.expandedAgents);p.has(r)?p.delete(r):p.add(r),e.expandedAgents=p}}):v}
|
|
1898
1912
|
|
|
1899
|
-
${e.tab==="nodes"?
|
|
1913
|
+
${e.tab==="nodes"?Na({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>Ne(e),onDevicesRefresh:()=>Fe(e),onDeviceApprove:r=>fa(e,r),onDeviceReject:r=>ma(e,r),onDeviceRotate:(r,p,g)=>pa(e,{deviceId:r,role:p,scopes:g}),onDeviceRevoke:(r,p)=>ha(e,{deviceId:r,role:p}),onLoadConfig:()=>oe(e),onLoadExecApprovals:()=>{const r=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Zn(e,r)},onBindDefault:r=>{r?ke(e,["tools","exec","node"],r):en(e,["tools","exec","node"])},onBindAgent:(r,p)=>{const g=["agents","list",r,"tools","exec","node"];p?ke(e,g,p):en(e,g)},onSaveBindings:()=>rt(e),onExecApprovalsTargetChange:(r,p)=>{e.execApprovalsTarget=r,e.execApprovalsTargetNodeId=p,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:r=>{e.execApprovalsSelectedAgent=r},onExecApprovalsPatch:(r,p)=>ra(e,r,p),onExecApprovalsRemove:r=>oa(e,r),onSaveExecApprovals:()=>{const r=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return aa(e,r)}}):v}
|
|
1900
1914
|
|
|
1901
1915
|
${e.tab==="chat"&&e.workspaceNeedsSetup&&!e.chatMessages?.length?d`
|
|
1902
1916
|
<div class="workspace-welcome-banner">
|
|
@@ -1922,23 +1936,23 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1922
1936
|
</div>
|
|
1923
1937
|
`:v}
|
|
1924
1938
|
|
|
1925
|
-
${e.tab==="chat"?
|
|
1939
|
+
${e.tab==="chat"?Td({basePath:e.basePath,sessionKey:e.sessionKey,onSessionKeyChange:r=>{te(e),e.sessionKey=r,ie(e,r),e.chatLoading=!0,e.chatMessages=[],e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:r,lastActiveSessionKey:r}),e.loadAssistantIdentity(),N(e).then(()=>{e.resetChatScroll(),F(e,!0)}),Ke(e),e.loadSessionResources(),_e(e)},thinkingLevel:e.chatThinkingLevel,showThinking:a,loading:e.chatLoading,sending:e.chatSending,sendingSessionKey:e.chatSendingSessionKey,compactionStatus:e.compactionStatus,assistantAvatarUrl:l,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:n,error:e.lastError,sessions:e.sessionsResult,focusMode:i,onRefresh:()=>(e.resetToolStream(),e.loadSessionResources(),_e(e),Promise.all([N(e),Ke(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:r=>e.handleChatScroll(r),onDraftChange:r=>e.chatMessage=r,attachments:e.chatAttachments,onAttachmentsChange:r=>e.chatAttachments=r,showToast:(r,p)=>e.showToast(r,p),onSend:r=>e.handleSendChat(void 0,{queue:r}),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onCompact:()=>{e.handleCompactChat()},onQueueRemove:r=>e.removeQueuedMessage(r),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,sidebarMimeType:e.sidebarMimeType,sidebarFilePath:e.sidebarFilePath,sidebarTitle:e.sidebarTitle,sidebarMode:e.sidebarMode,sidebarProofSlug:e.sidebarProofSlug,sidebarProofUrl:e.sidebarProofUrl,sidebarProofHtml:e.sidebarProofHtml,splitRatio:e.splitRatio,onOpenSidebar:(r,p)=>e.handleOpenSidebar(r,p),onMessageLinkClick:r=>e.handleOpenMessageFileLink(r),onCloseSidebar:()=>e.handleCloseSidebar(),onOpenProof:r=>{e.handleOpenProofDoc(r)},onOpenFile:r=>e.handleOpenFile(r),onSplitRatioChange:r=>e.handleSplitRatioChange(r),onPushToDrive:(r,p)=>e.handlePushToDrive(r,p),driveAccounts:e.driveAccounts,showDrivePicker:e.showDrivePicker,driveUploading:e.driveUploading,onToggleDrivePicker:()=>e.handleToggleDrivePicker(),onImageClick:(r,p,g)=>e.handleImageClick(r,p,g),resolveImageUrl:(r,p)=>Vs(e.sessionKey,r,p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,userName:e.userName,userAvatar:e.userAvatar,currentModel:e.currentModel,availableModels:e.availableModels,modelPickerOpen:e.modelPickerOpen,onToggleModelPicker:()=>{const r=!e.modelPickerOpen;e.modelPickerOpen=r,r&&setTimeout(()=>{const p=()=>{e.modelPickerOpen=!1,document.removeEventListener("click",p,!0)};document.addEventListener("click",p,!0)},0)},onSwitchModel:r=>{(async()=>{const{switchModelFromChat:p}=await _(async()=>{const{switchModelFromChat:g}=await Promise.resolve().then(()=>ii);return{switchModelFromChat:g}},void 0,import.meta.url);await p(e,r)})()},currentToolName:e.currentToolName,currentToolInfo:e.currentToolInfo,privateMode:e.chatPrivateMode,onTogglePrivateMode:()=>e.handlePrivateModeToggle(),isWorking:e.workingSessions.has(e.sessionKey),showScrollButton:!e.chatUserNearBottom,showNewMessages:e.chatNewMessagesBelow,onScrollToBottom:()=>{const r=document.querySelector(".chat-thread");r&&(r.scrollTo({top:r.scrollHeight,behavior:"smooth"}),e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1)},onClearNewMessages:()=>{e.chatNewMessagesBelow=!1,e.chatUserNearBottom=!0},allyPanelOpen:e.allyPanelOpen??!1,allyProps:e.allyPanelOpen?{allyName:e.assistantName,allyAvatar:e.assistantAvatar??null,open:!0,messages:e.allyMessages??[],stream:e.allyStream??null,draft:e.allyDraft??"",sending:e.allySending??!1,isWorking:e.allyWorking??!1,unreadCount:0,connected:e.connected,compact:!0,attachments:e.allyAttachments??[],onToggle:()=>e.handleAllyToggle(),onDraftChange:r=>e.handleAllyDraftChange(r),onSend:()=>e.handleAllySend(),onOpenFullChat:()=>e.handleAllyOpenFull(),onAttachmentsChange:r=>e.handleAllyAttachmentsChange(r),onAction:(r,p,g,y)=>e.handleAllyAction(r,p,g,y),onHitlAction:(r,p,g)=>e.handleHitlAction(r,p,g)}:null,sessionResources:e.sessionResources,sessionResourcesCollapsed:e.sessionResourcesCollapsed,onToggleSessionResources:()=>e.handleToggleSessionResources(),onSessionResourceClick:r=>e.handleSessionResourceClick(r),onViewAllResources:()=>e.handleViewAllResources()}):v}
|
|
1926
1940
|
|
|
1927
|
-
${e.tab==="guardrails"?
|
|
1941
|
+
${e.tab==="guardrails"?Fa({connected:e.connected,loading:e.guardrailsLoading,data:e.guardrailsData,showAddForm:e.guardrailsShowAddForm,onToggle:(r,p)=>e.handleGuardrailToggle(r,p),onThresholdChange:(r,p,g)=>e.handleGuardrailThresholdChange(r,p,g),onCustomToggle:(r,p)=>e.handleCustomGuardrailToggle(r,p),onCustomDelete:r=>e.handleCustomGuardrailDelete(r),onToggleAddForm:()=>e.handleToggleGuardrailAddForm(),onOpenAllyChat:r=>{e.handleAllyToggle(),r&&e.handleAllyDraftChange(r)}}):v}
|
|
1928
1942
|
|
|
1929
|
-
${e.tab==="overview"?
|
|
1943
|
+
${e.tab==="overview"?Fd({connected:e.connected,updateStatus:e.updateStatus,updateLoading:e.updateLoading,updateRunning:e.updateRunning,pluginUpdateRunning:e.pluginUpdateRunning,updateError:e.lastError,onCheckUpdates:()=>{_(()=>Promise.resolve().then(()=>Gr),void 0,import.meta.url).then(r=>r.checkForUpdates(e))},onUpdateOpenclaw:()=>tn(e),onUpdatePlugin:()=>la(e)}):v}
|
|
1930
1944
|
|
|
1931
|
-
${e.tab==="trust"?
|
|
1945
|
+
${e.tab==="trust"?Ua({connected:e.connected,loading:e.trustTrackerLoading,data:e.trustTrackerData,onAddWorkflow:r=>e.handleTrustAddWorkflow(r),onRemoveWorkflow:r=>e.handleTrustRemoveWorkflow(r),onRefresh:()=>e.handleTrustLoad(),guardrailsData:e.guardrailsData,consciousnessStatus:e.consciousnessStatus,sessionsCount:t,gatewayUptimeMs:e.hello?.snapshot?.uptimeMs??null,onDailyRate:(r,p)=>e.handleDailyRate(r,p),updateStatus:e.updateStatus?{openclawUpdateAvailable:e.updateStatus.openclawUpdateAvailable,pluginUpdateAvailable:e.updateStatus.pluginUpdateAvailable,openclawVersion:e.updateStatus.openclawVersion,pluginVersion:e.updateStatus.pluginVersion,openclawLatest:e.updateStatus.openclawLatest,pluginLatest:e.updateStatus.pluginLatest}:null}):v}
|
|
1932
1946
|
|
|
1933
|
-
${e.tab==="memory"||e.tab==="second-brain"?(
|
|
1947
|
+
${e.tab==="memory"||e.tab==="second-brain"?(pe("gm-brain"),d`<gm-brain></gm-brain>`):v}
|
|
1934
1948
|
|
|
1935
|
-
${e.tab==="dashboards"?(
|
|
1949
|
+
${e.tab==="dashboards"?(pe("gm-dashboards"),d`<gm-dashboards></gm-dashboards>`):v}
|
|
1936
1950
|
|
|
1937
|
-
${
|
|
1951
|
+
${as(e.tab)?(()=>{const r=(e.customTabs??[]).find(p=>p.slug===e.tab);return r?bc({manifest:r,data:e.customTabData??{},loading:e.customTabLoading??!1,errors:e.customTabErrors??{}}):d`<div class="tab-view"><p>Custom tab not found.</p></div>`})():v}
|
|
1938
1952
|
|
|
1939
|
-
${e.tab==="connections"?(
|
|
1953
|
+
${e.tab==="connections"?(pe("gm-connections"),d`<gm-connections></gm-connections>`):v}
|
|
1940
1954
|
|
|
1941
|
-
${e.tab==="config"?d`${
|
|
1955
|
+
${e.tab==="config"?d`${Ba({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection,activeSubsection:e.configActiveSubsection,onRawChange:r=>{e.configRaw=r},onFormModeChange:r=>e.configFormMode=r,onFormPatch:(r,p)=>ke(e,r,p),onSearchChange:r=>e.configSearchQuery=r,onSectionChange:r=>{e.configActiveSection=r,e.configActiveSubsection=null},onSubsectionChange:r=>e.configActiveSubsection=r,onReload:()=>oe(e),onSave:()=>rt(e),onApply:()=>da(e),onUpdate:()=>tn(e),userName:e.userName||"",userAvatar:e.userAvatar,onUserProfileUpdate:(r,p)=>e.handleUpdateUserProfile(r,p),onModelSwitch:(r,p)=>ca(e,r,p),secrets:e.secrets??[],secretsLoading:e.secretsLoading??!1,onSecretsRefresh:()=>Xs(e),webFetchProvider:e.webFetchProvider??"default",webFetchLoading:e.webFetchLoading??!1,onWebFetchChange:r=>Zs(e,r),searchProvider:e.searchProvider??"tavily",searchExaConfigured:e.searchExaConfigured??!1,searchTavilyConfigured:e.searchTavilyConfigured??!1,searchLoading:e.searchLoading??!1,onSearchProviderChange:r=>ei(e,r)})}
|
|
1942
1956
|
<div style="margin-top: 24px; padding: 16px; border-top: 1px solid var(--border, #333);">
|
|
1943
1957
|
<button
|
|
1944
1958
|
class="btn btn--secondary"
|
|
@@ -1951,38 +1965,38 @@ Deletes the session entry and archives its transcript.`)&&(e.sessionsResult?.ses
|
|
|
1951
1965
|
</div>
|
|
1952
1966
|
`:v}
|
|
1953
1967
|
|
|
1954
|
-
${e.tab==="debug"?
|
|
1968
|
+
${e.tab==="debug"?Wa({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:r=>e.debugCallMethod=r,onCallParamsChange:r=>e.debugCallParams=r,onRefresh:()=>Ue(e),onCall:()=>ua(e)}):v}
|
|
1955
1969
|
|
|
1956
|
-
${e.tab==="logs"?
|
|
1970
|
+
${e.tab==="logs"?qa({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:r=>e.logsFilterText=r,onLevelToggle:(r,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[r]:p}},onToggleAutoFollow:r=>e.logsAutoFollow=r,onRefresh:()=>kt(e,{reset:!0}),onExport:(r,p)=>e.exportLogs(r,p),onScroll:r=>e.handleLogsScroll(r)}):v}
|
|
1957
1971
|
</main>
|
|
1958
1972
|
${v}
|
|
1959
|
-
${
|
|
1960
|
-
${
|
|
1961
|
-
${
|
|
1973
|
+
${ja(e)}
|
|
1974
|
+
${xd(e)}
|
|
1975
|
+
${Pd(e)}
|
|
1962
1976
|
${e.sidebarOpen&&e.tab!=="chat"?d`
|
|
1963
1977
|
<div class="global-document-viewer">
|
|
1964
1978
|
<div class="global-document-viewer__overlay" @click=${()=>e.handleCloseSidebar()}></div>
|
|
1965
1979
|
<div class="global-document-viewer__panel">
|
|
1966
|
-
${
|
|
1980
|
+
${Tt({content:e.sidebarContent??null,error:e.sidebarError??null,mimeType:e.sidebarMimeType??null,filePath:e.sidebarFilePath??null,title:e.sidebarTitle??null,onClose:()=>e.handleCloseSidebar(),onViewRawText:()=>{e.sidebarContent&&e.handleOpenSidebar(e.sidebarContent,{mimeType:"text/plain",filePath:e.sidebarFilePath,title:e.sidebarTitle})},onOpenFile:r=>e.handleOpenFile(r),onPushToDrive:(r,p)=>e.handlePushToDrive(r,p),driveAccounts:e.driveAccounts,showDrivePicker:e.showDrivePicker,driveUploading:e.driveUploading,onToggleDrivePicker:()=>e.handleToggleDrivePicker()})}
|
|
1967
1981
|
</div>
|
|
1968
1982
|
</div>
|
|
1969
1983
|
`:v}
|
|
1970
|
-
${
|
|
1971
|
-
${
|
|
1984
|
+
${Nd({toasts:e.toasts,onDismiss:r=>e.dismissToast(r)})}
|
|
1985
|
+
${Od(e.lightbox,{onClose:()=>e.handleLightboxClose(),onNav:r=>e.handleLightboxNav(r)})}
|
|
1972
1986
|
</div>
|
|
1973
|
-
`}async function
|
|
1987
|
+
`}async function Xt(e){if(!(!e.client||!e.connected)){e.trustTrackerLoading=!0;try{const[t,n]=await Promise.all([e.client.request("trust.dashboard",{}),e.client.request("trust.history",{limit:50})]);e.trustTrackerData={workflows:t.workflows,summaries:t.summaries,ratings:n.ratings,total:n.total,overallScore:t.overallScore,totalRatings:t.totalRatings,totalUses:t.totalUses,todayRating:t.todayRating??null,dailyAverage:t.dailyAverage??null,dailyStreak:t.dailyStreak??0,recentDaily:t.recentDaily??[]}}catch{e.trustTrackerData=null}finally{e.trustTrackerLoading=!1}}}async function Ci(e,t){if(!(!e.client||!e.connected))try{await e.client.request("trust.workflows.set",{workflows:t}),e.showToast("Workflows updated","success",2e3),await Xt(e)}catch(n){e.showToast("Failed to update workflows","error"),console.error("[TrustTracker] setWorkflows error:",n)}}async function Vd(e,t){const n=e.trustTrackerData?.workflows??[];if(n.length>=5){e.showToast("Maximum 5 workflows allowed","error");return}if(n.includes(t.trim())){e.showToast("Workflow already tracked","error");return}await Ci(e,[...n,t.trim()])}async function zd(e,t){const n=e.trustTrackerData?.workflows??[];await Ci(e,n.filter(s=>s!==t))}async function Gd(e,t,n){if(!(!e.client||!e.connected))try{await e.client.request("trust.dailyRate",{rating:t,...n?{note:n}:{}}),e.showToast(`Rated ${t}/10 today`,"success",2e3),await Xt(e)}catch(s){e.showToast("Failed to submit daily rating","error"),console.error("[TrustTracker] dailyRate error:",s)}}const Qd=6e4,zn=15,Gn=new Set;let Re=null;async function Qn(e){if(!(!e.client||!e.connected))try{const t=new Date,n=new Date(t.getTime()+zn*6e4+6e4),s=await e.client.request("calendar.events.range",{startDate:t.toISOString(),endDate:n.toISOString()});for(const i of s.events??[]){if(Gn.has(i.id))continue;const a=new Date(i.startTime),o=Math.round((a.getTime()-t.getTime())/6e4);if(o>0&&o<=zn){Gn.add(i.id);const l=a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}),c=i.location?` @ ${i.location}`:"",f=`${i.title} starts in ${o} min (${l})${c}`;e.showToast(f,"warning",0)}}}catch(t){console.warn("[MeetingNotify] Poll error:",t)}}function Yd(e){xi(),Qn(e),Re=setInterval(()=>{Qn(e)},Qd)}function xi(){Re&&(clearInterval(Re),Re=null)}let Jd=0;function Xd(e,t="info",n=3e3,s){return{id:`toast-${Date.now()}-${Jd++}`,message:e,type:t,duration:n,createdAt:Date.now(),action:s}}function Zd(e,t){return e.filter(n=>n.id!==t)}function eu(e,t){return[...e,t]}var tu=Object.defineProperty,nu=Object.getOwnPropertyDescriptor,h=(e,t,n,s)=>{for(var i=s>1?void 0:s?nu(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&tu(t,n,i),i};function ot(){return Or()}function Le(){return Nr()}function su(){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 iu(e,t){let n=e.trim();if(!n)return null;if(n.startsWith("Read HEARTBEAT.md")||n.startsWith("Read CONSCIOUSNESS.md")||/^System:\s*\[\d{4}-\d{2}-\d{2}/.test(n)||n==="NO_REPLY"||n.startsWith(`NO_REPLY
|
|
1974
1988
|
`)||/^#\s*(?:🧠|\w+ Consciousness)/i.test(n)||n.startsWith("# WORKING.md")||n.startsWith("# MISTAKES.md"))return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;if(/(?:VERIFIED|FIXED|NEW):\s/.test(n)&&/✅|🟡|☑/.test(n)&&n.length>300)return console.debug("[Ally] Filtered message (verification dump):",t,n.substring(0,100)),null;if(/^###\s*(?:Onboarding Philosophy|Self-Surgery Problem|Open Architecture)/i.test(n))return console.debug("[Ally] Filtered message (system block):",t,n.substring(0,100)),null;if(/^\[GodMode Context:[^\]]*\]\s*$/.test(n))return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;if(n=n.replace(/^(?:HEARTBEAT_OK|CONSCIOUSNESS_OK)\s*/i,"").trim(),n=n.replace(/^Deep work window is yours\.\s*/i,"").trim(),!n)return null;if(/^\w+\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(n)&&n.length>200||/^##\s*Your Team\s*\(Agent Roster\)/i.test(n)&&n.indexOf(`
|
|
1975
1989
|
|
|
1976
|
-
## `)===-1)return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;if(/^##?\s*Persistence Protocol/i.test(n)||/^You are resourceful and thorough\.\s*Your job is to GET THE JOB DONE/i.test(n)||/^##?\s*Core (?:Behaviors|Principles)/i.test(n)||/^##?\s*Your Role as \w+/i.test(n))return console.debug("[Ally] Filtered message (persona leak):",t,n.substring(0,100)),null;const s=n.toLowerCase();if(["persistence protocol","core principles:","core behaviors","your role as ","be diligent first time","exhaust reasonable options","assume capability exists","elite executive assistant","consciousness context","working context","enforcement:","internal system context injected by godmode"].filter(o=>s.includes(o)).length>=2)return console.debug("[Ally] Filtered message (multi-signal system leak):",t,n.substring(0,100)),null;if(/^(?:ID\s+START\s+END\s+SUMMARY)/i.test(n))return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;const a=n.match(/\b[\w.-]+\.(?:json\b|db\b|html\b|log\b|flag\b|jsonl\b|bak\b|css\b|js\b|ts\b|md\b|txt\b)/gi);return a&&a.length>=8&&a.join(" ").length>n.length*.4?(console.debug("[Ally] Filtered message (file listing dump):",t,n.substring(0,100)),null):n}const
|
|
1990
|
+
## `)===-1)return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;if(/^##?\s*Persistence Protocol/i.test(n)||/^You are resourceful and thorough\.\s*Your job is to GET THE JOB DONE/i.test(n)||/^##?\s*Core (?:Behaviors|Principles)/i.test(n)||/^##?\s*Your Role as \w+/i.test(n))return console.debug("[Ally] Filtered message (persona leak):",t,n.substring(0,100)),null;const s=n.toLowerCase();if(["persistence protocol","core principles:","core behaviors","your role as ","be diligent first time","exhaust reasonable options","assume capability exists","elite executive assistant","consciousness context","working context","enforcement:","internal system context injected by godmode"].filter(o=>s.includes(o)).length>=2)return console.debug("[Ally] Filtered message (multi-signal system leak):",t,n.substring(0,100)),null;if(/^(?:ID\s+START\s+END\s+SUMMARY)/i.test(n))return console.debug("[Ally] Filtered message:",t,n.substring(0,100)),null;const a=n.match(/\b[\w.-]+\.(?:json\b|db\b|html\b|log\b|flag\b|jsonl\b|bak\b|css\b|js\b|ts\b|md\b|txt\b)/gi);return a&&a.length>=8&&a.join(" ").length>n.length*.4?(console.debug("[Ally] Filtered message (file listing dump):",t,n.substring(0,100)),null):n}const Yn=new Set(["chat","today","workspaces","work","data","overview","channels","instances","sessions","cron","skills","nodes","config","debug","logs","my-day"]),au=["path","filePath","file","workspacePath"];let u=class extends ts{constructor(){super(...arguments),this._ctx=za(),this.settings=wl(),this.password="",this.tab="chat",this.onboarding=su(),this.connected=!1,this.reconnecting=!1,this.reconnectAttempt=0,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.sessionPickerClickOutsideHandler=null,this.sessionSearchClickOutsideHandler=null,this.assistantName=ot().name,this.assistantAvatar=ot().avatar,this.assistantAgentId=ot().agentId??null,this.userName=Le().name,this.userAvatar=Le().avatar,this.currentModel=null,this.availableModels=[],this.modelPickerOpen=!1,this.modelCacheTs=0,this.sessionKey=this.settings.sessionKey,this.sessionPickerOpen=!1,this.sessionPickerPosition=null,this.sessionPickerSearch="",this.sessionSearchOpen=!1,this.sessionSearchPosition=null,this.sessionSearchQuery="",this.sessionSearchResults=[],this.sessionSearchLoading=!1,this.profilePopoverOpen=!1,this.profileEditName="",this.profileEditAvatar="",this.editingTabKey=null,this.navDrawerOpen=!1,this.closeNavDrawer=()=>{this.navDrawerOpen=!1},this.chatLoading=!1,this.chatSending=!1,this.chatSendingSessionKey=null,this.chatMessage="",this.chatDrafts={},this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.currentToolName=null,this.currentToolInfo=null,this.workingSessions=new Set,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.sidebarMimeType=null,this.sidebarFilePath=null,this.sidebarTitle=null,this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null,this.sidebarProofHtml=null,this.splitRatio=this.settings.splitRatio,this.lightbox=$i(),this.driveAccounts=[],this.showDrivePicker=!1,this.driveUploading=!1,this.updateStatus=null,this.updateLoading=!1,this.updateError=null,this.updateLastChecked=null,this.updatePollInterval=null,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.pendingGatewayUrl=null,this.gatewayRestartPending=!1,this.gatewayRestartBusy=!1,this.deployPanelOpen=!1,this.configLoading=!1,this.configRaw=`{
|
|
1977
1991
|
}
|
|
1978
|
-
`,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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.archivedSessions=[],this.archivedSessionsLoading=!1,this.archivedSessionsExpanded=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...sc},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.workspaceNeedsSetup=!1,this.onboardingPhase=0,this.onboardingData=null,this.onboardingActive=!1,this.wizardActive=!1,this.wizardState=null,this.showSetupTab=!1,this.setupBarDismissed=!1,this.setupProgress=null,this.setupCapabilities=null,this.setupCapabilitiesLoading=!1,this.setupQuickDone=!1,this.onboardingIntegrations=null,this.onboardingCoreProgress=null,this.onboardingExpandedCard=null,this.onboardingLoadingGuide=null,this.onboardingActiveGuide=null,this.onboardingTestingId=null,this.onboardingTestResult=null,this.onboardingConfigValues={},this.onboardingProgress=null,this.allyPanelOpen=!1,this.allyMessages=[],this.allyStream=null,this.allyDraft="",this.allyUnread=0,this.allySending=!1,this.allyWorking=!1,this.allyAttachments=[],this.chatPrivateMode=!1,this.privateSessions=new Map,this._privateSessionTimer=null,this.dynamicSlots={},this.sessionResources=[],this.sessionResourcesCollapsed=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillsSubTab="godmode",this.godmodeSkills=null,this.godmodeSkillsLoading=!1,this.expandedSkills=new Set,this.rosterData=[],this.rosterLoading=!1,this.rosterError=null,this.rosterFilter="",this.expandedAgents=new Set,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={...nc},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.toasts=[],this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatUserNearBottom=!0,this.chatIsAutoScrolling=!1,this.chatNewMessagesBelow=!1,this.consciousnessStatus="idle",this.trustTrackerData=null,this.trustTrackerLoading=!1,this.guardrailsData=null,this.guardrailsLoading=!1,this.guardrailsShowAddForm=!1,this.secrets=[],this.secretsLoading=!1,this.webFetchProvider="default",this.webFetchLoading=!1,this.searchProvider="tavily",this.searchExaConfigured=!1,this.searchTavilyConfigured=!1,this.searchLoading=!1,this.customTabs=[],this.customTabData={},this.customTabLoading=!1,this.customTabErrors={},this.dashboardPreviousSessionKey=null,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.refreshSessionsAfterChat=!1,this.basePath="",this.popStateHandler=()=>Ql(this),this.keydownHandler=()=>{},this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._eventBusUnsubs=[]}createRenderRoot(){return this}connectedCallback(){if(super.connectedCallback(),this.settings.userName)this.userName=this.settings.userName;else{const e=Me();this.userName=e.name}if(this.settings.userAvatar)this.userAvatar=this.settings.userAvatar;else{const e=Me();this.userAvatar=e.avatar}vc(this),lu(this),this._restorePrivateSessions(),this._eventBusUnsubs.push(z.on("chat-navigate",e=>{e.sessionKey&&e.sessionKey!==this.sessionKey&&(e.sessionKey==="new"?this.sessionKey=`webchat-${Date.now()}`:this.sessionKey=e.sessionKey),e.tab==="chat"&&this.setTab("chat"),e.message&&(this.chatMessage=e.message)}))}firstUpdated(){bc(this)}disconnectedCallback(){Di(),this._stopPrivateSessionTimer();for(const e of this._eventBusUnsubs)e();this._eventBusUnsubs=[],wc(this),super.disconnectedCallback()}updated(e){_c(this,e),this._syncContext()}_syncContext(){const e=this._ctx;e.connected===this.connected&&e.reconnecting===this.reconnecting&&e.sessionKey===this.sessionKey&&e.assistantName===this.assistantName&&e.assistantAvatar===this.assistantAvatar&&e.userName===this.userName&&e.userAvatar===this.userAvatar&&e.theme===this.theme&&e.themeResolved===this.themeResolved&&e.settings===this.settings&&e.basePath===this.basePath&&e.gateway===this.client||(this._ctx={connected:this.connected,reconnecting:this.reconnecting,sessionKey:this.sessionKey,assistantName:this.assistantName,assistantAvatar:this.assistantAvatar,userName:this.userName,userAvatar:this.userAvatar,theme:this.theme,themeResolved:this.themeResolved,settings:this.settings,basePath:this.basePath,gateway:this.client,send:(t,n)=>this.client?.request(t,n)??Promise.reject(new Error("Not connected")),setTab:t=>this.setTab(t),addToast:(t,n)=>this.showToast(t,n??"info"),openSidebar:t=>this.handleOpenSidebar(t.content,{title:t.title,mimeType:t.mimeType,filePath:t.filePath}),closeSidebar:()=>this.handleCloseSidebar()})}connect(){ze(this)}handleChatScroll(e){ys(this,e)}handleLogsScroll(e){vs(this,e)}exportLogs(e,t){bs(e,t)}resetToolStream(){It(this),this.sessionResources=[]}resetChatScroll(){ke(this)}async loadAssistantIdentity(){await Es(this)}applySettings(e){te(this,e)}setTab(e){Bl(this,e)}setTheme(e,t){jl(this,e,t)}async loadOverview(){await vi(this)}async loadCron(){await Gt(this)}async handleAbortChat(){await Qt(this)}async handleConsciousnessFlush(){if(!(!this.client||this.consciousnessStatus==="loading")){this.consciousnessStatus="loading";try{await this.client.request("godmode.consciousness.flush",{}),this.consciousnessStatus="ok"}catch{this.consciousnessStatus="error"}setTimeout(()=>{this.consciousnessStatus!=="loading"&&(this.consciousnessStatus="idle")},3e3)}}async handleTrustLoad(){await sn(this)}async handleTrustAddWorkflow(e){await iu(this,e)}async handleTrustRemoveWorkflow(e){await au(this,e)}async handleDailyRate(e,t){await ou(this,e,t)}async handleGuardrailsLoad(){const{loadGuardrails:e}=await _(async()=>{const{loadGuardrails:t}=await import("./ctrl-settings-COfcdhha.js").then(n=>n.ae);return{loadGuardrails:t}},[],import.meta.url);await e(this)}async handleGuardrailToggle(e,t){const{toggleGuardrail:n}=await _(async()=>{const{toggleGuardrail:s}=await import("./ctrl-settings-COfcdhha.js").then(i=>i.ae);return{toggleGuardrail:s}},[],import.meta.url);await n(this,e,t)}async handleGuardrailThresholdChange(e,t,n){const{updateGuardrailThreshold:s}=await _(async()=>{const{updateGuardrailThreshold:i}=await import("./ctrl-settings-COfcdhha.js").then(a=>a.ae);return{updateGuardrailThreshold:i}},[],import.meta.url);await s(this,e,t,n)}async handleCustomGuardrailToggle(e,t){const{toggleCustomGuardrail:n}=await _(async()=>{const{toggleCustomGuardrail:s}=await import("./ctrl-settings-COfcdhha.js").then(i=>i.ae);return{toggleCustomGuardrail:s}},[],import.meta.url);await n(this,e,t)}async handleCustomGuardrailDelete(e){const{deleteCustomGuardrail:t}=await _(async()=>{const{deleteCustomGuardrail:n}=await import("./ctrl-settings-COfcdhha.js").then(s=>s.ae);return{deleteCustomGuardrail:n}},[],import.meta.url);await t(this,e)}async handleCustomGuardrailAdd(e){const{addCustomGuardrailFromUI:t}=await _(async()=>{const{addCustomGuardrailFromUI:n}=await import("./ctrl-settings-COfcdhha.js").then(s=>s.ae);return{addCustomGuardrailFromUI:n}},[],import.meta.url);await t(this,e),this.guardrailsShowAddForm=!1}handleToggleGuardrailAddForm(){this.guardrailsShowAddForm=!this.guardrailsShowAddForm}async handleMissionControlOpenSession(e){const t=this.settings.openTabs.includes(e)?this.settings.openTabs:[...this.settings.openTabs,e];this.applySettings({...this.settings,openTabs:t,sessionKey:e,lastActiveSessionKey:e,tabLastViewed:{...this.settings.tabLastViewed,[e]:Date.now()}}),this.sessionKey=e,this.setTab("chat"),this.chatMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.resetToolStream(),this.resetChatScroll(),this.loadAssistantIdentity();const{loadChatHistory:n}=await _(async()=>{const{loadChatHistory:s}=await Promise.resolve().then(()=>fe);return{loadChatHistory:s}},void 0,import.meta.url);await n(this),this.loadSessionResources()}async handleMissionControlOpenTaskSession(e){if(!(!this.client||!this.connected))try{const t=await this.client.request("tasks.openSession",{taskId:e});if(t?.sessionId){if(t.task?.title){const{autoTitleCache:n}=await _(async()=>{const{autoTitleCache:s}=await import("./ctrl-settings-COfcdhha.js").then(i=>i.ad);return{autoTitleCache:s}},[],import.meta.url);n.set(t.sessionId,t.task.title)}await this.handleMissionControlOpenSession(t.sessionId),t.queueOutput&&this.chatMessages.length===0&&await this.seedSessionWithAgentOutput(t.task?.title??"task",t.queueOutput,t.agentPrompt??void 0)}}catch(t){console.error("[MissionControl] Failed to open task session:",t),this.showToast("Failed to open session","error")}}async handleMissionControlStartQueueItem(e){await this.handleMissionControlOpenTaskSession(e)}async handleSwarmViewProofDoc(e){return this.handleOpenProofDoc(e)}async handleSwarmViewRunLog(e){if(!(!this.client||!this.connected))try{const t=await this.client.request("godmode.delegation.runLog",{queueItemId:e});t?.content?this.handleOpenSidebar(t.content,{mimeType:t.mimeType??"text/markdown",title:t.title??"Agent Logs"}):this.showToast("No logs available","error")}catch{this.showToast("Failed to load agent logs","error")}}async handleAllyAction(e,t,n,s){if(e==="navigate"&&t)this.setTab(t);else if(e==="rpc"&&n&&this.client)try{await this.client.request(n,s??{}),this.showToast("Done","success",2e3)}catch(i){console.error("[Ally] Action RPC failed:",i),this.showToast("Action failed","error")}}async handleHitlAction(e,t,n){if(this.client)try{await this.client.request("queue.hitl.respond",{checkpointId:e,action:t,modifiedInstructions:n});const s=this;s.hitlCheckpoints&&(s.hitlCheckpoints=s.hitlCheckpoints.filter(a=>a.id!==e));const i=t==="continue"?"Approved":t==="abort"?"Aborted":"Modified";this.showToast(`Checkpoint ${i.toLowerCase()}`,"success",2e3),this.requestUpdate()}catch(s){console.error("[HITL] Respond failed:",s),this.showToast("Failed to respond to checkpoint","error")}}handleAllyToggle(){this.allyPanelOpen=!this.allyPanelOpen,this.allyPanelOpen&&(this.allyUnread=0,this._loadAllyHistory().then(()=>{this._scrollAllyToBottom(),requestAnimationFrame(()=>this._scrollAllyToBottom())}))}handleAllyDraftChange(e){this.allyDraft=e}handleAllyAttachmentsChange(e){this.allyAttachments=e}async handleAllySend(){const e=this.allyDraft.trim(),t=this.allyAttachments;if(!e&&t.length===0||this.allySending)return;const n=yo(this);let s=e?`${n}
|
|
1992
|
+
`,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.pluginUpdateRunning=!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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.archivedSessions=[],this.archivedSessionsLoading=!1,this.archivedSessionsExpanded=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Hl},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.workspaceNeedsSetup=!1,this.onboardingPhase=0,this.onboardingData=null,this.onboardingActive=!1,this.wizardActive=!1,this.wizardState=null,this.showSetupTab=!1,this.setupBarDismissed=!1,this.setupProgress=null,this.setupCapabilities=null,this.setupCapabilitiesLoading=!1,this.setupQuickDone=!1,this.onboardingIntegrations=null,this.onboardingCoreProgress=null,this.onboardingExpandedCard=null,this.onboardingLoadingGuide=null,this.onboardingActiveGuide=null,this.onboardingTestingId=null,this.onboardingTestResult=null,this.onboardingConfigValues={},this.onboardingProgress=null,this.allyPanelOpen=!1,this.allyMessages=[],this.allyStream=null,this.allyDraft="",this.allyUnread=0,this.allySending=!1,this.allyWorking=!1,this.allyAttachments=[],this.chatPrivateMode=!1,this.privateSessions=new Map,this._privateSessionTimer=null,this.dynamicSlots={},this.sessionResources=[],this.sessionResourcesCollapsed=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillsSubTab="godmode",this.godmodeSkills=null,this.godmodeSkillsLoading=!1,this.expandedSkills=new Set,this.rosterData=[],this.rosterLoading=!1,this.rosterError=null,this.rosterFilter="",this.expandedAgents=new Set,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={...jl},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.toasts=[],this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatUserNearBottom=!0,this.chatIsAutoScrolling=!1,this.chatNewMessagesBelow=!1,this.consciousnessStatus="idle",this.trustTrackerData=null,this.trustTrackerLoading=!1,this.guardrailsData=null,this.guardrailsLoading=!1,this.guardrailsShowAddForm=!1,this.secrets=[],this.secretsLoading=!1,this.webFetchProvider="default",this.webFetchLoading=!1,this.searchProvider="tavily",this.searchExaConfigured=!1,this.searchTavilyConfigured=!1,this.searchLoading=!1,this.customTabs=[],this.customTabData={},this.customTabLoading=!1,this.customTabErrors={},this.dashboardPreviousSessionKey=null,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.refreshSessionsAfterChat=!1,this.basePath="",this.popStateHandler=()=>Kl(this),this.keydownHandler=()=>{},this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._eventBusUnsubs=[]}createRenderRoot(){return this}connectedCallback(){if(super.connectedCallback(),this.settings.userName)this.userName=this.settings.userName;else{const e=Le();this.userName=e.name}if(this.settings.userAvatar)this.userAvatar=this.settings.userAvatar;else{const e=Le();this.userAvatar=e.avatar}oc(this),Yd(this),this._restorePrivateSessions(),this._eventBusUnsubs.push(H.on("chat-navigate",e=>{let t=this.sessionKey;if(e.sessionKey&&e.sessionKey!==this.sessionKey){e.sessionKey==="new"?t=`webchat-${Date.now()}`:t=e.sessionKey,this.sessionKey=t;const n=t.toLowerCase();!(n==="main"||n==="agent:main:main"||n.endsWith(":main"))&&!this.settings.openTabs.includes(t)&&this.applySettings({...this.settings,openTabs:[...this.settings.openTabs,t],sessionKey:t,lastActiveSessionKey:t,tabLastViewed:{...this.settings.tabLastViewed,[t]:Date.now()}})}e.tab==="chat"&&this.setTab("chat"),e.message&&(this.chatMessage=e.message)}))}firstUpdated(){rc(this)}disconnectedCallback(){xi(),this._stopPrivateSessionTimer();for(const e of this._eventBusUnsubs)e();this._eventBusUnsubs=[],lc(this),super.disconnectedCallback()}updated(e){dc(this,e),this._syncContext()}_syncContext(){const e=this._ctx;e.connected===this.connected&&e.reconnecting===this.reconnecting&&e.sessionKey===this.sessionKey&&e.assistantName===this.assistantName&&e.assistantAvatar===this.assistantAvatar&&e.userName===this.userName&&e.userAvatar===this.userAvatar&&e.theme===this.theme&&e.themeResolved===this.themeResolved&&e.settings===this.settings&&e.basePath===this.basePath&&e.gateway===this.client||(this._ctx={connected:this.connected,reconnecting:this.reconnecting,sessionKey:this.sessionKey,assistantName:this.assistantName,assistantAvatar:this.assistantAvatar,userName:this.userName,userAvatar:this.userAvatar,theme:this.theme,themeResolved:this.themeResolved,settings:this.settings,basePath:this.basePath,gateway:this.client,send:(t,n)=>this.client?.request(t,n)??Promise.reject(new Error("Not connected")),setTab:t=>this.setTab(t),addToast:(t,n)=>this.showToast(t,n??"info"),openSidebar:t=>this.handleOpenSidebar(t.content,{title:t.title,mimeType:t.mimeType,filePath:t.filePath}),closeSidebar:()=>this.handleCloseSidebar()})}connect(){He(this)}handleChatScroll(e){us(this,e)}handleLogsScroll(e){hs(this,e)}exportLogs(e,t){ps(e,t)}resetToolStream(){Pt(this),this.sessionResources=[]}resetChatScroll(){Te(this)}async loadAssistantIdentity(){await xs(this)}applySettings(e){Q(this,e)}setTab(e){Ml(this,e)}setTheme(e,t){Il(this,e,t)}async loadOverview(){await ui(this)}async loadCron(){await qt(this)}async handleAbortChat(){await jt(this)}async handleConsciousnessFlush(){if(!(!this.client||this.consciousnessStatus==="loading")){this.consciousnessStatus="loading";try{await this.client.request("godmode.consciousness.flush",{}),this.consciousnessStatus="ok"}catch{this.consciousnessStatus="error"}setTimeout(()=>{this.consciousnessStatus!=="loading"&&(this.consciousnessStatus="idle")},3e3)}}async handleTrustLoad(){await Xt(this)}async handleTrustAddWorkflow(e){await Vd(this,e)}async handleTrustRemoveWorkflow(e){await zd(this,e)}async handleDailyRate(e,t){await Gd(this,e,t)}async handleGuardrailsLoad(){const{loadGuardrails:e}=await _(async()=>{const{loadGuardrails:t}=await import("./ctrl-settings-nG144v_G.js").then(n=>n.ae);return{loadGuardrails:t}},[],import.meta.url);await e(this)}async handleGuardrailToggle(e,t){const{toggleGuardrail:n}=await _(async()=>{const{toggleGuardrail:s}=await import("./ctrl-settings-nG144v_G.js").then(i=>i.ae);return{toggleGuardrail:s}},[],import.meta.url);await n(this,e,t)}async handleGuardrailThresholdChange(e,t,n){const{updateGuardrailThreshold:s}=await _(async()=>{const{updateGuardrailThreshold:i}=await import("./ctrl-settings-nG144v_G.js").then(a=>a.ae);return{updateGuardrailThreshold:i}},[],import.meta.url);await s(this,e,t,n)}async handleCustomGuardrailToggle(e,t){const{toggleCustomGuardrail:n}=await _(async()=>{const{toggleCustomGuardrail:s}=await import("./ctrl-settings-nG144v_G.js").then(i=>i.ae);return{toggleCustomGuardrail:s}},[],import.meta.url);await n(this,e,t)}async handleCustomGuardrailDelete(e){const{deleteCustomGuardrail:t}=await _(async()=>{const{deleteCustomGuardrail:n}=await import("./ctrl-settings-nG144v_G.js").then(s=>s.ae);return{deleteCustomGuardrail:n}},[],import.meta.url);await t(this,e)}async handleCustomGuardrailAdd(e){const{addCustomGuardrailFromUI:t}=await _(async()=>{const{addCustomGuardrailFromUI:n}=await import("./ctrl-settings-nG144v_G.js").then(s=>s.ae);return{addCustomGuardrailFromUI:n}},[],import.meta.url);await t(this,e),this.guardrailsShowAddForm=!1}handleToggleGuardrailAddForm(){this.guardrailsShowAddForm=!this.guardrailsShowAddForm}async handleMissionControlOpenSession(e){const t=this.settings.openTabs.includes(e)?this.settings.openTabs:[...this.settings.openTabs,e];this.applySettings({...this.settings,openTabs:t,sessionKey:e,lastActiveSessionKey:e,tabLastViewed:{...this.settings.tabLastViewed,[e]:Date.now()}}),this.sessionKey=e,this.setTab("chat"),this.chatMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.resetToolStream(),this.resetChatScroll(),this.loadAssistantIdentity();const{loadChatHistory:n}=await _(async()=>{const{loadChatHistory:s}=await Promise.resolve().then(()=>me);return{loadChatHistory:s}},void 0,import.meta.url);await n(this),this.loadSessionResources()}async handleMissionControlOpenTaskSession(e){if(!(!this.client||!this.connected))try{const t=await this.client.request("tasks.openSession",{taskId:e});if(t?.sessionId){if(t.task?.title){const{autoTitleCache:n}=await _(async()=>{const{autoTitleCache:s}=await import("./ctrl-settings-nG144v_G.js").then(i=>i.ad);return{autoTitleCache:s}},[],import.meta.url);n.set(t.sessionId,t.task.title)}await this.handleMissionControlOpenSession(t.sessionId),t.queueOutput&&this.chatMessages.length===0&&await this.seedSessionWithAgentOutput(t.task?.title??"task",t.queueOutput,t.agentPrompt??void 0)}}catch(t){console.error("[MissionControl] Failed to open task session:",t),this.showToast("Failed to open session","error")}}async handleMissionControlStartQueueItem(e){await this.handleMissionControlOpenTaskSession(e)}async handleSwarmViewProofDoc(e){return this.handleOpenProofDoc(e)}async handleSwarmViewRunLog(e){if(!(!this.client||!this.connected))try{const t=await this.client.request("godmode.delegation.runLog",{queueItemId:e});t?.content?this.handleOpenSidebar(t.content,{mimeType:t.mimeType??"text/markdown",title:t.title??"Agent Logs"}):this.showToast("No logs available","error")}catch{this.showToast("Failed to load agent logs","error")}}async handleAllyAction(e,t,n,s){if(e==="navigate"&&t)this.setTab(t);else if(e==="rpc"&&n&&this.client)try{await this.client.request(n,s??{}),this.showToast("Done","success",2e3)}catch(i){console.error("[Ally] Action RPC failed:",i),this.showToast("Action failed","error")}}async handleHitlAction(e,t,n){if(this.client)try{await this.client.request("queue.hitl.respond",{checkpointId:e,action:t,modifiedInstructions:n});const s=this;s.hitlCheckpoints&&(s.hitlCheckpoints=s.hitlCheckpoints.filter(a=>a.id!==e));const i=t==="continue"?"Approved":t==="abort"?"Aborted":"Modified";this.showToast(`Checkpoint ${i.toLowerCase()}`,"success",2e3),this.requestUpdate()}catch(s){console.error("[HITL] Respond failed:",s),this.showToast("Failed to respond to checkpoint","error")}}handleAllyToggle(){this.allyPanelOpen=!this.allyPanelOpen,this.allyPanelOpen&&(this.allyUnread=0,this._loadAllyHistory().then(()=>{this._scrollAllyToBottom(),requestAnimationFrame(()=>this._scrollAllyToBottom())}))}handleAllyDraftChange(e){this.allyDraft=e}handleAllyAttachmentsChange(e){this.allyAttachments=e}async handleAllySend(){const e=this.allyDraft.trim(),t=this.allyAttachments;if(!e&&t.length===0||this.allySending)return;const n=co(this);let s=e?`${n}
|
|
1979
1993
|
|
|
1980
|
-
${e}`:n;this.allyDraft="",this.allyAttachments=[],this.allySending=!0,this.allyMessages=[...this.allyMessages,{role:"user",content:e||"(image)",timestamp:Date.now()}];try{let i;if(t.length>0){const c=[];for(const
|
|
1994
|
+
${e}`:n;this.allyDraft="",this.allyAttachments=[],this.allySending=!0,this.allyMessages=[...this.allyMessages,{role:"user",content:e||"(image)",timestamp:Date.now()}];try{let i;if(t.length>0){const c=[];for(const f of t){if(!f.dataUrl)continue;const r=f.dataUrl.match(/^data:([^;]+);base64,(.+)$/);if(!r)continue;const[,p,g]=r;p.startsWith("image/")&&c.push({type:"image",mimeType:p,content:g,fileName:f.fileName})}if(c.length>0){i=c;try{await this.client?.request("images.cache",{images:c.map(f=>({data:f.content,mimeType:f.mimeType,fileName:f.fileName})),sessionKey:O})}catch{}}}const a=`ally-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await this.client?.request("sessions.patch",{key:O,lastChannel:"webchat"})}catch{}await this.client?.request("agent",{sessionKey:O,message:s,deliver:!1,channel:"webchat",idempotencyKey:a,attachments:i}),this.allyWorking=!0;const o=this.allyMessages[this.allyMessages.length-1]?.content,l=setInterval(async()=>{if(!this.allyWorking){clearInterval(l);return}try{await this._loadAllyHistory();const c=this.allyMessages[this.allyMessages.length-1];c&&c.role==="assistant"&&c.content!==o&&(this.allyWorking=!1,this.allyStream=null,clearInterval(l),this._scrollAllyToBottom())}catch{}},5e3);setTimeout(()=>clearInterval(l),12e4)}catch(i){const a=i instanceof Error?i.message:String(i);console.error("[Ally] Failed to send ally message:",a),this.allyMessages=[...this.allyMessages,{role:"assistant",content:`*Send failed: ${a}*`,timestamp:Date.now()}]}finally{this.allySending=!1}}handleAllyOpenFull(){this.allyPanelOpen=!1,this.setTab("chat"),this.applySettings({...this.settings,sessionKey:O,lastActiveSessionKey:O,tabLastViewed:{...this.settings.tabLastViewed,[O]:Date.now()}}),this.sessionKey=O,this.chatMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.resetToolStream(),this.resetChatScroll(),this.loadAssistantIdentity(),_(async()=>{const{loadChatHistory:e}=await Promise.resolve().then(()=>me);return{loadChatHistory:e}},void 0,import.meta.url).then(({loadChatHistory:e})=>e(this)),this.loadSessionResources()}_scrollAllyToBottom(){this.updateComplete.then(()=>{requestAnimationFrame(()=>{const e=this.renderRoot?.querySelector?.(".ally-panel, .ally-inline")??document.querySelector(".ally-panel, .ally-inline");if(!e)return;const t=e.querySelector(".ally-panel__messages");t&&(t.scrollTop=t.scrollHeight)})})}async _loadAllyHistory(){try{const e=await this.client?.request("chat.history",{sessionKey:O,limit:100});if(e?.messages){const{extractText:t,formatApiError:n}=await _(async()=>{const{extractText:i,formatApiError:a}=await Promise.resolve().then(()=>qo);return{extractText:i,formatApiError:a}},void 0,import.meta.url);this.allyMessages=e.messages.map(i=>{const a=i.role??"assistant",o=a.toLowerCase();if(o==="tool"||o==="toolresult"||o==="tool_result"||o==="function"||o==="system")return null;const l=i;if(l.toolCallId||l.tool_call_id||l.toolName||l.tool_name)return null;if(Array.isArray(i.content)){const p=i.content;if(!p.some(y=>{const b=(typeof y.type=="string"?y.type:"").toLowerCase();return(b==="text"||b==="")&&typeof y.text=="string"&&y.text.trim().length>0})&&p.some(b=>{const k=(typeof b.type=="string"?b.type:"").toLowerCase();return k==="tool_use"||k==="tool_result"||k==="toolresult"||k==="tooluse"}))return null}let c=t(i);if(!c)return null;const f=n(c);if(f&&(c=f),c=c.replace(/^\[GodMode Context:[^\]]*\]\s*/i,"").trim(),!c)return null;const r=iu(c,a);return r?{role:o==="user"?"user":"assistant",content:r,timestamp:i.timestamp}:null}).filter(i=>i!==null);const s=[];for(const i of this.allyMessages){const a=s[s.length-1];a&&a.role===i.role&&a.content===i.content||s.push(i)}this.allyMessages=s}}catch{}}async seedSessionWithAgentOutput(e,t,n){if(!this.client||!this.connected)return;this.handleOpenSidebar(t,{title:`Agent Output: ${e}`,filePath:null,mimeType:null});const s=t.match(/## Summary\n([\s\S]*?)(?=\n## |$)/),i=s?s[1].trim().split(`
|
|
1981
1995
|
`).slice(0,3).join(`
|
|
1982
1996
|
`):"Output available in sidebar.",a=[`Agent completed **${e}**.`,"",i,"","Full output is in the sidebar. What would you like to do?"].join(`
|
|
1983
|
-
`);try{const{sendChatMessage:o}=await _(async()=>{const{sendChatMessage:l}=await Promise.resolve().then(()=>fe);return{sendChatMessage:l}},void 0,import.meta.url);await o(this,a)}catch(o){console.error("[Session] Failed to seed session with agent output:",o)}}async handleMissionControlAddToQueue(e,t){if(!(!this.client||!this.connected))try{await this.client.request("queue.add",{type:e,title:t,priority:"normal"}),this.showToast("Added to queue","success",2e3)}catch{this.showToast("Failed to add to queue","error")}}removeQueuedMessage(e){Si(this,e)}async handleSendChat(e,t){await _i(this,e,t)}handleToggleSessionPicker(){this.sessionPickerOpen=!this.sessionPickerOpen}handleToggleSessionSearch(e){if(!this.sessionSearchOpen&&e){const n=e.currentTarget.getBoundingClientRect();this.sessionSearchPosition={top:n.bottom+8,right:window.innerWidth-n.right}}this.sessionSearchOpen=!this.sessionSearchOpen,this.sessionSearchOpen||(this.sessionSearchQuery="",this.sessionSearchResults=[])}async handleSessionSearchQuery(e){if(this.sessionSearchQuery=e,!e.trim()){this.sessionSearchResults=[];return}if(this.client){this.sessionSearchLoading=!0;try{const t=await this.client.request("sessions.searchContent",{query:e.trim(),limit:20});this.sessionSearchResults=t.results}catch(t){console.error("Session search failed:",t),this.sessionSearchResults=[]}finally{this.sessionSearchLoading=!1}}}handleSelectSession(e){this.sessionPickerOpen=!1,this.sessionSearchOpen=!1,this.sessionSearchQuery="",this.sessionSearchResults=[]}async handleWhatsAppStart(e){await no(this,e)}async handleWhatsAppWait(){await so(this)}async handleWhatsAppLogout(){await io(this)}async handleChannelConfigSave(){await ao(this)}async handleChannelConfigReload(){await oo(this)}async handleCompactChat(){if(!this.connected){this.showToast("Cannot compact: not connected","error");return}if(!this.sessionKey){this.showToast("Cannot compact: no active session","error");return}this.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null};try{await this.handleSendChat("/compact")}catch(e){this.compactionStatus=null,console.error("Compaction failed:",e),this.showToast("Compaction failed","error")}}injectCompactionSummary(e,t){const n={role:"system",content:e,timestamp:Date.now(),isCompactionSummary:!0,keptMessages:t};this.chatMessages=[n,...this.chatMessages]}handleNostrProfileEdit(e,t){lo(this,e,t)}handleNostrProfileCancel(){co(this)}handleNostrProfileFieldChange(e,t){uo(this,e,t)}async handleNostrProfileSave(){await ho(this)}async handleNostrProfileImport(){await fo(this)}handleNostrProfileToggleAdvanced(){po(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}}}handleGatewayUrlConfirm(){const e=this.pendingGatewayUrl;e&&(this.pendingGatewayUrl=null,te(this,{...this.settings,gatewayUrl:e}),this.connect())}handleGatewayUrlCancel(){this.pendingGatewayUrl=null}handleGatewayRestartClick(){this.gatewayRestartPending=!0}async handleGatewayRestartConfirm(){if(!(!this.client||this.gatewayRestartBusy)){this.gatewayRestartBusy=!0;try{await this.client.request("godmode.gateway.restart")}catch{}finally{this.gatewayRestartBusy=!1,this.gatewayRestartPending=!1}}}handleGatewayRestartCancel(){this.gatewayRestartPending=!1}handleDeployPanelToggle(){this.deployPanelOpen=!this.deployPanelOpen}async handleDeployDismiss(){if(this.client){try{await this.client.request("godmode.deploy.dismiss")}catch{}this.deployPanelOpen=!1,this.updateStatus&&(this.updateStatus={...this.updateStatus,pendingDeploy:null})}}handleOpenSidebar(e,t={}){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarMimeType=t.mimeType?.trim()||null,this.sidebarFilePath=t.filePath?.trim()||null,this.sidebarTitle=t.title?.trim()||null,this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.showDrivePicker=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarMimeType=null,this.sidebarFilePath=null,this.sidebarTitle=null,this.sidebarMode!=="proof"&&(this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null),this.sidebarCloseTimer=null)},200)}async handleOpenFile(e,t){if(!this.client||!this.connected){if(t){const s=e.split(".").pop()?.toLowerCase()??"",a={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",json5:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",html:"text/html",htm:"text/html"}[s]??null,o=e.split("/").pop()??e;this.showToast("Opening cached version (gateway offline)","warning"),this.handleOpenSidebar(t,{mimeType:a,filePath:e,title:o});return}this.showToast("Not connected to gateway","error");return}let n=e;if(!e.includes("/")&&!e.includes("\\")&&!e.startsWith("~"))try{n=(await this.client.request("files.resolve",{filename:e})).path}catch{}try{const s=await this.client.request("files.read",{path:n}),i=n.split(".").pop()?.toLowerCase()??"",o={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",json5:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",html:"text/html",htm:"text/html"}[i]??s.contentType??s.mime??null,l=n.split("/").pop()??n;this.handleOpenSidebar(s.content,{mimeType:o,filePath:n,title:l}),s.truncated&&this.showToast(`Opened truncated file: ${l}`,"warning")}catch(s){console.error("[Chat] Failed to open file via gateway:",s);const i=n.match(/\/inbox\/([^/]+)$/);if(i)try{const a=await fetch(`${this.basePath}/godmode/artifacts/${encodeURIComponent(i[1])}`);if(a.ok){const o=await a.text(),l=n.split(".").pop()?.toLowerCase()??"",m={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",html:"text/html",htm:"text/html"}[l]??a.headers.get("content-type")??null,r=n.split("/").pop()??n;this.handleOpenSidebar(o,{mimeType:m,filePath:n,title:r});return}}catch{}if(t){const a=e.split(".").pop()?.toLowerCase()??"",l={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",html:"text/html",htm:"text/html"}[a]??null,c=e.split("/").pop()??e;this.showToast("Opening cached version (file read failed)","warning"),this.handleOpenSidebar(t,{mimeType:l,filePath:e,title:c});return}this.showToast(`Failed to open file: ${e}`,"error")}}async handleToggleDrivePicker(){if(this.showDrivePicker){this.showDrivePicker=!1;return}if(this.driveAccounts.length===0)try{const e=await this.client?.request("files.listDriveAccounts",{});this.driveAccounts=e?.accounts??[]}catch{this.driveAccounts=[]}this.showDrivePicker=!0}async handlePushToDrive(e,t){if(!this.driveUploading){if(this.showDrivePicker=!1,this._pendingBatchPaths&&this._pendingBatchPaths.length>0){const n=this._pendingBatchPaths;this._pendingBatchPaths=void 0,await this._executeBatchDrive(n,t);return}this.driveUploading=!0;try{const n={filePath:e};t&&(n.account=t);const s=await this.client?.request("files.pushToDrive",n),i=t?` to ${t.split("@")[0]}`:"",a=s?.message??`Uploaded${i} to Google Drive`,o=s?.driveUrl;this.showToast(a,"success",o?8e3:5e3,o?{label:"View in Drive",url:o}:void 0)}catch(n){console.error("Push to Drive failed:",n);const s=n instanceof Error?n.message:typeof n=="object"&&n!==null&&"message"in n?String(n.message):"Unknown error";s.includes("GOG_NOT_FOUND")||s.includes("gog CLI not found")?this.showToast("Google Drive not configured. Install gog CLI: npm install -g gog-cli, then run: gog auth add <email> --services drive","warning",1e4):s.includes("GOG_AUTH")||s.includes("auth")&&s.includes("expired")?this.showToast("Google Drive auth expired. Re-authenticate: gog auth add <email> --services drive","warning",8e3):this.showToast(`Drive upload failed: ${s}`,"error",8e3)}finally{this.driveUploading=!1}}}async handleBatchPushToDrive(e){if(this.driveUploading||e.length===0)return;if(!this.driveAccounts||this.driveAccounts.length===0)try{const n=await this.client?.request("files.listDriveAccounts");this.driveAccounts=n?.accounts??[]}catch{}if(this.driveAccounts&&this.driveAccounts.length>1){this._pendingBatchPaths=e,this.showDrivePicker=!0;return}const t=this.driveAccounts?.[0]?.email;await this._executeBatchDrive(e,t)}async _executeBatchDrive(e,t){this.driveUploading=!0,this.showToast(`Uploading ${e.length} files to Drive...`,"info",0);try{const n={filePaths:e};t&&(n.account=t);const s=await this.client?.request("files.batchPushToDrive",n);this.dismissAllToasts();const i=s?.results?.filter(o=>o.success).length??0,a=s?.results?.length??e.length;i===a?this.showToast(`Uploaded ${i} files to Google Drive`,"success",5e3):this.showToast(`Uploaded ${i}/${a} files (${a-i} failed)`,"warning",8e3)}catch(n){this.dismissAllToasts();const s=n instanceof Error?n.message:"Unknown error";this.showToast(`Batch Drive upload failed: ${s}`,"error",8e3)}finally{this.driveUploading=!1,this._pendingBatchPaths=void 0}}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleImageClick(e,t,n){this.lightbox=qd(e,t,n)}handleLightboxClose(){this.lightbox=Bd()}handleLightboxNav(e){this.lightbox=jd(this.lightbox,e)}normalizeWorkspacePathCandidate(e,t={}){let n=e.trim();if(!n||n.startsWith("#"))return null;for(;n.startsWith("./");)n=n.slice(2);if(n=n.replaceAll("\\","/"),!t.allowAbsolute)for(;n.startsWith("/");)n=n.slice(1);return!n||n.includes("\0")?null:n}isAbsoluteFilesystemPath(e){return e.startsWith("/")||e.startsWith("~/")||/^[a-z]:[\\/]/i.test(e)}inferMimeTypeFromPath(e){if(!e)return null;const t=e.trim().toLowerCase();if(!t)return null;const n=t.split(".").pop()??"";return n?n==="md"||n==="markdown"||n==="mdx"?"text/markdown":n==="html"||n==="htm"?"text/html":n==="json"||n==="json5"?"application/json":n==="txt"||n==="text"||n==="log"?"text/plain":n==="svg"||n==="svgz"?"image/svg+xml":n==="avif"||n==="bmp"||n==="gif"||n==="heic"||n==="heif"||n==="jpeg"||n==="jpg"||n==="png"||n==="webp"?`image/${n==="jpg"?"jpeg":n}`:null:null}sidebarTitleForPath(e){const t=e.replaceAll("\\","/").trim();if(!t)return"Document";const n=t.split("/");return n[n.length-1]||t}async listWorkspaceIdsForPathResolution(){const e=[],t=new Set,n=s=>{if(typeof s!="string")return;const i=s.trim();!i||t.has(i)||(t.add(i),e.push(i))};n(this.selectedWorkspace?.id);for(const s of this.workspaces??[])n(s.id);if(e.length>0||!this.client||!this.connected)return e;try{const s=await this.client.request("workspaces.list",{});for(const i of s.workspaces??[])n(i.id)}catch{}return e}async openWorkspaceRelativeFileInViewer(e){if(!this.client||!this.connected)return!1;const t=await this.listWorkspaceIdsForPathResolution();for(const n of t)try{const s=await this.client.request("workspaces.readFile",{workspaceId:n,filePath:e});if(typeof s.content!="string")continue;return this.handleOpenSidebar(s.content,{mimeType:s.contentType??s.mime??this.inferMimeTypeFromPath(e),filePath:s.path??e,title:this.sidebarTitleForPath(e)}),!0}catch{}return!1}extractWorkspacePathCandidatesFromHref(e){const t=e.trim();if(!t)return[];const n=[],s=t.toLowerCase();if(s.startsWith("mailto:")||s.startsWith("tel:")||s.startsWith("javascript:")||s.startsWith("data:"))return[];if(t.startsWith("godmode-file://")){let m=t.slice(15);try{m=decodeURIComponent(m)}catch{}return n.push(m),n}if(t.startsWith("file://")){let m=t.slice(7);m.startsWith("/~/")&&(m="~"+m.slice(2));try{m=decodeURIComponent(m)}catch{}n.push(m);const r=[],p=new Set;for(const g of n){const y=this.normalizeWorkspacePathCandidate(g,{allowAbsolute:!0});!y||p.has(y)||(p.add(y),r.push(y))}return r}const i=/^[a-z][a-z0-9+.-]*:/i.test(t),a=/^[a-z]:[\\/]/i.test(t);(!i||a)&&n.push(t);let o=null;try{o=new URL(t,window.location.href)}catch{o=null}if(o&&/^https?:$/.test(o.protocol)&&o.origin===window.location.origin){for(const b of yu){const A=o.searchParams.get(b);A&&n.push(A)}const r=(t.split("#")[0]??"").split("?")[0]??"";r.length>0&&!r.startsWith("/")&&!r.includes("://")&&n.push(r);let g=o.pathname;this.basePath&&g.startsWith(`${this.basePath}/`)?g=g.slice(this.basePath.length):this.basePath&&g===this.basePath&&(g="");const y=g.startsWith("/")?g.slice(1):g;if(y){n.push(y);const b=y.indexOf("/");if(b>0){const A=y.slice(0,b).toLowerCase();ns.has(A)&&n.push(y.slice(b+1))}}if(g.startsWith("/")&&y){const b=y.split("/")[0]?.toLowerCase()??"";ns.has(b)||n.push(g)}}const l=[],c=new Set;for(const m of n){let r=m;try{r=decodeURIComponent(m)}catch{}const p=this.normalizeWorkspacePathCandidate(r,{allowAbsolute:!0});!p||c.has(p)||(c.add(p),l.push(p))}return l}async openWorkspaceFileInViewer(e){if(!this.client||!this.connected)return!1;const t=this.isAbsoluteFilesystemPath(e);if(!t&&await this.openWorkspaceRelativeFileInViewer(e))return!0;try{const n=await this.client.request("workspaces.readFile",{path:e});if(typeof n.content=="string")return this.handleOpenSidebar(n.content,{mimeType:n.contentType??n.mime??this.inferMimeTypeFromPath(e),filePath:n.path??e,title:this.sidebarTitleForPath(e)}),!0}catch{}if(!t)return!1;try{const n=await this.client.request("files.read",{path:e,maxSize:1e6});return typeof n.content!="string"?!1:(this.handleOpenSidebar(n.content,{mimeType:this.inferMimeTypeFromPath(e),filePath:e,title:this.sidebarTitleForPath(e)}),!0)}catch{return!1}}async handleOpenMessageFileLink(e){const t=this.extractWorkspacePathCandidatesFromHref(e);if(t.length===0)return!1;for(const n of t)if(await this.openWorkspaceFileInViewer(n))return!0;return!1}showToast(e,t="info",n=5e3,s){const i=du(e,t,n,s);this.toasts=pu(this.toasts,i),n>0&&window.setTimeout(()=>{this.dismissToast(i.id)},n)}dismissToast(e){this.toasts=uu(this.toasts,e)}dismissAllToasts(){this.toasts=[]}handlePrivateModeToggle(){if(this.chatPrivateMode){const e=this.sessionKey;this.chatPrivateMode=!1,this._destroyPrivateSession(e),this.showToast("Private session destroyed","info",2e3);return}this.chatPrivateMode=!0,this.setTab("chat"),_(async()=>{const{createNewSession:e}=await Promise.resolve().then(()=>ot);return{createNewSession:e}},void 0,import.meta.url).then(({createNewSession:e})=>{e(this);const t=Date.now()+1440*60*1e3;this.privateSessions=new Map(this.privateSessions).set(this.sessionKey,t),this._persistPrivateSessions(),this._startPrivateSessionTimer(),this.client&&this.connected&&this.client.request("session.setPrivate",{sessionKey:this.sessionKey,enabled:!0}).catch(()=>{}),this.chatMessages=[{role:"assistant",content:`This is a **private session**. Nothing will be saved to memory or logs.
|
|
1997
|
+
`);try{const{sendChatMessage:o}=await _(async()=>{const{sendChatMessage:l}=await Promise.resolve().then(()=>me);return{sendChatMessage:l}},void 0,import.meta.url);await o(this,a)}catch(o){console.error("[Session] Failed to seed session with agent output:",o)}}async handleMissionControlAddToQueue(e,t){if(!(!this.client||!this.connected))try{await this.client.request("queue.add",{type:e,title:t,priority:"normal"}),this.showToast("Added to queue","success",2e3)}catch{this.showToast("Failed to add to queue","error")}}removeQueuedMessage(e){mi(this,e)}async handleSendChat(e,t){await fi(this,e,t)}handleToggleSessionPicker(){this.sessionPickerOpen=!this.sessionPickerOpen}handleToggleSessionSearch(e){if(!this.sessionSearchOpen&&e){const n=e.currentTarget.getBoundingClientRect();this.sessionSearchPosition={top:n.bottom+8,right:window.innerWidth-n.right}}this.sessionSearchOpen=!this.sessionSearchOpen,this.sessionSearchOpen||(this.sessionSearchQuery="",this.sessionSearchResults=[])}async handleSessionSearchQuery(e){if(this.sessionSearchQuery=e,!e.trim()){this.sessionSearchResults=[];return}if(this.client){this.sessionSearchLoading=!0;try{const t=await this.client.request("sessions.searchContent",{query:e.trim(),limit:20});this.sessionSearchResults=t.results}catch(t){console.error("Session search failed:",t),this.sessionSearchResults=[]}finally{this.sessionSearchLoading=!1}}}handleSelectSession(e){this.sessionPickerOpen=!1,this.sessionSearchOpen=!1,this.sessionSearchQuery="",this.sessionSearchResults=[]}async handleWhatsAppStart(e){await Qa(this,e)}async handleWhatsAppWait(){await Ya(this)}async handleWhatsAppLogout(){await Ja(this)}async handleChannelConfigSave(){await Xa(this)}async handleChannelConfigReload(){await Za(this)}async handleCompactChat(){if(!this.connected){this.showToast("Cannot compact: not connected","error");return}if(!this.sessionKey){this.showToast("Cannot compact: no active session","error");return}this.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null};try{await this.handleSendChat("/compact")}catch(e){this.compactionStatus=null,console.error("Compaction failed:",e),this.showToast("Compaction failed","error")}}injectCompactionSummary(e,t){const n={role:"system",content:e,timestamp:Date.now(),isCompactionSummary:!0,keptMessages:t};this.chatMessages=[n,...this.chatMessages]}handleNostrProfileEdit(e,t){to(this,e,t)}handleNostrProfileCancel(){no(this)}handleNostrProfileFieldChange(e,t){so(this,e,t)}async handleNostrProfileSave(){await ao(this)}async handleNostrProfileImport(){await oo(this)}handleNostrProfileToggleAdvanced(){io(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}}}handleGatewayUrlConfirm(){const e=this.pendingGatewayUrl;e&&(this.pendingGatewayUrl=null,Q(this,{...this.settings,gatewayUrl:e}),this.connect())}handleGatewayUrlCancel(){this.pendingGatewayUrl=null}handleGatewayRestartClick(){this.gatewayRestartPending=!0}async handleGatewayRestartConfirm(){if(!(!this.client||this.gatewayRestartBusy)){this.gatewayRestartBusy=!0;try{await this.client.request("godmode.gateway.restart")}catch{}finally{this.gatewayRestartBusy=!1,this.gatewayRestartPending=!1}}}handleGatewayRestartCancel(){this.gatewayRestartPending=!1}handleDeployPanelToggle(){this.deployPanelOpen=!this.deployPanelOpen}async handleDeployDismiss(){if(this.client){try{await this.client.request("godmode.deploy.dismiss")}catch{}this.deployPanelOpen=!1,this.updateStatus&&(this.updateStatus={...this.updateStatus,pendingDeploy:null})}}handleOpenSidebar(e,t={}){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarMimeType=t.mimeType?.trim()||null,this.sidebarFilePath=t.filePath?.trim()||null,this.sidebarTitle=t.title?.trim()||null,this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.showDrivePicker=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarMimeType=null,this.sidebarFilePath=null,this.sidebarTitle=null,this.sidebarMode!=="proof"&&(this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null),this.sidebarCloseTimer=null)},200)}async handleOpenFile(e,t){if(!this.client||!this.connected){if(t){const s=e.split(".").pop()?.toLowerCase()??"",a={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",json5:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",html:"text/html",htm:"text/html"}[s]??null,o=e.split("/").pop()??e;this.showToast("Opening cached version (gateway offline)","warning"),this.handleOpenSidebar(t,{mimeType:a,filePath:e,title:o});return}this.showToast("Not connected to gateway","error");return}let n=e;if(!e.includes("/")&&!e.includes("\\")&&!e.startsWith("~"))try{n=(await this.client.request("files.resolve",{filename:e})).path}catch{}try{const s=await this.client.request("files.read",{path:n}),i=n.split(".").pop()?.toLowerCase()??"",o={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",json5:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",html:"text/html",htm:"text/html"}[i]??s.contentType??s.mime??null,l=n.split("/").pop()??n;this.handleOpenSidebar(s.content,{mimeType:o,filePath:n,title:l}),s.truncated&&this.showToast(`Opened truncated file: ${l}`,"warning")}catch(s){console.error("[Chat] Failed to open file via gateway:",s);const i=n.match(/\/inbox\/([^/]+)$/);if(i)try{const a=await fetch(`${this.basePath}/godmode/artifacts/${encodeURIComponent(i[1])}`);if(a.ok){const o=await a.text(),l=n.split(".").pop()?.toLowerCase()??"",f={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",html:"text/html",htm:"text/html"}[l]??a.headers.get("content-type")??null,r=n.split("/").pop()??n;this.handleOpenSidebar(o,{mimeType:f,filePath:n,title:r});return}}catch{}if(t){const a=e.split(".").pop()?.toLowerCase()??"",l={md:"text/markdown",markdown:"text/markdown",mdx:"text/markdown",json:"application/json",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",html:"text/html",htm:"text/html"}[a]??null,c=e.split("/").pop()??e;this.showToast("Opening cached version (file read failed)","warning"),this.handleOpenSidebar(t,{mimeType:l,filePath:e,title:c});return}this.showToast(`Failed to open file: ${e}`,"error")}}async handleToggleDrivePicker(){if(this.showDrivePicker){this.showDrivePicker=!1;return}if(this.driveAccounts.length===0)try{const e=await this.client?.request("files.listDriveAccounts",{});this.driveAccounts=e?.accounts??[]}catch{this.driveAccounts=[]}this.showDrivePicker=!0}async handlePushToDrive(e,t){if(!this.driveUploading){if(this.showDrivePicker=!1,this._pendingBatchPaths&&this._pendingBatchPaths.length>0){const n=this._pendingBatchPaths;this._pendingBatchPaths=void 0,await this._executeBatchDrive(n,t);return}this.driveUploading=!0;try{const n={filePath:e};t&&(n.account=t);const s=await this.client?.request("files.pushToDrive",n),i=t?` to ${t.split("@")[0]}`:"",a=s?.message??`Uploaded${i} to Google Drive`,o=s?.driveUrl;this.showToast(a,"success",o?8e3:5e3,o?{label:"View in Drive",url:o}:void 0)}catch(n){console.error("Push to Drive failed:",n);const s=n instanceof Error?n.message:typeof n=="object"&&n!==null&&"message"in n?String(n.message):"Unknown error";s.includes("GOG_NOT_FOUND")||s.includes("gog CLI not found")?this.showToast("Google Drive not configured. Install gog CLI: npm install -g gog-cli, then run: gog auth add <email> --services drive","warning",1e4):s.includes("GOG_AUTH")||s.includes("auth")&&s.includes("expired")?this.showToast("Google Drive auth expired. Re-authenticate: gog auth add <email> --services drive","warning",8e3):this.showToast(`Drive upload failed: ${s}`,"error",8e3)}finally{this.driveUploading=!1}}}async handleBatchPushToDrive(e){if(this.driveUploading||e.length===0)return;if(!this.driveAccounts||this.driveAccounts.length===0)try{const n=await this.client?.request("files.listDriveAccounts");this.driveAccounts=n?.accounts??[]}catch{}if(this.driveAccounts&&this.driveAccounts.length>1){this._pendingBatchPaths=e,this.showDrivePicker=!0;return}const t=this.driveAccounts?.[0]?.email;await this._executeBatchDrive(e,t)}async _executeBatchDrive(e,t){this.driveUploading=!0,this.showToast(`Uploading ${e.length} files to Drive...`,"info",0);try{const n={filePaths:e};t&&(n.account=t);const s=await this.client?.request("files.batchPushToDrive",n);this.dismissAllToasts();const i=s?.results?.filter(o=>o.success).length??0,a=s?.results?.length??e.length;i===a?this.showToast(`Uploaded ${i} files to Google Drive`,"success",5e3):this.showToast(`Uploaded ${i}/${a} files (${a-i} failed)`,"warning",8e3)}catch(n){this.dismissAllToasts();const s=n instanceof Error?n.message:"Unknown error";this.showToast(`Batch Drive upload failed: ${s}`,"error",8e3)}finally{this.driveUploading=!1,this._pendingBatchPaths=void 0}}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleImageClick(e,t,n){this.lightbox=Ld(e,t,n)}handleLightboxClose(){this.lightbox=Md()}handleLightboxNav(e){this.lightbox=Id(this.lightbox,e)}normalizeWorkspacePathCandidate(e,t={}){let n=e.trim();if(!n||n.startsWith("#"))return null;for(;n.startsWith("./");)n=n.slice(2);if(n=n.replaceAll("\\","/"),!t.allowAbsolute)for(;n.startsWith("/");)n=n.slice(1);return!n||n.includes("\0")?null:n}isAbsoluteFilesystemPath(e){return e.startsWith("/")||e.startsWith("~/")||/^[a-z]:[\\/]/i.test(e)}inferMimeTypeFromPath(e){if(!e)return null;const t=e.trim().toLowerCase();if(!t)return null;const n=t.split(".").pop()??"";return n?n==="md"||n==="markdown"||n==="mdx"?"text/markdown":n==="html"||n==="htm"?"text/html":n==="json"||n==="json5"?"application/json":n==="txt"||n==="text"||n==="log"?"text/plain":n==="svg"||n==="svgz"?"image/svg+xml":n==="avif"||n==="bmp"||n==="gif"||n==="heic"||n==="heif"||n==="jpeg"||n==="jpg"||n==="png"||n==="webp"?`image/${n==="jpg"?"jpeg":n}`:null:null}sidebarTitleForPath(e){const t=e.replaceAll("\\","/").trim();if(!t)return"Document";const n=t.split("/");return n[n.length-1]||t}async listWorkspaceIdsForPathResolution(){const e=[],t=new Set,n=s=>{if(typeof s!="string")return;const i=s.trim();!i||t.has(i)||(t.add(i),e.push(i))};n(this.selectedWorkspace?.id);for(const s of this.workspaces??[])n(s.id);if(e.length>0||!this.client||!this.connected)return e;try{const s=await this.client.request("workspaces.list",{});for(const i of s.workspaces??[])n(i.id)}catch{}return e}async openWorkspaceRelativeFileInViewer(e){if(!this.client||!this.connected)return!1;const t=await this.listWorkspaceIdsForPathResolution();for(const n of t)try{const s=await this.client.request("workspaces.readFile",{workspaceId:n,filePath:e});if(typeof s.content!="string")continue;return this.handleOpenSidebar(s.content,{mimeType:s.contentType??s.mime??this.inferMimeTypeFromPath(e),filePath:s.path??e,title:this.sidebarTitleForPath(e)}),!0}catch{}return!1}extractWorkspacePathCandidatesFromHref(e){const t=e.trim();if(!t)return[];const n=[],s=t.toLowerCase();if(s.startsWith("mailto:")||s.startsWith("tel:")||s.startsWith("javascript:")||s.startsWith("data:"))return[];if(t.startsWith("godmode-file://")){let f=t.slice(15);try{f=decodeURIComponent(f)}catch{}return n.push(f),n}if(t.startsWith("file://")){let f=t.slice(7);f.startsWith("/~/")&&(f="~"+f.slice(2));try{f=decodeURIComponent(f)}catch{}n.push(f);const r=[],p=new Set;for(const g of n){const y=this.normalizeWorkspacePathCandidate(g,{allowAbsolute:!0});!y||p.has(y)||(p.add(y),r.push(y))}return r}const i=/^[a-z][a-z0-9+.-]*:/i.test(t),a=/^[a-z]:[\\/]/i.test(t);(!i||a)&&n.push(t);let o=null;try{o=new URL(t,window.location.href)}catch{o=null}if(o&&/^https?:$/.test(o.protocol)&&o.origin===window.location.origin){for(const b of au){const k=o.searchParams.get(b);k&&n.push(k)}const r=(t.split("#")[0]??"").split("?")[0]??"";r.length>0&&!r.startsWith("/")&&!r.includes("://")&&n.push(r);let g=o.pathname;this.basePath&&g.startsWith(`${this.basePath}/`)?g=g.slice(this.basePath.length):this.basePath&&g===this.basePath&&(g="");const y=g.startsWith("/")?g.slice(1):g;if(y){n.push(y);const b=y.indexOf("/");if(b>0){const k=y.slice(0,b).toLowerCase();Yn.has(k)&&n.push(y.slice(b+1))}}if(g.startsWith("/")&&y){const b=y.split("/")[0]?.toLowerCase()??"";Yn.has(b)||n.push(g)}}const l=[],c=new Set;for(const f of n){let r=f;try{r=decodeURIComponent(f)}catch{}const p=this.normalizeWorkspacePathCandidate(r,{allowAbsolute:!0});!p||c.has(p)||(c.add(p),l.push(p))}return l}async openWorkspaceFileInViewer(e){if(!this.client||!this.connected)return!1;const t=this.isAbsoluteFilesystemPath(e);if(!t&&await this.openWorkspaceRelativeFileInViewer(e))return!0;try{const n=await this.client.request("workspaces.readFile",{path:e});if(typeof n.content=="string")return this.handleOpenSidebar(n.content,{mimeType:n.contentType??n.mime??this.inferMimeTypeFromPath(e),filePath:n.path??e,title:this.sidebarTitleForPath(e)}),!0}catch{}if(!t)return!1;try{const n=await this.client.request("files.read",{path:e,maxSize:1e6});return typeof n.content!="string"?!1:(this.handleOpenSidebar(n.content,{mimeType:this.inferMimeTypeFromPath(e),filePath:e,title:this.sidebarTitleForPath(e)}),!0)}catch{return!1}}async handleOpenMessageFileLink(e){const t=this.extractWorkspacePathCandidatesFromHref(e);if(t.length===0)return!1;for(const n of t)if(await this.openWorkspaceFileInViewer(n))return!0;return!1}showToast(e,t="info",n=5e3,s){const i=Xd(e,t,n,s);this.toasts=eu(this.toasts,i),n>0&&window.setTimeout(()=>{this.dismissToast(i.id)},n)}dismissToast(e){this.toasts=Zd(this.toasts,e)}dismissAllToasts(){this.toasts=[]}handlePrivateModeToggle(){if(this.chatPrivateMode){const e=this.sessionKey;this.chatPrivateMode=!1,this._destroyPrivateSession(e),this.showToast("Private session destroyed","info",2e3);return}this.chatPrivateMode=!0,this.setTab("chat"),_(async()=>{const{createNewSession:e}=await Promise.resolve().then(()=>st);return{createNewSession:e}},void 0,import.meta.url).then(({createNewSession:e})=>{e(this);const t=Date.now()+1440*60*1e3;this.privateSessions=new Map(this.privateSessions).set(this.sessionKey,t),this._persistPrivateSessions(),this._startPrivateSessionTimer(),this.client&&this.connected&&this.client.request("session.setPrivate",{sessionKey:this.sessionKey,enabled:!0}).catch(()=>{}),this.chatMessages=[{role:"assistant",content:`This is a **private session**. Nothing will be saved to memory or logs.
|
|
1984
1998
|
|
|
1985
|
-
This session self-destructs when you close it or in **24 hours** — whichever comes first.`,timestamp:Date.now()}],this.requestUpdate()}),this.showToast("Private session created — 24h countdown started","info",3e3)}async _destroyPrivateSession(e){const t=new Map(this.privateSessions);if(t.delete(e),this.privateSessions=t,this._persistPrivateSessions(),this.sessionKey===e){this.chatPrivateMode=!1;const n=this.settings.openTabs.filter(a=>a!==e),s=n[0]||O;this.applySettings({...this.settings,openTabs:n,sessionKey:s,lastActiveSessionKey:s}),this.sessionKey=s,await(await _(async()=>{const{loadChatHistory:a}=await Promise.resolve().then(()=>
|
|
1999
|
+
This session self-destructs when you close it or in **24 hours** — whichever comes first.`,timestamp:Date.now()}],this.requestUpdate()}),this.showToast("Private session created — 24h countdown started","info",3e3)}async _destroyPrivateSession(e){const t=new Map(this.privateSessions);if(t.delete(e),this.privateSessions=t,this._persistPrivateSessions(),this.sessionKey===e){this.chatPrivateMode=!1;const n=this.settings.openTabs.filter(a=>a!==e),s=n[0]||O;this.applySettings({...this.settings,openTabs:n,sessionKey:s,lastActiveSessionKey:s}),this.sessionKey=s,await(await _(async()=>{const{loadChatHistory:a}=await Promise.resolve().then(()=>me);return{loadChatHistory:a}},void 0,import.meta.url)).loadChatHistory(this);const{scheduleChatScroll:i}=await _(async()=>{const{scheduleChatScroll:a}=await Promise.resolve().then(()=>lo);return{scheduleChatScroll:a}},void 0,import.meta.url);i(this,!0)}else this.applySettings({...this.settings,openTabs:this.settings.openTabs.filter(n=>n!==e)});this.client&&this.connected&&(this.client.request("session.setPrivate",{sessionKey:e,enabled:!1}).catch(()=>{}),this.client.request("sessions.delete",{key:e,deleteTranscript:!0}).catch(()=>{})),this.privateSessions.size===0&&this._stopPrivateSessionTimer()}_persistPrivateSessions(){const e=Array.from(this.privateSessions.entries());e.length===0?localStorage.removeItem("godmode.privateSessions"):localStorage.setItem("godmode.privateSessions",JSON.stringify(e))}_restorePrivateSessions(){try{const e=localStorage.getItem("godmode.privateSessions");if(!e)return;const t=JSON.parse(e),n=Date.now(),s=t.filter(([,i])=>i>n);if(this.privateSessions=new Map(s),s.length!==t.length){const i=t.filter(([,a])=>a<=n);for(const[a]of i)this._destroyPrivateSession(a)}this.privateSessions.size>0&&(this.privateSessions.has(this.sessionKey)&&(this.chatPrivateMode=!0),this._startPrivateSessionTimer()),this._persistPrivateSessions()}catch{localStorage.removeItem("godmode.privateSessions")}}_startPrivateSessionTimer(){this._privateSessionTimer||(this._privateSessionTimer=setInterval(()=>{const e=Date.now();for(const[t,n]of this.privateSessions)n<=e&&(this._destroyPrivateSession(t),this.showToast("Private session expired and was destroyed","info",3e3));this.privateSessions.size>0&&this.requestUpdate()},3e4))}_stopPrivateSessionTimer(){this._privateSessionTimer&&(clearInterval(this._privateSessionTimer),this._privateSessionTimer=null)}handleResourceClick(e){e.path?this.handleWorkFileClick(e.path):e.url&&window.open(e.url,"_blank","noopener,noreferrer")}async loadSessionResources(){if(!(!this.client||!this.connected))try{const t=(await this.client.request("resources.list",{sessionKey:this.sessionKey,limit:20})).resources??[],n=new Set(t.filter(s=>s.proofSlug).map(s=>s.proofSlug));if(this.chatMessages?.length)for(const s of this.chatMessages){const i=s,a=Array.isArray(i.content)?i.content:[];for(const o of a){const l=typeof o.text=="string"?o.text:typeof o.content=="string"?o.content:null;if(l)try{const c=JSON.parse(l);c._sidebarAction?.type==="proof"&&c._sidebarAction.slug&&!n.has(c._sidebarAction.slug)&&(n.add(c._sidebarAction.slug),t.unshift({id:`proof:${c._sidebarAction.slug}`,title:c.title??"Proof Document",type:"doc",path:c.filePath,sessionKey:this.sessionKey,proofSlug:c._sidebarAction.slug}))}catch{}}}this.sessionResources=t}catch(e){console.warn("[SessionResources] load failed:",e),this.sessionResources=[]}}handleSessionResourceClick(e){e.proofSlug?this.handleOpenProofDoc(e.proofSlug):e.path?this.handleOpenFile(e.path):e.url&&window.open(e.url,"_blank","noopener,noreferrer")}handleToggleSessionResources(){this.sessionResourcesCollapsed=!this.sessionResourcesCollapsed}handleViewAllResources(){this.setTab("work")}async handleWorkFileClick(e){if(!this.client||!this.connected){this.showToast("Not connected to gateway","error");return}try{const t=await this.client.request("workspaces.readFile",{path:e});if(!t.content){this.showToast(t.error??"Failed to read file","error");return}this.handleOpenSidebar(t.content,{mimeType:t.contentType??t.mime??this.inferMimeTypeFromPath(e),filePath:t.path??e,title:this.sidebarTitleForPath(e)})}catch(t){console.error("[Work] Failed to read file:",t),this.showToast(`Failed to open: ${e}`,"error")}}handleWorkSkillClick(e,t){this.handleStartChatWithPrompt(`Tell me about the "${e}" skill and how it's used in the ${t} project.`)}handlePeopleImport(e){const t=e==="apple"?"Import my contacts from Apple Contacts and organize them into categories.":"Import my contacts from Google Contacts and organize them into categories.";this.handleStartChatWithPrompt(t)}handleOnboardingStart(){this.onboardingPhase=1,this.onboardingData&&(this.onboardingData={...this.onboardingData,phase:1}),this.client?.request("onboarding.update",{phase:1,completePhase:0})}async handleOnboardingIdentitySubmit(e){if(this.client)try{await this.client.request("onboarding.update",{phase:2,completePhase:1,identity:e}),this.onboardingPhase=2,this.onboardingData&&(this.onboardingData={...this.onboardingData,phase:2,identity:e}),this.userName=e.name,this.userAvatar=e.emoji,this.applySettings({...this.settings,userName:e.name,userAvatar:e.emoji}),this.setTab("chat"),_(async()=>{const{createNewSession:t}=await Promise.resolve().then(()=>st);return{createNewSession:t}},void 0,import.meta.url).then(({createNewSession:t})=>{t(this);const n=`I just set up my GodMode identity. My name is ${e.name}${e.mission?` and my mission is: ${e.mission}`:""}. Let's set up my workspace.`;this.chatMessage=n,this.handleSendChat(n)})}catch(t){console.error("[Onboarding] Identity submit failed:",t),this.showToast("Failed to save identity","error")}}handleOnboardingSkipPhase(){if(!this.client)return;const e=Math.min(this.onboardingPhase+1,6);this.onboardingPhase=e,this.client.request("onboarding.update",{phase:e,completePhase:this.onboardingPhase})}handleOnboardingComplete(){this.onboardingActive=!1,this.onboardingPhase=6,this.onboardingData&&(this.onboardingData={...this.onboardingData,phase:6,completedAt:new Date().toISOString()}),this.client?.request("onboarding.complete",{summary:this.onboardingData?.summary??null}),this.showToast("Welcome to GodMode!","success",4e3)}handleStartChatWithPrompt(e){this.setTab("chat"),_(async()=>{const{createNewSession:t}=await Promise.resolve().then(()=>st);return{createNewSession:t}},void 0,import.meta.url).then(({createNewSession:t})=>{t(this),this.chatMessage=e,this.requestUpdate()})}handleOpenSupportChat(){const e="agent:main:support";if(this.sessionKey===e){this.setTab("chat");return}_(async()=>{const{saveDraft:s}=await Promise.resolve().then(()=>ql);return{saveDraft:s}},void 0,import.meta.url).then(({saveDraft:s})=>s(this));const n=this.settings.openTabs.includes(e)?this.settings.openTabs:[...this.settings.openTabs,e];this.applySettings({...this.settings,openTabs:n,sessionKey:e,lastActiveSessionKey:e,tabLastViewed:{...this.settings.tabLastViewed,[e]:Date.now()}}),this.sessionKey=e,this.setTab("chat"),this.chatMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.resetToolStream(),this.resetChatScroll(),this.loadAssistantIdentity(),_(async()=>{const{autoTitleCache:s}=await import("./ctrl-settings-nG144v_G.js").then(i=>i.ad);return{autoTitleCache:s}},[],import.meta.url).then(({autoTitleCache:s})=>{s.set(e,"Support")}),_(async()=>{const{loadChatHistory:s}=await Promise.resolve().then(()=>me);return{loadChatHistory:s}},void 0,import.meta.url).then(({loadChatHistory:s})=>{s(this).then(()=>{this.loadSessionResources(),this.chatMessages.length===0&&this.sessionKey===e&&(this.chatMessages=[{role:"assistant",content:`**Welcome to GodMode Support**
|
|
1986
2000
|
|
|
1987
2001
|
I have full access to your system diagnostics and GodMode knowledge base. I can help with:
|
|
1988
2002
|
|
|
@@ -1991,4 +2005,4 @@ I have full access to your system diagnostics and GodMode knowledge base. I can
|
|
|
1991
2005
|
- Setup guidance
|
|
1992
2006
|
- Escalation to the team if needed
|
|
1993
2007
|
|
|
1994
|
-
What can I help you with?`,timestamp:Date.now()}],this.requestUpdate())}).catch(i=>{console.error("[Support] Failed to load chat history:",i)})})}handleWizardOpen(){_(async()=>{const{emptyWizardState:e}=await import("./views-settings-B2UFEtoi.js").then(t=>t.I);return{emptyWizardState:e}},__vite__mapDeps([4,1,3,5]),import.meta.url).then(({emptyWizardState:e})=>{this.wizardState=e(),this.wizardActive=!0,this.requestUpdate()})}handleWizardClose(){this.wizardActive=!1,this.wizardState=null,this.requestUpdate()}handleWizardStepChange(e){this.wizardState&&(this.wizardState={...this.wizardState,step:e},this.requestUpdate())}handleWizardAnswerChange(e,t){this.wizardState&&(this.wizardState={...this.wizardState,answers:{...this.wizardState.answers,[e]:t}},this.requestUpdate())}async handleWizardPreview(){if(!(!this.client||!this.wizardState))try{const[e,t]=await Promise.all([this.client.request("onboarding.wizard.preview",this.wizardState.answers),this.client.request("onboarding.wizard.diff",this.wizardState.answers).catch(()=>null)]),n={};for(const i of e.files??[])n[i.path]=i.wouldCreate;const s={};if(t){for(const i of t.additions)s[i.path]=!0;for(const i of t.changes)s[i.path]=!1}this.wizardState={...this.wizardState,preview:e.files??[],diff:t,fileSelections:n,configSelections:s},this.requestUpdate()}catch(e){console.error("[Wizard] Preview failed:",e)}}handleWizardFileToggle(e,t){this.wizardState&&(this.wizardState={...this.wizardState,fileSelections:{...this.wizardState.fileSelections,[e]:t}},this.requestUpdate())}handleWizardConfigToggle(e,t){this.wizardState&&(this.wizardState={...this.wizardState,configSelections:{...this.wizardState.configSelections,[e]:t}},this.requestUpdate())}async handleWizardGenerate(){if(!this.client||!this.wizardState)return;this.wizardState={...this.wizardState,generating:!0,error:null},this.requestUpdate();const e=[];for(const[n,s]of Object.entries(this.wizardState.fileSelections))s||e.push(n);const t=[];for(const[n,s]of Object.entries(this.wizardState.configSelections))s||t.push(n);try{const n=await this.client.request("onboarding.wizard.generate",{...this.wizardState.answers,skipFiles:e,skipKeys:t});this.wizardState={...this.wizardState,generating:!1,step:9,result:{filesCreated:n.filesCreated,filesSkipped:n.filesSkipped,configPatched:n.configPatched,workspacePath:n.workspacePath}},this.requestUpdate(),this.showToast("Memory system generated!","success",4e3)}catch(n){const s=n instanceof Error?n.message:"Failed to generate workspace";this.wizardState={...this.wizardState,generating:!1,error:s},this.requestUpdate(),this.showToast(s,"error")}}async handleQuickSetup(e){_(()=>import("./setup-BnLadXY9.js"),[],import.meta.url).then(async({quickSetup:t})=>{await t(this,e)&&(this.setTab("chat"),_(async()=>{const{loadCapabilities:s}=await import("./setup-BnLadXY9.js");return{loadCapabilities:s}},[],import.meta.url).then(({loadCapabilities:s})=>s(this)))})}handleLoadCapabilities(){_(async()=>{const{loadCapabilities:e}=await import("./setup-BnLadXY9.js");return{loadCapabilities:e}},[],import.meta.url).then(({loadCapabilities:e})=>e(this))}handleCapabilityAction(e){_(async()=>{const{capabilityAction:t}=await import("./setup-BnLadXY9.js");return{capabilityAction:t}},[],import.meta.url).then(({capabilityAction:t})=>t(this,e))}handleHideSetup(){_(async()=>{const{hideSetup:e}=await import("./setup-BnLadXY9.js");return{hideSetup:e}},[],import.meta.url).then(({hideSetup:e})=>e(this))}handleRunAssessment(){this.client&&this.client.request("onboarding.assess",{}).then(()=>{this.handleLoadCapabilities()})}continueSetup(){const e=this.setupProgress?.currentStep??"welcome";this._navigateToSetupStep(e)}dismissSetup(){this.setupBarDismissed=!0,_(async()=>{const{dismissSetupBar:e}=await import("./setup-BnLadXY9.js");return{dismissSetupBar:e}},[],import.meta.url).then(({dismissSetupBar:e})=>e(this))}handleSetupStepClick(e){this._navigateToSetupStep(e)}async loadSetupProgress(){await(await _(()=>import("./setup-BnLadXY9.js"),[],import.meta.url)).loadSetupProgress(this)}_navigateToSetupStep(e){const n={welcome:"Let's get started! What should I call you?","api-key":"Help me connect my Anthropic API key so you can work at full power.",memory:"Help me set up persistent memory with Honcho so you remember our conversations.",integrations:"Help me connect my tools via Composio — starting with Google and GitHub.",screenpipe:"Help me set up Screenpipe for ambient screen and audio recall.","second-brain":"Help me link my Obsidian vault to my Memory."}[e]??"Help me continue setting up GodMode.";this.handleStartChatWithPrompt(n)}handleUpdateUserProfile(e,t){const n=e.trim().slice(0,50),s=t.trim();this.userName=n||"You",this.userAvatar=s||null,this.applySettings({...this.settings,userName:n,userAvatar:s})}async handleLoadIntegrations(){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).loadIntegrations(this)}handleExpandCard(e){_(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url).then(t=>t.expandCard(this,e))}async handleLoadGuide(e){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).loadGuide(this,e)}async handleTestIntegration(e){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).testIntegration(this,e)}async handleConfigureIntegration(e,t){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).configureIntegration(this,e,t)}handleUpdateConfigValue(e,t){this.onboardingConfigValues={...this.onboardingConfigValues,[e]:t}}handleSkipIntegration(e){_(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url).then(t=>t.skipIntegration(this,e))}async handleMarkOnboardingComplete(){if(!(!this.client||!this.connected))try{await this.client.request("onboarding.complete",{}),this.showSetupTab=!1,this.setTab("chat")}catch(e){console.error("[onboarding] Failed to mark complete:",e)}}async handleOpenProofDoc(e){let t="Proof Document",n=null,s=null;if(this.client&&this.connected)try{const i=await this.client.request("proof.get",{slug:e});t=i.title?.trim()||t,n=i.filePath?.trim()||null,s=i.viewUrl?.trim()||null}catch(i){console.warn("[Proof] Failed to resolve document metadata:",i)}this.sidebarOpen=!0,this.sidebarMode="proof",this.sidebarProofSlug=e,this.sidebarProofUrl=s,this.sidebarProofHtml=null,this.sidebarFilePath=n,this.sidebarTitle=t}handleCloseProofDoc(){this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null,this.sidebarProofHtml=null,this.handleCloseSidebar()}render(){return su(this)}};h([$a({context:Xa}),f()],u.prototype,"_ctx",2);h([f()],u.prototype,"settings",2);h([f()],u.prototype,"password",2);h([f()],u.prototype,"tab",2);h([f()],u.prototype,"onboarding",2);h([f()],u.prototype,"connected",2);h([f()],u.prototype,"reconnecting",2);h([f()],u.prototype,"reconnectAttempt",2);h([f()],u.prototype,"theme",2);h([f()],u.prototype,"themeResolved",2);h([f()],u.prototype,"hello",2);h([f()],u.prototype,"lastError",2);h([f()],u.prototype,"eventLog",2);h([f()],u.prototype,"assistantName",2);h([f()],u.prototype,"assistantAvatar",2);h([f()],u.prototype,"assistantAgentId",2);h([f()],u.prototype,"userName",2);h([f()],u.prototype,"userAvatar",2);h([f()],u.prototype,"currentModel",2);h([f()],u.prototype,"availableModels",2);h([f()],u.prototype,"modelPickerOpen",2);h([f()],u.prototype,"modelCacheTs",2);h([f()],u.prototype,"sessionKey",2);h([f()],u.prototype,"sessionPickerOpen",2);h([f()],u.prototype,"sessionPickerPosition",2);h([f()],u.prototype,"sessionPickerSearch",2);h([f()],u.prototype,"sessionSearchOpen",2);h([f()],u.prototype,"sessionSearchPosition",2);h([f()],u.prototype,"sessionSearchQuery",2);h([f()],u.prototype,"sessionSearchResults",2);h([f()],u.prototype,"sessionSearchLoading",2);h([f()],u.prototype,"profilePopoverOpen",2);h([f()],u.prototype,"profileEditName",2);h([f()],u.prototype,"profileEditAvatar",2);h([f()],u.prototype,"editingTabKey",2);h([f()],u.prototype,"navDrawerOpen",2);h([f()],u.prototype,"chatLoading",2);h([f()],u.prototype,"chatSending",2);h([f()],u.prototype,"chatSendingSessionKey",2);h([f()],u.prototype,"chatMessage",2);h([f()],u.prototype,"chatDrafts",2);h([f()],u.prototype,"chatMessages",2);h([f()],u.prototype,"chatToolMessages",2);h([f()],u.prototype,"chatStream",2);h([f()],u.prototype,"chatStreamStartedAt",2);h([f()],u.prototype,"chatRunId",2);h([f()],u.prototype,"currentToolName",2);h([f()],u.prototype,"currentToolInfo",2);h([f()],u.prototype,"workingSessions",2);h([f()],u.prototype,"compactionStatus",2);h([f()],u.prototype,"chatAvatarUrl",2);h([f()],u.prototype,"chatThinkingLevel",2);h([f()],u.prototype,"chatQueue",2);h([f()],u.prototype,"chatAttachments",2);h([f()],u.prototype,"sidebarOpen",2);h([f()],u.prototype,"sidebarContent",2);h([f()],u.prototype,"sidebarError",2);h([f()],u.prototype,"sidebarMimeType",2);h([f()],u.prototype,"sidebarFilePath",2);h([f()],u.prototype,"sidebarTitle",2);h([f()],u.prototype,"sidebarMode",2);h([f()],u.prototype,"sidebarProofSlug",2);h([f()],u.prototype,"sidebarProofUrl",2);h([f()],u.prototype,"sidebarProofHtml",2);h([f()],u.prototype,"splitRatio",2);h([f()],u.prototype,"lightbox",2);h([f()],u.prototype,"driveAccounts",2);h([f()],u.prototype,"showDrivePicker",2);h([f()],u.prototype,"driveUploading",2);h([f()],u.prototype,"updateStatus",2);h([f()],u.prototype,"updateLoading",2);h([f()],u.prototype,"updateError",2);h([f()],u.prototype,"updateLastChecked",2);h([f()],u.prototype,"nodesLoading",2);h([f()],u.prototype,"nodes",2);h([f()],u.prototype,"devicesLoading",2);h([f()],u.prototype,"devicesError",2);h([f()],u.prototype,"devicesList",2);h([f()],u.prototype,"execApprovalsLoading",2);h([f()],u.prototype,"execApprovalsSaving",2);h([f()],u.prototype,"execApprovalsDirty",2);h([f()],u.prototype,"execApprovalsSnapshot",2);h([f()],u.prototype,"execApprovalsForm",2);h([f()],u.prototype,"execApprovalsSelectedAgent",2);h([f()],u.prototype,"execApprovalsTarget",2);h([f()],u.prototype,"execApprovalsTargetNodeId",2);h([f()],u.prototype,"execApprovalQueue",2);h([f()],u.prototype,"execApprovalBusy",2);h([f()],u.prototype,"execApprovalError",2);h([f()],u.prototype,"pendingGatewayUrl",2);h([f()],u.prototype,"gatewayRestartPending",2);h([f()],u.prototype,"gatewayRestartBusy",2);h([f()],u.prototype,"deployPanelOpen",2);h([f()],u.prototype,"configLoading",2);h([f()],u.prototype,"configRaw",2);h([f()],u.prototype,"configRawOriginal",2);h([f()],u.prototype,"configValid",2);h([f()],u.prototype,"configIssues",2);h([f()],u.prototype,"configSaving",2);h([f()],u.prototype,"configApplying",2);h([f()],u.prototype,"updateRunning",2);h([f()],u.prototype,"applySessionKey",2);h([f()],u.prototype,"configSnapshot",2);h([f()],u.prototype,"configSchema",2);h([f()],u.prototype,"configSchemaVersion",2);h([f()],u.prototype,"configSchemaLoading",2);h([f()],u.prototype,"configUiHints",2);h([f()],u.prototype,"configForm",2);h([f()],u.prototype,"configFormOriginal",2);h([f()],u.prototype,"configFormDirty",2);h([f()],u.prototype,"configFormMode",2);h([f()],u.prototype,"configSearchQuery",2);h([f()],u.prototype,"configActiveSection",2);h([f()],u.prototype,"configActiveSubsection",2);h([f()],u.prototype,"channelsLoading",2);h([f()],u.prototype,"channelsSnapshot",2);h([f()],u.prototype,"channelsError",2);h([f()],u.prototype,"channelsLastSuccess",2);h([f()],u.prototype,"whatsappLoginMessage",2);h([f()],u.prototype,"whatsappLoginQrDataUrl",2);h([f()],u.prototype,"whatsappLoginConnected",2);h([f()],u.prototype,"whatsappBusy",2);h([f()],u.prototype,"nostrProfileFormState",2);h([f()],u.prototype,"nostrProfileAccountId",2);h([f()],u.prototype,"presenceLoading",2);h([f()],u.prototype,"presenceEntries",2);h([f()],u.prototype,"presenceError",2);h([f()],u.prototype,"presenceStatus",2);h([f()],u.prototype,"agentsLoading",2);h([f()],u.prototype,"agentsList",2);h([f()],u.prototype,"agentsError",2);h([f()],u.prototype,"sessionsLoading",2);h([f()],u.prototype,"sessionsResult",2);h([f()],u.prototype,"sessionsError",2);h([f()],u.prototype,"sessionsFilterActive",2);h([f()],u.prototype,"sessionsFilterLimit",2);h([f()],u.prototype,"sessionsIncludeGlobal",2);h([f()],u.prototype,"sessionsIncludeUnknown",2);h([f()],u.prototype,"archivedSessions",2);h([f()],u.prototype,"archivedSessionsLoading",2);h([f()],u.prototype,"archivedSessionsExpanded",2);h([f()],u.prototype,"cronLoading",2);h([f()],u.prototype,"cronJobs",2);h([f()],u.prototype,"cronStatus",2);h([f()],u.prototype,"cronError",2);h([f()],u.prototype,"cronForm",2);h([f()],u.prototype,"cronRunsJobId",2);h([f()],u.prototype,"cronRuns",2);h([f()],u.prototype,"cronBusy",2);h([f()],u.prototype,"workspaceNeedsSetup",2);h([f()],u.prototype,"onboardingPhase",2);h([f()],u.prototype,"onboardingData",2);h([f()],u.prototype,"onboardingActive",2);h([f()],u.prototype,"wizardActive",2);h([f()],u.prototype,"wizardState",2);h([f()],u.prototype,"showSetupTab",2);h([f()],u.prototype,"setupBarDismissed",2);h([f()],u.prototype,"setupProgress",2);h([f()],u.prototype,"setupCapabilities",2);h([f()],u.prototype,"setupCapabilitiesLoading",2);h([f()],u.prototype,"setupQuickDone",2);h([f()],u.prototype,"onboardingIntegrations",2);h([f()],u.prototype,"onboardingCoreProgress",2);h([f()],u.prototype,"onboardingExpandedCard",2);h([f()],u.prototype,"onboardingLoadingGuide",2);h([f()],u.prototype,"onboardingActiveGuide",2);h([f()],u.prototype,"onboardingTestingId",2);h([f()],u.prototype,"onboardingTestResult",2);h([f()],u.prototype,"onboardingConfigValues",2);h([f()],u.prototype,"onboardingProgress",2);h([f()],u.prototype,"allyPanelOpen",2);h([f()],u.prototype,"allyMessages",2);h([f()],u.prototype,"allyStream",2);h([f()],u.prototype,"allyDraft",2);h([f()],u.prototype,"allyUnread",2);h([f()],u.prototype,"allySending",2);h([f()],u.prototype,"allyWorking",2);h([f()],u.prototype,"allyAttachments",2);h([f()],u.prototype,"chatPrivateMode",2);h([f()],u.prototype,"privateSessions",2);h([f()],u.prototype,"dynamicSlots",2);h([f()],u.prototype,"sessionResources",2);h([f()],u.prototype,"sessionResourcesCollapsed",2);h([f()],u.prototype,"skillsLoading",2);h([f()],u.prototype,"skillsReport",2);h([f()],u.prototype,"skillsError",2);h([f()],u.prototype,"skillsFilter",2);h([f()],u.prototype,"skillEdits",2);h([f()],u.prototype,"skillsBusyKey",2);h([f()],u.prototype,"skillMessages",2);h([f()],u.prototype,"skillsSubTab",2);h([f()],u.prototype,"godmodeSkills",2);h([f()],u.prototype,"godmodeSkillsLoading",2);h([f()],u.prototype,"expandedSkills",2);h([f()],u.prototype,"rosterData",2);h([f()],u.prototype,"rosterLoading",2);h([f()],u.prototype,"rosterError",2);h([f()],u.prototype,"rosterFilter",2);h([f()],u.prototype,"expandedAgents",2);h([f()],u.prototype,"debugLoading",2);h([f()],u.prototype,"debugStatus",2);h([f()],u.prototype,"debugHealth",2);h([f()],u.prototype,"debugModels",2);h([f()],u.prototype,"debugHeartbeat",2);h([f()],u.prototype,"debugCallMethod",2);h([f()],u.prototype,"debugCallParams",2);h([f()],u.prototype,"debugCallResult",2);h([f()],u.prototype,"debugCallError",2);h([f()],u.prototype,"logsLoading",2);h([f()],u.prototype,"logsError",2);h([f()],u.prototype,"logsFile",2);h([f()],u.prototype,"logsEntries",2);h([f()],u.prototype,"logsFilterText",2);h([f()],u.prototype,"logsLevelFilters",2);h([f()],u.prototype,"logsAutoFollow",2);h([f()],u.prototype,"logsTruncated",2);h([f()],u.prototype,"logsCursor",2);h([f()],u.prototype,"logsLastFetchAt",2);h([f()],u.prototype,"logsLimit",2);h([f()],u.prototype,"logsMaxBytes",2);h([f()],u.prototype,"logsAtBottom",2);h([f()],u.prototype,"toasts",2);h([f()],u.prototype,"chatUserNearBottom",2);h([f()],u.prototype,"chatNewMessagesBelow",2);h([f()],u.prototype,"consciousnessStatus",2);h([f()],u.prototype,"trustTrackerData",2);h([f()],u.prototype,"trustTrackerLoading",2);h([f()],u.prototype,"guardrailsData",2);h([f()],u.prototype,"guardrailsLoading",2);h([f()],u.prototype,"guardrailsShowAddForm",2);h([f()],u.prototype,"secrets",2);h([f()],u.prototype,"secretsLoading",2);h([f()],u.prototype,"webFetchProvider",2);h([f()],u.prototype,"webFetchLoading",2);h([f()],u.prototype,"searchProvider",2);h([f()],u.prototype,"searchExaConfigured",2);h([f()],u.prototype,"searchTavilyConfigured",2);h([f()],u.prototype,"searchLoading",2);h([f()],u.prototype,"customTabs",2);h([f()],u.prototype,"customTabData",2);h([f()],u.prototype,"customTabLoading",2);h([f()],u.prototype,"customTabErrors",2);u=h([ls("godmode-app")],u);export{z as a,Lu as b,$u as c,Cu as d,xu as e,Pu as f,Mu as g,zt as h,Eu as i,Ru as j,Du as k,xl as l,Ou as m,Ku as n,Fu as o,Nu as p,Ml as q,ku as r,Tu as s,Au as t,Iu as u,Uu as v,Xa as w,_u as x};
|
|
2008
|
+
What can I help you with?`,timestamp:Date.now()}],this.requestUpdate())}).catch(i=>{console.error("[Support] Failed to load chat history:",i)})})}handleWizardOpen(){_(async()=>{const{emptyWizardState:e}=await import("./views-settings-TQFJxfo9.js").then(t=>t.I);return{emptyWizardState:e}},__vite__mapDeps([4,1,3,5]),import.meta.url).then(({emptyWizardState:e})=>{this.wizardState=e(),this.wizardActive=!0,this.requestUpdate()})}handleWizardClose(){this.wizardActive=!1,this.wizardState=null,this.requestUpdate()}handleWizardStepChange(e){this.wizardState&&(this.wizardState={...this.wizardState,step:e},this.requestUpdate())}handleWizardAnswerChange(e,t){this.wizardState&&(this.wizardState={...this.wizardState,answers:{...this.wizardState.answers,[e]:t}},this.requestUpdate())}async handleWizardPreview(){if(!(!this.client||!this.wizardState))try{const[e,t]=await Promise.all([this.client.request("onboarding.wizard.preview",this.wizardState.answers),this.client.request("onboarding.wizard.diff",this.wizardState.answers).catch(()=>null)]),n={};for(const i of e.files??[])n[i.path]=i.wouldCreate;const s={};if(t){for(const i of t.additions)s[i.path]=!0;for(const i of t.changes)s[i.path]=!1}this.wizardState={...this.wizardState,preview:e.files??[],diff:t,fileSelections:n,configSelections:s},this.requestUpdate()}catch(e){console.error("[Wizard] Preview failed:",e)}}handleWizardFileToggle(e,t){this.wizardState&&(this.wizardState={...this.wizardState,fileSelections:{...this.wizardState.fileSelections,[e]:t}},this.requestUpdate())}handleWizardConfigToggle(e,t){this.wizardState&&(this.wizardState={...this.wizardState,configSelections:{...this.wizardState.configSelections,[e]:t}},this.requestUpdate())}async handleWizardGenerate(){if(!this.client||!this.wizardState)return;this.wizardState={...this.wizardState,generating:!0,error:null},this.requestUpdate();const e=[];for(const[n,s]of Object.entries(this.wizardState.fileSelections))s||e.push(n);const t=[];for(const[n,s]of Object.entries(this.wizardState.configSelections))s||t.push(n);try{const n=await this.client.request("onboarding.wizard.generate",{...this.wizardState.answers,skipFiles:e,skipKeys:t});this.wizardState={...this.wizardState,generating:!1,step:9,result:{filesCreated:n.filesCreated,filesSkipped:n.filesSkipped,configPatched:n.configPatched,workspacePath:n.workspacePath}},this.requestUpdate(),this.showToast("Memory system generated!","success",4e3)}catch(n){const s=n instanceof Error?n.message:"Failed to generate workspace";this.wizardState={...this.wizardState,generating:!1,error:s},this.requestUpdate(),this.showToast(s,"error")}}async handleQuickSetup(e){_(()=>import("./setup-BnLadXY9.js"),[],import.meta.url).then(async({quickSetup:t})=>{await t(this,e)&&(this.setTab("chat"),_(async()=>{const{loadCapabilities:s}=await import("./setup-BnLadXY9.js");return{loadCapabilities:s}},[],import.meta.url).then(({loadCapabilities:s})=>s(this)))})}handleLoadCapabilities(){_(async()=>{const{loadCapabilities:e}=await import("./setup-BnLadXY9.js");return{loadCapabilities:e}},[],import.meta.url).then(({loadCapabilities:e})=>e(this))}handleCapabilityAction(e){_(async()=>{const{capabilityAction:t}=await import("./setup-BnLadXY9.js");return{capabilityAction:t}},[],import.meta.url).then(({capabilityAction:t})=>t(this,e))}handleHideSetup(){_(async()=>{const{hideSetup:e}=await import("./setup-BnLadXY9.js");return{hideSetup:e}},[],import.meta.url).then(({hideSetup:e})=>e(this))}handleRunAssessment(){this.client&&this.client.request("onboarding.assess",{}).then(()=>{this.handleLoadCapabilities()})}continueSetup(){const e=this.setupProgress?.currentStep??"welcome";this._navigateToSetupStep(e)}dismissSetup(){this.setupBarDismissed=!0,_(async()=>{const{dismissSetupBar:e}=await import("./setup-BnLadXY9.js");return{dismissSetupBar:e}},[],import.meta.url).then(({dismissSetupBar:e})=>e(this))}handleSetupStepClick(e){this._navigateToSetupStep(e)}async loadSetupProgress(){await(await _(()=>import("./setup-BnLadXY9.js"),[],import.meta.url)).loadSetupProgress(this)}_navigateToSetupStep(e){const n={welcome:"Let's get started! What should I call you?","api-key":"Help me connect my Anthropic API key so you can work at full power.",memory:"Help me set up persistent memory with Honcho so you remember our conversations.",integrations:"Help me connect my tools via Composio — starting with Google and GitHub.",screenpipe:"Enable ambient memory so you can recall what I've been working on from my screen and audio.","second-brain":"Help me link my Obsidian vault to my Memory."}[e]??"Help me continue setting up GodMode.";this.handleStartChatWithPrompt(n)}handleUpdateUserProfile(e,t){const n=e.trim().slice(0,50),s=t.trim();this.userName=n||"You",this.userAvatar=s||null,this.applySettings({...this.settings,userName:n,userAvatar:s})}async handleLoadIntegrations(){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).loadIntegrations(this)}handleExpandCard(e){_(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url).then(t=>t.expandCard(this,e))}async handleLoadGuide(e){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).loadGuide(this,e)}async handleTestIntegration(e){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).testIntegration(this,e)}async handleConfigureIntegration(e,t){await(await _(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url)).configureIntegration(this,e,t)}handleUpdateConfigValue(e,t){this.onboardingConfigValues={...this.onboardingConfigValues,[e]:t}}handleSkipIntegration(e){_(()=>import("./onboarding-setup-eq3R6nNk.js"),[],import.meta.url).then(t=>t.skipIntegration(this,e))}async handleMarkOnboardingComplete(){if(!(!this.client||!this.connected))try{await this.client.request("onboarding.complete",{}),this.showSetupTab=!1,this.setTab("chat")}catch(e){console.error("[onboarding] Failed to mark complete:",e)}}async handleOpenProofDoc(e){let t="Proof Document",n=null,s=null;if(this.client&&this.connected)try{const i=await this.client.request("proof.get",{slug:e});t=i.title?.trim()||t,n=i.filePath?.trim()||null,s=i.viewUrl?.trim()||null}catch(i){console.warn("[Proof] Failed to resolve document metadata:",i)}this.sidebarOpen=!0,this.sidebarMode="proof",this.sidebarProofSlug=e,this.sidebarProofUrl=s,this.sidebarProofHtml=null,this.sidebarFilePath=n,this.sidebarTitle=t}handleCloseProofDoc(){this.sidebarMode="resource",this.sidebarProofSlug=null,this.sidebarProofUrl=null,this.sidebarProofHtml=null,this.handleCloseSidebar()}render(){return Hd(this)}};h([ba({context:Ha}),m()],u.prototype,"_ctx",2);h([m()],u.prototype,"settings",2);h([m()],u.prototype,"password",2);h([m()],u.prototype,"tab",2);h([m()],u.prototype,"onboarding",2);h([m()],u.prototype,"connected",2);h([m()],u.prototype,"reconnecting",2);h([m()],u.prototype,"reconnectAttempt",2);h([m()],u.prototype,"theme",2);h([m()],u.prototype,"themeResolved",2);h([m()],u.prototype,"hello",2);h([m()],u.prototype,"lastError",2);h([m()],u.prototype,"eventLog",2);h([m()],u.prototype,"assistantName",2);h([m()],u.prototype,"assistantAvatar",2);h([m()],u.prototype,"assistantAgentId",2);h([m()],u.prototype,"userName",2);h([m()],u.prototype,"userAvatar",2);h([m()],u.prototype,"currentModel",2);h([m()],u.prototype,"availableModels",2);h([m()],u.prototype,"modelPickerOpen",2);h([m()],u.prototype,"modelCacheTs",2);h([m()],u.prototype,"sessionKey",2);h([m()],u.prototype,"sessionPickerOpen",2);h([m()],u.prototype,"sessionPickerPosition",2);h([m()],u.prototype,"sessionPickerSearch",2);h([m()],u.prototype,"sessionSearchOpen",2);h([m()],u.prototype,"sessionSearchPosition",2);h([m()],u.prototype,"sessionSearchQuery",2);h([m()],u.prototype,"sessionSearchResults",2);h([m()],u.prototype,"sessionSearchLoading",2);h([m()],u.prototype,"profilePopoverOpen",2);h([m()],u.prototype,"profileEditName",2);h([m()],u.prototype,"profileEditAvatar",2);h([m()],u.prototype,"editingTabKey",2);h([m()],u.prototype,"navDrawerOpen",2);h([m()],u.prototype,"chatLoading",2);h([m()],u.prototype,"chatSending",2);h([m()],u.prototype,"chatSendingSessionKey",2);h([m()],u.prototype,"chatMessage",2);h([m()],u.prototype,"chatDrafts",2);h([m()],u.prototype,"chatMessages",2);h([m()],u.prototype,"chatToolMessages",2);h([m()],u.prototype,"chatStream",2);h([m()],u.prototype,"chatStreamStartedAt",2);h([m()],u.prototype,"chatRunId",2);h([m()],u.prototype,"currentToolName",2);h([m()],u.prototype,"currentToolInfo",2);h([m()],u.prototype,"workingSessions",2);h([m()],u.prototype,"compactionStatus",2);h([m()],u.prototype,"chatAvatarUrl",2);h([m()],u.prototype,"chatThinkingLevel",2);h([m()],u.prototype,"chatQueue",2);h([m()],u.prototype,"chatAttachments",2);h([m()],u.prototype,"sidebarOpen",2);h([m()],u.prototype,"sidebarContent",2);h([m()],u.prototype,"sidebarError",2);h([m()],u.prototype,"sidebarMimeType",2);h([m()],u.prototype,"sidebarFilePath",2);h([m()],u.prototype,"sidebarTitle",2);h([m()],u.prototype,"sidebarMode",2);h([m()],u.prototype,"sidebarProofSlug",2);h([m()],u.prototype,"sidebarProofUrl",2);h([m()],u.prototype,"sidebarProofHtml",2);h([m()],u.prototype,"splitRatio",2);h([m()],u.prototype,"lightbox",2);h([m()],u.prototype,"driveAccounts",2);h([m()],u.prototype,"showDrivePicker",2);h([m()],u.prototype,"driveUploading",2);h([m()],u.prototype,"updateStatus",2);h([m()],u.prototype,"updateLoading",2);h([m()],u.prototype,"updateError",2);h([m()],u.prototype,"updateLastChecked",2);h([m()],u.prototype,"nodesLoading",2);h([m()],u.prototype,"nodes",2);h([m()],u.prototype,"devicesLoading",2);h([m()],u.prototype,"devicesError",2);h([m()],u.prototype,"devicesList",2);h([m()],u.prototype,"execApprovalsLoading",2);h([m()],u.prototype,"execApprovalsSaving",2);h([m()],u.prototype,"execApprovalsDirty",2);h([m()],u.prototype,"execApprovalsSnapshot",2);h([m()],u.prototype,"execApprovalsForm",2);h([m()],u.prototype,"execApprovalsSelectedAgent",2);h([m()],u.prototype,"execApprovalsTarget",2);h([m()],u.prototype,"execApprovalsTargetNodeId",2);h([m()],u.prototype,"execApprovalQueue",2);h([m()],u.prototype,"execApprovalBusy",2);h([m()],u.prototype,"execApprovalError",2);h([m()],u.prototype,"pendingGatewayUrl",2);h([m()],u.prototype,"gatewayRestartPending",2);h([m()],u.prototype,"gatewayRestartBusy",2);h([m()],u.prototype,"deployPanelOpen",2);h([m()],u.prototype,"configLoading",2);h([m()],u.prototype,"configRaw",2);h([m()],u.prototype,"configRawOriginal",2);h([m()],u.prototype,"configValid",2);h([m()],u.prototype,"configIssues",2);h([m()],u.prototype,"configSaving",2);h([m()],u.prototype,"configApplying",2);h([m()],u.prototype,"updateRunning",2);h([m()],u.prototype,"pluginUpdateRunning",2);h([m()],u.prototype,"applySessionKey",2);h([m()],u.prototype,"configSnapshot",2);h([m()],u.prototype,"configSchema",2);h([m()],u.prototype,"configSchemaVersion",2);h([m()],u.prototype,"configSchemaLoading",2);h([m()],u.prototype,"configUiHints",2);h([m()],u.prototype,"configForm",2);h([m()],u.prototype,"configFormOriginal",2);h([m()],u.prototype,"configFormDirty",2);h([m()],u.prototype,"configFormMode",2);h([m()],u.prototype,"configSearchQuery",2);h([m()],u.prototype,"configActiveSection",2);h([m()],u.prototype,"configActiveSubsection",2);h([m()],u.prototype,"channelsLoading",2);h([m()],u.prototype,"channelsSnapshot",2);h([m()],u.prototype,"channelsError",2);h([m()],u.prototype,"channelsLastSuccess",2);h([m()],u.prototype,"whatsappLoginMessage",2);h([m()],u.prototype,"whatsappLoginQrDataUrl",2);h([m()],u.prototype,"whatsappLoginConnected",2);h([m()],u.prototype,"whatsappBusy",2);h([m()],u.prototype,"nostrProfileFormState",2);h([m()],u.prototype,"nostrProfileAccountId",2);h([m()],u.prototype,"presenceLoading",2);h([m()],u.prototype,"presenceEntries",2);h([m()],u.prototype,"presenceError",2);h([m()],u.prototype,"presenceStatus",2);h([m()],u.prototype,"agentsLoading",2);h([m()],u.prototype,"agentsList",2);h([m()],u.prototype,"agentsError",2);h([m()],u.prototype,"sessionsLoading",2);h([m()],u.prototype,"sessionsResult",2);h([m()],u.prototype,"sessionsError",2);h([m()],u.prototype,"sessionsFilterActive",2);h([m()],u.prototype,"sessionsFilterLimit",2);h([m()],u.prototype,"sessionsIncludeGlobal",2);h([m()],u.prototype,"sessionsIncludeUnknown",2);h([m()],u.prototype,"archivedSessions",2);h([m()],u.prototype,"archivedSessionsLoading",2);h([m()],u.prototype,"archivedSessionsExpanded",2);h([m()],u.prototype,"cronLoading",2);h([m()],u.prototype,"cronJobs",2);h([m()],u.prototype,"cronStatus",2);h([m()],u.prototype,"cronError",2);h([m()],u.prototype,"cronForm",2);h([m()],u.prototype,"cronRunsJobId",2);h([m()],u.prototype,"cronRuns",2);h([m()],u.prototype,"cronBusy",2);h([m()],u.prototype,"workspaceNeedsSetup",2);h([m()],u.prototype,"onboardingPhase",2);h([m()],u.prototype,"onboardingData",2);h([m()],u.prototype,"onboardingActive",2);h([m()],u.prototype,"wizardActive",2);h([m()],u.prototype,"wizardState",2);h([m()],u.prototype,"showSetupTab",2);h([m()],u.prototype,"setupBarDismissed",2);h([m()],u.prototype,"setupProgress",2);h([m()],u.prototype,"setupCapabilities",2);h([m()],u.prototype,"setupCapabilitiesLoading",2);h([m()],u.prototype,"setupQuickDone",2);h([m()],u.prototype,"onboardingIntegrations",2);h([m()],u.prototype,"onboardingCoreProgress",2);h([m()],u.prototype,"onboardingExpandedCard",2);h([m()],u.prototype,"onboardingLoadingGuide",2);h([m()],u.prototype,"onboardingActiveGuide",2);h([m()],u.prototype,"onboardingTestingId",2);h([m()],u.prototype,"onboardingTestResult",2);h([m()],u.prototype,"onboardingConfigValues",2);h([m()],u.prototype,"onboardingProgress",2);h([m()],u.prototype,"allyPanelOpen",2);h([m()],u.prototype,"allyMessages",2);h([m()],u.prototype,"allyStream",2);h([m()],u.prototype,"allyDraft",2);h([m()],u.prototype,"allyUnread",2);h([m()],u.prototype,"allySending",2);h([m()],u.prototype,"allyWorking",2);h([m()],u.prototype,"allyAttachments",2);h([m()],u.prototype,"chatPrivateMode",2);h([m()],u.prototype,"privateSessions",2);h([m()],u.prototype,"dynamicSlots",2);h([m()],u.prototype,"sessionResources",2);h([m()],u.prototype,"sessionResourcesCollapsed",2);h([m()],u.prototype,"skillsLoading",2);h([m()],u.prototype,"skillsReport",2);h([m()],u.prototype,"skillsError",2);h([m()],u.prototype,"skillsFilter",2);h([m()],u.prototype,"skillEdits",2);h([m()],u.prototype,"skillsBusyKey",2);h([m()],u.prototype,"skillMessages",2);h([m()],u.prototype,"skillsSubTab",2);h([m()],u.prototype,"godmodeSkills",2);h([m()],u.prototype,"godmodeSkillsLoading",2);h([m()],u.prototype,"expandedSkills",2);h([m()],u.prototype,"rosterData",2);h([m()],u.prototype,"rosterLoading",2);h([m()],u.prototype,"rosterError",2);h([m()],u.prototype,"rosterFilter",2);h([m()],u.prototype,"expandedAgents",2);h([m()],u.prototype,"debugLoading",2);h([m()],u.prototype,"debugStatus",2);h([m()],u.prototype,"debugHealth",2);h([m()],u.prototype,"debugModels",2);h([m()],u.prototype,"debugHeartbeat",2);h([m()],u.prototype,"debugCallMethod",2);h([m()],u.prototype,"debugCallParams",2);h([m()],u.prototype,"debugCallResult",2);h([m()],u.prototype,"debugCallError",2);h([m()],u.prototype,"logsLoading",2);h([m()],u.prototype,"logsError",2);h([m()],u.prototype,"logsFile",2);h([m()],u.prototype,"logsEntries",2);h([m()],u.prototype,"logsFilterText",2);h([m()],u.prototype,"logsLevelFilters",2);h([m()],u.prototype,"logsAutoFollow",2);h([m()],u.prototype,"logsTruncated",2);h([m()],u.prototype,"logsCursor",2);h([m()],u.prototype,"logsLastFetchAt",2);h([m()],u.prototype,"logsLimit",2);h([m()],u.prototype,"logsMaxBytes",2);h([m()],u.prototype,"logsAtBottom",2);h([m()],u.prototype,"toasts",2);h([m()],u.prototype,"chatUserNearBottom",2);h([m()],u.prototype,"chatNewMessagesBelow",2);h([m()],u.prototype,"consciousnessStatus",2);h([m()],u.prototype,"trustTrackerData",2);h([m()],u.prototype,"trustTrackerLoading",2);h([m()],u.prototype,"guardrailsData",2);h([m()],u.prototype,"guardrailsLoading",2);h([m()],u.prototype,"guardrailsShowAddForm",2);h([m()],u.prototype,"secrets",2);h([m()],u.prototype,"secretsLoading",2);h([m()],u.prototype,"webFetchProvider",2);h([m()],u.prototype,"webFetchLoading",2);h([m()],u.prototype,"searchProvider",2);h([m()],u.prototype,"searchExaConfigured",2);h([m()],u.prototype,"searchTavilyConfigured",2);h([m()],u.prototype,"searchLoading",2);h([m()],u.prototype,"customTabs",2);h([m()],u.prototype,"customTabData",2);h([m()],u.prototype,"customTabLoading",2);h([m()],u.prototype,"customTabErrors",2);u=h([ns("godmode-app")],u);export{H as a,Ha as b,du as s};
|